diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index 4f4affe9..d589b6fa 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -1,4 +1,5 @@ find_package(PkgConfig) + add_subdirectory(openssl) add_subdirectory(libssh2) add_subdirectory(libgit2) @@ -7,6 +8,5 @@ add_subdirectory(cmark) add_subdirectory(lua) add_subdirectory(lpeg) add_subdirectory(scintilla) -add_subdirectory(scintillua) add_subdirectory(git) diff --git a/dep/scintilla/CMakeLists.txt b/dep/scintilla/CMakeLists.txt index 90b09cb0..6e142af7 100644 --- a/dep/scintilla/CMakeLists.txt +++ b/dep/scintilla/CMakeLists.txt @@ -1,4 +1,4 @@ -set(SCINTILLA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scintilla-3.6.0) +set(SCINTILLA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scintilla-3.10.6) add_library(scintilla ${SCINTILLA_DIR}/src/AutoComplete.cxx @@ -27,6 +27,7 @@ add_library(scintilla ${SCINTILLA_DIR}/src/Selection.cxx ${SCINTILLA_DIR}/src/Style.cxx ${SCINTILLA_DIR}/src/UniConversion.cxx + ${SCINTILLA_DIR}/src/UniqueString.cxx ${SCINTILLA_DIR}/src/ViewStyle.cxx ${SCINTILLA_DIR}/src/XPM.cxx ${SCINTILLA_DIR}/lexlib/Accessor.cxx @@ -61,3 +62,5 @@ target_link_libraries(scintilla set_target_properties(scintilla PROPERTIES AUTOMOC ON ) + +set(SCINTILLUA_LEXERS_DIR ${SCINTILLA_DIR}/lexlua CACHE INTERNAL "") diff --git a/dep/scintilla/scintilla-3.10.6/.hg_archival.txt b/dep/scintilla/scintilla-3.10.6/.hg_archival.txt new file mode 100644 index 00000000..27ec9d2a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/.hg_archival.txt @@ -0,0 +1,5 @@ +repo: bdf8c3ef2fb01ea24578e726337888e706d10b92 +node: ff65f37949a5b59e8893843549dba045639d361a +branch: LongTerm3 +latesttag: rel-3-10-6 +latesttagdistance: 1 diff --git a/dep/scintilla/scintilla-3.6.0/.hgeol b/dep/scintilla/scintilla-3.10.6/.hgeol similarity index 95% rename from dep/scintilla/scintilla-3.6.0/.hgeol rename to dep/scintilla/scintilla-3.10.6/.hgeol index 45aa5e0b..30e9ddae 100755 --- a/dep/scintilla/scintilla-3.6.0/.hgeol +++ b/dep/scintilla/scintilla-3.10.6/.hgeol @@ -22,8 +22,10 @@ **.vb = native **.d = native **.lua = native -**.rb = native +**.nim = native **.pl = native +**.rb = native +**.tcl = native **.txt = native **.pch = native **.hgeol = native diff --git a/dep/scintilla/scintilla-3.6.0/.hgignore b/dep/scintilla/scintilla-3.10.6/.hgignore similarity index 84% rename from dep/scintilla/scintilla-3.6.0/.hgignore rename to dep/scintilla/scintilla-3.10.6/.hgignore index 5e066955..3099a3a9 100644 --- a/dep/scintilla/scintilla-3.6.0/.hgignore +++ b/dep/scintilla/scintilla-3.10.6/.hgignore @@ -1,16 +1,20 @@ syntax: glob *.o *.a +*.asm *.lib *.obj +*.iobj *.pyc *.dll *.dylib *.framework *.pyd +*.exe *.exp *.lib *.pdb +*.ipdb *.res *.bak *.sbr @@ -34,9 +38,8 @@ win32/*.plist *.pbproj *.log *.xcbkptlist -*.xcscheme -*.xcworkspacedata *.xcuserstate +xcuserdata/ *.xcsettings xcschememanagement.plist .DS_Store @@ -51,6 +54,7 @@ Makefile.Release *_resource.rc moc_* *.pro.user +.qmake.stash ScintillaEdit.cpp ScintillaEdit.h ScintillaConstants.py @@ -58,3 +62,9 @@ ScintillaEditBase.intermediate.manifest ScintillaEdit.intermediate.manifest qt/*/Makefile cov-int +.vs +meson-private +meson-logs +build.ninja +.ninja* +compile_commands.json diff --git a/dep/scintilla/scintilla-3.6.0/.hgtags b/dep/scintilla/scintilla-3.10.6/.hgtags similarity index 78% rename from dep/scintilla/scintilla-3.6.0/.hgtags rename to dep/scintilla/scintilla-3.10.6/.hgtags index c9cad85a..99472d9d 100644 --- a/dep/scintilla/scintilla-3.6.0/.hgtags +++ b/dep/scintilla/scintilla-3.10.6/.hgtags @@ -112,3 +112,34 @@ a797ff255bdf2085f0475b9202527da6a16d507a rel-3-5-2 dea417bad80a9225d72b4f839ab04b1f7ffd936f rel-3-5-5 e9bfc7a0cb83a972e8bfa5dbaa8aabd359549b57 rel-3-5-6 49ce1d4c2dea737f1e4c92858921dd403a61cb20 rel-3-5-7 +87a4e0fa293ec1dc47d9d4d4288a139a5e240c6f rel-3-6-0 +59165fbb6b9d51efae82d13ce1c4471310b90bde rel-3-6-1 +d906ba5d62cbb79a3b25d29aa4dae3f3d1fdf22a rel-3-6-2 +e575024931f89fbc70e06d1faaf73a2e8721a2da rel-3-6-3 +d2d4928e3e6a3e79ed7dbfd949968d5fc9818424 rel-3-6-4 +afd67be6f0b141ba23be25ea1f472258bb4d976f rel-3-6-5 +bfdfb44eb77717778c7a3ac2c3726903e66c81b8 rel-3-6-6 +f9ff5b9b1a485d742fb7bfae14ba323a3f990663 rel-3-6-7 +13cdacbbe2515620b0f582c4c274b17cae06180c rel-3-7-0 +a7dfda6c85859a9aa9f5c4ae43af005d3b7ce5fb rel-3-7-1 +e02540a3097449da69003d37c116c9b2104e3448 rel-3-7-2 +e99b1a2bfbf808a12ec988bcab2121b6c4cbb556 rel-3-7-3 +535c34f64993f3ef7367e773950e22a37d2475be rel-3-7-4 +535c34f64993f3ef7367e773950e22a37d2475be rel-3-7-4 +0000000000000000000000000000000000000000 rel-3-7-4 +0000000000000000000000000000000000000000 rel-3-7-4 +ddcae5344fa5390b352c1075d01e95379e145b43 rel-3-7-4 +7c0d4e81e9388f87a648208b834f58516797be31 rel-3-7-5 +c534665d5d3434bef08e400a93bfc5db8bb2d548 rel-3-7-6 +c534665d5d3434bef08e400a93bfc5db8bb2d548 rel-3-7-6 +0000000000000000000000000000000000000000 rel-3-7-6 +0000000000000000000000000000000000000000 rel-3-7-6 +caeb7b0e4db6d0ec81f1aaa78853eca6425257ed rel-3-7-6 +7c78091d5d6c1cc51b7633f6ef2ba5a4fb8ed3de rel-3-8-0 +68325956b46762053a471358508f2a4614aceb48 rel-3-10-0 +28b920189a7c81ef935c12793427cccbea313bb8 rel-3-10-1 +8b888bf05fe312a60fd249dcfa824744547c5dde rel-3-10-2 +233bf37d3bec6467ca3c81ad27129a5dffb28d42 rel-3-10-3 +0c0ea9d3c2df26a5f363250897885ab9d59613e3 rel-3-10-4 +59cfb7d5c8eed0f3498e982a92993801e7d28546 rel-3-10-5 +08973e00da9c1ed614516675e9f56c384483befa rel-3-10-6 diff --git a/dep/scintilla/scintilla-3.10.6/BACKPORTING b/dep/scintilla/scintilla-3.10.6/BACKPORTING new file mode 100644 index 00000000..0a903735 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/BACKPORTING @@ -0,0 +1,472 @@ +Overview +======== + +The LongTerm3 branch gets nearly all of its updates from default via +backporting. The process is simple: + + hg update LongTerm3 + hg graft -e [changeset] + +This grafts (or cherry-picks) [changeset] from default into LongTerm3. The '-e' +option allows for editing the commit message. Backported commit messages usually +have the form: + + Backport: [original commit message] + + Backport of [revision]:[changeset]. + +Any backport-specific additions, modifications, or deletions from the original +changeset should be mentioned in the new message. + +Note: the '-e' option also gives you a chance to compile and/or test any adverse +effects produced by the graft prior to commit. Any changes made to files before +committing will reflect in the final graft. + +In order to back out of a graft: + + hg rollback + hg revert --all [--no-backup] + +This can only be done ONCE, and affects the most recent graft, so make sure you +test any questionable grafts first before attempting another one. + +Testing Backports +================= + +Backporting a change is one thing, but ensuring the backport was successful is +another. Currently, the measure of "success" is whether Scintilla compiles on +all platforms after a backported change. This process can be automated using hg +hooks and the "check.mak" makefile. By adding the following to .hg/hgrc: + + [hooks] + pretxncommit.adddeps = test -z "`hg status | grep '^A' | grep '\.\(h\|cxx\)$'`" || make -f check.mak deps + pretxncommit.compile = make -f check.mak + +whenever a backported change is about to be committed, hg runs "check.mak", +which attempts to compile Scintilla on all platforms. If successful, the commit +is made. Otherwise, the commit fails and changes must be made before attempting +to commit again. + +The file "check.mak" is designed to run on a Linux machine that has +cross-compilers for Win32 and Mac OSX. It does not necessarily produce any +binary builds of Scintilla that can be used -- it just ensures Scintilla can be +built without compile errors. How to obtain a set of cross-compilers is beyond +the scope of this document. At the time of writing, GCC 5.4 is used exclusively. + +Not only does "check.mak" perform platform compile checks, but it also has rules +for manually running Scintilla's unit tests (which take too long to run +automatically as a pre-commit hook), creating a LongTerm3 release archive set, +and uploading documentation to the LongTerm3 website on SourceForge: + + make test + make zip + make upload + +The last rule requires user credentials. + +Backport Status +=============== + +This section mentions all upstream changesets that have either NOT been +backported, beginning at 6289:4c1084a571ff (Starting 3.x long term maintenance +branch), or have information worth noting. + +6290:2378244bf3c7 Converted to Automatic Reference Counting. +6291:31466630bccc Using instancetype for constructors. +6292:7f58802368f4 Using modern Objective C literals and indexing. +6294:e1301b1d2321 Use property dot syntax. +6295:57988f82bf71 Indented consistently by using astyle. + Cocoa platform only. + None of these are backported since I am unsure if they are supported in C++11. + Despite finding references to ARC and some Modern Objective-C dating back to + 2013ish, I also see that Clang 4.0 introduced support for some of this. + However, Clang 4.0 was released in early 2017. + +6304:b6cf154fe8d0 SciTE change log. + Not backported, as this applies only to SciTE. + +6309:2d4cb83e9297 Back down from gnu++17 to gnu++14 so can build with g++ on current Ubuntu. + Not backported since only C++11 is supported. + +6317:0f15d772bceb SciTE change log. +6319:a3b66b2525e7 SciTE change log. + Not backported, as these apply only to SciTE. + +6328:3c87cf6d2599 Update IDocument for version 4. Drop IDocumentWithLineEnd interface to just have IDocument but with all the methods from IDocumentWithLineEnd. This removes version checking (for now). Use dvRelease4 ID. Drop mask argument to StartStyling. + Not backported since IDocument and ILexer interfaces should not change once + published according to Neil. Since the only substantial change is changing the + StartStyling() API, it does not seem worth creating a new IDocument4 + interface with an option mask argument. It would likely cause compiler issues + too. + +6329:6468941ee017 Updated documentation to match changes to IDocument and ILexer. + Not backported since IDocument has not been changed. + It may be worth committed a modification of the first diff though, if 3.8.0 + ends up using 64-bit types for Sci_Position and Sci_PositionU. + +6330:59f341b22087 Deprecate single phase drawing. +6333:320418de6275 Clean whitespace. + Not backported since the curses platform relies on single-phase drawing for + now. + +6345:faecbd0078e5 Merge Ilexer and ILexerWithSubStyles into ILexer4 to avoid need for version checking in 4.0. Use lvRelease4 ID. + Partially backported with 6346:72bd27f81477 minus ILexer4, since the ILexer4 + interface being added cannot co-exist with the existing ILexer interface. + (LexerModule.h uses a single typedef.) + +6357:96232b746342 SciTE change log. +6361:69fddf8f8a15 SciTE changelog. + Not backported, as these apply only to SciTE. + +6372:cae69b34b92e Preparing for the 4.0.0 release. +6374:ec8e68de4ddb Delaying a day due to change with Lua in SciTE. +6375:4aaf170db91a Added tag rel-4-0-0 for changeset ec8e68de4ddb + Not backported, since this is LongTerm3. + +6394:dae03efac67d Update Xcode project files automatically for Xcode 9. + Not backported, since Xcode 9 was released in late 2017. + +6403:bd5c44cb0ab8 Updates for 4.0.1 release. +6404:e04bd73927ea Added tag rel-4-0-1 for changeset bd5c44cb0ab8 + Not backported, since this is LongTerm3. + +6407:f60756d22ff3 Fix bad formatting. + Not backported, as the bad formatting was not merged into the previous + backport. + +6409:c6a13f6eac24 Disable the animated find indicator on macOS 10.13 where it fails. +6410:29e81816b889 Change log. + Not backported, since macOS 10.13 was released late 2017 and + NSAppKitVersionNumber10_12_2 is probably not defined on earlier macOSs. I + cannot find a good way to #ifdef around it. + +6411:96becb885ce4 Updates for 4.0.2. +6412:ad210d76378f Added tag rel-4-0-2 for changeset 96becb885ce4 +6417:f78045efae20 Add section for 4.0.3 and move posr-4.0.2 items into it. + Not backported, since this is LongTerm3. + +6425:73343682cbda Start of bidirectional code - implement SCI_SETBIDIRECTIONAL. +6426:0f7f5a382dbb Add ENABLE_BIDIRECTIONAL option to make files. + Not backported, since it is unknown whether or not this feature will have any + C++14 or C++17 features in it. + +6432:b25c127aa6c5 Ensure build allows C++17. ARC setting is matching same setting at different scope so no effect. +6433:231ac99e1fdc Allow C++17 in all build and project files. +6435:5dd1b26df75f Replace Sci::clamp with C++ standard std::clamp function. std::clamp is from C++17. + Not backported, since only C++11 is supported. + +6438:f635874b303b SciTE changelog. +6439:0e036d7fa960 SciTE changelog. + Not backported, as these apply only to SciTE. + +6440:a1731ae83d2a Disable animated find indicator on macOS 10.12 as it causes drawing failures. + Not backported, since macOS 10.13 was released late 2017 and + NSAppKitVersionNumber10_12_2 is probably not defined on earlier macOSs. I + cannot find a good way to #ifdef around it. + +6446:f7abec3bbc7a SciTE change log. +6447:44ff2195a202 SciTE change log. + Not backported, as these apply only to SciTE. + +6450:7295a806b4c4 Updating for 4.0.3. + Not backported, since this is LongTerm3. + +6452:1bf8b7c50995 Update Cocoa test app to Xcode 9.2 settings. + Not backported, since Xcode 9 was released in late 2017. + +6453:71a51a9a6048 Added tag rel-4-0-3 for changeset 1bf8b7c50995 + Not backported, since this is LongTerm3. + +6454:c25d3cb37f7d SciTE change log. +6455:b9e278677527 SciTE changelog. +6459:0aef625a6ab0 SciTE changelog. + Not backported, as these apply only to SciTE. + +6460:b4500f60b593 Added string_view to order. + Not backported, since only C++11 is supported. + +6464:fe5f45df61ce SciTE change log. + Not backported, as this applies only to SciTE. + +6465:cdfd8b285278 Update to c++17 so make_unique is available. +6476:59bafd0d2f77 Updated requied compiler versions. + Not backported, since only C++11 is supported. + +6632:8399b7723701 Change standard flag on MacOS as Xcode clang doesn't yet like c++17. + Not backported, since only C++11 is supported. + +6643:ebbb4e5aaf93 Update unit test Visual C++ builds to Visual C++ 2017 with /std:c++latest. + Not backported, since only C++11 is supported. + +6661:d03cd726962c New Xcode 9.3 so ran the updater which turned on some warnings and it fiddled with the projects and schemes. +6662:3c001296c0a4 Reverted #6488 as Xcode clang 9.1 now likes --std=c++17. +6664:0f1db0d9a0a6 Standardize on --std=c++17, avoiding GNU extensions and enabling clang 6.0. +6666:9561714c303b Updated due to allowing C++17 code now. + Not backported, since only C++11 is supported. + +6676:d48bdae67b33 Updates for 4.0.4. +6678:95fdb4c19b33 Added tag rel-4-0-4 for changeset d48bdae67b33 + Not backported, since this is LongTerm3. + +6680:0161abb24da4 Bug [#2008]. Avoid warning unsigned >= 0. + Not backported, since it is unknown whether or not this feature will have any + C++14 or C++17 features in it. + +6689:41dbff5a4813 Make method const as it is just a reader. + Not backported, since return value depends on interface, which is different + from single interface in 4.x. + +6746:61e16d5c73cf Change log for SciTE for macOS. +6749:85d99f7c5c6d SciTE change log. +6757:56a46ce2e0b4 SciTE change log. +6779:d5508bacbfd4 SciTE change log. + Not backported, as these apply only to SciTE. + +6786:68c8592fe333 Specify type of std::clamp to avoid casting arguments. + Not backported, since std::clamp is C++17 and Sci::clamp is not typed. + +6922:d97cb73c8da7 SciTE change log. + Not backported, as this applies only to SciTE. + +6924:b9ab83221b03 Updates for 4.0.5. +6931:87dc832e3c94 Added tag rel-4-0-5 for changeset b9ab83221b03 +6932:cc470382029e Add stub for next release. + Not backported, since this is LongTerm3. + +6936:c98e38d29c46 Include in tests in case needed. +6937:5200f56c1494 Include to allow future use in Platform interface and Unicode. +6941:8a34096cd01e Modernize Platform.h (4) - update Surface to use string_view for text arguments. + Not backported, since only C++11 is supported. + +6942:adbc779db70a Modernize Platform.h (5) - remove ElapsedTime. + Not backported, since it was already removed in changeset 6876:a057d12cc6b9. + +6943:39f2ec3334c1 Use string_view for UniConversion functions. + Not backported, since only C++11 is supported. + +6946:959308676456 Fix warning. + Not backported, since it applies to a previous changeset not backported. + +6947:fb52ef66ed47 Remove dependency on StringCopy and simplify constructor. + Not backported, since only C++11 is supported. + +6949:7747dc29d8a0 Fix warnings in debug assertions. + Not backported, since it applies to a previous changeset not backported. + +6950:682b634df52b Encapsulate WideCharToMultiByte and MultiByteToWideChar to simplify calling sites and standardize use of options. + Not backported, since only C++11 is supported. + +6951:b2a17a08a1f8 Replace ELEMENTS with std::size and drop inclusion of StringCopy.h. + Backported only the latter bit since C++11 does not have std::size. + +6961:d2563c53ab4c SciTE change log. + Not backported, as this applies only to SciTE. + +6962:514fde42ccbf Draw invalid bytes in DBCS when detected as blobs in a similar way to UTF-8. + Backported, but replaced std::string_view usage with const char* and size_t + components. + +6964:d7ec2cdbcd16 If decoding DBCS text fails, use the MacRoman encoding to ensure something is visible. + Not backported, as it makes use of a previous changeset not backported and is + not easy for me to support if I patched it. + +6970:b78f7643ae73 Add definitions for bidirectional support to Platform.h and provide empty implementations for each platform. +6971:e51e7a972b89 Implement bidirectional mode bidiL2R for DirectDraw on Win32. +6972:f30d0a228046 Update for bidirectional support. +6973:7570322b0219 Added credits. +7006:a6d3cefd4f79 Add TabPositionAfter method to IScreenLine as this calculation is needed on each platform and it allows extension to custom tab stops. + Not backported, since previous bidirectional support was not backported. + +7009:e1100c6feaaf Add function to find a UTF-16 position in a UTF-8 string. + Not backported, since it is only used in bidirectional support at the moment. + +7011:23a98ab36601 Define IScreenLineLayout as the main interface for implementing bidirectional features by platform code. +7012:5f4011e010f9 Implement IScreenLineLayout for Cocoa Core Text as ScreenLineLayout. +7013:0d86879c5ca5 Make virtual space selections visible in bidirectional mode. +7014:39d3e00c381a UpdateBidiData is called by EditView but doesn't use any EditView fields so make it static. +7015:6a7459cd08f9 Updated to mention bidirectional works on Cocoa. + Not backported, since previous bidirectional support was not backported. + +7026:4377a8d710e1 Update Cocoa enumerations to current names instead of deprecated names. + Not backported, since many of these enumerations are not available for older SDKs. + +7027:b71248119e8b Remove compile-time ENABLE_BIDIRECTIONAL option as bidirectional feature is now controlled completely at run-time. + Not backported, since previous bidirectional support was not backported. + +7033:5da90aad11da Updates for 4.1.0. + Not backported, since this is LongTerm3. + +7034:0dc20d87a4f9 Note that Cocoa also supports bidirectional text. + Not backported, since previous bidirectional support was not backported. + +7055:bb3c92f403f7 Added tag rel-4-1-0 for changeset 0dc20d87a4f9 +7059:455f134efbc1 SciTE change log. +7061:d744568dfaa5 SciTE change log. + Not backported, since this is LongTerm3. + +7063:0d5edc93e280 Optional indexing of line starts in UTF-8 documents by UTF-32 code points and + Backported, but replaced std::string_view usage with const char* and size_t + components. Also used const_cast where appropriate to fix compile errors. + +7066:ee645426b872 Add SciTE credit. +7067:43101fb47a25 SciTE change log. + Not backported, since this is LongTerm3. + +7069:e65cfc5348a5 Change lifetime of textLayout for bidirectional so it is always released in +7071:d9e28bcc6cf9 Bug [#2030]. Fix Win32 crash setting technology to default after bidirectional + Not backported, since previous bidirectional support was not backported. + +7074:b190647b5084 SciTE change log. +7079:744cd6e004ae Updates for 4.1.1. +7080:59fdd1f4d5cd Updated change list for 4.1.1. +7082:058cd4b189e6 Added tag rel-4-1-1 for changeset 892c361b3969 +7083:d87b627094ad Fix version number. +7084:cd27559c2a65 Moved tag because of doc fix. +7085:fcf47c352832 Updated outdated text. +7086:c8643589ba1d Added tag rel-4-1-1 for changeset fcf47c352832 +7091:575636ffe226 Added section for next release. +7095:58524eea6d35 SciTE change log. +7101:f4988dfccc31 Updates for 4.1.2 release. +7103:20455b6997e3 Added tag rel-4-1-2 for changeset 927e7d62e917 + Not backported, since this is LongTerm3. + +7104:9b7f24b1b150 Fix crash when particular patterns of invalid UTF-8 led to failure to create a + Not backported, since previous bidirectional support was not backported. + +7109:29f0ca6d2d1b Improve performance of Editor::RangeText by avoding per-character checks. + Backported, but with const_cast to file compile error. + +7121:2f5d50043861 Bug [#2055]. Use dark info bar background when system is set to Dark Appearance. + Not backported, since its parent changeset 7026:4377a8d710e1 was not + backported. + +7172:05e2d46ae4c0 SciTE change log. +7177:08ccc2c490c2 SciTE change log. + Not backported, since this is LongTerm3. + +7187:29c12794f87e Stop specifying -std:c++latest as that is no longer needed to enable C++17 + Not backported, since only C++11 is supported. + +7194:b428bfb5a730 Bug [#2022]. Fix incorrect horizontal offset on macOS 10.14 Mojave. + Not backported, since I have no easy way to test if this compiles. I'd also + like to assume LongTerm3 clients are only interested in earlier versions of + macOS. + +7197:1484a537b380 Updates for version 4.1.3. +7198:974d0f564d0d Added tag rel-4-1-3 for changeset 1484a537b380 + Not backported, since this is LongTerm3. + +7250:f77887e669fc SciTE history. + Not backported, since this is LongTerm3. + +7280:9cf6a15d6c85 Use noexcept and constexpr where possible and reasonable. + Backported, but removed use of constexpr, since it is a >= C++14 feature for + non-return-only functions. + +7281:4cb7fa260e77 SciTE changelog. +7284:b52eed62fda9 SciTE change log. + Not backported, since this is LongTerm3. + +7289:3f930310a0de Use constexpr where reasonable and move groups of static functions into unnamed namespace. + Backported, but removed some instances of constexpr, since it is a >= C++14 + feature for non-return-only functions + +7290:07b4e4192bb2 Updated version number for release. +7292:20a944185079 Added tag rel-4-1-4 for changeset cd35899fef5e + Not backported, since this is LongTerm3. + +7293:3d4c60be1963 Update download sizes. + Not backported, since this is not applicable. + +7315:57ea0255c8aa Avoid hangs in idle styling modes caused by high-priority idle work styling. + Backported, but removed some instances of constexpr, since it is a >= C++14 + feature for non-static data members. + +7319:6db11117d56f Use noexcept where allowed, not inherited from base class, and not a COM method. +7320:304d26d7137f Minor warnings fixed - uninitialized, nullptr, type agreement, avoid casts. + Backported, but without the C++17 multi-byte helper functions from a previous + changeset. + +7322:b79d68be7e96 Credit for SciTE change. + Not backported, since this is LongTerm3. + +7325:6148329fb2f3 Implement WStringFromUTF8 to simplify code that creates wstring objects for regular expressions and calling the Win32 API. + Backported, but replaced std::string_view usage with const char* and size_t + components. Also used #ifdef instead of C++17 `if constexpr` at suggestion of + Neil. + +7326:2f9b5e1c97ae Use noexcept where sensible. Rename UTF8 string_view parameters for clarity. + Backported, but without the variable renames, since they are not applicable. + +7328:521b1e23bfe2 Fix warnings from MSVC Code Analysis. + Backported, but without C++17 std::size and `SymbolValue() = default` instead + of `SymbolValue() noexcept = default`, since the latter causes a compile + error. + +7329:2662ef098d93 Use generic versions of ceil, floor, round, lround, trunc from . + Backported, but without std::round and std::lround, since older Mac OSX SDKs + may not have them. + +7332:982c5f3833bb Simplify with range for. + Not backported, since std::string_view from C++17 is not used. + +7333:3f381a0bbeff Use std::make_unique. + Not backported, since std::make_unique is not in C++11. + +7337:eeaddec85ecc Use size_t for consistency and to avoid casts. + Not backported, since std::string_view from C++17 is not used. + +7349:0b7800a19ed3 Updated ScintillaFramework internationalization to fix warnings from Xcode 10.2. + Backported, but only .cxx file reordering. Internationalization was not + backported in case it's not compatible with earlier versions of Xcode. + +7350:0b319d73d317 Updated ScintillaTest internationalization to fix warnings from Xcode 10.2. + Not backported in case it's not compatible with earlier versions of Xcode. + +7392:2832adedd0f4 Feature [feature-requests:#1259]. Add SCI_SETCHARACTERCATEGORYOPTIMIZATION API + Backported, but with added includes for Sci::clamp(). + +7402:751b76b567f9 Move UniqueStringCopy into its own source file UniqueString.cxx to hide the implementation. +7409:a70a4ee51448 Rename FontNames to UniqueStringSet and move into UniqueString. + Backported, but with an alternative to C++17's string_view. + +7411:c3bc2e4277b2 Make dependencies scripts work when called from scite/scripts/RegenerateSource.py. + Not backported, since it is for SciTE and it requires Python 3.x. + +7414:599d698f70bf Use noexcept in CaseConvert as well as std::string_view::copy. + Backported, but without std::string_view::copy. + +7416:76d7aeac3271 Updated required Python version due to differences in how imports work in 2.7. + Not backported, since it is for SciTE and it requires Python 3.x. + +7417:bbef7c52aecf Use views for input string parameters as that allows calling with more varied values and can avoid allocations. +7418:bf93fe7f0940 Bug [#2093]. Use wstring_view to unify adding text and eliminate AddCharUTF16. + Not backported, since a previous commit to use C++17's std::string_view was + not backported. + +7423:2e2cf21cee0b Bug [#2093]. Remove restrictions on IME input length. + Not backported, since the lack of a previous backport still references + maxLenInputIME. + +7425:466a7bd45f06 Preparing for 4.1.5 release. +7427:72074cd809c5 Added 4.1.5 blurb. +7428:bebdebd489c6 Added tag rel-4-1-5 for changeset 72074cd809c5 +7430:6a6bf370ae9f Removed tag rel-4-1-5 +7431:fcecd4a96700 Added tag rel-4-1-5 for changeset 6a6bf370ae9f + Not backported, since this is LongTerm3. + +7479:be5a36866340 Switch from /std:c++latest to /std:c++17 as Visual C++ 2019 now includes some + Not backported, since only C++11 is supported. + +7480:1b7760e143911 SciTE change log. + Not backported, since this is LongTerm3. + +7486:a99fa007805f Feature [feature-requests:#1280]. Lexer added for X12. + Backported, but with LexerX12::Terminator struct definition not having default + values, which is a C++14 feature. + +7550:fb4a24eb8aec Preparing for 4.1.6 release. +7551:4781ee00f04f Clarified large file support. +7559:6ccb029fd955 Updated release date for 4.1.6. +7561:0e040330cb60 Added tag rel-4-1-6 for changeset 6ccb029fd955 + Not backported, since this is LongTerm3. diff --git a/dep/scintilla/scintilla-3.10.6/CONTRIBUTING b/dep/scintilla/scintilla-3.10.6/CONTRIBUTING new file mode 100644 index 00000000..cf70eafa --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/CONTRIBUTING @@ -0,0 +1,20 @@ +Fixes should be posted to the Bug Tracker +http://sourceforge.net/p/scintilla/bugs/ + +Features should be posted to the Feature Request Tracker +http://sourceforge.net/p/scintilla/feature-requests/ + +Either send unified diffs (or patch files) or zip archives with whole files. +Mercurial patch files are best as they include author information and commit +messages. + +Questions should go to the scintilla-interest mailing list +https://groups.google.com/forum/#!forum/scintilla-interest + +Code should follow the guidelines at +http://www.scintilla.org/SciCoding.html + +Do not use SourceForge's Merge Request mechanism or message sending +feature as no one is monitoring these. +The neilh @ scintilla.org account receives much spam and is only checked +occasionally. Almost all Scintilla mail should go to the mailing list. \ No newline at end of file diff --git a/dep/scintilla/scintilla-3.10.6/License.txt b/dep/scintilla/scintilla-3.10.6/License.txt new file mode 100644 index 00000000..47c79265 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/License.txt @@ -0,0 +1,20 @@ +License for Scintilla and SciTE + +Copyright 1998-2003 by Neil Hodgson + +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation. + +NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/dep/scintilla/scintilla-3.10.6/LongTermDownload.html b/dep/scintilla/scintilla-3.10.6/LongTermDownload.html new file mode 100644 index 00000000..dc398064 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/LongTermDownload.html @@ -0,0 +1,73 @@ + + + + + + + + + + Download Scintilla + + + + + + + + +
+ Scintilla icon + + Download + Scintilla +
+ + + + +
+ + Windows   + + GTK+/Linux   + +
+

+ Download. +

+

+ This page is for the LongTerm3 branch of Scintilla which avoids depending on C++14 or later features. + Compilers as old as GCC 4.8, MSVC 2015 (theoretically), and Clang 3.4 are supported. +

+

+ The license for using Scintilla is similar to that of Python + containing very few restrictions. +

+

+ Release 3.10.6 +

+

+ Source Code +

+ The source code package contains all of the source code for Scintilla but no binary + executable code and is available in +
    +
  • zip format commonly used on Windows
  • +
  • tgz format commonly used on Linux and compatible operating systems
  • +
+ Instructions for building on both Windows and Linux are included in the readme file. +

+ Previous versions can be downloaded from the history + page. +

+

+ Also available from Mercurial: +

+
+    hg clone http://hg.code.sf.net/p/scintilla/code scintilla
+    cd scintilla && hg update LongTerm3
+    
+ + diff --git a/dep/scintilla/scintilla-3.6.0/README b/dep/scintilla/scintilla-3.10.6/README similarity index 64% rename from dep/scintilla/scintilla-3.6.0/README rename to dep/scintilla/scintilla-3.10.6/README index 9980cdcf..45e4ef84 100644 --- a/dep/scintilla/scintilla-3.6.0/README +++ b/dep/scintilla/scintilla-3.10.6/README @@ -6,9 +6,11 @@ To build SciTE, Scintilla must first be built. *** GTK+/Linux version *** -You must first have GTK+ 2.0 or later and GCC (4.1 or better) installed. -GTK+ 1.x will not work. +You must first have GTK+ 2.24 or later and GCC (4.8 or better) installed. +Clang may be used by adding CLANG=1 to the make command line. Other C++ compilers may work but may require tweaking the make file. +Either GTK+ 2.x or 3.x may be used with 2.x the default and 3.x +chosen with the make argument GTK3=1. To build Scintilla, use the makefile located in the scintilla/gtk directory cd scintilla/gtk @@ -18,7 +20,7 @@ To build Scintilla, use the makefile located in the scintilla/gtk directory To build and install SciTE, use the makefile located in the scite/gtk directory cd scite/gtk make - make install + sudo make install This installs SciTE into $prefix/bin. The value of $prefix is determined from the location of Gnome if it is installed. This is usually /usr if installed @@ -30,7 +32,7 @@ properties file is installed at $prefix/share/scite/SciTEGlobal.properties. The language specific properties files are also installed into this directory. To remove SciTE - make uninstall + sudo make uninstall To clean the object files which may be needed to change $prefix make clean @@ -40,19 +42,20 @@ The current make file only supports static linking between SciTE and Scintilla. *** Windows version *** -A C++ compiler is required. Visual Studio 2010 is the development system -used for most development although TDM Mingw32 4.7.1 is also supported. +A C++ 11 compiler is required. +Visual Studio 2015 is the development system used for most development +although Mingw32 4.8 is also supported. To build Scintilla, make in the scintilla/win32 directory cd scintilla\win32 GCC: mingw32-make -VS .NET: nmake -f scintilla.mak +Visual C++: nmake -f scintilla.mak cd ..\.. To build SciTE, use the makefiles located in the scite/win32 directory cd scite\win32 GCC: mingw32-make -VS .NET: nmake -f scite.mak +Visual C++: nmake -f scite.mak An executable SciTE will now be in scite/bin. @@ -65,3 +68,22 @@ Only Scintilla will build with GTK+ on Windows. SciTE will not work. To build Scintilla, make in the scintilla/gtk directory cd scintilla\gtk mingw32-make + +*** macOS Cocoa version *** + +Xcode 8 may be used to build Scintilla on macOS. + +There is no open source version of SciTE for macOS but there is a commercial +version available through the App Store. + +To build Scintilla, run xcodebuild in the scintilla/cocoa/ScintillaFramework directory + cd cocoa/ScintillaFramework + xcodebuild + +*** Qt version *** + +See the qt/README file to build Scintilla with Qt. + +*** Curses version *** + +See the curses/README.md file to build Scintilla with curses. diff --git a/dep/scintilla/scintilla-3.6.0/bin/__init__.py b/dep/scintilla/scintilla-3.10.6/bin/__init__.py similarity index 100% rename from dep/scintilla/scintilla-3.6.0/bin/__init__.py rename to dep/scintilla/scintilla-3.10.6/bin/__init__.py diff --git a/dep/scintilla/scintilla-3.6.0/bin/empty.txt b/dep/scintilla/scintilla-3.10.6/bin/empty.txt similarity index 100% rename from dep/scintilla/scintilla-3.6.0/bin/empty.txt rename to dep/scintilla/scintilla-3.10.6/bin/empty.txt diff --git a/dep/scintilla/scintilla-3.10.6/check.mak b/dep/scintilla/scintilla-3.10.6/check.mak new file mode 100644 index 00000000..184c8230 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/check.mak @@ -0,0 +1,214 @@ +# Copyright 2018-2019 Mitchell mitchell.att.foicica.com. See License.txt. +# This makefile is used only for catching compile and test errors when +# backporting fixes and features from the main branch of Scintilla. It likely +# will not produce compiled targets that can be used by a Scintilla-based +# application. +# Usage: make -f check.mak + +.SUFFIXES: .cxx .c .o .h .a + +INCLUDEDIRS = -Iinclude -Isrc -Ilexlib +CC = gcc +CXX = g++ +AR = ar +CLANG_CC = clang --gcc-toolchain=$(shell pwd)/gcc/4.8.1 +CLANG_CXX = clang++ --gcc-toolchain=$(shell pwd)/gcc/4.8.1 +CFLAGS = -pedantic -Wall +CXXFLAGS = -std=c++11 -pedantic -pedantic-errors -DSCI_LEXER $(INCLUDEDIRS) \ + -DNDEBUG -Os -Wall +CROSS_WIN32 = i686-w64-mingw32- +CROSS_OSX = i386-apple-darwin9- +LINUX_CC = $(CC)-4.8 +LINUX_CXX = $(CXX)-4.8 +ifndef GTK3 + GTK_CFLAGS = $(shell pkg-config --cflags gtk+-2.0) +else + GTK_CFLAGS = $(shell pkg-config --cflags gtk+-3.0) +endif + +base_src_objs = AutoComplete.o CallTip.o CaseConvert.o CaseFolder.o \ + Catalogue.o CellBuffer.o CharClassify.o ContractionState.o \ + DBCS.o Decoration.o Document.o EditModel.o Editor.o EditView.o \ + ExternalLexer.o Indicator.o KeyMap.o LineMarker.o MarginView.o \ + PerLine.o PositionCache.o RESearch.o RunStyles.o \ + ScintillaBase.o Selection.o Style.o UniConversion.o \ + ViewStyle.o UniqueString.o XPM.o +base_lexlib_objs = Accessor.o CharacterCategory.o CharacterSet.o LexerBase.o \ + LexerModule.o LexerNoExceptions.o LexerSimple.o \ + PropSetSimple.o StyleContext.o WordList.o +base_lexer_objs = $(addsuffix .o,$(basename $(sort $(notdir $(wildcard lexers/Lex*.cxx))))) + +win32_src_objs = $(addprefix win32/, $(base_src_objs)) +win32_lexlib_objs = $(addprefix win32/, $(base_lexlib_objs)) +win32_lexer_objs = $(addprefix win32/, $(base_lexer_objs)) +win32_plat_objs = win32/PlatWin.o win32/ScintillaWin.o win32/ScintillaDLL.o \ + win32/HanjaDic.o +cocoa_src_objs = $(addprefix cocoa/, $(base_src_objs)) +cocoa_lexlib_objs = $(addprefix cocoa/, $(base_lexlib_objs)) +cocoa_lexer_objs = $(addprefix cocoa/, $(base_lexer_objs)) +cocoa_plat_objs = cocoa/PlatCocoa.o cocoa/ScintillaCocoa.o cocoa/ScintillaView.o +gtk_src_objs = $(addprefix gtk/, $(base_src_objs)) +gtk_lexlib_objs = $(addprefix gtk/, $(base_lexlib_objs)) +gtk_lexer_objs = $(addprefix gtk/, $(base_lexer_objs)) +gtk_plat_cc_objs = gtk/scintilla-marshal.o +gtk_plat_cxx_objs = gtk/PlatGTK.o gtk/ScintillaGTK.o \ + gtk/ScintillaGTKAccessible.o +gtk_src_objs_clang = $(addprefix gtk/clang-, $(base_src_objs)) +gtk_lexlib_objs_clang = $(addprefix gtk/clang-, $(base_lexlib_objs)) +gtk_lexer_objs_clang = $(addprefix gtk/clang-, $(base_lexer_objs)) +gtk_plat_cc_objs_clang = $(addprefix gtk/clang-, $(notdir $(gtk_plat_cc_objs))) +gtk_plat_cxx_objs_clang = $(addprefix gtk/clang-, $(notdir $(gtk_plat_cxx_objs))) +curses_src_objs = $(addprefix curses/, $(base_src_objs)) +curses_lexlib_objs = $(addprefix curses/, $(base_lexlib_objs)) +curses_lexer_objs = $(addprefix curses/, $(base_lexer_objs)) +curses_plat_objs = curses/ScintillaCurses.o +curses_src_objs_clang = $(addprefix curses/clang-, $(base_src_objs)) +curses_lexlib_objs_clang = $(addprefix curses/clang-, $(base_lexlib_objs)) +curses_lexer_objs_clang = $(addprefix curses/clang-, $(base_lexer_objs)) +curses_plat_objs_clang = $(addprefix curses/clang-, $(notdir $(curses_plat_objs))) + +all: | /tmp/scintilla + $(MAKE) -C $| -f check.mak -j8 bin/scintilla_win32.a bin/scintilla_cocoa.a \ + bin/scintilla_gtk.a bin/clang-scintilla_gtk.a bin/scintilla_curses.a \ + bin/clang-scintilla_curses.a qt qt-clang +/tmp/scintilla: + cp -rs `pwd` $@ + cp -r $@/qt $@/qt-clang + mkdir -p $@/gcc/4.8.1/include/c++/4.8.1 + cp -rs /usr/include/c++/4.8.1/* $@/gcc/4.8.1/include/c++/4.8.1 + cp -rs /usr/include/x86_64-linux-gnu/c++/4.8/* $@/gcc/4.8.1/include/c++/4.8.1 + mkdir -p $@/gcc/4.8.1/lib/gcc/x86_64-linux-gnu/4.8.1 + cp -rs /usr/lib/gcc/x86_64-linux-gnu/4.8.1/* \ + $@/gcc/4.8.1/lib/gcc/x86_64-linux-gnu/4.8.1/ + +# Windows platform objects. +bin/scintilla_win32.a: $(win32_src_objs) $(win32_lexlib_objs) \ + $(win32_lexer_objs) $(win32_plat_objs) + $(CROSS_WIN32)$(AR) rc $@ $^ + touch $@ +$(win32_src_objs): win32/%.o: src/%.cxx +$(win32_lexlib_objs): win32/%.o: lexlib/%.cxx +$(win32_lexer_objs): win32/%.o: lexers/%.cxx +$(win32_src_objs) $(win32_lexlib_objs) $(win32_lexer_objs): + $(CROSS_WIN32)$(CXX) -c $(CXXFLAGS) $< -o $@ +$(win32_plat_objs): win32/%.o: win32/%.cxx + $(CROSS_WIN32)$(CXX) -c $(CXXFLAGS) $< -o $@ + +# MacOS platform objects. +bin/scintilla_cocoa.a: $(cocoa_src_objs) $(cocoa_lexlib_objs) \ + $(cocoa_lexer_objs) #$(cocoa_plat_objs) + $(CROSS_OSX)$(AR) rc $@ $^ + touch $@ +$(cocoa_src_objs): cocoa/%.o: src/%.cxx +$(cocoa_lexlib_objs): cocoa/%.o: lexlib/%.cxx +$(cocoa_lexer_objs): cocoa/%.o: lexers/%.cxx +$(cocoa_src_objs) $(cocoa_lexlib_objs) $(cocoa_lexer_objs): + $(CROSS_OSX)$(CXX) -c $(CXXFLAGS) $< -o $@ +$(cocoa_plat_objs): cocoa/%.o: cocoa/%.mm + $(CROSS_OSX)$(CXX)-gstdc++ -c $(CXXFLAGS) $< -o $@ + +# GTK platform objects. +bin/scintilla_gtk.a: $(gtk_src_objs) $(gtk_lexlib_objs) $(gtk_lexer_objs) \ + $(gtk_plat_cc_objs) $(gtk_plat_cxx_objs) +bin/clang-scintilla_gtk.a: $(gtk_src_objs_clang) $(gtk_lexlib_objs_clang) \ + $(gtk_lexer_objs_clang) $(gtk_plat_cc_objs_clang) \ + $(gtk_plat_cxx_objs_clang) +$(gtk_src_objs): gtk/%.o: src/%.cxx +$(gtk_lexlib_objs): gtk/%.o: lexlib/%.cxx +$(gtk_lexer_objs): gtk/%.o: lexers/%.cxx +$(gtk_src_objs_clang): gtk/clang-%.o: src/%.cxx +$(gtk_lexlib_objs_clang): gtk/clang-%.o: lexlib/%.cxx +$(gtk_lexer_objs_clang): gtk/clang-%.o: lexers/%.cxx +$(gtk_plat_cc_objs): gtk/%.o: gtk/%.c +$(gtk_plat_cc_objs_clang): gtk/clang-%.o: gtk/%.c +$(gtk_plat_cxx_objs): gtk/%.o: gtk/%.cxx +$(gtk_plat_cxx_objs_clang): gtk/clang-%.o: gtk/%.cxx +$(gtk_src_objs) $(gtk_lexlib_objs) $(gtk_lexer_objs) $(gtk_plat_cxx_objs): CXX := $(LINUX_CXX) +$(gtk_plat_cc_objs): CC := $(LINUX_CC) +$(gtk_src_objs_clang) $(gtk_lexlib_objs_clang) $(gtk_lexer_objs_clang) $(gtk_plat_cxx_objs_clang): CXX := $(CLANG_CXX) +$(gtk_plat_cc_objs_clang): CC := $(CLANG_CC) +bin/scintilla_gtk.a bin/clang-scintilla_gtk.a: + $(AR) rc $@ $^ + touch $@ +$(gtk_src_objs) $(gtk_lexlib_objs) $(gtk_lexer_objs) \ +$(gtk_src_objs_clang) $(gtk_lexlib_objs_clang) $(gtk_lexer_objs_clang): + $(CXX) -c $(CXXFLAGS) -DGTK $< -o $@ +$(gtk_plat_cc_objs) $(gtk_plat_cc_objs_clang): + $(CC) -c $(CFLAGS) $(GTK_CFLAGS) $< -o $@ +$(gtk_plat_cxx_objs) $(gtk_plat_cxx_objs_clang): + $(CXX) -c $(CXXFLAGS) -DGTK $(GTK_CFLAGS) $< -o $@ + +# Curses platform objects. +bin/scintilla_curses.a: $(curses_src_objs) $(curses_lexlib_objs) \ + $(curses_lexer_objs) $(curses_plat_objs) +bin/clang-scintilla_curses.a: $(curses_src_objs_clang) \ + $(curses_lexlib_objs_clang) \ + $(curses_lexer_objs_clang) \ + $(curses_plat_objs_clang) +$(curses_src_objs): curses/%.o: src/%.cxx +$(curses_lexlib_objs): curses/%.o: lexlib/%.cxx +$(curses_lexer_objs): curses/%.o: lexers/%.cxx +$(curses_src_objs_clang): curses/clang-%.o: src/%.cxx +$(curses_lexlib_objs_clang): curses/clang-%.o: lexlib/%.cxx +$(curses_lexer_objs_clang): curses/clang-%.o: lexers/%.cxx +$(curses_plat_objs): curses/%.o: curses/%.cxx +$(curses_plat_objs_clang): curses/clang-%.o: curses/%.cxx +$(curses_src_objs) $(curses_lexlib_objs) $(curses_lexer_objs): CXX := $(LINUX_CXX) +$(curses_src_objs_clang) $(curses_lexlib_objs_clang) $(curses_lexer_objs_clang) $(curses_plat_objs_clang): CXX := $(CLANG_CXX) +bin/scintilla_curses.a bin/clang-scintilla_curses.a: + ar rc $@ $^ + touch $@ +$(curses_src_objs) $(curses_lexlib_objs) $(curses_lexer_objs) \ +$(curses_src_objs_clang) $(curses_lexlib_objs_clang) $(curses_lexer_objs_clang): + $(CXX) -c $(CXXFLAGS) -DCURSES -DLPEG_LEXER $< -o $@ +$(curses_plat_objs) $(curses_plat_objs_clang): + $(CXX) -c $(CXXFLAGS) -DCURSES -Wno-unused-parameter $< -o $@ + +# Qt platform objects. (Note: requires libqt4-dev qt4-qmake.) +.PHONY: qt qt-clang +qt: qt/ScintillaEditBase/Makefile +qt-clang: qt-clang/ScintillaEditBase/Makefile +qt qt-clang: ; $(MAKE) -C $(dir $<) -j8 +qt/ScintillaEditBase/Makefile: ; cd qt/ScintillaEditBase && qmake +qt-clang/ScintillaEditBase/Makefile: + cd $(dir $@) && qmake QMAKE_CC="$(CLANG_CC)" \ + QMAKE_CXX="$(CLANG_CXX)" + sed -i -e 's/libScintillaEditBase/clang-libScintillaEditBase/;' $@ + +deps: win32_deps cocoa_deps gtk_deps curses_deps +win32_deps: src/*.cxx lexlib/*.cxx lexers/*.cxx win32/*.cxx + $(CROSS_WIN32)$(CXX) -MM $(CXXFLAGS) $^ | \ + sed -e 's|^\([[:alnum:]-]\+\.o:\)|win32/\1|;' > checkdeps.mak +cocoa_deps: src/*.cxx lexlib/*.cxx lexers/*.cxx #cocoa/*.cxx + $(CROSS_OSX)$(CXX) -MM $(CXXFLAGS) $^ | \ + sed -e 's|^\([[:alnum:]-]\+\.o:\)|cocoa/\1|;' >> checkdeps.mak +gtk_deps: src/*.cxx lexlib/*.cxx lexers/*.cxx gtk/*.cxx + $(CXX) -MM $(CXXFLAGS) $^ | \ + sed -e 's|^\([[:alnum:]-]\+\.o:\)|gtk/\1|;' >> checkdeps.mak +curses_deps: src/*.cxx lexlib/*.cxx lexers/*.cxx curses/*.cxx + $(CXX) -MM $(CXXFLAGS) $^ | \ + sed -e 's|^\([[:alnum:]-]\+\.o:\)|curses/\1|;' >> checkdeps.mak + +include checkdeps.mak + +clean: + rm -f bin/*.a bin/*.dll win32/*.o cocoa/*.o gtk/*.o curses/*.o + make -f qt/ScintillaEditBase/Makefile clean + make -f qt-clang/ScintillaEditBase/Makefile clean + rm -rf /tmp/scintilla + +.PHONY: test +test: | /tmp/scintilla + make -C $|/test/unit CXX=$(LINUX_CXX) clean test + cd $|/test && lua5.1 test_lexlua.lua + +releasedir = /tmp/scintilla$(shell grep -o '[0-9]\+' version.txt) +$(releasedir): ; hg archive $@ +zip: $(releasedir) + cd /tmp && tar czf $<.tgz $(notdir $<) + cd /tmp && zip -r $<.zip $(notdir $<) + rm -r $< + +upload: LongTermDownload.html doc/ScintillaHistory.html doc/ScintillaDoc.html \ + doc/StyleMetadata.html doc/LPegLexer.html + scp $^ foicica@web.sourceforge.net:/home/project-web/scintilla/htdocs/ diff --git a/dep/scintilla/scintilla-3.10.6/checkdeps.mak b/dep/scintilla/scintilla-3.10.6/checkdeps.mak new file mode 100644 index 00000000..81225831 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/checkdeps.mak @@ -0,0 +1,2464 @@ +win32/AutoComplete.o: src/AutoComplete.cxx include/Platform.h \ + include/Scintilla.h include/Sci_Position.h lexlib/CharacterSet.h \ + src/Position.h src/AutoComplete.h +win32/CallTip.o: src/CallTip.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/Position.h \ + src/IntegerRectangle.h src/CallTip.h +win32/CaseConvert.o: src/CaseConvert.cxx lexlib/StringCopy.h src/CaseConvert.h \ + src/UniConversion.h +win32/CaseFolder.o: src/CaseFolder.cxx src/CaseFolder.h src/CaseConvert.h +win32/Catalogue.o: src/Catalogue.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/LexerModule.h \ + src/Catalogue.h +win32/CellBuffer.o: src/CellBuffer.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/CellBuffer.h src/UniConversion.h +win32/CharClassify.o: src/CharClassify.cxx lexlib/CharacterSet.h \ + src/CharClassify.h +win32/ContractionState.o: src/ContractionState.cxx include/Platform.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/SparseVector.h src/ContractionState.h +win32/DBCS.o: src/DBCS.cxx src/DBCS.h +win32/Decoration.o: src/Decoration.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/RunStyles.h src/Decoration.h +win32/Document.o: src/Document.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterSet.h lexlib/CharacterCategory.h src/Position.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h src/CellBuffer.h \ + src/PerLine.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/RESearch.h src/UniConversion.h src/ElapsedPeriod.h +win32/EditModel.o: src/EditModel.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterCategory.h src/Position.h src/UniqueString.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h src/EditModel.h +win32/Editor.o: src/Editor.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/StringCopy.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/ContractionState.h src/CellBuffer.h src/PerLine.h \ + src/KeyMap.h src/Indicator.h src/LineMarker.h src/Style.h \ + src/ViewStyle.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/UniConversion.h src/Selection.h src/PositionCache.h \ + src/EditModel.h src/MarginView.h src/EditView.h src/Editor.h \ + src/ElapsedPeriod.h +win32/EditView.o: src/EditView.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/StringCopy.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + src/Position.h src/IntegerRectangle.h src/UniqueString.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/PerLine.h src/KeyMap.h \ + src/Indicator.h src/LineMarker.h src/Style.h src/ViewStyle.h \ + src/CharClassify.h src/Decoration.h src/CaseFolder.h src/Document.h \ + src/UniConversion.h src/Selection.h src/PositionCache.h src/EditModel.h \ + src/MarginView.h src/EditView.h src/ElapsedPeriod.h +win32/ExternalLexer.o: src/ExternalLexer.cxx include/Platform.h \ + include/ILexer.h include/Sci_Position.h include/Scintilla.h \ + include/SciLexer.h lexlib/LexerModule.h src/Catalogue.h \ + src/ExternalLexer.h +win32/Indicator.o: src/Indicator.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/IntegerRectangle.h \ + src/Indicator.h src/XPM.h +win32/KeyMap.o: src/KeyMap.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/KeyMap.h +win32/LineMarker.o: src/LineMarker.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/IntegerRectangle.h \ + src/XPM.h src/LineMarker.h +win32/MarginView.o: src/MarginView.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterCategory.h src/Position.h src/IntegerRectangle.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h src/EditModel.h src/MarginView.h \ + src/EditView.h +win32/PerLine.o: src/PerLine.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/CellBuffer.h src/PerLine.h +win32/PositionCache.o: src/PositionCache.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h lexlib/CharacterCategory.h src/Position.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h +win32/RESearch.o: src/RESearch.cxx src/Position.h src/CharClassify.h \ + src/RESearch.h +win32/RunStyles.o: src/RunStyles.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/RunStyles.h +win32/ScintillaBase.o: src/ScintillaBase.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/CharacterCategory.h lexlib/LexerModule.h src/Catalogue.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/ContractionState.h src/CellBuffer.h src/CallTip.h \ + src/KeyMap.h src/Indicator.h src/LineMarker.h src/Style.h \ + src/ViewStyle.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/Selection.h src/PositionCache.h src/EditModel.h \ + src/MarginView.h src/EditView.h src/Editor.h src/AutoComplete.h \ + src/ScintillaBase.h +win32/Selection.o: src/Selection.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/Selection.h +win32/Style.o: src/Style.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Style.h +win32/UniConversion.o: src/UniConversion.cxx src/UniConversion.h +win32/UniqueString.o: src/UniqueString.cxx src/UniqueString.h +win32/ViewStyle.o: src/ViewStyle.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/UniqueString.h src/Indicator.h \ + src/XPM.h src/LineMarker.h src/Style.h src/ViewStyle.h +win32/XPM.o: src/XPM.cxx include/Platform.h src/XPM.h +win32/Accessor.o: lexlib/Accessor.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h +win32/CharacterCategory.o: lexlib/CharacterCategory.cxx include/Scintilla.h \ + include/Sci_Position.h lexlib/CharacterCategory.h src/Position.h +win32/CharacterSet.o: lexlib/CharacterSet.cxx lexlib/CharacterSet.h +win32/DefaultLexer.o: lexlib/DefaultLexer.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/DefaultLexer.h +win32/LexerBase.o: lexlib/LexerBase.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/LexerModule.h lexlib/LexerBase.h +win32/LexerModule.o: lexlib/LexerModule.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerSimple.h +win32/LexerNoExceptions.o: lexlib/LexerNoExceptions.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerNoExceptions.h +win32/LexerSimple.o: lexlib/LexerSimple.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerSimple.h +win32/PropSetSimple.o: lexlib/PropSetSimple.cxx lexlib/PropSetSimple.h +win32/StyleContext.o: lexlib/StyleContext.cxx include/ILexer.h \ + include/Sci_Position.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h +win32/WordList.o: lexlib/WordList.cxx lexlib/WordList.h +win32/LexA68k.o: lexers/LexA68k.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexAbaqus.o: lexers/LexAbaqus.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexAda.o: lexers/LexAda.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexAPDL.o: lexers/LexAPDL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexAsm.o: lexers/LexAsm.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexAsn1.o: lexers/LexAsn1.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexASY.o: lexers/LexASY.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexAU3.o: lexers/LexAU3.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexAVE.o: lexers/LexAVE.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexAVS.o: lexers/LexAVS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexBaan.o: lexers/LexBaan.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexBash.o: lexers/LexBash.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SubStyles.h lexlib/DefaultLexer.h +win32/LexBasic.o: lexers/LexBasic.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexBatch.o: lexers/LexBatch.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexBibTeX.o: lexers/LexBibTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexBullant.o: lexers/LexBullant.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexCaml.o: lexers/LexCaml.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexCIL.o: lexers/LexCIL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexCLW.o: lexers/LexCLW.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexCmake.o: lexers/LexCmake.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexCOBOL.o: lexers/LexCOBOL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexCoffeeScript.o: lexers/LexCoffeeScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexConf.o: lexers/LexConf.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexCPP.o: lexers/LexCPP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/SparseState.h lexlib/SubStyles.h +win32/LexCrontab.o: lexers/LexCrontab.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexCsound.o: lexers/LexCsound.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexCSS.o: lexers/LexCSS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexD.o: lexers/LexD.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexDiff.o: lexers/LexDiff.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexDMAP.o: lexers/LexDMAP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexDMIS.o: lexers/LexDMIS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/DefaultLexer.h +win32/LexECL.o: lexers/LexECL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h +win32/LexEDIFACT.o: lexers/LexEDIFACT.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/LexAccessor.h lexlib/LexerModule.h lexlib/DefaultLexer.h +win32/LexEiffel.o: lexers/LexEiffel.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexErlang.o: lexers/LexErlang.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexErrorList.o: lexers/LexErrorList.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexEScript.o: lexers/LexEScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexFlagship.o: lexers/LexFlagship.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexForth.o: lexers/LexForth.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexFortran.o: lexers/LexFortran.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexGAP.o: lexers/LexGAP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexGui4Cli.o: lexers/LexGui4Cli.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexHaskell.o: lexers/LexHaskell.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/CharacterCategory.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/DefaultLexer.h +win32/LexHex.o: lexers/LexHex.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexHTML.o: lexers/LexHTML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexIndent.o: lexers/LexIndent.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexInno.o: lexers/LexInno.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexJSON.o: lexers/LexJSON.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexKix.o: lexers/LexKix.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexKVIrc.o: lexers/LexKVIrc.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexLaTeX.o: lexers/LexLaTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/LexerBase.h +win32/LexLisp.o: lexers/LexLisp.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexLout.o: lexers/LexLout.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexLPeg.o: lexers/LexLPeg.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/LexerModule.h +win32/LexLua.o: lexers/LexLua.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMagik.o: lexers/LexMagik.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMake.o: lexers/LexMake.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMarkdown.o: lexers/LexMarkdown.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMatlab.o: lexers/LexMatlab.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMaxima.o: lexers/LexMaxima.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMetapost.o: lexers/LexMetapost.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMMIXAL.o: lexers/LexMMIXAL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexModula.o: lexers/LexModula.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMPT.o: lexers/LexMPT.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMSSQL.o: lexers/LexMSSQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexMySQL.o: lexers/LexMySQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexNim.o: lexers/LexNim.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexNimrod.o: lexers/LexNimrod.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexNsis.o: lexers/LexNsis.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexNull.o: lexers/LexNull.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexOpal.o: lexers/LexOpal.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexOScript.o: lexers/LexOScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexPascal.o: lexers/LexPascal.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexPB.o: lexers/LexPB.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexPerl.o: lexers/LexPerl.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexPLM.o: lexers/LexPLM.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexPO.o: lexers/LexPO.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexPOV.o: lexers/LexPOV.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexPowerPro.o: lexers/LexPowerPro.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexPowerShell.o: lexers/LexPowerShell.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexProgress.o: lexers/LexProgress.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SparseState.h lexlib/DefaultLexer.h +win32/LexProps.o: lexers/LexProps.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexPS.o: lexers/LexPS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexPython.o: lexers/LexPython.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/SubStyles.h \ + lexlib/DefaultLexer.h +win32/LexR.o: lexers/LexR.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexRebol.o: lexers/LexRebol.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexRegistry.o: lexers/LexRegistry.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/DefaultLexer.h +win32/LexRuby.o: lexers/LexRuby.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexRust.o: lexers/LexRust.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexSAS.o: lexers/LexSAS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexScriptol.o: lexers/LexScriptol.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexSmalltalk.o: lexers/LexSmalltalk.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexSML.o: lexers/LexSML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexSorcus.o: lexers/LexSorcus.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexSpecman.o: lexers/LexSpecman.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexSpice.o: lexers/LexSpice.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexSQL.o: lexers/LexSQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SparseState.h lexlib/DefaultLexer.h +win32/LexStata.o: lexers/LexStata.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexSTTXT.o: lexers/LexSTTXT.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexTACL.o: lexers/LexTACL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexTADS3.o: lexers/LexTADS3.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexTAL.o: lexers/LexTAL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexTCL.o: lexers/LexTCL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexTCMD.o: lexers/LexTCMD.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexTeX.o: lexers/LexTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexTxt2tags.o: lexers/LexTxt2tags.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexVB.o: lexers/LexVB.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexVerilog.o: lexers/LexVerilog.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/SubStyles.h lexlib/DefaultLexer.h +win32/LexVHDL.o: lexers/LexVHDL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/LexVisualProlog.o: lexers/LexVisualProlog.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +win32/LexYAML.o: lexers/LexYAML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +win32/HanjaDic.o: win32/HanjaDic.cxx src/UniConversion.h win32/HanjaDic.h +win32/PlatWin.o: win32/PlatWin.cxx include/Platform.h src/Position.h src/XPM.h \ + src/UniConversion.h src/DBCS.h src/FontQuality.h win32/PlatWin.h +win32/ScintillaDLL.o: win32/ScintillaDLL.cxx include/Scintilla.h \ + include/Sci_Position.h win32/ScintillaWin.h +win32/ScintillaWin.o: win32/ScintillaWin.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/CharacterCategory.h lexlib/LexerModule.h src/Position.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/CallTip.h src/KeyMap.h \ + src/Indicator.h src/LineMarker.h src/Style.h src/ViewStyle.h \ + src/CharClassify.h src/Decoration.h src/CaseFolder.h src/Document.h \ + src/CaseConvert.h src/UniConversion.h src/Selection.h \ + src/PositionCache.h src/EditModel.h src/MarginView.h src/EditView.h \ + src/Editor.h src/ElapsedPeriod.h src/AutoComplete.h src/ScintillaBase.h \ + src/ExternalLexer.h win32/PlatWin.h win32/HanjaDic.h \ + win32/ScintillaWin.h +cocoa/AutoComplete.o: src/AutoComplete.cxx include/Platform.h \ + include/Scintilla.h include/Sci_Position.h lexlib/CharacterSet.h \ + src/Position.h src/AutoComplete.h +cocoa/CallTip.o: src/CallTip.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/Position.h \ + src/IntegerRectangle.h src/CallTip.h +cocoa/CaseConvert.o: src/CaseConvert.cxx lexlib/StringCopy.h src/CaseConvert.h \ + src/UniConversion.h +cocoa/CaseFolder.o: src/CaseFolder.cxx src/CaseFolder.h src/CaseConvert.h +cocoa/Catalogue.o: src/Catalogue.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/LexerModule.h \ + src/Catalogue.h +cocoa/CellBuffer.o: src/CellBuffer.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/CellBuffer.h src/UniConversion.h +cocoa/CharClassify.o: src/CharClassify.cxx lexlib/CharacterSet.h \ + src/CharClassify.h +cocoa/ContractionState.o: src/ContractionState.cxx include/Platform.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/SparseVector.h src/ContractionState.h +cocoa/DBCS.o: src/DBCS.cxx src/DBCS.h +cocoa/Decoration.o: src/Decoration.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/RunStyles.h src/Decoration.h +cocoa/Document.o: src/Document.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterSet.h lexlib/CharacterCategory.h src/Position.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h src/CellBuffer.h \ + src/PerLine.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/RESearch.h src/UniConversion.h src/ElapsedPeriod.h +cocoa/EditModel.o: src/EditModel.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterCategory.h src/Position.h src/UniqueString.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h src/EditModel.h +cocoa/Editor.o: src/Editor.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/StringCopy.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/ContractionState.h src/CellBuffer.h src/PerLine.h \ + src/KeyMap.h src/Indicator.h src/LineMarker.h src/Style.h \ + src/ViewStyle.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/UniConversion.h src/Selection.h src/PositionCache.h \ + src/EditModel.h src/MarginView.h src/EditView.h src/Editor.h \ + src/ElapsedPeriod.h +cocoa/EditView.o: src/EditView.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/StringCopy.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + src/Position.h src/IntegerRectangle.h src/UniqueString.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/PerLine.h src/KeyMap.h \ + src/Indicator.h src/LineMarker.h src/Style.h src/ViewStyle.h \ + src/CharClassify.h src/Decoration.h src/CaseFolder.h src/Document.h \ + src/UniConversion.h src/Selection.h src/PositionCache.h src/EditModel.h \ + src/MarginView.h src/EditView.h src/ElapsedPeriod.h +cocoa/ExternalLexer.o: src/ExternalLexer.cxx include/Platform.h \ + include/ILexer.h include/Sci_Position.h include/Scintilla.h \ + include/SciLexer.h lexlib/LexerModule.h src/Catalogue.h \ + src/ExternalLexer.h +cocoa/Indicator.o: src/Indicator.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/IntegerRectangle.h \ + src/Indicator.h src/XPM.h +cocoa/KeyMap.o: src/KeyMap.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/KeyMap.h +cocoa/LineMarker.o: src/LineMarker.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/IntegerRectangle.h \ + src/XPM.h src/LineMarker.h +cocoa/MarginView.o: src/MarginView.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterCategory.h src/Position.h src/IntegerRectangle.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h src/EditModel.h src/MarginView.h \ + src/EditView.h +cocoa/PerLine.o: src/PerLine.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/CellBuffer.h src/PerLine.h +cocoa/PositionCache.o: src/PositionCache.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h lexlib/CharacterCategory.h src/Position.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h +cocoa/RESearch.o: src/RESearch.cxx src/Position.h src/CharClassify.h \ + src/RESearch.h +cocoa/RunStyles.o: src/RunStyles.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/RunStyles.h +cocoa/ScintillaBase.o: src/ScintillaBase.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/CharacterCategory.h lexlib/LexerModule.h src/Catalogue.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/ContractionState.h src/CellBuffer.h src/CallTip.h \ + src/KeyMap.h src/Indicator.h src/LineMarker.h src/Style.h \ + src/ViewStyle.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/Selection.h src/PositionCache.h src/EditModel.h \ + src/MarginView.h src/EditView.h src/Editor.h src/AutoComplete.h \ + src/ScintillaBase.h +cocoa/Selection.o: src/Selection.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/Selection.h +cocoa/Style.o: src/Style.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Style.h +cocoa/UniConversion.o: src/UniConversion.cxx src/UniConversion.h +cocoa/UniqueString.o: src/UniqueString.cxx src/UniqueString.h +cocoa/ViewStyle.o: src/ViewStyle.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/UniqueString.h src/Indicator.h \ + src/XPM.h src/LineMarker.h src/Style.h src/ViewStyle.h +cocoa/XPM.o: src/XPM.cxx include/Platform.h src/XPM.h +cocoa/Accessor.o: lexlib/Accessor.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h +cocoa/CharacterCategory.o: lexlib/CharacterCategory.cxx include/Scintilla.h \ + include/Sci_Position.h lexlib/CharacterCategory.h src/Position.h +cocoa/CharacterSet.o: lexlib/CharacterSet.cxx lexlib/CharacterSet.h +cocoa/DefaultLexer.o: lexlib/DefaultLexer.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/DefaultLexer.h +cocoa/LexerBase.o: lexlib/LexerBase.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/LexerModule.h lexlib/LexerBase.h +cocoa/LexerModule.o: lexlib/LexerModule.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerSimple.h +cocoa/LexerNoExceptions.o: lexlib/LexerNoExceptions.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerNoExceptions.h +cocoa/LexerSimple.o: lexlib/LexerSimple.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerSimple.h +cocoa/PropSetSimple.o: lexlib/PropSetSimple.cxx lexlib/PropSetSimple.h +cocoa/StyleContext.o: lexlib/StyleContext.cxx include/ILexer.h \ + include/Sci_Position.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h +cocoa/WordList.o: lexlib/WordList.cxx lexlib/WordList.h +cocoa/LexA68k.o: lexers/LexA68k.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexAbaqus.o: lexers/LexAbaqus.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexAda.o: lexers/LexAda.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexAPDL.o: lexers/LexAPDL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexAsm.o: lexers/LexAsm.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexAsn1.o: lexers/LexAsn1.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexASY.o: lexers/LexASY.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexAU3.o: lexers/LexAU3.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexAVE.o: lexers/LexAVE.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexAVS.o: lexers/LexAVS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexBaan.o: lexers/LexBaan.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexBash.o: lexers/LexBash.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SubStyles.h lexlib/DefaultLexer.h +cocoa/LexBasic.o: lexers/LexBasic.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexBatch.o: lexers/LexBatch.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexBibTeX.o: lexers/LexBibTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexBullant.o: lexers/LexBullant.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexCaml.o: lexers/LexCaml.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexCIL.o: lexers/LexCIL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexCLW.o: lexers/LexCLW.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexCmake.o: lexers/LexCmake.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexCOBOL.o: lexers/LexCOBOL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexCoffeeScript.o: lexers/LexCoffeeScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexConf.o: lexers/LexConf.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexCPP.o: lexers/LexCPP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/SparseState.h lexlib/SubStyles.h +cocoa/LexCrontab.o: lexers/LexCrontab.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexCsound.o: lexers/LexCsound.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexCSS.o: lexers/LexCSS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexD.o: lexers/LexD.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexDiff.o: lexers/LexDiff.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexDMAP.o: lexers/LexDMAP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexDMIS.o: lexers/LexDMIS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/DefaultLexer.h +cocoa/LexECL.o: lexers/LexECL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h +cocoa/LexEDIFACT.o: lexers/LexEDIFACT.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/LexAccessor.h lexlib/LexerModule.h lexlib/DefaultLexer.h +cocoa/LexEiffel.o: lexers/LexEiffel.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexErlang.o: lexers/LexErlang.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexErrorList.o: lexers/LexErrorList.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexEScript.o: lexers/LexEScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexFlagship.o: lexers/LexFlagship.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexForth.o: lexers/LexForth.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexFortran.o: lexers/LexFortran.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexGAP.o: lexers/LexGAP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexGui4Cli.o: lexers/LexGui4Cli.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexHaskell.o: lexers/LexHaskell.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/CharacterCategory.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/DefaultLexer.h +cocoa/LexHex.o: lexers/LexHex.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexHTML.o: lexers/LexHTML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexIndent.o: lexers/LexIndent.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexInno.o: lexers/LexInno.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexJSON.o: lexers/LexJSON.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexKix.o: lexers/LexKix.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexKVIrc.o: lexers/LexKVIrc.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexLaTeX.o: lexers/LexLaTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/LexerBase.h +cocoa/LexLisp.o: lexers/LexLisp.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexLout.o: lexers/LexLout.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexLPeg.o: lexers/LexLPeg.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/LexerModule.h +cocoa/LexLua.o: lexers/LexLua.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMagik.o: lexers/LexMagik.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMake.o: lexers/LexMake.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMarkdown.o: lexers/LexMarkdown.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMatlab.o: lexers/LexMatlab.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMaxima.o: lexers/LexMaxima.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMetapost.o: lexers/LexMetapost.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMMIXAL.o: lexers/LexMMIXAL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexModula.o: lexers/LexModula.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMPT.o: lexers/LexMPT.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMSSQL.o: lexers/LexMSSQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexMySQL.o: lexers/LexMySQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexNim.o: lexers/LexNim.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexNimrod.o: lexers/LexNimrod.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexNsis.o: lexers/LexNsis.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexNull.o: lexers/LexNull.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexOpal.o: lexers/LexOpal.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexOScript.o: lexers/LexOScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexPascal.o: lexers/LexPascal.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexPB.o: lexers/LexPB.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexPerl.o: lexers/LexPerl.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexPLM.o: lexers/LexPLM.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexPO.o: lexers/LexPO.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexPOV.o: lexers/LexPOV.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexPowerPro.o: lexers/LexPowerPro.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexPowerShell.o: lexers/LexPowerShell.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexProgress.o: lexers/LexProgress.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SparseState.h lexlib/DefaultLexer.h +cocoa/LexProps.o: lexers/LexProps.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexPS.o: lexers/LexPS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexPython.o: lexers/LexPython.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/SubStyles.h \ + lexlib/DefaultLexer.h +cocoa/LexR.o: lexers/LexR.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexRebol.o: lexers/LexRebol.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexRegistry.o: lexers/LexRegistry.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/DefaultLexer.h +cocoa/LexRuby.o: lexers/LexRuby.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexRust.o: lexers/LexRust.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexSAS.o: lexers/LexSAS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexScriptol.o: lexers/LexScriptol.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexSmalltalk.o: lexers/LexSmalltalk.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexSML.o: lexers/LexSML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexSorcus.o: lexers/LexSorcus.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexSpecman.o: lexers/LexSpecman.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexSpice.o: lexers/LexSpice.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexSQL.o: lexers/LexSQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SparseState.h lexlib/DefaultLexer.h +cocoa/LexStata.o: lexers/LexStata.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexSTTXT.o: lexers/LexSTTXT.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexTACL.o: lexers/LexTACL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexTADS3.o: lexers/LexTADS3.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexTAL.o: lexers/LexTAL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexTCL.o: lexers/LexTCL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexTCMD.o: lexers/LexTCMD.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexTeX.o: lexers/LexTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexTxt2tags.o: lexers/LexTxt2tags.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexVB.o: lexers/LexVB.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexVerilog.o: lexers/LexVerilog.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/SubStyles.h lexlib/DefaultLexer.h +cocoa/LexVHDL.o: lexers/LexVHDL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +cocoa/LexVisualProlog.o: lexers/LexVisualProlog.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +cocoa/LexYAML.o: lexers/LexYAML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/AutoComplete.o: src/AutoComplete.cxx include/Platform.h \ + include/Scintilla.h include/Sci_Position.h lexlib/CharacterSet.h \ + src/Position.h src/AutoComplete.h +gtk/CallTip.o: src/CallTip.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/Position.h \ + src/IntegerRectangle.h src/CallTip.h +gtk/CaseConvert.o: src/CaseConvert.cxx lexlib/StringCopy.h src/CaseConvert.h \ + src/UniConversion.h +gtk/CaseFolder.o: src/CaseFolder.cxx src/CaseFolder.h src/CaseConvert.h +gtk/Catalogue.o: src/Catalogue.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/LexerModule.h \ + src/Catalogue.h +gtk/CellBuffer.o: src/CellBuffer.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/CellBuffer.h src/UniConversion.h +gtk/CharClassify.o: src/CharClassify.cxx lexlib/CharacterSet.h \ + src/CharClassify.h +gtk/ContractionState.o: src/ContractionState.cxx include/Platform.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/SparseVector.h src/ContractionState.h +gtk/DBCS.o: src/DBCS.cxx src/DBCS.h +gtk/Decoration.o: src/Decoration.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/RunStyles.h src/Decoration.h +gtk/Document.o: src/Document.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterSet.h lexlib/CharacterCategory.h src/Position.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h src/CellBuffer.h \ + src/PerLine.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/RESearch.h src/UniConversion.h src/ElapsedPeriod.h +gtk/EditModel.o: src/EditModel.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterCategory.h src/Position.h src/UniqueString.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h src/EditModel.h +gtk/Editor.o: src/Editor.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/StringCopy.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/ContractionState.h src/CellBuffer.h src/PerLine.h \ + src/KeyMap.h src/Indicator.h src/LineMarker.h src/Style.h \ + src/ViewStyle.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/UniConversion.h src/Selection.h src/PositionCache.h \ + src/EditModel.h src/MarginView.h src/EditView.h src/Editor.h \ + src/ElapsedPeriod.h +gtk/EditView.o: src/EditView.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/StringCopy.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + src/Position.h src/IntegerRectangle.h src/UniqueString.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/PerLine.h src/KeyMap.h \ + src/Indicator.h src/LineMarker.h src/Style.h src/ViewStyle.h \ + src/CharClassify.h src/Decoration.h src/CaseFolder.h src/Document.h \ + src/UniConversion.h src/Selection.h src/PositionCache.h src/EditModel.h \ + src/MarginView.h src/EditView.h src/ElapsedPeriod.h +gtk/ExternalLexer.o: src/ExternalLexer.cxx include/Platform.h \ + include/ILexer.h include/Sci_Position.h include/Scintilla.h \ + include/SciLexer.h lexlib/LexerModule.h src/Catalogue.h \ + src/ExternalLexer.h +gtk/Indicator.o: src/Indicator.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/IntegerRectangle.h \ + src/Indicator.h src/XPM.h +gtk/KeyMap.o: src/KeyMap.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/KeyMap.h +gtk/LineMarker.o: src/LineMarker.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/IntegerRectangle.h \ + src/XPM.h src/LineMarker.h +gtk/MarginView.o: src/MarginView.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterCategory.h src/Position.h src/IntegerRectangle.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h src/EditModel.h src/MarginView.h \ + src/EditView.h +gtk/PerLine.o: src/PerLine.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/CellBuffer.h src/PerLine.h +gtk/PositionCache.o: src/PositionCache.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h lexlib/CharacterCategory.h src/Position.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h +gtk/RESearch.o: src/RESearch.cxx src/Position.h src/CharClassify.h \ + src/RESearch.h +gtk/RunStyles.o: src/RunStyles.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/RunStyles.h +gtk/ScintillaBase.o: src/ScintillaBase.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/CharacterCategory.h lexlib/LexerModule.h src/Catalogue.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/ContractionState.h src/CellBuffer.h src/CallTip.h \ + src/KeyMap.h src/Indicator.h src/LineMarker.h src/Style.h \ + src/ViewStyle.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/Selection.h src/PositionCache.h src/EditModel.h \ + src/MarginView.h src/EditView.h src/Editor.h src/AutoComplete.h \ + src/ScintillaBase.h +gtk/Selection.o: src/Selection.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/Selection.h +gtk/Style.o: src/Style.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Style.h +gtk/UniConversion.o: src/UniConversion.cxx src/UniConversion.h +gtk/UniqueString.o: src/UniqueString.cxx src/UniqueString.h +gtk/ViewStyle.o: src/ViewStyle.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/UniqueString.h src/Indicator.h \ + src/XPM.h src/LineMarker.h src/Style.h src/ViewStyle.h +gtk/XPM.o: src/XPM.cxx include/Platform.h src/XPM.h +gtk/Accessor.o: lexlib/Accessor.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h +gtk/CharacterCategory.o: lexlib/CharacterCategory.cxx include/Scintilla.h \ + include/Sci_Position.h lexlib/CharacterCategory.h src/Position.h +gtk/CharacterSet.o: lexlib/CharacterSet.cxx lexlib/CharacterSet.h +gtk/DefaultLexer.o: lexlib/DefaultLexer.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/DefaultLexer.h +gtk/LexerBase.o: lexlib/LexerBase.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/LexerModule.h lexlib/LexerBase.h +gtk/LexerModule.o: lexlib/LexerModule.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerSimple.h +gtk/LexerNoExceptions.o: lexlib/LexerNoExceptions.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerNoExceptions.h +gtk/LexerSimple.o: lexlib/LexerSimple.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerSimple.h +gtk/PropSetSimple.o: lexlib/PropSetSimple.cxx lexlib/PropSetSimple.h +gtk/StyleContext.o: lexlib/StyleContext.cxx include/ILexer.h \ + include/Sci_Position.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h +gtk/WordList.o: lexlib/WordList.cxx lexlib/WordList.h +gtk/LexA68k.o: lexers/LexA68k.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexAbaqus.o: lexers/LexAbaqus.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexAda.o: lexers/LexAda.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexAPDL.o: lexers/LexAPDL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexAsm.o: lexers/LexAsm.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexAsn1.o: lexers/LexAsn1.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexASY.o: lexers/LexASY.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexAU3.o: lexers/LexAU3.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexAVE.o: lexers/LexAVE.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexAVS.o: lexers/LexAVS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexBaan.o: lexers/LexBaan.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexBash.o: lexers/LexBash.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SubStyles.h lexlib/DefaultLexer.h +gtk/LexBasic.o: lexers/LexBasic.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexBatch.o: lexers/LexBatch.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexBibTeX.o: lexers/LexBibTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexBullant.o: lexers/LexBullant.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexCaml.o: lexers/LexCaml.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexCIL.o: lexers/LexCIL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexCLW.o: lexers/LexCLW.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexCmake.o: lexers/LexCmake.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexCOBOL.o: lexers/LexCOBOL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexCoffeeScript.o: lexers/LexCoffeeScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexConf.o: lexers/LexConf.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexCPP.o: lexers/LexCPP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/SparseState.h lexlib/SubStyles.h +gtk/LexCrontab.o: lexers/LexCrontab.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexCsound.o: lexers/LexCsound.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexCSS.o: lexers/LexCSS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexD.o: lexers/LexD.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexDiff.o: lexers/LexDiff.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexDMAP.o: lexers/LexDMAP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexDMIS.o: lexers/LexDMIS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/DefaultLexer.h +gtk/LexECL.o: lexers/LexECL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h +gtk/LexEDIFACT.o: lexers/LexEDIFACT.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/LexAccessor.h lexlib/LexerModule.h lexlib/DefaultLexer.h +gtk/LexEiffel.o: lexers/LexEiffel.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexErlang.o: lexers/LexErlang.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexErrorList.o: lexers/LexErrorList.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexEScript.o: lexers/LexEScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexFlagship.o: lexers/LexFlagship.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexForth.o: lexers/LexForth.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexFortran.o: lexers/LexFortran.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexGAP.o: lexers/LexGAP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexGui4Cli.o: lexers/LexGui4Cli.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexHaskell.o: lexers/LexHaskell.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/CharacterCategory.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/DefaultLexer.h +gtk/LexHex.o: lexers/LexHex.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexHTML.o: lexers/LexHTML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexIndent.o: lexers/LexIndent.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexInno.o: lexers/LexInno.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexJSON.o: lexers/LexJSON.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexKix.o: lexers/LexKix.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexKVIrc.o: lexers/LexKVIrc.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexLaTeX.o: lexers/LexLaTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/LexerBase.h +gtk/LexLisp.o: lexers/LexLisp.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexLout.o: lexers/LexLout.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexLPeg.o: lexers/LexLPeg.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/LexerModule.h +gtk/LexLua.o: lexers/LexLua.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMagik.o: lexers/LexMagik.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMake.o: lexers/LexMake.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMarkdown.o: lexers/LexMarkdown.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMatlab.o: lexers/LexMatlab.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMaxima.o: lexers/LexMaxima.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMetapost.o: lexers/LexMetapost.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMMIXAL.o: lexers/LexMMIXAL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexModula.o: lexers/LexModula.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMPT.o: lexers/LexMPT.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMSSQL.o: lexers/LexMSSQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexMySQL.o: lexers/LexMySQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexNim.o: lexers/LexNim.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexNimrod.o: lexers/LexNimrod.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexNsis.o: lexers/LexNsis.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexNull.o: lexers/LexNull.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexOpal.o: lexers/LexOpal.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexOScript.o: lexers/LexOScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexPascal.o: lexers/LexPascal.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexPB.o: lexers/LexPB.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexPerl.o: lexers/LexPerl.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexPLM.o: lexers/LexPLM.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexPO.o: lexers/LexPO.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexPOV.o: lexers/LexPOV.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexPowerPro.o: lexers/LexPowerPro.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexPowerShell.o: lexers/LexPowerShell.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexProgress.o: lexers/LexProgress.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SparseState.h lexlib/DefaultLexer.h +gtk/LexProps.o: lexers/LexProps.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexPS.o: lexers/LexPS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexPython.o: lexers/LexPython.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/SubStyles.h \ + lexlib/DefaultLexer.h +gtk/LexR.o: lexers/LexR.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexRebol.o: lexers/LexRebol.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexRegistry.o: lexers/LexRegistry.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/DefaultLexer.h +gtk/LexRuby.o: lexers/LexRuby.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexRust.o: lexers/LexRust.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexSAS.o: lexers/LexSAS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexScriptol.o: lexers/LexScriptol.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexSmalltalk.o: lexers/LexSmalltalk.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexSML.o: lexers/LexSML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexSorcus.o: lexers/LexSorcus.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexSpecman.o: lexers/LexSpecman.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexSpice.o: lexers/LexSpice.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexSQL.o: lexers/LexSQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SparseState.h lexlib/DefaultLexer.h +gtk/LexStata.o: lexers/LexStata.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexSTTXT.o: lexers/LexSTTXT.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexTACL.o: lexers/LexTACL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexTADS3.o: lexers/LexTADS3.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexTAL.o: lexers/LexTAL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexTCL.o: lexers/LexTCL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexTCMD.o: lexers/LexTCMD.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexTeX.o: lexers/LexTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexTxt2tags.o: lexers/LexTxt2tags.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexVB.o: lexers/LexVB.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexVerilog.o: lexers/LexVerilog.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/SubStyles.h lexlib/DefaultLexer.h +gtk/LexVHDL.o: lexers/LexVHDL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +gtk/LexVisualProlog.o: lexers/LexVisualProlog.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +gtk/LexYAML.o: lexers/LexYAML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/AutoComplete.o: src/AutoComplete.cxx include/Platform.h \ + include/Scintilla.h include/Sci_Position.h lexlib/CharacterSet.h \ + src/Position.h src/AutoComplete.h +curses/CallTip.o: src/CallTip.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/Position.h \ + src/IntegerRectangle.h src/CallTip.h +curses/CaseConvert.o: src/CaseConvert.cxx lexlib/StringCopy.h src/CaseConvert.h \ + src/UniConversion.h +curses/CaseFolder.o: src/CaseFolder.cxx src/CaseFolder.h src/CaseConvert.h +curses/Catalogue.o: src/Catalogue.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/LexerModule.h \ + src/Catalogue.h +curses/CellBuffer.o: src/CellBuffer.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/CellBuffer.h src/UniConversion.h +curses/CharClassify.o: src/CharClassify.cxx lexlib/CharacterSet.h \ + src/CharClassify.h +curses/ContractionState.o: src/ContractionState.cxx include/Platform.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/SparseVector.h src/ContractionState.h +curses/DBCS.o: src/DBCS.cxx src/DBCS.h +curses/Decoration.o: src/Decoration.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/RunStyles.h src/Decoration.h +curses/Document.o: src/Document.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterSet.h lexlib/CharacterCategory.h src/Position.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h src/CellBuffer.h \ + src/PerLine.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/RESearch.h src/UniConversion.h src/ElapsedPeriod.h +curses/EditModel.o: src/EditModel.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterCategory.h src/Position.h src/UniqueString.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h src/EditModel.h +curses/Editor.o: src/Editor.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/StringCopy.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/ContractionState.h src/CellBuffer.h src/PerLine.h \ + src/KeyMap.h src/Indicator.h src/LineMarker.h src/Style.h \ + src/ViewStyle.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/UniConversion.h src/Selection.h src/PositionCache.h \ + src/EditModel.h src/MarginView.h src/EditView.h src/Editor.h \ + src/ElapsedPeriod.h +curses/EditView.o: src/EditView.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/StringCopy.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + src/Position.h src/IntegerRectangle.h src/UniqueString.h \ + src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/PerLine.h src/KeyMap.h \ + src/Indicator.h src/LineMarker.h src/Style.h src/ViewStyle.h \ + src/CharClassify.h src/Decoration.h src/CaseFolder.h src/Document.h \ + src/UniConversion.h src/Selection.h src/PositionCache.h src/EditModel.h \ + src/MarginView.h src/EditView.h src/ElapsedPeriod.h +curses/ExternalLexer.o: src/ExternalLexer.cxx include/Platform.h \ + include/ILexer.h include/Sci_Position.h include/Scintilla.h \ + include/SciLexer.h lexlib/LexerModule.h src/Catalogue.h \ + src/ExternalLexer.h +curses/Indicator.o: src/Indicator.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/IntegerRectangle.h \ + src/Indicator.h src/XPM.h +curses/KeyMap.o: src/KeyMap.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/KeyMap.h +curses/LineMarker.o: src/LineMarker.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h lexlib/StringCopy.h src/IntegerRectangle.h \ + src/XPM.h src/LineMarker.h +curses/MarginView.o: src/MarginView.cxx include/Platform.h include/ILoader.h \ + include/Sci_Position.h include/ILexer.h include/Scintilla.h \ + lexlib/CharacterCategory.h src/Position.h src/IntegerRectangle.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h src/EditModel.h src/MarginView.h \ + src/EditView.h +curses/PerLine.o: src/PerLine.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/CellBuffer.h src/PerLine.h +curses/PositionCache.o: src/PositionCache.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h lexlib/CharacterCategory.h src/Position.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/KeyMap.h src/Indicator.h \ + src/LineMarker.h src/Style.h src/ViewStyle.h src/CharClassify.h \ + src/Decoration.h src/CaseFolder.h src/Document.h src/UniConversion.h \ + src/Selection.h src/PositionCache.h +curses/RESearch.o: src/RESearch.cxx src/Position.h src/CharClassify.h \ + src/RESearch.h +curses/RunStyles.o: src/RunStyles.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/SplitVector.h \ + src/Partitioning.h src/RunStyles.h +curses/ScintillaBase.o: src/ScintillaBase.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/CharacterCategory.h lexlib/LexerModule.h src/Catalogue.h \ + src/Position.h src/UniqueString.h src/SplitVector.h src/Partitioning.h \ + src/RunStyles.h src/ContractionState.h src/CellBuffer.h src/CallTip.h \ + src/KeyMap.h src/Indicator.h src/LineMarker.h src/Style.h \ + src/ViewStyle.h src/CharClassify.h src/Decoration.h src/CaseFolder.h \ + src/Document.h src/Selection.h src/PositionCache.h src/EditModel.h \ + src/MarginView.h src/EditView.h src/Editor.h src/AutoComplete.h \ + src/ScintillaBase.h +curses/Selection.o: src/Selection.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/Selection.h +curses/Style.o: src/Style.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Style.h +curses/UniConversion.o: src/UniConversion.cxx src/UniConversion.h +curses/UniqueString.o: src/UniqueString.cxx src/UniqueString.h +curses/ViewStyle.o: src/ViewStyle.cxx include/Platform.h include/Scintilla.h \ + include/Sci_Position.h src/Position.h src/UniqueString.h src/Indicator.h \ + src/XPM.h src/LineMarker.h src/Style.h src/ViewStyle.h +curses/XPM.o: src/XPM.cxx include/Platform.h src/XPM.h +curses/Accessor.o: lexlib/Accessor.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h +curses/CharacterCategory.o: lexlib/CharacterCategory.cxx include/Scintilla.h \ + include/Sci_Position.h lexlib/CharacterCategory.h src/Position.h +curses/CharacterSet.o: lexlib/CharacterSet.cxx lexlib/CharacterSet.h +curses/DefaultLexer.o: lexlib/DefaultLexer.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/DefaultLexer.h +curses/LexerBase.o: lexlib/LexerBase.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/LexerModule.h lexlib/LexerBase.h +curses/LexerModule.o: lexlib/LexerModule.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerSimple.h +curses/LexerNoExceptions.o: lexlib/LexerNoExceptions.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerNoExceptions.h +curses/LexerSimple.o: lexlib/LexerSimple.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/LexerModule.h lexlib/LexerBase.h \ + lexlib/LexerSimple.h +curses/PropSetSimple.o: lexlib/PropSetSimple.cxx lexlib/PropSetSimple.h +curses/StyleContext.o: lexlib/StyleContext.cxx include/ILexer.h \ + include/Sci_Position.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h +curses/WordList.o: lexlib/WordList.cxx lexlib/WordList.h +curses/LexA68k.o: lexers/LexA68k.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexAbaqus.o: lexers/LexAbaqus.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexAda.o: lexers/LexAda.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexAPDL.o: lexers/LexAPDL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexAsm.o: lexers/LexAsm.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexAsn1.o: lexers/LexAsn1.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexASY.o: lexers/LexASY.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexAU3.o: lexers/LexAU3.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexAVE.o: lexers/LexAVE.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexAVS.o: lexers/LexAVS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexBaan.o: lexers/LexBaan.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexBash.o: lexers/LexBash.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SubStyles.h lexlib/DefaultLexer.h +curses/LexBasic.o: lexers/LexBasic.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexBatch.o: lexers/LexBatch.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexBibTeX.o: lexers/LexBibTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexBullant.o: lexers/LexBullant.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexCaml.o: lexers/LexCaml.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexCIL.o: lexers/LexCIL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexCLW.o: lexers/LexCLW.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexCmake.o: lexers/LexCmake.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexCOBOL.o: lexers/LexCOBOL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexCoffeeScript.o: lexers/LexCoffeeScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexConf.o: lexers/LexConf.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexCPP.o: lexers/LexCPP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/SparseState.h lexlib/SubStyles.h +curses/LexCrontab.o: lexers/LexCrontab.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexCsound.o: lexers/LexCsound.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexCSS.o: lexers/LexCSS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexD.o: lexers/LexD.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexDiff.o: lexers/LexDiff.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexDMAP.o: lexers/LexDMAP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexDMIS.o: lexers/LexDMIS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/DefaultLexer.h +curses/LexECL.o: lexers/LexECL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h +curses/LexEDIFACT.o: lexers/LexEDIFACT.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/LexAccessor.h lexlib/LexerModule.h lexlib/DefaultLexer.h +curses/LexEiffel.o: lexers/LexEiffel.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexErlang.o: lexers/LexErlang.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexErrorList.o: lexers/LexErrorList.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexEScript.o: lexers/LexEScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexFlagship.o: lexers/LexFlagship.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexForth.o: lexers/LexForth.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexFortran.o: lexers/LexFortran.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexGAP.o: lexers/LexGAP.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexGui4Cli.o: lexers/LexGui4Cli.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexHaskell.o: lexers/LexHaskell.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/PropSetSimple.h lexlib/WordList.h lexlib/LexAccessor.h \ + lexlib/Accessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/CharacterCategory.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/DefaultLexer.h +curses/LexHex.o: lexers/LexHex.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexHTML.o: lexers/LexHTML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexIndent.o: lexers/LexIndent.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexInno.o: lexers/LexInno.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexJSON.o: lexers/LexJSON.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexKix.o: lexers/LexKix.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexKVIrc.o: lexers/LexKVIrc.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexLaTeX.o: lexers/LexLaTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/LexerBase.h +curses/LexLisp.o: lexers/LexLisp.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexLout.o: lexers/LexLout.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexLPeg.o: lexers/LexLPeg.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/LexerModule.h +curses/LexLua.o: lexers/LexLua.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMagik.o: lexers/LexMagik.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMake.o: lexers/LexMake.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMarkdown.o: lexers/LexMarkdown.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMatlab.o: lexers/LexMatlab.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMaxima.o: lexers/LexMaxima.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMetapost.o: lexers/LexMetapost.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMMIXAL.o: lexers/LexMMIXAL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexModula.o: lexers/LexModula.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMPT.o: lexers/LexMPT.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMSSQL.o: lexers/LexMSSQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexMySQL.o: lexers/LexMySQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexNim.o: lexers/LexNim.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexNimrod.o: lexers/LexNimrod.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexNsis.o: lexers/LexNsis.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexNull.o: lexers/LexNull.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexOpal.o: lexers/LexOpal.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexOScript.o: lexers/LexOScript.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexPascal.o: lexers/LexPascal.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexPB.o: lexers/LexPB.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexPerl.o: lexers/LexPerl.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/StyleContext.h lexlib/CharacterSet.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexPLM.o: lexers/LexPLM.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexPO.o: lexers/LexPO.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexPOV.o: lexers/LexPOV.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexPowerPro.o: lexers/LexPowerPro.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexPowerShell.o: lexers/LexPowerShell.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexProgress.o: lexers/LexProgress.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SparseState.h lexlib/DefaultLexer.h +curses/LexProps.o: lexers/LexProps.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexPS.o: lexers/LexPS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexPython.o: lexers/LexPython.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/StringCopy.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/SubStyles.h \ + lexlib/DefaultLexer.h +curses/LexR.o: lexers/LexR.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexRebol.o: lexers/LexRebol.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexRegistry.o: lexers/LexRegistry.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/DefaultLexer.h +curses/LexRuby.o: lexers/LexRuby.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexRust.o: lexers/LexRust.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/PropSetSimple.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexSAS.o: lexers/LexSAS.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexScriptol.o: lexers/LexScriptol.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexSmalltalk.o: lexers/LexSmalltalk.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexSML.o: lexers/LexSML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexSorcus.o: lexers/LexSorcus.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexSpecman.o: lexers/LexSpecman.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexSpice.o: lexers/LexSpice.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexSQL.o: lexers/LexSQL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h lexlib/OptionSet.h \ + lexlib/SparseState.h lexlib/DefaultLexer.h +curses/LexStata.o: lexers/LexStata.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexSTTXT.o: lexers/LexSTTXT.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexTACL.o: lexers/LexTACL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexTADS3.o: lexers/LexTADS3.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexTAL.o: lexers/LexTAL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexTCL.o: lexers/LexTCL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexTCMD.o: lexers/LexTCMD.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexTeX.o: lexers/LexTeX.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexTxt2tags.o: lexers/LexTxt2tags.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexVB.o: lexers/LexVB.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexVerilog.o: lexers/LexVerilog.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/LexerModule.h \ + lexlib/OptionSet.h lexlib/SubStyles.h lexlib/DefaultLexer.h +curses/LexVHDL.o: lexers/LexVHDL.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/LexVisualProlog.o: lexers/LexVisualProlog.cxx include/ILexer.h \ + include/Sci_Position.h include/Scintilla.h include/SciLexer.h \ + lexlib/WordList.h lexlib/LexAccessor.h lexlib/Accessor.h \ + lexlib/StyleContext.h lexlib/CharacterSet.h lexlib/CharacterCategory.h \ + lexlib/LexerModule.h lexlib/OptionSet.h lexlib/DefaultLexer.h +curses/LexYAML.o: lexers/LexYAML.cxx include/ILexer.h include/Sci_Position.h \ + include/Scintilla.h include/SciLexer.h lexlib/WordList.h \ + lexlib/LexAccessor.h lexlib/Accessor.h lexlib/StyleContext.h \ + lexlib/CharacterSet.h lexlib/LexerModule.h +curses/ScintillaCurses.o: curses/ScintillaCurses.cxx include/Platform.h \ + include/ILoader.h include/Sci_Position.h include/ILexer.h \ + include/Scintilla.h lexlib/CharacterCategory.h src/Position.h \ + src/UniqueString.h src/SplitVector.h src/Partitioning.h src/RunStyles.h \ + src/ContractionState.h src/CellBuffer.h src/CallTip.h src/KeyMap.h \ + src/Indicator.h src/LineMarker.h src/Style.h src/ViewStyle.h \ + src/CharClassify.h src/Decoration.h src/CaseFolder.h src/Document.h \ + src/UniConversion.h src/Selection.h src/PositionCache.h src/EditModel.h \ + src/MarginView.h src/EditView.h src/Editor.h src/AutoComplete.h \ + src/ScintillaBase.h curses/ScintillaCurses.h diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/InfoBar.h b/dep/scintilla/scintilla-3.10.6/cocoa/InfoBar.h similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/InfoBar.h rename to dep/scintilla/scintilla-3.10.6/cocoa/InfoBar.h diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/InfoBar.mm b/dep/scintilla/scintilla-3.10.6/cocoa/InfoBar.mm similarity index 94% rename from dep/scintilla/scintilla-3.6.0/cocoa/InfoBar.mm rename to dep/scintilla/scintilla-3.10.6/cocoa/InfoBar.mm index 01e2ce49..a351ce40 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/InfoBar.mm +++ b/dep/scintilla/scintilla-3.10.6/cocoa/InfoBar.mm @@ -10,6 +10,8 @@ * This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt). */ +#include + #import "InfoBar.h" //-------------------------------------------------------------------------------------------------- @@ -36,7 +38,7 @@ if (heightDelta > 0) { newRect.size.height -= heightDelta; - newRect.origin.y += ceil(heightDelta / 2); + newRect.origin.y += std::ceil(heightDelta / 2); } } @@ -88,6 +90,10 @@ NSBundle* bundle = [NSBundle bundleForClass: [InfoBar class]]; NSString* path = [bundle pathForResource: @"info_bar_bg" ofType: @"tiff" inDirectory: nil]; + // macOS 10.13 introduced bug where pathForResource: fails on SMB share + if (path == nil) { + path = [[bundle bundlePath] stringByAppendingPathComponent: @"Resources/info_bar_bg.tiff"]; + } mBackground = [[NSImage alloc] initWithContentsOfFile: path]; if (![mBackground isValid]) NSLog(@"Background image for info bar is invalid."); @@ -154,7 +160,7 @@ static float BarFontSize = 10.0; unsigned numberOfDefaultItems = sizeof(DefaultScaleMenuLabels) / sizeof(NSString *); // Create the popup button. - mZoomPopup = [[NSPopUpButton allocWithZone:[self zone]] initWithFrame: NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown: NO]; + mZoomPopup = [[NSPopUpButton alloc] initWithFrame: NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown: NO]; // No border or background please. [[mZoomPopup cell] setBordered: NO]; @@ -242,11 +248,13 @@ static float BarFontSize = 10.0; { // Since the background is seamless, we don't need to take care for the proper offset. // Simply tile the background over the invalid rectangle. - NSPoint target = {rect.origin.x, 0}; - while (target.x < rect.origin.x + rect.size.width) - { - [mBackground drawAtPoint: target fromRect: NSZeroRect operation: NSCompositeCopy fraction: 1]; - target.x += mBackground.size.width; + if (mBackground.size.width != 0) { + NSPoint target = {rect.origin.x, 0}; + while (target.x < rect.origin.x + rect.size.width) + { + [mBackground drawAtPoint: target fromRect: NSZeroRect operation: NSCompositeCopy fraction: 1]; + target.x += mBackground.size.width; + } } // Draw separator lines between items. @@ -346,7 +354,7 @@ static float BarFontSize = 10.0; { mDisplayMask = display; [self positionSubViews]; - [self needsDisplay]; + [self setNeedsDisplay: YES]; } } @@ -384,7 +392,7 @@ static float BarFontSize = 10.0; // We only work with some preset zoom values. If the given value does not correspond // to one then show no selection. - while (count < numberOfDefaultItems && (fabs(newScaleFactor - DefaultScaleMenuFactors[count]) > 0.07)) + while (count < numberOfDefaultItems && (std::abs(newScaleFactor - DefaultScaleMenuFactors[count]) > 0.07)) count++; if (count == numberOfDefaultItems) [mZoomPopup selectItemAtIndex: -1]; diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/InfoBarCommunicator.h b/dep/scintilla/scintilla-3.10.6/cocoa/InfoBarCommunicator.h similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/InfoBarCommunicator.h rename to dep/scintilla/scintilla-3.10.6/cocoa/InfoBarCommunicator.h diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/PlatCocoa.h b/dep/scintilla/scintilla-3.10.6/cocoa/PlatCocoa.h similarity index 61% rename from dep/scintilla/scintilla-3.6.0/cocoa/PlatCocoa.h rename to dep/scintilla/scintilla-3.10.6/cocoa/PlatCocoa.h index 60977c92..c9b3a835 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/PlatCocoa.h +++ b/dep/scintilla/scintilla-3.10.6/cocoa/PlatCocoa.h @@ -7,21 +7,21 @@ #ifndef PLATCOCOA_H #define PLATCOCOA_H -#include - -#include - #include +#include #include #include +#include + #include -#include "QuartzTextLayout.h" #include "Platform.h" #include "Scintilla.h" -NSRect PRectangleToNSRect(Scintilla::PRectangle& rc); +#include "QuartzTextLayout.h" + +NSRect PRectangleToNSRect(const Scintilla::PRectangle& rc); Scintilla::PRectangle NSRectToPRectangle(NSRect& rc); CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet); @@ -47,12 +47,12 @@ private: CGContextRef gc; /** The text layout instance */ - QuartzTextLayout* textLayout; + std::unique_ptr textLayout; int codePage; int verticalDeviceResolution; /** If the surface is a bitmap context, contains a reference to the bitmap data. */ - uint8_t* bitmapData; + std::unique_ptr bitmapData; /** If the surface is a bitmap context, stores the dimensions of the bitmap. */ int bitmapWidth; int bitmapHeight; @@ -65,57 +65,59 @@ private: static const int BITS_PER_COMPONENT = 8; static const int BITS_PER_PIXEL = BITS_PER_COMPONENT * 4; static const int BYTES_PER_PIXEL = BITS_PER_PIXEL / 8; + + void Clear(); + public: SurfaceImpl(); - ~SurfaceImpl(); + ~SurfaceImpl() override; - void Init(WindowID wid); - void Init(SurfaceID sid, WindowID wid); - void InitPixMap(int width, int height, Surface *surface_, WindowID wid); + void Init(WindowID wid) override; + void Init(SurfaceID sid, WindowID wid) override; + void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override; CGContextRef GetContext() { return gc; } - void Release(); - bool Initialised(); - void PenColour(ColourDesired fore); + void Release() override; + bool Initialised() override; + void PenColour(ColourDesired fore) override; /** Returns a CGImageRef that represents the surface. Returns NULL if this is not possible. */ CGImageRef GetImage(); void CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect, PRectangle dstRect); - int LogPixelsY(); - int DeviceHeightFont(int points); - void MoveTo(int x_, int y_); - void LineTo(int x_, int y_); - void Polygon(Scintilla::Point *pts, int npts, ColourDesired fore, ColourDesired back); - void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back); - void FillRectangle(PRectangle rc, ColourDesired back); - void FillRectangle(PRectangle rc, Surface &surfacePattern); - void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back); + int LogPixelsY() override; + int DeviceHeightFont(int points) override; + void MoveTo(int x_, int y_) override; + void LineTo(int x_, int y_) override; + void Polygon(Scintilla::Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; + void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void FillRectangle(PRectangle rc, ColourDesired back) override; + void FillRectangle(PRectangle rc, Surface &surfacePattern) override; + void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int flags); - void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage); - void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back); - void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource); + ColourDesired outline, int alphaOutline, int flags) override; + void GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions options) override; + void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override; + void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource) override; void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, - ColourDesired back); + ColourDesired back) override; void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, - ColourDesired back); - void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore); - void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions); - XYPOSITION WidthText(Font &font_, const char *s, int len); - XYPOSITION WidthChar(Font &font_, char ch); - XYPOSITION Ascent(Font &font_); - XYPOSITION Descent(Font &font_); - XYPOSITION InternalLeading(Font &font_); - XYPOSITION ExternalLeading(Font &font_); - XYPOSITION Height(Font &font_); - XYPOSITION AverageCharWidth(Font &font_); + ColourDesired back) override; + void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore) override; + void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) override; + XYPOSITION WidthText(Font &font_, const char *s, int len) override; + XYPOSITION Ascent(Font &font_) override; + XYPOSITION Descent(Font &font_) override; + XYPOSITION InternalLeading(Font &font_) override; + XYPOSITION Height(Font &font_) override; + XYPOSITION AverageCharWidth(Font &font_) override; - void SetClip(PRectangle rc); - void FlushCachedState(); + void SetClip(PRectangle rc) override; + void FlushCachedState() override; - void SetUnicodeMode(bool unicodeMode_); - void SetDBCSMode(int codePage_); + void SetUnicodeMode(bool unicodeMode_) override; + void SetDBCSMode(int codePage_) override; }; // SurfaceImpl class } // Scintilla namespace diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/PlatCocoa.mm b/dep/scintilla/scintilla-3.10.6/cocoa/PlatCocoa.mm similarity index 78% rename from dep/scintilla/scintilla-3.6.0/cocoa/PlatCocoa.mm rename to dep/scintilla/scintilla-3.10.6/cocoa/PlatCocoa.mm index 1d62385c..20a160d8 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/PlatCocoa.mm +++ b/dep/scintilla/scintilla-3.10.6/cocoa/PlatCocoa.mm @@ -12,26 +12,31 @@ * This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt). */ -#include -#include - +#include #include +#include #include #include +#include #include #include #include +#include + +#include #import #import "Platform.h" -#import "ScintillaView.h" -#import "ScintillaCocoa.h" -#import "PlatCocoa.h" #include "StringCopy.h" #include "XPM.h" +#include "UniConversion.h" + +#import "ScintillaView.h" +#import "ScintillaCocoa.h" +#import "PlatCocoa.h" using namespace Scintilla; @@ -42,7 +47,7 @@ extern sptr_t scintilla_send_message(void* sci, unsigned int iMessage, uptr_t wP /** * Converts a PRectangle as used by Scintilla to standard Obj-C NSRect structure . */ -NSRect PRectangleToNSRect(PRectangle& rc) +NSRect PRectangleToNSRect(const PRectangle& rc) { return NSMakeRect(rc.left, rc.top, rc.Width(), rc.Height()); } @@ -69,37 +74,9 @@ inline CGRect PRectangleToCGRect(PRectangle& rc) return CGRectMake(rc.left, rc.top, rc.Width(), rc.Height()); } -//-------------------------------------------------------------------------------------------------- - -/** - * Converts a Quartz-style rectangle to a PRectangle structure as used by Scintilla. - */ -inline PRectangle CGRectToPRectangle(const CGRect& rect) -{ - PRectangle rc; - rc.left = (int)(rect.origin.x + 0.5); - rc.top = (int)(rect.origin.y + 0.5); - rc.right = (int)(rect.origin.x + rect.size.width + 0.5); - rc.bottom = (int)(rect.origin.y + rect.size.height + 0.5); - return rc; -} - -//----------------- Point -------------------------------------------------------------------------- - -/** - * Converts a point given as a long into a native Point structure. - */ -Scintilla::Point Scintilla::Point::FromLong(long lpoint) -{ - return Scintilla::Point( - Platform::LowShortFromLong(lpoint), - Platform::HighShortFromLong(lpoint) - ); -} - //----------------- Font --------------------------------------------------------------------------- -Font::Font(): fid(0) +Font::Font() noexcept : fid(0) { } @@ -112,10 +89,18 @@ Font::~Font() //-------------------------------------------------------------------------------------------------- -static int FontCharacterSet(Font &f) { - return reinterpret_cast(f.GetID())->getCharacterSet(); +static QuartzTextStyle *TextStyleFromFont(Font &f) { + return static_cast(f.GetID()); } +//-------------------------------------------------------------------------------------------------- + +static int FontCharacterSet(Font &f) { + return TextStyleFromFont(f)->getCharacterSet(); +} + +//-------------------------------------------------------------------------------------------------- + /** * Creates a CTFontRef with the given properties. */ @@ -137,7 +122,7 @@ void Font::Create(const FontParameters &fp) void Font::Release() { if (fid) - delete reinterpret_cast( fid ); + delete static_cast( fid ); fid = 0; } @@ -150,11 +135,11 @@ SurfaceImpl::SurfaceImpl() y = 0; gc = NULL; - textLayout = new QuartzTextLayout(NULL); + textLayout.reset(new QuartzTextLayout()); codePage = 0; verticalDeviceResolution = 0; - bitmapData = NULL; // Release will try and delete bitmapData if != NULL + bitmapData.reset(); // Release will try and delete bitmapData if != nullptr bitmapWidth = 0; bitmapHeight = 0; @@ -165,23 +150,20 @@ SurfaceImpl::SurfaceImpl() SurfaceImpl::~SurfaceImpl() { - Release(); - delete textLayout; + Clear(); } //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::Release() +void SurfaceImpl::Clear() { - textLayout->setContext (NULL); - if ( bitmapData != NULL ) + if (bitmapData) { - delete[] bitmapData; + bitmapData.reset(); // We only "own" the graphics context if we are a bitmap context - if (gc != NULL) + if (gc) CGContextRelease(gc); } - bitmapData = NULL; gc = NULL; bitmapWidth = 0; @@ -192,6 +174,12 @@ void SurfaceImpl::Release() //-------------------------------------------------------------------------------------------------- +void SurfaceImpl::Release() { + Clear(); +} + +//-------------------------------------------------------------------------------------------------- + bool SurfaceImpl::Initialised() { // We are initalised if the graphics context is not null @@ -216,9 +204,8 @@ void SurfaceImpl::Init(WindowID) void SurfaceImpl::Init(SurfaceID sid, WindowID) { Release(); - gc = reinterpret_cast(sid); + gc = static_cast(sid); CGContextSetLineWidth(gc, 1.0); - textLayout->setContext(gc); } //-------------------------------------------------------------------------------------------------- @@ -240,9 +227,9 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface* surface_, WindowID return; // Create the bitmap. - bitmapData = new uint8_t[bitmapByteCount]; + bitmapData.reset(new uint8_t[bitmapByteCount]); // create the context - gc = CGBitmapContextCreate(bitmapData, + gc = CGBitmapContextCreate(bitmapData.get(), width, height, BITS_PER_COMPONENT, @@ -254,15 +241,13 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface* surface_, WindowID { // the context couldn't be created for some reason, // and we have no use for the bitmap without the context - delete[] bitmapData; - bitmapData = NULL; + bitmapData.reset(); } - textLayout->setContext (gc); // the context retains the color space, so we can release it CGColorSpaceRelease(colorSpace); - if (gc != NULL && bitmapData != NULL) + if (gc && bitmapData) { // "Erase" to white. CGContextClearRect( gc, CGRectMake( 0, 0, width, height ) ); @@ -289,7 +274,7 @@ void SurfaceImpl::PenColour(ColourDesired fore) { if (gc) { - ColourDesired colour(fore.AsLong()); + ColourDesired colour(fore.AsInteger()); // Set the Stroke color to match CGContextSetRGBStrokeColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, @@ -303,7 +288,7 @@ void SurfaceImpl::FillColour(const ColourDesired& back) { if (gc) { - ColourDesired colour(back.AsLong()); + ColourDesired colour(back.AsInteger()); // Set the Fill color to match CGContextSetRGBFillColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, @@ -316,7 +301,7 @@ void SurfaceImpl::FillColour(const ColourDesired& back) CGImageRef SurfaceImpl::GetImage() { // For now, assume that GetImage can only be called on PixMap surfaces. - if (bitmapData == NULL) + if (!bitmapData) return NULL; CGContextFlush(gc); @@ -326,12 +311,12 @@ CGImageRef SurfaceImpl::GetImage() if( colorSpace == NULL ) return NULL; - const int bitmapBytesPerRow = ((int) bitmapWidth * BYTES_PER_PIXEL); - const int bitmapByteCount = (bitmapBytesPerRow * (int) bitmapHeight); + const int bitmapBytesPerRow = bitmapWidth * BYTES_PER_PIXEL; + const int bitmapByteCount = bitmapBytesPerRow * bitmapHeight; // Make a copy of the bitmap data for the image creation and divorce it // From the SurfaceImpl lifetime - CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, bitmapData, bitmapByteCount); + CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, bitmapData.get(), bitmapByteCount); // Create a data provider. CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(dataRef); @@ -418,13 +403,13 @@ void SurfaceImpl::LineTo(int x_, int y_) //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::Polygon(Scintilla::Point *pts, int npts, ColourDesired fore, +void SurfaceImpl::Polygon(Scintilla::Point *pts, size_t npts, ColourDesired fore, ColourDesired back) { // Allocate memory for the array of points. std::vector points(npts); - for (int i = 0;i < npts;i++) + for (size_t i = 0;i < npts;i++) { // Quartz floating point issues: plot the MIDDLE of the pixels points[i].x = pts[i].x + 0.5; @@ -480,16 +465,17 @@ void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) //-------------------------------------------------------------------------------------------------- -void drawImageRefCallback(CGImageRef pattern, CGContextRef gc) +static void drawImageRefCallback(void *info, CGContextRef gc) { + CGImageRef pattern = static_cast(info); CGContextDrawImage(gc, CGRectMake(0, 0, CGImageGetWidth(pattern), CGImageGetHeight(pattern)), pattern); } //-------------------------------------------------------------------------------------------------- -void releaseImageRefCallback(CGImageRef pattern) +static void releaseImageRefCallback(void *info) { - CGImageRelease(pattern); + CGImageRelease(static_cast(info)); } //-------------------------------------------------------------------------------------------------- @@ -506,9 +492,7 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) return; } - const CGPatternCallbacks drawImageCallbacks = { 0, - reinterpret_cast(drawImageRefCallback), - reinterpret_cast(releaseImageRefCallback) }; + const CGPatternCallbacks drawImageCallbacks = { 0, drawImageRefCallback, releaseImageRefCallback }; CGPatternRef pattern = CGPatternCreate(image, CGRectMake(0, 0, patternSurface.bitmapWidth, patternSurface.bitmapHeight), @@ -707,8 +691,52 @@ void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, Colou } } +void Scintilla::SurfaceImpl::GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions options) { + if (!gc) { + return; + } + + CGPoint ptStart = CGPointMake(rc.left, rc.top); + CGPoint ptEnd = CGPointMake(rc.left, rc.bottom); + if (options == GradientOptions::leftToRight) { + ptEnd = CGPointMake(rc.right, rc.top); + } + + std::vector components; + std::vector locations; + for (const ColourStop &stop : stops) { + locations.push_back(stop.position); + components.push_back(stop.colour.GetRedComponent()); + components.push_back(stop.colour.GetGreenComponent()); + components.push_back(stop.colour.GetBlueComponent()); + components.push_back(stop.colour.GetAlphaComponent()); + } + + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + if (!colorSpace) { + return; + } + + CGGradientRef gradiantRef = CGGradientCreateWithColorComponents(colorSpace, + components.data(), + locations.data(), + locations.size()); + if (gradiantRef) { + CGContextSaveGState(gc); + CGRect rect = PRectangleToCGRect(rc); + CGContextClipToRect(gc, rect); + CGContextBeginPath(gc); + CGContextAddRect(gc, rect); + CGContextClosePath(gc); + CGContextDrawLinearGradient(gc, gradiantRef, ptStart, ptEnd, 0); + CGGradientRelease(gradiantRef); + CGContextRestoreGState(gc); + } + CGColorSpaceRelease(colorSpace); +} + static void ProviderReleaseData(void *, const void *data, size_t) { - const unsigned char *pixels = reinterpret_cast(data); + const unsigned char *pixels = static_cast(data); delete []pixels; } @@ -718,8 +746,8 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char // Create an RGB color space. CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); if (colorSpace) { - const int bitmapBytesPerRow = ((int) width * 4); - const int bitmapByteCount = (bitmapBytesPerRow * (int) height); + const int bitmapBytesPerRow = width * 4; + const int bitmapByteCount = bitmapBytesPerRow * height; // Create a data provider. CGDataProviderRef dataProvider = 0; @@ -790,8 +818,8 @@ void SurfaceImpl::CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect, CGRect dst = PRectangleToCGRect(dstRect); /* source from QuickDrawToQuartz2D.pdf on developer.apple.com */ - float w = (float) CGImageGetWidth(image); - float h = (float) CGImageGetHeight(image); + const float w = static_cast(CGImageGetWidth(image)); + const float h = static_cast(CGImageGetHeight(image)); CGRect drawRect = CGRectMake (0, 0, w, h); if (!CGRectEqualToRect (src, dst)) { @@ -925,28 +953,16 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION yba ColourDesired fore) { CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); - ColourDesired colour(fore.AsLong()); + ColourDesired colour(fore.AsInteger()); CGColorRef color = CGColorCreateGenericRGB(colour.GetRed()/255.0,colour.GetGreen()/255.0,colour.GetBlue()/255.0,1.0); - QuartzTextStyle* style = reinterpret_cast(font_.GetID()); - style->setCTStyleColor(color); + QuartzTextStyle *style = TextStyleFromFont(font_); + style->setCTStyleColour(color); CGColorRelease(color); - textLayout->setText (reinterpret_cast(s), len, encoding, *reinterpret_cast(font_.GetID())); - textLayout->draw(rc.left, ybase); -} - -static size_t utf8LengthFromLead(unsigned char uch) { - if (uch >= (0x80 + 0x40 + 0x20 + 0x10)) { - return 4; - } else if (uch >= (0x80 + 0x40 + 0x20)) { - return 3; - } else if (uch >= (0x80)) { - return 2; - } else { - return 1; - } + textLayout->setText(s, len, encoding, *style); + textLayout->draw(gc, rc.left, ybase); } //-------------------------------------------------------------------------------------------------- @@ -954,7 +970,7 @@ static size_t utf8LengthFromLead(unsigned char uch) { void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) { CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); - textLayout->setText (reinterpret_cast(s), len, encoding, *reinterpret_cast(font_.GetID())); + textLayout->setText(s, len, encoding, *TextStyleFromFont(font_)); CTLineRef mLine = textLayout->getCTLine(); assert(mLine != NULL); @@ -963,13 +979,13 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION // Map the widths given for UTF-16 characters back onto the UTF-8 input string CFIndex fit = textLayout->getStringLength(); int ui=0; - const unsigned char *us = reinterpret_cast(s); int i=0; while (ui(xPosition); } ui += codeUnits; @@ -983,7 +999,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION } else if (codePage) { int ui = 0; for (int i=0;i(xPosition); @@ -1003,26 +1019,13 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) { if (font_.GetID()) { CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); - textLayout->setText (reinterpret_cast(s), len, encoding, *reinterpret_cast(font_.GetID())); + textLayout->setText(s, len, encoding, *TextStyleFromFont(font_)); return static_cast(textLayout->MeasureStringWidth()); } return 1; } -XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) { - char str[2] = { ch, '\0' }; - if (font_.GetID()) - { - CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); - textLayout->setText (reinterpret_cast(str), 1, encoding, *reinterpret_cast(font_.GetID())); - - return textLayout->MeasureStringWidth(); - } - else - return 1; -} - // This string contains a good range of characters to test for size. const char sizeString[] = "`~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890" "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -1031,7 +1034,7 @@ XYPOSITION SurfaceImpl::Ascent(Font &font_) { if (!font_.GetID()) return 1; - float ascent = reinterpret_cast( font_.GetID() )->getAscent(); + float ascent = TextStyleFromFont(font_)->getAscent(); return ascent + 0.5f; } @@ -1040,7 +1043,7 @@ XYPOSITION SurfaceImpl::Descent(Font &font_) { if (!font_.GetID()) return 1; - float descent = reinterpret_cast( font_.GetID() )->getDescent(); + float descent = TextStyleFromFont(font_)->getDescent(); return descent + 0.5f; } @@ -1049,15 +1052,6 @@ XYPOSITION SurfaceImpl::InternalLeading(Font &) { return 0; } -XYPOSITION SurfaceImpl::ExternalLeading(Font &font_) { - if (!font_.GetID()) - return 1; - - float leading = reinterpret_cast( font_.GetID() )->getLeading(); - return leading + 0.5f; - -} - XYPOSITION SurfaceImpl::Height(Font &font_) { return Ascent(font_) + Descent(font_); @@ -1071,7 +1065,7 @@ XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) { const int sizeStringLength = ELEMENTS( sizeString ); XYPOSITION width = WidthText( font_, sizeString, sizeStringLength ); - return (int) ((width / (float) sizeStringLength) + 0.5); + return round(width / sizeStringLength); } void SurfaceImpl::SetClip(PRectangle rc) { @@ -1110,32 +1104,24 @@ Window::~Window() //-------------------------------------------------------------------------------------------------- -bool Window::HasFocus() -{ - NSView* container = reinterpret_cast(wid); - return [[container window] firstResponder] == container; -} - -//-------------------------------------------------------------------------------------------------- - -static CGFloat ScreenMax(NSWindow* win) +static CGFloat ScreenMax() { return NSMaxY([[NSScreen mainScreen] frame]); } //-------------------------------------------------------------------------------------------------- -PRectangle Window::GetPosition() +PRectangle Window::GetPosition() const { if (wid) { NSRect rect; - id idWin = reinterpret_cast(wid); + id idWin = static_cast(wid); NSWindow* win; if ([idWin isKindOfClass: [NSView class]]) { // NSView - NSView* view = reinterpret_cast(idWin); + NSView* view = idWin; win = [view window]; rect = [view convertRect: [view bounds] toView: nil]; rect = [win convertRectToScreen:rect]; @@ -1143,10 +1129,10 @@ PRectangle Window::GetPosition() else { // NSWindow - win = reinterpret_cast(idWin); + win = idWin; rect = [win frame]; } - CGFloat screenHeight = ScreenMax(win); + CGFloat screenHeight = ScreenMax(); // Invert screen positions to match Scintilla return PRectangle( static_cast(NSMinX(rect)), static_cast(screenHeight - NSMaxY(rect)), @@ -1164,13 +1150,13 @@ void Window::SetPosition(PRectangle rc) { if (wid) { - id idWin = reinterpret_cast(wid); + id idWin = static_cast(wid); if ([idWin isKindOfClass: [NSView class]]) { // NSView // Moves this view inside the parent view NSRect nsrc = NSMakeRect(rc.left, rc.bottom, rc.Width(), rc.Height()); - NSView* view = reinterpret_cast(idWin); + NSView* view = idWin; nsrc = [[view window] convertRectFromScreen:nsrc]; [view setFrame: nsrc]; } @@ -1178,8 +1164,8 @@ void Window::SetPosition(PRectangle rc) { // NSWindow PLATFORM_ASSERT([idWin isKindOfClass: [NSWindow class]]); - NSWindow* win = reinterpret_cast(idWin); - CGFloat screenHeight = ScreenMax(win); + NSWindow* win = idWin; + CGFloat screenHeight = ScreenMax(); NSRect nsrc = NSMakeRect(rc.left, screenHeight - rc.bottom, rc.Width(), rc.Height()); [win setFrame: nsrc display:YES]; @@ -1189,9 +1175,9 @@ void Window::SetPosition(PRectangle rc) //-------------------------------------------------------------------------------------------------- -void Window::SetPositionRelative(PRectangle rc, Window window) +void Window::SetPositionRelative(PRectangle rc, const Window *window) { - PRectangle rcOther = window.GetPosition(); + PRectangle rcOther = window->GetPosition(); rc.left += rcOther.left; rc.right += rcOther.left; rc.top += rcOther.top; @@ -1201,7 +1187,7 @@ void Window::SetPositionRelative(PRectangle rc, Window window) //-------------------------------------------------------------------------------------------------- -PRectangle Window::GetClientPosition() +PRectangle Window::GetClientPosition() const { // This means, in MacOS X terms, get the "frame bounds". Call GetPosition, just like on Win32. return GetPosition(); @@ -1213,10 +1199,10 @@ void Window::Show(bool show) { if (wid) { - id idWin = reinterpret_cast(wid); + id idWin = static_cast(wid); if ([idWin isKindOfClass: [NSWindow class]]) { - NSWindow* win = reinterpret_cast(idWin); + NSWindow* win = idWin; if (show) { [win orderFront:nil]; @@ -1238,17 +1224,17 @@ void Window::InvalidateAll() { if (wid) { - id idWin = reinterpret_cast(wid); + id idWin = static_cast(wid); NSView* container; if ([idWin isKindOfClass: [NSView class]]) { - container = reinterpret_cast(idWin); + container = idWin; } else { // NSWindow - NSWindow* win = reinterpret_cast(idWin); - container = reinterpret_cast([win contentView]); + NSWindow* win = idWin; + container = [win contentView]; container.needsDisplay = YES; } container.needsDisplay = YES; @@ -1264,17 +1250,17 @@ void Window::InvalidateRectangle(PRectangle rc) { if (wid) { - id idWin = reinterpret_cast(wid); + id idWin = static_cast(wid); NSView* container; if ([idWin isKindOfClass: [NSView class]]) { - container = reinterpret_cast(idWin); + container = idWin; } else { // NSWindow - NSWindow* win = reinterpret_cast(idWin); - container = reinterpret_cast([win contentView]); + NSWindow* win = idWin; + container = [win contentView]; } [container setNeedsDisplayInRect: PRectangleToNSRect(rc)]; } @@ -1297,10 +1283,10 @@ void Window::SetCursor(Cursor curs) { if (wid) { - id idWin = reinterpret_cast(wid); - if ([idWin isMemberOfClass: [SCIContentView class]]) + id idWin = static_cast(wid); + if ([idWin isKindOfClass: [SCIContentView class]]) { - SCIContentView* container = reinterpret_cast(idWin); + SCIContentView* container = idWin; [container setCursor: curs]; } } @@ -1308,37 +1294,21 @@ void Window::SetCursor(Cursor curs) //-------------------------------------------------------------------------------------------------- -void Window::SetTitle(const char* s) -{ - if (wid) - { - id idWin = reinterpret_cast(wid); - if ([idWin isKindOfClass: [NSWindow class]]) - { - NSWindow* win = reinterpret_cast(idWin); - NSString* sTitle = [NSString stringWithUTF8String:s]; - [win setTitle:sTitle]; - } - } -} - -//-------------------------------------------------------------------------------------------------- - PRectangle Window::GetMonitorRect(Point) { if (wid) { - id idWin = reinterpret_cast(wid); + id idWin = static_cast(wid); if ([idWin isKindOfClass: [NSView class]]) { - NSView* view = reinterpret_cast(idWin); + NSView* view = idWin; idWin = [view window]; } if ([idWin isKindOfClass: [NSWindow class]]) { PRectangle rcPosition = GetPosition(); - NSWindow* win = reinterpret_cast(idWin); + NSWindow* win = idWin; NSScreen* screen = [win screen]; NSRect rect = [screen visibleFrame]; CGFloat screenHeight = rect.origin.y + rect.size.height; @@ -1368,21 +1338,14 @@ static NSImage* ImageFromXPM(XPM* pxpm) const int width = pxpm->GetWidth(); const int height = pxpm->GetHeight(); PRectangle rcxpm(0, 0, width, height); - Surface* surfaceXPM = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); - if (surfaceXPM) - { - surfaceXPM->InitPixMap(width, height, NULL, NULL); - SurfaceImpl* surfaceIXPM = static_cast(surfaceXPM); - CGContextClearRect(surfaceIXPM->GetContext(), CGRectMake(0, 0, width, height)); - pxpm->Draw(surfaceXPM, rcxpm); - img = [[[NSImage alloc] initWithSize:NSZeroSize] autorelease]; - CGImageRef imageRef = surfaceIXPM->GetImage(); - NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage: imageRef]; - [img addRepresentation: bitmapRep]; - [bitmapRep release]; - CGImageRelease(imageRef); - delete surfaceXPM; - } + std::unique_ptr surfaceXPM(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); + surfaceXPM->InitPixMap(width, height, NULL, NULL); + SurfaceImpl* surfaceIXPM = static_cast(surfaceXPM.get()); + CGContextClearRect(surfaceIXPM->GetContext(), CGRectMake(0, 0, width, height)); + pxpm->Draw(surfaceXPM.get(), rcxpm); + CGImageRef imageRef = surfaceIXPM->GetImage(); + img = [[NSImage alloc] initWithCGImage:imageRef size: NSZeroSize]; + CGImageRelease(imageRef); } return img; } @@ -1393,7 +1356,9 @@ static NSImage* ImageFromXPM(XPM* pxpm) namespace { -// unnamed namespace hides IListBox interface +// Unnamed namespace hides local IListBox interface. +// IListBox is used to cross languages to send events from Objective C++ +// AutoCompletionDelegate and AutoCompletionDataSource to C++ ListBoxImpl. class IListBox { public: @@ -1401,19 +1366,44 @@ public: virtual NSImage* ImageForRow(NSInteger row) = 0; virtual NSString* TextForRow(NSInteger row) = 0; virtual void DoubleClick() = 0; + virtual void SelectionChange() = 0; }; -} // unnamed namespace +} + +//----------------- AutoCompletionDelegate --------------------------------------------------------- + +// AutoCompletionDelegate is an Objective C++ class so it can implement +// NSTableViewDelegate and receive tableViewSelectionDidChange events. + +@interface AutoCompletionDelegate : NSObject { + IListBox *box; +} + +@property IListBox *box; + +@end + +@implementation AutoCompletionDelegate + +@synthesize box; + +- (void) tableViewSelectionDidChange: (NSNotification *) notification { +#pragma unused(notification) + if (box) { + box->SelectionChange(); + } +} + +@end //----------------- AutoCompletionDataSource ------------------------------------------------------- -@interface AutoCompletionDataSource : -NSObject -#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 - -#endif -{ - IListBox* box; +// AutoCompletionDataSource provides data to display in the list box. +// It is also the target of the NSTableView so it receives double clicks. + +@interface AutoCompletionDataSource : NSObject { + IListBox *box; } @property IListBox* box; @@ -1525,13 +1515,10 @@ public: } }; -// Map from icon type to an NSImage* -typedef std::map ImageMap; - class ListBoxImpl : public ListBox, IListBox { private: - ImageMap images; + NSMutableDictionary *images; int lineHeight; bool unicodeMode; int desiredVisibleRows; @@ -1546,13 +1533,14 @@ private: NSTableColumn* colIcon; NSTableColumn* colText; AutoCompletionDataSource* ds; + AutoCompletionDelegate *acd; LinesData ld; - CallBackAction doubleClickAction; - void* doubleClickActionData; + IListBoxDelegate *delegate; public: ListBoxImpl() : + images(nil), lineHeight(10), unicodeMode(false), desiredVisibleRows(5), @@ -1565,45 +1553,47 @@ public: colIcon(nil), colText(nil), ds(nil), - doubleClickAction(nullptr), - doubleClickActionData(nullptr) + acd(nil), + delegate(nullptr) { + images = [[NSMutableDictionary alloc] init]; + } + ~ListBoxImpl() override { + [images release]; } - ~ListBoxImpl() {} // ListBox methods - void SetFont(Font& font); - void Create(Window& parent, int ctrlID, Scintilla::Point pt, int lineHeight_, bool unicodeMode_, int technology_); - void SetAverageCharWidth(int width); - void SetVisibleRows(int rows); - int GetVisibleRows() const; - PRectangle GetDesiredRect(); - int CaretFromEdge(); - void Clear(); - void Append(char* s, int type = -1); - int Length(); - void Select(int n); - int GetSelection(); - int Find(const char* prefix); - void GetValue(int n, char* value, int len); - void RegisterImage(int type, const char* xpm_data); - void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage); - void ClearRegisteredImages(); - void SetDoubleClickAction(CallBackAction action, void* data) - { - doubleClickAction = action; - doubleClickActionData = data; + void SetFont(Font& font) override; + void Create(Window& parent, int ctrlID, Scintilla::Point pt, int lineHeight_, bool unicodeMode_, int technology_) override; + void SetAverageCharWidth(int width) override; + void SetVisibleRows(int rows) override; + int GetVisibleRows() const override; + PRectangle GetDesiredRect() override; + int CaretFromEdge() override; + void Clear() override; + void Append(char* s, int type = -1) override; + int Length() override; + void Select(int n) override; + int GetSelection() override; + int Find(const char* prefix) override; + void GetValue(int n, char* value, int len) override; + void RegisterImage(int type, const char* xpm_data) override; + void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) override; + void ClearRegisteredImages() override; + void SetDelegate(IListBoxDelegate *lbDelegate) override { + delegate = lbDelegate; } - void SetList(const char* list, char separator, char typesep); + void SetList(const char* list, char separator, char typesep) override; // To clean up when closed void ReleaseViews(); // For access from AutoCompletionDataSource implement IListBox - int Rows(); - NSImage* ImageForRow(NSInteger row); - NSString* TextForRow(NSInteger row); - void DoubleClick(); + int Rows() override; + NSImage* ImageForRow(NSInteger row) override; + NSString* TextForRow(NSInteger row) override; + void DoubleClick() override; + void SelectionChange() override; }; void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt, @@ -1641,6 +1631,9 @@ void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt ds = [[AutoCompletionDataSource alloc] init]; [ds setBox:this]; [table setDataSource: ds]; // Weak reference + acd = [[AutoCompletionDelegate alloc] init]; + [acd setBox: this]; + [table setDelegate: acd]; [scroller setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; [[winLB contentView] addSubview: scroller]; @@ -1654,12 +1647,12 @@ void ListBoxImpl::SetFont(Font& font_) { // NSCell setFont takes an NSFont* rather than a CTFontRef but they // are the same thing toll-free bridged. - QuartzTextStyle* style = reinterpret_cast(font_.GetID()); + QuartzTextStyle *style = TextStyleFromFont(font_); font.Release(); font.SetID(new QuartzTextStyle(*style)); NSFont *pfont = (NSFont *)style->getFontRef(); [[colText dataCell] setFont: pfont]; - CGFloat itemHeight = ceil([pfont boundingRectForFont].size.height); + CGFloat itemHeight = std::ceil([pfont boundingRectForFont].size.height); [table setRowHeight:itemHeight]; } @@ -1692,6 +1685,7 @@ PRectangle ListBoxImpl::GetDesiredRect() rcDesired.bottom = rcDesired.top + static_cast(itemHeight * rows); rcDesired.right = rcDesired.left + maxItemWidth + aveCharWidth; + rcDesired.right += 4; // Ensures no truncation of text if (Length() > rows) { @@ -1704,7 +1698,7 @@ PRectangle ListBoxImpl::GetDesiredRect() [scroller setHasVerticalScroller:NO]; } rcDesired.right += maxIconWidth; - rcDesired.right += 6; + rcDesired.right += 6; // For icon space return rcDesired; } @@ -1719,6 +1713,7 @@ int ListBoxImpl::CaretFromEdge() void ListBoxImpl::ReleaseViews() { + [table setDataSource:nil]; [table release]; table = nil; [scroller release]; @@ -1727,6 +1722,8 @@ void ListBoxImpl::ReleaseViews() colIcon = nil; [colText release ]; colText = nil; + [acd release]; + acd = nil; [ds release]; ds = nil; } @@ -1750,19 +1747,15 @@ void ListBoxImpl::Append(char* s, int type) maxItemWidth = width; [colText setWidth: maxItemWidth]; } - ImageMap::iterator it = images.find(type); - if (it != images.end()) + NSImage *img = images[@(type)]; + if (img) { - NSImage* img = it->second; - if (img) + XYPOSITION widthIcon = static_cast(img.size.width); + if (widthIcon > maxIconWidth) { - XYPOSITION widthIcon = static_cast(img.size.width); - if (widthIcon > maxIconWidth) - { - [colIcon setHidden: NO]; - maxIconWidth = widthIcon; - [colIcon setWidth: maxIconWidth]; - } + [colIcon setHidden: NO]; + maxIconWidth = widthIcon; + [colIcon setWidth: maxIconWidth]; } } } @@ -1772,8 +1765,8 @@ void ListBoxImpl::SetList(const char* list, char separator, char typesep) Clear(); size_t count = strlen(list) + 1; std::vector words(list, list+count); - char* startword = words.data(); - char* numword = NULL; + char *startword = words.data(); + char *numword = nullptr; int i = 0; for (; words[i]; i++) { @@ -1784,7 +1777,7 @@ void ListBoxImpl::SetList(const char* list, char separator, char typesep) *numword = '\0'; Append(startword, numword?atoi(numword + 1):-1); startword = words.data() + i + 1; - numword = NULL; + numword = nullptr; } else if (words[i] == typesep) { @@ -1845,49 +1838,22 @@ void ListBoxImpl::RegisterImage(int type, const char* xpm_data) { XPM xpm(xpm_data); NSImage* img = ImageFromXPM(&xpm); - [img retain]; - ImageMap::iterator it=images.find(type); - if (it == images.end()) - { - images[type] = img; - } - else - { - [it->second release]; - it->second = img; - } + [images setObject:img forKey:@(type)]; + [img release]; } -void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) { - CGImageRef imageRef = ImageCreateFromRGBA(width, height, pixelsImage, false); - NSSize sz = {static_cast(width), static_cast(height)}; - NSImage *img = [[[NSImage alloc] initWithSize: sz] autorelease]; - NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage: imageRef]; - [img addRepresentation: bitmapRep]; - [bitmapRep release]; - CGImageRelease(imageRef); - [img retain]; - ImageMap::iterator it=images.find(type); - if (it == images.end()) - { - images[type] = img; - } - else - { - [it->second release]; - it->second = img; - } +void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) +{ + CGImageRef imageRef = ImageCreateFromRGBA(width, height, pixelsImage, false); + NSImage *img = [[NSImage alloc] initWithCGImage:imageRef size: NSZeroSize]; + CGImageRelease(imageRef); + [images setObject:img forKey:@(type)]; + [img release]; } void ListBoxImpl::ClearRegisteredImages() { - for (ImageMap::iterator it=images.begin(); - it != images.end(); ++it) - { - [it->second release]; - it->second = nil; - } - images.clear(); + [images removeAllObjects]; } int ListBoxImpl::Rows() @@ -1897,16 +1863,7 @@ int ListBoxImpl::Rows() NSImage* ListBoxImpl::ImageForRow(NSInteger row) { - ImageMap::iterator it = images.find(ld.GetType(row)); - if (it != images.end()) - { - NSImage* img = it->second; - return img; - } - else - { - return nil; - } + return images[@(ld.GetType(row))]; } NSString* ListBoxImpl::TextForRow(NSInteger row) @@ -1920,11 +1877,17 @@ NSString* ListBoxImpl::TextForRow(NSInteger row) return sTitle; } -void ListBoxImpl::DoubleClick() -{ - if (doubleClickAction) - { - doubleClickAction(doubleClickActionData); +void ListBoxImpl::DoubleClick() { + if (delegate) { + ListBoxEvent event(ListBoxEvent::EventType::doubleClick); + delegate->ListNotify(&event); + } +} + +void ListBoxImpl::SelectionChange() { + if (delegate) { + ListBoxEvent event(ListBoxEvent::EventType::selectionChange); + delegate->ListNotify(&event); } } @@ -1932,7 +1895,9 @@ void ListBoxImpl::DoubleClick() //----------------- ListBox ------------------------------------------------------------------------ -ListBox::ListBox() +// ListBox is implemented by the ListBoxImpl class. + +ListBox::ListBox() noexcept { } @@ -1957,11 +1922,10 @@ void Window::Destroy() } if (wid) { - id idWin = reinterpret_cast(wid); + id idWin = static_cast(wid); if ([idWin isKindOfClass: [NSWindow class]]) { - NSWindow* win = reinterpret_cast(idWin); - [win release]; + [idWin close]; } } wid = 0; @@ -1991,7 +1955,7 @@ void Window::Destroy() //----------------- Menu --------------------------------------------------------------------------- -Menu::Menu() +Menu::Menu() noexcept : mid(0) { } @@ -2008,7 +1972,7 @@ void Menu::CreatePopUp() void Menu::Destroy() { - ScintillaContextMenu* menu = reinterpret_cast(mid); + ScintillaContextMenu* menu = static_cast(mid); [menu release]; mid = NULL; } @@ -2021,34 +1985,6 @@ void Menu::Show(Point, Window &) // takes care to show it properly. } -//----------------- ElapsedTime -------------------------------------------------------------------- - -// ElapsedTime is used for precise performance measurements during development -// and not for anything a user sees. - -ElapsedTime::ElapsedTime() { - struct timeval curTime; - gettimeofday( &curTime, NULL ); - - bigBit = curTime.tv_sec; - littleBit = curTime.tv_usec; -} - -double ElapsedTime::Duration(bool reset) { - struct timeval curTime; - gettimeofday( &curTime, NULL ); - long endBigBit = curTime.tv_sec; - long endLittleBit = curTime.tv_usec; - double result = 1000000.0 * (endBigBit - bigBit); - result += endLittleBit - littleBit; - result /= 1000000.0; - if (reset) { - bigBit = endBigBit; - littleBit = endLittleBit; - } - return result; -} - //----------------- Platform ----------------------------------------------------------------------- ColourDesired Platform::Chrome() @@ -2104,93 +2040,6 @@ unsigned int Platform::DoubleClickTime() //-------------------------------------------------------------------------------------------------- -bool Platform::MouseButtonBounce() -{ - return false; -} - -//-------------------------------------------------------------------------------------------------- - -/** - * Helper method for the backend to reach through to the scintilla window. - */ -long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) -{ - return scintilla_send_message(w, msg, wParam, lParam); -} - -//-------------------------------------------------------------------------------------------------- - -/** - * Helper method for the backend to reach through to the scintilla window. - */ -long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) -{ - return scintilla_send_message(w, msg, wParam, (long) lParam); -} - -//-------------------------------------------------------------------------------------------------- - -bool Platform::IsDBCSLeadByte(int codePage, char ch) -{ - // Byte ranges found in Wikipedia articles with relevant search strings in each case - unsigned char uch = static_cast(ch); - switch (codePage) - { - case 932: - // Shift_jis - return ((uch >= 0x81) && (uch <= 0x9F)) || - ((uch >= 0xE0) && (uch <= 0xFC)); - // Lead bytes F0 to FC may be a Microsoft addition. - case 936: - // GBK - return (uch >= 0x81) && (uch <= 0xFE); - case 949: - // Korean Wansung KS C-5601-1987 - return (uch >= 0x81) && (uch <= 0xFE); - case 950: - // Big5 - return (uch >= 0x81) && (uch <= 0xFE); - case 1361: - // Korean Johab KS C-5601-1992 - return - ((uch >= 0x84) && (uch <= 0xD3)) || - ((uch >= 0xD8) && (uch <= 0xDE)) || - ((uch >= 0xE0) && (uch <= 0xF9)); - } - return false; -} - -//-------------------------------------------------------------------------------------------------- - -int Platform::DBCSCharLength(int /* codePage */, const char* /* s */) -{ - // DBCS no longer uses this. - return 1; -} - -//-------------------------------------------------------------------------------------------------- - -int Platform::DBCSCharMaxLength() -{ - return 2; -} - -//-------------------------------------------------------------------------------------------------- - -int Platform::Minimum(int a, int b) -{ - return (a < b) ? a : b; -} - -//-------------------------------------------------------------------------------------------------- - -int Platform::Maximum(int a, int b) { - return (a > b) ? a : b; -} - -//-------------------------------------------------------------------------------------------------- - //#define TRACE #ifdef TRACE @@ -2245,29 +2094,18 @@ void Platform::Assert(const char *c, const char *file, int line) #endif } -//-------------------------------------------------------------------------------------------------- - -int Platform::Clamp(int val, int minVal, int maxVal) -{ - if (val > maxVal) - val = maxVal; - if (val < minVal) - val = minVal; - return val; -} - //----------------- DynamicLibrary ----------------------------------------------------------------- /** * Implements the platform specific part of library loading. * * @param modulePath The path to the module to load. - * @return A library instance or NULL if the module could not be found or another problem occurred. + * @return A library instance or nullptr if the module could not be found or another problem occurred. */ DynamicLibrary* DynamicLibrary::Load(const char* /* modulePath */) { // Not implemented. - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/QuartzTextLayout.h b/dep/scintilla/scintilla-3.10.6/cocoa/QuartzTextLayout.h similarity index 71% rename from dep/scintilla/scintilla-3.6.0/cocoa/QuartzTextLayout.h rename to dep/scintilla/scintilla-3.10.6/cocoa/QuartzTextLayout.h index 33869ae6..f2387dd9 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/QuartzTextLayout.h +++ b/dep/scintilla/scintilla-3.10.6/cocoa/QuartzTextLayout.h @@ -19,13 +19,9 @@ class QuartzTextLayout { public: - /** Create a text layout for drawing on the specified context. */ - explicit QuartzTextLayout( CGContextRef context ) + /** Create a text layout for drawing. */ + QuartzTextLayout() : mString(NULL), mLine(NULL), stringLength(0) { - mString = NULL; - mLine = NULL; - stringLength = 0; - setContext(context); } ~QuartzTextLayout() @@ -42,9 +38,9 @@ public: } } - inline void setText( const UInt8* buffer, size_t byteLength, CFStringEncoding encoding, const QuartzTextStyle& r ) - { - CFStringRef str = CFStringCreateWithBytes( NULL, buffer, byteLength, encoding, false ); + void setText(const char *buffer, size_t byteLength, CFStringEncoding encoding, const QuartzTextStyle &r) { + const UInt8 *puiBuffer = reinterpret_cast(buffer); + CFStringRef str = CFStringCreateWithBytes(NULL, puiBuffer, byteLength, encoding, false); if (!str) return; @@ -63,12 +59,13 @@ public: CFRelease( str ); } - /** Draw the text layout into the current CGContext at the specified position. + /** Draw the text layout into a CGContext at the specified position. + * @param gc The CGContext in which to draw the text. * @param x The x axis position to draw the baseline in the current CGContext. * @param y The y axis position to draw the baseline in the current CGContext. */ - void draw( float x, float y ) + void draw( CGContextRef gc, float x, float y ) { - if (mLine == NULL) + if (!mLine) return; ::CGContextSetTextMatrix(gc, CGAffineTransformMakeScale(1.0, -1.0)); @@ -96,13 +93,7 @@ public: return stringLength; } - inline void setContext (CGContextRef context) - { - gc = context; - } - private: - CGContextRef gc; CFAttributedStringRef mString; CTLineRef mLine; CFIndex stringLength; diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/QuartzTextStyle.h b/dep/scintilla/scintilla-3.10.6/cocoa/QuartzTextStyle.h similarity index 97% rename from dep/scintilla/scintilla-3.6.0/cocoa/QuartzTextStyle.h rename to dep/scintilla/scintilla-3.10.6/cocoa/QuartzTextStyle.h index 12cc0e0b..17414949 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/QuartzTextStyle.h +++ b/dep/scintilla/scintilla-3.10.6/cocoa/QuartzTextStyle.h @@ -54,9 +54,9 @@ public: return styleDict; } - void setCTStyleColor(CGColor *inColor) + void setCTStyleColour(CGColor *inColour) { - CFDictionarySetValue(styleDict, kCTForegroundColorAttributeName, inColor); + CFDictionarySetValue(styleDict, kCTForegroundColorAttributeName, inColour); } float getAscent() const diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/QuartzTextStyleAttribute.h b/dep/scintilla/scintilla-3.10.6/cocoa/QuartzTextStyleAttribute.h similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/QuartzTextStyleAttribute.h rename to dep/scintilla/scintilla-3.10.6/cocoa/QuartzTextStyleAttribute.h diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaCocoa.h b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaCocoa.h similarity index 60% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaCocoa.h rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaCocoa.h index 4c7c2cc1..9a74cb6f 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaCocoa.h +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaCocoa.h @@ -13,16 +13,18 @@ * This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt). */ -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include #include +#include +#include "ILoader.h" #include "ILexer.h" #ifdef SCI_LEXER @@ -30,7 +32,9 @@ #include "PropSetSimple.h" #endif +#include "CharacterCategory.h" #include "Position.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -39,7 +43,6 @@ #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -48,6 +51,8 @@ #include "CaseFolder.h" #include "Document.h" #include "CaseConvert.h" +#include "UniConversion.h" +#include "DBCS.h" #include "Selection.h" #include "PositionCache.h" #include "EditModel.h" @@ -88,6 +93,7 @@ namespace Scintilla { class ScintillaCocoa : public ScintillaBase { private: + ScintillaView* sciView; TimerTarget* timerTarget; NSEvent* lastMouseEvent; @@ -100,45 +106,42 @@ private: bool enteredSetScrollingSize; - // Private so ScintillaCocoa objects can not be copied - ScintillaCocoa(const ScintillaCocoa &) : ScintillaBase() {} - ScintillaCocoa &operator=(const ScintillaCocoa &) { return * this; } - bool GetPasteboardData(NSPasteboard* board, SelectionText* selectedText); void SetPasteboardData(NSPasteboard* board, const SelectionText& selectedText); - int TargetAsUTF8(char *text); - int EncodedFromUTF8(char *utf8, char *encoded) const; + Sci::Position TargetAsUTF8(char *text) const; + Sci::Position EncodedFromUTF8(const char *utf8, char *encoded) const; int scrollSpeed; int scrollTicks; - NSTimer* tickTimer; - NSTimer* idleTimer; CFRunLoopObserverRef observer; FindHighlightLayer *layerFindIndicator; protected: - Point GetVisibleOriginInMain() const; - PRectangle GetClientRectangle() const; - virtual PRectangle GetClientDrawingRectangle(); + Point GetVisibleOriginInMain() const override; + PRectangle GetClientRectangle() const override; + PRectangle GetClientDrawingRectangle() override; Point ConvertPoint(NSPoint point); - virtual void RedrawRect(PRectangle rc); - virtual void DiscardOverdraw(); - virtual void Redraw(); + void RedrawRect(PRectangle rc) override; + void DiscardOverdraw() override; + void Redraw() override; - virtual void Initialise(); - virtual void Finalise(); - virtual CaseFolder *CaseFolderForEncoding(); - virtual std::string CaseMapString(const std::string &s, int caseMapping); - virtual void CancelModes(); + void Init(); + CaseFolder *CaseFolderForEncoding() override; + std::string CaseMapString(const std::string &s, int caseMapping) override; + void CancelModes() override; public: - ScintillaCocoa(SCIContentView* view, SCIMarginView* viewMargin); - virtual ~ScintillaCocoa(); + ScintillaCocoa(ScintillaView* sciView_, SCIContentView* viewContent, SCIMarginView* viewMargin); + // Deleted so ScintillaCocoa objects can not be copied. + ScintillaCocoa(const ScintillaCocoa &) = delete; + ScintillaCocoa &operator=(const ScintillaCocoa &) = delete; + ~ScintillaCocoa() override; + void Finalise() override; void SetDelegate(id delegate_); void RegisterNotifyCallback(intptr_t windowid, SciNotifyFunc callback); - sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); + sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; NSScrollView* ScrollContainer() const; SCIContentView* ContentView(); @@ -147,43 +150,42 @@ public: bool Draw(NSRect rect, CGContextRef gc); void PaintMargin(NSRect aRect); - virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); - void TickFor(TickReason reason); - bool FineTickerAvailable(); - bool FineTickerRunning(TickReason reason); - void FineTickerStart(TickReason reason, int millis, int tolerance); - void FineTickerCancel(TickReason reason); - bool SetIdle(bool on); - void SetMouseCapture(bool on); - bool HaveMouseCapture(); + sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; + void TickFor(TickReason reason) override; + bool FineTickerRunning(TickReason reason) override; + void FineTickerStart(TickReason reason, int millis, int tolerance) override; + void FineTickerCancel(TickReason reason) override; + bool SetIdle(bool on) override; + void SetMouseCapture(bool on) override; + bool HaveMouseCapture() override; void WillDraw(NSRect rect); - void ScrollText(int linesToMove); - void SetVerticalScrollPos(); - void SetHorizontalScrollPos(); - bool ModifyScrollBars(int nMax, int nPage); + void ScrollText(Sci::Line linesToMove) override; + void SetVerticalScrollPos() override; + void SetHorizontalScrollPos() override; + bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) override; bool SetScrollingSize(void); void Resize(); void UpdateForScroll(); // Notifications for the owner. - void NotifyChange(); - void NotifyFocus(bool focus); - void NotifyParent(SCNotification scn); + void NotifyChange() override; + void NotifyFocus(bool focus) override; + void NotifyParent(SCNotification scn) override; void NotifyURIDropped(const char *uri); bool HasSelection(); bool CanUndo(); bool CanRedo(); - virtual void CopyToClipboard(const SelectionText &selectedText); - virtual void Copy(); - virtual bool CanPaste(); - virtual void Paste(); - virtual void Paste(bool rectangular); + void CopyToClipboard(const SelectionText &selectedText) override; + void Copy() override; + bool CanPaste() override; + void Paste() override; + void Paste(bool rectangular); void CTPaint(void* gc, NSRect rc); void CallTipMouseDown(NSPoint pt); - virtual void CreateCallTipWindow(PRectangle rc); - virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true); - virtual void ClaimSelection(); + void CreateCallTipWindow(PRectangle rc) override; + void AddToPopUp(const char *label, int cmd = 0, bool enabled = true) override; + void ClaimSelection() override; NSPoint GetCaretPosition(); @@ -195,21 +197,27 @@ public: static void UpdateObserver(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *sci); void ObserverAdd(); void ObserverRemove(); - virtual void IdleWork(); - virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo); - int InsertText(NSString* input); - NSRange PositionsFromCharacters(NSRange range) const; - NSRange CharactersFromPositions(NSRange range) const; + void IdleWork() override; + void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) override; + ptrdiff_t InsertText(NSString *input); + NSRange PositionsFromCharacters(NSRange rangeCharacters) const; + NSRange CharactersFromPositions(NSRange rangePositions) const; + NSString *RangeTextAsString(NSRange rangePositions) const; + NSInteger VisibleLineForIndex(NSInteger index); + NSRange RangeForVisibleLine(NSInteger lineVisible); + NSRect FrameForRange(NSRange rangeCharacters); + NSRect GetBounds() const; void SelectOnlyMainSelection(); void ConvertSelectionVirtualSpace(); bool ClearAllSelections(); void CompositionStart(); void CompositionCommit(); void CompositionUndo(); - virtual void SetDocPointer(Document *document); + void SetDocPointer(Document *document) override; bool KeyboardInput(NSEvent* event); void MouseDown(NSEvent* event); + void RightMouseDown(NSEvent* event); void MouseMove(NSEvent* event); void MouseUp(NSEvent* event); void MouseEntered(NSEvent* event); @@ -217,7 +225,7 @@ public: void MouseWheel(NSEvent* event); // Drag and drop - void StartDrag(); + void StartDrag() override; bool GetDragData(id info, NSPasteboard &pasteBoard, SelectionText* selectedText); NSDragOperation DraggingEntered(id info); NSDragOperation DraggingUpdated(id info); @@ -226,16 +234,18 @@ public: void DragScroll(); // Promote some methods needed for NSResponder actions. - virtual void SelectAll(); + void SelectAll() override; void DeleteBackward(); - virtual void Cut(); - virtual void Undo(); - virtual void Redo(); + void Cut() override; + void Undo() override; + void Redo() override; - virtual NSMenu* CreateContextMenu(NSEvent* event); + bool ShouldDisplayPopupOnMargin(); + bool ShouldDisplayPopupOnText(); + NSMenu* CreateContextMenu(NSEvent* event); void HandleCommand(NSInteger command); - virtual void ActiveStateChanged(bool isActive); + void ActiveStateChanged(bool isActive); void WindowWillMove(); // Find indicator diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaCocoa.mm b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaCocoa.mm similarity index 80% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaCocoa.mm rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaCocoa.mm index b70975c2..3eaf1766 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaCocoa.mm +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaCocoa.mm @@ -14,6 +14,10 @@ * This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt). */ +#include + +#include + #import #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 #import @@ -146,7 +150,7 @@ static const KeyToCommand macMapDefault[] = { @private NSString *sFind; - int positionFind; + long positionFind; BOOL retaining; CGFloat widthText; CGFloat heightLine; @@ -155,7 +159,7 @@ static const KeyToCommand macMapDefault[] = } @property (copy) NSString *sFind; -@property (assign) int positionFind; +@property (assign) long positionFind; @property (assign) BOOL retaining; @property (assign) CGFloat widthText; @property (assign) CGFloat heightLine; @@ -198,6 +202,12 @@ static const KeyToCommand macMapDefault[] = } +- (void) dealloc { + [sFind release]; + [sFont release]; + [super dealloc]; +} + const CGFloat paddingHighlightX = 4; const CGFloat paddingHighlightY = 2; @@ -316,7 +326,7 @@ const CGFloat paddingHighlightY = 2; // main thread). We need that later for idle event processing. NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; notificationQueue = [[NSNotificationQueue alloc] initWithNotificationCenter: center]; - [center addObserver: self selector: @selector(idleTriggered:) name: @"Idle" object: nil]; + [center addObserver: self selector: @selector(idleTriggered:) name: @"Idle" object: self]; } return self; } @@ -333,13 +343,26 @@ const CGFloat paddingHighlightY = 2; //-------------------------------------------------------------------------------------------------- +/** + * Method called by owning ScintillaCocoa object when it is destroyed. + */ +- (void) ownerDestroyed +{ + mTarget = NULL; + [notificationQueue release]; + notificationQueue = nil; +} + +//-------------------------------------------------------------------------------------------------- + /** * Method called by a timer installed by ScintillaCocoa. This two step approach is needed because * a native Obj-C class is required as target for the timer. */ - (void) timerFired: (NSTimer*) timer { - reinterpret_cast(mTarget)->TimerFired(timer); + if (mTarget) + static_cast(mTarget)->TimerFired(timer); } //-------------------------------------------------------------------------------------------------- @@ -358,7 +381,7 @@ const CGFloat paddingHighlightY = 2; [notificationQueue enqueueNotification: notification postingStyle: NSPostWhenIdle coalesceMask: (NSNotificationCoalescingOnName | NSNotificationCoalescingOnSender) - forModes: nil]; + forModes: @[NSDefaultRunLoopMode, NSModalPanelRunLoopMode]]; } //-------------------------------------------------------------------------------------------------- @@ -370,18 +393,23 @@ const CGFloat paddingHighlightY = 2; - (void) idleTriggered: (NSNotification*) notification { #pragma unused(notification) - reinterpret_cast(mTarget)->IdleTimerFired(); + if (mTarget) + static_cast(mTarget)->IdleTimerFired(); } @end //----------------- ScintillaCocoa ----------------------------------------------------------------- -ScintillaCocoa::ScintillaCocoa(SCIContentView* view, SCIMarginView* viewMargin) +ScintillaCocoa::ScintillaCocoa(ScintillaView* sciView_, SCIContentView* viewContent, SCIMarginView* viewMargin) { vs.marginInside = false; - wMain = view; // Don't retain since we're owned by view, which would cause a cycle + + // Don't retain since we're owned by view, which would cause a cycle + sciView = sciView_; + wMain = viewContent; wMargin = viewMargin; + timerTarget = [[TimerTarget alloc] init: this]; lastMouseEvent = NULL; delegate = NULL; @@ -391,8 +419,6 @@ ScintillaCocoa::ScintillaCocoa(SCIContentView* view, SCIMarginView* viewMargin) enteredSetScrollingSize = false; scrollSpeed = 1; scrollTicks = 2000; - tickTimer = NULL; - idleTimer = NULL; observer = NULL; layerFindIndicator = NULL; imeInteraction = imeInline; @@ -400,14 +426,14 @@ ScintillaCocoa::ScintillaCocoa(SCIContentView* view, SCIMarginView* viewMargin) { timers[tr] = nil; } - Initialise(); + Init(); } //-------------------------------------------------------------------------------------------------- ScintillaCocoa::~ScintillaCocoa() { - Finalise(); + [timerTarget ownerDestroyed]; [timerTarget release]; } @@ -416,7 +442,7 @@ ScintillaCocoa::~ScintillaCocoa() /** * Core initialization of the control. Everything that needs to be set up happens here. */ -void ScintillaCocoa::Initialise() +void ScintillaCocoa::Init() { Scintilla_LinkLexers(); @@ -450,7 +476,7 @@ void ScintillaCocoa::Finalise() //-------------------------------------------------------------------------------------------------- void ScintillaCocoa::UpdateObserver(CFRunLoopObserverRef /* observer */, CFRunLoopActivity /* activity */, void *info) { - ScintillaCocoa* sci = reinterpret_cast(info); + ScintillaCocoa* sci = static_cast(info); sci->IdleWork(); } @@ -499,7 +525,7 @@ void ScintillaCocoa::IdleWork() { //-------------------------------------------------------------------------------------------------- -void ScintillaCocoa::QueueIdleWork(WorkNeeded::workItems items, int upTo) { +void ScintillaCocoa::QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) { Editor::QueueIdleWork(items, upTo); ObserverAdd(); } @@ -507,26 +533,7 @@ void ScintillaCocoa::QueueIdleWork(WorkNeeded::workItems items, int upTo) { //-------------------------------------------------------------------------------------------------- /** - * Convert a core foundation string into an array of bytes in a particular encoding - */ - -static char *EncodedBytes(CFStringRef cfsRef, CFStringEncoding encoding) { - CFRange rangeAll = {0, CFStringGetLength(cfsRef)}; - CFIndex usedLen = 0; - CFStringGetBytes(cfsRef, rangeAll, encoding, '?', - false, NULL, 0, &usedLen); - - char *buffer = new char[usedLen+1]; - CFStringGetBytes(cfsRef, rangeAll, encoding, '?', - false, (UInt8 *)buffer,usedLen, NULL); - buffer[usedLen] = '\0'; - return buffer; -} - -//-------------------------------------------------------------------------------------------------- - -/** - * Convert a core foundation string into a std::string in a particular encoding + * Convert a Core Foundation string into a std::string in a particular encoding. */ static std::string EncodedBytesString(CFStringRef cfsRef, CFStringEncoding encoding) { @@ -534,7 +541,7 @@ static std::string EncodedBytesString(CFStringRef cfsRef, CFStringEncoding encod CFIndex usedLen = 0; CFStringGetBytes(cfsRef, rangeAll, encoding, '?', false, NULL, 0, &usedLen); - + std::string buffer(usedLen, '\0'); if (usedLen > 0) { CFStringGetBytes(cfsRef, rangeAll, encoding, '?', false, @@ -545,6 +552,21 @@ static std::string EncodedBytesString(CFStringRef cfsRef, CFStringEncoding encod //-------------------------------------------------------------------------------------------------- +/** + * Create a Core Foundation string from a string. + * This is a simple wrapper that specifies common arguments (the default allocator and + * false for isExternalRepresentation) and avoids casting since strings in Scintilla + * contain char, not UInt8 (unsigned char). + */ + +static CFStringRef CFStringFromString(const char *s, size_t len, CFStringEncoding encoding) { + return CFStringCreateWithBytes(kCFAllocatorDefault, + reinterpret_cast(s), + len, encoding, false); +} + +//-------------------------------------------------------------------------------------------------- + /** * Case folders. */ @@ -555,29 +577,26 @@ public: explicit CaseFolderDBCS(CFStringEncoding encoding_) : encoding(encoding_) { StandardASCII(); } - virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) { + size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override { if ((lenMixed == 1) && (sizeFolded > 0)) { folded[0] = mapping[static_cast(mixed[0])]; return 1; } else { - CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast(mixed), - lenMixed, encoding, false); + CFStringRef cfsVal = CFStringFromString(mixed, lenMixed, encoding); - NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch - locale:[NSLocale currentLocale]]; + NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch + locale:[NSLocale currentLocale]]; - char *encoded = EncodedBytes((CFStringRef)sMapped, encoding); + std::string encoded = EncodedBytesString((CFStringRef)sMapped, encoding); - size_t lenMapped = strlen(encoded); - if (lenMapped < sizeFolded) { - memcpy(folded, encoded, lenMapped); - } else { - folded[0] = '\0'; - lenMapped = 1; - } - delete []encoded; - CFRelease(cfsVal); + size_t lenMapped = encoded.length(); + if (lenMapped < sizeFolded) { + memcpy(folded, encoded.c_str(), lenMapped); + } else { + folded[0] = '\0'; + lenMapped = 1; + } + CFRelease(cfsVal); return lenMapped; } } @@ -587,38 +606,34 @@ CaseFolder *ScintillaCocoa::CaseFolderForEncoding() { if (pdoc->dbcsCodePage == SC_CP_UTF8) { return new CaseFolderUnicode(); } else { - CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), - vs.styles[STYLE_DEFAULT].characterSet); - if (pdoc->dbcsCodePage == 0) { - CaseFolderTable *pcf = new CaseFolderTable(); - pcf->StandardASCII(); - // Only for single byte encodings - for (int i=0x80; i<0x100; i++) { - char sCharacter[2] = "A"; - sCharacter[0] = static_cast(i); - CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast(sCharacter), - 1, encoding, false); - if (!cfsVal) - continue; + CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), + vs.styles[STYLE_DEFAULT].characterSet); + if (pdoc->dbcsCodePage == 0) { + CaseFolderTable *pcf = new CaseFolderTable(); + pcf->StandardASCII(); + // Only for single byte encodings + for (int i=0x80; i<0x100; i++) { + char sCharacter[2] = "A"; + sCharacter[0] = static_cast(i); + CFStringRef cfsVal = CFStringFromString(sCharacter, 1, encoding); + if (!cfsVal) + continue; - NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch - locale:[NSLocale currentLocale]]; + NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch + locale:[NSLocale currentLocale]]; - char *encoded = EncodedBytes((CFStringRef)sMapped, encoding); + std::string encoded = EncodedBytesString((CFStringRef)sMapped, encoding); - if (strlen(encoded) == 1) { - pcf->SetTranslation(sCharacter[0], encoded[0]); - } + if (encoded.length() == 1) { + pcf->SetTranslation(sCharacter[0], encoded[0]); + } - delete []encoded; - CFRelease(cfsVal); - } - return pcf; - } else { - return new CaseFolderDBCS(encoding); - } - return 0; + CFRelease(cfsVal); + } + return pcf; + } else { + return new CaseFolderDBCS(encoding); + } } } @@ -643,9 +658,11 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping) CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); - CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast(s.c_str()), - s.length(), encoding, false); + + CFStringRef cfsVal = CFStringFromString(s.c_str(), s.length(), encoding); + if (!cfsVal) { + return s; + } NSString *sMapped; switch (caseMapping) @@ -661,9 +678,7 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping) } // Back to encoding - char *encoded = EncodedBytes((CFStringRef)sMapped, encoding); - std::string result(encoded); - delete []encoded; + std::string result = EncodedBytesString((CFStringRef)sMapped, encoding); CFRelease(cfsVal); return result; } @@ -821,7 +836,7 @@ sptr_t ScintillaCocoa::DirectFunction(sptr_t ptr, unsigned int iMessage, uptr_t */ sptr_t scintilla_send_message(void* sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { - ScintillaView *control = reinterpret_cast(sci); + ScintillaView *control = static_cast(sci); return [control message:iMessage wParam:wParam lParam:lParam]; } @@ -842,45 +857,54 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar { case SCI_GETDIRECTFUNCTION: return reinterpret_cast(DirectFunction); - + case SCI_GETDIRECTPOINTER: return reinterpret_cast(this); - + case SCI_TARGETASUTF8: - return TargetAsUTF8(reinterpret_cast(lParam)); - + return TargetAsUTF8(CharPtrFromSPtr(lParam)); + case SCI_ENCODEDFROMUTF8: - return EncodedFromUTF8(reinterpret_cast(wParam), - reinterpret_cast(lParam)); - + return EncodedFromUTF8(ConstCharPtrFromUPtr(wParam), + CharPtrFromSPtr(lParam)); + case SCI_SETIMEINTERACTION: // Only inline IME supported on Cocoa break; - + case SCI_GRABFOCUS: [[ContentView() window] makeFirstResponder:ContentView()]; break; - + case SCI_SETBUFFEREDDRAW: // Buffered drawing not supported on Cocoa view.bufferedDraw = false; break; - + case SCI_FINDINDICATORSHOW: ShowFindIndicatorForRange(NSMakeRange(wParam, lParam-wParam), YES); return 0; - + case SCI_FINDINDICATORFLASH: ShowFindIndicatorForRange(NSMakeRange(wParam, lParam-wParam), NO); return 0; - + case SCI_FINDINDICATORHIDE: HideFindIndicator(); return 0; - + + case SCI_SETPHASESDRAW: { + sptr_t r = ScintillaBase::WndProc(iMessage, wParam, lParam); + [sciView updateIndicatorIME]; + return r; + } + + case SCI_GETACCESSIBILITY: + return SC_ACCESSIBILITY_ENABLED; + default: sptr_t r = ScintillaBase::WndProc(iMessage, wParam, lParam); - + return r; } } catch (std::bad_alloc &) { @@ -888,7 +912,7 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar } catch (...) { errorStatus = SC_STATUS_FAILURE; } - return 0l; + return 0; } //-------------------------------------------------------------------------------------------------- @@ -921,16 +945,6 @@ void ScintillaCocoa::TickFor(TickReason reason) //-------------------------------------------------------------------------------------------------- -/** - * Report that this Editor subclass has a working implementation of FineTickerStart. - */ -bool ScintillaCocoa::FineTickerAvailable() -{ - return true; -} - -//-------------------------------------------------------------------------------------------------- - /** * Is a particular timer currently running? */ @@ -947,16 +961,18 @@ bool ScintillaCocoa::FineTickerRunning(TickReason reason) void ScintillaCocoa::FineTickerStart(TickReason reason, int millis, int tolerance) { FineTickerCancel(reason); - NSTimer *fineTimer = [NSTimer scheduledTimerWithTimeInterval: millis / 1000.0 - target: timerTarget - selector: @selector(timerFired:) - userInfo: nil - repeats: YES]; + NSTimer *fineTimer = [NSTimer timerWithTimeInterval: millis / 1000.0 + target: timerTarget + selector: @selector(timerFired:) + userInfo: nil + repeats: YES]; if (tolerance && [fineTimer respondsToSelector: @selector(setTolerance:)]) { [fineTimer setTolerance: tolerance / 1000.0]; } timers[reason] = fineTimer; + [NSRunLoop.currentRunLoop addTimer: fineTimer forMode: NSDefaultRunLoopMode]; + [NSRunLoop.currentRunLoop addTimer: fineTimer forMode: NSModalPanelRunLoopMode]; } //-------------------------------------------------------------------------------------------------- @@ -983,17 +999,18 @@ bool ScintillaCocoa::SetIdle(bool on) if (idler.state) { // Scintilla ticks = milliseconds - idleTimer = [NSTimer scheduledTimerWithTimeInterval: timer.tickSize / 1000.0 - target: timerTarget - selector: @selector(idleTimerFired:) - userInfo: nil - repeats: YES]; - idler.idlerID = reinterpret_cast(idleTimer); + NSTimer *idleTimer = [NSTimer scheduledTimerWithTimeInterval: timer.tickSize / 1000.0 + target: timerTarget + selector: @selector(idleTimerFired:) + userInfo: nil + repeats: YES]; + [NSRunLoop.currentRunLoop addTimer: idleTimer forMode: NSModalPanelRunLoopMode]; + idler.idlerID = idleTimer; } else if (idler.idlerID != NULL) { - [reinterpret_cast(idler.idlerID) invalidate]; + [static_cast(idler.idlerID) invalidate]; idler.idlerID = 0; } } @@ -1054,7 +1071,7 @@ void ScintillaCocoa::Paste(bool forceRectangular) pdoc->BeginUndoAction(); ClearSelection(false); - InsertPasteShape(selectedText.Data(), static_cast(selectedText.Length()), + InsertPasteShape(selectedText.Data(), selectedText.Length(), selectedText.rectangular ? pasteRectangular : pasteStream); pdoc->EndUndoAction(); @@ -1066,15 +1083,12 @@ void ScintillaCocoa::Paste(bool forceRectangular) void ScintillaCocoa::CTPaint(void* gc, NSRect rc) { #pragma unused(rc) - Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); - if (surfaceWindow) { - surfaceWindow->Init(gc, wMain.GetID()); - surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ct.codePage); - surfaceWindow->SetDBCSMode(ct.codePage); - ct.PaintCT(surfaceWindow); - surfaceWindow->Release(); - delete surfaceWindow; - } + std::unique_ptr surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); + surfaceWindow->Init(gc, wMain.GetID()); + surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ct.codePage); + surfaceWindow->SetDBCSMode(ct.codePage); + ct.PaintCT(surfaceWindow.get()); + surfaceWindow->Release(); } @interface CallTipView : NSControl { @@ -1169,7 +1183,7 @@ void ScintillaCocoa::CreateCallTipWindow(PRectangle rc) { void ScintillaCocoa::AddToPopUp(const char *label, int cmd, bool enabled) { NSMenuItem* item; - ScintillaContextMenu *menu= reinterpret_cast(popup.GetID()); + ScintillaContextMenu *menu = static_cast(popup.GetID()); [menu setOwner: this]; [menu setAutoenablesItems: NO]; @@ -1202,7 +1216,8 @@ void ScintillaCocoa::ClaimSelection() */ NSPoint ScintillaCocoa::GetCaretPosition() { - const int line = pdoc->LineFromPosition(sel.RangeMain().caret.Position()); + const Sci::Line line = static_cast( + pdoc->LineFromPosition(sel.RangeMain().caret.Position())); NSPoint result; result.y = line; @@ -1227,9 +1242,9 @@ void ScintillaCocoa::DragScroll() } // TODO: does not work for wrapped lines, fix it. - int line = pdoc->LineFromPosition(posDrag.Position()); - int currentVisibleLine = cs.DisplayFromDoc(line); - int lastVisibleLine = Platform::Minimum(topLine + LinesOnScreen(), cs.LinesDisplayed()) - 2; + Sci::Line line = static_cast(pdoc->LineFromPosition(posDrag.Position())); + Sci::Line currentVisibleLine = pcs->DisplayFromDoc(line); + Sci::Line lastVisibleLine = std::min(topLine + LinesOnScreen(), pcs->LinesDisplayed()) - 2; if (currentVisibleLine <= topLine && topLine > 0) ScrollTo(topLine - scrollSpeed); @@ -1271,16 +1286,17 @@ void ScintillaCocoa::DragScroll() - (id)initWithSelectedText:(const SelectionText *)other { self = [super init]; - + if (self) { selectedText.Copy(*other); } - + return self; } - (void)pasteboard:(NSPasteboard *)pasteboard item:(NSPasteboardItem *)item provideDataForType:(NSString *)type { +#pragma unused(item) if (selectedText.Length() == 0) return; @@ -1290,10 +1306,11 @@ void ScintillaCocoa::DragScroll() CFStringEncoding encoding = EncodingFromCharacterSet(selectedText.codePage == SC_CP_UTF8, selectedText.characterSet); - CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast(selectedText.Data()), - selectedText.Length(), encoding, false); - + + CFStringRef cfsVal = CFStringFromString(selectedText.Data(), selectedText.Length(), encoding); + if (!cfsVal) + return; + if ([type compare: NSPasteboardTypeString] == NSOrderedSame) { [pasteboard setString:(NSString *)cfsVal forType: NSStringPboardType]; @@ -1306,7 +1323,7 @@ void ScintillaCocoa::DragScroll() } if (cfsVal) - CFRelease(cfsVal); + CFRelease(cfsVal); } @end @@ -1333,12 +1350,14 @@ void ScintillaCocoa::StartDrag() // calculate the bounds of the selection PRectangle client = GetTextRectangle(); - int selStart = sel.RangeMain().Start().Position(); - int selEnd = sel.RangeMain().End().Position(); - int startLine = pdoc->LineFromPosition(selStart); - int endLine = pdoc->LineFromPosition(selEnd); + Sci::Position selStart = sel.RangeMain().Start().Position(); + Sci::Position selEnd = sel.RangeMain().End().Position(); + Sci::Line startLine = static_cast(pdoc->LineFromPosition(selStart)); + Sci::Line endLine = static_cast(pdoc->LineFromPosition(selEnd)); Point pt; - long startPos, endPos, ep; + Sci::Position startPos; + Sci::Position endPos; + Sci::Position ep; PRectangle rcSel; if (startLine==endLine && WndProc(SCI_GETWRAPMODE, 0, 0) != SC_WRAP_NONE) { @@ -1353,8 +1372,8 @@ void ScintillaCocoa::StartDrag() // step back a position if we're counting the newline ep = WndProc(SCI_GETLINEENDPOSITION, startLine, 0); if (endPos > ep) endPos = ep; - ptStart = LocationFromPosition(static_cast(startPos)); - ptEnd = LocationFromPosition(static_cast(endPos)); + ptStart = LocationFromPosition(startPos); + ptEnd = LocationFromPosition(endPos); if (ptStart.y == ptEnd.y) { // We're just selecting part of one visible line rcSel.left = ptStart.x; @@ -1362,7 +1381,7 @@ void ScintillaCocoa::StartDrag() } else { // Find the bounding box. startPos = WndProc(SCI_POSITIONFROMLINE, startLine, 0); - rcSel.left = LocationFromPosition(static_cast(startPos)).x; + rcSel.left = LocationFromPosition(startPos).x; rcSel.right = client.right; } rcSel.top = ptStart.y; @@ -1372,17 +1391,17 @@ void ScintillaCocoa::StartDrag() } } else { rcSel.top = rcSel.bottom = rcSel.right = rcSel.left = -1; - for (int l = startLine; l <= endLine; l++) { + for (Sci::Line l = startLine; l <= endLine; l++) { startPos = WndProc(SCI_GETLINESELSTARTPOSITION, l, 0); endPos = WndProc(SCI_GETLINESELENDPOSITION, l, 0); if (endPos == startPos) continue; // step back a position if we're counting the newline ep = WndProc(SCI_GETLINEENDPOSITION, l, 0); if (endPos > ep) endPos = ep; - pt = LocationFromPosition(static_cast(startPos)); // top left of line selection + pt = LocationFromPosition(startPos); // top left of line selection if (pt.x < rcSel.left || rcSel.left < 0) rcSel.left = pt.x; if (pt.y < rcSel.top || rcSel.top < 0) rcSel.top = pt.y; - pt = LocationFromPosition(static_cast(endPos)); // top right of line selection + pt = LocationFromPosition(endPos); // top right of line selection pt.y += vs.lineHeight; // get to the bottom of the line if (pt.x > rcSel.right || rcSel.right < 0) { if (pt.x > client.right) @@ -1407,59 +1426,40 @@ void ScintillaCocoa::StartDrag() SCIContentView* content = ContentView(); // To get a bitmap of the text we're dragging, we just use Paint on a pixmap surface. - SurfaceImpl *sw = new SurfaceImpl(); - SurfaceImpl *pixmap = NULL; + SurfaceImpl sw; + sw.InitPixMap(static_cast(client.Width()), static_cast(client.Height()), NULL, NULL); - bool lastHideSelection = view.hideSelection; + const bool lastHideSelection = view.hideSelection; view.hideSelection = true; - if (sw) - { - pixmap = new SurfaceImpl(); - if (pixmap) - { - PRectangle imageRect = rcSel; - paintState = painting; - sw->InitPixMap(static_cast(client.Width()), static_cast(client.Height()), NULL, NULL); - paintingAllText = true; - // Have to create a new context and make current as text drawing goes - // to the current context, not a passed context. - CGContextRef gcsw = sw->GetContext(); - NSGraphicsContext *nsgc = [NSGraphicsContext graphicsContextWithGraphicsPort: gcsw - flipped: YES]; - [NSGraphicsContext setCurrentContext:nsgc]; - CGContextTranslateCTM(gcsw, -client.left, -client.top); - Paint(sw, client); - paintState = notPainting; - - pixmap->InitPixMap(static_cast(imageRect.Width()), static_cast(imageRect.Height()), NULL, NULL); - pixmap->SetUnicodeMode(IsUnicodeMode()); - pixmap->SetDBCSMode(CodePage()); - - CGContextRef gc = pixmap->GetContext(); - // To make Paint() work on a bitmap, we have to flip our coordinates and translate the origin - CGContextTranslateCTM(gc, 0, imageRect.Height()); - CGContextScaleCTM(gc, 1.0, -1.0); - - pixmap->CopyImageRectangle(*sw, imageRect, PRectangle(0.0f, 0.0f, imageRect.Width(), imageRect.Height())); - // XXX TODO: overwrite any part of the image that is not part of the - // selection to make it transparent. right now we just use - // the full rectangle which may include non-selected text. - } - sw->Release(); - delete sw; - } + PRectangle imageRect = rcSel; + paintState = painting; + paintingAllText = true; + CGContextRef gcsw = sw.GetContext(); + CGContextTranslateCTM(gcsw, -client.left, -client.top); + Paint(&sw, client); + paintState = notPainting; view.hideSelection = lastHideSelection; + SurfaceImpl pixmap; + pixmap.InitPixMap(static_cast(imageRect.Width()), static_cast(imageRect.Height()), NULL, NULL); + pixmap.SetUnicodeMode(IsUnicodeMode()); + pixmap.SetDBCSMode(CodePage()); + + CGContextRef gc = pixmap.GetContext(); + // To make Paint() work on a bitmap, we have to flip our coordinates and translate the origin + CGContextTranslateCTM(gc, 0, imageRect.Height()); + CGContextScaleCTM(gc, 1.0, -1.0); + + pixmap.CopyImageRectangle(sw, imageRect, PRectangle(0.0f, 0.0f, imageRect.Width(), imageRect.Height())); + // XXX TODO: overwrite any part of the image that is not part of the + // selection to make it transparent. right now we just use + // the full rectangle which may include non-selected text. + NSBitmapImageRep* bitmap = NULL; - if (pixmap) - { - CGImageRef imagePixmap = pixmap->GetImage(); - if (imagePixmap) - bitmap = [[[NSBitmapImageRep alloc] initWithCGImage: imagePixmap] autorelease]; - CGImageRelease(imagePixmap); - pixmap->Release(); - delete pixmap; - } + CGImageRef imagePixmap = pixmap.GetImage(); + if (imagePixmap) + bitmap = [[[NSBitmapImageRep alloc] initWithCGImage: imagePixmap] autorelease]; + CGImageRelease(imagePixmap); NSImage* image = [[[NSImage alloc] initWithSize: selectionRectangle.size] autorelease]; [image addRepresentation: bitmap]; @@ -1473,17 +1473,17 @@ void ScintillaCocoa::StartDrag() NSPoint startPoint; startPoint.x = selectionRectangle.origin.x + client.left; startPoint.y = selectionRectangle.origin.y + selectionRectangle.size.height + client.top; - + NSPasteboardItem *pbItem = [NSPasteboardItem new]; DragProviderSource *dps = [[[DragProviderSource alloc] initWithSelectedText:&selectedText] autorelease]; - + NSArray *pbTypes = selectedText.rectangular ? @[NSPasteboardTypeString, ScintillaRecPboardType] : @[NSPasteboardTypeString]; [pbItem setDataProvider:dps forTypes:pbTypes]; NSDraggingItem *dragItem = [[NSDraggingItem alloc ]initWithPasteboardWriter:pbItem]; [pbItem release]; - + NSScrollView *scrollContainer = ScrollContainer(); NSRect contentRect = [[scrollContainer contentView] bounds]; NSRect draggingRect = NSOffsetRect(selectionRectangle, contentRect.origin.x, contentRect.origin.y); @@ -1545,7 +1545,7 @@ NSDragOperation ScintillaCocoa::DraggingUpdated(id info) void ScintillaCocoa::DraggingExited(id info) { #pragma unused(info) - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); FineTickerCancel(tickPlatform); inDragDrop = ddNone; } @@ -1591,9 +1591,10 @@ void ScintillaCocoa::SetPasteboardData(NSPasteboard* board, const SelectionText CFStringEncoding encoding = EncodingFromCharacterSet(selectedText.codePage == SC_CP_UTF8, selectedText.characterSet); - CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast(selectedText.Data()), - selectedText.Length(), encoding, false); + + CFStringRef cfsVal = CFStringFromString(selectedText.Data(), selectedText.Length(), encoding); + if (!cfsVal) + return; NSArray *pbTypes = selectedText.rectangular ? [NSArray arrayWithObjects: NSStringPboardType, ScintillaRecPboardType, nil] : @@ -1658,9 +1659,9 @@ bool ScintillaCocoa::GetPasteboardData(NSPasteboard* board, SelectionText* selec // Returns the target converted to UTF8. // Return the length in bytes. -int ScintillaCocoa::TargetAsUTF8(char *text) +Sci::Position ScintillaCocoa::TargetAsUTF8(char *text) const { - const int targetLength = targetEnd - targetStart; + const Sci::Position targetLength = targetEnd - targetStart; if (IsUnicodeMode()) { if (text) @@ -1672,12 +1673,13 @@ int ScintillaCocoa::TargetAsUTF8(char *text) const CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); const std::string s = RangeText(targetStart, targetEnd); - CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast(s.c_str()), - s.length(), encoding, false); - + CFStringRef cfsVal = CFStringFromString(s.c_str(), s.length(), encoding); + if (!cfsVal) { + return 0; + } + const std::string tmputf = EncodedBytesString(cfsVal, kCFStringEncodingUTF8); - + if (text) memcpy(text, tmputf.c_str(), tmputf.length()); CFRelease(cfsVal); @@ -1688,11 +1690,89 @@ int ScintillaCocoa::TargetAsUTF8(char *text) //-------------------------------------------------------------------------------------------------- +// Returns the text in the range converted to an NSString. +NSString *ScintillaCocoa::RangeTextAsString(NSRange rangePositions) const { + const std::string text = RangeText(rangePositions.location, + NSMaxRange(rangePositions)); + if (IsUnicodeMode()) + { + return [NSString stringWithUTF8String: text.c_str()]; + } + else + { + // Need to convert + const CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), + vs.styles[STYLE_DEFAULT].characterSet); + CFStringRef cfsVal = CFStringFromString(text.c_str(), text.length(), encoding); + + return (NSString *)cfsVal; + } +} + +//-------------------------------------------------------------------------------------------------- + +// Return character range of a line. +NSRange ScintillaCocoa::RangeForVisibleLine(NSInteger lineVisible) { + const Range posRangeLine = RangeDisplayLine(static_cast(lineVisible)); + return CharactersFromPositions(NSMakeRange(posRangeLine.First(), + posRangeLine.Last() - posRangeLine.First())); +} + +//-------------------------------------------------------------------------------------------------- + +// Returns visible line number of a text position in characters. +NSInteger ScintillaCocoa::VisibleLineForIndex(NSInteger index) { + const NSRange rangePosition = PositionsFromCharacters(NSMakeRange(index, 0)); + const Sci::Line lineVisible = DisplayFromPosition(rangePosition.location); + return lineVisible; +} + +//-------------------------------------------------------------------------------------------------- + +// Returns a rectangle that frames the range for use by the VoiceOver cursor. +NSRect ScintillaCocoa::FrameForRange(NSRange rangeCharacters) { + const NSRange posRange = PositionsFromCharacters(rangeCharacters); + + NSUInteger rangeEnd = NSMaxRange(posRange); + const bool endsWithLineEnd = rangeCharacters.length && + (pdoc->GetColumn(rangeEnd) == 0); + + Point ptStart = LocationFromPosition(posRange.location); + const PointEnd peEndRange = static_cast(peSubLineEnd|peLineEnd); + Point ptEnd = LocationFromPosition(rangeEnd, peEndRange); + + NSRect rect = NSMakeRect(ptStart.x, ptStart.y, + ptEnd.x - ptStart.x, + ptEnd.y - ptStart.y); + + rect.size.width += 2; // Shows the last character better + if (endsWithLineEnd) { + // Add a block to the right to indicate a line end is selected + rect.size.width += 20; + } + + rect.size.height += vs.lineHeight; + + // Adjust for margin and scroll + rect.origin.x = rect.origin.x - vs.textStart + vs.fixedColumnWidth; + + return rect; +} + +//-------------------------------------------------------------------------------------------------- + +// Returns a rectangle that frames the range for use by the VoiceOver cursor. +NSRect ScintillaCocoa::GetBounds() const { + return PRectangleToNSRect(GetClientRectangle()); +} + +//-------------------------------------------------------------------------------------------------- + // Translates a UTF8 string into the document encoding. // Return the length of the result in bytes. -int ScintillaCocoa::EncodedFromUTF8(char *utf8, char *encoded) const +Sci::Position ScintillaCocoa::EncodedFromUTF8(const char *utf8, char *encoded) const { - const int inputLength = (lengthForEncode >= 0) ? lengthForEncode : strlen(utf8); + const size_t inputLength = (lengthForEncode >= 0) ? lengthForEncode : strlen(utf8); if (IsUnicodeMode()) { if (encoded) @@ -1704,10 +1784,8 @@ int ScintillaCocoa::EncodedFromUTF8(char *utf8, char *encoded) const // Need to convert const CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); - - CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast(utf8), - inputLength, kCFStringEncodingUTF8, false); + + CFStringRef cfsVal = CFStringFromString(utf8, inputLength, kCFStringEncodingUTF8); const std::string sEncoded = EncodedBytesString(cfsVal, encoding); if (encoded) memcpy(encoded, sEncoded.c_str(), sEncoded.length()); @@ -1741,23 +1819,18 @@ bool ScintillaCocoa::SyncPaint(void* gc, PRectangle rc) rcPaint = rc; PRectangle rcText = GetTextRectangle(); paintingAllText = rcPaint.Contains(rcText); - bool succeeded = true; - Surface *sw = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); - if (sw) - { - CGContextSetAllowsAntialiasing((CGContextRef)gc, - vs.extraFontFlag != SC_EFF_QUALITY_NON_ANTIALIASED); - CGContextSetAllowsFontSmoothing((CGContextRef)gc, - vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED); - CGContextSetAllowsFontSubpixelPositioning((CGContextRef)gc, - vs.extraFontFlag == SC_EFF_QUALITY_DEFAULT || - vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED); - sw->Init(gc, wMain.GetID()); - Paint(sw, rc); - succeeded = paintState != paintAbandoned; - sw->Release(); - delete sw; - } + std::unique_ptr sw(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); + CGContextSetAllowsAntialiasing((CGContextRef)gc, + vs.extraFontFlag != SC_EFF_QUALITY_NON_ANTIALIASED); + CGContextSetAllowsFontSmoothing((CGContextRef)gc, + vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED); + CGContextSetAllowsFontSubpixelPositioning((CGContextRef)gc, + vs.extraFontFlag == SC_EFF_QUALITY_DEFAULT || + vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED); + sw->Init(gc, wMain.GetID()); + Paint(sw.get(), rc); + const bool succeeded = paintState != paintAbandoned; + sw->Release(); paintState = notPainting; if (!succeeded) { @@ -1778,7 +1851,7 @@ void ScintillaCocoa::PaintMargin(NSRect aRect) PRectangle rc = NSRectToPRectangle(aRect); rcPaint = rc; - Surface *sw = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); + std::unique_ptr sw(Surface::Allocate(SC_TECHNOLOGY_DEFAULT)); if (sw) { CGContextSetAllowsAntialiasing(gc, @@ -1789,9 +1862,8 @@ void ScintillaCocoa::PaintMargin(NSRect aRect) vs.extraFontFlag == SC_EFF_QUALITY_DEFAULT || vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED); sw->Init(gc, wMargin.GetID()); - PaintSelMargin(sw, rc); + PaintSelMargin(sw.get(), rc); sw->Release(); - delete sw; } } @@ -1806,13 +1878,15 @@ void ScintillaCocoa::WillDraw(NSRect rect) { RefreshStyleData(); PRectangle rcWillDraw = NSRectToPRectangle(rect); - int positionAfterRect = PositionAfterArea(rcWillDraw); - pdoc->EnsureStyledTo(positionAfterRect); + const Sci::Position posAfterArea = PositionAfterArea(rcWillDraw); + const Sci::Position posAfterMax = PositionAfterMaxStyling(posAfterArea, true); + pdoc->StyleToAdjustingLineDuration(posAfterMax); + StartIdleStyling(posAfterMax < posAfterArea); NotifyUpdateUI(); - if (WrapLines(wsVisible)) { + if (WrapLines(WrapScope::wsVisible)) { // Wrap may have reduced number of lines so more lines may need to be styled - positionAfterRect = PositionAfterArea(rcWillDraw); - pdoc->EnsureStyledTo(positionAfterRect); + const Sci::Position posAfterAreaWrapped = PositionAfterArea(rcWillDraw); + pdoc->EnsureStyledTo(posAfterAreaWrapped); // The wrapping process has changed the height of some lines so redraw all. Redraw(); } @@ -1823,7 +1897,7 @@ void ScintillaCocoa::WillDraw(NSRect rect) /** * ScrollText is empty because scrolling is handled by the NSScrollView. */ -void ScintillaCocoa::ScrollText(int) +void ScintillaCocoa::ScrollText(Sci::Line) { } @@ -1877,7 +1951,7 @@ void ScintillaCocoa::SetHorizontalScrollPos() * @param nPage Number of lines per scroll page. * @return True if there was a change, otherwise false. */ -bool ScintillaCocoa::ModifyScrollBars(int nMax, int nPage) +bool ScintillaCocoa::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) { #pragma unused(nMax, nPage) return SetScrollingSize(); @@ -1891,7 +1965,7 @@ bool ScintillaCocoa::SetScrollingSize(void) { NSScrollView *scrollView = ScrollContainer(); NSClipView *clipView = [ScrollContainer() contentView]; NSRect clipRect = [clipView bounds]; - CGFloat docHeight = cs.LinesDisplayed() * vs.lineHeight; + CGFloat docHeight = pcs->LinesDisplayed() * vs.lineHeight; if (!endAtLastLine) docHeight += (int([scrollView bounds].size.height / vs.lineHeight)-3) * vs.lineHeight; // Allow extra space so that last scroll position places whole line at top @@ -1917,7 +1991,7 @@ bool ScintillaCocoa::SetScrollingSize(void) { SetVerticalScrollPos(); enteredSetScrollingSize = false; } - [inner.owner setMarginWidth: vs.fixedColumnWidth]; + [sciView setMarginWidth: vs.fixedColumnWidth]; return changes; } @@ -1937,7 +2011,7 @@ void ScintillaCocoa::Resize() void ScintillaCocoa::UpdateForScroll() { Point ptOrigin = GetVisibleOriginInMain(); xOffset = static_cast(ptOrigin.x); - int newTop = Platform::Minimum(static_cast(ptOrigin.y / vs.lineHeight), MaxScrollPos()); + Sci::Line newTop = std::min(static_cast(ptOrigin.y / vs.lineHeight), MaxScrollPos()); SetTopLine(newTop); } @@ -1986,7 +2060,7 @@ void ScintillaCocoa::NotifyChange() void ScintillaCocoa::NotifyFocus(bool focus) { - if (notifyProc != NULL) + if (commandEvents && notifyProc) notifyProc(notifyObj, WM_COMMAND, Platform::LongFromTwoShorts(static_cast(GetCtrlID()), (focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS)), (uintptr_t) this); @@ -2010,6 +2084,15 @@ void ScintillaCocoa::NotifyParent(SCNotification scn) notifyProc(notifyObj, WM_NOTIFY, GetCtrlID(), (uintptr_t) &scn); if (delegate) [delegate notification:&scn]; + if (scn.nmhdr.code == SCN_UPDATEUI) { + NSView *content = ContentView(); + if (scn.updated & SC_UPDATE_CONTENT) { + NSAccessibilityPostNotification(content, NSAccessibilityValueChangedNotification); + } + if (scn.updated & SC_UPDATE_SELECTION) { + NSAccessibilityPostNotification(content, NSAccessibilitySelectedTextChangedNotification); + } + } } //-------------------------------------------------------------------------------------------------- @@ -2084,7 +2167,7 @@ bool ScintillaCocoa::Draw(NSRect rect, CGContextRef gc) /** * Helper function to translate OS X key codes to Scintilla key codes. */ -static inline UniChar KeyTranslate(UniChar unicodeChar) +static inline UniChar KeyTranslate(UniChar unicodeChar, NSEventModifierFlags modifierFlags) { switch (unicodeChar) { @@ -2113,6 +2196,21 @@ static inline UniChar KeyTranslate(UniChar unicodeChar) return SCK_RETURN; case 27: return SCK_ESCAPE; + case '+': + if (modifierFlags & NSNumericPadKeyMask) + return SCK_ADD; + else + return unicodeChar; + case '-': + if (modifierFlags & NSNumericPadKeyMask) + return SCK_SUBTRACT; + else + return unicodeChar; + case '/': + if (modifierFlags & NSNumericPadKeyMask) + return SCK_DIVIDE; + else + return unicodeChar; case 127: return SCK_BACK; case '\t': @@ -2153,7 +2251,7 @@ static int TranslateModifierFlags(NSUInteger modifiers) bool ScintillaCocoa::KeyboardInput(NSEvent* event) { // For now filter out function keys. - NSString* input = [event characters]; + NSString* input = [event charactersIgnoringModifiers]; bool handled = false; @@ -2161,11 +2259,13 @@ bool ScintillaCocoa::KeyboardInput(NSEvent* event) for (size_t i = 0; i < input.length; i++) { const UniChar originalKey = [input characterAtIndex: i]; - UniChar key = KeyTranslate(originalKey); + NSEventModifierFlags modifierFlags = [event modifierFlags]; + + UniChar key = KeyTranslate(originalKey, modifierFlags); bool consumed = false; // Consumed as command? - if (KeyDownWithModifiers(key, TranslateModifierFlags([event modifierFlags]), &consumed)) + if (KeyDownWithModifiers(key, TranslateModifierFlags(modifierFlags), &consumed)) handled = true; if (consumed) handled = true; @@ -2179,17 +2279,27 @@ bool ScintillaCocoa::KeyboardInput(NSEvent* event) /** * Used to insert already processed text provided by the Cocoa text input system. */ -int ScintillaCocoa::InsertText(NSString* input) -{ +ptrdiff_t ScintillaCocoa::InsertText(NSString *input) { CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); std::string encoded = EncodedBytesString((CFStringRef)input, encoding); - + if (encoded.length() > 0) { - AddCharUTF((char*) encoded.c_str(), static_cast(encoded.length()), false); + if (encoding == kCFStringEncodingUTF8) { + // There may be multiple characters in input so loop over them + std::string sv = encoded; + while (sv.length()) { + const unsigned char leadByte = sv[0]; + const unsigned int bytesInCharacter = UTF8BytesOfLead[leadByte]; + AddCharUTF(sv.c_str(), bytesInCharacter, false); + sv = sv.substr(bytesInCharacter, sv.length()); + } + } else { + AddCharUTF(encoded.c_str(), static_cast(encoded.length()), false); + } } - return static_cast(encoded.length()); + return encoded.length(); } //-------------------------------------------------------------------------------------------------- @@ -2197,12 +2307,12 @@ int ScintillaCocoa::InsertText(NSString* input) /** * Convert from a range of characters to a range of bytes. */ -NSRange ScintillaCocoa::PositionsFromCharacters(NSRange range) const +NSRange ScintillaCocoa::PositionsFromCharacters(NSRange rangeCharacters) const { - long start = pdoc->GetRelativePositionUTF16(0, range.location); + Sci::Position start = pdoc->GetRelativePositionUTF16(0, rangeCharacters.location); if (start == INVALID_POSITION) start = pdoc->Length(); - long end = pdoc->GetRelativePositionUTF16(start, range.length); + Sci::Position end = pdoc->GetRelativePositionUTF16(start, rangeCharacters.length); if (end == INVALID_POSITION) end = pdoc->Length(); return NSMakeRange(start, end - start); @@ -2213,10 +2323,11 @@ NSRange ScintillaCocoa::PositionsFromCharacters(NSRange range) const /** * Convert from a range of characters from a range of bytes. */ -NSRange ScintillaCocoa::CharactersFromPositions(NSRange range) const +NSRange ScintillaCocoa::CharactersFromPositions(NSRange rangePositions) const { - const long start = pdoc->CountUTF16(0, range.location); - const long len = pdoc->CountUTF16(range.location, NSMaxRange(range)); + const Sci::Position start = pdoc->CountUTF16(0, rangePositions.location); + const Sci::Position len = pdoc->CountUTF16(rangePositions.location, + NSMaxRange(rangePositions)); return NSMakeRange(start, len); } @@ -2239,7 +2350,7 @@ void ScintillaCocoa::SelectOnlyMainSelection() */ void ScintillaCocoa::ConvertSelectionVirtualSpace() { - FillVirtualSpace(); + ClearBeforeTentativeStart(); } //-------------------------------------------------------------------------------------------------- @@ -2276,7 +2387,7 @@ void ScintillaCocoa::CompositionStart() void ScintillaCocoa::CompositionCommit() { pdoc->TentativeCommit(); - pdoc->decorations.SetCurrentIndicator(INDIC_IME); + pdoc->DecorationSetCurrentIndicator(INDIC_IME); pdoc->DecorationFillRange(0, 0, pdoc->Length()); } @@ -2307,6 +2418,20 @@ void ScintillaCocoa::SetDocPointer(Document *document) //-------------------------------------------------------------------------------------------------- +/** + * Convert NSEvent timestamp NSTimeInterval into unsigned int milliseconds wanted by Editor methods. + */ + +namespace { + +unsigned int TimeOfEvent(NSEvent *event) { + return static_cast([event timestamp] * 1000); +} + +} + +//-------------------------------------------------------------------------------------------------- + /** * Called by the owning view when the mouse pointer enters the control. */ @@ -2318,7 +2443,9 @@ void ScintillaCocoa::MouseEntered(NSEvent* event) // Mouse location is given in screen coordinates and might also be outside of our bounds. Point location = ConvertPoint([event locationInWindow]); - ButtonMove(location); + ButtonMoveWithModifiers(location, + TimeOfEvent(event), + TranslateModifierFlags([event modifierFlags])); } } @@ -2334,12 +2461,17 @@ void ScintillaCocoa::MouseExited(NSEvent* /* event */) void ScintillaCocoa::MouseDown(NSEvent* event) { Point location = ConvertPoint([event locationInWindow]); - NSTimeInterval time = [event timestamp]; - bool command = ([event modifierFlags] & NSCommandKeyMask) != 0; - bool shift = ([event modifierFlags] & NSShiftKeyMask) != 0; - bool alt = ([event modifierFlags] & NSAlternateKeyMask) != 0; + ButtonDownWithModifiers(location, + TimeOfEvent(event), + TranslateModifierFlags([event modifierFlags])); +} - ButtonDown(Point(location.x, location.y), (int) (time * 1000), shift, command, alt); +void ScintillaCocoa::RightMouseDown(NSEvent *event) +{ + Point location = ConvertPoint([event locationInWindow]); + RightButtonDownWithModifiers(location, + TimeOfEvent(event), + TranslateModifierFlags([event modifierFlags])); } //-------------------------------------------------------------------------------------------------- @@ -2348,17 +2480,16 @@ void ScintillaCocoa::MouseMove(NSEvent* event) { lastMouseEvent = event; - ButtonMoveWithModifiers(ConvertPoint([event locationInWindow]), TranslateModifierFlags([event modifierFlags])); + ButtonMoveWithModifiers(ConvertPoint([event locationInWindow]), TimeOfEvent(event), TranslateModifierFlags([event modifierFlags])); } //-------------------------------------------------------------------------------------------------- void ScintillaCocoa::MouseUp(NSEvent* event) { - NSTimeInterval time = [event timestamp]; - bool control = ([event modifierFlags] & NSControlKeyMask) != 0; - - ButtonUp(ConvertPoint([event locationInWindow]), (int) (time * 1000), control); + ButtonUpWithModifiers(ConvertPoint([event locationInWindow]), + TimeOfEvent(event), + TranslateModifierFlags([event modifierFlags])); } //-------------------------------------------------------------------------------------------------- @@ -2371,9 +2502,9 @@ void ScintillaCocoa::MouseWheel(NSEvent* event) // In order to make scrolling with larger offset smoother we scroll less lines the larger the // delta value is. if ([event deltaY] < 0) - dY = -(int) sqrt(-10.0 * [event deltaY]); + dY = -static_cast(sqrt(-10.0 * [event deltaY])); else - dY = (int) sqrt(10.0 * [event deltaY]); + dY = static_cast(sqrt(10.0 * [event deltaY])); if (command) { @@ -2400,7 +2531,7 @@ void ScintillaCocoa::SelectAll() void ScintillaCocoa::DeleteBackward() { - KeyDown(SCK_BACK, false, false, false, nil); + KeyDownWithModifiers(SCK_BACK, 0, nil); } void ScintillaCocoa::Cut() @@ -2420,6 +2551,16 @@ void ScintillaCocoa::Redo() //-------------------------------------------------------------------------------------------------- +bool ScintillaCocoa::ShouldDisplayPopupOnMargin() +{ + return displayPopupMenu == SC_POPUP_ALL; +} + +bool ScintillaCocoa::ShouldDisplayPopupOnText() +{ + return displayPopupMenu == SC_POPUP_ALL || displayPopupMenu == SC_POPUP_TEXT; +} + /** * Creates and returns a popup menu, which is then displayed by the Cocoa framework. */ @@ -2428,7 +2569,7 @@ NSMenu* ScintillaCocoa::CreateContextMenu(NSEvent* /* event */) // Call ScintillaBase to create the context menu. ContextMenu(Point(0, 0)); - return reinterpret_cast(popup.GetID()); + return static_cast(popup.GetID()); } //-------------------------------------------------------------------------------------------------- @@ -2483,7 +2624,7 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining layerFindIndicator = [[FindHighlightLayer alloc] init]; [content setWantsLayer: YES]; layerFindIndicator.geometryFlipped = content.layer.geometryFlipped; - if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_8) + if (std::floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_8) { // Content layer is unflipped on 10.9, but the indicator shows wrong unless flipped layerFindIndicator.geometryFlipped = YES; @@ -2497,17 +2638,17 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); std::vector buffer(charRange.length); - pdoc->GetCharRange(&buffer[0], static_cast(charRange.location), static_cast(charRange.length)); + pdoc->GetCharRange(&buffer[0], charRange.location, charRange.length); - CFStringRef cfsFind = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast(&buffer[0]), - charRange.length, encoding, false); + CFStringRef cfsFind = CFStringFromString(&buffer[0], charRange.length, encoding); layerFindIndicator.sFind = (NSString *)cfsFind; if (cfsFind) CFRelease(cfsFind); layerFindIndicator.retaining = retaining; - layerFindIndicator.positionFind = static_cast(charRange.location); - long style = WndProc(SCI_GETSTYLEAT, charRange.location, 0); + layerFindIndicator.positionFind = charRange.location; + // SCI_GETSTYLEAT reports a signed byte but want an unsigned to index into styles + const char styleByte = static_cast(WndProc(SCI_GETSTYLEAT, charRange.location, 0)); + const long style = static_cast(styleByte); std::vector bufferFontName(WndProc(SCI_STYLEGETFONT, style, 0) + 1); WndProc(SCI_STYLEGETFONT, style, (sptr_t)&bufferFontName[0]); layerFindIndicator.sFont = [NSString stringWithUTF8String: &bufferFontName[0]]; diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/Info.plist b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/Info.plist similarity index 83% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/Info.plist rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/Info.plist index 13ee4cc2..bece06b2 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/Info.plist +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/Info.plist @@ -9,17 +9,19 @@ CFBundleIconFile CFBundleIdentifier - com.sun.${PRODUCT_NAME:identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName ${PRODUCT_NAME} CFBundlePackageType FMWK + CFBundleShortVersionString + 3.10.6 CFBundleSignature ???? CFBundleVersion - 1.0 + 3.10.6 NSPrincipalClass diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj similarity index 91% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj index 0d099faa..916b7d4e 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj @@ -7,11 +7,12 @@ objects = { /* Begin PBXBuildFile section */ + 00724A59981D34F11A3D162F /* LexCIL.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 577F46B88F633198B56D088D /* LexCIL.cxx */; }; + 0ED84236A703D57578EBFD2F /* LexNim.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 47814937A6B72D2B0F065B61 /* LexNim.cxx */; }; 1100F1EB178E393200105727 /* CaseConvert.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 1100F1E6178E393200105727 /* CaseConvert.cxx */; }; 1100F1EC178E393200105727 /* CaseConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1100F1E7178E393200105727 /* CaseConvert.h */; }; 1100F1ED178E393200105727 /* CaseFolder.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 1100F1E8178E393200105727 /* CaseFolder.cxx */; }; 1100F1EE178E393200105727 /* CaseFolder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1100F1E9178E393200105727 /* CaseFolder.h */; }; - 1100F1EF178E393200105727 /* UnicodeFromUTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = 1100F1EA178E393200105727 /* UnicodeFromUTF8.h */; }; 1102C31C169FB49300DC16AB /* LexLaTeX.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 1102C31B169FB49300DC16AB /* LexLaTeX.cxx */; }; 11126B8214CD3A6200803C49 /* LexAVS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11126B8114CD3A6200803C49 /* LexAVS.cxx */; }; 1114D6CB1602A951001DC345 /* LexPO.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 1114D6CA1602A951001DC345 /* LexPO.cxx */; }; @@ -125,7 +126,7 @@ 114B6F9D11FA75BE004FB6AB /* PropSetSimple.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 114B6F9411FA75BE004FB6AB /* PropSetSimple.cxx */; }; 114B6F9E11FA75BE004FB6AB /* StyleContext.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 114B6F9511FA75BE004FB6AB /* StyleContext.cxx */; }; 114B6F9F11FA75BE004FB6AB /* WordList.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 114B6F9611FA75BE004FB6AB /* WordList.cxx */; }; - 114B6FA111FA75DB004FB6AB /* ILexer.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FA011FA75DB004FB6AB /* ILexer.h */; }; + 114B6FA111FA75DB004FB6AB /* ILexer.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FA011FA75DB004FB6AB /* ILexer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 114B6FBD11FA7623004FB6AB /* AutoComplete.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FA211FA7623004FB6AB /* AutoComplete.h */; }; 114B6FBE11FA7623004FB6AB /* CallTip.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FA311FA7623004FB6AB /* CallTip.h */; }; 114B6FBF11FA7623004FB6AB /* Catalogue.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FA411FA7623004FB6AB /* Catalogue.h */; }; @@ -199,6 +200,9 @@ 280056FC188DDD2C00F200AE /* StringCopy.h in Headers */ = {isa = PBXBuildFile; fileRef = 280056F9188DDD2C00F200AE /* StringCopy.h */; }; 280056FD188DDD2C00F200AE /* SubStyles.h in Headers */ = {isa = PBXBuildFile; fileRef = 280056FA188DDD2C00F200AE /* SubStyles.h */; }; 28064A05190F12E100E6E47F /* LexDMIS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28064A04190F12E100E6E47F /* LexDMIS.cxx */; }; + 281225362256DD2D00AFE50C /* UniqueString.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 281225352256DD2D00AFE50C /* UniqueString.cxx */; }; + 282D4A961F53FE270082E4D3 /* ILoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 282D4A951F53FE270082E4D3 /* ILoader.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 28804B2C1EEE232E00C0D154 /* DBCS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28804B2B1EEE232E00C0D154 /* DBCS.cxx */; }; 28A067111A36B42600B4966A /* LexHex.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28A067101A36B42600B4966A /* LexHex.cxx */; }; 28A1DD51196BE0CA006EFCDD /* EditModel.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */; }; 28A1DD52196BE0CA006EFCDD /* EditView.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28A1DD4F196BE0CA006EFCDD /* EditView.cxx */; }; @@ -213,24 +217,33 @@ 28B6470F1B54C0720009DC49 /* LexMake.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28B647091B54C0720009DC49 /* LexMake.cxx */; }; 28B647101B54C0720009DC49 /* LexNull.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28B6470A1B54C0720009DC49 /* LexNull.cxx */; }; 28B647111B54C0720009DC49 /* LexProps.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28B6470B1B54C0720009DC49 /* LexProps.cxx */; }; + 28BC38EC1B74C6AD008BF9EB /* Sci_Position.h in Headers */ = {isa = PBXBuildFile; fileRef = 28BC38EB1B74C6AD008BF9EB /* Sci_Position.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 28BDA1221EFB8F7C00EBD3F3 /* DefaultLexer.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28BDA1211EFB8F7C00EBD3F3 /* DefaultLexer.cxx */; }; + 28BDA1241EFB8FB200EBD3F3 /* DefaultLexer.h in Headers */ = {isa = PBXBuildFile; fileRef = 28BDA1231EFB8FB200EBD3F3 /* DefaultLexer.h */; }; + 28C40CA81CB7321200B089F2 /* LexJSON.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28C40CA71CB7321200B089F2 /* LexJSON.cxx */; }; + 28D191A21DEA72C800159938 /* LexEDIFACT.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28D191A11DEA72C800159938 /* LexEDIFACT.cxx */; }; 28D516D81830FFCA0047C93D /* info_bar_bg@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 28D516D51830FFCA0047C93D /* info_bar_bg@2x.png */; }; 28D516D91830FFCA0047C93D /* mac_cursor_busy@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 28D516D61830FFCA0047C93D /* mac_cursor_busy@2x.png */; }; 28D516DA1830FFCA0047C93D /* mac_cursor_flipped@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 28D516D71830FFCA0047C93D /* mac_cursor_flipped@2x.png */; }; 28FDA42119B6967B00BE27D7 /* LexBibTeX.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28FDA42019B6967B00BE27D7 /* LexBibTeX.cxx */; }; + 3D994BD7A5EAC4FA5B3CFBDF /* LexMaxima.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 29B042978C1F93EF42F9E4AB /* LexMaxima.cxx */; }; + 5F804AA6B60FE695863A39FE /* LexStata.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 7623427695416AB1270EE023 /* LexStata.cxx */; }; 8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; }; 8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; }; + F437405F9F32C7DEFCA38C11 /* LexIndent.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */; }; + FDC7442CAD70B9A67EF1639D /* LexSAS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = A95147A1AB7CADB00DAFE724 /* LexSAS.cxx */; }; + AE894E1CB7328CAE5B2EF47E /* LexX12.cxx in Sources */ = {isa = PBXBuildFile; fileRef = ADA64364A443F3E3F02D294E /* LexX12.cxx */; }; + 4D0C4365AB6DF998CD48B1FC /* LexLPeg.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 5EB3467789767C0ACE40A46A /* LexLPeg.cxx */; }; */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; - 089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 1100F1E6178E393200105727 /* CaseConvert.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CaseConvert.cxx; path = ../../src/CaseConvert.cxx; sourceTree = ""; }; 1100F1E7178E393200105727 /* CaseConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CaseConvert.h; path = ../../src/CaseConvert.h; sourceTree = ""; }; 1100F1E8178E393200105727 /* CaseFolder.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CaseFolder.cxx; path = ../../src/CaseFolder.cxx; sourceTree = ""; }; 1100F1E9178E393200105727 /* CaseFolder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CaseFolder.h; path = ../../src/CaseFolder.h; sourceTree = ""; }; - 1100F1EA178E393200105727 /* UnicodeFromUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnicodeFromUTF8.h; path = ../../src/UnicodeFromUTF8.h; sourceTree = ""; }; 1102C31B169FB49300DC16AB /* LexLaTeX.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexLaTeX.cxx; path = ../../lexers/LexLaTeX.cxx; sourceTree = ""; }; 11126B8114CD3A6200803C49 /* LexAVS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexAVS.cxx; path = ../../lexers/LexAVS.cxx; sourceTree = ""; }; 1114D6CA1602A951001DC345 /* LexPO.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexPO.cxx; path = ../../lexers/LexPO.cxx; sourceTree = ""; }; @@ -418,6 +431,10 @@ 280056F9188DDD2C00F200AE /* StringCopy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringCopy.h; path = ../../lexlib/StringCopy.h; sourceTree = ""; }; 280056FA188DDD2C00F200AE /* SubStyles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SubStyles.h; path = ../../lexlib/SubStyles.h; sourceTree = ""; }; 28064A04190F12E100E6E47F /* LexDMIS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexDMIS.cxx; path = ../../lexers/LexDMIS.cxx; sourceTree = ""; }; + 281225352256DD2D00AFE50C /* UniqueString.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UniqueString.cxx; path = ../../src/UniqueString.cxx; sourceTree = ""; }; + 282D4A951F53FE270082E4D3 /* ILoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ILoader.h; path = ../../include/ILoader.h; sourceTree = ""; }; + 282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexIndent.cxx; path = ../../lexers/LexIndent.cxx; sourceTree = SOURCE_ROOT; }; + 28804B2B1EEE232E00C0D154 /* DBCS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DBCS.cxx; path = ../../src/DBCS.cxx; sourceTree = ""; }; 28A067101A36B42600B4966A /* LexHex.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexHex.cxx; path = ../../lexers/LexHex.cxx; sourceTree = ""; }; 28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditModel.cxx; path = ../../src/EditModel.cxx; sourceTree = ""; }; 28A1DD4F196BE0CA006EFCDD /* EditView.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditView.cxx; path = ../../src/EditView.cxx; sourceTree = ""; }; @@ -432,14 +449,28 @@ 28B647091B54C0720009DC49 /* LexMake.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexMake.cxx; path = ../../lexers/LexMake.cxx; sourceTree = ""; }; 28B6470A1B54C0720009DC49 /* LexNull.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexNull.cxx; path = ../../lexers/LexNull.cxx; sourceTree = ""; }; 28B6470B1B54C0720009DC49 /* LexProps.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexProps.cxx; path = ../../lexers/LexProps.cxx; sourceTree = ""; }; + 28BC38EB1B74C6AD008BF9EB /* Sci_Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sci_Position.h; path = ../../include/Sci_Position.h; sourceTree = ""; }; + 28BDA1211EFB8F7C00EBD3F3 /* DefaultLexer.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DefaultLexer.cxx; path = ../../lexlib/DefaultLexer.cxx; sourceTree = ""; }; + 28BDA1231EFB8FB200EBD3F3 /* DefaultLexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DefaultLexer.h; path = ../../lexlib/DefaultLexer.h; sourceTree = ""; }; + 28C40CA71CB7321200B089F2 /* LexJSON.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexJSON.cxx; path = ../../lexers/LexJSON.cxx; sourceTree = ""; }; + 28D1919E1DE69FC100159938 /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = ""; }; + 28D191A11DEA72C800159938 /* LexEDIFACT.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexEDIFACT.cxx; path = ../../lexers/LexEDIFACT.cxx; sourceTree = ""; }; 28D516D51830FFCA0047C93D /* info_bar_bg@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "info_bar_bg@2x.png"; sourceTree = ""; }; 28D516D61830FFCA0047C93D /* mac_cursor_busy@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "mac_cursor_busy@2x.png"; sourceTree = ""; }; 28D516D71830FFCA0047C93D /* mac_cursor_flipped@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "mac_cursor_flipped@2x.png"; sourceTree = ""; }; + 28F2653B224C30D7000CF4A3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 28FDA42019B6967B00BE27D7 /* LexBibTeX.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexBibTeX.cxx; path = ../../lexers/LexBibTeX.cxx; sourceTree = ""; }; + 29B042978C1F93EF42F9E4AB /* LexMaxima.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexMaxima.cxx; path = ../../lexers/LexMaxima.cxx; sourceTree = SOURCE_ROOT; }; 32DBCF5E0370ADEE00C91783 /* Scintilla_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scintilla_Prefix.pch; sourceTree = ""; }; + 47814937A6B72D2B0F065B61 /* LexNim.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexNim.cxx; path = ../../lexers/LexNim.cxx; sourceTree = SOURCE_ROOT; }; + 577F46B88F633198B56D088D /* LexCIL.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexCIL.cxx; path = ../../lexers/LexCIL.cxx; sourceTree = SOURCE_ROOT; }; + 7623427695416AB1270EE023 /* LexStata.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexStata.cxx; path = ../../lexers/LexStata.cxx; sourceTree = SOURCE_ROOT; }; 8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8DC2EF5B0486A6940098B216 /* Scintilla.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Scintilla.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A95147A1AB7CADB00DAFE724 /* LexSAS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexSAS.cxx; path = ../../lexers/LexSAS.cxx; sourceTree = SOURCE_ROOT; }; D2F7E79907B2D74100F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; + ADA64364A443F3E3F02D294E /* LexX12.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexX12.cxx; path = ../../lexers/LexX12.cxx; sourceTree = SOURCE_ROOT; }; + 5EB3467789767C0ACE40A46A /* LexLPeg.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexLPeg.cxx; path = ../../lexers/LexLPeg.cxx; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -499,6 +530,7 @@ 08FB77AEFE84172EC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 28D1919E1DE69FC100159938 /* module.modulemap */, 2744E4980FC167ED00E85C33 /* Source Files */, 2744E4970FC167E400E85C33 /* Header Files */, ); @@ -553,6 +585,7 @@ 28FDA42019B6967B00BE27D7 /* LexBibTeX.cxx */, 114B6EC911FA7526004FB6AB /* LexBullant.cxx */, 114B6ECA11FA7526004FB6AB /* LexCaml.cxx */, + 577F46B88F633198B56D088D /* LexCIL.cxx */, 114B6ECB11FA7526004FB6AB /* LexCLW.cxx */, 114B6ECC11FA7526004FB6AB /* LexCmake.cxx */, 114B6ECD11FA7526004FB6AB /* LexCOBOL.cxx */, @@ -567,6 +600,7 @@ 11FF3FE11810EB3900E13F13 /* LexDMAP.cxx */, 28064A04190F12E100E6E47F /* LexDMIS.cxx */, 11BEB6A114EF189600BDE92A /* LexECL.cxx */, + 28D191A11DEA72C800159938 /* LexEDIFACT.cxx */, 114B6ED411FA7526004FB6AB /* LexEiffel.cxx */, 114B6ED511FA7526004FB6AB /* LexErlang.cxx */, 28B647081B54C0720009DC49 /* LexErrorList.cxx */, @@ -579,23 +613,28 @@ 114B6EDC11FA7526004FB6AB /* LexHaskell.cxx */, 28A067101A36B42600B4966A /* LexHex.cxx */, 114B6EDD11FA7526004FB6AB /* LexHTML.cxx */, + 282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */, 114B6EDE11FA7526004FB6AB /* LexInno.cxx */, + 28C40CA71CB7321200B089F2 /* LexJSON.cxx */, 114B6EDF11FA7526004FB6AB /* LexKix.cxx */, 11FDD0DF17C480D4001541B9 /* LexKVIrc.cxx */, 1102C31B169FB49300DC16AB /* LexLaTeX.cxx */, 114B6EE011FA7526004FB6AB /* LexLisp.cxx */, 114B6EE111FA7526004FB6AB /* LexLout.cxx */, + 5EB3467789767C0ACE40A46A /* LexLPeg.cxx */, 114B6EE211FA7526004FB6AB /* LexLua.cxx */, 114B6EE311FA7526004FB6AB /* LexMagik.cxx */, 28B647091B54C0720009DC49 /* LexMake.cxx */, 114B6EE411FA7526004FB6AB /* LexMarkdown.cxx */, 114B6EE511FA7526004FB6AB /* LexMatlab.cxx */, + 29B042978C1F93EF42F9E4AB /* LexMaxima.cxx */, 114B6EE611FA7526004FB6AB /* LexMetapost.cxx */, 114B6EE711FA7526004FB6AB /* LexMMIXAL.cxx */, 11BB124C12FF9C1300F6BCF7 /* LexModula.cxx */, 114B6EE811FA7526004FB6AB /* LexMPT.cxx */, 114B6EE911FA7526004FB6AB /* LexMSSQL.cxx */, 114B6EEA11FA7526004FB6AB /* LexMySQL.cxx */, + 47814937A6B72D2B0F065B61 /* LexNim.cxx */, 114B6EEB11FA7526004FB6AB /* LexNimrod.cxx */, 114B6EEC11FA7526004FB6AB /* LexNsis.cxx */, 28B6470A1B54C0720009DC49 /* LexNull.cxx */, @@ -618,6 +657,7 @@ 28A7D6041995E47D0062D204 /* LexRegistry.cxx */, 114B6EFB11FA7526004FB6AB /* LexRuby.cxx */, 1160E0371803651C00BCEBCB /* LexRust.cxx */, + A95147A1AB7CADB00DAFE724 /* LexSAS.cxx */, 114B6EFC11FA7526004FB6AB /* LexScriptol.cxx */, 114B6EFD11FA7526004FB6AB /* LexSmalltalk.cxx */, 114B6EFE11FA7526004FB6AB /* LexSML.cxx */, @@ -625,6 +665,7 @@ 114B6F0011FA7526004FB6AB /* LexSpecman.cxx */, 114B6F0111FA7526004FB6AB /* LexSpice.cxx */, 114B6F0211FA7526004FB6AB /* LexSQL.cxx */, + 7623427695416AB1270EE023 /* LexStata.cxx */, 11FDAEB6174E1A9700FA161B /* LexSTTXT.cxx */, 114B6F0311FA7526004FB6AB /* LexTACL.cxx */, 114B6F0411FA7526004FB6AB /* LexTADS3.cxx */, @@ -637,6 +678,7 @@ 114B6F0A11FA7526004FB6AB /* LexVerilog.cxx */, 114B6F0B11FA7526004FB6AB /* LexVHDL.cxx */, 11594BE8155B91DF0099E1FA /* LexVisualProlog.cxx */, + ADA64364A443F3E3F02D294E /* LexX12.cxx */, 114B6F0C11FA7526004FB6AB /* LexYAML.cxx */, ); name = Lexers; @@ -657,6 +699,7 @@ 114B6FA611FA7623004FB6AB /* CharClassify.h */, 114B6FA711FA7623004FB6AB /* ContractionState.h */, 114B6FA811FA7623004FB6AB /* Decoration.h */, + 28BDA1231EFB8FB200EBD3F3 /* DefaultLexer.h */, 114B6FA911FA7623004FB6AB /* Document.h */, 28A1DD54196BE0ED006EFCDD /* EditModel.h */, 114B6FAA11FA7623004FB6AB /* Editor.h */, @@ -664,6 +707,7 @@ 114B6FAB11FA7623004FB6AB /* ExternalLexer.h */, 114B6FAC11FA7623004FB6AB /* FontQuality.h */, 114B6FA011FA75DB004FB6AB /* ILexer.h */, + 282D4A951F53FE270082E4D3 /* ILoader.h */, 114B6FAD11FA7623004FB6AB /* Indicator.h */, 114B6FAE11FA7623004FB6AB /* KeyMap.h */, 114B6FDA11FA7645004FB6AB /* LexAccessor.h */, @@ -688,7 +732,6 @@ 114B6FB811FA7623004FB6AB /* Style.h */, 114B6FE111FA7645004FB6AB /* StyleContext.h */, 280056FA188DDD2C00F200AE /* SubStyles.h */, - 1100F1EA178E393200105727 /* UnicodeFromUTF8.h */, 114B6FBA11FA7623004FB6AB /* UniConversion.h */, 114B6FBB11FA7623004FB6AB /* ViewStyle.h */, 114B6FE211FA7645004FB6AB /* WordList.h */, @@ -711,7 +754,9 @@ 114B6F8F11FA75BE004FB6AB /* CharacterSet.cxx */, 114B6F6411FA7597004FB6AB /* CharClassify.cxx */, 114B6F6511FA7597004FB6AB /* ContractionState.cxx */, + 28804B2B1EEE232E00C0D154 /* DBCS.cxx */, 114B6F6611FA7597004FB6AB /* Decoration.cxx */, + 28BDA1211EFB8F7C00EBD3F3 /* DefaultLexer.cxx */, 114B6F6711FA7597004FB6AB /* Document.cxx */, 28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */, 114B6F6811FA7597004FB6AB /* Editor.cxx */, @@ -735,6 +780,7 @@ 114B6F7311FA7598004FB6AB /* Style.cxx */, 114B6F9511FA75BE004FB6AB /* StyleContext.cxx */, 114B6F7411FA7598004FB6AB /* UniConversion.cxx */, + 281225352256DD2D00AFE50C /* UniqueString.cxx */, 114B6F7511FA7598004FB6AB /* ViewStyle.cxx */, 114B6F9611FA75BE004FB6AB /* WordList.cxx */, 114B6F7611FA7598004FB6AB /* XPM.cxx */, @@ -752,6 +798,7 @@ 2744E59F0FC168A100E85C33 /* QuartzTextLayout.h */, 119FF1BE13C9D1820007CE42 /* QuartzTextStyle.h */, 2744E5A00FC168A100E85C33 /* QuartzTextStyleAttribute.h */, + 28BC38EB1B74C6AD008BF9EB /* Sci_Position.h */, 2744E4870FC1678600E85C33 /* SciLexer.h */, 2744E4880FC1678600E85C33 /* Scintilla.h */, 2744E5A20FC168A100E85C33 /* ScintillaCocoa.h */, @@ -800,9 +847,12 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 28BC38EC1B74C6AD008BF9EB /* Sci_Position.h in Headers */, + 114B6FA111FA75DB004FB6AB /* ILexer.h in Headers */, 2744E5A40FC168A100E85C33 /* InfoBar.h in Headers */, 2744E5AC0FC168B200E85C33 /* InfoBarCommunicator.h in Headers */, 2744E5AA0FC168A100E85C33 /* ScintillaView.h in Headers */, + 28BDA1241EFB8FB200EBD3F3 /* DefaultLexer.h in Headers */, 280056FB188DDD2C00F200AE /* SparseState.h in Headers */, 2791F3C80FC19F71009DBCF9 /* SciLexer.h in Headers */, 2791F3C60FC19F71009DBCF9 /* PlatCocoa.h in Headers */, @@ -811,7 +861,6 @@ 2791F3E00FC1A390009DBCF9 /* ScintillaCocoa.h in Headers */, 2791F3C70FC19F71009DBCF9 /* Platform.h in Headers */, 2791F3C90FC19F71009DBCF9 /* Scintilla.h in Headers */, - 114B6FA111FA75DB004FB6AB /* ILexer.h in Headers */, 114B6FBD11FA7623004FB6AB /* AutoComplete.h in Headers */, 114B6FBE11FA7623004FB6AB /* CallTip.h in Headers */, 114B6FBF11FA7623004FB6AB /* Catalogue.h in Headers */, @@ -819,6 +868,7 @@ 114B6FC111FA7623004FB6AB /* CharClassify.h in Headers */, 114B6FC211FA7623004FB6AB /* ContractionState.h in Headers */, 114B6FC311FA7623004FB6AB /* Decoration.h in Headers */, + 282D4A961F53FE270082E4D3 /* ILoader.h in Headers */, 114B6FC411FA7623004FB6AB /* Document.h in Headers */, 114B6FC511FA7623004FB6AB /* Editor.h in Headers */, 114B6FC611FA7623004FB6AB /* ExternalLexer.h in Headers */, @@ -858,7 +908,6 @@ 11FBA39E17817DA00048C071 /* CharacterCategory.h in Headers */, 1100F1EC178E393200105727 /* CaseConvert.h in Headers */, 1100F1EE178E393200105727 /* CaseFolder.h in Headers */, - 1100F1EF178E393200105727 /* UnicodeFromUTF8.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -890,7 +939,7 @@ 0867D690FE84028FC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0610; + LastUpgradeCheck = 0800; }; buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "ScintillaFramework" */; compatibilityVersion = "Xcode 3.2"; @@ -901,6 +950,7 @@ Japanese, French, German, + Base, ); mainGroup = 0867D691FE84028FC02AAC07 /* Scintilla */; productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; @@ -938,6 +988,9 @@ 2744E5B30FC168C500E85C33 /* PlatCocoa.mm in Sources */, 2744E5B50FC168C500E85C33 /* ScintillaCocoa.mm in Sources */, 2744E5B60FC168C500E85C33 /* ScintillaView.mm in Sources */, + 28D191A21DEA72C800159938 /* LexEDIFACT.cxx in Sources */, + 28BDA1221EFB8F7C00EBD3F3 /* DefaultLexer.cxx in Sources */, + 281225362256DD2D00AFE50C /* UniqueString.cxx in Sources */, 114B6F0D11FA7526004FB6AB /* LexAbaqus.cxx in Sources */, 114B6F0E11FA7526004FB6AB /* LexAda.cxx in Sources */, 28B6470C1B54C0720009DC49 /* LexBatch.cxx in Sources */, @@ -955,6 +1008,7 @@ 114B6F1911FA7526004FB6AB /* LexCaml.cxx in Sources */, 114B6F1A11FA7526004FB6AB /* LexCLW.cxx in Sources */, 114B6F1B11FA7526004FB6AB /* LexCmake.cxx in Sources */, + 28C40CA81CB7321200B089F2 /* LexJSON.cxx in Sources */, 114B6F1C11FA7526004FB6AB /* LexCOBOL.cxx in Sources */, 114B6F1D11FA7526004FB6AB /* LexConf.cxx in Sources */, 28B647101B54C0720009DC49 /* LexNull.cxx in Sources */, @@ -993,6 +1047,7 @@ 114B6F3911FA7526004FB6AB /* LexMySQL.cxx in Sources */, 114B6F3A11FA7526004FB6AB /* LexNimrod.cxx in Sources */, 114B6F3B11FA7526004FB6AB /* LexNsis.cxx in Sources */, + 28804B2C1EEE232E00C0D154 /* DBCS.cxx in Sources */, 114B6F3C11FA7526004FB6AB /* LexOpal.cxx in Sources */, 114B6F3E11FA7526004FB6AB /* LexPascal.cxx in Sources */, 28B6470D1B54C0720009DC49 /* LexDiff.cxx in Sources */, @@ -1078,6 +1133,14 @@ 11FDD0E017C480D4001541B9 /* LexKVIrc.cxx in Sources */, 1160E0381803651C00BCEBCB /* LexRust.cxx in Sources */, 11FF3FE21810EB3900E13F13 /* LexDMAP.cxx in Sources */, + F437405F9F32C7DEFCA38C11 /* LexIndent.cxx in Sources */, + 4D0C4365AB6DF998CD48B1FC /* LexLPeg.cxx in Sources */, + 3D994BD7A5EAC4FA5B3CFBDF /* LexMaxima.cxx in Sources */, + FDC7442CAD70B9A67EF1639D /* LexSAS.cxx in Sources */, + 5F804AA6B60FE695863A39FE /* LexStata.cxx in Sources */, + 0ED84236A703D57578EBFD2F /* LexNim.cxx in Sources */, + 00724A59981D34F11A3D162F /* LexCIL.cxx in Sources */, + AE894E1CB7328CAE5B2EF47E /* LexX12.cxx in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1102,6 +1165,7 @@ CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; + DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES = ".bzr *.nib *.lproj *.framework *.gch (*) CVS .svn *.xcodeproj *.xcode *.pbproj *.pbxproj"; @@ -1112,7 +1176,6 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Scintilla_Prefix.pch; GCC_PREPROCESSOR_DEFINITIONS = ( - SCI_NAMESPACE, SCI_LEXER, ); GCC_WARN_UNINITIALIZED_AUTOS = NO; @@ -1122,6 +1185,8 @@ INFOPLIST_FILE = Info.plist; INSTALL_PATH = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.7; + MODULEMAP_FILE = module.modulemap; + PRODUCT_BUNDLE_IDENTIFIER = "com.sun.${PRODUCT_NAME:identifier}"; PRODUCT_NAME = Scintilla; SKIP_INSTALL = YES; WRAPPER_EXTENSION = framework; @@ -1135,6 +1200,7 @@ CLANG_CXX_LIBRARY = "libc++"; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; FRAMEWORK_VERSION = A; @@ -1142,7 +1208,6 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Scintilla_Prefix.pch; GCC_PREPROCESSOR_DEFINITIONS = ( - SCI_NAMESPACE, SCI_LEXER, ); GCC_WARN_UNINITIALIZED_AUTOS = NO; @@ -1152,6 +1217,8 @@ INFOPLIST_FILE = Info.plist; INSTALL_PATH = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.7; + MODULEMAP_FILE = module.modulemap; + PRODUCT_BUNDLE_IDENTIFIER = "com.sun.${PRODUCT_NAME:identifier}"; PRODUCT_NAME = Scintilla; SKIP_INSTALL = YES; WRAPPER_EXTENSION = framework; @@ -1161,10 +1228,27 @@ 1DEB91B208733DA50010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = c99; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( ../../include, @@ -1180,9 +1264,25 @@ 1DEB91B308733DA50010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = c99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( ../../include, diff --git a/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..acc8e3f9 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/xcshareddata/xcschemes/Scintilla.xcscheme b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/xcshareddata/xcschemes/Scintilla.xcscheme new file mode 100644 index 00000000..3e029056 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/xcshareddata/xcschemes/Scintilla.xcscheme @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/Scintilla_Prefix.pch b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/Scintilla_Prefix.pch similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/Scintilla_Prefix.pch rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/Scintilla_Prefix.pch diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/English.lproj/InfoPlist.strings b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/en.lproj/InfoPlist.strings similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaFramework/English.lproj/InfoPlist.strings rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/en.lproj/InfoPlist.strings diff --git a/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/module.modulemap b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/module.modulemap new file mode 100644 index 00000000..d09ce2e3 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaFramework/module.modulemap @@ -0,0 +1,10 @@ +framework module Scintilla { + umbrella header "ScintillaView.h" + module InfoBar { + header "InfoBar.h" + } + // ILexer.h is not included as Swift doesn't yet interoperate with C++ + exclude header "ILexer.h" + export * + module * { export * } +} diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/AppController.h b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/AppController.h similarity index 83% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/AppController.h rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/AppController.h index 6025f6a5..9c54dd88 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/AppController.h +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/AppController.h @@ -15,10 +15,12 @@ @interface AppController : NSObject { IBOutlet NSBox *mEditHost; ScintillaView* mEditor; + ScintillaView* sciExtra; // For testing Scintilla tear-down } - (void) awakeFromNib; - (void) setupEditor; - (IBAction) searchText: (id) sender; +- (IBAction) addRemoveExtra: (id) sender; @end diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/AppController.mm b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/AppController.mm similarity index 94% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/AppController.mm rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/AppController.mm index 44cd6e97..7eeeea6e 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/AppController.mm +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/AppController.mm @@ -72,20 +72,30 @@ const char user_keywords[] = // Definition of own keywords, not used by MySQL. [mEditor setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; // Let's load some text for the editor, as initial content. - NSError* error = nil; - - NSString* path = [[NSBundle mainBundle] pathForResource: @"TestData" - ofType: @"sql" inDirectory: nil]; - - NSString* sql = [NSString stringWithContentsOfFile: path - encoding: NSUTF8StringEncoding - error: &error]; - if (error && [[error domain] isEqual: NSCocoaErrorDomain]) - NSLog(@"%@", error); - + NSString *sql = [self exampleText]; + [mEditor setString: sql]; [self setupEditor]; + + sciExtra = nil; +} + +- (NSString *) exampleText +{ + NSError* error = nil; + + NSString* path = [[NSBundle mainBundle] pathForResource: @"TestData" + ofType: @"sql" inDirectory: nil]; + + NSString *sql = [NSString stringWithContentsOfFile: path + encoding: NSUTF8StringEncoding + error: &error]; + + if (error && [[error domain] isEqual: NSCocoaErrorDomain]) + NSLog(@"%@", error); + + return sql; } //-------------------------------------------------------------------------------------------------- @@ -99,9 +109,6 @@ const char user_keywords[] = // Definition of own keywords, not used by MySQL. [mEditor setGeneralProperty: SCI_SETLEXER parameter: SCLEX_MYSQL value: 0]; // alternatively: [mEditor setEditorProperty: SCI_SETLEXERLANGUAGE parameter: nil value: (sptr_t) "mysql"]; - // Number of styles we use with this lexer. - [mEditor setGeneralProperty: SCI_SETSTYLEBITS value: [mEditor getGeneralProperty: SCI_GETSTYLEBITSNEEDED]]; - // Keywords to highlight. Indices are: // 0 - Major keywords (reserved keywords) // 1 - Normal keywords (everything not reserved but integral part of the language) @@ -271,6 +278,26 @@ static const char * box_xpm[] = { [self showAutocompletion]; } +- (IBAction) addRemoveExtra: (id) sender +{ + if (sciExtra) { + [sciExtra removeFromSuperview]; + sciExtra = nil; + } else { + NSRect newFrame = mEditHost.frame; + newFrame.origin.x += newFrame.size.width + 5; + newFrame.origin.y += 46; + newFrame.size.width = 96; + newFrame.size.height -= 60; + + sciExtra = [[[ScintillaView alloc] initWithFrame: newFrame] autorelease]; + [[[mEditHost window]contentView] addSubview: sciExtra]; + [sciExtra setGeneralProperty: SCI_SETWRAPMODE parameter: SC_WRAP_WORD value: 1]; + NSString *sql = [self exampleText]; + [sciExtra setString: sql]; + } +} + -(IBAction) setFontQuality: (id) sender { [ScintillaView directCall:mEditor message:SCI_SETFONTQUALITY wParam:[sender tag] lParam:0]; diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/English.lproj/InfoPlist.strings b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/English.lproj/InfoPlist.strings similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/English.lproj/InfoPlist.strings rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/English.lproj/InfoPlist.strings diff --git a/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/English.lproj/MainMenu.xib b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/English.lproj/MainMenu.xib new file mode 100644 index 00000000..d2292d8c --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/English.lproj/MainMenu.xib @@ -0,0 +1,609 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/Info.plist b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/Info.plist similarity index 93% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/Info.plist rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/Info.plist index 6364d76a..ef71339a 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/Info.plist +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile CFBundleIdentifier - com.sun.${PRODUCT_NAME:identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/Scintilla-Info.plist b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/Scintilla-Info.plist similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/Scintilla-Info.plist rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/Scintilla-Info.plist diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/ScintillaTest.xcodeproj/project.pbxproj b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/ScintillaTest.xcodeproj/project.pbxproj similarity index 97% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/ScintillaTest.xcodeproj/project.pbxproj rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/ScintillaTest.xcodeproj/project.pbxproj index 36c763a5..72ace79e 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/ScintillaTest.xcodeproj/project.pbxproj +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/ScintillaTest.xcodeproj/project.pbxproj @@ -191,7 +191,7 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastUpgradeCheck = 0830; }; buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ScintillaTest" */; compatibilityVersion = "Xcode 3.2"; @@ -202,6 +202,7 @@ Japanese, French, German, + Base, ); mainGroup = 29B97314FDCFA39411CA2CEA /* ScintillaTest */; projectDirPath = ""; @@ -295,13 +296,13 @@ GCC_PREFIX_HEADER = ScintillaTest_Prefix.pch; GCC_PREPROCESSOR_DEFINITIONS = ( SCI_LEXER, - SCI_NAMESPACE, ); HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = ""; + PRODUCT_BUNDLE_IDENTIFIER = "com.sun.${PRODUCT_NAME:identifier}"; PRODUCT_NAME = ScintillaTest; SDKROOT = macosx; USER_HEADER_SEARCH_PATHS = ""; @@ -320,13 +321,13 @@ GCC_PREFIX_HEADER = ScintillaTest_Prefix.pch; GCC_PREPROCESSOR_DEFINITIONS = ( SCI_LEXER, - SCI_NAMESPACE, ); HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; LIBRARY_SEARCH_PATHS = "$(inherited)"; OTHER_LDFLAGS = ""; + PRODUCT_BUNDLE_IDENTIFIER = "com.sun.${PRODUCT_NAME:identifier}"; PRODUCT_NAME = ScintillaTest; SDKROOT = macosx; USER_HEADER_SEARCH_PATHS = ""; @@ -336,14 +337,18 @@ C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = c99; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -363,11 +368,14 @@ C01FCF5008A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; ENABLE_STRICT_OBJC_MSGSEND = YES; diff --git a/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/ScintillaTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/ScintillaTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..b3258829 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/ScintillaTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/ScintillaTest_Prefix.pch b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/ScintillaTest_Prefix.pch similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/ScintillaTest_Prefix.pch rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/ScintillaTest_Prefix.pch diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/TestData.sql b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/TestData.sql similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/TestData.sql rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/TestData.sql diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/main.m b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/main.m similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/main.m rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaTest/main.m diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaView.h b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaView.h similarity index 78% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaView.h rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaView.h index ec2c8ee1..8c4cdfe2 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaView.h +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaView.h @@ -23,7 +23,6 @@ #define WM_COMMAND 1001 #define WM_NOTIFY 1002 -namespace Scintilla { /** * On the Mac, there is no WM_COMMAND or WM_NOTIFY message that can be sent * back to the parent. Therefore, there must be a callback handler that acts @@ -37,32 +36,16 @@ namespace Scintilla { */ typedef void(*SciNotifyFunc) (intptr_t windowid, unsigned int iMessage, uintptr_t wParam, uintptr_t lParam); -class ScintillaCocoa; -} - -@class ScintillaView; - extern NSString *const SCIUpdateUINotification; @protocol ScintillaNotificationProtocol -- (void)notification: (Scintilla::SCNotification*)notification; +- (void)notification: (SCNotification*)notification; @end /** * SCIMarginView draws line numbers and other margins next to the text view. */ -@interface SCIMarginView : NSRulerView -{ -@private - int marginWidth; - ScintillaView *owner; - NSMutableArray *currentCursors; -} - -@property (assign) int marginWidth; -@property (assign) ScintillaView *owner; - -- (id)initWithScrollView:(NSScrollView *)aScrollView; +@interface SCIMarginView : NSRulerView; @end @@ -74,49 +57,20 @@ extern NSString *const SCIUpdateUINotification; NSTextInputClient, NSUserInterfaceValidations, NSDraggingSource, - NSDraggingDestination> -{ -@private - ScintillaView* mOwner; - NSCursor* mCurrentCursor; - NSTrackingArea *trackingArea; + NSDraggingDestination, + NSAccessibilityStaticText>; - // Set when we are in composition mode and partial input is displayed. - NSRange mMarkedTextRange; -} - -@property (nonatomic, assign) ScintillaView* owner; - -- (void) setCursor: (int) cursor; - -- (BOOL) canUndo; -- (BOOL) canRedo; +- (void) setCursor: (int) cursor; // Needed by ScintillaCocoa @end -@interface ScintillaView : NSView -{ -@private - // The back end is kind of a controller and model in one. - // It uses the content view for display. - Scintilla::ScintillaCocoa* mBackend; +/** + * ScintillaView is the class instantiated by client code. + * It contains an NSScrollView which contains a SCIMarginView and a SCIContentView. + * It is responsible for providing an API and communicating to a delegate. + */ +@interface ScintillaView : NSView ; - // This is the actual content to which the backend renders itself. - SCIContentView* mContent; - - NSScrollView *scrollView; - SCIMarginView *marginView; - - CGFloat zoomDelta; - - // Area to display additional controls (e.g. zoom info, caret position, status info). - NSView * mInfoBar; - BOOL mInfoBarAtTop; - - id mDelegate; -} - -@property (nonatomic, readonly) Scintilla::ScintillaCocoa* backend; @property (nonatomic, assign) id delegate; @property (nonatomic, readonly) NSScrollView *scrollView; @@ -127,7 +81,9 @@ extern NSString *const SCIUpdateUINotification; - (void) setCallback: (id ) callback; - (void) suspendDrawing: (BOOL) suspend; -- (void) notification: (Scintilla::SCNotification*) notification; +- (void) notification: (SCNotification*) notification; + +- (void) updateIndicatorIME; // Scroller handling - (void) setMarginWidth: (int) width; @@ -141,6 +97,7 @@ extern NSString *const SCIUpdateUINotification; - (void) setEditable: (BOOL) editable; - (BOOL) isEditable; - (NSRange) selectedRange; +- (NSRange) selectedRangePositions; - (NSString*) selectedString; @@ -177,7 +134,7 @@ extern NSString *const SCIUpdateUINotification; - (NSString*) getLexerProperty: (NSString*) name; // The delegate property should be used instead of registerNotifyCallback which is deprecated. -- (void) registerNotifyCallback: (intptr_t) windowid value: (Scintilla::SciNotifyFunc) callback __attribute__((deprecated)); +- (void) registerNotifyCallback: (intptr_t) windowid value: (SciNotifyFunc) callback __attribute__((deprecated)); - (void) setInfoBar: (NSView *) aView top: (BOOL) top; - (void) setStatusText: (NSString*) text; diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaView.mm b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaView.mm similarity index 79% rename from dep/scintilla/scintilla-3.6.0/cocoa/ScintillaView.mm rename to dep/scintilla/scintilla-3.10.6/cocoa/ScintillaView.mm index da16899e..224aac06 100644 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaView.mm +++ b/dep/scintilla/scintilla-3.10.6/cocoa/ScintillaView.mm @@ -9,12 +9,22 @@ * This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt). */ +#include + +#include + #import "Platform.h" #import "ScintillaView.h" #import "ScintillaCocoa.h" using namespace Scintilla; +// Add backend property to ScintillaView as a private category. +// Specified here as backend accessed by SCIMarginView and SCIContentView. +@interface ScintillaView () +@property (nonatomic, readonly) Scintilla::ScintillaCocoa* backend; +@end + // Two additional cursors we need, which aren't provided by Cocoa. static NSCursor* reverseArrowCursor; static NSCursor* waitCursor; @@ -46,8 +56,17 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) } } +// Add marginWidth and owner properties as a private category. +@interface SCIMarginView () +@property (assign) int marginWidth; +@property (nonatomic, assign) ScintillaView* owner; +@end -@implementation SCIMarginView +@implementation SCIMarginView { + int marginWidth; + ScintillaView *owner; + NSMutableArray *currentCursors; +} @synthesize marginWidth, owner; @@ -64,6 +83,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) [currentCursors addObject: [reverseArrowCursor retain]]; } [self setClientView:[aScrollView documentView]]; + if ([self respondsToSelector: @selector(setAccessibilityLabel:)]) + self.accessibilityLabel = @"Scintilla Margin"; } return self; } @@ -100,6 +121,21 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) } } +/** + * Called by the framework if it wants to show a context menu for the margin. + */ +- (NSMenu*) menuForEvent: (NSEvent*) theEvent +{ + NSMenu *menu = [owner menuForEvent: theEvent]; + if (menu) { + return menu; + } else if (owner.backend->ShouldDisplayPopupOnMargin()) { + return owner.backend->CreateContextMenu(theEvent); + } else { + return nil; + } +} + - (void) mouseDown: (NSEvent *) theEvent { NSClipView *textView = [[self scrollView] contentView]; @@ -107,6 +143,13 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) owner.backend->MouseDown(theEvent); } +- (void) rightMouseDown: (NSEvent *) theEvent +{ + [NSMenu popUpContextMenu:[self menuForEvent: theEvent] withEvent:theEvent forView:self]; + + owner.backend->RightMouseDown(theEvent); +} + - (void) mouseDragged: (NSEvent *) theEvent { owner.backend->MouseMove(theEvent); @@ -122,6 +165,12 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) owner.backend->MouseUp(theEvent); } +// Not a simple button so return failure +- (BOOL)accessibilityPerformPress +{ + return NO; +} + /** * This method is called to give us the opportunity to define our mouse sensitive rectangle. */ @@ -148,7 +197,19 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) @end -@implementation SCIContentView +// Add owner property as a private category. +@interface SCIContentView () +@property (nonatomic, assign) ScintillaView* owner; +@end + +@implementation SCIContentView { + ScintillaView* mOwner; + NSCursor* mCurrentCursor; + NSTrackingArea *trackingArea; + + // Set when we are in composition mode and partial input is displayed. + NSRange mMarkedTextRange; +} @synthesize owner = mOwner; @@ -167,6 +228,17 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) [self registerForDraggedTypes: [NSArray arrayWithObjects: NSStringPboardType, ScintillaRecPboardType, NSFilenamesPboardType, nil]]; + + // Set up accessibility in the text role + if ([self respondsToSelector: @selector(setAccessibilityElement:)]) + { + self.accessibilityElement = TRUE; + self.accessibilityEnabled = TRUE; + self.accessibilityLabel = NSLocalizedString(@"Scintilla", nil); // No real localization + self.accessibilityRoleDescription = @"source code editor"; + self.accessibilityRole = NSAccessibilityTextAreaRole; + self.accessibilityIdentifier = @"Scintilla"; + } } return self; @@ -180,8 +252,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) updateTrackingAreas { if (trackingArea) + { [self removeTrackingArea:trackingArea]; - + [trackingArea release]; + } + int opts = (NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved); trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] options:opts @@ -199,7 +274,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) setFrame: (NSRect) frame { [super setFrame: frame]; - + mOwner.backend->Resize(); } @@ -230,7 +305,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) [super resetCursorRects]; // We only have one cursor rect: our bounds. - [self addCursorRect: [self bounds] cursor: mCurrentCursor]; + const NSRect visibleBounds = mOwner.backend->GetBounds(); + [self addCursorRect: visibleBounds cursor: mCurrentCursor]; [mCurrentCursor setOnMouseEntered: YES]; } @@ -241,6 +317,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (void) viewWillDraw { + if (!mOwner) { + [super viewWillDraw]; + return; + } + const NSRect *rects; NSInteger nRects = 0; [self getRectsBeingDrawn:&rects count:&nRects]; @@ -261,7 +342,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (void) prepareContentInRect: (NSRect) rect { - mOwner.backend->WillDraw(rect); + if (mOwner) + mOwner.backend->WillDraw(rect); #if MAC_OS_X_VERSION_MAX_ALLOWED > 1080 [super prepareContentInRect: rect]; #endif @@ -332,10 +414,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (NSMenu*) menuForEvent: (NSEvent*) theEvent { - if (![mOwner respondsToSelector: @selector(menuForEvent:)]) + NSMenu *menu = [mOwner menuForEvent: theEvent]; + if (menu) { + return menu; + } else if (mOwner.backend->ShouldDisplayPopupOnText()) { return mOwner.backend->CreateContextMenu(theEvent); - else - return [mOwner menuForEvent: theEvent]; + } else { + return nil; + } } //-------------------------------------------------------------------------------------------------- @@ -344,6 +430,10 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange { + const NSInteger lengthCharacters = self.accessibilityNumberOfCharacters; + if (aRange.location > lengthCharacters) { + return nil; + } const NSRange posRange = mOwner.backend->PositionsFromCharacters(aRange); // The backend validated aRange and may have removed characters beyond the end of the document. const NSRange charRange = mOwner.backend->CharactersFromPositions(posRange); @@ -355,11 +445,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) [mOwner message: SCI_SETTARGETRANGE wParam: posRange.location lParam: NSMaxRange(posRange)]; std::string text([mOwner message: SCI_TARGETASUTF8] + 1, 0); [mOwner message: SCI_TARGETASUTF8 wParam: 0 lParam: reinterpret_cast(&text[0])]; + text = FixInvalidUTF8(text); NSString *result = [NSString stringWithUTF8String: text.c_str()]; NSMutableAttributedString *asResult = [[[NSMutableAttributedString alloc] initWithString:result] autorelease]; const NSRange rangeAS = NSMakeRange(0, [asResult length]); - const long style = [mOwner message: SCI_GETSTYLEAT wParam:posRange.location]; + // SCI_GETSTYLEAT reports a signed byte but want an unsigned to index into styles + const char styleByte = static_cast([mOwner message: SCI_GETSTYLEAT wParam:posRange.location]); + const long style = static_cast(styleByte); std::string fontName([mOwner message: SCI_STYLEGETFONT wParam:style lParam:0] + 1, 0); [mOwner message: SCI_STYLEGETFONT wParam:style lParam:(sptr_t)&fontName[0]]; const CGFloat fontSize = [mOwner message: SCI_STYLEGETSIZEFRACTIONAL wParam:style] / 100.0f; @@ -396,7 +489,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) doCommandBySelector: (SEL) selector { - if ([self respondsToSelector: @selector(selector)]) + if ([self respondsToSelector: selector]) [self performSelector: selector withObject: nil]; } @@ -404,6 +497,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (NSRect) firstRectForCharacterRange: (NSRange) aRange actualRange: (NSRangePointer) actualRange { +#pragma unused(actualRange) const NSRange posRange = mOwner.backend->PositionsFromCharacters(aRange); NSRect rect; @@ -483,9 +577,21 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (NSRange) selectedRange { - const long positionBegin = [mOwner message: SCI_GETSELECTIONSTART]; - const long positionEnd = [mOwner message: SCI_GETSELECTIONEND]; - NSRange posRangeSel = NSMakeRange(positionBegin, positionEnd-positionBegin); + const NSRange posRangeSel = [mOwner selectedRangePositions]; + if (posRangeSel.length == 0) + { + NSTextInputContext *tic = [NSTextInputContext currentInputContext]; + // Chinese input causes malloc crash when empty selection returned with actual + // position so return NSNotFound. + // If this is applied to European input, it stops the accented character + // chooser from appearing. + // May need to add more input source names. + if ([tic.selectedKeyboardInputSource + isEqualToString:@"com.apple.inputmethod.TCIM.Cangjie"]) + { + return NSMakeRange(NSNotFound, 0); + } + } return mOwner.backend->CharactersFromPositions(posRangeSel); } @@ -530,7 +636,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) // Must perform deletion before entering composition mode or else // both document and undo history will not contain the deleted text // leading to an inaccurate and unusable undo history. - + // Convert selection virtual space into real space mOwner.backend->ConvertSelectionVirtualSpace(); @@ -549,7 +655,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) } // Ensure only a single selection. mOwner.backend->SelectOnlyMainSelection(); - replacementRange = [self selectedRange]; + const NSRange posRangeSel = [mOwner selectedRangePositions]; + replacementRange = mOwner.backend->CharactersFromPositions(posRangeSel); } } @@ -561,11 +668,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { // Switching into composition. mOwner.backend->CompositionStart(); - + NSRange posRangeCurrent = mOwner.backend->PositionsFromCharacters(NSMakeRange(replacementRange.location, 0)); // Note: Scintilla internally works almost always with bytes instead chars, so we need to take // this into account when determining selection ranges and such. - int lengthInserted = mOwner.backend->InsertText(newText); + ptrdiff_t lengthInserted = mOwner.backend->InsertText(newText); posRangeCurrent.length = lengthInserted; mMarkedTextRange = mOwner.backend->CharactersFromPositions(posRangeCurrent); // Mark the just inserted text. Keep the marked range for later reset. @@ -606,7 +713,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (NSArray*) validAttributesForMarkedText { - return nil; + return @[]; } // End of the NSTextInputClient protocol adoption. @@ -620,10 +727,13 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (void) keyDown: (NSEvent *) theEvent { + bool handled = false; if (mMarkedTextRange.length == 0) - mOwner.backend->KeyboardInput(theEvent); - NSArray* events = [NSArray arrayWithObject: theEvent]; - [self interpretKeyEvents: events]; + handled = mOwner.backend->KeyboardInput(theEvent); + if (!handled) { + NSArray* events = [NSArray arrayWithObject: theEvent]; + [self interpretKeyEvents: events]; + } } //-------------------------------------------------------------------------------------------------- @@ -671,21 +781,21 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) //-------------------------------------------------------------------------------------------------- /** - * Mouse wheel with command key magnifies text. - * Enabling this code causes visual garbage to appear when scrolling - * horizontally on OS X 10.9 with a retina display. - * Pinch gestures and key commands can be used for magnification. + * Implementing scrollWheel makes scrolling work better even if just + * calling super. + * Mouse wheel with command key may magnify text if enabled. + * Pinch gestures and key commands can also be used for magnification. */ -#ifdef SCROLL_WHEEL_MAGNIFICATION - (void) scrollWheel: (NSEvent *) theEvent { +#ifdef SCROLL_WHEEL_MAGNIFICATION if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) { mOwner.backend->MouseWheel(theEvent); - } else { - [super scrollWheel:theEvent]; + return; } -} #endif + [super scrollWheel:theEvent]; +} //-------------------------------------------------------------------------------------------------- @@ -694,6 +804,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (NSRect)adjustScroll:(NSRect)proposedVisibleRect { + if (!mOwner) + return proposedVisibleRect; NSRect rc = proposedVisibleRect; // Snap to lines NSRect contentRect = [self bounds]; @@ -703,6 +815,13 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) long lineHeight = mOwner.backend->WndProc(SCI_TEXTHEIGHT, 0, 0); rc.origin.y = roundf(static_cast(rc.origin.y) / lineHeight) * lineHeight; } + // Snap to whole points - on retina displays this avoids visual debris + // when scrolling horizontally. + if ((rc.origin.x > 0) && (NSMaxX(rc) < contentRect.size.width)) { + // Only snap for positions inside the document - allow outside + // for overshoot. + rc.origin.x = roundf(static_cast(rc.origin.x)); + } return rc; } @@ -737,11 +856,12 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (NSDragOperation)draggingSession: (NSDraggingSession *) session sourceOperationMaskForDraggingContext: (NSDraggingContext) context { +#pragma unused(session) switch(context) { case NSDraggingContextOutsideApplication: return NSDragOperationCopy | NSDragOperationMove | NSDragOperationDelete; - + case NSDraggingContextWithinApplication: default: return NSDragOperationCopy | NSDragOperationMove | NSDragOperationDelete; @@ -751,12 +871,14 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context - (void)draggingSession:(NSDraggingSession *)session movedToPoint:(NSPoint)screenPoint { +#pragma unused(session, screenPoint) } - (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation { +#pragma unused(session, screenPoint) if (operation == NSDragOperationDelete) { mOwner.backend->WndProc(SCI_CLEAR, 0, 0); @@ -919,11 +1041,228 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context return mOwner.backend->WndProc(SCI_GETREADONLY, 0, 0) == 0; } +#pragma mark - NSAccessibility + +//-------------------------------------------------------------------------------------------------- + +// Adoption of NSAccessibility protocol. +// NSAccessibility wants to pass ranges in UTF-16 code units, not bytes (like Scintilla) +// or characters. +// Needs more testing with non-ASCII and non-BMP text. +// Needs to take account of folding and wraping. + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : Text of the whole document as a string. + */ +- (id) accessibilityValue { + const sptr_t length = [mOwner message: SCI_GETLENGTH]; + return mOwner.backend->RangeTextAsString(NSMakeRange(0, length)); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : Line of the caret. + */ +- (NSInteger) accessibilityInsertionPointLineNumber { + const Sci::Position caret = [mOwner message: SCI_GETCURRENTPOS]; + const NSRange rangeCharactersCaret = mOwner.backend->CharactersFromPositions(NSMakeRange(caret, 0)); + return mOwner.backend->VisibleLineForIndex(rangeCharactersCaret.location); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : Not implemented and not called by VoiceOver. + */ +- (NSRange)accessibilityRangeForPosition:(NSPoint)point { + return NSMakeRange(0,0); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : Number of characters in the whole document. + */ +- (NSInteger) accessibilityNumberOfCharacters { + sptr_t length = [mOwner message: SCI_GETLENGTH]; + const NSRange posRange = mOwner.backend->CharactersFromPositions(NSMakeRange(length, 0)); + return posRange.location; +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : The selection text as a string. + */ +- (NSString *) accessibilitySelectedText { + const sptr_t positionBegin = [mOwner message: SCI_GETSELECTIONSTART]; + const sptr_t positionEnd = [mOwner message: SCI_GETSELECTIONEND]; + const NSRange posRangeSel = NSMakeRange(positionBegin, positionEnd-positionBegin); + return mOwner.backend->RangeTextAsString(posRangeSel); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : The character range of the main selection. + */ +- (NSRange) accessibilitySelectedTextRange { + const sptr_t positionBegin = [mOwner message: SCI_GETSELECTIONSTART]; + const sptr_t positionEnd = [mOwner message: SCI_GETSELECTIONEND]; + const NSRange posRangeSel = NSMakeRange(positionBegin, positionEnd-positionBegin); + return mOwner.backend->CharactersFromPositions(posRangeSel); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : The setter for accessibilitySelectedTextRange. + * This method is the only setter required for reasonable VoiceOver behaviour. + */ +- (void) setAccessibilitySelectedTextRange: (NSRange) range { + NSRange rangePositions = mOwner.backend->PositionsFromCharacters(range); + [mOwner message: SCI_SETSELECTION wParam: rangePositions.location lParam:NSMaxRange(rangePositions)]; +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : Range of the glyph at a character index. + * Currently doesn't try to handle composite characters. + */ +- (NSRange) accessibilityRangeForIndex: (NSInteger)index { + sptr_t length = [mOwner message: SCI_GETLENGTH]; + const NSRange rangeLength = mOwner.backend->CharactersFromPositions(NSMakeRange(length, 0)); + NSRange rangePositions = NSMakeRange(length, 0); + if (index < rangeLength.location) { + rangePositions = mOwner.backend->PositionsFromCharacters(NSMakeRange(index, 1)); + } + return mOwner.backend->CharactersFromPositions(rangePositions); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : All the text ranges. + * Currently only returns the main selection. + */ +- (NSArray*) accessibilitySelectedTextRanges { + const sptr_t positionBegin = [mOwner message: SCI_GETSELECTIONSTART]; + const sptr_t positionEnd = [mOwner message: SCI_GETSELECTIONEND]; + const NSRange posRangeSel = NSMakeRange(positionBegin, positionEnd-positionBegin); + NSRange rangeCharacters = mOwner.backend->CharactersFromPositions(posRangeSel); + NSValue *valueRange = [NSValue valueWithRange:(NSRange)rangeCharacters]; + return @[valueRange]; +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : Character range currently visible. + */ +- (NSRange) accessibilityVisibleCharacterRange { + const sptr_t lineTopVisible = [mOwner message: SCI_GETFIRSTVISIBLELINE]; + const sptr_t lineTop = [mOwner message:SCI_DOCLINEFROMVISIBLE wParam:lineTopVisible]; + const sptr_t lineEndVisible = lineTopVisible + [mOwner message: SCI_LINESONSCREEN] - 1; + const sptr_t lineEnd = [mOwner message:SCI_DOCLINEFROMVISIBLE wParam:lineEndVisible]; + const sptr_t posStartView = [mOwner message: SCI_POSITIONFROMLINE wParam: lineTop]; + const sptr_t posEndView = [mOwner message: SCI_GETLINEENDPOSITION wParam: lineEnd]; + const NSRange posRangeSel = NSMakeRange(posStartView, posEndView-posStartView); + return mOwner.backend->CharactersFromPositions(posRangeSel); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : Character range of a line. + */ +- (NSRange)accessibilityRangeForLine:(NSInteger)line { + return mOwner.backend->RangeForVisibleLine(line); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : Line number of a text position in characters. + */ +- (NSInteger)accessibilityLineForIndex:(NSInteger)index { + return mOwner.backend->VisibleLineForIndex(index); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : A rectangle that covers a range which will be shown as the + * VoiceOver cursor. + * Producing a nice rectangle is a little tricky particularly when including new + * lines. Needs to improve the case where parts of two lines are included. + */ +- (NSRect)accessibilityFrameForRange:(NSRange)range { + const NSRect rectInView = mOwner.backend->FrameForRange(range); + const NSRect rectInWindow = [[[self superview] superview] convertRect:rectInView toView:nil]; + return [self.window convertRectToScreen:rectInWindow]; +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : A range of text as a string. + */ +- (NSString *) accessibilityStringForRange:(NSRange)range { + const NSRange posRange = mOwner.backend->PositionsFromCharacters(range); + return mOwner.backend->RangeTextAsString(posRange); +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : A range of text as an attributed string. + * Currently no attributes are set. + */ +- (NSAttributedString *) accessibilityAttributedStringForRange:(NSRange)range { + const NSRange posRange = mOwner.backend->PositionsFromCharacters(range); + NSString *result = mOwner.backend->RangeTextAsString(posRange); + return [[[NSMutableAttributedString alloc] initWithString:result] autorelease]; +} + +//-------------------------------------------------------------------------------------------------- + +/** + * NSAccessibility : Show the context menu at the caret. + */ +- (BOOL)accessibilityPerformShowMenu { + const sptr_t caret = [mOwner message: SCI_GETCURRENTPOS]; + NSRect rect; + rect.origin.x = [mOwner message: SCI_POINTXFROMPOSITION wParam: 0 lParam: caret]; + rect.origin.y = [mOwner message: SCI_POINTYFROMPOSITION wParam: 0 lParam: caret]; + rect.origin.y += [mOwner message: SCI_TEXTHEIGHT wParam: 0 lParam: 0]; + rect.size.width = 1.0; + rect.size.height = 1.0; + NSRect rectInWindow = [[[self superview] superview] convertRect:rect toView:nil]; + NSPoint pt = rectInWindow.origin; + NSEvent *event = [NSEvent mouseEventWithType: NSRightMouseDown + location: pt + modifierFlags: 0 + timestamp: 0 + windowNumber: [[self window] windowNumber] + context: nil + eventNumber: 0 + clickCount: 1 + pressure: 0.0]; + NSMenu *menu = mOwner.backend->CreateContextMenu(event); + [NSMenu popUpContextMenu:menu withEvent:event forView:self]; + return YES; +} + //-------------------------------------------------------------------------------------------------- - (void) dealloc { [mCurrentCursor release]; + [trackingArea release]; [super dealloc]; } @@ -931,7 +1270,25 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context //-------------------------------------------------------------------------------------------------- -@implementation ScintillaView +@implementation ScintillaView { + // The back end is kind of a controller and model in one. + // It uses the content view for display. + Scintilla::ScintillaCocoa* mBackend; + + // This is the actual content to which the backend renders itself. + SCIContentView* mContent; + + NSScrollView *scrollView; + SCIMarginView *marginView; + + CGFloat zoomDelta; + + // Area to display additional controls (e.g. zoom info, caret position, status info). + NSView * mInfoBar; + BOOL mInfoBarAtTop; + + id mDelegate; +} @synthesize backend = mBackend; @synthesize delegate = mDelegate; @@ -960,7 +1317,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context path = [bundle pathForResource: @"mac_cursor_flipped" ofType: @"tiff" inDirectory: nil]; image = [[[NSImage alloc] initWithContentsOfFile: path] autorelease]; - reverseArrowCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(12, 2)]; + reverseArrowCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(15, 2)]; } } @@ -985,7 +1342,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 zoomDelta += event.magnification * 10.0; - if (fabs(zoomDelta)>=1.0) { + if (std::abs(zoomDelta)>=1.0) { long zoomFactor = static_cast([self getGeneralProperty: SCI_GETZOOM] + zoomDelta); [self setGeneralProperty: SCI_SETZOOM parameter: zoomFactor value:0]; zoomDelta = 0.0; @@ -1072,7 +1429,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context * A delegate can be set to receive all notifications. If set no handling takes place here, except * for action pertaining to internal stuff (like the info bar). */ -- (void) notification: (Scintilla::SCNotification*)scn +- (void) notification: (SCNotification*)scn { // Parent notification. Details are passed as SCNotification structure. @@ -1135,6 +1492,21 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context //-------------------------------------------------------------------------------------------------- +/** + * Setup a special indicator used in the editor to provide visual feedback for + * input composition, depending on language, keyboard etc. + */ +- (void) updateIndicatorIME +{ + [self setColorProperty: SCI_INDICSETFORE parameter: INDIC_IME fromHTML: @"#FF0000"]; + const bool drawInBackground = [self message: SCI_GETPHASESDRAW] != 0; + [self setGeneralProperty: SCI_INDICSETUNDER parameter: INDIC_IME value: drawInBackground]; + [self setGeneralProperty: SCI_INDICSETSTYLE parameter: INDIC_IME value: INDIC_PLAIN]; + [self setGeneralProperty: SCI_INDICSETALPHA parameter: INDIC_IME value: 100]; +} + +//-------------------------------------------------------------------------------------------------- + /** * Initialization of the view. Used to setup a few other things we need. */ @@ -1168,18 +1540,13 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context [scrollView setHasVerticalRuler:YES]; [scrollView setRulersVisible:YES]; - mBackend = new ScintillaCocoa(mContent, marginView); + mBackend = new ScintillaCocoa(self, mContent, marginView); // Establish a connection from the back end to this container so we can handle situations // which require our attention. mBackend->SetDelegate(self); - // Setup a special indicator used in the editor to provide visual feedback for - // input composition, depending on language, keyboard etc. - [self setColorProperty: SCI_INDICSETFORE parameter: INDIC_IME fromHTML: @"#FF0000"]; - [self setGeneralProperty: SCI_INDICSETUNDER parameter: INDIC_IME value: 1]; - [self setGeneralProperty: SCI_INDICSETSTYLE parameter: INDIC_IME value: INDIC_PLAIN]; - [self setGeneralProperty: SCI_INDICSETALPHA parameter: INDIC_IME value: 100]; + [self updateIndicatorIME]; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self @@ -1196,7 +1563,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context selector:@selector(windowWillMove:) name:NSWindowWillMoveNotification object:[self window]]; - + [[scrollView contentView] setPostsBoundsChangedNotifications:YES]; [center addObserver:self selector:@selector(scrollerAction:) @@ -1211,7 +1578,12 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + mBackend->Finalise(); delete mBackend; + mBackend = NULL; + mContent.owner = nil; + [marginView setClientView:nil]; + [scrollView removeFromSuperview]; [marginView release]; [super dealloc]; } @@ -1310,6 +1682,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context */ - (void) scrollerAction: (id) sender { +#pragma unused(sender) mBackend->UpdateForScroll(); } @@ -1695,7 +2068,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context /** * Sets the notification callback */ -- (void) registerNotifyCallback: (intptr_t) windowid value: (Scintilla::SciNotifyFunc) callback +- (void) registerNotifyCallback: (intptr_t) windowid value: (SciNotifyFunc) callback { mBackend->RegisterNotifyCallback(windowid, callback); } @@ -1744,6 +2117,21 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context return [mContent selectedRange]; } +//-------------------------------------------------------------------------------------------------- + +/** + * Return the main selection as an NSRange of positions (not characters). + * Unlike selectedRange, this can return empty ranges inside the document. + */ + +- (NSRange) selectedRangePositions +{ + const sptr_t positionBegin = [self message: SCI_GETSELECTIONSTART]; + const sptr_t positionEnd = [self message: SCI_GETSELECTIONEND]; + return NSMakeRange(positionBegin, positionEnd-positionBegin); +} + + //-------------------------------------------------------------------------------------------------- - (void)insertText: (id) aString diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/checkbuildosx.sh b/dep/scintilla/scintilla-3.10.6/cocoa/checkbuildosx.sh similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/checkbuildosx.sh rename to dep/scintilla/scintilla-3.10.6/cocoa/checkbuildosx.sh diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/res/info_bar_bg.png b/dep/scintilla/scintilla-3.10.6/cocoa/res/info_bar_bg.png similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/res/info_bar_bg.png rename to dep/scintilla/scintilla-3.10.6/cocoa/res/info_bar_bg.png diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/res/info_bar_bg@2x.png b/dep/scintilla/scintilla-3.10.6/cocoa/res/info_bar_bg@2x.png similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/res/info_bar_bg@2x.png rename to dep/scintilla/scintilla-3.10.6/cocoa/res/info_bar_bg@2x.png diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/res/mac_cursor_busy.png b/dep/scintilla/scintilla-3.10.6/cocoa/res/mac_cursor_busy.png similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/res/mac_cursor_busy.png rename to dep/scintilla/scintilla-3.10.6/cocoa/res/mac_cursor_busy.png diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/res/mac_cursor_busy@2x.png b/dep/scintilla/scintilla-3.10.6/cocoa/res/mac_cursor_busy@2x.png similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/res/mac_cursor_busy@2x.png rename to dep/scintilla/scintilla-3.10.6/cocoa/res/mac_cursor_busy@2x.png diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/res/mac_cursor_flipped.png b/dep/scintilla/scintilla-3.10.6/cocoa/res/mac_cursor_flipped.png similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/res/mac_cursor_flipped.png rename to dep/scintilla/scintilla-3.10.6/cocoa/res/mac_cursor_flipped.png diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/res/mac_cursor_flipped@2x.png b/dep/scintilla/scintilla-3.10.6/cocoa/res/mac_cursor_flipped@2x.png similarity index 100% rename from dep/scintilla/scintilla-3.6.0/cocoa/res/mac_cursor_flipped@2x.png rename to dep/scintilla/scintilla-3.10.6/cocoa/res/mac_cursor_flipped@2x.png diff --git a/dep/scintilla/scintilla-3.10.6/cppcheck.suppress b/dep/scintilla/scintilla-3.10.6/cppcheck.suppress new file mode 100644 index 00000000..34a8ccb7 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/cppcheck.suppress @@ -0,0 +1,81 @@ +// File to suppress cppcheck warnings for files that will not be fixed. +// Does not suppress warnings where an additional occurrence of the warning may be of interest. + +// Coding style is to use assignments in constructor when there are many +// members to initialize or the initialization is complex or has comments. +useInitializationList + +// These may be interesting but its not clear without examining each instance closely +// Would have to ensure that any_of/all_of has same early/late exits as current code and +// produces same result on empty collections +useStlAlgorithm + +// The two sections are for different purposes: C1 control set and UTF-8 invalid bytes +duplicateCondition:scintilla/src/Editor.cxx + +// Some non-explicit constructors are used for conversions or are private to lexers +noExplicitConstructor + +// Document is checking for a change by called methods and cppcheck isn't considering escape +knownConditionTrueFalse:scintilla/src/Document.cxx + +// ScintillaDocument is providing an API and there are no consumers of the API inside Scintilla +unusedFunction:scintilla/qt/ScintillaEdit/ScintillaDocument.cpp + +// moc_ files are not understood by cppcheck +noValidConfiguration + +// The performance cost of by-value passing is often small and using a reference decreases +// code legibility. +passedByValue + +// Suppress most lexer warnings since the lexers are maintained by others +redundantCondition:scintilla/lexers/LexA68k.cxx +shadowVar:scintilla/lexers/LexAU3.cxx +unreadVariable:scintilla/lexers/LexBaan.cxx +uninitMemberVar:scintilla/lexers/LexBash.cxx +variableScope:scintilla/lexers/LexBash.cxx +variableScope:scintilla/lexers/LexBatch.cxx +variableScope:scintilla/lexers/LexCmake.cxx +variableScope:scintilla/lexers/LexCSS.cxx +variableScope:scintilla/lexers/LexErlang.cxx +variableScope:scintilla/lexers/LexGui4Cli.cxx +variableScope:scintilla/lexers/LexInno.cxx +variableScope:scintilla/lexers/LexLaTeX.cxx +unreadVariable:scintilla/lexers/LexMatlab.cxx +variableScope:scintilla/lexers/LexMetapost.cxx +variableScope:scintilla/lexers/LexModula.cxx +variableScope:scintilla/lexers/LexMSSQL.cxx +variableScope:scintilla/lexers/LexNimrod.cxx +variableScope:scintilla/lexers/LexNsis.cxx +variableScope:scintilla/lexers/LexOpal.cxx +variableScope:scintilla/lexers/LexPB.cxx +shadowVar:scintilla/lexers/LexPowerPro.cxx +variableScope:scintilla/lexers/LexProgress.cxx +redundantAssignment:scintilla/lexers/LexRegistry.cxx +variableScope:scintilla/lexers/LexRuby.cxx +uninitMemberVar:scintilla/lexers/LexRuby.cxx +variableScope:scintilla/lexers/LexSpecman.cxx +unreadVariable:scintilla/lexers/LexSpice.cxx +clarifyCalculation:scintilla/lexers/LexTADS3.cxx +invalidscanf:scintilla/lexers/LexTCMD.cxx +knownConditionTrueFalse:scintilla/lexers/LexTCMD.cxx +variableScope:scintilla/lexers/LexTeX.cxx +knownConditionTrueFalse:scintilla/lexers/LexVerilog.cxx +constArgument:scintilla/lexers/LexVerilog.cxx +shadowVar:scintilla/lexers/LexVHDL.cxx +unreadVariable:scintilla/lexers/LexVHDL.cxx +variableScope:scintilla/lexers/LexVHDL.cxx +unreadVariable:scintilla/lexers/LexVisualProlog.cxx + +// bp.itBracket not actually redundant as needed by return statements +redundantAssignment:scintilla/lexers/LexCPP.cxx + +// safety initializations at start of GetCharacterExtents +redundantAssignment:scintilla/gtk/ScintillaGTKAccessible.cxx + +// Suppress everything in catch.hpp as won't be changing +*:scintilla/test/unit/catch.hpp +// For now, suppress all test source files as, since Catch 2, cppcheck shows many warnings showing +// it doesn't understand the REQUIRE macro +*:scintilla/test/unit/*.cxx diff --git a/dep/scintilla/scintilla-3.10.6/curses/Makefile b/dep/scintilla/scintilla-3.10.6/curses/Makefile new file mode 100644 index 00000000..d12e65e2 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/curses/Makefile @@ -0,0 +1,52 @@ +# Copyright 2012-2019 Mitchell mitchell.att.foicica.com. See License.txt. + +.SUFFIXES: .cxx .c .o .h .a + +AR = ar +CC = gcc +CXX = g++ +INCLUDEDIRS = -I ../include -I ../src -I ../lexlib +CFLAGS = -std=c99 -pedantic -Wall +CXXFLAGS = -std=c++11 -pedantic -DCURSES -DSCI_LEXER $(INCLUDEDIRS) -Wall +ifdef DEBUG + CXXFLAGS += -DDEBUG -g +else + CXXFLAGS += -DNDEBUG -Os +endif +CURSES_FLAGS = + +scintilla = ../bin/scintilla.a +sci = AutoComplete.o CallTip.o CaseConvert.o CaseFolder.o Catalogue.o \ + CellBuffer.o CharacterCategory.o CharClassify.o ContractionState.o \ + DBCS.o Decoration.o Document.o EditModel.o Editor.o EditView.o \ + ExternalLexer.o Indicator.o KeyMap.o LineMarker.o MarginView.o PerLine.o \ + PositionCache.o RESearch.o RunStyles.o ScintillaBase.o Selection.o \ + Style.o UniConversion.o UniqueString.o ViewStyle.o XPM.o \ + Accessor.o CharacterSet.o DefaultLexer.o LexerBase.o LexerModule.o \ + LexerNoExceptions.o LexerSimple.o PropSetSimple.o StyleContext.o \ + WordList.o +lexers = $(addsuffix .o,$(basename $(sort $(notdir $(wildcard ../lexers/Lex*.cxx))))) +ifdef LPEG_LEXER + CXXFLAGS += -DLPEG_LEXER -I ../lua/src + LUA_CFLAGS = -I ../lua/src -DLUA_USE_POSIX -DLUA_USE_DLOPEN + lua = lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o linit.o \ + llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o \ + ltable.o ltm.o lundump.o lvm.o lzio.o \ + lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o lmathlib.o \ + loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o \ + lpcap.o lpcode.o lpprint.o lptree.o lpvm.o +endif + +vpath %.h ../src ../include ../lexlib +vpath %.cxx ../src ../lexlib ../lexers + +all: $(scintilla) +$(sci) $(lexers) ScintillaCurses.o: %.o: %.cxx + $(CXX) $(CXXFLAGS) $(CURSES_FLAGS) -c $< +$(lua): %.o: ../lua/src/%.c + $(CC) $(CFLAGS) $(LUA_CFLAGS) -c $< +$(scintilla): $(sci) $(lexers) $(lua) ScintillaCurses.o + $(AR) rc $@ $^ + touch $@ +clean: + rm -f *.o $(scintilla) diff --git a/dep/scintilla/scintilla-3.10.6/curses/README.md b/dep/scintilla/scintilla-3.10.6/curses/README.md new file mode 100644 index 00000000..ecbc2a5d --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/curses/README.md @@ -0,0 +1,78 @@ +# Scintilla curses + +## Overview + +This is an implementation of [Scintilla][] for curses platforms including: + +* [ncurses][] +* [PDCurses][] +* X/Open Curses + +[Scintilla]: http://scintilla.org +[ncurses]: http://invisible-island.net/ncurses/ +[PDCurses]: http://pdcurses.sourceforge.net/ + +## Compiling + +Simply run `make` to build the usual `../bin/scintilla.a`. + +## Usage + +It is highly recommended to use Scintilla curses in a UTF-8-aware terminal with +a font that supports many UTF-8 characters ("DejaVu Sans Mono" is one of them) +because Scintilla curses makes use of UTF-8 characters when drawing wrap +symbols, some marker symbols, and call tip arrows. + +Note: `setlocale(LC_CTYPE, "")` must be called before initializing curses in +order to display UTF-8 characters properly in ncursesw. + +## Curses Compatibility + +Scintilla curses lacks some Scintilla features due to the terminal's +constraints: + +* Any settings with alpha values are not supported. +* Autocompletion lists cannot show images (pixmap surfaces are not supported). + Instead, they show the first character in the string passed to + [`SCI_REGISTERIMAGE`][]. +* Buffered and two-phase drawing is not supported. +* Caret settings like period, line style, and width are not supported + (terminals use block carets with their own period definitions). +* Code pages other than UTF-8 have not been tested and it is possible some + curses implementations do not support them. +* Drag and drop is not supported. +* Edge lines are not displayed properly (the line is drawn over by text lines). +* Extra ascent and descent for lines is not supported. +* Fold lines cannot be drawn above or below lines. +* Hotspot underlines are not drawn on mouse hover (`surface->FillRectangle()` is + not supported). +* Indicators other than `INDIC_ROUNDBOX` and `INDIC_STRAIGHTBOX` are not drawn + (`surface->LineTo()` and `surface->FillRectangle()` are not supported for + drawing indicator shapes and pixmap surfaces are not supported). Translucent + drawing and rounded corners are not supported either. +* Some complex marker types are not drawn properly or at all (pixmap surfaces + are not supported and `surface->LineTo()` is not supported for drawing some + marker shapes). +* Mouse cursor types are not supported. +* Up to 16 colors are supported, regardless of how many colors the terminal + supports. They are (in "0xBBGGRR" format): black (`0x000000`), red + (`0x000080`), green (`0x008000`), yellow (`0x008080`), blue (`0x800000`), + magenta (`0x800080`), cyan (`0x808000`), white (`0xC0C0C0`), light black + (`0x404040`), light red (`0x0000FF`), light green (`0x00FF00`), light yellow + (`0x00FFFF`), light blue (`0xFF0000`), light magenta (`0xFF00FF`), light cyan + (`0xFFFF00`), and light white (`0xFFFFFF`). Even if your terminal uses a + different color map, you must use these color values with Scintilla; + unrecognized colors are set to white by default. For some terminals, you may + need to set a lexer style's `bold` attribute in order to use the light color + variant. +* Some styles settings like font name, font size, and italic do not display + properly (terminals use one only font, size and variant). +* X selections (primary and secondary) are not integrated into the clipboard. +* Zoom is not supported (terminal font size is fixed). + +[`SCI_REGISTERIMAGE`]: http://scintilla.org/ScintillaDoc.html#SCI_REGISTERIMAGE + +## `jinx` + +`jinx` is an example of using Scintilla with curses. You can build it by going +into `jinx/` and running `make`. diff --git a/dep/scintilla/scintilla-3.10.6/curses/ScintillaCurses.cxx b/dep/scintilla/scintilla-3.10.6/curses/ScintillaCurses.cxx new file mode 100644 index 00000000..a39ccbec --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/curses/ScintillaCurses.cxx @@ -0,0 +1,1445 @@ +// Copyright 2012-2019 Mitchell mitchell.att.foicica.com. See License.txt. +// Scintilla implemented in a curses (terminal) environment. +// Contains platform facilities and a curses-specific subclass of ScintillaBase. +// Note: setlocale(LC_CTYPE, "") must be called before initializing curses in +// order to display UTF-8 characters properly in ncursesw. + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "ILoader.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "CharacterCategory.h" +#include "Position.h" +#include "UniqueString.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h" +#include "ContractionState.h" +#include "CellBuffer.h" +#include "CallTip.h" +#include "KeyMap.h" +#include "Indicator.h" +#include "LineMarker.h" +#include "Style.h" +#include "ViewStyle.h" +#include "CharClassify.h" +#include "Decoration.h" +#include "CaseFolder.h" +#include "Document.h" +#include "UniConversion.h" +#include "Selection.h" +#include "PositionCache.h" +#include "EditModel.h" +#include "MarginView.h" +#include "EditView.h" +#include "Editor.h" +#include "AutoComplete.h" +#include "ScintillaBase.h" +#include "ScintillaCurses.h" + +/** + * Returns the given Scintilla `WindowID` as a curses `WINDOW`. + * @param w A Scintilla `WindowID`. + * @return curses `WINDOW`. + */ +#define _WINDOW(w) reinterpret_cast(w) + +#if _WIN32 +#define wcwidth(_) 1 // TODO: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c +#endif + +using namespace Scintilla; + +// Font handling. + +/** + * Allocates a new Scintilla font for curses. + * Since terminals handle fonts on their own, the only use for Scintilla font + * objects is to indicate which attributes terminal characters have. This is + * done in `Font::Create()`. + * @see Font::Create + */ +Font::Font() noexcept : fid(0) {} +/** Deletes the font. Currently empty. */ +Font::~Font() {} +/** + * Sets terminal character attributes for a particular font. + * These attributes are a union of curses attributes and stored in the font's + * `fid`. + * The curses attributes are not constructed from various fields in *fp* since + * there is no `underline` parameter. Instead, you need to manually set the + * `weight` parameter to be the union of your desired attributes. + * Scintilla's lexers/LexLPeg.cxx has an example of this. + */ +void Font::Create(const FontParameters &fp) { + Release(); + attr_t attrs = 0; + if (fp.weight == SC_WEIGHT_BOLD) + attrs = A_BOLD; + else if (fp.weight != SC_WEIGHT_NORMAL && fp.weight != SC_WEIGHT_SEMIBOLD) + attrs = fp.weight; // font attributes are stored in fp.weight + fid = reinterpret_cast(attrs); +} +/** Releases a font's resources. */ +void Font::Release() { fid = 0; } + +// Color handling. + +static int COLOR_LBLACK = COLOR_BLACK + 8; +static int COLOR_LRED = COLOR_RED + 8; +static int COLOR_LGREEN = COLOR_GREEN + 8; +static int COLOR_LYELLOW = COLOR_YELLOW + 8; +static int COLOR_LBLUE = COLOR_BLUE + 8; +static int COLOR_LMAGENTA = COLOR_MAGENTA + 8; +static int COLOR_LCYAN = COLOR_CYAN + 8; +static int COLOR_LWHITE = COLOR_WHITE + 8; + +static bool initialized_colors = false; + +/** + * Initializes colors in curses if they have not already been initialized. + * Creates all possible color pairs using the `SCI_COLOR_PAIR()` macro. + * This is called automatically from `scintilla_new()`. + */ +static void init_colors() { + if (initialized_colors) return; + if (has_colors()) { + start_color(); + for (int back = 0; back < ((COLORS < 16) ? 8 : 16); back++) + for (int fore = 0; fore < ((COLORS < 16) ? 8 : 16); fore++) + init_pair(SCI_COLOR_PAIR(fore, back), fore, back); + if (COLORS < 16) { + // Do not distinguish between light and normal colors. + COLOR_LBLACK -= 8; + COLOR_LRED -= 8; + COLOR_LGREEN -= 8; + COLOR_LYELLOW -= 8; + COLOR_LBLUE -= 8; + COLOR_LMAGENTA -= 8; + COLOR_LCYAN -= 8; + COLOR_LWHITE -= 8; + } + } + initialized_colors = true; +} + +static ColourDesired BLACK(0, 0, 0); +static ColourDesired RED(0x80, 0, 0); +static ColourDesired GREEN(0, 0x80, 0); +static ColourDesired YELLOW(0x80, 0x80, 0); +static ColourDesired BLUE(0, 0, 0x80); +static ColourDesired MAGENTA(0x80, 0, 0x80); +static ColourDesired CYAN(0, 0x80, 0x80); +static ColourDesired WHITE(0xC0, 0xC0, 0xC0); +static ColourDesired LBLACK(0x40, 0x40, 0x40); +static ColourDesired LRED(0xFF, 0, 0); +static ColourDesired LGREEN(0, 0xFF, 0); +static ColourDesired LYELLOW(0xFF, 0xFF, 0); +static ColourDesired LBLUE(0, 0, 0xFF); +static ColourDesired LMAGENTA(0xFF, 0, 0xFF); +static ColourDesired LCYAN(0, 0xFF, 0xFF); +static ColourDesired LWHITE(0xFF, 0xFF, 0xFF); +static ColourDesired SCI_COLORS[] = { + BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, LBLACK, LRED, LGREEN, + LYELLOW, LBLUE, LMAGENTA, LCYAN, LWHITE +}; + +/** + * Returns a curses color for the given Scintilla color. + * Recognized colors are: black (0x000000), red (0x800000), green (0x008000), + * yellow (0x808000), blue (0x000080), magenta (0x800080), cyan (0x008080), + * white (0xc0c0c0), light black (0x404040), light red (0xff0000), light green + * (0x00ff00), light yellow (0xffff00), light blue (0x0000ff), light magenta + * (0xff00ff), light cyan (0x00ffff), and light white (0xffffff). If the color + * is not recognized, returns `COLOR_WHITE` by default. + * @param color Color to get a curses color for. + * @return curses color + */ +static int term_color(ColourDesired color) { + if (color == BLACK) return COLOR_BLACK; + else if (color == RED) return COLOR_RED; + else if (color == GREEN) return COLOR_GREEN; + else if (color == YELLOW) return COLOR_YELLOW; + else if (color == BLUE) return COLOR_BLUE; + else if (color == MAGENTA) return COLOR_MAGENTA; + else if (color == CYAN) return COLOR_CYAN; + else if (color == LBLACK) return COLOR_LBLACK; + else if (color == LRED) return COLOR_LRED; + else if (color == LGREEN) return COLOR_LGREEN; + else if (color == LYELLOW) return COLOR_LYELLOW; + else if (color == LBLUE) return COLOR_LBLUE; + else if (color == LMAGENTA) return COLOR_LMAGENTA; + else if (color == LCYAN) return COLOR_LCYAN; + else if (color == LWHITE) return COLOR_LWHITE; + else return COLOR_WHITE; +} + +/** + * Returns a curses color for the given curses color. + * This overloaded method only exists for the `term_color_pair()` macro. + */ +static int term_color(int color) { return color; } + +/** + * Returns a curses color pair from the given fore and back colors. + * @param f Foreground color, either a Scintilla color or curses color. + * @param b Background color, either a Scintilla color or curses color. + * @return curses color pair suitable for calling `COLOR_PAIR()` with. + */ +#define term_color_pair(f, b) SCI_COLOR_PAIR(term_color(f), term_color(b)) + +// Surface handling. + +/** + * Implementation of a Scintilla surface for curses. + * The surface is initialized with a curses `WINDOW` for drawing on. Since + * curses can only show text, many of Scintilla's pixel-based functions are + * not implemented. + */ +class SurfaceImpl : public Surface { + WINDOW *win; + PRectangle clip; + + /** + * Returns the number of columns used to display the first UTF-8 character in + * `s`, taking into account zero-width combining characters. + * @param s The string that contains the first UTF-8 character to display. + */ + int grapheme_width(const char *s) { + wchar_t wch; + if (mbtowc(&wch, s, MB_CUR_MAX) < 1) return 1; + int width = wcwidth(wch); + return width >= 0 ? width : 1; + } +public: + /** Allocates a new Scintilla surface for curses. */ + SurfaceImpl() : win(0) {} + /** Deletes the surface. */ + ~SurfaceImpl() { Release(); } + + /** + * Initializes/reinitializes the surface with a curses `WINDOW` for drawing + * on. + * @param wid Curses `WINDOW`. + */ + void Init(WindowID wid) { + Release(); + win = _WINDOW(wid); + } + /** Identical to `Init()` using the given curses `WINDOW`. */ + void Init(SurfaceID sid, WindowID wid) { Init(wid); } + /** Initializing the surface as a pixmap is not implemented. */ + void InitPixMap(int width, int height, Surface *surface_, WindowID wid) {} + + /** Releases the surface's resources. */ + void Release() { win = 0; } + /** + * Returns `true` since this method is only called for pixmap surfaces and + * those surfaces are not implemented. + */ + bool Initialised() { return true; } + /** + * Setting the surface's foreground color is not implemented because all uses + * in Scintilla involve special drawing that is not supported in curses. + */ + void PenColour(ColourDesired fore) {} + /** Unused; return value irrelevant. */ + int LogPixelsY() { return 1; } + /** Returns 1 since font height is always 1 in curses. */ + int DeviceHeightFont(int points) { return 1; } + /** + * Moving to a particular position is not implemented because all uses in + * Scintilla involve subsequent calls to `LineTo()`, which is also + * unimplemented. + */ + void MoveTo(int x_, int y_) {} + /** + * Drawing lines is not implemented because more often than not lines are + * being drawn for decoration (e.g. line markers, underlines, indicators, + * arrows, etc.). + */ + void LineTo(int x_, int y_) {} + /** + * Draws the character equivalent of shape outlined by the given polygon's + * points. + * Scintilla only calls this method for CallTip arrows. + * Line markers that Scintilla would normally draw as polygons are handled in + * `DrawLineMarker()`. + */ + void Polygon(Point *pts, size_t npts, ColourDesired fore, + ColourDesired back) { + wattr_set(win, 0, term_color_pair(back, COLOR_WHITE), NULL); // invert + if (pts[0].y < pts[npts - 1].y) // up arrow + mvwaddstr(win, pts[0].y, pts[npts - 1].x + 1, "â–²"); + else if (pts[0].y > pts[npts - 1].y) // down arrow + mvwaddstr(win, pts[0].y - 2, pts[npts - 1].x + 1, "â–¼"); + } + /** + * Scintilla will never call this method. + * Line markers that Scintilla would normally draw as rectangles are handled + * in `DrawLineMarker()`. + */ + void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) {} + /** + * Clears the given portion of the screen with the given background color. + * In some cases, it can be determined that whitespace is being drawn. If so, + * draw it appropriately instead of clearing the given portion of the screen. + */ + void FillRectangle(PRectangle rc, ColourDesired back) { + wattr_set(win, 0, term_color_pair(COLOR_WHITE, back), NULL); + chtype ch = ' '; + if (fabs(rc.left - (int)rc.left) > 0.1) { + // If rc.left is a fractional value (e.g. 4.5) then whitespace dots are + // being drawn. Draw them appropriately. + // TODO: set color to vs.whitespaceColours.fore and back. + wcolor_set(win, term_color_pair(COLOR_BLACK, COLOR_BLACK), NULL); + rc.right = (int)rc.right, ch = ACS_BULLET | A_BOLD; + } + for (int y = rc.top; y < rc.bottom; y++) + for (int x = rc.left; x < rc.right; x++) + mvwaddch(win, y, x, ch); + } + /** + * Instead of filling a portion of the screen with a surface pixmap, fills the + * the screen portion with black. + */ + void FillRectangle(PRectangle rc, Surface &surfacePattern) { + FillRectangle(rc, BLACK); + } + /** + * Scintilla will never call this method. + * Line markers that Scintilla would normally draw as rounded rectangles are + * handled in `DrawLineMarker()`. + */ + void RoundedRectangle(PRectangle rc, ColourDesired fore, + ColourDesired back) {} + /** + * Drawing alpha rectangles is not fully supported. + * Instead, fills the background color of the given rectangle with the fill + * color, emulating INDIC_STRAIGHTBOX with no transparency. + * This is called by Scintilla to draw INDIC_ROUNDBOX and INDIC_STRAIGHTBOX + * indicators, text blobs, and translucent line states and selections. + */ + void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, + int alphaFill, ColourDesired outline, int alphaOutline, + int flags) { + for (int x = rc.left, y = rc.top - 1; x < rc.right; x++) { + attr_t attrs = mvwinch(win, y, x) & A_ATTRIBUTES; + short pair = PAIR_NUMBER(attrs), fore, unused; + if (pair > 0) pair_content(pair, &fore, &unused); + mvwchgat(win, y, x, 1, attrs, term_color_pair(fore, fill), NULL); + } + } + /** Drawing gradients is not implemented. */ + void GradientRectangle(PRectangle rc, const std::vector &stops, + GradientOptions options) {} + /** Drawing images is not implemented. */ + void DrawRGBAImage(PRectangle rc, int width, int height, + const unsigned char *pixelsImage) {} + /** + * Scintilla will never call this method. + * Line markers that Scintilla would normally draw as circles are handled in + * `DrawLineMarker()`. + */ + void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) {} + /** + * Draw an indentation guide. + * Scintilla will only call this method when drawing indentation guides or + * during certain drawing operations when double buffering is enabled. Since + * the latter is not supported, assume the former. + */ + void Copy(PRectangle rc, Point from, Surface &surfaceSource) { + // TODO: handle indent guide highlighting. + wattr_set(win, 0, term_color_pair(COLOR_BLACK, COLOR_BLACK), NULL); + mvwaddch(win, rc.top, rc.left - 1, '|' | A_BOLD); + } + + /** + * Draws the given text at the given position on the screen with the given + * foreground and background colors. + * Takes into account any clipping boundaries previously specified. + */ + void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, + const char *s, int len, ColourDesired fore, + ColourDesired back) { + intptr_t attrs = reinterpret_cast(font_.GetID()); + wattr_set(win, static_cast(attrs), term_color_pair(fore, back), + NULL); + if (rc.left < clip.left) { + // Do not overwrite margin text. + int clip_chars = static_cast(clip.left - rc.left); + int offset = 0; + for (int chars = 0; offset < len; offset++) { + if (!UTF8IsTrailByte((unsigned char)s[offset])) + chars += grapheme_width(s + offset); + if (chars > clip_chars) break; + } + s += offset, len -= offset, rc.left = clip.left; + } + // Do not write beyond right window boundary. + int clip_chars = getmaxx(win) - rc.left; + int bytes = 0; + for (int chars = 0; bytes < len; bytes++) { + if (!UTF8IsTrailByte((unsigned char)s[bytes])) + chars += grapheme_width(s + bytes); + if (chars > clip_chars) break; + } + mvwaddnstr(win, rc.top, rc.left, s, std::min(len, bytes)); + } + /** + * Similar to `DrawTextNoClip()`. + * Scintilla calls this method for drawing the caret, text blobs, and + * `SC_MARKCHARACTER` line markers. + * When drawing control characters, *rc* needs to have its pixel padding + * removed since curses has smaller resolution. Similarly when drawing line + * markers, *rc* needs to be reshaped. + * @see DrawTextNoClip + */ + void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, + const char *s, int len, ColourDesired fore, + ColourDesired back) { + if (rc.left >= rc.right) // when drawing text blobs + rc.left -= 2, rc.right -= 2, rc.top -= 1, rc.bottom -= 1; + DrawTextNoClip(rc, font_, ybase, s, len, fore, back); + } + /** + * Similar to `DrawTextNoClip()`. + * Scintilla calls this method for drawing CallTip text and two-phase buffer + * text. However, the latter is not supported. + */ + void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, + const char *s, int len, ColourDesired fore) { + if ((int)rc.top >= getmaxy(win) - 1) return; + attr_t attrs = mvwinch(win, (int)rc.top, (int)rc.left); + short pair = PAIR_NUMBER(attrs), unused, back; + if (pair > 0) pair_content(pair, &unused, &back); + DrawTextNoClip(rc, font_, ybase, s, len, fore, SCI_COLORS[back]); + } + /** + * Measures the width of characters in the given string and writes them to the + * given position list. + * Curses characters always have a width of 1 if they are not UTF-8 trailing + * bytes. + */ + void MeasureWidths(Font &font_, const char *s, int len, + XYPOSITION *positions) { + for (int i = 0, j = 0; i < len; i++) { + if (!UTF8IsTrailByte((unsigned char)s[i])) j += grapheme_width(s + i); + positions[i] = j; + } + } + /** + * Returns the number of UTF-8 characters in the given string since curses + * characters always have a width of 1. + */ + XYPOSITION WidthText(Font &font_, const char *s, int len) { + int width = 0; + for (int i = 0; i < len; i++) + if (!UTF8IsTrailByte((unsigned char)s[i])) width += grapheme_width(s + i); + return width; + } + /** Returns 0 since curses characters have no ascent. */ + XYPOSITION Ascent(Font &font_) { return 0; } + /** Returns 0 since curses characters have no descent. */ + XYPOSITION Descent(Font &font_) { return 0; } + /** Returns 0 since curses characters have no leading. */ + XYPOSITION InternalLeading(Font &font_) { return 0; } + /** Returns 1 since curses characters always have a height of 1. */ + XYPOSITION Height(Font &font_) { return 1; } + /** Returns 1 since curses characters always have a width of 1. */ + XYPOSITION AverageCharWidth(Font &font_) { return 1; } + + /** + * Ensure text to be drawn in subsequent calls to `DrawText*()` is drawn + * within the given rectangle. + * This is needed in order to prevent long lines from overwriting margin text + * when scrolling to the right. + */ + void SetClip(PRectangle rc) { + clip.left = rc.left, clip.top = rc.top; + clip.right = rc.right, clip.bottom = rc.bottom; + } + /** Flushing cache is not implemented. */ + void FlushCachedState() {} + + /** Unsetting unicode mode is not implemented. UTF-8 is assumed. */ + void SetUnicodeMode(bool unicodeMode_) {} + /** Setting DBCS mode is not implemented. UTF-8 is used. */ + void SetDBCSMode(int codePage) {} + + /** Draws the text representation of a line marker, if possible. */ + void DrawLineMarker(PRectangle &rcWhole, Font &fontForCharacter, int tFold, + const void *data) { + // TODO: handle fold marker highlighting. + const LineMarker *marker = reinterpret_cast(data); + wattr_set(win, 0, term_color_pair(marker->fore, marker->back), NULL); + switch (marker->markType) { + case SC_MARK_CIRCLE: + mvwaddstr(win, rcWhole.top, rcWhole.left, "â—"); + return; + case SC_MARK_SMALLRECT: + case SC_MARK_ROUNDRECT: + mvwaddstr(win, rcWhole.top, rcWhole.left, "â– "); + return; + case SC_MARK_ARROW: + mvwaddstr(win, rcWhole.top, rcWhole.left, "â–º"); + return; + case SC_MARK_SHORTARROW: + mvwaddstr(win, rcWhole.top, rcWhole.left, "→"); + return; + case SC_MARK_ARROWDOWN: + mvwaddstr(win, rcWhole.top, rcWhole.left, "â–¼"); + return; + case SC_MARK_MINUS: + mvwaddch(win, rcWhole.top, rcWhole.left, '-'); + return; + case SC_MARK_BOXMINUS: + case SC_MARK_BOXMINUSCONNECTED: + mvwaddstr(win, rcWhole.top, rcWhole.left, "⊟"); + return; + case SC_MARK_CIRCLEMINUS: + case SC_MARK_CIRCLEMINUSCONNECTED: + mvwaddstr(win, rcWhole.top, rcWhole.left, "⊖"); + return; + case SC_MARK_PLUS: + mvwaddch(win, rcWhole.top, rcWhole.left, '+'); + return; + case SC_MARK_BOXPLUS: + case SC_MARK_BOXPLUSCONNECTED: + mvwaddstr(win, rcWhole.top, rcWhole.left, "⊞"); + return; + case SC_MARK_CIRCLEPLUS: + case SC_MARK_CIRCLEPLUSCONNECTED: + mvwaddstr(win, rcWhole.top, rcWhole.left, "⊕"); + return; + case SC_MARK_VLINE: + mvwaddch(win, rcWhole.top, rcWhole.left, ACS_VLINE); + return; + case SC_MARK_LCORNER: + case SC_MARK_LCORNERCURVE: + mvwaddch(win, rcWhole.top, rcWhole.left, ACS_LLCORNER); + return; + case SC_MARK_TCORNER: + case SC_MARK_TCORNERCURVE: + mvwaddch(win, rcWhole.top, rcWhole.left, ACS_LTEE); + return; + case SC_MARK_DOTDOTDOT: + mvwaddstr(win, rcWhole.top, rcWhole.left, "…"); + return; + case SC_MARK_ARROWS: + mvwaddstr(win, rcWhole.top, rcWhole.left, "»"); + return; + case SC_MARK_FULLRECT: + FillRectangle(rcWhole, marker->back); + return; + case SC_MARK_LEFTRECT: + mvwaddstr(win, rcWhole.top, rcWhole.left, "â–Œ"); + return; + case SC_MARK_BOOKMARK: + mvwaddstr(win, rcWhole.top, rcWhole.left, "Σ"); + return; + } + if (marker->markType >= SC_MARK_CHARACTER) { + char ch = static_cast(marker->markType - SC_MARK_CHARACTER); + DrawTextClipped(rcWhole, fontForCharacter, rcWhole.bottom, &ch, 1, + marker->fore, marker->back); + return; + } + } + /** Draws the text representation of a wrap marker. */ + void DrawWrapMarker(PRectangle rcPlace, bool isEndMarker, + ColourDesired wrapColour) { + wattr_set(win, 0, term_color_pair(wrapColour, COLOR_BLACK), NULL); + mvwaddstr(win, rcPlace.top, rcPlace.left, isEndMarker ? "↩" : "↪"); + } + /** Draws the text representation of a tab arrow. */ + void DrawTabArrow(PRectangle rcTab) { + // TODO: set color to vs.whitespaceColours.fore and back. + wattr_set(win, 0, term_color_pair(COLOR_BLACK, COLOR_BLACK), NULL); + for (int i = rcTab.left - 1; i < rcTab.right; i++) + mvwaddch(win, rcTab.top, i, '-' | A_BOLD); + mvwaddch(win, rcTab.top, rcTab.right, '>' | A_BOLD); + } +}; + +/** Creates a new curses surface. */ +Surface *Surface::Allocate(int) { return new SurfaceImpl(); } + +/** Custom function for drawing line markers in curses. */ +static void DrawLineMarker(Surface *surface, PRectangle &rcWhole, + Font &fontForCharacter, int tFold, int marginStyle, + const void *data) { + reinterpret_cast(surface)->DrawLineMarker(rcWhole, + fontForCharacter, + tFold, data); +} +/** Custom function for drawing wrap markers in curses. */ +static void DrawWrapVisualMarker(Surface *surface, PRectangle rcPlace, + bool isEndMarker, ColourDesired wrapColour) { + reinterpret_cast(surface)->DrawWrapMarker(rcPlace, isEndMarker, + wrapColour); +} +/** Custom function for drawing tab arrows in curses. */ +static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { + reinterpret_cast(surface)->DrawTabArrow(rcTab); +} + +// Window handling. + +/** Deletes the window. */ +Window::~Window() {} +/** + * Releases the window's resources. + * Since the only Windows created are AutoComplete and CallTip windows, and + * since those windows are created in `ListBox::Create()` and + * `ScintillaCurses::CreateCallTipWindow()`, respectively, via `newwin()`, it is + * safe to use `delwin()`. + * It is important to note that even though `ScintillaCurses::wMain` is a Window, + * its `Destroy()` function is never called, hence why `scintilla_delete()` is + * the complement to `scintilla_new()`. + */ +void Window::Destroy() { + if (wid) delwin(_WINDOW(wid)); + wid = 0; +} +/** + * Returns the window's boundaries. + * Unlike other platforms, Scintilla paints in coordinates relative to the + * window in curses. Therefore, this function should always return the window + * bounds to ensure all of it is painted. + * @return PRectangle with the window's boundaries. + */ +PRectangle Window::GetPosition() const { + int maxx = wid ? getmaxx(_WINDOW(wid)) : 0; + int maxy = wid ? getmaxy(_WINDOW(wid)) : 0; + return PRectangle(0, 0, maxx, maxy); +} +/** + * Sets the position of the window relative to its parent window. + * It will take care not to exceed the boundaries of the parent. + * @param rc The position relative to the parent window. + * @param relativeTo The parent window. + */ +void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) { + int begx = 0, begy = 0, x = 0, y = 0; + // Determine the relative position. + getbegyx(_WINDOW(relativeTo->GetID()), begy, begx); + x = begx + rc.left; + if (x < begx) x = begx; + y = begy + rc.top; + if (y < begy) y = begy; + // Correct to fit the parent if necessary. + int sizex = rc.right - rc.left; + int sizey = rc.bottom - rc.top; + int screen_width = getmaxx(_WINDOW(relativeTo->GetID())); + int screen_height = getmaxy(_WINDOW(relativeTo->GetID())); + if (sizex > screen_width) + x = begx; // align left + else if (x + sizex > begx + screen_width) + x = begx + screen_width - sizex; // align right + if (y + sizey > begy + screen_height) { + y = begy + screen_height - sizey; // align bottom + if (screen_height == 1) y--; // show directly above the relative window + } + if (y < 0) y = begy; // align top + // Update the location. + mvwin(_WINDOW(wid), y, x); +} +/** Identical to `Window::GetPosition()`. */ +PRectangle Window::GetClientPosition() const { return GetPosition(); } +void Window::Show(bool show) { /* TODO: */ } +void Window::InvalidateAll() { /* notify repaint */ } +void Window::InvalidateRectangle(PRectangle rc) { /* notify repaint*/ } +/** Setting the font is not implemented. */ +void Window::SetFont(Font &) {} +/** Setting the cursor icon is not implemented. */ +void Window::SetCursor(Cursor curs) {} +/** Identical to `Window::GetPosition()`. */ +PRectangle Window::GetMonitorRect(Point pt) { return GetPosition(); } + +/** + * Implementation of a Scintilla ListBox for curses. + * Instead of registering images to types, printable UTF-8 characters are + * registered to types. + */ +class ListBoxImpl : public ListBox { + int height, width; + std::vector list; + char types[IMAGE_MAX + 1][5]; // UTF-8 character plus terminating '\0' + int selection; +public: + IListBoxDelegate *delegate; + + /** Allocates a new Scintilla ListBox for curses. */ + ListBoxImpl() : height(5), width(10), selection(0), delegate(NULL) { + list.reserve(10); + ClearRegisteredImages(); + } + /** Deletes the ListBox. */ + ~ListBoxImpl() {} + + /** Setting the font is not implemented. */ + void SetFont(Font &font) {} + /** + * Creates a new listbox. + * The `Show()` function resizes window with the appropriate height and width. + */ + void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, + bool unicodeMode_, int technology_) { + wid = newwin(1, 1, 0, 0); + } + /** + * Setting average char width is not implemented since all curses characters + * have a width of 1. + */ + void SetAverageCharWidth(int width) {} + /** Sets the number of visible rows in the listbox. */ + void SetVisibleRows(int rows) { + height = rows; + wresize(_WINDOW(wid), height + 2, width + 2); + } + /** Returns the number of visible rows in the listbox. */ + int GetVisibleRows() const { return height; } + /** Returns the desired size of the listbox. */ + PRectangle GetDesiredRect() { + return PRectangle(0, 0, width + 2, height + 2); // add border widths + } + /** + * Returns the left-offset of the ListBox with respect to the caret. + * Takes into account the border width and type character width. + * @return 2 to shift the ListBox to the left two characters. + */ + int CaretFromEdge() { return 2; } + /** Clears the contents of the listbox. */ + void Clear() { + list.clear(); + width = 0; + } + /** + * Adds the given string list item to the listbox. + * Prepends the item's type character (if any) to the list item for display. + */ + void Append(char *s, int type = -1) { + if (type >= 0 && type <= IMAGE_MAX) { + char *chtype = types[type]; + list.push_back(std::string(chtype, strlen(chtype)) + std::string(s)); + } else list.push_back(std::string(" ") + std::string(s)); + int len = strlen(s); // TODO: UTF-8 awareness? + if (width < len) { + width = len + 1; // include type character len + wresize(_WINDOW(wid), height + 2, width + 2); + } + } + /** Returns the number of items in the listbox. */ + int Length() { return list.size(); } + /** Selects the given item in the listbox and repaints the listbox. */ + void Select(int n) { + WINDOW *w = _WINDOW(wid); + wclear(w); + box(w, '|', '-'); + int len = static_cast(list.size()); + int s = n - height / 2; + if (s + height > len) s = len - height; + if (s < 0) s = 0; + for (int i = s; i < s + height && i < len; i++) { + mvwaddstr(w, i - s + 1, 1, list.at(i).c_str()); + if (i == n) mvwchgat(w, i - s + 1, 2, width - 1, A_REVERSE, 0, NULL); + } + wmove(w, n - s + 1, 1); // place cursor on selected line + wnoutrefresh(w); + selection = n; + } + /** Returns the currently selected item in the listbox. */ + int GetSelection() { return selection; } + /** + * Searches the listbox for the items matching the given prefix string and + * returns the index of the first match. + * Since the type is displayed as the first character, the value starts on the + * second character; match strings starting there. + */ + int Find(const char *prefix) { + int len = strlen(prefix); + for (unsigned int i = 0; i < list.size(); i++) { + const char *item = list.at(i).c_str(); + item += UTF8DrawBytes(reinterpret_cast(item), + strlen(item)); + if (strncmp(prefix, item, len) == 0) return i; + } + return -1; + } + /** + * Gets the item in the listbox at the given index and stores it in the given + * string. + * Since the type is displayed as the first character, the value starts on the + * second character. + */ + void GetValue(int n, char *value, int len) { + if (len > 0) { + const char *item = list.at(n).c_str(); + item += UTF8DrawBytes(reinterpret_cast(item), + strlen(item)); + strncpy(value, item, len); + value[len - 1] = '\0'; + } else value[0] = '\0'; + } + /** + * Registers the first UTF-8 character of the given string to the given type. + * By default, ' ' (space) is registered to all types. + * @usage SCI_REGISTERIMAGE(1, "*") // type 1 shows '*' in front of list item. + * @usage SCI_REGISTERIMAGE(2, "+") // type 2 shows '+' in front of list item. + * @usage SCI_REGISTERIMAGE(3, "â– ") // type 3 shows 'â– ' in front of list item. + */ + void RegisterImage(int type, const char *xpm_data) { + if (type < 0 || type > IMAGE_MAX) return; + int len = UTF8DrawBytes(reinterpret_cast(xpm_data), + strlen(xpm_data)); + for (int i = 0; i < len; i++) types[type][i] = xpm_data[i]; + types[type][len] = '\0'; + } + /** Registering images is not implemented. */ + void RegisterRGBAImage(int type, int width, int height, + const unsigned char *pixelsImage) {} + /** Clears all registered types back to ' ' (space). */ + void ClearRegisteredImages() { + for (int i = 0; i <= IMAGE_MAX; i++) types[i][0] = ' ', types[i][1] = '\0'; + } + /** Defines the delegate for ListBox actions. */ + void SetDelegate(IListBoxDelegate *lbDelegate) { + delegate = lbDelegate; + } + /** Sets the list items in the listbox to the given items. */ + void SetList(const char *listText, char separator, char typesep) { + Clear(); + int len = strlen(listText); + char *text = new char[len + 1]; + if (!text) return; + memcpy(text, listText, len + 1); + char *word = text, *type = NULL; + for (int i = 0; i <= len; i++) { + if (text[i] == separator || i == len) { + text[i] = '\0'; + if (type) *type = '\0'; + Append(word, type ? atoi(type + 1) : -1); + word = text + i + 1, type = NULL; + } else if (text[i] == typesep) + type = text + i; + } + delete []text; + } +}; + +/** Creates a new Scintilla ListBox. */ +ListBox::ListBox() noexcept {} +/** Deletes the ListBox. */ +ListBox::~ListBox() {} +/** Creates a new curses ListBox. */ +ListBox *ListBox::Allocate() { return new ListBoxImpl(); } + +// Menus are not implemented. +Menu::Menu() noexcept : mid(0) {} +void Menu::CreatePopUp() {} +void Menu::Destroy() {} +void Menu::Show(Point pt, Window &w) {} + +/** Dynamic library loading is not implemented. */ +DynamicLibrary *DynamicLibrary::Load(const char *modulePath) { + /* TODO */ return 0; +} + +ColourDesired Platform::Chrome() { return ColourDesired(0, 0, 0); } +ColourDesired Platform::ChromeHighlight() { return ColourDesired(0, 0, 0); } +const char *Platform::DefaultFont() { return "monospace"; } +int Platform::DefaultFontSize() { return 10; } +unsigned int Platform::DoubleClickTime() { return 500; /* ms */ } +void Platform::DebugDisplay(const char *s) { fprintf(stderr, "%s", s); } +void Platform::DebugPrintf(const char *format, ...) {} +//bool Platform::ShowAssertionPopUps(bool assertionPopUps_) { return true; } +void Platform::Assert(const char *c, const char *file, int line) { + char buffer[2000]; + sprintf(buffer, "Assertion [%s] failed at %s %d\r\n", c, file, line); + Platform::DebugDisplay(buffer); + abort(); +} + +/** Implementation of Scintilla for curses. */ +class ScintillaCurses : public ScintillaBase { + Surface *sur; // window surface to draw on + int width, height; // window dimensions + void (*callback)(void *, int, void *, void *); // SCNotification callback + int scrollBarVPos, scrollBarHPos; // positions of the scroll bars + int scrollBarHeight, scrollBarWidth; // height and width of the scroll bars + SelectionText clipboard; // current clipboard text + bool capturedMouse; // whether or not the mouse is currently captured + unsigned int autoCompleteLastClickTime; // last click time in the AC box + bool draggingVScrollBar, draggingHScrollBar; // a scrollbar is being dragged + int dragOffset; // the distance to the position of the scrollbar being dragged + + /** + * Uses the given UTF-8 code point to fill the given UTF-8 byte sequence and + * length. + * This algorithm was inspired by Paul Evans' libtermkey. + * (http://www.leonerd.org.uk/code/libtermkey) + * @param code The UTF-8 code point. + * @param s The string to write the UTF-8 byte sequence in. Must be at least + * 6 bytes in size. + * @param len The integer to put the number of UTF-8 bytes written in. + */ + void toutf8(int code, char *s, int *len) { + if (code < 0x80) *len = 1; + else if (code < 0x800) *len = 2; + else if (code < 0x10000) *len = 3; + else if (code < 0x200000) *len = 4; + else if (code < 0x4000000) *len = 5; + else *len = 6; + for (int b = *len - 1; b > 0; b--) s[b] = 0x80 | (code & 0x3F), code >>= 6; + if (*len == 1) s[0] = code & 0x7F; + else if (*len == 2) s[0] = 0xC0 | (code & 0x1F); + else if (*len == 3) s[0] = 0xE0 | (code & 0x0F); + else if (*len == 4) s[0] = 0xF0 | (code & 0x07); + else if (*len == 5) s[0] = 0xF8 | (code & 0x03); + else if (*len == 6) s[0] = 0xFC | (code & 0x01); + } +public: + /** + * Creates a new Scintilla instance in a curses `WINDOW`. + * However, the `WINDOW` itself will not be created until it is absolutely + * necessary. When the `WINDOW` is created, it will initially be full-screen. + * @param callback_ Callback function for Scintilla notifications. + */ + ScintillaCurses(void (*callback_)(void *, int, void *, void *)) : + width(0), height(0), scrollBarHeight(1), scrollBarWidth(1) { + callback = callback_; + sur = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); + + // Defaults for curses. + marginView.wrapMarkerPaddingRight = 0; // no padding for margin wrap markers + marginView.customDrawWrapMarker = DrawWrapVisualMarker; // draw text markers + view.tabWidthMinimumPixels = 0; // no proportional fonts + view.drawOverstrikeCaret = false; // always draw normal caret + view.bufferedDraw = false; // draw directly to the screen + view.phasesDraw = EditView::phasesOne; // no need for two-phase drawing + view.tabArrowHeight = 0; // no additional tab arrow height + view.customDrawTabArrow = DrawTabArrow; // draw text arrows for tabs + view.customDrawWrapMarker = DrawWrapVisualMarker; // draw text wrap markers + mouseSelectionRectangularSwitch = true; // easier rectangular selection + doubleClickCloseThreshold = Point(0, 0); // double-clicks only in same cell + horizontalScrollBarVisible = false; // no horizontal scroll bar + scrollWidth = 5 * width; // reasonable default for any horizontal scroll bar + vs.selColours.fore = ColourDesired(0, 0, 0); // black on white selection + vs.selColours.fore.isSet = true; // setting selection foreground above + vs.caretcolour = ColourDesired(0xFF, 0xFF, 0xFF); // white caret + vs.caretStyle = CARETSTYLE_BLOCK; // block caret + vs.leftMarginWidth = 0, vs.rightMarginWidth = 0; // no margins + vs.ms[1].width = 1; // marker margin width should be 1 + vs.extraDescent = -1; // hack to make lineHeight 1 instead of 2 + // Set default marker foreground and background colors. + for (int i = 0; i <= MARKER_MAX; i++) { + vs.markers[i].fore = ColourDesired(0xC0, 0xC0, 0xC0); + vs.markers[i].back = ColourDesired(0, 0, 0); + if (i >= 25) vs.markers[i].markType = SC_MARK_EMPTY; + vs.markers[i].customDraw = DrawLineMarker; + } + // Use '+' and '-' fold markers. + vs.markers[SC_MARKNUM_FOLDEROPEN].markType = SC_MARK_MINUS; + vs.markers[SC_MARKNUM_FOLDER].markType = SC_MARK_PLUS; + vs.markers[SC_MARKNUM_FOLDEROPENMID].markType = SC_MARK_MINUS; + vs.markers[SC_MARKNUM_FOLDEREND].markType = SC_MARK_PLUS; + displayPopupMenu = false; // no context menu + vs.marginNumberPadding = 0; // no number margin padding + vs.ctrlCharPadding = 0; // no ctrl character text blob padding + vs.lastSegItalicsOffset = 0; // no offset for italic characters at EOLs + ac.widthLBDefault = 10; // more sane bound for autocomplete width + ac.heightLBDefault = 10; // more sane bound for autocomplete height + ct.colourBG = ColourDesired(0, 0, 0); // black background color + ct.colourUnSel = ColourDesired(0xC0, 0xC0, 0xC0); // white text + ct.insetX = 2; // border and arrow widths are 1 each + ct.widthArrow = 1; // arrow width is 1 character + ct.borderHeight = 1; // no extra empty lines in border height + ct.verticalOffset = 0; // no extra offset of calltip from line + } + /** Deletes the Scintilla instance. */ + ~ScintillaCurses() { + if (wMain.GetID()) + delwin(GetWINDOW()); + if (sur) { + sur->Release(); + delete sur; + } + } + /** Initializing code is unnecessary. */ + void Initialise() {} + /** Disable drag and drop since it is not implemented. */ + void StartDrag() { + inDragDrop = ddNone; + SetDragPosition(SelectionPosition(Sci::invalidPosition)); + } + /** Draws the vertical scroll bar. */ + void SetVerticalScrollPos() { + if (!wMain.GetID() || !verticalScrollBarVisible) return; + WINDOW *w = GetWINDOW(); + int maxy = getmaxy(w), maxx = getmaxx(w); + // Draw the gutter. + wattr_set(w, 0, term_color_pair(COLOR_WHITE, COLOR_BLACK), NULL); + for (int i = 0; i < maxy; i++) mvwaddch(w, i, maxx - 1, ACS_CKBOARD); + // Draw the bar. + scrollBarVPos = static_cast(topLine) / + (MaxScrollPos() + LinesOnScreen() - 1) * maxy; + wattr_set(w, 0, term_color_pair(COLOR_BLACK, COLOR_WHITE), NULL); + for (int i = scrollBarVPos; i < scrollBarVPos + scrollBarHeight; i++) + mvwaddch(w, i, maxx - 1, ' '); + } + /** Draws the horizontal scroll bar. */ + void SetHorizontalScrollPos() { + if (!wMain.GetID() || !horizontalScrollBarVisible) return; + WINDOW *w = GetWINDOW(); + int maxy = getmaxy(w), maxx = getmaxx(w); + // Draw the gutter. + wattr_set(w, 0, term_color_pair(COLOR_WHITE, COLOR_BLACK), NULL); + for (int i = 0; i < maxx; i++) mvwaddch(w, maxy - 1, i, ACS_CKBOARD); + // Draw the bar. + scrollBarHPos = static_cast(xOffset) / scrollWidth * maxx; + wattr_set(w, 0, term_color_pair(COLOR_BLACK, COLOR_WHITE), NULL); + for (int i = scrollBarHPos; i < scrollBarHPos + scrollBarWidth; i++) + mvwaddch(w, maxy - 1, i, ' '); + } + /** + * Sets the height of the vertical scroll bar and width of the horizontal + * scroll bar. + * The height is based on the given size of a page and the total number of + * pages. The width is based on the width of the view and the view's scroll + * width property. + */ + bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) { + if (!wMain.GetID()) return false; + WINDOW *w = GetWINDOW(); + int maxy = getmaxy(w), maxx = getmaxx(w); + int height = roundf(static_cast(nPage) / nMax * maxy); + scrollBarHeight = Sci::clamp(height, 1, maxy); + int width = roundf(static_cast(maxx) / scrollWidth * maxx); + scrollBarWidth = Sci::clamp(width, 1, maxx); + return true; + } + /** + * Copies the selected text to the internal clipboard. + * The primary and secondary X selections are unaffected. + */ + void Copy() { if (!sel.Empty()) CopySelectionRange(&clipboard); } + /** + * Pastes text from the internal clipboard, not from primary or secondary X + * selections. + */ + void Paste() { + if (clipboard.Empty()) return; + ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH); + InsertPasteShape(clipboard.Data(), static_cast(clipboard.Length()), + !clipboard.rectangular ? pasteStream : pasteRectangular); + EnsureCaretVisible(); + } + /** Setting of the primary and/or secondary X selections is not supported. */ + void ClaimSelection() {} + /** Notifying the parent of text changes is not yet supported. */ + void NotifyChange() {} + /** Send Scintilla notifications to the parent. */ + void NotifyParent(SCNotification scn) { + if (callback) + (*callback)(reinterpret_cast(this), 0, (void *)&scn, 0); + } + /** + * Handles an unconsumed key. + * If a character is being typed, add it to the editor. Otherwise, notify the + * container. + */ + int KeyDefault(int key, int modifiers) { + if ((IsUnicodeMode() || key < 256) && modifiers == 0) { + if (IsUnicodeMode()) { + char utf8[6]; + int len; + toutf8(key, utf8, &len); + return (AddCharUTF(utf8, len), 1); + } else return (AddChar(key), 1); + } else { + SCNotification scn = {}; + scn.nmhdr.code = SCN_KEY; + scn.ch = key; + scn.modifiers = modifiers; + return (NotifyParent(scn), 0); + } + } + /** + * Copies the given text to the internal clipboard. + * Like `Copy()`, does not affect the primary and secondary X selections. + */ + void CopyToClipboard(const SelectionText &selectedText) { + clipboard.Copy(selectedText); + } + /** A ticking caret is not implemented. */ + bool FineTickerRunning(TickReason reason) { return false; } + /** A ticking caret is not implemented. */ + void FineTickerStart(TickReason reason, int millis, int tolerance) {} + /** A ticking caret is not implemented. */ + void FineTickerCancel(TickReason reason) {} + /** + * Sets whether or not the mouse is captured. + * This is used by Scintilla to handle mouse clicks, drags, and releases. + */ + void SetMouseCapture(bool on) { capturedMouse = on; } + /** Returns whether or not the mouse is captured. */ + bool HaveMouseCapture() { return capturedMouse; } + /** A Scintilla direct pointer is not implemented. */ + sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { + return 0; + } + /** Draws a CallTip, creating the curses window for it if necessary. */ + void CreateCallTipWindow(PRectangle rc) { + if (!wMain.GetID()) return; + if (!ct.wCallTip.Created()) { + rc.right -= 1; // remove right-side padding + int begx = 0, begy = 0, maxx = 0, maxy = 0; + getbegyx(GetWINDOW(), begy, begx); + int xoffset = begx - rc.left, yoffset = begy - rc.top; + if (xoffset > 0) rc.left += xoffset, rc.right += xoffset; + if (yoffset > 0) rc.top += yoffset, rc.bottom += yoffset; + getmaxyx(GetWINDOW(), maxy, maxx); + if (rc.Width() > maxx) rc.right = rc.left + maxx; + if (rc.Height() > maxy) rc.bottom = rc.top + maxy; + ct.wCallTip = newwin(rc.Height(), rc.Width(), rc.top, rc.left); + } + WindowID wid = ct.wCallTip.GetID(); + box(_WINDOW(wid), '|', '-'); + Surface *sur = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); + if (sur) { + sur->Init(wid); + ct.PaintCT(sur); + wnoutrefresh(_WINDOW(wid)); + sur->Release(); + delete sur; + } + } + /** Adding menu items to the popup menu is not implemented. */ + void AddToPopUp(const char *label, int cmd=0, bool enabled=true) {} + /** + * Sends the given message and parameters to Scintilla unless it is a message + * that changes an unsupported property. + */ + sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { + try { + switch (iMessage) { + case SCI_GETDIRECTFUNCTION: + return reinterpret_cast(scintilla_send_message); + case SCI_GETDIRECTPOINTER: return reinterpret_cast(this); + // Ignore attempted changes of the following unsupported properties. + case SCI_SETBUFFEREDDRAW: + case SCI_SETWHITESPACESIZE: + case SCI_SETTWOPHASEDRAW: case SCI_SETPHASESDRAW: + case SCI_SETEXTRAASCENT: case SCI_SETEXTRADESCENT: + return 0; + // Pass to Scintilla. + default: return ScintillaBase::WndProc(iMessage, wParam, lParam); + } + } catch (std::bad_alloc&) { + errorStatus = SC_STATUS_BADALLOC; + } catch (...) { + errorStatus = SC_STATUS_FAILURE; + } + return 0; + } + + /** + * Returns the curses `WINDOW` associated with this Scintilla instance. + * If the `WINDOW` has not been created yet, create it now. + */ + WINDOW *GetWINDOW() { + if (!wMain.GetID()) { + init_colors(); + wMain = newwin(0, 0, 0, 0); + WINDOW *w = _WINDOW(wMain.GetID()); + keypad(w, TRUE); + if (sur) + sur->Init(w); + getmaxyx(w, height, width); + InvalidateStyleRedraw(); // needed to fully initialize Scintilla + } + return _WINDOW(wMain.GetID()); + } + /** + * Repaints the Scintilla window on the virtual screen. + * If an autocompletion list, user list, or calltip is active, redraw it over + * the buffer's contents. + * It is the application's responsibility to call the curses `doupdate()` in + * order to refresh the physical screen. + * To paint to the physical screen instead, use `Refresh()`. + * @see Refresh + */ + void NoutRefresh() { + WINDOW *w = GetWINDOW(); + rcPaint.top = 0, rcPaint.left = 0; // paint from (0, 0), not (begy, begx) + getmaxyx(w, rcPaint.bottom, rcPaint.right); + if (rcPaint.bottom != height || rcPaint.right != width) + height = rcPaint.bottom, width = rcPaint.right, ChangeSize(); + Paint(sur, rcPaint); + SetVerticalScrollPos(), SetHorizontalScrollPos(); + wnoutrefresh(w); +#if PDCURSES + touchwin(w); // pdcurses sometimes has problems drawing overlapping windows +#endif + if (ac.Active()) + ac.lb->Select(ac.lb->GetSelection()); // redraw + else if (ct.inCallTipMode) + CreateCallTipWindow(PRectangle(0, 0, 0, 0)); // redraw + if (hasFocus) { + // Update cursor position, even if it's not visible, as the container may + // have a use for it. + int pos = WndProc(SCI_GETCURRENTPOS, 0, 0); + move(getbegy(w) + WndProc(SCI_POINTYFROMPOSITION, 0, pos), + getbegx(w) + WndProc(SCI_POINTXFROMPOSITION, 0, pos)); + } + } + /** + * Repaints the Scintilla window on the physical screen. + * If an autocompletion list, user list, or calltip is active, redraw it over + * the buffer's contents. + * To paint to the virtual screen instead, use `NoutRefresh()`. + * @see NoutRefresh + */ + void Refresh() { + NoutRefresh(); + doupdate(); + } + /** + * Sends a key to Scintilla. + * Usually if a key is consumed, the screen should be repainted. However, when + * autocomplete is active, that window is consuming the keys and any + * repainting of the main Scintilla window will overwrite the autocomplete + * window. + * @param key The key pressed. + * @param shift Flag indicating whether or not the shift modifier key is + * pressed. + * @param shift Flag indicating whether or not the control modifier key is + * pressed. + * @param shift Flag indicating whether or not the alt modifier key is + * pressed. + */ + void KeyPress(int key, bool shift, bool ctrl, bool alt) { + KeyDownWithModifiers(key, ModifierFlags(shift, ctrl, alt), NULL); + } + /** + * Handles a mouse button press. + * @param button The button number pressed, or `0` if none. + * @param time The time in milliseconds of the mouse event. + * @param y The y coordinate of the mouse event relative to this window. + * @param x The x coordinate of the mouse event relative to this window. + * @param shift Flag indicating whether or not the shift modifier key is + * pressed. + * @param ctrl Flag indicating whether or not the control modifier key is + * pressed. + * @param alt Flag indicating whether or not the alt modifier key is pressed. + * @return whether or not the mouse event was handled + */ + bool MousePress(int button, unsigned int time, int y, int x, bool shift, + bool ctrl, bool alt) { + GetWINDOW(); // ensure the curses `WINDOW` has been created + if (ac.Active() && (button == 1 || button == 4 || button == 5)) { + // Select an autocompletion list item if possible or scroll the list. + WINDOW *w = _WINDOW(ac.lb->GetID()), *parent = GetWINDOW(); + int begy = getbegy(w) - getbegy(parent); // y is relative to the view + int begx = getbegx(w) - getbegx(parent); // x is relative to the view + int maxy = getmaxy(w) - 1, maxx = getmaxx(w) - 1; // ignore border + int ry = y - begy, rx = x - begx; // relative to list box + if (ry > 0 && ry < maxy && rx > 0 && rx < maxx) { + if (button == 1) { + // Select a list item. + // The currently selected item is normally displayed in the middle. + int middle = ac.lb->GetVisibleRows() / 2; + int n = ac.lb->GetSelection(), ny = middle; + if (n < middle) + ny = n; // the currently selected item is near the beginning + else if (n >= ac.lb->Length() - middle) + ny = (n - 1) % ac.lb->GetVisibleRows(); // it's near the end + // Compute the index of the item to select. + int offset = ry - ny - 1; // -1 ignores list box border + if (offset == 0 && + time - autoCompleteLastClickTime < Platform::DoubleClickTime()) { + ListBoxImpl* listbox = reinterpret_cast(ac.lb.get()); + if (listbox->delegate) { + ListBoxEvent event(ListBoxEvent::EventType::doubleClick); + listbox->delegate->ListNotify(&event); + } + } else ac.lb->Select(n + offset); + autoCompleteLastClickTime = time; + } else { + // Scroll the list. + int n = ac.lb->GetSelection(); + if (button == 4 && n > 0) + ac.lb->Select(n - 1); + else if (button == 5 && n < ac.lb->Length() - 1) + ac.lb->Select(n + 1); + } + return true; + } else if (ry == 0 || ry == maxy || rx == 0 || rx == maxx) + return true; // ignore border click + } else if (ct.inCallTipMode && button == 1) { + // Send the click to the CallTip. + WINDOW *w = _WINDOW(ct.wCallTip.GetID()), *parent = GetWINDOW(); + int begy = getbegy(w) - getbegy(parent); // y is relative to the view + int begx = getbegx(w) - getbegx(parent); // x is relative to the view + int maxy = getmaxy(w) - 1, maxx = getmaxx(w) - 1; // ignore border + int ry = y - begy, rx = x - begx; // relative to list box + if (ry >= 0 && ry <= maxy && rx >= 0 && rx <= maxx) { + ct.MouseClick(Point(rx, ry)); + return (CallTipClick(), true); + } + } + + if (button == 1) { + if (verticalScrollBarVisible && x == getmaxx(GetWINDOW()) - 1) { + // Scroll the vertical scrollbar. + if (y < scrollBarVPos) + return (ScrollTo(topLine - LinesOnScreen()), true); + else if (y >= scrollBarVPos + scrollBarHeight) + return (ScrollTo(topLine + LinesOnScreen()), true); + else + draggingVScrollBar = true, dragOffset = y - scrollBarVPos; + } else if (horizontalScrollBarVisible && y == getmaxy(GetWINDOW()) - 1) { + // Scroll the horizontal scroll bar. + if (x < scrollBarHPos) + return (HorizontalScrollTo(xOffset - getmaxx(GetWINDOW()) / 2), true); + else if (x >= scrollBarHPos + scrollBarWidth) + return (HorizontalScrollTo(xOffset + getmaxx(GetWINDOW()) / 2), true); + else + draggingHScrollBar = true, dragOffset = x - scrollBarHPos; + } else { + // Have Scintilla handle the click. + ButtonDownWithModifiers(Point(x, y), time, + ModifierFlags(shift, ctrl, alt)); + return true; + } + } else if (button == 4 || button == 5) { + // Scroll the view. + int lines = getmaxy(GetWINDOW()) / 4; + if (lines < 1) lines = 1; + if (button == 4) lines *= -1; + return (ScrollTo(topLine + lines), true); + } + return false; + } + /** + * Sends a mouse move event to Scintilla, returning whether or not Scintilla + * handled the mouse event. + * @param y The y coordinate of the mouse event relative to this window. + * @param x The x coordinate of the mouse event relative to this window. + * @param shift Flag indicating whether or not the shift modifier key is + * pressed. + * @param ctrl Flag indicating whether or not the control modifier key is + * pressed. + * @param alt Flag indicating whether or not the alt modifier key is pressed. + * @return whether or not Scintilla handled the mouse event + */ + bool MouseMove(int y, int x, bool shift, bool ctrl, bool alt) { + GetWINDOW(); // ensure the curses `WINDOW` has been created + if (!draggingVScrollBar && !draggingHScrollBar) { + ButtonMoveWithModifiers(Point(x, y), 0, ModifierFlags(shift, ctrl, alt)); + } else if (draggingVScrollBar) { + int maxy = getmaxy(GetWINDOW()) - scrollBarHeight, pos = y - dragOffset; + if (pos >= 0 && pos <= maxy) ScrollTo(pos * MaxScrollPos() / maxy); + return true; + } else if (draggingHScrollBar) { + int maxx = getmaxx(GetWINDOW()) - scrollBarWidth, pos = x - dragOffset; + if (pos >= 0 && pos <= maxx) + HorizontalScrollTo(pos * (scrollWidth - maxx - scrollBarWidth) / maxx); + return true; + } + return HaveMouseCapture(); + } + /** + * Sends a mouse release event to Scintilla. + * @param time The time in milliseconds of the mouse event. + * @param y The y coordinate of the mouse event relative to this window. + * @param x The x coordinate of the mouse event relative to this window. + * @param ctrl Flag indicating whether or not the control modifier key is + * pressed. + */ + void MouseRelease(int time, int y, int x, int ctrl) { + GetWINDOW(); // ensure the curses `WINDOW` has been created + if (draggingVScrollBar || draggingHScrollBar) + draggingVScrollBar = false, draggingHScrollBar = false; + else if (HaveMouseCapture()) { + ButtonUpWithModifiers(Point(x, y), time, + ModifierFlags(ctrl, false, false)); + // TODO: ListBoxEvent event(ListBoxEvent::EventType::selectionChange); + // TODO: listbox->delegate->ListNotify(&event); + } + } + /** + * Copies the text of the internal clipboard, not the primary and/or secondary + * X selections, into the given buffer and returns the size of the clipboard + * text. + * @param text The buffer to copy clipboard text to. + * @return size of the clipboard text + */ + int GetClipboard(char *buffer) { + if (buffer) memcpy(buffer, clipboard.Data(), clipboard.Length() + 1); + return clipboard.Length() + 1; + } +}; + +// Link with C. Documentation in Scintilla.h. +extern "C" { +void *scintilla_new(void (*callback)(void *, int, void *, void *)) { + return reinterpret_cast(new ScintillaCurses(callback)); +} +WINDOW *scintilla_get_window(void *sci) { + return reinterpret_cast(sci)->GetWINDOW(); +} +sptr_t scintilla_send_message(void *sci, unsigned int iMessage, uptr_t wParam, + sptr_t lParam) { + return reinterpret_cast(sci)->WndProc(iMessage, wParam, + lParam); +} +void scintilla_send_key(void *sci, int key, bool shift, bool ctrl, bool alt) { + reinterpret_cast(sci)->KeyPress(key, shift, ctrl, alt); +} +bool scintilla_send_mouse(void *sci, int event, unsigned int time, int button, + int y, int x, bool shift, bool ctrl, bool alt) { + ScintillaCurses *scicurses = reinterpret_cast(sci); + WINDOW *w = scicurses->GetWINDOW(); + int begy = getbegy(w), begx = getbegx(w); + int maxy = getmaxy(w), maxx = getmaxx(w); + // Ignore most events outside the window. + if ((x < begx || x > begx + maxx - 1 || y < begy || y > begy + maxy - 1) && + button != 4 && button != 5) return false; + y = y - begy, x = x - begx; + if (event == SCM_PRESS) + return scicurses->MousePress(button, time, y, x, shift, ctrl, alt); + else if (event == SCM_DRAG) + return scicurses->MouseMove(y, x, shift, ctrl, alt); + else if (event == SCM_RELEASE) + return (scicurses->MouseRelease(time, y, x, ctrl), true); + return false; +} +int scintilla_get_clipboard(void *sci, char *buffer) { + return reinterpret_cast(sci)->GetClipboard(buffer); +} +void scintilla_noutrefresh(void *sci) { + reinterpret_cast(sci)->NoutRefresh(); +} +void scintilla_refresh(void *sci) { + reinterpret_cast(sci)->Refresh(); +} +void scintilla_delete(void *sci) { + delete reinterpret_cast(sci); +} +} diff --git a/dep/scintilla/scintilla-3.10.6/curses/ScintillaCurses.h b/dep/scintilla/scintilla-3.10.6/curses/ScintillaCurses.h new file mode 100644 index 00000000..e7c9441d --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/curses/ScintillaCurses.h @@ -0,0 +1,128 @@ +// Copyright 2012-2019 Mitchell mitchell.att.foicica.com. See License.txt. +// Header for Scintilla in a curses (terminal) environment. + +#ifndef SCINTILLACURSES_H +#define SCINTILLACURSES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Creates a new Scintilla window. + * Curses does not have to be initialized before calling this function. + * @param callback A callback function for Scintilla notifications. + */ +void *scintilla_new(void (*callback)(void *sci, int iMessage, void *wParam, + void *lParam)); +/** + * Returns the curses `WINDOW` associated with the given Scintilla window. + * Curses must have been initialized prior to calling this function. + * @param sci The Scintilla window returned by `scintilla_new()`. + * @return curses `WINDOW`. + */ +WINDOW *scintilla_get_window(void *sci); +/** + * Sends the given message with parameters to the given Scintilla window. + * Curses does not have to be initialized before calling this function. + * @param sci The Scintilla window returned by `scintilla_new()`. + * @param iMessage The message ID. + * @param wParam The first parameter. + * @param lParam The second parameter. + */ +sptr_t scintilla_send_message(void *sci, unsigned int iMessage, uptr_t wParam, + sptr_t lParam); +/** + * Sends the specified key to the given Scintilla window for processing. + * If it is not consumed, an SCNotification will be emitted. + * Curses does not have to be initialized before calling this function. + * @param sci The Scintilla window returned by `scintilla_new()`. + * @param key The keycode of the key. + * @param shift Flag indicating whether or not the shift modifier key is + * pressed. + * @param ctrl Flag indicating whether or not the control modifier key is + * pressed. + * @param alt Flag indicating whether or not the alt modifier key is pressed. + */ +void scintilla_send_key(void *sci, int key, bool shift, bool ctrl, bool alt); +/** + * Sends the specified mouse event to the given Scintilla window for processing. + * Curses must have been initialized prior to calling this function. + * @param sci The Scintilla window returned by `scintilla_new()`. + * @param event The mouse event (`SCM_CLICK`, `SCM_DRAG`, or `SCM_RELEASE`). + * @param time The time in milliseconds of the mouse event. This is only needed + * if double and triple clicks need to be detected. + * @param button The button number pressed, or `0` if none. + * @param y The absolute y coordinate of the mouse event. + * @param x The absolute x coordinate of the mouse event. + * @param shift Flag indicating whether or not the shift modifier key is + * pressed. + * @param ctrl Flag indicating whether or not the control modifier key is + * pressed. + * @param alt Flag indicating whether or not the alt modifier key is pressed. + * @return whether or not Scintilla handled the mouse event + */ +bool scintilla_send_mouse(void *sci, int event, unsigned int time, int button, + int y, int x, bool shift, bool ctrl, bool alt); +/** + * Copies the text of Scintilla's internal clipboard, not the primary and/or + * secondary X selections, into the given buffer and returns the size of the + * clipboard text. + * Call with a `null` buffer first to get the size of the buffer needed to store + * clipboard text. + * Keep in mind clipboard text may contain null bytes. + * Curses does not have to be initialized before calling this function. + * @param sci The Scintilla window returned by `scintilla_new()`. + * @param buffer The buffer to copy clipboard text to. + * @return size of the clipboard text. + */ +int scintilla_get_clipboard(void *sci, char *buffer); +/** + * Refreshes the Scintilla window on the virtual screen. + * This should be done along with the normal curses `noutrefresh()`, as the + * virtual screen is updated when calling this function. + * Curses must have been initialized prior to calling this function. + * @param sci The Scintilla window returned by `scintilla_new()`. + */ +void scintilla_noutrefresh(void *sci); +/** + * Refreshes the Scintilla window on the physical screen. + * This should be done along with the normal curses `refresh()`, as the physical + * screen is updated when calling this function. + * Curses must have been initialized prior to calling this function. + * @param sci The Scintilla window returned by `scintilla_new()`. + */ +void scintilla_refresh(void *sci); +/** + * Deletes the given Scintilla window. + * Curses must have been initialized prior to calling this function. + * @param sci The Scintilla window returned by `scintilla_new()`. + */ +void scintilla_delete(void *sci); + +/** + * Returns the curses `COLOR_PAIR` for the given curses foreground and + * background `COLOR`s. + * This is used simply to enumerate every possible color combination. + * Note: only 256 combinations are possible due to curses portability. + * Note: This references the global curses variable `COLORS` and is + * not a constant expression. + * @param f The curses foreground `COLOR`. + * @param b The curses background `COLOR`. + * @return int number for defining a curses `COLOR_PAIR`. + */ +#define SCI_COLOR_PAIR(f, b) ((b) * ((COLORS < 16) ? 8 : 16) + (f) + 1) + +#define IMAGE_MAX 31 + +#define SCM_PRESS 1 +#define SCM_DRAG 2 +#define SCM_RELEASE 3 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/curses/THANKS.md b/dep/scintilla/scintilla-3.10.6/curses/THANKS.md new file mode 100644 index 00000000..23e7b084 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/curses/THANKS.md @@ -0,0 +1,14 @@ +# Thanks + +Thank you everyone for your contributions and feedback. They have helped improve +Scintilla curses. + +## Code Contributors + +* Chad Voegele +* Chris Emerson +* Neil Hodgson +* Paul Evans +* Peter Kazmier +* Robin Haberkorn +* Valere Monseur diff --git a/dep/scintilla/scintilla-3.10.6/curses/jinx/Makefile b/dep/scintilla/scintilla-3.10.6/curses/jinx/Makefile new file mode 100644 index 00000000..a99341aa --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/curses/jinx/Makefile @@ -0,0 +1,17 @@ +# Copyright 2012-2019 Mitchell mitchell.att.foicica.com. See License.txt. + +CC = gcc +CXX = g++ +INCLUDEDIRS = -I ../../include -I ../../src -I ../../lexlib -I ../ +CFLAGS = -DCURSES -DSCI_LEXER -Wall $(INCLUDEDIRS) +CXXFLAGS = $(CFLAGS) +ifdef LPEG_LEXER + CFLAGS += -DLPEG_LEXER -I ../src/lua +endif + +scintilla = ../../bin/scintilla.a + +all: jinx +jinx.o: jinx.c ; $(CC) $(CFLAGS) -c $< +jinx: jinx.o $(scintilla) ; $(CXX) $^ -o $@ -lncursesw +clean: ; rm -f jinx *.o diff --git a/dep/scintilla/scintilla-3.10.6/curses/jinx/jinx.c b/dep/scintilla/scintilla-3.10.6/curses/jinx/jinx.c new file mode 100644 index 00000000..c6a1b374 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/curses/jinx/jinx.c @@ -0,0 +1,118 @@ +// Copyright 2012-2019 Mitchell mitchell.att.foicica.com. See License.txt. + +#include +#include +#include + +#include "Scintilla.h" +#include "SciLexer.h" +#include "ScintillaCurses.h" + +#define SSM(m, w, l) scintilla_send_message(sci, m, w, l) + +typedef void Scintilla; + +void scnotification(Scintilla *view, int msg, void *lParam, void *wParam) { + //struct SCNotification *scn = (struct SCNotification *)lParam; + //printw("SCNotification received: %i", scn->nmhdr.code); +} + +int main(int argc, char **argv) { + setlocale(LC_CTYPE, ""); // for displaying UTF-8 characters properly + initscr(), raw(), cbreak(), noecho(), start_color(); + Scintilla *sci = scintilla_new(scnotification); + curs_set(0); // Scintilla draws its own cursor + + SSM(SCI_STYLESETFORE, STYLE_DEFAULT, 0xFFFFFF); + SSM(SCI_STYLESETBACK, STYLE_DEFAULT, 0); + SSM(SCI_STYLECLEARALL, 0, 0); +#if !LPEG_LEXER + SSM(SCI_SETLEXER, SCLEX_CPP, 0); + SSM(SCI_SETKEYWORDS, 0, (sptr_t)"int char"); + SSM(SCI_STYLESETFORE, SCE_C_COMMENT, 0x00FF00); + SSM(SCI_STYLESETFORE, SCE_C_COMMENTLINE, 0x00FF00); + SSM(SCI_STYLESETFORE, SCE_C_NUMBER, 0xFFFF00); + SSM(SCI_STYLESETFORE, SCE_C_WORD, 0xFF0000); + SSM(SCI_STYLESETFORE, SCE_C_STRING, 0xFF00FF); + SSM(SCI_STYLESETBOLD, SCE_C_OPERATOR, 1); +#else + SSM(SCI_SETLEXER, SCLEX_LPEG, 0); + SSM(SCI_SETPROPERTY, (uptr_t)"lexer.lpeg.home", (sptr_t)"../../lexlua"); + SSM(SCI_SETPROPERTY, (uptr_t)"lexer.lpeg.color.theme", (sptr_t)"curses"); + SSM(SCI_PRIVATELEXERCALL, SCI_GETDIRECTFUNCTION, + SSM(SCI_GETDIRECTFUNCTION, 0, 0)); + SSM(SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, SSM(SCI_GETDIRECTPOINTER, 0, 0)); + SSM(SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, (sptr_t)"ansi_c"); +#endif + SSM(SCI_INSERTTEXT, 0, (sptr_t) + "int main(int argc, char **argv) {\n" + " // Start up the gnome\n" + " gnome_init(\"stest\", \"1.0\", argc, argv);\n}"); + SSM(SCI_SETPROPERTY, (uptr_t)"fold", (sptr_t)"1"); + SSM(SCI_SETMARGINWIDTHN, 2, 1); + SSM(SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS); + SSM(SCI_SETMARGINSENSITIVEN, 2, 1); + SSM(SCI_SETAUTOMATICFOLD, SC_AUTOMATICFOLD_CLICK, 0); + SSM(SCI_SETFOCUS, 1, 0); + scintilla_refresh(sci); + + printf("\033[?1000h"); // enable mouse press and release events + //printf("\033[?1002h"); // enable mouse press, drag, and release events + //printf("\033[?1003h"); // enable mouse move, press, drag, and release events + mousemask(ALL_MOUSE_EVENTS, NULL); + mouseinterval(0); + + // Non-UTF8 input. + int c = 0; + MEVENT mouse; + WINDOW *win = scintilla_get_window(sci); + while ((c = wgetch(win)) != 'q') { + if (c != KEY_MOUSE) { + if (c == KEY_UP) c = SCK_UP; + else if (c == KEY_DOWN) c = SCK_DOWN; + else if (c == KEY_LEFT) c = SCK_LEFT; + else if (c == KEY_RIGHT) c = SCK_RIGHT; + scintilla_send_key(sci, c, FALSE, FALSE, FALSE); + } else if (getmouse(&mouse) == OK) { + int event = SCM_DRAG, button = 0; + if (mouse.bstate & BUTTON1_PRESSED) + event = SCM_PRESS, button = 1; + else if (mouse.bstate & BUTTON1_RELEASED) + event = SCM_RELEASE, button = 1; + struct timeval time = {0, 0}; + gettimeofday(&time, NULL); + int millis = time.tv_sec * 1000 + time.tv_usec / 1000; + scintilla_send_mouse(sci, event, millis, button, mouse.y, mouse.x, + mouse.bstate & BUTTON_SHIFT, + mouse.bstate & BUTTON_CTRL, + mouse.bstate & BUTTON_ALT); + } + scintilla_refresh(sci); + } + // UTF-8 input. + //SSM(SCI_SETCODEPAGE, SC_CP_UTF8, 0); + //wint_t c = {0}; + //WINDOW *win = scintilla_get_window(sci); + //while (c != 'q') { + // int status = wget_wch(win, &c); + // if (status == ERR) + // continue; + // else if (status == KEY_CODE_YES) { + // if (c == KEY_UP) c = SCK_UP; + // else if (c == KEY_DOWN) c = SCK_DOWN; + // else if (c == KEY_LEFT) c = SCK_LEFT; + // else if (c == KEY_RIGHT) c = SCK_RIGHT; + // } + // scintilla_send_key(sci, c, FALSE, FALSE, FALSE); + // scintilla_refresh(sci); + //} + + printf("\033[?1000l"); // disable mouse press and release events + //printf("\033[?1002l"); // disable mouse press, drag, and release events + //printf("\033[?1003l"); // disable mouse move, press, drag, and release + + scintilla_delete(sci); + endwin(); + + return 0; +} diff --git a/dep/scintilla/scintilla-3.10.6/delbin.bat b/dep/scintilla/scintilla-3.10.6/delbin.bat new file mode 100755 index 00000000..60ae6815 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/delbin.bat @@ -0,0 +1 @@ +@del /S /Q *.a *.aps *.bsc *.dll *.dsw *.exe *.idb *.ilc *.ild *.ilf *.ilk *.ils *.lib *.map *.ncb *.obj *.o *.opt *.pdb *.plg *.res *.sbr *.tds *.exp *.tlog >NUL: diff --git a/dep/scintilla/scintilla-3.10.6/doc/AddSource.txt b/dep/scintilla/scintilla-3.10.6/doc/AddSource.txt new file mode 100644 index 00000000..777f6f2c --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/doc/AddSource.txt @@ -0,0 +1,30 @@ +Some of the build files adapt to adding and removing source code files but most +must be modified by hand. Here is a list of directories and the build files that +must be modified or possibly need to be modified. +The Cocoa project.pbxproj file is complex and should be modified with Xcode. +The other build files can be edited manually. + +src: + cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj + gtk/makefile + qt/ScintillaEdit/ScintillaEdit.pro + qt/ScintillaEditBase/ScintillaEditBase.pro + win32/makefile + win32/scintilla.mak + -- possibly: + test/unit/makefile + test/unit/test.mak + +cocoa: + cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj + +gtk: + gtk/makefile + +qt: + qt/ScintillaEdit/ScintillaEdit.pro + qt/ScintillaEditBase/ScintillaEditBase.pro + +win32: + win32/makefile + win32/scintilla.mak diff --git a/dep/scintilla/scintilla-3.6.0/doc/Design.html b/dep/scintilla/scintilla-3.10.6/doc/Design.html similarity index 80% rename from dep/scintilla/scintilla-3.6.0/doc/Design.html rename to dep/scintilla/scintilla-3.10.6/doc/Design.html index 0ca231e8..d08c01d9 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/Design.html +++ b/dep/scintilla/scintilla-3.10.6/doc/Design.html @@ -6,6 +6,7 @@ + Scintilla and SciTE @@ -48,14 +49,14 @@ library and with limited use of templates.

- The currently supported platforms, Windows, GTK+/Linux and wxWindows are fairly similar in + The currently supported platforms, Windows, GTK/Linux, Cocoa and wxWidgets are fairly similar in many ways. Each has windows, menus and bitmaps. These features generally work in similar ways so each has a way to move a window or draw a red line. Sometimes one platform requires a sequence of calls rather than a single call. At other times, the differences are more profound. Reading - the Windows clipboard occurs synchronously but reading the GTK+ clipboard requires a request + the Windows clipboard occurs synchronously but reading the GTK clipboard requires a request call that will be asynchronously answered with a message containing the clipboard data. - The wxWindows platform is available from the wxWindows site + The wxWidgets platform is available from the wxWidgets site


@@ -66,7 +67,7 @@

The portability library is defined in Platform.h and is implemented once for each platform. - PlatWin.cxx defines the Windows variants of the methods and PlatGTK.cxx the GTK+ variants. + PlatWin.cxx defines the Windows variants of the methods and PlatGTK.cxx the GTK variants.

Several of the classes here hold platform specific object identifiers and act as proxies to @@ -82,29 +83,25 @@

These are simple classes provided to hold the commonly used geometric primitives. A PRectangle follows the Mac / Windows convention of not including its bottom and right sides - instead of including all its sides as is normal in GTK+. It is not called Rectangle as this may be + instead of including all its sides as is normal in GTK. It is not called Rectangle as this may be the name of a macro on Windows.

- Colour, ColourPair, Palette + ColourDesired

- Colour holds a platform specific colour identifier - COLORREF for Windows and GdkColor for - GTK+. The red, green and blue components that make up the colour are limited to the 8 bits of - precision available on Windows. ColourPairs are used because not all possible colours are - always available. Using an 8 bit colour mode, which is a common setting for both Windows and - GTK+, only 256 colours are possible on the display. Thus when an application asks for a dull - red, say #400000, it may only be allocated an already available colour such as #800000 or - #330000. With 16 or 2 colour modes even less choice is available and the application will - have to use the limited set of already available colours. + This is a simple class holding an expected colour. It is internally represented as a single + 32 bit integer in BGR format with 8 bits per colour, but also provides a convenient API to fetch + each component separately. + As a platform might not be able to represent the exact desired colour if it doesn't have 24 bit + depth available, it might not actually represent the exact desired colour but select a best fit + that it can actually render.

- A Palette object holds a set of colour pairs and can make the appropriate calls to ask to - allocate these colours and to see what the platform has decided will be allowed.

Font

- Font holds a platform specific font identifier - HFONT for Windows, GdkFont* for GTK+. It + Font holds a platform specific font identifier - HFONT for Windows, PangoFontDescription* for GTK. It does not own the identifier and so will not delete the platform font object in its destructor. Client code should call Destroy at appropriate times.

@@ -115,8 +112,8 @@ Surface is an abstraction over each platform's concept of somewhere that graphical drawing operations can be done. It may wrap an already created drawing place such as a window or be used to create a bitmap that can be drawn into and later copied onto another surface. On - Windows it wraps a HDC and possibly a HBITMAP. On GTK+ it wraps a GdkDrawable* and possibly a - GdkPixmap*. Other platform specific objects are created (and correctly destroyed) whenever + Windows it wraps a HDC and possibly a HBITMAP. On GTK it wraps a cairo_surface_t*. + Other platform specific objects are created (and correctly destroyed) whenever required to perform drawing actions.

@@ -132,7 +129,7 @@

Window acts as a proxy to a platform window allowing operations such as showing, moving, redrawing, and destroying to be performed. It contains a platform specific window identifier - - HWND for Windows, GtkWidget* for GTK+. + - HWND for Windows, GtkWidget* for GTK.

ListBox @@ -146,7 +143,7 @@

Menu is a small helper class for constructing popup menus. It contains the platform specific - menu identifier - HMENU for Windows, GtkItemFactory* for GTK+. Most of the work in + menu identifier - HMENU for Windows, GtkMenu* for GTK. Most of the work in constructing menus requires access to platform events and so is done in the Platform Events and API layer.

@@ -163,7 +160,7 @@

The bulk of Scintilla's code is platform independent. This is made up of the CellBuffer, - ContractionState, Document, Editor, Indicator, LineMarker, Style, ViewStyle, KeyMap, + ContractionState, Document, Editor, Indicator, LineMarker, Style, ViewStyle, KeyMap, ScintillaBase, CallTip, and AutoComplete primary classes.

@@ -203,14 +200,14 @@

The Editor object is central to Scintilla. It is responsible for displaying a document and - responding to user actions and requests from the container. It uses ContractionState, Indicator, - LineMarker, Style, and ViewStyle objects to display the document and a KeyMap class to - map key presses to functions. - The visibility of each line is kept in the ContractionState which is also responsible for mapping + responding to user actions and requests from the container. It uses ContractionState, Indicator, + LineMarker, Style, and ViewStyle objects to display the document and a KeyMap class to + map key presses to functions. + The visibility of each line is kept in the ContractionState which is also responsible for mapping from display lines to documents lines and vice versa.

- There may be multiple Editor objects attached to one Document object. Changes to a + There may be multiple Editor objects attached to one Document object. Changes to a document are broadcast to the editors through the DocWatcher mechanism.

@@ -227,20 +224,20 @@

Each platform uses different mechanisms for receiving events. On Windows, events are - received through messages and COM. On GTK+, callback functions are used. + received through messages and COM. On GTK, callback functions are used.

For each platform, a class is derived from ScintillaBase (and thus from Editor). This is - ScintillaWin on Windows and ScintillaGTK on GTK+. These classes are responsible for + ScintillaWin on Windows and ScintillaGTK on GTK. These classes are responsible for connecting to the platforms event mechanism and also to implement some virtual methods in Editor and ScintillaBase which are different on the platforms. For example, this layer has to - support this difference between the synchronous Windows clipboard and the asynchronous GTK+ + support this difference between the synchronous Windows clipboard and the asynchronous GTK clipboard.

The external API is defined in this layer as each platform has different preferred styles of - API - messages on Windows and function calls on GTK+. This also allows multiple APIs to be - defined on a platform. The currently available API on GTK+ is similar to the Windows API and + API - messages on Windows and function calls on GTK. This also allows multiple APIs to be + defined on a platform. The currently available API on GTK is similar to the Windows API and does not follow platform conventions well. A second API could be implemented here that did follow platform conventions.

diff --git a/dep/scintilla/scintilla-3.6.0/doc/Icons.html b/dep/scintilla/scintilla-3.10.6/doc/Icons.html similarity index 91% rename from dep/scintilla/scintilla-3.6.0/doc/Icons.html rename to dep/scintilla/scintilla-3.10.6/doc/Icons.html index 0bf302d1..d6053f1e 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/Icons.html +++ b/dep/scintilla/scintilla-3.10.6/doc/Icons.html @@ -6,6 +6,7 @@ + Scintilla icons @@ -26,10 +27,10 @@ Icons

- These images may be used under the same license as Scintilla. + These images may be used under the same license as Scintilla.

- Drawn by Iago Rubio, Philippe Lhoste, and Neil Hodgson. + Drawn by Iago Rubio, Philippe Lhoste, and Neil Hodgson.

zip format (70K) diff --git a/dep/scintilla/scintilla-3.10.6/doc/Indicators.png b/dep/scintilla/scintilla-3.10.6/doc/Indicators.png new file mode 100644 index 00000000..541e3de6 Binary files /dev/null and b/dep/scintilla/scintilla-3.10.6/doc/Indicators.png differ diff --git a/dep/scintilla/scintilla-3.10.6/doc/LPegLexer.html b/dep/scintilla/scintilla-3.10.6/doc/LPegLexer.html new file mode 100644 index 00000000..57b0622a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/doc/LPegLexer.html @@ -0,0 +1,2643 @@ + + + + + + + + Lua LPeg Lexers + + + + + + + + + + + +
Scintilla iconScintilla
+ +

Lua LPeg Lexers

+ +

Scintilla's LPeg lexer adds dynamic Lua + LPeg lexers to + Scintilla. It is the quickest way to add new or customized syntax + highlighting and code folding for programming languages to any + Scintilla-based text editor or IDE.

+ +

Features

+ +
    +
  • Support for over 100 programming languages.
  • +
  • Easy lexer embedding for multi-language lexers.
  • +
  • Universal color themes.
  • +
  • Comparable speed to native Scintilla lexers.
  • +
+ +

Enabling and Configuring the LPeg Lexer

+ +

Scintilla is not compiled with the LPeg lexer enabled by + default (it is present, but empty). You need to manually enable it with the + LPEG_LEXER flag when building Scintilla and its lexers. You + also need to build and link the Lua source files contained in Scintilla's + lua/src/ directory to lexers/LexLPeg.cxx. If your + application has its own copy of Lua, you can ignore Scintilla's copy and + link to yours. + +

At this time, only the GTK, curses, and MinGW32 (for win32) platform + makefiles facilitate enabling the LPeg lexer. For example, when building + Scintilla, run make LPEG_LEXER=1. User contributions to + facilitate this for the other platforms is encouraged.

+ +

When Scintilla is compiled with the LPeg lexer enabled, and after + selecting it as the lexer to use via + SCI_SETLEXER or + SCI_SETLEXERLANGUAGE, + the following property must be set via + SCI_SETPROPERTY:

+ + + + + + + + + +
lexer.lpeg.homeThe directory containing the Lua lexers. This is the path + where you included Scintilla's lexlua/ directory in + your application's installation location.
+ +

The following properties are optional and may or may not be set:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
lexer.lpeg.color.themeThe color theme to use. Color themes are located in the + lexlua/themes/ directory. Currently supported themes + are light, dark, scite, and + curses. Your application can define colors and styles + manually through Scintilla properties. The theme files have + examples.
foldFor Lua lexers that have a folder, folding is turned on if + fold is set to 1. The default is + 0.
fold.by.indentation + + For Lua lexers that do not have a folder, if + fold.by.indentation is set to 1, folding is + done based on indentation level (like Python). The default is + 0.
fold.line.commentsIf fold.line.comments is set to 1, + multiple, consecutive line comments are folded, and only the top-level + comment is shown. There is a small performance penalty for large + source files when this option and folding are enabled. The default is + 0.
fold.on.zero.sum.linesIf fold.on.zero.sum.lines is set to 1, + lines that contain both an ending and starting fold point are marked + as fold points. For example, the C line } else { would be + marked as a fold point. The default is 0.
+ +

Using the LPeg Lexer

+ +

Your application communicates with the LPeg lexer using Scintilla's + SCI_PRIVATELEXERCALL + API. The operation constants recognized by the LPeg lexer are based on + Scintilla's existing named constants. Note that some of the names of the + operations do not make perfect sense. This is a tradeoff in order to reuse + Scintilla's existing constants.

+ +

In the descriptions that follow, + SCI_PRIVATELEXERCALL(int operation, void *pointer) means you + would call Scintilla like + SendScintilla(sci, SCI_PRIVATELEXERCALL, operation, pointer);

+ +

Usage Example

+ +

The curses platform demo, jinx, has a C-source example for using the LPeg + lexer. Additionally, here is a pseudo-code example:

+ +

+    init_app() {
+      sci = scintilla_new()
+    }
+
+    create_doc() {
+      doc = SendScintilla(sci, SCI_CREATEDOCUMENT, 0, 0)
+      SendScintilla(sci, SCI_SETDOCPOINTER, 0, doc)
+      SendScintilla(sci, SCI_SETLEXERLANGUAGE, 0, "lpeg")
+      home = "/home/mitchell/app/lua_lexers"
+      SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.home", home)
+      SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.color.theme", "light")
+      fn = SendScintilla(sci, SCI_GETDIRECTFUNCTION, 0, 0)
+      SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETDIRECTFUNCTION, fn)
+      psci = SendScintilla(sci, SCI_GETDIRECTPOINTER, 0, 0)
+      SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, psci)
+      SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua")
+    }
+
+    set_lexer(lang) {
+      psci = SendScintilla(sci, SCI_GETDIRECTPOINTER, 0, 0)
+      SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, psci)
+      SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, lang)
+    }
+    
+ + SCI_PRIVATELEXERCALL(SCI_CHANGELEXERSTATE, lua_State *L)
+ SCI_PRIVATELEXERCALL(SCI_GETDIRECTFUNCTION, int SciFnDirect)
+ SCI_PRIVATELEXERCALL(SCI_GETLEXERLANGUAGE, char *languageName) → int
+ SCI_PRIVATELEXERCALL(SCI_GETSTATUS, char *errorMessage) → int
+ SCI_PRIVATELEXERCALL(int styleNum, char *styleName) → int
+ SCI_PRIVATELEXERCALL(SCI_SETDOCPOINTER, int sci)
+ SCI_PRIVATELEXERCALL(SCI_SETLEXERLANGUAGE, languageName)
+
+ +

SCI_PRIVATELEXERCALL(SCI_CHANGELEXERSTATE, lua_State *L)
+ Tells the LPeg lexer to use L as its Lua state instead of + creating a separate state.

+ +

L must have already opened the "base", "string", "table", + "package", and "lpeg" libraries. If L is a Lua 5.1 state, it + must have also opened the "io" library.

+ +

The LPeg lexer will create a single lexer package (that can + be used with Lua's require function), as well as a number of + other variables in the LUA_REGISTRYINDEX table with the "sci_" + prefix.

+ +

Rather than including the path to Scintilla's Lua lexers in the + package.path of the given Lua state, set the "lexer.lpeg.home" + property instead. The LPeg lexer uses that property to find and load + lexers.

+ +

Usage:

+ +

+    lua = luaL_newstate()
+    SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_CHANGELEXERSTATE, lua)
+    
+ +

SCI_PRIVATELEXERCALL(SCI_GETDIRECTFUNCTION, SciFnDirect)
+ Tells the LPeg lexer the address of SciFnDirect, the function + that handles Scintilla messages.

+ +

Despite the name SCI_GETDIRECTFUNCTION, it only notifies the + LPeg lexer what the value of SciFnDirect obtained from + SCI_GETDIRECTFUNCTION + is. It does not return anything. Use this if you would like to have the LPeg + lexer set all Lua lexer styles automatically. This is useful for maintaining + a consistent color theme. Do not use this if your application maintains its + own color theme.

+ +

If you use this call, it must be made once for each + Scintilla document that was created using Scintilla's + SCI_CREATEDOCUMENT. + You must also use the + SCI_SETDOCPOINTER LPeg lexer + API call.

+ +

Usage:

+ +

+    fn = SendScintilla(sci, SCI_GETDIRECTFUNCTION, 0, 0)
+    SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETDIRECTFUNCTION, fn)
+    
+ +

See also: SCI_SETDOCPOINTER

+ +

SCI_PRIVATELEXERCALL(SCI_GETLEXERLANGUAGE, char *languageName) → int
+ Returns the length of the string name of the current Lua lexer or stores the + name into the given buffer. If the buffer is long enough, the name is + terminated by a 0 character.

+ +

For parent lexers with embedded children or child lexers embedded into + parents, the name is in "lexer/current" format, where "lexer" is the actual + lexer's name and "current" is the parent or child lexer at the current caret + position. In order for this to work, you must have called + SCI_GETDIRECTFUNCTION + and + SCI_SETDOCPOINTER.

+ +

SCI_PRIVATELEXERCALL(SCI_GETSTATUS, char *errorMessage) → int
+ Returns the length of the error message of the LPeg lexer or Lua lexer error + that occurred (if any), or stores the error message into the given buffer.

+ +

If no error occurred, the returned message will be empty.

+ +

Since the LPeg lexer does not throw errors as they occur, errors can only + be handled passively. Note that the LPeg lexer does print all errors to + stderr.

+ +

Usage:

+ +

+    SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETSTATUS, errmsg)
+    if (strlen(errmsg) > 0) { /* handle error */ }
+    
+ +

SCI_PRIVATELEXERCALL(int styleNum, char *styleName) → int
+ Returns the length of the token name associated with the given style number + or stores the style name into the given buffer. If the buffer is long + enough, the string is terminated by a 0 character.

+ +

Usage:

+ +

+    style = SendScintilla(sci, SCI_GETSTYLEAT, pos, 0)
+    SendScintilla(sci, SCI_PRIVATELEXERCALL, style, token)
+    // token now contains the name of the style at pos
+    
+ +

SCI_PRIVATELEXERCALL(SCI_SETDOCPOINTER, int sci)
+ Tells the LPeg lexer the address of the Scintilla window (obtained via + Scintilla's + SCI_GETDIRECTPOINTER) + currently in use.

+ +

Despite the name SCI_SETDOCPOINTER, it has no relationship + to Scintilla documents.

+ +

Use this call only if you are using the + SCI_GETDIRECTFUNCTION + LPeg lexer API call. It must be made before each call to + the SCI_SETLEXERLANGUAGE + LPeg lexer API call.

+ +

Usage:

+ +

+    SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, sci)
+    
+ +

See also: SCI_GETDIRECTFUNCTION, + SCI_SETLEXERLANGUAGE

+ +

SCI_PRIVATELEXERCALL(SCI_SETLEXERLANGUAGE, const char *languageName)
+ Sets the current Lua lexer to languageName.

+ +

If you are having the LPeg lexer set the Lua lexer styles automatically, + make sure you call the + SCI_SETDOCPOINTER + LPeg lexer API first.

+ +

Usage:

+ +

+    SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua")
+    
+ +

See also: SCI_SETDOCPOINTER

+ +

Using Scintilla as a Lua Library

+ +

In order to use Scintilla as a Lua library, simply place the lexlua/ + directory in your Lua path (or modify Lua’s package.path accordingly), + require() the library and load() a lexer, and call that lexer’s + lex() function. Here is an example interactive Lua session doing this:

+ +
$> lua
+Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
+> lexer_path = '/home/mitchell/code/scintilla/lexlua/?.lua'
+> package.path = package.path..';'..lexer_path
+> c = require('lexer').load('ansi_c')
+> tokens = c:lex('int void main() { return 0; }')
+> for i = 1, #tokens, 2 do print(tokens[i], tokens[i+1]) end
+type    4
+ansi_c_whitespace   5
+type    9
+ansi_c_whitespace   10
+identifier  14
+operator    15
+operator    16
+ansi_c_whitespace   17
+operator    18
+ansi_c_whitespace   19
+keyword 25
+ansi_c_whitespace   26
+number  27
+operator    28
+ansi_c_whitespace   29
+operator    30
+    
+ +

Writing Lua Lexers

+ +

Lexers highlight the syntax of source code. Scintilla (the editing component + behind Textadept) traditionally uses static, compiled C++ + lexers which are notoriously difficult to create and/or extend. On the other + hand, Lua makes it easy to to rapidly create new lexers, extend existing + ones, and embed lexers within one another. Lua lexers tend to be more + readable than C++ lexers too.

+ +

Lexers are Parsing Expression Grammars, or PEGs, composed with the Lua + LPeg library. The following table comes from the LPeg documentation and + summarizes all you need to know about constructing basic LPeg patterns. This + module provides convenience functions for creating and working with other + more advanced patterns and concepts.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Operator Description
lpeg.P(string) Matches string literally.
lpeg.P(n) Matches exactly n characters.
lpeg.S(string) Matches any character in set string.
lpeg.R("xy") Matches any character between range x and y.
patt^n Matches at least n repetitions of patt.
patt^-n Matches at most n repetitions of patt.
patt1 * patt2 Matches patt1 followed by patt2.
patt1 + patt2 Matches patt1 or patt2 (ordered choice).
patt1 - patt2 Matches patt1 if patt2 does not match.
-patt Equivalent to ("" - patt).
#patt Matches patt but consumes no input.
+ + +

The first part of this document deals with rapidly constructing a simple + lexer. The next part deals with more advanced techniques, such as custom + coloring and embedding lexers within one another. Following that is a + discussion about code folding, or being able to tell Scintilla which code + blocks are "foldable" (temporarily hideable from view). After that are + instructions on how to use Lua lexers with the aforementioned Textadept + editor. Finally there are comments on lexer performance and limitations.

+ +

+ +

Lexer Basics

+ +

The lexlua/ directory contains all lexers, including your new one. Before + attempting to write one from scratch though, first determine if your + programming language is similar to any of the 100+ languages supported. If + so, you may be able to copy and modify that lexer, saving some time and + effort. The filename of your lexer should be the name of your programming + language in lower case followed by a .lua extension. For example, a new Lua + lexer has the name lua.lua.

+ +

Note: Try to refrain from using one-character language names like "c", "d", + or "r". For example, Lua lexers for those languages are named "ansi_c", "dmd", and "rstats", + respectively.

+ +

+ +

New Lexer Template

+ +

There is a lexlua/template.txt file that contains a simple template for a + new lexer. Feel free to use it, replacing the '?'s with the name of your + lexer. Consider this snippet from the template:

+ +

+    -- ? LPeg lexer.
+
+    local lexer = require('lexer')
+    local token, word_match = lexer.token, lexer.word_match
+    local P, R, S = lpeg.P, lpeg.R, lpeg.S
+
+    local lex = lexer.new('?')
+
+    -- Whitespace.
+    local ws = token(lexer.WHITESPACE, lexer.space^1)
+    lex:add_rule('whitespace', ws)
+
+    [...]
+
+    return lex
+    
+ +

The first 3 lines of code simply define often used convenience variables. The + fourth and last lines define and return the lexer object + Scintilla uses; they are very important and must be part of every lexer. The + fifth line defines something called a "token", an essential building block of + lexers. You will learn about tokens shortly. The sixth line defines a lexer + grammar rule, which you will learn about later, as well as token styles. (Be + aware that it is common practice to combine these two lines for short rules.) + Note, however, the local prefix in front of variables, which is needed + so-as not to affect Lua's global environment. All in all, this is a minimal, + working lexer that you can build on.

+ +

+ +

Tokens

+ +

Take a moment to think about your programming language's structure. What kind + of key elements does it have? In the template shown earlier, one predefined + element all languages have is whitespace. Your language probably also has + elements like comments, strings, and keywords. Lexers refer to these elements + as "tokens". Tokens are the fundamental "building blocks" of lexers. Lexers + break down source code into tokens for coloring, which results in the syntax + highlighting familiar to you. It is up to you how specific your lexer is when + it comes to tokens. Perhaps only distinguishing between keywords and + identifiers is necessary, or maybe recognizing constants and built-in + functions, methods, or libraries is desirable. The Lua lexer, for example, + defines 11 tokens: whitespace, keywords, built-in functions, constants, + built-in libraries, identifiers, strings, comments, numbers, labels, and + operators. Even though constants, built-in functions, and built-in libraries + are subsets of identifiers, Lua programmers find it helpful for the lexer to + distinguish between them all. It is perfectly acceptable to just recognize + keywords and identifiers.

+ +

In a lexer, tokens consist of a token name and an LPeg pattern that matches a + sequence of characters recognized as an instance of that token. Create tokens + using the lexer.token() function. Let us examine the "whitespace" token + defined in the template shown earlier:

+ +

+    local ws = token(lexer.WHITESPACE, lexer.space^1)
+    
+ +

At first glance, the first argument does not appear to be a string name and + the second argument does not appear to be an LPeg pattern. Perhaps you + expected something like:

+ +

+    local ws = token('whitespace', S('\t\v\f\n\r ')^1)
+    
+ +

The lexer module actually provides a convenient list of common token names + and common LPeg patterns for you to use. Token names include + lexer.DEFAULT, lexer.WHITESPACE, lexer.COMMENT, + lexer.STRING, lexer.NUMBER, lexer.KEYWORD, + lexer.IDENTIFIER, lexer.OPERATOR, lexer.ERROR, + lexer.PREPROCESSOR, lexer.CONSTANT, lexer.VARIABLE, + lexer.FUNCTION, lexer.CLASS, lexer.TYPE, lexer.LABEL, + lexer.REGEX, and lexer.EMBEDDED. Patterns include + lexer.any, lexer.ascii, lexer.extend, lexer.alpha, + lexer.digit, lexer.alnum, lexer.lower, lexer.upper, + lexer.xdigit, lexer.cntrl, lexer.graph, lexer.print, + lexer.punct, lexer.space, lexer.newline, + lexer.nonnewline, lexer.nonnewline_esc, lexer.dec_num, + lexer.hex_num, lexer.oct_num, lexer.integer, + lexer.float, and lexer.word. You may use your own token names if + none of the above fit your language, but an advantage to using predefined + token names is that your lexer's tokens will inherit the universal syntax + highlighting color theme used by your text editor.

+ +

+ +
Example Tokens
+ +

So, how might you define other tokens like keywords, comments, and strings? + Here are some examples.

+ +

Keywords

+ +

Instead of matching n keywords with n P('keyword_n') ordered + choices, use another convenience function: lexer.word_match(). It is + much easier and more efficient to write word matches like:

+ +

+    local keyword = token(lexer.KEYWORD, lexer.word_match[[
+      keyword_1 keyword_2 ... keyword_n
+    ]])
+
+    local case_insensitive_keyword = token(lexer.KEYWORD, lexer.word_match([[
+      KEYWORD_1 keyword_2 ... KEYword_n
+    ]], true))
+
+    local hyphened_keyword = token(lexer.KEYWORD, lexer.word_match[[
+      keyword-1 keyword-2 ... keyword-n
+    ]])
+    
+ +

In order to more easily separate or categorize keyword sets, you can use Lua + line comments within keyword strings. Such comments will be ignored. For + example:

+ +

+    local keyword = token(lexer.KEYWORD, lexer.word_match[[
+      -- Version 1 keywords.
+      keyword_11, keyword_12 ... keyword_1n
+      -- Version 2 keywords.
+      keyword_21, keyword_22 ... keyword_2n
+      ...
+      -- Version N keywords.
+      keyword_m1, keyword_m2 ... keyword_mn
+    ]])
+    
+ +

Comments

+ +

Line-style comments with a prefix character(s) are easy to express with LPeg:

+ +

+    local shell_comment = token(lexer.COMMENT, '#' * lexer.nonnewline^0)
+    local c_line_comment = token(lexer.COMMENT,
+                                 '//' * lexer.nonnewline_esc^0)
+    
+ +

The comments above start with a '#' or "//" and go to the end of the line. + The second comment recognizes the next line also as a comment if the current + line ends with a '\' escape character.

+ +

C-style "block" comments with a start and end delimiter are also easy to + express:

+ +

+    local c_comment = token(lexer.COMMENT,
+                            '/*' * (lexer.any - '*/')^0 * P('*/')^-1)
+    
+ +

This comment starts with a "/*" sequence and contains anything up to and + including an ending "*/" sequence. The ending "*/" is optional so the lexer + can recognize unfinished comments as comments and highlight them properly.

+ +

Strings

+ +

It is tempting to think that a string is not much different from the block + comment shown above in that both have start and end delimiters:

+ +

+    local dq_str = '"' * (lexer.any - '"')^0 * P('"')^-1
+    local sq_str = "'" * (lexer.any - "'")^0 * P("'")^-1
+    local simple_string = token(lexer.STRING, dq_str + sq_str)
+    
+ +

However, most programming languages allow escape sequences in strings such + that a sequence like "\"" in a double-quoted string indicates that the + '"' is not the end of the string. The above token incorrectly matches + such a string. Instead, use the lexer.delimited_range() convenience + function.

+ +

+    local dq_str = lexer.delimited_range('"')
+    local sq_str = lexer.delimited_range("'")
+    local string = token(lexer.STRING, dq_str + sq_str)
+    
+ +

In this case, the lexer treats '\' as an escape character in a string + sequence.

+ +

Numbers

+ +

Most programming languages have the same format for integer and float tokens, + so it might be as simple as using a couple of predefined LPeg patterns:

+ +

+    local number = token(lexer.NUMBER, lexer.float + lexer.integer)
+    
+ +

However, some languages allow postfix characters on integers.

+ +

+    local integer = P('-')^-1 * (lexer.dec_num * S('lL')^-1)
+    local number = token(lexer.NUMBER, lexer.float + lexer.hex_num + integer)
+    
+ +

Your language may need other tweaks, but it is up to you how fine-grained you + want your highlighting to be. After all, you are not writing a compiler or + interpreter!

+ +

+ +

Rules

+ +

Programming languages have grammars, which specify valid token structure. For + example, comments usually cannot appear within a string. Grammars consist of + rules, which are simply combinations of tokens. Recall from the lexer + template the lexer.add_rule() call, which adds a rule to the lexer's + grammar:

+ +

+    lex:add_rule('whitespace', ws)
+    
+ +

Each rule has an associated name, but rule names are completely arbitrary and + serve only to identify and distinguish between different rules. Rule order is + important: if text does not match the first rule added to the grammar, the + lexer tries to match the second rule added, and so on. Right now this lexer + simply matches whitespace tokens under a rule named "whitespace".

+ +

To illustrate the importance of rule order, here is an example of a + simplified Lua lexer:

+ +

+    lex:add_rule('whitespace', token(lexer.WHITESPACE, ...))
+    lex:add_rule('keyword', token(lexer.KEYWORD, ...))
+    lex:add_rule('identifier', token(lexer.IDENTIFIER, ...))
+    lex:add_rule('string', token(lexer.STRING, ...))
+    lex:add_rule('comment', token(lexer.COMMENT, ...))
+    lex:add_rule('number', token(lexer.NUMBER, ...))
+    lex:add_rule('label', token(lexer.LABEL, ...))
+    lex:add_rule('operator', token(lexer.OPERATOR, ...))
+    
+ +

Note how identifiers come after keywords. In Lua, as with most programming + languages, the characters allowed in keywords and identifiers are in the same + set (alphanumerics plus underscores). If the lexer added the "identifier" + rule before the "keyword" rule, all keywords would match identifiers and thus + incorrectly highlight as identifiers instead of keywords. The same idea + applies to function, constant, etc. tokens that you may want to distinguish + between: their rules should come before identifiers.

+ +

So what about text that does not match any rules? For example in Lua, the '!' + character is meaningless outside a string or comment. Normally the lexer + skips over such text. If instead you want to highlight these "syntax errors", + add an additional end rule:

+ +

+    lex:add_rule('whitespace', ws)
+    ...
+    lex:add_rule('error', token(lexer.ERROR, lexer.any))
+    
+ +

This identifies and highlights any character not matched by an existing + rule as a lexer.ERROR token.

+ +

Even though the rules defined in the examples above contain a single token, + rules may consist of multiple tokens. For example, a rule for an HTML tag + could consist of a tag token followed by an arbitrary number of attribute + tokens, allowing the lexer to highlight all tokens separately. That rule + might look something like this:

+ +

+    lex:add_rule('tag', tag_start * (ws * attributes)^0 * tag_end^-1)
+    
+ +

Note however that lexers with complex rules like these are more prone to lose + track of their state, especially if they span multiple lines.

+ +

+ +

Summary

+ +

Lexers primarily consist of tokens and grammar rules. At your disposal are a + number of convenience patterns and functions for rapidly creating a lexer. If + you choose to use predefined token names for your tokens, you do not have to + define how the lexer highlights them. The tokens will inherit the default + syntax highlighting color theme your editor uses.

+ +

+ +

Advanced Techniques

+ +

+ +

Styles and Styling

+ +

The most basic form of syntax highlighting is assigning different colors to + different tokens. Instead of highlighting with just colors, Scintilla allows + for more rich highlighting, or "styling", with different fonts, font sizes, + font attributes, and foreground and background colors, just to name a few. + The unit of this rich highlighting is called a "style". Styles are simply + strings of comma-separated property settings. By default, lexers associate + predefined token names like lexer.WHITESPACE, lexer.COMMENT, + lexer.STRING, etc. with particular styles as part of a universal color + theme. These predefined styles include lexer.STYLE_CLASS, + lexer.STYLE_COMMENT, lexer.STYLE_CONSTANT, + lexer.STYLE_ERROR, lexer.STYLE_EMBEDDED, + lexer.STYLE_FUNCTION, lexer.STYLE_IDENTIFIER, + lexer.STYLE_KEYWORD, lexer.STYLE_LABEL, lexer.STYLE_NUMBER, + lexer.STYLE_OPERATOR, lexer.STYLE_PREPROCESSOR, + lexer.STYLE_REGEX, lexer.STYLE_STRING, lexer.STYLE_TYPE, + lexer.STYLE_VARIABLE, and lexer.STYLE_WHITESPACE. Like with + predefined token names and LPeg patterns, you may define your own styles. At + their core, styles are just strings, so you may create new ones and/or modify + existing ones. Each style consists of the following comma-separated settings:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Setting Description
font:name The name of the font the style uses.
size:int The size of the font the style uses.
[not]bold Whether or not the font face is bold.
weight:int The weight or boldness of a font, between 1 and 999.
[not]italics Whether or not the font face is italic.
[not]underlined Whether or not the font face is underlined.
fore:color The foreground color of the font face.
back:color The background color of the font face.
[not]eolfilled Does the background color extend to the end of the line?
case:char The case of the font ('u': upper, 'l': lower, 'm': normal).
[not]visible Whether or not the text is visible.
[not]changeable Whether the text is changeable or read-only.
+ + +

Specify font colors in either "#RRGGBB" format, "0xBBGGRR" format, or the + decimal equivalent of the latter. As with token names, LPeg patterns, and + styles, there is a set of predefined color names, but they vary depending on + the current color theme in use. Therefore, it is generally not a good idea to + manually define colors within styles in your lexer since they might not fit + into a user's chosen color theme. Try to refrain from even using predefined + colors in a style because that color may be theme-specific. Instead, the best + practice is to either use predefined styles or derive new color-agnostic + styles from predefined ones. For example, Lua "longstring" tokens use the + existing lexer.STYLE_STRING style instead of defining a new one.

+ +

+ +
Example Styles
+ +

Defining styles is pretty straightforward. An empty style that inherits the + default theme settings is simply an empty string:

+ +

+    local style_nothing = ''
+    
+ +

A similar style but with a bold font face looks like this:

+ +

+    local style_bold = 'bold'
+    
+ +

If you want the same style, but also with an italic font face, define the new + style in terms of the old one:

+ +

+    local style_bold_italic = style_bold..',italics'
+    
+ +

This allows you to derive new styles from predefined ones without having to + rewrite them. This operation leaves the old style unchanged. Thus if you + had a "static variable" token whose style you wanted to base off of + lexer.STYLE_VARIABLE, it would probably look like:

+ +

+    local style_static_var = lexer.STYLE_VARIABLE..',italics'
+    
+ +

The color theme files in the lexlua/themes/ folder give more examples of + style definitions.

+ +

+ +

Token Styles

+ +

Lexers use the lexer.add_style() function to assign styles to + particular tokens. Recall the token definition and from the lexer template:

+ +

+    local ws = token(lexer.WHITESPACE, lexer.space^1)
+    lex:add_rule('whitespace', ws)
+    
+ +

Why is a style not assigned to the lexer.WHITESPACE token? As mentioned + earlier, lexers automatically associate tokens that use predefined token + names with a particular style. Only tokens with custom token names need + manual style associations. As an example, consider a custom whitespace token:

+ +

+    local ws = token('custom_whitespace', lexer.space^1)
+    
+ +

Assigning a style to this token looks like:

+ +

+    lex:add_style('custom_whitespace', lexer.STYLE_WHITESPACE)
+    
+ +

Do not confuse token names with rule names. They are completely different + entities. In the example above, the lexer associates the "custom_whitespace" + token with the existing style for lexer.WHITESPACE tokens. If instead you + prefer to color the background of whitespace a shade of grey, it might look + like:

+ +

+    local custom_style = lexer.STYLE_WHITESPACE..',back:$(color.grey)'
+    lex:add_style('custom_whitespace', custom_style)
+    
+ +

Notice that the lexer peforms Scintilla-style "$()" property expansion. + You may also use "%()". Remember to refrain from assigning specific colors in + styles, but in this case, all user color themes probably define the + "color.grey" property.

+ +

+ +

Line Lexers

+ +

By default, lexers match the arbitrary chunks of text passed to them by + Scintilla. These chunks may be a full document, only the visible part of a + document, or even just portions of lines. Some lexers need to match whole + lines. For example, a lexer for the output of a file "diff" needs to know if + the line started with a '+' or '-' and then style the entire line + accordingly. To indicate that your lexer matches by line, create the lexer + with an extra parameter:

+ +

+    local lex = lexer.new('?', {lex_by_line = true})
+    
+ +

Now the input text for the lexer is a single line at a time. Keep in mind + that line lexers do not have the ability to look ahead at subsequent lines.

+ +

+ +

Embedded Lexers

+ +

Lexers embed within one another very easily, requiring minimal effort. In the + following sections, the lexer being embedded is called the "child" lexer and + the lexer a child is being embedded in is called the "parent". For example, + consider an HTML lexer and a CSS lexer. Either lexer stands alone for styling + their respective HTML and CSS files. However, CSS can be embedded inside + HTML. In this specific case, the CSS lexer is the "child" lexer with the HTML + lexer being the "parent". Now consider an HTML lexer and a PHP lexer. This + sounds a lot like the case with CSS, but there is a subtle difference: PHP + embeds itself into HTML while CSS is embedded in HTML. This fundamental + difference results in two types of embedded lexers: a parent lexer that + embeds other child lexers in it (like HTML embedding CSS), and a child lexer + that embeds itself into a parent lexer (like PHP embedding itself in HTML).

+ +

+ +
Parent Lexer
+ +

Before embedding a child lexer into a parent lexer, the parent lexer needs to + load the child lexer. This is done with the lexer.load() function. For + example, loading the CSS lexer within the HTML lexer looks like:

+ +

+    local css = lexer.load('css')
+    
+ +

The next part of the embedding process is telling the parent lexer when to + switch over to the child lexer and when to switch back. The lexer refers to + these indications as the "start rule" and "end rule", respectively, and are + just LPeg patterns. Continuing with the HTML/CSS example, the transition from + HTML to CSS is when the lexer encounters a "style" tag with a "type" + attribute whose value is "text/css":

+ +

+    local css_tag = P('<style') * P(function(input, index)
+      if input:find('^[^>]+type="text/css"', index) then
+        return index
+      end
+    end)
+    
+ +

This pattern looks for the beginning of a "style" tag and searches its + attribute list for the text "type="text/css"". (In this simplified example, + the Lua pattern does not consider whitespace between the '=' nor does it + consider that using single quotes is valid.) If there is a match, the + functional pattern returns a value instead of nil. In this case, the value + returned does not matter because we ultimately want to style the "style" tag + as an HTML tag, so the actual start rule looks like this:

+ +

+    local css_start_rule = #css_tag * tag
+    
+ +

Now that the parent knows when to switch to the child, it needs to know when + to switch back. In the case of HTML/CSS, the switch back occurs when the + lexer encounters an ending "style" tag, though the lexer should still style + the tag as an HTML tag:

+ +

+    local css_end_rule = #P('</style>') * tag
+    
+ +

Once the parent loads the child lexer and defines the child's start and end + rules, it embeds the child with the lexer.embed() function:

+ +

+    lex:embed(css, css_start_rule, css_end_rule)
+    
+ +

+ +
Child Lexer
+ +

The process for instructing a child lexer to embed itself into a parent is + very similar to embedding a child into a parent: first, load the parent lexer + into the child lexer with the lexer.load() function and then create + start and end rules for the child lexer. However, in this case, call + lexer.embed() with switched arguments. For example, in the PHP lexer:

+ +

+    local html = lexer.load('html')
+    local php_start_rule = token('php_tag', '<?php ')
+    local php_end_rule = token('php_tag', '?>')
+    lex:add_style('php_tag', lexer.STYLE_EMBEDDED)
+    html:embed(lex, php_start_rule, php_end_rule)
+    
+ +

+ +

Lexers with Complex State

+ +

A vast majority of lexers are not stateful and can operate on any chunk of + text in a document. However, there may be rare cases where a lexer does need + to keep track of some sort of persistent state. Rather than using lpeg.P + function patterns that set state variables, it is recommended to make use of + Scintilla's built-in, per-line state integers via lexer.line_state. It + was designed to accommodate up to 32 bit flags for tracking state. + lexer.line_from_position() will return the line for any position given + to an lpeg.P function pattern. (Any positions derived from that position + argument will also work.)

+ +

Writing stateful lexers is beyond the scope of this document.

+ +

+ +

Code Folding

+ +

When reading source code, it is occasionally helpful to temporarily hide + blocks of code like functions, classes, comments, etc. This is the concept of + "folding". In many Scintilla-based editors, such as Textadept, little indicators + in the editor margins appear next to code that can be folded at places called + "fold points". When the user clicks an indicator, the editor hides the code + associated with the indicator until the user clicks the indicator again. The + lexer specifies these fold points and what code exactly to fold.

+ +

The fold points for most languages occur on keywords or character sequences. + Examples of fold keywords are "if" and "end" in Lua and examples of fold + character sequences are '{', '}', "/*", and "*/" in C for code block and + comment delimiters, respectively. However, these fold points cannot occur + just anywhere. For example, lexers should not recognize fold keywords that + appear within strings or comments. The lexer.add_fold_point() function + allows you to conveniently define fold points with such granularity. For + example, consider C:

+ +

+    lex:add_fold_point(lexer.OPERATOR, '{', '}')
+    lex:add_fold_point(lexer.COMMENT, '/*', '*/')
+    
+ +

The first assignment states that any '{' or '}' that the lexer recognized as + an lexer.OPERATOR token is a fold point. Likewise, the second assignment + states that any "/*" or "*/" that the lexer recognizes as part of a + lexer.COMMENT token is a fold point. The lexer does not consider any + occurrences of these characters outside their defined tokens (such as in a + string) as fold points. How do you specify fold keywords? Here is an example + for Lua:

+ +

+    lex:add_fold_point(lexer.KEYWORD, 'if', 'end')
+    lex:add_fold_point(lexer.KEYWORD, 'do', 'end')
+    lex:add_fold_point(lexer.KEYWORD, 'function', 'end')
+    lex:add_fold_point(lexer.KEYWORD, 'repeat', 'until')
+    
+ +

If your lexer has case-insensitive keywords as fold points, simply add a + case_insensitive_fold_points = true option to lexer.new(), and + specify keywords in lower case.

+ +

If your lexer needs to do some additional processing in order to determine if + a token is a fold point, pass a function that returns an integer to + lex:add_fold_point(). Returning 1 indicates the token is a beginning fold + point and returning -1 indicates the token is an ending fold point. + Returning 0 indicates the token is not a fold point. For example:

+ +

+    local function fold_strange_token(text, pos, line, s, symbol)
+      if ... then
+        return 1 -- beginning fold point
+      elseif ... then
+        return -1 -- ending fold point
+      end
+      return 0
+    end
+
+    lex:add_fold_point('strange_token', '|', fold_strange_token)
+    
+ +

Any time the lexer encounters a '|' that is a "strange_token", it calls the + fold_strange_token function to determine if '|' is a fold point. The lexer + calls these functions with the following arguments: the text to identify fold + points in, the beginning position of the current line in the text to fold, + the current line's text, the position in the current line the fold point text + starts at, and the fold point text itself.

+ +

+ +

Fold by Indentation

+ +

Some languages have significant whitespace and/or no delimiters that indicate + fold points. If your lexer falls into this category and you would like to + mark fold points based on changes in indentation, create the lexer with a + fold_by_indentation = true option:

+ +

+    local lex = lexer.new('?', {fold_by_indentation = true})
+    
+ +

+ +

Using Lexers

+ +

+ +

Textadept

+ +

Put your lexer in your ~/.textadept/lexers/ directory so you do not + overwrite it when upgrading Textadept. Also, lexers in this directory + override default lexers. Thus, Textadept loads a user lua lexer instead of + the default lua lexer. This is convenient for tweaking a default lexer to + your liking. Then add a file type for your lexer if necessary.

+ +

+ +

Migrating Legacy Lexers

+ +

Legacy lexers are of the form:

+ +

+    local l = require('lexer')
+    local token, word_match = l.token, l.word_match
+    local P, R, S = lpeg.P, lpeg.R, lpeg.S
+
+    local M = {_NAME = '?'}
+
+    [... token and pattern definitions ...]
+
+    M._rules = {
+      {'rule', pattern},
+      [...]
+    }
+
+    M._tokenstyles = {
+      'token' = 'style',
+      [...]
+    }
+
+    M._foldsymbols = {
+      _patterns = {...},
+      ['token'] = {['start'] = 1, ['end'] = -1},
+      [...]
+    }
+
+    return M
+    
+ +

While such legacy lexers will be handled just fine without any + changes, it is recommended that you migrate yours. The migration process is + fairly straightforward:

+ +
    +
  1. Replace all instances of l with lexer, as it's better practice and + results in less confusion.
  2. +
  3. Replace local M = {_NAME = '?'} with local lex = lexer.new('?'), where + ? is the name of your legacy lexer. At the end of the lexer, change + return M to return lex.
  4. +
  5. Instead of defining rules towards the end of your lexer, define your rules + as you define your tokens and patterns using + lex:add_rule().
  6. +
  7. Similarly, any custom token names should have their styles immediately + defined using lex:add_style().
  8. +
  9. Convert any table arguments passed to lexer.word_match() to a + space-separated string of words.
  10. +
  11. Replace any calls to lexer.embed(M, child, ...) and + lexer.embed(parent, M, ...) with + lex:embed(child, ...) and parent:embed(lex, ...), + respectively.
  12. +
  13. Define fold points with simple calls to + lex:add_fold_point(). No need to mess with Lua + patterns anymore.
  14. +
  15. Any legacy lexer options such as M._FOLDBYINDENTATION, M._LEXBYLINE, + M._lexer, etc. should be added as table options to lexer.new().
  16. +
  17. Any external lexer rule fetching and/or modifications via lexer._RULES + should be changed to use lexer.get_rule() and + lexer.modify_rule().
  18. +
+ + +

As an example, consider the following sample legacy lexer:

+ +

+    local l = require('lexer')
+    local token, word_match = l.token, l.word_match
+    local P, R, S = lpeg.P, lpeg.R, lpeg.S
+
+    local M = {_NAME = 'legacy'}
+
+    local ws = token(l.WHITESPACE, l.space^1)
+    local comment = token(l.COMMENT, '#' * l.nonnewline^0)
+    local string = token(l.STRING, l.delimited_range('"'))
+    local number = token(l.NUMBER, l.float + l.integer)
+    local keyword = token(l.KEYWORD, word_match{'foo', 'bar', 'baz'})
+    local custom = token('custom', P('quux'))
+    local identifier = token(l.IDENTIFIER, l.word)
+    local operator = token(l.OPERATOR, S('+-*/%^=<>,.()[]{}'))
+
+    M._rules = {
+      {'whitespace', ws},
+      {'keyword', keyword},
+      {'custom', custom},
+      {'identifier', identifier},
+      {'string', string},
+      {'comment', comment},
+      {'number', number},
+      {'operator', operator}
+    }
+
+    M._tokenstyles = {
+      'custom' = l.STYLE_KEYWORD..',bold'
+    }
+
+    M._foldsymbols = {
+      _patterns = {'[{}]'},
+      [l.OPERATOR] = {['{'] = 1, ['}'] = -1}
+    }
+
+    return M
+    
+ +

Following the migration steps would yield:

+ +

+    local lexer = require('lexer')
+    local token, word_match = lexer.token, lexer.word_match
+    local P, R, S = lpeg.P, lpeg.R, lpeg.S
+
+    local lex = lexer.new('legacy')
+
+    lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))
+    lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[foo bar baz]]))
+    lex:add_rule('custom', token('custom', P('quux')))
+    lex:add_style('custom', lexer.STYLE_KEYWORD..',bold')
+    lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word))
+    lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"')))
+    lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0))
+    lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer))
+    lex:add_rule('operator', token(lexer.OPERATOR, S('+-*/%^=<>,.()[]{}')))
+
+    lex:add_fold_point(lexer.OPERATOR, '{', '}')
+
+    return lex
+    
+ +

+ +

Considerations

+ +

+ +

Performance

+ +

There might be some slight overhead when initializing a lexer, but loading a + file from disk into Scintilla is usually more expensive. On modern computer + systems, I see no difference in speed between Lua lexers and Scintilla's C++ + ones. Optimize lexers for speed by re-arranging lexer.add_rule() calls so + that the most common rules match first. Do keep in mind that order matters + for similar rules.

+ +

In some cases, folding may be far more expensive than lexing, particularly + in lexers with a lot of potential fold points. If your lexer is exhibiting + signs of slowness, try disabling folding your text editor first. If that + speeds things up, you can try reducing the number of fold points you added, + overriding lexer.fold() with your own implementation, or simply eliminating + folding support from your lexer.

+ +

+ +

Limitations

+ +

Embedded preprocessor languages like PHP cannot completely embed in their + parent languages in that the parent's tokens do not support start and end + rules. This mostly goes unnoticed, but code like

+ +

+    <div id="<?php echo $id; ?>">
+    
+ +

will not style correctly.

+ +

+ +

Troubleshooting

+ +

Errors in lexers can be tricky to debug. Lexers print Lua errors to + io.stderr and _G.print() statements to io.stdout. Running your editor + from a terminal is the easiest way to see errors as they occur.

+ +

+ +

Risks

+ +

Poorly written lexers have the ability to crash Scintilla (and thus its + containing application), so unsaved data might be lost. However, I have only + observed these crashes in early lexer development, when syntax errors or + pattern errors are present. Once the lexer actually starts styling text + (either correctly or incorrectly, it does not matter), I have not observed + any crashes.

+ +

+ +

Acknowledgements

+ +

Thanks to Peter Odding for his lexer post on the Lua mailing list + that inspired me, and thanks to Roberto Ierusalimschy for LPeg.

+ +

Lua lexer module API fields

+ +

+ +

lexer.CLASS (string)

+ +

The token name for class tokens.

+ +

+ +

lexer.COMMENT (string)

+ +

The token name for comment tokens.

+ +

+ +

lexer.CONSTANT (string)

+ +

The token name for constant tokens.

+ +

+ +

lexer.DEFAULT (string)

+ +

The token name for default tokens.

+ +

+ +

lexer.ERROR (string)

+ +

The token name for error tokens.

+ +

+ +

lexer.FOLD_BASE (number)

+ +

The initial (root) fold level.

+ +

+ +

lexer.FOLD_BLANK (number)

+ +

Flag indicating that the line is blank.

+ +

+ +

lexer.FOLD_HEADER (number)

+ +

Flag indicating the line is fold point.

+ +

+ +

lexer.FUNCTION (string)

+ +

The token name for function tokens.

+ +

+ +

lexer.IDENTIFIER (string)

+ +

The token name for identifier tokens.

+ +

+ +

lexer.KEYWORD (string)

+ +

The token name for keyword tokens.

+ +

+ +

lexer.LABEL (string)

+ +

The token name for label tokens.

+ +

+ +

lexer.NUMBER (string)

+ +

The token name for number tokens.

+ +

+ +

lexer.OPERATOR (string)

+ +

The token name for operator tokens.

+ +

+ +

lexer.PREPROCESSOR (string)

+ +

The token name for preprocessor tokens.

+ +

+ +

lexer.REGEX (string)

+ +

The token name for regex tokens.

+ +

+ +

lexer.STRING (string)

+ +

The token name for string tokens.

+ +

+ +

lexer.STYLE_BRACEBAD (string)

+ +

The style used for unmatched brace characters.

+ +

+ +

lexer.STYLE_BRACELIGHT (string)

+ +

The style used for highlighted brace characters.

+ +

+ +

lexer.STYLE_CALLTIP (string)

+ +

The style used by call tips if buffer.call_tip_use_style is set. + Only the font name, size, and color attributes are used.

+ +

+ +

lexer.STYLE_CLASS (string)

+ +

The style typically used for class definitions.

+ +

+ +

lexer.STYLE_COMMENT (string)

+ +

The style typically used for code comments.

+ +

+ +

lexer.STYLE_CONSTANT (string)

+ +

The style typically used for constants.

+ +

+ +

lexer.STYLE_CONTROLCHAR (string)

+ +

The style used for control characters. + Color attributes are ignored.

+ +

+ +

lexer.STYLE_DEFAULT (string)

+ +

The style all styles are based off of.

+ +

+ +

lexer.STYLE_EMBEDDED (string)

+ +

The style typically used for embedded code.

+ +

+ +

lexer.STYLE_ERROR (string)

+ +

The style typically used for erroneous syntax.

+ +

+ +

lexer.STYLE_FOLDDISPLAYTEXT (string)

+ +

The style used for fold display text.

+ +

+ +

lexer.STYLE_FUNCTION (string)

+ +

The style typically used for function definitions.

+ +

+ +

lexer.STYLE_IDENTIFIER (string)

+ +

The style typically used for identifier words.

+ +

+ +

lexer.STYLE_INDENTGUIDE (string)

+ +

The style used for indentation guides.

+ +

+ +

lexer.STYLE_KEYWORD (string)

+ +

The style typically used for language keywords.

+ +

+ +

lexer.STYLE_LABEL (string)

+ +

The style typically used for labels.

+ +

+ +

lexer.STYLE_LINENUMBER (string)

+ +

The style used for all margins except fold margins.

+ +

+ +

lexer.STYLE_NUMBER (string)

+ +

The style typically used for numbers.

+ +

+ +

lexer.STYLE_OPERATOR (string)

+ +

The style typically used for operators.

+ +

+ +

lexer.STYLE_PREPROCESSOR (string)

+ +

The style typically used for preprocessor statements.

+ +

+ +

lexer.STYLE_REGEX (string)

+ +

The style typically used for regular expression strings.

+ +

+ +

lexer.STYLE_STRING (string)

+ +

The style typically used for strings.

+ +

+ +

lexer.STYLE_TYPE (string)

+ +

The style typically used for static types.

+ +

+ +

lexer.STYLE_VARIABLE (string)

+ +

The style typically used for variables.

+ +

+ +

lexer.STYLE_WHITESPACE (string)

+ +

The style typically used for whitespace.

+ +

+ +

lexer.TYPE (string)

+ +

The token name for type tokens.

+ +

+ +

lexer.VARIABLE (string)

+ +

The token name for variable tokens.

+ +

+ +

lexer.WHITESPACE (string)

+ +

The token name for whitespace tokens.

+ +

+ +

lexer.alnum (pattern)

+ +

A pattern that matches any alphanumeric character ('A'-'Z', 'a'-'z', + '0'-'9').

+ +

+ +

lexer.alpha (pattern)

+ +

A pattern that matches any alphabetic character ('A'-'Z', 'a'-'z').

+ +

+ +

lexer.any (pattern)

+ +

A pattern that matches any single character.

+ +

+ +

lexer.ascii (pattern)

+ +

A pattern that matches any ASCII character (codes 0 to 127).

+ +

+ +

lexer.cntrl (pattern)

+ +

A pattern that matches any control character (ASCII codes 0 to 31).

+ +

+ +

lexer.dec_num (pattern)

+ +

A pattern that matches a decimal number.

+ +

+ +

lexer.digit (pattern)

+ +

A pattern that matches any digit ('0'-'9').

+ +

+ +

lexer.extend (pattern)

+ +

A pattern that matches any ASCII extended character (codes 0 to 255).

+ +

+ +

lexer.float (pattern)

+ +

A pattern that matches a floating point number.

+ +

+ +

lexer.fold_level (table, Read-only)

+ +

Table of fold level bit-masks for line numbers starting from zero. + Fold level masks are composed of an integer level combined with any of the + following bits:

+ +
    +
  • lexer.FOLD_BASE + The initial fold level.
  • +
  • lexer.FOLD_BLANK + The line is blank.
  • +
  • lexer.FOLD_HEADER + The line is a header, or fold point.
  • +
+ + +

+ +

lexer.graph (pattern)

+ +

A pattern that matches any graphical character ('!' to '~').

+ +

+ +

lexer.hex_num (pattern)

+ +

A pattern that matches a hexadecimal number.

+ +

+ +

lexer.indent_amount (table, Read-only)

+ +

Table of indentation amounts in character columns, for line numbers + starting from zero.

+ +

+ +

lexer.integer (pattern)

+ +

A pattern that matches either a decimal, hexadecimal, or octal number.

+ +

+ +

lexer.line_state (table)

+ +

Table of integer line states for line numbers starting from zero. + Line states can be used by lexers for keeping track of persistent states.

+ +

+ +

lexer.lower (pattern)

+ +

A pattern that matches any lower case character ('a'-'z').

+ +

+ +

lexer.newline (pattern)

+ +

A pattern that matches any set of end of line characters.

+ +

+ +

lexer.nonnewline (pattern)

+ +

A pattern that matches any single, non-newline character.

+ +

+ +

lexer.nonnewline_esc (pattern)

+ +

A pattern that matches any single, non-newline character or any set of end + of line characters escaped with '\'.

+ +

+ +

lexer.oct_num (pattern)

+ +

A pattern that matches an octal number.

+ +

+ +

lexer.path (string)

+ +

The path used to search for a lexer to load. + Identical in format to Lua's package.path string. + The default value is package.path.

+ +

+ +

lexer.print (pattern)

+ +

A pattern that matches any printable character (' ' to '~').

+ +

+ +

lexer.property (table)

+ +

Map of key-value string pairs.

+ +

+ +

lexer.property_expanded (table, Read-only)

+ +

Map of key-value string pairs with $() and %() variable replacement + performed in values.

+ +

+ +

lexer.property_int (table, Read-only)

+ +

Map of key-value pairs with values interpreted as numbers, or 0 if not + found.

+ +

+ +

lexer.punct (pattern)

+ +

A pattern that matches any punctuation character ('!' to '/', ':' to '@', + '[' to ''', '{' to '~').

+ +

+ +

lexer.space (pattern)

+ +

A pattern that matches any whitespace character ('\t', '\v', '\f', '\n', + '\r', space).

+ +

+ +

lexer.style_at (table, Read-only)

+ +

Table of style names at positions in the buffer starting from 1.

+ +

+ +

lexer.upper (pattern)

+ +

A pattern that matches any upper case character ('A'-'Z').

+ +

+ +

lexer.word (pattern)

+ +

A pattern that matches a typical word. Words begin with a letter or + underscore and consist of alphanumeric and underscore characters.

+ +

+ +

lexer.xdigit (pattern)

+ +

A pattern that matches any hexadecimal digit ('0'-'9', 'A'-'F', 'a'-'f').

+ +

Lua lexer module API functions

+ +

+ +

lexer.add_fold_point (lexer, token_name, start_symbol, end_symbol)

+ +

Adds to lexer lexer a fold point whose beginning and end tokens are string + token_name tokens with string content start_symbol and end_symbol, + respectively. + In the event that start_symbol may or may not be a fold point depending on + context, and that additional processing is required, end_symbol may be a + function that ultimately returns 1 (indicating a beginning fold point), + -1 (indicating an ending fold point), or 0 (indicating no fold point). + That function is passed the following arguments:

+ +
    +
  • text: The text being processed for fold points.
  • +
  • pos: The position in text of the beginning of the line currently + being processed.
  • +
  • line: The text of the line currently being processed.
  • +
  • s: The position of start_symbol in line.
  • +
  • symbol: start_symbol itself.
  • +
+ + +

Fields:

+ +
    +
  • lexer: The lexer to add a fold point to.
  • +
  • token_name: The token name of text that indicates a fold point.
  • +
  • start_symbol: The text that indicates the beginning of a fold point.
  • +
  • end_symbol: Either the text that indicates the end of a fold point, or + a function that returns whether or not start_symbol is a beginning fold + point (1), an ending fold point (-1), or not a fold point at all (0).
  • +
+ + +

Usage:

+ +
    +
  • lex:add_fold_point(lexer.OPERATOR, '{', '}')
  • +
  • lex:add_fold_point(lexer.KEYWORD, 'if', 'end')
  • +
  • lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#'))
  • +
  • lex:add_fold_point('custom', function(text, pos, line, s, symbol) + ... end)
  • +
+ + +

+ +

lexer.add_rule (lexer, id, rule)

+ +

Adds pattern rule identified by string id to the ordered list of rules + for lexer lexer.

+ +

Fields:

+ +
    +
  • lexer: The lexer to add the given rule to.
  • +
  • id: The id associated with this rule. It does not have to be the same + as the name passed to token().
  • +
  • rule: The LPeg pattern of the rule.
  • +
+ + +

See also:

+ + + + +

+ +

lexer.add_style (lexer, token_name, style)

+ +

Associates string token_name in lexer lexer with Scintilla style string + style. + Style strings are comma-separated property settings. Available property + settings are:

+ +
    +
  • font:name: Font name.
  • +
  • size:int: Font size.
  • +
  • bold or notbold: Whether or not the font face is bold.
  • +
  • weight:int: Font weight (between 1 and 999).
  • +
  • italics or notitalics: Whether or not the font face is italic.
  • +
  • underlined or notunderlined: Whether or not the font face is + underlined.
  • +
  • fore:color: Font face foreground color in "#RRGGBB" or 0xBBGGRR format.
  • +
  • back:color: Font face background color in "#RRGGBB" or 0xBBGGRR format.
  • +
  • eolfilled or noteolfilled: Whether or not the background color + extends to the end of the line.
  • +
  • case:char: Font case ('u' for uppercase, 'l' for lowercase, and 'm' for + mixed case).
  • +
  • visible or notvisible: Whether or not the text is visible.
  • +
  • changeable or notchangeable: Whether or not the text is changeable or + read-only.
  • +
+ + +

Property settings may also contain "$(property.name)" expansions for + properties defined in Scintilla, theme files, etc.

+ +

Fields:

+ +
    +
  • lexer: The lexer to add a style to.
  • +
  • token_name: The name of the token to associated with the style.
  • +
  • style: A style string for Scintilla.
  • +
+ + +

Usage:

+ +
    +
  • lex:add_style('longstring', lexer.STYLE_STRING)
  • +
  • lex:add_style('deprecated_function', lexer.STYLE_FUNCTION..',italics')
  • +
  • lex:add_style('visible_ws', + lexer.STYLE_WHITESPACE..',back:$(color.grey)')
  • +
+ + +

+ +

lexer.delimited_range (chars, single_line, no_escape, balanced)

+ +

Creates and returns a pattern that matches a range of text bounded by + chars characters. + This is a convenience function for matching more complicated delimited ranges + like strings with escape characters and balanced parentheses. single_line + indicates whether or not the range must be on a single line, no_escape + indicates whether or not to ignore '\' as an escape character, and balanced + indicates whether or not to handle balanced ranges like parentheses and + requires chars to be composed of two characters.

+ +

Fields:

+ +
    +
  • chars: The character(s) that bound the matched range.
  • +
  • single_line: Optional flag indicating whether or not the range must be + on a single line.
  • +
  • no_escape: Optional flag indicating whether or not the range end + character may be escaped by a '\' character.
  • +
  • balanced: Optional flag indicating whether or not to match a balanced + range, like the "%b" Lua pattern. This flag only applies if chars + consists of two different characters (e.g. "()").
  • +
+ + +

Usage:

+ +
    +
  • local dq_str_escapes = lexer.delimited_range('"')
  • +
  • local dq_str_noescapes = lexer.delimited_range('"', false, true)
  • +
  • local unbalanced_parens = lexer.delimited_range('()')
  • +
  • local balanced_parens = lexer.delimited_range('()', false, false, + true)
  • +
+ + +

Return:

+ +
    +
  • pattern
  • +
+ + +

See also:

+ + + + +

+ +

lexer.embed (lexer, child, start_rule, end_rule)

+ +

Embeds child lexer child in parent lexer lexer using patterns + start_rule and end_rule, which signal the beginning and end of the + embedded lexer, respectively.

+ +

Fields:

+ +
    +
  • lexer: The parent lexer.
  • +
  • child: The child lexer.
  • +
  • start_rule: The pattern that signals the beginning of the embedded + lexer.
  • +
  • end_rule: The pattern that signals the end of the embedded lexer.
  • +
+ + +

Usage:

+ +
    +
  • html:embed(css, css_start_rule, css_end_rule)
  • +
  • html:embed(lex, php_start_rule, php_end_rule) -- from php lexer
  • +
+ + +

+ +

lexer.fold (lexer, text, start_pos, start_line, start_level)

+ +

Determines fold points in a chunk of text text using lexer lexer, + returning a table of fold levels associated with line numbers. + text starts at position start_pos on line number start_line with a + beginning fold level of start_level in the buffer.

+ +

Fields:

+ +
    +
  • lexer: The lexer to fold text with.
  • +
  • text: The text in the buffer to fold.
  • +
  • start_pos: The position in the buffer text starts at, starting at + zero.
  • +
  • start_line: The line number text starts on.
  • +
  • start_level: The fold level text starts on.
  • +
+ + +

Return:

+ +
    +
  • table of fold levels associated with line numbers.
  • +
+ + +

+ +

lexer.fold_line_comments (prefix)

+ +

Returns a fold function (to be passed to lexer.add_fold_point()) that folds + consecutive line comments that start with string prefix.

+ +

Fields:

+ +
    +
  • prefix: The prefix string defining a line comment.
  • +
+ + +

Usage:

+ +
    +
  • lex:add_fold_point(lexer.COMMENT, '--', + lexer.fold_line_comments('--'))
  • +
  • lex:add_fold_point(lexer.COMMENT, '//', + lexer.fold_line_comments('//'))
  • +
+ + +

+ +

lexer.get_rule (lexer, id)

+ +

Returns the rule identified by string id.

+ +

Fields:

+ +
    +
  • lexer: The lexer to fetch a rule from.
  • +
  • id: The id of the rule to fetch.
  • +
+ + +

Return:

+ +
    +
  • pattern
  • +
+ + +

+ +

lexer.last_char_includes (s)

+ +

Creates and returns a pattern that verifies that string set s contains the + first non-whitespace character behind the current match position.

+ +

Fields:

+ +
    +
  • s: String character set like one passed to lpeg.S().
  • +
+ + +

Usage:

+ +
    +
  • local regex = lexer.last_char_includes('+-*!%^&|=,([{') * + lexer.delimited_range('/')
  • +
+ + +

Return:

+ +
    +
  • pattern
  • +
+ + +

+ +

lexer.lex (lexer, text, init_style)

+ +

Lexes a chunk of text text (that has an initial style number of + init_style) using lexer lexer, returning a table of token names and + positions.

+ +

Fields:

+ +
    +
  • lexer: The lexer to lex text with.
  • +
  • text: The text in the buffer to lex.
  • +
  • init_style: The current style. Multiple-language lexers use this to + determine which language to start lexing in.
  • +
+ + +

Return:

+ +
    +
  • table of token names and positions.
  • +
+ + +

+ +

lexer.line_from_position (pos)

+ +

Returns the line number of the line that contains position pos, which + starts from 1.

+ +

Fields:

+ +
    +
  • pos: The position to get the line number of.
  • +
+ + +

Return:

+ +
    +
  • number
  • +
+ + +

+ +

lexer.load (name, alt_name, cache)

+ +

Initializes or loads and returns the lexer of string name name. + Scintilla calls this function in order to load a lexer. Parent lexers also + call this function in order to load child lexers and vice-versa. The user + calls this function in order to load a lexer when using this module as a Lua + library.

+ +

Fields:

+ +
    +
  • name: The name of the lexing language.
  • +
  • alt_name: The alternate name of the lexing language. This is useful for + embedding the same child lexer with multiple sets of start and end tokens.
  • +
  • cache: Flag indicating whether or not to load lexers from the cache. + This should only be true when initially loading a lexer (e.g. not from + within another lexer for embedding purposes). + The default value is false.
  • +
+ + +

Return:

+ +
    +
  • lexer object
  • +
+ + +

+ +

lexer.modify_rule (lexer, id, rule)

+ +

Replaces in lexer lexer the existing rule identified by string id with + pattern rule.

+ +

Fields:

+ +
    +
  • lexer: The lexer to modify.
  • +
  • id: The id associated with this rule.
  • +
  • rule: The LPeg pattern of the rule.
  • +
+ + +

+ +

lexer.nested_pair (start_chars, end_chars)

+ +

Returns a pattern that matches a balanced range of text that starts with + string start_chars and ends with string end_chars. + With single-character delimiters, this function is identical to + delimited_range(start_chars..end_chars, false, true, true).

+ +

Fields:

+ +
    +
  • start_chars: The string starting a nested sequence.
  • +
  • end_chars: The string ending a nested sequence.
  • +
+ + +

Usage:

+ +
    +
  • local nested_comment = lexer.nested_pair('/*', '*/')
  • +
+ + +

Return:

+ +
    +
  • pattern
  • +
+ + +

See also:

+ + + + +

+ +

lexer.new (name, opts)

+ +

Creates a returns a new lexer with the given name.

+ +

Fields:

+ +
    +
  • name: The lexer's name.
  • +
  • opts: Table of lexer options. Options currently supported: + +
      +
    • lex_by_line: Whether or not the lexer only processes whole lines of + text (instead of arbitrary chunks of text) at a time. + Line lexers cannot look ahead to subsequent lines. + The default value is false.
    • +
    • fold_by_indentation: Whether or not the lexer does not define any fold + points and that fold points should be calculated based on changes in line + indentation. + The default value is false.
    • +
    • case_insensitive_fold_points: Whether or not fold points added via + lexer.add_fold_point() ignore case. + The default value is false.
    • +
    • inherit: Lexer to inherit from. + The default value is nil.
    • +
    +
  • +
+ + +

Usage:

+ +
    +
  • lexer.new('rhtml', {inherit = lexer.load('html')})
  • +
+ + +

+ +

lexer.starts_line (patt)

+ +

Creates and returns a pattern that matches pattern patt only at the + beginning of a line.

+ +

Fields:

+ +
    +
  • patt: The LPeg pattern to match on the beginning of a line.
  • +
+ + +

Usage:

+ +
    +
  • local preproc = token(lexer.PREPROCESSOR, lexer.starts_line('#') * + lexer.nonnewline^0)
  • +
+ + +

Return:

+ +
    +
  • pattern
  • +
+ + +

+ +

lexer.token (name, patt)

+ +

Creates and returns a token pattern with token name name and pattern + patt. + If name is not a predefined token name, its style must be defined via + lexer.add_style().

+ +

Fields:

+ +
    +
  • name: The name of token. If this name is not a predefined token name, + then a style needs to be assiciated with it via lexer.add_style().
  • +
  • patt: The LPeg pattern associated with the token.
  • +
+ + +

Usage:

+ +
    +
  • local ws = token(lexer.WHITESPACE, lexer.space^1)
  • +
  • local annotation = token('annotation', '@' * lexer.word)
  • +
+ + +

Return:

+ +
    +
  • pattern
  • +
+ + +

+ +

lexer.word_match (words, case_insensitive, word_chars)

+ +

Creates and returns a pattern that matches any single word in string words. + case_insensitive indicates whether or not to ignore case when matching + words. + This is a convenience function for simplifying a set of ordered choice word + patterns. + If words is a multi-line string, it may contain Lua line comments (--) + that will ultimately be ignored.

+ +

Fields:

+ +
    +
  • words: A string list of words separated by spaces.
  • +
  • case_insensitive: Optional boolean flag indicating whether or not the + word match is case-insensitive. The default value is false.
  • +
  • word_chars: Unused legacy parameter.
  • +
+ + +

Usage:

+ +
    +
  • local keyword = token(lexer.KEYWORD, word_match[[foo bar baz]])
  • +
  • local keyword = token(lexer.KEYWORD, word_match([[foo-bar foo-baz + bar-foo bar-baz baz-foo baz-bar]], true))
  • +
+ + +

Return:

+ +
    +
  • pattern
  • +
+ +

Supported Languages

+ +

Scintilla has Lua lexers for all of the languages below. Languages + denoted by a * have native + folders. For languages without + native folding support, folding based on indentation can be used if + fold.by.indentation is enabled.

+ +
    +
  1. Actionscript*
  2. +
  3. Ada
  4. +
  5. ANTLR*
  6. +
  7. APDL*
  8. +
  9. APL
  10. +
  11. Applescript
  12. +
  13. ASM* (NASM)
  14. +
  15. ASP*
  16. +
  17. AutoIt
  18. +
  19. AWK*
  20. +
  21. Batch*
  22. +
  23. BibTeX*
  24. +
  25. Boo
  26. +
  27. C*
  28. +
  29. C++*
  30. +
  31. C#*
  32. +
  33. ChucK
  34. +
  35. CMake*
  36. +
  37. Coffeescript
  38. +
  39. ConTeXt*
  40. +
  41. CSS*
  42. +
  43. CUDA*
  44. +
  45. D*
  46. +
  47. Dart*
  48. +
  49. Desktop Entry
  50. +
  51. Diff
  52. +
  53. Django*
  54. +
  55. Dockerfile
  56. +
  57. Dot*
  58. +
  59. Eiffel*
  60. +
  61. Elixir
  62. +
  63. Erlang*
  64. +
  65. F#
  66. +
  67. Faust
  68. +
  69. Fish*
  70. +
  71. Forth
  72. +
  73. Fortran
  74. +
  75. GAP*
  76. +
  77. gettext
  78. +
  79. Gherkin
  80. +
  81. GLSL*
  82. +
  83. Gnuplot
  84. +
  85. Go*
  86. +
  87. Groovy*
  88. +
  89. Gtkrc*
  90. +
  91. Haskell
  92. +
  93. HTML*
  94. +
  95. Icon*
  96. +
  97. IDL
  98. +
  99. Inform
  100. +
  101. ini
  102. +
  103. Io*
  104. +
  105. Java*
  106. +
  107. Javascript*
  108. +
  109. JSON*
  110. +
  111. JSP*
  112. +
  113. LaTeX*
  114. +
  115. Ledger
  116. +
  117. LESS*
  118. +
  119. LilyPond
  120. +
  121. Lisp*
  122. +
  123. Literate Coffeescript
  124. +
  125. Logtalk
  126. +
  127. Lua*
  128. +
  129. Makefile
  130. +
  131. Man Page
  132. +
  133. Markdown
  134. +
  135. MATLAB*
  136. +
  137. MoonScript
  138. +
  139. Myrddin
  140. +
  141. Nemerle*
  142. +
  143. Nim
  144. +
  145. NSIS
  146. +
  147. Objective-C*
  148. +
  149. OCaml
  150. +
  151. Pascal
  152. +
  153. Perl*
  154. +
  155. PHP*
  156. +
  157. PICO-8*
  158. +
  159. Pike*
  160. +
  161. PKGBUILD*
  162. +
  163. Postscript
  164. +
  165. PowerShell*
  166. +
  167. Prolog
  168. +
  169. Properties
  170. +
  171. Pure
  172. +
  173. Python
  174. +
  175. R
  176. +
  177. rc*
  178. +
  179. REBOL*
  180. +
  181. Rexx*
  182. +
  183. ReStructuredText*
  184. +
  185. RHTML*
  186. +
  187. Ruby*
  188. +
  189. Ruby on Rails*
  190. +
  191. Rust*
  192. +
  193. Sass*
  194. +
  195. Scala*
  196. +
  197. Scheme*
  198. +
  199. Shell*
  200. +
  201. Smalltalk*
  202. +
  203. Standard ML
  204. +
  205. SNOBOL4
  206. +
  207. SQL
  208. +
  209. TaskPaper
  210. +
  211. Tcl*
  212. +
  213. TeX*
  214. +
  215. Texinfo*
  216. +
  217. TOML
  218. +
  219. Vala*
  220. +
  221. VBScript
  222. +
  223. vCard*
  224. +
  225. Verilog*
  226. +
  227. VHDL
  228. +
  229. Visual Basic
  230. +
  231. Windows Script File*
  232. +
  233. XML*
  234. +
  235. Xtend*
  236. +
  237. YAML
  238. +
+ +

Code Contributors

+ +
    +
  • Alejandro Baez
  • +
  • Alex Saraci
  • +
  • Alexander Misel
  • +
  • Brian Schott
  • +
  • Carl Sturtivant
  • +
  • Chris Emerson
  • +
  • Christian Hesse
  • +
  • David B. Lamkins
  • +
  • Heck Fy
  • +
  • Jason Schindler
  • +
  • Jeff Stone
  • +
  • Jonathon Levi
  • +
  • Joseph Eib
  • +
  • Joshua Krämer
  • +
  • Klaus Borges
  • +
  • Larry Hynes
  • +
  • Lars Otter
  • +
  • M Rawash
  • +
  • Marc André Tanner
  • +
  • Markus F.X.J. Oberhumer
  • +
  • Martin Morawetz
  • +
  • Michael Forney
  • +
  • Michael T. Richter
  • +
  • Michel Martens
  • +
  • Murray Calavera
  • +
  • Neil Hodgson
  • +
  • Olivier Guibé
  • +
  • Peter Odding
  • +
  • Piotr Orzechowski
  • +
  • Richard Philips
  • +
  • Robert Gieseke
  • +
  • Roberto Ierusalimschy
  • +
  • S. Gilles
  • +
  • Stéphane Rivière
  • +
  • Tymur Gubayev
  • +
  • Wolfgang Seeberg
  • +
+ + + diff --git a/dep/scintilla/scintilla-3.6.0/doc/Lexer.txt b/dep/scintilla/scintilla-3.10.6/doc/Lexer.txt similarity index 99% rename from dep/scintilla/scintilla-3.6.0/doc/Lexer.txt rename to dep/scintilla/scintilla-3.10.6/doc/Lexer.txt index 0aeb66ba..9b9e54f5 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/Lexer.txt +++ b/dep/scintilla/scintilla-3.10.6/doc/Lexer.txt @@ -47,7 +47,7 @@ The task of a lexer can be summarized briefly: for each range r of characters that are to be colored the same, the lexer should call styler.ColourTo(i, state) - + where i is the position of the last character of the range r. The lexer should set the state variable to the coloring state of the character at position i and continue until the entire text has been colored. @@ -139,8 +139,8 @@ characters in ASCII for operators, comment markers, etc. Special case: Folding -Folding may be performed in the lexer function. It is better to use a -separate folder function as that avoids some troublesome interaction +Folding may be performed in the lexer function. It is better to use a +separate folder function as that avoids some troublesome interaction between styling and folding. The folder function will be run after the lexer function if folding is enabled. The rest of this section explains how to perform folding within the lexer function. @@ -148,15 +148,15 @@ how to perform folding within the lexer function. During initialization, lexers that support folding set bool fold = styler.GetPropertyInt("fold"); - + If folding is enabled in the editor, fold will be TRUE and the lexer should call: styler.SetLevel(line, level); - + at the end of each line and just before exiting. -The line parameter is simply the count of the number of newlines seen. +The line parameter is simply the count of the number of newlines seen. It's initial value is styler.GetLine(startPos) and it is incremented (after calling styler.SetLevel) whenever a newline is seen. @@ -169,7 +169,7 @@ comments, of course). The following flag bits, defined in Scintilla.h, may be set or cleared in the flags parameter. The SC_FOLDLEVELWHITEFLAG flag is set if the lexer considers that the line contains nothing but whitespace. The -SC_FOLDLEVELHEADERFLAG flag indicates that the line is a fold point. +SC_FOLDLEVELHEADERFLAG flag indicates that the line is a fold point. This normally means that the next line has a greater level than present line. However, the lexer may have some other basis for determining a fold point. For example, a lexer might create a header line for the @@ -193,7 +193,7 @@ seen: if ((levelCurrent > levelPrev) && (visChars > 0)) lev |= SC_FOLDLEVELHEADERFLAG; styler.SetLevel(lineCurrent, lev); - + // reinitialize the folding vars describing the present line. lineCurrent++; visChars = 0; // Number of non-whitespace characters on the line. @@ -210,7 +210,7 @@ The following code appears in the C++ lexer just before exit: flagsNext &= ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } - + Don't worry about performance diff --git a/dep/scintilla/scintilla-3.10.6/doc/Markers.png b/dep/scintilla/scintilla-3.10.6/doc/Markers.png new file mode 100644 index 00000000..b1d0120c Binary files /dev/null and b/dep/scintilla/scintilla-3.10.6/doc/Markers.png differ diff --git a/dep/scintilla/scintilla-3.6.0/doc/Privacy.html b/dep/scintilla/scintilla-3.10.6/doc/Privacy.html similarity index 96% rename from dep/scintilla/scintilla-3.6.0/doc/Privacy.html rename to dep/scintilla/scintilla-3.10.6/doc/Privacy.html index 22c8cd58..85cb801c 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/Privacy.html +++ b/dep/scintilla/scintilla-3.10.6/doc/Privacy.html @@ -5,6 +5,7 @@ + Privacy Policy diff --git a/dep/scintilla/scintilla-3.6.0/doc/SciBreak.jpg b/dep/scintilla/scintilla-3.10.6/doc/SciBreak.jpg similarity index 100% rename from dep/scintilla/scintilla-3.6.0/doc/SciBreak.jpg rename to dep/scintilla/scintilla-3.10.6/doc/SciBreak.jpg diff --git a/dep/scintilla/scintilla-3.6.0/doc/SciCoding.html b/dep/scintilla/scintilla-3.10.6/doc/SciCoding.html similarity index 87% rename from dep/scintilla/scintilla-3.6.0/doc/SciCoding.html rename to dep/scintilla/scintilla-3.10.6/doc/SciCoding.html index d51e3165..c5debf51 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/SciCoding.html +++ b/dep/scintilla/scintilla-3.10.6/doc/SciCoding.html @@ -5,6 +5,7 @@ + Scintilla and SciTE Code Style Preferences @@ -123,6 +124,8 @@ compilers on diverse platforms with high performance and low resource usage. Scintilla has stricter portability requirements to SciTE as it may be ported to low capability platforms. + Scintilla code must build with C++03 which can be checked with "g++ --std=gnu++03". + SciTE can use C++11 features that are widely available from g++ 4.6, MSVC 2012 and clang 3.4 compilers.

To achieve portability, only a subset of C++ features are used. @@ -130,22 +133,28 @@ C++, exceptions may not be thrown out of Scintilla and all exceptions should be caught before returning from Scintilla. Run-time type information adds to memory use so is turned off. - A 'Scintilla' name spaces is optionally used based on the SCI_NAMESPACE - definition. This helps with name clashes on OS X. + A 'Scintilla' name space is used. This helps with name clashes on OS X.

The goto statement is not used because of bad memories from my first job maintaining FORTRAN programs. The union feature is not used as it can lead to non-type-safe value access.

+

+ The SCI_METHOD preprocessor definition should be used when implementing + interfaces which include it like ILexer and only there. +

+

+ Headers should always be included in the same order as given by the + scripts/HeaderOrder.txt file. +

Casting

Do not use old C style casts like (char *)s. Instead use the most strict form of C++ cast possible like const_cast<char *>(s). Use static_cast and const_cast - where possible rather than reinterpret_cast. Because the code is compiled with - run-time type information turned off, dynamic_cast will not work. + where possible rather than reinterpret_cast.

The benefit to using the new style casts is that they explicitly detail what evil is @@ -255,5 +264,31 @@

Ensure there are no warnings under the compiler you use. Warnings from other compilers will be noted on the feature request.

sc.ch is an int: do not pass this around as a char.

+

The ctype functions like isalnum and isdigit only work on ASCII (0..127) and may cause + undefined behaviour including crashes if used on other values. Check with IsASCII before calling is*.

+

Functions, structs and classes in lexers should be in an unnamed namespace (see LexCPP) + or be marked "static" so they will not leak into other lexers.

+

If you copy from an existing lexer, remove any code that is not needed since it makes it + more difficult to maintain and review.

+

When modifying an existing lexer, try to maintain as much compatibility as possible. + Do not renumber lexical styles as current client code may be built against the earlier values.

+

+ Properties +

+

+ Properties provided by a new lexer should follow the naming conventions + and should include a comment suitable for showing to end users. + The convention is for properties that control styling to be named + lexer.<lexername>.* and those that control folding to be named + fold.<lexername>.*. + Examples are "lexer.python.literals.binary" and "fold.haskell.imports". +

+

+ The properties "fold" and "fold.comment" are generic and can be used by + any lexer. +

+

+ See LexPython for examples of properties in an object lexer and LexHTML for a functional lexer. +

diff --git a/dep/scintilla/scintilla-3.6.0/doc/SciRest.jpg b/dep/scintilla/scintilla-3.10.6/doc/SciRest.jpg similarity index 100% rename from dep/scintilla/scintilla-3.6.0/doc/SciRest.jpg rename to dep/scintilla/scintilla-3.10.6/doc/SciRest.jpg diff --git a/dep/scintilla/scintilla-3.10.6/doc/SciTEIco.png b/dep/scintilla/scintilla-3.10.6/doc/SciTEIco.png new file mode 100644 index 00000000..90ab9ff7 Binary files /dev/null and b/dep/scintilla/scintilla-3.10.6/doc/SciTEIco.png differ diff --git a/dep/scintilla/scintilla-3.6.0/doc/SciWord.jpg b/dep/scintilla/scintilla-3.10.6/doc/SciWord.jpg similarity index 100% rename from dep/scintilla/scintilla-3.6.0/doc/SciWord.jpg rename to dep/scintilla/scintilla-3.10.6/doc/SciWord.jpg diff --git a/dep/scintilla/scintilla-3.6.0/doc/ScintillaDoc.html b/dep/scintilla/scintilla-3.10.6/doc/ScintillaDoc.html similarity index 75% rename from dep/scintilla/scintilla-3.6.0/doc/ScintillaDoc.html rename to dep/scintilla/scintilla-3.10.6/doc/ScintillaDoc.html index c24f52d7..9d04fd11 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/ScintillaDoc.html +++ b/dep/scintilla/scintilla-3.10.6/doc/ScintillaDoc.html @@ -14,22 +14,53 @@ @@ -82,18 +116,18 @@

Scintilla Documentation

-

Last edited 31 July 2015 NH

+

Last edited 6 June 2018 NH

There is an overview of the internal design of Scintilla.
Some notes on using Scintilla.
How to use the Scintilla Edit Control on Windows.
- A simple sample using Scintilla from + A simple sample using Scintilla from C++ on Windows.
- A simple sample using Scintilla from + A simple sample using Scintilla from Visual Basic.
- Bait is a tiny sample using Scintilla - on GTK+.
+ Bait is a tiny sample using Scintilla + on GTK.
A detailed description of how to write a lexer, including a discussion of folding.
@@ -102,6 +136,7 @@ How to implement folding.
Beginner's Guide to lexing and folding.
+ How to write lexers in Lua.
The coding style used in Scintilla and SciTE is worth following if you want to contribute code to Scintilla but is not compulsory.

@@ -114,10 +149,10 @@ of a normal Edit control, Scintilla allows control of syntax styling, folding, markers, autocompletion and call tips.

-

The GTK+ version also uses messages in a similar way to the Windows version. This is - different to normal GTK+ practice but made it easier to implement rapidly.

+

The GTK version also uses messages in a similar way to the Windows version. This is + different to normal GTK practice but made it easier to implement rapidly.

-

Scintilla also builds with Cocoa on OS X and with Qt, and follows the conventions of +

Scintilla also builds with Cocoa on OS X, with Qt, and with curses, and follows the conventions of those platforms.

Scintilla does not properly support right-to-left languages like Arabic and Hebrew. @@ -140,23 +175,24 @@ enhancement of messages without the risk of breaking existing code. Common argument types are:

- +
- + - + - + - + - + - + - + - + @@ -207,153 +243,164 @@

Contents

-
boolbool Arguments expect the values 0 for false and 1 for true.
intintArguments are 32-bit signed integers.Arguments are 32-bit or 64-bit signed integers depending on the platform. + Equivalent to intptr_t.
const char *const char * Arguments point at text that is being passed to Scintilla but not modified. The text may be zero terminated or another argument may specify the character count, the @@ -164,7 +200,7 @@
char *char * Arguments point at text buffers that Scintilla will fill with text. In some cases, another argument will tell Scintilla the buffer size. In others, you must make sure that @@ -175,7 +211,7 @@
colourcolour Colours are set using the RGB format (Red, Green, Blue). The intensity of each colour is set in the range 0 to 255. If you have three such intensities, they are combined as: @@ -186,7 +222,7 @@
alphaalpha Translucency is set using an alpha value. Alpha ranges from 0 (SC_ALPHA_TRANSPARENT) which is completely transparent to @@ -197,7 +233,7 @@
<unused><unused> This is an unused argument. Setting it to 0 will ensure compatibility with future enhancements.
+
- - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - - + + + + + @@ -389,39 +436,38 @@ largest font in any current style. This restriction is for performance; if lines differed in height then calculations involving positioning of text would require the text to be styled first.

- SCI_GETTEXT(int length, char *text)
+ SCI_GETTEXT(int length, char *text) → int
SCI_SETTEXT(<unused>, const char *text)
SCI_SETSAVEPOINT
- SCI_GETLINE(int line, char *text)
+ SCI_GETLINE(int line, char *text) → int
SCI_REPLACESEL(<unused>, const char *text)
SCI_SETREADONLY(bool readOnly)
- SCI_GETREADONLY
- SCI_GETTEXTRANGE(<unused>, Sci_TextRange - *tr)
- SCI_ALLOCATE(int bytes, <unused>)
- SCI_ADDTEXT(int length, const char *s)
- SCI_ADDSTYLEDTEXT(int length, cell *s)
- SCI_APPENDTEXT(int length, const char *s)
+ SCI_GETREADONLY → bool
+ SCI_GETTEXTRANGE(<unused>, Sci_TextRange *tr) → int
+ SCI_ALLOCATE(int bytes)
+ SCI_ADDTEXT(int length, const char *text)
+ SCI_ADDSTYLEDTEXT(int length, cell *c)
+ SCI_APPENDTEXT(int length, const char *text)
SCI_INSERTTEXT(int pos, const char *text)
SCI_CHANGEINSERTION(int length, const char *text)
SCI_CLEARALL
- SCI_DELETERANGE(int pos, int deleteLength)
+ SCI_DELETERANGE(int start, int lengthDelete)
SCI_CLEARDOCUMENTSTYLE
- SCI_GETCHARAT(int position)
- SCI_GETSTYLEAT(int position)
- SCI_GETSTYLEDTEXT(<unused>, Sci_TextRange - *tr)
+ SCI_GETCHARAT(int pos) → int
+ SCI_GETSTYLEAT(int pos) → int
+ SCI_GETSTYLEDTEXT(<unused>, Sci_TextRange *tr) → int
SCI_RELEASEALLEXTENDEDSTYLES
- SCI_ALLOCATEEXTENDEDSTYLES(int numberStyles)
- SCI_TARGETASUTF8(<unused>, char *s)
- SCI_ENCODEDFROMUTF8(const char *utf8, char *encoded)
+ SCI_ALLOCATEEXTENDEDSTYLES(int numberStyles) → int
+ SCI_TARGETASUTF8(<unused>, char *s) → int
+ SCI_ENCODEDFROMUTF8(const char *utf8, char *encoded) → int
SCI_SETLENGTHFORENCODE(int bytes)
-

SCI_GETTEXT(int length, char *text NUL-terminated)
- This returns length-1 characters of text from the start of the document plus one - terminating 0 character. To collect all the text in a document, use SCI_GETLENGTH +

SCI_GETTEXT(int length, char *text NUL-terminated) → int
+ This returns at most length-1 characters of text from the start of the document plus one + terminating 0 character. When length-1 is beyond document length, it returns document length. + To collect all the text in a document, use SCI_GETLENGTH to get the number of characters in the document (nLen), allocate a character buffer of length nLen+1 bytes, then call SCI_GETTEXT(nLen+1, char *text). If the text argument is 0 then the length that should be allocated to store the @@ -429,11 +475,11 @@ If you then save the text, you should use SCI_SETSAVEPOINT to mark the text as unmodified.

-

See also: SCI_GETSELTEXT, SCI_GETCURLINE, SCI_GETLINE, SCI_GETSTYLEDTEXT, SCI_GETTEXTRANGE

+

See also: SCI_GETSELTEXT, + SCI_GETCURLINE, + SCI_GETLINE, + SCI_GETSTYLEDTEXT, + SCI_GETTEXTRANGE

SCI_SETTEXT(<unused>, const char *text)
This replaces all the text in the document with the zero terminated text string you pass @@ -452,7 +498,7 @@

See also: SCI_EMPTYUNDOBUFFER, SCI_GETMODIFY

-

SCI_GETLINE(int line, char *text)
+

SCI_GETLINE(int line, char *text) → int
This fills the buffer defined by text with the contents of the nominated line (lines start at 0). The buffer is not terminated by a 0 character. It is up to you to make sure that the buffer is long enough for the text, use -

See also: SCI_GETCURLINE, SCI_GETSELTEXT, SCI_GETTEXTRANGE, SCI_GETSTYLEDTEXT, SCI_GETTEXT

+

See also: SCI_GETCURLINE, + SCI_GETSELTEXT, + SCI_GETTEXTRANGE, + SCI_GETSTYLEDTEXT, + SCI_GETTEXT

SCI_REPLACESEL(<unused>, const char *text)
The currently selected text between the anchor @@ -475,13 +521,12 @@ positioned after the inserted text and the caret is scrolled into view.

SCI_SETREADONLY(bool readOnly)
- SCI_GETREADONLY
+ SCI_GETREADONLY → bool
These messages set and get the read-only flag for the document. If you mark a document as read only, attempts to modify the text cause the
SCN_MODIFYATTEMPTRO notification.

-

SCI_GETTEXTRANGE(<unused>, Sci_TextRange *tr)
+

SCI_GETTEXTRANGE(<unused>, Sci_TextRange *tr) → int
This collects the text between the positions cpMin and cpMax and copies it to lpstrText (see struct Sci_TextRange in Scintilla.h). If cpMax is -1, text is returned to the end of the @@ -489,14 +534,13 @@ longer than the number of characters you wish to read. The return value is the length of the returned text not including the terminating 0.

-

See also: SCI_GETSELTEXT, SCI_GETLINE, SCI_GETCURLINE, SCI_GETSTYLEDTEXT, SCI_GETTEXT

+

See also: SCI_GETSELTEXT, + SCI_GETLINE, + SCI_GETCURLINE, + SCI_GETSTYLEDTEXT, + SCI_GETTEXT

-

SCI_GETSTYLEDTEXT(<unused>, Sci_TextRange *tr)
+

SCI_GETSTYLEDTEXT(<unused>, Sci_TextRange *tr) → int
This collects styled text into a buffer using two bytes for each cell, with the character at the lower address of each pair and the style byte at the upper address. Characters between the positions cpMin and cpMax are copied to lpstrText (see @@ -506,34 +550,36 @@ cpMin or cpMax. Positions outside the document return character codes and style bytes of 0.

-

See also: SCI_GETSELTEXT, SCI_GETLINE, SCI_GETCURLINE, SCI_GETTEXTRANGE, SCI_GETTEXT

+

See also: SCI_GETSELTEXT, + SCI_GETLINE, + SCI_GETCURLINE, + SCI_GETTEXTRANGE, + SCI_GETTEXT

-

SCI_ALLOCATE(int bytes, <unused>)
+

SCI_ALLOCATE(int bytes)
Allocate a document buffer large enough to store a given number of bytes. The document will not be made smaller than its current contents.

-

SCI_ADDTEXT(int length, const char *s)
- This inserts the first length characters from the string s +

SCI_ADDTEXT(int length, const char *text)
+ This inserts the first length characters from the string + text at the current position. This will include any 0's in the string that you might have expected to stop the insert operation. The current position is set at the end of the inserted text, but it is not scrolled into view.

-

SCI_ADDSTYLEDTEXT(int length, cell *s)
+

SCI_ADDSTYLEDTEXT(int length, cell *c)
This behaves just like SCI_ADDTEXT, but inserts styled text.

-

SCI_APPENDTEXT(int length, const char *s)
- This adds the first length characters from the string s to the end +

SCI_APPENDTEXT(int length, const char *text)
+ This adds the first length characters from the string + text to the end of the document. This will include any 0's in the string that you might have expected to stop the operation. The current selection is not changed and the new text is not scrolled into view.

SCI_INSERTTEXT(int pos, const char *text)
- This inserts the zero terminated text string at position pos or at - the current position if pos is -1. If the current position is after the insertion point + This inserts the zero terminated text string at position pos or at + the current position if pos is -1. If the current position is after the insertion point then it is moved along with its surrounding text but no scrolling is performed.

SCI_CHANGEINSERTION(int length, const char *text)
@@ -543,7 +589,7 @@

SCI_CLEARALL
Unless the document is read-only, this deletes all the text.

-

SCI_DELETERANGE(int pos, int deleteLength)
+

SCI_DELETERANGE(int start, int lengthDelete)
Deletes a range of text in the document.

SCI_CLEARDOCUMENTSTYLE
@@ -551,16 +597,16 @@ SCI_CLEARDOCUMENTSTYLE can be used to clear all styling information and reset the folding state.

-

SCI_GETCHARAT(int pos)
- This returns the character at pos in the document or 0 if pos is +

SCI_GETCHARAT(int pos) → int
+ This returns the character at pos in the document or 0 if pos is negative or past the end of the document.

-

SCI_GETSTYLEAT(int pos)
- This returns the style at pos in the document, or 0 if pos is +

SCI_GETSTYLEAT(int pos) → int
+ This returns the style at pos in the document, or 0 if pos is negative or past the end of the document.

SCI_RELEASEALLEXTENDEDSTYLES
- SCI_ALLOCATEEXTENDEDSTYLES(int numberStyles)
+ SCI_ALLOCATEEXTENDEDSTYLES(int numberStyles) → int
Extended styles are used for features like textual margins and annotations as well as internally by Scintilla. They are outside the range 0..255 used for the styles bytes associated with document bytes. These functions manage the use of extended styles to ensures that components cooperate in defining styles. @@ -568,8 +614,8 @@ SCI_ALLOCATEEXTENDEDSTYLES allocates a range of style numbers after the byte style values and returns the number of the first allocated style. Ranges for margin and annotation styles should be allocated before calling - SCI_MARGINSETSTYLEOFFSET or - SCI_ANNOTATIONSETSTYLEOFFSET.

+ SCI_MARGINSETSTYLEOFFSET or + SCI_ANNOTATIONSETSTYLEOFFSET.

Sci_TextRange and Sci_CharacterRange
These structures are defined to be exactly the same shape as the Win32 TEXTRANGE @@ -591,17 +637,17 @@ struct Sci_TextRange { }; -

Specific to GTK+, Cocoa and Windows only: Access to encoded text

+

Specific to GTK, Cocoa and Windows only: Access to encoded text

-

SCI_TARGETASUTF8(<unused>, char *s)
+

SCI_TARGETASUTF8(<unused>, char *s) → int
This method retrieves the value of the target encoded as UTF-8 which is the default - encoding of GTK+ so is useful for retrieving text for use in other parts of the user interface, + encoding of GTK so is useful for retrieving text for use in other parts of the user interface, such as find and replace dialogs. The length of the encoded text in bytes is returned. Cocoa uses UTF-16 which is easily converted from UTF-8 so this method can be used to perform the more complex work of transcoding from the various encodings supported.

-

SCI_ENCODEDFROMUTF8(const char *utf8, char *encoded)
+

SCI_ENCODEDFROMUTF8(const char *utf8, char *encoded) → int
SCI_SETLENGTHFORENCODE(int bytes)
SCI_ENCODEDFROMUTF8 converts a UTF-8 string into the document's encoding which is useful for taking the results of a find dialog, for example, and receiving @@ -616,19 +662,20 @@ struct Sci_TextRange {

There are methods to search for text and for regular expressions. Most applications should use - SCI_SEARCHINTARGET + SCI_SEARCHINTARGET as the basis for their search implementations. Other calls augment this or were implemented before SCI_SEARCHINTARGET.

The base regular expression support is limited and should only be used for simple cases and initial development. - When using a C++11 compliant compiler and runtime, it may be possible to use the - runtime's implementation of <regex> by compiling Scintilla with CXX11_REGEX defined. + The C++ runtime <regex> library may be used by setting the SCFIND_CXX11REGEX search flag. + The C++11 <regex> support may be disabled by + compiling Scintilla with NO_CXX11_REGEX defined. A different regular expression library can be integrated into Scintilla or can be called from the container using direct access to the buffer contents through - SCI_GETCHARACTERPOINTER. + SCI_GETCHARACTERPOINTER.

Search and replace using the target

@@ -639,30 +686,26 @@ struct Sci_TextRange { SCI_SEARCHINTARGET such as SCFIND_MATCHCASE, SCFIND_WHOLEWORD, SCFIND_WORDSTART, and SCFIND_REGEXP can be set with SCI_SETSEARCHFLAGS.

- SCI_SETTARGETSTART(int pos)
- SCI_GETTARGETSTART
- SCI_SETTARGETEND(int pos)
- SCI_GETTARGETEND
+ SCI_SETTARGETSTART(int start)
+ SCI_GETTARGETSTART → position
+ SCI_SETTARGETEND(int end)
+ SCI_GETTARGETEND → position
SCI_SETTARGETRANGE(int start, int end)
SCI_TARGETFROMSELECTION
SCI_TARGETWHOLEDOCUMENT
SCI_SETSEARCHFLAGS(int searchFlags)
- SCI_GETSEARCHFLAGS
- SCI_SEARCHINTARGET(int length, const char - *text)
- SCI_GETTARGETTEXT(<unused>, - char *text)
- SCI_REPLACETARGET(int length, const char - *text)
- SCI_REPLACETARGETRE(int length, const char - *text)
- SCI_GETTAG(int tagNumber, char *tagValue)
+ SCI_GETSEARCHFLAGS → int
+ SCI_SEARCHINTARGET(int length, const char *text) → int
+ SCI_GETTARGETTEXT(<unused>, char *text) → int
+ SCI_REPLACETARGET(int length, const char *text) → int
+ SCI_REPLACETARGETRE(int length, const char *text) → int
+ SCI_GETTAG(int tagNumber, char *tagValue) → int
-

SCI_SETTARGETSTART(int pos)
- SCI_GETTARGETSTART
- SCI_SETTARGETEND(int pos)
- SCI_GETTARGETEND
+

SCI_SETTARGETSTART(int start)
+ SCI_GETTARGETSTART → position
+ SCI_SETTARGETEND(int end)
+ SCI_GETTARGETEND → position
SCI_SETTARGETRANGE(int start, int end)
These functions set and return the start and end of the target. When searching you can set start greater than end to find the last matching text in the @@ -676,51 +719,51 @@ struct Sci_TextRange { Set the target start to the start of the document and target end to the end of the document.

SCI_SETSEARCHFLAGS(int searchFlags)
- SCI_GETSEARCHFLAGS
- These get and set the searchFlags used by + SCI_GETSEARCHFLAGS → int
+ These get and set the searchFlags used by SCI_SEARCHINTARGET. There are several option flags including a simple regular expression search.

-

SCI_SEARCHINTARGET(int length, const char *text)
+

SCI_SEARCHINTARGET(int length, const char *text) → int
This searches for the first occurrence of a text string in the target defined by SCI_SETTARGETSTART and SCI_SETTARGETEND. The text string is not zero - terminated; the size is set by length. The search is modified by the search flags + terminated; the size is set by length. The search is modified by the search flags set by SCI_SETSEARCHFLAGS. If the search succeeds, the target is set to the found text and the return value is the position of the start of the matching text. If the search fails, the result is -1.

-

SCI_GETTARGETTEXT(<unused>, char *text)
+

SCI_GETTARGETTEXT(<unused>, char *text) → int
Retrieve the value in the target.

-

SCI_REPLACETARGET(int length, const char *text)
- If length is -1, text is a zero terminated string, otherwise - length sets the number of character to replace the target with. +

SCI_REPLACETARGET(int length, const char *text) → int
+ If length is -1, text is a zero terminated string, otherwise + length sets the number of character to replace the target with. After replacement, the target range refers to the replacement text. The return value is the length of the replacement string.
Note that the recommended way to delete text in the document is to set the target to the text to be removed, and to perform a replace target with an empty string.

-

SCI_REPLACETARGETRE(int length, const char *text)
- This replaces the target using regular expressions. If length is -1, - text is a zero terminated string, otherwise length is the number of +

SCI_REPLACETARGETRE(int length, const char *text) → int
+ This replaces the target using regular expressions. If length is -1, + text is a zero terminated string, otherwise length is the number of characters to use. The replacement string is formed from the text string with any sequences of \1 through \9 replaced by tagged matches from the most recent regular expression search. \0 is replaced with all the matched text from the most recent search. After replacement, the target range refers to the replacement text. The return value is the length of the replacement string.

-

SCI_GETTAG(int tagNumber, char *tagValue NUL-terminated)
+

SCI_GETTAG(int tagNumber, char *tagValue NUL-terminated) → int
Discover what text was matched by tagged expressions in a regular expression search. This is useful if the application wants to interpret the replacement string itself.

See also: SCI_FINDTEXT

-

searchFlags
+

searchFlags
Several of the search routines use flag options, which include a simple regular expression search. Combine the flag options by adding them:

-
o Text retrieval and + Text retrieval and modificationo Searching and replacingSearching and replacingo OvertypeOvertype
o Cut, copy and pasteCut, copy and pasteo Error handlingError handlingo Undo and RedoUndo and Redo
o Selection and informationSelection and informationo Multiple Selection and Virtual SpaceBy character or UTF-16 code unito Scrolling and automatic - scrollingMultiple Selection and Virtual Space
o White spaceScrolling and automatic scrollingo CursorWhite spaceo Mouse captureCursor
o Line endingsMouse captureo StylingLine endingso Style definitionWords
o Caret, selection, and hotspot stylesStylingo Character representationsStyle definitiono MarginsCaret, selection, and hotspot styles
o AnnotationsCharacter representationso Other settingsMarginso Brace highlightingAnnotations
o Tabs and Indentation + Other settingsBrace highlightingTabs and Indentation Guideso Markers
o Indicators
MarkersIndicatorsAutocompletion
o AutocompletionUser listso User listsCall tipso Call tipsKeyboard commands
o Keyboard commandsKey bindingso Key bindingsPopup edit menuo Popup edit menuMacro recording
o Macro recordingPrintingo PrintingDirect accesso Direct accessMultiple views
o Multiple viewsBackground loading and savingo Background loading and savingFoldingo FoldingLine wrapping
o Line wrappingZoomingo ZoomingLong lineso Long linesAccessibility
o LexerLexero Lexer objectsLexer objectso NotificationsNotifications
o ImagesImageso GTK+GTKo Provisional messagesProvisional messages
o Deprecated messagesDeprecated messageso Edit messages never + Edit messages never supported by Scintillao Building ScintillaRemoved features
Building Scintilla
+
@@ -731,43 +774,48 @@ struct Sci_TextRange { - + - + - + + by interpreting bare ( and ) for tagged sections rather than \( and \). + Has no effect when SCFIND_CXX11REGEX is set. - + - +
SCFIND_MATCHCASE
SCFIND_WHOLEWORDA match only occurs if the characters before and after are not word characters.A match only occurs if the characters before and after are not word characters as defined + by SCI_SETWORDCHARS.
SCFIND_WORDSTARTA match only occurs if the character before is not a word character.A match only occurs if the character before is not a word character as defined + by SCI_SETWORDCHARS.
SCFIND_REGEXPThe search string should be interpreted as a regular expression.The search string should be interpreted as a regular expression. + Uses Scintilla's base implementation unless combined with SCFIND_CXX11REGEX.
SCFIND_POSIX Treat regular expression in a more POSIX compatible manner - by interpreting bare ( and ) for tagged sections rather than \( and \).
SCFIND_CXX11REGEXWhen compiled with CXX11_REGEX this flag - may be set to use <regex> instead of Scintilla's basic regular expressions. - If the regular expression is invalid then -1 is returned and status is set to - SC_STATUS_WARN_REGEX. - The ECMAScript flag is set on the regex object and UTF-8 documents will exhibit Unicode-compliant - behaviour. For MSVC, where wchar_t is 16-bits, the reular expression ".." will match a single - astral-plane character. There may be other differences between compilers.This flag may be set to use C++11 <regex> instead of Scintilla's basic regular expressions. + If the regular expression is invalid then -1 is returned and status is set to + SC_STATUS_WARN_REGEX. + The ECMAScript flag is set on the regex object and UTF-8 documents will exhibit Unicode-compliant + behaviour. For MSVC, where wchar_t is 16-bits, the reular expression ".." will match a single + astral-plane character. There may be other differences between compilers. + Must also have SCFIND_REGEXP set.
-

In a regular expression, special characters interpreted are:

+

In a regular expression, using Scintilla's base implementation, + special characters interpreted are:

- +
@@ -860,19 +908,19 @@ struct Sci_TextRange {

Regular expressions will only match ranges within a single line, never matching over multiple lines.

- SCI_FINDTEXT(int flags, Sci_TextToFind - *ttf)
+

When using SCFIND_CXX11REGEX more features are available, + generally similar to regular expression support in JavaScript. + See the documentation of your C++ runtime for details on what is supported.

+ + SCI_FINDTEXT(int searchFlags, Sci_TextToFind *ft) → position
SCI_SEARCHANCHOR
- SCI_SEARCHNEXT(int searchFlags, const char - *text)
- SCI_SEARCHPREV(int searchFlags, const char - *text)
+ SCI_SEARCHNEXT(int searchFlags, const char *text) → int
+ SCI_SEARCHPREV(int searchFlags, const char *text) → int
-

SCI_FINDTEXT(int searchFlags, Sci_TextToFind *ttf)
+

SCI_FINDTEXT(int searchFlags, Sci_TextToFind *ft) → position
This message searches for text in the document. It does not use or move the current selection. - The searchFlags argument controls the + The searchFlags argument controls the search type, which includes regular expression searches.

You can @@ -906,8 +954,8 @@ struct Sci_TextToFind {

SCI_SEARCHANCHOR
- SCI_SEARCHNEXT(int searchFlags, const char *text)
- SCI_SEARCHPREV(int searchFlags, const char *text)
+ SCI_SEARCHNEXT(int searchFlags, const char *text) → int
+ SCI_SEARCHPREV(int searchFlags, const char *text) → int
These messages provide relocatable search support. This allows multiple incremental interactive searches to be macro recorded while still setting the selection to found text so the find/select operation is self-contained. These three messages send SCI_SEARCHNEXT and SCI_SEARCHPREV search for the next and previous occurrence of the zero terminated search string pointed at by text. The search is modified by - the searchFlags.

+ the searchFlags.

The return value is -1 if nothing is found, otherwise the return value is the start position of the matching text. The selection is updated to show the matched text, but is not scrolled @@ -933,12 +981,16 @@ struct Sci_TextToFind {

Overtype

+ SCI_SETOVERTYPE(bool overType)
+ SCI_GETOVERTYPE → bool
+
+

SCI_SETOVERTYPE(bool overType)
- SCI_GETOVERTYPE
+ SCI_GETOVERTYPE → bool
When overtype is enabled, each typed character replaces the character to the right of the text caret. When overtype is disabled, characters are inserted at the caret. - SCI_GETOVERTYPE returns TRUE (1) if overtyping is active, otherwise - FALSE (0) will be returned. Use SCI_SETOVERTYPE to set the overtype + SCI_GETOVERTYPE returns true (1) if overtyping is active, otherwise + false (0) will be returned. Use SCI_SETOVERTYPE to set the overtype mode.

Cut, copy and paste

@@ -947,20 +999,19 @@ struct Sci_TextToFind { SCI_COPY
SCI_PASTE
SCI_CLEAR
- SCI_CANPASTE
+ SCI_CANPASTE → bool
SCI_COPYRANGE(int start, int end)
- SCI_COPYTEXT(int length, - const char *text)
+ SCI_COPYTEXT(int length, const char *text)
SCI_COPYALLOWLINE
SCI_SETPASTECONVERTENDINGS(bool convert)
- SCI_GETPASTECONVERTENDINGS
+ SCI_GETPASTECONVERTENDINGS → bool

SCI_CUT
SCI_COPY
SCI_PASTE
SCI_CLEAR
- SCI_CANPASTE
+ SCI_CANPASTE → bool
SCI_COPYALLOWLINE
These commands perform the standard tasks of cutting and copying data to the clipboard, pasting from the clipboard into the document, and clearing the document. @@ -969,7 +1020,7 @@ struct Sci_TextToFind { SCI_GETSELECTIONEMPTY(), which will be zero if there are any non-empty selection ranges implying that a copy or cut to the clipboard should work.

-

GTK+ does not really support SCI_CANPASTE and always returns TRUE +

GTK does not really support SCI_CANPASTE and always returns true unless the document is read-only.

On X, the clipboard is asynchronous and may require several messages between @@ -988,16 +1039,20 @@ struct Sci_TextToFind { text to the system clipboard.

SCI_SETPASTECONVERTENDINGS(bool convert)
- SCI_GETPASTECONVERTENDINGS
+ SCI_GETPASTECONVERTENDINGS → bool
If this property is set then when text is pasted any line ends are converted to match the document's end of line mode as set with - SCI_SETEOLMODE. + SCI_SETEOLMODE. Defaults to true.

Error handling

+ SCI_SETSTATUS(int status)
+ SCI_GETSTATUS → int
+
+

SCI_SETSTATUS(int status)
- SCI_GETSTATUS
+ SCI_GETSTATUS → int
If an error occurs, Scintilla may set an internal error number that can be retrieved with SCI_GETSTATUS. To clear the error status call SCI_SETSTATUS(0). @@ -1006,28 +1061,28 @@ struct Sci_TextToFind { The currently defined statuses are:

-
.
+
- + - + - - + + - + @@ -1046,20 +1101,19 @@ struct Sci_TextToFind { SCI_ENDUNDOACTION messages. These transactions can be nested and only the top-level sequences are undone as units.

SCI_UNDO
- SCI_CANUNDO
+ SCI_CANUNDO → bool
SCI_EMPTYUNDOBUFFER
SCI_REDO
- SCI_CANREDO
- SCI_SETUNDOCOLLECTION(bool - collectUndo)
- SCI_GETUNDOCOLLECTION
+ SCI_CANREDO → bool
+ SCI_SETUNDOCOLLECTION(bool collectUndo)
+ SCI_GETUNDOCOLLECTION → bool
SCI_BEGINUNDOACTION
SCI_ENDUNDOACTION
SCI_ADDUNDOACTION(int token, int flags)

SCI_UNDO
- SCI_CANUNDO
+ SCI_CANUNDO → bool
SCI_UNDO undoes one action, or if the undo buffer has reached a SCI_ENDUNDOACTION point, all the actions back to the corresponding SCI_BEGINUNDOACTION.

@@ -1068,7 +1122,7 @@ struct Sci_TextToFind { typically use the result of this message to enable/disable the Edit menu Undo command.

SCI_REDO
- SCI_CANREDO
+ SCI_CANREDO → bool
SCI_REDO undoes the effect of the last SCI_UNDO operation.

SCI_CANREDO returns 0 if there is no action to redo and 1 if there are undo @@ -1085,7 +1139,7 @@ struct Sci_TextToFind {

See also: SCI_SETSAVEPOINT

SCI_SETUNDOCOLLECTION(bool collectUndo)
- SCI_GETUNDOCOLLECTION
+ SCI_GETUNDOCOLLECTION → bool
You can control whether Scintilla collects undo information with SCI_SETUNDOCOLLECTION. Pass in true (1) to collect information and false (0) to stop collecting. If you stop collection, you should also use @@ -1134,90 +1188,72 @@ struct Sci_TextToFind { (after the last character). If you use messages, there is nothing to stop you setting a position that is in the middle of a CRLF pair, or in the middle of a 2 byte character. However, keyboard commands will not move the caret into such positions.

- SCI_GETTEXTLENGTH
- SCI_GETLENGTH
- SCI_GETLINECOUNT
- SCI_SETFIRSTVISIBLELINE(int lineDisplay)
- SCI_GETFIRSTVISIBLELINE
- SCI_LINESONSCREEN
- SCI_GETMODIFY
- SCI_SETSEL(int anchorPos, int currentPos)
- SCI_GOTOPOS(int position)
+ SCI_GETTEXTLENGTH → int
+ SCI_GETLENGTH → int
+ SCI_GETLINECOUNT → int
+ SCI_LINESONSCREEN → int
+ SCI_GETMODIFY → bool
+ SCI_SETSEL(int anchor, int caret)
+ SCI_GOTOPOS(int caret)
SCI_GOTOLINE(int line)
- SCI_SETCURRENTPOS(int position)
- SCI_GETCURRENTPOS
- SCI_SETANCHOR(int position)
- SCI_GETANCHOR
- SCI_SETSELECTIONSTART(int position)
- SCI_GETSELECTIONSTART
- SCI_SETSELECTIONEND(int position)
- SCI_GETSELECTIONEND
- SCI_SETEMPTYSELECTION(int pos)
+ SCI_SETCURRENTPOS(int caret)
+ SCI_GETCURRENTPOS → position
+ SCI_SETANCHOR(int anchor)
+ SCI_GETANCHOR → position
+ SCI_SETSELECTIONSTART(int anchor)
+ SCI_GETSELECTIONSTART → position
+ SCI_SETSELECTIONEND(int caret)
+ SCI_GETSELECTIONEND → position
+ SCI_SETEMPTYSELECTION(int caret)
SCI_SELECTALL
- SCI_LINEFROMPOSITION(int position)
- SCI_POSITIONFROMLINE(int line)
- SCI_GETLINEENDPOSITION(int line)
- SCI_LINELENGTH(int line)
- SCI_GETCOLUMN(int position)
- SCI_FINDCOLUMN(int line, int column)
- SCI_POSITIONFROMPOINT(int x, int y)
- SCI_POSITIONFROMPOINTCLOSE(int x, int - y)
- SCI_CHARPOSITIONFROMPOINT(int x, int y)
- SCI_CHARPOSITIONFROMPOINTCLOSE(int x, int - y)
- SCI_POINTXFROMPOSITION(<unused>, int - position)
- SCI_POINTYFROMPOSITION(<unused>, int - position)
+ SCI_LINEFROMPOSITION(int pos) → int
+ SCI_POSITIONFROMLINE(int line) → position
+ SCI_GETLINEENDPOSITION(int line) → position
+ SCI_LINELENGTH(int line) → int
+ SCI_GETCOLUMN(int pos) → int
+ SCI_FINDCOLUMN(int line, int column) → int
+ SCI_POSITIONFROMPOINT(int x, int y) → position
+ SCI_POSITIONFROMPOINTCLOSE(int x, int y) → position
+ SCI_CHARPOSITIONFROMPOINT(int x, int y) → position
+ SCI_CHARPOSITIONFROMPOINTCLOSE(int x, int y) → position
+ SCI_POINTXFROMPOSITION(<unused>, int pos) → int
+ SCI_POINTYFROMPOSITION(<unused>, int pos) → int
SCI_HIDESELECTION(bool hide)
- SCI_GETSELTEXT(<unused>, char *text)
- SCI_GETCURLINE(int textLen, char *text)
- SCI_SELECTIONISRECTANGLE
- SCI_SETSELECTIONMODE(int mode)
- SCI_GETSELECTIONMODE
- SCI_GETLINESELSTARTPOSITION(int line)
- SCI_GETLINESELENDPOSITION(int line)
+ SCI_GETSELTEXT(<unused>, char *text) → int
+ SCI_GETCURLINE(int length, char *text) → int
+ SCI_SELECTIONISRECTANGLE → bool
+ SCI_SETSELECTIONMODE(int selectionMode)
+ SCI_GETSELECTIONMODE → int
+ SCI_GETMOVEEXTENDSSELECTION → bool
+ SCI_GETLINESELSTARTPOSITION(int line) → position
+ SCI_GETLINESELENDPOSITION(int line) → position
SCI_MOVECARETINSIDEVIEW
- SCI_WORDENDPOSITION(int position, bool - onlyWordCharacters)
- SCI_WORDSTARTPOSITION(int position, bool - onlyWordCharacters)
- SCI_ISRANGEWORD(int start, int end)
- SCI_POSITIONBEFORE(int position)
- SCI_POSITIONAFTER(int position)
- SCI_POSITIONRELATIVE(int position, int relative)
- SCI_COUNTCHARACTERS(int startPos, int endPos)
- SCI_TEXTWIDTH(int styleNumber, const char *text)
- SCI_TEXTHEIGHT(int line)
+ SCI_POSITIONBEFORE(int pos) → position
+ SCI_POSITIONAFTER(int pos) → position
+ SCI_TEXTWIDTH(int style, const char *text) → int
+ SCI_TEXTHEIGHT(int line) → int
SCI_CHOOSECARETX
SCI_MOVESELECTEDLINESUP
SCI_MOVESELECTEDLINESDOWN
- SCI_SETMOUSESELECTIONRECTANGULARSWITCH(bool - mouseSelectionRectangularSwitch)
- SCI_GETMOUSESELECTIONRECTANGULARSWITCH
+ SCI_SETMOUSESELECTIONRECTANGULARSWITCH(bool mouseSelectionRectangularSwitch)
+ SCI_GETMOUSESELECTIONRECTANGULARSWITCH → bool
-

SCI_GETTEXTLENGTH
- SCI_GETLENGTH
+

SCI_GETTEXTLENGTH → int
+ SCI_GETLENGTH → int
Both these messages return the length of the document in bytes.

-

SCI_GETLINECOUNT
+

SCI_GETLINECOUNT → int
This returns the number of lines in the document. An empty document contains 1 line. A document holding only an end of line sequence has 2 lines.

-

SCI_SETFIRSTVISIBLELINE(int lineDisplay)
- SCI_GETFIRSTVISIBLELINE
- These messages retrieve and set the line number of the first visible line in the Scintilla view. The first line - in the document is numbered 0. The value is a visible line rather than a document line.

- -

SCI_LINESONSCREEN
+

SCI_LINESONSCREEN → int
This returns the number of complete lines visible on the screen. With a constant line height, this is the vertical space available divided by the line separation. Unless you arrange to size your window to an integral number of lines, there may be a partial line visible at the bottom of the view.

-

SCI_GETMODIFY
+

SCI_GETMODIFY → bool
This returns non-zero if the document is modified and 0 if it is unmodified. The modified status of a document is determined by the undo position relative to the save point. The save point is set by SCI_SETSAVEPOINT, @@ -1229,57 +1265,58 @@ struct Sci_TextToFind { href="#SCN_SAVEPOINTLEFT">SCN_SAVEPOINTLEFT notification messages.

-

SCI_SETSEL(int anchorPos, int currentPos)
- This message sets both the anchor and the current position. If currentPos is - negative, it means the end of the document. If anchorPos is negative, it means - remove any selection (i.e. set the anchor to the same position as currentPos). The +

SCI_SETSEL(int anchor, int caret)
+ This message sets both the anchor and the current position. If caret is + negative, it means the end of the document. If anchor is negative, it means + remove any selection (i.e. set the anchor to the same position as caret). The caret is scrolled into view after this operation.

-

SCI_GOTOPOS(int pos)
- This removes any selection, sets the caret at pos and scrolls the view to make +

SCI_GOTOPOS(int caret)
+ This removes any selection, sets the caret at caret and scrolls the view to make the caret visible, if necessary. It is equivalent to - SCI_SETSEL(pos, pos). The anchor position is set the same as the current + SCI_SETSEL(caret, caret). The anchor position is set the same as the current position.

SCI_GOTOLINE(int line)
- This removes any selection and sets the caret at the start of line number line + This removes any selection and sets the caret at the start of line number line and scrolls the view (if needed) to make it visible. The anchor position is set the same as the - current position. If line is outside the lines in the document (first line is 0), + current position. If line is outside the lines in the document (first line is 0), the line set is the first or last.

-

SCI_SETCURRENTPOS(int pos)
+

SCI_SETCURRENTPOS(int caret)
This sets the current position and creates a selection between the anchor and the current position. The caret is not scrolled into view.

See also: SCI_SCROLLCARET

-

SCI_GETCURRENTPOS
+

SCI_GETCURRENTPOS → position
This returns the current position.

-

SCI_SETANCHOR(int pos)
+

SCI_SETANCHOR(int anchor)
This sets the anchor position and creates a selection between the anchor position and the current position. The caret is not scrolled into view.

See also: SCI_SCROLLCARET

-

SCI_GETANCHOR
+

SCI_GETANCHOR → position
This returns the current anchor position.

-

SCI_SETSELECTIONSTART(int pos)
- SCI_SETSELECTIONEND(int pos)
+

SCI_SETSELECTIONSTART(int anchor)
+ SCI_SETSELECTIONEND(int caret)
These set the selection based on the assumption that the anchor position is less than the current position. They do not make the caret visible. The table shows the positions of the anchor and the current position after using these messages.

-
SC_STATUS_OKSC_STATUS_OK 0 No failures
SC_STATUS_FAILURESC_STATUS_FAILURE 1 Generic failure
SC_STATUS_BADALLOC
SC_STATUS_BADALLOC 2 Memory is exhausted
SC_STATUS_WARN_REGEXSC_STATUS_WARN_REGEX 1001 Regular expression is invalid
+
- + @@ -1287,96 +1324,96 @@ struct Sci_TextToFind { - + - + - + - +
+ New value for anchorcurrentcaret
SCI_SETSELECTIONSTARTposanchorMax(pos, current)Max(anchor, current)
SCI_SETSELECTIONENDMin(anchor, pos)Min(anchor, caret)poscaret

See also: SCI_SCROLLCARET

-

SCI_GETSELECTIONSTART
- SCI_GETSELECTIONEND
+

SCI_GETSELECTIONSTART → position
+ SCI_GETSELECTIONEND → position
These return the start and end of the selection without regard to which end is the current position and which is the anchor. SCI_GETSELECTIONSTART returns the smaller of the current position or the anchor position. SCI_GETSELECTIONEND returns the larger of the two values.

-

SCI_SETEMPTYSELECTION(int pos)
- This removes any selection and sets the caret at pos. The caret is not scrolled into view.

+

SCI_SETEMPTYSELECTION(int caret)
+ This removes any selection and sets the caret at caret. The caret is not scrolled into view.

SCI_SELECTALL
This selects all the text in the document. The current position is not scrolled into view.

-

SCI_LINEFROMPOSITION(int pos)
- This message returns the line that contains the position pos in the document. The - return value is 0 if pos <= 0. The return value is the last line if - pos is beyond the end of the document.

+

SCI_LINEFROMPOSITION(int pos) → int
+ This message returns the line that contains the position pos in the document. The + return value is 0 if pos <= 0. The return value is the last line if + pos is beyond the end of the document.

-

SCI_POSITIONFROMLINE(int line)
+

SCI_POSITIONFROMLINE(int line) → position
This returns the document position that corresponds with the start of the line. If - line is negative, the position of the line holding the start of the selection is - returned. If line is greater than the lines in the document, the return value is - -1. If line is equal to the number of lines in the document (i.e. 1 line past the + line is negative, the position of the line holding the start of the selection is + returned. If line is greater than the lines in the document, the return value is + -1. If line is equal to the number of lines in the document (i.e. 1 line past the last line), the return value is the end of the document.

-

SCI_GETLINEENDPOSITION(int line)
- This returns the position at the end of the line, before any line end characters. If line +

SCI_GETLINEENDPOSITION(int line) → position
+ This returns the position at the end of the line, before any line end characters. If line is the last line in the document (which does not have any end of line characters) or greater, the result is the size of the document. - If line is negative the result is undefined.

+ If line is negative the result is undefined.

-

SCI_LINELENGTH(int line)
- This returns the length of the line, including any line end characters. If line +

SCI_LINELENGTH(int line) → int
+ This returns the length of the line, including any line end characters. If line is negative or beyond the last line in the document, the result is 0. If you want the length of the line not including any end of line characters, use SCI_GETLINEENDPOSITION(line) - SCI_POSITIONFROMLINE(line).

-

SCI_GETSELTEXT(<unused>, char *text NUL-terminated)
- This copies the currently selected text and a terminating 0 byte to the text - buffer. The buffer size should be determined by calling with a NULL pointer for the text argument +

SCI_GETSELTEXT(<unused>, char *text NUL-terminated) → int
+ This copies the currently selected text and a terminating 0 byte to the text + buffer. The buffer size should be determined by calling with a NULL pointer for the text argument SCI_GETSELTEXT(0,0). This allows for rectangular and discontiguous selections as well as simple selections. See Multiple Selection for information on how multiple and rectangular selections and virtual space are copied.

-

See also: SCI_GETCURLINE, - SCI_GETLINE, - SCI_GETTEXT, - SCI_GETSTYLEDTEXT, - SCI_GETTEXTRANGE +

See also: SCI_GETCURLINE, + SCI_GETLINE, + SCI_GETTEXT, + SCI_GETSTYLEDTEXT, + SCI_GETTEXTRANGE

-

SCI_GETCURLINE(int textLen, char *text NUL-terminated)
+

SCI_GETCURLINE(int length, char *text NUL-terminated) → int
This retrieves the text of the line containing the caret and returns the position within the line of the caret. Pass in char* text pointing at a buffer large enough to hold the text you wish to retrieve and a terminating 0 character. - Set textLen to the + Set length to the length of the buffer which must be at least 1 to hold the terminating 0 character. If the text argument is 0 then the length that should be allocated to store the entire current line is returned.

-

See also: SCI_GETSELTEXT, SCI_GETLINE, SCI_GETTEXT, SCI_GETSTYLEDTEXT, See also: SCI_GETSELTEXT, SCI_GETLINE, SCI_GETTEXT, SCI_GETSTYLEDTEXT, SCI_GETTEXTRANGE

-

SCI_SELECTIONISRECTANGLE
+

SCI_SELECTIONISRECTANGLE → bool
This returns 1 if the current selection is in rectangle mode, 0 if not.

-

SCI_SETSELECTIONMODE(int mode)
- SCI_GETSELECTIONMODE
+

SCI_SETSELECTIONMODE(int selectionMode)
+ SCI_GETSELECTIONMODE → int
The two functions set and get the selection mode, which can be stream (SC_SEL_STREAM=0) or rectangular (SC_SEL_RECTANGLE=1) or @@ -1389,8 +1426,12 @@ struct Sci_TextToFind { SC_SEL_THIN is the mode after a rectangular selection has been typed into and ensures that no characters are selected.

-

SCI_GETLINESELSTARTPOSITION(int line)
- SCI_GETLINESELENDPOSITION(int line)
+

SCI_GETMOVEEXTENDSSELECTION → bool
+ This returns 1 if regular caret moves will extend or reduce the selection, 0 if not. + SCI_SETSELECTIONMODE toggles this setting between on and off.

+ +

SCI_GETLINESELSTARTPOSITION(int line) → position
+ SCI_GETLINESELENDPOSITION(int line) → position
Retrieve the position of the start and end of the selection at the given line with INVALID_POSITION returned if no selection on this line.

@@ -1398,152 +1439,52 @@ struct Sci_TextToFind { If the caret is off the top or bottom of the view, it is moved to the nearest line that is visible to its current position. Any selection is lost.

-

SCI_WORDENDPOSITION(int position, bool - onlyWordCharacters)
- SCI_WORDSTARTPOSITION(int position, bool - onlyWordCharacters)
- These messages return the start and end of words using the same definition of words as used - internally within Scintilla. You can set your own list of characters that count as words with - SCI_SETWORDCHARS. The position - sets the start or the search, which is forwards when searching for the end and backwards when - searching for the start.

- -

SCI_ISRANGEWORD(int start, int end)
- Is the range start..end a word or set of words? This message checks that start is at a word start transition and that - end is at a word end transition. It does not check whether there are any spaces inside the range.

- - SCI_ISRANGEWORD(int start, int end)
- -

Set onlyWordCharacters to true (1) to stop searching at the first - non-word character in the search direction. If onlyWordCharacters is - false (0), the first character in the search direction sets the type of the search - as word or non-word and the search stops at the first non-matching character. Searches are also - terminated by the start or end of the document.

- -

If "w" represents word characters and "." represents non-word characters and "|" represents - the position and true or false is the state of - onlyWordCharacters:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Initial stateend, trueend, falsestart, truestart, false
..ww..|..ww....ww..|..ww....ww....|ww....ww..|..ww....ww|....ww..
....ww|ww........wwww|........wwww|........|wwww........|wwww....
..ww|....ww....ww|....ww....ww....|ww....|ww....ww....|ww....ww..
..ww....|ww....ww....ww|....ww....ww|....ww....|ww....ww|....ww..
- -

SCI_POSITIONBEFORE(int position)
- SCI_POSITIONAFTER(int position)
+

SCI_POSITIONBEFORE(int pos) → position
+ SCI_POSITIONAFTER(int pos) → position
These messages return the position before and after another position in the document taking into account the current code page. The minimum position returned is 0 and the maximum is the last position in the document. If called with a position within a multi byte character will return the position of the start/end of that character.

-

SCI_POSITIONRELATIVE(int position, int relative)
- Count a number of whole characters before or after the argument position and return that position. - The minimum position returned is 0 and the maximum is the last position in the document. -

- -

SCI_COUNTCHARACTERS(int startPos, int endPos)
- Returns the number of whole characters between two positions..

- -

SCI_TEXTWIDTH(int styleNumber, const char *text)
- This returns the pixel width of a string drawn in the given styleNumber which can +

SCI_TEXTWIDTH(int style, const char *text) → int
+ This returns the pixel width of a string drawn in the given style which can be used, for example, to decide how wide to make the line number margin in order to display a given number of numerals.

-

SCI_TEXTHEIGHT(int line)
+

SCI_TEXTHEIGHT(int line) → int
This returns the height in pixels of a particular line. Currently all lines are the same height.

-

SCI_GETCOLUMN(int pos)
- This message returns the column number of a position pos within the document +

SCI_GETCOLUMN(int pos) → int
+ This message returns the column number of a position pos within the document taking the width of tabs into account. This returns the column number of the last tab on the - line before pos, plus the number of characters between the last tab and - pos. If there are no tab characters on the line, the return value is the number of + line before pos, plus the number of characters between the last tab and + pos. If there are no tab characters on the line, the return value is the number of characters up to the position on the line. In both cases, double byte characters count as a single character. This is probably only useful with monospaced fonts.

-

SCI_FINDCOLUMN(int line, int column)
- This message returns the position of a column on a line +

SCI_FINDCOLUMN(int line, int column) → int
+ This message returns the position of a column on a line taking the width of tabs into account. It treats a multi-byte character as a single column. Column numbers, like lines start at 0.

-

SCI_POSITIONFROMPOINT(int x, int y)
- SCI_POSITIONFROMPOINTCLOSE(int x, int y)
+

SCI_POSITIONFROMPOINT(int x, int y) → position
+ SCI_POSITIONFROMPOINTCLOSE(int x, int y) → position
SCI_POSITIONFROMPOINT finds the closest character position to a point and SCI_POSITIONFROMPOINTCLOSE is similar but returns -1 if the point is outside the window or not close to any characters.

-

SCI_CHARPOSITIONFROMPOINT(int x, int y)
- SCI_CHARPOSITIONFROMPOINTCLOSE(int x, int y)
+

SCI_CHARPOSITIONFROMPOINT(int x, int y) → position
+ SCI_CHARPOSITIONFROMPOINTCLOSE(int x, int y) → position
SCI_CHARPOSITIONFROMPOINT finds the closest character to a point and SCI_CHARPOSITIONFROMPOINTCLOSE is similar but returns -1 if the point is outside the window or not close to any characters. This is similar to the previous methods but finds characters rather than inter-character positions.

-

SCI_POINTXFROMPOSITION(<unused>, int pos)
- SCI_POINTYFROMPOSITION(<unused>, int pos)
- These messages return the x and y display pixel location of text at position pos +

SCI_POINTXFROMPOSITION(<unused>, int pos) → int
+ SCI_POINTYFROMPOSITION(<unused>, int pos) → int
+ These messages return the x and y display pixel location of text at position pos in the document.

SCI_HIDESELECTION(bool hide)
@@ -1569,72 +1510,127 @@ struct Sci_TextToFind {

SCI_SETMOUSESELECTIONRECTANGULARSWITCH(bool mouseSelectionRectangularSwitch)
- SCI_GETMOUSESELECTIONRECTANGULARSWITCH
+ SCI_GETMOUSESELECTIONRECTANGULARSWITCH → bool
Enable or disable the ability to switch to rectangular selection mode while making a selection with the mouse. When this option is turned on, mouse selections in stream mode can be switched to rectangular mode by pressing the corresponding modifier key. They then stick to rectangular mode even when the modifier key is released again. When this option is turned off, mouse selections will always stick to the mode the selection was started in. It is off by default.

+

By character or UTF-16 code unit

+ +

Most Scintilla APIs use byte positions but some applications want to use positions based on counting + (UTF-32) characters or (UTF-16) code units + or need to communicate with other code written in terms of characters or code units. + With only byte positions, this may require examining many bytes to count characters or code units in the document + but this may be sped up in some cases by indexing the line starts by character or code unit.

+ + + SCI_POSITIONRELATIVE(int pos, int relative) → position
+ SCI_POSITIONRELATIVECODEUNITS(int pos, int relative) → position
+ SCI_COUNTCHARACTERS(int start, int end) → int
+ SCI_COUNTCODEUNITS(int start, int end) → int
+ SCI_GETLINECHARACTERINDEX → int
+ SCI_ALLOCATELINECHARACTERINDEX(int lineCharacterIndex)
+ SCI_RELEASELINECHARACTERINDEX(int lineCharacterIndex)
+ SCI_LINEFROMINDEXPOSITION(int pos, int lineCharacterIndex) → int
+ SCI_INDEXPOSITIONFROMLINE(int line, int lineCharacterIndex) → position
+
+ +

SCI_POSITIONRELATIVE(int pos, int relative) → position
+ Count a number of whole characters before or after the argument position and return that position. + The minimum position returned is 0 and the maximum is the last position in the document. + If the position goes past the document end then 0 is returned. +

+ +

SCI_COUNTCHARACTERS(int start, int end) → int
+ Returns the number of whole characters between two positions.

+ +

SCI_POSITIONRELATIVECODEUNITS(int pos, int relative) → position
+ SCI_COUNTCODEUNITS(int start, int end) → int
+ These are the UTF-16 versions of SCI_POSITIONRELATIVE and SCI_COUNTCHARACTERS + working in terms of UTF-16 code units.

+ +

SCI_GETLINECHARACTERINDEX → int
+ Returns which if any indexes are active. It may be SC_LINECHARACTERINDEX_NONE(0) or one or more + of SC_LINECHARACTERINDEX_UTF32(1) if whole characters are indexed or + SC_LINECHARACTERINDEX_UTF16(2) if UTF-16 code units are indexed. + Character indexes are currently only supported for UTF-8 documents.

+ +

SCI_ALLOCATELINECHARACTERINDEX(int lineCharacterIndex)
+ SCI_RELEASELINECHARACTERINDEX(int lineCharacterIndex)
+ Allocate or release one or more indexes using same enumeration as SCI_GETLINECHARACTERINDEX. + Different aspects of an application may need indexes for different periods and should allocate for those periods. + Indexes use additional memory so releasing them can help minimize memory but they also take time to recalculate. + Scintilla may also allocate indexes to support features like accessibility or input method editors. + Only one index of each type is created for a document at a time.

+ +

SCI_LINEFROMINDEXPOSITION(int pos, int lineCharacterIndex) → int
+ SCI_INDEXPOSITIONFROMLINE(int line, int lineCharacterIndex) → position
+ The document line of a particular character or code unit may be found by calling SCI_LINEFROMINDEXPOSITION with one of + SC_LINECHARACTERINDEX_UTF32(1) or SC_LINECHARACTERINDEX_UTF16(2). + The inverse action, finds the starting position of a document line either in characters or code units from the document start by calling + SCI_INDEXPOSITIONFROMLINE with the same lineCharacterIndex argument.

+

Multiple Selection and Virtual Space

SCI_SETMULTIPLESELECTION(bool multipleSelection)
- SCI_GETMULTIPLESELECTION
+ SCI_GETMULTIPLESELECTION → bool
SCI_SETADDITIONALSELECTIONTYPING(bool additionalSelectionTyping)
- SCI_GETADDITIONALSELECTIONTYPING
+ SCI_GETADDITIONALSELECTIONTYPING → bool
SCI_SETMULTIPASTE(int multiPaste)
- SCI_GETMULTIPASTE
+ SCI_GETMULTIPASTE → int
SCI_SETVIRTUALSPACEOPTIONS(int virtualSpaceOptions)
- SCI_GETVIRTUALSPACEOPTIONS
+ SCI_GETVIRTUALSPACEOPTIONS → int
SCI_SETRECTANGULARSELECTIONMODIFIER(int modifier)
- SCI_GETRECTANGULARSELECTIONMODIFIER
+ SCI_GETRECTANGULARSELECTIONMODIFIER → int

- SCI_GETSELECTIONS
- SCI_GETSELECTIONEMPTY
+ SCI_GETSELECTIONS → int
+ SCI_GETSELECTIONEMPTY → bool
SCI_CLEARSELECTIONS
SCI_SETSELECTION(int caret, int anchor)
SCI_ADDSELECTION(int caret, int anchor)
SCI_DROPSELECTIONN(int selection)
SCI_SETMAINSELECTION(int selection)
- SCI_GETMAINSELECTION
+ SCI_GETMAINSELECTION → int

- SCI_SETSELECTIONNCARET(int selection, int pos)
- SCI_GETSELECTIONNCARET(int selection)
+ SCI_SETSELECTIONNCARET(int selection, int caret)
+ SCI_GETSELECTIONNCARET(int selection) → position
SCI_SETSELECTIONNCARETVIRTUALSPACE(int selection, int space)
- SCI_GETSELECTIONNCARETVIRTUALSPACE(int selection)
- SCI_SETSELECTIONNANCHOR(int selection, int posAnchor)
- SCI_GETSELECTIONNANCHOR(int selection)
+ SCI_GETSELECTIONNCARETVIRTUALSPACE(int selection) → int
+ SCI_SETSELECTIONNANCHOR(int selection, int anchor)
+ SCI_GETSELECTIONNANCHOR(int selection) → position
SCI_SETSELECTIONNANCHORVIRTUALSPACE(int selection, int space)
- SCI_GETSELECTIONNANCHORVIRTUALSPACE(int selection)
- SCI_SETSELECTIONNSTART(int selection, int pos)
- SCI_GETSELECTIONNSTART(int selection)
- SCI_SETSELECTIONNEND(int selection, int pos)
- SCI_GETSELECTIONNEND(int selection)
+ SCI_GETSELECTIONNANCHORVIRTUALSPACE(int selection) → int
+ SCI_SETSELECTIONNSTART(int selection, int anchor)
+ SCI_GETSELECTIONNSTART(int selection) → position
+ SCI_SETSELECTIONNEND(int selection, int caret)
+ SCI_GETSELECTIONNEND(int selection) → position

- SCI_SETRECTANGULARSELECTIONCARET(int pos)
- SCI_GETRECTANGULARSELECTIONCARET
+ SCI_SETRECTANGULARSELECTIONCARET(int caret)
+ SCI_GETRECTANGULARSELECTIONCARET → position
SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE(int space)
- SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE
- SCI_SETRECTANGULARSELECTIONANCHOR(int posAnchor)
- SCI_GETRECTANGULARSELECTIONANCHOR
+ SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE → int
+ SCI_SETRECTANGULARSELECTIONANCHOR(int anchor)
+ SCI_GETRECTANGULARSELECTIONANCHOR → position
SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE(int space)
- SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE
+ SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE → int

- SCI_SETADDITIONALSELALPHA(int alpha)
- SCI_GETADDITIONALSELALPHA
- SCI_SETADDITIONALSELFORE(int colour)
- SCI_SETADDITIONALSELBACK(int colour)
- SCI_SETADDITIONALCARETFORE(int colour)
- SCI_GETADDITIONALCARETFORE
+ SCI_SETADDITIONALSELALPHA(alpha alpha)
+ SCI_GETADDITIONALSELALPHA → int
+ SCI_SETADDITIONALSELFORE(colour fore)
+ SCI_SETADDITIONALSELBACK(colour back)
+ SCI_SETADDITIONALCARETFORE(colour fore)
+ SCI_GETADDITIONALCARETFORE → colour
SCI_SETADDITIONALCARETSBLINK(bool additionalCaretsBlink)
- SCI_GETADDITIONALCARETSBLINK
+ SCI_GETADDITIONALCARETSBLINK → bool
SCI_SETADDITIONALCARETSVISIBLE(bool additionalCaretsVisible)
- SCI_GETADDITIONALCARETSVISIBLE
+ SCI_GETADDITIONALCARETSVISIBLE → bool

SCI_SWAPMAINANCHORCARET
@@ -1673,46 +1669,51 @@ struct Sci_TextToFind {

SCI_SETMULTIPLESELECTION(bool multipleSelection)
- SCI_GETMULTIPLESELECTION
+ SCI_GETMULTIPLESELECTION → bool
Enable or disable multiple selection. When multiple selection is disabled, it is not possible to select multiple ranges by holding down the Ctrl key while dragging with the mouse.

SCI_SETADDITIONALSELECTIONTYPING(bool additionalSelectionTyping)
- SCI_GETADDITIONALSELECTIONTYPING
+ SCI_GETADDITIONALSELECTIONTYPING → bool
Whether typing, new line, cursor left/right/up/down, backspace, delete, home, and end work with multiple selections simultaneously. Also allows selection and word and line deletion commands.

SCI_SETMULTIPASTE(int multiPaste)
- SCI_GETMULTIPASTE
+ SCI_GETMULTIPASTE → int
When pasting into multiple selections, the pasted text can go into just the main selection with SC_MULTIPASTE_ONCE=0 or into each selection with SC_MULTIPASTE_EACH=1. SC_MULTIPASTE_ONCE is the default.

- SCI_SETVIRTUALSPACEOPTIONS(int virtualSpace)
- SCI_GETVIRTUALSPACEOPTIONS
+ SCI_SETVIRTUALSPACEOPTIONS(int virtualSpaceOptions)
+ SCI_GETVIRTUALSPACEOPTIONS → int
Virtual space can be enabled or disabled for rectangular selections or in other circumstances or in both. - There are two bit flags SCVS_RECTANGULARSELECTION=1 and - SCVS_USERACCESSIBLE=2 which can be set independently. + There are three bit flags SCVS_RECTANGULARSELECTION=1, + SCVS_USERACCESSIBLE=2, and + SCVS_NOWRAPLINESTART=4 which can be set independently. SCVS_NONE=0, the default, disables all use of virtual space.

+

SCVS_NOWRAPLINESTART prevents left arrow movement and selection + from wrapping to the previous line. + This is most commonly desired in conjunction with virtual space but is an independent + setting so works without virtual space.

SCI_SETRECTANGULARSELECTIONMODIFIER(int modifier)
- SCI_GETRECTANGULARSELECTIONMODIFIER
- On GTK+, the key used to indicate that a rectangular selection should be created when combined with a mouse drag can be set. - The three possible values are SCMOD_CTRL=2 (default), SCMOD_ALT=4 or SCMOD_SUPER=8. - Since SCMOD_ALT is often already used by a window manager, the window manager may need configuring to allow this choice. + SCI_GETRECTANGULARSELECTIONMODIFIER → int
+ On GTK and Qt, the key used to indicate that a rectangular selection should be created when combined with a mouse drag can be set. + The three possible values are SCMOD_CTRL=2, SCMOD_ALT=4 (default) or SCMOD_SUPER=8. + Since SCMOD_ALT may already be used by a window manager, the window manager may need configuring to allow this choice. SCMOD_SUPER is often a system dependent modifier key such as the Left Windows key on a Windows keyboard or the Command key on a Mac.

- SCI_GETSELECTIONS
+ SCI_GETSELECTIONS → int
Return the number of selections currently active. There is always at least one selection.

- SCI_GETSELECTIONEMPTY
+ SCI_GETSELECTIONEMPTY → bool
Return 1 if every selected range is empty else 0.

@@ -1721,11 +1722,11 @@ struct Sci_TextToFind {

SCI_SETSELECTION(int caret, int anchor)
- Set a single selection from anchor to caret as the only selection.

+ Set a single selection from anchor to caret as the only selection.

SCI_ADDSELECTION(int caret, int anchor)
- Add a new selection from anchor to caret as the main selection retaining all other + Add a new selection from anchor to caret as the main selection retaining all other selections as additional selections. Since there is always at least one selection, to set a list of selections, the first selection should be added with SCI_SETSELECTION and later selections added with SCI_ADDSELECTION

@@ -1734,51 +1735,51 @@ struct Sci_TextToFind { SCI_DROPSELECTIONN(int selection)
If there are multiple selections, remove the indicated selection. If this was the main selection then make the previous selection the main and if it was the first then the last selection becomes main. - If there is only one selection, or there is no selection selection, then there is no effect.

+ If there is only one selection, or there is no selection selection, then there is no effect.

SCI_SETMAINSELECTION(int selection)
- SCI_GETMAINSELECTION
+ SCI_GETMAINSELECTION → int
One of the selections is the main selection which is used to determine what range of text is automatically visible. The main selection may be displayed in different colours or with a differently styled caret. Only an already existing selection can be made main.

- SCI_SETSELECTIONNCARET(int selection, int pos)
- SCI_GETSELECTIONNCARET(int selection)
+ SCI_SETSELECTIONNCARET(int selection, int caret)
+ SCI_GETSELECTIONNCARET(int selection) → position
SCI_SETSELECTIONNCARETVIRTUALSPACE(int selection, int space)
- SCI_GETSELECTIONNCARETVIRTUALSPACE(int selection)
- SCI_SETSELECTIONNANCHOR(int selection, int posAnchor)
- SCI_GETSELECTIONNANCHOR(int selection)
+ SCI_GETSELECTIONNCARETVIRTUALSPACE(int selection) → int
+ SCI_SETSELECTIONNANCHOR(int selection, int anchor)
+ SCI_GETSELECTIONNANCHOR(int selection) → position
SCI_SETSELECTIONNANCHORVIRTUALSPACE(int selection, int space)
- SCI_GETSELECTIONNANCHORVIRTUALSPACE(int selection)
+ SCI_GETSELECTIONNANCHORVIRTUALSPACE(int selection) → int
Set or query the position and amount of virtual space for the caret and anchor of each already existing selection.

- SCI_SETSELECTIONNSTART(int selection, int pos)
- SCI_GETSELECTIONNSTART(int selection)
- SCI_SETSELECTIONNEND(int selection, int pos)
- SCI_GETSELECTIONNEND(int selection)
+ SCI_SETSELECTIONNSTART(int selection, int anchor)
+ SCI_GETSELECTIONNSTART(int selection) → position
+ SCI_SETSELECTIONNEND(int selection, int caret)
+ SCI_GETSELECTIONNEND(int selection) → position
Set or query the start and end position of each already existing selection. Mostly of use to query each range for its text. The selection parameter is zero-based.

- SCI_SETRECTANGULARSELECTIONCARET(int pos)
- SCI_GETRECTANGULARSELECTIONCARET
+ SCI_SETRECTANGULARSELECTIONCARET(int caret)
+ SCI_GETRECTANGULARSELECTIONCARET → position
SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE(int space)
- SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE
- SCI_SETRECTANGULARSELECTIONANCHOR(int posAnchor)
- SCI_GETRECTANGULARSELECTIONANCHOR
+ SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE → int
+ SCI_SETRECTANGULARSELECTIONANCHOR(int anchor)
+ SCI_GETRECTANGULARSELECTIONANCHOR → position
SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE(int space)
- SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE
+ SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE → int
Set or query the position and amount of virtual space for the caret and anchor of the rectangular selection. After setting the rectangular selection, this is broken down into multiple selections, one for each line.

- SCI_SETADDITIONALSELALPHA(int alpha)
- SCI_GETADDITIONALSELALPHA
- SCI_SETADDITIONALSELFORE(int colour)
- SCI_SETADDITIONALSELBACK(int colour)
+ SCI_SETADDITIONALSELALPHA(alpha alpha)
+ SCI_GETADDITIONALSELALPHA → int
+ SCI_SETADDITIONALSELFORE(colour fore)
+ SCI_SETADDITIONALSELBACK(colour back)
Modify the appearance of additional selections so that they can be differentiated from the main selection which has its appearance set with SCI_SETSELALPHA, SCI_GETSELALPHA, @@ -1793,10 +1794,10 @@ struct Sci_TextToFind { and SCI_SETSELBACK will overwrite the values set by SCI_SETADDITIONALSEL* functions.

- SCI_SETADDITIONALCARETFORE(int colour)
- SCI_GETADDITIONALCARETFORE
+ SCI_SETADDITIONALCARETFORE(colour fore)
+ SCI_GETADDITIONALCARETFORE → colour
SCI_SETADDITIONALCARETSBLINK(bool additionalCaretsBlink)
- SCI_GETADDITIONALCARETSBLINK
+ SCI_GETADDITIONALCARETSBLINK → bool
Modify the appearance of additional carets so that they can be differentiated from the main caret which has its appearance set with SCI_SETCARETFORE, SCI_GETCARETFORE, @@ -1805,7 +1806,7 @@ struct Sci_TextToFind {

SCI_SETADDITIONALCARETSVISIBLE(bool additionalCaretsVisible)
- SCI_GETADDITIONALCARETSVISIBLE
+ SCI_GETADDITIONALCARETSVISIBLE → bool
Determine whether to show additional carets (defaults to true).

@@ -1825,31 +1826,45 @@ struct Sci_TextToFind {

Scrolling and automatic scrolling

- SCI_LINESCROLL(int column, int line)
+ + SCI_SETFIRSTVISIBLELINE(int displayLine)
+ SCI_GETFIRSTVISIBLELINE → int
+ SCI_SETXOFFSET(int xOffset)
+ SCI_GETXOFFSET → int
+ SCI_LINESCROLL(int columns, int lines)
SCI_SCROLLCARET
SCI_SCROLLRANGE(int secondary, int primary)
SCI_SETXCARETPOLICY(int caretPolicy, int caretSlop)
SCI_SETYCARETPOLICY(int caretPolicy, int caretSlop)
- SCI_SETVISIBLEPOLICY(int caretPolicy, int - caretSlop)
+ SCI_SETVISIBLEPOLICY(int visiblePolicy, int + visibleSlop)
SCI_SETHSCROLLBAR(bool visible)
- SCI_GETHSCROLLBAR
+ SCI_GETHSCROLLBAR → bool
SCI_SETVSCROLLBAR(bool visible)
- SCI_GETVSCROLLBAR
- SCI_GETXOFFSET
- SCI_SETXOFFSET(int xOffset)
+ SCI_GETVSCROLLBAR → bool
SCI_SETSCROLLWIDTH(int pixelWidth)
- SCI_GETSCROLLWIDTH
+ SCI_GETSCROLLWIDTH → int
SCI_SETSCROLLWIDTHTRACKING(bool tracking)
- SCI_GETSCROLLWIDTHTRACKING
+ SCI_GETSCROLLWIDTHTRACKING → bool
SCI_SETENDATLASTLINE(bool endAtLastLine)
- SCI_GETENDATLASTLINE
+ SCI_GETENDATLASTLINE → bool
-

SCI_LINESCROLL(int column, int line)
+

SCI_SETFIRSTVISIBLELINE(int displayLine)
+ SCI_GETFIRSTVISIBLELINE → int
+ These messages retrieve and set the line number of the first visible line in the Scintilla view. The first line + in the document is numbered 0. The value is a visible line rather than a document line.

+ +

SCI_SETXOFFSET(int xOffset)
+ SCI_GETXOFFSET → int
+ The xOffset is the horizontal scroll position in pixels of the start of the text + view. A value of 0 is the normal position with the first text column visible at the left of the + view.

+ +

SCI_LINESCROLL(int columns, int lines)
This will attempt to scroll the display by the number of columns and lines that you specify. Positive line values increase the line number at the top of the screen (i.e. they move the text upwards as far as the user is concerned), Negative line values do the reverse.

@@ -1874,16 +1889,16 @@ struct Sci_TextToFind {

SCI_SETXCARETPOLICY(int caretPolicy, int caretSlop)
SCI_SETYCARETPOLICY(int caretPolicy, int caretSlop)
- These set the caret policy. The value of caretPolicy is a combination of + These set the caret policy. The value of caretPolicy is a combination of CARET_SLOP, CARET_STRICT, CARET_JUMPS and CARET_EVEN.

- +
- + is centred on the display if caretSlop is not set, and cannot go in the UZ + if caretSlop is set. @@ -1918,8 +1933,9 @@ struct Sci_TextToFind {
CARET_SLOPIf set, we can define a slop value: caretSlop. This value defines an + If set, we can define a slop value: caretSlop. This value defines an unwanted zone (UZ) where the caret is... unwanted. This zone is defined as a number of pixels near the vertical margins, and as a number of lines near the horizontal margins. By keeping the caret away from the edges, it is seen within its context. This makes it @@ -1896,8 +1911,8 @@ struct Sci_TextToFind { CARET_STRICT If set, the policy set by CARET_SLOP is enforced... strictly. The caret - is centred on the display if caretSlop is not set, and cannot go in the UZ - if caretSlop is set.
+
- +
@@ -2122,7 +2138,7 @@ struct Sci_TextToFind {
slop
-

SCI_SETVISIBLEPOLICY(int caretPolicy, int caretSlop)
+

SCI_SETVISIBLEPOLICY(int visiblePolicy, int visibleSlop)
This determines how the vertical positioning is determined when SCI_ENSUREVISIBLEENFORCEPOLICY is called. It takes VISIBLE_SLOP and VISIBLE_STRICT flags for the policy @@ -2131,30 +2147,24 @@ struct Sci_TextToFind { caretSlop)
.

SCI_SETHSCROLLBAR(bool visible)
- SCI_GETHSCROLLBAR
+ SCI_GETHSCROLLBAR → bool
The horizontal scroll bar is only displayed if it is needed for the assumed width. If you never wish to see it, call SCI_SETHSCROLLBAR(0). Use SCI_SETHSCROLLBAR(1) to enable it again. SCI_GETHSCROLLBAR returns the current state. The default state is to display it when needed.

-

See also: SCI_SETSCROLLWIDTH.

+

See also: SCI_SETSCROLLWIDTH.

SCI_SETVSCROLLBAR(bool visible)
- SCI_GETVSCROLLBAR
+ SCI_GETVSCROLLBAR → bool
By default, the vertical scroll bar is always displayed when required. You can choose to hide or show it with SCI_SETVSCROLLBAR and get the current state with SCI_GETVSCROLLBAR.

-

SCI_SETXOFFSET(int xOffset)
- SCI_GETXOFFSET
- The xOffset is the horizontal scroll position in pixels of the start of the text - view. A value of 0 is the normal position with the first text column visible at the left of the - view.

-

See also: SCI_LINESCROLL

SCI_SETSCROLLWIDTH(int pixelWidth)
- SCI_GETSCROLLWIDTH
+ SCI_GETSCROLLWIDTH → int
For performance, Scintilla does not measure the display width of the document to determine the properties of the horizontal scroll bar. Instead, an assumed width is used. These messages set and get the document width in pixels assumed by Scintilla. @@ -2163,41 +2173,43 @@ struct Sci_TextToFind { SCI_SETSCROLLWIDTHTRACKING

SCI_SETSCROLLWIDTHTRACKING(bool tracking)
- SCI_GETSCROLLWIDTHTRACKING
+ SCI_GETSCROLLWIDTHTRACKING → bool
If scroll width tracking is enabled then the scroll width is adjusted to ensure that all of the lines currently displayed can be completely scrolled. This mode never adjusts the scroll width to be narrower.

SCI_SETENDATLASTLINE(bool endAtLastLine)
- SCI_GETENDATLASTLINE
+ SCI_GETENDATLASTLINE → bool
SCI_SETENDATLASTLINE sets the scroll range so that maximum scroll position has the last line at the bottom of the view (default). Setting this to false allows scrolling one page below the last line.

White space

- SCI_SETVIEWWS(int wsMode)
- SCI_GETVIEWWS
+ SCI_SETVIEWWS(int viewWS)
+ SCI_GETVIEWWS → int
SCI_SETWHITESPACEFORE(bool - useWhitespaceForeColour, int colour)
+ useSetting, colour fore)
SCI_SETWHITESPACEBACK(bool - useWhitespaceBackColour, int colour)
+ useSetting, colour back)
SCI_SETWHITESPACESIZE(int size)
- SCI_GETWHITESPACESIZE
+ SCI_GETWHITESPACESIZE → int
+ SCI_SETTABDRAWMODE(int tabDrawMode)
+ SCI_GETTABDRAWMODE → int
SCI_SETEXTRAASCENT(int extraAscent)
- SCI_GETEXTRAASCENT
+ SCI_GETEXTRAASCENT → int
SCI_SETEXTRADESCENT(int extraDescent)
- SCI_GETEXTRADESCENT
+ SCI_GETEXTRADESCENT → int
-

SCI_SETVIEWWS(int wsMode)
- SCI_GETVIEWWS
+

SCI_SETVIEWWS(int viewWS)
+ SCI_GETVIEWWS → int
White space can be made visible which may be useful for languages in which white space is significant, such as Python. Space characters appear as small centred dots and tab characters as light arrows pointing to the right. There are also ways to control the display of end of line characters. The two messages set and get the - white space display mode. The wsMode argument can be one of:

+ white space display mode. The viewWS argument can be one of:

- +
@@ -2224,31 +2236,64 @@ struct Sci_TextToFind { + + + + + + + +
SCWS_INVISIBLEWhite space used for indentation is displayed normally but after the first visible character, it is shown as dots and arrows.
SCWS_VISIBLEONLYININDENT3White space used for indentation is displayed as dots and arrows.
-

The effect of using any other wsMode value is undefined.

+

The effect of using any other viewWS value is undefined.

-

SCI_SETWHITESPACEFORE(bool useWhitespaceForeColour, int colour)
- SCI_SETWHITESPACEBACK(bool useWhitespaceBackColour, int colour)
+

SCI_SETWHITESPACEFORE(bool useSetting, colour fore)
+ SCI_SETWHITESPACEBACK(bool useSetting, colour back)
By default, the colour of visible white space is determined by the lexer in use. The foreground and/or background colour of all visible white space can be set globally, overriding the lexer's colours with SCI_SETWHITESPACEFORE and SCI_SETWHITESPACEBACK.

SCI_SETWHITESPACESIZE(int size)
- SCI_GETWHITESPACESIZE
+ SCI_GETWHITESPACESIZE → int
SCI_SETWHITESPACESIZE sets the size of the dots used for mark space characters. The SCI_GETWHITESPACESIZE message retrieves the current size.

+

SCI_SETTABDRAWMODE(int tabDrawMode)
+ SCI_GETTABDRAWMODE → int
+ These two messages get and set how tab characters are drawn when white space is visible. + The tabDrawMode argument can be one of:

+ + + + + + + + + + + + + + + + + + + +
SCTD_LONGARROW0The default mode of an arrow stretching until the tabstop.
SCTD_STRIKEOUT1A horizontal line stretching until the tabstop.
+ +

The effect of using any other tabDrawMode value is undefined.

+

SCI_SETEXTRAASCENT(int extraAscent)
- SCI_GETEXTRAASCENT
+ SCI_GETEXTRAASCENT → int
SCI_SETEXTRADESCENT(int extraDescent)
- SCI_GETEXTRADESCENT
+ SCI_GETEXTRADESCENT → int
Text is drawn with the base of each character on a 'baseline'. The height of a line is found from the maximum that any style extends above the baseline (its 'ascent'), added to the maximum that any style extends below the baseline (its 'descent'). @@ -2258,15 +2303,17 @@ struct Sci_TextToFind {

Cursor

+ SCI_SETCURSOR(int cursorType)
+ SCI_GETCURSOR → int
-

SCI_SETCURSOR(int curType)
- SCI_GETCURSOR
+

SCI_SETCURSOR(int cursorType)
+ SCI_GETCURSOR → int
The cursor is normally chosen in a context sensitive way, so it will be different over the margin than when over the text. When performing a slow action, you may wish to change to a wait - cursor. You set the cursor type with SCI_SETCURSOR. The curType + cursor. You set the cursor type with SCI_SETCURSOR. The cursorType argument can be:

- +
@@ -2288,18 +2335,31 @@ struct Sci_TextToFind {
SC_CURSORNORMAL

Cursor values 1 through 7 have defined cursors, but only SC_CURSORWAIT is - usefully controllable. Other values of curType cause a pointer to be displayed. + usefully controllable. Other values of cursorType cause a pointer to be displayed. The SCI_GETCURSOR message returns the last cursor type you set, or SC_CURSORNORMAL (-1) if you have not set a cursor type.

Mouse capture

+ SCI_SETMOUSEDOWNCAPTURES(bool captures)
+ SCI_GETMOUSEDOWNCAPTURES → bool
+ SCI_SETMOUSEWHEELCAPTURES(bool captures)
+ SCI_GETMOUSEWHEELCAPTURES → bool

SCI_SETMOUSEDOWNCAPTURES(bool captures)
- SCI_GETMOUSEDOWNCAPTURES
+ SCI_GETMOUSEDOWNCAPTURES → bool
When the mouse is pressed inside Scintilla, it is captured so future mouse movement events are sent to Scintilla. This behaviour may be turned off with SCI_SETMOUSEDOWNCAPTURES(0).

+

SCI_SETMOUSEWHEELCAPTURES(bool captures)
+ SCI_GETMOUSEWHEELCAPTURES → bool
+ On Windows, Scintilla captures all WM_MOUSEWHEEL messages if it has the + focus, even if the mouse pointer is nowhere near the Scintilla editor window. This + behavior can be changed with SCI_SETMOUSEWHEELCAPTURES(0) so that + Scintilla passes the WM_MOUSEWHEEL messages to its parent window. + Scintilla will still react to the mouse wheel if the mouse pointer is over + the editor window.

+

Line endings

Scintilla can handle the major line end conventions and, depending on settings and @@ -2319,53 +2379,251 @@ struct Sci_TextToFind { Unicode line ends.

SCI_SETEOLMODE(int eolMode)
- SCI_GETEOLMODE
+ SCI_GETEOLMODE → int
SCI_CONVERTEOLS(int eolMode)
SCI_SETVIEWEOL(bool visible)
- SCI_GETVIEWEOL
+ SCI_GETVIEWEOL → bool
- SCI_GETLINEENDTYPESSUPPORTED
+ SCI_GETLINEENDTYPESSUPPORTED → int
SCI_SETLINEENDTYPESALLOWED(int lineEndBitSet)
- SCI_GETLINEENDTYPESALLOWED
- SCI_GETLINEENDTYPESACTIVE
+ SCI_GETLINEENDTYPESALLOWED → int
+ SCI_GETLINEENDTYPESACTIVE → int

SCI_SETEOLMODE(int eolMode)
- SCI_GETEOLMODE
+ SCI_GETEOLMODE → int
SCI_SETEOLMODE sets the characters that are added into the document when the user - presses the Enter key. You can set eolMode to one of SC_EOL_CRLF (0), + presses the Enter key. You can set eolMode to one of SC_EOL_CRLF (0), SC_EOL_CR (1), or SC_EOL_LF (2). The SCI_GETEOLMODE message retrieves the current state.

SCI_CONVERTEOLS(int eolMode)
This message changes all the end of line characters in the document to match - eolMode. Valid values are: SC_EOL_CRLF (0), SC_EOL_CR + eolMode. Valid values are: SC_EOL_CRLF (0), SC_EOL_CR (1), or SC_EOL_LF (2).

SCI_SETVIEWEOL(bool visible)
- SCI_GETVIEWEOL
+ SCI_GETVIEWEOL → bool
Normally, the end of line characters are hidden, but SCI_SETVIEWEOL allows you to - display (or hide) them by setting visible true (or + display (or hide) them by setting visible true (or false). The visible rendering of the end of line characters is similar to (CR), (LF), or (CR)(LF). SCI_GETVIEWEOL returns the current state.

-

SCI_GETLINEENDTYPESSUPPORTED
+

SCI_GETLINEENDTYPESSUPPORTED → int
SCI_GETLINEENDTYPESSUPPORTED reports the different types of line ends supported by the current lexer. This is a bit set although there is currently only a single choice with either SC_LINE_END_TYPE_DEFAULT (0) or SC_LINE_END_TYPE_UNICODE (1). These values are also used by the other messages concerned with Unicode line ends.

SCI_SETLINEENDTYPESALLOWED(int lineEndBitSet)
- SCI_GETLINEENDTYPESALLOWED
+ SCI_GETLINEENDTYPESALLOWED → int
By default, only the ASCII line ends are interpreted. Unicode line ends may be requested with SCI_SETLINEENDTYPESALLOWED(SC_LINE_END_TYPE_UNICODE) but this will be ineffective unless the lexer also allows you Unicode line ends. SCI_GETLINEENDTYPESALLOWED returns the current state.

-

SCI_GETLINEENDTYPESACTIVE
+

SCI_GETLINEENDTYPESACTIVE → int
SCI_GETLINEENDTYPESACTIVE reports the set of line ends currently interpreted by Scintilla. It is SCI_GETLINEENDTYPESSUPPORTED & SCI_GETLINEENDTYPESALLOWED.

+

Words

+ +

There is support for selecting, navigating by, and searching for words.

+ +

+ Words are contiguous sequences of characters from a particular set of characters. + 4 categories define words: word, whitespace, punctuation, and line ends with each category + having a role in word functions. + Double clicking selects the word at that point, which may be a sequence of word, punctuation, + or whitespace bytes. + Line ends are not selected by double clicking but do act as word separators. +

+ +

Words are defined in terms of characters and the sets of characters in each category can be customized to an extent. + The NUL character (0) is always a space as the APIs to set categories use NUL-terminated strings. + For single-byte encodings a category may be assigned to any character (1 to 0xFF). + For multi-byte encodings a category may be assigned to characters from 1 to 0x7F with static behaviour from 0x80. + For UTF-8, characters from 0x80 will use a category based on their Unicode general category. + For Asian encodings, code pages 932, 936, 949, 950, and 1361, characters from 0x80 are treated as word characters. +

+ +

Identifiers in programming languages are often sequences of words with capitalisation + (aCamelCaseIdentifier) or underscores (an_under_bar_ident) used to mark word boundaries. + The SCI_WORDPART* commands are used for moving between word parts: + SCI_WORDPARTLEFT, + SCI_WORDPARTLEFTEXTEND, + SCI_WORDPARTRIGHT, and + SCI_WORDPARTRIGHTEXTEND. +

+ + SCI_WORDENDPOSITION(int pos, bool onlyWordCharacters) → int
+ SCI_WORDSTARTPOSITION(int pos, bool onlyWordCharacters) → int
+ SCI_ISRANGEWORD(int start, int end) → bool
+ + SCI_SETWORDCHARS(<unused>, const char *characters)
+ SCI_GETWORDCHARS(<unused>, char *characters) → int
+ SCI_SETWHITESPACECHARS(<unused>, const char *characters)
+ SCI_GETWHITESPACECHARS(<unused>, char *characters) → int
+ SCI_SETPUNCTUATIONCHARS(<unused>, const char *characters)
+ SCI_GETPUNCTUATIONCHARS(<unused>, char *characters) → int
+ SCI_SETCHARSDEFAULT
+ SCI_SETCHARACTERCATEGORYOPTIMIZATION(int countCharacters)
+ SCI_GETCHARACTERCATEGORYOPTIMIZATION → int
+ +

SCI_WORDENDPOSITION(int pos, bool onlyWordCharacters) → int
+ SCI_WORDSTARTPOSITION(int pos, bool onlyWordCharacters) → int
+ These messages return the start and end of words using the same definition of words as used + internally within Scintilla. You can set your own list of characters that count as words with + SCI_SETWORDCHARS. The position + sets the start or the search, which is forwards when searching for the end and backwards when + searching for the start.

+ +

SCI_ISRANGEWORD(int start, int end) → bool
+ Is the range start..end a word or set of words? This message checks that start is at a word start transition and that + end is at a word end transition. It does not check whether there are any spaces inside the range.

+ + SCI_ISRANGEWORD(int start, int end) → bool
+ +

Set onlyWordCharacters to true (1) to stop searching at the first + non-word character in the search direction. If onlyWordCharacters is + false (0), the first character in the search direction sets the type of the search + as word or non-word and the search stops at the first non-matching character. Searches are also + terminated by the start or end of the document.

+ +

If "w" represents word characters and "." represents non-word characters and "|" represents + the position and true or false is the state of + onlyWordCharacters:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Initial stateend, trueend, falsestart, truestart, false
..ww..|..ww....ww..|..ww....ww....|ww....ww..|..ww....ww|....ww..
....ww|ww........wwww|........wwww|........|wwww........|wwww....
..ww|....ww....ww|....ww....ww....|ww....|ww....ww....|ww....ww..
..ww....|ww....ww....ww|....ww....ww|....ww....|ww....ww|....ww..
+ +

SCI_SETWORDCHARS(<unused>, const char *characters)
+ This message defines which characters are members of the word category. + The character categories are set to default values before processing this function. + For example, if you don't allow '_' in your set of characters + use:
+ SCI_SETWORDCHARS(0, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");

+ +

SCI_GETWORDCHARS(<unused>, char *characters) → int
+ This fills the characters parameter with all the characters included in words. + The characters parameter must be large enough to hold all of the characters. + If the characters parameter is 0 then the length that should be allocated + to store the entire set is returned.

+ +

For multi-byte encodings, this API will not return meaningful values for 0x80 and above.

+ +

SCI_SETWHITESPACECHARS(<unused>, const char *characters)
+ SCI_GETWHITESPACECHARS(<unused>, char *characters) → int
+ Similar to SCI_SETWORDCHARS, this message allows the user to define which chars Scintilla considers + as whitespace. Setting the whitespace chars allows the user to fine-tune Scintilla's behaviour doing + such things as moving the cursor to the start or end of a word; for example, by defining punctuation chars + as whitespace, they will be skipped over when the user presses ctrl+left or ctrl+right. + This function should be called after SCI_SETWORDCHARS as it will + reset the whitespace characters to the default set. + SCI_GETWHITESPACECHARS behaves similarly to SCI_GETWORDCHARS.

+ +

SCI_SETPUNCTUATIONCHARS(<unused>, const char *characters)
+ SCI_GETPUNCTUATIONCHARS(<unused>, char *characters) → int
+ Similar to SCI_SETWORDCHARS and SCI_SETWHITESPACECHARS, this message + allows the user to define which chars Scintilla considers as punctuation. + SCI_GETPUNCTUATIONCHARS behaves similarly to SCI_GETWORDCHARS.

+ +

SCI_SETCHARSDEFAULT
+ Use the default sets of word and whitespace characters. This sets whitespace to space, tab and other + characters with codes less than 0x20, with word characters set to alphanumeric and '_'. +

+ +

SCI_SETCHARACTERCATEGORYOPTIMIZATION(int countCharacters)
+ SCI_GETCHARACTERCATEGORYOPTIMIZATION → int
+ Optimize speed of character category features like determining whether a character is a space or number at the expense of memory. + Mostly used for Unicode documents. + The countCharacters parameter determines how many character starting from 0 are added to a look-up table with one byte used for each character. + It is reasonable to cover the set of characters likely to be used in a document so 0x100 for simple Roman text, + 0x1000 to cover most simple alphabets, 0x10000 to cover most of East Asian languages, and 0x110000 to cover all possible characters. +

+ +

Word keyboard commands are:

+
    +
  • SCI_WORDLEFT
  • +
  • SCI_WORDLEFTEXTEND
  • +
  • SCI_WORDRIGHT
  • +
  • SCI_WORDRIGHTEXTEND
  • +
  • SCI_WORDLEFTEND
  • +
  • SCI_WORDLEFTENDEXTEND
  • +
  • SCI_WORDRIGHTEND
  • +
  • SCI_WORDRIGHTENDEXTEND
  • +
  • SCI_WORDPARTLEFT
  • +
  • SCI_WORDPARTLEFTEXTEND
  • +
  • SCI_WORDPARTRIGHT
  • +
  • SCI_WORDPARTRIGHTEXTEND
  • +
  • SCI_DELWORDLEFT
  • +
  • SCI_DELWORDRIGHT
  • +
  • SCI_DELWORDRIGHTEND
  • +
+

Styling

The styling messages allow you to assign styles to text. If your styling needs can be met by @@ -2378,17 +2636,19 @@ struct Sci_TextToFind { alternative, you might use idle time to style the document. Even if you use a lexer, you might use the styling commands to mark errors detected by a compiler. The following commands can be used.

- SCI_GETENDSTYLED
- SCI_STARTSTYLING(int position, int unused)
+ SCI_GETENDSTYLED → position
+ SCI_STARTSTYLING(int start, int unused)
SCI_SETSTYLING(int length, int style)
SCI_SETSTYLINGEX(int length, const char *styles)
- SCI_SETLINESTATE(int line, int value)
- SCI_GETLINESTATE(int line)
- SCI_GETMAXLINESTATE
+ SCI_SETIDLESTYLING(int idleStyling)
+ SCI_GETIDLESTYLING → int
+ SCI_SETLINESTATE(int line, int state)
+ SCI_GETLINESTATE(int line) → int
+ SCI_GETMAXLINESTATE → int
-

SCI_GETENDSTYLED
+

SCI_GETENDSTYLED → position
Scintilla keeps a record of the last character that is likely to be styled correctly. This is moved forwards when characters after it are styled and moved backwards if changes are made to the text of the document before it. Before drawing text, this position is checked to see if any @@ -2397,29 +2657,46 @@ struct Sci_TextToFind { container. The container can send SCI_GETENDSTYLED to work out where it needs to start styling. Scintilla will always ask to style whole lines.

-

SCI_STARTSTYLING(int pos, int unused)
- This prepares for styling by setting the styling position pos to start at. +

SCI_STARTSTYLING(int start, int unused)
+ This prepares for styling by setting the styling position start to start at. The unused argument was used in earlier versions but is now ignored. After SCI_STARTSTYLING, send multiple SCI_SETSTYLING messages for each lexical entity to style or send SCI_SETSTYLINGEX to style in blocks.

SCI_SETSTYLING(int length, int style)
- This message sets the style of length characters starting at the styling position - and then increases the styling position by length, ready for the next call. + This message sets the style of length characters starting at the styling position + and then increases the styling position by length, ready for the next call. SCI_STARTSTYLING should be called before the first call to this.

SCI_SETSTYLINGEX(int length, const char *styles)
As an alternative to SCI_SETSTYLING, which applies the same style to each byte, - you can use this message which specifies the styles for each of length bytes from - the styling position and then increases the styling position by length, ready for + you can use this message which specifies the styles for each of length bytes from + the styling position and then increases the styling position by length, ready for the next call. SCI_STARTSTYLING should be called before the first call to this.

-

SCI_SETLINESTATE(int line, int value)
- SCI_GETLINESTATE(int line)
+

SCI_SETIDLESTYLING(int idleStyling)
+ SCI_GETIDLESTYLING → int
+ By default, SC_IDLESTYLING_NONE (0), + syntax styling is performed for all the currently visible text before displaying it. + On very large files, this may make scrolling down slow. + With SC_IDLESTYLING_TOVISIBLE (1), + a small amount of styling is performed before display and then + further styling is performed incrementally in the background as an idle-time task. + This may result in the text initially appearing uncoloured and then, some time later, it is coloured. + Text after the currently visible portion may be styled in the background with SC_IDLESTYLING_AFTERVISIBLE (2). + To style both before and after the visible text in the background use SC_IDLESTYLING_ALL (3). +

+

+ Since wrapping also needs to perform styling and also uses idle time, this setting has no effect when + the document is displayed wrapped. +

+ +

SCI_SETLINESTATE(int line, int state)
+ SCI_GETLINESTATE(int line) → int
As well as the 8 bits of lexical state stored for each character there is also an integer stored for each line. This can be used for longer lived parse states such as what the current scripting language is in an ASP page. Use SCI_SETLINESTATE to set the integer @@ -2427,7 +2704,7 @@ struct Sci_TextToFind { Changing the value produces a SC_MOD_CHANGELINESTATE notification.

-

SCI_GETMAXLINESTATE
+

SCI_GETMAXLINESTATE → int
This returns the last line that has any line state.

Style definition

@@ -2439,7 +2716,7 @@ struct Sci_TextToFind { predefined numbered styles starting at 32, The following STYLE_* constants are defined.

- +
@@ -2510,20 +2787,26 @@ struct Sci_TextToFind { + + + + + + + + + predefined, this is set to the style number of the last predefined style. @@ -2548,51 +2831,49 @@ struct Sci_TextToFind { style 4 for preprocessor, style 5 for operators, and so on.

SCI_STYLERESETDEFAULT
SCI_STYLECLEARALL
- SCI_STYLESETFONT(int styleNumber, char + SCI_STYLESETFONT(int style, const char *fontName)
- SCI_STYLEGETFONT(int styleNumber, char *fontName)
- SCI_STYLESETSIZE(int styleNumber, int - sizeInPoints)
- SCI_STYLEGETSIZE(int styleNumber)
- SCI_STYLESETSIZEFRACTIONAL(int styleNumber, int - sizeInHundredthPoints)
- SCI_STYLEGETSIZEFRACTIONAL(int styleNumber)
- SCI_STYLESETBOLD(int styleNumber, bool + SCI_STYLEGETFONT(int style, char *fontName) → int
+ SCI_STYLESETSIZE(int style, int + sizePoints)
+ SCI_STYLEGETSIZE(int style) → int
+ SCI_STYLESETSIZEFRACTIONAL(int style, int + sizeHundredthPoints)
+ SCI_STYLEGETSIZEFRACTIONAL(int style) → int
+ SCI_STYLESETBOLD(int style, bool bold)
- SCI_STYLEGETBOLD(int styleNumber)
- SCI_STYLESETWEIGHT(int styleNumber, int + SCI_STYLEGETBOLD(int style) → bool
+ SCI_STYLESETWEIGHT(int style, int weight)
- SCI_STYLEGETWEIGHT(int styleNumber)
- SCI_STYLESETITALIC(int styleNumber, bool + SCI_STYLEGETWEIGHT(int style) → int
+ SCI_STYLESETITALIC(int style, bool italic)
- SCI_STYLEGETITALIC(int styleNumber)
- SCI_STYLESETUNDERLINE(int styleNumber, bool + SCI_STYLEGETITALIC(int style) → bool
+ SCI_STYLESETUNDERLINE(int style, bool underline)
- SCI_STYLEGETUNDERLINE(int styleNumber)
- SCI_STYLESETFORE(int styleNumber, int - colour)
- SCI_STYLEGETFORE(int styleNumber)
- SCI_STYLESETBACK(int styleNumber, int - colour)
- SCI_STYLEGETBACK(int styleNumber)
- SCI_STYLESETEOLFILLED(int styleNumber, bool + SCI_STYLEGETUNDERLINE(int style) → bool
+ SCI_STYLESETFORE(int style, colour fore)
+ SCI_STYLEGETFORE(int style) → colour
+ SCI_STYLESETBACK(int style, colour back)
+ SCI_STYLEGETBACK(int style) → colour
+ SCI_STYLESETEOLFILLED(int style, bool eolFilled)
- SCI_STYLEGETEOLFILLED(int styleNumber)
- SCI_STYLESETCHARACTERSET(int styleNumber, - int charSet)
- SCI_STYLEGETCHARACTERSET(int styleNumber)
- SCI_STYLESETCASE(int styleNumber, int - caseMode)
- SCI_STYLEGETCASE(int styleNumber)
- SCI_STYLESETVISIBLE(int styleNumber, bool + SCI_STYLEGETEOLFILLED(int style) → bool
+ SCI_STYLESETCHARACTERSET(int style, + int characterSet)
+ SCI_STYLEGETCHARACTERSET(int style) → int
+ SCI_STYLESETCASE(int style, int + caseVisible)
+ SCI_STYLEGETCASE(int style) → int
+ SCI_STYLESETVISIBLE(int style, bool visible)
- SCI_STYLEGETVISIBLE(int styleNumber)
- SCI_STYLESETCHANGEABLE(int styleNumber, bool + SCI_STYLEGETVISIBLE(int style) → bool
+ SCI_STYLESETCHANGEABLE(int style, bool changeable)
- SCI_STYLEGETCHANGEABLE(int styleNumber)
- SCI_STYLESETHOTSPOT(int styleNumber, bool + SCI_STYLEGETCHANGEABLE(int style) → bool
+ SCI_STYLESETHOTSPOT(int style, bool hotspot)
- SCI_STYLEGETHOTSPOT(int styleNumber)
+ SCI_STYLEGETHOTSPOT(int style) → bool

SCI_STYLERESETDEFAULT
@@ -2607,27 +2888,27 @@ struct Sci_TextToFind { 2. Use SCI_STYLECLEARALL to copy this to all styles.
3. Set the style attributes that make your lexical styles different.

-

SCI_STYLESETFONT(int styleNumber, const char *fontName)
- SCI_STYLEGETFONT(int styleNumber, char *fontName NUL-terminated)
- SCI_STYLESETSIZE(int styleNumber, int sizeInPoints)
- SCI_STYLEGETSIZE(int styleNumber)
- SCI_STYLESETSIZEFRACTIONAL(int styleNumber, int sizeInHundredthPoints)
- SCI_STYLEGETSIZEFRACTIONAL(int styleNumber)
- SCI_STYLESETBOLD(int styleNumber, bool bold)
- SCI_STYLEGETBOLD(int styleNumber)
- SCI_STYLESETWEIGHT(int styleNumber, int weight)
- SCI_STYLEGETWEIGHT(int styleNumber)
- SCI_STYLESETITALIC(int styleNumber, bool italic)
- SCI_STYLEGETITALIC(int styleNumber)
+

SCI_STYLESETFONT(int style, const char *fontName)
+ SCI_STYLEGETFONT(int style, char *fontName NUL-terminated) → int
+ SCI_STYLESETSIZE(int style, int sizePoints)
+ SCI_STYLEGETSIZE(int style) → int
+ SCI_STYLESETSIZEFRACTIONAL(int style, int sizeHundredthPoints)
+ SCI_STYLEGETSIZEFRACTIONAL(int style) → int
+ SCI_STYLESETBOLD(int style, bool bold)
+ SCI_STYLEGETBOLD(int style) → bool
+ SCI_STYLESETWEIGHT(int style, int weight)
+ SCI_STYLEGETWEIGHT(int style) → int
+ SCI_STYLESETITALIC(int style, bool italic)
+ SCI_STYLEGETITALIC(int style) → bool
These messages (plus SCI_STYLESETCHARACTERSET) set the font attributes that are used to match the fonts you request to those available.

The - fontName is a zero terminated string holding the name of a font. Under Windows, + fontName is a zero terminated string holding the name of a font. Under Windows, only the first 32 characters of the name are used, the name is decoded as UTF-8, and the name is not case sensitive. For internal caching, Scintilla tracks fonts by name and does care about the casing of font names, so please be consistent. - On GTK+, Pango is used to display text and the name is sent directly to Pango without transformation. + On GTK, Pango is used to display text and the name is sent directly to Pango without transformation. On Qt, the name is decoded as UTF-8. On Cocoa, the name is decoded as MacRoman.

Sizes can be set to a whole number of points with SCI_STYLESETSIZE @@ -2646,84 +2927,190 @@ struct Sci_TextToFind { and 1 SC_WEIGHT_BOLD.

-

SCI_STYLESETUNDERLINE(int styleNumber, bool +

SCI_STYLESETUNDERLINE(int style, bool underline)
- SCI_STYLEGETUNDERLINE(int styleNumber)
+ SCI_STYLEGETUNDERLINE(int style) → bool
You can set a style to be underlined. The underline is drawn in the foreground colour. All characters with a style that includes the underline attribute are underlined, even if they are white space.

-

SCI_STYLESETFORE(int styleNumber, int colour)
- SCI_STYLEGETFORE(int styleNumber)
- SCI_STYLESETBACK(int styleNumber, int colour)
- SCI_STYLEGETBACK(int styleNumber)
+

SCI_STYLESETFORE(int style, colour fore)
+ SCI_STYLEGETFORE(int style) → colour
+ SCI_STYLESETBACK(int style, colour back)
+ SCI_STYLEGETBACK(int style) → colour
Text is drawn in the foreground colour. The space in each character cell that is not occupied by the character is drawn in the background colour.

-

SCI_STYLESETEOLFILLED(int styleNumber, bool +

SCI_STYLESETEOLFILLED(int style, bool eolFilled)
- SCI_STYLEGETEOLFILLED(int styleNumber)
+ SCI_STYLEGETEOLFILLED(int style) → bool
If the last character in the line has a style with this attribute set, the remainder of the line up to the right edge of the window is filled with the background colour set for the last character. This is useful when a document contains embedded sections in another language such - as HTML pages with embedded JavaScript. By setting eolFilled to true + as HTML pages with embedded JavaScript. By setting eolFilled to true and a consistent background colour (different from the background colour set for the HTML styles) to all JavaScript styles then JavaScript sections will be easily distinguished from HTML.

-

SCI_STYLESETCHARACTERSET(int styleNumber, int - charSet)
- SCI_STYLEGETCHARACTERSET(int styleNumber)
+

SCI_STYLESETCHARACTERSET(int style, int + characterSet)
+ SCI_STYLEGETCHARACTERSET(int style) → int
You can set a style to use a different character set than the default. The places where such characters sets are likely to be useful are comments and literal strings. For example, SCI_STYLESETCHARACTERSET(SCE_C_STRING, SC_CHARSET_RUSSIAN) would ensure that strings in Russian would display correctly in C and C++ (SCE_C_STRING is the style number used by the C and C++ lexer to display literal strings; it has the value 6). This - feature works differently on Windows and GTK+.

+ feature works differently on Windows and GTK.
+ The default character set is SC_CHARSET_DEFAULT.

+

SC_CHARSET_ANSI and SC_CHARSET_DEFAULT specify European Windows code page 1252 unless the code page is set.

-

The character sets supported on Windows are:
- SC_CHARSET_ANSI, SC_CHARSET_ARABIC, SC_CHARSET_BALTIC, - SC_CHARSET_CHINESEBIG5, SC_CHARSET_DEFAULT, - SC_CHARSET_EASTEUROPE, SC_CHARSET_GB2312, - SC_CHARSET_GREEK, SC_CHARSET_HANGUL, SC_CHARSET_HEBREW, - SC_CHARSET_JOHAB, SC_CHARSET_MAC, SC_CHARSET_OEM, - SC_CHARSET_RUSSIAN (code page 1251), - SC_CHARSET_SHIFTJIS, SC_CHARSET_SYMBOL, SC_CHARSET_THAI, - SC_CHARSET_TURKISH, and SC_CHARSET_VIETNAMESE.

+
STYLE_DEFAULT38 Call tips normally use the font attributes defined by STYLE_DEFAULT. - Use of SCI_CALLTIPUSESTYLE + Use of SCI_CALLTIPUSESTYLE causes call tips to use this style instead. Only the font face name, font size, foreground and background colours and character set attributes are used.
STYLE_FOLDDISPLAYTEXT39This is the style used for drawing text tags attached to folded text.
STYLE_LASTPREDEFINED 39 To make it easier for client code to discover the range of styles that are - predefined, this is set to the style number of the last predefined style. This is - currently set to 39 and the last style with an identifier is 38, which reserves space - for one future predefined style.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Character SetWindowsGTKCocoa
SC_CHARSET_ANSI✓ (8859-1)
SC_CHARSET_ARABIC
SC_CHARSET_BALTIC
SC_CHARSET_CHINESEBIG5
SC_CHARSET_DEFAULT✓ (8859-1)✓ (8859-1)
SC_CHARSET_EASTEUROPE
SC_CHARSET_GB2312
SC_CHARSET_GREEK
SC_CHARSET_HANGUL
SC_CHARSET_HEBREW
SC_CHARSET_JOHAB
SC_CHARSET_MAC
SC_CHARSET_OEM
SC_CHARSET_RUSSIAN✓ (cp1251)✓ (koi8-r)✓ (cp1251)
SC_CHARSET_SHIFTJIS
SC_CHARSET_SYMBOL
SC_CHARSET_THAI
SC_CHARSET_TURKISH
SC_CHARSET_VIETNAMESE
SC_CHARSET_OEM866✓ (cp866)
SC_CHARSET_CYRILLIC✓ (cp1251)✓ (cp1251)
SC_CHARSET_8859_15
-

The character sets supported on GTK+ are:
- SC_CHARSET_ANSI, SC_CHARSET_CYRILLIC (code page 1251), - SC_CHARSET_EASTEUROPE, - SC_CHARSET_GB2312, SC_CHARSET_HANGUL, - SC_CHARSET_RUSSIAN (KOI8-R), SC_CHARSET_SHIFTJIS, and - SC_CHARSET_8859_15.

- -

SCI_STYLESETCASE(int styleNumber, int caseMode)
- SCI_STYLEGETCASE(int styleNumber)
- The value of caseMode determines how text is displayed. You can set upper case - (SC_CASE_UPPER, 1) or lower case (SC_CASE_LOWER, 2) or camel case (SC_CASE_CAMEL, 3) +

SCI_STYLESETCASE(int style, int caseVisible)
+ SCI_STYLEGETCASE(int style) → int
+ The value of caseVisible determines how text is displayed. You can set upper case + (SC_CASE_UPPER, 1) or lower case (SC_CASE_LOWER, 2) or camel case (SC_CASE_CAMEL, 3) or display normally (SC_CASE_MIXED, 0). This does not change the stored text, only how it is displayed.

-

SCI_STYLESETVISIBLE(int styleNumber, bool visible)
- SCI_STYLEGETVISIBLE(int styleNumber)
+

SCI_STYLESETVISIBLE(int style, bool visible)
+ SCI_STYLEGETVISIBLE(int style) → bool
Text is normally visible. However, you can completely hide it by giving it a style with the - visible set to 0. This could be used to hide embedded formatting instructions or - hypertext keywords in HTML or XML.

+ visible set to 0. This could be used to hide embedded formatting instructions or + hypertext keywords in HTML or XML. + Invisible text may not be deleted by user actions but the application may delete invisible text by calling + SCI_DELETERANGE.

-

SCI_STYLESETCHANGEABLE(int styleNumber, bool +

SCI_STYLESETCHANGEABLE(int style, bool changeable)
- SCI_STYLEGETCHANGEABLE(int styleNumber)
+ SCI_STYLEGETCHANGEABLE(int style) → bool
This is an experimental and incompletely implemented style attribute. The default setting is - changeable set true but when set false it makes text - read-only. Currently it only stops the caret from being within not-changeable text and does not - yet stop deleting a range that contains not-changeable text.

+ changeable set true but when set false it makes text + read-only. The user can not move the caret within not-changeable text and not-changeable + text may not be deleted by the user. + The application may delete not-changeable text by calling + SCI_DELETERANGE.

-

SCI_STYLESETHOTSPOT(int styleNumber, bool +

SCI_STYLESETHOTSPOT(int style, bool hotspot)
- SCI_STYLEGETHOTSPOT(int styleNumber)
+ SCI_STYLEGETHOTSPOT(int style) → bool
This style is used to mark ranges of text that can detect mouse clicks. The cursor changes to a hand over hotspots, and the foreground, and background colours may change and an underline appear to indicate that these areas are sensitive to clicking. @@ -2737,71 +3124,72 @@ struct Sci_TextToFind { it was not selected. When there is no selection, the current insertion point is marked by the text caret. This is a vertical line that is normally blinking on and off to attract the users attention.

- SCI_SETSELFORE(bool useSelectionForeColour, int colour)
- SCI_SETSELBACK(bool useSelectionBackColour, int colour)
- SCI_SETSELALPHA(int alpha)
- SCI_GETSELALPHA
+ SCI_SETSELFORE(bool useSetting, colour fore)
+ SCI_SETSELBACK(bool useSetting, colour back)
+ SCI_SETSELALPHA(alpha alpha)
+ SCI_GETSELALPHA → int
SCI_SETSELEOLFILLED(bool filled)
- SCI_GETSELEOLFILLED
- SCI_SETCARETFORE(int colour)
- SCI_GETCARETFORE
+ SCI_GETSELEOLFILLED → bool
+ SCI_SETCARETFORE(colour fore)
+ SCI_GETCARETFORE → colour
SCI_SETCARETLINEVISIBLE(bool show)
- SCI_GETCARETLINEVISIBLE
- SCI_SETCARETLINEBACK(int colour)
- SCI_GETCARETLINEBACK
- SCI_SETCARETLINEBACKALPHA(int alpha)
- SCI_GETCARETLINEBACKALPHA
+ SCI_GETCARETLINEVISIBLE → bool
+ SCI_SETCARETLINEBACK(colour back)
+ SCI_GETCARETLINEBACK → colour
+ SCI_SETCARETLINEBACKALPHA(alpha alpha)
+ SCI_GETCARETLINEBACKALPHA → int
+ SCI_SETCARETLINEFRAME(int width)
+ SCI_GETCARETLINEFRAME → int
SCI_SETCARETLINEVISIBLEALWAYS(bool alwaysVisible)
- SCI_GETCARETLINEVISIBLEALWAYS
- SCI_SETCARETPERIOD(int milliseconds)
- SCI_GETCARETPERIOD
- SCI_SETCARETSTYLE(int style)
- SCI_GETCARETSTYLE
- SCI_SETCARETWIDTH(int pixels)
- SCI_GETCARETWIDTH
- SCI_SETHOTSPOTACTIVEFORE(bool useSetting, int colour)
- SCI_GETHOTSPOTACTIVEFORE
- SCI_SETHOTSPOTACTIVEBACK(bool useSetting, int colour)
- SCI_GETHOTSPOTACTIVEBACK
+ SCI_GETCARETLINEVISIBLEALWAYS → bool
+ SCI_SETCARETPERIOD(int periodMilliseconds)
+ SCI_GETCARETPERIOD → int
+ SCI_SETCARETSTYLE(int caretStyle)
+ SCI_GETCARETSTYLE → int
+ SCI_SETCARETWIDTH(int pixelWidth)
+ SCI_GETCARETWIDTH → int
+ SCI_SETHOTSPOTACTIVEFORE(bool useSetting, colour fore)
+ SCI_GETHOTSPOTACTIVEFORE → colour
+ SCI_SETHOTSPOTACTIVEBACK(bool useSetting, colour back)
+ SCI_GETHOTSPOTACTIVEBACK → colour
SCI_SETHOTSPOTACTIVEUNDERLINE(bool underline)
- SCI_GETHOTSPOTACTIVEUNDERLINE
+ SCI_GETHOTSPOTACTIVEUNDERLINE → bool
SCI_SETHOTSPOTSINGLELINE(bool singleLine)
- SCI_GETHOTSPOTSINGLELINE
+ SCI_GETHOTSPOTSINGLELINE → bool
SCI_SETCARETSTICKY(int useCaretStickyBehaviour)
- SCI_GETCARETSTICKY
+ SCI_GETCARETSTICKY → int
SCI_TOGGLECARETSTICKY
-

SCI_SETSELFORE(bool useSelectionForeColour, int colour)
- SCI_SETSELBACK(bool useSelectionBackColour, int colour)
+

SCI_SETSELFORE(bool useSetting, colour fore)
+ SCI_SETSELBACK(bool useSetting, colour back)
You can choose to override the default selection colouring with these two messages. The colour - you provide is used if you set useSelection*Colour to true. If it is - set to false, the default styled colouring is used and the colour + you provide is used if you set useSelection*Colour to true. If it is + set to false, the default styled colouring is used and the + fore or back argument has no effect.

-

SCI_SETSELALPHA(int alpha)
- SCI_GETSELALPHA
+

SCI_SETSELALPHA(alpha alpha)
+ SCI_GETSELALPHA → int
The selection can be drawn translucently in the selection background colour by setting an alpha value.

SCI_SETSELEOLFILLED(bool filled)
- SCI_GETSELEOLFILLED
+ SCI_GETSELEOLFILLED → bool
The selection can be drawn up to the right hand border by setting this property.

-

SCI_SETCARETFORE(int colour)
- SCI_GETCARETFORE
+

SCI_SETCARETFORE(colour fore)
+ SCI_GETCARETFORE → colour
The colour of the caret can be set with SCI_SETCARETFORE and retrieved with SCI_GETCARETFORE.

SCI_SETCARETLINEVISIBLE(bool show)
- SCI_GETCARETLINEVISIBLE
- SCI_SETCARETLINEBACK(int colour)
- SCI_GETCARETLINEBACK
- SCI_SETCARETLINEBACKALPHA(int alpha)
- SCI_GETCARETLINEBACKALPHA
+ SCI_GETCARETLINEVISIBLE → bool
+ SCI_SETCARETLINEBACK(colour back)
+ SCI_GETCARETLINEBACK → colour
+ SCI_SETCARETLINEBACKALPHA(alpha alpha)
+ SCI_GETCARETLINEBACKALPHA → int
+ SCI_SETCARETLINEFRAME(int width)
+ SCI_GETCARETLINEFRAME → int
You can choose to make the background colour of the line containing the caret different with these messages. To do this, set the desired background colour with SCI_SETCARETLINEBACK, then use SCI_SETCARETLINEVISIBLE(true) to @@ -2813,35 +3201,39 @@ struct Sci_TextToFind { through. This is done by setting the alpha (translucency) value by calling SCI_SETCARETLINEBACKALPHA. When the alpha is not SC_ALPHA_NOALPHA, the caret line is drawn after all other features so will affect the colour of all other features. + Alternatively SCI_SETCARETLINEFRAME can be used to display the caret line framed + instead of filling the whole background. Set width != 0 to enable this option and width = 0 to disable it.

SCI_SETCARETLINEVISIBLEALWAYS(bool alwaysVisible)
- SCI_GETCARETLINEVISIBLEALWAYS
+ SCI_GETCARETLINEVISIBLEALWAYS → bool
Choose to make the caret line always visible even when the window is not in focus. Default behaviour SCI_SETCARETLINEVISIBLEALWAYS(false) the caret line is only visible when the window is in focus.

-

SCI_SETCARETPERIOD(int milliseconds)
- SCI_GETCARETPERIOD
+

SCI_SETCARETPERIOD(int periodMilliseconds)
+ SCI_GETCARETPERIOD → int
The rate at which the caret blinks can be set with SCI_SETCARETPERIOD which determines the time in milliseconds that the caret is visible or invisible before changing state. Setting the period to 0 stops the caret blinking. The default value is 500 milliseconds. SCI_GETCARETPERIOD returns the current setting.

-

SCI_SETCARETSTYLE(int style)
- SCI_GETCARETSTYLE
+

SCI_SETCARETSTYLE(int caretStyle)
+ SCI_GETCARETSTYLE → int
The style of the caret can be set with SCI_SETCARETSTYLE to be a line caret - (CARETSTYLE_LINE=1), a block caret (CARETSTYLE_BLOCK=2) or to not draw at all - (CARETSTYLE_INVISIBLE=0). The default value is the line caret (CARETSTYLE_LINE=1). + (CARETSTYLE_LINE=1) or a block caret (CARETSTYLE_BLOCK=2) for insert mode (lower 4-bits, CARETSTYLE_INS_MASK) combined with + a bar caret (CARETSTYLE_OVERSTRIKE_BAR=0) or a block caret (CARETSTYLE_OVERSTRIKE_BLOCK=16) for overtype mode (bit 4), + or to not draw at all (CARETSTYLE_INVISIBLE=0). The default value for insert mode is the line caret (CARETSTYLE_LINE=1), + for overtype mode is the bar caret (CARETSTYLE_OVERSTRIKE_BAR=0). You can determine the current caret style setting using SCI_GETCARETSTYLE.

-

The block character draws most combining and multibyte character sequences successfully, +

The block caret draws most combining and multibyte character sequences successfully, though some fonts like Thai Fonts (and possibly others) can sometimes appear strange when the cursor is positioned at these characters, which may result in only drawing a part of the cursor character sequence. This is most notable on Windows platforms.

-

SCI_SETCARETWIDTH(int pixels)
- SCI_GETCARETWIDTH
+

SCI_SETCARETWIDTH(int pixelWidth)
+ SCI_GETCARETWIDTH → int
The width of the line caret can be set with SCI_SETCARETWIDTH to a value of 0, 1, 2 or 3 pixels. The default width is 1 pixel. You can read back the current width with SCI_GETCARETWIDTH. A width of 0 makes the caret invisible (added at version @@ -2849,22 +3241,21 @@ struct Sci_TextToFind { This setting only affects the width of the cursor when the cursor style is set to line caret mode, it does not affect the width for a block caret.

-

SCI_SETHOTSPOTACTIVEFORE(bool useHotSpotForeColour, int colour)
- SCI_GETHOTSPOTACTIVEFORE
- SCI_SETHOTSPOTACTIVEBACK(bool useHotSpotBackColour, int colour)
- SCI_GETHOTSPOTACTIVEBACK
+

SCI_SETHOTSPOTACTIVEFORE(bool useSetting, colour fore)
+ SCI_GETHOTSPOTACTIVEFORE → colour
+ SCI_SETHOTSPOTACTIVEBACK(bool useSetting, + colour back)
+ SCI_GETHOTSPOTACTIVEBACK → colour
SCI_SETHOTSPOTACTIVEUNDERLINE(bool underline)
- SCI_GETHOTSPOTACTIVEUNDERLINE
+ SCI_GETHOTSPOTACTIVEUNDERLINE → bool
SCI_SETHOTSPOTSINGLELINE(bool singleLine)
- SCI_GETHOTSPOTSINGLELINE
+ SCI_GETHOTSPOTSINGLELINE → bool
While the cursor hovers over text in a style with the hotspot attribute set, the default colouring can be modified and an underline drawn with these settings. Single line mode stops a hotspot from wrapping onto next line.

SCI_SETCARETSTICKY(int useCaretStickyBehaviour)
- SCI_GETCARETSTICKY
+ SCI_GETCARETSTICKY → int
SCI_TOGGLECARETSTICKY
These messages set, get or toggle the caretSticky setting which controls when the last position of the caret on the line is saved.

@@ -2906,14 +3297,14 @@ struct Sci_TextToFind { SCI_SETREPRESENTATION(const char *encodedCharacter, const char *representation)
- SCI_GETREPRESENTATION(const char *encodedCharacter, char *representation)
+ SCI_GETREPRESENTATION(const char *encodedCharacter, char *representation) → int
SCI_CLEARREPRESENTATION(const char *encodedCharacter)
SCI_SETCONTROLCHARSYMBOL(int symbol)
- SCI_GETCONTROLCHARSYMBOL
+ SCI_GETCONTROLCHARSYMBOL → int

SCI_SETREPRESENTATION(const char *encodedCharacter, const char *representation)
- SCI_GETREPRESENTATION(const char *encodedCharacter, char *representation NUL-terminated)
+ SCI_GETREPRESENTATION(const char *encodedCharacter, char *representation NUL-terminated) → int
SCI_CLEARREPRESENTATION(const char *encodedCharacter)
Any character, including those normally displayed as mnemonics may be represented by a string inverted in a rounded rectangle.

@@ -2929,7 +3320,7 @@ struct Sci_TextToFind { character is specified as an empty string.

SCI_SETCONTROLCHARSYMBOL(int symbol)
- SCI_GETCONTROLCHARSYMBOL
+ SCI_GETCONTROLCHARSYMBOL → int
The mnemonics may be replaced by a nominated symbol with an ASCII code in the range 32 to 255. If you set a symbol value less than 32, all control characters are displayed as mnemonics. The symbol you set is rendered in the font of the style set for the character. @@ -2938,10 +3329,12 @@ struct Sci_TextToFind {

Margins

-

There may be up to five margins, numbered 0 to SC_MAX_MARGIN (4) - to the left of the text display, plus a gap either side of - the text. Each margin can be set to display only symbols, line numbers, or text with SCI_SETMARGINTYPEN. +

There may be multiple margins to the left of the text display plus a gap either side of the text. + 5 margins are allocated initially numbered from 0 to SC_MAX_MARGIN (4) + but this may be changed by calling + SCI_SETMARGINS. + Each margin can be set to display only symbols, line numbers, or text with + SCI_SETMARGINTYPEN. Textual margins may also display symbols. The markers that can be displayed in each margin are set with SCN_MARGINCLICK notification to the container or + href="#SCN_MARGINCLICK">SCN_MARGINCLICK or SCN_MARGINRIGHTCLICK notification to the container or selects a line of text.

-

The margins are numbered 0 to 4. Using a margin number outside the valid range has no +

Using a margin number outside the valid range has no effect. By default, margin 0 is set to display line numbers, but is given a width of 0, so it is hidden. Margin 1 is set to display non-folding symbols and is given a width of 16 pixels, so it is visible. Margin 2 is set to display the folding symbols, but is given a width of 0, so it @@ -2961,58 +3355,65 @@ struct Sci_TextToFind {

Styled text margins used to show revision and blame information:

Styled text margins used to show revision and blame information

- SCI_SETMARGINTYPEN(int margin, int - type)
- SCI_GETMARGINTYPEN(int margin)
+ + SCI_SETMARGINS(int margins)
+ SCI_GETMARGINS → int
+ SCI_SETMARGINTYPEN(int margin, int marginType)
+ SCI_GETMARGINTYPEN(int margin) → int
SCI_SETMARGINWIDTHN(int margin, int pixelWidth)
- SCI_GETMARGINWIDTHN(int margin)
+ SCI_GETMARGINWIDTHN(int margin) → int
SCI_SETMARGINMASKN(int margin, int mask)
- SCI_GETMARGINMASKN(int margin)
+ SCI_GETMARGINMASKN(int margin) → int
SCI_SETMARGINSENSITIVEN(int margin, bool sensitive)
- SCI_GETMARGINSENSITIVEN(int - margin)
+ SCI_GETMARGINSENSITIVEN(int margin) → bool
SCI_SETMARGINCURSORN(int margin, int cursor)
- SCI_GETMARGINCURSORN(int - margin)
+ SCI_GETMARGINCURSORN(int margin) → int
+ SCI_SETMARGINBACKN(int margin, colour back)
+ SCI_GETMARGINBACKN(int margin) → colour
SCI_SETMARGINLEFT(<unused>, int - pixels)
- SCI_GETMARGINLEFT
+ pixelWidth)
+ SCI_GETMARGINLEFT → int
SCI_SETMARGINRIGHT(<unused>, int - pixels)
- SCI_GETMARGINRIGHT
- SCI_SETFOLDMARGINCOLOUR(bool useSetting, int colour)
- SCI_SETFOLDMARGINHICOLOUR(bool useSetting, int colour)
- SCI_MARGINSETTEXT(int line, char *text)
- SCI_MARGINGETTEXT(int line, char *text)
+ pixelWidth)
+ SCI_GETMARGINRIGHT → int
+ SCI_SETFOLDMARGINCOLOUR(bool useSetting, colour back)
+ SCI_SETFOLDMARGINHICOLOUR(bool useSetting, colour fore)
+ SCI_MARGINSETTEXT(int line, const char *text)
+ SCI_MARGINGETTEXT(int line, char *text) → int
SCI_MARGINSETSTYLE(int line, int style)
- SCI_MARGINGETSTYLE(int line)
- SCI_MARGINSETSTYLES(int line, char *styles)
- SCI_MARGINGETSTYLES(int line, char *styles)
+ SCI_MARGINGETSTYLE(int line) → int
+ SCI_MARGINSETSTYLES(int line, const char *styles)
+ SCI_MARGINGETSTYLES(int line, char *styles) → int
SCI_MARGINTEXTCLEARALL
SCI_MARGINSETSTYLEOFFSET(int style)
- SCI_MARGINGETSTYLEOFFSET
+ SCI_MARGINGETSTYLEOFFSET → int
SCI_SETMARGINOPTIONS(int marginOptions)
- SCI_GETMARGINOPTIONS
+ SCI_GETMARGINOPTIONS → int
-

SCI_SETMARGINTYPEN(int margin, int iType)
- SCI_GETMARGINTYPEN(int margin)
+

SCI_SETMARGINS(int margins)
+ SCI_GETMARGINS → int
+ Allocate the number of margins or find the number of margins currently allocated.

+ +

SCI_SETMARGINTYPEN(int margin, int marginType)
+ SCI_GETMARGINTYPEN(int margin) → int
These two routines set and get the type of a margin. The margin argument should be 0, 1, 2, 3 or 4. You can use the predefined constants SC_MARGIN_SYMBOL (0) and SC_MARGIN_NUMBER (1) to set a margin as either a line number or a symbol margin. A margin with application defined text may use SC_MARGIN_TEXT (4) or SC_MARGIN_RTEXT (5) to right justify the text. By convention, margin 0 is used for line numbers and the next two are used for symbols. You can - also use the constants SC_MARGIN_BACK (2) and SC_MARGIN_FORE (3) for + also use the constants SC_MARGIN_BACK (2), SC_MARGIN_FORE (3), + and SC_MARGIN_COLOUR (6) for symbol margins that set their background colour to match the STYLE_DEFAULT background and - foreground colours.

+ foreground colours or a specified colour.

SCI_SETMARGINWIDTHN(int margin, int pixelWidth)
- SCI_GETMARGINWIDTHN(int margin)
+ SCI_GETMARGINWIDTHN(int margin) → int
These routines set and get the width of a margin in pixels. A margin with zero width is invisible. By default, Scintilla sets margin 1 for symbols with a width of 16 pixels, so this is a reasonable guess if you are not sure what would be appropriate. Line number margins widths @@ -3022,7 +3423,7 @@ struct Sci_TextToFind { suitable width.

SCI_SETMARGINMASKN(int margin, int mask)
- SCI_GETMARGINMASKN(int margin)
+ SCI_GETMARGINMASKN(int margin) → int
The mask is a 32-bit value. Each bit corresponds to one of 32 logical symbols that can be displayed in a margin that is enabled for symbols. There is a useful constant, SC_MASK_FOLDERS (0xFE000000 or -33554432), that is a mask for the 7 logical @@ -3049,42 +3450,47 @@ struct Sci_TextToFind {

SCI_SETMARGINSENSITIVEN(int margin, bool sensitive)
- SCI_GETMARGINSENSITIVEN(int margin)
+ SCI_GETMARGINSENSITIVEN(int margin) → bool
Each of the five margins can be set sensitive or insensitive to mouse clicks. A click in a sensitive margin sends a SCN_MARGINCLICK SCN_MARGINCLICK or SCN_MARGINRIGHTCLICK notification to the container. Margins that are not sensitive act as selection margins which make it easy to select ranges of lines. By default, all margins are insensitive.

SCI_SETMARGINCURSORN(int margin, int cursor)
- SCI_GETMARGINCURSORN(int margin)
+ SCI_GETMARGINCURSORN(int margin) → int
A reversed arrow cursor is normally shown over all margins. This may be changed to a normal arrow with SCI_SETMARGINCURSORN(margin, SC_CURSORARROW) or restored to a reversed arrow with SCI_SETMARGINCURSORN(margin, SC_CURSORREVERSEARROW).

+

SCI_SETMARGINBACKN(int margin, colour back)
+ SCI_GETMARGINBACKN(int margin) → colour
+ A margin of type SC_MARGIN_COLOUR + may have its colour set with SCI_SETMARGINBACKN.

-

SCI_SETMARGINLEFT(<unused>, int pixels)
- SCI_GETMARGINLEFT
- SCI_SETMARGINRIGHT(<unused>, int pixels)
- SCI_GETMARGINRIGHT
+

SCI_SETMARGINLEFT(<unused>, int pixelWidth)
+ SCI_GETMARGINLEFT → int
+ SCI_SETMARGINRIGHT(<unused>, int pixelWidth)
+ SCI_GETMARGINRIGHT → int
These messages set and get the width of the blank margin on both sides of the text in pixels. The default is to one pixel on each side.

-

SCI_SETFOLDMARGINCOLOUR(bool useSetting, int colour)
- SCI_SETFOLDMARGINHICOLOUR(bool useSetting, int colour)
+

SCI_SETFOLDMARGINCOLOUR(bool useSetting, colour back)
+ SCI_SETFOLDMARGINHICOLOUR(bool useSetting, colour fore)
These messages allow changing the colour of the fold margin and fold margin highlight. On Windows the fold margin colour defaults to ::GetSysColor(COLOR_3DFACE) and the fold margin highlight colour to ::GetSysColor(COLOR_3DHIGHLIGHT).

- SCI_MARGINSETTEXT(int line, char *text)
- SCI_MARGINGETTEXT(int line, char *text)
+ SCI_MARGINSETTEXT(int line, const char *text)
+ SCI_MARGINGETTEXT(int line, char *text) → int
SCI_MARGINSETSTYLE(int line, int style)
- SCI_MARGINGETSTYLE(int line)
- SCI_MARGINSETSTYLES(int line, char *styles)
- SCI_MARGINGETSTYLES(int line, char *styles)
+ SCI_MARGINGETSTYLE(int line) → int
+ SCI_MARGINSETSTYLES(int line, const char *styles)
+ SCI_MARGINGETSTYLES(int line, char *styles) → int
SCI_MARGINTEXTCLEARALL
Text margins are created with the type SC_MARGIN_TEXT or SC_MARGIN_RTEXT. A different string may be set for each line with SCI_MARGINSETTEXT. @@ -3101,19 +3507,19 @@ struct Sci_TextToFind {

SCI_MARGINSETSTYLEOFFSET(int style)
- SCI_MARGINGETSTYLEOFFSET
+ SCI_MARGINGETSTYLEOFFSET → int
Margin styles may be completely separated from standard text styles by setting a style offset. For example, SCI_MARGINSETSTYLEOFFSET(256) would allow the margin styles to be numbered from 256 up to 511 so they do not overlap styles set by lexers. Each style number set with SCI_MARGINSETSTYLE or SCI_MARGINSETSTYLES has the offset added before looking up the style.

- Always call SCI_ALLOCATEEXTENDEDSTYLES + Always call SCI_ALLOCATEEXTENDEDSTYLES before SCI_MARGINSETSTYLEOFFSET and use the result as the argument to SCI_MARGINSETSTYLEOFFSET.

SCI_SETMARGINOPTIONS(int marginOptions)
- SCI_GETMARGINOPTIONS
+ SCI_GETMARGINOPTIONS → int
Define margin options by enabling appropriate bit flags. At the moment, only one flag is available SC_MARGINOPTION_SUBLINESELECT=1, which controls how wrapped lines are selected when clicking on margin in front of them. If SC_MARGINOPTION_SUBLINESELECT is set only sub line of wrapped @@ -3134,28 +3540,28 @@ struct Sci_TextToFind {

Annotations used for inline diagnostics

- SCI_ANNOTATIONSETTEXT(int line, char *text)
- SCI_ANNOTATIONGETTEXT(int line, char *text)
+ SCI_ANNOTATIONSETTEXT(int line, const char *text)
+ SCI_ANNOTATIONGETTEXT(int line, char *text) → int
SCI_ANNOTATIONSETSTYLE(int line, int style)
- SCI_ANNOTATIONGETSTYLE(int line)
- SCI_ANNOTATIONSETSTYLES(int line, char *styles)
- SCI_ANNOTATIONGETSTYLES(int line, char *styles)
- SCI_ANNOTATIONGETLINES(int line)
+ SCI_ANNOTATIONGETSTYLE(int line) → int
+ SCI_ANNOTATIONSETSTYLES(int line, const char *styles)
+ SCI_ANNOTATIONGETSTYLES(int line, char *styles) → int
+ SCI_ANNOTATIONGETLINES(int line) → int
SCI_ANNOTATIONCLEARALL
SCI_ANNOTATIONSETVISIBLE(int visible)
- SCI_ANNOTATIONGETVISIBLE
+ SCI_ANNOTATIONGETVISIBLE → int
SCI_ANNOTATIONSETSTYLEOFFSET(int style)
- SCI_ANNOTATIONGETSTYLEOFFSET
+ SCI_ANNOTATIONGETSTYLEOFFSET → int

- SCI_ANNOTATIONSETTEXT(int line, char *text)
- SCI_ANNOTATIONGETTEXT(int line, char *text)
+ SCI_ANNOTATIONSETTEXT(int line, const char *text)
+ SCI_ANNOTATIONGETTEXT(int line, char *text) → int
SCI_ANNOTATIONSETSTYLE(int line, int style)
- SCI_ANNOTATIONGETSTYLE(int line)
- SCI_ANNOTATIONSETSTYLES(int line, char *styles)
- SCI_ANNOTATIONGETSTYLES(int line, char *styles)
- SCI_ANNOTATIONGETLINES(int line)
+ SCI_ANNOTATIONGETSTYLE(int line) → int
+ SCI_ANNOTATIONSETSTYLES(int line, const char *styles)
+ SCI_ANNOTATIONGETSTYLES(int line, char *styles) → int
+ SCI_ANNOTATIONGETLINES(int line) → int
SCI_ANNOTATIONCLEARALL
A different string may be set for each line with SCI_ANNOTATIONSETTEXT. To clear annotations call SCI_ANNOTATIONSETTEXT with a NULL pointer. @@ -3178,12 +3584,12 @@ struct Sci_TextToFind {

SCI_ANNOTATIONSETVISIBLE(int visible)
- SCI_ANNOTATIONGETVISIBLE
+ SCI_ANNOTATIONGETVISIBLE → int
Annotations can be made visible in a view and there is a choice of display style when visible. - The two messages set and get the annotation display mode. The visible + The two messages set and get the annotation display mode. The visible argument can be one of:

- +
@@ -3221,7 +3627,7 @@ struct Sci_TextToFind {

SCI_ANNOTATIONSETSTYLEOFFSET(int style)
- SCI_ANNOTATIONGETSTYLEOFFSET
+ SCI_ANNOTATIONGETSTYLEOFFSET → int
Annotation styles may be completely separated from standard text styles by setting a style offset. For example, SCI_ANNOTATIONSETSTYLEOFFSET(512) would allow the annotation styles to be numbered from 512 up to 767 so they do not overlap styles set by lexers (or margins if margins offset is 256). @@ -3229,36 +3635,29 @@ struct Sci_TextToFind { or SCI_ANNOTATIONSETSTYLES has the offset added before looking up the style.

- Always call SCI_ALLOCATEEXTENDEDSTYLES + Always call SCI_ALLOCATEEXTENDEDSTYLES before SCI_ANNOTATIONSETSTYLEOFFSET and use the result as the argument to SCI_ANNOTATIONSETSTYLEOFFSET.

Other settings

- SCI_SETBUFFEREDDRAW(bool isBuffered)
- SCI_GETBUFFEREDDRAW
+ SCI_SETBUFFEREDDRAW(bool buffered)
+ SCI_GETBUFFEREDDRAW → bool
SCI_SETPHASESDRAW(int phases)
- SCI_GETPHASESDRAW
+ SCI_GETPHASESDRAW → int
SCI_SETTWOPHASEDRAW(bool twoPhase)
- SCI_GETTWOPHASEDRAW
+ SCI_GETTWOPHASEDRAW → bool
SCI_SETTECHNOLOGY(int technology)
- SCI_GETTECHNOLOGY
+ SCI_GETTECHNOLOGY → int
SCI_SETFONTQUALITY(int fontQuality)
- SCI_GETFONTQUALITY
+ SCI_GETFONTQUALITY → int
SCI_SETCODEPAGE(int codePage)
- SCI_GETCODEPAGE
+ SCI_GETCODEPAGE → int
SCI_SETIMEINTERACTION(int imeInteraction)
- SCI_GETIMEINTERACTION
- SCI_SETWORDCHARS(<unused>, const char *characters)
- SCI_GETWORDCHARS(<unused>, char *characters)
- SCI_SETWHITESPACECHARS(<unused>, const char *characters)
- SCI_GETWHITESPACECHARS(<unused>, char *characters)
- SCI_SETPUNCTUATIONCHARS(<unused>, const char *characters)
- SCI_GETPUNCTUATIONCHARS(<unused>, char *characters)
- SCI_SETCHARSDEFAULT
+ SCI_GETIMEINTERACTION → int
SCI_GRABFOCUS
SCI_SETFOCUS(bool focus)
- SCI_GETFOCUS
+ SCI_GETFOCUS → bool

To forward a message (WM_XXXX, WPARAM, LPARAM) to Scintilla, you can use @@ -3270,15 +3669,22 @@ struct Sci_TextToFind { collect changes to mouse settings, but could be used for other user interface items in the future).

-

SCI_SETBUFFEREDDRAW(bool isBuffered)
- SCI_GETBUFFEREDDRAW
+

SCI_SETBUFFEREDDRAW(bool buffered)
+ SCI_GETBUFFEREDDRAW → bool
These messages turn buffered drawing on or off and report the buffered drawing state. Buffered drawing draws each line into a bitmap rather than directly to the screen and then copies the bitmap to the screen. This avoids flickering although it does take longer. The default is for - drawing to be buffered.

+ drawing to be buffered on Win32 and GTK and to not be buffered on Cocoa and Qt. + Buffered drawing is not supported on Cocoa. +

+ +

Current platforms perform window buffering so it is almost always better for this option to be turned off. + For Win32 and GTK, client code should turn off buffering at initialisation. + There are some older platforms and unusual modes where buffering may still be useful. +

SCI_SETPHASESDRAW(int phases)
- SCI_GETPHASESDRAW
+ SCI_GETPHASESDRAW → int
There are several orders in which the text area may be drawn offering a trade-off between speed and allowing all pixels of text to be seen even when they overlap other elements.

In single phase drawing (SC_PHASES_ONE) each @@ -3304,35 +3710,34 @@ struct Sci_TextToFind { This mode is incompatible with buffered drawing and will act as SC_PHASES_TWO if buffered drawing is turned on. Multiple phase drawing is slower than two phase drawing. - Setting the layout cache to SC_CACHE_PAGE + Setting the layout cache with + + SCI_SETLAYOUTCACHE(SC_CACHE_PAGE) or higher can ensure that multiple phase drawing is not significantly slower.

SCI_SETTWOPHASEDRAW(bool twoPhase)
- SCI_GETTWOPHASEDRAW
+ SCI_GETTWOPHASEDRAW → bool
This property has been replaced with the preceding PHASESDRAW property which is more general, allowing multiple phase drawing as well as one and two phase drawing.

SCI_SETTECHNOLOGY(int technology)
- SCI_GETTECHNOLOGY
+ SCI_GETTECHNOLOGY → int
The technology property allows choosing between different drawing APIs and options. On most platforms, the only choice is SC_TECHNOLOGY_DEFAULT (0). On Windows Vista or later, SC_TECHNOLOGY_DIRECTWRITE (1), - SC_TECHNOLOGY_DIRECTWRITERETAIN (2), or - SC_TECHNOLOGY_DIRECTWRITEDC (3) + SC_TECHNOLOGY_DIRECTWRITERETAIN (2), or + SC_TECHNOLOGY_DIRECTWRITEDC (3) can be chosen to use the Direct2D and DirectWrite APIs for higher quality antialiased drawing. - SC_TECHNOLOGY_DIRECTWRITERETAIN differs from + SC_TECHNOLOGY_DIRECTWRITERETAIN differs from SC_TECHNOLOGY_DIRECTWRITE by requesting that the frame is retained after being presented which may prevent drawing failures on some cards and drivers. - SC_TECHNOLOGY_DIRECTWRITEDC differs from + SC_TECHNOLOGY_DIRECTWRITEDC differs from SC_TECHNOLOGY_DIRECTWRITE by using DirectWrite to draw into a GDI DC. Since Direct2D buffers drawing, Scintilla's buffering can be turned off with - SCI_SETBUFFEREDDRAW(0). - Since SC_TECHNOLOGY_DIRECTWRITERETAIN and - SC_TECHNOLOGY_DIRECTWRITEDC - are provisional, they may be changed or removed in a future release if a better solution is found.

+ SCI_SETBUFFEREDDRAW(0).

SCI_SETFONTQUALITY(int fontQuality)
- SCI_GETFONTQUALITY
+ SCI_GETFONTQUALITY → int
Manage font quality (antialiasing method). Currently, the following values are available on Windows: SC_EFF_QUALITY_DEFAULT (backward compatible), SC_EFF_QUALITY_NON_ANTIALIASED, @@ -3342,15 +3747,16 @@ struct Sci_TextToFind { by SC_EFF_QUALITY_MASK (0xf) will be used for quality.

SCI_SETCODEPAGE(int codePage)
- SCI_GETCODEPAGE
- Scintilla has some support for Japanese, Chinese and Korean DBCS. Use this message with - codePage set to the code page number to set Scintilla to use code page information - to ensure double byte characters are treated as one character rather than two. This also stops - the caret from moving between the two bytes in a double byte character. - Do not use this message to choose between different single byte character sets: it doesn't do that. + SCI_GETCODEPAGE → int
+ Scintilla supports UTF-8, Japanese, Chinese and Korean DBCS along with single byte encodings like Latin-1. + UTF-8 (SC_CP_UTF8) is the default. Use this message with + codePage set to the code page number to set Scintilla to use code page information + to ensure multiple byte characters are treated as one character rather than multiple. This also stops + the caret from moving between the bytes in a multi-byte character. + Do not use this message to choose between different single byte character sets - use + SCI_STYLESETCHARACTERSET. Call with - codePage set to zero to disable DBCS support. The default is - SCI_SETCODEPAGE(0).

+ codePage set to zero to disable multi-byte support.

Code page SC_CP_UTF8 (65001) sets Scintilla into Unicode mode with the document treated as a sequence of characters expressed in UTF-8. The text is converted to the platform's @@ -3359,12 +3765,11 @@ struct Sci_TextToFind { horizontal space, such as Thai, will mostly work but there are some issues where the characters are drawn separately leading to visual glitches. Bi-directional text is not supported.

-

Code page can be set to 932 (Japanese Shift-JIS), 936 (Simplified Chinese GBK), - 949 (Korean Unified Hangul Code), 950 (Traditional Chinese Big5), or 1361 (Korean Johab) - although these may require installation of language specific support.

+

Code page can be set to 65001 (UTF-8), 932 (Japanese Shift-JIS), 936 (Simplified Chinese GBK), + 949 (Korean Unified Hangul Code), 950 (Traditional Chinese Big5), or 1361 (Korean Johab).

SCI_SETIMEINTERACTION(int imeInteraction)
- SCI_GETIMEINTERACTION
+ SCI_GETIMEINTERACTION → int
When entering text in Chinese, Japanese, or Korean an Input Method Editor (IME) may be displayed. The IME may be an extra window appearing above Scintilla or may be displayed by Scintilla itself as text. On some platforms there is a choice between the two techniques. @@ -3375,65 +3780,30 @@ struct Sci_TextToFind {

The windowed behaviour can be chosen with SCI_SETIMEINTERACTION(SC_IME_WINDOWED) and the inline behaviour with SCI_SETIMEINTERACTION(SC_IME_INLINE). Scintilla may ignore this call in some cases. For example, the inline behaviour might only be supported for some languages.

- -

SCI_SETWORDCHARS(<unused>, const char *characters)
- Scintilla has several functions that operate on words, which are defined to be contiguous - sequences of characters from a particular set of characters. This message defines which - characters are members of that set. The character sets are set to default values before processing this - function. - For example, if you don't allow '_' in your set of characters - use:
- SCI_SETWORDCHARS(0, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");

- -

SCI_GETWORDCHARS(<unused>, char *characters)
- This fills the characters parameter with all the characters included in words. - The characters parameter must be large enough to hold all of the characters. - If the characters parameter is 0 then the length that should be allocated - to store the entire set is returned.

- -

SCI_SETWHITESPACECHARS(<unused>, const char *characters)
- SCI_GETWHITESPACECHARS(<unused>, char *characters)
- Similar to SCI_SETWORDCHARS, this message allows the user to define which chars Scintilla considers - as whitespace. Setting the whitespace chars allows the user to fine-tune Scintilla's behaviour doing - such things as moving the cursor to the start or end of a word; for example, by defining punctuation chars - as whitespace, they will be skipped over when the user presses ctrl+left or ctrl+right. - This function should be called after SCI_SETWORDCHARS as it will - reset the whitespace characters to the default set. - SCI_GETWHITESPACECHARS behaves similarly to SCI_GETWORDCHARS.

- -

SCI_SETPUNCTUATIONCHARS(<unused>, const char *characters)
- SCI_GETPUNCTUATIONCHARS(<unused>, char *characters)
- Similar to SCI_SETWORDCHARS and SCI_SETWHITESPACECHARS, this message - allows the user to define which chars Scintilla considers as punctuation. - SCI_GETPUNCTUATIONCHARS behaves similarly to SCI_GETWORDCHARS.

- -

SCI_SETCHARSDEFAULT
- Use the default sets of word and whitespace characters. This sets whitespace to space, tab and other - characters with codes less than 0x20, with word characters set to alphanumeric and '_'. -

- +

When the inline IME mode is active, characters are added tentatively before being finalised and an + SCN_CHARADDED + notification is sent for each character.

SCI_GRABFOCUS
SCI_SETFOCUS(bool focus)
- SCI_GETFOCUS
- Scintilla can be told to grab the focus with this message. This is needed more on GTK+ where - focus handling is more complicated than on Windows.

+ SCI_GETFOCUS → bool
+ Scintilla can be told to grab the focus with SCI_GRABFOCUS. + This is needed more on GTK where focus handling is more complicated than on Windows.

The internal focus flag can be set with SCI_SETFOCUS. This is used by clients that have complex focus requirements such as having their own window that gets the real focus but with the need to indicate that Scintilla has the logical focus.

Brace highlighting

- SCI_BRACEHIGHLIGHT(int pos1, int - pos2)
- SCI_BRACEBADLIGHT(int pos1)
- SCI_BRACEHIGHLIGHTINDICATOR(bool useBraceHighlightIndicator, int indicatorNumber)
- SCI_BRACEBADLIGHTINDICATOR(bool useBraceBadLightIndicator, int indicatorNumber)
- SCI_BRACEMATCH(int position, int - maxReStyle)
+ SCI_BRACEHIGHLIGHT(int posA, int + posB)
+ SCI_BRACEBADLIGHT(int pos)
+ SCI_BRACEHIGHLIGHTINDICATOR(bool useSetting, int indicator)
+ SCI_BRACEBADLIGHTINDICATOR(bool useSetting, int indicator)
+ SCI_BRACEMATCH(int pos, int maxReStyle) → position
-

SCI_BRACEHIGHLIGHT(int pos1, int pos2)
+

SCI_BRACEHIGHLIGHT(int posA, int posB)
Up to two characters can be highlighted in a 'brace highlighting style', which is defined as style number STYLE_BRACELIGHT (34). If you have enabled indent guides, you may also wish to highlight the indent that corresponds @@ -3441,21 +3811,21 @@ struct Sci_TextToFind { href="#SCI_GETCOLUMN">SCI_GETCOLUMN and highlight the indent with SCI_SETHIGHLIGHTGUIDE.

-

SCI_BRACEBADLIGHT(int pos1)
+

SCI_BRACEBADLIGHT(int pos)
If there is no matching brace then the brace badlighting style, style STYLE_BRACEBAD (35), can be used to show the brace that is unmatched. Using a position of INVALID_POSITION (-1) removes the highlight.

-

SCI_BRACEHIGHLIGHTINDICATOR(bool useBraceHighlightIndicator, int indicatorNumber)
+

SCI_BRACEHIGHLIGHTINDICATOR(bool useSetting, int indicator)
Use specified indicator to highlight matching braces instead of changing their style.

-

SCI_BRACEBADLIGHTINDICATOR(bool useBraceBadLightIndicator, int indicatorNumber)
+

SCI_BRACEBADLIGHTINDICATOR(bool useSetting, int indicator)
Use specified indicator to highlight non matching brace instead of changing its style.

-

SCI_BRACEMATCH(int pos, int maxReStyle)
+

SCI_BRACEMATCH(int pos, int maxReStyle) → position
The SCI_BRACEMATCH message finds a corresponding matching brace given - pos, the position of one brace. The brace characters handled are '(', ')', '[', + pos, the position of one brace. The brace characters handled are '(', ')', '[', ']', '{', '}', '<', and '>'. The search is forwards from an opening brace and backwards from a closing brace. If the character at position is not a brace character, or a matching brace cannot be found, the return value is -1. Otherwise, the return value is the position of @@ -3463,7 +3833,7 @@ struct Sci_TextToFind {

A match only occurs if the style of the matching brace is the same as the starting brace or the matching brace is beyond the end of styling. Nested braces are handled correctly. The - maxReStyle parameter must currently be 0 - it may be used in the future to limit + maxReStyle parameter must currently be 0 - it may be used in the future to limit the length of brace searches.

Tabs and Indentation Guides

@@ -3482,40 +3852,39 @@ struct Sci_TextToFind { inserting a tab at the current character position and backspace unindents the line rather than deleting a character. Scintilla can also display indentation guides (vertical lines) to help you to generate code.

- SCI_SETTABWIDTH(int widthInChars)
- SCI_GETTABWIDTH
+ SCI_SETTABWIDTH(int tabWidth)
+ SCI_GETTABWIDTH → int
SCI_CLEARTABSTOPS(int line)
SCI_ADDTABSTOP(int line, int x)
- SCI_GETNEXTTABSTOP(int line, int x)
+ SCI_GETNEXTTABSTOP(int line, int x) → int
SCI_SETUSETABS(bool useTabs)
- SCI_GETUSETABS
- SCI_SETINDENT(int widthInChars)
- SCI_GETINDENT
+ SCI_GETUSETABS → bool
+ SCI_SETINDENT(int indentSize)
+ SCI_GETINDENT → int
SCI_SETTABINDENTS(bool tabIndents)
- SCI_GETTABINDENTS
+ SCI_GETTABINDENTS → bool
SCI_SETBACKSPACEUNINDENTS(bool bsUnIndents)
- SCI_GETBACKSPACEUNINDENTS
+ SCI_GETBACKSPACEUNINDENTS → bool
SCI_SETLINEINDENTATION(int line, int indentation)
- SCI_GETLINEINDENTATION(int line)
- SCI_GETLINEINDENTPOSITION(int - line)
+ SCI_GETLINEINDENTATION(int line) → int
+ SCI_GETLINEINDENTPOSITION(int line) → position
SCI_SETINDENTATIONGUIDES(int indentView)
- SCI_GETINDENTATIONGUIDES
+ SCI_GETINDENTATIONGUIDES → int
SCI_SETHIGHLIGHTGUIDE(int column)
- SCI_GETHIGHLIGHTGUIDE
+ SCI_GETHIGHLIGHTGUIDE → int
-

SCI_SETTABWIDTH(int widthInChars)
- SCI_GETTABWIDTH
+

SCI_SETTABWIDTH(int tabWidth)
+ SCI_GETTABWIDTH → int
SCI_SETTABWIDTH sets the size of a tab as a multiple of the size of a space character in STYLE_DEFAULT. The default tab width is 8 characters. There are no limits on tab sizes, but values less than 1 or large values may have undesirable effects.

SCI_CLEARTABSTOPS(int line)
SCI_ADDTABSTOP(int line, int x)
- SCI_GETNEXTTABSTOP(int line, int x)
+ SCI_GETNEXTTABSTOP(int line, int x) → int
SCI_CLEARTABSTOPS clears explicit tabstops on a line. SCI_ADDTABSTOP adds an explicit tabstop at the specified distance from the left (in pixels), and SCI_GETNEXTTABSTOP gets the next explicit tabstop position set after the given x position, @@ -3524,14 +3893,14 @@ struct Sci_TextToFind {

SCI_SETUSETABS(bool useTabs)
- SCI_GETUSETABS
+ SCI_GETUSETABS → bool
SCI_SETUSETABS determines whether indentation should be created out of a mixture - of tabs and spaces or be based purely on spaces. Set useTabs to false + of tabs and spaces or be based purely on spaces. Set useTabs to false (0) to create all tabs and indents out of spaces. The default is true. You can use SCI_GETCOLUMN to get the column of a position taking the width of a tab into account.

-

SCI_SETINDENT(int widthInChars)
- SCI_GETINDENT
+

SCI_SETINDENT(int indentSize)
+ SCI_GETINDENT → int
SCI_SETINDENT sets the size of indentation in terms of the width of a space in STYLE_DEFAULT. If you set a width of 0, the indent size is the same as the tab size. There are no limits on indent sizes, but values @@ -3539,9 +3908,9 @@ struct Sci_TextToFind {

SCI_SETTABINDENTS(bool tabIndents)
- SCI_GETTABINDENTS
+ SCI_GETTABINDENTS → bool
SCI_SETBACKSPACEUNINDENTS(bool bsUnIndents)
- SCI_GETBACKSPACEUNINDENTS
+ SCI_GETBACKSPACEUNINDENTS → bool

Inside indentation white space, the tab and backspace keys can be made to indent and @@ -3549,16 +3918,16 @@ struct Sci_TextToFind { SCI_SETTABINDENTS and SCI_SETBACKSPACEUNINDENTS functions.

SCI_SETLINEINDENTATION(int line, int indentation)
- SCI_GETLINEINDENTATION(int line)
+ SCI_GETLINEINDENTATION(int line) → int
The amount of indentation on a line can be discovered and set with SCI_GETLINEINDENTATION and SCI_SETLINEINDENTATION. The indentation is measured in character columns, which correspond to the width of space characters.

-

SCI_GETLINEINDENTPOSITION(int line)
+

SCI_GETLINEINDENTPOSITION(int line) → position
This returns the position at the end of indentation of a line.

SCI_SETINDENTATIONGUIDES(int indentView)
- SCI_GETINDENTATIONGUIDES
+ SCI_GETINDENTATIONGUIDES → int
Indentation guides are dotted vertical lines that appear within indentation white space every indent size columns. They make it easy to see which constructs line up especially when they extend over multiple pages. Style There are 4 indentation guide views. SC_IV_NONE turns the feature off but the other 3 states determine how far the guides appear on empty lines.

-
ANNOTATION_HIDDEN
+
@@ -3599,10 +3968,10 @@ struct Sci_TextToFind {
SC_IV_NONE

SCI_SETHIGHLIGHTGUIDE(int column)
- SCI_GETHIGHLIGHTGUIDE
+ SCI_GETHIGHLIGHTGUIDE → int
When brace highlighting occurs, the indentation guide corresponding to the braces may be highlighted with the brace highlighting style,
STYLE_BRACELIGHT (34). Set column to 0 to + href="#StyleDefinition">STYLE_BRACELIGHT (34). Set column to 0 to cancel this highlight.

Markers

@@ -3629,41 +3998,36 @@ struct Sci_TextToFind { their line moves. When a line is deleted, its markers are combined, by an OR operation, with the markers of the next line.

SCI_MARKERDEFINE(int markerNumber, int - markerSymbols)
+ markerSymbol)
SCI_MARKERDEFINEPIXMAP(int markerNumber, - const char *xpm)
+ const char *pixmap)
SCI_RGBAIMAGESETWIDTH(int width)
SCI_RGBAIMAGESETHEIGHT(int height)
SCI_RGBAIMAGESETSCALE(int scalePercent)
SCI_MARKERDEFINERGBAIMAGE(int markerNumber, const char *pixels)
- SCI_MARKERSYMBOLDEFINED(int markerNumber) -
- SCI_MARKERSETFORE(int markerNumber, int - colour)
- SCI_MARKERSETBACK(int markerNumber, int - colour)
- SCI_MARKERSETBACKSELECTED(int markerNumber, int - colour)
+ SCI_MARKERSYMBOLDEFINED(int markerNumber) → int
+ SCI_MARKERSETFORE(int markerNumber, colour + fore)
+ SCI_MARKERSETBACK(int markerNumber, colour + back)
+ SCI_MARKERSETBACKSELECTED(int markerNumber, colour + back)
SCI_MARKERENABLEHIGHLIGHT(bool enabled)
- SCI_MARKERSETALPHA(int markerNumber, int - alpha)
- SCI_MARKERADD(int line, int markerNumber)
- SCI_MARKERADDSET(int line, int markerMask)
+ SCI_MARKERSETALPHA(int markerNumber, alpha alpha)
+ SCI_MARKERADD(int line, int markerNumber) → int
+ SCI_MARKERADDSET(int line, int markerSet)
SCI_MARKERDELETE(int line, int markerNumber)
SCI_MARKERDELETEALL(int markerNumber)
- SCI_MARKERGET(int line)
- SCI_MARKERNEXT(int lineStart, int - markerMask)
- SCI_MARKERPREVIOUS(int lineStart, int - markerMask)
- SCI_MARKERLINEFROMHANDLE(int - handle)
- SCI_MARKERDELETEHANDLE(int handle)
+ SCI_MARKERGET(int line) → int
+ SCI_MARKERNEXT(int lineStart, int markerMask) → int
+ SCI_MARKERPREVIOUS(int lineStart, int markerMask) → int
+ SCI_MARKERLINEFROMHANDLE(int markerHandle) → int
+ SCI_MARKERDELETEHANDLE(int markerHandle)
-

SCI_MARKERDEFINE(int markerNumber, int markerSymbols)
+

SCI_MARKERDEFINE(int markerNumber, int markerSymbol)
This message associates a marker number in the range 0 to 31 with one of the marker symbols or an ASCII character. The general-purpose marker symbols currently available are:
SC_MARK_CIRCLE, @@ -3680,7 +4044,8 @@ struct Sci_TextToFind { SC_MARK_BACKGROUND, SC_MARK_LEFTRECT, SC_MARK_FULLRECT, - SC_MARK_BOOKMARK, and + SC_MARK_BOOKMARK, + SC_MARK_VERTICALBOOKMARK, and SC_MARK_UNDERLINE.

@@ -3731,7 +4096,7 @@ struct Sci_TextToFind { Macintosh), plus/minus shows folded lines as '+' and opened folds as '-', Circle tree, Box tree.

- +
@@ -3835,7 +4200,7 @@ struct Sci_TextToFind {

Marker samples

SCI_MARKERDEFINEPIXMAP(int markerNumber, const char - *xpm)
+ *pixmap)
Markers can be set to pixmaps with this message. The XPM format is used for the pixmap. Pixmaps use the SC_MARK_PIXMAP marker symbol.

@@ -3854,38 +4219,35 @@ struct Sci_TextToFind { The default scale, 100, will stretch each image pixel to cover 4 screen pixels on a retina display.

Pixmaps use the SC_MARK_RGBAIMAGE marker symbol.

-

SCI_MARKERSYMBOLDEFINED(int markerNumber)
+

SCI_MARKERSYMBOLDEFINED(int markerNumber) → int
Returns the symbol defined for a markerNumber with SCI_MARKERDEFINE or SC_MARK_PIXMAP if defined with SCI_MARKERDEFINEPIXMAP or SC_MARK_RGBAIMAGE if defined with SCI_MARKERDEFINERGBAIMAGE.

-

SCI_MARKERSETFORE(int markerNumber, int colour)
- SCI_MARKERSETBACK(int markerNumber, int colour)
+

SCI_MARKERSETFORE(int markerNumber, colour fore)
+ SCI_MARKERSETBACK(int markerNumber, colour back)
These two messages set the foreground and background colour of a marker number.
- SCI_MARKERSETBACKSELECTED(int markerNumber, int colour)
+ SCI_MARKERSETBACKSELECTED(int markerNumber, colour back)
This message sets the highlight background colour of a marker number when its folding block is selected. The default colour is #FF0000.

SCI_MARKERENABLEHIGHLIGHT(bool enabled)
This message allows to enable/disable the highlight folding block when it is selected. (i.e. block that contains the caret)

-

SCI_MARKERSETALPHA(int markerNumber, int alpha)
+

SCI_MARKERSETALPHA(int markerNumber, + alpha alpha)
When markers are drawn in the content area, either because there is no margin for them or they are of SC_MARK_BACKGROUND or SC_MARK_UNDERLINE types, they may be drawn translucently by setting an alpha value.

-

SCI_MARKERADD(int line, int markerNumber)
- This message adds marker number markerNumber to a line. The message returns -1 if +

SCI_MARKERADD(int line, int markerNumber) → int
+ This message adds marker number markerNumber to a line. The message returns -1 if this fails (illegal line number, out of memory) or it returns a marker handle number that - identifies the added marker. You can use this returned handle with SCI_MARKERLINEFROMHANDLE to find where a marker is after moving or combining lines and with SCI_MARKERDELETEHANDLE to delete the marker based on its handle. The message does not check the value of markerNumber, nor does it check if the line already contains the marker.

-

SCI_MARKERADDSET(int line, int markerMask)
+

SCI_MARKERADDSET(int line, int markerSet)
This message can add one or more markers to a line with a single call, specified in the same "one-bit-per-marker" 32-bit integer format returned by SCI_MARKERGET (and used by the mask-based marker search functions @@ -3905,28 +4267,28 @@ struct Sci_TextToFind { This removes markers of the given number from all lines. If markerNumber is -1, it deletes all markers from all lines.

-

SCI_MARKERGET(int line)
+

SCI_MARKERGET(int line) → int
This returns a 32-bit integer that indicates which markers were present on the line. Bit 0 is set if marker 0 is present, bit 1 for marker 1 and so on.

-

SCI_MARKERNEXT(int lineStart, int markerMask)
- SCI_MARKERPREVIOUS(int lineStart, int markerMask)
+

SCI_MARKERNEXT(int lineStart, int markerMask) → int
+ SCI_MARKERPREVIOUS(int lineStart, int markerMask) → int
These messages search efficiently for lines that include a given set of markers. The search - starts at line number lineStart and continues forwards to the end of the file + starts at line number lineStart and continues forwards to the end of the file (SCI_MARKERNEXT) or backwards to the start of the file - (SCI_MARKERPREVIOUS). The markerMask argument should have one bit set + (SCI_MARKERPREVIOUS). The markerMask argument should have one bit set for each marker you wish to find. Set bit 0 to find marker 0, bit 1 for marker 1 and so on. The message returns the line number of the first line that contains one of the markers in - markerMask or -1 if no marker is found.

+ markerMask or -1 if no marker is found.

-

SCI_MARKERLINEFROMHANDLE(int markerHandle)
- The markerHandle argument is an identifier for a marker returned by SCI_MARKERLINEFROMHANDLE(int markerHandle) → int
+ The markerHandle argument is an identifier for a marker returned by
SCI_MARKERADD. This function searches the document for the marker with this handle and returns the line number that contains it or -1 if it is not found.

SCI_MARKERDELETEHANDLE(int markerHandle)
- The markerHandle argument is an identifier for a marker returned by markerHandle argument is an identifier for a marker returned by SCI_MARKERADD. This function searches the document for the marker with this handle and deletes the marker if it is found.

@@ -3944,7 +4306,7 @@ struct Sci_TextToFind { They may also be invisible when used to track pieces of content for the application as INDIC_HIDDEN.

The SCI_INDIC* messages allow you to get and set the visual appearance of the - indicators. They all use an indicatorNumber argument in the range 0 to INDIC_MAX(35) + indicators. They all use an indicator argument in the range 0 to INDIC_MAX(35) to set the indicator to style. To prevent interference the set of indicators is divided up into a range for use by lexers (0..7) a range for use by containers (8=INDIC_CONTAINER .. 31=INDIC_IME-1) @@ -3952,8 +4314,9 @@ struct Sci_TextToFind {

Indicators are stored in a format similar to run length encoding which is efficient in both speed and storage for sparse information.

-

An indicator may store different values for each range but currently all values are drawn the same. - In the future, it may be possible to draw different values in different styles.

+

An indicator may store different values for each range but normally all values are drawn the same. + The SCI_INDICSETFLAGS + API may be used to display different colours for different values.

Originally, Scintilla used a different technique for indicators but this has been removed @@ -3961,53 +4324,53 @@ struct Sci_TextToFind { While both techniques were supported, the term "modern indicators" was used for the newer implementation.

- SCI_INDICSETSTYLE(int indicatorNumber, int + SCI_INDICSETSTYLE(int indicator, int indicatorStyle)
- SCI_INDICGETSTYLE(int indicatorNumber)
- SCI_INDICSETFORE(int indicatorNumber, int - colour)
- SCI_INDICGETFORE(int indicatorNumber)
- SCI_INDICSETALPHA(int indicatorNumber, int alpha)
- SCI_INDICGETALPHA(int indicatorNumber)
- SCI_INDICSETOUTLINEALPHA(int indicatorNumber, int alpha)
- SCI_INDICGETOUTLINEALPHA(int indicatorNumber)
- SCI_INDICSETUNDER(int indicatorNumber, bool under)
- SCI_INDICGETUNDER(int indicatorNumber)
- SCI_INDICSETHOVERSTYLE(int indicatorNumber, int + SCI_INDICGETSTYLE(int indicator) → int
+ SCI_INDICSETFORE(int indicator, colour + fore)
+ SCI_INDICGETFORE(int indicator) → colour
+ SCI_INDICSETALPHA(int indicator, alpha alpha)
+ SCI_INDICGETALPHA(int indicator) → int
+ SCI_INDICSETOUTLINEALPHA(int indicator, alpha alpha)
+ SCI_INDICGETOUTLINEALPHA(int indicator) → int
+ SCI_INDICSETUNDER(int indicator, bool under)
+ SCI_INDICGETUNDER(int indicator) → bool
+ SCI_INDICSETHOVERSTYLE(int indicator, int indicatorStyle)
- SCI_INDICGETHOVERSTYLE(int indicatorNumber)
- SCI_INDICSETHOVERFORE(int indicatorNumber, int - colour)
- SCI_INDICGETHOVERFORE(int indicatorNumber)
- SCI_INDICSETFLAGS(int indicatorNumber, int flags)
- SCI_INDICGETFLAGS(int indicatorNumber)
+ SCI_INDICGETHOVERSTYLE(int indicator) → int
+ SCI_INDICSETHOVERFORE(int indicator, colour + fore)
+ SCI_INDICGETHOVERFORE(int indicator) → colour
+ SCI_INDICSETFLAGS(int indicator, int flags)
+ SCI_INDICGETFLAGS(int indicator) → int

SCI_SETINDICATORCURRENT(int indicator)
- SCI_GETINDICATORCURRENT
+ SCI_GETINDICATORCURRENT → int
SCI_SETINDICATORVALUE(int value)
- SCI_GETINDICATORVALUE
- SCI_INDICATORFILLRANGE(int position, int fillLength)
- SCI_INDICATORCLEARRANGE(int position, int clearLength)
- SCI_INDICATORALLONFOR(int position)
- SCI_INDICATORVALUEAT(int indicator, int position)
- SCI_INDICATORSTART(int indicator, int position)
- SCI_INDICATOREND(int indicator, int position)
+ SCI_GETINDICATORVALUE → int
+ SCI_INDICATORFILLRANGE(int start, int lengthFill)
+ SCI_INDICATORCLEARRANGE(int start, int lengthClear)
+ SCI_INDICATORALLONFOR(int pos) → int
+ SCI_INDICATORVALUEAT(int indicator, int pos) → int
+ SCI_INDICATORSTART(int indicator, int pos) → int
+ SCI_INDICATOREND(int indicator, int pos) → int
SCI_FINDINDICATORSHOW(int start, int end)
SCI_FINDINDICATORFLASH(int start, int end)
SCI_FINDINDICATORHIDE
-

SCI_INDICSETSTYLE(int indicatorNumber, int +

SCI_INDICSETSTYLE(int indicator, int indicatorStyle)
- SCI_INDICGETSTYLE(int indicatorNumber)
+ SCI_INDICGETSTYLE(int indicator) → int
These two messages set and get the style for a particular indicator. The indicator styles currently available are:
Indicator samples

-
SC_MARKNUM_*
+
@@ -4082,8 +4445,8 @@ struct Sci_TextToFind { @@ -4094,8 +4457,8 @@ struct Sci_TextToFind { @@ -4142,12 +4505,29 @@ struct Sci_TextToFind { + + + + + + + + + + + + + + + + @@ -4155,7 +4535,7 @@ struct Sci_TextToFind { @@ -4187,6 +4567,22 @@ struct Sci_TextToFind { + + + + + + + + + + + + + + + +
SymbolA rectangle with rounded corners around the text using translucent drawing with the interior usually more transparent than the border. You can use - SCI_INDICSETALPHA and - SCI_INDICSETOUTLINEALPHA + SCI_INDICSETALPHA and + SCI_INDICSETOUTLINEALPHA to control the alpha transparency values. The default alpha values are 30 for fill colour and 50 for outline colour.
A rectangle around the text using translucent drawing with the interior usually more transparent than the border. You can use - SCI_INDICSETALPHA and - SCI_INDICSETOUTLINEALPHA + SCI_INDICSETALPHA and + SCI_INDICSETOUTLINEALPHA to control the alpha transparency values. The default alpha values are 30 for fill colour and 50 for outline colour. This indicator does not colour the top pixel of the line so that indicators on contiguous lines are visually distinct and disconnected.A dotted rectangle around the text using translucent drawing. Translucency alternates between the alpha and outline alpha settings with the top-left pixel using the alpha setting. - SCI_INDICSETALPHA and - SCI_INDICSETOUTLINEALPHA + SCI_INDICSETALPHA and + SCI_INDICSETOUTLINEALPHA control the alpha transparency values. The default values are 30 for alpha and 50 for outline alpha. To avoid excessive memory allocation the maximum width of a dotted box is 4000 pixels.
INDIC_GRADIENT20A vertical gradient between a colour and alpha at top to fully transparent at bottom.
INDIC_GRADIENTCENTRE21A vertical gradient with the specified colour and alpha in the middle + fading to fully transparent at top and bottom.
INDIC_SQUIGGLEPIXMAPA version of INDIC_SQUIGGLE that draws using a pixmap instead of as a series of line segments for performance. - Measured to be between 3 and 6 times faster than INDIC_SQUIGGLE on GTK+. + Measured to be between 3 and 6 times faster than INDIC_SQUIGGLE on GTK. Appearance will not be as good as INDIC_SQUIGGLE on OS X in HiDPI mode.
Change the colour of the text to the indicator's fore colour.
INDIC_POINT18Draw a triangle below the start of the indicator range.
INDIC_POINTCHARACTER19Draw a triangle below the centre of the first character of the indicator range.
@@ -4195,94 +4591,94 @@ struct Sci_TextToFind { SCI_INDICSETSTYLE(1, INDIC_TT);
SCI_INDICSETSTYLE(2, INDIC_PLAIN);

-

SCI_INDICSETFORE(int indicatorNumber, int colour)
- SCI_INDICGETFORE(int indicatorNumber)
+

SCI_INDICSETFORE(int indicator, colour fore)
+ SCI_INDICGETFORE(int indicator) → colour
These two messages set and get the colour used to draw an indicator. The default indicator colours are equivalent to:
SCI_INDICSETFORE(0, 0x007f00); (dark green)
SCI_INDICSETFORE(1, 0xff0000); (light blue)
SCI_INDICSETFORE(2, 0x0000ff); (light red)

-

SCI_INDICSETALPHA(int indicatorNumber, int alpha)
- SCI_INDICGETALPHA(int indicatorNumber)
+

SCI_INDICSETALPHA(int indicator, alpha alpha)
+ SCI_INDICGETALPHA(int indicator) → int
These two messages set and get the alpha transparency used for drawing the fill colour of the INDIC_ROUNDBOX and INDIC_STRAIGHTBOX rectangle. The alpha value can range from 0 (completely transparent) to 255 (no transparency).

-

SCI_INDICSETOUTLINEALPHA(int indicatorNumber, int alpha)
- SCI_INDICGETOUTLINEALPHA(int indicatorNumber)
+

SCI_INDICSETOUTLINEALPHA(int indicator, alpha alpha)
+ SCI_INDICGETOUTLINEALPHA(int indicator) → int
These two messages set and get the alpha transparency used for drawing the outline colour of the INDIC_ROUNDBOX and INDIC_STRAIGHTBOX rectangle. The alpha value can range from 0 (completely transparent) to 255 (no transparency).

-

SCI_INDICSETUNDER(int indicatorNumber, bool under)
- SCI_INDICGETUNDER(int indicatorNumber)
+

SCI_INDICSETUNDER(int indicator, bool under)
+ SCI_INDICGETUNDER(int indicator) → bool
These two messages set and get whether an indicator is drawn under text or over(default). Drawing under text works only for indicators when two phase drawing is enabled.

-

SCI_INDICSETHOVERSTYLE(int indicatorNumber, int +

SCI_INDICSETHOVERSTYLE(int indicator, int indicatorStyle)
- SCI_INDICGETHOVERSTYLE(int indicatorNumber)
- SCI_INDICSETHOVERFORE(int indicatorNumber, int colour)
- SCI_INDICGETHOVERFORE(int indicatorNumber)
+ SCI_INDICGETHOVERSTYLE(int indicator) → int
+ SCI_INDICSETHOVERFORE(int indicator, colour fore)
+ SCI_INDICGETHOVERFORE(int indicator) → colour
These messages set and get the colour and style used to draw indicators when the mouse is over them or the caret moved into them. - The mouse cursor also changes when an indicator is drawn in hover style. + The mouse cursor also changes when an indicator is drawn in hover style. The default is for the hover appearance to be the same as the normal appearance and calling - SCI_INDICSETFORE or - SCI_INDICSETSTYLE will + SCI_INDICSETFORE or + SCI_INDICSETSTYLE will also reset the hover attribute.

-

SCI_INDICSETFLAGS(int indicatorNumber, int flags)
- SCI_INDICGETFLAGS(int indicatorNumber)
+

SCI_INDICSETFLAGS(int indicator, int flags)
+ SCI_INDICGETFLAGS(int indicator) → int
These messages set and get the flags associated with an indicator. There is currently one flag defined, SC_INDICFLAG_VALUEFORE: when this flag is set the colour used by the indicator is not from the indicator's fore setting but instead from the value of the indicator at that point in the file. This allows many colours to be displayed for a single indicator. The value is an RGB integer colour that has been ored with SC_INDICVALUEBIT(0x1000000) - when calling SCI_SETINDICATORVALUE. + when calling SCI_SETINDICATORVALUE. To find the colour from the value, and the value with SC_INDICVALUEMASK(0xFFFFFF).

SCI_SETINDICATORCURRENT(int indicator)
- SCI_GETINDICATORCURRENT
+ SCI_GETINDICATORCURRENT → int
These two messages set and get the indicator that will be affected by calls to - SCI_INDICATORFILLRANGE(int position, int fillLength) and - SCI_INDICATORCLEARRANGE(int position, int clearLength). + SCI_INDICATORFILLRANGE(int start, int lengthFill) and + SCI_INDICATORCLEARRANGE(int start, int lengthClear).

SCI_SETINDICATORVALUE(int value)
- SCI_GETINDICATORVALUE
+ SCI_GETINDICATORVALUE → int
These two messages set and get the value that will be set by calls to - SCI_INDICATORFILLRANGE. + SCI_INDICATORFILLRANGE.

- SCI_INDICATORFILLRANGE(int position, int fillLength)
- SCI_INDICATORCLEARRANGE(int position, int clearLength)
+ SCI_INDICATORFILLRANGE(int start, int lengthFill)
+ SCI_INDICATORCLEARRANGE(int start, int lengthClear)
These two messages fill or clear a range for the current indicator. SCI_INDICATORFILLRANGE fills with the the current value.

- SCI_INDICATORALLONFOR(int position)
+ SCI_INDICATORALLONFOR(int pos) → int
Retrieve a bitmap value representing which indicators are non-zero at a position. Only the first 32 indicators are represented in the result so no IME indicators are included.

- SCI_INDICATORVALUEAT(int indicator, int position)
+ SCI_INDICATORVALUEAT(int indicator, int pos) → int
Retrieve the value of a particular indicator at a position.

- SCI_INDICATORSTART(int indicator, int position)
- SCI_INDICATOREND(int indicator, int position)
+ SCI_INDICATORSTART(int indicator, int pos) → int
+ SCI_INDICATOREND(int indicator, int pos) → int
Find the start or end of a range with one value from a position within the range. Can be used to iterate through the document to discover all the indicator positions.

@@ -4336,58 +4732,57 @@ struct Sci_TextToFind {

To make use of autocompletion you must monitor each character added to the document. See SciTEBase::CharAdded() in SciTEBase.cxx for an example of autocompletion.

- SCI_AUTOCSHOW(int lenEntered, const char - *list)
+ SCI_AUTOCSHOW(int lengthEntered, const char + *itemList)
SCI_AUTOCCANCEL
- SCI_AUTOCACTIVE
- SCI_AUTOCPOSSTART
+ SCI_AUTOCACTIVE → bool
+ SCI_AUTOCPOSSTART → position
SCI_AUTOCCOMPLETE
SCI_AUTOCSTOPS(<unused>, const char - *chars)
- SCI_AUTOCSETSEPARATOR(char - separator)
- SCI_AUTOCGETSEPARATOR
+ *characterSet)
+ SCI_AUTOCSETSEPARATOR(int + separatorCharacter)
+ SCI_AUTOCGETSEPARATOR → int
SCI_AUTOCSELECT(<unused>, const char *select)
- SCI_AUTOCGETCURRENT
- SCI_AUTOCGETCURRENTTEXT(<unused>, - char *text)
+ SCI_AUTOCGETCURRENT → int
+ SCI_AUTOCGETCURRENTTEXT(<unused>, char *text) → int
SCI_AUTOCSETCANCELATSTART(bool cancel)
- SCI_AUTOCGETCANCELATSTART
+ SCI_AUTOCGETCANCELATSTART → bool
SCI_AUTOCSETFILLUPS(<unused>, const char - *chars)
+ *characterSet)
SCI_AUTOCSETCHOOSESINGLE(bool chooseSingle)
- SCI_AUTOCGETCHOOSESINGLE
+ SCI_AUTOCGETCHOOSESINGLE → bool
SCI_AUTOCSETIGNORECASE(bool ignoreCase)
- SCI_AUTOCGETIGNORECASE
+ SCI_AUTOCGETIGNORECASE → bool
SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR(int behaviour)
- SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR
+ SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR → int
SCI_AUTOCSETMULTI(int multi)
- SCI_AUTOCGETMULTI
+ SCI_AUTOCGETMULTI → int
SCI_AUTOCSETORDER(int order)
- SCI_AUTOCGETORDER
+ SCI_AUTOCGETORDER → int
SCI_AUTOCSETAUTOHIDE(bool autoHide)
- SCI_AUTOCGETAUTOHIDE
+ SCI_AUTOCGETAUTOHIDE → bool
SCI_AUTOCSETDROPRESTOFWORD(bool dropRestOfWord)
- SCI_AUTOCGETDROPRESTOFWORD
+ SCI_AUTOCGETDROPRESTOFWORD → bool
SCI_REGISTERIMAGE(int type, const char *xpmData)
SCI_REGISTERRGBAIMAGE(int type, const char *pixels)
SCI_CLEARREGISTEREDIMAGES
- SCI_AUTOCSETTYPESEPARATOR(char separatorCharacter)
- SCI_AUTOCGETTYPESEPARATOR
+ SCI_AUTOCSETTYPESEPARATOR(int separatorCharacter)
+ SCI_AUTOCGETTYPESEPARATOR → int
SCI_AUTOCSETMAXHEIGHT(int rowCount)
- SCI_AUTOCGETMAXHEIGHT
+ SCI_AUTOCGETMAXHEIGHT → int
SCI_AUTOCSETMAXWIDTH(int characterCount)
- SCI_AUTOCGETMAXWIDTH
+ SCI_AUTOCGETMAXWIDTH → int
-

SCI_AUTOCSHOW(int lenEntered, const char *list)
- This message causes a list to be displayed. lenEntered is the number of - characters of the word already entered and list is the list of words separated by +

SCI_AUTOCSHOW(int lengthEntered, const char *itemList)
+ This message causes a list to be displayed. lengthEntered is the number of + characters of the word already entered and itemList is the list of words separated by separator characters. The initial separator character is a space but this can be set or got with SCI_AUTOCSETSEPARATOR and SCI_AUTOCSETORDER + Alternative handling of list order may be specified with SCI_AUTOCSETORDER

SCI_AUTOCCANCEL
@@ -4408,90 +4803,90 @@ struct Sci_TextToFind { autocompletion can be specified with SCI_AUTOCSTOPS.

-

SCI_AUTOCACTIVE
+

SCI_AUTOCACTIVE → bool
This message returns non-zero if there is an active autocompletion list and zero if there is not.

-

SCI_AUTOCPOSSTART
+

SCI_AUTOCPOSSTART → position
This returns the value of the current position when SCI_AUTOCSHOW started display of the list.

SCI_AUTOCCOMPLETE
This message triggers autocompletion. This has the same effect as the tab key.

-

SCI_AUTOCSTOPS(<unused>, const char *chars)
- The chars argument is a string containing a list of characters that will +

SCI_AUTOCSTOPS(<unused>, const char *characterSet)
+ The characterSet argument is a string containing a list of characters that will automatically cancel the autocompletion list. When you start the editor, this list is empty.

-

SCI_AUTOCSETSEPARATOR(char separator)
- SCI_AUTOCGETSEPARATOR
+

SCI_AUTOCSETSEPARATOR(int separatorCharacter)
+ SCI_AUTOCGETSEPARATOR → int
These two messages set and get the separator character used to separate words in the SCI_AUTOCSHOW list. The default is the space character.

SCI_AUTOCSELECT(<unused>, const char *select)
- SCI_AUTOCGETCURRENT
+ SCI_AUTOCGETCURRENT → int
This message selects an item in the autocompletion list. It searches the list of words for the - first that matches select. By default, comparisons are case sensitive, but you can + first that matches select. By default, comparisons are case sensitive, but you can change this with SCI_AUTOCSETIGNORECASE. The match is character - by character for the length of the select string. That is, if select is "Fred" it + by character for the length of the select string. That is, if select is "Fred" it will match "Frederick" if this is the first item in the list that begins with "Fred". If an item is found, it is selected. If the item is not found, the autocompletion list closes if auto-hide is true (see SCI_AUTOCSETAUTOHIDE).
The current selection index can be retrieved with SCI_AUTOCGETCURRENT.

-

SCI_AUTOCGETCURRENTTEXT(<unused>, char *text NUL-terminated)
+

SCI_AUTOCGETCURRENTTEXT(<unused>, char *text NUL-terminated) → int
This message retrieves the current selected text in the autocompletion list. Normally the SCN_AUTOCSELECTION notification is used instead.

-

The value is copied to the text buffer, returning the length (not including the +

The value is copied to the text buffer, returning the length (not including the terminating 0). If not found, an empty string is copied to the buffer and 0 is returned.

If the value argument is 0 then the length that should be allocated to store the value is returned; again, the terminating 0 is not included.

SCI_AUTOCSETCANCELATSTART(bool cancel)
- SCI_AUTOCGETCANCELATSTART
+ SCI_AUTOCGETCANCELATSTART → bool
The default behaviour is for the list to be cancelled if the caret moves to the location it was at when the list was displayed. By calling this message with a false argument, the list is not cancelled until the caret moves at least one character before the word being completed.

-

SCI_AUTOCSETFILLUPS(<unused>, const char *chars)
+

SCI_AUTOCSETFILLUPS(<unused>, const char *characterSet)
If a fillup character is typed with an autocompletion list active, the currently selected item in the list is added into the document, then the fillup character is added. Common fillup characters are '(', '[' and '.' but others are possible depending on the language. By default, no fillup characters are set.

SCI_AUTOCSETCHOOSESINGLE(bool chooseSingle)
- SCI_AUTOCGETCHOOSESINGLE
+ SCI_AUTOCGETCHOOSESINGLE → bool
If you use SCI_AUTOCSETCHOOSESINGLE(1) and a list has only one item, it is automatically added and no list is displayed. The default is to display the list even if there is only a single item.

SCI_AUTOCSETIGNORECASE(bool ignoreCase)
- SCI_AUTOCGETIGNORECASE
+ SCI_AUTOCGETIGNORECASE → bool
By default, matching of characters to list members is case sensitive. These messages let you set and get case sensitivity.

SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR(int behaviour)
- SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR
+ SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR → int
When autocompletion is set to ignore case (SCI_AUTOCSETIGNORECASE), by default it will nonetheless select the first list member that matches in a case sensitive way to entered characters. This corresponds to a behaviour property of SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE (0). If you want autocompletion to ignore case at all, choose SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE (1).

SCI_AUTOCSETMULTI(int multi)
- SCI_AUTOCGETMULTI
+ SCI_AUTOCGETMULTI → int
When autocompleting with multiple selections present, the autocompleted text can go into just the main selection with SC_MULTIAUTOC_ONCE (0) or into each selection with SC_MULTIAUTOC_EACH (1). The default is SC_MULTIAUTOC_ONCE.

SCI_AUTOCSETORDER(int order)
- SCI_AUTOCGETORDER
+ SCI_AUTOCGETORDER → int
The default setting SC_ORDER_PRESORTED (0) requires that the list be provided in alphabetical sorted order.

Sorting the list can be done by Scintilla instead of the application with SC_ORDER_PERFORMSORT (1). @@ -4499,29 +4894,29 @@ struct Sci_TextToFind {

Applications that wish to prioritize some values and show the list in order of priority instead of alphabetical order can use SC_ORDER_CUSTOM (2). - This requires extra processing in SCI_AUTOCSHOW to create a sorted index. + This requires extra processing in SCI_AUTOCSHOW to create a sorted index.

-

Setting the order should be done before calling SCI_AUTOCSHOW. +

Setting the order should be done before calling SCI_AUTOCSHOW.

SCI_AUTOCSETAUTOHIDE(bool autoHide)
- SCI_AUTOCGETAUTOHIDE
+ SCI_AUTOCGETAUTOHIDE → bool
By default, the list is cancelled if there are no viable matches (the user has typed characters that no longer match a list entry). If you want to keep displaying the original - list, set autoHide to false. This also effects autoHide
to false. This also effects SCI_AUTOCSELECT.

SCI_AUTOCSETDROPRESTOFWORD(bool dropRestOfWord)
- SCI_AUTOCGETDROPRESTOFWORD
+ SCI_AUTOCGETDROPRESTOFWORD → bool
When an item is selected, any word characters following the caret are first erased if - dropRestOfWord is set true. The default is false.

+ dropRestOfWord is set true. The default is false.

SCI_REGISTERIMAGE(int type, const char *xpmData)
SCI_REGISTERRGBAIMAGE(int type, const char *pixels)
SCI_CLEARREGISTEREDIMAGES
- SCI_AUTOCSETTYPESEPARATOR(char separatorCharacter)
- SCI_AUTOCGETTYPESEPARATOR
+ SCI_AUTOCSETTYPESEPARATOR(int separatorCharacter)
+ SCI_AUTOCGETTYPESEPARATOR → int
Autocompletion list items may display an image as well as text. Each image is first registered with an integer type. Then this integer is included in the text of the list separated by a '?' from the text. For example, @@ -4537,7 +4932,7 @@ struct Sci_TextToFind {

SCI_AUTOCSETMAXHEIGHT(int rowCount)
- SCI_AUTOCGETMAXHEIGHT
+ SCI_AUTOCGETMAXHEIGHT → int
Get or set the maximum number of rows that will be visible in an autocompletion list. If there are more rows in the list, then a vertical scrollbar is shown. The default is 5. @@ -4545,7 +4940,7 @@ struct Sci_TextToFind {

SCI_AUTOCSETMAXWIDTH(int characterCount)
- SCI_AUTOCGETMAXWIDTH
+ SCI_AUTOCGETMAXWIDTH → int
Get or set the maximum width of an autocompletion list expressed as the number of characters in the longest item that will be totally visible. If zero (the default) then the list's width is calculated to fit the item with the most characters. Any items that cannot be fully displayed within @@ -4558,24 +4953,26 @@ struct Sci_TextToFind { listed for autocompletion work on them; you cannot display a user list at the same time as an autocompletion list is active. They differ in the following respects:

+ SCI_USERLISTSHOW(int listType, const char *itemList)
+

o The SCI_AUTOCSETCHOOSESINGLE message has no effect.
o When the user makes a selection you are sent a SCN_USERLISTSELECTION notification message rather than SCN_AUTOCSELECTION.
+ href="#SCN_AUTOCSELECTION">SCN_AUTOCSELECTION
.

BEWARE: if you have set fillup characters or stop characters, these will still be active with the user list, and may result in items being selected or the user list cancelled due to the user typing into the editor.

-

SCI_USERLISTSHOW(int listType, const char *list)
- The listType parameter is returned to the container as the wParam +

SCI_USERLISTSHOW(int listType, const char *itemList)
+ The listType parameter is returned to the container as the wParam field of the SCNotification structure. It must be greater than 0 as this is how Scintilla tells the difference between an autocompletion list and a user list. If you have different types of list, for example a list of - buffers and a list of macros, you can use listType to tell which one has returned + buffers and a list of macros, you can use listType to tell which one has returned a selection.

Call tips

@@ -4586,14 +4983,12 @@ struct Sci_TextToFind { STYLE_DEFAULT. You can choose to use STYLE_CALLTIP to define the facename, size, foreground and background colours and character set with - SCI_CALLTIPUSESTYLE. + SCI_CALLTIPUSESTYLE. This also enables support for Tab characters. There is some interaction between call tips and autocompletion lists in that showing a call tip cancels any active autocompletion list, and vice versa.

-

Call tips are not implemented on Qt.

-

Call tips can highlight part of the text within them. You could use this to highlight the current argument to a function by counting the number of commas (or whatever separator your language uses). See SciTEBase::CharAdded() in SciTEBase.cxx for an @@ -4613,34 +5008,34 @@ struct Sci_TextToFind { href="#SCN_DWELLEND">SCN_DWELLEND. This method could be used in a debugger to give the value of a variable, or during editing to give information about the word under the pointer.

- SCI_CALLTIPSHOW(int posStart, const char + SCI_CALLTIPSHOW(int pos, const char *definition)
SCI_CALLTIPCANCEL
- SCI_CALLTIPACTIVE
- SCI_CALLTIPPOSSTART
+ SCI_CALLTIPACTIVE → bool
+ SCI_CALLTIPPOSSTART → position
SCI_CALLTIPSETPOSSTART(int posStart)
SCI_CALLTIPSETHLT(int highlightStart, int highlightEnd)
- SCI_CALLTIPSETBACK(int colour)
- SCI_CALLTIPSETFORE(int colour)
- SCI_CALLTIPSETFOREHLT(int colour)
- SCI_CALLTIPUSESTYLE(int tabsize)
+ SCI_CALLTIPSETBACK(colour back)
+ SCI_CALLTIPSETFORE(colour fore)
+ SCI_CALLTIPSETFOREHLT(colour fore)
+ SCI_CALLTIPUSESTYLE(int tabSize)
SCI_CALLTIPSETPOSITION(bool above)
-

SCI_CALLTIPSHOW(int posStart, const char *definition)
+

SCI_CALLTIPSHOW(int pos, const char *definition)
This message starts the process by displaying the call tip window. If a call tip is already active, this has no effect.
- posStart is the position in the document at which to align the call tip. The call + pos is the position in the document at which to align the call tip. The call tip text is aligned to start 1 line below this character unless you have included up and/or down arrows in the call tip text in which case the tip is aligned to the right-hand edge of the rightmost arrow. The assumption is that you will start the text with something like "\001 1 of 3 \002".
- definition is the call tip text. This can contain multiple lines separated by + definition is the call tip text. This can contain multiple lines separated by '\n' (Line Feed, ASCII code 10) characters. Do not include '\r' (Carriage Return, ASCII code 13), as this will most likely print as an empty box. '\t' (Tab, ASCII code 9) is supported if you set a tabsize with - SCI_CALLTIPUSESTYLE.
+ SCI_CALLTIPUSESTYLE.
The position of the caret is remembered here so that the call tip can be cancelled automatically if subsequent deletion moves the caret before this position.

@@ -4650,19 +5045,20 @@ struct Sci_TextToFind { function. Call tips are cancelled if you delete back past the position where the caret was when the tip was triggered.

-

SCI_CALLTIPACTIVE
+

SCI_CALLTIPACTIVE → bool
This returns 1 if a call tip is active and 0 if it is not active.

-

SCI_CALLTIPPOSSTART
+

SCI_CALLTIPPOSSTART → position
SCI_CALLTIPSETPOSSTART(int posStart)
This message returns or sets the value of the current position when SCI_CALLTIPSHOW started to display the tip.

-

SCI_CALLTIPSETHLT(int hlStart, int hlEnd)
+

SCI_CALLTIPSETHLT(int highlightStart, int highlightEnd)
This sets the region of the call tips text to display in a highlighted style. - hlStart is the zero-based index into the string of the first character to - highlight and hlEnd is the index of the first character after the highlight. - hlEnd must be greater than hlStart; hlEnd-hlStart is the + highlightStart is the zero-based index into the string of the first character to + highlight and highlightEnd is the index of the first character after the highlight. + highlightEnd must be greater than highlightStart; + highlightEnd-highlightStart is the number of characters to highlight. Highlights can extend over line ends if this is required.

@@ -4673,23 +5069,23 @@ struct Sci_TextToFind { SCI_CALLTIPSETFOREHLT.

-

SCI_CALLTIPSETBACK(int colour)
+

SCI_CALLTIPSETBACK(colour back)
The background colour of call tips can be set with this message; the default colour is white. It is not a good idea to set a dark colour as the background as the default colour for normal calltip text is mid grey and the default colour for highlighted text is dark blue. This also sets the background colour of STYLE_CALLTIP.

-

SCI_CALLTIPSETFORE(int colour)
+

SCI_CALLTIPSETFORE(colour fore)
The colour of call tip text can be set with this message; the default colour is mid grey. This also sets the foreground colour of STYLE_CALLTIP.

-

SCI_CALLTIPSETFOREHLT(int colour)
+

SCI_CALLTIPSETFOREHLT(colour fore)
The colour of highlighted call tip text can be set with this message; the default colour is dark blue.

-

SCI_CALLTIPUSESTYLE(int tabsize)
+

SCI_CALLTIPUSESTYLE(int tabSize)
This message changes the style used for call tips from STYLE_DEFAULT to - STYLE_CALLTIP and sets a tab size in screen pixels. If tabsize is + STYLE_CALLTIP and sets a tab size in screen pixels. If tabsize is less than 1, Tab characters are not treated specially. Once this call has been used, the call tip foreground and background colours are also taken from the style.

@@ -4896,15 +5292,18 @@ struct Sci_TextToFind { SCI_DELLINERIGHT SCI_LINEDELETE + + SCI_LINECUT - SCI_LINECUT SCI_LINECOPY SCI_LINETRANSPOSE + SCI_LINEREVERSE + SCI_LINEDUPLICATE @@ -4957,6 +5356,9 @@ struct Sci_TextToFind {

The SCI_WORDPART* commands are used to move between word segments marked by capitalisation (aCamelCaseIdentifier) or underscores (an_under_bar_ident).

+

The SCI_WORD[LEFT|RIGHT]END* commands are + similar to SCI_WORD[LEFT|RIGHT]* but move between word ends instead of word starts.

+

The SCI_HOME* commands move the caret to the start of the line, while the SCI_VCHOME* commands move the caret to the first non-blank character of the line (ie. just after the indentation) unless it is already there; in this case, it acts as SCI_HOME*.

@@ -5014,16 +5416,18 @@ struct Sci_TextToFind { SCK_WIN.

The modifiers are a combination of zero or more of SCMOD_ALT, - SCMOD_CTRL, SCMOD_SHIFT, and SCMOD_META. + SCMOD_CTRL, SCMOD_SHIFT, + SCMOD_META, and SCMOD_SUPER. On OS X, the Command key is mapped to SCMOD_CTRL and the Control key to SCMOD_META. + SCMOD_SUPER is only available on GTK which is commonly the Windows key. If you are building a table, you might want to use SCMOD_NORM, which has the value 0, to mean no modifiers.

SCI_ASSIGNCMDKEY(int keyDefinition, int sciCommand)
This assigns the given key definition to a Scintilla command identified by - sciCommand. sciCommand can be any SCI_* command that has + sciCommand. sciCommand can be any SCI_* command that has no arguments.

SCI_CLEARCMDKEY(int Popup edit menu -

SCI_USEPOPUP(bool bEnablePopup)
+
SCI_USEPOPUP(int popUpMode)
+
+ +

SCI_USEPOPUP(int popUpMode)
Clicking the wrong button on the mouse pops up a short default editing menu. This may be - turned off with SCI_USEPOPUP(0). If you turn it off, context menu commands (in + turned off with SCI_USEPOPUP(SC_POPUP_NEVER). If you turn it off, context menu commands (in Windows, WM_CONTEXTMENU) will not be handled by Scintilla, so the parent of the Scintilla window will have the opportunity to handle the message.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolValueMeaning
SC_POPUP_NEVER0Never show default editing menu.
SC_POPUP_ALL1Show default editing menu if clicking on scintilla.
SC_POPUP_TEXT2Show default editing menu only if clicking on text area.
+

Macro recording

Start and stop macro recording mode. In macro recording mode, actions are reported to the @@ -5054,6 +5504,10 @@ struct Sci_TextToFind { notifications. It is then up to the container to record these actions for future replay.

+ SCI_STARTRECORD
+ SCI_STOPRECORD
+
+

SCI_STARTRECORD
SCI_STOPRECORD
These two messages turn macro recording on and off.

@@ -5066,28 +5520,27 @@ struct Sci_TextToFind { removed and the selection and caret are hidden.

Different platforms use different display surface ID types to print on. On Windows, these are - HDCs., on GTK+ 3.x cairo_t *, + HDCs., on GTK 3.x cairo_t *, and on Cocoa CGContextRef is used.

- SCI_FORMATRANGE(bool bDraw, Sci_RangeToFormat - *pfr)
+ SCI_FORMATRANGE(bool draw, Sci_RangeToFormat *fr) → position
SCI_SETPRINTMAGNIFICATION(int magnification)
- SCI_GETPRINTMAGNIFICATION
+ SCI_GETPRINTMAGNIFICATION → int
SCI_SETPRINTCOLOURMODE(int mode)
- SCI_GETPRINTCOLOURMODE
- SCI_SETPRINTWRAPMODE
- SCI_GETPRINTWRAPMODE
+ SCI_GETPRINTCOLOURMODE → int
+ SCI_SETPRINTWRAPMODE(int wrapMode)
+ SCI_GETPRINTWRAPMODE → int
-

SCI_FORMATRANGE(bool bDraw, Sci_RangeToFormat *pfr)
+

SCI_FORMATRANGE(bool draw, Sci_RangeToFormat *fr) → position
This call renders a range of text into a device context. If you use this for printing, you will probably want to arrange a page header and footer; Scintilla does not do this for you. See SciTEWin::Print() in SciTEWinDlg.cxx for an example. Each use of this message renders a range of text into a rectangular area and returns the position in the document of the next character to print.

-

bDraw controls if any output is done. Set this to false if you are paginating +

draw controls if any output is done. Set this to false if you are paginating (for example, if you use this with MFC you will need to paginate in OnBeginPrinting() before you output each page.

@@ -5113,12 +5566,12 @@ struct Sci_RangeToFormat {
      chrg.cpMin and chrg.cpMax define the start position and maximum
     position of characters to output. All of each line within this character range is drawn.

-

On Cocoa, the surface IDs for printing (bDraw=1) should be the graphics port of the current context +

On Cocoa, the surface IDs for printing (draw=1) should be the graphics port of the current context ((CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]) when the view's drawRect method is called. - The Surface IDs are not really used for measurement (bDraw=0) but can be set + The Surface IDs are not really used for measurement (draw=0) but can be set to a bitmap context (created with CGBitmapContextCreate) to avoid runtime warnings.

-

On GTK+, the surface IDs to use can be found from the printing context with +

On GTK, the surface IDs to use can be found from the printing context with gtk_print_context_get_cairo_context(context).

chrg.cpMin and chrg.cpMax define the start position and maximum @@ -5131,20 +5584,20 @@ struct Sci_RangeToFormat { area, header and footer code.

SCI_SETPRINTMAGNIFICATION(int magnification)
- SCI_GETPRINTMAGNIFICATION
+ SCI_GETPRINTMAGNIFICATION → int
SCI_GETPRINTMAGNIFICATION lets you to print at a different size than the screen - font. magnification is the number of points to add to the size of each screen + font. magnification is the number of points to add to the size of each screen font. A value of -3 or -4 gives reasonably small print. You can get this value with SCI_GETPRINTMAGNIFICATION.

SCI_SETPRINTCOLOURMODE(int mode)
- SCI_GETPRINTCOLOURMODE
+ SCI_GETPRINTCOLOURMODE → int
These two messages set and get the method used to render coloured text on a printer that is probably using white paper. It is especially important to consider the treatment of colour if you use a dark or black screen background. Printing white on black uses up toner and ink very many times faster than the other way around. You can set the mode to one of:

- +
@@ -5161,7 +5614,8 @@ struct Sci_RangeToFormat { - + @@ -5194,15 +5648,25 @@ struct Sci_RangeToFormat { - + + + + + + + + + +
Symbol0Print using the current screen colours. This is the default.Print using the current screen colours with the exception of line number margins which print on a white background. + This is the default.
4Everything prints in its own colour on a white background except that line numbers - use their own background colour.Everything prints in its own foreground colour but all styles up to and including STYLE_LINENUMBER will print + on a white background.
SC_PRINT_SCREENCOLOURS5Print using the current screen colours for both foreground and background. + This is the only mode that does not set the background colour of the line number margin to white.

SCI_SETPRINTWRAPMODE(int wrapMode)
- SCI_GETPRINTWRAPMODE
- These two functions get and set the printer wrap mode. wrapMode can be + SCI_GETPRINTWRAPMODE → int
+ These two functions get and set the printer wrap mode. wrapMode can be set to SC_WRAP_NONE (0), SC_WRAP_WORD (1) or SC_WRAP_CHAR (2). The default is SC_WRAP_WORD, which wraps printed output so that all characters fit @@ -5216,11 +5680,11 @@ struct Sci_RangeToFormat { between words.

Direct access

- SCI_GETDIRECTFUNCTION
- SCI_GETDIRECTPOINTER
- SCI_GETCHARACTERPOINTER
- SCI_GETRANGEPOINTER(int position, int rangeLength)
- SCI_GETGAPPOSITION
+ SCI_GETDIRECTFUNCTION → int
+ SCI_GETDIRECTPOINTER → int
+ SCI_GETCHARACTERPOINTER → int
+ SCI_GETRANGEPOINTER(int start, int lengthRange) → int
+ SCI_GETGAPPOSITION → position

On Windows, the message-passing scheme used to communicate between the container and @@ -5240,14 +5704,14 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

SciFnDirect, sptr_t and uptr_t are declared in - Scintilla.h. hSciWnd is the window handle returned when you created + Scintilla.h. hSciWnd is the window handle returned when you created the Scintilla window.

While faster, this direct calling will cause problems if performed from a different thread to the native thread of the Scintilla window in which case SendMessage(hSciWnd, SCI_*, wParam, lParam) should be used to synchronize with the window's thread.

-

This feature also works on GTK+ but has no significant impact on speed.

+

This feature also works on GTK but has no significant impact on speed.

From version 1.47 on Windows, Scintilla exports a function called Scintilla_DirectFunction that can be used the same as the function returned by @@ -5255,19 +5719,19 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ SCI_GETDIRECTFUNCTION and the need to call Scintilla indirectly via the function pointer.

-

SCI_GETDIRECTFUNCTION
+

SCI_GETDIRECTFUNCTION → int
This message returns the address of the function to call to handle Scintilla messages without the overhead of passing through the Windows messaging system. You need only call this once, regardless of the number of Scintilla windows you create.

-

SCI_GETDIRECTPOINTER
+

SCI_GETDIRECTPOINTER → int
This returns a pointer to data that identifies which Scintilla window is in use. You must call this once for each Scintilla window you create. When you call the direct function, you must pass in the direct pointer associated with the target window.

-

SCI_GETCHARACTERPOINTER
- SCI_GETRANGEPOINTER(int position, int rangeLength)
- SCI_GETGAPPOSITION
+

SCI_GETCHARACTERPOINTER → int
+ SCI_GETRANGEPOINTER(int start, int lengthRange) → int
+ SCI_GETGAPPOSITION → position
Grant temporary direct read-only access to the memory used by Scintilla to store the document.

SCI_GETCHARACTERPOINTER moves the gap within Scintilla so that the @@ -5308,60 +5772,123 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ documents in a single Scintilla window and so you can display a single document in multiple windows (for use with splitter windows).

-

Although these messages use document *pDoc, to ensure compatibility with future - releases of Scintilla you should treat pDoc as an opaque void*. That +

Although these messages use document *doc, to ensure compatibility with future + releases of Scintilla you should treat doc as an opaque void*. That is, you can use and store the pointer as described in this section but you should not dereference it.

- SCI_GETDOCPOINTER
+ SCI_GETDOCPOINTER → document *
SCI_SETDOCPOINTER(<unused>, document - *pDoc)
- SCI_CREATEDOCUMENT
+ *doc)
+ SCI_CREATEDOCUMENT(int bytes, int documentOptions) → document *
SCI_ADDREFDOCUMENT(<unused>, document - *pDoc)
+ *doc)
SCI_RELEASEDOCUMENT(<unused>, document - *pDoc)
+ *doc)
+ SCI_GETDOCUMENTOPTIONS → int
-

SCI_GETDOCPOINTER
+

SCI_GETDOCPOINTER → document *
This returns a pointer to the document currently in use by the window. It has no other effect.

-

SCI_SETDOCPOINTER(<unused>, document *pDoc)
+

SCI_SETDOCPOINTER(<unused>, document *doc)
This message does the following:
1. It removes the current window from the list held by the current document.
2. It reduces the reference count of the current document by 1.
3. If the reference count reaches 0, the document is deleted.
- 4. pDoc is set as the new document for the window.
- 5. If pDoc was 0, a new, empty document is created and attached to the + 4. doc is set as the new document for the window.
+ 5. If doc was 0, a new, empty document is created and attached to the window.
- 6. If pDoc was not 0, its reference count is increased by 1.

+ 6. If doc was not 0, its reference count is increased by 1.

-

SCI_CREATEDOCUMENT
+

SCI_CREATEDOCUMENT(int bytes, int documentOptions) → document *
This message creates a new, empty document and returns a pointer to it. This document is not - selected into the editor and starts with a reference count of 1. This means that you have - ownership of it and must either reduce its reference count by 1 after using + selected into the editor and starts with a reference count of 1. This means that you have + ownership of it and must either reduce its reference count by 1 after using SCI_SETDOCPOINTER so that the Scintilla window owns it or you must make sure that - you reduce the reference count by 1 with SCI_RELEASEDOCUMENT before you close the - application to avoid memory leaks.

+ you reduce the reference count by 1 with SCI_RELEASEDOCUMENT before you close the + application to avoid memory leaks. The bytes argument determines + the initial memory allocation for the document as it is more efficient + to allocate once rather than rely on the buffer growing as data is added. + If SCI_CREATEDOCUMENT fails then 0 is returned.

-

SCI_ADDREFDOCUMENT(<unused>, document *pDoc)
+

The documentOptions argument + chooses between different document capabilities which affect memory allocation and performance with + SC_DOCUMENTOPTION_DEFAULT (0) choosing standard options. + SC_DOCUMENTOPTION_STYLES_NONE (0x1) stops allocation of memory to style characters + which saves significant memory, often 40% with the whole document treated as being style 0. + Lexers may still produce visual styling by using indicators. + SC_DOCUMENTOPTION_TEXT_LARGE (0x100) accomodates documents larger than 2 GigaBytes + in 64-bit executables. +

+ +

With SC_DOCUMENTOPTION_STYLES_NONE, lexers are still active and may display + indicators. Some may produce folding information althoough most require lexical styles to correctly determine folding. + Its often more efficient to set the null lexer SCLEX_NULL so no lexer is run. +

+ +

The SC_DOCUMENTOPTION_TEXT_LARGE option is experimental and has not been + thoroughly tested. Lexers may fail or hang when lexing past 2GB or 4GB. + Applications using this option should be tested to ensure the option works in their circumstances and each lexer + included should also be tested with documents larger than 4GB. + For many applications lexing documents larger than 4GB will be too sluggish so SC_DOCUMENTOPTION_STYLES_NONE + and the null lexer SCLEX_NULL can be used. Another approach is to turn on idle styling with + SCI_SETIDLESTYLING. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolValueEffect
SC_DOCUMENTOPTION_DEFAULT0Standard behaviour
SC_DOCUMENTOPTION_STYLES_NONE0x1Stop allocation of memory for styles and treat all text as style 0.
SC_DOCUMENTOPTION_TEXT_LARGE0x100Allow document to be larger than 2 GB.
+ +

SCI_ADDREFDOCUMENT(<unused>, document *doc)
This increases the reference count of a document by 1. If you want to replace the current document in the Scintilla window and take ownership of the current document, for example if you are editing many documents in one window, do the following:
1. Use SCI_GETDOCPOINTER to get a pointer to the document, - pDoc.
- 2. Use SCI_ADDREFDOCUMENT(0, pDoc) to increment the reference count.
- 3. Use SCI_SETDOCPOINTER(0, pNewDoc) to set a different document or + doc.
+ 2. Use SCI_ADDREFDOCUMENT(0, doc) to increment the reference count.
+ 3. Use SCI_SETDOCPOINTER(0, docNew) to set a different document or SCI_SETDOCPOINTER(0, 0) to set a new, empty document.

-

SCI_RELEASEDOCUMENT(<unused>, document *pDoc)
- This message reduces the reference count of the document identified by pDoc. pDoc +

SCI_RELEASEDOCUMENT(<unused>, document *doc)
+ This message reduces the reference count of the document identified by doc. doc must be the result of SCI_GETDOCPOINTER or SCI_CREATEDOCUMENT and must point at a document that still exists. If you call this on a document with a reference count of 1 that is still attached to a Scintilla window, bad things will happen. To keep the world spinning in its orbit you must balance each call to SCI_CREATEDOCUMENT or SCI_ADDREFDOCUMENT with a call to SCI_RELEASEDOCUMENT.

+

SCI_GETDOCUMENTOPTIONS → int
+ Returns the options that were used to create the document.

+

Background loading and saving

To ensure a responsive user interface, applications may decide to load and save documents using a separate thread @@ -5369,19 +5896,25 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

Loading in the background

+ SCI_CREATELOADER(int bytes, int documentOptions) → int
+
+

An application can load all of a file into a buffer it allocates on a background thread and then add the data in that buffer into a Scintilla document on the user interface thread. That technique uses extra memory to store a complete copy of the file and also means that the time that Scintilla takes to perform initial line end discovery blocks the user interface.

To avoid these issues, a loader object may be created and used to load the file. The loader object supports the ILoader interface.

-

SCI_CREATELOADER(int bytes)
+

SCI_CREATELOADER(int bytes, int documentOptions) → int
Create an object that supports the ILoader interface which can be used to load data and then be turned into a Scintilla document object for attachment to a view object. - The bytes argument determines the initial memory allocation for the document as it is more efficient + The bytes argument determines the initial memory allocation for the document as it is more efficient to allocate once rather than rely on the buffer growing as data is added. If SCI_CREATELOADER fails then 0 is returned.

+

The documentOptions argument + is described in the SCI_CREATEDOCUMENT section.

+

ILoader

@@ -5389,7 +5922,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ public:
        virtual int SCI_METHOD Release() = 0;
        // Returns a status code from SC_STATUS_*
-        virtual int SCI_METHOD AddData(char *data, int length) = 0;
+        virtual int SCI_METHOD AddData(const char *data, Sci_Position length) = 0;
        virtual void * SCI_METHOD ConvertToDocument() = 0;
};
@@ -5398,16 +5931,17 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ AddData will return SC_STATUS_OK unless a failure, such as memory exhaustion occurs. If a failure occurs in AddData or in a file reading call then loading can be abandoned and the loader released with the Release call. - When the whole file has been read, the ConvertToDocument method should be called to produce a Scintilla - document pointer which can be used in the same way as a document pointer returned from - SCI_CREATEDOCUMENT. + When the whole file has been read, ConvertToDocument should be called to produce a Scintilla + document pointer. The newly created document will have a reference count of 1 in the same way as a document pointer + returned from + SCI_CREATEDOCUMENT. There is no need to call Release after ConvertToDocument.

Saving in the background

An application that wants to save in the background should lock the document with SCI_SETREADONLY(1) to prevent modifications and retrieve a pointer to the unified document contents with - SCI_GETCHARACTERPOINTER. + SCI_GETCHARACTERPOINTER. The buffer of a locked document will not move so the pointer is valid until the application calls SCI_SETREADONLY(0).

If the user tries to performs a modification while the document is locked then a "fold" property should be set to "1" with SCI_SETPROPERTY("fold", "1") to enable folding.

- SCI_VISIBLEFROMDOCLINE(int - docLine)
- SCI_DOCLINEFROMVISIBLE(int - displayLine)
+ SCI_VISIBLEFROMDOCLINE(int docLine) → int
+ SCI_DOCLINEFROMVISIBLE(int displayLine) → int
SCI_SHOWLINES(int lineStart, int lineEnd)
SCI_HIDELINES(int lineStart, int lineEnd)
- SCI_GETLINEVISIBLE(int line)
- SCI_GETALLLINESVISIBLE
+ SCI_GETLINEVISIBLE(int line) → bool
+ SCI_GETALLLINESVISIBLE → bool
SCI_SETFOLDLEVEL(int line, int level)
- SCI_GETFOLDLEVEL(int line)
+ SCI_GETFOLDLEVEL(int line) → int
SCI_SETAUTOMATICFOLD(int automaticFold)
- SCI_GETAUTOMATICFOLD
+ SCI_GETAUTOMATICFOLD → int
SCI_SETFOLDFLAGS(int flags)
- SCI_GETLASTCHILD(int line, int level)
- SCI_GETFOLDPARENT(int line)
+ SCI_GETLASTCHILD(int line, int level) → int
+ SCI_GETFOLDPARENT(int line) → int
SCI_SETFOLDEXPANDED(int line, bool expanded)
- SCI_GETFOLDEXPANDED(int line)
- SCI_CONTRACTEDFOLDNEXT(int lineStart)
+ SCI_GETFOLDEXPANDED(int line) → bool
+ SCI_CONTRACTEDFOLDNEXT(int lineStart) → int
SCI_TOGGLEFOLD(int line)
+ SCI_TOGGLEFOLDSHOWTEXT(int line, const char *text)
+ SCI_FOLDDISPLAYTEXTSETSTYLE(int style)
+ SCI_FOLDDISPLAYTEXTGETSTYLE → int
+ SCI_SETDEFAULTFOLDDISPLAYTEXT(<unused>, const char *text)
+ SCI_GETDEFAULTFOLDDISPLAYTEXT(<unused>, char *text) → int
SCI_FOLDLINE(int line, int action)
SCI_FOLDCHILDREN(int line, int action)
SCI_FOLDALL(int action)
@@ -5461,30 +5998,30 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ line)
-

SCI_VISIBLEFROMDOCLINE(int docLine)
+

SCI_VISIBLEFROMDOCLINE(int docLine) → int
When some lines are hidden and/or annotations are displayed, then a particular line in the document may be displayed at a different position to its document position. If no lines are hidden and there are no annotations, this message returns - docLine. Otherwise, this returns the display line (counting the very first visible + docLine. Otherwise, this returns the display line (counting the very first visible line as 0). The display line of an invisible line is the same as the previous visible line. The display line number of the first line in the document is 0. If lines are hidden and - docLine is outside the range of lines in the document, the return value is -1. + docLine is outside the range of lines in the document, the return value is -1. Lines can occupy more than one display line if they wrap.

-

SCI_DOCLINEFROMVISIBLE(int displayLine)
+

SCI_DOCLINEFROMVISIBLE(int displayLine) → int
When some lines are hidden and/or annotations are displayed, then a particular line in the document may be displayed at a different position to its document position. This message returns the document line number that corresponds to a display line (counting the display line of the first line in the document as - 0). If displayLine is less than or equal to 0, the result is 0. If - displayLine is greater than or equal to the number of displayed lines, the result + 0). If displayLine is less than or equal to 0, the result is 0. If + displayLine is greater than or equal to the number of displayed lines, the result is the number of lines in the document.

SCI_SHOWLINES(int lineStart, int lineEnd)
SCI_HIDELINES(int lineStart, int lineEnd)
- SCI_GETLINEVISIBLE(int line)
- SCI_GETALLLINESVISIBLE
+ SCI_GETLINEVISIBLE(int line) → bool
+ SCI_GETALLLINESVISIBLE → bool
The first two messages mark a range of lines as visible or invisible and then redraw the display. SCI_GETLINEVISIBLE reports on the visible state of a line and returns 1 if it is @@ -5495,11 +6032,11 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ flags. The first line can not be hidden.

SCI_SETFOLDLEVEL(int line, int level)
- SCI_GETFOLDLEVEL(int line)
+ SCI_GETFOLDLEVEL(int line) → int
These two messages set and get a 32-bit value that contains the fold level of a line and some flags associated with folding. The fold level is a number in the range 0 to - SC_FOLDLEVELNUMBERMASK (4095). However, the initial fold level is set to - SC_FOLDLEVELBASE (1024) to allow unsigned arithmetic on folding levels. There are + SC_FOLDLEVELNUMBERMASK (0x0FFF). However, the initial fold level is set to + SC_FOLDLEVELBASE (0x400) to allow unsigned arithmetic on folding levels. There are two addition flag bits. SC_FOLDLEVELWHITEFLAG indicates that the line is blank and allows it to be treated slightly different then its level may indicate. For example, blank lines should generally not be fold points and will be considered part of the preceding section even though @@ -5521,10 +6058,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ In addition to showing markers in the folding margin, you can indicate folds to the user by drawing lines in the text area. The lines are drawn in the foreground colour set for STYLE_DEFAULT. Bits set in - flags determine where folding lines are drawn:
+ flags determine where folding lines are drawn:

- +
@@ -5588,28 +6125,73 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

This message causes the display to redraw.

-

SCI_GETLASTCHILD(int startLine, int level)
- This message searches for the next line after startLine, that has a folding level - that is less than or equal to level and then returns the previous line number. If - you set level to -1, level is set to the folding level of line - startLine. If from is a fold point, SCI_GETLASTCHILD(from, +

SCI_GETLASTCHILD(int line, int level) → int
+ This message searches for the next line after line, that has a folding level + that is less than or equal to level and then returns the previous line number. If + you set level to -1, level is set to the folding level of line + line. If from is a fold point, SCI_GETLASTCHILD(from, -1) returns the last line that would be in made visible or hidden by toggling the fold state.

-

SCI_GETFOLDPARENT(int startLine)
- This message returns the line number of the first line before startLine that is +

SCI_GETFOLDPARENT(int line) → int
+ This message returns the line number of the first line before line that is marked as a fold point with SC_FOLDLEVELHEADERFLAG and has a fold level less than - the startLine. If no line is found, or if the header flags and fold levels are + the line. If no line is found, or if the header flags and fold levels are inconsistent, the return value is -1.

SCI_TOGGLEFOLD(int line)
+ SCI_TOGGLEFOLDSHOWTEXT(int line, const char *text)
Each fold point may be either expanded, displaying all its child lines, or contracted, hiding - all the child lines. This message toggles the folding state of the given line as long as it has - the SC_FOLDLEVELHEADERFLAG set. This message takes care of folding or expanding + all the child lines. These messages toggle the folding state of the given line as long as it has + the SC_FOLDLEVELHEADERFLAG set. These messages take care of folding or expanding all the lines that depend on the line. The display updates after this message.

+

An optional text tag may be shown to the right of the folded text with the + text argument to + SCI_TOGGLEFOLDSHOWTEXT. + The default text for all header lines can be set with SCI_SETDEFAULTFOLDDISPLAYTEXT. + The text is drawn with the + STYLE_FOLDDISPLAYTEXT style.

+ +

SCI_FOLDDISPLAYTEXTSETSTYLE(int style)
+ SCI_FOLDDISPLAYTEXTGETSTYLE → int
+ These message changes the appearance of fold text tags.

+
Symbol
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolValueEffect
SC_FOLDDISPLAYTEXT_HIDDEN0Do not display the text tags. This is the default.
SC_FOLDDISPLAYTEXT_STANDARD1Display the text tags.
SC_FOLDDISPLAYTEXT_BOXED2Display the text tags with a box drawn around them.
+ +

SCI_SETDEFAULTFOLDDISPLAYTEXT(<unused>, const char *text)
+ SCI_GETDEFAULTFOLDDISPLAYTEXT(<unused>, char *text) → int
+ These messages set and get the default text displayed at the right of the folded text.

SCI_SETFOLDEXPANDED(int line, bool expanded)
- SCI_GETFOLDEXPANDED(int line)
+ SCI_GETFOLDEXPANDED(int line) → bool
These messages set and get the expanded state of a single line. The set message has no effect on the visible state of the line or any lines that depend on it. It does change the markers in the folding margin. If you ask for the expansion state of a line that is outside the document, @@ -5631,7 +6213,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

To affect the entire document call SCI_FOLDALL. With SC_FOLDACTION_TOGGLE the first fold header in the document is examined to decide whether to expand or contract.

- +
@@ -5671,9 +6253,9 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

SCI_SETAUTOMATICFOLD(int automaticFold)
- SCI_GETAUTOMATICFOLD
+ SCI_GETAUTOMATICFOLD → int
Instead of implementing all the logic for handling folding in the container, Scintilla can provide behaviour - that is adequate for many applications. The automaticFold argument is a bit set defining + that is adequate for many applications. The automaticFold argument is a bit set defining which of the 3 pieces of folding implementation should be enabled. Most applications should be able to use the SC_AUTOMATICFOLD_SHOW and SC_AUTOMATICFOLD_CHANGE flags unless they wish to implement quite different behaviour such as defining their own fold structure. @@ -5681,7 +6263,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ like to add or change click behaviour such as showing method headers only when Shift+Alt is used in conjunction with a click.

-
Symbol
+
@@ -5716,11 +6298,11 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
Symbol
-

SCI_CONTRACTEDFOLDNEXT(int lineStart)
+

SCI_CONTRACTEDFOLDNEXT(int lineStart) → int
Search efficiently for lines that are contracted fold headers. This is useful when saving the user's folding when switching documents or saving folding with a file. - The search starts at line number lineStart and continues forwards to the end of the file. - lineStart is returned if it is a contracted fold header otherwise the next contracted + The search starts at line number lineStart and continues forwards to the end of the file. + lineStart is returned if it is a contracted fold header otherwise the next contracted fold header is returned. If there are no more contracted fold headers then -1 is returned.

SCI_ENSUREVISIBLE(int line)
@@ -5734,22 +6316,22 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

Line wrapping

SCI_SETWRAPMODE(int wrapMode)
- SCI_GETWRAPMODE
+ SCI_GETWRAPMODE → int
SCI_SETWRAPVISUALFLAGS(int wrapVisualFlags)
- SCI_GETWRAPVISUALFLAGS
+ SCI_GETWRAPVISUALFLAGS → int
SCI_SETWRAPVISUALFLAGSLOCATION(int wrapVisualFlagsLocation)
- SCI_GETWRAPVISUALFLAGSLOCATION
- SCI_SETWRAPINDENTMODE(int indentMode)
- SCI_GETWRAPINDENTMODE
+ SCI_GETWRAPVISUALFLAGSLOCATION → int
+ SCI_SETWRAPINDENTMODE(int wrapIndentMode)
+ SCI_GETWRAPINDENTMODE → int
SCI_SETWRAPSTARTINDENT(int indent)
- SCI_GETWRAPSTARTINDENT
+ SCI_GETWRAPSTARTINDENT → int
SCI_SETLAYOUTCACHE(int cacheMode)
- SCI_GETLAYOUTCACHE
+ SCI_GETLAYOUTCACHE → int
SCI_SETPOSITIONCACHE(int size)
- SCI_GETPOSITIONCACHE
+ SCI_GETPOSITIONCACHE → int
SCI_LINESSPLIT(int pixelWidth)
SCI_LINESJOIN
- SCI_WRAPCOUNT(int docLine)
+ SCI_WRAPCOUNT(int docLine) → int

By default, Scintilla does not wrap lines of text. If you enable line wrapping, lines wider @@ -5783,7 +6365,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ SCN_PAINTED notification.

SCI_SETWRAPMODE(int wrapMode)
- SCI_GETWRAPMODE
+ SCI_GETWRAPMODE → int
Set wrapMode to SC_WRAP_WORD (1) to enable wrapping on word or style boundaries, SC_WRAP_CHAR (2) to enable wrapping between any characters, SC_WRAP_WHITESPACE (3) to enable @@ -5794,11 +6376,11 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

SCI_SETWRAPVISUALFLAGS(int wrapVisualFlags)
- SCI_GETWRAPVISUALFLAGS
+ SCI_GETWRAPVISUALFLAGS → int
You can enable the drawing of visual flags to indicate a line is wrapped. Bits set in wrapVisualFlags determine which visual flags are drawn.

- +
@@ -5837,12 +6419,12 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
Symbol

SCI_SETWRAPVISUALFLAGSLOCATION(int wrapVisualFlagsLocation)
- SCI_GETWRAPVISUALFLAGSLOCATION
+ SCI_GETWRAPVISUALFLAGSLOCATION → int
You can set whether the visual flags to indicate a line is wrapped are drawn near the border or near the text. Bits set in wrapVisualFlagsLocation set the location to near the text for the corresponding visual flag.

- +
@@ -5872,14 +6454,14 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
Symbol
-

SCI_SETWRAPINDENTMODE(int indentMode)
- SCI_GETWRAPINDENTMODE
+

SCI_SETWRAPINDENTMODE(int wrapIndentMode)
+ SCI_GETWRAPINDENTMODE → int
Wrapped sublines can be indented to the position of their first subline or one more indent level. The default is SC_WRAPINDENT_FIXED. The modes are:

- +
@@ -5892,8 +6474,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ - + @@ -5907,11 +6491,17 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ + + + + + +
Symbol
SC_WRAPINDENT_FIXED 0Wrapped sublines aligned to left of window plus amount set by - SCI_SETWRAPSTARTINDENT + Wrapped sublines aligned to left of window plus amount set by + SCI_SETWRAPSTARTINDENT +
2 Wrapped sublines are aligned to first subline indent plus one more level of indentation
SC_WRAPINDENT_DEEPINDENT3Wrapped sublines are aligned to first subline indent plus two more levels of indentation

SCI_SETWRAPSTARTINDENT(int indent)
- SCI_GETWRAPSTARTINDENT
+ SCI_GETWRAPSTARTINDENT → int
SCI_SETWRAPSTARTINDENT sets the size of indentation of sublines for wrapped lines in terms of the average character width in STYLE_DEFAULT. @@ -5922,10 +6512,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

SCI_SETLAYOUTCACHE(int cacheMode)
- SCI_GETLAYOUTCACHE
- You can set cacheMode to one of the symbols in the table:

+ SCI_GETLAYOUTCACHE → int
+ You can set cacheMode to one of the symbols in the table:

- +
@@ -5972,7 +6562,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
Symbol

SCI_SETPOSITIONCACHE(int size)
- SCI_GETPOSITIONCACHE
+ SCI_GETPOSITIONCACHE → int
The position cache stores position information for short runs of text so that their layout can be determined more quickly if the run recurs. The size in entries of this cache can be set with SCI_SETPOSITIONCACHE.

@@ -5980,7 +6570,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

SCI_LINESSPLIT(int pixelWidth)
Split a range of lines indicated by the target into lines that are at most pixelWidth wide. Splitting occurs on word boundaries wherever possible in a similar manner to line wrapping. - When pixelWidth is 0 then the width of the window is used. + When pixelWidth is 0 then the width of the window is used.

SCI_LINESJOIN
@@ -5989,7 +6579,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ Where this would lead to no space between words, an extra space is inserted.

-

SCI_WRAPCOUNT(int docLine)
+

SCI_WRAPCOUNT(int docLine) → int
Document lines can occupy more than one display line if they wrap and this returns the number of display lines needed to wrap a document line.

@@ -6001,7 +6591,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ SCI_ZOOMIN
SCI_ZOOMOUT
SCI_SETZOOM(int zoomInPoints)
- SCI_GETZOOM
+ SCI_GETZOOM → int

SCI_ZOOMIN
@@ -6011,7 +6601,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ current zoom factor is greater than -10 points.

SCI_SETZOOM(int zoomInPoints)
- SCI_GETZOOM
+ SCI_GETZOOM → int
These messages let you set and get the zoom factor directly. There is no limit set on the factors you can set, so limiting yourself to -10 to +20 to match the incremental zoom functions is a good idea.

@@ -6020,20 +6610,23 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

You can choose to mark lines that exceed a given length by drawing a vertical line or by colouring the background of characters that exceed the set length.

- SCI_SETEDGEMODE(int mode)
- SCI_GETEDGEMODE
+ SCI_SETEDGEMODE(int edgeMode)
+ SCI_GETEDGEMODE → int
SCI_SETEDGECOLUMN(int column)
- SCI_GETEDGECOLUMN
- SCI_SETEDGECOLOUR(int colour)
- SCI_GETEDGECOLOUR
+ SCI_GETEDGECOLUMN → int
+ SCI_SETEDGECOLOUR(colour edgeColour)
+ SCI_GETEDGECOLOUR → colour
+
+ SCI_MULTIEDGEADDLINE(int column, colour edgeColour)
+ SCI_MULTIEDGECLEARALL

SCI_SETEDGEMODE(int edgeMode)
- SCI_GETEDGEMODE
+ SCI_GETEDGEMODE → int
These two messages set and get the mode used to display long lines. You can set one of the values in the table:

- +
@@ -6074,22 +6667,94 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ + + + + + + + +
SymbolThe background colour of characters after the column limit is changed to the colour set by SCI_SETEDGECOLOUR. This is recommended for proportional fonts.
EDGE_MULTILINE3This is similar to EDGE_LINE but in contrary to showing only one single + line a configurable set of vertical lines can be shown simultaneously. This edgeMode + uses a completely independent dataset that can only be configured by using the + SCI_MULTIEDGE* messages.

SCI_SETEDGECOLUMN(int column)
- SCI_GETEDGECOLUMN
+ SCI_GETEDGECOLUMN → int
These messages set and get the column number at which to display the long line marker. When drawing lines, the column sets a position in units of the width of a space character in STYLE_DEFAULT. When setting the background colour, the column is a character count (allowing for tabs) into the line.

-

SCI_SETEDGECOLOUR(int colour)
- SCI_GETEDGECOLOUR
+

SCI_SETEDGECOLOUR(colour edgeColour)
+ SCI_GETEDGECOLOUR → colour
These messages set and get the colour of the marker used to show that a line has exceeded the length set by SCI_SETEDGECOLUMN.

+

SCI_MULTIEDGEADDLINE(int column, + colour edgeColour)
+ SCI_MULTIEDGECLEARALL
+ SCI_MULTIEDGEADDLINE adds a new vertical edge to the view. The edge will be + displayed at the given column number. The resulting edge position depends on the metric + of a space character in STYLE_DEFAULT. All the edges can be cleared with + SCI_MULTIEDGECLEARALL.

+ +

Accessibility

+ +

Scintilla supports some platform accessibility features. + This support differs between platforms. + On GTK and Cocoa the platform accessibility APIs are implemented sufficiently to + make screen readers work. + On Win32, the system caret is manipulated to help screen readers. +

+ + SCI_SETACCESSIBILITY(int accessibility)
+ SCI_GETACCESSIBILITY → int
+
+ +

SCI_SETACCESSIBILITY(int accessibility)
+ SCI_GETACCESSIBILITY → int
+ These messages may enable or disable accessibility and report its current status.

+ +

On most platforms, accessibility is either implemented or not implemented and this can be + discovered with SCI_GETACCESSIBILITY with + SCI_SETACCESSIBILITY performing no action. + On GTK, there are storage and performance costs to accessibility, so it can be disabled + by calling SCI_SETACCESSIBILITY. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SymbolValueAccessibility status
SC_ACCESSIBILITY_DISABLED0Accessibility is disabled.
SC_ACCESSIBILITY_ENABLED1Accessibility is enabled.
+

Lexer

If you define the symbol SCI_LEXER when building Scintilla, (this is sometimes @@ -6098,42 +6763,46 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ styling and fold points for an unsupported language you can either do this in the container or better still, write your own lexer following the pattern of one of the existing ones.

-

Scintilla also supports external lexers. These are DLLs (on Windows) or .so modules (on GTK+/Linux) that export three +

Scintilla also supports external lexers. These are DLLs (on Windows) or .so modules (on GTK/Linux) that export three functions: GetLexerCount, GetLexerName, and GetLexerFactory. See externalLexer.cxx for more.

SCI_SETLEXER(int lexer)
- SCI_GETLEXER
+ SCI_GETLEXER → int
SCI_SETLEXERLANGUAGE(<unused>, const char - *name)
- SCI_GETLEXERLANGUAGE(<unused>, char - *name)
+ *language)
+ SCI_GETLEXERLANGUAGE(<unused>, char *language) → int
SCI_LOADLEXERLIBRARY(<unused>, const char *path)
SCI_COLOURISE(int start, int end)
- SCI_CHANGELEXERSTATE(int start, int end)
- SCI_PROPERTYNAMES(<unused>, char *names)
- SCI_PROPERTYTYPE(const char *name)
- SCI_DESCRIBEPROPERTY(const char *name, char *description)
+ SCI_CHANGELEXERSTATE(int start, int end) → int
+ SCI_PROPERTYNAMES(<unused>, char *names) → int
+ SCI_PROPERTYTYPE(const char *name) → int
+ SCI_DESCRIBEPROPERTY(const char *name, char *description) → int
SCI_SETPROPERTY(const char *key, const char *value)
- SCI_GETPROPERTY(const char *key, char *value)
- SCI_GETPROPERTYEXPANDED(const char *key, char *value)
- SCI_GETPROPERTYINT(const char *key, int default)
- SCI_DESCRIBEKEYWORDSETS(<unused>, char *descriptions)
+ SCI_GETPROPERTY(const char *key, char *value) → int
+ SCI_GETPROPERTYEXPANDED(const char *key, char *value) → int
+ SCI_GETPROPERTYINT(const char *key, int defaultValue) → int
+ SCI_DESCRIBEKEYWORDSETS(<unused>, char *descriptions) → int
SCI_SETKEYWORDS(int keyWordSet, const char - *keyWordList)
+ *keyWords)
- SCI_GETSUBSTYLEBASES(<unused>, char *styles)
- SCI_DISTANCETOSECONDARYSTYLES
- SCI_ALLOCATESUBSTYLES(int styleBase, int numberStyles)
+ SCI_GETSUBSTYLEBASES(<unused>, char *styles) → int
+ SCI_DISTANCETOSECONDARYSTYLES → int
+ SCI_ALLOCATESUBSTYLES(int styleBase, int numberStyles) → int
SCI_FREESUBSTYLES
- SCI_GETSUBSTYLESSTART(int styleBase)
- SCI_GETSUBSTYLESLENGTH(int styleBase)
- SCI_GETSTYLEFROMSUBSTYLE(int subStyle)
- SCI_GETPRIMARYSTYLEFROMSTYLE(int style)
+ SCI_GETSUBSTYLESSTART(int styleBase) → int
+ SCI_GETSUBSTYLESLENGTH(int styleBase) → int
+ SCI_GETSTYLEFROMSUBSTYLE(int subStyle) → int
+ SCI_GETPRIMARYSTYLEFROMSTYLE(int style) → int
SCI_SETIDENTIFIERS(int style, const char *identifiers)
+ SCI_PRIVATELEXERCALL(int operation, int pointer) → int
+ SCI_GETNAMEDSTYLES → int
+ SCI_NAMEOFSTYLE(int style, char *name) → int
+ SCI_TAGSOFSTYLE(int style, char *tags) → int
+ SCI_DESCRIPTIONOFSTYLE(int style, char *description) → int

SCI_SETLEXER(int lexer)
- SCI_GETLEXER
+ SCI_GETLEXER → int
You can select the lexer to use with an integer code from the SCLEX_* enumeration in Scintilla.h. There are two codes in this sequence that do not use lexers: SCLEX_NULL to select no lexing action and SCLEX_CONTAINER which sends @@ -6142,11 +6811,11 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ SCLEX_AUTOMATIC value; this identifies additional external lexers that Scintilla assigns unused lexer numbers to.

-

SCI_SETLEXERLANGUAGE(<unused>, const char *name)
- SCI_GETLEXERLANGUAGE(<unused>, char *name NUL-terminated)
+

SCI_SETLEXERLANGUAGE(<unused>, const char *language)
+ SCI_GETLEXERLANGUAGE(<unused>, char *language NUL-terminated) → int
SCI_SETLEXERLANGUAGE lets you select a lexer by name, and is the only method if you are using an external lexer or if you have written a lexer module for a language of your own and do not wish - to assign it an explicit lexer number. To select an existing lexer, set name to + to assign it an explicit lexer number. To select an existing lexer, set language to match the (case sensitive) name given to the module, for example "ada" or "python", not "Ada" or "Python". To locate the name for the built-in lexers, open the relevant Lex*.cxx file and search for LexerModule. The third argument in the @@ -6159,24 +6828,24 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

SCI_GETLEXERLANGUAGE retrieves the name of the lexer.

SCI_LOADLEXERLIBRARY(<unused>, const char *path)
- Load a lexer implemented in a shared library. This is a .so file on GTK+/Linux or a .DLL file on Windows. + Load a lexer implemented in a shared library. This is a .so file on GTK/Linux or a .DLL file on Windows.

-

SCI_COLOURISE(int startPos, int endPos)
+

SCI_COLOURISE(int start, int end)
This requests the current lexer or the container (if the lexer is set to - SCLEX_CONTAINER) to style the document between startPos and - endPos. If endPos is -1, the document is styled from - startPos to the end. If the "fold" property is set to + SCLEX_CONTAINER) to style the document between start and + end. If end is -1, the document is styled from + start to the end. If the "fold" property is set to "1" and your lexer or container supports folding, fold levels are also set. This message causes a redraw.

-

SCI_CHANGELEXERSTATE(int startPos, int endPos)
+

SCI_CHANGELEXERSTATE(int start, int end) → int
Indicate that the internal state of a lexer has changed over a range and therefore there may be a need to redraw.

-

SCI_PROPERTYNAMES(<unused>, char *names NUL-terminated)
- SCI_PROPERTYTYPE(const char *name)
- SCI_DESCRIBEPROPERTY(const char *name, char *description NUL-terminated)
+

SCI_PROPERTYNAMES(<unused>, char *names NUL-terminated) → int
+ SCI_PROPERTYTYPE(const char *name) → int
+ SCI_DESCRIBEPROPERTY(const char *name, char *description NUL-terminated) → int
Information may be retrieved about the properties that can be set for the current lexer. This information is only available for newer lexers. SCI_PROPERTYNAMES returns a string with all of the valid properties separated by "\n". @@ -6187,14 +6856,14 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

SCI_SETPROPERTY(const char *key, const char *value)
You can communicate settings to lexers with keyword:value string pairs. There is no limit to - the number of keyword pairs you can set, other than available memory. key is a - case sensitive keyword, value is a string that is associated with the keyword. If + the number of keyword pairs you can set, other than available memory. key is a + case sensitive keyword, value is a string that is associated with the keyword. If there is already a value string associated with the keyword, it is replaced. If you pass a zero - length string, the message does nothing. Both key and value are used - without modification; extra spaces at the beginning or end of key are + length string, the message does nothing. Both key and value are used + without modification; extra spaces at the beginning or end of key are significant.

-

The value string can refer to other keywords. For example, +

The value string can refer to other keywords. For example, SCI_SETPROPERTY("foldTimes10", "$(fold)0") stores the string "$(fold)0", but when this is accessed, the $(fold) is replaced by the value of the "fold" keyword (or by nothing if this keyword does not exist).

@@ -6215,7 +6884,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ Documentation for the property may be located above the call as a multi-line comment starting with
// property <property-name>

-

SCI_GETPROPERTY(const char *key, char *value NUL-terminated)
+

SCI_GETPROPERTY(const char *key, char *value NUL-terminated) → int
Lookup a keyword:value pair using the specified key; if found, copy the value to the user-supplied buffer and return the length (not including the terminating 0). If not found, copy an empty string to the buffer and return 0.

@@ -6226,7 +6895,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

If the value argument is 0 then the length that should be allocated to store the value is returned; again, the terminating 0 is not included.

-

SCI_GETPROPERTYEXPANDED(const char *key, char *value)
+

SCI_GETPROPERTYEXPANDED(const char *key, char *value) → int
Lookup a keyword:value pair using the specified key; if found, copy the value to the user-supplied buffer and return the length (not including the terminating 0). If not found, copy an empty string to the buffer and return 0.

@@ -6237,7 +6906,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

If the value argument is 0 then the length that should be allocated to store the value (including any indicated keyword replacement) is returned; again, the terminating 0 is not included.

-

SCI_GETPROPERTYINT(const char *key, int default)
+

SCI_GETPROPERTYINT(const char *key, int defaultValue) → int
Lookup a keyword:value pair using the specified key; if found, interpret the value as an integer and return it. If not found (or the value is an empty string) then return the supplied default. If the keyword:value pair is found but is not a number, then return 0.

@@ -6245,10 +6914,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

Note that "keyword replacement" as described in SCI_SETPROPERTY will be performed before any numeric interpretation.

-

SCI_SETKEYWORDS(int keyWordSet, const char *keyWordList)
+

SCI_SETKEYWORDS(int keyWordSet, const char *keyWords)
You can set up to 9 lists of keywords for use by the current lexer. - keyWordSet can be 0 to 8 (actually 0 to KEYWORDSET_MAX) - and selects which keyword list to replace. keyWordList is a list of keywords + keyWordSet can be 0 to 8 (actually 0 to KEYWORDSET_MAX) + and selects which keyword list to replace. keyWords is a list of keywords separated by spaces, tabs, "\n" or "\r" or any combination of these. It is expected that the keywords will be composed of standard ASCII printing characters, but there is nothing to stop you using any non-separator character codes from 1 to 255 @@ -6267,7 +6936,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ There is nothing to stop you building your own keyword lists into the lexer, but this means that the lexer must be rebuilt if more keywords are added.

-

SCI_DESCRIBEKEYWORDSETS(<unused>, char *descriptions NUL-terminated)
+

SCI_DESCRIBEKEYWORDSETS(<unused>, char *descriptions NUL-terminated) → int
A description of all of the keyword sets separated by "\n" is returned by SCI_DESCRIBEKEYWORDSETS.

Substyles

@@ -6278,33 +6947,53 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ each purpose. Lexers have to explicitly support this feature by implementing the methods in ILexerWithSubStyles.

-

SCI_GETSUBSTYLEBASES(<unused>, char *styles NUL-terminated)
- Fill styles with a byte for each style that can be split into substyles.

+

SCI_GETSUBSTYLEBASES(<unused>, char *styles NUL-terminated) → int
+ Fill styles with a byte for each style that can be split into substyles.

-

SCI_DISTANCETOSECONDARYSTYLES
+

SCI_DISTANCETOSECONDARYSTYLES → int
Returns the distance between a primary style and its corresponding secondary style.

-

SCI_ALLOCATESUBSTYLES(int styleBase, int numberStyles)
+

SCI_ALLOCATESUBSTYLES(int styleBase, int numberStyles) → int
Allocate some number of substyles for a particular base style returning the first substyle number allocated. Substyles are allocated contiguously.

SCI_FREESUBSTYLES
Free all allocated substyles.

-

SCI_GETSUBSTYLESSTART(int styleBase)
- SCI_GETSUBSTYLESLENGTH(int styleBase)
+

SCI_GETSUBSTYLESSTART(int styleBase) → int
+ SCI_GETSUBSTYLESLENGTH(int styleBase) → int
Return the start and length of the substyles allocated for a base style.

-

SCI_GETSTYLEFROMSUBSTYLE(int subStyle)
+

SCI_GETSTYLEFROMSUBSTYLE(int subStyle) → int
For a sub style, return the base style, else return the argument.

-

SCI_GETPRIMARYSTYLEFROMSTYLE(int style)
+

SCI_GETPRIMARYSTYLEFROMSTYLE(int style) → int
For a secondary style, return the primary style, else return the argument.

SCI_SETIDENTIFIERS(int style, const char *identifiers)
Similar to SCI_SETKEYWORDS but for substyles. The prefix feature available with SCI_SETKEYWORDS is not implemented for SCI_SETIDENTIFIERS.

+

SCI_PRIVATELEXERCALL(int operation, int pointer) → int
+ Call into a lexer in a way not understood by Scintilla.

+ +

Style Metadata

+

Lexers may provide information on the styles they use. + Lexers have to explicitly support this feature by implementing particular methods.

+ +

SCI_GETNAMEDSTYLES → int
+ Retrieve the number of named styles for the lexer.

+ +

SCI_NAMEOFSTYLE(int style, char *name) → int
+ Retrieve the name of a style. This is a C preprocessor symbol like "SCE_C_COMMENTDOC".

+ +

SCI_TAGSOFSTYLE(int style, char *tags) → int
+ Retrieve the tags of a style. This is a space-separated set of words like "comment documentation".

+ +

SCI_DESCRIPTIONOFSTYLE(int style, char *description) → int
+ Retrieve an English-language description of a style which may be suitable for display in a user interface. + This looks like "Doc comment: block comments beginning with /** or /*!".

+

Lexer Objects

Lexers are programmed as objects that implement the ILexer interface and that interact @@ -6367,6 +7056,12 @@ Before release 3.6.0 the types int and unsigned int we In a future release, 64-bit builds will define these as 64-bit types to allow documents larger than 2 GB.

+

+Methods that return strings as const char * are not required to maintain separate allocations indefinitely: +lexer implementations may own a single buffer that is reused for each call. +Callers should make an immediate copy of returned strings. +

+

The return values from PropertySet and WordListSet are used to indicate whether the change requires performing lexing or folding over any of the document. It is the position at which to restart lexing and folding or -1 @@ -6376,7 +7071,8 @@ optimisation could be to remember where a setting first affects the document and

Version returns an enumerated value specifying which version of the interface is implemented: -lvOriginal for ILexer and lvSubStyles for ILexerWithSubStyles.

+lvOriginal for ILexer, lvSubStyles for ILexerWithSubStyles, +and lvMetaData for ILexerWithMetaData.

Release is called to destroy the lexer object.

@@ -6417,6 +7113,27 @@ To allow lexers to report which line ends they support, and to support substyles };
+

ILexerWithMetaData

+ +

NamedStyles, NameOfStyle, +TagsOfStyle, and DescriptionOfStyle +are used to provide information on the set of styles used by this lexer. +NameOfStyle is the C-language identifier like "SCE_LUA_COMMENT". +TagsOfStyle is a set of tags describing the style in a standardized way like "literal string multiline raw". +A set of common tags and conventions for combining them is described here. +DescriptionOfStyle is an English description of the style like "Function or method name definition". +

+ +
+class ILexerWithMetaData : public ILexerWithSubStyles {
+public:
+        virtual int SCI_METHOD NamedStyles() = 0;
+        virtual const char * SCI_METHOD NameOfStyle(int style) = 0;
+        virtual const char * SCI_METHOD TagsOfStyle(int style) = 0;
+        virtual const char * SCI_METHOD DescriptionOfStyle(int style) = 0;
+};
+
+

IDocument

@@ -6473,7 +7190,7 @@ returning INVALID_POSITION for movement beyond the start and end of conversion from UTF-8 bytes to a UTF-32 character or from DBCS to a 16 bit value. Bytes in invalid UTF-8 are reported individually with values 0xDC80+byteValue, which are not valid Unicode code points. -The pWidth argument can be NULL if the caller does not need to know the number of +The pWidth argument can be NULL if the caller does not need to know the number of bytes in the character.

@@ -6498,7 +7215,7 @@ implemented and thus which methods may be called.

occurred that may interest the container.

Notifications are sent using the WM_NOTIFY message on Windows.

-

On GTK+, the "sci-notify" signal is sent and the signal handler should have the signature +

On GTK, the "sci-notify" signal is sent and the signal handler should have the signature handler(GtkWidget *, gint, SCNotification *notification, gpointer userData).

On Cocoa, a delegate implementing the ScintillaNotificationProtocol may be set to receive notifications or the ScintillaView class may be subclassed and the @@ -6517,10 +7234,10 @@ struct SCNotification { struct Sci_NotifyHeader nmhdr; Sci_Position position; /* SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, */ - /* SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, */ - /* SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, */ - /* SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ - /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */ + /* SCN_MARGINRIGHTCLICK, SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, */ + /* SCN_CALLTIPCLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */ + /* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ + /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_AUTOCSELECTIONCHANGE */ int ch; /* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETE, SCN_AUTOCSELECTION, */ @@ -6531,7 +7248,8 @@ struct SCNotification { int modificationType; /* SCN_MODIFIED */ const char *text; - /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */ + /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED, */ + /* SCN_AUTOCSELECTIONCHANGE */ Sci_Position length; /* SCN_MODIFIED */ Sci_Position linesAdded; /* SCN_MODIFIED */ @@ -6541,14 +7259,14 @@ struct SCNotification { Sci_Position line; /* SCN_MODIFIED */ int foldLevelNow; /* SCN_MODIFIED */ int foldLevelPrev; /* SCN_MODIFIED */ - int margin; /* SCN_MARGINCLICK */ - int listType; /* SCN_USERLISTSELECTION */ + int margin; /* SCN_MARGINCLICK, SCN_MARGINRIGHTCLICK */ + int listType; /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTIONCHANGE */ int x; /* SCN_DWELLSTART, SCN_DWELLEND */ int y; /* SCN_DWELLSTART, SCN_DWELLEND */ int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */ int annotationLinesAdded; /* SCN_MODIFIED with SC_MOD_CHANGEANNOTATION */ int updated; /* SCN_UPDATEUI */ - int listCompletionMethod; + int listCompletionMethod; /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION */ }; @@ -6586,15 +7304,19 @@ struct SCNotification { SCN_FOCUSIN
SCN_FOCUSOUT
SCN_AUTOCCOMPLETED
+ SCN_MARGINRIGHTCLICK
+ SCN_AUTOCSELECTIONCHANGE

The following SCI_* messages are associated with these notifications:

SCI_SETMODEVENTMASK(int eventMask)
- SCI_GETMODEVENTMASK
- SCI_SETMOUSEDWELLTIME(int milliseconds)
- SCI_GETMOUSEDWELLTIME
+ SCI_GETMODEVENTMASK → int
+ SCI_SETCOMMANDEVENTS(bool commandEvents)
+ SCI_GETCOMMANDEVENTS → bool
+ SCI_SETMOUSEDWELLTIME(int periodMilliseconds)
+ SCI_GETMOUSEDWELLTIME → int
SCI_SETIDENTIFIER(int identifier)
- SCI_GETIDENTIFIER
+ SCI_GETIDENTIFIER → int

The following additional notifications are sent using a secondary "command" method and should @@ -6603,7 +7325,7 @@ struct SCNotification { The WM_COMMAND message is used on Windows. This emulates the Windows Edit control. Only the lower 16 bits of the control's ID is passed in these notifications.

-

On GTK+, the "command" signal is sent and the signal handler should have the signature +

On GTK, the "command" signal is sent and the signal handler should have the signature handler(GtkWidget *, gint wParam, gpointer lParam, gpointer userData).

SCEN_CHANGE
SCEN_SETFOCUS
@@ -6611,7 +7333,7 @@ struct SCNotification {

SCI_SETIDENTIFIER(int identifier)
- SCI_GETIDENTIFIER
+ SCI_GETIDENTIFIER → int
These two messages set and get the identifier of the Scintilla instance which is included in notifications as the idFrom field. When an application creates multiple Scintilla widgets, this allows the source of each notification to be found. @@ -6626,14 +7348,14 @@ struct SCNotification { href="#SCI_SETLEXER">SCI_SETLEXER(SCLEX_CONTAINER)
to make the container act as the lexer, you will receive this notification when Scintilla is about to display or print text that requires styling. You are required to style the text from the line that contains the position - returned by SCI_GETENDSTYLED up to + returned by SCI_GETENDSTYLED up to the position passed in SCNotification.position. Symbolically, you need code of the form:

-    startPos = SCI_GETENDSTYLED()
-    lineNumber = SCI_GETENDSTYLED()
+    lineNumber = SCI_LINEFROMPOSITION(startPos);
-    startPos = SCI_POSITIONFROMLINE(lineNumber);
     MyStyleRoutine(startPos, SCNotification.position);
 
@@ -6642,7 +7364,10 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); This is sent when the user types an ordinary text character (as opposed to a command character) that is entered into the text. The container can use this to decide to display a call tip or an auto - completion list. The character is in SCNotification.ch. + completion list. The character is in SCNotification::ch. + For single byte character sets, this is the byte value of the character; + for UTF-8, it is the Unicode code point; + for DBCS, it is (first byte * 256 + second byte) for 2 byte characters and the byte value for 1 byte characters. This notification is sent before the character has been styled so processing that depends on styling should instead be performed in the SCN_UPDATEUI notification.

@@ -6660,8 +7385,8 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); href="#SCI_SETREADONLY">SCI_SETREADONLY.

SCN_KEY
- Reports all keys pressed but not consumed by Scintilla. Used on GTK+ because of - some problems with keyboard focus and is not sent by the Windows version. SCNotification.ch holds the key code and + Reports all keys pressed but not consumed by Scintilla. Used on GTK because of + some problems with keyboard focus and is not sent by the Windows version. SCNotification::ch holds the key code and SCNotification.modifiers holds the modifiers. This notification is sent if the modifiers include SCMOD_ALT or SCMOD_CTRL and the key code is less than 256.

@@ -6673,10 +7398,12 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); held down in a similar manner to SCN_KEY.

SCN_UPDATEUI
- Either the text or styling of the document has changed or the selection range or scroll position has changed. + Either the text or styling of the document has changed or the selection range or scroll position may have changed. Now would be a good time to update any container UI elements that depend on document or view state. + As it is sometimes difficult to determine whether a change has occurred, these events may also fire when there + has been no actual change. The updated field is set to the bit set of things changed since the previous notification.

- +
@@ -6694,7 +7421,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); - + @@ -6703,7 +7430,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); - + @@ -6712,7 +7439,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); - + @@ -6721,7 +7448,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); - + @@ -6736,7 +7463,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); while in a SCN_MODIFIED event. The SCNotification fields used are:

-
Symbol0x01Contents, styling or markers have been changed.Contents, styling or markers may have been changed.
0x02Selection has been changed.Selection may have been changed.
0x04Scrolled vertically.May have scrolled vertically.
0x08Scrolled horizontally.May have scrolled horizontally.
+
@@ -6809,7 +7536,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); SC_PERFORMED_* bits tell you if the action was done by the user, or the result of Undo or Redo of a previous action.

-
Field
+
@@ -6958,7 +7685,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); - @@ -6969,8 +7696,8 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); - + @@ -7011,7 +7738,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); @@ -7070,15 +7797,17 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber);

SCEN_CHANGE
SCEN_CHANGE (768) is fired when the text (not the style) of the document changes. This notification is sent using the WM_COMMAND message on Windows and the - "command" signal on GTK+ as this is the behaviour of the standard Edit control + "command" signal on GTK as this is the behaviour of the standard Edit control (SCEN_CHANGE has the same value as the Windows Edit control EN_CHANGE). No other information is sent. If you need more detailed information use SCN_MODIFIED. You can filter the types of changes you are notified about with SCI_SETMODEVENTMASK.

+ href="#SCI_SETMODEVENTMASK">SCI_SETMODEVENTMASK and + SCI_SETCOMMANDEVENTS.

SCI_SETMODEVENTMASK(int eventMask)
- SCI_GETMODEVENTMASK
+ SCI_GETMODEVENTMASK → int
These messages set and get an event mask that determines which document change events are notified to the container with SCN_MODIFIED and SCI_POSITIONFROMLINE(lineNumber); SC_MOD_BEFOREINSERT, SC_MOD_BEFOREDELETE, SC_MULTILINEUNDOREDO, and SC_MODEVENTMASKALL.

+

SCI_SETCOMMANDEVENTS(bool commandEvents)
+ SCI_GETCOMMANDEVENTS → bool
+ These messages set and get whether SCEN_* command events are + sent to the container. For SCEN_CHANGE this acts as an additional filter over + SCI_SETMODEVENTMASK. + Most applications should set this off to avoid overhead and only use + SCN_MODIFIED.

+

SCEN_SETFOCUS
SCEN_KILLFOCUS
SCEN_SETFOCUS (512) is fired when Scintilla receives focus and SCEN_KILLFOCUS (256) when it loses focus. These notifications are sent using the - WM_COMMAND message on Windows and the "command" signal on GTK+ as this is the + WM_COMMAND message on Windows and the "command" signal on GTK as this is the behaviour of the standard Edit control. Unfortunately, these codes do not match the Windows Edit notification codes EN_SETFOCUS (256) and EN_KILLFOCUS (512). It is now too late to change the Scintilla codes as clients depend on the current values.

@@ -7114,7 +7851,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); Editor::NotifyMacroRecord. The fields of SCNotification set in this notification are:

-
Symbol0x8000A line state has changed because SCI_SETLINESTATE + A line state has changed because SCI_SETLINESTATE was called. line0x200000The explicit tab stops on a line have changed because SCI_CLEARTABSTOPS or - SCI_ADDTABSTOP was called.The explicit tab stops on a line have changed because SCI_CLEARTABSTOPS or + SCI_ADDTABSTOP was called. line
0x100000 Text is about to be inserted. The handler may change the text being inserted by calling - SCI_CHANGEINSERTION. + SCI_CHANGEINSERTION. No other modifications may be made in this handler. position, length, text
+
@@ -7145,13 +7882,14 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber);
Field

SCN_MARGINCLICK
- This notification tells the container that the mouse was clicked inside a SCN_MARGINRIGHTCLICK

+ These notifications tell the container that the mouse was clicked or right clicked inside a
margin that was marked as sensitive (see SCI_SETMARGINSENSITIVEN). This can be used to perform folding or to place breakpoints. The following SCNotification fields are used:

- +
@@ -7209,7 +7947,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next The user has selected an item in a user list. The SCNotification fields used are:

-
Field
+
@@ -7241,23 +7979,23 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next - -
Field
chIf a fillup character was the method of selection, the used + If a fillup character was the method of selection, the used character, otherwise 0.
listCompletionMethodA value indicating the way in which the completion + A value indicating the way in which the completion occurred. See the table below.

- + See the SCN_AUTOCCOMPLETED notification for the possible values for listCompletionMethod.

SCN_URIDROPPED
- Only on the GTK+ version. Indicates that the user has dragged a URI such as a file name or Web + Only on the GTK version. Indicates that the user has dragged a URI such as a file name or Web address onto Scintilla. The container could interpret this as a request to open the file. The text field of SCNotification points at the URI text.

@@ -7270,7 +8008,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next key press indicates the dwell is over. Both notifications set the same fields in SCNotification:

- +
@@ -7298,15 +8036,15 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next
Field

-

SCI_SETMOUSEDWELLTIME(int milliseconds)
- SCI_GETMOUSEDWELLTIME
+

SCI_SETMOUSEDWELLTIME(int periodMilliseconds)
+ SCI_GETMOUSEDWELLTIME → int
These two messages set and get the time the mouse must sit still, in milliseconds, to generate a SCN_DWELLSTART notification. If set to SC_TIME_FOREVER, the default, no dwell events are generated.

SCN_ZOOM
This notification is generated when the user zooms the display using the keyboard or the - SCI_SETZOOM method is called. This + SCI_SETZOOM method is called. This notification can be used to recalculate positions, such as the width of the line number margin to maintain sizes in terms of characters rather than pixels. SCNotification has no additional information.

@@ -7346,7 +8084,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next SCI_AUTOCCANCEL message before returning from the notification. The SCNotification fields used are:

- +
@@ -7369,19 +8107,19 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next - -
Field
chIf a fillup character was the method of selection, the used + If a fillup character was the method of selection, the used character, otherwise 0.
listCompletionMethodA value indicating the way in which the completion + A value indicating the way in which the completion occurred. See the table below.

- +
@@ -7397,9 +8135,9 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next - + - @@ -7407,7 +8145,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next - + @@ -7416,7 +8154,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next - + @@ -7425,7 +8163,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next - + @@ -7434,11 +8172,11 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next - + @@ -7453,18 +8191,56 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next The user deleted a character while autocompletion list was active. There is no other information in SCNotification.

-

SCN_FOCUSIN
- SCN_FOCUSOUT
- SCN_FOCUSIN (2028) is fired when Scintilla receives focus and - SCN_FOCUSOUT (2029) when it loses focus.

SCN_AUTOCCOMPLETED
-
This notification is generated after an autocompletion has inserted its + This notification is generated after an autocompletion has inserted its text. The fields are identical to the SCN_AUTOCSELECTION notification.

+

SCN_AUTOCSELECTIONCHANGE
+
This notification is sent when items are highlighted in an autocompletion or user list. + The + SCNotification fields used are:

+ +
Symbol
SC_AC_FILLUP0x011A fillup character triggered the completion. The character used is + A fillup character triggered the completion. The character used is in ch.
SC_AC_DOUBLECLICK0x022 A double-click triggered the completion. ch is 0.
SC_AC_TAB0x043 The tab key or SCI_TAB triggered the completion. ch is 0.
SC_AC_NEWLINE0x084 A new line or SCI_NEWLINE triggered the completion. ch is 0.
SC_AC_COMMAND0x105 The - SCI_AUTOCSELECT message + SCI_AUTOCSELECT message triggered the completion. ch is 0.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldUsage
listTypeThis is set to the listType parameter from the SCI_USERLISTSHOW message + or 0 for an autocompletion.
textThe text of the selection.
positionThe position the list was displayed at.
+ +

SCN_FOCUSIN
+ SCN_FOCUSOUT
+ SCN_FOCUSIN (2028) is fired when Scintilla receives focus and + SCN_FOCUSOUT (2029) when it loses focus.

+

Images

Two formats are supported for images used in margin markers and autocompletion lists, RGBA and XPM.

@@ -7493,7 +8269,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next If there is no suitable platform support, the LodePNG and picoPNG libraries are small libraries for loading and decoding PNG files available under a BSD-style license.

-

RGBA format is supported on Windows, GTK+ and OS X Cocoa.

+

RGBA format is supported on Windows, GTK and OS X Cocoa.

XPM

@@ -7513,8 +8289,8 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next

XPM format is supported on on all platforms.

-

GTK+

-

On GTK+, the following functions create a Scintilla widget, communicate with it and allow +

GTK

+

On GTK, the following functions create a Scintilla widget, communicate with it and allow resources to be released after all Scintilla widgets have been destroyed.

GtkWidget *scintilla_new()
void scintilla_set_id(ScintillaObject *sci, uptr_t id)
@@ -7527,9 +8303,9 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next widgets.

void scintilla_set_id(ScintillaObject *sci, uptr_t id)
- Set the control ID which will be used in the idFrom field of the NotifyHeader structure of all + Set the control ID which will be used in the idFrom field of the Sci_NotifyHeader structure of all notifications for this instance. - This is equivalent to SCI_SETIDENTIFIER.

+ This is equivalent to SCI_SETIDENTIFIER.

sptr_t scintilla_send_message(ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam)
The main entry point allows sending any of the messages described in this document.

@@ -7544,12 +8320,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next

Provisional features are displayed in this document with a distinctive background colour.

-

There are currently no provisional messages. - The SC_TECHNOLOGY_DIRECTWRITERETAIN and - SC_TECHNOLOGY_DIRECTWRITEDC values for - SCI_SETTECHNOLOGY are provisional.

- -

Using C++11 <regex> is provisional.

+

There are currently no provisional messages or values.

Some developers may want to only use features that are stable and have graduated from provisional status. To avoid using provisional messages compile with the symbol @@ -7608,25 +8379,24 @@ EM_FORMATRANGE INCLUDE_DEPRECATED_FEATURES in Scintilla.h. To ensure future compatibility you should change them as indicated.

-

SC_CP_DBCS Deprecated
- This was used to set a DBCS (Double Byte Character Set) mode on GTK+. - An explicit DBCS code page should be used when calling SCI_SETCODEPAGE

+ + SCI_SETKEYSUNICODE(bool keysUnicode)
+ SCI_GETKEYSUNICODE → bool
+ SCI_SETSTYLEBITS(int bits)
+ SCI_GETSTYLEBITS → int
+ SCI_GETSTYLEBITSNEEDED → int
+
-

SCI_SETUSEPALETTE(bool allowPaletteUse) Deprecated
- SCI_GETUSEPALETTE Deprecated
- Scintilla no longer supports palette mode. The last version to support palettes was 2.29. - Any calls to these methods should be removed.

-

SCI_SETKEYSUNICODE(bool keysUnicode) Deprecated
- SCI_GETKEYSUNICODE Deprecated
+ SCI_GETKEYSUNICODE → bool Deprecated
On Windows, Scintilla no longer supports narrow character windows so input is always treated as Unicode.

The following are features that should be removed from calling code but are still defined to avoid breaking callers.

SCI_SETSTYLEBITS(int bits) Deprecated
- SCI_GETSTYLEBITS Deprecated
- SCI_GETSTYLEBITSNEEDED Deprecated
+ SCI_GETSTYLEBITS → int Deprecated
+ SCI_GETSTYLEBITSNEEDED → int Deprecated
INDIC0_MASK, INDIC1_MASK, INDIC2_MASK, INDICS_MASK Deprecated
Scintilla no longer supports style byte indicators. The last version to support style byte indicators was 3.4.2. Any use of these symbols should be removed and replaced with standard indicators. @@ -7670,6 +8440,17 @@ EM_SETTARGETDEVICE

Removed features

+

These features have now been removed completely.

+ +

SC_CP_DBCS Removed in 2016 with release 3.7.1
+ This was used to set a DBCS (Double Byte Character Set) mode on GTK. + An explicit DBCS code page should be used when calling SCI_SETCODEPAGE

+ +

SCI_SETUSEPALETTE(bool usePalette) Removed in 2016 with release 3.7.1
+ SCI_GETUSEPALETTE → bool Removed in 2016 with release 3.7.1
+ Scintilla no longer supports palette mode. The last version to support palettes was 2.29. + Any calls to these methods must be removed.

+

Previous versions of Scintilla allowed indicators to be stored in bits of each style byte. This was deprecated in 2007 and removed in 2014 with release 3.4.3. All uses of style byte indicators should be replaced with standard indicators.

@@ -7677,21 +8458,26 @@ EM_SETTARGETDEVICE

Building Scintilla

To build Scintilla or SciTE, see the README file present in both the Scintilla and SciTE - directories. For Windows, GCC 4.7 or Microsoft Visual C++ 2010 can be used - for building. For GTK+, GCC 4.1 or newer should be used. GTK+ 2.8+ and 3.x are - supported. The version of GTK+ installed should be detected automatically. - When both GTK+ 2 and GTK+ 3 are present, building for GTK+ 3.x requires defining GTK3 + directories. + The compiler must support C++11. + For Windows, GCC 4.8 or Microsoft Visual C++ 2015 can be used + for building. For GTK, GCC 4.8 or newer should be used. GTK 2.24+ and 3.x are + supported with glib 2.22+. The version of GTK installed should be detected automatically. + When both GTK 2 and GTK 3 are present, building for GTK 3.x requires defining GTK3 on the command line.

+

Adding and removing source files from Scintilla may require modifying build files. + This is addressed in AddSource.txt.

+

Static linking

On Windows, Scintilla is normally used as a dynamic library as a .DLL file. If you want to - link Scintilla directly into your application .EXE or .DLL file, then the - STATIC_BUILD preprocessor symbol should be defined and - Scintilla_RegisterClasses called. STATIC_BUILD prevents compiling the - DllMain function which will conflict with any DllMain defined in your - code. Scintilla_RegisterClasses takes the HINSTANCE of your + link Scintilla directly into your application .EXE or .DLL file, then you can link to the static library + bin/libscintilla.lib (or .a if using GCC) and call Scintilla_RegisterClasses. + Scintilla_RegisterClasses takes the HINSTANCE of your application and ensures that the "Scintilla" window class is registered.

+

When producing a stand-alone Scintilla DLL, the ScintillaDLL.cxx file should be compiled and + linked in to provide DllMain and Scintilla_RegisterClasses.

Ensuring lexers are linked into Scintilla

diff --git a/dep/scintilla/scintilla-3.6.0/doc/ScintillaDownload.html b/dep/scintilla/scintilla-3.10.6/doc/ScintillaDownload.html similarity index 79% rename from dep/scintilla/scintilla-3.6.0/doc/ScintillaDownload.html rename to dep/scintilla/scintilla-3.10.6/doc/ScintillaDownload.html index aa23c79a..7f43f715 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/ScintillaDownload.html +++ b/dep/scintilla/scintilla-3.10.6/doc/ScintillaDownload.html @@ -6,6 +6,7 @@ + Download Scintilla @@ -25,10 +26,10 @@ @@ -41,7 +42,7 @@ containing very few restrictions.

- Release 3.6.0 + Release 3.10.6

Source Code @@ -49,8 +50,8 @@ The source code package contains all of the source code for Scintilla but no binary executable code and is available in
    -
  • zip format (1500K) commonly used on Windows
  • -
  • tgz format (1400K) commonly used on Linux and compatible operating systems
  • +
  • zip format (1600K) commonly used on Windows
  • +
  • tgz format (1400K) commonly used on Linux and compatible operating systems
Instructions for building on both Windows and Linux are included in the readme file.

diff --git a/dep/scintilla/scintilla-3.6.0/doc/ScintillaHistory.html b/dep/scintilla/scintilla-3.10.6/doc/ScintillaHistory.html similarity index 78% rename from dep/scintilla/scintilla-3.6.0/doc/ScintillaHistory.html rename to dep/scintilla/scintilla-3.10.6/doc/ScintillaHistory.html index 9046eb0f..556d4be3 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/ScintillaHistory.html +++ b/dep/scintilla/scintilla-3.10.6/doc/ScintillaHistory.html @@ -6,6 +6,7 @@ + Scintilla and SciTE @@ -473,10 +474,67 @@

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- + Windows   - - GTK+/Linux   + + GTK/Linux  
Jiří Techet Jonathan HuntSerg StetsukJordan Jueckstock
Yury DubinskySam HocevarLuyomiMatt Gilarde
Mark CJohannes SasongkofstirlitzRobin Haberkorn
Pavel SountsovDirk LorenzenKasper B. GraversenChris Mayo
Van de BuggerTse Kit YamSmartShare SystemsMorten Brørup
Alexey DenisovJustin DaileyoirfeodentA-R-C-A
Roberto RossiKenny LiuIain Clarkedesto
John FlatnessThorsten KaniBernhard M. WiedemannBaldur Karlsson
Martin KleusbergJannickZufu LiuSimon Sobisch
Georger AraújoDimitar RadevGunter KönigsmannNicholai Benalal
Andreas RönnquistHenrik HankLuke Rasmussen
maboroshinGokul Krishnan
Jad AltahanAndrea Ricchi

- Images used in GTK+ version + Images used in GTK version

  • @@ -485,7 +543,1612 @@

- Release 3.6.0 + Release 3.10.6 +

+
    +
  • + Released 11 Jun 2019. +
  • +
  • + Lexer added for X12. + Feature #1280. +
  • +
  • + CMake folder folds function - endfunction. + Feature #1289. +
  • +
  • + VB lexer adds support for VB2017 binary literal &B and digit separators 123_456. + Feature #1288. +
  • +
  • + Updated Markdown Lua LPeg lexer. +
  • +
  • + Updated C++ Lua LPeg lexer to support single quotes in C++14 integer literals. +
  • +
  • + Improved performance of line folding code on large files when no folds are contracted. + This improves the time taken to open or close large files. +
  • +
  • + Fix bug where changing identifier sets in lexers preserved previous identifiers. +
  • +
  • + Fixed bug where changing to Unicode would rediscover line end positions even if still + sticking to ASCII (not Unicode NEL, LS, PS) line ends. + Only noticeable on huge files with over 100,000 lines. +
  • +
  • + Changed behaviour of SCI_STYLESETCASE(*,SC_CASE_CAMEL) so that it only treats 'a-zA-Z' + as word characters because this covers the feature's intended use (viewing case-insensitive ASCII-only + keywords in a specified casing style) and simplifies the behaviour and code. + Feature #1238. +
  • +
+

+ Release 3.10.5 +

+
    +
  • + Released 10 May 2019. +
  • +
  • + Fixed compiler regressions with GCC 4.8 and Clang 3.4. +
  • +
+

+ Release 3.10.4 +

+
    +
  • + Released 17 April 2019. +
  • +
  • + On Win32, removed special handling of non-0 wParam to WM_PAINT. +
  • +
  • + Implement high-priority idle on Win32 to make redraw smoother and more efficient. +
  • +
  • + Add vertical bookmark symbol SC_MARK_VERTICALBOOKMARK. + Feature #1276. +
  • +
  • + Set default fold display text SCI_SETDEFAULTFOLDDISPLAYTEXT(text). + Feature #1272. +
  • +
  • + Add SCI_SETCHARACTERCATEGORYOPTIMIZATION API to optimize speed + of character category features like determining whether a character is a space or number + at the expense of memory. + Feature #1259. +
  • +
  • + Improve the styling of numbers in Nim. + Feature #1268. +
  • +
  • + Updated CSS Lua LPeg lexer to support CSS3. +
  • +
  • + Updated YAML Lua LPeg lexer to fix lack of highlighting strings. +
  • +
  • + Fix exception when inserting DBCS text. + Bug #2093. +
  • +
  • + Improve performance of accessibility on GTK. + Bug #2094. +
  • +
  • + Fix text reported for deletion with accessibility on GTK. + Bug #2095. +
  • +
  • + Fix flicker when inserting primary selection on GTK. + Bug #2087. +
  • +
  • + Support coloured text in Windows 8.1+. + Feature #1277. +
  • +
  • + Avoid potential long hangs with idle styling for huge documents on Cocoa and GTK. +
  • +
+

+ Release 3.10.3 +

+
    +
  • + Released 09 March 2019. +
  • +
  • + Calltips implemented on Qt. + Bug #1548. +
  • +
  • + Block caret in overtype mode SCI_SETCARETSTYLE(caretStyle | CARETSTYLE_OVERSTRIKE_BLOCK). + Feature #1217. +
  • +
  • + Lexer added for .NET's Common Intermediate Language CIL. + Feature #1265. +
  • +
  • + The C++ lexer, with styling.within.preprocessor on, now interprets "(" in preprocessor "#if(" + as an operator instead of part of the directive. This improves folding as well which could become + unbalanced. +
  • +
  • + Fix raw strings in Nim. + Feature #1253. +
  • +
  • + Fix inconsistency with dot styling in Nim. + Feature #1260. +
  • +
  • + Enhance the styling of backticks in Nim. + Feature #1261. +
  • +
  • + Enhance raw string identifier styling in Nim. + Feature #1262. +
  • +
  • + Fix fold behaviour with comments in Nim. + Feature #1254. +
  • +
  • + Fix TCL lexer recognizing '"' after "," inside a bracketed substitution. + Bug #1947. +
  • +
  • + Updated D Lua LPeg lexer. +
  • +
  • + Lua Lpeg lexer patterns for floats no longer erroneously match '..'. +
  • +
  • + Fix garbage text from SCI_MOVESELECTEDLINESUP and SCI_MOVESELECTEDLINESDOWN + for rectangular or thin selection by performing no action. + Bug #2078. +
  • +
  • + Ensure container notified if Insert pressed when caret off-screen. + Bug #2083. +
  • +
  • + Platform layer font cache removed on Win32 as there is a platform-independent cache. +
  • +
+

+ Release 3.10.2 +

+
    +
  • + Released 12 January 2019. +
  • +
  • + Errorlist lexer recognizes negative line numbers as some programs show whole-file + errors occurring on line -1. + SciTE's parsing of diagnostics also updated to handle this case. +
  • +
  • + Added "nim" lexer (SCLEX_NIM) for the Nim language which was previously called Nimrod. + For compatibility, the old "nimrod" lexer is still present but is deprecated and will be removed at the + next major version. + Feature #1242. +
  • +
  • + The Bash lexer implements substyles for multiple sets of keywords and supports SCI_PROPERTYNAMES. + Bug #2054. +
  • +
  • + The C++ lexer interprets continued preprocessor lines correctly by reading all of + the logical line. + Bug #2062. +
  • +
  • + The C++ lexer interprets preprocessor arithmetic expressions containing multiplicative and additive + operators correctly by following operator precedence rules. + Bug #2069. +
  • +
  • + The EDIFACT lexer handles message groups as well as messages. + Feature #1247. +
  • + +
  • + Notify with SC_UPDATE_SELECTION when user performs a multiple selection add. +
  • +
  • + On Cocoa, fix a crash that occurred when entering a dead key diacritic then a character + that can not take that diacritic, such as option+e (acute accent) followed by g. + Bug #2061. +
  • +
+

+ Release 3.10.1 +

+
    +
  • + Released 31 October 2018. +
  • +
  • + Add SCI_SETCOMMANDEVENTS API to allow turning off command events as they + can be a significant performance cost. +
  • +
  • + Optional indexing of line starts in UTF-8 documents by UTF-32 code points and UTF-16 code units added. + This can improve performance for clients that provide UTF-32 or UTF-16 interfaces or that need to interoperate + with UTF-32 or UTF-16 components. +
  • +
  • + Lexers added for SAS and Stata. + Feature #1185. +
  • +
  • + Improve efficiency of idle wrapping by wrapping in blocks as large as possible while + still remaining responsive. +
  • +
  • + Updated case conversion and character categories to Unicode 11. +
  • +
  • + C++ lexer fixes evaluation of "#elif". + Bug #2045. +
  • +
  • + Markdown lexer fixes highlighting of non-ASCII characters in links. +
  • +
  • + SCI_MARKERADD returns -1 for invalid lines as documented instead of 0. + Bug #2051. +
  • +
  • + Shell folder folds "if", "do", and "case". + Feature #1144. +
  • +
  • + Fix margin cursor on Cocoa to point more accurately. +
  • +
  • + Updated ConTeXt Lua LPeg lexer. +
  • +
  • + Improved folding of traditionally single elements in HTML Lua LPeg lexer. +
  • +
  • + Improved accuracy of Markdown Lua LPeg lexer. +
  • +
+

+ Release 3.10.0 +

+
    +
  • + Released 30 June 2018. +
  • +
  • + Add experimental SC_DOCUMENTOPTION_TEXT_LARGE option to accomodate documents larger than + 2 GigaBytes. +
  • +
  • + The platform layer interface has changed with the removal of the ElapsedTime + class in favor of C++11's chrono. +
  • +
  • + Additional print option SC_PRINT_SCREENCOLOURS prints with the same colours used on screen + including line numbers. +
  • +
  • + INDIC_GRADIENT and INDIC_GRADIENTCENTRE indicator types added. + INDIC_GRADIENT starts with a specified colour and alpha at top of line and fades + to fully transparent at bottom. + INDIC_GRADIENTCENTRE starts with a specified colour and alpha at centre of line and fades + to fully transparent at top and bottom. +
  • +
  • + Wrap indent mode SC_WRAPINDENT_DEEPINDENT added which indents two tabs from previous line. +
  • +
  • + Indicators are drawn for line end characters when displayed. +
  • +
  • + Most invalid bytes in DBCS encodings are displayed as blobs to make problems clear + and ensure something is shown. +
  • +
  • + Curses platform fixed potential crash with newer versions of ncurses. +
  • +
  • + Diff lexer adds styles for diffs containing patches. +
  • +
  • + Regular expression crash fixed on macOS when linking to libstdc++. +
  • +
  • + EDIFACT lexer adds property lexer.edifact.highlight.un.all to highlight all UN* segments. + Feature #1166. +
  • +
  • + Fortran folder understands "change team" and "endteam". + Feature #1216. +
  • +
  • + Markdown Lua LPeg lexer fixes incorrect highlighting of markdown lists. +
  • +
  • + Fixed child Lua LPeg lexers that embed themselves into parents. Also fixed proxy lexers. +
  • +
  • + Fixed legacy Lua LPeg lexers with custom fold functions. +
  • +
  • + C# Lua LPeg lexer highlights "var" keyword. +
  • +
  • + Set the last X chosen when SCI_REPLACESEL called to ensure macros work + when text insertion followed by caret up or down. +
  • +
  • + Bugs fixed in regular expression searches in Scintilla where some matches did not occur in an + effort to avoid infinite loops when replacing on empty matches like "^" and "$". + Applications should always handle empty matches in a way that avoids infinite loops, commonly + by incrementing the search position after replacing an empty match. + SciTE fixes a bug where replacing "^" always matched on the first line even when it was an + "in selection" replace and the selection started after the line start. +
  • +
  • + Crashes fixed on macOS for invalid DBCS characters when dragging text, + changing case of text, case-insensitive searching, and retrieving text as UTF-8. +
  • +
  • + Regular expression crash fixed on macOS when linking to libstdc++. +
  • +
  • + On Win32, a new file, ScintillaDLL.cxx, provides + the DllMain function required for a stand-alone Scintilla DLL. Build and project files should include this + file when producing a DLL and omit it when producing a static library or linking Scintilla statically. + The STATIC_BUILD preprocessor symbol is no longer used. +
  • +
  • + On Win32, Direct2D support is no longer automatically detected during build. + DISABLE_D2D may still be defined to remove Direct2D features. +
  • +
  • + In some cases, invalid UTF-8 is handled in a way that is a little friendlier. + For example, when copying to the clipboard on Windows, an invalid lead byte will be copied as the + equivalent ISO 8859-1 character and will not hide the following byte. + Feature #1211. +
  • +
+

+ Release 3.8.0 +

+
    +
  • + Released 29 Mar 2018. +
  • +
  • + Lua can be used to write lexers with the new, optional, LPeg lexer. +
  • +
  • + New curses platform support. +
  • +
  • + Support dropped for GTK+ versions before 2.24. +
  • +
  • + A new lexer interface ILexerWithMetaData with additional style metadata methods was added. +
  • +
  • + The platform layer interface has changed with unused methods removed, a new mechanism for + reporting events, removal of methods that take individual keyboard modifiers, and removal of old timer methods. +
  • +
  • + Style metadata may be retrieved from lexers that support this through the SCI_GETNAMEDSTYLES, SCI_NAMEOFSTYLE, + SCI_TAGSOFSTYLE, and SCI_DESCRIPTIONOFSTYLE APIs. +
  • +
  • + The default encoding in Scintilla is UTF-8. +
  • +
  • + An SCN_AUTOCSELECTIONCHANGE notification is sent when items are highlighted in an autocompletion or user list. +
  • +
  • + The data parameter to ILoader::AddData made const. + Bug #1955. +
  • +
  • + The ILoader interface is defined in its own header ILoader.h as it is not + related to lexing so doesn't belong in ILexer.h. +
  • +
  • + The Scintilla namespace is always active for internal symbols and for the lexer and document interfaces. +
  • +
  • + SCI_CREATEDOCUMENT adds a bytes argument to allocate memory for an initial size. + SCI_CREATELOADER and SCI_CREATEDOCUMENT add a documentOption argument to + allow choosing different document capabilities. +
  • +
  • + Add SC_DOCUMENTOPTION_STYLES_NONE option to stop allocating memory for styles. +
  • +
  • + Add SCI_GETMOVEEXTENDSSELECTION to allow applications to add more + complex selection commands. +
  • +
  • + For rectangular selections, pressing Home or End now moves the caret to the Home or End + position instead of the limit of the rectangular selection. +
  • +
  • + On Win32, the standard makefiles build a libscintilla static library as well as the existing dynamic libraries. +
  • +
  • + Fix move-extends-selection mode for rectangular and line selections. +
  • +
  • + On GTK+, change lifetime of selection widget to avoid runtime warnings. +
  • +
  • + Fix building on Mingw/MSYS to perform file copies and deletions. + Bug #1993. +
  • +
  • + Lexer added for the Maxima computer algebra language. + Feature #1210. +
  • +
  • + Fix hang in Lua lexer when lexing a label upto the terminating "::". + Bug #1999. +
  • +
  • + Lua lexer matches identifier chains with dots and colons. + Bug #1952. +
  • +
  • + Fix HTML lexer handling of Django so that nesting a {{ }} or {% %} + Django tag inside of a {# #} Django comment does not break highlighting of rest of file +
  • +
  • + The Matlab folder now treats "while" as a fold start. + Bug #1985. +
  • +
  • + Improve VHDL lexer's handling of character literals and escape characters in strings. +
  • +
  • + The Baan lexer checks that matches to 3rd set of keywords are function calls and leaves as identifiers if not. + Baan lexer and folder support #context_on / #context_off preprocessor feature. +
  • +
  • + The C++ lexer improved preprocessor conformance.
    + Default value of 0 for undefined preprocessor symbols.
    + #define A is treated as #define A 1.
    + "defined A" removes "A" before replacing "defined" with value. + Bug #1966. +
  • +
  • + The Python folder treats triple-quoted f-strings like triple-quoted strings. + Bug #1977. +
  • +
  • + The SQL lexer uses sql.backslash.escapes for double quoted strings. + Bug #1968. +
  • +
  • + The Matlab lexer treats 'end' as a number rather than a keyword when used as a index. + This also stops incorrect folding. + Bug #1951. +
  • +
  • + The Matlab folder implements "fold", "fold.comment", and "fold.compact" properties. + Bug #1965. +
  • +
  • + The Rust lexer recognizes 'usize' numeric literal suffixes. + Bug #1919. +
  • +
  • + Minor undefined behaviour fixed. + Bug #1978. +
  • +
  • + Fix double tap word selection on Windows 10 1709 Fall Creators Update. + Bug #1983. +
  • +
  • + Fix closing autocompletion lists on Cocoa for macOS 10.13 where the window + was emptying but staying visible. + Bug #1981. +
  • +
  • + Fix Cocoa hang when Scintilla loaded from SMB share on macOS 10.13. + Bug #1979. +
  • +
  • + On Cocoa, improve scrolling on macOS 10.12. + Bug #1885. +
  • +
  • + On Cocoa, fix line selection by clicking in the margin when scrolled. + Bug #1971. +
  • +
  • + Ensure redraw when application changes overtype mode so caret change visible even when not blinking. + Notify application with SC_UPDATE_SELECTION when overtype changed - previously + sent SC_UPDATE_CONTENT. +
  • +
  • + Fix drawing failure when in wrap mode for delete to start/end of line which + affects later lines but did not redraw them. + Also fixed drawing for wrap mode on GTK+ 2.x. + Bug #1949. +
  • +
  • + On GTK+ fix drawing problems including incorrect scrollbar redrawing and flickering of text. + Bug #1876. +
  • +
  • + On Linux, both for GTK+ and Qt, the default modifier key for rectangular selection is now Alt. + This is the same as Windows and macOS. + This was changed from Ctrl as window managers are less likely to intercept Alt+Drag for + moving windows than in the past. +
  • +
  • + On Cocoa, fix doCommandBySelector but avoid double effect of 'delete' + key. + Bug #1958. +
  • +
  • + On Qt, the updateUi signal includes the 'updated' flags. + No updateUi signal is sent for focus in events. + These changes make Qt behave more like the other platforms. +
  • +
  • + On Qt, dropping files on Scintilla now fires the SCN_URIDROPPED notification + instead of inserting text. +
  • +
  • + On Qt, focus changes send the focusChanged signal. + Bug #1957. +
  • +
  • + On Qt, mouse tracking is reenabled when the window is reshown. + Bug #1948. +
  • +
  • + On Windows, the DirectWrite modes SC_TECHNOLOGY_DIRECTWRITEDC and + SC_TECHNOLOGY_DIRECTWRITERETAIN are no longer provisional. +
  • +
+

+ Release 3.7.6 +

+
    +
  • + Released 8 August 2017. +
  • +
  • + This is the first release of the + long term branch + which avoids using features from C++14 or later in order to support older systems. +
  • +
  • + The Baan lexer correctly highlights numbers when followed by an operator. +
  • +
  • + On Cocoa, fix a bug with retrieving encoded bytes. +
  • +
+

+ Release 3.7.5 +

+
    +
  • + Released 26 May 2017. +
  • +
  • + This is the final release of SciTE 3.x. +
  • +
  • + Support dropped for Microsoft Visual C++ 2013 due to increased use of C++11 features. +
  • +
  • + Added a caret line frame as an alternative visual for highlighting the caret line. +
  • +
  • + Added "Reverse Selected Lines" feature. +
  • +
  • + SciTE adds "Select All Bookmarks" command. +
  • +
  • + SciTE adds a save.path.suggestion setting to suggest a file name when saving an + unnamed buffer. +
  • +
  • + Updated case conversion and character categories to Unicode 9. +
  • +
  • + The Baan lexer recognizes numeric literals in a more compliant manner including + hexadecimal numbers and exponentials. +
  • +
  • + The Bash lexer recognizes strings in lists in more cases. + Bug #1944. +
  • +
  • + The Fortran lexer recognizes a preprocessor line after a line continuation &. + Bug #1935. +
  • +
  • + The Fortran folder can fold comments. + Bug #1936. +
  • +
  • + The PowerShell lexer recognizes escaped quotes in strings. + Bug #1929. +
  • +
  • + The Python lexer recognizes identifiers more accurately when they include non-ASCII characters. +
  • +
  • + The Python folder treats comments at the end of the file as separate from the preceding structure. +
  • +
  • + The YAML lexer recognizes comments in more situations and styles a + "..." line like a "---" line. + Bug #1931. +
  • +
  • + Update scroll bar when annotations added, removed, or visibility changed. + Feature #1187. +
  • +
  • + Canceling modes with the Esc key preserves a rectangular selection. + Bug #1940. +
  • +
  • + Builds are made with a sorted list of lexers to be more reproducible. + Bug #1946. +
  • +
  • + On Cocoa, a leak of mouse tracking areas was fixed. +
  • +
  • + On Cocoa, the autocompletion is 4 pixels wider to avoid text truncation. +
  • +
  • + On Windows, stop drawing a focus rectangle on the autocompletion list and + raise the default list length to 9 items. +
  • +
  • + SciTE examines at most 1 MB of a file to automatically determine indentation + for indent.auto to avoid a lengthy pause when loading very large files. +
  • +
  • + SciTE user interface uses lighter colours and fewer 3D elements to match current desktop environments. +
  • +
  • + SciTE sets buffer dirty and shows message when file deleted if load.on.activate on. +
  • +
  • + SciTE on Windows Find strip Find button works in incremental no-close mode. + Bug #1926. +
  • +
+

+ Release 3.7.4 +

+
    +
  • + Released 21 March 2017. +
  • +
  • + Requires a C++11 compiler. GCC 4.8 and MSVC 2015 are supported. +
  • +
  • + Support dropped for Windows NT 4. +
  • +
  • + Accessibility support may be queried with SCI_GETACCESSIBILITY. + On GTK+, accessibility may be disabled by calling SCI_SETACCESSIBILITY. +
  • +
  • + Lexer added for "indent" language which is styled as plain text but folded by indentation level. +
  • +
  • + The Progress ABL lexer handles nested comments where comment starts or ends + are adjacent like "/*/*" or "*/*/". +
  • +
  • + In the Python lexer, improve f-string support. + Add support for multiline expressions in triple quoted f-strings. + Handle nested "()", "[]", and "{}" in f-string expressions and terminate expression colouring at ":" or "!". + End f-string if ending quote is seen in a "{}" expression. + Fix terminating single quoted f-string at EOL. + Bug #1918. +
  • +
  • + The VHDL folder folds an "entity" on the first line of the file. +
  • +
  • + For IMEs, do not clear selected text when there is no composition text to show. +
  • +
  • + Fix to crash with fold tags where line inserted at start. +
  • +
  • + Fix to stream selection mode when moving caret up or down. + Bug #1905. +
  • +
  • + Drawing fixes for fold tags include fully drawing lines and not overlapping some + drawing and ensuring edges and mark underlines are visible. +
  • +
  • + Fix Cocoa failure to display accented character chooser for European + languages by partially reverting a change made to prevent a crash with + Chinese input by special-casing the Cangjie input source. + Bug #1881. +
  • +
  • + Fix potential problems with IME on Cocoa when document contains invalid + UTF-8. +
  • +
  • + Fix crash on Cocoa with OS X 10.9 due to accessibility API not available. + Bug #1915. +
  • +
  • + Improved speed of accessibility code on GTK+ by using additional memory + as a cache. + Bug #1910. +
  • +
  • + Fix crash in accessibility code on GTK+ < 3.3.6 caused by previous bug fix. + Bug #1907. +
  • +
  • + Fix to prevent double scrolling on GTK+ with X11. + Bug #1901. +
  • +
  • + SciTE on GTK+ adds an "accessibility" property to allow disabling accessibility + on GTK+ as an optimization. +
  • +
  • + SciTE on GTK+ has changed file chooser behaviour for some actions: + overwriting an existing file shows a warning; + the default session file name "SciTE.session" is shown and a "*.session" filter is applied; + appropriate filters are applied when exporting; + the current file name is displayed in "Save As" even when that file no longer exists. +
  • +
  • + SciTE fixed a bug where, on GTK+, when the output pane had focus, menu commands + performed by mouse were sent instead to the edit pane. +
  • +
  • + SciTE on Windows 8+ further restricts the paths searched for DLLs to the application + and system directories which may prevent some binary planting attacks. +
  • +
  • + Fix failure to load Direct2D on Windows when used on old versions of Windows. + Bug #1653. +
  • +
+

+ Release 3.7.3 +

+
    +
  • + Released 19 February 2017. +
  • +
  • + Display block caret over the character at the end of a selection to be similar + to other editors. +
  • +
  • + In SciTE can choose colours for fold markers. + Feature #1172. +
  • +
  • + In SciTE can hide buffer numbers in tabs. + Feature #1173. +
  • +
  • + The Diff lexer recognizes deleted lines that start with "--- ". +
  • +
  • + The Lua lexer requires the first line to start with "#!" to be treated as a shebang comment, + not just "#". + Bug #1900. +
  • +
  • + The Matlab lexer requires block comment start and end to be alone on a line. + Bug #1902. +
  • +
  • + The Python lexer supports f-strings with new styles, allows Unicode identifiers, + and no longer allows @1 to be a decorator. + Bug #1848. +
  • +
  • + Fix folding inconsistency when fold header added above a folded part. + Avoid unnecessary unfolding when a deletion does not include a line end. + Bug #1896. +
  • +
  • + Fix finalization crash on Cocoa. + Bug #1909. +
  • +
  • + SciTE on GTK+ can have a wide divider between the panes with the + split.wide property. +
  • +
  • + Fix display of autocompletion lists and calltips on GTK+ 3.22 on Wayland. + Newer APIs used on GTK+ 3.22 as older APIs were deprecated. +
  • +
  • + Fix crash in accessibility code on GTK+ due to signal receipt after destruction. + Bug #1907. +
  • +
  • + Make trackpad scrolling work on Wayland. + Bug #1901. +
  • +
+

+ Release 3.7.2 +

+
    +
  • + Released 30 December 2016. +
  • +
  • + Minimize redrawing for SCI_SETSELECTIONN* APIs. + Bug #1888. +
  • +
  • + Use more precision to allow selecting individual lines in files with + more than 16.7 million lines. +
  • +
  • + For Qt 5, define QT_WS_MAC or QT_WS_X11 on those platforms. + Bug #1887. +
  • +
  • + For Cocoa, fix crash on view destruction with macOS 10.12.2. + Bug #1891. +
  • +
  • + Fix crash on GTK+ <3.8 due to incorrect lifetime of accessibility object. + More accurate reporting of attribute ranges and deletion lengths for accessibility. +
  • +
  • + In SciTE, if a Lua script causes a Scintilla failure exception, display error + message in output pane instead of exiting. + Bug #1773. +
  • +
+

+ Release 3.7.1 +

+
    +
  • + Released 4 December 2016. +
  • +
  • + The Scintilla namespace is no longer applied to struct definitions in Scintilla.h even + when SCI_NAMESPACE defined. + Client code should not define SCI_NAMESPACE. +
  • +
  • + Structure names in Scintilla.h without prefixes are deprecated and will now only + be usable with INCLUDE_DEPRECATED_FEATURES defined.
    + Use the newer names with the "Sci_" prefix:
    + CharacterRange → Sci_CharacterRange
    + TextRange → Sci_TextRange
    + TextToFind → Sci_TextToFind
    + RangeToFormat → Sci_RangeToFormat
    + NotifyHeader → Sci_NotifyHeader +
  • +
  • + Previously deprecated features SC_CP_DBCS, SCI_SETUSEPALETTE. and SCI_GETUSEPALETTE + have been removed and can no longer be used in client code. +
  • +
  • + Accessibility support allowing screen readers to work added on GTK+ and Cocoa. +
  • +
  • + Textual tags may be displayed to the right on folded lines with SCI_TOGGLEFOLDSHOWTEXT. + This is commonly something like "{ ... }" or "<tr>...</tr>". + It is displayed with the STYLE_FOLDDISPLAYTEXT style and may have a box drawn around it + with SCI_FOLDDISPLAYTEXTSETSTYLE. +
  • +
  • + A mouse right-click over the margin may send an SCN_MARGINRIGHTCLICK event. + This only occurs when popup menus are turned off. + SCI_USEPOPUP now has three states: SC_POPUP_NEVER, SC_POPUP_ALL, or SC_POPUP_TEXT. +
  • +
  • + INDIC_POINT and INDIC_POINTCHARACTER indicators added to display small arrows + underneath positions or characters. +
  • +
  • + Added alternate appearance for visible tabs which looks like a horizontal line. + Controlled with SCI_SETTABDRAWMODE. + Feature #1165. +
  • +
  • + On Cocoa, a modulemap file is included to allow Scintilla to be treated as a module. + This makes it easier to use Scintilla from the Swift language. +
  • +
  • + Baan folder accommodates sections and lexer fixes definition of SCE_BAAN_FUNCDEF. +
  • +
  • + EDIFACT lexer and folder added. + Feature #1166. +
  • +
  • + JSON folder fixed where it didn't resume folding with the correct fold level. +
  • +
  • + Matlab folder based on syntax instead of indentation so more accurate. + Bug #1692. +
  • +
  • + YAML lexer fixed style of references and keywords when followed by a comment. + Bug #1872. +
  • +
  • + Margin click to select line now clears rectangular and additional selections. +
  • +
  • + Fixed a NULL access bug on GTK+ where the scrollbars could be used during destruction. + Bug #1873. +
  • +
  • + A potential bug on GTK+ fixed where asynchronous clipboard could be delivered after its + target Scintilla instance was destroyed. +
  • +
  • + Cocoa IME made more compliant with documented behaviour to avoid bugs that caused + huge allocations. + Bug #1881. +
  • +
  • + On Win32 fix EM_SETSEL to match Microsoft documentation.. + Bug #1886. +
  • +
  • + SciTE on GTK+ allows localizing tool bar tool tips. + Feature #1167. +
  • +
  • + SciTE on Windows restores focus to edit pane after closing user strip. +
  • +
  • + SciTE measures files larger that 2 GB which allows it to refuse to open huge files more consistently + and to show better warning messages. +
  • +
+

+ Release 3.7.0 +

+
    +
  • + Released 16 October 2016. +
  • +
  • + Word selection, navigation, and manipulation is now performed on characters instead of bytes + leading to more natural behaviour for multi-byte encodings like UTF-8. + For UTF-8 characters 0x80 and above, classification into word; punctuation; space; or line-end + is based on the Unicode general category of the character and is not customizable. + Bug #1832. +
  • +
  • + Two enums changed in Scintilla.iface which may lead to changed bindings. + There were 2 FontQuality enums and the first is now PhasesDraw. + The prefix for FoldAction was SC_FOLDACTION and is now SC_FOLDACTION_ + which is similar to other enums. + These changes do not affect the standard C/C++ binding. +
  • +
  • + EDGE_MULTILINE and SCI_MULTIEDGEADDLINE added to allow displaying multiple + vertical edges simultaneously. +
  • +
  • + The number of margins can be changed with SCI_SETMARGINS. +
  • +
  • + Margin type SC_MARGIN_COLOUR added so that the application may + choose any colour for a margin with SCI_SETMARGINBACKN. +
  • +
  • + On Win32, mouse wheel scrolling can be restricted to only occur when the mouse is + within the window. +
  • +
  • + The WordList class in lexlib used by lexers adds an InListAbridged method for + matching keywords that have particular prefixes and/or suffixes. +
  • +
  • + The Baan lexer was changed significantly with more lexical states, keyword sets, + and support for abridged keywords. +
  • +
  • + The CoffeeScript lexer styles interpolated code in strings. + Bug #1865. +
  • +
  • + The Progress lexer "progress" has been replaced with a new lexer "abl" + (Advanced Business Language) + with a different set of lexical states and more functionality. + The lexical state prefix has changed from SCE_4GL_ to SCE_ABL_. + Feature #1143. +
  • +
  • + The PowerShell lexer understands the grave accent escape character. + Bug #1868. +
  • +
  • + The YAML lexer recognizes inline comments. + Bug #1660. +
  • +
  • + SciTE on Windows can retain coloured selection when inactive with + selection.always.visible property. +
  • +
  • + SciTE on Windows adds a state to close.on.find to close the find strip when + a match is found. +
  • +
  • + Fix caret position after left or right movement with rectangular selection. + Bug #1861. +
  • +
  • + In SciTE, optional prefix argument added to scite.ConstantName method. + Bug #1860. +
  • +
  • + On Cocoa, include ILexer.h in the public headers of the framework. + Bug #1855. +
  • +
  • + On Cocoa, allow subclass of SCIContentView to set cursor. + Bug #1863. +
  • +
  • + On Cocoa, recognize the numeric keypad '+', '-', and '/' keys as + SCK_ADD, SCK_SUBTRACT, and SCK_DIVIDE. + Bug #1867. +
  • +
  • + On GTK+ 3.21+ fix incorrect font size in auto-completion list. + Bug #1859. +
  • +
  • + Fix SciTE crash when command.mode ends with comma. + Bug #1857. +
  • +
  • + SciTE on Windows has a full size toolbar icon for "Close". +
  • +
+

+ Release 3.6.7 +

+
    +
  • + Released 4 September 2016. +
  • +
  • + C++11 range-based for loops used in SciTE so GCC 4.6 is now the minimum supported version. +
  • +
  • + SC_CHARSET_DEFAULT now means code page 1252 on Windows unless a code page is set. + This prevents unexpected behaviour and crashes on East Asian systems where default locales are commonly DBCS. + Projects which want to default to DBCS code pages in East Asian locales should set the code page and + character set explicitly. +
  • +
  • + SCVS_NOWRAPLINESTART option stops left arrow from wrapping to the previous line. + Most commonly wanted when virtual space is used. + Bug #1648. +
  • +
  • + The C++ lexer can fold on #else and #elif with the fold.cpp.preprocessor.at.else property. + Bug #210. +
  • +
  • + The errorlist lexer detects warnings from Visual C++ which do not contain line numbers. +
  • +
  • + The HTML lexer no longer treats "<?" inside a string in a script as potentially starting an XML document. + Bug #767. +
  • +
  • + The HTML lexer fixes a problem resuming at a script start where the starting state continued + past where it should. + Bug #1849. +
  • +
  • + When inserting spaces for virtual space and the position is in indentation and tabs are enabled + for indentation then use tabs. + Bug #1850. +
  • +
  • + Fix fold expand when some child text not styled. + Caused by fixes for Bug #1799. + Bug #1842. +
  • +
  • + Fix key binding bug on Cocoa for control+. + Bug #1854. +
  • +
  • + Fix scroll bar size warnings on GTK+ caused by #1831. + Bug #1851. +
  • +
  • + Small fixes for GTK+ makefile. + Bug #1844. + Bug #1845. + Bug #1846. +
  • +
  • + Fix SciTE indentation after code like "void function () {}". +
  • +
  • + Fix SciTE global regex replace of "^" with something which missed the line after empty + lines with LF line ends. + Bug #1839. +
  • +
  • + Fix SciTE on GTK+ 3.20 bug where toggle buttons on find and replace strips + did not show active state. + Bug #1853. +
  • +
+

+ Release 3.6.6 +

+
    +
  • + Released 24 May 2016. +
  • +
  • + C++ 11 <regex> support built by default. Can be disabled by defining NO_CXX11_REGEX. +
  • +
  • + SciTE_USERHOME environment variable allows separate location for writeable properties files. + Feature #965. +
  • +
  • + GObject introspection supports notify and command events. +
  • +
  • + The Progress lexer now allows comments preceded by a tab. +
  • +
  • + Scripts reading Scintilla.iface file include comments for enu and lex definitions. + Bug #1829. +
  • +
  • + Fix crashes on GTK+ if idle work active when destroyed. + Bug #1827. +
  • +
  • + Fixed bugs when used on GTK+ 3.20. + Bug #1825. + Bug #1831. +
  • +
  • + Fix SciTE search field background with dark theme on GTK+ 2.x. + Bug #1826. +
  • +
  • + Fixed bug on Win32 that allowed resizing autocompletion from bottom when it was + located above the caret. +
  • +
  • + On Win32, when using a screen reader and selecting text using Shift+Arrow, + fix bug when scrolling made the caret stay at the same screen location + so the screen reader did not speak the added or removed selection. +
  • +
+

+ Release 3.6.5 +

+
    +
  • + Released 26 April 2016. +
  • +
  • + JSON lexer added. + Feature #1140. +
  • +
  • + The C++ lexer fixes a bug with multi-line strings with line continuation where the string style + overflowed after an edit. + Bug #1824. +
  • +
  • + The Python lexer treats '@' as an operator except when it is the first visible character on a line. + This is for Python 3.5. +
  • +
  • + The Rust lexer allows '?' as an operator. + Feature #1146. +
  • +
  • + Doubled size of compiled regex buffer. + Bug #1822. +
  • +
  • + For GTK+, the Super modifier key can be used in key bindings. + Feature #1142. +
  • +
  • + For GTK+, fix some crashes when using multiple threads. +
  • +
  • + Platform layer font cache removed on GTK+ as platform-independent caches are used. + This avoids the use of thread locking and initialization of threads so any GTK+ + applications that rely on Scintilla initializing threads will have to do that themselves. +
  • +
  • + SciTE bug fixed with exported HTML where extra line shown. + Bug #1816. +
  • +
  • + SciTE on Windows fixes bugs with pop-up menus in the find and replace strips. + For the replace strip, menu choices change the state. + For the find strip, menu choices are reflected in the appearance of their corresponding buttons. +
  • +
  • + SciTE on Windows on high DPI displays fixes the height of edit boxes in user strips. +
  • +
+

+ Release 3.6.4 +

+
    +
  • + Released 13 March 2016. +
  • +
  • + SciTE allows setting the autocompletion type separator character. +
  • +
  • + The C++ folder folds code on '(' and ')' to allow multi-line calls to be folded. + Feature #1138. +
  • +
  • + For the HTML lexer, limit the extent of Mako line comments to finish before + the line end characters. +
  • +
  • + Folds unfolded when two fold regions are merged by either deleting an intervening line + or changing its fold level by adding characters. + This was fixed both in Scintilla and in SciTE's equivalent code. + Bug #1799.
    +
  • +
  • + The Progress lexer supports hexadecimal numeric literals, + single-line comments, abbreviated keywords and + extends nested comments to unlimited levels. +
  • +
  • + Ruby lexer treats alternate hash key syntax "key:" as a symbol. + Bug #1810. +
  • +
  • + Rust lexer handles bracketed Unicode string escapes like "\u{123abc}". + Bug #1809. +
  • +
  • + For GTK+ on Windows fix 64-bit build which was broken in 3.6.3. +
  • +
  • + For Qt, release builds have assertions turned off. +
  • +
  • + For Qt on Windows, fix compilation failure for Qt 4.x. +
  • +
  • + IME target range displayed on Qt for OS X. +
  • +
  • + On Windows, make clipboard operations more robust by retrying OpenClipboard if it fails + as this may occur when another application has opened the clipboard. +
  • +
  • + On Windows back out change that removed use of def file to ensure + Scintilla_DirectFunction exported without name mangling. + Bug #1813. +
  • +
  • + On GTK+ and Qt over Win32 in Korean fix bug caused by last release's word input change. +
  • +
  • + For SciTE, more descriptive error messages are displayed when there are problems loading the + Lua startup script. + Feature #1139. +
  • +
+

+ Release 3.6.3 +

+
    +
  • + Released 18 January 2016. +
  • +
  • + Allow painting without first styling all visible text then styling in the background + using idle-time. This helps performance when scrolling down in very large documents. + Can also incrementally style after the visible area to the end of the document so that + the document is already styled when the user scrolls to it. +
  • +
  • + Support GObject introspection on GTK+. +
  • +
  • + SciTE supports pasting to each selection with the selection.multipaste setting. + Feature #1123. +
  • +
  • + SciTE can optionally display a read-only indicator on tabs and in the Buffers menu. +
  • +
  • + Bash lexer flags incomplete here doc delimiters as syntax errors. + Bug #1789.
    + Support added for using '#' in non-comment ways as is possible with zsh. + Bug #1794.
    + Recognize more characters as here-doc delimiters. + Bug #1778. +
  • +
  • + Errorlist lexer highlights warning messages from the Microsoft linker. +
  • +
  • + Errorlist lexer fixes bug with final line in escape sequence recognition mode. +
  • +
  • + Lua lexer includes '&' and '|' bitwise operators for Lua 5.3. + Bug #1790. +
  • +
  • + Perl lexer updated for Perl 5.20 and 5.22.
    + Allow '_' for subroutine prototypes. + Bug #1791.
    + Double-diamond operator <<>>.
    + Hexadecimal floating point literals.
    + Repetition in list assignment. + Bug #1793.
    + Highlight changed subroutine prototype syntax for Perl 5.20. + Bug #1797.
    + Fix module ::-syntax when special characters such as 'x' are used.
    + Added ' and " detection as prefix chars for x repetition operator. + Bug #1800. +
  • +
  • + Visual Prolog lexer recognizes numbers more accurately and allows non-ASCII verbatim + quoting characters. + Feature #1130. +
  • +
  • + Send SCN_UPDATEUI with SC_UPDATE_SELECTION when the application changes multiple + selection. +
  • +
  • + Expand folded areas before deleting fold header line. + Bug #1796. +
  • +
  • + Treat Unicode line ends like common line ends when maintaining fold state. +
  • +
  • + Highlight whole run for hover indicator when wrapped. + Bug #1784. +
  • +
  • + On Cocoa, fix crash when autocompletion list closed during scroll bounce-back. + Bug #1788. +
  • +
  • + On Windows, fix non-BMP input through WM_CHAR and allow WM_UNICHAR to work + with non-BMP characters and on non-Unicode documents. + Bug #1779. +
  • +
  • + On Windows using DirectWrite, for ligatures and other character clusters, + display caret and selections part-way through clusters so that the caret doesn't stick + to the end of the cluster making it easier to understand editing actions. +
  • +
  • + On Windows, Scintilla no longer uses a .DEF file during linking as it duplicates + source code directives. +
  • +
  • + On GTK+ and Qt, Korean input by word fixed. +
  • +
  • + On GTK+, Qt, and Win32 block IME input when document is read-only or any selected text + is protected. +
  • +
  • + On GTK+ on OS X, fix warning during destruction. + Bug #1777. +
  • +
  • + Fix SciTE crashes when using LPEG lexers. +
  • +
+

+ Release 3.6.2 +

+
    +
  • + Released 6 November 2015. +
  • +
  • + Whitespace may be made visible just in indentation. +
  • +
  • + Whitespace dots are centred when larger than 1 pixel. +
  • +
  • + The Scintilla framework on Cocoa now contains version numbers. +
  • +
  • + SciTE's standard properties collect values from all active .properties file to produce the Language menu + and the file types pull-down in the File open dialog. +
  • +
  • + The single executable version of SciTE, Sc1, uses 'module' statements within its embedded + properties. This makes it act more like the full distribution allowing languages to be turned on + and off by setting imports.include and imports.exclude. + The default imports.exclude property adds eiffel, erlang, ps, and pov so these languages are + turned off by default. +
  • +
  • + SciTE adds an output.blank.margin.left property to allow setting the output pane + margin to a different width than the edit pane. +
  • +
  • + CoffeeScript lexer highlights ranges correctly. + Bug #1765. +
  • +
  • + Markdown lexer treats line starts consistently to always highlight *foo* or similar at line start. + Bug #1766. +
  • +
  • + Optimize marker redrawing by only drawing affected lines when markers shown in the text. +
  • +
  • + On Cocoa, timers and idling now work in modal dialogs. This also stops some crashes. +
  • +
  • + On Cocoa, fix crashes when deleting a ScintillaView. These crashes could occur when scrolling + at the time the ScintillaView was deleted although there may have been other cases. +
  • +
  • + On GTK+ 2.x, fix height of lines in autocompletion lists. + Bug #1774. +
  • +
  • + Fix bug with SCI_LINEENDDISPLAY where the caret moved to the next document line instead of the + end of the display line. + Bug #1772. +
  • +
  • + Report error (SC_STATUS_FAILURE) when negative length passed to SCI_SETSTYLING. + Bug #1768. +
  • +
  • + When SC_MARK_UNDERLINE is not assigned to a margin, stop drawing the whole line. +
  • +
  • + When reverting an untitled document in SciTE, just clear it with no message about a file. + Bug #1764. +
  • +
  • + SciTE on GTK+ allows use of Ctrl+A (Select All) inside find and replace strips. + Bug #1769. +
  • +
+

+ Release 3.6.1 +

+
    +
  • + Released 15 September 2015. +
  • +
  • + The oldest version of GTK+ supported now is 2.18 and for glib it is 2.22. +
  • +
  • + On GTK+, SC_CHARSET_OEM866 added to allow editing Russian files encoded in code page 866. + Feature #1019. +
  • +
  • + On Windows, reconversion is performed when requested by the IME. +
  • +
  • + CoffeeScript lexer adds lexical class for instance properties and fixes some cases of regex highlighting. + Bug #1749. +
  • +
  • + The errorlist lexer understands some ANSI escape sequences to change foreground colour and intensity. + This is sufficient to colour diagnostic output from gcc and clang when -fdiagnostics-color set. +
  • +
  • + The errorlist lexer allows the line number to be 0 in GCC errors as some tools report whole file + errors as line 0. +
  • +
  • + MySql lexer fixes empty comments /**/ so the comment state does not continue. +
  • +
  • + VHDL folder supports "protected" keyword. +
  • +
  • + Treat CRLF line end as two characters in SCI_COUNTCHARACTERS. + Bug #1757. +
  • +
  • + On GTK+ 3.x, fix height of lines in autocompletion lists to match the font. + Switch from deprecated style calls to CSS styling. + Removed setting list colours on GTK+ 3.16+ as no longer appears needed. +
  • +
  • + On GTK+, avoid "Invalid rectangle passed" warning messages by never reporting the client + rectangle with a negative width or height. + Bug #1743. +
  • +
  • + On Cocoa, copy Sci_Position.h into the framework so clients can build. +
  • +
  • + On Cocoa fix bug with drag and drop that could lead to crashes. + Bug #1751. +
  • +
  • + Fix SciTE disk exhaustion bug by reporting failures when writing files. + Bug #1760. +
  • +
  • + Fix find strip in SciTE on Windows XP to be visible. +
  • +
  • + SciTE on Windows changes the way it detects that a tool has finished executing to ensure all output data + from the process is read. +
  • +
  • + SciTE on Windows improves the time taken to read output from tools that produce a large amount + of output by a factor of around 10. +
  • +
  • + On GTK+ the keyboard command for View | End of Line was changed to Ctrl+Shift+N + to avoid clash with Search | Selection Add Next. + Bug #1750. +
  • +
+

+ Release 3.6.0

  • @@ -493,7 +2156,7 @@
  • External interfaces use the Sci_Position and Sci_PositionU typedefs instead of int and unsigned int - to allow for changes to a 64-bit interface on 64-bit plactforms in the future. + to allow for changes to a 64-bit interface on 64-bit platforms in the future. Applications and external lexers should start using the new type names so that they will be compatible when the 64-bit change occurs. There is also Sci_PositionCR (long) for use in the Sci_CharacterRange struct which will @@ -508,7 +2171,7 @@
  • Autocompletion lists send an SCN_AUTOCCOMPLETED notification after the text has been inserted. - Feature #1109. + Feature #1109.
  • The case mode style attribute can now be SC_CASE_CAMEL. @@ -538,7 +2201,7 @@
  • On Cocoa fix problems with positioning of autocompletion lists near screen edge or under dock. Cancel autocompletion when window moved. - Bug #1740. + Bug #1740.
  • Fix drawing problem when control characters are in a hidden style as they then @@ -550,7 +2213,7 @@
  • Fix bug on GTK+ with scroll bars leaking. - Bug #1742. + Bug #1742.
  • LexOthers.cxx file split into one file per lexer: LexBatch, LexDiff, @@ -567,7 +2230,7 @@

- Release 3.5.7 + Release 3.5.7

  • @@ -589,15 +2252,15 @@ Added SCI_TARGETWHOLEDOCUMENT to set the target to the whole document.
  • - Verilog lexer recognises protected regions and the folder folds protected regions. + Verilog lexer recognizes protected regions and the folder folds protected regions.
  • A performance problem with markers when deleting many lines was fixed. - Bug #1733. + Bug #1733.
  • On Cocoa fix crash when ScintillaView destroyed if no autocompletion ever displayed. - Bug #1728. + Bug #1728.
  • On Cocoa fix crash in drag and drop. @@ -605,7 +2268,7 @@
  • On GTK+ 3.4+, when there are both horizontal and vertical scrollbars, draw the lower-right corner so that it does not appear black when text selected. - Bug #1611. + Bug #1611.
  • Fixed most calls deprecated in GTK+ 3.16. Does not fix style override calls @@ -617,7 +2280,7 @@

- Release 3.5.6 + Release 3.5.6

  • @@ -632,15 +2295,15 @@
  • C++ lexer fixes empty backquoted string. - Bug #1711. + Bug #1711.
  • C++ lexer fixes #undef directive. - Bug #1719. + Bug #1719.
  • Fortran folder fixes handling of "selecttype" and "selectcase". - Bug #1724. + Bug #1724.
  • Verilog folder folds interface definitions. @@ -651,19 +2314,19 @@
  • Fix bug when drawing text margins in buffered mode which would use default encoding instead of chosen encoding. - Bug #1703. + Bug #1703.
  • Fix bug with Korean Hanja conversions in DBCS encoding on Windows.
  • Fix for reading a UTF-16 file in SciTE where a non-BMP character is split over a read buffer boundary. - Bug #1710. + Bug #1710.
  • Fix bug on GTK+ 2.x for Windows where there was an ABI difference between compiler version. - Bug #1726. + Bug #1726.
  • Fix undo bug on Cocoa that could lose data.. @@ -676,15 +2339,15 @@
  • SciTE does not report twice that a search string can not be found when "Replace" pressed. - Bug #1716. + Bug #1716.
  • SciTE on GTK+ 3.x disables arrow in search combo when no entries. - Bug #1717. + Bug #1717.

- Release 3.5.5 + Release 3.5.5

  • @@ -697,7 +2360,7 @@
  • The wxWidgets-specific ascent member of Font has been removed which breaks compatibility with current wxStyledTextCtrl. - Bug #1682. + Bug #1682.
  • IME on Qt supports multiple carets and behaves more like other platforms. @@ -711,7 +2374,7 @@
  • TCL lexer reverts change to string handling. - Bug #1642. + Bug #1642.
  • Verilog lexer fixes bugs with macro styling. @@ -727,28 +2390,28 @@
  • Fix leak on Cocoa with autocompletion lists. - Bug #1706. + Bug #1706.
  • Fix potential crash on Cocoa with drag and drop. - Bug #1709. + Bug #1709.
  • Fix bug on Windows when compiling with MinGW-w64 which caused text to not be drawn when in wrap mode. - Bug #1705. + Bug #1705.
  • Fix SciTE bug with missing file open filters and add hex to excluded set of properties files so that its settings don't appear. - Bug #1707. + Bug #1707.
  • Fix SciTE bug where files without extensions like "makefile" were not highlighted correctly.

- Release 3.5.4 + Release 3.5.4

  • @@ -782,18 +2445,18 @@
  • Rust lexer accepts new 'is'/'us' integer suffixes instead of 'i'/'u'. - Bug #1098. + Bug #1098.
  • Ruby folder can fold multiline comments. - Bug #1697. + Bug #1697.
  • SQL lexer fixes a bug with the q-quote operator.
  • TCL lexer fixes a bug with some strings. - Bug #1642. + Bug #1642.
  • Verilog lexer handles escaped identifiers that begin with \ and end with space like \reset* . @@ -811,14 +2474,14 @@
  • Fix adaptive scrolling speed for GTK+ on OS X with GTK Quartz backend (as opposed to X11 backend). - Bug #1696. + Bug #1696.
  • Fix position of autocompletion and calltips on Cocoa when there were two screens stacked vertically.
  • Fix crash in SciTE when saving large files in background when closing application. - Bug #1691. + Bug #1691.
  • Fix decoding of MSVC warnings in SciTE so that files in the C:\Program Files (x86)\ directory can be opened. @@ -829,7 +2492,7 @@

- Release 3.5.3 + Release 3.5.3

- Release 3.5.2 + Release 3.5.2

  • @@ -920,7 +2583,7 @@
  • ANNOTATION_INDENTED added which is similar to ANNOTATION_BOXED in terms of positioning but does not show a border. - Feature #1086. + Feature #1086.
  • Allow platform overrides for drawing tab arrows, wrap markers, and line markers. @@ -929,23 +2592,23 @@
  • CoffeeScript lexer fixes "/*" to not be a comment. - Bug #1420. + Bug #1420.
  • VHDL folder fixes "block" keyword. - Bug #1664. + Bug #1664.
  • Prevent caret blinking when holding down Delete key. - Bug #1657. + Bug #1657.
  • On Windows, allow right click selection in popup menu. - Feature #1080. + Feature #1080.
  • On Windows, only call ShowCaret in GDI mode as it interferes with caret drawing when using Direct2D. - Bug #1643. + Bug #1643.
  • On Windows, another DirectWrite mode SC_TECHNOLOGY_DIRECTWRITEDC added @@ -955,22 +2618,22 @@
  • On Windows, avoid processing mouse move events where the mouse has not moved as these can cause unexpected dwell start notifications. - Bug #1670. + Bug #1670.
  • For GTK+ on Windows, avoid extra space when pasting from external application.
  • On GTK+ 2.x allow Scintilla to be used inside tool tips by changing when preedit window created. - Bug #1662. + Bug #1662.
  • Support MinGW compilation under Linux. - Feature #1077. + Feature #1077.

- Release 3.5.1 + Release 3.5.1

  • @@ -978,22 +2641,22 @@
  • BibTeX lexer added. - Feature #1071. + Feature #1071.
  • SQL lexer supports the q-quote operator as SCE_SQL_QOPERATOR(24).
  • VHDL lexer supports block comments. - Bug #1527. + Bug #1527.
  • VHDL folder fixes case where "component" used before name. - Bug #613. + Bug #613.
  • Restore fractional pixel tab positioning which was truncated to whole pixels in 3.5.0. - Bug #1652. + Bug #1652.
  • Allow choice between windowed and inline IME on some platforms. @@ -1001,14 +2664,14 @@
  • On GTK+ cache autocomplete window to avoid platform bug where windows were sometimes lost. - Bug #1649. + Bug #1649.
  • On GTK+ size autocomplete window more accurately.
  • On Windows only unregister windows classes registered. - Bug #1639. + Bug #1639.
  • On Windows another DirectWrite mode SC_TECHNOLOGY_DIRECTWRITERETAIN added @@ -1017,14 +2680,14 @@
  • On Windows support the Visual Studio 2010+ clipboard format that indicates a line copy. - Bug #1636. + Bug #1636.
  • SciTE session files remember the scroll position.

- Release 3.5.0 + Release 3.5.0

  • @@ -1039,8 +2702,8 @@ as required. This saves power as there are fewer wake ups. On recent releases of OS X Cocoa and Windows, coalescing timers are used to further save power. - Bug #1086. - Bug #1532. + Bug #1086. + Bug #1532.
  • Explicit tab stops may be set for each line. @@ -1058,24 +2721,24 @@
  • HTML lexer fixes a crash with SGML after a Mako comment. - Bug #1622. + Bug #1622.
  • KiXtart lexer adds a block comment state. - Feature #1053. + Feature #1053.
  • Matlab lexer fixes transpose operations like "X{1}'". - Bug #1629. + Bug #1629.
  • Ruby lexer fixes bugs with the syntax of symbols including allowing a symbol to end with '?'. - Bug #1627. + Bug #1627.
  • Rust lexer supports byte string literals, naked CR can be escaped in strings, and files starting with "#![" are not treated as starting with a hashbang comment. - Feature #1063. + Feature #1063.
  • Bug fixed where style data was stale when deleting a rectangular selection. @@ -1085,34 +2748,34 @@
  • Bug fixed where selection not redrawn after SCI_DELWORDRIGHT. - Bug #1633. + Bug #1633.
  • Change the function prototypes to be complete for functions exported as "C". - Bug #1618. + Bug #1618.
  • Fix a memory leak on GTK+ with autocompletion lists. - Bug #1638. + Bug #1638.
  • On GTK+, use the full character width for the overstrike caret for multibyte characters.
  • On Qt, set list icon size to largest icon. Add padding on OS X. - Bug #1634. + Bug #1634.
  • On Qt, fix building on FreeBSD 9.2. - Bug #1635. + Bug #1635.
  • On Qt, add a get_character method on the document. - Feature #1064. + Feature #1064.
  • On Qt, add SCI_* for methods to ScintillaConstants.py. - Feature #1065. + Feature #1065.
  • SciTE on GTK+ crash fixed with Insert Abbreviation command. @@ -1123,11 +2786,11 @@
  • Fix SciTE bug where toggle bookmark did not work after multiple lines with bookmarks merged. - Bug #1617. + Bug #1617.

- Release 3.4.4 + Release 3.4.4

  • @@ -1144,7 +2807,7 @@
  • C++ lexer fixes crash for "#define x(". - Bug #1614. + Bug #1614.
  • C++ lexer fixes raw string recognition so that R"xxx(blah)xxx" is styled as SCE_C_STRINGRAW. @@ -1157,15 +2820,15 @@
  • TCL lexer fixes names of keyword sets. - Bug #1615. + Bug #1615.
  • Shell lexer fixes fold matching problem caused by "<<<". - Bug #1605. + Bug #1605.
  • Fix bug where indicators were not removed when fold highlighting on. - Bug #1604. + Bug #1604.
  • Fix bug on Cocoa where emoji were treated as being zero width. @@ -1195,19 +2858,19 @@
  • Fix crash in SciTE when stream comment performed at line end. - Bug #1610. + Bug #1610.
  • For SciTE on Windows, display error message when common dialogs fail. - Bug #156. + Bug #156.
  • - For SciTE on GTK+ fix bug with initialisation of toggle buttons in find and replace strips. - Bug #1612. + For SciTE on GTK+ fix bug with initialization of toggle buttons in find and replace strips. + Bug #1612.

- Release 3.4.3 + Release 3.4.3

  • @@ -1218,7 +2881,7 @@

- Release 3.4.2 + Release 3.4.2

  • @@ -1230,7 +2893,7 @@
  • DMIS lexer added. DMIS is a language for coordinate measuring machines. - Feature #1049. + Feature #1049.
  • Line state may be displayed in the line number margin to aid in debugging lexing and folding with @@ -1241,7 +2904,7 @@ Some macros with arguments can be understood and these may be predefined in keyword set 4 (keywords5 for SciTE) with syntax similar to CHECKVERSION(x)=(x<3). - Feature #1051. + Feature #1051.
  • C++ lexer can highlight task marker keywords in comments as SCE_C_TASKMARKER. @@ -1251,7 +2914,7 @@
  • C++ lexer supports Go back quoted raw string literals with lexer.cpp.backquoted.strings option. - Feature #1047. + Feature #1047.
  • SciTE performs word and search match highlighting as an idle task to improve interactivity @@ -1259,22 +2922,22 @@
  • Bug fixed on Cocoa where previous caret lines were visible. - Bug #1593. + Bug #1593.
  • Bug fixed where caret remained invisible when period set to 0. - Bug #1592. + Bug #1592.
  • Fixed display flashing when scrolling with GTK+ 3.10. - Bug #1567. + Bug #1567.
  • Fixed calls and constants deprecated in GTK+ 3.10.
  • Fixed bug on Windows where WM_GETTEXT did not provide data in UTF-16 for Unicode window. - Bug #685. + Bug #685.
  • For SciTE, protect access to variables used by threads with a mutex to prevent data races. @@ -1290,7 +2953,7 @@
  • For SciTE on Windows, fix bug where invoking help resubmitted the running program. - Bug #272. + Bug #272.
  • SciTE's highlight current word feature no longer matches the selection when it contains space. @@ -1301,7 +2964,7 @@

- Release 3.4.1 + Release 3.4.1

  • @@ -1312,20 +2975,20 @@
  • Bug fixed where cursor down failed on wrapped lines. - Bug #1585. + Bug #1585.
  • Caret positioning changed a little to appear inside characters less often by rounding the caret position to the pixel grid instead of truncating. - Bug #1588. + Bug #1588.
  • Bug fixed where automatic indentation wrong when caret in virtual space. - Bug #1586. + Bug #1586.
  • Bug fixed on Windows where WM_LBUTTONDBLCLK was no longer sent to window. - Bug #1587. + Bug #1587.
  • Bug fixed with SciTE on Windows XP where black stripes appeared inside the find and @@ -1333,11 +2996,11 @@
  • Crash fixed in SciTE with recursive properties files. - Bug #1507. + Bug #1507.
  • Bug fixed with SciTE where Ctrl+E before an unmatched end brace jumps to file start. - Bug #315. + Bug #315.
  • Fixed scrolling on Cocoa to avoid display glitches and be smoother. @@ -1347,14 +3010,14 @@

- Release 3.4.0 + Release 3.4.0

  • Released 22 March 2014.
  • - The Unicode line ends and substyles features added as provisional in 3.2.5 are now finalised. + The Unicode line ends and substyles features added as provisional in 3.2.5 are now finalized. There are now no provisional features.
  • @@ -1378,21 +3041,21 @@
  • Fix Coffeescript lexer for keyword style extending past end of word. Also fixes styling 0...myArray.length all as a number. - Bug #1583. + Bug #1583.
  • Fix crashes and other bugs in Fortran folder by removing folding of do-label constructs.
  • Deleting a whole line deletes the annotations on that line instead of the annotations on the next line. - Bug #1577. + Bug #1577.
  • Changed position of tall calltips to prefer lower half of screen to cut off end instead of start.
  • Fix Qt bug where double click treated as triple click. - Bug #1575. + Bug #1575.
  • On Qt, selecting an item in an autocompletion list that is not currently visible positions it at the top. @@ -1409,7 +3072,7 @@

- Release 3.3.9 + Release 3.3.9

  • @@ -1417,11 +3080,11 @@
  • Fix 3.3.8 bug where external lexers became inaccessible. - Bug #1574. + Bug #1574.

- Release 3.3.8 + Release 3.3.8

  • @@ -1440,29 +3103,29 @@
  • Basic lexer highlights hex, octal, and binary numbers in FreeBASIC which use the prefixes &h, &o and &b respectively. - Feature #1041. + Feature #1041.
  • C++ lexer fixes bug where keyword followed immediately by quoted string continued keyword style. - Bug #1564. + Bug #1564.
  • Matlab lexer treats '!' differently for Matlab and Octave languages. - Bug #1571. + Bug #1571.
  • Rust lexer improved with nested comments, more compliant doc-comment detection, octal literals, NUL characters treated as valid, and highlighting of raw string literals and float literals fixed. - Feature #1038. - Bug #1570. + Feature #1038. + Bug #1570.
  • On Qt expose the EOLMode on the document object.
  • Fix hotspot clicking where area was off by half a character width. - Bug #1562. + Bug #1562.
  • Tweaked scroll positioning by either 2 pixels or 1 pixel when caret is at left or right of view @@ -1494,11 +3157,11 @@
  • SciTE displays a warning message when asked to open a directory. - Bug #1568. + Bug #1568.

- Release 3.3.7 + Release 3.3.7

  • @@ -1506,15 +3169,15 @@
  • Lexer added for DMAP language. - Feature #1026. + Feature #1026.
  • Basic lexer supports multiline comments in FreeBASIC. - Feature #1023. + Feature #1023.
  • Bash lexer allows '#' inside words.. - Bug #1553. + Bug #1553.
  • C++ lexer recognizes C++11 user-defined literals and applies lexical class SCE_C_USERLITERAL. @@ -1525,32 +3188,32 @@
  • C++ lexer fixes bug with #include statements without " or > terminating filename. - Bug #1538. + Bug #1538.
  • C++ lexer fixes split of Doxygen keywords @code{.fileExtension} and @param[in,out]. - Bug #1551. + Bug #1551.
  • C++ lexer styles Doxygen keywords at end of document.
  • Cmake lexer fixes bug with empty comments. - Bug #1550. + Bug #1550.
  • Fortran folder improved. Treats "else" as fold header. - Feature #962. + Feature #962.
  • Fix bug with adjacent instances of the same indicator with different values where only the first was drawn. - Bug #1560. + Bug #1560.
  • For DirectWrite, use the GDI ClearType gamma value for SC_EFF_QUALITY_LCD_OPTIMIZED as this results in text that is similar in colour intensity to GDI. For the duller default DirectWrite ClearType text appearance, use SC_EFF_QUALITY_DEFAULT. - Feature #887. + Feature #887.
  • Fix another problem with drawing on Windows with Direct2D when returning from lock screen. @@ -1564,26 +3227,26 @@
  • On Cocoa, apply font quality setting to line numbers. - Bug #1544. + Bug #1544.
  • On Cocoa, clicking in margin now sets focus. - Bug #1542. + Bug #1542.
  • On Cocoa, correct cursor displayed in margin after showing dialog.
  • On Cocoa, multipaste mode now works. - Bug #1541. + Bug #1541.
  • On GTK+, chain up to superclass finalize so that all finalization is performed. - Bug #1549. + Bug #1549.
  • On GTK+, fix horizontal scroll bar range to not be double the needed width. - Bug #1546. + Bug #1546.
  • On OS X GTK+, report control key as SCI_META for mouse down events. @@ -1597,19 +3260,19 @@
  • SciTE fix for multiple message boxes when failing to save a file with save.on.deactivate. - Bug #1540. + Bug #1540.
  • SciTE on GTK+ fixes SIGCHLD handling so that Lua scripts can determine the exit status of processes they start. - Bug #1557. + Bug #1557.
  • SciTE on Windows XP fixes bad display of find and replace values when using strips.

- Release 3.3.6 + Release 3.3.6

  • @@ -1624,7 +3287,7 @@
  • Lexer added for Rust language. - Feature #1024. + Feature #1024.
  • Avoid false matches in errorlist lexer which is used for the SciTE output pane @@ -1632,19 +3295,19 @@
  • Perl lexer fixes bugs with multi-byte characters, including in HEREDOCs and PODs. - Bug #1528. + Bug #1528.
  • SQL folder folds 'create view' statements. - Feature #1020. + Feature #1020.
  • Visual Prolog lexer updated with better support for string literals and Unicode. - Feature #1025. + Feature #1025.
  • For SCI_SETIDENTIFIERS, \t, \r, and \n are allowed as well as space between identifiers. - Bug #1521. + Bug #1521.
  • Gaining and losing focus is now reported as a notification with the code set to SCN_FOCUSIN @@ -1676,18 +3339,18 @@
  • On Cocoa, make drag and drop work when destination view is empty. - Bug #1534. + Bug #1534.
  • On Cocoa, drag image fixed when view scrolled.
  • On Cocoa, SCI_POSITIONFROMPOINTCLOSE fixed when view scrolled. - Feature #1021. + Feature #1021.
  • On Cocoa, don't send selection change notification when scrolling. - Bug #1522. + Bug #1522.
  • On Qt, turn off idle events on destruction to prevent repeatedly calling idle. @@ -1710,11 +3373,11 @@
  • Fix SciTE bug with buffers becoming read-only. - Bug #1525. + Bug #1525.
  • Fix linking SciTE on non-Linux Unix systems with GNU toolchain by linking to libdl. - Bug #1523. + Bug #1523.
  • On Windows, SciTE's Incremental Search displays match failures by changing the background colour @@ -1726,7 +3389,7 @@

- Release 3.3.5 + Release 3.3.5

  • @@ -1741,27 +3404,27 @@
  • Option to allow mouse selection to switch to rectangular by pressing Alt after start of gesture. - Feature #1007. + Feature #1007.
  • Lexer added for KVIrc script. - Feature #1008. + Feature #1008.
  • Bash lexer fixed quoted HereDoc delimiters. - Bug #1500. + Bug #1500.
  • MS SQL lexer fixed ';' to appear as an operator. - Bug #1509. + Bug #1509.
  • Structured Text lexer fixed styling of enumeration members. - Bug #1508. + Bug #1508.
  • Fixed bug with horizontal caret position when margin changed. - Bug #1512. + Bug #1512.
  • Fixed bug on Cocoa where coordinates were relative to text subview instead of whole view. @@ -1770,12 +3433,12 @@ Ensure selection redrawn correctly in two cases. When switching from stream to rectangular selection with Alt+Shift+Up. When reducing the range of an additional selection by moving mouse up. - Feature #1007. + Feature #1007.
  • Copy and paste of rectangular selections compatible with Borland Delphi IDE on Windows. - Feature #1002. - Bug #1513. + Feature #1002. + Bug #1513.
  • Initialize extended styles to the default style. @@ -1791,22 +3454,22 @@
  • Fixed SciTE failure to save initial buffer in single buffer mode. - Bug #1339. + Bug #1339.
  • Fixed compilation problem with Visual C++ in non-English locales. - Bug #1506. + Bug #1506.
  • Disable Direct2D when compiling with MinGW gcc on Windows because of changes in the recent MinGW release.
  • SciTE crash fixed for negative line.margin.width. - Bug #1504. + Bug #1504.
  • SciTE fix for infinite dialog boxes when failing to automatically save a file. - Bug #1503. + Bug #1503.
  • SciTE settings buffered.draw, two.phase.draw, and technology are applied to the @@ -1814,7 +3477,7 @@

- Release 3.3.4 + Release 3.3.4

  • @@ -1823,7 +3486,7 @@
  • Handling of UTF-8 and DBCS text in lexers improved with methods ForwardBytes and GetRelativeCharacter added to StyleContext. - Bug #1483. + Bug #1483.
  • For Unicode text, case-insensitive searching and making text upper or lower case is now @@ -1850,28 +3513,28 @@
  • CoffeeScript lexer fixes a bug with comment blocks. - Bug #1495 + Bug #1495
  • ECL lexer regular expression code fixed. - Bug #1491. + Bug #1491.
  • - errorlist lexer only recognises Perl diagnostics when there is a filename between + errorlist lexer only recognizes Perl diagnostics when there is a filename between "at" and "line". Had been triggering for MSVC errors containing "at line".
  • Haskell lexer fixed to avoid unnecessary full redraws. Don't highlight CPP inside comments when styling.within.preprocessor is on. - Bug #1459. + Bug #1459.
  • Lua lexer fixes bug in labels with UTF-8 text. - Bug #1483. + Bug #1483.
  • Perl lexer fixes bug in string interpolation with UTF-8 text. - Bug #1483. + Bug #1483.
  • Fixed bugs with case conversion when the result was longer or shorter than the original text. @@ -1893,7 +3556,7 @@
  • Minor memory leak fixed. - Bug #1487. + Bug #1487.
  • On Cocoa, fixed insertText: method which was broken when implementing a newer protocol. @@ -1911,11 +3574,11 @@
  • Fixed SciTE on GTK+ bug where a tool command could be performed using the keyboard while one was already running leading to confusion and crashes. - Bug #1486. + Bug #1486.
  • Fixed SciTE bug in Copy as RTF which was limited to first 32 styles. - Bug #1011. + Bug #1011.
  • Fixed SciTE on Windows user strip height when the system text scaling factor is 125% or 150%. @@ -1925,7 +3588,7 @@
  • Visual C++ 2013 supported. - Bug #1492. + Bug #1492.
  • Python scripts used for building and maintenance improved and moved into scripts directory. @@ -1939,7 +3602,7 @@

- Release 3.3.3 + Release 3.3.3

- Release 3.3.2 + Release 3.3.2

  • @@ -1986,28 +3649,28 @@
  • On Cocoa, implement font quality setting. - Feature #988. + Feature #988.
  • On Cocoa, implement automatic enabling of commands and added clear command. - Feature #987. + Feature #987.
  • C++ lexer adds style for preprocessor doc comment. - Feature #990. + Feature #990.
  • Haskell lexer and folder improved. Separate mode for literate Haskell "literatehaskell" SCLEX_LITERATEHASKELL. - Bug #1459 . + Bug #1459 .
  • LaTeX lexer bug fixed for Unicode character following '\'. - Bug #1468 . + Bug #1468 .
  • - PowerShell lexer recognises here strings and doccomment keywords. + PowerShell lexer recognizes here strings and doccomment keywords. #region folding added. - Feature #985. + Feature #985.
  • Fix multi-typing when two carets are located in virtual space on one line so that spaces @@ -2024,7 +3687,7 @@
  • Fix crash on Cocoa when view deallocated. - Bug #1466. + Bug #1466.
  • Fix Qt window positioning to not assume the top right of a monitor is at 0, 0. @@ -2034,7 +3697,7 @@
  • Qt now supports Qt 5.0. - Bug #1448. + Bug #1448.
  • Fix drawing on Windows with Direct2D when returning from lock screen. @@ -2054,7 +3717,7 @@

- Release 3.3.1 + Release 3.3.1

  • @@ -2062,21 +3725,21 @@
  • Autocompletion lists can now appear in priority order or be sorted by Scintilla. - Feature #981. + Feature #981.
  • Most lexers now lex an extra NUL byte at the end of the document which makes it more likely they will classify keywords at document end correctly. - Bug #574, - Bug #588. + Bug #574, + Bug #588.
  • Haskell lexer improved in several ways. - Bug #1459. + Bug #1459.
  • - Matlab/Octave lexer recognises block comments and ... comments. - Bug #1414. + Matlab/Octave lexer recognizes block comments and ... comments. + Bug #1414.
  • Ruby lexer crash fixed with keyword at start of document. @@ -2104,7 +3767,7 @@

- Release 3.3.0 + Release 3.3.0

  • @@ -2124,33 +3787,33 @@ If the whole range can not be displayed, priority is given to one end.
  • - C++ lexer no longer recognises raw (R"") strings when the first character after " + C++ lexer no longer recognizes raw (R"") strings when the first character after " is invalid. - Bug #1454. + Bug #1454.
  • - HTML lexer recognises JavaScript RegEx literals in more contexts. - Bug #1412. + HTML lexer recognizes JavaScript RegEx literals in more contexts. + Bug #1412.
  • Fixed automatic display of folded text when return pressed at end of fold header and first folded line was blank. - Bug #1455. + Bug #1455.
  • SCI_VISIBLEFROMDOCLINE fixed to never return a line beyond the document end.
  • SCI_LINESCROLL fixed for a negative column offset. - Bug #1450. + Bug #1450.
  • On GTK+, fix tab markers so visible if indent markers are visible. - Bug #1453. + Bug #1453.

- Release 3.2.5 + Release 3.2.5

  • @@ -2168,27 +3831,27 @@
  • The C++ lexer understands the #undef directive when determining preprocessor definitions. - Feature #978. + Feature #978.
  • - The errorlist lexer recognises gcc include path diagnostics that appear before an error. + The errorlist lexer recognizes gcc include path diagnostics that appear before an error.
  • Folding implemented for GetText (PO) translation language. - Bug #1437. + Bug #1437.
  • HTML lexer does not interrupt comment style for processing instructions. - Bug #1447. + Bug #1447.
  • Fix SciTE forgetting caret x-position when switching documents. - Bug #1442. + Bug #1442.
  • Fixed bug where vertical scrollbar thumb appeared at beginning of document when scrollbar shown. - Bug #1446. + Bug #1446.
  • Fixed brace-highlighting bug on OS X 10.8 where matching brace is on a different line. @@ -2203,7 +3866,7 @@

- Release 3.2.4 + Release 3.2.4

  • @@ -2211,7 +3874,7 @@
  • Caret line highlight can optionally remain visible when window does not have focus. - Feature #964. + Feature #964.
  • Delegate mechanism for notifications added on Cocoa. @@ -2219,34 +3882,34 @@
  • NUL characters in selection are copied to clipboard as spaces to avoid truncating at the NUL. - Bug #1289. + Bug #1289.
  • C++ lexer fixes problem with showing inactive sections when preprocessor lines contain trailing comment. - Bug #1413. + Bug #1413.
  • C++ lexer fixes problem with JavaScript regular expressions with '/' in character ranges. - Bug #1415. + Bug #1415.
  • LaTeX folder added. - Feature #970. + Feature #970.
  • LaTeX lexer improves styling of math environments. - Feature #970. + Feature #970.
  • MySQL lexer implements hidden commands.
  • Only produce a single undo step when autocompleting a single word. - Bug #1421. + Bug #1421.
  • Fixed crash when printing lines longer than 8000 characters. - Bug #1430. + Bug #1430.
  • Fixed problem in character movement extends selection mode where reversing @@ -2255,7 +3918,7 @@
  • Memory issues fixed on Cocoa, involving object ownership, lifetime of timers, and images held by the info bar. - Bug #1436. + Bug #1436.
  • Cocoa key binding for Alt+Delete changed to delete previous word to be more compatible with @@ -2263,7 +3926,7 @@
  • Fixed crash on Cocoa with scrollbar when there is no scrolling possible. - Bug #1416. + Bug #1416.
  • On Cocoa with retina display fixed positioning of autocompletion lists. @@ -2271,23 +3934,23 @@
  • Fixed SciTE on Windows failure to run a batch file with a name containing a space by quoting the path in the properties file. - Bug #1423. + Bug #1423.
  • Fixed scaling bug when printing on GTK+. - Bug #1427. + Bug #1427.
  • SciTE on GTK toolbar.detachable feature removed.
  • Fixed some background saving bugs in SciTE. - Bug #1366. - Bug #1339. + Bug #1366. + Bug #1339.

- Release 3.2.3 + Release 3.2.3

  • @@ -2312,7 +3975,7 @@ Bug #3515392.
  • - For C/C++, recognise exponent in floating point hexadecimal literals. + For C/C++, recognize exponent in floating point hexadecimal literals. Bug #3576454.
  • @@ -2369,7 +4032,7 @@

- Release 3.2.2 + Release 3.2.2

  • @@ -2478,11 +4141,11 @@
  • Added ncurses platform definitions. Implementation is maintained separately as - Scinterm. + Scinterm.

- Release 3.2.1 + Release 3.2.1

  • @@ -2598,7 +4261,7 @@

- Release 3.2.0 + Release 3.2.0

  • @@ -2688,7 +4351,7 @@

- Release 3.1.0 + Release 3.1.0

  • @@ -2780,7 +4443,7 @@

- Release 3.0.4 + Release 3.0.4

  • @@ -2940,7 +4603,7 @@

- Release 3.0.3 + Release 3.0.3

  • @@ -3056,7 +4719,7 @@

- Release 3.0.2 + Release 3.0.2

  • @@ -3069,7 +4732,7 @@ Printing implemented in SciTE on GTK+ 3.x.
  • - ILoader interface for background loading finalised and documented. + ILoader interface for background loading finalized and documented.
  • CoffeeScript lexer added. @@ -3120,7 +4783,7 @@

- Release 3.0.1 + Release 3.0.1

  • @@ -3151,7 +4814,7 @@ as this avoids faint lines at lexeme boundaries.
  • - Ensure pixmaps allocated before painting as there was a crash when Scintilla drew without common initialisation calls. + Ensure pixmaps allocated before painting as there was a crash when Scintilla drew without common initialization calls. Bug #3432354.
  • @@ -3166,12 +4829,12 @@ Fixed leak of document objects in SciTE.
  • - Recognise URL characters '?' and '%' for Open Selected command in SciTE. + Recognize URL characters '?' and '%' for Open Selected command in SciTE. Bug #3429409.

- Release 3.0.0 + Release 3.0.0

  • @@ -3241,7 +4904,7 @@

- Release 2.29 + Release 2.29

  • @@ -3261,7 +4924,7 @@ avenue, baan, escript, lot, metapost, and mmixal.
  • - C++ lexer fixed a bug with raw strings being recognised too easily. + C++ lexer fixed a bug with raw strings being recognized too easily. Bug #3388122.
  • @@ -3322,7 +4985,7 @@

- Release 2.28 + Release 2.28

  • @@ -3366,7 +5029,7 @@ Bug #3014850.
  • - Mako template language block syntax extended and ## comments recognised. + Mako template language block syntax extended and ## comments recognized. Feature #3325178. Bug #3318818.
  • @@ -3423,7 +5086,7 @@

- Release 2.27 + Release 2.27

  • @@ -3534,7 +5197,7 @@

- Release 2.26 + Release 2.26

  • @@ -3571,7 +5234,7 @@ Batch file lexer allows braces '(' or ')' inside variable names.
  • - The cpp lexer only recognises Vala triple quoted strings when lexer.cpp.triplequoted.strings property is set. + The cpp lexer only recognizes Vala triple quoted strings when lexer.cpp.triplequoted.strings property is set. Bug #3239234.
  • @@ -3668,7 +5331,7 @@

- Release 2.25 + Release 2.25

  • @@ -3705,7 +5368,7 @@ LPeg lexer support‎ improved in SciTE.
  • - SciTE on Windows-64 fixes for menu localisation and Lua scripts. + SciTE on Windows-64 fixes for menu localization and Lua scripts. Bug #3204502.
  • @@ -3728,7 +5391,7 @@

- Release 2.24 + Release 2.24

  • @@ -3835,7 +5498,7 @@

- Release 2.23 + Release 2.23

  • @@ -3859,7 +5522,7 @@ Performance improved when creating large rectangular selections.
  • - PHP folder recognises #region and #endregion comments. + PHP folder recognizes #region and #endregion comments. Feature #3101624.
  • @@ -3868,7 +5531,7 @@ Feature #3098071.
  • - SQL folder recognises case statements and understands the fold.at.else property. + SQL folder recognizes case statements and understands the fold.at.else property. Bug #3104091. Bug #3107362.
  • @@ -3892,7 +5555,7 @@

- Release 2.22 + Release 2.22

  • @@ -3962,7 +5625,7 @@ Bug #3058924.
  • - JavaScript lexer recognise regexes following return keyword.‎ + JavaScript lexer recognize regexes following return keyword.‎ Bug #3062287.
  • @@ -3998,7 +5661,7 @@

- Release 2.21 + Release 2.21

  • @@ -4096,7 +5759,7 @@

- Release 2.20 + Release 2.20

  • @@ -4217,7 +5880,7 @@

- Release 2.12 + Release 2.12

  • @@ -4251,7 +5914,7 @@ SciTE HTML exports take the Use Monospaced Font setting into account.
  • - SciTE window title "[n of m]" localised. + SciTE window title "[n of m]" localized.
  • When new line inserted at start of line, markers are moved down. @@ -4305,7 +5968,7 @@

- Release 2.11 + Release 2.11

  • @@ -4324,7 +5987,7 @@

- Release 2.10 + Release 2.10

  • @@ -4414,7 +6077,7 @@

- Release 2.03 + Release 2.03

  • @@ -4424,8 +6087,8 @@ Added SCI_SETFIRSTVISIBLELINE to match SCI_GETFIRSTVISIBLELINE.
  • - Erlang lexer extended set of numeric bases recognised; separate style for module:function_name; detects - built-in functions, known module attributes, and known preprocessor instructions; recognises EDoc and EDoc macros; + Erlang lexer extended set of numeric bases recognized; separate style for module:function_name; detects + built-in functions, known module attributes, and known preprocessor instructions; recognizes EDoc and EDoc macros; separates types of comments. Bug #2942448.
  • @@ -4460,7 +6123,7 @@

- Release 2.02 + Release 2.02

  • @@ -4622,7 +6285,7 @@

- Release 2.01 + Release 2.01

  • @@ -4651,7 +6314,7 @@

- Release 2.0 + Release 2.0

  • @@ -4668,7 +6331,7 @@ SciTE on GTK+ path bar is now optional and defaults to off.
  • - MagikSF lexer recognises numbers correctly. + MagikSF lexer recognizes numbers correctly.
  • Folding of Python comments and blank lines improved. Bug #210240. @@ -4710,7 +6373,7 @@

- Release 1.79 + Release 1.79

  • @@ -4796,7 +6459,7 @@ Unit test script for Scintilla on Windows included with source code.
  • - User defined menu items are now localised when there is a matching translation. + User defined menu items are now localized when there is a matching translation.
  • Width of icon column of autocompletion lists on GTK+ made more consistent. @@ -4815,7 +6478,7 @@

- Release 1.78 + Release 1.78

  • @@ -4919,7 +6582,7 @@ Bug #2671749.
  • - SciTE on GTK+ crash fixed on startup when child process exits before initialisation complete. + SciTE on GTK+ crash fixed on startup when child process exits before initialization complete. Bug #2716987.
  • @@ -4939,7 +6602,7 @@

- Release 1.77 + Release 1.77

  • @@ -5065,7 +6728,7 @@

- Release 1.76 + Release 1.76

  • @@ -5130,7 +6793,7 @@

- Release 1.75 + Release 1.75

  • @@ -5203,7 +6866,7 @@ Bash lexer handles octal literals.
  • - C++/JavaScript lexer recognises regex literals in more situations. + C++/JavaScript lexer recognizes regex literals in more situations.
  • Haskell lexer fixed for quoted strings. @@ -5214,7 +6877,7 @@ ASP problem fixed where </ is used inside a comment.
  • - Error messages from Lua 5.1 are recognised. + Error messages from Lua 5.1 are recognized.
  • Folding implemented for Metapost. @@ -5271,7 +6934,7 @@

- Release 1.74 + Release 1.74

  • @@ -5365,7 +7028,7 @@

- Release 1.73 + Release 1.73

  • @@ -5378,7 +7041,7 @@ Style changes may be made during text modification events.
  • - Regular expressions recognise \d, \D, \s, \S, \w, \W, and \xHH. + Regular expressions recognize \d, \D, \s, \S, \w, \W, and \xHH.
  • Support for cmake language added. @@ -5402,7 +7065,7 @@ SciTE on GTK+ removed GTK+ 1.x compatible file dialog code.
  • - SciTE on GTK+ recognises key names KeypadMultiply and KeypadDivide. + SciTE on GTK+ recognizes key names KeypadMultiply and KeypadDivide.
  • Background colour of line wrapping visual flag changed to STYLE_DEFAULT. @@ -5483,7 +7146,7 @@

- Release 1.72 + Release 1.72

  • @@ -5574,7 +7237,7 @@

- Release 1.71 + Release 1.71

  • @@ -5627,7 +7290,7 @@

- Release 1.70 + Release 1.70

  • @@ -5639,7 +7302,7 @@ when no similar character is available a '?' may be inserted.
  • - On GTK+, the internationalised IM (Input Method) feature is used for all typed input for all character sets. + On GTK+, the internationalized IM (Input Method) feature is used for all typed input for all character sets.
  • Scintilla has new margin types SC_MARGIN_BACK and SC_MARGIN_FORE that use the default @@ -5661,7 +7324,7 @@

- Release 1.69 + Release 1.69

  • @@ -5680,7 +7343,7 @@ Support for Spice language.
  • - On GTK+ autocompletion lists are optimised and use correct selection colours. + On GTK+ autocompletion lists are optimized and use correct selection colours.
  • On GTK+ the URI data type is preferred in drag and drop so that applications @@ -5751,7 +7414,7 @@

- Release 1.68 + Release 1.68

  • @@ -5846,7 +7509,7 @@

- Release 1.67 + Release 1.67

  • @@ -5872,7 +7535,7 @@ Bash lexer handles here documents better.
  • - JavaScript lexing recognises regular expressions more accurately and includes flag + JavaScript lexing recognizes regular expressions more accurately and includes flag characters in the regular expression style. This is both in JavaScript files and when JavaScript is embedded in HTML.
  • @@ -5990,7 +7653,7 @@

- Release 1.66 + Release 1.66

  • @@ -6008,7 +7671,7 @@ An initial ">" on a line is ignored when Enter pressed.
  • - C++ lexer recognises keywords within line doc comments. It continues styles over line + C++ lexer recognizes keywords within line doc comments. It continues styles over line end characters more consistently so that eolfilled style can be used for preprocessor lines and line comments.
  • @@ -6066,7 +7729,7 @@

- Release 1.65 + Release 1.65

  • @@ -6098,7 +7761,7 @@
  • Perl lexer handles here docs better; disambiguates barewords, quote-like delimiters, and repetition operators; - handles Pods after __END__; recognises numbers better; and handles some typeglob special variables. + handles Pods after __END__; recognizes numbers better; and handles some typeglob special variables.
  • Lisp adds more lexical states. @@ -6107,7 +7770,7 @@ PHP allows spaces after <<<.
  • - TADS3 has a simpler set of states and recognises identifiers. + TADS3 has a simpler set of states and recognizes identifiers.
  • Avenue elseif folds better. @@ -6117,7 +7780,7 @@ styles from '+' and '-' as they indicate file names in diffs.
  • - SciTE error recogniser handles file paths in extra explanatory lines from MSVC + SciTE error recognizer handles file paths in extra explanatory lines from MSVC and in '+++' and '---' lines from diff.
  • @@ -6127,7 +7790,7 @@
  • SciTE on Windows uses correct font for dialogs and better font for tab bar - allowing better localisation + allowing better localization
  • When Windows is used with a secondary monitor before the primary @@ -6156,7 +7819,7 @@

- Release 1.64 + Release 1.64

  • @@ -6205,7 +7868,7 @@
  • Perl can fold POD and package sections. POD verbatim section style. - Globbing syntax recognised better. + Globbing syntax recognized better.
  • Context menu moved slightly on GTK+ so that it will be under the mouse and will @@ -6253,7 +7916,7 @@

- Release 1.63 + Release 1.63

  • @@ -6303,7 +7966,7 @@ SQL lexer gains second set of keywords.
  • - Errorlist lexer recognises Borland Delphi error messages. + Errorlist lexer recognizes Borland Delphi error messages.
  • Method added for determining number of visual lines occupied by a document @@ -6437,7 +8100,7 @@

- Release 1.62 + Release 1.62

  • @@ -6545,7 +8208,7 @@ PHP lexer handles 'e' in numerical literals.
  • - PowerBasic lexer updated for macros and optimised. + PowerBasic lexer updated for macros and optimized.
  • Properties file folder changed to leave lines before a header at the base level @@ -6582,7 +8245,7 @@ Other Lua scripting bugs fixed.
  • - SciTE on Windows localisation of menu accelerators changed to be compatible + SciTE on Windows localization of menu accelerators changed to be compatible with alternative UI themes.
  • @@ -6654,7 +8317,7 @@

- Release 1.61 + Release 1.61

  • @@ -6690,7 +8353,7 @@ AutoIt3 lexer updated.
  • - Perl lexer recognises regular expression use better. + Perl lexer recognizes regular expression use better.
  • Errorlist lexer understands Lua tracebacks and copes with findstr @@ -6737,7 +8400,7 @@

- Release 1.60 + Release 1.60

  • @@ -6778,7 +8441,7 @@ correctly in more circumstances.
  • - PHP recognises variables within strings. + PHP recognizes variables within strings.
  • NSIS has properties "nsis.uservars" and "nsis.ignorecase". @@ -6844,7 +8507,7 @@
  • Key bindings for command.shortcut implemented in a way that doesn't break - when the menus are localised. + when the menus are localized.
  • Drawing of background on GTK+ faster as theme drawing disabled. @@ -6907,7 +8570,7 @@

- Release 1.59 + Release 1.59

  • @@ -6989,7 +8652,7 @@

- Release 1.58 + Release 1.58

  • @@ -7030,9 +8693,9 @@ Replace in Selection performed.
  • - Localisation files may contain a translation.encoding setting which is used + Localization files may contain a translation.encoding setting which is used on GTK+ 2 to automatically reencode the translation to UTF-8 so it will be - the localised text will be displayed correctly. + the localized text will be displayed correctly.
  • SciTE on GTK+ implements check.if.already.open. @@ -7077,7 +8740,7 @@

- Release 1.57 + Release 1.57

  • @@ -7152,7 +8815,7 @@

- Release 1.56 + Release 1.56

  • @@ -7240,7 +8903,7 @@

- Release 1.55 + Release 1.55

  • @@ -7337,7 +9000,7 @@

- Release 1.54 + Release 1.54

  • @@ -7423,7 +9086,7 @@

- Release 1.53 + Release 1.53

  • @@ -7494,7 +9157,7 @@

- Release 1.52 + Release 1.52

  • @@ -7576,7 +9239,7 @@ CSS lexer improved.
  • - Interface to platform layer changed - Surface initialisation now requires + Interface to platform layer changed - Surface initialization now requires a WindowID parameter.
  • @@ -7631,7 +9294,7 @@

- Release 1.51 + Release 1.51

  • @@ -7723,7 +9386,7 @@

- Release 1.50 + Release 1.50

  • @@ -7766,7 +9429,7 @@ the subject of the Open Selected Filename command.
  • - The localisation file name can be changed with the locale.properties property. + The localization file name can be changed with the locale.properties property.
  • On Windows, SciTE can pipe the result of a string expression into a command line tool. @@ -7839,7 +9502,7 @@

- Release 1.49 + Release 1.49

  • @@ -7865,7 +9528,7 @@ and block comments.
  • - Errorlist lexer recognises PHP error messages. + Errorlist lexer recognizes PHP error messages.
  • Variant of the C++ lexer with case insensitive keywords @@ -7897,7 +9560,7 @@ SciTE Save All command saves all buffers.
  • - SciTE localisation compares keys case insensitively to make translations more flexible. + SciTE localization compares keys case insensitively to make translations more flexible.
  • SciTE detects a utf-8 coding cookie "coding: utf-8" in first two @@ -7937,7 +9600,7 @@

- Release 1.48 + Release 1.48

  • @@ -7965,10 +9628,10 @@ independent of the colours chosen for the lexical class of that whitespace.
  • - Per line data optimised by using an exponential allocation scheme. + Per line data optimized by using an exponential allocation scheme.
  • - SciTE API file loading optimised. + SciTE API file loading optimized.
  • SciTE for GTK+ subsystem 2 documented. The exit status of commands @@ -8042,7 +9705,7 @@

- Release 1.47 + Release 1.47

  • @@ -8075,7 +9738,7 @@ SciTE in scite/boundscheck.
  • - SciTE automatically recognises Unicode files based + SciTE automatically recognizes Unicode files based on their Byte Order Marks and switches to Unicode mode. On Windows, where SciTE supports Unicode display, this allows display of non European characters. @@ -8173,7 +9836,7 @@

- Release 1.46 + Release 1.46

  • @@ -8289,7 +9952,7 @@

- Release 1.45 + Release 1.45

  • @@ -8320,10 +9983,10 @@ insertion point.
  • - On Windows with a wheel mouse, page-at-a-time mode is recognised. + On Windows with a wheel mouse, page-at-a-time mode is recognized.
  • - Read-only mode added to SciTE with a property to initialise it and another property, + Read-only mode added to SciTE with a property to initialize it and another property, $(ReadOnly) available to show this mode in the status bar.
  • @@ -8376,12 +10039,12 @@
  • In SciTE, indentation and tab settings stored with buffers so maintained correctly as buffers selected. - The properties used to initialise these settings can now be set separately for different + The properties used to initialize these settings can now be set separately for different file patterns.
  • Thread safety improved on Windows with a critical section protecting the font - cache and initialisation of globals performed within Scintilla_RegisterClasses. + cache and initialization of globals performed within Scintilla_RegisterClasses. New Scintilla_ReleaseResources call provided to allow explicit freeing of resources when statically bound into another application. Resources automatically freed in DLL version. The window classes are now unregistered as part of resource @@ -8395,7 +10058,7 @@

- Release 1.44 + Release 1.44

  • @@ -8445,7 +10108,7 @@

- Release 1.43 + Release 1.43

  • @@ -8521,14 +10184,14 @@

- Release 1.42 + Release 1.42

  • Released on 24 December 2001.
  • - Better localisation support including context menus and most messages. + Better localization support including context menus and most messages. Translations of the SciTE user interface available for Bulgarian, French, German, Italian, Russian, and Turkish.
  • @@ -8636,10 +10299,10 @@ modifications.
  • - Horizontal scrolling and display of long lines optimised. + Horizontal scrolling and display of long lines optimized.
  • - Cursor setting in Scintilla on GTK+ optimised. + Cursor setting in Scintilla on GTK+ optimized.
  • Experimental changeable style attribute. @@ -8655,7 +10318,7 @@

- Release 1.41 + Release 1.41

  • @@ -8721,7 +10384,7 @@ menu.language property rather than being hardcoded.
  • - The user interface of SciTE can be localised to a particular language by editing + The user interface of SciTE can be localized to a particular language by editing a locale.properties file.
  • @@ -8742,7 +10405,7 @@

- Release 1.40 + Release 1.40

  • @@ -8831,7 +10494,7 @@

- Release 1.39 + Release 1.39

  • @@ -8999,7 +10662,7 @@

- Release 1.38 + Release 1.38

  • @@ -9052,7 +10715,7 @@ Regular expression '^' and '$' work more often allowing insertion of text at start or end of line with a replace command. Backslash quoted control characters \a, \b, \f, \t, and \v - recognised within sets. + recognized within sets.
  • Session files for SciTE. @@ -9084,7 +10747,7 @@

- Release 1.37 + Release 1.37

  • @@ -9122,7 +10785,7 @@ Option in both Scintilla and SciTE to treat both left and right margin as equally important when repositioning visible area in response to caret movement. Default is to prefer visible area positioning which - minimises the horizontal scroll position thus favouring the left margin. + minimizes the horizontal scroll position thus favouring the left margin.
  • Caret line highlighting. @@ -9209,7 +10872,7 @@ led to that range becoming permanently invisible.
  • - Bug fixed in Batch lexer where comments were not recognised. + Bug fixed in Batch lexer where comments were not recognized.
  • Bug fixed with undo actions coalescing into steps incorrectly. @@ -9247,7 +10910,7 @@

- Release 1.36 + Release 1.36

  • @@ -9348,7 +11011,7 @@

- Release 1.35 + Release 1.35

  • @@ -9450,7 +11113,7 @@

- Release 1.34 + Release 1.34

  • @@ -9507,7 +11170,7 @@

- Release 1.33 + Release 1.33

  • @@ -9544,7 +11207,7 @@
  • Changes to Python lexer to allow 'as' as a context sensitive keyword and the - string forms starting with u, r, and ur to be recognised. + string forms starting with u, r, and ur to be recognized.
  • SCN_POSCHANGED notification now working and SCN_PAINTED notification added. @@ -9603,7 +11266,7 @@

- Release 1.32 + Release 1.32

  • @@ -9615,7 +11278,7 @@

- Release 1.31 + Release 1.31

  • @@ -9730,7 +11393,7 @@

- Release 1.30 + Release 1.30

  • @@ -9746,7 +11409,7 @@ use the old APIs.
  • - "if" and "import" statements in SciTE properties files allows modularisation into + "if" and "import" statements in SciTE properties files allows modularization into language-specific properties files and choices based upon platform. This means that SciTE is delivered with 9 language-specific properties files as well as the standard SciTEGlobal.properties file. @@ -9762,7 +11425,7 @@ a dark background) and to force black on white printing.
  • - Option for printing magnified or miniaturised from screen settings. + Option for printing magnified or miniaturized from screen settings.
  • In SciTE, Ctrl+F3 and Ctrl+Shift+F3 find the selection in the forwards and backwards @@ -9790,7 +11453,7 @@
  • When saving a file, the SciTE option save.deletes.first deletes it before doing the save. - This allows saving with a different capitalisation on Windows. + This allows saving with a different capitalization on Windows.
  • When use tabs option is off pressing the tab key inserts spaces. @@ -9800,7 +11463,7 @@

- Release 1.28 + Release 1.28

  • @@ -9818,7 +11481,7 @@

- Release 1.27 + Release 1.27

  • @@ -9847,7 +11510,7 @@

- Release 1.26 + Release 1.26

  • @@ -9912,12 +11575,12 @@ Bug fixed with hiding fold margin by setting fold.margin.width to 0.
  • - Bugs fixed with file name confusion on Windows when long and short names used, or different capitalisations, + Bugs fixed with file name confusion on Windows when long and short names used, or different capitalizations, or relative paths.

- Release 1.25 + Release 1.25

  • @@ -9985,7 +11648,7 @@

- Release 1.24 + Release 1.24

  • @@ -10011,7 +11674,7 @@ Fixed bugs relating to null fonts.
  • - Fixed bugs where recolourisation was not done sometimes when required. + Fixed bugs where recolourization was not done sometimes when required.
  • Fixed compilation problems with SVector.h. @@ -10021,7 +11684,7 @@

- Release 1.23 + Release 1.23

  • @@ -10093,7 +11756,7 @@

- Release 1.22 + Release 1.22

  • @@ -10114,7 +11777,7 @@ Optional macro recording support.
  • - User properties file (SciTEUser.properties) allows for customisation by the user + User properties file (SciTEUser.properties) allows for customization by the user that is not overwritten with each installation of SciTE.
  • @@ -10172,7 +11835,7 @@ is more likely to show the same text as when the file was previously visible.
  • - Document reference count now initialised correctly. + Document reference count now initialized correctly.
  • Setting a null document pointer creates an empty document. @@ -10193,7 +11856,7 @@

- Release 1.21 + Release 1.21

  • @@ -10229,7 +11892,7 @@

- Release 1.2 + Release 1.2

  • @@ -10264,7 +11927,7 @@

- Release 1.15 + Release 1.15

  • @@ -10302,7 +11965,7 @@ File open filter remembered in SciTE on Windows.
  • - New mechanism using style numbers 32 to 36 standardises the setting of styles for brace + New mechanism using style numbers 32 to 36 standardizes the setting of styles for brace highlighting, brace badlighting, line numbers, control characters and the default style.
  • @@ -10311,7 +11974,7 @@

- Release 1.14 + Release 1.14

  • @@ -10322,7 +11985,7 @@

- Release 1.13 + Release 1.13

  • @@ -10350,7 +12013,7 @@

- Release 1.12 + Release 1.12

  • @@ -10362,7 +12025,7 @@

- Release 1.11 + Release 1.11

  • @@ -10382,7 +12045,7 @@

- Release 1.1 + Release 1.1

  • @@ -10439,7 +12102,7 @@

- Release 1.02 + Release 1.02

  • @@ -10466,7 +12129,7 @@

- Release 1.01 + Release 1.01

  • @@ -10490,7 +12153,7 @@

- Release 1.0 + Release 1.0

  • @@ -10512,7 +12175,7 @@

- Beta release 0.93 + Beta release 0.93

  • @@ -10523,7 +12186,7 @@

- Beta release 0.92 + Beta release 0.92

  • @@ -10543,7 +12206,7 @@

- Beta release 0.91 + Beta release 0.91

  • @@ -10552,19 +12215,19 @@

- Beta release 0.90 + Beta release 0.90

  • Released on 29 April 1999, containing working GTK+/Linux version.
  • - The Java, C++ and Python lexers recognise operators as distinct from default allowing them + The Java, C++ and Python lexers recognize operators as distinct from default allowing them to be highlighted.

- Beta release 0.82 + Beta release 0.82

  • @@ -10573,7 +12236,7 @@

- Beta release 0.81 + Beta release 0.81

  • @@ -10581,7 +12244,7 @@
  • Static linking supported and Tidy.EXE, a statically linked version of Tide.EXE. Changes to - compiler flags in the makefiles to optimise for size. + compiler flags in the makefiles to optimize for size.
  • Scintilla supports a 'savepoint' in the undo stack which can be set by the container when diff --git a/dep/scintilla/scintilla-3.6.0/doc/ScintillaRelated.html b/dep/scintilla/scintilla-3.10.6/doc/ScintillaRelated.html similarity index 82% rename from dep/scintilla/scintilla-3.6.0/doc/ScintillaRelated.html rename to dep/scintilla/scintilla-3.10.6/doc/ScintillaRelated.html index 6f31e5a5..1c347172 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/ScintillaRelated.html +++ b/dep/scintilla/scintilla-3.10.6/doc/ScintillaRelated.html @@ -6,6 +6,7 @@ + Scintilla and SciTE Related Sites @@ -28,16 +29,12 @@

    Ports and Bindings of Scintilla

    -

    - Scinterm - is an implementation of Scintilla for the ncurses platform. -

    Scintilla.mcc is a port to MorphOS.

    - Wx::Scintilla + Wx::Scintilla is a Perl Binding for Scintilla on wxWidgets.

    @@ -49,7 +46,7 @@ these programs, using all the typical GObject conventions.

    - Editawy + Editawy is an ActiveX Control wrapper that support all Scintilla functions and additional high level functions.

    @@ -75,7 +72,7 @@ is an encapsulation of Scintilla for use within the .NET framework.

    - QScintilla + QScintilla is a port of Scintilla to the Qt platform. It has a similar license to Qt: GPL for use in free software and commercial for use in close-source applications.

    @@ -127,7 +124,24 @@ Projects using Scintilla

    - SciTECO + Textilosaurus + is simple cross-platform UTF-8 text editor based on Qt and Scintilla. +

    +

    + BowPad + is a small and fast text editor with a modern ribbon user interface (Windows7 or later). +

    +

    + ZeroBrane Studio Lua IDE + is a lightweight Lua IDE with code completion, syntax highlighting, live + coding, remote debugger, and code analyzer (Windows, OSX, and Linux). +

    +

    + XML Validator Buddy + is an XML/JSON editor and XML validator for Windows. +

    +

    + SciTECO is an advanced TECO dialect and interactive screen editor based on Scintilla.

    @@ -153,7 +167,7 @@ is a cross-platform, visual database design, sql coding and administration tool.

    - LIVEditor + LIVEditor is for web front end coders editing html/css/js code.

    @@ -161,8 +175,8 @@ is a wxWidgets-based Perl IDE.

    - CoderStudio - is an IDE for Assembly programming similar to Visual Studio 6.0. + CoderStudio + is an IDE for plain C and Assembly programming similar to Visual Studio.

    Enterprise Architect @@ -170,14 +184,14 @@

    The CodeAssistor Editor - is a small and simple MacOSX source code editor. + is a small and simple source code editor for MacOSX, Windows, and GTK/Linux.

    PBEditor is a text editor for PowerBuilder.

    - CrypTool + CrypTool is an application for applying and analyzing cryptographic algorithms.

    @@ -190,34 +204,22 @@ is a simple programming language with a Visual Basic like syntax.

    - LispIDE + LispIDE is a basic Lisp editor for Windows 2000, XP and Vista.

    - FlexEdit - is Free Text/Hex Editor for Windows. -

    -

    - File Workbench: + File Workbench: a file manager / text editor environment with Squirrel scripting.

    Kephra is a free, easy and comfortable cross-platform editor written in Perl.

    -

    - TOP - is an interface to HP's NonStop servers which run a proprietary OS. -

    UniversalIndentGUI is a cross platform GUI for several code formatters, beautifiers and indenters like GreatCode, AStyle (Artistic Styler), GNU Indent, BCPP and so on.

    -

    - TrackBack - watches and backs up every change made in your source code. -

    Elementary Reports is designed to reduce the time to compose detailed and professional primary school reports. @@ -233,12 +235,12 @@ class diagrams.

    - The ExtendScript Toolkit + The ExtendScript Toolkit is a development and debugging tool for JavaScript scripts included with Adobe CS3 Suites.

    - TortoiseSVN + TortoiseSVN is a Windows GUI client for the Subversion source control software.

    @@ -263,7 +265,7 @@ is a graphical user interface for changing SciTE properties files.

    - Scintilla Lister + Scintilla Lister is a plugin for Total Commander allowing viewing all documents with syntax highlighting inside Total Commander.

    @@ -279,7 +281,7 @@ Code::Blocks is an open source, cross platform free C++ IDE.

    - + Notepad++ is a free source code editor under Windows.

    @@ -291,7 +293,7 @@ LSW DotNet-Lab is a development environment for the .NET platform.

    - + GLIntercept is an OpenGL function call interceptor that uses SciTE as a run-time shader editor.

    @@ -308,7 +310,7 @@ PyCrash Viewer can examine crash dumps of Python programs.

    - + MPT series Wire Analyzers use Scintilla and SciTE.

    @@ -330,18 +332,14 @@ is a user-friendly source code editor easily extended using Python.

    - + Venis IX, the Visual Environment for NSIS (Nullsoft Scriptable Install System).

    - Eric3 + Eric3 is a Python IDE written using PyQt and QScintilla.

    -

    - SciTE|Flash - is a free Scintilla-based ActionScript editor for Windows. -

    CPPIDE is part of some commercial high-school oriented programming course software. @@ -358,26 +356,18 @@ wxBasic is an open source Basic interpreter that uses the wxWidgets toolkit. A small IDE is under construction.

    -

    - FreeRIDE will be a - cross-platform IDE for the Ruby programming language. -

    Visual MinGW is an IDE for the MinGW compiler system.This runs on Windows with gcc.

    - The Wing IDE is a + The Wing IDE is a complete integrated development environment for the Python programming language. Available on Intel based Linux and Windows and on MacOS X through XDarwin.

    - LuaIDE - is an IDE for Lua on Windows. -

    -

    - Sphere + Sphere is 2D RPG engine with a development environment.

    @@ -398,20 +388,10 @@ is a Python debugger that can run on one Windows machine debugging a Python program running on either the same or another machine.

    -

    - pyeditor and wxEditor - are scriptable editors implemented in Python. pyeditor is based on GTK+ and - the pyscintilla wrapper. wxEditor is based on wxWidgets, wxPython and - wxStyledTextControl. -

    PyCrust is an interactive Python shell based on wxPython.

    -

    - Black Adder is a - Qt based development environment for Python and Ruby. -

    Komodo is a cross-platform multi-language development environment built @@ -424,16 +404,16 @@ will be of interest to others wanting to control SciTE.

    - Anjuta + Anjuta is an open source C/C++ IDE for Linux/GNOME.

    - A version of SciTE for Win32 enhanced + A version of SciTE for Win32 enhanced with a tab control to allow easy movement between buffers. Go to the "Goodies" area on this site.

    - + Suneido is an integrated application platform currently available for Win32 that includes an object-oriented language, client-server database, and user interface and reporting frameworks.

    @@ -448,7 +428,7 @@ wxStyledTextCtrl used as its editor.

    - PythonWin, a Win32 IDE for Python, uses + PythonWin, a Win32 IDE for Python, uses Scintilla for both its editing and interactive windows.

    @@ -463,7 +443,7 @@ is a Unicode aware syntax editor control for Delphi and C++ Builder.

    - GtkSourceView + GtkSourceView is a text widget that extends the standard GTK+ 2.x text widget and improves it by implementing syntax highlighting and other features typical of a source editor.

    @@ -472,7 +452,7 @@ is a free source code editing component implemented in Ruby.

    - SyntaxEditor + SyntaxEditor is a commercial native .Net source code editing component.

    @@ -482,7 +462,7 @@

    GTK+, the GIMP Toolkit, contains a rich text editing widget.
    - Gedit is an editor for GTK+/GNOME.
    + Gedit is an editor for GTK+/GNOME.
    + + + + + + + + +
    + Scintilla icon + + Scintilla +
    +

    + Language Types +

    +

    + Scintilla contains lexers for various types of languages: +

      +
    • Programming languages like C++, Java, and Python.
    • +
    • Assembler languages are low-level programming languages which may additionally include instructions and registers.
    • +
    • Markup languages like HTML, TeX, and Markdown.
    • +
    • Data languages like EDIFACT and YAML.
    • +
    +

    +

    + Some languages can be used in different ways. JavaScript is a programming language but also + the basis of JSON data files. Similarly, + Lisp s expressions can be used for both source code and data. +

    +

    + Each language type has common elements such as identifiers in programming languages. + These common elements should be identified so that languages can be displayed with common + styles for these elements. + Style tags are used for this purpose in Scintilla. +

    +

    + Style Tags +

    +

    + Every style has a list of tags where a tag is a lower-case word containing only the common ASCII letters 'a'-'z' + such as "comment" or "operator". +

    +

    + Tags are ordered from most important to least important. +

    +

    + While applications may assign visual attributes for tag lists in many different ways, one reasonable technique is to + apply tag-specific attributes in reverse order so that earlier and more important tags override less important tags. + For example, the tag list "error comment documentation keyword" with + a set of tag attributes
    + { comment=fore:green,back:very-light-green,font:Serif documentation=fore:light-green error=strikethrough keyword=bold }
    + could be rendered as
    + bold,fore:light-green,back:very-light-green,font:Serif,strikethrough. +

    +

    + Alternative renderings could check for multi-tag combinations like + { comment.documentation=fore:light-green comment.line=dark-green comment=green }. +

    +

    + Commonly, a tag list will contain an optional embedded language; optional statuses; a base type; and a set of type modifiers:
    + embedded-language? status* base-type modifiers* +

    +

    Embedded language

    +

    + The embedded language may be a source (client | server) followed by a language name + (javascript | php | python | basic). + This may be extended in the future with other programming languages and style-definition languages like CSS. +

    +

    Status

    +

    + The statuses may be (error | unused | predefined | inactive).
    + The error status is used for lexical statuses that indicate errors in the source code such as unterminated quoted strings.
    + The unused status may indicate a gap in the lexical states, possibly because an old lexical class is no longer used or an upcoming lexical class may fill that position.
    + The predefined status indicates a style in the range 32.39 that is used for non-lexical purposes in Scintilla.
    + The inactive status is used for text that is not currently interpreted such as C++ code that is contained within a '#if 0' preprocessor block. +

    +

    Basic Types

    +

    + The basic types for programming languages are (default | operator | keyword | identifier | literal | comment | preprocessor | label).
    + The default type is commonly used for spaces and tabs between tokens although it may cover other characters in some languages. +

    +

    + Assembler languages add (instruction | register). to the basic types from programming languages.
    +

    +

    + The basic types for markup languages are (default | tag | attribute | comment | preprocessor).
    +

    +

    + The basic types for data languages are (default | key | data | comment).
    +

    +

    Comments

    +

    + Programming languages may differentiate between line and stream comments and treat documentation comments as distinct from other comments. + Documentation comments may be marked up with documentation keywords.
    + The additional attributes commonly used are (line | documentation | keyword | taskmarker). +

    +

    Literals

    +

    + Programming and assembler languages contain a rich set of literals including numbers like 7 and 3.89e23; "string\n"; and nullptr + and differentiating between these is often wanted.
    + The common literal types are (numeric | boolean | string | regex | date | time | uuid | nil | compound).
    + Numeric literal types are subdivided into (integer | real).
    + String literal types may add (perhaps multiple) further attributes from (heredoc | character | escapesequence | interpolated | multiline | raw).
    +

    +

    + An escape sequence within an interpolated heredoc may thus be literal string heredoc escapesequence. +

    +

    + List of known tags +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    attributeMarkup attribute
    basicEmbedded Basic
    booleanTrue or false literal
    characterSingle character literal as opposed to a string literal
    clientScript executed on client
    commentThe standard comment type in a language: may be stream or line
    compoundLiteral containing multiple subliterals such as a tuple or complex number
    dataA value in a data file
    dateLiteral representing a data such as '19/November/1975'
    defaultStarting state commonly also used for white space
    documentationComment that can be extracted into documentation
    errorState indicating an invalid or erroneous element
    escapesequenceParts of a string that are not literal such as '\t' for tab in C
    heredocLengthy text literal marked by a word at both ends
    identifierName that identifies an object or class of object
    inactiveCode that is not currently interpreted
    instructionMnemonic in assembler languages like 'addc'
    integerNumeric literal with no fraction or exponent like '738'
    interpolatedString that can contain expressions
    javascriptEmbedded Javascript
    keyElement which allows finding associated data
    keywordReserved word with special meaning like 'while'
    labelDestination for jumps in programming and assembler languages
    lineDifferentiates between stream comments and line comments in languages that have both
    literalFixed value in source code
    multilineDifferentiates between single line and multiline elements, commonly strings
    nilLiteral for the null pointer such as nullptr in C++ or NULL in C
    numericLiteral number like '16'
    operatorPunctuation character such as '&' or '['
    phpEmbedded PHP
    predefinedStyle in the range 32.39 that is used for non-lexical purposes
    preprocessorElement that is recognized in an early stage of translation
    pythonEmbedded Python
    rawString type that avoids interpretation: may be used for regular expressions in languages without a specific regex type
    realNumeric literal which may have a fraction or exponent like '3.84e-15'
    regexRegular expression literal like '^[a-z]+'
    registerCPU register in assembler languages
    serverScript executed on server
    stringSequence of characters
    tagMarkup tag like '<br />'
    taskmarkerWord in comment that marks future work like 'FIXME'
    timeLiteral representing a time such as '9:34:31'
    unusedStyle that is not currently used
    uuidUniversally unique identifier often used in interface definition files which may look like '{098f2470-bae0-11cd-b579-08002b30bfeb}'
    +

    + Extension +

    +

    + Each element in this scheme may be extended in the future. This may be done by revising this document to provide a common approach to new features. + Individual lexers may also choose to expose unique language features through new tags. +

    +

    + Translation +

    +

    + Tags could be exposed directly in user interfaces or configuration languages. + However, an application may also translate these to match its naming schema. + Capitalization and punctuation could be different (like Here-Doc instead of heredoc), + terminology changed ("constant" instead of "literal"), + or human language changed from English to Chinese or Spanish. +

    +

    + Starting from a common set of tags makes these modifications tractable. +

    +

    + Open issues +

    +

    + The C++ lexer (for example) has inactive states and dynamically allocated substyles. + These should be exposed through the metadata mechanism but are not currently. +

    + + diff --git a/dep/scintilla/scintilla-3.10.6/doc/annotations.png b/dep/scintilla/scintilla-3.10.6/doc/annotations.png new file mode 100644 index 00000000..23e5feb2 Binary files /dev/null and b/dep/scintilla/scintilla-3.10.6/doc/annotations.png differ diff --git a/dep/scintilla/scintilla-3.6.0/doc/index.html b/dep/scintilla/scintilla-3.10.6/doc/index.html similarity index 57% rename from dep/scintilla/scintilla-3.6.0/doc/index.html rename to dep/scintilla/scintilla-3.10.6/doc/index.html index 444b4615..cf0177ea 100644 --- a/dep/scintilla/scintilla-3.6.0/doc/index.html +++ b/dep/scintilla/scintilla-3.10.6/doc/index.html @@ -9,7 +9,8 @@ - + + ). +local css = lexer.load('css') +local style_element = word_match([[style]], true) +local css_start_rule = #(P('<') * style_element * + ('>' + P(function(input, index) + if input:find('^%s+type%s*=%s*(["\'])text/css%1', index) then + return index + end +end))) * lex.embed_start_tag +local css_end_rule = #('') * lex.embed_end_tag +lex:embed(css, css_start_rule, css_end_rule) + +-- Embedded JavaScript (). +local js = lexer.load('javascript') +local script_element = word_match([[script]], true) +local js_start_rule = #(P('<') * script_element * + ('>' + P(function(input, index) + if input:find('^%s+type%s*=%s*(["\'])text/javascript%1', index) then + return index + end +end))) * lex.embed_start_tag +local js_end_rule = #('') * lex.embed_end_tag +local js_line_comment = '//' * (lexer.nonnewline_esc - js_end_rule)^0 +local js_block_comment = '/*' * (lexer.any - '*/' - js_end_rule)^0 * P('*/')^-1 +js:modify_rule('comment', token(lexer.COMMENT, js_line_comment + + js_block_comment)) +lex:embed(js, js_start_rule, js_end_rule) + +-- Embedded CoffeeScript (). +local cs = lexer.load('coffeescript') +local script_element = word_match([[script]], true) +local cs_start_rule = #(P('<') * script_element * P(function(input, index) + if input:find('^[^>]+type%s*=%s*(["\'])text/coffeescript%1', index) then + return index + end +end)) * lex.embed_start_tag +local cs_end_rule = #('') * lex.embed_end_tag +lex:embed(cs, cs_start_rule, cs_end_rule) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/icon.lua b/dep/scintilla/scintilla-3.10.6/lexlua/icon.lua new file mode 100644 index 00000000..05defaa3 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/icon.lua @@ -0,0 +1,61 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- LPeg lexer for the Icon programming language. +-- http://www.cs.arizona.edu/icon +-- Contributed by Carl Sturtivant. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('icon') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + break by case create default do else end every fail global if initial + invocable link local next not of procedure record repeat return static suspend + then to until while +]])) + +-- Icon Keywords: unique to Icon. +lex:add_rule('special_keyword', token('special_keyword', P('&') * word_match[[ + allocated ascii clock collections cset current date dateline digits dump e + error errornumber errortext errorvalue errout fail features file host input + lcase letters level line main null output phi pi pos progname random regions + source storage subject time trace ucase version +]])) +lex:add_style('special_keyword', lexer.STYLE_TYPE) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"'))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline_esc^0)) + +-- Numbers. +local radix_literal = P('-')^-1 * lexer.dec_num * S('rR') * lexer.alnum^1 +lex:add_rule('number', token(lexer.NUMBER, radix_literal + lexer.float + + lexer.integer)) + +-- Preprocessor. +local preproc_word = word_match[[ + define else endif error ifdef ifndef include line undef +]] +lex:add_rule('preproc', token(lexer.PREPROCESSOR, P('$') * preproc_word)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>~!=^&|?~@:;,.()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.PREPROCESSOR, 'ifdef', 'endif') +lex:add_fold_point(lexer.PREPROCESSOR, 'ifndef', 'endif') +lex:add_fold_point(lexer.KEYWORD, 'procedure', 'end') +lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/idl.lua b/dep/scintilla/scintilla-3.10.6/lexlua/idl.lua new file mode 100644 index 00000000..67a618b8 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/idl.lua @@ -0,0 +1,51 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- IDL LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('idl') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + abstract attribute case const context custom default enum exception factory + FALSE in inout interface local module native oneway out private public raises + readonly struct support switch TRUE truncatable typedef union valuetype +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + any boolean char double fixed float long Object octet sequence short string + unsigned ValueBase void wchar wstring +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + + lexer.delimited_range('"', true))) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Preprocessor. +local preproc_word = word_match[[ + define undef ifdef ifndef if elif else endif include warning pragma +]] +lex:add_rule('preproc', token(lexer.PREPROCESSOR, lexer.starts_line('#') * + preproc_word)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('!<>=+-/*%&|^~.,:;?()[]{}'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/inform.lua b/dep/scintilla/scintilla-3.10.6/lexlua/inform.lua new file mode 100644 index 00000000..a307cdf0 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/inform.lua @@ -0,0 +1,72 @@ +-- Copyright 2010-2019 Jeff Stone. See License.txt. +-- Inform LPeg lexer for Scintilla. +-- JMS 2010-04-25. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('inform') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + Abbreviate Array Attribute Class Constant Default End Endif Extend Global + Ifdef Iffalse Ifndef Ifnot Iftrue Import Include Link Lowstring Message Object + Property Release Replace Serial StartDaemon Statusline StopDaemon Switches + Verb + absent action actor add_to_scope address additive after and animate article + articles before bold box break cant_go capacity char class child children + clothing concealed container continue creature daemon deadflag default + describe description do door door_dir door_to d_to d_obj e_to e_obj each_turn + edible else enterable false female first font for found_in general give + grammar has hasnt held if in in_to in_obj initial inside_description invent + jump last life light list_together location lockable locked male move moved + multi multiexcept multiheld multiinside n_to n_obj ne_to ne_obj nw_to nw_obj + name neuter new_line nothing notin noun number objectloop ofclass off on only + open openable or orders out_to out_obj parent parse_name player plural + pluralname print print_ret private proper provides random react_after + react_before remove replace return reverse rfalseroman rtrue s_to s_obj se_to + se_obj sw_to sw_obj scenery scope score scored second self short_name + short_name_indef sibling spaces static string style supporter switch + switchable talkable thedark time_left time_out to topic transparent true + underline u_to u_obj visited w_to w_obj when_closed when_off when_on when_open + while with with_key workflag worn +]])) + +-- Library actions. +lex:add_rule('action', token('action', word_match[[ + Answer Ask AskFor Attack Blow Burn Buy Climb Close Consult Cut Dig Disrobe + Drink Drop Eat Empty EmptyT Enter Examine Exit Fill FullScore GetOff Give Go + GoIn Insert Inv InvTall InvWide Jump JumpOver Kiss LetGo Listen LMode1 LMode2 + LMode3 Lock Look LookUnder Mild No NotifyOff NotifyOn Objects Open Order + Places Pray Pronouns Pull Push PushDir PutOn Quit Receive Remove Restart + Restore Rub Save Score ScriptOff ScriptOn Search Set SetTo Show Sing Sleep + Smell Sorry Squeeze Strong Swim Swing SwitchOff SwitchOn Take Taste Tell Think + ThrowAt ThrownAt Tie Touch Transfer Turn Unlock VagueGo Verify Version Wait + Wake WakeOther Wave WaveHands Wear Yes +]])) +lex:add_style('action', lexer.STYLE_VARIABLE) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"'))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '!' * lexer.nonnewline^0)) + +-- Numbers. +local inform_hex = '$' * lexer.xdigit^1 +local inform_bin = '$$' * S('01')^1 +lex:add_rule('number', token(lexer.NUMBER, lexer.integer + inform_hex + + inform_bin)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('@~=+-*/%^#=<>;:,.{}[]()&|?'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/ini.lua b/dep/scintilla/scintilla-3.10.6/lexlua/ini.lua new file mode 100644 index 00000000..c82d6ed2 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/ini.lua @@ -0,0 +1,43 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Ini LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('ini') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + true false on off yes no +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, (lexer.alpha + '_') * + (lexer.alnum + S('_.'))^0)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"'))) + +-- Labels. +lex:add_rule('label', token(lexer.LABEL, + lexer.delimited_range('[]', true, true))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, lexer.starts_line(S(';#')) * + lexer.nonnewline^0)) + +-- Numbers. +local dec = lexer.digit^1 * ('_' * lexer.digit^1)^0 +local oct_num = '0' * S('01234567_')^1 +local integer = S('+-')^-1 * (lexer.hex_num + oct_num + dec) +lex:add_rule('number', token(lexer.NUMBER, lexer.float + integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, '=')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/io_lang.lua b/dep/scintilla/scintilla-3.10.6/lexlua/io_lang.lua new file mode 100644 index 00000000..ada6aed3 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/io_lang.lua @@ -0,0 +1,51 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Io LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('io_lang') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + block method while foreach if else do super self clone proto setSlot hasSlot + type write print forward +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + Block Buffer CFunction Date Duration File Future LinkedList List Map Message + Nil Nop Number Object String WeakLink +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +local sq_str = lexer.delimited_range("'") +local dq_str = lexer.delimited_range('"') +local tq_str = '"""' * (lexer.any - '"""')^0 * P('"""')^-1 +lex:add_rule('string', token(lexer.STRING, tq_str + sq_str + dq_str)) + +-- Comments. +local line_comment = (P('#') + '//') * lexer.nonnewline^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, + S('`~@$%^&*-+/=\\<>?.,:;()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '(', ')') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/java.lua b/dep/scintilla/scintilla-3.10.6/lexlua/java.lua new file mode 100644 index 00000000..187fb02a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/java.lua @@ -0,0 +1,66 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Java LPeg lexer. +-- Modified by Brian Schott. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('java') + +-- Whitespace. +local ws = token(lexer.WHITESPACE, lexer.space^1) +lex:add_rule('whitespace', ws) + +-- Classes. +lex:add_rule('classdef', token(lexer.KEYWORD, P('class')) * ws * + token(lexer.CLASS, lexer.word)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + abstract assert break case catch class const continue default do else enum + extends final finally for goto if implements import instanceof interface + native new package private protected public return static strictfp super + switch synchronized this throw throws transient try while volatile + -- Literals. + true false null +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + boolean byte char double float int long short void + Boolean Byte Character Double Float Integer Long Short String +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, lexer.word) * #P('(')) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + + lexer.delimited_range('"', true))) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, (lexer.float + lexer.integer) * + S('LlFfDd')^-1)) + +-- Annotations. +lex:add_rule('annotation', token('annotation', '@' * lexer.word)) +lex:add_style('annotation', lexer.STYLE_PREPROCESSOR) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/javascript.lua b/dep/scintilla/scintilla-3.10.6/lexlua/javascript.lua new file mode 100644 index 00000000..96d51f75 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/javascript.lua @@ -0,0 +1,50 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- JavaScript LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('javascript') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + abstract boolean break byte case catch char class const continue debugger + default delete do double else enum export extends false final finally float + for function get goto if implements import in instanceof int interface let + long native new null of package private protected public return set short + static super switch synchronized this throw throws transient true try typeof + var void volatile while with yield +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Strings. +local regex_str = #P('/') * lexer.last_char_includes('+-*%^!=&|?:;,([{<>') * + lexer.delimited_range('/', true) * S('igm')^0 +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"') + + lexer.delimited_range('`')) + + token(lexer.REGEX, regex_str)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%^!=&|?:;,.()[]{}<>'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/json.lua b/dep/scintilla/scintilla-3.10.6/lexlua/json.lua new file mode 100644 index 00000000..f0c3e083 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/json.lua @@ -0,0 +1,39 @@ +-- Copyright 2006-2019 Brian "Sir Alaran" Schott. See License.txt. +-- JSON LPeg lexer. +-- Based off of lexer code by Mitchell. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('json') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + + lexer.delimited_range('"', true))) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[true false null]])) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +local integer = S('+-')^-1 * lexer.digit^1 * S('Ll')^-1 +lex:add_rule('number', token(lexer.NUMBER, lexer.float + integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('[]{}:,'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '[', ']') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/jsp.lua b/dep/scintilla/scintilla-3.10.6/lexlua/jsp.lua new file mode 100644 index 00000000..8306a945 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/jsp.lua @@ -0,0 +1,20 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- JSP LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('jsp', {inherit = lexer.load('html')}) + +-- Embedded Java. +local java = lexer.load('java') +local java_start_rule = token('jsp_tag', '<%' * P('=')^-1) +local java_end_rule = token('jsp_tag', '%>') +lex:embed(java, java_start_rule, java_end_rule, true) +lex:add_style('jsp_tag', lexer.STYLE_EMBEDDED) + +-- Fold points. +lex:add_fold_point('jsp_tag', '<%', '%>') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/latex.lua b/dep/scintilla/scintilla-3.10.6/lexlua/latex.lua new file mode 100644 index 00000000..3344635a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/latex.lua @@ -0,0 +1,58 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Latex LPeg lexer. +-- Modified by Brian Schott. +-- Modified by Robert Gieseke. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('latex') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Comments. +local line_comment = '%' * lexer.nonnewline^0 +local block_comment = '\\begin' * P(' ')^0 * '{comment}' * + (lexer.any - '\\end' * P(' ')^0 * '{comment}')^0 * + P('\\end' * P(' ')^0 * '{comment}')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Math environments. +local math_word = word_match[[ + align displaymath eqnarray equation gather math multline +]] +local math_begin_end = (P('begin') + P('end')) * P(' ')^0 * + '{' * math_word * P('*')^-1 * '}' +lex:add_rule('math', token('math', '$' + '\\' * (S('[]()') + math_begin_end))) +lex:add_style('math', lexer.STYLE_FUNCTION) + +-- LaTeX environments. +lex:add_rule('environment', token('environment', '\\' * + (P('begin') + P('end')) * + P(' ')^0 * '{' * lexer.word * + P('*')^-1 * '}')) +lex:add_style('environment', lexer.STYLE_KEYWORD) + +-- Sections. +lex:add_rule('section', token('section', '\\' * word_match[[ + part chapter section subsection subsubsection paragraph subparagraph +]] * P('*')^-1)) +lex:add_style('section', lexer.STYLE_CLASS) + +-- Commands. +lex:add_rule('command', token('command', '\\' * + (lexer.alpha^1 + S('#$&~_^%{}')))) +lex:add_style('command', lexer.STYLE_KEYWORD) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('&#{}[]'))) + +-- Fold points. +lex:add_fold_point(lexer.COMMENT, '\\begin', '\\end') +lex:add_fold_point(lexer.COMMENT, '%', lexer.fold_line_comments('%')) +lex:add_fold_point('environment', '\\begin', '\\end') +lex:add_fold_point(lexer.OPERATOR, '{', '}') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/ledger.lua b/dep/scintilla/scintilla-3.10.6/lexlua/ledger.lua new file mode 100644 index 00000000..aea21385 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/ledger.lua @@ -0,0 +1,48 @@ +-- Copyright 2015-2019 Charles Lehner. See License.txt. +-- ledger journal LPeg lexer, see http://www.ledger-cli.org/ + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('ledger', {lex_by_line = true}) + +local delim = P('\t') + P(' ') + +-- Account. +lex:add_rule('account', token(lexer.VARIABLE, + lexer.starts_line(S(' \t')^1 * + (lexer.print - delim)^1))) + +-- Amount. +lex:add_rule('amount', token(lexer.NUMBER, delim * (1 - S(';\r\n'))^1)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, S(';#') * lexer.nonnewline^0)) + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Strings. +local sq_str = lexer.delimited_range("'") +local dq_str = lexer.delimited_range('"') +local label = lexer.delimited_range('[]', true, true) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str + label)) + +-- Date. +lex:add_rule('date', token(lexer.CONSTANT, + lexer.starts_line((lexer.digit + S('/-'))^1))) + +-- Automated transactions. +lex:add_rule('auto_tx', token(lexer.PREPROCESSOR, + lexer.starts_line(S('=~') * lexer.nonnewline^0))) + +-- Directives. +local directive_word = word_match[[ + account alias assert bucket capture check comment commodity define end fixed + endfixed include payee apply tag test year +]] + S('AYNDCIiOobh') +lex:add_rule('directive', token(lexer.KEYWORD, + lexer.starts_line(S('!@')^-1 * directive_word))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/less.lua b/dep/scintilla/scintilla-3.10.6/lexlua/less.lua new file mode 100644 index 00000000..92051643 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/less.lua @@ -0,0 +1,21 @@ +-- Copyright 2006-2019 Robert Gieseke. See License.txt. +-- Less CSS LPeg lexer. +-- http://lesscss.org + +local lexer = require('lexer') +local token = lexer.token +local S = lpeg.S + +local lex = lexer.new('less', {inherit = lexer.load('css')}) + +-- Line comments. +lex:add_rule('line_comment', token(lexer.COMMENT, '//' * lexer.nonnewline^0)) + +-- Variables. +lex:add_rule('variable', token(lexer.VARIABLE, '@' * + (lexer.alnum + S('_-{}'))^1)) + +-- Fold points. +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintillua/scintillua-3.6.0/lexers/lexer.lua b/dep/scintilla/scintilla-3.10.6/lexlua/lexer.lua similarity index 56% rename from dep/scintillua/scintillua-3.6.0/lexers/lexer.lua rename to dep/scintilla/scintilla-3.10.6/lexlua/lexer.lua index 0dc96748..724240a0 100644 --- a/dep/scintillua/scintillua-3.6.0/lexers/lexer.lua +++ b/dep/scintilla/scintilla-3.10.6/lexlua/lexer.lua @@ -1,19 +1,19 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. local M = {} --[=[ This comment is for LuaDoc. --- --- Lexes Scintilla documents with Lua and LPeg. +-- Lexes Scintilla documents and source code with Lua and LPeg. -- --- ## Overview +-- ## Writing Lua Lexers -- -- Lexers highlight the syntax of source code. Scintilla (the editing component --- behind [Textadept][] and [SciTE][]) traditionally uses static, compiled C++ --- lexers which are notoriously difficult to create and/or extend. On the other --- hand, Lua makes it easy to to rapidly create new lexers, extend existing --- ones, and embed lexers within one another. Lua lexers tend to be more --- readable than C++ lexers too. +-- behind [Textadept][]) traditionally uses static, compiled C++ lexers which +-- are notoriously difficult to create and/or extend. On the other hand, Lua +-- makes it easy to to rapidly create new lexers, extend existing ones, and +-- embed lexers within one another. Lua lexers tend to be more readable than C++ +-- lexers too. -- -- Lexers are Parsing Expression Grammars, or PEGs, composed with the Lua -- [LPeg library][]. The following table comes from the LPeg documentation and @@ -40,67 +40,60 @@ local M = {} -- coloring and embedding lexers within one another. Following that is a -- discussion about code folding, or being able to tell Scintilla which code -- blocks are "foldable" (temporarily hideable from view). After that are --- instructions on how to use LPeg lexers with the aforementioned Textadept and --- SciTE editors. Finally there are comments on lexer performance and --- limitations. +-- instructions on how to use Lua lexers with the aforementioned Textadept +-- editor. Finally there are comments on lexer performance and limitations. -- -- [LPeg library]: http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html -- [Textadept]: http://foicica.com/textadept --- [SciTE]: http://scintilla.org/SciTE.html -- --- ## Lexer Basics +-- ### Lexer Basics -- -- The *lexers/* directory contains all lexers, including your new one. Before -- attempting to write one from scratch though, first determine if your --- programming language is similar to any of the 80+ languages supported. If so, --- you may be able to copy and modify that lexer, saving some time and effort. --- The filename of your lexer should be the name of your programming language in --- lower case followed by a *.lua* extension. For example, a new Lua lexer has --- the name *lua.lua*. +-- programming language is similar to any of the 100+ languages supported. If +-- so, you may be able to copy and modify that lexer, saving some time and +-- effort. The filename of your lexer should be the name of your programming +-- language in lower case followed by a *.lua* extension. For example, a new Lua +-- lexer has the name *lua.lua*. -- --- Note: Try to refrain from using one-character language names like "b", "c", --- or "d". For example, Scintillua uses "b_lang", "cpp", and "dmd", --- respectively. +-- Note: Try to refrain from using one-character language names like "c", "d", +-- or "r". For example, Lua lexers for those language names are named "ansi_c", +-- "dmd", and "rstats", respectively. -- --- ### New Lexer Template +-- #### New Lexer Template -- -- There is a *lexers/template.txt* file that contains a simple template for a -- new lexer. Feel free to use it, replacing the '?'s with the name of your --- lexer: +-- lexer. Consider this snippet from the template: -- -- -- ? LPeg lexer. -- --- local l = require('lexer') --- local token, word_match = l.token, l.word_match +-- local lexer = require('lexer') +-- local token, word_match = lexer.token, lexer.word_match -- local P, R, S = lpeg.P, lpeg.R, lpeg.S -- --- local M = {_NAME = '?'} +-- local lex = lexer.new('?') -- -- -- Whitespace. --- local ws = token(l.WHITESPACE, l.space^1) +-- local ws = token(lexer.WHITESPACE, lexer.space^1) +-- lex:add_rule('whitespace', ws) -- --- M._rules = { --- {'whitespace', ws}, --- } +-- [...] -- --- M._tokenstyles = { +-- return lex -- --- } +-- The first 3 lines of code simply define often used convenience variables. The +-- fourth and last lines [define](#lexer.new) and return the lexer object +-- Scintilla uses; they are very important and must be part of every lexer. The +-- fifth line defines something called a "token", an essential building block of +-- lexers. You will learn about tokens shortly. The sixth line defines a lexer +-- grammar rule, which you will learn about later, as well as token styles. (Be +-- aware that it is common practice to combine these two lines for short rules.) +-- Note, however, the `local` prefix in front of variables, which is needed +-- so-as not to affect Lua's global environment. All in all, this is a minimal, +-- working lexer that you can build on. -- --- return M --- --- The first 4 lines of code simply define often used convenience variables. The --- 5th and last lines define and return the lexer object Scintilla uses; they --- are very important and must be part of every lexer. The sixth line defines --- something called a "token", an essential building block of lexers. You will --- learn about tokens shortly. The rest of the code defines a set of grammar --- rules and token styles. You will learn about those later. Note, however, the --- `M.` prefix in front of `_rules` and `_tokenstyles`: not only do these tables --- belong to their respective lexers, but any non-local variables need the `M.` --- prefix too so-as not to affect Lua's global environment. All in all, this is --- a minimal, working lexer that you can build on. --- --- ### Tokens +-- #### Tokens -- -- Take a moment to think about your programming language's structure. What kind -- of key elements does it have? In the template shown earlier, one predefined @@ -112,19 +105,19 @@ local M = {} -- it comes to tokens. Perhaps only distinguishing between keywords and -- identifiers is necessary, or maybe recognizing constants and built-in -- functions, methods, or libraries is desirable. The Lua lexer, for example, --- defines 11 tokens: whitespace, comments, strings, numbers, keywords, built-in --- functions, constants, built-in libraries, identifiers, labels, and operators. --- Even though constants, built-in functions, and built-in libraries are subsets --- of identifiers, Lua programmers find it helpful for the lexer to distinguish --- between them all. It is perfectly acceptable to just recognize keywords and --- identifiers. +-- defines 11 tokens: whitespace, keywords, built-in functions, constants, +-- built-in libraries, identifiers, strings, comments, numbers, labels, and +-- operators. Even though constants, built-in functions, and built-in libraries +-- are subsets of identifiers, Lua programmers find it helpful for the lexer to +-- distinguish between them all. It is perfectly acceptable to just recognize +-- keywords and identifiers. -- -- In a lexer, tokens consist of a token name and an LPeg pattern that matches a -- sequence of characters recognized as an instance of that token. Create tokens -- using the [`lexer.token()`]() function. Let us examine the "whitespace" token -- defined in the template shown earlier: -- --- local ws = token(l.WHITESPACE, l.space^1) +-- local ws = token(lexer.WHITESPACE, lexer.space^1) -- -- At first glance, the first argument does not appear to be a string name and -- the second argument does not appear to be an LPeg pattern. Perhaps you @@ -132,8 +125,8 @@ local M = {} -- -- local ws = token('whitespace', S('\t\v\f\n\r ')^1) -- --- The `lexer` (`l`) module actually provides a convenient list of common token --- names and common LPeg patterns for you to use. Token names include +-- The `lexer` module actually provides a convenient list of common token names +-- and common LPeg patterns for you to use. Token names include -- [`lexer.DEFAULT`](), [`lexer.WHITESPACE`](), [`lexer.COMMENT`](), -- [`lexer.STRING`](), [`lexer.NUMBER`](), [`lexer.KEYWORD`](), -- [`lexer.IDENTIFIER`](), [`lexer.OPERATOR`](), [`lexer.ERROR`](), @@ -151,17 +144,50 @@ local M = {} -- token names is that your lexer's tokens will inherit the universal syntax -- highlighting color theme used by your text editor. -- --- #### Example Tokens +-- ##### Example Tokens -- --- So, how might you define other tokens like comments, strings, and keywords? +-- So, how might you define other tokens like keywords, comments, and strings? -- Here are some examples. -- +-- **Keywords** +-- +-- Instead of matching _n_ keywords with _n_ `P('keyword_`_`n`_`')` ordered +-- choices, use another convenience function: [`lexer.word_match()`](). It is +-- much easier and more efficient to write word matches like: +-- +-- local keyword = token(lexer.KEYWORD, lexer.word_match[[ +-- keyword_1 keyword_2 ... keyword_n +-- ]]) +-- +-- local case_insensitive_keyword = token(lexer.KEYWORD, lexer.word_match([[ +-- KEYWORD_1 keyword_2 ... KEYword_n +-- ]], true)) +-- +-- local hyphened_keyword = token(lexer.KEYWORD, lexer.word_match[[ +-- keyword-1 keyword-2 ... keyword-n +-- ]]) +-- +-- In order to more easily separate or categorize keyword sets, you can use Lua +-- line comments within keyword strings. Such comments will be ignored. For +-- example: +-- +-- local keyword = token(lexer.KEYWORD, lexer.word_match[[ +-- -- Version 1 keywords. +-- keyword_11, keyword_12 ... keyword_1n +-- -- Version 2 keywords. +-- keyword_21, keyword_22 ... keyword_2n +-- ... +-- -- Version N keywords. +-- keyword_m1, keyword_m2 ... keyword_mn +-- ]]) +-- -- **Comments** -- -- Line-style comments with a prefix character(s) are easy to express with LPeg: -- --- local shell_comment = token(l.COMMENT, '#' * l.nonnewline^0) --- local c_line_comment = token(l.COMMENT, '//' * l.nonnewline_esc^0) +-- local shell_comment = token(lexer.COMMENT, '#' * lexer.nonnewline^0) +-- local c_line_comment = token(lexer.COMMENT, +-- '//' * lexer.nonnewline_esc^0) -- -- The comments above start with a '#' or "//" and go to the end of the line. -- The second comment recognizes the next line also as a comment if the current @@ -170,7 +196,8 @@ local M = {} -- C-style "block" comments with a start and end delimiter are also easy to -- express: -- --- local c_comment = token(l.COMMENT, '/*' * (l.any - '*/')^0 * P('*/')^-1) +-- local c_comment = token(lexer.COMMENT, +-- '/*' * (lexer.any - '*/')^0 * P('*/')^-1) -- -- This comment starts with a "/\*" sequence and contains anything up to and -- including an ending "\*/" sequence. The ending "\*/" is optional so the lexer @@ -181,9 +208,9 @@ local M = {} -- It is tempting to think that a string is not much different from the block -- comment shown above in that both have start and end delimiters: -- --- local dq_str = '"' * (l.any - '"')^0 * P('"')^-1 --- local sq_str = "'" * (l.any - "'")^0 * P("'")^-1 --- local simple_string = token(l.STRING, dq_str + sq_str) +-- local dq_str = '"' * (lexer.any - '"')^0 * P('"')^-1 +-- local sq_str = "'" * (lexer.any - "'")^0 * P("'")^-1 +-- local simple_string = token(lexer.STRING, dq_str + sq_str) -- -- However, most programming languages allow escape sequences in strings such -- that a sequence like "\\"" in a double-quoted string indicates that the @@ -191,87 +218,60 @@ local M = {} -- such a string. Instead, use the [`lexer.delimited_range()`]() convenience -- function. -- --- local dq_str = l.delimited_range('"') --- local sq_str = l.delimited_range("'") --- local string = token(l.STRING, dq_str + sq_str) +-- local dq_str = lexer.delimited_range('"') +-- local sq_str = lexer.delimited_range("'") +-- local string = token(lexer.STRING, dq_str + sq_str) -- -- In this case, the lexer treats '\' as an escape character in a string -- sequence. -- --- **Keywords** --- --- Instead of matching _n_ keywords with _n_ `P('keyword_`_`n`_`')` ordered --- choices, use another convenience function: [`lexer.word_match()`](). It is --- much easier and more efficient to write word matches like: --- --- local keyword = token(l.KEYWORD, l.word_match{ --- 'keyword_1', 'keyword_2', ..., 'keyword_n' --- }) --- --- local case_insensitive_keyword = token(l.KEYWORD, l.word_match({ --- 'KEYWORD_1', 'keyword_2', ..., 'KEYword_n' --- }, nil, true)) --- --- local hyphened_keyword = token(l.KEYWORD, l.word_match({ --- 'keyword-1', 'keyword-2', ..., 'keyword-n' --- }, '-')) --- --- By default, characters considered to be in keywords are in the set of --- alphanumeric characters and underscores. The last token demonstrates how to --- allow '-' (hyphen) characters to be in keywords as well. --- -- **Numbers** -- -- Most programming languages have the same format for integer and float tokens, -- so it might be as simple as using a couple of predefined LPeg patterns: -- --- local number = token(l.NUMBER, l.float + l.integer) +-- local number = token(lexer.NUMBER, lexer.float + lexer.integer) -- -- However, some languages allow postfix characters on integers. -- --- local integer = P('-')^-1 * (l.dec_num * S('lL')^-1) --- local number = token(l.NUMBER, l.float + l.hex_num + integer) +-- local integer = P('-')^-1 * (lexer.dec_num * S('lL')^-1) +-- local number = token(lexer.NUMBER, lexer.float + lexer.hex_num + integer) -- -- Your language may need other tweaks, but it is up to you how fine-grained you -- want your highlighting to be. After all, you are not writing a compiler or -- interpreter! -- --- ### Rules +-- #### Rules -- -- Programming languages have grammars, which specify valid token structure. For -- example, comments usually cannot appear within a string. Grammars consist of -- rules, which are simply combinations of tokens. Recall from the lexer --- template the `_rules` table, which defines all the rules used by the lexer +-- template the [`lexer.add_rule()`]() call, which adds a rule to the lexer's -- grammar: -- --- M._rules = { --- {'whitespace', ws}, --- } +-- lex:add_rule('whitespace', ws) -- --- Each entry in a lexer's `_rules` table consists of a rule name and its --- associated pattern. Rule names are completely arbitrary and serve only to --- identify and distinguish between different rules. Rule order is important: if --- text does not match the first rule, the lexer tries the second rule, and so --- on. This simple grammar says to match whitespace tokens under a rule named --- "whitespace". +-- Each rule has an associated name, but rule names are completely arbitrary and +-- serve only to identify and distinguish between different rules. Rule order is +-- important: if text does not match the first rule added to the grammar, the +-- lexer tries to match the second rule added, and so on. Right now this lexer +-- simply matches whitespace tokens under a rule named "whitespace". -- -- To illustrate the importance of rule order, here is an example of a --- simplified Lua grammar: +-- simplified Lua lexer: -- --- M._rules = { --- {'whitespace', ws}, --- {'keyword', keyword}, --- {'identifier', identifier}, --- {'string', string}, --- {'comment', comment}, --- {'number', number}, --- {'label', label}, --- {'operator', operator}, --- } +-- lex:add_rule('whitespace', token(lexer.WHITESPACE, ...)) +-- lex:add_rule('keyword', token(lexer.KEYWORD, ...)) +-- lex:add_rule('identifier', token(lexer.IDENTIFIER, ...)) +-- lex:add_rule('string', token(lexer.STRING, ...)) +-- lex:add_rule('comment', token(lexer.COMMENT, ...)) +-- lex:add_rule('number', token(lexer.NUMBER, ...)) +-- lex:add_rule('label', token(lexer.LABEL, ...)) +-- lex:add_rule('operator', token(lexer.OPERATOR, ...)) -- -- Note how identifiers come after keywords. In Lua, as with most programming -- languages, the characters allowed in keywords and identifiers are in the same --- set (alphanumerics plus underscores). If the lexer specified the "identifier" +-- set (alphanumerics plus underscores). If the lexer added the "identifier" -- rule before the "keyword" rule, all keywords would match identifiers and thus -- incorrectly highlight as identifiers instead of keywords. The same idea -- applies to function, constant, etc. tokens that you may want to distinguish @@ -282,26 +282,25 @@ local M = {} -- skips over such text. If instead you want to highlight these "syntax errors", -- add an additional end rule: -- --- M._rules = { --- {'whitespace', ws}, --- {'error', token(l.ERROR, l.any)}, --- } +-- lex:add_rule('whitespace', ws) +-- ... +-- lex:add_rule('error', token(lexer.ERROR, lexer.any)) -- -- This identifies and highlights any character not matched by an existing --- rule as an `lexer.ERROR` token. +-- rule as a `lexer.ERROR` token. -- -- Even though the rules defined in the examples above contain a single token, -- rules may consist of multiple tokens. For example, a rule for an HTML tag -- could consist of a tag token followed by an arbitrary number of attribute --- tokens, allowing the lexer to highlight all tokens separately. The rule might --- look something like this: +-- tokens, allowing the lexer to highlight all tokens separately. That rule +-- might look something like this: -- --- {'tag', tag_start * (ws * attributes)^0 * tag_end^-1} +-- lex:add_rule('tag', tag_start * (ws * attributes)^0 * tag_end^-1) -- -- Note however that lexers with complex rules like these are more prone to lose --- track of their state. +-- track of their state, especially if they span multiple lines. -- --- ### Summary +-- #### Summary -- -- Lexers primarily consist of tokens and grammar rules. At your disposal are a -- number of convenience patterns and functions for rapidly creating a lexer. If @@ -309,9 +308,9 @@ local M = {} -- define how the lexer highlights them. The tokens will inherit the default -- syntax highlighting color theme your editor uses. -- --- ## Advanced Techniques +-- ### Advanced Techniques -- --- ### Styles and Styling +-- #### Styles and Styling -- -- The most basic form of syntax highlighting is assigning different colors to -- different tokens. Instead of highlighting with just colors, Scintilla allows @@ -338,6 +337,7 @@ local M = {} -- font:_name_ | The name of the font the style uses. -- size:_int_ | The size of the font the style uses. -- [not]bold | Whether or not the font face is bold. +-- weight:_int_ | The weight or boldness of a font, between 1 and 999. -- [not]italics | Whether or not the font face is italic. -- [not]underlined| Whether or not the font face is underlined. -- fore:_color_ | The foreground color of the font face. @@ -358,7 +358,7 @@ local M = {} -- styles from predefined ones. For example, Lua "longstring" tokens use the -- existing `lexer.STYLE_STRING` style instead of defining a new one. -- --- #### Example Styles +-- ##### Example Styles -- -- Defining styles is pretty straightforward. An empty style that inherits the -- default theme settings is simply an empty string: @@ -379,68 +379,60 @@ local M = {} -- had a "static variable" token whose style you wanted to base off of -- `lexer.STYLE_VARIABLE`, it would probably look like: -- --- local style_static_var = l.STYLE_VARIABLE..',italics' +-- local style_static_var = lexer.STYLE_VARIABLE..',italics' -- -- The color theme files in the *lexers/themes/* folder give more examples of -- style definitions. -- --- ### Token Styles +-- #### Token Styles -- --- Lexers use the `_tokenstyles` table to assign tokens to particular styles. --- Recall the token definition and `_tokenstyles` table from the lexer template: +-- Lexers use the [`lexer.add_style()`]() function to assign styles to +-- particular tokens. Recall the token definition and from the lexer template: -- --- local ws = token(l.WHITESPACE, l.space^1) --- --- ... --- --- M._tokenstyles = { --- --- } +-- local ws = token(lexer.WHITESPACE, lexer.space^1) +-- lex:add_rule('whitespace', ws) -- -- Why is a style not assigned to the `lexer.WHITESPACE` token? As mentioned -- earlier, lexers automatically associate tokens that use predefined token -- names with a particular style. Only tokens with custom token names need -- manual style associations. As an example, consider a custom whitespace token: -- --- local ws = token('custom_whitespace', l.space^1) +-- local ws = token('custom_whitespace', lexer.space^1) -- -- Assigning a style to this token looks like: -- --- M._tokenstyles = { --- custom_whitespace = l.STYLE_WHITESPACE --- } +-- lex:add_style('custom_whitespace', lexer.STYLE_WHITESPACE) -- -- Do not confuse token names with rule names. They are completely different --- entities. In the example above, the lexer assigns the "custom_whitespace" --- token the existing style for `WHITESPACE` tokens. If instead you want to --- color the background of whitespace a shade of grey, it might look like: +-- entities. In the example above, the lexer associates the "custom_whitespace" +-- token with the existing style for `lexer.WHITESPACE` tokens. If instead you +-- prefer to color the background of whitespace a shade of grey, it might look +-- like: -- --- local custom_style = l.STYLE_WHITESPACE..',back:$(color.grey)' --- M._tokenstyles = { --- custom_whitespace = custom_style --- } +-- local custom_style = lexer.STYLE_WHITESPACE..',back:$(color.grey)' +-- lex:add_style('custom_whitespace', custom_style) -- --- Notice that the lexer peforms Scintilla/SciTE-style "$()" property expansion. --- You may also use "%()". Remember to refrain from assigning specific colors in +-- Notice that the lexer peforms Scintilla-style "$()" property expansion. You +-- may also use "%()". Remember to refrain from assigning specific colors in -- styles, but in this case, all user color themes probably define the -- "color.grey" property. -- --- ### Line Lexers +-- #### Line Lexers -- -- By default, lexers match the arbitrary chunks of text passed to them by -- Scintilla. These chunks may be a full document, only the visible part of a -- document, or even just portions of lines. Some lexers need to match whole -- lines. For example, a lexer for the output of a file "diff" needs to know if -- the line started with a '+' or '-' and then style the entire line --- accordingly. To indicate that your lexer matches by line, use the --- `_LEXBYLINE` field: +-- accordingly. To indicate that your lexer matches by line, create the lexer +-- with an extra parameter: -- --- M._LEXBYLINE = true +-- local lex = lexer.new('?', {lex_by_line = true}) -- -- Now the input text for the lexer is a single line at a time. Keep in mind -- that line lexers do not have the ability to look ahead at subsequent lines. -- --- ### Embedded Lexers +-- #### Embedded Lexers -- -- Lexers embed within one another very easily, requiring minimal effort. In the -- following sections, the lexer being embedded is called the "child" lexer and @@ -450,18 +442,18 @@ local M = {} -- HTML. In this specific case, the CSS lexer is the "child" lexer with the HTML -- lexer being the "parent". Now consider an HTML lexer and a PHP lexer. This -- sounds a lot like the case with CSS, but there is a subtle difference: PHP --- _embeds itself_ into HTML while CSS is _embedded in_ HTML. This fundamental +-- _embeds itself into_ HTML while CSS is _embedded in_ HTML. This fundamental -- difference results in two types of embedded lexers: a parent lexer that -- embeds other child lexers in it (like HTML embedding CSS), and a child lexer --- that embeds itself within a parent lexer (like PHP embedding itself in HTML). +-- that embeds itself into a parent lexer (like PHP embedding itself in HTML). -- --- #### Parent Lexer +-- ##### Parent Lexer -- -- Before embedding a child lexer into a parent lexer, the parent lexer needs to -- load the child lexer. This is done with the [`lexer.load()`]() function. For -- example, loading the CSS lexer within the HTML lexer looks like: -- --- local css = l.load('css') +-- local css = lexer.load('css') -- -- The next part of the embedding process is telling the parent lexer when to -- switch over to the child lexer and when to switch back. The lexer refers to @@ -494,89 +486,85 @@ local M = {} -- local css_end_rule = #P('') * tag -- -- Once the parent loads the child lexer and defines the child's start and end --- rules, it embeds the child with the [`lexer.embed_lexer()`]() function: +-- rules, it embeds the child with the [`lexer.embed()`]() function: -- --- l.embed_lexer(M, css, css_start_rule, css_end_rule) +-- lex:embed(css, css_start_rule, css_end_rule) -- --- The first parameter is the parent lexer object to embed the child in, which --- in this case is `M`. The other three parameters are the child lexer object --- loaded earlier followed by its start and end rules. --- --- #### Child Lexer +-- ##### Child Lexer -- -- The process for instructing a child lexer to embed itself into a parent is -- very similar to embedding a child into a parent: first, load the parent lexer -- into the child lexer with the [`lexer.load()`]() function and then create --- start and end rules for the child lexer. However, in this case, swap the --- lexer object arguments to [`lexer.embed_lexer()`](). For example, in the PHP --- lexer: +-- start and end rules for the child lexer. However, in this case, call +-- [`lexer.embed()`]() with switched arguments. For example, in the PHP lexer: -- --- local html = l.load('html') +-- local html = lexer.load('html') -- local php_start_rule = token('php_tag', '') --- l.embed_lexer(html, M, php_start_rule, php_end_rule) +-- lex:add_style('php_tag', lexer.STYLE_EMBEDDED) +-- html:embed(lex, php_start_rule, php_end_rule) -- --- ## Code Folding +-- #### Lexers with Complex State +-- +-- A vast majority of lexers are not stateful and can operate on any chunk of +-- text in a document. However, there may be rare cases where a lexer does need +-- to keep track of some sort of persistent state. Rather than using `lpeg.P` +-- function patterns that set state variables, it is recommended to make use of +-- Scintilla's built-in, per-line state integers via [`lexer.line_state`](). It +-- was designed to accommodate up to 32 bit flags for tracking state. +-- [`lexer.line_from_position()`]() will return the line for any position given +-- to an `lpeg.P` function pattern. (Any positions derived from that position +-- argument will also work.) +-- +-- Writing stateful lexers is beyond the scope of this document. +-- +-- ### Code Folding -- -- When reading source code, it is occasionally helpful to temporarily hide -- blocks of code like functions, classes, comments, etc. This is the concept of --- "folding". In the Textadept and SciTE editors for example, little indicators --- in the editor margins appear next to code that can be folded at places called --- "fold points". When the user clicks an indicator, the editor hides the code --- associated with the indicator until the user clicks the indicator again. The --- lexer specifies these fold points and what code exactly to fold. +-- "folding". In many Scintilla-based editors, such as Textadept, little +-- indicators in the editor margins appear next to code that can be folded at +-- places called "fold points". When the user clicks an indicator, the editor +-- hides the code associated with the indicator until the user clicks the +-- indicator again. The lexer specifies these fold points and what code exactly +-- to fold. -- -- The fold points for most languages occur on keywords or character sequences. -- Examples of fold keywords are "if" and "end" in Lua and examples of fold -- character sequences are '{', '}', "/\*", and "\*/" in C for code block and -- comment delimiters, respectively. However, these fold points cannot occur -- just anywhere. For example, lexers should not recognize fold keywords that --- appear within strings or comments. The lexer's `_foldsymbols` table allows --- you to conveniently define fold points with such granularity. For example, --- consider C: +-- appear within strings or comments. The [`lexer.add_fold_point()`]() function +-- allows you to conveniently define fold points with such granularity. For +-- example, consider C: -- --- M._foldsymbols = { --- [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, --- [l.COMMENT] = {['/*'] = 1, ['*/'] = -1}, --- _patterns = {'[{}]', '/%*', '%*/'} --- } +-- lex:add_fold_point(lexer.OPERATOR, '{', '}') +-- lex:add_fold_point(lexer.COMMENT, '/*', '*/') -- -- The first assignment states that any '{' or '}' that the lexer recognized as --- an `lexer.OPERATOR` token is a fold point. The integer `1` indicates the --- match is a beginning fold point and `-1` indicates the match is an ending --- fold point. Likewise, the second assignment states that any "/\*" or "\*/" --- that the lexer recognizes as part of a `lexer.COMMENT` token is a fold point. --- The lexer does not consider any occurences of these characters outside their --- defined tokens (such as in a string) as fold points. Finally, every --- `_foldsymbols` table must have a `_patterns` field that contains a list of --- [Lua patterns][] that match fold points. If the lexer encounters text that --- matches one of those patterns, the lexer looks up the matched text in its --- token's table to determine whether or not the text is a fold point. In the --- example above, the first Lua pattern matches any '{' or '}' characters. When --- the lexer comes across one of those characters, it checks if the match is an --- `lexer.OPERATOR` token. If so, the lexer identifies the match as a fold --- point. The same idea applies for the other patterns. (The '%' is in the other --- patterns because '\*' is a special character in Lua patterns that needs --- escaping.) How do you specify fold keywords? Here is an example for Lua: +-- an `lexer.OPERATOR` token is a fold point. Likewise, the second assignment +-- states that any "/\*" or "\*/" that the lexer recognizes as part of a +-- `lexer.COMMENT` token is a fold point. The lexer does not consider any +-- occurrences of these characters outside their defined tokens (such as in a +-- string) as fold points. How do you specify fold keywords? Here is an example +-- for Lua: -- --- M._foldsymbols = { --- [l.KEYWORD] = { --- ['if'] = 1, ['do'] = 1, ['function'] = 1, --- ['end'] = -1, ['repeat'] = 1, ['until'] = -1 --- }, --- _patterns = {'%l+'} --- } +-- lex:add_fold_point(lexer.KEYWORD, 'if', 'end') +-- lex:add_fold_point(lexer.KEYWORD, 'do', 'end') +-- lex:add_fold_point(lexer.KEYWORD, 'function', 'end') +-- lex:add_fold_point(lexer.KEYWORD, 'repeat', 'until') -- --- Any time the lexer encounters a lower case word, if that word is a --- `lexer.KEYWORD` token and in the associated list of fold points, the lexer --- identifies the word as a fold point. +-- If your lexer has case-insensitive keywords as fold points, simply add a +-- `case_insensitive_fold_points = true` option to [`lexer.new()`](), and +-- specify keywords in lower case. -- --- If your lexer needs to do some additional processing to determine if a match --- is a fold point, assign a function that returns an integer. Returning `1` or --- `-1` indicates the match is a fold point. Returning `0` indicates it is not. --- For example: +-- If your lexer needs to do some additional processing in order to determine if +-- a token is a fold point, pass a function that returns an integer to +-- `lex:add_fold_point()`. Returning `1` indicates the token is a beginning fold +-- point and returning `-1` indicates the token is an ending fold point. +-- Returning `0` indicates the token is not a fold point. For example: -- --- local function fold_strange_token(text, pos, line, s, match) +-- local function fold_strange_token(text, pos, line, s, symbol) -- if ... then -- return 1 -- beginning fold point -- elseif ... then @@ -585,32 +573,27 @@ local M = {} -- return 0 -- end -- --- M._foldsymbols = { --- ['strange_token'] = {['|'] = fold_strange_token}, --- _patterns = {'|'} --- } +-- lex:add_fold_point('strange_token', '|', fold_strange_token) -- -- Any time the lexer encounters a '|' that is a "strange_token", it calls the -- `fold_strange_token` function to determine if '|' is a fold point. The lexer -- calls these functions with the following arguments: the text to identify fold -- points in, the beginning position of the current line in the text to fold, --- the current line's text, the position in the current line the matched text --- starts at, and the matched text itself. +-- the current line's text, the position in the current line the fold point text +-- starts at, and the fold point text itself. -- --- [Lua patterns]: http://www.lua.org/manual/5.2/manual.html#6.4.1 --- --- ### Fold by Indentation +-- #### Fold by Indentation -- -- Some languages have significant whitespace and/or no delimiters that indicate -- fold points. If your lexer falls into this category and you would like to --- mark fold points based on changes in indentation, use the --- `_FOLDBYINDENTATION` field: +-- mark fold points based on changes in indentation, create the lexer with a +-- `fold_by_indentation = true` option: -- --- M._FOLDBYINDENTATION = true +-- local lex = lexer.new('?', {fold_by_indentation = true}) -- --- ## Using Lexers +-- ### Using Lexers -- --- ### Textadept +-- #### Textadept -- -- Put your lexer in your *~/.textadept/lexers/* directory so you do not -- overwrite it when upgrading Textadept. Also, lexers in this directory @@ -618,36 +601,147 @@ local M = {} -- the default *lua* lexer. This is convenient for tweaking a default lexer to -- your liking. Then add a [file type][] for your lexer if necessary. -- --- [file type]: _M.textadept.file_types.html +-- [file type]: textadept.file_types.html -- --- ### SciTE +-- ### Migrating Legacy Lexers -- --- Create a *.properties* file for your lexer and `import` it in either your --- *SciTEUser.properties* or *SciTEGlobal.properties*. The contents of the --- *.properties* file should contain: +-- Legacy lexers are of the form: -- --- file.patterns.[lexer_name]=[file_patterns] --- lexer.$(file.patterns.[lexer_name])=[lexer_name] +-- local l = require('lexer') +-- local token, word_match = l.token, l.word_match +-- local P, R, S = lpeg.P, lpeg.R, lpeg.S -- --- where `[lexer_name]` is the name of your lexer (minus the *.lua* extension) --- and `[file_patterns]` is a set of file extensions to use your lexer for. +-- local M = {_NAME = '?'} -- --- Please note that Lua lexers ignore any styling information in *.properties* --- files. Your theme file in the *lexers/themes/* directory contains styling --- information. +-- [... token and pattern definitions ...] -- --- ## Considerations +-- M._rules = { +-- {'rule', pattern}, +-- [...] +-- } -- --- ### Performance +-- M._tokenstyles = { +-- 'token' = 'style', +-- [...] +-- } +-- +-- M._foldsymbols = { +-- _patterns = {...}, +-- ['token'] = {['start'] = 1, ['end'] = -1}, +-- [...] +-- } +-- +-- return M +-- +-- While such legacy lexers will be handled just fine without any changes, it is +-- recommended that you migrate yours. The migration process is fairly +-- straightforward: +-- +-- 1. Replace all instances of `l` with `lexer`, as it's better practice and +-- results in less confusion. +-- 2. Replace `local M = {_NAME = '?'}` with `local lex = lexer.new('?')`, where +-- `?` is the name of your legacy lexer. At the end of the lexer, change +-- `return M` to `return lex`. +-- 3. Instead of defining rules towards the end of your lexer, define your rules +-- as you define your tokens and patterns using +-- [`lex:add_rule()`](#lexer.add_rule). +-- 4. Similarly, any custom token names should have their styles immediately +-- defined using [`lex:add_style()`](#lexer.add_style). +-- 5. Convert any table arguments passed to [`lexer.word_match()`]() to a +-- space-separated string of words. +-- 6. Replace any calls to `lexer.embed(M, child, ...)` and +-- `lexer.embed(parent, M, ...)` with +-- [`lex:embed`](#lexer.embed)`(child, ...)` and `parent:embed(lex, ...)`, +-- respectively. +-- 7. Define fold points with simple calls to +-- [`lex:add_fold_point()`](#lexer.add_fold_point). No need to mess with Lua +-- patterns anymore. +-- 8. Any legacy lexer options such as `M._FOLDBYINDENTATION`, `M._LEXBYLINE`, +-- `M._lexer`, etc. should be added as table options to [`lexer.new()`](). +-- 9. Any external lexer rule fetching and/or modifications via `lexer._RULES` +-- should be changed to use [`lexer.get_rule()`]() and +-- [`lexer.modify_rule()`](). +-- +-- As an example, consider the following sample legacy lexer: +-- +-- local l = require('lexer') +-- local token, word_match = l.token, l.word_match +-- local P, R, S = lpeg.P, lpeg.R, lpeg.S +-- +-- local M = {_NAME = 'legacy'} +-- +-- local ws = token(l.WHITESPACE, l.space^1) +-- local comment = token(l.COMMENT, '#' * l.nonnewline^0) +-- local string = token(l.STRING, l.delimited_range('"')) +-- local number = token(l.NUMBER, l.float + l.integer) +-- local keyword = token(l.KEYWORD, word_match{'foo', 'bar', 'baz'}) +-- local custom = token('custom', P('quux')) +-- local identifier = token(l.IDENTIFIER, l.word) +-- local operator = token(l.OPERATOR, S('+-*/%^=<>,.()[]{}')) +-- +-- M._rules = { +-- {'whitespace', ws}, +-- {'keyword', keyword}, +-- {'custom', custom}, +-- {'identifier', identifier}, +-- {'string', string}, +-- {'comment', comment}, +-- {'number', number}, +-- {'operator', operator} +-- } +-- +-- M._tokenstyles = { +-- 'custom' = l.STYLE_KEYWORD..',bold' +-- } +-- +-- M._foldsymbols = { +-- _patterns = {'[{}]'}, +-- [l.OPERATOR] = {['{'] = 1, ['}'] = -1} +-- } +-- +-- return M +-- +-- Following the migration steps would yield: +-- +-- local lexer = require('lexer') +-- local token, word_match = lexer.token, lexer.word_match +-- local P, R, S = lpeg.P, lpeg.R, lpeg.S +-- +-- local lex = lexer.new('legacy') +-- +-- lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) +-- lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[foo bar baz]])) +-- lex:add_rule('custom', token('custom', P('quux'))) +-- lex:add_style('custom', lexer.STYLE_KEYWORD..',bold') +-- lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) +-- lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"'))) +-- lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) +-- lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) +-- lex:add_rule('operator', token(lexer.OPERATOR, S('+-*/%^=<>,.()[]{}'))) +-- +-- lex:add_fold_point(lexer.OPERATOR, '{', '}') +-- +-- return lex +-- +-- ### Considerations +-- +-- #### Performance -- -- There might be some slight overhead when initializing a lexer, but loading a -- file from disk into Scintilla is usually more expensive. On modern computer --- systems, I see no difference in speed between LPeg lexers and Scintilla's C++ --- ones. Optimize lexers for speed by re-arranging rules in the `_rules` table --- so that the most common rules match first. Do keep in mind that order matters +-- systems, I see no difference in speed between Lua lexers and Scintilla's C++ +-- ones. Optimize lexers for speed by re-arranging `lexer.add_rule()` calls so +-- that the most common rules match first. Do keep in mind that order matters -- for similar rules. -- --- ### Limitations +-- In some cases, folding may be far more expensive than lexing, particularly +-- in lexers with a lot of potential fold points. If your lexer is exhibiting +-- signs of slowness, try disabling folding in your text editor first. If that +-- speeds things up, you can try reducing the number of fold points you added, +-- overriding `lexer.fold()` with your own implementation, or simply eliminating +-- folding support from your lexer. +-- +-- #### Limitations -- -- Embedded preprocessor languages like PHP cannot completely embed in their -- parent languages in that the parent's tokens do not support start and end @@ -655,19 +749,15 @@ local M = {} -- --
    -- --- or --- ---
    > --- -- will not style correctly. -- --- ### Troubleshooting +-- #### Troubleshooting -- -- Errors in lexers can be tricky to debug. Lexers print Lua errors to -- `io.stderr` and `_G.print()` statements to `io.stdout`. Running your editor -- from a terminal is the easiest way to see errors as they occur. -- --- ### Risks +-- #### Risks -- -- Poorly written lexers have the ability to crash Scintilla (and thus its -- containing application), so unsaved data might be lost. However, I have only @@ -676,13 +766,13 @@ local M = {} -- (either correctly or incorrectly, it does not matter), I have not observed -- any crashes. -- --- ### Acknowledgements +-- #### Acknowledgements -- -- Thanks to Peter Odding for his [lexer post][] on the Lua mailing list -- that inspired me, and thanks to Roberto Ierusalimschy for LPeg. -- -- [lexer post]: http://lua-users.org/lists/lua-l/2007-04/msg00116.html --- @field LEXERPATH (string) +-- @field path (string) -- The path used to search for a lexer to load. -- Identical in format to Lua's `package.path` string. -- The default value is `package.path`. @@ -770,6 +860,8 @@ local M = {} -- @field STYLE_CALLTIP (string) -- The style used by call tips if [`buffer.call_tip_use_style`]() is set. -- Only the font name, size, and color attributes are used. +-- @field STYLE_FOLDDISPLAYTEXT (string) +-- The style used for fold display text. -- @field any (pattern) -- A pattern that matches any single character. -- @field ascii (pattern) @@ -802,7 +894,7 @@ local M = {} -- A pattern that matches any whitespace character ('\t', '\v', '\f', '\n', -- '\r', space). -- @field newline (pattern) --- A pattern that matches any set of end of line characters. +-- A pattern that matches a sequence of end of line characters. -- @field nonnewline (pattern) -- A pattern that matches any single, non-newline character. -- @field nonnewline_esc (pattern) @@ -841,6 +933,9 @@ local M = {} -- @field indent_amount (table, Read-only) -- Table of indentation amounts in character columns, for line numbers -- starting from zero. +-- @field line_state (table) +-- Table of integer line states for line numbers starting from zero. +-- Line states can be used by lexers for keeping track of persistent states. -- @field property (table) -- Map of key-value string pairs. -- @field property_expanded (table, Read-only) @@ -850,7 +945,7 @@ local M = {} -- Map of key-value pairs with values interpreted as numbers, or `0` if not -- found. -- @field style_at (table, Read-only) --- Table of style names at positions in the buffer starting from zero. +-- Table of style names at positions in the buffer starting from 1. module('lexer')]=] local lpeg = require('lpeg') @@ -859,15 +954,7 @@ local lpeg_Ct, lpeg_Cc, lpeg_Cp = lpeg.Ct, lpeg.Cc, lpeg.Cp local lpeg_Cmt, lpeg_C = lpeg.Cmt, lpeg.C local lpeg_match = lpeg.match -M.LEXERPATH = package.path - --- Table of loaded lexers. -local lexers = {} - --- Keep track of the last parent lexer loaded. This lexer's rules are used for --- proxy lexers (those that load parent and child lexers to embed) that do not --- declare a parent lexer. -local parent_lexer +M.path = package.path if not package.searchpath then -- Searches for the given *name* in the given *path*. @@ -878,94 +965,16 @@ if not package.searchpath then for part in path:gmatch('[^;]+') do local filename = part:gsub('%?', name) local f = io.open(filename, 'r') - if f then f:close() return filename end - tried[#tried + 1] = ("no file '%s'"):format(filename) + if f then + f:close() + return filename + end + tried[#tried + 1] = string.format("no file '%s'", filename) end return nil, table.concat(tried, '\n') end end --- Adds a rule to a lexer's current ordered list of rules. --- @param lexer The lexer to add the given rule to. --- @param name The name associated with this rule. It is used for other lexers --- to access this particular rule from the lexer's `_RULES` table. It does not --- have to be the same as the name passed to `token`. --- @param rule The LPeg pattern of the rule. -local function add_rule(lexer, id, rule) - if not lexer._RULES then - lexer._RULES = {} - -- Contains an ordered list (by numerical index) of rule names. This is used - -- in conjunction with lexer._RULES for building _TOKENRULE. - lexer._RULEORDER = {} - end - lexer._RULES[id] = rule - lexer._RULEORDER[#lexer._RULEORDER + 1] = id -end - --- Adds a new Scintilla style to Scintilla. --- @param lexer The lexer to add the given style to. --- @param token_name The name of the token associated with this style. --- @param style A Scintilla style created from `style()`. --- @see style -local function add_style(lexer, token_name, style) - local num_styles = lexer._numstyles - if num_styles == 32 then num_styles = num_styles + 8 end -- skip predefined - if num_styles >= 255 then print('Too many styles defined (255 MAX)') end - lexer._TOKENSTYLES[token_name], lexer._numstyles = num_styles, num_styles + 1 - lexer._EXTRASTYLES[token_name] = style -end - --- (Re)constructs `lexer._TOKENRULE`. --- @param parent The parent lexer. -local function join_tokens(lexer) - local patterns, order = lexer._RULES, lexer._RULEORDER - local token_rule = patterns[order[1]] - for i = 2, #order do token_rule = token_rule + patterns[order[i]] end - lexer._TOKENRULE = token_rule + M.token(M.DEFAULT, M.any) - return lexer._TOKENRULE -end - --- Adds a given lexer and any of its embedded lexers to a given grammar. --- @param grammar The grammar to add the lexer to. --- @param lexer The lexer to add. -local function add_lexer(grammar, lexer, token_rule) - local token_rule = join_tokens(lexer) - local lexer_name = lexer._NAME - for _, child in ipairs(lexer._CHILDREN) do - if child._CHILDREN then add_lexer(grammar, child) end - local child_name = child._NAME - local rules = child._EMBEDDEDRULES[lexer_name] - local rules_token_rule = grammar['__'..child_name] or rules.token_rule - grammar[child_name] = (-rules.end_rule * rules_token_rule)^0 * - rules.end_rule^-1 * lpeg_V(lexer_name) - local embedded_child = '_'..child_name - grammar[embedded_child] = rules.start_rule * (-rules.end_rule * - rules_token_rule)^0 * rules.end_rule^-1 - token_rule = lpeg_V(embedded_child) + token_rule - end - grammar['__'..lexer_name] = token_rule -- can contain embedded lexer rules - grammar[lexer_name] = token_rule^0 -end - --- (Re)constructs `lexer._GRAMMAR`. --- @param lexer The parent lexer. --- @param initial_rule The name of the rule to start lexing with. The default --- value is `lexer._NAME`. Multilang lexers use this to start with a child --- rule if necessary. -local function build_grammar(lexer, initial_rule) - local children = lexer._CHILDREN - if children then - local lexer_name = lexer._NAME - if not initial_rule then initial_rule = lexer_name end - local grammar = {initial_rule} - add_lexer(grammar, lexer) - lexer._INITIALRULE = initial_rule - lexer._GRAMMAR = lpeg_Ct(lpeg_P(grammar)) - else - lexer._GRAMMAR = lpeg_Ct(join_tokens(lexer)^0) - end -end - local string_upper = string.upper -- Default styles. local default = { @@ -973,112 +982,270 @@ local default = { 'identifier', 'operator', 'error', 'preprocessor', 'constant', 'variable', 'function', 'class', 'type', 'label', 'regex', 'embedded' } -for _, v in ipairs(default) do - M[string_upper(v)], M['STYLE_'..string_upper(v)] = v, '$(style.'..v..')' +for i = 1, #default do + local name, upper_name = default[i], string_upper(default[i]) + M[upper_name], M['STYLE_'..upper_name] = name, '$(style.'..name..')' end -- Predefined styles. local predefined = { 'default', 'linenumber', 'bracelight', 'bracebad', 'controlchar', - 'indentguide', 'calltip' + 'indentguide', 'calltip', 'folddisplaytext' } -for _, v in ipairs(predefined) do - M[string_upper(v)], M['STYLE_'..string_upper(v)] = v, '$(style.'..v..')' +for i = 1, #predefined do + local name, upper_name = predefined[i], string_upper(predefined[i]) + M[upper_name], M['STYLE_'..upper_name] = name, '$(style.'..name..')' end --- --- Initializes or loads and returns the lexer of string name *name*. --- Scintilla calls this function to load a lexer. Parent lexers also call this --- function to load child lexers and vice-versa. The user calls this function --- to load a lexer when using Scintillua as a Lua library. --- @param name The name of the lexing language. --- @param alt_name The alternate name of the lexing language. This is useful for --- embedding the same child lexer with multiple sets of start and end tokens. --- @return lexer object --- @name load -function M.load(name, alt_name) - if lexers[alt_name or name] then return lexers[alt_name or name] end - parent_lexer = nil -- reset - - -- When using Scintillua as a stand-alone module, the `property` and - -- `property_int` tables do not exist (they are not useful). Create them to - -- prevent errors from occurring. - if not M.property then - M.property, M.property_int = {}, setmetatable({}, { - __index = function(t, k) - return tostring(tonumber(M.property[k]) or 0) - end, - __newindex = function() error('read-only property') end - }) +-- Adds pattern *rule* identified by string *id* to the ordered list of rules +-- for lexer *lexer*. +-- @param lexer The lexer to add the given rule to. +-- @param id The id associated with this rule. It does not have to be the same +-- as the name passed to `token()`. +-- @param rule The LPeg pattern of the rule. +-- @see modify_rule +-- @name add_rule +function M.add_rule(lexer, id, rule) + if lexer._lexer then lexer = lexer._lexer end -- proxy; get true parent + if not lexer._RULES then + lexer._RULES = {} + -- Contains an ordered list (by numerical index) of rule names. This is used + -- in conjunction with lexer._RULES for building _TOKENRULE. + lexer._RULEORDER = {} end + lexer._RULES[id] = rule + lexer._RULEORDER[#lexer._RULEORDER + 1] = id + lexer:build_grammar() +end - -- Load the language lexer with its rules, styles, etc. - M.WHITESPACE = (alt_name or name)..'_whitespace' - local lexer_file, error = package.searchpath(name, M.LEXERPATH) - local ok, lexer = pcall(dofile, lexer_file or '') - if not ok then - _G.print(error or lexer) -- error message - lexer = {_NAME = alt_name or name} +--- +-- Replaces in lexer *lexer* the existing rule identified by string *id* with +-- pattern *rule*. +-- @param lexer The lexer to modify. +-- @param id The id associated with this rule. +-- @param rule The LPeg pattern of the rule. +-- @name modify_rule +function M.modify_rule(lexer, id, rule) + if lexer._lexer then lexer = lexer._lexer end -- proxy; get true parent + lexer._RULES[id] = rule + lexer:build_grammar() +end + +--- +-- Returns the rule identified by string *id*. +-- @param lexer The lexer to fetch a rule from. +-- @param id The id of the rule to fetch. +-- @return pattern +-- @name get_rule +function M.get_rule(lexer, id) + if lexer._lexer then lexer = lexer._lexer end -- proxy; get true parent + return lexer._RULES[id] +end + +--- +-- Associates string *token_name* in lexer *lexer* with Scintilla style string +-- *style*. +-- Style strings are comma-separated property settings. Available property +-- settings are: +-- +-- * `font:name`: Font name. +-- * `size:int`: Font size. +-- * `bold` or `notbold`: Whether or not the font face is bold. +-- * `weight:int`: Font weight (between 1 and 999). +-- * `italics` or `notitalics`: Whether or not the font face is italic. +-- * `underlined` or `notunderlined`: Whether or not the font face is +-- underlined. +-- * `fore:color`: Font face foreground color in "#RRGGBB" or 0xBBGGRR format. +-- * `back:color`: Font face background color in "#RRGGBB" or 0xBBGGRR format. +-- * `eolfilled` or `noteolfilled`: Whether or not the background color +-- extends to the end of the line. +-- * `case:char`: Font case ('u' for uppercase, 'l' for lowercase, and 'm' for +-- mixed case). +-- * `visible` or `notvisible`: Whether or not the text is visible. +-- * `changeable` or `notchangeable`: Whether or not the text is changeable or +-- read-only. +-- +-- Property settings may also contain "$(property.name)" expansions for +-- properties defined in Scintilla, theme files, etc. +-- @param lexer The lexer to add a style to. +-- @param token_name The name of the token to associated with the style. +-- @param style A style string for Scintilla. +-- @usage lex:add_style('longstring', lexer.STYLE_STRING) +-- @usage lex:add_style('deprecated_function', lexer.STYLE_FUNCTION..',italics') +-- @usage lex:add_style('visible_ws', +-- lexer.STYLE_WHITESPACE..',back:$(color.grey)') +-- @name add_style +function M.add_style(lexer, token_name, style) + local num_styles = lexer._numstyles + if num_styles == 32 then num_styles = num_styles + 8 end -- skip predefined + if num_styles >= 255 then print('Too many styles defined (255 MAX)') end + lexer._TOKENSTYLES[token_name], lexer._numstyles = num_styles, num_styles + 1 + lexer._EXTRASTYLES[token_name] = style + -- If the lexer is a proxy or a child that embedded itself, copy this style to + -- the parent lexer. + if lexer._lexer then lexer._lexer:add_style(token_name, style) end +end + +--- +-- Adds to lexer *lexer* a fold point whose beginning and end tokens are string +-- *token_name* tokens with string content *start_symbol* and *end_symbol*, +-- respectively. +-- In the event that *start_symbol* may or may not be a fold point depending on +-- context, and that additional processing is required, *end_symbol* may be a +-- function that ultimately returns `1` (indicating a beginning fold point), +-- `-1` (indicating an ending fold point), or `0` (indicating no fold point). +-- That function is passed the following arguments: +-- +-- * `text`: The text being processed for fold points. +-- * `pos`: The position in *text* of the beginning of the line currently +-- being processed. +-- * `line`: The text of the line currently being processed. +-- * `s`: The position of *start_symbol* in *line*. +-- * `symbol`: *start_symbol* itself. +-- @param lexer The lexer to add a fold point to. +-- @param token_name The token name of text that indicates a fold point. +-- @param start_symbol The text that indicates the beginning of a fold point. +-- @param end_symbol Either the text that indicates the end of a fold point, or +-- a function that returns whether or not *start_symbol* is a beginning fold +-- point (1), an ending fold point (-1), or not a fold point at all (0). +-- @usage lex:add_fold_point(lexer.OPERATOR, '{', '}') +-- @usage lex:add_fold_point(lexer.KEYWORD, 'if', 'end') +-- @usage lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) +-- @usage lex:add_fold_point('custom', function(text, pos, line, s, symbol) +-- ... end) +-- @name add_fold_point +function M.add_fold_point(lexer, token_name, start_symbol, end_symbol) + if not lexer._FOLDPOINTS then lexer._FOLDPOINTS = {_SYMBOLS = {}} end + local symbols = lexer._FOLDPOINTS._SYMBOLS + if not symbols[start_symbol] then + symbols[#symbols + 1], symbols[start_symbol] = start_symbol, true end - if alt_name then lexer._NAME = alt_name end - - -- Create the initial maps for token names to style numbers and styles. - local token_styles = {} - for i = 1, #default do token_styles[default[i]] = i - 1 end - for i = 1, #predefined do token_styles[predefined[i]] = i + 31 end - lexer._TOKENSTYLES, lexer._numstyles = token_styles, #default - lexer._EXTRASTYLES = {} - - -- If the lexer is a proxy (loads parent and child lexers to embed) and does - -- not declare a parent, try and find one and use its rules. - if not lexer._rules and not lexer._lexer then lexer._lexer = parent_lexer end - - -- If the lexer is a proxy or a child that embedded itself, add its rules and - -- styles to the parent lexer. Then set the parent to be the main lexer. + if not lexer._FOLDPOINTS[token_name] then + lexer._FOLDPOINTS[token_name] = {} + end + if type(end_symbol) == 'string' then + if not symbols[end_symbol] then + symbols[#symbols + 1], symbols[end_symbol] = end_symbol, true + end + lexer._FOLDPOINTS[token_name][start_symbol] = 1 + lexer._FOLDPOINTS[token_name][end_symbol] = -1 + else + lexer._FOLDPOINTS[token_name][start_symbol] = end_symbol -- function or int + end + -- If the lexer is a proxy or a child that embedded itself, copy this fold + -- point to the parent lexer. if lexer._lexer then - local l, _r, _s = lexer._lexer, lexer._rules, lexer._tokenstyles - if not l._tokenstyles then l._tokenstyles = {} end - for _, r in ipairs(_r or {}) do - -- Prevent rule id clashes. - l._rules[#l._rules + 1] = {lexer._NAME..'_'..r[1], r[2]} + lexer._lexer:add_fold_point(token_name, start_symbol, end_symbol) + end +end + +-- (Re)constructs `lexer._TOKENRULE`. +local function join_tokens(lexer) + local patterns, order = lexer._RULES, lexer._RULEORDER + local token_rule = patterns[order[1]] + for i = 2, #order do token_rule = token_rule + patterns[order[i]] end + lexer._TOKENRULE = token_rule + M.token(M.DEFAULT, M.any) + return lexer._TOKENRULE +end + +-- Metatable for lexer grammars. +-- These grammars are just tables ultimately passed to `lpeg.P()`. +local grammar_mt = {__index = { + -- Adds lexer *lexer* and any of its embedded lexers to this grammar. + -- @param lexer The lexer to add. + add_lexer = function(self, lexer) + local lexer_name = lexer._PARENTNAME or lexer._NAME + local token_rule = lexer:join_tokens() + for i = 1, #lexer._CHILDREN do + local child = lexer._CHILDREN[i] + if child._CHILDREN then self:add_lexer(child) end + local rules = child._EMBEDDEDRULES[lexer_name] + local rules_token_rule = self['__'..child._NAME] or rules.token_rule + self[child._NAME] = (-rules.end_rule * rules_token_rule)^0 * + rules.end_rule^-1 * lpeg_V(lexer_name) + local embedded_child = '_'..child._NAME + self[embedded_child] = rules.start_rule * + (-rules.end_rule * rules_token_rule)^0 * + rules.end_rule^-1 + token_rule = lpeg_V(embedded_child) + token_rule end - for token, style in pairs(_s or {}) do l._tokenstyles[token] = style end - lexer = l + self['__'..lexer_name] = token_rule -- can contain embedded lexer rules + self[lexer_name] = token_rule^0 end +}} - -- Add the lexer's styles and build its grammar. - if lexer._rules then - for token, style in pairs(lexer._tokenstyles or {}) do - add_style(lexer, token, style) +-- (Re)constructs `lexer._GRAMMAR`. +-- @param initial_rule The name of the rule to start lexing with. The default +-- value is `lexer._NAME`. Multilang lexers use this to start with a child +-- rule if necessary. +local function build_grammar(lexer, initial_rule) + if not lexer._RULES then return end + if lexer._CHILDREN then + if not initial_rule then initial_rule = lexer._NAME end + local grammar = setmetatable({initial_rule}, grammar_mt) + grammar:add_lexer(lexer) + lexer._INITIALRULE = initial_rule + lexer._GRAMMAR = lpeg_Ct(lpeg_P(grammar)) + else + lexer._GRAMMAR = lpeg_Ct(lexer:join_tokens()^0) + end +end + +--- +-- Embeds child lexer *child* in parent lexer *lexer* using patterns +-- *start_rule* and *end_rule*, which signal the beginning and end of the +-- embedded lexer, respectively. +-- @param lexer The parent lexer. +-- @param child The child lexer. +-- @param start_rule The pattern that signals the beginning of the embedded +-- lexer. +-- @param end_rule The pattern that signals the end of the embedded lexer. +-- @usage html:embed(css, css_start_rule, css_end_rule) +-- @usage html:embed(lex, php_start_rule, php_end_rule) -- from php lexer +-- @name embed +function M.embed(lexer, child, start_rule, end_rule) + if lexer._lexer then lexer = lexer._lexer end -- proxy; get true parent + -- Add child rules. + if not child._EMBEDDEDRULES then child._EMBEDDEDRULES = {} end + if not child._RULES then error('Cannot embed lexer with no rules') end + child._EMBEDDEDRULES[lexer._NAME] = { + ['start_rule'] = start_rule, + token_rule = child:join_tokens(), + ['end_rule'] = end_rule + } + if not lexer._CHILDREN then lexer._CHILDREN = {} end + local children = lexer._CHILDREN + children[#children + 1] = child + -- Add child styles. + for token, style in pairs(child._EXTRASTYLES) do + lexer:add_style(token, style) + end + -- Add child fold symbols. + if child._FOLDPOINTS then + for token_name, symbols in pairs(child._FOLDPOINTS) do + if token_name ~= '_SYMBOLS' then + for symbol, v in pairs(symbols) do + lexer:add_fold_point(token_name, symbol, v) + end + end end - for _, r in ipairs(lexer._rules) do add_rule(lexer, r[1], r[2]) end - build_grammar(lexer) end - -- Add the lexer's unique whitespace style. - add_style(lexer, lexer._NAME..'_whitespace', M.STYLE_WHITESPACE) - - -- Process the lexer's fold symbols. - if lexer._foldsymbols and lexer._foldsymbols._patterns then - local patterns = lexer._foldsymbols._patterns - for i = 1, #patterns do patterns[i] = '()('..patterns[i]..')' end - end - - lexer.lex, lexer.fold = M.lex, M.fold - lexers[alt_name or name] = lexer - return lexer + lexer:build_grammar() + child._lexer = lexer -- use parent's tokens if child is embedding itself end --- -- Lexes a chunk of text *text* (that has an initial style number of --- *init_style*) with lexer *lexer*. --- If *lexer* has a `_LEXBYLINE` flag set, the text is lexed one line at a time. --- Otherwise the text is lexed as a whole. --- @param lexer The lexer object to lex with. +-- *init_style*) using lexer *lexer*, returning a table of token names and +-- positions. +-- @param lexer The lexer to lex text with. -- @param text The text in the buffer to lex. -- @param init_style The current style. Multiple-language lexers use this to -- determine which language to start lexing in. -- @return table of token names and positions. -- @name lex function M.lex(lexer, text, init_style) + if not lexer._GRAMMAR then return {M.DEFAULT, #text + 1} end if not lexer._LEXBYLINE then -- For multilang lexers, build a new grammar whose initial_rule is the -- current language. @@ -1087,7 +1254,7 @@ function M.lex(lexer, text, init_style) if style_num == init_style then local lexer_name = style:match('^(.+)_whitespace') or lexer._NAME if lexer._INITIALRULE ~= lexer_name then - build_grammar(lexer, lexer_name) + lexer:build_grammar(lexer_name) end break end @@ -1118,18 +1285,17 @@ function M.lex(lexer, text, init_style) end --- --- Folds a chunk of text *text* with lexer *lexer*. --- Folds *text* starting at position *start_pos* on line number *start_line* --- with a beginning fold level of *start_level* in the buffer. If *lexer* has a --- a `_fold` function or a `_foldsymbols` table, that field is used to perform --- folding. Otherwise, if *lexer* has a `_FOLDBYINDENTATION` field set, or if a --- `fold.by.indentation` property is set, folding by indentation is done. --- @param lexer The lexer object to fold with. +-- Determines fold points in a chunk of text *text* using lexer *lexer*, +-- returning a table of fold levels associated with line numbers. +-- *text* starts at position *start_pos* on line number *start_line* with a +-- beginning fold level of *start_level* in the buffer. +-- @param lexer The lexer to fold text with. -- @param text The text in the buffer to fold. --- @param start_pos The position in the buffer *text* starts at. +-- @param start_pos The position in the buffer *text* starts at, starting at +-- zero. -- @param start_line The line number *text* starts on. -- @param start_level The fold level *text* starts on. --- @return table of fold levels. +-- @return table of fold levels associated with line numbers. -- @name fold function M.fold(lexer, text, start_pos, start_line, start_level) local folds = {} @@ -1137,36 +1303,46 @@ function M.fold(lexer, text, start_pos, start_line, start_level) local fold = M.property_int['fold'] > 0 local FOLD_BASE = M.FOLD_BASE local FOLD_HEADER, FOLD_BLANK = M.FOLD_HEADER, M.FOLD_BLANK - if fold and lexer._fold then - return lexer._fold(text, start_pos, start_line, start_level) - elseif fold and lexer._foldsymbols then + if fold and lexer._FOLDPOINTS then local lines = {} for p, l in (text..'\n'):gmatch('()(.-)\r?\n') do lines[#lines + 1] = {p, l} end local fold_zero_sum_lines = M.property_int['fold.on.zero.sum.lines'] > 0 - local fold_symbols = lexer._foldsymbols - local fold_symbols_patterns = fold_symbols._patterns + local fold_compact = M.property_int['fold.compact'] > 0 + local fold_points = lexer._FOLDPOINTS + local fold_point_symbols = fold_points._SYMBOLS local style_at, fold_level = M.style_at, M.fold_level local line_num, prev_level = start_line, start_level local current_level = prev_level for i = 1, #lines do local pos, line = lines[i][1], lines[i][2] if line ~= '' then + if lexer._CASEINSENSITIVEFOLDPOINTS then line = line:lower() end local level_decreased = false - for j = 1, #fold_symbols_patterns do - for s, match in line:gmatch(fold_symbols_patterns[j]) do - local symbols = fold_symbols[style_at[start_pos + pos + s - 1]] - local l = symbols and symbols[match] - if type(l) == 'function' then l = l(text, pos, line, s, match) end - if type(l) == 'number' then - current_level = current_level + l - if l < 0 and current_level < prev_level then - -- Potential zero-sum line. If the level were to go back up on - -- the same line, the line may be marked as a fold header. - level_decreased = true + for j = 1, #fold_point_symbols do + local symbol = fold_point_symbols[j] + local word = not symbol:find('[^%w_]') + local s, e = line:find(symbol, 1, true) + while s and e do + --if not word or line:find('^%f[%w_]'..symbol..'%f[^%w_]', s) then + if not word or not ((s > 1 and line:find('^[%w_]', s - 1)) or + line:find('^[%w_]', e + 1)) then + local symbols = fold_points[style_at[start_pos + pos + s - 1]] + local level = symbols and symbols[symbol] + if type(level) == 'function' then + level = level(text, pos, line, s, symbol) + end + if type(level) == 'number' then + current_level = current_level + level + if level < 0 and current_level < prev_level then + -- Potential zero-sum line. If the level were to go back up on + -- the same line, the line may be marked as a fold header. + level_decreased = true + end end end + s = line:find(symbol, s + 1, true) end end folds[line_num] = prev_level @@ -1188,7 +1364,7 @@ function M.fold(lexer, text, start_pos, start_line, start_level) if current_level < FOLD_BASE then current_level = FOLD_BASE end prev_level = current_level else - folds[line_num] = prev_level + FOLD_BLANK + folds[line_num] = prev_level + (fold_compact and FOLD_BLANK or 0) end line_num = line_num + 1 end @@ -1250,6 +1426,158 @@ function M.fold(lexer, text, start_pos, start_line, start_level) return folds end +--- +-- Creates a returns a new lexer with the given name. +-- @param name The lexer's name. +-- @param opts Table of lexer options. Options currently supported: +-- * `lex_by_line`: Whether or not the lexer only processes whole lines of +-- text (instead of arbitrary chunks of text) at a time. +-- Line lexers cannot look ahead to subsequent lines. +-- The default value is `false`. +-- * `fold_by_indentation`: Whether or not the lexer does not define any fold +-- points and that fold points should be calculated based on changes in line +-- indentation. +-- The default value is `false`. +-- * `case_insensitive_fold_points`: Whether or not fold points added via +-- `lexer.add_fold_point()` ignore case. +-- The default value is `false`. +-- * `inherit`: Lexer to inherit from. +-- The default value is `nil`. +-- @usage lexer.new('rhtml', {inherit = lexer.load('html')}) +-- @name new +function M.new(name, opts) + local lexer = { + _NAME = assert(name, 'lexer name expected'), + _LEXBYLINE = opts and opts['lex_by_line'], + _FOLDBYINDENTATION = opts and opts['fold_by_indentation'], + _CASEINSENSITIVEFOLDPOINTS = opts and opts['case_insensitive_fold_points'], + _lexer = opts and opts['inherit'] + } + + -- Create the initial maps for token names to style numbers and styles. + local token_styles = {} + for i = 1, #default do token_styles[default[i]] = i - 1 end + for i = 1, #predefined do token_styles[predefined[i]] = i + 31 end + lexer._TOKENSTYLES, lexer._numstyles = token_styles, #default + lexer._EXTRASTYLES = {} + + return setmetatable(lexer, {__index = { + add_rule = M.add_rule, modify_rule = M.modify_rule, get_rule = M.get_rule, + add_style = M.add_style, add_fold_point = M.add_fold_point, + join_tokens = join_tokens, build_grammar = build_grammar, embed = M.embed, + lex = M.lex, fold = M.fold + }}) +end + +-- Legacy support for older lexers. +-- Processes the `lex._rules`, `lex._tokenstyles`, and `lex._foldsymbols` +-- tables. +-- Since legacy lexers may be processed up to twice, ensure their default styles +-- and rules are not processed more than once. +local function process_legacy_lexer(lexer) + local function warn(msg) --[[io.stderr:write(msg, "\n")]] end + if not lexer._LEGACY then + lexer._LEGACY = true + warn("lexers as tables are deprecated; use 'lexer.new()'") + local token_styles = {} + for i = 1, #default do token_styles[default[i]] = i - 1 end + for i = 1, #predefined do token_styles[predefined[i]] = i + 31 end + lexer._TOKENSTYLES, lexer._numstyles = token_styles, #default + lexer._EXTRASTYLES = {} + setmetatable(lexer, getmetatable(M.new(''))) + if lexer._rules then + warn("lexer '_rules' table is deprecated; use 'add_rule()'") + for i = 1, #lexer._rules do + lexer:add_rule(lexer._rules[i][1], lexer._rules[i][2]) + end + end + end + if lexer._tokenstyles then + warn("lexer '_tokenstyles' table is deprecated; use 'add_style()'") + for token, style in pairs(lexer._tokenstyles) do + -- If this legacy lexer is being processed a second time, only add styles + -- added since the first processing. + if not lexer._TOKENSTYLES[token] then lexer:add_style(token, style) end + end + end + if lexer._foldsymbols then + warn("lexer '_foldsymbols' table is deprecated; use 'add_fold_point()'") + for token_name, symbols in pairs(lexer._foldsymbols) do + if type(symbols) == 'table' and token_name ~= '_patterns' then + for symbol, v in pairs(symbols) do + lexer:add_fold_point(token_name, symbol, v) + end + end + end + if lexer._foldsymbols._case_insensitive then + lexer._CASEINSENSITIVEFOLDPOINTS = true + end + elseif lexer._fold then + lexer.fold = function(self, ...) return lexer._fold(...) end + end +end + +local lexers = {} -- cache of loaded lexers +--- +-- Initializes or loads and returns the lexer of string name *name*. +-- Scintilla calls this function in order to load a lexer. Parent lexers also +-- call this function in order to load child lexers and vice-versa. The user +-- calls this function in order to load a lexer when using this module as a Lua +-- library. +-- @param name The name of the lexing language. +-- @param alt_name The alternate name of the lexing language. This is useful for +-- embedding the same child lexer with multiple sets of start and end tokens. +-- @param cache Flag indicating whether or not to load lexers from the cache. +-- This should only be `true` when initially loading a lexer (e.g. not from +-- within another lexer for embedding purposes). +-- The default value is `false`. +-- @return lexer object +-- @name load +function M.load(name, alt_name, cache) + if cache and lexers[alt_name or name] then return lexers[alt_name or name] end + + -- When using this module as a stand-alone module, the `property` and + -- `property_int` tables do not exist (they are not useful). Create them in + -- order prevent errors from occurring. + if not M.property then + M.property, M.property_int = {}, setmetatable({}, { + __index = function(t, k) return tonumber(M.property[k]) or 0 end, + __newindex = function() error('read-only property') end + }) + end + + -- Load the language lexer with its rules, styles, etc. + -- However, replace the default `WHITESPACE` style name with a unique + -- whitespace style name (and then automatically add it afterwards), since + -- embedded lexing relies on these unique whitespace style names. Note that + -- loading embedded lexers changes `WHITESPACE` again, so when adding it + -- later, do not reference the potentially incorrect value. + M.WHITESPACE = (alt_name or name)..'_whitespace' + local lexer = dofile(assert(package.searchpath(name, M.path))) + assert(lexer, string.format("'%s.lua' did not return a lexer", name)) + if alt_name then lexer._NAME = alt_name end + if not getmetatable(lexer) or lexer._LEGACY then + -- A legacy lexer may need to be processed a second time in order to pick up + -- any `_tokenstyles` or `_foldsymbols` added after `lexer.embed_lexer()`. + process_legacy_lexer(lexer) + if lexer._lexer and lexer._lexer._LEGACY then + process_legacy_lexer(lexer._lexer) -- mainly for `_foldsymbols` edits + end + end + lexer:add_style((alt_name or name)..'_whitespace', M.STYLE_WHITESPACE) + + -- If the lexer is a proxy or a child that embedded itself, set the parent to + -- be the main lexer. Keep a reference to the old parent name since embedded + -- child rules reference and use that name. + if lexer._lexer then + lexer = lexer._lexer + lexer._PARENTNAME, lexer._NAME = lexer._NAME, alt_name or name + end + + if cache then lexers[alt_name or name] = lexer end + return lexer +end + -- The following are utility functions lexers will have access to. -- Common patterns. @@ -1268,7 +1596,7 @@ M.print = lpeg_R(' ~') M.punct = lpeg_R('!/', ':@', '[\'', '{~') M.space = lpeg_S('\t\v\f\n\r ') -M.newline = lpeg_S('\r\n\f')^1 +M.newline = lpeg_P('\r')^-1 * '\n' M.nonnewline = 1 - M.newline M.nonnewline_esc = 1 - (M.newline + '\\') + '\\' * M.any @@ -1277,23 +1605,24 @@ M.hex_num = '0' * lpeg_S('xX') * M.xdigit^1 M.oct_num = '0' * lpeg_R('07')^1 M.integer = lpeg_S('+-')^-1 * (M.hex_num + M.oct_num + M.dec_num) M.float = lpeg_S('+-')^-1 * - (M.digit^0 * '.' * M.digit^1 + M.digit^1 * '.' * M.digit^0 + - M.digit^1) * - lpeg_S('eE') * lpeg_S('+-')^-1 * M.digit^1 + ((M.digit^0 * '.' * M.digit^1 + M.digit^1 * '.' * M.digit^0 * + -lpeg_P('.')) * + (lpeg_S('eE') * lpeg_S('+-')^-1 * M.digit^1)^-1 + + (M.digit^1 * lpeg_S('eE') * lpeg_S('+-')^-1 * M.digit^1)) + M.word = (M.alpha + '_') * (M.alnum + '_')^0 --- -- Creates and returns a token pattern with token name *name* and pattern -- *patt*. --- If *name* is not a predefined token name, its style must be defined in the --- lexer's `_tokenstyles` table. +-- If *name* is not a predefined token name, its style must be defined via +-- `lexer.add_style()`. -- @param name The name of token. If this name is not a predefined token name, --- then a style needs to be assiciated with it in the lexer's `_tokenstyles` --- table. +-- then a style needs to be assiciated with it via `lexer.add_style()`. -- @param patt The LPeg pattern associated with the token. -- @return pattern --- @usage local ws = token(l.WHITESPACE, l.space^1) --- @usage local annotation = token('annotation', '@' * l.word) +-- @usage local ws = token(lexer.WHITESPACE, lexer.space^1) +-- @usage local annotation = token('annotation', '@' * lexer.word) -- @name token function M.token(name, patt) return lpeg_Cc(name) * patt * lpeg_Cp() @@ -1317,10 +1646,11 @@ end -- range, like the "%b" Lua pattern. This flag only applies if *chars* -- consists of two different characters (e.g. "()"). -- @return pattern --- @usage local dq_str_escapes = l.delimited_range('"') --- @usage local dq_str_noescapes = l.delimited_range('"', false, true) --- @usage local unbalanced_parens = l.delimited_range('()') --- @usage local balanced_parens = l.delimited_range('()', false, false, true) +-- @usage local dq_str_escapes = lexer.delimited_range('"') +-- @usage local dq_str_noescapes = lexer.delimited_range('"', false, true) +-- @usage local unbalanced_parens = lexer.delimited_range('()') +-- @usage local balanced_parens = lexer.delimited_range('()', false, false, +-- true) -- @see nested_pair -- @name delimited_range function M.delimited_range(chars, single_line, no_escape, balanced) @@ -1348,8 +1678,8 @@ end -- beginning of a line. -- @param patt The LPeg pattern to match on the beginning of a line. -- @return pattern --- @usage local preproc = token(l.PREPROCESSOR, l.starts_line('#') * --- l.nonnewline^0) +-- @usage local preproc = token(lexer.PREPROCESSOR, lexer.starts_line('#') * +-- lexer.nonnewline^0) -- @name starts_line function M.starts_line(patt) return lpeg_Cmt(lpeg_C(patt), function(input, index, match, ...) @@ -1365,8 +1695,8 @@ end -- first non-whitespace character behind the current match position. -- @param s String character set like one passed to `lpeg.S()`. -- @return pattern --- @usage local regex = l.last_char_includes('+-*!%^&|=,([{') * --- l.delimited_range('/') +-- @usage local regex = lexer.last_char_includes('+-*!%^&|=,([{') * +-- lexer.delimited_range('/') -- @name last_char_includes function M.last_char_includes(s) s = '['..s:gsub('[-%%%[]', '%%%1')..']' @@ -1386,7 +1716,7 @@ end -- @param start_chars The string starting a nested sequence. -- @param end_chars The string ending a nested sequence. -- @return pattern --- @usage local nested_comment = l.nested_pair('/*', '*/') +-- @usage local nested_comment = lexer.nested_pair('/*', '*/') -- @see delimited_range -- @name nested_pair function M.nested_pair(start_chars, end_chars) @@ -1395,38 +1725,46 @@ function M.nested_pair(start_chars, end_chars) end --- --- Creates and returns a pattern that matches any single word in list *words*. --- Words consist of alphanumeric and underscore characters, as well as the --- characters in string set *word_chars*. *case_insensitive* indicates whether --- or not to ignore case when matching words. +-- Creates and returns a pattern that matches any single word in string *words*. +-- *case_insensitive* indicates whether or not to ignore case when matching +-- words. -- This is a convenience function for simplifying a set of ordered choice word -- patterns. --- @param words A table of words. --- @param word_chars Optional string of additional characters considered to be --- part of a word. By default, word characters are alphanumerics and --- underscores ("%w_" in Lua). This parameter may be `nil` or the empty string --- to indicate no additional word characters. +-- If *words* is a multi-line string, it may contain Lua line comments (`--`) +-- that will ultimately be ignored. +-- @param words A string list of words separated by spaces. -- @param case_insensitive Optional boolean flag indicating whether or not the --- word match is case-insensitive. The default is `false`. +-- word match is case-insensitive. The default value is `false`. +-- @param word_chars Unused legacy parameter. -- @return pattern --- @usage local keyword = token(l.KEYWORD, word_match{'foo', 'bar', 'baz'}) --- @usage local keyword = token(l.KEYWORD, word_match({'foo-bar', 'foo-baz', --- 'bar-foo', 'bar-baz', 'baz-foo', 'baz-bar'}, '-', true)) +-- @usage local keyword = token(lexer.KEYWORD, word_match[[foo bar baz]]) +-- @usage local keyword = token(lexer.KEYWORD, word_match([[foo-bar foo-baz +-- bar-foo bar-baz baz-foo baz-bar]], true)) -- @name word_match -function M.word_match(words, word_chars, case_insensitive) +function M.word_match(words, case_insensitive, word_chars) local word_list = {} - for _, word in ipairs(words) do + if type(words) == 'table' then + -- Legacy `word_match(word_list, word_chars, case_insensitive)` form. + words = table.concat(words, ' ') + word_chars, case_insensitive = case_insensitive, word_chars + end + for word in words:gsub('%-%-[^\n]+', ''):gmatch('%S+') do word_list[case_insensitive and word:lower() or word] = true + for char in word:gmatch('[^%w_]') do + if not (word_chars or ''):find(char, 1, true) then + word_chars = (word_chars or '')..char + end + end end local chars = M.alnum + '_' - if word_chars then chars = chars + lpeg_S(word_chars) end + if (word_chars or '') ~= '' then chars = chars + lpeg_S(word_chars) end return lpeg_Cmt(chars^1, function(input, index, word) if case_insensitive then word = word:lower() end return word_list[word] and index or nil end) end ---- +-- Deprecated legacy function. Use `parent:embed()` instead. -- Embeds child lexer *child* in parent lexer *parent* using patterns -- *start_rule* and *end_rule*, which signal the beginning and end of the -- embedded lexer, respectively. @@ -1435,34 +1773,15 @@ end -- @param start_rule The pattern that signals the beginning of the embedded -- lexer. -- @param end_rule The pattern that signals the end of the embedded lexer. --- @usage l.embed_lexer(M, css, css_start_rule, css_end_rule) --- @usage l.embed_lexer(html, M, php_start_rule, php_end_rule) --- @usage l.embed_lexer(html, ruby, ruby_start_rule, ruby_end_rule) +-- @usage lexer.embed_lexer(M, css, css_start_rule, css_end_rule) +-- @usage lexer.embed_lexer(html, M, php_start_rule, php_end_rule) +-- @usage lexer.embed_lexer(html, ruby, ruby_start_rule, ruby_end_rule) +-- @see embed -- @name embed_lexer function M.embed_lexer(parent, child, start_rule, end_rule) - -- Add child rules. - if not child._EMBEDDEDRULES then child._EMBEDDEDRULES = {} end - if not child._RULES then -- creating a child lexer to be embedded - if not child._rules then error('Cannot embed language with no rules') end - for _, r in ipairs(child._rules) do add_rule(child, r[1], r[2]) end - end - child._EMBEDDEDRULES[parent._NAME] = { - ['start_rule'] = start_rule, - token_rule = join_tokens(child), - ['end_rule'] = end_rule - } - if not parent._CHILDREN then parent._CHILDREN = {} end - local children = parent._CHILDREN - children[#children + 1] = child - -- Add child styles. - if not parent._tokenstyles then parent._tokenstyles = {} end - local tokenstyles = parent._tokenstyles - tokenstyles[child._NAME..'_whitespace'] = M.STYLE_WHITESPACE - for token, style in pairs(child._tokenstyles or {}) do - tokenstyles[token] = style - end - child._lexer = parent -- use parent's tokens if child is embedding itself - parent_lexer = parent -- use parent's tokens if the calling lexer is a proxy + if not getmetatable(parent) then process_legacy_lexer(parent) end + if not getmetatable(child) then process_legacy_lexer(child) end + parent:embed(child, start_rule, end_rule) end -- Determines if the previous line is a comment. @@ -1506,11 +1825,13 @@ local function next_line_is_comment(prefix, text, pos, line, s) end --- --- Returns a fold function (to be used within the lexer's `_foldsymbols` table) --- that folds consecutive line comments that start with string *prefix*. +-- Returns a fold function (to be passed to `lexer.add_fold_point()`) that folds +-- consecutive line comments that start with string *prefix*. -- @param prefix The prefix string defining a line comment. --- @usage [l.COMMENT] = {['--'] = l.fold_line_comments('--')} --- @usage [l.COMMENT] = {['//'] = l.fold_line_comments('//')} +-- @usage lex:add_fold_point(lexer.COMMENT, '--', +-- lexer.fold_line_comments('--')) +-- @usage lex:add_fold_point(lexer.COMMENT, '//', +-- lexer.fold_line_comments('//')) -- @name fold_line_comments function M.fold_line_comments(prefix) local property_int = M.property_int @@ -1539,49 +1860,11 @@ M.property_expanded = setmetatable({}, { --[[ The functions and fields below were defined in C. --- --- Individual fields for a lexer instance. --- @field _NAME The string name of the lexer. --- @field _rules An ordered list of rules for a lexer grammar. --- Each rule is a table containing an arbitrary rule name and the LPeg pattern --- associated with the rule. The order of rules is important as rules are --- matched sequentially. --- Child lexers should not use this table to access and/or modify their --- parent's rules and vice-versa. Use the `_RULES` table instead. --- @field _tokenstyles A map of non-predefined token names to styles. --- Remember to use token names, not rule names. It is recommended to use --- predefined styles or color-agnostic styles derived from predefined styles --- to ensure compatibility with user color themes. --- @field _foldsymbols A table of recognized fold points for the lexer. --- Keys are token names with table values defining fold points. Those table --- values have string keys of keywords or characters that indicate a fold --- point whose values are integers. A value of `1` indicates a beginning fold --- point and a value of `-1` indicates an ending fold point. Values can also --- be functions that return `1`, `-1`, or `0` (indicating no fold point) for --- keys which need additional processing. --- There is also a required `_pattern` key whose value is a table containing --- Lua pattern strings that match all fold points (the string keys contained --- in token name table values). When the lexer encounters text that matches --- one of those patterns, the matched text is looked up in its token's table --- to determine whether or not it is a fold point. --- @field _fold If this function exists in the lexer, it is called for folding --- the document instead of using `_foldsymbols` or indentation. --- @field _lexer The parent lexer object whose rules should be used. This field --- is only necessary to disambiguate a proxy lexer that loaded parent and --- child lexers for embedding and ended up having multiple parents loaded. --- @field _RULES A map of rule name keys with their associated LPeg pattern --- values for the lexer. --- This is constructed from the lexer's `_rules` table and accessible to other --- lexers for embedded lexer applications like modifying parent or child --- rules. --- @field _LEXBYLINE Indicates the lexer can only process one whole line of text --- (instead of an arbitrary chunk of text) at a time. --- The default value is `false`. Line lexers cannot look ahead to subsequent --- lines. --- @field _FOLDBYINDENTATION Declares the lexer does not define fold points and --- that fold points should be calculated based on changes in indentation. --- @class table --- @name lexer -local lexer +-- Returns the line number of the line that contains position *pos*, which +-- starts from 1. +-- @param pos The position to get the line number of. +-- @return number +local function line_from_position(pos) end ]] return M diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/lilypond.lua b/dep/scintilla/scintilla-3.10.6/lexlua/lilypond.lua new file mode 100644 index 00000000..a280fd46 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/lilypond.lua @@ -0,0 +1,31 @@ +-- Copyright 2006-2019 Robert Gieseke. See License.txt. +-- Lilypond LPeg lexer. +-- TODO Embed Scheme; Notes?, Numbers? + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('lilypond') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords, commands. +lex:add_rule('keyword', token(lexer.KEYWORD, '\\' * lexer.word)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, + lexer.delimited_range('"', false, true))) + +-- Comments. +-- TODO: block comment. +lex:add_rule('comment', token(lexer.COMMENT, '%' * lexer.nonnewline^0)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S("{}'~<>|"))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/lisp.lua b/dep/scintilla/scintilla-3.10.6/lexlua/lisp.lua new file mode 100644 index 00000000..19df30f9 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/lisp.lua @@ -0,0 +1,65 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Lisp LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('lisp') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + defclass defconstant defgeneric define-compiler-macro define-condition + define-method-combination define-modify-macro define-setf-expander + define-symbol-macro defmacro defmethod defpackage defparameter defsetf + defstruct deftype defun defvar + abort assert block break case catch ccase cerror cond ctypecase declaim + declare do do* do-all-symbols do-external-symbols do-symbols dolist dotimes + ecase error etypecase eval-when flet handler-bind handler-case if + ignore-errors in-package labels lambda let let* locally loop macrolet + multiple-value-bind proclaim prog prog* prog1 prog2 progn progv provide + require restart-bind restart-case restart-name return return-from signal + symbol-macrolet tagbody the throw typecase unless unwind-protect when + with-accessors with-compilation-unit with-condition-restarts + with-hash-table-iterator with-input-from-string with-open-file + with-open-stream with-output-to-string with-package-iterator + with-simple-restart with-slots with-standard-io-syntax + t nil +]])) + +local word = lexer.alpha * (lexer.alnum + '_' + '-')^0 + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, "'" * word + + lexer.delimited_range('"'))) + +-- Comments. +local line_comment = ';' * lexer.nonnewline^0 +local block_comment = '#|' * (lexer.any - '|#')^0 * P('|#')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, P('-')^-1 * lexer.digit^1 * + (S('./') * lexer.digit^1)^-1)) + +-- Entities. +lex:add_rule('entity', token('entity', '&' * word)) +lex:add_style('entity', lexer.STYLE_VARIABLE) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('<>=*/+-`@%()'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '(', ')') +lex:add_fold_point(lexer.OPERATOR, '[', ']') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '#|', '|#') +lex:add_fold_point(lexer.COMMENT, ';', lexer.fold_line_comments(';')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/litcoffee.lua b/dep/scintilla/scintilla-3.10.6/lexlua/litcoffee.lua new file mode 100644 index 00000000..2cd9a55c --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/litcoffee.lua @@ -0,0 +1,22 @@ +-- Copyright 2006-2019 Robert Gieseke. See License.txt. +-- Literate CoffeeScript LPeg lexer. +-- http://coffeescript.org/#literate + +local lexer = require('lexer') +local token = lexer.token +local P, S = lpeg.P, lpeg.S + +local lex = lexer.new('litcoffee', {inherit = lexer.load('markdown')}) + +-- Embedded CoffeeScript. +local coffeescript = lexer.load('coffeescript') +local coffee_start_rule = token(lexer.STYLE_EMBEDDED, (P(' ')^4 + P('\t'))) +local coffee_end_rule = token(lexer.STYLE_EMBEDDED, lexer.newline) +lex:embed(coffeescript, coffee_start_rule, coffee_end_rule) + +-- Use 'markdown_whitespace' instead of lexer.WHITESPACE since the latter would +-- expand to 'litcoffee_whitespace'. +lex:modify_rule('whitespace', token('markdown_whitespace', S(' \t')^1 + + S('\r\n')^1)) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/logtalk.lua b/dep/scintilla/scintilla-3.10.6/lexlua/logtalk.lua new file mode 100644 index 00000000..219a9509 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/logtalk.lua @@ -0,0 +1,35 @@ +-- Copyright © 2017-2019 Michael T. Richter . See License.txt. +-- Logtalk LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('logtalk', {inherit = lexer.load('prolog')}) + +lex:modify_rule('keyword', token(lexer.KEYWORD, word_match[[ + -- Logtalk "keywords" generated from Vim syntax highlighting file with Prolog + -- keywords stripped since were building up on the Prolog lexer. + abolish_category abolish_events abolish_object abolish_protocol after alias as + before built_in calls category category_property coinductive complements + complements_object conforms_to_protocol create create_category create_object + create_protocol create_logtalk_flag current current_category current_event + current_logtalk_flag current_object current_protocol define_events encoding + end_category end_class end_object end_protocol extends extends_category + extends_object extends_protocol forward implements implements_protocol imports + imports_category include info instantiates instantiates_class is + logtalk_compile logtalk_library_path logtalk_load logtalk_load_context + logtalk_make meta_non_terminal mode object object_property parameter private + protected protocol_property self sender set_logtalk_flag specializes + specializes_class synchronized this threaded threaded_call threaded_engine + threaded_engine_create threaded_engine_destroy threaded_engine_fetch + threaded_engine_next threaded_engine_next_reified threaded_engine_post + threaded_engine_self threaded_engine_yield threaded_exit threaded_ignore + threaded_notify threaded_once threaded_peek threaded_wait uses + -- info/1 and info/2 predicates have their own keywords manually extracted + -- from documentation. + comment argnames arguments author version date parameters parnames copyright + license remarks see_also +]]) + lex:get_rule('keyword')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/lua.lua b/dep/scintilla/scintilla-3.10.6/lexlua/lua.lua new file mode 100644 index 00000000..f70159cd --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/lua.lua @@ -0,0 +1,159 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Lua LPeg lexer. +-- Original written by Peter Odding, 2007/04/04. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('lua') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + and break do else elseif end false for function if in local nil not or repeat + return then true until while + -- Added in 5.2. + goto +]])) + +-- Functions and deprecated functions. +local func = token(lexer.FUNCTION, word_match[[ + assert collectgarbage dofile error getmetatable ipairs load loadfile next + pairs pcall print rawequal rawget rawset require select setmetatable tonumber + tostring type xpcall + -- Added in 5.2. + rawlen +]]) +local deprecated_func = token('deprecated_function', word_match[[ + -- Deprecated in 5.2. + getfenv loadstring module setfenv unpack +]]) +lex:add_rule('function', func + deprecated_func) +lex:add_style('deprecated_function', lexer.STYLE_FUNCTION..',italics') + +-- Constants. +lex:add_rule('constant', token(lexer.CONSTANT, word_match[[ + _G _VERSION + -- Added in 5.2. + _ENV +]])) + +-- Libraries and deprecated libraries. +local library = token('library', word_match[[ + -- Coroutine. + coroutine coroutine.create coroutine.resume coroutine.running coroutine.status + coroutine.wrap coroutine.yield + -- Coroutine added in 5.3. + coroutine.isyieldable + -- Module. + package package.cpath package.loaded package.loadlib package.path + package.preload + -- Module added in 5.2. + package.config package.searchers package.searchpath + -- UTF-8 added in 5.3. + utf8 utf8.char utf8.charpattern utf8.codepoint utf8.codes utf8.len utf8.offset + -- String. + string string.byte string.char string.dump string.find string.format + string.gmatch string.gsub string.len string.lower string.match string.rep + string.reverse string.sub string.upper + -- String added in 5.3. + string.pack string.packsize string.unpack + -- Table. + table table.concat table.insert table.remove table.sort + -- Table added in 5.2. + table.pack table.unpack + -- Table added in 5.3. + table.move + -- Math. + math math.abs math.acos math.asin math.atan math.ceil math.cos math.deg + math.exp math.floor math.fmod math.huge math.log math.max math.min math.modf + math.pi math.rad math.random math.randomseed math.sin math.sqrt math.tan + -- Math added in 5.3. + math.maxinteger math.mininteger math.tointeger math.type math.ult + -- IO. + io io.close io.flush io.input io.lines io.open io.output io.popen io.read + io.stderr io.stdin io.stdout io.tmpfile io.type io.write + -- OS. + os os.clock os.date os.difftime os.execute os.exit os.getenv os.remove + os.rename os.setlocale os.time os.tmpname + -- Debug. + debug debug.debug debug.gethook debug.getinfo debug.getlocal + debug.getmetatable debug.getregistry debug.getupvalue debug.sethook + debug.setlocal debug.setmetatable debug.setupvalue debug.traceback + -- Debug added in 5.2. + debug.getuservalue debug.setuservalue debug.upvalueid debug.upvaluejoin +]]) +local deprecated_library = token('deprecated_library', word_match[[ + -- Module deprecated in 5.2. + package.loaders package.seeall + -- Table deprecated in 5.2. + table.maxn + -- Math deprecated in 5.2. + math.log10 + -- Math deprecated in 5.3. + math.atan2 math.cosh math.frexp math.ldexp math.pow math.sinh math.tanh + -- Bit32 deprecated in 5.3. + bit32 bit32.arshift bit32.band bit32.bnot bit32.bor bit32.btest bit32.extract + bit32.lrotate bit32.lshift bit32.replace bit32.rrotate bit32.rshift bit32.xor + -- Debug deprecated in 5.2. + debug.getfenv debug.setfenv +]]) +lex:add_rule('library', library + deprecated_library) +lex:add_style('library', lexer.STYLE_TYPE) +lex:add_style('deprecated_library', lexer.STYLE_TYPE..',italics') + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +local longstring = lpeg.Cmt('[' * lpeg.C(P('=')^0) * '[', + function(input, index, eq) + local _, e = input:find(']'..eq..']', index, true) + return (e or #input) + 1 + end) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"')) + + token('longstring', longstring)) +lex:add_style('longstring', lexer.STYLE_STRING) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '--' * (longstring + + lexer.nonnewline^0))) + +-- Numbers. +local lua_integer = P('-')^-1 * (lexer.hex_num + lexer.dec_num) +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lua_integer)) + +-- Labels. +lex:add_rule('label', token(lexer.LABEL, '::' * lexer.word * '::')) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, '..' + + S('+-*/%^#=<>&|~;:,.{}[]()'))) + +-- Fold points. +local function fold_longcomment(text, pos, line, s, symbol) + if symbol == '[' then + if line:find('^%[=*%[', s) then return 1 end + elseif symbol == ']' then + if line:find('^%]=*%]', s) then return -1 end + end + return 0 +end +lex:add_fold_point(lexer.KEYWORD, 'if', 'end') +lex:add_fold_point(lexer.KEYWORD, 'do', 'end') +lex:add_fold_point(lexer.KEYWORD, 'function', 'end') +lex:add_fold_point(lexer.KEYWORD, 'repeat', 'until') +lex:add_fold_point(lexer.COMMENT, '[', fold_longcomment) +lex:add_fold_point(lexer.COMMENT, ']', fold_longcomment) +lex:add_fold_point(lexer.COMMENT, '--', lexer.fold_line_comments('--')) +lex:add_fold_point('longstring', '[', ']') +lex:add_fold_point(lexer.OPERATOR, '(', ')') +lex:add_fold_point(lexer.OPERATOR, '[', ']') +lex:add_fold_point(lexer.OPERATOR, '{', '}') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/makefile.lua b/dep/scintilla/scintilla-3.10.6/lexlua/makefile.lua new file mode 100644 index 00000000..079975dc --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/makefile.lua @@ -0,0 +1,90 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Makefile LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('makefile', {lex_by_line = true}) + +-- Whitespace. +local ws = token(lexer.WHITESPACE, lexer.space^1) +lex:add_rule('whitespace', ws) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, P('!')^-1 * word_match([[ + -- GNU Make conditionals. + ifeq ifneq ifdef ifndef else endif + -- Other conditionals. + if elseif elseifdef elseifndef + -- Directives and other keywords. + define endef export include override private undefine unexport vpath +]], true))) + +-- Targets. +local special_target = token(lexer.CONSTANT, word_match[[ + .PHONY .SUFFIXES .DEFAULT .PRECIOUS .INTERMEDIATE .SECONDARY .SECONDEXPANSION + .DELETE_ON_ERROR .IGNORE .LOW_RESOLUTION_TIME .SILENT .EXPORT_ALL_VARIABLES + .NOTPARALLEL .ONESHELL .POSIX +]]) +local normal_target = token('target', (lexer.any - lexer.space - S(':#='))^1) +lex:add_rule('target', lexer.starts_line((special_target + normal_target) * + ws^0 * #(':' * -P('=')))) +lex:add_style('target', lexer.STYLE_LABEL) + +-- Variables. +local word_char = lexer.any - lexer.space - S(':#=(){}') +local assign = S(':+?')^-1 * '=' +local expanded_var = '$' * ('(' * word_char^1 * ')' + '{' * word_char^1 * '}') +local auto_var = '$' * S('@%. See License.txt. +-- man/roff LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('man') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Markup. +lex:add_rule('rule1', token(lexer.STRING, '.' * ('B' * P('R')^-1 + + 'I' * P('PR')^-1) * + lexer.nonnewline^0)) +lex:add_rule('rule2', token(lexer.NUMBER, '.' * S('ST') * 'H' * + lexer.nonnewline^0)) +lex:add_rule('rule3', token(lexer.KEYWORD, P('.br') + '.DS' + '.RS' + '.RE' + + '.PD')) +lex:add_rule('rule4', token(lexer.LABEL, '.' * (S('ST') * 'H' + '.TP'))) +lex:add_rule('rule5', token(lexer.VARIABLE, '.B' * P('R')^-1 + + '.I' * S('PR')^-1 + + '.PP')) +lex:add_rule('rule6', token(lexer.TYPE, '\\f' * S('BIPR'))) +lex:add_rule('rule7', token(lexer.PREPROCESSOR, lexer.starts_line('.') * + lexer.alpha^1)) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/markdown.lua b/dep/scintilla/scintilla-3.10.6/lexlua/markdown.lua new file mode 100644 index 00000000..c6236c22 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/markdown.lua @@ -0,0 +1,125 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Markdown LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('markdown') + +-- Block elements. +lex:add_rule('header', + token('h6', lexer.starts_line('######') * lexer.nonnewline^0) + + token('h5', lexer.starts_line('#####') * lexer.nonnewline^0) + + token('h4', lexer.starts_line('####') * lexer.nonnewline^0) + + token('h3', lexer.starts_line('###') * lexer.nonnewline^0) + + token('h2', lexer.starts_line('##') * lexer.nonnewline^0) + + token('h1', lexer.starts_line('#') * lexer.nonnewline^0)) +local font_size = lexer.property_int['fontsize'] > 0 and + lexer.property_int['fontsize'] or 10 +local hstyle = 'fore:$(color.red)' +lex:add_style('h6', hstyle) +lex:add_style('h5', hstyle..',size:'..(font_size + 1)) +lex:add_style('h4', hstyle..',size:'..(font_size + 2)) +lex:add_style('h3', hstyle..',size:'..(font_size + 3)) +lex:add_style('h2', hstyle..',size:'..(font_size + 4)) +lex:add_style('h1', hstyle..',size:'..(font_size + 5)) + +lex:add_rule('blockquote', + token(lexer.STRING, + lpeg.Cmt(lexer.starts_line(S(' \t')^0 * '>'), + function(input, index) + local _, e = input:find('\n[ \t]*\r?\n', index) + return (e or #input) + 1 + end))) + +lex:add_rule('list', token('list', lexer.starts_line(S(' \t')^0 * (S('*+-') + + R('09')^1 * '.')) * + S(' \t'))) +lex:add_style('list', lexer.STYLE_CONSTANT) + +lex:add_rule('block_code', + token('code', lexer.starts_line(P(' ')^4 + P('\t')) * -P('<') * + lexer.nonnewline^0 * lexer.newline^-1) + + token('code', lexer.starts_line(P('```')) * (lexer.any - '```')^0 * + P('```')^-1)) +lex:add_rule('inline_code', + token('code', P('``') * (lexer.any - '``')^0 * P('``')^-1 + + lexer.delimited_range('`', false, true))) +lex:add_style('code', lexer.STYLE_EMBEDDED..',eolfilled') + +lex:add_rule('hr', + token('hr', + lpeg.Cmt(lexer.starts_line(S(' \t')^0 * lpeg.C(S('*-_'))), + function(input, index, c) + local line = input:match('[^\r\n]*', index) + line = line:gsub('[ \t]', '') + if line:find('[^'..c..']') or #line < 2 then + return nil + end + return (select(2, input:find('\r?\n', index)) or + #input) + 1 + end))) +lex:add_style('hr', 'back:$(color.black),eolfilled') + +-- Whitespace. +local ws = token(lexer.WHITESPACE, S(' \t')^1 + S('\v\r\n')^1) +lex:add_rule('whitespace', ws) + +-- Span elements. +lex:add_rule('escape', token(lexer.DEFAULT, P('\\') * 1)) + +lex:add_rule('link_label', + token('link_label', lexer.delimited_range('[]') * ':') * ws * + token('link_url', (lexer.any - lexer.space)^1) * + (ws * token(lexer.STRING, lexer.delimited_range('"', false, true) + + lexer.delimited_range("'", false, true) + + lexer.delimited_range('()')))^-1) +lex:add_style('link_label', lexer.STYLE_LABEL) +lex:add_style('link_url', 'underlined') + +lex:add_rule('link', + token('link', P('!')^-1 * lexer.delimited_range('[]') * + (P('(') * (lexer.any - S(') \t'))^0 * + (S(' \t')^1 * + lexer.delimited_range('"', false, true))^-1 * ')' + + S(' \t')^0 * lexer.delimited_range('[]')) + + 'http' * P('s')^-1 * '://' * + (lexer.any - lexer.space)^1)) +lex:add_style('link', 'underlined') + +local punct_space = lexer.punct + lexer.space + +-- Handles flanking delimiters as described in +-- https://github.github.com/gfm/#emphasis-and-strong-emphasis in the cases +-- where simple delimited ranges are not sufficient. +local function flanked_range(s, not_inword) + local fl_char = lexer.any - s - lexer.space + local left_fl = lpeg.B(punct_space - s) * s * #fl_char + + s * #(fl_char - lexer.punct) + local right_fl = lpeg.B(lexer.punct) * s * #(punct_space - s) + + lpeg.B(fl_char) * s + return left_fl * (lexer.any - (not_inword and s * #punct_space or s))^0 * + right_fl +end + +lex:add_rule('strong', + token('strong', flanked_range('**') + + (lpeg.B(punct_space) + #lexer.starts_line('_')) * + flanked_range('__', true) * #(punct_space + -1))) +lex:add_style('strong', 'bold') + +lex:add_rule('em', + token('em', flanked_range('*') + + (lpeg.B(punct_space) + #lexer.starts_line('_')) * + flanked_range('_', true) * #(punct_space + -1))) +lex:add_style('em', 'italics') + +-- Embedded HTML. +local html = lexer.load('html') +local start_rule = lexer.starts_line(S(' \t')^0) * #P('<') * + html:get_rule('element') +local end_rule = token(lexer.DEFAULT, P('\n')) -- TODO: lexer.WHITESPACE errors +lex:embed(html, start_rule, end_rule) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/matlab.lua b/dep/scintilla/scintilla-3.10.6/lexlua/matlab.lua new file mode 100644 index 00000000..64373ff9 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/matlab.lua @@ -0,0 +1,86 @@ +-- Copyright 2006-2019 Martin Morawetz. See License.txt. +-- Matlab LPeg lexer. +-- Based off of lexer code by Mitchell. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('matlab') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match([[ + break case catch continue do else elseif end end_try_catch end_unwind_protect + endfor endif endswitch endwhile for function endfunction global if otherwise + persistent replot return static switch try until unwind_protect + unwind_protect_cleanup varargin varargout while +]], true))) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + abs any argvatan2 axes axis ceil cla clear clf columns cos delete diff disp + doc double drawnow exp figure find fix floor fprintf gca gcf get grid help + hist hold isempty isnull length load log log10 loglog max mean median min mod + ndims numel num2str ones pause plot printf quit rand randn rectangle rem + repmat reshape round rows save semilogx semilogy set sign sin size sizeof + size_equal sort sprintf squeeze sqrt std strcmp subplot sum tan tic title toc + uicontrol who xlabel ylabel zeros +]])) + +-- Constants. +lex:add_rule('constant', token(lexer.CONSTANT, word_match[[ + EDITOR I IMAGEPATH INFO_FILE J LOADPATH OCTAVE_VERSION PAGER PS1 PS2 PS4 PWD +]])) + +-- Variable. +lex:add_rule('variable', token(lexer.VARIABLE, word_match[[ + ans automatic_replot default_return_value do_fortran_indexing + define_all_return_values empty_list_elements_ok eps false gnuplot_binary + ignore_function_time_stamp implicit_str_to_num_ok Inf inf NaN nan + ok_to_lose_imaginary_part output_max_field_width output_precision + page_screen_output pi prefer_column_vectors prefer_zero_one_indexing + print_answer_id_name print_empty_dimensions realmax realmin + resize_on_range_error return_last_computed_value save_precision + silent_functions split_long_rows suppress_verbose_help_message + treat_neg_dim_as_zero true warn_assign_as_truth_value + warn_comma_in_global_decl warn_divide_by_zero warn_function_name_clash + whitespace_in_literal_matrix +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + + lexer.delimited_range('"') + + lexer.delimited_range('`'))) + +-- Comments. +local line_comment = (P('%') + '#') * lexer.nonnewline^0 +local block_comment = '%{' * (lexer.any - '%}')^0 * P('%}')^-1 +lex:add_rule('comment', token(lexer.COMMENT, block_comment + line_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer + + lexer.dec_num + lexer.hex_num + + lexer.oct_num)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, + S('!%^&*()[]{}-=+/\\|:;.,?<>~`´'))) + +-- Fold points. +lex:add_fold_point(lexer.KEYWORD, 'if', 'end') +lex:add_fold_point(lexer.KEYWORD, 'for', 'end') +lex:add_fold_point(lexer.KEYWORD, 'while', 'end') +lex:add_fold_point(lexer.KEYWORD, 'switch', 'end') +lex:add_fold_point(lexer.OPERATOR, '(', ')') +lex:add_fold_point(lexer.OPERATOR, '[', ']') +lex:add_fold_point(lexer.COMMENT, '%{', '%}') +lex:add_fold_point(lexer.COMMENT, '%', lexer.fold_line_comments('%')) +lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/moonscript.lua b/dep/scintilla/scintilla-3.10.6/lexlua/moonscript.lua new file mode 100644 index 00000000..039601fa --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/moonscript.lua @@ -0,0 +1,141 @@ +-- Copyright 2016-2019 Alejandro Baez (https://keybase.io/baez). See License.txt. +-- Moonscript LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, S, R = lpeg.P, lpeg.S, lpeg.R + +local lex = lexer.new('moonscript', {fold_by_indentation = true}) + +-- Whitespace. +lex:add_rule('whitspace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + -- Lua. + and break do else elseif false for if in local nil not or return then true + while + -- Moonscript. + continue class export extends from import super switch unless using when with +]])) + +-- Error words. +lex:add_rule('error', token(lexer.ERROR, word_match[[function end]])) + +-- Self reference. +lex:add_rule('self_ref', token('self_ref', '@' * lexer.word + 'self')) +lex:add_style('self_ref', lexer.STYLE_LABEL) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + assert collectgarbage dofile error getmetatable ipairs load loadfile next + pairs pcall print rawequal rawget rawset require select setmetatable tonumber + tostring type xpcall + -- Added in 5.2. + rawlen +]])) + +-- Constants. +lex:add_rule('constant', token(lexer.CONSTANT, word_match[[ + _G _VERSION + -- Added in 5.2. + _ENV +]])) + +-- Libraries. +lex:add_rule('library', token('library', word_match[[ + -- Coroutine. + coroutine coroutine.create coroutine.resume coroutine.running coroutine.status + coroutine.wrap coroutine.yield + -- Coroutine added in 5.3. + coroutine.isyieldable + -- Module. + package package.cpath package.loaded package.loadlib package.path + package.preload + -- Module added in 5.2. + package.config package.searchers package.searchpath + -- UTF-8 added in 5.3. + utf8 utf8.char utf8.charpattern utf8.codepoint utf8.codes utf8.len utf8.offset + -- String. + string string.byte string.char string.dump string.find string.format + string.gmatch string.gsub string.len string.lower string.match string.rep + string.reverse string.sub string.upper + -- String added in 5.3. + string.pack string.packsize string.unpack + -- Table. + table table.concat table.insert table.remove table.sort + -- Table added in 5.2. + table.pack table.unpack + -- Table added in 5.3. + table.move + -- Math. + math math.abs math.acos math.asin math.atan math.ceil math.cos math.deg + math.exp math.floor math.fmod math.huge math.log math.max math.min math.modf + math.pi math.rad math.random math.randomseed math.sin math.sqrt math.tan + -- Math added in 5.3. + math.maxinteger math.mininteger math.tointeger math.type math.ult + -- IO. + io io.close io.flush io.input io.lines io.open io.output io.popen io.read + io.stderr io.stdin io.stdout io.tmpfile io.type io.write + -- OS. + os os.clock os.date os.difftime os.execute os.exit os.getenv os.remove + os.rename os.setlocale os.time os.tmpname + -- Debug. + debug debug.debug debug.gethook debug.getinfo debug.getlocal + debug.getmetatable debug.getregistry debug.getupvalue debug.sethook + debug.setlocal debug.setmetatable debug.setupvalue debug.traceback + -- Debug added in 5.2. + debug.getuservalue debug.setuservalue debug.upvalueid debug.upvaluejoin + + --- MoonScript 0.3.1 standard library. + -- Printing functions. + p + -- Table functions. + run_with_scope defaultbl extend copy + -- Class/object functions. + is_object bind_methods mixin mixin_object mixin_table + -- Misc functions. + fold + -- Debug functions. + debug.upvalue +]])) +lex:add_style('library', lexer.STYLE_TYPE) + +-- Identifiers. +local identifier = token(lexer.IDENTIFIER, lexer.word) +local proper_ident = token('proper_ident', R('AZ') * lexer.word) +local tbl_key = token('tbl_key', lexer.word * ':' + ':' * lexer.word ) +lex:add_rule('identifier', tbl_key + proper_ident + identifier) +lex:add_style('proper_ident', lexer.STYLE_CLASS) +lex:add_style('tbl_key', lexer.STYLE_REGEX) + +local longstring = lpeg.Cmt('[' * lpeg.C(P('=')^0) * '[', + function(input, index, eq) + local _, e = input:find(']'..eq..']', index, true) + return (e or #input) + 1 + end) + +-- Strings. +local sq_str = lexer.delimited_range("'", false, true) +local dq_str = lexer.delimited_range('"', false, true) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str) + + token('longstring', longstring)) +lex:add_style('longstring', lexer.STYLE_STRING) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '--' * (longstring + + lexer.nonnewline^0))) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Function definition. +lex:add_rule('fndef', token('fndef', P('->') + '=>')) +lex:add_style('fndef', lexer.STYLE_PREPROCESSOR) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-*!\\/%^#=<>;:,.'))) +lex:add_rule('symbol', token('symbol', S('(){}[]'))) +lex:add_style('symbol', lexer.STYLE_EMBEDDED) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/myrddin.lua b/dep/scintilla/scintilla-3.10.6/lexlua/myrddin.lua new file mode 100644 index 00000000..ffe8a326 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/myrddin.lua @@ -0,0 +1,54 @@ +-- Copyright 2017-2019 Michael Forney. See License.txt +-- Myrddin LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V + +local lex = lexer.new('myrddin') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + break const continue elif else extern false for generic goto if impl in match + pkg pkglocal sizeof struct trait true type union use var while +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + void bool char byte int uint int8 uint8 int16 uint16 int32 uint32 int64 uint64 + flt32 flt64 +]] + '@' * lexer.word)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = P{ + V'part' * P'*/'^-1, + part = '/*' * (V'full' + (lexer.any - '/*' - '*/'))^0, + full = V'part' * '*/', +} +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + + lexer.delimited_range('"', true))) + +-- Numbers. +local digit = lexer.digit + '_' +local bdigit = R'01' + '_' +local xdigit = lexer.xdigit + '_' +local odigit = R'07' + '_' +local integer = '0x' * xdigit^1 + '0o' * odigit^1 + '0b' * bdigit^1 + digit^1 +local float = digit^1 * (('.' * digit^1) * (S'eE' * S'+-'^-1 * digit^1)^-1 + + ('.' * digit^1)^-1 * S'eE' * S'+-'^-1 * digit^1) +lex:add_rule('number', token(lexer.NUMBER, float + integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S'`#_+-/*%<>~!=^&|~:;,.()[]{}')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/nemerle.lua b/dep/scintilla/scintilla-3.10.6/lexlua/nemerle.lua new file mode 100644 index 00000000..449afaeb --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/nemerle.lua @@ -0,0 +1,66 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Nemerle LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('nemerle') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + _ abstract and array as base catch class def do else extends extern finally + foreach for fun if implements in interface internal lock macro match module + mutable namespace new out override params private protected public ref repeat + sealed static struct syntax this throw try type typeof unless until using + variant virtual when where while + -- Values. + null true false +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + bool byte char decimal double float int list long object sbyte short string + uint ulong ushort void +]])) + +-- Strings. +local sq_str = P('L')^-1 * lexer.delimited_range("'", true) +local dq_str = P('L')^-1 * lexer.delimited_range('"', true) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Preprocessor. +local preproc_word = word_match[[ + define elif else endif endregion error if ifdef ifndef line pragma region + undef using warning +]] +lex:add_rule('preproc', token(lexer.PREPROCESSOR, lexer.starts_line('#') * + S('\t ')^0 * preproc_word)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.PREPROCESSOR, 'region', 'endregion') +lex:add_fold_point(lexer.PREPROCESSOR, 'if', 'endif') +lex:add_fold_point(lexer.PREPROCESSOR, 'ifdef', 'endif') +lex:add_fold_point(lexer.PREPROCESSOR, 'ifndef', 'endif') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/nim.lua b/dep/scintilla/scintilla-3.10.6/lexlua/nim.lua new file mode 100644 index 00000000..e13c25f6 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/nim.lua @@ -0,0 +1,101 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Nim LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('nim', {fold_by_indentation = true}) + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match([[ + addr and as asm atomic bind block break case cast const continue converter + discard distinct div do elif else end enum except export finally for from + generic if import in include interface is isnot iterator lambda let macro + method mixin mod nil not notin object of or out proc ptr raise ref return + shared shl static template try tuple type var when while with without xor + yield +]], true))) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match([[ + -- Procs. + defined definedInScope new unsafeNew internalNew reset high low sizeof succ + pred inc dec newSeq len incl excl card ord chr ze ze64 toU8 toU16 toU32 abs + min max contains cmp setLen newString newStringOfCap add compileOption quit + shallowCopy del delete insert repr toFloat toBiggestFloat toInt toBiggestInt + addQuitProc substr zeroMem copyMem moveMem equalMem swap getRefcount clamp + isNil find contains pop each map GC_ref GC_unref echo debugEcho getTypeInfo + Open repopen Close EndOfFile readChar FlushFile readAll readFile writeFile + write readLine writeln getFileSize ReadBytes ReadChars readBuffer writeBytes + writeChars writeBuffer setFilePos getFilePos fileHandle cstringArrayToSeq + allocCStringArray deallocCStringArray atomicInc atomicDec compareAndSwap + setControlCHook writeStackTrace getStackTrace alloc alloc0 dealloc realloc + getFreeMem getTotalMem getOccupiedMem allocShared allocShared0 deallocShared + reallocShared IsOnStack GC_addCycleRoot GC_disable GC_enable GC_setStrategy + GC_enableMarkAndSweep GC_disableMarkAndSweep GC_fullCollect GC_getStatistics + nimDestroyRange getCurrentException getCurrentExceptionMsg onRaise likely + unlikely rawProc rawEnv finished slurp staticRead gorge staticExec rand + astToStr InstatiationInfo raiseAssert shallow compiles safeAdd locals + -- Iterators. + countdown countup items pairs fields fieldPairs lines + -- Templates. + accumulateResult newException CurrentSourcePath assert doAssert onFailedAssert + eval + -- Threads. + running joinThread joinThreads createThread threadId myThreadId + -- Channels. + send recv peek ready +]], true))) + +-- Types. +lex:add_rule('type', token(lexer.TYPE , word_match([[ + int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 + float64 bool char string cstring pointer Ordinal auto any TSignedInt + TUnsignedInt TInteger TOrdinal TReal TNumber range array openarray varargs + seq set TSlice TThread TChannel + -- Meta Types. + expr stmt typeDesc void +]], true))) + +-- Constants. +lex:add_rule('constant', token(lexer.CONSTANT, word_match[[ + on off isMainModule CompileDate CompileTime NimVersion NimMajor NimMinor + NimPatch cpuEndian hostOS hostCPU appType QuitSuccess QuitFailure inf neginf + nan +]])) + +-- Strings. +local sq_str = lexer.delimited_range("'", true) +local dq_str = lexer.delimited_range('"', true) +local triple_dq_str = '"""' * (lexer.any - '"""')^0 * P('"""')^-1 +local raw_dq_str = 'r' * lexer.delimited_range('"', false, true) +lex:add_rule('string', token(lexer.STRING, triple_dq_str + sq_str + dq_str + + raw_dq_str)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline_esc^0)) + +-- Numbers. +local dec = lexer.digit^1 * ('_' * lexer.digit^1)^0 +local hex = '0' * S('xX') * lexer.xdigit^1 * ('_' * lexer.xdigit^1)^0 +local bin = '0' * S('bB') * S('01')^1 * ('_' * S('01')^1)^0 +local oct = '0o' * R('07')^1 +local integer = S('+-')^-1 * (bin + hex + oct + dec) * + ("'" * S('iIuUfF') * (P('8') + '16' + '32' + '64'))^-1 +local float = lexer.digit^1 * ('_' * lexer.digit^1)^0 * + ('.' * ('_' * lexer.digit)^0)^-1 * S('eE') * S('+-')^-1 * + lexer.digit^1 * ('_' * lexer.digit^1)^0 +lex:add_rule('number', token(lexer.NUMBER, lexer.float + integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, + S('=+-*/<>@$~&%|!?^.:\\`()[]{},;'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/nsis.lua b/dep/scintilla/scintilla-3.10.6/lexlua/nsis.lua new file mode 100644 index 00000000..12f465e7 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/nsis.lua @@ -0,0 +1,146 @@ +-- Copyright 2006-2019 Robert Gieseke. See License.txt. +-- NSIS LPeg lexer +-- Based on NSIS 2.46 docs: http://nsis.sourceforge.net/Docs/. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('nsis') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Comments (4.1). +local line_comment = (P(';') + '#') * lexer.nonnewline^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * '*/' +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"') + + lexer.delimited_range('`'))) + +-- Constants (4.2.3). +lex:add_rule('constant', token(lexer.CONSTANT, word_match[[ + $PROGRAMFILES $PROGRAMFILES32 $PROGRAMFILES64 $COMMONFILES $COMMONFILES32 + $COMMONFILES64 $DESKTOP $EXEDIR $EXEFILE $EXEPATH ${NSISDIR} $WINDIR $SYSDIR + $TEMP $STARTMENU $SMPROGRAMS $SMSTARTUP $QUICKLAUNCH$DOCUMENTS $SENDTO $RECENT + $FAVORITES $MUSIC $PICTURES $VIDEOS $NETHOOD $FONTS $TEMPLATES $APPDATA + $LOCALAPPDATA $PRINTHOOD $INTERNET_CACHE $COOKIES $HISTORY $PROFILE + $ADMINTOOLS $RESOURCES $RESOURCES_LOCALIZED $CDBURN_AREA $HWNDPARENT + $PLUGINSDIR +]])) +-- TODO? Constants used in strings: $$ $\r $\n $\t + +-- Variables (4.2). +lex:add_rule('variable', token(lexer.VARIABLE, word_match[[ + $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $R0 $R1 $R2 $R3 $R4 $R5 $R6 $R7 $R8 $R9 + $INSTDIR $OUTDIR $CMDLINE $LANGUAGE Var /GLOBAL +]]) + '$' * lexer.word) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + -- Pages (4.5). + Page UninstPage PageEx PageEnd PageExEnd + -- Section commands (4.6). + AddSize Section SectionEnd SectionIn SectionGroup SectionGroupEnd + -- Functions (4.7). + Function FunctionEnd + -- Callbacks (4.7.2). + .onGUIInit .onInit .onInstFailed .onInstSuccess .onGUIEnd .onMouseOverSection + .onRebootFailed .onSelChange .onUserAbort .onVerifyInstDir un.onGUIInit + un.onInit un.onUninstFailed un.onUninstSuccess un.onGUIEnd un.onRebootFailed + un.onSelChange un.onUserAbort + -- General Attributes (4.8.1). + AddBrandingImage AllowRootDirInstall AutoCloseWindow BGFont BGFont + BrandingText /TRIMLEFT /TRIMRIGHT /TRIMCENTER Caption ChangeUI CheckBitmap + CompletedText ComponentText CRCCheck DetailsButtonText DirText DirVar + DirVerify FileErrorText Icon InstallButtonText InstallColors InstallDir + InstallDirRegKey InstProgressFlags InstType LicenseBkColor LicenseData + LicenseForceSelection LicenseText MiscButtonText Name OutFile + RequestExecutionLevel SetFont ShowInstDetails ShowUninstDetails SilentInstall + SilentUnInstall SpaceTexts SubCaption UninstallButtonText UninstallCaption + UninstallIcon UninstallSubCaption UninstallText WindowIcon XPStyle admin auto + bottom checkbox false force height hide highest leave left nevershow none + normal off on radiobuttons right show silent silentlog top true user width + -- Compiler Flags (4.8.2). + AllowSkipFiles FileBufSize SetCompress SetCompressor /SOLID /FINAL zlib bzip2 + lzma SetCompressorDictSize SetDatablockOptimize SetDateSave SetOverwrite + ifnewer ifdiff lastused try + -- Version Information (4.8.3). + VIAddVersionKey VIProductVersion /LANG ProductName Comments CompanyName + LegalCopyright FileDescription FileVersion ProductVersion InternalName + LegalTrademarks OriginalFilename PrivateBuild SpecialBuild + -- Basic Instructions (4.9.1). + Delete /REBOOTOK Exec ExecShell ExecShell File /nonfatal Rename ReserveFile + RMDir SetOutPath + -- Registry INI File Instructions (4.9.2). + DeleteINISec DeleteINIStr DeleteRegKey /ifempty DeleteRegValue EnumRegKey + EnumRegValue ExpandEnvStrings FlushINI ReadEnvStr ReadINIStr ReadRegDWORD + ReadRegStr WriteINIStr WriteRegBin WriteRegDWORD WriteRegStr WriteRegExpandStr + HKCR HKEY_CLASSES_ROOT HKLM HKEY_LOCAL_MACHINE HKCU HKEY_CURRENT_USER HKU + HKEY_USERS HKCC HKEY_CURRENT_CONFIG HKDD HKEY_DYN_DATA HKPD + HKEY_PERFORMANCE_DATA SHCTX SHELL_CONTEXT + -- General Purpose Instructions (4.9.3). + CallInstDLL CopyFiles /SILENT /FILESONLY CreateDirectory CreateShortCut + GetDLLVersion GetDLLVersionLocal GetFileTime GetFileTimeLocal GetFullPathName + /SHORT GetTempFileName SearchPath SetFileAttributes RegDLL UnRegDLL + -- Flow Control Instructions (4.9.4). + Abort Call ClearErrors GetCurrentAddress GetFunctionAddress GetLabelAddress + Goto IfAbort IfErrors IfFileExists IfRebootFlag IfSilent IntCmp IntCmpU + MessageBox MB_OK MB_OKCANCEL MB_ABORTRETRYIGNORE MB_RETRYCANCEL MB_YESNO + MB_YESNOCANCEL MB_ICONEXCLAMATION MB_ICONINFORMATION MB_ICONQUESTION + MB_ICONSTOP MB_USERICON MB_TOPMOST MB_SETFOREGROUND MB_RIGHT MB_RTLREADING + MB_DEFBUTTON1 MB_DEFBUTTON2 MB_DEFBUTTON3 MB_DEFBUTTON4 IDABORT IDCANCEL + IDIGNORE IDNO IDOK IDRETRY IDYES Return Quit SetErrors StrCmp StrCmpS + -- File Instructions (4.9.5). + FileClose FileOpen FileRead FileReadByte FileSeek FileWrite FileWriteByte + FindClose FindFirst FindNext + -- Uninstaller Instructions (4.9.6). + WriteUninstaller + -- Miscellaneous Instructions (4.9.7). + GetErrorLevel GetInstDirError InitPluginsDir Nop SetErrorLevel SetRegView + SetShellVarContext all current Sleep + -- String Manipulation Instructions (4.9.8). + StrCpy StrLen + -- Stack Support (4.9.9). + Exch Pop Push + -- Integer Support (4.9.10). + IntFmt IntOp + -- Reboot Instructions (4.9.11). + Reboot SetRebootFlag + -- Install Logging Instructions (4.9.12). + LogSet LogText + -- Section Management (4.9.13). + SectionSetFlags SectionGetFlags SectionGetFlags SectionSetText SectionGetText + SectionSetInstTypes SectionGetInstTypes SectionSetSize SectionGetSize + SetCurInstType GetCurInstType InstTypeSetText InstTypeGetText + -- User Interface Instructions (4.9.14). + BringToFront CreateFont DetailPrint EnableWindow FindWindow GetDlgItem + HideWindow IsWindow LockWindow SendMessage SetAutoClose SetBrandingImage + SetDetailsView SetDetailsPrint listonlytextonly both SetCtlColors /BRANDING + SetSilent ShowWindow + -- Multiple Languages Instructions (4.9.15). + LoadLanguageFile LangString LicenseLangString + -- Compile time commands (5). + !include !addincludedir !addplugindir !appendfile !cd !delfile !echo !error + !execute !packhdr !system !tempfile !warning !verbose {__FILE__} {__LINE__} + {__DATE__} {__TIME__} {__TIMESTAMP__} {NSIS_VERSION} !define !undef !ifdef + !ifndef !if !ifmacrodef !ifmacrondef !else !endif !insertmacro !macro + !macroend !searchparse !searchreplace +]])) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-*/%|&^~!<>'))) + +-- Labels (4.3). +lex:add_rule('label', token(lexer.LABEL, lexer.word * ':')) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/null.lua b/dep/scintilla/scintilla-3.10.6/lexlua/null.lua new file mode 100644 index 00000000..4bcee16b --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/null.lua @@ -0,0 +1,4 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Null LPeg lexer. + +return require('lexer').new('null') diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/objective_c.lua b/dep/scintilla/scintilla-3.10.6/lexlua/objective_c.lua new file mode 100644 index 00000000..da58ecd0 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/objective_c.lua @@ -0,0 +1,71 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Objective C LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('objective_c') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + -- From C. + asm auto break case const continue default do else extern false for goto if + inline register return sizeof static switch true typedef void volatile while + restrict _Bool _Complex _Pragma _Imaginary + -- Objective C. + oneway in out inout bycopy byref self super + -- Preprocessor directives. + @interface @implementation @protocol @end @private @protected @public @class + @selector @encode @defs @synchronized @try @throw @catch @finally + -- Constants. + TRUE FALSE YES NO NULL nil Nil METHOD_NULL +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + apply_t id Class MetaClass Object Protocol retval_t SEL STR IMP BOOL + TypedStream +]])) + +-- Strings. +local sq_str = P('L')^-1 * lexer.delimited_range("'", true) +local dq_str = P('L')^-1 * lexer.delimited_range('"', true) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Preprocessor. +local preproc_word = word_match[[ + define elif else endif error if ifdef ifndef import include line pragma undef + warning +]] +lex:add_rule('preprocessor', #lexer.starts_line('#') * + token(lexer.PREPROCESSOR, '#' * S('\t ')^0 * + preproc_word)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}'))) + +-- Fold symbols. +lex:add_fold_point(lexer.PREPROCESSOR, 'region', 'endregion') +lex:add_fold_point(lexer.PREPROCESSOR, 'if', 'endif') +lex:add_fold_point(lexer.PREPROCESSOR, 'ifdef', 'endif') +lex:add_fold_point(lexer.PREPROCESSOR, 'ifndef', 'endif') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/pascal.lua b/dep/scintilla/scintilla-3.10.6/lexlua/pascal.lua new file mode 100644 index 00000000..58e7b612 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/pascal.lua @@ -0,0 +1,62 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Pascal LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('pascal') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match([[ + and array as at asm begin case class const constructor destructor + dispinterface div do downto else end except exports file final finalization + finally for function goto if implementation in inherited initialization inline + interface is label mod not object of on or out packed procedure program + property raise record repeat resourcestring set sealed shl shr static string + then threadvar to try type unit unsafe until uses var while with xor + absolute abstract assembler automated cdecl contains default deprecated dispid + dynamic export external far forward implements index library local message + name namespaces near nodefault overload override package pascal platform + private protected public published read readonly register reintroduce requires + resident safecall stdcall stored varargs virtual write writeln writeonly + false nil self true +]], true))) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match([[ + chr ord succ pred abs round trunc sqr sqrt arctan cos sin exp ln odd eof eoln +]], true))) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match([[ + shortint byte char smallint integer word longint cardinal boolean bytebool + wordbool longbool real single double extended comp currency pointer +]], true))) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, + S('uUrR')^-1 * + lexer.delimited_range("'", true, true))) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local bblock_comment = '{' * (lexer.any - '}')^0 * P('}')^-1 +local pblock_comment = '(*' * (lexer.any - '*)')^0 * P('*)')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + bblock_comment + + pblock_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, (lexer.float + lexer.integer) * + S('LlDdFf')^-1)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('.,;^@:=<>+-/*()[]'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/perl.lua b/dep/scintilla/scintilla-3.10.6/lexlua/perl.lua new file mode 100644 index 00000000..c05c16a0 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/perl.lua @@ -0,0 +1,142 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Perl LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V + +local lex = lexer.new('perl') + +-- Whitespace. +lex:add_rule('perl', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + STDIN STDOUT STDERR BEGIN END CHECK INIT + require use + break continue do each else elsif foreach for if last local my next our + package return sub unless until while __FILE__ __LINE__ __PACKAGE__ + and or not eq ne lt gt le ge +]])) + +-- Markers. +lex:add_rule('marker', token(lexer.COMMENT, word_match[[__DATA__ __END__]] * + lexer.any^0)) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + abs accept alarm atan2 bind binmode bless caller chdir chmod chomp chop chown + chr chroot closedir close connect cos crypt dbmclose dbmopen defined delete + die dump each endgrent endhostent endnetent endprotoent endpwent endservent + eof eval exec exists exit exp fcntl fileno flock fork format formline getc + getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin + getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority + getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid + getservbyname getservbyport getservent getsockname getsockopt glob gmtime goto + grep hex import index int ioctl join keys kill lcfirst lc length link listen + localtime log lstat map mkdir msgctl msgget msgrcv msgsnd new oct opendir open + ord pack pipe pop pos printf print prototype push quotemeta rand readdir read + readlink recv redo ref rename reset reverse rewinddir rindex rmdir scalar + seekdir seek select semctl semget semop send setgrent sethostent setnetent + setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl + shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split + sprintf sqrt srand stat study substr symlink syscall sysread sysseek system + syswrite telldir tell tied tie time times truncate ucfirst uc umask undef + unlink unpack unshift untie utime values vec wait waitpid wantarray warn write +]])) + +local delimiter_matches = {['('] = ')', ['['] = ']', ['{'] = '}', ['<'] = '>'} +local literal_delimitted = P(function(input, index) -- for single delimiter sets + local delimiter = input:sub(index, index) + if not delimiter:find('%w') then -- only non alpha-numerics + local match_pos, patt + if delimiter_matches[delimiter] then + -- Handle nested delimiter/matches in strings. + local s, e = delimiter, delimiter_matches[delimiter] + patt = lexer.delimited_range(s..e, false, false, true) + else + patt = lexer.delimited_range(delimiter) + end + match_pos = lpeg.match(patt, input, index) + return match_pos or #input + 1 + end +end) +local literal_delimitted2 = P(function(input, index) -- for 2 delimiter sets + local delimiter = input:sub(index, index) + -- Only consider non-alpha-numerics and non-spaces as delimiters. The + -- non-spaces are used to ignore operators like "-s". + if not delimiter:find('[%w ]') then + local match_pos, patt + if delimiter_matches[delimiter] then + -- Handle nested delimiter/matches in strings. + local s, e = delimiter, delimiter_matches[delimiter] + patt = lexer.delimited_range(s..e, false, false, true) + else + patt = lexer.delimited_range(delimiter) + end + first_match_pos = lpeg.match(patt, input, index) + final_match_pos = lpeg.match(patt, input, first_match_pos - 1) + if not final_match_pos then -- using (), [], {}, or <> notation + final_match_pos = lpeg.match(lexer.space^0 * patt, input, first_match_pos) + end + return final_match_pos or #input + 1 + end +end) + +-- Strings. +local sq_str = lexer.delimited_range("'") +local dq_str = lexer.delimited_range('"') +local cmd_str = lexer.delimited_range('`') +local heredoc = '<<' * P(function(input, index) + local s, e, delimiter = input:find('([%a_][%w_]*)[\n\r\f;]+', index) + if s == index and delimiter then + local end_heredoc = '[\n\r\f]+' + local _, e = input:find(end_heredoc..delimiter, e) + return e and e + 1 or #input + 1 + end +end) +local lit_str = 'q' * P('q')^-1 * literal_delimitted +local lit_array = 'qw' * literal_delimitted +local lit_cmd = 'qx' * literal_delimitted +local lit_tr = (P('tr') + 'y') * literal_delimitted2 * S('cds')^0 +local regex_str = #P('/') * lexer.last_char_includes('-<>+*!~\\=%&|^?:;([{') * + lexer.delimited_range('/', true) * S('imosx')^0 +local lit_regex = 'qr' * literal_delimitted * S('imosx')^0 +local lit_match = 'm' * literal_delimitted * S('cgimosx')^0 +local lit_sub = 's' * literal_delimitted2 * S('ecgimosx')^0 +lex:add_rule('string', + token(lexer.STRING, sq_str + dq_str + cmd_str + heredoc + lit_str + + lit_array + lit_cmd + lit_tr) + + token(lexer.REGEX, regex_str + lit_regex + lit_match + lit_sub)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +local line_comment = '#' * lexer.nonnewline_esc^0 +local block_comment = lexer.starts_line('=') * lexer.alpha * + (lexer.any - lexer.newline * '=cut')^0 * + (lexer.newline * '=cut')^-1 +lex:add_rule('comment', token(lexer.COMMENT, block_comment + line_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Variables. +local special_var = '$' * ('^' * S('ADEFHILMOPSTWX')^-1 + + S('\\"[]\'&`+*.,;=%~?@<>(|/!-') + + ':' * (lexer.any - ':') + + P('$') * -lexer.word + + lexer.digit^1) +local plain_var = ('$#' + S('$@%')) * P('$')^0 * lexer.word + '$#' +lex:add_rule('variable', token(lexer.VARIABLE, special_var + plain_var)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('-<>+*!~\\=/%&|^.?:;()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '[', ']') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/php.lua b/dep/scintilla/scintilla-3.10.6/lexlua/php.lua new file mode 100644 index 00000000..2f71c378 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/php.lua @@ -0,0 +1,75 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- PHP LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V + +local lex = lexer.new('php') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + and array as bool boolean break case cfunction class const continue declare + default die directory do double echo else elseif empty enddeclare endfor + endforeach endif endswitch endwhile eval exit extends false float for foreach + function global if include include_once int integer isset list new null object + old_function or parent print real require require_once resource return static + stdclass string switch true unset use var while xor + __class__ __file__ __function__ __line__ __sleep __wakeup +]])) + +local word = (lexer.alpha + '_' + R('\127\255')) * + (lexer.alnum + '_' + R('\127\255'))^0 + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, word)) + +-- Variables. +lex:add_rule('variable', token(lexer.VARIABLE, '$' * word)) + +-- Strings. +local sq_str = lexer.delimited_range("'") +local dq_str = lexer.delimited_range('"') +local bt_str = lexer.delimited_range('`') +local heredoc = '<<<' * P(function(input, index) + local _, e, delimiter = input:find('([%a_][%w_]*)[\n\r\f]+', index) + if delimiter then + local _, e = input:find('[\n\r\f]+'..delimiter, e) + return e and e + 1 + end +end) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str + bt_str + heredoc)) +-- TODO: interpolated code. + +-- Comments. +local line_comment = (P('//') + '#') * lexer.nonnewline^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, block_comment + line_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('!@%^*&()-+=|/?.,;:<>[]{}'))) + +-- Embedded in HTML. +local html = lexer.load('html') + +-- Embedded PHP. +local php_start_rule = token('php_tag', '') +html:embed(lex, php_start_rule, php_end_rule) +lex:add_style('php_tag', lexer.STYLE_EMBEDDED) + +-- Fold points. +lex:add_fold_point('php_tag', '') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) +lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.OPERATOR, '(', ')') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/pico8.lua b/dep/scintilla/scintilla-3.10.6/lexlua/pico8.lua new file mode 100644 index 00000000..74a29347 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/pico8.lua @@ -0,0 +1,39 @@ +-- Copyright 2016-2019 Alejandro Baez (https://keybase.io/baez). See License.txt. +-- PICO-8 lexer. +-- http://www.lexaloffle.com/pico-8.php + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('pico8') + +-- Whitespace +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + __lua__ __gfx__ __gff__ __map__ __sfx__ __music__ +]])) + +-- Identifiers +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments +lex:add_rule('comment', token(lexer.COMMENT, '//' * lexer.nonnewline_esc^0)) + +-- Numbers +lex:add_rule('number', token(lexer.NUMBER, lexer.integer)) + +-- Operators +lex:add_rule('operator', token(lexer.OPERATOR, S('_'))) + +-- Embed Lua into PICO-8. +local lua = lexer.load('lua') + +local lua_start_rule = token('pico8_tag', '__lua__') +local lua_end_rule = token('pico8_tag', '__gfx__' ) +lex:embed(lua, lua_start_rule, lua_end_rule) +lex:add_style('pico8_tag', lexer.STYLE_EMBEDDED) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/pike.lua b/dep/scintilla/scintilla-3.10.6/lexlua/pike.lua new file mode 100644 index 00000000..7abae087 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/pike.lua @@ -0,0 +1,56 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Pike LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('pike') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + break case catch continue default do else for foreach gauge if lambda return + sscanf switch while import inherit + -- Type modifiers. + constant extern final inline local nomask optional private protected public + static variant +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + array class float function int mapping mixed multiset object program string + void +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + + lexer.delimited_range('"', true) + + '#' * lexer.delimited_range('"'))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '//' * lexer.nonnewline_esc^0 + + lexer.nested_pair('/*', '*/'))) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, (lexer.float + lexer.integer) * + S('lLdDfF')^-1)) + +-- Preprocessors. +lex:add_rule('preprocessor', token(lexer.PREPROCESSOR, lexer.starts_line('#') * + lexer.nonnewline^0)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('<>=!+-/*%&|^~@`.,:;()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/pkgbuild.lua b/dep/scintilla/scintilla-3.10.6/lexlua/pkgbuild.lua new file mode 100644 index 00000000..651270e8 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/pkgbuild.lua @@ -0,0 +1,79 @@ +-- Copyright 2006-2019 gwash. See License.txt. +-- Archlinux PKGBUILD LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('pkgbuild') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) + +-- Strings. +local sq_str = lexer.delimited_range("'", false, true) +local dq_str = lexer.delimited_range('"') +local ex_str = lexer.delimited_range('`') +local heredoc = '<<' * P(function(input, index) + local s, e, _, delimiter = + input:find('(["\']?)([%a_][%w_]*)%1[\n\r\f;]+', index) + if s == index and delimiter then + local _, e = input:find('[\n\r\f]+'..delimiter, e) + return e and e + 1 or #input + 1 + end +end) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str + ex_str + heredoc)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + patch cd make patch mkdir cp sed install rm if then elif else fi case in esac + while for do done continue local return git svn co clone gconf-merge-schema + msg echo ln + -- Operators. + -a -b -c -d -e -f -g -h -k -p -r -s -t -u -w -x -O -G -L -S -N -nt -ot -ef -o + -z -n -eq -ne -lt -le -gt -ge -Np -i +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + build check package pkgver prepare +]] * '()')) + +-- Constants. +lex:add_rule('constant', token(lexer.CONSTANT, word_match[[ + -- We do *not* list pkgver srcdir and startdir here. + -- These are defined by makepkg but user should not alter them. + arch backup changelog checkdepends conflicts depends epoch groups install + license makedepends md5sums noextract optdepends options pkgbase pkgdesc + pkgname pkgrel pkgver provides replaces sha1sums sha256sums sha384sums + sha512sums source url validpgpkeys +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Variables. +lex:add_rule('variable', token(lexer.VARIABLE, + '$' * (S('!#?*@$') + + lexer.delimited_range('()', true, true) + + lexer.delimited_range('[]', true, true) + + lexer.delimited_range('{}', true, true) + + lexer.delimited_range('`', true, true) + + lexer.digit^1 + + lexer.word))) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('=!<>+-/*^~.,:;?()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '(', ')') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/powershell.lua b/dep/scintilla/scintilla-3.10.6/lexlua/powershell.lua new file mode 100644 index 00000000..c6e4cbf3 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/powershell.lua @@ -0,0 +1,63 @@ +-- Copyright 2015-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- PowerShell LPeg lexer. +-- Contributed by Jeff Stone. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('powershell') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match([[ + Begin Break Continue Do Else End Exit For ForEach ForEach-Object Get-Date + Get-Random If Param Pause Powershell Process Read-Host Return Switch While + Write-Host +]], true))) + +-- Comparison Operators. +lex:add_rule('comparison', token(lexer.KEYWORD, '-' * word_match([[ + and as band bor contains eq ge gt is isnot le like lt match ne nomatch not + notcontains notlike or replace +]], true))) + +-- Parameters. +lex:add_rule('parameter', token(lexer.KEYWORD, '-' * word_match([[ + Confirm Debug ErrorAction ErrorVariable OutBuffer OutVariable Verbose WhatIf +]], true))) + +-- Properties. +lex:add_rule('property', token(lexer.KEYWORD, '.' * word_match([[ + day dayofweek dayofyear hour millisecond minute month second timeofday year +]], true))) + +-- Types. +lex:add_rule('type', token(lexer.KEYWORD, '[' * word_match([[ + array boolean byte char datetime decimal double hashtable int long single + string xml +]], true) * ']')) + +-- Variables. +lex:add_rule('variable', token(lexer.VARIABLE, + '$' * (lexer.digit^1 + lexer.word + + lexer.delimited_range('{}', true, true)))) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"', true))) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('=!<>+-/*^&|~.,:;?()[]{}%`'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '{', '}') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/prolog.lua b/dep/scintilla/scintilla-3.10.6/lexlua/prolog.lua new file mode 100644 index 00000000..4a45a5b3 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/prolog.lua @@ -0,0 +1,129 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Prolog LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('prolog') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + -- Directives by manual scanning of SWI-Prolog source code + abolish arithmetic_function at_halt create_prolog_flag discontiguous dynamic + elif else endif format_predicate if initialization lazy_list_iterator listing + load_extensions meta_predicate mode module module_transparent multifile op + persistent pop_operators pred predicate_options prolog_load_context public + push_operators record redefine_system_predicate reexport set_prolog_flag + setting thread_local type use_foreign_library use_module volatile + -- Built-in predicates generated in SWI-Prolog via current_predictate/1. + abolish abort absolute_file_name access_file acyclic_term add_import_module + append apply arg assert asserta assertz at_end_of_stream at_halt atom + atom_chars atom_codes atom_concat atomic atomic_concat atomic_list_concat + atomics_to_string atom_length atom_number atom_prefix atom_string atom_to_term + attach_packs attvar autoload_path bagof between b_getval blob break b_set_dict + b_setval byte_count call callable call_cleanup call_continuation call_dcg + call_residue_vars call_shared_object_function call_with_depth_limit + call_with_inference_limit cancel_halt catch character_count char_code + char_conversion char_type clause clause_property close close_shared_object + code_type collation_key compare compile_aux_clauses compile_predicates + compiling compound compound_name_arguments compound_name_arity consult + context_module copy_predicate_clauses copy_stream_data copy_term copy_term_nat + create_prolog_flag current_arithmetic_function current_atom current_blob + current_char_conversion current_engine current_flag current_format_predicate + current_functor current_input current_key current_locale current_module + current_op current_output current_predicate current_prolog_flag + current_resource current_signal current_trie cwd cyclic_term date_time_stamp + dcg_translate_rule debugging default_module del_attr del_attrs del_dict + delete_directory delete_file delete_import_module deterministic dict_create + dict_pairs directory_files divmod downcase_atom duplicate_term dwim_match + dwim_predicate engine_create engine_destroy engine_fetch engine_next + engine_next_reified engine_post engine_self engine_yield ensure_loaded erase + exception exists_directory exists_file expand_answer expand_file_name + expand_file_search_path expand_goal expand_query expand_term export + extern_indirect fail false fast_read fast_term_serialized fast_write + file_base_name file_directory_name file_name_extension file_search_path + fill_buffer findall findnsols flag float flush_output forall format + format_predicate format_time freeze frozen functor garbage_collect + garbage_collect_atoms garbage_collect_clauses gc_file_search_cache get0 get + get_attr get_attrs get_byte get_char get_code get_dict getenv get_flag + get_single_char get_string_code get_time goal_expansion ground halt ignore + import import_module instance integer intern_indirect is_absolute_file_name + is_dict is_engine is_list is_stream is_thread keysort known_licenses leash + length library_directory license line_count line_position load_files + locale_create locale_destroy locale_property make_directory make_library_index + memberchk message_hook message_property message_queue_create + message_queue_destroy message_queue_property message_to_string module + module_property msort mutex_create mutex_destroy mutex_lock mutex_property + mutex_statistics mutex_trylock mutex_unlock mutex_unlock_all name nb_current + nb_delete nb_getval nb_linkarg nb_link_dict nb_linkval nb_setarg nb_set_dict + nb_setval nl nonvar noprofile noprotocol normalize_space nospy nospyall not + notrace nth_clause nth_integer_root_and_remainder number number_chars + number_codes number_string numbervars once on_signal op open open_null_stream + open_resource open_shared_object open_string open_xterm peek_byte peek_char + peek_code peek_string phrase plus portray predicate_option_mode + predicate_option_type predicate_property print print_message + print_message_lines print_toplevel_variables profiler prolog + prolog_choice_attribute prolog_current_choice prolog_current_frame + prolog_cut_to prolog_debug prolog_event_hook prolog_file_type + prolog_frame_attribute prolog_list_goal prolog_load_context prolog_load_file + prolog_nodebug prolog_skip_frame prolog_skip_level prolog_stack_property + prolog_to_os_filename prompt1 prompt protocol protocola protocolling put + put_attr put_attrs put_byte put_char put_code put_dict pwd qcompile + random_property rational read read_clause read_history read_link + read_pending_chars read_pending_codes read_string read_term + read_term_from_atom recorda recorded recordz redefine_system_predicate + reexport reload_library_index rename_file repeat require reset reset_profiler + residual_goals resource retract retractall same_file same_term see seeing seek + seen select_dict setarg set_end_of_stream setenv set_flag set_input set_locale + setlocale set_module setof set_output set_prolog_flag set_prolog_IO + set_prolog_stack set_random set_stream set_stream_position + setup_call_catcher_cleanup setup_call_cleanup shell shift size_file skip sleep + sort source_file source_file_property source_location split_string spy + stamp_date_time statistics stream_pair stream_position_data stream_property + string string_chars string_code string_codes string_concat string_length + string_lower string_upper strip_module style_check sub_atom sub_atom_icasechk + sub_string subsumes_term succ swiplrc tab tell telling term_attvars + term_expansion term_hash term_string term_to_atom term_variables + text_to_string thread_at_exit thread_create thread_detach thread_exit + thread_get_message thread_join thread_message_hook thread_peek_message + thread_property thread_self thread_send_message thread_setconcurrency + thread_signal thread_statistics throw time_file tmp_file tmp_file_stream told + trace tracing trie_destroy trie_gen trie_insert trie_insert_new trie_lookup + trie_new trie_property trie_term trim_stacks true ttyflush tty_get_capability + tty_goto tty_put tty_size unifiable unify_with_occurs_check unload_file + unsetenv upcase_atom use_module var variant_hash variant_sha1 var_number + var_property verbose_expansion version visible wait_for_input wildcard_match + with_mutex with_output_to working_directory write write_canonical write_length + writeln writeq write_term + -- Built-in functions generated in SWI-Prolog via current_arithmetic_function/1. + xor rem rdiv mod div abs acos acosh asin asinh atan2 atan atanh ceil ceiling + copysign cos cosh cputime e epsilon erf erfc eval exp float + float_fractional_part float_integer_part floor gcd getbit inf integer lgamma + log10 log lsb max min msb nan pi popcount powm random random_float rational + rationalize round sign sin sinh sqrt tan tanh truncate +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + + lexer.delimited_range('"', true))) + +-- Comments. +local line_comment = '%' * lexer.nonnewline^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.digit^1 * + ('.' * lexer.digit^1)^-1)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('-!+\\|=:;&<>()[]{}'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/props.lua b/dep/scintilla/scintilla-3.10.6/lexlua/props.lua new file mode 100644 index 00000000..2dce8cf1 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/props.lua @@ -0,0 +1,33 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Props LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('props', {lex_by_line = true}) + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Colors. +lex:add_rule('color', token('color', '#' * lexer.xdigit * lexer.xdigit * + lexer.xdigit * lexer.xdigit * + lexer.xdigit * lexer.xdigit)) +lex:add_style('color', lexer.STYLE_NUMBER) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) + +-- Equals. +lex:add_rule('equals', token(lexer.OPERATOR, '=')) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"'))) + +-- Variables. +lex:add_rule('variable', token(lexer.VARIABLE, '$(' * (lexer.any - ')')^1 * + ')')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/protobuf.lua b/dep/scintilla/scintilla-3.10.6/lexlua/protobuf.lua new file mode 100644 index 00000000..8a6a249a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/protobuf.lua @@ -0,0 +1,45 @@ +-- Copyright 2016-2019 David B. Lamkins . See License.txt. +-- Protocol Buffer IDL LPeg lexer. +-- + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('protobuf') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + contained syntax import option package message group oneof optional required + repeated default extend extensions to max reserved service rpc returns +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + int32 int64 uint32 uint64 sint32 sint64 fixed32 fixed64 sfixed32 sfixed64 + float double bool string bytes enum true false +]])) + +-- Strings. +local sq_str = P('L')^-1 * lexer.delimited_range("'", true) +local dq_str = P('L')^-1 * lexer.delimited_range('"', true) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('<>=|;,.()[]{}'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/ps.lua b/dep/scintilla/scintilla-3.10.6/lexlua/ps.lua new file mode 100644 index 00000000..e4709c3f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/ps.lua @@ -0,0 +1,47 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Postscript LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('ps') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + pop exch dup copy roll clear count mark cleartomark counttomark exec if ifelse + for repeat loop exit stop stopped countexecstack execstack quit start + true false NULL +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + add div idiv mod mul sub abs ned ceiling floor round truncate sqrt atan cos + sin exp ln log rand srand rrand +]])) + +-- Identifiers. +local word = (lexer.alpha + '-') * (lexer.alnum + '-')^0 +lex:add_rule('identifier', token(lexer.IDENTIFIER, word)) + +-- Strings. +local arrow_string = lexer.delimited_range('<>') +local nested_string = lexer.delimited_range('()', false, false, true) +lex:add_rule('string', token(lexer.STRING, arrow_string + nested_string)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '%' * lexer.nonnewline^0)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Labels. +lex:add_rule('label', token(lexer.LABEL, '/' * word)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('[]{}'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/pure.lua b/dep/scintilla/scintilla-3.10.6/lexlua/pure.lua new file mode 100644 index 00000000..f948a96a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/pure.lua @@ -0,0 +1,50 @@ +-- Copyright 2015-2019 David B. Lamkins . See License.txt. +-- pure LPeg lexer, see http://purelang.bitbucket.org/ + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('pure') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Pragmas. +local hashbang = lexer.starts_line('#!') * (lexer.nonnewline - '//')^0 +lex:add_rule('pragma', token(lexer.PREPROCESSOR, hashbang)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + namespace with end using interface extern let const def type public private + nonfix outfix infix infixl infixr prefix postfix if otherwise when case of + then else +]])) + +-- Numbers. +local bin = '0' * S('Bb') * S('01')^1 +local hex = '0' * S('Xx') * (R('09') + R('af') + R('AF'))^1 +local dec = R('09')^1 +local int = (bin + hex + dec) * P('L')^-1 +local rad = P('.') - '..' +local exp = (S('Ee') * S('+-')^-1 * int)^-1 +local flt = int * (rad * dec)^-1 * exp + int^-1 * rad * dec * exp +lex:add_rule('number', token(lexer.NUMBER, flt + int)) + +-- Operators. +local punct = S('+-/*%<>~!=^&|?~:;,.()[]{}@#$`\\\'') +local dots = P('..') +lex:add_rule('operator', token(lexer.OPERATOR, dots + punct)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"', true))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/python.lua b/dep/scintilla/scintilla-3.10.6/lexlua/python.lua new file mode 100644 index 00000000..9de70b32 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/python.lua @@ -0,0 +1,104 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Python LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('python', {fold_by_indentation = true}) + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + and as assert break class continue def del elif else except exec finally for + from global if import in is lambda nonlocal not or pass print raise return try + while with yield + -- Descriptors/attr access. + __get__ __set__ __delete__ __slots__ + -- Class. + __new__ __init__ __del__ __repr__ __str__ __cmp__ __index__ __lt__ __le__ + __gt__ __ge__ __eq__ __ne__ __hash__ __nonzero__ __getattr__ __getattribute__ + __setattr__ __delattr__ __call__ + -- Operator. + __add__ __sub__ __mul__ __div__ __floordiv__ __mod__ __divmod__ __pow__ + __and__ __xor__ __or__ __lshift__ __rshift__ __nonzero__ __neg__ __pos__ + __abs__ __invert__ __iadd__ __isub__ __imul__ __idiv__ __ifloordiv__ __imod__ + __ipow__ __iand__ __ixor__ __ior__ __ilshift__ __irshift__ + -- Conversions. + __int__ __long__ __float__ __complex__ __oct__ __hex__ __coerce__ + -- Containers. + __len__ __getitem__ __missing__ __setitem__ __delitem__ __contains__ __iter__ + __getslice__ __setslice__ __delslice__ + -- Module and class attribs. + __doc__ __name__ __dict__ __file__ __path__ __module__ __bases__ __class__ + __self__ + -- Stdlib/sys. + __builtin__ __future__ __main__ __import__ __stdin__ __stdout__ __stderr__ + -- Other. + __debug__ __doc__ __import__ __name__ +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + abs all any apply basestring bool buffer callable chr classmethod cmp coerce + compile complex copyright credits delattr dict dir divmod enumerate eval + execfile exit file filter float frozenset getattr globals hasattr hash help + hex id input int intern isinstance issubclass iter len license list locals + long map max min object oct open ord pow property quit range raw_input reduce + reload repr reversed round set setattr slice sorted staticmethod str sum super + tuple type unichr unicode vars xrange zip +]])) + +-- Constants. +lex:add_rule('constant', token(lexer.CONSTANT, word_match[[ + ArithmeticError AssertionError AttributeError BaseException DeprecationWarning + EOFError Ellipsis EnvironmentError Exception False FloatingPointError + FutureWarning GeneratorExit IOError ImportError ImportWarning IndentationError + IndexError KeyError KeyboardInterrupt LookupError MemoryError NameError None + NotImplemented NotImplementedError OSError OverflowError + PendingDeprecationWarning ReferenceError RuntimeError RuntimeWarning + StandardError StopIteration SyntaxError SyntaxWarning SystemError SystemExit + TabError True TypeError UnboundLocalError UnicodeDecodeError + UnicodeEncodeError UnicodeError UnicodeTranslateError UnicodeWarning + UserWarning ValueError Warning ZeroDivisionError +]])) + +-- Self. +lex:add_rule('self', token('self', P('self'))) +lex:add_style('self', lexer.STYLE_TYPE) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline_esc^0)) + +-- Strings. +local sq_str = P('u')^-1 * lexer.delimited_range("'", true) +local dq_str = P('U')^-1 * lexer.delimited_range('"', true) +local triple_sq_str = "'''" * (lexer.any - "'''")^0 * P("'''")^-1 +local triple_dq_str = '"""' * (lexer.any - '"""')^0 * P('"""')^-1 +-- TODO: raw_strs cannot end in single \. +local raw_sq_str = P('u')^-1 * 'r' * lexer.delimited_range("'", false, true) +local raw_dq_str = P('U')^-1 * 'R' * lexer.delimited_range('"', false, true) +lex:add_rule('string', token(lexer.STRING, triple_sq_str + triple_dq_str + + sq_str + dq_str + raw_sq_str + + raw_dq_str)) + +-- Numbers. +local dec = lexer.digit^1 * S('Ll')^-1 +local bin = '0b' * S('01')^1 * ('_' * S('01')^1)^0 +local oct = '0' * R('07')^1 * S('Ll')^-1 +local integer = S('+-')^-1 * (bin + lexer.hex_num + oct + dec) +lex:add_rule('number', token(lexer.NUMBER, lexer.float + integer)) + +-- Decorators. +lex:add_rule('decorator', token('decorator', '@' * lexer.nonnewline^0)) +lex:add_style('decorator', lexer.STYLE_PREPROCESSOR) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('!%^&*()[]{}-=+/|:;.,?<>~`'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/rails.lua b/dep/scintilla/scintilla-3.10.6/lexlua/rails.lua new file mode 100644 index 00000000..8c76d956 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/rails.lua @@ -0,0 +1,54 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Ruby on Rails LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('rails', {inherit = lexer.load('ruby')}) + +-- Whitespace +lex:modify_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Functions. + +-- ActionPack. +lex:modify_rule('function', token(lexer.FUNCTION, word_match[[ + before_filter skip_before_filter skip_after_filter after_filter around_filter + filter filter_parameter_logging layout require_dependency render render_action + render_text render_file render_template render_nothing render_component + render_without_layout rescue_from url_for redirect_to redirect_to_path + redirect_to_url respond_to helper helper_method model service observer + serialize scaffold verify hide_action +]]) + + +-- View helpers. +token(lexer.FUNCTION, word_match[[ + check_box content_for error_messages_for form_for fields_for file_field + hidden_field image_submit_tag label link_to password_field radio_button submit + text_field text_area +]]) + + +-- ActiveRecord +token(lexer.FUNCTION, word_match[[ + after_create after_destroy after_save after_update after_validation + after_validation_on_create after_validation_on_update before_create + before_destroy before_save before_update before_validation + before_validation_on_create before_validation_on_update composed_of belongs_to + has_one has_many has_and_belongs_to_many validate validates validate_on_create + validates_numericality_of validate_on_update validates_acceptance_of + validates_associated validates_confirmation_of validates_each + validates_format_of validates_inclusion_of validates_exclusion_of + validates_length_of validates_presence_of validates_size_of + validates_uniqueness_of + attr_protected attr_accessible attr_readonly accepts_nested_attributes_for + default_scope scope +]]) + + +-- ActiveSupport +token(lexer.FUNCTION, word_match[[ + alias_method_chain alias_attribute delegate cattr_accessor mattr_accessor + returning memoize +]]) + lex:get_rule('function')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/rc.lua b/dep/scintilla/scintilla-3.10.6/lexlua/rc.lua new file mode 100644 index 00000000..60171f8f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/rc.lua @@ -0,0 +1,54 @@ +-- Copyright 2017-2019 Michael Forney. See License.txt. +-- rc LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('rc') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + for in while if not switch fn builtin cd eval exec exit flag rfork shift + ulimit umask wait whatis . ~ +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +local str = lexer.delimited_range("'", false, true) +local heredoc = '<<' * P(function(input, index) + local s, e, _, delimiter = input:find('[ \t]*(["\']?)([%w!"%%+,-./:?@_~]+)%1', + index) + if s == index and delimiter then + delimiter = delimiter:gsub('[%%+-.?]', '%%%1') + local _, e = input:find('[\n\r]'..delimiter..'[\n\r]', e) + return e and e + 1 or #input + 1 + end +end) +lex:add_rule('string', token(lexer.STRING, str + heredoc)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.integer + lexer.float)) + +-- Variables. +lex:add_rule('variable', token(lexer.VARIABLE, '$' * S('"#')^-1 * + ('*' + lexer.digit^1 + + lexer.word))) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('@`=!<>*&^|;?()[]{}') + + '\\\n')) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/rebol.lua b/dep/scintilla/scintilla-3.10.6/lexlua/rebol.lua new file mode 100644 index 00000000..81f48099 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/rebol.lua @@ -0,0 +1,98 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Rebol LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('rebol') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Comments. +local line_comment = ';' * lexer.nonnewline^0; +local block_comment = 'comment' * P(' ')^-1 * + lexer.delimited_range('{}', false, true) +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + abs absolute add and~ at back change clear complement copy cp divide fifth + find first fourth head insert last make max maximum min minimum multiply + negate next or~ pick poke power random remainder remove second select skip + sort subtract tail third to trim xor~ + alias all any arccosine arcsine arctangent bind break browse call + caret-to-offset catch checksum close comment compose compress cosine debase + decompress dehex detab dh-compute-key dh-generate-key dh-make-key difference + disarm do dsa-generate-key dsa-make-key dsa-make-signature + dsa-verify-signature either else enbase entab exclude exit exp foreach form + free get get-modes halt hide if in intersect load log-10 log-2 log-e loop + lowercase maximum-of minimum-of mold not now offset-to-caret open parse prin + print protect q query quit read read-io recycle reduce repeat return reverse + rsa-encrypt rsa-generate-key rsa-make-key save secure set set-modes show sine + size-text square-root tangent textinfo throw to-hex to-local-file + to-rebol-file trace try union unique unprotect unset until update uppercase + use wait while write write-io + basic-syntax-header crlf font-fixed font-sans-serif font-serif list-words + outstr val value + about alert alter append array ask boot-prefs build-tag center-face change-dir + charset choose clean-path clear-fields confine confirm context cvs-date + cvs-version decode-cgi decode-url deflag-face delete demo desktop dirize + dispatch do-boot do-events do-face do-face-alt does dump-face dump-pane echo + editor emailer emit extract find-by-type find-key-face find-window flag-face + flash focus for forall forever forskip func function get-net-info get-style + has help hide-popup import-email inform input insert-event-func join launch + launch-thru layout license list-dir load-image load-prefs load-thru make-dir + make-face net-error open-events parse-email-addrs parse-header + parse-header-date parse-xml path-thru probe protect-system read-net read-thru + reboot reform rejoin remold remove-event-func rename repend replace request + request-color request-date request-download request-file request-list + request-pass request-text resend save-prefs save-user scroll-para send + set-font set-net set-para set-style set-user set-user-name show-popup source + split-path stylize switch throw-on-error to-binary to-bitset to-block to-char + to-date to-decimal to-email to-event to-file to-get-word to-hash to-idate + to-image to-integer to-issue to-list to-lit-path to-lit-word to-logic to-money + to-none to-pair to-paren to-path to-refinement to-set-path to-set-word + to-string to-tag to-time to-tuple to-url to-word unfocus uninstall unview + upgrade Usage vbug view view-install view-prefs what what-dir write-user + return at space pad across below origin guide tabs indent style styles size + sense backcolor do none + action? any-block? any-function? any-string? any-type? any-word? binary? + bitset? block? char? datatype? date? decimal? email? empty? equal? error? + even? event? file? function? get-word? greater-or-equal? greater? hash? head? + image? index? integer? issue? length? lesser-or-equal? lesser? library? list? + lit-path? lit-word? logic? money? native? negative? none? not-equal? number? + object? odd? op? pair? paren? path? port? positive? refinement? routine? same? + series? set-path? set-word? strict-equal? strict-not-equal? string? struct? + tag? tail? time? tuple? unset? url? word? zero? connected? crypt-strength? + exists-key? input? script? type? value? ? ?? dir? exists-thru? exists? + flag-face? found? in-window? info? inside? link-app? link? modified? offset? + outside? screen-offset? size? span? view? viewed? win-offset? within? + action! any-block! any-function! any-string! any-type! any-word! binary! + bitset! block! char! datatype! date! decimal! email! error! event! file! + function! get-word! hash! image! integer! issue! library! list! lit-path! + lit-word! logic! money! native! none! number! object! op! pair! paren! path! + port! refinement! routine! series! set-path! set-word! string! struct! symbol! + tag! time! tuple! unset! url! word! + true false self +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, (lexer.alpha + '-') * + (lexer.alnum + '-')^0)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"', true) + + lexer.delimited_range('{}') + + "'" * lexer.word)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('=<>+/*:()[]'))) + +-- Fold points. +lex:add_fold_point(lexer.COMMENT, '{', '}') +lex:add_fold_point(lexer.COMMENT, ';', lexer.fold_line_comments(';')) +lex:add_fold_point(lexer.OPERATOR, '[', ']') + +return lex diff --git a/dep/scintillua/scintillua-3.6.0/lexers/rest.lua b/dep/scintilla/scintilla-3.10.6/lexlua/rest.lua similarity index 99% rename from dep/scintillua/scintillua-3.6.0/lexers/rest.lua rename to dep/scintilla/scintilla-3.10.6/lexlua/rest.lua index 1e0b3b18..a81e177a 100644 --- a/dep/scintillua/scintillua-3.6.0/lexers/rest.lua +++ b/dep/scintilla/scintilla-3.10.6/lexlua/rest.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. -- reStructuredText LPeg lexer. local l = require('lexer') diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/rexx.lua b/dep/scintilla/scintilla-3.10.6/lexlua/rexx.lua new file mode 100644 index 00000000..aea39e8f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/rexx.lua @@ -0,0 +1,76 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Rexx LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('rexx') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match([[ + address arg by call class do drop else end exit expose forever forward guard + if interpret iterate leave method nop numeric otherwise parse procedure pull + push queue raise reply requires return routine result rc say select self sigl + signal super then to trace use when while until +]], true))) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match([[ + abbrev abs address arg beep bitand bitor bitxor b2x center changestr charin + charout chars compare consition copies countstr c2d c2x datatype date delstr + delword digits directory d2c d2x errortext filespec form format fuzz insert + lastpos left length linein lineout lines max min overlay pos queued random + reverse right sign sourceline space stream strip substr subword symbol time + trace translate trunc value var verify word wordindex wordlength wordpos words + xrange x2b x2c x2d + rxfuncadd rxfuncdrop rxfuncquery rxmessagebox rxwinexec + sysaddrexxmacro sysbootdrive sysclearrexxmacrospace syscloseeventsem + sysclosemutexsem syscls syscreateeventsem syscreatemutexsem syscurpos + syscurstate sysdriveinfo sysdrivemap sysdropfuncs sysdroprexxmacro + sysdumpvariables sysfiledelete sysfilesearch sysfilesystemtype sysfiletree + sysfromunicode systounicode sysgeterrortext sysgetfiledatetime sysgetkey + sysini sysloadfuncs sysloadrexxmacrospace sysmkdir sysopeneventsem + sysopenmutexsem sysposteventsem syspulseeventsem sysqueryprocess + sysqueryrexxmacro sysreleasemutexsem sysreorderrexxmacro sysrequestmutexsem + sysreseteventsem sysrmdir syssaverexxmacrospace syssearchpath + syssetfiledatetime syssetpriority syssleep sysstemcopy sysstemdelete + syssteminsert sysstemsort sysswitchsession syssystemdirectory systempfilename + systextscreenread systextscreensize sysutilversion sysversion sysvolumelabel + syswaiteventsem syswaitnamedpipe syswindecryptfile syswinencryptfile syswinver +]], true))) + +-- Identifiers. +local word = lexer.alpha * (lexer.alnum + S('@#$\\.!?_'))^0 +lex:add_rule('identifier', token(lexer.IDENTIFIER, word)) + +-- Strings. +local sq_str = lexer.delimited_range("'", true, true) +local dq_str = lexer.delimited_range('"', true, true) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '--' * lexer.nonnewline_esc^0 + + lexer.nested_pair('/*', '*/'))) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Preprocessor. +lex:add_rule('preprocessor', token(lexer.PREPROCESSOR, lexer.starts_line('#') * + lexer.nonnewline^0)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('=!<>+-/\\*%&|^~.,:;(){}'))) + +-- Fold points +lex:add_fold_point(lexer.KEYWORD, 'do', 'end') +lex:add_fold_point(lexer.KEYWORD, 'select', 'return') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '--', lexer.fold_line_comments('--')) +--lex:add_fold_point(lexer.OPERATOR, ':', ?) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/rhtml.lua b/dep/scintilla/scintilla-3.10.6/lexlua/rhtml.lua new file mode 100644 index 00000000..51bc658f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/rhtml.lua @@ -0,0 +1,20 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- RHTML LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('rhtml', {inherit = lexer.load('html')}) + +-- Embedded Ruby. +local ruby = lexer.load('rails') +local ruby_start_rule = token('rhtml_tag', '<%' * P('=')^-1) +local ruby_end_rule = token('rhtml_tag', '%>') +lex:embed(ruby, ruby_start_rule, ruby_end_rule) +lex:add_style('rhtml_tag', lexer.STYLE_EMBEDDED) + +-- Fold points. +lex:add_fold_point('rhtml_tag', '<%', '%>') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/rstats.lua b/dep/scintilla/scintilla-3.10.6/lexlua/rstats.lua new file mode 100644 index 00000000..4af54fd0 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/rstats.lua @@ -0,0 +1,42 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- R LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('rstats') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + break else for if in next repeat return switch try while + Inf NA NaN NULL FALSE TRUE +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + array character complex data.frame double factor function integer list logical + matrix numeric vector +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + + lexer.delimited_range('"', true))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, (lexer.float + lexer.integer) * + P('i')^-1)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('<->+*/^=.,:;|$()[]{}'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/ruby.lua b/dep/scintilla/scintilla-3.10.6/lexlua/ruby.lua new file mode 100644 index 00000000..8aec1a7c --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/ruby.lua @@ -0,0 +1,132 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Ruby LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('ruby') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + BEGIN END alias and begin break case class def defined? do else elsif end + ensure false for if in module next nil not or redo rescue retry return self + super then true undef unless until when while yield __FILE__ __LINE__ +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + at_exit autoload binding caller catch chop chop! chomp chomp! eval exec exit + exit! fail fork format gets global_variables gsub gsub! iterator? lambda load + local_variables loop open p print printf proc putc puts raise rand readline + readlines require select sleep split sprintf srand sub sub! syscall system + test trace_var trap untrace_var +]]) * -S('.:|')) + +local word_char = lexer.alnum + S('_!?') + +-- Identifiers. +local word = (lexer.alpha + '_') * word_char^0 +lex:add_rule('identifier', token(lexer.IDENTIFIER, word)) + +-- Comments. +local line_comment = '#' * lexer.nonnewline_esc^0 +local block_comment = lexer.starts_line('=begin') * + (lexer.any - lexer.newline * '=end')^0 * + (lexer.newline * '=end')^-1 +lex:add_rule('comment', token(lexer.COMMENT, block_comment + line_comment)) + +local delimiter_matches = {['('] = ')', ['['] = ']', ['{'] = '}'} +local literal_delimitted = P(function(input, index) + local delimiter = input:sub(index, index) + if not delimiter:find('[%w\r\n\f\t ]') then -- only non alpha-numerics + local match_pos, patt + if delimiter_matches[delimiter] then + -- Handle nested delimiter/matches in strings. + local s, e = delimiter, delimiter_matches[delimiter] + patt = lexer.delimited_range(s..e, false, false, true) + else + patt = lexer.delimited_range(delimiter) + end + match_pos = lpeg.match(patt, input, index) + return match_pos or #input + 1 + end +end) + +-- Strings. +local cmd_str = lexer.delimited_range('`') +local lit_cmd = '%x' * literal_delimitted +local lit_array = '%w' * literal_delimitted +local sq_str = lexer.delimited_range("'") +local dq_str = lexer.delimited_range('"') +local lit_str = '%' * S('qQ')^-1 * literal_delimitted +local heredoc = '<<' * P(function(input, index) + local s, e, indented, _, delimiter = + input:find('(%-?)(["`]?)([%a_][%w_]*)%2[\n\r\f;]+', index) + if s == index and delimiter then + local end_heredoc = (#indented > 0 and '[\n\r\f]+ *' or '[\n\r\f]+') + local _, e = input:find(end_heredoc..delimiter, e) + return e and e + 1 or #input + 1 + end +end) +-- TODO: regex_str fails with `obj.method /patt/` syntax. +local regex_str = #P('/') * lexer.last_char_includes('!%^&*([{-=+|:;,?<>~') * + lexer.delimited_range('/', true, false) * S('iomx')^0 +local lit_regex = '%r' * literal_delimitted * S('iomx')^0 +lex:add_rule('string', token(lexer.STRING, (sq_str + dq_str + lit_str + + heredoc + cmd_str + lit_cmd + + lit_array) * S('f')^-1) + + token(lexer.REGEX, regex_str + lit_regex)) + +-- Numbers. +local dec = lexer.digit^1 * ('_' * lexer.digit^1)^0 * S('ri')^-1 +local bin = '0b' * S('01')^1 * ('_' * S('01')^1)^0 +local integer = S('+-')^-1 * (bin + lexer.hex_num + lexer.oct_num + dec) +-- TODO: meta, control, etc. for numeric_literal. +local numeric_literal = '?' * (lexer.any - lexer.space) * -word_char +lex:add_rule('number', token(lexer.NUMBER, lexer.float * S('ri')^-1 + integer + + numeric_literal)) + +-- Variables. +local global_var = '$' * (word + S('!@L+`\'=~/\\,.;<>_*"$?:') + lexer.digit + + '-' * S('0FadiIKlpvw')) +local class_var = '@@' * word +local inst_var = '@' * word +lex:add_rule('variable', token(lexer.VARIABLE, global_var + class_var + + inst_var)) + +-- Symbols. +lex:add_rule('symbol', token('symbol', ':' * P(function(input, index) + if input:sub(index - 2, index - 2) ~= ':' then return index end +end) * (word_char^1 + sq_str + dq_str))) +lex:add_style('symbol', lexer.STYLE_CONSTANT) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('!%^&*()[]{}-=+/|:;.,?<>~'))) + +-- Fold points. +local function disambiguate(text, pos, line, s) + return line:sub(1, s - 1):match('^%s*$') and + not text:sub(1, pos - 1):match('\\[ \t]*\r?\n$') and 1 or 0 +end +lex:add_fold_point(lexer.KEYWORD, 'begin', 'end') +lex:add_fold_point(lexer.KEYWORD, 'class', 'end') +lex:add_fold_point(lexer.KEYWORD, 'def', 'end') +lex:add_fold_point(lexer.KEYWORD, 'do', 'end') +lex:add_fold_point(lexer.KEYWORD, 'for', 'end') +lex:add_fold_point(lexer.KEYWORD, 'module', 'end') +lex:add_fold_point(lexer.KEYWORD, 'case', 'end') +lex:add_fold_point(lexer.KEYWORD, 'if', disambiguate) +lex:add_fold_point(lexer.KEYWORD, 'while', disambiguate) +lex:add_fold_point(lexer.KEYWORD, 'unless', disambiguate) +lex:add_fold_point(lexer.KEYWORD, 'until', disambiguate) +lex:add_fold_point(lexer.OPERATOR, '(', ')') +lex:add_fold_point(lexer.OPERATOR, '[', ']') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '=begin', '=end') +lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/rust.lua b/dep/scintilla/scintilla-3.10.6/lexlua/rust.lua new file mode 100644 index 00000000..418c9fa4 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/rust.lua @@ -0,0 +1,68 @@ +-- Copyright 2015-2019 Alejandro Baez (https://keybase.io/baez). See License.txt. +-- Rust LPeg lexer. + +local lexer = require("lexer") +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('rust') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + abstract alignof as become box break const continue crate do else enum extern + false final fn for if impl in let loop macro match mod move mut offsetof + override priv proc pub pure ref return Self self sizeof static struct super + trait true type typeof unsafe unsized use virtual where while yield +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, lexer.word^1 * S("!"))) + +-- Library types +lex:add_rule('library', token(lexer.LABEL, lexer.upper * + (lexer.lower + lexer.dec_num)^1)) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + () bool isize usize char str u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 +]])) + +-- Strings. +local sq_str = P('L')^-1 * lexer.delimited_range("'") +local dq_str = P('L')^-1 * lexer.delimited_range('"') +local raw_str = '#"' * (lexer.any - '#')^0 * P('#')^-1 +lex:add_rule('string', token(lexer.STRING, dq_str + raw_str)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, + lexer.float + + P('0b')^-1 * (lexer.dec_num + "_")^1 + + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, + S('+-/*%<>!=`^~@&|?#~:;,.()[]{}'))) + +-- Attributes. +lex:add_rule('preprocessor', token(lexer.PREPROCESSOR, + "#[" * (lexer.nonnewline - ']')^0 * + P("]")^-1)) + +-- Fold points. +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) +lex:add_fold_point(lexer.OPERATOR, '(', ')') +lex:add_fold_point(lexer.OPERATOR, '{', '}') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/sass.lua b/dep/scintilla/scintilla-3.10.6/lexlua/sass.lua new file mode 100644 index 00000000..8fec3fb2 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/sass.lua @@ -0,0 +1,24 @@ +-- Copyright 2006-2019 Robert Gieseke. See License.txt. +-- Sass CSS preprocessor LPeg lexer. +-- http://sass-lang.com + +local lexer = require('lexer') +local token = lexer.token +local P, S = lpeg.P, lpeg.S + +local lex = lexer.new('sass', {inherit = lexer.load('css')}) + +-- Line comments. +lex:add_rule('line_comment', token(lexer.COMMENT, '//' * lexer.nonnewline^0)) + +-- Variables. +lex:add_rule('variable', token(lexer.VARIABLE, '$' * (lexer.alnum + S('_-'))^1)) + +-- Mixins. +lex:add_rule('mixin', token('mixin', P('@') * lexer.word)) +lex:add_style('mixin', lexer.STYLE_FUNCTION) + +-- Fold points. +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/scala.lua b/dep/scintilla/scintilla-3.10.6/lexlua/scala.lua new file mode 100644 index 00000000..6635ec39 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/scala.lua @@ -0,0 +1,61 @@ +-- Copyright 2006-2019 JMS. See License.txt. +-- Scala LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('scala') + +-- Whitespace. +local ws = token(lexer.WHITESPACE, lexer.space^1) +lex:add_rule('whitespace', ws) + +-- Classes. +lex:add_rule('class', token(lexer.KEYWORD, P('class')) * ws^1 * + token(lexer.CLASS, lexer.word)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + abstract case catch class def do else extends false final finally for forSome + if implicit import lazy match new null object override package private + protected return sealed super this throw trait try true type val var while + with yield +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + Array Boolean Buffer Byte Char Collection Double Float Int Iterator LinkedList + List Long Map None Option Set Short SortedMap SortedSet String TreeMap TreeSet +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, lexer.word) * #P('(')) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +local symbol = "'" * lexer.word +local dq_str = lexer.delimited_range('"', true) +local tq_str = '"""' * (lexer.any - '"""')^0 * P('"""')^-1 +lex:add_rule('string', token(lexer.STRING, tq_str + symbol + dq_str)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, (lexer.float + lexer.integer) * + S('LlFfDd')^-1)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/scheme.lua b/dep/scintilla/scintilla-3.10.6/lexlua/scheme.lua new file mode 100644 index 00000000..fdf10731 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/scheme.lua @@ -0,0 +1,80 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Scheme LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('scheme') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + and begin case cond cond-expand define define-macro delay do else fluid-let if + lambda let let* letrec or quasiquote quote set! +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + abs acos angle append apply asin assoc assq assv atan car cdr caar cadr cdar + cddr caaar caadr cadar caddr cdaar cdadr cddar cdddr + call-with-current-continuation call-with-input-file call-with-output-file + call-with-values call/cc catch ceiling char->integer char-downcase char-upcase + close-input-port close-output-port cons cos current-input-port + current-output-port delete-file display dynamic-wind eval exit exact->inexact + exp expt file-or-directory-modify-seconds floor force for-each gcd gensym + get-output-string getenv imag-part integer->char lcm length list list->string + list->vector list-ref list-tail load log magnitude make-polar make-rectangular + make-string make-vector map max member memq memv min modulo newline nil not + number->string open-input-file open-input-string open-output-file + open-output-string peek-char quotient read read-char read-line real-part + remainder reverse reverse! round set-car! set-cdr! sin sqrt string + string->list string->number string->symbol string-append string-copy + string-fill! string-length string-ref string-set! substring symbol->string + system tan truncate values vector vector->list vector-fill! vector-length + vector-ref vector-set! with-input-from-file with-output-to-file write + write-char + boolean? char-alphabetic? char-ci<=? char-ci=? char-ci>? + char-lower-case? char-numeric? char-ready? char-upper-case? char-whitespace? + char<=? char=? char>? char? complex? eof-object? eq? equal? + eqv? even? exact? file-exists? inexact? input-port? integer? list? negative? + null? number? odd? output-port? pair? port? positive? procedure? rational? + real? string-ci<=? string-ci=? string-ci>? string<=? + string=? string>? string? symbol? vector? zero? + #t #f +]])) + +local word = (lexer.alpha + S('-!?')) * (lexer.alnum + S('-!?'))^0 + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, word)) + +-- Strings. +local literal = (P("'") + '#' * S('\\bdox')) * lexer.word +local dq_str = lexer.delimited_range('"') +lex:add_rule('string', token(lexer.STRING, literal + dq_str)) + +-- Comments. +local line_comment = ';' * lexer.nonnewline^0 +local block_comment = '#|' * (lexer.any - '|#')^0 * P('|#')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, P('-')^-1 * lexer.digit^1 * + (S('./') * lexer.digit^1)^-1)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('<>=*/+-`@%:()'))) + +-- Entity. +lex:add_rule('entity', token('entity', '&' * word)) +lex:add_style('entity', lexer.STYLE_VARIABLE) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '(', ')') +lex:add_fold_point(lexer.COMMENT, '#|', '|#') +lex:add_fold_point(lexer.COMMENT, ';', lexer.fold_line_comments(';')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/smalltalk.lua b/dep/scintilla/scintilla-3.10.6/lexlua/smalltalk.lua new file mode 100644 index 00000000..dc0ee297 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/smalltalk.lua @@ -0,0 +1,46 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Smalltalk LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('smalltalk') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + true false nil self super isNil not Smalltalk Transcript +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + Date Time Boolean True False Character String Array Symbol Integer Object +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + '$' * lexer.word)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, + lexer.delimited_range('"', false, true))) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S(':=_<>+-/*!()[]'))) + +-- Labels. +lex:add_rule('label', token(lexer.LABEL, '#' * lexer.word)) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '[', ']') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/sml.lua b/dep/scintilla/scintilla-3.10.6/lexlua/sml.lua new file mode 100644 index 00000000..fdb8282f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/sml.lua @@ -0,0 +1,113 @@ +-- Copyright 2017-2019 Murray Calavera. See License.txt. +-- Standard ML LPeg lexer. + +local lexer = require('lexer') +local token = lexer.token + +function mlword(words) + return lexer.word_match(words, "'") +end + +local ws = token(lexer.WHITESPACE, lexer.space^1) + +-- single line comments are valid in successor ml +local cl = '(*)' * lexer.nonnewline^0 +local comment = token(lexer.COMMENT, cl + lexer.nested_pair('(*', '*)')) + +local string = token(lexer.STRING, lpeg.P('#')^-1 * + lexer.delimited_range('"', true)) + +local function num(digit) + return digit * (digit^0 * lpeg.P('_'))^0 * digit^1 + digit +end + +local int = num(lexer.digit) +local frac = lpeg.P('.') * int +local minus = lpeg.P('~')^-1 +local exp = lpeg.S('eE') * minus * int +local real = int * frac^-1 * exp + int * frac * exp^-1 +local hex = num(lexer.xdigit) +local bin = num(lpeg.S('01')) + +local number = token(lexer.NUMBER, + lpeg.P('0w') * int + + (lpeg.P('0wx') + lpeg.P('0xw')) * hex + + (lpeg.P('0wb') + lpeg.P('0bw')) * bin + + minus * lpeg.P('0x') * hex + + minus * lpeg.P('0b') * bin + + minus * real + + minus * int +) + +local keyword = token(lexer.KEYWORD, mlword{ + 'abstype', 'and', 'andalso', 'as', 'case', 'do', 'datatype', 'else', 'end', + 'exception', 'fn', 'fun', 'handle', 'if', 'in', 'infix', 'infixr', 'let', + 'local', 'nonfix', 'of', 'op', 'orelse', 'raise', 'rec', 'then', + 'type', 'val', 'with', 'withtype', 'while', + + 'eqtype', 'functor', 'include', 'sharing', 'sig', 'signature', + 'struct', 'structure' +}) + +-- includes valid symbols for identifiers +local operator = token(lexer.OPERATOR, + lpeg.S('!*/+-^:@=<>()[]{},;._|#%&$?~`\\')) + +local type = token(lexer.TYPE, mlword{ + 'int', 'real', 'word', 'bool', 'char', 'string', 'unit', + 'array', 'exn', 'list', 'option', 'order', 'ref', 'substring', 'vector' +}) + +-- `real`, `vector` and `substring` are a problem +local func = token(lexer.FUNCTION, mlword{ + 'app', 'before', 'ceil', 'chr', 'concat', 'exnMessage', 'exnName', + 'explode', 'floor', 'foldl', 'foldr', 'getOpt', 'hd', 'ignore', + 'implode', 'isSome', 'length', 'map', 'not', 'null', 'ord', 'print', + 'real', 'rev', 'round', 'size', 'str', 'substring', 'tl', 'trunc', + 'valOf', 'vector', + 'o', 'abs', 'mod', 'div' +}) + +-- non-symbolic identifiers only +local id = (lexer.alnum + "'" + '_')^0 +local aid = lexer.alpha * id +local longid = (aid * lpeg.P('.'))^0 * aid +local identifier = token(lexer.IDENTIFIER, lexer.lower * id) +local typevar = token(lexer.VARIABLE, "'" * id) +local c = mlword{'true', 'false', 'nil'} +local const = token(lexer.CONSTANT, lexer.upper * id + c) +local structure = token(lexer.CLASS, aid * lpeg.P('.')) + +local open + = token(lexer.KEYWORD, mlword{'open', 'structure', 'functor'}) + * ws * token(lexer.CLASS, longid) + +local struct_dec + = token(lexer.KEYWORD, lpeg.P('structure')) * ws + * token(lexer.CLASS, aid) * ws + * token(lexer.OPERATOR, lpeg.P('=')) * ws + +local struct_new = struct_dec * token(lexer.KEYWORD, lpeg.P('struct')) +local struct_alias = struct_dec * token(lexer.CLASS, longid) + +local M = {_NAME = 'sml'} + +M._rules = { + {'whitespace', ws}, + {'comment', comment}, + {'number', number}, + {'struct_new', struct_new}, + {'struct_alias', struct_alias}, + {'structure', structure}, + {'open', open}, + {'type', type}, + {'keyword', keyword}, + {'function', func}, + {'string', string}, + {'operator', operator}, + {'typevar', typevar}, + {'constant', const}, + {'identifier', identifier}, +} + +return M diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/snobol4.lua b/dep/scintilla/scintilla-3.10.6/lexlua/snobol4.lua new file mode 100644 index 00000000..0437140c --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/snobol4.lua @@ -0,0 +1,65 @@ +-- Copyright 2013-2019 Michael T. Richter. See License.txt. +-- SNOBOL4 lexer. +-- This lexer works with classic SNOBOL4 as well as the CSNOBOL4 extensions. + +local lexer = require 'lexer' +local token, word_match = lexer.token, lexer.word_match +local B, P, R, S, V = lpeg.B, lpeg.P, lpeg.R, lpeg.S, lpeg.V + +local M = { _NAME = 'snobol4' } + +-- Helper patterns. +local dotted_id = lexer.word * (P'.' * lexer.word)^0 + +local dq_str = lexer.delimited_range('"', true, true) +local sq_str = lexer.delimited_range("'", true, true) + +local branch = B(lexer.space * P':(') * dotted_id * #P')' +local sbranch = B(lexer.space * P':' * S'SF' * '(') * dotted_id * #P')' +local sbranchx = B(P')' * S'SF' * P'(') * dotted_id * #P')' + +-- Token definitions. +local bif = token(lexer.FUNCTION, word_match({ + 'APPLY', 'ARRAY', 'CHAR', 'CONVERT', 'COPY', 'DATA', 'DATE', 'DIFFER', 'DUPL', + 'EQ', 'EVAL', 'FILE_ABSPATH', 'FILE_ISDIR', 'FREEZE', 'FUNCTION', 'GE', 'GT', + 'HOST', 'IDENT', 'INTEGER', 'IO_FINDUNIT', 'ITEM', 'LABEL', 'LOAD', 'LPAD', + 'LE', 'LGT', 'LT', 'NE', 'OPSYN', 'ORD', 'PROTOTYPE', 'REMDR', 'REPLACE', + 'REVERSE', 'RPAD', 'RSORT', 'SERV_LISTEN', 'SET', 'SETEXIT', 'SIZE', 'SORT', + 'SQRT', 'SSET', 'SUBSTR', 'TABLE', 'THAW', 'TIME', 'TRACE', 'TRIM', 'UNLOAD', + 'VALUE', 'VDIFFER', +}, '', true) * #lexer.delimited_range('()', false, true, true)) +local comment = token(lexer.COMMENT, + lexer.starts_line(S'*#|;!' * lexer.nonnewline^0)) +local control = token(lexer.PREPROCESSOR, lexer.starts_line(P'-' * lexer.word)) +local identifier = token(lexer.DEFAULT, dotted_id) +local keyword = token(lexer.KEYWORD, word_match({ + 'ABORT', 'ARRAY', 'CONTINUE', 'DEFINE', 'END', 'FRETURN', 'INPUT', 'NRETURN', + 'OUTPUT', 'PUNCH', 'RETURN', 'SCONTINUE', 'TABLE', +}, '', true) + P'&' * lexer.word) +local label = token(lexer.LABEL, lexer.starts_line(dotted_id)) +local number = token(lexer.NUMBER, lexer.float + lexer.integer) +local operator = token(lexer.OPERATOR, S'¬?$.!%*/#+-@⊥&^~\\=') +local pattern = lexer.token(lexer.CLASS, word_match({ -- keep distinct + 'ABORT', 'ANY', 'ARB', 'ARBNO', 'BAL', 'BREAK', 'BREAKX', 'FAIL', 'FENCE', + 'LEN', 'NOTANY', 'POS', 'REM', 'RPOS', 'RTAB', 'SPAN', 'SUCCEED', 'TAB', +}, '', true) * #lexer.delimited_range('()', false, true, true)) +local str = token(lexer.STRING, sq_str + dq_str) +local target = token(lexer.LABEL, branch + sbranch + sbranchx) +local ws = token(lexer.WHITESPACE, lexer.space^1) + +M._rules = { + { 'comment', comment }, + { 'control', control }, + { 'string', str }, + { 'number', number }, + { 'keyword', keyword }, + { 'label', label }, + { 'target', target }, + { 'pattern', pattern }, + { 'built-in', bif }, + { 'operator', operator }, + { 'identifier', identifier }, + { 'whitespace', ws }, +} + +return M diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/sql.lua b/dep/scintilla/scintilla-3.10.6/lexlua/sql.lua new file mode 100644 index 00000000..e6bbc521 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/sql.lua @@ -0,0 +1,59 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- SQL LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('sql') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match([[ + add all alter analyze and as asc asensitive before between bigint binary blob + both by call cascade case change char character check collate column condition + connection constraint continue convert create cross current_date current_time + current_timestamp current_user cursor database databases day_hour + day_microsecond day_minute day_second dec decimal declare default delayed + delete desc describe deterministic distinct distinctrow div double drop dual + each else elseif enclosed escaped exists exit explain false fetch float for + force foreign from fulltext goto grant group having high_priority + hour_microsecond hour_minute hour_second if ignore in index infile inner inout + insensitive insert int integer interval into is iterate join key keys kill + leading leave left like limit lines load localtime localtimestamp lock long + longblob longtext loop low_priority match mediumblob mediumint mediumtext + middleint minute_microsecond minute_second mod modifies natural not + no_write_to_binlog null numeric on optimize option optionally or order out + outer outfile precision primary procedure purge read reads real references + regexp rename repeat replace require restrict return revoke right rlike schema + schemas second_microsecond select sensitive separator set show smallint soname + spatial specific sql sqlexception sqlstate sqlwarning sql_big_result + sql_calc_found_rows sql_small_result ssl starting straight_join table + terminated text then tinyblob tinyint tinytext to trailing trigger true undo + union unique unlock unsigned update usage use using utc_date utc_time + utc_timestamp values varbinary varchar varcharacter varying when where while + with write xor year_month zerofill +]], true))) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"') + + lexer.delimited_range('`'))) + +-- Comments. +local line_comment = (P('--') + '#') * lexer.nonnewline^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S(',()'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/taskpaper.lua b/dep/scintilla/scintilla-3.10.6/lexlua/taskpaper.lua new file mode 100644 index 00000000..8bb760c4 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/taskpaper.lua @@ -0,0 +1,60 @@ +-- Copyright (c) 2016-2019 Larry Hynes. See License.txt. +-- Taskpaper LPeg lexer + +local lexer = require('lexer') +local token = lexer.token +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local M = {_NAME = 'taskpaper'} + +local delimiter = P(' ') + P('\t') + +-- Whitespace +local ws = token(lexer.WHITESPACE, lexer.space^1) + +-- Tags +local day_tag = token('day_tag', (P('@today') + P('@tomorrow'))) + +local overdue_tag = token('overdue_tag', P('@overdue')) + +local plain_tag = token('plain_tag', P('@') * lexer.word) + +local extended_tag = token('extended_tag', + P('@') * lexer.word * P('(') * + (lexer.word + R('09') + P('-'))^1 * P(')')) + +-- Projects +local project = token('project', + lexer.nested_pair(lexer.starts_line(lexer.alnum), ':') * + lexer.newline) + +-- Notes +local note = token('note', delimiter^1 * lexer.alnum * lexer.nonnewline^0) + +-- Tasks +local task = token('task', delimiter^1 * P('-') + lexer.newline) + +M._rules = { + {'note', note}, + {'task', task}, + {'project', project}, + {'extended_tag', extended_tag}, + {'day_tag', day_tag}, + {'overdue_tag', overdue_tag}, + {'plain_tag', plain_tag}, + {'whitespace', ws}, +} + +M._tokenstyles = { + note = lexer.STYLE_CONSTANT, + task = lexer.STYLE_FUNCTION, + project = lexer.STYLE_TAG, + extended_tag = lexer.STYLE_COMMENT, + day_tag = lexer.STYLE_CLASS, + overdue_tag = lexer.STYLE_PREPROCESSOR, + plain_tag = lexer.STYLE_COMMENT, +} + +M._LEXBYLINE = true + +return M diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/tcl.lua b/dep/scintilla/scintilla-3.10.6/lexlua/tcl.lua new file mode 100644 index 00000000..a612ce4f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/tcl.lua @@ -0,0 +1,49 @@ +-- Copyright 2014-2019 Joshua Krämer. See License.txt. +-- Tcl LPeg lexer. +-- This lexer follows the TCL dodekalogue (http://wiki.tcl.tk/10259). +-- It is based on the previous lexer by Mitchell. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('tcl') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Comment. +lex:add_rule('comment', token(lexer.COMMENT, '#' * P(function(input, index) + local i = index - 2 + while i > 0 and input:find('^[ \t]', i) do i = i - 1 end + if i < 1 or input:find('^[\r\n;]', i) then return index end +end) * lexer.nonnewline^0)) + +-- Separator (semicolon). +lex:add_rule('separator', token(lexer.CLASS, P(';'))) + +-- Argument expander. +lex:add_rule('expander', token(lexer.LABEL, P('{*}'))) + +-- Delimiters. +lex:add_rule('braces', token(lexer.KEYWORD, S('{}'))) +lex:add_rule('quotes', token(lexer.FUNCTION, '"')) +lex:add_rule('brackets', token(lexer.VARIABLE, S('[]'))) + +-- Variable substitution. +lex:add_rule('variable', token(lexer.STRING, '$' * + (lexer.alnum + '_' + P(':')^2)^0)) + +-- Backslash substitution. +lex:add_rule('backslash', token(lexer.TYPE, + '\\' * (lexer.digit * lexer.digit^-2 + + 'x' * lexer.xdigit^1 + + 'u' * lexer.xdigit * lexer.xdigit^-3 + + 'U' * lexer.xdigit * lexer.xdigit^-7 + + 1))) + +-- Fold points. +lex:add_fold_point(lexer.KEYWORD, '{', '}') +lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/template.txt b/dep/scintilla/scintilla-3.10.6/lexlua/template.txt new file mode 100644 index 00000000..73047938 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/template.txt @@ -0,0 +1,38 @@ +-- ? LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('?') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + keyword1 keyword2 keyword3 +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"'))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-*/%^=<>,.{}[]()'))) + +-- Fold points. +lex:add_fold_point(lexer.KEYWORD, 'start', 'end') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '#', lexer.fold_line_comments('#')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/tex.lua b/dep/scintilla/scintilla-3.10.6/lexlua/tex.lua new file mode 100644 index 00000000..7b970f83 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/tex.lua @@ -0,0 +1,34 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Plain TeX LPeg lexer. +-- Modified by Robert Gieseke. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('tex') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '%' * lexer.nonnewline^0)) + +-- TeX environments. +lex:add_rule('environment', token('environment', '\\' * (P('begin') + 'end') * + lexer.word)) +lex:add_style('environment', lexer.STYLE_KEYWORD) + +-- Commands. +lex:add_rule('command', token(lexer.KEYWORD, '\\' * + (lexer.alpha^1 + S('#$&~_^%{}')))) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('$&#{}[]'))) + +-- Fold points. +lex:add_fold_point(lexer.COMMENT, '%', lexer.fold_line_comments('%')) +lex:add_fold_point('environment', '\\begin', '\\end') +lex:add_fold_point(lexer.OPERATOR, '{', '}') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/texinfo.lua b/dep/scintilla/scintilla-3.10.6/lexlua/texinfo.lua new file mode 100644 index 00000000..01111288 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/texinfo.lua @@ -0,0 +1,222 @@ +-- Copyright 2014-2019 stef@ailleurs.land. See License.txt. +-- Plain Texinfo version 5.2 LPeg lexer +-- Freely inspired from Mitchell work and valuable help from him too ! + +-- Directives are processed (more or less) in the Reference Card Texinfo order +-- Reference Card page for each directive group is in comment for reference + +--[[ +Note: Improving Fold Points use with Texinfo + +At the very beginning of your Texinfo file, it could be wised to insert theses +alias : + +@alias startchapter = comment +@alias endchapter = comment + +Then use this to begin each chapter : + +@endchapter -------------------------------------------------------------------- +@chapter CHAPTER TITLE +@startchapter ------------------------------------------------------------------ + +With the use of Scintilla's `SCI_FOLDALL(SC_FOLDACTION_TOGGLE)` or Textadept's +`buffer:fold_all(buffer.FOLDACTION_TOGGLE)`, you have then a nice chapter +folding, useful with large documents. +]] + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('texinfo') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Directives. +local directives_base = word_match([[ + end + -- Custom keywords for chapter folding + startchapter endchapter + -- List and tables (page 2, column 2) + itemize enumerate + -- Beginning a Texinfo document (page 1, column 1) + titlepage copying + -- Block environments (page 2, column 1) + cartouche + -- Block environments > Displays using fixed-width fonts (page 2, column 2) + example smallexample + -- List and tables (page 2, column 2) + multitable + -- Floating Displays (page 2, column 3) + float listoffloats caption shortcaption image + -- Floating Displays > Footnotes (page 2, column 3) + footnote footnotestyle + -- Conditionally (in)visible text > Output formats (page 3, column 3) + ifdocbook ifhtml ifinfo ifplaintext iftex ifxml ifnotdocbook ifnothtml + ifnotplaintext ifnottex ifnotxml ifnotinfo inlinefmt inlinefmtifelse + -- Conditionally (in)visible text > Raw formatter text (page 4, column 1) + docbook html tex xml inlineraw + -- Conditionally (in)visible text > Documents variables (page 4, column 1) + set clear value ifset ifclear inlineifset inlineifclear + -- Conditionally (in)visible text > Testing for commands (page 4, column 1) + ifcommanddefined ifcommandnotdefined end + -- Defining new Texinfo commands (page 4, column 1) + alias macro unmacro definfounclose + -- File inclusion (page 4, column 1) + include verbatiminclude + -- Formatting and headers footers for TeX (page 4, column 1) + allowcodebreaks finalout fonttextsize + -- Formatting and headers footers for TeX > paper size (page 4, column 2) + smallbook afourpaper afivepaper afourlatex afourwide pagesizes + -- Formatting and headers footers for TeX > Page headers and footers (page 4, + -- column 2) + -- not implemented + -- Document preferences (page 4, column 2) + -- not implemented + -- Ending a Texinfo document (page 4, column 2) + bye +]], true) +lex:add_rule('directive', token('directives', ('@end' * lexer.space^1 + '@') * + directives_base)) +lex:add_style('directives', lexer.STYLE_FUNCTION) + +-- Chapters. +local chapters_base = word_match([[ + -- Chapter structuring (page 1, column 2) + lowersections raisesections part + -- Chapter structuring > Numbered, included in contents (page 1, column 2) + chapter centerchap + -- Chapter structuring > Context-dependent, included in contents (page 1, + -- column 2) + section subsection subsubsection + -- Chapter structuring > Unumbered, included in contents (page 1, column 2) + unnumbered unnumberedsec unnumberedsubsec unnumberedsubsection + unnumberedsubsubsec unnumberedsubsubsection + -- Chapter structuring > Letter and numbered, included in contents (page 1, + -- column 2) + appendix appendixsec appendixsection appendixsubsec appendixsubsection + appendixsubsubsec appendixsubsubsection + -- Chapter structuring > Unumbered, not included in contents, no new page + -- (page 1, column 3) + chapheading majorheading heading subheading subsubheading +]], true) +lex:add_rule('chapter', token('chapters', ('@end' * lexer.space^1 + '@') * + chapters_base)) +lex:add_style('chapters', lexer.STYLE_CLASS) + +-- Common keywords. +local keyword_base = word_match([[ + end + -- Beginning a Texinfo document (page 1, column 1) + setfilename settitle insertcopying + -- Beginning a Texinfo document > Internationlization (page 1, column 1) + documentencoding documentlanguage frenchspacing + -- Beginning a Texinfo document > Info directory specification and HTML + -- document description (page 1, column 1) + dircategory direntry documentdescription + -- Beginning a Texinfo document > Titre pages (page 1, column 1) + shorttitlepage center titlefont title subtitle author + -- Beginning a Texinfo document > Tables of contents (page 1, column 2) + shortcontents summarycontents contents setcontentsaftertitlepage + setshortcontentsaftertitlepage + -- Nodes (page 1, column 2) + node top anchor novalidate + -- Menus (page 1, column 2) + menu detailmenu + -- Cross references > Within the Info system (page 1, column 3) + xref pxref ref inforef xrefautomaticsectiontitle + -- Cross references > Outside of info (page 1, column 3) + url cite + -- Marking text > Markup for regular text (page 1, column 3) + var dfn acronym abbr + -- Marking text > Markup for litteral text (page 1, column 3) + code file command env option kbd key email indicateurl samp verb + -- Marking text > GUI sequences (page 2, column 1) + clicksequence click clickstyle arrow + -- Marking text > Math (page 2, column 1) + math minus geq leq + -- Marking text > Explicit font selection (page 2, column 1) + sc r i slanted b sansserif t + -- Block environments (page 2, column 1) + noindent indent exdent + -- Block environments > Normally filled displays using regular text fonts + -- (page 2, column 1) + quotation smallquotation indentedblock smallindentedblock raggedright + -- Block environments > Line-for-line displays using regular test fonts (page + -- 2, column 2) + format smallformat display smalldisplay flushleft flushright + -- Block environments > Displays using fixed-width fonts (page 2, column 2) + lisp smalllisp verbatim + -- List and tables (page 2, column 2) + table ftable vtable tab item itemx headitem headitemfont asis + -- Indices (page 2, column 3) + cindex findex vindex kindex pindex tindex defcodeindex syncodeindex synindex + printindex + -- Insertions within a paragraph > Characters special to Texinfo (page 2, + -- column 3) + @ { } backslashcar comma hashcar : . ? ! dmn + -- Insertions within a paragraph > Accents (page 3, column 1) + -- not implemented + -- Insertions within a paragraph > Non-English characters (page 3, column 1) + -- not implemented + -- Insertions within a paragraph > Other text characters an logos (page 3, + -- column 1) + bullet dots enddots euro pounds textdegree copyright registeredsymbol TeX + LaTeX today guillemetleft guillementright guillemotleft guillemotright + -- Insertions within a paragraph > Glyphs for code examples (page 3, column 2) + equiv error expansion point print result + -- Making and preventing breaks (page 3, column 2) + * / - hyphenation tie w refill + -- Vertical space (page 3, column 2) + sp page need group vskip + -- Definition commands (page 3, column 2) + -- not implemented +]], true) +lex:add_rule('keyword', token(lexer.KEYWORD, ('@end' * lexer.space^1 + '@') * + keyword_base)) + +-- Italics +lex:add_rule('emph', token('emph', + '@emph' * + lexer.delimited_range('{}', false, true, true))) +lex:add_style('emph', lexer.STYLE_STRING..',italics') + +-- Bold +lex:add_rule('strong', token('strong', + '@strong' * + lexer.delimited_range('{}', false, true, true))) +lex:add_style('strong', lexer.STYLE_STRING..',bold') + +-- Identifiers +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, + lexer.delimited_range('{}', false, true, true))) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Comments. +local line_comment = '@c' * lexer.nonnewline_esc^0 +--local line_comment_long = '@comment' * lexer.nonnewline_esc^0 +local block_comment = '@ignore' * (lexer.any - '@end ignore')^0 * + P('@end ignore')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Fold points. +lex:add_fold_point('directives', '@titlepage', '@end titlepage') +lex:add_fold_point('directives', '@copying', '@end copying') +lex:add_fold_point('directives', '@ifset', '@end ifset') +lex:add_fold_point('directives', '@tex', '@end tex') +lex:add_fold_point('directives', '@itemize', '@end itemize') +lex:add_fold_point('directives', '@enumerate', '@end enumerate') +lex:add_fold_point('directives', '@multitable', '@end multitable') +lex:add_fold_point('directives', '@example', '@end example') +lex:add_fold_point('directives', '@smallexample', '@end smallexample') +lex:add_fold_point('directives', '@cartouche', '@end cartouche') +lex:add_fold_point('directives', '@startchapter', '@end startchapter') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/text.lua b/dep/scintilla/scintilla-3.10.6/lexlua/text.lua new file mode 100644 index 00000000..de520485 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/text.lua @@ -0,0 +1,4 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Text LPeg lexer. + +return require('lexer').new('text') diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/themes/curses.lua b/dep/scintilla/scintilla-3.10.6/lexlua/themes/curses.lua new file mode 100644 index 00000000..9ad95f55 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/themes/curses.lua @@ -0,0 +1,55 @@ +-- Copyright 2007-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Curses theme for Lua lexers. +-- Contributions by Ana Balan. + +local property = require('lexer').property + +-- Normal colors. +property['color.black'] = '#000000' +property['color.red'] = '#800000' +property['color.green'] = '#008000' +property['color.yellow'] = '#808000' +property['color.blue'] = '#000080' +property['color.magenta'] = '#800080' +property['color.cyan'] = '#008080' +property['color.white'] = '#C0C0C0' + +-- Light colors. (16 color terminals only.) +-- These only apply to 16 color terminals. For other terminals, set the +-- style's `bold` attribute to use the light color variant. +property['color.light_black'] = '#404040' +property['color.light_red'] = '#FF0000' +property['color.light_green'] = '#00FF00' +--property['color.light_yellow'] = '#FFFF00' +property['color.light_blue'] = '#0000FF' +property['color.light_magenta'] = '#FF00FF' +--property['color.light_cyan'] = '#0000FF' +property['color.light_white'] = '#FFFFFF' + +-- Predefined styles. +property['style.default'] = 'fore:$(color.white),back:$(color.black)' +property['style.linenumber'] = '' +property['style.bracelight'] = 'fore:$(color.black),back:$(color.white)' +property['style.controlchar'] = '' +property['style.indentguide'] = '' +property['style.calltip'] = '$(style.default)' +property['style.folddisplaytext'] = 'fore:$(color.black),bold' + +-- Token styles. +property['style.class'] = 'fore:$(color.yellow)' +property['style.comment'] = 'fore:$(color.black),bold' +property['style.constant'] = 'fore:$(color.red)' +property['style.embedded'] = '$(style.keyword),back:$(color.black)' +property['style.error'] = 'fore:$(color.red),bold' +property['style.function'] = 'fore:$(color.blue)' +property['style.identifier'] = '' +property['style.keyword'] = 'fore:$(color.white),bold' +property['style.label'] = 'fore:$(color.red),bold' +property['style.number'] = 'fore:$(color.cyan)' +property['style.operator'] = 'fore:$(color.yellow)' +property['style.preprocessor'] = 'fore:$(color.magenta)' +property['style.regex'] = 'fore:$(color.green),bold' +property['style.string'] = 'fore:$(color.green)' +property['style.type'] = 'fore:$(color.magenta),bold' +property['style.variable'] = 'fore:$(color.blue),bold' +property['style.whitespace'] = '' diff --git a/dep/scintillua/scintillua-3.6.0/lexers/themes/dark.lua b/dep/scintilla/scintilla-3.10.6/lexlua/themes/dark.lua similarity index 74% rename from dep/scintillua/scintillua-3.6.0/lexers/themes/dark.lua rename to dep/scintilla/scintilla-3.10.6/lexlua/themes/dark.lua index 4be6bea7..4a1af5e7 100644 --- a/dep/scintillua/scintillua-3.6.0/lexers/themes/dark.lua +++ b/dep/scintilla/scintilla-3.10.6/lexlua/themes/dark.lua @@ -1,8 +1,8 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Dark lexer theme for Scintillua. +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Dark theme for Lua lexers. -- Contributions by Ana Balan. -local property = lexer.property +local property = require('lexer').property -- Greyscale colors. --property['color.dark_black'] = '#000000' @@ -51,43 +51,39 @@ property['color.light_green'] = '#80CC80' property['color.light_blue'] = '#80CCFF' -- Default style. -local font, size = 'Bitstream Vera Sans Mono', 10 +property['font'], property['fontsize'] = 'Bitstream Vera Sans Mono', 10 if WIN32 then - font = 'Courier New' + property['font'] = 'Courier New' elseif OSX then - font, size = 'Monaco', 12 + property['font'], property['fontsize'] = 'Monaco', 12 end -property['style.default'] = 'font:'..font..',size:'..size.. - ',fore:$(color.light_grey),back:$(color.black)' + +-- Predefined styles. +property['style.default'] = 'font:$(font),size:$(fontsize),'.. + 'fore:$(color.light_grey),back:$(color.black)' +property['style.linenumber'] = 'fore:$(color.dark_grey),back:$(color.black)' +property['style.bracelight'] = 'fore:$(color.light_blue)' +property['style.bracebad'] = 'fore:$(color.light_red)' +property['style.controlchar'] = '' +property['style.indentguide'] = 'fore:$(color.light_black)' +property['style.calltip'] = 'fore:$(color.light_grey),back:$(color.light_black)' +property['style.folddisplaytext'] = 'fore:$(color.dark_grey)' -- Token styles. -property['style.nothing'] = '' property['style.class'] = 'fore:$(color.light_yellow)' property['style.comment'] = 'fore:$(color.dark_grey)' property['style.constant'] = 'fore:$(color.red)' -property['style.definition'] = 'fore:$(color.light_yellow)' +property['style.embedded'] = '$(style.keyword),back:$(color.light_black)' property['style.error'] = 'fore:$(color.red),italics' property['style.function'] = 'fore:$(color.blue)' +property['style.identifier'] = '' property['style.keyword'] = 'fore:$(color.dark_white)' property['style.label'] = 'fore:$(color.orange)' property['style.number'] = 'fore:$(color.teal)' property['style.operator'] = 'fore:$(color.yellow)' +property['style.preprocessor'] = 'fore:$(color.purple)' property['style.regex'] = 'fore:$(color.light_green)' property['style.string'] = 'fore:$(color.green)' -property['style.preprocessor'] = 'fore:$(color.purple)' -property['style.tag'] = 'fore:$(color.dark_white)' property['style.type'] = 'fore:$(color.lavender)' property['style.variable'] = 'fore:$(color.light_blue)' property['style.whitespace'] = '' -property['style.embedded'] = '$(style.tag),back:$(color.light_black)' -property['style.identifier'] = '$(style.nothing)' - --- Predefined styles. -property['style.linenumber'] = 'fore:$(color.dark_grey),back:$(color.black)' -property['style.bracelight'] = 'fore:$(color.light_blue)' -property['style.bracebad'] = 'fore:$(color.light_red)' -property['style.controlchar'] = '$(style.nothing)' -property['style.indentguide'] = 'fore:$(color.light_black),'.. - 'back:$(color.light_black)' -property['style.calltip'] = 'fore:$(color.light_grey),'.. - 'back:$(color.light_black)' diff --git a/dep/scintillua/scintillua-3.6.0/lexers/themes/light.lua b/dep/scintilla/scintilla-3.10.6/lexlua/themes/light.lua similarity index 74% rename from dep/scintillua/scintillua-3.6.0/lexers/themes/light.lua rename to dep/scintilla/scintilla-3.10.6/lexlua/themes/light.lua index 0ae86d34..2c419d47 100644 --- a/dep/scintillua/scintillua-3.6.0/lexers/themes/light.lua +++ b/dep/scintilla/scintilla-3.10.6/lexlua/themes/light.lua @@ -1,8 +1,8 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Light lexer theme for Scintillua. +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Light theme for Lua lexers. -- Contributions by Ana Balan. -local property = lexer.property +local property = require('lexer').property -- Greyscale colors. --property['color.dark_black'] = '#000000' @@ -51,43 +51,39 @@ property['color.light_red'] = '#C08080' property['color.light_blue'] = '#80CCFF' -- Default style. -local font, size = 'Bitstream Vera Sans Mono', 10 +property['font'], property['fontsize'] = 'Bitstream Vera Sans Mono', 10 if WIN32 then - font = 'Courier New' + property['font'] = 'Courier New' elseif OSX then - font, size = 'Monaco', 12 + property['font'], property['fontsize'] = 'Monaco', 12 end -property['style.default'] = 'font:'..font..',size:'..size.. - ',fore:$(color.light_black),back:$(color.white)' + +-- Predefined styles. +property['style.default'] = 'font:$(font),size:$(fontsize),'.. + 'fore:$(color.light_black),back:$(color.white)' +property['style.linenumber'] = 'fore:$(color.grey),back:$(color.white)' +property['style.bracelight'] = 'fore:$(color.light_blue)' +property['style.bracebad'] = 'fore:$(color.light_red)' +property['style.controlchar'] = '' +property['style.indentguide'] = 'fore:$(color.dark_white)' +property['style.calltip'] = 'fore:$(color.light_black),back:$(color.dark_white)' +property['style.folddisplaytext'] = 'fore:$(color.grey)' -- Token styles. -property['style.nothing'] = '' property['style.class'] = 'fore:$(color.yellow)' property['style.comment'] = 'fore:$(color.grey)' property['style.constant'] = 'fore:$(color.red)' -property['style.definition'] = 'fore:$(color.yellow)' +property['style.embedded'] = '$(style.keyword),back:$(color.dark_white)' property['style.error'] = 'fore:$(color.red),italics' property['style.function'] = 'fore:$(color.dark_orange)' +property['style.identifier'] = '' property['style.keyword'] = 'fore:$(color.dark_blue)' property['style.label'] = 'fore:$(color.dark_orange)' property['style.number'] = 'fore:$(color.teal)' property['style.operator'] = 'fore:$(color.purple)' +property['style.preprocessor'] = 'fore:$(color.dark_yellow)' property['style.regex'] = 'fore:$(color.dark_green)' property['style.string'] = 'fore:$(color.green)' -property['style.preprocessor'] = 'fore:$(color.dark_yellow)' -property['style.tag'] = 'fore:$(color.dark_blue)' property['style.type'] = 'fore:$(color.lavender)' property['style.variable'] = 'fore:$(color.dark_lavender)' property['style.whitespace'] = '' -property['style.embedded'] = '$(style.tag),back:$(color.dark_white)' -property['style.identifier'] = '$(style.nothing)' - --- Predefined styles. -property['style.linenumber'] = 'fore:$(color.grey),back:$(color.white)' -property['style.bracelight'] = 'fore:$(color.light_blue)' -property['style.bracebad'] = 'fore:$(color.light_red)' -property['style.controlchar'] = '$(style.nothing)' -property['style.indentguide'] = 'fore:$(color.dark_white),'.. - 'back:$(color.dark_white)' -property['style.calltip'] = 'fore:$(color.light_black),'.. - 'back:$(color.dark_white)' diff --git a/dep/scintillua/scintillua-3.6.0/lexers/themes/scite.lua b/dep/scintilla/scintilla-3.10.6/lexlua/themes/scite.lua similarity index 72% rename from dep/scintillua/scintillua-3.6.0/lexers/themes/scite.lua rename to dep/scintilla/scintilla-3.10.6/lexlua/themes/scite.lua index 4e30f51c..94c97a5c 100644 --- a/dep/scintillua/scintillua-3.6.0/lexers/themes/scite.lua +++ b/dep/scintilla/scintilla-3.10.6/lexlua/themes/scite.lua @@ -1,7 +1,7 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- SciTE lexer theme for Scintillua. +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- SciTE theme for Lua lexers. -local property = lexer.property +local property = require('lexer').property property['color.red'] = '#7F0000' property['color.yellow'] = '#7F7F00' @@ -15,41 +15,39 @@ property['color.grey'] = '#808080' property['color.white'] = '#FFFFFF' -- Default style. -local font, size = 'Monospace', 11 +property['font'], property['fontsize'] = 'Monospace', 11 if WIN32 then - font = 'Courier New' + property['font'] = 'Courier New' elseif OSX then - font, size = 'Monaco', 12 + property['font'], property['fontsize'] = 'Monaco', 12 end -property['style.default'] = 'font:'..font..',size:'..size.. - ',fore:$(color.black),back:$(color.white)' + +-- Predefined styles. +property['style.default'] = 'font:$(font),size:$(fontsize),'.. + 'fore:$(color.black),back:$(color.white)' +property['style.linenumber'] = 'back:#C0C0C0' +property['style.bracelight'] = 'fore:#0000FF,bold' +property['style.bracebad'] = 'fore:#FF0000,bold' +property['style.controlchar'] = '' +property['style.indentguide'] = 'fore:#C0C0C0,back:$(color.white)' +property['style.calltip'] = 'fore:$(color.white),back:#444444' +property['style.folddisplaytext'] = '' -- Token styles. -property['style.nothing'] = '' property['style.class'] = 'fore:$(color.black),bold' property['style.comment'] = 'fore:$(color.green)' property['style.constant'] = 'fore:$(color.teal),bold' -property['style.definition'] = 'fore:$(color.black),bold' +property['style.embedded'] = 'fore:$(color.blue)' property['style.error'] = 'fore:$(color.red)' property['style.function'] = 'fore:$(color.black),bold' +property['style.identifier'] = '' property['style.keyword'] = 'fore:$(color.blue),bold' property['style.label'] = 'fore:$(color.teal),bold' property['style.number'] = 'fore:$(color.teal)' property['style.operator'] = 'fore:$(color.black),bold' +property['style.preprocessor'] = 'fore:$(color.yellow)' property['style.regex'] = '$(style.string)' property['style.string'] = 'fore:$(color.purple)' -property['style.preprocessor'] = 'fore:$(color.yellow)' -property['style.tag'] = 'fore:$(color.teal)' property['style.type'] = 'fore:$(color.blue)' property['style.variable'] = 'fore:$(color.black)' property['style.whitespace'] = '' -property['style.embedded'] = 'fore:$(color.blue)' -property['style.identifier'] = '$(style.nothing)' - --- Predefined styles. -property['style.linenumber'] = 'back:#C0C0C0' -property['style.bracelight'] = 'fore:#0000FF,bold' -property['style.bracebad'] = 'fore:#FF0000,bold' -property['style.controlchar'] = '$(style.nothing)' -property['style.indentguide'] = 'fore:#C0C0C0,back:$(color.white)' -property['style.calltip'] = 'fore:$(color.white),back:#444444' diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/toml.lua b/dep/scintilla/scintilla-3.10.6/lexlua/toml.lua new file mode 100644 index 00000000..b17474c9 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/toml.lua @@ -0,0 +1,53 @@ +-- Copyright 2015-2019 Alejandro Baez (https://keybase.io/baez). See License.txt. +-- TOML LPeg lexer. + +local lexer = require("lexer") +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('toml', {fold_by_indentation = true}) + +-- Whitespace +lex:add_rule('indent', #lexer.starts_line(S(' \t')) * + (token(lexer.WHITESPACE, ' ') + + token('indent_error', '\t'))^1) +lex:add_rule('whitespace', token(lexer.WHITESPACE, S(' \t')^1 + + lexer.newline^1)) +lex:add_style('indent_error', 'back:%(color.red)') + +-- kewwords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[true false]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"'))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('#=+-,.{}[]()'))) + +-- Datetime. +lex:add_rule('datetime', + token('timestamp', + lexer.digit * lexer.digit * lexer.digit * lexer.digit * -- yr + '-' * lexer.digit * lexer.digit^-1 * -- month + '-' * lexer.digit * lexer.digit^-1 * -- day + ((S(' \t')^1 + S('tT'))^-1 * -- separator + lexer.digit * lexer.digit^-1 * -- hour + ':' * lexer.digit * lexer.digit * -- minute + ':' * lexer.digit * lexer.digit * -- second + ('.' * lexer.digit^0)^-1 * -- fraction + ('Z' + -- timezone + S(' \t')^0 * S('-+') * lexer.digit * lexer.digit^-1 * + (':' * lexer.digit * lexer.digit)^-1)^-1)^-1)) +lex:add_style('timestamp', lexer.STYLE_NUMBER) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/vala.lua b/dep/scintilla/scintilla-3.10.6/lexlua/vala.lua new file mode 100644 index 00000000..8498592c --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/vala.lua @@ -0,0 +1,60 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Vala LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('vala') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + class delegate enum errordomain interface namespace signal struct using + -- Modifiers. + abstract const dynamic extern inline out override private protected public ref + static virtual volatile weak + -- Other. + as base break case catch construct continue default delete do else ensures + finally for foreach get if in is lock new requires return set sizeof switch + this throw throws try typeof value var void while + -- Etc. + null true false +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + bool char double float int int8 int16 int32 int64 long short size_t ssize_t + string uchar uint uint8 uint16 uint32 uint64 ulong unichar ushort +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +local sq_str = lexer.delimited_range("'", true) +local dq_str = lexer.delimited_range('"', true) +local tq_str = '"""' * (lexer.any - '"""')^0 * P('"""')^-1 +local ml_str = '@' * lexer.delimited_range('"', false, true) +lex:add_rule('string', token(lexer.STRING, tq_str + sq_str + dq_str + ml_str)) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, (lexer.float + lexer.integer) * + S('uUlLfFdDmM')^-1)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/vb.lua b/dep/scintilla/scintilla-3.10.6/lexlua/vb.lua new file mode 100644 index 00000000..332071dc --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/vb.lua @@ -0,0 +1,53 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- VisualBasic LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('vb') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match([[ + -- Control. + If Then Else ElseIf While Wend For To Each In Step Case Select Return Continue + Do Until Loop Next With Exit + -- Operators. + Mod And Not Or Xor Is + -- Storage types. + Call Class Const Dim ReDim Preserve Function Sub Property End Set Let Get New + Randomize Option Explicit On Error Execute + -- Storage modifiers. + Private Public Default + -- Constants. + Empty False Nothing Null True +]], true))) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match([[ + Boolean Byte Char Date Decimal Double Long Object Short Single String +]], true))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, + (P("'") + word_match([[rem]], true)) * + lexer.nonnewline^0)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, + lexer.delimited_range('"', true, true))) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, (lexer.float + lexer.integer) * + S('LlUuFf')^-2)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('=><+-*^&:.,_()'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/vbscript.lua b/dep/scintilla/scintilla-3.10.6/lexlua/vbscript.lua new file mode 100644 index 00000000..e6f9d886 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/vbscript.lua @@ -0,0 +1,53 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- VisualBasic LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('vbscript') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match([[ + -- Control. + If Then Else ElseIf While Wend For To Each In Step Case Select Return Continue + Do Until Loop Next With Exit + -- Operators. + Mod And Not Or Xor Is + -- Storage types. + Call Class Const Dim ReDim Preserve Function Sub Property End Set Let Get New + Randomize Option Explicit On Error Execute + -- Storage modifiers. + Private Public Default + -- Constants. + Empty False Nothing Null True +]], true))) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match([[ + Boolean Byte Char Date Decimal Double Long Object Short Single String +]], true))) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, + (P("'") + word_match([[rem]], true)) * + lexer.nonnewline^0)) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, + lexer.delimited_range('"', true, true))) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, (lexer.float + lexer.integer) * + S('LlUuFf')^-2)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('=><+-*^&:.,_()'))) + +return lex diff --git a/dep/scintillua/scintillua-3.6.0/lexers/vcard.lua b/dep/scintilla/scintilla-3.10.6/lexlua/vcard.lua similarity index 55% rename from dep/scintillua/scintillua-3.6.0/lexers/vcard.lua rename to dep/scintilla/scintilla-3.10.6/lexlua/vcard.lua index 20574514..99624f7d 100644 --- a/dep/scintillua/scintillua-3.6.0/lexers/vcard.lua +++ b/dep/scintilla/scintilla-3.10.6/lexlua/vcard.lua @@ -1,22 +1,22 @@ --- Copyright (c) 2015 Piotr Orzechowski [drzewo.org]. See LICENSE. +-- Copyright (c) 2015-2019 Piotr Orzechowski [drzewo.org]. See License.txt. -- vCard 2.1, 3.0 and 4.0 LPeg lexer. -local l = require('lexer') -local token, word_match = l.token, l.word_match +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match local P, R, S = lpeg.P, lpeg.R, lpeg.S local M = {_NAME = 'vcard'} -- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) +local ws = token(lexer.WHITESPACE, lexer.space^1) -- Required properties. -local required_property = token(l.KEYWORD, word_match({ +local required_property = token(lexer.KEYWORD, word_match({ 'BEGIN', 'END', 'FN', 'N' --[[ Not required in v4.0. ]], 'VERSION' }, nil, true)) * #P(':') -- Supported properties. -local supported_property = token(l.TYPE, word_match({ +local supported_property = token(lexer.TYPE, word_match({ 'ADR', 'AGENT' --[[ Not supported in v4.0. ]], 'ANNIVERSARY' --[[ Supported in v4.0 only. ]], 'BDAY', 'CALADRURI' --[[ Supported in v4.0 only. ]], @@ -40,38 +40,42 @@ local supported_property = token(l.TYPE, word_match({ 'TITLE', 'TZ', 'UID', 'URL', 'XML' --[[ Supported in v4.0 only. ]] }, nil, true)) * #S(':;') -local identifier = l.alpha^1 * l.digit^0 * (P('-') * l.alnum^1)^0 +local identifier = lexer.alpha^1 * lexer.digit^0 * (P('-') * lexer.alnum^1)^0 -- Extension. -local extension = token(l.TYPE, - l.starts_line(S('xX') * P('-') * identifier * #S(':;'))) +local extension = token(lexer.TYPE, lexer.starts_line(S('xX') * P('-') * + identifier * #S(':;'))) -- Parameter. -local parameter = token(l.IDENTIFIER, l.starts_line(identifier * #S(':='))) + - token(l.STRING, identifier) * #S(':=') +local parameter = token(lexer.IDENTIFIER, + lexer.starts_line(identifier * #S(':='))) + + token(lexer.STRING, identifier) * #S(':=') -- Operators. -local operator = token(l.OPERATOR, S('.:;=')) +local operator = token(lexer.OPERATOR, S('.:;=')) -- Group and property. -local group_sequence = token(l.CONSTANT, l.starts_line(identifier)) * - token(l.OPERATOR, P('.')) * +local group_sequence = token(lexer.CONSTANT, lexer.starts_line(identifier)) * + token(lexer.OPERATOR, P('.')) * (required_property + supported_property + - l.token(l.TYPE, S('xX') * P('-') * identifier) * + lexer.token(lexer.TYPE, S('xX') * P('-') * identifier) * #S(':;')) -- Begin vCard, end vCard. -local begin_sequence = token(l.KEYWORD, P('BEGIN')) * - token(l.OPERATOR, P(':')) * token(l.COMMENT, P('VCARD')) -local end_sequence = token(l.KEYWORD, P('END')) * token(l.OPERATOR, P(':')) * - token(l.COMMENT, P('VCARD')) +local begin_sequence = token(lexer.KEYWORD, P('BEGIN')) * + token(lexer.OPERATOR, P(':')) * + token(lexer.COMMENT, P('VCARD')) +local end_sequence = token(lexer.KEYWORD, P('END')) * + token(lexer.OPERATOR, P(':')) * + token(lexer.COMMENT, P('VCARD')) -- vCard version (in v3.0 and v4.0 must appear immediately after BEGIN:VCARD). -local version_sequence = token(l.KEYWORD, P('VERSION')) * - token(l.OPERATOR, P(':')) * - token(l.CONSTANT, l.digit^1 * (P('.') * l.digit^1)^-1) +local version_sequence = token(lexer.KEYWORD, P('VERSION')) * + token(lexer.OPERATOR, P(':')) * + token(lexer.CONSTANT, lexer.digit^1 * + (P('.') * lexer.digit^1)^-1) -- Data. -local data = token(l.IDENTIFIER, l.any) +local data = token(lexer.IDENTIFIER, lexer.any) -- Rules. M._rules = { @@ -91,7 +95,7 @@ M._rules = { -- Folding. M._foldsymbols = { _patterns = {'BEGIN', 'END'}, - [l.KEYWORD] = {['BEGIN'] = 1, ['END'] = -1} + [lexer.KEYWORD] = {['BEGIN'] = 1, ['END'] = -1} } return M diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/verilog.lua b/dep/scintilla/scintilla-3.10.6/lexlua/verilog.lua new file mode 100644 index 00000000..42619522 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/verilog.lua @@ -0,0 +1,86 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- Verilog LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('verilog') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + always assign begin case casex casez default deassign disable else end endcase + endfunction endgenerate endmodule endprimitive endspecify endtable endtask for + force forever fork function generate if initial join macromodule module + negedge posedge primitive repeat release specify table task wait while + -- Compiler directives. + `include `define `undef `ifdef `ifndef `else `endif `timescale `resetall + `signed `unsigned `celldefine `endcelldefine `default_nettype + `unconnected_drive `nounconnected_drive `protect `endprotect `protected + `endprotected `remove_gatename `noremove_gatename `remove_netname + `noremove_netname `expand_vectornets `noexpand_vectornets + `autoexpand_vectornets + -- Signal strengths. + strong0 strong1 pull0 pull1 weak0 weak1 highz0 highz1 small medium large +]])) + +-- Function. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + $stop $finish $time $stime $realtime $settrace $cleartrace $showscopes + $showvars $monitoron $monitoroff $random $printtimescale $timeformat $display + -- Built-in primitives. + and nand or nor xor xnor buf bufif0 bufif1 not notif0 notif1 nmos pmos cmos + rnmos rpmos rcmos tran tranif0 tranif1 rtran rtranif0 rtranif1 pullup pulldown +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + integer reg time realtime defparam parameter event wire wand wor tri triand + trior tri0 tri1 trireg vectored scalared input output inout supply0 supply1 +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"'))) + +-- Comments. +local line_comment = '//' * lexer.nonnewline^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +local bin_suffix = S('bB') * S('01_xXzZ')^1 +local oct_suffix = S('oO') * S('01234567_xXzZ')^1 +local dec_suffix = S('dD') * S('0123456789_xXzZ')^1 +local hex_suffix = S('hH') * S('0123456789abcdefABCDEF_xXzZ')^1 +lex:add_rule('number', token(lexer.NUMBER, (lexer.digit + '_')^1 + + "'" * (bin_suffix + oct_suffix + + dec_suffix + hex_suffix))) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('=~+-/*<>%&|^~,:;()[]{}'))) + +-- Fold points. +lex:add_fold_point(lexer.KEYWORD, 'case', 'endcase') +lex:add_fold_point(lexer.KEYWORD, 'casex', 'endcase') +lex:add_fold_point(lexer.KEYWORD, 'casez', 'endcase') +lex:add_fold_point(lexer.KEYWORD, 'function', 'endfunction') +lex:add_fold_point(lexer.KEYWORD, 'fork', 'join') +lex:add_fold_point(lexer.KEYWORD, 'table', 'endtable') +lex:add_fold_point(lexer.KEYWORD, 'task', 'endtask') +lex:add_fold_point(lexer.KEYWORD, 'generate', 'endgenerate') +lex:add_fold_point(lexer.KEYWORD, 'specify', 'endspecify') +lex:add_fold_point(lexer.KEYWORD, 'primitive', 'endprimitive') +lex:add_fold_point(lexer.KEYWORD, 'module', 'endmodule') +lex:add_fold_point(lexer.KEYWORD, 'begin', 'end') +lex:add_fold_point(lexer.OPERATOR, '(', ')') +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/vhdl.lua b/dep/scintilla/scintilla-3.10.6/lexlua/vhdl.lua new file mode 100644 index 00000000..d4695bd1 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/vhdl.lua @@ -0,0 +1,69 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- VHDL LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('vhdl') + +-- Whitespace. +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + access after alias all architecture array assert attribute begin block body + buffer bus case component configuration constant disconnect downto else elsif + end entity exit file for function generate generic group guarded if impure in + inertial inout is label library linkage literal loop map new next null of on + open others out package port postponed procedure process pure range record + register reject report return select severity signal shared subtype then to + transport type unaffected units until use variable wait when while with + note warning error failure + and nand or nor xor xnor rol ror sla sll sra srl mod rem + abs not false true +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, word_match[[ + rising_edge shift_left shift_right rotate_left rotate_right resize std_match + to_integer to_unsigned to_signed unsigned signed to_bit to_bitvector + to_stdulogic to_stdlogicvector to_stdulogicvector +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + bit bit_vector character boolean integer real time string severity_level + positive natural signed unsigned line text std_logic std_logic_vector + std_ulogic std_ulogic_vector qsim_state qsim_state_vector qsim_12state + qsim_12state_vector qsim_strength mux_bit mux_vectory reg_bit reg_vector + wor_bit wor_vector +]])) + +-- Constants. +lex:add_rule('constant', token(lexer.CONSTANT, word_match[[ + EVENT BASE LEFT RIGHT LOW HIGH ASCENDING IMAGE VALUE POS VAL SUCC VAL POS PRED + VAL POS LEFTOF RIGHTOF LEFT RIGHT LOW HIGH RANGE REVERSE LENGTH ASCENDING + DELAYED STABLE QUIET TRANSACTION EVENT ACTIVE LAST LAST LAST DRIVING DRIVING + SIMPLE INSTANCE PATH +]])) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, (lexer.alpha + "'") * + (lexer.alnum + S("_'"))^1)) + +-- Strings. +local sq_str = lexer.delimited_range("'", true, true) +local dq_str = lexer.delimited_range('"', true) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str)) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '--' * lexer.nonnewline^0)) + +-- Numbers. +lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('=/!:;<>+-/*%&|^~()'))) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/wsf.lua b/dep/scintilla/scintilla-3.10.6/lexlua/wsf.lua new file mode 100644 index 00000000..d5c5f5e4 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/wsf.lua @@ -0,0 +1,101 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- WSF LPeg lexer (based on XML). +-- Contributed by Jeff Stone. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V + +local lex = lexer.new('wsf') + +-- Whitespace. +local ws = token(lexer.WHITESPACE, lexer.space^1) +lex:add_rule('whitespace', ws) + +-- Comments. +lex:add_rule('comment', token(lexer.COMMENT, '')^0 * + P('-->')^-1)) + +local alpha = R('az', 'AZ', '\127\255') +local word_char = lexer.alnum + S('_-:.??') +local identifier = (alpha + S('_-:.??')) * word_char^0 + +-- Elements. +local element = token('element', '<' * P('/')^-1 * identifier) +lex:add_rule('element', element) +lex:add_style('element', lexer.STYLE_KEYWORD) + +-- Closing tags. +local tag_close = token('element', P('/')^-1 * '>') +lex:add_rule('tag_close', tag_close) + +-- Attributes. +local attribute = token('attribute', identifier) * #(lexer.space^0 * '=') +lex:add_rule('attribute', attribute) +lex:add_style('attribute', lexer.STYLE_TYPE) + +local in_tag = P(function(input, index) + local before = input:sub(1, index - 1) + local s, e = before:find('<[^>]-$'), before:find('>[^<]-$') + if s and e then return s > e and index or nil end + if s then return index end + return input:find('^[^<]->', index) and index or nil +end) + +-- Equals. +local equals = token(lexer.OPERATOR, '=') * in_tag +lex:add_rule('equals', equals) + +-- Strings. +local string = #S('\'"') * lexer.last_char_includes('=') * + token(lexer.STRING, lexer.delimited_range("'", false, true) + + lexer.delimited_range('"', false, true)) +lex:add_rule('string', string) + +-- Numbers. +lex:add_rule('number', #lexer.digit * lexer.last_char_includes('=') * + token(lexer.NUMBER, lexer.digit^1 * P('%')^-1) * in_tag) + +-- Entities. +lex:add_rule('entity', token('entity', '&' * word_match[[ + lt gt amp apos quot +]] * ';')) +lex:add_style('entity', lexer.STYLE_OPERATOR) + +-- Fold points. +local function disambiguate_lt(text, pos, line, s) + return not line:find('^', -1) +lex:add_fold_point(lexer.COMMENT, '') + +-- Finally, add JavaScript and VBScript as embedded languages + +-- Tags that start embedded languages. +local embed_start_tag = element * + (ws^1 * attribute * ws^0 * equals * ws^0 * string)^0 * + ws^0 * tag_close +local embed_end_tag = element * tag_close + +-- Embedded JavaScript. +local js = lexer.load('javascript') +local js_start_rule = #(P('')) * embed_start_tag -- +lex:embed(js, js_start_rule, js_end_rule) + +-- Embedded VBScript. +local vbs = lexer.load('vbscript') +local vbs_start_rule = #(P('')) * embed_start_tag -- +lex:embed(vbs, vbs_start_rule, vbs_end_rule) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/xml.lua b/dep/scintilla/scintilla-3.10.6/lexlua/xml.lua new file mode 100644 index 00000000..9e2119b0 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/xml.lua @@ -0,0 +1,88 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- XML LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V + +local lex = lexer.new('xml') + +-- Whitespace. +local ws = token(lexer.WHITESPACE, lexer.space^1) +lex:add_rule('whitespace', ws) + +-- Comments and CDATA. +lex:add_rule('comment', token(lexer.COMMENT, '')^0 * + P('-->')^-1)) +lex:add_rule('cdata', token('cdata', '')^0 * + P(']]>')^-1)) +lex:add_style('cdata', lexer.STYLE_COMMENT) + +local alpha = R('az', 'AZ', '\127\255') +local word_char = lexer.alnum + S('_-:.??') +local identifier = (alpha + S('_-:.??')) * word_char^0 + +-- Doctypes and other markup tags. +lex:add_rule('doctype', token('doctype', P(''))^0 * token('doctype', '>')) +lex:add_style('doctype', lexer.STYLE_COMMENT) + +-- Processing instructions. +lex:add_rule('proc_insn', token('proc_insn', P(''))^0 * + P('?>')^-1)) +lex:add_style('proc_insn', lexer.STYLE_COMMENT) + +-- Elements. +local namespace = token(lexer.OPERATOR, ':') * token('namespace', identifier) +lex:add_rule('element', token('element', '<' * P('/')^-1 * identifier) * + namespace^-1) +lex:add_style('element', lexer.STYLE_KEYWORD) +lex:add_style('namespace', lexer.STYLE_CLASS) + +-- Closing tags. +lex:add_rule('close_tag', token('element', P('/')^-1 * '>')) + +-- Attributes. +lex:add_rule('attribute', token('attribute', identifier) * namespace^-1 * + #(lexer.space^0 * '=')) +lex:add_style('attribute', lexer.STYLE_TYPE) + +-- TODO: performance is terrible on large files. +local in_tag = P(function(input, index) + local before = input:sub(1, index - 1) + local s, e = before:find('<[^>]-$'), before:find('>[^<]-$') + if s and e then return s > e and index or nil end + if s then return index end + return input:find('^[^<]->', index) and index or nil +end) + +-- Equals. +--lex:add_rule('equal', token(lexer.OPERATOR, '=')) -- * in_tag + +-- Strings. +lex:add_rule('string', #S('\'"') * lexer.last_char_includes('=') * + token(lexer.STRING, + lexer.delimited_range("'", false, true) + + lexer.delimited_range('"', false, true))) + +-- Numbers. +lex:add_rule('number', #lexer.digit * lexer.last_char_includes('=') * + token(lexer.NUMBER, lexer.digit^1 * P('%')^-1))--*in_tag) + +-- Entities. +lex:add_rule('entity', token('entity', '&' * word_match[[ + lt gt amp apos quot +]] * ';')) +lex:add_style('entity', lexer.STYLE_OPERATOR) + +-- Fold Points. +local function disambiguate_lt(text, pos, line, s) + return not line:find('^', -1) +lex:add_fold_point(lexer.COMMENT, '') +lex:add_fold_point('cdata', '') + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/xtend.lua b/dep/scintilla/scintilla-3.10.6/lexlua/xtend.lua new file mode 100644 index 00000000..3f6247aa --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/xtend.lua @@ -0,0 +1,90 @@ +-- Copyright (c) 2014-2019 Piotr Orzechowski [drzewo.org]. See License.txt. +-- Xtend LPeg lexer. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local lex = lexer.new('xtend') + +-- Whitespace. +local ws = token(lexer.WHITESPACE, lexer.space^1) +lex:add_rule('whitespace', ws) + +-- Classes. +lex:add_rule('class', token(lexer.KEYWORD, P('class')) * ws^1 * + token(lexer.CLASS, lexer.word)) + +-- Keywords. +lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ + -- General. + abstract annotation as case catch class create def default dispatch do else + enum extends extension final finally for if implements import interface + instanceof it new override package private protected public return self static + super switch synchronized this throw throws try typeof val var while + -- Templates. + -- AFTER BEFORE ENDFOR ENDIF FOR IF SEPARATOR + -- Literals. + true false null +]])) + +-- Types. +lex:add_rule('type', token(lexer.TYPE, word_match[[ + boolean byte char double float int long short void + Boolean Byte Character Double Float Integer Long Short String +]])) + +-- Functions. +lex:add_rule('function', token(lexer.FUNCTION, lexer.word) * #P('(')) + +-- Identifiers. +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) + +-- Templates. +lex:add_rule('template', token('template', "'''" * (lexer.any - P("'''"))^0 * + P("'''")^-1)) +lex:add_style('template', lexer.STYLE_EMBEDDED) + +-- Strings. +lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + + lexer.delimited_range('"', true))) + +-- Comments. +local line_comment = '//' * lexer.nonnewline_esc^0 +local block_comment = '/*' * (lexer.any - '*/')^0 * P('*/')^-1 +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) + +-- Numbers. +local small_suff = S('lL') +local med_suff = S('bB') * S('iI') +local large_suff = S('dD') + S('fF') + S('bB') * S('dD') +local exp = S('eE') * lexer.digit^1 + +local dec_inf = ('_' * lexer.digit^1)^0 +local hex_inf = ('_' * lexer.xdigit^1)^0 +local float_pref = lexer.digit^1 * '.' * lexer.digit^1 +local float_suff = exp^-1 * med_suff^-1 * large_suff^-1 + +local dec = lexer.digit * dec_inf * (small_suff^-1 + float_suff) +local hex = lexer.hex_num * hex_inf * P('#' * (small_suff + med_suff))^-1 +local float = float_pref * dec_inf * float_suff + +lex:add_rule('number', token(lexer.NUMBER, float + hex + dec)) + +-- Annotations. +lex:add_rule('annotation', token('annotation', '@' * lexer.word)) +lex:add_style('annotation', lexer.STYLE_PREPROCESSOR) + +-- Operators. +lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}#'))) + +-- Error. +lex:add_rule('error', token(lexer.ERROR, lexer.any)) + +-- Fold points. +lex:add_fold_point(lexer.OPERATOR, '{', '}') +lex:add_fold_point(lexer.COMMENT, '/*', '*/') +lex:add_fold_point(lexer.COMMENT, '//', lexer.fold_line_comments('//')) +lex:add_fold_point(lexer.KEYWORD, 'import', lexer.fold_line_comments('import')) + +return lex diff --git a/dep/scintilla/scintilla-3.10.6/lexlua/yaml.lua b/dep/scintilla/scintilla-3.10.6/lexlua/yaml.lua new file mode 100644 index 00000000..0b0bd983 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lexlua/yaml.lua @@ -0,0 +1,121 @@ +-- Copyright 2006-2019 Mitchell mitchell.att.foicica.com. See License.txt. +-- YAML LPeg lexer. +-- It does not keep track of indentation perfectly. + +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local M = {_NAME = 'yaml'} + +-- Whitespace. +local indent = #lexer.starts_line(S(' \t')) * + (token(lexer.WHITESPACE, ' ') + token('indent_error', '\t'))^1 +local ws = token(lexer.WHITESPACE, S(' \t')^1 + lexer.newline^1) + +-- Comments. +local comment = token(lexer.COMMENT, '#' * lexer.nonnewline^0) + +-- Strings. +local string = token(lexer.STRING, lexer.delimited_range("'") + + lexer.delimited_range('"')) + +-- Numbers. +local integer = lexer.dec_num + lexer.hex_num + '0' * S('oO') * R('07')^1 +local special_num = '.' * word_match({'inf', 'nan'}, nil, true) +local number = token(lexer.NUMBER, special_num + lexer.float + integer) + +-- Timestamps. +local ts = token('timestamp', + lexer.digit * lexer.digit * lexer.digit * lexer.digit * -- year + '-' * lexer.digit * lexer.digit^-1 * -- month + '-' * lexer.digit * lexer.digit^-1 * -- day + ((S(' \t')^1 + S('tT'))^-1 * -- separator + lexer.digit * lexer.digit^-1 * -- hour + ':' * lexer.digit * lexer.digit * -- minute + ':' * lexer.digit * lexer.digit * -- second + ('.' * lexer.digit^0)^-1 * -- fraction + ('Z' + -- timezone + S(' \t')^0 * S('-+') * lexer.digit * lexer.digit^-1 * + (':' * lexer.digit * lexer.digit)^-1)^-1)^-1) + +-- Constants. +local constant = token(lexer.CONSTANT, + word_match({'null', 'true', 'false'}, nil, true)) + +-- Types. +local type = token(lexer.TYPE, '!!' * word_match({ + -- Collection types. + 'map', 'omap', 'pairs', 'set', 'seq', + -- Scalar types. + 'binary', 'bool', 'float', 'int', 'merge', 'null', 'str', 'timestamp', + 'value', 'yaml' +}, nil, true) + '!' * lexer.delimited_range('<>')) + +-- Document boundaries. +local doc_bounds = token('document', lexer.starts_line(P('---') + '...')) + +-- Directives +local directive = token('directive', lexer.starts_line('%') * + lexer.nonnewline^1) + +local word = (lexer.alpha + '-' * -lexer.space) * (lexer.alnum + '-')^0 + +-- Keys and literals. +local colon = S(' \t')^0 * ':' * (lexer.space + -1) +local key = token(lexer.KEYWORD, + #word * (lexer.nonnewline - colon)^1 * #colon * + P(function(input, index) + local line = input:sub(1, index - 1):match('[^\r\n]+$') + return not line:find('[%w-]+:') and index + end)) +local value = #word * (lexer.nonnewline - lexer.space^0 * S(',]}'))^1 +local block = S('|>') * S('+-')^-1 * (lexer.newline + -1) * + function(input, index) + local rest = input:sub(index) + local level = #rest:match('^( *)') + for pos, indent, line in rest:gmatch('() *()([^\r\n]+)') do + if indent - pos < level and line ~= ' ' or + level == 0 and pos > 1 then + return index + pos - 1 + end + end + return #input + 1 + end +local literal = token('literal', value + block) + +-- Indicators. +local anchor = token(lexer.LABEL, '&' * word) +local alias = token(lexer.VARIABLE, '*' * word) +local tag = token('tag', '!' * word * P('!')^-1) +local reserved = token(lexer.ERROR, S('@`') * word) +local indicator_chars = token(lexer.OPERATOR, S('-?:,[]{}!')) + +M._rules = { + {'indent', indent}, + {'whitespace', ws}, + {'comment', comment}, + {'doc_bounds', doc_bounds}, + {'key', key}, + {'string', string}, + {'literal', literal}, + {'timestamp', ts}, + {'number', number}, + {'constant', constant}, + {'type', type}, + {'indicator', tag + indicator_chars + alias + anchor + reserved}, + {'directive', directive}, +} + +M._tokenstyles = { + indent_error = 'back:%(color.red)', + document = lexer.STYLE_CONSTANT, + literal = lexer.STYLE_DEFAULT, + timestamp = lexer.STYLE_NUMBER, + tag = lexer.STYLE_CLASS, + directive = lexer.STYLE_PREPROCESSOR, +} + +M._FOLDBYINDENTATION = true + +return M diff --git a/dep/scintillua/scintillua-3.6.0/LICENSE b/dep/scintilla/scintilla-3.10.6/lua/LICENSE similarity index 58% rename from dep/scintillua/scintillua-3.6.0/LICENSE rename to dep/scintilla/scintilla-3.10.6/lua/LICENSE index 13cd3113..4212dee6 100644 --- a/dep/scintillua/scintillua-3.6.0/LICENSE +++ b/dep/scintilla/scintilla-3.10.6/lua/LICENSE @@ -1,12 +1,10 @@ -The MIT License +Copyright © 1994–2017 Lua.org, PUC-Rio. -Copyright (c) 2007-2015 Mitchell - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in @@ -14,8 +12,8 @@ all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/dep/scintilla/scintilla-3.10.6/lua/README b/dep/scintilla/scintilla-3.10.6/lua/README new file mode 100644 index 00000000..1238641b --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/README @@ -0,0 +1,7 @@ + +This is Lua 5.3.4, released on 12 Jan 2017. + +For further information about Lua, see doc/manual.html. + +Scintilla only uses Lua with its LPeg lexer, which is disabled by default. +In order to enable it, see ../doc/LPegLexer.html. diff --git a/dep/scintilla/scintilla-3.10.6/lua/doc/lua.css b/dep/scintilla/scintilla-3.10.6/lua/doc/lua.css new file mode 100644 index 00000000..5bedf7eb --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/doc/lua.css @@ -0,0 +1,164 @@ +html { + background-color: #F8F8F8 ; +} + +body { + background-color: #FFFFFF ; + color: #000000 ; + font-family: Helvetica, Arial, sans-serif ; + text-align: justify ; + line-height: 1.25 ; + margin: 16px auto ; + padding: 32px ; + border: solid #a0a0a0 1px ; + border-radius: 20px ; + max-width: 70em ; + width: 90% ; +} + +h1, h2, h3, h4 { + color: #000080 ; + font-family: Verdana, Geneva, sans-serif ; + font-weight: normal ; + font-style: normal ; + text-align: left ; +} + +h1 { + font-size: 28pt ; +} + +h1 img { + vertical-align: text-bottom ; +} + +h2:before { + content: "\2756" ; + padding-right: 0.5em ; +} + +a { + text-decoration: none ; +} + +a:link { + color: #000080 ; +} + +a:link:hover, a:visited:hover { + background-color: #D0D0FF ; + color: #000080 ; + border-radius: 4px ; +} + +a:link:active, a:visited:active { + color: #FF0000 ; +} + +div.menubar { + padding-bottom: 0.5em ; +} + +p.menubar { + margin-left: 2.5em ; +} + +.menubar a:hover { + margin: -3px -3px -3px -3px ; + padding: 3px 3px 3px 3px ; + border-radius: 4px ; +} + +:target { + background-color: #F0F0F0 ; + margin: -8px ; + padding: 8px ; + border-radius: 8px ; + outline: none ; +} + +hr { + display: none ; +} + +table hr { + background-color: #a0a0a0 ; + color: #a0a0a0 ; + border: 0 ; + height: 1px ; + display: block ; +} + +.footer { + color: gray ; + font-size: x-small ; + text-transform: lowercase ; +} + +input[type=text] { + border: solid #a0a0a0 2px ; + border-radius: 2em ; + background-image: url('images/search.png') ; + background-repeat: no-repeat ; + background-position: 4px center ; + padding-left: 20px ; + height: 2em ; +} + +pre.session { + background-color: #F8F8F8 ; + padding: 1em ; + border-radius: 8px ; +} + +td.gutter { + width: 4% ; +} + +table.columns { + border: none ; + border-spacing: 0 ; + border-collapse: collapse ; +} + +table.columns td { + vertical-align: top ; + padding: 0 ; + padding-bottom: 1em ; + text-align: justify ; + line-height: 1.25 ; +} + +p.logos a:link:hover, p.logos a:visited:hover { + background-color: inherit ; +} + +table.book { + border: none ; + border-spacing: 0 ; + border-collapse: collapse ; +} + +table.book td { + padding: 0 ; + vertical-align: top ; +} + +table.book td.cover { + padding-right: 1em ; +} + +table.book img { + border: solid #000080 1px ; +} + +table.book span { + font-size: small ; + text-align: left ; + display: block ; + margin-top: 0.25em ; +} + +img { + background-color: white ; +} diff --git a/dep/scintilla/scintilla-3.10.6/lua/doc/manual.css b/dep/scintilla/scintilla-3.10.6/lua/doc/manual.css new file mode 100644 index 00000000..aa0e677d --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/doc/manual.css @@ -0,0 +1,21 @@ +h3 code { + font-family: inherit ; + font-size: inherit ; +} + +pre, code { + font-size: 12pt ; +} + +span.apii { + color: gray ; + float: right ; + font-family: inherit ; + font-style: normal ; + font-size: small ; +} + +h2:before { + content: "" ; + padding-right: 0em ; +} diff --git a/dep/scintilla/scintilla-3.10.6/lua/doc/manual.html b/dep/scintilla/scintilla-3.10.6/lua/doc/manual.html new file mode 100644 index 00000000..3126b5d6 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/doc/manual.html @@ -0,0 +1,10985 @@ + + + +Lua 5.3 Reference Manual + + + + + + + +

    +Lua +Lua 5.3 Reference Manual +

    + +

    +by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes + +

    + +Copyright © 2015–2017 Lua.org, PUC-Rio. +Freely available under the terms of the +Lua license. + + +

    + + +

    + + + + + + +

    1 – Introduction

    + +

    +Lua is a powerful, efficient, lightweight, embeddable scripting language. +It supports procedural programming, +object-oriented programming, functional programming, +data-driven programming, and data description. + + +

    +Lua combines simple procedural syntax with powerful data description +constructs based on associative arrays and extensible semantics. +Lua is dynamically typed, +runs by interpreting bytecode with a register-based +virtual machine, +and has automatic memory management with +incremental garbage collection, +making it ideal for configuration, scripting, +and rapid prototyping. + + +

    +Lua is implemented as a library, written in clean C, +the common subset of Standard C and C++. +The Lua distribution includes a host program called lua, +which uses the Lua library to offer a complete, +standalone Lua interpreter, +for interactive or batch use. +Lua is intended to be used both as a powerful, lightweight, +embeddable scripting language for any program that needs one, +and as a powerful but lightweight and efficient stand-alone language. + + +

    +As an extension language, Lua has no notion of a "main" program: +it works embedded in a host client, +called the embedding program or simply the host. +(Frequently, this host is the stand-alone lua program.) +The host program can invoke functions to execute a piece of Lua code, +can write and read Lua variables, +and can register C functions to be called by Lua code. +Through the use of C functions, Lua can be augmented to cope with +a wide range of different domains, +thus creating customized programming languages sharing a syntactical framework. + + +

    +Lua is free software, +and is provided as usual with no guarantees, +as stated in its license. +The implementation described in this manual is available +at Lua's official web site, www.lua.org. + + +

    +Like any other reference manual, +this document is dry in places. +For a discussion of the decisions behind the design of Lua, +see the technical papers available at Lua's web site. +For a detailed introduction to programming in Lua, +see Roberto's book, Programming in Lua. + + + +

    2 – Basic Concepts

    + +

    +This section describes the basic concepts of the language. + + + +

    2.1 – Values and Types

    + +

    +Lua is a dynamically typed language. +This means that +variables do not have types; only values do. +There are no type definitions in the language. +All values carry their own type. + + +

    +All values in Lua are first-class values. +This means that all values can be stored in variables, +passed as arguments to other functions, and returned as results. + + +

    +There are eight basic types in Lua: +nil, boolean, number, +string, function, userdata, +thread, and table. +The type nil has one single value, nil, +whose main property is to be different from any other value; +it usually represents the absence of a useful value. +The type boolean has two values, false and true. +Both nil and false make a condition false; +any other value makes it true. +The type number represents both +integer numbers and real (floating-point) numbers. +The type string represents immutable sequences of bytes. + +Lua is 8-bit clean: +strings can contain any 8-bit value, +including embedded zeros ('\0'). +Lua is also encoding-agnostic; +it makes no assumptions about the contents of a string. + + +

    +The type number uses two internal representations, +or two subtypes, +one called integer and the other called float. +Lua has explicit rules about when each representation is used, +but it also converts between them automatically as needed (see §3.4.3). +Therefore, +the programmer may choose to mostly ignore the difference +between integers and floats +or to assume complete control over the representation of each number. +Standard Lua uses 64-bit integers and double-precision (64-bit) floats, +but you can also compile Lua so that it +uses 32-bit integers and/or single-precision (32-bit) floats. +The option with 32 bits for both integers and floats +is particularly attractive +for small machines and embedded systems. +(See macro LUA_32BITS in file luaconf.h.) + + +

    +Lua can call (and manipulate) functions written in Lua and +functions written in C (see §3.4.10). +Both are represented by the type function. + + +

    +The type userdata is provided to allow arbitrary C data to +be stored in Lua variables. +A userdata value represents a block of raw memory. +There are two kinds of userdata: +full userdata, +which is an object with a block of memory managed by Lua, +and light userdata, +which is simply a C pointer value. +Userdata has no predefined operations in Lua, +except assignment and identity test. +By using metatables, +the programmer can define operations for full userdata values +(see §2.4). +Userdata values cannot be created or modified in Lua, +only through the C API. +This guarantees the integrity of data owned by the host program. + + +

    +The type thread represents independent threads of execution +and it is used to implement coroutines (see §2.6). +Lua threads are not related to operating-system threads. +Lua supports coroutines on all systems, +even those that do not support threads natively. + + +

    +The type table implements associative arrays, +that is, arrays that can be indexed not only with numbers, +but with any Lua value except nil and NaN. +(Not a Number is a special value used to represent +undefined or unrepresentable numerical results, such as 0/0.) +Tables can be heterogeneous; +that is, they can contain values of all types (except nil). +Any key with value nil is not considered part of the table. +Conversely, any key that is not part of a table has +an associated value nil. + + +

    +Tables are the sole data-structuring mechanism in Lua; +they can be used to represent ordinary arrays, lists, +symbol tables, sets, records, graphs, trees, etc. +To represent records, Lua uses the field name as an index. +The language supports this representation by +providing a.name as syntactic sugar for a["name"]. +There are several convenient ways to create tables in Lua +(see §3.4.9). + + +

    +Like indices, +the values of table fields can be of any type. +In particular, +because functions are first-class values, +table fields can contain functions. +Thus tables can also carry methods (see §3.4.11). + + +

    +The indexing of tables follows +the definition of raw equality in the language. +The expressions a[i] and a[j] +denote the same table element +if and only if i and j are raw equal +(that is, equal without metamethods). +In particular, floats with integral values +are equal to their respective integers +(e.g., 1.0 == 1). +To avoid ambiguities, +any float with integral value used as a key +is converted to its respective integer. +For instance, if you write a[2.0] = true, +the actual key inserted into the table will be the +integer 2. +(On the other hand, +2 and "2" are different Lua values and therefore +denote different table entries.) + + +

    +Tables, functions, threads, and (full) userdata values are objects: +variables do not actually contain these values, +only references to them. +Assignment, parameter passing, and function returns +always manipulate references to such values; +these operations do not imply any kind of copy. + + +

    +The library function type returns a string describing the type +of a given value (see §6.1). + + + + + +

    2.2 – Environments and the Global Environment

    + +

    +As will be discussed in §3.2 and §3.3.3, +any reference to a free name +(that is, a name not bound to any declaration) var +is syntactically translated to _ENV.var. +Moreover, every chunk is compiled in the scope of +an external local variable named _ENV (see §3.3.2), +so _ENV itself is never a free name in a chunk. + + +

    +Despite the existence of this external _ENV variable and +the translation of free names, +_ENV is a completely regular name. +In particular, +you can define new variables and parameters with that name. +Each reference to a free name uses the _ENV that is +visible at that point in the program, +following the usual visibility rules of Lua (see §3.5). + + +

    +Any table used as the value of _ENV is called an environment. + + +

    +Lua keeps a distinguished environment called the global environment. +This value is kept at a special index in the C registry (see §4.5). +In Lua, the global variable _G is initialized with this same value. +(_G is never used internally.) + + +

    +When Lua loads a chunk, +the default value for its _ENV upvalue +is the global environment (see load). +Therefore, by default, +free names in Lua code refer to entries in the global environment +(and, therefore, they are also called global variables). +Moreover, all standard libraries are loaded in the global environment +and some functions there operate on that environment. +You can use load (or loadfile) +to load a chunk with a different environment. +(In C, you have to load the chunk and then change the value +of its first upvalue.) + + + + + +

    2.3 – Error Handling

    + +

    +Because Lua is an embedded extension language, +all Lua actions start from C code in the host program +calling a function from the Lua library. +(When you use Lua standalone, +the lua application is the host program.) +Whenever an error occurs during +the compilation or execution of a Lua chunk, +control returns to the host, +which can take appropriate measures +(such as printing an error message). + + +

    +Lua code can explicitly generate an error by calling the +error function. +If you need to catch errors in Lua, +you can use pcall or xpcall +to call a given function in protected mode. + + +

    +Whenever there is an error, +an error object (also called an error message) +is propagated with information about the error. +Lua itself only generates errors whose error object is a string, +but programs may generate errors with +any value as the error object. +It is up to the Lua program or its host to handle such error objects. + + +

    +When you use xpcall or lua_pcall, +you may give a message handler +to be called in case of errors. +This function is called with the original error object +and returns a new error object. +It is called before the error unwinds the stack, +so that it can gather more information about the error, +for instance by inspecting the stack and creating a stack traceback. +This message handler is still protected by the protected call; +so, an error inside the message handler +will call the message handler again. +If this loop goes on for too long, +Lua breaks it and returns an appropriate message. +(The message handler is called only for regular runtime errors. +It is not called for memory-allocation errors +nor for errors while running finalizers.) + + + + + +

    2.4 – Metatables and Metamethods

    + +

    +Every value in Lua can have a metatable. +This metatable is an ordinary Lua table +that defines the behavior of the original value +under certain special operations. +You can change several aspects of the behavior +of operations over a value by setting specific fields in its metatable. +For instance, when a non-numeric value is the operand of an addition, +Lua checks for a function in the field "__add" of the value's metatable. +If it finds one, +Lua calls this function to perform the addition. + + +

    +The key for each event in a metatable is a string +with the event name prefixed by two underscores; +the corresponding values are called metamethods. +In the previous example, the key is "__add" +and the metamethod is the function that performs the addition. + + +

    +You can query the metatable of any value +using the getmetatable function. +Lua queries metamethods in metatables using a raw access (see rawget). +So, to retrieve the metamethod for event ev in object o, +Lua does the equivalent to the following code: + +

    +     rawget(getmetatable(o) or {}, "__ev")
    +
    + +

    +You can replace the metatable of tables +using the setmetatable function. +You cannot change the metatable of other types from Lua code +(except by using the debug library (§6.10)); +you should use the C API for that. + + +

    +Tables and full userdata have individual metatables +(although multiple tables and userdata can share their metatables). +Values of all other types share one single metatable per type; +that is, there is one single metatable for all numbers, +one for all strings, etc. +By default, a value has no metatable, +but the string library sets a metatable for the string type (see §6.4). + + +

    +A metatable controls how an object behaves in +arithmetic operations, bitwise operations, +order comparisons, concatenation, length operation, calls, and indexing. +A metatable also can define a function to be called +when a userdata or a table is garbage collected (§2.5). + + +

    +For the unary operators (negation, length, and bitwise NOT), +the metamethod is computed and called with a dummy second operand, +equal to the first one. +This extra operand is only to simplify Lua's internals +(by making these operators behave like a binary operation) +and may be removed in future versions. +(For most uses this extra operand is irrelevant.) + + +

    +A detailed list of events controlled by metatables is given next. +Each operation is identified by its corresponding key. + + + +

      + +
    • __add: +the addition (+) operation. +If any operand for an addition is not a number +(nor a string coercible to a number), +Lua will try to call a metamethod. +First, Lua will check the first operand (even if it is valid). +If that operand does not define a metamethod for __add, +then Lua will check the second operand. +If Lua can find a metamethod, +it calls the metamethod with the two operands as arguments, +and the result of the call +(adjusted to one value) +is the result of the operation. +Otherwise, +it raises an error. +
    • + +
    • __sub: +the subtraction (-) operation. +Behavior similar to the addition operation. +
    • + +
    • __mul: +the multiplication (*) operation. +Behavior similar to the addition operation. +
    • + +
    • __div: +the division (/) operation. +Behavior similar to the addition operation. +
    • + +
    • __mod: +the modulo (%) operation. +Behavior similar to the addition operation. +
    • + +
    • __pow: +the exponentiation (^) operation. +Behavior similar to the addition operation. +
    • + +
    • __unm: +the negation (unary -) operation. +Behavior similar to the addition operation. +
    • + +
    • __idiv: +the floor division (//) operation. +Behavior similar to the addition operation. +
    • + +
    • __band: +the bitwise AND (&) operation. +Behavior similar to the addition operation, +except that Lua will try a metamethod +if any operand is neither an integer +nor a value coercible to an integer (see §3.4.3). +
    • + +
    • __bor: +the bitwise OR (|) operation. +Behavior similar to the bitwise AND operation. +
    • + +
    • __bxor: +the bitwise exclusive OR (binary ~) operation. +Behavior similar to the bitwise AND operation. +
    • + +
    • __bnot: +the bitwise NOT (unary ~) operation. +Behavior similar to the bitwise AND operation. +
    • + +
    • __shl: +the bitwise left shift (<<) operation. +Behavior similar to the bitwise AND operation. +
    • + +
    • __shr: +the bitwise right shift (>>) operation. +Behavior similar to the bitwise AND operation. +
    • + +
    • __concat: +the concatenation (..) operation. +Behavior similar to the addition operation, +except that Lua will try a metamethod +if any operand is neither a string nor a number +(which is always coercible to a string). +
    • + +
    • __len: +the length (#) operation. +If the object is not a string, +Lua will try its metamethod. +If there is a metamethod, +Lua calls it with the object as argument, +and the result of the call +(always adjusted to one value) +is the result of the operation. +If there is no metamethod but the object is a table, +then Lua uses the table length operation (see §3.4.7). +Otherwise, Lua raises an error. +
    • + +
    • __eq: +the equal (==) operation. +Behavior similar to the addition operation, +except that Lua will try a metamethod only when the values +being compared are either both tables or both full userdata +and they are not primitively equal. +The result of the call is always converted to a boolean. +
    • + +
    • __lt: +the less than (<) operation. +Behavior similar to the addition operation, +except that Lua will try a metamethod only when the values +being compared are neither both numbers nor both strings. +The result of the call is always converted to a boolean. +
    • + +
    • __le: +the less equal (<=) operation. +Unlike other operations, +the less-equal operation can use two different events. +First, Lua looks for the __le metamethod in both operands, +like in the less than operation. +If it cannot find such a metamethod, +then it will try the __lt metamethod, +assuming that a <= b is equivalent to not (b < a). +As with the other comparison operators, +the result is always a boolean. +(This use of the __lt event can be removed in future versions; +it is also slower than a real __le metamethod.) +
    • + +
    • __index: +The indexing access table[key]. +This event happens when table is not a table or +when key is not present in table. +The metamethod is looked up in table. + + +

      +Despite the name, +the metamethod for this event can be either a function or a table. +If it is a function, +it is called with table and key as arguments, +and the result of the call +(adjusted to one value) +is the result of the operation. +If it is a table, +the final result is the result of indexing this table with key. +(This indexing is regular, not raw, +and therefore can trigger another metamethod.) +

    • + +
    • __newindex: +The indexing assignment table[key] = value. +Like the index event, +this event happens when table is not a table or +when key is not present in table. +The metamethod is looked up in table. + + +

      +Like with indexing, +the metamethod for this event can be either a function or a table. +If it is a function, +it is called with table, key, and value as arguments. +If it is a table, +Lua does an indexing assignment to this table with the same key and value. +(This assignment is regular, not raw, +and therefore can trigger another metamethod.) + + +

      +Whenever there is a __newindex metamethod, +Lua does not perform the primitive assignment. +(If necessary, +the metamethod itself can call rawset +to do the assignment.) +

    • + +
    • __call: +The call operation func(args). +This event happens when Lua tries to call a non-function value +(that is, func is not a function). +The metamethod is looked up in func. +If present, +the metamethod is called with func as its first argument, +followed by the arguments of the original call (args). +All results of the call +are the result of the operation. +(This is the only metamethod that allows multiple results.) +
    • + +
    + +

    +It is a good practice to add all needed metamethods to a table +before setting it as a metatable of some object. +In particular, the __gc metamethod works only when this order +is followed (see §2.5.1). + + +

    +Because metatables are regular tables, +they can contain arbitrary fields, +not only the event names defined above. +Some functions in the standard library +(e.g., tostring) +use other fields in metatables for their own purposes. + + + + + +

    2.5 – Garbage Collection

    + +

    +Lua performs automatic memory management. +This means that +you do not have to worry about allocating memory for new objects +or freeing it when the objects are no longer needed. +Lua manages memory automatically by running +a garbage collector to collect all dead objects +(that is, objects that are no longer accessible from Lua). +All memory used by Lua is subject to automatic management: +strings, tables, userdata, functions, threads, internal structures, etc. + + +

    +Lua implements an incremental mark-and-sweep collector. +It uses two numbers to control its garbage-collection cycles: +the garbage-collector pause and +the garbage-collector step multiplier. +Both use percentage points as units +(e.g., a value of 100 means an internal value of 1). + + +

    +The garbage-collector pause +controls how long the collector waits before starting a new cycle. +Larger values make the collector less aggressive. +Values smaller than 100 mean the collector will not wait to +start a new cycle. +A value of 200 means that the collector waits for the total memory in use +to double before starting a new cycle. + + +

    +The garbage-collector step multiplier +controls the relative speed of the collector relative to +memory allocation. +Larger values make the collector more aggressive but also increase +the size of each incremental step. +You should not use values smaller than 100, +because they make the collector too slow and +can result in the collector never finishing a cycle. +The default is 200, +which means that the collector runs at "twice" +the speed of memory allocation. + + +

    +If you set the step multiplier to a very large number +(larger than 10% of the maximum number of +bytes that the program may use), +the collector behaves like a stop-the-world collector. +If you then set the pause to 200, +the collector behaves as in old Lua versions, +doing a complete collection every time Lua doubles its +memory usage. + + +

    +You can change these numbers by calling lua_gc in C +or collectgarbage in Lua. +You can also use these functions to control +the collector directly (e.g., stop and restart it). + + + +

    2.5.1 – Garbage-Collection Metamethods

    + +

    +You can set garbage-collector metamethods for tables +and, using the C API, +for full userdata (see §2.4). +These metamethods are also called finalizers. +Finalizers allow you to coordinate Lua's garbage collection +with external resource management +(such as closing files, network or database connections, +or freeing your own memory). + + +

    +For an object (table or userdata) to be finalized when collected, +you must mark it for finalization. + +You mark an object for finalization when you set its metatable +and the metatable has a field indexed by the string "__gc". +Note that if you set a metatable without a __gc field +and later create that field in the metatable, +the object will not be marked for finalization. + + +

    +When a marked object becomes garbage, +it is not collected immediately by the garbage collector. +Instead, Lua puts it in a list. +After the collection, +Lua goes through that list. +For each object in the list, +it checks the object's __gc metamethod: +If it is a function, +Lua calls it with the object as its single argument; +if the metamethod is not a function, +Lua simply ignores it. + + +

    +At the end of each garbage-collection cycle, +the finalizers for objects are called in +the reverse order that the objects were marked for finalization, +among those collected in that cycle; +that is, the first finalizer to be called is the one associated +with the object marked last in the program. +The execution of each finalizer may occur at any point during +the execution of the regular code. + + +

    +Because the object being collected must still be used by the finalizer, +that object (and other objects accessible only through it) +must be resurrected by Lua. +Usually, this resurrection is transient, +and the object memory is freed in the next garbage-collection cycle. +However, if the finalizer stores the object in some global place +(e.g., a global variable), +then the resurrection is permanent. +Moreover, if the finalizer marks a finalizing object for finalization again, +its finalizer will be called again in the next cycle where the +object is unreachable. +In any case, +the object memory is freed only in a GC cycle where +the object is unreachable and not marked for finalization. + + +

    +When you close a state (see lua_close), +Lua calls the finalizers of all objects marked for finalization, +following the reverse order that they were marked. +If any finalizer marks objects for collection during that phase, +these marks have no effect. + + + + + +

    2.5.2 – Weak Tables

    + +

    +A weak table is a table whose elements are +weak references. +A weak reference is ignored by the garbage collector. +In other words, +if the only references to an object are weak references, +then the garbage collector will collect that object. + + +

    +A weak table can have weak keys, weak values, or both. +A table with weak values allows the collection of its values, +but prevents the collection of its keys. +A table with both weak keys and weak values allows the collection of +both keys and values. +In any case, if either the key or the value is collected, +the whole pair is removed from the table. +The weakness of a table is controlled by the +__mode field of its metatable. +If the __mode field is a string containing the character 'k', +the keys in the table are weak. +If __mode contains 'v', +the values in the table are weak. + + +

    +A table with weak keys and strong values +is also called an ephemeron table. +In an ephemeron table, +a value is considered reachable only if its key is reachable. +In particular, +if the only reference to a key comes through its value, +the pair is removed. + + +

    +Any change in the weakness of a table may take effect only +at the next collect cycle. +In particular, if you change the weakness to a stronger mode, +Lua may still collect some items from that table +before the change takes effect. + + +

    +Only objects that have an explicit construction +are removed from weak tables. +Values, such as numbers and light C functions, +are not subject to garbage collection, +and therefore are not removed from weak tables +(unless their associated values are collected). +Although strings are subject to garbage collection, +they do not have an explicit construction, +and therefore are not removed from weak tables. + + +

    +Resurrected objects +(that is, objects being finalized +and objects accessible only through objects being finalized) +have a special behavior in weak tables. +They are removed from weak values before running their finalizers, +but are removed from weak keys only in the next collection +after running their finalizers, when such objects are actually freed. +This behavior allows the finalizer to access properties +associated with the object through weak tables. + + +

    +If a weak table is among the resurrected objects in a collection cycle, +it may not be properly cleared until the next cycle. + + + + + + + +

    2.6 – Coroutines

    + +

    +Lua supports coroutines, +also called collaborative multithreading. +A coroutine in Lua represents an independent thread of execution. +Unlike threads in multithread systems, however, +a coroutine only suspends its execution by explicitly calling +a yield function. + + +

    +You create a coroutine by calling coroutine.create. +Its sole argument is a function +that is the main function of the coroutine. +The create function only creates a new coroutine and +returns a handle to it (an object of type thread); +it does not start the coroutine. + + +

    +You execute a coroutine by calling coroutine.resume. +When you first call coroutine.resume, +passing as its first argument +a thread returned by coroutine.create, +the coroutine starts its execution by +calling its main function. +Extra arguments passed to coroutine.resume are passed +as arguments to that function. +After the coroutine starts running, +it runs until it terminates or yields. + + +

    +A coroutine can terminate its execution in two ways: +normally, when its main function returns +(explicitly or implicitly, after the last instruction); +and abnormally, if there is an unprotected error. +In case of normal termination, +coroutine.resume returns true, +plus any values returned by the coroutine main function. +In case of errors, coroutine.resume returns false +plus an error object. + + +

    +A coroutine yields by calling coroutine.yield. +When a coroutine yields, +the corresponding coroutine.resume returns immediately, +even if the yield happens inside nested function calls +(that is, not in the main function, +but in a function directly or indirectly called by the main function). +In the case of a yield, coroutine.resume also returns true, +plus any values passed to coroutine.yield. +The next time you resume the same coroutine, +it continues its execution from the point where it yielded, +with the call to coroutine.yield returning any extra +arguments passed to coroutine.resume. + + +

    +Like coroutine.create, +the coroutine.wrap function also creates a coroutine, +but instead of returning the coroutine itself, +it returns a function that, when called, resumes the coroutine. +Any arguments passed to this function +go as extra arguments to coroutine.resume. +coroutine.wrap returns all the values returned by coroutine.resume, +except the first one (the boolean error code). +Unlike coroutine.resume, +coroutine.wrap does not catch errors; +any error is propagated to the caller. + + +

    +As an example of how coroutines work, +consider the following code: + +

    +     function foo (a)
    +       print("foo", a)
    +       return coroutine.yield(2*a)
    +     end
    +     
    +     co = coroutine.create(function (a,b)
    +           print("co-body", a, b)
    +           local r = foo(a+1)
    +           print("co-body", r)
    +           local r, s = coroutine.yield(a+b, a-b)
    +           print("co-body", r, s)
    +           return b, "end"
    +     end)
    +     
    +     print("main", coroutine.resume(co, 1, 10))
    +     print("main", coroutine.resume(co, "r"))
    +     print("main", coroutine.resume(co, "x", "y"))
    +     print("main", coroutine.resume(co, "x", "y"))
    +

    +When you run it, it produces the following output: + +

    +     co-body 1       10
    +     foo     2
    +     main    true    4
    +     co-body r
    +     main    true    11      -9
    +     co-body x       y
    +     main    true    10      end
    +     main    false   cannot resume dead coroutine
    +
    + +

    +You can also create and manipulate coroutines through the C API: +see functions lua_newthread, lua_resume, +and lua_yield. + + + + + +

    3 – The Language

    + +

    +This section describes the lexis, the syntax, and the semantics of Lua. +In other words, +this section describes +which tokens are valid, +how they can be combined, +and what their combinations mean. + + +

    +Language constructs will be explained using the usual extended BNF notation, +in which +{a} means 0 or more a's, and +[a] means an optional a. +Non-terminals are shown like non-terminal, +keywords are shown like kword, +and other terminal symbols are shown like ‘=’. +The complete syntax of Lua can be found in §9 +at the end of this manual. + + + +

    3.1 – Lexical Conventions

    + +

    +Lua is a free-form language. +It ignores spaces (including new lines) and comments +between lexical elements (tokens), +except as delimiters between names and keywords. + + +

    +Names +(also called identifiers) +in Lua can be any string of letters, +digits, and underscores, +not beginning with a digit and +not being a reserved word. +Identifiers are used to name variables, table fields, and labels. + + +

    +The following keywords are reserved +and cannot be used as names: + + +

    +     and       break     do        else      elseif    end
    +     false     for       function  goto      if        in
    +     local     nil       not       or        repeat    return
    +     then      true      until     while
    +
    + +

    +Lua is a case-sensitive language: +and is a reserved word, but And and AND +are two different, valid names. +As a convention, +programs should avoid creating +names that start with an underscore followed by +one or more uppercase letters (such as _VERSION). + + +

    +The following strings denote other tokens: + +

    +     +     -     *     /     %     ^     #
    +     &     ~     |     <<    >>    //
    +     ==    ~=    <=    >=    <     >     =
    +     (     )     {     }     [     ]     ::
    +     ;     :     ,     .     ..    ...
    +
    + +

    +A short literal string +can be delimited by matching single or double quotes, +and can contain the following C-like escape sequences: +'\a' (bell), +'\b' (backspace), +'\f' (form feed), +'\n' (newline), +'\r' (carriage return), +'\t' (horizontal tab), +'\v' (vertical tab), +'\\' (backslash), +'\"' (quotation mark [double quote]), +and '\'' (apostrophe [single quote]). +A backslash followed by a line break +results in a newline in the string. +The escape sequence '\z' skips the following span +of white-space characters, +including line breaks; +it is particularly useful to break and indent a long literal string +into multiple lines without adding the newlines and spaces +into the string contents. +A short literal string cannot contain unescaped line breaks +nor escapes not forming a valid escape sequence. + + +

    +We can specify any byte in a short literal string by its numeric value +(including embedded zeros). +This can be done +with the escape sequence \xXX, +where XX is a sequence of exactly two hexadecimal digits, +or with the escape sequence \ddd, +where ddd is a sequence of up to three decimal digits. +(Note that if a decimal escape sequence is to be followed by a digit, +it must be expressed using exactly three digits.) + + +

    +The UTF-8 encoding of a Unicode character +can be inserted in a literal string with +the escape sequence \u{XXX} +(note the mandatory enclosing brackets), +where XXX is a sequence of one or more hexadecimal digits +representing the character code point. + + +

    +Literal strings can also be defined using a long format +enclosed by long brackets. +We define an opening long bracket of level n as an opening +square bracket followed by n equal signs followed by another +opening square bracket. +So, an opening long bracket of level 0 is written as [[, +an opening long bracket of level 1 is written as [=[, +and so on. +A closing long bracket is defined similarly; +for instance, +a closing long bracket of level 4 is written as ]====]. +A long literal starts with an opening long bracket of any level and +ends at the first closing long bracket of the same level. +It can contain any text except a closing bracket of the same level. +Literals in this bracketed form can run for several lines, +do not interpret any escape sequences, +and ignore long brackets of any other level. +Any kind of end-of-line sequence +(carriage return, newline, carriage return followed by newline, +or newline followed by carriage return) +is converted to a simple newline. + + +

    +For convenience, +when the opening long bracket is immediately followed by a newline, +the newline is not included in the string. +As an example, in a system using ASCII +(in which 'a' is coded as 97, +newline is coded as 10, and '1' is coded as 49), +the five literal strings below denote the same string: + +

    +     a = 'alo\n123"'
    +     a = "alo\n123\""
    +     a = '\97lo\10\04923"'
    +     a = [[alo
    +     123"]]
    +     a = [==[
    +     alo
    +     123"]==]
    +
    + +

    +Any byte in a literal string not +explicitly affected by the previous rules represents itself. +However, Lua opens files for parsing in text mode, +and the system file functions may have problems with +some control characters. +So, it is safer to represent +non-text data as a quoted literal with +explicit escape sequences for the non-text characters. + + +

    +A numeric constant (or numeral) +can be written with an optional fractional part +and an optional decimal exponent, +marked by a letter 'e' or 'E'. +Lua also accepts hexadecimal constants, +which start with 0x or 0X. +Hexadecimal constants also accept an optional fractional part +plus an optional binary exponent, +marked by a letter 'p' or 'P'. +A numeric constant with a radix point or an exponent +denotes a float; +otherwise, +if its value fits in an integer, +it denotes an integer. +Examples of valid integer constants are + +

    +     3   345   0xff   0xBEBADA
    +

    +Examples of valid float constants are + +

    +     3.0     3.1416     314.16e-2     0.31416E1     34e1
    +     0x0.1E  0xA23p-4   0X1.921FB54442D18P+1
    +
    + +

    +A comment starts with a double hyphen (--) +anywhere outside a string. +If the text immediately after -- is not an opening long bracket, +the comment is a short comment, +which runs until the end of the line. +Otherwise, it is a long comment, +which runs until the corresponding closing long bracket. +Long comments are frequently used to disable code temporarily. + + + + + +

    3.2 – Variables

    + +

    +Variables are places that store values. +There are three kinds of variables in Lua: +global variables, local variables, and table fields. + + +

    +A single name can denote a global variable or a local variable +(or a function's formal parameter, +which is a particular kind of local variable): + +

    +	var ::= Name
    +

    +Name denotes identifiers, as defined in §3.1. + + +

    +Any variable name is assumed to be global unless explicitly declared +as a local (see §3.3.7). +Local variables are lexically scoped: +local variables can be freely accessed by functions +defined inside their scope (see §3.5). + + +

    +Before the first assignment to a variable, its value is nil. + + +

    +Square brackets are used to index a table: + +

    +	var ::= prefixexp ‘[’ exp ‘]’
    +

    +The meaning of accesses to table fields can be changed via metatables. +An access to an indexed variable t[i] is equivalent to +a call gettable_event(t,i). +(See §2.4 for a complete description of the +gettable_event function. +This function is not defined or callable in Lua. +We use it here only for explanatory purposes.) + + +

    +The syntax var.Name is just syntactic sugar for +var["Name"]: + +

    +	var ::= prefixexp ‘.’ Name
    +
    + +

    +An access to a global variable x +is equivalent to _ENV.x. +Due to the way that chunks are compiled, +_ENV is never a global name (see §2.2). + + + + + +

    3.3 – Statements

    + +

    +Lua supports an almost conventional set of statements, +similar to those in Pascal or C. +This set includes +assignments, control structures, function calls, +and variable declarations. + + + +

    3.3.1 – Blocks

    + +

    +A block is a list of statements, +which are executed sequentially: + +

    +	block ::= {stat}
    +

    +Lua has empty statements +that allow you to separate statements with semicolons, +start a block with a semicolon +or write two semicolons in sequence: + +

    +	stat ::= ‘;’
    +
    + +

    +Function calls and assignments +can start with an open parenthesis. +This possibility leads to an ambiguity in Lua's grammar. +Consider the following fragment: + +

    +     a = b + c
    +     (print or io.write)('done')
    +

    +The grammar could see it in two ways: + +

    +     a = b + c(print or io.write)('done')
    +     
    +     a = b + c; (print or io.write)('done')
    +

    +The current parser always sees such constructions +in the first way, +interpreting the open parenthesis +as the start of the arguments to a call. +To avoid this ambiguity, +it is a good practice to always precede with a semicolon +statements that start with a parenthesis: + +

    +     ;(print or io.write)('done')
    +
    + +

    +A block can be explicitly delimited to produce a single statement: + +

    +	stat ::= do block end
    +

    +Explicit blocks are useful +to control the scope of variable declarations. +Explicit blocks are also sometimes used to +add a return statement in the middle +of another block (see §3.3.4). + + + + + +

    3.3.2 – Chunks

    + +

    +The unit of compilation of Lua is called a chunk. +Syntactically, +a chunk is simply a block: + +

    +	chunk ::= block
    +
    + +

    +Lua handles a chunk as the body of an anonymous function +with a variable number of arguments +(see §3.4.11). +As such, chunks can define local variables, +receive arguments, and return values. +Moreover, such anonymous function is compiled as in the +scope of an external local variable called _ENV (see §2.2). +The resulting function always has _ENV as its only upvalue, +even if it does not use that variable. + + +

    +A chunk can be stored in a file or in a string inside the host program. +To execute a chunk, +Lua first loads it, +precompiling the chunk's code into instructions for a virtual machine, +and then Lua executes the compiled code +with an interpreter for the virtual machine. + + +

    +Chunks can also be precompiled into binary form; +see program luac and function string.dump for details. +Programs in source and compiled forms are interchangeable; +Lua automatically detects the file type and acts accordingly (see load). + + + + + +

    3.3.3 – Assignment

    + +

    +Lua allows multiple assignments. +Therefore, the syntax for assignment +defines a list of variables on the left side +and a list of expressions on the right side. +The elements in both lists are separated by commas: + +

    +	stat ::= varlist ‘=’ explist
    +	varlist ::= var {‘,’ var}
    +	explist ::= exp {‘,’ exp}
    +

    +Expressions are discussed in §3.4. + + +

    +Before the assignment, +the list of values is adjusted to the length of +the list of variables. +If there are more values than needed, +the excess values are thrown away. +If there are fewer values than needed, +the list is extended with as many nil's as needed. +If the list of expressions ends with a function call, +then all values returned by that call enter the list of values, +before the adjustment +(except when the call is enclosed in parentheses; see §3.4). + + +

    +The assignment statement first evaluates all its expressions +and only then the assignments are performed. +Thus the code + +

    +     i = 3
    +     i, a[i] = i+1, 20
    +

    +sets a[3] to 20, without affecting a[4] +because the i in a[i] is evaluated (to 3) +before it is assigned 4. +Similarly, the line + +

    +     x, y = y, x
    +

    +exchanges the values of x and y, +and + +

    +     x, y, z = y, z, x
    +

    +cyclically permutes the values of x, y, and z. + + +

    +The meaning of assignments to global variables +and table fields can be changed via metatables. +An assignment to an indexed variable t[i] = val is equivalent to +settable_event(t,i,val). +(See §2.4 for a complete description of the +settable_event function. +This function is not defined or callable in Lua. +We use it here only for explanatory purposes.) + + +

    +An assignment to a global name x = val +is equivalent to the assignment +_ENV.x = val (see §2.2). + + + + + +

    3.3.4 – Control Structures

    +The control structures +if, while, and repeat have the usual meaning and +familiar syntax: + + + + +

    +	stat ::= while exp do block end
    +	stat ::= repeat block until exp
    +	stat ::= if exp then block {elseif exp then block} [else block] end
    +

    +Lua also has a for statement, in two flavors (see §3.3.5). + + +

    +The condition expression of a +control structure can return any value. +Both false and nil are considered false. +All values different from nil and false are considered true +(in particular, the number 0 and the empty string are also true). + + +

    +In the repeatuntil loop, +the inner block does not end at the until keyword, +but only after the condition. +So, the condition can refer to local variables +declared inside the loop block. + + +

    +The goto statement transfers the program control to a label. +For syntactical reasons, +labels in Lua are considered statements too: + + + +

    +	stat ::= goto Name
    +	stat ::= label
    +	label ::= ‘::’ Name ‘::’
    +
    + +

    +A label is visible in the entire block where it is defined, +except +inside nested blocks where a label with the same name is defined and +inside nested functions. +A goto may jump to any visible label as long as it does not +enter into the scope of a local variable. + + +

    +Labels and empty statements are called void statements, +as they perform no actions. + + +

    +The break statement terminates the execution of a +while, repeat, or for loop, +skipping to the next statement after the loop: + + +

    +	stat ::= break
    +

    +A break ends the innermost enclosing loop. + + +

    +The return statement is used to return values +from a function or a chunk +(which is an anonymous function). + +Functions can return more than one value, +so the syntax for the return statement is + +

    +	stat ::= return [explist] [‘;’]
    +
    + +

    +The return statement can only be written +as the last statement of a block. +If it is really necessary to return in the middle of a block, +then an explicit inner block can be used, +as in the idiom do return end, +because now return is the last statement in its (inner) block. + + + + + +

    3.3.5 – For Statement

    + +

    + +The for statement has two forms: +one numerical and one generic. + + +

    +The numerical for loop repeats a block of code while a +control variable runs through an arithmetic progression. +It has the following syntax: + +

    +	stat ::= for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end
    +

    +The block is repeated for name starting at the value of +the first exp, until it passes the second exp by steps of the +third exp. +More precisely, a for statement like + +

    +     for v = e1, e2, e3 do block end
    +

    +is equivalent to the code: + +

    +     do
    +       local var, limit, step = tonumber(e1), tonumber(e2), tonumber(e3)
    +       if not (var and limit and step) then error() end
    +       var = var - step
    +       while true do
    +         var = var + step
    +         if (step >= 0 and var > limit) or (step < 0 and var < limit) then
    +           break
    +         end
    +         local v = var
    +         block
    +       end
    +     end
    +
    + +

    +Note the following: + +

      + +
    • +All three control expressions are evaluated only once, +before the loop starts. +They must all result in numbers. +
    • + +
    • +var, limit, and step are invisible variables. +The names shown here are for explanatory purposes only. +
    • + +
    • +If the third expression (the step) is absent, +then a step of 1 is used. +
    • + +
    • +You can use break and goto to exit a for loop. +
    • + +
    • +The loop variable v is local to the loop body. +If you need its value after the loop, +assign it to another variable before exiting the loop. +
    • + +
    + +

    +The generic for statement works over functions, +called iterators. +On each iteration, the iterator function is called to produce a new value, +stopping when this new value is nil. +The generic for loop has the following syntax: + +

    +	stat ::= for namelist in explist do block end
    +	namelist ::= Name {‘,’ Name}
    +

    +A for statement like + +

    +     for var_1, ···, var_n in explist do block end
    +

    +is equivalent to the code: + +

    +     do
    +       local f, s, var = explist
    +       while true do
    +         local var_1, ···, var_n = f(s, var)
    +         if var_1 == nil then break end
    +         var = var_1
    +         block
    +       end
    +     end
    +

    +Note the following: + +

      + +
    • +explist is evaluated only once. +Its results are an iterator function, +a state, +and an initial value for the first iterator variable. +
    • + +
    • +f, s, and var are invisible variables. +The names are here for explanatory purposes only. +
    • + +
    • +You can use break to exit a for loop. +
    • + +
    • +The loop variables var_i are local to the loop; +you cannot use their values after the for ends. +If you need these values, +then assign them to other variables before breaking or exiting the loop. +
    • + +
    + + + + +

    3.3.6 – Function Calls as Statements

    +To allow possible side-effects, +function calls can be executed as statements: + +

    +	stat ::= functioncall
    +

    +In this case, all returned values are thrown away. +Function calls are explained in §3.4.10. + + + + + +

    3.3.7 – Local Declarations

    +Local variables can be declared anywhere inside a block. +The declaration can include an initial assignment: + +

    +	stat ::= local namelist [‘=’ explist]
    +

    +If present, an initial assignment has the same semantics +of a multiple assignment (see §3.3.3). +Otherwise, all variables are initialized with nil. + + +

    +A chunk is also a block (see §3.3.2), +and so local variables can be declared in a chunk outside any explicit block. + + +

    +The visibility rules for local variables are explained in §3.5. + + + + + + + +

    3.4 – Expressions

    + +

    +The basic expressions in Lua are the following: + +

    +	exp ::= prefixexp
    +	exp ::= nil | false | true
    +	exp ::= Numeral
    +	exp ::= LiteralString
    +	exp ::= functiondef
    +	exp ::= tableconstructor
    +	exp ::= ‘...’
    +	exp ::= exp binop exp
    +	exp ::= unop exp
    +	prefixexp ::= var | functioncall | ‘(’ exp ‘)’
    +
    + +

    +Numerals and literal strings are explained in §3.1; +variables are explained in §3.2; +function definitions are explained in §3.4.11; +function calls are explained in §3.4.10; +table constructors are explained in §3.4.9. +Vararg expressions, +denoted by three dots ('...'), can only be used when +directly inside a vararg function; +they are explained in §3.4.11. + + +

    +Binary operators comprise arithmetic operators (see §3.4.1), +bitwise operators (see §3.4.2), +relational operators (see §3.4.4), logical operators (see §3.4.5), +and the concatenation operator (see §3.4.6). +Unary operators comprise the unary minus (see §3.4.1), +the unary bitwise NOT (see §3.4.2), +the unary logical not (see §3.4.5), +and the unary length operator (see §3.4.7). + + +

    +Both function calls and vararg expressions can result in multiple values. +If a function call is used as a statement (see §3.3.6), +then its return list is adjusted to zero elements, +thus discarding all returned values. +If an expression is used as the last (or the only) element +of a list of expressions, +then no adjustment is made +(unless the expression is enclosed in parentheses). +In all other contexts, +Lua adjusts the result list to one element, +either discarding all values except the first one +or adding a single nil if there are no values. + + +

    +Here are some examples: + +

    +     f()                -- adjusted to 0 results
    +     g(f(), x)          -- f() is adjusted to 1 result
    +     g(x, f())          -- g gets x plus all results from f()
    +     a,b,c = f(), x     -- f() is adjusted to 1 result (c gets nil)
    +     a,b = ...          -- a gets the first vararg parameter, b gets
    +                        -- the second (both a and b can get nil if there
    +                        -- is no corresponding vararg parameter)
    +     
    +     a,b,c = x, f()     -- f() is adjusted to 2 results
    +     a,b,c = f()        -- f() is adjusted to 3 results
    +     return f()         -- returns all results from f()
    +     return ...         -- returns all received vararg parameters
    +     return x,y,f()     -- returns x, y, and all results from f()
    +     {f()}              -- creates a list with all results from f()
    +     {...}              -- creates a list with all vararg parameters
    +     {f(), nil}         -- f() is adjusted to 1 result
    +
    + +

    +Any expression enclosed in parentheses always results in only one value. +Thus, +(f(x,y,z)) is always a single value, +even if f returns several values. +(The value of (f(x,y,z)) is the first value returned by f +or nil if f does not return any values.) + + + +

    3.4.1 – Arithmetic Operators

    +Lua supports the following arithmetic operators: + +

      +
    • +: addition
    • +
    • -: subtraction
    • +
    • *: multiplication
    • +
    • /: float division
    • +
    • //: floor division
    • +
    • %: modulo
    • +
    • ^: exponentiation
    • +
    • -: unary minus
    • +
    + +

    +With the exception of exponentiation and float division, +the arithmetic operators work as follows: +If both operands are integers, +the operation is performed over integers and the result is an integer. +Otherwise, if both operands are numbers +or strings that can be converted to +numbers (see §3.4.3), +then they are converted to floats, +the operation is performed following the usual rules +for floating-point arithmetic +(usually the IEEE 754 standard), +and the result is a float. + + +

    +Exponentiation and float division (/) +always convert their operands to floats +and the result is always a float. +Exponentiation uses the ISO C function pow, +so that it works for non-integer exponents too. + + +

    +Floor division (//) is a division +that rounds the quotient towards minus infinity, +that is, the floor of the division of its operands. + + +

    +Modulo is defined as the remainder of a division +that rounds the quotient towards minus infinity (floor division). + + +

    +In case of overflows in integer arithmetic, +all operations wrap around, +according to the usual rules of two-complement arithmetic. +(In other words, +they return the unique representable integer +that is equal modulo 264 to the mathematical result.) + + + +

    3.4.2 – Bitwise Operators

    +Lua supports the following bitwise operators: + +

      +
    • &: bitwise AND
    • +
    • |: bitwise OR
    • +
    • ~: bitwise exclusive OR
    • +
    • >>: right shift
    • +
    • <<: left shift
    • +
    • ~: unary bitwise NOT
    • +
    + +

    +All bitwise operations convert its operands to integers +(see §3.4.3), +operate on all bits of those integers, +and result in an integer. + + +

    +Both right and left shifts fill the vacant bits with zeros. +Negative displacements shift to the other direction; +displacements with absolute values equal to or higher than +the number of bits in an integer +result in zero (as all bits are shifted out). + + + + + +

    3.4.3 – Coercions and Conversions

    +Lua provides some automatic conversions between some +types and representations at run time. +Bitwise operators always convert float operands to integers. +Exponentiation and float division +always convert integer operands to floats. +All other arithmetic operations applied to mixed numbers +(integers and floats) convert the integer operand to a float; +this is called the usual rule. +The C API also converts both integers to floats and +floats to integers, as needed. +Moreover, string concatenation accepts numbers as arguments, +besides strings. + + +

    +Lua also converts strings to numbers, +whenever a number is expected. + + +

    +In a conversion from integer to float, +if the integer value has an exact representation as a float, +that is the result. +Otherwise, +the conversion gets the nearest higher or +the nearest lower representable value. +This kind of conversion never fails. + + +

    +The conversion from float to integer +checks whether the float has an exact representation as an integer +(that is, the float has an integral value and +it is in the range of integer representation). +If it does, that representation is the result. +Otherwise, the conversion fails. + + +

    +The conversion from strings to numbers goes as follows: +First, the string is converted to an integer or a float, +following its syntax and the rules of the Lua lexer. +(The string may have also leading and trailing spaces and a sign.) +Then, the resulting number (float or integer) +is converted to the type (float or integer) required by the context +(e.g., the operation that forced the conversion). + + +

    +All conversions from strings to numbers +accept both a dot and the current locale mark +as the radix character. +(The Lua lexer, however, accepts only a dot.) + + +

    +The conversion from numbers to strings uses a +non-specified human-readable format. +For complete control over how numbers are converted to strings, +use the format function from the string library +(see string.format). + + + + + +

    3.4.4 – Relational Operators

    +Lua supports the following relational operators: + +

      +
    • ==: equality
    • +
    • ~=: inequality
    • +
    • <: less than
    • +
    • >: greater than
    • +
    • <=: less or equal
    • +
    • >=: greater or equal
    • +

    +These operators always result in false or true. + + +

    +Equality (==) first compares the type of its operands. +If the types are different, then the result is false. +Otherwise, the values of the operands are compared. +Strings are compared in the obvious way. +Numbers are equal if they denote the same mathematical value. + + +

    +Tables, userdata, and threads +are compared by reference: +two objects are considered equal only if they are the same object. +Every time you create a new object +(a table, userdata, or thread), +this new object is different from any previously existing object. +Closures with the same reference are always equal. +Closures with any detectable difference +(different behavior, different definition) are always different. + + +

    +You can change the way that Lua compares tables and userdata +by using the "eq" metamethod (see §2.4). + + +

    +Equality comparisons do not convert strings to numbers +or vice versa. +Thus, "0"==0 evaluates to false, +and t[0] and t["0"] denote different +entries in a table. + + +

    +The operator ~= is exactly the negation of equality (==). + + +

    +The order operators work as follows. +If both arguments are numbers, +then they are compared according to their mathematical values +(regardless of their subtypes). +Otherwise, if both arguments are strings, +then their values are compared according to the current locale. +Otherwise, Lua tries to call the "lt" or the "le" +metamethod (see §2.4). +A comparison a > b is translated to b < a +and a >= b is translated to b <= a. + + +

    +Following the IEEE 754 standard, +NaN is considered neither smaller than, +nor equal to, nor greater than any value (including itself). + + + + + +

    3.4.5 – Logical Operators

    +The logical operators in Lua are +and, or, and not. +Like the control structures (see §3.3.4), +all logical operators consider both false and nil as false +and anything else as true. + + +

    +The negation operator not always returns false or true. +The conjunction operator and returns its first argument +if this value is false or nil; +otherwise, and returns its second argument. +The disjunction operator or returns its first argument +if this value is different from nil and false; +otherwise, or returns its second argument. +Both and and or use short-circuit evaluation; +that is, +the second operand is evaluated only if necessary. +Here are some examples: + +

    +     10 or 20            --> 10
    +     10 or error()       --> 10
    +     nil or "a"          --> "a"
    +     nil and 10          --> nil
    +     false and error()   --> false
    +     false and nil       --> false
    +     false or nil        --> nil
    +     10 and 20           --> 20
    +

    +(In this manual, +--> indicates the result of the preceding expression.) + + + + + +

    3.4.6 – Concatenation

    +The string concatenation operator in Lua is +denoted by two dots ('..'). +If both operands are strings or numbers, then they are converted to +strings according to the rules described in §3.4.3. +Otherwise, the __concat metamethod is called (see §2.4). + + + + + +

    3.4.7 – The Length Operator

    + +

    +The length operator is denoted by the unary prefix operator #. + + +

    +The length of a string is its number of bytes +(that is, the usual meaning of string length when each +character is one byte). + + +

    +The length operator applied on a table +returns a border in that table. +A border in a table t is any natural number +that satisfies the following condition: + +

    +     (border == 0 or t[border] ~= nil) and t[border + 1] == nil
    +

    +In words, +a border is any (natural) index in a table +where a non-nil value is followed by a nil value +(or zero, when index 1 is nil). + + +

    +A table with exactly one border is called a sequence. +For instance, the table {10, 20, 30, 40, 50} is a sequence, +as it has only one border (5). +The table {10, 20, 30, nil, 50} has two borders (3 and 5), +and therefore it is not a sequence. +The table {nil, 20, 30, nil, nil, 60, nil} +has three borders (0, 3, and 6), +so it is not a sequence, too. +The table {} is a sequence with border 0. +Note that non-natural keys do not interfere +with whether a table is a sequence. + + +

    +When t is a sequence, +#t returns its only border, +which corresponds to the intuitive notion of the length of the sequence. +When t is not a sequence, +#t can return any of its borders. +(The exact one depends on details of +the internal representation of the table, +which in turn can depend on how the table was populated and +the memory addresses of its non-numeric keys.) + + +

    +The computation of the length of a table +has a guaranteed worst time of O(log n), +where n is the largest natural key in the table. + + +

    +A program can modify the behavior of the length operator for +any value but strings through the __len metamethod (see §2.4). + + + + + +

    3.4.8 – Precedence

    +Operator precedence in Lua follows the table below, +from lower to higher priority: + +

    +     or
    +     and
    +     <     >     <=    >=    ~=    ==
    +     |
    +     ~
    +     &
    +     <<    >>
    +     ..
    +     +     -
    +     *     /     //    %
    +     unary operators (not   #     -     ~)
    +     ^
    +

    +As usual, +you can use parentheses to change the precedences of an expression. +The concatenation ('..') and exponentiation ('^') +operators are right associative. +All other binary operators are left associative. + + + + + +

    3.4.9 – Table Constructors

    +Table constructors are expressions that create tables. +Every time a constructor is evaluated, a new table is created. +A constructor can be used to create an empty table +or to create a table and initialize some of its fields. +The general syntax for constructors is + +

    +	tableconstructor ::= ‘{’ [fieldlist] ‘}’
    +	fieldlist ::= field {fieldsep field} [fieldsep]
    +	field ::= ‘[’ exp ‘]’ ‘=’ exp | Name ‘=’ exp | exp
    +	fieldsep ::= ‘,’ | ‘;’
    +
    + +

    +Each field of the form [exp1] = exp2 adds to the new table an entry +with key exp1 and value exp2. +A field of the form name = exp is equivalent to +["name"] = exp. +Finally, fields of the form exp are equivalent to +[i] = exp, where i are consecutive integers +starting with 1. +Fields in the other formats do not affect this counting. +For example, + +

    +     a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 }
    +

    +is equivalent to + +

    +     do
    +       local t = {}
    +       t[f(1)] = g
    +       t[1] = "x"         -- 1st exp
    +       t[2] = "y"         -- 2nd exp
    +       t.x = 1            -- t["x"] = 1
    +       t[3] = f(x)        -- 3rd exp
    +       t[30] = 23
    +       t[4] = 45          -- 4th exp
    +       a = t
    +     end
    +
    + +

    +The order of the assignments in a constructor is undefined. +(This order would be relevant only when there are repeated keys.) + + +

    +If the last field in the list has the form exp +and the expression is a function call or a vararg expression, +then all values returned by this expression enter the list consecutively +(see §3.4.10). + + +

    +The field list can have an optional trailing separator, +as a convenience for machine-generated code. + + + + + +

    3.4.10 – Function Calls

    +A function call in Lua has the following syntax: + +

    +	functioncall ::= prefixexp args
    +

    +In a function call, +first prefixexp and args are evaluated. +If the value of prefixexp has type function, +then this function is called +with the given arguments. +Otherwise, the prefixexp "call" metamethod is called, +having as first parameter the value of prefixexp, +followed by the original call arguments +(see §2.4). + + +

    +The form + +

    +	functioncall ::= prefixexp ‘:’ Name args
    +

    +can be used to call "methods". +A call v:name(args) +is syntactic sugar for v.name(v,args), +except that v is evaluated only once. + + +

    +Arguments have the following syntax: + +

    +	args ::= ‘(’ [explist] ‘)’
    +	args ::= tableconstructor
    +	args ::= LiteralString
    +

    +All argument expressions are evaluated before the call. +A call of the form f{fields} is +syntactic sugar for f({fields}); +that is, the argument list is a single new table. +A call of the form f'string' +(or f"string" or f[[string]]) +is syntactic sugar for f('string'); +that is, the argument list is a single literal string. + + +

    +A call of the form return functioncall is called +a tail call. +Lua implements proper tail calls +(or proper tail recursion): +in a tail call, +the called function reuses the stack entry of the calling function. +Therefore, there is no limit on the number of nested tail calls that +a program can execute. +However, a tail call erases any debug information about the +calling function. +Note that a tail call only happens with a particular syntax, +where the return has one single function call as argument; +this syntax makes the calling function return exactly +the returns of the called function. +So, none of the following examples are tail calls: + +

    +     return (f(x))        -- results adjusted to 1
    +     return 2 * f(x)
    +     return x, f(x)       -- additional results
    +     f(x); return         -- results discarded
    +     return x or f(x)     -- results adjusted to 1
    +
    + + + + +

    3.4.11 – Function Definitions

    + +

    +The syntax for function definition is + +

    +	functiondef ::= function funcbody
    +	funcbody ::= ‘(’ [parlist] ‘)’ block end
    +
    + +

    +The following syntactic sugar simplifies function definitions: + +

    +	stat ::= function funcname funcbody
    +	stat ::= local function Name funcbody
    +	funcname ::= Name {‘.’ Name} [‘:’ Name]
    +

    +The statement + +

    +     function f () body end
    +

    +translates to + +

    +     f = function () body end
    +

    +The statement + +

    +     function t.a.b.c.f () body end
    +

    +translates to + +

    +     t.a.b.c.f = function () body end
    +

    +The statement + +

    +     local function f () body end
    +

    +translates to + +

    +     local f; f = function () body end
    +

    +not to + +

    +     local f = function () body end
    +

    +(This only makes a difference when the body of the function +contains references to f.) + + +

    +A function definition is an executable expression, +whose value has type function. +When Lua precompiles a chunk, +all its function bodies are precompiled too. +Then, whenever Lua executes the function definition, +the function is instantiated (or closed). +This function instance (or closure) +is the final value of the expression. + + +

    +Parameters act as local variables that are +initialized with the argument values: + +

    +	parlist ::= namelist [‘,’ ‘...’] | ‘...’
    +

    +When a function is called, +the list of arguments is adjusted to +the length of the list of parameters, +unless the function is a vararg function, +which is indicated by three dots ('...') +at the end of its parameter list. +A vararg function does not adjust its argument list; +instead, it collects all extra arguments and supplies them +to the function through a vararg expression, +which is also written as three dots. +The value of this expression is a list of all actual extra arguments, +similar to a function with multiple results. +If a vararg expression is used inside another expression +or in the middle of a list of expressions, +then its return list is adjusted to one element. +If the expression is used as the last element of a list of expressions, +then no adjustment is made +(unless that last expression is enclosed in parentheses). + + +

    +As an example, consider the following definitions: + +

    +     function f(a, b) end
    +     function g(a, b, ...) end
    +     function r() return 1,2,3 end
    +

    +Then, we have the following mapping from arguments to parameters and +to the vararg expression: + +

    +     CALL            PARAMETERS
    +     
    +     f(3)             a=3, b=nil
    +     f(3, 4)          a=3, b=4
    +     f(3, 4, 5)       a=3, b=4
    +     f(r(), 10)       a=1, b=10
    +     f(r())           a=1, b=2
    +     
    +     g(3)             a=3, b=nil, ... -->  (nothing)
    +     g(3, 4)          a=3, b=4,   ... -->  (nothing)
    +     g(3, 4, 5, 8)    a=3, b=4,   ... -->  5  8
    +     g(5, r())        a=5, b=1,   ... -->  2  3
    +
    + +

    +Results are returned using the return statement (see §3.3.4). +If control reaches the end of a function +without encountering a return statement, +then the function returns with no results. + + +

    + +There is a system-dependent limit on the number of values +that a function may return. +This limit is guaranteed to be larger than 1000. + + +

    +The colon syntax +is used for defining methods, +that is, functions that have an implicit extra parameter self. +Thus, the statement + +

    +     function t.a.b.c:f (params) body end
    +

    +is syntactic sugar for + +

    +     t.a.b.c.f = function (self, params) body end
    +
    + + + + + + +

    3.5 – Visibility Rules

    + +

    + +Lua is a lexically scoped language. +The scope of a local variable begins at the first statement after +its declaration and lasts until the last non-void statement +of the innermost block that includes the declaration. +Consider the following example: + +

    +     x = 10                -- global variable
    +     do                    -- new block
    +       local x = x         -- new 'x', with value 10
    +       print(x)            --> 10
    +       x = x+1
    +       do                  -- another block
    +         local x = x+1     -- another 'x'
    +         print(x)          --> 12
    +       end
    +       print(x)            --> 11
    +     end
    +     print(x)              --> 10  (the global one)
    +
    + +

    +Notice that, in a declaration like local x = x, +the new x being declared is not in scope yet, +and so the second x refers to the outside variable. + + +

    +Because of the lexical scoping rules, +local variables can be freely accessed by functions +defined inside their scope. +A local variable used by an inner function is called +an upvalue, or external local variable, +inside the inner function. + + +

    +Notice that each execution of a local statement +defines new local variables. +Consider the following example: + +

    +     a = {}
    +     local x = 20
    +     for i=1,10 do
    +       local y = 0
    +       a[i] = function () y=y+1; return x+y end
    +     end
    +

    +The loop creates ten closures +(that is, ten instances of the anonymous function). +Each of these closures uses a different y variable, +while all of them share the same x. + + + + + +

    4 – The Application Program Interface

    + +

    + +This section describes the C API for Lua, that is, +the set of C functions available to the host program to communicate +with Lua. +All API functions and related types and constants +are declared in the header file lua.h. + + +

    +Even when we use the term "function", +any facility in the API may be provided as a macro instead. +Except where stated otherwise, +all such macros use each of their arguments exactly once +(except for the first argument, which is always a Lua state), +and so do not generate any hidden side-effects. + + +

    +As in most C libraries, +the Lua API functions do not check their arguments for validity or consistency. +However, you can change this behavior by compiling Lua +with the macro LUA_USE_APICHECK defined. + + +

    +The Lua library is fully reentrant: +it has no global variables. +It keeps all information it needs in a dynamic structure, +called the Lua state. + + +

    +Each Lua state has one or more threads, +which correspond to independent, cooperative lines of execution. +The type lua_State (despite its name) refers to a thread. +(Indirectly, through the thread, it also refers to the +Lua state associated to the thread.) + + +

    +A pointer to a thread must be passed as the first argument to +every function in the library, except to lua_newstate, +which creates a Lua state from scratch and returns a pointer +to the main thread in the new state. + + + +

    4.1 – The Stack

    + +

    +Lua uses a virtual stack to pass values to and from C. +Each element in this stack represents a Lua value +(nil, number, string, etc.). +Functions in the API can access this stack through the +Lua state parameter that they receive. + + +

    +Whenever Lua calls C, the called function gets a new stack, +which is independent of previous stacks and of stacks of +C functions that are still active. +This stack initially contains any arguments to the C function +and it is where the C function can store temporary +Lua values and must push its results +to be returned to the caller (see lua_CFunction). + + +

    +For convenience, +most query operations in the API do not follow a strict stack discipline. +Instead, they can refer to any element in the stack +by using an index: +A positive index represents an absolute stack position +(starting at 1); +a negative index represents an offset relative to the top of the stack. +More specifically, if the stack has n elements, +then index 1 represents the first element +(that is, the element that was pushed onto the stack first) +and +index n represents the last element; +index -1 also represents the last element +(that is, the element at the top) +and index -n represents the first element. + + + + + +

    4.2 – Stack Size

    + +

    +When you interact with the Lua API, +you are responsible for ensuring consistency. +In particular, +you are responsible for controlling stack overflow. +You can use the function lua_checkstack +to ensure that the stack has enough space for pushing new elements. + + +

    +Whenever Lua calls C, +it ensures that the stack has space for +at least LUA_MINSTACK extra slots. +LUA_MINSTACK is defined as 20, +so that usually you do not have to worry about stack space +unless your code has loops pushing elements onto the stack. + + +

    +When you call a Lua function +without a fixed number of results (see lua_call), +Lua ensures that the stack has enough space for all results, +but it does not ensure any extra space. +So, before pushing anything in the stack after such a call +you should use lua_checkstack. + + + + + +

    4.3 – Valid and Acceptable Indices

    + +

    +Any function in the API that receives stack indices +works only with valid indices or acceptable indices. + + +

    +A valid index is an index that refers to a +position that stores a modifiable Lua value. +It comprises stack indices between 1 and the stack top +(1 ≤ abs(index) ≤ top) + +plus pseudo-indices, +which represent some positions that are accessible to C code +but that are not in the stack. +Pseudo-indices are used to access the registry (see §4.5) +and the upvalues of a C function (see §4.4). + + +

    +Functions that do not need a specific mutable position, +but only a value (e.g., query functions), +can be called with acceptable indices. +An acceptable index can be any valid index, +but it also can be any positive index after the stack top +within the space allocated for the stack, +that is, indices up to the stack size. +(Note that 0 is never an acceptable index.) +Except when noted otherwise, +functions in the API work with acceptable indices. + + +

    +Acceptable indices serve to avoid extra tests +against the stack top when querying the stack. +For instance, a C function can query its third argument +without the need to first check whether there is a third argument, +that is, without the need to check whether 3 is a valid index. + + +

    +For functions that can be called with acceptable indices, +any non-valid index is treated as if it +contains a value of a virtual type LUA_TNONE, +which behaves like a nil value. + + + + + +

    4.4 – C Closures

    + +

    +When a C function is created, +it is possible to associate some values with it, +thus creating a C closure +(see lua_pushcclosure); +these values are called upvalues and are +accessible to the function whenever it is called. + + +

    +Whenever a C function is called, +its upvalues are located at specific pseudo-indices. +These pseudo-indices are produced by the macro +lua_upvalueindex. +The first upvalue associated with a function is at index +lua_upvalueindex(1), and so on. +Any access to lua_upvalueindex(n), +where n is greater than the number of upvalues of the +current function +(but not greater than 256, +which is one plus the maximum number of upvalues in a closure), +produces an acceptable but invalid index. + + + + + +

    4.5 – Registry

    + +

    +Lua provides a registry, +a predefined table that can be used by any C code to +store whatever Lua values it needs to store. +The registry table is always located at pseudo-index +LUA_REGISTRYINDEX. +Any C library can store data into this table, +but it must take care to choose keys +that are different from those used +by other libraries, to avoid collisions. +Typically, you should use as key a string containing your library name, +or a light userdata with the address of a C object in your code, +or any Lua object created by your code. +As with variable names, +string keys starting with an underscore followed by +uppercase letters are reserved for Lua. + + +

    +The integer keys in the registry are used +by the reference mechanism (see luaL_ref) +and by some predefined values. +Therefore, integer keys must not be used for other purposes. + + +

    +When you create a new Lua state, +its registry comes with some predefined values. +These predefined values are indexed with integer keys +defined as constants in lua.h. +The following constants are defined: + +

      +
    • LUA_RIDX_MAINTHREAD: At this index the registry has +the main thread of the state. +(The main thread is the one created together with the state.) +
    • + +
    • LUA_RIDX_GLOBALS: At this index the registry has +the global environment. +
    • +
    + + + + +

    4.6 – Error Handling in C

    + +

    +Internally, Lua uses the C longjmp facility to handle errors. +(Lua will use exceptions if you compile it as C++; +search for LUAI_THROW in the source code for details.) +When Lua faces any error +(such as a memory allocation error or a type error) +it raises an error; +that is, it does a long jump. +A protected environment uses setjmp +to set a recovery point; +any error jumps to the most recent active recovery point. + + +

    +Inside a C function you can raise an error by calling lua_error. + + +

    +Most functions in the API can raise an error, +for instance due to a memory allocation error. +The documentation for each function indicates whether +it can raise errors. + + +

    +If an error happens outside any protected environment, +Lua calls a panic function (see lua_atpanic) +and then calls abort, +thus exiting the host application. +Your panic function can avoid this exit by +never returning +(e.g., doing a long jump to your own recovery point outside Lua). + + +

    +The panic function, +as its name implies, +is a mechanism of last resort. +Programs should avoid it. +As a general rule, +when a C function is called by Lua with a Lua state, +it can do whatever it wants on that Lua state, +as it should be already protected. +However, +when C code operates on other Lua states +(e.g., a Lua parameter to the function, +a Lua state stored in the registry, or +the result of lua_newthread), +it should use them only in API calls that cannot raise errors. + + +

    +The panic function runs as if it were a message handler (see §2.3); +in particular, the error object is at the top of the stack. +However, there is no guarantee about stack space. +To push anything on the stack, +the panic function must first check the available space (see §4.2). + + + + + +

    4.7 – Handling Yields in C

    + +

    +Internally, Lua uses the C longjmp facility to yield a coroutine. +Therefore, if a C function foo calls an API function +and this API function yields +(directly or indirectly by calling another function that yields), +Lua cannot return to foo any more, +because the longjmp removes its frame from the C stack. + + +

    +To avoid this kind of problem, +Lua raises an error whenever it tries to yield across an API call, +except for three functions: +lua_yieldk, lua_callk, and lua_pcallk. +All those functions receive a continuation function +(as a parameter named k) to continue execution after a yield. + + +

    +We need to set some terminology to explain continuations. +We have a C function called from Lua which we will call +the original function. +This original function then calls one of those three functions in the C API, +which we will call the callee function, +that then yields the current thread. +(This can happen when the callee function is lua_yieldk, +or when the callee function is either lua_callk or lua_pcallk +and the function called by them yields.) + + +

    +Suppose the running thread yields while executing the callee function. +After the thread resumes, +it eventually will finish running the callee function. +However, +the callee function cannot return to the original function, +because its frame in the C stack was destroyed by the yield. +Instead, Lua calls a continuation function, +which was given as an argument to the callee function. +As the name implies, +the continuation function should continue the task +of the original function. + + +

    +As an illustration, consider the following function: + +

    +     int original_function (lua_State *L) {
    +       ...     /* code 1 */
    +       status = lua_pcall(L, n, m, h);  /* calls Lua */
    +       ...     /* code 2 */
    +     }
    +

    +Now we want to allow +the Lua code being run by lua_pcall to yield. +First, we can rewrite our function like here: + +

    +     int k (lua_State *L, int status, lua_KContext ctx) {
    +       ...  /* code 2 */
    +     }
    +     
    +     int original_function (lua_State *L) {
    +       ...     /* code 1 */
    +       return k(L, lua_pcall(L, n, m, h), ctx);
    +     }
    +

    +In the above code, +the new function k is a +continuation function (with type lua_KFunction), +which should do all the work that the original function +was doing after calling lua_pcall. +Now, we must inform Lua that it must call k if the Lua code +being executed by lua_pcall gets interrupted in some way +(errors or yielding), +so we rewrite the code as here, +replacing lua_pcall by lua_pcallk: + +

    +     int original_function (lua_State *L) {
    +       ...     /* code 1 */
    +       return k(L, lua_pcallk(L, n, m, h, ctx2, k), ctx1);
    +     }
    +

    +Note the external, explicit call to the continuation: +Lua will call the continuation only if needed, that is, +in case of errors or resuming after a yield. +If the called function returns normally without ever yielding, +lua_pcallk (and lua_callk) will also return normally. +(Of course, instead of calling the continuation in that case, +you can do the equivalent work directly inside the original function.) + + +

    +Besides the Lua state, +the continuation function has two other parameters: +the final status of the call plus the context value (ctx) that +was passed originally to lua_pcallk. +(Lua does not use this context value; +it only passes this value from the original function to the +continuation function.) +For lua_pcallk, +the status is the same value that would be returned by lua_pcallk, +except that it is LUA_YIELD when being executed after a yield +(instead of LUA_OK). +For lua_yieldk and lua_callk, +the status is always LUA_YIELD when Lua calls the continuation. +(For these two functions, +Lua will not call the continuation in case of errors, +because they do not handle errors.) +Similarly, when using lua_callk, +you should call the continuation function +with LUA_OK as the status. +(For lua_yieldk, there is not much point in calling +directly the continuation function, +because lua_yieldk usually does not return.) + + +

    +Lua treats the continuation function as if it were the original function. +The continuation function receives the same Lua stack +from the original function, +in the same state it would be if the callee function had returned. +(For instance, +after a lua_callk the function and its arguments are +removed from the stack and replaced by the results from the call.) +It also has the same upvalues. +Whatever it returns is handled by Lua as if it were the return +of the original function. + + + + + +

    4.8 – Functions and Types

    + +

    +Here we list all functions and types from the C API in +alphabetical order. +Each function has an indicator like this: +[-o, +p, x] + + +

    +The first field, o, +is how many elements the function pops from the stack. +The second field, p, +is how many elements the function pushes onto the stack. +(Any function always pushes its results after popping its arguments.) +A field in the form x|y means the function can push (or pop) +x or y elements, +depending on the situation; +an interrogation mark '?' means that +we cannot know how many elements the function pops/pushes +by looking only at its arguments +(e.g., they may depend on what is on the stack). +The third field, x, +tells whether the function may raise errors: +'-' means the function never raises any error; +'m' means the function may raise out-of-memory errors +and errors running a __gc metamethod; +'e' means the function may raise any errors +(it can run arbitrary Lua code, +either directly or through metamethods); +'v' means the function may raise an error on purpose. + + + +


    lua_absindex

    +[-0, +0, –] +

    int lua_absindex (lua_State *L, int idx);
    + +

    +Converts the acceptable index idx +into an equivalent absolute index +(that is, one that does not depend on the stack top). + + + + + +


    lua_Alloc

    +
    typedef void * (*lua_Alloc) (void *ud,
    +                             void *ptr,
    +                             size_t osize,
    +                             size_t nsize);
    + +

    +The type of the memory-allocation function used by Lua states. +The allocator function must provide a +functionality similar to realloc, +but not exactly the same. +Its arguments are +ud, an opaque pointer passed to lua_newstate; +ptr, a pointer to the block being allocated/reallocated/freed; +osize, the original size of the block or some code about what +is being allocated; +and nsize, the new size of the block. + + +

    +When ptr is not NULL, +osize is the size of the block pointed by ptr, +that is, the size given when it was allocated or reallocated. + + +

    +When ptr is NULL, +osize encodes the kind of object that Lua is allocating. +osize is any of +LUA_TSTRING, LUA_TTABLE, LUA_TFUNCTION, +LUA_TUSERDATA, or LUA_TTHREAD when (and only when) +Lua is creating a new object of that type. +When osize is some other value, +Lua is allocating memory for something else. + + +

    +Lua assumes the following behavior from the allocator function: + + +

    +When nsize is zero, +the allocator must behave like free +and return NULL. + + +

    +When nsize is not zero, +the allocator must behave like realloc. +The allocator returns NULL +if and only if it cannot fulfill the request. +Lua assumes that the allocator never fails when +osize >= nsize. + + +

    +Here is a simple implementation for the allocator function. +It is used in the auxiliary library by luaL_newstate. + +

    +     static void *l_alloc (void *ud, void *ptr, size_t osize,
    +                                                size_t nsize) {
    +       (void)ud;  (void)osize;  /* not used */
    +       if (nsize == 0) {
    +         free(ptr);
    +         return NULL;
    +       }
    +       else
    +         return realloc(ptr, nsize);
    +     }
    +

    +Note that Standard C ensures +that free(NULL) has no effect and that +realloc(NULL,size) is equivalent to malloc(size). +This code assumes that realloc does not fail when shrinking a block. +(Although Standard C does not ensure this behavior, +it seems to be a safe assumption.) + + + + + +


    lua_arith

    +[-(2|1), +1, e] +

    void lua_arith (lua_State *L, int op);
    + +

    +Performs an arithmetic or bitwise operation over the two values +(or one, in the case of negations) +at the top of the stack, +with the value at the top being the second operand, +pops these values, and pushes the result of the operation. +The function follows the semantics of the corresponding Lua operator +(that is, it may call metamethods). + + +

    +The value of op must be one of the following constants: + +

    + + + + +

    lua_atpanic

    +[-0, +0, –] +

    lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);
    + +

    +Sets a new panic function and returns the old one (see §4.6). + + + + + +


    lua_call

    +[-(nargs+1), +nresults, e] +

    void lua_call (lua_State *L, int nargs, int nresults);
    + +

    +Calls a function. + + +

    +To call a function you must use the following protocol: +first, the function to be called is pushed onto the stack; +then, the arguments to the function are pushed +in direct order; +that is, the first argument is pushed first. +Finally you call lua_call; +nargs is the number of arguments that you pushed onto the stack. +All arguments and the function value are popped from the stack +when the function is called. +The function results are pushed onto the stack when the function returns. +The number of results is adjusted to nresults, +unless nresults is LUA_MULTRET. +In this case, all results from the function are pushed; +Lua takes care that the returned values fit into the stack space, +but it does not ensure any extra space in the stack. +The function results are pushed onto the stack in direct order +(the first result is pushed first), +so that after the call the last result is on the top of the stack. + + +

    +Any error inside the called function is propagated upwards +(with a longjmp). + + +

    +The following example shows how the host program can do the +equivalent to this Lua code: + +

    +     a = f("how", t.x, 14)
    +

    +Here it is in C: + +

    +     lua_getglobal(L, "f");                  /* function to be called */
    +     lua_pushliteral(L, "how");                       /* 1st argument */
    +     lua_getglobal(L, "t");                    /* table to be indexed */
    +     lua_getfield(L, -1, "x");        /* push result of t.x (2nd arg) */
    +     lua_remove(L, -2);                  /* remove 't' from the stack */
    +     lua_pushinteger(L, 14);                          /* 3rd argument */
    +     lua_call(L, 3, 1);     /* call 'f' with 3 arguments and 1 result */
    +     lua_setglobal(L, "a");                         /* set global 'a' */
    +

    +Note that the code above is balanced: +at its end, the stack is back to its original configuration. +This is considered good programming practice. + + + + + +


    lua_callk

    +[-(nargs + 1), +nresults, e] +

    void lua_callk (lua_State *L,
    +                int nargs,
    +                int nresults,
    +                lua_KContext ctx,
    +                lua_KFunction k);
    + +

    +This function behaves exactly like lua_call, +but allows the called function to yield (see §4.7). + + + + + +


    lua_CFunction

    +
    typedef int (*lua_CFunction) (lua_State *L);
    + +

    +Type for C functions. + + +

    +In order to communicate properly with Lua, +a C function must use the following protocol, +which defines the way parameters and results are passed: +a C function receives its arguments from Lua in its stack +in direct order (the first argument is pushed first). +So, when the function starts, +lua_gettop(L) returns the number of arguments received by the function. +The first argument (if any) is at index 1 +and its last argument is at index lua_gettop(L). +To return values to Lua, a C function just pushes them onto the stack, +in direct order (the first result is pushed first), +and returns the number of results. +Any other value in the stack below the results will be properly +discarded by Lua. +Like a Lua function, a C function called by Lua can also return +many results. + + +

    +As an example, the following function receives a variable number +of numeric arguments and returns their average and their sum: + +

    +     static int foo (lua_State *L) {
    +       int n = lua_gettop(L);    /* number of arguments */
    +       lua_Number sum = 0.0;
    +       int i;
    +       for (i = 1; i <= n; i++) {
    +         if (!lua_isnumber(L, i)) {
    +           lua_pushliteral(L, "incorrect argument");
    +           lua_error(L);
    +         }
    +         sum += lua_tonumber(L, i);
    +       }
    +       lua_pushnumber(L, sum/n);        /* first result */
    +       lua_pushnumber(L, sum);         /* second result */
    +       return 2;                   /* number of results */
    +     }
    +
    + + + + +

    lua_checkstack

    +[-0, +0, –] +

    int lua_checkstack (lua_State *L, int n);
    + +

    +Ensures that the stack has space for at least n extra slots +(that is, that you can safely push up to n values into it). +It returns false if it cannot fulfill the request, +either because it would cause the stack +to be larger than a fixed maximum size +(typically at least several thousand elements) or +because it cannot allocate memory for the extra space. +This function never shrinks the stack; +if the stack already has space for the extra slots, +it is left unchanged. + + + + + +


    lua_close

    +[-0, +0, –] +

    void lua_close (lua_State *L);
    + +

    +Destroys all objects in the given Lua state +(calling the corresponding garbage-collection metamethods, if any) +and frees all dynamic memory used by this state. +On several platforms, you may not need to call this function, +because all resources are naturally released when the host program ends. +On the other hand, long-running programs that create multiple states, +such as daemons or web servers, +will probably need to close states as soon as they are not needed. + + + + + +


    lua_compare

    +[-0, +0, e] +

    int lua_compare (lua_State *L, int index1, int index2, int op);
    + +

    +Compares two Lua values. +Returns 1 if the value at index index1 satisfies op +when compared with the value at index index2, +following the semantics of the corresponding Lua operator +(that is, it may call metamethods). +Otherwise returns 0. +Also returns 0 if any of the indices is not valid. + + +

    +The value of op must be one of the following constants: + +

      + +
    • LUA_OPEQ: compares for equality (==)
    • +
    • LUA_OPLT: compares for less than (<)
    • +
    • LUA_OPLE: compares for less or equal (<=)
    • + +
    + + + + +

    lua_concat

    +[-n, +1, e] +

    void lua_concat (lua_State *L, int n);
    + +

    +Concatenates the n values at the top of the stack, +pops them, and leaves the result at the top. +If n is 1, the result is the single value on the stack +(that is, the function does nothing); +if n is 0, the result is the empty string. +Concatenation is performed following the usual semantics of Lua +(see §3.4.6). + + + + + +


    lua_copy

    +[-0, +0, –] +

    void lua_copy (lua_State *L, int fromidx, int toidx);
    + +

    +Copies the element at index fromidx +into the valid index toidx, +replacing the value at that position. +Values at other positions are not affected. + + + + + +


    lua_createtable

    +[-0, +1, m] +

    void lua_createtable (lua_State *L, int narr, int nrec);
    + +

    +Creates a new empty table and pushes it onto the stack. +Parameter narr is a hint for how many elements the table +will have as a sequence; +parameter nrec is a hint for how many other elements +the table will have. +Lua may use these hints to preallocate memory for the new table. +This preallocation is useful for performance when you know in advance +how many elements the table will have. +Otherwise you can use the function lua_newtable. + + + + + +


    lua_dump

    +[-0, +0, –] +

    int lua_dump (lua_State *L,
    +                        lua_Writer writer,
    +                        void *data,
    +                        int strip);
    + +

    +Dumps a function as a binary chunk. +Receives a Lua function on the top of the stack +and produces a binary chunk that, +if loaded again, +results in a function equivalent to the one dumped. +As it produces parts of the chunk, +lua_dump calls function writer (see lua_Writer) +with the given data +to write them. + + +

    +If strip is true, +the binary representation may not include all debug information +about the function, +to save space. + + +

    +The value returned is the error code returned by the last +call to the writer; +0 means no errors. + + +

    +This function does not pop the Lua function from the stack. + + + + + +


    lua_error

    +[-1, +0, v] +

    int lua_error (lua_State *L);
    + +

    +Generates a Lua error, +using the value at the top of the stack as the error object. +This function does a long jump, +and therefore never returns +(see luaL_error). + + + + + +


    lua_gc

    +[-0, +0, m] +

    int lua_gc (lua_State *L, int what, int data);
    + +

    +Controls the garbage collector. + + +

    +This function performs several tasks, +according to the value of the parameter what: + +

      + +
    • LUA_GCSTOP: +stops the garbage collector. +
    • + +
    • LUA_GCRESTART: +restarts the garbage collector. +
    • + +
    • LUA_GCCOLLECT: +performs a full garbage-collection cycle. +
    • + +
    • LUA_GCCOUNT: +returns the current amount of memory (in Kbytes) in use by Lua. +
    • + +
    • LUA_GCCOUNTB: +returns the remainder of dividing the current amount of bytes of +memory in use by Lua by 1024. +
    • + +
    • LUA_GCSTEP: +performs an incremental step of garbage collection. +
    • + +
    • LUA_GCSETPAUSE: +sets data as the new value +for the pause of the collector (see §2.5) +and returns the previous value of the pause. +
    • + +
    • LUA_GCSETSTEPMUL: +sets data as the new value for the step multiplier of +the collector (see §2.5) +and returns the previous value of the step multiplier. +
    • + +
    • LUA_GCISRUNNING: +returns a boolean that tells whether the collector is running +(i.e., not stopped). +
    • + +
    + +

    +For more details about these options, +see collectgarbage. + + + + + +


    lua_getallocf

    +[-0, +0, –] +

    lua_Alloc lua_getallocf (lua_State *L, void **ud);
    + +

    +Returns the memory-allocation function of a given state. +If ud is not NULL, Lua stores in *ud the +opaque pointer given when the memory-allocator function was set. + + + + + +


    lua_getfield

    +[-0, +1, e] +

    int lua_getfield (lua_State *L, int index, const char *k);
    + +

    +Pushes onto the stack the value t[k], +where t is the value at the given index. +As in Lua, this function may trigger a metamethod +for the "index" event (see §2.4). + + +

    +Returns the type of the pushed value. + + + + + +


    lua_getextraspace

    +[-0, +0, –] +

    void *lua_getextraspace (lua_State *L);
    + +

    +Returns a pointer to a raw memory area associated with the +given Lua state. +The application can use this area for any purpose; +Lua does not use it for anything. + + +

    +Each new thread has this area initialized with a copy +of the area of the main thread. + + +

    +By default, this area has the size of a pointer to void, +but you can recompile Lua with a different size for this area. +(See LUA_EXTRASPACE in luaconf.h.) + + + + + +


    lua_getglobal

    +[-0, +1, e] +

    int lua_getglobal (lua_State *L, const char *name);
    + +

    +Pushes onto the stack the value of the global name. +Returns the type of that value. + + + + + +


    lua_geti

    +[-0, +1, e] +

    int lua_geti (lua_State *L, int index, lua_Integer i);
    + +

    +Pushes onto the stack the value t[i], +where t is the value at the given index. +As in Lua, this function may trigger a metamethod +for the "index" event (see §2.4). + + +

    +Returns the type of the pushed value. + + + + + +


    lua_getmetatable

    +[-0, +(0|1), –] +

    int lua_getmetatable (lua_State *L, int index);
    + +

    +If the value at the given index has a metatable, +the function pushes that metatable onto the stack and returns 1. +Otherwise, +the function returns 0 and pushes nothing on the stack. + + + + + +


    lua_gettable

    +[-1, +1, e] +

    int lua_gettable (lua_State *L, int index);
    + +

    +Pushes onto the stack the value t[k], +where t is the value at the given index +and k is the value at the top of the stack. + + +

    +This function pops the key from the stack, +pushing the resulting value in its place. +As in Lua, this function may trigger a metamethod +for the "index" event (see §2.4). + + +

    +Returns the type of the pushed value. + + + + + +


    lua_gettop

    +[-0, +0, –] +

    int lua_gettop (lua_State *L);
    + +

    +Returns the index of the top element in the stack. +Because indices start at 1, +this result is equal to the number of elements in the stack; +in particular, 0 means an empty stack. + + + + + +


    lua_getuservalue

    +[-0, +1, –] +

    int lua_getuservalue (lua_State *L, int index);
    + +

    +Pushes onto the stack the Lua value associated with the full userdata +at the given index. + + +

    +Returns the type of the pushed value. + + + + + +


    lua_insert

    +[-1, +1, –] +

    void lua_insert (lua_State *L, int index);
    + +

    +Moves the top element into the given valid index, +shifting up the elements above this index to open space. +This function cannot be called with a pseudo-index, +because a pseudo-index is not an actual stack position. + + + + + +


    lua_Integer

    +
    typedef ... lua_Integer;
    + +

    +The type of integers in Lua. + + +

    +By default this type is long long, +(usually a 64-bit two-complement integer), +but that can be changed to long or int +(usually a 32-bit two-complement integer). +(See LUA_INT_TYPE in luaconf.h.) + + +

    +Lua also defines the constants +LUA_MININTEGER and LUA_MAXINTEGER, +with the minimum and the maximum values that fit in this type. + + + + + +


    lua_isboolean

    +[-0, +0, –] +

    int lua_isboolean (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is a boolean, +and 0 otherwise. + + + + + +


    lua_iscfunction

    +[-0, +0, –] +

    int lua_iscfunction (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is a C function, +and 0 otherwise. + + + + + +


    lua_isfunction

    +[-0, +0, –] +

    int lua_isfunction (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is a function +(either C or Lua), and 0 otherwise. + + + + + +


    lua_isinteger

    +[-0, +0, –] +

    int lua_isinteger (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is an integer +(that is, the value is a number and is represented as an integer), +and 0 otherwise. + + + + + +


    lua_islightuserdata

    +[-0, +0, –] +

    int lua_islightuserdata (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is a light userdata, +and 0 otherwise. + + + + + +


    lua_isnil

    +[-0, +0, –] +

    int lua_isnil (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is nil, +and 0 otherwise. + + + + + +


    lua_isnone

    +[-0, +0, –] +

    int lua_isnone (lua_State *L, int index);
    + +

    +Returns 1 if the given index is not valid, +and 0 otherwise. + + + + + +


    lua_isnoneornil

    +[-0, +0, –] +

    int lua_isnoneornil (lua_State *L, int index);
    + +

    +Returns 1 if the given index is not valid +or if the value at this index is nil, +and 0 otherwise. + + + + + +


    lua_isnumber

    +[-0, +0, –] +

    int lua_isnumber (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is a number +or a string convertible to a number, +and 0 otherwise. + + + + + +


    lua_isstring

    +[-0, +0, –] +

    int lua_isstring (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is a string +or a number (which is always convertible to a string), +and 0 otherwise. + + + + + +


    lua_istable

    +[-0, +0, –] +

    int lua_istable (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is a table, +and 0 otherwise. + + + + + +


    lua_isthread

    +[-0, +0, –] +

    int lua_isthread (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is a thread, +and 0 otherwise. + + + + + +


    lua_isuserdata

    +[-0, +0, –] +

    int lua_isuserdata (lua_State *L, int index);
    + +

    +Returns 1 if the value at the given index is a userdata +(either full or light), and 0 otherwise. + + + + + +


    lua_isyieldable

    +[-0, +0, –] +

    int lua_isyieldable (lua_State *L);
    + +

    +Returns 1 if the given coroutine can yield, +and 0 otherwise. + + + + + +


    lua_KContext

    +
    typedef ... lua_KContext;
    + +

    +The type for continuation-function contexts. +It must be a numeric type. +This type is defined as intptr_t +when intptr_t is available, +so that it can store pointers too. +Otherwise, it is defined as ptrdiff_t. + + + + + +


    lua_KFunction

    +
    typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);
    + +

    +Type for continuation functions (see §4.7). + + + + + +


    lua_len

    +[-0, +1, e] +

    void lua_len (lua_State *L, int index);
    + +

    +Returns the length of the value at the given index. +It is equivalent to the '#' operator in Lua (see §3.4.7) and +may trigger a metamethod for the "length" event (see §2.4). +The result is pushed on the stack. + + + + + +


    lua_load

    +[-0, +1, –] +

    int lua_load (lua_State *L,
    +              lua_Reader reader,
    +              void *data,
    +              const char *chunkname,
    +              const char *mode);
    + +

    +Loads a Lua chunk without running it. +If there are no errors, +lua_load pushes the compiled chunk as a Lua +function on top of the stack. +Otherwise, it pushes an error message. + + +

    +The return values of lua_load are: + +

      + +
    • LUA_OK: no errors;
    • + +
    • LUA_ERRSYNTAX: +syntax error during precompilation;
    • + +
    • LUA_ERRMEM: +memory allocation (out-of-memory) error;
    • + +
    • LUA_ERRGCMM: +error while running a __gc metamethod. +(This error has no relation with the chunk being loaded. +It is generated by the garbage collector.) +
    • + +
    + +

    +The lua_load function uses a user-supplied reader function +to read the chunk (see lua_Reader). +The data argument is an opaque value passed to the reader function. + + +

    +The chunkname argument gives a name to the chunk, +which is used for error messages and in debug information (see §4.9). + + +

    +lua_load automatically detects whether the chunk is text or binary +and loads it accordingly (see program luac). +The string mode works as in function load, +with the addition that +a NULL value is equivalent to the string "bt". + + +

    +lua_load uses the stack internally, +so the reader function must always leave the stack +unmodified when returning. + + +

    +If the resulting function has upvalues, +its first upvalue is set to the value of the global environment +stored at index LUA_RIDX_GLOBALS in the registry (see §4.5). +When loading main chunks, +this upvalue will be the _ENV variable (see §2.2). +Other upvalues are initialized with nil. + + + + + +


    lua_newstate

    +[-0, +0, –] +

    lua_State *lua_newstate (lua_Alloc f, void *ud);
    + +

    +Creates a new thread running in a new, independent state. +Returns NULL if it cannot create the thread or the state +(due to lack of memory). +The argument f is the allocator function; +Lua does all memory allocation for this state +through this function (see lua_Alloc). +The second argument, ud, is an opaque pointer that Lua +passes to the allocator in every call. + + + + + +


    lua_newtable

    +[-0, +1, m] +

    void lua_newtable (lua_State *L);
    + +

    +Creates a new empty table and pushes it onto the stack. +It is equivalent to lua_createtable(L, 0, 0). + + + + + +


    lua_newthread

    +[-0, +1, m] +

    lua_State *lua_newthread (lua_State *L);
    + +

    +Creates a new thread, pushes it on the stack, +and returns a pointer to a lua_State that represents this new thread. +The new thread returned by this function shares with the original thread +its global environment, +but has an independent execution stack. + + +

    +There is no explicit function to close or to destroy a thread. +Threads are subject to garbage collection, +like any Lua object. + + + + + +


    lua_newuserdata

    +[-0, +1, m] +

    void *lua_newuserdata (lua_State *L, size_t size);
    + +

    +This function allocates a new block of memory with the given size, +pushes onto the stack a new full userdata with the block address, +and returns this address. +The host program can freely use this memory. + + + + + +


    lua_next

    +[-1, +(2|0), e] +

    int lua_next (lua_State *L, int index);
    + +

    +Pops a key from the stack, +and pushes a key–value pair from the table at the given index +(the "next" pair after the given key). +If there are no more elements in the table, +then lua_next returns 0 (and pushes nothing). + + +

    +A typical traversal looks like this: + +

    +     /* table is in the stack at index 't' */
    +     lua_pushnil(L);  /* first key */
    +     while (lua_next(L, t) != 0) {
    +       /* uses 'key' (at index -2) and 'value' (at index -1) */
    +       printf("%s - %s\n",
    +              lua_typename(L, lua_type(L, -2)),
    +              lua_typename(L, lua_type(L, -1)));
    +       /* removes 'value'; keeps 'key' for next iteration */
    +       lua_pop(L, 1);
    +     }
    +
    + +

    +While traversing a table, +do not call lua_tolstring directly on a key, +unless you know that the key is actually a string. +Recall that lua_tolstring may change +the value at the given index; +this confuses the next call to lua_next. + + +

    +See function next for the caveats of modifying +the table during its traversal. + + + + + +


    lua_Number

    +
    typedef ... lua_Number;
    + +

    +The type of floats in Lua. + + +

    +By default this type is double, +but that can be changed to a single float or a long double. +(See LUA_FLOAT_TYPE in luaconf.h.) + + + + + +


    lua_numbertointeger

    +
    int lua_numbertointeger (lua_Number n, lua_Integer *p);
    + +

    +Converts a Lua float to a Lua integer. +This macro assumes that n has an integral value. +If that value is within the range of Lua integers, +it is converted to an integer and assigned to *p. +The macro results in a boolean indicating whether the +conversion was successful. +(Note that this range test can be tricky to do +correctly without this macro, +due to roundings.) + + +

    +This macro may evaluate its arguments more than once. + + + + + +


    lua_pcall

    +[-(nargs + 1), +(nresults|1), –] +

    int lua_pcall (lua_State *L, int nargs, int nresults, int msgh);
    + +

    +Calls a function in protected mode. + + +

    +Both nargs and nresults have the same meaning as +in lua_call. +If there are no errors during the call, +lua_pcall behaves exactly like lua_call. +However, if there is any error, +lua_pcall catches it, +pushes a single value on the stack (the error object), +and returns an error code. +Like lua_call, +lua_pcall always removes the function +and its arguments from the stack. + + +

    +If msgh is 0, +then the error object returned on the stack +is exactly the original error object. +Otherwise, msgh is the stack index of a +message handler. +(This index cannot be a pseudo-index.) +In case of runtime errors, +this function will be called with the error object +and its return value will be the object +returned on the stack by lua_pcall. + + +

    +Typically, the message handler is used to add more debug +information to the error object, such as a stack traceback. +Such information cannot be gathered after the return of lua_pcall, +since by then the stack has unwound. + + +

    +The lua_pcall function returns one of the following constants +(defined in lua.h): + +

      + +
    • LUA_OK (0): +success.
    • + +
    • LUA_ERRRUN: +a runtime error. +
    • + +
    • LUA_ERRMEM: +memory allocation error. +For such errors, Lua does not call the message handler. +
    • + +
    • LUA_ERRERR: +error while running the message handler. +
    • + +
    • LUA_ERRGCMM: +error while running a __gc metamethod. +For such errors, Lua does not call the message handler +(as this kind of error typically has no relation +with the function being called). +
    • + +
    + + + + +

    lua_pcallk

    +[-(nargs + 1), +(nresults|1), –] +

    int lua_pcallk (lua_State *L,
    +                int nargs,
    +                int nresults,
    +                int msgh,
    +                lua_KContext ctx,
    +                lua_KFunction k);
    + +

    +This function behaves exactly like lua_pcall, +but allows the called function to yield (see §4.7). + + + + + +


    lua_pop

    +[-n, +0, –] +

    void lua_pop (lua_State *L, int n);
    + +

    +Pops n elements from the stack. + + + + + +


    lua_pushboolean

    +[-0, +1, –] +

    void lua_pushboolean (lua_State *L, int b);
    + +

    +Pushes a boolean value with value b onto the stack. + + + + + +


    lua_pushcclosure

    +[-n, +1, m] +

    void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
    + +

    +Pushes a new C closure onto the stack. + + +

    +When a C function is created, +it is possible to associate some values with it, +thus creating a C closure (see §4.4); +these values are then accessible to the function whenever it is called. +To associate values with a C function, +first these values must be pushed onto the stack +(when there are multiple values, the first value is pushed first). +Then lua_pushcclosure +is called to create and push the C function onto the stack, +with the argument n telling how many values will be +associated with the function. +lua_pushcclosure also pops these values from the stack. + + +

    +The maximum value for n is 255. + + +

    +When n is zero, +this function creates a light C function, +which is just a pointer to the C function. +In that case, it never raises a memory error. + + + + + +


    lua_pushcfunction

    +[-0, +1, –] +

    void lua_pushcfunction (lua_State *L, lua_CFunction f);
    + +

    +Pushes a C function onto the stack. +This function receives a pointer to a C function +and pushes onto the stack a Lua value of type function that, +when called, invokes the corresponding C function. + + +

    +Any function to be callable by Lua must +follow the correct protocol to receive its parameters +and return its results (see lua_CFunction). + + + + + +


    lua_pushfstring

    +[-0, +1, e] +

    const char *lua_pushfstring (lua_State *L, const char *fmt, ...);
    + +

    +Pushes onto the stack a formatted string +and returns a pointer to this string. +It is similar to the ISO C function sprintf, +but has some important differences: + +

      + +
    • +You do not have to allocate space for the result: +the result is a Lua string and Lua takes care of memory allocation +(and deallocation, through garbage collection). +
    • + +
    • +The conversion specifiers are quite restricted. +There are no flags, widths, or precisions. +The conversion specifiers can only be +'%%' (inserts the character '%'), +'%s' (inserts a zero-terminated string, with no size restrictions), +'%f' (inserts a lua_Number), +'%I' (inserts a lua_Integer), +'%p' (inserts a pointer as a hexadecimal numeral), +'%d' (inserts an int), +'%c' (inserts an int as a one-byte character), and +'%U' (inserts a long int as a UTF-8 byte sequence). +
    • + +
    + +

    +Unlike other push functions, +this function checks for the stack space it needs, +including the slot for its result. + + + + + +


    lua_pushglobaltable

    +[-0, +1, –] +

    void lua_pushglobaltable (lua_State *L);
    + +

    +Pushes the global environment onto the stack. + + + + + +


    lua_pushinteger

    +[-0, +1, –] +

    void lua_pushinteger (lua_State *L, lua_Integer n);
    + +

    +Pushes an integer with value n onto the stack. + + + + + +


    lua_pushlightuserdata

    +[-0, +1, –] +

    void lua_pushlightuserdata (lua_State *L, void *p);
    + +

    +Pushes a light userdata onto the stack. + + +

    +Userdata represent C values in Lua. +A light userdata represents a pointer, a void*. +It is a value (like a number): +you do not create it, it has no individual metatable, +and it is not collected (as it was never created). +A light userdata is equal to "any" +light userdata with the same C address. + + + + + +


    lua_pushliteral

    +[-0, +1, m] +

    const char *lua_pushliteral (lua_State *L, const char *s);
    + +

    +This macro is equivalent to lua_pushstring, +but should be used only when s is a literal string. + + + + + +


    lua_pushlstring

    +[-0, +1, m] +

    const char *lua_pushlstring (lua_State *L, const char *s, size_t len);
    + +

    +Pushes the string pointed to by s with size len +onto the stack. +Lua makes (or reuses) an internal copy of the given string, +so the memory at s can be freed or reused immediately after +the function returns. +The string can contain any binary data, +including embedded zeros. + + +

    +Returns a pointer to the internal copy of the string. + + + + + +


    lua_pushnil

    +[-0, +1, –] +

    void lua_pushnil (lua_State *L);
    + +

    +Pushes a nil value onto the stack. + + + + + +


    lua_pushnumber

    +[-0, +1, –] +

    void lua_pushnumber (lua_State *L, lua_Number n);
    + +

    +Pushes a float with value n onto the stack. + + + + + +


    lua_pushstring

    +[-0, +1, m] +

    const char *lua_pushstring (lua_State *L, const char *s);
    + +

    +Pushes the zero-terminated string pointed to by s +onto the stack. +Lua makes (or reuses) an internal copy of the given string, +so the memory at s can be freed or reused immediately after +the function returns. + + +

    +Returns a pointer to the internal copy of the string. + + +

    +If s is NULL, pushes nil and returns NULL. + + + + + +


    lua_pushthread

    +[-0, +1, –] +

    int lua_pushthread (lua_State *L);
    + +

    +Pushes the thread represented by L onto the stack. +Returns 1 if this thread is the main thread of its state. + + + + + +


    lua_pushvalue

    +[-0, +1, –] +

    void lua_pushvalue (lua_State *L, int index);
    + +

    +Pushes a copy of the element at the given index +onto the stack. + + + + + +


    lua_pushvfstring

    +[-0, +1, m] +

    const char *lua_pushvfstring (lua_State *L,
    +                              const char *fmt,
    +                              va_list argp);
    + +

    +Equivalent to lua_pushfstring, except that it receives a va_list +instead of a variable number of arguments. + + + + + +


    lua_rawequal

    +[-0, +0, –] +

    int lua_rawequal (lua_State *L, int index1, int index2);
    + +

    +Returns 1 if the two values in indices index1 and +index2 are primitively equal +(that is, without calling the __eq metamethod). +Otherwise returns 0. +Also returns 0 if any of the indices are not valid. + + + + + +


    lua_rawget

    +[-1, +1, –] +

    int lua_rawget (lua_State *L, int index);
    + +

    +Similar to lua_gettable, but does a raw access +(i.e., without metamethods). + + + + + +


    lua_rawgeti

    +[-0, +1, –] +

    int lua_rawgeti (lua_State *L, int index, lua_Integer n);
    + +

    +Pushes onto the stack the value t[n], +where t is the table at the given index. +The access is raw, +that is, it does not invoke the __index metamethod. + + +

    +Returns the type of the pushed value. + + + + + +


    lua_rawgetp

    +[-0, +1, –] +

    int lua_rawgetp (lua_State *L, int index, const void *p);
    + +

    +Pushes onto the stack the value t[k], +where t is the table at the given index and +k is the pointer p represented as a light userdata. +The access is raw; +that is, it does not invoke the __index metamethod. + + +

    +Returns the type of the pushed value. + + + + + +


    lua_rawlen

    +[-0, +0, –] +

    size_t lua_rawlen (lua_State *L, int index);
    + +

    +Returns the raw "length" of the value at the given index: +for strings, this is the string length; +for tables, this is the result of the length operator ('#') +with no metamethods; +for userdata, this is the size of the block of memory allocated +for the userdata; +for other values, it is 0. + + + + + +


    lua_rawset

    +[-2, +0, m] +

    void lua_rawset (lua_State *L, int index);
    + +

    +Similar to lua_settable, but does a raw assignment +(i.e., without metamethods). + + + + + +


    lua_rawseti

    +[-1, +0, m] +

    void lua_rawseti (lua_State *L, int index, lua_Integer i);
    + +

    +Does the equivalent of t[i] = v, +where t is the table at the given index +and v is the value at the top of the stack. + + +

    +This function pops the value from the stack. +The assignment is raw, +that is, it does not invoke the __newindex metamethod. + + + + + +


    lua_rawsetp

    +[-1, +0, m] +

    void lua_rawsetp (lua_State *L, int index, const void *p);
    + +

    +Does the equivalent of t[p] = v, +where t is the table at the given index, +p is encoded as a light userdata, +and v is the value at the top of the stack. + + +

    +This function pops the value from the stack. +The assignment is raw, +that is, it does not invoke __newindex metamethod. + + + + + +


    lua_Reader

    +
    typedef const char * (*lua_Reader) (lua_State *L,
    +                                    void *data,
    +                                    size_t *size);
    + +

    +The reader function used by lua_load. +Every time it needs another piece of the chunk, +lua_load calls the reader, +passing along its data parameter. +The reader must return a pointer to a block of memory +with a new piece of the chunk +and set size to the block size. +The block must exist until the reader function is called again. +To signal the end of the chunk, +the reader must return NULL or set size to zero. +The reader function may return pieces of any size greater than zero. + + + + + +


    lua_register

    +[-0, +0, e] +

    void lua_register (lua_State *L, const char *name, lua_CFunction f);
    + +

    +Sets the C function f as the new value of global name. +It is defined as a macro: + +

    +     #define lua_register(L,n,f) \
    +            (lua_pushcfunction(L, f), lua_setglobal(L, n))
    +
    + + + + +

    lua_remove

    +[-1, +0, –] +

    void lua_remove (lua_State *L, int index);
    + +

    +Removes the element at the given valid index, +shifting down the elements above this index to fill the gap. +This function cannot be called with a pseudo-index, +because a pseudo-index is not an actual stack position. + + + + + +


    lua_replace

    +[-1, +0, –] +

    void lua_replace (lua_State *L, int index);
    + +

    +Moves the top element into the given valid index +without shifting any element +(therefore replacing the value at that given index), +and then pops the top element. + + + + + +


    lua_resume

    +[-?, +?, –] +

    int lua_resume (lua_State *L, lua_State *from, int nargs);
    + +

    +Starts and resumes a coroutine in the given thread L. + + +

    +To start a coroutine, +you push onto the thread stack the main function plus any arguments; +then you call lua_resume, +with nargs being the number of arguments. +This call returns when the coroutine suspends or finishes its execution. +When it returns, the stack contains all values passed to lua_yield, +or all values returned by the body function. +lua_resume returns +LUA_YIELD if the coroutine yields, +LUA_OK if the coroutine finishes its execution +without errors, +or an error code in case of errors (see lua_pcall). + + +

    +In case of errors, +the stack is not unwound, +so you can use the debug API over it. +The error object is on the top of the stack. + + +

    +To resume a coroutine, +you remove any results from the last lua_yield, +put on its stack only the values to +be passed as results from yield, +and then call lua_resume. + + +

    +The parameter from represents the coroutine that is resuming L. +If there is no such coroutine, +this parameter can be NULL. + + + + + +


    lua_rotate

    +[-0, +0, –] +

    void lua_rotate (lua_State *L, int idx, int n);
    + +

    +Rotates the stack elements between the valid index idx +and the top of the stack. +The elements are rotated n positions in the direction of the top, +for a positive n, +or -n positions in the direction of the bottom, +for a negative n. +The absolute value of n must not be greater than the size +of the slice being rotated. +This function cannot be called with a pseudo-index, +because a pseudo-index is not an actual stack position. + + + + + +


    lua_setallocf

    +[-0, +0, –] +

    void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
    + +

    +Changes the allocator function of a given state to f +with user data ud. + + + + + +


    lua_setfield

    +[-1, +0, e] +

    void lua_setfield (lua_State *L, int index, const char *k);
    + +

    +Does the equivalent to t[k] = v, +where t is the value at the given index +and v is the value at the top of the stack. + + +

    +This function pops the value from the stack. +As in Lua, this function may trigger a metamethod +for the "newindex" event (see §2.4). + + + + + +


    lua_setglobal

    +[-1, +0, e] +

    void lua_setglobal (lua_State *L, const char *name);
    + +

    +Pops a value from the stack and +sets it as the new value of global name. + + + + + +


    lua_seti

    +[-1, +0, e] +

    void lua_seti (lua_State *L, int index, lua_Integer n);
    + +

    +Does the equivalent to t[n] = v, +where t is the value at the given index +and v is the value at the top of the stack. + + +

    +This function pops the value from the stack. +As in Lua, this function may trigger a metamethod +for the "newindex" event (see §2.4). + + + + + +


    lua_setmetatable

    +[-1, +0, –] +

    void lua_setmetatable (lua_State *L, int index);
    + +

    +Pops a table from the stack and +sets it as the new metatable for the value at the given index. + + + + + +


    lua_settable

    +[-2, +0, e] +

    void lua_settable (lua_State *L, int index);
    + +

    +Does the equivalent to t[k] = v, +where t is the value at the given index, +v is the value at the top of the stack, +and k is the value just below the top. + + +

    +This function pops both the key and the value from the stack. +As in Lua, this function may trigger a metamethod +for the "newindex" event (see §2.4). + + + + + +


    lua_settop

    +[-?, +?, –] +

    void lua_settop (lua_State *L, int index);
    + +

    +Accepts any index, or 0, +and sets the stack top to this index. +If the new top is larger than the old one, +then the new elements are filled with nil. +If index is 0, then all stack elements are removed. + + + + + +


    lua_setuservalue

    +[-1, +0, –] +

    void lua_setuservalue (lua_State *L, int index);
    + +

    +Pops a value from the stack and sets it as +the new value associated to the full userdata at the given index. + + + + + +


    lua_State

    +
    typedef struct lua_State lua_State;
    + +

    +An opaque structure that points to a thread and indirectly +(through the thread) to the whole state of a Lua interpreter. +The Lua library is fully reentrant: +it has no global variables. +All information about a state is accessible through this structure. + + +

    +A pointer to this structure must be passed as the first argument to +every function in the library, except to lua_newstate, +which creates a Lua state from scratch. + + + + + +


    lua_status

    +[-0, +0, –] +

    int lua_status (lua_State *L);
    + +

    +Returns the status of the thread L. + + +

    +The status can be 0 (LUA_OK) for a normal thread, +an error code if the thread finished the execution +of a lua_resume with an error, +or LUA_YIELD if the thread is suspended. + + +

    +You can only call functions in threads with status LUA_OK. +You can resume threads with status LUA_OK +(to start a new coroutine) or LUA_YIELD +(to resume a coroutine). + + + + + +


    lua_stringtonumber

    +[-0, +1, –] +

    size_t lua_stringtonumber (lua_State *L, const char *s);
    + +

    +Converts the zero-terminated string s to a number, +pushes that number into the stack, +and returns the total size of the string, +that is, its length plus one. +The conversion can result in an integer or a float, +according to the lexical conventions of Lua (see §3.1). +The string may have leading and trailing spaces and a sign. +If the string is not a valid numeral, +returns 0 and pushes nothing. +(Note that the result can be used as a boolean, +true if the conversion succeeds.) + + + + + +


    lua_toboolean

    +[-0, +0, –] +

    int lua_toboolean (lua_State *L, int index);
    + +

    +Converts the Lua value at the given index to a C boolean +value (0 or 1). +Like all tests in Lua, +lua_toboolean returns true for any Lua value +different from false and nil; +otherwise it returns false. +(If you want to accept only actual boolean values, +use lua_isboolean to test the value's type.) + + + + + +


    lua_tocfunction

    +[-0, +0, –] +

    lua_CFunction lua_tocfunction (lua_State *L, int index);
    + +

    +Converts a value at the given index to a C function. +That value must be a C function; +otherwise, returns NULL. + + + + + +


    lua_tointeger

    +[-0, +0, –] +

    lua_Integer lua_tointeger (lua_State *L, int index);
    + +

    +Equivalent to lua_tointegerx with isnum equal to NULL. + + + + + +


    lua_tointegerx

    +[-0, +0, –] +

    lua_Integer lua_tointegerx (lua_State *L, int index, int *isnum);
    + +

    +Converts the Lua value at the given index +to the signed integral type lua_Integer. +The Lua value must be an integer, +or a number or string convertible to an integer (see §3.4.3); +otherwise, lua_tointegerx returns 0. + + +

    +If isnum is not NULL, +its referent is assigned a boolean value that +indicates whether the operation succeeded. + + + + + +


    lua_tolstring

    +[-0, +0, m] +

    const char *lua_tolstring (lua_State *L, int index, size_t *len);
    + +

    +Converts the Lua value at the given index to a C string. +If len is not NULL, +it sets *len with the string length. +The Lua value must be a string or a number; +otherwise, the function returns NULL. +If the value is a number, +then lua_tolstring also +changes the actual value in the stack to a string. +(This change confuses lua_next +when lua_tolstring is applied to keys during a table traversal.) + + +

    +lua_tolstring returns a pointer +to a string inside the Lua state. +This string always has a zero ('\0') +after its last character (as in C), +but can contain other zeros in its body. + + +

    +Because Lua has garbage collection, +there is no guarantee that the pointer returned by lua_tolstring +will be valid after the corresponding Lua value is removed from the stack. + + + + + +


    lua_tonumber

    +[-0, +0, –] +

    lua_Number lua_tonumber (lua_State *L, int index);
    + +

    +Equivalent to lua_tonumberx with isnum equal to NULL. + + + + + +


    lua_tonumberx

    +[-0, +0, –] +

    lua_Number lua_tonumberx (lua_State *L, int index, int *isnum);
    + +

    +Converts the Lua value at the given index +to the C type lua_Number (see lua_Number). +The Lua value must be a number or a string convertible to a number +(see §3.4.3); +otherwise, lua_tonumberx returns 0. + + +

    +If isnum is not NULL, +its referent is assigned a boolean value that +indicates whether the operation succeeded. + + + + + +


    lua_topointer

    +[-0, +0, –] +

    const void *lua_topointer (lua_State *L, int index);
    + +

    +Converts the value at the given index to a generic +C pointer (void*). +The value can be a userdata, a table, a thread, or a function; +otherwise, lua_topointer returns NULL. +Different objects will give different pointers. +There is no way to convert the pointer back to its original value. + + +

    +Typically this function is used only for hashing and debug information. + + + + + +


    lua_tostring

    +[-0, +0, m] +

    const char *lua_tostring (lua_State *L, int index);
    + +

    +Equivalent to lua_tolstring with len equal to NULL. + + + + + +


    lua_tothread

    +[-0, +0, –] +

    lua_State *lua_tothread (lua_State *L, int index);
    + +

    +Converts the value at the given index to a Lua thread +(represented as lua_State*). +This value must be a thread; +otherwise, the function returns NULL. + + + + + +


    lua_touserdata

    +[-0, +0, –] +

    void *lua_touserdata (lua_State *L, int index);
    + +

    +If the value at the given index is a full userdata, +returns its block address. +If the value is a light userdata, +returns its pointer. +Otherwise, returns NULL. + + + + + +


    lua_type

    +[-0, +0, –] +

    int lua_type (lua_State *L, int index);
    + +

    +Returns the type of the value in the given valid index, +or LUA_TNONE for a non-valid (but acceptable) index. +The types returned by lua_type are coded by the following constants +defined in lua.h: +LUA_TNIL (0), +LUA_TNUMBER, +LUA_TBOOLEAN, +LUA_TSTRING, +LUA_TTABLE, +LUA_TFUNCTION, +LUA_TUSERDATA, +LUA_TTHREAD, +and +LUA_TLIGHTUSERDATA. + + + + + +


    lua_typename

    +[-0, +0, –] +

    const char *lua_typename (lua_State *L, int tp);
    + +

    +Returns the name of the type encoded by the value tp, +which must be one the values returned by lua_type. + + + + + +


    lua_Unsigned

    +
    typedef ... lua_Unsigned;
    + +

    +The unsigned version of lua_Integer. + + + + + +


    lua_upvalueindex

    +[-0, +0, –] +

    int lua_upvalueindex (int i);
    + +

    +Returns the pseudo-index that represents the i-th upvalue of +the running function (see §4.4). + + + + + +


    lua_version

    +[-0, +0, –] +

    const lua_Number *lua_version (lua_State *L);
    + +

    +Returns the address of the version number +(a C static variable) +stored in the Lua core. +When called with a valid lua_State, +returns the address of the version used to create that state. +When called with NULL, +returns the address of the version running the call. + + + + + +


    lua_Writer

    +
    typedef int (*lua_Writer) (lua_State *L,
    +                           const void* p,
    +                           size_t sz,
    +                           void* ud);
    + +

    +The type of the writer function used by lua_dump. +Every time it produces another piece of chunk, +lua_dump calls the writer, +passing along the buffer to be written (p), +its size (sz), +and the data parameter supplied to lua_dump. + + +

    +The writer returns an error code: +0 means no errors; +any other value means an error and stops lua_dump from +calling the writer again. + + + + + +


    lua_xmove

    +[-?, +?, –] +

    void lua_xmove (lua_State *from, lua_State *to, int n);
    + +

    +Exchange values between different threads of the same state. + + +

    +This function pops n values from the stack from, +and pushes them onto the stack to. + + + + + +


    lua_yield

    +[-?, +?, e] +

    int lua_yield (lua_State *L, int nresults);
    + +

    +This function is equivalent to lua_yieldk, +but it has no continuation (see §4.7). +Therefore, when the thread resumes, +it continues the function that called +the function calling lua_yield. + + + + + +


    lua_yieldk

    +[-?, +?, e] +

    int lua_yieldk (lua_State *L,
    +                int nresults,
    +                lua_KContext ctx,
    +                lua_KFunction k);
    + +

    +Yields a coroutine (thread). + + +

    +When a C function calls lua_yieldk, +the running coroutine suspends its execution, +and the call to lua_resume that started this coroutine returns. +The parameter nresults is the number of values from the stack +that will be passed as results to lua_resume. + + +

    +When the coroutine is resumed again, +Lua calls the given continuation function k to continue +the execution of the C function that yielded (see §4.7). +This continuation function receives the same stack +from the previous function, +with the n results removed and +replaced by the arguments passed to lua_resume. +Moreover, +the continuation function receives the value ctx +that was passed to lua_yieldk. + + +

    +Usually, this function does not return; +when the coroutine eventually resumes, +it continues executing the continuation function. +However, there is one special case, +which is when this function is called +from inside a line or a count hook (see §4.9). +In that case, lua_yieldk should be called with no continuation +(probably in the form of lua_yield) and no results, +and the hook should return immediately after the call. +Lua will yield and, +when the coroutine resumes again, +it will continue the normal execution +of the (Lua) function that triggered the hook. + + +

    +This function can raise an error if it is called from a thread +with a pending C call with no continuation function, +or it is called from a thread that is not running inside a resume +(e.g., the main thread). + + + + + + + +

    4.9 – The Debug Interface

    + +

    +Lua has no built-in debugging facilities. +Instead, it offers a special interface +by means of functions and hooks. +This interface allows the construction of different +kinds of debuggers, profilers, and other tools +that need "inside information" from the interpreter. + + + +


    lua_Debug

    +
    typedef struct lua_Debug {
    +  int event;
    +  const char *name;           /* (n) */
    +  const char *namewhat;       /* (n) */
    +  const char *what;           /* (S) */
    +  const char *source;         /* (S) */
    +  int currentline;            /* (l) */
    +  int linedefined;            /* (S) */
    +  int lastlinedefined;        /* (S) */
    +  unsigned char nups;         /* (u) number of upvalues */
    +  unsigned char nparams;      /* (u) number of parameters */
    +  char isvararg;              /* (u) */
    +  char istailcall;            /* (t) */
    +  char short_src[LUA_IDSIZE]; /* (S) */
    +  /* private part */
    +  other fields
    +} lua_Debug;
    + +

    +A structure used to carry different pieces of +information about a function or an activation record. +lua_getstack fills only the private part +of this structure, for later use. +To fill the other fields of lua_Debug with useful information, +call lua_getinfo. + + +

    +The fields of lua_Debug have the following meaning: + +

      + +
    • source: +the name of the chunk that created the function. +If source starts with a '@', +it means that the function was defined in a file where +the file name follows the '@'. +If source starts with a '=', +the remainder of its contents describe the source in a user-dependent manner. +Otherwise, +the function was defined in a string where +source is that string. +
    • + +
    • short_src: +a "printable" version of source, to be used in error messages. +
    • + +
    • linedefined: +the line number where the definition of the function starts. +
    • + +
    • lastlinedefined: +the line number where the definition of the function ends. +
    • + +
    • what: +the string "Lua" if the function is a Lua function, +"C" if it is a C function, +"main" if it is the main part of a chunk. +
    • + +
    • currentline: +the current line where the given function is executing. +When no line information is available, +currentline is set to -1. +
    • + +
    • name: +a reasonable name for the given function. +Because functions in Lua are first-class values, +they do not have a fixed name: +some functions can be the value of multiple global variables, +while others can be stored only in a table field. +The lua_getinfo function checks how the function was +called to find a suitable name. +If it cannot find a name, +then name is set to NULL. +
    • + +
    • namewhat: +explains the name field. +The value of namewhat can be +"global", "local", "method", +"field", "upvalue", or "" (the empty string), +according to how the function was called. +(Lua uses the empty string when no other option seems to apply.) +
    • + +
    • istailcall: +true if this function invocation was called by a tail call. +In this case, the caller of this level is not in the stack. +
    • + +
    • nups: +the number of upvalues of the function. +
    • + +
    • nparams: +the number of fixed parameters of the function +(always 0 for C functions). +
    • + +
    • isvararg: +true if the function is a vararg function +(always true for C functions). +
    • + +
    + + + + +

    lua_gethook

    +[-0, +0, –] +

    lua_Hook lua_gethook (lua_State *L);
    + +

    +Returns the current hook function. + + + + + +


    lua_gethookcount

    +[-0, +0, –] +

    int lua_gethookcount (lua_State *L);
    + +

    +Returns the current hook count. + + + + + +


    lua_gethookmask

    +[-0, +0, –] +

    int lua_gethookmask (lua_State *L);
    + +

    +Returns the current hook mask. + + + + + +


    lua_getinfo

    +[-(0|1), +(0|1|2), e] +

    int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
    + +

    +Gets information about a specific function or function invocation. + + +

    +To get information about a function invocation, +the parameter ar must be a valid activation record that was +filled by a previous call to lua_getstack or +given as argument to a hook (see lua_Hook). + + +

    +To get information about a function you push it onto the stack +and start the what string with the character '>'. +(In that case, +lua_getinfo pops the function from the top of the stack.) +For instance, to know in which line a function f was defined, +you can write the following code: + +

    +     lua_Debug ar;
    +     lua_getglobal(L, "f");  /* get global 'f' */
    +     lua_getinfo(L, ">S", &ar);
    +     printf("%d\n", ar.linedefined);
    +
    + +

    +Each character in the string what +selects some fields of the structure ar to be filled or +a value to be pushed on the stack: + +

      + +
    • 'n': fills in the field name and namewhat; +
    • + +
    • 'S': +fills in the fields source, short_src, +linedefined, lastlinedefined, and what; +
    • + +
    • 'l': fills in the field currentline; +
    • + +
    • 't': fills in the field istailcall; +
    • + +
    • 'u': fills in the fields +nups, nparams, and isvararg; +
    • + +
    • 'f': +pushes onto the stack the function that is +running at the given level; +
    • + +
    • 'L': +pushes onto the stack a table whose indices are the +numbers of the lines that are valid on the function. +(A valid line is a line with some associated code, +that is, a line where you can put a break point. +Non-valid lines include empty lines and comments.) + + +

      +If this option is given together with option 'f', +its table is pushed after the function. +

    • + +
    + +

    +This function returns 0 on error +(for instance, an invalid option in what). + + + + + +


    lua_getlocal

    +[-0, +(0|1), –] +

    const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
    + +

    +Gets information about a local variable of +a given activation record or a given function. + + +

    +In the first case, +the parameter ar must be a valid activation record that was +filled by a previous call to lua_getstack or +given as argument to a hook (see lua_Hook). +The index n selects which local variable to inspect; +see debug.getlocal for details about variable indices +and names. + + +

    +lua_getlocal pushes the variable's value onto the stack +and returns its name. + + +

    +In the second case, ar must be NULL and the function +to be inspected must be at the top of the stack. +In this case, only parameters of Lua functions are visible +(as there is no information about what variables are active) +and no values are pushed onto the stack. + + +

    +Returns NULL (and pushes nothing) +when the index is greater than +the number of active local variables. + + + + + +


    lua_getstack

    +[-0, +0, –] +

    int lua_getstack (lua_State *L, int level, lua_Debug *ar);
    + +

    +Gets information about the interpreter runtime stack. + + +

    +This function fills parts of a lua_Debug structure with +an identification of the activation record +of the function executing at a given level. +Level 0 is the current running function, +whereas level n+1 is the function that has called level n +(except for tail calls, which do not count on the stack). +When there are no errors, lua_getstack returns 1; +when called with a level greater than the stack depth, +it returns 0. + + + + + +


    lua_getupvalue

    +[-0, +(0|1), –] +

    const char *lua_getupvalue (lua_State *L, int funcindex, int n);
    + +

    +Gets information about the n-th upvalue +of the closure at index funcindex. +It pushes the upvalue's value onto the stack +and returns its name. +Returns NULL (and pushes nothing) +when the index n is greater than the number of upvalues. + + +

    +For C functions, this function uses the empty string "" +as a name for all upvalues. +(For Lua functions, +upvalues are the external local variables that the function uses, +and that are consequently included in its closure.) + + +

    +Upvalues have no particular order, +as they are active through the whole function. +They are numbered in an arbitrary order. + + + + + +


    lua_Hook

    +
    typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
    + +

    +Type for debugging hook functions. + + +

    +Whenever a hook is called, its ar argument has its field +event set to the specific event that triggered the hook. +Lua identifies these events with the following constants: +LUA_HOOKCALL, LUA_HOOKRET, +LUA_HOOKTAILCALL, LUA_HOOKLINE, +and LUA_HOOKCOUNT. +Moreover, for line events, the field currentline is also set. +To get the value of any other field in ar, +the hook must call lua_getinfo. + + +

    +For call events, event can be LUA_HOOKCALL, +the normal value, or LUA_HOOKTAILCALL, for a tail call; +in this case, there will be no corresponding return event. + + +

    +While Lua is running a hook, it disables other calls to hooks. +Therefore, if a hook calls back Lua to execute a function or a chunk, +this execution occurs without any calls to hooks. + + +

    +Hook functions cannot have continuations, +that is, they cannot call lua_yieldk, +lua_pcallk, or lua_callk with a non-null k. + + +

    +Hook functions can yield under the following conditions: +Only count and line events can yield; +to yield, a hook function must finish its execution +calling lua_yield with nresults equal to zero +(that is, with no values). + + + + + +


    lua_sethook

    +[-0, +0, –] +

    void lua_sethook (lua_State *L, lua_Hook f, int mask, int count);
    + +

    +Sets the debugging hook function. + + +

    +Argument f is the hook function. +mask specifies on which events the hook will be called: +it is formed by a bitwise OR of the constants +LUA_MASKCALL, +LUA_MASKRET, +LUA_MASKLINE, +and LUA_MASKCOUNT. +The count argument is only meaningful when the mask +includes LUA_MASKCOUNT. +For each event, the hook is called as explained below: + +

      + +
    • The call hook: is called when the interpreter calls a function. +The hook is called just after Lua enters the new function, +before the function gets its arguments. +
    • + +
    • The return hook: is called when the interpreter returns from a function. +The hook is called just before Lua leaves the function. +There is no standard way to access the values +to be returned by the function. +
    • + +
    • The line hook: is called when the interpreter is about to +start the execution of a new line of code, +or when it jumps back in the code (even to the same line). +(This event only happens while Lua is executing a Lua function.) +
    • + +
    • The count hook: is called after the interpreter executes every +count instructions. +(This event only happens while Lua is executing a Lua function.) +
    • + +
    + +

    +A hook is disabled by setting mask to zero. + + + + + +


    lua_setlocal

    +[-(0|1), +0, –] +

    const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
    + +

    +Sets the value of a local variable of a given activation record. +It assigns the value at the top of the stack +to the variable and returns its name. +It also pops the value from the stack. + + +

    +Returns NULL (and pops nothing) +when the index is greater than +the number of active local variables. + + +

    +Parameters ar and n are as in function lua_getlocal. + + + + + +


    lua_setupvalue

    +[-(0|1), +0, –] +

    const char *lua_setupvalue (lua_State *L, int funcindex, int n);
    + +

    +Sets the value of a closure's upvalue. +It assigns the value at the top of the stack +to the upvalue and returns its name. +It also pops the value from the stack. + + +

    +Returns NULL (and pops nothing) +when the index n is greater than the number of upvalues. + + +

    +Parameters funcindex and n are as in function lua_getupvalue. + + + + + +


    lua_upvalueid

    +[-0, +0, –] +

    void *lua_upvalueid (lua_State *L, int funcindex, int n);
    + +

    +Returns a unique identifier for the upvalue numbered n +from the closure at index funcindex. + + +

    +These unique identifiers allow a program to check whether different +closures share upvalues. +Lua closures that share an upvalue +(that is, that access a same external local variable) +will return identical ids for those upvalue indices. + + +

    +Parameters funcindex and n are as in function lua_getupvalue, +but n cannot be greater than the number of upvalues. + + + + + +


    lua_upvaluejoin

    +[-0, +0, –] +

    void lua_upvaluejoin (lua_State *L, int funcindex1, int n1,
    +                                    int funcindex2, int n2);
    + +

    +Make the n1-th upvalue of the Lua closure at index funcindex1 +refer to the n2-th upvalue of the Lua closure at index funcindex2. + + + + + + + +

    5 – The Auxiliary Library

    + +

    + +The auxiliary library provides several convenient functions +to interface C with Lua. +While the basic API provides the primitive functions for all +interactions between C and Lua, +the auxiliary library provides higher-level functions for some +common tasks. + + +

    +All functions and types from the auxiliary library +are defined in header file lauxlib.h and +have a prefix luaL_. + + +

    +All functions in the auxiliary library are built on +top of the basic API, +and so they provide nothing that cannot be done with that API. +Nevertheless, the use of the auxiliary library ensures +more consistency to your code. + + +

    +Several functions in the auxiliary library use internally some +extra stack slots. +When a function in the auxiliary library uses less than five slots, +it does not check the stack size; +it simply assumes that there are enough slots. + + +

    +Several functions in the auxiliary library are used to +check C function arguments. +Because the error message is formatted for arguments +(e.g., "bad argument #1"), +you should not use these functions for other stack values. + + +

    +Functions called luaL_check* +always raise an error if the check is not satisfied. + + + +

    5.1 – Functions and Types

    + +

    +Here we list all functions and types from the auxiliary library +in alphabetical order. + + + +


    luaL_addchar

    +[-?, +?, m] +

    void luaL_addchar (luaL_Buffer *B, char c);
    + +

    +Adds the byte c to the buffer B +(see luaL_Buffer). + + + + + +


    luaL_addlstring

    +[-?, +?, m] +

    void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
    + +

    +Adds the string pointed to by s with length l to +the buffer B +(see luaL_Buffer). +The string can contain embedded zeros. + + + + + +


    luaL_addsize

    +[-?, +?, –] +

    void luaL_addsize (luaL_Buffer *B, size_t n);
    + +

    +Adds to the buffer B (see luaL_Buffer) +a string of length n previously copied to the +buffer area (see luaL_prepbuffer). + + + + + +


    luaL_addstring

    +[-?, +?, m] +

    void luaL_addstring (luaL_Buffer *B, const char *s);
    + +

    +Adds the zero-terminated string pointed to by s +to the buffer B +(see luaL_Buffer). + + + + + +


    luaL_addvalue

    +[-1, +?, m] +

    void luaL_addvalue (luaL_Buffer *B);
    + +

    +Adds the value at the top of the stack +to the buffer B +(see luaL_Buffer). +Pops the value. + + +

    +This is the only function on string buffers that can (and must) +be called with an extra element on the stack, +which is the value to be added to the buffer. + + + + + +


    luaL_argcheck

    +[-0, +0, v] +

    void luaL_argcheck (lua_State *L,
    +                    int cond,
    +                    int arg,
    +                    const char *extramsg);
    + +

    +Checks whether cond is true. +If it is not, raises an error with a standard message (see luaL_argerror). + + + + + +


    luaL_argerror

    +[-0, +0, v] +

    int luaL_argerror (lua_State *L, int arg, const char *extramsg);
    + +

    +Raises an error reporting a problem with argument arg +of the C function that called it, +using a standard message +that includes extramsg as a comment: + +

    +     bad argument #arg to 'funcname' (extramsg)
    +

    +This function never returns. + + + + + +


    luaL_Buffer

    +
    typedef struct luaL_Buffer luaL_Buffer;
    + +

    +Type for a string buffer. + + +

    +A string buffer allows C code to build Lua strings piecemeal. +Its pattern of use is as follows: + +

      + +
    • First declare a variable b of type luaL_Buffer.
    • + +
    • Then initialize it with a call luaL_buffinit(L, &b).
    • + +
    • +Then add string pieces to the buffer calling any of +the luaL_add* functions. +
    • + +
    • +Finish by calling luaL_pushresult(&b). +This call leaves the final string on the top of the stack. +
    • + +
    + +

    +If you know beforehand the total size of the resulting string, +you can use the buffer like this: + +

      + +
    • First declare a variable b of type luaL_Buffer.
    • + +
    • Then initialize it and preallocate a space of +size sz with a call luaL_buffinitsize(L, &b, sz).
    • + +
    • Then copy the string into that space.
    • + +
    • +Finish by calling luaL_pushresultsize(&b, sz), +where sz is the total size of the resulting string +copied into that space. +
    • + +
    + +

    +During its normal operation, +a string buffer uses a variable number of stack slots. +So, while using a buffer, you cannot assume that you know where +the top of the stack is. +You can use the stack between successive calls to buffer operations +as long as that use is balanced; +that is, +when you call a buffer operation, +the stack is at the same level +it was immediately after the previous buffer operation. +(The only exception to this rule is luaL_addvalue.) +After calling luaL_pushresult the stack is back to its +level when the buffer was initialized, +plus the final string on its top. + + + + + +


    luaL_buffinit

    +[-0, +0, –] +

    void luaL_buffinit (lua_State *L, luaL_Buffer *B);
    + +

    +Initializes a buffer B. +This function does not allocate any space; +the buffer must be declared as a variable +(see luaL_Buffer). + + + + + +


    luaL_buffinitsize

    +[-?, +?, m] +

    char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz);
    + +

    +Equivalent to the sequence +luaL_buffinit, luaL_prepbuffsize. + + + + + +


    luaL_callmeta

    +[-0, +(0|1), e] +

    int luaL_callmeta (lua_State *L, int obj, const char *e);
    + +

    +Calls a metamethod. + + +

    +If the object at index obj has a metatable and this +metatable has a field e, +this function calls this field passing the object as its only argument. +In this case this function returns true and pushes onto the +stack the value returned by the call. +If there is no metatable or no metamethod, +this function returns false (without pushing any value on the stack). + + + + + +


    luaL_checkany

    +[-0, +0, v] +

    void luaL_checkany (lua_State *L, int arg);
    + +

    +Checks whether the function has an argument +of any type (including nil) at position arg. + + + + + +


    luaL_checkinteger

    +[-0, +0, v] +

    lua_Integer luaL_checkinteger (lua_State *L, int arg);
    + +

    +Checks whether the function argument arg is an integer +(or can be converted to an integer) +and returns this integer cast to a lua_Integer. + + + + + +


    luaL_checklstring

    +[-0, +0, v] +

    const char *luaL_checklstring (lua_State *L, int arg, size_t *l);
    + +

    +Checks whether the function argument arg is a string +and returns this string; +if l is not NULL fills *l +with the string's length. + + +

    +This function uses lua_tolstring to get its result, +so all conversions and caveats of that function apply here. + + + + + +


    luaL_checknumber

    +[-0, +0, v] +

    lua_Number luaL_checknumber (lua_State *L, int arg);
    + +

    +Checks whether the function argument arg is a number +and returns this number. + + + + + +


    luaL_checkoption

    +[-0, +0, v] +

    int luaL_checkoption (lua_State *L,
    +                      int arg,
    +                      const char *def,
    +                      const char *const lst[]);
    + +

    +Checks whether the function argument arg is a string and +searches for this string in the array lst +(which must be NULL-terminated). +Returns the index in the array where the string was found. +Raises an error if the argument is not a string or +if the string cannot be found. + + +

    +If def is not NULL, +the function uses def as a default value when +there is no argument arg or when this argument is nil. + + +

    +This is a useful function for mapping strings to C enums. +(The usual convention in Lua libraries is +to use strings instead of numbers to select options.) + + + + + +


    luaL_checkstack

    +[-0, +0, v] +

    void luaL_checkstack (lua_State *L, int sz, const char *msg);
    + +

    +Grows the stack size to top + sz elements, +raising an error if the stack cannot grow to that size. +msg is an additional text to go into the error message +(or NULL for no additional text). + + + + + +


    luaL_checkstring

    +[-0, +0, v] +

    const char *luaL_checkstring (lua_State *L, int arg);
    + +

    +Checks whether the function argument arg is a string +and returns this string. + + +

    +This function uses lua_tolstring to get its result, +so all conversions and caveats of that function apply here. + + + + + +


    luaL_checktype

    +[-0, +0, v] +

    void luaL_checktype (lua_State *L, int arg, int t);
    + +

    +Checks whether the function argument arg has type t. +See lua_type for the encoding of types for t. + + + + + +


    luaL_checkudata

    +[-0, +0, v] +

    void *luaL_checkudata (lua_State *L, int arg, const char *tname);
    + +

    +Checks whether the function argument arg is a userdata +of the type tname (see luaL_newmetatable) and +returns the userdata address (see lua_touserdata). + + + + + +


    luaL_checkversion

    +[-0, +0, v] +

    void luaL_checkversion (lua_State *L);
    + +

    +Checks whether the core running the call, +the core that created the Lua state, +and the code making the call are all using the same version of Lua. +Also checks whether the core running the call +and the core that created the Lua state +are using the same address space. + + + + + +


    luaL_dofile

    +[-0, +?, e] +

    int luaL_dofile (lua_State *L, const char *filename);
    + +

    +Loads and runs the given file. +It is defined as the following macro: + +

    +     (luaL_loadfile(L, filename) || lua_pcall(L, 0, LUA_MULTRET, 0))
    +

    +It returns false if there are no errors +or true in case of errors. + + + + + +


    luaL_dostring

    +[-0, +?, –] +

    int luaL_dostring (lua_State *L, const char *str);
    + +

    +Loads and runs the given string. +It is defined as the following macro: + +

    +     (luaL_loadstring(L, str) || lua_pcall(L, 0, LUA_MULTRET, 0))
    +

    +It returns false if there are no errors +or true in case of errors. + + + + + +


    luaL_error

    +[-0, +0, v] +

    int luaL_error (lua_State *L, const char *fmt, ...);
    + +

    +Raises an error. +The error message format is given by fmt +plus any extra arguments, +following the same rules of lua_pushfstring. +It also adds at the beginning of the message the file name and +the line number where the error occurred, +if this information is available. + + +

    +This function never returns, +but it is an idiom to use it in C functions +as return luaL_error(args). + + + + + +


    luaL_execresult

    +[-0, +3, m] +

    int luaL_execresult (lua_State *L, int stat);
    + +

    +This function produces the return values for +process-related functions in the standard library +(os.execute and io.close). + + + + + +


    luaL_fileresult

    +[-0, +(1|3), m] +

    int luaL_fileresult (lua_State *L, int stat, const char *fname);
    + +

    +This function produces the return values for +file-related functions in the standard library +(io.open, os.rename, file:seek, etc.). + + + + + +


    luaL_getmetafield

    +[-0, +(0|1), m] +

    int luaL_getmetafield (lua_State *L, int obj, const char *e);
    + +

    +Pushes onto the stack the field e from the metatable +of the object at index obj and returns the type of pushed value. +If the object does not have a metatable, +or if the metatable does not have this field, +pushes nothing and returns LUA_TNIL. + + + + + +


    luaL_getmetatable

    +[-0, +1, m] +

    int luaL_getmetatable (lua_State *L, const char *tname);
    + +

    +Pushes onto the stack the metatable associated with name tname +in the registry (see luaL_newmetatable) +(nil if there is no metatable associated with that name). +Returns the type of the pushed value. + + + + + +


    luaL_getsubtable

    +[-0, +1, e] +

    int luaL_getsubtable (lua_State *L, int idx, const char *fname);
    + +

    +Ensures that the value t[fname], +where t is the value at index idx, +is a table, +and pushes that table onto the stack. +Returns true if it finds a previous table there +and false if it creates a new table. + + + + + +


    luaL_gsub

    +[-0, +1, m] +

    const char *luaL_gsub (lua_State *L,
    +                       const char *s,
    +                       const char *p,
    +                       const char *r);
    + +

    +Creates a copy of string s by replacing +any occurrence of the string p +with the string r. +Pushes the resulting string on the stack and returns it. + + + + + +


    luaL_len

    +[-0, +0, e] +

    lua_Integer luaL_len (lua_State *L, int index);
    + +

    +Returns the "length" of the value at the given index +as a number; +it is equivalent to the '#' operator in Lua (see §3.4.7). +Raises an error if the result of the operation is not an integer. +(This case only can happen through metamethods.) + + + + + +


    luaL_loadbuffer

    +[-0, +1, –] +

    int luaL_loadbuffer (lua_State *L,
    +                     const char *buff,
    +                     size_t sz,
    +                     const char *name);
    + +

    +Equivalent to luaL_loadbufferx with mode equal to NULL. + + + + + +


    luaL_loadbufferx

    +[-0, +1, –] +

    int luaL_loadbufferx (lua_State *L,
    +                      const char *buff,
    +                      size_t sz,
    +                      const char *name,
    +                      const char *mode);
    + +

    +Loads a buffer as a Lua chunk. +This function uses lua_load to load the chunk in the +buffer pointed to by buff with size sz. + + +

    +This function returns the same results as lua_load. +name is the chunk name, +used for debug information and error messages. +The string mode works as in function lua_load. + + + + + +


    luaL_loadfile

    +[-0, +1, m] +

    int luaL_loadfile (lua_State *L, const char *filename);
    + +

    +Equivalent to luaL_loadfilex with mode equal to NULL. + + + + + +


    luaL_loadfilex

    +[-0, +1, m] +

    int luaL_loadfilex (lua_State *L, const char *filename,
    +                                            const char *mode);
    + +

    +Loads a file as a Lua chunk. +This function uses lua_load to load the chunk in the file +named filename. +If filename is NULL, +then it loads from the standard input. +The first line in the file is ignored if it starts with a #. + + +

    +The string mode works as in function lua_load. + + +

    +This function returns the same results as lua_load, +but it has an extra error code LUA_ERRFILE +for file-related errors +(e.g., it cannot open or read the file). + + +

    +As lua_load, this function only loads the chunk; +it does not run it. + + + + + +


    luaL_loadstring

    +[-0, +1, –] +

    int luaL_loadstring (lua_State *L, const char *s);
    + +

    +Loads a string as a Lua chunk. +This function uses lua_load to load the chunk in +the zero-terminated string s. + + +

    +This function returns the same results as lua_load. + + +

    +Also as lua_load, this function only loads the chunk; +it does not run it. + + + + + +


    luaL_newlib

    +[-0, +1, m] +

    void luaL_newlib (lua_State *L, const luaL_Reg l[]);
    + +

    +Creates a new table and registers there +the functions in list l. + + +

    +It is implemented as the following macro: + +

    +     (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
    +

    +The array l must be the actual array, +not a pointer to it. + + + + + +


    luaL_newlibtable

    +[-0, +1, m] +

    void luaL_newlibtable (lua_State *L, const luaL_Reg l[]);
    + +

    +Creates a new table with a size optimized +to store all entries in the array l +(but does not actually store them). +It is intended to be used in conjunction with luaL_setfuncs +(see luaL_newlib). + + +

    +It is implemented as a macro. +The array l must be the actual array, +not a pointer to it. + + + + + +


    luaL_newmetatable

    +[-0, +1, m] +

    int luaL_newmetatable (lua_State *L, const char *tname);
    + +

    +If the registry already has the key tname, +returns 0. +Otherwise, +creates a new table to be used as a metatable for userdata, +adds to this new table the pair __name = tname, +adds to the registry the pair [tname] = new table, +and returns 1. +(The entry __name is used by some error-reporting functions.) + + +

    +In both cases pushes onto the stack the final value associated +with tname in the registry. + + + + + +


    luaL_newstate

    +[-0, +0, –] +

    lua_State *luaL_newstate (void);
    + +

    +Creates a new Lua state. +It calls lua_newstate with an +allocator based on the standard C realloc function +and then sets a panic function (see §4.6) that prints +an error message to the standard error output in case of fatal +errors. + + +

    +Returns the new state, +or NULL if there is a memory allocation error. + + + + + +


    luaL_openlibs

    +[-0, +0, e] +

    void luaL_openlibs (lua_State *L);
    + +

    +Opens all standard Lua libraries into the given state. + + + + + +


    luaL_opt

    +[-0, +0, e] +

    T luaL_opt (L, func, arg, dflt);
    + +

    +This macro is defined as follows: + +

    +     (lua_isnoneornil(L,(arg)) ? (dflt) : func(L,(arg)))
    +

    +In words, if the argument arg is nil or absent, +the macro results in the default dflt. +Otherwise, it results in the result of calling func +with the state L and the argument index arg as +parameters. +Note that it evaluates the expression dflt only if needed. + + + + + +


    luaL_optinteger

    +[-0, +0, v] +

    lua_Integer luaL_optinteger (lua_State *L,
    +                             int arg,
    +                             lua_Integer d);
    + +

    +If the function argument arg is an integer +(or convertible to an integer), +returns this integer. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


    luaL_optlstring

    +[-0, +0, v] +

    const char *luaL_optlstring (lua_State *L,
    +                             int arg,
    +                             const char *d,
    +                             size_t *l);
    + +

    +If the function argument arg is a string, +returns this string. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + +

    +If l is not NULL, +fills the position *l with the result's length. +If the result is NULL +(only possible when returning d and d == NULL), +its length is considered zero. + + +

    +This function uses lua_tolstring to get its result, +so all conversions and caveats of that function apply here. + + + + + +


    luaL_optnumber

    +[-0, +0, v] +

    lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number d);
    + +

    +If the function argument arg is a number, +returns this number. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


    luaL_optstring

    +[-0, +0, v] +

    const char *luaL_optstring (lua_State *L,
    +                            int arg,
    +                            const char *d);
    + +

    +If the function argument arg is a string, +returns this string. +If this argument is absent or is nil, +returns d. +Otherwise, raises an error. + + + + + +


    luaL_prepbuffer

    +[-?, +?, m] +

    char *luaL_prepbuffer (luaL_Buffer *B);
    + +

    +Equivalent to luaL_prepbuffsize +with the predefined size LUAL_BUFFERSIZE. + + + + + +


    luaL_prepbuffsize

    +[-?, +?, m] +

    char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz);
    + +

    +Returns an address to a space of size sz +where you can copy a string to be added to buffer B +(see luaL_Buffer). +After copying the string into this space you must call +luaL_addsize with the size of the string to actually add +it to the buffer. + + + + + +


    luaL_pushresult

    +[-?, +1, m] +

    void luaL_pushresult (luaL_Buffer *B);
    + +

    +Finishes the use of buffer B leaving the final string on +the top of the stack. + + + + + +


    luaL_pushresultsize

    +[-?, +1, m] +

    void luaL_pushresultsize (luaL_Buffer *B, size_t sz);
    + +

    +Equivalent to the sequence luaL_addsize, luaL_pushresult. + + + + + +


    luaL_ref

    +[-1, +0, m] +

    int luaL_ref (lua_State *L, int t);
    + +

    +Creates and returns a reference, +in the table at index t, +for the object at the top of the stack (and pops the object). + + +

    +A reference is a unique integer key. +As long as you do not manually add integer keys into table t, +luaL_ref ensures the uniqueness of the key it returns. +You can retrieve an object referred by reference r +by calling lua_rawgeti(L, t, r). +Function luaL_unref frees a reference and its associated object. + + +

    +If the object at the top of the stack is nil, +luaL_ref returns the constant LUA_REFNIL. +The constant LUA_NOREF is guaranteed to be different +from any reference returned by luaL_ref. + + + + + +


    luaL_Reg

    +
    typedef struct luaL_Reg {
    +  const char *name;
    +  lua_CFunction func;
    +} luaL_Reg;
    + +

    +Type for arrays of functions to be registered by +luaL_setfuncs. +name is the function name and func is a pointer to +the function. +Any array of luaL_Reg must end with a sentinel entry +in which both name and func are NULL. + + + + + +


    luaL_requiref

    +[-0, +1, e] +

    void luaL_requiref (lua_State *L, const char *modname,
    +                    lua_CFunction openf, int glb);
    + +

    +If modname is not already present in package.loaded, +calls function openf with string modname as an argument +and sets the call result in package.loaded[modname], +as if that function has been called through require. + + +

    +If glb is true, +also stores the module into global modname. + + +

    +Leaves a copy of the module on the stack. + + + + + +


    luaL_setfuncs

    +[-nup, +0, m] +

    void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
    + +

    +Registers all functions in the array l +(see luaL_Reg) into the table on the top of the stack +(below optional upvalues, see next). + + +

    +When nup is not zero, +all functions are created sharing nup upvalues, +which must be previously pushed on the stack +on top of the library table. +These values are popped from the stack after the registration. + + + + + +


    luaL_setmetatable

    +[-0, +0, –] +

    void luaL_setmetatable (lua_State *L, const char *tname);
    + +

    +Sets the metatable of the object at the top of the stack +as the metatable associated with name tname +in the registry (see luaL_newmetatable). + + + + + +


    luaL_Stream

    +
    typedef struct luaL_Stream {
    +  FILE *f;
    +  lua_CFunction closef;
    +} luaL_Stream;
    + +

    +The standard representation for file handles, +which is used by the standard I/O library. + + +

    +A file handle is implemented as a full userdata, +with a metatable called LUA_FILEHANDLE +(where LUA_FILEHANDLE is a macro with the actual metatable's name). +The metatable is created by the I/O library +(see luaL_newmetatable). + + +

    +This userdata must start with the structure luaL_Stream; +it can contain other data after this initial structure. +Field f points to the corresponding C stream +(or it can be NULL to indicate an incompletely created handle). +Field closef points to a Lua function +that will be called to close the stream +when the handle is closed or collected; +this function receives the file handle as its sole argument and +must return either true (in case of success) +or nil plus an error message (in case of error). +Once Lua calls this field, +it changes the field value to NULL +to signal that the handle is closed. + + + + + +


    luaL_testudata

    +[-0, +0, m] +

    void *luaL_testudata (lua_State *L, int arg, const char *tname);
    + +

    +This function works like luaL_checkudata, +except that, when the test fails, +it returns NULL instead of raising an error. + + + + + +


    luaL_tolstring

    +[-0, +1, e] +

    const char *luaL_tolstring (lua_State *L, int idx, size_t *len);
    + +

    +Converts any Lua value at the given index to a C string +in a reasonable format. +The resulting string is pushed onto the stack and also +returned by the function. +If len is not NULL, +the function also sets *len with the string length. + + +

    +If the value has a metatable with a __tostring field, +then luaL_tolstring calls the corresponding metamethod +with the value as argument, +and uses the result of the call as its result. + + + + + +


    luaL_traceback

    +[-0, +1, m] +

    void luaL_traceback (lua_State *L, lua_State *L1, const char *msg,
    +                     int level);
    + +

    +Creates and pushes a traceback of the stack L1. +If msg is not NULL it is appended +at the beginning of the traceback. +The level parameter tells at which level +to start the traceback. + + + + + +


    luaL_typename

    +[-0, +0, –] +

    const char *luaL_typename (lua_State *L, int index);
    + +

    +Returns the name of the type of the value at the given index. + + + + + +


    luaL_unref

    +[-0, +0, –] +

    void luaL_unref (lua_State *L, int t, int ref);
    + +

    +Releases reference ref from the table at index t +(see luaL_ref). +The entry is removed from the table, +so that the referred object can be collected. +The reference ref is also freed to be used again. + + +

    +If ref is LUA_NOREF or LUA_REFNIL, +luaL_unref does nothing. + + + + + +


    luaL_where

    +[-0, +1, m] +

    void luaL_where (lua_State *L, int lvl);
    + +

    +Pushes onto the stack a string identifying the current position +of the control at level lvl in the call stack. +Typically this string has the following format: + +

    +     chunkname:currentline:
    +

    +Level 0 is the running function, +level 1 is the function that called the running function, +etc. + + +

    +This function is used to build a prefix for error messages. + + + + + + + +

    6 – Standard Libraries

    + +

    +The standard Lua libraries provide useful functions +that are implemented directly through the C API. +Some of these functions provide essential services to the language +(e.g., type and getmetatable); +others provide access to "outside" services (e.g., I/O); +and others could be implemented in Lua itself, +but are quite useful or have critical performance requirements that +deserve an implementation in C (e.g., table.sort). + + +

    +All libraries are implemented through the official C API +and are provided as separate C modules. +Currently, Lua has the following standard libraries: + +

      + +
    • basic library (§6.1);
    • + +
    • coroutine library (§6.2);
    • + +
    • package library (§6.3);
    • + +
    • string manipulation (§6.4);
    • + +
    • basic UTF-8 support (§6.5);
    • + +
    • table manipulation (§6.6);
    • + +
    • mathematical functions (§6.7) (sin, log, etc.);
    • + +
    • input and output (§6.8);
    • + +
    • operating system facilities (§6.9);
    • + +
    • debug facilities (§6.10).
    • + +

    +Except for the basic and the package libraries, +each library provides all its functions as fields of a global table +or as methods of its objects. + + +

    +To have access to these libraries, +the C host program should call the luaL_openlibs function, +which opens all standard libraries. +Alternatively, +the host program can open them individually by using +luaL_requiref to call +luaopen_base (for the basic library), +luaopen_package (for the package library), +luaopen_coroutine (for the coroutine library), +luaopen_string (for the string library), +luaopen_utf8 (for the UTF8 library), +luaopen_table (for the table library), +luaopen_math (for the mathematical library), +luaopen_io (for the I/O library), +luaopen_os (for the operating system library), +and luaopen_debug (for the debug library). +These functions are declared in lualib.h. + + + +

    6.1 – Basic Functions

    + +

    +The basic library provides core functions to Lua. +If you do not include this library in your application, +you should check carefully whether you need to provide +implementations for some of its facilities. + + +

    +


    assert (v [, message])

    + + +

    +Calls error if +the value of its argument v is false (i.e., nil or false); +otherwise, returns all its arguments. +In case of error, +message is the error object; +when absent, it defaults to "assertion failed!" + + + + +

    +


    collectgarbage ([opt [, arg]])

    + + +

    +This function is a generic interface to the garbage collector. +It performs different functions according to its first argument, opt: + +

      + +
    • "collect": +performs a full garbage-collection cycle. +This is the default option. +
    • + +
    • "stop": +stops automatic execution of the garbage collector. +The collector will run only when explicitly invoked, +until a call to restart it. +
    • + +
    • "restart": +restarts automatic execution of the garbage collector. +
    • + +
    • "count": +returns the total memory in use by Lua in Kbytes. +The value has a fractional part, +so that it multiplied by 1024 +gives the exact number of bytes in use by Lua +(except for overflows). +
    • + +
    • "step": +performs a garbage-collection step. +The step "size" is controlled by arg. +With a zero value, +the collector will perform one basic (indivisible) step. +For non-zero values, +the collector will perform as if that amount of memory +(in KBytes) had been allocated by Lua. +Returns true if the step finished a collection cycle. +
    • + +
    • "setpause": +sets arg as the new value for the pause of +the collector (see §2.5). +Returns the previous value for pause. +
    • + +
    • "setstepmul": +sets arg as the new value for the step multiplier of +the collector (see §2.5). +Returns the previous value for step. +
    • + +
    • "isrunning": +returns a boolean that tells whether the collector is running +(i.e., not stopped). +
    • + +
    + + + +

    +


    dofile ([filename])

    +Opens the named file and executes its contents as a Lua chunk. +When called without arguments, +dofile executes the contents of the standard input (stdin). +Returns all values returned by the chunk. +In case of errors, dofile propagates the error +to its caller (that is, dofile does not run in protected mode). + + + + +

    +


    error (message [, level])

    +Terminates the last protected function called +and returns message as the error object. +Function error never returns. + + +

    +Usually, error adds some information about the error position +at the beginning of the message, if the message is a string. +The level argument specifies how to get the error position. +With level 1 (the default), the error position is where the +error function was called. +Level 2 points the error to where the function +that called error was called; and so on. +Passing a level 0 avoids the addition of error position information +to the message. + + + + +

    +


    _G

    +A global variable (not a function) that +holds the global environment (see §2.2). +Lua itself does not use this variable; +changing its value does not affect any environment, +nor vice versa. + + + + +

    +


    getmetatable (object)

    + + +

    +If object does not have a metatable, returns nil. +Otherwise, +if the object's metatable has a __metatable field, +returns the associated value. +Otherwise, returns the metatable of the given object. + + + + +

    +


    ipairs (t)

    + + +

    +Returns three values (an iterator function, the table t, and 0) +so that the construction + +

    +     for i,v in ipairs(t) do body end
    +

    +will iterate over the key–value pairs +(1,t[1]), (2,t[2]), ..., +up to the first nil value. + + + + +

    +


    load (chunk [, chunkname [, mode [, env]]])

    + + +

    +Loads a chunk. + + +

    +If chunk is a string, the chunk is this string. +If chunk is a function, +load calls it repeatedly to get the chunk pieces. +Each call to chunk must return a string that concatenates +with previous results. +A return of an empty string, nil, or no value signals the end of the chunk. + + +

    +If there are no syntactic errors, +returns the compiled chunk as a function; +otherwise, returns nil plus the error message. + + +

    +If the resulting function has upvalues, +the first upvalue is set to the value of env, +if that parameter is given, +or to the value of the global environment. +Other upvalues are initialized with nil. +(When you load a main chunk, +the resulting function will always have exactly one upvalue, +the _ENV variable (see §2.2). +However, +when you load a binary chunk created from a function (see string.dump), +the resulting function can have an arbitrary number of upvalues.) +All upvalues are fresh, that is, +they are not shared with any other function. + + +

    +chunkname is used as the name of the chunk for error messages +and debug information (see §4.9). +When absent, +it defaults to chunk, if chunk is a string, +or to "=(load)" otherwise. + + +

    +The string mode controls whether the chunk can be text or binary +(that is, a precompiled chunk). +It may be the string "b" (only binary chunks), +"t" (only text chunks), +or "bt" (both binary and text). +The default is "bt". + + +

    +Lua does not check the consistency of binary chunks. +Maliciously crafted binary chunks can crash +the interpreter. + + + + +

    +


    loadfile ([filename [, mode [, env]]])

    + + +

    +Similar to load, +but gets the chunk from file filename +or from the standard input, +if no file name is given. + + + + +

    +


    next (table [, index])

    + + +

    +Allows a program to traverse all fields of a table. +Its first argument is a table and its second argument +is an index in this table. +next returns the next index of the table +and its associated value. +When called with nil as its second argument, +next returns an initial index +and its associated value. +When called with the last index, +or with nil in an empty table, +next returns nil. +If the second argument is absent, then it is interpreted as nil. +In particular, +you can use next(t) to check whether a table is empty. + + +

    +The order in which the indices are enumerated is not specified, +even for numeric indices. +(To traverse a table in numerical order, +use a numerical for.) + + +

    +The behavior of next is undefined if, +during the traversal, +you assign any value to a non-existent field in the table. +You may however modify existing fields. +In particular, you may clear existing fields. + + + + +

    +


    pairs (t)

    + + +

    +If t has a metamethod __pairs, +calls it with t as argument and returns the first three +results from the call. + + +

    +Otherwise, +returns three values: the next function, the table t, and nil, +so that the construction + +

    +     for k,v in pairs(t) do body end
    +

    +will iterate over all key–value pairs of table t. + + +

    +See function next for the caveats of modifying +the table during its traversal. + + + + +

    +


    pcall (f [, arg1, ···])

    + + +

    +Calls function f with +the given arguments in protected mode. +This means that any error inside f is not propagated; +instead, pcall catches the error +and returns a status code. +Its first result is the status code (a boolean), +which is true if the call succeeds without errors. +In such case, pcall also returns all results from the call, +after this first result. +In case of any error, pcall returns false plus the error message. + + + + +

    +


    print (···)

    +Receives any number of arguments +and prints their values to stdout, +using the tostring function to convert each argument to a string. +print is not intended for formatted output, +but only as a quick way to show a value, +for instance for debugging. +For complete control over the output, +use string.format and io.write. + + + + +

    +


    rawequal (v1, v2)

    +Checks whether v1 is equal to v2, +without invoking the __eq metamethod. +Returns a boolean. + + + + +

    +


    rawget (table, index)

    +Gets the real value of table[index], +without invoking the __index metamethod. +table must be a table; +index may be any value. + + + + +

    +


    rawlen (v)

    +Returns the length of the object v, +which must be a table or a string, +without invoking the __len metamethod. +Returns an integer. + + + + +

    +


    rawset (table, index, value)

    +Sets the real value of table[index] to value, +without invoking the __newindex metamethod. +table must be a table, +index any value different from nil and NaN, +and value any Lua value. + + +

    +This function returns table. + + + + +

    +


    select (index, ···)

    + + +

    +If index is a number, +returns all arguments after argument number index; +a negative number indexes from the end (-1 is the last argument). +Otherwise, index must be the string "#", +and select returns the total number of extra arguments it received. + + + + +

    +


    setmetatable (table, metatable)

    + + +

    +Sets the metatable for the given table. +(To change the metatable of other types from Lua code, +you must use the debug library (§6.10).) +If metatable is nil, +removes the metatable of the given table. +If the original metatable has a __metatable field, +raises an error. + + +

    +This function returns table. + + + + +

    +


    tonumber (e [, base])

    + + +

    +When called with no base, +tonumber tries to convert its argument to a number. +If the argument is already a number or +a string convertible to a number, +then tonumber returns this number; +otherwise, it returns nil. + + +

    +The conversion of strings can result in integers or floats, +according to the lexical conventions of Lua (see §3.1). +(The string may have leading and trailing spaces and a sign.) + + +

    +When called with base, +then e must be a string to be interpreted as +an integer numeral in that base. +The base may be any integer between 2 and 36, inclusive. +In bases above 10, the letter 'A' (in either upper or lower case) +represents 10, 'B' represents 11, and so forth, +with 'Z' representing 35. +If the string e is not a valid numeral in the given base, +the function returns nil. + + + + +

    +


    tostring (v)

    +Receives a value of any type and +converts it to a string in a human-readable format. +(For complete control of how numbers are converted, +use string.format.) + + +

    +If the metatable of v has a __tostring field, +then tostring calls the corresponding value +with v as argument, +and uses the result of the call as its result. + + + + +

    +


    type (v)

    +Returns the type of its only argument, coded as a string. +The possible results of this function are +"nil" (a string, not the value nil), +"number", +"string", +"boolean", +"table", +"function", +"thread", +and "userdata". + + + + +

    +


    _VERSION

    + + +

    +A global variable (not a function) that +holds a string containing the running Lua version. +The current value of this variable is "Lua 5.3". + + + + +

    +


    xpcall (f, msgh [, arg1, ···])

    + + +

    +This function is similar to pcall, +except that it sets a new message handler msgh. + + + + + + + +

    6.2 – Coroutine Manipulation

    + +

    +This library comprises the operations to manipulate coroutines, +which come inside the table coroutine. +See §2.6 for a general description of coroutines. + + +

    +


    coroutine.create (f)

    + + +

    +Creates a new coroutine, with body f. +f must be a function. +Returns this new coroutine, +an object with type "thread". + + + + +

    +


    coroutine.isyieldable ()

    + + +

    +Returns true when the running coroutine can yield. + + +

    +A running coroutine is yieldable if it is not the main thread and +it is not inside a non-yieldable C function. + + + + +

    +


    coroutine.resume (co [, val1, ···])

    + + +

    +Starts or continues the execution of coroutine co. +The first time you resume a coroutine, +it starts running its body. +The values val1, ... are passed +as the arguments to the body function. +If the coroutine has yielded, +resume restarts it; +the values val1, ... are passed +as the results from the yield. + + +

    +If the coroutine runs without any errors, +resume returns true plus any values passed to yield +(when the coroutine yields) or any values returned by the body function +(when the coroutine terminates). +If there is any error, +resume returns false plus the error message. + + + + +

    +


    coroutine.running ()

    + + +

    +Returns the running coroutine plus a boolean, +true when the running coroutine is the main one. + + + + +

    +


    coroutine.status (co)

    + + +

    +Returns the status of coroutine co, as a string: +"running", +if the coroutine is running (that is, it called status); +"suspended", if the coroutine is suspended in a call to yield, +or if it has not started running yet; +"normal" if the coroutine is active but not running +(that is, it has resumed another coroutine); +and "dead" if the coroutine has finished its body function, +or if it has stopped with an error. + + + + +

    +


    coroutine.wrap (f)

    + + +

    +Creates a new coroutine, with body f. +f must be a function. +Returns a function that resumes the coroutine each time it is called. +Any arguments passed to the function behave as the +extra arguments to resume. +Returns the same values returned by resume, +except the first boolean. +In case of error, propagates the error. + + + + +

    +


    coroutine.yield (···)

    + + +

    +Suspends the execution of the calling coroutine. +Any arguments to yield are passed as extra results to resume. + + + + + + + +

    6.3 – Modules

    + +

    +The package library provides basic +facilities for loading modules in Lua. +It exports one function directly in the global environment: +require. +Everything else is exported in a table package. + + +

    +


    require (modname)

    + + +

    +Loads the given module. +The function starts by looking into the package.loaded table +to determine whether modname is already loaded. +If it is, then require returns the value stored +at package.loaded[modname]. +Otherwise, it tries to find a loader for the module. + + +

    +To find a loader, +require is guided by the package.searchers sequence. +By changing this sequence, +we can change how require looks for a module. +The following explanation is based on the default configuration +for package.searchers. + + +

    +First require queries package.preload[modname]. +If it has a value, +this value (which must be a function) is the loader. +Otherwise require searches for a Lua loader using the +path stored in package.path. +If that also fails, it searches for a C loader using the +path stored in package.cpath. +If that also fails, +it tries an all-in-one loader (see package.searchers). + + +

    +Once a loader is found, +require calls the loader with two arguments: +modname and an extra value dependent on how it got the loader. +(If the loader came from a file, +this extra value is the file name.) +If the loader returns any non-nil value, +require assigns the returned value to package.loaded[modname]. +If the loader does not return a non-nil value and +has not assigned any value to package.loaded[modname], +then require assigns true to this entry. +In any case, require returns the +final value of package.loaded[modname]. + + +

    +If there is any error loading or running the module, +or if it cannot find any loader for the module, +then require raises an error. + + + + +

    +


    package.config

    + + +

    +A string describing some compile-time configurations for packages. +This string is a sequence of lines: + +

      + +
    • The first line is the directory separator string. +Default is '\' for Windows and '/' for all other systems.
    • + +
    • The second line is the character that separates templates in a path. +Default is ';'.
    • + +
    • The third line is the string that marks the +substitution points in a template. +Default is '?'.
    • + +
    • The fourth line is a string that, in a path in Windows, +is replaced by the executable's directory. +Default is '!'.
    • + +
    • The fifth line is a mark to ignore all text after it +when building the luaopen_ function name. +Default is '-'.
    • + +
    + + + +

    +


    package.cpath

    + + +

    +The path used by require to search for a C loader. + + +

    +Lua initializes the C path package.cpath in the same way +it initializes the Lua path package.path, +using the environment variable LUA_CPATH_5_3, +or the environment variable LUA_CPATH, +or a default path defined in luaconf.h. + + + + +

    +


    package.loaded

    + + +

    +A table used by require to control which +modules are already loaded. +When you require a module modname and +package.loaded[modname] is not false, +require simply returns the value stored there. + + +

    +This variable is only a reference to the real table; +assignments to this variable do not change the +table used by require. + + + + +

    +


    package.loadlib (libname, funcname)

    + + +

    +Dynamically links the host program with the C library libname. + + +

    +If funcname is "*", +then it only links with the library, +making the symbols exported by the library +available to other dynamically linked libraries. +Otherwise, +it looks for a function funcname inside the library +and returns this function as a C function. +So, funcname must follow the lua_CFunction prototype +(see lua_CFunction). + + +

    +This is a low-level function. +It completely bypasses the package and module system. +Unlike require, +it does not perform any path searching and +does not automatically adds extensions. +libname must be the complete file name of the C library, +including if necessary a path and an extension. +funcname must be the exact name exported by the C library +(which may depend on the C compiler and linker used). + + +

    +This function is not supported by Standard C. +As such, it is only available on some platforms +(Windows, Linux, Mac OS X, Solaris, BSD, +plus other Unix systems that support the dlfcn standard). + + + + +

    +


    package.path

    + + +

    +The path used by require to search for a Lua loader. + + +

    +At start-up, Lua initializes this variable with +the value of the environment variable LUA_PATH_5_3 or +the environment variable LUA_PATH or +with a default path defined in luaconf.h, +if those environment variables are not defined. +Any ";;" in the value of the environment variable +is replaced by the default path. + + + + +

    +


    package.preload

    + + +

    +A table to store loaders for specific modules +(see require). + + +

    +This variable is only a reference to the real table; +assignments to this variable do not change the +table used by require. + + + + +

    +


    package.searchers

    + + +

    +A table used by require to control how to load modules. + + +

    +Each entry in this table is a searcher function. +When looking for a module, +require calls each of these searchers in ascending order, +with the module name (the argument given to require) as its +sole parameter. +The function can return another function (the module loader) +plus an extra value that will be passed to that loader, +or a string explaining why it did not find that module +(or nil if it has nothing to say). + + +

    +Lua initializes this table with four searcher functions. + + +

    +The first searcher simply looks for a loader in the +package.preload table. + + +

    +The second searcher looks for a loader as a Lua library, +using the path stored at package.path. +The search is done as described in function package.searchpath. + + +

    +The third searcher looks for a loader as a C library, +using the path given by the variable package.cpath. +Again, +the search is done as described in function package.searchpath. +For instance, +if the C path is the string + +

    +     "./?.so;./?.dll;/usr/local/?/init.so"
    +

    +the searcher for module foo +will try to open the files ./foo.so, ./foo.dll, +and /usr/local/foo/init.so, in that order. +Once it finds a C library, +this searcher first uses a dynamic link facility to link the +application with the library. +Then it tries to find a C function inside the library to +be used as the loader. +The name of this C function is the string "luaopen_" +concatenated with a copy of the module name where each dot +is replaced by an underscore. +Moreover, if the module name has a hyphen, +its suffix after (and including) the first hyphen is removed. +For instance, if the module name is a.b.c-v2.1, +the function name will be luaopen_a_b_c. + + +

    +The fourth searcher tries an all-in-one loader. +It searches the C path for a library for +the root name of the given module. +For instance, when requiring a.b.c, +it will search for a C library for a. +If found, it looks into it for an open function for +the submodule; +in our example, that would be luaopen_a_b_c. +With this facility, a package can pack several C submodules +into one single library, +with each submodule keeping its original open function. + + +

    +All searchers except the first one (preload) return as the extra value +the file name where the module was found, +as returned by package.searchpath. +The first searcher returns no extra value. + + + + +

    +


    package.searchpath (name, path [, sep [, rep]])

    + + +

    +Searches for the given name in the given path. + + +

    +A path is a string containing a sequence of +templates separated by semicolons. +For each template, +the function replaces each interrogation mark (if any) +in the template with a copy of name +wherein all occurrences of sep +(a dot, by default) +were replaced by rep +(the system's directory separator, by default), +and then tries to open the resulting file name. + + +

    +For instance, if the path is the string + +

    +     "./?.lua;./?.lc;/usr/local/?/init.lua"
    +

    +the search for the name foo.a +will try to open the files +./foo/a.lua, ./foo/a.lc, and +/usr/local/foo/a/init.lua, in that order. + + +

    +Returns the resulting name of the first file that it can +open in read mode (after closing the file), +or nil plus an error message if none succeeds. +(This error message lists all file names it tried to open.) + + + + + + + +

    6.4 – String Manipulation

    + +

    +This library provides generic functions for string manipulation, +such as finding and extracting substrings, and pattern matching. +When indexing a string in Lua, the first character is at position 1 +(not at 0, as in C). +Indices are allowed to be negative and are interpreted as indexing backwards, +from the end of the string. +Thus, the last character is at position -1, and so on. + + +

    +The string library provides all its functions inside the table +string. +It also sets a metatable for strings +where the __index field points to the string table. +Therefore, you can use the string functions in object-oriented style. +For instance, string.byte(s,i) +can be written as s:byte(i). + + +

    +The string library assumes one-byte character encodings. + + +

    +


    string.byte (s [, i [, j]])

    +Returns the internal numeric codes of the characters s[i], +s[i+1], ..., s[j]. +The default value for i is 1; +the default value for j is i. +These indices are corrected +following the same rules of function string.sub. + + +

    +Numeric codes are not necessarily portable across platforms. + + + + +

    +


    string.char (···)

    +Receives zero or more integers. +Returns a string with length equal to the number of arguments, +in which each character has the internal numeric code equal +to its corresponding argument. + + +

    +Numeric codes are not necessarily portable across platforms. + + + + +

    +


    string.dump (function [, strip])

    + + +

    +Returns a string containing a binary representation +(a binary chunk) +of the given function, +so that a later load on this string returns +a copy of the function (but with new upvalues). +If strip is a true value, +the binary representation may not include all debug information +about the function, +to save space. + + +

    +Functions with upvalues have only their number of upvalues saved. +When (re)loaded, +those upvalues receive fresh instances containing nil. +(You can use the debug library to serialize +and reload the upvalues of a function +in a way adequate to your needs.) + + + + +

    +


    string.find (s, pattern [, init [, plain]])

    + + +

    +Looks for the first match of +pattern (see §6.4.1) in the string s. +If it finds a match, then find returns the indices of s +where this occurrence starts and ends; +otherwise, it returns nil. +A third, optional numeric argument init specifies +where to start the search; +its default value is 1 and can be negative. +A value of true as a fourth, optional argument plain +turns off the pattern matching facilities, +so the function does a plain "find substring" operation, +with no characters in pattern being considered magic. +Note that if plain is given, then init must be given as well. + + +

    +If the pattern has captures, +then in a successful match +the captured values are also returned, +after the two indices. + + + + +

    +


    string.format (formatstring, ···)

    + + +

    +Returns a formatted version of its variable number of arguments +following the description given in its first argument (which must be a string). +The format string follows the same rules as the ISO C function sprintf. +The only differences are that the options/modifiers +*, h, L, l, n, +and p are not supported +and that there is an extra option, q. + + +

    +The q option formats a string between double quotes, +using escape sequences when necessary to ensure that +it can safely be read back by the Lua interpreter. +For instance, the call + +

    +     string.format('%q', 'a string with "quotes" and \n new line')
    +

    +may produce the string: + +

    +     "a string with \"quotes\" and \
    +      new line"
    +
    + +

    +Options +A, a, E, e, f, +G, and g all expect a number as argument. +Options c, d, +i, o, u, X, and x +expect an integer. +When Lua is compiled with a C89 compiler, +options A and a (hexadecimal floats) +do not support any modifier (flags, width, length). + + +

    +Option s expects a string; +if its argument is not a string, +it is converted to one following the same rules of tostring. +If the option has any modifier (flags, width, length), +the string argument should not contain embedded zeros. + + + + +

    +


    string.gmatch (s, pattern)

    +Returns an iterator function that, +each time it is called, +returns the next captures from pattern (see §6.4.1) +over the string s. +If pattern specifies no captures, +then the whole match is produced in each call. + + +

    +As an example, the following loop +will iterate over all the words from string s, +printing one per line: + +

    +     s = "hello world from Lua"
    +     for w in string.gmatch(s, "%a+") do
    +       print(w)
    +     end
    +

    +The next example collects all pairs key=value from the +given string into a table: + +

    +     t = {}
    +     s = "from=world, to=Lua"
    +     for k, v in string.gmatch(s, "(%w+)=(%w+)") do
    +       t[k] = v
    +     end
    +
    + +

    +For this function, a caret '^' at the start of a pattern does not +work as an anchor, as this would prevent the iteration. + + + + +

    +


    string.gsub (s, pattern, repl [, n])

    +Returns a copy of s +in which all (or the first n, if given) +occurrences of the pattern (see §6.4.1) have been +replaced by a replacement string specified by repl, +which can be a string, a table, or a function. +gsub also returns, as its second value, +the total number of matches that occurred. +The name gsub comes from Global SUBstitution. + + +

    +If repl is a string, then its value is used for replacement. +The character % works as an escape character: +any sequence in repl of the form %d, +with d between 1 and 9, +stands for the value of the d-th captured substring. +The sequence %0 stands for the whole match. +The sequence %% stands for a single %. + + +

    +If repl is a table, then the table is queried for every match, +using the first capture as the key. + + +

    +If repl is a function, then this function is called every time a +match occurs, with all captured substrings passed as arguments, +in order. + + +

    +In any case, +if the pattern specifies no captures, +then it behaves as if the whole pattern was inside a capture. + + +

    +If the value returned by the table query or by the function call +is a string or a number, +then it is used as the replacement string; +otherwise, if it is false or nil, +then there is no replacement +(that is, the original match is kept in the string). + + +

    +Here are some examples: + +

    +     x = string.gsub("hello world", "(%w+)", "%1 %1")
    +     --> x="hello hello world world"
    +     
    +     x = string.gsub("hello world", "%w+", "%0 %0", 1)
    +     --> x="hello hello world"
    +     
    +     x = string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")
    +     --> x="world hello Lua from"
    +     
    +     x = string.gsub("home = $HOME, user = $USER", "%$(%w+)", os.getenv)
    +     --> x="home = /home/roberto, user = roberto"
    +     
    +     x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
    +           return load(s)()
    +         end)
    +     --> x="4+5 = 9"
    +     
    +     local t = {name="lua", version="5.3"}
    +     x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
    +     --> x="lua-5.3.tar.gz"
    +
    + + + +

    +


    string.len (s)

    +Receives a string and returns its length. +The empty string "" has length 0. +Embedded zeros are counted, +so "a\000bc\000" has length 5. + + + + +

    +


    string.lower (s)

    +Receives a string and returns a copy of this string with all +uppercase letters changed to lowercase. +All other characters are left unchanged. +The definition of what an uppercase letter is depends on the current locale. + + + + +

    +


    string.match (s, pattern [, init])

    +Looks for the first match of +pattern (see §6.4.1) in the string s. +If it finds one, then match returns +the captures from the pattern; +otherwise it returns nil. +If pattern specifies no captures, +then the whole match is returned. +A third, optional numeric argument init specifies +where to start the search; +its default value is 1 and can be negative. + + + + +

    +


    string.pack (fmt, v1, v2, ···)

    + + +

    +Returns a binary string containing the values v1, v2, etc. +packed (that is, serialized in binary form) +according to the format string fmt (see §6.4.2). + + + + +

    +


    string.packsize (fmt)

    + + +

    +Returns the size of a string resulting from string.pack +with the given format. +The format string cannot have the variable-length options +'s' or 'z' (see §6.4.2). + + + + +

    +


    string.rep (s, n [, sep])

    +Returns a string that is the concatenation of n copies of +the string s separated by the string sep. +The default value for sep is the empty string +(that is, no separator). +Returns the empty string if n is not positive. + + +

    +(Note that it is very easy to exhaust the memory of your machine +with a single call to this function.) + + + + +

    +


    string.reverse (s)

    +Returns a string that is the string s reversed. + + + + +

    +


    string.sub (s, i [, j])

    +Returns the substring of s that +starts at i and continues until j; +i and j can be negative. +If j is absent, then it is assumed to be equal to -1 +(which is the same as the string length). +In particular, +the call string.sub(s,1,j) returns a prefix of s +with length j, +and string.sub(s, -i) (for a positive i) +returns a suffix of s +with length i. + + +

    +If, after the translation of negative indices, +i is less than 1, +it is corrected to 1. +If j is greater than the string length, +it is corrected to that length. +If, after these corrections, +i is greater than j, +the function returns the empty string. + + + + +

    +


    string.unpack (fmt, s [, pos])

    + + +

    +Returns the values packed in string s (see string.pack) +according to the format string fmt (see §6.4.2). +An optional pos marks where +to start reading in s (default is 1). +After the read values, +this function also returns the index of the first unread byte in s. + + + + +

    +


    string.upper (s)

    +Receives a string and returns a copy of this string with all +lowercase letters changed to uppercase. +All other characters are left unchanged. +The definition of what a lowercase letter is depends on the current locale. + + + + + +

    6.4.1 – Patterns

    + +

    +Patterns in Lua are described by regular strings, +which are interpreted as patterns by the pattern-matching functions +string.find, +string.gmatch, +string.gsub, +and string.match. +This section describes the syntax and the meaning +(that is, what they match) of these strings. + + + +

    Character Class:

    +A character class is used to represent a set of characters. +The following combinations are allowed in describing a character class: + +

      + +
    • x: +(where x is not one of the magic characters +^$()%.[]*+-?) +represents the character x itself. +
    • + +
    • .: (a dot) represents all characters.
    • + +
    • %a: represents all letters.
    • + +
    • %c: represents all control characters.
    • + +
    • %d: represents all digits.
    • + +
    • %g: represents all printable characters except space.
    • + +
    • %l: represents all lowercase letters.
    • + +
    • %p: represents all punctuation characters.
    • + +
    • %s: represents all space characters.
    • + +
    • %u: represents all uppercase letters.
    • + +
    • %w: represents all alphanumeric characters.
    • + +
    • %x: represents all hexadecimal digits.
    • + +
    • %x: (where x is any non-alphanumeric character) +represents the character x. +This is the standard way to escape the magic characters. +Any non-alphanumeric character +(including all punctuation characters, even the non-magical) +can be preceded by a '%' +when used to represent itself in a pattern. +
    • + +
    • [set]: +represents the class which is the union of all +characters in set. +A range of characters can be specified by +separating the end characters of the range, +in ascending order, with a '-'. +All classes %x described above can also be used as +components in set. +All other characters in set represent themselves. +For example, [%w_] (or [_%w]) +represents all alphanumeric characters plus the underscore, +[0-7] represents the octal digits, +and [0-7%l%-] represents the octal digits plus +the lowercase letters plus the '-' character. + + +

      +You can put a closing square bracket in a set +by positioning it as the first character in the set. +You can put an hyphen in a set +by positioning it as the first or the last character in the set. +(You can also use an escape for both cases.) + + +

      +The interaction between ranges and classes is not defined. +Therefore, patterns like [%a-z] or [a-%%] +have no meaning. +

    • + +
    • [^set]: +represents the complement of set, +where set is interpreted as above. +
    • + +

    +For all classes represented by single letters (%a, %c, etc.), +the corresponding uppercase letter represents the complement of the class. +For instance, %S represents all non-space characters. + + +

    +The definitions of letter, space, and other character groups +depend on the current locale. +In particular, the class [a-z] may not be equivalent to %l. + + + + + +

    Pattern Item:

    +A pattern item can be + +

      + +
    • +a single character class, +which matches any single character in the class; +
    • + +
    • +a single character class followed by '*', +which matches zero or more repetitions of characters in the class. +These repetition items will always match the longest possible sequence; +
    • + +
    • +a single character class followed by '+', +which matches one or more repetitions of characters in the class. +These repetition items will always match the longest possible sequence; +
    • + +
    • +a single character class followed by '-', +which also matches zero or more repetitions of characters in the class. +Unlike '*', +these repetition items will always match the shortest possible sequence; +
    • + +
    • +a single character class followed by '?', +which matches zero or one occurrence of a character in the class. +It always matches one occurrence if possible; +
    • + +
    • +%n, for n between 1 and 9; +such item matches a substring equal to the n-th captured string +(see below); +
    • + +
    • +%bxy, where x and y are two distinct characters; +such item matches strings that start with x, end with y, +and where the x and y are balanced. +This means that, if one reads the string from left to right, +counting +1 for an x and -1 for a y, +the ending y is the first y where the count reaches 0. +For instance, the item %b() matches expressions with +balanced parentheses. +
    • + +
    • +%f[set], a frontier pattern; +such item matches an empty string at any position such that +the next character belongs to set +and the previous character does not belong to set. +The set set is interpreted as previously described. +The beginning and the end of the subject are handled as if +they were the character '\0'. +
    • + +
    + + + + +

    Pattern:

    +A pattern is a sequence of pattern items. +A caret '^' at the beginning of a pattern anchors the match at the +beginning of the subject string. +A '$' at the end of a pattern anchors the match at the +end of the subject string. +At other positions, +'^' and '$' have no special meaning and represent themselves. + + + + + +

    Captures:

    +A pattern can contain sub-patterns enclosed in parentheses; +they describe captures. +When a match succeeds, the substrings of the subject string +that match captures are stored (captured) for future use. +Captures are numbered according to their left parentheses. +For instance, in the pattern "(a*(.)%w(%s*))", +the part of the string matching "a*(.)%w(%s*)" is +stored as the first capture (and therefore has number 1); +the character matching "." is captured with number 2, +and the part matching "%s*" has number 3. + + +

    +As a special case, the empty capture () captures +the current string position (a number). +For instance, if we apply the pattern "()aa()" on the +string "flaaap", there will be two captures: 3 and 5. + + + + + + + +

    6.4.2 – Format Strings for Pack and Unpack

    + +

    +The first argument to string.pack, +string.packsize, and string.unpack +is a format string, +which describes the layout of the structure being created or read. + + +

    +A format string is a sequence of conversion options. +The conversion options are as follows: + +

      +
    • <: sets little endian
    • +
    • >: sets big endian
    • +
    • =: sets native endian
    • +
    • ![n]: sets maximum alignment to n +(default is native alignment)
    • +
    • b: a signed byte (char)
    • +
    • B: an unsigned byte (char)
    • +
    • h: a signed short (native size)
    • +
    • H: an unsigned short (native size)
    • +
    • l: a signed long (native size)
    • +
    • L: an unsigned long (native size)
    • +
    • j: a lua_Integer
    • +
    • J: a lua_Unsigned
    • +
    • T: a size_t (native size)
    • +
    • i[n]: a signed int with n bytes +(default is native size)
    • +
    • I[n]: an unsigned int with n bytes +(default is native size)
    • +
    • f: a float (native size)
    • +
    • d: a double (native size)
    • +
    • n: a lua_Number
    • +
    • cn: a fixed-sized string with n bytes
    • +
    • z: a zero-terminated string
    • +
    • s[n]: a string preceded by its length +coded as an unsigned integer with n bytes +(default is a size_t)
    • +
    • x: one byte of padding
    • +
    • Xop: an empty item that aligns +according to option op +(which is otherwise ignored)
    • +
    • ' ': (empty space) ignored
    • +

    +(A "[n]" means an optional integral numeral.) +Except for padding, spaces, and configurations +(options "xX <=>!"), +each option corresponds to an argument (in string.pack) +or a result (in string.unpack). + + +

    +For options "!n", "sn", "in", and "In", +n can be any integer between 1 and 16. +All integral options check overflows; +string.pack checks whether the given value fits in the given size; +string.unpack checks whether the read value fits in a Lua integer. + + +

    +Any format string starts as if prefixed by "!1=", +that is, +with maximum alignment of 1 (no alignment) +and native endianness. + + +

    +Alignment works as follows: +For each option, +the format gets extra padding until the data starts +at an offset that is a multiple of the minimum between the +option size and the maximum alignment; +this minimum must be a power of 2. +Options "c" and "z" are not aligned; +option "s" follows the alignment of its starting integer. + + +

    +All padding is filled with zeros by string.pack +(and ignored by string.unpack). + + + + + + + +

    6.5 – UTF-8 Support

    + +

    +This library provides basic support for UTF-8 encoding. +It provides all its functions inside the table utf8. +This library does not provide any support for Unicode other +than the handling of the encoding. +Any operation that needs the meaning of a character, +such as character classification, is outside its scope. + + +

    +Unless stated otherwise, +all functions that expect a byte position as a parameter +assume that the given position is either the start of a byte sequence +or one plus the length of the subject string. +As in the string library, +negative indices count from the end of the string. + + +

    +


    utf8.char (···)

    +Receives zero or more integers, +converts each one to its corresponding UTF-8 byte sequence +and returns a string with the concatenation of all these sequences. + + + + +

    +


    utf8.charpattern

    +The pattern (a string, not a function) "[\0-\x7F\xC2-\xF4][\x80-\xBF]*" +(see §6.4.1), +which matches exactly one UTF-8 byte sequence, +assuming that the subject is a valid UTF-8 string. + + + + +

    +


    utf8.codes (s)

    + + +

    +Returns values so that the construction + +

    +     for p, c in utf8.codes(s) do body end
    +

    +will iterate over all characters in string s, +with p being the position (in bytes) and c the code point +of each character. +It raises an error if it meets any invalid byte sequence. + + + + +

    +


    utf8.codepoint (s [, i [, j]])

    +Returns the codepoints (as integers) from all characters in s +that start between byte position i and j (both included). +The default for i is 1 and for j is i. +It raises an error if it meets any invalid byte sequence. + + + + +

    +


    utf8.len (s [, i [, j]])

    +Returns the number of UTF-8 characters in string s +that start between positions i and j (both inclusive). +The default for i is 1 and for j is -1. +If it finds any invalid byte sequence, +returns a false value plus the position of the first invalid byte. + + + + +

    +


    utf8.offset (s, n [, i])

    +Returns the position (in bytes) where the encoding of the +n-th character of s +(counting from position i) starts. +A negative n gets characters before position i. +The default for i is 1 when n is non-negative +and #s + 1 otherwise, +so that utf8.offset(s, -n) gets the offset of the +n-th character from the end of the string. +If the specified character is neither in the subject +nor right after its end, +the function returns nil. + + +

    +As a special case, +when n is 0 the function returns the start of the encoding +of the character that contains the i-th byte of s. + + +

    +This function assumes that s is a valid UTF-8 string. + + + + + + + +

    6.6 – Table Manipulation

    + +

    +This library provides generic functions for table manipulation. +It provides all its functions inside the table table. + + +

    +Remember that, whenever an operation needs the length of a table, +all caveats about the length operator apply (see §3.4.7). +All functions ignore non-numeric keys +in the tables given as arguments. + + +

    +


    table.concat (list [, sep [, i [, j]]])

    + + +

    +Given a list where all elements are strings or numbers, +returns the string list[i]..sep..list[i+1] ··· sep..list[j]. +The default value for sep is the empty string, +the default for i is 1, +and the default for j is #list. +If i is greater than j, returns the empty string. + + + + +

    +


    table.insert (list, [pos,] value)

    + + +

    +Inserts element value at position pos in list, +shifting up the elements +list[pos], list[pos+1], ···, list[#list]. +The default value for pos is #list+1, +so that a call table.insert(t,x) inserts x at the end +of list t. + + + + +

    +


    table.move (a1, f, e, t [,a2])

    + + +

    +Moves elements from table a1 to table a2, +performing the equivalent to the following +multiple assignment: +a2[t],··· = a1[f],···,a1[e]. +The default for a2 is a1. +The destination range can overlap with the source range. +The number of elements to be moved must fit in a Lua integer. + + +

    +Returns the destination table a2. + + + + +

    +


    table.pack (···)

    + + +

    +Returns a new table with all parameters stored into keys 1, 2, etc. +and with a field "n" with the total number of parameters. +Note that the resulting table may not be a sequence. + + + + +

    +


    table.remove (list [, pos])

    + + +

    +Removes from list the element at position pos, +returning the value of the removed element. +When pos is an integer between 1 and #list, +it shifts down the elements +list[pos+1], list[pos+2], ···, list[#list] +and erases element list[#list]; +The index pos can also be 0 when #list is 0, +or #list + 1; +in those cases, the function erases the element list[pos]. + + +

    +The default value for pos is #list, +so that a call table.remove(l) removes the last element +of list l. + + + + +

    +


    table.sort (list [, comp])

    + + +

    +Sorts list elements in a given order, in-place, +from list[1] to list[#list]. +If comp is given, +then it must be a function that receives two list elements +and returns true when the first element must come +before the second in the final order +(so that, after the sort, +i < j implies not comp(list[j],list[i])). +If comp is not given, +then the standard Lua operator < is used instead. + + +

    +Note that the comp function must define +a strict partial order over the elements in the list; +that is, it must be asymmetric and transitive. +Otherwise, no valid sort may be possible. + + +

    +The sort algorithm is not stable: +elements considered equal by the given order +may have their relative positions changed by the sort. + + + + +

    +


    table.unpack (list [, i [, j]])

    + + +

    +Returns the elements from the given list. +This function is equivalent to + +

    +     return list[i], list[i+1], ···, list[j]
    +

    +By default, i is 1 and j is #list. + + + + + + + +

    6.7 – Mathematical Functions

    + +

    +This library provides basic mathematical functions. +It provides all its functions and constants inside the table math. +Functions with the annotation "integer/float" give +integer results for integer arguments +and float results for float (or mixed) arguments. +Rounding functions +(math.ceil, math.floor, and math.modf) +return an integer when the result fits in the range of an integer, +or a float otherwise. + + +

    +


    math.abs (x)

    + + +

    +Returns the absolute value of x. (integer/float) + + + + +

    +


    math.acos (x)

    + + +

    +Returns the arc cosine of x (in radians). + + + + +

    +


    math.asin (x)

    + + +

    +Returns the arc sine of x (in radians). + + + + +

    +


    math.atan (y [, x])

    + + +

    + +Returns the arc tangent of y/x (in radians), +but uses the signs of both parameters to find the +quadrant of the result. +(It also handles correctly the case of x being zero.) + + +

    +The default value for x is 1, +so that the call math.atan(y) +returns the arc tangent of y. + + + + +

    +


    math.ceil (x)

    + + +

    +Returns the smallest integral value larger than or equal to x. + + + + +

    +


    math.cos (x)

    + + +

    +Returns the cosine of x (assumed to be in radians). + + + + +

    +


    math.deg (x)

    + + +

    +Converts the angle x from radians to degrees. + + + + +

    +


    math.exp (x)

    + + +

    +Returns the value ex +(where e is the base of natural logarithms). + + + + +

    +


    math.floor (x)

    + + +

    +Returns the largest integral value smaller than or equal to x. + + + + +

    +


    math.fmod (x, y)

    + + +

    +Returns the remainder of the division of x by y +that rounds the quotient towards zero. (integer/float) + + + + +

    +


    math.huge

    + + +

    +The float value HUGE_VAL, +a value larger than any other numeric value. + + + + +

    +


    math.log (x [, base])

    + + +

    +Returns the logarithm of x in the given base. +The default for base is e +(so that the function returns the natural logarithm of x). + + + + +

    +


    math.max (x, ···)

    + + +

    +Returns the argument with the maximum value, +according to the Lua operator <. (integer/float) + + + + +

    +


    math.maxinteger

    +An integer with the maximum value for an integer. + + + + +

    +


    math.min (x, ···)

    + + +

    +Returns the argument with the minimum value, +according to the Lua operator <. (integer/float) + + + + +

    +


    math.mininteger

    +An integer with the minimum value for an integer. + + + + +

    +


    math.modf (x)

    + + +

    +Returns the integral part of x and the fractional part of x. +Its second result is always a float. + + + + +

    +


    math.pi

    + + +

    +The value of π. + + + + +

    +


    math.rad (x)

    + + +

    +Converts the angle x from degrees to radians. + + + + +

    +


    math.random ([m [, n]])

    + + +

    +When called without arguments, +returns a pseudo-random float with uniform distribution +in the range [0,1). +When called with two integers m and n, +math.random returns a pseudo-random integer +with uniform distribution in the range [m, n]. +(The value n-m cannot be negative and must fit in a Lua integer.) +The call math.random(n) is equivalent to math.random(1,n). + + +

    +This function is an interface to the underling +pseudo-random generator function provided by C. + + + + +

    +


    math.randomseed (x)

    + + +

    +Sets x as the "seed" +for the pseudo-random generator: +equal seeds produce equal sequences of numbers. + + + + +

    +


    math.sin (x)

    + + +

    +Returns the sine of x (assumed to be in radians). + + + + +

    +


    math.sqrt (x)

    + + +

    +Returns the square root of x. +(You can also use the expression x^0.5 to compute this value.) + + + + +

    +


    math.tan (x)

    + + +

    +Returns the tangent of x (assumed to be in radians). + + + + +

    +


    math.tointeger (x)

    + + +

    +If the value x is convertible to an integer, +returns that integer. +Otherwise, returns nil. + + + + +

    +


    math.type (x)

    + + +

    +Returns "integer" if x is an integer, +"float" if it is a float, +or nil if x is not a number. + + + + +

    +


    math.ult (m, n)

    + + +

    +Returns a boolean, +true if and only if integer m is below integer n when +they are compared as unsigned integers. + + + + + + + +

    6.8 – Input and Output Facilities

    + +

    +The I/O library provides two different styles for file manipulation. +The first one uses implicit file handles; +that is, there are operations to set a default input file and a +default output file, +and all input/output operations are over these default files. +The second style uses explicit file handles. + + +

    +When using implicit file handles, +all operations are supplied by table io. +When using explicit file handles, +the operation io.open returns a file handle +and then all operations are supplied as methods of the file handle. + + +

    +The table io also provides +three predefined file handles with their usual meanings from C: +io.stdin, io.stdout, and io.stderr. +The I/O library never closes these files. + + +

    +Unless otherwise stated, +all I/O functions return nil on failure +(plus an error message as a second result and +a system-dependent error code as a third result) +and some value different from nil on success. +On non-POSIX systems, +the computation of the error message and error code +in case of errors +may be not thread safe, +because they rely on the global C variable errno. + + +

    +


    io.close ([file])

    + + +

    +Equivalent to file:close(). +Without a file, closes the default output file. + + + + +

    +


    io.flush ()

    + + +

    +Equivalent to io.output():flush(). + + + + +

    +


    io.input ([file])

    + + +

    +When called with a file name, it opens the named file (in text mode), +and sets its handle as the default input file. +When called with a file handle, +it simply sets this file handle as the default input file. +When called without parameters, +it returns the current default input file. + + +

    +In case of errors this function raises the error, +instead of returning an error code. + + + + +

    +


    io.lines ([filename, ···])

    + + +

    +Opens the given file name in read mode +and returns an iterator function that +works like file:lines(···) over the opened file. +When the iterator function detects the end of file, +it returns no values (to finish the loop) and automatically closes the file. + + +

    +The call io.lines() (with no file name) is equivalent +to io.input():lines("*l"); +that is, it iterates over the lines of the default input file. +In this case it does not close the file when the loop ends. + + +

    +In case of errors this function raises the error, +instead of returning an error code. + + + + +

    +


    io.open (filename [, mode])

    + + +

    +This function opens a file, +in the mode specified in the string mode. +In case of success, +it returns a new file handle. + + +

    +The mode string can be any of the following: + +

      +
    • "r": read mode (the default);
    • +
    • "w": write mode;
    • +
    • "a": append mode;
    • +
    • "r+": update mode, all previous data is preserved;
    • +
    • "w+": update mode, all previous data is erased;
    • +
    • "a+": append update mode, previous data is preserved, + writing is only allowed at the end of file.
    • +

    +The mode string can also have a 'b' at the end, +which is needed in some systems to open the file in binary mode. + + + + +

    +


    io.output ([file])

    + + +

    +Similar to io.input, but operates over the default output file. + + + + +

    +


    io.popen (prog [, mode])

    + + +

    +This function is system dependent and is not available +on all platforms. + + +

    +Starts program prog in a separated process and returns +a file handle that you can use to read data from this program +(if mode is "r", the default) +or to write data to this program +(if mode is "w"). + + + + +

    +


    io.read (···)

    + + +

    +Equivalent to io.input():read(···). + + + + +

    +


    io.tmpfile ()

    + + +

    +In case of success, +returns a handle for a temporary file. +This file is opened in update mode +and it is automatically removed when the program ends. + + + + +

    +


    io.type (obj)

    + + +

    +Checks whether obj is a valid file handle. +Returns the string "file" if obj is an open file handle, +"closed file" if obj is a closed file handle, +or nil if obj is not a file handle. + + + + +

    +


    io.write (···)

    + + +

    +Equivalent to io.output():write(···). + + + + +

    +


    file:close ()

    + + +

    +Closes file. +Note that files are automatically closed when +their handles are garbage collected, +but that takes an unpredictable amount of time to happen. + + +

    +When closing a file handle created with io.popen, +file:close returns the same values +returned by os.execute. + + + + +

    +


    file:flush ()

    + + +

    +Saves any written data to file. + + + + +

    +


    file:lines (···)

    + + +

    +Returns an iterator function that, +each time it is called, +reads the file according to the given formats. +When no format is given, +uses "l" as a default. +As an example, the construction + +

    +     for c in file:lines(1) do body end
    +

    +will iterate over all characters of the file, +starting at the current position. +Unlike io.lines, this function does not close the file +when the loop ends. + + +

    +In case of errors this function raises the error, +instead of returning an error code. + + + + +

    +


    file:read (···)

    + + +

    +Reads the file file, +according to the given formats, which specify what to read. +For each format, +the function returns a string or a number with the characters read, +or nil if it cannot read data with the specified format. +(In this latter case, +the function does not read subsequent formats.) +When called without formats, +it uses a default format that reads the next line +(see below). + + +

    +The available formats are + +

      + +
    • "n": +reads a numeral and returns it as a float or an integer, +following the lexical conventions of Lua. +(The numeral may have leading spaces and a sign.) +This format always reads the longest input sequence that +is a valid prefix for a numeral; +if that prefix does not form a valid numeral +(e.g., an empty string, "0x", or "3.4e-"), +it is discarded and the function returns nil. +
    • + +
    • "a": +reads the whole file, starting at the current position. +On end of file, it returns the empty string. +
    • + +
    • "l": +reads the next line skipping the end of line, +returning nil on end of file. +This is the default format. +
    • + +
    • "L": +reads the next line keeping the end-of-line character (if present), +returning nil on end of file. +
    • + +
    • number: +reads a string with up to this number of bytes, +returning nil on end of file. +If number is zero, +it reads nothing and returns an empty string, +or nil on end of file. +
    • + +

    +The formats "l" and "L" should be used only for text files. + + + + +

    +


    file:seek ([whence [, offset]])

    + + +

    +Sets and gets the file position, +measured from the beginning of the file, +to the position given by offset plus a base +specified by the string whence, as follows: + +

      +
    • "set": base is position 0 (beginning of the file);
    • +
    • "cur": base is current position;
    • +
    • "end": base is end of file;
    • +

    +In case of success, seek returns the final file position, +measured in bytes from the beginning of the file. +If seek fails, it returns nil, +plus a string describing the error. + + +

    +The default value for whence is "cur", +and for offset is 0. +Therefore, the call file:seek() returns the current +file position, without changing it; +the call file:seek("set") sets the position to the +beginning of the file (and returns 0); +and the call file:seek("end") sets the position to the +end of the file, and returns its size. + + + + +

    +


    file:setvbuf (mode [, size])

    + + +

    +Sets the buffering mode for an output file. +There are three available modes: + +

      + +
    • "no": +no buffering; the result of any output operation appears immediately. +
    • + +
    • "full": +full buffering; output operation is performed only +when the buffer is full or when +you explicitly flush the file (see io.flush). +
    • + +
    • "line": +line buffering; output is buffered until a newline is output +or there is any input from some special files +(such as a terminal device). +
    • + +

    +For the last two cases, size +specifies the size of the buffer, in bytes. +The default is an appropriate size. + + + + +

    +


    file:write (···)

    + + +

    +Writes the value of each of its arguments to file. +The arguments must be strings or numbers. + + +

    +In case of success, this function returns file. +Otherwise it returns nil plus a string describing the error. + + + + + + + +

    6.9 – Operating System Facilities

    + +

    +This library is implemented through table os. + + +

    +


    os.clock ()

    + + +

    +Returns an approximation of the amount in seconds of CPU time +used by the program. + + + + +

    +


    os.date ([format [, time]])

    + + +

    +Returns a string or a table containing date and time, +formatted according to the given string format. + + +

    +If the time argument is present, +this is the time to be formatted +(see the os.time function for a description of this value). +Otherwise, date formats the current time. + + +

    +If format starts with '!', +then the date is formatted in Coordinated Universal Time. +After this optional character, +if format is the string "*t", +then date returns a table with the following fields: +year, month (1–12), day (1–31), +hour (0–23), min (0–59), sec (0–61), +wday (weekday, 1–7, Sunday is 1), +yday (day of the year, 1–366), +and isdst (daylight saving flag, a boolean). +This last field may be absent +if the information is not available. + + +

    +If format is not "*t", +then date returns the date as a string, +formatted according to the same rules as the ISO C function strftime. + + +

    +When called without arguments, +date returns a reasonable date and time representation that depends on +the host system and on the current locale. +(More specifically, os.date() is equivalent to os.date("%c").) + + +

    +On non-POSIX systems, +this function may be not thread safe +because of its reliance on C function gmtime and C function localtime. + + + + +

    +


    os.difftime (t2, t1)

    + + +

    +Returns the difference, in seconds, +from time t1 to time t2 +(where the times are values returned by os.time). +In POSIX, Windows, and some other systems, +this value is exactly t2-t1. + + + + +

    +


    os.execute ([command])

    + + +

    +This function is equivalent to the ISO C function system. +It passes command to be executed by an operating system shell. +Its first result is true +if the command terminated successfully, +or nil otherwise. +After this first result +the function returns a string plus a number, +as follows: + +

      + +
    • "exit": +the command terminated normally; +the following number is the exit status of the command. +
    • + +
    • "signal": +the command was terminated by a signal; +the following number is the signal that terminated the command. +
    • + +
    + +

    +When called without a command, +os.execute returns a boolean that is true if a shell is available. + + + + +

    +


    os.exit ([code [, close]])

    + + +

    +Calls the ISO C function exit to terminate the host program. +If code is true, +the returned status is EXIT_SUCCESS; +if code is false, +the returned status is EXIT_FAILURE; +if code is a number, +the returned status is this number. +The default value for code is true. + + +

    +If the optional second argument close is true, +closes the Lua state before exiting. + + + + +

    +


    os.getenv (varname)

    + + +

    +Returns the value of the process environment variable varname, +or nil if the variable is not defined. + + + + +

    +


    os.remove (filename)

    + + +

    +Deletes the file (or empty directory, on POSIX systems) +with the given name. +If this function fails, it returns nil, +plus a string describing the error and the error code. +Otherwise, it returns true. + + + + +

    +


    os.rename (oldname, newname)

    + + +

    +Renames the file or directory named oldname to newname. +If this function fails, it returns nil, +plus a string describing the error and the error code. +Otherwise, it returns true. + + + + +

    +


    os.setlocale (locale [, category])

    + + +

    +Sets the current locale of the program. +locale is a system-dependent string specifying a locale; +category is an optional string describing which category to change: +"all", "collate", "ctype", +"monetary", "numeric", or "time"; +the default category is "all". +The function returns the name of the new locale, +or nil if the request cannot be honored. + + +

    +If locale is the empty string, +the current locale is set to an implementation-defined native locale. +If locale is the string "C", +the current locale is set to the standard C locale. + + +

    +When called with nil as the first argument, +this function only returns the name of the current locale +for the given category. + + +

    +This function may be not thread safe +because of its reliance on C function setlocale. + + + + +

    +


    os.time ([table])

    + + +

    +Returns the current time when called without arguments, +or a time representing the local date and time specified by the given table. +This table must have fields year, month, and day, +and may have fields +hour (default is 12), +min (default is 0), +sec (default is 0), +and isdst (default is nil). +Other fields are ignored. +For a description of these fields, see the os.date function. + + +

    +The values in these fields do not need to be inside their valid ranges. +For instance, if sec is -10, +it means -10 seconds from the time specified by the other fields; +if hour is 1000, +it means +1000 hours from the time specified by the other fields. + + +

    +The returned value is a number, whose meaning depends on your system. +In POSIX, Windows, and some other systems, +this number counts the number +of seconds since some given start time (the "epoch"). +In other systems, the meaning is not specified, +and the number returned by time can be used only as an argument to +os.date and os.difftime. + + + + +

    +


    os.tmpname ()

    + + +

    +Returns a string with a file name that can +be used for a temporary file. +The file must be explicitly opened before its use +and explicitly removed when no longer needed. + + +

    +On POSIX systems, +this function also creates a file with that name, +to avoid security risks. +(Someone else might create the file with wrong permissions +in the time between getting the name and creating the file.) +You still have to open the file to use it +and to remove it (even if you do not use it). + + +

    +When possible, +you may prefer to use io.tmpfile, +which automatically removes the file when the program ends. + + + + + + + +

    6.10 – The Debug Library

    + +

    +This library provides +the functionality of the debug interface (§4.9) to Lua programs. +You should exert care when using this library. +Several of its functions +violate basic assumptions about Lua code +(e.g., that variables local to a function +cannot be accessed from outside; +that userdata metatables cannot be changed by Lua code; +that Lua programs do not crash) +and therefore can compromise otherwise secure code. +Moreover, some functions in this library may be slow. + + +

    +All functions in this library are provided +inside the debug table. +All functions that operate over a thread +have an optional first argument which is the +thread to operate over. +The default is always the current thread. + + +

    +


    debug.debug ()

    + + +

    +Enters an interactive mode with the user, +running each string that the user enters. +Using simple commands and other debug facilities, +the user can inspect global and local variables, +change their values, evaluate expressions, and so on. +A line containing only the word cont finishes this function, +so that the caller continues its execution. + + +

    +Note that commands for debug.debug are not lexically nested +within any function and so have no direct access to local variables. + + + + +

    +


    debug.gethook ([thread])

    + + +

    +Returns the current hook settings of the thread, as three values: +the current hook function, the current hook mask, +and the current hook count +(as set by the debug.sethook function). + + + + +

    +


    debug.getinfo ([thread,] f [, what])

    + + +

    +Returns a table with information about a function. +You can give the function directly +or you can give a number as the value of f, +which means the function running at level f of the call stack +of the given thread: +level 0 is the current function (getinfo itself); +level 1 is the function that called getinfo +(except for tail calls, which do not count on the stack); +and so on. +If f is a number larger than the number of active functions, +then getinfo returns nil. + + +

    +The returned table can contain all the fields returned by lua_getinfo, +with the string what describing which fields to fill in. +The default for what is to get all information available, +except the table of valid lines. +If present, +the option 'f' +adds a field named func with the function itself. +If present, +the option 'L' +adds a field named activelines with the table of +valid lines. + + +

    +For instance, the expression debug.getinfo(1,"n").name returns +a name for the current function, +if a reasonable name can be found, +and the expression debug.getinfo(print) +returns a table with all available information +about the print function. + + + + +

    +


    debug.getlocal ([thread,] f, local)

    + + +

    +This function returns the name and the value of the local variable +with index local of the function at level f of the stack. +This function accesses not only explicit local variables, +but also parameters, temporaries, etc. + + +

    +The first parameter or local variable has index 1, and so on, +following the order that they are declared in the code, +counting only the variables that are active +in the current scope of the function. +Negative indices refer to vararg parameters; +-1 is the first vararg parameter. +The function returns nil if there is no variable with the given index, +and raises an error when called with a level out of range. +(You can call debug.getinfo to check whether the level is valid.) + + +

    +Variable names starting with '(' (open parenthesis) +represent variables with no known names +(internal variables such as loop control variables, +and variables from chunks saved without debug information). + + +

    +The parameter f may also be a function. +In that case, getlocal returns only the name of function parameters. + + + + +

    +


    debug.getmetatable (value)

    + + +

    +Returns the metatable of the given value +or nil if it does not have a metatable. + + + + +

    +


    debug.getregistry ()

    + + +

    +Returns the registry table (see §4.5). + + + + +

    +


    debug.getupvalue (f, up)

    + + +

    +This function returns the name and the value of the upvalue +with index up of the function f. +The function returns nil if there is no upvalue with the given index. + + +

    +Variable names starting with '(' (open parenthesis) +represent variables with no known names +(variables from chunks saved without debug information). + + + + +

    +


    debug.getuservalue (u)

    + + +

    +Returns the Lua value associated to u. +If u is not a full userdata, +returns nil. + + + + +

    +


    debug.sethook ([thread,] hook, mask [, count])

    + + +

    +Sets the given function as a hook. +The string mask and the number count describe +when the hook will be called. +The string mask may have any combination of the following characters, +with the given meaning: + +

      +
    • 'c': the hook is called every time Lua calls a function;
    • +
    • 'r': the hook is called every time Lua returns from a function;
    • +
    • 'l': the hook is called every time Lua enters a new line of code.
    • +

    +Moreover, +with a count different from zero, +the hook is called also after every count instructions. + + +

    +When called without arguments, +debug.sethook turns off the hook. + + +

    +When the hook is called, its first parameter is a string +describing the event that has triggered its call: +"call" (or "tail call"), +"return", +"line", and "count". +For line events, +the hook also gets the new line number as its second parameter. +Inside a hook, +you can call getinfo with level 2 to get more information about +the running function +(level 0 is the getinfo function, +and level 1 is the hook function). + + + + +

    +


    debug.setlocal ([thread,] level, local, value)

    + + +

    +This function assigns the value value to the local variable +with index local of the function at level level of the stack. +The function returns nil if there is no local +variable with the given index, +and raises an error when called with a level out of range. +(You can call getinfo to check whether the level is valid.) +Otherwise, it returns the name of the local variable. + + +

    +See debug.getlocal for more information about +variable indices and names. + + + + +

    +


    debug.setmetatable (value, table)

    + + +

    +Sets the metatable for the given value to the given table +(which can be nil). +Returns value. + + + + +

    +


    debug.setupvalue (f, up, value)

    + + +

    +This function assigns the value value to the upvalue +with index up of the function f. +The function returns nil if there is no upvalue +with the given index. +Otherwise, it returns the name of the upvalue. + + + + +

    +


    debug.setuservalue (udata, value)

    + + +

    +Sets the given value as +the Lua value associated to the given udata. +udata must be a full userdata. + + +

    +Returns udata. + + + + +

    +


    debug.traceback ([thread,] [message [, level]])

    + + +

    +If message is present but is neither a string nor nil, +this function returns message without further processing. +Otherwise, +it returns a string with a traceback of the call stack. +The optional message string is appended +at the beginning of the traceback. +An optional level number tells at which level +to start the traceback +(default is 1, the function calling traceback). + + + + +

    +


    debug.upvalueid (f, n)

    + + +

    +Returns a unique identifier (as a light userdata) +for the upvalue numbered n +from the given function. + + +

    +These unique identifiers allow a program to check whether different +closures share upvalues. +Lua closures that share an upvalue +(that is, that access a same external local variable) +will return identical ids for those upvalue indices. + + + + +

    +


    debug.upvaluejoin (f1, n1, f2, n2)

    + + +

    +Make the n1-th upvalue of the Lua closure f1 +refer to the n2-th upvalue of the Lua closure f2. + + + + + + + +

    7 – Lua Standalone

    + +

    +Although Lua has been designed as an extension language, +to be embedded in a host C program, +it is also frequently used as a standalone language. +An interpreter for Lua as a standalone language, +called simply lua, +is provided with the standard distribution. +The standalone interpreter includes +all standard libraries, including the debug library. +Its usage is: + +

    +     lua [options] [script [args]]
    +

    +The options are: + +

      +
    • -e stat: executes string stat;
    • +
    • -l mod: "requires" mod;
    • +
    • -i: enters interactive mode after running script;
    • +
    • -v: prints version information;
    • +
    • -E: ignores environment variables;
    • +
    • --: stops handling options;
    • +
    • -: executes stdin as a file and stops handling options.
    • +

    +After handling its options, lua runs the given script. +When called without arguments, +lua behaves as lua -v -i +when the standard input (stdin) is a terminal, +and as lua - otherwise. + + +

    +When called without option -E, +the interpreter checks for an environment variable LUA_INIT_5_3 +(or LUA_INIT if the versioned name is not defined) +before running any argument. +If the variable content has the format @filename, +then lua executes the file. +Otherwise, lua executes the string itself. + + +

    +When called with option -E, +besides ignoring LUA_INIT, +Lua also ignores +the values of LUA_PATH and LUA_CPATH, +setting the values of +package.path and package.cpath +with the default paths defined in luaconf.h. + + +

    +All options are handled in order, except -i and -E. +For instance, an invocation like + +

    +     $ lua -e'a=1' -e 'print(a)' script.lua
    +

    +will first set a to 1, then print the value of a, +and finally run the file script.lua with no arguments. +(Here $ is the shell prompt. Your prompt may be different.) + + +

    +Before running any code, +lua collects all command-line arguments +in a global table called arg. +The script name goes to index 0, +the first argument after the script name goes to index 1, +and so on. +Any arguments before the script name +(that is, the interpreter name plus its options) +go to negative indices. +For instance, in the call + +

    +     $ lua -la b.lua t1 t2
    +

    +the table is like this: + +

    +     arg = { [-2] = "lua", [-1] = "-la",
    +             [0] = "b.lua",
    +             [1] = "t1", [2] = "t2" }
    +

    +If there is no script in the call, +the interpreter name goes to index 0, +followed by the other arguments. +For instance, the call + +

    +     $ lua -e "print(arg[1])"
    +

    +will print "-e". +If there is a script, +the script is called with parameters +arg[1], ···, arg[#arg]. +(Like all chunks in Lua, +the script is compiled as a vararg function.) + + +

    +In interactive mode, +Lua repeatedly prompts and waits for a line. +After reading a line, +Lua first try to interpret the line as an expression. +If it succeeds, it prints its value. +Otherwise, it interprets the line as a statement. +If you write an incomplete statement, +the interpreter waits for its completion +by issuing a different prompt. + + +

    +If the global variable _PROMPT contains a string, +then its value is used as the prompt. +Similarly, if the global variable _PROMPT2 contains a string, +its value is used as the secondary prompt +(issued during incomplete statements). + + +

    +In case of unprotected errors in the script, +the interpreter reports the error to the standard error stream. +If the error object is not a string but +has a metamethod __tostring, +the interpreter calls this metamethod to produce the final message. +Otherwise, the interpreter converts the error object to a string +and adds a stack traceback to it. + + +

    +When finishing normally, +the interpreter closes its main Lua state +(see lua_close). +The script can avoid this step by +calling os.exit to terminate. + + +

    +To allow the use of Lua as a +script interpreter in Unix systems, +the standalone interpreter skips +the first line of a chunk if it starts with #. +Therefore, Lua scripts can be made into executable programs +by using chmod +x and the #! form, +as in + +

    +     #!/usr/local/bin/lua
    +

    +(Of course, +the location of the Lua interpreter may be different in your machine. +If lua is in your PATH, +then + +

    +     #!/usr/bin/env lua
    +

    +is a more portable solution.) + + + +

    8 – Incompatibilities with the Previous Version

    + +

    +Here we list the incompatibilities that you may find when moving a program +from Lua 5.2 to Lua 5.3. +You can avoid some incompatibilities by compiling Lua with +appropriate options (see file luaconf.h). +However, +all these compatibility options will be removed in the future. + + +

    +Lua versions can always change the C API in ways that +do not imply source-code changes in a program, +such as the numeric values for constants +or the implementation of functions as macros. +Therefore, +you should not assume that binaries are compatible between +different Lua versions. +Always recompile clients of the Lua API when +using a new version. + + +

    +Similarly, Lua versions can always change the internal representation +of precompiled chunks; +precompiled chunks are not compatible between different Lua versions. + + +

    +The standard paths in the official distribution may +change between versions. + + + +

    8.1 – Changes in the Language

    +
      + +
    • +The main difference between Lua 5.2 and Lua 5.3 is the +introduction of an integer subtype for numbers. +Although this change should not affect "normal" computations, +some computations +(mainly those that involve some kind of overflow) +can give different results. + + +

      +You can fix these differences by forcing a number to be a float +(in Lua 5.2 all numbers were float), +in particular writing constants with an ending .0 +or using x = x + 0.0 to convert a variable. +(This recommendation is only for a quick fix +for an occasional incompatibility; +it is not a general guideline for good programming. +For good programming, +use floats where you need floats +and integers where you need integers.) +

    • + +
    • +The conversion of a float to a string now adds a .0 suffix +to the result if it looks like an integer. +(For instance, the float 2.0 will be printed as 2.0, +not as 2.) +You should always use an explicit format +when you need a specific format for numbers. + + +

      +(Formally this is not an incompatibility, +because Lua does not specify how numbers are formatted as strings, +but some programs assumed a specific format.) +

    • + +
    • +The generational mode for the garbage collector was removed. +(It was an experimental feature in Lua 5.2.) +
    • + +
    + + + + +

    8.2 – Changes in the Libraries

    +
      + +
    • +The bit32 library has been deprecated. +It is easy to require a compatible external library or, +better yet, to replace its functions with appropriate bitwise operations. +(Keep in mind that bit32 operates on 32-bit integers, +while the bitwise operators in Lua 5.3 operate on Lua integers, +which by default have 64 bits.) +
    • + +
    • +The Table library now respects metamethods +for setting and getting elements. +
    • + +
    • +The ipairs iterator now respects metamethods and +its __ipairs metamethod has been deprecated. +
    • + +
    • +Option names in io.read do not have a starting '*' anymore. +For compatibility, Lua will continue to accept (and ignore) this character. +
    • + +
    • +The following functions were deprecated in the mathematical library: +atan2, cosh, sinh, tanh, pow, +frexp, and ldexp. +You can replace math.pow(x,y) with x^y; +you can replace math.atan2 with math.atan, +which now accepts one or two parameters; +you can replace math.ldexp(x,exp) with x * 2.0^exp. +For the other operations, +you can either use an external library or +implement them in Lua. +
    • + +
    • +The searcher for C loaders used by require +changed the way it handles versioned names. +Now, the version should come after the module name +(as is usual in most other tools). +For compatibility, that searcher still tries the old format +if it cannot find an open function according to the new style. +(Lua 5.2 already worked that way, +but it did not document the change.) +
    • + +
    • +The call collectgarbage("count") now returns only one result. +(You can compute that second result from the fractional part +of the first result.) +
    • + +
    + + + + +

    8.3 – Changes in the API

    + + +
      + +
    • +Continuation functions now receive as parameters what they needed +to get through lua_getctx, +so lua_getctx has been removed. +Adapt your code accordingly. +
    • + +
    • +Function lua_dump has an extra parameter, strip. +Use 0 as the value of this parameter to get the old behavior. +
    • + +
    • +Functions to inject/project unsigned integers +(lua_pushunsigned, lua_tounsigned, lua_tounsignedx, +luaL_checkunsigned, luaL_optunsigned) +were deprecated. +Use their signed equivalents with a type cast. +
    • + +
    • +Macros to project non-default integer types +(luaL_checkint, luaL_optint, luaL_checklong, luaL_optlong) +were deprecated. +Use their equivalent over lua_Integer with a type cast +(or, when possible, use lua_Integer in your code). +
    • + +
    + + + + +

    9 – The Complete Syntax of Lua

    + +

    +Here is the complete syntax of Lua in extended BNF. +As usual in extended BNF, +{A} means 0 or more As, +and [A] means an optional A. +(For operator precedences, see §3.4.8; +for a description of the terminals +Name, Numeral, +and LiteralString, see §3.1.) + + + + +

    +
    +	chunk ::= block
    +
    +	block ::= {stat} [retstat]
    +
    +	stat ::=  ‘;’ | 
    +		 varlist ‘=’ explist | 
    +		 functioncall | 
    +		 label | 
    +		 break | 
    +		 goto Name | 
    +		 do block end | 
    +		 while exp do block end | 
    +		 repeat block until exp | 
    +		 if exp then block {elseif exp then block} [else block] end | 
    +		 for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end | 
    +		 for namelist in explist do block end | 
    +		 function funcname funcbody | 
    +		 local function Name funcbody | 
    +		 local namelist [‘=’ explist] 
    +
    +	retstat ::= return [explist] [‘;’]
    +
    +	label ::= ‘::’ Name ‘::’
    +
    +	funcname ::= Name {‘.’ Name} [‘:’ Name]
    +
    +	varlist ::= var {‘,’ var}
    +
    +	var ::=  Name | prefixexp ‘[’ exp ‘]’ | prefixexp ‘.’ Name 
    +
    +	namelist ::= Name {‘,’ Name}
    +
    +	explist ::= exp {‘,’ exp}
    +
    +	exp ::=  nil | false | true | Numeral | LiteralString | ‘...’ | functiondef | 
    +		 prefixexp | tableconstructor | exp binop exp | unop exp 
    +
    +	prefixexp ::= var | functioncall | ‘(’ exp ‘)’
    +
    +	functioncall ::=  prefixexp args | prefixexp ‘:’ Name args 
    +
    +	args ::=  ‘(’ [explist] ‘)’ | tableconstructor | LiteralString 
    +
    +	functiondef ::= function funcbody
    +
    +	funcbody ::= ‘(’ [parlist] ‘)’ block end
    +
    +	parlist ::= namelist [‘,’ ‘...’] | ‘...’
    +
    +	tableconstructor ::= ‘{’ [fieldlist] ‘}’
    +
    +	fieldlist ::= field {fieldsep field} [fieldsep]
    +
    +	field ::= ‘[’ exp ‘]’ ‘=’ exp | Name ‘=’ exp | exp
    +
    +	fieldsep ::= ‘,’ | ‘;’
    +
    +	binop ::=  ‘+’ | ‘-’ | ‘*’ | ‘/’ | ‘//’ | ‘^’ | ‘%’ | 
    +		 ‘&’ | ‘~’ | ‘|’ | ‘>>’ | ‘<<’ | ‘..’ | 
    +		 ‘<’ | ‘<=’ | ‘>’ | ‘>=’ | ‘==’ | ‘~=’ | 
    +		 and | or
    +
    +	unop ::= ‘-’ | not | ‘#’ | ‘~’
    +
    +
    + +

    + + + + + + + +

    + + + + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lapi.c b/dep/scintilla/scintilla-3.10.6/lua/src/lapi.c new file mode 100644 index 00000000..c9455a5d --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lapi.c @@ -0,0 +1,1298 @@ +/* +** $Id: lapi.c,v 2.259 2016/02/29 14:27:14 roberto Exp $ +** Lua API +** See Copyright Notice in lua.h +*/ + +#define lapi_c +#define LUA_CORE + +#include "lprefix.h" + + +#include +#include + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" + + + +const char lua_ident[] = + "$LuaVersion: " LUA_COPYRIGHT " $" + "$LuaAuthors: " LUA_AUTHORS " $"; + + +/* value at a non-valid index */ +#define NONVALIDVALUE cast(TValue *, luaO_nilobject) + +/* corresponding test */ +#define isvalid(o) ((o) != luaO_nilobject) + +/* test for pseudo index */ +#define ispseudo(i) ((i) <= LUA_REGISTRYINDEX) + +/* test for upvalue */ +#define isupvalue(i) ((i) < LUA_REGISTRYINDEX) + +/* test for valid but not pseudo index */ +#define isstackindex(i, o) (isvalid(o) && !ispseudo(i)) + +#define api_checkvalidindex(l,o) api_check(l, isvalid(o), "invalid index") + +#define api_checkstackindex(l, i, o) \ + api_check(l, isstackindex(i, o), "index not in the stack") + + +static TValue *index2addr (lua_State *L, int idx) { + CallInfo *ci = L->ci; + if (idx > 0) { + TValue *o = ci->func + idx; + api_check(L, idx <= ci->top - (ci->func + 1), "unacceptable index"); + if (o >= L->top) return NONVALIDVALUE; + else return o; + } + else if (!ispseudo(idx)) { /* negative index */ + api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); + return L->top + idx; + } + else if (idx == LUA_REGISTRYINDEX) + return &G(L)->l_registry; + else { /* upvalues */ + idx = LUA_REGISTRYINDEX - idx; + api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); + if (ttislcf(ci->func)) /* light C function? */ + return NONVALIDVALUE; /* it has no upvalues */ + else { + CClosure *func = clCvalue(ci->func); + return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : NONVALIDVALUE; + } + } +} + + +/* +** to be called by 'lua_checkstack' in protected mode, to grow stack +** capturing memory errors +*/ +static void growstack (lua_State *L, void *ud) { + int size = *(int *)ud; + luaD_growstack(L, size); +} + + +LUA_API int lua_checkstack (lua_State *L, int n) { + int res; + CallInfo *ci = L->ci; + lua_lock(L); + api_check(L, n >= 0, "negative 'n'"); + if (L->stack_last - L->top > n) /* stack large enough? */ + res = 1; /* yes; check is OK */ + else { /* no; need to grow stack */ + int inuse = cast_int(L->top - L->stack) + EXTRA_STACK; + if (inuse > LUAI_MAXSTACK - n) /* can grow without overflow? */ + res = 0; /* no */ + else /* try to grow stack */ + res = (luaD_rawrunprotected(L, &growstack, &n) == LUA_OK); + } + if (res && ci->top < L->top + n) + ci->top = L->top + n; /* adjust frame top */ + lua_unlock(L); + return res; +} + + +LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { + int i; + if (from == to) return; + lua_lock(to); + api_checknelems(from, n); + api_check(from, G(from) == G(to), "moving among independent states"); + api_check(from, to->ci->top - to->top >= n, "stack overflow"); + from->top -= n; + for (i = 0; i < n; i++) { + setobj2s(to, to->top, from->top + i); + to->top++; /* stack already checked by previous 'api_check' */ + } + lua_unlock(to); +} + + +LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { + lua_CFunction old; + lua_lock(L); + old = G(L)->panic; + G(L)->panic = panicf; + lua_unlock(L); + return old; +} + + +LUA_API const lua_Number *lua_version (lua_State *L) { + static const lua_Number version = LUA_VERSION_NUM; + if (L == NULL) return &version; + else return G(L)->version; +} + + + +/* +** basic stack manipulation +*/ + + +/* +** convert an acceptable stack index into an absolute index +*/ +LUA_API int lua_absindex (lua_State *L, int idx) { + return (idx > 0 || ispseudo(idx)) + ? idx + : cast_int(L->top - L->ci->func) + idx; +} + + +LUA_API int lua_gettop (lua_State *L) { + return cast_int(L->top - (L->ci->func + 1)); +} + + +LUA_API void lua_settop (lua_State *L, int idx) { + StkId func = L->ci->func; + lua_lock(L); + if (idx >= 0) { + api_check(L, idx <= L->stack_last - (func + 1), "new top too large"); + while (L->top < (func + 1) + idx) + setnilvalue(L->top++); + L->top = (func + 1) + idx; + } + else { + api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top"); + L->top += idx+1; /* 'subtract' index (index is negative) */ + } + lua_unlock(L); +} + + +/* +** Reverse the stack segment from 'from' to 'to' +** (auxiliary to 'lua_rotate') +*/ +static void reverse (lua_State *L, StkId from, StkId to) { + for (; from < to; from++, to--) { + TValue temp; + setobj(L, &temp, from); + setobjs2s(L, from, to); + setobj2s(L, to, &temp); + } +} + + +/* +** Let x = AB, where A is a prefix of length 'n'. Then, +** rotate x n == BA. But BA == (A^r . B^r)^r. +*/ +LUA_API void lua_rotate (lua_State *L, int idx, int n) { + StkId p, t, m; + lua_lock(L); + t = L->top - 1; /* end of stack segment being rotated */ + p = index2addr(L, idx); /* start of segment */ + api_checkstackindex(L, idx, p); + api_check(L, (n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'"); + m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */ + reverse(L, p, m); /* reverse the prefix with length 'n' */ + reverse(L, m + 1, t); /* reverse the suffix */ + reverse(L, p, t); /* reverse the entire segment */ + lua_unlock(L); +} + + +LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { + TValue *fr, *to; + lua_lock(L); + fr = index2addr(L, fromidx); + to = index2addr(L, toidx); + api_checkvalidindex(L, to); + setobj(L, to, fr); + if (isupvalue(toidx)) /* function upvalue? */ + luaC_barrier(L, clCvalue(L->ci->func), fr); + /* LUA_REGISTRYINDEX does not need gc barrier + (collector revisits it before finishing collection) */ + lua_unlock(L); +} + + +LUA_API void lua_pushvalue (lua_State *L, int idx) { + lua_lock(L); + setobj2s(L, L->top, index2addr(L, idx)); + api_incr_top(L); + lua_unlock(L); +} + + + +/* +** access functions (stack -> C) +*/ + + +LUA_API int lua_type (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + return (isvalid(o) ? ttnov(o) : LUA_TNONE); +} + + +LUA_API const char *lua_typename (lua_State *L, int t) { + UNUSED(L); + api_check(L, LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); + return ttypename(t); +} + + +LUA_API int lua_iscfunction (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + return (ttislcf(o) || (ttisCclosure(o))); +} + + +LUA_API int lua_isinteger (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + return ttisinteger(o); +} + + +LUA_API int lua_isnumber (lua_State *L, int idx) { + lua_Number n; + const TValue *o = index2addr(L, idx); + return tonumber(o, &n); +} + + +LUA_API int lua_isstring (lua_State *L, int idx) { + const TValue *o = index2addr(L, idx); + return (ttisstring(o) || cvt2str(o)); +} + + +LUA_API int lua_isuserdata (lua_State *L, int idx) { + const TValue *o = index2addr(L, idx); + return (ttisfulluserdata(o) || ttislightuserdata(o)); +} + + +LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { + StkId o1 = index2addr(L, index1); + StkId o2 = index2addr(L, index2); + return (isvalid(o1) && isvalid(o2)) ? luaV_rawequalobj(o1, o2) : 0; +} + + +LUA_API void lua_arith (lua_State *L, int op) { + lua_lock(L); + if (op != LUA_OPUNM && op != LUA_OPBNOT) + api_checknelems(L, 2); /* all other operations expect two operands */ + else { /* for unary operations, add fake 2nd operand */ + api_checknelems(L, 1); + setobjs2s(L, L->top, L->top - 1); + api_incr_top(L); + } + /* first operand at top - 2, second at top - 1; result go to top - 2 */ + luaO_arith(L, op, L->top - 2, L->top - 1, L->top - 2); + L->top--; /* remove second operand */ + lua_unlock(L); +} + + +LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { + StkId o1, o2; + int i = 0; + lua_lock(L); /* may call tag method */ + o1 = index2addr(L, index1); + o2 = index2addr(L, index2); + if (isvalid(o1) && isvalid(o2)) { + switch (op) { + case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; + case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; + case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; + default: api_check(L, 0, "invalid option"); + } + } + lua_unlock(L); + return i; +} + + +LUA_API size_t lua_stringtonumber (lua_State *L, const char *s) { + size_t sz = luaO_str2num(s, L->top); + if (sz != 0) + api_incr_top(L); + return sz; +} + + +LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *pisnum) { + lua_Number n; + const TValue *o = index2addr(L, idx); + int isnum = tonumber(o, &n); + if (!isnum) + n = 0; /* call to 'tonumber' may change 'n' even if it fails */ + if (pisnum) *pisnum = isnum; + return n; +} + + +LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *pisnum) { + lua_Integer res; + const TValue *o = index2addr(L, idx); + int isnum = tointeger(o, &res); + if (!isnum) + res = 0; /* call to 'tointeger' may change 'n' even if it fails */ + if (pisnum) *pisnum = isnum; + return res; +} + + +LUA_API int lua_toboolean (lua_State *L, int idx) { + const TValue *o = index2addr(L, idx); + return !l_isfalse(o); +} + + +LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { + StkId o = index2addr(L, idx); + if (!ttisstring(o)) { + if (!cvt2str(o)) { /* not convertible? */ + if (len != NULL) *len = 0; + return NULL; + } + lua_lock(L); /* 'luaO_tostring' may create a new string */ + luaO_tostring(L, o); + luaC_checkGC(L); + o = index2addr(L, idx); /* previous call may reallocate the stack */ + lua_unlock(L); + } + if (len != NULL) + *len = vslen(o); + return svalue(o); +} + + +LUA_API size_t lua_rawlen (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + switch (ttype(o)) { + case LUA_TSHRSTR: return tsvalue(o)->shrlen; + case LUA_TLNGSTR: return tsvalue(o)->u.lnglen; + case LUA_TUSERDATA: return uvalue(o)->len; + case LUA_TTABLE: return luaH_getn(hvalue(o)); + default: return 0; + } +} + + +LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + if (ttislcf(o)) return fvalue(o); + else if (ttisCclosure(o)) + return clCvalue(o)->f; + else return NULL; /* not a C function */ +} + + +LUA_API void *lua_touserdata (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + switch (ttnov(o)) { + case LUA_TUSERDATA: return getudatamem(uvalue(o)); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + +LUA_API lua_State *lua_tothread (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + return (!ttisthread(o)) ? NULL : thvalue(o); +} + + +LUA_API const void *lua_topointer (lua_State *L, int idx) { + StkId o = index2addr(L, idx); + switch (ttype(o)) { + case LUA_TTABLE: return hvalue(o); + case LUA_TLCL: return clLvalue(o); + case LUA_TCCL: return clCvalue(o); + case LUA_TLCF: return cast(void *, cast(size_t, fvalue(o))); + case LUA_TTHREAD: return thvalue(o); + case LUA_TUSERDATA: return getudatamem(uvalue(o)); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + + +/* +** push functions (C -> stack) +*/ + + +LUA_API void lua_pushnil (lua_State *L) { + lua_lock(L); + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { + lua_lock(L); + setfltvalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { + lua_lock(L); + setivalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +/* +** Pushes on the stack a string with given length. Avoid using 's' when +** 'len' == 0 (as 's' can be NULL in that case), due to later use of +** 'memcmp' and 'memcpy'. +*/ +LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) { + TString *ts; + lua_lock(L); + ts = (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len); + setsvalue2s(L, L->top, ts); + api_incr_top(L); + luaC_checkGC(L); + lua_unlock(L); + return getstr(ts); +} + + +LUA_API const char *lua_pushstring (lua_State *L, const char *s) { + lua_lock(L); + if (s == NULL) + setnilvalue(L->top); + else { + TString *ts; + ts = luaS_new(L, s); + setsvalue2s(L, L->top, ts); + s = getstr(ts); /* internal copy's address */ + } + api_incr_top(L); + luaC_checkGC(L); + lua_unlock(L); + return s; +} + + +LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, + va_list argp) { + const char *ret; + lua_lock(L); + ret = luaO_pushvfstring(L, fmt, argp); + luaC_checkGC(L); + lua_unlock(L); + return ret; +} + + +LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { + const char *ret; + va_list argp; + lua_lock(L); + va_start(argp, fmt); + ret = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + luaC_checkGC(L); + lua_unlock(L); + return ret; +} + + +LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { + lua_lock(L); + if (n == 0) { + setfvalue(L->top, fn); + } + else { + CClosure *cl; + api_checknelems(L, n); + api_check(L, n <= MAXUPVAL, "upvalue index too large"); + cl = luaF_newCclosure(L, n); + cl->f = fn; + L->top -= n; + while (n--) { + setobj2n(L, &cl->upvalue[n], L->top + n); + /* does not need barrier because closure is white */ + } + setclCvalue(L, L->top, cl); + } + api_incr_top(L); + luaC_checkGC(L); + lua_unlock(L); +} + + +LUA_API void lua_pushboolean (lua_State *L, int b) { + lua_lock(L); + setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { + lua_lock(L); + setpvalue(L->top, p); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + + +/* +** get functions (Lua -> stack) +*/ + + +static int auxgetstr (lua_State *L, const TValue *t, const char *k) { + const TValue *slot; + TString *str = luaS_new(L, k); + if (luaV_fastget(L, t, str, slot, luaH_getstr)) { + setobj2s(L, L->top, slot); + api_incr_top(L); + } + else { + setsvalue2s(L, L->top, str); + api_incr_top(L); + luaV_finishget(L, t, L->top - 1, L->top - 1, slot); + } + lua_unlock(L); + return ttnov(L->top - 1); +} + + +LUA_API int lua_getglobal (lua_State *L, const char *name) { + Table *reg = hvalue(&G(L)->l_registry); + lua_lock(L); + return auxgetstr(L, luaH_getint(reg, LUA_RIDX_GLOBALS), name); +} + + +LUA_API int lua_gettable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); + return ttnov(L->top - 1); +} + + +LUA_API int lua_getfield (lua_State *L, int idx, const char *k) { + lua_lock(L); + return auxgetstr(L, index2addr(L, idx), k); +} + + +LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) { + StkId t; + const TValue *slot; + lua_lock(L); + t = index2addr(L, idx); + if (luaV_fastget(L, t, n, slot, luaH_getint)) { + setobj2s(L, L->top, slot); + api_incr_top(L); + } + else { + setivalue(L->top, n); + api_incr_top(L); + luaV_finishget(L, t, L->top - 1, L->top - 1, slot); + } + lua_unlock(L); + return ttnov(L->top - 1); +} + + +LUA_API int lua_rawget (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); + lua_unlock(L); + return ttnov(L->top - 1); +} + + +LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setobj2s(L, L->top, luaH_getint(hvalue(t), n)); + api_incr_top(L); + lua_unlock(L); + return ttnov(L->top - 1); +} + + +LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) { + StkId t; + TValue k; + lua_lock(L); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + setpvalue(&k, cast(void *, p)); + setobj2s(L, L->top, luaH_get(hvalue(t), &k)); + api_incr_top(L); + lua_unlock(L); + return ttnov(L->top - 1); +} + + +LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + Table *t; + lua_lock(L); + t = luaH_new(L); + sethvalue(L, L->top, t); + api_incr_top(L); + if (narray > 0 || nrec > 0) + luaH_resize(L, t, narray, nrec); + luaC_checkGC(L); + lua_unlock(L); +} + + +LUA_API int lua_getmetatable (lua_State *L, int objindex) { + const TValue *obj; + Table *mt; + int res = 0; + lua_lock(L); + obj = index2addr(L, objindex); + switch (ttnov(obj)) { + case LUA_TTABLE: + mt = hvalue(obj)->metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(obj)->metatable; + break; + default: + mt = G(L)->mt[ttnov(obj)]; + break; + } + if (mt != NULL) { + sethvalue(L, L->top, mt); + api_incr_top(L); + res = 1; + } + lua_unlock(L); + return res; +} + + +LUA_API int lua_getuservalue (lua_State *L, int idx) { + StkId o; + lua_lock(L); + o = index2addr(L, idx); + api_check(L, ttisfulluserdata(o), "full userdata expected"); + getuservalue(L, uvalue(o), L->top); + api_incr_top(L); + lua_unlock(L); + return ttnov(L->top - 1); +} + + +/* +** set functions (stack -> Lua) +*/ + +/* +** t[k] = value at the top of the stack (where 'k' is a string) +*/ +static void auxsetstr (lua_State *L, const TValue *t, const char *k) { + const TValue *slot; + TString *str = luaS_new(L, k); + api_checknelems(L, 1); + if (luaV_fastset(L, t, str, slot, luaH_getstr, L->top - 1)) + L->top--; /* pop value */ + else { + setsvalue2s(L, L->top, str); /* push 'str' (to make it a TValue) */ + api_incr_top(L); + luaV_finishset(L, t, L->top - 1, L->top - 2, slot); + L->top -= 2; /* pop value and key */ + } + lua_unlock(L); /* lock done by caller */ +} + + +LUA_API void lua_setglobal (lua_State *L, const char *name) { + Table *reg = hvalue(&G(L)->l_registry); + lua_lock(L); /* unlock done in 'auxsetstr' */ + auxsetstr(L, luaH_getint(reg, LUA_RIDX_GLOBALS), name); +} + + +LUA_API void lua_settable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2addr(L, idx); + luaV_settable(L, t, L->top - 2, L->top - 1); + L->top -= 2; /* pop index and value */ + lua_unlock(L); +} + + +LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + lua_lock(L); /* unlock done in 'auxsetstr' */ + auxsetstr(L, index2addr(L, idx), k); +} + + +LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) { + StkId t; + const TValue *slot; + lua_lock(L); + api_checknelems(L, 1); + t = index2addr(L, idx); + if (luaV_fastset(L, t, n, slot, luaH_getint, L->top - 1)) + L->top--; /* pop value */ + else { + setivalue(L->top, n); + api_incr_top(L); + luaV_finishset(L, t, L->top - 1, L->top - 2, slot); + L->top -= 2; /* pop value and key */ + } + lua_unlock(L); +} + + +LUA_API void lua_rawset (lua_State *L, int idx) { + StkId o; + TValue *slot; + lua_lock(L); + api_checknelems(L, 2); + o = index2addr(L, idx); + api_check(L, ttistable(o), "table expected"); + slot = luaH_set(L, hvalue(o), L->top - 2); + setobj2t(L, slot, L->top - 1); + invalidateTMcache(hvalue(o)); + luaC_barrierback(L, hvalue(o), L->top-1); + L->top -= 2; + lua_unlock(L); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2addr(L, idx); + api_check(L, ttistable(o), "table expected"); + luaH_setint(L, hvalue(o), n, L->top - 1); + luaC_barrierback(L, hvalue(o), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) { + StkId o; + TValue k, *slot; + lua_lock(L); + api_checknelems(L, 1); + o = index2addr(L, idx); + api_check(L, ttistable(o), "table expected"); + setpvalue(&k, cast(void *, p)); + slot = luaH_set(L, hvalue(o), &k); + setobj2t(L, slot, L->top - 1); + luaC_barrierback(L, hvalue(o), L->top - 1); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_setmetatable (lua_State *L, int objindex) { + TValue *obj; + Table *mt; + lua_lock(L); + api_checknelems(L, 1); + obj = index2addr(L, objindex); + if (ttisnil(L->top - 1)) + mt = NULL; + else { + api_check(L, ttistable(L->top - 1), "table expected"); + mt = hvalue(L->top - 1); + } + switch (ttnov(obj)) { + case LUA_TTABLE: { + hvalue(obj)->metatable = mt; + if (mt) { + luaC_objbarrier(L, gcvalue(obj), mt); + luaC_checkfinalizer(L, gcvalue(obj), mt); + } + break; + } + case LUA_TUSERDATA: { + uvalue(obj)->metatable = mt; + if (mt) { + luaC_objbarrier(L, uvalue(obj), mt); + luaC_checkfinalizer(L, gcvalue(obj), mt); + } + break; + } + default: { + G(L)->mt[ttnov(obj)] = mt; + break; + } + } + L->top--; + lua_unlock(L); + return 1; +} + + +LUA_API void lua_setuservalue (lua_State *L, int idx) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2addr(L, idx); + api_check(L, ttisfulluserdata(o), "full userdata expected"); + setuservalue(L, uvalue(o), L->top - 1); + luaC_barrier(L, gcvalue(o), L->top - 1); + L->top--; + lua_unlock(L); +} + + +/* +** 'load' and 'call' functions (run Lua code) +*/ + + +#define checkresults(L,na,nr) \ + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ + "results from function overflow current stack size") + + +LUA_API void lua_callk (lua_State *L, int nargs, int nresults, + lua_KContext ctx, lua_KFunction k) { + StkId func; + lua_lock(L); + api_check(L, k == NULL || !isLua(L->ci), + "cannot use continuations inside hooks"); + api_checknelems(L, nargs+1); + api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); + checkresults(L, nargs, nresults); + func = L->top - (nargs+1); + if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ + L->ci->u.c.k = k; /* save continuation */ + L->ci->u.c.ctx = ctx; /* save context */ + luaD_call(L, func, nresults); /* do the call */ + } + else /* no continuation or no yieldable */ + luaD_callnoyield(L, func, nresults); /* just do the call */ + adjustresults(L, nresults); + lua_unlock(L); +} + + + +/* +** Execute a protected call. +*/ +struct CallS { /* data to 'f_call' */ + StkId func; + int nresults; +}; + + +static void f_call (lua_State *L, void *ud) { + struct CallS *c = cast(struct CallS *, ud); + luaD_callnoyield(L, c->func, c->nresults); +} + + + +LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, + lua_KContext ctx, lua_KFunction k) { + struct CallS c; + int status; + ptrdiff_t func; + lua_lock(L); + api_check(L, k == NULL || !isLua(L->ci), + "cannot use continuations inside hooks"); + api_checknelems(L, nargs+1); + api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread"); + checkresults(L, nargs, nresults); + if (errfunc == 0) + func = 0; + else { + StkId o = index2addr(L, errfunc); + api_checkstackindex(L, errfunc, o); + func = savestack(L, o); + } + c.func = L->top - (nargs+1); /* function to be called */ + if (k == NULL || L->nny > 0) { /* no continuation or no yieldable? */ + c.nresults = nresults; /* do a 'conventional' protected call */ + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + } + else { /* prepare continuation (call is already protected by 'resume') */ + CallInfo *ci = L->ci; + ci->u.c.k = k; /* save continuation */ + ci->u.c.ctx = ctx; /* save context */ + /* save information for error recovery */ + ci->extra = savestack(L, c.func); + ci->u.c.old_errfunc = L->errfunc; + L->errfunc = func; + setoah(ci->callstatus, L->allowhook); /* save value of 'allowhook' */ + ci->callstatus |= CIST_YPCALL; /* function can do error recovery */ + luaD_call(L, c.func, nresults); /* do the call */ + ci->callstatus &= ~CIST_YPCALL; + L->errfunc = ci->u.c.old_errfunc; + status = LUA_OK; /* if it is here, there were no errors */ + } + adjustresults(L, nresults); + lua_unlock(L); + return status; +} + + +LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, + const char *chunkname, const char *mode) { + ZIO z; + int status; + lua_lock(L); + if (!chunkname) chunkname = "?"; + luaZ_init(L, &z, reader, data); + status = luaD_protectedparser(L, &z, chunkname, mode); + if (status == LUA_OK) { /* no errors? */ + LClosure *f = clLvalue(L->top - 1); /* get newly created function */ + if (f->nupvalues >= 1) { /* does it have an upvalue? */ + /* get global table from registry */ + Table *reg = hvalue(&G(L)->l_registry); + const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS); + /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ + setobj(L, f->upvals[0]->v, gt); + luaC_upvalbarrier(L, f->upvals[0]); + } + } + lua_unlock(L); + return status; +} + + +LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip) { + int status; + TValue *o; + lua_lock(L); + api_checknelems(L, 1); + o = L->top - 1; + if (isLfunction(o)) + status = luaU_dump(L, getproto(o), writer, data, strip); + else + status = 1; + lua_unlock(L); + return status; +} + + +LUA_API int lua_status (lua_State *L) { + return L->status; +} + + +/* +** Garbage-collection function +*/ + +LUA_API int lua_gc (lua_State *L, int what, int data) { + int res = 0; + global_State *g; + lua_lock(L); + g = G(L); + switch (what) { + case LUA_GCSTOP: { + g->gcrunning = 0; + break; + } + case LUA_GCRESTART: { + luaE_setdebt(g, 0); + g->gcrunning = 1; + break; + } + case LUA_GCCOLLECT: { + luaC_fullgc(L, 0); + break; + } + case LUA_GCCOUNT: { + /* GC values are expressed in Kbytes: #bytes/2^10 */ + res = cast_int(gettotalbytes(g) >> 10); + break; + } + case LUA_GCCOUNTB: { + res = cast_int(gettotalbytes(g) & 0x3ff); + break; + } + case LUA_GCSTEP: { + l_mem debt = 1; /* =1 to signal that it did an actual step */ + lu_byte oldrunning = g->gcrunning; + g->gcrunning = 1; /* allow GC to run */ + if (data == 0) { + luaE_setdebt(g, -GCSTEPSIZE); /* to do a "small" step */ + luaC_step(L); + } + else { /* add 'data' to total debt */ + debt = cast(l_mem, data) * 1024 + g->GCdebt; + luaE_setdebt(g, debt); + luaC_checkGC(L); + } + g->gcrunning = oldrunning; /* restore previous state */ + if (debt > 0 && g->gcstate == GCSpause) /* end of cycle? */ + res = 1; /* signal it */ + break; + } + case LUA_GCSETPAUSE: { + res = g->gcpause; + g->gcpause = data; + break; + } + case LUA_GCSETSTEPMUL: { + res = g->gcstepmul; + if (data < 40) data = 40; /* avoid ridiculous low values (and 0) */ + g->gcstepmul = data; + break; + } + case LUA_GCISRUNNING: { + res = g->gcrunning; + break; + } + default: res = -1; /* invalid option */ + } + lua_unlock(L); + return res; +} + + + +/* +** miscellaneous functions +*/ + + +LUA_API int lua_error (lua_State *L) { + lua_lock(L); + api_checknelems(L, 1); + luaG_errormsg(L); + /* code unreachable; will unlock when control actually leaves the kernel */ + return 0; /* to avoid warnings */ +} + + +LUA_API int lua_next (lua_State *L, int idx) { + StkId t; + int more; + lua_lock(L); + t = index2addr(L, idx); + api_check(L, ttistable(t), "table expected"); + more = luaH_next(L, hvalue(t), L->top - 1); + if (more) { + api_incr_top(L); + } + else /* no more elements */ + L->top -= 1; /* remove key */ + lua_unlock(L); + return more; +} + + +LUA_API void lua_concat (lua_State *L, int n) { + lua_lock(L); + api_checknelems(L, n); + if (n >= 2) { + luaV_concat(L, n); + } + else if (n == 0) { /* push empty string */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ + luaC_checkGC(L); + lua_unlock(L); +} + + +LUA_API void lua_len (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2addr(L, idx); + luaV_objlen(L, L->top, t); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { + lua_Alloc f; + lua_lock(L); + if (ud) *ud = G(L)->ud; + f = G(L)->frealloc; + lua_unlock(L); + return f; +} + + +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { + lua_lock(L); + G(L)->ud = ud; + G(L)->frealloc = f; + lua_unlock(L); +} + + +LUA_API void *lua_newuserdata (lua_State *L, size_t size) { + Udata *u; + lua_lock(L); + u = luaS_newudata(L, size); + setuvalue(L, L->top, u); + api_incr_top(L); + luaC_checkGC(L); + lua_unlock(L); + return getudatamem(u); +} + + + +static const char *aux_upvalue (StkId fi, int n, TValue **val, + CClosure **owner, UpVal **uv) { + switch (ttype(fi)) { + case LUA_TCCL: { /* C closure */ + CClosure *f = clCvalue(fi); + if (!(1 <= n && n <= f->nupvalues)) return NULL; + *val = &f->upvalue[n-1]; + if (owner) *owner = f; + return ""; + } + case LUA_TLCL: { /* Lua closure */ + LClosure *f = clLvalue(fi); + TString *name; + Proto *p = f->p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->upvals[n-1]->v; + if (uv) *uv = f->upvals[n - 1]; + name = p->upvalues[n-1].name; + return (name == NULL) ? "(*no name)" : getstr(name); + } + default: return NULL; /* not a closure */ + } +} + + +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val = NULL; /* to avoid warnings */ + lua_lock(L); + name = aux_upvalue(index2addr(L, funcindex), n, &val, NULL, NULL); + if (name) { + setobj2s(L, L->top, val); + api_incr_top(L); + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val = NULL; /* to avoid warnings */ + CClosure *owner = NULL; + UpVal *uv = NULL; + StkId fi; + lua_lock(L); + fi = index2addr(L, funcindex); + api_checknelems(L, 1); + name = aux_upvalue(fi, n, &val, &owner, &uv); + if (name) { + L->top--; + setobj(L, val, L->top); + if (owner) { luaC_barrier(L, owner, L->top); } + else if (uv) { luaC_upvalbarrier(L, uv); } + } + lua_unlock(L); + return name; +} + + +static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { + LClosure *f; + StkId fi = index2addr(L, fidx); + api_check(L, ttisLclosure(fi), "Lua function expected"); + f = clLvalue(fi); + api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); + if (pf) *pf = f; + return &f->upvals[n - 1]; /* get its upvalue pointer */ +} + + +LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) { + StkId fi = index2addr(L, fidx); + switch (ttype(fi)) { + case LUA_TLCL: { /* lua closure */ + return *getupvalref(L, fidx, n, NULL); + } + case LUA_TCCL: { /* C closure */ + CClosure *f = clCvalue(fi); + api_check(L, 1 <= n && n <= f->nupvalues, "invalid upvalue index"); + return &f->upvalue[n - 1]; + } + default: { + api_check(L, 0, "closure expected"); + return NULL; + } + } +} + + +LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, + int fidx2, int n2) { + LClosure *f1; + UpVal **up1 = getupvalref(L, fidx1, n1, &f1); + UpVal **up2 = getupvalref(L, fidx2, n2, NULL); + luaC_upvdeccount(L, *up1); + *up1 = *up2; + (*up1)->refcount++; + if (upisopen(*up1)) (*up1)->u.open.touched = 1; + luaC_upvalbarrier(L, *up1); +} + + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lapi.h b/dep/scintilla/scintilla-3.10.6/lua/src/lapi.h new file mode 100644 index 00000000..6d36dee3 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lapi.h @@ -0,0 +1,24 @@ +/* +** $Id: lapi.h,v 2.9 2015/03/06 19:49:50 roberto Exp $ +** Auxiliary functions from Lua API +** See Copyright Notice in lua.h +*/ + +#ifndef lapi_h +#define lapi_h + + +#include "llimits.h" +#include "lstate.h" + +#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ + "stack overflow");} + +#define adjustresults(L,nres) \ + { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } + +#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ + "not enough elements in the stack") + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lauxlib.c b/dep/scintilla/scintilla-3.10.6/lua/src/lauxlib.c new file mode 100644 index 00000000..f7a38366 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lauxlib.c @@ -0,0 +1,1043 @@ +/* +** $Id: lauxlib.c,v 1.289 2016/12/20 18:37:00 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include +#include +#include +#include + + +/* +** This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#include "lua.h" + +#include "lauxlib.h" + + +/* +** {====================================================== +** Traceback +** ======================================================= +*/ + + +#define LEVELS1 10 /* size of the first part of the stack */ +#define LEVELS2 11 /* size of the second part of the stack */ + + + +/* +** search for 'objidx' in table at index -1. +** return 1 + string at top if find a good name. +*/ +static int findfield (lua_State *L, int objidx, int level) { + if (level == 0 || !lua_istable(L, -1)) + return 0; /* not found */ + lua_pushnil(L); /* start 'next' loop */ + while (lua_next(L, -2)) { /* for each pair in table */ + if (lua_type(L, -2) == LUA_TSTRING) { /* ignore non-string keys */ + if (lua_rawequal(L, objidx, -1)) { /* found object? */ + lua_pop(L, 1); /* remove value (but keep name) */ + return 1; + } + else if (findfield(L, objidx, level - 1)) { /* try recursively */ + lua_remove(L, -2); /* remove table (but keep name) */ + lua_pushliteral(L, "."); + lua_insert(L, -2); /* place '.' between the two names */ + lua_concat(L, 3); + return 1; + } + } + lua_pop(L, 1); /* remove value */ + } + return 0; /* not found */ +} + + +/* +** Search for a name for a function in all loaded modules +*/ +static int pushglobalfuncname (lua_State *L, lua_Debug *ar) { + int top = lua_gettop(L); + lua_getinfo(L, "f", ar); /* push function */ + lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); + if (findfield(L, top + 1, 2)) { + const char *name = lua_tostring(L, -1); + if (strncmp(name, "_G.", 3) == 0) { /* name start with '_G.'? */ + lua_pushstring(L, name + 3); /* push name without prefix */ + lua_remove(L, -2); /* remove original name */ + } + lua_copy(L, -1, top + 1); /* move name to proper place */ + lua_pop(L, 2); /* remove pushed values */ + return 1; + } + else { + lua_settop(L, top); /* remove function and global table */ + return 0; + } +} + + +static void pushfuncname (lua_State *L, lua_Debug *ar) { + if (pushglobalfuncname(L, ar)) { /* try first a global name */ + lua_pushfstring(L, "function '%s'", lua_tostring(L, -1)); + lua_remove(L, -2); /* remove name */ + } + else if (*ar->namewhat != '\0') /* is there a name from code? */ + lua_pushfstring(L, "%s '%s'", ar->namewhat, ar->name); /* use it */ + else if (*ar->what == 'm') /* main? */ + lua_pushliteral(L, "main chunk"); + else if (*ar->what != 'C') /* for Lua functions, use */ + lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined); + else /* nothing left... */ + lua_pushliteral(L, "?"); +} + + +static int lastlevel (lua_State *L) { + lua_Debug ar; + int li = 1, le = 1; + /* find an upper bound */ + while (lua_getstack(L, le, &ar)) { li = le; le *= 2; } + /* do a binary search */ + while (li < le) { + int m = (li + le)/2; + if (lua_getstack(L, m, &ar)) li = m + 1; + else le = m; + } + return le - 1; +} + + +LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, + const char *msg, int level) { + lua_Debug ar; + int top = lua_gettop(L); + int last = lastlevel(L1); + int n1 = (last - level > LEVELS1 + LEVELS2) ? LEVELS1 : -1; + if (msg) + lua_pushfstring(L, "%s\n", msg); + luaL_checkstack(L, 10, NULL); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (n1-- == 0) { /* too many levels? */ + lua_pushliteral(L, "\n\t..."); /* add a '...' */ + level = last - LEVELS2 + 1; /* and skip to last ones */ + } + else { + lua_getinfo(L1, "Slnt", &ar); + lua_pushfstring(L, "\n\t%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + lua_pushliteral(L, " in "); + pushfuncname(L, &ar); + if (ar.istailcall) + lua_pushliteral(L, "\n\t(...tail calls...)"); + lua_concat(L, lua_gettop(L) - top); + } + } + lua_concat(L, lua_gettop(L) - top); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + +LUALIB_API int luaL_argerror (lua_State *L, int arg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", arg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + arg--; /* do not count 'self' */ + if (arg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling '%s' on bad self (%s)", + ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?"; + return luaL_error(L, "bad argument #%d to '%s' (%s)", + arg, ar.name, extramsg); +} + + +static int typeerror (lua_State *L, int arg, const char *tname) { + const char *msg; + const char *typearg; /* name for the type of the actual argument */ + if (luaL_getmetafield(L, arg, "__name") == LUA_TSTRING) + typearg = lua_tostring(L, -1); /* use the given type name */ + else if (lua_type(L, arg) == LUA_TLIGHTUSERDATA) + typearg = "light userdata"; /* special name for messages */ + else + typearg = luaL_typename(L, arg); /* standard name */ + msg = lua_pushfstring(L, "%s expected, got %s", tname, typearg); + return luaL_argerror(L, arg, msg); +} + + +static void tag_error (lua_State *L, int arg, int tag) { + typeerror(L, arg, lua_typename(L, tag)); +} + + +/* +** The use of 'lua_pushfstring' ensures this function does not +** need reserved stack space when called. +*/ +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushfstring(L, ""); /* else, no information available... */ +} + + +/* +** Again, the use of 'lua_pushvfstring' ensures this function does +** not need reserved stack space when called. (At worst, it generates +** an error with "stack overflow" instead of the given message.) +*/ +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + + +LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { + int en = errno; /* calls to Lua API may change this value */ + if (stat) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (fname) + lua_pushfstring(L, "%s: %s", fname, strerror(en)); + else + lua_pushstring(L, strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +#if !defined(l_inspectstat) /* { */ + +#if defined(LUA_USE_POSIX) + +#include + +/* +** use appropriate macros to interpret 'pclose' return status +*/ +#define l_inspectstat(stat,what) \ + if (WIFEXITED(stat)) { stat = WEXITSTATUS(stat); } \ + else if (WIFSIGNALED(stat)) { stat = WTERMSIG(stat); what = "signal"; } + +#else + +#define l_inspectstat(stat,what) /* no op */ + +#endif + +#endif /* } */ + + +LUALIB_API int luaL_execresult (lua_State *L, int stat) { + const char *what = "exit"; /* type of termination */ + if (stat == -1) /* error? */ + return luaL_fileresult(L, 0, NULL); + else { + l_inspectstat(stat, what); /* interpret result */ + if (*what == 'e' && stat == 0) /* successful termination? */ + lua_pushboolean(L, 1); + else + lua_pushnil(L); + lua_pushstring(L, what); + lua_pushinteger(L, stat); + return 3; /* return true/nil,what,code */ + } +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Userdata's metatable manipulation +** ======================================================= +*/ + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + if (luaL_getmetatable(L, tname) != LUA_TNIL) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_createtable(L, 0, 2); /* create metatable */ + lua_pushstring(L, tname); + lua_setfield(L, -2, "__name"); /* metatable.__name = tname */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) { + luaL_getmetatable(L, tname); + lua_setmetatable(L, -2); +} + + +LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + luaL_getmetatable(L, tname); /* get correct metatable */ + if (!lua_rawequal(L, -1, -2)) /* not the same? */ + p = NULL; /* value is a userdata with wrong metatable */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + return NULL; /* value is not a userdata with a metatable */ +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = luaL_testudata(L, ud, tname); + if (p == NULL) typeerror(L, ud, tname); + return p; +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Argument check functions +** ======================================================= +*/ + +LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, arg, def) : + luaL_checkstring(L, arg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, arg, + lua_pushfstring(L, "invalid option '%s'", name)); +} + + +/* +** Ensures the stack has at least 'space' extra slots, raising an error +** if it cannot fulfill the request. (The error handling needs a few +** extra slots to format the error message. In case of an error without +** this extra space, Lua will generate the same 'stack overflow' error, +** but without 'msg'.) +*/ +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { + if (!lua_checkstack(L, space)) { + if (msg) + luaL_error(L, "stack overflow (%s)", msg); + else + luaL_error(L, "stack overflow"); + } +} + + +LUALIB_API void luaL_checktype (lua_State *L, int arg, int t) { + if (lua_type(L, arg) != t) + tag_error(L, arg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int arg) { + if (lua_type(L, arg) == LUA_TNONE) + luaL_argerror(L, arg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int arg, size_t *len) { + const char *s = lua_tolstring(L, arg, len); + if (!s) tag_error(L, arg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int arg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, arg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, arg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int arg) { + int isnum; + lua_Number d = lua_tonumberx(L, arg, &isnum); + if (!isnum) + tag_error(L, arg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, arg, def); +} + + +static void interror (lua_State *L, int arg) { + if (lua_isnumber(L, arg)) + luaL_argerror(L, arg, "number has no integer representation"); + else + tag_error(L, arg, LUA_TNUMBER); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int arg) { + int isnum; + lua_Integer d = lua_tointegerx(L, arg, &isnum); + if (!isnum) { + interror(L, arg); + } + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int arg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, arg, def); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + +/* userdata to box arbitrary data */ +typedef struct UBox { + void *box; + size_t bsize; +} UBox; + + +static void *resizebox (lua_State *L, int idx, size_t newsize) { + void *ud; + lua_Alloc allocf = lua_getallocf(L, &ud); + UBox *box = (UBox *)lua_touserdata(L, idx); + void *temp = allocf(ud, box->box, box->bsize, newsize); + if (temp == NULL && newsize > 0) { /* allocation error? */ + resizebox(L, idx, 0); /* free buffer */ + luaL_error(L, "not enough memory for buffer allocation"); + } + box->box = temp; + box->bsize = newsize; + return temp; +} + + +static int boxgc (lua_State *L) { + resizebox(L, 1, 0); + return 0; +} + + +static void *newbox (lua_State *L, size_t newsize) { + UBox *box = (UBox *)lua_newuserdata(L, sizeof(UBox)); + box->box = NULL; + box->bsize = 0; + if (luaL_newmetatable(L, "LUABOX")) { /* creating metatable? */ + lua_pushcfunction(L, boxgc); + lua_setfield(L, -2, "__gc"); /* metatable.__gc = boxgc */ + } + lua_setmetatable(L, -2); + return resizebox(L, -1, newsize); +} + + +/* +** check whether buffer is using a userdata on the stack as a temporary +** buffer +*/ +#define buffonstack(B) ((B)->b != (B)->initb) + + +/* +** returns a pointer to a free area with at least 'sz' bytes +*/ +LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) { + lua_State *L = B->L; + if (B->size - B->n < sz) { /* not enough space? */ + char *newbuff; + size_t newsize = B->size * 2; /* double buffer size */ + if (newsize - B->n < sz) /* not big enough? */ + newsize = B->n + sz; + if (newsize < B->n || newsize - B->n < sz) + luaL_error(L, "buffer too large"); + /* create larger buffer */ + if (buffonstack(B)) + newbuff = (char *)resizebox(L, -1, newsize); + else { /* no buffer yet */ + newbuff = (char *)newbox(L, newsize); + memcpy(newbuff, B->b, B->n * sizeof(char)); /* copy original content */ + } + B->b = newbuff; + B->size = newsize; + } + return &B->b[B->n]; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + if (l > 0) { /* avoid 'memcpy' when 's' can be NULL */ + char *b = luaL_prepbuffsize(B, l); + memcpy(b, s, l * sizeof(char)); + luaL_addsize(B, l); + } +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + lua_State *L = B->L; + lua_pushlstring(L, B->b, B->n); + if (buffonstack(B)) { + resizebox(L, -2, 0); /* delete old buffer */ + lua_remove(L, -2); /* remove its header from the stack */ + } +} + + +LUALIB_API void luaL_pushresultsize (luaL_Buffer *B, size_t sz) { + luaL_addsize(B, sz); + luaL_pushresult(B); +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t l; + const char *s = lua_tolstring(L, -1, &l); + if (buffonstack(B)) + lua_insert(L, -2); /* put value below buffer */ + luaL_addlstring(B, s, l); + lua_remove(L, (buffonstack(B)) ? -2 : -1); /* remove value */ +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->b = B->initb; + B->n = 0; + B->size = LUAL_BUFFERSIZE; +} + + +LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) { + luaL_buffinit(L, B); + return luaL_prepbuffsize(B, sz); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Reference system +** ======================================================= +*/ + +/* index of free-list header */ +#define freelist 0 + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* 'nil' has a unique fixed reference */ + } + t = lua_absindex(L, t); + lua_rawgeti(L, t, freelist); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */ + } + else /* no free elements */ + ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */ + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = lua_absindex(L, t); + lua_rawgeti(L, t, freelist); + lua_rawseti(L, t, ref); /* t[ref] = t[freelist] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, freelist); /* t[freelist] = ref */ + } +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int n; /* number of pre-read characters */ + FILE *f; /* file being read */ + char buff[BUFSIZ]; /* area for reading file */ +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; /* not used */ + if (lf->n > 0) { /* are there pre-read characters to be read? */ + *size = lf->n; /* return them (chars already in buffer) */ + lf->n = 0; /* no more pre-read characters */ + } + else { /* read a block from file */ + /* 'fread' can return > 0 *and* set the EOF flag. If next call to + 'getF' called 'fread', it might still wait for user input. + The next check avoids this problem. */ + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); /* read block */ + } + return lf->buff; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +static int skipBOM (LoadF *lf) { + const char *p = "\xEF\xBB\xBF"; /* UTF-8 BOM mark */ + int c; + lf->n = 0; + do { + c = getc(lf->f); + if (c == EOF || c != *(const unsigned char *)p++) return c; + lf->buff[lf->n++] = c; /* to be read by the parser */ + } while (*p != '\0'); + lf->n = 0; /* prefix matched; discard it */ + return getc(lf->f); /* return next character */ +} + + +/* +** reads the first character of file 'f' and skips an optional BOM mark +** in its beginning plus its first line if it starts with '#'. Returns +** true if it skipped the first line. In any case, '*cp' has the +** first "valid" character of the file (after the optional BOM and +** a first-line comment). +*/ +static int skipcomment (LoadF *lf, int *cp) { + int c = *cp = skipBOM(lf); + if (c == '#') { /* first line is a comment (Unix exec. file)? */ + do { /* skip first line */ + c = getc(lf->f); + } while (c != EOF && c != '\n'); + *cp = getc(lf->f); /* skip end-of-line, if present */ + return 1; /* there was a comment */ + } + else return 0; /* no comment */ +} + + +LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename, + const char *mode) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + if (skipcomment(&lf, &c)) /* read initial portion */ + lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */ + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + skipcomment(&lf, &c); /* re-read initial portion */ + } + if (c != EOF) + lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */ + status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; /* not used */ + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbufferx (lua_State *L, const char *buff, size_t size, + const char *name, const char *mode) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name, mode); +} + + +LUALIB_API int luaL_loadstring (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + +/* }====================================================== */ + + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return LUA_TNIL; + else { + int tt; + lua_pushstring(L, event); + tt = lua_rawget(L, -2); + if (tt == LUA_TNIL) /* is metafield nil? */ + lua_pop(L, 2); /* remove metatable and metafield */ + else + lua_remove(L, -2); /* remove only metatable */ + return tt; /* return metafield type */ + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = lua_absindex(L, obj); + if (luaL_getmetafield(L, obj, event) == LUA_TNIL) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API lua_Integer luaL_len (lua_State *L, int idx) { + lua_Integer l; + int isnum; + lua_len(L, idx); + l = lua_tointegerx(L, -1, &isnum); + if (!isnum) + luaL_error(L, "object length is not an integer"); + lua_pop(L, 1); /* remove object */ + return l; +} + + +LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { + if (luaL_callmeta(L, idx, "__tostring")) { /* metafield? */ + if (!lua_isstring(L, -1)) + luaL_error(L, "'__tostring' must return a string"); + } + else { + switch (lua_type(L, idx)) { + case LUA_TNUMBER: { + if (lua_isinteger(L, idx)) + lua_pushfstring(L, "%I", (LUAI_UACINT)lua_tointeger(L, idx)); + else + lua_pushfstring(L, "%f", (LUAI_UACNUMBER)lua_tonumber(L, idx)); + break; + } + case LUA_TSTRING: + lua_pushvalue(L, idx); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, idx) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: { + int tt = luaL_getmetafield(L, idx, "__name"); /* try name */ + const char *kind = (tt == LUA_TSTRING) ? lua_tostring(L, -1) : + luaL_typename(L, idx); + lua_pushfstring(L, "%s: %p", kind, lua_topointer(L, idx)); + if (tt != LUA_TNIL) + lua_remove(L, -2); /* remove '__name' */ + break; + } + } + } + return lua_tolstring(L, -1, len); +} + + +/* +** {====================================================== +** Compatibility with 5.1 module functions +** ======================================================= +*/ +#if defined(LUA_COMPAT_MODULE) + +static const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + if (idx) lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + if (lua_rawget(L, -2) == LUA_TNIL) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + +/* +** Count number of elements in a luaL_Reg list. +*/ +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l && l->name; l++) size++; + return size; +} + + +/* +** Find or create a module table with a given name. The function +** first looks at the LOADED table and, if that fails, try a +** global variable with that name. In any case, leaves on the stack +** the module table. +*/ +LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname, + int sizehint) { + luaL_findtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE, 1); + if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no LOADED[modname]? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + lua_pushglobaltable(L); + if (luaL_findtable(L, 0, modname, sizehint) != NULL) + luaL_error(L, "name conflict for module '%s'", modname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, modname); /* LOADED[modname] = new table */ + } + lua_remove(L, -2); /* remove LOADED table */ +} + + +LUALIB_API void luaL_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + luaL_checkversion(L); + if (libname) { + luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */ + lua_insert(L, -(nup + 1)); /* move library table to below upvalues */ + } + if (l) + luaL_setfuncs(L, l, nup); + else + lua_pop(L, nup); /* remove upvalues */ +} + +#endif +/* }====================================================== */ + +/* +** set functions from list 'l' into table at top - 'nup'; each +** function gets the 'nup' elements at the top as upvalues. +** Returns with only the table at the stack. +*/ +LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { + luaL_checkstack(L, nup, "too many upvalues"); + for (; l->name != NULL; l++) { /* fill the table with given functions */ + int i; + for (i = 0; i < nup; i++) /* copy upvalues to the top */ + lua_pushvalue(L, -nup); + lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ + lua_setfield(L, -(nup + 2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + +/* +** ensure that stack[idx][fname] has a table and push that table +** into the stack +*/ +LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { + if (lua_getfield(L, idx, fname) == LUA_TTABLE) + return 1; /* table already there */ + else { + lua_pop(L, 1); /* remove previous result */ + idx = lua_absindex(L, idx); + lua_newtable(L); + lua_pushvalue(L, -1); /* copy to be left at top */ + lua_setfield(L, idx, fname); /* assign new table to field */ + return 0; /* false, because did not find table there */ + } +} + + +/* +** Stripped-down 'require': After checking "loaded" table, calls 'openf' +** to open a module, registers the result in 'package.loaded' table and, +** if 'glb' is true, also registers the result in the global table. +** Leaves resulting module on the top. +*/ +LUALIB_API void luaL_requiref (lua_State *L, const char *modname, + lua_CFunction openf, int glb) { + luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); + lua_getfield(L, -1, modname); /* LOADED[modname] */ + if (!lua_toboolean(L, -1)) { /* package not already loaded? */ + lua_pop(L, 1); /* remove field */ + lua_pushcfunction(L, openf); + lua_pushstring(L, modname); /* argument to open function */ + lua_call(L, 1, 1); /* call 'openf' to open module */ + lua_pushvalue(L, -1); /* make copy of module (call result) */ + lua_setfield(L, -3, modname); /* LOADED[modname] = module */ + } + lua_remove(L, -2); /* remove LOADED table */ + if (glb) { + lua_pushvalue(L, -1); /* copy of module */ + lua_setglobal(L, modname); /* _G[modname] = module */ + } +} + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after 'p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; (void)osize; /* not used */ + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; /* return to Lua to abort */ +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + + +LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz) { + const lua_Number *v = lua_version(L); + if (sz != LUAL_NUMSIZES) /* check numeric types */ + luaL_error(L, "core and library have incompatible numeric types"); + if (v != lua_version(NULL)) + luaL_error(L, "multiple Lua VMs detected"); + else if (*v != ver) + luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f", + (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)*v); +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lauxlib.h b/dep/scintilla/scintilla-3.10.6/lua/src/lauxlib.h new file mode 100644 index 00000000..9a2e66aa --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lauxlib.h @@ -0,0 +1,264 @@ +/* +** $Id: lauxlib.h,v 1.131 2016/12/06 14:54:31 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + + +/* extra error code for 'luaL_loadfilex' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +/* key, in the registry, for table of loaded modules */ +#define LUA_LOADED_TABLE "_LOADED" + + +/* key, in the registry, for table of preloaded loaders */ +#define LUA_PRELOAD_TABLE "_PRELOAD" + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + +#define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number)) + +LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz); +#define luaL_checkversion(L) \ + luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES) + +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); +LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int arg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); +LUALIB_API int (luaL_execresult) (lua_State *L, int stat); + +/* predefined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, + const char *mode); + +#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) + +LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, + const char *name, const char *mode); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + +LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); + +LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); + +LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, + const char *msg, int level); + +LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, + lua_CFunction openf, int glb); + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + + +#define luaL_newlibtable(L,l) \ + lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) + +#define luaL_newlib(L,l) \ + (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) + +#define luaL_argcheck(L, cond,arg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (arg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + +typedef struct luaL_Buffer { + char *b; /* buffer address */ + size_t size; /* buffer size */ + size_t n; /* number of characters in buffer */ + lua_State *L; + char initb[LUAL_BUFFERSIZE]; /* initial buffer */ +} luaL_Buffer; + + +#define luaL_addchar(B,c) \ + ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ + ((B)->b[(B)->n++] = (c))) + +#define luaL_addsize(B,s) ((B)->n += (s)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); +LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); + +#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) + +/* }====================================================== */ + + + +/* +** {====================================================== +** File handles for IO library +** ======================================================= +*/ + +/* +** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and +** initial structure 'luaL_Stream' (it may contain other fields +** after that initial structure). +*/ + +#define LUA_FILEHANDLE "FILE*" + + +typedef struct luaL_Stream { + FILE *f; /* stream (NULL for incompletely created streams) */ + lua_CFunction closef; /* to close stream (NULL for closed streams) */ +} luaL_Stream; + +/* }====================================================== */ + + + +/* compatibility with old module system */ +#if defined(LUA_COMPAT_MODULE) + +LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, + int sizehint); +LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); + +#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) + +#endif + + +/* +** {================================================================== +** "Abstraction Layer" for basic report of messages and errors +** =================================================================== +*/ + +/* print a string */ +#if !defined(lua_writestring) +#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) +#endif + +/* print a newline and flush the output */ +#if !defined(lua_writeline) +#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout)) +#endif + +/* print an error message */ +#if !defined(lua_writestringerror) +#define lua_writestringerror(s,p) \ + (fprintf(stderr, (s), (p)), fflush(stderr)) +#endif + +/* }================================================================== */ + + +/* +** {============================================================ +** Compatibility with deprecated conversions +** ============================================================= +*/ +#if defined(LUA_COMPAT_APIINTCASTS) + +#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a)) +#define luaL_optunsigned(L,a,d) \ + ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d))) + +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) + +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#endif +/* }============================================================ */ + + + +#endif + + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lbaselib.c b/dep/scintilla/scintilla-3.10.6/lua/src/lbaselib.c new file mode 100644 index 00000000..08523e6e --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lbaselib.c @@ -0,0 +1,498 @@ +/* +** $Id: lbaselib.c,v 1.314 2016/09/05 19:06:34 roberto Exp $ +** Basic library +** See Copyright Notice in lua.h +*/ + +#define lbaselib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include +#include +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + size_t l; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tolstring(L, -1, &l); /* get result */ + if (s == NULL) + return luaL_error(L, "'tostring' must return a string to 'print'"); + if (i>1) lua_writestring("\t", 1); + lua_writestring(s, l); + lua_pop(L, 1); /* pop result */ + } + lua_writeline(); + return 0; +} + + +#define SPACECHARS " \f\n\r\t\v" + +static const char *b_str2int (const char *s, int base, lua_Integer *pn) { + lua_Unsigned n = 0; + int neg = 0; + s += strspn(s, SPACECHARS); /* skip initial spaces */ + if (*s == '-') { s++; neg = 1; } /* handle signal */ + else if (*s == '+') s++; + if (!isalnum((unsigned char)*s)) /* no digit? */ + return NULL; + do { + int digit = (isdigit((unsigned char)*s)) ? *s - '0' + : (toupper((unsigned char)*s) - 'A') + 10; + if (digit >= base) return NULL; /* invalid numeral */ + n = n * base + digit; + s++; + } while (isalnum((unsigned char)*s)); + s += strspn(s, SPACECHARS); /* skip trailing spaces */ + *pn = (lua_Integer)((neg) ? (0u - n) : n); + return s; +} + + +static int luaB_tonumber (lua_State *L) { + if (lua_isnoneornil(L, 2)) { /* standard conversion? */ + luaL_checkany(L, 1); + if (lua_type(L, 1) == LUA_TNUMBER) { /* already a number? */ + lua_settop(L, 1); /* yes; return it */ + return 1; + } + else { + size_t l; + const char *s = lua_tolstring(L, 1, &l); + if (s != NULL && lua_stringtonumber(L, s) == l + 1) + return 1; /* successful conversion to number */ + /* else not a number */ + } + } + else { + size_t l; + const char *s; + lua_Integer n = 0; /* to avoid warnings */ + lua_Integer base = luaL_checkinteger(L, 2); + luaL_checktype(L, 1, LUA_TSTRING); /* no numbers as strings */ + s = lua_tolstring(L, 1, &l); + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + if (b_str2int(s, (int)base, &n) == s + l) { + lua_pushinteger(L, n); + return 1; + } /* else not a number */ + } /* else not a number */ + lua_pushnil(L); /* not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = (int)luaL_optinteger(L, 2, 1); + lua_settop(L, 1); + if (lua_type(L, 1) == LUA_TSTRING && level > 0) { + luaL_where(L, level); /* add extra information */ + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable") != LUA_TNIL) + return luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawlen (lua_State *L) { + int t = lua_type(L, 1); + luaL_argcheck(L, t == LUA_TTABLE || t == LUA_TSTRING, 1, + "table or string expected"); + lua_pushinteger(L, lua_rawlen(L, 1)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_settop(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_collectgarbage (lua_State *L) { + static const char *const opts[] = {"stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", + "isrunning", NULL}; + static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, + LUA_GCISRUNNING}; + int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; + int ex = (int)luaL_optinteger(L, 2, 0); + int res = lua_gc(L, o, ex); + switch (o) { + case LUA_GCCOUNT: { + int b = lua_gc(L, LUA_GCCOUNTB, 0); + lua_pushnumber(L, (lua_Number)res + ((lua_Number)b/1024)); + return 1; + } + case LUA_GCSTEP: case LUA_GCISRUNNING: { + lua_pushboolean(L, res); + return 1; + } + default: { + lua_pushinteger(L, res); + return 1; + } + } +} + + +static int luaB_type (lua_State *L) { + int t = lua_type(L, 1); + luaL_argcheck(L, t != LUA_TNONE, 1, "value expected"); + lua_pushstring(L, lua_typename(L, t)); + return 1; +} + + +static int pairsmeta (lua_State *L, const char *method, int iszero, + lua_CFunction iter) { + luaL_checkany(L, 1); + if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */ + lua_pushcfunction(L, iter); /* will return generator, */ + lua_pushvalue(L, 1); /* state, */ + if (iszero) lua_pushinteger(L, 0); /* and initial value */ + else lua_pushnil(L); + } + else { + lua_pushvalue(L, 1); /* argument 'self' to metamethod */ + lua_call(L, 1, 3); /* get 3 values from metamethod */ + } + return 3; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + return pairsmeta(L, "__pairs", 0, luaB_next); +} + + +/* +** Traversal function for 'ipairs' +*/ +static int ipairsaux (lua_State *L) { + lua_Integer i = luaL_checkinteger(L, 2) + 1; + lua_pushinteger(L, i); + return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2; +} + + +/* +** 'ipairs' function. Returns 'ipairsaux', given "table", 0. +** (The given "table" may not be a table.) +*/ +static int luaB_ipairs (lua_State *L) { +#if defined(LUA_COMPAT_IPAIRS) + return pairsmeta(L, "__ipairs", 1, ipairsaux); +#else + luaL_checkany(L, 1); + lua_pushcfunction(L, ipairsaux); /* iteration function */ + lua_pushvalue(L, 1); /* state */ + lua_pushinteger(L, 0); /* initial value */ + return 3; +#endif +} + + +static int load_aux (lua_State *L, int status, int envidx) { + if (status == LUA_OK) { + if (envidx != 0) { /* 'env' parameter? */ + lua_pushvalue(L, envidx); /* environment for loaded function */ + if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */ + lua_pop(L, 1); /* remove 'env' if not used by previous call */ + } + return 1; + } + else { /* error (message is on top of the stack) */ + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + const char *mode = luaL_optstring(L, 2, NULL); + int env = (!lua_isnone(L, 3) ? 3 : 0); /* 'env' index or 0 if no 'env' */ + int status = luaL_loadfilex(L, fname, mode); + return load_aux(L, status, env); +} + + +/* +** {====================================================== +** Generic Read function +** ======================================================= +*/ + + +/* +** reserved slot, above all arguments, to hold a copy of the returned +** string to avoid it being collected while parsed. 'load' has four +** optional arguments (chunk, source name, mode, and environment). +*/ +#define RESERVEDSLOT 5 + + +/* +** Reader for generic 'load' function: 'lua_load' uses the +** stack for internal stuff, so the reader cannot change the +** stack top. Instead, it keeps its resulting string in a +** reserved slot inside the stack. +*/ +static const char *generic_reader (lua_State *L, void *ud, size_t *size) { + (void)(ud); /* not used */ + luaL_checkstack(L, 2, "too many nested functions"); + lua_pushvalue(L, 1); /* get function */ + lua_call(L, 0, 1); /* call it */ + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* pop result */ + *size = 0; + return NULL; + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "reader function must return a string"); + lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ + return lua_tolstring(L, RESERVEDSLOT, size); +} + + +static int luaB_load (lua_State *L) { + int status; + size_t l; + const char *s = lua_tolstring(L, 1, &l); + const char *mode = luaL_optstring(L, 3, "bt"); + int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */ + if (s != NULL) { /* loading a string? */ + const char *chunkname = luaL_optstring(L, 2, s); + status = luaL_loadbufferx(L, s, l, chunkname, mode); + } + else { /* loading from a reader function */ + const char *chunkname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, RESERVEDSLOT); /* create reserved slot */ + status = lua_load(L, generic_reader, NULL, chunkname, mode); + } + return load_aux(L, status, env); +} + +/* }====================================================== */ + + +static int dofilecont (lua_State *L, int d1, lua_KContext d2) { + (void)d1; (void)d2; /* only to match 'lua_Kfunction' prototype */ + return lua_gettop(L) - 1; +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + lua_settop(L, 1); + if (luaL_loadfile(L, fname) != LUA_OK) + return lua_error(L); + lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); + return dofilecont(L, 0, 0); +} + + +static int luaB_assert (lua_State *L) { + if (lua_toboolean(L, 1)) /* condition is true? */ + return lua_gettop(L); /* return all arguments */ + else { /* error */ + luaL_checkany(L, 1); /* there must be a condition */ + lua_remove(L, 1); /* remove it */ + lua_pushliteral(L, "assertion failed!"); /* default message */ + lua_settop(L, 1); /* leave only message (default if no other one) */ + return luaB_error(L); /* call 'error' */ + } +} + + +static int luaB_select (lua_State *L) { + int n = lua_gettop(L); + if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { + lua_pushinteger(L, n-1); + return 1; + } + else { + lua_Integer i = luaL_checkinteger(L, 1); + if (i < 0) i = n + i; + else if (i > n) i = n; + luaL_argcheck(L, 1 <= i, 1, "index out of range"); + return n - (int)i; + } +} + + +/* +** Continuation function for 'pcall' and 'xpcall'. Both functions +** already pushed a 'true' before doing the call, so in case of success +** 'finishpcall' only has to return everything in the stack minus +** 'extra' values (where 'extra' is exactly the number of items to be +** ignored). +*/ +static int finishpcall (lua_State *L, int status, lua_KContext extra) { + if (status != LUA_OK && status != LUA_YIELD) { /* error? */ + lua_pushboolean(L, 0); /* first result (false) */ + lua_pushvalue(L, -2); /* error message */ + return 2; /* return false, msg */ + } + else + return lua_gettop(L) - (int)extra; /* return all results */ +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + lua_pushboolean(L, 1); /* first result if no errors */ + lua_insert(L, 1); /* put it in place */ + status = lua_pcallk(L, lua_gettop(L) - 2, LUA_MULTRET, 0, 0, finishpcall); + return finishpcall(L, status, 0); +} + + +/* +** Do a protected call with error handling. After 'lua_rotate', the +** stack will have ; so, the function passes +** 2 to 'finishpcall' to skip the 2 first values when returning results. +*/ +static int luaB_xpcall (lua_State *L) { + int status; + int n = lua_gettop(L); + luaL_checktype(L, 2, LUA_TFUNCTION); /* check error function */ + lua_pushboolean(L, 1); /* first result */ + lua_pushvalue(L, 1); /* function */ + lua_rotate(L, 3, 2); /* move them below function's arguments */ + status = lua_pcallk(L, n - 2, LUA_MULTRET, 2, 2, finishpcall); + return finishpcall(L, status, 2); +} + + +static int luaB_tostring (lua_State *L) { + luaL_checkany(L, 1); + luaL_tolstring(L, 1, NULL); + return 1; +} + + +static const luaL_Reg base_funcs[] = { + {"assert", luaB_assert}, + {"collectgarbage", luaB_collectgarbage}, + {"dofile", luaB_dofile}, + {"error", luaB_error}, + {"getmetatable", luaB_getmetatable}, + {"ipairs", luaB_ipairs}, + {"loadfile", luaB_loadfile}, + {"load", luaB_load}, +#if defined(LUA_COMPAT_LOADSTRING) + {"loadstring", luaB_load}, +#endif + {"next", luaB_next}, + {"pairs", luaB_pairs}, + {"pcall", luaB_pcall}, + {"print", luaB_print}, + {"rawequal", luaB_rawequal}, + {"rawlen", luaB_rawlen}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"select", luaB_select}, + {"setmetatable", luaB_setmetatable}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"xpcall", luaB_xpcall}, + /* placeholders */ + {"_G", NULL}, + {"_VERSION", NULL}, + {NULL, NULL} +}; + + +LUAMOD_API int luaopen_base (lua_State *L) { + /* open lib into global table */ + lua_pushglobaltable(L); + luaL_setfuncs(L, base_funcs, 0); + /* set global _G */ + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_G"); + /* set global _VERSION */ + lua_pushliteral(L, LUA_VERSION); + lua_setfield(L, -2, "_VERSION"); + return 1; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lbitlib.c b/dep/scintilla/scintilla-3.10.6/lua/src/lbitlib.c new file mode 100644 index 00000000..1cb1d5b9 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lbitlib.c @@ -0,0 +1,233 @@ +/* +** $Id: lbitlib.c,v 1.30 2015/11/11 19:08:09 roberto Exp $ +** Standard library for bitwise operations +** See Copyright Notice in lua.h +*/ + +#define lbitlib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#if defined(LUA_COMPAT_BITLIB) /* { */ + + +#define pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) +#define checkunsigned(L,i) ((lua_Unsigned)luaL_checkinteger(L,i)) + + +/* number of bits to consider in a number */ +#if !defined(LUA_NBITS) +#define LUA_NBITS 32 +#endif + + +/* +** a lua_Unsigned with its first LUA_NBITS bits equal to 1. (Shift must +** be made in two parts to avoid problems when LUA_NBITS is equal to the +** number of bits in a lua_Unsigned.) +*/ +#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1)) + + +/* macro to trim extra bits */ +#define trim(x) ((x) & ALLONES) + + +/* builds a number with 'n' ones (1 <= n <= LUA_NBITS) */ +#define mask(n) (~((ALLONES << 1) << ((n) - 1))) + + + +static lua_Unsigned andaux (lua_State *L) { + int i, n = lua_gettop(L); + lua_Unsigned r = ~(lua_Unsigned)0; + for (i = 1; i <= n; i++) + r &= checkunsigned(L, i); + return trim(r); +} + + +static int b_and (lua_State *L) { + lua_Unsigned r = andaux(L); + pushunsigned(L, r); + return 1; +} + + +static int b_test (lua_State *L) { + lua_Unsigned r = andaux(L); + lua_pushboolean(L, r != 0); + return 1; +} + + +static int b_or (lua_State *L) { + int i, n = lua_gettop(L); + lua_Unsigned r = 0; + for (i = 1; i <= n; i++) + r |= checkunsigned(L, i); + pushunsigned(L, trim(r)); + return 1; +} + + +static int b_xor (lua_State *L) { + int i, n = lua_gettop(L); + lua_Unsigned r = 0; + for (i = 1; i <= n; i++) + r ^= checkunsigned(L, i); + pushunsigned(L, trim(r)); + return 1; +} + + +static int b_not (lua_State *L) { + lua_Unsigned r = ~checkunsigned(L, 1); + pushunsigned(L, trim(r)); + return 1; +} + + +static int b_shift (lua_State *L, lua_Unsigned r, lua_Integer i) { + if (i < 0) { /* shift right? */ + i = -i; + r = trim(r); + if (i >= LUA_NBITS) r = 0; + else r >>= i; + } + else { /* shift left */ + if (i >= LUA_NBITS) r = 0; + else r <<= i; + r = trim(r); + } + pushunsigned(L, r); + return 1; +} + + +static int b_lshift (lua_State *L) { + return b_shift(L, checkunsigned(L, 1), luaL_checkinteger(L, 2)); +} + + +static int b_rshift (lua_State *L) { + return b_shift(L, checkunsigned(L, 1), -luaL_checkinteger(L, 2)); +} + + +static int b_arshift (lua_State *L) { + lua_Unsigned r = checkunsigned(L, 1); + lua_Integer i = luaL_checkinteger(L, 2); + if (i < 0 || !(r & ((lua_Unsigned)1 << (LUA_NBITS - 1)))) + return b_shift(L, r, -i); + else { /* arithmetic shift for 'negative' number */ + if (i >= LUA_NBITS) r = ALLONES; + else + r = trim((r >> i) | ~(trim(~(lua_Unsigned)0) >> i)); /* add signal bit */ + pushunsigned(L, r); + return 1; + } +} + + +static int b_rot (lua_State *L, lua_Integer d) { + lua_Unsigned r = checkunsigned(L, 1); + int i = d & (LUA_NBITS - 1); /* i = d % NBITS */ + r = trim(r); + if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */ + r = (r << i) | (r >> (LUA_NBITS - i)); + pushunsigned(L, trim(r)); + return 1; +} + + +static int b_lrot (lua_State *L) { + return b_rot(L, luaL_checkinteger(L, 2)); +} + + +static int b_rrot (lua_State *L) { + return b_rot(L, -luaL_checkinteger(L, 2)); +} + + +/* +** get field and width arguments for field-manipulation functions, +** checking whether they are valid. +** ('luaL_error' called without 'return' to avoid later warnings about +** 'width' being used uninitialized.) +*/ +static int fieldargs (lua_State *L, int farg, int *width) { + lua_Integer f = luaL_checkinteger(L, farg); + lua_Integer w = luaL_optinteger(L, farg + 1, 1); + luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); + luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); + if (f + w > LUA_NBITS) + luaL_error(L, "trying to access non-existent bits"); + *width = (int)w; + return (int)f; +} + + +static int b_extract (lua_State *L) { + int w; + lua_Unsigned r = trim(checkunsigned(L, 1)); + int f = fieldargs(L, 2, &w); + r = (r >> f) & mask(w); + pushunsigned(L, r); + return 1; +} + + +static int b_replace (lua_State *L) { + int w; + lua_Unsigned r = trim(checkunsigned(L, 1)); + lua_Unsigned v = trim(checkunsigned(L, 2)); + int f = fieldargs(L, 3, &w); + lua_Unsigned m = mask(w); + r = (r & ~(m << f)) | ((v & m) << f); + pushunsigned(L, r); + return 1; +} + + +static const luaL_Reg bitlib[] = { + {"arshift", b_arshift}, + {"band", b_and}, + {"bnot", b_not}, + {"bor", b_or}, + {"bxor", b_xor}, + {"btest", b_test}, + {"extract", b_extract}, + {"lrotate", b_lrot}, + {"lshift", b_lshift}, + {"replace", b_replace}, + {"rrotate", b_rrot}, + {"rshift", b_rshift}, + {NULL, NULL} +}; + + + +LUAMOD_API int luaopen_bit32 (lua_State *L) { + luaL_newlib(L, bitlib); + return 1; +} + + +#else /* }{ */ + + +LUAMOD_API int luaopen_bit32 (lua_State *L) { + return luaL_error(L, "library 'bit32' has been deprecated"); +} + +#endif /* } */ diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lcode.c b/dep/scintilla/scintilla-3.10.6/lua/src/lcode.c new file mode 100644 index 00000000..0bb41426 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lcode.c @@ -0,0 +1,1203 @@ +/* +** $Id: lcode.c,v 2.112 2016/12/22 13:08:50 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#define lcode_c +#define LUA_CORE + +#include "lprefix.h" + + +#include +#include + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstring.h" +#include "ltable.h" +#include "lvm.h" + + +/* Maximum number of registers in a Lua function (must fit in 8 bits) */ +#define MAXREGS 255 + + +#define hasjumps(e) ((e)->t != (e)->f) + + +/* +** If expression is a numeric constant, fills 'v' with its value +** and returns 1. Otherwise, returns 0. +*/ +static int tonumeral(const expdesc *e, TValue *v) { + if (hasjumps(e)) + return 0; /* not a numeral */ + switch (e->k) { + case VKINT: + if (v) setivalue(v, e->u.ival); + return 1; + case VKFLT: + if (v) setfltvalue(v, e->u.nval); + return 1; + default: return 0; + } +} + + +/* +** Create a OP_LOADNIL instruction, but try to optimize: if the previous +** instruction is also OP_LOADNIL and ranges are compatible, adjust +** range of previous instruction instead of emitting a new one. (For +** instance, 'local a; local b' will generate a single opcode.) +*/ +void luaK_nil (FuncState *fs, int from, int n) { + Instruction *previous; + int l = from + n - 1; /* last register to set nil */ + if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { /* previous is LOADNIL? */ + int pfrom = GETARG_A(*previous); /* get previous range */ + int pl = pfrom + GETARG_B(*previous); + if ((pfrom <= from && from <= pl + 1) || + (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ + if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ + if (pl > l) l = pl; /* l = max(l, pl) */ + SETARG_A(*previous, from); + SETARG_B(*previous, l - from); + return; + } + } /* else go through */ + } + luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */ +} + + +/* +** Gets the destination address of a jump instruction. Used to traverse +** a list of jumps. +*/ +static int getjump (FuncState *fs, int pc) { + int offset = GETARG_sBx(fs->f->code[pc]); + if (offset == NO_JUMP) /* point to itself represents end of list */ + return NO_JUMP; /* end of list */ + else + return (pc+1)+offset; /* turn offset into absolute position */ +} + + +/* +** Fix jump instruction at position 'pc' to jump to 'dest'. +** (Jump addresses are relative in Lua) +*/ +static void fixjump (FuncState *fs, int pc, int dest) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest - (pc + 1); + lua_assert(dest != NO_JUMP); + if (abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_sBx(*jmp, offset); +} + + +/* +** Concatenate jump-list 'l2' into jump-list 'l1' +*/ +void luaK_concat (FuncState *fs, int *l1, int l2) { + if (l2 == NO_JUMP) return; /* nothing to concatenate? */ + else if (*l1 == NO_JUMP) /* no original list? */ + *l1 = l2; /* 'l1' points to 'l2' */ + else { + int list = *l1; + int next; + while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ + list = next; + fixjump(fs, list, l2); /* last element links to 'l2' */ + } +} + + +/* +** Create a jump instruction and return its position, so its destination +** can be fixed later (with 'fixjump'). If there are jumps to +** this position (kept in 'jpc'), link them all together so that +** 'patchlistaux' will fix all them directly to the final destination. +*/ +int luaK_jump (FuncState *fs) { + int jpc = fs->jpc; /* save list of jumps to here */ + int j; + fs->jpc = NO_JUMP; /* no more jumps to here */ + j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); + luaK_concat(fs, &j, jpc); /* keep them on hold */ + return j; +} + + +/* +** Code a 'return' instruction +*/ +void luaK_ret (FuncState *fs, int first, int nret) { + luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); +} + + +/* +** Code a "conditional jump", that is, a test or comparison opcode +** followed by a jump. Return jump position. +*/ +static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { + luaK_codeABC(fs, op, A, B, C); + return luaK_jump(fs); +} + + +/* +** returns current 'pc' and marks it as a jump target (to avoid wrong +** optimizations with consecutive instructions not in the same basic block). +*/ +int luaK_getlabel (FuncState *fs) { + fs->lasttarget = fs->pc; + return fs->pc; +} + + +/* +** Returns the position of the instruction "controlling" a given +** jump (that is, its condition), or the jump itself if it is +** unconditional. +*/ +static Instruction *getjumpcontrol (FuncState *fs, int pc) { + Instruction *pi = &fs->f->code[pc]; + if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) + return pi-1; + else + return pi; +} + + +/* +** Patch destination register for a TESTSET instruction. +** If instruction in position 'node' is not a TESTSET, return 0 ("fails"). +** Otherwise, if 'reg' is not 'NO_REG', set it as the destination +** register. Otherwise, change instruction to a simple 'TEST' (produces +** no register value) +*/ +static int patchtestreg (FuncState *fs, int node, int reg) { + Instruction *i = getjumpcontrol(fs, node); + if (GET_OPCODE(*i) != OP_TESTSET) + return 0; /* cannot patch other instructions */ + if (reg != NO_REG && reg != GETARG_B(*i)) + SETARG_A(*i, reg); + else { + /* no register to put value or register already has the value; + change instruction to simple test */ + *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + } + return 1; +} + + +/* +** Traverse a list of tests ensuring no one produces a value +*/ +static void removevalues (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) + patchtestreg(fs, list, NO_REG); +} + + +/* +** Traverse a list of tests, patching their destination address and +** registers: tests producing values jump to 'vtarget' (and put their +** values in 'reg'), other tests jump to 'dtarget'. +*/ +static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, + int dtarget) { + while (list != NO_JUMP) { + int next = getjump(fs, list); + if (patchtestreg(fs, list, reg)) + fixjump(fs, list, vtarget); + else + fixjump(fs, list, dtarget); /* jump to default target */ + list = next; + } +} + + +/* +** Ensure all pending jumps to current position are fixed (jumping +** to current position with no values) and reset list of pending +** jumps +*/ +static void dischargejpc (FuncState *fs) { + patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); + fs->jpc = NO_JUMP; +} + + +/* +** Add elements in 'list' to list of pending jumps to "here" +** (current position) +*/ +void luaK_patchtohere (FuncState *fs, int list) { + luaK_getlabel(fs); /* mark "here" as a jump target */ + luaK_concat(fs, &fs->jpc, list); +} + + +/* +** Path all jumps in 'list' to jump to 'target'. +** (The assert means that we cannot fix a jump to a forward address +** because we only know addresses once code is generated.) +*/ +void luaK_patchlist (FuncState *fs, int list, int target) { + if (target == fs->pc) /* 'target' is current position? */ + luaK_patchtohere(fs, list); /* add list to pending jumps */ + else { + lua_assert(target < fs->pc); + patchlistaux(fs, list, target, NO_REG, target); + } +} + + +/* +** Path all jumps in 'list' to close upvalues up to given 'level' +** (The assertion checks that jumps either were closing nothing +** or were closing higher levels, from inner blocks.) +*/ +void luaK_patchclose (FuncState *fs, int list, int level) { + level++; /* argument is +1 to reserve 0 as non-op */ + for (; list != NO_JUMP; list = getjump(fs, list)) { + lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP && + (GETARG_A(fs->f->code[list]) == 0 || + GETARG_A(fs->f->code[list]) >= level)); + SETARG_A(fs->f->code[list], level); + } +} + + +/* +** Emit instruction 'i', checking for array sizes and saving also its +** line information. Return 'i' position. +*/ +static int luaK_code (FuncState *fs, Instruction i) { + Proto *f = fs->f; + dischargejpc(fs); /* 'pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->ls->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "opcodes"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->ls->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "opcodes"); + f->lineinfo[fs->pc] = fs->ls->lastline; + return fs->pc++; +} + + +/* +** Format and emit an 'iABC' instruction. (Assertions check consistency +** of parameters versus opcode.) +*/ +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); + return luaK_code(fs, CREATE_ABC(o, a, b, c)); +} + + +/* +** Format and emit an 'iABx' instruction. +*/ +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); + return luaK_code(fs, CREATE_ABx(o, a, bc)); +} + + +/* +** Emit an "extra argument" instruction (format 'iAx') +*/ +static int codeextraarg (FuncState *fs, int a) { + lua_assert(a <= MAXARG_Ax); + return luaK_code(fs, CREATE_Ax(OP_EXTRAARG, a)); +} + + +/* +** Emit a "load constant" instruction, using either 'OP_LOADK' +** (if constant index 'k' fits in 18 bits) or an 'OP_LOADKX' +** instruction with "extra argument". +*/ +int luaK_codek (FuncState *fs, int reg, int k) { + if (k <= MAXARG_Bx) + return luaK_codeABx(fs, OP_LOADK, reg, k); + else { + int p = luaK_codeABx(fs, OP_LOADKX, reg, 0); + codeextraarg(fs, k); + return p; + } +} + + +/* +** Check register-stack level, keeping track of its maximum size +** in field 'maxstacksize' +*/ +void luaK_checkstack (FuncState *fs, int n) { + int newstack = fs->freereg + n; + if (newstack > fs->f->maxstacksize) { + if (newstack >= MAXREGS) + luaX_syntaxerror(fs->ls, + "function or expression needs too many registers"); + fs->f->maxstacksize = cast_byte(newstack); + } +} + + +/* +** Reserve 'n' registers in register stack +*/ +void luaK_reserveregs (FuncState *fs, int n) { + luaK_checkstack(fs, n); + fs->freereg += n; +} + + +/* +** Free register 'reg', if it is neither a constant index nor +** a local variable. +) +*/ +static void freereg (FuncState *fs, int reg) { + if (!ISK(reg) && reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + + +/* +** Free register used by expression 'e' (if any) +*/ +static void freeexp (FuncState *fs, expdesc *e) { + if (e->k == VNONRELOC) + freereg(fs, e->u.info); +} + + +/* +** Free registers used by expressions 'e1' and 'e2' (if any) in proper +** order. +*/ +static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) { + int r1 = (e1->k == VNONRELOC) ? e1->u.info : -1; + int r2 = (e2->k == VNONRELOC) ? e2->u.info : -1; + if (r1 > r2) { + freereg(fs, r1); + freereg(fs, r2); + } + else { + freereg(fs, r2); + freereg(fs, r1); + } +} + + +/* +** Add constant 'v' to prototype's list of constants (field 'k'). +** Use scanner's table to cache position of constants in constant list +** and try to reuse constants. Because some values should not be used +** as keys (nil cannot be a key, integer keys can collapse with float +** keys), the caller must provide a useful 'key' for indexing the cache. +*/ +static int addk (FuncState *fs, TValue *key, TValue *v) { + lua_State *L = fs->ls->L; + Proto *f = fs->f; + TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */ + int k, oldsize; + if (ttisinteger(idx)) { /* is there an index there? */ + k = cast_int(ivalue(idx)); + /* correct value? (warning: must distinguish floats from integers!) */ + if (k < fs->nk && ttype(&f->k[k]) == ttype(v) && + luaV_rawequalobj(&f->k[k], v)) + return k; /* reuse index */ + } + /* constant not found; create a new entry */ + oldsize = f->sizek; + k = fs->nk; + /* numerical value does not need GC barrier; + table has no metatable, so it does not need to invalidate cache */ + setivalue(idx, k); + luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[k], v); + fs->nk++; + luaC_barrier(L, f, v); + return k; +} + + +/* +** Add a string to list of constants and return its index. +*/ +int luaK_stringK (FuncState *fs, TString *s) { + TValue o; + setsvalue(fs->ls->L, &o, s); + return addk(fs, &o, &o); /* use string itself as key */ +} + + +/* +** Add an integer to list of constants and return its index. +** Integers use userdata as keys to avoid collision with floats with +** same value; conversion to 'void*' is used only for hashing, so there +** are no "precision" problems. +*/ +int luaK_intK (FuncState *fs, lua_Integer n) { + TValue k, o; + setpvalue(&k, cast(void*, cast(size_t, n))); + setivalue(&o, n); + return addk(fs, &k, &o); +} + +/* +** Add a float to list of constants and return its index. +*/ +static int luaK_numberK (FuncState *fs, lua_Number r) { + TValue o; + setfltvalue(&o, r); + return addk(fs, &o, &o); /* use number itself as key */ +} + + +/* +** Add a boolean to list of constants and return its index. +*/ +static int boolK (FuncState *fs, int b) { + TValue o; + setbvalue(&o, b); + return addk(fs, &o, &o); /* use boolean itself as key */ +} + + +/* +** Add nil to list of constants and return its index. +*/ +static int nilK (FuncState *fs) { + TValue k, v; + setnilvalue(&v); + /* cannot use nil as key; instead use table itself to represent nil */ + sethvalue(fs->ls->L, &k, fs->ls->h); + return addk(fs, &k, &v); +} + + +/* +** Fix an expression to return the number of results 'nresults'. +** Either 'e' is a multi-ret expression (function call or vararg) +** or 'nresults' is LUA_MULTRET (as any expression can satisfy that). +*/ +void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { + if (e->k == VCALL) { /* expression is an open function call? */ + SETARG_C(getinstruction(fs, e), nresults + 1); + } + else if (e->k == VVARARG) { + Instruction *pc = &getinstruction(fs, e); + SETARG_B(*pc, nresults + 1); + SETARG_A(*pc, fs->freereg); + luaK_reserveregs(fs, 1); + } + else lua_assert(nresults == LUA_MULTRET); +} + + +/* +** Fix an expression to return one result. +** If expression is not a multi-ret expression (function call or +** vararg), it already returns one result, so nothing needs to be done. +** Function calls become VNONRELOC expressions (as its result comes +** fixed in the base register of the call), while vararg expressions +** become VRELOCABLE (as OP_VARARG puts its results where it wants). +** (Calls are created returning one result, so that does not need +** to be fixed.) +*/ +void luaK_setoneret (FuncState *fs, expdesc *e) { + if (e->k == VCALL) { /* expression is an open function call? */ + /* already returns 1 value */ + lua_assert(GETARG_C(getinstruction(fs, e)) == 2); + e->k = VNONRELOC; /* result has fixed position */ + e->u.info = GETARG_A(getinstruction(fs, e)); + } + else if (e->k == VVARARG) { + SETARG_B(getinstruction(fs, e), 2); + e->k = VRELOCABLE; /* can relocate its simple result */ + } +} + + +/* +** Ensure that expression 'e' is not a variable. +*/ +void luaK_dischargevars (FuncState *fs, expdesc *e) { + switch (e->k) { + case VLOCAL: { /* already in a register */ + e->k = VNONRELOC; /* becomes a non-relocatable value */ + break; + } + case VUPVAL: { /* move value to some (pending) register */ + e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); + e->k = VRELOCABLE; + break; + } + case VINDEXED: { + OpCode op; + freereg(fs, e->u.ind.idx); + if (e->u.ind.vt == VLOCAL) { /* is 't' in a register? */ + freereg(fs, e->u.ind.t); + op = OP_GETTABLE; + } + else { + lua_assert(e->u.ind.vt == VUPVAL); + op = OP_GETTABUP; /* 't' is in an upvalue */ + } + e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx); + e->k = VRELOCABLE; + break; + } + case VVARARG: case VCALL: { + luaK_setoneret(fs, e); + break; + } + default: break; /* there is one value available (somewhere) */ + } +} + + +/* +** Ensures expression value is in register 'reg' (and therefore +** 'e' will become a non-relocatable expression). +*/ +static void discharge2reg (FuncState *fs, expdesc *e, int reg) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: { + luaK_nil(fs, reg, 1); + break; + } + case VFALSE: case VTRUE: { + luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + break; + } + case VK: { + luaK_codek(fs, reg, e->u.info); + break; + } + case VKFLT: { + luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval)); + break; + } + case VKINT: { + luaK_codek(fs, reg, luaK_intK(fs, e->u.ival)); + break; + } + case VRELOCABLE: { + Instruction *pc = &getinstruction(fs, e); + SETARG_A(*pc, reg); /* instruction will put result in 'reg' */ + break; + } + case VNONRELOC: { + if (reg != e->u.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); + break; + } + default: { + lua_assert(e->k == VJMP); + return; /* nothing to do... */ + } + } + e->u.info = reg; + e->k = VNONRELOC; +} + + +/* +** Ensures expression value is in any register. +*/ +static void discharge2anyreg (FuncState *fs, expdesc *e) { + if (e->k != VNONRELOC) { /* no fixed register yet? */ + luaK_reserveregs(fs, 1); /* get a register */ + discharge2reg(fs, e, fs->freereg-1); /* put value there */ + } +} + + +static int code_loadbool (FuncState *fs, int A, int b, int jump) { + luaK_getlabel(fs); /* those instructions may be jump targets */ + return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); +} + + +/* +** check whether list has any jump that do not produce a value +** or produce an inverted value +*/ +static int need_value (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) { + Instruction i = *getjumpcontrol(fs, list); + if (GET_OPCODE(i) != OP_TESTSET) return 1; + } + return 0; /* not found */ +} + + +/* +** Ensures final expression result (including results from its jump +** lists) is in register 'reg'. +** If expression has jumps, need to patch these jumps either to +** its final position or to "load" instructions (for those tests +** that do not produce values). +*/ +static void exp2reg (FuncState *fs, expdesc *e, int reg) { + discharge2reg(fs, e, reg); + if (e->k == VJMP) /* expression itself is a test? */ + luaK_concat(fs, &e->t, e->u.info); /* put this jump in 't' list */ + if (hasjumps(e)) { + int final; /* position after whole expression */ + int p_f = NO_JUMP; /* position of an eventual LOAD false */ + int p_t = NO_JUMP; /* position of an eventual LOAD true */ + if (need_value(fs, e->t) || need_value(fs, e->f)) { + int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); + p_f = code_loadbool(fs, reg, 0, 1); + p_t = code_loadbool(fs, reg, 1, 0); + luaK_patchtohere(fs, fj); + } + final = luaK_getlabel(fs); + patchlistaux(fs, e->f, final, reg, p_f); + patchlistaux(fs, e->t, final, reg, p_t); + } + e->f = e->t = NO_JUMP; + e->u.info = reg; + e->k = VNONRELOC; +} + + +/* +** Ensures final expression result (including results from its jump +** lists) is in next available register. +*/ +void luaK_exp2nextreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + freeexp(fs, e); + luaK_reserveregs(fs, 1); + exp2reg(fs, e, fs->freereg - 1); +} + + +/* +** Ensures final expression result (including results from its jump +** lists) is in some (any) register and return that register. +*/ +int luaK_exp2anyreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + if (e->k == VNONRELOC) { /* expression already has a register? */ + if (!hasjumps(e)) /* no jumps? */ + return e->u.info; /* result is already in a register */ + if (e->u.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.info); /* put final result in it */ + return e->u.info; + } + } + luaK_exp2nextreg(fs, e); /* otherwise, use next available register */ + return e->u.info; +} + + +/* +** Ensures final expression result is either in a register or in an +** upvalue. +*/ +void luaK_exp2anyregup (FuncState *fs, expdesc *e) { + if (e->k != VUPVAL || hasjumps(e)) + luaK_exp2anyreg(fs, e); +} + + +/* +** Ensures final expression result is either in a register or it is +** a constant. +*/ +void luaK_exp2val (FuncState *fs, expdesc *e) { + if (hasjumps(e)) + luaK_exp2anyreg(fs, e); + else + luaK_dischargevars(fs, e); +} + + +/* +** Ensures final expression result is in a valid R/K index +** (that is, it is either in a register or in 'k' with an index +** in the range of R/K indices). +** Returns R/K index. +*/ +int luaK_exp2RK (FuncState *fs, expdesc *e) { + luaK_exp2val(fs, e); + switch (e->k) { /* move constants to 'k' */ + case VTRUE: e->u.info = boolK(fs, 1); goto vk; + case VFALSE: e->u.info = boolK(fs, 0); goto vk; + case VNIL: e->u.info = nilK(fs); goto vk; + case VKINT: e->u.info = luaK_intK(fs, e->u.ival); goto vk; + case VKFLT: e->u.info = luaK_numberK(fs, e->u.nval); goto vk; + case VK: + vk: + e->k = VK; + if (e->u.info <= MAXINDEXRK) /* constant fits in 'argC'? */ + return RKASK(e->u.info); + else break; + default: break; + } + /* not a constant in the right range: put it in a register */ + return luaK_exp2anyreg(fs, e); +} + + +/* +** Generate code to store result of expression 'ex' into variable 'var'. +*/ +void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { + switch (var->k) { + case VLOCAL: { + freeexp(fs, ex); + exp2reg(fs, ex, var->u.info); /* compute 'ex' into proper place */ + return; + } + case VUPVAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); + break; + } + case VINDEXED: { + OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP; + int e = luaK_exp2RK(fs, ex); + luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e); + break; + } + default: lua_assert(0); /* invalid var kind to store */ + } + freeexp(fs, ex); +} + + +/* +** Emit SELF instruction (convert expression 'e' into 'e:key(e,'). +*/ +void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { + int ereg; + luaK_exp2anyreg(fs, e); + ereg = e->u.info; /* register where 'e' was placed */ + freeexp(fs, e); + e->u.info = fs->freereg; /* base register for op_self */ + e->k = VNONRELOC; /* self expression has a fixed register */ + luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ + luaK_codeABC(fs, OP_SELF, e->u.info, ereg, luaK_exp2RK(fs, key)); + freeexp(fs, key); +} + + +/* +** Negate condition 'e' (where 'e' is a comparison). +*/ +static void negatecondition (FuncState *fs, expdesc *e) { + Instruction *pc = getjumpcontrol(fs, e->u.info); + lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && + GET_OPCODE(*pc) != OP_TEST); + SETARG_A(*pc, !(GETARG_A(*pc))); +} + + +/* +** Emit instruction to jump if 'e' is 'cond' (that is, if 'cond' +** is true, code will jump if 'e' is true.) Return jump position. +** Optimize when 'e' is 'not' something, inverting the condition +** and removing the 'not'. +*/ +static int jumponcond (FuncState *fs, expdesc *e, int cond) { + if (e->k == VRELOCABLE) { + Instruction ie = getinstruction(fs, e); + if (GET_OPCODE(ie) == OP_NOT) { + fs->pc--; /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + } + /* else go through */ + } + discharge2anyreg(fs, e); + freeexp(fs, e); + return condjump(fs, OP_TESTSET, NO_REG, e->u.info, cond); +} + + +/* +** Emit code to go through if 'e' is true, jump otherwise. +*/ +void luaK_goiftrue (FuncState *fs, expdesc *e) { + int pc; /* pc of new jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VJMP: { /* condition? */ + negatecondition(fs, e); /* jump when it is false */ + pc = e->u.info; /* save jump position */ + break; + } + case VK: case VKFLT: case VKINT: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ + break; + } + default: { + pc = jumponcond(fs, e, 0); /* jump when false */ + break; + } + } + luaK_concat(fs, &e->f, pc); /* insert new jump in false list */ + luaK_patchtohere(fs, e->t); /* true list jumps to here (to go through) */ + e->t = NO_JUMP; +} + + +/* +** Emit code to go through if 'e' is false, jump otherwise. +*/ +void luaK_goiffalse (FuncState *fs, expdesc *e) { + int pc; /* pc of new jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VJMP: { + pc = e->u.info; /* already jump if true */ + break; + } + case VNIL: case VFALSE: { + pc = NO_JUMP; /* always false; do nothing */ + break; + } + default: { + pc = jumponcond(fs, e, 1); /* jump if true */ + break; + } + } + luaK_concat(fs, &e->t, pc); /* insert new jump in 't' list */ + luaK_patchtohere(fs, e->f); /* false list jumps to here (to go through) */ + e->f = NO_JUMP; +} + + +/* +** Code 'not e', doing constant folding. +*/ +static void codenot (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + e->k = VTRUE; /* true == not nil == not false */ + break; + } + case VK: case VKFLT: case VKINT: case VTRUE: { + e->k = VFALSE; /* false == not "x" == not 0.5 == not 1 == not true */ + break; + } + case VJMP: { + negatecondition(fs, e); + break; + } + case VRELOCABLE: + case VNONRELOC: { + discharge2anyreg(fs, e); + freeexp(fs, e); + e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); + e->k = VRELOCABLE; + break; + } + default: lua_assert(0); /* cannot happen */ + } + /* interchange true and false lists */ + { int temp = e->f; e->f = e->t; e->t = temp; } + removevalues(fs, e->f); /* values are useless when negated */ + removevalues(fs, e->t); +} + + +/* +** Create expression 't[k]'. 't' must have its final result already in a +** register or upvalue. +*/ +void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + lua_assert(!hasjumps(t) && (vkisinreg(t->k) || t->k == VUPVAL)); + t->u.ind.t = t->u.info; /* register or upvalue index */ + t->u.ind.idx = luaK_exp2RK(fs, k); /* R/K index for key */ + t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL : VLOCAL; + t->k = VINDEXED; +} + + +/* +** Return false if folding can raise an error. +** Bitwise operations need operands convertible to integers; division +** operations cannot have 0 as divisor. +*/ +static int validop (int op, TValue *v1, TValue *v2) { + switch (op) { + case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: + case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ + lua_Integer i; + return (tointeger(v1, &i) && tointeger(v2, &i)); + } + case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ + return (nvalue(v2) != 0); + default: return 1; /* everything else is valid */ + } +} + + +/* +** Try to "constant-fold" an operation; return 1 iff successful. +** (In this case, 'e1' has the final result.) +*/ +static int constfolding (FuncState *fs, int op, expdesc *e1, + const expdesc *e2) { + TValue v1, v2, res; + if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2)) + return 0; /* non-numeric operands or not safe to fold */ + luaO_arith(fs->ls->L, op, &v1, &v2, &res); /* does operation */ + if (ttisinteger(&res)) { + e1->k = VKINT; + e1->u.ival = ivalue(&res); + } + else { /* folds neither NaN nor 0.0 (to avoid problems with -0.0) */ + lua_Number n = fltvalue(&res); + if (luai_numisnan(n) || n == 0) + return 0; + e1->k = VKFLT; + e1->u.nval = n; + } + return 1; +} + + +/* +** Emit code for unary expressions that "produce values" +** (everything but 'not'). +** Expression to produce final result will be encoded in 'e'. +*/ +static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) { + int r = luaK_exp2anyreg(fs, e); /* opcodes operate only on registers */ + freeexp(fs, e); + e->u.info = luaK_codeABC(fs, op, 0, r, 0); /* generate opcode */ + e->k = VRELOCABLE; /* all those operations are relocatable */ + luaK_fixline(fs, line); +} + + +/* +** Emit code for binary expressions that "produce values" +** (everything but logical operators 'and'/'or' and comparison +** operators). +** Expression to produce final result will be encoded in 'e1'. +** Because 'luaK_exp2RK' can free registers, its calls must be +** in "stack order" (that is, first on 'e2', which may have more +** recent registers to be released). +*/ +static void codebinexpval (FuncState *fs, OpCode op, + expdesc *e1, expdesc *e2, int line) { + int rk2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */ + int rk1 = luaK_exp2RK(fs, e1); + freeexps(fs, e1, e2); + e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */ + e1->k = VRELOCABLE; /* all those operations are relocatable */ + luaK_fixline(fs, line); +} + + +/* +** Emit code for comparisons. +** 'e1' was already put in R/K form by 'luaK_infix'. +*/ +static void codecomp (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { + int rk1 = (e1->k == VK) ? RKASK(e1->u.info) + : check_exp(e1->k == VNONRELOC, e1->u.info); + int rk2 = luaK_exp2RK(fs, e2); + freeexps(fs, e1, e2); + switch (opr) { + case OPR_NE: { /* '(a ~= b)' ==> 'not (a == b)' */ + e1->u.info = condjump(fs, OP_EQ, 0, rk1, rk2); + break; + } + case OPR_GT: case OPR_GE: { + /* '(a > b)' ==> '(b < a)'; '(a >= b)' ==> '(b <= a)' */ + OpCode op = cast(OpCode, (opr - OPR_NE) + OP_EQ); + e1->u.info = condjump(fs, op, 1, rk2, rk1); /* invert operands */ + break; + } + default: { /* '==', '<', '<=' use their own opcodes */ + OpCode op = cast(OpCode, (opr - OPR_EQ) + OP_EQ); + e1->u.info = condjump(fs, op, 1, rk1, rk2); + break; + } + } + e1->k = VJMP; +} + + +/* +** Aplly prefix operation 'op' to expression 'e'. +*/ +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { + static const expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP}; + switch (op) { + case OPR_MINUS: case OPR_BNOT: /* use 'ef' as fake 2nd operand */ + if (constfolding(fs, op + LUA_OPUNM, e, &ef)) + break; + /* FALLTHROUGH */ + case OPR_LEN: + codeunexpval(fs, cast(OpCode, op + OP_UNM), e, line); + break; + case OPR_NOT: codenot(fs, e); break; + default: lua_assert(0); + } +} + + +/* +** Process 1st operand 'v' of binary operation 'op' before reading +** 2nd operand. +*/ +void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + switch (op) { + case OPR_AND: { + luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */ + break; + } + case OPR_OR: { + luaK_goiffalse(fs, v); /* go ahead only if 'v' is false */ + break; + } + case OPR_CONCAT: { + luaK_exp2nextreg(fs, v); /* operand must be on the 'stack' */ + break; + } + case OPR_ADD: case OPR_SUB: + case OPR_MUL: case OPR_DIV: case OPR_IDIV: + case OPR_MOD: case OPR_POW: + case OPR_BAND: case OPR_BOR: case OPR_BXOR: + case OPR_SHL: case OPR_SHR: { + if (!tonumeral(v, NULL)) + luaK_exp2RK(fs, v); + /* else keep numeral, which may be folded with 2nd operand */ + break; + } + default: { + luaK_exp2RK(fs, v); + break; + } + } +} + + +/* +** Finalize code for binary operation, after reading 2nd operand. +** For '(a .. b .. c)' (which is '(a .. (b .. c))', because +** concatenation is right associative), merge second CONCAT into first +** one. +*/ +void luaK_posfix (FuncState *fs, BinOpr op, + expdesc *e1, expdesc *e2, int line) { + switch (op) { + case OPR_AND: { + lua_assert(e1->t == NO_JUMP); /* list closed by 'luK_infix' */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->f, e1->f); + *e1 = *e2; + break; + } + case OPR_OR: { + lua_assert(e1->f == NO_JUMP); /* list closed by 'luK_infix' */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->t, e1->t); + *e1 = *e2; + break; + } + case OPR_CONCAT: { + luaK_exp2val(fs, e2); + if (e2->k == VRELOCABLE && + GET_OPCODE(getinstruction(fs, e2)) == OP_CONCAT) { + lua_assert(e1->u.info == GETARG_B(getinstruction(fs, e2))-1); + freeexp(fs, e1); + SETARG_B(getinstruction(fs, e2), e1->u.info); + e1->k = VRELOCABLE; e1->u.info = e2->u.info; + } + else { + luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ + codebinexpval(fs, OP_CONCAT, e1, e2, line); + } + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_IDIV: case OPR_MOD: case OPR_POW: + case OPR_BAND: case OPR_BOR: case OPR_BXOR: + case OPR_SHL: case OPR_SHR: { + if (!constfolding(fs, op + LUA_OPADD, e1, e2)) + codebinexpval(fs, cast(OpCode, op + OP_ADD), e1, e2, line); + break; + } + case OPR_EQ: case OPR_LT: case OPR_LE: + case OPR_NE: case OPR_GT: case OPR_GE: { + codecomp(fs, op, e1, e2); + break; + } + default: lua_assert(0); + } +} + + +/* +** Change line information associated with current position. +*/ +void luaK_fixline (FuncState *fs, int line) { + fs->f->lineinfo[fs->pc - 1] = line; +} + + +/* +** Emit a SETLIST instruction. +** 'base' is register that keeps table; +** 'nelems' is #table plus those to be stored now; +** 'tostore' is number of values (in registers 'base + 1',...) to add to +** table (or LUA_MULTRET to add up to stack top). +*/ +void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { + int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int b = (tostore == LUA_MULTRET) ? 0 : tostore; + lua_assert(tostore != 0 && tostore <= LFIELDS_PER_FLUSH); + if (c <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, b, c); + else if (c <= MAXARG_Ax) { + luaK_codeABC(fs, OP_SETLIST, base, b, 0); + codeextraarg(fs, c); + } + else + luaX_syntaxerror(fs->ls, "constructor too long"); + fs->freereg = base + 1; /* free registers with list values */ +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lcode.h b/dep/scintilla/scintilla-3.10.6/lua/src/lcode.h new file mode 100644 index 00000000..cd306d57 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lcode.h @@ -0,0 +1,88 @@ +/* +** $Id: lcode.h,v 1.64 2016/01/05 16:22:37 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums (ORDER OP) +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, + OPR_DIV, + OPR_IDIV, + OPR_BAND, OPR_BOR, OPR_BXOR, + OPR_SHL, OPR_SHR, + OPR_CONCAT, + OPR_EQ, OPR_LT, OPR_LE, + OPR_NE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +/* get (pointer to) instruction of given 'expdesc' */ +#define getinstruction(fs,e) ((fs)->f->code[(e)->u.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +#define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, + expdesc *v2, int line); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lcorolib.c b/dep/scintilla/scintilla-3.10.6/lua/src/lcorolib.c new file mode 100644 index 00000000..2303429e --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lcorolib.c @@ -0,0 +1,168 @@ +/* +** $Id: lcorolib.c,v 1.10 2016/04/11 19:19:55 roberto Exp $ +** Coroutine Library +** See Copyright Notice in lua.h +*/ + +#define lcorolib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static lua_State *getco (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "thread expected"); + return co; +} + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status; + if (!lua_checkstack(co, narg)) { + lua_pushliteral(L, "too many arguments to resume"); + return -1; /* error flag */ + } + if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { + lua_pushliteral(L, "cannot resume dead coroutine"); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + status = lua_resume(co, L, narg); + if (status == LUA_OK || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) { + lua_pop(co, nres); /* remove results anyway */ + lua_pushliteral(L, "too many results to resume"); + return -1; /* error flag */ + } + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = getco(L); + int r; + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + 'resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + return lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL; + luaL_checktype(L, 1, LUA_TFUNCTION); + NL = lua_newthread(L); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = getco(L); + if (L == co) lua_pushliteral(L, "running"); + else { + switch (lua_status(co)) { + case LUA_YIELD: + lua_pushliteral(L, "suspended"); + break; + case LUA_OK: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + lua_pushliteral(L, "normal"); /* it is running */ + else if (lua_gettop(co) == 0) + lua_pushliteral(L, "dead"); + else + lua_pushliteral(L, "suspended"); /* initial state */ + break; + } + default: /* some error occurred */ + lua_pushliteral(L, "dead"); + break; + } + } + return 1; +} + + +static int luaB_yieldable (lua_State *L) { + lua_pushboolean(L, lua_isyieldable(L)); + return 1; +} + + +static int luaB_corunning (lua_State *L) { + int ismain = lua_pushthread(L); + lua_pushboolean(L, ismain); + return 2; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {"isyieldable", luaB_yieldable}, + {NULL, NULL} +}; + + + +LUAMOD_API int luaopen_coroutine (lua_State *L) { + luaL_newlib(L, co_funcs); + return 1; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lctype.c b/dep/scintilla/scintilla-3.10.6/lua/src/lctype.c new file mode 100644 index 00000000..ae9367e6 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lctype.c @@ -0,0 +1,55 @@ +/* +** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ +** 'ctype' functions for Lua +** See Copyright Notice in lua.h +*/ + +#define lctype_c +#define LUA_CORE + +#include "lprefix.h" + + +#include "lctype.h" + +#if !LUA_USE_CTYPE /* { */ + +#include + +LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { + 0x00, /* EOZ */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ + 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ + 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ + 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, + 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ + 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +#endif /* } */ diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lctype.h b/dep/scintilla/scintilla-3.10.6/lua/src/lctype.h new file mode 100644 index 00000000..99c7d122 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lctype.h @@ -0,0 +1,95 @@ +/* +** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ +** 'ctype' functions for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lctype_h +#define lctype_h + +#include "lua.h" + + +/* +** WARNING: the functions defined here do not necessarily correspond +** to the similar functions in the standard C ctype.h. They are +** optimized for the specific needs of Lua +*/ + +#if !defined(LUA_USE_CTYPE) + +#if 'A' == 65 && '0' == 48 +/* ASCII case: can use its own tables; faster and fixed */ +#define LUA_USE_CTYPE 0 +#else +/* must use standard C ctype */ +#define LUA_USE_CTYPE 1 +#endif + +#endif + + +#if !LUA_USE_CTYPE /* { */ + +#include + +#include "llimits.h" + + +#define ALPHABIT 0 +#define DIGITBIT 1 +#define PRINTBIT 2 +#define SPACEBIT 3 +#define XDIGITBIT 4 + + +#define MASK(B) (1 << (B)) + + +/* +** add 1 to char to allow index -1 (EOZ) +*/ +#define testprop(c,p) (luai_ctype_[(c)+1] & (p)) + +/* +** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' +*/ +#define lislalpha(c) testprop(c, MASK(ALPHABIT)) +#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) +#define lisdigit(c) testprop(c, MASK(DIGITBIT)) +#define lisspace(c) testprop(c, MASK(SPACEBIT)) +#define lisprint(c) testprop(c, MASK(PRINTBIT)) +#define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) + +/* +** this 'ltolower' only works for alphabetic characters +*/ +#define ltolower(c) ((c) | ('A' ^ 'a')) + + +/* two more entries for 0 and -1 (EOZ) */ +LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; + + +#else /* }{ */ + +/* +** use standard C ctypes +*/ + +#include + + +#define lislalpha(c) (isalpha(c) || (c) == '_') +#define lislalnum(c) (isalnum(c) || (c) == '_') +#define lisdigit(c) (isdigit(c)) +#define lisspace(c) (isspace(c)) +#define lisprint(c) (isprint(c)) +#define lisxdigit(c) (isxdigit(c)) + +#define ltolower(c) (tolower(c)) + +#endif /* } */ + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ldblib.c b/dep/scintilla/scintilla-3.10.6/lua/src/ldblib.c new file mode 100644 index 00000000..786f6cd9 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ldblib.c @@ -0,0 +1,456 @@ +/* +** $Id: ldblib.c,v 1.151 2015/11/23 11:29:43 roberto Exp $ +** Interface from Lua to its debug API +** See Copyright Notice in lua.h +*/ + +#define ldblib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* +** The hook table at registry[&HOOKKEY] maps threads to their current +** hook function. (We only need the unique address of 'HOOKKEY'.) +*/ +static const int HOOKKEY = 0; + + +/* +** If L1 != L, L1 can be in any state, and therefore there are no +** guarantees about its stack space; any push in L1 must be +** checked. +*/ +static void checkstack (lua_State *L, lua_State *L1, int n) { + if (L != L1 && !lua_checkstack(L1, n)) + luaL_error(L, "stack overflow"); +} + + +static int db_getregistry (lua_State *L) { + lua_pushvalue(L, LUA_REGISTRYINDEX); + return 1; +} + + +static int db_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); /* no metatable */ + } + return 1; +} + + +static int db_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; /* return 1st argument */ +} + + +static int db_getuservalue (lua_State *L) { + if (lua_type(L, 1) != LUA_TUSERDATA) + lua_pushnil(L); + else + lua_getuservalue(L, 1); + return 1; +} + + +static int db_setuservalue (lua_State *L) { + luaL_checktype(L, 1, LUA_TUSERDATA); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_setuservalue(L, 1); + return 1; +} + + +/* +** Auxiliary function used by several library functions: check for +** an optional thread as function's first argument and set 'arg' with +** 1 if this argument is present (so that functions can skip it to +** access their other arguments) +*/ +static lua_State *getthread (lua_State *L, int *arg) { + if (lua_isthread(L, 1)) { + *arg = 1; + return lua_tothread(L, 1); + } + else { + *arg = 0; + return L; /* function will operate over current thread */ + } +} + + +/* +** Variations of 'lua_settable', used by 'db_getinfo' to put results +** from 'lua_getinfo' into result table. Key is always a string; +** value can be a string, an int, or a boolean. +*/ +static void settabss (lua_State *L, const char *k, const char *v) { + lua_pushstring(L, v); + lua_setfield(L, -2, k); +} + +static void settabsi (lua_State *L, const char *k, int v) { + lua_pushinteger(L, v); + lua_setfield(L, -2, k); +} + +static void settabsb (lua_State *L, const char *k, int v) { + lua_pushboolean(L, v); + lua_setfield(L, -2, k); +} + + +/* +** In function 'db_getinfo', the call to 'lua_getinfo' may push +** results on the stack; later it creates the result table to put +** these objects. Function 'treatstackoption' puts the result from +** 'lua_getinfo' on top of the result table so that it can call +** 'lua_setfield'. +*/ +static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { + if (L == L1) + lua_rotate(L, -2, 1); /* exchange object and table */ + else + lua_xmove(L1, L, 1); /* move object to the "main" stack */ + lua_setfield(L, -2, fname); /* put object into table */ +} + + +/* +** Calls 'lua_getinfo' and collects all results in a new table. +** L1 needs stack space for an optional input (function) plus +** two optional outputs (function and line table) from function +** 'lua_getinfo'. +*/ +static int db_getinfo (lua_State *L) { + lua_Debug ar; + int arg; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnStu"); + checkstack(L, L1, 3); + if (lua_isfunction(L, arg + 1)) { /* info about a function? */ + options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */ + lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ + lua_xmove(L, L1, 1); + } + else { /* stack level */ + if (!lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + if (!lua_getinfo(L1, options, &ar)) + return luaL_argerror(L, arg+2, "invalid option"); + lua_newtable(L); /* table to collect results */ + if (strchr(options, 'S')) { + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + } + if (strchr(options, 'l')) + settabsi(L, "currentline", ar.currentline); + if (strchr(options, 'u')) { + settabsi(L, "nups", ar.nups); + settabsi(L, "nparams", ar.nparams); + settabsb(L, "isvararg", ar.isvararg); + } + if (strchr(options, 'n')) { + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + } + if (strchr(options, 't')) + settabsb(L, "istailcall", ar.istailcall); + if (strchr(options, 'L')) + treatstackoption(L, L1, "activelines"); + if (strchr(options, 'f')) + treatstackoption(L, L1, "func"); + return 1; /* return table */ +} + + +static int db_getlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */ + if (lua_isfunction(L, arg + 1)) { /* function argument? */ + lua_pushvalue(L, arg + 1); /* push function */ + lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */ + return 1; /* return only name (there is no value) */ + } + else { /* stack-level argument */ + int level = (int)luaL_checkinteger(L, arg + 1); + if (!lua_getstack(L1, level, &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + checkstack(L, L1, 1); + name = lua_getlocal(L1, &ar, nvar); + if (name) { + lua_xmove(L1, L, 1); /* move local value */ + lua_pushstring(L, name); /* push name */ + lua_rotate(L, -2, 1); /* re-order */ + return 2; + } + else { + lua_pushnil(L); /* no name (nor value) */ + return 1; + } + } +} + + +static int db_setlocal (lua_State *L) { + int arg; + const char *name; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + int level = (int)luaL_checkinteger(L, arg + 1); + int nvar = (int)luaL_checkinteger(L, arg + 2); + if (!lua_getstack(L1, level, &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + luaL_checkany(L, arg+3); + lua_settop(L, arg+3); + checkstack(L, L1, 1); + lua_xmove(L, L1, 1); + name = lua_setlocal(L1, &ar, nvar); + if (name == NULL) + lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */ + lua_pushstring(L, name); + return 1; +} + + +/* +** get (if 'get' is true) or set an upvalue from a closure +*/ +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = (int)luaL_checkinteger(L, 2); /* upvalue index */ + luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */ + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); /* no-op if get is false */ + return get + 1; +} + + +static int db_getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int db_setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + +/* +** Check whether a given upvalue from a given closure exists and +** returns its index +*/ +static int checkupval (lua_State *L, int argf, int argnup) { + int nup = (int)luaL_checkinteger(L, argnup); /* upvalue index */ + luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ + luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup, + "invalid upvalue index"); + return nup; +} + + +static int db_upvalueid (lua_State *L) { + int n = checkupval(L, 1, 2); + lua_pushlightuserdata(L, lua_upvalueid(L, 1, n)); + return 1; +} + + +static int db_upvaluejoin (lua_State *L) { + int n1 = checkupval(L, 1, 2); + int n2 = checkupval(L, 3, 4); + luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); + luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); + lua_upvaluejoin(L, 1, n1, 3, n2); + return 0; +} + + +/* +** Call hook function registered at hook table for the current +** thread (if there is one) +*/ +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail call"}; + lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY); + lua_pushthread(L); + if (lua_rawget(L, -2) == LUA_TFUNCTION) { /* is there a hook function? */ + lua_pushstring(L, hooknames[(int)ar->event]); /* push event name */ + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); /* push current line */ + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); /* call hook function */ + } +} + + +/* +** Convert a string mask (for 'sethook') into a bit mask +*/ +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +/* +** Convert a bit mask (for 'gethook') into a string mask +*/ +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static int db_sethook (lua_State *L) { + int arg, mask, count; + lua_Hook func; + lua_State *L1 = getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { /* no hook? */ + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = (int)luaL_optinteger(L, arg + 3, 0); + func = hookf; mask = makemask(smask, count); + } + if (lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY) == LUA_TNIL) { + lua_createtable(L, 0, 2); /* create a hook table */ + lua_pushvalue(L, -1); + lua_rawsetp(L, LUA_REGISTRYINDEX, &HOOKKEY); /* set it in position */ + lua_pushstring(L, "k"); + lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */ + lua_pushvalue(L, -1); + lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ + } + checkstack(L, L1, 1); + lua_pushthread(L1); lua_xmove(L1, L, 1); /* key (thread) */ + lua_pushvalue(L, arg + 1); /* value (hook function) */ + lua_rawset(L, -3); /* hooktable[L1] = new Lua hook */ + lua_sethook(L1, func, mask, count); + return 0; +} + + +static int db_gethook (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + char buff[5]; + int mask = lua_gethookmask(L1); + lua_Hook hook = lua_gethook(L1); + if (hook == NULL) /* no hook? */ + lua_pushnil(L); + else if (hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { /* hook table must exist */ + lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY); + checkstack(L, L1, 1); + lua_pushthread(L1); lua_xmove(L1, L, 1); + lua_rawget(L, -2); /* 1st result = hooktable[L1] */ + lua_remove(L, -2); /* remove hook table */ + } + lua_pushstring(L, unmakemask(mask, buff)); /* 2nd result = mask */ + lua_pushinteger(L, lua_gethookcount(L1)); /* 3rd result = count */ + return 3; +} + + +static int db_debug (lua_State *L) { + for (;;) { + char buffer[250]; + lua_writestringerror("%s", "lua_debug> "); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) + lua_writestringerror("%s\n", lua_tostring(L, -1)); + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +static int db_traceback (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + const char *msg = lua_tostring(L, arg + 1); + if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ + lua_pushvalue(L, arg + 1); /* return it untouched */ + else { + int level = (int)luaL_optinteger(L, arg + 2, (L == L1) ? 1 : 0); + luaL_traceback(L, L1, msg, level); + } + return 1; +} + + +static const luaL_Reg dblib[] = { + {"debug", db_debug}, + {"getuservalue", db_getuservalue}, + {"gethook", db_gethook}, + {"getinfo", db_getinfo}, + {"getlocal", db_getlocal}, + {"getregistry", db_getregistry}, + {"getmetatable", db_getmetatable}, + {"getupvalue", db_getupvalue}, + {"upvaluejoin", db_upvaluejoin}, + {"upvalueid", db_upvalueid}, + {"setuservalue", db_setuservalue}, + {"sethook", db_sethook}, + {"setlocal", db_setlocal}, + {"setmetatable", db_setmetatable}, + {"setupvalue", db_setupvalue}, + {"traceback", db_traceback}, + {NULL, NULL} +}; + + +LUAMOD_API int luaopen_debug (lua_State *L) { + luaL_newlib(L, dblib); + return 1; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ldebug.c b/dep/scintilla/scintilla-3.10.6/lua/src/ldebug.c new file mode 100644 index 00000000..239affb7 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ldebug.c @@ -0,0 +1,698 @@ +/* +** $Id: ldebug.c,v 2.121 2016/10/19 12:32:10 roberto Exp $ +** Debug Interface +** See Copyright Notice in lua.h +*/ + +#define ldebug_c +#define LUA_CORE + +#include "lprefix.h" + + +#include +#include +#include + +#include "lua.h" + +#include "lapi.h" +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +#define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_TCCL) + + +/* Active Lua function (given call info) */ +#define ci_func(ci) (clLvalue((ci)->func)) + + +static const char *funcnamefromcode (lua_State *L, CallInfo *ci, + const char **name); + + +static int currentpc (CallInfo *ci) { + lua_assert(isLua(ci)); + return pcRel(ci->u.l.savedpc, ci_func(ci)->p); +} + + +static int currentline (CallInfo *ci) { + return getfuncline(ci_func(ci)->p, currentpc(ci)); +} + + +/* +** If function yielded, its 'func' can be in the 'extra' field. The +** next function restores 'func' to its correct value for debugging +** purposes. (It exchanges 'func' and 'extra'; so, when called again, +** after debugging, it also "re-restores" ** 'func' to its altered value. +*/ +static void swapextra (lua_State *L) { + if (L->status == LUA_YIELD) { + CallInfo *ci = L->ci; /* get function that yielded */ + StkId temp = ci->func; /* exchange its 'func' and 'extra' values */ + ci->func = restorestack(L, ci->extra); + ci->extra = savestack(L, temp); + } +} + + +/* +** This function can be called asynchronously (e.g. during a signal). +** Fields 'oldpc', 'basehookcount', and 'hookcount' (set by +** 'resethookcount') are for debug only, and it is no problem if they +** get arbitrary values (causes at most one wrong hook call). 'hookmask' +** is an atomic value. We assume that pointers are atomic too (e.g., gcc +** ensures that for all platforms where it runs). Moreover, 'hook' is +** always checked before being called (see 'luaD_hook'). +*/ +LUA_API void lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { + if (func == NULL || mask == 0) { /* turn off hooks? */ + mask = 0; + func = NULL; + } + if (isLua(L->ci)) + L->oldpc = L->ci->u.l.savedpc; + L->hook = func; + L->basehookcount = count; + resethookcount(L); + L->hookmask = cast_byte(mask); +} + + +LUA_API lua_Hook lua_gethook (lua_State *L) { + return L->hook; +} + + +LUA_API int lua_gethookmask (lua_State *L) { + return L->hookmask; +} + + +LUA_API int lua_gethookcount (lua_State *L) { + return L->basehookcount; +} + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { + int status; + CallInfo *ci; + if (level < 0) return 0; /* invalid (negative) level */ + lua_lock(L); + for (ci = L->ci; level > 0 && ci != &L->base_ci; ci = ci->previous) + level--; + if (level == 0 && ci != &L->base_ci) { /* level found? */ + status = 1; + ar->i_ci = ci; + } + else status = 0; /* no such level */ + lua_unlock(L); + return status; +} + + +static const char *upvalname (Proto *p, int uv) { + TString *s = check_exp(uv < p->sizeupvalues, p->upvalues[uv].name); + if (s == NULL) return "?"; + else return getstr(s); +} + + +static const char *findvararg (CallInfo *ci, int n, StkId *pos) { + int nparams = clLvalue(ci->func)->p->numparams; + if (n >= cast_int(ci->u.l.base - ci->func) - nparams) + return NULL; /* no such vararg */ + else { + *pos = ci->func + nparams + n; + return "(*vararg)"; /* generic name for any vararg */ + } +} + + +static const char *findlocal (lua_State *L, CallInfo *ci, int n, + StkId *pos) { + const char *name = NULL; + StkId base; + if (isLua(ci)) { + if (n < 0) /* access to vararg values? */ + return findvararg(ci, -n, pos); + else { + base = ci->u.l.base; + name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); + } + } + else + base = ci->func + 1; + if (name == NULL) { /* no 'standard' name? */ + StkId limit = (ci == L->ci) ? L->top : ci->next->func; + if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + name = "(*temporary)"; /* generic name for any valid slot */ + else + return NULL; /* no name */ + } + *pos = base + (n - 1); + return name; +} + + +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { + const char *name; + lua_lock(L); + swapextra(L); + if (ar == NULL) { /* information about non-active function? */ + if (!isLfunction(L->top - 1)) /* not a Lua function? */ + name = NULL; + else /* consider live variables at function start (parameters) */ + name = luaF_getlocalname(clLvalue(L->top - 1)->p, n, 0); + } + else { /* active function; get information through 'ar' */ + StkId pos = NULL; /* to avoid warnings */ + name = findlocal(L, ar->i_ci, n, &pos); + if (name) { + setobj2s(L, L->top, pos); + api_incr_top(L); + } + } + swapextra(L); + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { + StkId pos = NULL; /* to avoid warnings */ + const char *name; + lua_lock(L); + swapextra(L); + name = findlocal(L, ar->i_ci, n, &pos); + if (name) { + setobjs2s(L, pos, L->top - 1); + L->top--; /* pop value */ + } + swapextra(L); + lua_unlock(L); + return name; +} + + +static void funcinfo (lua_Debug *ar, Closure *cl) { + if (noLuaClosure(cl)) { + ar->source = "=[C]"; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + else { + Proto *p = cl->l.p; + ar->source = p->source ? getstr(p->source) : "=?"; + ar->linedefined = p->linedefined; + ar->lastlinedefined = p->lastlinedefined; + ar->what = (ar->linedefined == 0) ? "main" : "Lua"; + } + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); +} + + +static void collectvalidlines (lua_State *L, Closure *f) { + if (noLuaClosure(f)) { + setnilvalue(L->top); + api_incr_top(L); + } + else { + int i; + TValue v; + int *lineinfo = f->l.p->lineinfo; + Table *t = luaH_new(L); /* new table to store active lines */ + sethvalue(L, L->top, t); /* push it on stack */ + api_incr_top(L); + setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */ + for (i = 0; i < f->l.p->sizelineinfo; i++) /* for all lines with code */ + luaH_setint(L, t, lineinfo[i], &v); /* table[line] = true */ + } +} + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + if (ci == NULL) /* no 'ci'? */ + return NULL; /* no info */ + else if (ci->callstatus & CIST_FIN) { /* is this a finalizer? */ + *name = "__gc"; + return "metamethod"; /* report it as such */ + } + /* calling function is a known Lua function? */ + else if (!(ci->callstatus & CIST_TAIL) && isLua(ci->previous)) + return funcnamefromcode(L, ci->previous, name); + else return NULL; /* no way to find a name */ +} + + +static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, + Closure *f, CallInfo *ci) { + int status = 1; + for (; *what; what++) { + switch (*what) { + case 'S': { + funcinfo(ar, f); + break; + } + case 'l': { + ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1; + break; + } + case 'u': { + ar->nups = (f == NULL) ? 0 : f->c.nupvalues; + if (noLuaClosure(f)) { + ar->isvararg = 1; + ar->nparams = 0; + } + else { + ar->isvararg = f->l.p->is_vararg; + ar->nparams = f->l.p->numparams; + } + break; + } + case 't': { + ar->istailcall = (ci) ? ci->callstatus & CIST_TAIL : 0; + break; + } + case 'n': { + ar->namewhat = getfuncname(L, ci, &ar->name); + if (ar->namewhat == NULL) { + ar->namewhat = ""; /* not found */ + ar->name = NULL; + } + break; + } + case 'L': + case 'f': /* handled by lua_getinfo */ + break; + default: status = 0; /* invalid option */ + } + } + return status; +} + + +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { + int status; + Closure *cl; + CallInfo *ci; + StkId func; + lua_lock(L); + swapextra(L); + if (*what == '>') { + ci = NULL; + func = L->top - 1; + api_check(L, ttisfunction(func), "function expected"); + what++; /* skip the '>' */ + L->top--; /* pop function */ + } + else { + ci = ar->i_ci; + func = ci->func; + lua_assert(ttisfunction(ci->func)); + } + cl = ttisclosure(func) ? clvalue(func) : NULL; + status = auxgetinfo(L, what, ar, cl, ci); + if (strchr(what, 'f')) { + setobjs2s(L, L->top, func); + api_incr_top(L); + } + swapextra(L); /* correct before option 'L', which can raise a mem. error */ + if (strchr(what, 'L')) + collectvalidlines(L, cl); + lua_unlock(L); + return status; +} + + +/* +** {====================================================== +** Symbolic Execution +** ======================================================= +*/ + +static const char *getobjname (Proto *p, int lastpc, int reg, + const char **name); + + +/* +** find a "name" for the RK value 'c' +*/ +static void kname (Proto *p, int pc, int c, const char **name) { + if (ISK(c)) { /* is 'c' a constant? */ + TValue *kvalue = &p->k[INDEXK(c)]; + if (ttisstring(kvalue)) { /* literal constant? */ + *name = svalue(kvalue); /* it is its own name */ + return; + } + /* else no reasonable name found */ + } + else { /* 'c' is a register */ + const char *what = getobjname(p, pc, c, name); /* search for 'c' */ + if (what && *what == 'c') { /* found a constant name? */ + return; /* 'name' already filled */ + } + /* else no reasonable name found */ + } + *name = "?"; /* no reasonable name found */ +} + + +static int filterpc (int pc, int jmptarget) { + if (pc < jmptarget) /* is code conditional (inside a jump)? */ + return -1; /* cannot know who sets that register */ + else return pc; /* current position sets that register */ +} + + +/* +** try to find last instruction before 'lastpc' that modified register 'reg' +*/ +static int findsetreg (Proto *p, int lastpc, int reg) { + int pc; + int setreg = -1; /* keep last instruction that changed 'reg' */ + int jmptarget = 0; /* any code before this address is conditional */ + for (pc = 0; pc < lastpc; pc++) { + Instruction i = p->code[pc]; + OpCode op = GET_OPCODE(i); + int a = GETARG_A(i); + switch (op) { + case OP_LOADNIL: { + int b = GETARG_B(i); + if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ + setreg = filterpc(pc, jmptarget); + break; + } + case OP_TFORCALL: { + if (reg >= a + 2) /* affect all regs above its base */ + setreg = filterpc(pc, jmptarget); + break; + } + case OP_CALL: + case OP_TAILCALL: { + if (reg >= a) /* affect all registers above base */ + setreg = filterpc(pc, jmptarget); + break; + } + case OP_JMP: { + int b = GETARG_sBx(i); + int dest = pc + 1 + b; + /* jump is forward and do not skip 'lastpc'? */ + if (pc < dest && dest <= lastpc) { + if (dest > jmptarget) + jmptarget = dest; /* update 'jmptarget' */ + } + break; + } + default: + if (testAMode(op) && reg == a) /* any instruction that set A */ + setreg = filterpc(pc, jmptarget); + break; + } + } + return setreg; +} + + +static const char *getobjname (Proto *p, int lastpc, int reg, + const char **name) { + int pc; + *name = luaF_getlocalname(p, reg + 1, lastpc); + if (*name) /* is a local? */ + return "local"; + /* else try symbolic execution */ + pc = findsetreg(p, lastpc, reg); + if (pc != -1) { /* could find instruction? */ + Instruction i = p->code[pc]; + OpCode op = GET_OPCODE(i); + switch (op) { + case OP_MOVE: { + int b = GETARG_B(i); /* move from 'b' to 'a' */ + if (b < GETARG_A(i)) + return getobjname(p, pc, b, name); /* get name for 'b' */ + break; + } + case OP_GETTABUP: + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + int t = GETARG_B(i); /* table index */ + const char *vn = (op == OP_GETTABLE) /* name of indexed variable */ + ? luaF_getlocalname(p, t + 1, pc) + : upvalname(p, t); + kname(p, pc, k, name); + return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field"; + } + case OP_GETUPVAL: { + *name = upvalname(p, GETARG_B(i)); + return "upvalue"; + } + case OP_LOADK: + case OP_LOADKX: { + int b = (op == OP_LOADK) ? GETARG_Bx(i) + : GETARG_Ax(p->code[pc + 1]); + if (ttisstring(&p->k[b])) { + *name = svalue(&p->k[b]); + return "constant"; + } + break; + } + case OP_SELF: { + int k = GETARG_C(i); /* key index */ + kname(p, pc, k, name); + return "method"; + } + default: break; /* go through to return NULL */ + } + } + return NULL; /* could not find reasonable name */ +} + + +/* +** Try to find a name for a function based on the code that called it. +** (Only works when function was called by a Lua function.) +** Returns what the name is (e.g., "for iterator", "method", +** "metamethod") and sets '*name' to point to the name. +*/ +static const char *funcnamefromcode (lua_State *L, CallInfo *ci, + const char **name) { + TMS tm = (TMS)0; /* (initial value avoids warnings) */ + Proto *p = ci_func(ci)->p; /* calling function */ + int pc = currentpc(ci); /* calling instruction index */ + Instruction i = p->code[pc]; /* calling instruction */ + if (ci->callstatus & CIST_HOOKED) { /* was it called inside a hook? */ + *name = "?"; + return "hook"; + } + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: + return getobjname(p, pc, GETARG_A(i), name); /* get function name */ + case OP_TFORCALL: { /* for iterator */ + *name = "for iterator"; + return "for iterator"; + } + /* other instructions can do calls through metamethods */ + case OP_SELF: case OP_GETTABUP: case OP_GETTABLE: + tm = TM_INDEX; + break; + case OP_SETTABUP: case OP_SETTABLE: + tm = TM_NEWINDEX; + break; + case OP_ADD: case OP_SUB: case OP_MUL: case OP_MOD: + case OP_POW: case OP_DIV: case OP_IDIV: case OP_BAND: + case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: { + int offset = cast_int(GET_OPCODE(i)) - cast_int(OP_ADD); /* ORDER OP */ + tm = cast(TMS, offset + cast_int(TM_ADD)); /* ORDER TM */ + break; + } + case OP_UNM: tm = TM_UNM; break; + case OP_BNOT: tm = TM_BNOT; break; + case OP_LEN: tm = TM_LEN; break; + case OP_CONCAT: tm = TM_CONCAT; break; + case OP_EQ: tm = TM_EQ; break; + case OP_LT: tm = TM_LT; break; + case OP_LE: tm = TM_LE; break; + default: + return NULL; /* cannot find a reasonable name */ + } + *name = getstr(G(L)->tmname[tm]); + return "metamethod"; +} + +/* }====================================================== */ + + + +/* +** The subtraction of two potentially unrelated pointers is +** not ISO C, but it should not crash a program; the subsequent +** checks are ISO C and ensure a correct result. +*/ +static int isinstack (CallInfo *ci, const TValue *o) { + ptrdiff_t i = o - ci->u.l.base; + return (0 <= i && i < (ci->top - ci->u.l.base) && ci->u.l.base + i == o); +} + + +/* +** Checks whether value 'o' came from an upvalue. (That can only happen +** with instructions OP_GETTABUP/OP_SETTABUP, which operate directly on +** upvalues.) +*/ +static const char *getupvalname (CallInfo *ci, const TValue *o, + const char **name) { + LClosure *c = ci_func(ci); + int i; + for (i = 0; i < c->nupvalues; i++) { + if (c->upvals[i]->v == o) { + *name = upvalname(c->p, i); + return "upvalue"; + } + } + return NULL; +} + + +static const char *varinfo (lua_State *L, const TValue *o) { + const char *name = NULL; /* to avoid warnings */ + CallInfo *ci = L->ci; + const char *kind = NULL; + if (isLua(ci)) { + kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ + if (!kind && isinstack(ci, o)) /* no? try a register */ + kind = getobjname(ci_func(ci)->p, currentpc(ci), + cast_int(o - ci->u.l.base), &name); + } + return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : ""; +} + + +l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + const char *t = luaT_objtypename(L, o); + luaG_runerror(L, "attempt to %s a %s value%s", op, t, varinfo(L, o)); +} + + +l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2) { + if (ttisstring(p1) || cvt2str(p1)) p1 = p2; + luaG_typeerror(L, p1, "concatenate"); +} + + +l_noret luaG_opinterror (lua_State *L, const TValue *p1, + const TValue *p2, const char *msg) { + lua_Number temp; + if (!tonumber(p1, &temp)) /* first operand is wrong? */ + p2 = p1; /* now second is wrong */ + luaG_typeerror(L, p2, msg); +} + + +/* +** Error when both values are convertible to numbers, but not to integers +*/ +l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) { + lua_Integer temp; + if (!tointeger(p1, &temp)) + p2 = p1; + luaG_runerror(L, "number%s has no integer representation", varinfo(L, p2)); +} + + +l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = luaT_objtypename(L, p1); + const char *t2 = luaT_objtypename(L, p2); + if (strcmp(t1, t2) == 0) + luaG_runerror(L, "attempt to compare two %s values", t1); + else + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); +} + + +/* add src:line information to 'msg' */ +const char *luaG_addinfo (lua_State *L, const char *msg, TString *src, + int line) { + char buff[LUA_IDSIZE]; + if (src) + luaO_chunkid(buff, getstr(src), LUA_IDSIZE); + else { /* no source available; use "?" instead */ + buff[0] = '?'; buff[1] = '\0'; + } + return luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); +} + + +l_noret luaG_errormsg (lua_State *L) { + if (L->errfunc != 0) { /* is there an error handling function? */ + StkId errfunc = restorestack(L, L->errfunc); + setobjs2s(L, L->top, L->top - 1); /* move argument */ + setobjs2s(L, L->top - 1, errfunc); /* push function */ + L->top++; /* assume EXTRA_STACK */ + luaD_callnoyield(L, L->top - 2, 1); /* call it */ + } + luaD_throw(L, LUA_ERRRUN); +} + + +l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { + CallInfo *ci = L->ci; + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); /* format message */ + va_end(argp); + if (isLua(ci)) /* if Lua function, add source:line information */ + luaG_addinfo(L, msg, ci_func(ci)->p->source, currentline(ci)); + luaG_errormsg(L); +} + + +void luaG_traceexec (lua_State *L) { + CallInfo *ci = L->ci; + lu_byte mask = L->hookmask; + int counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT)); + if (counthook) + resethookcount(L); /* reset count */ + else if (!(mask & LUA_MASKLINE)) + return; /* no line hook and count != 0; nothing to be done */ + if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ + ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ + return; /* do not call hook again (VM yielded, so it did not move) */ + } + if (counthook) + luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ + if (mask & LUA_MASKLINE) { + Proto *p = ci_func(ci)->p; + int npc = pcRel(ci->u.l.savedpc, p); + int newline = getfuncline(p, npc); + if (npc == 0 || /* call linehook when enter a new function, */ + ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ + newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */ + luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ + } + L->oldpc = ci->u.l.savedpc; + if (L->status == LUA_YIELD) { /* did hook yield? */ + if (counthook) + L->hookcount = 1; /* undo decrement to zero */ + ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ + ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ + ci->func = L->top - 1; /* protect stack below results */ + luaD_throw(L, LUA_YIELD); + } +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ldebug.h b/dep/scintilla/scintilla-3.10.6/lua/src/ldebug.h new file mode 100644 index 00000000..0e31546b --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ldebug.h @@ -0,0 +1,39 @@ +/* +** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + + +LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, + const TValue *p2, + const char *msg); +LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, + TString *src, int line); +LUAI_FUNC l_noret luaG_errormsg (lua_State *L); +LUAI_FUNC void luaG_traceexec (lua_State *L); + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ldo.c b/dep/scintilla/scintilla-3.10.6/lua/src/ldo.c new file mode 100644 index 00000000..90b695fb --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ldo.c @@ -0,0 +1,802 @@ +/* +** $Id: ldo.c,v 2.157 2016/12/13 15:52:21 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#define ldo_c +#define LUA_CORE + +#include "lprefix.h" + + +#include +#include +#include + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" +#include "lzio.h" + + + +#define errorstatus(s) ((s) > LUA_YIELD) + + +/* +** {====================================================== +** Error-recovery functions +** ======================================================= +*/ + +/* +** LUAI_THROW/LUAI_TRY define how Lua does exception handling. By +** default, Lua handles errors with exceptions when compiling as +** C++ code, with _longjmp/_setjmp when asked to use them, and with +** longjmp/setjmp otherwise. +*/ +#if !defined(LUAI_THROW) /* { */ + +#if defined(__cplusplus) && !defined(LUA_USE_LONGJMP) /* { */ + +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) \ + try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_POSIX) /* }{ */ + +/* in POSIX, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else /* }{ */ + +/* ISO C handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif /* } */ + +#endif /* } */ + + + +/* chain list of long jump buffers */ +struct lua_longjmp { + struct lua_longjmp *previous; + luai_jmpbuf b; + volatile int status; /* error code */ +}; + + +static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { + switch (errcode) { + case LUA_ERRMEM: { /* memory error? */ + setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ + break; + } + case LUA_ERRERR: { + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + break; + } + default: { + setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + break; + } + } + L->top = oldtop + 1; +} + + +l_noret luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { /* thread has an error handler? */ + L->errorJmp->status = errcode; /* set status */ + LUAI_THROW(L, L->errorJmp); /* jump to it */ + } + else { /* thread has no error handler */ + global_State *g = G(L); + L->status = cast_byte(errcode); /* mark it as dead */ + if (g->mainthread->errorJmp) { /* main thread has a handler? */ + setobjs2s(L, g->mainthread->top++, L->top - 1); /* copy error obj. */ + luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ + } + else { /* no handler at all; abort */ + if (g->panic) { /* panic function? */ + seterrorobj(L, errcode, L->top); /* assume EXTRA_STACK */ + if (L->ci->top < L->top) + L->ci->top = L->top; /* pushing msg. can break this invariant */ + lua_unlock(L); + g->panic(L); /* call panic function (last chance to jump out) */ + } + abort(); + } + } +} + + +int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + unsigned short oldnCcalls = L->nCcalls; + struct lua_longjmp lj; + lj.status = LUA_OK; + lj.previous = L->errorJmp; /* chain new error handler */ + L->errorJmp = &lj; + LUAI_TRY(L, &lj, + (*f)(L, ud); + ); + L->errorJmp = lj.previous; /* restore old error handler */ + L->nCcalls = oldnCcalls; + return lj.status; +} + +/* }====================================================== */ + + +/* +** {================================================================== +** Stack reallocation +** =================================================================== +*/ +static void correctstack (lua_State *L, TValue *oldstack) { + CallInfo *ci; + UpVal *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->u.open.next) + up->v = (up->v - oldstack) + L->stack; + for (ci = L->ci; ci != NULL; ci = ci->previous) { + ci->top = (ci->top - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + if (isLua(ci)) + ci->u.l.base = (ci->u.l.base - oldstack) + L->stack; + } +} + + +/* some space for error handling */ +#define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) + + +void luaD_reallocstack (lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int lim = L->stacksize; + lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK); + luaM_reallocvector(L, L->stack, L->stacksize, newsize, TValue); + for (; lim < newsize; lim++) + setnilvalue(L->stack + lim); /* erase new segment */ + L->stacksize = newsize; + L->stack_last = L->stack + newsize - EXTRA_STACK; + correctstack(L, oldstack); +} + + +void luaD_growstack (lua_State *L, int n) { + int size = L->stacksize; + if (size > LUAI_MAXSTACK) /* error after extra size? */ + luaD_throw(L, LUA_ERRERR); + else { + int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK; + int newsize = 2 * size; + if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; + if (newsize < needed) newsize = needed; + if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ + luaD_reallocstack(L, ERRORSTACKSIZE); + luaG_runerror(L, "stack overflow"); + } + else + luaD_reallocstack(L, newsize); + } +} + + +static int stackinuse (lua_State *L) { + CallInfo *ci; + StkId lim = L->top; + for (ci = L->ci; ci != NULL; ci = ci->previous) { + if (lim < ci->top) lim = ci->top; + } + lua_assert(lim <= L->stack_last); + return cast_int(lim - L->stack) + 1; /* part of stack in use */ +} + + +void luaD_shrinkstack (lua_State *L) { + int inuse = stackinuse(L); + int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK; + if (goodsize > LUAI_MAXSTACK) + goodsize = LUAI_MAXSTACK; /* respect stack limit */ + if (L->stacksize > LUAI_MAXSTACK) /* had been handling stack overflow? */ + luaE_freeCI(L); /* free all CIs (list grew because of an error) */ + else + luaE_shrinkCI(L); /* shrink list */ + /* if thread is currently not handling a stack overflow and its + good size is smaller than current size, shrink its stack */ + if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) && + goodsize < L->stacksize) + luaD_reallocstack(L, goodsize); + else /* don't change stack */ + condmovestack(L,{},{}); /* (change only for debugging) */ +} + + +void luaD_inctop (lua_State *L) { + luaD_checkstack(L, 1); + L->top++; +} + +/* }================================================================== */ + + +/* +** Call a hook for the given event. Make sure there is a hook to be +** called. (Both 'L->hook' and 'L->hookmask', which triggers this +** function, can be changed asynchronously by signals.) +*/ +void luaD_hook (lua_State *L, int event, int line) { + lua_Hook hook = L->hook; + if (hook && L->allowhook) { /* make sure there is a hook */ + CallInfo *ci = L->ci; + ptrdiff_t top = savestack(L, L->top); + ptrdiff_t ci_top = savestack(L, ci->top); + lua_Debug ar; + ar.event = event; + ar.currentline = line; + ar.i_ci = ci; + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + L->allowhook = 0; /* cannot call hooks inside a hook */ + ci->callstatus |= CIST_HOOKED; + lua_unlock(L); + (*hook)(L, &ar); + lua_lock(L); + lua_assert(!L->allowhook); + L->allowhook = 1; + ci->top = restorestack(L, ci_top); + L->top = restorestack(L, top); + ci->callstatus &= ~CIST_HOOKED; + } +} + + +static void callhook (lua_State *L, CallInfo *ci) { + int hook = LUA_HOOKCALL; + ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ + if (isLua(ci->previous) && + GET_OPCODE(*(ci->previous->u.l.savedpc - 1)) == OP_TAILCALL) { + ci->callstatus |= CIST_TAIL; + hook = LUA_HOOKTAILCALL; + } + luaD_hook(L, hook, -1); + ci->u.l.savedpc--; /* correct 'pc' */ +} + + +static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { + int i; + int nfixargs = p->numparams; + StkId base, fixed; + /* move fixed parameters to final position */ + fixed = L->top - actual; /* first fixed argument */ + base = L->top; /* final position of first argument */ + for (i = 0; i < nfixargs && i < actual; i++) { + setobjs2s(L, L->top++, fixed + i); + setnilvalue(fixed + i); /* erase original copy (for GC) */ + } + for (; i < nfixargs; i++) + setnilvalue(L->top++); /* complete missing arguments */ + return base; +} + + +/* +** Check whether __call metafield of 'func' is a function. If so, put +** it in stack below original 'func' so that 'luaD_precall' can call +** it. Raise an error if __call metafield is not a function. +*/ +static void tryfuncTM (lua_State *L, StkId func) { + const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); + StkId p; + if (!ttisfunction(tm)) + luaG_typeerror(L, func, "call"); + /* Open a hole inside the stack at 'func' */ + for (p = L->top; p > func; p--) + setobjs2s(L, p, p-1); + L->top++; /* slot ensured by caller */ + setobj2s(L, func, tm); /* tag method is the new function to be called */ +} + + +/* +** Given 'nres' results at 'firstResult', move 'wanted' of them to 'res'. +** Handle most typical cases (zero results for commands, one result for +** expressions, multiple results for tail calls/single parameters) +** separated. +*/ +static int moveresults (lua_State *L, const TValue *firstResult, StkId res, + int nres, int wanted) { + switch (wanted) { /* handle typical cases separately */ + case 0: break; /* nothing to move */ + case 1: { /* one result needed */ + if (nres == 0) /* no results? */ + firstResult = luaO_nilobject; /* adjust with nil */ + setobjs2s(L, res, firstResult); /* move it to proper place */ + break; + } + case LUA_MULTRET: { + int i; + for (i = 0; i < nres; i++) /* move all results to correct place */ + setobjs2s(L, res + i, firstResult + i); + L->top = res + nres; + return 0; /* wanted == LUA_MULTRET */ + } + default: { + int i; + if (wanted <= nres) { /* enough results? */ + for (i = 0; i < wanted; i++) /* move wanted results to correct place */ + setobjs2s(L, res + i, firstResult + i); + } + else { /* not enough results; use all of them plus nils */ + for (i = 0; i < nres; i++) /* move all results to correct place */ + setobjs2s(L, res + i, firstResult + i); + for (; i < wanted; i++) /* complete wanted number of results */ + setnilvalue(res + i); + } + break; + } + } + L->top = res + wanted; /* top points after the last result */ + return 1; +} + + +/* +** Finishes a function call: calls hook if necessary, removes CallInfo, +** moves current number of results to proper place; returns 0 iff call +** wanted multiple (variable number of) results. +*/ +int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, int nres) { + StkId res; + int wanted = ci->nresults; + if (L->hookmask & (LUA_MASKRET | LUA_MASKLINE)) { + if (L->hookmask & LUA_MASKRET) { + ptrdiff_t fr = savestack(L, firstResult); /* hook may change stack */ + luaD_hook(L, LUA_HOOKRET, -1); + firstResult = restorestack(L, fr); + } + L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */ + } + res = ci->func; /* res == final position of 1st result */ + L->ci = ci->previous; /* back to caller */ + /* move results to proper place */ + return moveresults(L, firstResult, res, nres, wanted); +} + + + +#define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L))) + + +/* macro to check stack size, preserving 'p' */ +#define checkstackp(L,n,p) \ + luaD_checkstackaux(L, n, \ + ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ + luaC_checkGC(L), /* stack grow uses memory */ \ + p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ + + +/* +** Prepares a function call: checks the stack, creates a new CallInfo +** entry, fills in the relevant information, calls hook if needed. +** If function is a C function, does the call, too. (Otherwise, leave +** the execution ('luaV_execute') to the caller, to allow stackless +** calls.) Returns true iff function has been executed (C function). +*/ +int luaD_precall (lua_State *L, StkId func, int nresults) { + lua_CFunction f; + CallInfo *ci; + switch (ttype(func)) { + case LUA_TCCL: /* C closure */ + f = clCvalue(func)->f; + goto Cfunc; + case LUA_TLCF: /* light C function */ + f = fvalue(func); + Cfunc: { + int n; /* number of returns */ + checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ + ci = next_ci(L); /* now 'enter' new function */ + ci->nresults = nresults; + ci->func = func; + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->callstatus = 0; + if (L->hookmask & LUA_MASKCALL) + luaD_hook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*f)(L); /* do the actual call */ + lua_lock(L); + api_checknelems(L, n); + luaD_poscall(L, ci, L->top - n, n); + return 1; + } + case LUA_TLCL: { /* Lua function: prepare its call */ + StkId base; + Proto *p = clLvalue(func)->p; + int n = cast_int(L->top - func) - 1; /* number of real arguments */ + int fsize = p->maxstacksize; /* frame size */ + checkstackp(L, fsize, func); + if (p->is_vararg) + base = adjust_varargs(L, p, n); + else { /* non vararg function */ + for (; n < p->numparams; n++) + setnilvalue(L->top++); /* complete missing arguments */ + base = func + 1; + } + ci = next_ci(L); /* now 'enter' new function */ + ci->nresults = nresults; + ci->func = func; + ci->u.l.base = base; + L->top = ci->top = base + fsize; + lua_assert(ci->top <= L->stack_last); + ci->u.l.savedpc = p->code; /* starting point */ + ci->callstatus = CIST_LUA; + if (L->hookmask & LUA_MASKCALL) + callhook(L, ci); + return 0; + } + default: { /* not a function */ + checkstackp(L, 1, func); /* ensure space for metamethod */ + tryfuncTM(L, func); /* try to get '__call' metamethod */ + return luaD_precall(L, func, nresults); /* now it must be a function */ + } + } +} + + +/* +** Check appropriate error for stack overflow ("regular" overflow or +** overflow while handling stack overflow). If 'nCalls' is larger than +** LUAI_MAXCCALLS (which means it is handling a "regular" overflow) but +** smaller than 9/8 of LUAI_MAXCCALLS, does not report an error (to +** allow overflow handling to work) +*/ +static void stackerror (lua_State *L) { + if (L->nCcalls == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ +} + + +/* +** Call a function (C or Lua). The function to be called is at *func. +** The arguments are on the stack, right after the function. +** When returns, all the results are on the stack, starting at the original +** function position. +*/ +void luaD_call (lua_State *L, StkId func, int nResults) { + if (++L->nCcalls >= LUAI_MAXCCALLS) + stackerror(L); + if (!luaD_precall(L, func, nResults)) /* is a Lua function? */ + luaV_execute(L); /* call it */ + L->nCcalls--; +} + + +/* +** Similar to 'luaD_call', but does not allow yields during the call +*/ +void luaD_callnoyield (lua_State *L, StkId func, int nResults) { + L->nny++; + luaD_call(L, func, nResults); + L->nny--; +} + + +/* +** Completes the execution of an interrupted C function, calling its +** continuation function. +*/ +static void finishCcall (lua_State *L, int status) { + CallInfo *ci = L->ci; + int n; + /* must have a continuation and must be able to call it */ + lua_assert(ci->u.c.k != NULL && L->nny == 0); + /* error status can only happen in a protected call */ + lua_assert((ci->callstatus & CIST_YPCALL) || status == LUA_YIELD); + if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */ + ci->callstatus &= ~CIST_YPCALL; /* continuation is also inside it */ + L->errfunc = ci->u.c.old_errfunc; /* with the same error function */ + } + /* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already + handled */ + adjustresults(L, ci->nresults); + lua_unlock(L); + n = (*ci->u.c.k)(L, status, ci->u.c.ctx); /* call continuation function */ + lua_lock(L); + api_checknelems(L, n); + luaD_poscall(L, ci, L->top - n, n); /* finish 'luaD_precall' */ +} + + +/* +** Executes "full continuation" (everything in the stack) of a +** previously interrupted coroutine until the stack is empty (or another +** interruption long-jumps out of the loop). If the coroutine is +** recovering from an error, 'ud' points to the error status, which must +** be passed to the first continuation function (otherwise the default +** status is LUA_YIELD). +*/ +static void unroll (lua_State *L, void *ud) { + if (ud != NULL) /* error status? */ + finishCcall(L, *(int *)ud); /* finish 'lua_pcallk' callee */ + while (L->ci != &L->base_ci) { /* something in the stack */ + if (!isLua(L->ci)) /* C function? */ + finishCcall(L, LUA_YIELD); /* complete its execution */ + else { /* Lua function */ + luaV_finishOp(L); /* finish interrupted instruction */ + luaV_execute(L); /* execute down to higher C 'boundary' */ + } + } +} + + +/* +** Try to find a suspended protected call (a "recover point") for the +** given thread. +*/ +static CallInfo *findpcall (lua_State *L) { + CallInfo *ci; + for (ci = L->ci; ci != NULL; ci = ci->previous) { /* search for a pcall */ + if (ci->callstatus & CIST_YPCALL) + return ci; + } + return NULL; /* no pending pcall */ +} + + +/* +** Recovers from an error in a coroutine. Finds a recover point (if +** there is one) and completes the execution of the interrupted +** 'luaD_pcall'. If there is no recover point, returns zero. +*/ +static int recover (lua_State *L, int status) { + StkId oldtop; + CallInfo *ci = findpcall(L); + if (ci == NULL) return 0; /* no recovery point */ + /* "finish" luaD_pcall */ + oldtop = restorestack(L, ci->extra); + luaF_close(L, oldtop); + seterrorobj(L, status, oldtop); + L->ci = ci; + L->allowhook = getoah(ci->callstatus); /* restore original 'allowhook' */ + L->nny = 0; /* should be zero to be yieldable */ + luaD_shrinkstack(L); + L->errfunc = ci->u.c.old_errfunc; + return 1; /* continue running the coroutine */ +} + + +/* +** Signal an error in the call to 'lua_resume', not in the execution +** of the coroutine itself. (Such errors should not be handled by any +** coroutine error handler and should not kill the coroutine.) +*/ +static int resume_error (lua_State *L, const char *msg, int narg) { + L->top -= narg; /* remove args from the stack */ + setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ + api_incr_top(L); + lua_unlock(L); + return LUA_ERRRUN; +} + + +/* +** Do the work for 'lua_resume' in protected mode. Most of the work +** depends on the status of the coroutine: initial state, suspended +** inside a hook, or regularly suspended (optionally with a continuation +** function), plus erroneous cases: non-suspended coroutine or dead +** coroutine. +*/ +static void resume (lua_State *L, void *ud) { + int n = *(cast(int*, ud)); /* number of arguments */ + StkId firstArg = L->top - n; /* first argument */ + CallInfo *ci = L->ci; + if (L->status == LUA_OK) { /* starting a coroutine? */ + if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */ + luaV_execute(L); /* call it */ + } + else { /* resuming from previous yield */ + lua_assert(L->status == LUA_YIELD); + L->status = LUA_OK; /* mark that it is running (again) */ + ci->func = restorestack(L, ci->extra); + if (isLua(ci)) /* yielded inside a hook? */ + luaV_execute(L); /* just continue running Lua code */ + else { /* 'common' yield */ + if (ci->u.c.k != NULL) { /* does it have a continuation function? */ + lua_unlock(L); + n = (*ci->u.c.k)(L, LUA_YIELD, ci->u.c.ctx); /* call continuation */ + lua_lock(L); + api_checknelems(L, n); + firstArg = L->top - n; /* yield results come from continuation */ + } + luaD_poscall(L, ci, firstArg, n); /* finish 'luaD_precall' */ + } + unroll(L, NULL); /* run continuation */ + } +} + + +LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) { + int status; + unsigned short oldnny = L->nny; /* save "number of non-yieldable" calls */ + lua_lock(L); + if (L->status == LUA_OK) { /* may be starting a coroutine */ + if (L->ci != &L->base_ci) /* not in base level? */ + return resume_error(L, "cannot resume non-suspended coroutine", nargs); + } + else if (L->status != LUA_YIELD) + return resume_error(L, "cannot resume dead coroutine", nargs); + L->nCcalls = (from) ? from->nCcalls + 1 : 1; + if (L->nCcalls >= LUAI_MAXCCALLS) + return resume_error(L, "C stack overflow", nargs); + luai_userstateresume(L, nargs); + L->nny = 0; /* allow yields */ + api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); + status = luaD_rawrunprotected(L, resume, &nargs); + if (status == -1) /* error calling 'lua_resume'? */ + status = LUA_ERRRUN; + else { /* continue running after recoverable errors */ + while (errorstatus(status) && recover(L, status)) { + /* unroll continuation */ + status = luaD_rawrunprotected(L, unroll, &status); + } + if (errorstatus(status)) { /* unrecoverable error? */ + L->status = cast_byte(status); /* mark thread as 'dead' */ + seterrorobj(L, status, L->top); /* push error message */ + L->ci->top = L->top; + } + else lua_assert(status == L->status); /* normal end or yield */ + } + L->nny = oldnny; /* restore 'nny' */ + L->nCcalls--; + lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0)); + lua_unlock(L); + return status; +} + + +LUA_API int lua_isyieldable (lua_State *L) { + return (L->nny == 0); +} + + +LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx, + lua_KFunction k) { + CallInfo *ci = L->ci; + luai_userstateyield(L, nresults); + lua_lock(L); + api_checknelems(L, nresults); + if (L->nny > 0) { + if (L != G(L)->mainthread) + luaG_runerror(L, "attempt to yield across a C-call boundary"); + else + luaG_runerror(L, "attempt to yield from outside a coroutine"); + } + L->status = LUA_YIELD; + ci->extra = savestack(L, ci->func); /* save current 'func' */ + if (isLua(ci)) { /* inside a hook? */ + api_check(L, k == NULL, "hooks cannot continue after yielding"); + } + else { + if ((ci->u.c.k = k) != NULL) /* is there a continuation? */ + ci->u.c.ctx = ctx; /* save context */ + ci->func = L->top - nresults - 1; /* protect stack below results */ + luaD_throw(L, LUA_YIELD); + } + lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */ + lua_unlock(L); + return 0; /* return to 'luaD_hook' */ +} + + +int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t old_top, ptrdiff_t ef) { + int status; + CallInfo *old_ci = L->ci; + lu_byte old_allowhooks = L->allowhook; + unsigned short old_nny = L->nny; + ptrdiff_t old_errfunc = L->errfunc; + L->errfunc = ef; + status = luaD_rawrunprotected(L, func, u); + if (status != LUA_OK) { /* an error occurred? */ + StkId oldtop = restorestack(L, old_top); + luaF_close(L, oldtop); /* close possible pending closures */ + seterrorobj(L, status, oldtop); + L->ci = old_ci; + L->allowhook = old_allowhooks; + L->nny = old_nny; + luaD_shrinkstack(L); + } + L->errfunc = old_errfunc; + return status; +} + + + +/* +** Execute a protected parser. +*/ +struct SParser { /* data to 'f_parser' */ + ZIO *z; + Mbuffer buff; /* dynamic structure used by the scanner */ + Dyndata dyd; /* dynamic structures used by the parser */ + const char *mode; + const char *name; +}; + + +static void checkmode (lua_State *L, const char *mode, const char *x) { + if (mode && strchr(mode, x[0]) == NULL) { + luaO_pushfstring(L, + "attempt to load a %s chunk (mode is '%s')", x, mode); + luaD_throw(L, LUA_ERRSYNTAX); + } +} + + +static void f_parser (lua_State *L, void *ud) { + LClosure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = zgetc(p->z); /* read first character */ + if (c == LUA_SIGNATURE[0]) { + checkmode(L, p->mode, "binary"); + cl = luaU_undump(L, p->z, p->name); + } + else { + checkmode(L, p->mode, "text"); + cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); + } + lua_assert(cl->nupvalues == cl->p->sizeupvalues); + luaF_initupvals(L, cl); +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, + const char *mode) { + struct SParser p; + int status; + L->nny++; /* cannot yield during parsing */ + p.z = z; p.name = name; p.mode = mode; + p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0; + p.dyd.gt.arr = NULL; p.dyd.gt.size = 0; + p.dyd.label.arr = NULL; p.dyd.label.size = 0; + luaZ_initbuffer(L, &p.buff); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + luaZ_freebuffer(L, &p.buff); + luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size); + luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size); + luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size); + L->nny--; + return status; +} + + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ldo.h b/dep/scintilla/scintilla-3.10.6/lua/src/ldo.h new file mode 100644 index 00000000..4f5d51c3 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ldo.h @@ -0,0 +1,58 @@ +/* +** $Id: ldo.h,v 2.29 2015/12/21 13:02:14 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +/* +** Macro to check stack size and grow stack if needed. Parameters +** 'pre'/'pos' allow the macro to preserve a pointer into the +** stack across reallocations, doing the work only when needed. +** 'condmovestack' is used in heavy tests to force a stack reallocation +** at every check. +*/ +#define luaD_checkstackaux(L,n,pre,pos) \ + if (L->stack_last - L->top <= (n)) \ + { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } + +/* In general, 'pre'/'pos' are empty (nothing to save) */ +#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) + + + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + + +/* type of protected functions, to be ran by 'runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, + const char *mode); +LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, + int nres); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); +LUAI_FUNC void luaD_shrinkstack (lua_State *L); +LUAI_FUNC void luaD_inctop (lua_State *L); + +LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ldump.c b/dep/scintilla/scintilla-3.10.6/lua/src/ldump.c new file mode 100644 index 00000000..016e3008 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ldump.c @@ -0,0 +1,215 @@ +/* +** $Id: ldump.c,v 2.37 2015/10/08 15:53:49 roberto Exp $ +** save precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#define ldump_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lundump.h" + + +typedef struct { + lua_State *L; + lua_Writer writer; + void *data; + int strip; + int status; +} DumpState; + + +/* +** All high-level dumps go through DumpVector; you can change it to +** change the endianness of the result +*/ +#define DumpVector(v,n,D) DumpBlock(v,(n)*sizeof((v)[0]),D) + +#define DumpLiteral(s,D) DumpBlock(s, sizeof(s) - sizeof(char), D) + + +static void DumpBlock (const void *b, size_t size, DumpState *D) { + if (D->status == 0 && size > 0) { + lua_unlock(D->L); + D->status = (*D->writer)(D->L, b, size, D->data); + lua_lock(D->L); + } +} + + +#define DumpVar(x,D) DumpVector(&x,1,D) + + +static void DumpByte (int y, DumpState *D) { + lu_byte x = (lu_byte)y; + DumpVar(x, D); +} + + +static void DumpInt (int x, DumpState *D) { + DumpVar(x, D); +} + + +static void DumpNumber (lua_Number x, DumpState *D) { + DumpVar(x, D); +} + + +static void DumpInteger (lua_Integer x, DumpState *D) { + DumpVar(x, D); +} + + +static void DumpString (const TString *s, DumpState *D) { + if (s == NULL) + DumpByte(0, D); + else { + size_t size = tsslen(s) + 1; /* include trailing '\0' */ + const char *str = getstr(s); + if (size < 0xFF) + DumpByte(cast_int(size), D); + else { + DumpByte(0xFF, D); + DumpVar(size, D); + } + DumpVector(str, size - 1, D); /* no need to save '\0' */ + } +} + + +static void DumpCode (const Proto *f, DumpState *D) { + DumpInt(f->sizecode, D); + DumpVector(f->code, f->sizecode, D); +} + + +static void DumpFunction(const Proto *f, TString *psource, DumpState *D); + +static void DumpConstants (const Proto *f, DumpState *D) { + int i; + int n = f->sizek; + DumpInt(n, D); + for (i = 0; i < n; i++) { + const TValue *o = &f->k[i]; + DumpByte(ttype(o), D); + switch (ttype(o)) { + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + DumpByte(bvalue(o), D); + break; + case LUA_TNUMFLT: + DumpNumber(fltvalue(o), D); + break; + case LUA_TNUMINT: + DumpInteger(ivalue(o), D); + break; + case LUA_TSHRSTR: + case LUA_TLNGSTR: + DumpString(tsvalue(o), D); + break; + default: + lua_assert(0); + } + } +} + + +static void DumpProtos (const Proto *f, DumpState *D) { + int i; + int n = f->sizep; + DumpInt(n, D); + for (i = 0; i < n; i++) + DumpFunction(f->p[i], f->source, D); +} + + +static void DumpUpvalues (const Proto *f, DumpState *D) { + int i, n = f->sizeupvalues; + DumpInt(n, D); + for (i = 0; i < n; i++) { + DumpByte(f->upvalues[i].instack, D); + DumpByte(f->upvalues[i].idx, D); + } +} + + +static void DumpDebug (const Proto *f, DumpState *D) { + int i, n; + n = (D->strip) ? 0 : f->sizelineinfo; + DumpInt(n, D); + DumpVector(f->lineinfo, n, D); + n = (D->strip) ? 0 : f->sizelocvars; + DumpInt(n, D); + for (i = 0; i < n; i++) { + DumpString(f->locvars[i].varname, D); + DumpInt(f->locvars[i].startpc, D); + DumpInt(f->locvars[i].endpc, D); + } + n = (D->strip) ? 0 : f->sizeupvalues; + DumpInt(n, D); + for (i = 0; i < n; i++) + DumpString(f->upvalues[i].name, D); +} + + +static void DumpFunction (const Proto *f, TString *psource, DumpState *D) { + if (D->strip || f->source == psource) + DumpString(NULL, D); /* no debug info or same source as its parent */ + else + DumpString(f->source, D); + DumpInt(f->linedefined, D); + DumpInt(f->lastlinedefined, D); + DumpByte(f->numparams, D); + DumpByte(f->is_vararg, D); + DumpByte(f->maxstacksize, D); + DumpCode(f, D); + DumpConstants(f, D); + DumpUpvalues(f, D); + DumpProtos(f, D); + DumpDebug(f, D); +} + + +static void DumpHeader (DumpState *D) { + DumpLiteral(LUA_SIGNATURE, D); + DumpByte(LUAC_VERSION, D); + DumpByte(LUAC_FORMAT, D); + DumpLiteral(LUAC_DATA, D); + DumpByte(sizeof(int), D); + DumpByte(sizeof(size_t), D); + DumpByte(sizeof(Instruction), D); + DumpByte(sizeof(lua_Integer), D); + DumpByte(sizeof(lua_Number), D); + DumpInteger(LUAC_INT, D); + DumpNumber(LUAC_NUM, D); +} + + +/* +** dump Lua function as precompiled chunk +*/ +int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data, + int strip) { + DumpState D; + D.L = L; + D.writer = w; + D.data = data; + D.strip = strip; + D.status = 0; + DumpHeader(&D); + DumpByte(f->sizeupvalues, &D); + DumpFunction(f, NULL, &D); + return D.status; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lfunc.c b/dep/scintilla/scintilla-3.10.6/lua/src/lfunc.c new file mode 100644 index 00000000..67967dab --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lfunc.c @@ -0,0 +1,151 @@ +/* +** $Id: lfunc.c,v 2.45 2014/11/02 19:19:04 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#define lfunc_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +CClosure *luaF_newCclosure (lua_State *L, int n) { + GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n)); + CClosure *c = gco2ccl(o); + c->nupvalues = cast_byte(n); + return c; +} + + +LClosure *luaF_newLclosure (lua_State *L, int n) { + GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n)); + LClosure *c = gco2lcl(o); + c->p = NULL; + c->nupvalues = cast_byte(n); + while (n--) c->upvals[n] = NULL; + return c; +} + +/* +** fill a closure with new closed upvalues +*/ +void luaF_initupvals (lua_State *L, LClosure *cl) { + int i; + for (i = 0; i < cl->nupvalues; i++) { + UpVal *uv = luaM_new(L, UpVal); + uv->refcount = 1; + uv->v = &uv->u.value; /* make it closed */ + setnilvalue(uv->v); + cl->upvals[i] = uv; + } +} + + +UpVal *luaF_findupval (lua_State *L, StkId level) { + UpVal **pp = &L->openupval; + UpVal *p; + UpVal *uv; + lua_assert(isintwups(L) || L->openupval == NULL); + while (*pp != NULL && (p = *pp)->v >= level) { + lua_assert(upisopen(p)); + if (p->v == level) /* found a corresponding upvalue? */ + return p; /* return it */ + pp = &p->u.open.next; + } + /* not found: create a new upvalue */ + uv = luaM_new(L, UpVal); + uv->refcount = 0; + uv->u.open.next = *pp; /* link it to list of open upvalues */ + uv->u.open.touched = 1; + *pp = uv; + uv->v = level; /* current value lives in the stack */ + if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ + L->twups = G(L)->twups; /* link it to the list */ + G(L)->twups = L; + } + return uv; +} + + +void luaF_close (lua_State *L, StkId level) { + UpVal *uv; + while (L->openupval != NULL && (uv = L->openupval)->v >= level) { + lua_assert(upisopen(uv)); + L->openupval = uv->u.open.next; /* remove from 'open' list */ + if (uv->refcount == 0) /* no references? */ + luaM_free(L, uv); /* free upvalue */ + else { + setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */ + uv->v = &uv->u.value; /* now current value lives here */ + luaC_upvalbarrier(L, uv); + } + } +} + + +Proto *luaF_newproto (lua_State *L) { + GCObject *o = luaC_newobj(L, LUA_TPROTO, sizeof(Proto)); + Proto *f = gco2p(o); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->cache = NULL; + f->sizecode = 0; + f->lineinfo = NULL; + f->sizelineinfo = 0; + f->upvalues = NULL; + f->sizeupvalues = 0; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->locvars = NULL; + f->sizelocvars = 0; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + + +void luaF_freeproto (lua_State *L, Proto *f) { + luaM_freearray(L, f->code, f->sizecode); + luaM_freearray(L, f->p, f->sizep); + luaM_freearray(L, f->k, f->sizek); + luaM_freearray(L, f->lineinfo, f->sizelineinfo); + luaM_freearray(L, f->locvars, f->sizelocvars); + luaM_freearray(L, f->upvalues, f->sizeupvalues); + luaM_free(L, f); +} + + +/* +** Look for n-th local variable at line 'line' in function 'func'. +** Returns NULL if not found. +*/ +const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { + int i; + for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { + if (pc < f->locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return getstr(f->locvars[i].varname); + } + } + return NULL; /* not found */ +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lfunc.h b/dep/scintilla/scintilla-3.10.6/lua/src/lfunc.h new file mode 100644 index 00000000..2eeb0d5a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lfunc.h @@ -0,0 +1,61 @@ +/* +** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +/* test whether thread is in 'twups' list */ +#define isintwups(L) (L->twups != L) + + +/* +** maximum number of upvalues in a closure (both C and Lua). (Value +** must fit in a VM register.) +*/ +#define MAXUPVAL 255 + + +/* +** Upvalues for Lua closures +*/ +struct UpVal { + TValue *v; /* points to stack or to its own value */ + lu_mem refcount; /* reference counter */ + union { + struct { /* (when open) */ + UpVal *next; /* linked list */ + int touched; /* mark to avoid cycles with dead threads */ + } open; + TValue value; /* the value (when closed) */ + } u; +}; + +#define upisopen(up) ((up)->v != &(up)->u.value) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); +LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); +LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lgc.c b/dep/scintilla/scintilla-3.10.6/lua/src/lgc.c new file mode 100644 index 00000000..ba2c19e1 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lgc.c @@ -0,0 +1,1178 @@ +/* +** $Id: lgc.c,v 2.215 2016/12/22 13:08:50 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#define lgc_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +/* +** internal state for collector while inside the atomic phase. The +** collector should never be in this state while running regular code. +*/ +#define GCSinsideatomic (GCSpause + 1) + +/* +** cost of sweeping one element (the size of a small object divided +** by some adjust for the sweep speed) +*/ +#define GCSWEEPCOST ((sizeof(TString) + 4) / 4) + +/* maximum number of elements to sweep in each single step */ +#define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4)) + +/* cost of calling one finalizer */ +#define GCFINALIZECOST GCSWEEPCOST + + +/* +** macro to adjust 'stepmul': 'stepmul' is actually used like +** 'stepmul / STEPMULADJ' (value chosen by tests) +*/ +#define STEPMULADJ 200 + + +/* +** macro to adjust 'pause': 'pause' is actually used like +** 'pause / PAUSEADJ' (value chosen by tests) +*/ +#define PAUSEADJ 100 + + +/* +** 'makewhite' erases all color bits then sets only the current white +** bit +*/ +#define maskcolors (~(bitmask(BLACKBIT) | WHITEBITS)) +#define makewhite(g,x) \ + (x->marked = cast_byte((x->marked & maskcolors) | luaC_white(g))) + +#define white2gray(x) resetbits(x->marked, WHITEBITS) +#define black2gray(x) resetbit(x->marked, BLACKBIT) + + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n))) + + +#define checkconsistency(obj) \ + lua_longassert(!iscollectable(obj) || righttt(obj)) + + +#define markvalue(g,o) { checkconsistency(o); \ + if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); } + +#define markobject(g,t) { if (iswhite(t)) reallymarkobject(g, obj2gco(t)); } + +/* +** mark an object that can be NULL (either because it is really optional, +** or it was stripped as debug info, or inside an uncompleted structure) +*/ +#define markobjectN(g,t) { if (t) markobject(g,t); } + +static void reallymarkobject (global_State *g, GCObject *o); + + +/* +** {====================================================== +** Generic functions +** ======================================================= +*/ + + +/* +** one after last element in a hash array +*/ +#define gnodelast(h) gnode(h, cast(size_t, sizenode(h))) + + +/* +** link collectable object 'o' into list pointed by 'p' +*/ +#define linkgclist(o,p) ((o)->gclist = (p), (p) = obj2gco(o)) + + +/* +** If key is not marked, mark its entry as dead. This allows key to be +** collected, but keeps its entry in the table. A dead node is needed +** when Lua looks up for a key (it may be part of a chain) and when +** traversing a weak table (key might be removed from the table during +** traversal). Other places never manipulate dead keys, because its +** associated nil value is enough to signal that the entry is logically +** empty. +*/ +static void removeentry (Node *n) { + lua_assert(ttisnil(gval(n))); + if (valiswhite(gkey(n))) + setdeadvalue(wgkey(n)); /* unused and unmarked key; remove it */ +} + + +/* +** tells whether a key or value can be cleared from a weak +** table. Non-collectable objects are never removed from weak +** tables. Strings behave as 'values', so are never removed too. for +** other objects: if really collected, cannot keep them; for objects +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (global_State *g, const TValue *o) { + if (!iscollectable(o)) return 0; + else if (ttisstring(o)) { + markobject(g, tsvalue(o)); /* strings are 'values', so are never weak */ + return 0; + } + else return iswhite(gcvalue(o)); +} + + +/* +** barrier that moves collector forward, that is, mark the white object +** being pointed by a black object. (If in sweep phase, clear the black +** object to white [sweep it] to avoid other barrier calls for this +** same object.) +*/ +void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + if (keepinvariant(g)) /* must keep invariant? */ + reallymarkobject(g, v); /* restore invariant */ + else { /* sweep phase */ + lua_assert(issweepphase(g)); + makewhite(g, o); /* mark main obj. as white to avoid other barriers */ + } +} + + +/* +** barrier that moves collector backward, that is, mark the black object +** pointing to a white object as gray again. +*/ +void luaC_barrierback_ (lua_State *L, Table *t) { + global_State *g = G(L); + lua_assert(isblack(t) && !isdead(g, t)); + black2gray(t); /* make table gray (again) */ + linkgclist(t, g->grayagain); +} + + +/* +** barrier for assignments to closed upvalues. Because upvalues are +** shared among closures, it is impossible to know the color of all +** closures pointing to it. So, we assume that the object being assigned +** must be marked. +*/ +void luaC_upvalbarrier_ (lua_State *L, UpVal *uv) { + global_State *g = G(L); + GCObject *o = gcvalue(uv->v); + lua_assert(!upisopen(uv)); /* ensured by macro luaC_upvalbarrier */ + if (keepinvariant(g)) + markobject(g, o); +} + + +void luaC_fix (lua_State *L, GCObject *o) { + global_State *g = G(L); + lua_assert(g->allgc == o); /* object must be 1st in 'allgc' list! */ + white2gray(o); /* they will be gray forever */ + g->allgc = o->next; /* remove object from 'allgc' list */ + o->next = g->fixedgc; /* link it to 'fixedgc' list */ + g->fixedgc = o; +} + + +/* +** create a new collectable object (with given type and size) and link +** it to 'allgc' list. +*/ +GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { + global_State *g = G(L); + GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz)); + o->marked = luaC_white(g); + o->tt = tt; + o->next = g->allgc; + g->allgc = o; + return o; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** Mark functions +** ======================================================= +*/ + + +/* +** mark an object. Userdata, strings, and closed upvalues are visited +** and turned black here. Other objects are marked gray and added +** to appropriate list to be visited (and turned black) later. (Open +** upvalues are already linked in 'headuv' list.) +*/ +static void reallymarkobject (global_State *g, GCObject *o) { + reentry: + white2gray(o); + switch (o->tt) { + case LUA_TSHRSTR: { + gray2black(o); + g->GCmemtrav += sizelstring(gco2ts(o)->shrlen); + break; + } + case LUA_TLNGSTR: { + gray2black(o); + g->GCmemtrav += sizelstring(gco2ts(o)->u.lnglen); + break; + } + case LUA_TUSERDATA: { + TValue uvalue; + markobjectN(g, gco2u(o)->metatable); /* mark its metatable */ + gray2black(o); + g->GCmemtrav += sizeudata(gco2u(o)); + getuservalue(g->mainthread, gco2u(o), &uvalue); + if (valiswhite(&uvalue)) { /* markvalue(g, &uvalue); */ + o = gcvalue(&uvalue); + goto reentry; + } + break; + } + case LUA_TLCL: { + linkgclist(gco2lcl(o), g->gray); + break; + } + case LUA_TCCL: { + linkgclist(gco2ccl(o), g->gray); + break; + } + case LUA_TTABLE: { + linkgclist(gco2t(o), g->gray); + break; + } + case LUA_TTHREAD: { + linkgclist(gco2th(o), g->gray); + break; + } + case LUA_TPROTO: { + linkgclist(gco2p(o), g->gray); + break; + } + default: lua_assert(0); break; + } +} + + +/* +** mark metamethods for basic types +*/ +static void markmt (global_State *g) { + int i; + for (i=0; i < LUA_NUMTAGS; i++) + markobjectN(g, g->mt[i]); +} + + +/* +** mark all objects in list of being-finalized +*/ +static void markbeingfnz (global_State *g) { + GCObject *o; + for (o = g->tobefnz; o != NULL; o = o->next) + markobject(g, o); +} + + +/* +** Mark all values stored in marked open upvalues from non-marked threads. +** (Values from marked threads were already marked when traversing the +** thread.) Remove from the list threads that no longer have upvalues and +** not-marked threads. +*/ +static void remarkupvals (global_State *g) { + lua_State *thread; + lua_State **p = &g->twups; + while ((thread = *p) != NULL) { + lua_assert(!isblack(thread)); /* threads are never black */ + if (isgray(thread) && thread->openupval != NULL) + p = &thread->twups; /* keep marked thread with upvalues in the list */ + else { /* thread is not marked or without upvalues */ + UpVal *uv; + *p = thread->twups; /* remove thread from the list */ + thread->twups = thread; /* mark that it is out of list */ + for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) { + if (uv->u.open.touched) { + markvalue(g, uv->v); /* remark upvalue's value */ + uv->u.open.touched = 0; + } + } + } + } +} + + +/* +** mark root set and reset all gray lists, to start a new collection +*/ +static void restartcollection (global_State *g) { + g->gray = g->grayagain = NULL; + g->weak = g->allweak = g->ephemeron = NULL; + markobject(g, g->mainthread); + markvalue(g, &g->l_registry); + markmt(g); + markbeingfnz(g); /* mark any finalizing object left from previous cycle */ +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Traverse functions +** ======================================================= +*/ + +/* +** Traverse a table with weak values and link it to proper list. During +** propagate phase, keep it in 'grayagain' list, to be revisited in the +** atomic phase. In the atomic phase, if table has any white value, +** put it in 'weak' list, to be cleared. +*/ +static void traverseweakvalue (global_State *g, Table *h) { + Node *n, *limit = gnodelast(h); + /* if there is array part, assume it may have white values (it is not + worth traversing it now just to check) */ + int hasclears = (h->sizearray > 0); + for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */ + checkdeadkey(n); + if (ttisnil(gval(n))) /* entry is empty? */ + removeentry(n); /* remove it */ + else { + lua_assert(!ttisnil(gkey(n))); + markvalue(g, gkey(n)); /* mark key */ + if (!hasclears && iscleared(g, gval(n))) /* is there a white value? */ + hasclears = 1; /* table will have to be cleared */ + } + } + if (g->gcstate == GCSpropagate) + linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */ + else if (hasclears) + linkgclist(h, g->weak); /* has to be cleared later */ +} + + +/* +** Traverse an ephemeron table and link it to proper list. Returns true +** iff any object was marked during this traversal (which implies that +** convergence has to continue). During propagation phase, keep table +** in 'grayagain' list, to be visited again in the atomic phase. In +** the atomic phase, if table has any white->white entry, it has to +** be revisited during ephemeron convergence (as that key may turn +** black). Otherwise, if it has any white key, table has to be cleared +** (in the atomic phase). +*/ +static int traverseephemeron (global_State *g, Table *h) { + int marked = 0; /* true if an object is marked in this traversal */ + int hasclears = 0; /* true if table has white keys */ + int hasww = 0; /* true if table has entry "white-key -> white-value" */ + Node *n, *limit = gnodelast(h); + unsigned int i; + /* traverse array part */ + for (i = 0; i < h->sizearray; i++) { + if (valiswhite(&h->array[i])) { + marked = 1; + reallymarkobject(g, gcvalue(&h->array[i])); + } + } + /* traverse hash part */ + for (n = gnode(h, 0); n < limit; n++) { + checkdeadkey(n); + if (ttisnil(gval(n))) /* entry is empty? */ + removeentry(n); /* remove it */ + else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */ + hasclears = 1; /* table must be cleared */ + if (valiswhite(gval(n))) /* value not marked yet? */ + hasww = 1; /* white-white entry */ + } + else if (valiswhite(gval(n))) { /* value not marked yet? */ + marked = 1; + reallymarkobject(g, gcvalue(gval(n))); /* mark it now */ + } + } + /* link table into proper list */ + if (g->gcstate == GCSpropagate) + linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */ + else if (hasww) /* table has white->white entries? */ + linkgclist(h, g->ephemeron); /* have to propagate again */ + else if (hasclears) /* table has white keys? */ + linkgclist(h, g->allweak); /* may have to clean white keys */ + return marked; +} + + +static void traversestrongtable (global_State *g, Table *h) { + Node *n, *limit = gnodelast(h); + unsigned int i; + for (i = 0; i < h->sizearray; i++) /* traverse array part */ + markvalue(g, &h->array[i]); + for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */ + checkdeadkey(n); + if (ttisnil(gval(n))) /* entry is empty? */ + removeentry(n); /* remove it */ + else { + lua_assert(!ttisnil(gkey(n))); + markvalue(g, gkey(n)); /* mark key */ + markvalue(g, gval(n)); /* mark value */ + } + } +} + + +static lu_mem traversetable (global_State *g, Table *h) { + const char *weakkey, *weakvalue; + const TValue *mode = gfasttm(g, h->metatable, TM_MODE); + markobjectN(g, h->metatable); + if (mode && ttisstring(mode) && /* is there a weak mode? */ + ((weakkey = strchr(svalue(mode), 'k')), + (weakvalue = strchr(svalue(mode), 'v')), + (weakkey || weakvalue))) { /* is really weak? */ + black2gray(h); /* keep table gray */ + if (!weakkey) /* strong keys? */ + traverseweakvalue(g, h); + else if (!weakvalue) /* strong values? */ + traverseephemeron(g, h); + else /* all weak */ + linkgclist(h, g->allweak); /* nothing to traverse now */ + } + else /* not weak */ + traversestrongtable(g, h); + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * cast(size_t, allocsizenode(h)); +} + + +/* +** Traverse a prototype. (While a prototype is being build, its +** arrays can be larger than needed; the extra slots are filled with +** NULL, so the use of 'markobjectN') +*/ +static int traverseproto (global_State *g, Proto *f) { + int i; + if (f->cache && iswhite(f->cache)) + f->cache = NULL; /* allow cache to be collected */ + markobjectN(g, f->source); + for (i = 0; i < f->sizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */ + markobjectN(g, f->upvalues[i].name); + for (i = 0; i < f->sizep; i++) /* mark nested protos */ + markobjectN(g, f->p[i]); + for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */ + markobjectN(g, f->locvars[i].varname); + return sizeof(Proto) + sizeof(Instruction) * f->sizecode + + sizeof(Proto *) * f->sizep + + sizeof(TValue) * f->sizek + + sizeof(int) * f->sizelineinfo + + sizeof(LocVar) * f->sizelocvars + + sizeof(Upvaldesc) * f->sizeupvalues; +} + + +static lu_mem traverseCclosure (global_State *g, CClosure *cl) { + int i; + for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->upvalue[i]); + return sizeCclosure(cl->nupvalues); +} + +/* +** open upvalues point to values in a thread, so those values should +** be marked when the thread is traversed except in the atomic phase +** (because then the value cannot be changed by the thread and the +** thread may not be traversed again) +*/ +static lu_mem traverseLclosure (global_State *g, LClosure *cl) { + int i; + markobjectN(g, cl->p); /* mark its prototype */ + for (i = 0; i < cl->nupvalues; i++) { /* mark its upvalues */ + UpVal *uv = cl->upvals[i]; + if (uv != NULL) { + if (upisopen(uv) && g->gcstate != GCSinsideatomic) + uv->u.open.touched = 1; /* can be marked in 'remarkupvals' */ + else + markvalue(g, uv->v); + } + } + return sizeLclosure(cl->nupvalues); +} + + +static lu_mem traversethread (global_State *g, lua_State *th) { + StkId o = th->stack; + if (o == NULL) + return 1; /* stack not completely built yet */ + lua_assert(g->gcstate == GCSinsideatomic || + th->openupval == NULL || isintwups(th)); + for (; o < th->top; o++) /* mark live elements in the stack */ + markvalue(g, o); + if (g->gcstate == GCSinsideatomic) { /* final traversal? */ + StkId lim = th->stack + th->stacksize; /* real end of stack */ + for (; o < lim; o++) /* clear not-marked stack slice */ + setnilvalue(o); + /* 'remarkupvals' may have removed thread from 'twups' list */ + if (!isintwups(th) && th->openupval != NULL) { + th->twups = g->twups; /* link it back to the list */ + g->twups = th; + } + } + else if (g->gckind != KGC_EMERGENCY) + luaD_shrinkstack(th); /* do not change stack in emergency cycle */ + return (sizeof(lua_State) + sizeof(TValue) * th->stacksize + + sizeof(CallInfo) * th->nci); +} + + +/* +** traverse one gray object, turning it to black (except for threads, +** which are always gray). +*/ +static void propagatemark (global_State *g) { + lu_mem size; + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (o->tt) { + case LUA_TTABLE: { + Table *h = gco2t(o); + g->gray = h->gclist; /* remove from 'gray' list */ + size = traversetable(g, h); + break; + } + case LUA_TLCL: { + LClosure *cl = gco2lcl(o); + g->gray = cl->gclist; /* remove from 'gray' list */ + size = traverseLclosure(g, cl); + break; + } + case LUA_TCCL: { + CClosure *cl = gco2ccl(o); + g->gray = cl->gclist; /* remove from 'gray' list */ + size = traverseCclosure(g, cl); + break; + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; /* remove from 'gray' list */ + linkgclist(th, g->grayagain); /* insert into 'grayagain' list */ + black2gray(o); + size = traversethread(g, th); + break; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; /* remove from 'gray' list */ + size = traverseproto(g, p); + break; + } + default: lua_assert(0); return; + } + g->GCmemtrav += size; +} + + +static void propagateall (global_State *g) { + while (g->gray) propagatemark(g); +} + + +static void convergeephemerons (global_State *g) { + int changed; + do { + GCObject *w; + GCObject *next = g->ephemeron; /* get ephemeron list */ + g->ephemeron = NULL; /* tables may return to this list when traversed */ + changed = 0; + while ((w = next) != NULL) { + next = gco2t(w)->gclist; + if (traverseephemeron(g, gco2t(w))) { /* traverse marked some value? */ + propagateall(g); /* propagate changes */ + changed = 1; /* will have to revisit all ephemeron tables */ + } + } + } while (changed); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Sweep Functions +** ======================================================= +*/ + + +/* +** clear entries with unmarked keys from all weaktables in list 'l' up +** to element 'f' +*/ +static void clearkeys (global_State *g, GCObject *l, GCObject *f) { + for (; l != f; l = gco2t(l)->gclist) { + Table *h = gco2t(l); + Node *n, *limit = gnodelast(h); + for (n = gnode(h, 0); n < limit; n++) { + if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* and remove entry from table */ + } + } + } +} + + +/* +** clear entries with unmarked values from all weaktables in list 'l' up +** to element 'f' +*/ +static void clearvalues (global_State *g, GCObject *l, GCObject *f) { + for (; l != f; l = gco2t(l)->gclist) { + Table *h = gco2t(l); + Node *n, *limit = gnodelast(h); + unsigned int i; + for (i = 0; i < h->sizearray; i++) { + TValue *o = &h->array[i]; + if (iscleared(g, o)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + for (n = gnode(h, 0); n < limit; n++) { + if (!ttisnil(gval(n)) && iscleared(g, gval(n))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* and remove entry from table */ + } + } + } +} + + +void luaC_upvdeccount (lua_State *L, UpVal *uv) { + lua_assert(uv->refcount > 0); + uv->refcount--; + if (uv->refcount == 0 && !upisopen(uv)) + luaM_free(L, uv); +} + + +static void freeLclosure (lua_State *L, LClosure *cl) { + int i; + for (i = 0; i < cl->nupvalues; i++) { + UpVal *uv = cl->upvals[i]; + if (uv) + luaC_upvdeccount(L, uv); + } + luaM_freemem(L, cl, sizeLclosure(cl->nupvalues)); +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (o->tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TLCL: { + freeLclosure(L, gco2lcl(o)); + break; + } + case LUA_TCCL: { + luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues)); + break; + } + case LUA_TTABLE: luaH_free(L, gco2t(o)); break; + case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break; + case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; + case LUA_TSHRSTR: + luaS_remove(L, gco2ts(o)); /* remove it from hash table */ + luaM_freemem(L, o, sizelstring(gco2ts(o)->shrlen)); + break; + case LUA_TLNGSTR: { + luaM_freemem(L, o, sizelstring(gco2ts(o)->u.lnglen)); + break; + } + default: lua_assert(0); + } +} + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count); + + +/* +** sweep at most 'count' elements from a list of GCObjects erasing dead +** objects, where a dead object is one marked with the old (non current) +** white; change all non-dead objects back to white, preparing for next +** collection cycle. Return where to continue the traversal or NULL if +** list is finished. +*/ +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + global_State *g = G(L); + int ow = otherwhite(g); + int white = luaC_white(g); /* current white */ + while (*p != NULL && count-- > 0) { + GCObject *curr = *p; + int marked = curr->marked; + if (isdeadm(ow, marked)) { /* is 'curr' dead? */ + *p = curr->next; /* remove 'curr' from list */ + freeobj(L, curr); /* erase 'curr' */ + } + else { /* change mark to 'white' */ + curr->marked = cast_byte((marked & maskcolors) | white); + p = &curr->next; /* go to next element */ + } + } + return (*p == NULL) ? NULL : p; +} + + +/* +** sweep a list until a live object (or end of list) +*/ +static GCObject **sweeptolive (lua_State *L, GCObject **p) { + GCObject **old = p; + do { + p = sweeplist(L, p, 1); + } while (p == old); + return p; +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Finalization +** ======================================================= +*/ + +/* +** If possible, shrink string table +*/ +static void checkSizes (lua_State *L, global_State *g) { + if (g->gckind != KGC_EMERGENCY) { + l_mem olddebt = g->GCdebt; + if (g->strt.nuse < g->strt.size / 4) /* string table too big? */ + luaS_resize(L, g->strt.size / 2); /* shrink it a little */ + g->GCestimate += g->GCdebt - olddebt; /* update estimate */ + } +} + + +static GCObject *udata2finalize (global_State *g) { + GCObject *o = g->tobefnz; /* get first element */ + lua_assert(tofinalize(o)); + g->tobefnz = o->next; /* remove it from 'tobefnz' list */ + o->next = g->allgc; /* return it to 'allgc' list */ + g->allgc = o; + resetbit(o->marked, FINALIZEDBIT); /* object is "normal" again */ + if (issweepphase(g)) + makewhite(g, o); /* "sweep" object */ + return o; +} + + +static void dothecall (lua_State *L, void *ud) { + UNUSED(ud); + luaD_callnoyield(L, L->top - 2, 0); +} + + +static void GCTM (lua_State *L, int propagateerrors) { + global_State *g = G(L); + const TValue *tm; + TValue v; + setgcovalue(L, &v, udata2finalize(g)); + tm = luaT_gettmbyobj(L, &v, TM_GC); + if (tm != NULL && ttisfunction(tm)) { /* is there a finalizer? */ + int status; + lu_byte oldah = L->allowhook; + int running = g->gcrunning; + L->allowhook = 0; /* stop debug hooks during GC metamethod */ + g->gcrunning = 0; /* avoid GC steps */ + setobj2s(L, L->top, tm); /* push finalizer... */ + setobj2s(L, L->top + 1, &v); /* ... and its argument */ + L->top += 2; /* and (next line) call the finalizer */ + L->ci->callstatus |= CIST_FIN; /* will run a finalizer */ + status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); + L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */ + L->allowhook = oldah; /* restore hooks */ + g->gcrunning = running; /* restore state */ + if (status != LUA_OK && propagateerrors) { /* error while running __gc? */ + if (status == LUA_ERRRUN) { /* is there an error object? */ + const char *msg = (ttisstring(L->top - 1)) + ? svalue(L->top - 1) + : "no message"; + luaO_pushfstring(L, "error in __gc metamethod (%s)", msg); + status = LUA_ERRGCMM; /* error in __gc metamethod */ + } + luaD_throw(L, status); /* re-throw error */ + } + } +} + + +/* +** call a few (up to 'g->gcfinnum') finalizers +*/ +static int runafewfinalizers (lua_State *L) { + global_State *g = G(L); + unsigned int i; + lua_assert(!g->tobefnz || g->gcfinnum > 0); + for (i = 0; g->tobefnz && i < g->gcfinnum; i++) + GCTM(L, 1); /* call one finalizer */ + g->gcfinnum = (!g->tobefnz) ? 0 /* nothing more to finalize? */ + : g->gcfinnum * 2; /* else call a few more next time */ + return i; +} + + +/* +** call all pending finalizers +*/ +static void callallpendingfinalizers (lua_State *L) { + global_State *g = G(L); + while (g->tobefnz) + GCTM(L, 0); +} + + +/* +** find last 'next' field in list 'p' list (to add elements in its end) +*/ +static GCObject **findlast (GCObject **p) { + while (*p != NULL) + p = &(*p)->next; + return p; +} + + +/* +** move all unreachable objects (or 'all' objects) that need +** finalization from list 'finobj' to list 'tobefnz' (to be finalized) +*/ +static void separatetobefnz (global_State *g, int all) { + GCObject *curr; + GCObject **p = &g->finobj; + GCObject **lastnext = findlast(&g->tobefnz); + while ((curr = *p) != NULL) { /* traverse all finalizable objects */ + lua_assert(tofinalize(curr)); + if (!(iswhite(curr) || all)) /* not being collected? */ + p = &curr->next; /* don't bother with it */ + else { + *p = curr->next; /* remove 'curr' from 'finobj' list */ + curr->next = *lastnext; /* link at the end of 'tobefnz' list */ + *lastnext = curr; + lastnext = &curr->next; + } + } +} + + +/* +** if object 'o' has a finalizer, remove it from 'allgc' list (must +** search the list to find it) and link it in 'finobj' list. +*/ +void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { + global_State *g = G(L); + if (tofinalize(o) || /* obj. is already marked... */ + gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */ + return; /* nothing to be done */ + else { /* move 'o' to 'finobj' list */ + GCObject **p; + if (issweepphase(g)) { + makewhite(g, o); /* "sweep" object 'o' */ + if (g->sweepgc == &o->next) /* should not remove 'sweepgc' object */ + g->sweepgc = sweeptolive(L, g->sweepgc); /* change 'sweepgc' */ + } + /* search for pointer pointing to 'o' */ + for (p = &g->allgc; *p != o; p = &(*p)->next) { /* empty */ } + *p = o->next; /* remove 'o' from 'allgc' list */ + o->next = g->finobj; /* link it in 'finobj' list */ + g->finobj = o; + l_setbit(o->marked, FINALIZEDBIT); /* mark it as such */ + } +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** GC control +** ======================================================= +*/ + + +/* +** Set a reasonable "time" to wait before starting a new GC cycle; cycle +** will start when memory use hits threshold. (Division by 'estimate' +** should be OK: it cannot be zero (because Lua cannot even start with +** less than PAUSEADJ bytes). +*/ +static void setpause (global_State *g) { + l_mem threshold, debt; + l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ + lua_assert(estimate > 0); + threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */ + ? estimate * g->gcpause /* no overflow */ + : MAX_LMEM; /* overflow; truncate to maximum */ + debt = gettotalbytes(g) - threshold; + luaE_setdebt(g, debt); +} + + +/* +** Enter first sweep phase. +** The call to 'sweeplist' tries to make pointer point to an object +** inside the list (instead of to the header), so that the real sweep do +** not need to skip objects created between "now" and the start of the +** real sweep. +*/ +static void entersweep (lua_State *L) { + global_State *g = G(L); + g->gcstate = GCSswpallgc; + lua_assert(g->sweepgc == NULL); + g->sweepgc = sweeplist(L, &g->allgc, 1); +} + + +void luaC_freeallobjects (lua_State *L) { + global_State *g = G(L); + separatetobefnz(g, 1); /* separate all objects with finalizers */ + lua_assert(g->finobj == NULL); + callallpendingfinalizers(L); + lua_assert(g->tobefnz == NULL); + g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */ + g->gckind = KGC_NORMAL; + sweepwholelist(L, &g->finobj); + sweepwholelist(L, &g->allgc); + sweepwholelist(L, &g->fixedgc); /* collect fixed objects */ + lua_assert(g->strt.nuse == 0); +} + + +static l_mem atomic (lua_State *L) { + global_State *g = G(L); + l_mem work; + GCObject *origweak, *origall; + GCObject *grayagain = g->grayagain; /* save original list */ + lua_assert(g->ephemeron == NULL && g->weak == NULL); + lua_assert(!iswhite(g->mainthread)); + g->gcstate = GCSinsideatomic; + g->GCmemtrav = 0; /* start counting work */ + markobject(g, L); /* mark running thread */ + /* registry and global metatables may be changed by API */ + markvalue(g, &g->l_registry); + markmt(g); /* mark global metatables */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + propagateall(g); /* propagate changes */ + work = g->GCmemtrav; /* stop counting (do not recount 'grayagain') */ + g->gray = grayagain; + propagateall(g); /* traverse 'grayagain' list */ + g->GCmemtrav = 0; /* restart counting */ + convergeephemerons(g); + /* at this point, all strongly accessible objects are marked. */ + /* Clear values from weak tables, before checking finalizers */ + clearvalues(g, g->weak, NULL); + clearvalues(g, g->allweak, NULL); + origweak = g->weak; origall = g->allweak; + work += g->GCmemtrav; /* stop counting (objects being finalized) */ + separatetobefnz(g, 0); /* separate objects to be finalized */ + g->gcfinnum = 1; /* there may be objects to be finalized */ + markbeingfnz(g); /* mark objects that will be finalized */ + propagateall(g); /* remark, to propagate 'resurrection' */ + g->GCmemtrav = 0; /* restart counting */ + convergeephemerons(g); + /* at this point, all resurrected objects are marked. */ + /* remove dead objects from weak tables */ + clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */ + clearkeys(g, g->allweak, NULL); /* clear keys from all 'allweak' tables */ + /* clear values from resurrected weak tables */ + clearvalues(g, g->weak, origweak); + clearvalues(g, g->allweak, origall); + luaS_clearcache(g); + g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ + work += g->GCmemtrav; /* complete counting */ + return work; /* estimate of memory marked by 'atomic' */ +} + + +static lu_mem sweepstep (lua_State *L, global_State *g, + int nextstate, GCObject **nextlist) { + if (g->sweepgc) { + l_mem olddebt = g->GCdebt; + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + g->GCestimate += g->GCdebt - olddebt; /* update estimate */ + if (g->sweepgc) /* is there still something to sweep? */ + return (GCSWEEPMAX * GCSWEEPCOST); + } + /* else enter next state */ + g->gcstate = nextstate; + g->sweepgc = nextlist; + return 0; +} + + +static lu_mem singlestep (lua_State *L) { + global_State *g = G(L); + switch (g->gcstate) { + case GCSpause: { + g->GCmemtrav = g->strt.size * sizeof(GCObject*); + restartcollection(g); + g->gcstate = GCSpropagate; + return g->GCmemtrav; + } + case GCSpropagate: { + g->GCmemtrav = 0; + lua_assert(g->gray); + propagatemark(g); + if (g->gray == NULL) /* no more gray objects? */ + g->gcstate = GCSatomic; /* finish propagate phase */ + return g->GCmemtrav; /* memory traversed in this step */ + } + case GCSatomic: { + lu_mem work; + propagateall(g); /* make sure gray list is empty */ + work = atomic(L); /* work is what was traversed by 'atomic' */ + entersweep(L); + g->GCestimate = gettotalbytes(g); /* first estimate */; + return work; + } + case GCSswpallgc: { /* sweep "regular" objects */ + return sweepstep(L, g, GCSswpfinobj, &g->finobj); + } + case GCSswpfinobj: { /* sweep objects with finalizers */ + return sweepstep(L, g, GCSswptobefnz, &g->tobefnz); + } + case GCSswptobefnz: { /* sweep objects to be finalized */ + return sweepstep(L, g, GCSswpend, NULL); + } + case GCSswpend: { /* finish sweeps */ + makewhite(g, g->mainthread); /* sweep main thread */ + checkSizes(L, g); + g->gcstate = GCScallfin; + return 0; + } + case GCScallfin: { /* call remaining finalizers */ + if (g->tobefnz && g->gckind != KGC_EMERGENCY) { + int n = runafewfinalizers(L); + return (n * GCFINALIZECOST); + } + else { /* emergency mode or no more finalizers */ + g->gcstate = GCSpause; /* finish collection */ + return 0; + } + } + default: lua_assert(0); return 0; + } +} + + +/* +** advances the garbage collector until it reaches a state allowed +** by 'statemask' +*/ +void luaC_runtilstate (lua_State *L, int statesmask) { + global_State *g = G(L); + while (!testbit(statesmask, g->gcstate)) + singlestep(L); +} + + +/* +** get GC debt and convert it from Kb to 'work units' (avoid zero debt +** and overflows) +*/ +static l_mem getdebt (global_State *g) { + l_mem debt = g->GCdebt; + int stepmul = g->gcstepmul; + if (debt <= 0) return 0; /* minimal debt */ + else { + debt = (debt / STEPMULADJ) + 1; + debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM; + return debt; + } +} + +/* +** performs a basic GC step when collector is running +*/ +void luaC_step (lua_State *L) { + global_State *g = G(L); + l_mem debt = getdebt(g); /* GC deficit (be paid now) */ + if (!g->gcrunning) { /* not running? */ + luaE_setdebt(g, -GCSTEPSIZE * 10); /* avoid being called too often */ + return; + } + do { /* repeat until pause or enough "credit" (negative debt) */ + lu_mem work = singlestep(L); /* perform one single step */ + debt -= work; + } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); + if (g->gcstate == GCSpause) + setpause(g); /* pause until next cycle */ + else { + debt = (debt / g->gcstepmul) * STEPMULADJ; /* convert 'work units' to Kb */ + luaE_setdebt(g, debt); + runafewfinalizers(L); + } +} + + +/* +** Performs a full GC cycle; if 'isemergency', set a flag to avoid +** some operations which could change the interpreter state in some +** unexpected ways (running finalizers and shrinking some structures). +** Before running the collection, check 'keepinvariant'; if it is true, +** there may be some objects marked as black, so the collector has +** to sweep all objects to turn them back to white (as white has not +** changed, nothing will be collected). +*/ +void luaC_fullgc (lua_State *L, int isemergency) { + global_State *g = G(L); + lua_assert(g->gckind == KGC_NORMAL); + if (isemergency) g->gckind = KGC_EMERGENCY; /* set flag */ + if (keepinvariant(g)) { /* black objects? */ + entersweep(L); /* sweep everything to turn them back to white */ + } + /* finish any pending sweep phase to start a new cycle */ + luaC_runtilstate(L, bitmask(GCSpause)); + luaC_runtilstate(L, ~bitmask(GCSpause)); /* start new collection */ + luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ + /* estimate must be correct after a full GC cycle */ + lua_assert(g->GCestimate == gettotalbytes(g)); + luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ + g->gckind = KGC_NORMAL; + setpause(g); +} + +/* }====================================================== */ + + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lgc.h b/dep/scintilla/scintilla-3.10.6/lua/src/lgc.h new file mode 100644 index 00000000..aed3e18a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lgc.h @@ -0,0 +1,147 @@ +/* +** $Id: lgc.h,v 2.91 2015/12/21 13:02:14 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" +#include "lstate.h" + +/* +** Collectable objects may have one of three colors: white, which +** means the object is not marked; gray, which means the +** object is marked, but its references may be not marked; and +** black, which means that the object and all its references are marked. +** The main invariant of the garbage collector, while marking objects, +** is that a black object can never point to a white one. Moreover, +** any gray object must be in a "gray list" (gray, grayagain, weak, +** allweak, ephemeron) so that it can be visited again before finishing +** the collection cycle. These lists have no meaning when the invariant +** is not being enforced (e.g., sweep phase). +*/ + + + +/* how much to allocate before next GC step */ +#if !defined(GCSTEPSIZE) +/* ~100 small strings */ +#define GCSTEPSIZE (cast_int(100 * sizeof(TString))) +#endif + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpropagate 0 +#define GCSatomic 1 +#define GCSswpallgc 2 +#define GCSswpfinobj 3 +#define GCSswptobefnz 4 +#define GCSswpend 5 +#define GCScallfin 6 +#define GCSpause 7 + + +#define issweepphase(g) \ + (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend) + + +/* +** macro to tell when main invariant (white objects cannot point to black +** ones) must be kept. During a collection, the sweep +** phase may break the invariant, as objects turned white may point to +** still-black objects. The invariant is restored when sweep ends and +** all objects are white again. +*/ + +#define keepinvariant(g) ((g)->gcstate <= GCSatomic) + + +/* +** some useful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) + + +/* Layout for bit use in 'marked' field: */ +#define WHITE0BIT 0 /* object is white (type 0) */ +#define WHITE1BIT 1 /* object is white (type 1) */ +#define BLACKBIT 2 /* object is black */ +#define FINALIZEDBIT 3 /* object has been marked for finalization */ +/* bit 7 is currently used by tests (luaL_checkmemory) */ + +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) testbits((x)->marked, WHITEBITS) +#define isblack(x) testbit((x)->marked, BLACKBIT) +#define isgray(x) /* neither white nor black */ \ + (!testbits((x)->marked, WHITEBITS | bitmask(BLACKBIT))) + +#define tofinalize(x) testbit((x)->marked, FINALIZEDBIT) + +#define otherwhite(g) ((g)->currentwhite ^ WHITEBITS) +#define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) +#define isdead(g,v) isdeadm(otherwhite(g), (v)->marked) + +#define changewhite(x) ((x)->marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->marked, BLACKBIT) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +/* +** Does one step of collection when debt becomes positive. 'pre'/'pos' +** allows some adjustments to be done only when needed. macro +** 'condchangemem' is used only for heavy tests (forcing a full +** GC cycle on every opportunity) +*/ +#define luaC_condGC(L,pre,pos) \ + { if (G(L)->GCdebt > 0) { pre; luaC_step(L); pos;}; \ + condchangemem(L,pre,pos); } + +/* more often than not, 'pre'/'pos' are empty */ +#define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0) + + +#define luaC_barrier(L,p,v) ( \ + (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \ + luaC_barrier_(L,obj2gco(p),gcvalue(v)) : cast_void(0)) + +#define luaC_barrierback(L,p,v) ( \ + (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \ + luaC_barrierback_(L,p) : cast_void(0)) + +#define luaC_objbarrier(L,p,o) ( \ + (isblack(p) && iswhite(o)) ? \ + luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0)) + +#define luaC_upvalbarrier(L,uv) ( \ + (iscollectable((uv)->v) && !upisopen(uv)) ? \ + luaC_upvalbarrier_(L,uv) : cast_void(0)) + +LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o); +LUAI_FUNC void luaC_freeallobjects (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); +LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); +LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz); +LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o); +LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); +LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv); + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/linit.c b/dep/scintilla/scintilla-3.10.6/lua/src/linit.c new file mode 100644 index 00000000..afcaf98b --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/linit.c @@ -0,0 +1,68 @@ +/* +** $Id: linit.c,v 1.39 2016/12/04 20:17:24 roberto Exp $ +** Initialization of libraries for lua.c and other clients +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +/* +** If you embed Lua in your program and need to open the standard +** libraries, call luaL_openlibs in your program. If you need a +** different set of libraries, copy this file to your project and edit +** it to suit your needs. +** +** You can also *preload* libraries, so that a later 'require' can +** open the library, which is already linked to the application. +** For that, do the following code: +** +** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); +** lua_pushcfunction(L, luaopen_modname); +** lua_setfield(L, -2, modname); +** lua_pop(L, 1); // remove PRELOAD table +*/ + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" + + +/* +** these libs are loaded by lua.c and are readily available to any Lua +** program +*/ +static const luaL_Reg loadedlibs[] = { + {"_G", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_COLIBNAME, luaopen_coroutine}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_UTF8LIBNAME, luaopen_utf8}, + {LUA_DBLIBNAME, luaopen_debug}, +#if defined(LUA_COMPAT_BITLIB) + {LUA_BITLIBNAME, luaopen_bit32}, +#endif + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib; + /* "require" functions from 'loadedlibs' and set results to global table */ + for (lib = loadedlibs; lib->func; lib++) { + luaL_requiref(L, lib->name, lib->func, 1); + lua_pop(L, 1); /* remove lib */ + } +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/liolib.c b/dep/scintilla/scintilla-3.10.6/lua/src/liolib.c new file mode 100644 index 00000000..15684035 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/liolib.c @@ -0,0 +1,771 @@ +/* +** $Id: liolib.c,v 2.151 2016/12/20 18:37:00 roberto Exp $ +** Standard I/O (and system) library +** See Copyright Notice in lua.h +*/ + +#define liolib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include +#include +#include +#include +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + + +/* +** Change this macro to accept other modes for 'fopen' besides +** the standard ones. +*/ +#if !defined(l_checkmode) + +/* accepted extensions to 'mode' in 'fopen' */ +#if !defined(L_MODEEXT) +#define L_MODEEXT "b" +#endif + +/* Check whether 'mode' matches '[rwa]%+?[L_MODEEXT]*' */ +static int l_checkmode (const char *mode) { + return (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && + (*mode != '+' || (++mode, 1)) && /* skip if char is '+' */ + (strspn(mode, L_MODEEXT) == strlen(mode))); /* check extensions */ +} + +#endif + +/* +** {====================================================== +** l_popen spawns a new process connected to the current +** one through the file streams. +** ======================================================= +*/ + +#if !defined(l_popen) /* { */ + +#if defined(LUA_USE_POSIX) /* { */ + +#define l_popen(L,c,m) (fflush(NULL), popen(c,m)) +#define l_pclose(L,file) (pclose(file)) + +#elif defined(LUA_USE_WINDOWS) /* }{ */ + +#define l_popen(L,c,m) (_popen(c,m)) +#define l_pclose(L,file) (_pclose(file)) + +#else /* }{ */ + +/* ISO C definitions */ +#define l_popen(L,c,m) \ + ((void)((void)c, m), \ + luaL_error(L, "'popen' not supported"), \ + (FILE*)0) +#define l_pclose(L,file) ((void)L, (void)file, -1) + +#endif /* } */ + +#endif /* } */ + +/* }====================================================== */ + + +#if !defined(l_getc) /* { */ + +#if defined(LUA_USE_POSIX) +#define l_getc(f) getc_unlocked(f) +#define l_lockfile(f) flockfile(f) +#define l_unlockfile(f) funlockfile(f) +#else +#define l_getc(f) getc(f) +#define l_lockfile(f) ((void)0) +#define l_unlockfile(f) ((void)0) +#endif + +#endif /* } */ + + +/* +** {====================================================== +** l_fseek: configuration for longer offsets +** ======================================================= +*/ + +#if !defined(l_fseek) /* { */ + +#if defined(LUA_USE_POSIX) /* { */ + +#include + +#define l_fseek(f,o,w) fseeko(f,o,w) +#define l_ftell(f) ftello(f) +#define l_seeknum off_t + +#elif defined(LUA_USE_WINDOWS) && !defined(_CRTIMP_TYPEINFO) \ + && defined(_MSC_VER) && (_MSC_VER >= 1400) /* }{ */ + +/* Windows (but not DDK) and Visual C++ 2005 or higher */ +#define l_fseek(f,o,w) _fseeki64(f,o,w) +#define l_ftell(f) _ftelli64(f) +#define l_seeknum __int64 + +#else /* }{ */ + +/* ISO C definitions */ +#define l_fseek(f,o,w) fseek(f,o,w) +#define l_ftell(f) ftell(f) +#define l_seeknum long + +#endif /* } */ + +#endif /* } */ + +/* }====================================================== */ + + +#define IO_PREFIX "_IO_" +#define IOPREF_LEN (sizeof(IO_PREFIX)/sizeof(char) - 1) +#define IO_INPUT (IO_PREFIX "input") +#define IO_OUTPUT (IO_PREFIX "output") + + +typedef luaL_Stream LStream; + + +#define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + +#define isclosed(p) ((p)->closef == NULL) + + +static int io_type (lua_State *L) { + LStream *p; + luaL_checkany(L, 1); + p = (LStream *)luaL_testudata(L, 1, LUA_FILEHANDLE); + if (p == NULL) + lua_pushnil(L); /* not a file */ + else if (isclosed(p)) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static int f_tostring (lua_State *L) { + LStream *p = tolstream(L); + if (isclosed(p)) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", p->f); + return 1; +} + + +static FILE *tofile (lua_State *L) { + LStream *p = tolstream(L); + if (isclosed(p)) + luaL_error(L, "attempt to use a closed file"); + lua_assert(p->f); + return p->f; +} + + +/* +** When creating file handles, always creates a 'closed' file handle +** before opening the actual file; so, if there is a memory error, the +** handle is in a consistent state. +*/ +static LStream *newprefile (lua_State *L) { + LStream *p = (LStream *)lua_newuserdata(L, sizeof(LStream)); + p->closef = NULL; /* mark file handle as 'closed' */ + luaL_setmetatable(L, LUA_FILEHANDLE); + return p; +} + + +/* +** Calls the 'close' function from a file handle. The 'volatile' avoids +** a bug in some versions of the Clang compiler (e.g., clang 3.0 for +** 32 bits). +*/ +static int aux_close (lua_State *L) { + LStream *p = tolstream(L); + volatile lua_CFunction cf = p->closef; + p->closef = NULL; /* mark stream as closed */ + return (*cf)(L); /* close it */ +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) /* no argument? */ + lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */ + tofile(L); /* make sure argument is an open stream */ + return aux_close(L); +} + + +static int f_gc (lua_State *L) { + LStream *p = tolstream(L); + if (!isclosed(p) && p->f != NULL) + aux_close(L); /* ignore closed and incompletely open files */ + return 0; +} + + +/* +** function to close regular files +*/ +static int io_fclose (lua_State *L) { + LStream *p = tolstream(L); + int res = fclose(p->f); + return luaL_fileresult(L, (res == 0), NULL); +} + + +static LStream *newfile (lua_State *L) { + LStream *p = newprefile(L); + p->f = NULL; + p->closef = &io_fclose; + return p; +} + + +static void opencheck (lua_State *L, const char *fname, const char *mode) { + LStream *p = newfile(L); + p->f = fopen(fname, mode); + if (p->f == NULL) + luaL_error(L, "cannot open file '%s' (%s)", fname, strerror(errno)); +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + LStream *p = newfile(L); + const char *md = mode; /* to traverse/check mode */ + luaL_argcheck(L, l_checkmode(md), 2, "invalid mode"); + p->f = fopen(filename, mode); + return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; +} + + +/* +** function to close 'popen' files +*/ +static int io_pclose (lua_State *L) { + LStream *p = tolstream(L); + return luaL_execresult(L, l_pclose(L, p->f)); +} + + +static int io_popen (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + LStream *p = newprefile(L); + p->f = l_popen(L, filename, mode); + p->closef = &io_pclose; + return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; +} + + +static int io_tmpfile (lua_State *L) { + LStream *p = newfile(L); + p->f = tmpfile(); + return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, const char *findex) { + LStream *p; + lua_getfield(L, LUA_REGISTRYINDEX, findex); + p = (LStream *)lua_touserdata(L, -1); + if (isclosed(p)) + luaL_error(L, "standard %s file is closed", findex + IOPREF_LEN); + return p->f; +} + + +static int g_iofile (lua_State *L, const char *f, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + if (filename) + opencheck(L, filename, mode); + else { + tofile(L); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_setfield(L, LUA_REGISTRYINDEX, f); + } + /* return current value */ + lua_getfield(L, LUA_REGISTRYINDEX, f); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +/* +** maximum number of arguments to 'f:lines'/'io.lines' (it + 3 must fit +** in the limit for upvalues of a closure) +*/ +#define MAXARGLINE 250 + +static void aux_lines (lua_State *L, int toclose) { + int n = lua_gettop(L) - 1; /* number of arguments to read */ + luaL_argcheck(L, n <= MAXARGLINE, MAXARGLINE + 2, "too many arguments"); + lua_pushinteger(L, n); /* number of arguments to read */ + lua_pushboolean(L, toclose); /* close/not close file when finished */ + lua_rotate(L, 2, 2); /* move 'n' and 'toclose' to their positions */ + lua_pushcclosure(L, io_readline, 3 + n); +} + + +static int f_lines (lua_State *L) { + tofile(L); /* check that it's a valid file handle */ + aux_lines(L, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + int toclose; + if (lua_isnone(L, 1)) lua_pushnil(L); /* at least one argument */ + if (lua_isnil(L, 1)) { /* no file name? */ + lua_getfield(L, LUA_REGISTRYINDEX, IO_INPUT); /* get default input */ + lua_replace(L, 1); /* put it at index 1 */ + tofile(L); /* check that it's a valid file handle */ + toclose = 0; /* do not close it after iteration */ + } + else { /* open a new file */ + const char *filename = luaL_checkstring(L, 1); + opencheck(L, filename, "r"); + lua_replace(L, 1); /* put file at index 1 */ + toclose = 1; /* close it after iteration */ + } + aux_lines(L, toclose); + return 1; +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +/* maximum length of a numeral */ +#if !defined (L_MAXLENNUM) +#define L_MAXLENNUM 200 +#endif + + +/* auxiliary structure used by 'read_number' */ +typedef struct { + FILE *f; /* file being read */ + int c; /* current character (look ahead) */ + int n; /* number of elements in buffer 'buff' */ + char buff[L_MAXLENNUM + 1]; /* +1 for ending '\0' */ +} RN; + + +/* +** Add current char to buffer (if not out of space) and read next one +*/ +static int nextc (RN *rn) { + if (rn->n >= L_MAXLENNUM) { /* buffer overflow? */ + rn->buff[0] = '\0'; /* invalidate result */ + return 0; /* fail */ + } + else { + rn->buff[rn->n++] = rn->c; /* save current char */ + rn->c = l_getc(rn->f); /* read next one */ + return 1; + } +} + + +/* +** Accept current char if it is in 'set' (of size 2) +*/ +static int test2 (RN *rn, const char *set) { + if (rn->c == set[0] || rn->c == set[1]) + return nextc(rn); + else return 0; +} + + +/* +** Read a sequence of (hex)digits +*/ +static int readdigits (RN *rn, int hex) { + int count = 0; + while ((hex ? isxdigit(rn->c) : isdigit(rn->c)) && nextc(rn)) + count++; + return count; +} + + +/* +** Read a number: first reads a valid prefix of a numeral into a buffer. +** Then it calls 'lua_stringtonumber' to check whether the format is +** correct and to convert it to a Lua number +*/ +static int read_number (lua_State *L, FILE *f) { + RN rn; + int count = 0; + int hex = 0; + char decp[2]; + rn.f = f; rn.n = 0; + decp[0] = lua_getlocaledecpoint(); /* get decimal point from locale */ + decp[1] = '.'; /* always accept a dot */ + l_lockfile(rn.f); + do { rn.c = l_getc(rn.f); } while (isspace(rn.c)); /* skip spaces */ + test2(&rn, "-+"); /* optional signal */ + if (test2(&rn, "00")) { + if (test2(&rn, "xX")) hex = 1; /* numeral is hexadecimal */ + else count = 1; /* count initial '0' as a valid digit */ + } + count += readdigits(&rn, hex); /* integral part */ + if (test2(&rn, decp)) /* decimal point? */ + count += readdigits(&rn, hex); /* fractional part */ + if (count > 0 && test2(&rn, (hex ? "pP" : "eE"))) { /* exponent mark? */ + test2(&rn, "-+"); /* exponent signal */ + readdigits(&rn, 0); /* exponent digits */ + } + ungetc(rn.c, rn.f); /* unread look-ahead char */ + l_unlockfile(rn.f); + rn.buff[rn.n] = '\0'; /* finish string */ + if (lua_stringtonumber(L, rn.buff)) /* is this a valid number? */ + return 1; /* ok */ + else { /* invalid format */ + lua_pushnil(L); /* "result" to be removed */ + return 0; /* read fails */ + } +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); /* no-op when c == EOF */ + lua_pushliteral(L, ""); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f, int chop) { + luaL_Buffer b; + int c = '\0'; + luaL_buffinit(L, &b); + while (c != EOF && c != '\n') { /* repeat until end of line */ + char *buff = luaL_prepbuffer(&b); /* preallocate buffer */ + int i = 0; + l_lockfile(f); /* no memory errors can happen inside the lock */ + while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n') + buff[i++] = c; + l_unlockfile(f); + luaL_addsize(&b, i); + } + if (!chop && c == '\n') /* want a newline and have one? */ + luaL_addchar(&b, c); /* add ending newline to result */ + luaL_pushresult(&b); /* close buffer */ + /* return ok if read something (either a newline or something else) */ + return (c == '\n' || lua_rawlen(L, -1) > 0); +} + + +static void read_all (lua_State *L, FILE *f) { + size_t nr; + luaL_Buffer b; + luaL_buffinit(L, &b); + do { /* read file in chunks of LUAL_BUFFERSIZE bytes */ + char *p = luaL_prepbuffer(&b); + nr = fread(p, sizeof(char), LUAL_BUFFERSIZE, f); + luaL_addsize(&b, nr); + } while (nr == LUAL_BUFFERSIZE); + luaL_pushresult(&b); /* close buffer */ +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t nr; /* number of chars actually read */ + char *p; + luaL_Buffer b; + luaL_buffinit(L, &b); + p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */ + nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */ + luaL_addsize(&b, nr); + luaL_pushresult(&b); /* close buffer */ + return (nr > 0); /* true iff read something */ +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + clearerr(f); + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f, 1); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)luaL_checkinteger(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = luaL_checkstring(L, n); + if (*p == '*') p++; /* skip optional '*' (for compatibility) */ + switch (*p) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f, 1); + break; + case 'L': /* line with end-of-line */ + success = read_line(L, f, 0); + break; + case 'a': /* file */ + read_all(L, f); /* read entire file */ + success = 1; /* always success */ + break; + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (ferror(f)) + return luaL_fileresult(L, 0, NULL); + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L), 2); +} + + +static int io_readline (lua_State *L) { + LStream *p = (LStream *)lua_touserdata(L, lua_upvalueindex(1)); + int i; + int n = (int)lua_tointeger(L, lua_upvalueindex(2)); + if (isclosed(p)) /* file is already closed? */ + return luaL_error(L, "file is already closed"); + lua_settop(L , 1); + luaL_checkstack(L, n, "too many arguments"); + for (i = 1; i <= n; i++) /* push arguments to 'g_read' */ + lua_pushvalue(L, lua_upvalueindex(3 + i)); + n = g_read(L, p->f, 2); /* 'n' is number of results */ + lua_assert(n > 0); /* should return at least a nil */ + if (lua_toboolean(L, -n)) /* read at least one value? */ + return n; /* return them */ + else { /* first result is nil: EOF or error */ + if (n > 1) { /* is there error information? */ + /* 2nd result is error message */ + return luaL_error(L, "%s", lua_tostring(L, -n + 1)); + } + if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(1)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - arg; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + int len = lua_isinteger(L, arg) + ? fprintf(f, LUA_INTEGER_FMT, + (LUAI_UACINT)lua_tointeger(L, arg)) + : fprintf(f, LUA_NUMBER_FMT, + (LUAI_UACNUMBER)lua_tonumber(L, arg)); + status = status && (len > 0); + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + if (status) return 1; /* file handle already on stack top */ + else return luaL_fileresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + FILE *f = tofile(L); + lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */ + return g_write(L, f, 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, "cur", modenames); + lua_Integer p3 = luaL_optinteger(L, 3, 0); + l_seeknum offset = (l_seeknum)p3; + luaL_argcheck(L, (lua_Integer)offset == p3, 3, + "not an integer in proper range"); + op = l_fseek(f, offset, mode[op]); + if (op) + return luaL_fileresult(L, 0, NULL); /* error */ + else { + lua_pushinteger(L, (lua_Integer)l_ftell(f)); + return 1; + } +} + + +static int f_setvbuf (lua_State *L) { + static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; + static const char *const modenames[] = {"no", "full", "line", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, NULL, modenames); + lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); + int res = setvbuf(f, NULL, mode[op], (size_t)sz); + return luaL_fileresult(L, res == 0, NULL); +} + + + +static int io_flush (lua_State *L) { + return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL); +} + + +/* +** functions for 'io' library +*/ +static const luaL_Reg iolib[] = { + {"close", io_close}, + {"flush", io_flush}, + {"input", io_input}, + {"lines", io_lines}, + {"open", io_open}, + {"output", io_output}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +/* +** methods for file handles +*/ +static const luaL_Reg flib[] = { + {"close", io_close}, + {"flush", f_flush}, + {"lines", f_lines}, + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, + {"write", f_write}, + {"__gc", f_gc}, + {"__tostring", f_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ + lua_pushvalue(L, -1); /* push metatable */ + lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ + lua_pop(L, 1); /* pop new metatable */ +} + + +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + LStream *p = tolstream(L); + p->closef = &io_noclose; /* keep file opened */ + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +static void createstdfile (lua_State *L, FILE *f, const char *k, + const char *fname) { + LStream *p = newprefile(L); + p->f = f; + p->closef = &io_noclose; + if (k != NULL) { + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, k); /* add file to registry */ + } + lua_setfield(L, -2, fname); /* add file to module */ +} + + +LUAMOD_API int luaopen_io (lua_State *L) { + luaL_newlib(L, iolib); /* new module */ + createmeta(L); + /* create (and set) default files */ + createstdfile(L, stdin, IO_INPUT, "stdin"); + createstdfile(L, stdout, IO_OUTPUT, "stdout"); + createstdfile(L, stderr, NULL, "stderr"); + return 1; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/llex.c b/dep/scintilla/scintilla-3.10.6/lua/src/llex.c new file mode 100644 index 00000000..70328273 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/llex.c @@ -0,0 +1,565 @@ +/* +** $Id: llex.c,v 2.96 2016/05/02 14:02:12 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#define llex_c +#define LUA_CORE + +#include "lprefix.h" + + +#include +#include + +#include "lua.h" + +#include "lctype.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lobject.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lzio.h" + + + +#define next(ls) (ls->current = zgetc(ls->z)) + + + +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') + + +/* ORDER RESERVED */ +static const char *const luaX_tokens [] = { + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "goto", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "//", "..", "...", "==", ">=", "<=", "~=", + "<<", ">>", "::", "", + "", "", "", "" +}; + + +#define save_and_next(ls) (save(ls, ls->current), next(ls)) + + +static l_noret lexerror (LexState *ls, const char *msg, int token); + + +static void save (LexState *ls, int c) { + Mbuffer *b = ls->buff; + if (luaZ_bufflen(b) + 1 > luaZ_sizebuffer(b)) { + size_t newsize; + if (luaZ_sizebuffer(b) >= MAX_SIZE/2) + lexerror(ls, "lexical element too long", 0); + newsize = luaZ_sizebuffer(b) * 2; + luaZ_resizebuffer(ls->L, b, newsize); + } + b->buffer[luaZ_bufflen(b)++] = cast(char, c); +} + + +void luaX_init (lua_State *L) { + int i; + TString *e = luaS_newliteral(L, LUA_ENV); /* create env name */ + luaC_fix(L, obj2gco(e)); /* never collect this name */ + for (i=0; iextra = cast_byte(i+1); /* reserved word */ + } +} + + +const char *luaX_token2str (LexState *ls, int token) { + if (token < FIRST_RESERVED) { /* single-byte symbols? */ + lua_assert(token == cast_uchar(token)); + return luaO_pushfstring(ls->L, "'%c'", token); + } + else { + const char *s = luaX_tokens[token - FIRST_RESERVED]; + if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ + return luaO_pushfstring(ls->L, "'%s'", s); + else /* names, strings, and numerals */ + return s; + } +} + + +static const char *txtToken (LexState *ls, int token) { + switch (token) { + case TK_NAME: case TK_STRING: + case TK_FLT: case TK_INT: + save(ls, '\0'); + return luaO_pushfstring(ls->L, "'%s'", luaZ_buffer(ls->buff)); + default: + return luaX_token2str(ls, token); + } +} + + +static l_noret lexerror (LexState *ls, const char *msg, int token) { + msg = luaG_addinfo(ls->L, msg, ls->source, ls->linenumber); + if (token) + luaO_pushfstring(ls->L, "%s near %s", msg, txtToken(ls, token)); + luaD_throw(ls->L, LUA_ERRSYNTAX); +} + + +l_noret luaX_syntaxerror (LexState *ls, const char *msg) { + lexerror(ls, msg, ls->t.token); +} + + +/* +** creates a new string and anchors it in scanner's table so that +** it will not be collected until the end of the compilation +** (by that time it should be anchored somewhere) +*/ +TString *luaX_newstring (LexState *ls, const char *str, size_t l) { + lua_State *L = ls->L; + TValue *o; /* entry for 'str' */ + TString *ts = luaS_newlstr(L, str, l); /* create new string */ + setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */ + o = luaH_set(L, ls->h, L->top - 1); + if (ttisnil(o)) { /* not in use yet? */ + /* boolean value does not need GC barrier; + table has no metatable, so it does not need to invalidate cache */ + setbvalue(o, 1); /* t[string] = true */ + luaC_checkGC(L); + } + else { /* string already present */ + ts = tsvalue(keyfromval(o)); /* re-use value previously stored */ + } + L->top--; /* remove string from stack */ + return ts; +} + + +/* +** increment line number and skips newline sequence (any of +** \n, \r, \n\r, or \r\n) +*/ +static void inclinenumber (LexState *ls) { + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip '\n' or '\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip '\n\r' or '\r\n' */ + if (++ls->linenumber >= MAX_INT) + lexerror(ls, "chunk has too many lines", 0); +} + + +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source, + int firstchar) { + ls->t.token = 0; + ls->L = L; + ls->current = firstchar; + ls->lookahead.token = TK_EOS; /* no look-ahead token */ + ls->z = z; + ls->fs = NULL; + ls->linenumber = 1; + ls->lastline = 1; + ls->source = source; + ls->envn = luaS_newliteral(L, LUA_ENV); /* get env name */ + luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ +} + + + +/* +** ======================================================= +** LEXICAL ANALYZER +** ======================================================= +*/ + + +static int check_next1 (LexState *ls, int c) { + if (ls->current == c) { + next(ls); + return 1; + } + else return 0; +} + + +/* +** Check whether current char is in set 'set' (with two chars) and +** saves it +*/ +static int check_next2 (LexState *ls, const char *set) { + lua_assert(set[2] == '\0'); + if (ls->current == set[0] || ls->current == set[1]) { + save_and_next(ls); + return 1; + } + else return 0; +} + + +/* LUA_NUMBER */ +/* +** this function is quite liberal in what it accepts, as 'luaO_str2num' +** will reject ill-formed numerals. +*/ +static int read_numeral (LexState *ls, SemInfo *seminfo) { + TValue obj; + const char *expo = "Ee"; + int first = ls->current; + lua_assert(lisdigit(ls->current)); + save_and_next(ls); + if (first == '0' && check_next2(ls, "xX")) /* hexadecimal? */ + expo = "Pp"; + for (;;) { + if (check_next2(ls, expo)) /* exponent part? */ + check_next2(ls, "-+"); /* optional exponent sign */ + if (lisxdigit(ls->current)) + save_and_next(ls); + else if (ls->current == '.') + save_and_next(ls); + else break; + } + save(ls, '\0'); + if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */ + lexerror(ls, "malformed number", TK_FLT); + if (ttisinteger(&obj)) { + seminfo->i = ivalue(&obj); + return TK_INT; + } + else { + lua_assert(ttisfloat(&obj)); + seminfo->r = fltvalue(&obj); + return TK_FLT; + } +} + + +/* +** skip a sequence '[=*[' or ']=*]'; if sequence is well formed, return +** its number of '='s; otherwise, return a negative number (-1 iff there +** are no '='s after initial bracket) +*/ +static int skip_sep (LexState *ls) { + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + + +static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { + int line = ls->linenumber; /* initial line (for error message) */ + save_and_next(ls); /* skip 2nd '[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case EOZ: { /* error */ + const char *what = (seminfo ? "string" : "comment"); + const char *msg = luaO_pushfstring(ls->L, + "unfinished long %s (starting at line %d)", what, line); + lexerror(ls, msg, TK_EOS); + break; /* to avoid warnings */ + } + case ']': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd ']' */ + goto endloop; + } + break; + } + case '\n': case '\r': { + save(ls, '\n'); + inclinenumber(ls); + if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ + break; + } + default: { + if (seminfo) save_and_next(ls); + else next(ls); + } + } + } endloop: + if (seminfo) + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), + luaZ_bufflen(ls->buff) - 2*(2 + sep)); +} + + +static void esccheck (LexState *ls, int c, const char *msg) { + if (!c) { + if (ls->current != EOZ) + save_and_next(ls); /* add current to buffer for error message */ + lexerror(ls, msg, TK_STRING); + } +} + + +static int gethexa (LexState *ls) { + save_and_next(ls); + esccheck (ls, lisxdigit(ls->current), "hexadecimal digit expected"); + return luaO_hexavalue(ls->current); +} + + +static int readhexaesc (LexState *ls) { + int r = gethexa(ls); + r = (r << 4) + gethexa(ls); + luaZ_buffremove(ls->buff, 2); /* remove saved chars from buffer */ + return r; +} + + +static unsigned long readutf8esc (LexState *ls) { + unsigned long r; + int i = 4; /* chars to be removed: '\', 'u', '{', and first digit */ + save_and_next(ls); /* skip 'u' */ + esccheck(ls, ls->current == '{', "missing '{'"); + r = gethexa(ls); /* must have at least one digit */ + while ((save_and_next(ls), lisxdigit(ls->current))) { + i++; + r = (r << 4) + luaO_hexavalue(ls->current); + esccheck(ls, r <= 0x10FFFF, "UTF-8 value too large"); + } + esccheck(ls, ls->current == '}', "missing '}'"); + next(ls); /* skip '}' */ + luaZ_buffremove(ls->buff, i); /* remove saved chars from buffer */ + return r; +} + + +static void utf8esc (LexState *ls) { + char buff[UTF8BUFFSZ]; + int n = luaO_utf8esc(buff, readutf8esc(ls)); + for (; n > 0; n--) /* add 'buff' to string */ + save(ls, buff[UTF8BUFFSZ - n]); +} + + +static int readdecesc (LexState *ls) { + int i; + int r = 0; /* result accumulator */ + for (i = 0; i < 3 && lisdigit(ls->current); i++) { /* read up to 3 digits */ + r = 10*r + ls->current - '0'; + save_and_next(ls); + } + esccheck(ls, r <= UCHAR_MAX, "decimal escape too large"); + luaZ_buffremove(ls->buff, i); /* remove read digits from buffer */ + return r; +} + + +static void read_string (LexState *ls, int del, SemInfo *seminfo) { + save_and_next(ls); /* keep delimiter (for error messages) */ + while (ls->current != del) { + switch (ls->current) { + case EOZ: + lexerror(ls, "unfinished string", TK_EOS); + break; /* to avoid warnings */ + case '\n': + case '\r': + lexerror(ls, "unfinished string", TK_STRING); + break; /* to avoid warnings */ + case '\\': { /* escape sequences */ + int c; /* final character to be saved */ + save_and_next(ls); /* keep '\\' for error messages */ + switch (ls->current) { + case 'a': c = '\a'; goto read_save; + case 'b': c = '\b'; goto read_save; + case 'f': c = '\f'; goto read_save; + case 'n': c = '\n'; goto read_save; + case 'r': c = '\r'; goto read_save; + case 't': c = '\t'; goto read_save; + case 'v': c = '\v'; goto read_save; + case 'x': c = readhexaesc(ls); goto read_save; + case 'u': utf8esc(ls); goto no_save; + case '\n': case '\r': + inclinenumber(ls); c = '\n'; goto only_save; + case '\\': case '\"': case '\'': + c = ls->current; goto read_save; + case EOZ: goto no_save; /* will raise an error next loop */ + case 'z': { /* zap following span of spaces */ + luaZ_buffremove(ls->buff, 1); /* remove '\\' */ + next(ls); /* skip the 'z' */ + while (lisspace(ls->current)) { + if (currIsNewline(ls)) inclinenumber(ls); + else next(ls); + } + goto no_save; + } + default: { + esccheck(ls, lisdigit(ls->current), "invalid escape sequence"); + c = readdecesc(ls); /* digital escape '\ddd' */ + goto only_save; + } + } + read_save: + next(ls); + /* go through */ + only_save: + luaZ_buffremove(ls->buff, 1); /* remove '\\' */ + save(ls, c); + /* go through */ + no_save: break; + } + default: + save_and_next(ls); + } + } + save_and_next(ls); /* skip delimiter */ + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, + luaZ_bufflen(ls->buff) - 2); +} + + +static int llex (LexState *ls, SemInfo *seminfo) { + luaZ_resetbuffer(ls->buff); + for (;;) { + switch (ls->current) { + case '\n': case '\r': { /* line breaks */ + inclinenumber(ls); + break; + } + case ' ': case '\f': case '\t': case '\v': { /* spaces */ + next(ls); + break; + } + case '-': { /* '-' or '--' (comment) */ + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { /* long comment? */ + int sep = skip_sep(ls); + luaZ_resetbuffer(ls->buff); /* 'skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* skip long comment */ + luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */ + break; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); /* skip until end of line (or end of file) */ + break; + } + case '[': { /* long string or simply '[' */ + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, seminfo, sep); + return TK_STRING; + } + else if (sep != -1) /* '[=...' missing second bracket */ + lexerror(ls, "invalid long string delimiter", TK_STRING); + return '['; + } + case '=': { + next(ls); + if (check_next1(ls, '=')) return TK_EQ; + else return '='; + } + case '<': { + next(ls); + if (check_next1(ls, '=')) return TK_LE; + else if (check_next1(ls, '<')) return TK_SHL; + else return '<'; + } + case '>': { + next(ls); + if (check_next1(ls, '=')) return TK_GE; + else if (check_next1(ls, '>')) return TK_SHR; + else return '>'; + } + case '/': { + next(ls); + if (check_next1(ls, '/')) return TK_IDIV; + else return '/'; + } + case '~': { + next(ls); + if (check_next1(ls, '=')) return TK_NE; + else return '~'; + } + case ':': { + next(ls); + if (check_next1(ls, ':')) return TK_DBCOLON; + else return ':'; + } + case '"': case '\'': { /* short literal strings */ + read_string(ls, ls->current, seminfo); + return TK_STRING; + } + case '.': { /* '.', '..', '...', or number */ + save_and_next(ls); + if (check_next1(ls, '.')) { + if (check_next1(ls, '.')) + return TK_DOTS; /* '...' */ + else return TK_CONCAT; /* '..' */ + } + else if (!lisdigit(ls->current)) return '.'; + else return read_numeral(ls, seminfo); + } + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': { + return read_numeral(ls, seminfo); + } + case EOZ: { + return TK_EOS; + } + default: { + if (lislalpha(ls->current)) { /* identifier or reserved word? */ + TString *ts; + do { + save_and_next(ls); + } while (lislalnum(ls->current)); + ts = luaX_newstring(ls, luaZ_buffer(ls->buff), + luaZ_bufflen(ls->buff)); + seminfo->ts = ts; + if (isreserved(ts)) /* reserved word? */ + return ts->extra - 1 + FIRST_RESERVED; + else { + return TK_NAME; + } + } + else { /* single-char tokens (+ - / ...) */ + int c = ls->current; + next(ls); + return c; + } + } + } + } +} + + +void luaX_next (LexState *ls) { + ls->lastline = ls->linenumber; + if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ + ls->t = ls->lookahead; /* use this one */ + ls->lookahead.token = TK_EOS; /* and discharge it */ + } + else + ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ +} + + +int luaX_lookahead (LexState *ls) { + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); + return ls->lookahead.token; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/llex.h b/dep/scintilla/scintilla-3.10.6/lua/src/llex.h new file mode 100644 index 00000000..2363d87e --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/llex.h @@ -0,0 +1,85 @@ +/* +** $Id: llex.h,v 1.79 2016/05/02 14:02:12 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + + +#if !defined(LUA_ENV) +#define LUA_ENV "_ENV" +#endif + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, + TK_SHL, TK_SHR, + TK_DBCOLON, TK_EOS, + TK_FLT, TK_INT, TK_NAME, TK_STRING +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +typedef union { + lua_Number r; + lua_Integer i; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +/* state of the lexer plus state of the parser when shared by all + functions */ +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token 'consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* current function (parser) */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + Table *h; /* to avoid collection/reuse strings */ + struct Dyndata *dyd; /* dynamic structures used by the parser */ + TString *source; /* current source name */ + TString *envn; /* environment variable name */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source, int firstchar); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC int luaX_lookahead (LexState *ls); +LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/llimits.h b/dep/scintilla/scintilla-3.10.6/lua/src/llimits.h new file mode 100644 index 00000000..f21377fe --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/llimits.h @@ -0,0 +1,323 @@ +/* +** $Id: llimits.h,v 1.141 2015/11/19 19:16:22 roberto Exp $ +** Limits, basic types, and some other 'installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + + +#include +#include + + +#include "lua.h" + +/* +** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count +** the total memory used by Lua (in bytes). Usually, 'size_t' and +** 'ptrdiff_t' should work, but we use 'long' for 16-bit machines. +*/ +#if defined(LUAI_MEM) /* { external definitions? */ +typedef LUAI_UMEM lu_mem; +typedef LUAI_MEM l_mem; +#elif LUAI_BITSINT >= 32 /* }{ */ +typedef size_t lu_mem; +typedef ptrdiff_t l_mem; +#else /* 16-bit ints */ /* }{ */ +typedef unsigned long lu_mem; +typedef long l_mem; +#endif /* } */ + + +/* chars used as small naturals (so that 'char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +/* maximum value for size_t */ +#define MAX_SIZET ((size_t)(~(size_t)0)) + +/* maximum size visible for Lua (must be representable in a lua_Integer */ +#define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET \ + : (size_t)(LUA_MAXINTEGER)) + + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)) + +#define MAX_LMEM ((l_mem)(MAX_LUMEM >> 1)) + + +#define MAX_INT INT_MAX /* maximum value of an int */ + + +/* +** conversion of pointer to unsigned integer: +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define point2uint(p) ((unsigned int)((size_t)(p) & UINT_MAX)) + + + +/* type to ensure maximum alignment */ +#if defined(LUAI_USER_ALIGNMENT_T) +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; +#else +typedef union { + lua_Number n; + double u; + void *s; + lua_Integer i; + long l; +} L_Umaxalign; +#endif + + + +/* types of 'usual argument conversions' for lua_Number and lua_Integer */ +typedef LUAI_UACNUMBER l_uacNumber; +typedef LUAI_UACINT l_uacInt; + + +/* internal assertions for in-house debugging */ +#if defined(lua_assert) +#define check_exp(c,e) (lua_assert(c), (e)) +/* to avoid problems with conditions too long */ +#define lua_longassert(c) ((c) ? (void)0 : lua_assert(0)) +#else +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define lua_longassert(c) ((void)0) +#endif + +/* +** assertion for checking API calls +*/ +#if !defined(luai_apicheck) +#define luai_apicheck(l,e) lua_assert(e) +#endif + +#define api_check(l,e,msg) luai_apicheck(l,(e) && msg) + + +/* macro to avoid warnings about unused variables */ +#if !defined(UNUSED) +#define UNUSED(x) ((void)(x)) +#endif + + +/* type casts (a macro highlights casts in the code) */ +#define cast(t, exp) ((t)(exp)) + +#define cast_void(i) cast(void, (i)) +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) +#define cast_uchar(i) cast(unsigned char, (i)) + + +/* cast a signed lua_Integer to lua_Unsigned */ +#if !defined(l_castS2U) +#define l_castS2U(i) ((lua_Unsigned)(i)) +#endif + +/* +** cast a lua_Unsigned to a signed lua_Integer; this cast is +** not strict ISO C, but two-complement architectures should +** work fine. +*/ +#if !defined(l_castU2S) +#define l_castU2S(i) ((lua_Integer)(i)) +#endif + + +/* +** non-return type +*/ +#if defined(__GNUC__) +#define l_noret void __attribute__((noreturn)) +#elif defined(_MSC_VER) && _MSC_VER >= 1200 +#define l_noret void __declspec(noreturn) +#else +#define l_noret void +#endif + + + +/* +** maximum depth for nested C calls and syntactical nested non-terminals +** in a program. (Value must fit in an unsigned short int.) +*/ +#if !defined(LUAI_MAXCCALLS) +#define LUAI_MAXCCALLS 200 +#endif + + + +/* +** type for virtual-machine instructions; +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +#if LUAI_BITSINT >= 32 +typedef unsigned int Instruction; +#else +typedef unsigned long Instruction; +#endif + + + +/* +** Maximum length for short strings, that is, strings that are +** internalized. (Cannot be smaller than reserved words or tags for +** metamethods, as these strings must be internalized; +** #("function") = 8, #("__newindex") = 10.) +*/ +#if !defined(LUAI_MAXSHORTLEN) +#define LUAI_MAXSHORTLEN 40 +#endif + + +/* +** Initial size for the string table (must be power of 2). +** The Lua core alone registers ~50 strings (reserved words + +** metaevent keys + a few others). Libraries would typically add +** a few dozens more. +*/ +#if !defined(MINSTRTABSIZE) +#define MINSTRTABSIZE 128 +#endif + + +/* +** Size of cache for strings in the API. 'N' is the number of +** sets (better be a prime) and "M" is the size of each set (M == 1 +** makes a direct cache.) +*/ +#if !defined(STRCACHE_N) +#define STRCACHE_N 53 +#define STRCACHE_M 2 +#endif + + +/* minimum size for string buffer */ +#if !defined(LUA_MINBUFFER) +#define LUA_MINBUFFER 32 +#endif + + +/* +** macros that are executed whenever program enters the Lua core +** ('lua_lock') and leaves the core ('lua_unlock') +*/ +#if !defined(lua_lock) +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +/* +** macro executed during Lua functions at points where the +** function can yield. +*/ +#if !defined(luai_threadyield) +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** these macros allow user-specific actions on threads when you defined +** LUAI_EXTRASPACE and need to do something extra when a thread is +** created/deleted/resumed/yielded. +*/ +#if !defined(luai_userstateopen) +#define luai_userstateopen(L) ((void)L) +#endif + +#if !defined(luai_userstateclose) +#define luai_userstateclose(L) ((void)L) +#endif + +#if !defined(luai_userstatethread) +#define luai_userstatethread(L,L1) ((void)L) +#endif + +#if !defined(luai_userstatefree) +#define luai_userstatefree(L,L1) ((void)L) +#endif + +#if !defined(luai_userstateresume) +#define luai_userstateresume(L,n) ((void)L) +#endif + +#if !defined(luai_userstateyield) +#define luai_userstateyield(L,n) ((void)L) +#endif + + + +/* +** The luai_num* macros define the primitive operations over numbers. +*/ + +/* floor division (defined as 'floor(a/b)') */ +#if !defined(luai_numidiv) +#define luai_numidiv(L,a,b) ((void)L, l_floor(luai_numdiv(L,a,b))) +#endif + +/* float division */ +#if !defined(luai_numdiv) +#define luai_numdiv(L,a,b) ((a)/(b)) +#endif + +/* +** modulo: defined as 'a - floor(a/b)*b'; this definition gives NaN when +** 'b' is huge, but the result should be 'a'. 'fmod' gives the result of +** 'a - trunc(a/b)*b', and therefore must be corrected when 'trunc(a/b) +** ~= floor(a/b)'. That happens when the division has a non-integer +** negative result, which is equivalent to the test below. +*/ +#if !defined(luai_nummod) +#define luai_nummod(L,a,b,m) \ + { (m) = l_mathop(fmod)(a,b); if ((m)*(b) < 0) (m) += (b); } +#endif + +/* exponentiation */ +#if !defined(luai_numpow) +#define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b)) +#endif + +/* the others are quite standard operations */ +#if !defined(luai_numadd) +#define luai_numadd(L,a,b) ((a)+(b)) +#define luai_numsub(L,a,b) ((a)-(b)) +#define luai_nummul(L,a,b) ((a)*(b)) +#define luai_numunm(L,a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + + + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#if !defined(HARDSTACKTESTS) +#define condmovestack(L,pre,pos) ((void)0) +#else +/* realloc stack keeping its size */ +#define condmovestack(L,pre,pos) \ + { int sz_ = (L)->stacksize; pre; luaD_reallocstack((L), sz_); pos; } +#endif + +#if !defined(HARDMEMTESTS) +#define condchangemem(L,pre,pos) ((void)0) +#else +#define condchangemem(L,pre,pos) \ + { if (G(L)->gcrunning) { pre; luaC_fullgc(L, 0); pos; } } +#endif + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lmathlib.c b/dep/scintilla/scintilla-3.10.6/lua/src/lmathlib.c new file mode 100644 index 00000000..b7f8baee --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lmathlib.c @@ -0,0 +1,410 @@ +/* +** $Id: lmathlib.c,v 1.119 2016/12/22 13:08:50 roberto Exp $ +** Standard mathematical library +** See Copyright Notice in lua.h +*/ + +#define lmathlib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#undef PI +#define PI (l_mathop(3.141592653589793238462643383279502884)) + + +#if !defined(l_rand) /* { */ +#if defined(LUA_USE_POSIX) +#define l_rand() random() +#define l_srand(x) srandom(x) +#define L_RANDMAX 2147483647 /* (2^31 - 1), following POSIX */ +#else +#define l_rand() rand() +#define l_srand(x) srand(x) +#define L_RANDMAX RAND_MAX +#endif +#endif /* } */ + + +static int math_abs (lua_State *L) { + if (lua_isinteger(L, 1)) { + lua_Integer n = lua_tointeger(L, 1); + if (n < 0) n = (lua_Integer)(0u - (lua_Unsigned)n); + lua_pushinteger(L, n); + } + else + lua_pushnumber(L, l_mathop(fabs)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, l_mathop(sin)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, l_mathop(cos)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, l_mathop(tan)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, l_mathop(asin)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, l_mathop(acos)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_Number y = luaL_checknumber(L, 1); + lua_Number x = luaL_optnumber(L, 2, 1); + lua_pushnumber(L, l_mathop(atan2)(y, x)); + return 1; +} + + +static int math_toint (lua_State *L) { + int valid; + lua_Integer n = lua_tointegerx(L, 1, &valid); + if (valid) + lua_pushinteger(L, n); + else { + luaL_checkany(L, 1); + lua_pushnil(L); /* value is not convertible to integer */ + } + return 1; +} + + +static void pushnumint (lua_State *L, lua_Number d) { + lua_Integer n; + if (lua_numbertointeger(d, &n)) /* does 'd' fit in an integer? */ + lua_pushinteger(L, n); /* result is integer */ + else + lua_pushnumber(L, d); /* result is float */ +} + + +static int math_floor (lua_State *L) { + if (lua_isinteger(L, 1)) + lua_settop(L, 1); /* integer is its own floor */ + else { + lua_Number d = l_mathop(floor)(luaL_checknumber(L, 1)); + pushnumint(L, d); + } + return 1; +} + + +static int math_ceil (lua_State *L) { + if (lua_isinteger(L, 1)) + lua_settop(L, 1); /* integer is its own ceil */ + else { + lua_Number d = l_mathop(ceil)(luaL_checknumber(L, 1)); + pushnumint(L, d); + } + return 1; +} + + +static int math_fmod (lua_State *L) { + if (lua_isinteger(L, 1) && lua_isinteger(L, 2)) { + lua_Integer d = lua_tointeger(L, 2); + if ((lua_Unsigned)d + 1u <= 1u) { /* special cases: -1 or 0 */ + luaL_argcheck(L, d != 0, 2, "zero"); + lua_pushinteger(L, 0); /* avoid overflow with 0x80000... / -1 */ + } + else + lua_pushinteger(L, lua_tointeger(L, 1) % d); + } + else + lua_pushnumber(L, l_mathop(fmod)(luaL_checknumber(L, 1), + luaL_checknumber(L, 2))); + return 1; +} + + +/* +** next function does not use 'modf', avoiding problems with 'double*' +** (which is not compatible with 'float*') when lua_Number is not +** 'double'. +*/ +static int math_modf (lua_State *L) { + if (lua_isinteger(L ,1)) { + lua_settop(L, 1); /* number is its own integer part */ + lua_pushnumber(L, 0); /* no fractional part */ + } + else { + lua_Number n = luaL_checknumber(L, 1); + /* integer part (rounds toward zero) */ + lua_Number ip = (n < 0) ? l_mathop(ceil)(n) : l_mathop(floor)(n); + pushnumint(L, ip); + /* fractional part (test needed for inf/-inf) */ + lua_pushnumber(L, (n == ip) ? l_mathop(0.0) : (n - ip)); + } + return 2; +} + + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, l_mathop(sqrt)(luaL_checknumber(L, 1))); + return 1; +} + + +static int math_ult (lua_State *L) { + lua_Integer a = luaL_checkinteger(L, 1); + lua_Integer b = luaL_checkinteger(L, 2); + lua_pushboolean(L, (lua_Unsigned)a < (lua_Unsigned)b); + return 1; +} + +static int math_log (lua_State *L) { + lua_Number x = luaL_checknumber(L, 1); + lua_Number res; + if (lua_isnoneornil(L, 2)) + res = l_mathop(log)(x); + else { + lua_Number base = luaL_checknumber(L, 2); +#if !defined(LUA_USE_C89) + if (base == l_mathop(2.0)) + res = l_mathop(log2)(x); else +#endif + if (base == l_mathop(10.0)) + res = l_mathop(log10)(x); + else + res = l_mathop(log)(x)/l_mathop(log)(base); + } + lua_pushnumber(L, res); + return 1; +} + +static int math_exp (lua_State *L) { + lua_pushnumber(L, l_mathop(exp)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1) * (l_mathop(180.0) / PI)); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1) * (PI / l_mathop(180.0))); + return 1; +} + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int imin = 1; /* index of current minimum value */ + int i; + luaL_argcheck(L, n >= 1, 1, "value expected"); + for (i = 2; i <= n; i++) { + if (lua_compare(L, i, imin, LUA_OPLT)) + imin = i; + } + lua_pushvalue(L, imin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int imax = 1; /* index of current maximum value */ + int i; + luaL_argcheck(L, n >= 1, 1, "value expected"); + for (i = 2; i <= n; i++) { + if (lua_compare(L, imax, i, LUA_OPLT)) + imax = i; + } + lua_pushvalue(L, imax); + return 1; +} + +/* +** This function uses 'double' (instead of 'lua_Number') to ensure that +** all bits from 'l_rand' can be represented, and that 'RANDMAX + 1.0' +** will keep full precision (ensuring that 'r' is always less than 1.0.) +*/ +static int math_random (lua_State *L) { + lua_Integer low, up; + double r = (double)l_rand() * (1.0 / ((double)L_RANDMAX + 1.0)); + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, (lua_Number)r); /* Number between 0 and 1 */ + return 1; + } + case 1: { /* only upper limit */ + low = 1; + up = luaL_checkinteger(L, 1); + break; + } + case 2: { /* lower and upper limits */ + low = luaL_checkinteger(L, 1); + up = luaL_checkinteger(L, 2); + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + /* random integer in the interval [low, up] */ + luaL_argcheck(L, low <= up, 1, "interval is empty"); + luaL_argcheck(L, low >= 0 || up <= LUA_MAXINTEGER + low, 1, + "interval too large"); + r *= (double)(up - low) + 1.0; + lua_pushinteger(L, (lua_Integer)r + low); + return 1; +} + + +static int math_randomseed (lua_State *L) { + l_srand((unsigned int)(lua_Integer)luaL_checknumber(L, 1)); + (void)l_rand(); /* discard first value to avoid undesirable correlations */ + return 0; +} + + +static int math_type (lua_State *L) { + if (lua_type(L, 1) == LUA_TNUMBER) { + if (lua_isinteger(L, 1)) + lua_pushliteral(L, "integer"); + else + lua_pushliteral(L, "float"); + } + else { + luaL_checkany(L, 1); + lua_pushnil(L); + } + return 1; +} + + +/* +** {================================================================== +** Deprecated functions (for compatibility only) +** =================================================================== +*/ +#if defined(LUA_COMPAT_MATHLIB) + +static int math_cosh (lua_State *L) { + lua_pushnumber(L, l_mathop(cosh)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sinh (lua_State *L) { + lua_pushnumber(L, l_mathop(sinh)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tanh (lua_State *L) { + lua_pushnumber(L, l_mathop(tanh)(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_Number x = luaL_checknumber(L, 1); + lua_Number y = luaL_checknumber(L, 2); + lua_pushnumber(L, l_mathop(pow)(x, y)); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, l_mathop(frexp)(luaL_checknumber(L, 1), &e)); + lua_pushinteger(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_Number x = luaL_checknumber(L, 1); + int ep = (int)luaL_checkinteger(L, 2); + lua_pushnumber(L, l_mathop(ldexp)(x, ep)); + return 1; +} + +static int math_log10 (lua_State *L) { + lua_pushnumber(L, l_mathop(log10)(luaL_checknumber(L, 1))); + return 1; +} + +#endif +/* }================================================================== */ + + + +static const luaL_Reg mathlib[] = { + {"abs", math_abs}, + {"acos", math_acos}, + {"asin", math_asin}, + {"atan", math_atan}, + {"ceil", math_ceil}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, + {"tointeger", math_toint}, + {"floor", math_floor}, + {"fmod", math_fmod}, + {"ult", math_ult}, + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tan", math_tan}, + {"type", math_type}, +#if defined(LUA_COMPAT_MATHLIB) + {"atan2", math_atan}, + {"cosh", math_cosh}, + {"sinh", math_sinh}, + {"tanh", math_tanh}, + {"pow", math_pow}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, + {"log10", math_log10}, +#endif + /* placeholders */ + {"pi", NULL}, + {"huge", NULL}, + {"maxinteger", NULL}, + {"mininteger", NULL}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUAMOD_API int luaopen_math (lua_State *L) { + luaL_newlib(L, mathlib); + lua_pushnumber(L, PI); + lua_setfield(L, -2, "pi"); + lua_pushnumber(L, (lua_Number)HUGE_VAL); + lua_setfield(L, -2, "huge"); + lua_pushinteger(L, LUA_MAXINTEGER); + lua_setfield(L, -2, "maxinteger"); + lua_pushinteger(L, LUA_MININTEGER); + lua_setfield(L, -2, "mininteger"); + return 1; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lmem.c b/dep/scintilla/scintilla-3.10.6/lua/src/lmem.c new file mode 100644 index 00000000..0a0476cc --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lmem.c @@ -0,0 +1,100 @@ +/* +** $Id: lmem.c,v 1.91 2015/03/06 19:45:54 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#define lmem_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +/* +** About the realloc function: +** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** ('osize' is the old size, 'nsize' is the new size) +** +** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no +** matter 'x'). +** +** * frealloc(ud, p, x, 0) frees the block 'p' +** (in this specific case, frealloc must return NULL); +** particularly, frealloc(ud, NULL, 0, 0) does nothing +** (which is equivalent to free(NULL) in ISO C) +** +** frealloc returns NULL if it cannot create or reallocate the area +** (any reallocation to an equal or smaller size cannot fail!) +*/ + + + +#define MINSIZEARRAY 4 + + +void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, + int limit, const char *what) { + void *newblock; + int newsize; + if (*size >= limit/2) { /* cannot double it? */ + if (*size >= limit) /* cannot grow even a little? */ + luaG_runerror(L, "too many %s (limit is %d)", what, limit); + newsize = limit; /* still have at least one free place */ + } + else { + newsize = (*size)*2; + if (newsize < MINSIZEARRAY) + newsize = MINSIZEARRAY; /* minimum size */ + } + newblock = luaM_reallocv(L, block, *size, newsize, size_elems); + *size = newsize; /* update only when everything else is OK */ + return newblock; +} + + +l_noret luaM_toobig (lua_State *L) { + luaG_runerror(L, "memory allocation error: block too big"); +} + + + +/* +** generic allocation routine. +*/ +void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + void *newblock; + global_State *g = G(L); + size_t realosize = (block) ? osize : 0; + lua_assert((realosize == 0) == (block == NULL)); +#if defined(HARDMEMTESTS) + if (nsize > realosize && g->gcrunning) + luaC_fullgc(L, 1); /* force a GC whenever possible */ +#endif + newblock = (*g->frealloc)(g->ud, block, osize, nsize); + if (newblock == NULL && nsize > 0) { + lua_assert(nsize > realosize); /* cannot fail when shrinking a block */ + if (g->version) { /* is state fully built? */ + luaC_fullgc(L, 1); /* try to free some memory... */ + newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ + } + if (newblock == NULL) + luaD_throw(L, LUA_ERRMEM); + } + lua_assert((nsize == 0) == (newblock == NULL)); + g->GCdebt = (g->GCdebt + nsize) - realosize; + return newblock; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lmem.h b/dep/scintilla/scintilla-3.10.6/lua/src/lmem.h new file mode 100644 index 00000000..30f48489 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lmem.h @@ -0,0 +1,69 @@ +/* +** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + + +#include + +#include "llimits.h" +#include "lua.h" + + +/* +** This macro reallocs a vector 'b' from 'on' to 'n' elements, where +** each element has size 'e'. In case of arithmetic overflow of the +** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because +** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). +** +** (The macro is somewhat complex to avoid warnings: The 'sizeof' +** comparison avoids a runtime comparison when overflow cannot occur. +** The compiler should be able to optimize the real test by itself, but +** when it does it, it may give a warning about "comparison is always +** false due to limited range of data type"; the +1 tricks the compiler, +** avoiding this warning but also this optimization.) +*/ +#define luaM_reallocv(L,b,on,n,e) \ + (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ + ? luaM_toobig(L) : cast_void(0)) , \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e))) + +/* +** Arrays of chars do not need any test +*/ +#define luaM_reallocvchar(L,b,on,n) \ + cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) + +#define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + +LUAI_FUNC l_noret luaM_toobig (lua_State *L); + +/* not to be called directly */ +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *what); + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/loadlib.c b/dep/scintilla/scintilla-3.10.6/lua/src/loadlib.c new file mode 100644 index 00000000..4791e748 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/loadlib.c @@ -0,0 +1,790 @@ +/* +** $Id: loadlib.c,v 1.130 2017/01/12 17:14:26 roberto Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +** +** This module contains an implementation of loadlib for Unix systems +** that have dlfcn, an implementation for Windows, and a stub for other +** systems. +*/ + +#define loadlib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* +** LUA_IGMARK is a mark to ignore all before it when building the +** luaopen_ function name. +*/ +#if !defined (LUA_IGMARK) +#define LUA_IGMARK "-" +#endif + + +/* +** LUA_CSUBSEP is the character that replaces dots in submodule names +** when searching for a C loader. +** LUA_LSUBSEP is the character that replaces dots in submodule names +** when searching for a Lua loader. +*/ +#if !defined(LUA_CSUBSEP) +#define LUA_CSUBSEP LUA_DIRSEP +#endif + +#if !defined(LUA_LSUBSEP) +#define LUA_LSUBSEP LUA_DIRSEP +#endif + + +/* prefix for open functions in C libraries */ +#define LUA_POF "luaopen_" + +/* separator for open functions in C libraries */ +#define LUA_OFSEP "_" + + +/* +** unique key for table in the registry that keeps handles +** for all loaded C libraries +*/ +static const int CLIBS = 0; + +#define LIB_FAIL "open" + + +#define setprogdir(L) ((void)0) + + +/* +** system-dependent functions +*/ + +/* +** unload library 'lib' +*/ +static void lsys_unloadlib (void *lib); + +/* +** load C library in file 'path'. If 'seeglb', load with all names in +** the library global. +** Returns the library; in case of error, returns NULL plus an +** error string in the stack. +*/ +static void *lsys_load (lua_State *L, const char *path, int seeglb); + +/* +** Try to find a function named 'sym' in library 'lib'. +** Returns the function; in case of error, returns NULL plus an +** error string in the stack. +*/ +static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym); + + + + +#if defined(LUA_USE_DLOPEN) /* { */ +/* +** {======================================================================== +** This is an implementation of loadlib based on the dlfcn interface. +** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +** as an emulation layer on top of native functions. +** ========================================================================= +*/ + +#include + +/* +** Macro to convert pointer-to-void* to pointer-to-function. This cast +** is undefined according to ISO C, but POSIX assumes that it works. +** (The '__extension__' in gnu compilers is only to avoid warnings.) +*/ +#if defined(__GNUC__) +#define cast_func(p) (__extension__ (lua_CFunction)(p)) +#else +#define cast_func(p) ((lua_CFunction)(p)) +#endif + + +static void lsys_unloadlib (void *lib) { + dlclose(lib); +} + + +static void *lsys_load (lua_State *L, const char *path, int seeglb) { + void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL)); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + + +static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = cast_func(dlsym(lib, sym)); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DLL) /* }{ */ +/* +** {====================================================================== +** This is an implementation of loadlib for Windows using native functions. +** ======================================================================= +*/ + +#include + + +/* +** optional flags for LoadLibraryEx +*/ +#if !defined(LUA_LLE_FLAGS) +#define LUA_LLE_FLAGS 0 +#endif + + +#undef setprogdir + + +/* +** Replace in the path (on the top of the stack) any occurrence +** of LUA_EXEC_DIR with the executable's path. +*/ +static void setprogdir (lua_State *L) { + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff)/sizeof(char); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); /* get exec. name */ + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) + luaL_error(L, "unable to get ModuleFileName"); + else { + *lb = '\0'; /* cut name on the last '\\' to get the path */ + luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + + + + +static void pusherror (lua_State *L) { + int error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer)/sizeof(char), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void lsys_unloadlib (void *lib) { + FreeLibrary((HMODULE)lib); +} + + +static void *lsys_load (lua_State *L, const char *path, int seeglb) { + HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS); + (void)(seeglb); /* not used: symbols are 'global' by default */ + if (lib == NULL) pusherror(L); + return lib; +} + + +static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +/* }====================================================== */ + + +#else /* }{ */ +/* +** {====================================================== +** Fallback for other systems +** ======================================================= +*/ + +#undef LIB_FAIL +#define LIB_FAIL "absent" + + +#define DLMSG "dynamic libraries not enabled; check your Lua installation" + + +static void lsys_unloadlib (void *lib) { + (void)(lib); /* not used */ +} + + +static void *lsys_load (lua_State *L, const char *path, int seeglb) { + (void)(path); (void)(seeglb); /* not used */ + lua_pushliteral(L, DLMSG); + return NULL; +} + + +static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { + (void)(lib); (void)(sym); /* not used */ + lua_pushliteral(L, DLMSG); + return NULL; +} + +/* }====================================================== */ +#endif /* } */ + + +/* +** {================================================================== +** Set Paths +** =================================================================== +*/ + +/* +** LUA_PATH_VAR and LUA_CPATH_VAR are the names of the environment +** variables that Lua check to set its paths. +*/ +#if !defined(LUA_PATH_VAR) +#define LUA_PATH_VAR "LUA_PATH" +#endif + +#if !defined(LUA_CPATH_VAR) +#define LUA_CPATH_VAR "LUA_CPATH" +#endif + + +#define AUXMARK "\1" /* auxiliary mark */ + + +/* +** return registry.LUA_NOENV as a boolean +*/ +static int noenv (lua_State *L) { + int b; + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); + b = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + return b; +} + + +/* +** Set a path +*/ +static void setpath (lua_State *L, const char *fieldname, + const char *envname, + const char *dft) { + const char *nver = lua_pushfstring(L, "%s%s", envname, LUA_VERSUFFIX); + const char *path = getenv(nver); /* use versioned name */ + if (path == NULL) /* no environment variable? */ + path = getenv(envname); /* try unversioned name */ + if (path == NULL || noenv(L)) /* no environment variable? */ + lua_pushstring(L, dft); /* use default */ + else { + /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ + path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP, + LUA_PATH_SEP AUXMARK LUA_PATH_SEP); + luaL_gsub(L, path, AUXMARK, dft); + lua_remove(L, -2); /* remove result from 1st 'gsub' */ + } + setprogdir(L); + lua_setfield(L, -3, fieldname); /* package[fieldname] = path value */ + lua_pop(L, 1); /* pop versioned variable name */ +} + +/* }================================================================== */ + + +/* +** return registry.CLIBS[path] +*/ +static void *checkclib (lua_State *L, const char *path) { + void *plib; + lua_rawgetp(L, LUA_REGISTRYINDEX, &CLIBS); + lua_getfield(L, -1, path); + plib = lua_touserdata(L, -1); /* plib = CLIBS[path] */ + lua_pop(L, 2); /* pop CLIBS table and 'plib' */ + return plib; +} + + +/* +** registry.CLIBS[path] = plib -- for queries +** registry.CLIBS[#CLIBS + 1] = plib -- also keep a list of all libraries +*/ +static void addtoclib (lua_State *L, const char *path, void *plib) { + lua_rawgetp(L, LUA_REGISTRYINDEX, &CLIBS); + lua_pushlightuserdata(L, plib); + lua_pushvalue(L, -1); + lua_setfield(L, -3, path); /* CLIBS[path] = plib */ + lua_rawseti(L, -2, luaL_len(L, -2) + 1); /* CLIBS[#CLIBS + 1] = plib */ + lua_pop(L, 1); /* pop CLIBS table */ +} + + +/* +** __gc tag method for CLIBS table: calls 'lsys_unloadlib' for all lib +** handles in list CLIBS +*/ +static int gctm (lua_State *L) { + lua_Integer n = luaL_len(L, 1); + for (; n >= 1; n--) { /* for each handle, in reverse order */ + lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */ + lsys_unloadlib(lua_touserdata(L, -1)); + lua_pop(L, 1); /* pop handle */ + } + return 0; +} + + + +/* error codes for 'lookforfunc' */ +#define ERRLIB 1 +#define ERRFUNC 2 + +/* +** Look for a C function named 'sym' in a dynamically loaded library +** 'path'. +** First, check whether the library is already loaded; if not, try +** to load it. +** Then, if 'sym' is '*', return true (as library has been loaded). +** Otherwise, look for symbol 'sym' in the library and push a +** C function with that symbol. +** Return 0 and 'true' or a function in the stack; in case of +** errors, return an error code and an error message in the stack. +*/ +static int lookforfunc (lua_State *L, const char *path, const char *sym) { + void *reg = checkclib(L, path); /* check loaded C libraries */ + if (reg == NULL) { /* must load library? */ + reg = lsys_load(L, path, *sym == '*'); /* global symbols if 'sym'=='*' */ + if (reg == NULL) return ERRLIB; /* unable to load library */ + addtoclib(L, path, reg); + } + if (*sym == '*') { /* loading only library (no function)? */ + lua_pushboolean(L, 1); /* return 'true' */ + return 0; /* no errors */ + } + else { + lua_CFunction f = lsys_sym(L, reg, sym); + if (f == NULL) + return ERRFUNC; /* unable to find function */ + lua_pushcfunction(L, f); /* else create new function */ + return 0; /* no errors */ + } +} + + +static int ll_loadlib (lua_State *L) { + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int stat = lookforfunc(L, path, init); + if (stat == 0) /* no errors? */ + return 1; /* return the loaded function */ + else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + + + +/* +** {====================================================== +** 'require' function +** ======================================================= +*/ + + +static int readable (const char *filename) { + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + + +static const char *pushnexttemplate (lua_State *L, const char *path) { + const char *l; + while (*path == *LUA_PATH_SEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATH_SEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, l - path); /* template */ + return l; +} + + +static const char *searchpath (lua_State *L, const char *name, + const char *path, + const char *sep, + const char *dirsep) { + luaL_Buffer msg; /* to build error message */ + luaL_buffinit(L, &msg); + if (*sep != '\0') /* non-empty separator? */ + name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename = luaL_gsub(L, lua_tostring(L, -1), + LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file '%s'", filename); + lua_remove(L, -2); /* remove file name */ + luaL_addvalue(&msg); /* concatenate error msg. entry */ + } + luaL_pushresult(&msg); /* create error message */ + return NULL; /* not found */ +} + + +static int ll_searchpath (lua_State *L) { + const char *f = searchpath(L, luaL_checkstring(L, 1), + luaL_checkstring(L, 2), + luaL_optstring(L, 3, "."), + luaL_optstring(L, 4, LUA_DIRSEP)); + if (f != NULL) return 1; + else { /* error message is on top of the stack */ + lua_pushnil(L); + lua_insert(L, -2); + return 2; /* return nil + error message */ + } +} + + +static const char *findfile (lua_State *L, const char *name, + const char *pname, + const char *dirsep) { + const char *path; + lua_getfield(L, lua_upvalueindex(1), pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, "'package.%s' must be a string", pname); + return searchpath(L, name, path, ".", dirsep); +} + + +static int checkload (lua_State *L, int stat, const char *filename) { + if (stat) { /* module loaded successfully? */ + lua_pushstring(L, filename); /* will be 2nd argument to module */ + return 2; /* return open function and file name */ + } + else + return luaL_error(L, "error loading module '%s' from file '%s':\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int searcher_Lua (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path", LUA_LSUBSEP); + if (filename == NULL) return 1; /* module not found in this path */ + return checkload(L, (luaL_loadfile(L, filename) == LUA_OK), filename); +} + + +/* +** Try to find a load function for module 'modname' at file 'filename'. +** First, change '.' to '_' in 'modname'; then, if 'modname' has +** the form X-Y (that is, it has an "ignore mark"), build a function +** name "luaopen_X" and look for it. (For compatibility, if that +** fails, it also tries "luaopen_Y".) If there is no ignore mark, +** look for a function named "luaopen_modname". +*/ +static int loadfunc (lua_State *L, const char *filename, const char *modname) { + const char *openfunc; + const char *mark; + modname = luaL_gsub(L, modname, ".", LUA_OFSEP); + mark = strchr(modname, *LUA_IGMARK); + if (mark) { + int stat; + openfunc = lua_pushlstring(L, modname, mark - modname); + openfunc = lua_pushfstring(L, LUA_POF"%s", openfunc); + stat = lookforfunc(L, filename, openfunc); + if (stat != ERRFUNC) return stat; + modname = mark + 1; /* else go ahead and try old-style name */ + } + openfunc = lua_pushfstring(L, LUA_POF"%s", modname); + return lookforfunc(L, filename, openfunc); +} + + +static int searcher_C (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath", LUA_CSUBSEP); + if (filename == NULL) return 1; /* module not found in this path */ + return checkload(L, (loadfunc(L, filename, name) == 0), filename); +} + + +static int searcher_Croot (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int stat; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, p - name); + filename = findfile(L, lua_tostring(L, -1), "cpath", LUA_CSUBSEP); + if (filename == NULL) return 1; /* root not found */ + if ((stat = loadfunc(L, filename, name)) != 0) { + if (stat != ERRFUNC) + return checkload(L, 0, filename); /* real error */ + else { /* open function not found */ + lua_pushfstring(L, "\n\tno module '%s' in file '%s'", name, filename); + return 1; + } + } + lua_pushstring(L, filename); /* will be 2nd argument to module */ + return 2; +} + + +static int searcher_preload (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); + if (lua_getfield(L, -1, name) == LUA_TNIL) /* not found? */ + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + return 1; +} + + +static void findloader (lua_State *L, const char *name) { + int i; + luaL_Buffer msg; /* to build error message */ + luaL_buffinit(L, &msg); + /* push 'package.searchers' to index 3 in the stack */ + if (lua_getfield(L, lua_upvalueindex(1), "searchers") != LUA_TTABLE) + luaL_error(L, "'package.searchers' must be a table"); + /* iterate over available searchers to find a loader */ + for (i = 1; ; i++) { + if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */ + lua_pop(L, 1); /* remove nil */ + luaL_pushresult(&msg); /* create error message */ + luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1)); + } + lua_pushstring(L, name); + lua_call(L, 1, 2); /* call it */ + if (lua_isfunction(L, -2)) /* did it find a loader? */ + return; /* module loader found */ + else if (lua_isstring(L, -2)) { /* searcher returned error message? */ + lua_pop(L, 1); /* remove extra return */ + luaL_addvalue(&msg); /* concatenate error message */ + } + else + lua_pop(L, 2); /* remove both returns */ + } +} + + +static int ll_require (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_settop(L, 1); /* LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); + lua_getfield(L, 2, name); /* LOADED[name] */ + if (lua_toboolean(L, -1)) /* is it there? */ + return 1; /* package is already loaded */ + /* else must load package */ + lua_pop(L, 1); /* remove 'getfield' result */ + findloader(L, name); + lua_pushstring(L, name); /* pass name as argument to module loader */ + lua_insert(L, -2); /* name is 1st argument (before search data) */ + lua_call(L, 2, 1); /* run loader to load module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* LOADED[name] = returned value */ + if (lua_getfield(L, 2, name) == LUA_TNIL) { /* module set no value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* LOADED[name] = true */ + } + return 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** 'module' function +** ======================================================= +*/ +#if defined(LUA_COMPAT_MODULE) + +/* +** changes the environment variable of calling function +*/ +static void set_env (lua_State *L) { + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, "'module' not called from a Lua function"); + lua_pushvalue(L, -2); /* copy new environment table to top */ + lua_setupvalue(L, -2, 1); + lua_pop(L, 1); /* remove function */ +} + + +static void dooptions (lua_State *L, int n) { + int i; + for (i = 2; i <= n; i++) { + if (lua_isfunction(L, i)) { /* avoid 'calling' extra info. */ + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } + } +} + + +static void modinit (lua_State *L, const char *modname) { + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; + else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, dot - modname); + lua_setfield(L, -2, "_PACKAGE"); +} + + +static int ll_module (lua_State *L) { + const char *modname = luaL_checkstring(L, 1); + int lastarg = lua_gettop(L); /* last parameter */ + luaL_pushmodule(L, modname, 1); /* get/create module table */ + /* check whether table already has a _NAME field */ + if (lua_getfield(L, -1, "_NAME") != LUA_TNIL) + lua_pop(L, 1); /* table is an initialized module */ + else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + set_env(L); + dooptions(L, lastarg); + return 1; +} + + +static int ll_seeall (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushglobaltable(L); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + +#endif +/* }====================================================== */ + + + +static const luaL_Reg pk_funcs[] = { + {"loadlib", ll_loadlib}, + {"searchpath", ll_searchpath}, +#if defined(LUA_COMPAT_MODULE) + {"seeall", ll_seeall}, +#endif + /* placeholders */ + {"preload", NULL}, + {"cpath", NULL}, + {"path", NULL}, + {"searchers", NULL}, + {"loaded", NULL}, + {NULL, NULL} +}; + + +static const luaL_Reg ll_funcs[] = { +#if defined(LUA_COMPAT_MODULE) + {"module", ll_module}, +#endif + {"require", ll_require}, + {NULL, NULL} +}; + + +static void createsearcherstable (lua_State *L) { + static const lua_CFunction searchers[] = + {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; + int i; + /* create 'searchers' table */ + lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0); + /* fill it with predefined searchers */ + for (i=0; searchers[i] != NULL; i++) { + lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */ + lua_pushcclosure(L, searchers[i], 1); + lua_rawseti(L, -2, i+1); + } +#if defined(LUA_COMPAT_LOADERS) + lua_pushvalue(L, -1); /* make a copy of 'searchers' table */ + lua_setfield(L, -3, "loaders"); /* put it in field 'loaders' */ +#endif + lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */ +} + + +/* +** create table CLIBS to keep track of loaded C libraries, +** setting a finalizer to close all libraries when closing state. +*/ +static void createclibstable (lua_State *L) { + lua_newtable(L); /* create CLIBS table */ + lua_createtable(L, 0, 1); /* create metatable for CLIBS */ + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */ + lua_setmetatable(L, -2); + lua_rawsetp(L, LUA_REGISTRYINDEX, &CLIBS); /* set CLIBS table in registry */ +} + + +LUAMOD_API int luaopen_package (lua_State *L) { + createclibstable(L); + luaL_newlib(L, pk_funcs); /* create 'package' table */ + createsearcherstable(L); + /* set paths */ + setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT); + setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT); + /* store config information */ + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n" + LUA_EXEC_DIR "\n" LUA_IGMARK "\n"); + lua_setfield(L, -2, "config"); + /* set field 'loaded' */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); + lua_setfield(L, -2, "loaded"); + /* set field 'preload' */ + luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); + lua_setfield(L, -2, "preload"); + lua_pushglobaltable(L); + lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ + luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ + lua_pop(L, 1); /* pop global table */ + return 1; /* return 'package' table */ +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lobject.c b/dep/scintilla/scintilla-3.10.6/lua/src/lobject.c new file mode 100644 index 00000000..2da76899 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lobject.c @@ -0,0 +1,521 @@ +/* +** $Id: lobject.c,v 2.113 2016/12/22 13:08:50 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + +#define lobject_c +#define LUA_CORE + +#include "lprefix.h" + + +#include +#include +#include +#include +#include +#include + +#include "lua.h" + +#include "lctype.h" +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "lvm.h" + + + +LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT}; + + +/* +** converts an integer to a "floating point byte", represented as +** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if +** eeeee != 0 and (xxx) otherwise. +*/ +int luaO_int2fb (unsigned int x) { + int e = 0; /* exponent */ + if (x < 8) return x; + while (x >= (8 << 4)) { /* coarse steps */ + x = (x + 0xf) >> 4; /* x = ceil(x / 16) */ + e += 4; + } + while (x >= (8 << 1)) { /* fine steps */ + x = (x + 1) >> 1; /* x = ceil(x / 2) */ + e++; + } + return ((e+1) << 3) | (cast_int(x) - 8); +} + + +/* converts back */ +int luaO_fb2int (int x) { + return (x < 8) ? x : ((x & 7) + 8) << ((x >> 3) - 1); +} + + +/* +** Computes ceil(log2(x)) +*/ +int luaO_ceillog2 (unsigned int x) { + static const lu_byte log_2[256] = { /* log_2[i] = ceil(log2(i - 1)) */ + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + }; + int l = 0; + x--; + while (x >= 256) { l += 8; x >>= 8; } + return l + log_2[x]; +} + + +static lua_Integer intarith (lua_State *L, int op, lua_Integer v1, + lua_Integer v2) { + switch (op) { + case LUA_OPADD: return intop(+, v1, v2); + case LUA_OPSUB:return intop(-, v1, v2); + case LUA_OPMUL:return intop(*, v1, v2); + case LUA_OPMOD: return luaV_mod(L, v1, v2); + case LUA_OPIDIV: return luaV_div(L, v1, v2); + case LUA_OPBAND: return intop(&, v1, v2); + case LUA_OPBOR: return intop(|, v1, v2); + case LUA_OPBXOR: return intop(^, v1, v2); + case LUA_OPSHL: return luaV_shiftl(v1, v2); + case LUA_OPSHR: return luaV_shiftl(v1, -v2); + case LUA_OPUNM: return intop(-, 0, v1); + case LUA_OPBNOT: return intop(^, ~l_castS2U(0), v1); + default: lua_assert(0); return 0; + } +} + + +static lua_Number numarith (lua_State *L, int op, lua_Number v1, + lua_Number v2) { + switch (op) { + case LUA_OPADD: return luai_numadd(L, v1, v2); + case LUA_OPSUB: return luai_numsub(L, v1, v2); + case LUA_OPMUL: return luai_nummul(L, v1, v2); + case LUA_OPDIV: return luai_numdiv(L, v1, v2); + case LUA_OPPOW: return luai_numpow(L, v1, v2); + case LUA_OPIDIV: return luai_numidiv(L, v1, v2); + case LUA_OPUNM: return luai_numunm(L, v1); + case LUA_OPMOD: { + lua_Number m; + luai_nummod(L, v1, v2, m); + return m; + } + default: lua_assert(0); return 0; + } +} + + +void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, + TValue *res) { + switch (op) { + case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: + case LUA_OPSHL: case LUA_OPSHR: + case LUA_OPBNOT: { /* operate only on integers */ + lua_Integer i1; lua_Integer i2; + if (tointeger(p1, &i1) && tointeger(p2, &i2)) { + setivalue(res, intarith(L, op, i1, i2)); + return; + } + else break; /* go to the end */ + } + case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */ + lua_Number n1; lua_Number n2; + if (tonumber(p1, &n1) && tonumber(p2, &n2)) { + setfltvalue(res, numarith(L, op, n1, n2)); + return; + } + else break; /* go to the end */ + } + default: { /* other operations */ + lua_Number n1; lua_Number n2; + if (ttisinteger(p1) && ttisinteger(p2)) { + setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2))); + return; + } + else if (tonumber(p1, &n1) && tonumber(p2, &n2)) { + setfltvalue(res, numarith(L, op, n1, n2)); + return; + } + else break; /* go to the end */ + } + } + /* could not perform raw operation; try metamethod */ + lua_assert(L != NULL); /* should not fail when folding (compile time) */ + luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD)); +} + + +int luaO_hexavalue (int c) { + if (lisdigit(c)) return c - '0'; + else return (ltolower(c) - 'a') + 10; +} + + +static int isneg (const char **s) { + if (**s == '-') { (*s)++; return 1; } + else if (**s == '+') (*s)++; + return 0; +} + + + +/* +** {================================================================== +** Lua's implementation for 'lua_strx2number' +** =================================================================== +*/ + +#if !defined(lua_strx2number) + +/* maximum number of significant digits to read (to avoid overflows + even with single floats) */ +#define MAXSIGDIG 30 + +/* +** convert an hexadecimal numeric string to a number, following +** C99 specification for 'strtod' +*/ +static lua_Number lua_strx2number (const char *s, char **endptr) { + int dot = lua_getlocaledecpoint(); + lua_Number r = 0.0; /* result (accumulator) */ + int sigdig = 0; /* number of significant digits */ + int nosigdig = 0; /* number of non-significant digits */ + int e = 0; /* exponent correction */ + int neg; /* 1 if number is negative */ + int hasdot = 0; /* true after seen a dot */ + *endptr = cast(char *, s); /* nothing is valid yet */ + while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ + neg = isneg(&s); /* check signal */ + if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ + return 0.0; /* invalid format (no '0x') */ + for (s += 2; ; s++) { /* skip '0x' and read numeral */ + if (*s == dot) { + if (hasdot) break; /* second dot? stop loop */ + else hasdot = 1; + } + else if (lisxdigit(cast_uchar(*s))) { + if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */ + nosigdig++; + else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */ + r = (r * cast_num(16.0)) + luaO_hexavalue(*s); + else e++; /* too many digits; ignore, but still count for exponent */ + if (hasdot) e--; /* decimal digit? correct exponent */ + } + else break; /* neither a dot nor a digit */ + } + if (nosigdig + sigdig == 0) /* no digits? */ + return 0.0; /* invalid format */ + *endptr = cast(char *, s); /* valid up to here */ + e *= 4; /* each digit multiplies/divides value by 2^4 */ + if (*s == 'p' || *s == 'P') { /* exponent part? */ + int exp1 = 0; /* exponent value */ + int neg1; /* exponent signal */ + s++; /* skip 'p' */ + neg1 = isneg(&s); /* signal */ + if (!lisdigit(cast_uchar(*s))) + return 0.0; /* invalid; must have at least one digit */ + while (lisdigit(cast_uchar(*s))) /* read exponent */ + exp1 = exp1 * 10 + *(s++) - '0'; + if (neg1) exp1 = -exp1; + e += exp1; + *endptr = cast(char *, s); /* valid up to here */ + } + if (neg) r = -r; + return l_mathop(ldexp)(r, e); +} + +#endif +/* }====================================================== */ + + +/* maximum length of a numeral */ +#if !defined (L_MAXLENNUM) +#define L_MAXLENNUM 200 +#endif + +static const char *l_str2dloc (const char *s, lua_Number *result, int mode) { + char *endptr; + *result = (mode == 'x') ? lua_strx2number(s, &endptr) /* try to convert */ + : lua_str2number(s, &endptr); + if (endptr == s) return NULL; /* nothing recognized? */ + while (lisspace(cast_uchar(*endptr))) endptr++; /* skip trailing spaces */ + return (*endptr == '\0') ? endptr : NULL; /* OK if no trailing characters */ +} + + +/* +** Convert string 's' to a Lua number (put in 'result'). Return NULL +** on fail or the address of the ending '\0' on success. +** 'pmode' points to (and 'mode' contains) special things in the string: +** - 'x'/'X' means an hexadecimal numeral +** - 'n'/'N' means 'inf' or 'nan' (which should be rejected) +** - '.' just optimizes the search for the common case (nothing special) +** This function accepts both the current locale or a dot as the radix +** mark. If the convertion fails, it may mean number has a dot but +** locale accepts something else. In that case, the code copies 's' +** to a buffer (because 's' is read-only), changes the dot to the +** current locale radix mark, and tries to convert again. +*/ +static const char *l_str2d (const char *s, lua_Number *result) { + const char *endptr; + const char *pmode = strpbrk(s, ".xXnN"); + int mode = pmode ? ltolower(cast_uchar(*pmode)) : 0; + if (mode == 'n') /* reject 'inf' and 'nan' */ + return NULL; + endptr = l_str2dloc(s, result, mode); /* try to convert */ + if (endptr == NULL) { /* failed? may be a different locale */ + char buff[L_MAXLENNUM + 1]; + const char *pdot = strchr(s, '.'); + if (strlen(s) > L_MAXLENNUM || pdot == NULL) + return NULL; /* string too long or no dot; fail */ + strcpy(buff, s); /* copy string to buffer */ + buff[pdot - s] = lua_getlocaledecpoint(); /* correct decimal point */ + endptr = l_str2dloc(buff, result, mode); /* try again */ + if (endptr != NULL) + endptr = s + (endptr - buff); /* make relative to 's' */ + } + return endptr; +} + + +#define MAXBY10 cast(lua_Unsigned, LUA_MAXINTEGER / 10) +#define MAXLASTD cast_int(LUA_MAXINTEGER % 10) + +static const char *l_str2int (const char *s, lua_Integer *result) { + lua_Unsigned a = 0; + int empty = 1; + int neg; + while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ + neg = isneg(&s); + if (s[0] == '0' && + (s[1] == 'x' || s[1] == 'X')) { /* hex? */ + s += 2; /* skip '0x' */ + for (; lisxdigit(cast_uchar(*s)); s++) { + a = a * 16 + luaO_hexavalue(*s); + empty = 0; + } + } + else { /* decimal */ + for (; lisdigit(cast_uchar(*s)); s++) { + int d = *s - '0'; + if (a >= MAXBY10 && (a > MAXBY10 || d > MAXLASTD + neg)) /* overflow? */ + return NULL; /* do not accept it (as integer) */ + a = a * 10 + d; + empty = 0; + } + } + while (lisspace(cast_uchar(*s))) s++; /* skip trailing spaces */ + if (empty || *s != '\0') return NULL; /* something wrong in the numeral */ + else { + *result = l_castU2S((neg) ? 0u - a : a); + return s; + } +} + + +size_t luaO_str2num (const char *s, TValue *o) { + lua_Integer i; lua_Number n; + const char *e; + if ((e = l_str2int(s, &i)) != NULL) { /* try as an integer */ + setivalue(o, i); + } + else if ((e = l_str2d(s, &n)) != NULL) { /* else try as a float */ + setfltvalue(o, n); + } + else + return 0; /* conversion failed */ + return (e - s) + 1; /* success; return string size */ +} + + +int luaO_utf8esc (char *buff, unsigned long x) { + int n = 1; /* number of bytes put in buffer (backwards) */ + lua_assert(x <= 0x10FFFF); + if (x < 0x80) /* ascii? */ + buff[UTF8BUFFSZ - 1] = cast(char, x); + else { /* need continuation bytes */ + unsigned int mfb = 0x3f; /* maximum that fits in first byte */ + do { /* add continuation bytes */ + buff[UTF8BUFFSZ - (n++)] = cast(char, 0x80 | (x & 0x3f)); + x >>= 6; /* remove added bits */ + mfb >>= 1; /* now there is one less bit available in first byte */ + } while (x > mfb); /* still needs continuation byte? */ + buff[UTF8BUFFSZ - n] = cast(char, (~mfb << 1) | x); /* add first byte */ + } + return n; +} + + +/* maximum length of the conversion of a number to a string */ +#define MAXNUMBER2STR 50 + + +/* +** Convert a number object to a string +*/ +void luaO_tostring (lua_State *L, StkId obj) { + char buff[MAXNUMBER2STR]; + size_t len; + lua_assert(ttisnumber(obj)); + if (ttisinteger(obj)) + len = lua_integer2str(buff, sizeof(buff), ivalue(obj)); + else { + len = lua_number2str(buff, sizeof(buff), fltvalue(obj)); +#if !defined(LUA_COMPAT_FLOATSTRING) + if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */ + buff[len++] = lua_getlocaledecpoint(); + buff[len++] = '0'; /* adds '.0' to result */ + } +#endif + } + setsvalue2s(L, obj, luaS_newlstr(L, buff, len)); +} + + +static void pushstr (lua_State *L, const char *str, size_t l) { + setsvalue2s(L, L->top, luaS_newlstr(L, str, l)); + luaD_inctop(L); +} + + +/* +** this function handles only '%d', '%c', '%f', '%p', and '%s' + conventional formats, plus Lua-specific '%I' and '%U' +*/ +const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { + int n = 0; + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + pushstr(L, fmt, e - fmt); + switch (*(e+1)) { + case 's': { /* zero-terminated string */ + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + pushstr(L, s, strlen(s)); + break; + } + case 'c': { /* an 'int' as a character */ + char buff = cast(char, va_arg(argp, int)); + if (lisprint(cast_uchar(buff))) + pushstr(L, &buff, 1); + else /* non-printable character; print its code */ + luaO_pushfstring(L, "<\\%d>", cast_uchar(buff)); + break; + } + case 'd': { /* an 'int' */ + setivalue(L->top, va_arg(argp, int)); + goto top2str; + } + case 'I': { /* a 'lua_Integer' */ + setivalue(L->top, cast(lua_Integer, va_arg(argp, l_uacInt))); + goto top2str; + } + case 'f': { /* a 'lua_Number' */ + setfltvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); + top2str: /* convert the top element to a string */ + luaD_inctop(L); + luaO_tostring(L, L->top - 1); + break; + } + case 'p': { /* a pointer */ + char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */ + int l = l_sprintf(buff, sizeof(buff), "%p", va_arg(argp, void *)); + pushstr(L, buff, l); + break; + } + case 'U': { /* an 'int' as a UTF-8 sequence */ + char buff[UTF8BUFFSZ]; + int l = luaO_utf8esc(buff, cast(long, va_arg(argp, long))); + pushstr(L, buff + UTF8BUFFSZ - l, l); + break; + } + case '%': { + pushstr(L, "%", 1); + break; + } + default: { + luaG_runerror(L, "invalid option '%%%c' to 'lua_pushfstring'", + *(e + 1)); + } + } + n += 2; + fmt = e+2; + } + luaD_checkstack(L, 1); + pushstr(L, fmt, strlen(fmt)); + if (n > 0) luaV_concat(L, n + 1); + return svalue(L->top - 1); +} + + +const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + return msg; +} + + +/* number of chars of a literal string without the ending \0 */ +#define LL(x) (sizeof(x)/sizeof(char) - 1) + +#define RETS "..." +#define PRE "[string \"" +#define POS "\"]" + +#define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) ) + +void luaO_chunkid (char *out, const char *source, size_t bufflen) { + size_t l = strlen(source); + if (*source == '=') { /* 'literal' source */ + if (l <= bufflen) /* small enough? */ + memcpy(out, source + 1, l * sizeof(char)); + else { /* truncate it */ + addstr(out, source + 1, bufflen - 1); + *out = '\0'; + } + } + else if (*source == '@') { /* file name */ + if (l <= bufflen) /* small enough? */ + memcpy(out, source + 1, l * sizeof(char)); + else { /* add '...' before rest of name */ + addstr(out, RETS, LL(RETS)); + bufflen -= LL(RETS); + memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char)); + } + } + else { /* string; format as [string "source"] */ + const char *nl = strchr(source, '\n'); /* find first new line (if any) */ + addstr(out, PRE, LL(PRE)); /* add prefix */ + bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */ + if (l < bufflen && nl == NULL) { /* small one-line source? */ + addstr(out, source, l); /* keep it */ + } + else { + if (nl != NULL) l = nl - source; /* stop at first newline */ + if (l > bufflen) l = bufflen; + addstr(out, source, l); + addstr(out, RETS, LL(RETS)); + } + memcpy(out, POS, (LL(POS) + 1) * sizeof(char)); + } +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lobject.h b/dep/scintilla/scintilla-3.10.6/lua/src/lobject.h new file mode 100644 index 00000000..3c042289 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lobject.h @@ -0,0 +1,549 @@ +/* +** $Id: lobject.h,v 2.117 2016/08/01 19:51:24 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO LUA_NUMTAGS /* function prototypes */ +#define LUA_TDEADKEY (LUA_NUMTAGS+1) /* removed keys in tables */ + +/* +** number of all possible tags (including LUA_TNONE but excluding DEADKEY) +*/ +#define LUA_TOTALTAGS (LUA_TPROTO + 2) + + +/* +** tags for Tagged Values have the following use of bits: +** bits 0-3: actual tag (a LUA_T* value) +** bits 4-5: variant bits +** bit 6: whether value is collectable +*/ + + +/* +** LUA_TFUNCTION variants: +** 0 - Lua function +** 1 - light C function +** 2 - regular C function (closure) +*/ + +/* Variant tags for functions */ +#define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */ +#define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */ +#define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */ + + +/* Variant tags for strings */ +#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */ +#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */ + + +/* Variant tags for numbers */ +#define LUA_TNUMFLT (LUA_TNUMBER | (0 << 4)) /* float numbers */ +#define LUA_TNUMINT (LUA_TNUMBER | (1 << 4)) /* integer numbers */ + + +/* Bit mark for collectable types */ +#define BIT_ISCOLLECTABLE (1 << 6) + +/* mark a tag as collectable */ +#define ctb(t) ((t) | BIT_ISCOLLECTABLE) + + +/* +** Common type for all collectable objects +*/ +typedef struct GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common type has only the common header +*/ +struct GCObject { + CommonHeader; +}; + + + + +/* +** Tagged Values. This is the basic representation of values in Lua, +** an actual value plus a tag with its type. +*/ + +/* +** Union of all Lua values +*/ +typedef union Value { + GCObject *gc; /* collectable objects */ + void *p; /* light userdata */ + int b; /* booleans */ + lua_CFunction f; /* light C functions */ + lua_Integer i; /* integer numbers */ + lua_Number n; /* float numbers */ +} Value; + + +#define TValuefields Value value_; int tt_ + + +typedef struct lua_TValue { + TValuefields; +} TValue; + + + +/* macro defining a nil value */ +#define NILCONSTANT {NULL}, LUA_TNIL + + +#define val_(o) ((o)->value_) + + +/* raw type tag of a TValue */ +#define rttype(o) ((o)->tt_) + +/* tag with no variants (bits 0-3) */ +#define novariant(x) ((x) & 0x0F) + +/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ +#define ttype(o) (rttype(o) & 0x3F) + +/* type tag of a TValue with no variants (bits 0-3) */ +#define ttnov(o) (novariant(rttype(o))) + + +/* Macros to test type */ +#define checktag(o,t) (rttype(o) == (t)) +#define checktype(o,t) (ttnov(o) == (t)) +#define ttisnumber(o) checktype((o), LUA_TNUMBER) +#define ttisfloat(o) checktag((o), LUA_TNUMFLT) +#define ttisinteger(o) checktag((o), LUA_TNUMINT) +#define ttisnil(o) checktag((o), LUA_TNIL) +#define ttisboolean(o) checktag((o), LUA_TBOOLEAN) +#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA) +#define ttisstring(o) checktype((o), LUA_TSTRING) +#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) +#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR)) +#define ttistable(o) checktag((o), ctb(LUA_TTABLE)) +#define ttisfunction(o) checktype(o, LUA_TFUNCTION) +#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) +#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) +#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) +#define ttislcf(o) checktag((o), LUA_TLCF) +#define ttisfulluserdata(o) checktag((o), ctb(LUA_TUSERDATA)) +#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD)) +#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY) + + +/* Macros to access values */ +#define ivalue(o) check_exp(ttisinteger(o), val_(o).i) +#define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) +#define nvalue(o) check_exp(ttisnumber(o), \ + (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) +#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) +#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) +#define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) +#define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc)) +#define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc)) +#define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc)) +#define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc)) +#define fvalue(o) check_exp(ttislcf(o), val_(o).f) +#define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc)) +#define bvalue(o) check_exp(ttisboolean(o), val_(o).b) +#define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc)) +/* a dead value may get the 'gc' field, but cannot access its contents */ +#define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc)) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + + +#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE) + + +/* Macros for internal tests */ +#define righttt(obj) (ttype(obj) == gcvalue(obj)->tt) + +#define checkliveness(L,obj) \ + lua_longassert(!iscollectable(obj) || \ + (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj))))) + + +/* Macros to set values */ +#define settt_(o,t) ((o)->tt_=(t)) + +#define setfltvalue(obj,x) \ + { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_TNUMFLT); } + +#define chgfltvalue(obj,x) \ + { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); } + +#define setivalue(obj,x) \ + { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_TNUMINT); } + +#define chgivalue(obj,x) \ + { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); } + +#define setnilvalue(obj) settt_(obj, LUA_TNIL) + +#define setfvalue(obj,x) \ + { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); } + +#define setpvalue(obj,x) \ + { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); } + +#define setbvalue(obj,x) \ + { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); } + +#define setgcovalue(L,obj,x) \ + { TValue *io = (obj); GCObject *i_g=(x); \ + val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); } + +#define setsvalue(L,obj,x) \ + { TValue *io = (obj); TString *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ + checkliveness(L,io); } + +#define setuvalue(L,obj,x) \ + { TValue *io = (obj); Udata *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TUSERDATA)); \ + checkliveness(L,io); } + +#define setthvalue(L,obj,x) \ + { TValue *io = (obj); lua_State *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTHREAD)); \ + checkliveness(L,io); } + +#define setclLvalue(L,obj,x) \ + { TValue *io = (obj); LClosure *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TLCL)); \ + checkliveness(L,io); } + +#define setclCvalue(L,obj,x) \ + { TValue *io = (obj); CClosure *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TCCL)); \ + checkliveness(L,io); } + +#define sethvalue(L,obj,x) \ + { TValue *io = (obj); Table *x_ = (x); \ + val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTABLE)); \ + checkliveness(L,io); } + +#define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) + + + +#define setobj(L,obj1,obj2) \ + { TValue *io1=(obj1); *io1 = *(obj2); \ + (void)L; checkliveness(L,io1); } + + +/* +** different types of assignments, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + +/* to table (define it as an expression to be used in macros) */ +#define setobj2t(L,o1,o2) ((void)L, *(o1)=*(o2), checkliveness(L,(o1))) + + + + +/* +** {====================================================== +** types and prototypes +** ======================================================= +*/ + + +typedef TValue *StkId; /* index to stack elements */ + + + + +/* +** Header for string value; string bytes follow the end of this structure +** (aligned according to 'UTString'; see next). +*/ +typedef struct TString { + CommonHeader; + lu_byte extra; /* reserved words for short strings; "has hash" for longs */ + lu_byte shrlen; /* length for short strings */ + unsigned int hash; + union { + size_t lnglen; /* length for long strings */ + struct TString *hnext; /* linked list for hash table */ + } u; +} TString; + + +/* +** Ensures that address after this type is always fully aligned. +*/ +typedef union UTString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + TString tsv; +} UTString; + + +/* +** Get the actual string (array of bytes) from a 'TString'. +** (Access to 'extra' ensures that value is really a 'TString'.) +*/ +#define getstr(ts) \ + check_exp(sizeof((ts)->extra), cast(char *, (ts)) + sizeof(UTString)) + + +/* get the actual string (array of bytes) from a Lua value */ +#define svalue(o) getstr(tsvalue(o)) + +/* get string length from 'TString *s' */ +#define tsslen(s) ((s)->tt == LUA_TSHRSTR ? (s)->shrlen : (s)->u.lnglen) + +/* get string length from 'TValue *o' */ +#define vslen(o) tsslen(tsvalue(o)) + + +/* +** Header for userdata; memory area follows the end of this structure +** (aligned according to 'UUdata'; see next). +*/ +typedef struct Udata { + CommonHeader; + lu_byte ttuv_; /* user value's tag */ + struct Table *metatable; + size_t len; /* number of bytes */ + union Value user_; /* user value */ +} Udata; + + +/* +** Ensures that address after this type is always fully aligned. +*/ +typedef union UUdata { + L_Umaxalign dummy; /* ensures maximum alignment for 'local' udata */ + Udata uv; +} UUdata; + + +/* +** Get the address of memory block inside 'Udata'. +** (Access to 'ttuv_' ensures that value is really a 'Udata'.) +*/ +#define getudatamem(u) \ + check_exp(sizeof((u)->ttuv_), (cast(char*, (u)) + sizeof(UUdata))) + +#define setuservalue(L,u,o) \ + { const TValue *io=(o); Udata *iu = (u); \ + iu->user_ = io->value_; iu->ttuv_ = rttype(io); \ + checkliveness(L,io); } + + +#define getuservalue(L,u,o) \ + { TValue *io=(o); const Udata *iu = (u); \ + io->value_ = iu->user_; settt_(io, iu->ttuv_); \ + checkliveness(L,io); } + + +/* +** Description of an upvalue for function prototypes +*/ +typedef struct Upvaldesc { + TString *name; /* upvalue name (for debug information) */ + lu_byte instack; /* whether it is in stack (register) */ + lu_byte idx; /* index of upvalue (in stack or in outer function's list) */ +} Upvaldesc; + + +/* +** Description of a local variable for function prototypes +** (used for debug information) +*/ +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + lu_byte numparams; /* number of fixed parameters */ + lu_byte is_vararg; + lu_byte maxstacksize; /* number of registers needed by this function */ + int sizeupvalues; /* size of 'upvalues' */ + int sizek; /* size of 'k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of 'p' */ + int sizelocvars; + int linedefined; /* debug information */ + int lastlinedefined; /* debug information */ + TValue *k; /* constants used by the function */ + Instruction *code; /* opcodes */ + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines (debug information) */ + LocVar *locvars; /* information about local variables (debug information) */ + Upvaldesc *upvalues; /* upvalue information */ + struct LClosure *cache; /* last-created closure with this prototype */ + TString *source; /* used for debug information */ + GCObject *gclist; +} Proto; + + + +/* +** Lua Upvalues +*/ +typedef struct UpVal UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte nupvalues; GCObject *gclist + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; /* list of upvalues */ +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; /* list of upvalues */ +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define isLfunction(o) ttisLclosure(o) + +#define getproto(o) (clLvalue(o)->p) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + int next; /* for chaining (offset for next node) */ + } nk; + TValue tvk; +} TKey; + + +/* copy a value into a key without messing up field 'next' */ +#define setnodekey(L,key,obj) \ + { TKey *k_=(key); const TValue *io_=(obj); \ + k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ + (void)L; checkliveness(L,io_); } + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

    lsizenode)) + + +/* +** (address of) a fixed nil value +*/ +#define luaO_nilobject (&luaO_nilobject_) + + +LUAI_DDEC const TValue luaO_nilobject_; + +/* size of buffer for 'luaO_utf8esc' function */ +#define UTF8BUFFSZ 8 + +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x); +LUAI_FUNC int luaO_ceillog2 (unsigned int x); +LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1, + const TValue *p2, TValue *res); +LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o); +LUAI_FUNC int luaO_hexavalue (int c); +LUAI_FUNC void luaO_tostring (lua_State *L, StkId obj); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lopcodes.c b/dep/scintilla/scintilla-3.10.6/lua/src/lopcodes.c new file mode 100644 index 00000000..a1cbef85 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lopcodes.c @@ -0,0 +1,124 @@ +/* +** $Id: lopcodes.c,v 1.55 2015/01/05 13:48:33 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#define lopcodes_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lopcodes.h" + + +/* ORDER OP */ + +LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADKX", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETTABUP", + "GETTABLE", + "SETTABUP", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "MOD", + "POW", + "DIV", + "IDIV", + "BAND", + "BOR", + "BXOR", + "SHL", + "SHR", + "UNM", + "BNOT", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORCALL", + "TFORLOOP", + "SETLIST", + "CLOSURE", + "VARARG", + "EXTRAARG", + NULL +}; + + +#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { +/* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ + ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ + ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ + ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ + ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ + ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ + ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ +}; + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lopcodes.h b/dep/scintilla/scintilla-3.10.6/lua/src/lopcodes.h new file mode 100644 index 00000000..bbc4b619 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lopcodes.h @@ -0,0 +1,297 @@ +/* +** $Id: lopcodes.h,v 1.149 2016/07/19 17:12:21 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + 'A' : 8 bits + 'B' : 9 bits + 'C' : 9 bits + 'Ax' : 26 bits ('A', 'B', and 'C' together) + 'Bx' : 18 bits ('B' and 'C' together) + 'sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 +#define SIZE_Ax (SIZE_C + SIZE_B + SIZE_A) + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C +#define POS_Ax POS_A + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* 'sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + +#if SIZE_Ax < LUAI_BITSINT-1 +#define MAXARG_Ax ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>pos) & MASK1(size,0))) +#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \ + ((cast(Instruction, v)<> RK(C) */ +OP_UNM,/* A B R(A) := -R(B) */ +OP_BNOT,/* A B R(A) := ~R(B) */ +OP_NOT,/* A B R(A) := not R(B) */ +OP_LEN,/* A B R(A) := length of R(B) */ + +OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */ + +OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A - 1) */ +OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ +OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ +OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ + +OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) > 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/loslib.c b/dep/scintilla/scintilla-3.10.6/lua/src/loslib.c new file mode 100644 index 00000000..5a94eb90 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/loslib.c @@ -0,0 +1,407 @@ +/* +** $Id: loslib.c,v 1.65 2016/07/18 17:58:58 roberto Exp $ +** Standard Operating System library +** See Copyright Notice in lua.h +*/ + +#define loslib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include +#include +#include +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* +** {================================================================== +** List of valid conversion specifiers for the 'strftime' function; +** options are grouped by length; group of length 2 start with '||'. +** =================================================================== +*/ +#if !defined(LUA_STRFTIMEOPTIONS) /* { */ + +/* options for ANSI C 89 (only 1-char options) */ +#define L_STRFTIMEC89 "aAbBcdHIjmMpSUwWxXyYZ%" + +/* options for ISO C 99 and POSIX */ +#define L_STRFTIMEC99 "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \ + "||" "EcECExEXEyEY" "OdOeOHOIOmOMOSOuOUOVOwOWOy" /* two-char options */ + +/* options for Windows */ +#define L_STRFTIMEWIN "aAbBcdHIjmMpSUwWxXyYzZ%" \ + "||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" /* two-char options */ + +#if defined(LUA_USE_WINDOWS) +#define LUA_STRFTIMEOPTIONS L_STRFTIMEWIN +#elif defined(LUA_USE_C89) +#define LUA_STRFTIMEOPTIONS L_STRFTIMEC89 +#else /* C99 specification */ +#define LUA_STRFTIMEOPTIONS L_STRFTIMEC99 +#endif + +#endif /* } */ +/* }================================================================== */ + + +/* +** {================================================================== +** Configuration for time-related stuff +** =================================================================== +*/ + +#if !defined(l_time_t) /* { */ +/* +** type to represent time_t in Lua +*/ +#define l_timet lua_Integer +#define l_pushtime(L,t) lua_pushinteger(L,(lua_Integer)(t)) + +static time_t l_checktime (lua_State *L, int arg) { + lua_Integer t = luaL_checkinteger(L, arg); + luaL_argcheck(L, (time_t)t == t, arg, "time out-of-bounds"); + return (time_t)t; +} + +#endif /* } */ + + +#if !defined(l_gmtime) /* { */ +/* +** By default, Lua uses gmtime/localtime, except when POSIX is available, +** where it uses gmtime_r/localtime_r +*/ + +#if defined(LUA_USE_POSIX) /* { */ + +#define l_gmtime(t,r) gmtime_r(t,r) +#define l_localtime(t,r) localtime_r(t,r) + +#else /* }{ */ + +/* ISO C definitions */ +#define l_gmtime(t,r) ((void)(r)->tm_sec, gmtime(t)) +#define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t)) + +#endif /* } */ + +#endif /* } */ + +/* }================================================================== */ + + +/* +** {================================================================== +** Configuration for 'tmpnam': +** By default, Lua uses tmpnam except when POSIX is available, where +** it uses mkstemp. +** =================================================================== +*/ +#if !defined(lua_tmpnam) /* { */ + +#if defined(LUA_USE_POSIX) /* { */ + +#include + +#define LUA_TMPNAMBUFSIZE 32 + +#if !defined(LUA_TMPNAMTEMPLATE) +#define LUA_TMPNAMTEMPLATE "/tmp/lua_XXXXXX" +#endif + +#define lua_tmpnam(b,e) { \ + strcpy(b, LUA_TMPNAMTEMPLATE); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else /* }{ */ + +/* ISO C definitions */ +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } + +#endif /* } */ + +#endif /* } */ +/* }================================================================== */ + + + + +static int os_execute (lua_State *L) { + const char *cmd = luaL_optstring(L, 1, NULL); + int stat = system(cmd); + if (cmd != NULL) + return luaL_execresult(L, stat); + else { + lua_pushboolean(L, stat); /* true if there is a shell */ + return 1; + } +} + + +static int os_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return luaL_fileresult(L, remove(filename) == 0, filename); +} + + +static int os_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return luaL_fileresult(L, rename(fromname, toname) == 0, NULL); +} + + +static int os_tmpname (lua_State *L) { + char buff[LUA_TMPNAMBUFSIZE]; + int err; + lua_tmpnam(buff, err); + if (err) + return luaL_error(L, "unable to generate a unique filename"); + lua_pushstring(L, buff); + return 1; +} + + +static int os_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int os_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + + +/* +** Set all fields from structure 'tm' in the table on top of the stack +*/ +static void setallfields (lua_State *L, struct tm *stm) { + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon + 1); + setfield(L, "year", stm->tm_year + 1900); + setfield(L, "wday", stm->tm_wday + 1); + setfield(L, "yday", stm->tm_yday + 1); + setboolfield(L, "isdst", stm->tm_isdst); +} + + +static int getboolfield (lua_State *L, const char *key) { + int res; + res = (lua_getfield(L, -1, key) == LUA_TNIL) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +/* maximum value for date fields (to avoid arithmetic overflows with 'int') */ +#if !defined(L_MAXDATEFIELD) +#define L_MAXDATEFIELD (INT_MAX / 2) +#endif + +static int getfield (lua_State *L, const char *key, int d, int delta) { + int isnum; + int t = lua_getfield(L, -1, key); /* get field and its type */ + lua_Integer res = lua_tointegerx(L, -1, &isnum); + if (!isnum) { /* field is not an integer? */ + if (t != LUA_TNIL) /* some other value? */ + return luaL_error(L, "field '%s' is not an integer", key); + else if (d < 0) /* absent field; no default? */ + return luaL_error(L, "field '%s' missing in date table", key); + res = d; + } + else { + if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD)) + return luaL_error(L, "field '%s' is out-of-bound", key); + res -= delta; + } + lua_pop(L, 1); + return (int)res; +} + + +static const char *checkoption (lua_State *L, const char *conv, + ptrdiff_t convlen, char *buff) { + const char *option = LUA_STRFTIMEOPTIONS; + int oplen = 1; /* length of options being checked */ + for (; *option != '\0' && oplen <= convlen; option += oplen) { + if (*option == '|') /* next block? */ + oplen++; /* will check options with next length (+1) */ + else if (memcmp(conv, option, oplen) == 0) { /* match? */ + memcpy(buff, conv, oplen); /* copy valid option to buffer */ + buff[oplen] = '\0'; + return conv + oplen; /* return next item */ + } + } + luaL_argerror(L, 1, + lua_pushfstring(L, "invalid conversion specifier '%%%s'", conv)); + return conv; /* to avoid warnings */ +} + + +/* maximum size for an individual 'strftime' item */ +#define SIZETIMEFMT 250 + + +static int os_date (lua_State *L) { + size_t slen; + const char *s = luaL_optlstring(L, 1, "%c", &slen); + time_t t = luaL_opt(L, l_checktime, 2, time(NULL)); + const char *se = s + slen; /* 's' end */ + struct tm tmr, *stm; + if (*s == '!') { /* UTC? */ + stm = l_gmtime(&t, &tmr); + s++; /* skip '!' */ + } + else + stm = l_localtime(&t, &tmr); + if (stm == NULL) /* invalid date? */ + luaL_error(L, "time result cannot be represented in this installation"); + if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setallfields(L, stm); + } + else { + char cc[4]; /* buffer for individual conversion specifiers */ + luaL_Buffer b; + cc[0] = '%'; + luaL_buffinit(L, &b); + while (s < se) { + if (*s != '%') /* not a conversion specifier? */ + luaL_addchar(&b, *s++); + else { + size_t reslen; + char *buff = luaL_prepbuffsize(&b, SIZETIMEFMT); + s++; /* skip '%' */ + s = checkoption(L, s, se - s, cc + 1); /* copy specifier to 'cc' */ + reslen = strftime(buff, SIZETIMEFMT, cc, stm); + luaL_addsize(&b, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + + +static int os_time (lua_State *L) { + time_t t; + if (lua_isnoneornil(L, 1)) /* called without args? */ + t = time(NULL); /* get current time */ + else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0, 0); + ts.tm_min = getfield(L, "min", 0, 0); + ts.tm_hour = getfield(L, "hour", 12, 0); + ts.tm_mday = getfield(L, "day", -1, 0); + ts.tm_mon = getfield(L, "month", -1, 1); + ts.tm_year = getfield(L, "year", -1, 1900); + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + setallfields(L, &ts); /* update fields with normalized values */ + } + if (t != (time_t)(l_timet)t || t == (time_t)(-1)) + luaL_error(L, "time result cannot be represented in this installation"); + l_pushtime(L, t); + return 1; +} + + +static int os_difftime (lua_State *L) { + time_t t1 = l_checktime(L, 1); + time_t t2 = l_checktime(L, 2); + lua_pushnumber(L, (lua_Number)difftime(t1, t2)); + return 1; +} + +/* }====================================================== */ + + +static int os_setlocale (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = luaL_optstring(L, 1, NULL); + int op = luaL_checkoption(L, 2, "all", catnames); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int os_exit (lua_State *L) { + int status; + if (lua_isboolean(L, 1)) + status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE); + else + status = (int)luaL_optinteger(L, 1, EXIT_SUCCESS); + if (lua_toboolean(L, 2)) + lua_close(L); + if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */ + return 0; +} + + +static const luaL_Reg syslib[] = { + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUAMOD_API int luaopen_os (lua_State *L) { + luaL_newlib(L, syslib); + return 1; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lparser.c b/dep/scintilla/scintilla-3.10.6/lua/src/lparser.c new file mode 100644 index 00000000..cd4512d4 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lparser.c @@ -0,0 +1,1650 @@ +/* +** $Id: lparser.c,v 2.155 2016/08/01 19:51:24 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#define lparser_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" + + + +/* maximum number of local variables per function (must be smaller + than 250, due to the bytecode format) */ +#define MAXVARS 200 + + +#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) + + +/* because all strings are unified by the scanner, the parser + can use pointer equality for string equality */ +#define eqstr(a,b) ((a) == (b)) + + +/* +** nodes for block list (list of active blocks) +*/ +typedef struct BlockCnt { + struct BlockCnt *previous; /* chain */ + int firstlabel; /* index of first label in this block */ + int firstgoto; /* index of first pending goto in this block */ + lu_byte nactvar; /* # active locals outside the block */ + lu_byte upval; /* true if some variable in the block is an upvalue */ + lu_byte isloop; /* true if 'block' is a loop */ +} BlockCnt; + + + +/* +** prototypes for recursive non-terminal functions +*/ +static void statement (LexState *ls); +static void expr (LexState *ls, expdesc *v); + + +/* semantic error */ +static l_noret semerror (LexState *ls, const char *msg) { + ls->t.token = 0; /* remove "near " from final message */ + luaX_syntaxerror(ls, msg); +} + + +static l_noret error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token))); +} + + +static l_noret errorlimit (FuncState *fs, int limit, const char *what) { + lua_State *L = fs->ls->L; + const char *msg; + int line = fs->f->linedefined; + const char *where = (line == 0) + ? "main function" + : luaO_pushfstring(L, "function at line %d", line); + msg = luaO_pushfstring(L, "too many %s (limit is %d) in %s", + what, limit, where); + luaX_syntaxerror(fs->ls, msg); +} + + +static void checklimit (FuncState *fs, int v, int l, const char *what) { + if (v > l) errorlimit(fs, l, what); +} + + +static int testnext (LexState *ls, int c) { + if (ls->t.token == c) { + luaX_next(ls); + return 1; + } + else return 0; +} + + +static void check (LexState *ls, int c) { + if (ls->t.token != c) + error_expected(ls, c); +} + + +static void checknext (LexState *ls, int c) { + check(ls, c); + luaX_next(ls); +} + + +#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } + + + +static void check_match (LexState *ls, int what, int who, int where) { + if (!testnext(ls, what)) { + if (where == ls->linenumber) + error_expected(ls, what); + else { + luaX_syntaxerror(ls, luaO_pushfstring(ls->L, + "%s expected (to close %s at line %d)", + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + } + } +} + + +static TString *str_checkname (LexState *ls) { + TString *ts; + check(ls, TK_NAME); + ts = ls->t.seminfo.ts; + luaX_next(ls); + return ts; +} + + +static void init_exp (expdesc *e, expkind k, int i) { + e->f = e->t = NO_JUMP; + e->k = k; + e->u.info = i; +} + + +static void codestring (LexState *ls, expdesc *e, TString *s) { + init_exp(e, VK, luaK_stringK(ls->fs, s)); +} + + +static void checkname (LexState *ls, expdesc *e) { + codestring(ls, e, str_checkname(ls)); +} + + +static int registerlocalvar (LexState *ls, TString *varname) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizelocvars; + luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + LocVar, SHRT_MAX, "local variables"); + while (oldsize < f->sizelocvars) + f->locvars[oldsize++].varname = NULL; + f->locvars[fs->nlocvars].varname = varname; + luaC_objbarrier(ls->L, f, varname); + return fs->nlocvars++; +} + + +static void new_localvar (LexState *ls, TString *name) { + FuncState *fs = ls->fs; + Dyndata *dyd = ls->dyd; + int reg = registerlocalvar(ls, name); + checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal, + MAXVARS, "local variables"); + luaM_growvector(ls->L, dyd->actvar.arr, dyd->actvar.n + 1, + dyd->actvar.size, Vardesc, MAX_INT, "local variables"); + dyd->actvar.arr[dyd->actvar.n++].idx = cast(short, reg); +} + + +static void new_localvarliteral_ (LexState *ls, const char *name, size_t sz) { + new_localvar(ls, luaX_newstring(ls, name, sz)); +} + +#define new_localvarliteral(ls,v) \ + new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1) + + +static LocVar *getlocvar (FuncState *fs, int i) { + int idx = fs->ls->dyd->actvar.arr[fs->firstlocal + i].idx; + lua_assert(idx < fs->nlocvars); + return &fs->f->locvars[idx]; +} + + +static void adjustlocalvars (LexState *ls, int nvars) { + FuncState *fs = ls->fs; + fs->nactvar = cast_byte(fs->nactvar + nvars); + for (; nvars; nvars--) { + getlocvar(fs, fs->nactvar - nvars)->startpc = fs->pc; + } +} + + +static void removevars (FuncState *fs, int tolevel) { + fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel); + while (fs->nactvar > tolevel) + getlocvar(fs, --fs->nactvar)->endpc = fs->pc; +} + + +static int searchupvalue (FuncState *fs, TString *name) { + int i; + Upvaldesc *up = fs->f->upvalues; + for (i = 0; i < fs->nups; i++) { + if (eqstr(up[i].name, name)) return i; + } + return -1; /* not found */ +} + + +static int newupvalue (FuncState *fs, TString *name, expdesc *v) { + Proto *f = fs->f; + int oldsize = f->sizeupvalues; + checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues"); + luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues, + Upvaldesc, MAXUPVAL, "upvalues"); + while (oldsize < f->sizeupvalues) + f->upvalues[oldsize++].name = NULL; + f->upvalues[fs->nups].instack = (v->k == VLOCAL); + f->upvalues[fs->nups].idx = cast_byte(v->u.info); + f->upvalues[fs->nups].name = name; + luaC_objbarrier(fs->ls->L, f, name); + return fs->nups++; +} + + +static int searchvar (FuncState *fs, TString *n) { + int i; + for (i = cast_int(fs->nactvar) - 1; i >= 0; i--) { + if (eqstr(n, getlocvar(fs, i)->varname)) + return i; + } + return -1; /* not found */ +} + + +/* + Mark block where variable at given level was defined + (to emit close instructions later). +*/ +static void markupval (FuncState *fs, int level) { + BlockCnt *bl = fs->bl; + while (bl->nactvar > level) + bl = bl->previous; + bl->upval = 1; +} + + +/* + Find variable with given name 'n'. If it is an upvalue, add this + upvalue into all intermediate functions. +*/ +static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { + if (fs == NULL) /* no more levels? */ + init_exp(var, VVOID, 0); /* default is global */ + else { + int v = searchvar(fs, n); /* look up locals at current level */ + if (v >= 0) { /* found? */ + init_exp(var, VLOCAL, v); /* variable is local */ + if (!base) + markupval(fs, v); /* local will be used as an upval */ + } + else { /* not found as local at current level; try upvalues */ + int idx = searchupvalue(fs, n); /* try existing upvalues */ + if (idx < 0) { /* not found? */ + singlevaraux(fs->prev, n, var, 0); /* try upper levels */ + if (var->k == VVOID) /* not found? */ + return; /* it is a global */ + /* else was LOCAL or UPVAL */ + idx = newupvalue(fs, n, var); /* will be a new upvalue */ + } + init_exp(var, VUPVAL, idx); /* new or old upvalue */ + } + } +} + + +static void singlevar (LexState *ls, expdesc *var) { + TString *varname = str_checkname(ls); + FuncState *fs = ls->fs; + singlevaraux(fs, varname, var, 1); + if (var->k == VVOID) { /* global name? */ + expdesc key; + singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ + lua_assert(var->k != VVOID); /* this one must exist */ + codestring(ls, &key, varname); /* key is variable name */ + luaK_indexed(fs, var, &key); /* env[varname] */ + } +} + + +static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { + FuncState *fs = ls->fs; + int extra = nvars - nexps; + if (hasmultret(e->k)) { + extra++; /* includes call itself */ + if (extra < 0) extra = 0; + luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) luaK_reserveregs(fs, extra-1); + } + else { + if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (extra > 0) { + int reg = fs->freereg; + luaK_reserveregs(fs, extra); + luaK_nil(fs, reg, extra); + } + } + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* remove extra values */ +} + + +static void enterlevel (LexState *ls) { + lua_State *L = ls->L; + ++L->nCcalls; + checklimit(ls->fs, L->nCcalls, LUAI_MAXCCALLS, "C levels"); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + +static void closegoto (LexState *ls, int g, Labeldesc *label) { + int i; + FuncState *fs = ls->fs; + Labellist *gl = &ls->dyd->gt; + Labeldesc *gt = &gl->arr[g]; + lua_assert(eqstr(gt->name, label->name)); + if (gt->nactvar < label->nactvar) { + TString *vname = getlocvar(fs, gt->nactvar)->varname; + const char *msg = luaO_pushfstring(ls->L, + " at line %d jumps into the scope of local '%s'", + getstr(gt->name), gt->line, getstr(vname)); + semerror(ls, msg); + } + luaK_patchlist(fs, gt->pc, label->pc); + /* remove goto from pending list */ + for (i = g; i < gl->n - 1; i++) + gl->arr[i] = gl->arr[i + 1]; + gl->n--; +} + + +/* +** try to close a goto with existing labels; this solves backward jumps +*/ +static int findlabel (LexState *ls, int g) { + int i; + BlockCnt *bl = ls->fs->bl; + Dyndata *dyd = ls->dyd; + Labeldesc *gt = &dyd->gt.arr[g]; + /* check labels in current block for a match */ + for (i = bl->firstlabel; i < dyd->label.n; i++) { + Labeldesc *lb = &dyd->label.arr[i]; + if (eqstr(lb->name, gt->name)) { /* correct label? */ + if (gt->nactvar > lb->nactvar && + (bl->upval || dyd->label.n > bl->firstlabel)) + luaK_patchclose(ls->fs, gt->pc, lb->nactvar); + closegoto(ls, g, lb); /* close it */ + return 1; + } + } + return 0; /* label not found; cannot close goto */ +} + + +static int newlabelentry (LexState *ls, Labellist *l, TString *name, + int line, int pc) { + int n = l->n; + luaM_growvector(ls->L, l->arr, n, l->size, + Labeldesc, SHRT_MAX, "labels/gotos"); + l->arr[n].name = name; + l->arr[n].line = line; + l->arr[n].nactvar = ls->fs->nactvar; + l->arr[n].pc = pc; + l->n = n + 1; + return n; +} + + +/* +** check whether new label 'lb' matches any pending gotos in current +** block; solves forward jumps +*/ +static void findgotos (LexState *ls, Labeldesc *lb) { + Labellist *gl = &ls->dyd->gt; + int i = ls->fs->bl->firstgoto; + while (i < gl->n) { + if (eqstr(gl->arr[i].name, lb->name)) + closegoto(ls, i, lb); + else + i++; + } +} + + +/* +** export pending gotos to outer level, to check them against +** outer labels; if the block being exited has upvalues, and +** the goto exits the scope of any variable (which can be the +** upvalue), close those variables being exited. +*/ +static void movegotosout (FuncState *fs, BlockCnt *bl) { + int i = bl->firstgoto; + Labellist *gl = &fs->ls->dyd->gt; + /* correct pending gotos to current block and try to close it + with visible labels */ + while (i < gl->n) { + Labeldesc *gt = &gl->arr[i]; + if (gt->nactvar > bl->nactvar) { + if (bl->upval) + luaK_patchclose(fs, gt->pc, bl->nactvar); + gt->nactvar = bl->nactvar; + } + if (!findlabel(fs->ls, i)) + i++; /* move to next one */ + } +} + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) { + bl->isloop = isloop; + bl->nactvar = fs->nactvar; + bl->firstlabel = fs->ls->dyd->label.n; + bl->firstgoto = fs->ls->dyd->gt.n; + bl->upval = 0; + bl->previous = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + + +/* +** create a label named 'break' to resolve break statements +*/ +static void breaklabel (LexState *ls) { + TString *n = luaS_new(ls->L, "break"); + int l = newlabelentry(ls, &ls->dyd->label, n, 0, ls->fs->pc); + findgotos(ls, &ls->dyd->label.arr[l]); +} + +/* +** generates an error for an undefined 'goto'; choose appropriate +** message when label name is a reserved word (which can only be 'break') +*/ +static l_noret undefgoto (LexState *ls, Labeldesc *gt) { + const char *msg = isreserved(gt->name) + ? "<%s> at line %d not inside a loop" + : "no visible label '%s' for at line %d"; + msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); + semerror(ls, msg); +} + + +static void leaveblock (FuncState *fs) { + BlockCnt *bl = fs->bl; + LexState *ls = fs->ls; + if (bl->previous && bl->upval) { + /* create a 'jump to here' to close upvalues */ + int j = luaK_jump(fs); + luaK_patchclose(fs, j, bl->nactvar); + luaK_patchtohere(fs, j); + } + if (bl->isloop) + breaklabel(ls); /* close pending breaks */ + fs->bl = bl->previous; + removevars(fs, bl->nactvar); + lua_assert(bl->nactvar == fs->nactvar); + fs->freereg = fs->nactvar; /* free registers */ + ls->dyd->label.n = bl->firstlabel; /* remove local labels */ + if (bl->previous) /* inner block? */ + movegotosout(fs, bl); /* update pending gotos to outer block */ + else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */ + undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */ +} + + +/* +** adds a new prototype into list of prototypes +*/ +static Proto *addprototype (LexState *ls) { + Proto *clp; + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; /* prototype of current function */ + if (fs->np >= f->sizep) { + int oldsize = f->sizep; + luaM_growvector(L, f->p, fs->np, f->sizep, Proto *, MAXARG_Bx, "functions"); + while (oldsize < f->sizep) + f->p[oldsize++] = NULL; + } + f->p[fs->np++] = clp = luaF_newproto(L); + luaC_objbarrier(L, f, clp); + return clp; +} + + +/* +** codes instruction to create new closure in parent function. +** The OP_CLOSURE instruction must use the last available register, +** so that, if it invokes the GC, the GC knows which registers +** are in use at that time. +*/ +static void codeclosure (LexState *ls, expdesc *v) { + FuncState *fs = ls->fs->prev; + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); + luaK_exp2nextreg(fs, v); /* fix it at the last register */ +} + + +static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) { + Proto *f; + fs->prev = ls->fs; /* linked list of funcstates */ + fs->ls = ls; + ls->fs = fs; + fs->pc = 0; + fs->lasttarget = 0; + fs->jpc = NO_JUMP; + fs->freereg = 0; + fs->nk = 0; + fs->np = 0; + fs->nups = 0; + fs->nlocvars = 0; + fs->nactvar = 0; + fs->firstlocal = ls->dyd->actvar.n; + fs->bl = NULL; + f = fs->f; + f->source = ls->source; + f->maxstacksize = 2; /* registers 0/1 are always valid */ + enterblock(fs, bl, 0); +} + + +static void close_func (LexState *ls) { + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; + luaK_ret(fs, 0, 0); /* final return */ + leaveblock(fs); + luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); + f->sizecode = fs->pc; + luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); + f->sizelineinfo = fs->pc; + luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); + f->sizek = fs->nk; + luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); + f->sizep = fs->np; + luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); + f->sizelocvars = fs->nlocvars; + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc); + f->sizeupvalues = fs->nups; + lua_assert(fs->bl == NULL); + ls->fs = fs->prev; + luaC_checkGC(L); +} + + + +/*============================================================*/ +/* GRAMMAR RULES */ +/*============================================================*/ + + +/* +** check whether current token is in the follow set of a block. +** 'until' closes syntactical blocks, but do not close scope, +** so it is handled in separate. +*/ +static int block_follow (LexState *ls, int withuntil) { + switch (ls->t.token) { + case TK_ELSE: case TK_ELSEIF: + case TK_END: case TK_EOS: + return 1; + case TK_UNTIL: return withuntil; + default: return 0; + } +} + + +static void statlist (LexState *ls) { + /* statlist -> { stat [';'] } */ + while (!block_follow(ls, 1)) { + if (ls->t.token == TK_RETURN) { + statement(ls); + return; /* 'return' must be last statement */ + } + statement(ls); + } +} + + +static void fieldsel (LexState *ls, expdesc *v) { + /* fieldsel -> ['.' | ':'] NAME */ + FuncState *fs = ls->fs; + expdesc key; + luaK_exp2anyregup(fs, v); + luaX_next(ls); /* skip the dot or colon */ + checkname(ls, &key); + luaK_indexed(fs, v, &key); +} + + +static void yindex (LexState *ls, expdesc *v) { + /* index -> '[' expr ']' */ + luaX_next(ls); /* skip the '[' */ + expr(ls, v); + luaK_exp2val(ls->fs, v); + checknext(ls, ']'); +} + + +/* +** {====================================================================== +** Rules for Constructors +** ======================================================================= +*/ + + +struct ConsControl { + expdesc v; /* last list item read */ + expdesc *t; /* table descriptor */ + int nh; /* total number of 'record' elements */ + int na; /* total number of array elements */ + int tostore; /* number of array elements pending to be stored */ +}; + + +static void recfield (LexState *ls, struct ConsControl *cc) { + /* recfield -> (NAME | '['exp1']') = exp1 */ + FuncState *fs = ls->fs; + int reg = ls->fs->freereg; + expdesc key, val; + int rkkey; + if (ls->t.token == TK_NAME) { + checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checkname(ls, &key); + } + else /* ls->t.token == '[' */ + yindex(ls, &key); + cc->nh++; + checknext(ls, '='); + rkkey = luaK_exp2RK(fs, &key); + expr(ls, &val); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.info, rkkey, luaK_exp2RK(fs, &val)); + fs->freereg = reg; /* free registers */ +} + + +static void closelistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->v.k == VVOID) return; /* there is no list item */ + luaK_exp2nextreg(fs, &cc->v); + cc->v.k = VVOID; + if (cc->tostore == LFIELDS_PER_FLUSH) { + luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); /* flush */ + cc->tostore = 0; /* no more items pending */ + } +} + + +static void lastlistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->tostore == 0) return; + if (hasmultret(cc->v.k)) { + luaK_setmultret(fs, &cc->v); + luaK_setlist(fs, cc->t->u.info, cc->na, LUA_MULTRET); + cc->na--; /* do not count last expression (unknown number of elements) */ + } + else { + if (cc->v.k != VVOID) + luaK_exp2nextreg(fs, &cc->v); + luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); + } +} + + +static void listfield (LexState *ls, struct ConsControl *cc) { + /* listfield -> exp */ + expr(ls, &cc->v); + checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + cc->na++; + cc->tostore++; +} + + +static void field (LexState *ls, struct ConsControl *cc) { + /* field -> listfield | recfield */ + switch(ls->t.token) { + case TK_NAME: { /* may be 'listfield' or 'recfield' */ + if (luaX_lookahead(ls) != '=') /* expression? */ + listfield(ls, cc); + else + recfield(ls, cc); + break; + } + case '[': { + recfield(ls, cc); + break; + } + default: { + listfield(ls, cc); + break; + } + } +} + + +static void constructor (LexState *ls, expdesc *t) { + /* constructor -> '{' [ field { sep field } [sep] ] '}' + sep -> ',' | ';' */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + struct ConsControl cc; + cc.na = cc.nh = cc.tostore = 0; + cc.t = t; + init_exp(t, VRELOCABLE, pc); + init_exp(&cc.v, VVOID, 0); /* no value (yet) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ + checknext(ls, '{'); + do { + lua_assert(cc.v.k == VVOID || cc.tostore > 0); + if (ls->t.token == '}') break; + closelistfield(fs, &cc); + field(ls, &cc); + } while (testnext(ls, ',') || testnext(ls, ';')); + check_match(ls, '}', '{', line); + lastlistfield(fs, &cc); + SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ +} + +/* }====================================================================== */ + + + +static void parlist (LexState *ls) { + /* parlist -> [ param { ',' param } ] */ + FuncState *fs = ls->fs; + Proto *f = fs->f; + int nparams = 0; + f->is_vararg = 0; + if (ls->t.token != ')') { /* is 'parlist' not empty? */ + do { + switch (ls->t.token) { + case TK_NAME: { /* param -> NAME */ + new_localvar(ls, str_checkname(ls)); + nparams++; + break; + } + case TK_DOTS: { /* param -> '...' */ + luaX_next(ls); + f->is_vararg = 1; /* declared vararg */ + break; + } + default: luaX_syntaxerror(ls, " or '...' expected"); + } + } while (!f->is_vararg && testnext(ls, ',')); + } + adjustlocalvars(ls, nparams); + f->numparams = cast_byte(fs->nactvar); + luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ +} + + +static void body (LexState *ls, expdesc *e, int ismethod, int line) { + /* body -> '(' parlist ')' block END */ + FuncState new_fs; + BlockCnt bl; + new_fs.f = addprototype(ls); + new_fs.f->linedefined = line; + open_func(ls, &new_fs, &bl); + checknext(ls, '('); + if (ismethod) { + new_localvarliteral(ls, "self"); /* create 'self' parameter */ + adjustlocalvars(ls, 1); + } + parlist(ls); + checknext(ls, ')'); + statlist(ls); + new_fs.f->lastlinedefined = ls->linenumber; + check_match(ls, TK_END, TK_FUNCTION, line); + codeclosure(ls, e); + close_func(ls); +} + + +static int explist (LexState *ls, expdesc *v) { + /* explist -> expr { ',' expr } */ + int n = 1; /* at least one expression */ + expr(ls, v); + while (testnext(ls, ',')) { + luaK_exp2nextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + + +static void funcargs (LexState *ls, expdesc *f, int line) { + FuncState *fs = ls->fs; + expdesc args; + int base, nparams; + switch (ls->t.token) { + case '(': { /* funcargs -> '(' [ explist ] ')' */ + luaX_next(ls); + if (ls->t.token == ')') /* arg list is empty? */ + args.k = VVOID; + else { + explist(ls, &args); + luaK_setmultret(fs, &args); + } + check_match(ls, ')', '(', line); + break; + } + case '{': { /* funcargs -> constructor */ + constructor(ls, &args); + break; + } + case TK_STRING: { /* funcargs -> STRING */ + codestring(ls, &args, ls->t.seminfo.ts); + luaX_next(ls); /* must use 'seminfo' before 'next' */ + break; + } + default: { + luaX_syntaxerror(ls, "function arguments expected"); + } + } + lua_assert(f->k == VNONRELOC); + base = f->u.info; /* base register for call */ + if (hasmultret(args.k)) + nparams = LUA_MULTRET; /* open call */ + else { + if (args.k != VVOID) + luaK_exp2nextreg(fs, &args); /* close last argument */ + nparams = fs->freereg - (base+1); + } + init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + luaK_fixline(fs, line); + fs->freereg = base+1; /* call remove function and arguments and leaves + (unless changed) one result */ +} + + + + +/* +** {====================================================================== +** Expression parsing +** ======================================================================= +*/ + + +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> NAME | '(' expr ')' */ + switch (ls->t.token) { + case '(': { + int line = ls->linenumber; + luaX_next(ls); + expr(ls, v); + check_match(ls, ')', '(', line); + luaK_dischargevars(ls->fs, v); + return; + } + case TK_NAME: { + singlevar(ls, v); + return; + } + default: { + luaX_syntaxerror(ls, "unexpected symbol"); + } + } +} + + +static void suffixedexp (LexState *ls, expdesc *v) { + /* suffixedexp -> + primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + primaryexp(ls, v); + for (;;) { + switch (ls->t.token) { + case '.': { /* fieldsel */ + fieldsel(ls, v); + break; + } + case '[': { /* '[' exp1 ']' */ + expdesc key; + luaK_exp2anyregup(fs, v); + yindex(ls, &key); + luaK_indexed(fs, v, &key); + break; + } + case ':': { /* ':' NAME funcargs */ + expdesc key; + luaX_next(ls); + checkname(ls, &key); + luaK_self(fs, v, &key); + funcargs(ls, v, line); + break; + } + case '(': case TK_STRING: case '{': { /* funcargs */ + luaK_exp2nextreg(fs, v); + funcargs(ls, v, line); + break; + } + default: return; + } + } +} + + +static void simpleexp (LexState *ls, expdesc *v) { + /* simpleexp -> FLT | INT | STRING | NIL | TRUE | FALSE | ... | + constructor | FUNCTION body | suffixedexp */ + switch (ls->t.token) { + case TK_FLT: { + init_exp(v, VKFLT, 0); + v->u.nval = ls->t.seminfo.r; + break; + } + case TK_INT: { + init_exp(v, VKINT, 0); + v->u.ival = ls->t.seminfo.i; + break; + } + case TK_STRING: { + codestring(ls, v, ls->t.seminfo.ts); + break; + } + case TK_NIL: { + init_exp(v, VNIL, 0); + break; + } + case TK_TRUE: { + init_exp(v, VTRUE, 0); + break; + } + case TK_FALSE: { + init_exp(v, VFALSE, 0); + break; + } + case TK_DOTS: { /* vararg */ + FuncState *fs = ls->fs; + check_condition(ls, fs->f->is_vararg, + "cannot use '...' outside a vararg function"); + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + break; + } + case '{': { /* constructor */ + constructor(ls, v); + return; + } + case TK_FUNCTION: { + luaX_next(ls); + body(ls, v, 0, ls->linenumber); + return; + } + default: { + suffixedexp(ls, v); + return; + } + } + luaX_next(ls); +} + + +static UnOpr getunopr (int op) { + switch (op) { + case TK_NOT: return OPR_NOT; + case '-': return OPR_MINUS; + case '~': return OPR_BNOT; + case '#': return OPR_LEN; + default: return OPR_NOUNOPR; + } +} + + +static BinOpr getbinopr (int op) { + switch (op) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case '/': return OPR_DIV; + case TK_IDIV: return OPR_IDIV; + case '&': return OPR_BAND; + case '|': return OPR_BOR; + case '~': return OPR_BXOR; + case TK_SHL: return OPR_SHL; + case TK_SHR: return OPR_SHR; + case TK_CONCAT: return OPR_CONCAT; + case TK_NE: return OPR_NE; + case TK_EQ: return OPR_EQ; + case '<': return OPR_LT; + case TK_LE: return OPR_LE; + case '>': return OPR_GT; + case TK_GE: return OPR_GE; + case TK_AND: return OPR_AND; + case TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + + +static const struct { + lu_byte left; /* left priority for each binary operator */ + lu_byte right; /* right priority */ +} priority[] = { /* ORDER OPR */ + {10, 10}, {10, 10}, /* '+' '-' */ + {11, 11}, {11, 11}, /* '*' '%' */ + {14, 13}, /* '^' (right associative) */ + {11, 11}, {11, 11}, /* '/' '//' */ + {6, 6}, {4, 4}, {5, 5}, /* '&' '|' '~' */ + {7, 7}, {7, 7}, /* '<<' '>>' */ + {9, 8}, /* '..' (right associative) */ + {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ + {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ + {2, 2}, {1, 1} /* and, or */ +}; + +#define UNARY_PRIORITY 12 /* priority for unary operators */ + + +/* +** subexpr -> (simpleexp | unop subexpr) { binop subexpr } +** where 'binop' is any binary operator with a priority higher than 'limit' +*/ +static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { + BinOpr op; + UnOpr uop; + enterlevel(ls); + uop = getunopr(ls->t.token); + if (uop != OPR_NOUNOPR) { + int line = ls->linenumber; + luaX_next(ls); + subexpr(ls, v, UNARY_PRIORITY); + luaK_prefix(ls->fs, uop, v, line); + } + else simpleexp(ls, v); + /* expand while operators have priorities higher than 'limit' */ + op = getbinopr(ls->t.token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + expdesc v2; + BinOpr nextop; + int line = ls->linenumber; + luaX_next(ls); + luaK_infix(ls->fs, op, v); + /* read sub-expression with higher priority */ + nextop = subexpr(ls, &v2, priority[op].right); + luaK_posfix(ls->fs, op, v, &v2, line); + op = nextop; + } + leavelevel(ls); + return op; /* return first untreated operator */ +} + + +static void expr (LexState *ls, expdesc *v) { + subexpr(ls, v, 0); +} + +/* }==================================================================== */ + + + +/* +** {====================================================================== +** Rules for Statements +** ======================================================================= +*/ + + +static void block (LexState *ls) { + /* block -> statlist */ + FuncState *fs = ls->fs; + BlockCnt bl; + enterblock(fs, &bl, 0); + statlist(ls); + leaveblock(fs); +} + + +/* +** structure to chain all variables in the left-hand side of an +** assignment +*/ +struct LHS_assign { + struct LHS_assign *prev; + expdesc v; /* variable (global, local, upvalue, or indexed) */ +}; + + +/* +** check whether, in an assignment to an upvalue/local variable, the +** upvalue/local variable is begin used in a previous assignment to a +** table. If so, save original upvalue/local value in a safe place and +** use this safe copy in the previous assignment. +*/ +static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { + FuncState *fs = ls->fs; + int extra = fs->freereg; /* eventual position to save local variable */ + int conflict = 0; + for (; lh; lh = lh->prev) { /* check all previous assignments */ + if (lh->v.k == VINDEXED) { /* assigning to a table? */ + /* table is the upvalue/local being assigned now? */ + if (lh->v.u.ind.vt == v->k && lh->v.u.ind.t == v->u.info) { + conflict = 1; + lh->v.u.ind.vt = VLOCAL; + lh->v.u.ind.t = extra; /* previous assignment will use safe copy */ + } + /* index is the local being assigned? (index cannot be upvalue) */ + if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) { + conflict = 1; + lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */ + } + } + } + if (conflict) { + /* copy upvalue/local value to a temporary (in position 'extra') */ + OpCode op = (v->k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, op, extra, v->u.info, 0); + luaK_reserveregs(fs, 1); + } +} + + +static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { + expdesc e; + check_condition(ls, vkisvar(lh->v.k), "syntax error"); + if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */ + struct LHS_assign nv; + nv.prev = lh; + suffixedexp(ls, &nv.v); + if (nv.v.k != VINDEXED) + check_conflict(ls, lh, &nv.v); + checklimit(ls->fs, nvars + ls->L->nCcalls, LUAI_MAXCCALLS, + "C levels"); + assignment(ls, &nv, nvars+1); + } + else { /* assignment -> '=' explist */ + int nexps; + checknext(ls, '='); + nexps = explist(ls, &e); + if (nexps != nvars) + adjust_assign(ls, nvars, nexps, &e); + else { + luaK_setoneret(ls->fs, &e); /* close last expression */ + luaK_storevar(ls->fs, &lh->v, &e); + return; /* avoid default */ + } + } + init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ + luaK_storevar(ls->fs, &lh->v, &e); +} + + +static int cond (LexState *ls) { + /* cond -> exp */ + expdesc v; + expr(ls, &v); /* read condition */ + if (v.k == VNIL) v.k = VFALSE; /* 'falses' are all equal here */ + luaK_goiftrue(ls->fs, &v); + return v.f; +} + + +static void gotostat (LexState *ls, int pc) { + int line = ls->linenumber; + TString *label; + int g; + if (testnext(ls, TK_GOTO)) + label = str_checkname(ls); + else { + luaX_next(ls); /* skip break */ + label = luaS_new(ls->L, "break"); + } + g = newlabelentry(ls, &ls->dyd->gt, label, line, pc); + findlabel(ls, g); /* close it if label already defined */ +} + + +/* check for repeated labels on the same block */ +static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) { + int i; + for (i = fs->bl->firstlabel; i < ll->n; i++) { + if (eqstr(label, ll->arr[i].name)) { + const char *msg = luaO_pushfstring(fs->ls->L, + "label '%s' already defined on line %d", + getstr(label), ll->arr[i].line); + semerror(fs->ls, msg); + } + } +} + + +/* skip no-op statements */ +static void skipnoopstat (LexState *ls) { + while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) + statement(ls); +} + + +static void labelstat (LexState *ls, TString *label, int line) { + /* label -> '::' NAME '::' */ + FuncState *fs = ls->fs; + Labellist *ll = &ls->dyd->label; + int l; /* index of new label being created */ + checkrepeated(fs, ll, label); /* check for repeated labels */ + checknext(ls, TK_DBCOLON); /* skip double colon */ + /* create new entry for this label */ + l = newlabelentry(ls, ll, label, line, luaK_getlabel(fs)); + skipnoopstat(ls); /* skip other no-op statements */ + if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ + /* assume that locals are already out of scope */ + ll->arr[l].nactvar = fs->bl->nactvar; + } + findgotos(ls, &ll->arr[l]); +} + + +static void whilestat (LexState *ls, int line) { + /* whilestat -> WHILE cond DO block END */ + FuncState *fs = ls->fs; + int whileinit; + int condexit; + BlockCnt bl; + luaX_next(ls); /* skip WHILE */ + whileinit = luaK_getlabel(fs); + condexit = cond(ls); + enterblock(fs, &bl, 1); + checknext(ls, TK_DO); + block(ls); + luaK_jumpto(fs, whileinit); + check_match(ls, TK_END, TK_WHILE, line); + leaveblock(fs); + luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ +} + + +static void repeatstat (LexState *ls, int line) { + /* repeatstat -> REPEAT block UNTIL cond */ + int condexit; + FuncState *fs = ls->fs; + int repeat_init = luaK_getlabel(fs); + BlockCnt bl1, bl2; + enterblock(fs, &bl1, 1); /* loop block */ + enterblock(fs, &bl2, 0); /* scope block */ + luaX_next(ls); /* skip REPEAT */ + statlist(ls); + check_match(ls, TK_UNTIL, TK_REPEAT, line); + condexit = cond(ls); /* read condition (inside scope block) */ + if (bl2.upval) /* upvalues? */ + luaK_patchclose(fs, condexit, bl2.nactvar); + leaveblock(fs); /* finish scope */ + luaK_patchlist(fs, condexit, repeat_init); /* close the loop */ + leaveblock(fs); /* finish loop */ +} + + +static int exp1 (LexState *ls) { + expdesc e; + int reg; + expr(ls, &e); + luaK_exp2nextreg(ls->fs, &e); + lua_assert(e.k == VNONRELOC); + reg = e.u.info; + return reg; +} + + +static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { + /* forbody -> DO block */ + BlockCnt bl; + FuncState *fs = ls->fs; + int prep, endfor; + adjustlocalvars(ls, 3); /* control variables */ + checknext(ls, TK_DO); + prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + enterblock(fs, &bl, 0); /* scope for declared variables */ + adjustlocalvars(ls, nvars); + luaK_reserveregs(fs, nvars); + block(ls); + leaveblock(fs); /* end of scope for declared variables */ + luaK_patchtohere(fs, prep); + if (isnum) /* numeric for? */ + endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP); + else { /* generic for */ + luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars); + luaK_fixline(fs, line); + endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP); + } + luaK_patchlist(fs, endfor, prep + 1); + luaK_fixline(fs, line); +} + + +static void fornum (LexState *ls, TString *varname, int line) { + /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + FuncState *fs = ls->fs; + int base = fs->freereg; + new_localvarliteral(ls, "(for index)"); + new_localvarliteral(ls, "(for limit)"); + new_localvarliteral(ls, "(for step)"); + new_localvar(ls, varname); + checknext(ls, '='); + exp1(ls); /* initial value */ + checknext(ls, ','); + exp1(ls); /* limit */ + if (testnext(ls, ',')) + exp1(ls); /* optional step */ + else { /* default step = 1 */ + luaK_codek(fs, fs->freereg, luaK_intK(fs, 1)); + luaK_reserveregs(fs, 1); + } + forbody(ls, base, line, 1, 1); +} + + +static void forlist (LexState *ls, TString *indexname) { + /* forlist -> NAME {,NAME} IN explist forbody */ + FuncState *fs = ls->fs; + expdesc e; + int nvars = 4; /* gen, state, control, plus at least one declared var */ + int line; + int base = fs->freereg; + /* create control variables */ + new_localvarliteral(ls, "(for generator)"); + new_localvarliteral(ls, "(for state)"); + new_localvarliteral(ls, "(for control)"); + /* create declared variables */ + new_localvar(ls, indexname); + while (testnext(ls, ',')) { + new_localvar(ls, str_checkname(ls)); + nvars++; + } + checknext(ls, TK_IN); + line = ls->linenumber; + adjust_assign(ls, 3, explist(ls, &e), &e); + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 3, 0); +} + + +static void forstat (LexState *ls, int line) { + /* forstat -> FOR (fornum | forlist) END */ + FuncState *fs = ls->fs; + TString *varname; + BlockCnt bl; + enterblock(fs, &bl, 1); /* scope for loop and control variables */ + luaX_next(ls); /* skip 'for' */ + varname = str_checkname(ls); /* first variable name */ + switch (ls->t.token) { + case '=': fornum(ls, varname, line); break; + case ',': case TK_IN: forlist(ls, varname); break; + default: luaX_syntaxerror(ls, "'=' or 'in' expected"); + } + check_match(ls, TK_END, TK_FOR, line); + leaveblock(fs); /* loop scope ('break' jumps to this point) */ +} + + +static void test_then_block (LexState *ls, int *escapelist) { + /* test_then_block -> [IF | ELSEIF] cond THEN block */ + BlockCnt bl; + FuncState *fs = ls->fs; + expdesc v; + int jf; /* instruction to skip 'then' code (if condition is false) */ + luaX_next(ls); /* skip IF or ELSEIF */ + expr(ls, &v); /* read condition */ + checknext(ls, TK_THEN); + if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) { + luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ + enterblock(fs, &bl, 0); /* must enter block before 'goto' */ + gotostat(ls, v.t); /* handle goto/break */ + skipnoopstat(ls); /* skip other no-op statements */ + if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ + leaveblock(fs); + return; /* and that is it */ + } + else /* must skip over 'then' part if condition is false */ + jf = luaK_jump(fs); + } + else { /* regular case (not goto/break) */ + luaK_goiftrue(ls->fs, &v); /* skip over block if condition is false */ + enterblock(fs, &bl, 0); + jf = v.f; + } + statlist(ls); /* 'then' part */ + leaveblock(fs); + if (ls->t.token == TK_ELSE || + ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */ + luaK_concat(fs, escapelist, luaK_jump(fs)); /* must jump over it */ + luaK_patchtohere(fs, jf); +} + + +static void ifstat (LexState *ls, int line) { + /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ + FuncState *fs = ls->fs; + int escapelist = NO_JUMP; /* exit list for finished parts */ + test_then_block(ls, &escapelist); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) + test_then_block(ls, &escapelist); /* ELSEIF cond THEN block */ + if (testnext(ls, TK_ELSE)) + block(ls); /* 'else' part */ + check_match(ls, TK_END, TK_IF, line); + luaK_patchtohere(fs, escapelist); /* patch escape list to 'if' end */ +} + + +static void localfunc (LexState *ls) { + expdesc b; + FuncState *fs = ls->fs; + new_localvar(ls, str_checkname(ls)); /* new local variable */ + adjustlocalvars(ls, 1); /* enter its scope */ + body(ls, &b, 0, ls->linenumber); /* function created in next register */ + /* debug information will only see the variable after this point! */ + getlocvar(fs, b.u.info)->startpc = fs->pc; +} + + +static void localstat (LexState *ls) { + /* stat -> LOCAL NAME {',' NAME} ['=' explist] */ + int nvars = 0; + int nexps; + expdesc e; + do { + new_localvar(ls, str_checkname(ls)); + nvars++; + } while (testnext(ls, ',')); + if (testnext(ls, '=')) + nexps = explist(ls, &e); + else { + e.k = VVOID; + nexps = 0; + } + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); +} + + +static int funcname (LexState *ls, expdesc *v) { + /* funcname -> NAME {fieldsel} [':' NAME] */ + int ismethod = 0; + singlevar(ls, v); + while (ls->t.token == '.') + fieldsel(ls, v); + if (ls->t.token == ':') { + ismethod = 1; + fieldsel(ls, v); + } + return ismethod; +} + + +static void funcstat (LexState *ls, int line) { + /* funcstat -> FUNCTION funcname body */ + int ismethod; + expdesc v, b; + luaX_next(ls); /* skip FUNCTION */ + ismethod = funcname(ls, &v); + body(ls, &b, ismethod, line); + luaK_storevar(ls->fs, &v, &b); + luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ +} + + +static void exprstat (LexState *ls) { + /* stat -> func | assignment */ + FuncState *fs = ls->fs; + struct LHS_assign v; + suffixedexp(ls, &v.v); + if (ls->t.token == '=' || ls->t.token == ',') { /* stat -> assignment ? */ + v.prev = NULL; + assignment(ls, &v, 1); + } + else { /* stat -> func */ + check_condition(ls, v.v.k == VCALL, "syntax error"); + SETARG_C(getinstruction(fs, &v.v), 1); /* call statement uses no results */ + } +} + + +static void retstat (LexState *ls) { + /* stat -> RETURN [explist] [';'] */ + FuncState *fs = ls->fs; + expdesc e; + int first, nret; /* registers with returned values */ + if (block_follow(ls, 1) || ls->t.token == ';') + first = nret = 0; /* return no values */ + else { + nret = explist(ls, &e); /* optional return values */ + if (hasmultret(e.k)) { + luaK_setmultret(fs, &e); + if (e.k == VCALL && nret == 1) { /* tail call? */ + SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL); + lua_assert(GETARG_A(getinstruction(fs,&e)) == fs->nactvar); + } + first = fs->nactvar; + nret = LUA_MULTRET; /* return all values */ + } + else { + if (nret == 1) /* only one single value? */ + first = luaK_exp2anyreg(fs, &e); + else { + luaK_exp2nextreg(fs, &e); /* values must go to the stack */ + first = fs->nactvar; /* return all active values */ + lua_assert(nret == fs->freereg - first); + } + } + } + luaK_ret(fs, first, nret); + testnext(ls, ';'); /* skip optional semicolon */ +} + + +static void statement (LexState *ls) { + int line = ls->linenumber; /* may be needed for error messages */ + enterlevel(ls); + switch (ls->t.token) { + case ';': { /* stat -> ';' (empty statement) */ + luaX_next(ls); /* skip ';' */ + break; + } + case TK_IF: { /* stat -> ifstat */ + ifstat(ls, line); + break; + } + case TK_WHILE: { /* stat -> whilestat */ + whilestat(ls, line); + break; + } + case TK_DO: { /* stat -> DO block END */ + luaX_next(ls); /* skip DO */ + block(ls); + check_match(ls, TK_END, TK_DO, line); + break; + } + case TK_FOR: { /* stat -> forstat */ + forstat(ls, line); + break; + } + case TK_REPEAT: { /* stat -> repeatstat */ + repeatstat(ls, line); + break; + } + case TK_FUNCTION: { /* stat -> funcstat */ + funcstat(ls, line); + break; + } + case TK_LOCAL: { /* stat -> localstat */ + luaX_next(ls); /* skip LOCAL */ + if (testnext(ls, TK_FUNCTION)) /* local function? */ + localfunc(ls); + else + localstat(ls); + break; + } + case TK_DBCOLON: { /* stat -> label */ + luaX_next(ls); /* skip double colon */ + labelstat(ls, str_checkname(ls), line); + break; + } + case TK_RETURN: { /* stat -> retstat */ + luaX_next(ls); /* skip RETURN */ + retstat(ls); + break; + } + case TK_BREAK: /* stat -> breakstat */ + case TK_GOTO: { /* stat -> 'goto' NAME */ + gotostat(ls, luaK_jump(ls->fs)); + break; + } + default: { /* stat -> func | assignment */ + exprstat(ls); + break; + } + } + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ + leavelevel(ls); +} + +/* }====================================================================== */ + + +/* +** compiles the main function, which is a regular vararg function with an +** upvalue named LUA_ENV +*/ +static void mainfunc (LexState *ls, FuncState *fs) { + BlockCnt bl; + expdesc v; + open_func(ls, fs, &bl); + fs->f->is_vararg = 1; /* main function is always declared vararg */ + init_exp(&v, VLOCAL, 0); /* create and... */ + newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ + luaX_next(ls); /* read first token */ + statlist(ls); /* parse main body */ + check(ls, TK_EOS); + close_func(ls); +} + + +LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + Dyndata *dyd, const char *name, int firstchar) { + LexState lexstate; + FuncState funcstate; + LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */ + setclLvalue(L, L->top, cl); /* anchor it (to avoid being collected) */ + luaD_inctop(L); + lexstate.h = luaH_new(L); /* create table for scanner */ + sethvalue(L, L->top, lexstate.h); /* anchor it */ + luaD_inctop(L); + funcstate.f = cl->p = luaF_newproto(L); + funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ + lua_assert(iswhite(funcstate.f)); /* do not need barrier here */ + lexstate.buff = buff; + lexstate.dyd = dyd; + dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; + luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar); + mainfunc(&lexstate, &funcstate); + lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); + /* all scopes should be correctly finished */ + lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); + L->top--; /* remove scanner's table */ + return cl; /* closure is on the stack, too */ +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lparser.h b/dep/scintilla/scintilla-3.10.6/lua/src/lparser.h new file mode 100644 index 00000000..02e9b03a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lparser.h @@ -0,0 +1,133 @@ +/* +** $Id: lparser.h,v 1.76 2015/12/30 18:16:13 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression and variable descriptor. +** Code generation for variables and expressions can be delayed to allow +** optimizations; An 'expdesc' structure describes a potentially-delayed +** variable/expression. It has a description of its "main" value plus a +** list of conditional jumps that can also produce its value (generated +** by short-circuit operators 'and'/'or'). +*/ + +/* kinds of variables/expressions */ +typedef enum { + VVOID, /* when 'expdesc' describes the last expression a list, + this kind means an empty list (so, no expression) */ + VNIL, /* constant nil */ + VTRUE, /* constant true */ + VFALSE, /* constant false */ + VK, /* constant in 'k'; info = index of constant in 'k' */ + VKFLT, /* floating constant; nval = numerical float value */ + VKINT, /* integer constant; nval = numerical integer value */ + VNONRELOC, /* expression has its value in a fixed register; + info = result register */ + VLOCAL, /* local variable; info = local register */ + VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ + VINDEXED, /* indexed variable; + ind.vt = whether 't' is register or upvalue; + ind.t = table register or upvalue; + ind.idx = key's R/K index */ + VJMP, /* expression is a test/comparison; + info = pc of corresponding jump instruction */ + VRELOCABLE, /* expression can put result in any register; + info = instruction pc */ + VCALL, /* expression is a function call; info = instruction pc */ + VVARARG /* vararg expression; info = instruction pc */ +} expkind; + + +#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED) +#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL) + +typedef struct expdesc { + expkind k; + union { + lua_Integer ival; /* for VKINT */ + lua_Number nval; /* for VKFLT */ + int info; /* for generic use */ + struct { /* for indexed variables (VINDEXED) */ + short idx; /* index (R/K) */ + lu_byte t; /* table (register or upvalue) */ + lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ + } ind; + } u; + int t; /* patch list of 'exit when true' */ + int f; /* patch list of 'exit when false' */ +} expdesc; + + +/* description of active local variable */ +typedef struct Vardesc { + short idx; /* variable index in stack */ +} Vardesc; + + +/* description of pending goto statements and label statements */ +typedef struct Labeldesc { + TString *name; /* label identifier */ + int pc; /* position in code */ + int line; /* line where it appeared */ + lu_byte nactvar; /* local level where it appears in current block */ +} Labeldesc; + + +/* list of labels or gotos */ +typedef struct Labellist { + Labeldesc *arr; /* array */ + int n; /* number of entries in use */ + int size; /* array size */ +} Labellist; + + +/* dynamic structures used by the parser */ +typedef struct Dyndata { + struct { /* list of active local variables */ + Vardesc *arr; + int n; + int size; + } actvar; + Labellist gt; /* list of pending gotos */ + Labellist label; /* list of active labels */ +} Dyndata; + + +/* control of blocks */ +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to 'ncode') */ + int lasttarget; /* 'label' of last 'jump label' */ + int jpc; /* list of pending jumps to 'pc' */ + int nk; /* number of elements in 'k' */ + int np; /* number of elements in 'p' */ + int firstlocal; /* index of first local var (in Dyndata array) */ + short nlocvars; /* number of elements in 'f->locvars' */ + lu_byte nactvar; /* number of active local variables */ + lu_byte nups; /* number of upvalues */ + lu_byte freereg; /* first free register */ +} FuncState; + + +LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + Dyndata *dyd, const char *name, int firstchar); + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lpcap.c b/dep/scintilla/scintilla-3.10.6/lua/src/lpcap.c new file mode 100644 index 00000000..c9085de0 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lpcap.c @@ -0,0 +1,537 @@ +/* +** $Id: lpcap.c,v 1.6 2015/06/15 16:09:57 roberto Exp $ +** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license) +*/ + +#include "lua.h" +#include "lauxlib.h" + +#include "lpcap.h" +#include "lptypes.h" + + +#define captype(cap) ((cap)->kind) + +#define isclosecap(cap) (captype(cap) == Cclose) + +#define closeaddr(c) ((c)->s + (c)->siz - 1) + +#define isfullcap(cap) ((cap)->siz != 0) + +#define getfromktable(cs,v) lua_rawgeti((cs)->L, ktableidx((cs)->ptop), v) + +#define pushluaval(cs) getfromktable(cs, (cs)->cap->idx) + + + +/* +** Put at the cache for Lua values the value indexed by 'v' in ktable +** of the running pattern (if it is not there yet); returns its index. +*/ +static int updatecache (CapState *cs, int v) { + int idx = cs->ptop + 1; /* stack index of cache for Lua values */ + if (v != cs->valuecached) { /* not there? */ + getfromktable(cs, v); /* get value from 'ktable' */ + lua_replace(cs->L, idx); /* put it at reserved stack position */ + cs->valuecached = v; /* keep track of what is there */ + } + return idx; +} + + +static int pushcapture (CapState *cs); + + +/* +** Goes back in a list of captures looking for an open capture +** corresponding to a close +*/ +static Capture *findopen (Capture *cap) { + int n = 0; /* number of closes waiting an open */ + for (;;) { + cap--; + if (isclosecap(cap)) n++; /* one more open to skip */ + else if (!isfullcap(cap)) + if (n-- == 0) return cap; + } +} + + +/* +** Go to the next capture +*/ +static void nextcap (CapState *cs) { + Capture *cap = cs->cap; + if (!isfullcap(cap)) { /* not a single capture? */ + int n = 0; /* number of opens waiting a close */ + for (;;) { /* look for corresponding close */ + cap++; + if (isclosecap(cap)) { + if (n-- == 0) break; + } + else if (!isfullcap(cap)) n++; + } + } + cs->cap = cap + 1; /* + 1 to skip last close (or entire single capture) */ +} + + +/* +** Push on the Lua stack all values generated by nested captures inside +** the current capture. Returns number of values pushed. 'addextra' +** makes it push the entire match after all captured values. The +** entire match is pushed also if there are no other nested values, +** so the function never returns zero. +*/ +static int pushnestedvalues (CapState *cs, int addextra) { + Capture *co = cs->cap; + if (isfullcap(cs->cap++)) { /* no nested captures? */ + lua_pushlstring(cs->L, co->s, co->siz - 1); /* push whole match */ + return 1; /* that is it */ + } + else { + int n = 0; + while (!isclosecap(cs->cap)) /* repeat for all nested patterns */ + n += pushcapture(cs); + if (addextra || n == 0) { /* need extra? */ + lua_pushlstring(cs->L, co->s, cs->cap->s - co->s); /* push whole match */ + n++; + } + cs->cap++; /* skip close entry */ + return n; + } +} + + +/* +** Push only the first value generated by nested captures +*/ +static void pushonenestedvalue (CapState *cs) { + int n = pushnestedvalues(cs, 0); + if (n > 1) + lua_pop(cs->L, n - 1); /* pop extra values */ +} + + +/* +** Try to find a named group capture with the name given at the top of +** the stack; goes backward from 'cap'. +*/ +static Capture *findback (CapState *cs, Capture *cap) { + lua_State *L = cs->L; + while (cap-- > cs->ocap) { /* repeat until end of list */ + if (isclosecap(cap)) + cap = findopen(cap); /* skip nested captures */ + else if (!isfullcap(cap)) + continue; /* opening an enclosing capture: skip and get previous */ + if (captype(cap) == Cgroup) { + getfromktable(cs, cap->idx); /* get group name */ + if (lp_equal(L, -2, -1)) { /* right group? */ + lua_pop(L, 2); /* remove reference name and group name */ + return cap; + } + else lua_pop(L, 1); /* remove group name */ + } + } + luaL_error(L, "back reference '%s' not found", lua_tostring(L, -1)); + return NULL; /* to avoid warnings */ +} + + +/* +** Back-reference capture. Return number of values pushed. +*/ +static int backrefcap (CapState *cs) { + int n; + Capture *curr = cs->cap; + pushluaval(cs); /* reference name */ + cs->cap = findback(cs, curr); /* find corresponding group */ + n = pushnestedvalues(cs, 0); /* push group's values */ + cs->cap = curr + 1; + return n; +} + + +/* +** Table capture: creates a new table and populates it with nested +** captures. +*/ +static int tablecap (CapState *cs) { + lua_State *L = cs->L; + int n = 0; + lua_newtable(L); + if (isfullcap(cs->cap++)) + return 1; /* table is empty */ + while (!isclosecap(cs->cap)) { + if (captype(cs->cap) == Cgroup && cs->cap->idx != 0) { /* named group? */ + pushluaval(cs); /* push group name */ + pushonenestedvalue(cs); + lua_settable(L, -3); + } + else { /* not a named group */ + int i; + int k = pushcapture(cs); + for (i = k; i > 0; i--) /* store all values into table */ + lua_rawseti(L, -(i + 1), n + i); + n += k; + } + } + cs->cap++; /* skip close entry */ + return 1; /* number of values pushed (only the table) */ +} + + +/* +** Table-query capture +*/ +static int querycap (CapState *cs) { + int idx = cs->cap->idx; + pushonenestedvalue(cs); /* get nested capture */ + lua_gettable(cs->L, updatecache(cs, idx)); /* query cap. value at table */ + if (!lua_isnil(cs->L, -1)) + return 1; + else { /* no value */ + lua_pop(cs->L, 1); /* remove nil */ + return 0; + } +} + + +/* +** Fold capture +*/ +static int foldcap (CapState *cs) { + int n; + lua_State *L = cs->L; + int idx = cs->cap->idx; + if (isfullcap(cs->cap++) || /* no nested captures? */ + isclosecap(cs->cap) || /* no nested captures (large subject)? */ + (n = pushcapture(cs)) == 0) /* nested captures with no values? */ + return luaL_error(L, "no initial value for fold capture"); + if (n > 1) + lua_pop(L, n - 1); /* leave only one result for accumulator */ + while (!isclosecap(cs->cap)) { + lua_pushvalue(L, updatecache(cs, idx)); /* get folding function */ + lua_insert(L, -2); /* put it before accumulator */ + n = pushcapture(cs); /* get next capture's values */ + lua_call(L, n + 1, 1); /* call folding function */ + } + cs->cap++; /* skip close entry */ + return 1; /* only accumulator left on the stack */ +} + + +/* +** Function capture +*/ +static int functioncap (CapState *cs) { + int n; + int top = lua_gettop(cs->L); + pushluaval(cs); /* push function */ + n = pushnestedvalues(cs, 0); /* push nested captures */ + lua_call(cs->L, n, LUA_MULTRET); /* call function */ + return lua_gettop(cs->L) - top; /* return function's results */ +} + + +/* +** Select capture +*/ +static int numcap (CapState *cs) { + int idx = cs->cap->idx; /* value to select */ + if (idx == 0) { /* no values? */ + nextcap(cs); /* skip entire capture */ + return 0; /* no value produced */ + } + else { + int n = pushnestedvalues(cs, 0); + if (n < idx) /* invalid index? */ + return luaL_error(cs->L, "no capture '%d'", idx); + else { + lua_pushvalue(cs->L, -(n - idx + 1)); /* get selected capture */ + lua_replace(cs->L, -(n + 1)); /* put it in place of 1st capture */ + lua_pop(cs->L, n - 1); /* remove other captures */ + return 1; + } + } +} + + +/* +** Return the stack index of the first runtime capture in the given +** list of captures (or zero if no runtime captures) +*/ +int finddyncap (Capture *cap, Capture *last) { + for (; cap < last; cap++) { + if (cap->kind == Cruntime) + return cap->idx; /* stack position of first capture */ + } + return 0; /* no dynamic captures in this segment */ +} + + +/* +** Calls a runtime capture. Returns number of captures removed by +** the call, including the initial Cgroup. (Captures to be added are +** on the Lua stack.) +*/ +int runtimecap (CapState *cs, Capture *close, const char *s, int *rem) { + int n, id; + lua_State *L = cs->L; + int otop = lua_gettop(L); + Capture *open = findopen(close); + assert(captype(open) == Cgroup); + id = finddyncap(open, close); /* get first dynamic capture argument */ + close->kind = Cclose; /* closes the group */ + close->s = s; + cs->cap = open; cs->valuecached = 0; /* prepare capture state */ + luaL_checkstack(L, 4, "too many runtime captures"); + pushluaval(cs); /* push function to be called */ + lua_pushvalue(L, SUBJIDX); /* push original subject */ + lua_pushinteger(L, s - cs->s + 1); /* push current position */ + n = pushnestedvalues(cs, 0); /* push nested captures */ + lua_call(L, n + 2, LUA_MULTRET); /* call dynamic function */ + if (id > 0) { /* are there old dynamic captures to be removed? */ + int i; + for (i = id; i <= otop; i++) + lua_remove(L, id); /* remove old dynamic captures */ + *rem = otop - id + 1; /* total number of dynamic captures removed */ + } + else + *rem = 0; /* no dynamic captures removed */ + return close - open; /* number of captures of all kinds removed */ +} + + +/* +** Auxiliary structure for substitution and string captures: keep +** information about nested captures for future use, avoiding to push +** string results into Lua +*/ +typedef struct StrAux { + int isstring; /* whether capture is a string */ + union { + Capture *cp; /* if not a string, respective capture */ + struct { /* if it is a string... */ + const char *s; /* ... starts here */ + const char *e; /* ... ends here */ + } s; + } u; +} StrAux; + +#define MAXSTRCAPS 10 + +/* +** Collect values from current capture into array 'cps'. Current +** capture must be Cstring (first call) or Csimple (recursive calls). +** (In first call, fills %0 with whole match for Cstring.) +** Returns number of elements in the array that were filled. +*/ +static int getstrcaps (CapState *cs, StrAux *cps, int n) { + int k = n++; + cps[k].isstring = 1; /* get string value */ + cps[k].u.s.s = cs->cap->s; /* starts here */ + if (!isfullcap(cs->cap++)) { /* nested captures? */ + while (!isclosecap(cs->cap)) { /* traverse them */ + if (n >= MAXSTRCAPS) /* too many captures? */ + nextcap(cs); /* skip extra captures (will not need them) */ + else if (captype(cs->cap) == Csimple) /* string? */ + n = getstrcaps(cs, cps, n); /* put info. into array */ + else { + cps[n].isstring = 0; /* not a string */ + cps[n].u.cp = cs->cap; /* keep original capture */ + nextcap(cs); + n++; + } + } + cs->cap++; /* skip close */ + } + cps[k].u.s.e = closeaddr(cs->cap - 1); /* ends here */ + return n; +} + + +/* +** add next capture value (which should be a string) to buffer 'b' +*/ +static int addonestring (luaL_Buffer *b, CapState *cs, const char *what); + + +/* +** String capture: add result to buffer 'b' (instead of pushing +** it into the stack) +*/ +static void stringcap (luaL_Buffer *b, CapState *cs) { + StrAux cps[MAXSTRCAPS]; + int n; + size_t len, i; + const char *fmt; /* format string */ + fmt = lua_tolstring(cs->L, updatecache(cs, cs->cap->idx), &len); + n = getstrcaps(cs, cps, 0) - 1; /* collect nested captures */ + for (i = 0; i < len; i++) { /* traverse them */ + if (fmt[i] != '%') /* not an escape? */ + luaL_addchar(b, fmt[i]); /* add it to buffer */ + else if (fmt[++i] < '0' || fmt[i] > '9') /* not followed by a digit? */ + luaL_addchar(b, fmt[i]); /* add to buffer */ + else { + int l = fmt[i] - '0'; /* capture index */ + if (l > n) + luaL_error(cs->L, "invalid capture index (%d)", l); + else if (cps[l].isstring) + luaL_addlstring(b, cps[l].u.s.s, cps[l].u.s.e - cps[l].u.s.s); + else { + Capture *curr = cs->cap; + cs->cap = cps[l].u.cp; /* go back to evaluate that nested capture */ + if (!addonestring(b, cs, "capture")) + luaL_error(cs->L, "no values in capture index %d", l); + cs->cap = curr; /* continue from where it stopped */ + } + } + } +} + + +/* +** Substitution capture: add result to buffer 'b' +*/ +static void substcap (luaL_Buffer *b, CapState *cs) { + const char *curr = cs->cap->s; + if (isfullcap(cs->cap)) /* no nested captures? */ + luaL_addlstring(b, curr, cs->cap->siz - 1); /* keep original text */ + else { + cs->cap++; /* skip open entry */ + while (!isclosecap(cs->cap)) { /* traverse nested captures */ + const char *next = cs->cap->s; + luaL_addlstring(b, curr, next - curr); /* add text up to capture */ + if (addonestring(b, cs, "replacement")) + curr = closeaddr(cs->cap - 1); /* continue after match */ + else /* no capture value */ + curr = next; /* keep original text in final result */ + } + luaL_addlstring(b, curr, cs->cap->s - curr); /* add last piece of text */ + } + cs->cap++; /* go to next capture */ +} + + +/* +** Evaluates a capture and adds its first value to buffer 'b'; returns +** whether there was a value +*/ +static int addonestring (luaL_Buffer *b, CapState *cs, const char *what) { + switch (captype(cs->cap)) { + case Cstring: + stringcap(b, cs); /* add capture directly to buffer */ + return 1; + case Csubst: + substcap(b, cs); /* add capture directly to buffer */ + return 1; + default: { + lua_State *L = cs->L; + int n = pushcapture(cs); + if (n > 0) { + if (n > 1) lua_pop(L, n - 1); /* only one result */ + if (!lua_isstring(L, -1)) + luaL_error(L, "invalid %s value (a %s)", what, luaL_typename(L, -1)); + luaL_addvalue(b); + } + return n; + } + } +} + + +/* +** Push all values of the current capture into the stack; returns +** number of values pushed +*/ +static int pushcapture (CapState *cs) { + lua_State *L = cs->L; + luaL_checkstack(L, 4, "too many captures"); + switch (captype(cs->cap)) { + case Cposition: { + lua_pushinteger(L, cs->cap->s - cs->s + 1); + cs->cap++; + return 1; + } + case Cconst: { + pushluaval(cs); + cs->cap++; + return 1; + } + case Carg: { + int arg = (cs->cap++)->idx; + if (arg + FIXEDARGS > cs->ptop) + return luaL_error(L, "reference to absent extra argument #%d", arg); + lua_pushvalue(L, arg + FIXEDARGS); + return 1; + } + case Csimple: { + int k = pushnestedvalues(cs, 1); + lua_insert(L, -k); /* make whole match be first result */ + return k; + } + case Cruntime: { + lua_pushvalue(L, (cs->cap++)->idx); /* value is in the stack */ + return 1; + } + case Cstring: { + luaL_Buffer b; + luaL_buffinit(L, &b); + stringcap(&b, cs); + luaL_pushresult(&b); + return 1; + } + case Csubst: { + luaL_Buffer b; + luaL_buffinit(L, &b); + substcap(&b, cs); + luaL_pushresult(&b); + return 1; + } + case Cgroup: { + if (cs->cap->idx == 0) /* anonymous group? */ + return pushnestedvalues(cs, 0); /* add all nested values */ + else { /* named group: add no values */ + nextcap(cs); /* skip capture */ + return 0; + } + } + case Cbackref: return backrefcap(cs); + case Ctable: return tablecap(cs); + case Cfunction: return functioncap(cs); + case Cnum: return numcap(cs); + case Cquery: return querycap(cs); + case Cfold: return foldcap(cs); + default: assert(0); return 0; + } +} + + +/* +** Prepare a CapState structure and traverse the entire list of +** captures in the stack pushing its results. 's' is the subject +** string, 'r' is the final position of the match, and 'ptop' +** the index in the stack where some useful values were pushed. +** Returns the number of results pushed. (If the list produces no +** results, push the final position of the match.) +*/ +int getcaptures (lua_State *L, const char *s, const char *r, int ptop) { + Capture *capture = (Capture *)lua_touserdata(L, caplistidx(ptop)); + int n = 0; + if (!isclosecap(capture)) { /* is there any capture? */ + CapState cs; + cs.ocap = cs.cap = capture; cs.L = L; + cs.s = s; cs.valuecached = 0; cs.ptop = ptop; + do { /* collect their values */ + n += pushcapture(&cs); + } while (!isclosecap(cs.cap)); + } + if (n == 0) { /* no capture values? */ + lua_pushinteger(L, r - s + 1); /* return only end position */ + n = 1; + } + return n; +} + + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lpcap.h b/dep/scintilla/scintilla-3.10.6/lua/src/lpcap.h new file mode 100644 index 00000000..d762fdcf --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lpcap.h @@ -0,0 +1,43 @@ +/* +** $Id: lpcap.h,v 1.2 2015/02/27 17:13:17 roberto Exp $ +*/ + +#if !defined(lpcap_h) +#define lpcap_h + + +#include "lptypes.h" + + +/* kinds of captures */ +typedef enum CapKind { + Cclose, Cposition, Cconst, Cbackref, Carg, Csimple, Ctable, Cfunction, + Cquery, Cstring, Cnum, Csubst, Cfold, Cruntime, Cgroup +} CapKind; + + +typedef struct Capture { + const char *s; /* subject position */ + unsigned short idx; /* extra info (group name, arg index, etc.) */ + byte kind; /* kind of capture */ + byte siz; /* size of full capture + 1 (0 = not a full capture) */ +} Capture; + + +typedef struct CapState { + Capture *cap; /* current capture */ + Capture *ocap; /* (original) capture list */ + lua_State *L; + int ptop; /* index of last argument to 'match' */ + const char *s; /* original string */ + int valuecached; /* value stored in cache slot */ +} CapState; + + +int runtimecap (CapState *cs, Capture *close, const char *s, int *rem); +int getcaptures (lua_State *L, const char *s, const char *r, int ptop); +int finddyncap (Capture *cap, Capture *last); + +#endif + + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lpcode.c b/dep/scintilla/scintilla-3.10.6/lua/src/lpcode.c new file mode 100644 index 00000000..fbf44feb --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lpcode.c @@ -0,0 +1,986 @@ +/* +** $Id: lpcode.c,v 1.23 2015/06/12 18:36:47 roberto Exp $ +** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license) +*/ + +#include + + +#include "lua.h" +#include "lauxlib.h" + +#include "lptypes.h" +#include "lpcode.h" + + +/* signals a "no-instruction */ +#define NOINST -1 + + + +static const Charset fullset_ = + {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}}; + +static const Charset *fullset = &fullset_; + +/* +** {====================================================== +** Analysis and some optimizations +** ======================================================= +*/ + +/* +** Check whether a charset is empty (returns IFail), singleton (IChar), +** full (IAny), or none of those (ISet). When singleton, '*c' returns +** which character it is. (When generic set, the set was the input, +** so there is no need to return it.) +*/ +static Opcode charsettype (const byte *cs, int *c) { + int count = 0; /* number of characters in the set */ + int i; + int candidate = -1; /* candidate position for the singleton char */ + for (i = 0; i < CHARSETSIZE; i++) { /* for each byte */ + int b = cs[i]; + if (b == 0) { /* is byte empty? */ + if (count > 1) /* was set neither empty nor singleton? */ + return ISet; /* neither full nor empty nor singleton */ + /* else set is still empty or singleton */ + } + else if (b == 0xFF) { /* is byte full? */ + if (count < (i * BITSPERCHAR)) /* was set not full? */ + return ISet; /* neither full nor empty nor singleton */ + else count += BITSPERCHAR; /* set is still full */ + } + else if ((b & (b - 1)) == 0) { /* has byte only one bit? */ + if (count > 0) /* was set not empty? */ + return ISet; /* neither full nor empty nor singleton */ + else { /* set has only one char till now; track it */ + count++; + candidate = i; + } + } + else return ISet; /* byte is neither empty, full, nor singleton */ + } + switch (count) { + case 0: return IFail; /* empty set */ + case 1: { /* singleton; find character bit inside byte */ + int b = cs[candidate]; + *c = candidate * BITSPERCHAR; + if ((b & 0xF0) != 0) { *c += 4; b >>= 4; } + if ((b & 0x0C) != 0) { *c += 2; b >>= 2; } + if ((b & 0x02) != 0) { *c += 1; } + return IChar; + } + default: { + assert(count == CHARSETSIZE * BITSPERCHAR); /* full set */ + return IAny; + } + } +} + + +/* +** A few basic operations on Charsets +*/ +static void cs_complement (Charset *cs) { + loopset(i, cs->cs[i] = ~cs->cs[i]); +} + +static int cs_equal (const byte *cs1, const byte *cs2) { + loopset(i, if (cs1[i] != cs2[i]) return 0); + return 1; +} + +static int cs_disjoint (const Charset *cs1, const Charset *cs2) { + loopset(i, if ((cs1->cs[i] & cs2->cs[i]) != 0) return 0;) + return 1; +} + + +/* +** If 'tree' is a 'char' pattern (TSet, TChar, TAny), convert it into a +** charset and return 1; else return 0. +*/ +int tocharset (TTree *tree, Charset *cs) { + switch (tree->tag) { + case TSet: { /* copy set */ + loopset(i, cs->cs[i] = treebuffer(tree)[i]); + return 1; + } + case TChar: { /* only one char */ + assert(0 <= tree->u.n && tree->u.n <= UCHAR_MAX); + loopset(i, cs->cs[i] = 0); /* erase all chars */ + setchar(cs->cs, tree->u.n); /* add that one */ + return 1; + } + case TAny: { + loopset(i, cs->cs[i] = 0xFF); /* add all characters to the set */ + return 1; + } + default: return 0; + } +} + + +/* +** Check whether a pattern tree has captures +*/ +int hascaptures (TTree *tree) { + tailcall: + switch (tree->tag) { + case TCapture: case TRunTime: + return 1; + case TCall: + tree = sib2(tree); goto tailcall; /* return hascaptures(sib2(tree)); */ + case TOpenCall: assert(0); + default: { + switch (numsiblings[tree->tag]) { + case 1: /* return hascaptures(sib1(tree)); */ + tree = sib1(tree); goto tailcall; + case 2: + if (hascaptures(sib1(tree))) return 1; + /* else return hascaptures(sib2(tree)); */ + tree = sib2(tree); goto tailcall; + default: assert(numsiblings[tree->tag] == 0); return 0; + } + } + } +} + + +/* +** Checks how a pattern behaves regarding the empty string, +** in one of two different ways: +** A pattern is *nullable* if it can match without consuming any character; +** A pattern is *nofail* if it never fails for any string +** (including the empty string). +** The difference is only for predicates and run-time captures; +** for other patterns, the two properties are equivalent. +** (With predicates, &'a' is nullable but not nofail. Of course, +** nofail => nullable.) +** These functions are all convervative in the following way: +** p is nullable => nullable(p) +** nofail(p) => p cannot fail +** The function assumes that TOpenCall is not nullable; +** this will be checked again when the grammar is fixed. +** Run-time captures can do whatever they want, so the result +** is conservative. +*/ +int checkaux (TTree *tree, int pred) { + tailcall: + switch (tree->tag) { + case TChar: case TSet: case TAny: + case TFalse: case TOpenCall: + return 0; /* not nullable */ + case TRep: case TTrue: + return 1; /* no fail */ + case TNot: case TBehind: /* can match empty, but can fail */ + if (pred == PEnofail) return 0; + else return 1; /* PEnullable */ + case TAnd: /* can match empty; fail iff body does */ + if (pred == PEnullable) return 1; + /* else return checkaux(sib1(tree), pred); */ + tree = sib1(tree); goto tailcall; + case TRunTime: /* can fail; match empty iff body does */ + if (pred == PEnofail) return 0; + /* else return checkaux(sib1(tree), pred); */ + tree = sib1(tree); goto tailcall; + case TSeq: + if (!checkaux(sib1(tree), pred)) return 0; + /* else return checkaux(sib2(tree), pred); */ + tree = sib2(tree); goto tailcall; + case TChoice: + if (checkaux(sib2(tree), pred)) return 1; + /* else return checkaux(sib1(tree), pred); */ + tree = sib1(tree); goto tailcall; + case TCapture: case TGrammar: case TRule: + /* return checkaux(sib1(tree), pred); */ + tree = sib1(tree); goto tailcall; + case TCall: /* return checkaux(sib2(tree), pred); */ + tree = sib2(tree); goto tailcall; + default: assert(0); return 0; + } +} + + +/* +** number of characters to match a pattern (or -1 if variable) +** ('count' avoids infinite loops for grammars) +*/ +int fixedlenx (TTree *tree, int count, int len) { + tailcall: + switch (tree->tag) { + case TChar: case TSet: case TAny: + return len + 1; + case TFalse: case TTrue: case TNot: case TAnd: case TBehind: + return len; + case TRep: case TRunTime: case TOpenCall: + return -1; + case TCapture: case TRule: case TGrammar: + /* return fixedlenx(sib1(tree), count); */ + tree = sib1(tree); goto tailcall; + case TCall: + if (count++ >= MAXRULES) + return -1; /* may be a loop */ + /* else return fixedlenx(sib2(tree), count); */ + tree = sib2(tree); goto tailcall; + case TSeq: { + len = fixedlenx(sib1(tree), count, len); + if (len < 0) return -1; + /* else return fixedlenx(sib2(tree), count, len); */ + tree = sib2(tree); goto tailcall; + } + case TChoice: { + int n1, n2; + n1 = fixedlenx(sib1(tree), count, len); + if (n1 < 0) return -1; + n2 = fixedlenx(sib2(tree), count, len); + if (n1 == n2) return n1; + else return -1; + } + default: assert(0); return 0; + }; +} + + +/* +** Computes the 'first set' of a pattern. +** The result is a conservative aproximation: +** match p ax -> x (for some x) ==> a belongs to first(p) +** or +** a not in first(p) ==> match p ax -> fail (for all x) +** +** The set 'follow' is the first set of what follows the +** pattern (full set if nothing follows it). +** +** The function returns 0 when this resulting set can be used for +** test instructions that avoid the pattern altogether. +** A non-zero return can happen for two reasons: +** 1) match p '' -> '' ==> return has bit 1 set +** (tests cannot be used because they would always fail for an empty input); +** 2) there is a match-time capture ==> return has bit 2 set +** (optimizations should not bypass match-time captures). +*/ +static int getfirst (TTree *tree, const Charset *follow, Charset *firstset) { + tailcall: + switch (tree->tag) { + case TChar: case TSet: case TAny: { + tocharset(tree, firstset); + return 0; + } + case TTrue: { + loopset(i, firstset->cs[i] = follow->cs[i]); + return 1; /* accepts the empty string */ + } + case TFalse: { + loopset(i, firstset->cs[i] = 0); + return 0; + } + case TChoice: { + Charset csaux; + int e1 = getfirst(sib1(tree), follow, firstset); + int e2 = getfirst(sib2(tree), follow, &csaux); + loopset(i, firstset->cs[i] |= csaux.cs[i]); + return e1 | e2; + } + case TSeq: { + if (!nullable(sib1(tree))) { + /* when p1 is not nullable, p2 has nothing to contribute; + return getfirst(sib1(tree), fullset, firstset); */ + tree = sib1(tree); follow = fullset; goto tailcall; + } + else { /* FIRST(p1 p2, fl) = FIRST(p1, FIRST(p2, fl)) */ + Charset csaux; + int e2 = getfirst(sib2(tree), follow, &csaux); + int e1 = getfirst(sib1(tree), &csaux, firstset); + if (e1 == 0) return 0; /* 'e1' ensures that first can be used */ + else if ((e1 | e2) & 2) /* one of the children has a matchtime? */ + return 2; /* pattern has a matchtime capture */ + else return e2; /* else depends on 'e2' */ + } + } + case TRep: { + getfirst(sib1(tree), follow, firstset); + loopset(i, firstset->cs[i] |= follow->cs[i]); + return 1; /* accept the empty string */ + } + case TCapture: case TGrammar: case TRule: { + /* return getfirst(sib1(tree), follow, firstset); */ + tree = sib1(tree); goto tailcall; + } + case TRunTime: { /* function invalidates any follow info. */ + int e = getfirst(sib1(tree), fullset, firstset); + if (e) return 2; /* function is not "protected"? */ + else return 0; /* pattern inside capture ensures first can be used */ + } + case TCall: { + /* return getfirst(sib2(tree), follow, firstset); */ + tree = sib2(tree); goto tailcall; + } + case TAnd: { + int e = getfirst(sib1(tree), follow, firstset); + loopset(i, firstset->cs[i] &= follow->cs[i]); + return e; + } + case TNot: { + if (tocharset(sib1(tree), firstset)) { + cs_complement(firstset); + return 1; + } + /* else go through */ + } + case TBehind: { /* instruction gives no new information */ + /* call 'getfirst' only to check for math-time captures */ + int e = getfirst(sib1(tree), follow, firstset); + loopset(i, firstset->cs[i] = follow->cs[i]); /* uses follow */ + return e | 1; /* always can accept the empty string */ + } + default: assert(0); return 0; + } +} + + +/* +** If 'headfail(tree)' true, then 'tree' can fail only depending on the +** next character of the subject. +*/ +static int headfail (TTree *tree) { + tailcall: + switch (tree->tag) { + case TChar: case TSet: case TAny: case TFalse: + return 1; + case TTrue: case TRep: case TRunTime: case TNot: + case TBehind: + return 0; + case TCapture: case TGrammar: case TRule: case TAnd: + tree = sib1(tree); goto tailcall; /* return headfail(sib1(tree)); */ + case TCall: + tree = sib2(tree); goto tailcall; /* return headfail(sib2(tree)); */ + case TSeq: + if (!nofail(sib2(tree))) return 0; + /* else return headfail(sib1(tree)); */ + tree = sib1(tree); goto tailcall; + case TChoice: + if (!headfail(sib1(tree))) return 0; + /* else return headfail(sib2(tree)); */ + tree = sib2(tree); goto tailcall; + default: assert(0); return 0; + } +} + + +/* +** Check whether the code generation for the given tree can benefit +** from a follow set (to avoid computing the follow set when it is +** not needed) +*/ +static int needfollow (TTree *tree) { + tailcall: + switch (tree->tag) { + case TChar: case TSet: case TAny: + case TFalse: case TTrue: case TAnd: case TNot: + case TRunTime: case TGrammar: case TCall: case TBehind: + return 0; + case TChoice: case TRep: + return 1; + case TCapture: + tree = sib1(tree); goto tailcall; + case TSeq: + tree = sib2(tree); goto tailcall; + default: assert(0); return 0; + } +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** Code generation +** ======================================================= +*/ + + +/* +** size of an instruction +*/ +int sizei (const Instruction *i) { + switch((Opcode)i->i.code) { + case ISet: case ISpan: return CHARSETINSTSIZE; + case ITestSet: return CHARSETINSTSIZE + 1; + case ITestChar: case ITestAny: case IChoice: case IJmp: case ICall: + case IOpenCall: case ICommit: case IPartialCommit: case IBackCommit: + return 2; + default: return 1; + } +} + + +/* +** state for the compiler +*/ +typedef struct CompileState { + Pattern *p; /* pattern being compiled */ + int ncode; /* next position in p->code to be filled */ + lua_State *L; +} CompileState; + + +/* +** code generation is recursive; 'opt' indicates that the code is being +** generated as the last thing inside an optional pattern (so, if that +** code is optional too, it can reuse the 'IChoice' already in place for +** the outer pattern). 'tt' points to a previous test protecting this +** code (or NOINST). 'fl' is the follow set of the pattern. +*/ +static void codegen (CompileState *compst, TTree *tree, int opt, int tt, + const Charset *fl); + + +void realloccode (lua_State *L, Pattern *p, int nsize) { + void *ud; + lua_Alloc f = lua_getallocf(L, &ud); + void *newblock = f(ud, p->code, p->codesize * sizeof(Instruction), + nsize * sizeof(Instruction)); + if (newblock == NULL && nsize > 0) + luaL_error(L, "not enough memory"); + p->code = (Instruction *)newblock; + p->codesize = nsize; +} + + +static int nextinstruction (CompileState *compst) { + int size = compst->p->codesize; + if (compst->ncode >= size) + realloccode(compst->L, compst->p, size * 2); + return compst->ncode++; +} + + +#define getinstr(cs,i) ((cs)->p->code[i]) + + +static int addinstruction (CompileState *compst, Opcode op, int aux) { + int i = nextinstruction(compst); + getinstr(compst, i).i.code = op; + getinstr(compst, i).i.aux = aux; + return i; +} + + +/* +** Add an instruction followed by space for an offset (to be set later) +*/ +static int addoffsetinst (CompileState *compst, Opcode op) { + int i = addinstruction(compst, op, 0); /* instruction */ + addinstruction(compst, (Opcode)0, 0); /* open space for offset */ + assert(op == ITestSet || sizei(&getinstr(compst, i)) == 2); + return i; +} + + +/* +** Set the offset of an instruction +*/ +static void setoffset (CompileState *compst, int instruction, int offset) { + getinstr(compst, instruction + 1).offset = offset; +} + + +/* +** Add a capture instruction: +** 'op' is the capture instruction; 'cap' the capture kind; +** 'key' the key into ktable; 'aux' is the optional capture offset +** +*/ +static int addinstcap (CompileState *compst, Opcode op, int cap, int key, + int aux) { + int i = addinstruction(compst, op, joinkindoff(cap, aux)); + getinstr(compst, i).i.key = key; + return i; +} + + +#define gethere(compst) ((compst)->ncode) + +#define target(code,i) ((i) + code[i + 1].offset) + + +/* +** Patch 'instruction' to jump to 'target' +*/ +static void jumptothere (CompileState *compst, int instruction, int target) { + if (instruction >= 0) + setoffset(compst, instruction, target - instruction); +} + + +/* +** Patch 'instruction' to jump to current position +*/ +static void jumptohere (CompileState *compst, int instruction) { + jumptothere(compst, instruction, gethere(compst)); +} + + +/* +** Code an IChar instruction, or IAny if there is an equivalent +** test dominating it +*/ +static void codechar (CompileState *compst, int c, int tt) { + if (tt >= 0 && getinstr(compst, tt).i.code == ITestChar && + getinstr(compst, tt).i.aux == c) + addinstruction(compst, IAny, 0); + else + addinstruction(compst, IChar, c); +} + + +/* +** Add a charset posfix to an instruction +*/ +static void addcharset (CompileState *compst, const byte *cs) { + int p = gethere(compst); + int i; + for (i = 0; i < (int)CHARSETINSTSIZE - 1; i++) + nextinstruction(compst); /* space for buffer */ + /* fill buffer with charset */ + loopset(j, getinstr(compst, p).buff[j] = cs[j]); +} + + +/* +** code a char set, optimizing unit sets for IChar, "complete" +** sets for IAny, and empty sets for IFail; also use an IAny +** when instruction is dominated by an equivalent test. +*/ +static void codecharset (CompileState *compst, const byte *cs, int tt) { + int c = 0; /* (=) to avoid warnings */ + Opcode op = charsettype(cs, &c); + switch (op) { + case IChar: codechar(compst, c, tt); break; + case ISet: { /* non-trivial set? */ + if (tt >= 0 && getinstr(compst, tt).i.code == ITestSet && + cs_equal(cs, getinstr(compst, tt + 2).buff)) + addinstruction(compst, IAny, 0); + else { + addinstruction(compst, ISet, 0); + addcharset(compst, cs); + } + break; + } + default: addinstruction(compst, op, c); break; + } +} + + +/* +** code a test set, optimizing unit sets for ITestChar, "complete" +** sets for ITestAny, and empty sets for IJmp (always fails). +** 'e' is true iff test should accept the empty string. (Test +** instructions in the current VM never accept the empty string.) +*/ +static int codetestset (CompileState *compst, Charset *cs, int e) { + if (e) return NOINST; /* no test */ + else { + int c = 0; + Opcode op = charsettype(cs->cs, &c); + switch (op) { + case IFail: return addoffsetinst(compst, IJmp); /* always jump */ + case IAny: return addoffsetinst(compst, ITestAny); + case IChar: { + int i = addoffsetinst(compst, ITestChar); + getinstr(compst, i).i.aux = c; + return i; + } + case ISet: { + int i = addoffsetinst(compst, ITestSet); + addcharset(compst, cs->cs); + return i; + } + default: assert(0); return 0; + } + } +} + + +/* +** Find the final destination of a sequence of jumps +*/ +static int finaltarget (Instruction *code, int i) { + while (code[i].i.code == IJmp) + i = target(code, i); + return i; +} + + +/* +** final label (after traversing any jumps) +*/ +static int finallabel (Instruction *code, int i) { + return finaltarget(code, target(code, i)); +} + + +/* +** == behind n;

    (where n = fixedlen(p)) +*/ +static void codebehind (CompileState *compst, TTree *tree) { + if (tree->u.n > 0) + addinstruction(compst, IBehind, tree->u.n); + codegen(compst, sib1(tree), 0, NOINST, fullset); +} + + +/* +** Choice; optimizations: +** - when p1 is headfail or +** when first(p1) and first(p2) are disjoint, than +** a character not in first(p1) cannot go to p1, and a character +** in first(p1) cannot go to p2 (at it is not in first(p2)). +** (The optimization is not valid if p1 accepts the empty string, +** as then there is no character at all...) +** - when p2 is empty and opt is true; a IPartialCommit can reuse +** the Choice already active in the stack. +*/ +static void codechoice (CompileState *compst, TTree *p1, TTree *p2, int opt, + const Charset *fl) { + int emptyp2 = (p2->tag == TTrue); + Charset cs1, cs2; + int e1 = getfirst(p1, fullset, &cs1); + if (headfail(p1) || + (!e1 && (getfirst(p2, fl, &cs2), cs_disjoint(&cs1, &cs2)))) { + /* == test (fail(p1)) -> L1 ; p1 ; jmp L2; L1: p2; L2: */ + int test = codetestset(compst, &cs1, 0); + int jmp = NOINST; + codegen(compst, p1, 0, test, fl); + if (!emptyp2) + jmp = addoffsetinst(compst, IJmp); + jumptohere(compst, test); + codegen(compst, p2, opt, NOINST, fl); + jumptohere(compst, jmp); + } + else if (opt && emptyp2) { + /* p1? == IPartialCommit; p1 */ + jumptohere(compst, addoffsetinst(compst, IPartialCommit)); + codegen(compst, p1, 1, NOINST, fullset); + } + else { + /* == + test(first(p1)) -> L1; choice L1; ; commit L2; L1: ; L2: */ + int pcommit; + int test = codetestset(compst, &cs1, e1); + int pchoice = addoffsetinst(compst, IChoice); + codegen(compst, p1, emptyp2, test, fullset); + pcommit = addoffsetinst(compst, ICommit); + jumptohere(compst, pchoice); + jumptohere(compst, test); + codegen(compst, p2, opt, NOINST, fl); + jumptohere(compst, pcommit); + } +} + + +/* +** And predicate +** optimization: fixedlen(p) = n ==> <&p> ==

    ; behind n +** (valid only when 'p' has no captures) +*/ +static void codeand (CompileState *compst, TTree *tree, int tt) { + int n = fixedlen(tree); + if (n >= 0 && n <= MAXBEHIND && !hascaptures(tree)) { + codegen(compst, tree, 0, tt, fullset); + if (n > 0) + addinstruction(compst, IBehind, n); + } + else { /* default: Choice L1; p1; BackCommit L2; L1: Fail; L2: */ + int pcommit; + int pchoice = addoffsetinst(compst, IChoice); + codegen(compst, tree, 0, tt, fullset); + pcommit = addoffsetinst(compst, IBackCommit); + jumptohere(compst, pchoice); + addinstruction(compst, IFail, 0); + jumptohere(compst, pcommit); + } +} + + +/* +** Captures: if pattern has fixed (and not too big) length, use +** a single IFullCapture instruction after the match; otherwise, +** enclose the pattern with OpenCapture - CloseCapture. +*/ +static void codecapture (CompileState *compst, TTree *tree, int tt, + const Charset *fl) { + int len = fixedlen(sib1(tree)); + if (len >= 0 && len <= MAXOFF && !hascaptures(sib1(tree))) { + codegen(compst, sib1(tree), 0, tt, fl); + addinstcap(compst, IFullCapture, tree->cap, tree->key, len); + } + else { + addinstcap(compst, IOpenCapture, tree->cap, tree->key, 0); + codegen(compst, sib1(tree), 0, tt, fl); + addinstcap(compst, ICloseCapture, Cclose, 0, 0); + } +} + + +static void coderuntime (CompileState *compst, TTree *tree, int tt) { + addinstcap(compst, IOpenCapture, Cgroup, tree->key, 0); + codegen(compst, sib1(tree), 0, tt, fullset); + addinstcap(compst, ICloseRunTime, Cclose, 0, 0); +} + + +/* +** Repetion; optimizations: +** When pattern is a charset, can use special instruction ISpan. +** When pattern is head fail, or if it starts with characters that +** are disjoint from what follows the repetions, a simple test +** is enough (a fail inside the repetition would backtrack to fail +** again in the following pattern, so there is no need for a choice). +** When 'opt' is true, the repetion can reuse the Choice already +** active in the stack. +*/ +static void coderep (CompileState *compst, TTree *tree, int opt, + const Charset *fl) { + Charset st; + if (tocharset(tree, &st)) { + addinstruction(compst, ISpan, 0); + addcharset(compst, st.cs); + } + else { + int e1 = getfirst(tree, fullset, &st); + if (headfail(tree) || (!e1 && cs_disjoint(&st, fl))) { + /* L1: test (fail(p1)) -> L2;

    ; jmp L1; L2: */ + int jmp; + int test = codetestset(compst, &st, 0); + codegen(compst, tree, 0, test, fullset); + jmp = addoffsetinst(compst, IJmp); + jumptohere(compst, test); + jumptothere(compst, jmp, test); + } + else { + /* test(fail(p1)) -> L2; choice L2; L1:

    ; partialcommit L1; L2: */ + /* or (if 'opt'): partialcommit L1; L1:

    ; partialcommit L1; */ + int commit, l2; + int test = codetestset(compst, &st, e1); + int pchoice = NOINST; + if (opt) + jumptohere(compst, addoffsetinst(compst, IPartialCommit)); + else + pchoice = addoffsetinst(compst, IChoice); + l2 = gethere(compst); + codegen(compst, tree, 0, NOINST, fullset); + commit = addoffsetinst(compst, IPartialCommit); + jumptothere(compst, commit, l2); + jumptohere(compst, pchoice); + jumptohere(compst, test); + } + } +} + + +/* +** Not predicate; optimizations: +** In any case, if first test fails, 'not' succeeds, so it can jump to +** the end. If pattern is headfail, that is all (it cannot fail +** in other parts); this case includes 'not' of simple sets. Otherwise, +** use the default code (a choice plus a failtwice). +*/ +static void codenot (CompileState *compst, TTree *tree) { + Charset st; + int e = getfirst(tree, fullset, &st); + int test = codetestset(compst, &st, e); + if (headfail(tree)) /* test (fail(p1)) -> L1; fail; L1: */ + addinstruction(compst, IFail, 0); + else { + /* test(fail(p))-> L1; choice L1;

    ; failtwice; L1: */ + int pchoice = addoffsetinst(compst, IChoice); + codegen(compst, tree, 0, NOINST, fullset); + addinstruction(compst, IFailTwice, 0); + jumptohere(compst, pchoice); + } + jumptohere(compst, test); +} + + +/* +** change open calls to calls, using list 'positions' to find +** correct offsets; also optimize tail calls +*/ +static void correctcalls (CompileState *compst, int *positions, + int from, int to) { + int i; + Instruction *code = compst->p->code; + for (i = from; i < to; i += sizei(&code[i])) { + if (code[i].i.code == IOpenCall) { + int n = code[i].i.key; /* rule number */ + int rule = positions[n]; /* rule position */ + assert(rule == from || code[rule - 1].i.code == IRet); + if (code[finaltarget(code, i + 2)].i.code == IRet) /* call; ret ? */ + code[i].i.code = IJmp; /* tail call */ + else + code[i].i.code = ICall; + jumptothere(compst, i, rule); /* call jumps to respective rule */ + } + } + assert(i == to); +} + + +/* +** Code for a grammar: +** call L1; jmp L2; L1: rule 1; ret; rule 2; ret; ...; L2: +*/ +static void codegrammar (CompileState *compst, TTree *grammar) { + int positions[MAXRULES]; + int rulenumber = 0; + TTree *rule; + int firstcall = addoffsetinst(compst, ICall); /* call initial rule */ + int jumptoend = addoffsetinst(compst, IJmp); /* jump to the end */ + int start = gethere(compst); /* here starts the initial rule */ + jumptohere(compst, firstcall); + for (rule = sib1(grammar); rule->tag == TRule; rule = sib2(rule)) { + positions[rulenumber++] = gethere(compst); /* save rule position */ + codegen(compst, sib1(rule), 0, NOINST, fullset); /* code rule */ + addinstruction(compst, IRet, 0); + } + assert(rule->tag == TTrue); + jumptohere(compst, jumptoend); + correctcalls(compst, positions, start, gethere(compst)); +} + + +static void codecall (CompileState *compst, TTree *call) { + int c = addoffsetinst(compst, IOpenCall); /* to be corrected later */ + getinstr(compst, c).i.key = sib2(call)->cap; /* rule number */ + assert(sib2(call)->tag == TRule); +} + + +/* +** Code first child of a sequence +** (second child is called in-place to allow tail call) +** Return 'tt' for second child +*/ +static int codeseq1 (CompileState *compst, TTree *p1, TTree *p2, + int tt, const Charset *fl) { + if (needfollow(p1)) { + Charset fl1; + getfirst(p2, fl, &fl1); /* p1 follow is p2 first */ + codegen(compst, p1, 0, tt, &fl1); + } + else /* use 'fullset' as follow */ + codegen(compst, p1, 0, tt, fullset); + if (fixedlen(p1) != 0) /* can 'p1' consume anything? */ + return NOINST; /* invalidate test */ + else return tt; /* else 'tt' still protects sib2 */ +} + + +/* +** Main code-generation function: dispatch to auxiliar functions +** according to kind of tree. ('needfollow' should return true +** only for consructions that use 'fl'.) +*/ +static void codegen (CompileState *compst, TTree *tree, int opt, int tt, + const Charset *fl) { + tailcall: + switch (tree->tag) { + case TChar: codechar(compst, tree->u.n, tt); break; + case TAny: addinstruction(compst, IAny, 0); break; + case TSet: codecharset(compst, treebuffer(tree), tt); break; + case TTrue: break; + case TFalse: addinstruction(compst, IFail, 0); break; + case TChoice: codechoice(compst, sib1(tree), sib2(tree), opt, fl); break; + case TRep: coderep(compst, sib1(tree), opt, fl); break; + case TBehind: codebehind(compst, tree); break; + case TNot: codenot(compst, sib1(tree)); break; + case TAnd: codeand(compst, sib1(tree), tt); break; + case TCapture: codecapture(compst, tree, tt, fl); break; + case TRunTime: coderuntime(compst, tree, tt); break; + case TGrammar: codegrammar(compst, tree); break; + case TCall: codecall(compst, tree); break; + case TSeq: { + tt = codeseq1(compst, sib1(tree), sib2(tree), tt, fl); /* code 'p1' */ + /* codegen(compst, p2, opt, tt, fl); */ + tree = sib2(tree); goto tailcall; + } + default: assert(0); + } +} + + +/* +** Optimize jumps and other jump-like instructions. +** * Update labels of instructions with labels to their final +** destinations (e.g., choice L1; ... L1: jmp L2: becomes +** choice L2) +** * Jumps to other instructions that do jumps become those +** instructions (e.g., jump to return becomes a return; jump +** to commit becomes a commit) +*/ +static void peephole (CompileState *compst) { + Instruction *code = compst->p->code; + int i; + for (i = 0; i < compst->ncode; i += sizei(&code[i])) { + redo: + switch (code[i].i.code) { + case IChoice: case ICall: case ICommit: case IPartialCommit: + case IBackCommit: case ITestChar: case ITestSet: + case ITestAny: { /* instructions with labels */ + jumptothere(compst, i, finallabel(code, i)); /* optimize label */ + break; + } + case IJmp: { + int ft = finaltarget(code, i); + switch (code[ft].i.code) { /* jumping to what? */ + case IRet: case IFail: case IFailTwice: + case IEnd: { /* instructions with unconditional implicit jumps */ + code[i] = code[ft]; /* jump becomes that instruction */ + code[i + 1].i.code = IAny; /* 'no-op' for target position */ + break; + } + case ICommit: case IPartialCommit: + case IBackCommit: { /* inst. with unconditional explicit jumps */ + int fft = finallabel(code, ft); + code[i] = code[ft]; /* jump becomes that instruction... */ + jumptothere(compst, i, fft); /* but must correct its offset */ + goto redo; /* reoptimize its label */ + } + default: { + jumptothere(compst, i, ft); /* optimize label */ + break; + } + } + break; + } + default: break; + } + } + assert(code[i - 1].i.code == IEnd); +} + + +/* +** Compile a pattern +*/ +Instruction *compile (lua_State *L, Pattern *p) { + CompileState compst; + compst.p = p; compst.ncode = 0; compst.L = L; + realloccode(L, p, 2); /* minimum initial size */ + codegen(&compst, p->tree, 0, NOINST, fullset); + addinstruction(&compst, IEnd, 0); + realloccode(L, p, compst.ncode); /* set final size */ + peephole(&compst); + return p->code; +} + + +/* }====================================================== */ + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lpcode.h b/dep/scintilla/scintilla-3.10.6/lua/src/lpcode.h new file mode 100644 index 00000000..896d3c79 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lpcode.h @@ -0,0 +1,42 @@ +/* +** $Id: lpcode.h,v 1.7 2015/06/12 18:24:45 roberto Exp $ +*/ + +#if !defined(lpcode_h) +#define lpcode_h + +#include "lua.h" + +#include "lptypes.h" +#include "lptree.h" +#include "lpvm.h" + +int tocharset (TTree *tree, Charset *cs); +int checkaux (TTree *tree, int pred); +int fixedlenx (TTree *tree, int count, int len); +int hascaptures (TTree *tree); +int lp_gc (lua_State *L); +Instruction *compile (lua_State *L, Pattern *p); +void realloccode (lua_State *L, Pattern *p, int nsize); +int sizei (const Instruction *i); + + +#define PEnullable 0 +#define PEnofail 1 + +/* +** nofail(t) implies that 't' cannot fail with any input +*/ +#define nofail(t) checkaux(t, PEnofail) + +/* +** (not nullable(t)) implies 't' cannot match without consuming +** something +*/ +#define nullable(t) checkaux(t, PEnullable) + +#define fixedlen(t) fixedlenx(t, 0, 0) + + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lpprint.c b/dep/scintilla/scintilla-3.10.6/lua/src/lpprint.c new file mode 100644 index 00000000..174d1687 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lpprint.c @@ -0,0 +1,244 @@ +/* +** $Id: lpprint.c,v 1.9 2015/06/15 16:09:57 roberto Exp $ +** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license) +*/ + +#include +#include +#include + + +#include "lptypes.h" +#include "lpprint.h" +#include "lpcode.h" + + +#if defined(LPEG_DEBUG) + +/* +** {====================================================== +** Printing patterns (for debugging) +** ======================================================= +*/ + + +void printcharset (const byte *st) { + int i; + printf("["); + for (i = 0; i <= UCHAR_MAX; i++) { + int first = i; + while (testchar(st, i) && i <= UCHAR_MAX) i++; + if (i - 1 == first) /* unary range? */ + printf("(%02x)", first); + else if (i - 1 > first) /* non-empty range? */ + printf("(%02x-%02x)", first, i - 1); + } + printf("]"); +} + + +static void printcapkind (int kind) { + const char *const modes[] = { + "close", "position", "constant", "backref", + "argument", "simple", "table", "function", + "query", "string", "num", "substitution", "fold", + "runtime", "group"}; + printf("%s", modes[kind]); +} + + +static void printjmp (const Instruction *op, const Instruction *p) { + printf("-> %d", (int)(p + (p + 1)->offset - op)); +} + + +void printinst (const Instruction *op, const Instruction *p) { + const char *const names[] = { + "any", "char", "set", + "testany", "testchar", "testset", + "span", "behind", + "ret", "end", + "choice", "jmp", "call", "open_call", + "commit", "partial_commit", "back_commit", "failtwice", "fail", "giveup", + "fullcapture", "opencapture", "closecapture", "closeruntime" + }; + printf("%02ld: %s ", (long)(p - op), names[p->i.code]); + switch ((Opcode)p->i.code) { + case IChar: { + printf("'%c'", p->i.aux); + break; + } + case ITestChar: { + printf("'%c'", p->i.aux); printjmp(op, p); + break; + } + case IFullCapture: { + printcapkind(getkind(p)); + printf(" (size = %d) (idx = %d)", getoff(p), p->i.key); + break; + } + case IOpenCapture: { + printcapkind(getkind(p)); + printf(" (idx = %d)", p->i.key); + break; + } + case ISet: { + printcharset((p+1)->buff); + break; + } + case ITestSet: { + printcharset((p+2)->buff); printjmp(op, p); + break; + } + case ISpan: { + printcharset((p+1)->buff); + break; + } + case IOpenCall: { + printf("-> %d", (p + 1)->offset); + break; + } + case IBehind: { + printf("%d", p->i.aux); + break; + } + case IJmp: case ICall: case ICommit: case IChoice: + case IPartialCommit: case IBackCommit: case ITestAny: { + printjmp(op, p); + break; + } + default: break; + } + printf("\n"); +} + + +void printpatt (Instruction *p, int n) { + Instruction *op = p; + while (p < op + n) { + printinst(op, p); + p += sizei(p); + } +} + + +#if defined(LPEG_DEBUG) +static void printcap (Capture *cap) { + printcapkind(cap->kind); + printf(" (idx: %d - size: %d) -> %p\n", cap->idx, cap->siz, cap->s); +} + + +void printcaplist (Capture *cap, Capture *limit) { + printf(">======\n"); + for (; cap->s && (limit == NULL || cap < limit); cap++) + printcap(cap); + printf("=======\n"); +} +#endif + +/* }====================================================== */ + + +/* +** {====================================================== +** Printing trees (for debugging) +** ======================================================= +*/ + +static const char *tagnames[] = { + "char", "set", "any", + "true", "false", + "rep", + "seq", "choice", + "not", "and", + "call", "opencall", "rule", "grammar", + "behind", + "capture", "run-time" +}; + + +void printtree (TTree *tree, int ident) { + int i; + for (i = 0; i < ident; i++) printf(" "); + printf("%s", tagnames[tree->tag]); + switch (tree->tag) { + case TChar: { + int c = tree->u.n; + if (isprint(c)) + printf(" '%c'\n", c); + else + printf(" (%02X)\n", c); + break; + } + case TSet: { + printcharset(treebuffer(tree)); + printf("\n"); + break; + } + case TOpenCall: case TCall: { + printf(" key: %d\n", tree->key); + break; + } + case TBehind: { + printf(" %d\n", tree->u.n); + printtree(sib1(tree), ident + 2); + break; + } + case TCapture: { + printf(" cap: %d key: %d n: %d\n", tree->cap, tree->key, tree->u.n); + printtree(sib1(tree), ident + 2); + break; + } + case TRule: { + printf(" n: %d key: %d\n", tree->cap, tree->key); + printtree(sib1(tree), ident + 2); + break; /* do not print next rule as a sibling */ + } + case TGrammar: { + TTree *rule = sib1(tree); + printf(" %d\n", tree->u.n); /* number of rules */ + for (i = 0; i < tree->u.n; i++) { + printtree(rule, ident + 2); + rule = sib2(rule); + } + assert(rule->tag == TTrue); /* sentinel */ + break; + } + default: { + int sibs = numsiblings[tree->tag]; + printf("\n"); + if (sibs >= 1) { + printtree(sib1(tree), ident + 2); + if (sibs >= 2) + printtree(sib2(tree), ident + 2); + } + break; + } + } +} + + +void printktable (lua_State *L, int idx) { + int n, i; + lua_getuservalue(L, idx); + if (lua_isnil(L, -1)) /* no ktable? */ + return; + n = lua_rawlen(L, -1); + printf("["); + for (i = 1; i <= n; i++) { + printf("%d = ", i); + lua_rawgeti(L, -1, i); + if (lua_isstring(L, -1)) + printf("%s ", lua_tostring(L, -1)); + else + printf("%s ", lua_typename(L, lua_type(L, -1))); + lua_pop(L, 1); + } + printf("]\n"); + /* leave ktable at the stack */ +} + +/* }====================================================== */ + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lpprint.h b/dep/scintilla/scintilla-3.10.6/lua/src/lpprint.h new file mode 100644 index 00000000..63297607 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lpprint.h @@ -0,0 +1,36 @@ +/* +** $Id: lpprint.h,v 1.2 2015/06/12 18:18:08 roberto Exp $ +*/ + + +#if !defined(lpprint_h) +#define lpprint_h + + +#include "lptree.h" +#include "lpvm.h" + + +#if defined(LPEG_DEBUG) + +void printpatt (Instruction *p, int n); +void printtree (TTree *tree, int ident); +void printktable (lua_State *L, int idx); +void printcharset (const byte *st); +void printcaplist (Capture *cap, Capture *limit); +void printinst (const Instruction *op, const Instruction *p); + +#else + +#define printktable(L,idx) \ + luaL_error(L, "function only implemented in debug mode") +#define printtree(tree,i) \ + luaL_error(L, "function only implemented in debug mode") +#define printpatt(p,n) \ + luaL_error(L, "function only implemented in debug mode") + +#endif + + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lprefix.h b/dep/scintilla/scintilla-3.10.6/lua/src/lprefix.h new file mode 100644 index 00000000..02daa837 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lprefix.h @@ -0,0 +1,45 @@ +/* +** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ +** Definitions for Lua code that must come before any other header file +** See Copyright Notice in lua.h +*/ + +#ifndef lprefix_h +#define lprefix_h + + +/* +** Allows POSIX/XSI stuff +*/ +#if !defined(LUA_USE_C89) /* { */ + +#if !defined(_XOPEN_SOURCE) +#define _XOPEN_SOURCE 600 +#elif _XOPEN_SOURCE == 0 +#undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ +#endif + +/* +** Allows manipulation of large files in gcc and some other compilers +*/ +#if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) +#define _LARGEFILE_SOURCE 1 +#define _FILE_OFFSET_BITS 64 +#endif + +#endif /* } */ + + +/* +** Windows stuff +*/ +#if defined(_WIN32) /* { */ + +#if !defined(_CRT_SECURE_NO_WARNINGS) +#define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ +#endif + +#endif /* } */ + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lptree.c b/dep/scintilla/scintilla-3.10.6/lua/src/lptree.c new file mode 100644 index 00000000..ac5f5150 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lptree.c @@ -0,0 +1,1296 @@ +/* +** $Id: lptree.c,v 1.21 2015/09/28 17:01:25 roberto Exp $ +** Copyright 2013, Lua.org & PUC-Rio (see 'lpeg.html' for license) +*/ + +#include +#include +#include + + +#include "lua.h" +#include "lauxlib.h" + +#include "lptypes.h" +#include "lpcap.h" +#include "lpcode.h" +#include "lpprint.h" +#include "lptree.h" + + +/* number of siblings for each tree */ +const byte numsiblings[] = { + 0, 0, 0, /* char, set, any */ + 0, 0, /* true, false */ + 1, /* rep */ + 2, 2, /* seq, choice */ + 1, 1, /* not, and */ + 0, 0, 2, 1, /* call, opencall, rule, grammar */ + 1, /* behind */ + 1, 1 /* capture, runtime capture */ +}; + + +static TTree *newgrammar (lua_State *L, int arg); + + +/* +** returns a reasonable name for value at index 'idx' on the stack +*/ +static const char *val2str (lua_State *L, int idx) { + const char *k = lua_tostring(L, idx); + if (k != NULL) + return lua_pushfstring(L, "%s", k); + else + return lua_pushfstring(L, "(a %s)", luaL_typename(L, idx)); +} + + +/* +** Fix a TOpenCall into a TCall node, using table 'postable' to +** translate a key to its rule address in the tree. Raises an +** error if key does not exist. +*/ +static void fixonecall (lua_State *L, int postable, TTree *g, TTree *t) { + int n; + lua_rawgeti(L, -1, t->key); /* get rule's name */ + lua_gettable(L, postable); /* query name in position table */ + n = lua_tonumber(L, -1); /* get (absolute) position */ + lua_pop(L, 1); /* remove position */ + if (n == 0) { /* no position? */ + lua_rawgeti(L, -1, t->key); /* get rule's name again */ + luaL_error(L, "rule '%s' undefined in given grammar", val2str(L, -1)); + } + t->tag = TCall; + t->u.ps = n - (t - g); /* position relative to node */ + assert(sib2(t)->tag == TRule); + sib2(t)->key = t->key; +} + + +/* +** Transform left associative constructions into right +** associative ones, for sequence and choice; that is: +** (t11 + t12) + t2 => t11 + (t12 + t2) +** (t11 * t12) * t2 => t11 * (t12 * t2) +** (that is, Op (Op t11 t12) t2 => Op t11 (Op t12 t2)) +*/ +static void correctassociativity (TTree *tree) { + TTree *t1 = sib1(tree); + assert(tree->tag == TChoice || tree->tag == TSeq); + while (t1->tag == tree->tag) { + int n1size = tree->u.ps - 1; /* t1 == Op t11 t12 */ + int n11size = t1->u.ps - 1; + int n12size = n1size - n11size - 1; + memmove(sib1(tree), sib1(t1), n11size * sizeof(TTree)); /* move t11 */ + tree->u.ps = n11size + 1; + sib2(tree)->tag = tree->tag; + sib2(tree)->u.ps = n12size + 1; + } +} + + +/* +** Make final adjustments in a tree. Fix open calls in tree 't', +** making them refer to their respective rules or raising appropriate +** errors (if not inside a grammar). Correct associativity of associative +** constructions (making them right associative). Assume that tree's +** ktable is at the top of the stack (for error messages). +*/ +static void finalfix (lua_State *L, int postable, TTree *g, TTree *t) { + tailcall: + switch (t->tag) { + case TGrammar: /* subgrammars were already fixed */ + return; + case TOpenCall: { + if (g != NULL) /* inside a grammar? */ + fixonecall(L, postable, g, t); + else { /* open call outside grammar */ + lua_rawgeti(L, -1, t->key); + luaL_error(L, "rule '%s' used outside a grammar", val2str(L, -1)); + } + break; + } + case TSeq: case TChoice: + correctassociativity(t); + break; + } + switch (numsiblings[t->tag]) { + case 1: /* finalfix(L, postable, g, sib1(t)); */ + t = sib1(t); goto tailcall; + case 2: + finalfix(L, postable, g, sib1(t)); + t = sib2(t); goto tailcall; /* finalfix(L, postable, g, sib2(t)); */ + default: assert(numsiblings[t->tag] == 0); break; + } +} + + + +/* +** {=================================================================== +** KTable manipulation +** +** - The ktable of a pattern 'p' can be shared by other patterns that +** contain 'p' and no other constants. Because of this sharing, we +** should not add elements to a 'ktable' unless it was freshly created +** for the new pattern. +** +** - The maximum index in a ktable is USHRT_MAX, because trees and +** patterns use unsigned shorts to store those indices. +** ==================================================================== +*/ + +/* +** Create a new 'ktable' to the pattern at the top of the stack. +*/ +static void newktable (lua_State *L, int n) { + lua_createtable(L, n, 0); /* create a fresh table */ + lua_setuservalue(L, -2); /* set it as 'ktable' for pattern */ +} + + +/* +** Add element 'idx' to 'ktable' of pattern at the top of the stack; +** Return index of new element. +** If new element is nil, does not add it to table (as it would be +** useless) and returns 0, as ktable[0] is always nil. +*/ +static int addtoktable (lua_State *L, int idx) { + if (lua_isnil(L, idx)) /* nil value? */ + return 0; + else { + int n; + lua_getuservalue(L, -1); /* get ktable from pattern */ + n = lua_rawlen(L, -1); + if (n >= USHRT_MAX) + luaL_error(L, "too many Lua values in pattern"); + lua_pushvalue(L, idx); /* element to be added */ + lua_rawseti(L, -2, ++n); + lua_pop(L, 1); /* remove 'ktable' */ + return n; + } +} + + +/* +** Return the number of elements in the ktable at 'idx'. +** In Lua 5.2/5.3, default "environment" for patterns is nil, not +** a table. Treat it as an empty table. In Lua 5.1, assumes that +** the environment has no numeric indices (len == 0) +*/ +static int ktablelen (lua_State *L, int idx) { + if (!lua_istable(L, idx)) return 0; + else return lua_rawlen(L, idx); +} + + +/* +** Concatentate the contents of table 'idx1' into table 'idx2'. +** (Assume that both indices are negative.) +** Return the original length of table 'idx2' (or 0, if no +** element was added, as there is no need to correct any index). +*/ +static int concattable (lua_State *L, int idx1, int idx2) { + int i; + int n1 = ktablelen(L, idx1); + int n2 = ktablelen(L, idx2); + if (n1 + n2 > USHRT_MAX) + luaL_error(L, "too many Lua values in pattern"); + if (n1 == 0) return 0; /* nothing to correct */ + for (i = 1; i <= n1; i++) { + lua_rawgeti(L, idx1, i); + lua_rawseti(L, idx2 - 1, n2 + i); /* correct 'idx2' */ + } + return n2; +} + + +/* +** When joining 'ktables', constants from one of the subpatterns must +** be renumbered; 'correctkeys' corrects their indices (adding 'n' +** to each of them) +*/ +static void correctkeys (TTree *tree, int n) { + if (n == 0) return; /* no correction? */ + tailcall: + switch (tree->tag) { + case TOpenCall: case TCall: case TRunTime: case TRule: { + if (tree->key > 0) + tree->key += n; + break; + } + case TCapture: { + if (tree->key > 0 && tree->cap != Carg && tree->cap != Cnum) + tree->key += n; + break; + } + default: break; + } + switch (numsiblings[tree->tag]) { + case 1: /* correctkeys(sib1(tree), n); */ + tree = sib1(tree); goto tailcall; + case 2: + correctkeys(sib1(tree), n); + tree = sib2(tree); goto tailcall; /* correctkeys(sib2(tree), n); */ + default: assert(numsiblings[tree->tag] == 0); break; + } +} + + +/* +** Join the ktables from p1 and p2 the ktable for the new pattern at the +** top of the stack, reusing them when possible. +*/ +static void joinktables (lua_State *L, int p1, TTree *t2, int p2) { + int n1, n2; + lua_getuservalue(L, p1); /* get ktables */ + lua_getuservalue(L, p2); + n1 = ktablelen(L, -2); + n2 = ktablelen(L, -1); + if (n1 == 0 && n2 == 0) /* are both tables empty? */ + lua_pop(L, 2); /* nothing to be done; pop tables */ + else if (n2 == 0 || lp_equal(L, -2, -1)) { /* 2nd table empty or equal? */ + lua_pop(L, 1); /* pop 2nd table */ + lua_setuservalue(L, -2); /* set 1st ktable into new pattern */ + } + else if (n1 == 0) { /* first table is empty? */ + lua_setuservalue(L, -3); /* set 2nd table into new pattern */ + lua_pop(L, 1); /* pop 1st table */ + } + else { + lua_createtable(L, n1 + n2, 0); /* create ktable for new pattern */ + /* stack: new p; ktable p1; ktable p2; new ktable */ + concattable(L, -3, -1); /* from p1 into new ktable */ + concattable(L, -2, -1); /* from p2 into new ktable */ + lua_setuservalue(L, -4); /* new ktable becomes 'p' environment */ + lua_pop(L, 2); /* pop other ktables */ + correctkeys(t2, n1); /* correction for indices from p2 */ + } +} + + +/* +** copy 'ktable' of element 'idx' to new tree (on top of stack) +*/ +static void copyktable (lua_State *L, int idx) { + lua_getuservalue(L, idx); + lua_setuservalue(L, -2); +} + + +/* +** merge 'ktable' from 'stree' at stack index 'idx' into 'ktable' +** from tree at the top of the stack, and correct corresponding +** tree. +*/ +static void mergektable (lua_State *L, int idx, TTree *stree) { + int n; + lua_getuservalue(L, -1); /* get ktables */ + lua_getuservalue(L, idx); + n = concattable(L, -1, -2); + lua_pop(L, 2); /* remove both ktables */ + correctkeys(stree, n); +} + + +/* +** Create a new 'ktable' to the pattern at the top of the stack, adding +** all elements from pattern 'p' (if not 0) plus element 'idx' to it. +** Return index of new element. +*/ +static int addtonewktable (lua_State *L, int p, int idx) { + newktable(L, 1); + if (p) + mergektable(L, p, NULL); + return addtoktable(L, idx); +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Tree generation +** ======================================================= +*/ + +/* +** In 5.2, could use 'luaL_testudata'... +*/ +static int testpattern (lua_State *L, int idx) { + if (lua_touserdata(L, idx)) { /* value is a userdata? */ + if (lua_getmetatable(L, idx)) { /* does it have a metatable? */ + luaL_getmetatable(L, PATTERN_T); + if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ + lua_pop(L, 2); /* remove both metatables */ + return 1; + } + } + } + return 0; +} + + +static Pattern *getpattern (lua_State *L, int idx) { + return (Pattern *)luaL_checkudata(L, idx, PATTERN_T); +} + + +static int getsize (lua_State *L, int idx) { + return (lua_rawlen(L, idx) - sizeof(Pattern)) / sizeof(TTree) + 1; +} + + +static TTree *gettree (lua_State *L, int idx, int *len) { + Pattern *p = getpattern(L, idx); + if (len) + *len = getsize(L, idx); + return p->tree; +} + + +/* +** create a pattern. Set its uservalue (the 'ktable') equal to its +** metatable. (It could be any empty sequence; the metatable is at +** hand here, so we use it.) +*/ +static TTree *newtree (lua_State *L, int len) { + size_t size = (len - 1) * sizeof(TTree) + sizeof(Pattern); + Pattern *p = (Pattern *)lua_newuserdata(L, size); + luaL_getmetatable(L, PATTERN_T); + lua_pushvalue(L, -1); + lua_setuservalue(L, -3); + lua_setmetatable(L, -2); + p->code = NULL; p->codesize = 0; + return p->tree; +} + + +static TTree *newleaf (lua_State *L, int tag) { + TTree *tree = newtree(L, 1); + tree->tag = tag; + return tree; +} + + +static TTree *newcharset (lua_State *L) { + TTree *tree = newtree(L, bytes2slots(CHARSETSIZE) + 1); + tree->tag = TSet; + loopset(i, treebuffer(tree)[i] = 0); + return tree; +} + + +/* +** add to tree a sequence where first sibling is 'sib' (with size +** 'sibsize'); returns position for second sibling +*/ +static TTree *seqaux (TTree *tree, TTree *sib, int sibsize) { + tree->tag = TSeq; tree->u.ps = sibsize + 1; + memcpy(sib1(tree), sib, sibsize * sizeof(TTree)); + return sib2(tree); +} + + +/* +** Build a sequence of 'n' nodes, each with tag 'tag' and 'u.n' got +** from the array 's' (or 0 if array is NULL). (TSeq is binary, so it +** must build a sequence of sequence of sequence...) +*/ +static void fillseq (TTree *tree, int tag, int n, const char *s) { + int i; + for (i = 0; i < n - 1; i++) { /* initial n-1 copies of Seq tag; Seq ... */ + tree->tag = TSeq; tree->u.ps = 2; + sib1(tree)->tag = tag; + sib1(tree)->u.n = s ? (byte)s[i] : 0; + tree = sib2(tree); + } + tree->tag = tag; /* last one does not need TSeq */ + tree->u.n = s ? (byte)s[i] : 0; +} + + +/* +** Numbers as patterns: +** 0 == true (always match); n == TAny repeated 'n' times; +** -n == not (TAny repeated 'n' times) +*/ +static TTree *numtree (lua_State *L, int n) { + if (n == 0) + return newleaf(L, TTrue); + else { + TTree *tree, *nd; + if (n > 0) + tree = nd = newtree(L, 2 * n - 1); + else { /* negative: code it as !(-n) */ + n = -n; + tree = newtree(L, 2 * n); + tree->tag = TNot; + nd = sib1(tree); + } + fillseq(nd, TAny, n, NULL); /* sequence of 'n' any's */ + return tree; + } +} + + +/* +** Convert value at index 'idx' to a pattern +*/ +static TTree *getpatt (lua_State *L, int idx, int *len) { + TTree *tree; + switch (lua_type(L, idx)) { + case LUA_TSTRING: { + size_t slen; + const char *s = lua_tolstring(L, idx, &slen); /* get string */ + if (slen == 0) /* empty? */ + tree = newleaf(L, TTrue); /* always match */ + else { + tree = newtree(L, 2 * (slen - 1) + 1); + fillseq(tree, TChar, slen, s); /* sequence of 'slen' chars */ + } + break; + } + case LUA_TNUMBER: { + int n = lua_tointeger(L, idx); + tree = numtree(L, n); + break; + } + case LUA_TBOOLEAN: { + tree = (lua_toboolean(L, idx) ? newleaf(L, TTrue) : newleaf(L, TFalse)); + break; + } + case LUA_TTABLE: { + tree = newgrammar(L, idx); + break; + } + case LUA_TFUNCTION: { + tree = newtree(L, 2); + tree->tag = TRunTime; + tree->key = addtonewktable(L, 0, idx); + sib1(tree)->tag = TTrue; + break; + } + default: { + return gettree(L, idx, len); + } + } + lua_replace(L, idx); /* put new tree into 'idx' slot */ + if (len) + *len = getsize(L, idx); + return tree; +} + + +/* +** create a new tree, whith a new root and one sibling. +** Sibling must be on the Lua stack, at index 1. +*/ +static TTree *newroot1sib (lua_State *L, int tag) { + int s1; + TTree *tree1 = getpatt(L, 1, &s1); + TTree *tree = newtree(L, 1 + s1); /* create new tree */ + tree->tag = tag; + memcpy(sib1(tree), tree1, s1 * sizeof(TTree)); + copyktable(L, 1); + return tree; +} + + +/* +** create a new tree, whith a new root and 2 siblings. +** Siblings must be on the Lua stack, first one at index 1. +*/ +static TTree *newroot2sib (lua_State *L, int tag) { + int s1, s2; + TTree *tree1 = getpatt(L, 1, &s1); + TTree *tree2 = getpatt(L, 2, &s2); + TTree *tree = newtree(L, 1 + s1 + s2); /* create new tree */ + tree->tag = tag; + tree->u.ps = 1 + s1; + memcpy(sib1(tree), tree1, s1 * sizeof(TTree)); + memcpy(sib2(tree), tree2, s2 * sizeof(TTree)); + joinktables(L, 1, sib2(tree), 2); + return tree; +} + + +static int lp_P (lua_State *L) { + luaL_checkany(L, 1); + getpatt(L, 1, NULL); + lua_settop(L, 1); + return 1; +} + + +/* +** sequence operator; optimizations: +** false x => false, x true => x, true x => x +** (cannot do x . false => false because x may have runtime captures) +*/ +static int lp_seq (lua_State *L) { + TTree *tree1 = getpatt(L, 1, NULL); + TTree *tree2 = getpatt(L, 2, NULL); + if (tree1->tag == TFalse || tree2->tag == TTrue) + lua_pushvalue(L, 1); /* false . x == false, x . true = x */ + else if (tree1->tag == TTrue) + lua_pushvalue(L, 2); /* true . x = x */ + else + newroot2sib(L, TSeq); + return 1; +} + + +/* +** choice operator; optimizations: +** charset / charset => charset +** true / x => true, x / false => x, false / x => x +** (x / true is not equivalent to true) +*/ +static int lp_choice (lua_State *L) { + Charset st1, st2; + TTree *t1 = getpatt(L, 1, NULL); + TTree *t2 = getpatt(L, 2, NULL); + if (tocharset(t1, &st1) && tocharset(t2, &st2)) { + TTree *t = newcharset(L); + loopset(i, treebuffer(t)[i] = st1.cs[i] | st2.cs[i]); + } + else if (nofail(t1) || t2->tag == TFalse) + lua_pushvalue(L, 1); /* true / x => true, x / false => x */ + else if (t1->tag == TFalse) + lua_pushvalue(L, 2); /* false / x => x */ + else + newroot2sib(L, TChoice); + return 1; +} + + +/* +** p^n +*/ +static int lp_star (lua_State *L) { + int size1; + int n = (int)luaL_checkinteger(L, 2); + TTree *tree1 = getpatt(L, 1, &size1); + if (n >= 0) { /* seq tree1 (seq tree1 ... (seq tree1 (rep tree1))) */ + TTree *tree = newtree(L, (n + 1) * (size1 + 1)); + if (nullable(tree1)) + luaL_error(L, "loop body may accept empty string"); + while (n--) /* repeat 'n' times */ + tree = seqaux(tree, tree1, size1); + tree->tag = TRep; + memcpy(sib1(tree), tree1, size1 * sizeof(TTree)); + } + else { /* choice (seq tree1 ... choice tree1 true ...) true */ + TTree *tree; + n = -n; + /* size = (choice + seq + tree1 + true) * n, but the last has no seq */ + tree = newtree(L, n * (size1 + 3) - 1); + for (; n > 1; n--) { /* repeat (n - 1) times */ + tree->tag = TChoice; tree->u.ps = n * (size1 + 3) - 2; + sib2(tree)->tag = TTrue; + tree = sib1(tree); + tree = seqaux(tree, tree1, size1); + } + tree->tag = TChoice; tree->u.ps = size1 + 1; + sib2(tree)->tag = TTrue; + memcpy(sib1(tree), tree1, size1 * sizeof(TTree)); + } + copyktable(L, 1); + return 1; +} + + +/* +** #p == &p +*/ +static int lp_and (lua_State *L) { + newroot1sib(L, TAnd); + return 1; +} + + +/* +** -p == !p +*/ +static int lp_not (lua_State *L) { + newroot1sib(L, TNot); + return 1; +} + + +/* +** [t1 - t2] == Seq (Not t2) t1 +** If t1 and t2 are charsets, make their difference. +*/ +static int lp_sub (lua_State *L) { + Charset st1, st2; + int s1, s2; + TTree *t1 = getpatt(L, 1, &s1); + TTree *t2 = getpatt(L, 2, &s2); + if (tocharset(t1, &st1) && tocharset(t2, &st2)) { + TTree *t = newcharset(L); + loopset(i, treebuffer(t)[i] = st1.cs[i] & ~st2.cs[i]); + } + else { + TTree *tree = newtree(L, 2 + s1 + s2); + tree->tag = TSeq; /* sequence of... */ + tree->u.ps = 2 + s2; + sib1(tree)->tag = TNot; /* ...not... */ + memcpy(sib1(sib1(tree)), t2, s2 * sizeof(TTree)); /* ...t2 */ + memcpy(sib2(tree), t1, s1 * sizeof(TTree)); /* ... and t1 */ + joinktables(L, 1, sib1(tree), 2); + } + return 1; +} + + +static int lp_set (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + TTree *tree = newcharset(L); + while (l--) { + setchar(treebuffer(tree), (byte)(*s)); + s++; + } + return 1; +} + + +static int lp_range (lua_State *L) { + int arg; + int top = lua_gettop(L); + TTree *tree = newcharset(L); + for (arg = 1; arg <= top; arg++) { + int c; + size_t l; + const char *r = luaL_checklstring(L, arg, &l); + luaL_argcheck(L, l == 2, arg, "range must have two characters"); + for (c = (byte)r[0]; c <= (byte)r[1]; c++) + setchar(treebuffer(tree), c); + } + return 1; +} + + +/* +** Look-behind predicate +*/ +static int lp_behind (lua_State *L) { + TTree *tree; + TTree *tree1 = getpatt(L, 1, NULL); + int n = fixedlen(tree1); + luaL_argcheck(L, n >= 0, 1, "pattern may not have fixed length"); + luaL_argcheck(L, !hascaptures(tree1), 1, "pattern have captures"); + luaL_argcheck(L, n <= MAXBEHIND, 1, "pattern too long to look behind"); + tree = newroot1sib(L, TBehind); + tree->u.n = n; + return 1; +} + + +/* +** Create a non-terminal +*/ +static int lp_V (lua_State *L) { + TTree *tree = newleaf(L, TOpenCall); + luaL_argcheck(L, !lua_isnoneornil(L, 1), 1, "non-nil value expected"); + tree->key = addtonewktable(L, 0, 1); + return 1; +} + + +/* +** Create a tree for a non-empty capture, with a body and +** optionally with an associated Lua value (at index 'labelidx' in the +** stack) +*/ +static int capture_aux (lua_State *L, int cap, int labelidx) { + TTree *tree = newroot1sib(L, TCapture); + tree->cap = cap; + tree->key = (labelidx == 0) ? 0 : addtonewktable(L, 1, labelidx); + return 1; +} + + +/* +** Fill a tree with an empty capture, using an empty (TTrue) sibling. +*/ +static TTree *auxemptycap (TTree *tree, int cap) { + tree->tag = TCapture; + tree->cap = cap; + sib1(tree)->tag = TTrue; + return tree; +} + + +/* +** Create a tree for an empty capture +*/ +static TTree *newemptycap (lua_State *L, int cap) { + return auxemptycap(newtree(L, 2), cap); +} + + +/* +** Create a tree for an empty capture with an associated Lua value +*/ +static TTree *newemptycapkey (lua_State *L, int cap, int idx) { + TTree *tree = auxemptycap(newtree(L, 2), cap); + tree->key = addtonewktable(L, 0, idx); + return tree; +} + + +/* +** Captures with syntax p / v +** (function capture, query capture, string capture, or number capture) +*/ +static int lp_divcapture (lua_State *L) { + switch (lua_type(L, 2)) { + case LUA_TFUNCTION: return capture_aux(L, Cfunction, 2); + case LUA_TTABLE: return capture_aux(L, Cquery, 2); + case LUA_TSTRING: return capture_aux(L, Cstring, 2); + case LUA_TNUMBER: { + int n = lua_tointeger(L, 2); + TTree *tree = newroot1sib(L, TCapture); + luaL_argcheck(L, 0 <= n && n <= SHRT_MAX, 1, "invalid number"); + tree->cap = Cnum; + tree->key = n; + return 1; + } + default: return luaL_argerror(L, 2, "invalid replacement value"); + } +} + + +static int lp_substcapture (lua_State *L) { + return capture_aux(L, Csubst, 0); +} + + +static int lp_tablecapture (lua_State *L) { + return capture_aux(L, Ctable, 0); +} + + +static int lp_groupcapture (lua_State *L) { + if (lua_isnoneornil(L, 2)) + return capture_aux(L, Cgroup, 0); + else + return capture_aux(L, Cgroup, 2); +} + + +static int lp_foldcapture (lua_State *L) { + luaL_checktype(L, 2, LUA_TFUNCTION); + return capture_aux(L, Cfold, 2); +} + + +static int lp_simplecapture (lua_State *L) { + return capture_aux(L, Csimple, 0); +} + + +static int lp_poscapture (lua_State *L) { + newemptycap(L, Cposition); + return 1; +} + + +static int lp_argcapture (lua_State *L) { + int n = (int)luaL_checkinteger(L, 1); + TTree *tree = newemptycap(L, Carg); + tree->key = n; + luaL_argcheck(L, 0 < n && n <= SHRT_MAX, 1, "invalid argument index"); + return 1; +} + + +static int lp_backref (lua_State *L) { + luaL_checkany(L, 1); + newemptycapkey(L, Cbackref, 1); + return 1; +} + + +/* +** Constant capture +*/ +static int lp_constcapture (lua_State *L) { + int i; + int n = lua_gettop(L); /* number of values */ + if (n == 0) /* no values? */ + newleaf(L, TTrue); /* no capture */ + else if (n == 1) + newemptycapkey(L, Cconst, 1); /* single constant capture */ + else { /* create a group capture with all values */ + TTree *tree = newtree(L, 1 + 3 * (n - 1) + 2); + newktable(L, n); /* create a 'ktable' for new tree */ + tree->tag = TCapture; + tree->cap = Cgroup; + tree->key = 0; + tree = sib1(tree); + for (i = 1; i <= n - 1; i++) { + tree->tag = TSeq; + tree->u.ps = 3; /* skip TCapture and its sibling */ + auxemptycap(sib1(tree), Cconst); + sib1(tree)->key = addtoktable(L, i); + tree = sib2(tree); + } + auxemptycap(tree, Cconst); + tree->key = addtoktable(L, i); + } + return 1; +} + + +static int lp_matchtime (lua_State *L) { + TTree *tree; + luaL_checktype(L, 2, LUA_TFUNCTION); + tree = newroot1sib(L, TRunTime); + tree->key = addtonewktable(L, 1, 2); + return 1; +} + +/* }====================================================== */ + + +/* +** {====================================================== +** Grammar - Tree generation +** ======================================================= +*/ + +/* +** push on the stack the index and the pattern for the +** initial rule of grammar at index 'arg' in the stack; +** also add that index into position table. +*/ +static void getfirstrule (lua_State *L, int arg, int postab) { + lua_rawgeti(L, arg, 1); /* access first element */ + if (lua_isstring(L, -1)) { /* is it the name of initial rule? */ + lua_pushvalue(L, -1); /* duplicate it to use as key */ + lua_gettable(L, arg); /* get associated rule */ + } + else { + lua_pushinteger(L, 1); /* key for initial rule */ + lua_insert(L, -2); /* put it before rule */ + } + if (!testpattern(L, -1)) { /* initial rule not a pattern? */ + if (lua_isnil(L, -1)) + luaL_error(L, "grammar has no initial rule"); + else + luaL_error(L, "initial rule '%s' is not a pattern", lua_tostring(L, -2)); + } + lua_pushvalue(L, -2); /* push key */ + lua_pushinteger(L, 1); /* push rule position (after TGrammar) */ + lua_settable(L, postab); /* insert pair at position table */ +} + +/* +** traverse grammar at index 'arg', pushing all its keys and patterns +** into the stack. Create a new table (before all pairs key-pattern) to +** collect all keys and their associated positions in the final tree +** (the "position table"). +** Return the number of rules and (in 'totalsize') the total size +** for the new tree. +*/ +static int collectrules (lua_State *L, int arg, int *totalsize) { + int n = 1; /* to count number of rules */ + int postab = lua_gettop(L) + 1; /* index of position table */ + int size; /* accumulator for total size */ + lua_newtable(L); /* create position table */ + getfirstrule(L, arg, postab); + size = 2 + getsize(L, postab + 2); /* TGrammar + TRule + rule */ + lua_pushnil(L); /* prepare to traverse grammar table */ + while (lua_next(L, arg) != 0) { + if (lua_tonumber(L, -2) == 1 || + lp_equal(L, -2, postab + 1)) { /* initial rule? */ + lua_pop(L, 1); /* remove value (keep key for lua_next) */ + continue; + } + if (!testpattern(L, -1)) /* value is not a pattern? */ + luaL_error(L, "rule '%s' is not a pattern", val2str(L, -2)); + luaL_checkstack(L, LUA_MINSTACK, "grammar has too many rules"); + lua_pushvalue(L, -2); /* push key (to insert into position table) */ + lua_pushinteger(L, size); + lua_settable(L, postab); + size += 1 + getsize(L, -1); /* update size */ + lua_pushvalue(L, -2); /* push key (for next lua_next) */ + n++; + } + *totalsize = size + 1; /* TTrue to finish list of rules */ + return n; +} + + +static void buildgrammar (lua_State *L, TTree *grammar, int frule, int n) { + int i; + TTree *nd = sib1(grammar); /* auxiliary pointer to traverse the tree */ + for (i = 0; i < n; i++) { /* add each rule into new tree */ + int ridx = frule + 2*i + 1; /* index of i-th rule */ + int rulesize; + TTree *rn = gettree(L, ridx, &rulesize); + nd->tag = TRule; + nd->key = 0; + nd->cap = i; /* rule number */ + nd->u.ps = rulesize + 1; /* point to next rule */ + memcpy(sib1(nd), rn, rulesize * sizeof(TTree)); /* copy rule */ + mergektable(L, ridx, sib1(nd)); /* merge its ktable into new one */ + nd = sib2(nd); /* move to next rule */ + } + nd->tag = TTrue; /* finish list of rules */ +} + + +/* +** Check whether a tree has potential infinite loops +*/ +static int checkloops (TTree *tree) { + tailcall: + if (tree->tag == TRep && nullable(sib1(tree))) + return 1; + else if (tree->tag == TGrammar) + return 0; /* sub-grammars already checked */ + else { + switch (numsiblings[tree->tag]) { + case 1: /* return checkloops(sib1(tree)); */ + tree = sib1(tree); goto tailcall; + case 2: + if (checkloops(sib1(tree))) return 1; + /* else return checkloops(sib2(tree)); */ + tree = sib2(tree); goto tailcall; + default: assert(numsiblings[tree->tag] == 0); return 0; + } + } +} + + +static int verifyerror (lua_State *L, int *passed, int npassed) { + int i, j; + for (i = npassed - 1; i >= 0; i--) { /* search for a repetition */ + for (j = i - 1; j >= 0; j--) { + if (passed[i] == passed[j]) { + lua_rawgeti(L, -1, passed[i]); /* get rule's key */ + return luaL_error(L, "rule '%s' may be left recursive", val2str(L, -1)); + } + } + } + return luaL_error(L, "too many left calls in grammar"); +} + + +/* +** Check whether a rule can be left recursive; raise an error in that +** case; otherwise return 1 iff pattern is nullable. +** The return value is used to check sequences, where the second pattern +** is only relevant if the first is nullable. +** Parameter 'nb' works as an accumulator, to allow tail calls in +** choices. ('nb' true makes function returns true.) +** Assume ktable at the top of the stack. +*/ +static int verifyrule (lua_State *L, TTree *tree, int *passed, int npassed, + int nb) { + tailcall: + switch (tree->tag) { + case TChar: case TSet: case TAny: + case TFalse: + return nb; /* cannot pass from here */ + case TTrue: + case TBehind: /* look-behind cannot have calls */ + return 1; + case TNot: case TAnd: case TRep: + /* return verifyrule(L, sib1(tree), passed, npassed, 1); */ + tree = sib1(tree); nb = 1; goto tailcall; + case TCapture: case TRunTime: + /* return verifyrule(L, sib1(tree), passed, npassed, nb); */ + tree = sib1(tree); goto tailcall; + case TCall: + /* return verifyrule(L, sib2(tree), passed, npassed, nb); */ + tree = sib2(tree); goto tailcall; + case TSeq: /* only check 2nd child if first is nb */ + if (!verifyrule(L, sib1(tree), passed, npassed, 0)) + return nb; + /* else return verifyrule(L, sib2(tree), passed, npassed, nb); */ + tree = sib2(tree); goto tailcall; + case TChoice: /* must check both children */ + nb = verifyrule(L, sib1(tree), passed, npassed, nb); + /* return verifyrule(L, sib2(tree), passed, npassed, nb); */ + tree = sib2(tree); goto tailcall; + case TRule: + if (npassed >= MAXRULES) + return verifyerror(L, passed, npassed); + else { + passed[npassed++] = tree->key; + /* return verifyrule(L, sib1(tree), passed, npassed); */ + tree = sib1(tree); goto tailcall; + } + case TGrammar: + return nullable(tree); /* sub-grammar cannot be left recursive */ + default: assert(0); return 0; + } +} + + +static void verifygrammar (lua_State *L, TTree *grammar) { + int passed[MAXRULES]; + TTree *rule; + /* check left-recursive rules */ + for (rule = sib1(grammar); rule->tag == TRule; rule = sib2(rule)) { + if (rule->key == 0) continue; /* unused rule */ + verifyrule(L, sib1(rule), passed, 0, 0); + } + assert(rule->tag == TTrue); + /* check infinite loops inside rules */ + for (rule = sib1(grammar); rule->tag == TRule; rule = sib2(rule)) { + if (rule->key == 0) continue; /* unused rule */ + if (checkloops(sib1(rule))) { + lua_rawgeti(L, -1, rule->key); /* get rule's key */ + luaL_error(L, "empty loop in rule '%s'", val2str(L, -1)); + } + } + assert(rule->tag == TTrue); +} + + +/* +** Give a name for the initial rule if it is not referenced +*/ +static void initialrulename (lua_State *L, TTree *grammar, int frule) { + if (sib1(grammar)->key == 0) { /* initial rule is not referenced? */ + int n = lua_rawlen(L, -1) + 1; /* index for name */ + lua_pushvalue(L, frule); /* rule's name */ + lua_rawseti(L, -2, n); /* ktable was on the top of the stack */ + sib1(grammar)->key = n; + } +} + + +static TTree *newgrammar (lua_State *L, int arg) { + int treesize; + int frule = lua_gettop(L) + 2; /* position of first rule's key */ + int n = collectrules(L, arg, &treesize); + TTree *g = newtree(L, treesize); + luaL_argcheck(L, n <= MAXRULES, arg, "grammar has too many rules"); + g->tag = TGrammar; g->u.n = n; + lua_newtable(L); /* create 'ktable' */ + lua_setuservalue(L, -2); + buildgrammar(L, g, frule, n); + lua_getuservalue(L, -1); /* get 'ktable' for new tree */ + finalfix(L, frule - 1, g, sib1(g)); + initialrulename(L, g, frule); + verifygrammar(L, g); + lua_pop(L, 1); /* remove 'ktable' */ + lua_insert(L, -(n * 2 + 2)); /* move new table to proper position */ + lua_pop(L, n * 2 + 1); /* remove position table + rule pairs */ + return g; /* new table at the top of the stack */ +} + +/* }====================================================== */ + + +static Instruction *prepcompile (lua_State *L, Pattern *p, int idx) { + lua_getuservalue(L, idx); /* push 'ktable' (may be used by 'finalfix') */ + finalfix(L, 0, NULL, p->tree); + lua_pop(L, 1); /* remove 'ktable' */ + return compile(L, p); +} + + +static int lp_printtree (lua_State *L) { + TTree *tree = getpatt(L, 1, NULL); + int c = lua_toboolean(L, 2); + if (c) { + lua_getuservalue(L, 1); /* push 'ktable' (may be used by 'finalfix') */ + finalfix(L, 0, NULL, tree); + lua_pop(L, 1); /* remove 'ktable' */ + } + printktable(L, 1); + printtree(tree, 0); + return 0; +} + + +static int lp_printcode (lua_State *L) { + Pattern *p = getpattern(L, 1); + printktable(L, 1); + if (p->code == NULL) /* not compiled yet? */ + prepcompile(L, p, 1); + printpatt(p->code, p->codesize); + return 0; +} + + +/* +** Get the initial position for the match, interpreting negative +** values from the end of the subject +*/ +static size_t initposition (lua_State *L, size_t len) { + lua_Integer ii = luaL_optinteger(L, 3, 1); + if (ii > 0) { /* positive index? */ + if ((size_t)ii <= len) /* inside the string? */ + return (size_t)ii - 1; /* return it (corrected to 0-base) */ + else return len; /* crop at the end */ + } + else { /* negative index */ + if ((size_t)(-ii) <= len) /* inside the string? */ + return len - ((size_t)(-ii)); /* return position from the end */ + else return 0; /* crop at the beginning */ + } +} + + +/* +** Main match function +*/ +static int lp_match (lua_State *L) { + Capture capture[INITCAPSIZE]; + const char *r; + size_t l; + Pattern *p = (getpatt(L, 1, NULL), getpattern(L, 1)); + Instruction *code = (p->code != NULL) ? p->code : prepcompile(L, p, 1); + const char *s = luaL_checklstring(L, SUBJIDX, &l); + size_t i = initposition(L, l); + int ptop = lua_gettop(L); + lua_pushnil(L); /* initialize subscache */ + lua_pushlightuserdata(L, capture); /* initialize caplistidx */ + lua_getuservalue(L, 1); /* initialize penvidx */ + r = match(L, s, s + i, s + l, code, capture, ptop); + if (r == NULL) { + lua_pushnil(L); + return 1; + } + return getcaptures(L, s, r, ptop); +} + + + +/* +** {====================================================== +** Library creation and functions not related to matching +** ======================================================= +*/ + +/* maximum limit for stack size */ +#define MAXLIM (INT_MAX / 100) + +static int lp_setmax (lua_State *L) { + lua_Integer lim = luaL_checkinteger(L, 1); + luaL_argcheck(L, 0 < lim && lim <= MAXLIM, 1, "out of range"); + lua_settop(L, 1); + lua_setfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX); + return 0; +} + + +static int lp_version (lua_State *L) { + lua_pushstring(L, VERSION); + return 1; +} + + +static int lp_type (lua_State *L) { + if (testpattern(L, 1)) + lua_pushliteral(L, "pattern"); + else + lua_pushnil(L); + return 1; +} + + +int lp_gc (lua_State *L) { + Pattern *p = getpattern(L, 1); + realloccode(L, p, 0); /* delete code block */ + return 0; +} + + +static void createcat (lua_State *L, const char *catname, int (catf) (int)) { + TTree *t = newcharset(L); + int i; + for (i = 0; i <= UCHAR_MAX; i++) + if (catf(i)) setchar(treebuffer(t), i); + lua_setfield(L, -2, catname); +} + + +static int lp_locale (lua_State *L) { + if (lua_isnoneornil(L, 1)) { + lua_settop(L, 0); + lua_createtable(L, 0, 12); + } + else { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); + } + createcat(L, "alnum", isalnum); + createcat(L, "alpha", isalpha); + createcat(L, "cntrl", iscntrl); + createcat(L, "digit", isdigit); + createcat(L, "graph", isgraph); + createcat(L, "lower", islower); + createcat(L, "print", isprint); + createcat(L, "punct", ispunct); + createcat(L, "space", isspace); + createcat(L, "upper", isupper); + createcat(L, "xdigit", isxdigit); + return 1; +} + + +static struct luaL_Reg pattreg[] = { + {"ptree", lp_printtree}, + {"pcode", lp_printcode}, + {"match", lp_match}, + {"B", lp_behind}, + {"V", lp_V}, + {"C", lp_simplecapture}, + {"Cc", lp_constcapture}, + {"Cmt", lp_matchtime}, + {"Cb", lp_backref}, + {"Carg", lp_argcapture}, + {"Cp", lp_poscapture}, + {"Cs", lp_substcapture}, + {"Ct", lp_tablecapture}, + {"Cf", lp_foldcapture}, + {"Cg", lp_groupcapture}, + {"P", lp_P}, + {"S", lp_set}, + {"R", lp_range}, + {"locale", lp_locale}, + {"version", lp_version}, + {"setmaxstack", lp_setmax}, + {"type", lp_type}, + {NULL, NULL} +}; + + +static struct luaL_Reg metareg[] = { + {"__mul", lp_seq}, + {"__add", lp_choice}, + {"__pow", lp_star}, + {"__gc", lp_gc}, + {"__len", lp_and}, + {"__div", lp_divcapture}, + {"__unm", lp_not}, + {"__sub", lp_sub}, + {NULL, NULL} +}; + + +int luaopen_lpeg (lua_State *L); +int luaopen_lpeg (lua_State *L) { + luaL_newmetatable(L, PATTERN_T); + lua_pushnumber(L, MAXBACK); /* initialize maximum backtracking */ + lua_setfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX); + luaL_setfuncs(L, metareg, 0); + luaL_newlib(L, pattreg); + lua_pushvalue(L, -1); + lua_setfield(L, -3, "__index"); + return 1; +} + +/* }====================================================== */ diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lptree.h b/dep/scintilla/scintilla-3.10.6/lua/src/lptree.h new file mode 100644 index 00000000..b69528a6 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lptree.h @@ -0,0 +1,77 @@ +/* +** $Id: lptree.h,v 1.2 2013/03/24 13:51:12 roberto Exp $ +*/ + +#if !defined(lptree_h) +#define lptree_h + + +#include "lptypes.h" + + +/* +** types of trees +*/ +typedef enum TTag { + TChar = 0, TSet, TAny, /* standard PEG elements */ + TTrue, TFalse, + TRep, + TSeq, TChoice, + TNot, TAnd, + TCall, + TOpenCall, + TRule, /* sib1 is rule's pattern, sib2 is 'next' rule */ + TGrammar, /* sib1 is initial (and first) rule */ + TBehind, /* match behind */ + TCapture, /* regular capture */ + TRunTime /* run-time capture */ +} TTag; + +/* number of siblings for each tree */ +extern const byte numsiblings[]; + + +/* +** Tree trees +** The first sibling of a tree (if there is one) is immediately after +** the tree. A reference to a second sibling (ps) is its position +** relative to the position of the tree itself. A key in ktable +** uses the (unique) address of the original tree that created that +** entry. NULL means no data. +*/ +typedef struct TTree { + byte tag; + byte cap; /* kind of capture (if it is a capture) */ + unsigned short key; /* key in ktable for Lua data (0 if no key) */ + union { + int ps; /* occasional second sibling */ + int n; /* occasional counter */ + } u; +} TTree; + + +/* +** A complete pattern has its tree plus, if already compiled, +** its corresponding code +*/ +typedef struct Pattern { + union Instruction *code; + int codesize; + TTree tree[1]; +} Pattern; + + +/* number of siblings for each tree */ +extern const byte numsiblings[]; + +/* access to siblings */ +#define sib1(t) ((t) + 1) +#define sib2(t) ((t) + (t)->u.ps) + + + + + + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lptypes.h b/dep/scintilla/scintilla-3.10.6/lua/src/lptypes.h new file mode 100644 index 00000000..5eb7987b --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lptypes.h @@ -0,0 +1,149 @@ +/* +** $Id: lptypes.h,v 1.14 2015/09/28 17:17:41 roberto Exp $ +** LPeg - PEG pattern matching for Lua +** Copyright 2007-2015, Lua.org & PUC-Rio (see 'lpeg.html' for license) +** written by Roberto Ierusalimschy +*/ + +#if !defined(lptypes_h) +#define lptypes_h + + +#if !defined(LPEG_DEBUG) +#define NDEBUG +#endif + +#include +#include + +#include "lua.h" + + +#define VERSION "1.0.0" + + +#define PATTERN_T "lpeg-pattern" +#define MAXSTACKIDX "lpeg-maxstack" + + +/* +** compatibility with Lua 5.1 +*/ +#if (LUA_VERSION_NUM == 501) + +#define lp_equal lua_equal + +#define lua_getuservalue lua_getfenv +#define lua_setuservalue lua_setfenv + +#define lua_rawlen lua_objlen + +#define luaL_setfuncs(L,f,n) luaL_register(L,NULL,f) +#define luaL_newlib(L,f) luaL_register(L,"lpeg",f) + +#endif + + +#if !defined(lp_equal) +#define lp_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) +#endif + + +/* default maximum size for call/backtrack stack */ +#if !defined(MAXBACK) +#define MAXBACK 400 +#endif + + +/* maximum number of rules in a grammar */ +#if !defined(MAXRULES) +#define MAXRULES 1000 +#endif + + + +/* initial size for capture's list */ +#define INITCAPSIZE 32 + + +/* index, on Lua stack, for subject */ +#define SUBJIDX 2 + +/* number of fixed arguments to 'match' (before capture arguments) */ +#define FIXEDARGS 3 + +/* index, on Lua stack, for capture list */ +#define caplistidx(ptop) ((ptop) + 2) + +/* index, on Lua stack, for pattern's ktable */ +#define ktableidx(ptop) ((ptop) + 3) + +/* index, on Lua stack, for backtracking stack */ +#define stackidx(ptop) ((ptop) + 4) + + + +typedef unsigned char byte; + + +#define BITSPERCHAR 8 + +#define CHARSETSIZE ((UCHAR_MAX/BITSPERCHAR) + 1) + + + +typedef struct Charset { + byte cs[CHARSETSIZE]; +} Charset; + + + +#define loopset(v,b) { int v; for (v = 0; v < CHARSETSIZE; v++) {b;} } + +/* access to charset */ +#define treebuffer(t) ((byte *)((t) + 1)) + +/* number of slots needed for 'n' bytes */ +#define bytes2slots(n) (((n) - 1) / sizeof(TTree) + 1) + +/* set 'b' bit in charset 'cs' */ +#define setchar(cs,b) ((cs)[(b) >> 3] |= (1 << ((b) & 7))) + + +/* +** in capture instructions, 'kind' of capture and its offset are +** packed in field 'aux', 4 bits for each +*/ +#define getkind(op) ((op)->i.aux & 0xF) +#define getoff(op) (((op)->i.aux >> 4) & 0xF) +#define joinkindoff(k,o) ((k) | ((o) << 4)) + +#define MAXOFF 0xF +#define MAXAUX 0xFF + + +/* maximum number of bytes to look behind */ +#define MAXBEHIND MAXAUX + + +/* maximum size (in elements) for a pattern */ +#define MAXPATTSIZE (SHRT_MAX - 10) + + +/* size (in elements) for an instruction plus extra l bytes */ +#define instsize(l) (((l) + sizeof(Instruction) - 1)/sizeof(Instruction) + 1) + + +/* size (in elements) for a ISet instruction */ +#define CHARSETINSTSIZE instsize(CHARSETSIZE) + +/* size (in elements) for a IFunc instruction */ +#define funcinstsize(p) ((p)->i.aux + 2) + + + +#define testchar(st,c) (((int)(st)[((c) >> 3)] & (1 << ((c) & 7)))) + + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lpvm.c b/dep/scintilla/scintilla-3.10.6/lua/src/lpvm.c new file mode 100644 index 00000000..eaf2ebfd --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lpvm.c @@ -0,0 +1,355 @@ +/* +** $Id: lpvm.c,v 1.6 2015/09/28 17:01:25 roberto Exp $ +** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license) +*/ + +#include +#include + + +#include "lua.h" +#include "lauxlib.h" + +#include "lpcap.h" +#include "lptypes.h" +#include "lpvm.h" +#include "lpprint.h" + + +/* initial size for call/backtrack stack */ +#if !defined(INITBACK) +#define INITBACK MAXBACK +#endif + + +#define getoffset(p) (((p) + 1)->offset) + +static const Instruction giveup = {{IGiveup, 0, 0}}; + + +/* +** {====================================================== +** Virtual Machine +** ======================================================= +*/ + + +typedef struct Stack { + const char *s; /* saved position (or NULL for calls) */ + const Instruction *p; /* next instruction */ + int caplevel; +} Stack; + + +#define getstackbase(L, ptop) ((Stack *)lua_touserdata(L, stackidx(ptop))) + + +/* +** Double the size of the array of captures +*/ +static Capture *doublecap (lua_State *L, Capture *cap, int captop, int ptop) { + Capture *newc; + if (captop >= INT_MAX/((int)sizeof(Capture) * 2)) + luaL_error(L, "too many captures"); + newc = (Capture *)lua_newuserdata(L, captop * 2 * sizeof(Capture)); + memcpy(newc, cap, captop * sizeof(Capture)); + lua_replace(L, caplistidx(ptop)); + return newc; +} + + +/* +** Double the size of the stack +*/ +static Stack *doublestack (lua_State *L, Stack **stacklimit, int ptop) { + Stack *stack = getstackbase(L, ptop); + Stack *newstack; + int n = *stacklimit - stack; /* current stack size */ + int max, newn; + lua_getfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX); + max = lua_tointeger(L, -1); /* maximum allowed size */ + lua_pop(L, 1); + if (n >= max) /* already at maximum size? */ + luaL_error(L, "backtrack stack overflow (current limit is %d)", max); + newn = 2 * n; /* new size */ + if (newn > max) newn = max; + newstack = (Stack *)lua_newuserdata(L, newn * sizeof(Stack)); + memcpy(newstack, stack, n * sizeof(Stack)); + lua_replace(L, stackidx(ptop)); + *stacklimit = newstack + newn; + return newstack + n; /* return next position */ +} + + +/* +** Interpret the result of a dynamic capture: false -> fail; +** true -> keep current position; number -> next position. +** Return new subject position. 'fr' is stack index where +** is the result; 'curr' is current subject position; 'limit' +** is subject's size. +*/ +static int resdyncaptures (lua_State *L, int fr, int curr, int limit) { + lua_Integer res; + if (!lua_toboolean(L, fr)) { /* false value? */ + lua_settop(L, fr - 1); /* remove results */ + return -1; /* and fail */ + } + else if (lua_isboolean(L, fr)) /* true? */ + res = curr; /* keep current position */ + else { + res = lua_tointeger(L, fr) - 1; /* new position */ + if (res < curr || res > limit) + luaL_error(L, "invalid position returned by match-time capture"); + } + lua_remove(L, fr); /* remove first result (offset) */ + return res; +} + + +/* +** Add capture values returned by a dynamic capture to the capture list +** 'base', nested inside a group capture. 'fd' indexes the first capture +** value, 'n' is the number of values (at least 1). +*/ +static void adddyncaptures (const char *s, Capture *base, int n, int fd) { + int i; + /* Cgroup capture is already there */ + assert(base[0].kind == Cgroup && base[0].siz == 0); + base[0].idx = 0; /* make it an anonymous group */ + for (i = 1; i <= n; i++) { /* add runtime captures */ + base[i].kind = Cruntime; + base[i].siz = 1; /* mark it as closed */ + base[i].idx = fd + i - 1; /* stack index of capture value */ + base[i].s = s; + } + base[i].kind = Cclose; /* close group */ + base[i].siz = 1; + base[i].s = s; +} + + +/* +** Remove dynamic captures from the Lua stack (called in case of failure) +*/ +static int removedyncap (lua_State *L, Capture *capture, + int level, int last) { + int id = finddyncap(capture + level, capture + last); /* index of 1st cap. */ + int top = lua_gettop(L); + if (id == 0) return 0; /* no dynamic captures? */ + lua_settop(L, id - 1); /* remove captures */ + return top - id + 1; /* number of values removed */ +} + + +/* +** Opcode interpreter +*/ +const char *match (lua_State *L, const char *o, const char *s, const char *e, + Instruction *op, Capture *capture, int ptop) { + Stack stackbase[INITBACK]; + Stack *stacklimit = stackbase + INITBACK; + Stack *stack = stackbase; /* point to first empty slot in stack */ + int capsize = INITCAPSIZE; + int captop = 0; /* point to first empty slot in captures */ + int ndyncap = 0; /* number of dynamic captures (in Lua stack) */ + const Instruction *p = op; /* current instruction */ + stack->p = &giveup; stack->s = s; stack->caplevel = 0; stack++; + lua_pushlightuserdata(L, stackbase); + for (;;) { +#if defined(DEBUG) + printf("s: |%s| stck:%d, dyncaps:%d, caps:%d ", + s, stack - getstackbase(L, ptop), ndyncap, captop); + printinst(op, p); + printcaplist(capture, capture + captop); +#endif + assert(stackidx(ptop) + ndyncap == lua_gettop(L) && ndyncap <= captop); + switch ((Opcode)p->i.code) { + case IEnd: { + assert(stack == getstackbase(L, ptop) + 1); + capture[captop].kind = Cclose; + capture[captop].s = NULL; + return s; + } + case IGiveup: { + assert(stack == getstackbase(L, ptop)); + return NULL; + } + case IRet: { + assert(stack > getstackbase(L, ptop) && (stack - 1)->s == NULL); + p = (--stack)->p; + continue; + } + case IAny: { + if (s < e) { p++; s++; } + else goto fail; + continue; + } + case ITestAny: { + if (s < e) p += 2; + else p += getoffset(p); + continue; + } + case IChar: { + if ((byte)*s == p->i.aux && s < e) { p++; s++; } + else goto fail; + continue; + } + case ITestChar: { + if ((byte)*s == p->i.aux && s < e) p += 2; + else p += getoffset(p); + continue; + } + case ISet: { + int c = (byte)*s; + if (testchar((p+1)->buff, c) && s < e) + { p += CHARSETINSTSIZE; s++; } + else goto fail; + continue; + } + case ITestSet: { + int c = (byte)*s; + if (testchar((p + 2)->buff, c) && s < e) + p += 1 + CHARSETINSTSIZE; + else p += getoffset(p); + continue; + } + case IBehind: { + int n = p->i.aux; + if (n > s - o) goto fail; + s -= n; p++; + continue; + } + case ISpan: { + for (; s < e; s++) { + int c = (byte)*s; + if (!testchar((p+1)->buff, c)) break; + } + p += CHARSETINSTSIZE; + continue; + } + case IJmp: { + p += getoffset(p); + continue; + } + case IChoice: { + if (stack == stacklimit) + stack = doublestack(L, &stacklimit, ptop); + stack->p = p + getoffset(p); + stack->s = s; + stack->caplevel = captop; + stack++; + p += 2; + continue; + } + case ICall: { + if (stack == stacklimit) + stack = doublestack(L, &stacklimit, ptop); + stack->s = NULL; + stack->p = p + 2; /* save return address */ + stack++; + p += getoffset(p); + continue; + } + case ICommit: { + assert(stack > getstackbase(L, ptop) && (stack - 1)->s != NULL); + stack--; + p += getoffset(p); + continue; + } + case IPartialCommit: { + assert(stack > getstackbase(L, ptop) && (stack - 1)->s != NULL); + (stack - 1)->s = s; + (stack - 1)->caplevel = captop; + p += getoffset(p); + continue; + } + case IBackCommit: { + assert(stack > getstackbase(L, ptop) && (stack - 1)->s != NULL); + s = (--stack)->s; + captop = stack->caplevel; + p += getoffset(p); + continue; + } + case IFailTwice: + assert(stack > getstackbase(L, ptop)); + stack--; + /* go through */ + case IFail: + fail: { /* pattern failed: try to backtrack */ + do { /* remove pending calls */ + assert(stack > getstackbase(L, ptop)); + s = (--stack)->s; + } while (s == NULL); + if (ndyncap > 0) /* is there matchtime captures? */ + ndyncap -= removedyncap(L, capture, stack->caplevel, captop); + captop = stack->caplevel; + p = stack->p; + continue; + } + case ICloseRunTime: { + CapState cs; + int rem, res, n; + int fr = lua_gettop(L) + 1; /* stack index of first result */ + cs.s = o; cs.L = L; cs.ocap = capture; cs.ptop = ptop; + n = runtimecap(&cs, capture + captop, s, &rem); /* call function */ + captop -= n; /* remove nested captures */ + fr -= rem; /* 'rem' items were popped from Lua stack */ + res = resdyncaptures(L, fr, s - o, e - o); /* get result */ + if (res == -1) /* fail? */ + goto fail; + s = o + res; /* else update current position */ + n = lua_gettop(L) - fr + 1; /* number of new captures */ + ndyncap += n - rem; /* update number of dynamic captures */ + if (n > 0) { /* any new capture? */ + if ((captop += n + 2) >= capsize) { + capture = doublecap(L, capture, captop, ptop); + capsize = 2 * captop; + } + /* add new captures to 'capture' list */ + adddyncaptures(s, capture + captop - n - 2, n, fr); + } + p++; + continue; + } + case ICloseCapture: { + const char *s1 = s; + assert(captop > 0); + /* if possible, turn capture into a full capture */ + if (capture[captop - 1].siz == 0 && + s1 - capture[captop - 1].s < UCHAR_MAX) { + capture[captop - 1].siz = s1 - capture[captop - 1].s + 1; + p++; + continue; + } + else { + capture[captop].siz = 1; /* mark entry as closed */ + capture[captop].s = s; + goto pushcapture; + } + } + case IOpenCapture: + capture[captop].siz = 0; /* mark entry as open */ + capture[captop].s = s; + goto pushcapture; + case IFullCapture: + capture[captop].siz = getoff(p) + 1; /* save capture size */ + capture[captop].s = s - getoff(p); + /* goto pushcapture; */ + pushcapture: { + capture[captop].idx = p->i.key; + capture[captop].kind = getkind(p); + if (++captop >= capsize) { + capture = doublecap(L, capture, captop, ptop); + capsize = 2 * captop; + } + p++; + continue; + } + default: assert(0); return NULL; + } + } +} + +/* }====================================================== */ + + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lpvm.h b/dep/scintilla/scintilla-3.10.6/lua/src/lpvm.h new file mode 100644 index 00000000..757b9e13 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lpvm.h @@ -0,0 +1,58 @@ +/* +** $Id: lpvm.h,v 1.3 2014/02/21 13:06:41 roberto Exp $ +*/ + +#if !defined(lpvm_h) +#define lpvm_h + +#include "lpcap.h" + + +/* Virtual Machine's instructions */ +typedef enum Opcode { + IAny, /* if no char, fail */ + IChar, /* if char != aux, fail */ + ISet, /* if char not in buff, fail */ + ITestAny, /* in no char, jump to 'offset' */ + ITestChar, /* if char != aux, jump to 'offset' */ + ITestSet, /* if char not in buff, jump to 'offset' */ + ISpan, /* read a span of chars in buff */ + IBehind, /* walk back 'aux' characters (fail if not possible) */ + IRet, /* return from a rule */ + IEnd, /* end of pattern */ + IChoice, /* stack a choice; next fail will jump to 'offset' */ + IJmp, /* jump to 'offset' */ + ICall, /* call rule at 'offset' */ + IOpenCall, /* call rule number 'key' (must be closed to a ICall) */ + ICommit, /* pop choice and jump to 'offset' */ + IPartialCommit, /* update top choice to current position and jump */ + IBackCommit, /* "fails" but jump to its own 'offset' */ + IFailTwice, /* pop one choice and then fail */ + IFail, /* go back to saved state on choice and jump to saved offset */ + IGiveup, /* internal use */ + IFullCapture, /* complete capture of last 'off' chars */ + IOpenCapture, /* start a capture */ + ICloseCapture, + ICloseRunTime +} Opcode; + + + +typedef union Instruction { + struct Inst { + byte code; + byte aux; + short key; + } i; + int offset; + byte buff[1]; +} Instruction; + + +void printpatt (Instruction *p, int n); +const char *match (lua_State *L, const char *o, const char *s, const char *e, + Instruction *op, Capture *capture, int ptop); + + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lstate.c b/dep/scintilla/scintilla-3.10.6/lua/src/lstate.c new file mode 100644 index 00000000..9194ac34 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lstate.c @@ -0,0 +1,347 @@ +/* +** $Id: lstate.c,v 2.133 2015/11/13 12:16:51 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#define lstate_c +#define LUA_CORE + +#include "lprefix.h" + + +#include +#include + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#if !defined(LUAI_GCPAUSE) +#define LUAI_GCPAUSE 200 /* 200% */ +#endif + +#if !defined(LUAI_GCMUL) +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ +#endif + + +/* +** a macro to help the creation of a unique random seed when a state is +** created; the seed is used to randomize hashes. +*/ +#if !defined(luai_makeseed) +#include +#define luai_makeseed() cast(unsigned int, time(NULL)) +#endif + + + +/* +** thread state + extra space +*/ +typedef struct LX { + lu_byte extra_[LUA_EXTRASPACE]; + lua_State l; +} LX; + + +/* +** Main thread combines a thread state and the global state +*/ +typedef struct LG { + LX l; + global_State g; +} LG; + + + +#define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) + + +/* +** Compute an initial seed as random as possible. Rely on Address Space +** Layout Randomization (if present) to increase randomness.. +*/ +#define addbuff(b,p,e) \ + { size_t t = cast(size_t, e); \ + memcpy(b + p, &t, sizeof(t)); p += sizeof(t); } + +static unsigned int makeseed (lua_State *L) { + char buff[4 * sizeof(size_t)]; + unsigned int h = luai_makeseed(); + int p = 0; + addbuff(buff, p, L); /* heap variable */ + addbuff(buff, p, &h); /* local variable */ + addbuff(buff, p, luaO_nilobject); /* global variable */ + addbuff(buff, p, &lua_newstate); /* public function */ + lua_assert(p == sizeof(buff)); + return luaS_hash(buff, p, h); +} + + +/* +** set GCdebt to a new value keeping the value (totalbytes + GCdebt) +** invariant (and avoiding underflows in 'totalbytes') +*/ +void luaE_setdebt (global_State *g, l_mem debt) { + l_mem tb = gettotalbytes(g); + lua_assert(tb > 0); + if (debt < tb - MAX_LMEM) + debt = tb - MAX_LMEM; /* will make 'totalbytes == MAX_LMEM' */ + g->totalbytes = tb - debt; + g->GCdebt = debt; +} + + +CallInfo *luaE_extendCI (lua_State *L) { + CallInfo *ci = luaM_new(L, CallInfo); + lua_assert(L->ci->next == NULL); + L->ci->next = ci; + ci->previous = L->ci; + ci->next = NULL; + L->nci++; + return ci; +} + + +/* +** free all CallInfo structures not in use by a thread +*/ +void luaE_freeCI (lua_State *L) { + CallInfo *ci = L->ci; + CallInfo *next = ci->next; + ci->next = NULL; + while ((ci = next) != NULL) { + next = ci->next; + luaM_free(L, ci); + L->nci--; + } +} + + +/* +** free half of the CallInfo structures not in use by a thread +*/ +void luaE_shrinkCI (lua_State *L) { + CallInfo *ci = L->ci; + CallInfo *next2; /* next's next */ + /* while there are two nexts */ + while (ci->next != NULL && (next2 = ci->next->next) != NULL) { + luaM_free(L, ci->next); /* free next */ + L->nci--; + ci->next = next2; /* remove 'next' from the list */ + next2->previous = ci; + ci = next2; /* keep next's next */ + } +} + + +static void stack_init (lua_State *L1, lua_State *L) { + int i; CallInfo *ci; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, TValue); + L1->stacksize = BASIC_STACK_SIZE; + for (i = 0; i < BASIC_STACK_SIZE; i++) + setnilvalue(L1->stack + i); /* erase new stack */ + L1->top = L1->stack; + L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; + /* initialize first ci */ + ci = &L1->base_ci; + ci->next = ci->previous = NULL; + ci->callstatus = 0; + ci->func = L1->top; + setnilvalue(L1->top++); /* 'function' entry for this 'ci' */ + ci->top = L1->top + LUA_MINSTACK; + L1->ci = ci; +} + + +static void freestack (lua_State *L) { + if (L->stack == NULL) + return; /* stack not completely built yet */ + L->ci = &L->base_ci; /* free the entire 'ci' list */ + luaE_freeCI(L); + lua_assert(L->nci == 0); + luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ +} + + +/* +** Create registry table and its predefined values +*/ +static void init_registry (lua_State *L, global_State *g) { + TValue temp; + /* create registry */ + Table *registry = luaH_new(L); + sethvalue(L, &g->l_registry, registry); + luaH_resize(L, registry, LUA_RIDX_LAST, 0); + /* registry[LUA_RIDX_MAINTHREAD] = L */ + setthvalue(L, &temp, L); /* temp = L */ + luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); + /* registry[LUA_RIDX_GLOBALS] = table of globals */ + sethvalue(L, &temp, luaH_new(L)); /* temp = new table (global table) */ + luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp); +} + + +/* +** open parts of the state that may cause memory-allocation errors. +** ('g->version' != NULL flags that the state was completely build) +*/ +static void f_luaopen (lua_State *L, void *ud) { + global_State *g = G(L); + UNUSED(ud); + stack_init(L, L); /* init stack */ + init_registry(L, g); + luaS_init(L); + luaT_init(L); + luaX_init(L); + g->gcrunning = 1; /* allow gc */ + g->version = lua_version(NULL); + luai_userstateopen(L); +} + + +/* +** preinitialize a thread with consistent values without allocating +** any memory (to avoid errors) +*/ +static void preinit_thread (lua_State *L, global_State *g) { + G(L) = g; + L->stack = NULL; + L->ci = NULL; + L->nci = 0; + L->stacksize = 0; + L->twups = L; /* thread has no upvalues */ + L->errorJmp = NULL; + L->nCcalls = 0; + L->hook = NULL; + L->hookmask = 0; + L->basehookcount = 0; + L->allowhook = 1; + resethookcount(L); + L->openupval = NULL; + L->nny = 1; + L->status = LUA_OK; + L->errfunc = 0; +} + + +static void close_state (lua_State *L) { + global_State *g = G(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_freeallobjects(L); /* collect all objects */ + if (g->version) /* closing a fully built state? */ + luai_userstateclose(L); + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); + freestack(L); + lua_assert(gettotalbytes(g) == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ +} + + +LUA_API lua_State *lua_newthread (lua_State *L) { + global_State *g = G(L); + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + /* create new thread */ + L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; + L1->marked = luaC_white(g); + L1->tt = LUA_TTHREAD; + /* link it on list 'allgc' */ + L1->next = g->allgc; + g->allgc = obj2gco(L1); + /* anchor it on L stack */ + setthvalue(L, L->top, L1); + api_incr_top(L); + preinit_thread(L1, g); + L1->hookmask = L->hookmask; + L1->basehookcount = L->basehookcount; + L1->hook = L->hook; + resethookcount(L1); + /* initialize L1 extra space */ + memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread), + LUA_EXTRASPACE); + luai_userstatethread(L, L1); + stack_init(L1, L); /* init stack */ + lua_unlock(L); + return L1; +} + + +void luaE_freethread (lua_State *L, lua_State *L1) { + LX *l = fromstate(L1); + luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + lua_assert(L1->openupval == NULL); + luai_userstatefree(L, L1); + freestack(L1); + luaM_free(L, l); +} + + +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; + global_State *g; + LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG))); + if (l == NULL) return NULL; + L = &l->l.l; + g = &l->g; + L->next = NULL; + L->tt = LUA_TTHREAD; + g->currentwhite = bitmask(WHITE0BIT); + L->marked = luaC_white(g); + preinit_thread(L, g); + g->frealloc = f; + g->ud = ud; + g->mainthread = L; + g->seed = makeseed(L); + g->gcrunning = 0; /* no GC while building state */ + g->GCestimate = 0; + g->strt.size = g->strt.nuse = 0; + g->strt.hash = NULL; + setnilvalue(&g->l_registry); + g->panic = NULL; + g->version = NULL; + g->gcstate = GCSpause; + g->gckind = KGC_NORMAL; + g->allgc = g->finobj = g->tobefnz = g->fixedgc = NULL; + g->sweepgc = NULL; + g->gray = g->grayagain = NULL; + g->weak = g->ephemeron = g->allweak = NULL; + g->twups = NULL; + g->totalbytes = sizeof(LG); + g->GCdebt = 0; + g->gcfinnum = 0; + g->gcpause = LUAI_GCPAUSE; + g->gcstepmul = LUAI_GCMUL; + for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { + /* memory allocation error: free partial state */ + close_state(L); + L = NULL; + } + return L; +} + + +LUA_API void lua_close (lua_State *L) { + L = G(L)->mainthread; /* only the main thread can be closed */ + lua_lock(L); + close_state(L); +} + + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lstate.h b/dep/scintilla/scintilla-3.10.6/lua/src/lstate.h new file mode 100644 index 00000000..a469466c --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lstate.h @@ -0,0 +1,235 @@ +/* +** $Id: lstate.h,v 2.133 2016/12/22 13:08:50 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + +/* + +** Some notes about garbage-collected objects: All objects in Lua must +** be kept somehow accessible until being freed, so all objects always +** belong to one (and only one) of these lists, using field 'next' of +** the 'CommonHeader' for the link: +** +** 'allgc': all objects not marked for finalization; +** 'finobj': all objects marked for finalization; +** 'tobefnz': all objects ready to be finalized; +** 'fixedgc': all objects that are not to be collected (currently +** only small strings, such as reserved words). + +*/ + + +struct lua_longjmp; /* defined in ldo.c */ + + +/* +** Atomic type (relative to signals) to better ensure that 'lua_sethook' +** is thread safe +*/ +#if !defined(l_signalT) +#include +#define l_signalT sig_atomic_t +#endif + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + +/* kinds of Garbage Collection */ +#define KGC_NORMAL 0 +#define KGC_EMERGENCY 1 /* gc was forced by an allocation failure */ + + +typedef struct stringtable { + TString **hash; + int nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** Information about a call. +** When a thread yields, 'func' is adjusted to pretend that the +** top function has only the yielded values in its stack; in that +** case, the actual 'func' value is saved in field 'extra'. +** When a function calls another with a continuation, 'extra' keeps +** the function index so that, in case of errors, the continuation +** function can be called with the correct top. +*/ +typedef struct CallInfo { + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + struct CallInfo *previous, *next; /* dynamic call link */ + union { + struct { /* only for Lua functions */ + StkId base; /* base for this function */ + const Instruction *savedpc; + } l; + struct { /* only for C functions */ + lua_KFunction k; /* continuation in case of yields */ + ptrdiff_t old_errfunc; + lua_KContext ctx; /* context info. in case of yields */ + } c; + } u; + ptrdiff_t extra; + short nresults; /* expected number of results from this function */ + unsigned short callstatus; +} CallInfo; + + +/* +** Bits in CallInfo status +*/ +#define CIST_OAH (1<<0) /* original value of 'allowhook' */ +#define CIST_LUA (1<<1) /* call is running a Lua function */ +#define CIST_HOOKED (1<<2) /* call is running a debug hook */ +#define CIST_FRESH (1<<3) /* call is running on a fresh invocation + of luaV_execute */ +#define CIST_YPCALL (1<<4) /* call is a yieldable protected call */ +#define CIST_TAIL (1<<5) /* call was tail called */ +#define CIST_HOOKYIELD (1<<6) /* last hook called yielded */ +#define CIST_LEQ (1<<7) /* using __lt for __le */ +#define CIST_FIN (1<<8) /* call is running a finalizer */ + +#define isLua(ci) ((ci)->callstatus & CIST_LUA) + +/* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */ +#define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v)) +#define getoah(st) ((st) & CIST_OAH) + + +/* +** 'global state', shared by all threads of this state +*/ +typedef struct global_State { + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to 'frealloc' */ + l_mem totalbytes; /* number of bytes currently allocated - GCdebt */ + l_mem GCdebt; /* bytes allocated not yet compensated by the collector */ + lu_mem GCmemtrav; /* memory traversed by the GC */ + lu_mem GCestimate; /* an estimate of the non-garbage memory in use */ + stringtable strt; /* hash table for strings */ + TValue l_registry; + unsigned int seed; /* randomized seed for hashes */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + lu_byte gckind; /* kind of GC running */ + lu_byte gcrunning; /* true if GC is running */ + GCObject *allgc; /* list of all collectable objects */ + GCObject **sweepgc; /* current position of sweep in list */ + GCObject *finobj; /* list of collectable objects with finalizers */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of tables with weak values */ + GCObject *ephemeron; /* list of ephemeron tables (weak keys) */ + GCObject *allweak; /* list of all-weak tables */ + GCObject *tobefnz; /* list of userdata to be GC */ + GCObject *fixedgc; /* list of objects not to be collected */ + struct lua_State *twups; /* list of threads with open upvalues */ + unsigned int gcfinnum; /* number of finalizers to call in each GC step */ + int gcpause; /* size of pause between successive GCs */ + int gcstepmul; /* GC 'granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + struct lua_State *mainthread; + const lua_Number *version; /* pointer to version number */ + TString *memerrmsg; /* memory-error message */ + TString *tmname[TM_N]; /* array with tag-method names */ + struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */ + TString *strcache[STRCACHE_N][STRCACHE_M]; /* cache for strings in API */ +} global_State; + + +/* +** 'per thread' state +*/ +struct lua_State { + CommonHeader; + unsigned short nci; /* number of items in 'ci' list */ + lu_byte status; + StkId top; /* first free slot in the stack */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *oldpc; /* last pc traced */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + UpVal *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_State *twups; /* list of threads with open upvalues */ + struct lua_longjmp *errorJmp; /* current error recover point */ + CallInfo base_ci; /* CallInfo for first level (C calling Lua) */ + volatile lua_Hook hook; + ptrdiff_t errfunc; /* current error handling function (stack index) */ + int stacksize; + int basehookcount; + int hookcount; + unsigned short nny; /* number of non-yieldable calls in stack */ + unsigned short nCcalls; /* number of nested C calls */ + l_signalT hookmask; + lu_byte allowhook; +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects (only for conversions) +*/ +union GCUnion { + GCObject gc; /* common header */ + struct TString ts; + struct Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct lua_State th; /* thread */ +}; + + +#define cast_u(o) cast(union GCUnion *, (o)) + +/* macros to convert a GCObject into a specific value */ +#define gco2ts(o) \ + check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts)) +#define gco2u(o) check_exp((o)->tt == LUA_TUSERDATA, &((cast_u(o))->u)) +#define gco2lcl(o) check_exp((o)->tt == LUA_TLCL, &((cast_u(o))->cl.l)) +#define gco2ccl(o) check_exp((o)->tt == LUA_TCCL, &((cast_u(o))->cl.c)) +#define gco2cl(o) \ + check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl)) +#define gco2t(o) check_exp((o)->tt == LUA_TTABLE, &((cast_u(o))->h)) +#define gco2p(o) check_exp((o)->tt == LUA_TPROTO, &((cast_u(o))->p)) +#define gco2th(o) check_exp((o)->tt == LUA_TTHREAD, &((cast_u(o))->th)) + + +/* macro to convert a Lua object into a GCObject */ +#define obj2gco(v) \ + check_exp(novariant((v)->tt) < LUA_TDEADKEY, (&(cast_u(v)->gc))) + + +/* actual number of total bytes allocated */ +#define gettotalbytes(g) cast(lu_mem, (g)->totalbytes + (g)->GCdebt) + +LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); +LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L); +LUAI_FUNC void luaE_freeCI (lua_State *L); +LUAI_FUNC void luaE_shrinkCI (lua_State *L); + + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lstring.c b/dep/scintilla/scintilla-3.10.6/lua/src/lstring.c new file mode 100644 index 00000000..9351766f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lstring.c @@ -0,0 +1,248 @@ +/* +** $Id: lstring.c,v 2.56 2015/11/23 11:32:51 roberto Exp $ +** String table (keeps all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#define lstring_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" + + +#define MEMERRMSG "not enough memory" + + +/* +** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to +** compute its hash +*/ +#if !defined(LUAI_HASHLIMIT) +#define LUAI_HASHLIMIT 5 +#endif + + +/* +** equality for long strings +*/ +int luaS_eqlngstr (TString *a, TString *b) { + size_t len = a->u.lnglen; + lua_assert(a->tt == LUA_TLNGSTR && b->tt == LUA_TLNGSTR); + return (a == b) || /* same instance or... */ + ((len == b->u.lnglen) && /* equal length and ... */ + (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */ +} + + +unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { + unsigned int h = seed ^ cast(unsigned int, l); + size_t step = (l >> LUAI_HASHLIMIT) + 1; + for (; l >= step; l -= step) + h ^= ((h<<5) + (h>>2) + cast_byte(str[l - 1])); + return h; +} + + +unsigned int luaS_hashlongstr (TString *ts) { + lua_assert(ts->tt == LUA_TLNGSTR); + if (ts->extra == 0) { /* no hash? */ + ts->hash = luaS_hash(getstr(ts), ts->u.lnglen, ts->hash); + ts->extra = 1; /* now it has its hash */ + } + return ts->hash; +} + + +/* +** resizes the string table +*/ +void luaS_resize (lua_State *L, int newsize) { + int i; + stringtable *tb = &G(L)->strt; + if (newsize > tb->size) { /* grow table if needed */ + luaM_reallocvector(L, tb->hash, tb->size, newsize, TString *); + for (i = tb->size; i < newsize; i++) + tb->hash[i] = NULL; + } + for (i = 0; i < tb->size; i++) { /* rehash */ + TString *p = tb->hash[i]; + tb->hash[i] = NULL; + while (p) { /* for each node in the list */ + TString *hnext = p->u.hnext; /* save next */ + unsigned int h = lmod(p->hash, newsize); /* new position */ + p->u.hnext = tb->hash[h]; /* chain it */ + tb->hash[h] = p; + p = hnext; + } + } + if (newsize < tb->size) { /* shrink table if needed */ + /* vanishing slice should be empty */ + lua_assert(tb->hash[newsize] == NULL && tb->hash[tb->size - 1] == NULL); + luaM_reallocvector(L, tb->hash, tb->size, newsize, TString *); + } + tb->size = newsize; +} + + +/* +** Clear API string cache. (Entries cannot be empty, so fill them with +** a non-collectable string.) +*/ +void luaS_clearcache (global_State *g) { + int i, j; + for (i = 0; i < STRCACHE_N; i++) + for (j = 0; j < STRCACHE_M; j++) { + if (iswhite(g->strcache[i][j])) /* will entry be collected? */ + g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */ + } +} + + +/* +** Initialize the string table and the string cache +*/ +void luaS_init (lua_State *L) { + global_State *g = G(L); + int i, j; + luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + /* pre-create memory-error message */ + g->memerrmsg = luaS_newliteral(L, MEMERRMSG); + luaC_fix(L, obj2gco(g->memerrmsg)); /* it should never be collected */ + for (i = 0; i < STRCACHE_N; i++) /* fill cache with valid strings */ + for (j = 0; j < STRCACHE_M; j++) + g->strcache[i][j] = g->memerrmsg; +} + + + +/* +** creates a new string object +*/ +static TString *createstrobj (lua_State *L, size_t l, int tag, unsigned int h) { + TString *ts; + GCObject *o; + size_t totalsize; /* total size of TString object */ + totalsize = sizelstring(l); + o = luaC_newobj(L, tag, totalsize); + ts = gco2ts(o); + ts->hash = h; + ts->extra = 0; + getstr(ts)[l] = '\0'; /* ending 0 */ + return ts; +} + + +TString *luaS_createlngstrobj (lua_State *L, size_t l) { + TString *ts = createstrobj(L, l, LUA_TLNGSTR, G(L)->seed); + ts->u.lnglen = l; + return ts; +} + + +void luaS_remove (lua_State *L, TString *ts) { + stringtable *tb = &G(L)->strt; + TString **p = &tb->hash[lmod(ts->hash, tb->size)]; + while (*p != ts) /* find previous element */ + p = &(*p)->u.hnext; + *p = (*p)->u.hnext; /* remove element from its list */ + tb->nuse--; +} + + +/* +** checks whether short string exists and reuses it or creates a new one +*/ +static TString *internshrstr (lua_State *L, const char *str, size_t l) { + TString *ts; + global_State *g = G(L); + unsigned int h = luaS_hash(str, l, g->seed); + TString **list = &g->strt.hash[lmod(h, g->strt.size)]; + lua_assert(str != NULL); /* otherwise 'memcmp'/'memcpy' are undefined */ + for (ts = *list; ts != NULL; ts = ts->u.hnext) { + if (l == ts->shrlen && + (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) { + /* found! */ + if (isdead(g, ts)) /* dead (but not collected yet)? */ + changewhite(ts); /* resurrect it */ + return ts; + } + } + if (g->strt.nuse >= g->strt.size && g->strt.size <= MAX_INT/2) { + luaS_resize(L, g->strt.size * 2); + list = &g->strt.hash[lmod(h, g->strt.size)]; /* recompute with new size */ + } + ts = createstrobj(L, l, LUA_TSHRSTR, h); + memcpy(getstr(ts), str, l * sizeof(char)); + ts->shrlen = cast_byte(l); + ts->u.hnext = *list; + *list = ts; + g->strt.nuse++; + return ts; +} + + +/* +** new string (with explicit length) +*/ +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + if (l <= LUAI_MAXSHORTLEN) /* short string? */ + return internshrstr(L, str, l); + else { + TString *ts; + if (l >= (MAX_SIZE - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + ts = luaS_createlngstrobj(L, l); + memcpy(getstr(ts), str, l * sizeof(char)); + return ts; + } +} + + +/* +** Create or reuse a zero-terminated string, first checking in the +** cache (using the string address as a key). The cache can contain +** only zero-terminated strings, so it is safe to use 'strcmp' to +** check hits. +*/ +TString *luaS_new (lua_State *L, const char *str) { + unsigned int i = point2uint(str) % STRCACHE_N; /* hash */ + int j; + TString **p = G(L)->strcache[i]; + for (j = 0; j < STRCACHE_M; j++) { + if (strcmp(str, getstr(p[j])) == 0) /* hit? */ + return p[j]; /* that is it */ + } + /* normal route */ + for (j = STRCACHE_M - 1; j > 0; j--) + p[j] = p[j - 1]; /* move out last element */ + /* new element is first in the list */ + p[0] = luaS_newlstr(L, str, strlen(str)); + return p[0]; +} + + +Udata *luaS_newudata (lua_State *L, size_t s) { + Udata *u; + GCObject *o; + if (s > MAX_SIZE - sizeof(Udata)) + luaM_toobig(L); + o = luaC_newobj(L, LUA_TUSERDATA, sizeludata(s)); + u = gco2u(o); + u->len = s; + u->metatable = NULL; + setuservalue(L, u, luaO_nilobject); + return u; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lstring.h b/dep/scintilla/scintilla-3.10.6/lua/src/lstring.h new file mode 100644 index 00000000..27efd207 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lstring.h @@ -0,0 +1,49 @@ +/* +** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) + +#define sizeludata(l) (sizeof(union UUdata) + (l)) +#define sizeudata(u) sizeludata((u)->len) + +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + + +/* +** test whether a string is a reserved word +*/ +#define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) + + +/* +** equality for short strings, which are always internalized +*/ +#define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) + + +LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); +LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); +LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC void luaS_clearcache (global_State *g); +LUAI_FUNC void luaS_init (lua_State *L); +LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); +LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); +LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lstrlib.c b/dep/scintilla/scintilla-3.10.6/lua/src/lstrlib.c new file mode 100644 index 00000000..c7aa755f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lstrlib.c @@ -0,0 +1,1584 @@ +/* +** $Id: lstrlib.c,v 1.254 2016/12/22 13:08:50 roberto Exp $ +** Standard library for string operations and pattern-matching +** See Copyright Notice in lua.h +*/ + +#define lstrlib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* +** maximum number of captures that a pattern can do during +** pattern-matching. This limit is arbitrary, but must fit in +** an unsigned char. +*/ +#if !defined(LUA_MAXCAPTURES) +#define LUA_MAXCAPTURES 32 +#endif + + +/* macro to 'unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + + +/* +** Some sizes are better limited to fit in 'int', but must also fit in +** 'size_t'. (We assume that 'lua_Integer' cannot be smaller than 'int'.) +*/ +#define MAX_SIZET ((size_t)(~(size_t)0)) + +#define MAXSIZE \ + (sizeof(size_t) < sizeof(int) ? MAX_SIZET : (size_t)(INT_MAX)) + + + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushinteger(L, (lua_Integer)l); + return 1; +} + + +/* translate a relative string position: negative means back from end */ +static lua_Integer posrelat (lua_Integer pos, size_t len) { + if (pos >= 0) return pos; + else if (0u - (size_t)pos > len) return 0; + else return (lua_Integer)len + pos + 1; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + lua_Integer start = posrelat(luaL_checkinteger(L, 2), l); + lua_Integer end = posrelat(luaL_optinteger(L, 3, -1), l); + if (start < 1) start = 1; + if (end > (lua_Integer)l) end = l; + if (start <= end) + lua_pushlstring(L, s + start - 1, (size_t)(end - start) + 1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_reverse (lua_State *L) { + size_t l, i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + char *p = luaL_buffinitsize(L, &b, l); + for (i = 0; i < l; i++) + p[i] = s[l - i - 1]; + luaL_pushresultsize(&b, l); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + char *p = luaL_buffinitsize(L, &b, l); + for (i=0; i MAXSIZE / n) /* may overflow? */ + return luaL_error(L, "resulting string too large"); + else { + size_t totallen = (size_t)n * l + (size_t)(n - 1) * lsep; + luaL_Buffer b; + char *p = luaL_buffinitsize(L, &b, totallen); + while (n-- > 1) { /* first n-1 copies (followed by separator) */ + memcpy(p, s, l * sizeof(char)); p += l; + if (lsep > 0) { /* empty 'memcpy' is not that cheap */ + memcpy(p, sep, lsep * sizeof(char)); + p += lsep; + } + } + memcpy(p, s, l * sizeof(char)); /* last copy (not followed by separator) */ + luaL_pushresultsize(&b, totallen); + } + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + lua_Integer posi = posrelat(luaL_optinteger(L, 2, 1), l); + lua_Integer pose = posrelat(luaL_optinteger(L, 3, posi), l); + int n, i; + if (posi < 1) posi = 1; + if (pose > (lua_Integer)l) pose = l; + if (posi > pose) return 0; /* empty interval; return no values */ + if (pose - posi >= INT_MAX) /* arithmetic overflow? */ + return luaL_error(L, "string slice too long"); + n = (int)(pose - posi) + 1; + luaL_checkstack(L, n, "string slice too long"); + for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index %%%d", l + 1); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *classend (MatchState *ms, const char *p) { + switch (*p++) { + case L_ESC: { + if (p == ms->p_end) + luaL_error(ms->L, "malformed pattern (ends with '%%')"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a ']' */ + if (p == ms->p_end) + luaL_error(ms->L, "malformed pattern (missing ']')"); + if (*(p++) == L_ESC && p < ms->p_end) + p++; /* skip escapes (e.g. '%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'g' : res = isgraph(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; /* deprecated option */ + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the '^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int singlematch (MatchState *ms, const char *s, const char *p, + const char *ep) { + if (s >= ms->src_end) + return 0; + else { + int c = uchar(*s); + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } + } +} + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (p >= ms->p_end - 1) + luaL_error(ms->L, "malformed pattern (missing arguments to '%%b')"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + ptrdiff_t i = 0; /* counts maximum expand for item */ + while (singlematch(ms, s + i, p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (singlematch(ms, s, p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + if (ms->matchdepth-- == 0) + luaL_error(ms->L, "pattern too complex"); + init: /* using goto's to optimize tail recursion */ + if (p != ms->p_end) { /* end of pattern? */ + switch (*p) { + case '(': { /* start capture */ + if (*(p + 1) == ')') /* position capture? */ + s = start_capture(ms, s, p + 2, CAP_POSITION); + else + s = start_capture(ms, s, p + 1, CAP_UNFINISHED); + break; + } + case ')': { /* end capture */ + s = end_capture(ms, s, p + 1); + break; + } + case '$': { + if ((p + 1) != ms->p_end) /* is the '$' the last char in pattern? */ + goto dflt; /* no; go to default */ + s = (s == ms->src_end) ? s : NULL; /* check end of string */ + break; + } + case L_ESC: { /* escaped sequences not in the format class[*+?-]? */ + switch (*(p + 1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p + 2); + if (s != NULL) { + p += 4; goto init; /* return match(ms, s, p + 4); */ + } /* else fail (s == NULL) */ + break; + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing '[' after '%%f' in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s - 1); + if (!matchbracketclass(uchar(previous), p, ep - 1) && + matchbracketclass(uchar(*s), p, ep - 1)) { + p = ep; goto init; /* return match(ms, s, ep); */ + } + s = NULL; /* match failed */ + break; + } + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + case '8': case '9': { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p + 1))); + if (s != NULL) { + p += 2; goto init; /* return match(ms, s, p + 2) */ + } + break; + } + default: goto dflt; + } + break; + } + default: dflt: { /* pattern class plus optional suffix */ + const char *ep = classend(ms, p); /* points to optional suffix */ + /* does not match at least once? */ + if (!singlematch(ms, s, p, ep)) { + if (*ep == '*' || *ep == '?' || *ep == '-') { /* accept empty? */ + p = ep + 1; goto init; /* return match(ms, s, ep + 1); */ + } + else /* '+' or no suffix */ + s = NULL; /* fail */ + } + else { /* matched once */ + switch (*ep) { /* handle optional suffix */ + case '?': { /* optional */ + const char *res; + if ((res = match(ms, s + 1, ep + 1)) != NULL) + s = res; + else { + p = ep + 1; goto init; /* else return match(ms, s, ep + 1); */ + } + break; + } + case '+': /* 1 or more repetitions */ + s++; /* 1 match already done */ + /* FALLTHROUGH */ + case '*': /* 0 or more repetitions */ + s = max_expand(ms, s, p, ep); + break; + case '-': /* 0 or more repetitions (minimum) */ + s = min_expand(ms, s, p, ep); + break; + default: /* no suffix */ + s++; p = ep; goto init; /* return match(ms, s + 1, ep); */ + } + } + break; + } + } + } + ms->matchdepth++; + return s; +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative 'l1' */ + else { + const char *init; /* to search for a '*s2' inside 's1' */ + l2--; /* 1st char will be checked by 'memchr' */ + l1 = l1-l2; /* 's2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct 'l1' and 's1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, e - s); /* add whole match */ + else + luaL_error(ms->L, "invalid capture index %%%d", i + 1); + } + else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, (ms->capture[i].init - ms->src_init) + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); + } +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + + +/* check whether pattern has no special characters */ +static int nospecials (const char *p, size_t l) { + size_t upto = 0; + do { + if (strpbrk(p + upto, SPECIALS)) + return 0; /* pattern has a special character */ + upto += strlen(p + upto) + 1; /* may have more after \0 */ + } while (upto <= l); + return 1; /* no special chars found */ +} + + +static void prepstate (MatchState *ms, lua_State *L, + const char *s, size_t ls, const char *p, size_t lp) { + ms->L = L; + ms->matchdepth = MAXCCALLS; + ms->src_init = s; + ms->src_end = s + ls; + ms->p_end = p + lp; +} + + +static void reprepstate (MatchState *ms) { + ms->level = 0; + lua_assert(ms->matchdepth == MAXCCALLS); +} + + +static int str_find_aux (lua_State *L, int find) { + size_t ls, lp; + const char *s = luaL_checklstring(L, 1, &ls); + const char *p = luaL_checklstring(L, 2, &lp); + lua_Integer init = posrelat(luaL_optinteger(L, 3, 1), ls); + if (init < 1) init = 1; + else if (init > (lua_Integer)ls + 1) { /* start after string's end? */ + lua_pushnil(L); /* cannot find anything */ + return 1; + } + /* explicit request or no special characters? */ + if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) { + /* do a plain search */ + const char *s2 = lmemfind(s + init - 1, ls - (size_t)init + 1, p, lp); + if (s2) { + lua_pushinteger(L, (s2 - s) + 1); + lua_pushinteger(L, (s2 - s) + lp); + return 2; + } + } + else { + MatchState ms; + const char *s1 = s + init - 1; + int anchor = (*p == '^'); + if (anchor) { + p++; lp--; /* skip anchor character */ + } + prepstate(&ms, L, s, ls, p, lp); + do { + const char *res; + reprepstate(&ms); + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, (s1 - s) + 1); /* start */ + lua_pushinteger(L, res - s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + else + return push_captures(&ms, s1, res); + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + + +static int str_find (lua_State *L) { + return str_find_aux(L, 1); +} + + +static int str_match (lua_State *L) { + return str_find_aux(L, 0); +} + + +/* state for 'gmatch' */ +typedef struct GMatchState { + const char *src; /* current position */ + const char *p; /* pattern */ + const char *lastmatch; /* end of last match */ + MatchState ms; /* match state */ +} GMatchState; + + +static int gmatch_aux (lua_State *L) { + GMatchState *gm = (GMatchState *)lua_touserdata(L, lua_upvalueindex(3)); + const char *src; + gm->ms.L = L; + for (src = gm->src; src <= gm->ms.src_end; src++) { + const char *e; + reprepstate(&gm->ms); + if ((e = match(&gm->ms, src, gm->p)) != NULL && e != gm->lastmatch) { + gm->src = gm->lastmatch = e; + return push_captures(&gm->ms, src, e); + } + } + return 0; /* not found */ +} + + +static int gmatch (lua_State *L) { + size_t ls, lp; + const char *s = luaL_checklstring(L, 1, &ls); + const char *p = luaL_checklstring(L, 2, &lp); + GMatchState *gm; + lua_settop(L, 2); /* keep them on closure to avoid being collected */ + gm = (GMatchState *)lua_newuserdata(L, sizeof(GMatchState)); + prepstate(&gm->ms, L, s, ls, p, lp); + gm->src = s; gm->p = p; gm->lastmatch = NULL; + lua_pushcclosure(L, gmatch_aux, 3); + return 1; +} + + +static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + size_t l, i; + lua_State *L = ms->L; + const char *news = lua_tolstring(L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) + luaL_addchar(b, news[i]); + else { + i++; /* skip ESC */ + if (!isdigit(uchar(news[i]))) { + if (news[i] != L_ESC) + luaL_error(L, "invalid use of '%c' in replacement string", L_ESC); + luaL_addchar(b, news[i]); + } + else if (news[i] == '0') + luaL_addlstring(b, s, e - s); + else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_tolstring(L, -1, NULL); /* if number, convert it to string */ + lua_remove(L, -2); /* remove original value */ + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + + +static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e, int tr) { + lua_State *L = ms->L; + switch (tr) { + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + default: { /* LUA_TNUMBER or LUA_TSTRING */ + add_s(ms, b, s, e); + return; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, e - s); /* keep original text */ + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_addvalue(b); /* add result to accumulator */ +} + + +static int str_gsub (lua_State *L) { + size_t srcl, lp; + const char *src = luaL_checklstring(L, 1, &srcl); /* subject */ + const char *p = luaL_checklstring(L, 2, &lp); /* pattern */ + const char *lastmatch = NULL; /* end of last match */ + int tr = lua_type(L, 3); /* replacement type */ + lua_Integer max_s = luaL_optinteger(L, 4, srcl + 1); /* max replacements */ + int anchor = (*p == '^'); + lua_Integer n = 0; /* replacement count */ + MatchState ms; + luaL_Buffer b; + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, + "string/function/table expected"); + luaL_buffinit(L, &b); + if (anchor) { + p++; lp--; /* skip anchor character */ + } + prepstate(&ms, L, src, srcl, p, lp); + while (n < max_s) { + const char *e; + reprepstate(&ms); /* (re)prepare state for new match */ + if ((e = match(&ms, src, p)) != NULL && e != lastmatch) { /* match? */ + n++; + add_value(&ms, &b, src, e, tr); /* add replacement to buffer */ + src = lastmatch = e; + } + else if (src < ms.src_end) /* otherwise, skip one character */ + luaL_addchar(&b, *src++); + else break; /* end of subject */ + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** STRING FORMAT +** ======================================================= +*/ + +#if !defined(lua_number2strx) /* { */ + +/* +** Hexadecimal floating-point formatter +*/ + +#include + +#define SIZELENMOD (sizeof(LUA_NUMBER_FRMLEN)/sizeof(char)) + + +/* +** Number of bits that goes into the first digit. It can be any value +** between 1 and 4; the following definition tries to align the number +** to nibble boundaries by making what is left after that first digit a +** multiple of 4. +*/ +#define L_NBFD ((l_mathlim(MANT_DIG) - 1)%4 + 1) + + +/* +** Add integer part of 'x' to buffer and return new 'x' +*/ +static lua_Number adddigit (char *buff, int n, lua_Number x) { + lua_Number dd = l_mathop(floor)(x); /* get integer part from 'x' */ + int d = (int)dd; + buff[n] = (d < 10 ? d + '0' : d - 10 + 'a'); /* add to buffer */ + return x - dd; /* return what is left */ +} + + +static int num2straux (char *buff, int sz, lua_Number x) { + /* if 'inf' or 'NaN', format it like '%g' */ + if (x != x || x == (lua_Number)HUGE_VAL || x == -(lua_Number)HUGE_VAL) + return l_sprintf(buff, sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)x); + else if (x == 0) { /* can be -0... */ + /* create "0" or "-0" followed by exponent */ + return l_sprintf(buff, sz, LUA_NUMBER_FMT "x0p+0", (LUAI_UACNUMBER)x); + } + else { + int e; + lua_Number m = l_mathop(frexp)(x, &e); /* 'x' fraction and exponent */ + int n = 0; /* character count */ + if (m < 0) { /* is number negative? */ + buff[n++] = '-'; /* add signal */ + m = -m; /* make it positive */ + } + buff[n++] = '0'; buff[n++] = 'x'; /* add "0x" */ + m = adddigit(buff, n++, m * (1 << L_NBFD)); /* add first digit */ + e -= L_NBFD; /* this digit goes before the radix point */ + if (m > 0) { /* more digits? */ + buff[n++] = lua_getlocaledecpoint(); /* add radix point */ + do { /* add as many digits as needed */ + m = adddigit(buff, n++, m * 16); + } while (m > 0); + } + n += l_sprintf(buff + n, sz - n, "p%+d", e); /* add exponent */ + lua_assert(n < sz); + return n; + } +} + + +static int lua_number2strx (lua_State *L, char *buff, int sz, + const char *fmt, lua_Number x) { + int n = num2straux(buff, sz, x); + if (fmt[SIZELENMOD] == 'A') { + int i; + for (i = 0; i < n; i++) + buff[i] = toupper(uchar(buff[i])); + } + else if (fmt[SIZELENMOD] != 'a') + luaL_error(L, "modifiers for format '%%a'/'%%A' not implemented"); + return n; +} + +#endif /* } */ + + +/* +** Maximum size of each formatted item. This maximum size is produced +** by format('%.99f', -maxfloat), and is equal to 99 + 3 ('-', '.', +** and '\0') + number of decimal digits to represent maxfloat (which +** is maximum exponent + 1). (99+3+1 then rounded to 120 for "extra +** expenses", such as locale-dependent stuff) +*/ +#define MAX_ITEM (120 + l_mathlim(MAX_10_EXP)) + + +/* valid flags in a format specification */ +#define FLAGS "-+ #0" + +/* +** maximum size of each format specification (such as "%-099.99d") +*/ +#define MAX_FORMAT 32 + + +static void addquoted (luaL_Buffer *b, const char *s, size_t len) { + luaL_addchar(b, '"'); + while (len--) { + if (*s == '"' || *s == '\\' || *s == '\n') { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); + } + else if (iscntrl(uchar(*s))) { + char buff[10]; + if (!isdigit(uchar(*(s+1)))) + l_sprintf(buff, sizeof(buff), "\\%d", (int)uchar(*s)); + else + l_sprintf(buff, sizeof(buff), "\\%03d", (int)uchar(*s)); + luaL_addstring(b, buff); + } + else + luaL_addchar(b, *s); + s++; + } + luaL_addchar(b, '"'); +} + + +/* +** Ensures the 'buff' string uses a dot as the radix character. +*/ +static void checkdp (char *buff, int nb) { + if (memchr(buff, '.', nb) == NULL) { /* no dot? */ + char point = lua_getlocaledecpoint(); /* try locale point */ + char *ppoint = (char *)memchr(buff, point, nb); + if (ppoint) *ppoint = '.'; /* change it to a dot */ + } +} + + +static void addliteral (lua_State *L, luaL_Buffer *b, int arg) { + switch (lua_type(L, arg)) { + case LUA_TSTRING: { + size_t len; + const char *s = lua_tolstring(L, arg, &len); + addquoted(b, s, len); + break; + } + case LUA_TNUMBER: { + char *buff = luaL_prepbuffsize(b, MAX_ITEM); + int nb; + if (!lua_isinteger(L, arg)) { /* float? */ + lua_Number n = lua_tonumber(L, arg); /* write as hexa ('%a') */ + nb = lua_number2strx(L, buff, MAX_ITEM, "%" LUA_NUMBER_FRMLEN "a", n); + checkdp(buff, nb); /* ensure it uses a dot */ + } + else { /* integers */ + lua_Integer n = lua_tointeger(L, arg); + const char *format = (n == LUA_MININTEGER) /* corner case? */ + ? "0x%" LUA_INTEGER_FRMLEN "x" /* use hexa */ + : LUA_INTEGER_FMT; /* else use default format */ + nb = l_sprintf(buff, MAX_ITEM, format, (LUAI_UACINT)n); + } + luaL_addsize(b, nb); + break; + } + case LUA_TNIL: case LUA_TBOOLEAN: { + luaL_tolstring(L, arg, NULL); + luaL_addvalue(b); + break; + } + default: { + luaL_argerror(L, arg, "value has no literal form"); + } + } +} + + +static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { + const char *p = strfrmt; + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char)) + luaL_error(L, "invalid format (repeated flags)"); + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + *(form++) = '%'; + memcpy(form, strfrmt, ((p - strfrmt) + 1) * sizeof(char)); + form += (p - strfrmt) + 1; + *form = '\0'; + return p; +} + + +/* +** add length modifier into formats +*/ +static void addlenmod (char *form, const char *lenmod) { + size_t l = strlen(form); + size_t lm = strlen(lenmod); + char spec = form[l - 1]; + strcpy(form + l - 1, lenmod); + form[l + lm - 1] = spec; + form[l + lm] = '\0'; +} + + +static int str_format (lua_State *L) { + int top = lua_gettop(L); + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) + luaL_addchar(&b, *strfrmt++); + else if (*++strfrmt == L_ESC) + luaL_addchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format ('%...') */ + char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */ + int nb = 0; /* number of bytes in added item */ + if (++arg > top) + luaL_argerror(L, arg, "no value"); + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': { + nb = l_sprintf(buff, MAX_ITEM, form, (int)luaL_checkinteger(L, arg)); + break; + } + case 'd': case 'i': + case 'o': case 'u': case 'x': case 'X': { + lua_Integer n = luaL_checkinteger(L, arg); + addlenmod(form, LUA_INTEGER_FRMLEN); + nb = l_sprintf(buff, MAX_ITEM, form, (LUAI_UACINT)n); + break; + } + case 'a': case 'A': + addlenmod(form, LUA_NUMBER_FRMLEN); + nb = lua_number2strx(L, buff, MAX_ITEM, form, + luaL_checknumber(L, arg)); + break; + case 'e': case 'E': case 'f': + case 'g': case 'G': { + lua_Number n = luaL_checknumber(L, arg); + addlenmod(form, LUA_NUMBER_FRMLEN); + nb = l_sprintf(buff, MAX_ITEM, form, (LUAI_UACNUMBER)n); + break; + } + case 'q': { + addliteral(L, &b, arg); + break; + } + case 's': { + size_t l; + const char *s = luaL_tolstring(L, arg, &l); + if (form[2] == '\0') /* no modifiers? */ + luaL_addvalue(&b); /* keep entire string */ + else { + luaL_argcheck(L, l == strlen(s), arg, "string contains zeros"); + if (!strchr(form, '.') && l >= 100) { + /* no precision and string is too long to be formatted */ + luaL_addvalue(&b); /* keep entire string */ + } + else { /* format the string into 'buff' */ + nb = l_sprintf(buff, MAX_ITEM, form, s); + lua_pop(L, 1); /* remove result from 'luaL_tolstring' */ + } + } + break; + } + default: { /* also treat cases 'pnLlh' */ + return luaL_error(L, "invalid option '%%%c' to 'format'", + *(strfrmt - 1)); + } + } + lua_assert(nb < MAX_ITEM); + luaL_addsize(&b, nb); + } + } + luaL_pushresult(&b); + return 1; +} + +/* }====================================================== */ + + +/* +** {====================================================== +** PACK/UNPACK +** ======================================================= +*/ + + +/* value used for padding */ +#if !defined(LUAL_PACKPADBYTE) +#define LUAL_PACKPADBYTE 0x00 +#endif + +/* maximum size for the binary representation of an integer */ +#define MAXINTSIZE 16 + +/* number of bits in a character */ +#define NB CHAR_BIT + +/* mask for one character (NB 1's) */ +#define MC ((1 << NB) - 1) + +/* size of a lua_Integer */ +#define SZINT ((int)sizeof(lua_Integer)) + + +/* dummy union to get native endianness */ +static const union { + int dummy; + char little; /* true iff machine is little endian */ +} nativeendian = {1}; + + +/* dummy structure to get native alignment requirements */ +struct cD { + char c; + union { double d; void *p; lua_Integer i; lua_Number n; } u; +}; + +#define MAXALIGN (offsetof(struct cD, u)) + + +/* +** Union for serializing floats +*/ +typedef union Ftypes { + float f; + double d; + lua_Number n; + char buff[5 * sizeof(lua_Number)]; /* enough for any float type */ +} Ftypes; + + +/* +** information to pack/unpack stuff +*/ +typedef struct Header { + lua_State *L; + int islittle; + int maxalign; +} Header; + + +/* +** options for pack/unpack +*/ +typedef enum KOption { + Kint, /* signed integers */ + Kuint, /* unsigned integers */ + Kfloat, /* floating-point numbers */ + Kchar, /* fixed-length strings */ + Kstring, /* strings with prefixed length */ + Kzstr, /* zero-terminated strings */ + Kpadding, /* padding */ + Kpaddalign, /* padding for alignment */ + Knop /* no-op (configuration or spaces) */ +} KOption; + + +/* +** Read an integer numeral from string 'fmt' or return 'df' if +** there is no numeral +*/ +static int digit (int c) { return '0' <= c && c <= '9'; } + +static int getnum (const char **fmt, int df) { + if (!digit(**fmt)) /* no number? */ + return df; /* return default value */ + else { + int a = 0; + do { + a = a*10 + (*((*fmt)++) - '0'); + } while (digit(**fmt) && a <= ((int)MAXSIZE - 9)/10); + return a; + } +} + + +/* +** Read an integer numeral and raises an error if it is larger +** than the maximum size for integers. +*/ +static int getnumlimit (Header *h, const char **fmt, int df) { + int sz = getnum(fmt, df); + if (sz > MAXINTSIZE || sz <= 0) + luaL_error(h->L, "integral size (%d) out of limits [1,%d]", + sz, MAXINTSIZE); + return sz; +} + + +/* +** Initialize Header +*/ +static void initheader (lua_State *L, Header *h) { + h->L = L; + h->islittle = nativeendian.little; + h->maxalign = 1; +} + + +/* +** Read and classify next option. 'size' is filled with option's size. +*/ +static KOption getoption (Header *h, const char **fmt, int *size) { + int opt = *((*fmt)++); + *size = 0; /* default */ + switch (opt) { + case 'b': *size = sizeof(char); return Kint; + case 'B': *size = sizeof(char); return Kuint; + case 'h': *size = sizeof(short); return Kint; + case 'H': *size = sizeof(short); return Kuint; + case 'l': *size = sizeof(long); return Kint; + case 'L': *size = sizeof(long); return Kuint; + case 'j': *size = sizeof(lua_Integer); return Kint; + case 'J': *size = sizeof(lua_Integer); return Kuint; + case 'T': *size = sizeof(size_t); return Kuint; + case 'f': *size = sizeof(float); return Kfloat; + case 'd': *size = sizeof(double); return Kfloat; + case 'n': *size = sizeof(lua_Number); return Kfloat; + case 'i': *size = getnumlimit(h, fmt, sizeof(int)); return Kint; + case 'I': *size = getnumlimit(h, fmt, sizeof(int)); return Kuint; + case 's': *size = getnumlimit(h, fmt, sizeof(size_t)); return Kstring; + case 'c': + *size = getnum(fmt, -1); + if (*size == -1) + luaL_error(h->L, "missing size for format option 'c'"); + return Kchar; + case 'z': return Kzstr; + case 'x': *size = 1; return Kpadding; + case 'X': return Kpaddalign; + case ' ': break; + case '<': h->islittle = 1; break; + case '>': h->islittle = 0; break; + case '=': h->islittle = nativeendian.little; break; + case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break; + default: luaL_error(h->L, "invalid format option '%c'", opt); + } + return Knop; +} + + +/* +** Read, classify, and fill other details about the next option. +** 'psize' is filled with option's size, 'notoalign' with its +** alignment requirements. +** Local variable 'size' gets the size to be aligned. (Kpadal option +** always gets its full alignment, other options are limited by +** the maximum alignment ('maxalign'). Kchar option needs no alignment +** despite its size. +*/ +static KOption getdetails (Header *h, size_t totalsize, + const char **fmt, int *psize, int *ntoalign) { + KOption opt = getoption(h, fmt, psize); + int align = *psize; /* usually, alignment follows size */ + if (opt == Kpaddalign) { /* 'X' gets alignment from following option */ + if (**fmt == '\0' || getoption(h, fmt, &align) == Kchar || align == 0) + luaL_argerror(h->L, 1, "invalid next option for option 'X'"); + } + if (align <= 1 || opt == Kchar) /* need no alignment? */ + *ntoalign = 0; + else { + if (align > h->maxalign) /* enforce maximum alignment */ + align = h->maxalign; + if ((align & (align - 1)) != 0) /* is 'align' not a power of 2? */ + luaL_argerror(h->L, 1, "format asks for alignment not power of 2"); + *ntoalign = (align - (int)(totalsize & (align - 1))) & (align - 1); + } + return opt; +} + + +/* +** Pack integer 'n' with 'size' bytes and 'islittle' endianness. +** The final 'if' handles the case when 'size' is larger than +** the size of a Lua integer, correcting the extra sign-extension +** bytes if necessary (by default they would be zeros). +*/ +static void packint (luaL_Buffer *b, lua_Unsigned n, + int islittle, int size, int neg) { + char *buff = luaL_prepbuffsize(b, size); + int i; + buff[islittle ? 0 : size - 1] = (char)(n & MC); /* first byte */ + for (i = 1; i < size; i++) { + n >>= NB; + buff[islittle ? i : size - 1 - i] = (char)(n & MC); + } + if (neg && size > SZINT) { /* negative number need sign extension? */ + for (i = SZINT; i < size; i++) /* correct extra bytes */ + buff[islittle ? i : size - 1 - i] = (char)MC; + } + luaL_addsize(b, size); /* add result to buffer */ +} + + +/* +** Copy 'size' bytes from 'src' to 'dest', correcting endianness if +** given 'islittle' is different from native endianness. +*/ +static void copywithendian (volatile char *dest, volatile const char *src, + int size, int islittle) { + if (islittle == nativeendian.little) { + while (size-- != 0) + *(dest++) = *(src++); + } + else { + dest += size - 1; + while (size-- != 0) + *(dest--) = *(src++); + } +} + + +static int str_pack (lua_State *L) { + luaL_Buffer b; + Header h; + const char *fmt = luaL_checkstring(L, 1); /* format string */ + int arg = 1; /* current argument to pack */ + size_t totalsize = 0; /* accumulate total size of result */ + initheader(L, &h); + lua_pushnil(L); /* mark to separate arguments from string buffer */ + luaL_buffinit(L, &b); + while (*fmt != '\0') { + int size, ntoalign; + KOption opt = getdetails(&h, totalsize, &fmt, &size, &ntoalign); + totalsize += ntoalign + size; + while (ntoalign-- > 0) + luaL_addchar(&b, LUAL_PACKPADBYTE); /* fill alignment */ + arg++; + switch (opt) { + case Kint: { /* signed integers */ + lua_Integer n = luaL_checkinteger(L, arg); + if (size < SZINT) { /* need overflow check? */ + lua_Integer lim = (lua_Integer)1 << ((size * NB) - 1); + luaL_argcheck(L, -lim <= n && n < lim, arg, "integer overflow"); + } + packint(&b, (lua_Unsigned)n, h.islittle, size, (n < 0)); + break; + } + case Kuint: { /* unsigned integers */ + lua_Integer n = luaL_checkinteger(L, arg); + if (size < SZINT) /* need overflow check? */ + luaL_argcheck(L, (lua_Unsigned)n < ((lua_Unsigned)1 << (size * NB)), + arg, "unsigned overflow"); + packint(&b, (lua_Unsigned)n, h.islittle, size, 0); + break; + } + case Kfloat: { /* floating-point options */ + volatile Ftypes u; + char *buff = luaL_prepbuffsize(&b, size); + lua_Number n = luaL_checknumber(L, arg); /* get argument */ + if (size == sizeof(u.f)) u.f = (float)n; /* copy it into 'u' */ + else if (size == sizeof(u.d)) u.d = (double)n; + else u.n = n; + /* move 'u' to final result, correcting endianness if needed */ + copywithendian(buff, u.buff, size, h.islittle); + luaL_addsize(&b, size); + break; + } + case Kchar: { /* fixed-size string */ + size_t len; + const char *s = luaL_checklstring(L, arg, &len); + luaL_argcheck(L, len <= (size_t)size, arg, + "string longer than given size"); + luaL_addlstring(&b, s, len); /* add string */ + while (len++ < (size_t)size) /* pad extra space */ + luaL_addchar(&b, LUAL_PACKPADBYTE); + break; + } + case Kstring: { /* strings with length count */ + size_t len; + const char *s = luaL_checklstring(L, arg, &len); + luaL_argcheck(L, size >= (int)sizeof(size_t) || + len < ((size_t)1 << (size * NB)), + arg, "string length does not fit in given size"); + packint(&b, (lua_Unsigned)len, h.islittle, size, 0); /* pack length */ + luaL_addlstring(&b, s, len); + totalsize += len; + break; + } + case Kzstr: { /* zero-terminated string */ + size_t len; + const char *s = luaL_checklstring(L, arg, &len); + luaL_argcheck(L, strlen(s) == len, arg, "string contains zeros"); + luaL_addlstring(&b, s, len); + luaL_addchar(&b, '\0'); /* add zero at the end */ + totalsize += len + 1; + break; + } + case Kpadding: luaL_addchar(&b, LUAL_PACKPADBYTE); /* FALLTHROUGH */ + case Kpaddalign: case Knop: + arg--; /* undo increment */ + break; + } + } + luaL_pushresult(&b); + return 1; +} + + +static int str_packsize (lua_State *L) { + Header h; + const char *fmt = luaL_checkstring(L, 1); /* format string */ + size_t totalsize = 0; /* accumulate total size of result */ + initheader(L, &h); + while (*fmt != '\0') { + int size, ntoalign; + KOption opt = getdetails(&h, totalsize, &fmt, &size, &ntoalign); + size += ntoalign; /* total space used by option */ + luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, + "format result too large"); + totalsize += size; + switch (opt) { + case Kstring: /* strings with length count */ + case Kzstr: /* zero-terminated string */ + luaL_argerror(L, 1, "variable-length format"); + /* call never return, but to avoid warnings: *//* FALLTHROUGH */ + default: break; + } + } + lua_pushinteger(L, (lua_Integer)totalsize); + return 1; +} + + +/* +** Unpack an integer with 'size' bytes and 'islittle' endianness. +** If size is smaller than the size of a Lua integer and integer +** is signed, must do sign extension (propagating the sign to the +** higher bits); if size is larger than the size of a Lua integer, +** it must check the unread bytes to see whether they do not cause an +** overflow. +*/ +static lua_Integer unpackint (lua_State *L, const char *str, + int islittle, int size, int issigned) { + lua_Unsigned res = 0; + int i; + int limit = (size <= SZINT) ? size : SZINT; + for (i = limit - 1; i >= 0; i--) { + res <<= NB; + res |= (lua_Unsigned)(unsigned char)str[islittle ? i : size - 1 - i]; + } + if (size < SZINT) { /* real size smaller than lua_Integer? */ + if (issigned) { /* needs sign extension? */ + lua_Unsigned mask = (lua_Unsigned)1 << (size*NB - 1); + res = ((res ^ mask) - mask); /* do sign extension */ + } + } + else if (size > SZINT) { /* must check unread bytes */ + int mask = (!issigned || (lua_Integer)res >= 0) ? 0 : MC; + for (i = limit; i < size; i++) { + if ((unsigned char)str[islittle ? i : size - 1 - i] != mask) + luaL_error(L, "%d-byte integer does not fit into Lua Integer", size); + } + } + return (lua_Integer)res; +} + + +static int str_unpack (lua_State *L) { + Header h; + const char *fmt = luaL_checkstring(L, 1); + size_t ld; + const char *data = luaL_checklstring(L, 2, &ld); + size_t pos = (size_t)posrelat(luaL_optinteger(L, 3, 1), ld) - 1; + int n = 0; /* number of results */ + luaL_argcheck(L, pos <= ld, 3, "initial position out of string"); + initheader(L, &h); + while (*fmt != '\0') { + int size, ntoalign; + KOption opt = getdetails(&h, pos, &fmt, &size, &ntoalign); + if ((size_t)ntoalign + size > ~pos || pos + ntoalign + size > ld) + luaL_argerror(L, 2, "data string too short"); + pos += ntoalign; /* skip alignment */ + /* stack space for item + next position */ + luaL_checkstack(L, 2, "too many results"); + n++; + switch (opt) { + case Kint: + case Kuint: { + lua_Integer res = unpackint(L, data + pos, h.islittle, size, + (opt == Kint)); + lua_pushinteger(L, res); + break; + } + case Kfloat: { + volatile Ftypes u; + lua_Number num; + copywithendian(u.buff, data + pos, size, h.islittle); + if (size == sizeof(u.f)) num = (lua_Number)u.f; + else if (size == sizeof(u.d)) num = (lua_Number)u.d; + else num = u.n; + lua_pushnumber(L, num); + break; + } + case Kchar: { + lua_pushlstring(L, data + pos, size); + break; + } + case Kstring: { + size_t len = (size_t)unpackint(L, data + pos, h.islittle, size, 0); + luaL_argcheck(L, pos + len + size <= ld, 2, "data string too short"); + lua_pushlstring(L, data + pos + size, len); + pos += len; /* skip string */ + break; + } + case Kzstr: { + size_t len = (int)strlen(data + pos); + lua_pushlstring(L, data + pos, len); + pos += len + 1; /* skip string plus final '\0' */ + break; + } + case Kpaddalign: case Kpadding: case Knop: + n--; /* undo increment */ + break; + } + pos += size; + } + lua_pushinteger(L, pos + 1); /* next position */ + return n + 1; +} + +/* }====================================================== */ + + +static const luaL_Reg strlib[] = { + {"byte", str_byte}, + {"char", str_char}, + {"dump", str_dump}, + {"find", str_find}, + {"format", str_format}, + {"gmatch", gmatch}, + {"gsub", str_gsub}, + {"len", str_len}, + {"lower", str_lower}, + {"match", str_match}, + {"rep", str_rep}, + {"reverse", str_reverse}, + {"sub", str_sub}, + {"upper", str_upper}, + {"pack", str_pack}, + {"packsize", str_packsize}, + {"unpack", str_unpack}, + {NULL, NULL} +}; + + +static void createmetatable (lua_State *L) { + lua_createtable(L, 0, 1); /* table to be metatable for strings */ + lua_pushliteral(L, ""); /* dummy string */ + lua_pushvalue(L, -2); /* copy table */ + lua_setmetatable(L, -2); /* set table as metatable for strings */ + lua_pop(L, 1); /* pop dummy string */ + lua_pushvalue(L, -2); /* get string library */ + lua_setfield(L, -2, "__index"); /* metatable.__index = string */ + lua_pop(L, 1); /* pop metatable */ +} + + +/* +** Open string library +*/ +LUAMOD_API int luaopen_string (lua_State *L) { + luaL_newlib(L, strlib); + createmetatable(L); + return 1; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ltable.c b/dep/scintilla/scintilla-3.10.6/lua/src/ltable.c new file mode 100644 index 00000000..d080189f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ltable.c @@ -0,0 +1,669 @@ +/* +** $Id: ltable.c,v 2.118 2016/11/07 12:38:35 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#define ltable_c +#define LUA_CORE + +#include "lprefix.h" + + +/* +** Implementation of tables (aka arrays, objects, or hash tables). +** Tables keep its elements in two parts: an array part and a hash part. +** Non-negative integer keys are all candidates to be kept in the array +** part. The actual size of the array is the largest 'n' such that +** more than half the slots between 1 and n are in use. +** Hash uses a mix of chained scatter table with Brent's variation. +** A main invariant of these tables is that, if an element is not +** in its main position (i.e. the 'original' position that its hash gives +** to it), then the colliding element is in its own main position. +** Hence even when the load factor reaches 100%, performance remains good. +*/ + +#include +#include + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lvm.h" + + +/* +** Maximum size of array part (MAXASIZE) is 2^MAXABITS. MAXABITS is +** the largest integer such that MAXASIZE fits in an unsigned int. +*/ +#define MAXABITS cast_int(sizeof(int) * CHAR_BIT - 1) +#define MAXASIZE (1u << MAXABITS) + +/* +** Maximum size of hash part is 2^MAXHBITS. MAXHBITS is the largest +** integer such that 2^MAXHBITS fits in a signed int. (Note that the +** maximum number of elements in a table, 2^MAXABITS + 2^MAXHBITS, still +** fits comfortably in an unsigned int.) +*/ +#define MAXHBITS (MAXABITS - 1) + + +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->hash) +#define hashboolean(t,p) hashpow2(t, p) +#define hashint(t,i) hashpow2(t, i) + + +/* +** for some types, it is better to avoid modulus by power of 2, as +** they tend to have many 2 factors. +*/ +#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) + + +#define hashpointer(t,p) hashmod(t, point2uint(p)) + + +#define dummynode (&dummynode_) + +static const Node dummynode_ = { + {NILCONSTANT}, /* value */ + {{NILCONSTANT, 0}} /* key */ +}; + + +/* +** Hash for floating-point numbers. +** The main computation should be just +** n = frexp(n, &i); return (n * INT_MAX) + i +** but there are some numerical subtleties. +** In a two-complement representation, INT_MAX does not has an exact +** representation as a float, but INT_MIN does; because the absolute +** value of 'frexp' is smaller than 1 (unless 'n' is inf/NaN), the +** absolute value of the product 'frexp * -INT_MIN' is smaller or equal +** to INT_MAX. Next, the use of 'unsigned int' avoids overflows when +** adding 'i'; the use of '~u' (instead of '-u') avoids problems with +** INT_MIN. +*/ +#if !defined(l_hashfloat) +static int l_hashfloat (lua_Number n) { + int i; + lua_Integer ni; + n = l_mathop(frexp)(n, &i) * -cast_num(INT_MIN); + if (!lua_numbertointeger(n, &ni)) { /* is 'n' inf/-inf/NaN? */ + lua_assert(luai_numisnan(n) || l_mathop(fabs)(n) == cast_num(HUGE_VAL)); + return 0; + } + else { /* normal case */ + unsigned int u = cast(unsigned int, i) + cast(unsigned int, ni); + return cast_int(u <= cast(unsigned int, INT_MAX) ? u : ~u); + } +} +#endif + + +/* +** returns the 'main' position of an element in a table (that is, the index +** of its hash value) +*/ +static Node *mainposition (const Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNUMINT: + return hashint(t, ivalue(key)); + case LUA_TNUMFLT: + return hashmod(t, l_hashfloat(fltvalue(key))); + case LUA_TSHRSTR: + return hashstr(t, tsvalue(key)); + case LUA_TLNGSTR: + return hashpow2(t, luaS_hashlongstr(tsvalue(key))); + case LUA_TBOOLEAN: + return hashboolean(t, bvalue(key)); + case LUA_TLIGHTUSERDATA: + return hashpointer(t, pvalue(key)); + case LUA_TLCF: + return hashpointer(t, fvalue(key)); + default: + lua_assert(!ttisdeadkey(key)); + return hashpointer(t, gcvalue(key)); + } +} + + +/* +** returns the index for 'key' if 'key' is an appropriate key to live in +** the array part of the table, 0 otherwise. +*/ +static unsigned int arrayindex (const TValue *key) { + if (ttisinteger(key)) { + lua_Integer k = ivalue(key); + if (0 < k && (lua_Unsigned)k <= MAXASIZE) + return cast(unsigned int, k); /* 'key' is an appropriate array index */ + } + return 0; /* 'key' did not match some condition */ +} + + +/* +** returns the index of a 'key' for table traversals. First goes all +** elements in the array part, then elements in the hash part. The +** beginning of a traversal is signaled by 0. +*/ +static unsigned int findindex (lua_State *L, Table *t, StkId key) { + unsigned int i; + if (ttisnil(key)) return 0; /* first iteration */ + i = arrayindex(key); + if (i != 0 && i <= t->sizearray) /* is 'key' inside array part? */ + return i; /* yes; that's the index */ + else { + int nx; + Node *n = mainposition(t, key); + for (;;) { /* check whether 'key' is somewhere in the chain */ + /* key may be dead already, but it is ok to use it in 'next' */ + if (luaV_rawequalobj(gkey(n), key) || + (ttisdeadkey(gkey(n)) && iscollectable(key) && + deadvalue(gkey(n)) == gcvalue(key))) { + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return (i + 1) + t->sizearray; + } + nx = gnext(n); + if (nx == 0) + luaG_runerror(L, "invalid key to 'next'"); /* key not found */ + else n += nx; + } + } +} + + +int luaH_next (lua_State *L, Table *t, StkId key) { + unsigned int i = findindex(L, t, key); /* find original element */ + for (; i < t->sizearray; i++) { /* try first array part */ + if (!ttisnil(&t->array[i])) { /* a non-nil value? */ + setivalue(key, i + 1); + setobj2s(L, key+1, &t->array[i]); + return 1; + } + } + for (i -= t->sizearray; cast_int(i) < sizenode(t); i++) { /* hash part */ + if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ + setobj2s(L, key, gkey(gnode(t, i))); + setobj2s(L, key+1, gval(gnode(t, i))); + return 1; + } + } + return 0; /* no more elements */ +} + + +/* +** {============================================================= +** Rehash +** ============================================================== +*/ + +/* +** Compute the optimal size for the array part of table 't'. 'nums' is a +** "count array" where 'nums[i]' is the number of integers in the table +** between 2^(i - 1) + 1 and 2^i. 'pna' enters with the total number of +** integer keys in the table and leaves with the number of keys that +** will go to the array part; return the optimal size. +*/ +static unsigned int computesizes (unsigned int nums[], unsigned int *pna) { + int i; + unsigned int twotoi; /* 2^i (candidate for optimal size) */ + unsigned int a = 0; /* number of elements smaller than 2^i */ + unsigned int na = 0; /* number of elements to go to array part */ + unsigned int optimal = 0; /* optimal size for array part */ + /* loop while keys can fill more than half of total size */ + for (i = 0, twotoi = 1; *pna > twotoi / 2; i++, twotoi *= 2) { + if (nums[i] > 0) { + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + optimal = twotoi; /* optimal size (till now) */ + na = a; /* all elements up to 'optimal' will go to array part */ + } + } + } + lua_assert((optimal == 0 || optimal / 2 < na) && na <= optimal); + *pna = na; + return optimal; +} + + +static int countint (const TValue *key, unsigned int *nums) { + unsigned int k = arrayindex(key); + if (k != 0) { /* is 'key' an appropriate array index? */ + nums[luaO_ceillog2(k)]++; /* count as such */ + return 1; + } + else + return 0; +} + + +/* +** Count keys in array part of table 't': Fill 'nums[i]' with +** number of keys that will go into corresponding slice and return +** total number of non-nil keys. +*/ +static unsigned int numusearray (const Table *t, unsigned int *nums) { + int lg; + unsigned int ttlg; /* 2^lg */ + unsigned int ause = 0; /* summation of 'nums' */ + unsigned int i = 1; /* count to traverse all array keys */ + /* traverse each slice */ + for (lg = 0, ttlg = 1; lg <= MAXABITS; lg++, ttlg *= 2) { + unsigned int lc = 0; /* counter */ + unsigned int lim = ttlg; + if (lim > t->sizearray) { + lim = t->sizearray; /* adjust upper limit */ + if (i > lim) + break; /* no more elements to count */ + } + /* count elements in range (2^(lg - 1), 2^lg] */ + for (; i <= lim; i++) { + if (!ttisnil(&t->array[i-1])) + lc++; + } + nums[lg] += lc; + ause += lc; + } + return ause; +} + + +static int numusehash (const Table *t, unsigned int *nums, unsigned int *pna) { + int totaluse = 0; /* total number of elements */ + int ause = 0; /* elements added to 'nums' (can go to array part) */ + int i = sizenode(t); + while (i--) { + Node *n = &t->node[i]; + if (!ttisnil(gval(n))) { + ause += countint(gkey(n), nums); + totaluse++; + } + } + *pna += ause; + return totaluse; +} + + +static void setarrayvector (lua_State *L, Table *t, unsigned int size) { + unsigned int i; + luaM_reallocvector(L, t->array, t->sizearray, size, TValue); + for (i=t->sizearray; iarray[i]); + t->sizearray = size; +} + + +static void setnodevector (lua_State *L, Table *t, unsigned int size) { + if (size == 0) { /* no elements to hash part? */ + t->node = cast(Node *, dummynode); /* use common 'dummynode' */ + t->lsizenode = 0; + t->lastfree = NULL; /* signal that it is using dummy node */ + } + else { + int i; + int lsize = luaO_ceillog2(size); + if (lsize > MAXHBITS) + luaG_runerror(L, "table overflow"); + size = twoto(lsize); + t->node = luaM_newvector(L, size, Node); + for (i = 0; i < (int)size; i++) { + Node *n = gnode(t, i); + gnext(n) = 0; + setnilvalue(wgkey(n)); + setnilvalue(gval(n)); + } + t->lsizenode = cast_byte(lsize); + t->lastfree = gnode(t, size); /* all positions are free */ + } +} + + +void luaH_resize (lua_State *L, Table *t, unsigned int nasize, + unsigned int nhsize) { + unsigned int i; + int j; + unsigned int oldasize = t->sizearray; + int oldhsize = allocsizenode(t); + Node *nold = t->node; /* save old hash ... */ + if (nasize > oldasize) /* array part must grow? */ + setarrayvector(L, t, nasize); + /* create new hash part with appropriate size */ + setnodevector(L, t, nhsize); + if (nasize < oldasize) { /* array part must shrink? */ + t->sizearray = nasize; + /* re-insert elements from vanishing slice */ + for (i=nasize; iarray[i])) + luaH_setint(L, t, i + 1, &t->array[i]); + } + /* shrink array */ + luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + } + /* re-insert elements from hash part */ + for (j = oldhsize - 1; j >= 0; j--) { + Node *old = nold + j; + if (!ttisnil(gval(old))) { + /* doesn't need barrier/invalidate cache, as entry was + already present in the table */ + setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old)); + } + } + if (oldhsize > 0) /* not the dummy node? */ + luaM_freearray(L, nold, cast(size_t, oldhsize)); /* free old hash */ +} + + +void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize) { + int nsize = allocsizenode(t); + luaH_resize(L, t, nasize, nsize); +} + +/* +** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i +*/ +static void rehash (lua_State *L, Table *t, const TValue *ek) { + unsigned int asize; /* optimal size for array part */ + unsigned int na; /* number of keys in the array part */ + unsigned int nums[MAXABITS + 1]; + int i; + int totaluse; + for (i = 0; i <= MAXABITS; i++) nums[i] = 0; /* reset counts */ + na = numusearray(t, nums); /* count keys in array part */ + totaluse = na; /* all those keys are integer keys */ + totaluse += numusehash(t, nums, &na); /* count keys in hash part */ + /* count extra key */ + na += countint(ek, nums); + totaluse++; + /* compute new size for array part */ + asize = computesizes(nums, &na); + /* resize the table to new computed sizes */ + luaH_resize(L, t, asize, totaluse - na); +} + + + +/* +** }============================================================= +*/ + + +Table *luaH_new (lua_State *L) { + GCObject *o = luaC_newobj(L, LUA_TTABLE, sizeof(Table)); + Table *t = gco2t(o); + t->metatable = NULL; + t->flags = cast_byte(~0); + t->array = NULL; + t->sizearray = 0; + setnodevector(L, t, 0); + return t; +} + + +void luaH_free (lua_State *L, Table *t) { + if (!isdummy(t)) + luaM_freearray(L, t->node, cast(size_t, sizenode(t))); + luaM_freearray(L, t->array, t->sizearray); + luaM_free(L, t); +} + + +static Node *getfreepos (Table *t) { + if (!isdummy(t)) { + while (t->lastfree > t->node) { + t->lastfree--; + if (ttisnil(gkey(t->lastfree))) + return t->lastfree; + } + } + return NULL; /* could not find a free place */ +} + + + +/* +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. +*/ +TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp; + TValue aux; + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisfloat(key)) { + lua_Integer k; + if (luaV_tointeger(key, &k, 0)) { /* does index fit in an integer? */ + setivalue(&aux, k); + key = &aux; /* insert it as an integer */ + } + else if (luai_numisnan(fltvalue(key))) + luaG_runerror(L, "table index is NaN"); + } + mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || isdummy(t)) { /* main position is taken? */ + Node *othern; + Node *f = getfreepos(t); /* get a free place */ + if (f == NULL) { /* cannot find a free place? */ + rehash(L, t, key); /* grow table */ + /* whatever called 'newkey' takes care of TM cache */ + return luaH_set(L, t, key); /* insert key into grown table */ + } + lua_assert(!isdummy(t)); + othern = mainposition(t, gkey(mp)); + if (othern != mp) { /* is colliding node out of its main position? */ + /* yes; move colliding node into free position */ + while (othern + gnext(othern) != mp) /* find previous */ + othern += gnext(othern); + gnext(othern) = cast_int(f - othern); /* rechain to point to 'f' */ + *f = *mp; /* copy colliding node into free pos. (mp->next also goes) */ + if (gnext(mp) != 0) { + gnext(f) += cast_int(mp - f); /* correct 'next' */ + gnext(mp) = 0; /* now 'mp' is free */ + } + setnilvalue(gval(mp)); + } + else { /* colliding node is in its own main position */ + /* new node will go into free position */ + if (gnext(mp) != 0) + gnext(f) = cast_int((mp + gnext(mp)) - f); /* chain new position */ + else lua_assert(gnext(f) == 0); + gnext(mp) = cast_int(f - mp); + mp = f; + } + } + setnodekey(L, &mp->i_key, key); + luaC_barrierback(L, t, key); + lua_assert(ttisnil(gval(mp))); + return gval(mp); +} + + +/* +** search function for integers +*/ +const TValue *luaH_getint (Table *t, lua_Integer key) { + /* (1 <= key && key <= t->sizearray) */ + if (l_castS2U(key) - 1 < t->sizearray) + return &t->array[key - 1]; + else { + Node *n = hashint(t, key); + for (;;) { /* check whether 'key' is somewhere in the chain */ + if (ttisinteger(gkey(n)) && ivalue(gkey(n)) == key) + return gval(n); /* that's it */ + else { + int nx = gnext(n); + if (nx == 0) break; + n += nx; + } + } + return luaO_nilobject; + } +} + + +/* +** search function for short strings +*/ +const TValue *luaH_getshortstr (Table *t, TString *key) { + Node *n = hashstr(t, key); + lua_assert(key->tt == LUA_TSHRSTR); + for (;;) { /* check whether 'key' is somewhere in the chain */ + const TValue *k = gkey(n); + if (ttisshrstring(k) && eqshrstr(tsvalue(k), key)) + return gval(n); /* that's it */ + else { + int nx = gnext(n); + if (nx == 0) + return luaO_nilobject; /* not found */ + n += nx; + } + } +} + + +/* +** "Generic" get version. (Not that generic: not valid for integers, +** which may be in array part, nor for floats with integral values.) +*/ +static const TValue *getgeneric (Table *t, const TValue *key) { + Node *n = mainposition(t, key); + for (;;) { /* check whether 'key' is somewhere in the chain */ + if (luaV_rawequalobj(gkey(n), key)) + return gval(n); /* that's it */ + else { + int nx = gnext(n); + if (nx == 0) + return luaO_nilobject; /* not found */ + n += nx; + } + } +} + + +const TValue *luaH_getstr (Table *t, TString *key) { + if (key->tt == LUA_TSHRSTR) + return luaH_getshortstr(t, key); + else { /* for long strings, use generic case */ + TValue ko; + setsvalue(cast(lua_State *, NULL), &ko, key); + return getgeneric(t, &ko); + } +} + + +/* +** main search function +*/ +const TValue *luaH_get (Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TSHRSTR: return luaH_getshortstr(t, tsvalue(key)); + case LUA_TNUMINT: return luaH_getint(t, ivalue(key)); + case LUA_TNIL: return luaO_nilobject; + case LUA_TNUMFLT: { + lua_Integer k; + if (luaV_tointeger(key, &k, 0)) /* index is int? */ + return luaH_getint(t, k); /* use specialized version */ + /* else... */ + } /* FALLTHROUGH */ + default: + return getgeneric(t, key); + } +} + + +/* +** beware: when using this function you probably need to check a GC +** barrier and invalidate the TM cache. +*/ +TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { + const TValue *p = luaH_get(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else return luaH_newkey(L, t, key); +} + + +void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) { + const TValue *p = luaH_getint(t, key); + TValue *cell; + if (p != luaO_nilobject) + cell = cast(TValue *, p); + else { + TValue k; + setivalue(&k, key); + cell = luaH_newkey(L, t, &k); + } + setobj2t(L, cell, value); +} + + +static int unbound_search (Table *t, unsigned int j) { + unsigned int i = j; /* i is zero or a present index */ + j++; + /* find 'i' and 'j' such that i is present and j is not */ + while (!ttisnil(luaH_getint(t, j))) { + i = j; + if (j > cast(unsigned int, MAX_INT)/2) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while (!ttisnil(luaH_getint(t, i))) i++; + return i - 1; + } + j *= 2; + } + /* now do a binary search between them */ + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(luaH_getint(t, m))) j = m; + else i = m; + } + return i; +} + + +/* +** Try to find a boundary in table 't'. A 'boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +int luaH_getn (Table *t) { + unsigned int j = t->sizearray; + if (j > 0 && ttisnil(&t->array[j - 1])) { + /* there is a boundary in the array part: (binary) search for it */ + unsigned int i = 0; + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(&t->array[m - 1])) j = m; + else i = m; + } + return i; + } + /* else must find a boundary in hash part */ + else if (isdummy(t)) /* hash part is empty? */ + return j; /* that is easy... */ + else return unbound_search(t, j); +} + + + +#if defined(LUA_DEBUG) + +Node *luaH_mainposition (const Table *t, const TValue *key) { + return mainposition(t, key); +} + +int luaH_isdummy (const Table *t) { return isdummy(t); } + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ltable.h b/dep/scintilla/scintilla-3.10.6/lua/src/ltable.h new file mode 100644 index 00000000..6da9024f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ltable.h @@ -0,0 +1,66 @@ +/* +** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + + +/* 'const' to avoid wrong writings that can mess up field 'next' */ +#define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) + +/* +** writable version of 'gkey'; allows updates to individual fields, +** but not to the whole (which has incompatible type) +*/ +#define wgkey(n) (&(n)->i_key.nk) + +#define invalidateTMcache(t) ((t)->flags = 0) + + +/* true when 't' is using 'dummynode' as its hash part */ +#define isdummy(t) ((t)->lastfree == NULL) + + +/* allocated size for hash nodes */ +#define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) + + +/* returns the key, given the value of a table entry */ +#define keyfromval(v) \ + (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) + + +LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); +LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, + TValue *value); +LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L); +LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, + unsigned int nhsize); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (const Table *t); +#endif + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ltablib.c b/dep/scintilla/scintilla-3.10.6/lua/src/ltablib.c new file mode 100644 index 00000000..98b2f871 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ltablib.c @@ -0,0 +1,450 @@ +/* +** $Id: ltablib.c,v 1.93 2016/02/25 19:41:54 roberto Exp $ +** Library for Table Manipulation +** See Copyright Notice in lua.h +*/ + +#define ltablib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* +** Operations that an object must define to mimic a table +** (some functions only need some of them) +*/ +#define TAB_R 1 /* read */ +#define TAB_W 2 /* write */ +#define TAB_L 4 /* length */ +#define TAB_RW (TAB_R | TAB_W) /* read/write */ + + +#define aux_getn(L,n,w) (checktab(L, n, (w) | TAB_L), luaL_len(L, n)) + + +static int checkfield (lua_State *L, const char *key, int n) { + lua_pushstring(L, key); + return (lua_rawget(L, -n) != LUA_TNIL); +} + + +/* +** Check that 'arg' either is a table or can behave like one (that is, +** has a metatable with the required metamethods) +*/ +static void checktab (lua_State *L, int arg, int what) { + if (lua_type(L, arg) != LUA_TTABLE) { /* is it not a table? */ + int n = 1; /* number of elements to pop */ + if (lua_getmetatable(L, arg) && /* must have metatable */ + (!(what & TAB_R) || checkfield(L, "__index", ++n)) && + (!(what & TAB_W) || checkfield(L, "__newindex", ++n)) && + (!(what & TAB_L) || checkfield(L, "__len", ++n))) { + lua_pop(L, n); /* pop metatable and tested metamethods */ + } + else + luaL_checktype(L, arg, LUA_TTABLE); /* force an error */ + } +} + + +#if defined(LUA_COMPAT_MAXN) +static int maxn (lua_State *L) { + lua_Number max = 0; + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pop(L, 1); /* remove value */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_Number v = lua_tonumber(L, -1); + if (v > max) max = v; + } + } + lua_pushnumber(L, max); + return 1; +} +#endif + + +static int tinsert (lua_State *L) { + lua_Integer e = aux_getn(L, 1, TAB_RW) + 1; /* first empty element */ + lua_Integer pos; /* where to insert new element */ + switch (lua_gettop(L)) { + case 2: { /* called with only 2 arguments */ + pos = e; /* insert new element at the end */ + break; + } + case 3: { + lua_Integer i; + pos = luaL_checkinteger(L, 2); /* 2nd argument is the position */ + luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds"); + for (i = e; i > pos; i--) { /* move up elements */ + lua_geti(L, 1, i - 1); + lua_seti(L, 1, i); /* t[i] = t[i - 1] */ + } + break; + } + default: { + return luaL_error(L, "wrong number of arguments to 'insert'"); + } + } + lua_seti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int tremove (lua_State *L) { + lua_Integer size = aux_getn(L, 1, TAB_RW); + lua_Integer pos = luaL_optinteger(L, 2, size); + if (pos != size) /* validate 'pos' if given */ + luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); + lua_geti(L, 1, pos); /* result = t[pos] */ + for ( ; pos < size; pos++) { + lua_geti(L, 1, pos + 1); + lua_seti(L, 1, pos); /* t[pos] = t[pos + 1] */ + } + lua_pushnil(L); + lua_seti(L, 1, pos); /* t[pos] = nil */ + return 1; +} + + +/* +** Copy elements (1[f], ..., 1[e]) into (tt[t], tt[t+1], ...). Whenever +** possible, copy in increasing order, which is better for rehashing. +** "possible" means destination after original range, or smaller +** than origin, or copying to another table. +*/ +static int tmove (lua_State *L) { + lua_Integer f = luaL_checkinteger(L, 2); + lua_Integer e = luaL_checkinteger(L, 3); + lua_Integer t = luaL_checkinteger(L, 4); + int tt = !lua_isnoneornil(L, 5) ? 5 : 1; /* destination table */ + checktab(L, 1, TAB_R); + checktab(L, tt, TAB_W); + if (e >= f) { /* otherwise, nothing to move */ + lua_Integer n, i; + luaL_argcheck(L, f > 0 || e < LUA_MAXINTEGER + f, 3, + "too many elements to move"); + n = e - f + 1; /* number of elements to move */ + luaL_argcheck(L, t <= LUA_MAXINTEGER - n + 1, 4, + "destination wrap around"); + if (t > e || t <= f || (tt != 1 && !lua_compare(L, 1, tt, LUA_OPEQ))) { + for (i = 0; i < n; i++) { + lua_geti(L, 1, f + i); + lua_seti(L, tt, t + i); + } + } + else { + for (i = n - 1; i >= 0; i--) { + lua_geti(L, 1, f + i); + lua_seti(L, tt, t + i); + } + } + } + lua_pushvalue(L, tt); /* return destination table */ + return 1; +} + + +static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) { + lua_geti(L, 1, i); + if (!lua_isstring(L, -1)) + luaL_error(L, "invalid value (%s) at index %d in table for 'concat'", + luaL_typename(L, -1), i); + luaL_addvalue(b); +} + + +static int tconcat (lua_State *L) { + luaL_Buffer b; + lua_Integer last = aux_getn(L, 1, TAB_R); + size_t lsep; + const char *sep = luaL_optlstring(L, 2, "", &lsep); + lua_Integer i = luaL_optinteger(L, 3, 1); + last = luaL_optinteger(L, 4, last); + luaL_buffinit(L, &b); + for (; i < last; i++) { + addfield(L, &b, i); + luaL_addlstring(&b, sep, lsep); + } + if (i == last) /* add last value (if interval was not empty) */ + addfield(L, &b, i); + luaL_pushresult(&b); + return 1; +} + + +/* +** {====================================================== +** Pack/unpack +** ======================================================= +*/ + +static int pack (lua_State *L) { + int i; + int n = lua_gettop(L); /* number of elements to pack */ + lua_createtable(L, n, 1); /* create result table */ + lua_insert(L, 1); /* put it at index 1 */ + for (i = n; i >= 1; i--) /* assign elements */ + lua_seti(L, 1, i); + lua_pushinteger(L, n); + lua_setfield(L, 1, "n"); /* t.n = number of elements */ + return 1; /* return table */ +} + + +static int unpack (lua_State *L) { + lua_Unsigned n; + lua_Integer i = luaL_optinteger(L, 2, 1); + lua_Integer e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1)); + if (i > e) return 0; /* empty range */ + n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */ + if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, (int)(++n))) + return luaL_error(L, "too many results to unpack"); + for (; i < e; i++) { /* push arg[i..e - 1] (to avoid overflows) */ + lua_geti(L, 1, i); + } + lua_geti(L, 1, e); /* push last element */ + return (int)n; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** Quicksort +** (based on 'Algorithms in MODULA-3', Robert Sedgewick; +** Addison-Wesley, 1993.) +** ======================================================= +*/ + + +/* type for array indices */ +typedef unsigned int IdxT; + + +/* +** Produce a "random" 'unsigned int' to randomize pivot choice. This +** macro is used only when 'sort' detects a big imbalance in the result +** of a partition. (If you don't want/need this "randomness", ~0 is a +** good choice.) +*/ +#if !defined(l_randomizePivot) /* { */ + +#include + +/* size of 'e' measured in number of 'unsigned int's */ +#define sof(e) (sizeof(e) / sizeof(unsigned int)) + +/* +** Use 'time' and 'clock' as sources of "randomness". Because we don't +** know the types 'clock_t' and 'time_t', we cannot cast them to +** anything without risking overflows. A safe way to use their values +** is to copy them to an array of a known type and use the array values. +*/ +static unsigned int l_randomizePivot (void) { + clock_t c = clock(); + time_t t = time(NULL); + unsigned int buff[sof(c) + sof(t)]; + unsigned int i, rnd = 0; + memcpy(buff, &c, sof(c) * sizeof(unsigned int)); + memcpy(buff + sof(c), &t, sof(t) * sizeof(unsigned int)); + for (i = 0; i < sof(buff); i++) + rnd += buff[i]; + return rnd; +} + +#endif /* } */ + + +/* arrays larger than 'RANLIMIT' may use randomized pivots */ +#define RANLIMIT 100u + + +static void set2 (lua_State *L, IdxT i, IdxT j) { + lua_seti(L, 1, i); + lua_seti(L, 1, j); +} + + +/* +** Return true iff value at stack index 'a' is less than the value at +** index 'b' (according to the order of the sort). +*/ +static int sort_comp (lua_State *L, int a, int b) { + if (lua_isnil(L, 2)) /* no function? */ + return lua_compare(L, a, b, LUA_OPLT); /* a < b */ + else { /* function */ + int res; + lua_pushvalue(L, 2); /* push function */ + lua_pushvalue(L, a-1); /* -1 to compensate function */ + lua_pushvalue(L, b-2); /* -2 to compensate function and 'a' */ + lua_call(L, 2, 1); /* call function */ + res = lua_toboolean(L, -1); /* get result */ + lua_pop(L, 1); /* pop result */ + return res; + } +} + + +/* +** Does the partition: Pivot P is at the top of the stack. +** precondition: a[lo] <= P == a[up-1] <= a[up], +** so it only needs to do the partition from lo + 1 to up - 2. +** Pos-condition: a[lo .. i - 1] <= a[i] == P <= a[i + 1 .. up] +** returns 'i'. +*/ +static IdxT partition (lua_State *L, IdxT lo, IdxT up) { + IdxT i = lo; /* will be incremented before first use */ + IdxT j = up - 1; /* will be decremented before first use */ + /* loop invariant: a[lo .. i] <= P <= a[j .. up] */ + for (;;) { + /* next loop: repeat ++i while a[i] < P */ + while (lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ + luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ + /* next loop: repeat --j while P < a[j] */ + while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j < i) /* j < i but a[j] > P ?? */ + luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[j] */ + } + /* after the loop, a[j] <= P and a[j + 1 .. up] >= P */ + if (j < i) { /* no elements out of place? */ + /* a[lo .. i - 1] <= P <= a[j + 1 .. i .. up] */ + lua_pop(L, 1); /* pop a[j] */ + /* swap pivot (a[up - 1]) with a[i] to satisfy pos-condition */ + set2(L, up - 1, i); + return i; + } + /* otherwise, swap a[i] - a[j] to restore invariant and repeat */ + set2(L, i, j); + } +} + + +/* +** Choose an element in the middle (2nd-3th quarters) of [lo,up] +** "randomized" by 'rnd' +*/ +static IdxT choosePivot (IdxT lo, IdxT up, unsigned int rnd) { + IdxT r4 = (up - lo) / 4; /* range/4 */ + IdxT p = rnd % (r4 * 2) + (lo + r4); + lua_assert(lo + r4 <= p && p <= up - r4); + return p; +} + + +/* +** QuickSort algorithm (recursive function) +*/ +static void auxsort (lua_State *L, IdxT lo, IdxT up, + unsigned int rnd) { + while (lo < up) { /* loop for tail recursion */ + IdxT p; /* Pivot index */ + IdxT n; /* to be used later */ + /* sort elements 'lo', 'p', and 'up' */ + lua_geti(L, 1, lo); + lua_geti(L, 1, up); + if (sort_comp(L, -1, -2)) /* a[up] < a[lo]? */ + set2(L, lo, up); /* swap a[lo] - a[up] */ + else + lua_pop(L, 2); /* remove both values */ + if (up - lo == 1) /* only 2 elements? */ + return; /* already sorted */ + if (up - lo < RANLIMIT || rnd == 0) /* small interval or no randomize? */ + p = (lo + up)/2; /* middle element is a good pivot */ + else /* for larger intervals, it is worth a random pivot */ + p = choosePivot(lo, up, rnd); + lua_geti(L, 1, p); + lua_geti(L, 1, lo); + if (sort_comp(L, -2, -1)) /* a[p] < a[lo]? */ + set2(L, p, lo); /* swap a[p] - a[lo] */ + else { + lua_pop(L, 1); /* remove a[lo] */ + lua_geti(L, 1, up); + if (sort_comp(L, -1, -2)) /* a[up] < a[p]? */ + set2(L, p, up); /* swap a[up] - a[p] */ + else + lua_pop(L, 2); + } + if (up - lo == 2) /* only 3 elements? */ + return; /* already sorted */ + lua_geti(L, 1, p); /* get middle element (Pivot) */ + lua_pushvalue(L, -1); /* push Pivot */ + lua_geti(L, 1, up - 1); /* push a[up - 1] */ + set2(L, p, up - 1); /* swap Pivot (a[p]) with a[up - 1] */ + p = partition(L, lo, up); + /* a[lo .. p - 1] <= a[p] == P <= a[p + 1 .. up] */ + if (p - lo < up - p) { /* lower interval is smaller? */ + auxsort(L, lo, p - 1, rnd); /* call recursively for lower interval */ + n = p - lo; /* size of smaller interval */ + lo = p + 1; /* tail call for [p + 1 .. up] (upper interval) */ + } + else { + auxsort(L, p + 1, up, rnd); /* call recursively for upper interval */ + n = up - p; /* size of smaller interval */ + up = p - 1; /* tail call for [lo .. p - 1] (lower interval) */ + } + if ((up - lo) / 128 > n) /* partition too imbalanced? */ + rnd = l_randomizePivot(); /* try a new randomization */ + } /* tail call auxsort(L, lo, up, rnd) */ +} + + +static int sort (lua_State *L) { + lua_Integer n = aux_getn(L, 1, TAB_RW); + if (n > 1) { /* non-trivial interval? */ + luaL_argcheck(L, n < INT_MAX, 1, "array too big"); + if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ + luaL_checktype(L, 2, LUA_TFUNCTION); /* must be a function */ + lua_settop(L, 2); /* make sure there are two arguments */ + auxsort(L, 1, (IdxT)n, 0); + } + return 0; +} + +/* }====================================================== */ + + +static const luaL_Reg tab_funcs[] = { + {"concat", tconcat}, +#if defined(LUA_COMPAT_MAXN) + {"maxn", maxn}, +#endif + {"insert", tinsert}, + {"pack", pack}, + {"unpack", unpack}, + {"remove", tremove}, + {"move", tmove}, + {"sort", sort}, + {NULL, NULL} +}; + + +LUAMOD_API int luaopen_table (lua_State *L) { + luaL_newlib(L, tab_funcs); +#if defined(LUA_COMPAT_UNPACK) + /* _G.unpack = table.unpack */ + lua_getfield(L, -1, "unpack"); + lua_setglobal(L, "unpack"); +#endif + return 1; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ltm.c b/dep/scintilla/scintilla-3.10.6/lua/src/ltm.c new file mode 100644 index 00000000..14e52578 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ltm.c @@ -0,0 +1,165 @@ +/* +** $Id: ltm.c,v 2.38 2016/12/22 13:08:50 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#define ltm_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + +static const char udatatypename[] = "userdata"; + +LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = { + "no value", + "nil", "boolean", udatatypename, "number", + "string", "table", "function", udatatypename, "thread", + "proto" /* this last case is used for tests only */ +}; + + +void luaT_init (lua_State *L) { + static const char *const luaT_eventname[] = { /* ORDER TM */ + "__index", "__newindex", + "__gc", "__mode", "__len", "__eq", + "__add", "__sub", "__mul", "__mod", "__pow", + "__div", "__idiv", + "__band", "__bor", "__bxor", "__shl", "__shr", + "__unm", "__bnot", "__lt", "__le", + "__concat", "__call" + }; + int i; + for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); + luaC_fix(L, obj2gco(G(L)->tmname[i])); /* never collect these names */ + } +} + + +/* +** function to be used with macro "fasttm": optimized for absence of +** tag methods +*/ +const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { + const TValue *tm = luaH_getshortstr(events, ename); + lua_assert(event <= TM_EQ); + if (ttisnil(tm)) { /* no tag method? */ + events->flags |= cast_byte(1u<metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(o)->metatable; + break; + default: + mt = G(L)->mt[ttnov(o)]; + } + return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : luaO_nilobject); +} + + +/* +** Return the name of the type of an object. For tables and userdata +** with metatable, use their '__name' metafield, if present. +*/ +const char *luaT_objtypename (lua_State *L, const TValue *o) { + Table *mt; + if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) || + (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) { + const TValue *name = luaH_getshortstr(mt, luaS_new(L, "__name")); + if (ttisstring(name)) /* is '__name' a string? */ + return getstr(tsvalue(name)); /* use it as type name */ + } + return ttypename(ttnov(o)); /* else use standard type name */ +} + + +void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, TValue *p3, int hasres) { + ptrdiff_t result = savestack(L, p3); + StkId func = L->top; + setobj2s(L, func, f); /* push function (assume EXTRA_STACK) */ + setobj2s(L, func + 1, p1); /* 1st argument */ + setobj2s(L, func + 2, p2); /* 2nd argument */ + L->top += 3; + if (!hasres) /* no result? 'p3' is third argument */ + setobj2s(L, L->top++, p3); /* 3rd argument */ + /* metamethod may yield only when called from Lua code */ + if (isLua(L->ci)) + luaD_call(L, func, hasres); + else + luaD_callnoyield(L, func, hasres); + if (hasres) { /* if has result, move it to its place */ + p3 = restorestack(L, result); + setobjs2s(L, p3, --L->top); + } +} + + +int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ + if (ttisnil(tm)) + tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ + if (ttisnil(tm)) return 0; + luaT_callTM(L, tm, p1, p2, res, 1); + return 1; +} + + +void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + if (!luaT_callbinTM(L, p1, p2, res, event)) { + switch (event) { + case TM_CONCAT: + luaG_concaterror(L, p1, p2); + /* call never returns, but to avoid warnings: *//* FALLTHROUGH */ + case TM_BAND: case TM_BOR: case TM_BXOR: + case TM_SHL: case TM_SHR: case TM_BNOT: { + lua_Number dummy; + if (tonumber(p1, &dummy) && tonumber(p2, &dummy)) + luaG_tointerror(L, p1, p2); + else + luaG_opinterror(L, p1, p2, "perform bitwise operation on"); + } + /* calls never return, but to avoid warnings: *//* FALLTHROUGH */ + default: + luaG_opinterror(L, p1, p2, "perform arithmetic on"); + } + } +} + + +int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, + TMS event) { + if (!luaT_callbinTM(L, p1, p2, L->top, event)) + return -1; /* no metamethod */ + else + return !l_isfalse(L->top); +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/ltm.h b/dep/scintilla/scintilla-3.10.6/lua/src/ltm.h new file mode 100644 index 00000000..63db7269 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/ltm.h @@ -0,0 +1,76 @@ +/* +** $Id: ltm.h,v 2.22 2016/02/26 19:20:15 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" and "ORDER OP" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_LEN, + TM_EQ, /* last tag method with fast access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_MOD, + TM_POW, + TM_DIV, + TM_IDIV, + TM_BAND, + TM_BOR, + TM_BXOR, + TM_SHL, + TM_SHR, + TM_UNM, + TM_BNOT, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +#define ttypename(x) luaT_typenames_[(x) + 1] + +LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; + + +LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, TValue *p3, int hasres); +LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event); +LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event); +LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, + const TValue *p2, TMS event); + + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lua.h b/dep/scintilla/scintilla-3.10.6/lua/src/lua.h new file mode 100644 index 00000000..26c0e2d6 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lua.h @@ -0,0 +1,486 @@ +/* +** $Id: lua.h,v 1.332 2016/12/22 15:51:20 roberto Exp $ +** Lua - A Scripting Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "3" +#define LUA_VERSION_NUM 503 +#define LUA_VERSION_RELEASE "4" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2017 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" + + +/* mark for precompiled code ('Lua') */ +#define LUA_SIGNATURE "\x1bLua" + +/* option for multiple returns in 'lua_pcall' and 'lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** Pseudo-indices +** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty +** space after that to help overflow detection) +*/ +#define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000) +#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) + + +/* thread status */ +#define LUA_OK 0 +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRGCMM 5 +#define LUA_ERRERR 6 + + +typedef struct lua_State lua_State; + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + +#define LUA_NUMTAGS 9 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* predefined values in the registry */ +#define LUA_RIDX_MAINTHREAD 1 +#define LUA_RIDX_GLOBALS 2 +#define LUA_RIDX_LAST LUA_RIDX_GLOBALS + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + +/* unsigned integer type */ +typedef LUA_UNSIGNED lua_Unsigned; + +/* type for continuation-function contexts */ +typedef LUA_KCONTEXT lua_KContext; + + +/* +** Type for C functions registered with Lua +*/ +typedef int (*lua_CFunction) (lua_State *L); + +/* +** Type for continuation functions +*/ +typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); + + +/* +** Type for functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud); + + +/* +** Type for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* +** RCS ident string +*/ +extern const char lua_ident[]; + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +LUA_API const lua_Number *(lua_version) (lua_State *L); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_absindex) (lua_State *L, int idx); +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_rotate) (lua_State *L, int idx, int n); +LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); +LUA_API int (lua_checkstack) (lua_State *L, int n); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isinteger) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); +LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_rawlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** Comparison and arithmetic functions +*/ + +#define LUA_OPADD 0 /* ORDER TM, ORDER OP */ +#define LUA_OPSUB 1 +#define LUA_OPMUL 2 +#define LUA_OPMOD 3 +#define LUA_OPPOW 4 +#define LUA_OPDIV 5 +#define LUA_OPIDIV 6 +#define LUA_OPBAND 7 +#define LUA_OPBOR 8 +#define LUA_OPBXOR 9 +#define LUA_OPSHL 10 +#define LUA_OPSHR 11 +#define LUA_OPUNM 12 +#define LUA_OPBNOT 13 + +LUA_API void (lua_arith) (lua_State *L, int op); + +#define LUA_OPEQ 0 +#define LUA_OPLT 1 +#define LUA_OPLE 2 + +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len); +LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API int (lua_getglobal) (lua_State *L, const char *name); +LUA_API int (lua_gettable) (lua_State *L, int idx); +LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n); +LUA_API int (lua_rawget) (lua_State *L, int idx); +LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n); +LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p); + +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API int (lua_getuservalue) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_setglobal) (lua_State *L, const char *name); +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n); +LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API void (lua_setuservalue) (lua_State *L, int idx); + + +/* +** 'load' and 'call' functions (load and run Lua code) +*/ +LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, + lua_KContext ctx, lua_KFunction k); +#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) + +LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, + lua_KContext ctx, lua_KFunction k); +#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) + +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname, const char *mode); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx, + lua_KFunction k); +LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); +LUA_API int (lua_status) (lua_State *L); +LUA_API int (lua_isyieldable) (lua_State *L); + +#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) + + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 +#define LUA_GCISRUNNING 9 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); +LUA_API void (lua_len) (lua_State *L, int idx); + +LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** {============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE)) + +#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) +#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) lua_pushstring(L, "" s) + +#define lua_pushglobaltable(L) \ + ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + +#define lua_insert(L,idx) lua_rotate(L, (idx), 1) + +#define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1)) + +#define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1)) + +/* }============================================================== */ + + +/* +** {============================================================== +** compatibility macros for unsigned conversions +** =============================================================== +*/ +#if defined(LUA_COMPAT_APIINTCASTS) + +#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) +#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is)) +#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) + +#endif +/* }============================================================== */ + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILCALL 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debugger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); +LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); +LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); + +LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); +LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, + int fidx2, int n2); + +LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook (lua_gethook) (lua_State *L); +LUA_API int (lua_gethookmask) (lua_State *L); +LUA_API int (lua_gethookcount) (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ + const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + unsigned char nups; /* (u) number of upvalues */ + unsigned char nparams;/* (u) number of parameters */ + char isvararg; /* (u) */ + char istailcall; /* (t) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + struct CallInfo *i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2017 Lua.org, PUC-Rio. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lua.hpp b/dep/scintilla/scintilla-3.10.6/lua/src/lua.hpp new file mode 100644 index 00000000..ec417f59 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/luaconf.h b/dep/scintilla/scintilla-3.10.6/lua/src/luaconf.h new file mode 100644 index 00000000..f37bea09 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/luaconf.h @@ -0,0 +1,783 @@ +/* +** $Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef luaconf_h +#define luaconf_h + +#include +#include + + +/* +** =================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +** {==================================================================== +** System Configuration: macros to adapt (if needed) Lua to some +** particular platform, for instance compiling it with 32-bit numbers or +** restricting it to C89. +** ===================================================================== +*/ + +/* +@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You +** can also define LUA_32BITS in the make file, but changing here you +** ensure that all software connected to Lua will be compiled with the +** same configuration. +*/ +/* #define LUA_32BITS */ + + +/* +@@ LUA_USE_C89 controls the use of non-ISO-C89 features. +** Define it if you want Lua to avoid the use of a few C99 features +** or Windows-specific features on Windows. +*/ +/* #define LUA_USE_C89 */ + + +/* +** By default, Lua on Windows use (some) specific Windows features +*/ +#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) +#define LUA_USE_WINDOWS /* enable goodies for regular Windows */ +#endif + + +#if defined(LUA_USE_WINDOWS) +#define LUA_DL_DLL /* enable support for DLL */ +#define LUA_USE_C89 /* broadly, Windows is C89 */ +#endif + + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* MacOS does not need -ldl */ +#define LUA_USE_READLINE /* needs an extra library: -lreadline */ +#endif + + +/* +@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for +** C89 ('long' and 'double'); Windows always has '__int64', so it does +** not need to use this case. +*/ +#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) +#define LUA_C89_NUMBERS +#endif + + + +/* +@@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. +*/ +/* avoid undefined shifts */ +#if ((INT_MAX >> 15) >> 15) >= 1 +#define LUAI_BITSINT 32 +#else +/* 'int' always must have at least 16 bits */ +#define LUAI_BITSINT 16 +#endif + + +/* +@@ LUA_INT_TYPE defines the type for Lua integers. +@@ LUA_FLOAT_TYPE defines the type for Lua floats. +** Lua should work fine with any mix of these options (if supported +** by your C compiler). The usual configurations are 64-bit integers +** and 'double' (the default), 32-bit integers and 'float' (for +** restricted platforms), and 'long'/'double' (for C compilers not +** compliant with C99, which may not have support for 'long long'). +*/ + +/* predefined options for LUA_INT_TYPE */ +#define LUA_INT_INT 1 +#define LUA_INT_LONG 2 +#define LUA_INT_LONGLONG 3 + +/* predefined options for LUA_FLOAT_TYPE */ +#define LUA_FLOAT_FLOAT 1 +#define LUA_FLOAT_DOUBLE 2 +#define LUA_FLOAT_LONGDOUBLE 3 + +#if defined(LUA_32BITS) /* { */ +/* +** 32-bit integers and 'float' +*/ +#if LUAI_BITSINT >= 32 /* use 'int' if big enough */ +#define LUA_INT_TYPE LUA_INT_INT +#else /* otherwise use 'long' */ +#define LUA_INT_TYPE LUA_INT_LONG +#endif +#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT + +#elif defined(LUA_C89_NUMBERS) /* }{ */ +/* +** largest types available for C89 ('long' and 'double') +*/ +#define LUA_INT_TYPE LUA_INT_LONG +#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE + +#endif /* } */ + + +/* +** default configuration for 64-bit Lua ('long long' and 'double') +*/ +#if !defined(LUA_INT_TYPE) +#define LUA_INT_TYPE LUA_INT_LONGLONG +#endif + +#if !defined(LUA_FLOAT_TYPE) +#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE +#endif + +/* }================================================================== */ + + + + +/* +** {================================================================== +** Configuration for Paths. +** =================================================================== +*/ + +/* +** LUA_PATH_SEP is the character that separates templates in a path. +** LUA_PATH_MARK is the string that marks the substitution points in a +** template. +** LUA_EXEC_DIR in a Windows path is replaced by the executable's +** directory. +*/ +#define LUA_PATH_SEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXEC_DIR "!" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +** Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +** C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#if defined(_WIN32) /* { */ +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ + LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ + ".\\?.lua;" ".\\?\\init.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.dll;" \ + LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ + LUA_CDIR"loadall.dll;" ".\\?.dll" + +#else /* }{ */ + +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" +#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ + "./?.lua;" "./?/init.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" +#endif /* } */ + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + +/* }================================================================== */ + + +/* +** {================================================================== +** Marks for exported symbols in the C code +** =================================================================== +*/ + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all auxiliary library functions. +@@ LUAMOD_API is a mark for all standard library opening functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) /* { */ + +#if defined(LUA_CORE) || defined(LUA_LIB) /* { */ +#define LUA_API __declspec(dllexport) +#else /* }{ */ +#define LUA_API __declspec(dllimport) +#endif /* } */ + +#else /* }{ */ + +#define LUA_API extern + +#endif /* } */ + + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API +#define LUAMOD_API LUALIB_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +** exported to outside modules. +@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables +** that are not to be exported to outside modules (LUAI_DDEF for +** definitions and LUAI_DDEC for declarations). +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. Not all elf targets support +** this attribute. Unfortunately, gcc does not offer a way to check +** whether the target offers that support, and those without support +** give a warning about it. To avoid these warnings, change to the +** default definition. +*/ +#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) /* { */ +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#else /* }{ */ +#define LUAI_FUNC extern +#endif /* } */ + +#define LUAI_DDEC LUAI_FUNC +#define LUAI_DDEF /* empty */ + +/* }================================================================== */ + + +/* +** {================================================================== +** Compatibility with previous versions +** =================================================================== +*/ + +/* +@@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2. +@@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1. +** You can define it to get all options, or change specific options +** to fit your specific needs. +*/ +#if defined(LUA_COMPAT_5_2) /* { */ + +/* +@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated +** functions in the mathematical library. +*/ +#define LUA_COMPAT_MATHLIB + +/* +@@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. +*/ +#define LUA_COMPAT_BITLIB + +/* +@@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod. +*/ +#define LUA_COMPAT_IPAIRS + +/* +@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for +** manipulating other integer types (lua_pushunsigned, lua_tounsigned, +** luaL_checkint, luaL_checklong, etc.) +*/ +#define LUA_COMPAT_APIINTCASTS + +#endif /* } */ + + +#if defined(LUA_COMPAT_5_1) /* { */ + +/* Incompatibilities from 5.2 -> 5.3 */ +#define LUA_COMPAT_MATHLIB +#define LUA_COMPAT_APIINTCASTS + +/* +@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. +** You can replace it with 'table.unpack'. +*/ +#define LUA_COMPAT_UNPACK + +/* +@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. +** You can replace it with 'package.searchers'. +*/ +#define LUA_COMPAT_LOADERS + +/* +@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. +** You can call your C function directly (with light C functions). +*/ +#define lua_cpcall(L,f,u) \ + (lua_pushcfunction(L, (f)), \ + lua_pushlightuserdata(L,(u)), \ + lua_pcall(L,1,0,0)) + + +/* +@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. +** You can rewrite 'log10(x)' as 'log(x, 10)'. +*/ +#define LUA_COMPAT_LOG10 + +/* +@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base +** library. You can rewrite 'loadstring(s)' as 'load(s)'. +*/ +#define LUA_COMPAT_LOADSTRING + +/* +@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. +*/ +#define LUA_COMPAT_MAXN + +/* +@@ The following macros supply trivial compatibility for some +** changes in the API. The macros themselves document how to +** change your code to avoid using them. +*/ +#define lua_strlen(L,i) lua_rawlen(L, (i)) + +#define lua_objlen(L,i) lua_rawlen(L, (i)) + +#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) +#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) + +/* +@@ LUA_COMPAT_MODULE controls compatibility with previous +** module functions 'module' (Lua) and 'luaL_register' (C). +*/ +#define LUA_COMPAT_MODULE + +#endif /* } */ + + +/* +@@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a +@@ a float mark ('.0'). +** This macro is not on by default even in compatibility mode, +** because this is not really an incompatibility. +*/ +/* #define LUA_COMPAT_FLOATSTRING */ + +/* }================================================================== */ + + + +/* +** {================================================================== +** Configuration for Numbers. +** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* +** satisfy your needs. +** =================================================================== +*/ + +/* +@@ LUA_NUMBER is the floating-point type used by Lua. +@@ LUAI_UACNUMBER is the result of a 'default argument promotion' +@@ over a floating number. +@@ l_mathlim(x) corrects limit name 'x' to the proper float type +** by prefixing it with one of FLT/DBL/LDBL. +@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. +@@ LUA_NUMBER_FMT is the format for writing floats. +@@ lua_number2str converts a float to a string. +@@ l_mathop allows the addition of an 'l' or 'f' to all math operations. +@@ l_floor takes the floor of a float. +@@ lua_str2number converts a decimal numeric string to a number. +*/ + + +/* The following definitions are good for most cases here */ + +#define l_floor(x) (l_mathop(floor)(x)) + +#define lua_number2str(s,sz,n) \ + l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n)) + +/* +@@ lua_numbertointeger converts a float number to an integer, or +** returns 0 if float is not within the range of a lua_Integer. +** (The range comparisons are tricky because of rounding. The tests +** here assume a two-complement representation, where MININTEGER always +** has an exact representation as a float; MAXINTEGER may not have one, +** and therefore its conversion to float may have an ill-defined value.) +*/ +#define lua_numbertointeger(n,p) \ + ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ + (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ + (*(p) = (LUA_INTEGER)(n), 1)) + + +/* now the variable definitions */ + +#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ + +#define LUA_NUMBER float + +#define l_mathlim(n) (FLT_##n) + +#define LUAI_UACNUMBER double + +#define LUA_NUMBER_FRMLEN "" +#define LUA_NUMBER_FMT "%.7g" + +#define l_mathop(op) op##f + +#define lua_str2number(s,p) strtof((s), (p)) + + +#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */ + +#define LUA_NUMBER long double + +#define l_mathlim(n) (LDBL_##n) + +#define LUAI_UACNUMBER long double + +#define LUA_NUMBER_FRMLEN "L" +#define LUA_NUMBER_FMT "%.19Lg" + +#define l_mathop(op) op##l + +#define lua_str2number(s,p) strtold((s), (p)) + +#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */ + +#define LUA_NUMBER double + +#define l_mathlim(n) (DBL_##n) + +#define LUAI_UACNUMBER double + +#define LUA_NUMBER_FRMLEN "" +#define LUA_NUMBER_FMT "%.14g" + +#define l_mathop(op) op + +#define lua_str2number(s,p) strtod((s), (p)) + +#else /* }{ */ + +#error "numeric float type not defined" + +#endif /* } */ + + + +/* +@@ LUA_INTEGER is the integer type used by Lua. +** +@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. +** +@@ LUAI_UACINT is the result of a 'default argument promotion' +@@ over a lUA_INTEGER. +@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. +@@ LUA_INTEGER_FMT is the format for writing integers. +@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. +@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. +@@ lua_integer2str converts an integer to a string. +*/ + + +/* The following definitions are good for most cases here */ + +#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" + +#define LUAI_UACINT LUA_INTEGER + +#define lua_integer2str(s,sz,n) \ + l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n)) + +/* +** use LUAI_UACINT here to avoid problems with promotions (which +** can turn a comparison between unsigneds into a signed comparison) +*/ +#define LUA_UNSIGNED unsigned LUAI_UACINT + + +/* now the variable definitions */ + +#if LUA_INT_TYPE == LUA_INT_INT /* { int */ + +#define LUA_INTEGER int +#define LUA_INTEGER_FRMLEN "" + +#define LUA_MAXINTEGER INT_MAX +#define LUA_MININTEGER INT_MIN + +#elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ + +#define LUA_INTEGER long +#define LUA_INTEGER_FRMLEN "l" + +#define LUA_MAXINTEGER LONG_MAX +#define LUA_MININTEGER LONG_MIN + +#elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ + +/* use presence of macro LLONG_MAX as proxy for C99 compliance */ +#if defined(LLONG_MAX) /* { */ +/* use ISO C99 stuff */ + +#define LUA_INTEGER long long +#define LUA_INTEGER_FRMLEN "ll" + +#define LUA_MAXINTEGER LLONG_MAX +#define LUA_MININTEGER LLONG_MIN + +#elif defined(LUA_USE_WINDOWS) /* }{ */ +/* in Windows, can use specific Windows types */ + +#define LUA_INTEGER __int64 +#define LUA_INTEGER_FRMLEN "I64" + +#define LUA_MAXINTEGER _I64_MAX +#define LUA_MININTEGER _I64_MIN + +#else /* }{ */ + +#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ + or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" + +#endif /* } */ + +#else /* }{ */ + +#error "numeric integer type not defined" + +#endif /* } */ + +/* }================================================================== */ + + +/* +** {================================================================== +** Dependencies with C99 and other C details +** =================================================================== +*/ + +/* +@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89. +** (All uses in Lua have only one format item.) +*/ +#if !defined(LUA_USE_C89) +#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) +#else +#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) +#endif + + +/* +@@ lua_strx2number converts an hexadecimal numeric string to a number. +** In C99, 'strtod' does that conversion. Otherwise, you can +** leave 'lua_strx2number' undefined and Lua will provide its own +** implementation. +*/ +#if !defined(LUA_USE_C89) +#define lua_strx2number(s,p) lua_str2number(s,p) +#endif + + +/* +@@ lua_number2strx converts a float to an hexadecimal numeric string. +** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. +** Otherwise, you can leave 'lua_number2strx' undefined and Lua will +** provide its own implementation. +*/ +#if !defined(LUA_USE_C89) +#define lua_number2strx(L,b,sz,f,n) \ + ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n))) +#endif + + +/* +** 'strtof' and 'opf' variants for math functions are not valid in +** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the +** availability of these variants. ('math.h' is already included in +** all files that use these macros.) +*/ +#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) +#undef l_mathop /* variants not available */ +#undef lua_str2number +#define l_mathop(op) (lua_Number)op /* no variant */ +#define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) +#endif + + +/* +@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation +** functions. It must be a numerical type; Lua will use 'intptr_t' if +** available, otherwise it will use 'ptrdiff_t' (the nearest thing to +** 'intptr_t' in C89) +*/ +#define LUA_KCONTEXT ptrdiff_t + +#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ + __STDC_VERSION__ >= 199901L +#include +#if defined(INTPTR_MAX) /* even in C99 this type is optional */ +#undef LUA_KCONTEXT +#define LUA_KCONTEXT intptr_t +#endif +#endif + + +/* +@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). +** Change that if you do not want to use C locales. (Code using this +** macro must include header 'locale.h'.) +*/ +#if !defined(lua_getlocaledecpoint) +#define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) +#endif + +/* }================================================================== */ + + +/* +** {================================================================== +** Language Variations +** ===================================================================== +*/ + +/* +@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some +** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from +** numbers to strings. Define LUA_NOCVTS2N to turn off automatic +** coercion from strings to numbers. +*/ +/* #define LUA_NOCVTN2S */ +/* #define LUA_NOCVTS2N */ + + +/* +@@ LUA_USE_APICHECK turns on several consistency checks on the C API. +** Define it as a help when debugging C code. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(l,e) assert(e) +#endif + +/* }================================================================== */ + + +/* +** {================================================================== +** Macros that affect the API and must be stable (that is, must be the +** same when you compile Lua and when you compile code that links to +** Lua). You probably do not want/need to change them. +** ===================================================================== +*/ + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua from consuming unlimited stack +** space (and to reserve some numbers for pseudo-indices). +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_MAXSTACK 1000000 +#else +#define LUAI_MAXSTACK 15000 +#endif + + +/* +@@ LUA_EXTRASPACE defines the size of a raw memory area associated with +** a Lua state with very fast access. +** CHANGE it if you need a different size. +*/ +#define LUA_EXTRASPACE (sizeof(void *)) + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@@ of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +** CHANGE it if it uses too much C-stack space. (For long double, +** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a +** smaller buffer would force a memory allocation for each call to +** 'string.format'.) +*/ +#if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE +#define LUAL_BUFFERSIZE 8192 +#else +#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer))) +#endif + +/* }================================================================== */ + + +/* +@@ LUA_QL describes how error messages quote program elements. +** Lua does not use these macros anymore; they are here for +** compatibility only. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + + + +#endif + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lualib.h b/dep/scintilla/scintilla-3.10.6/lua/src/lualib.h new file mode 100644 index 00000000..6c0bc4cb --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lualib.h @@ -0,0 +1,61 @@ +/* +** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* version suffix for environment variable names */ +#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR + + +LUAMOD_API int (luaopen_base) (lua_State *L); + +#define LUA_COLIBNAME "coroutine" +LUAMOD_API int (luaopen_coroutine) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUAMOD_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUAMOD_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUAMOD_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUAMOD_API int (luaopen_string) (lua_State *L); + +#define LUA_UTF8LIBNAME "utf8" +LUAMOD_API int (luaopen_utf8) (lua_State *L); + +#define LUA_BITLIBNAME "bit32" +LUAMOD_API int (luaopen_bit32) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUAMOD_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUAMOD_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUAMOD_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#if !defined(lua_assert) +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lundump.c b/dep/scintilla/scintilla-3.10.6/lua/src/lundump.c new file mode 100644 index 00000000..4080af9c --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lundump.c @@ -0,0 +1,279 @@ +/* +** $Id: lundump.c,v 2.44 2015/11/02 16:09:30 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#define lundump_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstring.h" +#include "lundump.h" +#include "lzio.h" + + +#if !defined(luai_verifycode) +#define luai_verifycode(L,b,f) /* empty */ +#endif + + +typedef struct { + lua_State *L; + ZIO *Z; + const char *name; +} LoadState; + + +static l_noret error(LoadState *S, const char *why) { + luaO_pushfstring(S->L, "%s: %s precompiled chunk", S->name, why); + luaD_throw(S->L, LUA_ERRSYNTAX); +} + + +/* +** All high-level loads go through LoadVector; you can change it to +** adapt to the endianness of the input +*/ +#define LoadVector(S,b,n) LoadBlock(S,b,(n)*sizeof((b)[0])) + +static void LoadBlock (LoadState *S, void *b, size_t size) { + if (luaZ_read(S->Z, b, size) != 0) + error(S, "truncated"); +} + + +#define LoadVar(S,x) LoadVector(S,&x,1) + + +static lu_byte LoadByte (LoadState *S) { + lu_byte x; + LoadVar(S, x); + return x; +} + + +static int LoadInt (LoadState *S) { + int x; + LoadVar(S, x); + return x; +} + + +static lua_Number LoadNumber (LoadState *S) { + lua_Number x; + LoadVar(S, x); + return x; +} + + +static lua_Integer LoadInteger (LoadState *S) { + lua_Integer x; + LoadVar(S, x); + return x; +} + + +static TString *LoadString (LoadState *S) { + size_t size = LoadByte(S); + if (size == 0xFF) + LoadVar(S, size); + if (size == 0) + return NULL; + else if (--size <= LUAI_MAXSHORTLEN) { /* short string? */ + char buff[LUAI_MAXSHORTLEN]; + LoadVector(S, buff, size); + return luaS_newlstr(S->L, buff, size); + } + else { /* long string */ + TString *ts = luaS_createlngstrobj(S->L, size); + LoadVector(S, getstr(ts), size); /* load directly in final place */ + return ts; + } +} + + +static void LoadCode (LoadState *S, Proto *f) { + int n = LoadInt(S); + f->code = luaM_newvector(S->L, n, Instruction); + f->sizecode = n; + LoadVector(S, f->code, n); +} + + +static void LoadFunction(LoadState *S, Proto *f, TString *psource); + + +static void LoadConstants (LoadState *S, Proto *f) { + int i; + int n = LoadInt(S); + f->k = luaM_newvector(S->L, n, TValue); + f->sizek = n; + for (i = 0; i < n; i++) + setnilvalue(&f->k[i]); + for (i = 0; i < n; i++) { + TValue *o = &f->k[i]; + int t = LoadByte(S); + switch (t) { + case LUA_TNIL: + setnilvalue(o); + break; + case LUA_TBOOLEAN: + setbvalue(o, LoadByte(S)); + break; + case LUA_TNUMFLT: + setfltvalue(o, LoadNumber(S)); + break; + case LUA_TNUMINT: + setivalue(o, LoadInteger(S)); + break; + case LUA_TSHRSTR: + case LUA_TLNGSTR: + setsvalue2n(S->L, o, LoadString(S)); + break; + default: + lua_assert(0); + } + } +} + + +static void LoadProtos (LoadState *S, Proto *f) { + int i; + int n = LoadInt(S); + f->p = luaM_newvector(S->L, n, Proto *); + f->sizep = n; + for (i = 0; i < n; i++) + f->p[i] = NULL; + for (i = 0; i < n; i++) { + f->p[i] = luaF_newproto(S->L); + LoadFunction(S, f->p[i], f->source); + } +} + + +static void LoadUpvalues (LoadState *S, Proto *f) { + int i, n; + n = LoadInt(S); + f->upvalues = luaM_newvector(S->L, n, Upvaldesc); + f->sizeupvalues = n; + for (i = 0; i < n; i++) + f->upvalues[i].name = NULL; + for (i = 0; i < n; i++) { + f->upvalues[i].instack = LoadByte(S); + f->upvalues[i].idx = LoadByte(S); + } +} + + +static void LoadDebug (LoadState *S, Proto *f) { + int i, n; + n = LoadInt(S); + f->lineinfo = luaM_newvector(S->L, n, int); + f->sizelineinfo = n; + LoadVector(S, f->lineinfo, n); + n = LoadInt(S); + f->locvars = luaM_newvector(S->L, n, LocVar); + f->sizelocvars = n; + for (i = 0; i < n; i++) + f->locvars[i].varname = NULL; + for (i = 0; i < n; i++) { + f->locvars[i].varname = LoadString(S); + f->locvars[i].startpc = LoadInt(S); + f->locvars[i].endpc = LoadInt(S); + } + n = LoadInt(S); + for (i = 0; i < n; i++) + f->upvalues[i].name = LoadString(S); +} + + +static void LoadFunction (LoadState *S, Proto *f, TString *psource) { + f->source = LoadString(S); + if (f->source == NULL) /* no source in dump? */ + f->source = psource; /* reuse parent's source */ + f->linedefined = LoadInt(S); + f->lastlinedefined = LoadInt(S); + f->numparams = LoadByte(S); + f->is_vararg = LoadByte(S); + f->maxstacksize = LoadByte(S); + LoadCode(S, f); + LoadConstants(S, f); + LoadUpvalues(S, f); + LoadProtos(S, f); + LoadDebug(S, f); +} + + +static void checkliteral (LoadState *S, const char *s, const char *msg) { + char buff[sizeof(LUA_SIGNATURE) + sizeof(LUAC_DATA)]; /* larger than both */ + size_t len = strlen(s); + LoadVector(S, buff, len); + if (memcmp(s, buff, len) != 0) + error(S, msg); +} + + +static void fchecksize (LoadState *S, size_t size, const char *tname) { + if (LoadByte(S) != size) + error(S, luaO_pushfstring(S->L, "%s size mismatch in", tname)); +} + + +#define checksize(S,t) fchecksize(S,sizeof(t),#t) + +static void checkHeader (LoadState *S) { + checkliteral(S, LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */ + if (LoadByte(S) != LUAC_VERSION) + error(S, "version mismatch in"); + if (LoadByte(S) != LUAC_FORMAT) + error(S, "format mismatch in"); + checkliteral(S, LUAC_DATA, "corrupted"); + checksize(S, int); + checksize(S, size_t); + checksize(S, Instruction); + checksize(S, lua_Integer); + checksize(S, lua_Number); + if (LoadInteger(S) != LUAC_INT) + error(S, "endianness mismatch in"); + if (LoadNumber(S) != LUAC_NUM) + error(S, "float format mismatch in"); +} + + +/* +** load precompiled chunk +*/ +LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) { + LoadState S; + LClosure *cl; + if (*name == '@' || *name == '=') + S.name = name + 1; + else if (*name == LUA_SIGNATURE[0]) + S.name = "binary string"; + else + S.name = name; + S.L = L; + S.Z = Z; + checkHeader(&S); + cl = luaF_newLclosure(L, LoadByte(&S)); + setclLvalue(L, L->top, cl); + luaD_inctop(L); + cl->p = luaF_newproto(L); + LoadFunction(&S, cl->p, NULL); + lua_assert(cl->nupvalues == cl->p->sizeupvalues); + luai_verifycode(L, buff, cl->p); + return cl; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lundump.h b/dep/scintilla/scintilla-3.10.6/lua/src/lundump.h new file mode 100644 index 00000000..aa5cc82f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lundump.h @@ -0,0 +1,32 @@ +/* +** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* data to catch conversion errors */ +#define LUAC_DATA "\x19\x93\r\n\x1a\n" + +#define LUAC_INT 0x5678 +#define LUAC_NUM cast_num(370.5) + +#define MYINT(s) (s[0]-'0') +#define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) +#define LUAC_FORMAT 0 /* this is the official format */ + +/* load one chunk; from lundump.c */ +LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, + void* data, int strip); + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lutf8lib.c b/dep/scintilla/scintilla-3.10.6/lua/src/lutf8lib.c new file mode 100644 index 00000000..de9e3dcd --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lutf8lib.c @@ -0,0 +1,256 @@ +/* +** $Id: lutf8lib.c,v 1.16 2016/12/22 13:08:50 roberto Exp $ +** Standard library for UTF-8 manipulation +** See Copyright Notice in lua.h +*/ + +#define lutf8lib_c +#define LUA_LIB + +#include "lprefix.h" + + +#include +#include +#include +#include + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + +#define MAXUNICODE 0x10FFFF + +#define iscont(p) ((*(p) & 0xC0) == 0x80) + + +/* from strlib */ +/* translate a relative string position: negative means back from end */ +static lua_Integer u_posrelat (lua_Integer pos, size_t len) { + if (pos >= 0) return pos; + else if (0u - (size_t)pos > len) return 0; + else return (lua_Integer)len + pos + 1; +} + + +/* +** Decode one UTF-8 sequence, returning NULL if byte sequence is invalid. +*/ +static const char *utf8_decode (const char *o, int *val) { + static const unsigned int limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFF}; + const unsigned char *s = (const unsigned char *)o; + unsigned int c = s[0]; + unsigned int res = 0; /* final result */ + if (c < 0x80) /* ascii? */ + res = c; + else { + int count = 0; /* to count number of continuation bytes */ + while (c & 0x40) { /* still have continuation bytes? */ + int cc = s[++count]; /* read next byte */ + if ((cc & 0xC0) != 0x80) /* not a continuation byte? */ + return NULL; /* invalid byte sequence */ + res = (res << 6) | (cc & 0x3F); /* add lower 6 bits from cont. byte */ + c <<= 1; /* to test next bit */ + } + res |= ((c & 0x7F) << (count * 5)); /* add first byte */ + if (count > 3 || res > MAXUNICODE || res <= limits[count]) + return NULL; /* invalid byte sequence */ + s += count; /* skip continuation bytes read */ + } + if (val) *val = res; + return (const char *)s + 1; /* +1 to include first byte */ +} + + +/* +** utf8len(s [, i [, j]]) --> number of characters that start in the +** range [i,j], or nil + current position if 's' is not well formed in +** that interval +*/ +static int utflen (lua_State *L) { + int n = 0; + size_t len; + const char *s = luaL_checklstring(L, 1, &len); + lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len); + lua_Integer posj = u_posrelat(luaL_optinteger(L, 3, -1), len); + luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 2, + "initial position out of string"); + luaL_argcheck(L, --posj < (lua_Integer)len, 3, + "final position out of string"); + while (posi <= posj) { + const char *s1 = utf8_decode(s + posi, NULL); + if (s1 == NULL) { /* conversion error? */ + lua_pushnil(L); /* return nil ... */ + lua_pushinteger(L, posi + 1); /* ... and current position */ + return 2; + } + posi = s1 - s; + n++; + } + lua_pushinteger(L, n); + return 1; +} + + +/* +** codepoint(s, [i, [j]]) -> returns codepoints for all characters +** that start in the range [i,j] +*/ +static int codepoint (lua_State *L) { + size_t len; + const char *s = luaL_checklstring(L, 1, &len); + lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len); + lua_Integer pose = u_posrelat(luaL_optinteger(L, 3, posi), len); + int n; + const char *se; + luaL_argcheck(L, posi >= 1, 2, "out of range"); + luaL_argcheck(L, pose <= (lua_Integer)len, 3, "out of range"); + if (posi > pose) return 0; /* empty interval; return no values */ + if (pose - posi >= INT_MAX) /* (lua_Integer -> int) overflow? */ + return luaL_error(L, "string slice too long"); + n = (int)(pose - posi) + 1; + luaL_checkstack(L, n, "string slice too long"); + n = 0; + se = s + pose; + for (s += posi - 1; s < se;) { + int code; + s = utf8_decode(s, &code); + if (s == NULL) + return luaL_error(L, "invalid UTF-8 code"); + lua_pushinteger(L, code); + n++; + } + return n; +} + + +static void pushutfchar (lua_State *L, int arg) { + lua_Integer code = luaL_checkinteger(L, arg); + luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range"); + lua_pushfstring(L, "%U", (long)code); +} + + +/* +** utfchar(n1, n2, ...) -> char(n1)..char(n2)... +*/ +static int utfchar (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + if (n == 1) /* optimize common case of single char */ + pushutfchar(L, 1); + else { + int i; + luaL_Buffer b; + luaL_buffinit(L, &b); + for (i = 1; i <= n; i++) { + pushutfchar(L, i); + luaL_addvalue(&b); + } + luaL_pushresult(&b); + } + return 1; +} + + +/* +** offset(s, n, [i]) -> index where n-th character counting from +** position 'i' starts; 0 means character at 'i'. +*/ +static int byteoffset (lua_State *L) { + size_t len; + const char *s = luaL_checklstring(L, 1, &len); + lua_Integer n = luaL_checkinteger(L, 2); + lua_Integer posi = (n >= 0) ? 1 : len + 1; + posi = u_posrelat(luaL_optinteger(L, 3, posi), len); + luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 3, + "position out of range"); + if (n == 0) { + /* find beginning of current byte sequence */ + while (posi > 0 && iscont(s + posi)) posi--; + } + else { + if (iscont(s + posi)) + luaL_error(L, "initial position is a continuation byte"); + if (n < 0) { + while (n < 0 && posi > 0) { /* move back */ + do { /* find beginning of previous character */ + posi--; + } while (posi > 0 && iscont(s + posi)); + n++; + } + } + else { + n--; /* do not move for 1st character */ + while (n > 0 && posi < (lua_Integer)len) { + do { /* find beginning of next character */ + posi++; + } while (iscont(s + posi)); /* (cannot pass final '\0') */ + n--; + } + } + } + if (n == 0) /* did it find given character? */ + lua_pushinteger(L, posi + 1); + else /* no such character */ + lua_pushnil(L); + return 1; +} + + +static int iter_aux (lua_State *L) { + size_t len; + const char *s = luaL_checklstring(L, 1, &len); + lua_Integer n = lua_tointeger(L, 2) - 1; + if (n < 0) /* first iteration? */ + n = 0; /* start from here */ + else if (n < (lua_Integer)len) { + n++; /* skip current byte */ + while (iscont(s + n)) n++; /* and its continuations */ + } + if (n >= (lua_Integer)len) + return 0; /* no more codepoints */ + else { + int code; + const char *next = utf8_decode(s + n, &code); + if (next == NULL || iscont(next)) + return luaL_error(L, "invalid UTF-8 code"); + lua_pushinteger(L, n + 1); + lua_pushinteger(L, code); + return 2; + } +} + + +static int iter_codes (lua_State *L) { + luaL_checkstring(L, 1); + lua_pushcfunction(L, iter_aux); + lua_pushvalue(L, 1); + lua_pushinteger(L, 0); + return 3; +} + + +/* pattern to match a single UTF-8 character */ +#define UTF8PATT "[\0-\x7F\xC2-\xF4][\x80-\xBF]*" + + +static const luaL_Reg funcs[] = { + {"offset", byteoffset}, + {"codepoint", codepoint}, + {"char", utfchar}, + {"len", utflen}, + {"codes", iter_codes}, + /* placeholders */ + {"charpattern", NULL}, + {NULL, NULL} +}; + + +LUAMOD_API int luaopen_utf8 (lua_State *L) { + luaL_newlib(L, funcs); + lua_pushlstring(L, UTF8PATT, sizeof(UTF8PATT)/sizeof(char) - 1); + lua_setfield(L, -2, "charpattern"); + return 1; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lvm.c b/dep/scintilla/scintilla-3.10.6/lua/src/lvm.c new file mode 100644 index 00000000..84ade6b2 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lvm.c @@ -0,0 +1,1322 @@ +/* +** $Id: lvm.c,v 2.268 2016/02/05 19:59:14 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#define lvm_c +#define LUA_CORE + +#include "lprefix.h" + +#include +#include +#include +#include +#include +#include + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + +/* limit for table tag-method chains (to avoid loops) */ +#define MAXTAGLOOP 2000 + + + +/* +** 'l_intfitsf' checks whether a given integer can be converted to a +** float without rounding. Used in comparisons. Left undefined if +** all integers fit in a float precisely. +*/ +#if !defined(l_intfitsf) + +/* number of bits in the mantissa of a float */ +#define NBM (l_mathlim(MANT_DIG)) + +/* +** Check whether some integers may not fit in a float, that is, whether +** (maxinteger >> NBM) > 0 (that implies (1 << NBM) <= maxinteger). +** (The shifts are done in parts to avoid shifting by more than the size +** of an integer. In a worst case, NBM == 113 for long double and +** sizeof(integer) == 32.) +*/ +#if ((((LUA_MAXINTEGER >> (NBM / 4)) >> (NBM / 4)) >> (NBM / 4)) \ + >> (NBM - (3 * (NBM / 4)))) > 0 + +#define l_intfitsf(i) \ + (-((lua_Integer)1 << NBM) <= (i) && (i) <= ((lua_Integer)1 << NBM)) + +#endif + +#endif + + + +/* +** Try to convert a value to a float. The float case is already handled +** by the macro 'tonumber'. +*/ +int luaV_tonumber_ (const TValue *obj, lua_Number *n) { + TValue v; + if (ttisinteger(obj)) { + *n = cast_num(ivalue(obj)); + return 1; + } + else if (cvt2num(obj) && /* string convertible to number? */ + luaO_str2num(svalue(obj), &v) == vslen(obj) + 1) { + *n = nvalue(&v); /* convert result of 'luaO_str2num' to a float */ + return 1; + } + else + return 0; /* conversion failed */ +} + + +/* +** try to convert a value to an integer, rounding according to 'mode': +** mode == 0: accepts only integral values +** mode == 1: takes the floor of the number +** mode == 2: takes the ceil of the number +*/ +int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode) { + TValue v; + again: + if (ttisfloat(obj)) { + lua_Number n = fltvalue(obj); + lua_Number f = l_floor(n); + if (n != f) { /* not an integral value? */ + if (mode == 0) return 0; /* fails if mode demands integral value */ + else if (mode > 1) /* needs ceil? */ + f += 1; /* convert floor to ceil (remember: n != f) */ + } + return lua_numbertointeger(f, p); + } + else if (ttisinteger(obj)) { + *p = ivalue(obj); + return 1; + } + else if (cvt2num(obj) && + luaO_str2num(svalue(obj), &v) == vslen(obj) + 1) { + obj = &v; + goto again; /* convert result from 'luaO_str2num' to an integer */ + } + return 0; /* conversion failed */ +} + + +/* +** Try to convert a 'for' limit to an integer, preserving the +** semantics of the loop. +** (The following explanation assumes a non-negative step; it is valid +** for negative steps mutatis mutandis.) +** If the limit can be converted to an integer, rounding down, that is +** it. +** Otherwise, check whether the limit can be converted to a number. If +** the number is too large, it is OK to set the limit as LUA_MAXINTEGER, +** which means no limit. If the number is too negative, the loop +** should not run, because any initial integer value is larger than the +** limit. So, it sets the limit to LUA_MININTEGER. 'stopnow' corrects +** the extreme case when the initial value is LUA_MININTEGER, in which +** case the LUA_MININTEGER limit would still run the loop once. +*/ +static int forlimit (const TValue *obj, lua_Integer *p, lua_Integer step, + int *stopnow) { + *stopnow = 0; /* usually, let loops run */ + if (!luaV_tointeger(obj, p, (step < 0 ? 2 : 1))) { /* not fit in integer? */ + lua_Number n; /* try to convert to float */ + if (!tonumber(obj, &n)) /* cannot convert to float? */ + return 0; /* not a number */ + if (luai_numlt(0, n)) { /* if true, float is larger than max integer */ + *p = LUA_MAXINTEGER; + if (step < 0) *stopnow = 1; + } + else { /* float is smaller than min integer */ + *p = LUA_MININTEGER; + if (step >= 0) *stopnow = 1; + } + } + return 1; +} + + +/* +** Finish the table access 'val = t[key]'. +** if 'slot' is NULL, 't' is not a table; otherwise, 'slot' points to +** t[k] entry (which must be nil). +*/ +void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, + const TValue *slot) { + int loop; /* counter to avoid infinite loops */ + const TValue *tm; /* metamethod */ + for (loop = 0; loop < MAXTAGLOOP; loop++) { + if (slot == NULL) { /* 't' is not a table? */ + lua_assert(!ttistable(t)); + tm = luaT_gettmbyobj(L, t, TM_INDEX); + if (ttisnil(tm)) + luaG_typeerror(L, t, "index"); /* no metamethod */ + /* else will try the metamethod */ + } + else { /* 't' is a table */ + lua_assert(ttisnil(slot)); + tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */ + if (tm == NULL) { /* no metamethod? */ + setnilvalue(val); /* result is nil */ + return; + } + /* else will try the metamethod */ + } + if (ttisfunction(tm)) { /* is metamethod a function? */ + luaT_callTM(L, tm, t, key, val, 1); /* call it */ + return; + } + t = tm; /* else try to access 'tm[key]' */ + if (luaV_fastget(L,t,key,slot,luaH_get)) { /* fast track? */ + setobj2s(L, val, slot); /* done */ + return; + } + /* else repeat (tail call 'luaV_finishget') */ + } + luaG_runerror(L, "'__index' chain too long; possible loop"); +} + + +/* +** Finish a table assignment 't[key] = val'. +** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points +** to the entry 't[key]', or to 'luaO_nilobject' if there is no such +** entry. (The value at 'slot' must be nil, otherwise 'luaV_fastset' +** would have done the job.) +*/ +void luaV_finishset (lua_State *L, const TValue *t, TValue *key, + StkId val, const TValue *slot) { + int loop; /* counter to avoid infinite loops */ + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; /* '__newindex' metamethod */ + if (slot != NULL) { /* is 't' a table? */ + Table *h = hvalue(t); /* save 't' table */ + lua_assert(ttisnil(slot)); /* old value must be nil */ + tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */ + if (tm == NULL) { /* no metamethod? */ + if (slot == luaO_nilobject) /* no previous entry? */ + slot = luaH_newkey(L, h, key); /* create one */ + /* no metamethod and (now) there is an entry with given key */ + setobj2t(L, cast(TValue *, slot), val); /* set its new value */ + invalidateTMcache(h); + luaC_barrierback(L, h, val); + return; + } + /* else will try the metamethod */ + } + else { /* not a table; check metamethod */ + if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + } + /* try the metamethod */ + if (ttisfunction(tm)) { + luaT_callTM(L, tm, t, key, val, 0); + return; + } + t = tm; /* else repeat assignment over 'tm' */ + if (luaV_fastset(L, t, key, slot, luaH_get, val)) + return; /* done */ + /* else loop */ + } + luaG_runerror(L, "'__newindex' chain too long; possible loop"); +} + + +/* +** Compare two strings 'ls' x 'rs', returning an integer smaller-equal- +** -larger than zero if 'ls' is smaller-equal-larger than 'rs'. +** The code is a little tricky because it allows '\0' in the strings +** and it uses 'strcoll' (to respect locales) for each segments +** of the strings. +*/ +static int l_strcmp (const TString *ls, const TString *rs) { + const char *l = getstr(ls); + size_t ll = tsslen(ls); + const char *r = getstr(rs); + size_t lr = tsslen(rs); + for (;;) { /* for each segment */ + int temp = strcoll(l, r); + if (temp != 0) /* not equal? */ + return temp; /* done */ + else { /* strings are equal up to a '\0' */ + size_t len = strlen(l); /* index of first '\0' in both strings */ + if (len == lr) /* 'rs' is finished? */ + return (len == ll) ? 0 : 1; /* check 'ls' */ + else if (len == ll) /* 'ls' is finished? */ + return -1; /* 'ls' is smaller than 'rs' ('rs' is not finished) */ + /* both strings longer than 'len'; go on comparing after the '\0' */ + len++; + l += len; ll -= len; r += len; lr -= len; + } + } +} + + +/* +** Check whether integer 'i' is less than float 'f'. If 'i' has an +** exact representation as a float ('l_intfitsf'), compare numbers as +** floats. Otherwise, if 'f' is outside the range for integers, result +** is trivial. Otherwise, compare them as integers. (When 'i' has no +** float representation, either 'f' is "far away" from 'i' or 'f' has +** no precision left for a fractional part; either way, how 'f' is +** truncated is irrelevant.) When 'f' is NaN, comparisons must result +** in false. +*/ +static int LTintfloat (lua_Integer i, lua_Number f) { +#if defined(l_intfitsf) + if (!l_intfitsf(i)) { + if (f >= -cast_num(LUA_MININTEGER)) /* -minint == maxint + 1 */ + return 1; /* f >= maxint + 1 > i */ + else if (f > cast_num(LUA_MININTEGER)) /* minint < f <= maxint ? */ + return (i < cast(lua_Integer, f)); /* compare them as integers */ + else /* f <= minint <= i (or 'f' is NaN) --> not(i < f) */ + return 0; + } +#endif + return luai_numlt(cast_num(i), f); /* compare them as floats */ +} + + +/* +** Check whether integer 'i' is less than or equal to float 'f'. +** See comments on previous function. +*/ +static int LEintfloat (lua_Integer i, lua_Number f) { +#if defined(l_intfitsf) + if (!l_intfitsf(i)) { + if (f >= -cast_num(LUA_MININTEGER)) /* -minint == maxint + 1 */ + return 1; /* f >= maxint + 1 > i */ + else if (f >= cast_num(LUA_MININTEGER)) /* minint <= f <= maxint ? */ + return (i <= cast(lua_Integer, f)); /* compare them as integers */ + else /* f < minint <= i (or 'f' is NaN) --> not(i <= f) */ + return 0; + } +#endif + return luai_numle(cast_num(i), f); /* compare them as floats */ +} + + +/* +** Return 'l < r', for numbers. +*/ +static int LTnum (const TValue *l, const TValue *r) { + if (ttisinteger(l)) { + lua_Integer li = ivalue(l); + if (ttisinteger(r)) + return li < ivalue(r); /* both are integers */ + else /* 'l' is int and 'r' is float */ + return LTintfloat(li, fltvalue(r)); /* l < r ? */ + } + else { + lua_Number lf = fltvalue(l); /* 'l' must be float */ + if (ttisfloat(r)) + return luai_numlt(lf, fltvalue(r)); /* both are float */ + else if (luai_numisnan(lf)) /* 'r' is int and 'l' is float */ + return 0; /* NaN < i is always false */ + else /* without NaN, (l < r) <--> not(r <= l) */ + return !LEintfloat(ivalue(r), lf); /* not (r <= l) ? */ + } +} + + +/* +** Return 'l <= r', for numbers. +*/ +static int LEnum (const TValue *l, const TValue *r) { + if (ttisinteger(l)) { + lua_Integer li = ivalue(l); + if (ttisinteger(r)) + return li <= ivalue(r); /* both are integers */ + else /* 'l' is int and 'r' is float */ + return LEintfloat(li, fltvalue(r)); /* l <= r ? */ + } + else { + lua_Number lf = fltvalue(l); /* 'l' must be float */ + if (ttisfloat(r)) + return luai_numle(lf, fltvalue(r)); /* both are float */ + else if (luai_numisnan(lf)) /* 'r' is int and 'l' is float */ + return 0; /* NaN <= i is always false */ + else /* without NaN, (l <= r) <--> not(r < l) */ + return !LTintfloat(ivalue(r), lf); /* not (r < l) ? */ + } +} + + +/* +** Main operation less than; return 'l < r'. +*/ +int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttisnumber(l) && ttisnumber(r)) /* both operands are numbers? */ + return LTnum(l, r); + else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ + return l_strcmp(tsvalue(l), tsvalue(r)) < 0; + else if ((res = luaT_callorderTM(L, l, r, TM_LT)) < 0) /* no metamethod? */ + luaG_ordererror(L, l, r); /* error */ + return res; +} + + +/* +** Main operation less than or equal to; return 'l <= r'. If it needs +** a metamethod and there is no '__le', try '__lt', based on +** l <= r iff !(r < l) (assuming a total order). If the metamethod +** yields during this substitution, the continuation has to know +** about it (to negate the result of r= 0) /* try 'le' */ + return res; + else { /* try 'lt': */ + L->ci->callstatus |= CIST_LEQ; /* mark it is doing 'lt' for 'le' */ + res = luaT_callorderTM(L, r, l, TM_LT); + L->ci->callstatus ^= CIST_LEQ; /* clear mark */ + if (res < 0) + luaG_ordererror(L, l, r); + return !res; /* result is negated */ + } +} + + +/* +** Main operation for equality of Lua values; return 't1 == t2'. +** L == NULL means raw equality (no metamethods) +*/ +int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { + const TValue *tm; + if (ttype(t1) != ttype(t2)) { /* not the same variant? */ + if (ttnov(t1) != ttnov(t2) || ttnov(t1) != LUA_TNUMBER) + return 0; /* only numbers can be equal with different variants */ + else { /* two numbers with different variants */ + lua_Integer i1, i2; /* compare them as integers */ + return (tointeger(t1, &i1) && tointeger(t2, &i2) && i1 == i2); + } + } + /* values have same type and same variant */ + switch (ttype(t1)) { + case LUA_TNIL: return 1; + case LUA_TNUMINT: return (ivalue(t1) == ivalue(t2)); + case LUA_TNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2)); + case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ + case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TLCF: return fvalue(t1) == fvalue(t2); + case LUA_TSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2)); + case LUA_TLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2)); + case LUA_TUSERDATA: { + if (uvalue(t1) == uvalue(t2)) return 1; + else if (L == NULL) return 0; + tm = fasttm(L, uvalue(t1)->metatable, TM_EQ); + if (tm == NULL) + tm = fasttm(L, uvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + case LUA_TTABLE: { + if (hvalue(t1) == hvalue(t2)) return 1; + else if (L == NULL) return 0; + tm = fasttm(L, hvalue(t1)->metatable, TM_EQ); + if (tm == NULL) + tm = fasttm(L, hvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + default: + return gcvalue(t1) == gcvalue(t2); + } + if (tm == NULL) /* no TM? */ + return 0; /* objects are different */ + luaT_callTM(L, tm, t1, t2, L->top, 1); /* call TM */ + return !l_isfalse(L->top); +} + + +/* macro used by 'luaV_concat' to ensure that element at 'o' is a string */ +#define tostring(L,o) \ + (ttisstring(o) || (cvt2str(o) && (luaO_tostring(L, o), 1))) + +#define isemptystr(o) (ttisshrstring(o) && tsvalue(o)->shrlen == 0) + +/* copy strings in stack from top - n up to top - 1 to buffer */ +static void copy2buff (StkId top, int n, char *buff) { + size_t tl = 0; /* size already copied */ + do { + size_t l = vslen(top - n); /* length of string being copied */ + memcpy(buff + tl, svalue(top - n), l * sizeof(char)); + tl += l; + } while (--n > 0); +} + + +/* +** Main operation for concatenation: concat 'total' values in the stack, +** from 'L->top - total' up to 'L->top - 1'. +*/ +void luaV_concat (lua_State *L, int total) { + lua_assert(total >= 2); + do { + StkId top = L->top; + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(top-2) || cvt2str(top-2)) || !tostring(L, top-1)) + luaT_trybinTM(L, top-2, top-1, top-2, TM_CONCAT); + else if (isemptystr(top - 1)) /* second operand is empty? */ + cast_void(tostring(L, top - 2)); /* result is first operand */ + else if (isemptystr(top - 2)) { /* first operand is an empty string? */ + setobjs2s(L, top - 2, top - 1); /* result is second op. */ + } + else { + /* at least two non-empty string values; get as many as possible */ + size_t tl = vslen(top - 1); + TString *ts; + /* collect total length and number of strings */ + for (n = 1; n < total && tostring(L, top - n - 1); n++) { + size_t l = vslen(top - n - 1); + if (l >= (MAX_SIZE/sizeof(char)) - tl) + luaG_runerror(L, "string length overflow"); + tl += l; + } + if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */ + char buff[LUAI_MAXSHORTLEN]; + copy2buff(top, n, buff); /* copy strings to buffer */ + ts = luaS_newlstr(L, buff, tl); + } + else { /* long string; copy strings directly to final result */ + ts = luaS_createlngstrobj(L, tl); + copy2buff(top, n, getstr(ts)); + } + setsvalue2s(L, top - n, ts); /* create result */ + } + total -= n-1; /* got 'n' strings to create 1 new */ + L->top -= n-1; /* popped 'n' strings and pushed one */ + } while (total > 1); /* repeat until only 1 result left */ +} + + +/* +** Main operation 'ra' = #rb'. +*/ +void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { + const TValue *tm; + switch (ttype(rb)) { + case LUA_TTABLE: { + Table *h = hvalue(rb); + tm = fasttm(L, h->metatable, TM_LEN); + if (tm) break; /* metamethod? break switch to call it */ + setivalue(ra, luaH_getn(h)); /* else primitive len */ + return; + } + case LUA_TSHRSTR: { + setivalue(ra, tsvalue(rb)->shrlen); + return; + } + case LUA_TLNGSTR: { + setivalue(ra, tsvalue(rb)->u.lnglen); + return; + } + default: { /* try metamethod */ + tm = luaT_gettmbyobj(L, rb, TM_LEN); + if (ttisnil(tm)) /* no metamethod? */ + luaG_typeerror(L, rb, "get length of"); + break; + } + } + luaT_callTM(L, tm, rb, rb, ra, 1); +} + + +/* +** Integer division; return 'm // n', that is, floor(m/n). +** C division truncates its result (rounds towards zero). +** 'floor(q) == trunc(q)' when 'q >= 0' or when 'q' is integer, +** otherwise 'floor(q) == trunc(q) - 1'. +*/ +lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n) { + if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */ + if (n == 0) + luaG_runerror(L, "attempt to divide by zero"); + return intop(-, 0, m); /* n==-1; avoid overflow with 0x80000...//-1 */ + } + else { + lua_Integer q = m / n; /* perform C division */ + if ((m ^ n) < 0 && m % n != 0) /* 'm/n' would be negative non-integer? */ + q -= 1; /* correct result for different rounding */ + return q; + } +} + + +/* +** Integer modulus; return 'm % n'. (Assume that C '%' with +** negative operands follows C99 behavior. See previous comment +** about luaV_div.) +*/ +lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) { + if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */ + if (n == 0) + luaG_runerror(L, "attempt to perform 'n%%0'"); + return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */ + } + else { + lua_Integer r = m % n; + if (r != 0 && (m ^ n) < 0) /* 'm/n' would be non-integer negative? */ + r += n; /* correct result for different rounding */ + return r; + } +} + + +/* number of bits in an integer */ +#define NBITS cast_int(sizeof(lua_Integer) * CHAR_BIT) + +/* +** Shift left operation. (Shift right just negates 'y'.) +*/ +lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { + if (y < 0) { /* shift right? */ + if (y <= -NBITS) return 0; + else return intop(>>, x, -y); + } + else { /* shift left */ + if (y >= NBITS) return 0; + else return intop(<<, x, y); + } +} + + +/* +** check whether cached closure in prototype 'p' may be reused, that is, +** whether there is a cached closure with the same upvalues needed by +** new closure to be created. +*/ +static LClosure *getcached (Proto *p, UpVal **encup, StkId base) { + LClosure *c = p->cache; + if (c != NULL) { /* is there a cached closure? */ + int nup = p->sizeupvalues; + Upvaldesc *uv = p->upvalues; + int i; + for (i = 0; i < nup; i++) { /* check whether it has right upvalues */ + TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v; + if (c->upvals[i]->v != v) + return NULL; /* wrong upvalue; cannot reuse closure */ + } + } + return c; /* return cached closure (or NULL if no cached closure) */ +} + + +/* +** create a new Lua closure, push it in the stack, and initialize +** its upvalues. Note that the closure is not cached if prototype is +** already black (which means that 'cache' was already cleared by the +** GC). +*/ +static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, + StkId ra) { + int nup = p->sizeupvalues; + Upvaldesc *uv = p->upvalues; + int i; + LClosure *ncl = luaF_newLclosure(L, nup); + ncl->p = p; + setclLvalue(L, ra, ncl); /* anchor new closure in stack */ + for (i = 0; i < nup; i++) { /* fill in its upvalues */ + if (uv[i].instack) /* upvalue refers to local variable? */ + ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx); + else /* get upvalue from enclosing function */ + ncl->upvals[i] = encup[uv[i].idx]; + ncl->upvals[i]->refcount++; + /* new closure is white, so we do not need a barrier here */ + } + if (!isblack(p)) /* cache will not break GC invariant? */ + p->cache = ncl; /* save it on cache for reuse */ +} + + +/* +** finish execution of an opcode interrupted by an yield +*/ +void luaV_finishOp (lua_State *L) { + CallInfo *ci = L->ci; + StkId base = ci->u.l.base; + Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */ + OpCode op = GET_OPCODE(inst); + switch (op) { /* finish its execution */ + case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: case OP_IDIV: + case OP_BAND: case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: + case OP_MOD: case OP_POW: + case OP_UNM: case OP_BNOT: case OP_LEN: + case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: { + setobjs2s(L, base + GETARG_A(inst), --L->top); + break; + } + case OP_LE: case OP_LT: case OP_EQ: { + int res = !l_isfalse(L->top - 1); + L->top--; + if (ci->callstatus & CIST_LEQ) { /* "<=" using "<" instead? */ + lua_assert(op == OP_LE); + ci->callstatus ^= CIST_LEQ; /* clear mark */ + res = !res; /* negate result */ + } + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); + if (res != GETARG_A(inst)) /* condition failed? */ + ci->u.l.savedpc++; /* skip jump instruction */ + break; + } + case OP_CONCAT: { + StkId top = L->top - 1; /* top when 'luaT_trybinTM' was called */ + int b = GETARG_B(inst); /* first element to concatenate */ + int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */ + setobj2s(L, top - 2, top); /* put TM result in proper position */ + if (total > 1) { /* are there elements to concat? */ + L->top = top - 1; /* top is one after last element (at top-2) */ + luaV_concat(L, total); /* concat them (may yield again) */ + } + /* move final result to final position */ + setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1); + L->top = ci->top; /* restore top */ + break; + } + case OP_TFORCALL: { + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_TFORLOOP); + L->top = ci->top; /* correct top */ + break; + } + case OP_CALL: { + if (GETARG_C(inst) - 1 >= 0) /* nresults >= 0? */ + L->top = ci->top; /* adjust results */ + break; + } + case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE: + break; + default: lua_assert(0); + } +} + + + + +/* +** {================================================================== +** Function 'luaV_execute': main interpreter loop +** =================================================================== +*/ + + +/* +** some macros for common tasks in 'luaV_execute' +*/ + + +#define RA(i) (base+GETARG_A(i)) +#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) +#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) +#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) +#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) + + +/* execute a jump instruction */ +#define dojump(ci,i,e) \ + { int a = GETARG_A(i); \ + if (a != 0) luaF_close(L, ci->u.l.base + a - 1); \ + ci->u.l.savedpc += GETARG_sBx(i) + e; } + +/* for test instructions, execute the jump instruction that follows it */ +#define donextjump(ci) { i = *ci->u.l.savedpc; dojump(ci, i, 1); } + + +#define Protect(x) { {x;}; base = ci->u.l.base; } + +#define checkGC(L,c) \ + { luaC_condGC(L, L->top = (c), /* limit of live values */ \ + Protect(L->top = ci->top)); /* restore top */ \ + luai_threadyield(L); } + + +/* fetch an instruction and prepare its execution */ +#define vmfetch() { \ + i = *(ci->u.l.savedpc++); \ + if (L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) \ + Protect(luaG_traceexec(L)); \ + ra = RA(i); /* WARNING: any stack reallocation invalidates 'ra' */ \ + lua_assert(base == ci->u.l.base); \ + lua_assert(base <= L->top && L->top < L->stack + L->stacksize); \ +} + +#define vmdispatch(o) switch(o) +#define vmcase(l) case l: +#define vmbreak break + + +/* +** copy of 'luaV_gettable', but protecting the call to potential +** metamethod (which can reallocate the stack) +*/ +#define gettableProtected(L,t,k,v) { const TValue *slot; \ + if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ + else Protect(luaV_finishget(L,t,k,v,slot)); } + + +/* same for 'luaV_settable' */ +#define settableProtected(L,t,k,v) { const TValue *slot; \ + if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \ + Protect(luaV_finishset(L,t,k,v,slot)); } + + + +void luaV_execute (lua_State *L) { + CallInfo *ci = L->ci; + LClosure *cl; + TValue *k; + StkId base; + ci->callstatus |= CIST_FRESH; /* fresh invocation of 'luaV_execute" */ + newframe: /* reentry point when frame changes (call/return) */ + lua_assert(ci == L->ci); + cl = clLvalue(ci->func); /* local reference to function's closure */ + k = cl->p->k; /* local reference to function's constant table */ + base = ci->u.l.base; /* local copy of function's base */ + /* main loop of interpreter */ + for (;;) { + Instruction i; + StkId ra; + vmfetch(); + vmdispatch (GET_OPCODE(i)) { + vmcase(OP_MOVE) { + setobjs2s(L, ra, RB(i)); + vmbreak; + } + vmcase(OP_LOADK) { + TValue *rb = k + GETARG_Bx(i); + setobj2s(L, ra, rb); + vmbreak; + } + vmcase(OP_LOADKX) { + TValue *rb; + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); + rb = k + GETARG_Ax(*ci->u.l.savedpc++); + setobj2s(L, ra, rb); + vmbreak; + } + vmcase(OP_LOADBOOL) { + setbvalue(ra, GETARG_B(i)); + if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */ + vmbreak; + } + vmcase(OP_LOADNIL) { + int b = GETARG_B(i); + do { + setnilvalue(ra++); + } while (b--); + vmbreak; + } + vmcase(OP_GETUPVAL) { + int b = GETARG_B(i); + setobj2s(L, ra, cl->upvals[b]->v); + vmbreak; + } + vmcase(OP_GETTABUP) { + TValue *upval = cl->upvals[GETARG_B(i)]->v; + TValue *rc = RKC(i); + gettableProtected(L, upval, rc, ra); + vmbreak; + } + vmcase(OP_GETTABLE) { + StkId rb = RB(i); + TValue *rc = RKC(i); + gettableProtected(L, rb, rc, ra); + vmbreak; + } + vmcase(OP_SETTABUP) { + TValue *upval = cl->upvals[GETARG_A(i)]->v; + TValue *rb = RKB(i); + TValue *rc = RKC(i); + settableProtected(L, upval, rb, rc); + vmbreak; + } + vmcase(OP_SETUPVAL) { + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v, ra); + luaC_upvalbarrier(L, uv); + vmbreak; + } + vmcase(OP_SETTABLE) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + settableProtected(L, ra, rb, rc); + vmbreak; + } + vmcase(OP_NEWTABLE) { + int b = GETARG_B(i); + int c = GETARG_C(i); + Table *t = luaH_new(L); + sethvalue(L, ra, t); + if (b != 0 || c != 0) + luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); + checkGC(L, ra + 1); + vmbreak; + } + vmcase(OP_SELF) { + const TValue *aux; + StkId rb = RB(i); + TValue *rc = RKC(i); + TString *key = tsvalue(rc); /* key must be a string */ + setobjs2s(L, ra + 1, rb); + if (luaV_fastget(L, rb, key, aux, luaH_getstr)) { + setobj2s(L, ra, aux); + } + else Protect(luaV_finishget(L, rb, rc, ra, aux)); + vmbreak; + } + vmcase(OP_ADD) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Number nb; lua_Number nc; + if (ttisinteger(rb) && ttisinteger(rc)) { + lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); + setivalue(ra, intop(+, ib, ic)); + } + else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { + setfltvalue(ra, luai_numadd(L, nb, nc)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); } + vmbreak; + } + vmcase(OP_SUB) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Number nb; lua_Number nc; + if (ttisinteger(rb) && ttisinteger(rc)) { + lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); + setivalue(ra, intop(-, ib, ic)); + } + else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { + setfltvalue(ra, luai_numsub(L, nb, nc)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); } + vmbreak; + } + vmcase(OP_MUL) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Number nb; lua_Number nc; + if (ttisinteger(rb) && ttisinteger(rc)) { + lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); + setivalue(ra, intop(*, ib, ic)); + } + else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { + setfltvalue(ra, luai_nummul(L, nb, nc)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); } + vmbreak; + } + vmcase(OP_DIV) { /* float division (always with floats) */ + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Number nb; lua_Number nc; + if (tonumber(rb, &nb) && tonumber(rc, &nc)) { + setfltvalue(ra, luai_numdiv(L, nb, nc)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); } + vmbreak; + } + vmcase(OP_BAND) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Integer ib; lua_Integer ic; + if (tointeger(rb, &ib) && tointeger(rc, &ic)) { + setivalue(ra, intop(&, ib, ic)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); } + vmbreak; + } + vmcase(OP_BOR) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Integer ib; lua_Integer ic; + if (tointeger(rb, &ib) && tointeger(rc, &ic)) { + setivalue(ra, intop(|, ib, ic)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); } + vmbreak; + } + vmcase(OP_BXOR) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Integer ib; lua_Integer ic; + if (tointeger(rb, &ib) && tointeger(rc, &ic)) { + setivalue(ra, intop(^, ib, ic)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); } + vmbreak; + } + vmcase(OP_SHL) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Integer ib; lua_Integer ic; + if (tointeger(rb, &ib) && tointeger(rc, &ic)) { + setivalue(ra, luaV_shiftl(ib, ic)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); } + vmbreak; + } + vmcase(OP_SHR) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Integer ib; lua_Integer ic; + if (tointeger(rb, &ib) && tointeger(rc, &ic)) { + setivalue(ra, luaV_shiftl(ib, -ic)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); } + vmbreak; + } + vmcase(OP_MOD) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Number nb; lua_Number nc; + if (ttisinteger(rb) && ttisinteger(rc)) { + lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); + setivalue(ra, luaV_mod(L, ib, ic)); + } + else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { + lua_Number m; + luai_nummod(L, nb, nc, m); + setfltvalue(ra, m); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); } + vmbreak; + } + vmcase(OP_IDIV) { /* floor division */ + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Number nb; lua_Number nc; + if (ttisinteger(rb) && ttisinteger(rc)) { + lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); + setivalue(ra, luaV_div(L, ib, ic)); + } + else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { + setfltvalue(ra, luai_numidiv(L, nb, nc)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); } + vmbreak; + } + vmcase(OP_POW) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + lua_Number nb; lua_Number nc; + if (tonumber(rb, &nb) && tonumber(rc, &nc)) { + setfltvalue(ra, luai_numpow(L, nb, nc)); + } + else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); } + vmbreak; + } + vmcase(OP_UNM) { + TValue *rb = RB(i); + lua_Number nb; + if (ttisinteger(rb)) { + lua_Integer ib = ivalue(rb); + setivalue(ra, intop(-, 0, ib)); + } + else if (tonumber(rb, &nb)) { + setfltvalue(ra, luai_numunm(L, nb)); + } + else { + Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); + } + vmbreak; + } + vmcase(OP_BNOT) { + TValue *rb = RB(i); + lua_Integer ib; + if (tointeger(rb, &ib)) { + setivalue(ra, intop(^, ~l_castS2U(0), ib)); + } + else { + Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); + } + vmbreak; + } + vmcase(OP_NOT) { + TValue *rb = RB(i); + int res = l_isfalse(rb); /* next assignment may change this value */ + setbvalue(ra, res); + vmbreak; + } + vmcase(OP_LEN) { + Protect(luaV_objlen(L, ra, RB(i))); + vmbreak; + } + vmcase(OP_CONCAT) { + int b = GETARG_B(i); + int c = GETARG_C(i); + StkId rb; + L->top = base + c + 1; /* mark the end of concat operands */ + Protect(luaV_concat(L, c - b + 1)); + ra = RA(i); /* 'luaV_concat' may invoke TMs and move the stack */ + rb = base + b; + setobjs2s(L, ra, rb); + checkGC(L, (ra >= rb ? ra + 1 : rb)); + L->top = ci->top; /* restore top */ + vmbreak; + } + vmcase(OP_JMP) { + dojump(ci, i, 0); + vmbreak; + } + vmcase(OP_EQ) { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect( + if (luaV_equalobj(L, rb, rc) != GETARG_A(i)) + ci->u.l.savedpc++; + else + donextjump(ci); + ) + vmbreak; + } + vmcase(OP_LT) { + Protect( + if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) + ci->u.l.savedpc++; + else + donextjump(ci); + ) + vmbreak; + } + vmcase(OP_LE) { + Protect( + if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) + ci->u.l.savedpc++; + else + donextjump(ci); + ) + vmbreak; + } + vmcase(OP_TEST) { + if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra)) + ci->u.l.savedpc++; + else + donextjump(ci); + vmbreak; + } + vmcase(OP_TESTSET) { + TValue *rb = RB(i); + if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb)) + ci->u.l.savedpc++; + else { + setobjs2s(L, ra, rb); + donextjump(ci); + } + vmbreak; + } + vmcase(OP_CALL) { + int b = GETARG_B(i); + int nresults = GETARG_C(i) - 1; + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + if (luaD_precall(L, ra, nresults)) { /* C function? */ + if (nresults >= 0) + L->top = ci->top; /* adjust results */ + Protect((void)0); /* update 'base' */ + } + else { /* Lua function */ + ci = L->ci; + goto newframe; /* restart luaV_execute over new Lua function */ + } + vmbreak; + } + vmcase(OP_TAILCALL) { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); + if (luaD_precall(L, ra, LUA_MULTRET)) { /* C function? */ + Protect((void)0); /* update 'base' */ + } + else { + /* tail call: put called frame (n) in place of caller one (o) */ + CallInfo *nci = L->ci; /* called frame */ + CallInfo *oci = nci->previous; /* caller frame */ + StkId nfunc = nci->func; /* called function */ + StkId ofunc = oci->func; /* caller function */ + /* last stack slot filled by 'precall' */ + StkId lim = nci->u.l.base + getproto(nfunc)->numparams; + int aux; + /* close all upvalues from previous call */ + if (cl->p->sizep > 0) luaF_close(L, oci->u.l.base); + /* move new frame into old one */ + for (aux = 0; nfunc + aux < lim; aux++) + setobjs2s(L, ofunc + aux, nfunc + aux); + oci->u.l.base = ofunc + (nci->u.l.base - nfunc); /* correct base */ + oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */ + oci->u.l.savedpc = nci->u.l.savedpc; + oci->callstatus |= CIST_TAIL; /* function was tail called */ + ci = L->ci = oci; /* remove new frame */ + lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); + goto newframe; /* restart luaV_execute over new Lua function */ + } + vmbreak; + } + vmcase(OP_RETURN) { + int b = GETARG_B(i); + if (cl->p->sizep > 0) luaF_close(L, base); + b = luaD_poscall(L, ci, ra, (b != 0 ? b - 1 : cast_int(L->top - ra))); + if (ci->callstatus & CIST_FRESH) /* local 'ci' still from callee */ + return; /* external invocation: return */ + else { /* invocation via reentry: continue execution */ + ci = L->ci; + if (b) L->top = ci->top; + lua_assert(isLua(ci)); + lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL); + goto newframe; /* restart luaV_execute over new Lua function */ + } + } + vmcase(OP_FORLOOP) { + if (ttisinteger(ra)) { /* integer loop? */ + lua_Integer step = ivalue(ra + 2); + lua_Integer idx = intop(+, ivalue(ra), step); /* increment index */ + lua_Integer limit = ivalue(ra + 1); + if ((0 < step) ? (idx <= limit) : (limit <= idx)) { + ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ + chgivalue(ra, idx); /* update internal index... */ + setivalue(ra + 3, idx); /* ...and external index */ + } + } + else { /* floating loop */ + lua_Number step = fltvalue(ra + 2); + lua_Number idx = luai_numadd(L, fltvalue(ra), step); /* inc. index */ + lua_Number limit = fltvalue(ra + 1); + if (luai_numlt(0, step) ? luai_numle(idx, limit) + : luai_numle(limit, idx)) { + ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ + chgfltvalue(ra, idx); /* update internal index... */ + setfltvalue(ra + 3, idx); /* ...and external index */ + } + } + vmbreak; + } + vmcase(OP_FORPREP) { + TValue *init = ra; + TValue *plimit = ra + 1; + TValue *pstep = ra + 2; + lua_Integer ilimit; + int stopnow; + if (ttisinteger(init) && ttisinteger(pstep) && + forlimit(plimit, &ilimit, ivalue(pstep), &stopnow)) { + /* all values are integer */ + lua_Integer initv = (stopnow ? 0 : ivalue(init)); + setivalue(plimit, ilimit); + setivalue(init, intop(-, initv, ivalue(pstep))); + } + else { /* try making all values floats */ + lua_Number ninit; lua_Number nlimit; lua_Number nstep; + if (!tonumber(plimit, &nlimit)) + luaG_runerror(L, "'for' limit must be a number"); + setfltvalue(plimit, nlimit); + if (!tonumber(pstep, &nstep)) + luaG_runerror(L, "'for' step must be a number"); + setfltvalue(pstep, nstep); + if (!tonumber(init, &ninit)) + luaG_runerror(L, "'for' initial value must be a number"); + setfltvalue(init, luai_numsub(L, ninit, nstep)); + } + ci->u.l.savedpc += GETARG_sBx(i); + vmbreak; + } + vmcase(OP_TFORCALL) { + StkId cb = ra + 3; /* call base */ + setobjs2s(L, cb+2, ra+2); + setobjs2s(L, cb+1, ra+1); + setobjs2s(L, cb, ra); + L->top = cb + 3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i))); + L->top = ci->top; + i = *(ci->u.l.savedpc++); /* go to next instruction */ + ra = RA(i); + lua_assert(GET_OPCODE(i) == OP_TFORLOOP); + goto l_tforloop; + } + vmcase(OP_TFORLOOP) { + l_tforloop: + if (!ttisnil(ra + 1)) { /* continue loop? */ + setobjs2s(L, ra, ra + 1); /* save control variable */ + ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ + } + vmbreak; + } + vmcase(OP_SETLIST) { + int n = GETARG_B(i); + int c = GETARG_C(i); + unsigned int last; + Table *h; + if (n == 0) n = cast_int(L->top - ra) - 1; + if (c == 0) { + lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); + c = GETARG_Ax(*ci->u.l.savedpc++); + } + h = hvalue(ra); + last = ((c-1)*LFIELDS_PER_FLUSH) + n; + if (last > h->sizearray) /* needs more space? */ + luaH_resizearray(L, h, last); /* preallocate it at once */ + for (; n > 0; n--) { + TValue *val = ra+n; + luaH_setint(L, h, last--, val); + luaC_barrierback(L, h, val); + } + L->top = ci->top; /* correct top (in case of previous open call) */ + vmbreak; + } + vmcase(OP_CLOSURE) { + Proto *p = cl->p->p[GETARG_Bx(i)]; + LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */ + if (ncl == NULL) /* no match? */ + pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ + else + setclLvalue(L, ra, ncl); /* push cashed closure */ + checkGC(L, ra + 1); + vmbreak; + } + vmcase(OP_VARARG) { + int b = GETARG_B(i) - 1; /* required results */ + int j; + int n = cast_int(base - ci->func) - cl->p->numparams - 1; + if (n < 0) /* less arguments than parameters? */ + n = 0; /* no vararg arguments */ + if (b < 0) { /* B == 0? */ + b = n; /* get all var. arguments */ + Protect(luaD_checkstack(L, n)); + ra = RA(i); /* previous call may change the stack */ + L->top = ra + n; + } + for (j = 0; j < b && j < n; j++) + setobjs2s(L, ra + j, base - n + j); + for (; j < b; j++) /* complete required results with nil */ + setnilvalue(ra + j); + vmbreak; + } + vmcase(OP_EXTRAARG) { + lua_assert(0); + vmbreak; + } + } + } +} + +/* }================================================================== */ + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lvm.h b/dep/scintilla/scintilla-3.10.6/lua/src/lvm.h new file mode 100644 index 00000000..422f8719 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lvm.h @@ -0,0 +1,113 @@ +/* +** $Id: lvm.h,v 2.41 2016/12/22 13:08:50 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#if !defined(LUA_NOCVTN2S) +#define cvt2str(o) ttisnumber(o) +#else +#define cvt2str(o) 0 /* no conversion from numbers to strings */ +#endif + + +#if !defined(LUA_NOCVTS2N) +#define cvt2num(o) ttisstring(o) +#else +#define cvt2num(o) 0 /* no conversion from strings to numbers */ +#endif + + +/* +** You can define LUA_FLOORN2I if you want to convert floats to integers +** by flooring them (instead of raising an error if they are not +** integral values) +*/ +#if !defined(LUA_FLOORN2I) +#define LUA_FLOORN2I 0 +#endif + + +#define tonumber(o,n) \ + (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) + +#define tointeger(o,i) \ + (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger(o,i,LUA_FLOORN2I)) + +#define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) + +#define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) + + +/* +** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, +** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise, +** return 0 (meaning it will have to check metamethod) with 'slot' +** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise). +** 'f' is the raw get function to use. +*/ +#define luaV_fastget(L,t,k,slot,f) \ + (!ttistable(t) \ + ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ + : (slot = f(hvalue(t), k), /* else, do raw access */ \ + !ttisnil(slot))) /* result not nil? */ + +/* +** standard implementation for 'gettable' +*/ +#define luaV_gettable(L,t,k,v) { const TValue *slot; \ + if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ + else luaV_finishget(L,t,k,v,slot); } + + +/* +** Fast track for set table. If 't' is a table and 't[k]' is not nil, +** call GC barrier, do a raw 't[k]=v', and return true; otherwise, +** return false with 'slot' equal to NULL (if 't' is not a table) or +** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro +** returns true, there is no need to 'invalidateTMcache', because the +** call is not creating a new entry. +*/ +#define luaV_fastset(L,t,k,slot,f,v) \ + (!ttistable(t) \ + ? (slot = NULL, 0) \ + : (slot = f(hvalue(t), k), \ + ttisnil(slot) ? 0 \ + : (luaC_barrierback(L, hvalue(t), v), \ + setobj2t(L, cast(TValue *,slot), v), \ + 1))) + + +#define luaV_settable(L,t,k,v) { const TValue *slot; \ + if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \ + luaV_finishset(L,t,k,v,slot); } + + + +LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); +LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); +LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, + StkId val, const TValue *slot); +LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, + StkId val, const TValue *slot); +LUAI_FUNC void luaV_finishOp (lua_State *L); +LUAI_FUNC void luaV_execute (lua_State *L); +LUAI_FUNC void luaV_concat (lua_State *L, int total); +LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); +LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); +LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); +LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lzio.c b/dep/scintilla/scintilla-3.10.6/lua/src/lzio.c new file mode 100644 index 00000000..c9e1f491 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lzio.c @@ -0,0 +1,68 @@ +/* +** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + +#define lzio_c +#define LUA_CORE + +#include "lprefix.h" + + +#include + +#include "lua.h" + +#include "llimits.h" +#include "lmem.h" +#include "lstate.h" +#include "lzio.h" + + +int luaZ_fill (ZIO *z) { + size_t size; + lua_State *L = z->L; + const char *buff; + lua_unlock(L); + buff = z->reader(L, z->data, &size); + lua_lock(L); + if (buff == NULL || size == 0) + return EOZ; + z->n = size - 1; /* discount char being returned */ + z->p = buff; + return cast_uchar(*(z->p++)); +} + + +void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { + z->L = L; + z->reader = reader; + z->data = data; + z->n = 0; + z->p = NULL; +} + + +/* --------------------------------------------------------------- read --- */ +size_t luaZ_read (ZIO *z, void *b, size_t n) { + while (n) { + size_t m; + if (z->n == 0) { /* no bytes in buffer? */ + if (luaZ_fill(z) == EOZ) /* try to read more */ + return n; /* no more input; return number of missing bytes */ + else { + z->n++; /* luaZ_fill consumed first byte; put it back */ + z->p--; + } + } + m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ + memcpy(b, z->p, m); + z->n -= m; + z->p += m; + b = (char *)b + m; + n -= m; + } + return 0; +} + diff --git a/dep/scintilla/scintilla-3.10.6/lua/src/lzio.h b/dep/scintilla/scintilla-3.10.6/lua/src/lzio.h new file mode 100644 index 00000000..e7b6f34b --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/lua/src/lzio.h @@ -0,0 +1,66 @@ +/* +** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) + + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_buffremove(buff,i) ((buff)->n -= (i)) +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ + (buff)->buffsize, size), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; /* reader function */ + void *data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif diff --git a/dep/scintilla/scintilla-3.6.0/qt/README b/dep/scintilla/scintilla-3.10.6/qt/README similarity index 86% rename from dep/scintilla/scintilla-3.6.0/qt/README rename to dep/scintilla/scintilla-3.10.6/qt/README index e6d490fb..3ad22e5d 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/README +++ b/dep/scintilla/scintilla-3.10.6/qt/README @@ -1,36 +1,38 @@ -README for building of Scintilla on Qt - -There are three different Scintilla libraries that can be produced: - - ScintillaEditBase -A basic widget callable from C++ which is small and can be used just as is -or with higher level functionality added. - - ScintillaEdit -A more complete C++ widget with a method for every Scintilla API and a -secondary API allowing direct access to document objects. - - ScintillaEditPy -A Python callable version of ScintillaEdit using the PySide bindings. - - Building a library - -ScintillaEditBase can be built without performing any generation steps. -The ScintillaEditBase/ScintillaEditBase.pro project can be loaded into -Qt Creator and the "Build All" command performed. -Alternatively, run "qmake" to build make files and then use the platform -make to build. Most commonly, use "make" on Unix and "nmake" -on Windows. - -ScintillaEdit requires a generation command be run first. From the -ScintillaEdit directory: - -python WidgetGen.py - -After the generation command has run, the ScintillaEdit.h and -ScintillaEdit.cpp files will have been populated with the Scintilla API -methods. -To build, use Qt Creator or qmake and make as for ScintillaEditBase. - -ScintillaEditPy is more complex and instructions are found in -ScintillaEditPy/README. +README for building of Scintilla on Qt + +There are three different Scintilla libraries that can be produced: + + ScintillaEditBase +A basic widget callable from C++ which is small and can be used just as is +or with higher level functionality added. + + ScintillaEdit +A more complete C++ widget with a method for every Scintilla API and a +secondary API allowing direct access to document objects. + + ScintillaEditPy +A Python callable version of ScintillaEdit using the PySide bindings. + + Building a library + +ScintillaEditBase can be built without performing any generation steps. +The ScintillaEditBase/ScintillaEditBase.pro project can be loaded into +Qt Creator and the "Build All" command performed. +Alternatively, run "qmake" to build make files and then use the platform +make to build. Most commonly, use "make" on Unix and "nmake" +on Windows. + +On Linux, qmake may be called qmake-qt5 or qmake-qt4. + +ScintillaEdit requires a generation command be run first. From the +ScintillaEdit directory: + +python WidgetGen.py + +After the generation command has run, the ScintillaEdit.h and +ScintillaEdit.cpp files will have been populated with the Scintilla API +methods. +To build, use Qt Creator or qmake and make as for ScintillaEditBase. + +ScintillaEditPy is more complex and instructions are found in +ScintillaEditPy/README. diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaDocument.cpp b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaDocument.cpp similarity index 75% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaDocument.cpp rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaDocument.cpp index fd9f3e99..1dc7c304 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaDocument.cpp +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaDocument.cpp @@ -5,15 +5,19 @@ #include #include #include +#include #include "ScintillaDocument.h" #include "Platform.h" +#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" +#include "CharacterCategory.h" #include "Position.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -21,7 +25,6 @@ #include "CellBuffer.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -30,23 +33,21 @@ #include "CaseFolder.h" #include "Document.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif class WatcherHelper : public DocWatcher { - ScintillaDocument *owner; + ScintillaDocument *owner; public: - explicit WatcherHelper(ScintillaDocument *owner_); - virtual ~WatcherHelper(); + explicit WatcherHelper(ScintillaDocument *owner_); + virtual ~WatcherHelper(); - void NotifyModifyAttempt(Document *doc, void *userData); - void NotifySavePoint(Document *doc, void *userData, bool atSavePoint); - void NotifyModified(Document *doc, DocModification mh, void *userData); - void NotifyDeleted(Document *doc, void *userData); - void NotifyStyleNeeded(Document *doc, void *userData, int endPos); - void NotifyLexerChanged(Document *doc, void *userData); - void NotifyErrorOccurred(Document *doc, void *userData, int status); + void NotifyModifyAttempt(Document *doc, void *userData) override; + void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) override; + void NotifyModified(Document *doc, DocModification mh, void *userData) override; + void NotifyDeleted(Document *doc, void *userData) noexcept override; + void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos); + void NotifyLexerChanged(Document *doc, void *userData) override; + void NotifyErrorOccurred(Document *doc, void *userData, int status) override; }; WatcherHelper::WatcherHelper(ScintillaDocument *owner_) : owner(owner_) { @@ -56,11 +57,11 @@ WatcherHelper::~WatcherHelper() { } void WatcherHelper::NotifyModifyAttempt(Document *, void *) { - owner->emit_modify_attempt(); + emit owner->modify_attempt(); } void WatcherHelper::NotifySavePoint(Document *, void *, bool atSavePoint) { - owner->emit_save_point(atSavePoint); + emit owner->save_point(atSavePoint); } void WatcherHelper::NotifyModified(Document *, DocModification mh, void *) { @@ -68,29 +69,29 @@ void WatcherHelper::NotifyModified(Document *, DocModification mh, void *) { if (!mh.text) length = 0; QByteArray ba = QByteArray::fromRawData(mh.text, length); - owner->emit_modified(mh.position, mh.modificationType, ba, length, - mh.linesAdded, mh.line, mh.foldLevelNow, mh.foldLevelPrev); + emit owner->modified(mh.position, mh.modificationType, ba, length, + mh.linesAdded, mh.line, mh.foldLevelNow, mh.foldLevelPrev); } -void WatcherHelper::NotifyDeleted(Document *, void *) { +void WatcherHelper::NotifyDeleted(Document *, void *) noexcept { } -void WatcherHelper::NotifyStyleNeeded(Document *, void *, int endPos) { - owner->emit_style_needed(endPos); +void WatcherHelper::NotifyStyleNeeded(Document *, void *, Sci::Position endPos) { + emit owner->style_needed(endPos); } void WatcherHelper::NotifyLexerChanged(Document *, void *) { - owner->emit_lexer_changed(); + emit owner->lexer_changed(); } void WatcherHelper::NotifyErrorOccurred(Document *, void *, int status) { - owner->emit_error_occurred(status); + emit owner->error_occurred(status); } ScintillaDocument::ScintillaDocument(QObject *parent, void *pdoc_) : QObject(parent), pdoc(pdoc_), docWatcher(0) { if (!pdoc) { - pdoc = new Document(); + pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT); } docWatcher = new WatcherHelper(this); (static_cast(pdoc))->AddRef(); @@ -109,7 +110,7 @@ ScintillaDocument::~ScintillaDocument() { } void *ScintillaDocument::pointer() { - return pdoc; + return pdoc; } int ScintillaDocument::line_from_position(int pos) { @@ -232,7 +233,7 @@ void ScintillaDocument::ensure_styled_to(int position) { } void ScintillaDocument::set_current_indicator(int indic) { - (static_cast(pdoc))->decorations.SetCurrentIndicator(indic); + (static_cast(pdoc))->decorations->SetCurrentIndicator(indic); } void ScintillaDocument::decoration_fill_range(int position, int value, int fillLength) { @@ -240,15 +241,15 @@ void ScintillaDocument::decoration_fill_range(int position, int value, int fillL } int ScintillaDocument::decorations_value_at(int indic, int position) { - return (static_cast(pdoc))->decorations.ValueAt(indic, position); + return (static_cast(pdoc))->decorations->ValueAt(indic, position); } int ScintillaDocument::decorations_start(int indic, int position) { - return (static_cast(pdoc))->decorations.Start(indic, position); + return (static_cast(pdoc))->decorations->Start(indic, position); } int ScintillaDocument::decorations_end(int indic, int position) { - return (static_cast(pdoc))->decorations.End(indic, position); + return (static_cast(pdoc))->decorations->End(indic, position); } int ScintillaDocument::get_code_page() { @@ -274,32 +275,3 @@ int ScintillaDocument::move_position_outside_char(int pos, int move_dir, bool ch int ScintillaDocument::get_character(int pos) { return (static_cast(pdoc))->GetCharacterAndWidth(pos, NULL); } - -// Signal emitters - -void ScintillaDocument::emit_modify_attempt() { - emit modify_attempt(); -} - -void ScintillaDocument::emit_save_point(bool atSavePoint) { - emit save_point(atSavePoint); -} - -void ScintillaDocument::emit_modified(int position, int modification_type, const QByteArray& text, int length, - int linesAdded, int line, int foldLevelNow, int foldLevelPrev) { - emit modified(position, modification_type, text, length, - linesAdded, line, foldLevelNow, foldLevelPrev); -} - -void ScintillaDocument::emit_style_needed(int pos) { - emit style_needed(pos); -} - -void ScintillaDocument::emit_lexer_changed() { - emit lexer_changed(); -} - -void ScintillaDocument::emit_error_occurred(int status) { - emit error_occurred(status); -} - diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaDocument.h b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaDocument.h similarity index 82% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaDocument.h rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaDocument.h index 1d571a73..fb0acb1c 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaDocument.h +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaDocument.h @@ -9,10 +9,6 @@ class WatcherHelper; -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - #ifndef EXPORT_IMPORT_API #ifdef WIN32 #ifdef MAKING_LIBRARY @@ -77,33 +73,19 @@ public: int get_eol_mode(); void set_eol_mode(int eol_mode); int move_position_outside_char(int pos, int move_dir, bool check_line_end); - - int get_character(int pos); // Calls GetCharacterAndWidth(pos, NULL) -private: - void emit_modify_attempt(); - void emit_save_point(bool atSavePoint); - void emit_modified(int position, int modification_type, const QByteArray& text, int length, - int linesAdded, int line, int foldLevelNow, int foldLevelPrev); - void emit_style_needed(int pos); - void emit_lexer_changed(); - void emit_error_occurred(int status); + int get_character(int pos); // Calls GetCharacterAndWidth(pos, NULL) signals: void modify_attempt(); void save_point(bool atSavePoint); - void modified(int position, int modification_type, const QByteArray& text, int length, - int linesAdded, int line, int foldLevelNow, int foldLevelPrev); + void modified(int position, int modification_type, const QByteArray &text, int length, + int linesAdded, int line, int foldLevelNow, int foldLevelPrev); void style_needed(int pos); void lexer_changed(); void error_occurred(int status); friend class ::WatcherHelper; - }; -#ifdef SCI_NAMESPACE -} -#endif - #endif // SCINTILLADOCUMENT_H diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.cpp.template b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaEdit.cpp.template similarity index 91% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.cpp.template rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaEdit.cpp.template index 3aca0260..8bcbf42b 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.cpp.template +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaEdit.cpp.template @@ -4,9 +4,7 @@ #include "ScintillaEdit.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif ScintillaEdit::ScintillaEdit(QWidget *parent) : ScintillaEditBase(parent) { } @@ -25,12 +23,12 @@ QByteArray ScintillaEdit::TextReturner(int message, uptr_t wParam) const { } QPairScintillaEdit::find_text(int flags, const char *text, int cpMin, int cpMax) { - struct TextToFind ft = {{0, 0}, 0, {0, 0}}; + struct Sci_TextToFind ft = {{0, 0}, 0, {0, 0}}; ft.chrg.cpMin = cpMin; ft.chrg.cpMax = cpMax; ft.chrgText.cpMin = cpMin; ft.chrgText.cpMax = cpMax; - ft.lpstrText = const_cast(text); + ft.lpstrText = text; int start = send(SCI_FINDTEXT, flags, (uptr_t) (&ft)); @@ -43,7 +41,7 @@ QByteArray ScintillaEdit::get_text_range(int start, int end) { int length = end-start; QByteArray ba(length+1, '\0'); - struct TextRange tr = {{start, end}, ba.data()}; + struct Sci_TextRange tr = {{start, end}, ba.data()}; send(SCI_GETTEXTRANGE, 0, (sptr_t)&tr); ba.chop(1); // Remove extra NUL @@ -59,25 +57,25 @@ void ScintillaEdit::set_doc(ScintillaDocument *pdoc_) { send(SCI_SETDOCPOINTER, 0, (sptr_t)(pdoc_->pointer())); } -long ScintillaEdit::format_range(bool draw, QPaintDevice* target, QPaintDevice* measure, +long ScintillaEdit::format_range(bool draw, QPaintDevice* target, QPaintDevice* measure, const QRect& print_rect, const QRect& page_rect, long range_start, long range_end) { Sci_RangeToFormat to_format; - + to_format.hdc = target; to_format.hdcTarget = measure; - + to_format.rc.left = print_rect.left(); to_format.rc.top = print_rect.top(); to_format.rc.right = print_rect.right(); to_format.rc.bottom = print_rect.bottom(); - + to_format.rcPage.left = page_rect.left(); to_format.rcPage.top = page_rect.top(); to_format.rcPage.right = page_rect.right(); to_format.rcPage.bottom = page_rect.bottom(); - + to_format.chrg.cpMin = range_start; to_format.chrg.cpMax = range_end; diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.h.template b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaEdit.h.template similarity index 92% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.h.template rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaEdit.h.template index 052d87c7..875f2bee 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.h.template +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaEdit.h.template @@ -10,10 +10,6 @@ #include "ScintillaEditBase.h" #include "ScintillaDocument.h" -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - #ifndef EXPORT_IMPORT_API #ifdef WIN32 #ifdef MAKING_LIBRARY @@ -52,14 +48,14 @@ public: } // Exposing the FORMATRANGE api with both underscore & qt style names - long format_range(bool draw, QPaintDevice* target, QPaintDevice* measure, + long format_range(bool draw, QPaintDevice* target, QPaintDevice* measure, const QRect& print_rect, const QRect& page_rect, long range_start, long range_end); - long formatRange(bool draw, QPaintDevice* target, QPaintDevice* measure, + long formatRange(bool draw, QPaintDevice* target, QPaintDevice* measure, const QRect& print_rect, const QRect& page_rect, long range_start, long range_end) { return format_range(draw, target, measure, print_rect, page_rect, - range_start, range_end); + range_start, range_end); } /* ++Autogenerated -- start of section automatically generated from Scintilla.iface */ @@ -67,8 +63,8 @@ public: }; -#ifdef SCI_NAMESPACE -} +#if defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif #endif /* SCINTILLAEDIT_H */ diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.pro b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaEdit.pro similarity index 85% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.pro rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaEdit.pro index c6ae03b6..9042ce14 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.pro +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/ScintillaEdit.pro @@ -11,7 +11,16 @@ TARGET = ScintillaEdit TEMPLATE = lib CONFIG += lib_bundle -VERSION = 3.6.0 +unix { + # requires C++11 support + greaterThan(QT_MAJOR_VERSION, 4){ + CONFIG += c++11 + } else { + QMAKE_CXXFLAGS += -std=c++0x + } +} + +VERSION = 3.10.6 SOURCES += \ ScintillaEdit.cpp \ @@ -21,6 +30,7 @@ SOURCES += \ ../ScintillaEditBase/ScintillaEditBase.cpp \ ../../src/XPM.cxx \ ../../src/ViewStyle.cxx \ + ../../src/UniqueString.cxx \ ../../src/UniConversion.cxx \ ../../src/Style.cxx \ ../../src/Selection.cxx \ @@ -39,6 +49,7 @@ SOURCES += \ ../../src/EditModel.cxx \ ../../src/Document.cxx \ ../../src/Decoration.cxx \ + ../../src/DBCS.cxx \ ../../src/ContractionState.cxx \ ../../src/CharClassify.cxx \ ../../src/CellBuffer.cxx \ @@ -54,10 +65,11 @@ SOURCES += \ ../../lexlib/LexerNoExceptions.cxx \ ../../lexlib/LexerModule.cxx \ ../../lexlib/LexerBase.cxx \ + ../../lexlib/DefaultLexer.cxx \ ../../lexlib/CharacterSet.cxx \ ../../lexlib/CharacterCategory.cxx \ ../../lexlib/Accessor.cxx \ - ../../lexers/*.cxx + $$files(../../lexers/*.cxx, false) HEADERS += \ ScintillaEdit.h \ @@ -70,6 +82,9 @@ OTHER_FILES += INCLUDEPATH += ../ScintillaEditBase ../../include ../../src ../../lexlib DEFINES += SCINTILLA_QT=1 MAKING_LIBRARY=1 SCI_LEXER=1 _CRT_SECURE_NO_DEPRECATE=1 +CONFIG(release, debug|release) { + DEFINES += NDEBUG=1 +} DESTDIR = ../../bin DLLDESTDIR = ../../bin diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/WidgetGen.py b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/WidgetGen.py similarity index 99% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/WidgetGen.py rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/WidgetGen.py index 92ebfd68..2c8ef203 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/WidgetGen.py +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEdit/WidgetGen.py @@ -107,7 +107,7 @@ def printHFile(f, options): if feat in ["fun", "get", "set"]: if checkTypes(name, v): constDeclarator = " const" if feat == "get" else "" - returnType = cppAlias(v["ReturnType"]) + returnType = cppAlias(v["ReturnType"]) if returnType == "int": returnType = "sptr_t" stringResult = v["Param2Type"] == "stringresult" @@ -230,7 +230,7 @@ def main(argv): options = {"qtStyle": qtStyleInterface} f = readInterface(cleanGenerated) try: - GenerateFile("ScintillaEdit.cpp.template", "ScintillaEdit.cpp", + GenerateFile("ScintillaEdit.cpp.template", "ScintillaEdit.cpp", "/* ", True, printCPPFile(f, options)) GenerateFile("ScintillaEdit.h.template", "ScintillaEdit.h", "/* ", True, printHFile(f, options)) @@ -256,6 +256,6 @@ def main(argv): os.remove(file) except OSError: pass - + if __name__ == "__main__": main(sys.argv[1:]) diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/Notes.txt b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/Notes.txt similarity index 100% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/Notes.txt rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/Notes.txt diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/PlatQt.cpp b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/PlatQt.cpp similarity index 78% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/PlatQt.cpp rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/PlatQt.cpp index 35e4aee7..cce9c080 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/PlatQt.cpp +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/PlatQt.cpp @@ -8,8 +8,12 @@ // Additions Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware // Scintilla platform layer for Qt +#include + #include "PlatQt.h" #include "Scintilla.h" +#include "UniConversion.h" +#include "DBCS.h" #include "FontQuality.h" #include @@ -33,12 +37,8 @@ #include #include #include -#include -#include -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif //---------------------------------------------------------------------- @@ -102,10 +102,9 @@ public: } ~FontAndCharacterSet() { delete pfont; - pfont = 0; + pfont = nullptr; } }; - static int FontCharacterSet(Font &f) { return reinterpret_cast(f.GetID())->characterSet; @@ -115,15 +114,12 @@ static QFont *FontPointer(Font &f) { return reinterpret_cast(f.GetID())->pfont; } - -Font::Font() : fid(0) {} - +Font::Font() noexcept : fid(nullptr) {} Font::~Font() { delete reinterpret_cast(fid); - fid = 0; + fid = nullptr; } - static QFont::StyleStrategy ChooseStrategy(int eff) { switch (eff) { @@ -153,19 +149,30 @@ void Font::Release() { if (fid) delete reinterpret_cast(fid); - - fid = 0; + fid = nullptr; } - - SurfaceImpl::SurfaceImpl() -: device(0), painter(0), deviceOwned(false), painterOwned(false), x(0), y(0), - unicodeMode(false), codePage(0), codecName(0), codec(0) +: device(nullptr), painter(nullptr), deviceOwned(false), painterOwned(false), x(0), y(0), + unicodeMode(false), codePage(0), codecName(nullptr), codec(nullptr) {} - SurfaceImpl::~SurfaceImpl() { - Release(); + Clear(); +} + +void SurfaceImpl::Clear() +{ + if (painterOwned && painter) { + delete painter; + } + + if (deviceOwned && device) { + delete device; + } + device = nullptr; + painter = nullptr; + deviceOwned = false; + painterOwned = false; } void SurfaceImpl::Init(WindowID wid) @@ -197,18 +204,7 @@ void SurfaceImpl::InitPixMap(int width, void SurfaceImpl::Release() { - if (painterOwned && painter) { - delete painter; - } - - if (deviceOwned && device) { - delete device; - } - - device = 0; - painter = 0; - deviceOwned = false; - painterOwned = false; + Clear(); } bool SurfaceImpl::Initialised() @@ -274,20 +270,19 @@ void SurfaceImpl::LineTo(int x_, int y_) } void SurfaceImpl::Polygon(Point *pts, - int npts, + size_t npts, ColourDesired fore, ColourDesired back) { PenColour(fore); BrushColour(back); - QPoint *qpts = new QPoint[npts]; - for (int i = 0; i < npts; i++) { + std::vector qpts(npts); + for (size_t i = 0; i < npts; i++) { qpts[i] = QPoint(pts[i].x, pts[i].y); } - GetPainter()->drawPolygon(qpts, npts); - delete [] qpts; + GetPainter()->drawPolygon(&qpts[0], static_cast(npts)); } void SurfaceImpl::RectangleDraw(PRectangle rc, @@ -355,6 +350,26 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, GetPainter()->drawRoundedRect(rect, radius, radius); } +void SurfaceImpl::GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions options) { + QRectF rect = QRectFFromPRect(rc); + QLinearGradient linearGradient; + switch (options) { + case GradientOptions::leftToRight: + linearGradient = QLinearGradient(rc.left, rc.top, rc.right, rc.top); + break; + case GradientOptions::topToBottom: + default: + linearGradient = QLinearGradient(rc.left, rc.top, rc.left, rc.bottom); + break; + } + linearGradient.setSpread(QGradient::RepeatSpread); + for (const ColourStop &stop : stops) { + linearGradient.setColorAt(stop.position, QColorFromColourAlpha(stop.colour)); + } + QBrush brush = QBrush(linearGradient); + GetPainter()->fillRect(rect, brush); +} + static std::vector ImageByteSwapped(int width, int height, const unsigned char *pixelsImage) { // Input is RGBA, but Format_ARGB32 is BGRA, so swap the red bytes and blue bytes @@ -440,19 +455,6 @@ void SurfaceImpl::SetClip(PRectangle rc) GetPainter()->setClipRect(QRectFFromPRect(rc)); } -static size_t utf8LengthFromLead(unsigned char uch) -{ - if (uch >= (0x80 + 0x40 + 0x20 + 0x10)) { - return 4; - } else if (uch >= (0x80 + 0x40 + 0x20)) { - return 3; - } else if (uch >= (0x80)) { - return 2; - } else { - return 1; - } -} - void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, @@ -469,13 +471,13 @@ void SurfaceImpl::MeasureWidths(Font &font, if (unicodeMode) { int fit = su.size(); int ui=0; - const unsigned char *us = reinterpret_cast(s); int i=0; while (uipaintingActive()) { painter = device->paintEngine()->painter(); } else { @@ -610,7 +599,7 @@ Surface *Surface::Allocate(int) //---------------------------------------------------------------------- namespace { -QWidget *window(WindowID wid) +QWidget *window(WindowID wid) noexcept { return static_cast(wid); } @@ -622,16 +611,9 @@ void Window::Destroy() { if (wid) delete window(wid); - - wid = 0; + wid = nullptr; } - -bool Window::HasFocus() -{ - return wid ? window(wid)->hasFocus() : false; -} - -PRectangle Window::GetPosition() +PRectangle Window::GetPosition() const { // Before any size allocated pretend its 1000 wide so not scrolled return wid ? PRectFromQRect(window(wid)->frameGeometry()) : PRectangle(0, 0, 1000, 1000); @@ -643,9 +625,9 @@ void Window::SetPosition(PRectangle rc) window(wid)->setGeometry(QRectFromPRect(rc)); } -void Window::SetPositionRelative(PRectangle rc, Window relativeTo) +void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) { - QPoint oPos = window(relativeTo.wid)->mapToGlobal(QPoint(0,0)); + QPoint oPos = window(relativeTo->wid)->mapToGlobal(QPoint(0,0)); int ox = oPos.x(); int oy = oPos.y(); ox += rc.left; @@ -671,7 +653,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) window(wid)->resize(sizex, sizey); } -PRectangle Window::GetClientPosition() +PRectangle Window::GetClientPosition() const { // The client position is the window position return GetPosition(); @@ -726,12 +708,6 @@ void Window::SetCursor(Cursor curs) } } -void Window::SetTitle(const char *s) -{ - if (wid) - window(wid)->setWindowTitle(s); -} - /* Returns rectangle of monitor pt is on, both rect and pt are in Window's window coordinates */ PRectangle Window::GetMonitorRect(Point pt) @@ -745,59 +721,58 @@ PRectangle Window::GetMonitorRect(Point pt) rectScreen.right(), rectScreen.bottom()); } - //---------------------------------------------------------------------- +class ListWidget : public QListWidget { +public: + explicit ListWidget(QWidget *parent); + virtual ~ListWidget(); + + void setDelegate(IListBoxDelegate *lbDelegate); + void selectionChanged(); + +protected: + void mouseReleaseEvent(QMouseEvent * event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + QStyleOptionViewItem viewOptions() const override; + +private: + IListBoxDelegate *delegate; +}; class ListBoxImpl : public ListBox { public: ListBoxImpl(); ~ListBoxImpl(); - virtual void SetFont(Font &font); - virtual void Create(Window &parent, int ctrlID, Point location, - int lineHeight, bool unicodeMode, int technology); - virtual void SetAverageCharWidth(int width); - virtual void SetVisibleRows(int rows); - virtual int GetVisibleRows() const; - virtual PRectangle GetDesiredRect(); - virtual int CaretFromEdge(); - virtual void Clear(); - virtual void Append(char *s, int type = -1); - virtual int Length(); - virtual void Select(int n); - virtual int GetSelection(); - virtual int Find(const char *prefix); - virtual void GetValue(int n, char *value, int len); - virtual void RegisterImage(int type, const char *xpmData); - virtual void RegisterRGBAImage(int type, int width, int height, - const unsigned char *pixelsImage); + void SetFont(Font &font) override; + void Create(Window &parent, int ctrlID, Point location, + int lineHeight, bool unicodeMode_, int technology) override; + void SetAverageCharWidth(int width) override; + void SetVisibleRows(int rows) override; + int GetVisibleRows() const override; + PRectangle GetDesiredRect() override; + int CaretFromEdge() override; + void Clear() override; + void Append(char *s, int type = -1) override; + int Length() override; + void Select(int n) override; + int GetSelection() override; + int Find(const char *prefix) override; + void GetValue(int n, char *value, int len) override; + void RegisterImage(int type, const char *xpmData) override; + void RegisterRGBAImage(int type, int width, int height, + const unsigned char *pixelsImage) override; virtual void RegisterQPixmapImage(int type, const QPixmap& pm); - virtual void ClearRegisteredImages(); - virtual void SetDoubleClickAction(CallBackAction action, void *data); - virtual void SetList(const char *list, char separator, char typesep); + void ClearRegisteredImages() override; + void SetDelegate(IListBoxDelegate *lbDelegate) override; + void SetList(const char *list, char separator, char typesep) override; + + ListWidget *GetWidget() const; private: bool unicodeMode; int visibleRows; QMap images; }; - -class ListWidget : public QListWidget { -public: - explicit ListWidget(QWidget *parent); - virtual ~ListWidget(); - - void setDoubleClickAction(CallBackAction action, void *data); - -protected: - virtual void mouseDoubleClickEvent(QMouseEvent *event); - virtual QStyleOptionViewItem viewOptions() const; - -private: - CallBackAction doubleClickAction; - void *doubleClickActionData; -}; - - ListBoxImpl::ListBoxImpl() : unicodeMode(false), visibleRows(5) {} @@ -819,13 +794,17 @@ void ListBoxImpl::Create(Window &parent, #if defined(Q_OS_WIN) // On Windows, Qt::ToolTip causes a crash when the list is clicked on // so Qt::Tool is used. - list->setParent(0, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + list->setParent(nullptr, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + | Qt::WindowDoesNotAcceptFocus +#endif + ); #else // On OS X, Qt::Tool takes focus so main window loses focus so // keyboard stops working. Qt::ToolTip works but its only really // documented for tooltips. // On Linux / X this setting allows clicking on list items. - list->setParent(0, Qt::ToolTip | Qt::FramelessWindowHint); + list->setParent(nullptr, Qt::ToolTip | Qt::FramelessWindowHint); #endif list->setAttribute(Qt::WA_ShowWithoutActivating); list->setFocusPolicy(Qt::NoFocus); @@ -846,13 +825,11 @@ void ListBoxImpl::Create(Window &parent, wid = list; } - void ListBoxImpl::SetFont(Font &font) { - ListWidget *list = static_cast(wid); + ListWidget *list = GetWidget(); list->setFont(*FontPointer(font)); } - void ListBoxImpl::SetAverageCharWidth(int /*width*/) {} void ListBoxImpl::SetVisibleRows(int rows) @@ -864,11 +841,9 @@ int ListBoxImpl::GetVisibleRows() const { return visibleRows; } - PRectangle ListBoxImpl::GetDesiredRect() { - ListWidget *list = static_cast(wid); - + ListWidget *list = GetWidget(); int rows = Length(); if (rows == 0 || rows > visibleRows) { rows = visibleRows; @@ -884,11 +859,9 @@ PRectangle ListBoxImpl::GetDesiredRect() return PRectangle(0, 0, width, height); } - int ListBoxImpl::CaretFromEdge() { - ListWidget *list = static_cast(wid); - + ListWidget *list = GetWidget(); int maxIconWidth = 0; foreach (QPixmap im, images) { if (maxIconWidth < im.width()) @@ -906,17 +879,14 @@ int ListBoxImpl::CaretFromEdge() #endif return maxIconWidth + (2 * list->frameWidth()) + extra; } - void ListBoxImpl::Clear() { - ListWidget *list = static_cast(wid); + ListWidget *list = GetWidget(); list->clear(); } - void ListBoxImpl::Append(char *s, int type) { - ListWidget *list = static_cast(wid); - + ListWidget *list = GetWidget(); QString str = unicodeMode ? QString::fromUtf8(s) : QString::fromLocal8Bit(s); QIcon icon; if (type >= 0) { @@ -925,16 +895,14 @@ void ListBoxImpl::Append(char *s, int type) } new QListWidgetItem(icon, str, list); } - int ListBoxImpl::Length() { - ListWidget *list = static_cast(wid); + ListWidget *list = GetWidget(); return list->count(); } - void ListBoxImpl::Select(int n) { - ListWidget *list = static_cast(wid); + ListWidget *list = GetWidget(); QModelIndex index = list->model()->index(n, 0); if (index.isValid()) { QRect row_rect = list->visualRect(index); @@ -943,20 +911,18 @@ void ListBoxImpl::Select(int n) } } list->setCurrentRow(n); + list->selectionChanged(); } - int ListBoxImpl::GetSelection() { - ListWidget *list = static_cast(wid); + ListWidget *list = GetWidget(); return list->currentRow(); } - int ListBoxImpl::Find(const char *prefix) { - ListWidget *list = static_cast(wid); + ListWidget *list = GetWidget(); QString sPrefix = unicodeMode ? QString::fromUtf8(prefix) : QString::fromLocal8Bit(prefix); QList ms = list->findItems(sPrefix, Qt::MatchStartsWith); - int result = -1; if (!ms.isEmpty()) { result = list->row(ms.first()); @@ -964,10 +930,9 @@ int ListBoxImpl::Find(const char *prefix) return result; } - void ListBoxImpl::GetValue(int n, char *value, int len) { - ListWidget *list = static_cast(wid); + ListWidget *list = GetWidget(); QListWidgetItem *item = list->item(n); QString str = item->data(Qt::DisplayRole).toString(); QByteArray bytes = unicodeMode ? str.toUtf8() : str.toLocal8Bit(); @@ -979,12 +944,11 @@ void ListBoxImpl::GetValue(int n, char *value, int len) void ListBoxImpl::RegisterQPixmapImage(int type, const QPixmap& pm) { images[type] = pm; - - ListWidget *list = static_cast(wid); - if (list != NULL) { + ListWidget *list = GetWidget(); + if (list) { QSize iconSize = list->iconSize(); if (pm.width() > iconSize.width() || pm.height() > iconSize.height()) - list->setIconSize(QSize(qMax(pm.width(), iconSize.width()), + list->setIconSize(QSize(qMax(pm.width(), iconSize.width()), qMax(pm.height(), iconSize.height()))); } @@ -1005,18 +969,15 @@ void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsig void ListBoxImpl::ClearRegisteredImages() { images.clear(); - - ListWidget *list = static_cast(wid); - if (list != NULL) + ListWidget *list = GetWidget(); + if (list) list->setIconSize(QSize(0, 0)); } - -void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data) +void ListBoxImpl::SetDelegate(IListBoxDelegate *lbDelegate) { - ListWidget *list = static_cast(wid); - list->setDoubleClickAction(action, data); + ListWidget *list = GetWidget(); + list->setDelegate(lbDelegate); } - void ListBoxImpl::SetList(const char *list, char separator, char typesep) { // This method is *not* platform dependent. @@ -1025,7 +986,7 @@ void ListBoxImpl::SetList(const char *list, char separator, char typesep) size_t count = strlen(list) + 1; std::vector words(list, list+count); char *startword = &words[0]; - char *numword = NULL; + char *numword = nullptr; int i = 0; for (; words[i]; i++) { if (words[i] == separator) { @@ -1034,7 +995,7 @@ void ListBoxImpl::SetList(const char *list, char separator, char typesep) *numword = '\0'; Append(startword, numword?atoi(numword + 1):-1); startword = &words[0] + i + 1; - numword = NULL; + numword = nullptr; } else if (words[i] == typesep) { numword = &words[0] + i; } @@ -1045,46 +1006,56 @@ void ListBoxImpl::SetList(const char *list, char separator, char typesep) Append(startword, numword?atoi(numword + 1):-1); } } +ListWidget *ListBoxImpl::GetWidget() const +{ + return static_cast(wid); +} -ListBox::ListBox() {} - +ListBox::ListBox() noexcept {} ListBox::~ListBox() {} ListBox *ListBox::Allocate() { return new ListBoxImpl(); } - ListWidget::ListWidget(QWidget *parent) -: QListWidget(parent), doubleClickAction(0), doubleClickActionData(0) +: QListWidget(parent), delegate(nullptr) {} - ListWidget::~ListWidget() {} -void ListWidget::setDoubleClickAction(CallBackAction action, void *data) +void ListWidget::setDelegate(IListBoxDelegate *lbDelegate) { - doubleClickAction = action; - doubleClickActionData = data; + delegate = lbDelegate; +} + +void ListWidget::selectionChanged() { + if (delegate) { + ListBoxEvent event(ListBoxEvent::EventType::selectionChange); + delegate->ListNotify(&event); + } } void ListWidget::mouseDoubleClickEvent(QMouseEvent * /* event */) { - if (doubleClickAction != 0) { - doubleClickAction(doubleClickActionData); + if (delegate) { + ListBoxEvent event(ListBoxEvent::EventType::doubleClick); + delegate->ListNotify(&event); } } +void ListWidget::mouseReleaseEvent(QMouseEvent * /* event */) +{ + selectionChanged(); +} + QStyleOptionViewItem ListWidget::viewOptions() const { QStyleOptionViewItem result = QListWidget::viewOptions(); result.state |= QStyle::State_Active; return result; } - //---------------------------------------------------------------------- - -Menu::Menu() : mid(0) {} - +Menu::Menu() noexcept : mid(nullptr) {} void Menu::CreatePopUp() { Destroy(); @@ -1097,9 +1068,8 @@ void Menu::Destroy() QMenu *menu = static_cast(mid); delete menu; } - mid = 0; + mid = nullptr; } - void Menu::Show(Point pt, Window & /*w*/) { QMenu *menu = static_cast(mid); @@ -1117,14 +1087,18 @@ public: QString path = QString::fromUtf8(modulePath); lib = new QLibrary(path); } + // Deleted so DynamicLibraryImpl objects can not be copied + DynamicLibraryImpl(const DynamicLibraryImpl &) = delete; + DynamicLibraryImpl(DynamicLibraryImpl &&) = delete; + DynamicLibraryImpl &operator=(const DynamicLibraryImpl &) = delete; + DynamicLibraryImpl &operator=(DynamicLibraryImpl &&) = delete; virtual ~DynamicLibraryImpl() { if (lib) lib->unload(); - lib = 0; + lib = nullptr; } - - virtual Function FindFunction(const char *name) { + Function FindFunction(const char *name) override { if (lib) { // C++ standard doesn't like casts between function pointers and void pointers so use a union union { @@ -1138,14 +1112,12 @@ public: fnConv.fp = lib->resolve(name); return fnConv.f; } - return NULL; + return nullptr; } - - virtual bool IsValid() { - return lib != NULL; + bool IsValid() override { + return lib != nullptr; } }; - DynamicLibrary *DynamicLibrary::Load(const char *modulePath) { return static_cast(new DynamicLibraryImpl(modulePath)); @@ -1184,47 +1156,6 @@ unsigned int Platform::DoubleClickTime() return QApplication::doubleClickInterval(); } -bool Platform::MouseButtonBounce() -{ - return false; -} - -bool Platform::IsKeyDown(int /*key*/) -{ - return false; -} - -long Platform::SendScintilla(WindowID /*w*/, - unsigned int /*msg*/, - unsigned long /*wParam*/, - long /*lParam*/) -{ - return 0; -} - -long Platform::SendScintillaPointer(WindowID /*w*/, - unsigned int /*msg*/, - unsigned long /*wParam*/, - void * /*lParam*/) -{ - return 0; -} - -int Platform::Minimum(int a, int b) -{ - return qMin(a, b); -} - -int Platform::Maximum(int a, int b) -{ - return qMax(a, b); -} - -int Platform::Clamp(int val, int minVal, int maxVal) -{ - return qBound(minVal, val, maxVal); -} - void Platform::DebugDisplay(const char *s) { qWarning("Scintilla: %s", s); @@ -1259,77 +1190,4 @@ void Platform::Assert(const char *c, const char *file, int line) } } - -bool Platform::IsDBCSLeadByte(int codePage, char ch) -{ - // Byte ranges found in Wikipedia articles with relevant search strings in each case - unsigned char uch = static_cast(ch); - switch (codePage) { - case 932: - // Shift_jis - return ((uch >= 0x81) && (uch <= 0x9F)) || - ((uch >= 0xE0) && (uch <= 0xEF)); - case 936: - // GBK - return (uch >= 0x81) && (uch <= 0xFE); - case 949: - // Korean Wansung KS C-5601-1987 - return (uch >= 0x81) && (uch <= 0xFE); - case 950: - // Big5 - return (uch >= 0x81) && (uch <= 0xFE); - case 1361: - // Korean Johab KS C-5601-1992 - return - ((uch >= 0x84) && (uch <= 0xD3)) || - ((uch >= 0xD8) && (uch <= 0xDE)) || - ((uch >= 0xE0) && (uch <= 0xF9)); - } - return false; } - -int Platform::DBCSCharLength(int codePage, const char *s) -{ - if (codePage == 932 || codePage == 936 || codePage == 949 || - codePage == 950 || codePage == 1361) { - return IsDBCSLeadByte(codePage, s[0]) ? 2 : 1; - } else { - return 1; - } -} - -int Platform::DBCSCharMaxLength() -{ - return 2; -} - - -//---------------------------------------------------------------------- - -static QElapsedTimer timer; - -ElapsedTime::ElapsedTime() : bigBit(0), littleBit(0) -{ - if (!timer.isValid()) { - timer.start(); - } - qint64 ns64Now = timer.nsecsElapsed(); - bigBit = static_cast(ns64Now >> 32); - littleBit = static_cast(ns64Now & 0xFFFFFFFF); -} - -double ElapsedTime::Duration(bool reset) -{ - qint64 ns64Now = timer.nsecsElapsed(); - qint64 ns64Start = (static_cast(static_cast(bigBit)) << 32) + static_cast(littleBit); - double result = ns64Now - ns64Start; - if (reset) { - bigBit = static_cast(ns64Now >> 32); - littleBit = static_cast(ns64Now & 0xFFFFFFFF); - } - return result / 1000000000.0; // 1 billion nanoseconds in a second -} - -#ifdef SCI_NAMESPACE -} -#endif diff --git a/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/PlatQt.h b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/PlatQt.h new file mode 100644 index 00000000..26ea7406 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/PlatQt.h @@ -0,0 +1,140 @@ +// +// Copyright (c) 1990-2011, Scientific Toolworks, Inc. +// +// The License.txt file describes the conditions under which this software may be distributed. +// +// Author: Jason Haslam +// +// Additions Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware +// Scintilla platform layer for Qt + +#ifndef PLATQT_H +#define PLATQT_H + +#include + +#include +#include + +#include "Platform.h" + +#include +#include +#include +#include + +namespace Scintilla { + +const char *CharacterSetID(int characterSet); + +inline QColor QColorFromCA(ColourDesired ca) +{ + long c = ca.AsInteger(); + return QColor(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); +} + +inline QColor QColorFromColourAlpha(ColourAlpha ca) +{ + return QColor(ca.GetRed(), ca.GetGreen(), ca.GetBlue(), ca.GetAlpha()); +} + +inline QRect QRectFromPRect(PRectangle pr) +{ + return QRect(pr.left, pr.top, pr.Width(), pr.Height()); +} + +inline QRectF QRectFFromPRect(PRectangle pr) +{ + return QRectF(pr.left, pr.top, pr.Width(), pr.Height()); +} + +inline PRectangle PRectFromQRect(QRect qr) +{ + return PRectangle(qr.x(), qr.y(), qr.x() + qr.width(), qr.y() + qr.height()); +} + +inline Point PointFromQPoint(QPoint qp) +{ + return Point(qp.x(), qp.y()); +} + +class SurfaceImpl : public Surface { +private: + QPaintDevice *device; + QPainter *painter; + bool deviceOwned; + bool painterOwned; + float x, y; + bool unicodeMode; + int codePage; + const char *codecName; + QTextCodec *codec; + + void Clear(); + +public: + SurfaceImpl(); + virtual ~SurfaceImpl(); + + void Init(WindowID wid) override; + void Init(SurfaceID sid, WindowID wid) override; + void InitPixMap(int width, int height, + Surface *surface, WindowID wid) override; + + void Release() override; + bool Initialised() override; + void PenColour(ColourDesired fore) override; + int LogPixelsY() override; + int DeviceHeightFont(int points) override; + void MoveTo(int x_, int y_) override; + void LineTo(int x_, int y_) override; + void Polygon(Point *pts, size_t npts, ColourDesired fore, + ColourDesired back) override; + void RectangleDraw(PRectangle rc, ColourDesired fore, + ColourDesired back) override; + void FillRectangle(PRectangle rc, ColourDesired back) override; + void FillRectangle(PRectangle rc, Surface &surfacePattern) override; + void RoundedRectangle(PRectangle rc, ColourDesired fore, + ColourDesired back) override; + void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, + int alphaFill, ColourDesired outline, int alphaOutline, int flags) override; + void GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions options) override; + void DrawRGBAImage(PRectangle rc, int width, int height, + const unsigned char *pixelsImage) override; + void Ellipse(PRectangle rc, ColourDesired fore, + ColourDesired back) override; + void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; + + void DrawTextNoClip(PRectangle rc, Font &font, XYPOSITION ybase, + const char *s, int len, ColourDesired fore, ColourDesired back) override; + void DrawTextClipped(PRectangle rc, Font &font, XYPOSITION ybase, + const char *s, int len, ColourDesired fore, ColourDesired back) override; + void DrawTextTransparent(PRectangle rc, Font &font, XYPOSITION ybase, + const char *s, int len, ColourDesired fore) override; + void MeasureWidths(Font &font, const char *s, int len, + XYPOSITION *positions) override; + XYPOSITION WidthText(Font &font, const char *s, int len) override; + XYPOSITION Ascent(Font &font) override; + XYPOSITION Descent(Font &font) override; + XYPOSITION InternalLeading(Font &font) override; + XYPOSITION Height(Font &font) override; + XYPOSITION AverageCharWidth(Font &font) override; + + void SetClip(PRectangle rc) override; + void FlushCachedState() override; + + void SetUnicodeMode(bool unicodeMode_) override; + void SetDBCSMode(int codePage_) override; + + void BrushColour(ColourDesired back); + void SetCodec(Font &font); + void SetFont(Font &font); + + QPaintDevice *GetPaintDevice(); + void SetPainter(QPainter *painter); + QPainter *GetPainter(); +}; + +} + +#endif diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaEditBase.cpp b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaEditBase.cpp similarity index 80% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaEditBase.cpp rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaEditBase.cpp index 3e390426..d7f25dbd 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaEditBase.cpp +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaEditBase.cpp @@ -17,9 +17,9 @@ #include #endif #include +#include #include #include -#include #define INDIC_INPUTMETHOD 24 @@ -29,10 +29,19 @@ #define SC_INDICATOR_CONVERTED INDIC_IME+2 #define SC_INDICATOR_UNKNOWN INDIC_IME_MAX -#ifdef SCI_NAMESPACE -using namespace Scintilla; +// Q_WS_MAC and Q_WS_X11 aren't defined in Qt5 +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#ifdef Q_OS_MAC +#define Q_WS_MAC 1 #endif +#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) +#define Q_WS_X11 1 +#endif +#endif // QT_VERSION >= 5.0.0 + +using namespace Scintilla; + ScintillaEditBase::ScintillaEditBase(QWidget *parent) : QAbstractScrollArea(parent), sqt(0), preeditPos(-1), wheelDelta(0) { @@ -47,10 +56,9 @@ ScintillaEditBase::ScintillaEditBase(QWidget *parent) setFrameStyle(QFrame::NoFrame); setFocusPolicy(Qt::StrongFocus); setAttribute(Qt::WA_StaticContents); + viewport()->setAutoFillBackground(false); setAttribute(Qt::WA_KeyCompression); setAttribute(Qt::WA_InputMethodEnabled); - viewport()->setAutoFillBackground(false); - viewport()->setAttribute(Qt::WA_OpaquePaintEvent); sqt->vs.indicators[SC_INDICATOR_UNKNOWN] = Indicator(INDIC_HIDDEN, ColourDesired(0, 0, 0xff)); sqt->vs.indicators[SC_INDICATOR_INPUT] = Indicator(INDIC_DOTS, ColourDesired(0, 0, 0xff)); @@ -122,6 +130,9 @@ bool ScintillaEditBase::event(QEvent *event) // Circumvent the tab focus convention. keyPressEvent(static_cast(event)); result = event->isAccepted(); + } else if (event->type() == QEvent::Show) { + setMouseTracking(true); + result = QAbstractScrollArea::event(event); } else if (event->type() == QEvent::Hide) { setMouseTracking(false); result = QAbstractScrollArea::event(event); @@ -168,7 +179,6 @@ void ScintillaEditBase::wheelEvent(QWheelEvent *event) void ScintillaEditBase::focusInEvent(QFocusEvent *event) { sqt->SetFocusState(true); - emit updateUi(); QAbstractScrollArea::focusInEvent(event); } @@ -228,7 +238,9 @@ void ScintillaEditBase::keyPressEvent(QKeyEvent *event) bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; bool consumed = false; - bool added = sqt->KeyDown(key, shift, ctrl, alt, &consumed) != 0; + bool added = sqt->KeyDownWithModifiers(key, + ScintillaQt::ModifierFlags(shift, ctrl, alt), + &consumed) != 0; if (!consumed) consumed = added; @@ -290,9 +302,7 @@ void ScintillaEditBase::mousePressEvent(QMouseEvent *event) return; } - bool button = event->button() == Qt::LeftButton; - - if (button) { + if (event->button() == Qt::LeftButton) { bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier; bool ctrl = QApplication::keyboardModifiers() & Qt::ControlModifier; #ifdef Q_WS_X11 @@ -303,16 +313,19 @@ void ScintillaEditBase::mousePressEvent(QMouseEvent *event) bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; #endif - sqt->ButtonDown(pos, time.elapsed(), shift, ctrl, alt); + sqt->ButtonDownWithModifiers(pos, time.elapsed(), ScintillaQt::ModifierFlags(shift, ctrl, alt)); + } + + if (event->button() == Qt::RightButton) { + sqt->RightButtonDownWithModifiers(pos, time.elapsed(), ModifiersOfKeyboard()); } } void ScintillaEditBase::mouseReleaseEvent(QMouseEvent *event) { Point point = PointFromQPoint(event->pos()); - bool ctrl = QApplication::keyboardModifiers() & Qt::ControlModifier; if (event->button() == Qt::LeftButton) - sqt->ButtonUp(point, time.elapsed(), ctrl); + sqt->ButtonUpWithModifiers(point, time.elapsed(), ModifiersOfKeyboard()); int pos = send(SCI_POSITIONFROMPOINT, point.x, point.y); int line = send(SCI_LINEFROMPOSITION, pos); @@ -342,23 +355,28 @@ void ScintillaEditBase::mouseMoveEvent(QMouseEvent *event) bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; #endif - int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); + const int modifiers = ScintillaQt::ModifierFlags(shift, ctrl, alt); - sqt->ButtonMoveWithModifiers(pos, modifiers); + sqt->ButtonMoveWithModifiers(pos, time.elapsed(), modifiers); } void ScintillaEditBase::contextMenuEvent(QContextMenuEvent *event) { Point pos = PointFromQPoint(event->globalPos()); Point pt = PointFromQPoint(event->pos()); - if (!sqt->PointInSelection(pt)) + if (!sqt->PointInSelection(pt)) { sqt->SetEmptySelection(sqt->PositionFromLocation(pt)); - sqt->ContextMenu(pos); + } + if (sqt->ShouldDisplayPopup(pt)) { + sqt->ContextMenu(pos); + } } void ScintillaEditBase::dragEnterEvent(QDragEnterEvent *event) { - if (event->mimeData()->hasText()) { + if (event->mimeData()->hasUrls()) { + event->acceptProposedAction(); + } else if (event->mimeData()->hasText()) { event->acceptProposedAction(); Point point = PointFromQPoint(event->pos()); @@ -375,7 +393,9 @@ void ScintillaEditBase::dragLeaveEvent(QDragLeaveEvent * /* event */) void ScintillaEditBase::dragMoveEvent(QDragMoveEvent *event) { - if (event->mimeData()->hasText()) { + if (event->mimeData()->hasUrls()) { + event->acceptProposedAction(); + } else if (event->mimeData()->hasText()) { event->acceptProposedAction(); Point point = PointFromQPoint(event->pos()); @@ -387,7 +407,10 @@ void ScintillaEditBase::dragMoveEvent(QDragMoveEvent *event) void ScintillaEditBase::dropEvent(QDropEvent *event) { - if (event->mimeData()->hasText()) { + if (event->mimeData()->hasUrls()) { + event->acceptProposedAction(); + sqt->DropUrls(event->mimeData()); + } else if (event->mimeData()->hasText()) { event->acceptProposedAction(); Point point = PointFromQPoint(event->pos()); @@ -410,10 +433,10 @@ bool ScintillaEditBase::IsHangul(const QChar qchar) const bool HangulJamoExtendedB = (0xD7B0 <= unicode && unicode <= 0xD7FF); const bool HangulSyllable = (0xAC00 <= unicode && unicode <= 0xD7A3); return HangulJamo || HangulCompatibleJamo || HangulSyllable || - HangulJamoExtendedA || HangulJamoExtendedB; + HangulJamoExtendedA || HangulJamoExtendedB; } -void ScintillaEditBase::MoveImeCarets(int offset) +void ScintillaEditBase::MoveImeCarets(int offset) { // Move carets relatively by bytes for (size_t r=0; r < sqt->sel.Count(); r++) { @@ -422,8 +445,8 @@ void ScintillaEditBase::MoveImeCarets(int offset) sqt->sel.Range(r).anchor.SetPosition(positionInsert + offset); } } - -void ScintillaEditBase::DrawImeIndicator(int indicator, int len) + +void ScintillaEditBase::DrawImeIndicator(int indicator, int len) { // Emulate the visual style of IME characters with indicators. // Draw an indicator on the character before caret by the character bytes of len @@ -432,24 +455,87 @@ void ScintillaEditBase::DrawImeIndicator(int indicator, int len) if (indicator < 8 || indicator > INDIC_MAX) { return; } - sqt->pdoc->decorations.SetCurrentIndicator(indicator); + sqt->pdoc->DecorationSetCurrentIndicator(indicator); for (size_t r=0; r< sqt-> sel.Count(); r++) { int positionInsert = sqt->sel.Range(r).Start().Position(); sqt->pdoc->DecorationFillRange(positionInsert - len, 1, len); } } +static int GetImeCaretPos(QInputMethodEvent *event) +{ + foreach (QInputMethodEvent::Attribute attr, event->attributes()) { + if (attr.type == QInputMethodEvent::Cursor) + return attr.start; + } + return 0; +} + +static std::vector MapImeIndicators(QInputMethodEvent *event) +{ + std::vector imeIndicator(event->preeditString().size(), SC_INDICATOR_UNKNOWN); + foreach (QInputMethodEvent::Attribute attr, event->attributes()) { + if (attr.type == QInputMethodEvent::TextFormat) { + QTextFormat format = attr.value.value(); + QTextCharFormat charFormat = format.toCharFormat(); + + int indicator = SC_INDICATOR_UNKNOWN; + switch (charFormat.underlineStyle()) { + case QTextCharFormat::NoUnderline: // win32, linux + indicator = SC_INDICATOR_TARGET; + break; + case QTextCharFormat::SingleUnderline: // osx + case QTextCharFormat::DashUnderline: // win32, linux + indicator = SC_INDICATOR_INPUT; + break; + case QTextCharFormat::DotLine: + case QTextCharFormat::DashDotLine: + case QTextCharFormat::WaveUnderline: + case QTextCharFormat::SpellCheckUnderline: + indicator = SC_INDICATOR_CONVERTED; + break; + + default: + indicator = SC_INDICATOR_UNKNOWN; + } + + if (format.hasProperty(QTextFormat::BackgroundBrush)) // win32, linux + indicator = SC_INDICATOR_TARGET; + +#ifdef Q_OS_OSX + if (charFormat.underlineStyle() == QTextCharFormat::SingleUnderline) { + QColor uc = charFormat.underlineColor(); + if (uc.lightness() < 2) { // osx + indicator = SC_INDICATOR_TARGET; + } + } +#endif + + for (int i = attr.start; i < attr.start+attr.length; i++) { + imeIndicator[i] = indicator; + } + } + } + return imeIndicator; +} + void ScintillaEditBase::inputMethodEvent(QInputMethodEvent *event) { // Copy & paste by johnsonj with a lot of helps of Neil // Great thanks for my forerunners, jiniya and BLUEnLIVE + if (sqt->pdoc->IsReadOnly() || sqt->SelectionContainsProtected()) { + // Here, a canceling and/or completing composition function is needed. + return; + } + + bool initialCompose = false; if (sqt->pdoc->TentativeActive()) { sqt->pdoc->TentativeUndo(); } else { // No tentative undo means start of this composition so // Fill in any virtual spaces. - sqt->FillVirtualSpace(); + initialCompose = true; } sqt->view.imeCaretBlockOverride = false; @@ -476,60 +562,11 @@ void ScintillaEditBase::inputMethodEvent(QInputMethodEvent *event) return; } + if (initialCompose) + sqt->ClearBeforeTentativeStart(); sqt->pdoc->TentativeStart(); // TentativeActive() from now on. - // Mark segments and get ime caret position. - unsigned int imeCaretPos = 0; - unsigned int imeIndicator[MAXLENINPUTIME] = {0}; -#ifdef Q_OS_LINUX - // ibus-qt has a bug to return only one underline style. - // Q_OS_LINUX blocks are temporary work around to cope with it. - unsigned int attrSegment = 0; -#endif - - foreach (QInputMethodEvent::Attribute attr, event->attributes()) { - if (attr.type == QInputMethodEvent::TextFormat) { - QTextFormat format = attr.value.value(); - QTextCharFormat charFormat = format.toCharFormat(); - - unsigned int indicator = SC_INDICATOR_UNKNOWN; - switch (charFormat.underlineStyle()) { - case QTextCharFormat::NoUnderline: - indicator = SC_INDICATOR_TARGET; //target input - break; - case QTextCharFormat::SingleUnderline: - case QTextCharFormat::DashUnderline: - indicator = SC_INDICATOR_INPUT; //normal input - break; - case QTextCharFormat::DotLine: - case QTextCharFormat::DashDotLine: - case QTextCharFormat::WaveUnderline: - case QTextCharFormat::SpellCheckUnderline: - indicator = SC_INDICATOR_CONVERTED; - break; - - default: - indicator = SC_INDICATOR_UNKNOWN; - } - -#ifdef Q_OS_LINUX - attrSegment++; - indicator = attr.start; -#endif - for (int i = attr.start; i < attr.start+attr.length; i++) { - imeIndicator[i] = indicator; - } - } else if (attr.type == QInputMethodEvent::Cursor) { - imeCaretPos = attr.start; - } - } -#ifdef Q_OS_LINUX - const bool targetInput = (attrSegment > 1) || ((imeCaretPos == 0) && (preeditStr != preeditString)); - preeditString = preeditStr; -#endif - // Display preedit characters one by one. - int imeCharPos[MAXLENINPUTIME] = {0}; - int numBytes = 0; + std::vector imeIndicator = MapImeIndicators(event); const bool recording = sqt->recordingMacro; sqt->recordingMacro = false; @@ -539,32 +576,28 @@ void ScintillaEditBase::inputMethodEvent(QInputMethodEvent *event) const QByteArray oneChar = sqt->BytesForDocument(oneCharUTF16); const int oneCharLen = oneChar.length(); - // Record character positions for moving ime caret. - numBytes += oneCharLen; - imeCharPos[i+1] = numBytes; - sqt->AddCharUTF(oneChar.data(), oneCharLen); -#ifdef Q_OS_LINUX - // Segment marked with imeCaretPos is for target input. - if ((imeIndicator[i] == imeCaretPos) && (targetInput)) { - DrawImeIndicator(SC_INDICATOR_TARGET, oneCharLen); - } else { - DrawImeIndicator(SC_INDICATOR_INPUT, oneCharLen); - } -#else DrawImeIndicator(imeIndicator[i], oneCharLen); -#endif i += ucWidth; - } + } sqt->recordingMacro = recording; // Move IME carets. + int imeCaretPos = GetImeCaretPos(event); + int imeEndToImeCaretU16 = imeCaretPos - preeditStrLen; + int imeCaretPosDoc = sqt->pdoc->GetRelativePositionUTF16(sqt->CurrentPosition(), imeEndToImeCaretU16); + + MoveImeCarets(- sqt->CurrentPosition() + imeCaretPosDoc); + if (IsHangul(preeditStr.at(0))) { +#ifndef Q_OS_WIN + if (imeCaretPos > 0) { + int oneCharBefore = sqt->pdoc->GetRelativePosition(sqt->CurrentPosition(), -1); + MoveImeCarets(- sqt->CurrentPosition() + oneCharBefore); + } +#endif sqt->view.imeCaretBlockOverride = true; - MoveImeCarets(- imeCharPos[preeditStrLen]); - } else { - MoveImeCarets(- imeCharPos[preeditStrLen] + imeCharPos[imeCaretPos]); } // Set candidate box position for Qt::ImMicroFocus. @@ -672,7 +705,7 @@ void ScintillaEditBase::notifyParent(SCNotification scn) break; case SCN_UPDATEUI: - emit updateUi(); + emit updateUi(scn.updated); break; case SCN_MODIFIED: @@ -718,7 +751,7 @@ void ScintillaEditBase::notifyParent(SCNotification scn) break; case SCN_URIDROPPED: - emit uriDropped(); + emit uriDropped(QString::fromUtf8(scn.text)); break; case SCN_DWELLSTART: @@ -753,6 +786,14 @@ void ScintillaEditBase::notifyParent(SCNotification scn) emit autoCompleteCancelled(); break; + case SCN_FOCUSIN: + emit focusChanged(true); + break; + + case SCN_FOCUSOUT: + emit focusChanged(false); + break; + default: return; } @@ -762,3 +803,12 @@ void ScintillaEditBase::event_command(uptr_t wParam, sptr_t lParam) { emit command(wParam, lParam); } + +int ScintillaEditBase::ModifiersOfKeyboard() const +{ + const bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier; + const bool ctrl = QApplication::keyboardModifiers() & Qt::ControlModifier; + const bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; + + return ScintillaQt::ModifierFlags(shift, ctrl, alt); +} diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaEditBase.h b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaEditBase.h similarity index 72% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaEditBase.h rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaEditBase.h index c4453334..6ae09110 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaEditBase.h +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaEditBase.h @@ -12,6 +12,11 @@ #ifndef SCINTILLAEDITBASE_H #define SCINTILLAEDITBASE_H +#include + +#include +#include + #include "Platform.h" #include "Scintilla.h" @@ -19,14 +24,14 @@ #include #include -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif class ScintillaQt; class SurfaceImpl; -struct SCNotification; +} + +#ifndef EXPORT_IMPORT_API #ifdef WIN32 #ifdef MAKING_LIBRARY #define EXPORT_IMPORT_API __declspec(dllexport) @@ -38,6 +43,7 @@ struct SCNotification; #else #define EXPORT_IMPORT_API #endif +#endif class EXPORT_IMPORT_API ScintillaEditBase : public QAbstractScrollArea { Q_OBJECT @@ -84,7 +90,7 @@ signals: void modifyAttemptReadOnly(); void key(int key); void doubleClick(int position, int line); - void updateUi(); + void updateUi(int updated); void modified(int type, int position, int length, int linesAdded, const QByteArray &text, int line, int foldNow, int foldPrev); void macroRecord(int message, uptr_t wParam, sptr_t lParam); @@ -93,7 +99,7 @@ signals: void needShown(int position, int length); void painted(); void userListSelection(); // Wants some args. - void uriDropped(); // Wants some args. + void uriDropped(const QString &uri); void dwellStart(int x, int y); void dwellEnd(int x, int y); void zoom(int zoom); @@ -102,6 +108,7 @@ signals: void callTipClick(); void autoCompleteSelection(int position, const QString &text); void autoCompleteCancelled(); + void focusChanged(bool focused); // Base notifications for compatibility with other Scintilla implementations void notify(SCNotification *pscn); @@ -114,28 +121,28 @@ signals: void resized(); protected: - virtual bool event(QEvent *event); - virtual void paintEvent(QPaintEvent *event); - virtual void wheelEvent(QWheelEvent *event); - virtual void focusInEvent(QFocusEvent *event); - virtual void focusOutEvent(QFocusEvent *event); - virtual void resizeEvent(QResizeEvent *event); - virtual void keyPressEvent(QKeyEvent *event); - virtual void mousePressEvent(QMouseEvent *event); - virtual void mouseReleaseEvent(QMouseEvent *event); - virtual void mouseDoubleClickEvent(QMouseEvent *event); - virtual void mouseMoveEvent(QMouseEvent *event); - virtual void contextMenuEvent(QContextMenuEvent *event); - virtual void dragEnterEvent(QDragEnterEvent *event); - virtual void dragLeaveEvent(QDragLeaveEvent *event); - virtual void dragMoveEvent(QDragMoveEvent *event); - virtual void dropEvent(QDropEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *event); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - virtual void scrollContentsBy(int, int) {} + bool event(QEvent *event) override; + void paintEvent(QPaintEvent *event) override; + void wheelEvent(QWheelEvent *event) override; + void focusInEvent(QFocusEvent *event) override; + void focusOutEvent(QFocusEvent *event) override; + void resizeEvent(QResizeEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void contextMenuEvent(QContextMenuEvent *event) override; + void dragEnterEvent(QDragEnterEvent *event) override; + void dragLeaveEvent(QDragLeaveEvent *event) override; + void dragMoveEvent(QDragMoveEvent *event) override; + void dropEvent(QDropEvent *event) override; + void inputMethodEvent(QInputMethodEvent *event) override; + QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; + void scrollContentsBy(int, int) override {} private: - ScintillaQt *sqt; + Scintilla::ScintillaQt *sqt; QTime time; @@ -145,12 +152,9 @@ private: int wheelDelta; static bool IsHangul(const QChar qchar); - void MoveImeCarets(int offset); + void MoveImeCarets(int offset); void DrawImeIndicator(int indicator, int len); + int ModifiersOfKeyboard() const; }; -#ifdef SCI_NAMESPACE -} -#endif - #endif /* SCINTILLAEDITBASE_H */ diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaEditBase.pro b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaEditBase.pro similarity index 89% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaEditBase.pro rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaEditBase.pro index c6de7743..0308816a 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaEditBase.pro +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaEditBase.pro @@ -10,8 +10,16 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = ScintillaEditBase TEMPLATE = lib CONFIG += lib_bundle +unix { + # requires C++11 support + greaterThan(QT_MAJOR_VERSION, 4){ + CONFIG += c++11 + } else { + QMAKE_CXXFLAGS += -std=c++0x + } +} -VERSION = 3.6.0 +VERSION = 3.10.6 SOURCES += \ PlatQt.cpp \ @@ -19,6 +27,7 @@ SOURCES += \ ScintillaEditBase.cpp \ ../../src/XPM.cxx \ ../../src/ViewStyle.cxx \ + ../../src/UniqueString.cxx \ ../../src/UniConversion.cxx \ ../../src/Style.cxx \ ../../src/Selection.cxx \ @@ -37,6 +46,7 @@ SOURCES += \ ../../src/EditModel.cxx \ ../../src/Document.cxx \ ../../src/Decoration.cxx \ + ../../src/DBCS.cxx \ ../../src/ContractionState.cxx \ ../../src/CharClassify.cxx \ ../../src/CellBuffer.cxx \ @@ -52,10 +62,11 @@ SOURCES += \ ../../lexlib/LexerNoExceptions.cxx \ ../../lexlib/LexerModule.cxx \ ../../lexlib/LexerBase.cxx \ + ../../lexlib/DefaultLexer.cxx \ ../../lexlib/CharacterSet.cxx \ ../../lexlib/Accessor.cxx \ ../../lexlib/CharacterCategory.cxx \ - ../../lexers/*.cxx + $$files(../../lexers/*.cxx, false) HEADERS += \ PlatQt.h \ @@ -64,7 +75,6 @@ HEADERS += \ ../../src/XPM.h \ ../../src/ViewStyle.h \ ../../src/UniConversion.h \ - ../../src/UnicodeFromUTF8.h \ ../../src/Style.h \ ../../src/SplitVector.h \ ../../src/Selection.h \ @@ -113,6 +123,9 @@ OTHER_FILES += INCLUDEPATH += ../../include ../../src ../../lexlib DEFINES += SCINTILLA_QT=1 MAKING_LIBRARY=1 SCI_LEXER=1 _CRT_SECURE_NO_DEPRECATE=1 +CONFIG(release, debug|release) { + DEFINES += NDEBUG=1 +} DESTDIR = ../../bin diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaQt.cpp b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaQt.cpp similarity index 88% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaQt.cpp rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaQt.cpp index 81150f33..98a8000f 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaQt.cpp +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaQt.cpp @@ -8,8 +8,8 @@ // Additions Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware // ScintillaQt.cpp - Qt specific subclass of ScintillaBase -#include "PlatQt.h" #include "ScintillaQt.h" +#include "PlatQt.h" #ifdef SCI_LEXER #include "LexerModule.h" #include "ExternalLexer.h" @@ -22,13 +22,11 @@ #endif #include #include +#include #include #include -#include -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif ScintillaQt::ScintillaQt(QAbstractScrollArea *parent) @@ -45,7 +43,7 @@ ScintillaQt::ScintillaQt(QAbstractScrollArea *parent) // Buffered drawing turned off by default to avoid this. WndProc(SCI_SETBUFFEREDDRAW, false, 0); - Initialise(); + Init(); for (TickReason tr = tickCaret; tr <= tickDwell; tr = static_cast(tr + 1)) { timers[tr] = 0; @@ -128,13 +126,9 @@ static ScintillaRectangularMime *singletonMime = 0; #endif -void ScintillaQt::Initialise() +void ScintillaQt::Init() { -#if defined(Q_OS_WIN) || defined(Q_OS_MAC) rectangularSelectionModifier = SCMOD_ALT; -#else - rectangularSelectionModifier = SCMOD_CTRL; -#endif #if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 0, 0) if (!singletonMime) { @@ -239,7 +233,7 @@ bool ScintillaQt::ValidCodePage(int codePage) const } -void ScintillaQt::ScrollText(int linesToMove) +void ScintillaQt::ScrollText(Sci::Line linesToMove) { int dy = vs.lineHeight * (linesToMove); scrollArea->viewport()->scroll(0, dy); @@ -257,7 +251,7 @@ void ScintillaQt::SetHorizontalScrollPos() emit horizontalScrolled(xOffset); } -bool ScintillaQt::ModifyScrollBars(int nMax, int nPage) +bool ScintillaQt::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) { bool modified = false; @@ -350,7 +344,7 @@ void ScintillaQt::PasteFromMode(QClipboard::Mode clipboardMode_) UndoGroup ug(pdoc); ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH); - InsertPasteShape(selText.Data(), static_cast(selText.Length()), + InsertPasteShape(selText.Data(), selText.Length(), selText.rectangular ? pasteRectangular : pasteStream); EnsureCaretVisible(); } @@ -386,10 +380,12 @@ void ScintillaQt::NotifyChange() void ScintillaQt::NotifyFocus(bool focus) { - emit command( - Platform::LongFromTwoShorts - (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), - reinterpret_cast(wMain.GetID())); + if (commandEvents) { + emit command( + Platform::LongFromTwoShorts + (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), + reinterpret_cast(wMain.GetID())); + } Editor::NotifyFocus(focus); } @@ -401,12 +397,13 @@ void ScintillaQt::NotifyParent(SCNotification scn) emit notifyParent(scn); } -/** -* Report that this Editor subclass has a working implementation of FineTickerStart. -*/ -bool ScintillaQt::FineTickerAvailable() +void ScintillaQt::NotifyURIDropped(const char *uri) { - return true; + SCNotification scn = {}; + scn.nmhdr.code = SCN_URIDROPPED; + scn.text = uri; + + NotifyParent(scn); } bool ScintillaQt::FineTickerRunning(TickReason reason) @@ -501,7 +498,7 @@ public: explicit CaseFolderDBCS(QTextCodec *codec_) : codec(codec_) { StandardASCII(); } - virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) { + size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override { if ((lenMixed == 1) && (sizeFolded > 0)) { folded[0] = mapping[static_cast(mixed[0])]; return 1; @@ -613,14 +610,41 @@ void ScintillaQt::StartDrag() } } inDragDrop = ddNone; - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); } +class CallTipImpl : public QWidget { +public: + CallTipImpl(CallTip *pct_) + : QWidget(nullptr, Qt::ToolTip), + pct(pct_) + { +#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) + setWindowFlag(Qt::WindowTransparentForInput); +#endif + } + + void paintEvent(QPaintEvent *) override + { + if (pct->inCallTipMode) { + Surface *surfaceWindow = Surface::Allocate(0); + surfaceWindow->Init(this); + surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == pct->codePage); + surfaceWindow->SetDBCSMode(pct->codePage); + pct->PaintCT(surfaceWindow); + delete surfaceWindow; + } + } + +private: + CallTip *pct; +}; + void ScintillaQt::CreateCallTipWindow(PRectangle rc) { if (!ct.wCallTip.Created()) { - QWidget *pCallTip = new QWidget(0, Qt::ToolTip); + QWidget *pCallTip = new CallTipImpl(&ct); ct.wCallTip = pCallTip; pCallTip->move(rc.left, rc.top); pCallTip->resize(rc.Width(), rc.Height()); @@ -648,23 +672,24 @@ void ScintillaQt::AddToPopUp(const char *label, this, SLOT(execCommand(QAction *))); } -sptr_t ScintillaQt::WndProc(unsigned int message, uptr_t wParam, sptr_t lParam) +sptr_t ScintillaQt::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { - switch (message) { + try { + switch (iMessage) { - case SCI_SETIMEINTERACTION: - // Only inline IME supported on Qt - break; + case SCI_SETIMEINTERACTION: + // Only inline IME supported on Qt + break; - case SCI_GRABFOCUS: - scrollArea->setFocus(Qt::OtherFocusReason); - break; + case SCI_GRABFOCUS: + scrollArea->setFocus(Qt::OtherFocusReason); + break; - case SCI_GETDIRECTFUNCTION: - return reinterpret_cast(DirectFunction); + case SCI_GETDIRECTFUNCTION: + return reinterpret_cast(DirectFunction); - case SCI_GETDIRECTPOINTER: - return reinterpret_cast(this); + case SCI_GETDIRECTPOINTER: + return reinterpret_cast(this); #ifdef SCI_LEXER case SCI_LOADLEXERLIBRARY: @@ -672,11 +697,15 @@ sptr_t ScintillaQt::WndProc(unsigned int message, uptr_t wParam, sptr_t lParam) break; #endif - default: - return ScintillaBase::WndProc(message, wParam, lParam); + default: + return ScintillaBase::WndProc(iMessage, wParam, lParam); + } + } catch (std::bad_alloc &) { + errorStatus = SC_STATUS_BADALLOC; + } catch (...) { + errorStatus = SC_STATUS_FAILURE; } - - return 0l; + return 0; } sptr_t ScintillaQt::DefWndProc(unsigned int, uptr_t, sptr_t) @@ -699,9 +728,9 @@ void ScintillaQt::PartialPaint(const PRectangle &rect) PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); - AutoSurface surface(this); - Paint(surface, rcPaint); - surface->Release(); + AutoSurface surfacePaint(this); + Paint(surfacePaint, rcPaint); + surfacePaint->Release(); if (paintState == paintAbandoned) { // FIXME: Failure to paint the requested rectangle in each @@ -735,7 +764,7 @@ void ScintillaQt::DragMove(const Point &point) void ScintillaQt::DragLeave() { - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); } void ScintillaQt::Drop(const Point &point, const QMimeData *data, bool move) @@ -751,6 +780,13 @@ void ScintillaQt::Drop(const Point &point, const QMimeData *data, bool move) DropAt(movePos, bytes, len, move, rectangular); } +void ScintillaQt::DropUrls(const QMimeData *data) +{ + foreach(const QUrl &url, data->urls()) { + NotifyURIDropped(url.toString().toUtf8().constData()); + } +} + void ScintillaQt::timerEvent(QTimerEvent *event) { for (TickReason tr=tickCaret; tr<=tickDwell; tr = static_cast(tr+1)) { diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaQt.h b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaQt.h similarity index 62% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaQt.h rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaQt.h index 6db30bde..b0a18750 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/ScintillaQt.h +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditBase/ScintillaQt.h @@ -11,23 +11,28 @@ #ifndef SCINTILLAQT_H #define SCINTILLAQT_H -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include #include #include +#include #include "Scintilla.h" #include "Platform.h" +#include "ILoader.h" #include "ILexer.h" +#include "CharacterCategory.h" #include "Position.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -36,7 +41,6 @@ #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "AutoComplete.h" @@ -65,9 +69,9 @@ #include #include -#ifdef SCI_NAMESPACE +class ScintillaEditBase; + namespace Scintilla { -#endif class ScintillaQt : public QObject, public ScintillaBase { Q_OBJECT @@ -97,46 +101,46 @@ private slots: void SelectionChanged(); private: - virtual void Initialise(); - virtual void Finalise(); - virtual bool DragThreshold(Point ptStart, Point ptNow); - virtual bool ValidCodePage(int codePage) const; + void Init(); + void Finalise() override; + bool DragThreshold(Point ptStart, Point ptNow) override; + bool ValidCodePage(int codePage) const override; private: - virtual void ScrollText(int linesToMove); - virtual void SetVerticalScrollPos(); - virtual void SetHorizontalScrollPos(); - virtual bool ModifyScrollBars(int nMax, int nPage); - virtual void ReconfigureScrollBars(); + void ScrollText(Sci::Line linesToMove) override; + void SetVerticalScrollPos() override; + void SetHorizontalScrollPos() override; + bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) override; + void ReconfigureScrollBars() override; void CopyToModeClipboard(const SelectionText &selectedText, QClipboard::Mode clipboardMode_); - virtual void Copy(); - virtual void CopyToClipboard(const SelectionText &selectedText); + void Copy() override; + void CopyToClipboard(const SelectionText &selectedText) override; void PasteFromMode(QClipboard::Mode clipboardMode_); - virtual void Paste(); - virtual void ClaimSelection(); - virtual void NotifyChange(); - virtual void NotifyFocus(bool focus); - virtual void NotifyParent(SCNotification scn); + void Paste() override; + void ClaimSelection() override; + void NotifyChange() override; + void NotifyFocus(bool focus) override; + void NotifyParent(SCNotification scn) override; + void NotifyURIDropped(const char *uri); int timers[tickDwell+1]; - virtual bool FineTickerAvailable(); - virtual bool FineTickerRunning(TickReason reason); - virtual void FineTickerStart(TickReason reason, int millis, int tolerance); - virtual void FineTickerCancel(TickReason reason); - virtual bool SetIdle(bool on); - virtual void SetMouseCapture(bool on); - virtual bool HaveMouseCapture(); - virtual void StartDrag(); + bool FineTickerRunning(TickReason reason) override; + void FineTickerStart(TickReason reason, int millis, int tolerance) override; + void FineTickerCancel(TickReason reason) override; + bool SetIdle(bool on) override; + void SetMouseCapture(bool on) override; + bool HaveMouseCapture() override; + void StartDrag() override; int CharacterSetOfDocument() const; const char *CharacterSetIDOfDocument() const; QString StringFromDocument(const char *s) const; QByteArray BytesForDocument(const QString &text) const; - virtual CaseFolder *CaseFolderForEncoding(); - virtual std::string CaseMapString(const std::string &s, int caseMapping); + CaseFolder *CaseFolderForEncoding() override; + std::string CaseMapString(const std::string &s, int caseMapping) override; - virtual void CreateCallTipWindow(PRectangle rc); - virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true); - virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); - virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); + void CreateCallTipWindow(PRectangle rc) override; + void AddToPopUp(const char *label, int cmd = 0, bool enabled = true) override; + sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; + sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; static sptr_t DirectFunction(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam); @@ -149,8 +153,9 @@ protected: void DragMove(const Point &point); void DragLeave(); void Drop(const Point &point, const QMimeData *data, bool move); + void DropUrls(const QMimeData *data); - void timerEvent(QTimerEvent *event); + void timerEvent(QTimerEvent *event) override; private: QAbstractScrollArea *scrollArea; @@ -162,11 +167,9 @@ private: bool dragWasDropped; int rectangularSelectionModifier; - friend class ScintillaEditBase; + friend class ::ScintillaEditBase; }; -#ifdef SCI_NAMESPACE } -#endif #endif // SCINTILLAQT_H diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/README b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/README similarity index 89% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/README rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/README index 4e4a63d8..d0c653d2 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/README +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/README @@ -1,86 +1,87 @@ -README for building of ScintillaEditPy on Qt with PySide - -This directory is for building a Python encapsulation of Scintilla for use -with PySide. For C++ libraries see the README in the parent directory. - - Prerequisites - -PySide and ScintillaEditPy currently only support Python 2.x. - -CMake may be used to rebuild PySide and is required on Windows. -It can be downloaded from -http://www.cmake.org/cmake/resources/software.html - -On Windows, PySide only supports Visual C++ 2008. The "Visual Studio 2008 -Command Prompt" should be used to run all build commands. -Visual C++ 2008 Express Edition can be downloaded from -http://msdn.microsoft.com/en-us/express/future/bb421473 - -Download and install PySide. Instructions are on the PySide web site -http://developer.qt.nokia.com/wiki/Category:LanguageBindings::PySide::Downloads - -For Linux, there may be both PySide library packages and PySide development -files. Both should be installed as ScintillaEditPy needs the headers and -libraries from the development package and runs with the normal library package. -On apt-based systems, the packages are libshiboken-dev, shiboken, libpyside-dev, -and python-pyside. python-dev is also needed for Python language headers. -On yum-based systems the packages are shiboken-devel, python-pyside-devel, -and python-devel. -The qmake program may not be in the path and can be found with -"find /usr -name qmake". - -On Windows, the PySide library packages can be downloaded from -http://developer.qt.nokia.com/wiki/PySide_Binaries_Windows -The PySide development files must be built from source using CMake as -described on the PySide site. This will create a Unix-style set of [bin, include, -lib, and share] directories in packaging\setuptools\install-py-qt. -There is no standard place for the PySide development files so copy them -to "\usr", creating it if needed. - -On OS X, a combined package with PySide libraries and PySide development -files can be downloaded from -http://developer.qt.nokia.com/wiki/PySide_Binaries_MacOSX -This package works best in combination with the Qt libraries for Mac from -http://qt.nokia.com/downloads/downloads#qt-lib - -The path should be modified so that a Python 2.x interpreter and Qt's "qmake" -program can be run by typing "python" or "qmake". - - Building - -There are several steps to building and they are encapsulated in the sepbuild.py -script which is run: - -python sepbuild.py - -This script first runs the WidgetGen.py script to fill out the ScintillaEdit.h, -ScintillaEdit.cpp and ScintillaConstants.py files. - -A short file "sepbuild.pri" is written out which contains a series of version and -path properties discovered by sepbuild.py which are used by qmake. - -Then it runs PySide's "shiboken" program to create C++ code that will act as a -bridge between Python and the C++ libraries. This code goes into the -ScintillaEditPy/ScintillaEditPy directory. Several log files are produced which can -help uncover problems in the bridge if it fails to build. - -The qmake program is run to produce make files from ScintillaEditPy.pro. - -The system make program is then run to build the library. The library is located in -the scintilla/bin directory as ScintillaEditPy.so for Unix systems and -ScintillaEditPy.pyd for Windows. - -A demonstration program can be run: - -python testsepq.py - -The individual steps in the script can be run manually if wanted although the -shiboken program has complex arguments and differs between systems so run -sepbuild.py and copy the section starting with a line containing "generatorrunner" -and continuing to "typesystem_ScintillaEdit.xml". - -On Windows, it is more difficult to set up an environment to debug ScintillaEditPy -since all the libraries have to be debug or all have to be release. The easy path -is to always build for release with "nmake release". - -To remove generated code, run "python sepbuild.py --clean". +README for building of ScintillaEditPy on Qt with PySide + +This directory is for building a Python encapsulation of Scintilla for use +with PySide. For C++ libraries see the README in the parent directory. + + Prerequisites + +PySide and ScintillaEditPy currently only support Python 2.x. + +CMake may be used to rebuild PySide and is required on Windows. +It can be downloaded from +http://www.cmake.org/cmake/resources/software.html + +On Windows, PySide only supports Visual C++ 2008. The "Visual Studio 2008 +Command Prompt" should be used to run all build commands. +Visual C++ 2008 Express Edition can be downloaded from +http://msdn.microsoft.com/en-us/express/future/bb421473 + +Download and install PySide. Instructions are on the PySide web site +http://developer.qt.nokia.com/wiki/Category:LanguageBindings::PySide::Downloads + +For Linux, there may be both PySide library packages and PySide development +files. Both should be installed as ScintillaEditPy needs the headers and +libraries from the development package and runs with the normal library package. +On apt-based systems, the packages are libshiboken-dev, shiboken, libpyside-dev, +and python-pyside. python-dev is also needed for Python language headers. +On yum-based systems the packages are shiboken-devel, python-pyside-devel, +and python-devel. +The qmake program may be called qmake-qt5 or qmake-qt4. +It can be found with: +which qmake-qt5 || which qmake-qt4 || which qmake + +On Windows, the PySide library packages can be downloaded from +http://developer.qt.nokia.com/wiki/PySide_Binaries_Windows +The PySide development files must be built from source using CMake as +described on the PySide site. This will create a Unix-style set of [bin, include, +lib, and share] directories in packaging\setuptools\install-py-qt. +There is no standard place for the PySide development files so copy them +to "\usr", creating it if needed. + +On OS X, a combined package with PySide libraries and PySide development +files can be downloaded from +http://developer.qt.nokia.com/wiki/PySide_Binaries_MacOSX +This package works best in combination with the Qt libraries for Mac from +http://qt.nokia.com/downloads/downloads#qt-lib + +The path should be modified so that a Python 2.x interpreter and Qt's "qmake" +program can be run by typing "python" or "qmake". + + Building + +There are several steps to building and they are encapsulated in the sepbuild.py +script which is run: + +python sepbuild.py + +This script first runs the WidgetGen.py script to fill out the ScintillaEdit.h, +ScintillaEdit.cpp and ScintillaConstants.py files. + +A short file "sepbuild.pri" is written out which contains a series of version and +path properties discovered by sepbuild.py which are used by qmake. + +Then it runs PySide's "shiboken" program to create C++ code that will act as a +bridge between Python and the C++ libraries. This code goes into the +ScintillaEditPy/ScintillaEditPy directory. Several log files are produced which can +help uncover problems in the bridge if it fails to build. + +The qmake program is run to produce make files from ScintillaEditPy.pro. + +The system make program is then run to build the library. The library is located in +the scintilla/bin directory as ScintillaEditPy.so for Unix systems and +ScintillaEditPy.pyd for Windows. + +A demonstration program can be run: + +python testsepq.py + +The individual steps in the script can be run manually if wanted although the +shiboken program has complex arguments and differs between systems so run +sepbuild.py and copy the section starting with a line containing "generatorrunner" +and continuing to "typesystem_ScintillaEdit.xml". + +On Windows, it is more difficult to set up an environment to debug ScintillaEditPy +since all the libraries have to be debug or all have to be release. The easy path +is to always build for release with "nmake release". + +To remove generated code, run "python sepbuild.py --clean". diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/ScintillaConstants.py.template b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/ScintillaConstants.py.template similarity index 100% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/ScintillaConstants.py.template rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/ScintillaConstants.py.template diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/ScintillaEditPy.pro b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/ScintillaEditPy.pro similarity index 84% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/ScintillaEditPy.pro rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/ScintillaEditPy.pro index 4eb968c0..42e38f34 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/ScintillaEditPy.pro +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/ScintillaEditPy.pro @@ -11,6 +11,15 @@ include(sepbuild.pri) VERSION = $$SCINTILLA_VERSION +unix { + # requires C++11 support + greaterThan(QT_MAJOR_VERSION, 4){ + CONFIG += c++11 + } else { + QMAKE_CXXFLAGS += -std=c++0x -Wno-deprecated-declarations + } +} + win32 { DebugBuild { TARGET_EXT = _d.pyd @@ -36,7 +45,9 @@ unix:!mac { } unix:linux-* { # gcc on freebsd 9.2, at least, doesn't support -Wno-empty-body - QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-empty-body + # g++ 7.x has deprecated std::auto_ptr but that is used by code generated by Shiboken so + # turn off warning. + QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-empty-body -Wno-deprecated-declarations LIBS += -ldl } @@ -95,9 +106,10 @@ SOURCES += \ ../ScintillaEditBase/PlatQt.cpp \ ../ScintillaEditBase/ScintillaQt.cpp \ ../ScintillaEditBase/ScintillaEditBase.cpp \ - ../../src/*.cxx \ - ../../lexlib/*.cxx \ - ../../lexers/*.cxx + $$files(../../src/*.cxx, false) \ + $$files(../../lexlib/*.cxx, false) \ + $$files(../../lexers/*.cxx, false) + # HEADERS is used to find what needs to be run through moc HEADERS += \ @@ -107,6 +119,9 @@ HEADERS += \ ../ScintillaEditBase/ScintillaEditBase.h DEFINES += SCINTILLA_QT=1 MAKING_LIBRARY=1 SCI_LEXER=1 _CRT_SECURE_NO_DEPRECATE=1 +CONFIG(release, debug|release) { + DEFINES += NDEBUG=1 +} DESTDIR = ../../bin diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/global.h b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/global.h similarity index 100% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/global.h rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/global.h diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/sepbuild.py b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/sepbuild.py similarity index 99% rename from dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/sepbuild.py rename to dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/sepbuild.py index c399eb3e..8fa9b4b2 100644 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/sepbuild.py +++ b/dep/scintilla/scintilla-3.10.6/qt/ScintillaEditPy/sepbuild.py @@ -172,7 +172,7 @@ class SepBuilder: self.qtStyleInterface = True def _setPySideBase(self, base): - + self.PySideBase = base def _try_pkgconfig(var, package, *relpath): try: @@ -209,7 +209,7 @@ class SepBuilder: f = WidgetGen.readInterface(False) os.chdir(os.path.join("..", "ScintillaEditPy")) options = {"qtStyle": self.qtStyleInterface} - GenerateFile("typesystem_ScintillaEdit.xml.template", "typesystem_ScintillaEdit.xml", + GenerateFile("typesystem_ScintillaEdit.xml.template", "typesystem_ScintillaEdit.xml", " - - diff --git a/dep/scintilla/scintilla-3.10.6/scripts/Dependencies.py b/dep/scintilla/scintilla-3.10.6/scripts/Dependencies.py new file mode 100644 index 00000000..90b8b952 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/scripts/Dependencies.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python +# Dependencies.py - discover, read, and write dependencies file for make. +# The format like the output from "g++ -MM" which produces a +# list of header (.h) files used by source files (.cxx). +# As a module, provides +# FindPathToHeader(header, includePath) -> path +# FindHeadersInFile(filePath) -> [headers] +# FindHeadersInFileRecursive(filePath, includePath, renames) -> [paths] +# FindDependencies(sourceGlobs, includePath, objExt, startDirectory, renames) -> [dependencies] +# ExtractDependencies(input) -> [dependencies] +# TextFromDependencies(dependencies) +# WriteDependencies(output, dependencies) +# UpdateDependencies(filepath, dependencies) +# PathStem(p) -> stem +# InsertSynonym(dependencies, current, additional) -> [dependencies] +# If run as a script reads from stdin and writes to stdout. +# Only tested with ASCII file names. +# Copyright 2019 by Neil Hodgson +# The License.txt file describes the conditions under which this software may be distributed. +# Requires Python 2.7 or later + +import codecs, glob, os, sys + +from . import FileGenerator + +continuationLineEnd = " \\" + +def FindPathToHeader(header, includePath): + for incDir in includePath: + relPath = os.path.join(incDir, header) + if os.path.exists(relPath): + return relPath + return "" + +fhifCache = {} # Remember the includes in each file. ~5x speed up. +def FindHeadersInFile(filePath): + if filePath not in fhifCache: + headers = [] + with codecs.open(filePath, "r", "utf-8") as f: + for line in f: + if line.strip().startswith("#include"): + parts = line.split() + if len(parts) > 1: + header = parts[1] + if header[0] != '<': # No system headers + headers.append(header.strip('"')) + fhifCache[filePath] = headers + return fhifCache[filePath] + +def FindHeadersInFileRecursive(filePath, includePath, renames): + headerPaths = [] + for header in FindHeadersInFile(filePath): + if header in renames: + header = renames[header] + relPath = FindPathToHeader(header, includePath) + if relPath and relPath not in headerPaths: + headerPaths.append(relPath) + subHeaders = FindHeadersInFileRecursive(relPath, includePath, renames) + headerPaths.extend(sh for sh in subHeaders if sh not in headerPaths) + return headerPaths + +def RemoveStart(relPath, start): + if relPath.startswith(start): + return relPath[len(start):] + return relPath + +def ciKey(f): + return f.lower() + +def FindDependencies(sourceGlobs, includePath, objExt, startDirectory, renames={}): + deps = [] + for sourceGlob in sourceGlobs: + sourceFiles = glob.glob(sourceGlob) + # Sorting the files minimizes deltas as order returned by OS may be arbitrary + sourceFiles.sort(key=ciKey) + for sourceName in sourceFiles: + objName = os.path.splitext(os.path.basename(sourceName))[0]+objExt + headerPaths = FindHeadersInFileRecursive(sourceName, includePath, renames) + depsForSource = [sourceName] + headerPaths + depsToAppend = [RemoveStart(fn.replace("\\", "/"), startDirectory) for + fn in depsForSource] + deps.append([objName, depsToAppend]) + return deps + +def PathStem(p): + """ Return the stem of a filename: "CallTip.o" -> "CallTip" """ + return os.path.splitext(os.path.basename(p))[0] + +def InsertSynonym(dependencies, current, additional): + """ Insert a copy of one object file with dependencies under a different name. + Used when one source file is used to create two object files with different + preprocessor definitions. """ + result = [] + for dep in dependencies: + result.append(dep) + if (dep[0] == current): + depAdd = [additional, dep[1]] + result.append(depAdd) + return result + +def ExtractDependencies(input): + """ Create a list of dependencies from input list of lines + Each element contains the name of the object and a list of + files that it depends on. + Dependencies that contain "/usr/" are removed as they are system headers. """ + + deps = [] + for line in input: + headersLine = line.startswith(" ") or line.startswith("\t") + line = line.strip() + isContinued = line.endswith("\\") + line = line.rstrip("\\ ") + fileNames = line.strip().split(" ") + if not headersLine: + # its a source file line, there may be headers too + sourceLine = fileNames[0].rstrip(":") + fileNames = fileNames[1:] + deps.append([sourceLine, []]) + deps[-1][1].extend(header for header in fileNames if "/usr/" not in header) + return deps + +def TextFromDependencies(dependencies): + """ Convert a list of dependencies to text. """ + text = "" + indentHeaders = "\t" + joinHeaders = continuationLineEnd + os.linesep + indentHeaders + for dep in dependencies: + object, headers = dep + text += object + ":" + for header in headers: + text += joinHeaders + text += header + if headers: + text += os.linesep + return text + +def UpdateDependencies(filepath, dependencies, comment=""): + """ Write a dependencies file if different from dependencies. """ + FileGenerator.UpdateFile(os.path.abspath(filepath), comment.rstrip() + os.linesep + + TextFromDependencies(dependencies)) + +def WriteDependencies(output, dependencies): + """ Write a list of dependencies out to a stream. """ + output.write(TextFromDependencies(dependencies)) + +if __name__ == "__main__": + """ Act as a filter that reformats input dependencies to one per line. """ + inputLines = sys.stdin.readlines() + deps = ExtractDependencies(inputLines) + WriteDependencies(sys.stdout, deps) diff --git a/dep/scintilla/scintilla-3.6.0/scripts/Face.py b/dep/scintilla/scintilla-3.10.6/scripts/Face.py similarity index 83% rename from dep/scintilla/scintilla-3.6.0/scripts/Face.py rename to dep/scintilla/scintilla-3.10.6/scripts/Face.py index 17d161fd..e4001e47 100644 --- a/dep/scintilla/scintilla-3.6.0/scripts/Face.py +++ b/dep/scintilla/scintilla-3.10.6/scripts/Face.py @@ -9,7 +9,7 @@ def sanitiseLine(line): line = line[:line.find("##")] line = line.strip() return line - + def decodeFunction(featureVal): retType, rest = featureVal.split(" ", 1) nameIdent, params = rest.split("(") @@ -17,13 +17,13 @@ def decodeFunction(featureVal): params, rest = params.split(")") param1, param2 = params.split(",") return retType, name, value, param1, param2 - + def decodeEvent(featureVal): retType, rest = featureVal.split(" ", 1) nameIdent, params = rest.split("(") name, value = nameIdent.split("=") return retType, name, value - + def decodeParam(p): param = p.strip() type = "" @@ -44,7 +44,7 @@ class Face: self.features = {} self.values = {} self.events = {} - + def ReadFromFile(self, name): currentCategory = "" currentComment = [] @@ -70,24 +70,25 @@ class Face: raise p1 = decodeParam(param1) p2 = decodeParam(param2) - self.features[name] = { - "FeatureType": featureType, + self.features[name] = { + "FeatureType": featureType, "ReturnType": retType, - "Value": value, - "Param1Type": p1[0], "Param1Name": p1[1], "Param1Value": p1[2], - "Param2Type": p2[0], "Param2Name": p2[1], "Param2Value": p2[2], + "Value": value, + "Param1Type": p1[0], "Param1Name": p1[1], "Param1Value": p1[2], + "Param2Type": p2[0], "Param2Name": p2[1], "Param2Value": p2[2], "Category": currentCategory, "Comment": currentComment } if value in self.values: raise Exception("Duplicate value " + value + " " + name) self.values[value] = 1 self.order.append(name) + currentComment = [] elif featureType == "evt": retType, name, value = decodeEvent(featureVal) - self.features[name] = { - "FeatureType": featureType, + self.features[name] = { + "FeatureType": featureType, "ReturnType": retType, - "Value": value, + "Value": value, "Category": currentCategory, "Comment": currentComment } if value in self.events: @@ -102,16 +103,18 @@ class Face: except ValueError: print("Failure %s" % featureVal) raise Exception() - self.features[name] = { - "FeatureType": featureType, - "Category": currentCategory, + self.features[name] = { + "FeatureType": featureType, + "Category": currentCategory, "Value": value } self.order.append(name) elif featureType == "enu" or featureType == "lex": name, value = featureVal.split("=", 1) - self.features[name] = { - "FeatureType": featureType, - "Category": currentCategory, - "Value": value } + self.features[name] = { + "FeatureType": featureType, + "Category": currentCategory, + "Value": value, + "Comment": currentComment } self.order.append(name) + currentComment = [] diff --git a/dep/scintilla/scintilla-3.6.0/scripts/FileGenerator.py b/dep/scintilla/scintilla-3.10.6/scripts/FileGenerator.py similarity index 73% rename from dep/scintilla/scintilla-3.6.0/scripts/FileGenerator.py rename to dep/scintilla/scintilla-3.10.6/scripts/FileGenerator.py index 01a79bf9..7022769f 100644 --- a/dep/scintilla/scintilla-3.6.0/scripts/FileGenerator.py +++ b/dep/scintilla/scintilla-3.10.6/scripts/FileGenerator.py @@ -7,8 +7,8 @@ # Requires Python 2.5 or later # The files are copied to a string apart from sections between a # ++Autogenerated comment and a --Autogenerated comment which is -# generated by the CopyWithInsertion function. After the whole string is -# instantiated, it is compared with the target file and if different the file +# generated by the CopyWithInsertion function. After the whole string is +# instantiated, it is compared with the target file and if different the file # is rewritten. from __future__ import with_statement @@ -28,7 +28,7 @@ def UpdateFile(filename, updated): # Same as before so don't write return os.unlink(filename) - except IOError: # File is not there yet + except IOError: # File is not there yet newOrChanged = "New" with codecs.open(filename, "w", "utf-8") as outfile: outfile.write(updated) @@ -137,6 +137,25 @@ def Regenerate(filename, commentPrefix, *lists): """ Generate(filename, filename, commentPrefix, *lists) +def UpdateLineInPlistFile(path, key, value): + """Replace a single string value preceded by 'key' in an XML plist file. + """ + lines = [] + keyCurrent = "" + with codecs.open(path, "rb", "utf-8") as f: + for l in f.readlines(): + ls = l.strip() + if ls.startswith(""): + keyCurrent = ls.replace("", "").replace("", "") + elif ls.startswith(""): + if keyCurrent == key: + start, tag, rest = l.partition("") + val, etag, end = rest.partition("") + l = start + tag + value + etag + end + lines.append(l) + contents = "".join(lines) + UpdateFile(path, contents) + def UpdateLineInFile(path, linePrefix, lineReplace): lines = [] updated = False @@ -151,6 +170,50 @@ def UpdateLineInFile(path, linePrefix, lineReplace): contents = lineEnd.join(lines) + lineEnd UpdateFile(path, contents) +def ReadFileAsList(path): + """Read all the lnes in the file and return as a list of strings without line ends. + """ + with codecs.open(path, "rU", "utf-8") as f: + return [l.rstrip('\n') for l in f] + +def UpdateFileFromLines(path, lines, lineEndToUse): + """Join the lines with the lineEndToUse then update file if the result is different. + """ + contents = lineEndToUse.join(lines) + lineEndToUse + UpdateFile(path, contents) + +def FindSectionInList(lines, markers): + """Find a section defined by an initial start marker, an optional secondary + marker and an end marker. + The section is between the secondary/initial start and the end. + Report as a slice object so the section can be extracted or replaced. + Raises an exception if the markers can't be found. + """ + start = -1 + end = -1 + state = 0 + for i, l in enumerate(lines): + if markers[0] in l: + if markers[1]: + state = 1 + else: + start = i+1 + state = 2 + elif state == 1: + if markers[1] in l: + start = i+1 + state = 2 + elif state == 2: + if markers[2] in l: + end = i + state = 3 + # Check that section was found + if start == -1: + raise Exception("Could not find start marker(s) |" + markers[0] + "|" + markers[1] + "|") + if end == -1: + raise Exception("Could not find end marker " + markers[2]) + return slice(start, end) + def ReplaceREInFile(path, match, replace): with codecs.open(path, "r", "utf-8") as f: contents = f.read() diff --git a/dep/scintilla/scintilla-3.6.0/scripts/GenerateCaseConvert.py b/dep/scintilla/scintilla-3.10.6/scripts/GenerateCaseConvert.py similarity index 91% rename from dep/scintilla/scintilla-3.6.0/scripts/GenerateCaseConvert.py rename to dep/scintilla/scintilla-3.10.6/scripts/GenerateCaseConvert.py index 37506b7b..1e85a1c4 100644 --- a/dep/scintilla/scintilla-3.6.0/scripts/GenerateCaseConvert.py +++ b/dep/scintilla/scintilla-3.10.6/scripts/GenerateCaseConvert.py @@ -3,15 +3,15 @@ # Requires Python 3.3 or later # Should not be run with old versions of Python. -# Current best approach divides case conversions into two cases: +# Current best approach divides case conversions into two cases: # simple symmetric and complex. # Simple symmetric is where a lower and upper case pair convert to each -# other and the folded form is the same as the lower case. +# other and the folded form is the same as the lower case. # There are 1006 symmetric pairs. # These are further divided into ranges (stored as lower, upper, range length, -# range pitch and singletons (stored as lower, upper). +# range pitch and singletons (stored as lower, upper). # Complex is for cases that don't fit the above: where there are multiple -# characters in one of the forms or fold is different to lower or +# characters in one of the forms or fold is different to lower or # lower(upper(x)) or upper(lower(x)) are not x. These are represented as UTF-8 # strings with original, folded, upper, and lower separated by '|'. # There are 126 complex cases. @@ -33,7 +33,7 @@ def contiguousRanges(l, diff): def flatten(listOfLists): "Flatten one level of nesting" return itertools.chain.from_iterable(listOfLists) - + def conversionSets(): # For all Unicode characters, see whether they have case conversions # Return 2 sets: one of simple symmetric conversion cases and another @@ -89,7 +89,7 @@ def groupRanges(symmetrics): contiguousGroups = flatten([contiguousRanges(g, 1) for g in groups]) longGroups = [(x[0][0], x[0][1], len(x), 1) for x in contiguousGroups if len(x) > 4] - + oneDiffs = [s for s in symmetrics if s[2] == 1] contiguousOnes = flatten([contiguousRanges(g, 2) for g in [oneDiffs]]) longOneGroups = [(x[0][0], x[0][1], len(x), 2) for x in contiguousOnes if len(x) > 4] @@ -97,27 +97,27 @@ def groupRanges(symmetrics): rangeGroups = sorted(longGroups+longOneGroups, key=lambda s: s[0]) rangeCoverage = list(flatten([range(r[0], r[0]+r[2]*r[3], r[3]) for r in rangeGroups])) - + nonRanges = [(l, u) for l, u, d in symmetrics if l not in rangeCoverage] return rangeGroups, nonRanges def escape(s): - return "".join((chr(c) if chr(c) in string.ascii_letters else "\\x%x" % c) for c in s.encode('utf-8')) + return "".join((chr(c) if chr(c) in string.ascii_letters else "\\x%x" % c) for c in s.encode('utf-8')) def updateCaseConvert(): symmetrics, complexes = conversionSets() - + rangeGroups, nonRanges = groupRanges(symmetrics) print(len(rangeGroups), "ranges") - rangeLines = ["%d,%d,%d,%d, " % x for x in rangeGroups] + rangeLines = ["%d,%d,%d,%d," % x for x in rangeGroups] print(len(nonRanges), "non ranges") - nonRangeLines = ["%d,%d, " % x for x in nonRanges] - + nonRangeLines = ["%d,%d," % x for x in nonRanges] + print(len(symmetrics), "symmetric") - + complexLines = ['"%s|%s|%s|%s|"' % tuple(escape(t) for t in x) for x in complexes] print(len(complexLines), "complex") diff --git a/dep/scintilla/scintilla-3.6.0/scripts/GenerateCharacterCategory.py b/dep/scintilla/scintilla-3.10.6/scripts/GenerateCharacterCategory.py similarity index 70% rename from dep/scintilla/scintilla-3.6.0/scripts/GenerateCharacterCategory.py rename to dep/scintilla/scintilla-3.10.6/scripts/GenerateCharacterCategory.py index 4596eec6..ba6ac858 100644 --- a/dep/scintilla/scintilla-3.6.0/scripts/GenerateCharacterCategory.py +++ b/dep/scintilla/scintilla-3.10.6/scripts/GenerateCharacterCategory.py @@ -17,17 +17,27 @@ def findCategories(filename): def updateCharacterCategory(filename): values = ["// Created with Python %s, Unicode %s" % ( platform.python_version(), unicodedata.unidata_version)] - category = unicodedata.category(chr(0)) + startRange = 0 + category = unicodedata.category(chr(startRange)) + table = [] for ch in range(sys.maxunicode): uch = chr(ch) - if unicodedata.category(uch) != category: + current = unicodedata.category(uch) + if current != category: value = startRange * 32 + categories.index(category) - values.append("%d," % value) - category = unicodedata.category(uch) + table.append(value) + category = current startRange = ch value = startRange * 32 + categories.index(category) - values.append("%d," % value) + table.append(value) + + # the sentinel value is used to simplify CharacterCategoryMap::Optimize() + category = 'Cn' + value = (sys.maxunicode + 1)*32 + categories.index(category) + table.append(value) + + values.extend(["%d," % value for value in table]) Regenerate(filename, "//", values) diff --git a/dep/scintilla/scintilla-3.6.0/scripts/HFacer.py b/dep/scintilla/scintilla-3.10.6/scripts/HFacer.py similarity index 98% rename from dep/scintilla/scintilla-3.6.0/scripts/HFacer.py rename to dep/scintilla/scintilla-3.10.6/scripts/HFacer.py index ed36df4e..fe164256 100755 --- a/dep/scintilla/scintilla-3.6.0/scripts/HFacer.py +++ b/dep/scintilla/scintilla-3.10.6/scripts/HFacer.py @@ -58,4 +58,4 @@ def RegenerateAll(root, showMaxID): #~ print(v) if __name__ == "__main__": - RegenerateAll("../", True) + RegenerateAll("../", True) diff --git a/dep/scintilla/scintilla-3.10.6/scripts/HeaderCheck.py b/dep/scintilla/scintilla-3.10.6/scripts/HeaderCheck.py new file mode 100644 index 00000000..715859c5 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/scripts/HeaderCheck.py @@ -0,0 +1,93 @@ +# Script to check that headers are in a consistent order +# Requires Python 2.6 or later + +from __future__ import print_function +import codecs, glob, os, platform, sys, unicodedata + +def ciCompare(a,b): + return cmp(a.lower(), b.lower()) + +def ciKey(a): + return a.lower() + +def SortListInsensitive(l): + try: # Try key function + l.sort(key=ciKey) + except TypeError: # Earlier version of Python, so use comparison function + l.sort(ciCompare) + +def IsHeader(x): + return x.strip().startswith("#") and ("include" in x or "import" in x) + +def ExtractHeaders(filename): + with codecs.open(filename, "r", "UTF-8") as infile: + includeLines = [x.strip()[1:].strip()[7:].strip() for x in infile.readlines() if \ + IsHeader(x)] + if '.' not in filename: + print(filename) + for n in includeLines: + print(n) + print() + return includeLines + +def CheckFiles(root): + # Find all the lexer source code files + filePaths = glob.glob(root + "/include/*.h") + filePaths += glob.glob(root + "/src/*.cxx") + SortListInsensitive(filePaths) + filePaths += glob.glob(root + "/lexlib/*.cxx") + filePaths += glob.glob(root + "/lexers/*.cxx") + filePaths += glob.glob(root + "/win32/*.cxx") + filePaths += glob.glob(root + "/gtk/*.cxx") + filePaths += glob.glob(root + "/cocoa/*.mm") + filePaths += glob.glob(root + "/cocoa/*.h") + filePaths += glob.glob(root + "/test/unit/*.cxx") + # The Qt platform code interleaves system and Scintilla headers + #~ filePaths += glob.glob(root + "/qt/ScintillaEditBase/*.cpp") + #~ filePaths += glob.glob(root + "/qt/ScintillaEdit/*.cpp") + filePaths += glob.glob(root + "/curses/*.cxx") + #~ print(filePaths) + masterHeaderList = ExtractHeaders(root + "/scripts/HeaderOrder.txt") + for f in filePaths: + if "LexCaml" in f: + continue + print(" File ", f) + try: + incs = ExtractHeaders(f) + except UnicodeDecodeError: + #~ print("UnicodeDecodeError\n") + continue + #~ print("\n".join(incs)) + news = set(incs) - set(masterHeaderList) + #~ print("") + #~ print("\n".join(incs)) + #~ print("") + ended = False + m = 0 + i = 0 + while i < len(incs): + if m == len(masterHeaderList): + print("**** extend", incs[i:]) + masterHeaderList.extend(incs[i:]) + break + if masterHeaderList[m] == incs[i]: + #~ print("equal", masterHeaderList[m]) + i += 1 + m += 1 + else: + if masterHeaderList[m] not in incs: + #~ print("skip", masterHeaderList[m]) + m += 1 + elif incs[i] not in masterHeaderList: + print(f + ":1: Add master", incs[i]) + masterHeaderList.insert(m, incs[i]) + i += 1 + m += 1 + else: + print(f + ":1: Header out of order", incs[i], masterHeaderList[m]) + print("incs", " ".join(incs)) + i += 1 + #~ return + #print("Master header list", " ".join(masterHeaderList)) + +CheckFiles("..") diff --git a/dep/scintilla/scintilla-3.6.0/scripts/HeaderOrder.txt b/dep/scintilla/scintilla-3.10.6/scripts/HeaderOrder.txt similarity index 71% rename from dep/scintilla/scintilla-3.6.0/scripts/HeaderOrder.txt rename to dep/scintilla/scintilla-3.10.6/scripts/HeaderOrder.txt index eb00e16e..d5b876e1 100644 --- a/dep/scintilla/scintilla-3.6.0/scripts/HeaderOrder.txt +++ b/dep/scintilla/scintilla-3.10.6/scripts/HeaderOrder.txt @@ -3,36 +3,54 @@ // and each of these groups are then divided into directory groups. // C standard library +#include #include +#include #include #include -#include #include #include #include #include #include #include +#include // C++ wrappers of C standard library +#include #include +#include #include #include #include #include +#include +#include #include +#include // C++ standard library #include #include +#include +#include #include #include #include #include #include +#include #include +#include +#include #include +#include #include +#include +#include + +// POSIX +#include // GTK+ headers #include @@ -40,6 +58,8 @@ #include #include #include +#include +#include // Windows headers #include @@ -53,6 +73,10 @@ // Cocoa headers #include +#import +#import +#import +#import // Scintilla headers @@ -61,6 +85,8 @@ // include #include "Platform.h" +#include "Sci_Position.h" +#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" #include "ScintillaWidget.h" @@ -80,6 +106,7 @@ #include "OptionSet.h" #include "SparseState.h" #include "SubStyles.h" +#include "DefaultLexer.h" #include "LexerBase.h" #include "LexerSimple.h" #include "LexerNoExceptions.h" @@ -88,9 +115,12 @@ #include "Catalogue.h" #include "Position.h" +#include "IntegerRectangle.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" +#include "SparseVector.h" #include "ContractionState.h" #include "CellBuffer.h" #include "PerLine.h" @@ -105,9 +135,10 @@ #include "Decoration.h" #include "CaseFolder.h" #include "Document.h" +#include "RESearch.h" #include "CaseConvert.h" #include "UniConversion.h" -#include "UnicodeFromUTF8.h" +#include "DBCS.h" #include "Selection.h" #include "PositionCache.h" #include "FontQuality.h" @@ -115,6 +146,7 @@ #include "MarginView.h" #include "EditView.h" #include "Editor.h" +#include "ElapsedPeriod.h" #include "AutoComplete.h" #include "ScintillaBase.h" @@ -126,12 +158,27 @@ // win32 #include "PlatWin.h" #include "HanjaDic.h" +#include "ScintillaWin.h" // gtk +#include "ScintillaGTK.h" +#include "scintilla-marshal.h" +#include "ScintillaGTKAccessible.h" #include "Converter.h" // cocoa #include "QuartzTextStyle.h" #include "QuartzTextStyleAttribute.h" +#include "QuartzTextLayout.h" #import "InfoBarCommunicator.h" #include "InfoBar.h" +#import "ScintillaView.h" +#import "ScintillaCocoa.h" +#import "PlatCocoa.h" + +// curses +#include "ScintillaCurses.h" + +// Catch testing framework +#include "catch.hpp" + diff --git a/dep/scintilla/scintilla-3.10.6/scripts/LexGen.py b/dep/scintilla/scintilla-3.10.6/scripts/LexGen.py new file mode 100644 index 00000000..8748a744 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/scripts/LexGen.py @@ -0,0 +1,135 @@ +#!/usr/bin/env python +# LexGen.py - implemented 2002 by Neil Hodgson neilh@scintilla.org +# Released to the public domain. + +# Regenerate the Scintilla source files that list all the lexers. +# Should be run whenever a new lexer is added or removed. +# Requires Python 2.5 or later +# Files are regenerated in place with templates stored in comments. +# The format of generation comments is documented in FileGenerator.py. + +from FileGenerator import Regenerate, UpdateLineInFile, \ + ReplaceREInFile, UpdateLineInPlistFile, ReadFileAsList, UpdateFileFromLines, \ + FindSectionInList +import ScintillaData +import HFacer +import uuid +import sys + +sys.path.append("../") + +import win32.DepGen +import gtk.DepGen + +def UpdateVersionNumbers(sci, root): + UpdateLineInFile(root + "win32/ScintRes.rc", "#define VERSION_SCINTILLA", + "#define VERSION_SCINTILLA \"" + sci.versionDotted + "\"") + UpdateLineInFile(root + "win32/ScintRes.rc", "#define VERSION_WORDS", + "#define VERSION_WORDS " + sci.versionCommad) + UpdateLineInFile(root + "qt/ScintillaEditBase/ScintillaEditBase.pro", + "VERSION =", + "VERSION = " + sci.versionDotted) + UpdateLineInFile(root + "qt/ScintillaEdit/ScintillaEdit.pro", + "VERSION =", + "VERSION = " + sci.versionDotted) + UpdateLineInFile(root + "doc/ScintillaDownload.html", " Release", + " Release " + sci.versionDotted) + ReplaceREInFile(root + "doc/ScintillaDownload.html", + r"/www.scintilla.org/([a-zA-Z]+)\d\d\d\d?", + r"/www.scintilla.org/\g<1>" + sci.version) + UpdateLineInFile(root + "doc/index.html", + ' Release version', + ' Release version ' +\ + sci.versionDotted + '
    ') + UpdateLineInFile(root + "doc/index.html", + ' Site last modified', + ' Site last modified ' + sci.mdyModified + '
    ') + UpdateLineInFile(root + "doc/ScintillaHistory.html", + ' Released ', + ' Released ' + sci.dmyModified + '.') + UpdateLineInPlistFile(root + "cocoa/ScintillaFramework/Info.plist", + "CFBundleVersion", sci.versionDotted) + UpdateLineInPlistFile(root + "cocoa/ScintillaFramework/Info.plist", + "CFBundleShortVersionString", sci.versionDotted) + +# Last 24 digits of UUID, used for item IDs in Xcode +def uid24(): + return str(uuid.uuid4()).replace("-", "").upper()[-24:] + +def ciLexerKey(a): + return a.split()[2].lower() + +""" + 11F35FDB12AEFAF100F0236D /* LexA68k.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11F35FDA12AEFAF100F0236D /* LexA68k.cxx */; }; + 11F35FDA12AEFAF100F0236D /* LexA68k.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexA68k.cxx; path = ../../lexers/LexA68k.cxx; sourceTree = SOURCE_ROOT; }; + 11F35FDA12AEFAF100F0236D /* LexA68k.cxx */, + 11F35FDB12AEFAF100F0236D /* LexA68k.cxx in Sources */, +""" +def RegenerateXcodeProject(path, lexers, lexerReferences): + # Build 4 blocks for insertion: + # Each markers contains a unique section start, an optional wait string, and a section end + + markersPBXBuildFile = ["Begin PBXBuildFile section", "", "End PBXBuildFile section"] + sectionPBXBuildFile = [] + + markersPBXFileReference = ["Begin PBXFileReference section", "", "End PBXFileReference section"] + sectionPBXFileReference = [] + + markersLexers = ["/* Lexers */ =", "children", ");"] + sectionLexers = [] + + markersPBXSourcesBuildPhase = ["Begin PBXSourcesBuildPhase section", "files", ");"] + sectionPBXSourcesBuildPhase = [] + + for lexer in lexers: + if lexer not in lexerReferences: + uid1 = uid24() + uid2 = uid24() + print("Lexer", lexer, "is not in Xcode project. Use IDs", uid1, uid2) + lexerReferences[lexer] = [uid1, uid2] + linePBXBuildFile = "\t\t{} /* {}.cxx in Sources */ = {{isa = PBXBuildFile; fileRef = {} /* {}.cxx */; }};".format(uid1, lexer, uid2, lexer) + linePBXFileReference = "\t\t{} /* {}.cxx */ = {{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = {}.cxx; path = ../../lexers/{}.cxx; sourceTree = SOURCE_ROOT; }};".format(uid2, lexer, lexer, lexer) + lineLexers = "\t\t\t\t{} /* {}.cxx */,".format(uid2, lexer) + linePBXSourcesBuildPhase = "\t\t\t\t{} /* {}.cxx in Sources */,".format(uid1, lexer) + sectionPBXBuildFile.append(linePBXBuildFile) + sectionPBXFileReference.append(linePBXFileReference) + sectionLexers.append(lineLexers) + sectionPBXSourcesBuildPhase.append(linePBXSourcesBuildPhase) + + lines = ReadFileAsList(path) + + sli = FindSectionInList(lines, markersPBXBuildFile) + lines[sli.stop:sli.stop] = sectionPBXBuildFile + + sli = FindSectionInList(lines, markersPBXFileReference) + lines[sli.stop:sli.stop] = sectionPBXFileReference + + sli = FindSectionInList(lines, markersLexers) + # This section is shown in the project outline so sort it to make it easier to navigate. + allLexers = sorted(lines[sli.start:sli.stop] + sectionLexers, key=ciLexerKey) + lines[sli] = allLexers + + sli = FindSectionInList(lines, markersPBXSourcesBuildPhase) + lines[sli.stop:sli.stop] = sectionPBXSourcesBuildPhase + + UpdateFileFromLines(path, lines, "\n") + +def RegenerateAll(root): + + sci = ScintillaData.ScintillaData(root) + + Regenerate(root + "src/Catalogue.cxx", "//", sci.lexerModules) + Regenerate(root + "win32/scintilla.mak", "#", sci.lexFiles) + + win32.DepGen.Generate() + gtk.DepGen.Generate() + + RegenerateXcodeProject(root + "cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj", + sci.lexFiles, sci.lexersXcode) + + UpdateVersionNumbers(sci, root) + + HFacer.RegenerateAll(root, False) + +if __name__=="__main__": + RegenerateAll("../") diff --git a/dep/scintilla/scintilla-3.6.0/scripts/ScintillaData.py b/dep/scintilla/scintilla-3.10.6/scripts/ScintillaData.py similarity index 71% rename from dep/scintilla/scintilla-3.6.0/scripts/ScintillaData.py rename to dep/scintilla/scintilla-3.10.6/scripts/ScintillaData.py index f9c7718b..385db59a 100644 --- a/dep/scintilla/scintilla-3.6.0/scripts/ScintillaData.py +++ b/dep/scintilla/scintilla-3.10.6/scripts/ScintillaData.py @@ -7,14 +7,14 @@ # version # versionDotted # versionCommad -# +# # Date last modified # dateModified # yearModified # mdyModified # dmyModified # myModified -# +# # Information about lexers and properties defined in lexers # lexFiles # sorted list of lexer files @@ -24,9 +24,13 @@ # sorted list of lexer properties # propertyDocuments # dictionary of property documentation { name: document string } +# sclexFromName +# dictionary of SCLEX_* IDs { name: SCLEX_ID } +# fileFromSclex +# dictionary of file names { SCLEX_ID: file name } # This file can be run to see the data it provides. -# Requires Python 2.5 or later +# Requires Python 2.7 or later from __future__ import with_statement @@ -36,13 +40,48 @@ import FileGenerator def FindModules(lexFile): modules = [] + partLine = "" with open(lexFile) as f: for l in f.readlines(): - if l.startswith("LexerModule"): - l = l.replace("(", " ") - modules.append(l.split()[1]) + l = l.rstrip() + if partLine or l.startswith("LexerModule"): + if ")" in l: + l = partLine + l + l = l.replace("(", " ") + l = l.replace(")", " ") + l = l.replace(",", " ") + parts = l.split() + modules.append([parts[1], parts[2], parts[4][1:-1]]) + partLine = "" + else: + partLine = partLine + l return modules +def FindLexersInXcode(xCodeProject): + lines = FileGenerator.ReadFileAsList(xCodeProject) + + uidsOfBuild = {} + markersPBXBuildFile = ["Begin PBXBuildFile section", "", "End PBXBuildFile section"] + for buildLine in lines[FileGenerator.FindSectionInList(lines, markersPBXBuildFile)]: + # Occurs for each file in the build. Find the UIDs used for the file. + #\t\t[0-9A-F]+ /* [a-zA-Z]+.cxx in sources */ = {isa = PBXBuildFile; fileRef = [0-9A-F]+ /* [a-zA-Z]+ */; }; + pieces = buildLine.split() + uid1 = pieces[0] + filename = pieces[2].split(".")[0] + uid2 = pieces[12] + uidsOfBuild[filename] = [uid1, uid2] + + lexers = {} + markersLexers = ["/* Lexers */ =", "children", ");"] + for lexerLine in lines[FileGenerator.FindSectionInList(lines, markersLexers)]: + #\t\t\t\t[0-9A-F]+ /* [a-zA-Z]+.cxx */, + uid, _, rest = lexerLine.partition("/* ") + uid = uid.strip() + lexer, _, _ = rest.partition(".") + lexers[lexer] = uidsOfBuild[lexer] + + return lexers + # Properties that start with lexer. or fold. are automatically found but there are some # older properties that don't follow this pattern so must be explicitly listed. knownIrregularProperties = [ @@ -156,10 +195,16 @@ class ScintillaData: # Discover verion information with open(scintillaRoot + "version.txt") as f: self.version = f.read().strip() - self.versionDotted = self.version[0] + '.' + self.version[1] + '.' + \ - self.version[2] - self.versionCommad = self.version[0] + ', ' + self.version[1] + ', ' + \ - self.version[2] + ', 0' + if len(self.version) == 3: + self.versionDotted = self.version[0] + '.' + self.version[1] + '.' + \ + self.version[2] + self.versionCommad = self.version[0] + ', ' + self.version[1] + ', ' + \ + self.version[2] + ', 0' + else: + self.versionDotted = self.version[0] + '.' + self.version[1:3] + '.' + \ + self.version[3] + self.versionCommad = self.version[0] + ', ' + self.version[1:3] + ', ' + \ + self.version[3] + ', 0' with open(scintillaRoot + "doc/index.html") as f: self.dateModified = [l for l in f.readlines() if "Date.Modified" in l]\ @@ -185,8 +230,14 @@ class ScintillaData: self.lexerModules = [] lexerProperties = set() self.propertyDocuments = {} + self.sclexFromName = {} + self.fileFromSclex = {} for lexFile in lexFilePaths: - self.lexerModules.extend(FindModules(lexFile)) + modules = FindModules(lexFile) + for module in modules: + self.sclexFromName[module[2]] = module[1] + self.fileFromSclex[module[1]] = lexFile + self.lexerModules.append(module[0]) for k in FindProperties(lexFile).keys(): lexerProperties.add(k) documents = FindPropertyDocumentation(lexFile) @@ -197,6 +248,7 @@ class ScintillaData: self.lexerProperties = list(lexerProperties) SortListInsensitive(self.lexerProperties) + self.lexersXcode = FindLexersInXcode(scintillaRoot + "cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj") self.credits = FindCredits(scintillaRoot + "doc/ScintillaHistory.html") def printWrapped(text): @@ -209,6 +261,14 @@ if __name__=="__main__": sci.dateModified, sci.yearModified, sci.mdyModified, sci.dmyModified, sci.myModified)) printWrapped(str(len(sci.lexFiles)) + " lexer files: " + ", ".join(sci.lexFiles)) printWrapped(str(len(sci.lexerModules)) + " lexer modules: " + ", ".join(sci.lexerModules)) + #~ printWrapped(str(len(sci.lexersXcode)) + " Xcode lexer references: " + ", ".join( + #~ [lex+":"+uids[0]+","+uids[1] for lex, uids in sci.lexersXcode.items()])) + print("Lexer name to ID:") + lexNames = sorted(sci.sclexFromName.keys()) + for lexName in lexNames: + sclex = sci.sclexFromName[lexName] + fileName = os.path.basename(sci.fileFromSclex[sclex]) + print(" " + lexName + " -> " + sclex + " in " + fileName) printWrapped("Lexer properties: " + ", ".join(sci.lexerProperties)) print("Lexer property documentation:") documentProperties = list(sci.propertyDocuments.keys()) diff --git a/dep/scintilla/scintilla-3.10.6/scripts/__init__.py b/dep/scintilla/scintilla-3.10.6/scripts/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/dep/scintilla/scintilla-3.6.0/src/AutoComplete.cxx b/dep/scintilla/scintilla-3.10.6/src/AutoComplete.cxx similarity index 88% rename from dep/scintilla/scintilla-3.6.0/src/AutoComplete.cxx rename to dep/scintilla/scintilla-3.10.6/src/AutoComplete.cxx index 3f357028..886ace4a 100644 --- a/dep/scintilla/scintilla-3.6.0/src/AutoComplete.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/AutoComplete.cxx @@ -5,15 +5,17 @@ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include #include +#include #include "Platform.h" @@ -22,9 +24,7 @@ #include "Position.h" #include "AutoComplete.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif AutoComplete::AutoComplete() : active(false), @@ -32,7 +32,6 @@ AutoComplete::AutoComplete() : typesep('?'), ignoreCase(false), chooseSingle(false), - lb(0), posStart(0), startLen(0), cancelAtStartPos(true), @@ -42,23 +41,21 @@ AutoComplete::AutoComplete() : widthLBDefault(100), heightLBDefault(100), autoSort(SC_ORDER_PRESORTED) { - lb = ListBox::Allocate(); + lb.reset(ListBox::Allocate()); } AutoComplete::~AutoComplete() { if (lb) { lb->Destroy(); - delete lb; - lb = 0; } } -bool AutoComplete::Active() const { +bool AutoComplete::Active() const noexcept { return active; } void AutoComplete::Start(Window &parent, int ctrlID, - int position, Point location, int startLen_, + Sci::Position position, Point location, Sci::Position startLen_, int lineHeight, bool unicodeMode, int technology) { if (active) { Cancel(); @@ -74,7 +71,7 @@ void AutoComplete::SetStopChars(const char *stopChars_) { stopChars = stopChars_; } -bool AutoComplete::IsStopChar(char ch) { +bool AutoComplete::IsStopChar(char ch) const noexcept { return ch && (stopChars.find(ch) != std::string::npos); } @@ -82,7 +79,7 @@ void AutoComplete::SetFillUpChars(const char *fillUpChars_) { fillUpChars = fillUpChars_; } -bool AutoComplete::IsFillUpChar(char ch) { +bool AutoComplete::IsFillUpChar(char ch) const noexcept { return ch && (fillUpChars.find(ch) != std::string::npos); } @@ -90,7 +87,7 @@ void AutoComplete::SetSeparator(char separator_) { separator = separator_; } -char AutoComplete::GetSeparator() const { +char AutoComplete::GetSeparator() const noexcept { return separator; } @@ -98,7 +95,7 @@ void AutoComplete::SetTypesep(char separator_) { typesep = separator_; } -char AutoComplete::GetTypesep() const { +char AutoComplete::GetTypesep() const noexcept { return typesep; } @@ -131,9 +128,9 @@ struct Sorter { } bool operator()(int a, int b) { - int lenA = indices[a * 2 + 1] - indices[a * 2]; - int lenB = indices[b * 2 + 1] - indices[b * 2]; - int len = std::min(lenA, lenB); + const int lenA = indices[a * 2 + 1] - indices[a * 2]; + const int lenB = indices[b * 2 + 1] - indices[b * 2]; + const int len = std::min(lenA, lenB); int cmp; if (ac->ignoreCase) cmp = CompareNCaseInsensitive(list + indices[a * 2], list + indices[b * 2], len); @@ -156,7 +153,7 @@ void AutoComplete::SetList(const char *list) { Sorter IndexSort(this, list); sortMatrix.clear(); - for (int i = 0; i < (int)IndexSort.indices.size() / 2; ++i) + for (int i = 0; i < static_cast(IndexSort.indices.size()) / 2; ++i) sortMatrix.push_back(i); std::sort(sortMatrix.begin(), sortMatrix.end(), IndexSort); if (autoSort == SC_ORDER_CUSTOM || sortMatrix.size() < 2) { @@ -186,7 +183,7 @@ void AutoComplete::SetList(const char *list) { item[wordLen] = '\0'; sortedList += item; } - for (int i = 0; i < (int)sortMatrix.size(); ++i) + for (int i = 0; i < static_cast(sortMatrix.size()); ++i) sortMatrix[i] = i; lb->SetList(sortedList.c_str(), separator, typesep); } @@ -217,7 +214,7 @@ void AutoComplete::Cancel() { void AutoComplete::Move(int delta) { - int count = lb->Length(); + const int count = lb->Length(); int current = lb->GetSelection(); current += delta; if (current >= count) @@ -228,7 +225,7 @@ void AutoComplete::Move(int delta) { } void AutoComplete::Select(const char *word) { - size_t lenWord = strlen(word); + const size_t lenWord = strlen(word); int location = -1; int start = 0; // lower bound of the api array block to search int end = lb->Length() - 1; // upper bound of the api array block to search diff --git a/dep/scintilla/scintilla-3.6.0/src/AutoComplete.h b/dep/scintilla/scintilla-3.10.6/src/AutoComplete.h similarity index 84% rename from dep/scintilla/scintilla-3.6.0/src/AutoComplete.h rename to dep/scintilla/scintilla-3.10.6/src/AutoComplete.h index c35fa1a0..6440c13d 100644 --- a/dep/scintilla/scintilla-3.6.0/src/AutoComplete.h +++ b/dep/scintilla/scintilla-3.10.6/src/AutoComplete.h @@ -8,9 +8,7 @@ #ifndef AUTOCOMPLETE_H #define AUTOCOMPLETE_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif /** */ @@ -27,9 +25,9 @@ public: bool ignoreCase; bool chooseSingle; - ListBox *lb; - int posStart; - int startLen; + std::unique_ptr lb; + Sci::Position posStart; + Sci::Position startLen; /// Should autocompletion be canceled if editor's currentPos <= startPos? bool cancelAtStartPos; bool autoHide; @@ -47,27 +45,27 @@ public: ~AutoComplete(); /// Is the auto completion list displayed? - bool Active() const; + bool Active() const noexcept; /// Display the auto completion list positioned to be near a character position - void Start(Window &parent, int ctrlID, int position, Point location, - int startLen_, int lineHeight, bool unicodeMode, int technology); + void Start(Window &parent, int ctrlID, Sci::Position position, Point location, + Sci::Position startLen_, int lineHeight, bool unicodeMode, int technology); /// The stop chars are characters which, when typed, cause the auto completion list to disappear void SetStopChars(const char *stopChars_); - bool IsStopChar(char ch); + bool IsStopChar(char ch) const noexcept; /// The fillup chars are characters which, when typed, fill up the selected word void SetFillUpChars(const char *fillUpChars_); - bool IsFillUpChar(char ch); + bool IsFillUpChar(char ch) const noexcept; /// The separator character is used when interpreting the list in SetList void SetSeparator(char separator_); - char GetSeparator() const; + char GetSeparator() const noexcept; /// The typesep character is used for separating the word from the type void SetTypesep(char separator_); - char GetTypesep() const; + char GetTypesep() const noexcept; /// The list string contains a sequence of words separated by the separator character void SetList(const char *list); @@ -88,8 +86,6 @@ public: void Select(const char *word); }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/CallTip.cxx b/dep/scintilla/scintilla-3.10.6/src/CallTip.cxx similarity index 77% rename from dep/scintilla/scintilla-3.6.0/src/CallTip.cxx rename to dep/scintilla/scintilla-3.10.6/src/CallTip.cxx index 541f4c68..18c4549b 100644 --- a/dep/scintilla/scintilla-3.6.0/src/CallTip.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/CallTip.cxx @@ -5,12 +5,17 @@ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include #include "Platform.h" @@ -18,11 +23,10 @@ #include "StringCopy.h" #include "Position.h" +#include "IntegerRectangle.h" #include "CallTip.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif CallTip::CallTip() { wCallTip = 0; @@ -89,7 +93,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, int posStart, int posEnd, int ytext, PRectangle rcClient, bool highlight, bool draw) { s += posStart; - int len = posEnd - posStart; + const int len = posEnd - posStart; // Divide the text into sections that are all text, or that are // single arrows or single tab characters (if tabSize > 0). @@ -108,11 +112,11 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, int startSeg = 0; int xEnd; for (int seg = 0; seg startSeg) { if (IsArrowCharacter(s[startSeg])) { xEnd = x + widthArrow; - bool upArrow = s[startSeg] == '\001'; + const bool upArrow = s[startSeg] == '\001'; rcClient.left = static_cast(x); rcClient.right = static_cast(xEnd); if (draw) { @@ -121,7 +125,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, const int centreX = x + widthArrow / 2 - 1; const int centreY = static_cast(rcClient.top + rcClient.bottom) / 2; surface->FillRectangle(rcClient, colourBG); - PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1, + const PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1, rcClient.right - 2, rcClient.bottom - 1); surface->FillRectangle(rcClientInner, colourUnSel); @@ -150,7 +154,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, } else if (IsTabCharacter(s[startSeg])) { xEnd = NextTabPos(x); } else { - xEnd = x + RoundXYPosition(surface->WidthText(font, s + startSeg, endSeg - startSeg)); + xEnd = x + static_cast(lround(surface->WidthText(font, s + startSeg, endSeg - startSeg))); if (draw) { rcClient.left = static_cast(x); rcClient.right = static_cast(xEnd); @@ -166,13 +170,13 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, } int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { - PRectangle rcClientPos = wCallTip.GetClientPosition(); - PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left, + const PRectangle rcClientPos = wCallTip.GetClientPosition(); + const PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left, rcClientPos.bottom - rcClientPos.top); PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1); // To make a nice small call tip window, it is only sized to fit most normal characters without accents - int ascent = RoundXYPosition(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font)); + const int ascent = static_cast(round(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font))); // For each line... // Draw the definition in three parts: before highlight, highlighted, after highlight @@ -184,18 +188,18 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { while (moreChunks) { const char *chunkEnd = strchr(chunkVal, '\n'); - if (chunkEnd == NULL) { + if (!chunkEnd) { chunkEnd = chunkVal + strlen(chunkVal); moreChunks = false; } - int chunkOffset = static_cast(chunkVal - val.c_str()); - int chunkLength = static_cast(chunkEnd - chunkVal); - int chunkEndOffset = chunkOffset + chunkLength; - int thisStartHighlight = Platform::Maximum(startHighlight, chunkOffset); - thisStartHighlight = Platform::Minimum(thisStartHighlight, chunkEndOffset); + const int chunkOffset = static_cast(chunkVal - val.c_str()); + const int chunkLength = static_cast(chunkEnd - chunkVal); + const int chunkEndOffset = chunkOffset + chunkLength; + int thisStartHighlight = std::max(startHighlight, chunkOffset); + thisStartHighlight = std::min(thisStartHighlight, chunkEndOffset); thisStartHighlight -= chunkOffset; - int thisEndHighlight = Platform::Maximum(endHighlight, chunkOffset); - thisEndHighlight = Platform::Minimum(thisEndHighlight, chunkEndOffset); + int thisEndHighlight = std::max(endHighlight, chunkOffset); + thisEndHighlight = std::min(thisEndHighlight, chunkEndOffset); thisEndHighlight -= chunkOffset; rcClient.top = static_cast(ytext - ascent - 1); @@ -211,7 +215,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { chunkVal = chunkEnd + 1; ytext += lineHeight; rcClient.bottom += lineHeight; - maxWidth = Platform::Maximum(maxWidth, x); + maxWidth = std::max(maxWidth, x); } return maxWidth; } @@ -219,10 +223,10 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { void CallTip::PaintCT(Surface *surfaceWindow) { if (val.empty()) return; - PRectangle rcClientPos = wCallTip.GetClientPosition(); - PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left, + const PRectangle rcClientPos = wCallTip.GetClientPosition(); + const PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left, rcClientPos.bottom - rcClientPos.top); - PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1); + const PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1); surfaceWindow->FillRectangle(rcClient, colourBG); @@ -232,13 +236,14 @@ void CallTip::PaintCT(Surface *surfaceWindow) { #ifndef __APPLE__ // OSX doesn't put borders on "help tags" // Draw a raised border around the edges of the window - surfaceWindow->MoveTo(0, static_cast(rcClientSize.bottom) - 1); + const IntegerRectangle ircClientSize(rcClientSize); + surfaceWindow->MoveTo(0, ircClientSize.bottom - 1); surfaceWindow->PenColour(colourShade); - surfaceWindow->LineTo(static_cast(rcClientSize.right) - 1, static_cast(rcClientSize.bottom) - 1); - surfaceWindow->LineTo(static_cast(rcClientSize.right) - 1, 0); + surfaceWindow->LineTo(ircClientSize.right - 1, ircClientSize.bottom - 1); + surfaceWindow->LineTo(ircClientSize.right - 1, 0); surfaceWindow->PenColour(colourLight); surfaceWindow->LineTo(0, 0); - surfaceWindow->LineTo(0, static_cast(rcClientSize.bottom) - 1); + surfaceWindow->LineTo(0, ircClientSize.bottom - 1); #endif } @@ -250,16 +255,14 @@ void CallTip::MouseClick(Point pt) { clickPlace = 2; } -PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char *defn, +PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn, const char *faceName, int size, int codePage_, int characterSet, - int technology, Window &wParent) { + int technology, const Window &wParent) { clickPlace = 0; val = defn; codePage = codePage_; - Surface *surfaceMeasure = Surface::Allocate(technology); - if (!surfaceMeasure) - return PRectangle(); + std::unique_ptr surfaceMeasure(Surface::Allocate(technology)); surfaceMeasure->Init(wParent.GetID()); surfaceMeasure->SetUnicodeMode(SC_CP_UTF8 == codePage); surfaceMeasure->SetDBCSMode(codePage); @@ -267,29 +270,22 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char * endHighlight = 0; inCallTipMode = true; posStartCallTip = pos; - XYPOSITION deviceHeight = static_cast(surfaceMeasure->DeviceHeightFont(size)); - FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet); + const XYPOSITION deviceHeight = static_cast(surfaceMeasure->DeviceHeightFont(size)); + const FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet); font.Create(fp); // Look for multiple lines in the text // Only support \n here - simply means container must avoid \r! - int numLines = 1; - const char *newline; - const char *look = val.c_str(); + const int numLines = 1 + static_cast(std::count(val.begin(), val.end(), '\n')); rectUp = PRectangle(0,0,0,0); rectDown = PRectangle(0,0,0,0); offsetMain = insetX; // changed to right edge of any arrows - int width = PaintContents(surfaceMeasure, false) + insetX; - while ((newline = strchr(look, '\n')) != NULL) { - look = newline + 1; - numLines++; - } - lineHeight = RoundXYPosition(surfaceMeasure->Height(font)); + const int width = PaintContents(surfaceMeasure.get(), false) + insetX; + lineHeight = static_cast(lround(surfaceMeasure->Height(font))); // The returned // rectangle is aligned to the right edge of the last arrow encountered in // the tip text, else to the tip text left edge. - int height = lineHeight * numLines - static_cast(surfaceMeasure->InternalLeading(font)) + borderHeight * 2; - delete surfaceMeasure; + const int height = lineHeight * numLines - static_cast(surfaceMeasure->InternalLeading(font)) + borderHeight * 2; if (above) { return PRectangle(pt.x - offsetMain, pt.y - verticalOffset - height, pt.x + width - offsetMain, pt.y - verticalOffset); } else { diff --git a/dep/scintilla/scintilla-3.6.0/src/CallTip.h b/dep/scintilla/scintilla-3.10.6/src/CallTip.h similarity index 85% rename from dep/scintilla/scintilla-3.6.0/src/CallTip.h rename to dep/scintilla/scintilla-3.10.6/src/CallTip.h index 840aa26a..a37138d5 100644 --- a/dep/scintilla/scintilla-3.6.0/src/CallTip.h +++ b/dep/scintilla/scintilla-3.10.6/src/CallTip.h @@ -8,9 +8,7 @@ #ifndef CALLTIP_H #define CALLTIP_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif /** */ @@ -27,21 +25,18 @@ class CallTip { bool useStyleCallTip; // if true, STYLE_CALLTIP should be used bool above; // if true, display calltip above text - // Private so CallTip objects can not be copied - CallTip(const CallTip &); - CallTip &operator=(const CallTip &); void DrawChunk(Surface *surface, int &x, const char *s, int posStart, int posEnd, int ytext, PRectangle rcClient, bool highlight, bool draw); int PaintContents(Surface *surfaceWindow, bool draw); - bool IsTabCharacter(char c) const; + bool IsTabCharacter(char ch) const; int NextTabPos(int x) const; public: Window wCallTip; Window wDraw; bool inCallTipMode; - int posStartCallTip; + Sci::Position posStartCallTip; ColourDesired colourBG; ColourDesired colourUnSel; ColourDesired colourSel; @@ -56,6 +51,11 @@ public: int verticalOffset; // pixel offset up or down of the calltip with respect to the line CallTip(); + // Deleted so CallTip objects can not be copied. + CallTip(const CallTip &) = delete; + CallTip(CallTip &&) = delete; + CallTip &operator=(const CallTip &) = delete; + CallTip &operator=(CallTip &&) = delete; ~CallTip(); void PaintCT(Surface *surfaceWindow); @@ -63,9 +63,9 @@ public: void MouseClick(Point pt); /// Setup the calltip and return a rectangle of the area required. - PRectangle CallTipStart(int pos, Point pt, int textHeight, const char *defn, + PRectangle CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn, const char *faceName, int size, int codePage_, - int characterSet, int technology, Window &wParent); + int characterSet, int technology, const Window &wParent); void CallTipCancel(); @@ -86,8 +86,6 @@ public: void SetForeBack(const ColourDesired &fore, const ColourDesired &back); }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/CaseConvert.cxx b/dep/scintilla/scintilla-3.10.6/src/CaseConvert.cxx similarity index 57% rename from dep/scintilla/scintilla-3.6.0/src/CaseConvert.cxx rename to dep/scintilla/scintilla-3.10.6/src/CaseConvert.cxx index 63a27222..c1cfd38e 100644 --- a/dep/scintilla/scintilla-3.6.0/src/CaseConvert.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/CaseConvert.cxx @@ -11,17 +11,15 @@ #include #include +#include #include #include #include "StringCopy.h" #include "CaseConvert.h" #include "UniConversion.h" -#include "UnicodeFromUTF8.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif namespace { // Use an unnamed namespace to protect the declarations from name conflicts @@ -36,48 +34,54 @@ int symmetricCaseConversionRanges[] = { //lower, upper, range length, range pitch //++Autogenerated -- start of section automatically generated //**\(\*\n\) -97,65,26,1, -224,192,23,1, -248,216,7,1, -257,256,24,2, -314,313,8,2, -331,330,23,2, -462,461,8,2, -479,478,9,2, -505,504,20,2, -547,546,9,2, -583,582,5,2, -945,913,17,1, -963,931,9,1, -985,984,12,2, -1072,1040,32,1, -1104,1024,16,1, -1121,1120,17,2, -1163,1162,27,2, -1218,1217,7,2, -1233,1232,44,2, -1377,1329,38,1, -7681,7680,75,2, -7841,7840,48,2, -7936,7944,8,1, -7952,7960,6,1, -7968,7976,8,1, -7984,7992,8,1, -8000,8008,6,1, -8032,8040,8,1, -8560,8544,16,1, -9424,9398,26,1, -11312,11264,47,1, -11393,11392,50,2, -11520,4256,38,1, -42561,42560,23,2, -42625,42624,12,2, -42787,42786,7,2, -42803,42802,31,2, -42879,42878,5,2, -42913,42912,5,2, -65345,65313,26,1, -66600,66560,40,1, +97,65,26,1, +224,192,23,1, +248,216,7,1, +257,256,24,2, +314,313,8,2, +331,330,23,2, +462,461,8,2, +479,478,9,2, +505,504,20,2, +547,546,9,2, +583,582,5,2, +945,913,17,1, +963,931,9,1, +985,984,12,2, +1072,1040,32,1, +1104,1024,16,1, +1121,1120,17,2, +1163,1162,27,2, +1218,1217,7,2, +1233,1232,48,2, +1377,1329,38,1, +4304,7312,43,1, +7681,7680,75,2, +7841,7840,48,2, +7936,7944,8,1, +7952,7960,6,1, +7968,7976,8,1, +7984,7992,8,1, +8000,8008,6,1, +8032,8040,8,1, +8560,8544,16,1, +9424,9398,26,1, +11312,11264,47,1, +11393,11392,50,2, +11520,4256,38,1, +42561,42560,23,2, +42625,42624,14,2, +42787,42786,7,2, +42803,42802,31,2, +42879,42878,5,2, +42903,42902,10,2, +65345,65313,26,1, +66600,66560,40,1, +66776,66736,36,1, +68800,68736,51,1, +71872,71840,32,1, +93792,93760,32,1, +125218,125184,34,1, //--Autogenerated -- end of section automatically generated }; @@ -89,138 +93,153 @@ int symmetricCaseConversions[] = { //lower, upper //++Autogenerated -- start of section automatically generated //**1 \(\*\n\) -255,376, -307,306, -309,308, -311,310, -378,377, -380,379, -382,381, -384,579, -387,386, -389,388, -392,391, -396,395, -402,401, -405,502, -409,408, -410,573, -414,544, -417,416, -419,418, -421,420, -424,423, -429,428, -432,431, -436,435, -438,437, -441,440, -445,444, -447,503, -454,452, -457,455, -460,458, -477,398, -499,497, -501,500, -572,571, -575,11390, -576,11391, -578,577, -592,11375, -593,11373, -594,11376, -595,385, -596,390, -598,393, -599,394, -601,399, -603,400, -608,403, -611,404, -613,42893, -614,42922, -616,407, -617,406, -619,11362, -623,412, -625,11374, -626,413, -629,415, -637,11364, -640,422, -643,425, -648,430, -649,580, -650,433, -651,434, -652,581, -658,439, -881,880, -883,882, -887,886, -891,1021, -892,1022, -893,1023, -940,902, -941,904, -942,905, -943,906, -972,908, -973,910, -974,911, -983,975, -1010,1017, -1016,1015, -1019,1018, -1231,1216, -7545,42877, -7549,11363, -8017,8025, -8019,8027, -8021,8029, -8023,8031, -8048,8122, -8049,8123, -8050,8136, -8051,8137, -8052,8138, -8053,8139, -8054,8154, -8055,8155, -8056,8184, -8057,8185, -8058,8170, -8059,8171, -8060,8186, -8061,8187, -8112,8120, -8113,8121, -8144,8152, -8145,8153, -8160,8168, -8161,8169, -8165,8172, -8526,8498, -8580,8579, -11361,11360, -11365,570, -11366,574, -11368,11367, -11370,11369, -11372,11371, -11379,11378, -11382,11381, -11500,11499, -11502,11501, -11507,11506, -11559,4295, -11565,4301, -42874,42873, -42876,42875, -42892,42891, -42897,42896, -42899,42898, +255,376, +307,306, +309,308, +311,310, +378,377, +380,379, +382,381, +384,579, +387,386, +389,388, +392,391, +396,395, +402,401, +405,502, +409,408, +410,573, +414,544, +417,416, +419,418, +421,420, +424,423, +429,428, +432,431, +436,435, +438,437, +441,440, +445,444, +447,503, +454,452, +457,455, +460,458, +477,398, +499,497, +501,500, +572,571, +575,11390, +576,11391, +578,577, +592,11375, +593,11373, +594,11376, +595,385, +596,390, +598,393, +599,394, +601,399, +603,400, +604,42923, +608,403, +609,42924, +611,404, +613,42893, +614,42922, +616,407, +617,406, +618,42926, +619,11362, +620,42925, +623,412, +625,11374, +626,413, +629,415, +637,11364, +640,422, +643,425, +647,42929, +648,430, +649,580, +650,433, +651,434, +652,581, +658,439, +669,42930, +670,42928, +881,880, +883,882, +887,886, +891,1021, +892,1022, +893,1023, +940,902, +941,904, +942,905, +943,906, +972,908, +973,910, +974,911, +983,975, +1010,1017, +1011,895, +1016,1015, +1019,1018, +1231,1216, +4349,7357, +4350,7358, +4351,7359, +7545,42877, +7549,11363, +8017,8025, +8019,8027, +8021,8029, +8023,8031, +8048,8122, +8049,8123, +8050,8136, +8051,8137, +8052,8138, +8053,8139, +8054,8154, +8055,8155, +8056,8184, +8057,8185, +8058,8170, +8059,8171, +8060,8186, +8061,8187, +8112,8120, +8113,8121, +8144,8152, +8145,8153, +8160,8168, +8161,8169, +8165,8172, +8526,8498, +8580,8579, +11361,11360, +11365,570, +11366,574, +11368,11367, +11370,11369, +11372,11371, +11379,11378, +11382,11381, +11500,11499, +11502,11501, +11507,11506, +11559,4295, +11565,4301, +42874,42873, +42876,42875, +42892,42891, +42897,42896, +42899,42898, +42933,42932, +42935,42934, +42937,42936, +43859,42931, //--Autogenerated -- end of section automatically generated }; @@ -258,6 +277,107 @@ const char *complexCaseConversions = "\xcf\xb4|\xce\xb8||\xce\xb8|" "\xcf\xb5|\xce\xb5|\xce\x95||" "\xd6\x87|\xd5\xa5\xd6\x82|\xd4\xb5\xd5\x92||" +"\xe1\x8e\xa0|||\xea\xad\xb0|" +"\xe1\x8e\xa1|||\xea\xad\xb1|" +"\xe1\x8e\xa2|||\xea\xad\xb2|" +"\xe1\x8e\xa3|||\xea\xad\xb3|" +"\xe1\x8e\xa4|||\xea\xad\xb4|" +"\xe1\x8e\xa5|||\xea\xad\xb5|" +"\xe1\x8e\xa6|||\xea\xad\xb6|" +"\xe1\x8e\xa7|||\xea\xad\xb7|" +"\xe1\x8e\xa8|||\xea\xad\xb8|" +"\xe1\x8e\xa9|||\xea\xad\xb9|" +"\xe1\x8e\xaa|||\xea\xad\xba|" +"\xe1\x8e\xab|||\xea\xad\xbb|" +"\xe1\x8e\xac|||\xea\xad\xbc|" +"\xe1\x8e\xad|||\xea\xad\xbd|" +"\xe1\x8e\xae|||\xea\xad\xbe|" +"\xe1\x8e\xaf|||\xea\xad\xbf|" +"\xe1\x8e\xb0|||\xea\xae\x80|" +"\xe1\x8e\xb1|||\xea\xae\x81|" +"\xe1\x8e\xb2|||\xea\xae\x82|" +"\xe1\x8e\xb3|||\xea\xae\x83|" +"\xe1\x8e\xb4|||\xea\xae\x84|" +"\xe1\x8e\xb5|||\xea\xae\x85|" +"\xe1\x8e\xb6|||\xea\xae\x86|" +"\xe1\x8e\xb7|||\xea\xae\x87|" +"\xe1\x8e\xb8|||\xea\xae\x88|" +"\xe1\x8e\xb9|||\xea\xae\x89|" +"\xe1\x8e\xba|||\xea\xae\x8a|" +"\xe1\x8e\xbb|||\xea\xae\x8b|" +"\xe1\x8e\xbc|||\xea\xae\x8c|" +"\xe1\x8e\xbd|||\xea\xae\x8d|" +"\xe1\x8e\xbe|||\xea\xae\x8e|" +"\xe1\x8e\xbf|||\xea\xae\x8f|" +"\xe1\x8f\x80|||\xea\xae\x90|" +"\xe1\x8f\x81|||\xea\xae\x91|" +"\xe1\x8f\x82|||\xea\xae\x92|" +"\xe1\x8f\x83|||\xea\xae\x93|" +"\xe1\x8f\x84|||\xea\xae\x94|" +"\xe1\x8f\x85|||\xea\xae\x95|" +"\xe1\x8f\x86|||\xea\xae\x96|" +"\xe1\x8f\x87|||\xea\xae\x97|" +"\xe1\x8f\x88|||\xea\xae\x98|" +"\xe1\x8f\x89|||\xea\xae\x99|" +"\xe1\x8f\x8a|||\xea\xae\x9a|" +"\xe1\x8f\x8b|||\xea\xae\x9b|" +"\xe1\x8f\x8c|||\xea\xae\x9c|" +"\xe1\x8f\x8d|||\xea\xae\x9d|" +"\xe1\x8f\x8e|||\xea\xae\x9e|" +"\xe1\x8f\x8f|||\xea\xae\x9f|" +"\xe1\x8f\x90|||\xea\xae\xa0|" +"\xe1\x8f\x91|||\xea\xae\xa1|" +"\xe1\x8f\x92|||\xea\xae\xa2|" +"\xe1\x8f\x93|||\xea\xae\xa3|" +"\xe1\x8f\x94|||\xea\xae\xa4|" +"\xe1\x8f\x95|||\xea\xae\xa5|" +"\xe1\x8f\x96|||\xea\xae\xa6|" +"\xe1\x8f\x97|||\xea\xae\xa7|" +"\xe1\x8f\x98|||\xea\xae\xa8|" +"\xe1\x8f\x99|||\xea\xae\xa9|" +"\xe1\x8f\x9a|||\xea\xae\xaa|" +"\xe1\x8f\x9b|||\xea\xae\xab|" +"\xe1\x8f\x9c|||\xea\xae\xac|" +"\xe1\x8f\x9d|||\xea\xae\xad|" +"\xe1\x8f\x9e|||\xea\xae\xae|" +"\xe1\x8f\x9f|||\xea\xae\xaf|" +"\xe1\x8f\xa0|||\xea\xae\xb0|" +"\xe1\x8f\xa1|||\xea\xae\xb1|" +"\xe1\x8f\xa2|||\xea\xae\xb2|" +"\xe1\x8f\xa3|||\xea\xae\xb3|" +"\xe1\x8f\xa4|||\xea\xae\xb4|" +"\xe1\x8f\xa5|||\xea\xae\xb5|" +"\xe1\x8f\xa6|||\xea\xae\xb6|" +"\xe1\x8f\xa7|||\xea\xae\xb7|" +"\xe1\x8f\xa8|||\xea\xae\xb8|" +"\xe1\x8f\xa9|||\xea\xae\xb9|" +"\xe1\x8f\xaa|||\xea\xae\xba|" +"\xe1\x8f\xab|||\xea\xae\xbb|" +"\xe1\x8f\xac|||\xea\xae\xbc|" +"\xe1\x8f\xad|||\xea\xae\xbd|" +"\xe1\x8f\xae|||\xea\xae\xbe|" +"\xe1\x8f\xaf|||\xea\xae\xbf|" +"\xe1\x8f\xb0|||\xe1\x8f\xb8|" +"\xe1\x8f\xb1|||\xe1\x8f\xb9|" +"\xe1\x8f\xb2|||\xe1\x8f\xba|" +"\xe1\x8f\xb3|||\xe1\x8f\xbb|" +"\xe1\x8f\xb4|||\xe1\x8f\xbc|" +"\xe1\x8f\xb5|||\xe1\x8f\xbd|" +"\xe1\x8f\xb8|\xe1\x8f\xb0|\xe1\x8f\xb0||" +"\xe1\x8f\xb9|\xe1\x8f\xb1|\xe1\x8f\xb1||" +"\xe1\x8f\xba|\xe1\x8f\xb2|\xe1\x8f\xb2||" +"\xe1\x8f\xbb|\xe1\x8f\xb3|\xe1\x8f\xb3||" +"\xe1\x8f\xbc|\xe1\x8f\xb4|\xe1\x8f\xb4||" +"\xe1\x8f\xbd|\xe1\x8f\xb5|\xe1\x8f\xb5||" +"\xe1\xb2\x80|\xd0\xb2|\xd0\x92||" +"\xe1\xb2\x81|\xd0\xb4|\xd0\x94||" +"\xe1\xb2\x82|\xd0\xbe|\xd0\x9e||" +"\xe1\xb2\x83|\xd1\x81|\xd0\xa1||" +"\xe1\xb2\x84|\xd1\x82|\xd0\xa2||" +"\xe1\xb2\x85|\xd1\x82|\xd0\xa2||" +"\xe1\xb2\x86|\xd1\x8a|\xd0\xaa||" +"\xe1\xb2\x87|\xd1\xa3|\xd1\xa2||" +"\xe1\xb2\x88|\xea\x99\x8b|\xea\x99\x8a||" "\xe1\xba\x96|h\xcc\xb1|H\xcc\xb1||" "\xe1\xba\x97|t\xcc\x88|T\xcc\x88||" "\xe1\xba\x98|w\xcc\x8a|W\xcc\x8a||" @@ -348,6 +468,86 @@ const char *complexCaseConversions = "\xe2\x84\xa6|\xcf\x89||\xcf\x89|" "\xe2\x84\xaa|k||k|" "\xe2\x84\xab|\xc3\xa5||\xc3\xa5|" +"\xea\xad\xb0|\xe1\x8e\xa0|\xe1\x8e\xa0||" +"\xea\xad\xb1|\xe1\x8e\xa1|\xe1\x8e\xa1||" +"\xea\xad\xb2|\xe1\x8e\xa2|\xe1\x8e\xa2||" +"\xea\xad\xb3|\xe1\x8e\xa3|\xe1\x8e\xa3||" +"\xea\xad\xb4|\xe1\x8e\xa4|\xe1\x8e\xa4||" +"\xea\xad\xb5|\xe1\x8e\xa5|\xe1\x8e\xa5||" +"\xea\xad\xb6|\xe1\x8e\xa6|\xe1\x8e\xa6||" +"\xea\xad\xb7|\xe1\x8e\xa7|\xe1\x8e\xa7||" +"\xea\xad\xb8|\xe1\x8e\xa8|\xe1\x8e\xa8||" +"\xea\xad\xb9|\xe1\x8e\xa9|\xe1\x8e\xa9||" +"\xea\xad\xba|\xe1\x8e\xaa|\xe1\x8e\xaa||" +"\xea\xad\xbb|\xe1\x8e\xab|\xe1\x8e\xab||" +"\xea\xad\xbc|\xe1\x8e\xac|\xe1\x8e\xac||" +"\xea\xad\xbd|\xe1\x8e\xad|\xe1\x8e\xad||" +"\xea\xad\xbe|\xe1\x8e\xae|\xe1\x8e\xae||" +"\xea\xad\xbf|\xe1\x8e\xaf|\xe1\x8e\xaf||" +"\xea\xae\x80|\xe1\x8e\xb0|\xe1\x8e\xb0||" +"\xea\xae\x81|\xe1\x8e\xb1|\xe1\x8e\xb1||" +"\xea\xae\x82|\xe1\x8e\xb2|\xe1\x8e\xb2||" +"\xea\xae\x83|\xe1\x8e\xb3|\xe1\x8e\xb3||" +"\xea\xae\x84|\xe1\x8e\xb4|\xe1\x8e\xb4||" +"\xea\xae\x85|\xe1\x8e\xb5|\xe1\x8e\xb5||" +"\xea\xae\x86|\xe1\x8e\xb6|\xe1\x8e\xb6||" +"\xea\xae\x87|\xe1\x8e\xb7|\xe1\x8e\xb7||" +"\xea\xae\x88|\xe1\x8e\xb8|\xe1\x8e\xb8||" +"\xea\xae\x89|\xe1\x8e\xb9|\xe1\x8e\xb9||" +"\xea\xae\x8a|\xe1\x8e\xba|\xe1\x8e\xba||" +"\xea\xae\x8b|\xe1\x8e\xbb|\xe1\x8e\xbb||" +"\xea\xae\x8c|\xe1\x8e\xbc|\xe1\x8e\xbc||" +"\xea\xae\x8d|\xe1\x8e\xbd|\xe1\x8e\xbd||" +"\xea\xae\x8e|\xe1\x8e\xbe|\xe1\x8e\xbe||" +"\xea\xae\x8f|\xe1\x8e\xbf|\xe1\x8e\xbf||" +"\xea\xae\x90|\xe1\x8f\x80|\xe1\x8f\x80||" +"\xea\xae\x91|\xe1\x8f\x81|\xe1\x8f\x81||" +"\xea\xae\x92|\xe1\x8f\x82|\xe1\x8f\x82||" +"\xea\xae\x93|\xe1\x8f\x83|\xe1\x8f\x83||" +"\xea\xae\x94|\xe1\x8f\x84|\xe1\x8f\x84||" +"\xea\xae\x95|\xe1\x8f\x85|\xe1\x8f\x85||" +"\xea\xae\x96|\xe1\x8f\x86|\xe1\x8f\x86||" +"\xea\xae\x97|\xe1\x8f\x87|\xe1\x8f\x87||" +"\xea\xae\x98|\xe1\x8f\x88|\xe1\x8f\x88||" +"\xea\xae\x99|\xe1\x8f\x89|\xe1\x8f\x89||" +"\xea\xae\x9a|\xe1\x8f\x8a|\xe1\x8f\x8a||" +"\xea\xae\x9b|\xe1\x8f\x8b|\xe1\x8f\x8b||" +"\xea\xae\x9c|\xe1\x8f\x8c|\xe1\x8f\x8c||" +"\xea\xae\x9d|\xe1\x8f\x8d|\xe1\x8f\x8d||" +"\xea\xae\x9e|\xe1\x8f\x8e|\xe1\x8f\x8e||" +"\xea\xae\x9f|\xe1\x8f\x8f|\xe1\x8f\x8f||" +"\xea\xae\xa0|\xe1\x8f\x90|\xe1\x8f\x90||" +"\xea\xae\xa1|\xe1\x8f\x91|\xe1\x8f\x91||" +"\xea\xae\xa2|\xe1\x8f\x92|\xe1\x8f\x92||" +"\xea\xae\xa3|\xe1\x8f\x93|\xe1\x8f\x93||" +"\xea\xae\xa4|\xe1\x8f\x94|\xe1\x8f\x94||" +"\xea\xae\xa5|\xe1\x8f\x95|\xe1\x8f\x95||" +"\xea\xae\xa6|\xe1\x8f\x96|\xe1\x8f\x96||" +"\xea\xae\xa7|\xe1\x8f\x97|\xe1\x8f\x97||" +"\xea\xae\xa8|\xe1\x8f\x98|\xe1\x8f\x98||" +"\xea\xae\xa9|\xe1\x8f\x99|\xe1\x8f\x99||" +"\xea\xae\xaa|\xe1\x8f\x9a|\xe1\x8f\x9a||" +"\xea\xae\xab|\xe1\x8f\x9b|\xe1\x8f\x9b||" +"\xea\xae\xac|\xe1\x8f\x9c|\xe1\x8f\x9c||" +"\xea\xae\xad|\xe1\x8f\x9d|\xe1\x8f\x9d||" +"\xea\xae\xae|\xe1\x8f\x9e|\xe1\x8f\x9e||" +"\xea\xae\xaf|\xe1\x8f\x9f|\xe1\x8f\x9f||" +"\xea\xae\xb0|\xe1\x8f\xa0|\xe1\x8f\xa0||" +"\xea\xae\xb1|\xe1\x8f\xa1|\xe1\x8f\xa1||" +"\xea\xae\xb2|\xe1\x8f\xa2|\xe1\x8f\xa2||" +"\xea\xae\xb3|\xe1\x8f\xa3|\xe1\x8f\xa3||" +"\xea\xae\xb4|\xe1\x8f\xa4|\xe1\x8f\xa4||" +"\xea\xae\xb5|\xe1\x8f\xa5|\xe1\x8f\xa5||" +"\xea\xae\xb6|\xe1\x8f\xa6|\xe1\x8f\xa6||" +"\xea\xae\xb7|\xe1\x8f\xa7|\xe1\x8f\xa7||" +"\xea\xae\xb8|\xe1\x8f\xa8|\xe1\x8f\xa8||" +"\xea\xae\xb9|\xe1\x8f\xa9|\xe1\x8f\xa9||" +"\xea\xae\xba|\xe1\x8f\xaa|\xe1\x8f\xaa||" +"\xea\xae\xbb|\xe1\x8f\xab|\xe1\x8f\xab||" +"\xea\xae\xbc|\xe1\x8f\xac|\xe1\x8f\xac||" +"\xea\xae\xbd|\xe1\x8f\xad|\xe1\x8f\xad||" +"\xea\xae\xbe|\xe1\x8f\xae|\xe1\x8f\xae||" +"\xea\xae\xbf|\xe1\x8f\xaf|\xe1\x8f\xaf||" "\xef\xac\x80|ff|FF||" "\xef\xac\x81|fi|FI||" "\xef\xac\x82|fl|FL||" @@ -369,8 +569,7 @@ class CaseConverter : public ICaseConverter { enum { maxConversionLength=6 }; struct ConversionString { char conversion[maxConversionLength+1]; - ConversionString() { - conversion[0] = '\0'; + ConversionString() noexcept : conversion{} { } }; // Conversions are initially store in a vector of structs but then decomposed into @@ -378,10 +577,10 @@ class CaseConverter : public ICaseConverter { struct CharacterConversion { int character; ConversionString conversion; - CharacterConversion(int character_=0, const char *conversion_="") : character(character_) { + CharacterConversion(int character_=0, const char *conversion_="") noexcept : character(character_) { StringCopy(conversion.conversion, conversion_); } - bool operator<(const CharacterConversion &other) const { + bool operator<(const CharacterConversion &other) const noexcept { return character < other.character; } }; @@ -392,30 +591,31 @@ class CaseConverter : public ICaseConverter { std::vector conversions; public: - CaseConverter() { + CaseConverter() noexcept { } - bool Initialised() const { - return characters.size() > 0; + virtual ~CaseConverter() = default; + bool Initialised() const noexcept { + return !characters.empty(); } void Add(int character, const char *conversion) { - characterToConversion.push_back(CharacterConversion(character, conversion)); + characterToConversion.emplace_back(character, conversion); } const char *Find(int character) { const std::vector::iterator it = std::lower_bound(characters.begin(), characters.end(), character); if (it == characters.end()) - return 0; + return nullptr; else if (*it == character) return conversions[it - characters.begin()].conversion; else - return 0; + return nullptr; } - size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) { + size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) override { size_t lenConverted = 0; size_t mixedPos = 0; - unsigned char bytes[UTF8MaxBytes + 1]; + unsigned char bytes[UTF8MaxBytes + 1]{}; while (mixedPos < lenMixed) { - const unsigned char leadByte = static_cast(mixed[mixedPos]); - const char *caseConverted = 0; + const unsigned char leadByte = mixed[mixedPos]; + const char *caseConverted = nullptr; size_t lenMixedChar = 1; if (UTF8IsAscii(leadByte)) { caseConverted = Find(leadByte); @@ -425,11 +625,11 @@ public: for (int b=1; bcharacter); - conversions.push_back(it->conversion); + for (const CharacterConversion &chConv : characterToConversion) { + characters.push_back(chConv.character); + conversions.push_back(chConv.conversion); } // Empty the original calculated data completely CharacterToConversion().swap(characterToConversion); @@ -469,26 +669,6 @@ CaseConverter caseConvFold; CaseConverter caseConvUp; CaseConverter caseConvLow; -void UTF8FromUTF32Character(int uch, char *putf) { - size_t k = 0; - if (uch < 0x80) { - putf[k++] = static_cast(uch); - } else if (uch < 0x800) { - putf[k++] = static_cast(0xC0 | (uch >> 6)); - putf[k++] = static_cast(0x80 | (uch & 0x3f)); - } else if (uch < 0x10000) { - putf[k++] = static_cast(0xE0 | (uch >> 12)); - putf[k++] = static_cast(0x80 | ((uch >> 6) & 0x3f)); - putf[k++] = static_cast(0x80 | (uch & 0x3f)); - } else { - putf[k++] = static_cast(0xF0 | (uch >> 18)); - putf[k++] = static_cast(0x80 | ((uch >> 12) & 0x3f)); - putf[k++] = static_cast(0x80 | ((uch >> 6) & 0x3f)); - putf[k++] = static_cast(0x80 | (uch & 0x3f)); - } - putf[k] = 0; -} - void AddSymmetric(enum CaseConversion conversion, int lower,int upper) { char lowerUTF8[UTF8MaxBytes+1]; UTF8FromUTF32Character(lower, lowerUTF8); @@ -511,18 +691,18 @@ void AddSymmetric(enum CaseConversion conversion, int lower,int upper) { void SetupConversions(enum CaseConversion conversion) { // First initialize for the symmetric ranges for (size_t i=0; i(originUTF8)); + const int character = UnicodeFromUTF8(originUTF8); if (conversion == CaseConversionFold && foldedUTF8[0]) { caseConvFold.Add(character, foldedUTF8); @@ -591,7 +771,7 @@ void SetupConversions(enum CaseConversion conversion) { } } -CaseConverter *ConverterForConversion(enum CaseConversion conversion) { +CaseConverter *ConverterForConversion(enum CaseConversion conversion) noexcept { switch (conversion) { case CaseConversionFold: return &caseConvFold; @@ -600,14 +780,12 @@ CaseConverter *ConverterForConversion(enum CaseConversion conversion) { case CaseConversionLower: return &caseConvLow; } - return 0; + return nullptr; } } -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif ICaseConverter *ConverterFor(enum CaseConversion conversion) { CaseConverter *pCaseConv = ConverterForConversion(conversion); @@ -630,6 +808,12 @@ size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixe return pCaseConv->CaseConvertString(converted, sizeConverted, mixed, lenMixed); } -#ifdef SCI_NAMESPACE +std::string CaseConvertString(const std::string &s, enum CaseConversion conversion) { + std::string retMapped(s.length() * maxExpansionCaseConversion, 0); + const size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(), + conversion); + retMapped.resize(lenMapped); + return retMapped; +} + } -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/CaseConvert.h b/dep/scintilla/scintilla-3.10.6/src/CaseConvert.h similarity index 90% rename from dep/scintilla/scintilla-3.6.0/src/CaseConvert.h rename to dep/scintilla/scintilla-3.10.6/src/CaseConvert.h index 60de2279..cdd08971 100644 --- a/dep/scintilla/scintilla-3.6.0/src/CaseConvert.h +++ b/dep/scintilla/scintilla-3.10.6/src/CaseConvert.h @@ -10,9 +10,7 @@ #ifndef CASECONVERT_H #define CASECONVERT_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif enum CaseConversion { CaseConversionFold, @@ -40,8 +38,9 @@ const int maxExpansionCaseConversion=3; // If there is not enough space then 0 is returned. size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed, enum CaseConversion conversion); -#ifdef SCI_NAMESPACE +// Converts a mixed case string using a particular conversion. +std::string CaseConvertString(const std::string &s, enum CaseConversion conversion); + } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/CaseFolder.cxx b/dep/scintilla/scintilla-3.10.6/src/CaseFolder.cxx similarity index 92% rename from dep/scintilla/scintilla-3.6.0/src/CaseFolder.cxx rename to dep/scintilla/scintilla-3.10.6/src/CaseFolder.cxx index 4e095df1..7db4bb67 100644 --- a/dep/scintilla/scintilla-3.6.0/src/CaseFolder.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/CaseFolder.cxx @@ -11,16 +11,13 @@ #include "CaseFolder.h" #include "CaseConvert.h" -#include "UniConversion.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif CaseFolder::~CaseFolder() { } -CaseFolderTable::CaseFolderTable() { +CaseFolderTable::CaseFolderTable() : mapping{} { for (size_t iChar=0; iChar(iChar); } @@ -44,7 +41,7 @@ void CaseFolderTable::SetTranslation(char ch, char chTranslation) { mapping[static_cast(ch)] = chTranslation; } -void CaseFolderTable::StandardASCII() { +void CaseFolderTable::StandardASCII() noexcept { for (size_t iChar=0; iChar= 'A' && iChar <= 'Z') { mapping[iChar] = static_cast(iChar - 'A' + 'a'); diff --git a/dep/scintilla/scintilla-3.6.0/src/CaseFolder.h b/dep/scintilla/scintilla-3.10.6/src/CaseFolder.h similarity index 72% rename from dep/scintilla/scintilla-3.6.0/src/CaseFolder.h rename to dep/scintilla/scintilla-3.10.6/src/CaseFolder.h index 2d754d4f..eb852a49 100644 --- a/dep/scintilla/scintilla-3.6.0/src/CaseFolder.h +++ b/dep/scintilla/scintilla-3.10.6/src/CaseFolder.h @@ -8,9 +8,7 @@ #ifndef CASEFOLDER_H #define CASEFOLDER_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif class CaseFolder { public: @@ -23,10 +21,10 @@ protected: char mapping[256]; public: CaseFolderTable(); - virtual ~CaseFolderTable(); - virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed); + ~CaseFolderTable() override; + size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override; void SetTranslation(char ch, char chTranslation); - void StandardASCII(); + void StandardASCII() noexcept; }; class ICaseConverter; @@ -35,11 +33,9 @@ class CaseFolderUnicode : public CaseFolderTable { ICaseConverter *converter; public: CaseFolderUnicode(); - virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed); + size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override; }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/Catalogue.cxx b/dep/scintilla/scintilla-3.10.6/src/Catalogue.cxx similarity index 85% rename from dep/scintilla/scintilla-3.6.0/src/Catalogue.cxx rename to dep/scintilla/scintilla-3.10.6/src/Catalogue.cxx index 02091414..6ce665ba 100644 --- a/dep/scintilla/scintilla-3.6.0/src/Catalogue.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/Catalogue.cxx @@ -1,16 +1,15 @@ // Scintilla source code edit control /** @file Catalogue.cxx - ** Colourise for particular languages. + ** Lexer infrastructure. + ** Contains a list of LexerModules which can be searched to find a module appropriate for a + ** particular language. **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include -#include -#include +#include +#include +#include #include #include @@ -22,35 +21,31 @@ #include "LexerModule.h" #include "Catalogue.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif static std::vector lexerCatalogue; static int nextLanguage = SCLEX_AUTOMATIC+1; const LexerModule *Catalogue::Find(int language) { Scintilla_LinkLexers(); - for (std::vector::iterator it=lexerCatalogue.begin(); - it != lexerCatalogue.end(); ++it) { - if ((*it)->GetLanguage() == language) { - return *it; + for (const LexerModule *lm : lexerCatalogue) { + if (lm->GetLanguage() == language) { + return lm; } } - return 0; + return nullptr; } const LexerModule *Catalogue::Find(const char *languageName) { Scintilla_LinkLexers(); if (languageName) { - for (std::vector::iterator it=lexerCatalogue.begin(); - it != lexerCatalogue.end(); ++it) { - if ((*it)->languageName && (0 == strcmp((*it)->languageName, languageName))) { - return *it; + for (const LexerModule *lm : lexerCatalogue) { + if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) { + return lm; } } } - return 0; + return nullptr; } void Catalogue::AddLexerModule(LexerModule *plm) { @@ -72,10 +67,13 @@ int Scintilla_LinkLexers() { return 0; initialised = 1; +#if 0 // Shorten the code that declares a lexer and ensures it is linked in by calling a method. #define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer); +#else +#define LINK_LEXER(lexer) +#endif -#if 0 //++Autogenerated -- run scripts/LexGen.py to regenerate //**\(\tLINK_LEXER(\*);\n\) LINK_LEXER(lmA68k); @@ -96,6 +94,7 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmBlitzBasic); LINK_LEXER(lmBullant); LINK_LEXER(lmCaml); + LINK_LEXER(lmCIL); LINK_LEXER(lmClw); LINK_LEXER(lmClwNoCase); LINK_LEXER(lmCmake); @@ -111,6 +110,7 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmDMAP); LINK_LEXER(lmDMIS); LINK_LEXER(lmECL); + LINK_LEXER(lmEDIFACT); LINK_LEXER(lmEiffel); LINK_LEXER(lmEiffelkw); LINK_LEXER(lmErlang); @@ -126,7 +126,9 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmHaskell); LINK_LEXER(lmHTML); LINK_LEXER(lmIHex); + LINK_LEXER(lmIndent); LINK_LEXER(lmInno); + LINK_LEXER(lmJSON); LINK_LEXER(lmKix); LINK_LEXER(lmKVIrc); LINK_LEXER(lmLatex); @@ -134,16 +136,19 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmLiterateHaskell); LINK_LEXER(lmLot); LINK_LEXER(lmLout); + LINK_LEXER(lmLPeg); LINK_LEXER(lmLua); LINK_LEXER(lmMagikSF); LINK_LEXER(lmMake); LINK_LEXER(lmMarkdown); LINK_LEXER(lmMatlab); + LINK_LEXER(lmMaxima); LINK_LEXER(lmMETAPOST); LINK_LEXER(lmMMIXAL); LINK_LEXER(lmModula); LINK_LEXER(lmMSSQL); LINK_LEXER(lmMySQL); + LINK_LEXER(lmNim); LINK_LEXER(lmNimrod); LINK_LEXER(lmNncrontab); LINK_LEXER(lmNsis); @@ -170,6 +175,7 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmRegistry); LINK_LEXER(lmRuby); LINK_LEXER(lmRust); + LINK_LEXER(lmSAS); LINK_LEXER(lmScriptol); LINK_LEXER(lmSmalltalk); LINK_LEXER(lmSML); @@ -178,6 +184,7 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmSpice); LINK_LEXER(lmSQL); LINK_LEXER(lmSrec); + LINK_LEXER(lmStata); LINK_LEXER(lmSTTXT); LINK_LEXER(lmTACL); LINK_LEXER(lmTADS3); @@ -192,11 +199,11 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmVerilog); LINK_LEXER(lmVHDL); LINK_LEXER(lmVisualProlog); + LINK_LEXER(lmX12); LINK_LEXER(lmXML); LINK_LEXER(lmYAML); //--Autogenerated -- end of automatically generated section -#endif return 1; } diff --git a/dep/scintilla/scintilla-3.6.0/src/Catalogue.h b/dep/scintilla/scintilla-3.10.6/src/Catalogue.h similarity index 81% rename from dep/scintilla/scintilla-3.6.0/src/Catalogue.h rename to dep/scintilla/scintilla-3.10.6/src/Catalogue.h index 7fea37da..d8769a89 100644 --- a/dep/scintilla/scintilla-3.6.0/src/Catalogue.h +++ b/dep/scintilla/scintilla-3.10.6/src/Catalogue.h @@ -1,6 +1,8 @@ // Scintilla source code edit control /** @file Catalogue.h ** Lexer infrastructure. + ** Contains a list of LexerModules which can be searched to find a module appropriate for a + ** particular language. **/ // Copyright 1998-2010 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. @@ -8,9 +10,7 @@ #ifndef CATALOGUE_H #define CATALOGUE_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif class Catalogue { public: @@ -19,8 +19,6 @@ public: static void AddLexerModule(LexerModule *plm); }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.10.6/src/CellBuffer.cxx b/dep/scintilla/scintilla-3.10.6/src/CellBuffer.cxx new file mode 100644 index 00000000..41ab8c3d --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/CellBuffer.cxx @@ -0,0 +1,1209 @@ +// Scintilla source code edit control +/** @file CellBuffer.cxx + ** Manages a buffer of cells. + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "Scintilla.h" +#include "Position.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "CellBuffer.h" +#include "UniConversion.h" + +namespace Scintilla { + +struct CountWidths { + // Measures the number of characters in a string divided into those + // from the Base Multilingual Plane and those from other planes. + Sci::Position countBasePlane; + Sci::Position countOtherPlanes; + CountWidths(Sci::Position countBasePlane_=0, Sci::Position countOtherPlanes_=0) noexcept : + countBasePlane(countBasePlane_), + countOtherPlanes(countOtherPlanes_) { + } + CountWidths operator-() const noexcept { + return CountWidths(-countBasePlane , -countOtherPlanes); + } + Sci::Position WidthUTF32() const noexcept { + // All code points take one code unit in UTF-32. + return countBasePlane + countOtherPlanes; + } + Sci::Position WidthUTF16() const noexcept { + // UTF-16 takes 2 code units for other planes + return countBasePlane + 2 * countOtherPlanes; + } + void CountChar(int lenChar) noexcept { + if (lenChar == 4) { + countOtherPlanes++; + } else { + countBasePlane++; + } + } +}; + +class ILineVector { +public: + virtual void Init() = 0; + virtual void SetPerLine(PerLine *pl) = 0; + virtual void InsertText(Sci::Line line, Sci::Position delta) = 0; + virtual void InsertLine(Sci::Line line, Sci::Position position, bool lineStart) = 0; + virtual void SetLineStart(Sci::Line line, Sci::Position position) noexcept = 0; + virtual void RemoveLine(Sci::Line line) = 0; + virtual Sci::Line Lines() const noexcept = 0; + virtual Sci::Line LineFromPosition(Sci::Position pos) const noexcept = 0; + virtual Sci::Position LineStart(Sci::Line line) const noexcept = 0; + virtual void InsertCharacters(Sci::Line line, CountWidths delta) = 0; + virtual void SetLineCharactersWidth(Sci::Line line, CountWidths width) = 0; + virtual int LineCharacterIndex() const noexcept = 0; + virtual bool AllocateLineCharacterIndex(int lineCharacterIndex, Sci::Line lines) = 0; + virtual bool ReleaseLineCharacterIndex(int lineCharacterIndex) = 0; + virtual Sci::Position IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept = 0; + virtual Sci::Line LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept = 0; + virtual ~ILineVector() {} +}; + +} + +using namespace Scintilla; + +template +class LineStartIndex { +public: + int refCount; + Partitioning starts; + + LineStartIndex() : refCount(0), starts(4) { + // Minimal initial allocation + } + // Deleted so LineStartIndex objects can not be copied. + LineStartIndex(const LineStartIndex &) = delete; + LineStartIndex(LineStartIndex &&) = delete; + void operator=(const LineStartIndex &) = delete; + void operator=(LineStartIndex &&) = delete; + virtual ~LineStartIndex() { + starts.DeleteAll(); + } + bool Allocate(Sci::Line lines) { + refCount++; + Sci::Position length = starts.PositionFromPartition(starts.Partitions()); + for (Sci::Line line = starts.Partitions(); line < lines; line++) { + // Produce an ascending sequence that will be filled in with correct widths later + length++; + starts.InsertPartition(static_cast(line), static_cast(length)); + } + return refCount == 1; + } + bool Release() { + if (refCount == 1) { + starts.DeleteAll(); + } + refCount--; + return refCount == 0; + } + bool Active() const noexcept { + return refCount > 0; + } + Sci::Position LineWidth(Sci::Line line) const noexcept { + return starts.PositionFromPartition(static_cast(line) + 1) - + starts.PositionFromPartition(static_cast(line)); + } + void SetLineWidth(Sci::Line line, Sci::Position width) { + const Sci::Position widthCurrent = LineWidth(line); + starts.InsertText(static_cast(line), static_cast(width - widthCurrent)); + } +}; + +template +class LineVector : public ILineVector { + Partitioning starts; + PerLine *perLine; + LineStartIndex startsUTF16; + LineStartIndex startsUTF32; +public: + LineVector() : starts(256), perLine(nullptr) { + Init(); + } + // Deleted so LineVector objects can not be copied. + LineVector(const LineVector &) = delete; + LineVector(LineVector &&) = delete; + LineVector &operator=(const LineVector &) = delete; + LineVector &operator=(LineVector &&) = delete; + ~LineVector() override { + } + void Init() override { + starts.DeleteAll(); + if (perLine) { + perLine->Init(); + } + startsUTF32.starts.DeleteAll(); + startsUTF16.starts.DeleteAll(); + } + void SetPerLine(PerLine *pl) override { + perLine = pl; + } + void InsertText(Sci::Line line, Sci::Position delta) override { + starts.InsertText(static_cast(line), static_cast(delta)); + } + void InsertLine(Sci::Line line, Sci::Position position, bool lineStart) override { + const POS lineAsPos = static_cast(line); + starts.InsertPartition(lineAsPos, static_cast(position)); + if (startsUTF32.Active()) { + startsUTF32.starts.InsertPartition(lineAsPos, + static_cast(startsUTF32.starts.PositionFromPartition(lineAsPos - 1) + 1)); + } + if (startsUTF16.Active()) { + startsUTF16.starts.InsertPartition(lineAsPos, + static_cast(startsUTF16.starts.PositionFromPartition(lineAsPos - 1) + 1)); + } + if (perLine) { + if ((line > 0) && lineStart) + line--; + perLine->InsertLine(line); + } + } + void SetLineStart(Sci::Line line, Sci::Position position) noexcept override { + starts.SetPartitionStartPosition(static_cast(line), static_cast(position)); + } + void RemoveLine(Sci::Line line) override { + starts.RemovePartition(static_cast(line)); + if (startsUTF32.Active()) { + startsUTF32.starts.RemovePartition(static_cast(line)); + } + if (startsUTF16.Active()) { + startsUTF16.starts.RemovePartition(static_cast(line)); + } + if (perLine) { + perLine->RemoveLine(line); + } + } + Sci::Line Lines() const noexcept override { + return static_cast(starts.Partitions()); + } + Sci::Line LineFromPosition(Sci::Position pos) const noexcept override { + return static_cast(starts.PartitionFromPosition(static_cast(pos))); + } + Sci::Position LineStart(Sci::Line line) const noexcept override { + return starts.PositionFromPartition(static_cast(line)); + } + void InsertCharacters(Sci::Line line, CountWidths delta) override { + if (startsUTF32.Active()) { + startsUTF32.starts.InsertText(static_cast(line), static_cast(delta.WidthUTF32())); + } + if (startsUTF16.Active()) { + startsUTF16.starts.InsertText(static_cast(line), static_cast(delta.WidthUTF16())); + } + } + void SetLineCharactersWidth(Sci::Line line, CountWidths width) override { + if (startsUTF32.Active()) { + assert(startsUTF32.starts.Partitions() == starts.Partitions()); + startsUTF32.SetLineWidth(line, width.WidthUTF32()); + } + if (startsUTF16.Active()) { + assert(startsUTF16.starts.Partitions() == starts.Partitions()); + startsUTF16.SetLineWidth(line, width.WidthUTF16()); + } + } + + int LineCharacterIndex() const noexcept override { + int retVal = 0; + if (startsUTF32.Active()) { + retVal |= SC_LINECHARACTERINDEX_UTF32; + } + if (startsUTF16.Active()) { + retVal |= SC_LINECHARACTERINDEX_UTF16; + } + return retVal; + } + bool AllocateLineCharacterIndex(int lineCharacterIndex, Sci::Line lines) override { + bool changed = false; + if ((lineCharacterIndex & SC_LINECHARACTERINDEX_UTF32) != 0) { + changed = startsUTF32.Allocate(lines) || changed; + assert(startsUTF32.starts.Partitions() == starts.Partitions()); + } + if ((lineCharacterIndex & SC_LINECHARACTERINDEX_UTF16) != 0) { + changed = startsUTF16.Allocate(lines) || changed; + assert(startsUTF16.starts.Partitions() == starts.Partitions()); + } + return changed; + } + bool ReleaseLineCharacterIndex(int lineCharacterIndex) override { + bool changed = false; + if ((lineCharacterIndex & SC_LINECHARACTERINDEX_UTF32) != 0) { + changed = startsUTF32.Release() || changed; + } + if ((lineCharacterIndex & SC_LINECHARACTERINDEX_UTF16) != 0) { + changed = startsUTF16.Release() || changed; + } + return changed; + } + Sci::Position IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept override { + if (lineCharacterIndex == SC_LINECHARACTERINDEX_UTF32) { + return startsUTF32.starts.PositionFromPartition(static_cast(line)); + } else { + return startsUTF16.starts.PositionFromPartition(static_cast(line)); + } + } + Sci::Line LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept override { + if (lineCharacterIndex == SC_LINECHARACTERINDEX_UTF32) { + return static_cast(startsUTF32.starts.PartitionFromPosition(static_cast(pos))); + } else { + return static_cast(startsUTF16.starts.PartitionFromPosition(static_cast(pos))); + } + } +}; + +Action::Action() { + at = startAction; + position = 0; + lenData = 0; + mayCoalesce = false; +} + +Action::~Action() { +} + +void Action::Create(actionType at_, Sci::Position position_, const char *data_, Sci::Position lenData_, bool mayCoalesce_) { + data = nullptr; + position = position_; + at = at_; + if (lenData_) { + data = std::unique_ptr(new char[lenData_]); + memcpy(&data[0], data_, lenData_); + } + lenData = lenData_; + mayCoalesce = mayCoalesce_; +} + +void Action::Clear() { + data = nullptr; + lenData = 0; +} + +// The undo history stores a sequence of user operations that represent the user's view of the +// commands executed on the text. +// Each user operation contains a sequence of text insertion and text deletion actions. +// All the user operations are stored in a list of individual actions with 'start' actions used +// as delimiters between user operations. +// Initially there is one start action in the history. +// As each action is performed, it is recorded in the history. The action may either become +// part of the current user operation or may start a new user operation. If it is to be part of the +// current operation, then it overwrites the current last action. If it is to be part of a new +// operation, it is appended after the current last action. +// After writing the new action, a new start action is appended at the end of the history. +// The decision of whether to start a new user operation is based upon two factors. If a +// compound operation has been explicitly started by calling BeginUndoAction and no matching +// EndUndoAction (these calls nest) has been called, then the action is coalesced into the current +// operation. If there is no outstanding BeginUndoAction call then a new operation is started +// unless it looks as if the new action is caused by the user typing or deleting a stream of text. +// Sequences that look like typing or deletion are coalesced into a single user operation. + +UndoHistory::UndoHistory() { + + actions.resize(3); + maxAction = 0; + currentAction = 0; + undoSequenceDepth = 0; + savePoint = 0; + tentativePoint = -1; + + actions[currentAction].Create(startAction); +} + +UndoHistory::~UndoHistory() { +} + +void UndoHistory::EnsureUndoRoom() { + // Have to test that there is room for 2 more actions in the array + // as two actions may be created by the calling function + if (static_cast(currentAction) >= (actions.size() - 2)) { + // Run out of undo nodes so extend the array + actions.resize(actions.size() * 2); + } +} + +const char *UndoHistory::AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position lengthData, + bool &startSequence, bool mayCoalesce) { + EnsureUndoRoom(); + //Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction); + //Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at, + // actions[currentAction - 1].position, actions[currentAction - 1].lenData); + if (currentAction < savePoint) { + savePoint = -1; + } + int oldCurrentAction = currentAction; + if (currentAction >= 1) { + if (0 == undoSequenceDepth) { + // Top level actions may not always be coalesced + int targetAct = -1; + const Action *actPrevious = &(actions[currentAction + targetAct]); + // Container actions may forward the coalesce state of Scintilla Actions. + while ((actPrevious->at == containerAction) && actPrevious->mayCoalesce) { + targetAct--; + actPrevious = &(actions[currentAction + targetAct]); + } + // See if current action can be coalesced into previous action + // Will work if both are inserts or deletes and position is same + if ((currentAction == savePoint) || (currentAction == tentativePoint)) { + currentAction++; + } else if (!actions[currentAction].mayCoalesce) { + // Not allowed to coalesce if this set + currentAction++; + } else if (!mayCoalesce || !actPrevious->mayCoalesce) { + currentAction++; + } else if (at == containerAction || actions[currentAction].at == containerAction) { + ; // A coalescible containerAction + } else if ((at != actPrevious->at) && (actPrevious->at != startAction)) { + currentAction++; + } else if ((at == insertAction) && + (position != (actPrevious->position + actPrevious->lenData))) { + // Insertions must be immediately after to coalesce + currentAction++; + } else if (at == removeAction) { + if ((lengthData == 1) || (lengthData == 2)) { + if ((position + lengthData) == actPrevious->position) { + ; // Backspace -> OK + } else if (position == actPrevious->position) { + ; // Delete -> OK + } else { + // Removals must be at same position to coalesce + currentAction++; + } + } else { + // Removals must be of one character to coalesce + currentAction++; + } + } else { + // Action coalesced. + } + + } else { + // Actions not at top level are always coalesced unless this is after return to top level + if (!actions[currentAction].mayCoalesce) + currentAction++; + } + } else { + currentAction++; + } + startSequence = oldCurrentAction != currentAction; + const int actionWithData = currentAction; + actions[currentAction].Create(at, position, data, lengthData, mayCoalesce); + currentAction++; + actions[currentAction].Create(startAction); + maxAction = currentAction; + return actions[actionWithData].data.get(); +} + +void UndoHistory::BeginUndoAction() { + EnsureUndoRoom(); + if (undoSequenceDepth == 0) { + if (actions[currentAction].at != startAction) { + currentAction++; + actions[currentAction].Create(startAction); + maxAction = currentAction; + } + actions[currentAction].mayCoalesce = false; + } + undoSequenceDepth++; +} + +void UndoHistory::EndUndoAction() { + PLATFORM_ASSERT(undoSequenceDepth > 0); + EnsureUndoRoom(); + undoSequenceDepth--; + if (0 == undoSequenceDepth) { + if (actions[currentAction].at != startAction) { + currentAction++; + actions[currentAction].Create(startAction); + maxAction = currentAction; + } + actions[currentAction].mayCoalesce = false; + } +} + +void UndoHistory::DropUndoSequence() { + undoSequenceDepth = 0; +} + +void UndoHistory::DeleteUndoHistory() { + for (int i = 1; i < maxAction; i++) + actions[i].Clear(); + maxAction = 0; + currentAction = 0; + actions[currentAction].Create(startAction); + savePoint = 0; + tentativePoint = -1; +} + +void UndoHistory::SetSavePoint() { + savePoint = currentAction; +} + +bool UndoHistory::IsSavePoint() const noexcept { + return savePoint == currentAction; +} + +void UndoHistory::TentativeStart() { + tentativePoint = currentAction; +} + +void UndoHistory::TentativeCommit() { + tentativePoint = -1; + // Truncate undo history + maxAction = currentAction; +} + +int UndoHistory::TentativeSteps() { + // Drop any trailing startAction + if (actions[currentAction].at == startAction && currentAction > 0) + currentAction--; + if (tentativePoint >= 0) + return currentAction - tentativePoint; + else + return -1; +} + +bool UndoHistory::CanUndo() const noexcept { + return (currentAction > 0) && (maxAction > 0); +} + +int UndoHistory::StartUndo() { + // Drop any trailing startAction + if (actions[currentAction].at == startAction && currentAction > 0) + currentAction--; + + // Count the steps in this action + int act = currentAction; + while (actions[act].at != startAction && act > 0) { + act--; + } + return currentAction - act; +} + +const Action &UndoHistory::GetUndoStep() const { + return actions[currentAction]; +} + +void UndoHistory::CompletedUndoStep() { + currentAction--; +} + +bool UndoHistory::CanRedo() const noexcept { + return maxAction > currentAction; +} + +int UndoHistory::StartRedo() { + // Drop any leading startAction + if (currentAction < maxAction && actions[currentAction].at == startAction) + currentAction++; + + // Count the steps in this action + int act = currentAction; + while (act < maxAction && actions[act].at != startAction) { + act++; + } + return act - currentAction; +} + +const Action &UndoHistory::GetRedoStep() const { + return actions[currentAction]; +} + +void UndoHistory::CompletedRedoStep() { + currentAction++; +} + +CellBuffer::CellBuffer(bool hasStyles_, bool largeDocument_) : + hasStyles(hasStyles_), largeDocument(largeDocument_) { + readOnly = false; + utf8Substance = false; + utf8LineEnds = 0; + collectingUndo = true; + if (largeDocument) + plv = std::unique_ptr>(new LineVector()); + else + plv = std::unique_ptr>(new LineVector()); +} + +CellBuffer::~CellBuffer() { +} + +char CellBuffer::CharAt(Sci::Position position) const noexcept { + return substance.ValueAt(position); +} + +unsigned char CellBuffer::UCharAt(Sci::Position position) const noexcept { + return substance.ValueAt(position); +} + +void CellBuffer::GetCharRange(char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const { + if (lengthRetrieve <= 0) + return; + if (position < 0) + return; + if ((position + lengthRetrieve) > substance.Length()) { + Platform::DebugPrintf("Bad GetCharRange %.0f for %.0f of %.0f\n", + static_cast(position), + static_cast(lengthRetrieve), + static_cast(substance.Length())); + return; + } + substance.GetRange(buffer, position, lengthRetrieve); +} + +char CellBuffer::StyleAt(Sci::Position position) const noexcept { + return hasStyles ? style.ValueAt(position) : 0; +} + +void CellBuffer::GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const { + if (lengthRetrieve < 0) + return; + if (position < 0) + return; + if (!hasStyles) { + std::fill(buffer, buffer + lengthRetrieve, static_cast(0)); + return; + } + if ((position + lengthRetrieve) > style.Length()) { + Platform::DebugPrintf("Bad GetStyleRange %.0f for %.0f of %.0f\n", + static_cast(position), + static_cast(lengthRetrieve), + static_cast(style.Length())); + return; + } + style.GetRange(reinterpret_cast(buffer), position, lengthRetrieve); +} + +const char *CellBuffer::BufferPointer() { + return substance.BufferPointer(); +} + +const char *CellBuffer::RangePointer(Sci::Position position, Sci::Position rangeLength) { + return substance.RangePointer(position, rangeLength); +} + +Sci::Position CellBuffer::GapPosition() const noexcept { + return substance.GapPosition(); +} + +// The char* returned is to an allocation owned by the undo history +const char *CellBuffer::InsertString(Sci::Position position, const char *s, Sci::Position insertLength, bool &startSequence) { + // InsertString and DeleteChars are the bottleneck though which all changes occur + const char *data = s; + 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 = uh.AppendAction(insertAction, position, s, insertLength, startSequence); + } + + BasicInsertString(position, s, insertLength); + } + return data; +} + +bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) { + if (!hasStyles) { + return false; + } + const char curVal = style.ValueAt(position); + if (curVal != styleValue) { + style.SetValueAt(position, styleValue); + return true; + } else { + return false; + } +} + +bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) { + if (!hasStyles) { + return false; + } + bool changed = false; + PLATFORM_ASSERT(lengthStyle == 0 || + (lengthStyle > 0 && lengthStyle + position <= style.Length())); + while (lengthStyle--) { + const char curVal = style.ValueAt(position); + if (curVal != styleValue) { + style.SetValueAt(position, styleValue); + changed = true; + } + position++; + } + return changed; +} + +// The char* returned is to an allocation owned by the undo history +const char *CellBuffer::DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence) { + // InsertString and DeleteChars are the bottleneck though which all changes occur + PLATFORM_ASSERT(deleteLength > 0); + const char *data = nullptr; + if (!readOnly) { + if (collectingUndo) { + // Save into the undo/redo stack, but only the characters - not the formatting + // The gap would be moved to position anyway for the deletion so this doesn't cost extra + data = substance.RangePointer(position, deleteLength); + data = uh.AppendAction(removeAction, position, data, deleteLength, startSequence); + } + + BasicDeleteChars(position, deleteLength); + } + return data; +} + +Sci::Position CellBuffer::Length() const noexcept { + return substance.Length(); +} + +void CellBuffer::Allocate(Sci::Position newSize) { + substance.ReAllocate(newSize); + if (hasStyles) { + style.ReAllocate(newSize); + } +} + +void CellBuffer::SetUTF8Substance(bool utf8Substance_) { + if (utf8Substance != utf8Substance_) { + utf8Substance = utf8Substance_; + } +} + +void CellBuffer::SetLineEndTypes(int utf8LineEnds_) { + if (utf8LineEnds != utf8LineEnds_) { + const int indexes = plv->LineCharacterIndex(); + utf8LineEnds = utf8LineEnds_; + ResetLineEnds(); + AllocateLineCharacterIndex(indexes); + } +} + +bool CellBuffer::ContainsLineEnd(const char *s, Sci::Position length) const noexcept { + unsigned char chBeforePrev = 0; + unsigned char chPrev = 0; + for (Sci::Position i = 0; i < length; i++) { + const unsigned char ch = s[i]; + if ((ch == '\r') || (ch == '\n')) { + return true; + } else if (utf8LineEnds) { + const unsigned char back3[3] = { chBeforePrev, chPrev, ch }; + if (UTF8IsSeparator(back3) || UTF8IsNEL(back3 + 1)) { + return true; + } + } + chBeforePrev = chPrev; + chPrev = ch; + } + return false; +} + +void CellBuffer::SetPerLine(PerLine *pl) { + plv->SetPerLine(pl); +} + +int CellBuffer::LineCharacterIndex() const noexcept { + return plv->LineCharacterIndex(); +} + +void CellBuffer::AllocateLineCharacterIndex(int lineCharacterIndex) { + if (utf8Substance) { + if (plv->AllocateLineCharacterIndex(lineCharacterIndex, Lines())) { + // Changed so recalculate whole file + RecalculateIndexLineStarts(0, Lines() - 1); + } + } +} + +void CellBuffer::ReleaseLineCharacterIndex(int lineCharacterIndex) { + plv->ReleaseLineCharacterIndex(lineCharacterIndex); +} + +Sci::Line CellBuffer::Lines() const noexcept { + return plv->Lines(); +} + +Sci::Position CellBuffer::LineStart(Sci::Line line) const noexcept { + if (line < 0) + return 0; + else if (line >= Lines()) + return Length(); + else + return plv->LineStart(line); +} + +Sci::Line CellBuffer::LineFromPosition(Sci::Position pos) const noexcept { + return plv->LineFromPosition(pos); +} + +Sci::Position CellBuffer::IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept { + return plv->IndexLineStart(line, lineCharacterIndex); +} + +Sci::Line CellBuffer::LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept { + return plv->LineFromPositionIndex(pos, lineCharacterIndex); +} + +bool CellBuffer::IsReadOnly() const noexcept { + return readOnly; +} + +void CellBuffer::SetReadOnly(bool set) { + readOnly = set; +} + +bool CellBuffer::IsLarge() const noexcept { + return largeDocument; +} + +bool CellBuffer::HasStyles() const noexcept { + return hasStyles; +} + +void CellBuffer::SetSavePoint() { + uh.SetSavePoint(); +} + +bool CellBuffer::IsSavePoint() const noexcept { + return uh.IsSavePoint(); +} + +void CellBuffer::TentativeStart() { + uh.TentativeStart(); +} + +void CellBuffer::TentativeCommit() { + uh.TentativeCommit(); +} + +int CellBuffer::TentativeSteps() { + return uh.TentativeSteps(); +} + +bool CellBuffer::TentativeActive() const noexcept { + return uh.TentativeActive(); +} + +// Without undo + +void CellBuffer::InsertLine(Sci::Line line, Sci::Position position, bool lineStart) { + plv->InsertLine(line, position, lineStart); +} + +void CellBuffer::RemoveLine(Sci::Line line) { + plv->RemoveLine(line); +} + +bool CellBuffer::UTF8LineEndOverlaps(Sci::Position position) const noexcept { + const unsigned char bytes[] = { + static_cast(substance.ValueAt(position-2)), + static_cast(substance.ValueAt(position-1)), + static_cast(substance.ValueAt(position)), + static_cast(substance.ValueAt(position+1)), + }; + return UTF8IsSeparator(bytes) || UTF8IsSeparator(bytes+1) || UTF8IsNEL(bytes+1); +} + +bool CellBuffer::UTF8IsCharacterBoundary(Sci::Position position) const { + assert(position >= 0 && position <= Length()); + if (position > 0) { + std::string back; + for (int i = 0; i < UTF8MaxBytes; i++) { + const Sci::Position posBack = position - i; + if (posBack < 0) { + return false; + } + back.insert(0, 1, substance.ValueAt(posBack)); + if (!UTF8IsTrailByte(back.front())) { + if (i > 0) { + // Have reached a non-trail + const int cla = UTF8Classify(reinterpret_cast(back.data()), back.size()); + if ((cla & UTF8MaskInvalid) || (cla != i)) { + return false; + } + } + break; + } + } + } + if (position < Length()) { + const unsigned char fore = substance.ValueAt(position); + if (UTF8IsTrailByte(fore)) { + return false; + } + } + return true; +} + +void CellBuffer::ResetLineEnds() { + // Reinitialize line data -- too much work to preserve + plv->Init(); + + const Sci::Position position = 0; + const Sci::Position length = Length(); + Sci::Line lineInsert = 1; + const bool atLineStart = true; + plv->InsertText(lineInsert-1, length); + unsigned char chBeforePrev = 0; + unsigned char chPrev = 0; + for (Sci::Position i = 0; i < length; i++) { + const unsigned char ch = substance.ValueAt(position + i); + if (ch == '\r') { + InsertLine(lineInsert, (position + i) + 1, atLineStart); + lineInsert++; + } else if (ch == '\n') { + if (chPrev == '\r') { + // Patch up what was end of line + plv->SetLineStart(lineInsert - 1, (position + i) + 1); + } else { + InsertLine(lineInsert, (position + i) + 1, atLineStart); + lineInsert++; + } + } else if (utf8LineEnds) { + const unsigned char back3[3] = {chBeforePrev, chPrev, ch}; + if (UTF8IsSeparator(back3) || UTF8IsNEL(back3+1)) { + InsertLine(lineInsert, (position + i) + 1, atLineStart); + lineInsert++; + } + } + chBeforePrev = chPrev; + chPrev = ch; + } +} + +namespace { + +CountWidths CountCharacterWidthsUTF8(const char *s, size_t len) noexcept { + CountWidths cw; + size_t remaining = len; + while (remaining > 0) { + const int utf8Status = UTF8Classify(reinterpret_cast(s), len); + const int lenChar = utf8Status & UTF8MaskWidth; + cw.CountChar(lenChar); + s += lenChar; + remaining -= lenChar; + } + return cw; +} + +} + +bool CellBuffer::MaintainingLineCharacterIndex() const noexcept { + return plv->LineCharacterIndex() != SC_LINECHARACTERINDEX_NONE; +} + +void CellBuffer::RecalculateIndexLineStarts(Sci::Line lineFirst, Sci::Line lineLast) { + std::string text; + Sci::Position posLineEnd = LineStart(lineFirst); + for (Sci::Line line = lineFirst; line <= lineLast; line++) { + // Find line start and end, retrieve text of line, count characters and update line width + const Sci::Position posLineStart = posLineEnd; + posLineEnd = LineStart(line+1); + const Sci::Position width = posLineEnd - posLineStart; + text.resize(width); + GetCharRange(const_cast(text.data()), posLineStart, width); + const CountWidths cw = CountCharacterWidthsUTF8(text.data(), text.size()); + plv->SetLineCharactersWidth(line, cw); + } +} + +void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::Position insertLength) { + if (insertLength == 0) + return; + PLATFORM_ASSERT(insertLength > 0); + + const unsigned char chAfter = substance.ValueAt(position); + bool breakingUTF8LineEnd = false; + if (utf8LineEnds && UTF8IsTrailByte(chAfter)) { + breakingUTF8LineEnd = UTF8LineEndOverlaps(position); + } + + const Sci::Line linePosition = plv->LineFromPosition(position); + Sci::Line lineInsert = linePosition + 1; + + // A simple insertion is one that inserts valid text on a single line at a character boundary + bool simpleInsertion = false; + + const bool maintainingIndex = MaintainingLineCharacterIndex(); + + // Check for breaking apart a UTF-8 sequence and inserting invalid UTF-8 + if (utf8Substance && maintainingIndex) { + // Actually, don't need to check that whole insertion is valid just that there + // are no potential fragments at ends. + simpleInsertion = UTF8IsCharacterBoundary(position) && + UTF8IsValid(s, insertLength); + } + + substance.InsertFromArray(position, s, 0, insertLength); + if (hasStyles) { + style.InsertValue(position, insertLength, 0); + } + + const bool atLineStart = plv->LineStart(lineInsert-1) == position; + // Point all the lines after the insertion point further along in the buffer + plv->InsertText(lineInsert-1, insertLength); + unsigned char chBeforePrev = substance.ValueAt(position - 2); + unsigned char chPrev = substance.ValueAt(position - 1); + if (chPrev == '\r' && chAfter == '\n') { + // Splitting up a crlf pair at position + InsertLine(lineInsert, position, false); + lineInsert++; + } + if (breakingUTF8LineEnd) { + RemoveLine(lineInsert); + } + unsigned char ch = ' '; + for (Sci::Position i = 0; i < insertLength; i++) { + ch = s[i]; + if (ch == '\r') { + InsertLine(lineInsert, (position + i) + 1, atLineStart); + lineInsert++; + simpleInsertion = false; + } else if (ch == '\n') { + if (chPrev == '\r') { + // Patch up what was end of line + plv->SetLineStart(lineInsert - 1, (position + i) + 1); + } else { + InsertLine(lineInsert, (position + i) + 1, atLineStart); + lineInsert++; + } + simpleInsertion = false; + } else if (utf8LineEnds) { + const unsigned char back3[3] = {chBeforePrev, chPrev, ch}; + if (UTF8IsSeparator(back3) || UTF8IsNEL(back3+1)) { + InsertLine(lineInsert, (position + i) + 1, atLineStart); + lineInsert++; + simpleInsertion = false; + } + } + chBeforePrev = chPrev; + chPrev = ch; + } + // Joining two lines where last insertion is cr and following substance starts with lf + if (chAfter == '\n') { + if (ch == '\r') { + // End of line already in buffer so drop the newly created one + RemoveLine(lineInsert - 1); + simpleInsertion = false; + } + } else if (utf8LineEnds && !UTF8IsAscii(chAfter)) { + // May have end of UTF-8 line end in buffer and start in insertion + for (int j = 0; j < UTF8SeparatorLength-1; j++) { + const unsigned char chAt = substance.ValueAt(position + insertLength + j); + const unsigned char back3[3] = {chBeforePrev, chPrev, chAt}; + if (UTF8IsSeparator(back3)) { + InsertLine(lineInsert, (position + insertLength + j) + 1, atLineStart); + lineInsert++; + simpleInsertion = false; + } + if ((j == 0) && UTF8IsNEL(back3+1)) { + InsertLine(lineInsert, (position + insertLength + j) + 1, atLineStart); + lineInsert++; + simpleInsertion = false; + } + chBeforePrev = chPrev; + chPrev = chAt; + } + } + if (maintainingIndex) { + if (simpleInsertion) { + const CountWidths cw = CountCharacterWidthsUTF8(s, insertLength); + plv->InsertCharacters(linePosition, cw); + } else { + RecalculateIndexLineStarts(linePosition, lineInsert - 1); + } + } +} + +void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLength) { + if (deleteLength == 0) + return; + + Sci::Line lineRecalculateStart = INVALID_POSITION; + + if ((position == 0) && (deleteLength == substance.Length())) { + // If whole buffer is being deleted, faster to reinitialise lines data + // than to delete each line. + plv->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 + + const Sci::Line linePosition = plv->LineFromPosition(position); + Sci::Line lineRemove = linePosition + 1; + + plv->InsertText(lineRemove-1, - (deleteLength)); + const unsigned char chPrev = substance.ValueAt(position - 1); + const unsigned char chBefore = chPrev; + unsigned char chNext = substance.ValueAt(position); + + // Check for breaking apart a UTF-8 sequence + // Needs further checks that text is UTF-8 or that some other break apart is occurring + if (utf8Substance && MaintainingLineCharacterIndex()) { + const Sci::Position posEnd = position + deleteLength; + const Sci::Line lineEndRemove = plv->LineFromPosition(posEnd); + const bool simpleDeletion = + (linePosition == lineEndRemove) && + UTF8IsCharacterBoundary(position) && UTF8IsCharacterBoundary(posEnd); + if (simpleDeletion) { + std::string text(deleteLength, '\0'); + GetCharRange(const_cast(text.data()), position, deleteLength); + if (UTF8IsValid(text.data(), text.size())) { + // Everything is good + const CountWidths cw = CountCharacterWidthsUTF8(text.data(), text.size()); + plv->InsertCharacters(linePosition, -cw); + } else { + lineRecalculateStart = linePosition; + } + } else { + lineRecalculateStart = linePosition; + } + } + + bool ignoreNL = false; + if (chPrev == '\r' && chNext == '\n') { + // Move back one + plv->SetLineStart(lineRemove, position); + lineRemove++; + ignoreNL = true; // First \n is not real deletion + } + if (utf8LineEnds && UTF8IsTrailByte(chNext)) { + if (UTF8LineEndOverlaps(position)) { + RemoveLine(lineRemove); + } + } + + unsigned char ch = chNext; + for (Sci::Position i = 0; i < deleteLength; i++) { + chNext = substance.ValueAt(position + i + 1); + if (ch == '\r') { + if (chNext != '\n') { + RemoveLine(lineRemove); + } + } else if (ch == '\n') { + if (ignoreNL) { + ignoreNL = false; // Further \n are real deletions + } else { + RemoveLine(lineRemove); + } + } else if (utf8LineEnds) { + if (!UTF8IsAscii(ch)) { + const unsigned char next3[3] = {ch, chNext, + static_cast(substance.ValueAt(position + i + 2))}; + if (UTF8IsSeparator(next3) || UTF8IsNEL(next3)) { + RemoveLine(lineRemove); + } + } + } + + ch = chNext; + } + // May have to fix up end if last deletion causes cr to be next to lf + // or removes one of a crlf pair + const char chAfter = substance.ValueAt(position + deleteLength); + if (chBefore == '\r' && chAfter == '\n') { + // Using lineRemove-1 as cr ended line before start of deletion + RemoveLine(lineRemove - 1); + plv->SetLineStart(lineRemove - 1, position + 1); + } + } + substance.DeleteRange(position, deleteLength); + if (lineRecalculateStart >= 0) { + RecalculateIndexLineStarts(lineRecalculateStart, lineRecalculateStart); + } + if (hasStyles) { + style.DeleteRange(position, deleteLength); + } +} + +bool CellBuffer::SetUndoCollection(bool collectUndo) { + collectingUndo = collectUndo; + uh.DropUndoSequence(); + return collectingUndo; +} + +bool CellBuffer::IsCollectingUndo() const noexcept { + return collectingUndo; +} + +void CellBuffer::BeginUndoAction() { + uh.BeginUndoAction(); +} + +void CellBuffer::EndUndoAction() { + uh.EndUndoAction(); +} + +void CellBuffer::AddUndoAction(Sci::Position token, bool mayCoalesce) { + bool startSequence; + uh.AppendAction(containerAction, token, nullptr, 0, startSequence, mayCoalesce); +} + +void CellBuffer::DeleteUndoHistory() { + uh.DeleteUndoHistory(); +} + +bool CellBuffer::CanUndo() const noexcept { + return uh.CanUndo(); +} + +int CellBuffer::StartUndo() { + return uh.StartUndo(); +} + +const Action &CellBuffer::GetUndoStep() const { + return uh.GetUndoStep(); +} + +void CellBuffer::PerformUndoStep() { + const Action &actionStep = uh.GetUndoStep(); + if (actionStep.at == insertAction) { +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) + if (substance.Length() < actionStep.lenData) { + throw std::runtime_error( + "CellBuffer::PerformUndoStep: deletion must be less than document length."); + } +#endif + BasicDeleteChars(actionStep.position, actionStep.lenData); + } else if (actionStep.at == removeAction) { + BasicInsertString(actionStep.position, actionStep.data.get(), actionStep.lenData); + } + uh.CompletedUndoStep(); +} + +bool CellBuffer::CanRedo() const noexcept { + return uh.CanRedo(); +} + +int CellBuffer::StartRedo() { + return uh.StartRedo(); +} + +const Action &CellBuffer::GetRedoStep() const { + return uh.GetRedoStep(); +} + +void CellBuffer::PerformRedoStep() { + const Action &actionStep = uh.GetRedoStep(); + if (actionStep.at == insertAction) { + BasicInsertString(actionStep.position, actionStep.data.get(), actionStep.lenData); + } else if (actionStep.at == removeAction) { + BasicDeleteChars(actionStep.position, actionStep.lenData); + } + uh.CompletedRedoStep(); +} + diff --git a/dep/scintilla/scintilla-3.10.6/src/CellBuffer.h b/dep/scintilla/scintilla-3.10.6/src/CellBuffer.h new file mode 100644 index 00000000..599f3b3f --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/CellBuffer.h @@ -0,0 +1,215 @@ +// Scintilla source code edit control +/** @file CellBuffer.h + ** Manages the text of the document. + **/ +// Copyright 1998-2004 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef CELLBUFFER_H +#define CELLBUFFER_H + +namespace Scintilla { + +// Interface to per-line data that wants to see each line insertion and deletion +class PerLine { +public: + virtual ~PerLine() {} + virtual void Init()=0; + virtual void InsertLine(Sci::Line line)=0; + virtual void RemoveLine(Sci::Line line)=0; +}; + +/** + * The line vector contains information about each of the lines in a cell buffer. + */ +class ILineVector; + +enum actionType { insertAction, removeAction, startAction, containerAction }; + +/** + * Actions are used to store all the information required to perform one undo/redo step. + */ +class Action { +public: + actionType at; + Sci::Position position; + std::unique_ptr data; + Sci::Position lenData; + bool mayCoalesce; + + Action(); + // Deleted so Action objects can not be copied. + Action(const Action &other) = delete; + Action &operator=(const Action &other) = delete; + Action &operator=(const Action &&other) = delete; + // Move constructor allows vector to be resized without reallocating. + Action(Action &&other) noexcept = default; + ~Action(); + void Create(actionType at_, Sci::Position position_=0, const char *data_=nullptr, Sci::Position lenData_=0, bool mayCoalesce_=true); + void Clear(); +}; + +/** + * + */ +class UndoHistory { + std::vector actions; + int maxAction; + int currentAction; + int undoSequenceDepth; + int savePoint; + int tentativePoint; + + void EnsureUndoRoom(); + +public: + UndoHistory(); + // Deleted so UndoHistory objects can not be copied. + UndoHistory(const UndoHistory &) = delete; + UndoHistory(UndoHistory &&) = delete; + void operator=(const UndoHistory &) = delete; + void operator=(UndoHistory &&) = delete; + ~UndoHistory(); + + const char *AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position lengthData, bool &startSequence, bool mayCoalesce=true); + + void BeginUndoAction(); + void EndUndoAction(); + void DropUndoSequence(); + void DeleteUndoHistory(); + + /// The save point is a marker in the undo stack where the container has stated that + /// the buffer was saved. Undo and redo can move over the save point. + void SetSavePoint(); + bool IsSavePoint() const noexcept; + + // Tentative actions are used for input composition so that it can be undone cleanly + void TentativeStart(); + void TentativeCommit(); + bool TentativeActive() const noexcept { return tentativePoint >= 0; } + int TentativeSteps(); + + /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is + /// called that many times. Similarly for redo. + bool CanUndo() const noexcept; + int StartUndo(); + const Action &GetUndoStep() const; + void CompletedUndoStep(); + bool CanRedo() const noexcept; + int StartRedo(); + const Action &GetRedoStep() const; + void CompletedRedoStep(); +}; + +/** + * Holder for an expandable array of characters that supports undo and line markers. + * Based on article "Data Structures in a Bit-Mapped Text Editor" + * by Wilfred J. Hansen, Byte January 1987, page 183. + */ +class CellBuffer { +private: + bool hasStyles; + bool largeDocument; + SplitVector substance; + SplitVector style; + bool readOnly; + bool utf8Substance; + int utf8LineEnds; + + bool collectingUndo; + UndoHistory uh; + + std::unique_ptr plv; + + bool UTF8LineEndOverlaps(Sci::Position position) const noexcept; + bool UTF8IsCharacterBoundary(Sci::Position position) const; + void ResetLineEnds(); + void RecalculateIndexLineStarts(Sci::Line lineFirst, Sci::Line lineLast); + bool MaintainingLineCharacterIndex() const noexcept; + /// Actions without undo + void BasicInsertString(Sci::Position position, const char *s, Sci::Position insertLength); + void BasicDeleteChars(Sci::Position position, Sci::Position deleteLength); + +public: + + CellBuffer(bool hasStyles_, bool largeDocument_); + // Deleted so CellBuffer objects can not be copied. + CellBuffer(const CellBuffer &) = delete; + CellBuffer(CellBuffer &&) = delete; + void operator=(const CellBuffer &) = delete; + void operator=(CellBuffer &&) = delete; + ~CellBuffer(); + + /// Retrieving positions outside the range of the buffer works and returns 0 + char CharAt(Sci::Position position) const noexcept; + unsigned char UCharAt(Sci::Position position) const noexcept; + void GetCharRange(char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const; + char StyleAt(Sci::Position position) const noexcept; + void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const; + const char *BufferPointer(); + const char *RangePointer(Sci::Position position, Sci::Position rangeLength); + Sci::Position GapPosition() const noexcept; + + Sci::Position Length() const noexcept; + void Allocate(Sci::Position newSize); + void SetUTF8Substance(bool utf8Substance_); + int GetLineEndTypes() const noexcept { return utf8LineEnds; } + void SetLineEndTypes(int utf8LineEnds_); + bool ContainsLineEnd(const char *s, Sci::Position length) const noexcept; + void SetPerLine(PerLine *pl); + int LineCharacterIndex() const noexcept; + void AllocateLineCharacterIndex(int lineCharacterIndex); + void ReleaseLineCharacterIndex(int lineCharacterIndex); + Sci::Line Lines() const noexcept; + Sci::Position LineStart(Sci::Line line) const noexcept; + Sci::Position IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept; + Sci::Line LineFromPosition(Sci::Position pos) const noexcept; + Sci::Line LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept; + void InsertLine(Sci::Line line, Sci::Position position, bool lineStart); + void RemoveLine(Sci::Line line); + const char *InsertString(Sci::Position position, const char *s, Sci::Position 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(Sci::Position position, char styleValue); + bool SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue); + + const char *DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence); + + bool IsReadOnly() const noexcept; + void SetReadOnly(bool set); + bool IsLarge() const noexcept; + bool HasStyles() const noexcept; + + /// The save point is a marker in the undo stack where the container has stated that + /// the buffer was saved. Undo and redo can move over the save point. + void SetSavePoint(); + bool IsSavePoint() const noexcept; + + void TentativeStart(); + void TentativeCommit(); + bool TentativeActive() const noexcept; + int TentativeSteps(); + + bool SetUndoCollection(bool collectUndo); + bool IsCollectingUndo() const noexcept; + void BeginUndoAction(); + void EndUndoAction(); + void AddUndoAction(Sci::Position token, bool mayCoalesce); + void DeleteUndoHistory(); + + /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is + /// called that many times. Similarly for redo. + bool CanUndo() const noexcept; + int StartUndo(); + const Action &GetUndoStep() const; + void PerformUndoStep(); + bool CanRedo() const noexcept; + int StartRedo(); + const Action &GetRedoStep() const; + void PerformRedoStep(); +}; + +} + +#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/CharClassify.cxx b/dep/scintilla/scintilla-3.10.6/src/CharClassify.cxx similarity index 87% rename from dep/scintilla/scintilla-3.6.0/src/CharClassify.cxx rename to dep/scintilla/scintilla-3.10.6/src/CharClassify.cxx index 595b0da3..5ae47a2e 100644 --- a/dep/scintilla/scintilla-3.6.0/src/CharClassify.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/CharClassify.cxx @@ -5,18 +5,17 @@ // Copyright 2006 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include +#include +#include #include +#include "CharacterSet.h" #include "CharClassify.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif -CharClassify::CharClassify() { +CharClassify::CharClassify() : charClass{} { SetDefaultCharClasses(true); } @@ -27,7 +26,7 @@ void CharClassify::SetDefaultCharClasses(bool includeWordClass) { charClass[ch] = ccNewLine; else if (ch < 0x20 || ch == ' ') charClass[ch] = ccSpace; - else if (includeWordClass && (ch >= 0x80 || isalnum(ch) || ch == '_')) + else if (includeWordClass && (ch >= 0x80 || IsAlphaNumeric(ch) || ch == '_')) charClass[ch] = ccWord; else charClass[ch] = ccPunctuation; @@ -44,7 +43,7 @@ void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) { } } -int CharClassify::GetCharsOfClass(cc characterClass, unsigned char *buffer) { +int CharClassify::GetCharsOfClass(cc characterClass, unsigned char *buffer) const { // Get characters belonging to the given char class; return the number // of characters (if the buffer is NULL, don't write to it). int count = 0; diff --git a/dep/scintilla/scintilla-3.6.0/src/CharClassify.h b/dep/scintilla/scintilla-3.10.6/src/CharClassify.h similarity index 70% rename from dep/scintilla/scintilla-3.6.0/src/CharClassify.h rename to dep/scintilla/scintilla-3.10.6/src/CharClassify.h index 5d2734c0..1381a1b3 100644 --- a/dep/scintilla/scintilla-3.6.0/src/CharClassify.h +++ b/dep/scintilla/scintilla-3.10.6/src/CharClassify.h @@ -8,9 +8,7 @@ #ifndef CHARCLASSIFY_H #define CHARCLASSIFY_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif class CharClassify { public: @@ -19,17 +17,15 @@ public: enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation }; void SetDefaultCharClasses(bool includeWordClass); void SetCharClasses(const unsigned char *chars, cc newCharClass); - int GetCharsOfClass(cc charClass, unsigned char *buffer); - cc GetClass(unsigned char ch) const { return static_cast(charClass[ch]);} - bool IsWord(unsigned char ch) const { return static_cast(charClass[ch]) == ccWord;} + int GetCharsOfClass(cc characterClass, unsigned char *buffer) const; + cc GetClass(unsigned char ch) const noexcept { return static_cast(charClass[ch]);} + bool IsWord(unsigned char ch) const noexcept { return static_cast(charClass[ch]) == ccWord;} private: enum { maxChar=256 }; unsigned char charClass[maxChar]; // not type cc to save space }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.10.6/src/ContractionState.cxx b/dep/scintilla/scintilla-3.10.6/src/ContractionState.cxx new file mode 100644 index 00000000..ebbf9aef --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/ContractionState.cxx @@ -0,0 +1,420 @@ +// Scintilla source code edit control +/** @file ContractionState.cxx + ** Manages visibility of lines for folding and wrapping. + **/ +// Copyright 1998-2007 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include + +#include +#include +#include +#include + +#include "Platform.h" + +#include "Position.h" +#include "UniqueString.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h" +#include "SparseVector.h" +#include "ContractionState.h" + +using namespace Scintilla; + +namespace { + +template +class ContractionState final : public IContractionState { + // These contain 1 element for every document line. + std::unique_ptr> visible; + std::unique_ptr> expanded; + std::unique_ptr> heights; + std::unique_ptr> foldDisplayTexts; + std::unique_ptr> displayLines; + LINE linesInDocument; + + void EnsureData(); + + bool OneToOne() const noexcept { + // True when each document line is exactly one display line so need for + // complex data structures. + return visible == nullptr; + } + + void InsertLine(Sci::Line lineDoc); + void DeleteLine(Sci::Line lineDoc); + +public: + ContractionState() noexcept; + // Deleted so ContractionState objects can not be copied. + ContractionState(const ContractionState &) = delete; + void operator=(const ContractionState &) = delete; + ContractionState(ContractionState &&) = delete; + void operator=(ContractionState &&) = delete; + ~ContractionState() override; + + void Clear() noexcept override; + + Sci::Line LinesInDoc() const override; + Sci::Line LinesDisplayed() const override; + Sci::Line DisplayFromDoc(Sci::Line lineDoc) const override; + Sci::Line DisplayLastFromDoc(Sci::Line lineDoc) const override; + Sci::Line DocFromDisplay(Sci::Line lineDisplay) const override; + + void InsertLines(Sci::Line lineDoc, Sci::Line lineCount) override; + void DeleteLines(Sci::Line lineDoc, Sci::Line lineCount) override; + + bool GetVisible(Sci::Line lineDoc) const override; + bool SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd, bool isVisible) override; + bool HiddenLines() const override; + + const char *GetFoldDisplayText(Sci::Line lineDoc) const override; + bool SetFoldDisplayText(Sci::Line lineDoc, const char *text) override; + + bool GetExpanded(Sci::Line lineDoc) const override; + bool SetExpanded(Sci::Line lineDoc, bool isExpanded) override; + Sci::Line ContractedNext(Sci::Line lineDocStart) const override; + + int GetHeight(Sci::Line lineDoc) const override; + bool SetHeight(Sci::Line lineDoc, int height) override; + + void ShowAll() override; + + void Check() const; +}; + +template +ContractionState::ContractionState() noexcept : linesInDocument(1) { +} + +template +ContractionState::~ContractionState() { + Clear(); +} + +template +void ContractionState::EnsureData() { + if (OneToOne()) { + visible = std::unique_ptr>(new RunStyles()); + expanded = std::unique_ptr>(new RunStyles()); + heights = std::unique_ptr>(new RunStyles()); + foldDisplayTexts = std::unique_ptr>(new SparseVector()); + displayLines = std::unique_ptr>(new Partitioning(4)); + InsertLines(0, linesInDocument); + } +} + +template +void ContractionState::InsertLine(Sci::Line lineDoc) { + if (OneToOne()) { + linesInDocument++; + } else { + const LINE lineDocCast = static_cast(lineDoc); + visible->InsertSpace(lineDocCast, 1); + visible->SetValueAt(lineDocCast, 1); + expanded->InsertSpace(lineDocCast, 1); + expanded->SetValueAt(lineDocCast, 1); + heights->InsertSpace(lineDocCast, 1); + heights->SetValueAt(lineDocCast, 1); + foldDisplayTexts->InsertSpace(lineDocCast, 1); + foldDisplayTexts->SetValueAt(lineDocCast, nullptr); + const Sci::Line lineDisplay = DisplayFromDoc(lineDoc); + displayLines->InsertPartition(lineDocCast, static_cast(lineDisplay)); + displayLines->InsertText(lineDocCast, 1); + } +} + +template +void ContractionState::DeleteLine(Sci::Line lineDoc) { + if (OneToOne()) { + linesInDocument--; + } else { + const LINE lineDocCast = static_cast(lineDoc); + if (GetVisible(lineDoc)) { + displayLines->InsertText(lineDocCast, -heights->ValueAt(lineDocCast)); + } + displayLines->RemovePartition(lineDocCast); + visible->DeleteRange(lineDocCast, 1); + expanded->DeleteRange(lineDocCast, 1); + heights->DeleteRange(lineDocCast, 1); + foldDisplayTexts->DeletePosition(lineDocCast); + } +} + +template +void ContractionState::Clear() noexcept { + visible.reset(); + expanded.reset(); + heights.reset(); + foldDisplayTexts.reset(); + displayLines.reset(); + linesInDocument = 1; +} + +template +Sci::Line ContractionState::LinesInDoc() const { + if (OneToOne()) { + return linesInDocument; + } else { + return displayLines->Partitions() - 1; + } +} + +template +Sci::Line ContractionState::LinesDisplayed() const { + if (OneToOne()) { + return linesInDocument; + } else { + return displayLines->PositionFromPartition(static_cast(LinesInDoc())); + } +} + +template +Sci::Line ContractionState::DisplayFromDoc(Sci::Line lineDoc) const { + if (OneToOne()) { + return (lineDoc <= linesInDocument) ? lineDoc : linesInDocument; + } else { + if (lineDoc > displayLines->Partitions()) + lineDoc = displayLines->Partitions(); + return displayLines->PositionFromPartition(static_cast(lineDoc)); + } +} + +template +Sci::Line ContractionState::DisplayLastFromDoc(Sci::Line lineDoc) const { + return DisplayFromDoc(lineDoc) + GetHeight(lineDoc) - 1; +} + +template +Sci::Line ContractionState::DocFromDisplay(Sci::Line lineDisplay) const { + if (OneToOne()) { + return lineDisplay; + } else { + if (lineDisplay <= 0) { + return 0; + } + if (lineDisplay > LinesDisplayed()) { + return displayLines->PartitionFromPosition(static_cast(LinesDisplayed())); + } + const Sci::Line lineDoc = displayLines->PartitionFromPosition(static_cast(lineDisplay)); + PLATFORM_ASSERT(GetVisible(lineDoc)); + return lineDoc; + } +} + +template +void ContractionState::InsertLines(Sci::Line lineDoc, Sci::Line lineCount) { + if (OneToOne()) { + linesInDocument += static_cast(lineCount); + } else { + for (Sci::Line l = 0; l < lineCount; l++) { + InsertLine(lineDoc + l); + } + } + Check(); +} + +template +void ContractionState::DeleteLines(Sci::Line lineDoc, Sci::Line lineCount) { + if (OneToOne()) { + linesInDocument -= static_cast(lineCount); + } else { + for (Sci::Line l = 0; l < lineCount; l++) { + DeleteLine(lineDoc); + } + } + Check(); +} + +template +bool ContractionState::GetVisible(Sci::Line lineDoc) const { + if (OneToOne()) { + return true; + } else { + if (lineDoc >= visible->Length()) + return true; + return visible->ValueAt(static_cast(lineDoc)) == 1; + } +} + +template +bool ContractionState::SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd, bool isVisible) { + if (OneToOne() && isVisible) { + return false; + } else { + EnsureData(); + Sci::Line delta = 0; + Check(); + if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) { + for (Sci::Line line = lineDocStart; line <= lineDocEnd; line++) { + if (GetVisible(line) != isVisible) { + const int heightLine = heights->ValueAt(static_cast(line)); + const int difference = isVisible ? heightLine : -heightLine; + visible->SetValueAt(static_cast(line), isVisible ? 1 : 0); + displayLines->InsertText(static_cast(line), difference); + delta += difference; + } + } + } else { + return false; + } + Check(); + return delta != 0; + } +} + +template +bool ContractionState::HiddenLines() const { + if (OneToOne()) { + return false; + } else { + return !visible->AllSameAs(1); + } +} + +template +const char *ContractionState::GetFoldDisplayText(Sci::Line lineDoc) const { + Check(); + return foldDisplayTexts->ValueAt(lineDoc).get(); +} + +template +bool ContractionState::SetFoldDisplayText(Sci::Line lineDoc, const char *text) { + EnsureData(); + const char *foldText = foldDisplayTexts->ValueAt(lineDoc).get(); + if (!foldText || !text || 0 != strcmp(text, foldText)) { + UniqueString uns = IsNullOrEmpty(text) ? UniqueString() : UniqueStringCopy(text); + foldDisplayTexts->SetValueAt(lineDoc, std::move(uns)); + Check(); + return true; + } else { + Check(); + return false; + } +} + +template +bool ContractionState::GetExpanded(Sci::Line lineDoc) const { + if (OneToOne()) { + return true; + } else { + Check(); + return expanded->ValueAt(static_cast(lineDoc)) == 1; + } +} + +template +bool ContractionState::SetExpanded(Sci::Line lineDoc, bool isExpanded) { + if (OneToOne() && isExpanded) { + return false; + } else { + EnsureData(); + if (isExpanded != (expanded->ValueAt(static_cast(lineDoc)) == 1)) { + expanded->SetValueAt(static_cast(lineDoc), isExpanded ? 1 : 0); + Check(); + return true; + } else { + Check(); + return false; + } + } +} + +template +Sci::Line ContractionState::ContractedNext(Sci::Line lineDocStart) const { + if (OneToOne()) { + return -1; + } else { + Check(); + if (!expanded->ValueAt(static_cast(lineDocStart))) { + return lineDocStart; + } else { + const Sci::Line lineDocNextChange = expanded->EndRun(static_cast(lineDocStart)); + if (lineDocNextChange < LinesInDoc()) + return lineDocNextChange; + else + return -1; + } + } +} + +template +int ContractionState::GetHeight(Sci::Line lineDoc) const { + if (OneToOne()) { + return 1; + } else { + return heights->ValueAt(static_cast(lineDoc)); + } +} + +// Set the number of display lines needed for this line. +// Return true if this is a change. +template +bool ContractionState::SetHeight(Sci::Line lineDoc, int height) { + if (OneToOne() && (height == 1)) { + return false; + } else if (lineDoc < LinesInDoc()) { + EnsureData(); + if (GetHeight(lineDoc) != height) { + if (GetVisible(lineDoc)) { + displayLines->InsertText(static_cast(lineDoc), height - GetHeight(lineDoc)); + } + heights->SetValueAt(static_cast(lineDoc), height); + Check(); + return true; + } else { + Check(); + return false; + } + } else { + return false; + } +} + +template +void ContractionState::ShowAll() { + const LINE lines = static_cast(LinesInDoc()); + Clear(); + linesInDocument = lines; +} + +// Debugging checks + +template +void ContractionState::Check() const { +#ifdef CHECK_CORRECTNESS + for (Sci::Line vline = 0; vline < LinesDisplayed(); vline++) { + const Sci::Line lineDoc = DocFromDisplay(vline); + PLATFORM_ASSERT(GetVisible(lineDoc)); + } + for (Sci::Line lineDoc = 0; lineDoc < LinesInDoc(); lineDoc++) { + const Sci::Line displayThis = DisplayFromDoc(lineDoc); + const Sci::Line displayNext = DisplayFromDoc(lineDoc + 1); + const Sci::Line height = displayNext - displayThis; + PLATFORM_ASSERT(height >= 0); + if (GetVisible(lineDoc)) { + PLATFORM_ASSERT(GetHeight(lineDoc) == height); + } else { + PLATFORM_ASSERT(0 == height); + } + } +#endif +} + +} + +namespace Scintilla { + +std::unique_ptr ContractionStateCreate(bool largeDocument) { + if (largeDocument) + return std::unique_ptr>(new ContractionState()); + else + return std::unique_ptr>(new ContractionState()); +} + +} diff --git a/dep/scintilla/scintilla-3.10.6/src/ContractionState.h b/dep/scintilla/scintilla-3.10.6/src/ContractionState.h new file mode 100644 index 00000000..f9ec7b64 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/ContractionState.h @@ -0,0 +1,51 @@ +// Scintilla source code edit control +/** @file ContractionState.h + ** Manages visibility of lines for folding and wrapping. + **/ +// Copyright 1998-2007 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef CONTRACTIONSTATE_H +#define CONTRACTIONSTATE_H + +namespace Scintilla { + +/** +*/ +class IContractionState { +public: + virtual ~IContractionState() {}; + + virtual void Clear()=0; + + virtual Sci::Line LinesInDoc() const=0; + virtual Sci::Line LinesDisplayed() const=0; + virtual Sci::Line DisplayFromDoc(Sci::Line lineDoc) const=0; + virtual Sci::Line DisplayLastFromDoc(Sci::Line lineDoc) const=0; + virtual Sci::Line DocFromDisplay(Sci::Line lineDisplay) const=0; + + virtual void InsertLines(Sci::Line lineDoc, Sci::Line lineCount)=0; + virtual void DeleteLines(Sci::Line lineDoc, Sci::Line lineCount)=0; + + virtual bool GetVisible(Sci::Line lineDoc) const=0; + virtual bool SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd, bool isVisible)=0; + virtual bool HiddenLines() const=0; + + virtual const char *GetFoldDisplayText(Sci::Line lineDoc) const=0; + virtual bool SetFoldDisplayText(Sci::Line lineDoc, const char *text)=0; + + virtual bool GetExpanded(Sci::Line lineDoc) const=0; + virtual bool SetExpanded(Sci::Line lineDoc, bool isExpanded)=0; + virtual Sci::Line ContractedNext(Sci::Line lineDocStart) const=0; + + virtual int GetHeight(Sci::Line lineDoc) const=0; + virtual bool SetHeight(Sci::Line lineDoc, int height)=0; + + virtual void ShowAll()=0; +}; + +std::unique_ptr ContractionStateCreate(bool largeDocument); + +} + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/src/DBCS.cxx b/dep/scintilla/scintilla-3.10.6/src/DBCS.cxx new file mode 100644 index 00000000..148c9818 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/DBCS.cxx @@ -0,0 +1,42 @@ +// Scintilla source code edit control +/** @file DBCS.cxx + ** Functions to handle DBCS double byte encodings like Shift-JIS. + **/ +// Copyright 2017 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include "DBCS.h" + +using namespace Scintilla; + +namespace Scintilla { + +bool DBCSIsLeadByte(int codePage, char ch) noexcept { + // Byte ranges found in Wikipedia articles with relevant search strings in each case + const unsigned char uch = ch; + switch (codePage) { + case 932: + // Shift_jis + return ((uch >= 0x81) && (uch <= 0x9F)) || + ((uch >= 0xE0) && (uch <= 0xFC)); + // Lead bytes F0 to FC may be a Microsoft addition. + case 936: + // GBK + return (uch >= 0x81) && (uch <= 0xFE); + case 949: + // Korean Wansung KS C-5601-1987 + return (uch >= 0x81) && (uch <= 0xFE); + case 950: + // Big5 + return (uch >= 0x81) && (uch <= 0xFE); + case 1361: + // Korean Johab KS C-5601-1992 + return + ((uch >= 0x84) && (uch <= 0xD3)) || + ((uch >= 0xD8) && (uch <= 0xDE)) || + ((uch >= 0xE0) && (uch <= 0xF9)); + } + return false; +} + +} diff --git a/dep/scintilla/scintilla-3.10.6/src/DBCS.h b/dep/scintilla/scintilla-3.10.6/src/DBCS.h new file mode 100644 index 00000000..58659ee3 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/DBCS.h @@ -0,0 +1,25 @@ +// Scintilla source code edit control +/** @file DBCS.h + ** Functions to handle DBCS double byte encodings like Shift-JIS. + **/ +// Copyright 2017 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef DBCS_H +#define DBCS_H + +namespace Scintilla { + +constexpr bool IsDBCSCodePage(int codePage) noexcept { + return codePage == 932 + || codePage == 936 + || codePage == 949 + || codePage == 950 + || codePage == 1361; +} + +bool DBCSIsLeadByte(int codePage, char ch) noexcept; + +} + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/src/Decoration.cxx b/dep/scintilla/scintilla-3.10.6/src/Decoration.cxx new file mode 100644 index 00000000..104f75ae --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/Decoration.cxx @@ -0,0 +1,316 @@ +/** @file Decoration.cxx + ** Visual elements added over text. + **/ +// Copyright 1998-2007 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "Platform.h" + +#include "Scintilla.h" +#include "Position.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h" +#include "Decoration.h" + +using namespace Scintilla; + +namespace { + +template +class Decoration : public IDecoration { + int indicator; +public: + RunStyles rs; + + explicit Decoration(int indicator_) : indicator(indicator_) { + } + ~Decoration() override { + } + + bool Empty() const override { + return (rs.Runs() == 1) && (rs.AllSameAs(0)); + } + int Indicator() const override { + return indicator; + } + Sci::Position Length() const override { + return rs.Length(); + } + int ValueAt(Sci::Position position) const override { + return rs.ValueAt(static_cast(position)); + } + Sci::Position StartRun(Sci::Position position) const override { + return rs.StartRun(static_cast(position)); + } + Sci::Position EndRun(Sci::Position position) const override { + return rs.EndRun(static_cast(position)); + } + void SetValueAt(Sci::Position position, int value) override { + rs.SetValueAt(static_cast(position), value); + } + void InsertSpace(Sci::Position position, Sci::Position insertLength) override { + rs.InsertSpace(static_cast(position), static_cast(insertLength)); + } + Sci::Position Runs() const override { + return rs.Runs(); + } +}; + +template +class DecorationList : public IDecorationList { + int currentIndicator; + int currentValue; + Decoration *current; // Cached so FillRange doesn't have to search for each call. + Sci::Position lengthDocument; + // Ordered by indicator + std::vector>> decorationList; + std::vector decorationView; // Read-only view of decorationList + bool clickNotified; + + Decoration *DecorationFromIndicator(int indicator); + Decoration *Create(int indicator, Sci::Position length); + void Delete(int indicator); + void DeleteAnyEmpty(); + void SetView(); +public: + + DecorationList(); + ~DecorationList() override; + + const std::vector &View() const override { + return decorationView; + } + + void SetCurrentIndicator(int indicator) override; + int GetCurrentIndicator() const override { return currentIndicator; } + + void SetCurrentValue(int value) override; + int GetCurrentValue() const override { return currentValue; } + + // Returns changed=true if some values may have changed + FillResult FillRange(Sci::Position position, int value, Sci::Position fillLength) override; + + void InsertSpace(Sci::Position position, Sci::Position insertLength) override; + void DeleteRange(Sci::Position position, Sci::Position deleteLength) override; + + void DeleteLexerDecorations() override; + + int AllOnFor(Sci::Position position) const override; + int ValueAt(int indicator, Sci::Position position) override; + Sci::Position Start(int indicator, Sci::Position position) override; + Sci::Position End(int indicator, Sci::Position position) override; + + bool ClickNotified() const override { + return clickNotified; + } + void SetClickNotified(bool notified) override { + clickNotified = notified; + } +}; + +template +DecorationList::DecorationList() : currentIndicator(0), currentValue(1), current(nullptr), + lengthDocument(0), clickNotified(false) { +} + +template +DecorationList::~DecorationList() { + current = nullptr; +} + +template +Decoration *DecorationList::DecorationFromIndicator(int indicator) { + for (const std::unique_ptr> &deco : decorationList) { + if (deco->Indicator() == indicator) { + return deco.get(); + } + } + return nullptr; +} + +template +Decoration *DecorationList::Create(int indicator, Sci::Position length) { + currentIndicator = indicator; + std::unique_ptr> decoNew = std::unique_ptr>(new Decoration(indicator)); + decoNew->rs.InsertSpace(0, static_cast(length)); + + typename std::vector>>::iterator it = std::lower_bound( + decorationList.begin(), decorationList.end(), decoNew, + [](const std::unique_ptr> &a, const std::unique_ptr> &b) { + return a->Indicator() < b->Indicator(); + }); + typename std::vector>>::iterator itAdded = + decorationList.insert(it, std::move(decoNew)); + + SetView(); + + return itAdded->get(); +} + +template +void DecorationList::Delete(int indicator) { + decorationList.erase(std::remove_if(decorationList.begin(), decorationList.end(), + [indicator](const std::unique_ptr> &deco) { + return deco->Indicator() == indicator; + }), decorationList.end()); + current = nullptr; + SetView(); +} + +template +void DecorationList::SetCurrentIndicator(int indicator) { + currentIndicator = indicator; + current = DecorationFromIndicator(indicator); + currentValue = 1; +} + +template +void DecorationList::SetCurrentValue(int value) { + currentValue = value ? value : 1; +} + +template +FillResult DecorationList::FillRange(Sci::Position position, int value, Sci::Position fillLength) { + if (!current) { + current = DecorationFromIndicator(currentIndicator); + if (!current) { + current = Create(currentIndicator, lengthDocument); + } + } + // Converting result from POS to Sci::Position as callers not polymorphic. + const FillResult frInPOS = current->rs.FillRange(static_cast(position), value, static_cast(fillLength)); + const FillResult fr { frInPOS.changed, frInPOS.position, frInPOS.fillLength }; + if (current->Empty()) { + Delete(currentIndicator); + } + return fr; +} + +template +void DecorationList::InsertSpace(Sci::Position position, Sci::Position insertLength) { + const bool atEnd = position == lengthDocument; + lengthDocument += insertLength; + for (const std::unique_ptr> &deco : decorationList) { + deco->rs.InsertSpace(static_cast(position), static_cast(insertLength)); + if (atEnd) { + deco->rs.FillRange(static_cast(position), 0, static_cast(insertLength)); + } + } +} + +template +void DecorationList::DeleteRange(Sci::Position position, Sci::Position deleteLength) { + lengthDocument -= deleteLength; + for (const std::unique_ptr> &deco : decorationList) { + deco->rs.DeleteRange(static_cast(position), static_cast(deleteLength)); + } + DeleteAnyEmpty(); + if (decorationList.size() != decorationView.size()) { + // One or more empty decorations deleted so update view. + current = nullptr; + SetView(); + } +} + +template +void DecorationList::DeleteLexerDecorations() { + decorationList.erase(std::remove_if(decorationList.begin(), decorationList.end(), + [](const std::unique_ptr> &deco) { + return deco->Indicator() < INDIC_CONTAINER; + }), decorationList.end()); + current = nullptr; + SetView(); +} + +template +void DecorationList::DeleteAnyEmpty() { + if (lengthDocument == 0) { + decorationList.clear(); + } else { + decorationList.erase(std::remove_if(decorationList.begin(), decorationList.end(), + [](const std::unique_ptr> &deco) { + return deco->Empty(); + }), decorationList.end()); + } +} + +template +void DecorationList::SetView() { + decorationView.clear(); + for (const std::unique_ptr> &deco : decorationList) { + decorationView.push_back(deco.get()); + } +} + +template +int DecorationList::AllOnFor(Sci::Position position) const { + int mask = 0; + for (const std::unique_ptr> &deco : decorationList) { + if (deco->rs.ValueAt(static_cast(position))) { + if (deco->Indicator() < INDIC_IME) { + mask |= 1 << deco->Indicator(); + } + } + } + return mask; +} + +template +int DecorationList::ValueAt(int indicator, Sci::Position position) { + const Decoration *deco = DecorationFromIndicator(indicator); + if (deco) { + return deco->rs.ValueAt(static_cast(position)); + } + return 0; +} + +template +Sci::Position DecorationList::Start(int indicator, Sci::Position position) { + const Decoration *deco = DecorationFromIndicator(indicator); + if (deco) { + return deco->rs.StartRun(static_cast(position)); + } + return 0; +} + +template +Sci::Position DecorationList::End(int indicator, Sci::Position position) { + const Decoration *deco = DecorationFromIndicator(indicator); + if (deco) { + return deco->rs.EndRun(static_cast(position)); + } + return 0; +} + +} + +namespace Scintilla { + +std::unique_ptr DecorationCreate(bool largeDocument, int indicator) { + if (largeDocument) + return std::unique_ptr>(new Decoration(indicator)); + else + return std::unique_ptr>(new Decoration(indicator)); +} + +std::unique_ptr DecorationListCreate(bool largeDocument) { + if (largeDocument) + return std::unique_ptr>(new DecorationList()); + else + return std::unique_ptr>(new DecorationList()); +} + +} + diff --git a/dep/scintilla/scintilla-3.10.6/src/Decoration.h b/dep/scintilla/scintilla-3.10.6/src/Decoration.h new file mode 100644 index 00000000..1461f2f9 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/Decoration.h @@ -0,0 +1,59 @@ +/** @file Decoration.h + ** Visual elements added over text. + **/ +// Copyright 1998-2007 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef DECORATION_H +#define DECORATION_H + +namespace Scintilla { + +class IDecoration { +public: + virtual ~IDecoration() {} + virtual bool Empty() const = 0; + virtual int Indicator() const = 0; + virtual Sci::Position Length() const = 0; + virtual int ValueAt(Sci::Position position) const = 0; + virtual Sci::Position StartRun(Sci::Position position) const = 0; + virtual Sci::Position EndRun(Sci::Position position) const = 0; + virtual void SetValueAt(Sci::Position position, int value) = 0; + virtual void InsertSpace(Sci::Position position, Sci::Position insertLength) = 0; + virtual Sci::Position Runs() const = 0; +}; + +class IDecorationList { +public: + virtual ~IDecorationList() {} + + virtual const std::vector &View() const =0; + + virtual void SetCurrentIndicator(int indicator) = 0; + virtual int GetCurrentIndicator() const = 0; + + virtual void SetCurrentValue(int value) = 0; + virtual int GetCurrentValue() const = 0; + + // Returns with changed=true if some values may have changed + virtual FillResult FillRange(Sci::Position position, int value, Sci::Position fillLength) = 0; + virtual void InsertSpace(Sci::Position position, Sci::Position insertLength) = 0; + virtual void DeleteRange(Sci::Position position, Sci::Position deleteLength) = 0; + virtual void DeleteLexerDecorations() = 0; + + virtual int AllOnFor(Sci::Position position) const = 0; + virtual int ValueAt(int indicator, Sci::Position position) = 0; + virtual Sci::Position Start(int indicator, Sci::Position position) = 0; + virtual Sci::Position End(int indicator, Sci::Position position) = 0; + + virtual bool ClickNotified() const = 0; + virtual void SetClickNotified(bool notified) = 0; +}; + +std::unique_ptr DecorationCreate(bool largeDocument, int indicator); + +std::unique_ptr DecorationListCreate(bool largeDocument); + +} + +#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/Document.cxx b/dep/scintilla/scintilla-3.10.6/src/Document.cxx similarity index 54% rename from dep/scintilla/scintilla-3.6.0/src/Document.cxx rename to dep/scintilla/scintilla-3.10.6/src/Document.cxx index 361f8d3e..1383c50c 100644 --- a/dep/scintilla/scintilla-3.6.0/src/Document.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/Document.cxx @@ -5,27 +5,33 @@ // Copyright 1998-2011 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include +#include +#include -#ifdef CXX11_REGEX +#ifndef NO_CXX11_REGEX #include #endif #include "Platform.h" +#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" #include "CharacterSet.h" +#include "CharacterCategory.h" #include "Position.h" #include "SplitVector.h" #include "Partitioning.h" @@ -38,27 +44,21 @@ #include "Document.h" #include "RESearch.h" #include "UniConversion.h" -#include "UnicodeFromUTF8.h" +#include "ElapsedPeriod.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif -static inline bool IsPunctuation(char ch) { - return IsASCII(ch) && ispunct(ch); -} - -void LexInterface::Colourise(int start, int end) { +void LexInterface::Colourise(Sci::Position start, Sci::Position end) { if (pdoc && instance && !performingStyle) { // Protect against reentrance, which may occur, for example, when // fold points are discovered while performing styling and the folding // code looks for child lines which may trigger styling. performingStyle = true; - int lengthDoc = pdoc->Length(); + const Sci::Position lengthDoc = pdoc->Length(); if (end == -1) end = lengthDoc; - int len = end - start; + const Sci::Position len = end - start; PLATFORM_ASSERT(len >= 0); PLATFORM_ASSERT(start + len <= lengthDoc); @@ -78,7 +78,7 @@ void LexInterface::Colourise(int start, int end) { int LexInterface::LineEndTypesSupported() { if (instance) { - int interfaceVersion = instance->Version(); + const int interfaceVersion = instance->Version(); if (interfaceVersion >= lvSubStyles) { ILexerWithSubStyles *ssinstance = static_cast(instance); return ssinstance->LineEndTypesSupported(); @@ -87,15 +87,38 @@ int LexInterface::LineEndTypesSupported() { return 0; } -Document::Document() { +ActionDuration::ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept : + duration(duration_), minDuration(minDuration_), maxDuration(maxDuration_) { +} + +void ActionDuration::AddSample(size_t numberActions, double durationOfActions) noexcept { + // Only adjust for multiple actions to avoid instability + if (numberActions < 8) + return; + + // Alpha value for exponential smoothing. + // Most recent value contributes 25% to smoothed value. + const double alpha = 0.25; + + const double durationOne = durationOfActions / numberActions; + duration = Sci::clamp(alpha * durationOne + (1.0 - alpha) * duration, + minDuration, maxDuration); +} + +double ActionDuration::Duration() const noexcept { + return duration; +} + +Document::Document(int options) : + cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0, (options & SC_DOCUMENTOPTION_TEXT_LARGE) != 0), + durationStyleOneLine(0.00001, 0.000001, 0.0001) { refCount = 0; - pcf = NULL; #ifdef _WIN32 eolMode = SC_EOL_CRLF; #else eolMode = SC_EOL_LF; #endif - dbcsCodePage = 0; + dbcsCodePage = SC_CP_UTF8; lineEndBitSet = SC_LINE_END_TYPE_DEFAULT; endStyled = 0; styleClock = 0; @@ -111,44 +134,80 @@ Document::Document() { backspaceUnindents = false; matchesValid = false; - regex = 0; - UTF8BytesOfLeadInitialise(); + perLineData[ldMarkers].reset(new LineMarkers()); + perLineData[ldLevels].reset(new LineLevels()); + perLineData[ldState].reset(new LineState()); + perLineData[ldMargin].reset(new LineAnnotation()); + perLineData[ldAnnotation].reset(new LineAnnotation()); - perLineData[ldMarkers] = new LineMarkers(); - perLineData[ldLevels] = new LineLevels(); - perLineData[ldState] = new LineState(); - perLineData[ldMargin] = new LineAnnotation(); - perLineData[ldAnnotation] = new LineAnnotation(); + decorations = DecorationListCreate(IsLarge()); cb.SetPerLine(this); - - pli = 0; + cb.SetUTF8Substance(SC_CP_UTF8 == dbcsCodePage); } Document::~Document() { - for (std::vector::iterator it = watchers.begin(); it != watchers.end(); ++it) { - it->watcher->NotifyDeleted(this, it->userData); + for (const WatcherWithUserData &watcher : watchers) { + watcher.watcher->NotifyDeleted(this, watcher.userData); } - for (int j=0; jInit(); + for (const std::unique_ptr &pl : perLineData) { + if (pl) + pl->Init(); } } +void Document::InsertLine(Sci::Line line) { + for (const std::unique_ptr &pl : perLineData) { + if (pl) + pl->InsertLine(line); + } +} + +void Document::RemoveLine(Sci::Line line) { + for (const std::unique_ptr &pl : perLineData) { + if (pl) + pl->RemoveLine(line); + } +} + +LineMarkers *Document::Markers() const { + return static_cast(perLineData[ldMarkers].get()); +} + +LineLevels *Document::Levels() const { + return static_cast(perLineData[ldLevels].get()); +} + +LineState *Document::States() const { + return static_cast(perLineData[ldState].get()); +} + +LineAnnotation *Document::Margins() const { + return static_cast(perLineData[ldMargin].get()); +} + +LineAnnotation *Document::Annotations() const { + return static_cast(perLineData[ldAnnotation].get()); +} + int Document::LineEndTypesSupported() const { if ((SC_CP_UTF8 == dbcsCodePage) && pli) return pli->LineEndTypesSupported(); @@ -159,8 +218,10 @@ int Document::LineEndTypesSupported() const { bool Document::SetDBCSCodePage(int dbcsCodePage_) { if (dbcsCodePage != dbcsCodePage_) { dbcsCodePage = dbcsCodePage_; - SetCaseFolder(NULL); + SetCaseFolder(nullptr); cb.SetLineEndTypes(lineEndBitSet & LineEndTypesSupported()); + cb.SetUTF8Substance(SC_CP_UTF8 == dbcsCodePage); + ModifiedAt(0); // Need to restyle whole document return true; } else { return false; @@ -170,7 +231,7 @@ bool Document::SetDBCSCodePage(int dbcsCodePage_) { bool Document::SetLineEndTypesAllowed(int lineEndBitSet_) { if (lineEndBitSet != lineEndBitSet_) { lineEndBitSet = lineEndBitSet_; - int lineEndBitSetActive = lineEndBitSet & LineEndTypesSupported(); + const int lineEndBitSetActive = lineEndBitSet & LineEndTypesSupported(); if (lineEndBitSetActive != cb.GetLineEndTypes()) { ModifiedAt(0); cb.SetLineEndTypes(lineEndBitSetActive); @@ -183,34 +244,6 @@ bool Document::SetLineEndTypesAllowed(int lineEndBitSet_) { } } -void Document::InsertLine(int line) { - for (int j=0; jInsertLine(line); - } -} - -void Document::RemoveLine(int line) { - for (int j=0; jRemoveLine(line); - } -} - -// Increase reference count and return its previous value. -int Document::AddRef() { - return refCount++; -} - -// Decrease reference count and return its previous value. -// Delete the document if reference count reaches zero. -int SCI_METHOD Document::Release() { - int curRefCount = --refCount; - if (curRefCount == 0) - delete this; - return curRefCount; -} - void Document::SetSavePoint() { cb.SetSavePoint(); NotifySavePoint(true); @@ -223,12 +256,12 @@ void Document::TentativeUndo() { if (enteredModification == 0) { enteredModification++; if (!cb.IsReadOnly()) { - bool startSavePoint = cb.IsSavePoint(); + const bool startSavePoint = cb.IsSavePoint(); bool multiLine = false; - int steps = cb.TentativeSteps(); + const int steps = cb.TentativeSteps(); //Platform::DebugPrintf("Steps=%d\n", steps); for (int step = 0; step < steps; step++) { - const int prevLinesTotal = LinesTotal(); + const Sci::Line prevLinesTotal = LinesTotal(); const Action &action = cb.GetUndoStep(); if (action.at == removeAction) { NotifyModified(DocModification( @@ -255,7 +288,7 @@ void Document::TentativeUndo() { } if (steps > 1) modFlags |= SC_MULTISTEPUNDOREDO; - const int linesAdded = LinesTotal() - prevLinesTotal; + const Sci::Line linesAdded = LinesTotal() - prevLinesTotal; if (linesAdded != 0) multiLine = true; if (step == steps - 1) { @@ -264,87 +297,86 @@ void Document::TentativeUndo() { modFlags |= SC_MULTILINEUNDOREDO; } NotifyModified(DocModification(modFlags, action.position, action.lenData, - linesAdded, action.data)); + linesAdded, action.data.get())); } - bool endSavePoint = cb.IsSavePoint(); + const bool endSavePoint = cb.IsSavePoint(); if (startSavePoint != endSavePoint) NotifySavePoint(endSavePoint); - + cb.TentativeCommit(); } enteredModification--; } } -int Document::GetMark(int line) { - return static_cast(perLineData[ldMarkers])->MarkValue(line); +int Document::GetMark(Sci::Line line) const { + return Markers()->MarkValue(line); } -int Document::MarkerNext(int lineStart, int mask) const { - return static_cast(perLineData[ldMarkers])->MarkerNext(lineStart, mask); +Sci::Line Document::MarkerNext(Sci::Line lineStart, int mask) const { + return Markers()->MarkerNext(lineStart, mask); } -int Document::AddMark(int line, int markerNum) { +int Document::AddMark(Sci::Line line, int markerNum) { if (line >= 0 && line <= LinesTotal()) { - int prev = static_cast(perLineData[ldMarkers])-> - AddMark(line, markerNum, LinesTotal()); - DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); + const int prev = Markers()->AddMark(line, markerNum, LinesTotal()); + const DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, nullptr, line); NotifyModified(mh); return prev; } else { - return 0; + return -1; } } -void Document::AddMarkSet(int line, int valueSet) { +void Document::AddMarkSet(Sci::Line line, int valueSet) { if (line < 0 || line > LinesTotal()) { return; } unsigned int m = valueSet; - for (int i = 0; m; i++, m >>= 1) + for (int i = 0; m; i++, m >>= 1) { if (m & 1) - static_cast(perLineData[ldMarkers])-> - AddMark(line, i, LinesTotal()); - DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); + Markers()->AddMark(line, i, LinesTotal()); + } + const DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, nullptr, line); NotifyModified(mh); } -void Document::DeleteMark(int line, int markerNum) { - static_cast(perLineData[ldMarkers])->DeleteMark(line, markerNum, false); - DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); +void Document::DeleteMark(Sci::Line line, int markerNum) { + Markers()->DeleteMark(line, markerNum, false); + const DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, nullptr, line); NotifyModified(mh); } void Document::DeleteMarkFromHandle(int markerHandle) { - static_cast(perLineData[ldMarkers])->DeleteMarkFromHandle(markerHandle); - DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); + Markers()->DeleteMarkFromHandle(markerHandle); + DocModification mh(SC_MOD_CHANGEMARKER); mh.line = -1; NotifyModified(mh); } void Document::DeleteAllMarks(int markerNum) { bool someChanges = false; - for (int line = 0; line < LinesTotal(); line++) { - if (static_cast(perLineData[ldMarkers])->DeleteMark(line, markerNum, true)) + for (Sci::Line line = 0; line < LinesTotal(); line++) { + if (Markers()->DeleteMark(line, markerNum, true)) someChanges = true; } if (someChanges) { - DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); + DocModification mh(SC_MOD_CHANGEMARKER); mh.line = -1; NotifyModified(mh); } } -int Document::LineFromHandle(int markerHandle) { - return static_cast(perLineData[ldMarkers])->LineFromHandle(markerHandle); +Sci::Line Document::LineFromHandle(int markerHandle) const { + return Markers()->LineFromHandle(markerHandle); } Sci_Position SCI_METHOD Document::LineStart(Sci_Position line) const { - return cb.LineStart(line); + return cb.LineStart(static_cast(line)); } -bool Document::IsLineStartPosition(int position) const { +bool Document::IsLineStartPosition(Sci::Position position) const { return LineStart(LineFromPosition(position)) == position; } @@ -352,12 +384,12 @@ Sci_Position SCI_METHOD Document::LineEnd(Sci_Position line) const { if (line >= LinesTotal() - 1) { return LineStart(line + 1); } else { - int position = LineStart(line + 1); + Sci::Position position = LineStart(line + 1); if (SC_CP_UTF8 == dbcsCodePage) { - unsigned char bytes[] = { - static_cast(cb.CharAt(position-3)), - static_cast(cb.CharAt(position-2)), - static_cast(cb.CharAt(position-1)), + const unsigned char bytes[] = { + cb.UCharAt(position-3), + cb.UCharAt(position-2), + cb.UCharAt(position-1), }; if (UTF8IsSeparator(bytes)) { return position - UTF8SeparatorLength; @@ -377,8 +409,8 @@ Sci_Position SCI_METHOD Document::LineEnd(Sci_Position line) const { void SCI_METHOD Document::SetErrorStatus(int status) { // Tell the watchers an error has occurred. - for (std::vector::iterator it = watchers.begin(); it != watchers.end(); ++it) { - it->watcher->NotifyErrorOccurred(this, it->userData, status); + for (const WatcherWithUserData &watcher : watchers) { + watcher.watcher->NotifyErrorOccurred(this, watcher.userData, status); } } @@ -386,23 +418,28 @@ Sci_Position SCI_METHOD Document::LineFromPosition(Sci_Position pos) const { return cb.LineFromPosition(pos); } -int Document::LineEndPosition(int position) const { +Sci::Line Document::SciLineFromPosition(Sci::Position pos) const noexcept { + // Avoids casting in callers for this very common function + return cb.LineFromPosition(pos); +} + +Sci::Position Document::LineEndPosition(Sci::Position position) const { return LineEnd(LineFromPosition(position)); } -bool Document::IsLineEndPosition(int position) const { +bool Document::IsLineEndPosition(Sci::Position position) const { return LineEnd(LineFromPosition(position)) == position; } -bool Document::IsPositionInLineEnd(int position) const { +bool Document::IsPositionInLineEnd(Sci::Position position) const { return position >= LineEnd(LineFromPosition(position)); } -int Document::VCHomePosition(int position) const { - int line = LineFromPosition(position); - int startPosition = LineStart(line); - int endLine = LineEnd(line); - int startText = startPosition; +Sci::Position Document::VCHomePosition(Sci::Position position) const { + const Sci::Line line = SciLineFromPosition(position); + const Sci::Position startPosition = LineStart(line); + const Sci::Position endLine = LineEnd(line); + Sci::Position startText = startPosition; while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t')) startText++; if (position == startText) @@ -411,11 +448,19 @@ int Document::VCHomePosition(int position) const { return startText; } +Sci::Position Document::IndexLineStart(Sci::Line line, int lineCharacterIndex) const { + return cb.IndexLineStart(line, lineCharacterIndex); +} + +Sci::Line Document::LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const { + return cb.LineFromPositionIndex(pos, lineCharacterIndex); +} + int SCI_METHOD Document::SetLevel(Sci_Position line, int level) { - int prev = static_cast(perLineData[ldLevels])->SetLevel(line, level, LinesTotal()); + const int prev = Levels()->SetLevel(static_cast(line), level, LinesTotal()); if (prev != level) { DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER, - LineStart(line), 0, 0, 0, line); + LineStart(line), 0, 0, nullptr, static_cast(line)); mh.foldLevelNow = level; mh.foldLevelPrev = prev; NotifyModified(mh); @@ -424,26 +469,26 @@ int SCI_METHOD Document::SetLevel(Sci_Position line, int level) { } int SCI_METHOD Document::GetLevel(Sci_Position line) const { - return static_cast(perLineData[ldLevels])->GetLevel(line); + return Levels()->GetLevel(static_cast(line)); } void Document::ClearLevels() { - static_cast(perLineData[ldLevels])->ClearLevels(); + Levels()->ClearLevels(); } -static bool IsSubordinate(int levelStart, int levelTry) { +static bool IsSubordinate(int levelStart, int levelTry) noexcept { if (levelTry & SC_FOLDLEVELWHITEFLAG) return true; else - return (levelStart & SC_FOLDLEVELNUMBERMASK) < (levelTry & SC_FOLDLEVELNUMBERMASK); + return LevelNumber(levelStart) < LevelNumber(levelTry); } -int Document::GetLastChild(int lineParent, int level, int lastLine) { +Sci::Line Document::GetLastChild(Sci::Line lineParent, int level, Sci::Line lastLine) { if (level == -1) - level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK; - int maxLine = LinesTotal(); - int lookLastLine = (lastLine != -1) ? Platform::Minimum(LinesTotal() - 1, lastLine) : -1; - int lineMaxSubord = lineParent; + level = LevelNumber(GetLevel(lineParent)); + const Sci::Line maxLine = LinesTotal(); + const Sci::Line lookLastLine = (lastLine != -1) ? std::min(LinesTotal() - 1, lastLine) : -1; + Sci::Line lineMaxSubord = lineParent; while (lineMaxSubord < maxLine - 1) { EnsureStyledTo(LineStart(lineMaxSubord + 2)); if (!IsSubordinate(level, GetLevel(lineMaxSubord + 1))) @@ -453,7 +498,7 @@ int Document::GetLastChild(int lineParent, int level, int lastLine) { lineMaxSubord++; } if (lineMaxSubord > lineParent) { - if (level > (GetLevel(lineMaxSubord + 1) & SC_FOLDLEVELNUMBERMASK)) { + if (level > LevelNumber(GetLevel(lineMaxSubord + 1))) { // Have chewed up some whitespace that belongs to a parent so seek back if (GetLevel(lineMaxSubord) & SC_FOLDLEVELWHITEFLAG) { lineMaxSubord--; @@ -463,48 +508,48 @@ int Document::GetLastChild(int lineParent, int level, int lastLine) { return lineMaxSubord; } -int Document::GetFoldParent(int line) const { - int level = GetLevel(line) & SC_FOLDLEVELNUMBERMASK; - int lineLook = line - 1; +Sci::Line Document::GetFoldParent(Sci::Line line) const { + const int level = LevelNumber(GetLevel(line)); + Sci::Line lineLook = line - 1; while ((lineLook > 0) && ( (!(GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG)) || - ((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) >= level)) + (LevelNumber(GetLevel(lineLook)) >= level)) ) { lineLook--; } if ((GetLevel(lineLook) & SC_FOLDLEVELHEADERFLAG) && - ((GetLevel(lineLook) & SC_FOLDLEVELNUMBERMASK) < level)) { + (LevelNumber(GetLevel(lineLook)) < level)) { return lineLook; } else { return -1; } } -void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, int line, int lastLine) { - int level = GetLevel(line); - int lookLastLine = Platform::Maximum(line, lastLine) + 1; +void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine) { + const int level = GetLevel(line); + const Sci::Line lookLastLine = std::max(line, lastLine) + 1; - int lookLine = line; + Sci::Line lookLine = line; int lookLineLevel = level; - int lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK; + int lookLineLevelNum = LevelNumber(lookLineLevel); while ((lookLine > 0) && ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) || - ((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum >= (GetLevel(lookLine + 1) & SC_FOLDLEVELNUMBERMASK))))) { + ((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum >= LevelNumber(GetLevel(lookLine + 1)))))) { lookLineLevel = GetLevel(--lookLine); - lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK; + lookLineLevelNum = LevelNumber(lookLineLevel); } - int beginFoldBlock = (lookLineLevel & SC_FOLDLEVELHEADERFLAG) ? lookLine : GetFoldParent(lookLine); + Sci::Line beginFoldBlock = (lookLineLevel & SC_FOLDLEVELHEADERFLAG) ? lookLine : GetFoldParent(lookLine); if (beginFoldBlock == -1) { highlightDelimiter.Clear(); return; } - int endFoldBlock = GetLastChild(beginFoldBlock, -1, lookLastLine); - int firstChangeableLineBefore = -1; + Sci::Line endFoldBlock = GetLastChild(beginFoldBlock, -1, lookLastLine); + Sci::Line firstChangeableLineBefore = -1; if (endFoldBlock < line) { lookLine = beginFoldBlock - 1; lookLineLevel = GetLevel(lookLine); - lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK; + lookLineLevelNum = LevelNumber(lookLineLevel); while ((lookLine >= 0) && (lookLineLevelNum >= SC_FOLDLEVELBASE)) { if (lookLineLevel & SC_FOLDLEVELHEADERFLAG) { if (GetLastChild(lookLine, -1, lookLastLine) == line) { @@ -513,17 +558,17 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in firstChangeableLineBefore = line - 1; } } - if ((lookLine > 0) && (lookLineLevelNum == SC_FOLDLEVELBASE) && ((GetLevel(lookLine - 1) & SC_FOLDLEVELNUMBERMASK) > lookLineLevelNum)) + if ((lookLine > 0) && (lookLineLevelNum == SC_FOLDLEVELBASE) && (LevelNumber(GetLevel(lookLine - 1)) > lookLineLevelNum)) break; lookLineLevel = GetLevel(--lookLine); - lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK; + lookLineLevelNum = LevelNumber(lookLineLevel); } } if (firstChangeableLineBefore == -1) { - for (lookLine = line - 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK; + for (lookLine = line - 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = LevelNumber(lookLineLevel); lookLine >= beginFoldBlock; - lookLineLevel = GetLevel(--lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK) { - if ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) || (lookLineLevelNum > (level & SC_FOLDLEVELNUMBERMASK))) { + lookLineLevel = GetLevel(--lookLine), lookLineLevelNum = LevelNumber(lookLineLevel)) { + if ((lookLineLevel & SC_FOLDLEVELWHITEFLAG) || (lookLineLevelNum > LevelNumber(level))) { firstChangeableLineBefore = lookLine; break; } @@ -532,11 +577,11 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in if (firstChangeableLineBefore == -1) firstChangeableLineBefore = beginFoldBlock - 1; - int firstChangeableLineAfter = -1; - for (lookLine = line + 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK; + Sci::Line firstChangeableLineAfter = -1; + for (lookLine = line + 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = LevelNumber(lookLineLevel); lookLine <= endFoldBlock; - lookLineLevel = GetLevel(++lookLine), lookLineLevelNum = lookLineLevel & SC_FOLDLEVELNUMBERMASK) { - if ((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum < (GetLevel(lookLine + 1) & SC_FOLDLEVELNUMBERMASK))) { + lookLineLevel = GetLevel(++lookLine), lookLineLevelNum = LevelNumber(lookLineLevel)) { + if ((lookLineLevel & SC_FOLDLEVELHEADERFLAG) && (lookLineLevelNum < LevelNumber(GetLevel(lookLine + 1)))) { firstChangeableLineAfter = lookLine; break; } @@ -550,11 +595,11 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, in highlightDelimiter.firstChangeableLineAfter = firstChangeableLineAfter; } -int Document::ClampPositionIntoDocument(int pos) const { - return Platform::Clamp(pos, 0, Length()); +Sci::Position Document::ClampPositionIntoDocument(Sci::Position pos) const { + return Sci::clamp(pos, static_cast(0), static_cast(Length())); } -bool Document::IsCrLf(int pos) const { +bool Document::IsCrLf(Sci::Position pos) const { if (pos < 0) return false; if (pos >= (Length() - 1)) @@ -562,46 +607,46 @@ bool Document::IsCrLf(int pos) const { return (cb.CharAt(pos) == '\r') && (cb.CharAt(pos + 1) == '\n'); } -int Document::LenChar(int pos) { +int Document::LenChar(Sci::Position pos) { if (pos < 0) { return 1; } else if (IsCrLf(pos)) { return 2; } else if (SC_CP_UTF8 == dbcsCodePage) { - const unsigned char leadByte = static_cast(cb.CharAt(pos)); + const unsigned char leadByte = cb.UCharAt(pos); const int widthCharBytes = UTF8BytesOfLead[leadByte]; - int lengthDoc = Length(); + const Sci::Position lengthDoc = Length(); if ((pos + widthCharBytes) > lengthDoc) - return lengthDoc - pos; + return static_cast(lengthDoc - pos); else return widthCharBytes; } else if (dbcsCodePage) { - return IsDBCSLeadByte(cb.CharAt(pos)) ? 2 : 1; + return IsDBCSLeadByteNoExcept(cb.CharAt(pos)) ? 2 : 1; } else { return 1; } } -bool Document::InGoodUTF8(int pos, int &start, int &end) const { - int trail = pos; - while ((trail>0) && (pos-trail < UTF8MaxBytes) && UTF8IsTrailByte(static_cast(cb.CharAt(trail-1)))) +bool Document::InGoodUTF8(Sci::Position pos, Sci::Position &start, Sci::Position &end) const noexcept { + Sci::Position trail = pos; + while ((trail>0) && (pos-trail < UTF8MaxBytes) && UTF8IsTrailByte(cb.UCharAt(trail-1))) trail--; start = (trail > 0) ? trail-1 : trail; - const unsigned char leadByte = static_cast(cb.CharAt(start)); + const unsigned char leadByte = cb.UCharAt(start); const int widthCharBytes = UTF8BytesOfLead[leadByte]; if (widthCharBytes == 1) { return false; } else { - int trailBytes = widthCharBytes - 1; - int len = pos - start; + const int trailBytes = widthCharBytes - 1; + const Sci::Position len = pos - start; if (len > trailBytes) // pos too far from lead return false; - char charBytes[UTF8MaxBytes] = {static_cast(leadByte),0,0,0}; - for (int b=1; b(start+b)); - int utf8status = UTF8Classify(reinterpret_cast(charBytes), widthCharBytes); + unsigned char charBytes[UTF8MaxBytes] = {leadByte,0,0,0}; + for (Sci::Position b=1; b(cb.CharAt(pos)); + const unsigned char ch = cb.UCharAt(pos); // If ch is not a trail byte then pos is valid intercharacter position if (UTF8IsTrailByte(ch)) { - int startUTF = pos; - int endUTF = pos; + Sci::Position startUTF = pos; + Sci::Position endUTF = pos; if (InGoodUTF8(pos, startUTF, endUTF)) { // ch is a trail byte within a UTF-8 character if (moveDir > 0) @@ -649,18 +694,18 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) c } else { // Anchor DBCS calculations at start of line because start of line can // not be a DBCS trail byte. - int posStartLine = LineStart(LineFromPosition(pos)); + const Sci::Position posStartLine = LineStart(LineFromPosition(pos)); if (pos == posStartLine) return pos; // Step back until a non-lead-byte is found. - int posCheck = pos; - while ((posCheck > posStartLine) && IsDBCSLeadByte(cb.CharAt(posCheck-1))) + Sci::Position posCheck = pos; + while ((posCheck > posStartLine) && IsDBCSLeadByteNoExcept(cb.CharAt(posCheck-1))) posCheck--; // Check from known start of character. while (posCheck < pos) { - int mbsize = IsDBCSLeadByte(cb.CharAt(posCheck)) ? 2 : 1; + const int mbsize = IsDBCSLeadByteNoExcept(cb.CharAt(posCheck)) ? 2 : 1; if (posCheck + mbsize == pos) { return pos; } else if (posCheck + mbsize > pos) { @@ -681,28 +726,28 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) c // NextPosition moves between valid positions - it can not handle a position in the middle of a // multi-byte character. It is used to iterate through text more efficiently than MovePositionOutsideChar. // A \r\n pair is treated as two characters. -int Document::NextPosition(int pos, int moveDir) const { +Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const noexcept { // If out of range, just return minimum/maximum value. - int increment = (moveDir > 0) ? 1 : -1; + const int increment = (moveDir > 0) ? 1 : -1; if (pos + increment <= 0) return 0; - if (pos + increment >= Length()) - return Length(); + if (pos + increment >= cb.Length()) + return cb.Length(); if (dbcsCodePage) { if (SC_CP_UTF8 == dbcsCodePage) { if (increment == 1) { // Simple forward movement case so can avoid some checks - const unsigned char leadByte = static_cast(cb.CharAt(pos)); + const unsigned char leadByte = cb.UCharAt(pos); if (UTF8IsAscii(leadByte)) { // Single byte character or invalid pos++; } else { const int widthCharBytes = UTF8BytesOfLead[leadByte]; - char charBytes[UTF8MaxBytes] = {static_cast(leadByte),0,0,0}; + unsigned char charBytes[UTF8MaxBytes] = {leadByte,0,0,0}; for (int b=1; b(pos+b)); - int utf8status = UTF8Classify(reinterpret_cast(charBytes), widthCharBytes); + charBytes[b] = cb.CharAt(pos+b); + const int utf8status = UTF8Classify(charBytes, widthCharBytes); if (utf8status & UTF8MaskInvalid) pos++; else @@ -711,12 +756,12 @@ int Document::NextPosition(int pos, int moveDir) const { } else { // Examine byte before position pos--; - unsigned char ch = static_cast(cb.CharAt(pos)); + const unsigned char ch = cb.UCharAt(pos); // If ch is not a trail byte then pos is valid intercharacter position if (UTF8IsTrailByte(ch)) { // If ch is a trail byte in a valid UTF-8 character then return start of character - int startUTF = pos; - int endUTF = pos; + Sci::Position startUTF = pos; + Sci::Position endUTF = pos; if (InGoodUTF8(pos, startUTF, endUTF)) { pos = startUTF; } @@ -725,25 +770,25 @@ int Document::NextPosition(int pos, int moveDir) const { } } else { if (moveDir > 0) { - int mbsize = IsDBCSLeadByte(cb.CharAt(pos)) ? 2 : 1; + const int mbsize = IsDBCSLeadByteNoExcept(cb.CharAt(pos)) ? 2 : 1; pos += mbsize; - if (pos > Length()) - pos = Length(); + if (pos > cb.Length()) + pos = cb.Length(); } else { // Anchor DBCS calculations at start of line because start of line can // not be a DBCS trail byte. - int posStartLine = LineStart(LineFromPosition(pos)); + const Sci::Position posStartLine = cb.LineStart(cb.LineFromPosition(pos)); // See http://msdn.microsoft.com/en-us/library/cc194792%28v=MSDN.10%29.aspx // http://msdn.microsoft.com/en-us/library/cc194790.aspx if ((pos - 1) <= posStartLine) { return pos - 1; - } else if (IsDBCSLeadByte(cb.CharAt(pos - 1))) { + } else if (IsDBCSLeadByteNoExcept(cb.CharAt(pos - 1))) { // Must actually be trail byte return pos - 2; } else { // Otherwise, step back until a non-lead-byte is found. - int posTemp = pos - 1; - while (posStartLine <= --posTemp && IsDBCSLeadByte(cb.CharAt(posTemp))) + Sci::Position posTemp = pos - 1; + while (posStartLine <= --posTemp && IsDBCSLeadByteNoExcept(cb.CharAt(posTemp))) ; // Now posTemp+1 must point to the beginning of a character, // so figure out whether we went back an even or an odd @@ -759,9 +804,9 @@ int Document::NextPosition(int pos, int moveDir) const { return pos; } -bool Document::NextCharacter(int &pos, int moveDir) const { +bool Document::NextCharacter(Sci::Position &pos, int moveDir) const noexcept { // Returns true if pos changed - int posNext = NextPosition(pos, moveDir); + Sci::Position posNext = NextPosition(pos, moveDir); if (posNext == pos) { return false; } else { @@ -770,13 +815,84 @@ bool Document::NextCharacter(int &pos, int moveDir) const { } } +Document::CharacterExtracted Document::CharacterAfter(Sci::Position position) const { + if (position >= Length()) { + return CharacterExtracted(unicodeReplacementChar, 0); + } + const unsigned char leadByte = cb.UCharAt(position); + if (!dbcsCodePage || UTF8IsAscii(leadByte)) { + // Common case: ASCII character + return CharacterExtracted(leadByte, 1); + } + if (SC_CP_UTF8 == dbcsCodePage) { + const int widthCharBytes = UTF8BytesOfLead[leadByte]; + unsigned char charBytes[UTF8MaxBytes] = { leadByte, 0, 0, 0 }; + for (int b = 1; b(endUTF - startUTF); + unsigned char charBytes[UTF8MaxBytes] = { 0, 0, 0, 0 }; + for (int b = 0; b 0) ? 1 : -1; while (characterOffset != 0) { - const int posNext = NextPosition(pos, increment); + const Sci::Position posNext = NextPosition(pos, increment); if (posNext == pos) return INVALID_POSITION; pos = posNext; @@ -790,15 +906,15 @@ Sci_Position SCI_METHOD Document::GetRelativePosition(Sci_Position positionStart return pos; } -int Document::GetRelativePositionUTF16(int positionStart, int characterOffset) const { - int pos = positionStart; +Sci::Position Document::GetRelativePositionUTF16(Sci::Position positionStart, Sci::Position characterOffset) const { + Sci::Position pos = positionStart; if (dbcsCodePage) { const int increment = (characterOffset > 0) ? 1 : -1; while (characterOffset != 0) { - const int posNext = NextPosition(pos, increment); + const Sci::Position posNext = NextPosition(pos, increment); if (posNext == pos) return INVALID_POSITION; - if (abs(pos-posNext) > 3) // 4 byte character = 2*UTF16. + if (std::abs(pos-posNext) > 3) // 4 byte character = 2*UTF16. characterOffset -= increment; pos = posNext; characterOffset -= increment; @@ -814,8 +930,8 @@ int Document::GetRelativePositionUTF16(int positionStart, int characterOffset) c int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const { int character; int bytesInCharacter = 1; + const unsigned char leadByte = cb.UCharAt(position); if (dbcsCodePage) { - const unsigned char leadByte = static_cast(cb.CharAt(position)); if (SC_CP_UTF8 == dbcsCodePage) { if (UTF8IsAscii(leadByte)) { // Single byte character or invalid @@ -824,8 +940,8 @@ int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Positio const int widthCharBytes = UTF8BytesOfLead[leadByte]; unsigned char charBytes[UTF8MaxBytes] = {leadByte,0,0,0}; for (int b=1; b(cb.CharAt(position+b)); - int utf8status = UTF8Classify(charBytes, widthCharBytes); + charBytes[b] = cb.UCharAt(position+b); + const int utf8status = UTF8Classify(charBytes, widthCharBytes); if (utf8status & UTF8MaskInvalid) { // Report as singleton surrogate values which are invalid Unicode character = 0xDC80 + leadByte; @@ -835,15 +951,15 @@ int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Positio } } } else { - if (IsDBCSLeadByte(leadByte)) { + if (IsDBCSLeadByteNoExcept(leadByte)) { bytesInCharacter = 2; - character = (leadByte << 8) | static_cast(cb.CharAt(position+1)); + character = (leadByte << 8) | cb.UCharAt(position+1); } else { character = leadByte; } } } else { - character = cb.CharAt(position); + character = leadByte; } if (pWidth) { *pWidth = bytesInCharacter; @@ -856,8 +972,14 @@ int SCI_METHOD Document::CodePage() const { } bool SCI_METHOD Document::IsDBCSLeadByte(char ch) const { + // Used by lexers so must match IDocument method exactly + return IsDBCSLeadByteNoExcept(ch); +} + +bool Document::IsDBCSLeadByteNoExcept(char ch) const noexcept { + // Used inside core Scintilla // Byte ranges found in Wikipedia articles with relevant search strings in each case - unsigned char uch = static_cast(ch); + const unsigned char uch = ch; switch (dbcsCodePage) { case 932: // Shift_jis @@ -883,7 +1005,94 @@ bool SCI_METHOD Document::IsDBCSLeadByte(char ch) const { return false; } -static inline bool IsSpaceOrTab(int ch) { +bool Document::IsDBCSLeadByteInvalid(char ch) const noexcept { + const unsigned char lead = ch; + switch (dbcsCodePage) { + case 932: + // Shift_jis + return + (lead == 0x85) || + (lead == 0x86) || + (lead == 0xEB) || + (lead == 0xEC) || + (lead == 0xEF) || + (lead == 0xFA) || + (lead == 0xFB) || + (lead == 0xFC); + case 936: + // GBK + return (lead == 0x80) || (lead == 0xFF); + case 949: + // Korean Wansung KS C-5601-1987 + return (lead == 0x80) || (lead == 0xC9) || (lead >= 0xFE); + case 950: + // Big5 + return + ((lead >= 0x80) && (lead <= 0xA0)) || + (lead == 0xC8) || + (lead >= 0xFA); + case 1361: + // Korean Johab KS C-5601-1992 + return + ((lead >= 0x80) && (lead <= 0x83)) || + ((lead >= 0xD4) && (lead <= 0xD8)) || + (lead == 0xDF) || + (lead >= 0xFA); + } + return false; +} + +bool Document::IsDBCSTrailByteInvalid(char ch) const noexcept { + const unsigned char trail = ch; + switch (dbcsCodePage) { + case 932: + // Shift_jis + return + (trail <= 0x3F) || + (trail == 0x7F) || + (trail >= 0xFD); + case 936: + // GBK + return + (trail <= 0x3F) || + (trail == 0x7F) || + (trail == 0xFF); + case 949: + // Korean Wansung KS C-5601-1987 + return + (trail <= 0x40) || + ((trail >= 0x5B) && (trail <= 0x60)) || + ((trail >= 0x7B) && (trail <= 0x80)) || + (trail == 0xFF); + case 950: + // Big5 + return + (trail <= 0x3F) || + ((trail >= 0x7F) && (trail <= 0xA0)) || + (trail == 0xFF); + case 1361: + // Korean Johab KS C-5601-1992 + return + (trail <= 0x30) || + (trail == 0x7F) || + (trail == 0x80) || + (trail == 0xFF); + } + return false; +} + +int Document::DBCSDrawBytes(const char *text, int len) const noexcept { + if (len <= 1) { + return len; + } + if (IsDBCSLeadByteNoExcept(text[0])) { + return IsDBCSTrailByteInvalid(text[1]) ? 1 : 2; + } else { + return 1; + } +} + +static constexpr bool IsSpaceOrTab(int ch) noexcept { return ch == ' ' || ch == '\t'; } @@ -898,14 +1107,14 @@ static inline bool IsSpaceOrTab(int ch) { // 2) Break before punctuation // 3) Break after whole character -int Document::SafeSegment(const char *text, int length, int lengthSegment) const { +int Document::SafeSegment(const char *text, int length, int lengthSegment) const noexcept { if (length <= lengthSegment) return length; int lastSpaceBreak = -1; int lastPunctuationBreak = -1; int lastEncodingAllowedBreak = 0; for (int j=0; j < lengthSegment;) { - unsigned char ch = static_cast(text[j]); + const unsigned char ch = text[j]; if (j > 0) { if (IsSpaceOrTab(text[j - 1]) && !IsSpaceOrTab(text[j])) { lastSpaceBreak = j; @@ -919,7 +1128,7 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const if (dbcsCodePage == SC_CP_UTF8) { j += UTF8BytesOfLead[ch]; } else if (dbcsCodePage) { - j += IsDBCSLeadByte(ch) ? 2 : 1; + j += IsDBCSLeadByteNoExcept(ch) ? 2 : 1; } else { j++; } @@ -932,7 +1141,7 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const return lastEncodingAllowedBreak; } -EncodingFamily Document::CodePageFamily() const { +EncodingFamily Document::CodePageFamily() const noexcept { if (SC_CP_UTF8 == dbcsCodePage) return efUnicode; else if (dbcsCodePage) @@ -941,7 +1150,7 @@ EncodingFamily Document::CodePageFamily() const { return efEightBit; } -void Document::ModifiedAt(int pos) { +void Document::ModifiedAt(Sci::Position pos) noexcept { if (endStyled > pos) endStyled = pos; } @@ -957,7 +1166,7 @@ void Document::CheckReadOnly() { // Document only modified by gateways DeleteChars, InsertString, Undo, Redo, and SetStyleAt. // SetStyleAt does not change the persistent state of a document -bool Document::DeleteChars(int pos, int len) { +bool Document::DeleteChars(Sci::Position pos, Sci::Position len) { if (pos < 0) return false; if (len <= 0) @@ -975,8 +1184,8 @@ bool Document::DeleteChars(int pos, int len) { SC_MOD_BEFOREDELETE | SC_PERFORMED_USER, pos, len, 0, 0)); - int prevLinesTotal = LinesTotal(); - bool startSavePoint = cb.IsSavePoint(); + const Sci::Line prevLinesTotal = LinesTotal(); + const bool startSavePoint = cb.IsSavePoint(); bool startSequence = false; const char *text = cb.DeleteChars(pos, len, startSequence); if (startSavePoint && cb.IsCollectingUndo()) @@ -999,7 +1208,7 @@ bool Document::DeleteChars(int pos, int len) { /** * Insert a string with a length. */ -int Document::InsertString(int position, const char *s, int insertLength) { +Sci::Position Document::InsertString(Sci::Position position, const char *s, Sci::Position insertLength) { if (insertLength <= 0) { return 0; } @@ -1020,15 +1229,15 @@ int Document::InsertString(int position, const char *s, int insertLength) { 0, s)); if (insertionSet) { s = insertion.c_str(); - insertLength = static_cast(insertion.length()); + insertLength = insertion.length(); } NotifyModified( DocModification( SC_MOD_BEFOREINSERT | SC_PERFORMED_USER, position, insertLength, 0, s)); - int prevLinesTotal = LinesTotal(); - bool startSavePoint = cb.IsSavePoint(); + const Sci::Line prevLinesTotal = LinesTotal(); + const bool startSavePoint = cb.IsSavePoint(); bool startSequence = false; const char *text = cb.InsertString(position, s, insertLength, startSequence); if (startSavePoint && cb.IsCollectingUndo()) @@ -1046,14 +1255,24 @@ int Document::InsertString(int position, const char *s, int insertLength) { return insertLength; } -void Document::ChangeInsertion(const char *s, int length) { +void Document::ChangeInsertion(const char *s, Sci::Position length) { insertionSet = true; insertion.assign(s, length); } -int SCI_METHOD Document::AddData(char *data, Sci_Position length) { - int position = Length(); - InsertString(position, data, length); +int SCI_METHOD Document::AddData(const char *data, Sci_Position length) { +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) + try { +#endif + const Sci::Position position = Length(); + InsertString(position, data, length); +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) + } catch (std::bad_alloc &) { + return SC_STATUS_BADALLOC; + } catch (...) { + return SC_STATUS_FAILURE; + } +#endif return 0; } @@ -1061,22 +1280,22 @@ void * SCI_METHOD Document::ConvertToDocument() { return this; } -int Document::Undo() { - int newPos = -1; +Sci::Position Document::Undo() { + Sci::Position newPos = -1; CheckReadOnly(); if ((enteredModification == 0) && (cb.IsCollectingUndo())) { enteredModification++; if (!cb.IsReadOnly()) { - bool startSavePoint = cb.IsSavePoint(); + const bool startSavePoint = cb.IsSavePoint(); bool multiLine = false; - int steps = cb.StartUndo(); + const int steps = cb.StartUndo(); //Platform::DebugPrintf("Steps=%d\n", steps); - int coalescedRemovePos = -1; - int coalescedRemoveLen = 0; - int prevRemoveActionPos = -1; - int prevRemoveActionLen = 0; + Sci::Position coalescedRemovePos = -1; + Sci::Position coalescedRemoveLen = 0; + Sci::Position prevRemoveActionPos = -1; + Sci::Position prevRemoveActionLen = 0; for (int step = 0; step < steps; step++) { - const int prevLinesTotal = LinesTotal(); + const Sci::Line prevLinesTotal = LinesTotal(); const Action &action = cb.GetUndoStep(); if (action.at == removeAction) { NotifyModified(DocModification( @@ -1125,7 +1344,7 @@ int Document::Undo() { } if (steps > 1) modFlags |= SC_MULTISTEPUNDOREDO; - const int linesAdded = LinesTotal() - prevLinesTotal; + const Sci::Line linesAdded = LinesTotal() - prevLinesTotal; if (linesAdded != 0) multiLine = true; if (step == steps - 1) { @@ -1134,10 +1353,10 @@ int Document::Undo() { modFlags |= SC_MULTILINEUNDOREDO; } NotifyModified(DocModification(modFlags, action.position, action.lenData, - linesAdded, action.data)); + linesAdded, action.data.get())); } - bool endSavePoint = cb.IsSavePoint(); + const bool endSavePoint = cb.IsSavePoint(); if (startSavePoint != endSavePoint) NotifySavePoint(endSavePoint); } @@ -1146,17 +1365,17 @@ int Document::Undo() { return newPos; } -int Document::Redo() { - int newPos = -1; +Sci::Position Document::Redo() { + Sci::Position newPos = -1; CheckReadOnly(); if ((enteredModification == 0) && (cb.IsCollectingUndo())) { enteredModification++; if (!cb.IsReadOnly()) { - bool startSavePoint = cb.IsSavePoint(); + const bool startSavePoint = cb.IsSavePoint(); bool multiLine = false; - int steps = cb.StartRedo(); + const int steps = cb.StartRedo(); for (int step = 0; step < steps; step++) { - const int prevLinesTotal = LinesTotal(); + const Sci::Line prevLinesTotal = LinesTotal(); const Action &action = cb.GetRedoStep(); if (action.at == insertAction) { NotifyModified(DocModification( @@ -1184,7 +1403,7 @@ int Document::Redo() { } if (steps > 1) modFlags |= SC_MULTISTEPUNDOREDO; - const int linesAdded = LinesTotal() - prevLinesTotal; + const Sci::Line linesAdded = LinesTotal() - prevLinesTotal; if (linesAdded != 0) multiLine = true; if (step == steps - 1) { @@ -1194,10 +1413,10 @@ int Document::Redo() { } NotifyModified( DocModification(modFlags, action.position, action.lenData, - linesAdded, action.data)); + linesAdded, action.data.get())); } - bool endSavePoint = cb.IsSavePoint(); + const bool endSavePoint = cb.IsSavePoint(); if (startSavePoint != endSavePoint) NotifySavePoint(endSavePoint); } @@ -1206,28 +1425,28 @@ int Document::Redo() { return newPos; } -void Document::DelChar(int pos) { +void Document::DelChar(Sci::Position pos) { DeleteChars(pos, LenChar(pos)); } -void Document::DelCharBack(int pos) { +void Document::DelCharBack(Sci::Position pos) { if (pos <= 0) { return; } else if (IsCrLf(pos - 2)) { DeleteChars(pos - 2, 2); } else if (dbcsCodePage) { - int startChar = NextPosition(pos, -1); + const Sci::Position startChar = NextPosition(pos, -1); DeleteChars(startChar, pos - startChar); } else { DeleteChars(pos - 1, 1); } } -static int NextTab(int pos, int tabSize) { +static constexpr Sci::Position NextTab(Sci::Position pos, Sci::Position tabSize) noexcept { return ((pos / tabSize) + 1) * tabSize; } -static std::string CreateIndentation(int indent, int tabSize, bool insertSpaces) { +static std::string CreateIndentation(Sci::Position indent, int tabSize, bool insertSpaces) { std::string indentation; if (!insertSpaces) { while (indent >= tabSize) { @@ -1245,14 +1464,14 @@ static std::string CreateIndentation(int indent, int tabSize, bool insertSpaces) int SCI_METHOD Document::GetLineIndentation(Sci_Position line) { int indent = 0; if ((line >= 0) && (line < LinesTotal())) { - int lineStart = LineStart(line); - int length = Length(); - for (int i = lineStart; i < length; i++) { - char ch = cb.CharAt(i); + const Sci::Position lineStart = LineStart(line); + const Sci::Position length = Length(); + for (Sci::Position i = lineStart; i < length; i++) { + const char ch = cb.CharAt(i); if (ch == ' ') indent++; else if (ch == '\t') - indent = NextTab(indent, tabInChars); + indent = static_cast(NextTab(indent, tabInChars)); else return indent; } @@ -1260,40 +1479,40 @@ int SCI_METHOD Document::GetLineIndentation(Sci_Position line) { return indent; } -int Document::SetLineIndentation(int line, int indent) { - int indentOfLine = GetLineIndentation(line); +Sci::Position Document::SetLineIndentation(Sci::Line line, Sci::Position indent) { + const int indentOfLine = GetLineIndentation(line); if (indent < 0) indent = 0; if (indent != indentOfLine) { std::string linebuf = CreateIndentation(indent, tabInChars, !useTabs); - int thisLineStart = LineStart(line); - int indentPos = GetLineIndentPosition(line); + const Sci::Position thisLineStart = LineStart(line); + const Sci::Position indentPos = GetLineIndentPosition(line); UndoGroup ug(this); DeleteChars(thisLineStart, indentPos - thisLineStart); - return thisLineStart + InsertString(thisLineStart, linebuf.c_str(), - static_cast(linebuf.length())); + return thisLineStart + InsertString(thisLineStart, linebuf.c_str(), + linebuf.length()); } else { return GetLineIndentPosition(line); } } -int Document::GetLineIndentPosition(int line) const { +Sci::Position Document::GetLineIndentPosition(Sci::Line line) const { if (line < 0) return 0; - int pos = LineStart(line); - int length = Length(); + Sci::Position pos = LineStart(line); + const Sci::Position length = Length(); while ((pos < length) && IsSpaceOrTab(cb.CharAt(pos))) { pos++; } return pos; } -int Document::GetColumn(int pos) { - int column = 0; - int line = LineFromPosition(pos); +Sci::Position Document::GetColumn(Sci::Position pos) { + Sci::Position column = 0; + const Sci::Line line = SciLineFromPosition(pos); if ((line >= 0) && (line < LinesTotal())) { - for (int i = LineStart(line); i < pos;) { - char ch = cb.CharAt(i); + for (Sci::Position i = LineStart(line); i < pos;) { + const char ch = cb.CharAt(i); if (ch == '\t') { column = NextTab(column, tabInChars); i++; @@ -1312,28 +1531,26 @@ int Document::GetColumn(int pos) { return column; } -int Document::CountCharacters(int startPos, int endPos) const { +Sci::Position Document::CountCharacters(Sci::Position startPos, Sci::Position endPos) const { startPos = MovePositionOutsideChar(startPos, 1, false); endPos = MovePositionOutsideChar(endPos, -1, false); - int count = 0; - int i = startPos; + Sci::Position count = 0; + Sci::Position i = startPos; while (i < endPos) { count++; - if (IsCrLf(i)) - i++; i = NextPosition(i, 1); } return count; } -int Document::CountUTF16(int startPos, int endPos) const { +Sci::Position Document::CountUTF16(Sci::Position startPos, Sci::Position endPos) const { startPos = MovePositionOutsideChar(startPos, 1, false); endPos = MovePositionOutsideChar(endPos, -1, false); - int count = 0; - int i = startPos; + Sci::Position count = 0; + Sci::Position i = startPos; while (i < endPos) { count++; - const int next = NextPosition(i, 1); + const Sci::Position next = NextPosition(i, 1); if ((next - i) > 3) count++; i = next; @@ -1341,12 +1558,12 @@ int Document::CountUTF16(int startPos, int endPos) const { return count; } -int Document::FindColumn(int line, int column) { - int position = LineStart(line); +Sci::Position Document::FindColumn(Sci::Line line, Sci::Position column) { + Sci::Position position = LineStart(line); if ((line >= 0) && (line < LinesTotal())) { - int columnCurrent = 0; + Sci::Position columnCurrent = 0; while ((columnCurrent < column) && (position < Length())) { - char ch = cb.CharAt(position); + const char ch = cb.CharAt(position); if (ch == '\t') { columnCurrent = NextTab(columnCurrent, tabInChars); if (columnCurrent > column) @@ -1365,10 +1582,10 @@ int Document::FindColumn(int line, int column) { return position; } -void Document::Indent(bool forwards, int lineBottom, int lineTop) { +void Document::Indent(bool forwards, Sci::Line lineBottom, Sci::Line lineTop) { // Dedent - suck white space off the front of the line to dedent by equivalent of a tab - for (int line = lineBottom; line >= lineTop; line--) { - int indentOfLine = GetLineIndentation(line); + for (Sci::Line line = lineBottom; line >= lineTop; line--) { + const Sci::Position indentOfLine = GetLineIndentation(line); if (forwards) { if (LineStart(line) < LineEnd(line)) { SetLineIndentation(line, indentOfLine + IndentSize()); @@ -1406,7 +1623,7 @@ std::string Document::TransformLineEnds(const char *s, size_t len, int eolModeWa void Document::ConvertLineEnds(int eolModeSet) { UndoGroup ug(this); - for (int pos = 0; pos < Length(); pos++) { + for (Sci::Position pos = 0; pos < Length(); pos++) { if (cb.CharAt(pos) == '\r') { if (cb.CharAt(pos + 1) == '\n') { // CRLF @@ -1441,11 +1658,16 @@ void Document::ConvertLineEnds(int eolModeSet) { } -bool Document::IsWhiteLine(int line) const { - int currentChar = LineStart(line); - int endLine = LineEnd(line); +int Document::Options() const { + return (IsLarge() ? SC_DOCUMENTOPTION_TEXT_LARGE : 0) | + (cb.HasStyles() ? 0 : SC_DOCUMENTOPTION_STYLES_NONE); +} + +bool Document::IsWhiteLine(Sci::Line line) const { + Sci::Position currentChar = LineStart(line); + const Sci::Position endLine = LineEnd(line); while (currentChar < endLine) { - if (cb.CharAt(currentChar) != ' ' && cb.CharAt(currentChar) != '\t') { + if (!IsSpaceOrTab(cb.CharAt(currentChar))) { return false; } ++currentChar; @@ -1453,8 +1675,8 @@ bool Document::IsWhiteLine(int line) const { return true; } -int Document::ParaUp(int pos) const { - int line = LineFromPosition(pos); +Sci::Position Document::ParaUp(Sci::Position pos) const { + Sci::Line line = SciLineFromPosition(pos); line--; while (line >= 0 && IsWhiteLine(line)) { // skip empty lines line--; @@ -1466,8 +1688,8 @@ int Document::ParaUp(int pos) const { return LineStart(line); } -int Document::ParaDown(int pos) const { - int line = LineFromPosition(pos); +Sci::Position Document::ParaDown(Sci::Position pos) const { + Sci::Line line = SciLineFromPosition(pos); while (line < LinesTotal() && !IsWhiteLine(line)) { // skip non-empty lines line++; } @@ -1480,28 +1702,96 @@ int Document::ParaDown(int pos) const { return LineEnd(line-1); } -CharClassify::cc Document::WordCharClass(unsigned char ch) const { - if ((SC_CP_UTF8 == dbcsCodePage) && (!UTF8IsAscii(ch))) - return CharClassify::ccWord; - return charClass.GetClass(ch); +CharClassify::cc Document::WordCharacterClass(unsigned int ch) const { + if (dbcsCodePage && (!UTF8IsAscii(ch))) { + if (SC_CP_UTF8 == dbcsCodePage) { + // Use hard coded Unicode class + const CharacterCategory cc = charMap.CategoryFor(ch); + switch (cc) { + + // Separator, Line/Paragraph + case ccZl: + case ccZp: + return CharClassify::ccNewLine; + + // Separator, Space + case ccZs: + // Other + case ccCc: + case ccCf: + case ccCs: + case ccCo: + case ccCn: + return CharClassify::ccSpace; + + // Letter + case ccLu: + case ccLl: + case ccLt: + case ccLm: + case ccLo: + // Number + case ccNd: + case ccNl: + case ccNo: + // Mark - includes combining diacritics + case ccMn: + case ccMc: + case ccMe: + return CharClassify::ccWord; + + // Punctuation + case ccPc: + case ccPd: + case ccPs: + case ccPe: + case ccPi: + case ccPf: + case ccPo: + // Symbol + case ccSm: + case ccSc: + case ccSk: + case ccSo: + return CharClassify::ccPunctuation; + + } + } else { + // Asian DBCS + return CharClassify::ccWord; + } + } + return charClass.GetClass(static_cast(ch)); } /** * Used by commmands that want to select whole words. * Finds the start of word at pos when delta < 0 or the end of the word when delta >= 0. */ -int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) { +Sci::Position Document::ExtendWordSelect(Sci::Position pos, int delta, bool onlyWordCharacters) const { CharClassify::cc ccStart = CharClassify::ccWord; if (delta < 0) { - if (!onlyWordCharacters) - ccStart = WordCharClass(cb.CharAt(pos-1)); - while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart)) - pos--; + if (!onlyWordCharacters) { + const CharacterExtracted ce = CharacterBefore(pos); + ccStart = WordCharacterClass(ce.character); + } + while (pos > 0) { + const CharacterExtracted ce = CharacterBefore(pos); + if (WordCharacterClass(ce.character) != ccStart) + break; + pos -= ce.widthBytes; + } } else { - if (!onlyWordCharacters && pos < Length()) - ccStart = WordCharClass(cb.CharAt(pos)); - while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart)) - pos++; + if (!onlyWordCharacters && pos < Length()) { + const CharacterExtracted ce = CharacterAfter(pos); + ccStart = WordCharacterClass(ce.character); + } + while (pos < Length()) { + const CharacterExtracted ce = CharacterAfter(pos); + if (WordCharacterClass(ce.character) != ccStart) + break; + pos += ce.widthBytes; + } } return MovePositionOutsideChar(pos, delta, true); } @@ -1513,22 +1803,39 @@ int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) { * additional movement to transit white space. * Used by cursor movement by word commands. */ -int Document::NextWordStart(int pos, int delta) { +Sci::Position Document::NextWordStart(Sci::Position pos, int delta) const { if (delta < 0) { - while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == CharClassify::ccSpace)) - pos--; + while (pos > 0) { + const CharacterExtracted ce = CharacterBefore(pos); + if (WordCharacterClass(ce.character) != CharClassify::ccSpace) + break; + pos -= ce.widthBytes; + } if (pos > 0) { - CharClassify::cc ccStart = WordCharClass(cb.CharAt(pos-1)); - while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart)) { - pos--; + CharacterExtracted ce = CharacterBefore(pos); + const CharClassify::cc ccStart = WordCharacterClass(ce.character); + while (pos > 0) { + ce = CharacterBefore(pos); + if (WordCharacterClass(ce.character) != ccStart) + break; + pos -= ce.widthBytes; } } } else { - CharClassify::cc ccStart = WordCharClass(cb.CharAt(pos)); - while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart)) - pos++; - while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == CharClassify::ccSpace)) - pos++; + CharacterExtracted ce = CharacterAfter(pos); + const CharClassify::cc ccStart = WordCharacterClass(ce.character); + while (pos < Length()) { + ce = CharacterAfter(pos); + if (WordCharacterClass(ce.character) != ccStart) + break; + pos += ce.widthBytes; + } + while (pos < Length()) { + ce = CharacterAfter(pos); + if (WordCharacterClass(ce.character) != CharClassify::ccSpace) + break; + pos += ce.widthBytes; + } } return pos; } @@ -1540,27 +1847,41 @@ int Document::NextWordStart(int pos, int delta) { * additional movement to transit white space. * Used by cursor movement by word commands. */ -int Document::NextWordEnd(int pos, int delta) { +Sci::Position Document::NextWordEnd(Sci::Position pos, int delta) const { if (delta < 0) { if (pos > 0) { - CharClassify::cc ccStart = WordCharClass(cb.CharAt(pos-1)); + CharacterExtracted ce = CharacterBefore(pos); + const CharClassify::cc ccStart = WordCharacterClass(ce.character); if (ccStart != CharClassify::ccSpace) { - while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == ccStart) { - pos--; + while (pos > 0) { + ce = CharacterBefore(pos); + if (WordCharacterClass(ce.character) != ccStart) + break; + pos -= ce.widthBytes; } } - while (pos > 0 && WordCharClass(cb.CharAt(pos - 1)) == CharClassify::ccSpace) { - pos--; + while (pos > 0) { + ce = CharacterBefore(pos); + if (WordCharacterClass(ce.character) != CharClassify::ccSpace) + break; + pos -= ce.widthBytes; } } } else { - while (pos < Length() && WordCharClass(cb.CharAt(pos)) == CharClassify::ccSpace) { - pos++; + while (pos < Length()) { + const CharacterExtracted ce = CharacterAfter(pos); + if (WordCharacterClass(ce.character) != CharClassify::ccSpace) + break; + pos += ce.widthBytes; } if (pos < Length()) { - CharClassify::cc ccStart = WordCharClass(cb.CharAt(pos)); - while (pos < Length() && WordCharClass(cb.CharAt(pos)) == ccStart) { - pos++; + CharacterExtracted ce = CharacterAfter(pos); + const CharClassify::cc ccStart = WordCharacterClass(ce.character); + while (pos < Length()) { + ce = CharacterAfter(pos); + if (WordCharacterClass(ce.character) != ccStart) + break; + pos += ce.widthBytes; } } } @@ -1571,11 +1892,16 @@ int Document::NextWordEnd(int pos, int delta) { * Check that the character at the given position is a word or punctuation character and that * the previous character is of a different character class. */ -bool Document::IsWordStartAt(int pos) const { +bool Document::IsWordStartAt(Sci::Position pos) const { + if (pos >= Length()) + return false; if (pos > 0) { - CharClassify::cc ccPos = WordCharClass(CharAt(pos)); + const CharacterExtracted cePos = CharacterAfter(pos); + const CharClassify::cc ccPos = WordCharacterClass(cePos.character); + const CharacterExtracted cePrev = CharacterBefore(pos); + const CharClassify::cc ccPrev = WordCharacterClass(cePrev.character); return (ccPos == CharClassify::ccWord || ccPos == CharClassify::ccPunctuation) && - (ccPos != WordCharClass(CharAt(pos - 1))); + (ccPos != ccPrev); } return true; } @@ -1584,11 +1910,16 @@ bool Document::IsWordStartAt(int pos) const { * Check that the character at the given position is a word or punctuation character and that * the next character is of a different character class. */ -bool Document::IsWordEndAt(int pos) const { +bool Document::IsWordEndAt(Sci::Position pos) const { + if (pos <= 0) + return false; if (pos < Length()) { - CharClassify::cc ccPrev = WordCharClass(CharAt(pos-1)); + const CharacterExtracted cePos = CharacterAfter(pos); + const CharClassify::cc ccPos = WordCharacterClass(cePos.character); + const CharacterExtracted cePrev = CharacterBefore(pos); + const CharClassify::cc ccPrev = WordCharacterClass(cePrev.character); return (ccPrev == CharClassify::ccWord || ccPrev == CharClassify::ccPunctuation) && - (ccPrev != WordCharClass(CharAt(pos))); + (ccPrev != ccPos); } return true; } @@ -1597,27 +1928,26 @@ bool Document::IsWordEndAt(int pos) const { * Check that the given range is has transitions between character classes at both * ends and where the characters on the inside are word or punctuation characters. */ -bool Document::IsWordAt(int start, int end) const { +bool Document::IsWordAt(Sci::Position start, Sci::Position end) const { return (start < end) && IsWordStartAt(start) && IsWordEndAt(end); } -bool Document::MatchesWordOptions(bool word, bool wordStart, int pos, int length) const { +bool Document::MatchesWordOptions(bool word, bool wordStart, Sci::Position pos, Sci::Position length) const { return (!word && !wordStart) || (word && IsWordAt(pos, pos + length)) || (wordStart && IsWordStartAt(pos)); } -bool Document::HasCaseFolder(void) const { - return pcf != 0; +bool Document::HasCaseFolder() const noexcept { + return pcf != nullptr; } void Document::SetCaseFolder(CaseFolder *pcf_) { - delete pcf; - pcf = pcf_; + pcf.reset(pcf_); } -Document::CharacterExtracted Document::ExtractCharacter(int position) const { - const unsigned char leadByte = static_cast(cb.CharAt(position)); +Document::CharacterExtracted Document::ExtractCharacter(Sci::Position position) const noexcept { + const unsigned char leadByte = cb.UCharAt(position); if (UTF8IsAscii(leadByte)) { // Common case: ASCII character return CharacterExtracted(leadByte, 1); @@ -1625,8 +1955,8 @@ Document::CharacterExtracted Document::ExtractCharacter(int position) const { const int widthCharBytes = UTF8BytesOfLead[leadByte]; unsigned char charBytes[UTF8MaxBytes] = { leadByte, 0, 0, 0 }; for (int b=1; b(cb.CharAt(position + b)); - int utf8status = UTF8Classify(charBytes, widthCharBytes); + charBytes[b] = cb.UCharAt(position + b); + const int utf8status = UTF8Classify(charBytes, widthCharBytes); if (utf8status & UTF8MaskInvalid) { // Treat as invalid and use up just one byte return CharacterExtracted(unicodeReplacementChar, 1); @@ -1640,8 +1970,8 @@ Document::CharacterExtracted Document::ExtractCharacter(int position) const { * searches (just pass minPos > maxPos to do a backward search) * Has not been tested with backwards DBCS searches yet. */ -long Document::FindText(int minPos, int maxPos, const char *search, - int flags, int *length) { +Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, const char *search, + int flags, Sci::Position *length) { if (*length <= 0) return minPos; const bool caseSensitive = (flags & SCFIND_MATCHCASE) != 0; @@ -1650,7 +1980,7 @@ long Document::FindText(int minPos, int maxPos, const char *search, const bool regExp = (flags & SCFIND_REGEXP) != 0; if (regExp) { if (!regex) - regex = CreateRegexSearch(&charClass); + regex = std::unique_ptr(CreateRegexSearch(&charClass)); return regex->FindText(this, minPos, maxPos, search, caseSensitive, word, wordStart, flags, length); } else { @@ -1658,21 +1988,21 @@ long Document::FindText(int minPos, int maxPos, const char *search, const int increment = forward ? 1 : -1; // Range endpoints should not be inside DBCS characters, but just in case, move them. - const int startPos = MovePositionOutsideChar(minPos, increment, false); - const int endPos = MovePositionOutsideChar(maxPos, increment, false); + const Sci::Position startPos = MovePositionOutsideChar(minPos, increment, false); + const Sci::Position endPos = MovePositionOutsideChar(maxPos, increment, false); // Compute actual search ranges needed - const int lengthFind = *length; + const Sci::Position lengthFind = *length; //Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind); - const int limitPos = Platform::Maximum(startPos, endPos); - int pos = startPos; + const Sci::Position limitPos = std::max(startPos, endPos); + Sci::Position pos = startPos; if (!forward) { // Back all of a character pos = NextPosition(pos, increment); } if (caseSensitive) { - const int endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos; + const Sci::Position endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos; const char charStartSearch = search[0]; while (forward ? (pos < endSearch) : (pos >= endSearch)) { if (CharAt(pos) == charStartSearch) { @@ -1689,18 +2019,18 @@ long Document::FindText(int minPos, int maxPos, const char *search, } } else if (SC_CP_UTF8 == dbcsCodePage) { const size_t maxFoldingExpansion = 4; - std::vector searchThing(lengthFind * UTF8MaxBytes * maxFoldingExpansion + 1); - const int lenSearch = static_cast( - pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind)); - char bytes[UTF8MaxBytes + 1]; - char folded[UTF8MaxBytes * maxFoldingExpansion + 1]; + std::vector searchThing((lengthFind+1) * UTF8MaxBytes * maxFoldingExpansion + 1); + const size_t lenSearch = + pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind); + char bytes[UTF8MaxBytes + 1] = ""; + char folded[UTF8MaxBytes * maxFoldingExpansion + 1] = ""; while (forward ? (pos < endPos) : (pos >= endPos)) { int widthFirstCharacter = 0; - int posIndexDocument = pos; - int indexSearch = 0; + Sci::Position posIndexDocument = pos; + size_t indexSearch = 0; bool characterMatches = true; for (;;) { - const unsigned char leadByte = static_cast(cb.CharAt(posIndexDocument)); + const unsigned char leadByte = cb.UCharAt(posIndexDocument); bytes[0] = leadByte; int widthChar = 1; if (!UTF8IsAscii(leadByte)) { @@ -1714,8 +2044,9 @@ long Document::FindText(int minPos, int maxPos, const char *search, widthFirstCharacter = widthChar; if ((posIndexDocument + widthChar) > limitPos) break; - const int lenFlat = static_cast(pcf->Fold(folded, sizeof(folded), bytes, widthChar)); - folded[lenFlat] = 0; + const size_t lenFlat = pcf->Fold(folded, sizeof(folded), bytes, widthChar); + // memcmp may examine lenFlat bytes in both arguments so assert it doesn't read past end of searchThing + assert((indexSearch + lenFlat) <= searchThing.size()); // Does folded match the buffer characterMatches = 0 == memcmp(folded, &searchThing[0] + indexSearch, lenFlat); if (!characterMatches) @@ -1725,7 +2056,7 @@ long Document::FindText(int minPos, int maxPos, const char *search, if (indexSearch >= lenSearch) break; } - if (characterMatches && (indexSearch == static_cast(lenSearch))) { + if (characterMatches && (indexSearch == lenSearch)) { if (MatchesWordOptions(word, wordStart, pos, posIndexDocument - pos)) { *length = posIndexDocument - pos; return pos; @@ -1741,32 +2072,32 @@ long Document::FindText(int minPos, int maxPos, const char *search, } else if (dbcsCodePage) { const size_t maxBytesCharacter = 2; const size_t maxFoldingExpansion = 4; - std::vector searchThing(lengthFind * maxBytesCharacter * maxFoldingExpansion + 1); - const int lenSearch = static_cast( - pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind)); + std::vector searchThing((lengthFind+1) * maxBytesCharacter * maxFoldingExpansion + 1); + const size_t lenSearch = pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind); while (forward ? (pos < endPos) : (pos >= endPos)) { - int indexDocument = 0; - int indexSearch = 0; + Sci::Position indexDocument = 0; + size_t indexSearch = 0; bool characterMatches = true; while (characterMatches && ((pos + indexDocument) < limitPos) && (indexSearch < lenSearch)) { char bytes[maxBytesCharacter + 1]; bytes[0] = cb.CharAt(pos + indexDocument); - const int widthChar = IsDBCSLeadByte(bytes[0]) ? 2 : 1; + const Sci::Position widthChar = IsDBCSLeadByteNoExcept(bytes[0]) ? 2 : 1; if (widthChar == 2) bytes[1] = cb.CharAt(pos + indexDocument + 1); if ((pos + indexDocument + widthChar) > limitPos) break; char folded[maxBytesCharacter * maxFoldingExpansion + 1]; - const int lenFlat = static_cast(pcf->Fold(folded, sizeof(folded), bytes, widthChar)); - folded[lenFlat] = 0; + const size_t lenFlat = pcf->Fold(folded, sizeof(folded), bytes, widthChar); + // memcmp may examine lenFlat bytes in both arguments so assert it doesn't read past end of searchThing + assert((indexSearch + lenFlat) <= searchThing.size()); // Does folded match the buffer characterMatches = 0 == memcmp(folded, &searchThing[0] + indexSearch, lenFlat); indexDocument += widthChar; indexSearch += lenFlat; } - if (characterMatches && (indexSearch == static_cast(lenSearch))) { + if (characterMatches && (indexSearch == lenSearch)) { if (MatchesWordOptions(word, wordStart, pos, indexDocument)) { *length = indexDocument; return pos; @@ -1776,13 +2107,13 @@ long Document::FindText(int minPos, int maxPos, const char *search, break; } } else { - const int endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos; + const Sci::Position endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos; std::vector searchThing(lengthFind + 1); pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind); while (forward ? (pos < endSearch) : (pos >= endSearch)) { bool found = (pos + lengthFind) <= limitPos; for (int indexSearch = 0; (indexSearch < lengthFind) && found; indexSearch++) { - char ch = CharAt(pos + indexSearch); + const char ch = CharAt(pos + indexSearch); char folded[2]; pcf->Fold(folded, sizeof(folded), &ch, 1); found = folded[0] == searchThing[indexSearch]; @@ -1799,14 +2130,26 @@ long Document::FindText(int minPos, int maxPos, const char *search, return -1; } -const char *Document::SubstituteByPosition(const char *text, int *length) { +const char *Document::SubstituteByPosition(const char *text, Sci::Position *length) { if (regex) return regex->SubstituteByPosition(this, text, length); else - return 0; + return nullptr; } -int Document::LinesTotal() const { +int Document::LineCharacterIndex() const { + return cb.LineCharacterIndex(); +} + +void Document::AllocateLineCharacterIndex(int lineCharacterIndex) { + return cb.AllocateLineCharacterIndex(lineCharacterIndex); +} + +void Document::ReleaseLineCharacterIndex(int lineCharacterIndex) { + return cb.ReleaseLineCharacterIndex(lineCharacterIndex); +} + +Sci::Line Document::LinesTotal() const noexcept { return cb.Lines(); } @@ -1818,10 +2161,18 @@ void Document::SetCharClasses(const unsigned char *chars, CharClassify::cc newCh charClass.SetCharClasses(chars, newCharClass); } -int Document::GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer) { +int Document::GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer) const { return charClass.GetCharsOfClass(characterClass, buffer); } +void Document::SetCharacterCategoryOptimization(int countCharacters) { + charMap.Optimize(countCharacters); +} + +int Document::CharacterCategoryOptimization() const noexcept { + return charMap.Size(); +} + void SCI_METHOD Document::StartStyling(Sci_Position position, char) { endStyled = position; } @@ -1831,9 +2182,9 @@ bool SCI_METHOD Document::SetStyleFor(Sci_Position length, char style) { return false; } else { enteredStyling++; - int prevEndStyled = endStyled; + const Sci::Position prevEndStyled = endStyled; if (cb.SetStyleFor(endStyled, length, style)) { - DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, + const DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, prevEndStyled, length); NotifyModified(mh); } @@ -1849,8 +2200,8 @@ bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) { } else { enteredStyling++; bool didChange = false; - int startMod = 0; - int endMod = 0; + Sci::Position startMod = 0; + Sci::Position endMod = 0; for (int iPos = 0; iPos < length; iPos++, endStyled++) { PLATFORM_ASSERT(endStyled < Length()); if (cb.SetStyleAt(endStyled, styles[iPos])) { @@ -1862,7 +2213,7 @@ bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) { } } if (didChange) { - DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, + const DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, startMod, endMod - startMod + 1); NotifyModified(mh); } @@ -1871,12 +2222,12 @@ bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) { } } -void Document::EnsureStyledTo(int pos) { +void Document::EnsureStyledTo(Sci::Position pos) { if ((enteredStyling == 0) && (pos > GetEndStyled())) { IncrementStyleClock(); if (pli && !pli->UseContainerLexing()) { - int lineEndStyled = LineFromPosition(GetEndStyled()); - int endStyledTo = LineStart(lineEndStyled); + const Sci::Line lineEndStyled = SciLineFromPosition(GetEndStyled()); + const Sci::Position endStyledTo = LineStart(lineEndStyled); pli->Colourise(endStyledTo, pos); } else { // Ask the watchers to style, and stop as soon as one responds. @@ -1888,120 +2239,149 @@ void Document::EnsureStyledTo(int pos) { } } +void Document::StyleToAdjustingLineDuration(Sci::Position pos) { + const Sci::Line lineFirst = SciLineFromPosition(GetEndStyled()); + ElapsedPeriod epStyling; + EnsureStyledTo(pos); + const Sci::Line lineLast = SciLineFromPosition(GetEndStyled()); + durationStyleOneLine.AddSample(lineLast - lineFirst, epStyling.Duration()); +} + void Document::LexerChanged() { // Tell the watchers the lexer has changed. - for (std::vector::iterator it = watchers.begin(); it != watchers.end(); ++it) { - it->watcher->NotifyLexerChanged(this, it->userData); + for (const WatcherWithUserData &watcher : watchers) { + watcher.watcher->NotifyLexerChanged(this, watcher.userData); } } +LexInterface *Document::GetLexInterface() const { + return pli.get(); +} + +void Document::SetLexInterface(LexInterface *pLexInterface) { + pli.reset(pLexInterface); +} + int SCI_METHOD Document::SetLineState(Sci_Position line, int state) { - int statePrevious = static_cast(perLineData[ldState])->SetLineState(line, state); + const int statePrevious = States()->SetLineState(static_cast(line), state); if (state != statePrevious) { - DocModification mh(SC_MOD_CHANGELINESTATE, LineStart(line), 0, 0, 0, line); + const DocModification mh(SC_MOD_CHANGELINESTATE, LineStart(line), 0, 0, nullptr, + static_cast(line)); NotifyModified(mh); } return statePrevious; } int SCI_METHOD Document::GetLineState(Sci_Position line) const { - return static_cast(perLineData[ldState])->GetLineState(line); + return States()->GetLineState(static_cast(line)); } -int Document::GetMaxLineState() { - return static_cast(perLineData[ldState])->GetMaxLineState(); +Sci::Line Document::GetMaxLineState() const { + return States()->GetMaxLineState(); } void SCI_METHOD Document::ChangeLexerState(Sci_Position start, Sci_Position end) { - DocModification mh(SC_MOD_LEXERSTATE, start, end-start, 0, 0, 0); + const DocModification mh(SC_MOD_LEXERSTATE, start, + end-start, 0, 0, 0); NotifyModified(mh); } -StyledText Document::MarginStyledText(int line) const { - LineAnnotation *pla = static_cast(perLineData[ldMargin]); +StyledText Document::MarginStyledText(Sci::Line line) const { + const LineAnnotation *pla = Margins(); return StyledText(pla->Length(line), pla->Text(line), pla->MultipleStyles(line), pla->Style(line), pla->Styles(line)); } -void Document::MarginSetText(int line, const char *text) { - static_cast(perLineData[ldMargin])->SetText(line, text); - DocModification mh(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line); +void Document::MarginSetText(Sci::Line line, const char *text) { + Margins()->SetText(line, text); + const DocModification mh(SC_MOD_CHANGEMARGIN, LineStart(line), + 0, 0, 0, line); NotifyModified(mh); } -void Document::MarginSetStyle(int line, int style) { - static_cast(perLineData[ldMargin])->SetStyle(line, style); - NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line)); +void Document::MarginSetStyle(Sci::Line line, int style) { + Margins()->SetStyle(line, style); + NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line), + 0, 0, 0, line)); } -void Document::MarginSetStyles(int line, const unsigned char *styles) { - static_cast(perLineData[ldMargin])->SetStyles(line, styles); - NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line)); +void Document::MarginSetStyles(Sci::Line line, const unsigned char *styles) { + Margins()->SetStyles(line, styles); + NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line), + 0, 0, 0, line)); } void Document::MarginClearAll() { - int maxEditorLine = LinesTotal(); - for (int l=0; l(perLineData[ldMargin])->ClearAll(); + Margins()->ClearAll(); } -StyledText Document::AnnotationStyledText(int line) const { - LineAnnotation *pla = static_cast(perLineData[ldAnnotation]); +StyledText Document::AnnotationStyledText(Sci::Line line) const { + const LineAnnotation *pla = Annotations(); return StyledText(pla->Length(line), pla->Text(line), pla->MultipleStyles(line), pla->Style(line), pla->Styles(line)); } -void Document::AnnotationSetText(int line, const char *text) { +void Document::AnnotationSetText(Sci::Line line, const char *text) { if (line >= 0 && line < LinesTotal()) { - const int linesBefore = AnnotationLines(line); - static_cast(perLineData[ldAnnotation])->SetText(line, text); + const Sci::Line linesBefore = AnnotationLines(line); + Annotations()->SetText(line, text); const int linesAfter = AnnotationLines(line); - DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), 0, 0, 0, line); + DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), + 0, 0, 0, line); mh.annotationLinesAdded = linesAfter - linesBefore; NotifyModified(mh); } } -void Document::AnnotationSetStyle(int line, int style) { - static_cast(perLineData[ldAnnotation])->SetStyle(line, style); - DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), 0, 0, 0, line); +void Document::AnnotationSetStyle(Sci::Line line, int style) { + Annotations()->SetStyle(line, style); + const DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), + 0, 0, 0, line); NotifyModified(mh); } -void Document::AnnotationSetStyles(int line, const unsigned char *styles) { +void Document::AnnotationSetStyles(Sci::Line line, const unsigned char *styles) { if (line >= 0 && line < LinesTotal()) { - static_cast(perLineData[ldAnnotation])->SetStyles(line, styles); + Annotations()->SetStyles(line, styles); } } -int Document::AnnotationLines(int line) const { - return static_cast(perLineData[ldAnnotation])->Lines(line); +int Document::AnnotationLines(Sci::Line line) const { + return Annotations()->Lines(line); } void Document::AnnotationClearAll() { - int maxEditorLine = LinesTotal(); - for (int l=0; l(perLineData[ldAnnotation])->ClearAll(); + Annotations()->ClearAll(); } -void Document::IncrementStyleClock() { +void Document::IncrementStyleClock() noexcept { styleClock = (styleClock + 1) % 0x100000; } +void SCI_METHOD Document::DecorationSetCurrentIndicator(int indicator) { + decorations->SetCurrentIndicator(indicator); +} + void SCI_METHOD Document::DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength) { - if (decorations.FillRange(position, value, fillLength)) { - DocModification mh(SC_MOD_CHANGEINDICATOR | SC_PERFORMED_USER, - position, fillLength); + const FillResult fr = decorations->FillRange( + position, value, fillLength); + if (fr.changed) { + const DocModification mh(SC_MOD_CHANGEINDICATOR | SC_PERFORMED_USER, + fr.position, fr.fillLength); NotifyModified(mh); } } bool Document::AddWatcher(DocWatcher *watcher, void *userData) { - WatcherWithUserData wwud(watcher, userData); + const WatcherWithUserData wwud(watcher, userData); std::vector::iterator it = std::find(watchers.begin(), watchers.end(), wwud); if (it != watchers.end()) @@ -2021,128 +2401,169 @@ bool Document::RemoveWatcher(DocWatcher *watcher, void *userData) { } void Document::NotifyModifyAttempt() { - for (std::vector::iterator it = watchers.begin(); it != watchers.end(); ++it) { - it->watcher->NotifyModifyAttempt(this, it->userData); + for (const WatcherWithUserData &watcher : watchers) { + watcher.watcher->NotifyModifyAttempt(this, watcher.userData); } } void Document::NotifySavePoint(bool atSavePoint) { - for (std::vector::iterator it = watchers.begin(); it != watchers.end(); ++it) { - it->watcher->NotifySavePoint(this, it->userData, atSavePoint); + for (const WatcherWithUserData &watcher : watchers) { + watcher.watcher->NotifySavePoint(this, watcher.userData, atSavePoint); } } void Document::NotifyModified(DocModification mh) { if (mh.modificationType & SC_MOD_INSERTTEXT) { - decorations.InsertSpace(mh.position, mh.length); + decorations->InsertSpace(mh.position, mh.length); } else if (mh.modificationType & SC_MOD_DELETETEXT) { - decorations.DeleteRange(mh.position, mh.length); + decorations->DeleteRange(mh.position, mh.length); } - for (std::vector::iterator it = watchers.begin(); it != watchers.end(); ++it) { - it->watcher->NotifyModified(this, mh, it->userData); + for (const WatcherWithUserData &watcher : watchers) { + watcher.watcher->NotifyModified(this, mh, watcher.userData); } } -bool Document::IsWordPartSeparator(char ch) const { - return (WordCharClass(ch) == CharClassify::ccWord) && IsPunctuation(ch); +// Used for word part navigation. +static bool IsASCIIPunctuationCharacter(unsigned int ch) noexcept { + switch (ch) { + case '!': + case '"': + case '#': + case '$': + case '%': + case '&': + case '\'': + case '(': + case ')': + case '*': + case '+': + case ',': + case '-': + case '.': + case '/': + case ':': + case ';': + case '<': + case '=': + case '>': + case '?': + case '@': + case '[': + case '\\': + case ']': + case '^': + case '_': + case '`': + case '{': + case '|': + case '}': + case '~': + return true; + default: + return false; + } } -int Document::WordPartLeft(int pos) { +bool Document::IsWordPartSeparator(unsigned int ch) const { + return (WordCharacterClass(ch) == CharClassify::ccWord) && IsASCIIPunctuationCharacter(ch); +} + +Sci::Position Document::WordPartLeft(Sci::Position pos) const { if (pos > 0) { - --pos; - char startChar = cb.CharAt(pos); - if (IsWordPartSeparator(startChar)) { - while (pos > 0 && IsWordPartSeparator(cb.CharAt(pos))) { - --pos; + pos -= CharacterBefore(pos).widthBytes; + CharacterExtracted ceStart = CharacterAfter(pos); + if (IsWordPartSeparator(ceStart.character)) { + while (pos > 0 && IsWordPartSeparator(CharacterAfter(pos).character)) { + pos -= CharacterBefore(pos).widthBytes; } } if (pos > 0) { - startChar = cb.CharAt(pos); - --pos; - if (IsLowerCase(startChar)) { - while (pos > 0 && IsLowerCase(cb.CharAt(pos))) - --pos; - if (!IsUpperCase(cb.CharAt(pos)) && !IsLowerCase(cb.CharAt(pos))) - ++pos; - } else if (IsUpperCase(startChar)) { - while (pos > 0 && IsUpperCase(cb.CharAt(pos))) - --pos; - if (!IsUpperCase(cb.CharAt(pos))) - ++pos; - } else if (IsADigit(startChar)) { - while (pos > 0 && IsADigit(cb.CharAt(pos))) - --pos; - if (!IsADigit(cb.CharAt(pos))) - ++pos; - } else if (IsPunctuation(startChar)) { - while (pos > 0 && IsPunctuation(cb.CharAt(pos))) - --pos; - if (!IsPunctuation(cb.CharAt(pos))) - ++pos; - } else if (isspacechar(startChar)) { - while (pos > 0 && isspacechar(cb.CharAt(pos))) - --pos; - if (!isspacechar(cb.CharAt(pos))) - ++pos; - } else if (!IsASCII(startChar)) { - while (pos > 0 && !IsASCII(cb.CharAt(pos))) - --pos; - if (IsASCII(cb.CharAt(pos))) - ++pos; + ceStart = CharacterAfter(pos); + pos -= CharacterBefore(pos).widthBytes; + if (IsLowerCase(ceStart.character)) { + while (pos > 0 && IsLowerCase(CharacterAfter(pos).character)) + pos -= CharacterBefore(pos).widthBytes; + if (!IsUpperCase(CharacterAfter(pos).character) && !IsLowerCase(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + } else if (IsUpperCase(ceStart.character)) { + while (pos > 0 && IsUpperCase(CharacterAfter(pos).character)) + pos -= CharacterBefore(pos).widthBytes; + if (!IsUpperCase(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + } else if (IsADigit(ceStart.character)) { + while (pos > 0 && IsADigit(CharacterAfter(pos).character)) + pos -= CharacterBefore(pos).widthBytes; + if (!IsADigit(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + } else if (IsASCIIPunctuationCharacter(ceStart.character)) { + while (pos > 0 && IsASCIIPunctuationCharacter(CharacterAfter(pos).character)) + pos -= CharacterBefore(pos).widthBytes; + if (!IsASCIIPunctuationCharacter(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + } else if (isspacechar(ceStart.character)) { + while (pos > 0 && isspacechar(CharacterAfter(pos).character)) + pos -= CharacterBefore(pos).widthBytes; + if (!isspacechar(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + } else if (!IsASCII(ceStart.character)) { + while (pos > 0 && !IsASCII(CharacterAfter(pos).character)) + pos -= CharacterBefore(pos).widthBytes; + if (IsASCII(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; } else { - ++pos; + pos += CharacterAfter(pos).widthBytes; } } } return pos; } -int Document::WordPartRight(int pos) { - char startChar = cb.CharAt(pos); - int length = Length(); - if (IsWordPartSeparator(startChar)) { - while (pos < length && IsWordPartSeparator(cb.CharAt(pos))) - ++pos; - startChar = cb.CharAt(pos); +Sci::Position Document::WordPartRight(Sci::Position pos) const { + CharacterExtracted ceStart = CharacterAfter(pos); + const Sci::Position length = Length(); + if (IsWordPartSeparator(ceStart.character)) { + while (pos < length && IsWordPartSeparator(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + ceStart = CharacterAfter(pos); } - if (!IsASCII(startChar)) { - while (pos < length && !IsASCII(cb.CharAt(pos))) - ++pos; - } else if (IsLowerCase(startChar)) { - while (pos < length && IsLowerCase(cb.CharAt(pos))) - ++pos; - } else if (IsUpperCase(startChar)) { - if (IsLowerCase(cb.CharAt(pos + 1))) { - ++pos; - while (pos < length && IsLowerCase(cb.CharAt(pos))) - ++pos; + if (!IsASCII(ceStart.character)) { + while (pos < length && !IsASCII(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + } else if (IsLowerCase(ceStart.character)) { + while (pos < length && IsLowerCase(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + } else if (IsUpperCase(ceStart.character)) { + if (IsLowerCase(CharacterAfter(pos + ceStart.widthBytes).character)) { + pos += CharacterAfter(pos).widthBytes; + while (pos < length && IsLowerCase(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; } else { - while (pos < length && IsUpperCase(cb.CharAt(pos))) - ++pos; + while (pos < length && IsUpperCase(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; } - if (IsLowerCase(cb.CharAt(pos)) && IsUpperCase(cb.CharAt(pos - 1))) - --pos; - } else if (IsADigit(startChar)) { - while (pos < length && IsADigit(cb.CharAt(pos))) - ++pos; - } else if (IsPunctuation(startChar)) { - while (pos < length && IsPunctuation(cb.CharAt(pos))) - ++pos; - } else if (isspacechar(startChar)) { - while (pos < length && isspacechar(cb.CharAt(pos))) - ++pos; + if (IsLowerCase(CharacterAfter(pos).character) && IsUpperCase(CharacterBefore(pos).character)) + pos -= CharacterBefore(pos).widthBytes; + } else if (IsADigit(ceStart.character)) { + while (pos < length && IsADigit(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + } else if (IsASCIIPunctuationCharacter(ceStart.character)) { + while (pos < length && IsASCIIPunctuationCharacter(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; + } else if (isspacechar(ceStart.character)) { + while (pos < length && isspacechar(CharacterAfter(pos).character)) + pos += CharacterAfter(pos).widthBytes; } else { - ++pos; + pos += CharacterAfter(pos).widthBytes; } return pos; } -bool IsLineEndChar(char c) { +static constexpr bool IsLineEndChar(char c) noexcept { return (c == '\n' || c == '\r'); } -int Document::ExtendStyleRange(int pos, int delta, bool singleLine) { - int sStart = cb.StyleAt(pos); +Sci::Position Document::ExtendStyleRange(Sci::Position pos, int delta, bool singleLine) { + const int sStart = cb.StyleAt(pos); if (delta < 0) { while (pos > 0 && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos)))) pos--; @@ -2154,7 +2575,7 @@ int Document::ExtendStyleRange(int pos, int delta, bool singleLine) { return pos; } -static char BraceOpposite(char ch) { +static char BraceOpposite(char ch) noexcept { switch (ch) { case '(': return ')'; @@ -2178,20 +2599,20 @@ static char BraceOpposite(char ch) { } // TODO: should be able to extend styled region to find matching brace -int Document::BraceMatch(int position, int /*maxReStyle*/) { - char chBrace = CharAt(position); - char chSeek = BraceOpposite(chBrace); +Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxReStyle*/) { + const char chBrace = CharAt(position); + const char chSeek = BraceOpposite(chBrace); if (chSeek == '\0') return - 1; - char styBrace = static_cast(StyleAt(position)); + const int styBrace = StyleIndexAt(position); int direction = -1; if (chBrace == '(' || chBrace == '[' || chBrace == '{' || chBrace == '<') direction = 1; int depth = 1; position = NextPosition(position, direction); while ((position >= 0) && (position < Length())) { - char chAtPos = CharAt(position); - char styAtPos = static_cast(StyleAt(position)); + const char chAtPos = CharAt(position); + const int styAtPos = StyleIndexAt(position); if ((position > GetEndStyled()) || (styAtPos == styBrace)) { if (chAtPos == chBrace) depth++; @@ -2200,7 +2621,7 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { if (depth == 0) return position; } - int positionBeforeMove = position; + const Sci::Position positionBeforeMove = position; position = NextPosition(position, direction); if (position == positionBeforeMove) break; @@ -2214,15 +2635,17 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { class BuiltinRegex : public RegexSearchBase { public: explicit BuiltinRegex(CharClassify *charClassTable) : search(charClassTable) {} + BuiltinRegex(const BuiltinRegex &) = delete; + BuiltinRegex(BuiltinRegex &&) = delete; + BuiltinRegex &operator=(const BuiltinRegex &) = delete; + BuiltinRegex &operator=(BuiltinRegex &&) = delete; + ~BuiltinRegex() override = default; - virtual ~BuiltinRegex() { - } - - virtual long FindText(Document *doc, int minPos, int maxPos, const char *s, + Sci::Position FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s, bool caseSensitive, bool word, bool wordStart, int flags, - int *length); + Sci::Position *length) override; - virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length); + const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) override; private: RESearch search; @@ -2238,36 +2661,24 @@ class RESearchRange { public: const Document *doc; int increment; - int startPos; - int endPos; - int lineRangeStart; - int lineRangeEnd; - int lineRangeBreak; - RESearchRange(const Document *doc_, int minPos, int maxPos) : doc(doc_) { + Sci::Position startPos; + Sci::Position endPos; + Sci::Line lineRangeStart; + Sci::Line lineRangeEnd; + Sci::Line lineRangeBreak; + RESearchRange(const Document *doc_, Sci::Position minPos, Sci::Position maxPos) : doc(doc_) { increment = (minPos <= maxPos) ? 1 : -1; - // Range endpoints should not be inside DBCS characters, but just in case, move them. - startPos = doc->MovePositionOutsideChar(minPos, 1, false); - endPos = doc->MovePositionOutsideChar(maxPos, 1, false); + // Range endpoints should not be inside DBCS characters or between a CR and LF, + // but just in case, move them. + startPos = doc->MovePositionOutsideChar(minPos, 1, true); + endPos = doc->MovePositionOutsideChar(maxPos, 1, true); - lineRangeStart = doc->LineFromPosition(startPos); - lineRangeEnd = doc->LineFromPosition(endPos); - if ((increment == 1) && - (startPos >= doc->LineEnd(lineRangeStart)) && - (lineRangeStart < lineRangeEnd)) { - // the start position is at end of line or between line end characters. - lineRangeStart++; - startPos = doc->LineStart(lineRangeStart); - } else if ((increment == -1) && - (startPos <= doc->LineStart(lineRangeStart)) && - (lineRangeStart > lineRangeEnd)) { - // the start position is at beginning of line. - lineRangeStart--; - startPos = doc->LineEnd(lineRangeStart); - } + lineRangeStart = doc->SciLineFromPosition(startPos); + lineRangeEnd = doc->SciLineFromPosition(endPos); lineRangeBreak = lineRangeEnd + increment; } - Range LineRange(int line) const { + Range LineRange(Sci::Line line) const { Range range(doc->LineStart(line), doc->LineEnd(line)); if (increment == 1) { if (line == lineRangeStart) @@ -2287,16 +2698,20 @@ public: // Define a way for the Regular Expression code to access the document class DocumentIndexer : public CharacterIndexer { Document *pdoc; - int end; + Sci::Position end; public: - DocumentIndexer(Document *pdoc_, int end_) : + DocumentIndexer(Document *pdoc_, Sci::Position end_) noexcept : pdoc(pdoc_), end(end_) { } - virtual ~DocumentIndexer() { - } + DocumentIndexer(const DocumentIndexer &) = delete; + DocumentIndexer(DocumentIndexer &&) = delete; + DocumentIndexer &operator=(const DocumentIndexer &) = delete; + DocumentIndexer &operator=(DocumentIndexer &&) = delete; - virtual char CharAt(int index) { + ~DocumentIndexer() override = default; + + char CharAt(Sci::Position index) const noexcept override { if (index < 0 || index >= end) return 0; else @@ -2304,51 +2719,65 @@ public: } }; -#ifdef CXX11_REGEX +#ifndef NO_CXX11_REGEX -class ByteIterator : public std::iterator { +class ByteIterator { public: + typedef std::bidirectional_iterator_tag iterator_category; + typedef char value_type; + typedef ptrdiff_t difference_type; + typedef char* pointer; + typedef char& reference; + const Document *doc; - Position position; - ByteIterator(const Document *doc_ = 0, Position position_ = 0) : doc(doc_), position(position_) { + Sci::Position position; + + ByteIterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept : + doc(doc_), position(position_) { } - ByteIterator(const ByteIterator &other) { + ByteIterator(const ByteIterator &other) noexcept { doc = other.doc; position = other.position; } - ByteIterator &operator=(const ByteIterator &other) { + ByteIterator(ByteIterator &&other) noexcept { + doc = other.doc; + position = other.position; + } + ByteIterator &operator=(const ByteIterator &other) noexcept { if (this != &other) { doc = other.doc; position = other.position; } return *this; } - char operator*() const { + ByteIterator &operator=(ByteIterator &&) noexcept = default; + ~ByteIterator() = default; + char operator*() const noexcept { return doc->CharAt(position); } - ByteIterator &operator++() { + ByteIterator &operator++() noexcept { position++; return *this; } - ByteIterator operator++(int) { + ByteIterator operator++(int) noexcept { ByteIterator retVal(*this); position++; return retVal; } - ByteIterator &operator--() { + ByteIterator &operator--() noexcept { position--; return *this; } - bool operator==(const ByteIterator &other) const { + bool operator==(const ByteIterator &other) const noexcept { return doc == other.doc && position == other.position; } - bool operator!=(const ByteIterator &other) const { + bool operator!=(const ByteIterator &other) const noexcept { return doc != other.doc || position != other.position; } - int Pos() const { + Sci::Position Pos() const noexcept { return position; } - int PosRoundUp() const { + Sci::Position PosRoundUp() const noexcept { return position; } }; @@ -2369,25 +2798,31 @@ public: // On Windows, report non-BMP characters as 2 separate surrogates as that // matches wregex since it is based on wchar_t. -class UTF8Iterator : public std::iterator { +class UTF8Iterator { // These 3 fields determine the iterator position and are used for comparisons const Document *doc; - Position position; + Sci::Position position; size_t characterIndex; // Remaining fields are derived from the determining fields so are excluded in comparisons unsigned int lenBytes; size_t lenCharacters; wchar_t buffered[2]; public: - UTF8Iterator(const Document *doc_ = 0, Position position_ = 0) : - doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0) { + typedef std::bidirectional_iterator_tag iterator_category; + typedef wchar_t value_type; + typedef ptrdiff_t difference_type; + typedef wchar_t* pointer; + typedef wchar_t& reference; + + UTF8Iterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept : + doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0), buffered{} { buffered[0] = 0; buffered[1] = 0; if (doc) { ReadCharacter(); } } - UTF8Iterator(const UTF8Iterator &other) { + UTF8Iterator(const UTF8Iterator &other) noexcept : buffered{} { doc = other.doc; position = other.position; characterIndex = other.characterIndex; @@ -2396,7 +2831,8 @@ public: buffered[0] = other.buffered[0]; buffered[1] = other.buffered[1]; } - UTF8Iterator &operator=(const UTF8Iterator &other) { + UTF8Iterator(UTF8Iterator &&other) noexcept = default; + UTF8Iterator &operator=(const UTF8Iterator &other) noexcept { if (this != &other) { doc = other.doc; position = other.position; @@ -2408,11 +2844,13 @@ public: } return *this; } - wchar_t operator*() const { + UTF8Iterator &operator=(UTF8Iterator &&) noexcept = default; + ~UTF8Iterator() = default; + wchar_t operator*() const noexcept { assert(lenCharacters != 0); return buffered[characterIndex]; } - UTF8Iterator &operator++() { + UTF8Iterator &operator++() noexcept { if ((characterIndex + 1) < (lenCharacters)) { characterIndex++; } else { @@ -2422,7 +2860,7 @@ public: } return *this; } - UTF8Iterator operator++(int) { + UTF8Iterator operator++(int) noexcept { UTF8Iterator retVal(*this); if ((characterIndex + 1) < (lenCharacters)) { characterIndex++; @@ -2433,7 +2871,7 @@ public: } return retVal; } - UTF8Iterator &operator--() { + UTF8Iterator &operator--() noexcept { if (characterIndex) { characterIndex--; } else { @@ -2443,30 +2881,30 @@ public: } return *this; } - bool operator==(const UTF8Iterator &other) const { + bool operator==(const UTF8Iterator &other) const noexcept { // Only test the determining fields, not the character widths and values derived from this return doc == other.doc && position == other.position && characterIndex == other.characterIndex; } - bool operator!=(const UTF8Iterator &other) const { + bool operator!=(const UTF8Iterator &other) const noexcept { // Only test the determining fields, not the character widths and values derived from this return doc != other.doc || position != other.position || characterIndex != other.characterIndex; } - int Pos() const { + Sci::Position Pos() const noexcept { return position; } - int PosRoundUp() const { + Sci::Position PosRoundUp() const noexcept { if (characterIndex) return position + lenBytes; // Force to end of character else return position; } private: - void ReadCharacter() { - Document::CharacterExtracted charExtracted = doc->ExtractCharacter(position); + void ReadCharacter() noexcept { + const Document::CharacterExtracted charExtracted = doc->ExtractCharacter(position); lenBytes = charExtracted.widthBytes; if (charExtracted.character == unicodeReplacementChar) { lenCharacters = 1; @@ -2481,57 +2919,67 @@ private: // On Unix, report non-BMP characters as single characters -class UTF8Iterator : public std::iterator { +class UTF8Iterator { const Document *doc; - Position position; + Sci::Position position; public: - UTF8Iterator(const Document *doc_=0, Position position_=0) : doc(doc_), position(position_) { + typedef std::bidirectional_iterator_tag iterator_category; + typedef wchar_t value_type; + typedef ptrdiff_t difference_type; + typedef wchar_t* pointer; + typedef wchar_t& reference; + + UTF8Iterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept : + doc(doc_), position(position_) { } - UTF8Iterator(const UTF8Iterator &other) { + UTF8Iterator(const UTF8Iterator &other) noexcept { doc = other.doc; position = other.position; } - UTF8Iterator &operator=(const UTF8Iterator &other) { + UTF8Iterator(UTF8Iterator &&other) noexcept = default; + UTF8Iterator &operator=(const UTF8Iterator &other) noexcept { if (this != &other) { doc = other.doc; position = other.position; } return *this; } - wchar_t operator*() const { - Document::CharacterExtracted charExtracted = doc->ExtractCharacter(position); + UTF8Iterator &operator=(UTF8Iterator &&) noexcept = default; + ~UTF8Iterator() = default; + wchar_t operator*() const noexcept { + const Document::CharacterExtracted charExtracted = doc->ExtractCharacter(position); return charExtracted.character; } - UTF8Iterator &operator++() { + UTF8Iterator &operator++() noexcept { position = doc->NextPosition(position, 1); return *this; } - UTF8Iterator operator++(int) { + UTF8Iterator operator++(int) noexcept { UTF8Iterator retVal(*this); position = doc->NextPosition(position, 1); return retVal; } - UTF8Iterator &operator--() { + UTF8Iterator &operator--() noexcept { position = doc->NextPosition(position, -1); return *this; } - bool operator==(const UTF8Iterator &other) const { + bool operator==(const UTF8Iterator &other) const noexcept { return doc == other.doc && position == other.position; } - bool operator!=(const UTF8Iterator &other) const { + bool operator!=(const UTF8Iterator &other) const noexcept { return doc != other.doc || position != other.position; } - int Pos() const { - return position; + Sci::Position Pos() const noexcept { + return position; } - int PosRoundUp() const { - return position; + Sci::Position PosRoundUp() const noexcept { + return position; } }; #endif -std::regex_constants::match_flag_type MatchFlags(const Document *doc, int startPos, int endPos) { +std::regex_constants::match_flag_type MatchFlags(const Document *doc, Sci::Position startPos, Sci::Position endPos) { std::regex_constants::match_flag_type flagsMatch = std::regex_constants::match_default; if (!doc->IsLineStartPosition(startPos)) flagsMatch |= std::regex_constants::match_not_bol; @@ -2542,19 +2990,24 @@ std::regex_constants::match_flag_type MatchFlags(const Document *doc, int startP template bool MatchOnLines(const Document *doc, const Regex ®exp, const RESearchRange &resr, RESearch &search) { - bool matched = false; std::match_results match; - // MSVC and libc++ have problems with ^ and $ matching line ends inside a range - // If they didn't then the line by line iteration could be removed for the forwards - // case and replaced with the following 4 lines: - // Iterator uiStart(doc, startPos); - // Iterator uiEnd(doc, endPos); - // flagsMatch = MatchFlags(doc, startPos, endPos); - // matched = std::regex_search(uiStart, uiEnd, match, regexp, flagsMatch); - + // MSVC and libc++ have problems with ^ and $ matching line ends inside a range. + // CRLF line ends are also a problem as ^ and $ only treat LF as a line end. + // The std::regex::multiline option was added to C++17 to improve behaviour but + // has not been implemented by compiler runtimes with MSVC always in multiline + // mode and libc++ and libstdc++ always in single-line mode. + // If multiline regex worked well then the line by line iteration could be removed + // for the forwards case and replaced with the following 4 lines: +#ifdef REGEX_MULTILINE + Iterator itStart(doc, resr.startPos); + Iterator itEnd(doc, resr.endPos); + const std::regex_constants::match_flag_type flagsMatch = MatchFlags(doc, resr.startPos, resr.endPos); + const bool matched = std::regex_search(itStart, itEnd, match, regexp, flagsMatch); +#else // Line by line. - for (int line = resr.lineRangeStart; line != resr.lineRangeBreak; line += resr.increment) { + bool matched = false; + for (Sci::Line line = resr.lineRangeStart; line != resr.lineRangeBreak; line += resr.increment) { const Range lineRange = resr.LineRange(line); Iterator itStart(doc, lineRange.start); Iterator itEnd(doc, lineRange.end); @@ -2581,13 +3034,14 @@ bool MatchOnLines(const Document *doc, const Regex ®exp, const RESearchRange break; } } +#endif if (matched) { for (size_t co = 0; co < match.size(); co++) { search.bopat[co] = match[co].first.Pos(); search.eopat[co] = match[co].second.PosRoundUp(); - size_t lenMatch = search.eopat[co] - search.bopat[co]; + const Sci::Position lenMatch = search.eopat[co] - search.bopat[co]; search.pat[co].resize(lenMatch); - for (size_t iPos = 0; iPos < lenMatch; iPos++) { + for (Sci::Position iPos = 0; iPos < lenMatch; iPos++) { search.pat[co][iPos] = doc->CharAt(iPos + search.bopat[co]); } } @@ -2595,11 +3049,13 @@ bool MatchOnLines(const Document *doc, const Regex ®exp, const RESearchRange return matched; } -long Cxx11RegexFindText(Document *doc, int minPos, int maxPos, const char *s, - bool caseSensitive, int *length, RESearch &search) { +Sci::Position Cxx11RegexFindText(const Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s, + bool caseSensitive, Sci::Position *length, RESearch &search) { const RESearchRange resr(doc, minPos, maxPos); +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) try { - //ElapsedTime et; +#endif + //ElapsedPeriod ep; std::regex::flag_type flagsRe = std::regex::ECMAScript; // Flags that apper to have no effect: // | std::regex::collate | std::regex::extended; @@ -2611,23 +3067,9 @@ long Cxx11RegexFindText(Document *doc, int minPos, int maxPos, const char *s, bool matched = false; if (SC_CP_UTF8 == doc->dbcsCodePage) { - unsigned int lenS = static_cast(strlen(s)); - std::vector ws(lenS + 1); -#if WCHAR_T_IS_16 - size_t outLen = UTF16FromUTF8(s, lenS, &ws[0], lenS); -#else - size_t outLen = UTF32FromUTF8(s, lenS, reinterpret_cast(&ws[0]), lenS); -#endif - ws[outLen] = 0; + const std::wstring ws = WStringFromUTF8(s, strlen(s)); std::wregex regexp; -#if defined(__APPLE__) - // Using a UTF-8 locale doesn't change to Unicode over a byte buffer so '.' - // is one byte not one character. - // However, on OS X this makes wregex act as Unicode - std::locale localeU("en_US.UTF-8"); - regexp.imbue(localeU); -#endif - regexp.assign(&ws[0], flagsRe); + regexp.assign(ws, flagsRe); matched = MatchOnLines(doc, regexp, resr, search); } else { @@ -2636,7 +3078,7 @@ long Cxx11RegexFindText(Document *doc, int minPos, int maxPos, const char *s, matched = MatchOnLines(doc, regexp, resr, search); } - int posMatch = -1; + Sci::Position posMatch = -1; if (matched) { posMatch = search.bopat[0]; *length = search.eopat[0] - search.bopat[0]; @@ -2644,9 +3086,10 @@ long Cxx11RegexFindText(Document *doc, int minPos, int maxPos, const char *s, // Example - search in doc/ScintillaHistory.html for // [[:upper:]]eta[[:space:]] // On MacBook, normally around 1 second but with locale imbued -> 14 seconds. - //double durSearch = et.Duration(true); + //const double durSearch = ep.Duration(true); //Platform::DebugPrintf("Search:%9.6g \n", durSearch); return posMatch; +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) } catch (std::regex_error &) { // Failed to create regular expression throw RegexError(); @@ -2654,17 +3097,18 @@ long Cxx11RegexFindText(Document *doc, int minPos, int maxPos, const char *s, // Failed in some other way return -1; } +#endif } #endif } -long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s, +Sci::Position BuiltinRegex::FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s, bool caseSensitive, bool, bool, int flags, - int *length) { + Sci::Position *length) { -#ifdef CXX11_REGEX +#ifndef NO_CXX11_REGEX if (flags & SCFIND_CXX11REGEX) { return Cxx11RegexFindText(doc, minPos, maxPos, s, caseSensitive, length, search); @@ -2683,38 +3127,40 @@ long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s // Replace first '.' with '-' in each property file variable reference: // Search: \$(\([A-Za-z0-9_-]+\)\.\([A-Za-z0-9_.]+\)) // Replace: $(\1-\2) - int pos = -1; - int lenRet = 0; + Sci::Position pos = -1; + Sci::Position lenRet = 0; + const bool searchforLineStart = s[0] == '^'; const char searchEnd = s[*length - 1]; const char searchEndPrev = (*length > 1) ? s[*length - 2] : '\0'; - for (int line = resr.lineRangeStart; line != resr.lineRangeBreak; line += resr.increment) { - int startOfLine = doc->LineStart(line); - int endOfLine = doc->LineEnd(line); + const bool searchforLineEnd = (searchEnd == '$') && (searchEndPrev != '\\'); + for (Sci::Line line = resr.lineRangeStart; line != resr.lineRangeBreak; line += resr.increment) { + Sci::Position startOfLine = doc->LineStart(line); + Sci::Position endOfLine = doc->LineEnd(line); if (resr.increment == 1) { if (line == resr.lineRangeStart) { - if ((resr.startPos != startOfLine) && (s[0] == '^')) + if ((resr.startPos != startOfLine) && searchforLineStart) continue; // Can't match start of line if start position after start of line startOfLine = resr.startPos; } if (line == resr.lineRangeEnd) { - if ((resr.endPos != endOfLine) && (searchEnd == '$') && (searchEndPrev != '\\')) + if ((resr.endPos != endOfLine) && searchforLineEnd) continue; // Can't match end of line if end position before end of line endOfLine = resr.endPos; } } else { if (line == resr.lineRangeEnd) { - if ((resr.endPos != startOfLine) && (s[0] == '^')) + if ((resr.endPos != startOfLine) && searchforLineStart) continue; // Can't match start of line if end position after start of line startOfLine = resr.endPos; } if (line == resr.lineRangeStart) { - if ((resr.startPos != endOfLine) && (searchEnd == '$') && (searchEndPrev != '\\')) + if ((resr.startPos != endOfLine) && searchforLineEnd) continue; // Can't match end of line if start position before end of line endOfLine = resr.startPos; } } - DocumentIndexer di(doc, endOfLine); + const DocumentIndexer di(doc, endOfLine); int success = search.Execute(di, startOfLine, endOfLine); if (success) { pos = search.bopat[0]; @@ -2722,7 +3168,7 @@ long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s search.eopat[0] = doc->MovePositionOutsideChar(search.eopat[0], 1, false); lenRet = search.eopat[0] - search.bopat[0]; // There can be only one start of a line, so no need to look for last match in line - if ((resr.increment == -1) && (s[0] != '^')) { + if ((resr.increment == -1) && !searchforLineStart) { // Check for the last match on this line. int repetitions = 1000; // Break out of infinite loop while (success && (search.eopat[0] <= endOfLine) && (repetitions--)) { @@ -2744,15 +3190,15 @@ long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s return pos; } -const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, int *length) { +const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) { substituted.clear(); - DocumentIndexer di(doc, doc->Length()); + const DocumentIndexer di(doc, doc->Length()); search.GrabMatches(di); - for (int j = 0; j < *length; j++) { + for (Sci::Position j = 0; j < *length; j++) { if (text[j] == '\\') { if (text[j + 1] >= '0' && text[j + 1] <= '9') { - unsigned int patNum = text[j + 1] - '0'; - unsigned int len = search.eopat[patNum] - search.bopat[patNum]; + const unsigned int patNum = text[j + 1] - '0'; + const Sci::Position len = search.eopat[patNum] - search.bopat[patNum]; if (!search.pat[patNum].empty()) // Will be null if try for a match that did not occur substituted.append(search.pat[patNum].c_str(), len); j++; @@ -2792,24 +3238,14 @@ const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, substituted.push_back(text[j]); } } - *length = static_cast(substituted.length()); + *length = substituted.length(); return substituted.c_str(); } #ifndef SCI_OWNREGEX -#ifdef SCI_NAMESPACE - RegexSearchBase *Scintilla::CreateRegexSearch(CharClassify *charClassTable) { return new BuiltinRegex(charClassTable); } -#else - -RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable) { - return new BuiltinRegex(charClassTable); -} - -#endif - #endif diff --git a/dep/scintilla/scintilla-3.10.6/src/Document.h b/dep/scintilla/scintilla-3.10.6/src/Document.h new file mode 100644 index 00000000..f662dc99 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/Document.h @@ -0,0 +1,591 @@ +// Scintilla source code edit control +/** @file Document.h + ** Text document that handles notifications, DBCS, styling, words and end of line. + **/ +// Copyright 1998-2011 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef DOCUMENT_H +#define DOCUMENT_H + +namespace Scintilla { + +class DocWatcher; +class DocModification; +class Document; +class LineMarkers; +class LineLevels; +class LineState; +class LineAnnotation; + +enum EncodingFamily { efEightBit, efUnicode, efDBCS }; + +/** + * The range class represents a range of text in a document. + * The two values are not sorted as one end may be more significant than the other + * as is the case for the selection where the end position is the position of the caret. + * If either position is invalidPosition then the range is invalid and most operations will fail. + */ +class Range { +public: + Sci::Position start; + Sci::Position end; + + explicit Range(Sci::Position pos=0) noexcept : + start(pos), end(pos) { + } + Range(Sci::Position start_, Sci::Position end_) noexcept : + start(start_), end(end_) { + } + + bool operator==(const Range &other) const noexcept { + return (start == other.start) && (end == other.end); + } + + bool Valid() const noexcept { + return (start != Sci::invalidPosition) && (end != Sci::invalidPosition); + } + + Sci::Position First() const noexcept { + return (start <= end) ? start : end; + } + + Sci::Position Last() const noexcept { + return (start > end) ? start : end; + } + + // Is the position within the range? + bool Contains(Sci::Position pos) const noexcept { + if (start < end) { + return (pos >= start && pos <= end); + } else { + return (pos <= start && pos >= end); + } + } + + // Is the character after pos within the range? + bool ContainsCharacter(Sci::Position pos) const noexcept { + if (start < end) { + return (pos >= start && pos < end); + } else { + return (pos < start && pos >= end); + } + } + + bool Contains(Range other) const noexcept { + return Contains(other.start) && Contains(other.end); + } + + bool Overlaps(Range other) const noexcept { + return + Contains(other.start) || + Contains(other.end) || + other.Contains(start) || + other.Contains(end); + } +}; + +/** + * Interface class for regular expression searching + */ +class RegexSearchBase { +public: + virtual ~RegexSearchBase() {} + + virtual Sci::Position FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s, + bool caseSensitive, bool word, bool wordStart, int flags, Sci::Position *length) = 0; + + ///@return String with the substitutions, must remain valid until the next call or destruction + virtual const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) = 0; +}; + +/// Factory function for RegexSearchBase +extern RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable); + +struct StyledText { + size_t length; + const char *text; + bool multipleStyles; + size_t style; + const unsigned char *styles; + StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) noexcept : + length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) { + } + // Return number of bytes from start to before '\n' or end of text. + // Return 1 when start is outside text + size_t LineLength(size_t start) const noexcept { + size_t cur = start; + while ((cur < length) && (text[cur] != '\n')) + cur++; + return cur-start; + } + size_t StyleAt(size_t i) const noexcept { + return multipleStyles ? styles[i] : style; + } +}; + +class HighlightDelimiter { +public: + HighlightDelimiter() noexcept : isEnabled(false) { + Clear(); + } + + void Clear() noexcept { + beginFoldBlock = -1; + endFoldBlock = -1; + firstChangeableLineBefore = -1; + firstChangeableLineAfter = -1; + } + + bool NeedsDrawing(Sci::Line line) const { + return isEnabled && (line <= firstChangeableLineBefore || line >= firstChangeableLineAfter); + } + + bool IsFoldBlockHighlighted(Sci::Line line) const { + return isEnabled && beginFoldBlock != -1 && beginFoldBlock <= line && line <= endFoldBlock; + } + + bool IsHeadOfFoldBlock(Sci::Line line) const { + return beginFoldBlock == line && line < endFoldBlock; + } + + bool IsBodyOfFoldBlock(Sci::Line line) const { + return beginFoldBlock != -1 && beginFoldBlock < line && line < endFoldBlock; + } + + bool IsTailOfFoldBlock(Sci::Line line) const { + return beginFoldBlock != -1 && beginFoldBlock < line && line == endFoldBlock; + } + + Sci::Line beginFoldBlock; // Begin of current fold block + Sci::Line endFoldBlock; // End of current fold block + Sci::Line firstChangeableLineBefore; // First line that triggers repaint before starting line that determined current fold block + Sci::Line firstChangeableLineAfter; // First line that triggers repaint after starting line that determined current fold block + bool isEnabled; +}; + +constexpr int LevelNumber(int level) noexcept { + return level & SC_FOLDLEVELNUMBERMASK; +} + +class LexInterface { +protected: + Document *pdoc; + ILexer *instance; + bool performingStyle; ///< Prevent reentrance +public: + explicit LexInterface(Document *pdoc_) noexcept : pdoc(pdoc_), instance(nullptr), performingStyle(false) { + } + virtual ~LexInterface() { + } + void Colourise(Sci::Position start, Sci::Position end); + virtual int LineEndTypesSupported(); + bool UseContainerLexing() const noexcept { + return instance == nullptr; + } +}; + +struct RegexError : public std::runtime_error { + RegexError() : std::runtime_error("regex failure") {} +}; + +/** + * The ActionDuration class stores the average time taken for some action such as styling or + * wrapping a line. It is used to decide how many repetitions of that action can be performed + * on idle to maximize efficiency without affecting application responsiveness. + * The duration changes if the time for the action changes. For example, if a simple lexer is + * changed to a complex lexer. Changes are damped and clamped to avoid short periods of easy + * or difficult processing moving the value too far leading to inefficiency or poor user + * experience. + */ + +class ActionDuration { + double duration; + const double minDuration; + const double maxDuration; +public: + ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept; + void AddSample(size_t numberActions, double durationOfActions) noexcept; + double Duration() const noexcept; +}; + +/** + */ +class Document : PerLine, public IDocumentWithLineEnd, public ILoader { + +public: + /** Used to pair watcher pointer with user data. */ + struct WatcherWithUserData { + DocWatcher *watcher; + void *userData; + WatcherWithUserData(DocWatcher *watcher_=nullptr, void *userData_=nullptr) noexcept : + watcher(watcher_), userData(userData_) { + } + bool operator==(const WatcherWithUserData &other) const noexcept { + return (watcher == other.watcher) && (userData == other.userData); + } + }; + +private: + int refCount; + CellBuffer cb; + CharClassify charClass; + CharacterCategoryMap charMap; + std::unique_ptr pcf; + Sci::Position endStyled; + int styleClock; + int enteredModification; + int enteredStyling; + int enteredReadOnlyCount; + + bool insertionSet; + std::string insertion; + + std::vector watchers; + + // ldSize is not real data - it is for dimensions and loops + enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize }; + std::unique_ptr perLineData[ldSize]; + LineMarkers *Markers() const; + LineLevels *Levels() const; + LineState *States() const; + LineAnnotation *Margins() const; + LineAnnotation *Annotations() const; + + bool matchesValid; + std::unique_ptr regex; + std::unique_ptr pli; + +public: + + struct CharacterExtracted { + unsigned int character; + unsigned int widthBytes; + CharacterExtracted(unsigned int character_, unsigned int widthBytes_) noexcept : + character(character_), widthBytes(widthBytes_) { + } + // For DBCS characters turn 2 bytes into an int + static CharacterExtracted DBCS(unsigned char lead, unsigned char trail) noexcept { + return CharacterExtracted((lead << 8) | trail, 2); + } + }; + + int eolMode; + /// Can also be SC_CP_UTF8 to enable UTF-8 mode + int dbcsCodePage; + int lineEndBitSet; + int tabInChars; + int indentInChars; + int actualIndentInChars; + bool useTabs; + bool tabIndents; + bool backspaceUnindents; + ActionDuration durationStyleOneLine; + + std::unique_ptr decorations; + + Document(int options); + // Deleted so Document objects can not be copied. + Document(const Document &) = delete; + Document(Document &&) = delete; + void operator=(const Document &) = delete; + Document &operator=(Document &&) = delete; + ~Document() override; + + int AddRef(); + int SCI_METHOD Release() override; + + // From PerLine + void Init() override; + void InsertLine(Sci::Line line) override; + void RemoveLine(Sci::Line line) override; + + int LineEndTypesSupported() const; + bool SetDBCSCodePage(int dbcsCodePage_); + int GetLineEndTypesAllowed() const { return cb.GetLineEndTypes(); } + bool SetLineEndTypesAllowed(int lineEndBitSet_); + int GetLineEndTypesActive() const { return cb.GetLineEndTypes(); } + + int SCI_METHOD Version() const override { + return dvLineEnd; + } + + void SCI_METHOD SetErrorStatus(int status) override; + + Sci_Position SCI_METHOD LineFromPosition(Sci_Position pos) const override; + Sci::Line SciLineFromPosition(Sci::Position pos) const noexcept; // Avoids casting LineFromPosition + Sci::Position ClampPositionIntoDocument(Sci::Position pos) const; + bool ContainsLineEnd(const char *s, Sci::Position length) const { return cb.ContainsLineEnd(s, length); } + bool IsCrLf(Sci::Position pos) const; + int LenChar(Sci::Position pos); + bool InGoodUTF8(Sci::Position pos, Sci::Position &start, Sci::Position &end) const noexcept; + Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd=true) const; + Sci::Position NextPosition(Sci::Position pos, int moveDir) const noexcept; + bool NextCharacter(Sci::Position &pos, int moveDir) const noexcept; // Returns true if pos changed + Document::CharacterExtracted CharacterAfter(Sci::Position position) const; + Document::CharacterExtracted CharacterBefore(Sci::Position position) const; + Sci_Position SCI_METHOD GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const override; + Sci::Position GetRelativePositionUTF16(Sci::Position positionStart, Sci::Position characterOffset) const; + int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const override; + int SCI_METHOD CodePage() const override; + bool SCI_METHOD IsDBCSLeadByte(char ch) const override; + bool IsDBCSLeadByteNoExcept(char ch) const noexcept; + bool IsDBCSLeadByteInvalid(char ch) const noexcept; + bool IsDBCSTrailByteInvalid(char ch) const noexcept; + int DBCSDrawBytes(const char *text, int len) const noexcept; + int SafeSegment(const char *text, int length, int lengthSegment) const noexcept; + EncodingFamily CodePageFamily() const noexcept; + + // Gateways to modifying document + void ModifiedAt(Sci::Position pos) noexcept; + void CheckReadOnly(); + bool DeleteChars(Sci::Position pos, Sci::Position len); + Sci::Position InsertString(Sci::Position position, const char *s, Sci::Position insertLength); + void ChangeInsertion(const char *s, Sci::Position length); + int SCI_METHOD AddData(const char *data, Sci_Position length) override; + void * SCI_METHOD ConvertToDocument() override; + Sci::Position Undo(); + Sci::Position Redo(); + bool CanUndo() const { return cb.CanUndo(); } + bool CanRedo() const { return cb.CanRedo(); } + void DeleteUndoHistory() { cb.DeleteUndoHistory(); } + bool SetUndoCollection(bool collectUndo) { + return cb.SetUndoCollection(collectUndo); + } + bool IsCollectingUndo() const { return cb.IsCollectingUndo(); } + void BeginUndoAction() { cb.BeginUndoAction(); } + void EndUndoAction() { cb.EndUndoAction(); } + void AddUndoAction(Sci::Position token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); } + void SetSavePoint(); + bool IsSavePoint() const { return cb.IsSavePoint(); } + + void TentativeStart() { cb.TentativeStart(); } + void TentativeCommit() { cb.TentativeCommit(); } + void TentativeUndo(); + bool TentativeActive() const { return cb.TentativeActive(); } + + const char * SCI_METHOD BufferPointer() override { return cb.BufferPointer(); } + const char *RangePointer(Sci::Position position, Sci::Position rangeLength) { return cb.RangePointer(position, rangeLength); } + Sci::Position GapPosition() const { return cb.GapPosition(); } + + int SCI_METHOD GetLineIndentation(Sci_Position line) override; + Sci::Position SetLineIndentation(Sci::Line line, Sci::Position indent); + Sci::Position GetLineIndentPosition(Sci::Line line) const; + Sci::Position GetColumn(Sci::Position pos); + Sci::Position CountCharacters(Sci::Position startPos, Sci::Position endPos) const; + Sci::Position CountUTF16(Sci::Position startPos, Sci::Position endPos) const; + Sci::Position FindColumn(Sci::Line line, Sci::Position column); + void Indent(bool forwards, Sci::Line lineBottom, Sci::Line lineTop); + static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted); + void ConvertLineEnds(int eolModeSet); + void SetReadOnly(bool set) { cb.SetReadOnly(set); } + bool IsReadOnly() const { return cb.IsReadOnly(); } + bool IsLarge() const { return cb.IsLarge(); } + int Options() const; + + void DelChar(Sci::Position pos); + void DelCharBack(Sci::Position pos); + + char CharAt(Sci::Position position) const noexcept { return cb.CharAt(position); } + void SCI_METHOD GetCharRange(char *buffer, Sci_Position position, Sci_Position lengthRetrieve) const override { + cb.GetCharRange(buffer, position, lengthRetrieve); + } + char SCI_METHOD StyleAt(Sci_Position position) const override { return cb.StyleAt(position); } + int StyleIndexAt(Sci_Position position) const noexcept { return static_cast(cb.StyleAt(position)); } + void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const { + cb.GetStyleRange(buffer, position, lengthRetrieve); + } + int GetMark(Sci::Line line) const; + Sci::Line MarkerNext(Sci::Line lineStart, int mask) const; + int AddMark(Sci::Line line, int markerNum); + void AddMarkSet(Sci::Line line, int valueSet); + void DeleteMark(Sci::Line line, int markerNum); + void DeleteMarkFromHandle(int markerHandle); + void DeleteAllMarks(int markerNum); + Sci::Line LineFromHandle(int markerHandle) const; + Sci_Position SCI_METHOD LineStart(Sci_Position line) const override; + bool IsLineStartPosition(Sci::Position position) const; + Sci_Position SCI_METHOD LineEnd(Sci_Position line) const override; + Sci::Position LineEndPosition(Sci::Position position) const; + bool IsLineEndPosition(Sci::Position position) const; + bool IsPositionInLineEnd(Sci::Position position) const; + Sci::Position VCHomePosition(Sci::Position position) const; + Sci::Position IndexLineStart(Sci::Line line, int lineCharacterIndex) const; + Sci::Line LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const; + + int SCI_METHOD SetLevel(Sci_Position line, int level) override; + int SCI_METHOD GetLevel(Sci_Position line) const override; + void ClearLevels(); + Sci::Line GetLastChild(Sci::Line lineParent, int level=-1, Sci::Line lastLine=-1); + Sci::Line GetFoldParent(Sci::Line line) const; + void GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine); + + Sci::Position ExtendWordSelect(Sci::Position pos, int delta, bool onlyWordCharacters=false) const; + Sci::Position NextWordStart(Sci::Position pos, int delta) const; + Sci::Position NextWordEnd(Sci::Position pos, int delta) const; + Sci_Position SCI_METHOD Length() const override { return cb.Length(); } + void Allocate(Sci::Position newSize) { cb.Allocate(newSize); } + + CharacterExtracted ExtractCharacter(Sci::Position position) const noexcept; + + bool IsWordStartAt(Sci::Position pos) const; + bool IsWordEndAt(Sci::Position pos) const; + bool IsWordAt(Sci::Position start, Sci::Position end) const; + + bool MatchesWordOptions(bool word, bool wordStart, Sci::Position pos, Sci::Position length) const; + bool HasCaseFolder() const noexcept; + void SetCaseFolder(CaseFolder *pcf_); + Sci::Position FindText(Sci::Position minPos, Sci::Position maxPos, const char *search, int flags, Sci::Position *length); + const char *SubstituteByPosition(const char *text, Sci::Position *length); + int LineCharacterIndex() const; + void AllocateLineCharacterIndex(int lineCharacterIndex); + void ReleaseLineCharacterIndex(int lineCharacterIndex); + Sci::Line LinesTotal() const noexcept; + + void SetDefaultCharClasses(bool includeWordClass); + void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass); + int GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer) const; + void SetCharacterCategoryOptimization(int countCharacters); + int CharacterCategoryOptimization() const noexcept; + void SCI_METHOD StartStyling(Sci_Position position, char mask) override; + bool SCI_METHOD SetStyleFor(Sci_Position length, char style) override; + bool SCI_METHOD SetStyles(Sci_Position length, const char *styles) override; + Sci::Position GetEndStyled() const noexcept { return endStyled; } + void EnsureStyledTo(Sci::Position pos); + void StyleToAdjustingLineDuration(Sci::Position pos); + void LexerChanged(); + int GetStyleClock() const noexcept { return styleClock; } + void IncrementStyleClock() noexcept; + void SCI_METHOD DecorationSetCurrentIndicator(int indicator) override; + void SCI_METHOD DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength) override; + LexInterface *GetLexInterface() const; + void SetLexInterface(LexInterface *pLexInterface); + + int SCI_METHOD SetLineState(Sci_Position line, int state) override; + int SCI_METHOD GetLineState(Sci_Position line) const override; + Sci::Line GetMaxLineState() const; + void SCI_METHOD ChangeLexerState(Sci_Position start, Sci_Position end) override; + + StyledText MarginStyledText(Sci::Line line) const; + void MarginSetStyle(Sci::Line line, int style); + void MarginSetStyles(Sci::Line line, const unsigned char *styles); + void MarginSetText(Sci::Line line, const char *text); + void MarginClearAll(); + + StyledText AnnotationStyledText(Sci::Line line) const; + void AnnotationSetText(Sci::Line line, const char *text); + void AnnotationSetStyle(Sci::Line line, int style); + void AnnotationSetStyles(Sci::Line line, const unsigned char *styles); + int AnnotationLines(Sci::Line line) const; + void AnnotationClearAll(); + + bool AddWatcher(DocWatcher *watcher, void *userData); + bool RemoveWatcher(DocWatcher *watcher, void *userData); + + CharClassify::cc WordCharacterClass(unsigned int ch) const; + bool IsWordPartSeparator(unsigned int ch) const; + Sci::Position WordPartLeft(Sci::Position pos) const; + Sci::Position WordPartRight(Sci::Position pos) const; + Sci::Position ExtendStyleRange(Sci::Position pos, int delta, bool singleLine = false); + bool IsWhiteLine(Sci::Line line) const; + Sci::Position ParaUp(Sci::Position pos) const; + Sci::Position ParaDown(Sci::Position pos) const; + int IndentSize() const noexcept { return actualIndentInChars; } + Sci::Position BraceMatch(Sci::Position position, Sci::Position maxReStyle); + +private: + void NotifyModifyAttempt(); + void NotifySavePoint(bool atSavePoint); + void NotifyModified(DocModification mh); +}; + +class UndoGroup { + Document *pdoc; + bool groupNeeded; +public: + UndoGroup(Document *pdoc_, bool groupNeeded_=true) : + pdoc(pdoc_), groupNeeded(groupNeeded_) { + if (groupNeeded) { + pdoc->BeginUndoAction(); + } + } + // Deleted so UndoGroup objects can not be copied. + UndoGroup(const UndoGroup &) = delete; + UndoGroup(UndoGroup &&) = delete; + void operator=(const UndoGroup &) = delete; + UndoGroup &operator=(UndoGroup &&) = delete; + ~UndoGroup() { + if (groupNeeded) { + pdoc->EndUndoAction(); + } + } + bool Needed() const noexcept { + return groupNeeded; + } +}; + + +/** + * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the + * scope of the change. + * If the DocWatcher is a document view then this can be used to optimise screen updating. + */ +class DocModification { +public: + int modificationType; + Sci::Position position; + Sci::Position length; + Sci::Line linesAdded; /**< Negative if lines deleted. */ + const char *text; /**< Only valid for changes to text, not for changes to style. */ + Sci::Line line; + int foldLevelNow; + int foldLevelPrev; + Sci::Line annotationLinesAdded; + Sci::Position token; + + DocModification(int modificationType_, Sci::Position position_=0, Sci::Position length_=0, + Sci::Line linesAdded_=0, const char *text_=nullptr, Sci::Line line_=0) noexcept : + modificationType(modificationType_), + position(position_), + length(length_), + linesAdded(linesAdded_), + text(text_), + line(line_), + foldLevelNow(0), + foldLevelPrev(0), + annotationLinesAdded(0), + token(0) {} + + DocModification(int modificationType_, const Action &act, Sci::Line linesAdded_=0) noexcept : + modificationType(modificationType_), + position(act.position), + length(act.lenData), + linesAdded(linesAdded_), + text(act.data.get()), + line(0), + foldLevelNow(0), + foldLevelPrev(0), + annotationLinesAdded(0), + token(0) {} +}; + +/** + * A class that wants to receive notifications from a Document must be derived from DocWatcher + * and implement the notification methods. It can then be added to the watcher list with AddWatcher. + */ +class DocWatcher { +public: + virtual ~DocWatcher() {} + + virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0; + virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0; + virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0; + virtual void NotifyDeleted(Document *doc, void *userData) noexcept = 0; + virtual void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos) = 0; + virtual void NotifyLexerChanged(Document *doc, void *userData) = 0; + virtual void NotifyErrorOccurred(Document *doc, void *userData, int status) = 0; +}; + +} + +#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/EditModel.cxx b/dep/scintilla/scintilla-3.10.6/src/EditModel.cxx similarity index 53% rename from dep/scintilla/scintilla-3.6.0/src/EditModel.cxx rename to dep/scintilla/scintilla-3.10.6/src/EditModel.cxx index 35903c6b..99520f3c 100644 --- a/dep/scintilla/scintilla-3.6.0/src/EditModel.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/EditModel.cxx @@ -5,12 +5,11 @@ // Copyright 1998-2014 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -21,11 +20,14 @@ #include "Platform.h" +#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" -#include "StringCopy.h" +#include "CharacterCategory.h" + #include "Position.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -33,7 +35,6 @@ #include "CellBuffer.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -46,33 +47,51 @@ #include "PositionCache.h" #include "EditModel.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif Caret::Caret() : active(false), on(false), period(500) {} -EditModel::EditModel() { +EditModel::EditModel() : braces{} { inOverstrike = false; xOffset = 0; trackLineWidth = false; - posDrag = SelectionPosition(invalidPosition); - braces[0] = invalidPosition; - braces[1] = invalidPosition; + posDrag = SelectionPosition(Sci::invalidPosition); + braces[0] = Sci::invalidPosition; + braces[1] = Sci::invalidPosition; bracesMatchStyle = STYLE_BRACEBAD; highlightGuideColumn = 0; primarySelection = true; imeInteraction = imeWindowed; foldFlags = 0; - hotspot = Range(invalidPosition); - hoverIndicatorPos = invalidPosition; + foldDisplayTextStyle = SC_FOLDDISPLAYTEXT_HIDDEN; + hotspot = Range(Sci::invalidPosition); + hoverIndicatorPos = Sci::invalidPosition; wrapWidth = LineLayout::wrapWidthInfinite; - pdoc = new Document(); + pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT); pdoc->AddRef(); + pcs = ContractionStateCreate(pdoc->IsLarge()); } EditModel::~EditModel() { pdoc->Release(); - pdoc = 0; + pdoc = nullptr; } + +void EditModel::SetDefaultFoldDisplayText(const char *text) { + defaultFoldDisplayText = IsNullOrEmpty(text) ? UniqueString() : UniqueStringCopy(text); +} + +const char *EditModel::GetDefaultFoldDisplayText() const noexcept { + return defaultFoldDisplayText.get(); +} + +const char *EditModel::GetFoldDisplayText(Sci::Line lineDoc) const { + if (foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_HIDDEN || pcs->GetExpanded(lineDoc)) { + return nullptr; + } + + const char *text = pcs->GetFoldDisplayText(lineDoc); + return text ? text : defaultFoldDisplayText.get(); +} + diff --git a/dep/scintilla/scintilla-3.6.0/src/EditModel.h b/dep/scintilla/scintilla-3.10.6/src/EditModel.h similarity index 54% rename from dep/scintilla/scintilla-3.6.0/src/EditModel.h rename to dep/scintilla/scintilla-3.10.6/src/EditModel.h index 33c1ac0d..ab5c23cd 100644 --- a/dep/scintilla/scintilla-3.6.0/src/EditModel.h +++ b/dep/scintilla/scintilla-3.10.6/src/EditModel.h @@ -8,9 +8,7 @@ #ifndef EDITMODEL_H #define EDITMODEL_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif /** */ @@ -24,10 +22,6 @@ public: }; class EditModel { - // Private so EditModel objects can not be copied - explicit EditModel(const EditModel &); - EditModel &operator=(const EditModel &); - public: bool inOverstrike; int xOffset; ///< Horizontal scrolled amount in pixels @@ -36,19 +30,21 @@ public: SpecialRepresentations reprs; Caret caret; SelectionPosition posDrag; - Position braces[2]; + Sci::Position braces[2]; int bracesMatchStyle; int highlightGuideColumn; Selection sel; bool primarySelection; - enum IMEInteraction { imeWindowed, imeInline } imeInteraction; + enum IMEInteraction { imeWindowed, imeInline } imeInteraction; int foldFlags; - ContractionState cs; + int foldDisplayTextStyle; + UniqueString defaultFoldDisplayText; + std::unique_ptr pcs; // Hotspot support Range hotspot; - int hoverIndicatorPos; + Sci::Position hoverIndicatorPos; // Wrapping support int wrapWidth; @@ -56,15 +52,21 @@ public: Document *pdoc; EditModel(); + // Deleted so EditModel objects can not be copied. + EditModel(const EditModel &) = delete; + EditModel(EditModel &&) = delete; + EditModel &operator=(const EditModel &) = delete; + EditModel &operator=(EditModel &&) = delete; virtual ~EditModel(); - virtual int TopLineOfMain() const = 0; + virtual Sci::Line TopLineOfMain() const = 0; virtual Point GetVisibleOriginInMain() const = 0; - virtual int LinesOnScreen() const = 0; - virtual Range GetHotSpotRange() const = 0; + virtual Sci::Line LinesOnScreen() const = 0; + virtual Range GetHotSpotRange() const noexcept = 0; + void SetDefaultFoldDisplayText(const char *text); + const char *GetDefaultFoldDisplayText() const noexcept; + const char *GetFoldDisplayText(Sci::Line lineDoc) const; }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/EditView.cxx b/dep/scintilla/scintilla-3.10.6/src/EditView.cxx similarity index 62% rename from dep/scintilla/scintilla-3.6.0/src/EditView.cxx rename to dep/scintilla/scintilla-3.10.6/src/EditView.cxx index f8912a99..fdcd9f28 100644 --- a/dep/scintilla/scintilla-3.6.0/src/EditView.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/EditView.cxx @@ -1,31 +1,39 @@ // Scintilla source code edit control -/** @file Editor.cxx +/** @file EditView.cxx ** Defines the appearance of the main text area of the editor window. **/ // Copyright 1998-2014 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include #include +#include #include +#include #include +#include #include "Platform.h" +#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" #include "StringCopy.h" +#include "CharacterSet.h" +#include "CharacterCategory.h" #include "Position.h" +#include "IntegerRectangle.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -34,7 +42,6 @@ #include "PerLine.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -48,25 +55,22 @@ #include "EditModel.h" #include "MarginView.h" #include "EditView.h" +#include "ElapsedPeriod.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 < ' '; } -PrintParameters::PrintParameters() { +PrintParameters::PrintParameters() noexcept { magnification = 0; colourMode = SC_PRINT_NORMAL; wrapState = eWrapWord; } -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif bool ValidStyledText(const ViewStyle &vs, size_t styleOffset, const StyledText &st) { if (st.multipleStyles) { @@ -86,9 +90,9 @@ static int WidthStyledText(Surface *surface, const ViewStyle &vs, int styleOffse int width = 0; size_t start = 0; while (start < len) { - size_t style = styles[start]; + const unsigned char style = styles[start]; size_t endSegment = start; - while ((endSegment + 1 < len) && (static_cast(styles[endSegment + 1]) == style)) + while ((endSegment + 1 < len) && (styles[endSegment + 1] == style)) endSegment++; FontAlias fontText = vs.styles[style + styleOffset].font; width += static_cast(surface->WidthText(fontText, text + start, @@ -102,7 +106,7 @@ int WidestLineWidth(Surface *surface, const ViewStyle &vs, int styleOffset, cons int widthMax = 0; size_t start = 0; while (start < st.length) { - size_t lenLine = st.LineLength(start); + const size_t lenLine = st.LineLength(start); int widthSubLine; if (st.multipleStyles) { widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine); @@ -166,14 +170,11 @@ void DrawStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, PRec } } -#ifdef SCI_NAMESPACE } -#endif const XYPOSITION epsilon = 0.0001f; // A small nudge to avoid floating point precision issues EditView::EditView() { - ldTabstops = NULL; tabWidthMinimumPixels = 2; // needed for calculating tab stops for fractional proportional fonts hideSelection = false; drawOverstrikeCaret = true; @@ -183,81 +184,72 @@ EditView::EditView() { additionalCaretsBlink = true; additionalCaretsVisible = true; imeCaretBlockOverride = false; - pixmapLine = 0; - pixmapIndentGuide = 0; - pixmapIndentGuideHighlight = 0; llc.SetLevel(LineLayoutCache::llcCaret); posCache.SetSize(0x400); tabArrowHeight = 4; - customDrawTabArrow = NULL; - customDrawWrapMarker = NULL; + customDrawTabArrow = nullptr; + customDrawWrapMarker = nullptr; } EditView::~EditView() { - delete ldTabstops; - ldTabstops = NULL; } -bool EditView::SetTwoPhaseDraw(bool twoPhaseDraw) { +bool EditView::SetTwoPhaseDraw(bool twoPhaseDraw) noexcept { const PhasesDraw phasesDrawNew = twoPhaseDraw ? phasesTwo : phasesOne; const bool redraw = phasesDraw != phasesDrawNew; phasesDraw = phasesDrawNew; return redraw; } -bool EditView::SetPhasesDraw(int phases) { +bool EditView::SetPhasesDraw(int phases) noexcept { const PhasesDraw phasesDrawNew = static_cast(phases); const bool redraw = phasesDraw != phasesDrawNew; phasesDraw = phasesDrawNew; return redraw; } -bool EditView::LinesOverlap() const { +bool EditView::LinesOverlap() const noexcept { return phasesDraw == phasesMultiple; } -void EditView::ClearAllTabstops() { - delete ldTabstops; - ldTabstops = 0; +void EditView::ClearAllTabstops() noexcept { + ldTabstops.reset(); } -XYPOSITION EditView::NextTabstopPos(int line, XYPOSITION x, XYPOSITION tabWidth) const { - int next = GetNextTabstop(line, static_cast(x + tabWidthMinimumPixels)); +XYPOSITION EditView::NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const { + const int next = GetNextTabstop(line, static_cast(x + tabWidthMinimumPixels)); if (next > 0) return static_cast(next); return (static_cast((x + tabWidthMinimumPixels) / tabWidth) + 1) * tabWidth; } -bool EditView::ClearTabstops(int line) { - LineTabstops *lt = static_cast(ldTabstops); - return lt && lt->ClearTabstops(line); +bool EditView::ClearTabstops(Sci::Line line) { + return ldTabstops && ldTabstops->ClearTabstops(line); } -bool EditView::AddTabstop(int line, int x) { +bool EditView::AddTabstop(Sci::Line line, int x) { if (!ldTabstops) { - ldTabstops = new LineTabstops(); + ldTabstops.reset(new LineTabstops()); } - LineTabstops *lt = static_cast(ldTabstops); - return lt && lt->AddTabstop(line, x); + return ldTabstops && ldTabstops->AddTabstop(line, x); } -int EditView::GetNextTabstop(int line, int x) const { - LineTabstops *lt = static_cast(ldTabstops); - if (lt) { - return lt->GetNextTabstop(line, x); +int EditView::GetNextTabstop(Sci::Line line, int x) const { + if (ldTabstops) { + return ldTabstops->GetNextTabstop(line, x); } else { return 0; } } -void EditView::LinesAddedOrRemoved(int lineOfPos, int linesAdded) { +void EditView::LinesAddedOrRemoved(Sci::Line lineOfPos, Sci::Line linesAdded) { if (ldTabstops) { if (linesAdded > 0) { - for (int line = lineOfPos; line < lineOfPos + linesAdded; line++) { + for (Sci::Line line = lineOfPos; line < lineOfPos + linesAdded; line++) { ldTabstops->InsertLine(line); } } else { - for (int line = (lineOfPos + -linesAdded) - 1; line >= lineOfPos; line--) { + for (Sci::Line line = (lineOfPos + -linesAdded) - 1; line >= lineOfPos; line--) { ldTabstops->RemoveLine(line); } } @@ -266,12 +258,9 @@ void EditView::LinesAddedOrRemoved(int lineOfPos, int linesAdded) { void EditView::DropGraphics(bool freeObjects) { if (freeObjects) { - delete pixmapLine; - pixmapLine = 0; - delete pixmapIndentGuide; - pixmapIndentGuide = 0; - delete pixmapIndentGuideHighlight; - pixmapIndentGuideHighlight = 0; + pixmapLine.reset(); + pixmapIndentGuide.reset(); + pixmapIndentGuideHighlight.reset(); } else { if (pixmapLine) pixmapLine->Release(); @@ -284,15 +273,15 @@ void EditView::DropGraphics(bool freeObjects) { void EditView::AllocateGraphics(const ViewStyle &vsDraw) { if (!pixmapLine) - pixmapLine = Surface::Allocate(vsDraw.technology); + pixmapLine.reset(Surface::Allocate(vsDraw.technology)); if (!pixmapIndentGuide) - pixmapIndentGuide = Surface::Allocate(vsDraw.technology); + pixmapIndentGuide.reset(Surface::Allocate(vsDraw.technology)); if (!pixmapIndentGuideHighlight) - pixmapIndentGuideHighlight = Surface::Allocate(vsDraw.technology); + pixmapIndentGuideHighlight.reset(Surface::Allocate(vsDraw.technology)); } -const char *ControlCharacterString(unsigned char ch) { - const char *reps[] = { +static const char *ControlCharacterString(unsigned char ch) noexcept { + const char * const reps[] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", @@ -305,21 +294,26 @@ const char *ControlCharacterString(unsigned char ch) { } } -void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { - int ydiff = static_cast(rcTab.bottom - rcTab.top) / 2; - int xhead = static_cast(rcTab.right) - 1 - ydiff; - if (xhead <= rcTab.left) { - ydiff -= static_cast(rcTab.left) - xhead - 1; - xhead = static_cast(rcTab.left) - 1; - } +static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid, const ViewStyle &vsDraw) { + const IntegerRectangle ircTab(rcTab); if ((rcTab.left + 2) < (rcTab.right - 1)) - surface->MoveTo(static_cast(rcTab.left) + 2, ymid); + surface->MoveTo(ircTab.left + 2, ymid); else - surface->MoveTo(static_cast(rcTab.right) - 1, ymid); - surface->LineTo(static_cast(rcTab.right) - 1, ymid); - surface->LineTo(xhead, ymid - ydiff); - surface->MoveTo(static_cast(rcTab.right) - 1, ymid); - surface->LineTo(xhead, ymid + ydiff); + surface->MoveTo(ircTab.right - 1, ymid); + surface->LineTo(ircTab.right - 1, ymid); + + // Draw the arrow head if needed + if (vsDraw.tabDrawMode == tdLongArrow) { + int ydiff = (ircTab.bottom - ircTab.top) / 2; + int xhead = ircTab.right - 1 - ydiff; + if (xhead <= rcTab.left) { + ydiff -= ircTab.left - xhead - 1; + xhead = ircTab.left - 1; + } + surface->LineTo(xhead, ymid - ydiff); + surface->MoveTo(ircTab.right - 1, ymid); + surface->LineTo(xhead, ymid + ydiff); + } } void EditView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw) { @@ -327,48 +321,76 @@ void EditView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewSt // 1 extra pixel in height so can handle odd/even positions and so produce a continuous line pixmapIndentGuide->InitPixMap(1, vsDraw.lineHeight + 1, surfaceWindow, wid); pixmapIndentGuideHighlight->InitPixMap(1, vsDraw.lineHeight + 1, surfaceWindow, wid); - PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vsDraw.lineHeight); + const PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vsDraw.lineHeight); pixmapIndentGuide->FillRectangle(rcIG, vsDraw.styles[STYLE_INDENTGUIDE].back); pixmapIndentGuide->PenColour(vsDraw.styles[STYLE_INDENTGUIDE].fore); pixmapIndentGuideHighlight->FillRectangle(rcIG, vsDraw.styles[STYLE_BRACELIGHT].back); pixmapIndentGuideHighlight->PenColour(vsDraw.styles[STYLE_BRACELIGHT].fore); for (int stripe = 1; stripe < vsDraw.lineHeight + 1; stripe += 2) { - PRectangle rcPixel = PRectangle::FromInts(0, stripe, 1, stripe + 1); + const PRectangle rcPixel = PRectangle::FromInts(0, stripe, 1, stripe + 1); pixmapIndentGuide->FillRectangle(rcPixel, vsDraw.styles[STYLE_INDENTGUIDE].fore); pixmapIndentGuideHighlight->FillRectangle(rcPixel, vsDraw.styles[STYLE_BRACELIGHT].fore); } } } -LineLayout *EditView::RetrieveLineLayout(int lineNumber, const EditModel &model) { - int posLineStart = model.pdoc->LineStart(lineNumber); - int posLineEnd = model.pdoc->LineStart(lineNumber + 1); +LineLayout *EditView::RetrieveLineLayout(Sci::Line lineNumber, const EditModel &model) { + const Sci::Position posLineStart = model.pdoc->LineStart(lineNumber); + const Sci::Position posLineEnd = model.pdoc->LineStart(lineNumber + 1); PLATFORM_ASSERT(posLineEnd >= posLineStart); - int lineCaret = model.pdoc->LineFromPosition(model.sel.MainCaret()); + const Sci::Line lineCaret = model.pdoc->SciLineFromPosition(model.sel.MainCaret()); return llc.Retrieve(lineNumber, lineCaret, - posLineEnd - posLineStart, model.pdoc->GetStyleClock(), + static_cast(posLineEnd - posLineStart), model.pdoc->GetStyleClock(), model.LinesOnScreen() + 1, model.pdoc->LinesTotal()); } +namespace { + +/** +* Return the chDoc argument with case transformed as indicated by the caseForce argument. +* chPrevious is needed for camel casing. +* This only affects ASCII characters and is provided for languages with case-insensitive +* ASCII keywords where the user wishes to view keywords in a preferred case. +*/ +inline char CaseForce(Style::ecaseForced caseForce, char chDoc, char chPrevious) { + switch (caseForce) { + case Style::caseMixed: + return chDoc; + case Style::caseLower: + return MakeLowerCase(chDoc); + case Style::caseUpper: + return MakeUpperCase(chDoc); + case Style::caseCamel: + default: // default should not occur, included to avoid warnings + if (IsUpperOrLowerCase(chDoc) && !IsUpperOrLowerCase(chPrevious)) { + return MakeUpperCase(chDoc); + } else { + return MakeLowerCase(chDoc); + } + } +} + +} + /** * Fill in the LineLayout data for the given line. * Copy the given @a line and its styles from the document into local arrays. * Also determine the x position at which each character starts. */ -void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width) { +void EditView::LayoutLine(const EditModel &model, Sci::Line line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width) { if (!ll) return; PLATFORM_ASSERT(line < model.pdoc->LinesTotal()); PLATFORM_ASSERT(ll->chars != NULL); - int posLineStart = model.pdoc->LineStart(line); - int posLineEnd = model.pdoc->LineStart(line + 1); + const Sci::Position posLineStart = model.pdoc->LineStart(line); + Sci::Position posLineEnd = model.pdoc->LineStart(line + 1); // If the line is very long, limit the treatment to a length that should fit in the viewport if (posLineEnd >(posLineStart + ll->maxLineLength)) { posLineEnd = posLineStart + ll->maxLineLength; } if (ll->validity == LineLayout::llCheckTextAndStyle) { - int lineLength = posLineEnd - posLineStart; + Sci::Position lineLength = posLineEnd - posLineStart; if (!vstyle.viewEOL) { lineLength = model.pdoc->LineEnd(line) - posLineStart; } @@ -376,31 +398,18 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co // See if chars, styles, indicators, are all the same bool allSame = true; // Check base line layout - char styleByte = 0; + int styleByte = 0; int numCharsInLine = 0; + char chPrevious = 0; while (numCharsInLine < lineLength) { - int charInDoc = numCharsInLine + posLineStart; - char chDoc = model.pdoc->CharAt(charInDoc); - styleByte = model.pdoc->StyleAt(charInDoc); + const Sci::Position charInDoc = numCharsInLine + posLineStart; + const char chDoc = model.pdoc->CharAt(charInDoc); + styleByte = model.pdoc->StyleIndexAt(charInDoc); allSame = allSame && - (ll->styles[numCharsInLine] == static_cast(styleByte)); - if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseMixed) - allSame = allSame && - (ll->chars[numCharsInLine] == chDoc); - else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) - allSame = allSame && - (ll->chars[numCharsInLine] == static_cast(tolower(chDoc))); - else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseUpper) - allSame = allSame && - (ll->chars[numCharsInLine] == static_cast(toupper(chDoc))); - else { // Style::caseCamel - if ((model.pdoc->WordCharClass(ll->chars[numCharsInLine]) == CharClassify::ccWord) && - ((numCharsInLine == 0) || (model.pdoc->WordCharClass(ll->chars[numCharsInLine - 1]) != CharClassify::ccWord))) { - allSame = allSame && (ll->chars[numCharsInLine] == static_cast(toupper(chDoc))); - } else { - allSame = allSame && (ll->chars[numCharsInLine] == static_cast(tolower(chDoc))); - } - } + (ll->styles[numCharsInLine] == styleByte); + allSame = allSame && + (ll->chars[numCharsInLine] == CaseForce(vstyle.styles[styleByte].caseForce, chDoc, chPrevious)); + chPrevious = chDoc; numCharsInLine++; } allSame = allSame && (ll->styles[numCharsInLine] == styleByte); // For eolFilled @@ -417,40 +426,28 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co ll->widthLine = LineLayout::wrapWidthInfinite; ll->lines = 1; if (vstyle.edgeState == EDGE_BACKGROUND) { - ll->edgeColumn = model.pdoc->FindColumn(line, vstyle.theEdge); - if (ll->edgeColumn >= posLineStart) { - ll->edgeColumn -= posLineStart; + Sci::Position edgePosition = model.pdoc->FindColumn(line, vstyle.theEdge.column); + if (edgePosition >= posLineStart) { + edgePosition -= posLineStart; } + ll->edgeColumn = static_cast(edgePosition); } else { ll->edgeColumn = -1; } // Fill base line layout - const int lineLength = posLineEnd - posLineStart; - model.pdoc->GetCharRange(ll->chars, posLineStart, lineLength); - model.pdoc->GetStyleRange(ll->styles, posLineStart, lineLength); - int numCharsBeforeEOL = model.pdoc->LineEnd(line) - posLineStart; + const int lineLength = static_cast(posLineEnd - posLineStart); + model.pdoc->GetCharRange(ll->chars.get(), posLineStart, lineLength); + model.pdoc->GetStyleRange(ll->styles.get(), posLineStart, lineLength); + const int numCharsBeforeEOL = static_cast(model.pdoc->LineEnd(line) - posLineStart); const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL; - for (int styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) { - const unsigned char styleByte = ll->styles[styleInLine]; - ll->styles[styleInLine] = styleByte; - } const unsigned char styleByteLast = (lineLength > 0) ? ll->styles[lineLength - 1] : 0; if (vstyle.someStylesForceCase) { + char chPrevious = 0; for (int charInLine = 0; charInLinechars[charInLine]; - if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseUpper) - ll->chars[charInLine] = static_cast(toupper(chDoc)); - else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseLower) - ll->chars[charInLine] = static_cast(tolower(chDoc)); - else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseCamel) { - if ((model.pdoc->WordCharClass(ll->chars[charInLine]) == CharClassify::ccWord) && - ((charInLine == 0) || (model.pdoc->WordCharClass(ll->chars[charInLine - 1]) != CharClassify::ccWord))) { - ll->chars[charInLine] = static_cast(toupper(chDoc)); - } else { - ll->chars[charInLine] = static_cast(tolower(chDoc)); - } - } + const char chDoc = ll->chars[charInLine]; + ll->chars[charInLine] = CaseForce(vstyle.styles[ll->styles[charInLine]].caseForce, chDoc, chPrevious); + chPrevious = chDoc; } } ll->xHighlightGuide = 0; @@ -463,7 +460,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co ll->positions[0] = 0; bool lastSegItalics = false; - BreakFinder bfLayout(ll, NULL, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs, NULL); + BreakFinder bfLayout(ll, nullptr, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs, nullptr); while (bfLayout.More()) { const TextSegment ts = bfLayout.Next(); @@ -491,14 +488,14 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co // Over half the segments are single characters and of these about half are space characters. ll->positions[ts.start + 1] = vstyle.styles[ll->styles[ts.start]].spaceWidth; } else { - posCache.MeasureWidths(surface, vstyle, ll->styles[ts.start], ll->chars + ts.start, - ts.length, ll->positions + ts.start + 1, model.pdoc); + posCache.MeasureWidths(surface, vstyle, ll->styles[ts.start], &ll->chars[ts.start], + ts.length, &ll->positions[ts.start + 1], model.pdoc); } } lastSegItalics = (!ts.representation) && ((ll->chars[ts.end() - 1] != ' ') && vstyle.styles[ll->styles[ts.start]].italic); } - for (int posToIncrease = ts.start + 1; posToIncrease <= ts.end(); posToIncrease++) { + for (Sci::Position posToIncrease = ts.start + 1; posToIncrease <= ts.end(); posToIncrease++) { ll->positions[posToIncrease] += ll->positions[ts.start]; } } @@ -527,17 +524,24 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co width -= static_cast(vstyle.aveCharWidth); // take into account the space for end wrap mark } XYPOSITION wrapAddIndent = 0; // This will be added to initial indent of line - if (vstyle.wrapIndentMode == SC_WRAPINDENT_INDENT) { - wrapAddIndent = model.pdoc->IndentSize() * vstyle.spaceWidth; - } else if (vstyle.wrapIndentMode == SC_WRAPINDENT_FIXED) { + switch (vstyle.wrapIndentMode) { + case SC_WRAPINDENT_FIXED: wrapAddIndent = vstyle.wrapVisualStartIndent * vstyle.aveCharWidth; + break; + case SC_WRAPINDENT_INDENT: + wrapAddIndent = model.pdoc->IndentSize() * vstyle.spaceWidth; + break; + case SC_WRAPINDENT_DEEPINDENT: + wrapAddIndent = model.pdoc->IndentSize() * 2 * vstyle.spaceWidth; + break; } ll->wrapIndent = wrapAddIndent; - if (vstyle.wrapIndentMode != SC_WRAPINDENT_FIXED) - for (int i = 0; i < ll->numCharsInLine; i++) { - if (!IsSpaceOrTab(ll->chars[i])) { - ll->wrapIndent += ll->positions[i]; // Add line indent - break; + if (vstyle.wrapIndentMode != SC_WRAPINDENT_FIXED) { + for (int i = 0; i < ll->numCharsInLine; i++) { + if (!IsSpaceOrTab(ll->chars[i])) { + ll->wrapIndent += ll->positions[i]; // Add line indent + break; + } } } // Check for text width minimum @@ -548,10 +552,10 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co ll->wrapIndent = vstyle.aveCharWidth; // Indent to show start visual ll->lines = 0; // Calculate line start positions based upon width. - int lastGoodBreak = 0; - int lastLineStart = 0; + Sci::Position lastGoodBreak = 0; + Sci::Position lastLineStart = 0; XYACCUMULATOR startOffset = 0; - int p = 0; + Sci::Position p = 0; while (p < ll->numCharsInLine) { if ((ll->positions[p + 1] - startOffset) >= width) { if (lastGoodBreak == lastLineStart) { @@ -568,7 +572,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co } lastLineStart = lastGoodBreak; ll->lines++; - ll->SetLineStart(ll->lines, lastGoodBreak); + ll->SetLineStart(ll->lines, static_cast(lastGoodBreak)); startOffset = ll->positions[lastGoodBreak]; // take into account the space for start wrap mark and indent startOffset -= ll->wrapIndent; @@ -595,19 +599,24 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co } } -Point EditView::LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine, const ViewStyle &vs) { +Point EditView::LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, Sci::Line topLine, + const ViewStyle &vs, PointEnd pe) { Point pt; if (pos.Position() == INVALID_POSITION) return pt; - const int line = model.pdoc->LineFromPosition(pos.Position()); - const int lineVisible = model.cs.DisplayFromDoc(line); - //Platform::DebugPrintf("line=%d\n", line); - AutoLineLayout ll(llc, RetrieveLineLayout(line, model)); + Sci::Line lineDoc = model.pdoc->SciLineFromPosition(pos.Position()); + Sci::Position posLineStart = model.pdoc->LineStart(lineDoc); + if ((pe & peLineEnd) && (lineDoc > 0) && (pos.Position() == posLineStart)) { + // Want point at end of first line + lineDoc--; + posLineStart = model.pdoc->LineStart(lineDoc); + } + const Sci::Line lineVisible = model.pcs->DisplayFromDoc(lineDoc); + AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model)); if (surface && ll) { - const int posLineStart = model.pdoc->LineStart(line); - LayoutLine(model, line, surface, vs, ll, model.wrapWidth); - const int posInLine = pos.Position() - posLineStart; - pt = ll->PointFromPosition(posInLine, vs.lineHeight); + LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth); + const int posInLine = static_cast(pos.Position() - posLineStart); + pt = ll->PointFromPosition(posInLine, vs.lineHeight, pe); pt.y += (lineVisible - topLine) * vs.lineHeight; pt.x += vs.textStart - model.xOffset; } @@ -615,28 +624,55 @@ Point EditView::LocationFromPosition(Surface *surface, const EditModel &model, S return pt; } -SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditModel &model, Point pt, bool canReturnInvalid, bool charPosition, bool virtualSpace, const ViewStyle &vs) { - pt.x = pt.x - vs.textStart; - int visibleLine = static_cast(floor(pt.y / vs.lineHeight)); - if (!canReturnInvalid && (visibleLine < 0)) - visibleLine = 0; - const int lineDoc = model.cs.DocFromDisplay(visibleLine); - if (canReturnInvalid && (lineDoc < 0)) - return SelectionPosition(INVALID_POSITION); - if (lineDoc >= model.pdoc->LinesTotal()) - return SelectionPosition(canReturnInvalid ? INVALID_POSITION : model.pdoc->Length()); - const int posLineStart = model.pdoc->LineStart(lineDoc); +Range EditView::RangeDisplayLine(Surface *surface, const EditModel &model, Sci::Line lineVisible, const ViewStyle &vs) { + Range rangeSubLine = Range(0, 0); + if (lineVisible < 0) { + return rangeSubLine; + } + const Sci::Line lineDoc = model.pcs->DocFromDisplay(lineVisible); + const Sci::Position positionLineStart = model.pdoc->LineStart(lineDoc); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model)); if (surface && ll) { LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth); - const int lineStartSet = model.cs.DisplayFromDoc(lineDoc); - const int subLine = visibleLine - lineStartSet; + const Sci::Line lineStartSet = model.pcs->DisplayFromDoc(lineDoc); + const int subLine = static_cast(lineVisible - lineStartSet); if (subLine < ll->lines) { - const Range rangeSubLine = ll->SubLineRange(subLine); + rangeSubLine = ll->SubLineRange(subLine, LineLayout::Scope::visibleOnly); + if (subLine == ll->lines-1) { + rangeSubLine.end = model.pdoc->LineStart(lineDoc + 1) - + positionLineStart; + } + } + } + rangeSubLine.start += positionLineStart; + rangeSubLine.end += positionLineStart; + return rangeSubLine; +} + +SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditModel &model, PointDocument pt, bool canReturnInvalid, bool charPosition, bool virtualSpace, const ViewStyle &vs) { + pt.x = pt.x - vs.textStart; + Sci::Line visibleLine = static_cast(std::floor(pt.y / vs.lineHeight)); + if (!canReturnInvalid && (visibleLine < 0)) + visibleLine = 0; + const Sci::Line lineDoc = model.pcs->DocFromDisplay(visibleLine); + if (canReturnInvalid && (lineDoc < 0)) + return SelectionPosition(INVALID_POSITION); + if (lineDoc >= model.pdoc->LinesTotal()) + return SelectionPosition(canReturnInvalid ? INVALID_POSITION : + model.pdoc->Length()); + const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc); + AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model)); + if (surface && ll) { + LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth); + const Sci::Line lineStartSet = model.pcs->DisplayFromDoc(lineDoc); + const int subLine = static_cast(visibleLine - lineStartSet); + if (subLine < ll->lines) { + const Range rangeSubLine = ll->SubLineRange(subLine, LineLayout::Scope::visibleOnly); const XYPOSITION subLineStart = ll->positions[rangeSubLine.start]; if (subLine > 0) // Wrapped pt.x -= ll->wrapIndent; - const int positionInLine = ll->FindPositionFromX(pt.x + subLineStart, rangeSubLine, charPosition); + const Sci::Position positionInLine = ll->FindPositionFromX(static_cast(pt.x + subLineStart), + rangeSubLine, charPosition); if (positionInLine < rangeSubLine.end) { return SelectionPosition(model.pdoc->MovePositionOutsideChar(positionInLine + posLineStart, 1)); } @@ -664,14 +700,14 @@ SelectionPosition EditView::SPositionFromLocation(Surface *surface, const EditMo * Ensure is between whole characters when document is in multi-byte or UTF-8 mode. * This method is used for rectangular selections and does not work on wrapped lines. */ -SelectionPosition EditView::SPositionFromLineX(Surface *surface, const EditModel &model, int lineDoc, int x, const ViewStyle &vs) { +SelectionPosition EditView::SPositionFromLineX(Surface *surface, const EditModel &model, Sci::Line lineDoc, int x, const ViewStyle &vs) { AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model)); if (surface && ll) { - const int posLineStart = model.pdoc->LineStart(lineDoc); + const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc); LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth); - const Range rangeSubLine = ll->SubLineRange(0); + const Range rangeSubLine = ll->SubLineRange(0, LineLayout::Scope::visibleOnly); const XYPOSITION subLineStart = ll->positions[rangeSubLine.start]; - const int positionInLine = ll->FindPositionFromX(x + subLineStart, rangeSubLine, false); + const Sci::Position positionInLine = ll->FindPositionFromX(x + subLineStart, rangeSubLine, false); if (positionInLine < rangeSubLine.end) { return SelectionPosition(model.pdoc->MovePositionOutsideChar(positionInLine + posLineStart, 1)); } @@ -683,14 +719,14 @@ SelectionPosition EditView::SPositionFromLineX(Surface *surface, const EditModel return SelectionPosition(0); } -int EditView::DisplayFromPosition(Surface *surface, const EditModel &model, int pos, const ViewStyle &vs) { - int lineDoc = model.pdoc->LineFromPosition(pos); - int lineDisplay = model.cs.DisplayFromDoc(lineDoc); +Sci::Line EditView::DisplayFromPosition(Surface *surface, const EditModel &model, Sci::Position pos, const ViewStyle &vs) { + const Sci::Line lineDoc = model.pdoc->SciLineFromPosition(pos); + Sci::Line lineDisplay = model.pcs->DisplayFromDoc(lineDoc); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc, model)); if (surface && ll) { LayoutLine(model, lineDoc, surface, vs, ll, model.wrapWidth); - unsigned int posLineStart = model.pdoc->LineStart(lineDoc); - int posInLine = pos - posLineStart; + const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc); + const Sci::Position posInLine = pos - posLineStart; lineDisplay--; // To make up for first increment ahead. for (int subLine = 0; subLine < ll->lines; subLine++) { if (posInLine >= ll->LineStart(subLine)) { @@ -701,22 +737,24 @@ int EditView::DisplayFromPosition(Surface *surface, const EditModel &model, int return lineDisplay; } -int EditView::StartEndDisplayLine(Surface *surface, const EditModel &model, int pos, bool start, const ViewStyle &vs) { - int line = model.pdoc->LineFromPosition(pos); +Sci::Position EditView::StartEndDisplayLine(Surface *surface, const EditModel &model, Sci::Position pos, bool start, const ViewStyle &vs) { + const Sci::Line line = model.pdoc->SciLineFromPosition(pos); AutoLineLayout ll(llc, RetrieveLineLayout(line, model)); - int posRet = INVALID_POSITION; + Sci::Position posRet = INVALID_POSITION; if (surface && ll) { - unsigned int posLineStart = model.pdoc->LineStart(line); + const Sci::Position posLineStart = model.pdoc->LineStart(line); LayoutLine(model, line, surface, vs, ll, model.wrapWidth); - int posInLine = pos - posLineStart; + const Sci::Position posInLine = pos - posLineStart; if (posInLine <= ll->maxLineLength) { for (int subLine = 0; subLine < ll->lines; subLine++) { - if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) { + if ((posInLine >= ll->LineStart(subLine)) && + (posInLine <= ll->LineStart(subLine + 1)) && + (posInLine <= ll->numCharsBeforeEOL)) { if (start) { posRet = ll->LineStart(subLine) + posLineStart; } else { if (subLine == ll->lines - 1) - posRet = ll->LineStart(subLine + 1) + posLineStart; + posRet = ll->numCharsBeforeEOL + posLineStart; else posRet = ll->LineStart(subLine + 1) + posLineStart - 1; } @@ -727,14 +765,14 @@ int EditView::StartEndDisplayLine(Surface *surface, const EditModel &model, int return posRet; } -static ColourDesired SelectionBackground(const ViewStyle &vsDraw, bool main, bool primarySelection) { +static ColourDesired SelectionBackground(const ViewStyle &vsDraw, bool main, bool primarySelection) noexcept { return main ? (primarySelection ? vsDraw.selColours.back : vsDraw.selBackground2) : vsDraw.selAdditionalBackground; } static ColourDesired TextBackground(const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - ColourOptional background, int inSelection, bool inHotspot, int styleMain, int i) { + ColourOptional background, int inSelection, bool inHotspot, int styleMain, Sci::Position i) { if (inSelection == 1) { if (vsDraw.selColours.back.isSet && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { return SelectionBackground(vsDraw, true, model.primarySelection); @@ -747,7 +785,7 @@ static ColourDesired TextBackground(const EditModel &model, const ViewStyle &vsD if ((vsDraw.edgeState == EDGE_BACKGROUND) && (i >= ll->edgeColumn) && (i < ll->numCharsBeforeEOL)) - return vsDraw.edgecolour; + return vsDraw.theEdge.colour; if (inHotspot && vsDraw.hotspotColours.back.isSet) return vsDraw.hotspotColours.back; } @@ -758,9 +796,10 @@ static ColourDesired TextBackground(const EditModel &model, const ViewStyle &vsD } } -void EditView::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight) { - Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0); - PRectangle rcCopyArea = PRectangle::FromInts(start + 1, static_cast(rcSegment.top), start + 2, static_cast(rcSegment.bottom)); +void EditView::DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, XYPOSITION start, PRectangle rcSegment, bool highlight) { + const Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0); + const PRectangle rcCopyArea(start + 1, rcSegment.top, + start + 2, rcSegment.bottom); surface->Copy(rcCopyArea, from, highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide); } @@ -779,8 +818,7 @@ static void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle r surface->FillRectangle(rcSegment, textBack); } FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; - int normalCharHeight = static_cast(surface->Ascent(ctrlCharsFont) - - surface->InternalLeading(ctrlCharsFont)); + const int normalCharHeight = static_cast(std::ceil(vsDraw.styles[STYLE_CONTROLCHAR].capitalHeight)); PRectangle rcCChar = rcSegment; rcCChar.left = rcCChar.left + 1; rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; @@ -797,11 +835,42 @@ static void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle r textBack, textFore); } +static void DrawFrame(Surface *surface, ColourDesired colour, int alpha, PRectangle rcFrame) { + if (alpha != SC_ALPHA_NOALPHA) + surface->AlphaRectangle(rcFrame, 0, colour, alpha, colour, alpha, 0); + else + surface->FillRectangle(rcFrame, colour); +} + +static void DrawCaretLineFramed(Surface *surface, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine, int subLine) { + const int width = vsDraw.GetFrameWidth(); + if (subLine == 0 || ll->wrapIndent == 0 || vsDraw.caretLineAlpha != SC_ALPHA_NOALPHA) { + // Left + DrawFrame(surface, vsDraw.caretLineBackground, vsDraw.caretLineAlpha, + PRectangle(rcLine.left, rcLine.top, rcLine.left + width, rcLine.bottom)); + } + if (subLine == 0) { + // Top + DrawFrame(surface, vsDraw.caretLineBackground, vsDraw.caretLineAlpha, + PRectangle(rcLine.left + width, rcLine.top, rcLine.right - width, rcLine.top + width)); + } + if (subLine == ll->lines - 1 || vsDraw.caretLineAlpha != SC_ALPHA_NOALPHA) { + // Right + DrawFrame(surface, vsDraw.caretLineBackground, vsDraw.caretLineAlpha, + PRectangle(rcLine.right - width, rcLine.top, rcLine.right, rcLine.bottom)); + } + if (subLine == ll->lines - 1) { + // Bottom + DrawFrame(surface, vsDraw.caretLineBackground, vsDraw.caretLineAlpha, + PRectangle(rcLine.left + width, rcLine.bottom - width, rcLine.right - width, rcLine.bottom)); + } +} + void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - PRectangle rcLine, int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, + PRectangle rcLine, Sci::Line line, Sci::Position lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, ColourOptional background) { - const int posLineStart = model.pdoc->LineStart(line); + const Sci::Position posLineStart = model.pdoc->LineStart(line); PRectangle rcSegment = rcLine; const bool lastSubLine = subLine == (ll->lines - 1); @@ -810,7 +879,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; virtualSpace = model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line)) * spaceWidth; } - XYPOSITION xEol = static_cast(ll->positions[lineEnd] - subLineStart); + const XYPOSITION xEol = static_cast(ll->positions[lineEnd] - subLineStart); // Fill the virtual space and show selections within it if (virtualSpace > 0.0f) { @@ -818,11 +887,13 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle rcSegment.right = xEol + xStart + virtualSpace; surface->FillRectangle(rcSegment, background.isSet ? background : vsDraw.styles[ll->styles[ll->numCharsInLine]].back); if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) { - SelectionSegment virtualSpaceRange(SelectionPosition(model.pdoc->LineEnd(line)), SelectionPosition(model.pdoc->LineEnd(line), model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line)))); + const SelectionSegment virtualSpaceRange(SelectionPosition(model.pdoc->LineEnd(line)), + SelectionPosition(model.pdoc->LineEnd(line), + model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line)))); for (size_t r = 0; rEndLineStyle()].spaceWidth; rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - @@ -841,27 +912,27 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle int eolInSelection = 0; int alpha = SC_ALPHA_NOALPHA; if (!hideSelection) { - int posAfterLineEnd = model.pdoc->LineStart(line + 1); - eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0; + const Sci::Position posAfterLineEnd = model.pdoc->LineStart(line + 1); + eolInSelection = lastSubLine ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0; alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; } // Draw the [CR], [LF], or [CR][LF] blobs if visible line ends are on XYPOSITION blobsWidth = 0; if (lastSubLine) { - for (int eolPos = ll->numCharsBeforeEOL; eolPosnumCharsInLine; eolPos++) { + for (Sci::Position eolPos = ll->numCharsBeforeEOL; eolPosnumCharsInLine; eolPos++) { rcSegment.left = xStart + ll->positions[eolPos] - static_cast(subLineStart)+virtualSpace; rcSegment.right = xStart + ll->positions[eolPos + 1] - static_cast(subLineStart)+virtualSpace; blobsWidth += rcSegment.Width(); - char hexits[4]; + char hexits[4] = ""; const char *ctrlChar; - unsigned char chEOL = ll->chars[eolPos]; - int styleMain = ll->styles[eolPos]; - ColourDesired textBack = TextBackground(model, vsDraw, ll, background, eolInSelection, false, styleMain, eolPos); + const unsigned char chEOL = ll->chars[eolPos]; + const int styleMain = ll->styles[eolPos]; + const ColourDesired textBack = TextBackground(model, vsDraw, ll, background, eolInSelection, false, styleMain, eolPos); if (UTF8IsAscii(chEOL)) { ctrlChar = ControlCharacterString(chEOL); } else { - const Representation *repr = model.reprs.RepresentationFromCharacter(ll->chars + eolPos, ll->numCharsInLine - eolPos); + const Representation *repr = model.reprs.RepresentationFromCharacter(&ll->chars[eolPos], ll->numCharsInLine - eolPos); if (repr) { ctrlChar = repr->stringRep.c_str(); eolPos = ll->numCharsInLine; @@ -911,33 +982,29 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle } } - // Fill the remainder of the line rcSegment.left = rcSegment.right; if (rcSegment.left < rcLine.left) rcSegment.left = rcLine.left; rcSegment.right = rcLine.right; - if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { - surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection)); - } else { - if (background.isSet) { - surface->FillRectangle(rcSegment, background); - } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { - surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); - } else { - surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back); - } - if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { - SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection), alpha); - } + const bool fillRemainder = !lastSubLine || !model.GetFoldDisplayText(line); + if (fillRemainder) { + // Fill the remainder of the line + FillLineRemainder(surface, model, vsDraw, ll, line, rcSegment, subLine); } bool drawWrapMarkEnd = false; - if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_END) { - if (subLine + 1 < ll->lines) { + if (subLine + 1 < ll->lines) { + if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_END) { drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0; } + if (vsDraw.IsLineFrameOpaque(model.caret.active, ll->containsCaret)) { + const int width = vsDraw.GetFrameWidth(); + // Draw right of frame under marker + DrawFrame(surface, vsDraw.caretLineBackground, vsDraw.caretLineAlpha, + PRectangle(rcLine.right - width, rcLine.top, rcLine.right, rcLine.bottom)); + } } if (drawWrapMarkEnd) { @@ -951,7 +1018,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle rcPlace.right = rcLine.right; rcPlace.left = rcPlace.right - vsDraw.aveCharWidth; } - if (customDrawWrapMarker == NULL) { + if (!customDrawWrapMarker) { DrawWrapMarker(surface, rcPlace, true, vsDraw.WrapColour()); } else { customDrawWrapMarker(surface, rcPlace, true, vsDraw.WrapColour()); @@ -959,43 +1026,52 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle } } -static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw, - const LineLayout *ll, int xStart, PRectangle rcLine, int subLine, Indicator::DrawState drawState, int value) { +static void DrawIndicator(int indicNum, Sci::Position startPos, Sci::Position endPos, Surface *surface, const ViewStyle &vsDraw, + const LineLayout *ll, int xStart, PRectangle rcLine, Sci::Position secondCharacter, int subLine, Indicator::DrawState drawState, int value) { const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)]; - PRectangle rcIndic( + const PRectangle rcIndic( ll->positions[startPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent, ll->positions[endPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent + 3); - vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, drawState, value); + PRectangle rcFirstCharacter = rcIndic; + // Allow full descent space for character indicators + rcFirstCharacter.bottom = rcLine.top + vsDraw.maxAscent + vsDraw.maxDescent; + if (secondCharacter >= 0) { + rcFirstCharacter.right = ll->positions[secondCharacter] + xStart - subLineStart; + } else { + // Indicator continued from earlier line so make an empty box and don't draw + rcFirstCharacter.right = rcFirstCharacter.left; + } + vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine, rcFirstCharacter, drawState, value); } static void DrawIndicators(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int line, int xStart, PRectangle rcLine, int subLine, int lineEnd, bool under, int hoverIndicatorPos) { + Sci::Line line, int xStart, PRectangle rcLine, int subLine, Sci::Position lineEnd, bool under, Sci::Position hoverIndicatorPos) { // Draw decorators - const int posLineStart = model.pdoc->LineStart(line); - const int lineStart = ll->LineStart(subLine); - const int posLineEnd = posLineStart + lineEnd; + const Sci::Position posLineStart = model.pdoc->LineStart(line); + const Sci::Position lineStart = ll->LineStart(subLine); + const Sci::Position posLineEnd = posLineStart + lineEnd; - for (Decoration *deco = model.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); + for (const IDecoration *deco : model.pdoc->decorations->View()) { + if (under == vsDraw.indicators[deco->Indicator()].under) { + Sci::Position startPos = posLineStart + lineStart; + if (!deco->ValueAt(startPos)) { + startPos = deco->EndRun(startPos); } - while ((startPos < posLineEnd) && (deco->rs.ValueAt(startPos))) { - int endPos = deco->rs.EndRun(startPos); - if (endPos > posLineEnd) - endPos = posLineEnd; - const bool hover = vsDraw.indicators[deco->indicator].IsDynamic() && - ((hoverIndicatorPos >= startPos) && (hoverIndicatorPos <= endPos)); - const int value = deco->rs.ValueAt(startPos); - Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal; - DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart, - surface, vsDraw, ll, xStart, rcLine, subLine, drawState, value); + while ((startPos < posLineEnd) && (deco->ValueAt(startPos))) { + const Range rangeRun(deco->StartRun(startPos), deco->EndRun(startPos)); + const Sci::Position endPos = std::min(rangeRun.end, posLineEnd); + const bool hover = vsDraw.indicators[deco->Indicator()].IsDynamic() && + rangeRun.ContainsCharacter(hoverIndicatorPos); + const int value = deco->ValueAt(startPos); + const Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal; + const Sci::Position posSecond = model.pdoc->MovePositionOutsideChar(rangeRun.First() + 1, 1); + DrawIndicator(deco->Indicator(), startPos - posLineStart, endPos - posLineStart, + surface, vsDraw, ll, xStart, rcLine, posSecond - posLineStart, subLine, drawState, value); startPos = endPos; - if (!deco->rs.ValueAt(startPos)) { - startPos = deco->rs.EndRun(startPos); + if (!deco->ValueAt(startPos)) { + startPos = deco->EndRun(startPos); } } } @@ -1004,34 +1080,130 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS // Use indicators to highlight matching braces if ((vsDraw.braceHighlightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACELIGHT)) || (vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACEBAD))) { - int braceIndicator = (model.bracesMatchStyle == STYLE_BRACELIGHT) ? vsDraw.braceHighlightIndicator : vsDraw.braceBadLightIndicator; + const int braceIndicator = (model.bracesMatchStyle == STYLE_BRACELIGHT) ? vsDraw.braceHighlightIndicator : vsDraw.braceBadLightIndicator; if (under == vsDraw.indicators[braceIndicator].under) { - Range rangeLine(posLineStart + lineStart, posLineEnd); + const Range rangeLine(posLineStart + lineStart, posLineEnd); if (rangeLine.ContainsCharacter(model.braces[0])) { - int braceOffset = model.braces[0] - posLineStart; + const Sci::Position braceOffset = model.braces[0] - posLineStart; if (braceOffset < ll->numCharsInLine) { - DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1); + const Sci::Position secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[0] + 1, 1) - posLineStart; + DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1); } } if (rangeLine.ContainsCharacter(model.braces[1])) { - int braceOffset = model.braces[1] - posLineStart; + const Sci::Position braceOffset = model.braces[1] - posLineStart; if (braceOffset < ll->numCharsInLine) { - DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, subLine, Indicator::drawNormal, 1); + const Sci::Position secondOffset = model.pdoc->MovePositionOutsideChar(model.braces[1] + 1, 1) - posLineStart; + DrawIndicator(braceIndicator, braceOffset, braceOffset + 1, surface, vsDraw, ll, xStart, rcLine, secondOffset, subLine, Indicator::drawNormal, 1); } } } } } -static bool AnnotationBoxedOrIndented(int annotationVisible) { +void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, + Sci::Line line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase) { + const bool lastSubLine = subLine == (ll->lines - 1); + if (!lastSubLine) + return; + + const char *text = model.GetFoldDisplayText(line); + if (!text) + return; + + PRectangle rcSegment = rcLine; + const char *foldDisplayText = text; + const int lengthFoldDisplayText = static_cast(strlen(foldDisplayText)); + FontAlias fontText = vsDraw.styles[STYLE_FOLDDISPLAYTEXT].font; + const int widthFoldDisplayText = static_cast(surface->WidthText(fontText, foldDisplayText, lengthFoldDisplayText)); + + int eolInSelection = 0; + int alpha = SC_ALPHA_NOALPHA; + if (!hideSelection) { + const Sci::Position posAfterLineEnd = model.pdoc->LineStart(line + 1); + eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0; + alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; + } + + const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; + const XYPOSITION virtualSpace = model.sel.VirtualSpaceFor( + model.pdoc->LineEnd(line)) * spaceWidth; + rcSegment.left = xStart + static_cast(ll->positions[ll->numCharsInLine] - subLineStart) + virtualSpace + vsDraw.aveCharWidth; + rcSegment.right = rcSegment.left + static_cast(widthFoldDisplayText); + + const ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret); + ColourDesired textFore = vsDraw.styles[STYLE_FOLDDISPLAYTEXT].fore; + if (eolInSelection && (vsDraw.selColours.fore.isSet)) { + textFore = (eolInSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground; + } + const ColourDesired textBack = TextBackground(model, vsDraw, ll, background, eolInSelection, + false, STYLE_FOLDDISPLAYTEXT, -1); + + if (model.trackLineWidth) { + if (rcSegment.right + 1> lineWidthMaxSeen) { + // Fold display text border drawn on rcSegment.right with width 1 is the last visble object of the line + lineWidthMaxSeen = static_cast(rcSegment.right + 1); + } + } + + if (phase & drawBack) { + surface->FillRectangle(rcSegment, textBack); + + // Fill Remainder of the line + PRectangle rcRemainder = rcSegment; + rcRemainder.left = rcRemainder.right; + if (rcRemainder.left < rcLine.left) + rcRemainder.left = rcLine.left; + rcRemainder.right = rcLine.right; + FillLineRemainder(surface, model, vsDraw, ll, line, rcRemainder, subLine); + } + + if (phase & drawText) { + if (phasesDraw != phasesOne) { + surface->DrawTextTransparent(rcSegment, fontText, + rcSegment.top + vsDraw.maxAscent, foldDisplayText, + lengthFoldDisplayText, textFore); + } else { + surface->DrawTextNoClip(rcSegment, fontText, + rcSegment.top + vsDraw.maxAscent, foldDisplayText, + lengthFoldDisplayText, textFore, textBack); + } + } + + if (phase & drawIndicatorsFore) { + if (model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_BOXED) { + surface->PenColour(textFore); + PRectangle rcBox = rcSegment; + rcBox.left = round(rcSegment.left); + rcBox.right = round(rcSegment.right); + const IntegerRectangle ircBox(rcBox); + surface->MoveTo(ircBox.left, ircBox.top); + surface->LineTo(ircBox.left, ircBox.bottom); + surface->MoveTo(ircBox.right, ircBox.top); + surface->LineTo(ircBox.right, ircBox.bottom); + surface->MoveTo(ircBox.left, ircBox.top); + surface->LineTo(ircBox.right, ircBox.top); + surface->MoveTo(ircBox.left, ircBox.bottom - 1); + surface->LineTo(ircBox.right, ircBox.bottom - 1); + } + } + + if (phase & drawSelectionTranslucent) { + if (eolInSelection && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && alpha != SC_ALPHA_NOALPHA) { + SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection), alpha); + } + } +} + +static constexpr bool AnnotationBoxedOrIndented(int annotationVisible) noexcept { return annotationVisible == ANNOTATION_BOXED || annotationVisible == ANNOTATION_INDENTED; } void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) { - int indent = static_cast(model.pdoc->GetLineIndentation(line) * vsDraw.spaceWidth); + Sci::Line line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) { + const int indent = static_cast(model.pdoc->GetLineIndentation(line) * vsDraw.spaceWidth); PRectangle rcSegment = rcLine; - int annotationLine = subLine - ll->lines; + const int annotationLine = subLine - ll->lines; const StyledText stAnnotation = model.pdoc->AnnotationStyledText(line); if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) { if (phase & drawBack) { @@ -1068,35 +1240,36 @@ void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const Vi stAnnotation, start, lengthAnnotation, phase); if ((phase & drawBack) && (vsDraw.annotationVisible == ANNOTATION_BOXED)) { surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore); - surface->MoveTo(static_cast(rcSegment.left), static_cast(rcSegment.top)); - surface->LineTo(static_cast(rcSegment.left), static_cast(rcSegment.bottom)); - surface->MoveTo(static_cast(rcSegment.right), static_cast(rcSegment.top)); - surface->LineTo(static_cast(rcSegment.right), static_cast(rcSegment.bottom)); + const IntegerRectangle ircSegment(rcSegment); + surface->MoveTo(ircSegment.left, ircSegment.top); + surface->LineTo(ircSegment.left, ircSegment.bottom); + surface->MoveTo(ircSegment.right, ircSegment.top); + surface->LineTo(ircSegment.right, ircSegment.bottom); if (subLine == ll->lines) { - surface->MoveTo(static_cast(rcSegment.left), static_cast(rcSegment.top)); - surface->LineTo(static_cast(rcSegment.right), static_cast(rcSegment.top)); + surface->MoveTo(ircSegment.left, ircSegment.top); + surface->LineTo(ircSegment.right, ircSegment.top); } if (subLine == ll->lines + annotationLines - 1) { - surface->MoveTo(static_cast(rcSegment.left), static_cast(rcSegment.bottom - 1)); - surface->LineTo(static_cast(rcSegment.right), static_cast(rcSegment.bottom - 1)); + surface->MoveTo(ircSegment.left, ircSegment.bottom - 1); + surface->LineTo(ircSegment.right, ircSegment.bottom - 1); } } } } static void DrawBlockCaret(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) { + int subLine, int xStart, Sci::Position offset, Sci::Position posCaret, PRectangle rcCaret, ColourDesired caretColour) { - int lineStart = ll->LineStart(subLine); - int posBefore = posCaret; - int posAfter = model.pdoc->MovePositionOutsideChar(posCaret + 1, 1); - int numCharsToDraw = posAfter - posCaret; + const Sci::Position lineStart = ll->LineStart(subLine); + Sci::Position posBefore = posCaret; + Sci::Position posAfter = model.pdoc->MovePositionOutsideChar(posCaret + 1, 1); + Sci::Position 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); + Sci::Position offsetFirstChar = offset; + Sci::Position offsetLastChar = offset + (posAfter - posCaret); while ((posBefore > 0) && ((offsetLastChar - numCharsToDraw) >= lineStart)) { if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - numCharsToDraw]) > 0) { // The char does not share horizontal space @@ -1135,46 +1308,52 @@ static void DrawBlockCaret(Surface *surface, const EditModel &model, const ViewS // Adjust caret position to take into account any word wrapping symbols. if ((ll->wrapIndent != 0) && (lineStart != 0)) { - XYPOSITION wordWrapCharWidth = ll->wrapIndent; + const XYPOSITION wordWrapCharWidth = ll->wrapIndent; rcCaret.left += wordWrapCharWidth; rcCaret.right += wordWrapCharWidth; } // This character is where the caret block is, we override the colours // (inversed) for drawing the caret here. - int styleMain = ll->styles[offsetFirstChar]; + const int styleMain = ll->styles[offsetFirstChar]; FontAlias fontText = vsDraw.styles[styleMain].font; surface->DrawTextClipped(rcCaret, fontText, - rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar, - numCharsToDraw, vsDraw.styles[styleMain].back, + rcCaret.top + vsDraw.maxAscent, &ll->chars[offsetFirstChar], + static_cast(numCharsToDraw), vsDraw.styles[styleMain].back, caretColour); } void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int lineDoc, int xStart, PRectangle rcLine, int subLine) const { + Sci::Line lineDoc, int xStart, PRectangle rcLine, int subLine) const { // When drag is active it is the only caret drawn - bool drawDrag = model.posDrag.IsValid(); + const bool drawDrag = model.posDrag.IsValid(); if (hideSelection && !drawDrag) return; - const int posLineStart = model.pdoc->LineStart(lineDoc); + const Sci::Position posLineStart = model.pdoc->LineStart(lineDoc); // For each selection draw for (size_t r = 0; (r model.sel.Range(r).anchor) { + if (posCaret.VirtualSpace() > 0) + posCaret.SetVirtualSpace(posCaret.VirtualSpace() - 1); + else + posCaret.SetPosition(model.pdoc->MovePositionOutsideChar(posCaret.Position()-1, -1)); + } + const int offset = static_cast(posCaret.Position() - posLineStart); const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; const XYPOSITION virtualOffset = posCaret.VirtualSpace() * spaceWidth; if (ll->InLine(offset, subLine) && offset <= ll->numCharsBeforeEOL) { XYPOSITION xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)]; if (ll->wrapIndent != 0) { - int lineStart = ll->LineStart(subLine); + const Sci::Position lineStart = ll->LineStart(subLine); if (lineStart != 0) // Wrapped xposCaret += ll->wrapIndent; } - bool caretBlinkState = (model.caret.active && model.caret.on) || (!additionalCaretsBlink && !mainCaret); - bool caretVisibleState = additionalCaretsVisible || mainCaret; + const bool caretBlinkState = (model.caret.active && model.caret.on) || (!additionalCaretsBlink && !mainCaret); + const bool caretVisibleState = additionalCaretsVisible || mainCaret; if ((xposCaret >= 0) && (vsDraw.caretWidth > 0) && (vsDraw.caretStyle != CARETSTYLE_INVISIBLE) && - ((model.posDrag.IsValid()) || (caretBlinkState && caretVisibleState))) { + (drawDrag || (caretBlinkState && caretVisibleState))) { bool caretAtEOF = false; bool caretAtEOL = false; bool drawBlockCaret = false; @@ -1198,16 +1377,17 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt if (xposCaret > 0) caretWidthOffset = 0.51f; // Move back so overlaps both character cells. xposCaret += xStart; - if (model.posDrag.IsValid()) { + const ViewStyle::CaretShape caretShape = drawDrag ? ViewStyle::CaretShape::line : vsDraw.CaretShapeForMode(model.inOverstrike); + if (drawDrag) { /* Dragging text, use a line caret */ - rcCaret.left = static_cast(RoundXYPosition(xposCaret - caretWidthOffset)); + rcCaret.left = round(xposCaret - caretWidthOffset); rcCaret.right = rcCaret.left + vsDraw.caretWidth; - } else if (model.inOverstrike && drawOverstrikeCaret) { + } else if ((caretShape == ViewStyle::CaretShape::bar) && drawOverstrikeCaret) { /* Overstrike (insert mode), use a modified bar caret */ rcCaret.top = rcCaret.bottom - 2; rcCaret.left = xposCaret + 1; rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1; - } else if ((vsDraw.caretStyle == CARETSTYLE_BLOCK) || imeCaretBlockOverride) { + } else if ((caretShape == ViewStyle::CaretShape::block) || imeCaretBlockOverride) { /* Block caret */ rcCaret.left = xposCaret; if (!caretAtEOL && !caretAtEOF && (ll->chars[offset] != '\t') && !(IsControlCharacter(ll->chars[offset]))) { @@ -1218,10 +1398,10 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt } } else { /* Line caret */ - rcCaret.left = static_cast(RoundXYPosition(xposCaret - caretWidthOffset)); + rcCaret.left = round(xposCaret - caretWidthOffset); rcCaret.right = rcCaret.left + vsDraw.caretWidth; } - ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour; + const ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour; if (drawBlockCaret) { DrawBlockCaret(surface, model, vsDraw, ll, subLine, xStart, offset, posCaret.Position(), rcCaret, caretColour); } else { @@ -1235,11 +1415,19 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt } static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, const LineLayout *ll, - int xStart, PRectangle rcLine, ColourOptional background, DrawWrapMarkerFn customDrawWrapMarker) { + int xStart, PRectangle rcLine, ColourOptional background, DrawWrapMarkerFn customDrawWrapMarker, + bool caretActive) { // default bgnd here.. surface->FillRectangle(rcLine, background.isSet ? background : vsDraw.styles[STYLE_DEFAULT].back); + if (vsDraw.IsLineFrameOpaque(caretActive, ll->containsCaret)) { + const int width = vsDraw.GetFrameWidth(); + // Draw left of frame under marker + DrawFrame(surface, vsDraw.caretLineBackground, vsDraw.caretLineAlpha, + PRectangle(rcLine.left, rcLine.top, rcLine.left + width, rcLine.bottom)); + } + if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_START) { // draw continuation rect @@ -1253,7 +1441,7 @@ static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, c else rcPlace.right = rcPlace.left + vsDraw.aveCharWidth; - if (customDrawWrapMarker == NULL) { + if (!customDrawWrapMarker) { DrawWrapMarker(surface, rcPlace, false, vsDraw.WrapColour()); } else { customDrawWrapMarker(surface, rcPlace, false, vsDraw.WrapColour()); @@ -1262,7 +1450,7 @@ static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, c } void EditView::DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - PRectangle rcLine, Range lineRange, int posLineStart, int xStart, + PRectangle rcLine, Range lineRange, Sci::Position posLineStart, int xStart, int subLine, ColourOptional background) const { const bool selBackDrawn = vsDraw.SelectionBackgroundDrawn(); @@ -1271,7 +1459,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi // Does not take margin into account but not significant const int xStartVisible = static_cast(subLineStart)-xStart; - BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs, NULL); + BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs, nullptr); const bool drawWhitespaceBackground = vsDraw.WhitespaceBackgroundDrawn() && !background.isSet; @@ -1279,8 +1467,8 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi while (bfBack.More()) { const TextSegment ts = bfBack.Next(); - const int i = ts.end() - 1; - const int iDoc = i + posLineStart; + const Sci::Position i = ts.end() - 1; + const Sci::Position iDoc = i + posLineStart; PRectangle rcSegment = rcLine; rcSegment.left = ll->positions[ts.start] + xStart - static_cast(subLineStart); @@ -1301,8 +1489,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi if (ts.representation) { if (ll->chars[i] == '\t') { // Tab display - if (drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) + if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) textBack = vsDraw.whitespaceColours.back; } else { // Blob display @@ -1312,13 +1499,11 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi } else { // Normal text display surface->FillRectangle(rcSegment, textBack); - if (vsDraw.viewWhitespace != wsInvisible || - (inIndentation && vsDraw.viewIndentationGuides == ivReal)) { + if (vsDraw.viewWhitespace != wsInvisible) { for (int cpos = 0; cpos <= i - ts.start; cpos++) { if (ll->chars[cpos + ts.start] == ' ') { - if (drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { - PRectangle rcSpace( + if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) { + const PRectangle rcSpace( ll->positions[cpos + ts.start] + xStart - static_cast(subLineStart), rcSegment.top, ll->positions[cpos + ts.start + 1] + xStart - static_cast(subLineStart), @@ -1341,18 +1526,30 @@ static void DrawEdgeLine(Surface *surface, const ViewStyle &vsDraw, const LineLa Range lineRange, int xStart) { if (vsDraw.edgeState == EDGE_LINE) { PRectangle rcSegment = rcLine; - int edgeX = static_cast(vsDraw.theEdge * vsDraw.spaceWidth); + const int edgeX = static_cast(vsDraw.theEdge.column * vsDraw.spaceWidth); rcSegment.left = static_cast(edgeX + xStart); if ((ll->wrapIndent != 0) && (lineRange.start != 0)) rcSegment.left -= ll->wrapIndent; rcSegment.right = rcSegment.left + 1; - surface->FillRectangle(rcSegment, vsDraw.edgecolour); + surface->FillRectangle(rcSegment, vsDraw.theEdge.colour); + } else if (vsDraw.edgeState == EDGE_MULTILINE) { + for (size_t edge = 0; edge < vsDraw.theMultiEdge.size(); edge++) { + if (vsDraw.theMultiEdge[edge].column >= 0) { + PRectangle rcSegment = rcLine; + const int edgeX = static_cast(vsDraw.theMultiEdge[edge].column * vsDraw.spaceWidth); + rcSegment.left = static_cast(edgeX + xStart); + if ((ll->wrapIndent != 0) && (lineRange.start != 0)) + rcSegment.left -= ll->wrapIndent; + rcSegment.right = rcSegment.left + 1; + surface->FillRectangle(rcSegment, vsDraw.theMultiEdge[edge].colour); + } + } } } // Draw underline mark as part of background if not transparent static void DrawMarkUnderline(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, - int line, PRectangle rcLine) { + Sci::Line line, PRectangle rcLine) { int marks = model.pdoc->GetMark(line); for (int markBit = 0; (markBit < 32) && marks; markBit++) { if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) && @@ -1365,22 +1562,22 @@ static void DrawMarkUnderline(Surface *surface, const EditModel &model, const Vi } } static void DrawTranslucentSelection(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int line, PRectangle rcLine, int subLine, Range lineRange, int xStart) { + Sci::Line line, PRectangle rcLine, int subLine, Range lineRange, int xStart) { if ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha != SC_ALPHA_NOALPHA)) { - const int posLineStart = model.pdoc->LineStart(line); + const Sci::Position posLineStart = model.pdoc->LineStart(line); const XYACCUMULATOR subLineStart = ll->positions[lineRange.start]; // For each selection draw - int virtualSpaces = 0; + Sci::Position virtualSpaces = 0; if (subLine == (ll->lines - 1)) { virtualSpaces = model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line)); } - SelectionPosition posStart(posLineStart + lineRange.start); - SelectionPosition posEnd(posLineStart + lineRange.end, virtualSpaces); - SelectionSegment virtualSpaceRange(posStart, posEnd); + const SelectionPosition posStart(posLineStart + lineRange.start); + const SelectionPosition posEnd(posLineStart + lineRange.end, virtualSpaces); + const SelectionSegment virtualSpaceRange(posStart, posEnd); for (size_t r = 0; r < model.sel.Count(); r++) { - int alpha = (r == model.sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; + const int alpha = (r == model.sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; if (alpha != SC_ALPHA_NOALPHA) { - SelectionSegment portion = model.sel.Range(r).Intersect(virtualSpaceRange); + const SelectionSegment portion = model.sel.Range(r).Intersect(virtualSpaceRange); if (!portion.Empty()) { const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; PRectangle rcSegment = rcLine; @@ -1404,36 +1601,40 @@ static void DrawTranslucentSelection(Surface *surface, const EditModel &model, c // Draw any translucent whole line states static void DrawTranslucentLineState(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int line, PRectangle rcLine) { - if ((model.caret.active || vsDraw.alwaysShowCaretLineBackground) && vsDraw.showCaretLineBackground && ll->containsCaret) { - SimpleAlphaRectangle(surface, rcLine, vsDraw.caretLineBackground, vsDraw.caretLineAlpha); - } - int marks = model.pdoc->GetMark(line); - for (int markBit = 0; (markBit < 32) && marks; markBit++) { - if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) { - SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); - } else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) { - PRectangle rcUnderline = rcLine; - rcUnderline.top = rcUnderline.bottom - 2; - SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); + Sci::Line line, PRectangle rcLine, int subLine) { + if ((model.caret.active || vsDraw.alwaysShowCaretLineBackground) && vsDraw.showCaretLineBackground && ll->containsCaret && + vsDraw.caretLineAlpha != SC_ALPHA_NOALPHA) { + if (vsDraw.caretLineFrame) { + DrawCaretLineFramed(surface, vsDraw, ll, rcLine, subLine); + } else { + SimpleAlphaRectangle(surface, rcLine, vsDraw.caretLineBackground, vsDraw.caretLineAlpha); } - marks >>= 1; } - if (vsDraw.maskInLine) { - int marksMasked = model.pdoc->GetMark(line) & vsDraw.maskInLine; - if (marksMasked) { - for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { - if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { - SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); - } - marksMasked >>= 1; + const int marksOfLine = model.pdoc->GetMark(line); + int marksDrawnInText = marksOfLine & vsDraw.maskDrawInText; + for (int markBit = 0; (markBit < 32) && marksDrawnInText; markBit++) { + if (marksDrawnInText & 1) { + if (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) { + SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); + } else if (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) { + PRectangle rcUnderline = rcLine; + rcUnderline.top = rcUnderline.bottom - 2; + SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); } } + marksDrawnInText >>= 1; + } + int marksDrawnInLine = marksOfLine & vsDraw.maskInLine; + for (int markBit = 0; (markBit < 32) && marksDrawnInLine; markBit++) { + if (marksDrawnInLine & 1) { + SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); + } + marksDrawnInLine >>= 1; } } void EditView::DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int lineVisible, PRectangle rcLine, Range lineRange, int posLineStart, int xStart, + Sci::Line lineVisible, PRectangle rcLine, Range lineRange, Sci::Position posLineStart, int xStart, int subLine, ColourOptional background) { const bool selBackDrawn = vsDraw.SelectionBackgroundDrawn(); @@ -1453,8 +1654,8 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi while (bfFore.More()) { const TextSegment ts = bfFore.Next(); - const int i = ts.end() - 1; - const int iDoc = i + posLineStart; + const Sci::Position i = ts.end() - 1; + const Sci::Position iDoc = i + posLineStart; PRectangle rcSegment = rcLine; rcSegment.left = ll->positions[ts.start] + xStart - static_cast(subLineStart); @@ -1462,7 +1663,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi // 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.Intersects(rcLine)) { - int styleMain = ll->styles[i]; + const int styleMain = ll->styles[i]; ColourDesired textFore = vsDraw.styles[styleMain].fore; FontAlias textFont = vsDraw.styles[styleMain].font; //hotspot foreground @@ -1471,14 +1672,14 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi if (vsDraw.hotspotColours.fore.isSet) textFore = vsDraw.hotspotColours.fore; } - if (vsDraw.indicatorsSetFore > 0) { + if (vsDraw.indicatorsSetFore) { // At least one indicator sets the text colour so see if it applies to this segment - for (Decoration *deco = model.pdoc->decorations.root; deco; deco = deco->next) { - const int indicatorValue = deco->rs.ValueAt(ts.start + posLineStart); + for (const IDecoration *deco : model.pdoc->decorations->View()) { + const int indicatorValue = deco->ValueAt(ts.start + posLineStart); if (indicatorValue) { - const Indicator &indicator = vsDraw.indicators[deco->indicator]; + const Indicator &indicator = vsDraw.indicators[deco->Indicator()]; const bool hover = indicator.IsDynamic() && - ((model.hoverIndicatorPos >= ts.start + posLineStart) && + ((model.hoverIndicatorPos >= ts.start + posLineStart) && (model.hoverIndicatorPos <= ts.end() + posLineStart)); if (hover) { if (indicator.sacHover.style == INDIC_TEXTFORE) { @@ -1487,7 +1688,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi } else { if (indicator.sacNormal.style == INDIC_TEXTFORE) { if (indicator.Flags() & SC_INDICFLAG_VALUEFORE) - textFore = indicatorValue & SC_INDICVALUEMASK; + textFore = ColourDesired(indicatorValue & SC_INDICVALUEMASK); else textFore = indicator.sacNormal.fore; } @@ -1504,8 +1705,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi if (ll->chars[i] == '\t') { // Tab display if (phasesDraw == phasesOne) { - if (drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) + if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) textBack = vsDraw.whitespaceColours.back; surface->FillRectangle(rcSegment, textBack); } @@ -1514,23 +1714,24 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { - int xIndent = static_cast(indentCount * indentWidth); + const XYPOSITION xIndent = std::floor(indentCount * indentWidth); DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } } } if (vsDraw.viewWhitespace != wsInvisible) { - if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { + if (vsDraw.WhiteSpaceVisible(inIndentation)) { if (vsDraw.whitespaceColours.fore.isSet) textFore = vsDraw.whitespaceColours.fore; surface->PenColour(textFore); - PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowHeight, + const PRectangle rcTab(rcSegment.left + 1, rcSegment.top + tabArrowHeight, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); - if (customDrawTabArrow == NULL) - DrawTabArrow(surface, rcTab, static_cast(rcSegment.top + vsDraw.lineHeight / 2)); + const int segmentTop = static_cast(rcSegment.top + vsDraw.lineHeight / 2); + if (!customDrawTabArrow) + DrawTabArrow(surface, rcTab, segmentTop, vsDraw); else - customDrawTabArrow(surface, rcTab, static_cast(rcSegment.top + vsDraw.lineHeight / 2)); + customDrawTabArrow(surface, rcTab, segmentTop); } } } else { @@ -1540,7 +1741,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi // the box goes around the characters tightly. Seems to be no way to work out what height // is taken by an individual character - internal leading gives varying results. FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; - char cc[2] = { static_cast(vsDraw.controlCharSymbol), '\0' }; + const char cc[2] = { static_cast(vsDraw.controlCharSymbol), '\0' }; surface->DrawTextNoClip(rcSegment, ctrlCharsFont, rcSegment.top + vsDraw.maxAscent, cc, 1, textBack, textFore); @@ -1554,12 +1755,12 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi if (vsDraw.styles[styleMain].visible) { if (phasesDraw != phasesOne) { surface->DrawTextTransparent(rcSegment, textFont, - rcSegment.top + vsDraw.maxAscent, ll->chars + ts.start, - i - ts.start + 1, textFore); + rcSegment.top + vsDraw.maxAscent, &ll->chars[ts.start], + static_cast(i - ts.start + 1), textFore); } else { surface->DrawTextNoClip(rcSegment, textFont, - rcSegment.top + vsDraw.maxAscent, ll->chars + ts.start, - i - ts.start + 1, textFore, textBack); + rcSegment.top + vsDraw.maxAscent, &ll->chars[ts.start], + static_cast(i - ts.start + 1), textFore, textBack); } } if (vsDraw.viewWhitespace != wsInvisible || @@ -1569,19 +1770,19 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi if (vsDraw.viewWhitespace != wsInvisible) { if (vsDraw.whitespaceColours.fore.isSet) textFore = vsDraw.whitespaceColours.fore; - if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { - XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2; - if ((phasesDraw == phasesOne) && drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { + if (vsDraw.WhiteSpaceVisible(inIndentation)) { + const XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2; + if ((phasesDraw == phasesOne) && drawWhitespaceBackground) { textBack = vsDraw.whitespaceColours.back; - PRectangle rcSpace( + const PRectangle rcSpace( ll->positions[cpos + ts.start] + xStart - static_cast(subLineStart), rcSegment.top, ll->positions[cpos + ts.start + 1] + xStart - static_cast(subLineStart), rcSegment.bottom); surface->FillRectangle(rcSpace, textBack); } - PRectangle rcDot(xmid + xStart - static_cast(subLineStart), + const int halfDotWidth = vsDraw.whitespaceSize / 2; + PRectangle rcDot(xmid + xStart - halfDotWidth - static_cast(subLineStart), rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f); rcDot.right = rcDot.left + vsDraw.whitespaceSize; rcDot.bottom = rcDot.top + vsDraw.whitespaceSize; @@ -1593,7 +1794,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { - int xIndent = static_cast(indentCount * indentWidth); + const XYPOSITION xIndent = std::floor(indentCount * indentWidth); DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } @@ -1626,24 +1827,24 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi } void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int line, int lineVisible, PRectangle rcLine, int xStart, int subLine) { + Sci::Line line, Sci::Line lineVisible, PRectangle rcLine, int xStart, int subLine) { if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth) && (subLine == 0)) { - const int posLineStart = model.pdoc->LineStart(line); + const Sci::Position posLineStart = model.pdoc->LineStart(line); int indentSpace = model.pdoc->GetLineIndentation(line); int xStartText = static_cast(ll->positions[model.pdoc->GetLineIndentPosition(line) - posLineStart]); // Find the most recent line with some text - int lineLastWithText = line; - while (lineLastWithText > Platform::Maximum(line - 20, 0) && model.pdoc->IsWhiteLine(lineLastWithText)) { + Sci::Line lineLastWithText = line; + while (lineLastWithText > std::max(line - 20, static_cast(0)) && model.pdoc->IsWhiteLine(lineLastWithText)) { lineLastWithText--; } if (lineLastWithText < line) { xStartText = 100000; // Don't limit to visible indentation on empty line // This line is empty, so use indentation of last line with text int indentLastWithText = model.pdoc->GetLineIndentation(lineLastWithText); - int isFoldHeader = model.pdoc->GetLevel(lineLastWithText) & SC_FOLDLEVELHEADERFLAG; + const int isFoldHeader = model.pdoc->GetLevel(lineLastWithText) & SC_FOLDLEVELHEADERFLAG; if (isFoldHeader) { // Level is one more level than parent indentLastWithText += model.pdoc->IndentSize(); @@ -1651,26 +1852,26 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode if (vsDraw.viewIndentationGuides == ivLookForward) { // In viLookForward mode, previous line only used if it is a fold header if (isFoldHeader) { - indentSpace = Platform::Maximum(indentSpace, indentLastWithText); + indentSpace = std::max(indentSpace, indentLastWithText); } } else { // viLookBoth - indentSpace = Platform::Maximum(indentSpace, indentLastWithText); + indentSpace = std::max(indentSpace, indentLastWithText); } } - int lineNextWithText = line; - while (lineNextWithText < Platform::Minimum(line + 20, model.pdoc->LinesTotal()) && model.pdoc->IsWhiteLine(lineNextWithText)) { + Sci::Line lineNextWithText = line; + while (lineNextWithText < std::min(line + 20, model.pdoc->LinesTotal()) && model.pdoc->IsWhiteLine(lineNextWithText)) { lineNextWithText++; } if (lineNextWithText > line) { xStartText = 100000; // Don't limit to visible indentation on empty line // This line is empty, so use indentation of first next line with text - indentSpace = Platform::Maximum(indentSpace, + indentSpace = std::max(indentSpace, model.pdoc->GetLineIndentation(lineNextWithText)); } for (int indentPos = model.pdoc->IndentSize(); indentPos < indentSpace; indentPos += model.pdoc->IndentSize()) { - int xIndent = static_cast(indentPos * vsDraw.spaceWidth); + const XYPOSITION xIndent = std::floor(indentPos * vsDraw.spaceWidth); if (xIndent < xStartText) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcLine, (ll->xHighlightGuide == xIndent)); @@ -1680,39 +1881,46 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode } void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int line, int lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) { + Sci::Line line, Sci::Line lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase) { if (subLine >= ll->lines) { DrawAnnotation(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, phase); return; // No further drawing } - // See if something overrides the line background color. + // See if something overrides the line background colour. const ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret); - const int posLineStart = model.pdoc->LineStart(line); + const Sci::Position posLineStart = model.pdoc->LineStart(line); - const Range lineRange = ll->SubLineRange(subLine); + const Range lineRange = ll->SubLineRange(subLine, LineLayout::Scope::visibleOnly); + const Range lineRangeIncludingEnd = ll->SubLineRange(subLine, LineLayout::Scope::includeEnd); const XYACCUMULATOR subLineStart = ll->positions[lineRange.start]; if ((ll->wrapIndent != 0) && (subLine > 0)) { if (phase & drawBack) { - DrawWrapIndentAndMarker(surface, vsDraw, ll, xStart, rcLine, background, customDrawWrapMarker); + DrawWrapIndentAndMarker(surface, vsDraw, ll, xStart, rcLine, background, customDrawWrapMarker, model.caret.active); } xStart += static_cast(ll->wrapIndent); } - if ((phasesDraw != phasesOne) && (phase & drawBack)) { - DrawBackground(surface, model, vsDraw, ll, rcLine, lineRange, posLineStart, xStart, - subLine, background); - DrawEOL(surface, model, vsDraw, ll, rcLine, line, lineRange.end, - xStart, subLine, subLineStart, background); - } + if (phasesDraw != phasesOne) { + if (phase & drawBack) { + DrawBackground(surface, model, vsDraw, ll, rcLine, lineRange, posLineStart, xStart, + subLine, background); + DrawFoldDisplayText(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, subLineStart, drawBack); + phase = static_cast(phase & ~drawBack); // Remove drawBack to not draw again in DrawFoldDisplayText + DrawEOL(surface, model, vsDraw, ll, rcLine, line, lineRange.end, + xStart, subLine, subLineStart, background); + if (vsDraw.IsLineFrameOpaque(model.caret.active, ll->containsCaret)) + DrawCaretLineFramed(surface, vsDraw, ll, rcLine, subLine); + } - if (phase & drawIndicatorsBack) { - DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, true, model.hoverIndicatorPos); - DrawEdgeLine(surface, vsDraw, ll, rcLine, lineRange, xStart); - DrawMarkUnderline(surface, model, vsDraw, line, rcLine); + if (phase & drawIndicatorsBack) { + DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRangeIncludingEnd.end, true, model.hoverIndicatorPos); + DrawEdgeLine(surface, vsDraw, ll, rcLine, lineRange, xStart); + DrawMarkUnderline(surface, model, vsDraw, line, rcLine); + } } if (phase & drawText) { @@ -1725,13 +1933,18 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl } if (phase & drawIndicatorsFore) { - DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRange.end, false, model.hoverIndicatorPos); + DrawIndicators(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, lineRangeIncludingEnd.end, false, model.hoverIndicatorPos); } - // End of the drawing of the current line + DrawFoldDisplayText(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, subLineStart, phase); + if (phasesDraw == phasesOne) { DrawEOL(surface, model, vsDraw, ll, rcLine, line, lineRange.end, xStart, subLine, subLineStart, background); + if (vsDraw.IsLineFrameOpaque(model.caret.active, ll->containsCaret)) + DrawCaretLineFramed(surface, vsDraw, ll, rcLine, subLine); + DrawEdgeLine(surface, vsDraw, ll, rcLine, lineRange, xStart); + DrawMarkUnderline(surface, model, vsDraw, line, rcLine); } if (!hideSelection && (phase & drawSelectionTranslucent)) { @@ -1739,16 +1952,16 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl } if (phase & drawLineTranslucent) { - DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine); + DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine, subLine); } } -static void DrawFoldLines(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, int line, PRectangle rcLine) { - bool expanded = model.cs.GetExpanded(line); +static void DrawFoldLines(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, Sci::Line line, PRectangle rcLine) { + const bool expanded = model.pcs->GetExpanded(line); const int level = model.pdoc->GetLevel(line); const int levelNext = model.pdoc->GetLevel(line + 1); if ((level & SC_FOLDLEVELHEADERFLAG) && - ((level & SC_FOLDLEVELNUMBERMASK) < (levelNext & SC_FOLDLEVELNUMBERMASK))) { + (LevelNumber(level) < LevelNumber(levelNext))) { // Paint the line above the fold if ((expanded && (model.foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) || @@ -1779,7 +1992,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan Surface *surface = surfaceWindow; if (bufferedDraw) { - surface = pixmapLine; + surface = pixmapLine.get(); PLATFORM_ASSERT(pixmapLine->Initialised()); } surface->SetUnicodeMode(SC_CP_UTF8 == model.pdoc->dbcsCodePage); @@ -1793,7 +2006,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan SelectionPosition posCaret = model.sel.RangeMain().caret; if (model.posDrag.IsValid()) posCaret = model.posDrag; - const int lineCaret = model.pdoc->LineFromPosition(posCaret.Position()); + const Sci::Line lineCaret = model.pdoc->SciLineFromPosition(posCaret.Position()); PRectangle rcTextArea = rcClient; if (vsDraw.marginInside) { @@ -1812,16 +2025,17 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan } // Loop on visible lines - //double durLayout = 0.0; - //double durPaint = 0.0; - //double durCopy = 0.0; - //ElapsedTime etWhole; - +#if defined(TIME_PAINTING) + double durLayout = 0.0; + double durPaint = 0.0; + double durCopy = 0.0; + ElapsedPeriod epWhole; +#endif const bool bracesIgnoreStyle = ((vsDraw.braceHighlightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACELIGHT)) || (vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACEBAD))); - int lineDocPrevious = -1; // Used to avoid laying out one document line multiple times - AutoLineLayout ll(llc, 0); + Sci::Line lineDocPrevious = -1; // Used to avoid laying out one document line multiple times + AutoLineLayout ll(llc, nullptr); std::vector phases; if ((phasesDraw == phasesMultiple) && !bufferedDraw) { for (DrawPhase phase = drawBack; phase <= drawCarets; phase = static_cast(phase * 2)) { @@ -1830,31 +2044,34 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan } else { phases.push_back(drawAll); } - for (std::vector::iterator it = phases.begin(); it != phases.end(); ++it) { + for (const DrawPhase &phase : phases) { int ypos = 0; if (!bufferedDraw) ypos += screenLinePaintFirst * vsDraw.lineHeight; int yposScreen = screenLinePaintFirst * vsDraw.lineHeight; - int visibleLine = model.TopLineOfMain() + screenLinePaintFirst; - while (visibleLine < model.cs.LinesDisplayed() && yposScreen < rcArea.bottom) { + Sci::Line visibleLine = model.TopLineOfMain() + screenLinePaintFirst; + while (visibleLine < model.pcs->LinesDisplayed() && yposScreen < rcArea.bottom) { - const int lineDoc = model.cs.DocFromDisplay(visibleLine); + const Sci::Line lineDoc = model.pcs->DocFromDisplay(visibleLine); // Only visible lines should be handled by the code within the loop - PLATFORM_ASSERT(model.cs.GetVisible(lineDoc)); - const int lineStartSet = model.cs.DisplayFromDoc(lineDoc); - const int subLine = visibleLine - lineStartSet; + PLATFORM_ASSERT(model.pcs->GetVisible(lineDoc)); + const Sci::Line lineStartSet = model.pcs->DisplayFromDoc(lineDoc); + const int subLine = static_cast(visibleLine - lineStartSet); // Copy this line and its styles from the document into local arrays // and determine the x position at which each character starts. - //ElapsedTime et; +#if defined(TIME_PAINTING) + ElapsedPeriod ep; +#endif if (lineDoc != lineDocPrevious) { - ll.Set(0); + ll.Set(nullptr); ll.Set(RetrieveLineLayout(lineDoc, model)); LayoutLine(model, lineDoc, surface, vsDraw, ll, model.wrapWidth); lineDocPrevious = lineDoc; } - //durLayout += et.Duration(true); - +#if defined(TIME_PAINTING) + durLayout += ep.Duration(true); +#endif if (ll) { ll->containsCaret = !hideSelection && (lineDoc == lineCaret); ll->hotspot = model.GetHotSpotRange(); @@ -1863,44 +2080,49 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan rcLine.top = static_cast(ypos); rcLine.bottom = static_cast(ypos + vsDraw.lineHeight); - Range rangeLine(model.pdoc->LineStart(lineDoc), model.pdoc->LineStart(lineDoc + 1)); + const Range rangeLine(model.pdoc->LineStart(lineDoc), + model.pdoc->LineStart(lineDoc + 1)); // Highlight the current braces if any ll->SetBracesHighlight(rangeLine, model.braces, static_cast(model.bracesMatchStyle), static_cast(model.highlightGuideColumn * vsDraw.spaceWidth), bracesIgnoreStyle); - if (leftTextOverlap && bufferedDraw) { + if (leftTextOverlap && (bufferedDraw || ((phasesDraw < phasesMultiple) && (phase & drawBack)))) { + // Clear the left margin PRectangle rcSpacer = rcLine; rcSpacer.right = rcSpacer.left; rcSpacer.left -= 1; surface->FillRectangle(rcSpacer, vsDraw.styles[STYLE_DEFAULT].back); } - DrawLine(surface, model, vsDraw, ll, lineDoc, visibleLine, xStart, rcLine, subLine, *it); - //durPaint += et.Duration(true); - + DrawLine(surface, model, vsDraw, ll, lineDoc, visibleLine, xStart, rcLine, subLine, phase); +#if defined(TIME_PAINTING) + durPaint += ep.Duration(true); +#endif // Restore the previous styles for the brace highlights in case layout is in cache. ll->RestoreBracesHighlight(rangeLine, model.braces, bracesIgnoreStyle); - if (*it & drawFoldLines) { + if (phase & drawFoldLines) { DrawFoldLines(surface, model, vsDraw, lineDoc, rcLine); } - if (*it & drawCarets) { + if (phase & drawCarets) { DrawCarets(surface, model, vsDraw, ll, lineDoc, xStart, rcLine, subLine); } if (bufferedDraw) { - Point from = Point::FromInts(vsDraw.textStart - leftTextOverlap, 0); - PRectangle rcCopyArea = PRectangle::FromInts(vsDraw.textStart - leftTextOverlap, yposScreen, + const Point from = Point::FromInts(vsDraw.textStart - leftTextOverlap, 0); + const PRectangle rcCopyArea = PRectangle::FromInts(vsDraw.textStart - leftTextOverlap, yposScreen, static_cast(rcClient.right - vsDraw.rightMarginWidth), yposScreen + vsDraw.lineHeight); surfaceWindow->Copy(rcCopyArea, from, *pixmapLine); } - lineWidthMaxSeen = Platform::Maximum( + lineWidthMaxSeen = std::max( lineWidthMaxSeen, static_cast(ll->positions[ll->numCharsInLine])); - //durCopy += et.Duration(true); +#if defined(TIME_PAINTING) + durCopy += ep.Duration(true); +#endif } if (!bufferedDraw) { @@ -1911,50 +2133,89 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan visibleLine++; } } - ll.Set(0); - //if (durPaint < 0.00000001) - // durPaint = 0.00000001; - + ll.Set(nullptr); +#if defined(TIME_PAINTING) + if (durPaint < 0.00000001) + durPaint = 0.00000001; +#endif // Right column limit indicator PRectangle rcBeyondEOF = (vsDraw.marginInside) ? rcClient : rcArea; rcBeyondEOF.left = static_cast(vsDraw.textStart); rcBeyondEOF.right = rcBeyondEOF.right - ((vsDraw.marginInside) ? vsDraw.rightMarginWidth : 0); - rcBeyondEOF.top = static_cast((model.cs.LinesDisplayed() - model.TopLineOfMain()) * vsDraw.lineHeight); + rcBeyondEOF.top = static_cast((model.pcs->LinesDisplayed() - model.TopLineOfMain()) * vsDraw.lineHeight); if (rcBeyondEOF.top < rcBeyondEOF.bottom) { surfaceWindow->FillRectangle(rcBeyondEOF, vsDraw.styles[STYLE_DEFAULT].back); if (vsDraw.edgeState == EDGE_LINE) { - int edgeX = static_cast(vsDraw.theEdge * vsDraw.spaceWidth); + const int edgeX = static_cast(vsDraw.theEdge.column * vsDraw.spaceWidth); rcBeyondEOF.left = static_cast(edgeX + xStart); rcBeyondEOF.right = rcBeyondEOF.left + 1; - surfaceWindow->FillRectangle(rcBeyondEOF, vsDraw.edgecolour); + surfaceWindow->FillRectangle(rcBeyondEOF, vsDraw.theEdge.colour); + } else if (vsDraw.edgeState == EDGE_MULTILINE) { + for (size_t edge = 0; edge < vsDraw.theMultiEdge.size(); edge++) { + if (vsDraw.theMultiEdge[edge].column >= 0) { + const int edgeX = static_cast(vsDraw.theMultiEdge[edge].column * vsDraw.spaceWidth); + rcBeyondEOF.left = static_cast(edgeX + xStart); + rcBeyondEOF.right = rcBeyondEOF.left + 1; + surfaceWindow->FillRectangle(rcBeyondEOF, vsDraw.theMultiEdge[edge].colour); + } + } } } - //Platform::DebugPrintf("start display %d, offset = %d\n", pdoc->Length(), xOffset); - - //Platform::DebugPrintf( - //"Layout:%9.6g Paint:%9.6g Ratio:%9.6g Copy:%9.6g Total:%9.6g\n", - //durLayout, durPaint, durLayout / durPaint, durCopy, etWhole.Duration()); + //Platform::DebugPrintf("start display %d, offset = %d\n", model.pdoc->Length(), model.xOffset); +#if defined(TIME_PAINTING) + Platform::DebugPrintf( + "Layout:%9.6g Paint:%9.6g Ratio:%9.6g Copy:%9.6g Total:%9.6g\n", + durLayout, durPaint, durLayout / durPaint, durCopy, epWhole.Duration()); +#endif } } +void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, + Sci::Line line, PRectangle rcArea, int subLine) const { + int eolInSelection = 0; + int alpha = SC_ALPHA_NOALPHA; + if (!hideSelection) { + const Sci::Position posAfterLineEnd = model.pdoc->LineStart(line + 1); + eolInSelection = (subLine == (ll->lines - 1)) ? model.sel.InSelectionForEOL(posAfterLineEnd) : 0; + alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; + } + + const ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret); + + if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { + surface->FillRectangle(rcArea, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection)); + } else { + if (background.isSet) { + surface->FillRectangle(rcArea, background); + } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { + surface->FillRectangle(rcArea, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); + } else { + surface->FillRectangle(rcArea, vsDraw.styles[STYLE_DEFAULT].back); + } + if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < model.pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { + SimpleAlphaRectangle(surface, rcArea, SelectionBackground(vsDraw, eolInSelection == 1, model.primarySelection), alpha); + } + } +} + // Space (3 space characters) between line numbers and text when printing. #define lineNumberPrintSpace " " -ColourDesired InvertedLight(ColourDesired orig) { +static ColourDesired InvertedLight(ColourDesired orig) noexcept { unsigned int r = orig.GetRed(); unsigned int g = orig.GetGreen(); unsigned int b = orig.GetBlue(); - unsigned int l = (r + g + b) / 3; // There is a better calculation for this that matches human eye - unsigned int il = 0xff - l; + const unsigned int l = (r + g + b) / 3; // There is a better calculation for this that matches human eye + const unsigned int il = 0xff - l; if (l == 0) return ColourDesired(0xff, 0xff, 0xff); r = r * il / l; g = g * il / l; b = b * il / l; - return ColourDesired(Platform::Minimum(r, 0xff), Platform::Minimum(g, 0xff), Platform::Minimum(b, 0xff)); + return ColourDesired(std::min(r, 0xffu), std::min(g, 0xffu), std::min(b, 0xffu)); } -long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure, +Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure, const EditModel &model, const ViewStyle &vs) { // Can't use measurements cached for screen posCache.Clear(); @@ -1965,9 +2226,9 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, // Modify the view style for printing as do not normally want any of the transient features to be printed // Printing supports only the line number margin. int lineNumberIndex = -1; - for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) { + for (size_t margin = 0; margin < vs.ms.size(); margin++) { if ((vsPrint.ms[margin].style == SC_MARGIN_NUMBER) && (vsPrint.ms[margin].width > 0)) { - lineNumberIndex = margin; + lineNumberIndex = static_cast(margin); } else { vsPrint.ms[margin].width = 0; } @@ -2006,8 +2267,9 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, } } } - // White background for the line numbers - vsPrint.styles[STYLE_LINENUMBER].back = ColourDesired(0xff, 0xff, 0xff); + // White background for the line numbers if SC_PRINT_SCREENCOLOURS isn't used + if (printParameters.colourMode != SC_PRINT_SCREENCOLOURS) + vsPrint.styles[STYLE_LINENUMBER].back = ColourDesired(0xff, 0xff, 0xff); // Printing uses different margins, so reset screen margins vsPrint.leftMarginWidth = 0; @@ -2023,29 +2285,31 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, vsPrint.Refresh(*surfaceMeasure, model.pdoc->tabInChars); // Recalculate fixedColumnWidth } - int linePrintStart = model.pdoc->LineFromPosition(static_cast(pfr->chrg.cpMin)); - int linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1; + const Sci::Line linePrintStart = + model.pdoc->SciLineFromPosition(static_cast(pfr->chrg.cpMin)); + Sci::Line linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1; if (linePrintLast < linePrintStart) linePrintLast = linePrintStart; - int linePrintMax = model.pdoc->LineFromPosition(static_cast(pfr->chrg.cpMax)); + const Sci::Line linePrintMax = + model.pdoc->SciLineFromPosition(static_cast(pfr->chrg.cpMax)); if (linePrintLast > linePrintMax) linePrintLast = linePrintMax; //Platform::DebugPrintf("Formatting lines=[%0d,%0d,%0d] top=%0d bottom=%0d line=%0d %0d\n", // linePrintStart, linePrintLast, linePrintMax, pfr->rc.top, pfr->rc.bottom, vsPrint.lineHeight, // surfaceMeasure->Height(vsPrint.styles[STYLE_LINENUMBER].font)); - int endPosPrint = model.pdoc->Length(); + Sci::Position endPosPrint = model.pdoc->Length(); if (linePrintLast < model.pdoc->LinesTotal()) endPosPrint = model.pdoc->LineStart(linePrintLast + 1); // Ensure we are styled to where we are formatting. model.pdoc->EnsureStyledTo(endPosPrint); - int xStart = vsPrint.fixedColumnWidth + pfr->rc.left; + const int xStart = vsPrint.fixedColumnWidth + pfr->rc.left; int ypos = pfr->rc.top; - int lineDoc = linePrintStart; + Sci::Line lineDoc = linePrintStart; - int nPrintPos = static_cast(pfr->chrg.cpMin); + Sci::Position nPrintPos = static_cast(pfr->chrg.cpMin); int visibleLine = 0; int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth; if (printParameters.wrapState == eWrapNone) @@ -2061,7 +2325,7 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, // Copy this line and its styles from the document into local arrays // and determine the x position at which each character starts. - LineLayout ll(model.pdoc->LineStart(lineDoc + 1) - model.pdoc->LineStart(lineDoc) + 1); + LineLayout ll(static_cast(model.pdoc->LineStart(lineDoc + 1) - model.pdoc->LineStart(lineDoc) + 1)); LayoutLine(model, lineDoc, surfaceMeasure, vsPrint, &ll, widthPrint); ll.containsCaret = false; @@ -2076,7 +2340,8 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, // to start printing from to ensure a particular position is on the first // line of the page. if (visibleLine == 0) { - int startWithinLine = nPrintPos - model.pdoc->LineStart(lineDoc); + const Sci::Position startWithinLine = nPrintPos - + model.pdoc->LineStart(lineDoc); for (int iwl = 0; iwl < ll.lines - 1; iwl++) { if (ll.LineStart(iwl) <= startWithinLine && ll.LineStart(iwl + 1) >= startWithinLine) { visibleLine = -iwl; @@ -2091,16 +2356,15 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, if (draw && lineNumberWidth && (ypos + vsPrint.lineHeight <= pfr->rc.bottom) && (visibleLine >= 0)) { - char number[100]; - sprintf(number, "%d" lineNumberPrintSpace, lineDoc + 1); + const std::string number = std::to_string(lineDoc + 1) + lineNumberPrintSpace; PRectangle rcNumber = rcLine; rcNumber.right = rcNumber.left + lineNumberWidth; // Right justify rcNumber.left = rcNumber.right - surfaceMeasure->WidthText( - vsPrint.styles[STYLE_LINENUMBER].font, number, static_cast(strlen(number))); + vsPrint.styles[STYLE_LINENUMBER].font, number.c_str(), static_cast(number.length())); surface->FlushCachedState(); surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font, - static_cast(ypos + vsPrint.maxAscent), number, static_cast(strlen(number)), + static_cast(ypos + vsPrint.maxAscent), number.c_str(), static_cast(number.length()), vsPrint.styles[STYLE_LINENUMBER].fore, vsPrint.styles[STYLE_LINENUMBER].back); } diff --git a/dep/scintilla/scintilla-3.6.0/src/EditView.h b/dep/scintilla/scintilla-3.10.6/src/EditView.h similarity index 56% rename from dep/scintilla/scintilla-3.6.0/src/EditView.h rename to dep/scintilla/scintilla-3.10.6/src/EditView.h index 79a88657..3addfbab 100644 --- a/dep/scintilla/scintilla-3.6.0/src/EditView.h +++ b/dep/scintilla/scintilla-3.10.6/src/EditView.h @@ -8,15 +8,13 @@ #ifndef EDITVIEW_H #define EDITVIEW_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif struct PrintParameters { int magnification; int colourMode; WrapMode wrapState; - PrintParameters(); + PrintParameters() noexcept; }; /** @@ -44,17 +42,19 @@ void DrawStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, PRec typedef void (*DrawTabArrowFn)(Surface *surface, PRectangle rcTab, int ymid); +class LineTabstops; + /** * EditView draws the main text area. */ class EditView { public: PrintParameters printParameters; - PerLine *ldTabstops; + std::unique_ptr ldTabstops; int tabWidthMinimumPixels; bool hideSelection; - bool drawOverstrikeCaret; + bool drawOverstrikeCaret; // used by the curses platform /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to * the screen. This avoids flashing but is about 30% slower. */ @@ -74,9 +74,9 @@ public: bool imeCaretBlockOverride; - Surface *pixmapLine; - Surface *pixmapIndentGuide; - Surface *pixmapIndentGuideHighlight; + std::unique_ptr pixmapLine; + std::unique_ptr pixmapIndentGuide; + std::unique_ptr pixmapIndentGuideHighlight; LineLayoutCache llc; PositionCache posCache; @@ -90,55 +90,66 @@ public: DrawWrapMarkerFn customDrawWrapMarker; EditView(); + // Deleted so EditView objects can not be copied. + EditView(const EditView &) = delete; + EditView(EditView &&) = delete; + void operator=(const EditView &) = delete; + void operator=(EditView &&) = delete; virtual ~EditView(); - bool SetTwoPhaseDraw(bool twoPhaseDraw); - bool SetPhasesDraw(int phases); - bool LinesOverlap() const; + bool SetTwoPhaseDraw(bool twoPhaseDraw) noexcept; + bool SetPhasesDraw(int phases) noexcept; + bool LinesOverlap() const noexcept; - void ClearAllTabstops(); - XYPOSITION NextTabstopPos(int line, XYPOSITION x, XYPOSITION tabWidth) const; - bool ClearTabstops(int line); - bool AddTabstop(int line, int x); - int GetNextTabstop(int line, int x) const; - void LinesAddedOrRemoved(int lineOfPos, int linesAdded); + void ClearAllTabstops() noexcept; + XYPOSITION NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const; + bool ClearTabstops(Sci::Line line); + bool AddTabstop(Sci::Line line, int x); + int GetNextTabstop(Sci::Line line, int x) const; + void LinesAddedOrRemoved(Sci::Line lineOfPos, Sci::Line linesAdded); void DropGraphics(bool freeObjects); void AllocateGraphics(const ViewStyle &vsDraw); void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw); - LineLayout *RetrieveLineLayout(int lineNumber, const EditModel &model); - void LayoutLine(const EditModel &model, int line, Surface *surface, const ViewStyle &vstyle, + LineLayout *RetrieveLineLayout(Sci::Line lineNumber, const EditModel &model); + void LayoutLine(const EditModel &model, Sci::Line line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width = LineLayout::wrapWidthInfinite); - Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine, const ViewStyle &vs); - SelectionPosition SPositionFromLocation(Surface *surface, const EditModel &model, Point pt, bool canReturnInvalid, + Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, Sci::Line topLine, + const ViewStyle &vs, PointEnd pe); + Range RangeDisplayLine(Surface *surface, const EditModel &model, Sci::Line lineVisible, const ViewStyle &vs); + SelectionPosition SPositionFromLocation(Surface *surface, const EditModel &model, PointDocument pt, bool canReturnInvalid, bool charPosition, bool virtualSpace, const ViewStyle &vs); - SelectionPosition SPositionFromLineX(Surface *surface, const EditModel &model, int lineDoc, int x, const ViewStyle &vs); - int DisplayFromPosition(Surface *surface, const EditModel &model, int pos, const ViewStyle &vs); - int StartEndDisplayLine(Surface *surface, const EditModel &model, int pos, bool start, const ViewStyle &vs); + SelectionPosition SPositionFromLineX(Surface *surface, const EditModel &model, Sci::Line lineDoc, int x, const ViewStyle &vs); + Sci::Line DisplayFromPosition(Surface *surface, const EditModel &model, Sci::Position pos, const ViewStyle &vs); + Sci::Position StartEndDisplayLine(Surface *surface, const EditModel &model, Sci::Position pos, bool start, const ViewStyle &vs); - void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight); + void DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, XYPOSITION start, PRectangle rcSegment, bool highlight); void DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine, - int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, + Sci::Line line, Sci::Position lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, ColourOptional background); + void DrawFoldDisplayText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, + Sci::Line line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase); void DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase); - void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line, + Sci::Line line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase); + void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line lineDoc, int xStart, PRectangle rcLine, int subLine) const; void DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine, - Range lineRange, int posLineStart, int xStart, + Range lineRange, Sci::Position posLineStart, int xStart, int subLine, ColourOptional background) const; - void DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int lineVisible, - PRectangle rcLine, Range lineRange, int posLineStart, int xStart, + void DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line lineVisible, + PRectangle rcLine, Range lineRange, Sci::Position posLineStart, int xStart, int subLine, ColourOptional background); void DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, - int line, int lineVisible, PRectangle rcLine, int xStart, int subLine); - void DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line, - int lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase); + Sci::Line line, Sci::Line lineVisible, PRectangle rcLine, int xStart, int subLine); + void DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line line, + Sci::Line lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase); void PaintText(Surface *surfaceWindow, const EditModel &model, PRectangle rcArea, PRectangle rcClient, const ViewStyle &vsDraw); - long FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure, + void FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, + Sci::Line line, PRectangle rcArea, int subLine) const; + Sci::Position FormatRange(bool draw, const Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure, const EditModel &model, const ViewStyle &vs); }; @@ -148,27 +159,28 @@ public: class AutoLineLayout { LineLayoutCache &llc; LineLayout *ll; - AutoLineLayout &operator=(const AutoLineLayout &); public: - AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {} - ~AutoLineLayout() { + AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) noexcept : llc(llc_), ll(ll_) {} + AutoLineLayout(const AutoLineLayout &) = delete; + AutoLineLayout(AutoLineLayout &&) = delete; + AutoLineLayout &operator=(const AutoLineLayout &) = delete; + AutoLineLayout &operator=(AutoLineLayout &&) = delete; + ~AutoLineLayout() noexcept { llc.Dispose(ll); - ll = 0; + ll = nullptr; } - LineLayout *operator->() const { + LineLayout *operator->() const noexcept { return ll; } - operator LineLayout *() const { + operator LineLayout *() const noexcept { return ll; } - void Set(LineLayout *ll_) { + void Set(LineLayout *ll_) noexcept { llc.Dispose(ll); ll = ll_; } }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/Editor.cxx b/dep/scintilla/scintilla-3.10.6/src/Editor.cxx similarity index 70% rename from dep/scintilla/scintilla-3.6.0/src/Editor.cxx rename to dep/scintilla/scintilla-3.10.6/src/Editor.cxx index 007780a0..acf53205 100644 --- a/dep/scintilla/scintilla-3.6.0/src/Editor.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/Editor.cxx @@ -5,27 +5,34 @@ // Copyright 1998-2011 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include -#include - +#include +#include +#include +#include +#include #include + #include #include #include #include +#include #include +#include #include +#include #include "Platform.h" +#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" #include "StringCopy.h" +#include "CharacterSet.h" +#include "CharacterCategory.h" #include "Position.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -34,7 +41,6 @@ #include "PerLine.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -49,16 +55,17 @@ #include "MarginView.h" #include "EditView.h" #include "Editor.h" +#include "ElapsedPeriod.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif + +namespace { /* 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) { +bool CanDeferToLastStep(const DocModification &mh) noexcept { if (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) return true; // CAN skip if (!(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO))) @@ -68,7 +75,7 @@ static bool CanDeferToLastStep(const DocModification &mh) { return false; // PRESUMABLY must do } -static bool CanEliminate(const DocModification &mh) { +constexpr bool CanEliminate(const DocModification &mh) noexcept { return (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) != 0; } @@ -77,7 +84,7 @@ static bool CanEliminate(const DocModification &mh) { return whether this modification represents the FINAL step in a [possibly lengthy] multi-step Undo/Redo sequence */ -static bool IsLastStep(const DocModification &mh) { +constexpr bool IsLastStep(const DocModification &mh) noexcept { return (mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)) != 0 && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0 @@ -85,13 +92,15 @@ static bool IsLastStep(const DocModification &mh) { && (mh.modificationType & SC_MULTILINEUNDOREDO) != 0; } -Timer::Timer() : - ticking(false), ticksToWait(0), tickerID(0) {} +} -Idler::Idler() : +Timer::Timer() noexcept : + ticking(false), ticksToWait(0), tickerID{} {} + +Idler::Idler() noexcept : state(false), idlerID(0) {} -static inline bool IsAllSpacesOrTabs(const char *s, unsigned int len) { +static bool IsAllSpacesOrTabs(const char *s, unsigned int len) noexcept { for (unsigned int i = 0; i < len; i++) { // This is safe because IsSpaceOrTab() will return false for null terminators if (!IsSpaceOrTab(s[i])) @@ -100,7 +109,7 @@ static inline bool IsAllSpacesOrTabs(const char *s, unsigned int len) { return true; } -Editor::Editor() { +Editor::Editor() : durationWrapOneLine(0.00001, 0.000001, 0.0001) { ctrlID = 0; stylesValid = false; @@ -112,6 +121,7 @@ Editor::Editor() { hasFocus = false; errorStatus = 0; mouseDownCaptures = true; + mouseWheelCaptures = true; lastClickTime = 0; doubleClickCloseThreshold = Point(3, 3); @@ -122,7 +132,7 @@ Editor::Editor() { ptMouseLast.y = 0; inDragDrop = ddNone; dropWentOutside = false; - posDrop = SelectionPosition(invalidPosition); + posDrop = SelectionPosition(Sci::invalidPosition); hotSpotClickPos = INVALID_POSITION; selectionType = selChar; @@ -173,8 +183,11 @@ Editor::Editor() { paintAbandonedByStyling = false; paintingAllText = false; willRedrawAll = false; + idleStyling = SC_IDLESTYLING_NONE; + needIdleStyling = false; modEventMask = SC_MODEVENTMASKALL; + commandEvents = true; pdoc->AddWatcher(this, 0); @@ -200,28 +213,28 @@ void Editor::SetRepresentations() { reprs.Clear(); // C0 control set - const char *reps[] = { + const char *const reps[] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" }; for (size_t j=0; j < ELEMENTS(reps); j++) { - char c[2] = { static_cast(j), 0 }; + const char c[2] = { static_cast(j), 0 }; reprs.SetRepresentation(c, reps[j]); } // C1 control set // As well as Unicode mode, ISO-8859-1 should use these if (IsUnicodeMode()) { - const char *repsC1[] = { + const char *const repsC1[] = { "PAD", "HOP", "BPH", "NBH", "IND", "NEL", "SSA", "ESA", "HTS", "HTJ", "VTS", "PLD", "PLU", "RI", "SS2", "SS3", "DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA", "SOS", "SGCI", "SCI", "CSI", "ST", "OSC", "PM", "APC" }; for (size_t j=0; j < ELEMENTS(repsC1); j++) { - char c1[3] = { '\xc2', static_cast(0x80+j), 0 }; + const char c1[3] = { '\xc2', static_cast(0x80+j), 0 }; reprs.SetRepresentation(c1, repsC1[j]); } reprs.SetRepresentation("\xe2\x80\xa8", "LS"); @@ -231,11 +244,22 @@ void Editor::SetRepresentations() { // UTF-8 invalid bytes if (IsUnicodeMode()) { for (int k=0x80; k < 0x100; k++) { - char hiByte[2] = { static_cast(k), 0 }; - char hexits[4]; + const char hiByte[2] = { static_cast(k), 0 }; + char hexits[5]; // Really only needs 4 but that causes warning from gcc 7.1 sprintf(hexits, "x%2X", k); reprs.SetRepresentation(hiByte, hexits); } + } else if (pdoc->dbcsCodePage) { + // DBCS invalid single lead bytes + for (int k = 0x80; k < 0x100; k++) { + const char ch = static_cast(k); + if (pdoc->IsDBCSLeadByteNoExcept(ch) || pdoc->IsDBCSLeadByteInvalid(ch)) { + const char hiByte[2] = { ch, 0 }; + char hexits[5]; // Really only needs 4 but that causes warning from gcc 7.1 + sprintf(hexits, "x%2X", k); + reprs.SetRepresentation(hiByte, hexits); + } + } } } @@ -277,13 +301,13 @@ void Editor::RefreshStyleData() { } Point Editor::GetVisibleOriginInMain() const { - return Point(0,0); + return Point(0, 0); } -Point Editor::DocumentPointFromView(Point ptView) const { - Point ptDocument = ptView; +PointDocument Editor::DocumentPointFromView(Point ptView) const { + PointDocument ptDocument(ptView); if (wMargin.GetID()) { - Point ptOrigin = GetVisibleOriginInMain(); + const Point ptOrigin = GetVisibleOriginInMain(); ptDocument.x += ptOrigin.x; ptDocument.y += ptOrigin.y; } else { @@ -293,7 +317,7 @@ Point Editor::DocumentPointFromView(Point ptView) const { return ptDocument; } -int Editor::TopLineOfMain() const { +Sci::Line Editor::TopLineOfMain() const { if (wMargin.GetID()) return 0; else @@ -301,8 +325,7 @@ int Editor::TopLineOfMain() const { } PRectangle Editor::GetClientRectangle() const { - Window &win = const_cast(wMain); - return win.GetClientPosition(); + return wMain.GetClientPosition(); } PRectangle Editor::GetClientDrawingRectangle() { @@ -316,25 +339,25 @@ PRectangle Editor::GetTextRectangle() const { return rc; } -int Editor::LinesOnScreen() const { - PRectangle rcClient = GetClientRectangle(); - int htClient = static_cast(rcClient.bottom - rcClient.top); +Sci::Line Editor::LinesOnScreen() const { + const PRectangle rcClient = GetClientRectangle(); + const int htClient = static_cast(rcClient.bottom - rcClient.top); //Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1); return htClient / vs.lineHeight; } -int Editor::LinesToScroll() const { - int retVal = LinesOnScreen() - 1; +Sci::Line Editor::LinesToScroll() const { + const Sci::Line retVal = LinesOnScreen() - 1; if (retVal < 1) return 1; else return retVal; } -int Editor::MaxScrollPos() const { +Sci::Line Editor::MaxScrollPos() const { //Platform::DebugPrintf("Lines %d screen = %d maxScroll = %d\n", //LinesTotal(), LinesOnScreen(), LinesTotal() - LinesOnScreen() + 1); - int retVal = cs.LinesDisplayed(); + Sci::Line retVal = pcs->LinesDisplayed(); if (endAtLastLine) { retVal -= LinesOnScreen(); } else { @@ -360,23 +383,18 @@ SelectionPosition Editor::ClampPositionIntoDocument(SelectionPosition sp) const } } -Point Editor::LocationFromPosition(SelectionPosition pos) { +Point Editor::LocationFromPosition(SelectionPosition pos, PointEnd pe) { RefreshStyleData(); AutoSurface surface(this); - return view.LocationFromPosition(surface, *this, pos, topLine, vs); + return view.LocationFromPosition(surface, *this, pos, topLine, vs, pe); } -Point Editor::LocationFromPosition(int pos) { - return LocationFromPosition(SelectionPosition(pos)); -} - -int Editor::XFromPosition(int pos) { - Point pt = LocationFromPosition(pos); - return static_cast(pt.x) - vs.textStart + xOffset; +Point Editor::LocationFromPosition(Sci::Position pos, PointEnd pe) { + return LocationFromPosition(SelectionPosition(pos), pe); } int Editor::XFromPosition(SelectionPosition sp) { - Point pt = LocationFromPosition(sp); + const Point pt = LocationFromPosition(sp); return static_cast(pt.x) - vs.textStart + xOffset; } @@ -387,7 +405,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, if (canReturnInvalid) { PRectangle rcClient = GetTextRectangle(); // May be in scroll view coordinates so translate back to main view - Point ptOrigin = GetVisibleOriginInMain(); + const Point ptOrigin = GetVisibleOriginInMain(); rcClient.Move(-ptOrigin.x, -ptOrigin.y); if (!rcClient.Contains(pt)) return SelectionPosition(INVALID_POSITION); @@ -396,11 +414,11 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, if (pt.y < 0) return SelectionPosition(INVALID_POSITION); } - pt = DocumentPointFromView(pt); - return view.SPositionFromLocation(surface, *this, pt, canReturnInvalid, charPosition, virtualSpace, vs); + const PointDocument ptdoc = DocumentPointFromView(pt); + return view.SPositionFromLocation(surface, *this, ptdoc, canReturnInvalid, charPosition, virtualSpace, vs); } -int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) { +Sci::Position Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) { return SPositionFromLocation(pt, canReturnInvalid, charPosition, false).Position(); } @@ -409,7 +427,7 @@ int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosit * Ensure is between whole characters when document is in multi-byte or UTF-8 mode. * This method is used for rectangular selections and does not work on wrapped lines. */ -SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) { +SelectionPosition Editor::SPositionFromLineX(Sci::Line lineDoc, int x) { RefreshStyleData(); if (lineDoc >= pdoc->LinesTotal()) return SelectionPosition(pdoc->Length()); @@ -418,20 +436,20 @@ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) { return view.SPositionFromLineX(surface, *this, lineDoc, x, vs); } -int Editor::PositionFromLineX(int lineDoc, int x) { +Sci::Position Editor::PositionFromLineX(Sci::Line lineDoc, int x) { return SPositionFromLineX(lineDoc, x).Position(); } -int Editor::LineFromLocation(Point pt) const { - return cs.DocFromDisplay(static_cast(pt.y) / vs.lineHeight + topLine); +Sci::Line Editor::LineFromLocation(Point pt) const { + return pcs->DocFromDisplay(static_cast(pt.y) / vs.lineHeight + topLine); } -void Editor::SetTopLine(int topLineNew) { +void Editor::SetTopLine(Sci::Line topLineNew) { if ((topLine != topLineNew) && (topLineNew >= 0)) { topLine = topLineNew; ContainerNeedsUpdate(SC_UPDATE_V_SCROLL); } - posTopLine = pdoc->LineStart(cs.DocFromDisplay(topLine)); + posTopLine = pdoc->LineStart(pcs->DocFromDisplay(topLine)); } /** @@ -449,7 +467,7 @@ void Editor::RedrawRect(PRectangle rc) { //Platform::DebugPrintf("Redraw %0d,%0d - %0d,%0d\n", rc.left, rc.top, rc.right, rc.bottom); // Clip the redraw rectangle into the client area - PRectangle rcClient = GetClientRectangle(); + const PRectangle rcClient = GetClientRectangle(); if (rc.top < rcClient.top) rc.top = rcClient.top; if (rc.bottom > rcClient.bottom) @@ -470,57 +488,63 @@ void Editor::DiscardOverdraw() { void Editor::Redraw() { //Platform::DebugPrintf("Redraw all\n"); - PRectangle rcClient = GetClientRectangle(); + const PRectangle rcClient = GetClientRectangle(); wMain.InvalidateRectangle(rcClient); if (wMargin.GetID()) wMargin.InvalidateAll(); //wMain.InvalidateAll(); } -void Editor::RedrawSelMargin(int line, bool allAfter) { - bool abandonDraw = false; - if (!wMargin.GetID()) // Margin in main window so may need to abandon and retry - abandonDraw = AbandonPaint(); - if (!abandonDraw) { - if (vs.maskInLine) { - Redraw(); - } else { - PRectangle rcSelMargin = GetClientRectangle(); - rcSelMargin.right = rcSelMargin.left + vs.fixedColumnWidth; - if (line != -1) { - PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)), 0); - - // Inflate line rectangle if there are image markers with height larger than line height - if (vs.largestMarkerHeight > vs.lineHeight) { - int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2; - rcLine.top -= delta; - rcLine.bottom += delta; - if (rcLine.top < rcSelMargin.top) - rcLine.top = rcSelMargin.top; - if (rcLine.bottom > rcSelMargin.bottom) - rcLine.bottom = rcSelMargin.bottom; - } - - rcSelMargin.top = rcLine.top; - if (!allAfter) - rcSelMargin.bottom = rcLine.bottom; - if (rcSelMargin.Empty()) - return; - } - if (wMargin.GetID()) { - Point ptOrigin = GetVisibleOriginInMain(); - rcSelMargin.Move(-ptOrigin.x, -ptOrigin.y); - wMargin.InvalidateRectangle(rcSelMargin); - } else { - wMain.InvalidateRectangle(rcSelMargin); - } +void Editor::RedrawSelMargin(Sci::Line line, bool allAfter) { + const bool markersInText = vs.maskInLine || vs.maskDrawInText; + if (!wMargin.GetID() || markersInText) { // May affect text area so may need to abandon and retry + if (AbandonPaint()) { + return; } } + if (wMargin.GetID() && markersInText) { + Redraw(); + return; + } + PRectangle rcMarkers = GetClientRectangle(); + if (!markersInText) { + // Normal case: just draw the margin + rcMarkers.right = rcMarkers.left + vs.fixedColumnWidth; + } + if (line != -1) { + PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)), 0); + + // Inflate line rectangle if there are image markers with height larger than line height + if (vs.largestMarkerHeight > vs.lineHeight) { + const int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2; + rcLine.top -= delta; + rcLine.bottom += delta; + if (rcLine.top < rcMarkers.top) + rcLine.top = rcMarkers.top; + if (rcLine.bottom > rcMarkers.bottom) + rcLine.bottom = rcMarkers.bottom; + } + + rcMarkers.top = rcLine.top; + if (!allAfter) + rcMarkers.bottom = rcLine.bottom; + if (rcMarkers.Empty()) + return; + } + if (wMargin.GetID()) { + const Point ptOrigin = GetVisibleOriginInMain(); + rcMarkers.Move(-ptOrigin.x, -ptOrigin.y); + wMargin.InvalidateRectangle(rcMarkers); + } else { + wMain.InvalidateRectangle(rcMarkers); + } } PRectangle Editor::RectangleFromRange(Range r, int overlap) { - const int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(r.First())); - const int maxLine = cs.DisplayLastFromDoc(pdoc->LineFromPosition(r.Last())); + const Sci::Line minLine = pcs->DisplayFromDoc( + pdoc->SciLineFromPosition(r.First())); + const Sci::Line maxLine = pcs->DisplayLastFromDoc( + pdoc->SciLineFromPosition(r.Last())); const PRectangle rcClientDrawing = GetClientDrawingRectangle(); PRectangle rc; const int leftTextOverlap = ((xOffset == 0) && (vs.leftMarginWidth > 0)) ? 1 : 0; @@ -535,11 +559,11 @@ PRectangle Editor::RectangleFromRange(Range r, int overlap) { return rc; } -void Editor::InvalidateRange(int start, int end) { +void Editor::InvalidateRange(Sci::Position start, Sci::Position end) { RedrawRect(RectangleFromRange(Range(start, end), view.LinesOverlap() ? vs.lineOverlap : 0)); } -int Editor::CurrentPosition() const { +Sci::Position Editor::CurrentPosition() const { return sel.MainCaret(); } @@ -557,15 +581,17 @@ SelectionPosition Editor::SelectionEnd() { void Editor::SetRectangularRange() { if (sel.IsRectangular()) { - int xAnchor = XFromPosition(sel.Rectangular().anchor); + const int xAnchor = XFromPosition(sel.Rectangular().anchor); int xCaret = XFromPosition(sel.Rectangular().caret); if (sel.selType == Selection::selThin) { xCaret = xAnchor; } - int lineAnchorRect = pdoc->LineFromPosition(sel.Rectangular().anchor.Position()); - int lineCaret = pdoc->LineFromPosition(sel.Rectangular().caret.Position()); - int increment = (lineCaret > lineAnchorRect) ? 1 : -1; - for (int line=lineAnchorRect; line != lineCaret+increment; line += increment) { + const Sci::Line lineAnchorRect = + pdoc->SciLineFromPosition(sel.Rectangular().anchor.Position()); + const Sci::Line lineCaret = + pdoc->SciLineFromPosition(sel.Rectangular().caret.Position()); + const int increment = (lineCaret > lineAnchorRect) ? 1 : -1; + for (Sci::Line line=lineAnchorRect; line != lineCaret+increment; line += increment) { SelectionRange range(SPositionFromLineX(line, xCaret), SPositionFromLineX(line, xAnchor)); if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) == 0) range.ClearVirtualSpace(); @@ -593,16 +619,16 @@ void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSel if (sel.Count() > 1 || !(sel.RangeMain().anchor == newMain.anchor) || sel.IsRectangular()) { invalidateWholeSelection = true; } - int firstAffected = Platform::Minimum(sel.RangeMain().Start().Position(), newMain.Start().Position()); + Sci::Position firstAffected = std::min(sel.RangeMain().Start().Position(), newMain.Start().Position()); // +1 for lastAffected ensures caret repainted - int lastAffected = Platform::Maximum(newMain.caret.Position()+1, newMain.anchor.Position()); - lastAffected = Platform::Maximum(lastAffected, sel.RangeMain().End().Position()); + Sci::Position lastAffected = std::max(newMain.caret.Position()+1, newMain.anchor.Position()); + lastAffected = std::max(lastAffected, sel.RangeMain().End().Position()); if (invalidateWholeSelection) { for (size_t r=0; r anchor_) { + anchor_ = SelectionPosition( + pdoc->LineStart(pdoc->LineFromPosition(anchor_.Position()))); + currentPos_ = SelectionPosition( + pdoc->LineEnd(pdoc->LineFromPosition(currentPos_.Position()))); + } else { + currentPos_ = SelectionPosition( + pdoc->LineStart(pdoc->LineFromPosition(currentPos_.Position()))); + anchor_ = SelectionPosition( + pdoc->LineEnd(pdoc->LineFromPosition(anchor_.Position()))); + } + return SelectionRange(currentPos_, anchor_); +} + void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) { currentPos_ = ClampPositionIntoDocument(currentPos_); anchor_ = ClampPositionIntoDocument(anchor_); - int currentLine = pdoc->LineFromPosition(currentPos_.Position()); - /* For Line selection - ensure the anchor and caret are always - at the beginning and end of the region lines. */ - if (sel.selType == Selection::selLines) { - if (currentPos_ > anchor_) { - anchor_ = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(anchor_.Position()))); - currentPos_ = SelectionPosition(pdoc->LineEnd(pdoc->LineFromPosition(currentPos_.Position()))); - } else { - currentPos_ = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(currentPos_.Position()))); - anchor_ = SelectionPosition(pdoc->LineEnd(pdoc->LineFromPosition(anchor_.Position()))); - } - } + const Sci::Line currentLine = pdoc->SciLineFromPosition(currentPos_.Position()); SelectionRange rangeNew(currentPos_, anchor_); + if (sel.selType == Selection::selLines) { + rangeNew = LineSelectionRange(currentPos_, anchor_); + } if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) { InvalidateSelection(rangeNew); } @@ -643,14 +678,14 @@ void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition ancho QueueIdleWork(WorkNeeded::workUpdateUI); } -void Editor::SetSelection(int currentPos_, int anchor_) { +void Editor::SetSelection(Sci::Position currentPos_, Sci::Position anchor_) { SetSelection(SelectionPosition(currentPos_), SelectionPosition(anchor_)); } // Just move the caret on the main selection void Editor::SetSelection(SelectionPosition currentPos_) { currentPos_ = ClampPositionIntoDocument(currentPos_); - int currentLine = pdoc->LineFromPosition(currentPos_.Position()); + const Sci::Line currentLine = pdoc->SciLineFromPosition(currentPos_.Position()); if (sel.Count() > 1 || !(sel.RangeMain().caret == currentPos_)) { InvalidateSelection(SelectionRange(currentPos_)); } @@ -658,6 +693,8 @@ void Editor::SetSelection(SelectionPosition currentPos_) { sel.Rectangular() = SelectionRange(SelectionPosition(currentPos_), sel.Rectangular().anchor); SetRectangularRange(); + } else if (sel.selType == Selection::selLines) { + sel.RangeMain() = LineSelectionRange(currentPos_, sel.RangeMain().anchor); } else { sel.RangeMain() = SelectionRange(SelectionPosition(currentPos_), sel.RangeMain().anchor); @@ -676,7 +713,7 @@ void Editor::SetSelection(int currentPos_) { } void Editor::SetEmptySelection(SelectionPosition currentPos_) { - int currentLine = pdoc->LineFromPosition(currentPos_.Position()); + const Sci::Line currentLine = pdoc->SciLineFromPosition(currentPos_.Position()); SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_)); if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) { InvalidateSelection(rangeNew); @@ -693,15 +730,15 @@ void Editor::SetEmptySelection(SelectionPosition currentPos_) { QueueIdleWork(WorkNeeded::workUpdateUI); } -void Editor::SetEmptySelection(int currentPos_) { +void Editor::SetEmptySelection(Sci::Position currentPos_) { SetEmptySelection(SelectionPosition(currentPos_)); } void Editor::MultipleSelectAdd(AddNumber addNumber) { if (SelectionEmpty() || !multipleSelection) { // Select word at caret - const int startWord = pdoc->ExtendWordSelect(sel.MainCaret(), -1, true); - const int endWord = pdoc->ExtendWordSelect(startWord, 1, true); + const Sci::Position startWord = pdoc->ExtendWordSelect(sel.MainCaret(), -1, true); + const Sci::Position endWord = pdoc->ExtendWordSelect(startWord, 1, true); TrimAndSetSelection(endWord, startWord); } else { @@ -729,14 +766,15 @@ void Editor::MultipleSelectAdd(AddNumber addNumber) { } for (std::vector::const_iterator it = searchRanges.begin(); it != searchRanges.end(); ++it) { - int searchStart = it->start; - const int searchEnd = it->end; + Sci::Position searchStart = it->start; + const Sci::Position searchEnd = it->end; for (;;) { - int lengthFound = static_cast(selectedText.length()); - int pos = pdoc->FindText(searchStart, searchEnd, selectedText.c_str(), - searchFlags, &lengthFound); + Sci::Position lengthFound = selectedText.length(); + const Sci::Position pos = pdoc->FindText(searchStart, searchEnd, + selectedText.c_str(), searchFlags, &lengthFound); if (pos >= 0) { sel.AddSelection(SelectionRange(pos + lengthFound, pos)); + ContainerNeedsUpdate(SC_UPDATE_SELECTION); ScrollRange(sel.RangeMain()); Redraw(); if (addNumber == addOne) @@ -750,15 +788,15 @@ void Editor::MultipleSelectAdd(AddNumber addNumber) { } } -bool Editor::RangeContainsProtected(int start, int end) const { +bool Editor::RangeContainsProtected(Sci::Position start, Sci::Position end) const { if (vs.ProtectionActive()) { if (start > end) { - int t = start; + const Sci::Position t = start; start = end; end = t; } - for (int pos = start; pos < end; pos++) { - if (vs.styles[pdoc->StyleAt(pos)].IsProtected()) + for (Sci::Position pos = start; pos < end; pos++) { + if (vs.styles[pdoc->StyleIndexAt(pos)].IsProtected()) return true; } } @@ -778,25 +816,25 @@ bool Editor::SelectionContainsProtected() { /** * Asks document to find a good position and then moves out of any invisible positions. */ -int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) const { +Sci::Position Editor::MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd) const { return MovePositionOutsideChar(SelectionPosition(pos), moveDir, checkLineEnd).Position(); } -SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd) const { - int posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd); +SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, Sci::Position moveDir, bool checkLineEnd) const { + const Sci::Position posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd); if (posMoved != pos.Position()) pos.SetPosition(posMoved); if (vs.ProtectionActive()) { if (moveDir > 0) { - if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected()) { + if ((pos.Position() > 0) && vs.styles[pdoc->StyleIndexAt(pos.Position() - 1)].IsProtected()) { while ((pos.Position() < pdoc->Length()) && - (vs.styles[pdoc->StyleAt(pos.Position())].IsProtected())) + (vs.styles[pdoc->StyleIndexAt(pos.Position())].IsProtected())) pos.Add(1); } } else if (moveDir < 0) { - if (vs.styles[pdoc->StyleAt(pos.Position())].IsProtected()) { + if (vs.styles[pdoc->StyleIndexAt(pos.Position())].IsProtected()) { while ((pos.Position() > 0) && - (vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected())) + (vs.styles[pdoc->StyleIndexAt(pos.Position() - 1)].IsProtected())) pos.Add(-1); } } @@ -805,12 +843,15 @@ SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int mov } void Editor::MovedCaret(SelectionPosition newPos, SelectionPosition previousPos, bool ensureVisible) { - const int currentLine = pdoc->LineFromPosition(newPos.Position()); + const Sci::Line currentLine = pdoc->SciLineFromPosition(newPos.Position()); if (ensureVisible) { // In case in need of wrapping to ensure DisplayFromDoc works. - if (currentLine >= wrapPending.start) - WrapLines(wsAll); - XYScrollPosition newXY = XYScrollToMakeVisible( + if (currentLine >= wrapPending.start) { + if (WrapLines(WrapScope::wsAll)) { + Redraw(); + } + } + const XYScrollPosition newXY = XYScrollToMakeVisible( SelectionRange(posDrag.IsValid() ? posDrag : newPos), xysDefault); if (previousPos.IsValid() && (newXY.xOffset == xOffset)) { // simple vertical scroll then invalidate @@ -822,6 +863,7 @@ void Editor::MovedCaret(SelectionPosition newPos, SelectionPosition previousPos, } ShowCaretAtCurrentPosition(); + NotifyCaretMove(); ClaimSelection(); SetHoverIndicatorPosition(sel.MainCaret()); @@ -836,7 +878,7 @@ void Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, const SelectionPosition spCaret = ((sel.Count() == 1) && sel.Empty()) ? sel.Last() : SelectionPosition(INVALID_POSITION); - int delta = newPos.Position() - sel.MainCaret(); + const Sci::Position delta = newPos.Position() - sel.MainCaret(); newPos = ClampPositionIntoDocument(newPos); newPos = MovePositionOutsideChar(newPos, delta); if (!multipleSelection && sel.IsRectangular() && (selt == Selection::selStream)) { @@ -863,30 +905,32 @@ void Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, MovedCaret(newPos, spCaret, ensureVisible); } -void Editor::MovePositionTo(int newPos, Selection::selTypes selt, bool ensureVisible) { +void Editor::MovePositionTo(Sci::Position newPos, Selection::selTypes selt, bool ensureVisible) { MovePositionTo(SelectionPosition(newPos), selt, ensureVisible); } SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveDir) { pos = ClampPositionIntoDocument(pos); pos = MovePositionOutsideChar(pos, moveDir); - int lineDoc = pdoc->LineFromPosition(pos.Position()); - if (cs.GetVisible(lineDoc)) { + const Sci::Line lineDoc = pdoc->SciLineFromPosition(pos.Position()); + if (pcs->GetVisible(lineDoc)) { return pos; } else { - int lineDisplay = cs.DisplayFromDoc(lineDoc); + Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc); if (moveDir > 0) { // lineDisplay is already line before fold as lines in fold use display line of line after fold - lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed()); - return SelectionPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay))); + lineDisplay = Sci::clamp(lineDisplay, static_cast(0), pcs->LinesDisplayed()); + return SelectionPosition( + pdoc->LineStart(pcs->DocFromDisplay(lineDisplay))); } else { - lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed()); - return SelectionPosition(pdoc->LineEnd(cs.DocFromDisplay(lineDisplay))); + lineDisplay = Sci::clamp(lineDisplay - 1, static_cast(0), pcs->LinesDisplayed()); + return SelectionPosition( + pdoc->LineEnd(pcs->DocFromDisplay(lineDisplay))); } } } -SelectionPosition Editor::MovePositionSoVisible(int pos, int moveDir) { +SelectionPosition Editor::MovePositionSoVisible(Sci::Position pos, int moveDir) { return MovePositionSoVisible(SelectionPosition(pos), moveDir); } @@ -899,23 +943,23 @@ Point Editor::PointMainCaret() { * as it moves up and down. */ void Editor::SetLastXChosen() { - Point pt = PointMainCaret(); + const Point pt = PointMainCaret(); lastXChosen = static_cast(pt.x) + xOffset; } -void Editor::ScrollTo(int line, bool moveThumb) { - int topLineNew = Platform::Clamp(line, 0, MaxScrollPos()); +void Editor::ScrollTo(Sci::Line line, bool moveThumb) { + const Sci::Line topLineNew = Sci::clamp(line, static_cast(0), MaxScrollPos()); if (topLineNew != topLine) { // Try to optimise small scrolls #ifndef UNDER_CE - int linesToMove = topLine - topLineNew; - bool performBlit = (abs(linesToMove) <= 10) && (paintState == notPainting); + const Sci::Line linesToMove = topLine - topLineNew; + const bool performBlit = (std::abs(linesToMove) <= 10) && (paintState == notPainting); willRedrawAll = !performBlit; #endif SetTopLine(topLineNew); // Optimize by styling the view as this will invalidate any needed area // which could abort the initial paint if discovered later. - StyleToPositionInView(PositionAfterArea(GetClientRectangle())); + StyleAreaBounded(GetClientRectangle(), true); #ifndef UNDER_CE // Perform redraw rather than scroll if many lines would be redrawn anyway. if (performBlit) { @@ -933,7 +977,7 @@ void Editor::ScrollTo(int line, bool moveThumb) { } } -void Editor::ScrollText(int /* linesToMove */) { +void Editor::ScrollText(Sci::Line /* linesToMove */) { //Platform::DebugPrintf("Editor::ScrollText %d\n", linesToMove); Redraw(); } @@ -951,39 +995,38 @@ void Editor::HorizontalScrollTo(int xPos) { } void Editor::VerticalCentreCaret() { - int lineDoc = pdoc->LineFromPosition(sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret()); - int lineDisplay = cs.DisplayFromDoc(lineDoc); - int newTop = lineDisplay - (LinesOnScreen() / 2); + const Sci::Line lineDoc = + pdoc->SciLineFromPosition(sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret()); + const Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc); + const Sci::Line newTop = lineDisplay - (LinesOnScreen() / 2); if (topLine != newTop) { SetTopLine(newTop > 0 ? newTop : 0); RedrawRect(GetClientRectangle()); } } -// Avoid 64 bit compiler warnings. -// Scintilla does not support text buffers larger than 2**31 -static int istrlen(const char *s) { - return static_cast(s ? strlen(s) : 0); -} - void Editor::MoveSelectedLines(int lineDelta) { + if (sel.IsRectangular()) { + return; + } + // if selection doesn't start at the beginning of the line, set the new start - int selectionStart = SelectionStart().Position(); - int startLine = pdoc->LineFromPosition(selectionStart); - int beginningOfStartLine = pdoc->LineStart(startLine); + Sci::Position selectionStart = SelectionStart().Position(); + const Sci::Line startLine = pdoc->SciLineFromPosition(selectionStart); + const Sci::Position beginningOfStartLine = pdoc->LineStart(startLine); selectionStart = beginningOfStartLine; // if selection doesn't end at the beginning of a line greater than that of the start, // then set it at the beginning of the next one - int selectionEnd = SelectionEnd().Position(); - int endLine = pdoc->LineFromPosition(selectionEnd); - int beginningOfEndLine = pdoc->LineStart(endLine); + Sci::Position selectionEnd = SelectionEnd().Position(); + const Sci::Line endLine = pdoc->SciLineFromPosition(selectionEnd); + const Sci::Position beginningOfEndLine = pdoc->LineStart(endLine); bool appendEol = false; if (selectionEnd > beginningOfEndLine || selectionStart == selectionEnd) { selectionEnd = pdoc->LineStart(endLine + 1); - appendEol = (selectionEnd == pdoc->Length() && pdoc->LineFromPosition(selectionEnd) == endLine); + appendEol = (selectionEnd == pdoc->Length() && pdoc->SciLineFromPosition(selectionEnd) == endLine); } // if there's nowhere for the selection to move @@ -1007,9 +1050,8 @@ void Editor::MoveSelectedLines(int lineDelta) { SelectionText selectedText; CopySelectionRange(&selectedText); - int selectionLength = SelectionRange(selectionStart, selectionEnd).Length(); - Point currentLocation = LocationFromPosition(CurrentPosition()); - int currentLine = LineFromLocation(currentLocation); + const Point currentLocation = LocationFromPosition(CurrentPosition()); + const Sci::Line currentLine = LineFromLocation(currentLocation); if (appendEol) SetSelection(pdoc->MovePositionOutsideChar(selectionStart - 1, -1), selectionEnd); @@ -1017,12 +1059,12 @@ void Editor::MoveSelectedLines(int lineDelta) { const char *eol = StringFromEOLMode(pdoc->eolMode); if (currentLine + lineDelta >= pdoc->LinesTotal()) - pdoc->InsertString(pdoc->Length(), eol, istrlen(eol)); + pdoc->InsertString(pdoc->Length(), eol, strlen(eol)); GoToLine(currentLine + lineDelta); - selectionLength = pdoc->InsertString(CurrentPosition(), selectedText.Data(), selectionLength); + Sci::Position selectionLength = pdoc->InsertString(CurrentPosition(), selectedText.Data(), selectedText.Length()); if (appendEol) { - const int lengthInserted = pdoc->InsertString(CurrentPosition() + selectionLength, eol, istrlen(eol)); + const Sci::Position lengthInserted = pdoc->InsertString(CurrentPosition() + selectionLength, eol, strlen(eol)); selectionLength += lengthInserted; } SetSelection(CurrentPosition(), CurrentPosition() + selectionLength); @@ -1037,23 +1079,23 @@ void Editor::MoveSelectedLinesDown() { } void Editor::MoveCaretInsideView(bool ensureVisible) { - PRectangle rcClient = GetTextRectangle(); - Point pt = PointMainCaret(); + const PRectangle rcClient = GetTextRectangle(); + const Point pt = PointMainCaret(); if (pt.y < rcClient.top) { MovePositionTo(SPositionFromLocation( Point::FromInts(lastXChosen - xOffset, static_cast(rcClient.top)), false, false, UserVirtualSpace()), Selection::noSel, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { - int yOfLastLineFullyDisplayed = static_cast(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight; + const ptrdiff_t yOfLastLineFullyDisplayed = static_cast(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight; MovePositionTo(SPositionFromLocation( - Point::FromInts(lastXChosen - xOffset, static_cast(rcClient.top) + yOfLastLineFullyDisplayed), + Point::FromInts(lastXChosen - xOffset, static_cast(rcClient.top + yOfLastLineFullyDisplayed)), false, false, UserVirtualSpace()), Selection::noSel, ensureVisible); } } -int Editor::DisplayFromPosition(int pos) { +Sci::Line Editor::DisplayFromPosition(Sci::Position pos) { AutoSurface surface(this); return view.DisplayFromPosition(surface, *this, pos, vs); } @@ -1105,14 +1147,10 @@ slop | strict | jumps | even | Caret can go to the margin | When */ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &range, const XYScrollOptions options) { - PRectangle rcClient = GetTextRectangle(); - Point pt = LocationFromPosition(range.caret); - Point ptAnchor = LocationFromPosition(range.anchor); + const PRectangle rcClient = GetTextRectangle(); const Point ptOrigin = GetVisibleOriginInMain(); - pt.x += ptOrigin.x; - pt.y += ptOrigin.y; - ptAnchor.x += ptOrigin.x; - ptAnchor.y += ptOrigin.y; + const Point pt = LocationFromPosition(range.caret) + ptOrigin; + const Point ptAnchor = LocationFromPosition(range.anchor) + ptOrigin; const Point ptBottomCaret(pt.x, pt.y + vs.lineHeight - 1); XYScrollPosition newXY(xOffset, topLine); @@ -1122,9 +1160,9 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran // Vertical positioning if ((options & xysVertical) && (pt.y < rcClient.top || ptBottomCaret.y >= rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) { - const int lineCaret = DisplayFromPosition(range.caret.Position()); - const int linesOnScreen = LinesOnScreen(); - const int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2; + const Sci::Line lineCaret = DisplayFromPosition(range.caret.Position()); + const Sci::Line linesOnScreen = LinesOnScreen(); + const Sci::Line halfScreen = std::max(linesOnScreen - 1, static_cast(2)) / 2; const bool bSlop = (caretYPolicy & CARET_SLOP) != 0; const bool bStrict = (caretYPolicy & CARET_STRICT) != 0; const bool bJump = (caretYPolicy & CARET_JUMPS) != 0; @@ -1133,9 +1171,9 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran // It should be possible to scroll the window to show the caret, // but this fails to remove the caret on GTK+ if (bSlop) { // A margin is defined - int yMoveT, yMoveB; + Sci::Line yMoveT, yMoveB; if (bStrict) { - int yMarginT, yMarginB; + Sci::Line yMarginT, yMarginB; if (!(options & xysUseMargin)) { // In drag mode, avoid moves // otherwise, a double click will select several lines. @@ -1143,7 +1181,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran } else { // yMarginT must equal to caretYSlop, with a minimum of 1 and // a maximum of slightly less than half the heigth of the text area. - yMarginT = Platform::Clamp(caretYSlop, 1, halfScreen); + yMarginT = Sci::clamp(static_cast(caretYSlop), static_cast(1), halfScreen); if (bEven) { yMarginB = yMarginT; } else { @@ -1153,7 +1191,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran yMoveT = yMarginT; if (bEven) { if (bJump) { - yMoveT = Platform::Clamp(caretYSlop * 3, 1, halfScreen); + yMoveT = Sci::clamp(static_cast(caretYSlop * 3), static_cast(1), halfScreen); } yMoveB = yMoveT; } else { @@ -1168,7 +1206,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran } } else { // Not strict yMoveT = bJump ? caretYSlop * 3 : caretYSlop; - yMoveT = Platform::Clamp(yMoveT, 1, halfScreen); + yMoveT = Sci::clamp(yMoveT, static_cast(1), halfScreen); if (bEven) { yMoveB = yMoveT; } else { @@ -1207,7 +1245,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran } } if (!(range.caret == range.anchor)) { - const int lineAnchor = DisplayFromPosition(range.anchor.Position()); + const Sci::Line lineAnchor = DisplayFromPosition(range.anchor.Position()); if (lineAnchor < lineCaret) { // Shift up to show anchor or as much of range as possible newXY.topLine = std::min(newXY.topLine, lineAnchor); @@ -1218,12 +1256,12 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran newXY.topLine = std::min(newXY.topLine, lineCaret); } } - newXY.topLine = Platform::Clamp(newXY.topLine, 0, MaxScrollPos()); + newXY.topLine = Sci::clamp(newXY.topLine, static_cast(0), MaxScrollPos()); } // Horizontal positioning if ((options & xysHorizontal) && !Wrapping()) { - const int halfScreen = Platform::Maximum(static_cast(rcClient.Width()) - 4, 4) / 2; + const int halfScreen = std::max(static_cast(rcClient.Width()) - 4, 4) / 2; const bool bSlop = (caretXPolicy & CARET_SLOP) != 0; const bool bStrict = (caretXPolicy & CARET_STRICT) != 0; const bool bJump = (caretXPolicy & CARET_JUMPS) != 0; @@ -1240,7 +1278,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran } else { // xMargin must equal to caretXSlop, with a minimum of 2 and // a maximum of slightly less than half the width of the text area. - xMarginR = Platform::Clamp(caretXSlop, 2, halfScreen); + xMarginR = Sci::clamp(caretXSlop, 2, halfScreen); if (bEven) { xMarginL = xMarginR; } else { @@ -1249,7 +1287,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran } if (bJump && bEven) { // Jump is used only in even mode - xMoveL = xMoveR = Platform::Clamp(caretXSlop * 3, 1, halfScreen); + xMoveL = xMoveR = Sci::clamp(caretXSlop * 3, 1, halfScreen); } else { xMoveL = xMoveR = 0; // Not used, avoid a warning } @@ -1272,7 +1310,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran } } else { // Not strict xMoveR = bJump ? caretXSlop * 3 : caretXSlop; - xMoveR = Platform::Clamp(xMoveR, 1, halfScreen); + xMoveR = Sci::clamp(xMoveR, 1, halfScreen); if (bEven) { xMoveL = xMoveR; } else { @@ -1317,7 +1355,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran newXY.xOffset = static_cast(pt.x + xOffset - rcClient.left) - 2; } else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) { newXY.xOffset = static_cast(pt.x + xOffset - rcClient.right) + 2; - if ((vs.caretStyle == CARETSTYLE_BLOCK) || view.imeCaretBlockOverride) { + if (vs.IsBlockCaretStyle() || view.imeCaretBlockOverride) { // Ensure we can see a good portion of the block caret newXY.xOffset += static_cast(vs.aveCharWidth); } @@ -1325,14 +1363,14 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran if (!(range.caret == range.anchor)) { if (ptAnchor.x < pt.x) { // Shift to left to show anchor or as much of range as possible - int maxOffset = static_cast(ptAnchor.x + xOffset - rcClient.left) - 1; - int minOffset = static_cast(pt.x + xOffset - rcClient.right) + 1; + const int maxOffset = static_cast(ptAnchor.x + xOffset - rcClient.left) - 1; + const int minOffset = static_cast(pt.x + xOffset - rcClient.right) + 1; newXY.xOffset = std::min(newXY.xOffset, maxOffset); newXY.xOffset = std::max(newXY.xOffset, minOffset); } else { // Shift to right to show anchor or as much of range as possible - int minOffset = static_cast(ptAnchor.x + xOffset - rcClient.right) + 1; - int maxOffset = static_cast(pt.x + xOffset - rcClient.left) - 1; + const int minOffset = static_cast(ptAnchor.x + xOffset - rcClient.right) + 1; + const int maxOffset = static_cast(pt.x + xOffset - rcClient.left) - 1; newXY.xOffset = std::max(newXY.xOffset, minOffset); newXY.xOffset = std::min(newXY.xOffset, maxOffset); } @@ -1355,7 +1393,7 @@ void Editor::SetXYScroll(XYScrollPosition newXY) { xOffset = newXY.xOffset; ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); if (newXY.xOffset > 0) { - PRectangle rcText = GetTextRectangle(); + const PRectangle rcText = GetTextRectangle(); if (horizontalScrollBarVisible && rcText.Width() + xOffset > scrollWidth) { scrollWidth = xOffset + static_cast(rcText.Width()); @@ -1382,28 +1420,20 @@ void Editor::ShowCaretAtCurrentPosition() { if (hasFocus) { caret.active = true; caret.on = true; - if (FineTickerAvailable()) { - FineTickerCancel(tickCaret); - if (caret.period > 0) - FineTickerStart(tickCaret, caret.period, caret.period/10); - } else { - SetTicking(true); - } + FineTickerCancel(tickCaret); + if (caret.period > 0) + FineTickerStart(tickCaret, caret.period, caret.period/10); } else { caret.active = false; caret.on = false; - if (FineTickerAvailable()) { - FineTickerCancel(tickCaret); - } + FineTickerCancel(tickCaret); } InvalidateCaret(); } void Editor::DropCaret() { caret.active = false; - if (FineTickerAvailable()) { - FineTickerCancel(tickCaret); - } + FineTickerCancel(tickCaret); InvalidateCaret(); } @@ -1411,11 +1441,9 @@ void Editor::CaretSetPeriod(int period) { if (caret.period != period) { caret.period = period; caret.on = true; - if (FineTickerAvailable()) { - FineTickerCancel(tickCaret); - if ((caret.active) && (caret.period > 0)) - FineTickerStart(tickCaret, caret.period, caret.period/10); - } + FineTickerCancel(tickCaret); + if ((caret.active) && (caret.period > 0)) + FineTickerStart(tickCaret, caret.period, caret.period/10); InvalidateCaret(); } } @@ -1431,14 +1459,17 @@ void Editor::InvalidateCaret() { UpdateSystemCaret(); } +void Editor::NotifyCaretMove() { +} + void Editor::UpdateSystemCaret() { } -bool Editor::Wrapping() const { +bool Editor::Wrapping() const noexcept { return vs.wrapState != eWrapNone; } -void Editor::NeedWrapping(int docLineStart, int docLineEnd) { +void Editor::NeedWrapping(Sci::Line docLineStart, Sci::Line docLineEnd) { //Platform::DebugPrintf("\nNeedWrapping: %0d..%0d\n", docLineStart, docLineEnd); if (wrapPending.AddRange(docLineStart, docLineEnd)) { view.llc.Invalidate(LineLayout::llPositions); @@ -1449,14 +1480,14 @@ void Editor::NeedWrapping(int docLineStart, int docLineEnd) { } } -bool Editor::WrapOneLine(Surface *surface, int lineToWrap) { +bool Editor::WrapOneLine(Surface *surface, Sci::Line lineToWrap) { AutoLineLayout ll(view.llc, view.RetrieveLineLayout(lineToWrap, *this)); int linesWrapped = 1; if (ll) { view.LayoutLine(*this, lineToWrap, surface, vs, ll, wrapWidth); linesWrapped = ll->lines; } - return cs.SetHeight(lineToWrap, linesWrapped + + return pcs->SetHeight(lineToWrap, linesWrapped + (vs.annotationVisible ? pdoc->AnnotationLines(lineToWrap) : 0)); } @@ -1465,14 +1496,14 @@ bool Editor::WrapOneLine(Surface *surface, int lineToWrap) { // wsVisible: wrap currently visible lines // wsIdle: wrap one page + 100 lines // Return true if wrapping occurred. -bool Editor::WrapLines(enum wrapScope ws) { - int goodTopLine = topLine; +bool Editor::WrapLines(WrapScope ws) { + Sci::Line goodTopLine = topLine; bool wrapOccurred = false; if (!Wrapping()) { if (wrapWidth != LineLayout::wrapWidthInfinite) { wrapWidth = LineLayout::wrapWidthInfinite; - for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) { - cs.SetHeight(lineDoc, 1 + + for (Sci::Line lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) { + pcs->SetHeight(lineDoc, 1 + (vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0)); } wrapOccurred = true; @@ -1483,22 +1514,22 @@ bool Editor::WrapLines(enum wrapScope ws) { wrapPending.start = std::min(wrapPending.start, pdoc->LinesTotal()); if (!SetIdle(true)) { // Idle processing not supported so full wrap required. - ws = wsAll; + ws = WrapScope::wsAll; } // Decide where to start wrapping - int lineToWrap = wrapPending.start; - int lineToWrapEnd = std::min(wrapPending.end, pdoc->LinesTotal()); - const int lineDocTop = cs.DocFromDisplay(topLine); - const int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop); - if (ws == wsVisible) { - lineToWrap = Platform::Clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal()); + Sci::Line lineToWrap = wrapPending.start; + Sci::Line lineToWrapEnd = std::min(wrapPending.end, pdoc->LinesTotal()); + const Sci::Line lineDocTop = pcs->DocFromDisplay(topLine); + const Sci::Line subLineTop = topLine - pcs->DisplayFromDoc(lineDocTop); + if (ws == WrapScope::wsVisible) { + lineToWrap = Sci::clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal()); // Priority wrap to just after visible area. // Since wrapping could reduce display lines, treat each // as taking only one display line. lineToWrapEnd = lineDocTop; - int lines = LinesOnScreen() + 1; - while ((lineToWrapEnd < cs.LinesInDoc()) && (lines>0)) { - if (cs.GetVisible(lineToWrapEnd)) + Sci::Line lines = LinesOnScreen() + 1; + while ((lineToWrapEnd < pcs->LinesInDoc()) && (lines>0)) { + if (pcs->GetVisible(lineToWrapEnd)) lines--; lineToWrapEnd++; } @@ -1507,10 +1538,15 @@ bool Editor::WrapLines(enum wrapScope ws) { // Currently visible text does not need wrapping return false; } - } else if (ws == wsIdle) { - lineToWrapEnd = lineToWrap + LinesOnScreen() + 100; + } else if (ws == WrapScope::wsIdle) { + // Try to keep time taken by wrapping reasonable so interaction remains smooth. + const double secondsAllowed = 0.01; + const Sci::Line linesInAllowedTime = Sci::clamp( + static_cast(secondsAllowed / durationWrapOneLine.Duration()), + LinesOnScreen() + 50, static_cast(0x10000)); + lineToWrapEnd = lineToWrap + linesInAllowedTime; } - const int lineEndNeedWrap = std::min(wrapPending.end, pdoc->LinesTotal()); + const Sci::Line lineEndNeedWrap = std::min(wrapPending.end, pdoc->LinesTotal()); lineToWrapEnd = std::min(lineToWrapEnd, lineEndNeedWrap); // Ensure all lines being wrapped are styled. @@ -1527,6 +1563,8 @@ bool Editor::WrapLines(enum wrapScope ws) { if (surface) { //Platform::DebugPrintf("Wraplines: scope=%0d need=%0d..%0d perform=%0d..%0d\n", ws, wrapPending.start, wrapPending.end, lineToWrap, lineToWrapEnd); + const Sci::Line linesBeingWrapped = lineToWrapEnd - lineToWrap; + ElapsedPeriod epWrapping; while (lineToWrap < lineToWrapEnd) { if (WrapOneLine(surface, lineToWrap)) { wrapOccurred = true; @@ -1534,8 +1572,10 @@ bool Editor::WrapLines(enum wrapScope ws) { wrapPending.Wrapped(lineToWrap); lineToWrap++; } + durationWrapOneLine.AddSample(linesBeingWrapped, epWrapping.Duration()); - goodTopLine = cs.DisplayFromDoc(lineDocTop) + std::min(subLineTop, cs.GetHeight(lineDocTop)-1); + goodTopLine = pcs->DisplayFromDoc(lineDocTop) + std::min( + subLineTop, static_cast(pcs->GetHeight(lineDocTop)-1)); } } @@ -1547,7 +1587,7 @@ bool Editor::WrapLines(enum wrapScope ws) { if (wrapOccurred) { SetScrollBars(); - SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos())); + SetTopLine(Sci::clamp(goodTopLine, static_cast(0), MaxScrollPos())); SetVerticalScrollPos(); } @@ -1558,13 +1598,13 @@ void Editor::LinesJoin() { if (!RangeContainsProtected(targetStart, targetEnd)) { UndoGroup ug(pdoc); bool prevNonWS = true; - for (int pos = targetStart; pos < targetEnd; pos++) { + for (Sci::Position pos = targetStart; pos < targetEnd; pos++) { if (pdoc->IsPositionInLineEnd(pos)) { targetEnd -= pdoc->LenChar(pos); pdoc->DelChar(pos); if (prevNonWS) { // Ensure at least one space separating previous lines - const int lengthInserted = pdoc->InsertString(pos, " ", 1); + const Sci::Position lengthInserted = pdoc->InsertString(pos, " ", 1); targetEnd += lengthInserted; } } else { @@ -1574,7 +1614,7 @@ void Editor::LinesJoin() { } } -const char *Editor::StringFromEOLMode(int eolMode) { +const char *Editor::StringFromEOLMode(int eolMode) noexcept { if (eolMode == SC_EOL_CRLF) { return "\r\n"; } else if (eolMode == SC_EOL_CR) { @@ -1587,51 +1627,50 @@ const char *Editor::StringFromEOLMode(int eolMode) { void Editor::LinesSplit(int pixelWidth) { if (!RangeContainsProtected(targetStart, targetEnd)) { if (pixelWidth == 0) { - PRectangle rcText = GetTextRectangle(); + const PRectangle rcText = GetTextRectangle(); pixelWidth = static_cast(rcText.Width()); } - int lineStart = pdoc->LineFromPosition(targetStart); - int lineEnd = pdoc->LineFromPosition(targetEnd); + const Sci::Line lineStart = pdoc->SciLineFromPosition(targetStart); + Sci::Line lineEnd = pdoc->SciLineFromPosition(targetEnd); const char *eol = StringFromEOLMode(pdoc->eolMode); UndoGroup ug(pdoc); - for (int line = lineStart; line <= lineEnd; line++) { + for (Sci::Line line = lineStart; line <= lineEnd; line++) { AutoSurface surface(this); AutoLineLayout ll(view.llc, view.RetrieveLineLayout(line, *this)); if (surface && ll) { - unsigned int posLineStart = pdoc->LineStart(line); + const Sci::Position posLineStart = pdoc->LineStart(line); view.LayoutLine(*this, line, surface, vs, ll, pixelWidth); - int lengthInsertedTotal = 0; + Sci::Position lengthInsertedTotal = 0; for (int subLine = 1; subLine < ll->lines; subLine++) { - const int lengthInserted = pdoc->InsertString( - static_cast(posLineStart + lengthInsertedTotal + - ll->LineStart(subLine)), - eol, istrlen(eol)); + const Sci::Position lengthInserted = pdoc->InsertString( + posLineStart + lengthInsertedTotal + ll->LineStart(subLine), + eol, strlen(eol)); targetEnd += lengthInserted; lengthInsertedTotal += lengthInserted; } } - lineEnd = pdoc->LineFromPosition(targetEnd); + lineEnd = pdoc->SciLineFromPosition(targetEnd); } } } -void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { +void Editor::PaintSelMargin(Surface *surfaceWindow, const PRectangle &rc) { if (vs.fixedColumnWidth == 0) return; AllocateGraphics(); RefreshStyleData(); - RefreshPixMaps(surfWindow); + RefreshPixMaps(surfaceWindow); // On GTK+ with Ubuntu overlay scroll bars, the surface may have been finished // at this point. The Initialised call checks for this case and sets the status // to be bad which avoids crashes in following calls. - if (!surfWindow->Initialised()) { + if (!surfaceWindow->Initialised()) { return; } PRectangle rcMargin = GetClientRectangle(); - Point ptOrigin = GetVisibleOriginInMain(); + const Point ptOrigin = GetVisibleOriginInMain(); rcMargin.Move(0, -ptOrigin.y); rcMargin.left = 0; rcMargin.right = static_cast(vs.fixedColumnWidth); @@ -1641,9 +1680,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { Surface *surface; if (view.bufferedDraw) { - surface = marginView.pixmapSelMargin; + surface = marginView.pixmapSelMargin.get(); } else { - surface = surfWindow; + surface = surfaceWindow; } // Clip vertically to paint area to avoid drawing line numbers @@ -1655,7 +1694,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { marginView.PaintMargin(surface, topLine, rc, rcMargin, *this, vs); if (view.bufferedDraw) { - surfWindow->Copy(rcMargin, Point(rcMargin.left, rcMargin.top), *marginView.pixmapSelMargin); + surfaceWindow->Copy(rcMargin, Point(rcMargin.left, rcMargin.top), *marginView.pixmapSelMargin); } } @@ -1663,7 +1702,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { view.RefreshPixMaps(surfaceWindow, wMain.GetID(), vs); marginView.RefreshPixMaps(surfaceWindow, wMain.GetID(), vs); if (view.bufferedDraw) { - PRectangle rcClient = GetClientRectangle(); + const PRectangle rcClient = GetClientRectangle(); if (!view.pixmapLine->Initialised()) { view.pixmapLine->InitPixMap(static_cast(rcClient.Width()), vs.lineHeight, @@ -1688,9 +1727,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { paintAbandonedByStyling = false; - StyleToPositionInView(PositionAfterArea(rcArea)); + StyleAreaBounded(rcArea, false); - PRectangle rcClient = GetClientRectangle(); + const PRectangle rcClient = GetClientRectangle(); //Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n", // rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); @@ -1700,7 +1739,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } // Wrap the visible lines if needed. - if (WrapLines(wsVisible)) { + if (WrapLines(WrapScope::wsVisible)) { // The wrapping process has changed the height of some lines so // abandon this paint for a complete repaint. if (AbandonPaint()) { @@ -1739,7 +1778,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { if (paintAbandonedByStyling) { // Styling has spilled over a line end, such as occurs by starting a multiline // comment. The width of subsequent text may have changed, so rewrap. - NeedWrapping(cs.DocFromDisplay(topLine)); + NeedWrapping(pcs->DocFromDisplay(topLine)); } } return; @@ -1748,11 +1787,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { view.PaintText(surfaceWindow, *this, rcArea, rcClient, vs); if (horizontalScrollBarVisible && trackLineWidth && (view.lineWidthMaxSeen > scrollWidth)) { - if (FineTickerAvailable()) { - scrollWidth = view.lineWidthMaxSeen; - if (!FineTickerRunning(tickWiden)) { - FineTickerStart(tickWiden, 50, 5); - } + scrollWidth = view.lineWidthMaxSeen; + if (!FineTickerRunning(tickWiden)) { + FineTickerStart(tickWiden, 50, 5); } } @@ -1762,7 +1799,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { // This is mostly copied from the Paint method but with some things omitted // such as the margin markers, line numbers, selection and caret // Should be merged back into a combined Draw method. -long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { +Sci::Position Editor::FormatRange(bool draw, const Sci_RangeToFormat *pfr) { if (!pfr) return 0; @@ -1780,7 +1817,7 @@ int Editor::TextWidth(int style, const char *text) { RefreshStyleData(); AutoSurface surface(this); if (surface) { - return static_cast(surface->WidthText(vs.styles[style].font, text, istrlen(text))); + return static_cast(surface->WidthText(vs.styles[style].font, text, static_cast(strlen(text)))); } else { return 1; } @@ -1792,9 +1829,9 @@ void Editor::ReconfigureScrollBars() {} void Editor::SetScrollBars() { RefreshStyleData(); - int nMax = MaxScrollPos(); - int nPage = LinesOnScreen(); - bool modified = ModifyScrollBars(nMax + nPage - 1, nPage); + const Sci::Line nMax = MaxScrollPos(); + const Sci::Line nPage = LinesOnScreen(); + const bool modified = ModifyScrollBars(nMax + nPage - 1, nPage); if (modified) { DwellEnd(true); } @@ -1802,7 +1839,7 @@ void Editor::SetScrollBars() { // TODO: ensure always showing as many lines as possible // May not be, if, for example, window made larger if (topLine > MaxScrollPos()) { - SetTopLine(Platform::Clamp(topLine, 0, MaxScrollPos())); + SetTopLine(Sci::clamp(topLine, static_cast(0), MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } @@ -1827,15 +1864,26 @@ void Editor::ChangeSize() { } } -int Editor::InsertSpace(int position, unsigned int spaces) { - if (spaces > 0) { - std::string spaceText(spaces, ' '); - const int lengthInserted = pdoc->InsertString(position, spaceText.c_str(), spaces); - position += lengthInserted; +Sci::Position Editor::RealizeVirtualSpace(Sci::Position position, Sci::Position virtualSpace) { + if (virtualSpace > 0) { + const Sci::Line line = pdoc->SciLineFromPosition(position); + const Sci::Position indent = pdoc->GetLineIndentPosition(line); + if (indent == position) { + return pdoc->SetLineIndentation(line, pdoc->GetLineIndentation(line) + virtualSpace); + } else { + std::string spaceText(virtualSpace, ' '); + const Sci::Position lengthInserted = pdoc->InsertString(position, spaceText.c_str(), virtualSpace); + position += lengthInserted; + } } return position; } +SelectionPosition Editor::RealizeVirtualSpace(const SelectionPosition &position) { + // Return the new position with no virtual space + return SelectionPosition(RealizeVirtualSpace(position.Position(), position.VirtualSpace())); +} + void Editor::AddChar(char ch) { char s[2]; s[0] = ch; @@ -1850,12 +1898,11 @@ void Editor::FilterSelections() { } } -static bool cmpSelPtrs(const SelectionRange *a, const SelectionRange *b) { - return *a < *b; -} - // AddCharUTF inserts an array of bytes which may or may not be in UTF-8. void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { + if (len == 0) { + return; + } FilterSelections(); { UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike); @@ -1866,7 +1913,8 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { selPtrs.push_back(&sel.Range(r)); } // Order selections by position in document. - std::sort(selPtrs.begin(), selPtrs.end(), cmpSelPtrs); + std::sort(selPtrs.begin(), selPtrs.end(), + [](const SelectionRange *a, const SelectionRange *b) {return *a < *b;}); // Loop in reverse to avoid disturbing positions of selections yet to be processed. for (std::vector::reverse_iterator rit = selPtrs.rbegin(); @@ -1874,7 +1922,7 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { SelectionRange *currentSel = *rit; if (!RangeContainsProtected(currentSel->Start().Position(), currentSel->End().Position())) { - int positionInsert = currentSel->Start().Position(); + Sci::Position positionInsert = currentSel->Start().Position(); if (!currentSel->Empty()) { if (currentSel->Length()) { pdoc->DeleteChars(positionInsert, currentSel->Length()); @@ -1891,8 +1939,8 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { } } } - positionInsert = InsertSpace(positionInsert, currentSel->caret.VirtualSpace()); - const int lengthInserted = pdoc->InsertString(positionInsert, s, len); + positionInsert = RealizeVirtualSpace(positionInsert, currentSel->caret.VirtualSpace()); + const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, s, len); if (lengthInserted > 0) { currentSel->caret.SetPosition(positionInsert + lengthInserted); currentSel->anchor.SetPosition(positionInsert + lengthInserted); @@ -1902,7 +1950,7 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { if (Wrapping()) { AutoSurface surface(this); if (surface) { - if (WrapOneLine(surface, pdoc->LineFromPosition(positionInsert))) { + if (WrapOneLine(surface, pdoc->SciLineFromPosition(positionInsert))) { SetScrollBars(); SetVerticalScrollPos(); Redraw(); @@ -1925,12 +1973,14 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { SetLastXChosen(); } - if (treatAsDBCS) { - NotifyChar((static_cast(s[0]) << 8) | - static_cast(s[1])); - } else if (len > 0) { - int byte = static_cast(s[0]); - if ((byte < 0xC0) || (1 == len)) { + int ch = static_cast(s[0]); + if (treatAsDBCS || pdoc->dbcsCodePage != SC_CP_UTF8) { + if (len > 1) { + // DBCS code page or DBCS font character set. + ch = (ch << 8) | static_cast(s[1]); + } + } else { + if ((ch < 0xC0) || (1 == len)) { // Handles UTF-8 characters between 0x01 and 0x7F and single byte // characters when not in UTF-8 mode. // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid @@ -1938,28 +1988,44 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { } else { unsigned int utf32[1] = { 0 }; UTF32FromUTF8(s, len, utf32, ELEMENTS(utf32)); - byte = utf32[0]; + ch = utf32[0]; } - NotifyChar(byte); } + NotifyChar(ch); if (recordingMacro) { NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(s)); } } -void Editor::FillVirtualSpace() { - const bool tmpOverstrike = inOverstrike; - inOverstrike = false; // not allow to be deleted twice. - AddCharUTF("", 0); - inOverstrike = tmpOverstrike; +void Editor::ClearBeforeTentativeStart() { + // Make positions for the first composition string. + FilterSelections(); + UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike); + for (size_t r = 0; rDeleteChars(positionInsert, sel.Range(r).Length()); + sel.Range(r).ClearVirtualSpace(); + } else { + // Range is all virtual so collapse to start of virtual space + sel.Range(r).MinimizeVirtualSpace(); + } + } + RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); + sel.Range(r).ClearVirtualSpace(); + } + } } -void Editor::InsertPaste(const char *text, int len) { +void Editor::InsertPaste(const char *text, Sci::Position len) { if (multiPasteMode == SC_MULTIPASTE_ONCE) { SelectionPosition selStart = sel.Start(); - selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace())); - const int lengthInserted = pdoc->InsertString(selStart.Position(), text, len); + selStart = RealizeVirtualSpace(selStart); + const Sci::Position lengthInserted = pdoc->InsertString(selStart.Position(), text, len); if (lengthInserted > 0) { SetEmptySelection(selStart.Position() + lengthInserted); } @@ -1968,7 +2034,7 @@ void Editor::InsertPaste(const char *text, int len) { for (size_t r=0; rDeleteChars(positionInsert, sel.Range(r).Length()); @@ -1978,8 +2044,8 @@ void Editor::InsertPaste(const char *text, int len) { sel.Range(r).MinimizeVirtualSpace(); } } - positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); - const int lengthInserted = pdoc->InsertString(positionInsert, text, len); + positionInsert = RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); + const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, text, len); if (lengthInserted > 0) { sel.Range(r).caret.SetPosition(positionInsert + lengthInserted); sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted); @@ -1990,24 +2056,25 @@ void Editor::InsertPaste(const char *text, int len) { } } -void Editor::InsertPasteShape(const char *text, int len, PasteShape shape) { +void Editor::InsertPasteShape(const char *text, Sci::Position len, PasteShape shape) { std::string convertedText; if (convertPastes) { // Convert line endings of the paste into our local line-endings mode convertedText = Document::TransformLineEnds(text, len, pdoc->eolMode); - len = static_cast(convertedText.length()); + len = convertedText.length(); text = convertedText.c_str(); } if (shape == pasteRectangular) { PasteRectangular(sel.Start(), text, len); } else { if (shape == pasteLine) { - int insertPos = pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())); - int lengthInserted = pdoc->InsertString(insertPos, text, len); + const Sci::Position insertPos = + pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())); + Sci::Position lengthInserted = pdoc->InsertString(insertPos, text, len); // add the newline if necessary if ((len > 0) && (text[len - 1] != '\n' && text[len - 1] != '\r')) { const char *endline = StringFromEOLMode(pdoc->eolMode); - int length = static_cast(strlen(endline)); + const Sci::Position length = strlen(endline); lengthInserted += pdoc->InsertString(insertPos + lengthInserted, endline, length); } if (sel.MainCaret() == insertPos) { @@ -2046,7 +2113,7 @@ void Editor::ClearAll() { pdoc->DeleteChars(0, pdoc->Length()); } if (!pdoc->IsReadOnly()) { - cs.Clear(); + pcs->Clear(); pdoc->AnnotationClearAll(); pdoc->MarginClearAll(); } @@ -2061,19 +2128,10 @@ void Editor::ClearAll() { } void Editor::ClearDocumentStyle() { - Decoration *deco = pdoc->decorations.root; - while (deco) { - // Save next in case deco deleted - Decoration *decoNext = deco->next; - if (deco->indicator < INDIC_CONTAINER) { - pdoc->decorations.SetCurrentIndicator(deco->indicator); - pdoc->DecorationFillRange(0, 0, pdoc->Length()); - } - deco = decoNext; - } + pdoc->decorations->DeleteLexerDecorations(); pdoc->StartStyling(0, '\377'); pdoc->SetStyleFor(pdoc->Length(), 0); - cs.ShowAll(); + pcs->ShowAll(); SetAnnotationHeights(0, pdoc->LinesTotal()); pdoc->ClearLevels(); } @@ -2092,21 +2150,20 @@ void Editor::Cut() { } } -void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) { +void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, Sci::Position len) { if (pdoc->IsReadOnly() || SelectionContainsProtected()) { return; } sel.Clear(); sel.RangeMain() = SelectionRange(pos); - int line = pdoc->LineFromPosition(sel.MainCaret()); + Sci::Line line = pdoc->SciLineFromPosition(sel.MainCaret()); UndoGroup ug(pdoc); - sel.RangeMain().caret = SelectionPosition( - InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); - int xInsert = XFromPosition(sel.RangeMain().caret); + sel.RangeMain().caret = RealizeVirtualSpace(sel.RangeMain().caret); + const int xInsert = XFromPosition(sel.RangeMain().caret); bool prevCr = false; while ((len > 0) && IsEOLChar(ptr[len-1])) len--; - for (int i = 0; i < len; i++) { + for (Sci::Position i = 0; i < len; i++) { if (IsEOLChar(ptr[i])) { if ((ptr[i] == '\r') || (!prevCr)) line++; @@ -2118,16 +2175,16 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) { } // Pad the end of lines with spaces if required sel.RangeMain().caret.SetPosition(PositionFromLineX(line, xInsert)); - if ((XFromPosition(sel.MainCaret()) < xInsert) && (i + 1 < len)) { - while (XFromPosition(sel.MainCaret()) < xInsert) { + if ((XFromPosition(sel.RangeMain().caret) < xInsert) && (i + 1 < len)) { + while (XFromPosition(sel.RangeMain().caret) < xInsert) { assert(pdoc); - const int lengthInserted = pdoc->InsertString(sel.MainCaret(), " ", 1); + const Sci::Position lengthInserted = pdoc->InsertString(sel.MainCaret(), " ", 1); sel.RangeMain().caret.Add(lengthInserted); } } prevCr = ptr[i] == '\r'; } else { - const int lengthInserted = pdoc->InsertString(sel.MainCaret(), ptr + i, 1); + const Sci::Position lengthInserted = pdoc->InsertString(sel.MainCaret(), ptr + i, 1); sel.RangeMain().caret.Add(lengthInserted); prevCr = false; } @@ -2153,9 +2210,9 @@ void Editor::Clear() { if (!RangeContainsProtected(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1)) { if (sel.Range(r).Start().VirtualSpace()) { if (sel.Range(r).anchor < sel.Range(r).caret) - sel.Range(r) = SelectionRange(InsertSpace(sel.Range(r).anchor.Position(), sel.Range(r).anchor.VirtualSpace())); + sel.Range(r) = SelectionRange(RealizeVirtualSpace(sel.Range(r).anchor.Position(), sel.Range(r).anchor.VirtualSpace())); else - sel.Range(r) = SelectionRange(InsertSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace())); + sel.Range(r) = SelectionRange(RealizeVirtualSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace())); } if ((sel.Count() == 1) || !pdoc->IsPositionInLineEnd(sel.Range(r).caret.Position())) { pdoc->DelChar(sel.Range(r).caret.Position()); @@ -2181,7 +2238,7 @@ void Editor::SelectAll() { void Editor::Undo() { if (pdoc->CanUndo()) { InvalidateCaret(); - int newPos = pdoc->Undo(); + const Sci::Position newPos = pdoc->Undo(); if (newPos >= 0) SetEmptySelection(newPos); EnsureCaretVisible(); @@ -2190,7 +2247,7 @@ void Editor::Undo() { void Editor::Redo() { if (pdoc->CanRedo()) { - int newPos = pdoc->Redo(); + const Sci::Position newPos = pdoc->Redo(); if (newPos >= 0) SetEmptySelection(newPos); EnsureCaretVisible(); @@ -2211,17 +2268,18 @@ void Editor::DelCharBack(bool allowLineStartDeletion) { sel.Range(r).caret.SetVirtualSpace(sel.Range(r).caret.VirtualSpace() - 1); sel.Range(r).anchor.SetVirtualSpace(sel.Range(r).caret.VirtualSpace()); } else { - int lineCurrentPos = pdoc->LineFromPosition(sel.Range(r).caret.Position()); + const Sci::Line lineCurrentPos = + pdoc->SciLineFromPosition(sel.Range(r).caret.Position()); if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != sel.Range(r).caret.Position())) { if (pdoc->GetColumn(sel.Range(r).caret.Position()) <= pdoc->GetLineIndentation(lineCurrentPos) && pdoc->GetColumn(sel.Range(r).caret.Position()) > 0 && pdoc->backspaceUnindents) { UndoGroup ugInner(pdoc, !ug.Needed()); - int indentation = pdoc->GetLineIndentation(lineCurrentPos); - int indentationStep = pdoc->IndentSize(); + const int indentation = pdoc->GetLineIndentation(lineCurrentPos); + const int indentationStep = pdoc->IndentSize(); int indentationChange = indentation % indentationStep; if (indentationChange == 0) indentationChange = indentationStep; - const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationChange); + const Sci::Position posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationChange); // SetEmptySelection sel.Range(r) = SelectionRange(posSelect); } else { @@ -2243,12 +2301,13 @@ void Editor::DelCharBack(bool allowLineStartDeletion) { ShowCaretAtCurrentPosition(); } -int Editor::ModifierFlags(bool shift, bool ctrl, bool alt, bool meta) { +int Editor::ModifierFlags(bool shift, bool ctrl, bool alt, bool meta, bool super) noexcept { return (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0) | - (meta ? SCI_META : 0); + (meta ? SCI_META : 0) | + (super ? SCI_SUPER : 0); } void Editor::NotifyFocus(bool focus) { @@ -2261,14 +2320,14 @@ void Editor::SetCtrlID(int identifier) { ctrlID = identifier; } -void Editor::NotifyStyleToNeeded(int endStyleNeeded) { +void Editor::NotifyStyleToNeeded(Sci::Position endStyleNeeded) { SCNotification scn = {}; scn.nmhdr.code = SCN_STYLENEEDED; scn.position = endStyleNeeded; NotifyParent(scn); } -void Editor::NotifyStyleNeeded(Document *, void *, int endStyleNeeded) { +void Editor::NotifyStyleNeeded(Document *, void *, Sci::Position endStyleNeeded) { NotifyStyleToNeeded(endStyleNeeded); } @@ -2311,11 +2370,7 @@ void Editor::NotifyDoubleClick(Point pt, int modifiers) { NotifyParent(scn); } -void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) { - NotifyDoubleClick(pt, ModifierFlags(shift, ctrl, alt)); -} - -void Editor::NotifyHotSpotDoubleClicked(int position, int modifiers) { +void Editor::NotifyHotSpotDoubleClicked(Sci::Position position, int modifiers) { SCNotification scn = {}; scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK; scn.position = position; @@ -2323,11 +2378,7 @@ void Editor::NotifyHotSpotDoubleClicked(int position, int modifiers) { NotifyParent(scn); } -void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) { - NotifyHotSpotDoubleClicked(position, ModifierFlags(shift, ctrl, alt)); -} - -void Editor::NotifyHotSpotClicked(int position, int modifiers) { +void Editor::NotifyHotSpotClicked(Sci::Position position, int modifiers) { SCNotification scn = {}; scn.nmhdr.code = SCN_HOTSPOTCLICK; scn.position = position; @@ -2335,11 +2386,7 @@ void Editor::NotifyHotSpotClicked(int position, int modifiers) { NotifyParent(scn); } -void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) { - NotifyHotSpotClicked(position, ModifierFlags(shift, ctrl, alt)); -} - -void Editor::NotifyHotSpotReleaseClick(int position, int modifiers) { +void Editor::NotifyHotSpotReleaseClick(Sci::Position position, int modifiers) { SCNotification scn = {}; scn.nmhdr.code = SCN_HOTSPOTRELEASECLICK; scn.position = position; @@ -2347,10 +2394,6 @@ void Editor::NotifyHotSpotReleaseClick(int position, int modifiers) { NotifyParent(scn); } -void Editor::NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt) { - NotifyHotSpotReleaseClick(position, ModifierFlags(shift, ctrl, alt)); -} - bool Editor::NotifyUpdateUI() { if (needUpdateUI) { SCNotification scn = {}; @@ -2369,11 +2412,11 @@ void Editor::NotifyPainted() { NotifyParent(scn); } -void Editor::NotifyIndicatorClick(bool click, int position, int modifiers) { - int mask = pdoc->decorations.AllOnFor(position); - if ((click && mask) || pdoc->decorations.clickNotified) { +void Editor::NotifyIndicatorClick(bool click, Sci::Position position, int modifiers) { + const int mask = pdoc->decorations->AllOnFor(position); + if ((click && mask) || pdoc->decorations->ClickNotified()) { SCNotification scn = {}; - pdoc->decorations.clickNotified = click; + pdoc->decorations->SetClickNotified(click); scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE; scn.modifiers = modifiers; scn.position = position; @@ -2381,28 +2424,18 @@ void Editor::NotifyIndicatorClick(bool click, int position, int modifiers) { } } -void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) { - NotifyIndicatorClick(click, position, ModifierFlags(shift, ctrl, alt)); -} - bool Editor::NotifyMarginClick(Point pt, int modifiers) { - int marginClicked = -1; - int x = vs.textStart - vs.fixedColumnWidth; - for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) { - if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width)) - marginClicked = margin; - x += vs.ms[margin].width; - } + const int marginClicked = vs.MarginFromLocation(pt); if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) { - int position = pdoc->LineStart(LineFromLocation(pt)); + const Sci::Position position = pdoc->LineStart(LineFromLocation(pt)); if ((vs.ms[marginClicked].mask & SC_MASK_FOLDERS) && (foldAutomatic & SC_AUTOMATICFOLD_CLICK)) { const bool ctrl = (modifiers & SCI_CTRL) != 0; const bool shift = (modifiers & SCI_SHIFT) != 0; - int lineClick = pdoc->LineFromPosition(position); + const Sci::Line lineClick = pdoc->SciLineFromPosition(position); if (shift && ctrl) { FoldAll(SC_FOLDACTION_TOGGLE); } else { - int levelClick = pdoc->GetLevel(lineClick); + const int levelClick = pdoc->GetLevel(lineClick); if (levelClick & SC_FOLDLEVELHEADERFLAG) { if (shift) { // Ensure all children visible @@ -2429,11 +2462,23 @@ bool Editor::NotifyMarginClick(Point pt, int modifiers) { } } -bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { - return NotifyMarginClick(pt, ModifierFlags(shift, ctrl, alt)); +bool Editor::NotifyMarginRightClick(Point pt, int modifiers) { + const int marginRightClicked = vs.MarginFromLocation(pt); + if ((marginRightClicked >= 0) && vs.ms[marginRightClicked].sensitive) { + const Sci::Position position = pdoc->LineStart(LineFromLocation(pt)); + SCNotification scn = {}; + scn.nmhdr.code = SCN_MARGINRIGHTCLICK; + scn.modifiers = modifiers; + scn.position = position; + scn.margin = marginRightClicked; + NotifyParent(scn); + return true; + } else { + return false; + } } -void Editor::NotifyNeedShown(int pos, int len) { +void Editor::NotifyNeedShown(Sci::Position pos, Sci::Position len) { SCNotification scn = {}; scn.nmhdr.code = SCN_NEEDSHOWN; scn.position = pos; @@ -2470,8 +2515,8 @@ void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) { void Editor::CheckModificationForWrap(DocModification mh) { if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) { view.llc.Invalidate(LineLayout::llCheckTextAndStyle); - int lineDoc = pdoc->LineFromPosition(mh.position); - int lines = Platform::Maximum(0, mh.linesAdded); + const Sci::Line lineDoc = pdoc->SciLineFromPosition(mh.position); + const Sci::Line lines = std::max(static_cast(0), mh.linesAdded); if (Wrapping()) { NeedWrapping(lineDoc, lineDoc + lines + 1); } @@ -2481,8 +2526,10 @@ void Editor::CheckModificationForWrap(DocModification mh) { } } +namespace { + // Move a position so it is still after the same character as before the insertion. -static inline int MovePositionForInsertion(int position, int startInsertion, int length) { +Sci::Position MovePositionForInsertion(Sci::Position position, Sci::Position startInsertion, Sci::Position length) noexcept { if (position > startInsertion) { return position + length; } @@ -2491,9 +2538,9 @@ static inline int MovePositionForInsertion(int position, int startInsertion, int // Move a position so it is still after the same character as before the deletion if that // character is still present else after the previous surviving character. -static inline int MovePositionForDeletion(int position, int startDeletion, int length) { +Sci::Position MovePositionForDeletion(Sci::Position position, Sci::Position startDeletion, Sci::Position length) noexcept { if (position > startDeletion) { - int endDeletion = startDeletion + length; + const Sci::Position endDeletion = startDeletion + length; if (position > endDeletion) { return position - length; } else { @@ -2504,6 +2551,8 @@ static inline int MovePositionForDeletion(int position, int startDeletion, int l } } +} + void Editor::NotifyModified(Document *, DocModification mh, void *) { ContainerNeedsUpdate(SC_UPDATE_CONTENT); if (paintState == painting) { @@ -2512,7 +2561,8 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { if (mh.modificationType & SC_MOD_CHANGELINESTATE) { if (paintState == painting) { CheckForChangeOutsidePaint( - Range(pdoc->LineStart(mh.line), pdoc->LineStart(mh.line + 1))); + Range(pdoc->LineStart(mh.line), + pdoc->LineStart(mh.line + 1))); } else { // Could check that change is before last visible line. Redraw(); @@ -2534,7 +2584,8 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { pdoc->IncrementStyleClock(); } if (paintState == notPainting) { - if (mh.position < pdoc->LineStart(topLine)) { + const Sci::Line lineDocTop = pcs->DocFromDisplay(topLine); + if (mh.position < pdoc->LineStart(lineDocTop)) { // Styling performed before this view Redraw(); } else { @@ -2555,41 +2606,46 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length); braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length); } - if ((mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) && cs.HiddenLines()) { + if ((mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) && pcs->HiddenLines()) { // Some lines are hidden so may need shown. - // TODO: check if the modified area is hidden. + const Sci::Line lineOfPos = pdoc->SciLineFromPosition(mh.position); + Sci::Position endNeedShown = mh.position; if (mh.modificationType & SC_MOD_BEFOREINSERT) { - int lineOfPos = pdoc->LineFromPosition(mh.position); - bool insertingNewLine = false; - for (int i=0; i < mh.length; i++) { - if ((mh.text[i] == '\n') || (mh.text[i] == '\r')) - insertingNewLine = true; - } - if (insertingNewLine && (mh.position != pdoc->LineStart(lineOfPos))) - NeedShown(mh.position, pdoc->LineStart(lineOfPos+1) - mh.position); - else - NeedShown(mh.position, 0); + if (pdoc->ContainsLineEnd(mh.text, mh.length) && (mh.position != pdoc->LineStart(lineOfPos))) + endNeedShown = pdoc->LineStart(lineOfPos+1); } else if (mh.modificationType & SC_MOD_BEFOREDELETE) { - NeedShown(mh.position, mh.length); + // If the deletion includes any EOL then we extend the need shown area. + endNeedShown = mh.position + mh.length; + Sci::Line lineLast = pdoc->SciLineFromPosition(mh.position+mh.length); + for (Sci::Line line = lineOfPos + 1; line <= lineLast; line++) { + const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, -1, -1); + if (lineLast < lineMaxSubord) { + lineLast = lineMaxSubord; + endNeedShown = pdoc->LineEnd(lineLast); + } + } } + NeedShown(mh.position, endNeedShown - mh.position); } if (mh.linesAdded != 0) { // Update contraction state for inserted and removed lines // lineOfPos should be calculated in context of state before modification, shouldn't it - int lineOfPos = pdoc->LineFromPosition(mh.position); + Sci::Line lineOfPos = pdoc->SciLineFromPosition(mh.position); if (mh.position > pdoc->LineStart(lineOfPos)) lineOfPos++; // Affecting subsequent lines if (mh.linesAdded > 0) { - cs.InsertLines(lineOfPos, mh.linesAdded); + pcs->InsertLines(lineOfPos, mh.linesAdded); } else { - cs.DeleteLines(lineOfPos, -mh.linesAdded); + pcs->DeleteLines(lineOfPos, -mh.linesAdded); } view.LinesAddedOrRemoved(lineOfPos, mh.linesAdded); } if (mh.modificationType & SC_MOD_CHANGEANNOTATION) { - int lineDoc = pdoc->LineFromPosition(mh.position); + const Sci::Line lineDoc = pdoc->SciLineFromPosition(mh.position); if (vs.annotationVisible) { - cs.SetHeight(lineDoc, cs.GetHeight(lineDoc) + mh.annotationLinesAdded); + if (pcs->SetHeight(lineDoc, pcs->GetHeight(lineDoc) + static_cast(mh.annotationLinesAdded))) { + SetScrollBars(); + } Redraw(); } } @@ -2597,7 +2653,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { if (mh.linesAdded != 0) { // Avoid scrolling of display if change before current display if (mh.position < posTopLine && !CanDeferToLastStep(mh)) { - int newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos()); + const Sci::Line newTop = Sci::clamp(topLine + mh.linesAdded, static_cast(0), MaxScrollPos()); if (newTop != topLine) { SetTopLine(newTop); SetVerticalScrollPos(); @@ -2605,12 +2661,16 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { } if (paintState == notPainting && !CanDeferToLastStep(mh)) { - QueueIdleWork(WorkNeeded::workStyle, pdoc->Length()); + if (SynchronousStylingToVisible()) { + QueueIdleWork(WorkNeeded::workStyle, pdoc->Length()); + } Redraw(); } } else { if (paintState == notPainting && mh.length && !CanEliminate(mh)) { - QueueIdleWork(WorkNeeded::workStyle, mh.position + mh.length); + if (SynchronousStylingToVisible()) { + QueueIdleWork(WorkNeeded::workStyle, mh.position + mh.length); + } InvalidateRange(mh.position, mh.position + mh.length); } } @@ -2642,9 +2702,11 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { // If client wants to see this modification if (mh.modificationType & modEventMask) { - if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) { - // Real modification made to text of document. - NotifyChange(); // Send EN_CHANGE + if (commandEvents) { + if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) { + // Real modification made to text of document. + NotifyChange(); // Send EN_CHANGE + } } SCNotification scn = {}; @@ -2657,13 +2719,13 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { scn.line = mh.line; scn.foldLevelNow = mh.foldLevelNow; scn.foldLevelPrev = mh.foldLevelPrev; - scn.token = mh.token; + scn.token = static_cast(mh.token); scn.annotationLinesAdded = mh.annotationLinesAdded; NotifyParent(scn); } } -void Editor::NotifyDeleted(Document *, void *) { +void Editor::NotifyDeleted(Document *, void *) noexcept { /* Do nothing */ } @@ -2751,6 +2813,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar case SCI_LINECUT: case SCI_LINEDELETE: case SCI_LINETRANSPOSE: + case SCI_LINEREVERSE: case SCI_LINEDUPLICATE: case SCI_LOWERCASE: case SCI_UPPERCASE: @@ -2798,7 +2861,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar } // Something has changed that the container should know about -void Editor::ContainerNeedsUpdate(int flags) { +void Editor::ContainerNeedsUpdate(int flags) noexcept { needUpdateUI |= flags; } @@ -2809,14 +2872,14 @@ void Editor::ContainerNeedsUpdate(int flags) { * If stuttered = true and already at first/last row, scroll as normal. */ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) { - int topLineNew; + Sci::Line topLineNew; SelectionPosition newPos; - int currentLine = pdoc->LineFromPosition(sel.MainCaret()); - int topStutterLine = topLine + caretYSlop; - int bottomStutterLine = - pdoc->LineFromPosition(PositionFromLocation( - Point::FromInts(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll()))) + const Sci::Line currentLine = pdoc->SciLineFromPosition(sel.MainCaret()); + const Sci::Line topStutterLine = topLine + caretYSlop; + const Sci::Line bottomStutterLine = + pdoc->SciLineFromPosition(PositionFromLocation( + Point::FromInts(lastXChosen - xOffset, direction * vs.lineHeight * static_cast(LinesToScroll())))) - caretYSlop - 1; if (stuttered && (direction < 0 && currentLine > topStutterLine)) { @@ -2826,16 +2889,17 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) { } else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) { topLineNew = topLine; - newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)), + newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * static_cast(LinesToScroll() - caretYSlop)), false, false, UserVirtualSpace()); } else { - Point pt = LocationFromPosition(sel.MainCaret()); + const Point pt = LocationFromPosition(sel.MainCaret()); - topLineNew = Platform::Clamp( - topLine + direction * LinesToScroll(), 0, MaxScrollPos()); + topLineNew = Sci::clamp( + topLine + direction * LinesToScroll(), static_cast(0), MaxScrollPos()); newPos = SPositionFromLocation( - Point::FromInts(lastXChosen - xOffset, static_cast(pt.y) + direction * (vs.lineHeight * LinesToScroll())), + Point::FromInts(lastXChosen - xOffset, static_cast(pt.y) + + direction * (vs.lineHeight * static_cast(LinesToScroll()))), false, false, UserVirtualSpace()); } @@ -2855,7 +2919,7 @@ void Editor::ChangeCaseOfSelection(int caseMapping) { SelectionRange current = sel.Range(r); SelectionRange currentNoVS = current; currentNoVS.ClearVirtualSpace(); - size_t rangeBytes = currentNoVS.Length(); + const size_t rangeBytes = currentNoVS.Length(); if (rangeBytes > 0) { std::string sText = RangeText(currentNoVS.Start().Position(), currentNoVS.End().Position()); @@ -2871,17 +2935,17 @@ void Editor::ChangeCaseOfSelection(int caseMapping) { lastDifferenceText--; lastDifferenceMapped--; } - size_t endDifferenceText = sText.size() - 1 - lastDifferenceText; + const size_t endDifferenceText = sText.size() - 1 - lastDifferenceText; pdoc->DeleteChars( - static_cast(currentNoVS.Start().Position() + firstDifference), - static_cast(rangeBytes - firstDifference - endDifferenceText)); - const int lengthChange = static_cast(lastDifferenceMapped - firstDifference + 1); - const int lengthInserted = pdoc->InsertString( - static_cast(currentNoVS.Start().Position() + firstDifference), + currentNoVS.Start().Position() + firstDifference, + rangeBytes - firstDifference - endDifferenceText); + const Sci::Position lengthChange = lastDifferenceMapped - firstDifference + 1; + const Sci::Position lengthInserted = pdoc->InsertString( + currentNoVS.Start().Position() + firstDifference, sMapped.c_str() + firstDifference, lengthChange); // Automatic movement changes selection so reset to exactly the same as it was. - int diffSizes = static_cast(sMapped.size() - sText.size()) + lengthInserted - lengthChange; + const Sci::Position diffSizes = sMapped.size() - sText.size() + lengthInserted - lengthChange; if (diffSizes != 0) { if (current.anchor > current.caret) current.anchor.Add(diffSizes); @@ -2895,59 +2959,89 @@ void Editor::ChangeCaseOfSelection(int caseMapping) { } void Editor::LineTranspose() { - int line = pdoc->LineFromPosition(sel.MainCaret()); + const Sci::Line line = pdoc->SciLineFromPosition(sel.MainCaret()); if (line > 0) { UndoGroup ug(pdoc); - const int startPrevious = pdoc->LineStart(line - 1); + const Sci::Position startPrevious = pdoc->LineStart(line - 1); const std::string linePrevious = RangeText(startPrevious, pdoc->LineEnd(line - 1)); - int startCurrent = pdoc->LineStart(line); + Sci::Position startCurrent = pdoc->LineStart(line); const std::string lineCurrent = RangeText(startCurrent, pdoc->LineEnd(line)); - pdoc->DeleteChars(startCurrent, static_cast(lineCurrent.length())); - pdoc->DeleteChars(startPrevious, static_cast(linePrevious.length())); - startCurrent -= static_cast(linePrevious.length()); + pdoc->DeleteChars(startCurrent, lineCurrent.length()); + pdoc->DeleteChars(startPrevious, linePrevious.length()); + startCurrent -= linePrevious.length(); startCurrent += pdoc->InsertString(startPrevious, lineCurrent.c_str(), - static_cast(lineCurrent.length())); + lineCurrent.length()); pdoc->InsertString(startCurrent, linePrevious.c_str(), - static_cast(linePrevious.length())); + linePrevious.length()); // Move caret to start of current line MovePositionTo(SelectionPosition(startCurrent)); } } +void Editor::LineReverse() { + const Sci::Line lineStart = + pdoc->SciLineFromPosition(sel.RangeMain().Start().Position()); + const Sci::Line lineEnd = + pdoc->SciLineFromPosition(sel.RangeMain().End().Position()-1); + const Sci::Line lineDiff = lineEnd - lineStart; + if (lineDiff <= 0) + return; + UndoGroup ug(pdoc); + for (Sci::Line i=(lineDiff+1)/2-1; i>=0; --i) { + const Sci::Line lineNum2 = lineEnd - i; + const Sci::Line lineNum1 = lineStart + i; + Sci::Position lineStart2 = pdoc->LineStart(lineNum2); + const Sci::Position lineStart1 = pdoc->LineStart(lineNum1); + const std::string line2 = RangeText(lineStart2, pdoc->LineEnd(lineNum2)); + const std::string line1 = RangeText(lineStart1, pdoc->LineEnd(lineNum1)); + const Sci::Position lineLen2 = line2.length(); + const Sci::Position lineLen1 = line1.length(); + pdoc->DeleteChars(lineStart2, lineLen2); + pdoc->DeleteChars(lineStart1, lineLen1); + lineStart2 -= lineLen1; + pdoc->InsertString(lineStart2, line1.c_str(), lineLen1); + pdoc->InsertString(lineStart1, line2.c_str(), lineLen2); + } + // Wholly select all affected lines + sel.RangeMain() = SelectionRange(pdoc->LineStart(lineStart), + pdoc->LineStart(lineEnd+1)); +} + void Editor::Duplicate(bool forLine) { if (sel.Empty()) { forLine = true; } UndoGroup ug(pdoc); const char *eol = ""; - int eolLen = 0; + Sci::Position eolLen = 0; if (forLine) { eol = StringFromEOLMode(pdoc->eolMode); - eolLen = istrlen(eol); + eolLen = strlen(eol); } for (size_t r=0; rLineFromPosition(sel.Range(r).caret.Position()); + const Sci::Line line = pdoc->SciLineFromPosition(sel.Range(r).caret.Position()); start = SelectionPosition(pdoc->LineStart(line)); end = SelectionPosition(pdoc->LineEnd(line)); } std::string text = RangeText(start.Position(), end.Position()); - int lengthInserted = eolLen; + Sci::Position lengthInserted = eolLen; if (forLine) lengthInserted = pdoc->InsertString(end.Position(), eol, eolLen); - pdoc->InsertString(end.Position() + lengthInserted, text.c_str(), static_cast(text.length())); + pdoc->InsertString(end.Position() + lengthInserted, text.c_str(), text.length()); } if (sel.Count() && sel.IsRectangular()) { SelectionPosition last = sel.Last(); if (forLine) { - int line = pdoc->LineFromPosition(last.Position()); - last = SelectionPosition(last.Position() + pdoc->LineStart(line+1) - pdoc->LineStart(line)); + const Sci::Line line = pdoc->SciLineFromPosition(last.Position()); + last = SelectionPosition(last.Position() + + pdoc->LineStart(line+1) - pdoc->LineStart(line)); } if (sel.Rectangular().anchor > sel.Rectangular().caret) sel.Rectangular().anchor = last; @@ -2980,8 +3074,8 @@ void Editor::NewLine() { for (size_t r = 0; r < sel.Count(); r++) { sel.Range(r).ClearVirtualSpace(); const char *eol = StringFromEOLMode(pdoc->eolMode); - const int positionInsert = sel.Range(r).caret.Position(); - const int insertLength = pdoc->InsertString(positionInsert, eol, istrlen(eol)); + const Sci::Position positionInsert = sel.Range(r).caret.Position(); + const Sci::Position insertLength = pdoc->InsertString(positionInsert, eol, strlen(eol)); if (insertLength > 0) { sel.Range(r) = SelectionRange(positionInsert + insertLength); countInsertions++; @@ -3016,26 +3110,26 @@ SelectionPosition Editor::PositionUpOrDown(SelectionPosition spStart, int direct int skipLines = 0; if (vs.annotationVisible) { - const int lineDoc = pdoc->LineFromPosition(spStart.Position()); + const Sci::Line lineDoc = pdoc->SciLineFromPosition(spStart.Position()); const Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc)); const int subLine = static_cast(pt.y - ptStartLine.y) / vs.lineHeight; if (direction < 0 && subLine == 0) { - const int lineDisplay = cs.DisplayFromDoc(lineDoc); + const Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc); if (lineDisplay > 0) { - skipLines = pdoc->AnnotationLines(cs.DocFromDisplay(lineDisplay - 1)); + skipLines = pdoc->AnnotationLines(pcs->DocFromDisplay(lineDisplay - 1)); } - } else if (direction > 0 && subLine >= (cs.GetHeight(lineDoc) - 1 - pdoc->AnnotationLines(lineDoc))) { + } else if (direction > 0 && subLine >= (pcs->GetHeight(lineDoc) - 1 - pdoc->AnnotationLines(lineDoc))) { skipLines = pdoc->AnnotationLines(lineDoc); } } - const int newY = static_cast(pt.y) + (1 + skipLines) * direction * vs.lineHeight; + const Sci::Line newY = static_cast(pt.y) + (1 + skipLines) * direction * vs.lineHeight; if (lastX < 0) { lastX = static_cast(pt.x) + xOffset; } SelectionPosition posNew = SPositionFromLocation( - Point::FromInts(lastX - xOffset, newY), false, false, UserVirtualSpace()); + Point::FromInts(lastX - xOffset, static_cast(newY)), false, false, UserVirtualSpace()); if (direction < 0) { // Line wrapping may lead to a location on the same line, so @@ -3060,6 +3154,9 @@ SelectionPosition Editor::PositionUpOrDown(SelectionPosition spStart, int direct } void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { + if ((selt == Selection::noSel) && sel.MoveExtends()) { + selt = !sel.IsRectangular() ? Selection::selStream : Selection::selRectangle; + } SelectionPosition caretToUse = sel.Range(sel.Main()).caret; if (sel.IsRectangular()) { if (selt == Selection::noSel) { @@ -3080,6 +3177,11 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { sel.Rectangular() = SelectionRange(posNew, rangeBase.anchor); SetRectangularRange(); MovedCaret(posNew, caretToUse, true); + } else if (sel.selType == Selection::selLines && sel.MoveExtends()) { + // Calculate new caret position and call SetSelection(), which will ensure whole lines are selected. + const SelectionPosition posNew = MovePositionSoVisible( + PositionUpOrDown(caretToUse, direction, -1), direction); + SetSelection(posNew, sel.Range(sel.Main()).anchor); } else { InvalidateWholeSelection(); if (!additionalSelectionTyping || (sel.IsRectangular())) { @@ -3091,7 +3193,7 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { const SelectionPosition spCaretNow = sel.Range(r).caret; const SelectionPosition posNew = MovePositionSoVisible( PositionUpOrDown(spCaretNow, direction, lastX), direction); - sel.Range(r) = selt == Selection::selStream ? + sel.Range(r) = selt == Selection::selStream ? SelectionRange(posNew, sel.Range(r).anchor) : SelectionRange(posNew); } sel.RemoveDuplicates(); @@ -3100,25 +3202,32 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { } void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) { - int lineDoc, savedPos = sel.MainCaret(); + Sci::Line lineDoc; + const Sci::Position savedPos = sel.MainCaret(); do { MovePositionTo(SelectionPosition(direction > 0 ? pdoc->ParaDown(sel.MainCaret()) : pdoc->ParaUp(sel.MainCaret())), selt); - lineDoc = pdoc->LineFromPosition(sel.MainCaret()); + lineDoc = pdoc->SciLineFromPosition(sel.MainCaret()); if (direction > 0) { - if (sel.MainCaret() >= pdoc->Length() && !cs.GetVisible(lineDoc)) { + if (sel.MainCaret() >= pdoc->Length() && !pcs->GetVisible(lineDoc)) { if (selt == Selection::noSel) { MovePositionTo(SelectionPosition(pdoc->LineEndPosition(savedPos))); } break; } } - } while (!cs.GetVisible(lineDoc)); + } while (!pcs->GetVisible(lineDoc)); } -int Editor::StartEndDisplayLine(int pos, bool start) { +Range Editor::RangeDisplayLine(Sci::Line lineVisible) { RefreshStyleData(); AutoSurface surface(this); - int posRet = view.StartEndDisplayLine(surface, *this, pos, start, vs); + return view.RangeDisplayLine(surface, *this, lineVisible, vs); +} + +Sci::Position Editor::StartEndDisplayLine(Sci::Position pos, bool start) { + RefreshStyleData(); + AutoSurface surface(this); + const Sci::Position posRet = view.StartEndDisplayLine(surface, *this, pos, start, vs); if (posRet == INVALID_POSITION) { return pos; } else { @@ -3128,7 +3237,15 @@ int Editor::StartEndDisplayLine(int pos, bool start) { namespace { -unsigned int WithExtends(unsigned int iMessage) { +constexpr short HighShortFromWParam(uptr_t x) { + return static_cast(x >> 16); +} + +constexpr short LowShortFromWParam(uptr_t x) { + return static_cast(x & 0xffff); +} + +unsigned int WithExtends(unsigned int iMessage) noexcept { switch (iMessage) { case SCI_CHARLEFT: return SCI_CHARLEFTEXTEND; case SCI_CHARRIGHT: return SCI_CHARRIGHTEXTEND; @@ -3155,7 +3272,7 @@ unsigned int WithExtends(unsigned int iMessage) { } } -int NaturalDirection(unsigned int iMessage) { +int NaturalDirection(unsigned int iMessage) noexcept { switch (iMessage) { case SCI_CHARLEFT: case SCI_CHARLEFTEXTEND: @@ -3186,7 +3303,7 @@ int NaturalDirection(unsigned int iMessage) { } } -bool IsRectExtend(unsigned int iMessage) { +bool IsRectExtend(unsigned int iMessage, bool isRectMoveExtends) noexcept { switch (iMessage) { case SCI_CHARLEFTRECTEXTEND: case SCI_CHARRIGHTRECTEXTEND: @@ -3195,33 +3312,46 @@ bool IsRectExtend(unsigned int iMessage) { case SCI_LINEENDRECTEXTEND: return true; default: + if (isRectMoveExtends) { + // Handle SCI_SETSELECTIONMODE(SC_SEL_RECTANGLE) and subsequent movements. + switch (iMessage) { + case SCI_CHARLEFTEXTEND: + case SCI_CHARRIGHTEXTEND: + case SCI_HOMEEXTEND: + case SCI_VCHOMEEXTEND: + case SCI_LINEENDEXTEND: + return true; + default: + return false; + } + } return false; } } } -int Editor::VCHomeDisplayPosition(int position) { - const int homePos = pdoc->VCHomePosition(position); - const int viewLineStart = StartEndDisplayLine(position, true); +Sci::Position Editor::VCHomeDisplayPosition(Sci::Position position) { + const Sci::Position homePos = pdoc->VCHomePosition(position); + const Sci::Position viewLineStart = StartEndDisplayLine(position, true); if (viewLineStart > homePos) return viewLineStart; else return homePos; } -int Editor::VCHomeWrapPosition(int position) { - const int homePos = pdoc->VCHomePosition(position); - const int viewLineStart = StartEndDisplayLine(position, true); +Sci::Position Editor::VCHomeWrapPosition(Sci::Position position) { + const Sci::Position homePos = pdoc->VCHomePosition(position); + const Sci::Position viewLineStart = StartEndDisplayLine(position, true); if ((viewLineStart < position) && (viewLineStart > homePos)) return viewLineStart; else return homePos; } -int Editor::LineEndWrapPosition(int position) { - const int endPos = StartEndDisplayLine(position, false); - const int realEndPos = pdoc->LineEndPosition(position); +Sci::Position Editor::LineEndWrapPosition(Sci::Position position) { + const Sci::Position endPos = StartEndDisplayLine(position, false); + const Sci::Position realEndPos = pdoc->LineEndPosition(position); if (endPos > realEndPos // if moved past visible EOLs || position >= endPos) // if at end of display line already return realEndPos; @@ -3230,6 +3360,9 @@ int Editor::LineEndWrapPosition(int position) { } int Editor::HorizontalMove(unsigned int iMessage) { + if (sel.selType == Selection::selLines) { + return 0; // horizontal moves with line selection have no effect + } if (sel.MoveExtends()) { iMessage = WithExtends(iMessage); } @@ -3242,7 +3375,7 @@ int Editor::HorizontalMove(unsigned int iMessage) { // Invalidate each of the current selections InvalidateWholeSelection(); - if (IsRectExtend(iMessage)) { + if (IsRectExtend(iMessage, sel.IsRectangular() && sel.MoveExtends())) { const SelectionRange rangeBase = sel.IsRectangular() ? sel.Rectangular() : sel.RangeMain(); if (!sel.IsRectangular()) { sel.DropAdditionalRanges(); @@ -3251,13 +3384,15 @@ int Editor::HorizontalMove(unsigned int iMessage) { SelectionPosition spCaret = rangeBase.caret; switch (iMessage) { case SCI_CHARLEFTRECTEXTEND: + case SCI_CHARLEFTEXTEND: // only when sel.IsRectangular() && sel.MoveExtends() if (pdoc->IsLineEndPosition(spCaret.Position()) && spCaret.VirtualSpace()) { spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); - } else { + } else if ((virtualSpaceOptions & SCVS_NOWRAPLINESTART) == 0 || pdoc->GetColumn(spCaret.Position()) > 0) { spCaret = SelectionPosition(spCaret.Position() - 1); } break; case SCI_CHARRIGHTRECTEXTEND: + case SCI_CHARRIGHTEXTEND: // only when sel.IsRectangular() && sel.MoveExtends() if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) && pdoc->IsLineEndPosition(sel.MainCaret())) { spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); } else { @@ -3265,12 +3400,16 @@ int Editor::HorizontalMove(unsigned int iMessage) { } break; case SCI_HOMERECTEXTEND: - spCaret = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position()))); + case SCI_HOMEEXTEND: // only when sel.IsRectangular() && sel.MoveExtends() + spCaret = SelectionPosition( + pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position()))); break; case SCI_VCHOMERECTEXTEND: + case SCI_VCHOMEEXTEND: // only when sel.IsRectangular() && sel.MoveExtends() spCaret = SelectionPosition(pdoc->VCHomePosition(spCaret.Position())); break; case SCI_LINEENDRECTEXTEND: + case SCI_LINEENDEXTEND: // only when sel.IsRectangular() && sel.MoveExtends() spCaret = SelectionPosition(pdoc->LineEndPosition(spCaret.Position())); break; } @@ -3279,13 +3418,24 @@ int Editor::HorizontalMove(unsigned int iMessage) { sel.selType = Selection::selRectangle; sel.Rectangular() = SelectionRange(spCaret, rangeBase.anchor); SetRectangularRange(); - } else { - if (sel.IsRectangular()) { - // Not a rectangular extension so switch to stream. - SelectionPosition selAtLimit = (NaturalDirection(iMessage) > 0) ? sel.Limits().end : sel.Limits().start; - sel.selType = Selection::selStream; - sel.SetSelection(SelectionRange(selAtLimit)); + } else if (sel.IsRectangular()) { + // Not a rectangular extension so switch to stream. + SelectionPosition selAtLimit = (NaturalDirection(iMessage) > 0) ? sel.Limits().end : sel.Limits().start; + switch (iMessage) { + case SCI_HOME: + selAtLimit = SelectionPosition( + pdoc->LineStart(pdoc->LineFromPosition(selAtLimit.Position()))); + break; + case SCI_VCHOME: + selAtLimit = SelectionPosition(pdoc->VCHomePosition(selAtLimit.Position())); + break; + case SCI_LINEEND: + selAtLimit = SelectionPosition(pdoc->LineEndPosition(selAtLimit.Position())); + break; } + sel.selType = Selection::selStream; + sel.SetSelection(SelectionRange(selAtLimit)); + } else { if (!additionalSelectionTyping) { InvalidateWholeSelection(); sel.DropAdditionalRanges(); @@ -3298,7 +3448,7 @@ int Editor::HorizontalMove(unsigned int iMessage) { case SCI_CHARLEFTEXTEND: if (spCaret.VirtualSpace()) { spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); - } else { + } else if ((virtualSpaceOptions & SCVS_NOWRAPLINESTART) == 0 || pdoc->GetColumn(spCaret.Position()) > 0) { spCaret = SelectionPosition(spCaret.Position() - 1); } break; @@ -3336,7 +3486,8 @@ int Editor::HorizontalMove(unsigned int iMessage) { break; case SCI_HOME: case SCI_HOMEEXTEND: - spCaret = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position()))); + spCaret = SelectionPosition( + pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position()))); break; case SCI_HOMEDISPLAY: case SCI_HOMEDISPLAYEXTEND: @@ -3346,7 +3497,8 @@ int Editor::HorizontalMove(unsigned int iMessage) { case SCI_HOMEWRAPEXTEND: spCaret = MovePositionSoVisible(StartEndDisplayLine(spCaret.Position(), true), -1); if (spCaretNow <= spCaret) - spCaret = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position()))); + spCaret = SelectionPosition( + pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position()))); break; case SCI_VCHOME: case SCI_VCHOMEEXTEND: @@ -3381,7 +3533,7 @@ int Editor::HorizontalMove(unsigned int iMessage) { const int directionMove = (spCaret < spCaretNow) ? -1 : 1; spCaret = MovePositionSoVisible(spCaret, directionMove); - // Handle move versus extend, and special behaviour for non-emoty left/right + // Handle move versus extend, and special behaviour for non-empty left/right switch (iMessage) { case SCI_CHARLEFT: case SCI_CHARRIGHT: @@ -3457,7 +3609,7 @@ int Editor::DelWordOrLine(unsigned int iMessage) { // which means 2 actions so wrap in an undo group. // Rightwards and leftwards deletions differ in treatment of virtual space. - // Clear virtual space for leftwards, realise for rightwards. + // Clear virtual space for leftwards, realise for rightwards. const bool leftwards = (iMessage == SCI_DELWORDLEFT) || (iMessage == SCI_DELLINELEFT); if (!additionalSelectionTyping) { @@ -3474,9 +3626,9 @@ int Editor::DelWordOrLine(unsigned int iMessage) { } else { // Delete to the right so first realise the virtual space. sel.Range(r) = SelectionRange( - InsertSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace())); + RealizeVirtualSpace(sel.Range(r).caret)); } - + Range rangeDelete; switch (iMessage) { case SCI_DELWORDLEFT: @@ -3652,14 +3804,14 @@ int Editor::KeyCommand(unsigned int iMessage) { break; case SCI_EDITTOGGLEOVERTYPE: inOverstrike = !inOverstrike; + ContainerNeedsUpdate(SC_UPDATE_SELECTION); ShowCaretAtCurrentPosition(); - ContainerNeedsUpdate(SC_UPDATE_CONTENT); - NotifyUpdateUI(); + SetIdle(true); break; case SCI_CANCEL: // Cancel any modes - handled in subclass // Also unselect text CancelModes(); - if (sel.Count() > 1) { + if ((sel.Count() > 1) && !sel.IsRectangular()) { // Drop additional selections InvalidateWholeSelection(); sel.DropAdditionalRanges(); @@ -3724,32 +3876,35 @@ int Editor::KeyCommand(unsigned int iMessage) { return DelWordOrLine(iMessage); case SCI_LINECOPY: { - int lineStart = pdoc->LineFromPosition(SelectionStart().Position()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position()); + const Sci::Line lineStart = pdoc->SciLineFromPosition(SelectionStart().Position()); + const Sci::Line lineEnd = pdoc->SciLineFromPosition(SelectionEnd().Position()); CopyRangeToClipboard(pdoc->LineStart(lineStart), - pdoc->LineStart(lineEnd + 1)); + pdoc->LineStart(lineEnd + 1)); } break; case SCI_LINECUT: { - int lineStart = pdoc->LineFromPosition(SelectionStart().Position()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position()); - int start = pdoc->LineStart(lineStart); - int end = pdoc->LineStart(lineEnd + 1); + const Sci::Line lineStart = pdoc->SciLineFromPosition(SelectionStart().Position()); + const Sci::Line lineEnd = pdoc->SciLineFromPosition(SelectionEnd().Position()); + const Sci::Position start = pdoc->LineStart(lineStart); + const Sci::Position end = pdoc->LineStart(lineEnd + 1); SetSelection(start, end); Cut(); SetLastXChosen(); } break; case SCI_LINEDELETE: { - int line = pdoc->LineFromPosition(sel.MainCaret()); - int start = pdoc->LineStart(line); - int end = pdoc->LineStart(line + 1); + const Sci::Line line = pdoc->SciLineFromPosition(sel.MainCaret()); + const Sci::Position start = pdoc->LineStart(line); + const Sci::Position end = pdoc->LineStart(line + 1); pdoc->DeleteChars(start, end - start); } break; case SCI_LINETRANSPOSE: LineTranspose(); break; + case SCI_LINEREVERSE: + LineReverse(); + break; case SCI_LINEDUPLICATE: Duplicate(true); break; @@ -3778,7 +3933,7 @@ int Editor::KeyDefault(int, int) { int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) { DwellEnd(false); - int msg = kmap.Find(key, modifiers); + const int msg = kmap.Find(key, modifiers); if (msg) { if (consumed) *consumed = true; @@ -3790,30 +3945,27 @@ int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) { } } -int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) { - return KeyDownWithModifiers(key, ModifierFlags(shift, ctrl, alt), consumed); -} - void Editor::Indent(bool forwards) { UndoGroup ug(pdoc); for (size_t r=0; rLineFromPosition(sel.Range(r).anchor.Position()); - int caretPosition = sel.Range(r).caret.Position(); - int lineCurrentPos = pdoc->LineFromPosition(caretPosition); + const Sci::Line lineOfAnchor = + pdoc->SciLineFromPosition(sel.Range(r).anchor.Position()); + Sci::Position caretPosition = sel.Range(r).caret.Position(); + const Sci::Line lineCurrentPos = pdoc->SciLineFromPosition(caretPosition); if (lineOfAnchor == lineCurrentPos) { if (forwards) { pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); caretPosition = sel.Range(r).caret.Position(); if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) && pdoc->tabIndents) { - int indentation = pdoc->GetLineIndentation(lineCurrentPos); - int indentationStep = pdoc->IndentSize(); - const int posSelect = pdoc->SetLineIndentation( + const int indentation = pdoc->GetLineIndentation(lineCurrentPos); + const int indentationStep = pdoc->IndentSize(); + const Sci::Position posSelect = pdoc->SetLineIndentation( lineCurrentPos, indentation + indentationStep - indentation % indentationStep); sel.Range(r) = SelectionRange(posSelect); } else { if (pdoc->useTabs) { - const int lengthInserted = pdoc->InsertString(caretPosition, "\t", 1); + const Sci::Position lengthInserted = pdoc->InsertString(caretPosition, "\t", 1); sel.Range(r) = SelectionRange(caretPosition + lengthInserted); } else { int numSpaces = (pdoc->tabInChars) - @@ -3821,48 +3973,54 @@ void Editor::Indent(bool forwards) { if (numSpaces < 1) numSpaces = pdoc->tabInChars; const std::string spaceText(numSpaces, ' '); - const int lengthInserted = pdoc->InsertString(caretPosition, spaceText.c_str(), - static_cast(spaceText.length())); + const Sci::Position lengthInserted = pdoc->InsertString(caretPosition, spaceText.c_str(), + spaceText.length()); sel.Range(r) = SelectionRange(caretPosition + lengthInserted); } } } else { if (pdoc->GetColumn(caretPosition) <= pdoc->GetLineIndentation(lineCurrentPos) && pdoc->tabIndents) { - int indentation = pdoc->GetLineIndentation(lineCurrentPos); - int indentationStep = pdoc->IndentSize(); - const int posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); + const int indentation = pdoc->GetLineIndentation(lineCurrentPos); + const int indentationStep = pdoc->IndentSize(); + const Sci::Position posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); sel.Range(r) = SelectionRange(posSelect); } else { - int newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) * + Sci::Position newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) * pdoc->tabInChars; if (newColumn < 0) newColumn = 0; - int newPos = caretPosition; + Sci::Position newPos = caretPosition; while (pdoc->GetColumn(newPos) > newColumn) newPos--; sel.Range(r) = SelectionRange(newPos); } } } else { // Multiline - int anchorPosOnLine = sel.Range(r).anchor.Position() - pdoc->LineStart(lineOfAnchor); - int currentPosPosOnLine = caretPosition - pdoc->LineStart(lineCurrentPos); + const Sci::Position anchorPosOnLine = sel.Range(r).anchor.Position() - + pdoc->LineStart(lineOfAnchor); + const Sci::Position currentPosPosOnLine = caretPosition - + pdoc->LineStart(lineCurrentPos); // Multiple lines selected so indent / dedent - int lineTopSel = Platform::Minimum(lineOfAnchor, lineCurrentPos); - int lineBottomSel = Platform::Maximum(lineOfAnchor, lineCurrentPos); + const Sci::Line lineTopSel = std::min(lineOfAnchor, lineCurrentPos); + Sci::Line lineBottomSel = std::max(lineOfAnchor, lineCurrentPos); if (pdoc->LineStart(lineBottomSel) == sel.Range(r).anchor.Position() || pdoc->LineStart(lineBottomSel) == caretPosition) lineBottomSel--; // If not selecting any characters on a line, do not indent pdoc->Indent(forwards, lineBottomSel, lineTopSel); if (lineOfAnchor < lineCurrentPos) { if (currentPosPosOnLine == 0) - sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); + sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), + pdoc->LineStart(lineOfAnchor)); else - sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos + 1), pdoc->LineStart(lineOfAnchor)); + sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos + 1), + pdoc->LineStart(lineOfAnchor)); } else { if (anchorPosOnLine == 0) - sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); + sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), + pdoc->LineStart(lineOfAnchor)); else - sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor + 1)); + sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), + pdoc->LineStart(lineOfAnchor + 1)); } } } @@ -3871,11 +4029,9 @@ void Editor::Indent(bool forwards) { class CaseFolderASCII : public CaseFolderTable { public: - CaseFolderASCII() { + CaseFolderASCII() noexcept { StandardASCII(); } - ~CaseFolderASCII() { - } }; @@ -3888,30 +4044,30 @@ CaseFolder *Editor::CaseFolderForEncoding() { * Search of a text in the document, in the given range. * @return The position of the found text, -1 if not found. */ -long Editor::FindText( +Sci::Position 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. + sptr_t lParam) { ///< @c Sci_TextToFind structure: The text to search for in the given range. - Sci_TextToFind *ft = reinterpret_cast(lParam); - int lengthFound = istrlen(ft->lpstrText); + Sci_TextToFind *ft = static_cast(PtrFromSPtr(lParam)); + Sci::Position lengthFound = strlen(ft->lpstrText); if (!pdoc->HasCaseFolder()) pdoc->SetCaseFolder(CaseFolderForEncoding()); -#ifdef CXX11_REGEX +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) try { #endif - long pos = pdoc->FindText( - static_cast(ft->chrg.cpMin), - static_cast(ft->chrg.cpMax), + const Sci::Position pos = pdoc->FindText( + static_cast(ft->chrg.cpMin), + static_cast(ft->chrg.cpMax), ft->lpstrText, static_cast(wParam), &lengthFound); if (pos != -1) { - ft->chrgText.cpMin = pos; - ft->chrgText.cpMax = pos + lengthFound; + ft->chrgText.cpMin = static_cast(pos); + ft->chrgText.cpMax = static_cast(pos + lengthFound); } - return static_cast(pos); -#ifdef CXX11_REGEX + return pos; +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) } catch (RegexError &) { errorStatus = SC_STATUS_WARN_REGEX; return -1; @@ -3939,18 +4095,18 @@ void Editor::SearchAnchor() { * Used for next text and previous text requests. * @return The position of the found text, -1 if not found. */ -long Editor::SearchText( +Sci::Position 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. sptr_t lParam) { ///< The text to search for. - const char *txt = reinterpret_cast(lParam); - long pos; - int lengthFound = istrlen(txt); + const char *txt = CharPtrFromSPtr(lParam); + Sci::Position pos = INVALID_POSITION; + Sci::Position lengthFound = strlen(txt); if (!pdoc->HasCaseFolder()) pdoc->SetCaseFolder(CaseFolderForEncoding()); -#ifdef CXX11_REGEX +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) try { #endif if (iMessage == SCI_SEARCHNEXT) { @@ -3962,14 +4118,14 @@ long Editor::SearchText( static_cast(wParam), &lengthFound); } -#ifdef CXX11_REGEX +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) } catch (RegexError &) { errorStatus = SC_STATUS_WARN_REGEX; - return -1; + return INVALID_POSITION; } #endif - if (pos != -1) { - SetSelection(static_cast(pos), static_cast(pos + lengthFound)); + if (pos != INVALID_POSITION) { + SetSelection(pos, pos + lengthFound); } return pos; @@ -3977,15 +4133,13 @@ long Editor::SearchText( std::string Editor::CaseMapString(const std::string &s, int caseMapping) { std::string ret(s); - for (size_t i=0; i= 'a' && ret[i] <= 'z') - ret[i] = static_cast(ret[i] - 'a' + 'A'); + ch = MakeUpperCase(ch); break; case cmLower: - if (ret[i] >= 'A' && ret[i] <= 'Z') - ret[i] = static_cast(ret[i] - 'A' + 'a'); + ch = MakeLowerCase(ch); break; } } @@ -3996,23 +4150,23 @@ std::string Editor::CaseMapString(const std::string &s, int caseMapping) { * Search for text in the target range of the document. * @return The position of the found text, -1 if not found. */ -long Editor::SearchInTarget(const char *text, int length) { - int lengthFound = length; +Sci::Position Editor::SearchInTarget(const char *text, Sci::Position length) { + Sci::Position lengthFound = length; if (!pdoc->HasCaseFolder()) pdoc->SetCaseFolder(CaseFolderForEncoding()); -#ifdef CXX11_REGEX +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) try { #endif - long pos = pdoc->FindText(targetStart, targetEnd, text, + const Sci::Position pos = pdoc->FindText(targetStart, targetEnd, text, searchFlags, &lengthFound); if (pos != -1) { - targetStart = static_cast(pos); - targetEnd = static_cast(pos + lengthFound); + targetStart = pos; + targetEnd = pos + lengthFound; } return pos; -#ifdef CXX11_REGEX +#if defined(__EXCEPTIONS) || defined(_CPPUNWIND) } catch (RegexError &) { errorStatus = SC_STATUS_WARN_REGEX; return -1; @@ -4020,7 +4174,7 @@ long Editor::SearchInTarget(const char *text, int length) { #endif } -void Editor::GoToLine(int lineNo) { +void Editor::GoToLine(Sci::Line lineNo) { if (lineNo > pdoc->LinesTotal()) lineNo = pdoc->LinesTotal(); if (lineNo < 0) @@ -4030,21 +4184,20 @@ void Editor::GoToLine(int lineNo) { EnsureCaretVisible(); } -static bool Close(Point pt1, Point pt2, Point threshold) { - if (std::abs(pt1.x - pt2.x) > threshold.x) +static bool Close(Point pt1, Point pt2, Point threshold) noexcept { + const Point ptDifference = pt2 - pt1; + if (std::abs(ptDifference.x) > threshold.x) return false; - if (std::abs(pt1.y - pt2.y) > threshold.y) + if (std::abs(ptDifference.y) > threshold.y) return false; return true; } -std::string Editor::RangeText(int start, int end) const { +std::string Editor::RangeText(Sci::Position start, Sci::Position end) const { if (start < end) { - int len = end - start; + const Sci::Position len = end - start; std::string ret(len, '\0'); - for (int i = 0; i < len; i++) { - ret[i] = pdoc->CharAt(start + i); - } + pdoc->GetCharRange(const_cast(ret.data()), start, len); return ret; } return std::string(); @@ -4053,9 +4206,9 @@ std::string Editor::RangeText(int start, int end) const { void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) { if (sel.Empty()) { if (allowLineCopy) { - int currentLine = pdoc->LineFromPosition(sel.MainCaret()); - int start = pdoc->LineStart(currentLine); - int end = pdoc->LineEnd(currentLine); + const Sci::Line currentLine = pdoc->SciLineFromPosition(sel.MainCaret()); + const Sci::Position start = pdoc->LineStart(currentLine); + const Sci::Position end = pdoc->LineEnd(currentLine); std::string text = RangeText(start, end); if (pdoc->eolMode != SC_EOL_LF) @@ -4070,9 +4223,8 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) { std::vector rangesInOrder = sel.RangesCopy(); if (sel.selType == Selection::selRectangle) std::sort(rangesInOrder.begin(), rangesInOrder.end()); - for (size_t r=0; reolMode != SC_EOL_LF) text.push_back('\r'); @@ -4085,7 +4237,7 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) { } } -void Editor::CopyRangeToClipboard(int start, int end) { +void Editor::CopyRangeToClipboard(Sci::Position start, Sci::Position end) { start = pdoc->ClampPositionIntoDocument(start); end = pdoc->ClampPositionIntoDocument(end); SelectionText selectedText; @@ -4095,7 +4247,7 @@ void Editor::CopyRangeToClipboard(int start, int end) { CopyToClipboard(selectedText); } -void Editor::CopyText(int length, const char *text) { +void Editor::CopyText(size_t length, const char *text) { SelectionText selectedText; selectedText.Copy(std::string(text, length), pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false); @@ -4109,13 +4261,9 @@ void Editor::SetDragPosition(SelectionPosition newPos) { } if (!(posDrag == newPos)) { caret.on = true; - if (FineTickerAvailable()) { - FineTickerCancel(tickCaret); - if ((caret.active) && (caret.period > 0) && (newPos.Position() < 0)) - FineTickerStart(tickCaret, caret.period, caret.period/10); - } else { - SetTicking(true); - } + FineTickerCancel(tickCaret); + if ((caret.active) && (caret.period > 0) && (newPos.Position() < 0)) + FineTickerStart(tickCaret, caret.period, caret.period/10); InvalidateCaret(); posDrag = newPos; InvalidateCaret(); @@ -4130,10 +4278,9 @@ void Editor::DisplayCursor(Window::Cursor c) { } bool Editor::DragThreshold(Point ptStart, Point ptNow) { - int xMove = static_cast(ptStart.x - ptNow.x); - int yMove = static_cast(ptStart.y - ptNow.y); - int distanceSquared = xMove * xMove + yMove * yMove; - return distanceSquared > 16; + const Point ptDiff = ptStart - ptNow; + const XYPOSITION distanceSquared = ptDiff.x * ptDiff.x + ptDiff.y * ptDiff.y; + return distanceSquared > 16.0f; } void Editor::StartDrag() { @@ -4147,16 +4294,16 @@ void Editor::DropAt(SelectionPosition position, const char *value, size_t length if (inDragDrop == ddDragging) dropWentOutside = false; - bool positionWasInSelection = PositionInSelection(position.Position()); + const bool positionWasInSelection = PositionInSelection(position.Position()); - bool positionOnEdgeOfSelection = + const bool positionOnEdgeOfSelection = (position == SelectionStart()) || (position == SelectionEnd()); if ((inDragDrop != ddDragging) || !(positionWasInSelection) || (positionOnEdgeOfSelection && !moving)) { - SelectionPosition selStart = SelectionStart(); - SelectionPosition selEnd = SelectionEnd(); + const SelectionPosition selStart = SelectionStart(); + const SelectionPosition selEnd = SelectionEnd(); UndoGroup ug(pdoc); @@ -4185,14 +4332,14 @@ void Editor::DropAt(SelectionPosition position, const char *value, size_t length std::string convertedText = Document::TransformLineEnds(value, lengthValue, pdoc->eolMode); if (rectangular) { - PasteRectangular(position, convertedText.c_str(), static_cast(convertedText.length())); + PasteRectangular(position, convertedText.c_str(), convertedText.length()); // Should try to select new rectangle but it may not be a rectangle now so just select the drop position SetEmptySelection(position); } else { position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position()); - position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace())); - const int lengthInserted = pdoc->InsertString( - position.Position(), convertedText.c_str(), static_cast(convertedText.length())); + position = RealizeVirtualSpace(position); + const Sci::Position lengthInserted = pdoc->InsertString( + position.Position(), convertedText.c_str(), convertedText.length()); if (lengthInserted > 0) { SelectionPosition posAfterInsertion = position; posAfterInsertion.Add(lengthInserted); @@ -4211,7 +4358,7 @@ void Editor::DropAt(SelectionPosition position, const char *value, bool moving, /** * @return true if given position is inside the selection, */ -bool Editor::PositionInSelection(int pos) { +bool Editor::PositionInSelection(Sci::Position pos) { pos = MovePositionOutsideChar(pos, sel.MainCaret() - pos); for (size_t r=0; r(vs.textStart - vs.leftMarginWidth); rcSelMargin.left = static_cast(vs.textStart - vs.fixedColumnWidth); + const Point ptOrigin = GetVisibleOriginInMain(); + rcSelMargin.Move(0, -ptOrigin.y); return rcSelMargin.ContainsWholePixel(pt); } else { return false; } } -Window::Cursor Editor::GetMarginCursor(Point pt) const { +Window::Cursor Editor::GetMarginCursor(Point pt) const noexcept { int x = 0; - for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) { - if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width)) - return static_cast(vs.ms[margin].cursor); - x += vs.ms[margin].width; + for (const MarginStyle &m : vs.ms) { + if ((pt.x >= x) && (pt.x < x + m.width)) + return static_cast(m.cursor); + x += m.width; } return Window::cursorReverseArrow; } -void Editor::TrimAndSetSelection(int currentPos_, int anchor_) { +void Editor::TrimAndSetSelection(Sci::Position currentPos_, Sci::Position anchor_) { sel.TrimSelection(SelectionRange(currentPos_, anchor_)); SetSelection(currentPos_, anchor_); } -void Editor::LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine) { - int selCurrentPos, selAnchorPos; +void Editor::LineSelection(Sci::Position lineCurrentPos_, Sci::Position lineAnchorPos_, bool wholeLine) { + Sci::Position selCurrentPos, selAnchorPos; if (wholeLine) { - int lineCurrent_ = pdoc->LineFromPosition(lineCurrentPos_); - int lineAnchor_ = pdoc->LineFromPosition(lineAnchorPos_); + const Sci::Line lineCurrent_ = pdoc->SciLineFromPosition(lineCurrentPos_); + const Sci::Line lineAnchor_ = pdoc->SciLineFromPosition(lineAnchorPos_); if (lineAnchorPos_ < lineCurrentPos_) { selCurrentPos = pdoc->LineStart(lineCurrent_ + 1); selAnchorPos = pdoc->LineStart(lineAnchor_); @@ -4306,7 +4455,7 @@ void Editor::LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLi TrimAndSetSelection(selCurrentPos, selAnchorPos); } -void Editor::WordSelection(int pos) { +void Editor::WordSelection(Sci::Position pos) { if (pos < wordSelectAnchorStartPos) { // Extend backward to the word containing pos. // Skip ExtendWordSelect if the line is empty or if pos is after the last character. @@ -4339,23 +4488,18 @@ void Editor::DwellEnd(bool mouseMoved) { dwelling = false; NotifyDwelling(ptMouseLast, dwelling); } - if (FineTickerAvailable()) { - FineTickerCancel(tickDwell); - if (mouseMoved && (dwellDelay < SC_TIME_FOREVER)) { - //FineTickerStart(tickDwell, dwellDelay, dwellDelay/10); - } - } + FineTickerCancel(tickDwell); } void Editor::MouseLeave() { - SetHotSpotRange(NULL); + SetHotSpotRange(nullptr); if (!HaveMouseCapture()) { - ptMouseLast = Point(-1,-1); + ptMouseLast = Point(-1, -1); DwellEnd(true); } } -static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) { +static constexpr bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) noexcept { return (!rectangular && ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0)) || (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0)); } @@ -4379,7 +4523,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie NotifyIndicatorClick(true, newPos.Position(), modifiers); - bool inSelMargin = PointInSelMargin(pt); + const bool inSelMargin = PointInSelMargin(pt); // In margin ctrl+(double)click should always select everything if (ctrl && inSelMargin) { SelectAll(); @@ -4390,50 +4534,45 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie if (shift && !inSelMargin) { SetSelection(newPos); } - if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick, doubleClickCloseThreshold)) { + if ((curTime < (lastClickTime+Platform::DoubleClickTime())) && Close(pt, lastClick, doubleClickCloseThreshold)) { //Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime); SetMouseCapture(true); - if (FineTickerAvailable()) { - FineTickerStart(tickScroll, 100, 10); - } + FineTickerStart(tickScroll, 100, 10); if (!ctrl || !multipleSelection || (selectionType != selChar && selectionType != selWord)) SetEmptySelection(newPos.Position()); bool doubleClick = false; - // Stop mouse button bounce changing selection type - if (!Platform::MouseButtonBounce() || curTime != lastClickTime) { - if (inSelMargin) { - // Inside margin selection type should be either selSubLine or selWholeLine. - if (selectionType == selSubLine) { - // If it is selSubLine, we're inside a *double* click and word wrap is enabled, - // so we switch to selWholeLine in order to select whole line. - selectionType = selWholeLine; - } else if (selectionType != selSubLine && selectionType != selWholeLine) { - // If it is neither, reset selection type to line selection. - selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; - } + if (inSelMargin) { + // Inside margin selection type should be either selSubLine or selWholeLine. + if (selectionType == selSubLine) { + // If it is selSubLine, we're inside a *double* click and word wrap is enabled, + // so we switch to selWholeLine in order to select whole line. + selectionType = selWholeLine; + } else if (selectionType != selSubLine && selectionType != selWholeLine) { + // If it is neither, reset selection type to line selection. + selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; + } + } else { + if (selectionType == selChar) { + selectionType = selWord; + doubleClick = true; + } else if (selectionType == selWord) { + // Since we ended up here, we're inside a *triple* click, which should always select + // whole line regardless of word wrap being enabled or not. + selectionType = selWholeLine; } else { - if (selectionType == selChar) { - selectionType = selWord; - doubleClick = true; - } else if (selectionType == selWord) { - // Since we ended up here, we're inside a *triple* click, which should always select - // whole line regardless of word wrap being enabled or not. - selectionType = selWholeLine; - } else { - selectionType = selChar; - originalAnchorPos = sel.MainCaret(); - } + selectionType = selChar; + originalAnchorPos = sel.MainCaret(); } } if (selectionType == selWord) { - int charPos = originalAnchorPos; + Sci::Position charPos = originalAnchorPos; if (sel.MainCaret() == originalAnchorPos) { charPos = PositionFromLocation(pt, false, true); charPos = MovePositionOutsideChar(charPos, -1); } - int startWord, endWord; + Sci::Position startWord, endWord; if ((sel.MainCaret() >= originalAnchorPos) && !pdoc->IsLineEndPosition(charPos)) { startWord = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(charPos + 1, 1), -1); endWord = pdoc->ExtendWordSelect(charPos, 1); @@ -4469,6 +4608,10 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie } } else { // Single click if (inSelMargin) { + if (sel.IsRectangular() || (sel.Count() > 1)) { + InvalidateWholeSelection(); + sel.Clear(); + } sel.selType = Selection::selStream; if (!shift) { // Single click in margin: select whole line or only subline if word wrap is enabled @@ -4490,11 +4633,9 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie LineSelection(newPos.Position(), lineAnchorPos, selectionType == selWholeLine); } - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); SetMouseCapture(true); - if (FineTickerAvailable()) { - FineTickerStart(tickScroll, 100, 10); - } + FineTickerStart(tickScroll, 100, 10); } else { if (PointIsHotspot(pt)) { NotifyHotSpotClicked(newCharPos.Position(), modifiers); @@ -4507,14 +4648,12 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie inDragDrop = ddNone; } SetMouseCapture(true); - if (FineTickerAvailable()) { - FineTickerStart(tickScroll, 100, 10); - } + FineTickerStart(tickScroll, 100, 10); if (inDragDrop != ddInitial) { - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); if (!shift) { if (ctrl && multipleSelection) { - SelectionRange range(newPos); + const SelectionRange range(newPos); sel.TentativeSelection(range); InvalidateSelection(range, true); } else { @@ -4545,54 +4684,52 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie ShowCaretAtCurrentPosition(); } -void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { - return ButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt)); +void Editor::RightButtonDownWithModifiers(Point pt, unsigned int, int modifiers) { + if (NotifyMarginRightClick(pt, modifiers)) + return; } -bool Editor::PositionIsHotspot(int position) const { - return vs.styles[static_cast(pdoc->StyleAt(position))].hotspot; +bool Editor::PositionIsHotspot(Sci::Position position) const { + return vs.styles[pdoc->StyleIndexAt(position)].hotspot; } bool Editor::PointIsHotspot(Point pt) { - int pos = PositionFromLocation(pt, true, true); + const Sci::Position pos = PositionFromLocation(pt, true, true); if (pos == INVALID_POSITION) return false; return PositionIsHotspot(pos); } -void Editor::SetHoverIndicatorPosition(int position) { - int hoverIndicatorPosPrev = hoverIndicatorPos; +void Editor::SetHoverIndicatorPosition(Sci::Position position) { + const Sci::Position hoverIndicatorPosPrev = hoverIndicatorPos; hoverIndicatorPos = INVALID_POSITION; - if (vs.indicatorsDynamic == 0) + if (!vs.indicatorsDynamic) return; if (position != INVALID_POSITION) { - for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) { - if (vs.indicators[deco->indicator].IsDynamic()) { - if (pdoc->decorations.ValueAt(deco->indicator, position)) { + for (const IDecoration *deco : pdoc->decorations->View()) { + if (vs.indicators[deco->Indicator()].IsDynamic()) { + if (pdoc->decorations->ValueAt(deco->Indicator(), position)) { hoverIndicatorPos = position; } } } } if (hoverIndicatorPosPrev != hoverIndicatorPos) { - if (hoverIndicatorPosPrev != INVALID_POSITION) - InvalidateRange(hoverIndicatorPosPrev, hoverIndicatorPosPrev + 1); - if (hoverIndicatorPos != INVALID_POSITION) - InvalidateRange(hoverIndicatorPos, hoverIndicatorPos + 1); + Redraw(); } } void Editor::SetHoverIndicatorPoint(Point pt) { - if (vs.indicatorsDynamic == 0) { + if (!vs.indicatorsDynamic) { SetHoverIndicatorPosition(INVALID_POSITION); } else { SetHoverIndicatorPosition(PositionFromLocation(pt, true, true)); } } -void Editor::SetHotSpotRange(Point *pt) { +void Editor::SetHotSpotRange(const Point *pt) { if (pt) { - int pos = PositionFromLocation(*pt, false, true); + const Sci::Position pos = PositionFromLocation(*pt, false, true); // If we don't limit this to word characters then the // range can encompass more than the run range and then @@ -4613,16 +4750,16 @@ void Editor::SetHotSpotRange(Point *pt) { if (hotspot.Valid()) { InvalidateRange(hotspot.start, hotspot.end); } - hotspot = Range(invalidPosition); + hotspot = Range(Sci::invalidPosition); } } -Range Editor::GetHotSpotRange() const { +Range Editor::GetHotSpotRange() const noexcept { return hotspot; } -void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { - if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) { +void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) { + if (ptMouseLast != pt) { DwellEnd(true); } @@ -4633,9 +4770,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { if (inDragDrop == ddInitial) { if (DragThreshold(ptMouseLast, pt)) { SetMouseCapture(false); - if (FineTickerAvailable()) { - FineTickerCancel(tickScroll); - } + FineTickerCancel(tickScroll); SetDragPosition(movePos); CopySelectionRange(&drag); StartDrag(); @@ -4645,9 +4780,9 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { ptMouseLast = pt; PRectangle rcClient = GetClientRectangle(); - Point ptOrigin = GetVisibleOriginInMain(); + const Point ptOrigin = GetVisibleOriginInMain(); rcClient.Move(0, -ptOrigin.y); - if (FineTickerAvailable() && (dwellDelay < SC_TIME_FOREVER) && rcClient.Contains(pt)) { + if ((dwellDelay < SC_TIME_FOREVER) && rcClient.Contains(pt)) { FineTickerStart(tickDwell, dwellDelay, dwellDelay/10); } //Platform::DebugPrintf("Move %d %d\n", pt.x, pt.y); @@ -4672,7 +4807,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { SetSelection(movePos, sel.RangeMain().anchor); } else if (sel.Count() > 1) { InvalidateSelection(sel.RangeMain(), false); - SelectionRange range(movePos, sel.RangeMain().anchor); + const SelectionRange range(movePos, sel.RangeMain().anchor); sel.TentativeSelection(range); InvalidateSelection(range, true); } else { @@ -4687,7 +4822,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { // the selection for a fancier definition of "word" (for // example, in Perl it is useful to include the leading // '$', '%' or '@' on variables for word selection). In this - // the ButtonMove() called via Tick() for auto-scrolling + // the ButtonMove() called via TickFor() for auto-scrolling // could result in the fancier word selection adjustment // being unmade. } else { @@ -4701,7 +4836,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { } // Autoscroll - int lineMove = DisplayFromPosition(movePos.Position()); + const Sci::Line lineMove = DisplayFromPosition(movePos.Position()); if (pt.y > rcClient.bottom) { ScrollTo(lineMove - LinesOnScreen() + 1); Redraw(); @@ -4712,9 +4847,9 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { EnsureCaretVisible(false, false, true); if (hotspot.Valid() && !PointIsHotspot(pt)) - SetHotSpotRange(NULL); + SetHotSpotRange(nullptr); - if (hotSpotClickPos != INVALID_POSITION && PositionFromLocation(pt,true,true) != hotSpotClickPos) { + if (hotSpotClickPos != INVALID_POSITION && PositionFromLocation(pt, true, true) != hotSpotClickPos) { if (inDragDrop == ddNone) { DisplayCursor(Window::cursorText); } @@ -4725,7 +4860,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { if (vs.fixedColumnWidth > 0) { // There is a margin if (PointInSelMargin(pt)) { DisplayCursor(GetMarginCursor(pt)); - SetHotSpotRange(NULL); + SetHotSpotRange(nullptr); return; // No need to test for selection } } @@ -4738,21 +4873,17 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { DisplayCursor(Window::cursorHand); SetHotSpotRange(&pt); } else { - if (hoverIndicatorPos != invalidPosition) + if (hoverIndicatorPos != Sci::invalidPosition) DisplayCursor(Window::cursorHand); else DisplayCursor(Window::cursorText); - SetHotSpotRange(NULL); + SetHotSpotRange(nullptr); } } } } -void Editor::ButtonMove(Point pt) { - ButtonMoveWithModifiers(pt, 0); -} - -void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { +void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers) { //Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop); SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); @@ -4769,44 +4900,42 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { hotSpotClickPos = INVALID_POSITION; SelectionPosition newCharPos = SPositionFromLocation(pt, false, true, false); newCharPos = MovePositionOutsideChar(newCharPos, -1); - NotifyHotSpotReleaseClick(newCharPos.Position(), ctrl ? SCI_CTRL : 0); + NotifyHotSpotReleaseClick(newCharPos.Position(), modifiers & SCI_CTRL); } if (HaveMouseCapture()) { if (PointInSelMargin(pt)) { DisplayCursor(GetMarginCursor(pt)); } else { DisplayCursor(Window::cursorText); - SetHotSpotRange(NULL); + SetHotSpotRange(nullptr); } ptMouseLast = pt; SetMouseCapture(false); - if (FineTickerAvailable()) { - FineTickerCancel(tickScroll); - } + FineTickerCancel(tickScroll); NotifyIndicatorClick(false, newPos.Position(), 0); if (inDragDrop == ddDragging) { - SelectionPosition selStart = SelectionStart(); - SelectionPosition selEnd = SelectionEnd(); + const SelectionPosition selStart = SelectionStart(); + const SelectionPosition selEnd = SelectionEnd(); if (selStart < selEnd) { if (drag.Length()) { - const int length = static_cast(drag.Length()); - if (ctrl) { - const int lengthInserted = pdoc->InsertString( + const Sci::Position length = drag.Length(); + if (modifiers & SCI_CTRL) { + const Sci::Position lengthInserted = pdoc->InsertString( newPos.Position(), drag.Data(), length); if (lengthInserted > 0) { SetSelection(newPos.Position(), newPos.Position() + lengthInserted); } } else if (newPos < selStart) { - pdoc->DeleteChars(selStart.Position(), static_cast(drag.Length())); - const int lengthInserted = pdoc->InsertString( + pdoc->DeleteChars(selStart.Position(), drag.Length()); + const Sci::Position lengthInserted = pdoc->InsertString( newPos.Position(), drag.Data(), length); if (lengthInserted > 0) { SetSelection(newPos.Position(), newPos.Position() + lengthInserted); } } else if (newPos > selEnd) { - pdoc->DeleteChars(selStart.Position(), static_cast(drag.Length())); - newPos.Add(-static_cast(drag.Length())); - const int lengthInserted = pdoc->InsertString( + pdoc->DeleteChars(selStart.Position(), drag.Length()); + newPos.Add(-static_cast(drag.Length())); + const Sci::Position lengthInserted = pdoc->InsertString( newPos.Position(), drag.Data(), length); if (lengthInserted > 0) { SetSelection(newPos.Position(), newPos.Position() + lengthInserted); @@ -4842,51 +4971,18 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { } } -// Called frequently to perform background UI including -// caret blinking and automatic scrolling. -void Editor::Tick() { - if (HaveMouseCapture()) { - // Auto scroll - ButtonMove(ptMouseLast); - } - if (caret.period > 0) { - timer.ticksToWait -= timer.tickSize; - if (timer.ticksToWait <= 0) { - caret.on = !caret.on; - timer.ticksToWait = caret.period; - if (caret.active) { - InvalidateCaret(); - } - } - } - if (horizontalScrollBarVisible && trackLineWidth && (view.lineWidthMaxSeen > scrollWidth)) { - scrollWidth = view.lineWidthMaxSeen; - SetScrollBars(); - } - if ((dwellDelay < SC_TIME_FOREVER) && - (ticksToDwell > 0) && - (!HaveMouseCapture()) && - (ptMouseLast.y >= 0)) { - ticksToDwell -= timer.tickSize; - if (ticksToDwell <= 0) { - dwelling = true; - NotifyDwelling(ptMouseLast, dwelling); - } - } -} - bool Editor::Idle() { + NotifyUpdateUI(); - bool idleDone; + bool needWrap = Wrapping() && wrapPending.NeedsWrap(); - bool wrappingDone = !Wrapping(); - - if (!wrappingDone) { + if (needWrap) { // Wrap lines during idle. - WrapLines(wsIdle); + WrapLines(WrapScope::wsIdle); // No more wrapping - if (!wrapPending.NeedsWrap()) - wrappingDone = true; + needWrap = wrapPending.NeedsWrap(); + } else if (needIdleStyling) { + IdleStyling(); } // Add more idle things to do here, but make sure idleDone is @@ -4894,18 +4990,11 @@ bool Editor::Idle() { // false will stop calling this idle function until SetIdle() is // called again. - idleDone = wrappingDone; // && thatDone && theOtherThingDone... + const bool idleDone = !needWrap && !needIdleStyling; // && thatDone && theOtherThingDone... return !idleDone; } -void Editor::SetTicking(bool) { - // SetTicking is deprecated. In the past it was pure virtual and was overridden in each - // derived platform class but fine grained timers should now be implemented. - // Either way, execution should not arrive here so assert failure. - assert(false); -} - void Editor::TickFor(TickReason reason) { switch (reason) { case tickCaret: @@ -4916,7 +5005,7 @@ void Editor::TickFor(TickReason reason) { break; case tickScroll: // Auto scroll - ButtonMove(ptMouseLast); + ButtonMoveWithModifiers(ptMouseLast, 0, 0); break; case tickWiden: SetScrollBars(); @@ -4936,10 +5025,6 @@ void Editor::TickFor(TickReason reason) { } } -bool Editor::FineTickerAvailable() { - return false; -} - // FineTickerStart is be overridden by subclasses that support fine ticking so // this method should never be called. bool Editor::FineTickerRunning(TickReason) { @@ -4968,26 +5053,26 @@ void Editor::SetFocusState(bool focusState) { ShowCaretAtCurrentPosition(); } -int Editor::PositionAfterArea(PRectangle rcArea) const { +Sci::Position Editor::PositionAfterArea(PRectangle rcArea) const { // The start of the document line after the display line after the area // This often means that the line after a modification is restyled which helps // detect multiline comment additions and heals single line comments - int lineAfter = TopLineOfMain() + static_cast(rcArea.bottom - 1) / vs.lineHeight + 1; - if (lineAfter < cs.LinesDisplayed()) - return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1); + const Sci::Line lineAfter = TopLineOfMain() + static_cast(rcArea.bottom - 1) / vs.lineHeight + 1; + if (lineAfter < pcs->LinesDisplayed()) + return pdoc->LineStart(pcs->DocFromDisplay(lineAfter) + 1); else return pdoc->Length(); } // Style to a position within the view. If this causes a change at end of last line then // affects later lines so style all the viewed text. -void Editor::StyleToPositionInView(Position pos) { - int endWindow = PositionAfterArea(GetClientDrawingRectangle()); +void Editor::StyleToPositionInView(Sci::Position pos) { + Sci::Position endWindow = PositionAfterArea(GetClientDrawingRectangle()); if (pos > endWindow) pos = endWindow; - int styleAtEnd = pdoc->StyleAt(pos-1); + const int styleAtEnd = pdoc->StyleIndexAt(pos-1); pdoc->EnsureStyledTo(pos); - if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) { + if ((endWindow > pos) && (styleAtEnd != pdoc->StyleIndexAt(pos-1))) { // Style at end of line changed so is multi-line change like starting a comment // so require rest of window to be styled. DiscardOverdraw(); // Prepared bitmaps may be invalid @@ -4997,17 +5082,76 @@ void Editor::StyleToPositionInView(Position pos) { } } +Sci::Position Editor::PositionAfterMaxStyling(Sci::Position posMax, bool scrolling) const { + if (SynchronousStylingToVisible()) { + // Both states do not limit styling + return posMax; + } + + // Try to keep time taken by styling reasonable so interaction remains smooth. + // When scrolling, allow less time to ensure responsive + const double secondsAllowed = scrolling ? 0.005 : 0.02; + + const Sci::Line linesToStyle = Sci::clamp(static_cast(secondsAllowed / pdoc->durationStyleOneLine.Duration()), + 10, 0x10000); + const Sci::Line stylingMaxLine = std::min( + pdoc->SciLineFromPosition(pdoc->GetEndStyled()) + linesToStyle, + pdoc->LinesTotal()); + return std::min(pdoc->LineStart(stylingMaxLine), posMax); +} + +void Editor::StartIdleStyling(bool truncatedLastStyling) { + if ((idleStyling == SC_IDLESTYLING_ALL) || (idleStyling == SC_IDLESTYLING_AFTERVISIBLE)) { + if (pdoc->GetEndStyled() < pdoc->Length()) { + // Style remainder of document in idle time + needIdleStyling = true; + } + } else if (truncatedLastStyling) { + needIdleStyling = true; + } + + if (needIdleStyling) { + SetIdle(true); + } +} + +// Style for an area but bound the amount of styling to remain responsive +void Editor::StyleAreaBounded(PRectangle rcArea, bool scrolling) { + const Sci::Position posAfterArea = PositionAfterArea(rcArea); + const Sci::Position posAfterMax = PositionAfterMaxStyling(posAfterArea, scrolling); + if (posAfterMax < posAfterArea) { + // Idle styling may be performed before current visible area + // Style a bit now then style further in idle time + pdoc->StyleToAdjustingLineDuration(posAfterMax); + } else { + // Can style all wanted now. + StyleToPositionInView(posAfterArea); + } + StartIdleStyling(posAfterMax < posAfterArea); +} + +void Editor::IdleStyling() { + const Sci::Position posAfterArea = PositionAfterArea(GetClientRectangle()); + const Sci::Position endGoal = (idleStyling >= SC_IDLESTYLING_AFTERVISIBLE) ? + pdoc->Length() : posAfterArea; + const Sci::Position posAfterMax = PositionAfterMaxStyling(endGoal, false); + pdoc->StyleToAdjustingLineDuration(posAfterMax); + if (pdoc->GetEndStyled() >= endGoal) { + needIdleStyling = false; + } +} + void Editor::IdleWork() { // Style the line after the modification as this allows modifications that change just the // line of the modification to heal instead of propagating to the rest of the window. - if (workNeeded.items & WorkNeeded::workStyle) + if (workNeeded.items & WorkNeeded::workStyle) { StyleToPositionInView(pdoc->LineStart(pdoc->LineFromPosition(workNeeded.upTo) + 2)); - + } NotifyUpdateUI(); workNeeded.Reset(); } -void Editor::QueueIdleWork(WorkNeeded::workItems items, int upTo) { +void Editor::QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) { workNeeded.Need(items, upTo); } @@ -5037,7 +5181,7 @@ void Editor::CheckForChangeOutsidePaint(Range r) { return; PRectangle rcRange = RectangleFromRange(r, 0); - PRectangle rcText = GetTextRectangle(); + const PRectangle rcText = GetTextRectangle(); if (rcRange.top < rcText.top) { rcRange.top = rcText.top; } @@ -5052,7 +5196,7 @@ void Editor::CheckForChangeOutsidePaint(Range r) { } } -void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) { +void Editor::SetBraceHighlight(Sci::Position pos0, Sci::Position pos1, int matchStyle) { if ((pos0 != braces[0]) || (pos1 != braces[1]) || (matchStyle != bracesMatchStyle)) { if ((braces[0] != pos0) || (matchStyle != bracesMatchStyle)) { CheckForChangeOutsidePaint(Range(braces[0])); @@ -5071,11 +5215,11 @@ void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) { } } -void Editor::SetAnnotationHeights(int start, int end) { +void Editor::SetAnnotationHeights(Sci::Line start, Sci::Line end) { if (vs.annotationVisible) { RefreshStyleData(); bool changedHeight = false; - for (int line=start; lineLinesTotal(); line++) { + for (Sci::Line line=start; lineLinesTotal(); line++) { int linesWrapped = 1; if (Wrapping()) { AutoSurface surface(this); @@ -5085,7 +5229,7 @@ void Editor::SetAnnotationHeights(int start, int end) { linesWrapped = ll->lines; } } - if (cs.SetHeight(line, pdoc->AnnotationLines(line) + linesWrapped)) + if (pcs->SetHeight(line, pdoc->AnnotationLines(line) + linesWrapped)) changedHeight = true; } if (changedHeight) { @@ -5098,34 +5242,35 @@ void Editor::SetDocPointer(Document *document) { //Platform::DebugPrintf("** %x setdoc to %x\n", pdoc, document); pdoc->RemoveWatcher(this, 0); pdoc->Release(); - if (document == NULL) { - pdoc = new Document(); + if (!document) { + pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT); } else { pdoc = document; } pdoc->AddRef(); + pcs = ContractionStateCreate(pdoc->IsLarge()); // Ensure all positions within document sel.Clear(); targetStart = 0; targetEnd = 0; - braces[0] = invalidPosition; - braces[1] = invalidPosition; + braces[0] = Sci::invalidPosition; + braces[1] = Sci::invalidPosition; vs.ReleaseAllExtendedStyles(); SetRepresentations(); // Reset the contraction state to fully shown. - cs.Clear(); - cs.InsertLines(0, pdoc->LinesTotal() - 1); + pcs->Clear(); + pcs->InsertLines(0, pdoc->LinesTotal() - 1); SetAnnotationHeights(0, pdoc->LinesTotal()); view.llc.Deallocate(); NeedWrapping(); - hotspot = Range(invalidPosition); - hoverIndicatorPos = invalidPosition; + hotspot = Range(Sci::invalidPosition); + hoverIndicatorPos = Sci::invalidPosition; view.ClearAllTabstops(); @@ -5136,16 +5281,17 @@ void Editor::SetDocPointer(Document *document) { void Editor::SetAnnotationVisible(int visible) { if (vs.annotationVisible != visible) { - bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0)); + const bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0)); vs.annotationVisible = visible; if (changedFromOrToHidden) { - int dir = vs.annotationVisible ? 1 : -1; - for (int line=0; lineLinesTotal(); line++) { - int annotationLines = pdoc->AnnotationLines(line); + const int dir = vs.annotationVisible ? 1 : -1; + for (Sci::Line line=0; lineLinesTotal(); line++) { + const int annotationLines = pdoc->AnnotationLines(line); if (annotationLines > 0) { - cs.SetHeight(line, cs.GetHeight(line) + annotationLines * dir); + pcs->SetHeight(line, pcs->GetHeight(line) + annotationLines * dir); } } + SetScrollBars(); } Redraw(); } @@ -5154,14 +5300,14 @@ void Editor::SetAnnotationVisible(int visible) { /** * Recursively expand a fold, making lines visible except where they have an unexpanded parent. */ -int Editor::ExpandLine(int line) { - int lineMaxSubord = pdoc->GetLastChild(line); +Sci::Line Editor::ExpandLine(Sci::Line line) { + const Sci::Line lineMaxSubord = pdoc->GetLastChild(line); line++; while (line <= lineMaxSubord) { - cs.SetVisible(line, line, true); - int level = pdoc->GetLevel(line); + pcs->SetVisible(line, line, true); + const int level = pdoc->GetLevel(line); if (level & SC_FOLDLEVELHEADERFLAG) { - if (cs.GetExpanded(line)) { + if (pcs->GetExpanded(line)) { line = ExpandLine(line); } else { line = pdoc->GetLastChild(line); @@ -5172,13 +5318,13 @@ int Editor::ExpandLine(int line) { return lineMaxSubord; } -void Editor::SetFoldExpanded(int lineDoc, bool expanded) { - if (cs.SetExpanded(lineDoc, expanded)) { +void Editor::SetFoldExpanded(Sci::Line lineDoc, bool expanded) { + if (pcs->SetExpanded(lineDoc, expanded)) { RedrawSelMargin(); } } -void Editor::FoldLine(int line, int action) { +void Editor::FoldLine(Sci::Line line, int action) { if (line >= 0) { if (action == SC_FOLDACTION_TOGGLE) { if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) { @@ -5186,16 +5332,17 @@ void Editor::FoldLine(int line, int action) { if (line < 0) return; } - action = (cs.GetExpanded(line)) ? SC_FOLDACTION_CONTRACT : SC_FOLDACTION_EXPAND; + action = (pcs->GetExpanded(line)) ? SC_FOLDACTION_CONTRACT : SC_FOLDACTION_EXPAND; } if (action == SC_FOLDACTION_CONTRACT) { - int lineMaxSubord = pdoc->GetLastChild(line); + const Sci::Line lineMaxSubord = pdoc->GetLastChild(line); if (lineMaxSubord > line) { - cs.SetExpanded(line, 0); - cs.SetVisible(line + 1, lineMaxSubord, false); + pcs->SetExpanded(line, false); + pcs->SetVisible(line + 1, lineMaxSubord, false); - int lineCurrent = pdoc->LineFromPosition(sel.MainCaret()); + const Sci::Line lineCurrent = + pdoc->SciLineFromPosition(sel.MainCaret()); if (lineCurrent > line && lineCurrent <= lineMaxSubord) { // This does not re-expand the fold EnsureCaretVisible(); @@ -5203,11 +5350,11 @@ void Editor::FoldLine(int line, int action) { } } else { - if (!(cs.GetVisible(line))) { + if (!(pcs->GetVisible(line))) { EnsureLineVisible(line, false); GoToLine(line); } - cs.SetExpanded(line, 1); + pcs->SetExpanded(line, true); ExpandLine(line); } @@ -5216,20 +5363,23 @@ void Editor::FoldLine(int line, int action) { } } -void Editor::FoldExpand(int line, int action, int level) { +void Editor::FoldExpand(Sci::Line line, int action, int level) { bool expanding = action == SC_FOLDACTION_EXPAND; if (action == SC_FOLDACTION_TOGGLE) { - expanding = !cs.GetExpanded(line); + expanding = !pcs->GetExpanded(line); } + // Ensure child lines lexed and fold information extracted before + // flipping the state. + pdoc->GetLastChild(line, LevelNumber(level)); SetFoldExpanded(line, expanding); - if (expanding && (cs.HiddenLines() == 0)) + if (expanding && (pcs->HiddenLines() == 0)) // Nothing to do return; - int lineMaxSubord = pdoc->GetLastChild(line, level & SC_FOLDLEVELNUMBERMASK); + const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, LevelNumber(level)); line++; - cs.SetVisible(line, lineMaxSubord, expanding); + pcs->SetVisible(line, lineMaxSubord, expanding); while (line <= lineMaxSubord) { - int levelLine = pdoc->GetLevel(line); + const int levelLine = pdoc->GetLevel(line); if (levelLine & SC_FOLDLEVELHEADERFLAG) { SetFoldExpanded(line, expanding); } @@ -5239,11 +5389,11 @@ void Editor::FoldExpand(int line, int action, int level) { Redraw(); } -int Editor::ContractedFoldNext(int lineStart) const { - for (int line = lineStart; lineLinesTotal();) { - if (!cs.GetExpanded(line) && (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG)) +Sci::Line Editor::ContractedFoldNext(Sci::Line lineStart) const { + for (Sci::Line line = lineStart; lineLinesTotal();) { + if (!pcs->GetExpanded(line) && (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG)) return line; - line = cs.ContractedNext(line+1); + line = pcs->ContractedNext(line+1); if (line < 0) return -1; } @@ -5255,20 +5405,23 @@ int Editor::ContractedFoldNext(int lineStart) const { * Recurse up from this line to find any folds that prevent this line from being visible * and unfold them all. */ -void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { +void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) { // In case in need of wrapping to ensure DisplayFromDoc works. - if (lineDoc >= wrapPending.start) - WrapLines(wsAll); + if (lineDoc >= wrapPending.start) { + if (WrapLines(WrapScope::wsAll)) { + Redraw(); + } + } - if (!cs.GetVisible(lineDoc)) { + if (!pcs->GetVisible(lineDoc)) { // Back up to find a non-blank line - int lookLine = lineDoc; + Sci::Line lookLine = lineDoc; int lookLineLevel = pdoc->GetLevel(lookLine); while ((lookLine > 0) && (lookLineLevel & SC_FOLDLEVELWHITEFLAG)) { lookLineLevel = pdoc->GetLevel(--lookLine); } - int lineParent = pdoc->GetFoldParent(lookLine); + Sci::Line lineParent = pdoc->GetFoldParent(lookLine); if (lineParent < 0) { // Backed up to a top level line, so try to find parent of initial line lineParent = pdoc->GetFoldParent(lineDoc); @@ -5276,8 +5429,8 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { if (lineParent >= 0) { if (lineDoc != lineParent) EnsureLineVisible(lineParent, enforcePolicy); - if (!cs.GetExpanded(lineParent)) { - cs.SetExpanded(lineParent, 1); + if (!pcs->GetExpanded(lineParent)) { + pcs->SetExpanded(lineParent, true); ExpandLine(lineParent); } } @@ -5285,21 +5438,21 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { Redraw(); } if (enforcePolicy) { - int lineDisplay = cs.DisplayFromDoc(lineDoc); + const Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc); if (visiblePolicy & VISIBLE_SLOP) { if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) { - SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos())); + SetTopLine(Sci::clamp(lineDisplay - visibleSlop, static_cast(0), MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } else if ((lineDisplay > topLine + LinesOnScreen() - 1) || ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) { - SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos())); + SetTopLine(Sci::clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, static_cast(0), MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } } else { if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) { - SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos())); + SetTopLine(Sci::clamp(lineDisplay - LinesOnScreen() / 2 + 1, static_cast(0), MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } @@ -5309,34 +5462,34 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { void Editor::FoldAll(int action) { pdoc->EnsureStyledTo(pdoc->Length()); - int maxLine = pdoc->LinesTotal(); + const Sci::Line maxLine = pdoc->LinesTotal(); bool expanding = action == SC_FOLDACTION_EXPAND; if (action == SC_FOLDACTION_TOGGLE) { // Discover current state for (int lineSeek = 0; lineSeek < maxLine; lineSeek++) { if (pdoc->GetLevel(lineSeek) & SC_FOLDLEVELHEADERFLAG) { - expanding = !cs.GetExpanded(lineSeek); + expanding = !pcs->GetExpanded(lineSeek); break; } } } if (expanding) { - cs.SetVisible(0, maxLine-1, true); + pcs->SetVisible(0, maxLine-1, true); for (int line = 0; line < maxLine; line++) { - int levelLine = pdoc->GetLevel(line); + const int levelLine = pdoc->GetLevel(line); if (levelLine & SC_FOLDLEVELHEADERFLAG) { SetFoldExpanded(line, true); } } } else { - for (int line = 0; line < maxLine; line++) { - int level = pdoc->GetLevel(line); + for (Sci::Line line = 0; line < maxLine; line++) { + const int level = pdoc->GetLevel(line); if ((level & SC_FOLDLEVELHEADERFLAG) && - (SC_FOLDLEVELBASE == (level & SC_FOLDLEVELNUMBERMASK))) { + (SC_FOLDLEVELBASE == LevelNumber(level))) { SetFoldExpanded(line, false); - int lineMaxSubord = pdoc->GetLastChild(line, -1); + const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, -1); if (lineMaxSubord > line) { - cs.SetVisible(line + 1, lineMaxSubord, false); + pcs->SetVisible(line + 1, lineMaxSubord, false); } } } @@ -5345,44 +5498,61 @@ void Editor::FoldAll(int action) { Redraw(); } -void Editor::FoldChanged(int line, int levelNow, int levelPrev) { +void Editor::FoldChanged(Sci::Line line, int levelNow, int levelPrev) { if (levelNow & SC_FOLDLEVELHEADERFLAG) { if (!(levelPrev & SC_FOLDLEVELHEADERFLAG)) { // Adding a fold point. - if (cs.SetExpanded(line, true)) { + if (pcs->SetExpanded(line, true)) { RedrawSelMargin(); } FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev); } } else if (levelPrev & SC_FOLDLEVELHEADERFLAG) { - if (!cs.GetExpanded(line)) { + const Sci::Line prevLine = line - 1; + const int prevLineLevel = pdoc->GetLevel(prevLine); + + // Combining two blocks where the first block is collapsed (e.g. by deleting the line(s) which separate(s) the two blocks) + if ((LevelNumber(prevLineLevel) == LevelNumber(levelNow)) && !pcs->GetVisible(prevLine)) + FoldLine(pdoc->GetFoldParent(prevLine), SC_FOLDACTION_EXPAND); + + if (!pcs->GetExpanded(line)) { // Removing the fold from one that has been contracted so should expand // otherwise lines are left invisible with no way to make them visible - if (cs.SetExpanded(line, true)) { + if (pcs->SetExpanded(line, true)) { RedrawSelMargin(); } + // Combining two blocks where the second one is collapsed (e.g. by adding characters in the line which separates the two blocks) FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev); } } if (!(levelNow & SC_FOLDLEVELWHITEFLAG) && - ((levelPrev & SC_FOLDLEVELNUMBERMASK) > (levelNow & SC_FOLDLEVELNUMBERMASK))) { - if (cs.HiddenLines()) { + (LevelNumber(levelPrev) > LevelNumber(levelNow))) { + if (pcs->HiddenLines()) { // See if should still be hidden - int parentLine = pdoc->GetFoldParent(line); - if ((parentLine < 0) || (cs.GetExpanded(parentLine) && cs.GetVisible(parentLine))) { - cs.SetVisible(line, line, true); + const Sci::Line parentLine = pdoc->GetFoldParent(line); + if ((parentLine < 0) || (pcs->GetExpanded(parentLine) && pcs->GetVisible(parentLine))) { + pcs->SetVisible(line, line, true); SetScrollBars(); Redraw(); } } } + + // Combining two blocks where the first one is collapsed (e.g. by adding characters in the line which separates the two blocks) + if (!(levelNow & SC_FOLDLEVELWHITEFLAG) && (LevelNumber(levelPrev) < LevelNumber(levelNow))) { + if (pcs->HiddenLines()) { + const Sci::Line parentLine = pdoc->GetFoldParent(line); + if (!pcs->GetExpanded(parentLine) && pcs->GetVisible(line)) + FoldLine(parentLine, SC_FOLDACTION_EXPAND); + } + } } -void Editor::NeedShown(int pos, int len) { +void Editor::NeedShown(Sci::Position pos, Sci::Position len) { if (foldAutomatic & SC_AUTOMATICFOLD_SHOW) { - int lineStart = pdoc->LineFromPosition(pos); - int lineEnd = pdoc->LineFromPosition(pos+len); - for (int line = lineStart; line <= lineEnd; line++) { + const Sci::Line lineStart = pdoc->SciLineFromPosition(pos); + const Sci::Line lineEnd = pdoc->SciLineFromPosition(pos+len); + for (Sci::Line line = lineStart; line <= lineEnd; line++) { EnsureLineVisible(line, false); } } else { @@ -5390,9 +5560,9 @@ void Editor::NeedShown(int pos, int len) { } } -int Editor::GetTag(char *tagValue, int tagNumber) { - const char *text = 0; - int length = 0; +Sci::Position Editor::GetTag(char *tagValue, int tagNumber) { + const char *text = nullptr; + Sci::Position length = 0; if ((tagNumber >= 1) && (tagNumber <= 9)) { char name[3] = "\\?"; name[1] = static_cast(tagNumber + '0'); @@ -5408,10 +5578,10 @@ int Editor::GetTag(char *tagValue, int tagNumber) { return length; } -int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) { +Sci::Position Editor::ReplaceTarget(bool replacePatterns, const char *text, Sci::Position length) { UndoGroup ug(pdoc); if (length == -1) - length = istrlen(text); + length = strlen(text); if (replacePatterns) { text = pdoc->SubstituteByPosition(text, &length); if (!text) { @@ -5421,23 +5591,23 @@ int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) { if (targetStart != targetEnd) pdoc->DeleteChars(targetStart, targetEnd - targetStart); targetEnd = targetStart; - const int lengthInserted = pdoc->InsertString(targetStart, text, length); + const Sci::Position lengthInserted = pdoc->InsertString(targetStart, text, length); targetEnd = targetStart + lengthInserted; return length; } -bool Editor::IsUnicodeMode() const { +bool Editor::IsUnicodeMode() const noexcept { return pdoc && (SC_CP_UTF8 == pdoc->dbcsCodePage); } -int Editor::CodePage() const { +int Editor::CodePage() const noexcept { if (pdoc) return pdoc->dbcsCodePage; else return 0; } -int Editor::WrapCount(int line) { +Sci::Line Editor::WrapCount(Sci::Line line) { AutoSurface surface(this); AutoLineLayout ll(view.llc, view.RetrieveLineLayout(line, *this)); @@ -5449,15 +5619,15 @@ int Editor::WrapCount(int line) { } } -void Editor::AddStyledText(char *buffer, int appendLength) { +void Editor::AddStyledText(const char *buffer, Sci::Position appendLength) { // The buffer consists of alternating character bytes and style bytes - int textLength = appendLength / 2; + const Sci::Position textLength = appendLength / 2; std::string text(textLength, '\0'); - int i; + Sci::Position i; for (i = 0; i < textLength; i++) { text[i] = buffer[i*2]; } - const int lengthInserted = pdoc->InsertString(CurrentPosition(), text.c_str(), textLength); + const Sci::Position lengthInserted = pdoc->InsertString(CurrentPosition(), text.c_str(), textLength); for (i = 0; i < textLength; i++) { text[i] = buffer[i*2+1]; } @@ -5466,22 +5636,18 @@ void Editor::AddStyledText(char *buffer, int appendLength) { SetEmptySelection(sel.MainCaret() + lengthInserted); } -static bool ValidMargin(uptr_t wParam) { - return wParam <= SC_MAX_MARGIN; -} - -static char *CharPtrFromSPtr(sptr_t lParam) { - return reinterpret_cast(lParam); +bool Editor::ValidMargin(uptr_t wParam) const noexcept { + return wParam < vs.ms.size(); } void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLESETFORE: - vs.styles[wParam].fore = ColourDesired(static_cast(lParam)); + vs.styles[wParam].fore = ColourDesired(static_cast(lParam)); break; case SCI_STYLESETBACK: - vs.styles[wParam].back = ColourDesired(static_cast(lParam)); + vs.styles[wParam].back = ColourDesired(static_cast(lParam)); break; case SCI_STYLESETBOLD: vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL; @@ -5514,7 +5680,7 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam break; case SCI_STYLESETCHARACTERSET: vs.styles[wParam].characterSet = static_cast(lParam); - pdoc->SetCaseFolder(NULL); + pdoc->SetCaseFolder(nullptr); break; case SCI_STYLESETVISIBLE: vs.styles[wParam].visible = lParam != 0; @@ -5533,9 +5699,9 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLEGETFORE: - return vs.styles[wParam].fore.AsLong(); + return vs.styles[wParam].fore.AsInteger(); case SCI_STYLEGETBACK: - return vs.styles[wParam].back.AsLong(); + return vs.styles[wParam].back.AsInteger(); case SCI_STYLEGETBOLD: return vs.styles[wParam].weight > SC_WEIGHT_NORMAL; case SCI_STYLEGETWEIGHT: @@ -5566,7 +5732,40 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar return 0; } -sptr_t Editor::StringResult(sptr_t lParam, const char *val) { +void Editor::SetSelectionNMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { + InvalidateRange(sel.Range(wParam).Start().Position(), sel.Range(wParam).End().Position()); + + switch (iMessage) { + case SCI_SETSELECTIONNCARET: + sel.Range(wParam).caret.SetPosition(lParam); + break; + + case SCI_SETSELECTIONNANCHOR: + sel.Range(wParam).anchor.SetPosition(lParam); + break; + + case SCI_SETSELECTIONNCARETVIRTUALSPACE: + sel.Range(wParam).caret.SetVirtualSpace(lParam); + break; + + case SCI_SETSELECTIONNANCHORVIRTUALSPACE: + sel.Range(wParam).anchor.SetVirtualSpace(lParam); + break; + + case SCI_SETSELECTIONNSTART: + sel.Range(wParam).anchor.SetPosition(lParam); + break; + + case SCI_SETSELECTIONNEND: + sel.Range(wParam).caret.SetPosition(lParam); + break; + } + + InvalidateRange(sel.Range(wParam).Start().Position(), sel.Range(wParam).End().Position()); + ContainerNeedsUpdate(SC_UPDATE_SELECTION); +} + +sptr_t Editor::StringResult(sptr_t lParam, const char *val) noexcept { const size_t len = val ? strlen(val) : 0; if (lParam) { char *ptr = CharPtrFromSPtr(lParam); @@ -5578,7 +5777,7 @@ sptr_t Editor::StringResult(sptr_t lParam, const char *val) { return len; // Not including NUL } -sptr_t Editor::BytesResult(sptr_t lParam, const unsigned char *val, size_t len) { +sptr_t Editor::BytesResult(sptr_t lParam, const unsigned char *val, size_t len) noexcept { // No NUL termination: len is number of valid/displayed bytes if ((lParam) && (len > 0)) { char *ptr = CharPtrFromSPtr(lParam); @@ -5605,11 +5804,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (wParam == 0) return 0; char *ptr = CharPtrFromSPtr(lParam); - unsigned int iChar = 0; - for (; iChar < wParam - 1; iChar++) - ptr[iChar] = pdoc->CharAt(iChar); - ptr[iChar] = '\0'; - return iChar; + const Sci_Position len = std::min(wParam - 1, pdoc->Length()); + pdoc->GetCharRange(ptr, 0, len); + ptr[len] = '\0'; + return len; } case SCI_SETTEXT: { @@ -5619,7 +5817,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { pdoc->DeleteChars(0, pdoc->Length()); SetEmptySelection(0); const char *text = CharPtrFromSPtr(lParam); - pdoc->InsertString(0, text, istrlen(text)); + pdoc->InsertString(0, text, strlen(text)); return 1; } @@ -5652,11 +5850,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_COPYRANGE: - CopyRangeToClipboard(static_cast(wParam), static_cast(lParam)); + CopyRangeToClipboard(static_cast(wParam), lParam); break; case SCI_COPYTEXT: - CopyText(static_cast(wParam), CharPtrFromSPtr(lParam)); + CopyText(wParam, CharPtrFromSPtr(lParam)); break; case SCI_PASTE: @@ -5689,21 +5887,22 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return topLine; case SCI_SETFIRSTVISIBLELINE: - ScrollTo(static_cast(wParam)); + ScrollTo(static_cast(wParam)); break; case SCI_GETLINE: { // Risk of overwriting the end of the buffer - int lineStart = pdoc->LineStart(static_cast(wParam)); - int lineEnd = pdoc->LineStart(static_cast(wParam + 1)); + const Sci::Position lineStart = + pdoc->LineStart(static_cast(wParam)); + const Sci::Position lineEnd = + pdoc->LineStart(static_cast(wParam + 1)); + // not NUL terminated + const Sci::Position len = lineEnd - lineStart; if (lParam == 0) { - return lineEnd - lineStart; + return len; } char *ptr = CharPtrFromSPtr(lParam); - int iPlace = 0; - for (int iChar = lineStart; iChar < lineEnd; iChar++) { - ptr[iPlace++] = pdoc->CharAt(iChar); - } - return iPlace; + pdoc->GetCharRange(ptr, lineStart, len); + return len; } case SCI_GETLINECOUNT: @@ -5716,8 +5915,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return !pdoc->IsSavePoint(); case SCI_SETSEL: { - int nStart = static_cast(wParam); - int nEnd = static_cast(lParam); + Sci::Position nStart = static_cast(wParam); + Sci::Position nEnd = lParam; if (nEnd < 0) nEnd = pdoc->Length(); if (nStart < 0) @@ -5737,10 +5936,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return selectedText.LengthWithTerminator(); } else { char *ptr = CharPtrFromSPtr(lParam); - unsigned int iChar = 0; - if (selectedText.Length()) { - for (; iChar < selectedText.LengthWithTerminator(); iChar++) - ptr[iChar] = selectedText.Data()[iChar]; + size_t iChar = selectedText.Length(); + if (iChar) { + memcpy(ptr, selectedText.Data(), iChar); + ptr[iChar++] = '\0'; } else { ptr[0] = '\0'; } @@ -5749,58 +5948,59 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { } case SCI_LINEFROMPOSITION: - if (static_cast(wParam) < 0) + if (static_cast(wParam) < 0) return 0; - return pdoc->LineFromPosition(static_cast(wParam)); + return pdoc->LineFromPosition(static_cast(wParam)); case SCI_POSITIONFROMLINE: - if (static_cast(wParam) < 0) + if (static_cast(wParam) < 0) wParam = pdoc->LineFromPosition(SelectionStart().Position()); if (wParam == 0) return 0; // Even if there is no text, there is a first line that starts at 0 - if (static_cast(wParam) > pdoc->LinesTotal()) + if (static_cast(wParam) > pdoc->LinesTotal()) return -1; //if (wParam > pdoc->LineFromPosition(pdoc->Length())) // Useful test, anyway... // return -1; - return pdoc->LineStart(static_cast(wParam)); + return pdoc->LineStart(static_cast(wParam)); // Replacement of the old Scintilla interpretation of EM_LINELENGTH case SCI_LINELENGTH: - if ((static_cast(wParam) < 0) || - (static_cast(wParam) > pdoc->LineFromPosition(pdoc->Length()))) + if ((static_cast(wParam) < 0) || + (static_cast(wParam) > pdoc->LineFromPosition(pdoc->Length()))) return 0; - return pdoc->LineStart(static_cast(wParam) + 1) - pdoc->LineStart(static_cast(wParam)); + return pdoc->LineStart(static_cast(wParam) + 1) - pdoc->LineStart(static_cast(wParam)); case SCI_REPLACESEL: { if (lParam == 0) return 0; UndoGroup ug(pdoc); ClearSelection(); - char *replacement = CharPtrFromSPtr(lParam); - const int lengthInserted = pdoc->InsertString( - sel.MainCaret(), replacement, istrlen(replacement)); + const char *replacement = CharPtrFromSPtr(lParam); + const Sci::Position lengthInserted = pdoc->InsertString( + sel.MainCaret(), replacement, strlen(replacement)); SetEmptySelection(sel.MainCaret() + lengthInserted); + SetLastXChosen(); EnsureCaretVisible(); } break; case SCI_SETTARGETSTART: - targetStart = static_cast(wParam); + targetStart = static_cast(wParam); break; case SCI_GETTARGETSTART: return targetStart; case SCI_SETTARGETEND: - targetEnd = static_cast(wParam); + targetEnd = static_cast(wParam); break; case SCI_GETTARGETEND: return targetEnd; case SCI_SETTARGETRANGE: - targetStart = static_cast(wParam); - targetEnd = static_cast(lParam); + targetStart = static_cast(wParam); + targetEnd = lParam; break; case SCI_TARGETWHOLEDOCUMENT: @@ -5825,15 +6025,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_REPLACETARGET: PLATFORM_ASSERT(lParam); - return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast(wParam)); + return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast(wParam)); case SCI_REPLACETARGETRE: PLATFORM_ASSERT(lParam); - return ReplaceTarget(true, CharPtrFromSPtr(lParam), static_cast(wParam)); + return ReplaceTarget(true, CharPtrFromSPtr(lParam), static_cast(wParam)); case SCI_SEARCHINTARGET: PLATFORM_ASSERT(lParam); - return SearchInTarget(CharPtrFromSPtr(lParam), static_cast(wParam)); + return SearchInTarget(CharPtrFromSPtr(lParam), static_cast(wParam)); case SCI_SETSEARCHFLAGS: searchFlags = static_cast(wParam); @@ -5846,17 +6046,24 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return GetTag(CharPtrFromSPtr(lParam), static_cast(wParam)); case SCI_POSITIONBEFORE: - return pdoc->MovePositionOutsideChar(static_cast(wParam) - 1, -1, true); + return pdoc->MovePositionOutsideChar(static_cast(wParam) - 1, -1, true); case SCI_POSITIONAFTER: - return pdoc->MovePositionOutsideChar(static_cast(wParam) + 1, 1, true); + return pdoc->MovePositionOutsideChar(static_cast(wParam) + 1, 1, true); case SCI_POSITIONRELATIVE: - return Platform::Clamp(pdoc->GetRelativePosition(static_cast(wParam), static_cast(lParam)), 0, pdoc->Length()); + return Sci::clamp(pdoc->GetRelativePosition( + static_cast(wParam), lParam), + static_cast(0), pdoc->Length()); + + case SCI_POSITIONRELATIVECODEUNITS: + return Sci::clamp(pdoc->GetRelativePositionUTF16( + static_cast(wParam), lParam), + static_cast(0), pdoc->Length()); case SCI_LINESCROLL: - ScrollTo(topLine + static_cast(lParam)); - HorizontalScrollTo(xOffset + static_cast(wParam)* static_cast(vs.spaceWidth)); + ScrollTo(topLine + static_cast(lParam)); + HorizontalScrollTo(xOffset + static_cast(wParam) * static_cast(vs.spaceWidth)); return 1; case SCI_SETXOFFSET: @@ -5891,7 +6098,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam < 0) { return 0; } else { - Point pt = LocationFromPosition(static_cast(lParam)); + const Point pt = LocationFromPosition(lParam); // Convert to view-relative return static_cast(pt.x) - vs.textStart + vs.fixedColumnWidth; } @@ -5900,7 +6107,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam < 0) { return 0; } else { - Point pt = LocationFromPosition(static_cast(lParam)); + const Point pt = LocationFromPosition(lParam); return static_cast(pt.y); } @@ -5910,13 +6117,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETTEXTRANGE: { if (lParam == 0) return 0; - Sci_TextRange *tr = reinterpret_cast(lParam); - int cpMax = static_cast(tr->chrg.cpMax); + Sci_TextRange *tr = static_cast(PtrFromSPtr(lParam)); + Sci::Position cpMax = static_cast(tr->chrg.cpMax); if (cpMax == -1) cpMax = pdoc->Length(); PLATFORM_ASSERT(cpMax <= pdoc->Length()); - int len = static_cast(cpMax - tr->chrg.cpMin); // No -1 as cpMin and cpMax are referring to inter character positions - pdoc->GetCharRange(tr->lpstrText, static_cast(tr->chrg.cpMin), len); + Sci::Position len = cpMax - tr->chrg.cpMin; // No -1 as cpMin and cpMax are referring to inter character positions + pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len); // Spec says copied text is terminated with a NUL tr->lpstrText[len] = '\0'; return len; // Not including NUL @@ -5928,7 +6135,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_FORMATRANGE: - return FormatRange(wParam != 0, reinterpret_cast(lParam)); + return FormatRange(wParam != 0, static_cast(PtrFromSPtr(lParam))); case SCI_GETMARGINLEFT: return vs.leftMarginWidth; @@ -5952,26 +6159,26 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_ADDTEXT: { if (lParam == 0) return 0; - const int lengthInserted = pdoc->InsertString( - CurrentPosition(), CharPtrFromSPtr(lParam), static_cast(wParam)); + const Sci::Position lengthInserted = pdoc->InsertString( + CurrentPosition(), CharPtrFromSPtr(lParam), static_cast(wParam)); SetEmptySelection(sel.MainCaret() + lengthInserted); return 0; } case SCI_ADDSTYLEDTEXT: if (lParam) - AddStyledText(CharPtrFromSPtr(lParam), static_cast(wParam)); + AddStyledText(CharPtrFromSPtr(lParam), static_cast(wParam)); return 0; case SCI_INSERTTEXT: { if (lParam == 0) return 0; - int insertPos = static_cast(wParam); - if (static_cast(wParam) == -1) + Sci::Position insertPos = static_cast(wParam); + if (insertPos == -1) insertPos = CurrentPosition(); - int newCurrent = CurrentPosition(); - char *sz = CharPtrFromSPtr(lParam); - const int lengthInserted = pdoc->InsertString(insertPos, sz, istrlen(sz)); + Sci::Position newCurrent = CurrentPosition(); + const char *sz = CharPtrFromSPtr(lParam); + const Sci::Position lengthInserted = pdoc->InsertString(insertPos, sz, strlen(sz)); if (newCurrent > insertPos) newCurrent += lengthInserted; SetEmptySelection(newCurrent); @@ -5980,11 +6187,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CHANGEINSERTION: PLATFORM_ASSERT(lParam); - pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), static_cast(wParam)); + pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), static_cast(wParam)); return 0; case SCI_APPENDTEXT: - pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), static_cast(wParam)); + pdoc->InsertString(pdoc->Length(), + CharPtrFromSPtr(lParam), static_cast(wParam)); return 0; case SCI_CLEARALL: @@ -5992,7 +6200,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; case SCI_DELETERANGE: - pdoc->DeleteChars(static_cast(wParam), static_cast(lParam)); + pdoc->DeleteChars(static_cast(wParam), lParam); return 0; case SCI_CLEARDOCUMENTSTYLE: @@ -6022,33 +6230,33 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETWORDCHARS: - return pdoc->GetCharsOfClass(CharClassify::ccWord, reinterpret_cast(lParam)); + return pdoc->GetCharsOfClass(CharClassify::ccWord, UCharPtrFromSPtr(lParam)); case SCI_SETWORDCHARS: { pdoc->SetDefaultCharClasses(false); if (lParam == 0) return 0; - pdoc->SetCharClasses(reinterpret_cast(lParam), CharClassify::ccWord); + pdoc->SetCharClasses(ConstUCharPtrFromSPtr(lParam), CharClassify::ccWord); } break; case SCI_GETWHITESPACECHARS: - return pdoc->GetCharsOfClass(CharClassify::ccSpace, reinterpret_cast(lParam)); + return pdoc->GetCharsOfClass(CharClassify::ccSpace, UCharPtrFromSPtr(lParam)); case SCI_SETWHITESPACECHARS: { if (lParam == 0) return 0; - pdoc->SetCharClasses(reinterpret_cast(lParam), CharClassify::ccSpace); + pdoc->SetCharClasses(ConstUCharPtrFromSPtr(lParam), CharClassify::ccSpace); } break; case SCI_GETPUNCTUATIONCHARS: - return pdoc->GetCharsOfClass(CharClassify::ccPunctuation, reinterpret_cast(lParam)); + return pdoc->GetCharsOfClass(CharClassify::ccPunctuation, UCharPtrFromSPtr(lParam)); case SCI_SETPUNCTUATIONCHARS: { if (lParam == 0) return 0; - pdoc->SetCharClasses(reinterpret_cast(lParam), CharClassify::ccPunctuation); + pdoc->SetCharClasses(ConstUCharPtrFromSPtr(lParam), CharClassify::ccPunctuation); } break; @@ -6056,23 +6264,30 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { pdoc->SetDefaultCharClasses(true); break; + case SCI_SETCHARACTERCATEGORYOPTIMIZATION: + pdoc->SetCharacterCategoryOptimization(static_cast(wParam)); + break; + + case SCI_GETCHARACTERCATEGORYOPTIMIZATION: + return pdoc->CharacterCategoryOptimization(); + case SCI_GETLENGTH: return pdoc->Length(); case SCI_ALLOCATE: - pdoc->Allocate(static_cast(wParam)); + pdoc->Allocate(static_cast(wParam)); break; case SCI_GETCHARAT: - return pdoc->CharAt(static_cast(wParam)); + return pdoc->CharAt(static_cast(wParam)); case SCI_SETCURRENTPOS: if (sel.IsRectangular()) { - sel.Rectangular().caret.SetPosition(static_cast(wParam)); + sel.Rectangular().caret.SetPosition(static_cast(wParam)); SetRectangularRange(); Redraw(); } else { - SetSelection(static_cast(wParam), sel.MainAnchor()); + SetSelection(static_cast(wParam), sel.MainAnchor()); } break; @@ -6081,11 +6296,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETANCHOR: if (sel.IsRectangular()) { - sel.Rectangular().anchor.SetPosition(static_cast(wParam)); + sel.Rectangular().anchor.SetPosition(static_cast(wParam)); SetRectangularRange(); Redraw(); } else { - SetSelection(sel.MainCaret(), static_cast(wParam)); + SetSelection(sel.MainCaret(), static_cast(wParam)); } break; @@ -6093,21 +6308,21 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor(); case SCI_SETSELECTIONSTART: - SetSelection(Platform::Maximum(sel.MainCaret(), static_cast(wParam)), static_cast(wParam)); + SetSelection(std::max(sel.MainCaret(), static_cast(wParam)), static_cast(wParam)); break; case SCI_GETSELECTIONSTART: return sel.LimitsForRectangularElseMain().start.Position(); case SCI_SETSELECTIONEND: - SetSelection(static_cast(wParam), Platform::Minimum(sel.MainAnchor(), static_cast(wParam))); + SetSelection(static_cast(wParam), std::min(sel.MainAnchor(), static_cast(wParam))); break; case SCI_GETSELECTIONEND: return sel.LimitsForRectangularElseMain().end.Position(); case SCI_SETEMPTYSELECTION: - SetEmptySelection(static_cast(wParam)); + SetEmptySelection(static_cast(wParam)); break; case SCI_SETPRINTMAGNIFICATION: @@ -6132,10 +6347,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return view.printParameters.wrapState; case SCI_GETSTYLEAT: - if (static_cast(wParam) >= pdoc->Length()) + if (static_cast(wParam) >= pdoc->Length()) return 0; else - return pdoc->StyleAt(static_cast(wParam)); + return pdoc->StyleAt(static_cast(wParam)); case SCI_REDO: Redo(); @@ -6152,11 +6367,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETSTYLEDTEXT: { if (lParam == 0) return 0; - Sci_TextRange *tr = reinterpret_cast(lParam); - int iPlace = 0; - for (long iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) { - tr->lpstrText[iPlace++] = pdoc->CharAt(static_cast(iChar)); - tr->lpstrText[iPlace++] = pdoc->StyleAt(static_cast(iChar)); + Sci_TextRange *tr = static_cast(PtrFromSPtr(lParam)); + Sci::Position iPlace = 0; + for (Sci::Position iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) { + tr->lpstrText[iPlace++] = pdoc->CharAt(iChar); + tr->lpstrText[iPlace++] = pdoc->StyleAt(iChar); } tr->lpstrText[iPlace] = '\0'; tr->lpstrText[iPlace + 1] = '\0'; @@ -6181,6 +6396,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { Redraw(); break; + case SCI_GETTABDRAWMODE: + return vs.tabDrawMode; + + case SCI_SETTABDRAWMODE: + vs.tabDrawMode = static_cast(wParam); + Redraw(); + break; + case SCI_GETWHITESPACESIZE: return vs.whitespaceSize; @@ -6206,28 +6429,26 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { true, true); case SCI_GOTOLINE: - GoToLine(static_cast(wParam)); + GoToLine(static_cast(wParam)); break; case SCI_GOTOPOS: - SetEmptySelection(static_cast(wParam)); + SetEmptySelection(static_cast(wParam)); EnsureCaretVisible(); break; case SCI_GETCURLINE: { - int lineCurrentPos = pdoc->LineFromPosition(sel.MainCaret()); - int lineStart = pdoc->LineStart(lineCurrentPos); - unsigned int lineEnd = pdoc->LineStart(lineCurrentPos + 1); + const Sci::Line lineCurrentPos = pdoc->SciLineFromPosition(sel.MainCaret()); + const Sci::Position lineStart = pdoc->LineStart(lineCurrentPos); + const Sci::Position lineEnd = pdoc->LineStart(lineCurrentPos + 1); if (lParam == 0) { return 1 + lineEnd - lineStart; } PLATFORM_ASSERT(wParam > 0); char *ptr = CharPtrFromSPtr(lParam); - unsigned int iPlace = 0; - for (unsigned int iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) { - ptr[iPlace++] = pdoc->CharAt(iChar); - } - ptr[iPlace] = '\0'; + const Sci::Position len = std::min(lineEnd - lineStart, wParam - 1); + pdoc->GetCharRange(ptr, lineStart, len); + ptr[len] = '\0'; return sel.MainCaret() - lineStart; } @@ -6243,8 +6464,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETLINEENDTYPESALLOWED: if (pdoc->SetLineEndTypesAllowed(static_cast(wParam))) { - cs.Clear(); - cs.InsertLines(0, pdoc->LinesTotal() - 1); + pcs->Clear(); + pcs->InsertLines(0, pdoc->LinesTotal() - 1); SetAnnotationHeights(0, pdoc->LinesTotal()); InvalidateStyleRedraw(); } @@ -6257,17 +6478,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->GetLineEndTypesActive(); case SCI_STARTSTYLING: - pdoc->StartStyling(static_cast(wParam), static_cast(lParam)); + pdoc->StartStyling(static_cast(wParam), static_cast(lParam)); break; case SCI_SETSTYLING: - pdoc->SetStyleFor(static_cast(wParam), static_cast(lParam)); + if (static_cast(wParam) < 0) + errorStatus = SC_STATUS_FAILURE; + else + pdoc->SetStyleFor(static_cast(wParam), static_cast(lParam)); break; case SCI_SETSTYLINGEX: // Specify a complete styling buffer if (lParam == 0) return 0; - pdoc->SetStyles(static_cast(wParam), CharPtrFromSPtr(lParam)); + pdoc->SetStyles(static_cast(wParam), CharPtrFromSPtr(lParam)); break; case SCI_SETBUFFEREDDRAW: @@ -6315,21 +6539,21 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->tabInChars; case SCI_CLEARTABSTOPS: - if (view.ClearTabstops(static_cast(wParam))) { - DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, 0, static_cast(wParam)); - NotifyModified(pdoc, mh, NULL); + if (view.ClearTabstops(static_cast(wParam))) { + const DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, nullptr, static_cast(wParam)); + NotifyModified(pdoc, mh, nullptr); } break; case SCI_ADDTABSTOP: - if (view.AddTabstop(static_cast(wParam), static_cast(lParam))) { - DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, 0, static_cast(wParam)); - NotifyModified(pdoc, mh, NULL); + if (view.AddTabstop(static_cast(wParam), static_cast(lParam))) { + const DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, nullptr, static_cast(wParam)); + NotifyModified(pdoc, mh, nullptr); } break; case SCI_GETNEXTTABSTOP: - return view.GetNextTabstop(static_cast(wParam), static_cast(lParam)); + return view.GetNextTabstop(static_cast(wParam), static_cast(lParam)); case SCI_SETINDENT: pdoc->indentInChars = static_cast(wParam); @@ -6352,14 +6576,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->useTabs; case SCI_SETLINEINDENTATION: - pdoc->SetLineIndentation(static_cast(wParam), static_cast(lParam)); + pdoc->SetLineIndentation(static_cast(wParam), lParam); break; case SCI_GETLINEINDENTATION: - return pdoc->GetLineIndentation(static_cast(wParam)); + return pdoc->GetLineIndentation(static_cast(wParam)); case SCI_GETLINEINDENTPOSITION: - return pdoc->GetLineIndentPosition(static_cast(wParam)); + return pdoc->GetLineIndentPosition(static_cast(wParam)); case SCI_SETTABINDENTS: pdoc->tabIndents = wParam != 0; @@ -6384,13 +6608,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return dwellDelay; case SCI_WORDSTARTPOSITION: - return pdoc->ExtendWordSelect(static_cast(wParam), -1, lParam != 0); + return pdoc->ExtendWordSelect(static_cast(wParam), -1, lParam != 0); case SCI_WORDENDPOSITION: - return pdoc->ExtendWordSelect(static_cast(wParam), 1, lParam != 0); + return pdoc->ExtendWordSelect(static_cast(wParam), 1, lParam != 0); case SCI_ISRANGEWORD: - return pdoc->IsWordAt(static_cast(wParam), static_cast(lParam)); + return pdoc->IsWordAt(static_cast(wParam), lParam); + + case SCI_SETIDLESTYLING: + idleStyling = static_cast(wParam); + break; + + case SCI_GETIDLESTYLING: + return idleStyling; case SCI_SETWRAPMODE: if (vs.SetWrapState(static_cast(wParam))) { @@ -6459,7 +6690,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETSCROLLWIDTH: PLATFORM_ASSERT(wParam > 0); - if ((wParam > 0) && (wParam != static_cast(scrollWidth))) { + if ((wParam > 0) && (wParam != static_cast(scrollWidth))) { view.lineWidthMaxSeen = 0; scrollWidth = static_cast(wParam); SetScrollBars(); @@ -6519,10 +6750,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETCOLUMN: - return pdoc->GetColumn(static_cast(wParam)); + return pdoc->GetColumn(static_cast(wParam)); case SCI_FINDCOLUMN: - return pdoc->FindColumn(static_cast(wParam), static_cast(lParam)); + return pdoc->FindColumn(static_cast(wParam), lParam); case SCI_SETHSCROLLBAR : if (horizontalScrollBarVisible != (wParam != 0)) { @@ -6549,7 +6780,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return verticalScrollBarVisible; case SCI_SETINDENTATIONGUIDES: - vs.viewIndentationGuides = IndentView(wParam); + vs.viewIndentationGuides = static_cast(wParam); Redraw(); break; @@ -6567,13 +6798,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return highlightGuideColumn; case SCI_GETLINEENDPOSITION: - return pdoc->LineEnd(static_cast(wParam)); + return pdoc->LineEnd(static_cast(wParam)); case SCI_SETCODEPAGE: if (ValidCodePage(static_cast(wParam))) { if (pdoc->SetDBCSCodePage(static_cast(wParam))) { - cs.Clear(); - cs.InsertLines(0, pdoc->LinesTotal() - 1); + pcs->Clear(); + pcs->InsertLines(0, pdoc->LinesTotal() - 1); SetAnnotationHeights(0, pdoc->LinesTotal()); InvalidateStyleRedraw(); SetRepresentations(); @@ -6590,15 +6821,23 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETIMEINTERACTION: return imeInteraction; - -#ifdef INCLUDE_DEPRECATED_FEATURES - case SCI_SETUSEPALETTE: - InvalidateStyleRedraw(); + + case SCI_GETLINECHARACTERINDEX: + return pdoc->LineCharacterIndex(); + + case SCI_ALLOCATELINECHARACTERINDEX: + pdoc->AllocateLineCharacterIndex(static_cast(wParam)); break; - case SCI_GETUSEPALETTE: - return 0; -#endif + case SCI_RELEASELINECHARACTERINDEX: + pdoc->ReleaseLineCharacterIndex(static_cast(wParam)); + break; + + case SCI_LINEFROMINDEXPOSITION: + return pdoc->LineFromPositionIndex(static_cast(wParam), static_cast(lParam)); + + case SCI_INDEXPOSITIONFROMLINE: + return pdoc->IndexLineStart(static_cast(wParam), static_cast(lParam)); // Marker definition and setting case SCI_MARKERDEFINE: @@ -6618,13 +6857,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_MARKERSETFORE: if (wParam <= MARKER_MAX) - vs.markers[wParam].fore = ColourDesired(static_cast(lParam)); + vs.markers[wParam].fore = ColourDesired(static_cast(lParam)); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSETBACKSELECTED: if (wParam <= MARKER_MAX) - vs.markers[wParam].backSelected = ColourDesired(static_cast(lParam)); + vs.markers[wParam].backSelected = ColourDesired(static_cast(lParam)); InvalidateStyleData(); RedrawSelMargin(); break; @@ -6634,7 +6873,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_MARKERSETBACK: if (wParam <= MARKER_MAX) - vs.markers[wParam].back = ColourDesired(static_cast(lParam)); + vs.markers[wParam].back = ColourDesired(static_cast(lParam)); InvalidateStyleData(); RedrawSelMargin(); break; @@ -6644,16 +6883,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; case SCI_MARKERADD: { - int markerID = pdoc->AddMark(static_cast(wParam), static_cast(lParam)); + const int markerID = pdoc->AddMark(static_cast(wParam), static_cast(lParam)); return markerID; } case SCI_MARKERADDSET: if (lParam != 0) - pdoc->AddMarkSet(static_cast(wParam), static_cast(lParam)); + pdoc->AddMarkSet(static_cast(wParam), static_cast(lParam)); break; case SCI_MARKERDELETE: - pdoc->DeleteMark(static_cast(wParam), static_cast(lParam)); + pdoc->DeleteMark(static_cast(wParam), static_cast(lParam)); break; case SCI_MARKERDELETEALL: @@ -6661,13 +6900,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_MARKERGET: - return pdoc->GetMark(static_cast(wParam)); + return pdoc->GetMark(static_cast(wParam)); case SCI_MARKERNEXT: - return pdoc->MarkerNext(static_cast(wParam), static_cast(lParam)); + return pdoc->MarkerNext(static_cast(wParam), static_cast(lParam)); case SCI_MARKERPREVIOUS: { - for (int iLine = static_cast(wParam); iLine >= 0; iLine--) { + for (Sci::Line iLine = static_cast(wParam); iLine >= 0; iLine--) { if ((pdoc->GetMark(iLine) & lParam) != 0) return iLine; } @@ -6697,7 +6936,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_MARKERDEFINERGBAIMAGE: if (wParam <= MARKER_MAX) { - vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0f, reinterpret_cast(lParam)); + vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0f, ConstUCharPtrFromSPtr(lParam)); vs.CalcLargestMarkerHeight(); } InvalidateStyleData(); @@ -6771,6 +7010,27 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { else return 0; + case SCI_SETMARGINBACKN: + if (ValidMargin(wParam)) { + vs.ms[wParam].back = ColourDesired(static_cast(lParam)); + InvalidateStyleRedraw(); + } + break; + + case SCI_GETMARGINBACKN: + if (ValidMargin(wParam)) + return vs.ms[wParam].back.AsInteger(); + else + return 0; + + case SCI_SETMARGINS: + if (wParam < 1000) + vs.ms.resize(wParam); + break; + + case SCI_GETMARGINS: + return vs.ms.size(); + case SCI_STYLECLEARALL: vs.ClearStyles(); InvalidateStyleRedraw(); @@ -6815,18 +7075,21 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { vs.ResetDefaultStyle(); InvalidateStyleRedraw(); break; + +#ifdef INCLUDE_DEPRECATED_FEATURES case SCI_SETSTYLEBITS: vs.EnsureStyle(0xff); break; case SCI_GETSTYLEBITS: return 8; +#endif case SCI_SETLINESTATE: - return pdoc->SetLineState(static_cast(wParam), static_cast(lParam)); + return pdoc->SetLineState(static_cast(wParam), static_cast(lParam)); case SCI_GETLINESTATE: - return pdoc->GetLineState(static_cast(wParam)); + return pdoc->GetLineState(static_cast(wParam)); case SCI_GETMAXLINESTATE: return pdoc->GetMaxLineState(); @@ -6844,10 +7107,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; + case SCI_GETCARETLINEFRAME: + return vs.caretLineFrame; + case SCI_SETCARETLINEFRAME: + vs.caretLineFrame = static_cast(wParam); + InvalidateStyleRedraw(); + break; case SCI_GETCARETLINEBACK: - return vs.caretLineBackground.AsLong(); + return vs.caretLineBackground.AsInteger(); case SCI_SETCARETLINEBACK: - vs.caretLineBackground = static_cast(wParam); + vs.caretLineBackground = ColourDesired(static_cast(wParam)); InvalidateStyleRedraw(); break; case SCI_GETCARETLINEBACKALPHA: @@ -6860,55 +7129,55 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { // Folding messages case SCI_VISIBLEFROMDOCLINE: - return cs.DisplayFromDoc(static_cast(wParam)); + return pcs->DisplayFromDoc(static_cast(wParam)); case SCI_DOCLINEFROMVISIBLE: - return cs.DocFromDisplay(static_cast(wParam)); + return pcs->DocFromDisplay(static_cast(wParam)); case SCI_WRAPCOUNT: - return WrapCount(static_cast(wParam)); + return WrapCount(static_cast(wParam)); case SCI_SETFOLDLEVEL: { - int prev = pdoc->SetLevel(static_cast(wParam), static_cast(lParam)); + const int prev = pdoc->SetLevel(static_cast(wParam), static_cast(lParam)); if (prev != static_cast(lParam)) RedrawSelMargin(); return prev; } case SCI_GETFOLDLEVEL: - return pdoc->GetLevel(static_cast(wParam)); + return pdoc->GetLevel(static_cast(wParam)); case SCI_GETLASTCHILD: - return pdoc->GetLastChild(static_cast(wParam), static_cast(lParam)); + return pdoc->GetLastChild(static_cast(wParam), static_cast(lParam)); case SCI_GETFOLDPARENT: - return pdoc->GetFoldParent(static_cast(wParam)); + return pdoc->GetFoldParent(static_cast(wParam)); case SCI_SHOWLINES: - cs.SetVisible(static_cast(wParam), static_cast(lParam), true); + pcs->SetVisible(static_cast(wParam), static_cast(lParam), true); SetScrollBars(); Redraw(); break; case SCI_HIDELINES: if (wParam > 0) - cs.SetVisible(static_cast(wParam), static_cast(lParam), false); + pcs->SetVisible(static_cast(wParam), static_cast(lParam), false); SetScrollBars(); Redraw(); break; case SCI_GETLINEVISIBLE: - return cs.GetVisible(static_cast(wParam)); + return pcs->GetVisible(static_cast(wParam)); case SCI_GETALLLINESVISIBLE: - return cs.HiddenLines() ? 0 : 1; + return pcs->HiddenLines() ? 0 : 1; case SCI_SETFOLDEXPANDED: - SetFoldExpanded(static_cast(wParam), lParam != 0); + SetFoldExpanded(static_cast(wParam), lParam != 0); break; case SCI_GETFOLDEXPANDED: - return cs.GetExpanded(static_cast(wParam)); + return pcs->GetExpanded(static_cast(wParam)); case SCI_SETAUTOMATICFOLD: foldAutomatic = static_cast(wParam); @@ -6922,16 +7191,37 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { Redraw(); break; + case SCI_TOGGLEFOLDSHOWTEXT: + pcs->SetFoldDisplayText(static_cast(wParam), CharPtrFromSPtr(lParam)); + FoldLine(static_cast(wParam), SC_FOLDACTION_TOGGLE); + break; + + case SCI_FOLDDISPLAYTEXTSETSTYLE: + foldDisplayTextStyle = static_cast(wParam); + Redraw(); + break; + + case SCI_FOLDDISPLAYTEXTGETSTYLE: + return foldDisplayTextStyle; + + case SCI_SETDEFAULTFOLDDISPLAYTEXT: + SetDefaultFoldDisplayText(CharPtrFromSPtr(lParam)); + Redraw(); + break; + + case SCI_GETDEFAULTFOLDDISPLAYTEXT: + return StringResult(lParam, GetDefaultFoldDisplayText()); + case SCI_TOGGLEFOLD: - FoldLine(static_cast(wParam), SC_FOLDACTION_TOGGLE); + FoldLine(static_cast(wParam), SC_FOLDACTION_TOGGLE); break; case SCI_FOLDLINE: - FoldLine(static_cast(wParam), static_cast(lParam)); + FoldLine(static_cast(wParam), static_cast(lParam)); break; case SCI_FOLDCHILDREN: - FoldExpand(static_cast(wParam), static_cast(lParam), pdoc->GetLevel(static_cast(wParam))); + FoldExpand(static_cast(wParam), static_cast(lParam), pdoc->GetLevel(static_cast(wParam))); break; case SCI_FOLDALL: @@ -6939,22 +7229,22 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_EXPANDCHILDREN: - FoldExpand(static_cast(wParam), SC_FOLDACTION_EXPAND, static_cast(lParam)); + FoldExpand(static_cast(wParam), SC_FOLDACTION_EXPAND, static_cast(lParam)); break; case SCI_CONTRACTEDFOLDNEXT: - return ContractedFoldNext(static_cast(wParam)); + return ContractedFoldNext(static_cast(wParam)); case SCI_ENSUREVISIBLE: - EnsureLineVisible(static_cast(wParam), false); + EnsureLineVisible(static_cast(wParam), false); break; case SCI_ENSUREVISIBLEENFORCEPOLICY: - EnsureLineVisible(static_cast(wParam), true); + EnsureLineVisible(static_cast(wParam), true); break; case SCI_SCROLLRANGE: - ScrollRange(SelectionRange(static_cast(wParam), static_cast(lParam))); + ScrollRange(SelectionRange(static_cast(wParam), lParam)); break; case SCI_SEARCHANCHOR: @@ -6985,13 +7275,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETSELFORE: vs.selColours.fore = ColourOptional(wParam, lParam); - vs.selAdditionalForeground = ColourDesired(static_cast(lParam)); + vs.selAdditionalForeground = ColourDesired(static_cast(lParam)); InvalidateStyleRedraw(); break; case SCI_SETSELBACK: vs.selColours.back = ColourOptional(wParam, lParam); - vs.selAdditionalBackground = ColourDesired(static_cast(lParam)); + vs.selAdditionalBackground = ColourDesired(static_cast(lParam)); InvalidateStyleRedraw(); break; @@ -7023,15 +7313,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETCARETFORE: - vs.caretcolour = ColourDesired(static_cast(wParam)); + vs.caretcolour = ColourDesired(static_cast(wParam)); InvalidateStyleRedraw(); break; case SCI_GETCARETFORE: - return vs.caretcolour.AsLong(); + return vs.caretcolour.AsInteger(); case SCI_SETCARETSTYLE: - if (wParam <= CARETSTYLE_BLOCK) + if (wParam <= (CARETSTYLE_BLOCK | CARETSTYLE_OVERSTRIKE_BLOCK)) vs.caretStyle = static_cast(wParam); else /* Default to the line caret */ @@ -7043,12 +7333,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.caretStyle; case SCI_SETCARETWIDTH: - if (static_cast(wParam) <= 0) - vs.caretWidth = 0; - else if (wParam >= 3) - vs.caretWidth = 3; - else - vs.caretWidth = static_cast(wParam); + vs.caretWidth = Sci::clamp(static_cast(wParam), 0, 3); InvalidateStyleRedraw(); break; @@ -7056,13 +7341,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.caretWidth; case SCI_ASSIGNCMDKEY: - kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast(wParam)), - Platform::HighShortFromLong(static_cast(wParam)), static_cast(lParam)); + kmap.AssignCmdKey(LowShortFromWParam(wParam), + HighShortFromWParam(wParam), static_cast(lParam)); break; case SCI_CLEARCMDKEY: - kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast(wParam)), - Platform::HighShortFromLong(static_cast(wParam)), SCI_NULL); + kmap.AssignCmdKey(LowShortFromWParam(wParam), + HighShortFromWParam(wParam), SCI_NULL); break; case SCI_CLEARALLCMDKEYS: @@ -7082,14 +7367,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETFORE: if (wParam <= INDIC_MAX) { - vs.indicators[wParam].sacNormal.fore = ColourDesired(static_cast(lParam)); - vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast(lParam)); + vs.indicators[wParam].sacNormal.fore = ColourDesired(static_cast(lParam)); + vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast(lParam)); InvalidateStyleRedraw(); } break; case SCI_INDICGETFORE: - return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.fore.AsLong() : 0; + return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacNormal.fore.AsInteger() : 0; case SCI_INDICSETHOVERSTYLE: if (wParam <= INDIC_MAX) { @@ -7103,13 +7388,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETHOVERFORE: if (wParam <= INDIC_MAX) { - vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast(lParam)); + vs.indicators[wParam].sacHover.fore = ColourDesired(static_cast(lParam)); InvalidateStyleRedraw(); } break; case SCI_INDICGETHOVERFORE: - return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.fore.AsLong() : 0; + return (wParam <= INDIC_MAX) ? vs.indicators[wParam].sacHover.fore.AsInteger() : 0; case SCI_INDICSETFLAGS: if (wParam <= INDIC_MAX) { @@ -7152,35 +7437,37 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return (wParam <= INDIC_MAX) ? vs.indicators[wParam].outlineAlpha : 0; case SCI_SETINDICATORCURRENT: - pdoc->decorations.SetCurrentIndicator(static_cast(wParam)); + pdoc->DecorationSetCurrentIndicator(static_cast(wParam)); break; case SCI_GETINDICATORCURRENT: - return pdoc->decorations.GetCurrentIndicator(); + return pdoc->decorations->GetCurrentIndicator(); case SCI_SETINDICATORVALUE: - pdoc->decorations.SetCurrentValue(static_cast(wParam)); + pdoc->decorations->SetCurrentValue(static_cast(wParam)); break; case SCI_GETINDICATORVALUE: - return pdoc->decorations.GetCurrentValue(); + return pdoc->decorations->GetCurrentValue(); case SCI_INDICATORFILLRANGE: - pdoc->DecorationFillRange(static_cast(wParam), pdoc->decorations.GetCurrentValue(), static_cast(lParam)); + pdoc->DecorationFillRange(static_cast(wParam), + pdoc->decorations->GetCurrentValue(), lParam); break; case SCI_INDICATORCLEARRANGE: - pdoc->DecorationFillRange(static_cast(wParam), 0, static_cast(lParam)); + pdoc->DecorationFillRange(static_cast(wParam), 0, + lParam); break; case SCI_INDICATORALLONFOR: - return pdoc->decorations.AllOnFor(static_cast(wParam)); + return pdoc->decorations->AllOnFor(static_cast(wParam)); case SCI_INDICATORVALUEAT: - return pdoc->decorations.ValueAt(static_cast(wParam), static_cast(lParam)); + return pdoc->decorations->ValueAt(static_cast(wParam), lParam); case SCI_INDICATORSTART: - return pdoc->decorations.Start(static_cast(wParam), static_cast(lParam)); + return pdoc->decorations->Start(static_cast(wParam), lParam); case SCI_INDICATOREND: - return pdoc->decorations.End(static_cast(wParam), static_cast(lParam)); + return pdoc->decorations->End(static_cast(wParam), lParam); case SCI_LINEDOWN: case SCI_LINEDOWNEXTEND: @@ -7250,6 +7537,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_LINECUT: case SCI_LINEDELETE: case SCI_LINETRANSPOSE: + case SCI_LINEREVERSE: case SCI_LINEDUPLICATE: case SCI_LOWERCASE: case SCI_UPPERCASE: @@ -7277,7 +7565,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return KeyCommand(iMessage); case SCI_BRACEHIGHLIGHT: - SetBraceHighlight(static_cast(wParam), static_cast(lParam), STYLE_BRACELIGHT); + SetBraceHighlight(static_cast(wParam), lParam, STYLE_BRACELIGHT); break; case SCI_BRACEHIGHLIGHTINDICATOR: @@ -7288,7 +7576,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_BRACEBADLIGHT: - SetBraceHighlight(static_cast(wParam), -1, STYLE_BRACEBAD); + SetBraceHighlight(static_cast(wParam), -1, STYLE_BRACEBAD); break; case SCI_BRACEBADLIGHTINDICATOR: @@ -7301,7 +7589,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_BRACEMATCH: // wParam is position of char to find brace for, // lParam is maximum amount of text to restyle to find it - return pdoc->BraceMatch(static_cast(wParam), static_cast(lParam)); + return pdoc->BraceMatch(static_cast(wParam), lParam); case SCI_GETVIEWEOL: return vs.viewEOL; @@ -7311,20 +7599,24 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; - case SCI_SETZOOM: - vs.zoomLevel = static_cast(wParam); - InvalidateStyleRedraw(); - NotifyZoom(); - break; + case SCI_SETZOOM: { + const int zoomLevel = static_cast(wParam); + if (zoomLevel != vs.zoomLevel) { + vs.zoomLevel = zoomLevel; + InvalidateStyleRedraw(); + NotifyZoom(); + } + break; + } case SCI_GETZOOM: return vs.zoomLevel; case SCI_GETEDGECOLUMN: - return vs.theEdge; + return vs.theEdge.column; case SCI_SETEDGECOLUMN: - vs.theEdge = static_cast(wParam); + vs.theEdge.column = static_cast(wParam); InvalidateStyleRedraw(); break; @@ -7337,40 +7629,63 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETEDGECOLOUR: - return vs.edgecolour.AsLong(); + return vs.theEdge.colour.AsInteger(); case SCI_SETEDGECOLOUR: - vs.edgecolour = ColourDesired(static_cast(wParam)); + vs.theEdge.colour = ColourDesired(static_cast(wParam)); InvalidateStyleRedraw(); break; + case SCI_MULTIEDGEADDLINE: + vs.theMultiEdge.push_back(EdgeProperties(wParam, lParam)); + InvalidateStyleRedraw(); + break; + + case SCI_MULTIEDGECLEARALL: + std::vector().swap(vs.theMultiEdge); // Free vector and memory, C++03 compatible + InvalidateStyleRedraw(); + break; + + case SCI_GETACCESSIBILITY: + return SC_ACCESSIBILITY_DISABLED; + + case SCI_SETACCESSIBILITY: + // May be implemented by platform code. + break; + case SCI_GETDOCPOINTER: return reinterpret_cast(pdoc); case SCI_SETDOCPOINTER: CancelModes(); - SetDocPointer(reinterpret_cast(lParam)); + SetDocPointer(static_cast(PtrFromSPtr(lParam))); return 0; case SCI_CREATEDOCUMENT: { - Document *doc = new Document(); + Document *doc = new Document(static_cast(lParam)); doc->AddRef(); + doc->Allocate(static_cast(wParam)); + pcs = ContractionStateCreate(pdoc->IsLarge()); return reinterpret_cast(doc); } case SCI_ADDREFDOCUMENT: - (reinterpret_cast(lParam))->AddRef(); + (static_cast(PtrFromSPtr(lParam)))->AddRef(); break; case SCI_RELEASEDOCUMENT: - (reinterpret_cast(lParam))->Release(); + (static_cast(PtrFromSPtr(lParam)))->Release(); break; + case SCI_GETDOCUMENTOPTIONS: + return pdoc->Options(); + case SCI_CREATELOADER: { - Document *doc = new Document(); + Document *doc = new Document(static_cast(lParam)); doc->AddRef(); - doc->Allocate(static_cast(wParam)); + doc->Allocate(static_cast(wParam)); doc->SetUndoCollection(false); + pcs = ContractionStateCreate(pdoc->IsLarge()); return reinterpret_cast(static_cast(doc)); } @@ -7381,13 +7696,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETMODEVENTMASK: return modEventMask; + case SCI_SETCOMMANDEVENTS: + commandEvents = static_cast(wParam); + return 0; + + case SCI_GETCOMMANDEVENTS: + return commandEvents; + case SCI_CONVERTEOLS: pdoc->ConvertLineEnds(static_cast(wParam)); SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document return 0; case SCI_SETLENGTHFORENCODE: - lengthForEncode = static_cast(wParam); + lengthForEncode = static_cast(wParam); return 0; case SCI_SELECTIONISRECTANGLE: @@ -7402,10 +7724,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SC_SEL_RECTANGLE: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selRectangle)); sel.selType = Selection::selRectangle; + sel.Rectangular() = sel.RangeMain(); // adjust current selection break; case SC_SEL_LINES: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selLines)); sel.selType = Selection::selLines; + SetSelection(sel.RangeMain().caret, sel.RangeMain().anchor); // adjust current selection break; case SC_SEL_THIN: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selThin)); @@ -7431,12 +7755,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { default: // ?! return SC_SEL_STREAM; } + case SCI_GETMOVEEXTENDSSELECTION: + return sel.MoveExtends(); case SCI_GETLINESELSTARTPOSITION: case SCI_GETLINESELENDPOSITION: { - SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(static_cast(wParam))), - SelectionPosition(pdoc->LineEnd(static_cast(wParam)))); + const SelectionSegment segmentLine( + SelectionPosition(pdoc->LineStart(static_cast(wParam))), + SelectionPosition(pdoc->LineEnd(static_cast(wParam)))); for (size_t r=0; r(wParam); DisplayCursor(Window::cursorText); @@ -7489,12 +7828,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.controlCharSymbol; case SCI_SETREPRESENTATION: - reprs.SetRepresentation(reinterpret_cast(wParam), CharPtrFromSPtr(lParam)); + reprs.SetRepresentation(ConstCharPtrFromUPtr(wParam), ConstCharPtrFromSPtr(lParam)); break; case SCI_GETREPRESENTATION: { const Representation *repr = reprs.RepresentationFromCharacter( - reinterpret_cast(wParam), UTF8MaxBytes); + ConstCharPtrFromUPtr(wParam), UTF8MaxBytes); if (repr) { return StringResult(lParam, repr->stringRep.c_str()); } @@ -7502,7 +7841,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { } case SCI_CLEARREPRESENTATION: - reprs.ClearRepresentation(reinterpret_cast(wParam)); + reprs.ClearRepresentation(ConstCharPtrFromUPtr(wParam)); break; case SCI_STARTRECORD: @@ -7533,7 +7872,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETHOTSPOTACTIVEFORE: - return vs.hotspotColours.fore.AsLong(); + return vs.hotspotColours.fore.AsInteger(); case SCI_SETHOTSPOTACTIVEBACK: vs.hotspotColours.back = ColourOptional(wParam, lParam); @@ -7541,7 +7880,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETHOTSPOTACTIVEBACK: - return vs.hotspotColours.back.AsLong(); + return vs.hotspotColours.back.AsInteger(); case SCI_SETHOTSPOTACTIVEUNDERLINE: vs.hotspotUnderline = wParam != 0; @@ -7570,7 +7909,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return reinterpret_cast(pdoc->BufferPointer()); case SCI_GETRANGEPOINTER: - return reinterpret_cast(pdoc->RangePointer(static_cast(wParam), static_cast(lParam))); + return reinterpret_cast(pdoc->RangePointer( + static_cast(wParam), lParam)); case SCI_GETGAPPOSITION: return pdoc->GapPosition(); @@ -7607,29 +7947,29 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return marginOptions; case SCI_MARGINSETTEXT: - pdoc->MarginSetText(static_cast(wParam), CharPtrFromSPtr(lParam)); + pdoc->MarginSetText(static_cast(wParam), CharPtrFromSPtr(lParam)); break; case SCI_MARGINGETTEXT: { - const StyledText st = pdoc->MarginStyledText(static_cast(wParam)); + const StyledText st = pdoc->MarginStyledText(static_cast(wParam)); return BytesResult(lParam, reinterpret_cast(st.text), st.length); } case SCI_MARGINSETSTYLE: - pdoc->MarginSetStyle(static_cast(wParam), static_cast(lParam)); + pdoc->MarginSetStyle(static_cast(wParam), static_cast(lParam)); break; case SCI_MARGINGETSTYLE: { - const StyledText st = pdoc->MarginStyledText(static_cast(wParam)); + const StyledText st = pdoc->MarginStyledText(static_cast(wParam)); return st.style; } case SCI_MARGINSETSTYLES: - pdoc->MarginSetStyles(static_cast(wParam), reinterpret_cast(lParam)); + pdoc->MarginSetStyles(static_cast(wParam), ConstUCharPtrFromSPtr(lParam)); break; case SCI_MARGINGETSTYLES: { - const StyledText st = pdoc->MarginStyledText(static_cast(wParam)); + const StyledText st = pdoc->MarginStyledText(static_cast(wParam)); return BytesResult(lParam, st.styles, st.length); } @@ -7638,34 +7978,34 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_ANNOTATIONSETTEXT: - pdoc->AnnotationSetText(static_cast(wParam), CharPtrFromSPtr(lParam)); + pdoc->AnnotationSetText(static_cast(wParam), CharPtrFromSPtr(lParam)); break; case SCI_ANNOTATIONGETTEXT: { - const StyledText st = pdoc->AnnotationStyledText(static_cast(wParam)); + const StyledText st = pdoc->AnnotationStyledText(static_cast(wParam)); return BytesResult(lParam, reinterpret_cast(st.text), st.length); } case SCI_ANNOTATIONGETSTYLE: { - const StyledText st = pdoc->AnnotationStyledText(static_cast(wParam)); + const StyledText st = pdoc->AnnotationStyledText(static_cast(wParam)); return st.style; } case SCI_ANNOTATIONSETSTYLE: - pdoc->AnnotationSetStyle(static_cast(wParam), static_cast(lParam)); + pdoc->AnnotationSetStyle(static_cast(wParam), static_cast(lParam)); break; case SCI_ANNOTATIONSETSTYLES: - pdoc->AnnotationSetStyles(static_cast(wParam), reinterpret_cast(lParam)); + pdoc->AnnotationSetStyles(static_cast(wParam), ConstUCharPtrFromSPtr(lParam)); break; case SCI_ANNOTATIONGETSTYLES: { - const StyledText st = pdoc->AnnotationStyledText(static_cast(wParam)); + const StyledText st = pdoc->AnnotationStyledText(static_cast(wParam)); return BytesResult(lParam, st.styles, st.length); } case SCI_ANNOTATIONGETLINES: - return pdoc->AnnotationLines(static_cast(wParam)); + return pdoc->AnnotationLines(static_cast(wParam)); case SCI_ANNOTATIONCLEARALL: pdoc->AnnotationClearAll(); @@ -7694,7 +8034,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.AllocateExtendedStyles(static_cast(wParam)); case SCI_ADDUNDOACTION: - pdoc->AddUndoAction(static_cast(wParam), lParam & UNDO_MAY_COALESCE); + pdoc->AddUndoAction(static_cast(wParam), lParam & UNDO_MAY_COALESCE); break; case SCI_SETMOUSESELECTIONRECTANGULARSWITCH: @@ -7751,26 +8091,30 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CLEARSELECTIONS: sel.Clear(); + ContainerNeedsUpdate(SC_UPDATE_SELECTION); Redraw(); break; case SCI_SETSELECTION: - sel.SetSelection(SelectionRange(static_cast(wParam), static_cast(lParam))); + sel.SetSelection(SelectionRange(static_cast(wParam), lParam)); Redraw(); break; case SCI_ADDSELECTION: - sel.AddSelection(SelectionRange(static_cast(wParam), static_cast(lParam))); + sel.AddSelection(SelectionRange(static_cast(wParam), lParam)); + ContainerNeedsUpdate(SC_UPDATE_SELECTION); Redraw(); break; case SCI_DROPSELECTIONN: - sel.DropSelection(static_cast(wParam)); + sel.DropSelection(static_cast(wParam)); + ContainerNeedsUpdate(SC_UPDATE_SELECTION); Redraw(); break; case SCI_SETMAINSELECTION: - sel.SetMain(static_cast(wParam)); + sel.SetMain(static_cast(wParam)); + ContainerNeedsUpdate(SC_UPDATE_SELECTION); Redraw(); break; @@ -7778,49 +8122,29 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Main(); case SCI_SETSELECTIONNCARET: - sel.Range(wParam).caret.SetPosition(static_cast(lParam)); - Redraw(); + case SCI_SETSELECTIONNANCHOR: + case SCI_SETSELECTIONNCARETVIRTUALSPACE: + case SCI_SETSELECTIONNANCHORVIRTUALSPACE: + case SCI_SETSELECTIONNSTART: + case SCI_SETSELECTIONNEND: + SetSelectionNMessage(iMessage, wParam, lParam); break; case SCI_GETSELECTIONNCARET: return sel.Range(wParam).caret.Position(); - case SCI_SETSELECTIONNANCHOR: - sel.Range(wParam).anchor.SetPosition(static_cast(lParam)); - Redraw(); - break; case SCI_GETSELECTIONNANCHOR: return sel.Range(wParam).anchor.Position(); - case SCI_SETSELECTIONNCARETVIRTUALSPACE: - sel.Range(wParam).caret.SetVirtualSpace(static_cast(lParam)); - Redraw(); - break; - case SCI_GETSELECTIONNCARETVIRTUALSPACE: return sel.Range(wParam).caret.VirtualSpace(); - case SCI_SETSELECTIONNANCHORVIRTUALSPACE: - sel.Range(wParam).anchor.SetVirtualSpace(static_cast(lParam)); - Redraw(); - break; - case SCI_GETSELECTIONNANCHORVIRTUALSPACE: return sel.Range(wParam).anchor.VirtualSpace(); - case SCI_SETSELECTIONNSTART: - sel.Range(wParam).anchor.SetPosition(static_cast(lParam)); - Redraw(); - break; - case SCI_GETSELECTIONNSTART: return sel.Range(wParam).Start().Position(); - case SCI_SETSELECTIONNEND: - sel.Range(wParam).caret.SetPosition(static_cast(lParam)); - Redraw(); - break; - case SCI_GETSELECTIONNEND: return sel.Range(wParam).End().Position(); @@ -7828,7 +8152,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().caret.SetPosition(static_cast(wParam)); + sel.Rectangular().caret.SetPosition(static_cast(wParam)); SetRectangularRange(); Redraw(); break; @@ -7840,7 +8164,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().anchor.SetPosition(static_cast(wParam)); + sel.Rectangular().anchor.SetPosition(static_cast(wParam)); SetRectangularRange(); Redraw(); break; @@ -7852,7 +8176,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().caret.SetVirtualSpace(static_cast(wParam)); + sel.Rectangular().caret.SetVirtualSpace(static_cast(wParam)); SetRectangularRange(); Redraw(); break; @@ -7864,7 +8188,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().anchor.SetVirtualSpace(static_cast(wParam)); + sel.Rectangular().anchor.SetVirtualSpace(static_cast(wParam)); SetRectangularRange(); Redraw(); break; @@ -7880,12 +8204,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return virtualSpaceOptions; case SCI_SETADDITIONALSELFORE: - vs.selAdditionalForeground = ColourDesired(static_cast(wParam)); + vs.selAdditionalForeground = ColourDesired(static_cast(wParam)); InvalidateStyleRedraw(); break; case SCI_SETADDITIONALSELBACK: - vs.selAdditionalBackground = ColourDesired(static_cast(wParam)); + vs.selAdditionalBackground = ColourDesired(static_cast(wParam)); InvalidateStyleRedraw(); break; @@ -7898,12 +8222,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.selAdditionalAlpha; case SCI_SETADDITIONALCARETFORE: - vs.additionalCaretColour = ColourDesired(static_cast(wParam)); + vs.additionalCaretColour = ColourDesired(static_cast(wParam)); InvalidateStyleRedraw(); break; case SCI_GETADDITIONALCARETFORE: - return vs.additionalCaretColour.AsLong(); + return vs.additionalCaretColour.AsInteger(); case SCI_ROTATESELECTION: sel.RotateMain(); @@ -7912,7 +8236,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SWAPMAINANCHORCARET: InvalidateSelection(sel.RangeMain()); - sel.RangeMain() = SelectionRange(sel.RangeMain().anchor, sel.RangeMain().caret); + sel.RangeMain().Swap(); break; case SCI_MULTIPLESELECTADDNEXT: @@ -7924,7 +8248,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_CHANGELEXERSTATE: - pdoc->ChangeLexerState(static_cast(wParam), static_cast(lParam)); + pdoc->ChangeLexerState(static_cast(wParam), lParam); break; case SCI_SETIDENTIFIER: @@ -7942,11 +8266,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return technology; case SCI_COUNTCHARACTERS: - return pdoc->CountCharacters(static_cast(wParam), static_cast(lParam)); + return pdoc->CountCharacters(static_cast(wParam), lParam); + + case SCI_COUNTCODEUNITS: + return pdoc->CountUTF16(static_cast(wParam), lParam); default: return DefWndProc(iMessage, wParam, lParam); } //Platform::DebugPrintf("end wnd proc\n"); - return 0l; + return 0; } diff --git a/dep/scintilla/scintilla-3.6.0/src/Editor.h b/dep/scintilla/scintilla-3.10.6/src/Editor.h similarity index 54% rename from dep/scintilla/scintilla-3.6.0/src/Editor.h rename to dep/scintilla/scintilla-3.10.6/src/Editor.h index fdc86f9f..e8d1ed48 100644 --- a/dep/scintilla/scintilla-3.6.0/src/Editor.h +++ b/dep/scintilla/scintilla-3.10.6/src/Editor.h @@ -8,9 +8,7 @@ #ifndef EDITOR_H #define EDITOR_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif /** */ @@ -21,7 +19,7 @@ public: enum {tickSize = 100}; TickerID tickerID; - Timer(); + Timer() noexcept; }; /** @@ -31,12 +29,12 @@ public: bool state; IdlerID idlerID; - Idler(); + Idler() noexcept; }; /** * When platform has a way to generate an event before painting, - * accumulate needed styling range and other work items in + * accumulate needed styling range and other work items in * WorkNeeded to avoid unnecessary work inside paint handler */ class WorkNeeded { @@ -46,17 +44,15 @@ public: workStyle=1, workUpdateUI=2 }; - bool active; enum workItems items; - Position upTo; + Sci::Position upTo; - WorkNeeded() : active(false), items(workNone), upTo(0) {} - void Reset() { - active = false; + WorkNeeded() noexcept : items(workNone), upTo(0) {} + void Reset() noexcept { items = workNone; upTo = 0; } - void Need(workItems items_, Position pos) { + void Need(workItems items_, Sci::Position pos) noexcept { if ((items_ & workStyle) && (upTo < pos)) upTo = pos; items = static_cast(items | items_); @@ -73,10 +69,8 @@ public: bool lineCopy; int codePage; int characterSet; - SelectionText() : rectangular(false), lineCopy(false), codePage(0), characterSet(0) {} - ~SelectionText() { - } - void Clear() { + SelectionText() noexcept : rectangular(false), lineCopy(false), codePage(0), characterSet(0) {} + void Clear() noexcept { s.clear(); rectangular = false; lineCopy = false; @@ -94,16 +88,16 @@ public: void Copy(const SelectionText &other) { Copy(other.s, other.codePage, other.characterSet, other.rectangular, other.lineCopy); } - const char *Data() const { + const char *Data() const noexcept { return s.c_str(); } - size_t Length() const { + size_t Length() const noexcept { return s.length(); } - size_t LengthWithTerminator() const { + size_t LengthWithTerminator() const noexcept { return s.length() + 1; } - bool Empty() const { + bool Empty() const noexcept { return s.empty(); } private: @@ -117,24 +111,24 @@ private: struct WrapPending { // The range of lines that need to be wrapped enum { lineLarge = 0x7ffffff }; - int start; // When there are wraps pending, will be in document range - int end; // May be lineLarge to indicate all of document after start - WrapPending() { + Sci::Line start; // When there are wraps pending, will be in document range + Sci::Line end; // May be lineLarge to indicate all of document after start + WrapPending() noexcept { start = lineLarge; end = lineLarge; } - void Reset() { + void Reset() noexcept { start = lineLarge; end = lineLarge; } - void Wrapped(int line) { + void Wrapped(Sci::Line line) noexcept { if (start == line) start++; } - bool NeedsWrap() const { + bool NeedsWrap() const noexcept { return start < end; } - bool AddRange(int lineStart, int lineEnd) { + bool AddRange(Sci::Line lineStart, Sci::Line lineEnd) noexcept { const bool neededWrap = NeedsWrap(); bool changed = false; if (start > lineStart) { @@ -152,10 +146,6 @@ struct WrapPending { /** */ class Editor : public EditModel, public DocWatcher { - // Private so Editor objects can not be copied - explicit Editor(const Editor &); - Editor &operator=(const Editor &); - protected: // ScintillaBase subclass needs access to much of Editor /** On GTK+, Scintilla is a container widget holding two scroll bars @@ -178,6 +168,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool hasFocus; bool mouseDownCaptures; + bool mouseWheelCaptures; int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret bool horizontalScrollBarVisible; @@ -212,19 +203,19 @@ protected: // ScintillaBase subclass needs access to much of Editor enum { ddNone, ddInitial, ddDragging } inDragDrop; bool dropWentOutside; SelectionPosition posDrop; - int hotSpotClickPos; + Sci::Position hotSpotClickPos; int lastXChosen; - int lineAnchorPos; - int originalAnchorPos; - int wordSelectAnchorStartPos; - int wordSelectAnchorEndPos; - int wordSelectInitialCaretPos; - int targetStart; - int targetEnd; + Sci::Position lineAnchorPos; + Sci::Position originalAnchorPos; + Sci::Position wordSelectAnchorStartPos; + Sci::Position wordSelectAnchorEndPos; + Sci::Position wordSelectInitialCaretPos; + Sci::Position targetStart; + Sci::Position targetEnd; int searchFlags; - int topLine; - int posTopLine; - int lengthForEncode; + Sci::Line topLine; + Sci::Position posTopLine; + Sci::Position lengthForEncode; int needUpdateUI; @@ -234,8 +225,11 @@ protected: // ScintillaBase subclass needs access to much of Editor bool paintingAllText; bool willRedrawAll; WorkNeeded workNeeded; + int idleStyling; + bool needIdleStyling; int modEventMask; + bool commandEvents; SelectionText drag; @@ -248,7 +242,7 @@ protected: // ScintillaBase subclass needs access to much of Editor int visiblePolicy; int visibleSlop; - int searchAnchor; + Sci::Position searchAnchor; bool recordingMacro; @@ -256,11 +250,17 @@ protected: // ScintillaBase subclass needs access to much of Editor // Wrapping support WrapPending wrapPending; + ActionDuration durationWrapOneLine; bool convertPastes; Editor(); - virtual ~Editor(); + // Deleted so Editor objects can not be copied. + Editor(const Editor &) = delete; + Editor(Editor &&) = delete; + Editor &operator=(const Editor &) = delete; + Editor &operator=(Editor &&) = delete; + // ~Editor() in public section virtual void Initialise() = 0; virtual void Finalise(); @@ -273,40 +273,39 @@ protected: // ScintillaBase subclass needs access to much of Editor // The top left visible point in main window coordinates. Will be 0,0 except for // scroll views where it will be equivalent to the current scroll position. - virtual Point GetVisibleOriginInMain() const; - Point DocumentPointFromView(Point ptView) const; // Convert a point from view space to document - int TopLineOfMain() const; // Return the line at Main's y coordinate 0 + Point GetVisibleOriginInMain() const override; + PointDocument DocumentPointFromView(Point ptView) const; // Convert a point from view space to document + Sci::Line TopLineOfMain() const override; // Return the line at Main's y coordinate 0 virtual PRectangle GetClientRectangle() const; virtual PRectangle GetClientDrawingRectangle(); PRectangle GetTextRectangle() const; - virtual int LinesOnScreen() const; - int LinesToScroll() const; - int MaxScrollPos() const; + Sci::Line LinesOnScreen() const override; + Sci::Line LinesToScroll() const; + Sci::Line MaxScrollPos() const; SelectionPosition ClampPositionIntoDocument(SelectionPosition sp) const; - Point LocationFromPosition(SelectionPosition pos); - Point LocationFromPosition(int pos); - int XFromPosition(int pos); + Point LocationFromPosition(SelectionPosition pos, PointEnd pe=peDefault); + Point LocationFromPosition(Sci::Position pos, PointEnd pe=peDefault); int XFromPosition(SelectionPosition sp); SelectionPosition SPositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false, bool virtualSpace=true); - int PositionFromLocation(Point pt, bool canReturnInvalid = false, bool charPosition = false); - SelectionPosition SPositionFromLineX(int lineDoc, int x); - int PositionFromLineX(int line, int x); - int LineFromLocation(Point pt) const; - void SetTopLine(int topLineNew); + Sci::Position PositionFromLocation(Point pt, bool canReturnInvalid = false, bool charPosition = false); + SelectionPosition SPositionFromLineX(Sci::Line lineDoc, int x); + Sci::Position PositionFromLineX(Sci::Line lineDoc, int x); + Sci::Line LineFromLocation(Point pt) const; + void SetTopLine(Sci::Line topLineNew); virtual bool AbandonPaint(); virtual void RedrawRect(PRectangle rc); virtual void DiscardOverdraw(); virtual void Redraw(); - void RedrawSelMargin(int line=-1, bool allAfter=false); + void RedrawSelMargin(Sci::Line line=-1, bool allAfter=false); PRectangle RectangleFromRange(Range r, int overlap); - void InvalidateRange(int start, int end); + void InvalidateRange(Sci::Position start, Sci::Position end); - bool UserVirtualSpace() const { + bool UserVirtualSpace() const noexcept { return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0); } - int CurrentPosition() const; + Sci::Position CurrentPosition() const; bool SelectionEmpty() const; SelectionPosition SelectionStart(); SelectionPosition SelectionEnd(); @@ -314,41 +313,42 @@ protected: // ScintillaBase subclass needs access to much of Editor void ThinRectangularRange(); void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false); void InvalidateWholeSelection(); + SelectionRange LineSelectionRange(SelectionPosition currentPos_, SelectionPosition anchor_) const; void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_); - void SetSelection(int currentPos_, int anchor_); + void SetSelection(Sci::Position currentPos_, Sci::Position anchor_); void SetSelection(SelectionPosition currentPos_); void SetSelection(int currentPos_); void SetEmptySelection(SelectionPosition currentPos_); - void SetEmptySelection(int currentPos_); + void SetEmptySelection(Sci::Position currentPos_); enum AddNumber { addOne, addEach }; void MultipleSelectAdd(AddNumber addNumber); - bool RangeContainsProtected(int start, int end) const; + bool RangeContainsProtected(Sci::Position start, Sci::Position end) const; bool SelectionContainsProtected(); - int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const; - SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const; + Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd=true) const; + SelectionPosition MovePositionOutsideChar(SelectionPosition pos, Sci::Position moveDir, bool checkLineEnd=true) const; void MovedCaret(SelectionPosition newPos, SelectionPosition previousPos, bool ensureVisible); void MovePositionTo(SelectionPosition newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true); - void MovePositionTo(int newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true); + void MovePositionTo(Sci::Position newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true); SelectionPosition MovePositionSoVisible(SelectionPosition pos, int moveDir); - SelectionPosition MovePositionSoVisible(int pos, int moveDir); + SelectionPosition MovePositionSoVisible(Sci::Position pos, int moveDir); Point PointMainCaret(); void SetLastXChosen(); - void ScrollTo(int line, bool moveThumb=true); - virtual void ScrollText(int linesToMove); + void ScrollTo(Sci::Line line, bool moveThumb=true); + virtual void ScrollText(Sci::Line linesToMove); void HorizontalScrollTo(int xPos); void VerticalCentreCaret(); void MoveSelectedLines(int lineDelta); void MoveSelectedLinesUp(); void MoveSelectedLinesDown(); void MoveCaretInsideView(bool ensureVisible=true); - int DisplayFromPosition(int pos); + Sci::Line DisplayFromPosition(Sci::Position pos); struct XYScrollPosition { int xOffset; - int topLine; - XYScrollPosition(int xOffset_, int topLine_) : xOffset(xOffset_), topLine(topLine_) {} - bool operator==(const XYScrollPosition &other) const { + Sci::Line topLine; + XYScrollPosition(int xOffset_, Sci::Line topLine_) noexcept : xOffset(xOffset_), topLine(topLine_) {} + bool operator==(const XYScrollPosition &other) const noexcept { return (xOffset == other.xOffset) && (topLine == other.topLine); } }; @@ -365,128 +365,126 @@ protected: // ScintillaBase subclass needs access to much of Editor void DropCaret(); void CaretSetPeriod(int period); void InvalidateCaret(); + virtual void NotifyCaretMove(); virtual void UpdateSystemCaret(); - bool Wrapping() const; - void NeedWrapping(int docLineStart=0, int docLineEnd=WrapPending::lineLarge); - bool WrapOneLine(Surface *surface, int lineToWrap); - enum wrapScope {wsAll, wsVisible, wsIdle}; - bool WrapLines(enum wrapScope ws); + bool Wrapping() const noexcept; + void NeedWrapping(Sci::Line docLineStart=0, Sci::Line docLineEnd=WrapPending::lineLarge); + bool WrapOneLine(Surface *surface, Sci::Line lineToWrap); + enum class WrapScope {wsAll, wsVisible, wsIdle}; + bool WrapLines(WrapScope ws); void LinesJoin(); void LinesSplit(int pixelWidth); - void PaintSelMargin(Surface *surface, PRectangle &rc); + void PaintSelMargin(Surface *surfaceWindow, const PRectangle &rc); void RefreshPixMaps(Surface *surfaceWindow); void Paint(Surface *surfaceWindow, PRectangle rcArea); - long FormatRange(bool draw, Sci_RangeToFormat *pfr); + Sci::Position FormatRange(bool draw, const Sci_RangeToFormat *pfr); int TextWidth(int style, const char *text); virtual void SetVerticalScrollPos() = 0; virtual void SetHorizontalScrollPos() = 0; - virtual bool ModifyScrollBars(int nMax, int nPage) = 0; + virtual bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) = 0; virtual void ReconfigureScrollBars(); void SetScrollBars(); void ChangeSize(); void FilterSelections(); - int InsertSpace(int position, unsigned int spaces); + Sci::Position RealizeVirtualSpace(Sci::Position position, Sci::Position virtualSpace); + SelectionPosition RealizeVirtualSpace(const SelectionPosition &position); void AddChar(char ch); virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false); - void FillVirtualSpace(); - void InsertPaste(const char *text, int len); + void ClearBeforeTentativeStart(); + void InsertPaste(const char *text, Sci::Position len); enum PasteShape { pasteStream=0, pasteRectangular = 1, pasteLine = 2 }; - void InsertPasteShape(const char *text, int len, PasteShape shape); + void InsertPasteShape(const char *text, Sci::Position len, PasteShape shape); void ClearSelection(bool retainMultipleSelections = false); void ClearAll(); void ClearDocumentStyle(); - void Cut(); - void PasteRectangular(SelectionPosition pos, const char *ptr, int len); + virtual void Cut(); + void PasteRectangular(SelectionPosition pos, const char *ptr, Sci::Position len); virtual void Copy() = 0; virtual void CopyAllowLine(); virtual bool CanPaste(); virtual void Paste() = 0; void Clear(); - void SelectAll(); - void Undo(); - void Redo(); + virtual void SelectAll(); + virtual void Undo(); + virtual void Redo(); void DelCharBack(bool allowLineStartDeletion); virtual void ClaimSelection() = 0; - static int ModifierFlags(bool shift, bool ctrl, bool alt, bool meta=false); + static int ModifierFlags(bool shift, bool ctrl, bool alt, bool meta=false, bool super=false) noexcept; virtual void NotifyChange() = 0; virtual void NotifyFocus(bool focus); virtual void SetCtrlID(int identifier); virtual int GetCtrlID() { return ctrlID; } virtual void NotifyParent(SCNotification scn) = 0; - virtual void NotifyStyleToNeeded(int endStyleNeeded); + virtual void NotifyStyleToNeeded(Sci::Position endStyleNeeded); void NotifyChar(int ch); void NotifySavePoint(bool isSavePoint); void NotifyModifyAttempt(); virtual void NotifyDoubleClick(Point pt, int modifiers); - virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt); - void NotifyHotSpotClicked(int position, int modifiers); - void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt); - void NotifyHotSpotDoubleClicked(int position, int modifiers); - void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt); - void NotifyHotSpotReleaseClick(int position, int modifiers); - void NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt); + void NotifyHotSpotClicked(Sci::Position position, int modifiers); + void NotifyHotSpotDoubleClicked(Sci::Position position, int modifiers); + void NotifyHotSpotReleaseClick(Sci::Position position, int modifiers); bool NotifyUpdateUI(); void NotifyPainted(); - void NotifyIndicatorClick(bool click, int position, int modifiers); - void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt); + void NotifyIndicatorClick(bool click, Sci::Position position, int modifiers); bool NotifyMarginClick(Point pt, int modifiers); - bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); - void NotifyNeedShown(int pos, int len); + bool NotifyMarginRightClick(Point pt, int modifiers); + void NotifyNeedShown(Sci::Position pos, Sci::Position len); void NotifyDwelling(Point pt, bool state); void NotifyZoom(); - void NotifyModifyAttempt(Document *document, void *userData); - void NotifySavePoint(Document *document, void *userData, bool atSavePoint); + void NotifyModifyAttempt(Document *document, void *userData) override; + void NotifySavePoint(Document *document, void *userData, bool atSavePoint) override; void CheckModificationForWrap(DocModification mh); - void NotifyModified(Document *document, DocModification mh, void *userData); - void NotifyDeleted(Document *document, void *userData); - void NotifyStyleNeeded(Document *doc, void *userData, int endPos); - void NotifyLexerChanged(Document *doc, void *userData); - void NotifyErrorOccurred(Document *doc, void *userData, int status); + void NotifyModified(Document *document, DocModification mh, void *userData) override; + void NotifyDeleted(Document *document, void *userData) noexcept override; + void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endStyleNeeded) override; + void NotifyLexerChanged(Document *doc, void *userData) override; + void NotifyErrorOccurred(Document *doc, void *userData, int status) override; void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam); - void ContainerNeedsUpdate(int flags); + void ContainerNeedsUpdate(int flags) noexcept; void PageMove(int direction, Selection::selTypes selt=Selection::noSel, bool stuttered = false); enum { cmSame, cmUpper, cmLower }; virtual std::string CaseMapString(const std::string &s, int caseMapping); void ChangeCaseOfSelection(int caseMapping); void LineTranspose(); + void LineReverse(); void Duplicate(bool forLine); virtual void CancelModes(); void NewLine(); SelectionPosition PositionUpOrDown(SelectionPosition spStart, int direction, int lastX); void CursorUpOrDown(int direction, Selection::selTypes selt); void ParaUpOrDown(int direction, Selection::selTypes selt); - int StartEndDisplayLine(int pos, bool start); - int VCHomeDisplayPosition(int position); - int VCHomeWrapPosition(int position); - int LineEndWrapPosition(int position); + Range RangeDisplayLine(Sci::Line lineVisible); + Sci::Position StartEndDisplayLine(Sci::Position pos, bool start); + Sci::Position VCHomeDisplayPosition(Sci::Position position); + Sci::Position VCHomeWrapPosition(Sci::Position position); + Sci::Position LineEndWrapPosition(Sci::Position position); int HorizontalMove(unsigned int iMessage); int DelWordOrLine(unsigned int iMessage); virtual int KeyCommand(unsigned int iMessage); virtual int KeyDefault(int /* key */, int /*modifiers*/); int KeyDownWithModifiers(int key, int modifiers, bool *consumed); - int KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed=0); void Indent(bool forwards); virtual CaseFolder *CaseFolderForEncoding(); - long FindText(uptr_t wParam, sptr_t lParam); + Sci::Position FindText(uptr_t wParam, sptr_t lParam); void SearchAnchor(); - long SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam); - long SearchInTarget(const char *text, int length); - void GoToLine(int lineNo); + Sci::Position SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam); + Sci::Position SearchInTarget(const char *text, Sci::Position length); + void GoToLine(Sci::Line lineNo); virtual void CopyToClipboard(const SelectionText &selectedText) = 0; - std::string RangeText(int start, int end) const; + std::string RangeText(Sci::Position start, Sci::Position end) const; void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false); - void CopyRangeToClipboard(int start, int end); - void CopyText(int length, const char *text); + void CopyRangeToClipboard(Sci::Position start, Sci::Position end); + void CopyText(size_t length, const char *text); void SetDragPosition(SelectionPosition newPos); virtual void DisplayCursor(Window::Cursor c); virtual bool DragThreshold(Point ptStart, Point ptNow); @@ -494,27 +492,23 @@ protected: // ScintillaBase subclass needs access to much of Editor void DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular); void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular); /** PositionInSelection returns true if position in selection. */ - bool PositionInSelection(int pos); + bool PositionInSelection(Sci::Position pos); bool PointInSelection(Point pt); bool PointInSelMargin(Point pt) const; - Window::Cursor GetMarginCursor(Point pt) const; - void TrimAndSetSelection(int currentPos_, int anchor_); - void LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine); - void WordSelection(int pos); + Window::Cursor GetMarginCursor(Point pt) const noexcept; + void TrimAndSetSelection(Sci::Position currentPos_, Sci::Position anchor_); + void LineSelection(Sci::Position lineCurrentPos_, Sci::Position lineAnchorPos_, bool wholeLine); + void WordSelection(Sci::Position pos); void DwellEnd(bool mouseMoved); void MouseLeave(); virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers); - virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); - void ButtonMoveWithModifiers(Point pt, int modifiers); - void ButtonMove(Point pt); - void ButtonUp(Point pt, unsigned int curTime, bool ctrl); + virtual void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers); + void ButtonMoveWithModifiers(Point pt, unsigned int curTime, int modifiers); + void ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers); - void Tick(); bool Idle(); - virtual void SetTicking(bool on); enum TickReason { tickCaret, tickScroll, tickWiden, tickDwell, tickPlatform }; virtual void TickFor(TickReason reason); - virtual bool FineTickerAvailable(); virtual bool FineTickerRunning(TickReason reason); virtual void FineTickerStart(TickReason reason, int millis, int tolerance); virtual void FineTickerCancel(TickReason reason); @@ -523,58 +517,92 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual bool HaveMouseCapture() = 0; void SetFocusState(bool focusState); - int PositionAfterArea(PRectangle rcArea) const; - void StyleToPositionInView(Position pos); + Sci::Position PositionAfterArea(PRectangle rcArea) const; + void StyleToPositionInView(Sci::Position pos); + Sci::Position PositionAfterMaxStyling(Sci::Position posMax, bool scrolling) const; + void StartIdleStyling(bool truncatedLastStyling); + void StyleAreaBounded(PRectangle rcArea, bool scrolling); + bool SynchronousStylingToVisible() const noexcept { + return (idleStyling == SC_IDLESTYLING_NONE) || (idleStyling == SC_IDLESTYLING_AFTERVISIBLE); + } + void IdleStyling(); virtual void IdleWork(); - virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo=0); + virtual void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo=0); virtual bool PaintContains(PRectangle rc); bool PaintContainsMargin(); void CheckForChangeOutsidePaint(Range r); - void SetBraceHighlight(Position pos0, Position pos1, int matchStyle); + void SetBraceHighlight(Sci::Position pos0, Sci::Position pos1, int matchStyle); - void SetAnnotationHeights(int start, int end); + void SetAnnotationHeights(Sci::Line start, Sci::Line end); virtual void SetDocPointer(Document *document); void SetAnnotationVisible(int visible); - int ExpandLine(int line); - void SetFoldExpanded(int lineDoc, bool expanded); - void FoldLine(int line, int action); - void FoldExpand(int line, int action, int level); - int ContractedFoldNext(int lineStart) const; - void EnsureLineVisible(int lineDoc, bool enforcePolicy); - void FoldChanged(int line, int levelNow, int levelPrev); - void NeedShown(int pos, int len); + Sci::Line ExpandLine(Sci::Line line); + void SetFoldExpanded(Sci::Line lineDoc, bool expanded); + void FoldLine(Sci::Line line, int action); + void FoldExpand(Sci::Line line, int action, int level); + Sci::Line ContractedFoldNext(Sci::Line lineStart) const; + void EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy); + void FoldChanged(Sci::Line line, int levelNow, int levelPrev); + void NeedShown(Sci::Position pos, Sci::Position len); void FoldAll(int action); - int GetTag(char *tagValue, int tagNumber); - int ReplaceTarget(bool replacePatterns, const char *text, int length=-1); + Sci::Position GetTag(char *tagValue, int tagNumber); + Sci::Position ReplaceTarget(bool replacePatterns, const char *text, Sci::Position length=-1); - bool PositionIsHotspot(int position) const; + bool PositionIsHotspot(Sci::Position position) const; bool PointIsHotspot(Point pt); - void SetHotSpotRange(Point *pt); - Range GetHotSpotRange() const; - void SetHoverIndicatorPosition(int position); + void SetHotSpotRange(const Point *pt); + Range GetHotSpotRange() const noexcept override; + void SetHoverIndicatorPosition(Sci::Position position); void SetHoverIndicatorPoint(Point pt); - int CodePage() const; + int CodePage() const noexcept; virtual bool ValidCodePage(int /* codePage */) const { return true; } - int WrapCount(int line); - void AddStyledText(char *buffer, int appendLength); + Sci::Line WrapCount(Sci::Line line); + void AddStyledText(const char *buffer, Sci::Position appendLength); virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0; + bool ValidMargin(uptr_t wParam) const noexcept; void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam); sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam); + void SetSelectionNMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam); - static const char *StringFromEOLMode(int eolMode); + static const char *StringFromEOLMode(int eolMode) noexcept; - static sptr_t StringResult(sptr_t lParam, const char *val); - static sptr_t BytesResult(sptr_t lParam, const unsigned char *val, size_t len); + // Coercion functions for transforming WndProc parameters into pointers + static void *PtrFromSPtr(sptr_t lParam) noexcept { + return reinterpret_cast(lParam); + } + static const char *ConstCharPtrFromSPtr(sptr_t lParam) noexcept { + return static_cast(PtrFromSPtr(lParam)); + } + static const unsigned char *ConstUCharPtrFromSPtr(sptr_t lParam) noexcept { + return static_cast(PtrFromSPtr(lParam)); + } + static char *CharPtrFromSPtr(sptr_t lParam) noexcept { + return static_cast(PtrFromSPtr(lParam)); + } + static unsigned char *UCharPtrFromSPtr(sptr_t lParam) noexcept { + return static_cast(PtrFromSPtr(lParam)); + } + static void *PtrFromUPtr(uptr_t wParam) noexcept { + return reinterpret_cast(wParam); + } + static const char *ConstCharPtrFromUPtr(uptr_t wParam) noexcept { + return static_cast(PtrFromUPtr(wParam)); + } + + static sptr_t StringResult(sptr_t lParam, const char *val) noexcept; + static sptr_t BytesResult(sptr_t lParam, const unsigned char *val, size_t len) noexcept; public: + ~Editor() override; + // Public so the COM thunks can access it. - bool IsUnicodeMode() const; + bool IsUnicodeMode() const noexcept; // Public so scintilla_send_message can use it. virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); // Public so scintilla_set_id can use it. @@ -582,7 +610,6 @@ public: // Public so COM methods for drag and drop can set it. int errorStatus; friend class AutoSurface; - friend class SelectionLineIterator; }; /** @@ -590,41 +617,39 @@ public: */ class AutoSurface { private: - Surface *surf; + std::unique_ptr surf; public: - AutoSurface(Editor *ed, int technology = -1) : surf(0) { + AutoSurface(Editor *ed, int technology = -1) { if (ed->wMain.GetID()) { - surf = Surface::Allocate(technology != -1 ? technology : ed->technology); - if (surf) { - surf->Init(ed->wMain.GetID()); - surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage()); - surf->SetDBCSMode(ed->CodePage()); - } + surf.reset(Surface::Allocate(technology != -1 ? technology : ed->technology)); + surf->Init(ed->wMain.GetID()); + surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage()); + surf->SetDBCSMode(ed->CodePage()); } } - AutoSurface(SurfaceID sid, Editor *ed, int technology = -1) : surf(0) { + AutoSurface(SurfaceID sid, Editor *ed, int technology = -1) { if (ed->wMain.GetID()) { - surf = Surface::Allocate(technology != -1 ? technology : ed->technology); - if (surf) { - surf->Init(sid, ed->wMain.GetID()); - surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage()); - surf->SetDBCSMode(ed->CodePage()); - } + surf.reset(Surface::Allocate(technology != -1 ? technology : ed->technology)); + surf->Init(sid, ed->wMain.GetID()); + surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage()); + surf->SetDBCSMode(ed->CodePage()); } } + // Deleted so AutoSurface objects can not be copied. + AutoSurface(const AutoSurface &) = delete; + AutoSurface(AutoSurface &&) = delete; + void operator=(const AutoSurface &) = delete; + void operator=(AutoSurface &&) = delete; ~AutoSurface() { - delete surf; } - Surface *operator->() const { - return surf; + Surface *operator->() const noexcept { + return surf.get(); } - operator Surface *() const { - return surf; + operator Surface *() const noexcept { + return surf.get(); } }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.10.6/src/ElapsedPeriod.h b/dep/scintilla/scintilla-3.10.6/src/ElapsedPeriod.h new file mode 100644 index 00000000..6f8cdabd --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/ElapsedPeriod.h @@ -0,0 +1,35 @@ +// Scintilla source code edit control +/** @file ElapsedPeriod.h + ** Encapsulate C++ to simplify use. + **/ +// Copyright 2018 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef ELAPSEDPERIOD_H +#define ELAPSEDPERIOD_H + +namespace Scintilla { + +// Simplified access to high precision timing. +class ElapsedPeriod { + std::chrono::high_resolution_clock::time_point tp; +public: + /// Capture the moment + ElapsedPeriod() noexcept : tp(std::chrono::high_resolution_clock::now()) { + } + /// Return duration as floating point seconds + double Duration(bool reset=false) { + const std::chrono::high_resolution_clock::time_point tpNow = + std::chrono::high_resolution_clock::now(); + const std::chrono::duration stylingDuration = + std::chrono::duration_cast>(tpNow - tp); + if (reset) { + tp = tpNow; + } + return stylingDuration.count(); + } +}; + +} + +#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/ExternalLexer.cxx b/dep/scintilla/scintilla-3.10.6/src/ExternalLexer.cxx similarity index 59% rename from dep/scintilla/scintilla-3.6.0/src/ExternalLexer.cxx rename to dep/scintilla/scintilla-3.10.6/src/ExternalLexer.cxx index 2f81df7e..4f2ab987 100644 --- a/dep/scintilla/scintilla-3.6.0/src/ExternalLexer.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/ExternalLexer.cxx @@ -1,18 +1,18 @@ // Scintilla source code edit control /** @file ExternalLexer.cxx - ** Support external lexers in DLLs. + ** Support external lexers in DLLs or shared libraries. **/ // Copyright 2001 Simon Steele , portions copyright Neil Hodgson. // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include -#include +#include +#include +#include #include #include +#include +#include #include "Platform.h" @@ -24,11 +24,9 @@ #include "Catalogue.h" #include "ExternalLexer.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif -LexerManager *LexerManager::theInstance = NULL; +std::unique_ptr LexerManager::theInstance; //------------------------------------------ // @@ -47,46 +45,32 @@ void ExternalLexerModule::SetExternal(GetLexerFactoryFunction fFactory, int inde // //------------------------------------------ -LexerLibrary::LexerLibrary(const char *ModuleName) { - // Initialise some members... - first = NULL; - last = NULL; - +LexerLibrary::LexerLibrary(const char *moduleName_) { // Load the DLL - lib = DynamicLibrary::Load(ModuleName); + lib.reset(DynamicLibrary::Load(moduleName_)); if (lib->IsValid()) { - m_sModuleName = ModuleName; + moduleName = moduleName_; //Cannot use reinterpret_cast because: ANSI C++ forbids casting between pointers to functions and objects GetLexerCountFn GetLexerCount = (GetLexerCountFn)(sptr_t)lib->FindFunction("GetLexerCount"); if (GetLexerCount) { - ExternalLexerModule *lex; - LexerMinder *lm; - // Find functions in the DLL GetLexerNameFn GetLexerName = (GetLexerNameFn)(sptr_t)lib->FindFunction("GetLexerName"); GetLexerFactoryFunction fnFactory = (GetLexerFactoryFunction)(sptr_t)lib->FindFunction("GetLexerFactory"); - int nl = GetLexerCount(); + const int nl = GetLexerCount(); for (int i = 0; i < nl; i++) { // Assign a buffer for the lexer name. char lexname[100] = ""; GetLexerName(i, lexname, sizeof(lexname)); - lex = new ExternalLexerModule(SCLEX_AUTOMATIC, NULL, lexname, NULL); + ExternalLexerModule *lex = new ExternalLexerModule(SCLEX_AUTOMATIC, nullptr, lexname, nullptr); + // This is storing a second reference to lex in the Catalogue as well as in modules. + // TODO: Should use std::shared_ptr or similar to ensure allocation safety. Catalogue::AddLexerModule(lex); - // Create a LexerMinder so we don't leak the ExternalLexerModule... - lm = new LexerMinder; - lm->self = lex; - lm->next = NULL; - if (first != NULL) { - last->next = lm; - last = lm; - } else { - first = lm; - last = lm; - } + // Remember ExternalLexerModule so we don't leak it + modules.push_back(std::unique_ptr(lex)); // The external lexer needs to know how to call into its DLL to // do its lexing and folding, we tell it here. @@ -94,27 +78,9 @@ LexerLibrary::LexerLibrary(const char *ModuleName) { } } } - next = NULL; } LexerLibrary::~LexerLibrary() { - Release(); - delete lib; -} - -void LexerLibrary::Release() { - LexerMinder *lm; - LexerMinder *lmNext; - lm = first; - while (NULL != lm) { - lmNext = lm->next; - delete lm->self; - delete lm; - lm = lmNext; - } - - first = NULL; - last = NULL; } //------------------------------------------ @@ -126,20 +92,17 @@ void LexerLibrary::Release() { /// Return the single LexerManager instance... LexerManager *LexerManager::GetInstance() { if (!theInstance) - theInstance = new LexerManager; - return theInstance; + theInstance.reset(new LexerManager); + return theInstance.get(); } /// Delete any LexerManager instance... void LexerManager::DeleteInstance() { - delete theInstance; - theInstance = NULL; + theInstance.reset(); } /// protected constructor - this is a singleton... LexerManager::LexerManager() { - first = NULL; - last = NULL; } LexerManager::~LexerManager() { @@ -147,41 +110,21 @@ LexerManager::~LexerManager() { } void LexerManager::Load(const char *path) { - LoadLexerLibrary(path); -} - -void LexerManager::LoadLexerLibrary(const char *module) { - for (LexerLibrary *ll = first; ll; ll= ll->next) { - if (strcmp(ll->m_sModuleName.c_str(), module) == 0) + for (const std::unique_ptr &ll : libraries) { + if (ll->moduleName == path) return; } - LexerLibrary *lib = new LexerLibrary(module); - if (NULL != first) { - last->next = lib; - last = lib; - } else { - first = lib; - last = lib; - } + LexerLibrary *lib = new LexerLibrary(path); + libraries.push_back(std::unique_ptr(lib)); } void LexerManager::Clear() { - if (NULL != first) { - LexerLibrary *cur = first; - LexerLibrary *next; - while (cur) { - next = cur->next; - delete cur; - cur = next; - } - first = NULL; - last = NULL; - } + libraries.clear(); } //------------------------------------------ // -// LexerManager +// LMMinder -- trigger to clean up at exit. // //------------------------------------------ diff --git a/dep/scintilla/scintilla-3.6.0/src/ExternalLexer.h b/dep/scintilla/scintilla-3.10.6/src/ExternalLexer.h similarity index 61% rename from dep/scintilla/scintilla-3.6.0/src/ExternalLexer.h rename to dep/scintilla/scintilla-3.10.6/src/ExternalLexer.h index a85213e3..f0af9834 100644 --- a/dep/scintilla/scintilla-3.6.0/src/ExternalLexer.h +++ b/dep/scintilla/scintilla-3.10.6/src/ExternalLexer.h @@ -1,6 +1,6 @@ // Scintilla source code edit control /** @file ExternalLexer.h - ** Support external lexers in DLLs. + ** Support external lexers in DLLs or shared libraries. **/ // Copyright 2001 Simon Steele , portions copyright Neil Hodgson. // The License.txt file describes the conditions under which this software may be distributed. @@ -14,11 +14,8 @@ #define EXT_LEXER_DECL #endif -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif -typedef void*(EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index); typedef int (EXT_LEXER_DECL *GetLexerCountFn)(); typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength); typedef LexerFactoryFunction(EXT_LEXER_DECL *GetLexerFactoryFunction)(unsigned int Index); @@ -30,34 +27,23 @@ protected: std::string name; public: ExternalLexerModule(int language_, LexerFunction fnLexer_, - const char *languageName_=0, LexerFunction fnFolder_=0) : - LexerModule(language_, fnLexer_, 0, fnFolder_), - fneFactory(0), name(languageName_){ + const char *languageName_=nullptr, LexerFunction fnFolder_=nullptr) : + LexerModule(language_, fnLexer_, nullptr, fnFolder_), + fneFactory(nullptr), name(languageName_){ languageName = name.c_str(); } virtual void SetExternal(GetLexerFactoryFunction fFactory, int index); }; -/// LexerMinder points to an ExternalLexerModule - so we don't leak them. -class LexerMinder { -public: - ExternalLexerModule *self; - LexerMinder *next; -}; - -/// LexerLibrary exists for every External Lexer DLL, contains LexerMinders. +/// LexerLibrary exists for every External Lexer DLL, contains ExternalLexerModules. class LexerLibrary { - DynamicLibrary *lib; - LexerMinder *first; - LexerMinder *last; - + std::unique_ptr lib; + std::vector> modules; public: - explicit LexerLibrary(const char *ModuleName); + explicit LexerLibrary(const char *moduleName_); ~LexerLibrary(); - void Release(); - LexerLibrary *next; - std::string m_sModuleName; + std::string moduleName; }; /// LexerManager manages external lexers, contains LexerLibrarys. @@ -73,11 +59,8 @@ public: private: LexerManager(); - static LexerManager *theInstance; - - void LoadLexerLibrary(const char *module); - LexerLibrary *first; - LexerLibrary *last; + static std::unique_ptr theInstance; + std::vector> libraries; }; class LMMinder { @@ -85,8 +68,6 @@ public: ~LMMinder(); }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/FontQuality.h b/dep/scintilla/scintilla-3.10.6/src/FontQuality.h similarity index 93% rename from dep/scintilla/scintilla-3.6.0/src/FontQuality.h rename to dep/scintilla/scintilla-3.10.6/src/FontQuality.h index a0ae207f..85dca1e1 100644 --- a/dep/scintilla/scintilla-3.6.0/src/FontQuality.h +++ b/dep/scintilla/scintilla-3.10.6/src/FontQuality.h @@ -9,9 +9,7 @@ #ifndef FONTQUALITY_H #define FONTQUALITY_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif // These definitions match Scintilla.h #define SC_EFF_QUALITY_MASK 0xF @@ -24,8 +22,6 @@ namespace Scintilla { #define SCWIN_TECH_GDI 0 #define SCWIN_TECH_DIRECTWRITE 1 -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/Indicator.cxx b/dep/scintilla/scintilla-3.10.6/src/Indicator.cxx similarity index 51% rename from dep/scintilla/scintilla-3.6.0/src/Indicator.cxx rename to dep/scintilla/scintilla-3.10.6/src/Indicator.cxx index 7380d52d..5b1259fb 100644 --- a/dep/scintilla/scintilla-3.6.0/src/Indicator.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/Indicator.cxx @@ -5,56 +5,62 @@ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. +#include + #include #include #include +#include +#include #include "Platform.h" #include "Scintilla.h" +#include "StringCopy.h" +#include "IntegerRectangle.h" #include "Indicator.h" #include "XPM.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif -static PRectangle PixelGridAlign(const PRectangle &rc) { +static PRectangle PixelGridAlign(const PRectangle &rc) noexcept { // Move left and right side to nearest pixel to avoid blurry visuals - return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom)); + return PRectangle(round(rc.left), std::floor(rc.top), + round(rc.right), std::floor(rc.bottom)); } -void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const { +void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const { StyleAndColour sacDraw = sacNormal; if (Flags() & SC_INDICFLAG_VALUEFORE) { - sacDraw.fore = value & SC_INDICVALUEMASK; + sacDraw.fore = ColourDesired(value & SC_INDICVALUEMASK); } if (drawState == drawHover) { sacDraw = sacHover; } + const IntegerRectangle irc(rc); surface->PenColour(sacDraw.fore); - int ymid = static_cast(rc.bottom + rc.top) / 2; + const int ymid = (irc.bottom + irc.top) / 2; if (sacDraw.style == INDIC_SQUIGGLE) { - int x = int(rc.left+0.5); - int xLast = int(rc.right+0.5); + const IntegerRectangle ircSquiggle(PixelGridAlign(rc)); + int x = ircSquiggle.left; + const int xLast = ircSquiggle.right; int y = 0; - surface->MoveTo(x, static_cast(rc.top) + y); + surface->MoveTo(x, irc.top + y); while (x < xLast) { if ((x + 2) > xLast) { - if (xLast > x) - y = 1; + y = 1; x = xLast; } else { x += 2; y = 2 - y; } - surface->LineTo(x, static_cast(rc.top) + y); + surface->LineTo(x, irc.top + y); } } else if (sacDraw.style == INDIC_SQUIGGLEPIXMAP) { - PRectangle rcSquiggle = PixelGridAlign(rc); + const PRectangle rcSquiggle = PixelGridAlign(rc); - int width = Platform::Minimum(4000, static_cast(rcSquiggle.Width())); - RGBAImage image(width, 3, 1.0, 0); + const int width = std::min(4000, static_cast(rcSquiggle.Width())); + RGBAImage image(width, 3, 1.0, nullptr); enum { alphaFull = 0xff, alphaSide = 0x2f, alphaSide2=0x5f }; for (int x = 0; x < width; x++) { if (x%2) { @@ -70,19 +76,19 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r } surface->DrawRGBAImage(rcSquiggle, image.GetWidth(), image.GetHeight(), image.Pixels()); } else if (sacDraw.style == INDIC_SQUIGGLELOW) { - surface->MoveTo(static_cast(rc.left), static_cast(rc.top)); - int x = static_cast(rc.left) + 3; + surface->MoveTo(irc.left, irc.top); + int x = irc.left + 3; int y = 0; while (x < rc.right) { - surface->LineTo(x - 1, static_cast(rc.top) + y); + surface->LineTo(x - 1, irc.top + y); y = 1 - y; - surface->LineTo(x, static_cast(rc.top) + y); + surface->LineTo(x, irc.top + y); x += 3; } - surface->LineTo(static_cast(rc.right), static_cast(rc.top) + y); // Finish the line + surface->LineTo(irc.right, irc.top + y); // Finish the line } else if (sacDraw.style == INDIC_TT) { - surface->MoveTo(static_cast(rc.left), ymid); - int x = static_cast(rc.left) + 5; + surface->MoveTo(irc.left, ymid); + int x = irc.left + 5; while (x < rc.right) { surface->LineTo(x, ymid); surface->MoveTo(x-3, ymid); @@ -91,35 +97,36 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r surface->MoveTo(x, ymid); x += 5; } - surface->LineTo(static_cast(rc.right), ymid); // Finish the line + surface->LineTo(irc.right, ymid); // Finish the line if (x - 3 <= rc.right) { surface->MoveTo(x-3, ymid); surface->LineTo(x-3, ymid+2); } } else if (sacDraw.style == INDIC_DIAGONAL) { - int x = static_cast(rc.left); + int x = irc.left; while (x < rc.right) { - surface->MoveTo(x, static_cast(rc.top) + 2); + surface->MoveTo(x, irc.top + 2); int endX = x+3; - int endY = static_cast(rc.top) - 1; + int endY = irc.top - 1; if (endX > rc.right) { - endY += endX - static_cast(rc.right); - endX = static_cast(rc.right); + endY += endX - irc.right; + endX = irc.right; } surface->LineTo(endX, endY); x += 4; } } else if (sacDraw.style == INDIC_STRIKE) { - surface->MoveTo(static_cast(rc.left), static_cast(rc.top) - 4); - surface->LineTo(static_cast(rc.right), static_cast(rc.top) - 4); + surface->MoveTo(irc.left, irc.top - 4); + surface->LineTo(irc.right, irc.top - 4); } else if ((sacDraw.style == INDIC_HIDDEN) || (sacDraw.style == INDIC_TEXTFORE)) { // Draw nothing } else if (sacDraw.style == INDIC_BOX) { - surface->MoveTo(static_cast(rc.left), ymid + 1); - surface->LineTo(static_cast(rc.right), ymid + 1); - surface->LineTo(static_cast(rc.right), static_cast(rcLine.top) + 1); - surface->LineTo(static_cast(rc.left), static_cast(rcLine.top) + 1); - surface->LineTo(static_cast(rc.left), ymid + 1); + surface->MoveTo(irc.left, ymid + 1); + surface->LineTo(irc.right, ymid + 1); + const int lineTop = static_cast(rcLine.top) + 1; + surface->LineTo(irc.right, lineTop); + surface->LineTo(irc.left, lineTop); + surface->LineTo(irc.left, ymid + 1); } else if (sacDraw.style == INDIC_ROUNDBOX || sacDraw.style == INDIC_STRAIGHTBOX || sacDraw.style == INDIC_FULLBOX) { @@ -128,51 +135,86 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r rcBox.top = rcLine.top + 1; rcBox.left = rc.left; rcBox.right = rc.right; - surface->AlphaRectangle(rcBox, (sacDraw.style == INDIC_ROUNDBOX) ? 1 : 0, + surface->AlphaRectangle(rcBox, (sacDraw.style == INDIC_ROUNDBOX) ? 1 : 0, sacDraw.fore, fillAlpha, sacDraw.fore, outlineAlpha, 0); + } else if (sacDraw.style == INDIC_GRADIENT || + sacDraw.style == INDIC_GRADIENTCENTRE) { + PRectangle rcBox = rc; + rcBox.top = rcLine.top + 1; + rcBox.bottom = rcLine.bottom; + const Surface::GradientOptions options = Surface::GradientOptions::topToBottom; + const ColourAlpha start(sacNormal.fore, fillAlpha); + const ColourAlpha end(sacNormal.fore, 0); + std::vector stops; + switch (sacDraw.style) { + case INDIC_GRADIENT: + stops.push_back(ColourStop(0.0, start)); + stops.push_back(ColourStop(1.0, end)); + break; + case INDIC_GRADIENTCENTRE: + stops.push_back(ColourStop(0.0, end)); + stops.push_back(ColourStop(0.5, start)); + stops.push_back(ColourStop(1.0, end)); + break; + } + surface->GradientRectangle(rcBox, stops, options); } else if (sacDraw.style == INDIC_DOTBOX) { PRectangle rcBox = PixelGridAlign(rc); rcBox.top = rcLine.top + 1; rcBox.bottom = rcLine.bottom; + IntegerRectangle ircBox(rcBox); // Cap width at 4000 to avoid large allocations when mistakes made - int width = Platform::Minimum(static_cast(rcBox.Width()), 4000); - RGBAImage image(width, static_cast(rcBox.Height()), 1.0, 0); + const int width = std::min(ircBox.Width(), 4000); + RGBAImage image(width, ircBox.Height(), 1.0, nullptr); // Draw horizontal lines top and bottom for (int x=0; x(rcBox.Height()); y += static_cast(rcBox.Height()) - 1) { + for (int y = 0; y(rcBox.Height()); y++) { + for (int y = 1; yDrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels()); } else if (sacDraw.style == INDIC_DASH) { - int x = static_cast(rc.left); + int x = irc.left; while (x < rc.right) { surface->MoveTo(x, ymid); - surface->LineTo(Platform::Minimum(x + 4, static_cast(rc.right)), ymid); + surface->LineTo(std::min(x + 4, irc.right), ymid); x += 7; } } else if (sacDraw.style == INDIC_DOTS) { - int x = static_cast(rc.left); - while (x < static_cast(rc.right)) { - PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1); + int x = irc.left; + while (x < irc.right) { + const PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1); surface->FillRectangle(rcDot, sacDraw.fore); x += 2; } } else if (sacDraw.style == INDIC_COMPOSITIONTHICK) { - PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom); + const PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom); surface->FillRectangle(rcComposition, sacDraw.fore); } else if (sacDraw.style == INDIC_COMPOSITIONTHIN) { - PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom-1); + const PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom-1); surface->FillRectangle(rcComposition, sacDraw.fore); + } else if (sacDraw.style == INDIC_POINT || sacDraw.style == INDIC_POINTCHARACTER) { + if (rcCharacter.Width() >= 0.1) { + const XYPOSITION pixelHeight = std::floor(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase + const XYPOSITION x = (sacDraw.style == INDIC_POINT) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2); + const XYPOSITION ix = round(x); + const XYPOSITION iy = std::floor(rc.top + 1.0f); + Point pts[] = { + Point(ix - pixelHeight, iy + pixelHeight), // Left + Point(ix + pixelHeight, iy + pixelHeight), // Right + Point(ix, iy) // Top + }; + surface->Polygon(pts, ELEMENTS(pts), sacDraw.fore, sacDraw.fore); + } } else { // Either INDIC_PLAIN or unknown - surface->MoveTo(static_cast(rc.left), ymid); - surface->LineTo(static_cast(rc.right), ymid); + surface->MoveTo(irc.left, ymid); + surface->LineTo(irc.right, ymid); } } diff --git a/dep/scintilla/scintilla-3.6.0/src/Indicator.h b/dep/scintilla/scintilla-3.10.6/src/Indicator.h similarity index 69% rename from dep/scintilla/scintilla-3.6.0/src/Indicator.h rename to dep/scintilla/scintilla-3.10.6/src/Indicator.h index c22ec71c..24319df9 100644 --- a/dep/scintilla/scintilla-3.6.0/src/Indicator.h +++ b/dep/scintilla/scintilla-3.10.6/src/Indicator.h @@ -8,18 +8,16 @@ #ifndef INDICATOR_H #define INDICATOR_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif struct StyleAndColour { int style; ColourDesired fore; - StyleAndColour() : style(INDIC_PLAIN), fore(0, 0, 0) { + StyleAndColour() noexcept : style(INDIC_PLAIN), fore(0, 0, 0) { } - StyleAndColour(int style_, ColourDesired fore_ = ColourDesired(0, 0, 0)) : style(style_), fore(fore_) { + StyleAndColour(int style_, ColourDesired fore_ = ColourDesired(0, 0, 0)) noexcept : style(style_), fore(fore_) { } - bool operator==(const StyleAndColour &other) const { + bool operator==(const StyleAndColour &other) const noexcept { return (style == other.style) && (fore == other.fore); } }; @@ -35,26 +33,24 @@ public: int fillAlpha; int outlineAlpha; int attributes; - Indicator() : under(false), fillAlpha(30), outlineAlpha(50), attributes(0) { + Indicator() noexcept : under(false), fillAlpha(30), outlineAlpha(50), attributes(0) { } - Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) : + Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) noexcept : sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(0) { } - void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, DrawState drawState, int value) const; - bool IsDynamic() const { + void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const; + bool IsDynamic() const noexcept { return !(sacNormal == sacHover); } - bool OverridesTextFore() const { + bool OverridesTextFore() const noexcept { return sacNormal.style == INDIC_TEXTFORE || sacHover.style == INDIC_TEXTFORE; } - int Flags() const { + int Flags() const noexcept { return attributes; } void SetFlags(int attributes_); }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.10.6/src/IntegerRectangle.h b/dep/scintilla/scintilla-3.10.6/src/IntegerRectangle.h new file mode 100644 index 00000000..4eaf39c4 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/IntegerRectangle.h @@ -0,0 +1,29 @@ +// Scintilla source code edit control +/** @file IntegerRectangle.h + ** A rectangle with integer coordinates. + **/ +// Copyright 2018 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef INTEGERRECTANGLE_H +#define INTEGERRECTANGLE_H + +namespace Scintilla { + +struct IntegerRectangle { + int left; + int top; + int right; + int bottom; + + explicit IntegerRectangle(PRectangle rc) noexcept : + left(static_cast(rc.left)), top(static_cast(rc.top)), + right(static_cast(rc.right)), bottom(static_cast(rc.bottom)) { + } + int Width() const noexcept { return right - left; } + int Height() const noexcept { return bottom - top; } +}; + +} + +#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/KeyMap.cxx b/dep/scintilla/scintilla-3.10.6/src/KeyMap.cxx similarity index 96% rename from dep/scintilla/scintilla-3.6.0/src/KeyMap.cxx rename to dep/scintilla/scintilla-3.10.6/src/KeyMap.cxx index a6b1cf6c..8dc4feff 100644 --- a/dep/scintilla/scintilla-3.6.0/src/KeyMap.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/KeyMap.cxx @@ -5,11 +5,12 @@ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include +#include #include #include #include +#include #include "Platform.h" @@ -17,9 +18,7 @@ #include "KeyMap.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif KeyMap::KeyMap() { for (int i = 0; MapDefault[i].key; i++) { @@ -33,7 +32,7 @@ KeyMap::~KeyMap() { Clear(); } -void KeyMap::Clear() { +void KeyMap::Clear() noexcept { kmap.clear(); } @@ -46,6 +45,10 @@ unsigned int KeyMap::Find(int key, int modifiers) const { return (it == kmap.end()) ? 0 : it->second; } +const std::map &KeyMap::GetKeyMap() const noexcept { + return kmap; +} + #if PLAT_GTK_MACOSX #define OS_X_KEYS 1 #else diff --git a/dep/scintilla/scintilla-3.6.0/src/KeyMap.h b/dep/scintilla/scintilla-3.10.6/src/KeyMap.h similarity index 80% rename from dep/scintilla/scintilla-3.6.0/src/KeyMap.h rename to dep/scintilla/scintilla-3.10.6/src/KeyMap.h index b102b356..245b6daa 100644 --- a/dep/scintilla/scintilla-3.6.0/src/KeyMap.h +++ b/dep/scintilla/scintilla-3.10.6/src/KeyMap.h @@ -8,15 +8,14 @@ #ifndef KEYMAP_H #define KEYMAP_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif #define SCI_NORM 0 #define SCI_SHIFT SCMOD_SHIFT #define SCI_CTRL SCMOD_CTRL #define SCI_ALT SCMOD_ALT #define SCI_META SCMOD_META +#define SCI_SUPER SCMOD_SUPER #define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT) #define SCI_ASHIFT (SCI_ALT | SCI_SHIFT) @@ -26,9 +25,9 @@ class KeyModifiers { public: int key; int modifiers; - KeyModifiers(int key_, int modifiers_) : key(key_), modifiers(modifiers_) { + KeyModifiers(int key_, int modifiers_) noexcept : key(key_), modifiers(modifiers_) { } - bool operator<(const KeyModifiers &other) const { + bool operator<(const KeyModifiers &other) const noexcept { if (key == other.key) return modifiers < other.modifiers; else @@ -54,13 +53,12 @@ class KeyMap { public: KeyMap(); ~KeyMap(); - void Clear(); + void Clear() noexcept; void AssignCmdKey(int key, int modifiers, unsigned int msg); unsigned int Find(int key, int modifiers) const; // 0 returned on failure + const std::map &GetKeyMap() const noexcept; }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/LineMarker.cxx b/dep/scintilla/scintilla-3.10.6/src/LineMarker.cxx similarity index 71% rename from dep/scintilla/scintilla-3.6.0/src/LineMarker.cxx rename to dep/scintilla/scintilla-3.10.6/src/LineMarker.cxx index 6239d1c9..d2c906d0 100644 --- a/dep/scintilla/scintilla-3.6.0/src/LineMarker.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/LineMarker.cxx @@ -5,45 +5,82 @@ // Copyright 1998-2011 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include +#include +#include #include #include #include +#include +#include #include "Platform.h" #include "Scintilla.h" #include "StringCopy.h" +#include "IntegerRectangle.h" #include "XPM.h" #include "LineMarker.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif + +LineMarker::LineMarker(const LineMarker &other) { + // Defined to avoid pxpm and image being blindly copied, not as a complete copy constructor. + markType = other.markType; + fore = other.fore; + back = other.back; + backSelected = other.backSelected; + alpha = other.alpha; + if (other.pxpm) + pxpm.reset(new XPM(*other.pxpm)); + else + pxpm = nullptr; + if (other.image) + image.reset(new RGBAImage(*other.image)); + else + image = nullptr; + customDraw = other.customDraw; +} + +LineMarker &LineMarker::operator=(const LineMarker &other) { + // Defined to avoid pxpm and image being blindly copied, not as a complete assignment operator. + if (this != &other) { + markType = other.markType; + fore = other.fore; + back = other.back; + backSelected = other.backSelected; + alpha = other.alpha; + if (other.pxpm) + pxpm.reset(new XPM(*other.pxpm)); + else + pxpm = nullptr; + if (other.image) + image.reset(new RGBAImage(*other.image)); + else + image = nullptr; + customDraw = other.customDraw; + } + return *this; +} void LineMarker::SetXPM(const char *textForm) { - delete pxpm; - pxpm = new XPM(textForm); + pxpm.reset(new XPM(textForm)); markType = SC_MARK_PIXMAP; } void LineMarker::SetXPM(const char *const *linesForm) { - delete pxpm; - pxpm = new XPM(linesForm); + pxpm.reset(new XPM(linesForm)); markType = SC_MARK_PIXMAP; } void LineMarker::SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage) { - delete image; - image = new RGBAImage(static_cast(sizeRGBAImage.x), static_cast(sizeRGBAImage.y), scale, pixelsRGBAImage); + image.reset(new RGBAImage(static_cast(sizeRGBAImage.x), static_cast(sizeRGBAImage.y), scale, pixelsRGBAImage)); markType = SC_MARK_RGBAIMAGE; } static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) { - PRectangle rc = PRectangle::FromInts( + const PRectangle rc = PRectangle::FromInts( centreX - armSize, centreY - armSize, centreX + armSize + 1, @@ -52,7 +89,7 @@ static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Col } static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) { - PRectangle rcCircle = PRectangle::FromInts( + const PRectangle rcCircle = PRectangle::FromInts( centreX - armSize, centreY - armSize, centreX + armSize + 1, @@ -61,19 +98,19 @@ static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, } static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) { - PRectangle rcV = PRectangle::FromInts(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1); + const PRectangle rcV = PRectangle::FromInts(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1); surface->FillRectangle(rcV, fore); - PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1); + const PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1); surface->FillRectangle(rcH, fore); } static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) { - PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1); + const PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1); surface->FillRectangle(rcH, fore); } void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const { - if (customDraw != NULL) { + if (customDraw) { customDraw(surface, rcWhole, fontForCharacter, tFold, marginStyle, this); return; } @@ -115,21 +152,20 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac surface->DrawRGBAImage(rcImage, image->GetWidth(), image->GetHeight(), image->Pixels()); return; } + const IntegerRectangle ircWhole(rcWhole); // Restrict most shapes a bit - PRectangle rc = rcWhole; - rc.top++; - rc.bottom--; - int minDim = Platform::Minimum(static_cast(rc.Width()), static_cast(rc.Height())); - minDim--; // Ensure does not go beyond edge - int centreX = static_cast(floor((rc.right + rc.left) / 2.0)); - int centreY = static_cast(floor((rc.bottom + rc.top) / 2.0)); - int dimOn2 = minDim / 2; - int dimOn4 = minDim / 4; - int blobSize = dimOn2-1; - int armSize = dimOn2-2; + const PRectangle rc(rcWhole.left, rcWhole.top + 1, rcWhole.right, rcWhole.bottom - 1); + // Ensure does not go beyond edge + const int minDim = std::min(ircWhole.Width(), ircWhole.Height()-2) - 1; + int centreX = (ircWhole.right + ircWhole.left) / 2; + const int centreY = (ircWhole.bottom + ircWhole.top) / 2; + const int dimOn2 = minDim / 2; + const int dimOn4 = minDim / 4; + const int blobSize = dimOn2-1; + const int armSize = dimOn2-2; if (marginStyle == SC_MARGIN_NUMBER || marginStyle == SC_MARGIN_TEXT || marginStyle == SC_MARGIN_RTEXT) { // On textual margins move marker to the left to try to avoid overlapping the text - centreX = static_cast(rc.left) + dimOn2 + 1; + centreX = ircWhole.left + dimOn2 + 1; } if (markType == SC_MARK_ROUNDRECT) { PRectangle rcRounded = rc; @@ -137,7 +173,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac rcRounded.right = rc.right - 1; surface->RoundedRectangle(rcRounded, fore, back); } else if (markType == SC_MARK_CIRCLE) { - PRectangle rcCircle = PRectangle::FromInts( + const PRectangle rcCircle = PRectangle::FromInts( centreX - dimOn2, centreY - dimOn2, centreX + dimOn2, @@ -199,46 +235,46 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac } else if (markType == SC_MARK_VLINE) { surface->PenColour(colourBody); - surface->MoveTo(centreX, static_cast(rcWhole.top)); - surface->LineTo(centreX, static_cast(rcWhole.bottom)); + surface->MoveTo(centreX, ircWhole.top); + surface->LineTo(centreX, ircWhole.bottom); } else if (markType == SC_MARK_LCORNER) { surface->PenColour(colourTail); - surface->MoveTo(centreX, static_cast(rcWhole.top)); + surface->MoveTo(centreX, ircWhole.top); surface->LineTo(centreX, centreY); - surface->LineTo(static_cast(rc.right) - 1, centreY); + surface->LineTo(ircWhole.right - 1, centreY); } else if (markType == SC_MARK_TCORNER) { surface->PenColour(colourTail); surface->MoveTo(centreX, centreY); - surface->LineTo(static_cast(rc.right) - 1, centreY); + surface->LineTo(ircWhole.right - 1, centreY); surface->PenColour(colourBody); - surface->MoveTo(centreX, static_cast(rcWhole.top)); + surface->MoveTo(centreX, ircWhole.top); surface->LineTo(centreX, centreY + 1); surface->PenColour(colourHead); - surface->LineTo(centreX, static_cast(rcWhole.bottom)); + surface->LineTo(centreX, ircWhole.bottom); } else if (markType == SC_MARK_LCORNERCURVE) { surface->PenColour(colourTail); - surface->MoveTo(centreX, static_cast(rcWhole.top)); + surface->MoveTo(centreX, ircWhole.top); surface->LineTo(centreX, centreY-3); surface->LineTo(centreX+3, centreY); - surface->LineTo(static_cast(rc.right) - 1, centreY); + surface->LineTo(ircWhole.right - 1, centreY); } else if (markType == SC_MARK_TCORNERCURVE) { surface->PenColour(colourTail); surface->MoveTo(centreX, centreY-3); surface->LineTo(centreX+3, centreY); - surface->LineTo(static_cast(rc.right) - 1, centreY); + surface->LineTo(ircWhole.right - 1, centreY); surface->PenColour(colourBody); - surface->MoveTo(centreX, static_cast(rcWhole.top)); + surface->MoveTo(centreX, ircWhole.top); surface->LineTo(centreX, centreY-2); surface->PenColour(colourHead); - surface->LineTo(centreX, static_cast(rcWhole.bottom)); + surface->LineTo(centreX, ircWhole.bottom); } else if (markType == SC_MARK_BOXPLUS) { DrawBox(surface, centreX, centreY, blobSize, fore, colourHead); @@ -250,10 +286,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac else surface->PenColour(colourBody); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, static_cast(rcWhole.bottom)); + surface->LineTo(centreX, ircWhole.bottom); surface->PenColour(colourBody); - surface->MoveTo(centreX, static_cast(rcWhole.top)); + surface->MoveTo(centreX, ircWhole.top); surface->LineTo(centreX, centreY - blobSize); DrawBox(surface, centreX, centreY, blobSize, fore, colourHead); @@ -276,7 +312,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac surface->PenColour(colourHead); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, static_cast(rcWhole.bottom)); + surface->LineTo(centreX, ircWhole.bottom); } else if (markType == SC_MARK_BOXMINUSCONNECTED) { DrawBox(surface, centreX, centreY, blobSize, fore, colourHead); @@ -284,10 +320,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac surface->PenColour(colourHead); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, static_cast(rcWhole.bottom)); + surface->LineTo(centreX, ircWhole.bottom); surface->PenColour(colourBody); - surface->MoveTo(centreX, static_cast(rcWhole.top)); + surface->MoveTo(centreX, ircWhole.top); surface->LineTo(centreX, centreY - blobSize); if (tFold == LineMarker::body) { @@ -311,10 +347,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac else surface->PenColour(colourBody); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, static_cast(rcWhole.bottom)); + surface->LineTo(centreX, ircWhole.bottom); surface->PenColour(colourBody); - surface->MoveTo(centreX, static_cast(rcWhole.top)); + surface->MoveTo(centreX, ircWhole.top); surface->LineTo(centreX, centreY - blobSize); DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead); @@ -323,7 +359,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac } else if (markType == SC_MARK_CIRCLEMINUS) { surface->PenColour(colourHead); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, static_cast(rcWhole.bottom)); + surface->LineTo(centreX, ircWhole.bottom); DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead); DrawMinus(surface, centreX, centreY, blobSize, colourTail); @@ -331,10 +367,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac } else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) { surface->PenColour(colourHead); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, static_cast(rcWhole.bottom)); + surface->LineTo(centreX, ircWhole.bottom); surface->PenColour(colourBody); - surface->MoveTo(centreX, static_cast(rcWhole.top)); + surface->MoveTo(centreX, ircWhole.top); surface->LineTo(centreX, centreY - blobSize); DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead); @@ -343,16 +379,17 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac } else if (markType >= SC_MARK_CHARACTER) { char character[1]; character[0] = static_cast(markType - SC_MARK_CHARACTER); - XYPOSITION width = surface->WidthText(fontForCharacter, character, 1); - rc.left += (rc.Width() - width) / 2; - rc.right = rc.left + width; - surface->DrawTextClipped(rc, fontForCharacter, rc.bottom - 2, + const XYPOSITION width = surface->WidthText(fontForCharacter, character, 1); + PRectangle rcText = rc; + rcText.left += (rc.Width() - width) / 2; + rcText.right = rc.left + width; + surface->DrawTextClipped(rcText, fontForCharacter, rcText.bottom - 2, character, 1, fore, back); } else if (markType == SC_MARK_DOTDOTDOT) { XYPOSITION right = static_cast(centreX - 6); for (int b=0; b<3; b++) { - PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom-2); + const PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom-2); surface->FillRectangle(rcBlob, fore); right += 5.0f; } @@ -384,13 +421,23 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac rcLeft.right = rcLeft.left + 4; surface->FillRectangle(rcLeft, back); } else if (markType == SC_MARK_BOOKMARK) { - int halfHeight = minDim / 3; + const int halfHeight = minDim / 3; Point pts[] = { - Point::FromInts(static_cast(rc.left), centreY-halfHeight), - Point::FromInts(static_cast(rc.right) - 3, centreY - halfHeight), - Point::FromInts(static_cast(rc.right) - 3 - halfHeight, centreY), - Point::FromInts(static_cast(rc.right) - 3, centreY + halfHeight), - Point::FromInts(static_cast(rc.left), centreY + halfHeight), + Point::FromInts(ircWhole.left, centreY-halfHeight), + Point::FromInts(ircWhole.right - 3, centreY - halfHeight), + Point::FromInts(ircWhole.right - 3 - halfHeight, centreY), + Point::FromInts(ircWhole.right - 3, centreY + halfHeight), + Point::FromInts(ircWhole.left, centreY + halfHeight), + }; + surface->Polygon(pts, ELEMENTS(pts), fore, back); + } else if (markType == SC_MARK_VERTICALBOOKMARK) { + const int halfWidth = minDim / 3; + Point pts[] = { + Point::FromInts(centreX - halfWidth, centreY - dimOn2), + Point::FromInts(centreX + halfWidth, centreY - dimOn2), + Point::FromInts(centreX + halfWidth, centreY + dimOn2), + Point::FromInts(centreX, centreY + dimOn2 - halfWidth), + Point::FromInts(centreX - halfWidth, centreY + dimOn2), }; surface->Polygon(pts, ELEMENTS(pts), fore, back); } else { // SC_MARK_FULLRECT diff --git a/dep/scintilla/scintilla-3.10.6/src/LineMarker.h b/dep/scintilla/scintilla-3.10.6/src/LineMarker.h new file mode 100644 index 00000000..db3a8f15 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/LineMarker.h @@ -0,0 +1,52 @@ +// Scintilla source code edit control +/** @file LineMarker.h + ** Defines the look of a line marker in the margin . + **/ +// Copyright 1998-2011 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef LINEMARKER_H +#define LINEMARKER_H + +namespace Scintilla { + +class XPM; +class RGBAImage; + +typedef void (*DrawLineMarkerFn)(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, int tFold, int marginStyle, const void *lineMarker); + +/** + */ +class LineMarker { +public: + enum typeOfFold { undefined, head, body, tail, headWithTail }; + + int markType = SC_MARK_CIRCLE; + ColourDesired fore = ColourDesired(0, 0, 0); + ColourDesired back = ColourDesired(0xff, 0xff, 0xff); + ColourDesired backSelected = ColourDesired(0xff, 0x00, 0x00); + int alpha = SC_ALPHA_NOALPHA; + std::unique_ptr pxpm; + std::unique_ptr image; + /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native + * Draw function for drawing line markers. Allow those platforms to override + * it instead of creating a new method(s) in the Surface class that existing + * platforms must implement as empty. */ + DrawLineMarkerFn customDraw = nullptr; + + LineMarker() = default; + LineMarker(const LineMarker &other); + LineMarker(LineMarker &&) noexcept = default; + LineMarker &operator=(const LineMarker& other); + LineMarker &operator=(LineMarker&&) noexcept = default; + virtual ~LineMarker() = default; + + void SetXPM(const char *textForm); + void SetXPM(const char *const *linesForm); + void SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage); + void Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const; +}; + +} + +#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/MarginView.cxx b/dep/scintilla/scintilla-3.10.6/src/MarginView.cxx similarity index 77% rename from dep/scintilla/scintilla-3.6.0/src/MarginView.cxx rename to dep/scintilla/scintilla-3.10.6/src/MarginView.cxx index f164a7cb..e6f73c52 100644 --- a/dep/scintilla/scintilla-3.6.0/src/MarginView.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/MarginView.cxx @@ -5,12 +5,12 @@ // Copyright 1998-2014 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include @@ -21,11 +21,14 @@ #include "Platform.h" +#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" -#include "StringCopy.h" +#include "CharacterCategory.h" #include "Position.h" +#include "IntegerRectangle.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -33,7 +36,6 @@ #include "CellBuffer.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -48,28 +50,26 @@ #include "MarginView.h" #include "EditView.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour) { surface->PenColour(wrapColour); + const IntegerRectangle ircPlace(rcPlace); + enum { xa = 1 }; // gap before start - int w = static_cast(rcPlace.right - rcPlace.left) - xa - 1; + const int w = ircPlace.Width() - xa - 1; - bool xStraight = isEndMarker; // x-mirrored symbol for start marker + const bool xStraight = isEndMarker; // x-mirrored symbol for start marker - int x0 = static_cast(xStraight ? rcPlace.left : rcPlace.right - 1); - int y0 = static_cast(rcPlace.top); + const int x0 = xStraight ? ircPlace.left : ircPlace.right - 1; + const int y0 = ircPlace.top; - int dy = static_cast(rcPlace.bottom - rcPlace.top) / 5; - int y = static_cast(rcPlace.bottom - rcPlace.top) / 2 + dy; + const int dy = ircPlace.Height() / 5; + const int y = ircPlace.Height() / 2 + dy; struct Relative { Surface *surface; @@ -100,22 +100,16 @@ void DrawWrapMarker(Surface *surface, PRectangle rcPlace, y - 2 * dy); } -MarginView::MarginView() { - pixmapSelMargin = 0; - pixmapSelPattern = 0; - pixmapSelPatternOffset1 = 0; +MarginView::MarginView() noexcept { wrapMarkerPaddingRight = 3; - customDrawWrapMarker = NULL; + customDrawWrapMarker = nullptr; } void MarginView::DropGraphics(bool freeObjects) { if (freeObjects) { - delete pixmapSelMargin; - pixmapSelMargin = 0; - delete pixmapSelPattern; - pixmapSelPattern = 0; - delete pixmapSelPatternOffset1; - pixmapSelPatternOffset1 = 0; + pixmapSelMargin.reset(); + pixmapSelPattern.reset(); + pixmapSelPatternOffset1.reset(); } else { if (pixmapSelMargin) pixmapSelMargin->Release(); @@ -128,11 +122,11 @@ void MarginView::DropGraphics(bool freeObjects) { void MarginView::AllocateGraphics(const ViewStyle &vsDraw) { if (!pixmapSelMargin) - pixmapSelMargin = Surface::Allocate(vsDraw.technology); + pixmapSelMargin.reset(Surface::Allocate(vsDraw.technology)); if (!pixmapSelPattern) - pixmapSelPattern = Surface::Allocate(vsDraw.technology); + pixmapSelPattern.reset(Surface::Allocate(vsDraw.technology)); if (!pixmapSelPatternOffset1) - pixmapSelPatternOffset1 = Surface::Allocate(vsDraw.technology); + pixmapSelPatternOffset1.reset(Surface::Allocate(vsDraw.technology)); } void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw) { @@ -144,7 +138,7 @@ void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const View // for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half // way between the chrome colour and the chrome highlight colour making a nice transition // between the window chrome and the content area. And it works in low colour depths. - PRectangle rcPattern = PRectangle::FromInts(0, 0, patternSize, patternSize); + const PRectangle rcPattern = PRectangle::FromInts(0, 0, patternSize, patternSize); // Initialize default colours based on the chrome colour scheme. Typically the highlight is white. ColourDesired colourFMFill = vsDraw.selbar; @@ -169,7 +163,7 @@ void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const View pixmapSelPatternOffset1->FillRectangle(rcPattern, colourFMStripes); for (int y = 0; y < patternSize; y++) { for (int x = y % 2; x < patternSize; x += 2) { - PRectangle rcPixel = PRectangle::FromInts(x, y, x + 1, y + 1); + const PRectangle rcPixel = PRectangle::FromInts(x, y, x + 1, y + 1); pixmapSelPattern->FillRectangle(rcPixel, colourFMStripes); pixmapSelPatternOffset1->FillRectangle(rcPixel, colourFMFill); } @@ -183,7 +177,7 @@ static int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault, const Vie return markerCheck; } -void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRectangle rcMargin, +void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc, PRectangle rcMargin, const EditModel &model, const ViewStyle &vs) { PRectangle rcSelMargin = rcMargin; @@ -191,9 +185,9 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect if (rcSelMargin.bottom < rc.bottom) rcSelMargin.bottom = rc.bottom; - Point ptOrigin = model.GetVisibleOriginInMain(); + const Point ptOrigin = model.GetVisibleOriginInMain(); FontAlias fontLineNumber = vs.styles[STYLE_LINENUMBER].font; - for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) { + for (size_t margin = 0; margin < vs.ms.size(); margin++) { if (vs.ms[margin].width > 0) { rcSelMargin.left = rcSelMargin.right; @@ -204,7 +198,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect // Required because of special way brush is created for selection margin // Ensure patterns line up when scrolling with separate margin view // by choosing correctly aligned variant. - bool invertPhase = static_cast(ptOrigin.y) & 1; + const bool invertPhase = static_cast(ptOrigin.y) & 1; surface->FillRectangle(rcSelMargin, invertPhase ? *pixmapSelPattern : *pixmapSelPatternOffset1); } else { @@ -216,6 +210,9 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect case SC_MARGIN_FORE: colour = vs.styles[STYLE_DEFAULT].fore; break; + case SC_MARGIN_COLOUR: + colour = vs.ms[margin].back; + break; default: colour = vs.styles[STYLE_LINENUMBER].back; break; @@ -227,29 +224,30 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect } const int lineStartPaint = static_cast(rcMargin.top + ptOrigin.y) / vs.lineHeight; - int visibleLine = model.TopLineOfMain() + lineStartPaint; - int yposScreen = lineStartPaint * vs.lineHeight - static_cast(ptOrigin.y); + Sci::Line visibleLine = model.TopLineOfMain() + lineStartPaint; + Sci::Position yposScreen = lineStartPaint * vs.lineHeight - static_cast(ptOrigin.y); // Work out whether the top line is whitespace located after a // lessening of fold level which implies a 'fold tail' but which should not // be displayed until the last of a sequence of whitespace. bool needWhiteClosure = false; if (vs.ms[margin].mask & SC_MASK_FOLDERS) { - int level = model.pdoc->GetLevel(model.cs.DocFromDisplay(visibleLine)); + const int level = model.pdoc->GetLevel(model.pcs->DocFromDisplay(visibleLine)); if (level & SC_FOLDLEVELWHITEFLAG) { - int lineBack = model.cs.DocFromDisplay(visibleLine); + Sci::Line lineBack = model.pcs->DocFromDisplay(visibleLine); int levelPrev = level; while ((lineBack > 0) && (levelPrev & SC_FOLDLEVELWHITEFLAG)) { lineBack--; levelPrev = model.pdoc->GetLevel(lineBack); } if (!(levelPrev & SC_FOLDLEVELHEADERFLAG)) { - if ((level & SC_FOLDLEVELNUMBERMASK) < (levelPrev & SC_FOLDLEVELNUMBERMASK)) + if (LevelNumber(level) < LevelNumber(levelPrev)) needWhiteClosure = true; } } if (highlightDelimiter.isEnabled) { - int lastLine = model.cs.DocFromDisplay(topLine + model.LinesOnScreen()) + 1; - model.pdoc->GetHighlightDelimiters(highlightDelimiter, model.pdoc->LineFromPosition(model.sel.MainCaret()), lastLine); + const Sci::Line lastLine = model.pcs->DocFromDisplay(topLine + model.LinesOnScreen()) + 1; + model.pdoc->GetHighlightDelimiters(highlightDelimiter, + model.pdoc->SciLineFromPosition(model.sel.MainCaret()), lastLine); } } @@ -259,13 +257,13 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect const int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND, SC_MARKNUM_FOLDER, vs); - while ((visibleLine < model.cs.LinesDisplayed()) && yposScreen < rc.bottom) { + while ((visibleLine < model.pcs->LinesDisplayed()) && yposScreen < rc.bottom) { - PLATFORM_ASSERT(visibleLine < model.cs.LinesDisplayed()); - const int lineDoc = model.cs.DocFromDisplay(visibleLine); - PLATFORM_ASSERT(model.cs.GetVisible(lineDoc)); - const int firstVisibleLine = model.cs.DisplayFromDoc(lineDoc); - const int lastVisibleLine = model.cs.DisplayLastFromDoc(lineDoc); + PLATFORM_ASSERT(visibleLine < model.pcs->LinesDisplayed()); + const Sci::Line lineDoc = model.pcs->DocFromDisplay(visibleLine); + PLATFORM_ASSERT(model.pcs->GetVisible(lineDoc)); + const Sci::Line firstVisibleLine = model.pcs->DisplayFromDoc(lineDoc); + const Sci::Line lastVisibleLine = model.pcs->DisplayLastFromDoc(lineDoc); const bool firstSubLine = visibleLine == firstVisibleLine; const bool lastSubLine = visibleLine == lastVisibleLine; @@ -279,12 +277,12 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect // Decide which fold indicator should be displayed const int level = model.pdoc->GetLevel(lineDoc); const int levelNext = model.pdoc->GetLevel(lineDoc + 1); - const int levelNum = level & SC_FOLDLEVELNUMBERMASK; - const int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK; + const int levelNum = LevelNumber(level); + const int levelNextNum = LevelNumber(levelNext); if (level & SC_FOLDLEVELHEADERFLAG) { if (firstSubLine) { if (levelNum < levelNextNum) { - if (model.cs.GetExpanded(lineDoc)) { + if (model.pcs->GetExpanded(lineDoc)) { if (levelNum == SC_FOLDLEVELBASE) marks |= 1 << SC_MARKNUM_FOLDEROPEN; else @@ -300,7 +298,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect } } else { if (levelNum < levelNextNum) { - if (model.cs.GetExpanded(lineDoc)) { + if (model.pcs->GetExpanded(lineDoc)) { marks |= 1 << SC_MARKNUM_FOLDERSUB; } else if (levelNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERSUB; @@ -310,10 +308,10 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect } } needWhiteClosure = false; - const int firstFollowupLine = model.cs.DocFromDisplay(model.cs.DisplayFromDoc(lineDoc + 1)); + const Sci::Line firstFollowupLine = model.pcs->DocFromDisplay(model.pcs->DisplayFromDoc(lineDoc + 1)); const int firstFollowupLineLevel = model.pdoc->GetLevel(firstFollowupLine); - const int secondFollowupLineLevelNum = model.pdoc->GetLevel(firstFollowupLine + 1) & SC_FOLDLEVELNUMBERMASK; - if (!model.cs.GetExpanded(lineDoc)) { + const int secondFollowupLineLevelNum = LevelNumber(model.pdoc->GetLevel(firstFollowupLine + 1)); + if (!model.pcs->GetExpanded(lineDoc)) { if ((firstFollowupLineLevel & SC_FOLDLEVELWHITEFLAG) && (levelNum > secondFollowupLineLevelNum)) needWhiteClosure = true; @@ -371,35 +369,38 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect rcMarker.bottom = static_cast(yposScreen + vs.lineHeight); if (vs.ms[margin].style == SC_MARGIN_NUMBER) { if (firstSubLine) { - char number[100] = ""; - if (lineDoc >= 0) - sprintf(number, "%d", lineDoc + 1); + std::string sNumber; + if (lineDoc >= 0) { + sNumber = std::to_string(lineDoc + 1); + } if (model.foldFlags & (SC_FOLDFLAG_LEVELNUMBERS | SC_FOLDFLAG_LINESTATE)) { + char number[100] = ""; if (model.foldFlags & SC_FOLDFLAG_LEVELNUMBERS) { - int lev = model.pdoc->GetLevel(lineDoc); + const int lev = model.pdoc->GetLevel(lineDoc); sprintf(number, "%c%c %03X %03X", (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_', (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_', - lev & SC_FOLDLEVELNUMBERMASK, + LevelNumber(lev), lev >> 16 ); } else { - int state = model.pdoc->GetLineState(lineDoc); + const int state = model.pdoc->GetLineState(lineDoc); sprintf(number, "%0X", state); } + sNumber = number; } PRectangle rcNumber = rcMarker; // Right justify - XYPOSITION width = surface->WidthText(fontLineNumber, number, static_cast(strlen(number))); - XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding; + const XYPOSITION width = surface->WidthText(fontLineNumber, sNumber.c_str(), static_cast(sNumber.length())); + const XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding; rcNumber.left = xpos; DrawTextNoClipPhase(surface, rcNumber, vs.styles[STYLE_LINENUMBER], - rcNumber.top + vs.maxAscent, number, static_cast(strlen(number)), drawAll); + rcNumber.top + vs.maxAscent, sNumber.c_str(), static_cast(sNumber.length()), drawAll); } else if (vs.wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) { PRectangle rcWrapMarker = rcMarker; rcWrapMarker.right -= wrapMarkerPaddingRight; rcWrapMarker.left = rcWrapMarker.right - vs.styles[STYLE_LINENUMBER].aveCharWidth; - if (customDrawWrapMarker == NULL) { + if (!customDrawWrapMarker) { DrawWrapMarker(surface, rcWrapMarker, false, vs.styles[STYLE_LINENUMBER].fore); } else { customDrawWrapMarker(surface, rcWrapMarker, false, vs.styles[STYLE_LINENUMBER].fore); @@ -412,13 +413,13 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect surface->FillRectangle(rcMarker, vs.styles[stMargin.StyleAt(0) + vs.marginStyleOffset].back); if (vs.ms[margin].style == SC_MARGIN_RTEXT) { - int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); + const int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); rcMarker.left = rcMarker.right - width - 3; } DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, stMargin, 0, stMargin.length, drawAll); } else { - // if we're displaying annotation lines, color the margin to match the associated document line + // if we're displaying annotation lines, colour the margin to match the associated document line const int annotationLines = model.pdoc->AnnotationLines(lineDoc); if (annotationLines && (visibleLine > lastVisibleLine - annotationLines)) { surface->FillRectangle(rcMarker, vs.styles[stMargin.StyleAt(0) + vs.marginStyleOffset].back); @@ -438,7 +439,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect if (firstSubLine) { tFold = headWithTail ? LineMarker::headWithTail : LineMarker::head; } else { - if (model.cs.GetExpanded(lineDoc) || headWithTail) { + if (model.pcs->GetExpanded(lineDoc) || headWithTail) { tFold = LineMarker::body; } else { tFold = LineMarker::undefined; @@ -465,7 +466,5 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back); } -#ifdef SCI_NAMESPACE } -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/MarginView.h b/dep/scintilla/scintilla-3.10.6/src/MarginView.h similarity index 84% rename from dep/scintilla/scintilla-3.6.0/src/MarginView.h rename to dep/scintilla/scintilla-3.10.6/src/MarginView.h index ff556467..4468afa1 100644 --- a/dep/scintilla/scintilla-3.6.0/src/MarginView.h +++ b/dep/scintilla/scintilla-3.10.6/src/MarginView.h @@ -8,9 +8,7 @@ #ifndef MARGINVIEW_H #define MARGINVIEW_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour); @@ -21,9 +19,9 @@ typedef void (*DrawWrapMarkerFn)(Surface *surface, PRectangle rcPlace, bool isEn */ class MarginView { public: - Surface *pixmapSelMargin; - Surface *pixmapSelPattern; - Surface *pixmapSelPatternOffset1; + std::unique_ptr pixmapSelMargin; + std::unique_ptr pixmapSelPattern; + std::unique_ptr pixmapSelPatternOffset1; // Highlight current folding block HighlightDelimiter highlightDelimiter; @@ -34,17 +32,15 @@ public: * existing platforms must implement as empty. */ DrawWrapMarkerFn customDrawWrapMarker; - MarginView(); + MarginView() noexcept; void DropGraphics(bool freeObjects); void AllocateGraphics(const ViewStyle &vsDraw); void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw); - void PaintMargin(Surface *surface, int topLine, PRectangle rc, PRectangle rcMargin, + void PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc, PRectangle rcMargin, const EditModel &model, const ViewStyle &vs); }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/Partitioning.h b/dep/scintilla/scintilla-3.10.6/src/Partitioning.h similarity index 61% rename from dep/scintilla/scintilla-3.6.0/src/Partitioning.h rename to dep/scintilla/scintilla-3.10.6/src/Partitioning.h index 688b38d7..a92e55b5 100644 --- a/dep/scintilla/scintilla-3.6.0/src/Partitioning.h +++ b/dep/scintilla/scintilla-3.10.6/src/Partitioning.h @@ -8,37 +8,41 @@ #ifndef PARTITIONING_H #define PARTITIONING_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif /// 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 { +template +class SplitVectorWithRangeAdd : public SplitVector { public: - explicit SplitVectorWithRangeAdd(int growSize_) { - SetGrowSize(growSize_); - ReAllocate(growSize_); + explicit SplitVectorWithRangeAdd(ptrdiff_t growSize_) { + this->SetGrowSize(growSize_); + this->ReAllocate(growSize_); } + // Deleted so SplitVectorWithRangeAdd objects can not be copied. + SplitVectorWithRangeAdd(const SplitVectorWithRangeAdd &) = delete; + SplitVectorWithRangeAdd(SplitVectorWithRangeAdd &&) = delete; + void operator=(const SplitVectorWithRangeAdd &) = delete; + void operator=(SplitVectorWithRangeAdd &&) = delete; ~SplitVectorWithRangeAdd() { } - void RangeAddDelta(int start, int end, int delta) { + void RangeAddDelta(ptrdiff_t start, ptrdiff_t end, T delta) noexcept { // 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; + ptrdiff_t i = 0; + const ptrdiff_t rangeLength = end - start; + ptrdiff_t range1Length = rangeLength; + const ptrdiff_t part1Left = this->part1Length - start; if (range1Length > part1Left) range1Length = part1Left; while (i < range1Length) { - body[start++] += delta; + this->body[start++] += delta; i++; } - start += gapLength; + start += this->gapLength; while (i < rangeLength) { - body[start++] += delta; + this->body[start++] += delta; i++; } } @@ -51,36 +55,37 @@ public: /// When needed, positions after the interval are considered part of the last partition /// but the end of the last partition can be found with PositionFromPartition(last+1). +template 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; + T stepPartition; + T stepLength; + std::unique_ptr> body; // Move step forward - void ApplyStep(int partitionUpTo) { + void ApplyStep(T partitionUpTo) noexcept { if (stepLength != 0) { body->RangeAddDelta(stepPartition+1, partitionUpTo + 1, stepLength); } stepPartition = partitionUpTo; if (stepPartition >= body->Length()-1) { - stepPartition = body->Length()-1; + stepPartition = Partitions(); stepLength = 0; } } // Move step backward - void BackStep(int partitionDownTo) { + void BackStep(T partitionDownTo) noexcept { if (stepLength != 0) { body->RangeAddDelta(partitionDownTo+1, stepPartition+1, -stepLength); } stepPartition = partitionDownTo; } - void Allocate(int growSize) { - body = new SplitVectorWithRangeAdd(growSize); + void Allocate(ptrdiff_t growSize) { + body.reset(new SplitVectorWithRangeAdd(growSize)); stepPartition = 0; stepLength = 0; body->Insert(0, 0); // This value stays 0 for ever @@ -88,20 +93,24 @@ private: } public: - explicit Partitioning(int growSize) { + explicit Partitioning(int growSize) : stepPartition(0), stepLength(0) { Allocate(growSize); } + // Deleted so Partitioning objects can not be copied. + Partitioning(const Partitioning &) = delete; + Partitioning(Partitioning &&) = delete; + void operator=(const Partitioning &) = delete; + void operator=(Partitioning &&) = delete; + ~Partitioning() { - delete body; - body = 0; } - int Partitions() const { - return body->Length()-1; + T Partitions() const noexcept { + return static_cast(body->Length())-1; } - void InsertPartition(int partition, int pos) { + void InsertPartition(T partition, T pos) { if (stepPartition < partition) { ApplyStep(partition); } @@ -109,7 +118,7 @@ public: stepPartition++; } - void SetPartitionStartPosition(int partition, int pos) { + void SetPartitionStartPosition(T partition, T pos) noexcept { ApplyStep(partition+1); if ((partition < 0) || (partition > body->Length())) { return; @@ -117,7 +126,7 @@ public: body->SetValueAt(partition, pos); } - void InsertText(int partitionInsert, int delta) { + void InsertText(T partitionInsert, T delta) { // Point all the partitions after the insertion point further along in the buffer if (stepLength != 0) { if (partitionInsert >= stepPartition) { @@ -129,7 +138,7 @@ public: BackStep(partitionInsert); stepLength += delta; } else { - ApplyStep(body->Length()-1); + ApplyStep(Partitions()); stepPartition = partitionInsert; stepLength = delta; } @@ -139,7 +148,7 @@ public: } } - void RemovePartition(int partition) { + void RemovePartition(T partition) { if (partition > stepPartition) { ApplyStep(partition); stepPartition--; @@ -149,29 +158,30 @@ public: body->Delete(partition); } - int PositionFromPartition(int partition) const { + T PositionFromPartition(T partition) const noexcept { PLATFORM_ASSERT(partition >= 0); PLATFORM_ASSERT(partition < body->Length()); - if ((partition < 0) || (partition >= body->Length())) { + const ptrdiff_t lengthBody = body->Length(); + if ((partition < 0) || (partition >= lengthBody)) { return 0; } - int pos = body->ValueAt(partition); + T pos = body->ValueAt(partition); if (partition > stepPartition) pos += stepLength; return pos; } /// Return value in range [0 .. Partitions() - 1] even for arguments outside interval - int PartitionFromPosition(int pos) const { + T PartitionFromPosition(T pos) const noexcept { 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; + if (pos >= (PositionFromPartition(Partitions()))) + return Partitions() - 1; + T lower = 0; + T upper = Partitions(); do { - int middle = (upper + lower + 1) / 2; // Round high - int posMiddle = body->ValueAt(middle); + const T middle = (upper + lower + 1) / 2; // Round high + T posMiddle = body->ValueAt(middle); if (middle > stepPartition) posMiddle += stepLength; if (pos < posMiddle) { @@ -184,15 +194,11 @@ public: } void DeleteAll() { - int growSize = body->GetGrowSize(); - delete body; - Allocate(growSize); + Allocate(body->GetGrowSize()); } }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/PerLine.cxx b/dep/scintilla/scintilla-3.10.6/src/PerLine.cxx similarity index 53% rename from dep/scintilla/scintilla-3.6.0/src/PerLine.cxx rename to dep/scintilla/scintilla-3.10.6/src/PerLine.cxx index 7d574177..53751229 100644 --- a/dep/scintilla/scintilla-3.6.0/src/PerLine.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/PerLine.cxx @@ -5,11 +5,15 @@ // Copyright 1998-2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include +#include +#include +#include #include #include +#include #include +#include #include "Platform.h" @@ -20,124 +24,76 @@ #include "CellBuffer.h" #include "PerLine.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif MarkerHandleSet::MarkerHandleSet() { - root = 0; } MarkerHandleSet::~MarkerHandleSet() { - MarkerHandleNumber *mhn = root; - while (mhn) { - MarkerHandleNumber *mhnToFree = mhn; - mhn = mhn->next; - delete mhnToFree; - } - root = 0; + mhList.clear(); } -int MarkerHandleSet::Length() const { - int c = 0; - MarkerHandleNumber *mhn = root; - while (mhn) { - c++; - mhn = mhn->next; - } - return c; +bool MarkerHandleSet::Empty() const noexcept { + return mhList.empty(); } -int MarkerHandleSet::MarkValue() const { +int MarkerHandleSet::MarkValue() const noexcept { unsigned int m = 0; - MarkerHandleNumber *mhn = root; - while (mhn) { - m |= (1 << mhn->number); - mhn = mhn->next; + for (const MarkerHandleNumber &mhn : mhList) { + m |= (1 << mhn.number); } return m; } -bool MarkerHandleSet::Contains(int handle) const { - MarkerHandleNumber *mhn = root; - while (mhn) { - if (mhn->handle == handle) { +bool MarkerHandleSet::Contains(int handle) const noexcept { + for (const MarkerHandleNumber &mhn : mhList) { + if (mhn.handle == handle) { return true; } - mhn = mhn->next; } return false; } bool MarkerHandleSet::InsertHandle(int handle, int markerNum) { - MarkerHandleNumber *mhn = new MarkerHandleNumber; - mhn->handle = handle; - mhn->number = markerNum; - mhn->next = root; - root = mhn; + mhList.push_front(MarkerHandleNumber(handle, markerNum)); return true; } void MarkerHandleSet::RemoveHandle(int handle) { - MarkerHandleNumber **pmhn = &root; - while (*pmhn) { - MarkerHandleNumber *mhn = *pmhn; - if (mhn->handle == handle) { - *pmhn = mhn->next; - delete mhn; - return; - } - pmhn = &((*pmhn)->next); - } + mhList.remove_if([handle](const MarkerHandleNumber &mhn) { return mhn.handle == handle; }); } bool MarkerHandleSet::RemoveNumber(int markerNum, bool all) { bool performedDeletion = false; - MarkerHandleNumber **pmhn = &root; - while (*pmhn) { - MarkerHandleNumber *mhn = *pmhn; - if (mhn->number == markerNum) { - *pmhn = mhn->next; - delete mhn; + mhList.remove_if([&](const MarkerHandleNumber &mhn) { + if ((all || !performedDeletion) && (mhn.number == markerNum)) { performedDeletion = true; - if (!all) - break; - } else { - pmhn = &((*pmhn)->next); + return true; } - } + return false; + }); return performedDeletion; } void MarkerHandleSet::CombineWith(MarkerHandleSet *other) { - MarkerHandleNumber **pmhn = &other->root; - while (*pmhn) { - pmhn = &((*pmhn)->next); - } - *pmhn = root; - root = other->root; - other->root = 0; + mhList.splice_after(mhList.before_begin(), other->mhList); } LineMarkers::~LineMarkers() { - Init(); -} - -void LineMarkers::Init() { - for (int line = 0; line < markers.Length(); line++) { - delete markers[line]; - markers[line] = 0; - } markers.DeleteAll(); } -void LineMarkers::InsertLine(int line) { +void LineMarkers::Init() { + markers.DeleteAll(); +} + +void LineMarkers::InsertLine(Sci::Line line) { if (markers.Length()) { markers.Insert(line, 0); } } -void LineMarkers::RemoveLine(int line) { +void LineMarkers::RemoveLine(Sci::Line line) { // Retain the markers from the deleted line by oring them into the previous line if (markers.Length()) { if (line > 0) { @@ -147,9 +103,9 @@ void LineMarkers::RemoveLine(int line) { } } -int LineMarkers::LineFromHandle(int markerHandle) { +Sci::Line LineMarkers::LineFromHandle(int markerHandle) { if (markers.Length()) { - for (int line = 0; line < markers.Length(); line++) { + for (Sci::Line line = 0; line < markers.Length(); line++) { if (markers[line]) { if (markers[line]->Contains(markerHandle)) { return line; @@ -160,66 +116,62 @@ int LineMarkers::LineFromHandle(int markerHandle) { return -1; } -void LineMarkers::MergeMarkers(int pos) { - if (markers[pos + 1] != NULL) { - if (markers[pos] == NULL) - markers[pos] = new MarkerHandleSet; - markers[pos]->CombineWith(markers[pos + 1]); - delete markers[pos + 1]; - markers[pos + 1] = NULL; +void LineMarkers::MergeMarkers(Sci::Line line) { + if (markers[line + 1]) { + if (!markers[line]) + markers[line].reset(new MarkerHandleSet); + markers[line]->CombineWith(markers[line + 1].get()); + markers[line + 1].reset(); } } -int LineMarkers::MarkValue(int line) { +int LineMarkers::MarkValue(Sci::Line line) noexcept { if (markers.Length() && (line >= 0) && (line < markers.Length()) && markers[line]) return markers[line]->MarkValue(); else return 0; } -int LineMarkers::MarkerNext(int lineStart, int mask) const { +Sci::Line LineMarkers::MarkerNext(Sci::Line lineStart, int mask) const { if (lineStart < 0) lineStart = 0; - int length = markers.Length(); - for (int iLine = lineStart; iLine < length; iLine++) { - MarkerHandleSet *onLine = markers[iLine]; + const Sci::Line length = static_cast(markers.Length()); + for (Sci::Line iLine = lineStart; iLine < length; iLine++) { + const MarkerHandleSet *onLine = markers[iLine].get(); if (onLine && ((onLine->MarkValue() & mask) != 0)) - //if ((pdoc->GetMark(iLine) & lParam) != 0) return iLine; } return -1; } -int LineMarkers::AddMark(int line, int markerNum, int lines) { +int LineMarkers::AddMark(Sci::Line line, int markerNum, Sci::Line lines) { handleCurrent++; if (!markers.Length()) { // No existing markers so allocate one element per line - markers.InsertValue(0, lines, 0); + markers.InsertEmpty(0, lines); } if (line >= markers.Length()) { return -1; } if (!markers[line]) { // Need new structure to hold marker handle - markers[line] = new MarkerHandleSet(); + markers[line].reset(new MarkerHandleSet()); } markers[line]->InsertHandle(handleCurrent, markerNum); return handleCurrent; } -bool LineMarkers::DeleteMark(int line, int markerNum, bool all) { +bool LineMarkers::DeleteMark(Sci::Line line, int markerNum, bool all) { bool someChanges = false; if (markers.Length() && (line >= 0) && (line < markers.Length()) && markers[line]) { if (markerNum == -1) { someChanges = true; - delete markers[line]; - markers[line] = NULL; + markers[line].reset(); } else { someChanges = markers[line]->RemoveNumber(markerNum, all); - if (markers[line]->Length() == 0) { - delete markers[line]; - markers[line] = NULL; + if (markers[line]->Empty()) { + markers[line].reset(); } } } @@ -227,12 +179,11 @@ bool LineMarkers::DeleteMark(int line, int markerNum, bool all) { } void LineMarkers::DeleteMarkFromHandle(int markerHandle) { - int line = LineFromHandle(markerHandle); + const Sci::Line line = LineFromHandle(markerHandle); if (line >= 0) { markers[line]->RemoveHandle(markerHandle); - if (markers[line]->Length() == 0) { - delete markers[line]; - markers[line] = NULL; + if (markers[line]->Empty()) { + markers[line].reset(); } } } @@ -244,14 +195,14 @@ void LineLevels::Init() { levels.DeleteAll(); } -void LineLevels::InsertLine(int line) { +void LineLevels::InsertLine(Sci::Line line) { if (levels.Length()) { - int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE; + const int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE; levels.InsertValue(line, 1, level); } } -void LineLevels::RemoveLine(int line) { +void LineLevels::RemoveLine(Sci::Line line) { if (levels.Length()) { // Move up following lines but merge header flag from this line // to line before to avoid a temporary disappearence causing expansion. @@ -264,7 +215,7 @@ void LineLevels::RemoveLine(int line) { } } -void LineLevels::ExpandLevels(int sizeNew) { +void LineLevels::ExpandLevels(Sci::Line sizeNew) { levels.InsertValue(levels.Length(), sizeNew - levels.Length(), SC_FOLDLEVELBASE); } @@ -272,7 +223,7 @@ void LineLevels::ClearLevels() { levels.DeleteAll(); } -int LineLevels::SetLevel(int line, int level, int lines) { +int LineLevels::SetLevel(Sci::Line line, int level, Sci::Line lines) { int prev = 0; if ((line >= 0) && (line < lines)) { if (!levels.Length()) { @@ -286,7 +237,7 @@ int LineLevels::SetLevel(int line, int level, int lines) { return prev; } -int LineLevels::GetLevel(int line) const { +int LineLevels::GetLevel(Sci::Line line) const { if (levels.Length() && (line >= 0) && (line < levels.Length())) { return levels[line]; } else { @@ -301,39 +252,39 @@ void LineState::Init() { lineStates.DeleteAll(); } -void LineState::InsertLine(int line) { +void LineState::InsertLine(Sci::Line line) { if (lineStates.Length()) { lineStates.EnsureLength(line); - int val = (line < lineStates.Length()) ? lineStates[line] : 0; + const int val = (line < lineStates.Length()) ? lineStates[line] : 0; lineStates.Insert(line, val); } } -void LineState::RemoveLine(int line) { +void LineState::RemoveLine(Sci::Line line) { if (lineStates.Length() > line) { lineStates.Delete(line); } } -int LineState::SetLineState(int line, int state) { +int LineState::SetLineState(Sci::Line line, int state) { lineStates.EnsureLength(line + 1); - int stateOld = lineStates[line]; + const int stateOld = lineStates[line]; lineStates[line] = state; return stateOld; } -int LineState::GetLineState(int line) { +int LineState::GetLineState(Sci::Line line) { if (line < 0) return 0; lineStates.EnsureLength(line + 1); return lineStates[line]; } -int LineState::GetMaxLineState() const { - return lineStates.Length(); +Sci::Line LineState::GetMaxLineState() const { + return static_cast(lineStates.Length()); } -static int NumberLines(const char *text) { +static int NumberLines(const char *text) noexcept { if (text) { int newLines = 0; while (*text) { @@ -366,157 +317,146 @@ void LineAnnotation::Init() { ClearAll(); } -void LineAnnotation::InsertLine(int line) { +void LineAnnotation::InsertLine(Sci::Line line) { if (annotations.Length()) { annotations.EnsureLength(line); - annotations.Insert(line, 0); + annotations.Insert(line, std::unique_ptr()); } } -void LineAnnotation::RemoveLine(int line) { +void LineAnnotation::RemoveLine(Sci::Line line) { if (annotations.Length() && (line > 0) && (line <= annotations.Length())) { - delete []annotations[line-1]; + annotations[line-1].reset(); annotations.Delete(line-1); } } -bool LineAnnotation::MultipleStyles(int line) const { +bool LineAnnotation::MultipleStyles(Sci::Line line) const { if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line]) - return reinterpret_cast(annotations[line])->style == IndividualStyles; + return reinterpret_cast(annotations[line].get())->style == IndividualStyles; + else + return false; +} + +int LineAnnotation::Style(Sci::Line line) const { + if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line]) + return reinterpret_cast(annotations[line].get())->style; else return 0; } -int LineAnnotation::Style(int line) const { +const char *LineAnnotation::Text(Sci::Line line) const { if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line]) - return reinterpret_cast(annotations[line])->style; + return annotations[line].get()+sizeof(AnnotationHeader); else - return 0; + return nullptr; } -const char *LineAnnotation::Text(int line) const { - if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line]) - return annotations[line]+sizeof(AnnotationHeader); - else - return 0; -} - -const unsigned char *LineAnnotation::Styles(int line) const { +const unsigned char *LineAnnotation::Styles(Sci::Line line) const { if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line] && MultipleStyles(line)) - return reinterpret_cast(annotations[line] + sizeof(AnnotationHeader) + Length(line)); + return reinterpret_cast(annotations[line].get() + sizeof(AnnotationHeader) + Length(line)); else - return 0; + return nullptr; } static char *AllocateAnnotation(int length, int style) { - size_t len = sizeof(AnnotationHeader) + length + ((style == IndividualStyles) ? length : 0); - char *ret = new char[len]; - memset(ret, 0, len); + const size_t len = sizeof(AnnotationHeader) + length + ((style == IndividualStyles) ? length : 0); + char *ret = new char[len](); return ret; } -void LineAnnotation::SetText(int line, const char *text) { +void LineAnnotation::SetText(Sci::Line line, const char *text) { if (text && (line >= 0)) { annotations.EnsureLength(line+1); - int style = Style(line); - if (annotations[line]) { - delete []annotations[line]; - } - annotations[line] = AllocateAnnotation(static_cast(strlen(text)), style); - AnnotationHeader *pah = reinterpret_cast(annotations[line]); + const int style = Style(line); + annotations[line].reset(AllocateAnnotation(static_cast(strlen(text)), style)); + char *pa = annotations[line].get(); + assert(pa); + AnnotationHeader *pah = reinterpret_cast(pa); pah->style = static_cast(style); pah->length = static_cast(strlen(text)); pah->lines = static_cast(NumberLines(text)); - memcpy(annotations[line]+sizeof(AnnotationHeader), text, pah->length); + memcpy(pa+sizeof(AnnotationHeader), text, pah->length); } else { if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line]) { - delete []annotations[line]; - annotations[line] = 0; + annotations[line].reset(); } } } void LineAnnotation::ClearAll() { - for (int line = 0; line < annotations.Length(); line++) { - delete []annotations[line]; - annotations[line] = 0; - } annotations.DeleteAll(); } -void LineAnnotation::SetStyle(int line, int style) { +void LineAnnotation::SetStyle(Sci::Line line, int style) { annotations.EnsureLength(line+1); if (!annotations[line]) { - annotations[line] = AllocateAnnotation(0, style); + annotations[line].reset(AllocateAnnotation(0, style)); } - reinterpret_cast(annotations[line])->style = static_cast(style); + reinterpret_cast(annotations[line].get())->style = static_cast(style); } -void LineAnnotation::SetStyles(int line, const unsigned char *styles) { +void LineAnnotation::SetStyles(Sci::Line line, const unsigned char *styles) { if (line >= 0) { annotations.EnsureLength(line+1); if (!annotations[line]) { - annotations[line] = AllocateAnnotation(0, IndividualStyles); + annotations[line].reset(AllocateAnnotation(0, IndividualStyles)); } else { - AnnotationHeader *pahSource = reinterpret_cast(annotations[line]); + const AnnotationHeader *pahSource = reinterpret_cast(annotations[line].get()); if (pahSource->style != IndividualStyles) { char *allocation = AllocateAnnotation(pahSource->length, IndividualStyles); AnnotationHeader *pahAlloc = reinterpret_cast(allocation); pahAlloc->length = pahSource->length; pahAlloc->lines = pahSource->lines; - memcpy(allocation + sizeof(AnnotationHeader), annotations[line] + sizeof(AnnotationHeader), pahSource->length); - delete []annotations[line]; - annotations[line] = allocation; + memcpy(allocation + sizeof(AnnotationHeader), annotations[line].get() + sizeof(AnnotationHeader), pahSource->length); + annotations[line].reset(allocation); } } - AnnotationHeader *pah = reinterpret_cast(annotations[line]); + AnnotationHeader *pah = reinterpret_cast(annotations[line].get()); pah->style = IndividualStyles; - memcpy(annotations[line] + sizeof(AnnotationHeader) + pah->length, styles, pah->length); + memcpy(annotations[line].get() + sizeof(AnnotationHeader) + pah->length, styles, pah->length); } } -int LineAnnotation::Length(int line) const { +int LineAnnotation::Length(Sci::Line line) const { if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line]) - return reinterpret_cast(annotations[line])->length; + return reinterpret_cast(annotations[line].get())->length; else return 0; } -int LineAnnotation::Lines(int line) const { +int LineAnnotation::Lines(Sci::Line line) const { if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line]) - return reinterpret_cast(annotations[line])->lines; + return reinterpret_cast(annotations[line].get())->lines; else return 0; } LineTabstops::~LineTabstops() { - Init(); -} - -void LineTabstops::Init() { - for (int line = 0; line < tabstops.Length(); line++) { - delete tabstops[line]; - } tabstops.DeleteAll(); } -void LineTabstops::InsertLine(int line) { +void LineTabstops::Init() { + tabstops.DeleteAll(); +} + +void LineTabstops::InsertLine(Sci::Line line) { if (tabstops.Length()) { tabstops.EnsureLength(line); - tabstops.Insert(line, 0); + tabstops.Insert(line, nullptr); } } -void LineTabstops::RemoveLine(int line) { +void LineTabstops::RemoveLine(Sci::Line line) { if (tabstops.Length() > line) { - delete tabstops[line]; + tabstops[line].reset(); tabstops.Delete(line); } } -bool LineTabstops::ClearTabstops(int line) { +bool LineTabstops::ClearTabstops(Sci::Line line) { if (line < tabstops.Length()) { - TabstopList *tl = tabstops[line]; + TabstopList *tl = tabstops[line].get(); if (tl) { tl->clear(); return true; @@ -525,13 +465,13 @@ bool LineTabstops::ClearTabstops(int line) { return false; } -bool LineTabstops::AddTabstop(int line, int x) { +bool LineTabstops::AddTabstop(Sci::Line line, int x) { tabstops.EnsureLength(line + 1); if (!tabstops[line]) { - tabstops[line] = new TabstopList(); + tabstops[line].reset(new TabstopList()); } - TabstopList *tl = tabstops[line]; + TabstopList *tl = tabstops[line].get(); if (tl) { // tabstop positions are kept in order - insert in the right place std::vector::iterator it = std::lower_bound(tl->begin(), tl->end(), x); @@ -544,13 +484,13 @@ bool LineTabstops::AddTabstop(int line, int x) { return false; } -int LineTabstops::GetNextTabstop(int line, int x) const { +int LineTabstops::GetNextTabstop(Sci::Line line, int x) const { if (line < tabstops.Length()) { - TabstopList *tl = tabstops[line]; + TabstopList *tl = tabstops[line].get(); if (tl) { - for (size_t i = 0; i < tl->size(); i++) { - if ((*tl)[i] > x) { - return (*tl)[i]; + for (const int i : *tl) { + if (i > x) { + return i; } } } diff --git a/dep/scintilla/scintilla-3.10.6/src/PerLine.h b/dep/scintilla/scintilla-3.10.6/src/PerLine.h new file mode 100644 index 00000000..94dc17a2 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/PerLine.h @@ -0,0 +1,164 @@ +// Scintilla source code edit control +/** @file PerLine.h + ** Manages data associated with each line of the document + **/ +// Copyright 1998-2009 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef PERLINE_H +#define PERLINE_H + +namespace Scintilla { + +/** + * This holds the marker identifier and the marker type to display. + * MarkerHandleNumbers are members of lists. + */ +struct MarkerHandleNumber { + int handle; + int number; + MarkerHandleNumber(int handle_, int number_) noexcept : handle(handle_), number(number_) {} +}; + +/** + * A marker handle set contains any number of MarkerHandleNumbers. + */ +class MarkerHandleSet { + std::forward_list mhList; + +public: + MarkerHandleSet(); + // Deleted so MarkerHandleSet objects can not be copied. + MarkerHandleSet(const MarkerHandleSet &) = delete; + MarkerHandleSet(MarkerHandleSet &&) = delete; + void operator=(const MarkerHandleSet &) = delete; + void operator=(MarkerHandleSet &&) = delete; + ~MarkerHandleSet(); + bool Empty() const noexcept; + int MarkValue() const noexcept; ///< Bit set of marker numbers. + bool Contains(int handle) const noexcept; + bool InsertHandle(int handle, int markerNum); + void RemoveHandle(int handle); + bool RemoveNumber(int markerNum, bool all); + void CombineWith(MarkerHandleSet *other); +}; + +class LineMarkers : public PerLine { + SplitVector> markers; + /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big. + int handleCurrent; +public: + LineMarkers() : handleCurrent(0) { + } + // Deleted so LineMarkers objects can not be copied. + LineMarkers(const LineMarkers &) = delete; + LineMarkers(LineMarkers &&) = delete; + void operator=(const LineMarkers &) = delete; + void operator=(LineMarkers &&) = delete; + ~LineMarkers() override; + void Init() override; + void InsertLine(Sci::Line line) override; + void RemoveLine(Sci::Line line) override; + + int MarkValue(Sci::Line line) noexcept; + Sci::Line MarkerNext(Sci::Line lineStart, int mask) const; + int AddMark(Sci::Line line, int markerNum, Sci::Line lines); + void MergeMarkers(Sci::Line line); + bool DeleteMark(Sci::Line line, int markerNum, bool all); + void DeleteMarkFromHandle(int markerHandle); + Sci::Line LineFromHandle(int markerHandle); +}; + +class LineLevels : public PerLine { + SplitVector levels; +public: + LineLevels() { + } + // Deleted so LineLevels objects can not be copied. + LineLevels(const LineLevels &) = delete; + LineLevels(LineLevels &&) = delete; + void operator=(const LineLevels &) = delete; + void operator=(LineLevels &&) = delete; + ~LineLevels() override; + void Init() override; + void InsertLine(Sci::Line line) override; + void RemoveLine(Sci::Line line) override; + + void ExpandLevels(Sci::Line sizeNew=-1); + void ClearLevels(); + int SetLevel(Sci::Line line, int level, Sci::Line lines); + int GetLevel(Sci::Line line) const; +}; + +class LineState : public PerLine { + SplitVector lineStates; +public: + LineState() { + } + // Deleted so LineState objects can not be copied. + LineState(const LineState &) = delete; + LineState(LineState &&) = delete; + void operator=(const LineState &) = delete; + void operator=(LineState &&) = delete; + ~LineState() override; + void Init() override; + void InsertLine(Sci::Line line) override; + void RemoveLine(Sci::Line line) override; + + int SetLineState(Sci::Line line, int state); + int GetLineState(Sci::Line line); + Sci::Line GetMaxLineState() const; +}; + +class LineAnnotation : public PerLine { + SplitVector> annotations; +public: + LineAnnotation() { + } + // Deleted so LineAnnotation objects can not be copied. + LineAnnotation(const LineAnnotation &) = delete; + LineAnnotation(LineAnnotation &&) = delete; + void operator=(const LineAnnotation &) = delete; + void operator=(LineAnnotation &&) = delete; + ~LineAnnotation() override; + void Init() override; + void InsertLine(Sci::Line line) override; + void RemoveLine(Sci::Line line) override; + + bool MultipleStyles(Sci::Line line) const; + int Style(Sci::Line line) const; + const char *Text(Sci::Line line) const; + const unsigned char *Styles(Sci::Line line) const; + void SetText(Sci::Line line, const char *text); + void ClearAll(); + void SetStyle(Sci::Line line, int style); + void SetStyles(Sci::Line line, const unsigned char *styles); + int Length(Sci::Line line) const; + int Lines(Sci::Line line) const; +}; + +typedef std::vector TabstopList; + +class LineTabstops : public PerLine { + SplitVector> tabstops; +public: + LineTabstops() { + } + // Deleted so LineTabstops objects can not be copied. + LineTabstops(const LineTabstops &) = delete; + LineTabstops(LineTabstops &&) = delete; + void operator=(const LineTabstops &) = delete; + void operator=(LineTabstops &&) = delete; + ~LineTabstops() override; + void Init() override; + void InsertLine(Sci::Line line) override; + void RemoveLine(Sci::Line line) override; + + bool ClearTabstops(Sci::Line line); + bool AddTabstop(Sci::Line line, int x); + int GetNextTabstop(Sci::Line line, int x) const; +}; + +} + +#endif diff --git a/dep/scintilla/scintilla-3.10.6/src/Position.h b/dep/scintilla/scintilla-3.10.6/src/Position.h new file mode 100644 index 00000000..ab8223b5 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/Position.h @@ -0,0 +1,31 @@ +// Scintilla source code edit control +/** @file Position.h + ** Defines global type name Position in the Sci internal namespace. + **/ +// Copyright 2015 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef POSITION_H +#define POSITION_H + +/** + * 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. + * A Line is a document or screen line. + */ + +namespace Sci { + +typedef ptrdiff_t Position; +typedef ptrdiff_t Line; + +const Position invalidPosition = -1; + +template +inline constexpr T clamp(T val, T minVal, T maxVal) { + return (val > maxVal) ? maxVal : ((val < minVal) ? minVal : val); +} + +} + +#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/PositionCache.cxx b/dep/scintilla/scintilla-3.10.6/src/PositionCache.cxx similarity index 67% rename from dep/scintilla/scintilla-3.6.0/src/PositionCache.cxx rename to dep/scintilla/scintilla-3.10.6/src/PositionCache.cxx index 997a4bfa..8910a295 100644 --- a/dep/scintilla/scintilla-3.6.0/src/PositionCache.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/PositionCache.cxx @@ -5,23 +5,28 @@ // Copyright 1998-2007 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include #include #include +#include +#include #include "Platform.h" +#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" +#include "CharacterCategory.h" #include "Position.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -29,7 +34,6 @@ #include "CellBuffer.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -41,12 +45,9 @@ #include "Selection.h" #include "PositionCache.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif LineLayout::LineLayout(int maxLineLength_) : - lineStarts(0), lenLineStarts(0), lineNumber(-1), inCache(false), @@ -55,18 +56,14 @@ LineLayout::LineLayout(int maxLineLength_) : numCharsBeforeEOL(0), validity(llInvalid), xHighlightGuide(0), - highlightColumn(0), + highlightColumn(false), containsCaret(false), edgeColumn(0), - chars(0), - styles(0), - positions(0), + bracePreviousStyles{}, hotspot(0,0), widthLine(wrapWidthInfinite), lines(1), wrapIndent(0) { - bracePreviousStyles[0] = 0; - bracePreviousStyles[1] = 0; Resize(maxLineLength_); } @@ -77,24 +74,20 @@ LineLayout::~LineLayout() { void LineLayout::Resize(int maxLineLength_) { if (maxLineLength_ > maxLineLength) { Free(); - chars = new char[maxLineLength_ + 1]; - styles = new unsigned char[maxLineLength_ + 1]; + chars.reset(new char[maxLineLength_ + 1]); + styles.reset(new unsigned char[maxLineLength_ + 1]); // Extra position allocated as sometimes the Windows // GetTextExtentExPoint API writes an extra element. - positions = new XYPOSITION[maxLineLength_ + 1 + 1]; + positions.reset(new XYPOSITION[maxLineLength_ + 1 + 1]); maxLineLength = maxLineLength_; } } -void LineLayout::Free() { - delete []chars; - chars = 0; - delete []styles; - styles = 0; - delete []positions; - positions = 0; - delete []lineStarts; - lineStarts = 0; +void LineLayout::Free() noexcept { + chars.reset(); + styles.reset(); + positions.reset(); + lineStarts.reset(); } void LineLayout::Invalidate(validLevel validity_) { @@ -112,18 +105,18 @@ int LineLayout::LineStart(int line) const { } } -int LineLayout::LineLastVisible(int line) const { +int LineLayout::LineLastVisible(int line, Scope scope) const { if (line < 0) { return 0; } else if ((line >= lines-1) || !lineStarts) { - return numCharsBeforeEOL; + return scope == Scope::visibleOnly ? numCharsBeforeEOL : numCharsInLine; } else { return lineStarts[line+1]; } } -Range LineLayout::SubLineRange(int subLine) const { - return Range(LineStart(subLine), LineLastVisible(subLine)); +Range LineLayout::SubLineRange(int subLine, Scope scope) const { + return Range(LineStart(subLine), LineLastVisible(subLine, scope)); } bool LineLayout::InLine(int offset, int line) const { @@ -141,24 +134,23 @@ void LineLayout::SetLineStart(int line, int start) { else newLineStarts[i] = 0; } - delete []lineStarts; - lineStarts = newLineStarts; + lineStarts.reset(newLineStarts); lenLineStarts = newMaxLines; } lineStarts[line] = start; } -void LineLayout::SetBracesHighlight(Range rangeLine, const Position braces[], +void LineLayout::SetBracesHighlight(Range rangeLine, const Sci::Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle) { if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) { - int braceOffset = braces[0] - rangeLine.start; + const Sci::Position braceOffset = braces[0] - rangeLine.start; if (braceOffset < numCharsInLine) { bracePreviousStyles[0] = styles[braceOffset]; styles[braceOffset] = bracesMatchStyle; } } if (!ignoreStyle && rangeLine.ContainsCharacter(braces[1])) { - int braceOffset = braces[1] - rangeLine.start; + const Sci::Position braceOffset = braces[1] - rangeLine.start; if (braceOffset < numCharsInLine) { bracePreviousStyles[1] = styles[braceOffset]; styles[braceOffset] = bracesMatchStyle; @@ -170,15 +162,15 @@ void LineLayout::SetBracesHighlight(Range rangeLine, const Position braces[], } } -void LineLayout::RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle) { +void LineLayout::RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle) { if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) { - int braceOffset = braces[0] - rangeLine.start; + const Sci::Position braceOffset = braces[0] - rangeLine.start; if (braceOffset < numCharsInLine) { styles[braceOffset] = bracePreviousStyles[0]; } } if (!ignoreStyle && rangeLine.ContainsCharacter(braces[1])) { - int braceOffset = braces[1] - rangeLine.start; + const Sci::Position braceOffset = braces[1] - rangeLine.start; if (braceOffset < numCharsInLine) { styles[braceOffset] = bracePreviousStyles[1]; } @@ -186,22 +178,24 @@ void LineLayout::RestoreBracesHighlight(Range rangeLine, const Position braces[] xHighlightGuide = 0; } -int LineLayout::FindBefore(XYPOSITION x, int lower, int upper) const { +int LineLayout::FindBefore(XYPOSITION x, Range range) const { + Sci::Position lower = range.start; + Sci::Position upper = range.end; do { - int middle = (upper + lower + 1) / 2; // Round high - XYPOSITION posMiddle = positions[middle]; + const Sci::Position middle = (upper + lower + 1) / 2; // Round high + const XYPOSITION posMiddle = positions[middle]; if (x < posMiddle) { upper = middle - 1; } else { lower = middle; } } while (lower < upper); - return lower; + return static_cast(lower); } int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const { - int pos = FindBefore(x, range.start, range.end); + int pos = FindBefore(x, range); while (pos < range.end) { if (charPosition) { if (x < (positions[pos + 1])) { @@ -214,10 +208,10 @@ int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition) } pos++; } - return range.end; + return static_cast(range.end); } -Point LineLayout::PointFromPosition(int posInLine, int lineHeight) const { +Point LineLayout::PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const { Point pt; // In case of very long line put x at arbitrary large position if (posInLine > maxLineLength) { @@ -225,13 +219,19 @@ Point LineLayout::PointFromPosition(int posInLine, int lineHeight) const { } for (int subLine = 0; subLine < lines; subLine++) { - const Range rangeSubLine = SubLineRange(subLine); + const Range rangeSubLine = SubLineRange(subLine, Scope::visibleOnly); if (posInLine >= rangeSubLine.start) { pt.y = static_cast(subLine*lineHeight); if (posInLine <= rangeSubLine.end) { pt.x = positions[posInLine] - positions[rangeSubLine.start]; if (rangeSubLine.start != 0) // Wrapped lines may be indented pt.x += wrapIndent; + if (pe & peSubLineEnd) // Return end of first subline not start of next + break; + } else if ((pe & peLineEnd) && (subLine == (lines-1))) { + pt.x = positions[numCharsInLine] - positions[rangeSubLine.start]; + if (rangeSubLine.start != 0) // Wrapped lines may be indented + pt.x += wrapIndent; } } else { break; @@ -260,7 +260,7 @@ void LineLayoutCache::Allocate(size_t length_) { cache.resize(length_); } -void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { +void LineLayoutCache::AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc) { PLATFORM_ASSERT(useCount == 0); size_t lengthForLevel = 0; if (level == llcCaret) { @@ -276,8 +276,7 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { } else { if (lengthForLevel < cache.size()) { for (size_t i = lengthForLevel; i < cache.size(); i++) { - delete cache[i]; - cache[i] = 0; + cache[i].reset(); } } cache.resize(lengthForLevel); @@ -285,18 +284,16 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { PLATFORM_ASSERT(cache.size() == lengthForLevel); } -void LineLayoutCache::Deallocate() { +void LineLayoutCache::Deallocate() noexcept { PLATFORM_ASSERT(useCount == 0); - for (size_t i = 0; i < cache.size(); i++) - delete cache[i]; cache.clear(); } void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) { if (!cache.empty() && !allInvalidated) { - for (size_t i = 0; i < cache.size(); i++) { - if (cache[i]) { - cache[i]->Invalidate(validity_); + for (const std::unique_ptr &ll : cache) { + if (ll) { + ll->Invalidate(validity_); } } if (validity_ == LineLayout::llInvalid) { @@ -305,7 +302,7 @@ void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) { } } -void LineLayoutCache::SetLevel(int level_) { +void LineLayoutCache::SetLevel(int level_) noexcept { allInvalidated = false; if ((level_ != -1) && (level != level_)) { level = level_; @@ -313,16 +310,16 @@ void LineLayoutCache::SetLevel(int level_) { } } -LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, - int linesOnScreen, int linesInDoc) { +LineLayout *LineLayoutCache::Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_, + Sci::Line linesOnScreen, Sci::Line linesInDoc) { AllocateForLevel(linesOnScreen, linesInDoc); if (styleClock != styleClock_) { Invalidate(LineLayout::llCheckTextAndStyle); styleClock = styleClock_; } allInvalidated = false; - int pos = -1; - LineLayout *ret = 0; + Sci::Position pos = -1; + LineLayout *ret = nullptr; if (level == llcCaret) { pos = 0; } else if (level == llcPage) { @@ -340,16 +337,15 @@ LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChar if (cache[pos]) { if ((cache[pos]->lineNumber != lineNumber) || (cache[pos]->maxLineLength < maxChars)) { - delete cache[pos]; - cache[pos] = 0; + cache[pos].reset(); } } if (!cache[pos]) { - cache[pos] = new LineLayout(maxChars); + cache[pos].reset(new LineLayout(maxChars)); } cache[pos]->lineNumber = lineNumber; cache[pos]->inCache = true; - ret = cache[pos]; + ret = cache[pos].get(); useCount++; } } @@ -362,7 +358,7 @@ LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChar return ret; } -void LineLayoutCache::Dispose(LineLayout *ll) { +void LineLayoutCache::Dispose(LineLayout *ll) noexcept { allInvalidated = false; if (ll) { if (!ll->inCache) { @@ -374,51 +370,58 @@ void LineLayoutCache::Dispose(LineLayout *ll) { } // Simply pack the (maximum 4) character bytes into an int -static inline int KeyFromString(const char *charBytes, size_t len) { +static unsigned int KeyFromString(const char *charBytes, size_t len) { PLATFORM_ASSERT(len <= 4); - int k=0; + unsigned int k=0; for (size_t i=0; i(charBytes[i]); + const unsigned char uc = charBytes[i]; + k += uc; } return k; } -SpecialRepresentations::SpecialRepresentations() { - std::fill(startByteHasReprs, startByteHasReprs+0x100, 0); +SpecialRepresentations::SpecialRepresentations() noexcept { + const short none = 0; + std::fill(startByteHasReprs, std::end(startByteHasReprs), none); } void SpecialRepresentations::SetRepresentation(const char *charBytes, const char *value) { - MapRepresentation::iterator it = mapReprs.find(KeyFromString(charBytes, UTF8MaxBytes)); + const unsigned int key = KeyFromString(charBytes, UTF8MaxBytes); + MapRepresentation::iterator it = mapReprs.find(key); if (it == mapReprs.end()) { // New entry so increment for first byte - startByteHasReprs[static_cast(charBytes[0])]++; + const unsigned char ucStart = charBytes[0]; + startByteHasReprs[ucStart]++; } - mapReprs[KeyFromString(charBytes, UTF8MaxBytes)] = Representation(value); + mapReprs[key] = Representation(value); } void SpecialRepresentations::ClearRepresentation(const char *charBytes) { MapRepresentation::iterator it = mapReprs.find(KeyFromString(charBytes, UTF8MaxBytes)); if (it != mapReprs.end()) { mapReprs.erase(it); - startByteHasReprs[static_cast(charBytes[0])]--; + const unsigned char ucStart = charBytes[0]; + startByteHasReprs[ucStart]--; } } const Representation *SpecialRepresentations::RepresentationFromCharacter(const char *charBytes, size_t len) const { PLATFORM_ASSERT(len <= 4); - if (!startByteHasReprs[static_cast(charBytes[0])]) - return 0; + const unsigned char ucStart = charBytes[0]; + if (!startByteHasReprs[ucStart]) + return nullptr; MapRepresentation::const_iterator it = mapReprs.find(KeyFromString(charBytes, len)); if (it != mapReprs.end()) { return &(it->second); } - return 0; + return nullptr; } bool SpecialRepresentations::Contains(const char *charBytes, size_t len) const { PLATFORM_ASSERT(len <= 4); - if (!startByteHasReprs[static_cast(charBytes[0])]) + const unsigned char ucStart = charBytes[0]; + if (!startByteHasReprs[ucStart]) return false; MapRepresentation::const_iterator it = mapReprs.find(KeyFromString(charBytes, len)); return it != mapReprs.end(); @@ -426,26 +429,28 @@ bool SpecialRepresentations::Contains(const char *charBytes, size_t len) const { void SpecialRepresentations::Clear() { mapReprs.clear(); - std::fill(startByteHasReprs, startByteHasReprs+0x100, 0); + const short none = 0; + std::fill(startByteHasReprs, std::end(startByteHasReprs), none); } -void BreakFinder::Insert(int val) { - if (val > nextBreak) { - const std::vector::iterator it = std::lower_bound(selAndEdge.begin(), selAndEdge.end(), val); +void BreakFinder::Insert(Sci::Position val) { + const int posInLine = static_cast(val); + if (posInLine > nextBreak) { + const std::vector::iterator it = std::lower_bound(selAndEdge.begin(), selAndEdge.end(), posInLine); if (it == selAndEdge.end()) { - selAndEdge.push_back(val); - } else if (*it != val) { - selAndEdge.insert(it, 1, val); + selAndEdge.push_back(posInLine); + } else if (*it != posInLine) { + selAndEdge.insert(it, 1, posInLine); } } } -BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, int posLineStart_, +BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_, int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw) : ll(ll_), lineRange(lineRange_), posLineStart(posLineStart_), - nextBreak(lineRange_.start), + nextBreak(static_cast(lineRange_.start)), saeCurrentPos(0), saeNext(0), subBreak(-1), @@ -456,18 +461,18 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin // Search for first visible break // First find the first visible character if (xStart > 0.0f) - nextBreak = ll->FindBefore(static_cast(xStart), lineRange.start, lineRange.end); + nextBreak = ll->FindBefore(static_cast(xStart), lineRange); // Now back to a style break while ((nextBreak > lineRange.start) && (ll->styles[nextBreak] == ll->styles[nextBreak - 1])) { nextBreak--; } if (breakForSelection) { - SelectionPosition posStart(posLineStart); - SelectionPosition posEnd(posLineStart + lineRange.end); - SelectionSegment segmentLine(posStart, posEnd); + const SelectionPosition posStart(posLineStart); + const SelectionPosition posEnd(posLineStart + lineRange.end); + const SelectionSegment segmentLine(posStart, posEnd); for (size_t r=0; rCount(); r++) { - SelectionSegment portion = psel->Range(r).Intersect(segmentLine); + const SelectionSegment portion = psel->Range(r).Intersect(segmentLine); if (!(portion.start == portion.end)) { if (portion.start.IsValid()) Insert(portion.start.Position() - posLineStart); @@ -476,13 +481,13 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin } } } - if (pvsDraw && pvsDraw->indicatorsSetFore > 0) { - for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) { - if (pvsDraw->indicators[deco->indicator].OverridesTextFore()) { - int startPos = deco->rs.EndRun(posLineStart); + if (pvsDraw && pvsDraw->indicatorsSetFore) { + for (const IDecoration *deco : pdoc->decorations->View()) { + if (pvsDraw->indicators[deco->Indicator()].OverridesTextFore()) { + Sci::Position startPos = deco->EndRun(posLineStart); while (startPos < (posLineStart + lineRange.end)) { Insert(startPos - posLineStart); - startPos = deco->rs.EndRun(startPos); + startPos = deco->EndRun(startPos); } } } @@ -497,27 +502,29 @@ BreakFinder::~BreakFinder() { TextSegment BreakFinder::Next() { if (subBreak == -1) { - int prev = nextBreak; + const int prev = nextBreak; while (nextBreak < lineRange.end) { int charWidth = 1; if (encodingFamily == efUnicode) - charWidth = UTF8DrawBytes(reinterpret_cast(ll->chars) + nextBreak, lineRange.end - nextBreak); + charWidth = UTF8DrawBytes(reinterpret_cast(&ll->chars[nextBreak]), + static_cast(lineRange.end - nextBreak)); else if (encodingFamily == efDBCS) - charWidth = pdoc->IsDBCSLeadByte(ll->chars[nextBreak]) ? 2 : 1; - const Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth); + charWidth = pdoc->DBCSDrawBytes( + &ll->chars[nextBreak], static_cast(lineRange.end - nextBreak)); + const Representation *repr = preprs->RepresentationFromCharacter(&ll->chars[nextBreak], charWidth); if (((nextBreak > 0) && (ll->styles[nextBreak] != ll->styles[nextBreak - 1])) || repr || (nextBreak == saeNext)) { while ((nextBreak >= saeNext) && (saeNext < lineRange.end)) { saeCurrentPos++; - saeNext = (saeCurrentPos < selAndEdge.size()) ? selAndEdge[saeCurrentPos] : lineRange.end; + saeNext = static_cast((saeCurrentPos < selAndEdge.size()) ? selAndEdge[saeCurrentPos] : lineRange.end); } if ((nextBreak > prev) || repr) { // Have a segment to report if (nextBreak == prev) { nextBreak += charWidth; } else { - repr = 0; // Optimize -> should remember repr + repr = nullptr; // Optimize -> should remember repr } if ((nextBreak - prev) < lengthStartSubdivision) { return TextSegment(prev, nextBreak - prev, repr); @@ -535,12 +542,12 @@ TextSegment BreakFinder::Next() { } // 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. - int startSegment = subBreak; + const int startSegment = subBreak; if ((nextBreak - subBreak) <= lengthEachSubdivision) { subBreak = -1; return TextSegment(startSegment, nextBreak - startSegment); } else { - subBreak += pdoc->SafeSegment(ll->chars + subBreak, nextBreak-subBreak, lengthEachSubdivision); + subBreak += pdoc->SafeSegment(&ll->chars[subBreak], nextBreak-subBreak, lengthEachSubdivision); if (subBreak >= nextBreak) { subBreak = -1; return TextSegment(startSegment, nextBreak - startSegment); @@ -550,26 +557,36 @@ TextSegment BreakFinder::Next() { } } -bool BreakFinder::More() const { +bool BreakFinder::More() const noexcept { return (subBreak >= 0) || (nextBreak < lineRange.end); } -PositionCacheEntry::PositionCacheEntry() : - styleNumber(0), len(0), clock(0), positions(0) { +PositionCacheEntry::PositionCacheEntry() noexcept : + styleNumber(0), len(0), clock(0), positions(nullptr) { +} + +// Copy constructor not currently used, but needed for being element in std::vector. +PositionCacheEntry::PositionCacheEntry(const PositionCacheEntry &other) : + styleNumber(other.styleNumber), len(other.styleNumber), clock(other.styleNumber), positions(nullptr) { + if (other.positions) { + const size_t lenData = len + (len / sizeof(XYPOSITION)) + 1; + positions.reset(new XYPOSITION[lenData]); + memcpy(positions.get(), other.positions.get(), lenData * sizeof(XYPOSITION)); + } } void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_, - unsigned int len_, XYPOSITION *positions_, unsigned int clock_) { + unsigned int len_, const XYPOSITION *positions_, unsigned int clock_) { Clear(); styleNumber = styleNumber_; len = len_; clock = clock_; if (s_ && positions_) { - positions = new XYPOSITION[len + (len / 4) + 1]; + positions.reset(new XYPOSITION[len + (len / sizeof(XYPOSITION)) + 1]); for (unsigned int i=0; i(reinterpret_cast(positions + len)), s_, len); + memcpy(&positions[len], s_, len); } } @@ -577,9 +594,8 @@ PositionCacheEntry::~PositionCacheEntry() { Clear(); } -void PositionCacheEntry::Clear() { - delete []positions; - positions = 0; +void PositionCacheEntry::Clear() noexcept { + positions.reset(); styleNumber = 0; len = 0; clock = 0; @@ -588,7 +604,7 @@ void PositionCacheEntry::Clear() { bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const { if ((styleNumber == styleNumber_) && (len == len_) && - (memcmp(reinterpret_cast(reinterpret_cast(positions + len)), s_, len)== 0)) { + (memcmp(&positions[len], s_, len)== 0)) { for (unsigned int i=0; i other.clock; } -void PositionCacheEntry::ResetClock() { +void PositionCacheEntry::ResetClock() noexcept { if (clock > 0) { clock = 1; } @@ -631,10 +647,10 @@ PositionCache::~PositionCache() { Clear(); } -void PositionCache::Clear() { +void PositionCache::Clear() noexcept { if (!allClear) { - for (size_t i=0; i BreakFinder::lengthStartSubdivision) { // Break up into segments unsigned int startSegment = 0; XYPOSITION xStartSegment = 0; while (startSegment < len) { - unsigned int lenSegment = pdoc->SafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision); - FontAlias fontStyle = vstyle.styles[styleNumber].font; + const unsigned int lenSegment = pdoc->SafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision); surface->MeasureWidths(fontStyle, s + startSegment, lenSegment, positions + startSegment); for (unsigned int inSeg = 0; inSeg < lenSegment; inSeg++) { positions[startSegment + inSeg] += xStartSegment; @@ -685,7 +701,6 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns startSegment += lenSegment; } } else { - FontAlias fontStyle = vstyle.styles[styleNumber].font; surface->MeasureWidths(fontStyle, s, len, positions); } if (probe < pces.size()) { @@ -694,8 +709,8 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns 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; i20,000,000 line) documents. +*/ +class PointDocument { +public: + double x; + double y; + + explicit PointDocument(double x_ = 0, double y_ = 0) noexcept : x(x_), y(y_) { + } + + // Conversion from Point. + explicit PointDocument(Point pt) noexcept : x(pt.x), y(pt.y) { + } +}; + +// There are two points for some positions and this enumeration +// can choose between the end of the first line or subline +// and the start of the next line or subline. +enum PointEnd { + peDefault = 0x0, + peLineEnd = 0x1, + peSubLineEnd = 0x2 +}; + /** */ class LineLayout { private: friend class LineLayoutCache; - int *lineStarts; + std::unique_ptrlineStarts; int lenLineStarts; /// Drawing is only performed for @a maxLineLength characters on each line. - int lineNumber; + Sci::Line lineNumber; bool inCache; public: enum { wrapWidthInfinite = 0x7ffffff }; + int maxLineLength; int numCharsInLine; int numCharsBeforeEOL; @@ -36,9 +65,9 @@ public: bool highlightColumn; bool containsCaret; int edgeColumn; - char *chars; - unsigned char *styles; - XYPOSITION *positions; + std::unique_ptr chars; + std::unique_ptr styles; + std::unique_ptr positions; char bracePreviousStyles[2]; // Hotspot support @@ -50,21 +79,27 @@ public: XYPOSITION wrapIndent; // In pixels explicit LineLayout(int maxLineLength_); + // Deleted so LineLayout objects can not be copied. + LineLayout(const LineLayout &) = delete; + LineLayout(LineLayout &&) = delete; + void operator=(const LineLayout &) = delete; + void operator=(LineLayout &&) = delete; virtual ~LineLayout(); void Resize(int maxLineLength_); - void Free(); + void Free() noexcept; void Invalidate(validLevel validity_); int LineStart(int line) const; - int LineLastVisible(int line) const; - Range SubLineRange(int line) const; + enum class Scope { visibleOnly, includeEnd }; + int LineLastVisible(int line, Scope scope) const; + Range SubLineRange(int subLine, Scope scope) const; bool InLine(int offset, int line) const; void SetLineStart(int line, int start); - void SetBracesHighlight(Range rangeLine, const Position braces[], + void SetBracesHighlight(Range rangeLine, const Sci::Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle); - void RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle); - int FindBefore(XYPOSITION x, int lower, int upper) const; + void RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle); + int FindBefore(XYPOSITION x, Range range) const; int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const; - Point PointFromPosition(int posInLine, int lineHeight) const; + Point PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const; int EndLineStyle() const; }; @@ -72,16 +107,21 @@ public: */ class LineLayoutCache { int level; - std::vectorcache; + std::vector>cache; bool allInvalidated; int styleClock; int useCount; void Allocate(size_t length_); - void AllocateForLevel(int linesOnScreen, int linesInDoc); + void AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc); public: LineLayoutCache(); + // Deleted so LineLayoutCache objects can not be copied. + LineLayoutCache(const LineLayoutCache &) = delete; + LineLayoutCache(LineLayoutCache &&) = delete; + void operator=(const LineLayoutCache &) = delete; + void operator=(LineLayoutCache &&) = delete; virtual ~LineLayoutCache(); - void Deallocate(); + void Deallocate() noexcept; enum { llcNone=SC_CACHE_NONE, llcCaret=SC_CACHE_CARET, @@ -89,27 +129,33 @@ public: llcDocument=SC_CACHE_DOCUMENT }; void Invalidate(LineLayout::validLevel validity_); - void SetLevel(int level_); - int GetLevel() const { return level; } - LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, - int linesOnScreen, int linesInDoc); - void Dispose(LineLayout *ll); + void SetLevel(int level_) noexcept; + int GetLevel() const noexcept { return level; } + LineLayout *Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_, + Sci::Line linesOnScreen, Sci::Line linesInDoc); + void Dispose(LineLayout *ll) noexcept; }; class PositionCacheEntry { unsigned int styleNumber:8; unsigned int len:8; unsigned int clock:16; - XYPOSITION *positions; + std::unique_ptr positions; public: - PositionCacheEntry(); + PositionCacheEntry() noexcept; + // Copy constructor not currently used, but needed for being element in std::vector. + PositionCacheEntry(const PositionCacheEntry &); + // PositionCacheEntry objects should not be moved but MSVC 2015 requires this. + PositionCacheEntry(PositionCacheEntry &&) = default; + void operator=(const PositionCacheEntry &) = delete; + void operator=(PositionCacheEntry &&) = delete; ~PositionCacheEntry(); - void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock_); - void Clear(); + void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, const XYPOSITION *positions_, unsigned int clock_); + void Clear() noexcept; bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const; - static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len); - bool NewerThan(const PositionCacheEntry &other) const; - void ResetClock(); + static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len_) noexcept; + bool NewerThan(const PositionCacheEntry &other) const noexcept; + void ResetClock() noexcept; }; class Representation { @@ -119,13 +165,13 @@ public: } }; -typedef std::map MapRepresentation; +typedef std::map MapRepresentation; class SpecialRepresentations { MapRepresentation mapReprs; short startByteHasReprs[0x100]; public: - SpecialRepresentations(); + SpecialRepresentations() noexcept; void SetRepresentation(const char *charBytes, const char *value); void ClearRepresentation(const char *charBytes); const Representation *RepresentationFromCharacter(const char *charBytes, size_t len) const; @@ -137,10 +183,10 @@ struct TextSegment { int start; int length; const Representation *representation; - TextSegment(int start_=0, int length_=0, const Representation *representation_=0) : + TextSegment(int start_=0, int length_=0, const Representation *representation_=nullptr) noexcept : start(start_), length(length_), representation(representation_) { } - int end() const { + int end() const noexcept { return start + length; } }; @@ -149,7 +195,7 @@ struct TextSegment { class BreakFinder { const LineLayout *ll; Range lineRange; - int posLineStart; + Sci::Position posLineStart; int nextBreak; std::vector selAndEdge; unsigned int saeCurrentPos; @@ -158,44 +204,44 @@ class BreakFinder { const Document *pdoc; EncodingFamily encodingFamily; const SpecialRepresentations *preprs; - void Insert(int val); - // Private so BreakFinder objects can not be copied - BreakFinder(const BreakFinder &); + void Insert(Sci::Position val); public: // 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 }; - BreakFinder(const LineLayout *ll_, const Selection *psel, Range rangeLine_, int posLineStart_, + BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_, int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw); + // Deleted so BreakFinder objects can not be copied. + BreakFinder(const BreakFinder &) = delete; + BreakFinder(BreakFinder &&) = delete; + void operator=(const BreakFinder &) = delete; + void operator=(BreakFinder &&) = delete; ~BreakFinder(); TextSegment Next(); - bool More() const; + bool More() const noexcept; }; class PositionCache { std::vector pces; unsigned int clock; bool allClear; - // Private so PositionCache objects can not be copied - PositionCache(const PositionCache &); public: PositionCache(); + // Deleted so PositionCache objects can not be copied. + PositionCache(const PositionCache &) = delete; + PositionCache(PositionCache &&) = delete; + void operator=(const PositionCache &) = delete; + void operator=(PositionCache &&) = delete; ~PositionCache(); - void Clear(); + void Clear() noexcept; void SetSize(size_t size_); - size_t GetSize() const { return pces.size(); } + size_t GetSize() const noexcept { return pces.size(); } void MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber, - const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc); + const char *s, unsigned int len, XYPOSITION *positions, const Document *pdoc); }; -inline bool IsSpaceOrTab(int ch) { - return ch == ' ' || ch == '\t'; } -#ifdef SCI_NAMESPACE -} -#endif - #endif diff --git a/dep/scintilla/scintilla-3.6.0/src/RESearch.cxx b/dep/scintilla/scintilla-3.10.6/src/RESearch.cxx similarity index 93% rename from dep/scintilla/scintilla-3.6.0/src/RESearch.cxx rename to dep/scintilla/scintilla-3.10.6/src/RESearch.cxx index f8d9c622..5ce073a4 100644 --- a/dep/scintilla/scintilla-3.6.0/src/RESearch.cxx +++ b/dep/scintilla/scintilla-3.10.6/src/RESearch.cxx @@ -200,19 +200,19 @@ * matches: foo-foo fo-fo fob-fob foobar-foobar ... */ -#include +#include +#include #include #include #include +#include #include "Position.h" #include "CharClassify.h" #include "RESearch.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif #define OKP 1 #define NOP 0 @@ -240,7 +240,7 @@ using namespace Scintilla; #define BLKIND 0370 #define BITIND 07 -const char bitarr[] = { 1, 2, 4, 8, 16, 32, 64, '\200' }; +static const char bitarr[] = { 1, 2, 4, 8, 16, 32, 64, '\200' }; #define badpat(x) (*nfa = END, x) @@ -256,9 +256,10 @@ RESearch::RESearch(CharClassify *charClassTable) { charClass = charClassTable; sta = NOP; /* status of lastpat */ bol = 0; - std::fill(bittab, bittab + BITBLK, 0); - std::fill(tagstk, tagstk + MAXTAG, 0); - std::fill(nfa, nfa + MAXNFA, 0); + const unsigned char nul=0; + std::fill(bittab, std::end(bittab), nul); + std::fill(tagstk, std::end(tagstk), 0); + std::fill(nfa, std::end(nfa), '\0'); Clear(); } @@ -274,12 +275,12 @@ void RESearch::Clear() { } } -void RESearch::GrabMatches(CharacterIndexer &ci) { +void RESearch::GrabMatches(const CharacterIndexer &ci) { for (unsigned int i = 0; i < MAXTAG; i++) { if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) { - unsigned int len = eopat[i] - bopat[i]; + Sci::Position len = eopat[i] - bopat[i]; pat[i].resize(len); - for (unsigned int j = 0; j < len; j++) + for (Sci::Position j = 0; j < len; j++) pat[i][j] = ci.CharAt(bopat[i] + j); } } @@ -290,22 +291,17 @@ void RESearch::ChSet(unsigned char c) { } void RESearch::ChSetWithCase(unsigned char c, bool caseSensitive) { - if (caseSensitive) { - ChSet(c); - } else { + ChSet(c); + if (!caseSensitive) { if ((c >= 'a') && (c <= 'z')) { - ChSet(c); - ChSet(static_cast(c - 'a' + 'A')); + ChSet(c - 'a' + 'A'); } else if ((c >= 'A') && (c <= 'Z')) { - ChSet(c); - ChSet(static_cast(c - 'A' + 'a')); - } else { - ChSet(c); + ChSet(c - 'A' + 'a'); } } } -unsigned char escapeValue(unsigned char ch) { +static unsigned char escapeValue(unsigned char ch) { switch (ch) { case 'a': return '\a'; case 'b': return '\b'; @@ -358,7 +354,7 @@ int RESearch::GetBackslashExpression( incr = 0; // Most of the time, will skip the char "naturally". int c; int result = -1; - unsigned char bsc = *pattern; + const unsigned char bsc = *pattern; if (!bsc) { // Avoid overrun result = '\\'; // \ at end of pattern, take it literally @@ -376,9 +372,9 @@ int RESearch::GetBackslashExpression( result = escapeValue(bsc); break; case 'x': { - unsigned char hd1 = *(pattern + 1); - unsigned char hd2 = *(pattern + 2); - int hexValue = GetHexaChar(hd1, hd2); + const unsigned char hd1 = *(pattern + 1); + const unsigned char hd2 = *(pattern + 2); + const int hexValue = GetHexaChar(hd1, hd2); if (hexValue >= 0) { result = hexValue; incr = 2; // Must skip the digits @@ -434,7 +430,7 @@ int RESearch::GetBackslashExpression( return result; } -const char *RESearch::Compile(const char *pattern, int length, bool caseSensitive, bool posix) { +const char *RESearch::Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) { char *mp=nfa; /* nfa pointer */ char *lp; /* saved pointer */ char *sp=nfa; /* another one */ @@ -449,7 +445,7 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv if (!pattern || !length) { if (sta) - return 0; + return nullptr; else return badpat("No previous regular expression"); } @@ -648,7 +644,7 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv if (tagi > 0 && tagstk[tagi] == n) return badpat("Cyclical reference"); if (tagc > n) { - *mp++ = static_cast(REF); + *mp++ = REF; *mp++ = static_cast(n); } else { return badpat("Undetermined reference"); @@ -667,7 +663,7 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv if (*sp == BOT) return badpat("Null pattern inside \\(\\)"); if (tagi > 0) { - *mp++ = static_cast(EOT); + *mp++ = EOT; *mp++ = static_cast(tagstk[tagi--]); } else { return badpat("Unmatched \\)"); @@ -703,7 +699,7 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv if (*sp == BOT) return badpat("Null pattern inside ()"); if (tagi > 0) { - *mp++ = static_cast(EOT); + *mp++ = EOT; *mp++ = static_cast(tagstk[tagi--]); } else { return badpat("Unmatched )"); @@ -731,7 +727,7 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv return badpat((posix ? "Unmatched (" : "Unmatched \\(")); *mp = END; sta = OKP; - return 0; + return nullptr; } /* @@ -755,9 +751,9 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv * respectively. * */ -int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) { +int RESearch::Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp) { unsigned char c; - int ep = NOTFOUND; + Sci::Position ep = NOTFOUND; char *ap = nfa; bol = lp; @@ -784,6 +780,7 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) { lp++; if (lp >= endp) /* if EOS, fail, else fall through. */ return 0; + // Falls through. default: /* regular matching all the way. */ while (lp < endp) { ep = PMatch(ci, lp, endp, ap); @@ -834,7 +831,9 @@ int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) { extern void re_fail(char *,char); -#define isinset(x,y) ((x)[((y)&BLKIND)>>3] & bitarr[(y)&BITIND]) +static inline int isinset(const char *ap, unsigned char c) { + return ap[(c & BLKIND) >> 3] & bitarr[c & BITIND]; +} /* * skip values for CLO XXX to skip past the closure @@ -844,13 +843,13 @@ extern void re_fail(char *,char); #define CHRSKIP 3 /* [CLO] CHR chr END */ #define CCLSKIP 34 /* [CLO] CCL 32 bytes END */ -int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) { +Sci::Position RESearch::PMatch(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, char *ap) { int op, c, n; - int e; /* extra pointer for CLO */ - int bp; /* beginning of subpat... */ - int ep; /* ending of subpat... */ - int are; /* to save the line ptr. */ - int llp; /* lazy lp for LCLO */ + Sci::Position e; /* extra pointer for CLO */ + Sci::Position bp; /* beginning of subpat... */ + Sci::Position ep; /* ending of subpat... */ + Sci::Position are; /* to save the line ptr. */ + Sci::Position llp; /* lazy lp for LCLO */ while ((op = *ap++) != END) switch (op) { @@ -866,8 +865,7 @@ int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) { case CCL: if (lp >= endp) return NOTFOUND; - c = ci.CharAt(lp++); - if (!isinset(ap,c)) + if (!isinset(ap, ci.CharAt(lp++))) return NOTFOUND; ap += BITBLK; break; @@ -926,7 +924,7 @@ int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) { n = CHRSKIP; break; case CCL: - while ((lp < endp) && isinset(ap+1,ci.CharAt(lp))) + while ((lp < endp) && isinset(ap+1, ci.CharAt(lp))) lp++; n = CCLSKIP; break; @@ -940,7 +938,7 @@ int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) { llp = lp; e = NOTFOUND; while (llp >= are) { - int q; + Sci::Position q; if ((q = PMatch(ci, llp, endp, ap)) != NOTFOUND) { e = q; lp = llp; diff --git a/dep/scintilla/scintilla-3.6.0/src/RESearch.h b/dep/scintilla/scintilla-3.10.6/src/RESearch.h similarity index 54% rename from dep/scintilla/scintilla-3.6.0/src/RESearch.h rename to dep/scintilla/scintilla-3.10.6/src/RESearch.h index 3a7f0e4d..213055da 100644 --- a/dep/scintilla/scintilla-3.6.0/src/RESearch.h +++ b/dep/scintilla/scintilla-3.10.6/src/RESearch.h @@ -9,21 +9,11 @@ #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. - */ -#define MAXCHR 256 -#define CHRBIT 8 -#define BITBLK MAXCHR/CHRBIT class CharacterIndexer { public: - virtual char CharAt(int index)=0; + virtual char CharAt(Sci::Position index) const=0; virtual ~CharacterIndexer() { } }; @@ -32,29 +22,37 @@ class RESearch { public: explicit RESearch(CharClassify *charClassTable); + // No dynamic allocation so default copy constructor and assignment operator are OK. ~RESearch(); void Clear(); - void GrabMatches(CharacterIndexer &ci); - const char *Compile(const char *pattern, int length, bool caseSensitive, bool posix); - int Execute(CharacterIndexer &ci, int lp, int endp); + void GrabMatches(const CharacterIndexer &ci); + const char *Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix); + int Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp); enum { MAXTAG=10 }; - enum { MAXNFA=2048 }; enum { NOTFOUND=-1 }; - int bopat[MAXTAG]; - int eopat[MAXTAG]; + Sci::Position bopat[MAXTAG]; + Sci::Position eopat[MAXTAG]; std::string pat[MAXTAG]; private: + + enum { MAXNFA = 4096 }; + // The following enums are not meant to be changeable. + // They are for readability only. + enum { MAXCHR = 256 }; + enum { CHRBIT = 8 }; + enum { BITBLK = MAXCHR / CHRBIT }; + void ChSet(unsigned char c); void ChSetWithCase(unsigned char c, bool caseSensitive); int GetBackslashExpression(const char *pattern, int &incr); - int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap); + Sci::Position PMatch(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, char *ap); - int bol; - int tagstk[MAXTAG]; /* subpat tag stack */ + Sci::Position bol; + Sci::Position tagstk[MAXTAG]; /* subpat tag stack */ char nfa[MAXNFA]; /* automaton */ int sta; unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */ @@ -65,9 +63,7 @@ private: } }; -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.10.6/src/RunStyles.cxx b/dep/scintilla/scintilla-3.10.6/src/RunStyles.cxx new file mode 100644 index 00000000..04e4659a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/src/RunStyles.cxx @@ -0,0 +1,316 @@ +/** @file RunStyles.cxx + ** Data structure used to store sparse styles. + **/ +// Copyright 1998-2007 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "Platform.h" + +#include "Scintilla.h" +#include "Position.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h" + +using namespace Scintilla; + +// Find the first run at a position +template +DISTANCE RunStyles::RunFromPosition(DISTANCE position) const noexcept { + DISTANCE 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. +template +DISTANCE RunStyles::SplitRun(DISTANCE position) { + DISTANCE run = RunFromPosition(position); + const DISTANCE posRun = starts->PositionFromPartition(run); + if (posRun < position) { + STYLE runStyle = ValueAt(position); + run++; + starts->InsertPartition(run, position); + styles->InsertValue(run, 1, runStyle); + } + return run; +} + +template +void RunStyles::RemoveRun(DISTANCE run) { + starts->RemovePartition(run); + styles->DeleteRange(run, 1); +} + +template +void RunStyles::RemoveRunIfEmpty(DISTANCE run) { + if ((run < starts->Partitions()) && (starts->Partitions() > 1)) { + if (starts->PositionFromPartition(run) == starts->PositionFromPartition(run+1)) { + RemoveRun(run); + } + } +} + +template +void RunStyles::RemoveRunIfSameAsPrevious(DISTANCE run) { + if ((run > 0) && (run < starts->Partitions())) { + if (styles->ValueAt(run-1) == styles->ValueAt(run)) { + RemoveRun(run); + } + } +} + +template +RunStyles::RunStyles() { + starts.reset(new Partitioning(8)); + styles.reset(new SplitVector + + + + + ]] + local tokens = { + {'doctype', ''}, + {lexer.COMMENT, ''}, + {'element', ''}, + {'element', ''}, + {'element', ''}, + {lexer.COMMENT, '/* Another comment. */'}, + {lexer.IDENTIFIER, 'h1'}, + {'pseudoclass', ':hover'}, + {lexer.OPERATOR, '{'}, + {'property', 'color'}, + {lexer.OPERATOR, ':'}, + {'value', 'red'}, + {lexer.OPERATOR, ';'}, + {'property', 'border'}, + {lexer.OPERATOR, ':'}, + {lexer.NUMBER, '1'}, + {'unit', 'px'}, + {'value', 'solid'}, + {'color', '#0000FF'}, + {lexer.OPERATOR, ';'}, + {lexer.OPERATOR, '}'}, + {'element', ''}, + {'element', ''}, + {lexer.COMMENT, '/* A third comment. */'}, + {lexer.KEYWORD, 'var'}, + {lexer.IDENTIFIER, 'a'}, + {lexer.OPERATOR, '='}, + {lexer.NUMBER, '1'}, + {lexer.OPERATOR, '+'}, + {lexer.NUMBER, '2.0e3'}, + {lexer.OPERATOR, '-'}, + {lexer.NUMBER, '0x40'}, + {lexer.OPERATOR, ';'}, + {lexer.KEYWORD, 'var'}, + {lexer.IDENTIFIER, 'b'}, + {lexer.OPERATOR, '='}, + {lexer.STRING, '"two"'}, + {lexer.OPERATOR, '+'}, + {lexer.STRING, '`three`'}, + {lexer.OPERATOR, ';'}, + {lexer.KEYWORD, 'var'}, + {lexer.IDENTIFIER, 'c'}, + {lexer.OPERATOR, '='}, + {lexer.REGEX, '/pattern/i'}, + {lexer.OPERATOR, ';'}, + {lexer.COMMENT, '//'}, + {'element', ''}, + {'element', ''}, + {'unknown_element', ''}, + {'element', ''} + } + assert_lex(html, code, tokens) + + -- Folding tests. + local symbols = {'<', '', '{', '}', '/*', '*/', '//'} + for i = 1, #symbols do assert(html._FOLDPOINTS._SYMBOLS[symbols[i]]) end + assert(html._FOLDPOINTS['element']['<']) + assert(html._FOLDPOINTS['unknown_element']['<']) + assert(html._FOLDPOINTS[lexer.COMMENT]['']) + assert(html._FOLDPOINTS[lexer.OPERATOR]['{']) + assert(html._FOLDPOINTS[lexer.OPERATOR]['}']) + assert(html._FOLDPOINTS[lexer.COMMENT]['/*']) + assert(html._FOLDPOINTS[lexer.COMMENT]['*/']) + assert(html._FOLDPOINTS[lexer.COMMENT]['//']) + code = [[ + + foo + + + + + h1 { + foo; + } + function foo() { + bar; + } + ]] + local folds = {1, 5, 6, 10, 11} + local levels = assert_fold_points(html, code, folds) + assert(levels[3] > levels[4]) -- is ending fold point +end + +-- Tests the PHP lexer. +function test_php() + local php = lexer.load('php') + assert(php._NAME == 'php') + assert_default_styles(php) + assert_extra_styles(php, {'php_whitespace', 'php_tag'}) + + -- Lexing tests + -- Starting in HTML. + local code = [[

    ]] + local tokens = { + {'element', ''}, + {'php_tag', ''}, + {'element', ''} + } + local initial_style = php._TOKENSTYLES['html_whitespace'] + assert_lex(php, code, tokens, initial_style) + -- Starting in PHP. + code = [[echo "hi";]] + initial_style = php._TOKENSTYLES['php_whitespace'] + tokens = { + {lexer.KEYWORD, 'echo'}, + {lexer.STRING, '"hi"'}, + {lexer.OPERATOR, ';'}, + } + assert_lex(php, code, tokens, initial_style) + + -- Folding tests. + local symbols = {'', '/*', '*/', '//', '#', '{', '}', '(', ')'} + for i = 1, #symbols do assert(php._FOLDPOINTS._SYMBOLS[symbols[i]]) end + assert(php._FOLDPOINTS['php_tag']['']) + assert(php._FOLDPOINTS[lexer.COMMENT]['/*']) + assert(php._FOLDPOINTS[lexer.COMMENT]['*/']) + assert(php._FOLDPOINTS[lexer.COMMENT]['//']) + assert(php._FOLDPOINTS[lexer.COMMENT]['#']) + assert(php._FOLDPOINTS[lexer.OPERATOR]['{']) + assert(php._FOLDPOINTS[lexer.OPERATOR]['}']) + assert(php._FOLDPOINTS[lexer.OPERATOR]['(']) + assert(php._FOLDPOINTS[lexer.OPERATOR][')']) +end + +-- Tests the Ruby lexer. +function test_ruby() + local ruby = lexer.load('ruby') + + -- Lexing tests. + local code = [[ + # Comment. + require "foo" + $a = 1 + 2.0e3 - 0x40 if true + b = "two" + %q[three] + puts :c + ]] + local tokens = { + {lexer.COMMENT, '# Comment.'}, + {lexer.FUNCTION, 'require'}, + {lexer.STRING, '"foo"'}, + {lexer.VARIABLE, '$a'}, + {lexer.OPERATOR, '='}, + {lexer.NUMBER, '1'}, + {lexer.OPERATOR, '+'}, + {lexer.NUMBER, '2.0e3'}, + {lexer.OPERATOR, '-'}, + {lexer.NUMBER, '0x40'}, + {lexer.KEYWORD, 'if'}, + {lexer.KEYWORD, 'true'}, + {lexer.IDENTIFIER, 'b'}, + {lexer.OPERATOR, '='}, + {lexer.STRING, '"two"'}, + {lexer.OPERATOR, '+'}, + {lexer.STRING, '%q[three]'}, + {lexer.FUNCTION, 'puts'}, + {'symbol', ':c'} + } + assert_lex(ruby, code, tokens) + + -- Folding tests. + local fold_keywords = { + begin = 1, class = 1, def = 1, ['do'] = 1, ['for'] = 1, ['module'] = 1, + case = 1, ['if'] = function() end, ['while'] = function() end, + ['unless'] = function() end, ['until'] = function() end, ['end'] = -1 + } + for k, v in pairs(fold_keywords) do + assert(ruby._FOLDPOINTS._SYMBOLS[k]) + if type(v) == 'number' then + assert(ruby._FOLDPOINTS[lexer.KEYWORD][k] == v) + else + assert(type(ruby._FOLDPOINTS[lexer.KEYWORD][k]) == 'function') + end + end + local fold_operators = { '(', ')', '[', ']', '{', '}'} + for i = 1, #fold_operators do + assert(ruby._FOLDPOINTS._SYMBOLS[fold_operators[i]]) + assert(ruby._FOLDPOINTS[lexer.OPERATOR][fold_operators[i]]) + end + code = [=[ + class Foo + bar + end + foo.each do |v| + bar + end + def foo(bar) + baz + end + =begin + foo + =end + (foo, + bar, + baz) + [foo, + bar, + baz] + {foo, + bar, + baz} + ]=] + local folds = {1, 4, 7, 10, 13, 16, 19} + assert_fold_points(ruby, code, folds) +end + +-- Tests the Ruby and Rails lexers and tests lexer caching and lack of caching. +-- The Rails lexer inherits from Ruby and modifies some of its rules. Verify +-- the Ruby lexer is unaffected. +function test_ruby_and_rails() + local ruby = lexer.load('ruby', nil, true) + local rails = lexer.load('rails', nil, true) + local code = [[ + class Foo < ActiveRecord::Base + has_one :bar + end + ]] + local ruby_tokens = { + {lexer.KEYWORD, 'class'}, + {lexer.IDENTIFIER, 'Foo'}, + {lexer.OPERATOR, '<'}, + {lexer.IDENTIFIER, 'ActiveRecord'}, + {lexer.OPERATOR, ':'}, + {lexer.OPERATOR, ':'}, + {lexer.IDENTIFIER, 'Base'}, + {lexer.IDENTIFIER, 'has_one'}, + {'symbol', ':bar'}, + {lexer.KEYWORD, 'end'} + } + assert_lex(ruby, code, ruby_tokens) + + local rails_tokens = { + {lexer.KEYWORD, 'class'}, + {lexer.IDENTIFIER, 'Foo'}, + {lexer.OPERATOR, '<'}, + {lexer.IDENTIFIER, 'ActiveRecord'}, + {lexer.OPERATOR, ':'}, + {lexer.OPERATOR, ':'}, + {lexer.IDENTIFIER, 'Base'}, + {lexer.FUNCTION, 'has_one'}, + {'symbol', ':bar'}, + {lexer.KEYWORD, 'end'} + } + assert_lex(rails, code, rails_tokens) + + -- Load from the cache. + local ruby2 = lexer.load('ruby', nil, true) + assert_lex(ruby, code, ruby_tokens) + assert(ruby == ruby2) + + -- Load without a cache and perform the same validations. + ruby = lexer.load('ruby') + assert_lex(ruby, code, ruby_tokens) + rails = lexer.load('rails') + assert_lex(rails, code, rails_tokens) + ruby2 = lexer.load('ruby') + assert_lex(ruby, code, ruby_tokens) + assert(ruby ~= ruby2) +end + +-- Tests the RHTML lexer, which is a proxy for HTML and Rails. +function test_rhtml() + local rhtml = lexer.load('rhtml') + + -- Lexing tests. + -- Start in HTML. + local code = [[

    <% puts "hi" %>

    ]] + local rhtml_tokens = { + {'element', ''}, + {'rhtml_tag', '<%'}, + {lexer.FUNCTION, 'puts'}, + {lexer.STRING, '"hi"'}, + {'rhtml_tag', '%>'}, + {'element', ''} + } + local initial_style = rhtml._TOKENSTYLES['html_whitespace'] + assert_lex(rhtml, code, rhtml_tokens, initial_style) + -- Start in Ruby. + code = [[puts "hi"]] + rhtml_tokens = { + {lexer.FUNCTION, 'puts'}, + {lexer.STRING, '"hi"'} + } + initial_style = rhtml._TOKENSTYLES['rails_whitespace'] + assert_lex(rhtml, code, rhtml_tokens, initial_style) +end + +-- Run tests. +print('Starting test suite.') +local tests = {} +if #arg == 0 then + for k, v in pairs(_G) do + if k:find('^test_') and type(v) == 'function' then + tests[#tests + 1] = k + end + end +else + for i = 1, #arg do + if type(_G[arg[i]]) == 'function' then tests[#tests + 1] = arg[i] end + end +end +table.sort(tests) +local failed = 0 +for i = 1, #tests do + print(string.format('Running %s.', tests[i])) + local ok, errmsg = xpcall(_G[tests[i]], function(errmsg) + print(string.format('Failed! %s', debug.traceback(errmsg, 3))) + failed = failed + 1 + end) +end +print(string.format('%d/%d tests passed', #tests - failed, #tests)) diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/LICENSE_1_0.txt b/dep/scintilla/scintilla-3.10.6/test/unit/LICENSE_1_0.txt similarity index 100% rename from dep/scintilla/scintilla-3.6.0/test/unit/LICENSE_1_0.txt rename to dep/scintilla/scintilla-3.10.6/test/unit/LICENSE_1_0.txt diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/README b/dep/scintilla/scintilla-3.10.6/test/unit/README similarity index 100% rename from dep/scintilla/scintilla-3.6.0/test/unit/README rename to dep/scintilla/scintilla-3.10.6/test/unit/README diff --git a/dep/scintilla/scintilla-3.10.6/test/unit/Sci.natvis b/dep/scintilla/scintilla-3.10.6/test/unit/Sci.natvis new file mode 100644 index 00000000..0646036b --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/test/unit/Sci.natvis @@ -0,0 +1,20 @@ + + + + {{size = {lengthBody}}} + + lengthBody + (size) + part1Length + gapLength + + part1Length + body + + + lengthBody-part1Length + body+part1Length+gapLength + + + + diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/SciTE.properties b/dep/scintilla/scintilla-3.10.6/test/unit/SciTE.properties similarity index 100% rename from dep/scintilla/scintilla-3.6.0/test/unit/SciTE.properties rename to dep/scintilla/scintilla-3.10.6/test/unit/SciTE.properties diff --git a/dep/scintilla/scintilla-3.10.6/test/unit/UnitTester.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/UnitTester.cxx new file mode 100644 index 00000000..c5077f33 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/test/unit/UnitTester.cxx @@ -0,0 +1,44 @@ +// UnitTester.cpp : Defines the entry point for the console application. +// + +// Catch uses std::uncaught_exception which is deprecated in C++17. +// This define silences a warning from Visual C++. +#define _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING + +#include +#include + +#include +#include + +#include "Platform.h" + +#define CATCH_CONFIG_WINDOWS_CRTDBG +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" + +// Needed for PLATFORM_ASSERT in code being tested + +namespace Scintilla { + +void Platform::Assert(const char *c, const char *file, int line) { + fprintf(stderr, "Assertion [%s] failed at %s %d\n", c, file, line); + abort(); +} + +void Platform::DebugPrintf(const char *format, ...) { + char buffer[2000]; + va_list pArguments; + va_start(pArguments, format); + vsprintf(buffer, format, pArguments); + va_end(pArguments); + fprintf(stderr, "%s", buffer); +} + +} + +int main(int argc, char* argv[]) { + const int result = Catch::Session().run(argc, argv); + + return result; +} diff --git a/dep/scintilla/scintilla-3.10.6/test/unit/UnitTester.vcxproj b/dep/scintilla/scintilla-3.10.6/test/unit/UnitTester.vcxproj new file mode 100644 index 00000000..0f62f90a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/test/unit/UnitTester.vcxproj @@ -0,0 +1,166 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {35688A27-D91B-453A-8A05-65A7F28DEFBF} + Win32Proj + UnitTester + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS=1;_SCL_SECURE_NO_WARNINGS=1;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\include\;..\..\src\;..\..\lexlib\ + + + Console + true + + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS=1;_SCL_SECURE_NO_WARNINGS=1;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\include\;..\..\src\;..\..\lexlib\ + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS=1;_SCL_SECURE_NO_WARNINGS=1;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\include\;..\..\src\;..\..\lexlib\ + + + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS=1;_SCL_SECURE_NO_WARNINGS=1;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\include\;..\..\src\;..\..\lexlib\ + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/scintilla/scintilla-3.10.6/test/unit/catch.hpp b/dep/scintilla/scintilla-3.10.6/test/unit/catch.hpp new file mode 100644 index 00000000..362f8693 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/test/unit/catch.hpp @@ -0,0 +1,12012 @@ +/* + * Catch v2.0.1 + * Generated: 2017-11-03 11:53:39.642003 + * ---------------------------------------------------------- + * This file has been merged from multiple headers. Please don't edit it directly + * Copyright (c) 2017 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +// start catch.hpp + + +#ifdef __clang__ +# pragma clang system_header +#elif defined __GNUC__ +# pragma GCC system_header +#endif + +// start catch_suppress_warnings.h + +#ifdef __clang__ +# ifdef __ICC // icpc defines the __clang__ macro +# pragma warning(push) +# pragma warning(disable: 161 1682) +# else // __ICC +# pragma clang diagnostic ignored "-Wglobal-constructors" +# pragma clang diagnostic ignored "-Wvariadic-macros" +# pragma clang diagnostic ignored "-Wc99-extensions" +# pragma clang diagnostic ignored "-Wunused-variable" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +# pragma clang diagnostic ignored "-Wswitch-enum" +# pragma clang diagnostic ignored "-Wcovered-switch-default" +# endif +#elif defined __GNUC__ +# pragma GCC diagnostic ignored "-Wvariadic-macros" +# pragma GCC diagnostic ignored "-Wunused-variable" +# pragma GCC diagnostic ignored "-Wparentheses" + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpadded" +#endif +// end catch_suppress_warnings.h +#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) +# define CATCH_IMPL +# define CATCH_CONFIG_EXTERNAL_INTERFACES +# if defined(CATCH_CONFIG_DISABLE_MATCHERS) +# undef CATCH_CONFIG_DISABLE_MATCHERS +# endif +#endif + +// start catch_platform.h + +#ifdef __APPLE__ +# include +# if TARGET_OS_MAC == 1 +# define CATCH_PLATFORM_MAC +# elif TARGET_OS_IPHONE == 1 +# define CATCH_PLATFORM_IPHONE +# endif + +#elif defined(linux) || defined(__linux) || defined(__linux__) +# define CATCH_PLATFORM_LINUX + +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) +# define CATCH_PLATFORM_WINDOWS +#endif + +// end catch_platform.h +#ifdef CATCH_IMPL +# ifndef CLARA_CONFIG_MAIN +# define CLARA_CONFIG_MAIN_NOT_DEFINED +# define CLARA_CONFIG_MAIN +# endif +#endif + +// start catch_tag_alias_autoregistrar.h + +// start catch_common.h + +// start catch_compiler_capabilities.h + +// Detect a number of compiler features - by compiler +// The following features are defined: +// +// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? +// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? +// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? +// **************** +// Note to maintainers: if new toggles are added please document them +// in configuration.md, too +// **************** + +// In general each macro has a _NO_ form +// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. +// Many features, at point of detection, define an _INTERNAL_ macro, so they +// can be combined, en-mass, with the _NO_ forms later. + +#ifdef __cplusplus + +# if __cplusplus >= 201402L +# define CATCH_CPP14_OR_GREATER +# endif + +#endif + +#ifdef __clang__ + +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic push" ) \ + _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ + _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") +# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic pop" ) + +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic push" ) \ + _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) +# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic pop" ) + +#endif // __clang__ + +//////////////////////////////////////////////////////////////////////////////// +// We know some environments not to support full POSIX signals +#if defined(__CYGWIN__) || defined(__QNX__) + +# if !defined(CATCH_CONFIG_POSIX_SIGNALS) +# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +# endif + +#endif + +#ifdef __OS400__ +# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +# define CATCH_CONFIG_COLOUR_NONE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Cygwin +#ifdef __CYGWIN__ + +// Required for some versions of Cygwin to declare gettimeofday +// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin +# define _BSD_SOURCE + +#endif // __CYGWIN__ + +//////////////////////////////////////////////////////////////////////////////// +// Visual C++ +#ifdef _MSC_VER + +// Universal Windows platform does not support SEH +// Or console colours (or console at all...) +# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +# define CATCH_CONFIG_COLOUR_NONE +# else +# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH +# endif + +#endif // _MSC_VER + +//////////////////////////////////////////////////////////////////////////////// + +// Use of __COUNTER__ is suppressed during code analysis in +// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly +// handled by it. +// Otherwise all supported compilers support COUNTER macro, +// but user still might want to turn it off +#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) + #define CATCH_INTERNAL_CONFIG_COUNTER +#endif + +#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) +# define CATCH_CONFIG_COUNTER +#endif +#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) +# define CATCH_CONFIG_WINDOWS_SEH +#endif +// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. +#if !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) +# define CATCH_CONFIG_POSIX_SIGNALS +#endif + +#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS +# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS +#endif + +// end catch_compiler_capabilities.h +#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line +#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) +#ifdef CATCH_CONFIG_COUNTER +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) +#else +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +#endif + +#include +#include +#include + +namespace Catch { + + struct CaseSensitive { enum Choice { + Yes, + No + }; }; + + class NonCopyable { + NonCopyable( NonCopyable const& ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable& operator = ( NonCopyable const& ) = delete; + NonCopyable& operator = ( NonCopyable && ) = delete; + + protected: + NonCopyable(); + virtual ~NonCopyable(); + }; + + struct SourceLineInfo { + + SourceLineInfo() = delete; + SourceLineInfo( char const* _file, std::size_t _line ) noexcept; + + SourceLineInfo( SourceLineInfo const& other ) = default; + SourceLineInfo( SourceLineInfo && ) = default; + SourceLineInfo& operator = ( SourceLineInfo const& ) = default; + SourceLineInfo& operator = ( SourceLineInfo && ) = default; + + bool empty() const noexcept; + bool operator == ( SourceLineInfo const& other ) const noexcept; + bool operator < ( SourceLineInfo const& other ) const noexcept; + + char const* file; + std::size_t line; + }; + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); + + // This is just here to avoid compiler warnings with macro constants and boolean literals + bool isTrue( bool value ); + bool alwaysTrue(); + bool alwaysFalse(); + + // Use this in variadic streaming macros to allow + // >> +StreamEndStop + // as well as + // >> stuff +StreamEndStop + struct StreamEndStop { + std::string operator+() const; + }; + template + T const& operator + ( T const& value, StreamEndStop ) { + return value; + } +} + +#define CATCH_INTERNAL_LINEINFO \ + ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) + +// end catch_common.h +namespace Catch { + + struct RegistrarForTagAliases { + RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); + }; + +} // end namespace Catch + +#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } + +// end catch_tag_alias_autoregistrar.h +// start catch_test_registry.h + +// start catch_interfaces_testcase.h + +#include +#include + +namespace Catch { + + class TestSpec; + + struct ITestInvoker { + virtual void invoke () const = 0; + virtual ~ITestInvoker(); + }; + + using ITestCasePtr = std::shared_ptr; + + class TestCase; + struct IConfig; + + struct ITestCaseRegistry { + virtual ~ITestCaseRegistry(); + virtual std::vector const& getAllTests() const = 0; + virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; + }; + + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector const& getAllTestCasesSorted( IConfig const& config ); + +} + +// end catch_interfaces_testcase.h +// start catch_stringref.h + +#include +#include +#include + +namespace Catch { + + class StringData; + + /// A non-owning string class (similar to the forthcoming std::string_view) + /// Note that, because a StringRef may be a substring of another string, + /// it may not be null terminated. c_str() must return a null terminated + /// string, however, and so the StringRef will internally take ownership + /// (taking a copy), if necessary. In theory this ownership is not externally + /// visible - but it does mean (substring) StringRefs should not be shared between + /// threads. + class StringRef { + friend struct StringRefTestAccess; + + using size_type = std::size_t; + + char const* m_start; + size_type m_size; + + char* m_data = nullptr; + + void takeOwnership(); + + public: // construction/ assignment + StringRef() noexcept; + StringRef( StringRef const& other ) noexcept; + StringRef( StringRef&& other ) noexcept; + StringRef( char const* rawChars ) noexcept; + StringRef( char const* rawChars, size_type size ) noexcept; + StringRef( std::string const& stdString ) noexcept; + ~StringRef() noexcept; + + auto operator = ( StringRef other ) noexcept -> StringRef&; + operator std::string() const; + + void swap( StringRef& other ) noexcept; + + public: // operators + auto operator == ( StringRef const& other ) const noexcept -> bool; + auto operator != ( StringRef const& other ) const noexcept -> bool; + + auto operator[] ( size_type index ) const noexcept -> char; + + public: // named queries + auto empty() const noexcept -> bool; + auto size() const noexcept -> size_type; + auto numberOfCharacters() const noexcept -> size_type; + auto c_str() const -> char const*; + + public: // substrings and searches + auto substr( size_type start, size_type size ) const noexcept -> StringRef; + + private: // ownership queries - may not be consistent between calls + auto isOwned() const noexcept -> bool; + auto isSubstring() const noexcept -> bool; + auto data() const noexcept -> char const*; + }; + + auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string; + auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string; + auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string; + + auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; + +} // namespace Catch + +// end catch_stringref.h +namespace Catch { + +template +class TestInvokerAsMethod : public ITestInvoker { + void (C::*m_testAsMethod)(); +public: + TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {} + + void invoke() const override { + C obj; + (obj.*m_testAsMethod)(); + } +}; + +auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker*; + +template +auto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* { + return new(std::nothrow) TestInvokerAsMethod( testAsMethod ); +} + +struct NameAndTags { + NameAndTags( StringRef name_ = "", StringRef tags_ = "" ) noexcept; + StringRef name; + StringRef tags; +}; + +struct AutoReg : NonCopyable { + AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept; + ~AutoReg(); +}; + +} // end namespace Catch + +#if defined(CATCH_CONFIG_DISABLE) + #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \ + static void TestName() + #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \ + namespace{ \ + struct TestName : ClassName { \ + void test(); \ + }; \ + } \ + void TestName::test() + +#endif + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ + static void TestName(); \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, "", Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + static void TestName() + #define INTERNAL_CATCH_TESTCASE( ... ) \ + INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ \ + struct TestName : ClassName{ \ + void test(); \ + }; \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + void TestName::test() + #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ + INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, "", Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + +// end catch_test_registry.h +// start catch_capture.hpp + +// start catch_assertionhandler.h + +// start catch_decomposer.h + +// start catch_tostring.h + +#include +#include +#include +#include +#include + +#ifdef __OBJC__ +// start catch_objc_arc.hpp + +#import + +#ifdef __has_feature +#define CATCH_ARC_ENABLED __has_feature(objc_arc) +#else +#define CATCH_ARC_ENABLED 0 +#endif + +void arcSafeRelease( NSObject* obj ); +id performOptionalSelector( id obj, SEL sel ); + +#if !CATCH_ARC_ENABLED +inline void arcSafeRelease( NSObject* obj ) { + [obj release]; +} +inline id performOptionalSelector( id obj, SEL sel ) { + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; + return nil; +} +#define CATCH_UNSAFE_UNRETAINED +#define CATCH_ARC_STRONG +#else +inline void arcSafeRelease( NSObject* ){} +inline id performOptionalSelector( id obj, SEL sel ) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" +#endif + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + return nil; +} +#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained +#define CATCH_ARC_STRONG __strong +#endif + +// end catch_objc_arc.hpp +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless +#endif + +// We need a dummy global operator<< so we can bring it into Catch namespace later +struct Catch_global_namespace_dummy; +std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); + +namespace Catch { + // Bring in operator<< from global namespace into Catch namespace + using ::operator<<; + + namespace Detail { + + extern const std::string unprintableString; + + std::string rawMemoryToString( const void *object, std::size_t size ); + + template + std::string rawMemoryToString( const T& object ) { + return rawMemoryToString( &object, sizeof(object) ); + } + + template + class IsStreamInsertable { + template + static auto test(int) + -> decltype(std::declval() << std::declval(), std::true_type()); + + template + static auto test(...)->std::false_type; + + public: + static const bool value = decltype(test(0))::value; + }; + + } // namespace Detail + + // If we decide for C++14, change these to enable_if_ts + template + struct StringMaker { + template + static + typename std::enable_if<::Catch::Detail::IsStreamInsertable::value, std::string>::type + convert(const Fake& t) { + std::ostringstream sstr; + sstr << t; + return sstr.str(); + } + + template + static + typename std::enable_if::value, std::string>::type + convert(const Fake&) { + return Detail::unprintableString; + } + }; + + namespace Detail { + + // This function dispatches all stringification requests inside of Catch. + // Should be preferably called fully qualified, like ::Catch::Detail::stringify + template + std::string stringify(const T& e) { + return ::Catch::StringMaker::type>::type>::convert(e); + } + + } // namespace Detail + + // Some predefined specializations + + template<> + struct StringMaker { + static std::string convert(const std::string& str); + }; + template<> + struct StringMaker { + static std::string convert(const std::wstring& wstr); + }; + + template<> + struct StringMaker { + static std::string convert(char const * str); + }; + template<> + struct StringMaker { + static std::string convert(char * str); + }; + template<> + struct StringMaker { + static std::string convert(wchar_t const * str); + }; + template<> + struct StringMaker { + static std::string convert(wchar_t * str); + }; + + template + struct StringMaker { + static std::string convert(const char* str) { + return ::Catch::Detail::stringify(std::string{ str }); + } + }; + template + struct StringMaker { + static std::string convert(const char* str) { + return ::Catch::Detail::stringify(std::string{ str }); + } + }; + template + struct StringMaker { + static std::string convert(const char* str) { + return ::Catch::Detail::stringify(std::string{ str }); + } + }; + + template<> + struct StringMaker { + static std::string convert(int value); + }; + template<> + struct StringMaker { + static std::string convert(long value); + }; + template<> + struct StringMaker { + static std::string convert(long long value); + }; + template<> + struct StringMaker { + static std::string convert(unsigned int value); + }; + template<> + struct StringMaker { + static std::string convert(unsigned long value); + }; + template<> + struct StringMaker { + static std::string convert(unsigned long long value); + }; + + template<> + struct StringMaker { + static std::string convert(bool b); + }; + + template<> + struct StringMaker { + static std::string convert(char c); + }; + template<> + struct StringMaker { + static std::string convert(signed char c); + }; + template<> + struct StringMaker { + static std::string convert(unsigned char c); + }; + + template<> + struct StringMaker { + static std::string convert(std::nullptr_t); + }; + + template<> + struct StringMaker { + static std::string convert(float value); + }; + template<> + struct StringMaker { + static std::string convert(double value); + }; + + template + struct StringMaker { + template + static std::string convert(U* p) { + if (p) { + return ::Catch::Detail::rawMemoryToString(p); + } else { + return "nullptr"; + } + } + }; + + template + struct StringMaker { + static std::string convert(R C::* p) { + if (p) { + return ::Catch::Detail::rawMemoryToString(p); + } else { + return "nullptr"; + } + } + }; + + namespace Detail { + template + std::string rangeToString(InputIterator first, InputIterator last) { + std::ostringstream oss; + oss << "{ "; + if (first != last) { + oss << ::Catch::Detail::stringify(*first); + for (++first; first != last; ++first) + oss << ", " << ::Catch::Detail::stringify(*first); + } + oss << " }"; + return oss.str(); + } + } + + template + struct StringMaker > { + static std::string convert( std::vector const& v ) { + return ::Catch::Detail::rangeToString( v.begin(), v.end() ); + } + }; + + template + struct EnumStringMaker { + static std::string convert(const T& t) { + return ::Catch::Detail::stringify(static_cast::type>(t)); + } + }; + +#ifdef __OBJC__ + template<> + struct StringMaker { + static std::string convert(NSString * nsstring) { + if (!nsstring) + return "nil"; + return std::string("@") + [nsstring UTF8String]; + } + }; + template<> + struct StringMaker { + static std::string convert(NSObject* nsObject) { + return ::Catch::Detail::stringify([nsObject description]); + } + + }; + namespace Detail { + inline std::string stringify( NSString* nsstring ) { + return StringMaker::convert( nsstring ); + } + + } // namespace Detail +#endif // __OBJC__ + +} // namespace Catch + +////////////////////////////////////////////////////// +// Separate std-lib types stringification, so it can be selectively enabled +// This means that we do not bring in + +#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS) +# define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER +# define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +#endif + +// Separate std::pair specialization +#if defined(CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER) +#include +namespace Catch { + template + struct StringMaker > { + static std::string convert(const std::pair& pair) { + std::ostringstream oss; + oss << "{ " + << ::Catch::Detail::stringify(pair.first) + << ", " + << ::Catch::Detail::stringify(pair.second) + << " }"; + return oss.str(); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER + +// Separate std::tuple specialization +#if defined(CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER) +#include +namespace Catch { + namespace Detail { + template< + typename Tuple, + std::size_t N = 0, + bool = (N < std::tuple_size::value) + > + struct TupleElementPrinter { + static void print(const Tuple& tuple, std::ostream& os) { + os << (N ? ", " : " ") + << ::Catch::Detail::stringify(std::get(tuple)); + TupleElementPrinter::print(tuple, os); + } + }; + + template< + typename Tuple, + std::size_t N + > + struct TupleElementPrinter { + static void print(const Tuple&, std::ostream&) {} + }; + + } + + template + struct StringMaker> { + static std::string convert(const std::tuple& tuple) { + std::ostringstream os; + os << '{'; + Detail::TupleElementPrinter>::print(tuple, os); + os << " }"; + return os.str(); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER + +// Separate std::chrono::duration specialization +#if defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +#include +#include +#include + +template +struct ratio_string { + static std::string symbol(); +}; + +template +std::string ratio_string::symbol() { + std::ostringstream oss; + oss << '[' << Ratio::num << '/' + << Ratio::den << ']'; + return oss.str(); +} +template <> +struct ratio_string { + static std::string symbol() { return "a"; } +}; +template <> +struct ratio_string { + static std::string symbol() { return "f"; } +}; +template <> +struct ratio_string { + static std::string symbol() { return "p"; } +}; +template <> +struct ratio_string { + static std::string symbol() { return "n"; } +}; +template <> +struct ratio_string { + static std::string symbol() { return "u"; } +}; +template <> +struct ratio_string { + static std::string symbol() { return "m"; } +}; + +namespace Catch { + //////////// + // std::chrono::duration specializations + template + struct StringMaker> { + static std::string convert(std::chrono::duration const& duration) { + std::ostringstream oss; + oss << duration.count() << ' ' << ratio_string::symbol() << 's'; + return oss.str(); + } + }; + template + struct StringMaker>> { + static std::string convert(std::chrono::duration> const& duration) { + std::ostringstream oss; + oss << duration.count() << " s"; + return oss.str(); + } + }; + template + struct StringMaker>> { + static std::string convert(std::chrono::duration> const& duration) { + std::ostringstream oss; + oss << duration.count() << " m"; + return oss.str(); + } + }; + template + struct StringMaker>> { + static std::string convert(std::chrono::duration> const& duration) { + std::ostringstream oss; + oss << duration.count() << " h"; + return oss.str(); + } + }; + + //////////// + // std::chrono::time_point specialization + // Generic time_point cannot be specialized, only std::chrono::time_point + template + struct StringMaker> { + static std::string convert(std::chrono::time_point const& time_point) { + return ::Catch::Detail::stringify(time_point.time_since_epoch()) + " since epoch"; + } + }; + // std::chrono::time_point specialization + template + struct StringMaker> { + static std::string convert(std::chrono::time_point const& time_point) { + auto converted = std::chrono::system_clock::to_time_t(time_point); + +#ifdef _MSC_VER + std::tm timeInfo = {}; + gmtime_s(&timeInfo, &converted); +#else + std::tm* timeInfo = std::gmtime(&converted); +#endif + + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); + char timeStamp[timeStampSize]; + const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; + +#ifdef _MSC_VER + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); +#else + std::strftime(timeStamp, timeStampSize, fmt, timeInfo); +#endif + return std::string(timeStamp); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +// end catch_tostring.h +#include + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4389) // '==' : signed/unsigned mismatch +#pragma warning(disable:4018) // more "signed/unsigned mismatch" +#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) +#pragma warning(disable:4180) // qualifier applied to function type has no meaning +#endif + +namespace Catch { + + struct ITransientExpression { + virtual auto isBinaryExpression() const -> bool = 0; + virtual auto getResult() const -> bool = 0; + virtual void streamReconstructedExpression( std::ostream &os ) const = 0; + + // We don't actually need a virtual destructore, but many static analysers + // complain if it's not here :-( + virtual ~ITransientExpression(); + }; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); + + template + class BinaryExpr : public ITransientExpression { + bool m_result; + LhsT m_lhs; + StringRef m_op; + RhsT m_rhs; + + auto isBinaryExpression() const -> bool override { return true; } + auto getResult() const -> bool override { return m_result; } + + void streamReconstructedExpression( std::ostream &os ) const override { + formatReconstructedExpression + ( os, Catch::Detail::stringify( m_lhs ), m_op, Catch::Detail::stringify( m_rhs ) ); + } + + public: + BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) + : m_result( comparisonResult ), + m_lhs( lhs ), + m_op( op ), + m_rhs( rhs ) + {} + }; + + template + class UnaryExpr : public ITransientExpression { + LhsT m_lhs; + + auto isBinaryExpression() const -> bool override { return false; } + auto getResult() const -> bool override { return m_lhs ? true : false; } + + void streamReconstructedExpression( std::ostream &os ) const override { + os << Catch::Detail::stringify( m_lhs ); + } + + public: + UnaryExpr( LhsT lhs ) : m_lhs( lhs ) {} + }; + + // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int) + template + auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return lhs == rhs; }; + template + auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast( rhs ); } + template + auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast( rhs ); } + template + auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) == rhs; } + template + auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) == rhs; } + + template + auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return lhs != rhs; }; + template + auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast( rhs ); } + template + auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast( rhs ); } + template + auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) != rhs; } + template + auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) != rhs; } + + template + class ExprLhs { + LhsT m_lhs; + public: + ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} + + template + auto operator == ( RhsT const& rhs ) -> BinaryExpr const { + return BinaryExpr( compareEqual( m_lhs, rhs ), m_lhs, "==", rhs ); + } + auto operator == ( bool rhs ) -> BinaryExpr const { + return BinaryExpr( m_lhs == rhs, m_lhs, "==", rhs ); + } + + template + auto operator != ( RhsT const& rhs ) -> BinaryExpr const { + return BinaryExpr( compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs ); + } + auto operator != ( bool rhs ) -> BinaryExpr const { + return BinaryExpr( m_lhs != rhs, m_lhs, "!=", rhs ); + } + + template + auto operator > ( RhsT const& rhs ) -> BinaryExpr const { + return BinaryExpr( m_lhs > rhs, m_lhs, ">", rhs ); + } + template + auto operator < ( RhsT const& rhs ) -> BinaryExpr const { + return BinaryExpr( m_lhs < rhs, m_lhs, "<", rhs ); + } + template + auto operator >= ( RhsT const& rhs ) -> BinaryExpr const { + return BinaryExpr( m_lhs >= rhs, m_lhs, ">=", rhs ); + } + template + auto operator <= ( RhsT const& rhs ) -> BinaryExpr const { + return BinaryExpr( m_lhs <= rhs, m_lhs, "<=", rhs ); + } + + auto makeUnaryExpr() const -> UnaryExpr { + return UnaryExpr( m_lhs ); + } + }; + + void handleExpression( ITransientExpression const& expr ); + + template + void handleExpression( ExprLhs const& expr ) { + handleExpression( expr.makeUnaryExpr() ); + } + + struct Decomposer { + template + auto operator <= ( T const& lhs ) -> ExprLhs { + return ExprLhs( lhs ); + } + auto operator <=( bool value ) -> ExprLhs { + return ExprLhs( value ); + } + }; + +} // end namespace Catch + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +// end catch_decomposer.h +// start catch_assertioninfo.h + +// start catch_result_type.h + +namespace Catch { + + // ResultWas::OfType enum + struct ResultWas { enum OfType { + Unknown = -1, + Ok = 0, + Info = 1, + Warning = 2, + + FailureBit = 0x10, + + ExpressionFailed = FailureBit | 1, + ExplicitFailure = FailureBit | 2, + + Exception = 0x100 | FailureBit, + + ThrewException = Exception | 1, + DidntThrowException = Exception | 2, + + FatalErrorCondition = 0x200 | FailureBit + + }; }; + + bool isOk( ResultWas::OfType resultType ); + bool isJustInfo( int flags ); + + // ResultDisposition::Flags enum + struct ResultDisposition { enum Flags { + Normal = 0x01, + + ContinueOnFailure = 0x02, // Failures fail test, but execution continues + FalseTest = 0x04, // Prefix expression with ! + SuppressFail = 0x08 // Failures are reported but do not fail the test + }; }; + + ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ); + + bool shouldContinueOnFailure( int flags ); + bool isFalseTest( int flags ); + bool shouldSuppressFailure( int flags ); + +} // end namespace Catch + +// end catch_result_type.h +namespace Catch { + + struct AssertionInfo + { + StringRef macroName; + SourceLineInfo lineInfo; + StringRef capturedExpression; + ResultDisposition::Flags resultDisposition; + + // We want to delete this constructor but a compiler bug in 4.8 means + // the struct is then treated as non-aggregate + //AssertionInfo() = delete; + }; + +} // end namespace Catch + +// end catch_assertioninfo.h +namespace Catch { + + struct TestFailureException{}; + struct AssertionResultData; + + class LazyExpression { + friend class AssertionHandler; + friend struct AssertionStats; + + ITransientExpression const* m_transientExpression = nullptr; + bool m_isNegated; + public: + LazyExpression( bool isNegated ); + LazyExpression( LazyExpression const& other ); + LazyExpression& operator = ( LazyExpression const& ) = delete; + + explicit operator bool() const; + + friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; + }; + + class AssertionHandler { + AssertionInfo m_assertionInfo; + bool m_shouldDebugBreak = false; + bool m_shouldThrow = false; + bool m_inExceptionGuard = false; + + public: + AssertionHandler + ( StringRef macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ); + ~AssertionHandler(); + + void handle( ITransientExpression const& expr ); + + template + void handle( ExprLhs const& expr ) { + handle( expr.makeUnaryExpr() ); + } + void handle( ResultWas::OfType resultType ); + void handle( ResultWas::OfType resultType, StringRef const& message ); + void handle( ResultWas::OfType resultType, ITransientExpression const* expr, bool negated ); + void handle( AssertionResultData const& resultData, ITransientExpression const* expr ); + + auto shouldDebugBreak() const -> bool; + auto allowThrows() const -> bool; + void reactWithDebugBreak() const; + void reactWithoutDebugBreak() const; + void useActiveException(); + void setExceptionGuard(); + void unsetExceptionGuard(); + }; + + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ); + +} // namespace Catch + +// end catch_assertionhandler.h +// start catch_message.h + +#include +#include + +namespace Catch { + + struct MessageInfo { + MessageInfo( std::string const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ); + + std::string macroName; + std::string message; + SourceLineInfo lineInfo; + ResultWas::OfType type; + unsigned int sequence; + + bool operator == ( MessageInfo const& other ) const; + bool operator < ( MessageInfo const& other ) const; + private: + static unsigned int globalCount; + }; + + struct MessageStream { + + template + MessageStream& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + // !TBD reuse a global/ thread-local stream + std::ostringstream m_stream; + }; + + struct MessageBuilder : MessageStream { + MessageBuilder( std::string const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ); + + template + MessageBuilder& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + MessageInfo m_info; + }; + + class ScopedMessage { + public: + ScopedMessage( MessageBuilder const& builder ); + ~ScopedMessage(); + + MessageInfo m_info; + }; + +} // end namespace Catch + +// end catch_message.h +// start catch_interfaces_capture.h + +#include + +namespace Catch { + + class AssertionResult; + struct AssertionInfo; + struct SectionInfo; + struct SectionEndInfo; + struct MessageInfo; + struct Counts; + struct BenchmarkInfo; + struct BenchmarkStats; + + struct IResultCapture { + + virtual ~IResultCapture(); + + virtual void assertionStarting( AssertionInfo const& info ) = 0; + virtual void assertionEnded( AssertionResult const& result ) = 0; + virtual bool sectionStarted( SectionInfo const& sectionInfo, + Counts& assertions ) = 0; + virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; + virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; + + virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0; + virtual void benchmarkEnded( BenchmarkStats const& stats ) = 0; + + virtual void pushScopedMessage( MessageInfo const& message ) = 0; + virtual void popScopedMessage( MessageInfo const& message ) = 0; + + virtual std::string getCurrentTestName() const = 0; + virtual const AssertionResult* getLastResult() const = 0; + + virtual void exceptionEarlyReported() = 0; + + virtual void handleFatalErrorCondition( StringRef message ) = 0; + + virtual bool lastAssertionPassed() = 0; + virtual void assertionPassed() = 0; + virtual void assertionRun() = 0; + }; + + IResultCapture& getResultCapture(); +} + +// end catch_interfaces_capture.h +// start catch_debugger.h + +namespace Catch { + bool isDebuggerActive(); +} + +#ifdef CATCH_PLATFORM_MAC + + #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ + +#elif defined(CATCH_PLATFORM_LINUX) + // If we can use inline assembler, do it because this allows us to break + // directly at the location of the failing check instead of breaking inside + // raise() called from it, i.e. one stack frame below. + #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) + #define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */ + #else // Fall back to the generic way. + #include + + #define CATCH_TRAP() raise(SIGTRAP) + #endif +#elif defined(_MSC_VER) + #define CATCH_TRAP() __debugbreak() +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) void __stdcall DebugBreak(); + #define CATCH_TRAP() DebugBreak() +#endif + +#ifdef CATCH_TRAP + #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } +#else + #define CATCH_BREAK_INTO_DEBUGGER() Catch::alwaysTrue(); +#endif + +// end catch_debugger.h +#if !defined(CATCH_CONFIG_DISABLE) + +#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) + #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__ +#else + #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" +#endif + +#if defined(CATCH_CONFIG_FAST_COMPILE) +/////////////////////////////////////////////////////////////////////////////// +// We can speedup compilation significantly by breaking into debugger lower in +// the callstack, because then we don't have to expand CATCH_BREAK_INTO_DEBUGGER +// macro in each assertion +#define INTERNAL_CATCH_REACT( handler ) \ + handler.reactWithDebugBreak(); + +/////////////////////////////////////////////////////////////////////////////// +// Another way to speed-up compilation is to omit local try-catch for REQUIRE* +// macros. +// This can potentially cause false negative, if the test code catches +// the exception before it propagates back up to the runner. +#define INTERNAL_CATCH_TRY( capturer ) capturer.setExceptionGuard(); +#define INTERNAL_CATCH_CATCH( capturer ) capturer.unsetExceptionGuard(); + +#else // CATCH_CONFIG_FAST_COMPILE + +/////////////////////////////////////////////////////////////////////////////// +// In the event of a failure works out if the debugger needs to be invoked +// and/or an exception thrown and takes appropriate action. +// This needs to be done as a macro so the debugger will stop in the user +// source code rather than in Catch library code +#define INTERNAL_CATCH_REACT( handler ) \ + if( handler.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \ + handler.reactWithoutDebugBreak(); + +#define INTERNAL_CATCH_TRY( capturer ) try +#define INTERNAL_CATCH_CATCH( capturer ) catch(...) { capturer.useActiveException(); } + +#endif + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + INTERNAL_CATCH_TRY( catchAssertionHandler ) { \ + CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + catchAssertionHandler.handle( Catch::Decomposer() <= __VA_ARGS__ ); \ + CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( Catch::isTrue( false && static_cast( !!(__VA_ARGS__) ) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look + // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( !Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handle( Catch::ResultWas::Ok ); \ + } \ + catch( ... ) { \ + catchAssertionHandler.useActiveException(); \ + } \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( Catch::alwaysFalse() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handle( Catch::ResultWas::DidntThrowException ); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handle( Catch::ResultWas::Ok ); \ + } \ + else \ + catchAssertionHandler.handle( Catch::ResultWas::Ok ); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( Catch::alwaysFalse() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(expr); \ + catchAssertionHandler.handle( Catch::ResultWas::DidntThrowException ); \ + } \ + catch( exceptionType const& ) { \ + catchAssertionHandler.handle( Catch::ResultWas::Ok ); \ + } \ + catch( ... ) { \ + catchAssertionHandler.useActiveException(); \ + } \ + else \ + catchAssertionHandler.handle( Catch::ResultWas::Ok ); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( Catch::alwaysFalse() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ + catchAssertionHandler.handle( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( Catch::alwaysFalse() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_INFO( macroName, log ) \ + Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log; + +/////////////////////////////////////////////////////////////////////////////// +// Although this is matcher-based, it can be used with just a string +#define INTERNAL_CATCH_THROWS_STR_MATCHES( macroName, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handle( Catch::ResultWas::DidntThrowException ); \ + } \ + catch( ... ) { \ + handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher ); \ + } \ + else \ + catchAssertionHandler.handle( Catch::ResultWas::Ok ); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( Catch::alwaysFalse() ) + +#endif // CATCH_CONFIG_DISABLE + +// end catch_capture.hpp +// start catch_section.h + +// start catch_section_info.h + +// start catch_totals.h + +#include + +namespace Catch { + + struct Counts { + Counts operator - ( Counts const& other ) const; + Counts& operator += ( Counts const& other ); + + std::size_t total() const; + bool allPassed() const; + bool allOk() const; + + std::size_t passed = 0; + std::size_t failed = 0; + std::size_t failedButOk = 0; + }; + + struct Totals { + + Totals operator - ( Totals const& other ) const; + Totals& operator += ( Totals const& other ); + + Totals delta( Totals const& prevTotals ) const; + + Counts assertions; + Counts testCases; + }; +} + +// end catch_totals.h +#include + +namespace Catch { + + struct SectionInfo { + SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name, + std::string const& _description = std::string() ); + + std::string name; + std::string description; + SourceLineInfo lineInfo; + }; + + struct SectionEndInfo { + SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds ); + + SectionInfo sectionInfo; + Counts prevAssertions; + double durationInSeconds; + }; + +} // end namespace Catch + +// end catch_section_info.h +// start catch_timer.h + +#include + +namespace Catch { + + auto getCurrentNanosecondsSinceEpoch() -> uint64_t; + auto getEstimatedClockResolution() -> uint64_t; + + class Timer { + uint64_t m_nanoseconds = 0; + public: + void start(); + auto getElapsedNanoseconds() const -> unsigned int; + auto getElapsedMicroseconds() const -> unsigned int; + auto getElapsedMilliseconds() const -> unsigned int; + auto getElapsedSeconds() const -> double; + }; + +} // namespace Catch + +// end catch_timer.h +#include + +namespace Catch { + + class Section : NonCopyable { + public: + Section( SectionInfo const& info ); + ~Section(); + + // This indicates whether the section should be executed or not + explicit operator bool() const; + + private: + SectionInfo m_info; + + std::string m_name; + Counts m_assertions; + bool m_sectionIncluded; + Timer m_timer; + }; + +} // end namespace Catch + + #define INTERNAL_CATCH_SECTION( ... ) \ + if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) + +// end catch_section.h +// start catch_benchmark.h + +#include +#include + +namespace Catch { + + class BenchmarkLooper { + + std::string m_name; + std::size_t m_count = 0; + std::size_t m_iterationsToRun = 1; + uint64_t m_resolution; + Timer m_timer; + + static auto getResolution() -> uint64_t; + public: + // Keep most of this inline as it's on the code path that is being timed + BenchmarkLooper( StringRef name ) + : m_name( name ), + m_resolution( getResolution() ) + { + reportStart(); + m_timer.start(); + } + + explicit operator bool() { + if( m_count < m_iterationsToRun ) + return true; + return needsMoreIterations(); + } + + void increment() { + ++m_count; + } + + void reportStart(); + auto needsMoreIterations() -> bool; + }; + +} // end namespace Catch + +#define BENCHMARK( name ) \ + for( Catch::BenchmarkLooper looper( name ); looper; looper.increment() ) + +// end catch_benchmark.h +// start catch_interfaces_exception.h + +// start catch_interfaces_registry_hub.h + +#include +#include + +namespace Catch { + + class TestCase; + struct ITestCaseRegistry; + struct IExceptionTranslatorRegistry; + struct IExceptionTranslator; + struct IReporterRegistry; + struct IReporterFactory; + struct ITagAliasRegistry; + class StartupExceptionRegistry; + + using IReporterFactoryPtr = std::shared_ptr; + + struct IRegistryHub { + virtual ~IRegistryHub(); + + virtual IReporterRegistry const& getReporterRegistry() const = 0; + virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; + virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; + + virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; + + virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; + }; + + struct IMutableRegistryHub { + virtual ~IMutableRegistryHub(); + virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) = 0; + virtual void registerListener( IReporterFactoryPtr const& factory ) = 0; + virtual void registerTest( TestCase const& testInfo ) = 0; + virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; + virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; + virtual void registerStartupException() noexcept = 0; + }; + + IRegistryHub& getRegistryHub(); + IMutableRegistryHub& getMutableRegistryHub(); + void cleanUp(); + std::string translateActiveException(); + +} + +// end catch_interfaces_registry_hub.h +#if defined(CATCH_CONFIG_DISABLE) + #define INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( translatorName, signature) \ + static std::string translatorName( signature ) +#endif + +#include +#include +#include + +namespace Catch { + using exceptionTranslateFunction = std::string(*)(); + + struct IExceptionTranslator; + using ExceptionTranslators = std::vector>; + + struct IExceptionTranslator { + virtual ~IExceptionTranslator(); + virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; + }; + + struct IExceptionTranslatorRegistry { + virtual ~IExceptionTranslatorRegistry(); + + virtual std::string translateActiveException() const = 0; + }; + + class ExceptionTranslatorRegistrar { + template + class ExceptionTranslator : public IExceptionTranslator { + public: + + ExceptionTranslator( std::string(*translateFunction)( T& ) ) + : m_translateFunction( translateFunction ) + {} + + std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { + try { + if( it == itEnd ) + std::rethrow_exception(std::current_exception()); + else + return (*it)->translate( it+1, itEnd ); + } + catch( T& ex ) { + return m_translateFunction( ex ); + } + } + + protected: + std::string(*m_translateFunction)( T& ); + }; + + public: + template + ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) { + getMutableRegistryHub().registerTranslator + ( new ExceptionTranslator( translateFunction ) ); + } + }; +} + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \ + static std::string translatorName( signature ); \ + namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); }\ + static std::string translatorName( signature ) + +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +// end catch_interfaces_exception.h +// start catch_approx.h + +// start catch_enforce.h + +#include +#include + +#define CATCH_PREPARE_EXCEPTION( type, msg ) \ + type( static_cast( std::ostringstream() << msg ).str() ) +#define CATCH_INTERNAL_ERROR( msg ) \ + throw CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg); +#define CATCH_ERROR( msg ) \ + throw CATCH_PREPARE_EXCEPTION( std::domain_error, msg ) +#define CATCH_ENFORCE( condition, msg ) \ + do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false) + +// end catch_enforce.h +#include + +namespace Catch { +namespace Detail { + + class Approx { + private: + bool equalityComparisonImpl(double other) const; + + public: + explicit Approx ( double value ); + + static Approx custom(); + + template ::value>::type> + Approx operator()( T const& value ) { + Approx approx( static_cast(value) ); + approx.epsilon( m_epsilon ); + approx.margin( m_margin ); + approx.scale( m_scale ); + return approx; + } + + template ::value>::type> + explicit Approx( T const& value ): Approx(static_cast(value)) + {} + + template ::value>::type> + friend bool operator == ( const T& lhs, Approx const& rhs ) { + auto lhs_v = static_cast(lhs); + return rhs.equalityComparisonImpl(lhs_v); + } + + template ::value>::type> + friend bool operator == ( Approx const& lhs, const T& rhs ) { + return operator==( rhs, lhs ); + } + + template ::value>::type> + friend bool operator != ( T const& lhs, Approx const& rhs ) { + return !operator==( lhs, rhs ); + } + + template ::value>::type> + friend bool operator != ( Approx const& lhs, T const& rhs ) { + return !operator==( rhs, lhs ); + } + + template ::value>::type> + friend bool operator <= ( T const& lhs, Approx const& rhs ) { + return static_cast(lhs) < rhs.m_value || lhs == rhs; + } + + template ::value>::type> + friend bool operator <= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value < static_cast(rhs) || lhs == rhs; + } + + template ::value>::type> + friend bool operator >= ( T const& lhs, Approx const& rhs ) { + return static_cast(lhs) > rhs.m_value || lhs == rhs; + } + + template ::value>::type> + friend bool operator >= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value > static_cast(rhs) || lhs == rhs; + } + + template ::value>::type> + Approx& epsilon( T const& newEpsilon ) { + double epsilonAsDouble = static_cast(newEpsilon); + CATCH_ENFORCE(epsilonAsDouble >= 0 && epsilonAsDouble <= 1.0, + "Invalid Approx::epsilon: " << epsilonAsDouble + << ", Approx::epsilon has to be between 0 and 1"); + m_epsilon = epsilonAsDouble; + return *this; + } + + template ::value>::type> + Approx& margin( T const& newMargin ) { + double marginAsDouble = static_cast(newMargin); + CATCH_ENFORCE(marginAsDouble >= 0, + "Invalid Approx::margin: " << marginAsDouble + << ", Approx::Margin has to be non-negative."); + m_margin = marginAsDouble; + return *this; + } + + template ::value>::type> + Approx& scale( T const& newScale ) { + m_scale = static_cast(newScale); + return *this; + } + + std::string toString() const; + + private: + double m_epsilon; + double m_margin; + double m_scale; + double m_value; + }; +} + +template<> +struct StringMaker { + static std::string convert(Catch::Detail::Approx const& value); +}; + +} // end namespace Catch + +// end catch_approx.h +// start catch_string_manip.h + +#include +#include + +namespace Catch { + + bool startsWith( std::string const& s, std::string const& prefix ); + bool startsWith( std::string const& s, char prefix ); + bool endsWith( std::string const& s, std::string const& suffix ); + bool endsWith( std::string const& s, char suffix ); + bool contains( std::string const& s, std::string const& infix ); + void toLowerInPlace( std::string& s ); + std::string toLower( std::string const& s ); + std::string trim( std::string const& str ); + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); + + struct pluralise { + pluralise( std::size_t count, std::string const& label ); + + friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); + + std::size_t m_count; + std::string m_label; + }; +} + +// end catch_string_manip.h +#ifndef CATCH_CONFIG_DISABLE_MATCHERS +// start catch_capture_matchers.h + +// start catch_matchers.h + +#include +#include + +namespace Catch { +namespace Matchers { + namespace Impl { + + template struct MatchAllOf; + template struct MatchAnyOf; + template struct MatchNotOf; + + class MatcherUntypedBase { + public: + MatcherUntypedBase() = default; + MatcherUntypedBase ( MatcherUntypedBase const& ) = default; + MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = delete; + std::string toString() const; + + protected: + virtual ~MatcherUntypedBase(); + virtual std::string describe() const = 0; + mutable std::string m_cachedToString; + }; + + template + struct MatcherMethod { + virtual bool match( ObjectT const& arg ) const = 0; + }; + template + struct MatcherMethod { + virtual bool match( PtrT* arg ) const = 0; + }; + + template + struct MatcherBase : MatcherUntypedBase, MatcherMethod { + + MatchAllOf operator && ( MatcherBase const& other ) const; + MatchAnyOf operator || ( MatcherBase const& other ) const; + MatchNotOf operator ! () const; + }; + + template + struct MatchAllOf : MatcherBase { + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (!matcher->match(arg)) + return false; + } + return true; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " and "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAllOf& operator && ( MatcherBase const& other ) { + m_matchers.push_back( &other ); + return *this; + } + + std::vector const*> m_matchers; + }; + template + struct MatchAnyOf : MatcherBase { + + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (matcher->match(arg)) + return true; + } + return false; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " or "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAnyOf& operator || ( MatcherBase const& other ) { + m_matchers.push_back( &other ); + return *this; + } + + std::vector const*> m_matchers; + }; + + template + struct MatchNotOf : MatcherBase { + + MatchNotOf( MatcherBase const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {} + + bool match( ArgT const& arg ) const override { + return !m_underlyingMatcher.match( arg ); + } + + std::string describe() const override { + return "not " + m_underlyingMatcher.toString(); + } + MatcherBase const& m_underlyingMatcher; + }; + + template + MatchAllOf MatcherBase::operator && ( MatcherBase const& other ) const { + return MatchAllOf() && *this && other; + } + template + MatchAnyOf MatcherBase::operator || ( MatcherBase const& other ) const { + return MatchAnyOf() || *this || other; + } + template + MatchNotOf MatcherBase::operator ! () const { + return MatchNotOf( *this ); + } + + } // namespace Impl + +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch + +// end catch_matchers.h +// start catch_matchers_string.h + +#include + +namespace Catch { +namespace Matchers { + + namespace StdString { + + struct CasedString + { + CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ); + std::string adjustString( std::string const& str ) const; + std::string caseSensitivitySuffix() const; + + CaseSensitive::Choice m_caseSensitivity; + std::string m_str; + }; + + struct StringMatcherBase : MatcherBase { + StringMatcherBase( std::string const& operation, CasedString const& comparator ); + std::string describe() const override; + + CasedString m_comparator; + std::string m_operation; + }; + + struct EqualsMatcher : StringMatcherBase { + EqualsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct ContainsMatcher : StringMatcherBase { + ContainsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct StartsWithMatcher : StringMatcherBase { + StartsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct EndsWithMatcher : StringMatcherBase { + EndsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + + } // namespace StdString + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_string.h +// start catch_matchers_vector.h + +namespace Catch { +namespace Matchers { + + namespace Vector { + + template + struct ContainsElementMatcher : MatcherBase, T> { + + ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} + + bool match(std::vector const &v) const override { + for (auto const& el : v) { + if (el == m_comparator) { + return true; + } + } + return false; + } + + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + T const& m_comparator; + }; + + template + struct ContainsMatcher : MatcherBase, std::vector > { + + ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector const &v) const override { + // !TBD: see note in EqualsMatcher + if (m_comparator.size() > v.size()) + return false; + for (auto const& comparator : m_comparator) { + auto present = false; + for (const auto& el : v) { + if (el == comparator) { + present = true; + break; + } + } + if (!present) { + return false; + } + } + return true; + } + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + std::vector const& m_comparator; + }; + + template + struct EqualsMatcher : MatcherBase, std::vector > { + + EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector const &v) const override { + // !TBD: This currently works if all elements can be compared using != + // - a more general approach would be via a compare template that defaults + // to using !=. but could be specialised for, e.g. std::vector etc + // - then just call that directly + if (m_comparator.size() != v.size()) + return false; + for (std::size_t i = 0; i < v.size(); ++i) + if (m_comparator[i] != v[i]) + return false; + return true; + } + std::string describe() const override { + return "Equals: " + ::Catch::Detail::stringify( m_comparator ); + } + std::vector const& m_comparator; + }; + + } // namespace Vector + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + template + Vector::ContainsMatcher Contains( std::vector const& comparator ) { + return Vector::ContainsMatcher( comparator ); + } + + template + Vector::ContainsElementMatcher VectorContains( T const& comparator ) { + return Vector::ContainsElementMatcher( comparator ); + } + + template + Vector::EqualsMatcher Equals( std::vector const& comparator ) { + return Vector::EqualsMatcher( comparator ); + } + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_vector.h +namespace Catch { + + template + class MatchExpr : public ITransientExpression { + ArgT const& m_arg; + MatcherT m_matcher; + StringRef m_matcherString; + bool m_result; + public: + MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef matcherString ) + : m_arg( arg ), + m_matcher( matcher ), + m_matcherString( matcherString ), + m_result( matcher.match( arg ) ) + {} + + auto isBinaryExpression() const -> bool override { return true; } + auto getResult() const -> bool override { return m_result; } + + void streamReconstructedExpression( std::ostream &os ) const override { + auto matcherAsString = m_matcher.toString(); + os << Catch::Detail::stringify( m_arg ) << ' '; + if( matcherAsString == Detail::unprintableString ) + os << m_matcherString; + else + os << matcherAsString; + } + }; + + using StringMatcher = Matchers::Impl::MatcherBase; + + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ); + + template + auto makeMatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr { + return MatchExpr( arg, matcher, matcherString ); + } + +} // namespace Catch + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + INTERNAL_CATCH_TRY( catchAssertionHandler ) { \ + catchAssertionHandler.handle( Catch::makeMatchExpr( arg, matcher, #matcher ) ); \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( Catch::alwaysFalse() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__ ); \ + catchAssertionHandler.handle( Catch::ResultWas::DidntThrowException ); \ + } \ + catch( exceptionType const& ex ) { \ + catchAssertionHandler.handle( Catch::makeMatchExpr( ex, matcher, #matcher ) ); \ + } \ + catch( ... ) { \ + catchAssertionHandler.useActiveException(); \ + } \ + else \ + catchAssertionHandler.handle( Catch::ResultWas::Ok ); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( Catch::alwaysFalse() ) + +// end catch_capture_matchers.h +#endif + +// These files are included here so the single_include script doesn't put them +// in the conditionally compiled sections +// start catch_test_case_info.h + +#include +#include +#include + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + + struct ITestInvoker; + + struct TestCaseInfo { + enum SpecialProperties{ + None = 0, + IsHidden = 1 << 1, + ShouldFail = 1 << 2, + MayFail = 1 << 3, + Throws = 1 << 4, + NonPortable = 1 << 5, + Benchmark = 1 << 6 + }; + + TestCaseInfo( std::string const& _name, + std::string const& _className, + std::string const& _description, + std::vector const& _tags, + SourceLineInfo const& _lineInfo ); + + friend void setTags( TestCaseInfo& testCaseInfo, std::vector tags ); + + bool isHidden() const; + bool throws() const; + bool okToFail() const; + bool expectedToFail() const; + + std::string tagsAsString() const; + + std::string name; + std::string className; + std::string description; + std::vector tags; + std::vector lcaseTags; + SourceLineInfo lineInfo; + SpecialProperties properties; + }; + + class TestCase : public TestCaseInfo { + public: + + TestCase( ITestInvoker* testCase, TestCaseInfo const& info ); + + TestCase withName( std::string const& _newName ) const; + + void invoke() const; + + TestCaseInfo const& getTestCaseInfo() const; + + bool operator == ( TestCase const& other ) const; + bool operator < ( TestCase const& other ) const; + + private: + std::shared_ptr test; + }; + + TestCase makeTestCase( ITestInvoker* testCase, + std::string const& className, + std::string const& name, + std::string const& description, + SourceLineInfo const& lineInfo ); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_test_case_info.h +// start catch_interfaces_runner.h + +namespace Catch { + + struct IRunner { + virtual ~IRunner(); + virtual bool aborting() const = 0; + }; +} + +// end catch_interfaces_runner.h + +#ifdef __OBJC__ +// start catch_objc.hpp + +#import + +#include + +// NB. Any general catch headers included here must be included +// in catch.hpp first to make sure they are included by the single +// header for non obj-usage + +/////////////////////////////////////////////////////////////////////////////// +// This protocol is really only here for (self) documenting purposes, since +// all its methods are optional. +@protocol OcFixture + +@optional + +-(void) setUp; +-(void) tearDown; + +@end + +namespace Catch { + + class OcMethod : public ITestInvoker { + + public: + OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {} + + virtual void invoke() const { + id obj = [[m_cls alloc] init]; + + performOptionalSelector( obj, @selector(setUp) ); + performOptionalSelector( obj, m_sel ); + performOptionalSelector( obj, @selector(tearDown) ); + + arcSafeRelease( obj ); + } + private: + virtual ~OcMethod() {} + + Class m_cls; + SEL m_sel; + }; + + namespace Detail{ + + inline std::string getAnnotation( Class cls, + std::string const& annotationName, + std::string const& testCaseName ) { + NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; + SEL sel = NSSelectorFromString( selStr ); + arcSafeRelease( selStr ); + id value = performOptionalSelector( cls, sel ); + if( value ) + return [(NSString*)value UTF8String]; + return ""; + } + } + + inline std::size_t registerTestMethods() { + std::size_t noTestMethods = 0; + int noClasses = objc_getClassList( nullptr, 0 ); + + Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); + objc_getClassList( classes, noClasses ); + + for( int c = 0; c < noClasses; c++ ) { + Class cls = classes[c]; + { + u_int count; + Method* methods = class_copyMethodList( cls, &count ); + for( u_int m = 0; m < count ; m++ ) { + SEL selector = method_getName(methods[m]); + std::string methodName = sel_getName(selector); + if( startsWith( methodName, "Catch_TestCase_" ) ) { + std::string testCaseName = methodName.substr( 15 ); + std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); + std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); + const char* className = class_getName( cls ); + + getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo("",0) ) ); + noTestMethods++; + } + } + free(methods); + } + } + return noTestMethods; + } + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) + + namespace Matchers { + namespace Impl { + namespace NSStringMatchers { + + struct StringHolder : MatcherBase{ + StringHolder( NSString* substr ) : m_substr( [substr copy] ){} + StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} + StringHolder() { + arcSafeRelease( m_substr ); + } + + bool match( NSString* arg ) const override { + return false; + } + + NSString* CATCH_ARC_STRONG m_substr; + }; + + struct Equals : StringHolder { + Equals( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str isEqualToString:m_substr]; + } + + std::string describe() const override { + return "equals string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct Contains : StringHolder { + Contains( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location != NSNotFound; + } + + std::string describe() const override { + return "contains string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct StartsWith : StringHolder { + StartsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == 0; + } + + std::string describe() const override { + return "starts with: " + Catch::Detail::stringify( m_substr ); + } + }; + struct EndsWith : StringHolder { + EndsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == [str length] - [m_substr length]; + } + + std::string describe() const override { + return "ends with: " + Catch::Detail::stringify( m_substr ); + } + }; + + } // namespace NSStringMatchers + } // namespace Impl + + inline Impl::NSStringMatchers::Equals + Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); } + + inline Impl::NSStringMatchers::Contains + Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); } + + inline Impl::NSStringMatchers::StartsWith + StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); } + + inline Impl::NSStringMatchers::EndsWith + EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); } + + } // namespace Matchers + + using namespace Matchers; + +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +} // namespace Catch + +/////////////////////////////////////////////////////////////////////////////// +#define OC_MAKE_UNIQUE_NAME( root, uniqueSuffix ) root##uniqueSuffix +#define OC_TEST_CASE2( name, desc, uniqueSuffix ) \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Name_test_, uniqueSuffix ) \ +{ \ +return @ name; \ +} \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Description_test_, uniqueSuffix ) \ +{ \ +return @ desc; \ +} \ +-(void) OC_MAKE_UNIQUE_NAME( Catch_TestCase_test_, uniqueSuffix ) + +#define OC_TEST_CASE( name, desc ) OC_TEST_CASE2( name, desc, __LINE__ ) + +// end catch_objc.hpp +#endif + +#ifdef CATCH_CONFIG_EXTERNAL_INTERFACES +// start catch_external_interfaces.h + +// start catch_reporter_bases.hpp + +// start catch_interfaces_reporter.h + +// start catch_config.hpp + +// start catch_test_spec_parser.h + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +// start catch_test_spec.h + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +// start catch_wildcard_pattern.h + +namespace Catch +{ + class WildcardPattern { + enum WildcardPosition { + NoWildcard = 0, + WildcardAtStart = 1, + WildcardAtEnd = 2, + WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd + }; + + public: + + WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity ); + virtual ~WildcardPattern() = default; + virtual bool matches( std::string const& str ) const; + + private: + std::string adjustCase( std::string const& str ) const; + CaseSensitive::Choice m_caseSensitivity; + WildcardPosition m_wildcard = NoWildcard; + std::string m_pattern; + }; +} + +// end catch_wildcard_pattern.h +#include +#include +#include + +namespace Catch { + + class TestSpec { + struct Pattern { + virtual ~Pattern(); + virtual bool matches( TestCaseInfo const& testCase ) const = 0; + }; + using PatternPtr = std::shared_ptr; + + class NamePattern : public Pattern { + public: + NamePattern( std::string const& name ); + virtual ~NamePattern(); + virtual bool matches( TestCaseInfo const& testCase ) const override; + private: + WildcardPattern m_wildcardPattern; + }; + + class TagPattern : public Pattern { + public: + TagPattern( std::string const& tag ); + virtual ~TagPattern(); + virtual bool matches( TestCaseInfo const& testCase ) const override; + private: + std::string m_tag; + }; + + class ExcludedPattern : public Pattern { + public: + ExcludedPattern( PatternPtr const& underlyingPattern ); + virtual ~ExcludedPattern(); + virtual bool matches( TestCaseInfo const& testCase ) const override; + private: + PatternPtr m_underlyingPattern; + }; + + struct Filter { + std::vector m_patterns; + + bool matches( TestCaseInfo const& testCase ) const; + }; + + public: + bool hasFilters() const; + bool matches( TestCaseInfo const& testCase ) const; + + private: + std::vector m_filters; + + friend class TestSpecParser; + }; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_test_spec.h +// start catch_interfaces_tag_alias_registry.h + +#include + +namespace Catch { + + struct TagAlias; + + struct ITagAliasRegistry { + virtual ~ITagAliasRegistry(); + // Nullptr if not present + virtual TagAlias const* find( std::string const& alias ) const = 0; + virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; + + static ITagAliasRegistry const& get(); + }; + +} // end namespace Catch + +// end catch_interfaces_tag_alias_registry.h +namespace Catch { + + class TestSpecParser { + enum Mode{ None, Name, QuotedName, Tag, EscapedName }; + Mode m_mode = None; + bool m_exclusion = false; + std::size_t m_start = std::string::npos, m_pos = 0; + std::string m_arg; + std::vector m_escapeChars; + TestSpec::Filter m_currentFilter; + TestSpec m_testSpec; + ITagAliasRegistry const* m_tagAliases = nullptr; + + public: + TestSpecParser( ITagAliasRegistry const& tagAliases ); + + TestSpecParser& parse( std::string const& arg ); + TestSpec testSpec(); + + private: + void visitChar( char c ); + void startNewMode( Mode mode, std::size_t start ); + void escape(); + std::string subString() const; + + template + void addPattern() { + std::string token = subString(); + for( std::size_t i = 0; i < m_escapeChars.size(); ++i ) + token = token.substr( 0, m_escapeChars[i]-m_start-i ) + token.substr( m_escapeChars[i]-m_start-i+1 ); + m_escapeChars.clear(); + if( startsWith( token, "exclude:" ) ) { + m_exclusion = true; + token = token.substr( 8 ); + } + if( !token.empty() ) { + TestSpec::PatternPtr pattern = std::make_shared( token ); + if( m_exclusion ) + pattern = std::make_shared( pattern ); + m_currentFilter.m_patterns.push_back( pattern ); + } + m_exclusion = false; + m_mode = None; + } + + void addFilter(); + }; + TestSpec parseTestSpec( std::string const& arg ); + +} // namespace Catch + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_test_spec_parser.h +// start catch_interfaces_config.h + +#include +#include +#include +#include + +namespace Catch { + + enum class Verbosity { + Quiet = 0, + Normal, + High + }; + + struct WarnAbout { enum What { + Nothing = 0x00, + NoAssertions = 0x01 + }; }; + + struct ShowDurations { enum OrNot { + DefaultForReporter, + Always, + Never + }; }; + struct RunTests { enum InWhatOrder { + InDeclarationOrder, + InLexicographicalOrder, + InRandomOrder + }; }; + struct UseColour { enum YesOrNo { + Auto, + Yes, + No + }; }; + struct WaitForKeypress { enum When { + Never, + BeforeStart = 1, + BeforeExit = 2, + BeforeStartAndExit = BeforeStart | BeforeExit + }; }; + + class TestSpec; + + struct IConfig : NonCopyable { + + virtual ~IConfig(); + + virtual bool allowThrows() const = 0; + virtual std::ostream& stream() const = 0; + virtual std::string name() const = 0; + virtual bool includeSuccessfulResults() const = 0; + virtual bool shouldDebugBreak() const = 0; + virtual bool warnAboutMissingAssertions() const = 0; + virtual int abortAfter() const = 0; + virtual bool showInvisibles() const = 0; + virtual ShowDurations::OrNot showDurations() const = 0; + virtual TestSpec const& testSpec() const = 0; + virtual RunTests::InWhatOrder runOrder() const = 0; + virtual unsigned int rngSeed() const = 0; + virtual int benchmarkResolutionMultiple() const = 0; + virtual UseColour::YesOrNo useColour() const = 0; + virtual std::vector const& getSectionsToRun() const = 0; + virtual Verbosity verbosity() const = 0; + }; + + using IConfigPtr = std::shared_ptr; +} + +// end catch_interfaces_config.h +// Libstdc++ doesn't like incomplete classes for unique_ptr +// start catch_stream.h + +// start catch_streambuf.h + +#include + +namespace Catch { + + class StreamBufBase : public std::streambuf { + public: + virtual ~StreamBufBase(); + }; +} + +// end catch_streambuf.h +#include +#include +#include +#include + +namespace Catch { + + std::ostream& cout(); + std::ostream& cerr(); + std::ostream& clog(); + + struct IStream { + virtual ~IStream(); + virtual std::ostream& stream() const = 0; + }; + + class FileStream : public IStream { + mutable std::ofstream m_ofs; + public: + FileStream( std::string const& filename ); + ~FileStream() override = default; + public: // IStream + std::ostream& stream() const override; + }; + + class CoutStream : public IStream { + mutable std::ostream m_os; + public: + CoutStream(); + ~CoutStream() override = default; + + public: // IStream + std::ostream& stream() const override; + }; + + class DebugOutStream : public IStream { + std::unique_ptr m_streamBuf; + mutable std::ostream m_os; + public: + DebugOutStream(); + ~DebugOutStream() override = default; + + public: // IStream + std::ostream& stream() const override; + }; +} + +// end catch_stream.h + +#include +#include +#include + +#ifndef CATCH_CONFIG_CONSOLE_WIDTH +#define CATCH_CONFIG_CONSOLE_WIDTH 80 +#endif + +namespace Catch { + + struct IStream; + + struct ConfigData { + bool listTests = false; + bool listTags = false; + bool listReporters = false; + bool listTestNamesOnly = false; + + bool showSuccessfulTests = false; + bool shouldDebugBreak = false; + bool noThrow = false; + bool showHelp = false; + bool showInvisibles = false; + bool filenamesAsTags = false; + bool libIdentify = false; + + int abortAfter = -1; + unsigned int rngSeed = 0; + int benchmarkResolutionMultiple = 100; + + Verbosity verbosity = Verbosity::Normal; + WarnAbout::What warnings = WarnAbout::Nothing; + ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter; + RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder; + UseColour::YesOrNo useColour = UseColour::Auto; + WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; + + std::string outputFilename; + std::string name; + std::string processName; + + std::vector reporterNames; + std::vector testsOrTags; + std::vector sectionsToRun; + }; + + class Config : public IConfig { + public: + + Config() = default; + Config( ConfigData const& data ); + virtual ~Config() = default; + + std::string const& getFilename() const; + + bool listTests() const; + bool listTestNamesOnly() const; + bool listTags() const; + bool listReporters() const; + + std::string getProcessName() const; + + std::vector const& getReporterNames() const; + std::vector const& getSectionsToRun() const override; + + virtual TestSpec const& testSpec() const override; + + bool showHelp() const; + + // IConfig interface + bool allowThrows() const override; + std::ostream& stream() const override; + std::string name() const override; + bool includeSuccessfulResults() const override; + bool warnAboutMissingAssertions() const override; + ShowDurations::OrNot showDurations() const override; + RunTests::InWhatOrder runOrder() const override; + unsigned int rngSeed() const override; + int benchmarkResolutionMultiple() const override; + UseColour::YesOrNo useColour() const override; + bool shouldDebugBreak() const override; + int abortAfter() const override; + bool showInvisibles() const override; + Verbosity verbosity() const override; + + private: + + IStream const* openStream(); + ConfigData m_data; + + std::unique_ptr m_stream; + TestSpec m_testSpec; + }; + +} // end namespace Catch + +// end catch_config.hpp +// start catch_assertionresult.h + +#include + +namespace Catch { + + struct AssertionResultData + { + AssertionResultData() = delete; + + AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); + + std::string message; + mutable std::string reconstructedExpression; + LazyExpression lazyExpression; + ResultWas::OfType resultType; + + std::string reconstructExpression() const; + }; + + class AssertionResult { + public: + AssertionResult() = delete; + AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); + + bool isOk() const; + bool succeeded() const; + ResultWas::OfType getResultType() const; + bool hasExpression() const; + bool hasMessage() const; + std::string getExpression() const; + std::string getExpressionInMacro() const; + bool hasExpandedExpression() const; + std::string getExpandedExpression() const; + std::string getMessage() const; + SourceLineInfo getSourceInfo() const; + std::string getTestMacroName() const; + + //protected: + AssertionInfo m_info; + AssertionResultData m_resultData; + }; + +} // end namespace Catch + +// end catch_assertionresult.h +// start catch_option.hpp + +namespace Catch { + + // An optional type + template + class Option { + public: + Option() : nullableValue( nullptr ) {} + Option( T const& _value ) + : nullableValue( new( storage ) T( _value ) ) + {} + Option( Option const& _other ) + : nullableValue( _other ? new( storage ) T( *_other ) : nullptr ) + {} + + ~Option() { + reset(); + } + + Option& operator= ( Option const& _other ) { + if( &_other != this ) { + reset(); + if( _other ) + nullableValue = new( storage ) T( *_other ); + } + return *this; + } + Option& operator = ( T const& _value ) { + reset(); + nullableValue = new( storage ) T( _value ); + return *this; + } + + void reset() { + if( nullableValue ) + nullableValue->~T(); + nullableValue = nullptr; + } + + T& operator*() { return *nullableValue; } + T const& operator*() const { return *nullableValue; } + T* operator->() { return nullableValue; } + const T* operator->() const { return nullableValue; } + + T valueOr( T const& defaultValue ) const { + return nullableValue ? *nullableValue : defaultValue; + } + + bool some() const { return nullableValue != nullptr; } + bool none() const { return nullableValue == nullptr; } + + bool operator !() const { return nullableValue == nullptr; } + explicit operator bool() const { + return some(); + } + + private: + T *nullableValue; + alignas(alignof(T)) char storage[sizeof(T)]; + }; + +} // end namespace Catch + +// end catch_option.hpp +#include +#include +#include +#include +#include + +namespace Catch { + + struct ReporterConfig { + explicit ReporterConfig( IConfigPtr const& _fullConfig ); + + ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ); + + std::ostream& stream() const; + IConfigPtr fullConfig() const; + + private: + std::ostream* m_stream; + IConfigPtr m_fullConfig; + }; + + struct ReporterPreferences { + bool shouldRedirectStdOut = false; + }; + + template + struct LazyStat : Option { + LazyStat& operator=( T const& _value ) { + Option::operator=( _value ); + used = false; + return *this; + } + void reset() { + Option::reset(); + used = false; + } + bool used = false; + }; + + struct TestRunInfo { + TestRunInfo( std::string const& _name ); + std::string name; + }; + struct GroupInfo { + GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ); + + std::string name; + std::size_t groupIndex; + std::size_t groupsCounts; + }; + + struct AssertionStats { + AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ); + + AssertionStats( AssertionStats const& ) = default; + AssertionStats( AssertionStats && ) = default; + AssertionStats& operator = ( AssertionStats const& ) = default; + AssertionStats& operator = ( AssertionStats && ) = default; + virtual ~AssertionStats(); + + AssertionResult assertionResult; + std::vector infoMessages; + Totals totals; + }; + + struct SectionStats { + SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ); + SectionStats( SectionStats const& ) = default; + SectionStats( SectionStats && ) = default; + SectionStats& operator = ( SectionStats const& ) = default; + SectionStats& operator = ( SectionStats && ) = default; + virtual ~SectionStats(); + + SectionInfo sectionInfo; + Counts assertions; + double durationInSeconds; + bool missingAssertions; + }; + + struct TestCaseStats { + TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ); + + TestCaseStats( TestCaseStats const& ) = default; + TestCaseStats( TestCaseStats && ) = default; + TestCaseStats& operator = ( TestCaseStats const& ) = default; + TestCaseStats& operator = ( TestCaseStats && ) = default; + virtual ~TestCaseStats(); + + TestCaseInfo testInfo; + Totals totals; + std::string stdOut; + std::string stdErr; + bool aborting; + }; + + struct TestGroupStats { + TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ); + TestGroupStats( GroupInfo const& _groupInfo ); + + TestGroupStats( TestGroupStats const& ) = default; + TestGroupStats( TestGroupStats && ) = default; + TestGroupStats& operator = ( TestGroupStats const& ) = default; + TestGroupStats& operator = ( TestGroupStats && ) = default; + virtual ~TestGroupStats(); + + GroupInfo groupInfo; + Totals totals; + bool aborting; + }; + + struct TestRunStats { + TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ); + + TestRunStats( TestRunStats const& ) = default; + TestRunStats( TestRunStats && ) = default; + TestRunStats& operator = ( TestRunStats const& ) = default; + TestRunStats& operator = ( TestRunStats && ) = default; + virtual ~TestRunStats(); + + TestRunInfo runInfo; + Totals totals; + bool aborting; + }; + + struct BenchmarkInfo { + std::string name; + }; + struct BenchmarkStats { + BenchmarkInfo info; + std::size_t iterations; + uint64_t elapsedTimeInNanoseconds; + }; + + struct IStreamingReporter { + virtual ~IStreamingReporter() = default; + + // Implementing class must also provide the following static methods: + // static std::string getDescription(); + // static std::set getSupportedVerbosities() + + virtual ReporterPreferences getPreferences() const = 0; + + virtual void noMatchingTestCases( std::string const& spec ) = 0; + + virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; + virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; + + virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; + virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; + + // *** experimental *** + virtual void benchmarkStarting( BenchmarkInfo const& ) {} + + virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; + + // The return value indicates if the messages buffer should be cleared: + virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; + + // *** experimental *** + virtual void benchmarkEnded( BenchmarkStats const& ) {} + + virtual void sectionEnded( SectionStats const& sectionStats ) = 0; + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; + virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; + virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; + + virtual void skipTest( TestCaseInfo const& testInfo ) = 0; + + // Default empty implementation provided + virtual void fatalErrorEncountered( StringRef name ); + + virtual bool isMulti() const; + }; + using IStreamingReporterPtr = std::unique_ptr; + + struct IReporterFactory { + virtual ~IReporterFactory(); + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const = 0; + virtual std::string getDescription() const = 0; + }; + using IReporterFactoryPtr = std::shared_ptr; + + struct IReporterRegistry { + using FactoryMap = std::map; + using Listeners = std::vector; + + virtual ~IReporterRegistry(); + virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0; + virtual FactoryMap const& getFactories() const = 0; + virtual Listeners const& getListeners() const = 0; + }; + + void addReporter( IStreamingReporterPtr& existingReporter, IStreamingReporterPtr&& additionalReporter ); + +} // end namespace Catch + +// end catch_interfaces_reporter.h +#include +#include +#include +#include +#include +#include + +namespace Catch { + void prepareExpandedExpression(AssertionResult& result); + + // Returns double formatted as %.3f (format expected on output) + std::string getFormattedDuration( double duration ); + + template + struct StreamingReporterBase : IStreamingReporter { + + StreamingReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = false; + CATCH_ENFORCE( DerivedT::getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" ); + } + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + static std::set getSupportedVerbosities() { + return { Verbosity::Normal }; + } + + ~StreamingReporterBase() override = default; + + void noMatchingTestCases(std::string const&) override {} + + void testRunStarting(TestRunInfo const& _testRunInfo) override { + currentTestRunInfo = _testRunInfo; + } + void testGroupStarting(GroupInfo const& _groupInfo) override { + currentGroupInfo = _groupInfo; + } + + void testCaseStarting(TestCaseInfo const& _testInfo) override { + currentTestCaseInfo = _testInfo; + } + void sectionStarting(SectionInfo const& _sectionInfo) override { + m_sectionStack.push_back(_sectionInfo); + } + + void sectionEnded(SectionStats const& /* _sectionStats */) override { + m_sectionStack.pop_back(); + } + void testCaseEnded(TestCaseStats const& /* _testCaseStats */) override { + currentTestCaseInfo.reset(); + } + void testGroupEnded(TestGroupStats const& /* _testGroupStats */) override { + currentGroupInfo.reset(); + } + void testRunEnded(TestRunStats const& /* _testRunStats */) override { + currentTestCaseInfo.reset(); + currentGroupInfo.reset(); + currentTestRunInfo.reset(); + } + + void skipTest(TestCaseInfo const&) override { + // Don't do anything with this by default. + // It can optionally be overridden in the derived class. + } + + IConfigPtr m_config; + std::ostream& stream; + + LazyStat currentTestRunInfo; + LazyStat currentGroupInfo; + LazyStat currentTestCaseInfo; + + std::vector m_sectionStack; + ReporterPreferences m_reporterPrefs; + }; + + template + struct CumulativeReporterBase : IStreamingReporter { + template + struct Node { + explicit Node( T const& _value ) : value( _value ) {} + virtual ~Node() {} + + using ChildNodes = std::vector>; + T value; + ChildNodes children; + }; + struct SectionNode { + explicit SectionNode(SectionStats const& _stats) : stats(_stats) {} + virtual ~SectionNode() = default; + + bool operator == (SectionNode const& other) const { + return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; + } + bool operator == (std::shared_ptr const& other) const { + return operator==(*other); + } + + SectionStats stats; + using ChildSections = std::vector>; + using Assertions = std::vector; + ChildSections childSections; + Assertions assertions; + std::string stdOut; + std::string stdErr; + }; + + struct BySectionInfo { + BySectionInfo( SectionInfo const& other ) : m_other( other ) {} + BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} + bool operator() (std::shared_ptr const& node) const { + return ((node->stats.sectionInfo.name == m_other.name) && + (node->stats.sectionInfo.lineInfo == m_other.lineInfo)); + } + void operator=(BySectionInfo const&) = delete; + + private: + SectionInfo const& m_other; + }; + + using TestCaseNode = Node; + using TestGroupNode = Node; + using TestRunNode = Node; + + CumulativeReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = false; + CATCH_ENFORCE( DerivedT::getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" ); + } + ~CumulativeReporterBase() override = default; + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + static std::set getSupportedVerbosities() { + return { Verbosity::Normal }; + } + + void testRunStarting( TestRunInfo const& ) override {} + void testGroupStarting( GroupInfo const& ) override {} + + void testCaseStarting( TestCaseInfo const& ) override {} + + void sectionStarting( SectionInfo const& sectionInfo ) override { + SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); + std::shared_ptr node; + if( m_sectionStack.empty() ) { + if( !m_rootSection ) + m_rootSection = std::make_shared( incompleteStats ); + node = m_rootSection; + } + else { + SectionNode& parentNode = *m_sectionStack.back(); + auto it = + std::find_if( parentNode.childSections.begin(), + parentNode.childSections.end(), + BySectionInfo( sectionInfo ) ); + if( it == parentNode.childSections.end() ) { + node = std::make_shared( incompleteStats ); + parentNode.childSections.push_back( node ); + } + else + node = *it; + } + m_sectionStack.push_back( node ); + m_deepestSection = std::move(node); + } + + void assertionStarting(AssertionInfo const&) override {} + + bool assertionEnded(AssertionStats const& assertionStats) override { + assert(!m_sectionStack.empty()); + // AssertionResult holds a pointer to a temporary DecomposedExpression, + // which getExpandedExpression() calls to build the expression string. + // Our section stack copy of the assertionResult will likely outlive the + // temporary, so it must be expanded or discarded now to avoid calling + // a destroyed object later. + prepareExpandedExpression(const_cast( assertionStats.assertionResult ) ); + SectionNode& sectionNode = *m_sectionStack.back(); + sectionNode.assertions.push_back(assertionStats); + return true; + } + void sectionEnded(SectionStats const& sectionStats) override { + assert(!m_sectionStack.empty()); + SectionNode& node = *m_sectionStack.back(); + node.stats = sectionStats; + m_sectionStack.pop_back(); + } + void testCaseEnded(TestCaseStats const& testCaseStats) override { + auto node = std::make_shared(testCaseStats); + assert(m_sectionStack.size() == 0); + node->children.push_back(m_rootSection); + m_testCases.push_back(node); + m_rootSection.reset(); + + assert(m_deepestSection); + m_deepestSection->stdOut = testCaseStats.stdOut; + m_deepestSection->stdErr = testCaseStats.stdErr; + } + void testGroupEnded(TestGroupStats const& testGroupStats) override { + auto node = std::make_shared(testGroupStats); + node->children.swap(m_testCases); + m_testGroups.push_back(node); + } + void testRunEnded(TestRunStats const& testRunStats) override { + auto node = std::make_shared(testRunStats); + node->children.swap(m_testGroups); + m_testRuns.push_back(node); + testRunEndedCumulative(); + } + virtual void testRunEndedCumulative() = 0; + + void skipTest(TestCaseInfo const&) override {} + + IConfigPtr m_config; + std::ostream& stream; + std::vector m_assertions; + std::vector>> m_sections; + std::vector> m_testCases; + std::vector> m_testGroups; + + std::vector> m_testRuns; + + std::shared_ptr m_rootSection; + std::shared_ptr m_deepestSection; + std::vector> m_sectionStack; + ReporterPreferences m_reporterPrefs; + }; + + template + char const* getLineOfChars() { + static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; + if( !*line ) { + std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 ); + line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0; + } + return line; + } + + struct TestEventListenerBase : StreamingReporterBase { + TestEventListenerBase( ReporterConfig const& _config ); + + void assertionStarting(AssertionInfo const&) override; + bool assertionEnded(AssertionStats const&) override; + }; + +} // end namespace Catch + +// end catch_reporter_bases.hpp +// start catch_console_colour.h + +namespace Catch { + + struct Colour { + enum Code { + None = 0, + + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, + + Bright = 0x10, + + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White, + + // By intention + FileName = LightGrey, + Warning = Yellow, + ResultError = BrightRed, + ResultSuccess = BrightGreen, + ResultExpectedFailure = Warning, + + Error = BrightRed, + Success = Green, + + OriginalExpression = Cyan, + ReconstructedExpression = Yellow, + + SecondaryText = LightGrey, + Headers = White + }; + + // Use constructed object for RAII guard + Colour( Code _colourCode ); + Colour( Colour&& other ) noexcept; + Colour& operator=( Colour&& other ) noexcept; + ~Colour(); + + // Use static method for one-shot changes + static void use( Code _colourCode ); + + private: + bool m_moved = false; + }; + + std::ostream& operator << ( std::ostream& os, Colour const& ); + +} // end namespace Catch + +// end catch_console_colour.h +// start catch_reporter_registrars.hpp + + +namespace Catch { + + template + class ReporterRegistrar { + + class ReporterFactory : public IReporterFactory { + + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override { + return std::unique_ptr( new T( config ) ); + } + + virtual std::string getDescription() const override { + return T::getDescription(); + } + }; + + public: + + ReporterRegistrar( std::string const& name ) { + getMutableRegistryHub().registerReporter( name, std::make_shared() ); + } + }; + + template + class ListenerRegistrar { + + class ListenerFactory : public IReporterFactory { + + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override { + return std::unique_ptr( new T( config ) ); + } + virtual std::string getDescription() const override { + return std::string(); + } + }; + + public: + + ListenerRegistrar() { + getMutableRegistryHub().registerListener( std::make_shared() ); + } + }; +} + +#if !defined(CATCH_CONFIG_DISABLE) + +#define CATCH_REGISTER_REPORTER( name, reporterType ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + +#define CATCH_REGISTER_LISTENER( listenerType ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ListenerRegistrar catch_internal_RegistrarFor##listenerType; } \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +#else // CATCH_CONFIG_DISABLE + +#define CATCH_REGISTER_REPORTER(name, reporterType) +#define CATCH_REGISTER_LISTENER(listenerType) + +#endif // CATCH_CONFIG_DISABLE + +// end catch_reporter_registrars.hpp +// end catch_external_interfaces.h +#endif + +#ifdef CATCH_IMPL +// start catch_impl.hpp + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +// Keep these here for external reporters +// start catch_test_case_tracker.h + +#include +#include +#include + +namespace Catch { +namespace TestCaseTracking { + + struct NameAndLocation { + std::string name; + SourceLineInfo location; + + NameAndLocation( std::string const& _name, SourceLineInfo const& _location ); + }; + + struct ITracker; + + using ITrackerPtr = std::shared_ptr; + + struct ITracker { + virtual ~ITracker(); + + // static queries + virtual NameAndLocation const& nameAndLocation() const = 0; + + // dynamic queries + virtual bool isComplete() const = 0; // Successfully completed or failed + virtual bool isSuccessfullyCompleted() const = 0; + virtual bool isOpen() const = 0; // Started but not complete + virtual bool hasChildren() const = 0; + + virtual ITracker& parent() = 0; + + // actions + virtual void close() = 0; // Successfully complete + virtual void fail() = 0; + virtual void markAsNeedingAnotherRun() = 0; + + virtual void addChild( ITrackerPtr const& child ) = 0; + virtual ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) = 0; + virtual void openChild() = 0; + + // Debug/ checking + virtual bool isSectionTracker() const = 0; + virtual bool isIndexTracker() const = 0; + }; + + class TrackerContext { + + enum RunState { + NotStarted, + Executing, + CompletedCycle + }; + + ITrackerPtr m_rootTracker; + ITracker* m_currentTracker = nullptr; + RunState m_runState = NotStarted; + + public: + + static TrackerContext& instance(); + + ITracker& startRun(); + void endRun(); + + void startCycle(); + void completeCycle(); + + bool completedCycle() const; + ITracker& currentTracker(); + void setCurrentTracker( ITracker* tracker ); + }; + + class TrackerBase : public ITracker { + protected: + enum CycleState { + NotStarted, + Executing, + ExecutingChildren, + NeedsAnotherRun, + CompletedSuccessfully, + Failed + }; + + class TrackerHasName { + NameAndLocation m_nameAndLocation; + public: + TrackerHasName( NameAndLocation const& nameAndLocation ); + bool operator ()( ITrackerPtr const& tracker ) const; + }; + + using Children = std::vector; + NameAndLocation m_nameAndLocation; + TrackerContext& m_ctx; + ITracker* m_parent; + Children m_children; + CycleState m_runState = NotStarted; + + public: + TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); + + NameAndLocation const& nameAndLocation() const override; + bool isComplete() const override; + bool isSuccessfullyCompleted() const override; + bool isOpen() const override; + bool hasChildren() const override; + + void addChild( ITrackerPtr const& child ) override; + + ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) override; + ITracker& parent() override; + + void openChild() override; + + bool isSectionTracker() const override; + bool isIndexTracker() const override; + + void open(); + + void close() override; + void fail() override; + void markAsNeedingAnotherRun() override; + + private: + void moveToParent(); + void moveToThis(); + }; + + class SectionTracker : public TrackerBase { + std::vector m_filters; + public: + SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); + + bool isSectionTracker() const override; + + static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ); + + void tryOpen(); + + void addInitialFilters( std::vector const& filters ); + void addNextFilters( std::vector const& filters ); + }; + + class IndexTracker : public TrackerBase { + int m_size; + int m_index = -1; + public: + IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size ); + + bool isIndexTracker() const override; + void close() override; + + static IndexTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ); + + int index() const; + + void moveNext(); + }; + +} // namespace TestCaseTracking + +using TestCaseTracking::ITracker; +using TestCaseTracking::TrackerContext; +using TestCaseTracking::SectionTracker; +using TestCaseTracking::IndexTracker; + +} // namespace Catch + +// end catch_test_case_tracker.h + +// start catch_leak_detector.h + +namespace Catch { + + struct LeakDetector { + LeakDetector(); + }; + +} +// end catch_leak_detector.h +// Cpp files will be included in the single-header file here +// start catch_approx.cpp + +#include +#include + +namespace { + +// Performs equivalent check of std::fabs(lhs - rhs) <= margin +// But without the subtraction to allow for INFINITY in comparison +bool marginComparison(double lhs, double rhs, double margin) { + return (lhs + margin >= rhs) && (rhs + margin >= lhs); +} + +} + +namespace Catch { +namespace Detail { + + Approx::Approx ( double value ) + : m_epsilon( std::numeric_limits::epsilon()*100 ), + m_margin( 0.0 ), + m_scale( 0.0 ), + m_value( value ) + {} + + Approx Approx::custom() { + return Approx( 0 ); + } + + std::string Approx::toString() const { + std::ostringstream oss; + oss << "Approx( " << ::Catch::Detail::stringify( m_value ) << " )"; + return oss.str(); + } + + bool Approx::equalityComparisonImpl(const double other) const { + // First try with fixed margin, then compute margin based on epsilon, scale and Approx's value + // Thanks to Richard Harris for his help refining the scaled margin value + return marginComparison(m_value, other, m_margin) || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(m_value))); + } + +} // end namespace Detail + +std::string StringMaker::convert(Catch::Detail::Approx const& value) { + return value.toString(); +} + +} // end namespace Catch +// end catch_approx.cpp +// start catch_assertionhandler.cpp + +// start catch_context.h + +#include + +namespace Catch { + + struct IResultCapture; + struct IRunner; + struct IConfig; + + using IConfigPtr = std::shared_ptr; + + struct IContext + { + virtual ~IContext(); + + virtual IResultCapture* getResultCapture() = 0; + virtual IRunner* getRunner() = 0; + virtual IConfigPtr getConfig() const = 0; + }; + + struct IMutableContext : IContext + { + virtual ~IMutableContext(); + virtual void setResultCapture( IResultCapture* resultCapture ) = 0; + virtual void setRunner( IRunner* runner ) = 0; + virtual void setConfig( IConfigPtr const& config ) = 0; + }; + + IContext& getCurrentContext(); + IMutableContext& getCurrentMutableContext(); + void cleanUpContext(); +} + +// end catch_context.h +#include + +namespace Catch { + + auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& { + expr.streamReconstructedExpression( os ); + return os; + } + + LazyExpression::LazyExpression( bool isNegated ) + : m_isNegated( isNegated ) + {} + + LazyExpression::LazyExpression( LazyExpression const& other ) : m_isNegated( other.m_isNegated ) {} + + LazyExpression::operator bool() const { + return m_transientExpression != nullptr; + } + + auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream& { + if( lazyExpr.m_isNegated ) + os << "!"; + + if( lazyExpr ) { + if( lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression() ) + os << "(" << *lazyExpr.m_transientExpression << ")"; + else + os << *lazyExpr.m_transientExpression; + } + else { + os << "{** error - unchecked empty expression requested **}"; + } + return os; + } + + AssertionHandler::AssertionHandler + ( StringRef macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ) + : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition } + { + getCurrentContext().getResultCapture()->assertionStarting( m_assertionInfo ); + } + AssertionHandler::~AssertionHandler() { + if ( m_inExceptionGuard ) { + handle( ResultWas::ThrewException, "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE" ); + getCurrentContext().getResultCapture()->exceptionEarlyReported(); + } + } + + void AssertionHandler::handle( ITransientExpression const& expr ) { + + bool negated = isFalseTest( m_assertionInfo.resultDisposition ); + bool result = expr.getResult() != negated; + + handle( result ? ResultWas::Ok : ResultWas::ExpressionFailed, &expr, negated ); + } + void AssertionHandler::handle( ResultWas::OfType resultType ) { + handle( resultType, nullptr, false ); + } + void AssertionHandler::handle( ResultWas::OfType resultType, StringRef const& message ) { + AssertionResultData data( resultType, LazyExpression( false ) ); + data.message = message; + handle( data, nullptr ); + } + void AssertionHandler::handle( ResultWas::OfType resultType, ITransientExpression const* expr, bool negated ) { + AssertionResultData data( resultType, LazyExpression( negated ) ); + handle( data, expr ); + } + void AssertionHandler::handle( AssertionResultData const& resultData, ITransientExpression const* expr ) { + + getResultCapture().assertionRun(); + + AssertionResult assertionResult{ m_assertionInfo, resultData }; + assertionResult.m_resultData.lazyExpression.m_transientExpression = expr; + + getResultCapture().assertionEnded( assertionResult ); + + if( !assertionResult.isOk() ) { + m_shouldDebugBreak = getCurrentContext().getConfig()->shouldDebugBreak(); + m_shouldThrow = + getCurrentContext().getRunner()->aborting() || + (m_assertionInfo.resultDisposition & ResultDisposition::Normal); + } + } + + auto AssertionHandler::allowThrows() const -> bool { + return getCurrentContext().getConfig()->allowThrows(); + } + + auto AssertionHandler::shouldDebugBreak() const -> bool { + return m_shouldDebugBreak; + } + void AssertionHandler::reactWithDebugBreak() const { + if (m_shouldDebugBreak) { + /////////////////////////////////////////////////////////////////// + // To inspect the state during test, you need to go one level up the callstack + // To go back to the test and change execution, jump over the reactWithoutDebugBreak() call + /////////////////////////////////////////////////////////////////// + CATCH_BREAK_INTO_DEBUGGER(); + } + reactWithoutDebugBreak(); + } + void AssertionHandler::reactWithoutDebugBreak() const { + if( m_shouldThrow ) + throw Catch::TestFailureException(); + } + + void AssertionHandler::useActiveException() { + handle( ResultWas::ThrewException, Catch::translateActiveException() ); + } + + void AssertionHandler::setExceptionGuard() { + assert( m_inExceptionGuard == false ); + m_inExceptionGuard = true; + } + void AssertionHandler::unsetExceptionGuard() { + assert( m_inExceptionGuard == true ); + m_inExceptionGuard = false; + } + + // This is the overload that takes a string and infers the Equals matcher from it + // The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) { + handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString ); + } + +} // namespace Catch +// end catch_assertionhandler.cpp +// start catch_assertionresult.cpp + +namespace Catch { + AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression): + lazyExpression(_lazyExpression), + resultType(_resultType) {} + + std::string AssertionResultData::reconstructExpression() const { + + if( reconstructedExpression.empty() ) { + if( lazyExpression ) { + // !TBD Use stringstream for now, but rework above to pass stream in + std::ostringstream oss; + oss << lazyExpression; + reconstructedExpression = oss.str(); + } + } + return reconstructedExpression; + } + + AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) + : m_info( info ), + m_resultData( data ) + {} + + // Result was a success + bool AssertionResult::succeeded() const { + return Catch::isOk( m_resultData.resultType ); + } + + // Result was a success, or failure is suppressed + bool AssertionResult::isOk() const { + return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); + } + + ResultWas::OfType AssertionResult::getResultType() const { + return m_resultData.resultType; + } + + bool AssertionResult::hasExpression() const { + return m_info.capturedExpression[0] != 0; + } + + bool AssertionResult::hasMessage() const { + return !m_resultData.message.empty(); + } + + std::string AssertionResult::getExpression() const { + if( isFalseTest( m_info.resultDisposition ) ) + return "!(" + std::string(m_info.capturedExpression) + ")"; + else + return m_info.capturedExpression; + } + + std::string AssertionResult::getExpressionInMacro() const { + std::string expr; + if( m_info.macroName[0] == 0 ) + expr = m_info.capturedExpression; + else { + expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 ); + expr += m_info.macroName; + expr += "( "; + expr += m_info.capturedExpression; + expr += " )"; + } + return expr; + } + + bool AssertionResult::hasExpandedExpression() const { + return hasExpression() && getExpandedExpression() != getExpression(); + } + + std::string AssertionResult::getExpandedExpression() const { + std::string expr = m_resultData.reconstructExpression(); + return expr.empty() + ? getExpression() + : expr; + } + + std::string AssertionResult::getMessage() const { + return m_resultData.message; + } + SourceLineInfo AssertionResult::getSourceInfo() const { + return m_info.lineInfo; + } + + std::string AssertionResult::getTestMacroName() const { + return m_info.macroName; + } + +} // end namespace Catch +// end catch_assertionresult.cpp +// start catch_benchmark.cpp + +namespace Catch { + + auto BenchmarkLooper::getResolution() -> uint64_t { + return getEstimatedClockResolution() * getCurrentContext().getConfig()->benchmarkResolutionMultiple(); + } + + void BenchmarkLooper::reportStart() { + getResultCapture().benchmarkStarting( { m_name } ); + } + auto BenchmarkLooper::needsMoreIterations() -> bool { + auto elapsed = m_timer.getElapsedNanoseconds(); + + // Exponentially increasing iterations until we're confident in our timer resolution + if( elapsed < m_resolution ) { + m_iterationsToRun *= 10; + return true; + } + + getResultCapture().benchmarkEnded( { { m_name }, m_count, elapsed } ); + return false; + } + +} // end namespace Catch +// end catch_benchmark.cpp +// start catch_capture_matchers.cpp + +namespace Catch { + + using StringMatcher = Matchers::Impl::MatcherBase; + + // This is the general overload that takes a any string matcher + // There is another overload, in catch_assertinhandler.h/.cpp, that only takes a string and infers + // the Equals matcher (so the header does not mention matchers) + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) { + std::string exceptionMessage = Catch::translateActiveException(); + MatchExpr expr( exceptionMessage, matcher, matcherString ); + handler.handle( expr ); + } + +} // namespace Catch +// end catch_capture_matchers.cpp +// start catch_commandline.cpp + +// start catch_commandline.h + +// start catch_clara.h + +// Use Catch's value for console width (store Clara's off to the side, if present) +#ifdef CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#undef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#endif +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH-1 + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wexit-time-destructors" +#pragma clang diagnostic ignored "-Wshadow" +#endif + +// start clara.hpp +// v1.0-develop.2 +// See https://github.com/philsquared/Clara + + +#ifndef CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_CONFIG_CONSOLE_WIDTH 80 +#endif + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +// ----------- #included from clara_textflow.hpp ----------- + +// TextFlowCpp +// +// A single-header library for wrapping and laying out basic text, by Phil Nash +// +// This work is licensed under the BSD 2-Clause license. +// See the accompanying LICENSE file, or the one at https://opensource.org/licenses/BSD-2-Clause +// +// This project is hosted at https://github.com/philsquared/textflowcpp + + +#include +#include +#include +#include + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80 +#endif + +namespace Catch { namespace clara { namespace TextFlow { + + inline auto isWhitespace( char c ) -> bool { + static std::string chars = " \t\n\r"; + return chars.find( c ) != std::string::npos; + } + inline auto isBreakableBefore( char c ) -> bool { + static std::string chars = "[({<|"; + return chars.find( c ) != std::string::npos; + } + inline auto isBreakableAfter( char c ) -> bool { + static std::string chars = "])}>.,:;*+-=&/\\"; + return chars.find( c ) != std::string::npos; + } + + class Columns; + + class Column { + std::vector m_strings; + size_t m_width = CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH; + size_t m_indent = 0; + size_t m_initialIndent = std::string::npos; + + public: + class iterator { + friend Column; + + Column const& m_column; + size_t m_stringIndex = 0; + size_t m_pos = 0; + + size_t m_len = 0; + size_t m_end = 0; + bool m_suffix = false; + + iterator( Column const& column, size_t stringIndex ) + : m_column( column ), + m_stringIndex( stringIndex ) + {} + + auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; } + + auto isBoundary( size_t at ) const -> bool { + assert( at > 0 ); + assert( at <= line().size() ); + + return at == line().size() || + ( isWhitespace( line()[at] ) && !isWhitespace( line()[at-1] ) ) || + isBreakableBefore( line()[at] ) || + isBreakableAfter( line()[at-1] ); + } + + void calcLength() { + assert( m_stringIndex < m_column.m_strings.size() ); + + m_suffix = false; + auto width = m_column.m_width-indent(); + m_end = m_pos; + while( m_end < line().size() && line()[m_end] != '\n' ) + ++m_end; + + if( m_end < m_pos + width ) { + m_len = m_end - m_pos; + } + else { + size_t len = width; + while (len > 0 && !isBoundary(m_pos + len)) + --len; + while (len > 0 && isWhitespace( line()[m_pos + len - 1] )) + --len; + + if (len > 0) { + m_len = len; + } else { + m_suffix = true; + m_len = width - 1; + } + } + } + + auto indent() const -> size_t { + auto initial = m_pos == 0 && m_stringIndex == 0 ? m_column.m_initialIndent : std::string::npos; + return initial == std::string::npos ? m_column.m_indent : initial; + } + + auto addIndentAndSuffix(std::string const &plain) const -> std::string { + return std::string( indent(), ' ' ) + (m_suffix ? plain + "-" : plain); + } + + public: + explicit iterator( Column const& column ) : m_column( column ) { + assert( m_column.m_width > m_column.m_indent ); + assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent ); + calcLength(); + if( m_len == 0 ) + m_stringIndex++; // Empty string + } + + auto operator *() const -> std::string { + assert( m_stringIndex < m_column.m_strings.size() ); + assert( m_pos <= m_end ); + if( m_pos + m_column.m_width < m_end ) + return addIndentAndSuffix(line().substr(m_pos, m_len)); + else + return addIndentAndSuffix(line().substr(m_pos, m_end - m_pos)); + } + + auto operator ++() -> iterator& { + m_pos += m_len; + if( m_pos < line().size() && line()[m_pos] == '\n' ) + m_pos += 1; + else + while( m_pos < line().size() && isWhitespace( line()[m_pos] ) ) + ++m_pos; + + if( m_pos == line().size() ) { + m_pos = 0; + ++m_stringIndex; + } + if( m_stringIndex < m_column.m_strings.size() ) + calcLength(); + return *this; + } + auto operator ++(int) -> iterator { + iterator prev( *this ); + operator++(); + return prev; + } + + auto operator ==( iterator const& other ) const -> bool { + return + m_pos == other.m_pos && + m_stringIndex == other.m_stringIndex && + &m_column == &other.m_column; + } + auto operator !=( iterator const& other ) const -> bool { + return !operator==( other ); + } + }; + using const_iterator = iterator; + + explicit Column( std::string const& text ) { m_strings.push_back( text ); } + + auto width( size_t newWidth ) -> Column& { + assert( newWidth > 0 ); + m_width = newWidth; + return *this; + } + auto indent( size_t newIndent ) -> Column& { + m_indent = newIndent; + return *this; + } + auto initialIndent( size_t newIndent ) -> Column& { + m_initialIndent = newIndent; + return *this; + } + + auto width() const -> size_t { return m_width; } + auto begin() const -> iterator { return iterator( *this ); } + auto end() const -> iterator { return { *this, m_strings.size() }; } + + inline friend std::ostream& operator << ( std::ostream& os, Column const& col ) { + bool first = true; + for( auto line : col ) { + if( first ) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto operator + ( Column const& other ) -> Columns; + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + }; + + class Spacer : public Column { + + public: + explicit Spacer( size_t spaceWidth ) : Column( "" ) { + width( spaceWidth ); + } + }; + + class Columns { + std::vector m_columns; + + public: + + class iterator { + friend Columns; + struct EndTag {}; + + std::vector const& m_columns; + std::vector m_iterators; + size_t m_activeIterators; + + iterator( Columns const& columns, EndTag ) + : m_columns( columns.m_columns ), + m_activeIterators( 0 ) + { + m_iterators.reserve( m_columns.size() ); + + for( auto const& col : m_columns ) + m_iterators.push_back( col.end() ); + } + + public: + explicit iterator( Columns const& columns ) + : m_columns( columns.m_columns ), + m_activeIterators( m_columns.size() ) + { + m_iterators.reserve( m_columns.size() ); + + for( auto const& col : m_columns ) + m_iterators.push_back( col.begin() ); + } + + auto operator ==( iterator const& other ) const -> bool { + return m_iterators == other.m_iterators; + } + auto operator !=( iterator const& other ) const -> bool { + return m_iterators != other.m_iterators; + } + auto operator *() const -> std::string { + std::string row, padding; + + for( size_t i = 0; i < m_columns.size(); ++i ) { + auto width = m_columns[i].width(); + if( m_iterators[i] != m_columns[i].end() ) { + std::string col = *m_iterators[i]; + row += padding + col; + if( col.size() < width ) + padding = std::string( width - col.size(), ' ' ); + else + padding = ""; + } + else { + padding += std::string( width, ' ' ); + } + } + return row; + } + auto operator ++() -> iterator& { + for( size_t i = 0; i < m_columns.size(); ++i ) { + if (m_iterators[i] != m_columns[i].end()) + ++m_iterators[i]; + } + return *this; + } + auto operator ++(int) -> iterator { + iterator prev( *this ); + operator++(); + return prev; + } + }; + using const_iterator = iterator; + + auto begin() const -> iterator { return iterator( *this ); } + auto end() const -> iterator { return { *this, iterator::EndTag() }; } + + auto operator += ( Column const& col ) -> Columns& { + m_columns.push_back( col ); + return *this; + } + auto operator + ( Column const& col ) -> Columns { + Columns combined = *this; + combined += col; + return combined; + } + + inline friend std::ostream& operator << ( std::ostream& os, Columns const& cols ) { + + bool first = true; + for( auto line : cols ) { + if( first ) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + }; + + inline auto Column::operator + ( Column const& other ) -> Columns { + Columns cols; + cols += *this; + cols += other; + return cols; + } +}}} // namespace Catch::clara::TextFlow + +// ----------- end of #include from clara_textflow.hpp ----------- +// ........... back in clara.hpp + +#include +#include +#include + +#if !defined(CATCH_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) ) +#define CATCH_PLATFORM_WINDOWS +#endif + +namespace Catch { namespace clara { +namespace detail { + + // Traits for extracting arg and return type of lambdas (for single argument lambdas) + template + struct UnaryLambdaTraits : UnaryLambdaTraits {}; + + template + struct UnaryLambdaTraits { + static const bool isValid = false; + }; + + template + struct UnaryLambdaTraits { + static const bool isValid = true; + using ArgType = typename std::remove_const::type>::type;; + using ReturnType = ReturnT; + }; + + class TokenStream; + + // Transport for raw args (copied from main args, or supplied via init list for testing) + class Args { + friend TokenStream; + std::string m_exeName; + std::vector m_args; + + public: + Args( int argc, char *argv[] ) { + m_exeName = argv[0]; + for( int i = 1; i < argc; ++i ) + m_args.push_back( argv[i] ); + } + + Args( std::initializer_list args ) + : m_exeName( *args.begin() ), + m_args( args.begin()+1, args.end() ) + {} + + auto exeName() const -> std::string { + return m_exeName; + } + }; + + // Wraps a token coming from a token stream. These may not directly correspond to strings as a single string + // may encode an option + its argument if the : or = form is used + enum class TokenType { + Option, Argument + }; + struct Token { + TokenType type; + std::string token; + }; + + inline auto isOptPrefix( char c ) -> bool { + return c == '-' +#ifdef CATCH_PLATFORM_WINDOWS + || c == '/' +#endif + ; + } + + // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled + class TokenStream { + using Iterator = std::vector::const_iterator; + Iterator it; + Iterator itEnd; + std::vector m_tokenBuffer; + + void loadBuffer() { + m_tokenBuffer.resize( 0 ); + + // Skip any empty strings + while( it != itEnd && it->empty() ) + ++it; + + if( it != itEnd ) { + auto const &next = *it; + if( isOptPrefix( next[0] ) ) { + auto delimiterPos = next.find_first_of( " :=" ); + if( delimiterPos != std::string::npos ) { + m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); + m_tokenBuffer.push_back( { TokenType::Argument, next.substr( delimiterPos + 1 ) } ); + } else { + if( next[1] != '-' && next.size() > 2 ) { + std::string opt = "- "; + for( size_t i = 1; i < next.size(); ++i ) { + opt[1] = next[i]; + m_tokenBuffer.push_back( { TokenType::Option, opt } ); + } + } else { + m_tokenBuffer.push_back( { TokenType::Option, next } ); + } + } + } else { + m_tokenBuffer.push_back( { TokenType::Argument, next } ); + } + } + } + + public: + explicit TokenStream( Args const &args ) : TokenStream( args.m_args.begin(), args.m_args.end() ) {} + + TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( itEnd ) { + loadBuffer(); + } + + explicit operator bool() const { + return !m_tokenBuffer.empty() || it != itEnd; + } + + auto count() const -> size_t { return m_tokenBuffer.size() + (itEnd - it); } + + auto operator*() const -> Token { + assert( !m_tokenBuffer.empty() ); + return m_tokenBuffer.front(); + } + + auto operator->() const -> Token const * { + assert( !m_tokenBuffer.empty() ); + return &m_tokenBuffer.front(); + } + + auto operator++() -> TokenStream & { + if( m_tokenBuffer.size() >= 2 ) { + m_tokenBuffer.erase( m_tokenBuffer.begin() ); + } else { + if( it != itEnd ) + ++it; + loadBuffer(); + } + return *this; + } + }; + + class ResultBase { + public: + enum Type { + Ok, LogicError, RuntimeError + }; + + protected: + ResultBase( Type type ) : m_type( type ) {} + virtual ~ResultBase() = default; + + virtual void enforceOk() const = 0; + + Type m_type; + }; + + template + class ResultValueBase : public ResultBase { + public: + auto value() const -> T const & { + enforceOk(); + return m_value; + } + + protected: + ResultValueBase( Type type ) : ResultBase( type ) {} + + ResultValueBase( ResultValueBase const &other ) : ResultBase( other ) { + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + } + + ResultValueBase( Type, T const &value ) : ResultBase( Ok ) { + new( &m_value ) T( value ); + } + + auto operator=( ResultValueBase const &other ) -> ResultValueBase & { + if( m_type == ResultBase::Ok ) + m_value.~T(); + ResultBase::operator=(other); + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + return *this; + } + + ~ResultValueBase() { + if( m_type == Ok ) + m_value.~T(); + } + + union { + T m_value; + }; + }; + + template<> + class ResultValueBase : public ResultBase { + protected: + using ResultBase::ResultBase; + }; + + template + class BasicResult : public ResultValueBase { + public: + template + explicit BasicResult( BasicResult const &other ) + : ResultValueBase( other.type() ), + m_errorMessage( other.errorMessage() ) + { + assert( type() != ResultBase::Ok ); + } + + template + static auto ok( U const &value ) -> BasicResult { return { ResultBase::Ok, value }; } + static auto ok() -> BasicResult { return { ResultBase::Ok }; } + static auto logicError( std::string const &message ) -> BasicResult { return { ResultBase::LogicError, message }; } + static auto runtimeError( std::string const &message ) -> BasicResult { return { ResultBase::RuntimeError, message }; } + + explicit operator bool() const { return m_type == ResultBase::Ok; } + auto type() const -> ResultBase::Type { return m_type; } + auto errorMessage() const -> std::string { return m_errorMessage; } + + protected: + virtual void enforceOk() const { + // !TBD: If no exceptions, std::terminate here or something + switch( m_type ) { + case ResultBase::LogicError: + throw std::logic_error( m_errorMessage ); + case ResultBase::RuntimeError: + throw std::runtime_error( m_errorMessage ); + case ResultBase::Ok: + break; + } + } + + std::string m_errorMessage; // Only populated if resultType is an error + + BasicResult( ResultBase::Type type, std::string const &message ) + : ResultValueBase(type), + m_errorMessage(message) + { + assert( m_type != ResultBase::Ok ); + } + + using ResultValueBase::ResultValueBase; + using ResultBase::m_type; + }; + + enum class ParseResultType { + Matched, NoMatch, ShortCircuitAll, ShortCircuitSame + }; + + class ParseState { + public: + + ParseState( ParseResultType type, TokenStream const &remainingTokens ) + : m_type(type), + m_remainingTokens( remainingTokens ) + {} + + auto type() const -> ParseResultType { return m_type; } + auto remainingTokens() const -> TokenStream { return m_remainingTokens; } + + private: + ParseResultType m_type; + TokenStream m_remainingTokens; + }; + + using Result = BasicResult; + using ParserResult = BasicResult; + using InternalParseResult = BasicResult; + + struct HelpColumns { + std::string left; + std::string right; + }; + + template + inline auto convertInto( std::string const &source, T& target ) -> ParserResult { + std::stringstream ss; + ss << source; + ss >> target; + if( ss.fail() ) + return ParserResult::runtimeError( "Unable to convert '" + source + "' to destination type" ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, std::string& target ) -> ParserResult { + target = source; + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { + std::string srcLC = source; + std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast( ::tolower(c) ); } ); + if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") + target = true; + else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") + target = false; + else + return ParserResult::runtimeError( "Expected a boolean value but did not recognise: '" + source + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + } + + struct BoundRefBase { + BoundRefBase() = default; + BoundRefBase( BoundRefBase const & ) = delete; + BoundRefBase( BoundRefBase && ) = delete; + BoundRefBase &operator=( BoundRefBase const & ) = delete; + BoundRefBase &operator=( BoundRefBase && ) = delete; + + virtual ~BoundRefBase() = default; + + virtual auto isFlag() const -> bool = 0; + virtual auto isContainer() const -> bool { return false; } + virtual auto setValue( std::string const &arg ) -> ParserResult = 0; + virtual auto setFlag( bool flag ) -> ParserResult = 0; + }; + + struct BoundValueRefBase : BoundRefBase { + auto isFlag() const -> bool override { return false; } + + auto setFlag( bool ) -> ParserResult override { + return ParserResult::logicError( "Flags can only be set on boolean fields" ); + } + }; + + struct BoundFlagRefBase : BoundRefBase { + auto isFlag() const -> bool override { return true; } + + auto setValue( std::string const &arg ) -> ParserResult override { + bool flag; + auto result = convertInto( arg, flag ); + if( result ) + setFlag( flag ); + return result; + } + }; + + template + struct BoundRef : BoundValueRefBase { + T &m_ref; + + explicit BoundRef( T &ref ) : m_ref( ref ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return convertInto( arg, m_ref ); + } + }; + + template + struct BoundRef> : BoundValueRefBase { + std::vector &m_ref; + + explicit BoundRef( std::vector &ref ) : m_ref( ref ) {} + + auto isContainer() const -> bool override { return true; } + + auto setValue( std::string const &arg ) -> ParserResult override { + T temp; + auto result = convertInto( arg, temp ); + if( result ) + m_ref.push_back( temp ); + return result; + } + }; + + struct BoundFlagRef : BoundFlagRefBase { + bool &m_ref; + + explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {} + + auto setFlag( bool flag ) -> ParserResult override { + m_ref = flag; + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + struct LambdaInvoker { + static_assert( std::is_same::value, "Lambda must return void or clara::ParserResult" ); + + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + return lambda( arg ); + } + }; + + template<> + struct LambdaInvoker { + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + lambda( arg ); + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + inline auto invokeLambda( L const &lambda, std::string const &arg ) -> ParserResult { + ArgType temp; + auto result = convertInto( arg, temp ); + return !result + ? result + : LambdaInvoker::ReturnType>::invoke( lambda, temp ); + }; + + template + struct BoundLambda : BoundValueRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return invokeLambda::ArgType>( m_lambda, arg ); + } + }; + + template + struct BoundFlagLambda : BoundFlagRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + static_assert( std::is_same::ArgType, bool>::value, "flags must be boolean" ); + + explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setFlag( bool flag ) -> ParserResult override { + return LambdaInvoker::ReturnType>::invoke( m_lambda, flag ); + } + }; + + enum class Optionality { Optional, Required }; + + struct Parser; + + class ParserBase { + public: + virtual ~ParserBase() = default; + virtual auto validate() const -> Result { return Result::ok(); } + virtual auto parse( std::string const& exeName, TokenStream const &tokens) const -> InternalParseResult = 0; + virtual auto cardinality() const -> size_t { return 1; } + + auto parse( Args const &args ) const -> InternalParseResult { + return parse( args.exeName(), TokenStream( args ) ); + } + }; + + template + class ComposableParserImpl : public ParserBase { + public: + template + auto operator|( T const &other ) const -> Parser; + }; + + // Common code and state for Args and Opts + template + class ParserRefImpl : public ComposableParserImpl { + protected: + Optionality m_optionality = Optionality::Optional; + std::shared_ptr m_ref; + std::string m_hint; + std::string m_description; + + explicit ParserRefImpl( std::shared_ptr const &ref ) : m_ref( ref ) {} + + public: + template + ParserRefImpl( T &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint( hint ) + {} + + template + ParserRefImpl( LambdaT const &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint(hint) + {} + + auto operator()( std::string const &description ) -> DerivedT & { + m_description = description; + return static_cast( *this ); + } + + auto optional() -> DerivedT & { + m_optionality = Optionality::Optional; + return static_cast( *this ); + }; + + auto required() -> DerivedT & { + m_optionality = Optionality::Required; + return static_cast( *this ); + }; + + auto isOptional() const -> bool { + return m_optionality == Optionality::Optional; + } + + auto cardinality() const -> size_t override { + if( m_ref->isContainer() ) + return 0; + else + return 1; + } + + auto hint() const -> std::string { return m_hint; } + }; + + class ExeName : public ComposableParserImpl { + std::shared_ptr m_name; + std::shared_ptr m_ref; + + template + static auto makeRef(LambdaT const &lambda) -> std::shared_ptr { + return std::make_shared>( lambda) ; + } + + public: + ExeName() : m_name( std::make_shared( "" ) ) {} + + explicit ExeName( std::string &ref ) : ExeName() { + m_ref = std::make_shared>( ref ); + } + + template + explicit ExeName( LambdaT const& lambda ) : ExeName() { + m_ref = std::make_shared>( lambda ); + } + + // The exe name is not parsed out of the normal tokens, but is handled specially + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + } + + auto name() const -> std::string { return *m_name; } + auto set( std::string const& newName ) -> ParserResult { + + auto lastSlash = newName.find_last_of( "\\/" ); + auto filename = ( lastSlash == std::string::npos ) + ? newName + : newName.substr( lastSlash+1 ); + + *m_name = filename; + if( m_ref ) + return m_ref->setValue( filename ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + class Arg : public ParserRefImpl { + public: + using ParserRefImpl::ParserRefImpl; + + auto parse( std::string const &, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + auto const &token = *remainingTokens; + if( token.type != TokenType::Argument ) + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + + auto result = m_ref->setValue( remainingTokens->token ); + if( !result ) + return InternalParseResult( result ); + else + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + }; + + inline auto normaliseOpt( std::string const &optName ) -> std::string { +#ifdef CATCH_PLATFORM_WINDOWS + if( optName[0] == '/' ) + return "-" + optName.substr( 1 ); + else +#endif + return optName; + } + + class Opt : public ParserRefImpl { + protected: + std::vector m_optNames; + + public: + template + explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_shared>( ref ) ) {} + + explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared( ref ) ) {} + + template + Opt( LambdaT const &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + template + Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + auto operator[]( std::string const &optName ) -> Opt & { + m_optNames.push_back( optName ); + return *this; + } + + auto getHelpColumns() const -> std::vector { + std::ostringstream oss; + bool first = true; + for( auto const &opt : m_optNames ) { + if (first) + first = false; + else + oss << ", "; + oss << opt; + } + if( !m_hint.empty() ) + oss << " <" << m_hint << ">"; + return { { oss.str(), m_description } }; + } + + auto isMatch( std::string const &optToken ) const -> bool { + auto normalisedToken = normaliseOpt( optToken ); + for( auto const &name : m_optNames ) { + if( normaliseOpt( name ) == normalisedToken ) + return true; + } + return false; + } + + using ParserBase::parse; + + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + if( remainingTokens && remainingTokens->type == TokenType::Option ) { + auto const &token = *remainingTokens; + if( isMatch(token.token ) ) { + if( m_ref->isFlag() ) { + auto result = m_ref->setFlag( true ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } else { + ++remainingTokens; + if( !remainingTokens ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto const &argToken = *remainingTokens; + if( argToken.type != TokenType::Argument ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto result = m_ref->setValue( argToken.token ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + } + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + } + + auto validate() const -> Result override { + if( m_optNames.empty() ) + return Result::logicError( "No options supplied to Opt" ); + for( auto const &name : m_optNames ) { + if( name.empty() ) + return Result::logicError( "Option name cannot be empty" ); +#ifdef CATCH_PLATFORM_WINDOWS + if( name[0] != '-' && name[0] != '/' ) + return Result::logicError( "Option name must begin with '-' or '/'" ); +#else + if( name[0] != '-' ) + return Result::logicError( "Option name must begin with '-'" ); +#endif + } + return ParserRefImpl::validate(); + } + }; + + struct Help : Opt { + Help( bool &showHelpFlag ) + : Opt([&]( bool flag ) { + showHelpFlag = flag; + return ParserResult::ok( ParseResultType::ShortCircuitAll ); + }) + { + static_cast( *this ) + ("display usage information") + ["-?"]["-h"]["--help"] + .optional(); + } + }; + + struct Parser : ParserBase { + + mutable ExeName m_exeName; + std::vector m_options; + std::vector m_args; + + auto operator|=( ExeName const &exeName ) -> Parser & { + m_exeName = exeName; + return *this; + } + + auto operator|=( Arg const &arg ) -> Parser & { + m_args.push_back(arg); + return *this; + } + + auto operator|=( Opt const &opt ) -> Parser & { + m_options.push_back(opt); + return *this; + } + + auto operator|=( Parser const &other ) -> Parser & { + m_options.insert(m_options.end(), other.m_options.begin(), other.m_options.end()); + m_args.insert(m_args.end(), other.m_args.begin(), other.m_args.end()); + return *this; + } + + template + auto operator|( T const &other ) const -> Parser { + return Parser( *this ) |= other; + } + + auto getHelpColumns() const -> std::vector { + std::vector cols; + for (auto const &o : m_options) { + auto childCols = o.getHelpColumns(); + cols.insert( cols.end(), childCols.begin(), childCols.end() ); + } + return cols; + } + + void writeToStream( std::ostream &os ) const { + if (!m_exeName.name().empty()) { + os << "usage:\n" << " " << m_exeName.name() << " "; + bool required = true, first = true; + for( auto const &arg : m_args ) { + if (first) + first = false; + else + os << " "; + if( arg.isOptional() && required ) { + os << "["; + required = false; + } + os << "<" << arg.hint() << ">"; + if( arg.cardinality() == 0 ) + os << " ... "; + } + if( !required ) + os << "]"; + if( !m_options.empty() ) + os << " options"; + os << "\n\nwhere options are:" << std::endl; + } + + auto rows = getHelpColumns(); + size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH; + size_t optWidth = 0; + for( auto const &cols : rows ) + optWidth = (std::max)(optWidth, cols.left.size() + 2); + + for( auto const &cols : rows ) { + auto row = + TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) + + TextFlow::Spacer(4) + + TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth ); + os << row << std::endl; + } + } + + friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& { + parser.writeToStream( os ); + return os; + } + + auto validate() const -> Result override { + for( auto const &opt : m_options ) { + auto result = opt.validate(); + if( !result ) + return result; + } + for( auto const &arg : m_args ) { + auto result = arg.validate(); + if( !result ) + return result; + } + return Result::ok(); + } + + using ParserBase::parse; + + auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override { + + struct ParserInfo { + ParserBase const* parser = nullptr; + size_t count = 0; + }; + const size_t totalParsers = m_options.size() + m_args.size(); + assert( totalParsers < 512 ); + // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do + ParserInfo parseInfos[512]; + + { + size_t i = 0; + for (auto const &opt : m_options) parseInfos[i++].parser = &opt; + for (auto const &arg : m_args) parseInfos[i++].parser = &arg; + } + + m_exeName.set( exeName ); + + auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + while( result.value().remainingTokens() ) { + bool tokenParsed = false; + + for( size_t i = 0; i < totalParsers; ++i ) { + auto& parseInfo = parseInfos[i]; + if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { + result = parseInfo.parser->parse(exeName, result.value().remainingTokens()); + if (!result) + return result; + if (result.value().type() != ParseResultType::NoMatch) { + tokenParsed = true; + ++parseInfo.count; + break; + } + } + } + + if( result.value().type() == ParseResultType::ShortCircuitAll ) + return result; + if( !tokenParsed ) + return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token ); + } + // !TBD Check missing required options + return result; + } + }; + + template + template + auto ComposableParserImpl::operator|( T const &other ) const -> Parser { + return Parser() | static_cast( *this ) | other; + } +} // namespace detail + +// A Combined parser +using detail::Parser; + +// A parser for options +using detail::Opt; + +// A parser for arguments +using detail::Arg; + +// Wrapper for argc, argv from main() +using detail::Args; + +// Specifies the name of the executable +using detail::ExeName; + +// Convenience wrapper for option parser that specifies the help option +using detail::Help; + +// enum of result types from a parse +using detail::ParseResultType; + +// Result type for parser operation +using detail::ParserResult; + +}} // namespace Catch::clara + +// end clara.hpp +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// Restore Clara's value for console width, if present +#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +// end catch_clara.h +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ); + +} // end namespace Catch + +// end catch_commandline.h +#include +#include + +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ) { + + using namespace clara; + + auto const setWarning = [&]( std::string const& warning ) { + if( warning != "NoAssertions" ) + return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" ); + config.warnings = static_cast( config.warnings | WarnAbout::NoAssertions ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const loadTestNamesFromFile = [&]( std::string const& filename ) { + std::ifstream f( filename.c_str() ); + if( !f.is_open() ) + return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" ); + + std::string line; + while( std::getline( f, line ) ) { + line = trim(line); + if( !line.empty() && !startsWith( line, '#' ) ) { + if( !startsWith( line, '"' ) ) + line = '"' + line + '"'; + config.testsOrTags.push_back( line + ',' ); + } + } + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setTestOrder = [&]( std::string const& order ) { + if( startsWith( "declared", order ) ) + config.runOrder = RunTests::InDeclarationOrder; + else if( startsWith( "lexical", order ) ) + config.runOrder = RunTests::InLexicographicalOrder; + else if( startsWith( "random", order ) ) + config.runOrder = RunTests::InRandomOrder; + else + return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setRngSeed = [&]( std::string const& seed ) { + if( seed != "time" ) + return clara::detail::convertInto( seed, config.rngSeed ); + config.rngSeed = static_cast( std::time(nullptr) ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setColourUsage = [&]( std::string const& useColour ) { + auto mode = toLower( useColour ); + + if( mode == "yes" ) + config.useColour = UseColour::Yes; + else if( mode == "no" ) + config.useColour = UseColour::No; + else if( mode == "auto" ) + config.useColour = UseColour::Auto; + else + return ParserResult::runtimeError( "colour mode must be one of: auto, yes or no. '" + useColour + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setWaitForKeypress = [&]( std::string const& keypress ) { + auto keypressLc = toLower( keypress ); + if( keypressLc == "start" ) + config.waitForKeypress = WaitForKeypress::BeforeStart; + else if( keypressLc == "exit" ) + config.waitForKeypress = WaitForKeypress::BeforeExit; + else if( keypressLc == "both" ) + config.waitForKeypress = WaitForKeypress::BeforeStartAndExit; + else + return ParserResult::runtimeError( "keypress argument must be one of: start, exit or both. '" + keypress + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setVerbosity = [&]( std::string const& verbosity ) { + auto lcVerbosity = toLower( verbosity ); + if( lcVerbosity == "quiet" ) + config.verbosity = Verbosity::Quiet; + else if( lcVerbosity == "normal" ) + config.verbosity = Verbosity::Normal; + else if( lcVerbosity == "high" ) + config.verbosity = Verbosity::High; + else + return ParserResult::runtimeError( "Unrecognised verbosity, '" + verbosity + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + + auto cli + = ExeName( config.processName ) + | Help( config.showHelp ) + | Opt( config.listTests ) + ["-l"]["--list-tests"] + ( "list all/matching test cases" ) + | Opt( config.listTags ) + ["-t"]["--list-tags"] + ( "list all/matching tags" ) + | Opt( config.showSuccessfulTests ) + ["-s"]["--success"] + ( "include successful tests in output" ) + | Opt( config.shouldDebugBreak ) + ["-b"]["--break"] + ( "break into debugger on failure" ) + | Opt( config.noThrow ) + ["-e"]["--nothrow"] + ( "skip exception tests" ) + | Opt( config.showInvisibles ) + ["-i"]["--invisibles"] + ( "show invisibles (tabs, newlines)" ) + | Opt( config.outputFilename, "filename" ) + ["-o"]["--out"] + ( "output filename" ) + | Opt( config.reporterNames, "name" ) + ["-r"]["--reporter"] + ( "reporter to use (defaults to console)" ) + | Opt( config.name, "name" ) + ["-n"]["--name"] + ( "suite name" ) + | Opt( [&]( bool ){ config.abortAfter = 1; } ) + ["-a"]["--abort"] + ( "abort at first failure" ) + | Opt( [&]( int x ){ config.abortAfter = x; }, "no. failures" ) + ["-x"]["--abortx"] + ( "abort after x failures" ) + | Opt( setWarning, "warning name" ) + ["-w"]["--warn"] + ( "enable warnings" ) + | Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" ) + ["-d"]["--durations"] + ( "show test durations" ) + | Opt( loadTestNamesFromFile, "filename" ) + ["-f"]["--input-file"] + ( "load test names to run from a file" ) + | Opt( config.filenamesAsTags ) + ["-#"]["--filenames-as-tags"] + ( "adds a tag for the filename" ) + | Opt( config.sectionsToRun, "section name" ) + ["-c"]["--section"] + ( "specify section to run" ) + | Opt( setVerbosity, "quiet|normal|high" ) + ["-v"]["--verbosity"] + ( "set output verbosity" ) + | Opt( config.listTestNamesOnly ) + ["--list-test-names-only"] + ( "list all/matching test cases names only" ) + | Opt( config.listReporters ) + ["--list-reporters"] + ( "list all reporters" ) + | Opt( setTestOrder, "decl|lex|rand" ) + ["--order"] + ( "test case order (defaults to decl)" ) + | Opt( setRngSeed, "'time'|number" ) + ["--rng-seed"] + ( "set a specific seed for random numbers" ) + | Opt( setColourUsage, "yes|no" ) + ["--use-colour"] + ( "should output be colourised" ) + | Opt( config.libIdentify ) + ["--libidentify"] + ( "report name and version according to libidentify standard" ) + | Opt( setWaitForKeypress, "start|exit|both" ) + ["--wait-for-keypress"] + ( "waits for a keypress before exiting" ) + | Opt( config.benchmarkResolutionMultiple, "multiplier" ) + ["--benchmark-resolution-multiple"] + ( "multiple of clock resolution to run benchmarks" ) + + | Arg( config.testsOrTags, "test name|pattern|tags" ) + ( "which test or tests to use" ); + + return cli; + } + +} // end namespace Catch +// end catch_commandline.cpp +// start catch_common.cpp + +#include +#include + +namespace Catch { + + SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line ) noexcept + : file( _file ), + line( _line ) + {} + bool SourceLineInfo::empty() const noexcept { + return file[0] == '\0'; + } + bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { + return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); + } + bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept { + return line < other.line || ( line == other.line && (std::strcmp(file, other.file) < 0)); + } + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { +#ifndef __GNUG__ + os << info.file << '(' << info.line << ')'; +#else + os << info.file << ':' << info.line; +#endif + return os; + } + + bool isTrue( bool value ){ return value; } + bool alwaysTrue() { return true; } + bool alwaysFalse() { return false; } + + std::string StreamEndStop::operator+() const { + return std::string(); + } + + NonCopyable::NonCopyable() = default; + NonCopyable::~NonCopyable() = default; + +} +// end catch_common.cpp +// start catch_config.cpp + +namespace Catch { + + Config::Config( ConfigData const& data ) + : m_data( data ), + m_stream( openStream() ) + { + if( !data.testsOrTags.empty() ) { + TestSpecParser parser( ITagAliasRegistry::get() ); + for( auto const& testOrTags : data.testsOrTags ) + parser.parse( testOrTags ); + m_testSpec = parser.testSpec(); + } + } + + std::string const& Config::getFilename() const { + return m_data.outputFilename ; + } + + bool Config::listTests() const { return m_data.listTests; } + bool Config::listTestNamesOnly() const { return m_data.listTestNamesOnly; } + bool Config::listTags() const { return m_data.listTags; } + bool Config::listReporters() const { return m_data.listReporters; } + + std::string Config::getProcessName() const { return m_data.processName; } + + std::vector const& Config::getReporterNames() const { return m_data.reporterNames; } + std::vector const& Config::getSectionsToRun() const { return m_data.sectionsToRun; } + + TestSpec const& Config::testSpec() const { return m_testSpec; } + + bool Config::showHelp() const { return m_data.showHelp; } + + // IConfig interface + bool Config::allowThrows() const { return !m_data.noThrow; } + std::ostream& Config::stream() const { return m_stream->stream(); } + std::string Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } + bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; } + bool Config::warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; } + ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } + RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; } + unsigned int Config::rngSeed() const { return m_data.rngSeed; } + int Config::benchmarkResolutionMultiple() const { return m_data.benchmarkResolutionMultiple; } + UseColour::YesOrNo Config::useColour() const { return m_data.useColour; } + bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; } + int Config::abortAfter() const { return m_data.abortAfter; } + bool Config::showInvisibles() const { return m_data.showInvisibles; } + Verbosity Config::verbosity() const { return m_data.verbosity; } + + IStream const* Config::openStream() { + if( m_data.outputFilename.empty() ) + return new CoutStream(); + else if( m_data.outputFilename[0] == '%' ) { + if( m_data.outputFilename == "%debug" ) + return new DebugOutStream(); + else + CATCH_ERROR( "Unrecognised stream: '" << m_data.outputFilename << "'" ); + } + else + return new FileStream( m_data.outputFilename ); + } + +} // end namespace Catch +// end catch_config.cpp +// start catch_console_colour.cpp + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +// start catch_errno_guard.h + +namespace Catch { + + class ErrnoGuard { + public: + ErrnoGuard(); + ~ErrnoGuard(); + private: + int m_oldErrno; + }; + +} + +// end catch_errno_guard.h +// start catch_windows_h_proxy.h + + +#if defined(CATCH_PLATFORM_WINDOWS) + +#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX) +# define CATCH_DEFINED_NOMINMAX +# define NOMINMAX +#endif +#if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN) +# define CATCH_DEFINED_WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif + +#ifdef __AFXDLL +#include +#else +#include +#endif + +#ifdef CATCH_DEFINED_NOMINMAX +# undef NOMINMAX +#endif +#ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN +# undef WIN32_LEAN_AND_MEAN +#endif + +#endif // defined(CATCH_PLATFORM_WINDOWS) + +// end catch_windows_h_proxy.h +namespace Catch { + namespace { + + struct IColourImpl { + virtual ~IColourImpl() = default; + virtual void use( Colour::Code _colourCode ) = 0; + }; + + struct NoColourImpl : IColourImpl { + void use( Colour::Code ) {} + + static IColourImpl* instance() { + static NoColourImpl s_instance; + return &s_instance; + } + }; + + } // anon namespace +} // namespace Catch + +#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI ) +# ifdef CATCH_PLATFORM_WINDOWS +# define CATCH_CONFIG_COLOUR_WINDOWS +# else +# define CATCH_CONFIG_COLOUR_ANSI +# endif +#endif + +#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// + +namespace Catch { +namespace { + + class Win32ColourImpl : public IColourImpl { + public: + Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) ) + { + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); + originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY ); + originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY ); + } + + virtual void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: return setTextAttribute( originalForegroundAttributes ); + case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + case Colour::Red: return setTextAttribute( FOREGROUND_RED ); + case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); + case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE ); + case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN ); + case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN ); + case Colour::Grey: return setTextAttribute( 0 ); + + case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY ); + case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED ); + case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN ); + case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + } + } + + private: + void setTextAttribute( WORD _textAttribute ) { + SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes ); + } + HANDLE stdoutHandle; + WORD originalForegroundAttributes; + WORD originalBackgroundAttributes; + }; + + IColourImpl* platformColourInstance() { + static Win32ColourImpl s_instance; + + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = UseColour::Yes; + return colourMode == UseColour::Yes + ? &s_instance + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#elif defined( CATCH_CONFIG_COLOUR_ANSI ) ////////////////////////////////////// + +#include + +namespace Catch { +namespace { + + // use POSIX/ ANSI console terminal codes + // Thanks to Adam Strzelecki for original contribution + // (http://github.com/nanoant) + // https://github.com/philsquared/Catch/pull/131 + class PosixColourImpl : public IColourImpl { + public: + virtual void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: + case Colour::White: return setColour( "[0m" ); + case Colour::Red: return setColour( "[0;31m" ); + case Colour::Green: return setColour( "[0;32m" ); + case Colour::Blue: return setColour( "[0;34m" ); + case Colour::Cyan: return setColour( "[0;36m" ); + case Colour::Yellow: return setColour( "[0;33m" ); + case Colour::Grey: return setColour( "[1;30m" ); + + case Colour::LightGrey: return setColour( "[0;37m" ); + case Colour::BrightRed: return setColour( "[1;31m" ); + case Colour::BrightGreen: return setColour( "[1;32m" ); + case Colour::BrightWhite: return setColour( "[1;37m" ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + } + } + static IColourImpl* instance() { + static PosixColourImpl s_instance; + return &s_instance; + } + + private: + void setColour( const char* _escapeCode ) { + Catch::cout() << '\033' << _escapeCode; + } + }; + + bool useColourOnPlatform() { + return +#ifdef CATCH_PLATFORM_MAC + !isDebuggerActive() && +#endif + isatty(STDOUT_FILENO); + } + IColourImpl* platformColourInstance() { + ErrnoGuard guard; + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = useColourOnPlatform() + ? UseColour::Yes + : UseColour::No; + return colourMode == UseColour::Yes + ? PosixColourImpl::instance() + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#else // not Windows or ANSI /////////////////////////////////////////////// + +namespace Catch { + + static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); } + +} // end namespace Catch + +#endif // Windows/ ANSI/ None + +namespace Catch { + + Colour::Colour( Code _colourCode ) { use( _colourCode ); } + Colour::Colour( Colour&& rhs ) noexcept { + m_moved = rhs.m_moved; + rhs.m_moved = true; + } + Colour& Colour::operator=( Colour&& rhs ) noexcept { + m_moved = rhs.m_moved; + rhs.m_moved = true; + return *this; + } + + Colour::~Colour(){ if( !m_moved ) use( None ); } + + void Colour::use( Code _colourCode ) { + static IColourImpl* impl = platformColourInstance(); + impl->use( _colourCode ); + } + + std::ostream& operator << ( std::ostream& os, Colour const& ) { + return os; + } + +} // end namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + +// end catch_console_colour.cpp +// start catch_context.cpp + +namespace Catch { + + class Context : public IMutableContext, NonCopyable { + + public: // IContext + virtual IResultCapture* getResultCapture() override { + return m_resultCapture; + } + virtual IRunner* getRunner() override { + return m_runner; + } + + virtual IConfigPtr getConfig() const override { + return m_config; + } + + virtual ~Context() override; + + public: // IMutableContext + virtual void setResultCapture( IResultCapture* resultCapture ) override { + m_resultCapture = resultCapture; + } + virtual void setRunner( IRunner* runner ) override { + m_runner = runner; + } + virtual void setConfig( IConfigPtr const& config ) override { + m_config = config; + } + + friend IMutableContext& getCurrentMutableContext(); + + private: + IConfigPtr m_config; + IRunner* m_runner = nullptr; + IResultCapture* m_resultCapture = nullptr; + }; + + namespace { + Context* currentContext = nullptr; + } + IMutableContext& getCurrentMutableContext() { + if( !currentContext ) + currentContext = new Context(); + return *currentContext; + } + IContext& getCurrentContext() { + return getCurrentMutableContext(); + } + + void cleanUpContext() { + delete currentContext; + currentContext = nullptr; + } + IContext::~IContext() = default; + IMutableContext::~IMutableContext() = default; + Context::~Context() = default; +} +// end catch_context.cpp +// start catch_debug_console.cpp + +// start catch_debug_console.h + +#include + +namespace Catch { + void writeToDebugConsole( std::string const& text ); +} + +// end catch_debug_console.h +#ifdef CATCH_PLATFORM_WINDOWS + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + ::OutputDebugStringA( text.c_str() ); + } + } +#else + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + // !TBD: Need a version for Mac/ XCode and other IDEs + Catch::cout() << text; + } + } +#endif // Platform +// end catch_debug_console.cpp +// start catch_debugger.cpp + +#ifdef CATCH_PLATFORM_MAC + + #include + #include + #include + #include + #include + + namespace Catch { + + // The following function is taken directly from the following technical note: + // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html + + // Returns true if the current process is being debugged (either + // running under the debugger or has a debugger attached post facto). + bool isDebuggerActive(){ + + int mib[4]; + struct kinfo_proc info; + std::size_t size; + + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + + info.kp_proc.p_flag = 0; + + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + + // Call sysctl. + + size = sizeof(info); + if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) { + Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; + return false; + } + + // We're being debugged if the P_TRACED flag is set. + + return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); + } + } // namespace Catch + +#elif defined(CATCH_PLATFORM_LINUX) + #include + #include + + namespace Catch{ + // The standard POSIX way of detecting a debugger is to attempt to + // ptrace() the process, but this needs to be done from a child and not + // this process itself to still allow attaching to this process later + // if wanted, so is rather heavy. Under Linux we have the PID of the + // "debugger" (which doesn't need to be gdb, of course, it could also + // be strace, for example) in /proc/$PID/status, so just get it from + // there instead. + bool isDebuggerActive(){ + // Libstdc++ has a bug, where std::ifstream sets errno to 0 + // This way our users can properly assert over errno values + ErrnoGuard guard; + std::ifstream in("/proc/self/status"); + for( std::string line; std::getline(in, line); ) { + static const int PREFIX_LEN = 11; + if( line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0 ) { + // We're traced if the PID is not 0 and no other PID starts + // with 0 digit, so it's enough to check for just a single + // character. + return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0'; + } + } + + return false; + } + } // namespace Catch +#elif defined(_MSC_VER) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#else + namespace Catch { + bool isDebuggerActive() { return false; } + } +#endif // Platform +// end catch_debugger.cpp +// start catch_decomposer.cpp + +namespace Catch { + + ITransientExpression::~ITransientExpression() = default; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { + if( lhs.size() + rhs.size() < 40 && + lhs.find('\n') == std::string::npos && + rhs.find('\n') == std::string::npos ) + os << lhs << " " << op << " " << rhs; + else + os << lhs << "\n" << op << "\n" << rhs; + } +} +// end catch_decomposer.cpp +// start catch_errno_guard.cpp + +#include + +namespace Catch { + ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} + ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } +} +// end catch_errno_guard.cpp +// start catch_exception_translator_registry.cpp + +// start catch_exception_translator_registry.h + +#include +#include +#include + +namespace Catch { + + class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { + public: + ~ExceptionTranslatorRegistry(); + virtual void registerTranslator( const IExceptionTranslator* translator ); + virtual std::string translateActiveException() const override; + std::string tryTranslators() const; + + private: + std::vector> m_translators; + }; +} + +// end catch_exception_translator_registry.h +#ifdef __OBJC__ +#import "Foundation/Foundation.h" +#endif + +namespace Catch { + + ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { + } + + void ExceptionTranslatorRegistry::registerTranslator( const IExceptionTranslator* translator ) { + m_translators.push_back( std::unique_ptr( translator ) ); + } + + std::string ExceptionTranslatorRegistry::translateActiveException() const { + try { +#ifdef __OBJC__ + // In Objective-C try objective-c exceptions first + @try { + return tryTranslators(); + } + @catch (NSException *exception) { + return Catch::Detail::stringify( [exception description] ); + } +#else + return tryTranslators(); +#endif + } + catch( TestFailureException& ) { + std::rethrow_exception(std::current_exception()); + } + catch( std::exception& ex ) { + return ex.what(); + } + catch( std::string& msg ) { + return msg; + } + catch( const char* msg ) { + return msg; + } + catch(...) { + return "Unknown exception"; + } + } + + std::string ExceptionTranslatorRegistry::tryTranslators() const { + if( m_translators.empty() ) + std::rethrow_exception(std::current_exception()); + else + return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() ); + } +} +// end catch_exception_translator_registry.cpp +// start catch_fatal_condition.cpp + +// start catch_fatal_condition.h + +#include + +#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// + +# if !defined ( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + struct FatalConditionHandler { + void reset(); + }; +} + +# else // CATCH_CONFIG_WINDOWS_SEH is defined + +namespace Catch { + + struct FatalConditionHandler { + + static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo); + FatalConditionHandler(); + static void reset(); + ~FatalConditionHandler(); + + private: + static bool isSet; + static ULONG guaranteeSize; + static PVOID exceptionHandlerHandle; + }; + +} // namespace Catch + +# endif // CATCH_CONFIG_WINDOWS_SEH + +#else // Not Windows - assumed to be POSIX compatible ////////////////////////// + +# if !defined(CATCH_CONFIG_POSIX_SIGNALS) + +namespace Catch { + struct FatalConditionHandler { + void reset(); + }; +} + +# else // CATCH_CONFIG_POSIX_SIGNALS is defined + +#include + +namespace Catch { + + struct FatalConditionHandler { + + static bool isSet; + static struct sigaction oldSigActions[];// [sizeof(signalDefs) / sizeof(SignalDefs)]; + static stack_t oldSigStack; + static char altStackMem[]; + + static void handleSignal( int sig ); + + FatalConditionHandler(); + ~FatalConditionHandler(); + static void reset(); + }; + +} // namespace Catch + +# endif // CATCH_CONFIG_POSIX_SIGNALS + +#endif // not Windows + +// end catch_fatal_condition.h +namespace { + // Report the error condition + void reportFatal( char const * const message ) { + Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message ); + } +} + +#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// + +# if !defined ( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + void FatalConditionHandler::reset() {} +} + +# else // CATCH_CONFIG_WINDOWS_SEH is defined + +namespace Catch { + struct SignalDefs { DWORD id; const char* name; }; + + // There is no 1-1 mapping between signals and windows exceptions. + // Windows can easily distinguish between SO and SigSegV, + // but SigInt, SigTerm, etc are handled differently. + static SignalDefs signalDefs[] = { + { EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" }, + { EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" }, + { EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" }, + { EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" }, + }; + + LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { + for (auto const& def : signalDefs) { + if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) { + reportFatal(def.name); + } + } + // If its not an exception we care about, pass it along. + // This stops us from eating debugger breaks etc. + return EXCEPTION_CONTINUE_SEARCH; + } + + FatalConditionHandler::FatalConditionHandler() { + isSet = true; + // 32k seems enough for Catch to handle stack overflow, + // but the value was found experimentally, so there is no strong guarantee + guaranteeSize = 32 * 1024; + exceptionHandlerHandle = nullptr; + // Register as first handler in current chain + exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); + // Pass in guarantee size to be filled + SetThreadStackGuarantee(&guaranteeSize); + } + + void FatalConditionHandler::reset() { + if (isSet) { + // Unregister handler and restore the old guarantee + RemoveVectoredExceptionHandler(exceptionHandlerHandle); + SetThreadStackGuarantee(&guaranteeSize); + exceptionHandlerHandle = nullptr; + isSet = false; + } + } + + FatalConditionHandler::~FatalConditionHandler() { + reset(); + } + +bool FatalConditionHandler::isSet = false; +ULONG FatalConditionHandler::guaranteeSize = 0; +PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr; + +} // namespace Catch + +# endif // CATCH_CONFIG_WINDOWS_SEH + +#else // Not Windows - assumed to be POSIX compatible ////////////////////////// + +# if !defined(CATCH_CONFIG_POSIX_SIGNALS) + +namespace Catch { + void FatalConditionHandler::reset() {} +} + +# else // CATCH_CONFIG_POSIX_SIGNALS is defined + +#include + +namespace Catch { + + struct SignalDefs { + int id; + const char* name; + }; + static SignalDefs signalDefs[] = { + { SIGINT, "SIGINT - Terminal interrupt signal" }, + { SIGILL, "SIGILL - Illegal instruction signal" }, + { SIGFPE, "SIGFPE - Floating point error signal" }, + { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, + { SIGTERM, "SIGTERM - Termination request signal" }, + { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } + }; + + void FatalConditionHandler::handleSignal( int sig ) { + char const * name = ""; + for (auto const& def : signalDefs) { + if (sig == def.id) { + name = def.name; + break; + } + } + reset(); + reportFatal(name); + raise( sig ); + } + + FatalConditionHandler::FatalConditionHandler() { + isSet = true; + stack_t sigStack; + sigStack.ss_sp = altStackMem; + sigStack.ss_size = SIGSTKSZ; + sigStack.ss_flags = 0; + sigaltstack(&sigStack, &oldSigStack); + struct sigaction sa = { }; + + sa.sa_handler = handleSignal; + sa.sa_flags = SA_ONSTACK; + for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); + } + } + + FatalConditionHandler::~FatalConditionHandler() { + reset(); + } + + void FatalConditionHandler::reset() { + if( isSet ) { + // Set signals back to previous values -- hopefully nobody overwrote them in the meantime + for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { + sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); + } + // Return the old stack + sigaltstack(&oldSigStack, nullptr); + isSet = false; + } + } + + bool FatalConditionHandler::isSet = false; + struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; + stack_t FatalConditionHandler::oldSigStack = {}; + char FatalConditionHandler::altStackMem[SIGSTKSZ] = {}; + +} // namespace Catch + +# endif // CATCH_CONFIG_POSIX_SIGNALS + +#endif // not Windows +// end catch_fatal_condition.cpp +// start catch_interfaces_capture.cpp + +namespace Catch { + IResultCapture::~IResultCapture() = default; +} +// end catch_interfaces_capture.cpp +// start catch_interfaces_config.cpp + +namespace Catch { + IConfig::~IConfig() = default; +} +// end catch_interfaces_config.cpp +// start catch_interfaces_exception.cpp + +namespace Catch { + IExceptionTranslator::~IExceptionTranslator() = default; + IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; +} +// end catch_interfaces_exception.cpp +// start catch_interfaces_registry_hub.cpp + +namespace Catch { + IRegistryHub::~IRegistryHub() = default; + IMutableRegistryHub::~IMutableRegistryHub() = default; +} +// end catch_interfaces_registry_hub.cpp +// start catch_interfaces_reporter.cpp + +// start catch_reporter_multi.h + +namespace Catch { + + class MultipleReporters : public IStreamingReporter { + using Reporters = std::vector; + Reporters m_reporters; + + public: + void add( IStreamingReporterPtr&& reporter ); + + public: // IStreamingReporter + + ReporterPreferences getPreferences() const override; + + void noMatchingTestCases( std::string const& spec ) override; + + static std::set getSupportedVerbosities(); + + void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override; + void benchmarkEnded( BenchmarkStats const& benchmarkStats ) override; + + void testRunStarting( TestRunInfo const& testRunInfo ) override; + void testGroupStarting( GroupInfo const& groupInfo ) override; + void testCaseStarting( TestCaseInfo const& testInfo ) override; + void sectionStarting( SectionInfo const& sectionInfo ) override; + void assertionStarting( AssertionInfo const& assertionInfo ) override; + + // The return value indicates if the messages buffer should be cleared: + bool assertionEnded( AssertionStats const& assertionStats ) override; + void sectionEnded( SectionStats const& sectionStats ) override; + void testCaseEnded( TestCaseStats const& testCaseStats ) override; + void testGroupEnded( TestGroupStats const& testGroupStats ) override; + void testRunEnded( TestRunStats const& testRunStats ) override; + + void skipTest( TestCaseInfo const& testInfo ) override; + bool isMulti() const override; + + }; + +} // end namespace Catch + +// end catch_reporter_multi.h +namespace Catch { + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig ) + : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ) + : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} + + std::ostream& ReporterConfig::stream() const { return *m_stream; } + IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; } + + TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {} + + GroupInfo::GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ) + : name( _name ), + groupIndex( _groupIndex ), + groupsCounts( _groupsCount ) + {} + + AssertionStats::AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ) + : assertionResult( _assertionResult ), + infoMessages( _infoMessages ), + totals( _totals ) + { + assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression; + + if( assertionResult.hasMessage() ) { + // Copy message into messages list. + // !TBD This should have been done earlier, somewhere + MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); + builder << assertionResult.getMessage(); + builder.m_info.message = builder.m_stream.str(); + + infoMessages.push_back( builder.m_info ); + } + } + + AssertionStats::~AssertionStats() = default; + + SectionStats::SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ) + : sectionInfo( _sectionInfo ), + assertions( _assertions ), + durationInSeconds( _durationInSeconds ), + missingAssertions( _missingAssertions ) + {} + + SectionStats::~SectionStats() = default; + + TestCaseStats::TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ) + : testInfo( _testInfo ), + totals( _totals ), + stdOut( _stdOut ), + stdErr( _stdErr ), + aborting( _aborting ) + {} + + TestCaseStats::~TestCaseStats() = default; + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ) + : groupInfo( _groupInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo ) + : groupInfo( _groupInfo ), + aborting( false ) + {} + + TestGroupStats::~TestGroupStats() = default; + + TestRunStats::TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ) + : runInfo( _runInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestRunStats::~TestRunStats() = default; + + void IStreamingReporter::fatalErrorEncountered( StringRef ) {} + bool IStreamingReporter::isMulti() const { return false; } + + IReporterFactory::~IReporterFactory() = default; + IReporterRegistry::~IReporterRegistry() = default; + + void addReporter( IStreamingReporterPtr& existingReporter, IStreamingReporterPtr&& additionalReporter ) { + + if( !existingReporter ) { + existingReporter = std::move( additionalReporter ); + return; + } + + MultipleReporters* multi = nullptr; + + if( existingReporter->isMulti() ) { + multi = static_cast( existingReporter.get() ); + } + else { + auto newMulti = std::unique_ptr( new MultipleReporters ); + newMulti->add( std::move( existingReporter ) ); + multi = newMulti.get(); + existingReporter = std::move( newMulti ); + } + multi->add( std::move( additionalReporter ) ); + } + +} // end namespace Catch +// end catch_interfaces_reporter.cpp +// start catch_interfaces_runner.cpp + +namespace Catch { + IRunner::~IRunner() = default; +} +// end catch_interfaces_runner.cpp +// start catch_interfaces_testcase.cpp + +namespace Catch { + ITestInvoker::~ITestInvoker() = default; + ITestCaseRegistry::~ITestCaseRegistry() = default; +} +// end catch_interfaces_testcase.cpp +// start catch_leak_detector.cpp + +namespace Catch { + +#ifdef CATCH_CONFIG_WINDOWS_CRTDBG +#include + + LeakDetector::LeakDetector() { + int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + flag |= _CRTDBG_LEAK_CHECK_DF; + flag |= _CRTDBG_ALLOC_MEM_DF; + _CrtSetDbgFlag(flag); + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + // Change this to leaking allocation's number to break there + _CrtSetBreakAlloc(-1); + } + +#else + + LeakDetector::LeakDetector(){} + +#endif + +} +// end catch_leak_detector.cpp +// start catch_list.cpp + +// start catch_list.h + +#include + +namespace Catch { + + std::size_t listTests( Config const& config ); + + std::size_t listTestsNamesOnly( Config const& config ); + + struct TagInfo { + void add( std::string const& spelling ); + std::string all() const; + + std::set spellings; + std::size_t count = 0; + }; + + std::size_t listTags( Config const& config ); + + std::size_t listReporters( Config const& /*config*/ ); + + Option list( Config const& config ); + +} // end namespace Catch + +// end catch_list.h +// start catch_text.h + +namespace Catch { + using namespace clara::TextFlow; +} + +// end catch_text.h +#include +#include +#include + +namespace Catch { + + std::size_t listTests( Config const& config ) { + TestSpec testSpec = config.testSpec(); + if( config.testSpec().hasFilters() ) + Catch::cout() << "Matching test cases:\n"; + else { + Catch::cout() << "All available test cases:\n"; + testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); + } + + auto matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + Colour::Code colour = testCaseInfo.isHidden() + ? Colour::SecondaryText + : Colour::None; + Colour colourGuard( colour ); + + Catch::cout() << Column( testCaseInfo.name ).initialIndent( 2 ).indent( 4 ) << "\n"; + if( config.verbosity() >= Verbosity::High ) { + Catch::cout() << Column( Catch::Detail::stringify( testCaseInfo.lineInfo ) ).indent(4) << std::endl; + std::string description = testCaseInfo.description; + if( description.empty() ) + description = "(NO DESCRIPTION)"; + Catch::cout() << Column( description ).indent(4) << std::endl; + } + if( !testCaseInfo.tags.empty() ) + Catch::cout() << Column( testCaseInfo.tagsAsString() ).indent( 6 ) << "\n"; + } + + if( !config.testSpec().hasFilters() ) + Catch::cout() << pluralise( matchedTestCases.size(), "test case" ) << '\n' << std::endl; + else + Catch::cout() << pluralise( matchedTestCases.size(), "matching test case" ) << '\n' << std::endl; + return matchedTestCases.size(); + } + + std::size_t listTestsNamesOnly( Config const& config ) { + TestSpec testSpec = config.testSpec(); + if( !config.testSpec().hasFilters() ) + testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); + std::size_t matchedTests = 0; + std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + matchedTests++; + if( startsWith( testCaseInfo.name, '#' ) ) + Catch::cout() << '"' << testCaseInfo.name << '"'; + else + Catch::cout() << testCaseInfo.name; + if ( config.verbosity() >= Verbosity::High ) + Catch::cout() << "\t@" << testCaseInfo.lineInfo; + Catch::cout() << std::endl; + } + return matchedTests; + } + + void TagInfo::add( std::string const& spelling ) { + ++count; + spellings.insert( spelling ); + } + + std::string TagInfo::all() const { + std::string out; + for( auto const& spelling : spellings ) + out += "[" + spelling + "]"; + return out; + } + + std::size_t listTags( Config const& config ) { + TestSpec testSpec = config.testSpec(); + if( config.testSpec().hasFilters() ) + Catch::cout() << "Tags for matching test cases:\n"; + else { + Catch::cout() << "All available tags:\n"; + testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); + } + + std::map tagCounts; + + std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCase : matchedTestCases ) { + for( auto const& tagName : testCase.getTestCaseInfo().tags ) { + std::string lcaseTagName = toLower( tagName ); + auto countIt = tagCounts.find( lcaseTagName ); + if( countIt == tagCounts.end() ) + countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first; + countIt->second.add( tagName ); + } + } + + for( auto const& tagCount : tagCounts ) { + std::ostringstream oss; + oss << " " << std::setw(2) << tagCount.second.count << " "; + auto wrapper = Column( tagCount.second.all() ) + .initialIndent( 0 ) + .indent( oss.str().size() ) + .width( CATCH_CONFIG_CONSOLE_WIDTH-10 ); + Catch::cout() << oss.str() << wrapper << '\n'; + } + Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl; + return tagCounts.size(); + } + + std::size_t listReporters( Config const& /*config*/ ) { + Catch::cout() << "Available reporters:\n"; + IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); + std::size_t maxNameLen = 0; + for( auto const& factoryKvp : factories ) + maxNameLen = (std::max)( maxNameLen, factoryKvp.first.size() ); + + for( auto const& factoryKvp : factories ) { + Catch::cout() + << Column( factoryKvp.first + ":" ) + .indent(2) + .width( 5+maxNameLen ) + + Column( factoryKvp.second->getDescription() ) + .initialIndent(0) + .indent(2) + .width( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) + << "\n"; + } + Catch::cout() << std::endl; + return factories.size(); + } + + Option list( Config const& config ) { + Option listedCount; + if( config.listTests() ) + listedCount = listedCount.valueOr(0) + listTests( config ); + if( config.listTestNamesOnly() ) + listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config ); + if( config.listTags() ) + listedCount = listedCount.valueOr(0) + listTags( config ); + if( config.listReporters() ) + listedCount = listedCount.valueOr(0) + listReporters( config ); + return listedCount; + } + +} // end namespace Catch +// end catch_list.cpp +// start catch_matchers.cpp + +namespace Catch { +namespace Matchers { + namespace Impl { + + std::string MatcherUntypedBase::toString() const { + if( m_cachedToString.empty() ) + m_cachedToString = describe(); + return m_cachedToString; + } + + MatcherUntypedBase::~MatcherUntypedBase() = default; + + } // namespace Impl +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch +// end catch_matchers.cpp +// start catch_matchers_string.cpp + +namespace Catch { +namespace Matchers { + + namespace StdString { + + CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ) + : m_caseSensitivity( caseSensitivity ), + m_str( adjustString( str ) ) + {} + std::string CasedString::adjustString( std::string const& str ) const { + return m_caseSensitivity == CaseSensitive::No + ? toLower( str ) + : str; + } + std::string CasedString::caseSensitivitySuffix() const { + return m_caseSensitivity == CaseSensitive::No + ? " (case insensitive)" + : std::string(); + } + + StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator ) + : m_comparator( comparator ), + m_operation( operation ) { + } + + std::string StringMatcherBase::describe() const { + std::string description; + description.reserve(5 + m_operation.size() + m_comparator.m_str.size() + + m_comparator.caseSensitivitySuffix().size()); + description += m_operation; + description += ": \""; + description += m_comparator.m_str; + description += "\""; + description += m_comparator.caseSensitivitySuffix(); + return description; + } + + EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {} + + bool EqualsMatcher::match( std::string const& source ) const { + return m_comparator.adjustString( source ) == m_comparator.m_str; + } + + ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {} + + bool ContainsMatcher::match( std::string const& source ) const { + return contains( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {} + + bool StartsWithMatcher::match( std::string const& source ) const { + return startsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {} + + bool EndsWithMatcher::match( std::string const& source ) const { + return endsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + } // namespace StdString + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + +} // namespace Matchers +} // namespace Catch +// end catch_matchers_string.cpp +// start catch_message.cpp + +namespace Catch { + + MessageInfo::MessageInfo( std::string const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + type( _type ), + sequence( ++globalCount ) + {} + + bool MessageInfo::operator==( MessageInfo const& other ) const { + return sequence == other.sequence; + } + + bool MessageInfo::operator<( MessageInfo const& other ) const { + return sequence < other.sequence; + } + + // This may need protecting if threading support is added + unsigned int MessageInfo::globalCount = 0; + + //////////////////////////////////////////////////////////////////////////// + + Catch::MessageBuilder::MessageBuilder( std::string const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ) + :m_info(macroName, lineInfo, type) {} + + //////////////////////////////////////////////////////////////////////////// + + ScopedMessage::ScopedMessage( MessageBuilder const& builder ) + : m_info( builder.m_info ) + { + m_info.message = builder.m_stream.str(); + getResultCapture().pushScopedMessage( m_info ); + } + + ScopedMessage::~ScopedMessage() { + if ( !std::uncaught_exception() ){ + getResultCapture().popScopedMessage(m_info); + } + } + +} // end namespace Catch +// end catch_message.cpp +// start catch_random_number_generator.cpp + +// start catch_random_number_generator.h + +#include + +namespace Catch { + + struct IConfig; + + void seedRng( IConfig const& config ); + + unsigned int rngSeed(); + + struct RandomNumberGenerator { + using result_type = unsigned int; + + static constexpr result_type (min)() { return 0; } + static constexpr result_type (max)() { return 1000000; } + + result_type operator()( result_type n ) const; + result_type operator()() const; + + template + static void shuffle( V& vector ) { + RandomNumberGenerator rng; + std::shuffle( vector.begin(), vector.end(), rng ); + } + }; + +} + +// end catch_random_number_generator.h +#include + +namespace Catch { + + void seedRng( IConfig const& config ) { + if( config.rngSeed() != 0 ) + std::srand( config.rngSeed() ); + } + unsigned int rngSeed() { + return getCurrentContext().getConfig()->rngSeed(); + } + + RandomNumberGenerator::result_type RandomNumberGenerator::operator()( result_type n ) const { + return std::rand() % n; + } + RandomNumberGenerator::result_type RandomNumberGenerator::operator()() const { + return std::rand() % (max)(); + } + +} +// end catch_random_number_generator.cpp +// start catch_registry_hub.cpp + +// start catch_test_case_registry_impl.h + +#include +#include +#include +#include + +namespace Catch { + + class TestCase; + struct IConfig; + + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ); + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + + void enforceNoDuplicateTestCases( std::vector const& functions ); + + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector const& getAllTestCasesSorted( IConfig const& config ); + + class TestRegistry : public ITestCaseRegistry { + public: + virtual ~TestRegistry() = default; + + virtual void registerTest( TestCase const& testCase ); + + std::vector const& getAllTests() const override; + std::vector const& getAllTestsSorted( IConfig const& config ) const override; + + private: + std::vector m_functions; + mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder; + mutable std::vector m_sortedFunctions; + std::size_t m_unnamedCount = 0; + std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised + }; + + /////////////////////////////////////////////////////////////////////////// + + class TestInvokerAsFunction : public ITestInvoker { + void(*m_testAsFunction)(); + public: + TestInvokerAsFunction( void(*testAsFunction)() ) noexcept; + + void invoke() const override; + }; + + std::string extractClassName( std::string const& classOrQualifiedMethodName ); + + /////////////////////////////////////////////////////////////////////////// + +} // end namespace Catch + +// end catch_test_case_registry_impl.h +// start catch_reporter_registry.h + +#include + +namespace Catch { + + class ReporterRegistry : public IReporterRegistry { + + public: + + ~ReporterRegistry() override; + + IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override; + + void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ); + void registerListener( IReporterFactoryPtr const& factory ); + + FactoryMap const& getFactories() const override; + Listeners const& getListeners() const override; + + private: + FactoryMap m_factories; + Listeners m_listeners; + }; +} + +// end catch_reporter_registry.h +// start catch_tag_alias_registry.h + +// start catch_tag_alias.h + +#include + +namespace Catch { + + struct TagAlias { + TagAlias(std::string const& _tag, SourceLineInfo _lineInfo); + + std::string tag; + SourceLineInfo lineInfo; + }; + +} // end namespace Catch + +// end catch_tag_alias.h +#include + +namespace Catch { + + class TagAliasRegistry : public ITagAliasRegistry { + public: + ~TagAliasRegistry() override; + TagAlias const* find( std::string const& alias ) const override; + std::string expandAliases( std::string const& unexpandedTestSpec ) const override; + void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ); + + private: + std::map m_registry; + }; + +} // end namespace Catch + +// end catch_tag_alias_registry.h +// start catch_startup_exception_registry.h + +#include +#include + +namespace Catch { + + class StartupExceptionRegistry { + public: + void add(std::exception_ptr const& exception) noexcept; + std::vector const& getExceptions() const noexcept; + private: + std::vector m_exceptions; + }; + +} // end namespace Catch + +// end catch_startup_exception_registry.h +namespace Catch { + + namespace { + + class RegistryHub : public IRegistryHub, public IMutableRegistryHub, + private NonCopyable { + + public: // IRegistryHub + RegistryHub() = default; + IReporterRegistry const& getReporterRegistry() const override { + return m_reporterRegistry; + } + ITestCaseRegistry const& getTestCaseRegistry() const override { + return m_testCaseRegistry; + } + IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() override { + return m_exceptionTranslatorRegistry; + } + ITagAliasRegistry const& getTagAliasRegistry() const override { + return m_tagAliasRegistry; + } + StartupExceptionRegistry const& getStartupExceptionRegistry() const override { + return m_exceptionRegistry; + } + + public: // IMutableRegistryHub + void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) override { + m_reporterRegistry.registerReporter( name, factory ); + } + void registerListener( IReporterFactoryPtr const& factory ) override { + m_reporterRegistry.registerListener( factory ); + } + void registerTest( TestCase const& testInfo ) override { + m_testCaseRegistry.registerTest( testInfo ); + } + void registerTranslator( const IExceptionTranslator* translator ) override { + m_exceptionTranslatorRegistry.registerTranslator( translator ); + } + void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override { + m_tagAliasRegistry.add( alias, tag, lineInfo ); + } + void registerStartupException() noexcept override { + m_exceptionRegistry.add(std::current_exception()); + } + + private: + TestRegistry m_testCaseRegistry; + ReporterRegistry m_reporterRegistry; + ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; + TagAliasRegistry m_tagAliasRegistry; + StartupExceptionRegistry m_exceptionRegistry; + }; + + // Single, global, instance + RegistryHub*& getTheRegistryHub() { + static RegistryHub* theRegistryHub = nullptr; + if( !theRegistryHub ) + theRegistryHub = new RegistryHub(); + return theRegistryHub; + } + } + + IRegistryHub& getRegistryHub() { + return *getTheRegistryHub(); + } + IMutableRegistryHub& getMutableRegistryHub() { + return *getTheRegistryHub(); + } + void cleanUp() { + delete getTheRegistryHub(); + getTheRegistryHub() = nullptr; + cleanUpContext(); + } + std::string translateActiveException() { + return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException(); + } + +} // end namespace Catch +// end catch_registry_hub.cpp +// start catch_reporter_registry.cpp + +namespace Catch { + + ReporterRegistry::~ReporterRegistry() = default; + + IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const { + auto it = m_factories.find( name ); + if( it == m_factories.end() ) + return nullptr; + return it->second->create( ReporterConfig( config ) ); + } + + void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) { + m_factories.emplace(name, factory); + } + void ReporterRegistry::registerListener( IReporterFactoryPtr const& factory ) { + m_listeners.push_back( factory ); + } + + IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const { + return m_factories; + } + IReporterRegistry::Listeners const& ReporterRegistry::getListeners() const { + return m_listeners; + } + +} +// end catch_reporter_registry.cpp +// start catch_result_type.cpp + +namespace Catch { + + bool isOk( ResultWas::OfType resultType ) { + return ( resultType & ResultWas::FailureBit ) == 0; + } + bool isJustInfo( int flags ) { + return flags == ResultWas::Info; + } + + ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { + return static_cast( static_cast( lhs ) | static_cast( rhs ) ); + } + + bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } + bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } + bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } + +} // end namespace Catch +// end catch_result_type.cpp +// start catch_run_context.cpp +// start catch_run_context.h + +#include + +namespace Catch { + + struct IMutableContext; + + class StreamRedirect { + + public: + StreamRedirect(std::ostream& stream, std::string& targetString); + + ~StreamRedirect(); + + private: + std::ostream& m_stream; + std::streambuf* m_prevBuf; + std::ostringstream m_oss; + std::string& m_targetString; + }; + + // StdErr has two constituent streams in C++, std::cerr and std::clog + // This means that we need to redirect 2 streams into 1 to keep proper + // order of writes and cannot use StreamRedirect on its own + class StdErrRedirect { + public: + StdErrRedirect(std::string& targetString); + ~StdErrRedirect(); + private: + std::streambuf* m_cerrBuf; + std::streambuf* m_clogBuf; + std::ostringstream m_oss; + std::string& m_targetString; + }; + + /////////////////////////////////////////////////////////////////////////// + + class RunContext : public IResultCapture, public IRunner { + + public: + RunContext( RunContext const& ) = delete; + RunContext& operator =( RunContext const& ) = delete; + + explicit RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter); + + virtual ~RunContext(); + + void testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount); + void testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount); + + Totals runTest(TestCase const& testCase); + + IConfigPtr config() const; + IStreamingReporter& reporter() const; + + private: // IResultCapture + + void assertionStarting(AssertionInfo const& info) override; + void assertionEnded(AssertionResult const& result) override; + + bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override; + bool testForMissingAssertions(Counts& assertions); + + void sectionEnded(SectionEndInfo const& endInfo) override; + void sectionEndedEarly(SectionEndInfo const& endInfo) override; + + void benchmarkStarting( BenchmarkInfo const& info ) override; + void benchmarkEnded( BenchmarkStats const& stats ) override; + + void pushScopedMessage(MessageInfo const& message) override; + void popScopedMessage(MessageInfo const& message) override; + + std::string getCurrentTestName() const override; + + const AssertionResult* getLastResult() const override; + + void exceptionEarlyReported() override; + + void handleFatalErrorCondition( StringRef message ) override; + + bool lastAssertionPassed() override; + + void assertionPassed() override; + + void assertionRun() override; + + public: + // !TBD We need to do this another way! + bool aborting() const override; + + private: + + void runCurrentTest(std::string& redirectedCout, std::string& redirectedCerr); + void invokeActiveTestCase(); + + private: + + void handleUnfinishedSections(); + + TestRunInfo m_runInfo; + IMutableContext& m_context; + TestCase const* m_activeTestCase = nullptr; + ITracker* m_testCaseTracker; + Option m_lastResult; + + IConfigPtr m_config; + Totals m_totals; + IStreamingReporterPtr m_reporter; + std::vector m_messages; + AssertionInfo m_lastAssertionInfo; + std::vector m_unfinishedSections; + std::vector m_activeSections; + TrackerContext m_trackerContext; + std::size_t m_prevPassed = 0; + bool m_shouldReportUnexpected = true; + }; + + IResultCapture& getResultCapture(); + +} // end namespace Catch + +// end catch_run_context.h + +#include +#include + +namespace Catch { + + StreamRedirect::StreamRedirect(std::ostream& stream, std::string& targetString) + : m_stream(stream), + m_prevBuf(stream.rdbuf()), + m_targetString(targetString) { + stream.rdbuf(m_oss.rdbuf()); + } + + StreamRedirect::~StreamRedirect() { + m_targetString += m_oss.str(); + m_stream.rdbuf(m_prevBuf); + } + + StdErrRedirect::StdErrRedirect(std::string & targetString) + :m_cerrBuf(cerr().rdbuf()), m_clogBuf(clog().rdbuf()), + m_targetString(targetString) { + cerr().rdbuf(m_oss.rdbuf()); + clog().rdbuf(m_oss.rdbuf()); + } + + StdErrRedirect::~StdErrRedirect() { + m_targetString += m_oss.str(); + cerr().rdbuf(m_cerrBuf); + clog().rdbuf(m_clogBuf); + } + + RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter) + : m_runInfo(_config->name()), + m_context(getCurrentMutableContext()), + m_config(_config), + m_reporter(std::move(reporter)), + m_lastAssertionInfo{ "", SourceLineInfo("",0), "", ResultDisposition::Normal } + { + m_context.setRunner(this); + m_context.setConfig(m_config); + m_context.setResultCapture(this); + m_reporter->testRunStarting(m_runInfo); + } + + RunContext::~RunContext() { + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, aborting())); + } + + void RunContext::testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount) { + m_reporter->testGroupStarting(GroupInfo(testSpec, groupIndex, groupsCount)); + } + + void RunContext::testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount) { + m_reporter->testGroupEnded(TestGroupStats(GroupInfo(testSpec, groupIndex, groupsCount), totals, aborting())); + } + + Totals RunContext::runTest(TestCase const& testCase) { + Totals prevTotals = m_totals; + + std::string redirectedCout; + std::string redirectedCerr; + + TestCaseInfo testInfo = testCase.getTestCaseInfo(); + + m_reporter->testCaseStarting(testInfo); + + m_activeTestCase = &testCase; + + ITracker& rootTracker = m_trackerContext.startRun(); + assert(rootTracker.isSectionTracker()); + static_cast(rootTracker).addInitialFilters(m_config->getSectionsToRun()); + do { + m_trackerContext.startCycle(); + m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(testInfo.name, testInfo.lineInfo)); + runCurrentTest(redirectedCout, redirectedCerr); + } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting()); + + Totals deltaTotals = m_totals.delta(prevTotals); + if (testInfo.expectedToFail() && deltaTotals.testCases.passed > 0) { + deltaTotals.assertions.failed++; + deltaTotals.testCases.passed--; + deltaTotals.testCases.failed++; + } + m_totals.testCases += deltaTotals.testCases; + m_reporter->testCaseEnded(TestCaseStats(testInfo, + deltaTotals, + redirectedCout, + redirectedCerr, + aborting())); + + m_activeTestCase = nullptr; + m_testCaseTracker = nullptr; + + return deltaTotals; + } + + IConfigPtr RunContext::config() const { + return m_config; + } + + IStreamingReporter& RunContext::reporter() const { + return *m_reporter; + } + + void RunContext::assertionStarting(AssertionInfo const& info) { + m_reporter->assertionStarting( info ); + } + void RunContext::assertionEnded(AssertionResult const & result) { + if (result.getResultType() == ResultWas::Ok) { + m_totals.assertions.passed++; + } else if (!result.isOk()) { + if( m_activeTestCase->getTestCaseInfo().okToFail() ) + m_totals.assertions.failedButOk++; + else + m_totals.assertions.failed++; + } + + // We have no use for the return value (whether messages should be cleared), because messages were made scoped + // and should be let to clear themselves out. + static_cast(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals))); + + // Reset working state + m_lastAssertionInfo = { "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}", m_lastAssertionInfo.resultDisposition }; + m_lastResult = result; + } + + bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) { + ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo)); + if (!sectionTracker.isOpen()) + return false; + m_activeSections.push_back(§ionTracker); + + m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; + + m_reporter->sectionStarting(sectionInfo); + + assertions = m_totals.assertions; + + return true; + } + + bool RunContext::testForMissingAssertions(Counts& assertions) { + if (assertions.total() != 0) + return false; + if (!m_config->warnAboutMissingAssertions()) + return false; + if (m_trackerContext.currentTracker().hasChildren()) + return false; + m_totals.assertions.failed++; + assertions.failed++; + return true; + } + + void RunContext::sectionEnded(SectionEndInfo const & endInfo) { + Counts assertions = m_totals.assertions - endInfo.prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + + if (!m_activeSections.empty()) { + m_activeSections.back()->close(); + m_activeSections.pop_back(); + } + + m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions)); + m_messages.clear(); + } + + void RunContext::sectionEndedEarly(SectionEndInfo const & endInfo) { + if (m_unfinishedSections.empty()) + m_activeSections.back()->fail(); + else + m_activeSections.back()->close(); + m_activeSections.pop_back(); + + m_unfinishedSections.push_back(endInfo); + } + void RunContext::benchmarkStarting( BenchmarkInfo const& info ) { + m_reporter->benchmarkStarting( info ); + } + void RunContext::benchmarkEnded( BenchmarkStats const& stats ) { + m_reporter->benchmarkEnded( stats ); + } + + void RunContext::pushScopedMessage(MessageInfo const & message) { + m_messages.push_back(message); + } + + void RunContext::popScopedMessage(MessageInfo const & message) { + m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end()); + } + + std::string RunContext::getCurrentTestName() const { + return m_activeTestCase + ? m_activeTestCase->getTestCaseInfo().name + : std::string(); + } + + const AssertionResult * RunContext::getLastResult() const { + return &(*m_lastResult); + } + + void RunContext::exceptionEarlyReported() { + m_shouldReportUnexpected = false; + } + + void RunContext::handleFatalErrorCondition( StringRef message ) { + // First notify reporter that bad things happened + m_reporter->fatalErrorEncountered(message); + + // Don't rebuild the result -- the stringification itself can cause more fatal errors + // Instead, fake a result data. + AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } ); + tempResult.message = message; + AssertionResult result(m_lastAssertionInfo, tempResult); + + getResultCapture().assertionEnded(result); + + handleUnfinishedSections(); + + // Recreate section for test case (as we will lose the one that was in scope) + auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description); + + Counts assertions; + assertions.failed = 1; + SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false); + m_reporter->sectionEnded(testCaseSectionStats); + + auto const& testInfo = m_activeTestCase->getTestCaseInfo(); + + Totals deltaTotals; + deltaTotals.testCases.failed = 1; + deltaTotals.assertions.failed = 1; + m_reporter->testCaseEnded(TestCaseStats(testInfo, + deltaTotals, + std::string(), + std::string(), + false)); + m_totals.testCases.failed++; + testGroupEnded(std::string(), m_totals, 1, 1); + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false)); + } + + bool RunContext::lastAssertionPassed() { + return m_totals.assertions.passed == (m_prevPassed + 1); + } + + void RunContext::assertionPassed() { + ++m_totals.assertions.passed; + m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"; + m_lastAssertionInfo.macroName = ""; + } + + void RunContext::assertionRun() { + m_prevPassed = m_totals.assertions.passed; + } + + bool RunContext::aborting() const { + return m_totals.assertions.failed == static_cast(m_config->abortAfter()); + } + + void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) { + auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description); + m_reporter->sectionStarting(testCaseSection); + Counts prevAssertions = m_totals.assertions; + double duration = 0; + m_shouldReportUnexpected = true; + try { + m_lastAssertionInfo = { "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal }; + + seedRng(*m_config); + + Timer timer; + timer.start(); + if (m_reporter->getPreferences().shouldRedirectStdOut) { + StreamRedirect coutRedir(cout(), redirectedCout); + StdErrRedirect errRedir(redirectedCerr); + invokeActiveTestCase(); + } else { + invokeActiveTestCase(); + } + duration = timer.getElapsedSeconds(); + } catch (TestFailureException&) { + // This just means the test was aborted due to failure + } catch (...) { + // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions + // are reported without translation at the point of origin. + if (m_shouldReportUnexpected) { + AssertionHandler + ( m_lastAssertionInfo.macroName, + m_lastAssertionInfo.lineInfo, + m_lastAssertionInfo.capturedExpression, + m_lastAssertionInfo.resultDisposition ).useActiveException(); + } + } + m_testCaseTracker->close(); + handleUnfinishedSections(); + m_messages.clear(); + + Counts assertions = m_totals.assertions - prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions); + m_reporter->sectionEnded(testCaseSectionStats); + } + + void RunContext::invokeActiveTestCase() { + FatalConditionHandler fatalConditionHandler; // Handle signals + m_activeTestCase->invoke(); + fatalConditionHandler.reset(); + } + + void RunContext::handleUnfinishedSections() { + // If sections ended prematurely due to an exception we stored their + // infos here so we can tear them down outside the unwind process. + for (auto it = m_unfinishedSections.rbegin(), + itEnd = m_unfinishedSections.rend(); + it != itEnd; + ++it) + sectionEnded(*it); + m_unfinishedSections.clear(); + } + + IResultCapture& getResultCapture() { + if (auto* capture = getCurrentContext().getResultCapture()) + return *capture; + else + CATCH_INTERNAL_ERROR("No result capture instance"); + } +} +// end catch_run_context.cpp +// start catch_section.cpp + +namespace Catch { + + Section::Section( SectionInfo const& info ) + : m_info( info ), + m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) + { + m_timer.start(); + } + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17 +#endif + Section::~Section() { + if( m_sectionIncluded ) { + SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() ); + if( std::uncaught_exception() ) + getResultCapture().sectionEndedEarly( endInfo ); + else + getResultCapture().sectionEnded( endInfo ); + } + } +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + + // This indicates whether the section should be executed or not + Section::operator bool() const { + return m_sectionIncluded; + } + +} // end namespace Catch +// end catch_section.cpp +// start catch_section_info.cpp + +namespace Catch { + + SectionInfo::SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name, + std::string const& _description ) + : name( _name ), + description( _description ), + lineInfo( _lineInfo ) + {} + + SectionEndInfo::SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds ) + : sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds ) + {} + +} // end namespace Catch +// end catch_section_info.cpp +// start catch_session.cpp + +// start catch_session.h + +#include + +namespace Catch { + + class Session : NonCopyable { + public: + + Session(); + ~Session() override; + + void showHelp() const; + void libIdentify(); + + int applyCommandLine( int argc, char* argv[] ); + + void useConfigData( ConfigData const& configData ); + + int run( int argc, char* argv[] ); + #if defined(WIN32) && defined(UNICODE) + int run( int argc, wchar_t* const argv[] ); + #endif + int run(); + + clara::Parser const& cli() const; + void cli( clara::Parser const& newParser ); + ConfigData& configData(); + Config& config(); + private: + int runInternal(); + + clara::Parser m_cli; + ConfigData m_configData; + std::shared_ptr m_config; + bool m_startupExceptions = false; + }; + +} // end namespace Catch + +// end catch_session.h +// start catch_version.h + +#include + +namespace Catch { + + // Versioning information + struct Version { + Version( Version const& ) = delete; + Version& operator=( Version const& ) = delete; + Version( unsigned int _majorVersion, + unsigned int _minorVersion, + unsigned int _patchNumber, + char const * const _branchName, + unsigned int _buildNumber ); + + unsigned int const majorVersion; + unsigned int const minorVersion; + unsigned int const patchNumber; + + // buildNumber is only used if branchName is not null + char const * const branchName; + unsigned int const buildNumber; + + friend std::ostream& operator << ( std::ostream& os, Version const& version ); + }; + + Version const& libraryVersion(); +} + +// end catch_version.h +#include +#include + +namespace { + const int MaxExitCode = 255; + using Catch::IStreamingReporterPtr; + using Catch::IConfigPtr; + using Catch::Config; + + IStreamingReporterPtr createReporter(std::string const& reporterName, IConfigPtr const& config) { + auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, config); + CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << "'"); + + return reporter; + } + +#ifndef CATCH_CONFIG_DEFAULT_REPORTER +#define CATCH_CONFIG_DEFAULT_REPORTER "console" +#endif + + IStreamingReporterPtr makeReporter(std::shared_ptr const& config) { + auto const& reporterNames = config->getReporterNames(); + if (reporterNames.empty()) + return createReporter(CATCH_CONFIG_DEFAULT_REPORTER, config); + + IStreamingReporterPtr reporter; + for (auto const& name : reporterNames) + addReporter(reporter, createReporter(name, config)); + return reporter; + } + +#undef CATCH_CONFIG_DEFAULT_REPORTER + + void addListeners(IStreamingReporterPtr& reporters, IConfigPtr const& config) { + auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners(); + for (auto const& listener : listeners) + addReporter(reporters, listener->create(Catch::ReporterConfig(config))); + } + + Catch::Totals runTests(std::shared_ptr const& config) { + using namespace Catch; + IStreamingReporterPtr reporter = makeReporter(config); + addListeners(reporter, config); + + RunContext context(config, std::move(reporter)); + + Totals totals; + + context.testGroupStarting(config->name(), 1, 1); + + TestSpec testSpec = config->testSpec(); + if (!testSpec.hasFilters()) + testSpec = TestSpecParser(ITagAliasRegistry::get()).parse("~[.]").testSpec(); // All not hidden tests + + auto const& allTestCases = getAllTestCasesSorted(*config); + for (auto const& testCase : allTestCases) { + if (!context.aborting() && matchTest(testCase, testSpec, *config)) + totals += context.runTest(testCase); + else + context.reporter().skipTest(testCase); + } + + context.testGroupEnded(config->name(), totals, 1, 1); + return totals; + } + + void applyFilenamesAsTags(Catch::IConfig const& config) { + using namespace Catch; + auto& tests = const_cast&>(getAllTestCasesSorted(config)); + for (auto& testCase : tests) { + auto tags = testCase.tags; + + std::string filename = testCase.lineInfo.file; + auto lastSlash = filename.find_last_of("\\/"); + if (lastSlash != std::string::npos) { + filename.erase(0, lastSlash); + filename[0] = '#'; + } + + auto lastDot = filename.find_last_of('.'); + if (lastDot != std::string::npos) { + filename.erase(lastDot); + } + + tags.push_back(std::move(filename)); + setTags(testCase, tags); + } + } + +} + +namespace Catch { + + Session::Session() { + static bool alreadyInstantiated = false; + if( alreadyInstantiated ) { + try { CATCH_INTERNAL_ERROR( "Only one instance of Catch::Session can ever be used" ); } + catch(...) { getMutableRegistryHub().registerStartupException(); } + } + + const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions(); + if ( !exceptions.empty() ) { + m_startupExceptions = true; + Colour colourGuard( Colour::Red ); + Catch::cerr() << "Errors occured during startup!" << '\n'; + // iterate over all exceptions and notify user + for ( const auto& ex_ptr : exceptions ) { + try { + std::rethrow_exception(ex_ptr); + } catch ( std::exception const& ex ) { + Catch::cerr() << Column( ex.what() ).indent(2) << '\n'; + } + } + } + + alreadyInstantiated = true; + m_cli = makeCommandLineParser( m_configData ); + } + Session::~Session() { + Catch::cleanUp(); + } + + void Session::showHelp() const { + Catch::cout() + << "\nCatch v" << libraryVersion() << "\n" + << m_cli << std::endl + << "For more detailed usage please see the project docs\n" << std::endl; + } + void Session::libIdentify() { + Catch::cout() + << std::left << std::setw(16) << "description: " << "A Catch test executable\n" + << std::left << std::setw(16) << "category: " << "testframework\n" + << std::left << std::setw(16) << "framework: " << "Catch Test\n" + << std::left << std::setw(16) << "version: " << libraryVersion() << std::endl; + } + + int Session::applyCommandLine( int argc, char* argv[] ) { + if( m_startupExceptions ) + return 1; + + auto result = m_cli.parse( clara::Args( argc, argv ) ); + if( !result ) { + Catch::cerr() + << Colour( Colour::Red ) + << "\nError(s) in input:\n" + << Column( result.errorMessage() ).indent( 2 ) + << "\n\n"; + Catch::cerr() << "Run with -? for usage\n" << std::endl; + return MaxExitCode; + } + + if( m_configData.showHelp ) + showHelp(); + if( m_configData.libIdentify ) + libIdentify(); + m_config.reset(); + return 0; + } + + void Session::useConfigData( ConfigData const& configData ) { + m_configData = configData; + m_config.reset(); + } + + int Session::run( int argc, char* argv[] ) { + if( m_startupExceptions ) + return 1; + int returnCode = applyCommandLine( argc, argv ); + if( returnCode == 0 ) + returnCode = run(); + return returnCode; + } + +#if defined(WIN32) && defined(UNICODE) + int Session::run( int argc, wchar_t* const argv[] ) { + + char **utf8Argv = new char *[ argc ]; + + for ( int i = 0; i < argc; ++i ) { + int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL ); + + utf8Argv[ i ] = new char[ bufSize ]; + + WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL ); + } + + int returnCode = run( argc, utf8Argv ); + + for ( int i = 0; i < argc; ++i ) + delete [] utf8Argv[ i ]; + + delete [] utf8Argv; + + return returnCode; + } +#endif + int Session::run() { + if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) { + Catch::cout() << "...waiting for enter/ return before starting" << std::endl; + static_cast(std::getchar()); + } + int exitCode = runInternal(); + if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) { + Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << std::endl; + static_cast(std::getchar()); + } + return exitCode; + } + + clara::Parser const& Session::cli() const { + return m_cli; + } + void Session::cli( clara::Parser const& newParser ) { + m_cli = newParser; + } + ConfigData& Session::configData() { + return m_configData; + } + Config& Session::config() { + if( !m_config ) + m_config = std::make_shared( m_configData ); + return *m_config; + } + + int Session::runInternal() { + if( m_startupExceptions ) + return 1; + + if( m_configData.showHelp || m_configData.libIdentify ) + return 0; + + try + { + config(); // Force config to be constructed + + seedRng( *m_config ); + + if( m_configData.filenamesAsTags ) + applyFilenamesAsTags( *m_config ); + + // Handle list request + if( Option listed = list( config() ) ) + return static_cast( *listed ); + + return (std::min)( MaxExitCode, static_cast( runTests( m_config ).assertions.failed ) ); + } + catch( std::exception& ex ) { + Catch::cerr() << ex.what() << std::endl; + return MaxExitCode; + } + } + +} // end namespace Catch +// end catch_session.cpp +// start catch_startup_exception_registry.cpp + +namespace Catch { + void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { + try { + m_exceptions.push_back(exception); + } + catch(...) { + // If we run out of memory during start-up there's really not a lot more we can do about it + std::terminate(); + } + } + + std::vector const& StartupExceptionRegistry::getExceptions() const noexcept { + return m_exceptions; + } + +} // end namespace Catch +// end catch_startup_exception_registry.cpp +// start catch_stream.cpp + +#include +#include +#include + +namespace Catch { + + template + class StreamBufImpl : public StreamBufBase { + char data[bufferSize]; + WriterF m_writer; + + public: + StreamBufImpl() { + setp( data, data + sizeof(data) ); + } + + ~StreamBufImpl() noexcept { + StreamBufImpl::sync(); + } + + private: + int overflow( int c ) override { + sync(); + + if( c != EOF ) { + if( pbase() == epptr() ) + m_writer( std::string( 1, static_cast( c ) ) ); + else + sputc( static_cast( c ) ); + } + return 0; + } + + int sync() override { + if( pbase() != pptr() ) { + m_writer( std::string( pbase(), static_cast( pptr() - pbase() ) ) ); + setp( pbase(), epptr() ); + } + return 0; + } + }; + + /////////////////////////////////////////////////////////////////////////// + + Catch::IStream::~IStream() = default; + + FileStream::FileStream( std::string const& filename ) { + m_ofs.open( filename.c_str() ); + CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << "'" ); + } + + std::ostream& FileStream::stream() const { + return m_ofs; + } + + struct OutputDebugWriter { + + void operator()( std::string const&str ) { + writeToDebugConsole( str ); + } + }; + + DebugOutStream::DebugOutStream() + : m_streamBuf( new StreamBufImpl() ), + m_os( m_streamBuf.get() ) + {} + + std::ostream& DebugOutStream::stream() const { + return m_os; + } + + // Store the streambuf from cout up-front because + // cout may get redirected when running tests + CoutStream::CoutStream() + : m_os( Catch::cout().rdbuf() ) + {} + + std::ostream& CoutStream::stream() const { + return m_os; + } + +#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions + std::ostream& cout() { + return std::cout; + } + std::ostream& cerr() { + return std::cerr; + } + std::ostream& clog() { + return std::clog; + } +#endif +} +// end catch_stream.cpp +// start catch_streambuf.cpp + +namespace Catch { + StreamBufBase::~StreamBufBase() = default; +} +// end catch_streambuf.cpp +// start catch_string_manip.cpp + +#include +#include +#include +#include + +namespace Catch { + + bool startsWith( std::string const& s, std::string const& prefix ) { + return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin()); + } + bool startsWith( std::string const& s, char prefix ) { + return !s.empty() && s[0] == prefix; + } + bool endsWith( std::string const& s, std::string const& suffix ) { + return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin()); + } + bool endsWith( std::string const& s, char suffix ) { + return !s.empty() && s[s.size()-1] == suffix; + } + bool contains( std::string const& s, std::string const& infix ) { + return s.find( infix ) != std::string::npos; + } + char toLowerCh(char c) { + return static_cast( std::tolower( c ) ); + } + void toLowerInPlace( std::string& s ) { + std::transform( s.begin(), s.end(), s.begin(), toLowerCh ); + } + std::string toLower( std::string const& s ) { + std::string lc = s; + toLowerInPlace( lc ); + return lc; + } + std::string trim( std::string const& str ) { + static char const* whitespaceChars = "\n\r\t "; + std::string::size_type start = str.find_first_not_of( whitespaceChars ); + std::string::size_type end = str.find_last_not_of( whitespaceChars ); + + return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string(); + } + + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { + bool replaced = false; + std::size_t i = str.find( replaceThis ); + while( i != std::string::npos ) { + replaced = true; + str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); + if( i < str.size()-withThis.size() ) + i = str.find( replaceThis, i+withThis.size() ); + else + i = std::string::npos; + } + return replaced; + } + + pluralise::pluralise( std::size_t count, std::string const& label ) + : m_count( count ), + m_label( label ) + {} + + std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { + os << pluraliser.m_count << ' ' << pluraliser.m_label; + if( pluraliser.m_count != 1 ) + os << 's'; + return os; + } + +} +// end catch_string_manip.cpp +// start catch_stringref.cpp + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +#include +#include +#include + +namespace Catch { + + auto getEmptyStringRef() -> StringRef { + static StringRef s_emptyStringRef(""); + return s_emptyStringRef; + } + + StringRef::StringRef() noexcept + : StringRef( getEmptyStringRef() ) + {} + + StringRef::StringRef( StringRef const& other ) noexcept + : m_start( other.m_start ), + m_size( other.m_size ) + {} + + StringRef::StringRef( StringRef&& other ) noexcept + : m_start( other.m_start ), + m_size( other.m_size ), + m_data( other.m_data ) + { + other.m_data = nullptr; + } + + StringRef::StringRef( char const* rawChars ) noexcept + : m_start( rawChars ), + m_size( static_cast( std::strlen( rawChars ) ) ) + { + assert( rawChars != nullptr ); + } + + StringRef::StringRef( char const* rawChars, size_type size ) noexcept + : m_start( rawChars ), + m_size( size ) + { + size_type rawSize = rawChars == nullptr ? 0 : static_cast( std::strlen( rawChars ) ); + if( rawSize < size ) + m_size = rawSize; + } + + StringRef::StringRef( std::string const& stdString ) noexcept + : m_start( stdString.c_str() ), + m_size( stdString.size() ) + {} + + StringRef::~StringRef() noexcept { + delete[] m_data; + } + + auto StringRef::operator = ( StringRef other ) noexcept -> StringRef& { + swap( other ); + return *this; + } + StringRef::operator std::string() const { + return std::string( m_start, m_size ); + } + + void StringRef::swap( StringRef& other ) noexcept { + std::swap( m_start, other.m_start ); + std::swap( m_size, other.m_size ); + std::swap( m_data, other.m_data ); + } + + auto StringRef::c_str() const -> char const* { + if( isSubstring() ) + const_cast( this )->takeOwnership(); + return m_start; + } + auto StringRef::data() const noexcept -> char const* { + return m_start; + } + + auto StringRef::isOwned() const noexcept -> bool { + return m_data != nullptr; + } + auto StringRef::isSubstring() const noexcept -> bool { + return m_start[m_size] != '\0'; + } + + void StringRef::takeOwnership() { + if( !isOwned() ) { + m_data = new char[m_size+1]; + memcpy( m_data, m_start, m_size ); + m_data[m_size] = '\0'; + m_start = m_data; + } + } + auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef { + if( start < m_size ) + return StringRef( m_start+start, size ); + else + return StringRef(); + } + auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool { + return + size() == other.size() && + (std::strncmp( m_start, other.m_start, size() ) == 0); + } + auto StringRef::operator != ( StringRef const& other ) const noexcept -> bool { + return !operator==( other ); + } + + auto StringRef::operator[](size_type index) const noexcept -> char { + return m_start[index]; + } + + auto StringRef::empty() const noexcept -> bool { + return m_size == 0; + } + + auto StringRef::size() const noexcept -> size_type { + return m_size; + } + auto StringRef::numberOfCharacters() const noexcept -> size_type { + size_type noChars = m_size; + // Make adjustments for uft encodings + for( size_type i=0; i < m_size; ++i ) { + char c = m_start[i]; + if( ( c & 0b11000000 ) == 0b11000000 ) { + if( ( c & 0b11100000 ) == 0b11000000 ) + noChars--; + else if( ( c & 0b11110000 ) == 0b11100000 ) + noChars-=2; + else if( ( c & 0b11111000 ) == 0b11110000 ) + noChars-=3; + } + } + return noChars; + } + + auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string { + std::string str; + str.reserve( lhs.size() + rhs.size() ); + str += lhs; + str += rhs; + return str; + } + auto operator + ( StringRef const& lhs, const char* rhs ) -> std::string { + return std::string( lhs ) + std::string( rhs ); + } + auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string { + return std::string( lhs ) + std::string( rhs ); + } + + auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& { + return os << str.c_str(); + } + +} // namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +// end catch_stringref.cpp +// start catch_tag_alias.cpp + +namespace Catch { + TagAlias::TagAlias(std::string const & _tag, SourceLineInfo _lineInfo): tag(_tag), lineInfo(_lineInfo) {} +} +// end catch_tag_alias.cpp +// start catch_tag_alias_autoregistrar.cpp + +namespace Catch { + + RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { + try { + getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); + } catch (...) { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + +} +// end catch_tag_alias_autoregistrar.cpp +// start catch_tag_alias_registry.cpp + +namespace Catch { + + TagAliasRegistry::~TagAliasRegistry() {} + + TagAlias const* TagAliasRegistry::find( std::string const& alias ) const { + auto it = m_registry.find( alias ); + if( it != m_registry.end() ) + return &(it->second); + else + return nullptr; + } + + std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const { + std::string expandedTestSpec = unexpandedTestSpec; + for( auto const& registryKvp : m_registry ) { + std::size_t pos = expandedTestSpec.find( registryKvp.first ); + if( pos != std::string::npos ) { + expandedTestSpec = expandedTestSpec.substr( 0, pos ) + + registryKvp.second.tag + + expandedTestSpec.substr( pos + registryKvp.first.size() ); + } + } + return expandedTestSpec; + } + + void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) { + CATCH_ENFORCE( startsWith(alias, "[@") && endsWith(alias, ']'), + "error: tag alias, '" << alias << "' is not of the form [@alias name].\n" << lineInfo ); + + CATCH_ENFORCE( m_registry.insert(std::make_pair(alias, TagAlias(tag, lineInfo))).second, + "error: tag alias, '" << alias << "' already registered.\n" + << "\tFirst seen at: " << find(alias)->lineInfo << "\n" + << "\tRedefined at: " << lineInfo ); + } + + ITagAliasRegistry::~ITagAliasRegistry() {} + + ITagAliasRegistry const& ITagAliasRegistry::get() { + return getRegistryHub().getTagAliasRegistry(); + } + +} // end namespace Catch +// end catch_tag_alias_registry.cpp +// start catch_test_case_info.cpp + +#include +#include +#include + +namespace Catch { + + TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) { + if( startsWith( tag, '.' ) || + tag == "!hide" ) + return TestCaseInfo::IsHidden; + else if( tag == "!throws" ) + return TestCaseInfo::Throws; + else if( tag == "!shouldfail" ) + return TestCaseInfo::ShouldFail; + else if( tag == "!mayfail" ) + return TestCaseInfo::MayFail; + else if( tag == "!nonportable" ) + return TestCaseInfo::NonPortable; + else if( tag == "!benchmark" ) + return static_cast( TestCaseInfo::Benchmark | TestCaseInfo::IsHidden ); + else + return TestCaseInfo::None; + } + bool isReservedTag( std::string const& tag ) { + return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( tag[0] ); + } + void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { + CATCH_ENFORCE( !isReservedTag(tag), + "Tag name: [" << tag << "] is not allowed.\n" + << "Tag names starting with non alpha-numeric characters are reserved\n" + << _lineInfo ); + } + + TestCase makeTestCase( ITestInvoker* _testCase, + std::string const& _className, + std::string const& _name, + std::string const& _descOrTags, + SourceLineInfo const& _lineInfo ) + { + bool isHidden = false; + + // Parse out tags + std::vector tags; + std::string desc, tag; + bool inTag = false; + for (char c : _descOrTags) { + if( !inTag ) { + if( c == '[' ) + inTag = true; + else + desc += c; + } + else { + if( c == ']' ) { + TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag ); + if( ( prop & TestCaseInfo::IsHidden ) != 0 ) + isHidden = true; + else if( prop == TestCaseInfo::None ) + enforceNotReservedTag( tag, _lineInfo ); + + tags.push_back( tag ); + tag.clear(); + inTag = false; + } + else + tag += c; + } + } + if( isHidden ) { + tags.push_back( "." ); + } + + TestCaseInfo info( _name, _className, desc, tags, _lineInfo ); + return TestCase( _testCase, info ); + } + + void setTags( TestCaseInfo& testCaseInfo, std::vector tags ) { + std::sort(begin(tags), end(tags)); + tags.erase(std::unique(begin(tags), end(tags)), end(tags)); + testCaseInfo.lcaseTags.clear(); + + for( auto const& tag : tags ) { + std::string lcaseTag = toLower( tag ); + testCaseInfo.properties = static_cast( testCaseInfo.properties | parseSpecialTag( lcaseTag ) ); + testCaseInfo.lcaseTags.push_back( lcaseTag ); + } + testCaseInfo.tags = std::move(tags); + } + + TestCaseInfo::TestCaseInfo( std::string const& _name, + std::string const& _className, + std::string const& _description, + std::vector const& _tags, + SourceLineInfo const& _lineInfo ) + : name( _name ), + className( _className ), + description( _description ), + lineInfo( _lineInfo ), + properties( None ) + { + setTags( *this, _tags ); + } + + bool TestCaseInfo::isHidden() const { + return ( properties & IsHidden ) != 0; + } + bool TestCaseInfo::throws() const { + return ( properties & Throws ) != 0; + } + bool TestCaseInfo::okToFail() const { + return ( properties & (ShouldFail | MayFail ) ) != 0; + } + bool TestCaseInfo::expectedToFail() const { + return ( properties & (ShouldFail ) ) != 0; + } + + std::string TestCaseInfo::tagsAsString() const { + std::string ret; + // '[' and ']' per tag + std::size_t full_size = 2 * tags.size(); + for (const auto& tag : tags) { + full_size += tag.size(); + } + ret.reserve(full_size); + for (const auto& tag : tags) { + ret.push_back('['); + ret.append(tag); + ret.push_back(']'); + } + + return ret; + } + + TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {} + + TestCase TestCase::withName( std::string const& _newName ) const { + TestCase other( *this ); + other.name = _newName; + return other; + } + + void TestCase::invoke() const { + test->invoke(); + } + + bool TestCase::operator == ( TestCase const& other ) const { + return test.get() == other.test.get() && + name == other.name && + className == other.className; + } + + bool TestCase::operator < ( TestCase const& other ) const { + return name < other.name; + } + + TestCaseInfo const& TestCase::getTestCaseInfo() const + { + return *this; + } + +} // end namespace Catch +// end catch_test_case_info.cpp +// start catch_test_case_registry_impl.cpp + +#include + +namespace Catch { + + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { + + std::vector sorted = unsortedTestCases; + + switch( config.runOrder() ) { + case RunTests::InLexicographicalOrder: + std::sort( sorted.begin(), sorted.end() ); + break; + case RunTests::InRandomOrder: + seedRng( config ); + RandomNumberGenerator::shuffle( sorted ); + break; + case RunTests::InDeclarationOrder: + // already in declaration order + break; + } + return sorted; + } + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) { + return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() ); + } + + void enforceNoDuplicateTestCases( std::vector const& functions ) { + std::set seenFunctions; + for( auto const& function : functions ) { + auto prev = seenFunctions.insert( function ); + CATCH_ENFORCE( prev.second, + "error: TEST_CASE( \"" << function.name << "\" ) already defined.\n" + << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n" + << "\tRedefined at " << function.getTestCaseInfo().lineInfo ); + } + } + + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ) { + std::vector filtered; + filtered.reserve( testCases.size() ); + for( auto const& testCase : testCases ) + if( matchTest( testCase, testSpec, config ) ) + filtered.push_back( testCase ); + return filtered; + } + std::vector const& getAllTestCasesSorted( IConfig const& config ) { + return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config ); + } + + void TestRegistry::registerTest( TestCase const& testCase ) { + std::string name = testCase.getTestCaseInfo().name; + if( name.empty() ) { + std::ostringstream oss; + oss << "Anonymous test case " << ++m_unnamedCount; + return registerTest( testCase.withName( oss.str() ) ); + } + m_functions.push_back( testCase ); + } + + std::vector const& TestRegistry::getAllTests() const { + return m_functions; + } + std::vector const& TestRegistry::getAllTestsSorted( IConfig const& config ) const { + if( m_sortedFunctions.empty() ) + enforceNoDuplicateTestCases( m_functions ); + + if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) { + m_sortedFunctions = sortTests( config, m_functions ); + m_currentSortOrder = config.runOrder(); + } + return m_sortedFunctions; + } + + /////////////////////////////////////////////////////////////////////////// + TestInvokerAsFunction::TestInvokerAsFunction( void(*testAsFunction)() ) noexcept : m_testAsFunction( testAsFunction ) {} + + void TestInvokerAsFunction::invoke() const { + m_testAsFunction(); + } + + std::string extractClassName( std::string const& classOrQualifiedMethodName ) { + std::string className = classOrQualifiedMethodName; + if( startsWith( className, '&' ) ) + { + std::size_t lastColons = className.rfind( "::" ); + std::size_t penultimateColons = className.rfind( "::", lastColons-1 ); + if( penultimateColons == std::string::npos ) + penultimateColons = 1; + className = className.substr( penultimateColons, lastColons-penultimateColons ); + } + return className; + } + +} // end namespace Catch +// end catch_test_case_registry_impl.cpp +// start catch_test_case_tracker.cpp + +#include +#include +#include +#include + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +namespace Catch { +namespace TestCaseTracking { + + NameAndLocation::NameAndLocation( std::string const& _name, SourceLineInfo const& _location ) + : name( _name ), + location( _location ) + {} + + ITracker::~ITracker() = default; + + TrackerContext& TrackerContext::instance() { + static TrackerContext s_instance; + return s_instance; + } + + ITracker& TrackerContext::startRun() { + m_rootTracker = std::make_shared( NameAndLocation( "{root}", CATCH_INTERNAL_LINEINFO ), *this, nullptr ); + m_currentTracker = nullptr; + m_runState = Executing; + return *m_rootTracker; + } + + void TrackerContext::endRun() { + m_rootTracker.reset(); + m_currentTracker = nullptr; + m_runState = NotStarted; + } + + void TrackerContext::startCycle() { + m_currentTracker = m_rootTracker.get(); + m_runState = Executing; + } + void TrackerContext::completeCycle() { + m_runState = CompletedCycle; + } + + bool TrackerContext::completedCycle() const { + return m_runState == CompletedCycle; + } + ITracker& TrackerContext::currentTracker() { + return *m_currentTracker; + } + void TrackerContext::setCurrentTracker( ITracker* tracker ) { + m_currentTracker = tracker; + } + + TrackerBase::TrackerHasName::TrackerHasName( NameAndLocation const& nameAndLocation ) : m_nameAndLocation( nameAndLocation ) {} + bool TrackerBase::TrackerHasName::operator ()( ITrackerPtr const& tracker ) const { + return + tracker->nameAndLocation().name == m_nameAndLocation.name && + tracker->nameAndLocation().location == m_nameAndLocation.location; + } + + TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) + : m_nameAndLocation( nameAndLocation ), + m_ctx( ctx ), + m_parent( parent ) + {} + + NameAndLocation const& TrackerBase::nameAndLocation() const { + return m_nameAndLocation; + } + bool TrackerBase::isComplete() const { + return m_runState == CompletedSuccessfully || m_runState == Failed; + } + bool TrackerBase::isSuccessfullyCompleted() const { + return m_runState == CompletedSuccessfully; + } + bool TrackerBase::isOpen() const { + return m_runState != NotStarted && !isComplete(); + } + bool TrackerBase::hasChildren() const { + return !m_children.empty(); + } + + void TrackerBase::addChild( ITrackerPtr const& child ) { + m_children.push_back( child ); + } + + ITrackerPtr TrackerBase::findChild( NameAndLocation const& nameAndLocation ) { + auto it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( nameAndLocation ) ); + return( it != m_children.end() ) + ? *it + : nullptr; + } + ITracker& TrackerBase::parent() { + assert( m_parent ); // Should always be non-null except for root + return *m_parent; + } + + void TrackerBase::openChild() { + if( m_runState != ExecutingChildren ) { + m_runState = ExecutingChildren; + if( m_parent ) + m_parent->openChild(); + } + } + + bool TrackerBase::isSectionTracker() const { return false; } + bool TrackerBase::isIndexTracker() const { return false; } + + void TrackerBase::open() { + m_runState = Executing; + moveToThis(); + if( m_parent ) + m_parent->openChild(); + } + + void TrackerBase::close() { + + // Close any still open children (e.g. generators) + while( &m_ctx.currentTracker() != this ) + m_ctx.currentTracker().close(); + + switch( m_runState ) { + case NeedsAnotherRun: + break; + + case Executing: + m_runState = CompletedSuccessfully; + break; + case ExecutingChildren: + if( m_children.empty() || m_children.back()->isComplete() ) + m_runState = CompletedSuccessfully; + break; + + case NotStarted: + case CompletedSuccessfully: + case Failed: + CATCH_INTERNAL_ERROR( "Illogical state: " << m_runState ); + + default: + CATCH_INTERNAL_ERROR( "Unknown state: " << m_runState ); + } + moveToParent(); + m_ctx.completeCycle(); + } + void TrackerBase::fail() { + m_runState = Failed; + if( m_parent ) + m_parent->markAsNeedingAnotherRun(); + moveToParent(); + m_ctx.completeCycle(); + } + void TrackerBase::markAsNeedingAnotherRun() { + m_runState = NeedsAnotherRun; + } + + void TrackerBase::moveToParent() { + assert( m_parent ); + m_ctx.setCurrentTracker( m_parent ); + } + void TrackerBase::moveToThis() { + m_ctx.setCurrentTracker( this ); + } + + SectionTracker::SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) + : TrackerBase( nameAndLocation, ctx, parent ) + { + if( parent ) { + while( !parent->isSectionTracker() ) + parent = &parent->parent(); + + SectionTracker& parentSection = static_cast( *parent ); + addNextFilters( parentSection.m_filters ); + } + } + + bool SectionTracker::isSectionTracker() const { return true; } + + SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) { + std::shared_ptr section; + + ITracker& currentTracker = ctx.currentTracker(); + if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isSectionTracker() ); + section = std::static_pointer_cast( childTracker ); + } + else { + section = std::make_shared( nameAndLocation, ctx, ¤tTracker ); + currentTracker.addChild( section ); + } + if( !ctx.completedCycle() ) + section->tryOpen(); + return *section; + } + + void SectionTracker::tryOpen() { + if( !isComplete() && (m_filters.empty() || m_filters[0].empty() || m_filters[0] == m_nameAndLocation.name ) ) + open(); + } + + void SectionTracker::addInitialFilters( std::vector const& filters ) { + if( !filters.empty() ) { + m_filters.push_back(""); // Root - should never be consulted + m_filters.push_back(""); // Test Case - not a section filter + m_filters.insert( m_filters.end(), filters.begin(), filters.end() ); + } + } + void SectionTracker::addNextFilters( std::vector const& filters ) { + if( filters.size() > 1 ) + m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() ); + } + + IndexTracker::IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size ) + : TrackerBase( nameAndLocation, ctx, parent ), + m_size( size ) + {} + + bool IndexTracker::isIndexTracker() const { return true; } + + IndexTracker& IndexTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ) { + std::shared_ptr tracker; + + ITracker& currentTracker = ctx.currentTracker(); + if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isIndexTracker() ); + tracker = std::static_pointer_cast( childTracker ); + } + else { + tracker = std::make_shared( nameAndLocation, ctx, ¤tTracker, size ); + currentTracker.addChild( tracker ); + } + + if( !ctx.completedCycle() && !tracker->isComplete() ) { + if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun ) + tracker->moveNext(); + tracker->open(); + } + + return *tracker; + } + + int IndexTracker::index() const { return m_index; } + + void IndexTracker::moveNext() { + m_index++; + m_children.clear(); + } + + void IndexTracker::close() { + TrackerBase::close(); + if( m_runState == CompletedSuccessfully && m_index < m_size-1 ) + m_runState = Executing; + } + +} // namespace TestCaseTracking + +using TestCaseTracking::ITracker; +using TestCaseTracking::TrackerContext; +using TestCaseTracking::SectionTracker; +using TestCaseTracking::IndexTracker; + +} // namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +// end catch_test_case_tracker.cpp +// start catch_test_registry.cpp + +namespace Catch { + + auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker* { + return new(std::nothrow) TestInvokerAsFunction( testAsFunction ); + } + + NameAndTags::NameAndTags( StringRef name_ , StringRef tags_ ) noexcept : name( name_ ), tags( tags_ ) {} + + AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept { + try { + getMutableRegistryHub() + .registerTest( + makeTestCase( + invoker, + extractClassName( classOrMethod ), + nameAndTags.name, + nameAndTags.tags, + lineInfo)); + } catch (...) { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + + AutoReg::~AutoReg() = default; +} +// end catch_test_registry.cpp +// start catch_test_spec.cpp + +#include +#include +#include +#include + +namespace Catch { + + TestSpec::Pattern::~Pattern() = default; + TestSpec::NamePattern::~NamePattern() = default; + TestSpec::TagPattern::~TagPattern() = default; + TestSpec::ExcludedPattern::~ExcludedPattern() = default; + + TestSpec::NamePattern::NamePattern( std::string const& name ) + : m_wildcardPattern( toLower( name ), CaseSensitive::No ) + {} + bool TestSpec::NamePattern::matches( TestCaseInfo const& testCase ) const { + return m_wildcardPattern.matches( toLower( testCase.name ) ); + } + + TestSpec::TagPattern::TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} + bool TestSpec::TagPattern::matches( TestCaseInfo const& testCase ) const { + return std::find(begin(testCase.lcaseTags), + end(testCase.lcaseTags), + m_tag) != end(testCase.lcaseTags); + } + + TestSpec::ExcludedPattern::ExcludedPattern( PatternPtr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} + bool TestSpec::ExcludedPattern::matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); } + + bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const { + // All patterns in a filter must match for the filter to be a match + for( auto const& pattern : m_patterns ) { + if( !pattern->matches( testCase ) ) + return false; + } + return true; + } + + bool TestSpec::hasFilters() const { + return !m_filters.empty(); + } + bool TestSpec::matches( TestCaseInfo const& testCase ) const { + // A TestSpec matches if any filter matches + for( auto const& filter : m_filters ) + if( filter.matches( testCase ) ) + return true; + return false; + } +} +// end catch_test_spec.cpp +// start catch_test_spec_parser.cpp + +namespace Catch { + + TestSpecParser::TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {} + + TestSpecParser& TestSpecParser::parse( std::string const& arg ) { + m_mode = None; + m_exclusion = false; + m_start = std::string::npos; + m_arg = m_tagAliases->expandAliases( arg ); + m_escapeChars.clear(); + for( m_pos = 0; m_pos < m_arg.size(); ++m_pos ) + visitChar( m_arg[m_pos] ); + if( m_mode == Name ) + addPattern(); + return *this; + } + TestSpec TestSpecParser::testSpec() { + addFilter(); + return m_testSpec; + } + + void TestSpecParser::visitChar( char c ) { + if( m_mode == None ) { + switch( c ) { + case ' ': return; + case '~': m_exclusion = true; return; + case '[': return startNewMode( Tag, ++m_pos ); + case '"': return startNewMode( QuotedName, ++m_pos ); + case '\\': return escape(); + default: startNewMode( Name, m_pos ); break; + } + } + if( m_mode == Name ) { + if( c == ',' ) { + addPattern(); + addFilter(); + } + else if( c == '[' ) { + if( subString() == "exclude:" ) + m_exclusion = true; + else + addPattern(); + startNewMode( Tag, ++m_pos ); + } + else if( c == '\\' ) + escape(); + } + else if( m_mode == EscapedName ) + m_mode = Name; + else if( m_mode == QuotedName && c == '"' ) + addPattern(); + else if( m_mode == Tag && c == ']' ) + addPattern(); + } + void TestSpecParser::startNewMode( Mode mode, std::size_t start ) { + m_mode = mode; + m_start = start; + } + void TestSpecParser::escape() { + if( m_mode == None ) + m_start = m_pos; + m_mode = EscapedName; + m_escapeChars.push_back( m_pos ); + } + std::string TestSpecParser::subString() const { return m_arg.substr( m_start, m_pos - m_start ); } + + void TestSpecParser::addFilter() { + if( !m_currentFilter.m_patterns.empty() ) { + m_testSpec.m_filters.push_back( m_currentFilter ); + m_currentFilter = TestSpec::Filter(); + } + } + + TestSpec parseTestSpec( std::string const& arg ) { + return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec(); + } + +} // namespace Catch +// end catch_test_spec_parser.cpp +// start catch_timer.cpp + +#include + +namespace Catch { + + auto getCurrentNanosecondsSinceEpoch() -> uint64_t { + return std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); + } + + auto estimateClockResolution() -> uint64_t { + uint64_t sum = 0; + static const uint64_t iterations = 1000000; + + for( std::size_t i = 0; i < iterations; ++i ) { + + uint64_t ticks; + uint64_t baseTicks = getCurrentNanosecondsSinceEpoch(); + do { + ticks = getCurrentNanosecondsSinceEpoch(); + } + while( ticks == baseTicks ); + + auto delta = ticks - baseTicks; + sum += delta; + } + + // We're just taking the mean, here. To do better we could take the std. dev and exclude outliers + // - and potentially do more iterations if there's a high variance. + return sum/iterations; + } + auto getEstimatedClockResolution() -> uint64_t { + static auto s_resolution = estimateClockResolution(); + return s_resolution; + } + + void Timer::start() { + m_nanoseconds = getCurrentNanosecondsSinceEpoch(); + } + auto Timer::getElapsedNanoseconds() const -> unsigned int { + return static_cast(getCurrentNanosecondsSinceEpoch() - m_nanoseconds); + } + auto Timer::getElapsedMicroseconds() const -> unsigned int { + return static_cast(getElapsedNanoseconds()/1000); + } + auto Timer::getElapsedMilliseconds() const -> unsigned int { + return static_cast(getElapsedMicroseconds()/1000); + } + auto Timer::getElapsedSeconds() const -> double { + return getElapsedMicroseconds()/1000000.0; + } + +} // namespace Catch +// end catch_timer.cpp +// start catch_tostring.cpp + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + +#include + +namespace Catch { + +namespace Detail { + + const std::string unprintableString = "{?}"; + + namespace { + const int hexThreshold = 255; + + struct Endianness { + enum Arch { Big, Little }; + + static Arch which() { + union _{ + int asInt; + char asChar[sizeof (int)]; + } u; + + u.asInt = 1; + return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little; + } + }; + } + + std::string rawMemoryToString( const void *object, std::size_t size ) { + // Reverse order for little endian architectures + int i = 0, end = static_cast( size ), inc = 1; + if( Endianness::which() == Endianness::Little ) { + i = end-1; + end = inc = -1; + } + + unsigned char const *bytes = static_cast(object); + std::ostringstream os; + os << "0x" << std::setfill('0') << std::hex; + for( ; i != end; i += inc ) + os << std::setw(2) << static_cast(bytes[i]); + return os.str(); + } +} + +template +std::string fpToString( T value, int precision ) { + std::ostringstream oss; + oss << std::setprecision( precision ) + << std::fixed + << value; + std::string d = oss.str(); + std::size_t i = d.find_last_not_of( '0' ); + if( i != std::string::npos && i != d.size()-1 ) { + if( d[i] == '.' ) + i++; + d = d.substr( 0, i+1 ); + } + return d; +} + +//// ======================================================= //// +// +// Out-of-line defs for full specialization of StringMaker +// +//// ======================================================= //// + +std::string StringMaker::convert(const std::string& str) { + if (!getCurrentContext().getConfig()->showInvisibles()) { + return '"' + str + '"'; + } + + std::string s("\""); + for (char c : str) { + switch (c) { + case '\n': + s.append("\\n"); + break; + case '\t': + s.append("\\t"); + break; + default: + s.push_back(c); + break; + } + } + s.append("\""); + return s; +} + +std::string StringMaker::convert(const std::wstring& wstr) { + std::string s; + s.reserve(wstr.size()); + for (auto c : wstr) { + s += (c <= 0xff) ? static_cast(c) : '?'; + } + return ::Catch::Detail::stringify(s); +} + +std::string StringMaker::convert(char const* str) { + if (str) { + return ::Catch::Detail::stringify(std::string{ str }); + } else { + return{ "{null string}" }; + } +} +std::string StringMaker::convert(char* str) { + if (str) { + return ::Catch::Detail::stringify(std::string{ str }); + } else { + return{ "{null string}" }; + } +} +std::string StringMaker::convert(wchar_t const * str) { + if (str) { + return ::Catch::Detail::stringify(std::wstring{ str }); + } else { + return{ "{null string}" }; + } +} +std::string StringMaker::convert(wchar_t * str) { + if (str) { + return ::Catch::Detail::stringify(std::wstring{ str }); + } else { + return{ "{null string}" }; + } +} + +std::string StringMaker::convert(int value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(long value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(long long value) { + std::ostringstream oss; + oss << value; + if (value > Detail::hexThreshold) { + oss << " (0x" << std::hex << value << ')'; + } + return oss.str(); +} + +std::string StringMaker::convert(unsigned int value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(unsigned long value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(unsigned long long value) { + std::ostringstream oss; + oss << value; + if (value > Detail::hexThreshold) { + oss << " (0x" << std::hex << value << ')'; + } + return oss.str(); +} + +std::string StringMaker::convert(bool b) { + return b ? "true" : "false"; +} + +std::string StringMaker::convert(char value) { + if (value == '\r') { + return "'\\r'"; + } else if (value == '\f') { + return "'\\f'"; + } else if (value == '\n') { + return "'\\n'"; + } else if (value == '\t') { + return "'\\t'"; + } else if ('\0' <= value && value < ' ') { + return ::Catch::Detail::stringify(static_cast(value)); + } else { + char chstr[] = "' '"; + chstr[1] = value; + return chstr; + } +} +std::string StringMaker::convert(signed char c) { + return ::Catch::Detail::stringify(static_cast(c)); +} +std::string StringMaker::convert(unsigned char c) { + return ::Catch::Detail::stringify(static_cast(c)); +} + +std::string StringMaker::convert(std::nullptr_t) { + return "nullptr"; +} + +std::string StringMaker::convert(float value) { + return fpToString(value, 5) + 'f'; +} +std::string StringMaker::convert(double value) { + return fpToString(value, 10); +} + +} // end namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + +// end catch_tostring.cpp +// start catch_totals.cpp + +namespace Catch { + + Counts Counts::operator - ( Counts const& other ) const { + Counts diff; + diff.passed = passed - other.passed; + diff.failed = failed - other.failed; + diff.failedButOk = failedButOk - other.failedButOk; + return diff; + } + + Counts& Counts::operator += ( Counts const& other ) { + passed += other.passed; + failed += other.failed; + failedButOk += other.failedButOk; + return *this; + } + + std::size_t Counts::total() const { + return passed + failed + failedButOk; + } + bool Counts::allPassed() const { + return failed == 0 && failedButOk == 0; + } + bool Counts::allOk() const { + return failed == 0; + } + + Totals Totals::operator - ( Totals const& other ) const { + Totals diff; + diff.assertions = assertions - other.assertions; + diff.testCases = testCases - other.testCases; + return diff; + } + + Totals& Totals::operator += ( Totals const& other ) { + assertions += other.assertions; + testCases += other.testCases; + return *this; + } + + Totals Totals::delta( Totals const& prevTotals ) const { + Totals diff = *this - prevTotals; + if( diff.assertions.failed > 0 ) + ++diff.testCases.failed; + else if( diff.assertions.failedButOk > 0 ) + ++diff.testCases.failedButOk; + else + ++diff.testCases.passed; + return diff; + } + +} +// end catch_totals.cpp +// start catch_version.cpp + +#include + +namespace Catch { + + Version::Version + ( unsigned int _majorVersion, + unsigned int _minorVersion, + unsigned int _patchNumber, + char const * const _branchName, + unsigned int _buildNumber ) + : majorVersion( _majorVersion ), + minorVersion( _minorVersion ), + patchNumber( _patchNumber ), + branchName( _branchName ), + buildNumber( _buildNumber ) + {} + + std::ostream& operator << ( std::ostream& os, Version const& version ) { + os << version.majorVersion << '.' + << version.minorVersion << '.' + << version.patchNumber; + // branchName is never null -> 0th char is \0 if it is empty + if (version.branchName[0]) { + os << '-' << version.branchName + << '.' << version.buildNumber; + } + return os; + } + + Version const& libraryVersion() { + static Version version( 2, 0, 1, "", 0 ); + return version; + } + +} +// end catch_version.cpp +// start catch_wildcard_pattern.cpp + +namespace Catch { + + WildcardPattern::WildcardPattern( std::string const& pattern, + CaseSensitive::Choice caseSensitivity ) + : m_caseSensitivity( caseSensitivity ), + m_pattern( adjustCase( pattern ) ) + { + if( startsWith( m_pattern, '*' ) ) { + m_pattern = m_pattern.substr( 1 ); + m_wildcard = WildcardAtStart; + } + if( endsWith( m_pattern, '*' ) ) { + m_pattern = m_pattern.substr( 0, m_pattern.size()-1 ); + m_wildcard = static_cast( m_wildcard | WildcardAtEnd ); + } + } + + bool WildcardPattern::matches( std::string const& str ) const { + switch( m_wildcard ) { + case NoWildcard: + return m_pattern == adjustCase( str ); + case WildcardAtStart: + return endsWith( adjustCase( str ), m_pattern ); + case WildcardAtEnd: + return startsWith( adjustCase( str ), m_pattern ); + case WildcardAtBothEnds: + return contains( adjustCase( str ), m_pattern ); + default: + CATCH_INTERNAL_ERROR( "Unknown enum" ); + } + } + + std::string WildcardPattern::adjustCase( std::string const& str ) const { + return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str; + } +} +// end catch_wildcard_pattern.cpp +// start catch_xmlwriter.cpp + +// start catch_xmlwriter.h + +#include +#include + +namespace Catch { + + class XmlEncode { + public: + enum ForWhat { ForTextNodes, ForAttributes }; + + XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ); + + void encodeTo( std::ostream& os ) const; + + friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ); + + private: + std::string m_str; + ForWhat m_forWhat; + }; + + class XmlWriter { + public: + + class ScopedElement { + public: + ScopedElement( XmlWriter* writer ); + + ScopedElement( ScopedElement&& other ) noexcept; + ScopedElement& operator=( ScopedElement&& other ) noexcept; + + ~ScopedElement(); + + ScopedElement& writeText( std::string const& text, bool indent = true ); + + template + ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { + m_writer->writeAttribute( name, attribute ); + return *this; + } + + private: + mutable XmlWriter* m_writer = nullptr; + }; + + XmlWriter( std::ostream& os = Catch::cout() ); + ~XmlWriter(); + + XmlWriter( XmlWriter const& ) = delete; + XmlWriter& operator=( XmlWriter const& ) = delete; + + XmlWriter& startElement( std::string const& name ); + + ScopedElement scopedElement( std::string const& name ); + + XmlWriter& endElement(); + + XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ); + + XmlWriter& writeAttribute( std::string const& name, bool attribute ); + + template + XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { + m_oss.clear(); + m_oss.str(std::string()); + m_oss << attribute; + return writeAttribute( name, m_oss.str() ); + } + + XmlWriter& writeText( std::string const& text, bool indent = true ); + + XmlWriter& writeComment( std::string const& text ); + + void writeStylesheetRef( std::string const& url ); + + XmlWriter& writeBlankLine(); + + void ensureTagClosed(); + + private: + + void writeDeclaration(); + + void newlineIfNecessary(); + + bool m_tagIsOpen = false; + bool m_needsNewline = false; + std::vector m_tags; + std::string m_indent; + std::ostream& m_os; + std::ostringstream m_oss; + }; + +} + +// end catch_xmlwriter.h +#include + +namespace Catch { + + XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat ) + : m_str( str ), + m_forWhat( forWhat ) + {} + + void XmlEncode::encodeTo( std::ostream& os ) const { + + // Apostrophe escaping not necessary if we always use " to write attributes + // (see: http://www.w3.org/TR/xml/#syntax) + + for( std::size_t i = 0; i < m_str.size(); ++ i ) { + char c = m_str[i]; + switch( c ) { + case '<': os << "<"; break; + case '&': os << "&"; break; + + case '>': + // See: http://www.w3.org/TR/xml/#syntax + if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' ) + os << ">"; + else + os << c; + break; + + case '\"': + if( m_forWhat == ForAttributes ) + os << """; + else + os << c; + break; + + default: + // Escape control chars - based on contribution by @espenalb in PR #465 and + // by @mrpi PR #588 + if ( ( c >= 0 && c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' ) { + // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0 + os << "\\x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) + << static_cast( c ); + } + else + os << c; + } + } + } + + std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { + xmlEncode.encodeTo( os ); + return os; + } + + XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer ) + : m_writer( writer ) + {} + + XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) noexcept + : m_writer( other.m_writer ){ + other.m_writer = nullptr; + } + XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) noexcept { + if ( m_writer ) { + m_writer->endElement(); + } + m_writer = other.m_writer; + other.m_writer = nullptr; + return *this; + } + + XmlWriter::ScopedElement::~ScopedElement() { + if( m_writer ) + m_writer->endElement(); + } + + XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, bool indent ) { + m_writer->writeText( text, indent ); + return *this; + } + + XmlWriter::XmlWriter( std::ostream& os ) : m_os( os ) + { + writeDeclaration(); + } + + XmlWriter::~XmlWriter() { + while( !m_tags.empty() ) + endElement(); + } + + XmlWriter& XmlWriter::startElement( std::string const& name ) { + ensureTagClosed(); + newlineIfNecessary(); + m_os << m_indent << '<' << name; + m_tags.push_back( name ); + m_indent += " "; + m_tagIsOpen = true; + return *this; + } + + XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name ) { + ScopedElement scoped( this ); + startElement( name ); + return scoped; + } + + XmlWriter& XmlWriter::endElement() { + newlineIfNecessary(); + m_indent = m_indent.substr( 0, m_indent.size()-2 ); + if( m_tagIsOpen ) { + m_os << "/>"; + m_tagIsOpen = false; + } + else { + m_os << m_indent << ""; + } + m_os << std::endl; + m_tags.pop_back(); + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, std::string const& attribute ) { + if( !name.empty() && !attribute.empty() ) + m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, bool attribute ) { + m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeText( std::string const& text, bool indent ) { + if( !text.empty() ){ + bool tagWasOpen = m_tagIsOpen; + ensureTagClosed(); + if( tagWasOpen && indent ) + m_os << m_indent; + m_os << XmlEncode( text ); + m_needsNewline = true; + } + return *this; + } + + XmlWriter& XmlWriter::writeComment( std::string const& text ) { + ensureTagClosed(); + m_os << m_indent << ""; + m_needsNewline = true; + return *this; + } + + void XmlWriter::writeStylesheetRef( std::string const& url ) { + m_os << "\n"; + } + + XmlWriter& XmlWriter::writeBlankLine() { + ensureTagClosed(); + m_os << '\n'; + return *this; + } + + void XmlWriter::ensureTagClosed() { + if( m_tagIsOpen ) { + m_os << ">" << std::endl; + m_tagIsOpen = false; + } + } + + void XmlWriter::writeDeclaration() { + m_os << "\n"; + } + + void XmlWriter::newlineIfNecessary() { + if( m_needsNewline ) { + m_os << std::endl; + m_needsNewline = false; + } + } +} +// end catch_xmlwriter.cpp +// start catch_reporter_bases.cpp + +#include +#include +#include +#include +#include + +namespace Catch { + void prepareExpandedExpression(AssertionResult& result) { + result.getExpandedExpression(); + } + + // Because formatting using c++ streams is stateful, drop down to C is required + // Alternatively we could use stringstream, but its performance is... not good. + std::string getFormattedDuration( double duration ) { + // Max exponent + 1 is required to represent the whole part + // + 1 for decimal point + // + 3 for the 3 decimal places + // + 1 for null terminator + const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1; + char buffer[maxDoubleSize]; + + // Save previous errno, to prevent sprintf from overwriting it + ErrnoGuard guard; +#ifdef _MSC_VER + sprintf_s(buffer, "%.3f", duration); +#else + sprintf(buffer, "%.3f", duration); +#endif + return std::string(buffer); + } + + TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config) + :StreamingReporterBase(_config) {} + + void TestEventListenerBase::assertionStarting(AssertionInfo const &) {} + + bool TestEventListenerBase::assertionEnded(AssertionStats const &) { + return false; + } + +} // end namespace Catch +// end catch_reporter_bases.cpp +// start catch_reporter_compact.cpp + +namespace { + +#ifdef CATCH_PLATFORM_MAC + const char* failedString() { return "FAILED"; } + const char* passedString() { return "PASSED"; } +#else + const char* failedString() { return "failed"; } + const char* passedString() { return "passed"; } +#endif + + // Colour::LightGrey + Catch::Colour::Code dimColour() { return Catch::Colour::FileName; } + + std::string bothOrAll( std::size_t count ) { + return count == 1 ? std::string() : + count == 2 ? "both " : "all " ; + } +} + +namespace Catch { + + struct CompactReporter : StreamingReporterBase { + + using StreamingReporterBase::StreamingReporterBase; + + ~CompactReporter() override; + + static std::string getDescription() { + return "Reports test results on a single line, suitable for IDEs"; + } + + ReporterPreferences getPreferences() const override { + ReporterPreferences prefs; + prefs.shouldRedirectStdOut = false; + return prefs; + } + + void noMatchingTestCases( std::string const& spec ) override { + stream << "No test cases matched '" << spec << '\'' << std::endl; + } + + void assertionStarting( AssertionInfo const& ) override {} + + bool assertionEnded( AssertionStats const& _assertionStats ) override { + AssertionResult const& result = _assertionStats.assertionResult; + + bool printInfoMessages = true; + + // Drop out if result was successful and we're not printing those + if( !m_config->includeSuccessfulResults() && result.isOk() ) { + if( result.getResultType() != ResultWas::Warning ) + return false; + printInfoMessages = false; + } + + AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); + printer.print(); + + stream << std::endl; + return true; + } + + void sectionEnded(SectionStats const& _sectionStats) override { + if (m_config->showDurations() == ShowDurations::Always) { + stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; + } + } + + void testRunEnded( TestRunStats const& _testRunStats ) override { + printTotals( _testRunStats.totals ); + stream << '\n' << std::endl; + StreamingReporterBase::testRunEnded( _testRunStats ); + } + + private: + class AssertionPrinter { + public: + AssertionPrinter& operator= ( AssertionPrinter const& ) = delete; + AssertionPrinter( AssertionPrinter const& ) = delete; + AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) + : stream( _stream ) + , result( _stats.assertionResult ) + , messages( _stats.infoMessages ) + , itMessage( _stats.infoMessages.begin() ) + , printInfoMessages( _printInfoMessages ) + {} + + void print() { + printSourceInfo(); + + itMessage = messages.begin(); + + switch( result.getResultType() ) { + case ResultWas::Ok: + printResultType( Colour::ResultSuccess, passedString() ); + printOriginalExpression(); + printReconstructedExpression(); + if ( ! result.hasExpression() ) + printRemainingMessages( Colour::None ); + else + printRemainingMessages(); + break; + case ResultWas::ExpressionFailed: + if( result.isOk() ) + printResultType( Colour::ResultSuccess, failedString() + std::string( " - but was ok" ) ); + else + printResultType( Colour::Error, failedString() ); + printOriginalExpression(); + printReconstructedExpression(); + printRemainingMessages(); + break; + case ResultWas::ThrewException: + printResultType( Colour::Error, failedString() ); + printIssue( "unexpected exception with message:" ); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::FatalErrorCondition: + printResultType( Colour::Error, failedString() ); + printIssue( "fatal error condition with message:" ); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::DidntThrowException: + printResultType( Colour::Error, failedString() ); + printIssue( "expected exception, got none" ); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::Info: + printResultType( Colour::None, "info" ); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::Warning: + printResultType( Colour::None, "warning" ); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::ExplicitFailure: + printResultType( Colour::Error, failedString() ); + printIssue( "explicitly" ); + printRemainingMessages( Colour::None ); + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + printResultType( Colour::Error, "** internal error **" ); + break; + } + } + + private: + void printSourceInfo() const { + Colour colourGuard( Colour::FileName ); + stream << result.getSourceInfo() << ':'; + } + + void printResultType( Colour::Code colour, std::string const& passOrFail ) const { + if( !passOrFail.empty() ) { + { + Colour colourGuard( colour ); + stream << ' ' << passOrFail; + } + stream << ':'; + } + } + + void printIssue( std::string const& issue ) const { + stream << ' ' << issue; + } + + void printExpressionWas() { + if( result.hasExpression() ) { + stream << ';'; + { + Colour colour( dimColour() ); + stream << " expression was:"; + } + printOriginalExpression(); + } + } + + void printOriginalExpression() const { + if( result.hasExpression() ) { + stream << ' ' << result.getExpression(); + } + } + + void printReconstructedExpression() const { + if( result.hasExpandedExpression() ) { + { + Colour colour( dimColour() ); + stream << " for: "; + } + stream << result.getExpandedExpression(); + } + } + + void printMessage() { + if ( itMessage != messages.end() ) { + stream << " '" << itMessage->message << '\''; + ++itMessage; + } + } + + void printRemainingMessages( Colour::Code colour = dimColour() ) { + if ( itMessage == messages.end() ) + return; + + // using messages.end() directly yields (or auto) compilation error: + std::vector::const_iterator itEnd = messages.end(); + const std::size_t N = static_cast( std::distance( itMessage, itEnd ) ); + + { + Colour colourGuard( colour ); + stream << " with " << pluralise( N, "message" ) << ':'; + } + + for(; itMessage != itEnd; ) { + // If this assertion is a warning ignore any INFO messages + if( printInfoMessages || itMessage->type != ResultWas::Info ) { + stream << " '" << itMessage->message << '\''; + if ( ++itMessage != itEnd ) { + Colour colourGuard( dimColour() ); + stream << " and"; + } + } + } + } + + private: + std::ostream& stream; + AssertionResult const& result; + std::vector messages; + std::vector::const_iterator itMessage; + bool printInfoMessages; + }; + + // Colour, message variants: + // - white: No tests ran. + // - red: Failed [both/all] N test cases, failed [both/all] M assertions. + // - white: Passed [both/all] N test cases (no assertions). + // - red: Failed N tests cases, failed M assertions. + // - green: Passed [both/all] N tests cases with M assertions. + + void printTotals( const Totals& totals ) const { + if( totals.testCases.total() == 0 ) { + stream << "No tests ran."; + } + else if( totals.testCases.failed == totals.testCases.total() ) { + Colour colour( Colour::ResultError ); + const std::string qualify_assertions_failed = + totals.assertions.failed == totals.assertions.total() ? + bothOrAll( totals.assertions.failed ) : std::string(); + stream << + "Failed " << bothOrAll( totals.testCases.failed ) + << pluralise( totals.testCases.failed, "test case" ) << ", " + "failed " << qualify_assertions_failed << + pluralise( totals.assertions.failed, "assertion" ) << '.'; + } + else if( totals.assertions.total() == 0 ) { + stream << + "Passed " << bothOrAll( totals.testCases.total() ) + << pluralise( totals.testCases.total(), "test case" ) + << " (no assertions)."; + } + else if( totals.assertions.failed ) { + Colour colour( Colour::ResultError ); + stream << + "Failed " << pluralise( totals.testCases.failed, "test case" ) << ", " + "failed " << pluralise( totals.assertions.failed, "assertion" ) << '.'; + } + else { + Colour colour( Colour::ResultSuccess ); + stream << + "Passed " << bothOrAll( totals.testCases.passed ) + << pluralise( totals.testCases.passed, "test case" ) << + " with " << pluralise( totals.assertions.passed, "assertion" ) << '.'; + } + } + }; + + CompactReporter::~CompactReporter() {} + + CATCH_REGISTER_REPORTER( "compact", CompactReporter ) + +} // end namespace Catch +// end catch_reporter_compact.cpp +// start catch_reporter_console.cpp + +#include +#include + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + +namespace Catch { + + namespace { + std::size_t makeRatio( std::size_t number, std::size_t total ) { + std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0; + return ( ratio == 0 && number > 0 ) ? 1 : ratio; + } + + std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) { + if( i > j && i > k ) + return i; + else if( j > k ) + return j; + else + return k; + } + + struct ColumnInfo { + enum Justification { Left, Right }; + std::string name; + int width; + Justification justification; + }; + struct ColumnBreak {}; + struct RowBreak {}; + + class TablePrinter { + std::ostream& m_os; + std::vector m_columnInfos; + std::ostringstream m_oss; + int m_currentColumn = -1; + bool m_isOpen = false; + + public: + TablePrinter( std::ostream& os, std::vector const& columnInfos ) + : m_os( os ), + m_columnInfos( columnInfos ) + {} + + auto columnInfos() const -> std::vector const& { + return m_columnInfos; + } + + void open() { + if( !m_isOpen ) { + m_isOpen = true; + *this << RowBreak(); + for( auto const& info : m_columnInfos ) + *this << info.name << ColumnBreak(); + *this << RowBreak(); + m_os << Catch::getLineOfChars<'-'>() << "\n"; + } + } + void close() { + if( m_isOpen ) { + *this << RowBreak(); + m_os << std::endl; + m_isOpen = false; + } + } + + template + friend TablePrinter& operator << ( TablePrinter& tp, T const& value ) { + tp.m_oss << value; + return tp; + } + + friend TablePrinter& operator << ( TablePrinter& tp, ColumnBreak ) { + auto colStr = tp.m_oss.str(); + // This takes account of utf8 encodings + auto strSize = Catch::StringRef( colStr ).numberOfCharacters(); + tp.m_oss.str(""); + tp.open(); + if( tp.m_currentColumn == static_cast(tp.m_columnInfos.size()-1) ) { + tp.m_currentColumn = -1; + tp.m_os << "\n"; + } + tp.m_currentColumn++; + + auto colInfo = tp.m_columnInfos[tp.m_currentColumn]; + auto padding = ( strSize+2 < static_cast( colInfo.width ) ) + ? std::string( colInfo.width-(strSize+2), ' ' ) + : std::string(); + if( colInfo.justification == ColumnInfo::Left ) + tp.m_os << colStr << padding << " "; + else + tp.m_os << padding << colStr << " "; + return tp; + } + + friend TablePrinter& operator << ( TablePrinter& tp, RowBreak ) { + if( tp.m_currentColumn > 0 ) { + tp.m_os << "\n"; + tp.m_currentColumn = -1; + } + return tp; + } + }; + + class Duration { + enum class Unit { + Auto, + Nanoseconds, + Microseconds, + Milliseconds, + Seconds, + Minutes + }; + static const uint64_t s_nanosecondsInAMicrosecond = 1000; + static const uint64_t s_nanosecondsInAMillisecond = 1000*s_nanosecondsInAMicrosecond; + static const uint64_t s_nanosecondsInASecond = 1000*s_nanosecondsInAMillisecond; + static const uint64_t s_nanosecondsInAMinute = 60*s_nanosecondsInASecond; + + uint64_t m_inNanoseconds; + Unit m_units; + + public: + Duration( uint64_t inNanoseconds, Unit units = Unit::Auto ) + : m_inNanoseconds( inNanoseconds ), + m_units( units ) + { + if( m_units == Unit::Auto ) { + if( m_inNanoseconds < s_nanosecondsInAMicrosecond ) + m_units = Unit::Nanoseconds; + else if( m_inNanoseconds < s_nanosecondsInAMillisecond ) + m_units = Unit::Microseconds; + else if( m_inNanoseconds < s_nanosecondsInASecond ) + m_units = Unit::Milliseconds; + else if( m_inNanoseconds < s_nanosecondsInAMinute ) + m_units = Unit::Seconds; + else + m_units = Unit::Minutes; + } + + } + + auto value() const -> double { + switch( m_units ) { + case Unit::Microseconds: + return m_inNanoseconds / static_cast( s_nanosecondsInAMicrosecond ); + case Unit::Milliseconds: + return m_inNanoseconds / static_cast( s_nanosecondsInAMillisecond ); + case Unit::Seconds: + return m_inNanoseconds / static_cast( s_nanosecondsInASecond ); + case Unit::Minutes: + return m_inNanoseconds / static_cast( s_nanosecondsInAMinute ); + default: + return static_cast( m_inNanoseconds ); + } + } + auto unitsAsString() const -> std::string { + switch( m_units ) { + case Unit::Nanoseconds: + return "ns"; + case Unit::Microseconds: + return "µs"; + case Unit::Milliseconds: + return "ms"; + case Unit::Seconds: + return "s"; + case Unit::Minutes: + return "m"; + default: + return "** internal error **"; + } + + } + friend auto operator << ( std::ostream& os, Duration const& duration ) -> std::ostream& { + return os << duration.value() << " " << duration.unitsAsString(); + } + }; + } // end anon namespace + + struct ConsoleReporter : StreamingReporterBase { + TablePrinter m_tablePrinter; + + ConsoleReporter( ReporterConfig const& config ) + : StreamingReporterBase( config ), + m_tablePrinter( config.stream(), + { + { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH-32, ColumnInfo::Left }, + { "iters", 8, ColumnInfo::Right }, + { "elapsed ns", 14, ColumnInfo::Right }, + { "average", 14, ColumnInfo::Right } + } ) + {} + ~ConsoleReporter() override; + static std::string getDescription() { + return "Reports test results as plain lines of text"; + } + + void noMatchingTestCases( std::string const& spec ) override { + stream << "No test cases matched '" << spec << '\'' << std::endl; + } + + void assertionStarting( AssertionInfo const& ) override { + } + + bool assertionEnded( AssertionStats const& _assertionStats ) override { + AssertionResult const& result = _assertionStats.assertionResult; + + bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); + + // Drop out if result was successful but we're not printing them. + if( !includeResults && result.getResultType() != ResultWas::Warning ) + return false; + + lazyPrint(); + + AssertionPrinter printer( stream, _assertionStats, includeResults ); + printer.print(); + stream << std::endl; + return true; + } + + void sectionStarting( SectionInfo const& _sectionInfo ) override { + m_headerPrinted = false; + StreamingReporterBase::sectionStarting( _sectionInfo ); + } + void sectionEnded( SectionStats const& _sectionStats ) override { + m_tablePrinter.close(); + if( _sectionStats.missingAssertions ) { + lazyPrint(); + Colour colour( Colour::ResultError ); + if( m_sectionStack.size() > 1 ) + stream << "\nNo assertions in section"; + else + stream << "\nNo assertions in test case"; + stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; + } + if( m_config->showDurations() == ShowDurations::Always ) { + stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; + } + if( m_headerPrinted ) { + m_headerPrinted = false; + } + StreamingReporterBase::sectionEnded( _sectionStats ); + } + + void benchmarkStarting( BenchmarkInfo const& info ) override { + lazyPrintWithoutClosingBenchmarkTable(); + + auto nameCol = Column( info.name ).width( m_tablePrinter.columnInfos()[0].width-2 ); + + bool firstLine = true; + for( auto line : nameCol ) { + if( !firstLine ) + m_tablePrinter << ColumnBreak() << ColumnBreak() << ColumnBreak(); + else + firstLine = false; + + m_tablePrinter << line << ColumnBreak(); + } + } + void benchmarkEnded( BenchmarkStats const& stats ) override { + Duration average( stats.elapsedTimeInNanoseconds/stats.iterations ); + m_tablePrinter + << stats.iterations << ColumnBreak() + << stats.elapsedTimeInNanoseconds << ColumnBreak() + << average << ColumnBreak(); + } + + void testCaseEnded( TestCaseStats const& _testCaseStats ) override { + m_tablePrinter.close(); + StreamingReporterBase::testCaseEnded( _testCaseStats ); + m_headerPrinted = false; + } + void testGroupEnded( TestGroupStats const& _testGroupStats ) override { + if( currentGroupInfo.used ) { + printSummaryDivider(); + stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n"; + printTotals( _testGroupStats.totals ); + stream << '\n' << std::endl; + } + StreamingReporterBase::testGroupEnded( _testGroupStats ); + } + void testRunEnded( TestRunStats const& _testRunStats ) override { + printTotalsDivider( _testRunStats.totals ); + printTotals( _testRunStats.totals ); + stream << std::endl; + StreamingReporterBase::testRunEnded( _testRunStats ); + } + + private: + + class AssertionPrinter { + public: + AssertionPrinter& operator= ( AssertionPrinter const& ) = delete; + AssertionPrinter( AssertionPrinter const& ) = delete; + AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) + : stream( _stream ), + stats( _stats ), + result( _stats.assertionResult ), + colour( Colour::None ), + message( result.getMessage() ), + messages( _stats.infoMessages ), + printInfoMessages( _printInfoMessages ) + { + switch( result.getResultType() ) { + case ResultWas::Ok: + colour = Colour::Success; + passOrFail = "PASSED"; + //if( result.hasMessage() ) + if( _stats.infoMessages.size() == 1 ) + messageLabel = "with message"; + if( _stats.infoMessages.size() > 1 ) + messageLabel = "with messages"; + break; + case ResultWas::ExpressionFailed: + if( result.isOk() ) { + colour = Colour::Success; + passOrFail = "FAILED - but was ok"; + } + else { + colour = Colour::Error; + passOrFail = "FAILED"; + } + if( _stats.infoMessages.size() == 1 ) + messageLabel = "with message"; + if( _stats.infoMessages.size() > 1 ) + messageLabel = "with messages"; + break; + case ResultWas::ThrewException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to unexpected exception with "; + if (_stats.infoMessages.size() == 1) + messageLabel += "message"; + if (_stats.infoMessages.size() > 1) + messageLabel += "messages"; + break; + case ResultWas::FatalErrorCondition: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to a fatal error condition"; + break; + case ResultWas::DidntThrowException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "because no exception was thrown where one was expected"; + break; + case ResultWas::Info: + messageLabel = "info"; + break; + case ResultWas::Warning: + messageLabel = "warning"; + break; + case ResultWas::ExplicitFailure: + passOrFail = "FAILED"; + colour = Colour::Error; + if( _stats.infoMessages.size() == 1 ) + messageLabel = "explicitly with message"; + if( _stats.infoMessages.size() > 1 ) + messageLabel = "explicitly with messages"; + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + passOrFail = "** internal error **"; + colour = Colour::Error; + break; + } + } + + void print() const { + printSourceInfo(); + if( stats.totals.assertions.total() > 0 ) { + if( result.isOk() ) + stream << '\n'; + printResultType(); + printOriginalExpression(); + printReconstructedExpression(); + } + else { + stream << '\n'; + } + printMessage(); + } + + private: + void printResultType() const { + if( !passOrFail.empty() ) { + Colour colourGuard( colour ); + stream << passOrFail << ":\n"; + } + } + void printOriginalExpression() const { + if( result.hasExpression() ) { + Colour colourGuard( Colour::OriginalExpression ); + stream << " "; + stream << result.getExpressionInMacro(); + stream << '\n'; + } + } + void printReconstructedExpression() const { + if( result.hasExpandedExpression() ) { + stream << "with expansion:\n"; + Colour colourGuard( Colour::ReconstructedExpression ); + stream << Column( result.getExpandedExpression() ).indent(2) << '\n'; + } + } + void printMessage() const { + if( !messageLabel.empty() ) + stream << messageLabel << ':' << '\n'; + for( auto const& msg : messages ) { + // If this assertion is a warning ignore any INFO messages + if( printInfoMessages || msg.type != ResultWas::Info ) + stream << Column( msg.message ).indent(2) << '\n'; + } + } + void printSourceInfo() const { + Colour colourGuard( Colour::FileName ); + stream << result.getSourceInfo() << ": "; + } + + std::ostream& stream; + AssertionStats const& stats; + AssertionResult const& result; + Colour::Code colour; + std::string passOrFail; + std::string messageLabel; + std::string message; + std::vector messages; + bool printInfoMessages; + }; + + void lazyPrint() { + + m_tablePrinter.close(); + lazyPrintWithoutClosingBenchmarkTable(); + } + + void lazyPrintWithoutClosingBenchmarkTable() { + + if( !currentTestRunInfo.used ) + lazyPrintRunInfo(); + if( !currentGroupInfo.used ) + lazyPrintGroupInfo(); + + if( !m_headerPrinted ) { + printTestCaseAndSectionHeader(); + m_headerPrinted = true; + } + } + void lazyPrintRunInfo() { + stream << '\n' << getLineOfChars<'~'>() << '\n'; + Colour colour( Colour::SecondaryText ); + stream << currentTestRunInfo->name + << " is a Catch v" << libraryVersion() << " host application.\n" + << "Run with -? for options\n\n"; + + if( m_config->rngSeed() != 0 ) + stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; + + currentTestRunInfo.used = true; + } + void lazyPrintGroupInfo() { + if( !currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1 ) { + printClosedHeader( "Group: " + currentGroupInfo->name ); + currentGroupInfo.used = true; + } + } + void printTestCaseAndSectionHeader() { + assert( !m_sectionStack.empty() ); + printOpenHeader( currentTestCaseInfo->name ); + + if( m_sectionStack.size() > 1 ) { + Colour colourGuard( Colour::Headers ); + + auto + it = m_sectionStack.begin()+1, // Skip first section (test case) + itEnd = m_sectionStack.end(); + for( ; it != itEnd; ++it ) + printHeaderString( it->name, 2 ); + } + + SourceLineInfo lineInfo = m_sectionStack.back().lineInfo; + + if( !lineInfo.empty() ){ + stream << getLineOfChars<'-'>() << '\n'; + Colour colourGuard( Colour::FileName ); + stream << lineInfo << '\n'; + } + stream << getLineOfChars<'.'>() << '\n' << std::endl; + } + + void printClosedHeader( std::string const& _name ) { + printOpenHeader( _name ); + stream << getLineOfChars<'.'>() << '\n'; + } + void printOpenHeader( std::string const& _name ) { + stream << getLineOfChars<'-'>() << '\n'; + { + Colour colourGuard( Colour::Headers ); + printHeaderString( _name ); + } + } + + // if string has a : in first line will set indent to follow it on + // subsequent lines + void printHeaderString( std::string const& _string, std::size_t indent = 0 ) { + std::size_t i = _string.find( ": " ); + if( i != std::string::npos ) + i+=2; + else + i = 0; + stream << Column( _string ).indent( indent+i ).initialIndent( indent ) << '\n'; + } + + struct SummaryColumn { + + SummaryColumn( std::string const& _label, Colour::Code _colour ) + : label( _label ), + colour( _colour ) + {} + SummaryColumn addRow( std::size_t count ) { + std::ostringstream oss; + oss << count; + std::string row = oss.str(); + for( auto& oldRow : rows ) { + while( oldRow.size() < row.size() ) + oldRow = ' ' + oldRow; + while( oldRow.size() > row.size() ) + row = ' ' + row; + } + rows.push_back( row ); + return *this; + } + + std::string label; + Colour::Code colour; + std::vector rows; + + }; + + void printTotals( Totals const& totals ) { + if( totals.testCases.total() == 0 ) { + stream << Colour( Colour::Warning ) << "No tests ran\n"; + } + else if( totals.assertions.total() > 0 && totals.testCases.allPassed() ) { + stream << Colour( Colour::ResultSuccess ) << "All tests passed"; + stream << " (" + << pluralise( totals.assertions.passed, "assertion" ) << " in " + << pluralise( totals.testCases.passed, "test case" ) << ')' + << '\n'; + } + else { + + std::vector columns; + columns.push_back( SummaryColumn( "", Colour::None ) + .addRow( totals.testCases.total() ) + .addRow( totals.assertions.total() ) ); + columns.push_back( SummaryColumn( "passed", Colour::Success ) + .addRow( totals.testCases.passed ) + .addRow( totals.assertions.passed ) ); + columns.push_back( SummaryColumn( "failed", Colour::ResultError ) + .addRow( totals.testCases.failed ) + .addRow( totals.assertions.failed ) ); + columns.push_back( SummaryColumn( "failed as expected", Colour::ResultExpectedFailure ) + .addRow( totals.testCases.failedButOk ) + .addRow( totals.assertions.failedButOk ) ); + + printSummaryRow( "test cases", columns, 0 ); + printSummaryRow( "assertions", columns, 1 ); + } + } + void printSummaryRow( std::string const& label, std::vector const& cols, std::size_t row ) { + for( auto col : cols ) { + std::string value = col.rows[row]; + if( col.label.empty() ) { + stream << label << ": "; + if( value != "0" ) + stream << value; + else + stream << Colour( Colour::Warning ) << "- none -"; + } + else if( value != "0" ) { + stream << Colour( Colour::LightGrey ) << " | "; + stream << Colour( col.colour ) + << value << ' ' << col.label; + } + } + stream << '\n'; + } + + void printTotalsDivider( Totals const& totals ) { + if( totals.testCases.total() > 0 ) { + std::size_t failedRatio = makeRatio( totals.testCases.failed, totals.testCases.total() ); + std::size_t failedButOkRatio = makeRatio( totals.testCases.failedButOk, totals.testCases.total() ); + std::size_t passedRatio = makeRatio( totals.testCases.passed, totals.testCases.total() ); + while( failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH-1 ) + findMax( failedRatio, failedButOkRatio, passedRatio )++; + while( failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH-1 ) + findMax( failedRatio, failedButOkRatio, passedRatio )--; + + stream << Colour( Colour::Error ) << std::string( failedRatio, '=' ); + stream << Colour( Colour::ResultExpectedFailure ) << std::string( failedButOkRatio, '=' ); + if( totals.testCases.allPassed() ) + stream << Colour( Colour::ResultSuccess ) << std::string( passedRatio, '=' ); + else + stream << Colour( Colour::Success ) << std::string( passedRatio, '=' ); + } + else { + stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' ); + } + stream << '\n'; + } + void printSummaryDivider() { + stream << getLineOfChars<'-'>() << '\n'; + } + + private: + bool m_headerPrinted = false; + }; + + CATCH_REGISTER_REPORTER( "console", ConsoleReporter ) + + ConsoleReporter::~ConsoleReporter() {} + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif +// end catch_reporter_console.cpp +// start catch_reporter_junit.cpp + +#include + +#include +#include + +namespace Catch { + + namespace { + std::string getCurrentTimestamp() { + // Beware, this is not reentrant because of backward compatibility issues + // Also, UTC only, again because of backward compatibility (%z is C++11) + time_t rawtime; + std::time(&rawtime); + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); + +#ifdef _MSC_VER + std::tm timeInfo = {}; + gmtime_s(&timeInfo, &rawtime); +#else + std::tm* timeInfo; + timeInfo = std::gmtime(&rawtime); +#endif + + char timeStamp[timeStampSize]; + const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; + +#ifdef _MSC_VER + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); +#else + std::strftime(timeStamp, timeStampSize, fmt, timeInfo); +#endif + return std::string(timeStamp); + } + + std::string fileNameTag(const std::vector &tags) { + auto it = std::find_if(begin(tags), + end(tags), + [] (std::string const& tag) {return tag.front() == '#'; }); + if (it != tags.end()) + return it->substr(1); + return std::string(); + } + } + + class JunitReporter : public CumulativeReporterBase { + public: + JunitReporter( ReporterConfig const& _config ) + : CumulativeReporterBase( _config ), + xml( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = true; + } + + ~JunitReporter() override; + + static std::string getDescription() { + return "Reports test results in an XML format that looks like Ant's junitreport target"; + } + + void noMatchingTestCases( std::string const& /*spec*/ ) override {} + + void testRunStarting( TestRunInfo const& runInfo ) override { + CumulativeReporterBase::testRunStarting( runInfo ); + xml.startElement( "testsuites" ); + } + + void testGroupStarting( GroupInfo const& groupInfo ) override { + suiteTimer.start(); + stdOutForSuite.str(""); + stdErrForSuite.str(""); + unexpectedExceptions = 0; + CumulativeReporterBase::testGroupStarting( groupInfo ); + } + + void testCaseStarting( TestCaseInfo const& testCaseInfo ) override { + m_okToFail = testCaseInfo.okToFail(); + } + bool assertionEnded( AssertionStats const& assertionStats ) override { + if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail ) + unexpectedExceptions++; + return CumulativeReporterBase::assertionEnded( assertionStats ); + } + + void testCaseEnded( TestCaseStats const& testCaseStats ) override { + stdOutForSuite << testCaseStats.stdOut; + stdErrForSuite << testCaseStats.stdErr; + CumulativeReporterBase::testCaseEnded( testCaseStats ); + } + + void testGroupEnded( TestGroupStats const& testGroupStats ) override { + double suiteTime = suiteTimer.getElapsedSeconds(); + CumulativeReporterBase::testGroupEnded( testGroupStats ); + writeGroup( *m_testGroups.back(), suiteTime ); + } + + void testRunEndedCumulative() override { + xml.endElement(); + } + + void writeGroup( TestGroupNode const& groupNode, double suiteTime ) { + XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" ); + TestGroupStats const& stats = groupNode.value; + xml.writeAttribute( "name", stats.groupInfo.name ); + xml.writeAttribute( "errors", unexpectedExceptions ); + xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions ); + xml.writeAttribute( "tests", stats.totals.assertions.total() ); + xml.writeAttribute( "hostname", "tbd" ); // !TBD + if( m_config->showDurations() == ShowDurations::Never ) + xml.writeAttribute( "time", "" ); + else + xml.writeAttribute( "time", suiteTime ); + xml.writeAttribute( "timestamp", getCurrentTimestamp() ); + + // Write test cases + for( auto const& child : groupNode.children ) + writeTestCase( *child ); + + xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite.str() ), false ); + xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite.str() ), false ); + } + + void writeTestCase( TestCaseNode const& testCaseNode ) { + TestCaseStats const& stats = testCaseNode.value; + + // All test cases have exactly one section - which represents the + // test case itself. That section may have 0-n nested sections + assert( testCaseNode.children.size() == 1 ); + SectionNode const& rootSection = *testCaseNode.children.front(); + + std::string className = stats.testInfo.className; + + if( className.empty() ) { + className = fileNameTag(stats.testInfo.tags); + if ( className.empty() ) + className = "global"; + } + + if ( !m_config->name().empty() ) + className = m_config->name() + "." + className; + + writeSection( className, "", rootSection ); + } + + void writeSection( std::string const& className, + std::string const& rootName, + SectionNode const& sectionNode ) { + std::string name = trim( sectionNode.stats.sectionInfo.name ); + if( !rootName.empty() ) + name = rootName + '/' + name; + + if( !sectionNode.assertions.empty() || + !sectionNode.stdOut.empty() || + !sectionNode.stdErr.empty() ) { + XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); + if( className.empty() ) { + xml.writeAttribute( "classname", name ); + xml.writeAttribute( "name", "root" ); + } + else { + xml.writeAttribute( "classname", className ); + xml.writeAttribute( "name", name ); + } + xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) ); + + writeAssertions( sectionNode ); + + if( !sectionNode.stdOut.empty() ) + xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false ); + if( !sectionNode.stdErr.empty() ) + xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false ); + } + for( auto const& childNode : sectionNode.childSections ) + if( className.empty() ) + writeSection( name, "", *childNode ); + else + writeSection( className, name, *childNode ); + } + + void writeAssertions( SectionNode const& sectionNode ) { + for( auto const& assertion : sectionNode.assertions ) + writeAssertion( assertion ); + } + void writeAssertion( AssertionStats const& stats ) { + AssertionResult const& result = stats.assertionResult; + if( !result.isOk() ) { + std::string elementName; + switch( result.getResultType() ) { + case ResultWas::ThrewException: + case ResultWas::FatalErrorCondition: + elementName = "error"; + break; + case ResultWas::ExplicitFailure: + elementName = "failure"; + break; + case ResultWas::ExpressionFailed: + elementName = "failure"; + break; + case ResultWas::DidntThrowException: + elementName = "failure"; + break; + + // We should never see these here: + case ResultWas::Info: + case ResultWas::Warning: + case ResultWas::Ok: + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + elementName = "internalError"; + break; + } + + XmlWriter::ScopedElement e = xml.scopedElement( elementName ); + + xml.writeAttribute( "message", result.getExpandedExpression() ); + xml.writeAttribute( "type", result.getTestMacroName() ); + + std::ostringstream oss; + if( !result.getMessage().empty() ) + oss << result.getMessage() << '\n'; + for( auto const& msg : stats.infoMessages ) + if( msg.type == ResultWas::Info ) + oss << msg.message << '\n'; + + oss << "at " << result.getSourceInfo(); + xml.writeText( oss.str(), false ); + } + } + + XmlWriter xml; + Timer suiteTimer; + std::ostringstream stdOutForSuite; + std::ostringstream stdErrForSuite; + unsigned int unexpectedExceptions = 0; + bool m_okToFail = false; + }; + + JunitReporter::~JunitReporter() {} + CATCH_REGISTER_REPORTER( "junit", JunitReporter ) + +} // end namespace Catch +// end catch_reporter_junit.cpp +// start catch_reporter_multi.cpp + +namespace Catch { + + void MultipleReporters::add( IStreamingReporterPtr&& reporter ) { + m_reporters.push_back( std::move( reporter ) ); + } + + ReporterPreferences MultipleReporters::getPreferences() const { + return m_reporters[0]->getPreferences(); + } + + std::set MultipleReporters::getSupportedVerbosities() { + return std::set{ }; + } + + void MultipleReporters::noMatchingTestCases( std::string const& spec ) { + for( auto const& reporter : m_reporters ) + reporter->noMatchingTestCases( spec ); + } + + void MultipleReporters::benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) { + for( auto const& reporter : m_reporters ) + reporter->benchmarkStarting( benchmarkInfo ); + } + void MultipleReporters::benchmarkEnded( BenchmarkStats const& benchmarkStats ) { + for( auto const& reporter : m_reporters ) + reporter->benchmarkEnded( benchmarkStats ); + } + + void MultipleReporters::testRunStarting( TestRunInfo const& testRunInfo ) { + for( auto const& reporter : m_reporters ) + reporter->testRunStarting( testRunInfo ); + } + + void MultipleReporters::testGroupStarting( GroupInfo const& groupInfo ) { + for( auto const& reporter : m_reporters ) + reporter->testGroupStarting( groupInfo ); + } + + void MultipleReporters::testCaseStarting( TestCaseInfo const& testInfo ) { + for( auto const& reporter : m_reporters ) + reporter->testCaseStarting( testInfo ); + } + + void MultipleReporters::sectionStarting( SectionInfo const& sectionInfo ) { + for( auto const& reporter : m_reporters ) + reporter->sectionStarting( sectionInfo ); + } + + void MultipleReporters::assertionStarting( AssertionInfo const& assertionInfo ) { + for( auto const& reporter : m_reporters ) + reporter->assertionStarting( assertionInfo ); + } + + // The return value indicates if the messages buffer should be cleared: + bool MultipleReporters::assertionEnded( AssertionStats const& assertionStats ) { + bool clearBuffer = false; + for( auto const& reporter : m_reporters ) + clearBuffer |= reporter->assertionEnded( assertionStats ); + return clearBuffer; + } + + void MultipleReporters::sectionEnded( SectionStats const& sectionStats ) { + for( auto const& reporter : m_reporters ) + reporter->sectionEnded( sectionStats ); + } + + void MultipleReporters::testCaseEnded( TestCaseStats const& testCaseStats ) { + for( auto const& reporter : m_reporters ) + reporter->testCaseEnded( testCaseStats ); + } + + void MultipleReporters::testGroupEnded( TestGroupStats const& testGroupStats ) { + for( auto const& reporter : m_reporters ) + reporter->testGroupEnded( testGroupStats ); + } + + void MultipleReporters::testRunEnded( TestRunStats const& testRunStats ) { + for( auto const& reporter : m_reporters ) + reporter->testRunEnded( testRunStats ); + } + + void MultipleReporters::skipTest( TestCaseInfo const& testInfo ) { + for( auto const& reporter : m_reporters ) + reporter->skipTest( testInfo ); + } + + bool MultipleReporters::isMulti() const { + return true; + } + +} // end namespace Catch +// end catch_reporter_multi.cpp +// start catch_reporter_xml.cpp + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + +namespace Catch { + class XmlReporter : public StreamingReporterBase { + public: + XmlReporter( ReporterConfig const& _config ) + : StreamingReporterBase( _config ), + m_xml(_config.stream()) + { + m_reporterPrefs.shouldRedirectStdOut = true; + } + + ~XmlReporter() override; + + static std::string getDescription() { + return "Reports test results as an XML document"; + } + + virtual std::string getStylesheetRef() const { + return std::string(); + } + + void writeSourceInfo( SourceLineInfo const& sourceInfo ) { + m_xml + .writeAttribute( "filename", sourceInfo.file ) + .writeAttribute( "line", sourceInfo.line ); + } + + public: // StreamingReporterBase + + void noMatchingTestCases( std::string const& s ) override { + StreamingReporterBase::noMatchingTestCases( s ); + } + + void testRunStarting( TestRunInfo const& testInfo ) override { + StreamingReporterBase::testRunStarting( testInfo ); + std::string stylesheetRef = getStylesheetRef(); + if( !stylesheetRef.empty() ) + m_xml.writeStylesheetRef( stylesheetRef ); + m_xml.startElement( "Catch" ); + if( !m_config->name().empty() ) + m_xml.writeAttribute( "name", m_config->name() ); + } + + void testGroupStarting( GroupInfo const& groupInfo ) override { + StreamingReporterBase::testGroupStarting( groupInfo ); + m_xml.startElement( "Group" ) + .writeAttribute( "name", groupInfo.name ); + } + + void testCaseStarting( TestCaseInfo const& testInfo ) override { + StreamingReporterBase::testCaseStarting(testInfo); + m_xml.startElement( "TestCase" ) + .writeAttribute( "name", trim( testInfo.name ) ) + .writeAttribute( "description", testInfo.description ) + .writeAttribute( "tags", testInfo.tagsAsString() ); + + writeSourceInfo( testInfo.lineInfo ); + + if ( m_config->showDurations() == ShowDurations::Always ) + m_testCaseTimer.start(); + m_xml.ensureTagClosed(); + } + + void sectionStarting( SectionInfo const& sectionInfo ) override { + StreamingReporterBase::sectionStarting( sectionInfo ); + if( m_sectionDepth++ > 0 ) { + m_xml.startElement( "Section" ) + .writeAttribute( "name", trim( sectionInfo.name ) ) + .writeAttribute( "description", sectionInfo.description ); + writeSourceInfo( sectionInfo.lineInfo ); + m_xml.ensureTagClosed(); + } + } + + void assertionStarting( AssertionInfo const& ) override { } + + bool assertionEnded( AssertionStats const& assertionStats ) override { + + AssertionResult const& result = assertionStats.assertionResult; + + bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); + + if( includeResults ) { + // Print any info messages in tags. + for( auto const& msg : assertionStats.infoMessages ) { + if( msg.type == ResultWas::Info ) { + m_xml.scopedElement( "Info" ) + .writeText( msg.message ); + } else if ( msg.type == ResultWas::Warning ) { + m_xml.scopedElement( "Warning" ) + .writeText( msg.message ); + } + } + } + + // Drop out if result was successful but we're not printing them. + if( !includeResults && result.getResultType() != ResultWas::Warning ) + return true; + + // Print the expression if there is one. + if( result.hasExpression() ) { + m_xml.startElement( "Expression" ) + .writeAttribute( "success", result.succeeded() ) + .writeAttribute( "type", result.getTestMacroName() ); + + writeSourceInfo( result.getSourceInfo() ); + + m_xml.scopedElement( "Original" ) + .writeText( result.getExpression() ); + m_xml.scopedElement( "Expanded" ) + .writeText( result.getExpandedExpression() ); + } + + // And... Print a result applicable to each result type. + switch( result.getResultType() ) { + case ResultWas::ThrewException: + m_xml.startElement( "Exception" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + case ResultWas::FatalErrorCondition: + m_xml.startElement( "FatalErrorCondition" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + case ResultWas::Info: + m_xml.scopedElement( "Info" ) + .writeText( result.getMessage() ); + break; + case ResultWas::Warning: + // Warning will already have been written + break; + case ResultWas::ExplicitFailure: + m_xml.startElement( "Failure" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + default: + break; + } + + if( result.hasExpression() ) + m_xml.endElement(); + + return true; + } + + void sectionEnded( SectionStats const& sectionStats ) override { + StreamingReporterBase::sectionEnded( sectionStats ); + if( --m_sectionDepth > 0 ) { + XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); + e.writeAttribute( "successes", sectionStats.assertions.passed ); + e.writeAttribute( "failures", sectionStats.assertions.failed ); + e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk ); + + if ( m_config->showDurations() == ShowDurations::Always ) + e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds ); + + m_xml.endElement(); + } + } + + void testCaseEnded( TestCaseStats const& testCaseStats ) override { + StreamingReporterBase::testCaseEnded( testCaseStats ); + XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); + e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() ); + + if ( m_config->showDurations() == ShowDurations::Always ) + e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); + + if( !testCaseStats.stdOut.empty() ) + m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), false ); + if( !testCaseStats.stdErr.empty() ) + m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), false ); + + m_xml.endElement(); + } + + void testGroupEnded( TestGroupStats const& testGroupStats ) override { + StreamingReporterBase::testGroupEnded( testGroupStats ); + // TODO: Check testGroupStats.aborting and act accordingly. + m_xml.scopedElement( "OverallResults" ) + .writeAttribute( "successes", testGroupStats.totals.assertions.passed ) + .writeAttribute( "failures", testGroupStats.totals.assertions.failed ) + .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); + m_xml.endElement(); + } + + void testRunEnded( TestRunStats const& testRunStats ) override { + StreamingReporterBase::testRunEnded( testRunStats ); + m_xml.scopedElement( "OverallResults" ) + .writeAttribute( "successes", testRunStats.totals.assertions.passed ) + .writeAttribute( "failures", testRunStats.totals.assertions.failed ) + .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ); + m_xml.endElement(); + } + + private: + Timer m_testCaseTimer; + XmlWriter m_xml; + int m_sectionDepth = 0; + }; + + XmlReporter::~XmlReporter() {} + CATCH_REGISTER_REPORTER( "xml", XmlReporter ) + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif +// end catch_reporter_xml.cpp + +namespace Catch { + LeakDetector leakDetector; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_impl.hpp +#endif + +#ifdef CATCH_CONFIG_MAIN +// start catch_default_main.hpp + +#ifndef __OBJC__ + +#if defined(WIN32) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) +// Standard C/C++ Win32 Unicode wmain entry point +extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) { +#else +// Standard C/C++ main entry point +int main (int argc, char * argv[]) { +#endif + + return Catch::Session().run( argc, argv ); +} + +#else // __OBJC__ + +// Objective-C entry point +int main (int argc, char * const argv[]) { +#if !CATCH_ARC_ENABLED + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; +#endif + + Catch::registerTestMethods(); + int result = Catch::Session().run( argc, (char**)argv ); + +#if !CATCH_ARC_ENABLED + [pool drain]; +#endif + + return result; +} + +#endif // __OBJC__ + +// end catch_default_main.hpp +#endif + +#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED +# undef CLARA_CONFIG_MAIN +#endif + +#if !defined(CATCH_CONFIG_DISABLE) +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", __VA_ARGS__ ) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", __VA_ARGS__ ) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) +#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) +#define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc ) +#define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc ) +#define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc ) +#define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc ) +#define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc ) + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) +#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) + +#define GIVEN( desc ) SECTION( std::string(" Given: ") + desc ) +#define WHEN( desc ) SECTION( std::string(" When: ") + desc ) +#define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc ) +#define THEN( desc ) SECTION( std::string(" Then: ") + desc ) +#define AND_THEN( desc ) SECTION( std::string(" And: ") + desc ) + +using Catch::Detail::Approx; + +#else +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) (void)(0) +#define CATCH_REQUIRE_FALSE( ... ) (void)(0) + +#define CATCH_REQUIRE_THROWS( ... ) (void)(0) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) (void)(0) + +#define CATCH_CHECK( ... ) (void)(0) +#define CATCH_CHECK_FALSE( ... ) (void)(0) +#define CATCH_CHECKED_IF( ... ) if (__VA_ARGS__) +#define CATCH_CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CATCH_CHECK_NOFAIL( ... ) (void)(0) + +#define CATCH_CHECK_THROWS( ... ) (void)(0) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) (void)(0) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) (void)(0) + +#define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) (void)(0) +#define CATCH_WARN( msg ) (void)(0) +#define CATCH_CAPTURE( msg ) (void)(0) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define CATCH_SECTION( ... ) +#define CATCH_FAIL( ... ) (void)(0) +#define CATCH_FAIL_CHECK( ... ) (void)(0) +#define CATCH_SUCCEED( ... ) (void)(0) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) +#define CATCH_GIVEN( desc ) +#define CATCH_WHEN( desc ) +#define CATCH_AND_WHEN( desc ) +#define CATCH_THEN( desc ) +#define CATCH_AND_THEN( desc ) + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) (void)(0) +#define REQUIRE_FALSE( ... ) (void)(0) + +#define REQUIRE_THROWS( ... ) (void)(0) +#define REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) (void)(0) + +#define CHECK( ... ) (void)(0) +#define CHECK_FALSE( ... ) (void)(0) +#define CHECKED_IF( ... ) if (__VA_ARGS__) +#define CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CHECK_NOFAIL( ... ) (void)(0) + +#define CHECK_THROWS( ... ) (void)(0) +#define CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) (void)(0) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) (void)(0) + +#define REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) (void)(0) +#define WARN( msg ) (void)(0) +#define CAPTURE( msg ) (void)(0) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define METHOD_AS_TEST_CASE( method, ... ) +#define REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define SECTION( ... ) +#define FAIL( ... ) (void)(0) +#define FAIL_CHECK( ... ) (void)(0) +#define SUCCEED( ... ) (void)(0) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) + +#define GIVEN( desc ) +#define WHEN( desc ) +#define AND_WHEN( desc ) +#define THEN( desc ) +#define AND_THEN( desc ) + +using Catch::Detail::Approx; + +#endif + +// start catch_reenable_warnings.h + + +#ifdef __clang__ +# ifdef __ICC // icpc defines the __clang__ macro +# pragma warning(pop) +# else +# pragma clang diagnostic pop +# endif +#elif defined __GNUC__ +# pragma GCC diagnostic pop +#endif + +// end catch_reenable_warnings.h +// end catch.hpp +#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED + diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/makefile b/dep/scintilla/scintilla-3.10.6/test/unit/makefile similarity index 92% rename from dep/scintilla/scintilla-3.6.0/test/unit/makefile rename to dep/scintilla/scintilla-3.10.6/test/unit/makefile index 68339110..51c4950d 100644 --- a/dep/scintilla/scintilla-3.6.0/test/unit/makefile +++ b/dep/scintilla/scintilla-3.10.6/test/unit/makefile @@ -47,11 +47,14 @@ CXXFLAGS += -Wall -Wextra TESTSRC=test*.cxx # Files being tested from scintilla/src directory TESTEDSRC=\ + ../../lexlib/WordList.cxx \ ../../src/CellBuffer.cxx \ ../../src/CharClassify.cxx \ ../../src/ContractionState.cxx \ ../../src/Decoration.cxx \ - ../../src/RunStyles.cxx + ../../src/RunStyles.cxx \ + ../../src/UniConversion.cxx \ + ../../src/UniqueString.cxx TESTS=$(EXE) diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/test.mak b/dep/scintilla/scintilla-3.10.6/test/unit/test.mak similarity index 84% rename from dep/scintilla/scintilla-3.6.0/test/unit/test.mak rename to dep/scintilla/scintilla-3.10.6/test/unit/test.mak index 934b0aa1..228689d2 100644 --- a/dep/scintilla/scintilla-3.6.0/test/unit/test.mak +++ b/dep/scintilla/scintilla-3.10.6/test/unit/test.mak @@ -12,11 +12,14 @@ CXXFLAGS = /EHsc /wd 4805 $(INCLUDEDIRS) TESTSRC=test*.cxx # Files being tested from scintilla/src directory TESTEDSRC=\ + ../../lexlib/WordList.cxx \ ../../src/CellBuffer.cxx \ ../../src/CharClassify.cxx \ ../../src/ContractionState.cxx \ ../../src/Decoration.cxx \ - ../../src/RunStyles.cxx + ../../src/RunStyles.cxx \ + ../../src/UniConversion.cxx \ + ../../src/UniqueString.cxx TESTS=$(EXE) diff --git a/dep/scintilla/scintilla-3.10.6/test/unit/testCellBuffer.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testCellBuffer.cxx new file mode 100644 index 00000000..ab0b8aca --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testCellBuffer.cxx @@ -0,0 +1,434 @@ +// Unit Tests for Scintilla internal data structures + +#include +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "Scintilla.h" +#include "Position.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h" +#include "CellBuffer.h" + +#include "catch.hpp" + +using namespace Scintilla; + +// Test CellBuffer. + +TEST_CASE("CellBuffer") { + + const char sText[] = "Scintilla"; + const Sci::Position sLength = static_cast(strlen(sText)); + + CellBuffer cb(true, false); + + SECTION("InsertOneLine") { + bool startSequence = false; + const char *cpChange = cb.InsertString(0, sText, static_cast(sLength), startSequence); + REQUIRE(startSequence); + REQUIRE(sLength == cb.Length()); + REQUIRE(memcmp(cpChange, sText, sLength) == 0); + REQUIRE(1 == cb.Lines()); + REQUIRE(0 == cb.LineStart(0)); + REQUIRE(0 == cb.LineFromPosition(0)); + REQUIRE(sLength == cb.LineStart(1)); + REQUIRE(0 == cb.LineFromPosition(static_cast(sLength))); + REQUIRE(cb.CanUndo()); + REQUIRE(!cb.CanRedo()); + } + + SECTION("InsertTwoLines") { + const char sText2[] = "Two\nLines"; + const Sci::Position sLength2 = static_cast(strlen(sText2)); + bool startSequence = false; + const char *cpChange = cb.InsertString(0, sText2, static_cast(sLength), startSequence); + REQUIRE(startSequence); + REQUIRE(sLength2 == cb.Length()); + REQUIRE(memcmp(cpChange, sText2, sLength2) == 0); + REQUIRE(2 == cb.Lines()); + REQUIRE(0 == cb.LineStart(0)); + REQUIRE(0 == cb.LineFromPosition(0)); + REQUIRE(4 == cb.LineStart(1)); + REQUIRE(1 == cb.LineFromPosition(5)); + REQUIRE(sLength2 == cb.LineStart(2)); + REQUIRE(1 == cb.LineFromPosition(static_cast(sLength))); + REQUIRE(cb.CanUndo()); + REQUIRE(!cb.CanRedo()); + } + + SECTION("UndoOff") { + REQUIRE(cb.IsCollectingUndo()); + cb.SetUndoCollection(false); + REQUIRE(!cb.IsCollectingUndo()); + bool startSequence = false; + const char *cpChange = cb.InsertString(0, sText, static_cast(sLength), startSequence); + REQUIRE(!startSequence); + REQUIRE(sLength == cb.Length()); + REQUIRE(memcmp(cpChange, sText, sLength) == 0); + REQUIRE(!cb.CanUndo()); + REQUIRE(!cb.CanRedo()); + } + + SECTION("UndoRedo") { + const char sTextDeleted[] = "ci"; + const char sTextAfterDeletion[] = "Sntilla"; + bool startSequence = false; + const char *cpChange = cb.InsertString(0, sText, static_cast(sLength), startSequence); + REQUIRE(startSequence); + REQUIRE(sLength == cb.Length()); + REQUIRE(memcmp(cpChange, sText, sLength) == 0); + REQUIRE(memcmp(cb.BufferPointer(), sText, sLength) == 0); + REQUIRE(cb.CanUndo()); + REQUIRE(!cb.CanRedo()); + const char *cpDeletion = cb.DeleteChars(1, 2, startSequence); + REQUIRE(startSequence); + REQUIRE(memcmp(cpDeletion, sTextDeleted, strlen(sTextDeleted)) == 0); + REQUIRE(memcmp(cb.BufferPointer(), sTextAfterDeletion, strlen(sTextAfterDeletion)) == 0); + REQUIRE(cb.CanUndo()); + REQUIRE(!cb.CanRedo()); + + int steps = cb.StartUndo(); + REQUIRE(steps == 1); + cb.PerformUndoStep(); + REQUIRE(memcmp(cb.BufferPointer(), sText, sLength) == 0); + REQUIRE(cb.CanUndo()); + REQUIRE(cb.CanRedo()); + + steps = cb.StartUndo(); + REQUIRE(steps == 1); + cb.PerformUndoStep(); + REQUIRE(cb.Length() == 0); + REQUIRE(!cb.CanUndo()); + REQUIRE(cb.CanRedo()); + + steps = cb.StartRedo(); + REQUIRE(steps == 1); + cb.PerformRedoStep(); + REQUIRE(memcmp(cb.BufferPointer(), sText, sLength) == 0); + REQUIRE(cb.CanUndo()); + REQUIRE(cb.CanRedo()); + + steps = cb.StartRedo(); + REQUIRE(steps == 1); + cb.PerformRedoStep(); + REQUIRE(memcmp(cb.BufferPointer(), sTextAfterDeletion, strlen(sTextAfterDeletion)) == 0); + REQUIRE(cb.CanUndo()); + REQUIRE(!cb.CanRedo()); + + cb.DeleteUndoHistory(); + REQUIRE(!cb.CanUndo()); + REQUIRE(!cb.CanRedo()); + } + + SECTION("LineEndTypes") { + REQUIRE(cb.GetLineEndTypes() == 0); + cb.SetLineEndTypes(1); + REQUIRE(cb.GetLineEndTypes() == 1); + cb.SetLineEndTypes(0); + REQUIRE(cb.GetLineEndTypes() == 0); + } + + SECTION("ReadOnly") { + REQUIRE(!cb.IsReadOnly()); + cb.SetReadOnly(true); + REQUIRE(cb.IsReadOnly()); + bool startSequence = false; + cb.InsertString(0, sText, static_cast(sLength), startSequence); + REQUIRE(cb.Length() == 0); + } + +} + +TEST_CASE("CharacterIndex") { + + CellBuffer cb(true, false); + + SECTION("Setup") { + REQUIRE(cb.LineCharacterIndex() == SC_LINECHARACTERINDEX_NONE); + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 0); + cb.SetUTF8Substance(true); + + cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16); + REQUIRE(cb.LineCharacterIndex() == SC_LINECHARACTERINDEX_UTF16); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 0); + + cb.ReleaseLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16); + REQUIRE(cb.LineCharacterIndex() == SC_LINECHARACTERINDEX_NONE); + } + + SECTION("Insertion") { + cb.SetUTF8Substance(true); + + cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32); + + bool startSequence = false; + cb.InsertString(0, "a", 1, startSequence); + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 1); + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 1); + + const char *hwair = "\xF0\x90\x8D\x88"; + cb.InsertString(0, hwair, strlen(hwair), startSequence); + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3); + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2); + } + + SECTION("Deletion") { + cb.SetUTF8Substance(true); + + cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32); + + bool startSequence = false; + const char *hwair = "a\xF0\x90\x8D\x88z"; + cb.InsertString(0, hwair, strlen(hwair), startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 4); + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3); + + cb.DeleteChars(5, 1, startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3); + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2); + + cb.DeleteChars(1, 4, startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 1); + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 1); + } + + SECTION("Insert Complex") { + cb.SetUTF8Substance(true); + cb.SetLineEndTypes(1); + cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32); + + bool startSequence = false; + // 3 lines of text containing 8 bytes + const char *data = "a\n\xF0\x90\x8D\x88\nz"; + cb.InsertString(0, data, strlen(data), startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 5); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 6); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 5); + + // Insert a new line at end -> "a\n\xF0\x90\x8D\x88\nz\n" 4 lines + // Last line empty + cb.InsertString(strlen(data), "\n", 1, startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 5); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 7); + REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF16) == 7); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 6); + REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF32) == 6); + + // Insert a new line before end -> "a\n\xF0\x90\x8D\x88\nz\n\n" 5 lines + cb.InsertString(strlen(data), "\n", 1, startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 5); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 7); + REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF16) == 8); + REQUIRE(cb.IndexLineStart(5, SC_LINECHARACTERINDEX_UTF16) == 8); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 6); + REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF32) == 7); + REQUIRE(cb.IndexLineStart(5, SC_LINECHARACTERINDEX_UTF32) == 7); + + // Insert a valid 3-byte UTF-8 character at start -> + // "\xE2\x82\xACa\n\xF0\x90\x8D\x88\nz\n\n" 5 lines + + const char *euro = "\xE2\x82\xAC"; + cb.InsertString(0, euro, strlen(euro), startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 6); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 8); + REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF16) == 9); + REQUIRE(cb.IndexLineStart(5, SC_LINECHARACTERINDEX_UTF16) == 9); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 5); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 7); + REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF32) == 8); + REQUIRE(cb.IndexLineStart(5, SC_LINECHARACTERINDEX_UTF32) == 8); + + // Insert a lone lead byte implying a 3 byte character at start of line 2 -> + // "\xE2\x82\xACa\n\EF\xF0\x90\x8D\x88\nz\n\n" 5 lines + // Should be treated as a single byte character + + const char *lead = "\xEF"; + cb.InsertString(5, lead, strlen(lead), startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 7); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 9); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 6); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 8); + + // Insert an ASCII lead byte inside the 3-byte initial character -> + // "\xE2!\x82\xACa\n\EF\xF0\x90\x8D\x88\nz\n\n" 5 lines + // It should b treated as a single character and should cause the + // byte before and the 2 bytes after also be each treated as singles + // so 3 more characters on line 0. + + const char *ascii = "!"; + cb.InsertString(1, ascii, strlen(ascii), startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 6); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 10); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 6); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 9); + + // Insert a NEL after the '!' to trigger the utf8 line end case -> + // "\xE2!\xC2\x85 \x82\xACa\n \EF\xF0\x90\x8D\x88\n z\n\n" 5 lines + + const char *nel = "\xC2\x85"; + cb.InsertString(2, nel, strlen(nel), startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 7); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 11); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 7); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 10); + } + + SECTION("Delete Multiple lines") { + cb.SetUTF8Substance(true); + cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32); + + bool startSequence = false; + // 3 lines of text containing 8 bytes + const char *data = "a\n\xF0\x90\x8D\x88\nz\nc"; + cb.InsertString(0, data, strlen(data), startSequence); + + // Delete first 2 new lines -> "az\nc" + cb.DeleteChars(1, strlen(data) - 4, startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 4); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4); + } + + SECTION("Delete Complex") { + cb.SetUTF8Substance(true); + cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32); + + bool startSequence = false; + // 3 lines of text containing 8 bytes + const char *data = "a\n\xF0\x90\x8D\x88\nz"; + cb.InsertString(0, data, strlen(data), startSequence); + + // Delete lead byte from character on line 1 -> + // "a\n\x90\x8D\x88\nz" + // line 1 becomes 4 single byte characters + cb.DeleteChars(2, 1, startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 6); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 7); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 6); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 7); + + // Delete first new line -> + // "a\x90\x8D\x88\nz" + // Only 2 lines with line 0 containing 5 single byte characters + cb.DeleteChars(1, 1, startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 5); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 6); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 5); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 6); + + // Restore lead byte from character on line 0 making a 4-byte character -> + // "a\xF0\x90\x8D\x88\nz" + + const char *lead4 = "\xF0"; + cb.InsertString(1, lead4, strlen(lead4), startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 4); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 5); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4); + } + + SECTION("Insert separates new line bytes") { + cb.SetUTF8Substance(true); + cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32); + + bool startSequence = false; + // 2 lines of text containing 4 bytes + const char *data = "a\r\nb"; + cb.InsertString(0, data, strlen(data), startSequence); + + // 3 lines of text containing 5 bytes -> + // "a\r!\nb" + const char *ascii = "!"; + cb.InsertString(2, ascii, strlen(ascii), startSequence); + + REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0); + REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2); + REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 4); + REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 5); + } +} diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/testCharClassify.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testCharClassify.cxx similarity index 81% rename from dep/scintilla/scintilla-3.6.0/test/unit/testCharClassify.cxx rename to dep/scintilla/scintilla-3.10.6/test/unit/testCharClassify.cxx index c1e6cf53..879a3648 100644 --- a/dep/scintilla/scintilla-3.6.0/test/unit/testCharClassify.cxx +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testCharClassify.cxx @@ -1,8 +1,11 @@ // Unit Tests for Scintilla internal data structures -#include +#include +#include #include +#include +#include #include "Platform.h" @@ -10,14 +13,16 @@ #include "catch.hpp" +using namespace Scintilla; + // Test CharClassify. class CharClassifyTest { - // Avoid warnings, private so never called. - CharClassifyTest(const CharClassifyTest &); + // Avoid warnings, deleted so never called. + CharClassifyTest(const CharClassifyTest &) = delete; protected: CharClassifyTest() { - pcc = new CharClassify(); + pcc.reset(new CharClassify()); for (int ch = 0; ch < 256; ch++) { if (ch == '\r' || ch == '\n') charClass[ch] = CharClassify::ccNewLine; @@ -31,11 +36,9 @@ protected: } ~CharClassifyTest() { - delete pcc; - pcc = 0; } - CharClassify *pcc; + std::unique_ptr pcc; CharClassify::cc charClass[256]; static const char* GetClassName(CharClassify::cc charClass) { @@ -92,30 +95,28 @@ TEST_CASE_METHOD(CharClassifyTest, "CharsOfClass") { for (int classVal = 0; classVal < 4; ++classVal) { CharClassify::cc thisClass = CharClassify::cc(classVal % 4); int size = pcc->GetCharsOfClass(thisClass, NULL); - unsigned char* buffer = new unsigned char[size + 1]; - buffer[size] = '\0'; - pcc->GetCharsOfClass(thisClass, buffer); + std::vector buffer(size+1); + pcc->GetCharsOfClass(thisClass, &buffer[0]); for (int i = 1; i < 256; i++) { if (charClass[i] == thisClass) { - if (!memchr(reinterpret_cast(buffer), i, size)) + if (!memchr(reinterpret_cast(&buffer[0]), i, size)) std::cerr << "Character " << i << " should be class " << GetClassName(thisClass) << ", but was not in GetCharsOfClass;" << " it is reported to be " << GetClassName(pcc->GetClass(i)) << std::endl; - REQUIRE(memchr(reinterpret_cast(buffer), i, size)); + REQUIRE(memchr(reinterpret_cast(&buffer[0]), i, size)); } else { - if (memchr(reinterpret_cast(buffer), i, size)) + if (memchr(reinterpret_cast(&buffer[0]), i, size)) std::cerr << "Character " << i << " should not be class " << GetClassName(thisClass) << ", but was in GetCharsOfClass" << " it is reported to be " << GetClassName(pcc->GetClass(i)) << std::endl; - REQUIRE_FALSE(memchr(reinterpret_cast(buffer), i, size)); + REQUIRE_FALSE(memchr(reinterpret_cast(&buffer[0]), i, size)); } } - delete []buffer; } } diff --git a/dep/scintilla/scintilla-3.10.6/test/unit/testContractionState.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testContractionState.cxx new file mode 100644 index 00000000..fcee9028 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testContractionState.cxx @@ -0,0 +1,158 @@ +// Unit Tests for Scintilla internal data structures + +#include +#include + +#include +#include +#include +#include + +#include "Platform.h" + +#include "Position.h" +#include "UniqueString.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h" +#include "ContractionState.h" + +#include "catch.hpp" + +using namespace Scintilla; + +// Test ContractionState. + +TEST_CASE("ContractionState") { + + std::unique_ptr pcs = ContractionStateCreate(false); + + SECTION("IsEmptyInitially") { + REQUIRE(1 == pcs->LinesInDoc()); + REQUIRE(1 == pcs->LinesDisplayed()); + REQUIRE(0 == pcs->DisplayFromDoc(0)); + REQUIRE(0 == pcs->DocFromDisplay(0)); + } + + SECTION("OneLine") { + pcs->InsertLines(0, 1); + REQUIRE(2 == pcs->LinesInDoc()); + REQUIRE(2 == pcs->LinesDisplayed()); + REQUIRE(0 == pcs->DisplayFromDoc(0)); + REQUIRE(0 == pcs->DocFromDisplay(0)); + REQUIRE(1 == pcs->DisplayFromDoc(1)); + REQUIRE(1 == pcs->DocFromDisplay(1)); + } + + SECTION("InsertionThenDeletions") { + pcs->InsertLines(0,4); + pcs->DeleteLines(1, 1); + + REQUIRE(4 == pcs->LinesInDoc()); + REQUIRE(4 == pcs->LinesDisplayed()); + for (int l=0;l<4;l++) { + REQUIRE(l == pcs->DisplayFromDoc(l)); + REQUIRE(l == pcs->DocFromDisplay(l)); + } + + pcs->DeleteLines(0,2); + REQUIRE(2 == pcs->LinesInDoc()); + REQUIRE(2 == pcs->LinesDisplayed()); + for (int l=0;l<2;l++) { + REQUIRE(l == pcs->DisplayFromDoc(l)); + REQUIRE(l == pcs->DocFromDisplay(l)); + } + } + + SECTION("ShowHide") { + pcs->InsertLines(0,4); + REQUIRE(true == pcs->GetVisible(0)); + REQUIRE(true == pcs->GetVisible(1)); + REQUIRE(true == pcs->GetVisible(2)); + REQUIRE(5 == pcs->LinesDisplayed()); + + pcs->SetVisible(1, 1, false); + REQUIRE(true == pcs->GetVisible(0)); + REQUIRE(false == pcs->GetVisible(1)); + REQUIRE(true == pcs->GetVisible(2)); + REQUIRE(4 == pcs->LinesDisplayed()); + REQUIRE(true == pcs->HiddenLines()); + + pcs->SetVisible(1, 2, true); + for (int l=0;l<4;l++) { + REQUIRE(true == pcs->GetVisible(0)); + } + + pcs->SetVisible(1, 1, false); + REQUIRE(false == pcs->GetVisible(1)); + pcs->ShowAll(); + for (int l=0;l<4;l++) { + REQUIRE(true == pcs->GetVisible(0)); + } + REQUIRE(false == pcs->HiddenLines()); + } + + SECTION("Hidden") { + pcs->InsertLines(0,1); + for (int l=0;l<2;l++) { + REQUIRE(true == pcs->GetVisible(0)); + } + REQUIRE(false == pcs->HiddenLines()); + + pcs->SetVisible(1, 1, false); + REQUIRE(true == pcs->GetVisible(0)); + REQUIRE(false == pcs->GetVisible(1)); + REQUIRE(true == pcs->HiddenLines()); + + pcs->SetVisible(1, 1, true); + for (int l=0;l<2;l++) { + REQUIRE(true == pcs->GetVisible(0)); + } + REQUIRE(false == pcs->HiddenLines()); + } + + SECTION("Contracting") { + pcs->InsertLines(0,4); + for (int l=0;l<4;l++) { + REQUIRE(true == pcs->GetExpanded(l)); + } + + pcs->SetExpanded(2, false); + REQUIRE(true == pcs->GetExpanded(1)); + REQUIRE(false == pcs->GetExpanded(2)); + REQUIRE(true == pcs->GetExpanded(3)); + + REQUIRE(2 == pcs->ContractedNext(0)); + REQUIRE(2 == pcs->ContractedNext(1)); + REQUIRE(2 == pcs->ContractedNext(2)); + REQUIRE(-1 == pcs->ContractedNext(3)); + + pcs->SetExpanded(2, true); + REQUIRE(true == pcs->GetExpanded(1)); + REQUIRE(true == pcs->GetExpanded(2)); + REQUIRE(true == pcs->GetExpanded(3)); + } + + SECTION("ChangeHeight") { + pcs->InsertLines(0,4); + for (int l=0;l<4;l++) { + REQUIRE(1 == pcs->GetHeight(l)); + } + + pcs->SetHeight(1, 2); + REQUIRE(1 == pcs->GetHeight(0)); + REQUIRE(2 == pcs->GetHeight(1)); + REQUIRE(1 == pcs->GetHeight(2)); + } + + SECTION("SetFoldDisplayText") { + pcs->InsertLines(0, 4); + pcs->SetFoldDisplayText(1, "abc"); + REQUIRE(strcmp(pcs->GetFoldDisplayText(1), "abc") == 0); + pcs->SetFoldDisplayText(1, "def"); + REQUIRE(strcmp(pcs->GetFoldDisplayText(1), "def") == 0); + pcs->SetFoldDisplayText(1, nullptr); + REQUIRE(static_cast(nullptr) == pcs->GetFoldDisplayText(1)); + } + +} diff --git a/dep/scintilla/scintilla-3.10.6/test/unit/testDecoration.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testDecoration.cxx new file mode 100644 index 00000000..7641850b --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testDecoration.cxx @@ -0,0 +1,94 @@ +// Unit Tests for Scintilla internal data structures + +#include +#include + +#include +#include +#include +#include + +#include "Platform.h" + +#include "Position.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h" +#include "Decoration.h" + +#include "catch.hpp" + +const int indicator=4; + +using namespace Scintilla; + +// Test Decoration. + +TEST_CASE("Decoration") { + + std::unique_ptr deco = DecorationCreate(false, indicator); + + SECTION("HasCorrectIndicator") { + REQUIRE(indicator == deco->Indicator()); + } + + SECTION("IsEmptyInitially") { + REQUIRE(0 == deco->Length()); + REQUIRE(1 == deco->Runs()); + REQUIRE(deco->Empty()); + } + + SECTION("SimpleSpace") { + deco->InsertSpace(0, 1); + REQUIRE(deco->Empty()); + } + + SECTION("SimpleRun") { + deco->InsertSpace(0, 1); + deco->SetValueAt(0, 2); + REQUIRE(!deco->Empty()); + } +} + +// Test DecorationList. + +TEST_CASE("DecorationList") { + + std::unique_ptr decol = DecorationListCreate(false); + + SECTION("HasCorrectIndicator") { + decol->SetCurrentIndicator(indicator); + REQUIRE(indicator == decol->GetCurrentIndicator()); + } + + SECTION("HasCorrectCurrentValue") { + const int value = 55; + decol->SetCurrentValue(value); + REQUIRE(value == decol->GetCurrentValue()); + } + + SECTION("ExpandSetValues") { + decol->SetCurrentIndicator(indicator); + decol->InsertSpace(0, 9); + const int value = 59; + const Sci::Position position = 4; + const Sci::Position fillLength = 3; + auto fr = decol->FillRange(position, value, fillLength); + REQUIRE(fr.changed); + REQUIRE(fr.position == 4); + REQUIRE(fr.fillLength == 3); + REQUIRE(decol->ValueAt(indicator, 5) == value); + REQUIRE(decol->AllOnFor(5) == (1 << indicator)); + REQUIRE(decol->Start(indicator, 5) == 4); + REQUIRE(decol->End(indicator, 5) == 7); + const int indicatorB=6; + decol->SetCurrentIndicator(indicatorB); + fr = decol->FillRange(position, value, fillLength); + REQUIRE(fr.changed); + REQUIRE(decol->AllOnFor(5) == ((1 << indicator) | (1 << indicatorB))); + decol->DeleteRange(5, 1); + REQUIRE(decol->Start(indicatorB, 5) == 4); + REQUIRE(decol->End(indicatorB, 5) == 6); + } + +} diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/testPartitioning.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testPartitioning.cxx similarity index 96% rename from dep/scintilla/scintilla-3.6.0/test/unit/testPartitioning.cxx rename to dep/scintilla/scintilla-3.10.6/test/unit/testPartitioning.cxx index 4863cfb1..449253ef 100644 --- a/dep/scintilla/scintilla-3.6.0/test/unit/testPartitioning.cxx +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testPartitioning.cxx @@ -1,9 +1,12 @@ // Unit Tests for Scintilla internal data structures -#include +#include +#include #include +#include #include +#include #include "Platform.h" @@ -13,6 +16,8 @@ #include "catch.hpp" +using namespace Scintilla; + const int growSize = 4; const int lengthTestArray = 8; @@ -22,7 +27,7 @@ static const int testArray[lengthTestArray] = {3, 4, 5, 6, 7, 8, 9, 10}; TEST_CASE("SplitVectorWithRangeAdd") { - SplitVectorWithRangeAdd svwra(growSize); + SplitVectorWithRangeAdd svwra(growSize); SECTION("IsEmptyInitially") { REQUIRE(0 == svwra.Length()); @@ -45,7 +50,7 @@ TEST_CASE("SplitVectorWithRangeAdd") { TEST_CASE("Partitioning") { - Partitioning part(growSize); + Partitioning part(growSize); SECTION("IsEmptyInitially") { REQUIRE(1 == part.Partitions()); diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/testRunStyles.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testRunStyles.cxx similarity index 75% rename from dep/scintilla/scintilla-3.6.0/test/unit/testRunStyles.cxx rename to dep/scintilla/scintilla-3.10.6/test/unit/testRunStyles.cxx index 250b5c04..3edb6165 100644 --- a/dep/scintilla/scintilla-3.6.0/test/unit/testRunStyles.cxx +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testRunStyles.cxx @@ -1,9 +1,12 @@ // Unit Tests for Scintilla internal data structures -#include +#include +#include #include +#include #include +#include #include "Platform.h" @@ -14,11 +17,21 @@ #include "catch.hpp" +using namespace Scintilla; + // Test RunStyles. +namespace Scintilla { // Xcode clang 9.0 doesn't like this when in the unnamed namespace + bool operator==(const FillResult &fra, const FillResult &frb) { + return fra.changed == frb.changed && + fra.position == frb.position && + fra.fillLength == frb.fillLength; + } +} + TEST_CASE("RunStyles") { - RunStyles rs; + RunStyles rs; SECTION("IsEmptyInitially") { REQUIRE(0 == rs.Length()); @@ -88,9 +101,8 @@ TEST_CASE("RunStyles") { rs.InsertSpace(0, 5); int startFill = 1; int lengthFill = 3; - REQUIRE(true == rs.FillRange(startFill, 99, lengthFill)); - REQUIRE(1 == startFill); - REQUIRE(3 == lengthFill); + const auto fr = rs.FillRange(startFill, 99, lengthFill); + REQUIRE(FillResult{true, 1, 3} == fr); REQUIRE(0 == rs.ValueAt(0)); REQUIRE(99 == rs.ValueAt(1)); @@ -109,16 +121,14 @@ TEST_CASE("RunStyles") { rs.InsertSpace(0, 5); int startFill = 1; int lengthFill = 3; - REQUIRE(true == rs.FillRange(startFill, 99, lengthFill)); - REQUIRE(1 == startFill); - REQUIRE(3 == lengthFill); + const auto fr = rs.FillRange(startFill, 99, lengthFill); + REQUIRE(FillResult{true, 1, 3} == fr); int startFill2 = 2; int lengthFill2 = 1; // Compiler warnings if 'false' used instead of '0' as expected value: - REQUIRE(0 == rs.FillRange(startFill2, 99, lengthFill2)); - REQUIRE(2 == startFill2); - REQUIRE(1 == lengthFill2); + const auto fr2 = rs.FillRange(startFill2, 99, lengthFill2); + REQUIRE(FillResult{false, 2, 1} == fr2); REQUIRE(0 == rs.ValueAt(0)); REQUIRE(99 == rs.ValueAt(1)); REQUIRE(99 == rs.ValueAt(2)); @@ -131,15 +141,13 @@ TEST_CASE("RunStyles") { rs.InsertSpace(0, 5); int startFill = 1; int lengthFill = 2; - REQUIRE(true == rs.FillRange(startFill, 99, lengthFill)); - REQUIRE(1 == startFill); - REQUIRE(2 == lengthFill); + const auto fr = rs.FillRange(startFill, 99, lengthFill); + REQUIRE(FillResult{true, 1, 2} == fr); int startFill2 = 2; int lengthFill2 = 2; - REQUIRE(true == rs.FillRange(startFill2, 99, lengthFill2)); - REQUIRE(3 == startFill2); - REQUIRE(1 == lengthFill2); + const auto fr2 = rs.FillRange(startFill2, 99, lengthFill2); + REQUIRE(FillResult{true, 3, 1} == fr2); REQUIRE(3 == rs.Runs()); } @@ -169,9 +177,8 @@ TEST_CASE("RunStyles") { rs.InsertSpace(0, 5); int startFill = 1; int lengthFill = 3; - REQUIRE(true == rs.FillRange(startFill, 99, lengthFill)); - REQUIRE(1 == startFill); - REQUIRE(3 == lengthFill); + const auto fr = rs.FillRange(startFill, 99, lengthFill); + REQUIRE(FillResult{true, 1, 3} == fr); REQUIRE(0 == rs.Find(0,0)); REQUIRE(1 == rs.Find(99,0)); @@ -202,17 +209,19 @@ TEST_CASE("RunStyles") { REQUIRE(true == rs.AllSame()); rs.InsertSpace(0, 5); REQUIRE(true == rs.AllSame()); - REQUIRE(0 == rs.AllSameAs(88)); + REQUIRE(false == rs.AllSameAs(88)); REQUIRE(true == rs.AllSameAs(0)); int startFill = 1; int lengthFill = 3; - REQUIRE(true == rs.FillRange(startFill, 99, lengthFill)); - REQUIRE(0 == rs.AllSame()); - REQUIRE(0 == rs.AllSameAs(88)); - REQUIRE(0 == rs.AllSameAs(0)); - REQUIRE(true == rs.FillRange(startFill, 0, lengthFill)); + const auto fr = rs.FillRange(startFill, 99, lengthFill); + REQUIRE(true == fr.changed); + REQUIRE(false == rs.AllSame()); + REQUIRE(false == rs.AllSameAs(88)); + REQUIRE(false == rs.AllSameAs(0)); + const auto fr2 = rs.FillRange(startFill, 0, lengthFill); + REQUIRE(true == fr2.changed); REQUIRE(true == rs.AllSame()); - REQUIRE(0 == rs.AllSameAs(88)); + REQUIRE(false == rs.AllSameAs(88)); REQUIRE(true == rs.AllSameAs(0)); } @@ -222,29 +231,27 @@ TEST_CASE("RunStyles") { int startFill = 1; int lengthFill = 1; - REQUIRE(true == rs.FillRange(startFill, 99, lengthFill)); - REQUIRE(1 == startFill); - REQUIRE(1 == lengthFill); + const auto fr = rs.FillRange(startFill, 99, lengthFill); + REQUIRE(FillResult{true, 1, 1} == fr); REQUIRE(3 == rs.Runs()); startFill = 2; lengthFill = 1; - REQUIRE(true == rs.FillRange(startFill, 99, lengthFill)); - REQUIRE(2 == startFill); - REQUIRE(1 == lengthFill); + const auto fr2 = rs.FillRange(startFill, 99, lengthFill); + REQUIRE(FillResult{true, 2, 1} == fr2); REQUIRE(3 == rs.Runs()); startFill = 1; lengthFill = 1; - REQUIRE(true == rs.FillRange(startFill, 0, lengthFill)); + const auto fr3 = rs.FillRange(startFill, 0, lengthFill); + REQUIRE(FillResult{true, 1, 1} == fr3); REQUIRE(3 == rs.Runs()); - REQUIRE(1 == lengthFill); startFill = 2; lengthFill = 1; - REQUIRE(true == rs.FillRange(startFill, 0, lengthFill)); + const auto fr4 = rs.FillRange(startFill, 0, lengthFill); + REQUIRE(FillResult{true, 2, 1} == fr4); REQUIRE(1 == rs.Runs()); - REQUIRE(1 == lengthFill); REQUIRE(-1 == rs.Find(0,6)); } @@ -279,7 +286,8 @@ TEST_CASE("RunStyles") { rs.InsertSpace(0, 3); int startFill = 1; int lengthFill = 1; - REQUIRE(true == rs.FillRange(startFill, 99, lengthFill)); + const auto fr = rs.FillRange(startFill, 99, lengthFill); + REQUIRE(true == fr.changed); REQUIRE(3 == rs.Length()); REQUIRE(3 == rs.Runs()); rs.DeleteRange(1, 1); @@ -291,7 +299,8 @@ TEST_CASE("RunStyles") { rs.InsertSpace(0, 2); int startFill = 1; int lengthFill = 1; - REQUIRE(true == rs.FillRange(startFill, 99, lengthFill)); + const auto fr = rs.FillRange(startFill, 99, lengthFill); + REQUIRE(true == fr.changed); REQUIRE(2 == rs.Length()); REQUIRE(2 == rs.Runs()); REQUIRE(0 == rs.StartRun(0)); diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/testSparseState.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testSparseState.cxx similarity index 95% rename from dep/scintilla/scintilla-3.6.0/test/unit/testSparseState.cxx rename to dep/scintilla/scintilla-3.10.6/test/unit/testSparseState.cxx index bcc7d555..3cc283b6 100644 --- a/dep/scintilla/scintilla-3.6.0/test/unit/testSparseState.cxx +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testSparseState.cxx @@ -3,13 +3,18 @@ #include #include #include +#include #include "Platform.h" +#include "Sci_Position.h" + #include "SparseState.h" #include "catch.hpp" +using namespace Scintilla; + // Test SparseState. TEST_CASE("SparseState") { @@ -102,7 +107,7 @@ TEST_CASE("SparseState") { ssAdditions.Set(4, 34); REQUIRE(1u == ssAdditions.size()); bool mergeChanged = ss.Merge(ssAdditions,5); - REQUIRE(0 == mergeChanged); + REQUIRE(false == mergeChanged); ssAdditions.Set(4, 44); REQUIRE(1u == ssAdditions.size()); @@ -122,7 +127,7 @@ TEST_CASE("SparseState") { ssAdditions.Set(4, 34); REQUIRE(1u == ssAdditions.size()); bool mergeChanged = ss.Merge(ssAdditions,5); - REQUIRE(0 == mergeChanged); + REQUIRE(false == mergeChanged); ssAdditions.Set(4, 44); REQUIRE(1u == ssAdditions.size()); @@ -157,7 +162,7 @@ TEST_CASE("SparseState") { ssAdditions.Set(2, 32); bool mergeChanged = ss.Merge(ssAdditions,3); - REQUIRE(0 == mergeChanged); + REQUIRE(false == mergeChanged); REQUIRE(2u == ss.size()); REQUIRE(32 == ss.ValueAt(2)); } @@ -171,7 +176,7 @@ TEST_CASE("SparseState") { ssAdditions.Set(2, 32); bool mergeChanged = ss.Merge(ssAdditions,2); - REQUIRE(0 == mergeChanged); + REQUIRE(false == mergeChanged); REQUIRE(2u == ss.size()); REQUIRE(32 == ss.ValueAt(2)); } @@ -186,7 +191,7 @@ TEST_CASE("SparseState") { ssAdditions.Set(5, 34); bool mergeChanged = ss.Merge(ssAdditions,6); - REQUIRE(0 == mergeChanged); + REQUIRE(false == mergeChanged); REQUIRE(3u == ss.size()); REQUIRE(34 == ss.ValueAt(4)); } diff --git a/dep/scintilla/scintilla-3.10.6/test/unit/testSparseVector.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testSparseVector.cxx new file mode 100644 index 00000000..ce3b9706 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testSparseVector.cxx @@ -0,0 +1,252 @@ +// Unit Tests for Scintilla internal data structures + +#include +#include +#include + +#include +#include +#include +#include + +#include "Platform.h" + +#include "Position.h" +#include "UniqueString.h" +#include "SplitVector.h" +#include "Partitioning.h" +#include "SparseVector.h" + +#include "catch.hpp" + +using namespace Scintilla; + +// Test SparseVector. + +// Helper to produce a string representation of a SparseVector +// to simplify checks. +static std::string Representation(const SparseVector &st) { + std::string ret; + for (int i = 0;i < st.Length();i++) { + const char *value = st.ValueAt(i).get(); + if (value && *value) + ret += value; + else + ret += "-"; + } + return ret; +} + +TEST_CASE("SparseVector") { + + SparseVector st; + + SECTION("IsEmptyInitially") { + REQUIRE(1 == st.Elements()); + REQUIRE(0 == st.Length()); + st.Check(); + } + + SECTION("InsertSpace") { + st.InsertSpace(0, 5); + REQUIRE(1 == st.Elements()); + REQUIRE(static_cast(nullptr) == st.ValueAt(0).get()); + REQUIRE(static_cast(nullptr) == st.ValueAt(1).get()); + REQUIRE(static_cast(nullptr) == st.ValueAt(4).get()); + st.Check(); + } + + SECTION("InsertValue") { + st.InsertSpace(0, 5); + st.SetValueAt(3, UniqueStringCopy("3")); + REQUIRE(2 == st.Elements()); + REQUIRE("---3-" == Representation(st)); + st.Check(); + } + + SECTION("InsertAndChangeAndDeleteValue") { + st.InsertSpace(0, 5); + REQUIRE(5 == st.Length()); + st.SetValueAt(3, UniqueStringCopy("3")); + REQUIRE(2 == st.Elements()); + st.SetValueAt(3, UniqueStringCopy("4")); + REQUIRE(2 == st.Elements()); + st.DeletePosition(3); + REQUIRE(1 == st.Elements()); + REQUIRE(4 == st.Length()); + REQUIRE("----" == Representation(st)); + st.Check(); + } + + SECTION("InsertAndDeleteAtStart") { + REQUIRE(1 == st.Elements()); + st.InsertSpace(0, 5); + st.SetValueAt(0, UniqueStringCopy("3")); + REQUIRE(1 == st.Elements()); + REQUIRE("3----" == Representation(st)); + st.DeletePosition(0); + REQUIRE(1 == st.Elements()); + REQUIRE("----" == Representation(st)); + st.SetValueAt(0, UniqueStringCopy("4")); + REQUIRE(1 == st.Elements()); + REQUIRE("4---" == Representation(st)); + st.DeletePosition(0); + REQUIRE(1 == st.Elements()); + REQUIRE("---" == Representation(st)); + st.Check(); + } + + SECTION("InsertStringAtStartThenInsertSpaceAtStart") { + REQUIRE(1 == st.Elements()); + st.InsertSpace(0, 5); + st.SetValueAt(0, UniqueStringCopy("3")); + REQUIRE(1 == st.Elements()); + REQUIRE("3----" == Representation(st)); + st.InsertSpace(0, 1); + REQUIRE(2 == st.Elements()); + REQUIRE("-3----" == Representation(st)); + st.Check(); + } + + SECTION("InsertSpaceAfterStart") { + REQUIRE(1 == st.Elements()); + st.InsertSpace(0, 5); + st.SetValueAt(1, UniqueStringCopy("1")); + REQUIRE(2 == st.Elements()); + REQUIRE("-1---" == Representation(st)); + st.InsertSpace(1, 1); + REQUIRE(2 == st.Elements()); + REQUIRE("--1---" == Representation(st)); + st.Check(); + } + + SECTION("InsertStringAt1ThenInsertLettersAt1") { + REQUIRE(1 == st.Elements()); + st.InsertSpace(0, 5); + st.SetValueAt(1, UniqueStringCopy("9")); + REQUIRE(2 == st.Elements()); + REQUIRE("-9---" == Representation(st)); + st.InsertSpace(0, 1); + REQUIRE(2 == st.Elements()); + REQUIRE("--9---" == Representation(st)); + // Initial st has allocation of 9 values so this should cause reallocation + const std::string letters("ABCDEFGHIJKLMNOP"); // 16 letters + for (const char letter : letters) { + const char sLetter[] = { letter, 0 }; + st.InsertSpace(0, 1); + st.SetValueAt(1, UniqueStringCopy(sLetter)); + } + REQUIRE("-PONMLKJIHGFEDCBA-9---" == Representation(st)); + st.Check(); + } + + SECTION("InsertAndDeleteAtEnd") { + REQUIRE(1 == st.Elements()); + st.InsertSpace(0, 5); + st.SetValueAt(4, UniqueStringCopy("5")); + REQUIRE(2 == st.Elements()); + REQUIRE("----5" == Representation(st)); + st.DeletePosition(4); + REQUIRE(1 == st.Elements()); + REQUIRE("----" == Representation(st)); + st.Check(); + } + + SECTION("SetNULL") { + REQUIRE(1 == st.Elements()); + st.InsertSpace(0, 5); + st.SetValueAt(4, UniqueStringCopy("5")); + REQUIRE(2 == st.Elements()); + REQUIRE("----5" == Representation(st)); + st.SetValueAt(4, nullptr); + REQUIRE(1 == st.Elements()); + REQUIRE("-----" == Representation(st)); + st.Check(); + } + + SECTION("DeleteAll") { + REQUIRE(1 == st.Elements()); + st.InsertSpace(0, 10); + st.SetValueAt(9, UniqueStringCopy("9")); + st.SetValueAt(7, UniqueStringCopy("7")); + st.SetValueAt(4, UniqueStringCopy("4")); + st.SetValueAt(3, UniqueStringCopy("3")); + REQUIRE(5 == st.Elements()); + REQUIRE("---34--7-9" == Representation(st)); + st.Check(); + } + +} + +TEST_CASE("SparseTextInt") { + + SparseVector st; + + SECTION("InsertAndDeleteValue") { + st.InsertSpace(0, 5); + st.SetValueAt(3, 3); + REQUIRE(2 == st.Elements()); + REQUIRE(0 == st.ValueAt(0)); + REQUIRE(0 == st.ValueAt(1)); + REQUIRE(0 == st.ValueAt(2)); + REQUIRE(3 == st.ValueAt(3)); + REQUIRE(0 == st.ValueAt(4)); + st.SetValueAt(3, -3); + REQUIRE(2 == st.Elements()); + REQUIRE(0 == st.ValueAt(0)); + REQUIRE(0 == st.ValueAt(1)); + REQUIRE(0 == st.ValueAt(2)); + REQUIRE(-3 == st.ValueAt(3)); + REQUIRE(0 == st.ValueAt(4)); + st.SetValueAt(3, 0); + REQUIRE(1 == st.Elements()); + REQUIRE(0 == st.ValueAt(0)); + REQUIRE(0 == st.ValueAt(1)); + REQUIRE(0 == st.ValueAt(2)); + REQUIRE(0 == st.ValueAt(3)); + REQUIRE(0 == st.ValueAt(4)); + st.Check(); + } +} + +TEST_CASE("SparseTextString") { + + SparseVector st; + + SECTION("InsertAndDeleteValue") { + st.InsertSpace(0, 5); + REQUIRE(5 == st.Length()); + st.SetValueAt(3, std::string("3")); + REQUIRE(2 == st.Elements()); + REQUIRE("" == st.ValueAt(0)); + REQUIRE("" == st.ValueAt(2)); + REQUIRE("3" == st.ValueAt(3)); + REQUIRE("" == st.ValueAt(4)); + st.DeletePosition(0); + REQUIRE(4 == st.Length()); + REQUIRE("3" == st.ValueAt(2)); + st.DeletePosition(2); + REQUIRE(1 == st.Elements()); + REQUIRE(3 == st.Length()); + REQUIRE("" == st.ValueAt(0)); + REQUIRE("" == st.ValueAt(1)); + REQUIRE("" == st.ValueAt(2)); + st.Check(); + } + + SECTION("SetAndMoveString") { + st.InsertSpace(0, 2); + REQUIRE(2u == st.Length()); + std::string s24("24"); + st.SetValueAt(0, s24); + REQUIRE("24" == s24); // Not moved from + REQUIRE("" == st.ValueAt(-1)); + REQUIRE("24" == st.ValueAt(0)); + REQUIRE("" == st.ValueAt(1)); + std::string s25("25"); + st.SetValueAt(1, std::move(s25)); + REQUIRE("" == s25); // moved from + REQUIRE("25" == st.ValueAt(1)); + } + +} diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/testSplitVector.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testSplitVector.cxx similarity index 58% rename from dep/scintilla/scintilla-3.6.0/test/unit/testSplitVector.cxx rename to dep/scintilla/scintilla-3.10.6/test/unit/testSplitVector.cxx index a82d4491..2d9d3607 100644 --- a/dep/scintilla/scintilla-3.6.0/test/unit/testSplitVector.cxx +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testSplitVector.cxx @@ -1,9 +1,12 @@ // Unit Tests for Scintilla internal data structures -#include +#include +#include #include +#include #include +#include #include "Platform.h" @@ -12,8 +15,22 @@ #include "catch.hpp" +using namespace Scintilla; + // Test SplitVector. +struct StringSetHolder { + SplitVector sa; + bool Check() { + for (int i = 0; i < sa.Length(); i++) { + if (sa[i].empty()) { + return false; + } + } + return true; + } +}; + const int lengthTestArray = 4; static const int testArray[4] = {3, 4, 5, 6}; @@ -42,6 +59,98 @@ TEST_CASE("SplitVector") { } } + SECTION("InsertionString") { + // This test failed an earlier version of SplitVector that copied backwards incorrectly + StringSetHolder ssh; + ssh.sa.Insert(0, "Alpha"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(0, "Beta"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(0, "Cat"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(1, "Dog"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(0, "Elephant"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(1, "Fox"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(0, "Grass"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(1, "Hat"); + REQUIRE(ssh.Check()); + ssh.sa.Delete(4); + REQUIRE(ssh.Check()); + ssh.sa.Insert(0, "Indigo"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(1, "Jackal"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(0, "Kanga"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(1, "Lion"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(0, "Mango"); + REQUIRE(ssh.Check()); + ssh.sa.Insert(1, "Neon"); + REQUIRE(ssh.Check()); + } + + SECTION("InsertionPattern") { + sv.Insert(0, 1); // 1 + sv.Insert(0, 2); // 21 + sv.Insert(0, 3); // 321 + sv.Insert(1, 4); // 3421 + sv.Insert(0, 5); // 53421 + sv.Insert(1, 6); // 563421 + sv.Insert(0, 7); // 7563421 + sv.Insert(1, 8); // 78563421 + + REQUIRE(8 == sv.Length()); + + REQUIRE(7 == sv.ValueAt(0)); + REQUIRE(8 == sv.ValueAt(1)); + REQUIRE(5 == sv.ValueAt(2)); + REQUIRE(6 == sv.ValueAt(3)); + REQUIRE(3 == sv.ValueAt(4)); + REQUIRE(4 == sv.ValueAt(5)); + REQUIRE(2 == sv.ValueAt(6)); + REQUIRE(1 == sv.ValueAt(7)); + + sv.Delete(4); // 7856421 + + REQUIRE(7 == sv.Length()); + + REQUIRE(7 == sv.ValueAt(0)); + REQUIRE(8 == sv.ValueAt(1)); + REQUIRE(5 == sv.ValueAt(2)); + REQUIRE(6 == sv.ValueAt(3)); + REQUIRE(4 == sv.ValueAt(4)); + REQUIRE(2 == sv.ValueAt(5)); + REQUIRE(1 == sv.ValueAt(6)); + + sv.Insert(0, 9); // 97856421 + sv.Insert(1, 0xa); // 9a7856421 + sv.Insert(0, 0xb); // b9a7856421 + sv.Insert(1, 0xc); // bc9a7856421 + sv.Insert(0, 0xd); // dbc9a7856421 + sv.Insert(1, 0xe); // debc9a7856421 + + REQUIRE(13 == sv.Length()); + + REQUIRE(0xd == sv.ValueAt(0)); + REQUIRE(0xe == sv.ValueAt(1)); + REQUIRE(0xb == sv.ValueAt(2)); + REQUIRE(0xc == sv.ValueAt(3)); + REQUIRE(9 == sv.ValueAt(4)); + REQUIRE(0xa == sv.ValueAt(5)); + REQUIRE(7 == sv.ValueAt(6)); + REQUIRE(8 == sv.ValueAt(7)); + REQUIRE(5 == sv.ValueAt(8)); + REQUIRE(6 == sv.ValueAt(9)); + REQUIRE(4 == sv.ValueAt(10)); + REQUIRE(2 == sv.ValueAt(11)); + REQUIRE(1 == sv.ValueAt(12)); + } + SECTION("EnsureLength") { sv.EnsureLength(4); REQUIRE(4 == sv.Length()); @@ -166,8 +275,8 @@ TEST_CASE("SplitVector") { for (int i=0; i=0; i--) { - sv.InsertValue(i, 1, i+5); + for (ptrdiff_t i=sv.Length()-1; i>=0; i--) { + sv.InsertValue(i, 1, static_cast(i+5)); sv.Delete(i+1); } for (int i=0; i + +#include +#include +#include +#include + +#include "Platform.h" + +#include "UniConversion.h" + +#include "catch.hpp" + +using namespace Scintilla; + +// Test UniConversion. +// Use examples from Wikipedia: +// https://en.wikipedia.org/wiki/UTF-8 + +TEST_CASE("UTF16Length") { + + SECTION("UTF16Length ASCII") { + // Latin Small Letter A + const char *s = "a"; + size_t len = UTF16Length(s, strlen(s)); + REQUIRE(len == 1U); + } + + SECTION("UTF16Length Example1") { + // Dollar Sign + const char *s = "\x24"; + size_t len = UTF16Length(s, strlen(s)); + REQUIRE(len == 1U); + } + + SECTION("UTF16Length Example2") { + // Cent Sign + const char *s = "\xC2\xA2"; + size_t len = UTF16Length(s, strlen(s)); + REQUIRE(len == 1U); + } + + SECTION("UTF16Length Example3") { + // Euro Sign + const char *s = "\xE2\x82\xAC"; + size_t len = UTF16Length(s, strlen(s)); + REQUIRE(len == 1U); + } + + SECTION("UTF16Length Example4") { + // Gothic Letter Hwair + const char *s = "\xF0\x90\x8D\x88"; + size_t len = UTF16Length(s, strlen(s)); + REQUIRE(len == 2U); + } + + SECTION("UTF16Length Invalid Trail byte in lead position") { + const char *s = "a\xB5yz"; + size_t len = UTF16Length(s, strlen(s)); + REQUIRE(len == 4U); + } + + SECTION("UTF16Length Invalid Lead byte at end") { + const char *s = "a\xC2"; + size_t len = UTF16Length(s, strlen(s)); + REQUIRE(len == 2U); + } + + SECTION("UTF16Length Invalid Lead byte implies 3 trails but only 2") { + const char *s = "a\xF1yz"; + size_t len = UTF16Length(s, strlen(s)); + REQUIRE(len == 2U); + } +} + +TEST_CASE("UniConversion") { + + // UnicodeFromUTF8 + + SECTION("UnicodeFromUTF8 ASCII") { + const unsigned char s[]={'a', 0}; + REQUIRE(UnicodeFromUTF8(s) == 'a'); + } + + SECTION("UnicodeFromUTF8 Example1") { + const unsigned char s[]={0x24, 0}; + REQUIRE(UnicodeFromUTF8(s) == 0x24); + } + + SECTION("UnicodeFromUTF8 Example2") { + const unsigned char s[]={0xC2, 0xA2, 0}; + REQUIRE(UnicodeFromUTF8(s) == 0xA2); + } + + SECTION("UnicodeFromUTF8 Example3") { + const unsigned char s[]={0xE2, 0x82, 0xAC, 0}; + REQUIRE(UnicodeFromUTF8(s) == 0x20AC); + } + + SECTION("UnicodeFromUTF8 Example4") { + const unsigned char s[]={0xF0, 0x90, 0x8D, 0x88, 0}; + REQUIRE(UnicodeFromUTF8(s) == 0x10348); + } + + // UTF16FromUTF8 + + SECTION("UTF16FromUTF8 ASCII") { + const char s[] = {'a', 0}; + wchar_t tbuf[1] = {0}; + size_t tlen = UTF16FromUTF8(s, 1, tbuf, 1); + REQUIRE(tlen == 1U); + REQUIRE(tbuf[0] == 'a'); + } + + SECTION("UTF16FromUTF8 Example1") { + const char s[] = {'\x24', 0}; + wchar_t tbuf[1] = {0}; + size_t tlen = UTF16FromUTF8(s, 1, tbuf, 1); + REQUIRE(tlen == 1U); + REQUIRE(tbuf[0] == 0x24); + } + + SECTION("UTF16FromUTF8 Example2") { + const char s[] = {'\xC2', '\xA2', 0}; + wchar_t tbuf[1] = {0}; + size_t tlen = UTF16FromUTF8(s, 2, tbuf, 1); + REQUIRE(tlen == 1U); + REQUIRE(tbuf[0] == 0xA2); + } + + SECTION("UTF16FromUTF8 Example3") { + const char s[] = {'\xE2', '\x82', '\xAC', 0}; + wchar_t tbuf[1] = {0}; + size_t tlen = UTF16FromUTF8(s, 3, tbuf, 1);; + REQUIRE(tlen == 1U); + REQUIRE(tbuf[0] == 0x20AC); + } + + SECTION("UTF16FromUTF8 Example4") { + const char s[] = {'\xF0', '\x90', '\x8D', '\x88', 0}; + wchar_t tbuf[2] = {0, 0}; + size_t tlen = UTF16FromUTF8(s, 4, tbuf, 2); + REQUIRE(tlen == 2U); + REQUIRE(tbuf[0] == 0xD800); + REQUIRE(tbuf[1] == 0xDF48); + } + + SECTION("UTF16FromUTF8 Invalid Trail byte in lead position") { + const char s[] = "a\xB5yz"; + wchar_t tbuf[4] = {}; + size_t tlen = UTF16FromUTF8(s, 4, tbuf, 4); + REQUIRE(tlen == 4U); + REQUIRE(tbuf[0] == 'a'); + REQUIRE(tbuf[1] == 0xB5); + REQUIRE(tbuf[2] == 'y'); + REQUIRE(tbuf[3] == 'z'); + } + + SECTION("UTF16FromUTF8 Invalid Lead byte at end") { + const char s[] = "a\xC2"; + wchar_t tbuf[2] = {}; + size_t tlen = UTF16FromUTF8(s, 2, tbuf, 2); + REQUIRE(tlen == 2U); + REQUIRE(tbuf[0] == 'a'); + REQUIRE(tbuf[1] == 0xC2); + } + + SECTION("UTF16FromUTF8 Invalid Lead byte implies 3 trails but only 2") { + const char *s = "a\xF1yz"; + wchar_t tbuf[4] = {}; + size_t tlen = UTF16FromUTF8(s, 4, tbuf, 4); + REQUIRE(tlen == 2U); + REQUIRE(tbuf[0] == 'a'); + REQUIRE(tbuf[1] == 0xF1); + } + + // UTF32FromUTF8 + + SECTION("UTF32FromUTF8 ASCII") { + const char s[] = {'a', 0}; + unsigned int tbuf[1] = {0}; + size_t tlen = UTF32FromUTF8(s, 1, tbuf, 1); + REQUIRE(tlen == 1U); + REQUIRE(tbuf[0] == static_cast('a')); + } + + SECTION("UTF32FromUTF8 Example1") { + const char s[] = {'\x24', 0}; + unsigned int tbuf[1] = {0}; + size_t tlen = UTF32FromUTF8(s, 1, tbuf, 1); + REQUIRE(tlen == 1U); + REQUIRE(tbuf[0] == 0x24); + } + + SECTION("UTF32FromUTF8 Example2") { + const char s[] = {'\xC2', '\xA2', 0}; + unsigned int tbuf[1] = {0}; + size_t tlen = UTF32FromUTF8(s, 2, tbuf, 1); + REQUIRE(tlen == 1U); + REQUIRE(tbuf[0] == 0xA2); + } + + SECTION("UTF32FromUTF8 Example3") { + const char s[] = {'\xE2', '\x82', '\xAC', 0}; + unsigned int tbuf[1] = {0}; + size_t tlen = UTF32FromUTF8(s, 3, tbuf, 1); + REQUIRE(tlen == 1U); + REQUIRE(tbuf[0] == 0x20AC); + } + + SECTION("UTF32FromUTF8 Example4") { + const char s[] = {'\xF0', '\x90', '\x8D', '\x88', 0}; + unsigned int tbuf[1] = {0}; + size_t tlen = UTF32FromUTF8(s, 4, tbuf, 1); + REQUIRE(tlen == 1U); + REQUIRE(tbuf[0] == 0x10348); + } + + SECTION("UTF32FromUTF8 Invalid Trail byte in lead position") { + const char s[] = "a\xB5yz"; + unsigned int tbuf[4] = {}; + size_t tlen = UTF32FromUTF8(s, 4, tbuf, 4); + REQUIRE(tlen == 4U); + REQUIRE(tbuf[0] == static_cast('a')); + REQUIRE(tbuf[1] == 0xB5); + REQUIRE(tbuf[2] == static_cast('y')); + REQUIRE(tbuf[3] == static_cast('z')); + } + + SECTION("UTF32FromUTF8 Invalid Lead byte at end") { + const char s[] = "a\xC2"; + unsigned int tbuf[2] = {}; + size_t tlen = UTF32FromUTF8(s, 2, tbuf, 2); + REQUIRE(tlen == 2U); + REQUIRE(tbuf[0] == static_cast('a')); + REQUIRE(tbuf[1] == 0xC2); + } + + SECTION("UTF32FromUTF8 Invalid Lead byte implies 3 trails but only 2") { + const char *s = "a\xF1yz"; + unsigned int tbuf[4] = {}; + size_t tlen = UTF32FromUTF8(s, 4, tbuf, 4); + REQUIRE(tlen == 2U); + REQUIRE(tbuf[0] == static_cast('a')); + REQUIRE(tbuf[1] == 0xF1); + } +} + +namespace { + +// Simple adapter to avoid casting +int UTFClass(const char *s) { + return UTF8Classify(reinterpret_cast(s), static_cast(strlen(s))); +} + +} + +TEST_CASE("UTF8Classify") { + + // These tests are supposed to hit every return statement in UTF8Classify in order + // with some hit multiple times. + + // Single byte + + SECTION("UTF8Classify Simple ASCII") { + REQUIRE(UTFClass("a") == 1); + } + SECTION("UTF8Classify Invalid Too large lead") { + REQUIRE(UTFClass("\xF5") == (1|UTF8MaskInvalid)); + } + SECTION("UTF8Classify Overlong") { + REQUIRE(UTFClass("\xC0\x80") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify single trail byte") { + REQUIRE(UTFClass("\x80") == (1 | UTF8MaskInvalid)); + } + + // Invalid length tests + + SECTION("UTF8Classify 2 byte lead, string less than 2 long") { + REQUIRE(UTFClass("\xD0") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 3 byte lead, string less than 3 long") { + REQUIRE(UTFClass("\xEF") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 4 byte lead, string less than 4 long") { + REQUIRE(UTFClass("\xF0") == (1 | UTF8MaskInvalid)); + } + + // Invalid first trail byte tests + + SECTION("UTF8Classify 2 byte lead trail is invalid") { + REQUIRE(UTFClass("\xD0q") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 3 byte lead invalid trails") { + REQUIRE(UTFClass("\xE2qq") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 4 byte bad trails") { + REQUIRE(UTFClass("\xF0xyz") == (1 | UTF8MaskInvalid)); + } + + // 2 byte lead + + SECTION("UTF8Classify 2 byte valid character") { + REQUIRE(UTFClass("\xD0\x80") == 2); + } + + // 3 byte lead + + SECTION("UTF8Classify 3 byte lead, overlong") { + REQUIRE(UTFClass("\xE0\x80\xAF") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 3 byte lead, surrogate") { + REQUIRE(UTFClass("\xED\xA0\x80") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify FFFE non-character") { + REQUIRE(UTFClass("\xEF\xBF\xBE") == (3 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify FFFF non-character") { + REQUIRE(UTFClass("\xEF\xBF\xBF") == (3 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify FDD0 non-character") { + REQUIRE(UTFClass("\xEF\xB7\x90") == (3 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 3 byte valid character") { + REQUIRE(UTFClass("\xE2\x82\xAC") == 3); + } + + // 4 byte lead + + SECTION("UTF8Classify 1FFFF non-character") { + REQUIRE(UTFClass("\xF0\x9F\xBF\xBF") == (4 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 1 Greater than max Unicode 110000") { + // Maximum Unicode value is 10FFFF so 110000 is out of range + REQUIRE(UTFClass("\xF4\x90\x80\x80") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 4 byte overlong") { + REQUIRE(UTFClass("\xF0\x80\x80\x80") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 4 byte valid character") { + REQUIRE(UTFClass("\xF0\x9F\x8C\x90") == 4); + } + + // Invalid 2nd or 3rd continuation bytes + SECTION("UTF8Classify 3 byte lead invalid 2nd trail") { + REQUIRE(UTFClass("\xE2\x82q") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 4 byte lead invalid 2nd trail") { + REQUIRE(UTFClass("\xF0\x9Fq\x9F") == (1 | UTF8MaskInvalid)); + } + SECTION("UTF8Classify 4 byte lead invalid 3rd trail") { + REQUIRE(UTFClass("\xF0\x9F\x9Fq") == (1 | UTF8MaskInvalid)); + } +} diff --git a/dep/scintilla/scintilla-3.10.6/test/unit/testWordList.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/testWordList.cxx new file mode 100644 index 00000000..4d7805d1 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/test/unit/testWordList.cxx @@ -0,0 +1,72 @@ +// Unit Tests for Scintilla internal data structures + +#include + +#include "WordList.h" + +#include "catch.hpp" + +using namespace Scintilla; + +// Test WordList. + +TEST_CASE("WordList") { + + WordList wl; + + SECTION("IsEmptyInitially") { + REQUIRE(0 == wl.Length()); + REQUIRE(!wl.InList("struct")); + } + + SECTION("InList") { + wl.Set("else struct"); + REQUIRE(2 == wl.Length()); + REQUIRE(wl.InList("struct")); + REQUIRE(!wl.InList("class")); + } + + SECTION("WordAt") { + wl.Set("else struct"); + REQUIRE(0 == strcmp(wl.WordAt(0), "else")); + } + + SECTION("InListAbbreviated") { + wl.Set("else stru~ct w~hile"); + REQUIRE(wl.InListAbbreviated("else", '~')); + + REQUIRE(wl.InListAbbreviated("struct", '~')); + REQUIRE(wl.InListAbbreviated("stru", '~')); + REQUIRE(wl.InListAbbreviated("struc", '~')); + REQUIRE(!wl.InListAbbreviated("str", '~')); + + REQUIRE(wl.InListAbbreviated("while", '~')); + REQUIRE(wl.InListAbbreviated("wh", '~')); + // TODO: Next line fails but should allow single character prefixes + //REQUIRE(wl.InListAbbreviated("w", '~')); + REQUIRE(!wl.InListAbbreviated("", '~')); + } + + SECTION("InListAbridged") { + wl.Set("list w.~.active bo~k a~z ~_frozen"); + REQUIRE(wl.InListAbridged("list", '~')); + + REQUIRE(wl.InListAbridged("w.front.active", '~')); + REQUIRE(wl.InListAbridged("w.x.active", '~')); + REQUIRE(wl.InListAbridged("w..active", '~')); + REQUIRE(!wl.InListAbridged("w.active", '~')); + REQUIRE(!wl.InListAbridged("w.x.closed", '~')); + + REQUIRE(wl.InListAbridged("book", '~')); + REQUIRE(wl.InListAbridged("bok", '~')); + REQUIRE(!wl.InListAbridged("bk", '~')); + + REQUIRE(wl.InListAbridged("a_frozen", '~')); + REQUIRE(wl.InListAbridged("_frozen", '~')); + REQUIRE(!wl.InListAbridged("frozen", '~')); + + REQUIRE(wl.InListAbridged("abcz", '~')); + REQUIRE(wl.InListAbridged("abz", '~')); + REQUIRE(wl.InListAbridged("az", '~')); + } +} diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/unitTest.cxx b/dep/scintilla/scintilla-3.10.6/test/unit/unitTest.cxx similarity index 73% rename from dep/scintilla/scintilla-3.6.0/test/unit/unitTest.cxx rename to dep/scintilla/scintilla-3.10.6/test/unit/unitTest.cxx index a6feed20..cd948ff6 100644 --- a/dep/scintilla/scintilla-3.6.0/test/unit/unitTest.cxx +++ b/dep/scintilla/scintilla-3.10.6/test/unit/unitTest.cxx @@ -10,7 +10,7 @@ Decoration DecorationList CellBuffer - UnicodeFromUTF8 + UniConversion To do: PerLine * @@ -20,7 +20,6 @@ Document RESearch Selection - UniConversion Style lexlib: @@ -36,11 +35,26 @@ #include #include +#include +#include + #include "Platform.h" +#if defined(__GNUC__) +// Want to avoid misleading indentation warnings in catch.hpp but the pragma +// may not be available so protect by turning off pragma warnings +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wpragmas" +#if !defined(__clang__) +#pragma GCC diagnostic ignored "-Wmisleading-indentation" +#endif +#endif + #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file #include "catch.hpp" +using namespace Scintilla; + // Needed for PLATFORM_ASSERT in code being tested void Platform::Assert(const char *c, const char *file, int line) { diff --git a/dep/scintilla/scintilla-3.6.0/test/xite.py b/dep/scintilla/scintilla-3.10.6/test/xite.py similarity index 100% rename from dep/scintilla/scintilla-3.6.0/test/xite.py rename to dep/scintilla/scintilla-3.10.6/test/xite.py diff --git a/dep/scintilla/scintilla-3.6.0/tgzsrc b/dep/scintilla/scintilla-3.10.6/tgzsrc similarity index 100% rename from dep/scintilla/scintilla-3.6.0/tgzsrc rename to dep/scintilla/scintilla-3.10.6/tgzsrc diff --git a/dep/scintilla/scintilla-3.10.6/version.txt b/dep/scintilla/scintilla-3.10.6/version.txt new file mode 100644 index 00000000..4253b051 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/version.txt @@ -0,0 +1 @@ +3106 diff --git a/dep/scintilla/scintilla-3.10.6/win32/DepGen.py b/dep/scintilla/scintilla-3.10.6/win32/DepGen.py new file mode 100644 index 00000000..c43d2f66 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/win32/DepGen.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# DepGen.py - produce a make dependencies file for Scintilla +# Copyright 2019 by Neil Hodgson +# The License.txt file describes the conditions under which this software may be distributed. +# Requires Python 2.7 or later + +import sys + +sys.path.append("../") + +import scripts.Dependencies as Dependencies + +topComment = "# Created by DepGen.py. To recreate, run 'python DepGen.py'.\n" + +def Generate(): + sources = ["../src/*.cxx", "../lexlib/*.cxx", "../lexers/*.cxx"] + includes = ["../include", "../src", "../lexlib"] + + # Create the dependencies file for g++ + deps = Dependencies.FindDependencies(["../win32/*.cxx"] + sources, ["../win32"] + includes, ".o", "../win32/") + + # Add ScintillaBaseL as the same as ScintillaBase + deps = Dependencies.InsertSynonym(deps, "ScintillaBase.o", "ScintillaBaseL.o") + + # Add ScintillaWinL as the same as ScintillaWin + deps = Dependencies.InsertSynonym(deps, "ScintillaWin.o", "ScintillaWinL.o") + + Dependencies.UpdateDependencies("../win32/deps.mak", deps, topComment) + + # Create the dependencies file for MSVC + + # Place the objects in $(DIR_O) and change extension from ".o" to ".obj" + deps = [["$(DIR_O)/"+Dependencies.PathStem(obj)+".obj", headers] for obj, headers in deps] + + Dependencies.UpdateDependencies("../win32/nmdeps.mak", deps, topComment) + +if __name__ == "__main__": + Generate() \ No newline at end of file diff --git a/dep/scintilla/scintilla-3.6.0/win32/HanjaDic.cxx b/dep/scintilla/scintilla-3.10.6/win32/HanjaDic.cxx similarity index 94% rename from dep/scintilla/scintilla-3.6.0/win32/HanjaDic.cxx rename to dep/scintilla/scintilla-3.10.6/win32/HanjaDic.cxx index dbb755fb..a67a5612 100644 --- a/dep/scintilla/scintilla-3.6.0/win32/HanjaDic.cxx +++ b/dep/scintilla/scintilla-3.10.6/win32/HanjaDic.cxx @@ -6,14 +6,14 @@ // Copyright 2015 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. +#include + #include #include "UniConversion.h" #include "HanjaDic.h" -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif namespace HanjaDict { @@ -64,10 +64,10 @@ private: public: IHanjaDic *HJinterface; - HanjaDic() : HJinterface(NULL) { + HanjaDic() : HJinterface(nullptr) { hr = CLSIDFromProgID(OLESTR("mshjdic.hanjadic"), &CLSID_HanjaDic); if (SUCCEEDED(hr)) { - hr = CoCreateInstance(CLSID_HanjaDic, NULL, + hr = CoCreateInstance(CLSID_HanjaDic, nullptr, CLSCTX_INPROC_SERVER, IID_IHanjaDic, (LPVOID *)& HJinterface); if (SUCCEEDED(hr)) { @@ -110,7 +110,7 @@ int GetHangulOfHanja(wchar_t *inout) { if (dict.IsHanja(static_cast(inout[i]))) { // Pass hanja only! conv[0] = inout[i]; BSTR bstrHanja = SysAllocString(conv); - HRESULT hr = dict.HJinterface->HanjaToHangul(bstrHanja, &bstrHangul); + const HRESULT hr = dict.HJinterface->HanjaToHangul(bstrHanja, &bstrHangul); if (SUCCEEDED(hr)) { inout[i] = static_cast(bstrHangul[0]); changed += 1; @@ -124,6 +124,4 @@ int GetHangulOfHanja(wchar_t *inout) { } } -#ifdef SCI_NAMESPACE } -#endif diff --git a/dep/scintilla/scintilla-3.6.0/win32/HanjaDic.h b/dep/scintilla/scintilla-3.10.6/win32/HanjaDic.h similarity index 88% rename from dep/scintilla/scintilla-3.6.0/win32/HanjaDic.h rename to dep/scintilla/scintilla-3.10.6/win32/HanjaDic.h index d58735dc..3aafdf8e 100644 --- a/dep/scintilla/scintilla-3.6.0/win32/HanjaDic.h +++ b/dep/scintilla/scintilla-3.10.6/win32/HanjaDic.h @@ -9,9 +9,7 @@ #ifndef HANJADIC_H #define HANJADIC_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif namespace HanjaDict { @@ -19,8 +17,6 @@ int GetHangulOfHanja(wchar_t *inout); } -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/win32/PlatWin.cxx b/dep/scintilla/scintilla-3.10.6/win32/PlatWin.cxx similarity index 62% rename from dep/scintilla/scintilla-3.6.0/win32/PlatWin.cxx rename to dep/scintilla/scintilla-3.10.6/win32/PlatWin.cxx index b0c368e6..e70b8c36 100644 --- a/dep/scintilla/scintilla-3.6.0/win32/PlatWin.cxx +++ b/dep/scintilla/scintilla-3.10.6/win32/PlatWin.cxx @@ -5,18 +5,24 @@ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +// Want to use std::min and std::max so don't want Windows.h version of min and max +#if !defined(NOMINMAX) +#define NOMINMAX +#endif #undef _WIN32_WINNT #define _WIN32_WINNT 0x0500 #undef WINVER @@ -26,7 +32,7 @@ #include #include -#if defined(NTDDI_WIN7) && !defined(DISABLE_D2D) +#if !defined(DISABLE_D2D) #define USE_D2D 1 #endif @@ -36,102 +42,89 @@ #endif #include "Platform.h" -#include "StringCopy.h" +#include "Position.h" #include "XPM.h" #include "UniConversion.h" +#include "DBCS.h" #include "FontQuality.h" -#ifndef IDC_HAND -#define IDC_HAND MAKEINTRESOURCE(32649) -#endif +#include "PlatWin.h" #ifndef SPI_GETFONTSMOOTHINGCONTRAST #define SPI_GETFONTSMOOTHINGCONTRAST 0x200C #endif -static void *PointerFromWindow(HWND hWnd) { - return reinterpret_cast(::GetWindowLongPtr(hWnd, 0)); -} - -static void SetWindowPointer(HWND hWnd, void *ptr) { - ::SetWindowLongPtr(hWnd, 0, reinterpret_cast(ptr)); -} - -extern UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage); - -// Declarations needed for functions dynamically loaded as not available on all Windows versions. -typedef BOOL (WINAPI *AlphaBlendSig)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION); -typedef HMONITOR (WINAPI *MonitorFromPointSig)(POINT, DWORD); -typedef HMONITOR (WINAPI *MonitorFromRectSig)(LPCRECT, DWORD); -typedef BOOL (WINAPI *GetMonitorInfoSig)(HMONITOR, LPMONITORINFO); - -static CRITICAL_SECTION crPlatformLock; -static HINSTANCE hinstPlatformRes = 0; - -static HMODULE hDLLImage = 0; -static AlphaBlendSig AlphaBlendFn = 0; - -static HMODULE hDLLUser32 = 0; -static HMONITOR (WINAPI *MonitorFromPointFn)(POINT, DWORD) = 0; -static HMONITOR (WINAPI *MonitorFromRectFn)(LPCRECT, DWORD) = 0; -static BOOL (WINAPI *GetMonitorInfoFn)(HMONITOR, LPMONITORINFO) = 0; - -static HCURSOR reverseArrowCursor = NULL; - -#ifdef SCI_NAMESPACE -namespace Scintilla { +#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32 +#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 #endif -Point Point::FromLong(long lpoint) { - return Point(static_cast(LOWORD(lpoint)), static_cast(HIWORD(lpoint))); -} +namespace Scintilla { -static RECT RectFromPRectangle(PRectangle prc) { - RECT rc = {static_cast(prc.left), static_cast(prc.top), - static_cast(prc.right), static_cast(prc.bottom)}; - return rc; -} +UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage); #if defined(USE_D2D) -IDWriteFactory *pIDWriteFactory = 0; -ID2D1Factory *pD2DFactory = 0; -IDWriteRenderingParams *defaultRenderingParams = 0; -IDWriteRenderingParams *customClearTypeRenderingParams = 0; +IDWriteFactory *pIDWriteFactory = nullptr; +ID2D1Factory *pD2DFactory = nullptr; +IDWriteRenderingParams *defaultRenderingParams = nullptr; +IDWriteRenderingParams *customClearTypeRenderingParams = nullptr; +D2D1_DRAW_TEXT_OPTIONS d2dDrawTextOptions = D2D1_DRAW_TEXT_OPTIONS_NONE; -static HMODULE hDLLD2D = NULL; -static HMODULE hDLLDWrite = NULL; +static HMODULE hDLLD2D {}; +static HMODULE hDLLDWrite {}; bool LoadD2D() { static bool triedLoadingD2D = false; if (!triedLoadingD2D) { + DWORD loadLibraryFlags = 0; + HMODULE kernel32 = ::GetModuleHandle(TEXT("kernel32.dll")); + if (kernel32) { + if (::GetProcAddress(kernel32, "SetDefaultDllDirectories")) { + // Availability of SetDefaultDllDirectories implies Windows 8+ or + // that KB2533623 has been installed so LoadLibraryEx can be called + // with LOAD_LIBRARY_SEARCH_SYSTEM32. + loadLibraryFlags = LOAD_LIBRARY_SEARCH_SYSTEM32; + } + } + typedef HRESULT (WINAPI *D2D1CFSig)(D2D1_FACTORY_TYPE factoryType, REFIID riid, CONST D2D1_FACTORY_OPTIONS *pFactoryOptions, IUnknown **factory); typedef HRESULT (WINAPI *DWriteCFSig)(DWRITE_FACTORY_TYPE factoryType, REFIID iid, IUnknown **factory); - hDLLD2D = ::LoadLibraryEx(TEXT("D2D1.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/); + hDLLD2D = ::LoadLibraryEx(TEXT("D2D1.DLL"), 0, loadLibraryFlags); if (hDLLD2D) { - D2D1CFSig fnD2DCF = (D2D1CFSig)::GetProcAddress(hDLLD2D, "D2D1CreateFactory"); + D2D1CFSig fnD2DCF = reinterpret_cast(::GetProcAddress(hDLLD2D, "D2D1CreateFactory")); if (fnD2DCF) { // A single threaded factory as Scintilla always draw on the GUI thread fnD2DCF(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory), - 0, + nullptr, reinterpret_cast(&pD2DFactory)); } } - hDLLDWrite = ::LoadLibraryEx(TEXT("DWRITE.DLL"), 0, 0x00000800 /*LOAD_LIBRARY_SEARCH_SYSTEM32*/); + hDLLDWrite = ::LoadLibraryEx(TEXT("DWRITE.DLL"), 0, loadLibraryFlags); if (hDLLDWrite) { - DWriteCFSig fnDWCF = (DWriteCFSig)::GetProcAddress(hDLLDWrite, "DWriteCreateFactory"); + DWriteCFSig fnDWCF = reinterpret_cast(::GetProcAddress(hDLLDWrite, "DWriteCreateFactory")); if (fnDWCF) { - fnDWCF(DWRITE_FACTORY_TYPE_SHARED, - __uuidof(IDWriteFactory), + const GUID IID_IDWriteFactory2 = // 0439fc60-ca44-4994-8dee-3a9af7b732ec + { 0x0439fc60, 0xca44, 0x4994, { 0x8d, 0xee, 0x3a, 0x9a, 0xf7, 0xb7, 0x32, 0xec } }; + + const HRESULT hr = fnDWCF(DWRITE_FACTORY_TYPE_SHARED, + IID_IDWriteFactory2, reinterpret_cast(&pIDWriteFactory)); + if (SUCCEEDED(hr)) { + // D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT + d2dDrawTextOptions = static_cast(0x00000004); + } else { + fnDWCF(DWRITE_FACTORY_TYPE_SHARED, + __uuidof(IDWriteFactory), + reinterpret_cast(&pIDWriteFactory)); + } } } if (pIDWriteFactory) { - HRESULT hr = pIDWriteFactory->CreateRenderingParams(&defaultRenderingParams); + const HRESULT hr = pIDWriteFactory->CreateRenderingParams(&defaultRenderingParams); if (SUCCEEDED(hr)) { unsigned int clearTypeContrast; if (::SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &clearTypeContrast, 0)) { @@ -165,10 +158,10 @@ struct FormatAndMetrics { FLOAT yAscent; FLOAT yDescent; FLOAT yInternalLeading; - FormatAndMetrics(HFONT hfont_, int extraFontFlag_, int characterSet_) : + FormatAndMetrics(HFONT hfont_, int extraFontFlag_, int characterSet_) noexcept : technology(SCWIN_TECH_GDI), hfont(hfont_), #if defined(USE_D2D) - pTextFormat(0), + pTextFormat(nullptr), #endif extraFontFlag(extraFontFlag_), characterSet(characterSet_), yAscent(2), yDescent(1), yInternalLeading(0) { } @@ -178,9 +171,9 @@ struct FormatAndMetrics { int characterSet_, FLOAT yAscent_, FLOAT yDescent_, - FLOAT yInternalLeading_) : + FLOAT yInternalLeading_) noexcept : technology(SCWIN_TECH_DIRECTWRITE), - hfont(0), + hfont{}, pTextFormat(pTextFormat_), extraFontFlag(extraFontFlag_), characterSet(characterSet_), @@ -189,13 +182,18 @@ struct FormatAndMetrics { yInternalLeading(yInternalLeading_) { } #endif + FormatAndMetrics(const FormatAndMetrics &) = delete; + FormatAndMetrics(FormatAndMetrics &&) = delete; + FormatAndMetrics &operator=(const FormatAndMetrics &) = delete; + FormatAndMetrics &operator=(FormatAndMetrics &&) = delete; + ~FormatAndMetrics() { if (hfont) ::DeleteObject(hfont); #if defined(USE_D2D) if (pTextFormat) pTextFormat->Release(); - pTextFormat = 0; + pTextFormat = nullptr; #endif extraFontFlag = 0; characterSet = 0; @@ -214,7 +212,7 @@ HFONT FormatAndMetrics::HFont() { return 0; } } else { - HRESULT hr = pTextFormat->GetFontFamilyName(lf.lfFaceName, LF_FACESIZE); + const HRESULT hr = pTextFormat->GetFontFamilyName(lf.lfFaceName, LF_FACESIZE); if (!SUCCEEDED(hr)) { return 0; } @@ -234,7 +232,26 @@ HFONT FormatAndMetrics::HFont() { #define CLEARTYPE_QUALITY 5 #endif -static BYTE Win32MapFontQuality(int extraFontFlag) { +namespace { + +void *PointerFromWindow(HWND hWnd) noexcept { + return reinterpret_cast(::GetWindowLongPtr(hWnd, 0)); +} + +void SetWindowPointer(HWND hWnd, void *ptr) noexcept { + ::SetWindowLongPtr(hWnd, 0, reinterpret_cast(ptr)); +} + +CRITICAL_SECTION crPlatformLock; +HINSTANCE hinstPlatformRes {}; + +HCURSOR reverseArrowCursor {}; + +FormatAndMetrics *FamFromFontID(void *fid) noexcept { + return static_cast(fid); +} + +BYTE Win32MapFontQuality(int extraFontFlag) noexcept { switch (extraFontFlag & SC_EFF_QUALITY_MASK) { case SC_EFF_QUALITY_NON_ANTIALIASED: @@ -252,7 +269,7 @@ static BYTE Win32MapFontQuality(int extraFontFlag) { } #if defined(USE_D2D) -static D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) { +D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) noexcept { switch (extraFontFlag & SC_EFF_QUALITY_MASK) { case SC_EFF_QUALITY_NON_ANTIALIASED: @@ -270,87 +287,47 @@ static D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) { } #endif -static void SetLogFont(LOGFONTW &lf, const char *faceName, int characterSet, float size, int weight, bool italic, int extraFontFlag) { +void SetLogFont(LOGFONTW &lf, const char *faceName, int characterSet, float size, int weight, bool italic, int extraFontFlag) { lf = LOGFONTW(); // The negative is to allow for leading - lf.lfHeight = -(abs(static_cast(size + 0.5))); + lf.lfHeight = -(std::abs(std::lround(size))); lf.lfWeight = weight; - lf.lfItalic = static_cast(italic ? 1 : 0); + lf.lfItalic = italic ? 1 : 0; lf.lfCharSet = static_cast(characterSet); lf.lfQuality = Win32MapFontQuality(extraFontFlag); UTF16FromUTF8(faceName, strlen(faceName)+1, lf.lfFaceName, LF_FACESIZE); } -/** - * Create a hash from the parameters for a font to allow easy checking for identity. - * If one font is the same as another, its hash will be the same, but if the hash is the - * same then they may still be different. - */ -static int HashFont(const FontParameters &fp) { - return - static_cast(fp.size) ^ - (fp.characterSet << 10) ^ - ((fp.extraFontFlag & SC_EFF_QUALITY_MASK) << 9) ^ - ((fp.weight/100) << 12) ^ - (fp.italic ? 0x20000000 : 0) ^ - (fp.technology << 15) ^ - fp.faceName[0]; -} - -class FontCached : Font { - FontCached *next; - int usage; - float size; +FontID CreateFontFromParameters(const FontParameters &fp) { LOGFONTW lf; - int technology; - int hash; - explicit FontCached(const FontParameters &fp); - ~FontCached() {} - bool SameAs(const FontParameters &fp); - virtual void Release(); - - static FontCached *first; -public: - static FontID FindOrCreate(const FontParameters &fp); - static void ReleaseId(FontID fid_); -}; - -FontCached *FontCached::first = 0; - -FontCached::FontCached(const FontParameters &fp) : - next(0), usage(0), size(1.0), hash(0) { SetLogFont(lf, fp.faceName, fp.characterSet, fp.size, fp.weight, fp.italic, fp.extraFontFlag); - technology = fp.technology; - hash = HashFont(fp); - fid = 0; - if (technology == SCWIN_TECH_GDI) { + FontID fid = nullptr; + if (fp.technology == SCWIN_TECH_GDI) { HFONT hfont = ::CreateFontIndirectW(&lf); - fid = reinterpret_cast(new FormatAndMetrics(hfont, fp.extraFontFlag, fp.characterSet)); + fid = new FormatAndMetrics(hfont, fp.extraFontFlag, fp.characterSet); } else { #if defined(USE_D2D) - IDWriteTextFormat *pTextFormat; - const int faceSize = 200; - WCHAR wszFace[faceSize]; - UTF16FromUTF8(fp.faceName, strlen(fp.faceName)+1, wszFace, faceSize); - FLOAT fHeight = fp.size; - DWRITE_FONT_STYLE style = fp.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL; - HRESULT hr = pIDWriteFactory->CreateTextFormat(wszFace, NULL, + IDWriteTextFormat *pTextFormat = nullptr; + const std::wstring wsFace = WStringFromUTF8(fp.faceName, strlen(fp.faceName) + 1); + const FLOAT fHeight = fp.size; + const DWRITE_FONT_STYLE style = fp.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL; + HRESULT hr = pIDWriteFactory->CreateTextFormat(wsFace.c_str(), nullptr, static_cast(fp.weight), style, DWRITE_FONT_STRETCH_NORMAL, fHeight, L"en-us", &pTextFormat); if (SUCCEEDED(hr)) { pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); - const int maxLines = 2; - DWRITE_LINE_METRICS lineMetrics[maxLines]; - UINT32 lineCount = 0; FLOAT yAscent = 1.0f; FLOAT yDescent = 1.0f; FLOAT yInternalLeading = 0.0f; - IDWriteTextLayout *pTextLayout = 0; + IDWriteTextLayout *pTextLayout = nullptr; hr = pIDWriteFactory->CreateTextLayout(L"X", 1, pTextFormat, 100.0f, 100.0f, &pTextLayout); if (SUCCEEDED(hr)) { + const int maxLines = 2; + DWRITE_LINE_METRICS lineMetrics[maxLines]{}; + UINT32 lineCount = 0; hr = pTextLayout->GetLineMetrics(lineMetrics, maxLines, &lineCount); if (SUCCEEDED(hr)) { yAscent = lineMetrics[0].baseline; @@ -365,92 +342,31 @@ FontCached::FontCached(const FontParameters &fp) : pTextLayout->Release(); pTextFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_UNIFORM, lineMetrics[0].height, lineMetrics[0].baseline); } - fid = reinterpret_cast(new FormatAndMetrics(pTextFormat, fp.extraFontFlag, fp.characterSet, yAscent, yDescent, yInternalLeading)); + fid = new FormatAndMetrics(pTextFormat, fp.extraFontFlag, fp.characterSet, yAscent, yDescent, yInternalLeading); } #endif } - usage = 1; + return fid; } -bool FontCached::SameAs(const FontParameters &fp) { - if ( - (size == fp.size) && - (lf.lfWeight == fp.weight) && - (lf.lfItalic == static_cast(fp.italic ? 1 : 0)) && - (lf.lfCharSet == fp.characterSet) && - (lf.lfQuality == Win32MapFontQuality(fp.extraFontFlag)) && - (technology == fp.technology)) { - wchar_t wszFace[LF_FACESIZE]; - UTF16FromUTF8(fp.faceName, strlen(fp.faceName)+1, wszFace, LF_FACESIZE); - return 0 == wcscmp(lf.lfFaceName,wszFace); - } - return false; } -void FontCached::Release() { - delete reinterpret_cast(fid); - fid = 0; -} - -FontID FontCached::FindOrCreate(const FontParameters &fp) { - FontID ret = 0; - ::EnterCriticalSection(&crPlatformLock); - int hashFind = HashFont(fp); - for (FontCached *cur=first; cur; cur=cur->next) { - if ((cur->hash == hashFind) && - cur->SameAs(fp)) { - cur->usage++; - ret = cur->fid; - } - } - if (ret == 0) { - FontCached *fc = new FontCached(fp); - fc->next = first; - first = fc; - ret = fc->fid; - } - ::LeaveCriticalSection(&crPlatformLock); - return ret; -} - -void FontCached::ReleaseId(FontID fid_) { - ::EnterCriticalSection(&crPlatformLock); - FontCached **pcur=&first; - for (FontCached *cur=first; cur; cur=cur->next) { - if (cur->fid == fid_) { - cur->usage--; - if (cur->usage == 0) { - *pcur = cur->next; - cur->Release(); - cur->next = 0; - delete cur; - } - break; - } - pcur=&cur->next; - } - ::LeaveCriticalSection(&crPlatformLock); -} - -Font::Font() { - fid = 0; +Font::Font() noexcept : fid{} { } Font::~Font() { } -#define FONTS_CACHED - void Font::Create(const FontParameters &fp) { Release(); if (fp.faceName) - fid = FontCached::FindOrCreate(fp); + fid = CreateFontFromParameters(fp); } void Font::Release() { if (fid) - FontCached::ReleaseId(fid); - fid = 0; + delete FamFromFontID(fid); + fid = nullptr; } // Buffer to hold strings and string position arrays without always allocating on heap. @@ -459,22 +375,25 @@ void Font::Release() { template class VarBuffer { T bufferStandard[lengthStandard]; - // Private so VarBuffer objects can not be copied - VarBuffer(const VarBuffer &); - VarBuffer &operator=(const VarBuffer &); public: T *buffer; - explicit VarBuffer(size_t length) : buffer(0) { + explicit VarBuffer(size_t length) : buffer(nullptr) { if (length > lengthStandard) { buffer = new T[length]; } else { buffer = bufferStandard; } } + // Deleted so VarBuffer objects can not be copied. + VarBuffer(const VarBuffer &) = delete; + VarBuffer(VarBuffer &&) = delete; + VarBuffer &operator=(const VarBuffer &) = delete; + VarBuffer &operator=(VarBuffer &&) = delete; + ~VarBuffer() { if (buffer != bufferStandard) { delete []buffer; - buffer = 0; + buffer = nullptr; } } }; @@ -482,7 +401,7 @@ public: const int stackBufferLength = 1000; class TextWide : public VarBuffer { public: - int tlen; + int tlen; // Using int instead of size_t as most Win32 APIs take int. TextWide(const char *s, int len, bool unicodeMode, int codePage=0) : VarBuffer(len) { if (unicodeMode) { @@ -496,125 +415,120 @@ public: typedef VarBuffer TextPositions; class SurfaceGDI : public Surface { - bool unicodeMode; - HDC hdc; - bool hdcOwned; - HPEN pen; - HPEN penOld; - HBRUSH brush; - HBRUSH brushOld; - HFONT font; - HFONT fontOld; - HBITMAP bitmap; - HBITMAP bitmapOld; - int maxWidthMeasure; - int maxLenText; + bool unicodeMode=false; + HDC hdc{}; + bool hdcOwned=false; + HPEN pen{}; + HPEN penOld{}; + HBRUSH brush{}; + HBRUSH brushOld{}; + HFONT fontOld{}; + HBITMAP bitmap{}; + HBITMAP bitmapOld{}; + int maxWidthMeasure = INT_MAX; + // There appears to be a 16 bit string length limit in GDI on NT. + int maxLenText = 65535; - int codePage; + int codePage = 0; - void BrushColor(ColourDesired back); - void SetFont(Font &font_); + void BrushColour(ColourDesired back) noexcept; + void SetFont(const Font &font_) noexcept; + void Clear() noexcept; - // Private so SurfaceGDI objects can not be copied - SurfaceGDI(const SurfaceGDI &); - SurfaceGDI &operator=(const SurfaceGDI &); public: - SurfaceGDI(); - virtual ~SurfaceGDI(); + SurfaceGDI() noexcept; + // Deleted so SurfaceGDI objects can not be copied. + SurfaceGDI(const SurfaceGDI &) = delete; + SurfaceGDI(SurfaceGDI &&) = delete; + SurfaceGDI &operator=(const SurfaceGDI &) = delete; + SurfaceGDI &operator=(SurfaceGDI &&) = delete; - void Init(WindowID wid); - void Init(SurfaceID sid, WindowID wid); - void InitPixMap(int width, int height, Surface *surface_, WindowID wid); + ~SurfaceGDI() noexcept override; - void Release(); - bool Initialised(); - void PenColour(ColourDesired fore); - int LogPixelsY(); - int DeviceHeightFont(int points); - void MoveTo(int x_, int y_); - void LineTo(int x_, int y_); - void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back); - void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back); - void FillRectangle(PRectangle rc, ColourDesired back); - void FillRectangle(PRectangle rc, Surface &surfacePattern); - void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back); + void Init(WindowID wid) override; + void Init(SurfaceID sid, WindowID wid) override; + void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override; + + void Release() override; + bool Initialised() override; + void PenColour(ColourDesired fore) override; + int LogPixelsY() override; + int DeviceHeightFont(int points) override; + void MoveTo(int x_, int y_) override; + void LineTo(int x_, int y_) override; + void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; + void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void FillRectangle(PRectangle rc, ColourDesired back) override; + void FillRectangle(PRectangle rc, Surface &surfacePattern) override; + void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int flags); - void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage); - void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back); - void Copy(PRectangle rc, Point from, Surface &surfaceSource); + ColourDesired outline, int alphaOutline, int flags) override; + void GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions options) override; + void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override; + void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; void DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, UINT fuOptions); - void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); - void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); - void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore); - void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions); - XYPOSITION WidthText(Font &font_, const char *s, int len); - XYPOSITION WidthChar(Font &font_, char ch); - XYPOSITION Ascent(Font &font_); - XYPOSITION Descent(Font &font_); - XYPOSITION InternalLeading(Font &font_); - XYPOSITION ExternalLeading(Font &font_); - XYPOSITION Height(Font &font_); - XYPOSITION AverageCharWidth(Font &font_); + void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) override; + void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) override; + void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore) override; + void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) override; + XYPOSITION WidthText(Font &font_, const char *s, int len) override; + XYPOSITION Ascent(Font &font_) override; + XYPOSITION Descent(Font &font_) override; + XYPOSITION InternalLeading(Font &font_) override; + XYPOSITION Height(Font &font_) override; + XYPOSITION AverageCharWidth(Font &font_) override; - void SetClip(PRectangle rc); - void FlushCachedState(); + void SetClip(PRectangle rc) override; + void FlushCachedState() override; - void SetUnicodeMode(bool unicodeMode_); - void SetDBCSMode(int codePage_); + void SetUnicodeMode(bool unicodeMode_) override; + void SetDBCSMode(int codePage_) override; }; -SurfaceGDI::SurfaceGDI() : - unicodeMode(false), - hdc(0), hdcOwned(false), - pen(0), penOld(0), - brush(0), brushOld(0), - font(0), fontOld(0), - bitmap(0), bitmapOld(0) { - maxWidthMeasure = INT_MAX; - // There appears to be a 16 bit string length limit in GDI on NT. - maxLenText = 65535; - - codePage = 0; +SurfaceGDI::SurfaceGDI() noexcept { } -SurfaceGDI::~SurfaceGDI() { - Release(); +SurfaceGDI::~SurfaceGDI() noexcept { + Clear(); } -void SurfaceGDI::Release() { +void SurfaceGDI::Clear() noexcept { if (penOld) { - ::SelectObject(reinterpret_cast(hdc), penOld); + ::SelectObject(hdc, penOld); ::DeleteObject(pen); penOld = 0; } pen = 0; if (brushOld) { - ::SelectObject(reinterpret_cast(hdc), brushOld); + ::SelectObject(hdc, brushOld); ::DeleteObject(brush); brushOld = 0; } brush = 0; if (fontOld) { // Fonts are not deleted as they are owned by a Font object - ::SelectObject(reinterpret_cast(hdc), fontOld); + ::SelectObject(hdc, fontOld); fontOld = 0; } - font = 0; if (bitmapOld) { - ::SelectObject(reinterpret_cast(hdc), bitmapOld); + ::SelectObject(hdc, bitmapOld); ::DeleteObject(bitmap); bitmapOld = 0; } bitmap = 0; if (hdcOwned) { - ::DeleteDC(reinterpret_cast(hdc)); + ::DeleteDC(hdc); hdc = 0; hdcOwned = false; } } +void SurfaceGDI::Release() { + Clear(); +} + bool SurfaceGDI::Initialised() { return hdc != 0; } @@ -623,13 +537,13 @@ void SurfaceGDI::Init(WindowID) { Release(); hdc = ::CreateCompatibleDC(NULL); hdcOwned = true; - ::SetTextAlign(reinterpret_cast(hdc), TA_BASELINE); + ::SetTextAlign(hdc, TA_BASELINE); } void SurfaceGDI::Init(SurfaceID sid, WindowID) { Release(); - hdc = reinterpret_cast(sid); - ::SetTextAlign(reinterpret_cast(hdc), TA_BASELINE); + hdc = static_cast(sid); + ::SetTextAlign(hdc, TA_BASELINE); } void SurfaceGDI::InitPixMap(int width, int height, Surface *surface_, WindowID) { @@ -638,8 +552,8 @@ void SurfaceGDI::InitPixMap(int width, int height, Surface *surface_, WindowID) hdc = ::CreateCompatibleDC(psurfOther->hdc); hdcOwned = true; bitmap = ::CreateCompatibleBitmap(psurfOther->hdc, width, height); - bitmapOld = static_cast(::SelectObject(hdc, bitmap)); - ::SetTextAlign(reinterpret_cast(hdc), TA_BASELINE); + bitmapOld = SelectBitmap(hdc, bitmap); + ::SetTextAlign(hdc, TA_BASELINE); SetUnicodeMode(psurfOther->unicodeMode); SetDBCSMode(psurfOther->codePage); } @@ -651,11 +565,11 @@ void SurfaceGDI::PenColour(ColourDesired fore) { pen = 0; penOld = 0; } - pen = ::CreatePen(0,1,fore.AsLong()); - penOld = static_cast(::SelectObject(reinterpret_cast(hdc), pen)); + pen = ::CreatePen(0,1,fore.AsInteger()); + penOld = SelectPen(hdc, pen); } -void SurfaceGDI::BrushColor(ColourDesired back) { +void SurfaceGDI::BrushColour(ColourDesired back) noexcept { if (brush) { ::SelectObject(hdc, brushOld); ::DeleteObject(brush); @@ -663,21 +577,18 @@ void SurfaceGDI::BrushColor(ColourDesired back) { brushOld = 0; } // Only ever want pure, non-dithered brushes - ColourDesired colourNearest = ::GetNearestColor(hdc, back.AsLong()); - brush = ::CreateSolidBrush(colourNearest.AsLong()); - brushOld = static_cast(::SelectObject(hdc, brush)); + const ColourDesired colourNearest = ColourDesired(::GetNearestColor(hdc, back.AsInteger())); + brush = ::CreateSolidBrush(colourNearest.AsInteger()); + brushOld = SelectBrush(hdc, brush); } -void SurfaceGDI::SetFont(Font &font_) { - if (font_.GetID() != font) { - FormatAndMetrics *pfm = reinterpret_cast(font_.GetID()); - PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_GDI); - if (fontOld) { - ::SelectObject(hdc, pfm->hfont); - } else { - fontOld = static_cast(::SelectObject(hdc, pfm->hfont)); - } - font = reinterpret_cast(pfm->hfont); +void SurfaceGDI::SetFont(const Font &font_) noexcept { + const FormatAndMetrics *pfm = FamFromFontID(font_.GetID()); + PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_GDI); + if (fontOld) { + SelectFont(hdc, pfm->hfont); + } else { + fontOld = SelectFont(hdc, pfm->hfont); } } @@ -690,27 +601,27 @@ int SurfaceGDI::DeviceHeightFont(int points) { } void SurfaceGDI::MoveTo(int x_, int y_) { - ::MoveToEx(hdc, x_, y_, 0); + ::MoveToEx(hdc, x_, y_, nullptr); } void SurfaceGDI::LineTo(int x_, int y_) { ::LineTo(hdc, x_, y_); } -void SurfaceGDI::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) { +void SurfaceGDI::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) { PenColour(fore); - BrushColor(back); + BrushColour(back); std::vector outline; - for (int i=0; i(pts[i].x), static_cast(pts[i].y)}; outline.push_back(pt); } - ::Polygon(hdc, &outline[0], npts); + ::Polygon(hdc, &outline[0], static_cast(npts)); } void SurfaceGDI::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { PenColour(fore); - BrushColor(back); + BrushColour(back); const RECT rcw = RectFromPRectangle(rc); ::Rectangle(hdc, rcw.left, rcw.top, rcw.right, rcw.bottom); } @@ -718,9 +629,9 @@ void SurfaceGDI::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired void SurfaceGDI::FillRectangle(PRectangle rc, ColourDesired back) { // Using ExtTextOut rather than a FillRect ensures that no dithering occurs. // There is no need to allocate a brush either. - RECT rcw = RectFromPRectangle(rc); - ::SetBkColor(hdc, back.AsLong()); - ::ExtTextOut(hdc, rcw.left, rcw.top, ETO_OPAQUE, &rcw, TEXT(""), 0, NULL); + const RECT rcw = RectFromPRectangle(rc); + ::SetBkColor(hdc, back.AsInteger()); + ::ExtTextOut(hdc, rcw.left, rcw.top, ETO_OPAQUE, &rcw, TEXT(""), 0, nullptr); } void SurfaceGDI::FillRectangle(PRectangle rc, Surface &surfacePattern) { @@ -729,14 +640,14 @@ void SurfaceGDI::FillRectangle(PRectangle rc, Surface &surfacePattern) { br = ::CreatePatternBrush(static_cast(surfacePattern).bitmap); else // Something is wrong so display in red br = ::CreateSolidBrush(RGB(0xff, 0, 0)); - RECT rcw = RectFromPRectangle(rc); + const RECT rcw = RectFromPRectangle(rc); ::FillRect(hdc, &rcw, br); ::DeleteObject(br); } void SurfaceGDI::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) { PenColour(fore); - BrushColor(back); + BrushColour(back); const RECT rcw = RectFromPRectangle(rc); ::RoundRect(hdc, rcw.left + 1, rcw.top, @@ -744,22 +655,17 @@ void SurfaceGDI::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesir 8, 8); } +namespace { + // Plot a point into a DWORD buffer symmetrically to all 4 quadrants -static void AllFour(DWORD *pixels, int width, int height, int x, int y, DWORD val) { +void AllFour(DWORD *pixels, int width, int height, int x, int y, DWORD val) noexcept { pixels[y*width+x] = val; pixels[y*width+width-1-x] = val; pixels[(height-1-y)*width+x] = val; pixels[(height-1-y)*width+width-1-x] = val; } -#ifndef AC_SRC_OVER -#define AC_SRC_OVER 0x00 -#endif -#ifndef AC_SRC_ALPHA -#define AC_SRC_ALPHA 0x01 -#endif - -static DWORD dwordFromBGRA(byte b, byte g, byte r, byte a) { +DWORD dwordFromBGRA(byte b, byte g, byte r, byte a) noexcept { union { byte pixVal[4]; DWORD val; @@ -771,35 +677,39 @@ static DWORD dwordFromBGRA(byte b, byte g, byte r, byte a) { return converter.val; } +DWORD dwordMultiplied(ColourDesired colour, unsigned int alpha) noexcept { + return dwordFromBGRA( + static_cast(colour.GetBlue() * alpha / 255), + static_cast(colour.GetGreen() * alpha / 255), + static_cast(colour.GetRed() * alpha / 255), + static_cast(alpha)); +} + +} + void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, ColourDesired outline, int alphaOutline, int /* flags*/ ) { const RECT rcw = RectFromPRectangle(rc); - if (AlphaBlendFn && rc.Width() > 0) { - HDC hMemDC = ::CreateCompatibleDC(reinterpret_cast(hdc)); - int width = static_cast(rc.Width()); - int height = static_cast(rc.Height()); + if (rc.Width() > 0) { + HDC hMemDC = ::CreateCompatibleDC(hdc); + const int width = rcw.right - rcw.left; + const int height = rcw.bottom - rcw.top; // Ensure not distorted too much by corners when small - cornerSize = Platform::Minimum(cornerSize, (Platform::Minimum(width, height) / 2) - 2); - BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}}; - void *image = 0; - HBITMAP hbmMem = CreateDIBSection(reinterpret_cast(hMemDC), &bpih, + cornerSize = std::min(cornerSize, (std::min(width, height) / 2) - 2); + const BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}, + {{0, 0, 0, 0}}}; + void *image = nullptr; + HBITMAP hbmMem = CreateDIBSection(hMemDC, &bpih, DIB_RGB_COLORS, &image, NULL, 0); if (hbmMem) { HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem); - DWORD valEmpty = dwordFromBGRA(0,0,0,0); - DWORD valFill = dwordFromBGRA( - static_cast(GetBValue(fill.AsLong()) * alphaFill / 255), - static_cast(GetGValue(fill.AsLong()) * alphaFill / 255), - static_cast(GetRValue(fill.AsLong()) * alphaFill / 255), - static_cast(alphaFill)); - DWORD valOutline = dwordFromBGRA( - static_cast(GetBValue(outline.AsLong()) * alphaOutline / 255), - static_cast(GetGValue(outline.AsLong()) * alphaOutline / 255), - static_cast(GetRValue(outline.AsLong()) * alphaOutline / 255), - static_cast(alphaOutline)); - DWORD *pixels = reinterpret_cast(image); + const DWORD valEmpty = dwordFromBGRA(0,0,0,0); + const DWORD valFill = dwordMultiplied(fill, alphaFill); + const DWORD valOutline = dwordMultiplied(outline, alphaOutline); + + DWORD *pixels = static_cast(image); for (int y=0; y(hdc), rcw.left, rcw.top, width, height, hMemDC, 0, 0, width, height, merge); + AlphaBlend(hdc, rcw.left, rcw.top, width, height, hMemDC, 0, 0, width, height, merge); SelectBitmap(hMemDC, hbmOld); ::DeleteObject(hbmMem); } ::DeleteDC(hMemDC); } else { - BrushColor(outline); + BrushColour(outline); FrameRect(hdc, &rcw, brush); } } +void SurfaceGDI::GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions) { + // Would be better to average start and end. + const ColourAlpha colourAverage = stops[0].colour.MixedWith(stops[1].colour); + AlphaRectangle(rc, 0, colourAverage.GetColour(), colourAverage.GetAlpha(), + colourAverage.GetColour(), colourAverage.GetAlpha(), 0); +} + void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { - if (AlphaBlendFn && rc.Width() > 0) { - HDC hMemDC = ::CreateCompatibleDC(reinterpret_cast(hdc)); + if (rc.Width() > 0) { + HDC hMemDC = ::CreateCompatibleDC(hdc); if (rc.Width() > width) - rc.left += static_cast((rc.Width() - width) / 2); + rc.left += std::floor((rc.Width() - width) / 2); rc.right = rc.left + width; if (rc.Height() > height) - rc.top += static_cast((rc.Height() - height) / 2); + rc.top += std::floor((rc.Height() - height) / 2); rc.bottom = rc.top + height; - BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}}; - unsigned char *image = 0; - HBITMAP hbmMem = CreateDIBSection(reinterpret_cast(hMemDC), &bpih, - DIB_RGB_COLORS, reinterpret_cast(&image), NULL, 0); + const BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}, + {{0, 0, 0, 0}}}; + void *image = nullptr; + HBITMAP hbmMem = CreateDIBSection(hMemDC, &bpih, + DIB_RGB_COLORS, &image, NULL, 0); if (hbmMem) { HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem); for (int y=height-1; y>=0; y--) { for (int x=0; x(image) + (y*width+x) * 4; + const unsigned char alpha = pixelsImage[3]; // Input is RGBA, output is BGRA with premultiplied alpha pixel[2] = static_cast((*pixelsImage++) * alpha / 255); pixel[1] = static_cast((*pixelsImage++) * alpha / 255); pixel[0] = static_cast((*pixelsImage++) * alpha / 255); - pixel[3] = static_cast(*pixelsImage++); + pixel[3] = *pixelsImage++; } } - BLENDFUNCTION merge = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; + const BLENDFUNCTION merge = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; - AlphaBlendFn(reinterpret_cast(hdc), static_cast(rc.left), static_cast(rc.top), + AlphaBlend(hdc, static_cast(rc.left), static_cast(rc.top), static_cast(rc.Width()), static_cast(rc.Height()), hMemDC, 0, 0, width, height, merge); SelectBitmap(hMemDC, hbmOld); @@ -876,7 +794,7 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig void SurfaceGDI::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { PenColour(fore); - BrushColor(back); + BrushColour(back); const RECT rcw = RectFromPRectangle(rc); ::Ellipse(hdc, rcw.left, rcw.top, rcw.right, rcw.bottom); } @@ -907,15 +825,15 @@ void SurfaceGDI::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, co void SurfaceGDI::DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) { - ::SetTextColor(hdc, fore.AsLong()); - ::SetBkColor(hdc, back.AsLong()); + ::SetTextColor(hdc, fore.AsInteger()); + ::SetBkColor(hdc, back.AsInteger()); DrawTextCommon(rc, font_, ybase, s, len, ETO_OPAQUE); } void SurfaceGDI::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) { - ::SetTextColor(hdc, fore.AsLong()); - ::SetBkColor(hdc, back.AsLong()); + ::SetTextColor(hdc, fore.AsInteger()); + ::SetBkColor(hdc, back.AsInteger()); DrawTextCommon(rc, font_, ybase, s, len, ETO_OPAQUE | ETO_CLIPPED); } @@ -924,7 +842,7 @@ void SurfaceGDI::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybas // Avoid drawing spaces in transparent mode for (int i=0; i(s[i])]; - if (lenChar == 4) { // Non-BMP + const unsigned char uch = s[i]; + const unsigned int byteCount = UTF8BytesOfLead[uch]; + if (byteCount == 4) { // Non-BMP ui++; } - for (unsigned int bytePos=0; (bytePos(poses.buffer[ui]); } } @@ -985,13 +904,6 @@ void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION * std::fill(positions+i, positions + len, lastPos); } -XYPOSITION SurfaceGDI::WidthChar(Font &font_, char ch) { - SetFont(font_); - SIZE sz; - ::GetTextExtentPoint32A(hdc, &ch, 1, &sz); - return static_cast(sz.cx); -} - XYPOSITION SurfaceGDI::Ascent(Font &font_) { SetFont(font_); TEXTMETRIC tm; @@ -1013,13 +925,6 @@ XYPOSITION SurfaceGDI::InternalLeading(Font &font_) { return static_cast(tm.tmInternalLeading); } -XYPOSITION SurfaceGDI::ExternalLeading(Font &font_) { - SetFont(font_); - TEXTMETRIC tm; - ::GetTextMetrics(hdc, &tm); - return static_cast(tm.tmExternalLeading); -} - XYPOSITION SurfaceGDI::Height(Font &font_) { SetFont(font_); TEXTMETRIC tm; @@ -1042,7 +947,6 @@ void SurfaceGDI::SetClip(PRectangle rc) { void SurfaceGDI::FlushCachedState() { pen = 0; brush = 0; - font = 0; } void SurfaceGDI::SetUnicodeMode(bool unicodeMode_) { @@ -1078,81 +982,83 @@ class SurfaceD2D : public Surface { float dpiScaleX; float dpiScaleY; - void SetFont(Font &font_); + void Clear() noexcept; + void SetFont(const Font &font_); - // Private so SurfaceD2D objects can not be copied - SurfaceD2D(const SurfaceD2D &); - SurfaceD2D &operator=(const SurfaceD2D &); public: - SurfaceD2D(); - virtual ~SurfaceD2D(); + SurfaceD2D() noexcept; + // Deleted so SurfaceD2D objects can not be copied. + SurfaceD2D(const SurfaceD2D &) = delete; + SurfaceD2D(SurfaceD2D &&) = delete; + SurfaceD2D &operator=(const SurfaceD2D &) = delete; + SurfaceD2D &operator=(SurfaceD2D &&) = delete; + ~SurfaceD2D() override; void SetScale(); - void Init(WindowID wid); - void Init(SurfaceID sid, WindowID wid); - void InitPixMap(int width, int height, Surface *surface_, WindowID wid); + void Init(WindowID wid) override; + void Init(SurfaceID sid, WindowID wid) override; + void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override; - void Release(); - bool Initialised(); + void Release() override; + bool Initialised() override; HRESULT FlushDrawing(); - void PenColour(ColourDesired fore); + void PenColour(ColourDesired fore) override; void D2DPenColour(ColourDesired fore, int alpha=255); - int LogPixelsY(); - int DeviceHeightFont(int points); - void MoveTo(int x_, int y_); - void LineTo(int x_, int y_); - void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back); - void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back); - void FillRectangle(PRectangle rc, ColourDesired back); - void FillRectangle(PRectangle rc, Surface &surfacePattern); - void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back); + int LogPixelsY() override; + int DeviceHeightFont(int points) override; + void MoveTo(int x_, int y_) override; + void LineTo(int x_, int y_) override; + void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; + void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void FillRectangle(PRectangle rc, ColourDesired back) override; + void FillRectangle(PRectangle rc, Surface &surfacePattern) override; + void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int flags); - void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage); - void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back); - void Copy(PRectangle rc, Point from, Surface &surfaceSource); + ColourDesired outline, int alphaOutline, int flags) override; + void GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions options) override; + void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override; + void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; void DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, UINT fuOptions); - void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); - void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); - void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore); - void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions); - XYPOSITION WidthText(Font &font_, const char *s, int len); - XYPOSITION WidthChar(Font &font_, char ch); - XYPOSITION Ascent(Font &font_); - XYPOSITION Descent(Font &font_); - XYPOSITION InternalLeading(Font &font_); - XYPOSITION ExternalLeading(Font &font_); - XYPOSITION Height(Font &font_); - XYPOSITION AverageCharWidth(Font &font_); + void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) override; + void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) override; + void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore) override; + void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) override; + XYPOSITION WidthText(Font &font_, const char *s, int len) override; + XYPOSITION Ascent(Font &font_) override; + XYPOSITION Descent(Font &font_) override; + XYPOSITION InternalLeading(Font &font_) override; + XYPOSITION Height(Font &font_) override; + XYPOSITION AverageCharWidth(Font &font_) override; - void SetClip(PRectangle rc); - void FlushCachedState(); + void SetClip(PRectangle rc) override; + void FlushCachedState() override; - void SetUnicodeMode(bool unicodeMode_); - void SetDBCSMode(int codePage_); + void SetUnicodeMode(bool unicodeMode_) override; + void SetDBCSMode(int codePage_) override; }; -SurfaceD2D::SurfaceD2D() : +SurfaceD2D::SurfaceD2D() noexcept : unicodeMode(false), x(0), y(0) { codePage = 0; codePageText = 0; - pRenderTarget = NULL; + pRenderTarget = nullptr; ownRenderTarget = false; clipsActive = 0; // From selected font - pTextFormat = NULL; + pTextFormat = nullptr; yAscent = 2; yDescent = 1; yInternalLeading = 0; - pBrush = NULL; + pBrush = nullptr; logPixelsY = 72; dpiScaleX = 1.0; @@ -1160,13 +1066,13 @@ SurfaceD2D::SurfaceD2D() : } SurfaceD2D::~SurfaceD2D() { - Release(); + Clear(); } -void SurfaceD2D::Release() { +void SurfaceD2D::Clear() noexcept { if (pBrush) { pBrush->Release(); - pBrush = 0; + pBrush = nullptr; } if (pRenderTarget) { while (clipsActive) { @@ -1176,10 +1082,14 @@ void SurfaceD2D::Release() { if (ownRenderTarget) { pRenderTarget->Release(); } - pRenderTarget = 0; + pRenderTarget = nullptr; } } +void SurfaceD2D::Release() { + Clear(); +} + void SurfaceD2D::SetScale() { HDC hdcMeasure = ::CreateCompatibleDC(NULL); logPixelsY = ::GetDeviceCaps(hdcMeasure, LOGPIXELSY); @@ -1189,7 +1099,7 @@ void SurfaceD2D::SetScale() { } bool SurfaceD2D::Initialised() { - return pRenderTarget != 0; + return pRenderTarget != nullptr; } HRESULT SurfaceD2D::FlushDrawing() { @@ -1204,15 +1114,15 @@ void SurfaceD2D::Init(WindowID /* wid */) { void SurfaceD2D::Init(SurfaceID sid, WindowID) { Release(); SetScale(); - pRenderTarget = reinterpret_cast(sid); + pRenderTarget = static_cast(sid); } void SurfaceD2D::InitPixMap(int width, int height, Surface *surface_, WindowID) { Release(); SetScale(); SurfaceD2D *psurfOther = static_cast(surface_); - ID2D1BitmapRenderTarget *pCompatibleRenderTarget = NULL; - D2D1_SIZE_F desiredSize = D2D1::SizeF(static_cast(width), static_cast(height)); + ID2D1BitmapRenderTarget *pCompatibleRenderTarget = nullptr; + const D2D1_SIZE_F desiredSize = D2D1::SizeF(static_cast(width), static_cast(height)); D2D1_PIXEL_FORMAT desiredFormat; #ifdef __MINGW32__ desiredFormat.format = DXGI_FORMAT_UNKNOWN; @@ -1220,8 +1130,8 @@ void SurfaceD2D::InitPixMap(int width, int height, Surface *surface_, WindowID) desiredFormat = psurfOther->pRenderTarget->GetPixelFormat(); #endif desiredFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE; - HRESULT hr = psurfOther->pRenderTarget->CreateCompatibleRenderTarget( - &desiredSize, NULL, &desiredFormat, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE, &pCompatibleRenderTarget); + const HRESULT hr = psurfOther->pRenderTarget->CreateCompatibleRenderTarget( + &desiredSize, nullptr, &desiredFormat, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE, &pCompatibleRenderTarget); if (SUCCEEDED(hr)) { pRenderTarget = pCompatibleRenderTarget; pRenderTarget->BeginDraw(); @@ -1238,32 +1148,32 @@ void SurfaceD2D::PenColour(ColourDesired fore) { void SurfaceD2D::D2DPenColour(ColourDesired fore, int alpha) { if (pRenderTarget) { D2D_COLOR_F col; - col.r = (fore.AsLong() & 0xff) / 255.0f; - col.g = ((fore.AsLong() & 0xff00) >> 8) / 255.0f; - col.b = (fore.AsLong() >> 16) / 255.0f; + col.r = fore.GetRedComponent(); + col.g = fore.GetGreenComponent(); + col.b = fore.GetBlueComponent(); col.a = alpha / 255.0f; if (pBrush) { pBrush->SetColor(col); } else { - HRESULT hr = pRenderTarget->CreateSolidColorBrush(col, &pBrush); + const HRESULT hr = pRenderTarget->CreateSolidColorBrush(col, &pBrush); if (!SUCCEEDED(hr) && pBrush) { pBrush->Release(); - pBrush = 0; + pBrush = nullptr; } } } } -void SurfaceD2D::SetFont(Font &font_) { - FormatAndMetrics *pfm = reinterpret_cast(font_.GetID()); +void SurfaceD2D::SetFont(const Font &font_) { + const FormatAndMetrics *pfm = FamFromFontID(font_.GetID()); PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_DIRECTWRITE); pTextFormat = pfm->pTextFormat; yAscent = pfm->yAscent; yDescent = pfm->yDescent; yInternalLeading = pfm->yInternalLeading; codePageText = codePage; - if (pfm->characterSet) { - codePageText = CodePageFromCharSet(pfm->characterSet, codePage); + if (!unicodeMode && pfm->characterSet) { + codePageText = Scintilla::CodePageFromCharSet(pfm->characterSet, codePage); } if (pRenderTarget) { D2D1_TEXT_ANTIALIAS_MODE aaMode; @@ -1291,7 +1201,7 @@ void SurfaceD2D::MoveTo(int x_, int y_) { y = y_; } -static int Delta(int difference) { +static int Delta(int difference) noexcept { if (difference < 0) return -1; else if (difference > 0) @@ -1300,28 +1210,24 @@ static int Delta(int difference) { return 0; } -static float RoundFloat(float f) { - return float(int(f+0.5f)); -} - void SurfaceD2D::LineTo(int x_, int y_) { if (pRenderTarget) { - int xDiff = x_ - x; - int xDelta = Delta(xDiff); - int yDiff = y_ - y; - int yDelta = Delta(yDiff); + const int xDiff = x_ - x; + const int xDelta = Delta(xDiff); + const int yDiff = y_ - y; + const int yDelta = Delta(yDiff); if ((xDiff == 0) || (yDiff == 0)) { // Horizontal or vertical lines can be more precisely drawn as a filled rectangle - int xEnd = x_ - xDelta; - int left = Platform::Minimum(x, xEnd); - int width = abs(x - xEnd) + 1; - int yEnd = y_ - yDelta; - int top = Platform::Minimum(y, yEnd); - int height = abs(y - yEnd) + 1; - D2D1_RECT_F rectangle1 = D2D1::RectF(static_cast(left), static_cast(top), + const int xEnd = x_ - xDelta; + const int left = std::min(x, xEnd); + const int width = std::abs(x - xEnd) + 1; + const int yEnd = y_ - yDelta; + const int top = std::min(y, yEnd); + const int height = std::abs(y - yEnd) + 1; + const D2D1_RECT_F rectangle1 = D2D1::RectF(static_cast(left), static_cast(top), static_cast(left+width), static_cast(top+height)); pRenderTarget->FillRectangle(&rectangle1, pBrush); - } else if ((abs(xDiff) == abs(yDiff))) { + } else if ((std::abs(xDiff) == std::abs(yDiff))) { // 45 degree slope pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5f, y + 0.5f), D2D1::Point2F(x_ + 0.5f - xDelta, y_ + 0.5f - yDelta), pBrush); @@ -1335,18 +1241,18 @@ void SurfaceD2D::LineTo(int x_, int y_) { } } -void SurfaceD2D::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) { +void SurfaceD2D::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) { if (pRenderTarget) { - ID2D1Factory *pFactory = 0; + ID2D1Factory *pFactory = nullptr; pRenderTarget->GetFactory(&pFactory); - ID2D1PathGeometry *geometry=0; + ID2D1PathGeometry *geometry=nullptr; HRESULT hr = pFactory->CreatePathGeometry(&geometry); if (SUCCEEDED(hr)) { - ID2D1GeometrySink *sink = 0; + ID2D1GeometrySink *sink = nullptr; hr = geometry->Open(&sink); if (SUCCEEDED(hr)) { sink->BeginFigure(D2D1::Point2F(pts[0].x + 0.5f, pts[0].y + 0.5f), D2D1_FIGURE_BEGIN_FILLED); - for (size_t i=1; i(npts); i++) { + for (size_t i=1; iAddLine(D2D1::Point2F(pts[i].x + 0.5f, pts[i].y + 0.5f)); } sink->EndFigure(D2D1_FIGURE_END_CLOSED); @@ -1366,7 +1272,7 @@ void SurfaceD2D::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { if (pRenderTarget) { - D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left) + 0.5f, rc.top+0.5f, RoundFloat(rc.right) - 0.5f, rc.bottom-0.5f); + const D2D1_RECT_F rectangle1 = D2D1::RectF(std::round(rc.left) + 0.5f, rc.top+0.5f, std::round(rc.right) - 0.5f, rc.bottom-0.5f); D2DPenColour(back); pRenderTarget->FillRectangle(&rectangle1, pBrush); D2DPenColour(fore); @@ -1377,7 +1283,7 @@ void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired void SurfaceD2D::FillRectangle(PRectangle rc, ColourDesired back) { if (pRenderTarget) { D2DPenColour(back); - D2D1_RECT_F rectangle1 = D2D1::RectF(RoundFloat(rc.left), rc.top, RoundFloat(rc.right), rc.bottom); + const D2D1_RECT_F rectangle1 = D2D1::RectF(std::round(rc.left), rc.top, std::round(rc.right), rc.bottom); pRenderTarget->FillRectangle(&rectangle1, pBrush); } } @@ -1385,13 +1291,13 @@ void SurfaceD2D::FillRectangle(PRectangle rc, ColourDesired back) { void SurfaceD2D::FillRectangle(PRectangle rc, Surface &surfacePattern) { SurfaceD2D &surfOther = static_cast(surfacePattern); surfOther.FlushDrawing(); - ID2D1Bitmap *pBitmap = NULL; + ID2D1Bitmap *pBitmap = nullptr; ID2D1BitmapRenderTarget *pCompatibleRenderTarget = reinterpret_cast( surfOther.pRenderTarget); HRESULT hr = pCompatibleRenderTarget->GetBitmap(&pBitmap); if (SUCCEEDED(hr)) { - ID2D1BitmapBrush *pBitmapBrush = NULL; - D2D1_BITMAP_BRUSH_PROPERTIES brushProperties = + ID2D1BitmapBrush *pBitmapBrush = nullptr; + const D2D1_BITMAP_BRUSH_PROPERTIES brushProperties = D2D1::BitmapBrushProperties(D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_WRAP, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR); // Create the bitmap brush. @@ -1427,23 +1333,23 @@ void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil if (pRenderTarget) { if (cornerSize == 0) { // When corner size is zero, draw square rectangle to prevent blurry pixels at corners - D2D1_RECT_F rectFill = D2D1::RectF(RoundFloat(rc.left) + 1.0f, rc.top + 1.0f, RoundFloat(rc.right) - 1.0f, rc.bottom - 1.0f); + const D2D1_RECT_F rectFill = D2D1::RectF(std::round(rc.left) + 1.0f, rc.top + 1.0f, std::round(rc.right) - 1.0f, rc.bottom - 1.0f); D2DPenColour(fill, alphaFill); pRenderTarget->FillRectangle(rectFill, pBrush); - D2D1_RECT_F rectOutline = D2D1::RectF(RoundFloat(rc.left) + 0.5f, rc.top + 0.5f, RoundFloat(rc.right) - 0.5f, rc.bottom - 0.5f); + const D2D1_RECT_F rectOutline = D2D1::RectF(std::round(rc.left) + 0.5f, rc.top + 0.5f, std::round(rc.right) - 0.5f, rc.bottom - 0.5f); D2DPenColour(outline, alphaOutline); pRenderTarget->DrawRectangle(rectOutline, pBrush); } else { const float cornerSizeF = static_cast(cornerSize); D2D1_ROUNDED_RECT roundedRectFill = { - D2D1::RectF(RoundFloat(rc.left) + 1.0f, rc.top + 1.0f, RoundFloat(rc.right) - 1.0f, rc.bottom - 1.0f), + D2D1::RectF(std::round(rc.left) + 1.0f, rc.top + 1.0f, std::round(rc.right) - 1.0f, rc.bottom - 1.0f), cornerSizeF, cornerSizeF}; D2DPenColour(fill, alphaFill); pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush); D2D1_ROUNDED_RECT roundedRect = { - D2D1::RectF(RoundFloat(rc.left) + 0.5f, rc.top + 0.5f, RoundFloat(rc.right) - 0.5f, rc.bottom - 0.5f), + D2D1::RectF(std::round(rc.left) + 0.5f, rc.top + 0.5f, std::round(rc.right) - 0.5f, rc.bottom - 0.5f), cornerSizeF, cornerSizeF}; D2DPenColour(outline, alphaOutline); pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush); @@ -1451,20 +1357,69 @@ void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil } } +namespace { + +D2D_COLOR_F ColorFromColourAlpha(ColourAlpha colour) noexcept { + D2D_COLOR_F col; + col.r = colour.GetRedComponent(); + col.g = colour.GetGreenComponent(); + col.b = colour.GetBlueComponent(); + col.a = colour.GetAlphaComponent(); + return col; +} + +} + +void SurfaceD2D::GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions options) { + if (pRenderTarget) { + D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES lgbp; + lgbp.startPoint = D2D1::Point2F(rc.left, rc.top); + switch (options) { + case GradientOptions::leftToRight: + lgbp.endPoint = D2D1::Point2F(rc.right, rc.top); + break; + case GradientOptions::topToBottom: + default: + lgbp.endPoint = D2D1::Point2F(rc.left, rc.bottom); + break; + } + + std::vector gradientStops; + for (const ColourStop &stop : stops) { + gradientStops.push_back({ stop.position, ColorFromColourAlpha(stop.colour) }); + } + ID2D1GradientStopCollection *pGradientStops = nullptr; + HRESULT hr = pRenderTarget->CreateGradientStopCollection( + gradientStops.data(), static_cast(gradientStops.size()), &pGradientStops); + if (FAILED(hr)) { + return; + } + ID2D1LinearGradientBrush *pBrushLinear = nullptr; + hr = pRenderTarget->CreateLinearGradientBrush( + lgbp, pGradientStops, &pBrushLinear); + if (SUCCEEDED(hr)) { + const D2D1_RECT_F rectangle = D2D1::RectF(std::round(rc.left), rc.top, std::round(rc.right), rc.bottom); + pRenderTarget->FillRectangle(&rectangle, pBrushLinear); + pBrushLinear->Release(); + } + pGradientStops->Release(); + } +} + void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { if (pRenderTarget) { if (rc.Width() > width) - rc.left += static_cast((rc.Width() - width) / 2); + rc.left += std::floor((rc.Width() - width) / 2); rc.right = rc.left + width; if (rc.Height() > height) - rc.top += static_cast((rc.Height() - height) / 2); + rc.top += std::floor((rc.Height() - height) / 2); rc.bottom = rc.top + height; std::vector image(height * width * 4); for (int yPixel=0; yPixelCreateBitmap(size, &image[0], + const HRESULT hr = pRenderTarget->CreateBitmap(size, &image[0], width * 4, &props, &bitmap); if (SUCCEEDED(hr)) { D2D1_RECT_F rcDestination = {rc.left, rc.top, rc.right, rc.bottom}; @@ -1489,7 +1444,7 @@ void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsig void SurfaceD2D::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { if (pRenderTarget) { - FLOAT radius = rc.Width() / 2.0f; + const FLOAT radius = rc.Width() / 2.0f; D2D1_ELLIPSE ellipse = { D2D1::Point2F((rc.left + rc.right) / 2.0f, (rc.top + rc.bottom) / 2.0f), radius,radius}; @@ -1506,7 +1461,7 @@ void SurfaceD2D::Copy(PRectangle rc, Point from, Surface &surfaceSource) { surfOther.FlushDrawing(); ID2D1BitmapRenderTarget *pCompatibleRenderTarget = reinterpret_cast( surfOther.pRenderTarget); - ID2D1Bitmap *pBitmap = NULL; + ID2D1Bitmap *pBitmap = nullptr; HRESULT hr = pCompatibleRenderTarget->GetBitmap(&pBitmap); if (SUCCEEDED(hr)) { D2D1_RECT_F rcDestination = {rc.left, rc.top, rc.right, rc.bottom}; @@ -1515,7 +1470,7 @@ void SurfaceD2D::Copy(PRectangle rc, Point from, Surface &surfaceSource) { D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, rcSource); hr = pRenderTarget->Flush(); if (FAILED(hr)) { - Platform::DebugPrintf("Failed Flush 0x%x\n", hr); + Platform::DebugPrintf("Failed Flush 0x%lx\n", hr); } pBitmap->Release(); } @@ -1534,11 +1489,11 @@ void SurfaceD2D::DrawTextCommon(PRectangle rc, Font &font_, XYPOSITION ybase, co // Explicitly creating a text layout appears a little faster IDWriteTextLayout *pTextLayout; - HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, + const HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, rc.Width(), rc.Height(), &pTextLayout); if (SUCCEEDED(hr)) { D2D1_POINT_2F origin = {rc.left, ybase-yAscent}; - pRenderTarget->DrawTextLayout(origin, pTextLayout, pBrush, D2D1_DRAW_TEXT_OPTIONS_NONE); + pRenderTarget->DrawTextLayout(origin, pTextLayout, pBrush, d2dDrawTextOptions); pTextLayout->Release(); } @@ -1586,8 +1541,8 @@ XYPOSITION SurfaceD2D::WidthText(Font &font_, const char *s, int len) { const TextWide tbuf(s, len, unicodeMode, codePageText); if (pIDWriteFactory && pTextFormat) { // Create a layout - IDWriteTextLayout *pTextLayout = 0; - HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, 1000.0, 1000.0, &pTextLayout); + IDWriteTextLayout *pTextLayout = nullptr; + const HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, 1000.0, 1000.0, &pTextLayout); if (SUCCEEDED(hr)) { DWRITE_TEXT_METRICS textMetrics; if (SUCCEEDED(pTextLayout->GetMetrics(&textMetrics))) @@ -1600,52 +1555,49 @@ XYPOSITION SurfaceD2D::WidthText(Font &font_, const char *s, int len) { void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) { SetFont(font_); - int fit = 0; + if (!pIDWriteFactory || !pTextFormat) { + // SetFont failed or no access to DirectWrite so give up. + return; + } const TextWide tbuf(s, len, unicodeMode, codePageText); TextPositions poses(tbuf.tlen); - fit = tbuf.tlen; - const int clusters = 1000; + // Initialize poses for safety. + std::fill(poses.buffer, poses.buffer + tbuf.tlen, 0.0f); + // Create a layout + IDWriteTextLayout *pTextLayout = nullptr; + const HRESULT hrCreate = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, 10000.0, 1000.0, &pTextLayout); + if (!SUCCEEDED(hrCreate)) { + return; + } + const int clusters = stackBufferLength; DWRITE_CLUSTER_METRICS clusterMetrics[clusters]; UINT32 count = 0; - if (pIDWriteFactory && pTextFormat) { - SetFont(font_); - // Create a layout - IDWriteTextLayout *pTextLayout = 0; - HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, 10000.0, 1000.0, &pTextLayout); - if (!SUCCEEDED(hr)) - return; - // For now, assuming WCHAR == cluster - if (!SUCCEEDED(pTextLayout->GetClusterMetrics(clusterMetrics, clusters, &count))) - return; - FLOAT position = 0.0f; - size_t ti=0; - for (size_t ci=0; ci(tbuf.tlen)); - pTextLayout->Release(); + const HRESULT hrGetCluster = pTextLayout->GetClusterMetrics(clusterMetrics, clusters, &count); + pTextLayout->Release(); + if (!SUCCEEDED(hrGetCluster)) { + return; } + // A cluster may be more than one WCHAR, such as for "ffi" which is a ligature in the Candara font + FLOAT position = 0.0f; + size_t ti=0; + for (size_t ci=0; ci(tbuf.tlen)); if (unicodeMode) { // Map the widths given for UTF-16 characters back onto the UTF-8 input string int ui=0; - const unsigned char *us = reinterpret_cast(s); int i=0; - while (ui= (0x80 + 0x40 + 0x20 + 0x10)) { - lenChar = 4; + while (ui= (0x80 + 0x40 + 0x20)) { - lenChar = 3; - } else if (uch >= (0x80)) { - lenChar = 2; } - for (unsigned int bytePos=0; (bytePos(len); kk++) { + for (int kk=0; kkCreateTextLayout(&wch, 1, pTextFormat, 1000.0, 1000.0, &pTextLayout); - if (SUCCEEDED(hr)) { - DWRITE_TEXT_METRICS textMetrics; - if (SUCCEEDED(pTextLayout->GetMetrics(&textMetrics))) - width = textMetrics.widthIncludingTrailingWhitespace; - pTextLayout->Release(); - } - } - return width; -} - XYPOSITION SurfaceD2D::Ascent(Font &font_) { SetFont(font_); - return ceil(yAscent); + return std::ceil(yAscent); } XYPOSITION SurfaceD2D::Descent(Font &font_) { SetFont(font_); - return ceil(yDescent); + return std::ceil(yDescent); } XYPOSITION SurfaceD2D::InternalLeading(Font &font_) { SetFont(font_); - return floor(yInternalLeading); -} - -XYPOSITION SurfaceD2D::ExternalLeading(Font &) { - // Not implemented, always return one - return 1; + return std::floor(yInternalLeading); } XYPOSITION SurfaceD2D::Height(Font &font_) { @@ -1733,10 +1658,10 @@ XYPOSITION SurfaceD2D::AverageCharWidth(Font &font_) { SetFont(font_); if (pIDWriteFactory && pTextFormat) { // Create a layout - IDWriteTextLayout *pTextLayout = 0; + IDWriteTextLayout *pTextLayout = nullptr; const WCHAR wszAllAlpha[] = L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; const size_t lenAllAlpha = wcslen(wszAllAlpha); - HRESULT hr = pIDWriteFactory->CreateTextLayout(wszAllAlpha, static_cast(lenAllAlpha), + const HRESULT hr = pIDWriteFactory->CreateTextLayout(wszAllAlpha, static_cast(lenAllAlpha), pTextFormat, 1000.0, 1000.0, &pTextLayout); if (SUCCEEDED(hr)) { DWRITE_TEXT_METRICS textMetrics; @@ -1780,38 +1705,42 @@ Surface *Surface::Allocate(int technology) { #endif } +namespace { + +HWND HwndFromWindowID(WindowID wid) noexcept { + return static_cast(wid); +} + +} + Window::~Window() { } void Window::Destroy() { if (wid) - ::DestroyWindow(reinterpret_cast(wid)); - wid = 0; + ::DestroyWindow(HwndFromWindowID(wid)); + wid = nullptr; } -bool Window::HasFocus() { - return ::GetFocus() == wid; -} - -PRectangle Window::GetPosition() { +PRectangle Window::GetPosition() const { RECT rc; - ::GetWindowRect(reinterpret_cast(wid), &rc); + ::GetWindowRect(HwndFromWindowID(wid), &rc); return PRectangle::FromInts(rc.left, rc.top, rc.right, rc.bottom); } void Window::SetPosition(PRectangle rc) { - ::SetWindowPos(reinterpret_cast(wid), + ::SetWindowPos(HwndFromWindowID(wid), 0, static_cast(rc.left), static_cast(rc.top), static_cast(rc.Width()), static_cast(rc.Height()), SWP_NOZORDER | SWP_NOACTIVATE); } -static RECT RectFromMonitor(HMONITOR hMonitor) { - if (GetMonitorInfoFn) { - MONITORINFO mi = {0}; - mi.cbSize = sizeof(mi); - if (GetMonitorInfoFn(hMonitor, &mi)) { - return mi.rcWork; - } +namespace { + +static RECT RectFromMonitor(HMONITOR hMonitor) noexcept { + MONITORINFO mi = {}; + mi.cbSize = sizeof(mi); + if (GetMonitorInfo(hMonitor, &mi)) { + return mi.rcWork; } RECT rc = {0, 0, 0, 0}; if (::SystemParametersInfoA(SPI_GETWORKAREA, 0, &rc, 0) == 0) { @@ -1823,21 +1752,20 @@ static RECT RectFromMonitor(HMONITOR hMonitor) { return rc; } -void Window::SetPositionRelative(PRectangle rc, Window w) { - LONG style = ::GetWindowLong(reinterpret_cast(wid), GWL_STYLE); +} + +void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) { + const LONG style = ::GetWindowLong(HwndFromWindowID(wid), GWL_STYLE); if (style & WS_POPUP) { POINT ptOther = {0, 0}; - ::ClientToScreen(reinterpret_cast(w.GetID()), &ptOther); + ::ClientToScreen(HwndFromWindowID(relativeTo->GetID()), &ptOther); rc.Move(static_cast(ptOther.x), static_cast(ptOther.y)); - RECT rcMonitor = RectFromPRectangle(rc); + const RECT rcMonitor = RectFromPRectangle(rc); - HMONITOR hMonitor = NULL; - if (MonitorFromRectFn) - hMonitor = MonitorFromRectFn(&rcMonitor, MONITOR_DEFAULTTONEAREST); + HMONITOR hMonitor = MonitorFromRect(&rcMonitor, MONITOR_DEFAULTTONEAREST); // If hMonitor is NULL, that's just the main screen anyways. - //::GetMonitorInfo(hMonitor, &mi); - RECT rcWork = RectFromMonitor(hMonitor); + const RECT rcWork = RectFromMonitor(hMonitor); if (rcWork.left < rcWork.right) { // Now clamp our desired rectangle to fit inside the work area @@ -1857,72 +1785,70 @@ void Window::SetPositionRelative(PRectangle rc, Window w) { SetPosition(rc); } -PRectangle Window::GetClientPosition() { +PRectangle Window::GetClientPosition() const { RECT rc={0,0,0,0}; if (wid) - ::GetClientRect(reinterpret_cast(wid), &rc); + ::GetClientRect(HwndFromWindowID(wid), &rc); return PRectangle::FromInts(rc.left, rc.top, rc.right, rc.bottom); } void Window::Show(bool show) { if (show) - ::ShowWindow(reinterpret_cast(wid), SW_SHOWNOACTIVATE); + ::ShowWindow(HwndFromWindowID(wid), SW_SHOWNOACTIVATE); else - ::ShowWindow(reinterpret_cast(wid), SW_HIDE); + ::ShowWindow(HwndFromWindowID(wid), SW_HIDE); } void Window::InvalidateAll() { - ::InvalidateRect(reinterpret_cast(wid), NULL, FALSE); + ::InvalidateRect(HwndFromWindowID(wid), nullptr, FALSE); } void Window::InvalidateRectangle(PRectangle rc) { - RECT rcw = RectFromPRectangle(rc); - ::InvalidateRect(reinterpret_cast(wid), &rcw, FALSE); -} - -static LRESULT Window_SendMessage(Window *w, UINT msg, WPARAM wParam=0, LPARAM lParam=0) { - return ::SendMessage(reinterpret_cast(w->GetID()), msg, wParam, lParam); + const RECT rcw = RectFromPRectangle(rc); + ::InvalidateRect(HwndFromWindowID(wid), &rcw, FALSE); } void Window::SetFont(Font &font) { - Window_SendMessage(this, WM_SETFONT, + ::SendMessage(HwndFromWindowID(wid), WM_SETFONT, reinterpret_cast(font.GetID()), 0); } -static void FlipBitmap(HBITMAP bitmap, int width, int height) { +namespace { + +void FlipBitmap(HBITMAP bitmap, int width, int height) noexcept { HDC hdc = ::CreateCompatibleDC(NULL); - if (hdc != NULL) { - HGDIOBJ prevBmp = ::SelectObject(hdc, bitmap); + if (hdc) { + HBITMAP prevBmp = SelectBitmap(hdc, bitmap); ::StretchBlt(hdc, width - 1, 0, -width, height, hdc, 0, 0, width, height, SRCCOPY); - ::SelectObject(hdc, prevBmp); + SelectBitmap(hdc, prevBmp); ::DeleteDC(hdc); } } -static HCURSOR GetReverseArrowCursor() { - if (reverseArrowCursor != NULL) +HCURSOR GetReverseArrowCursor() noexcept { + if (reverseArrowCursor) return reverseArrowCursor; ::EnterCriticalSection(&crPlatformLock); HCURSOR cursor = reverseArrowCursor; - if (cursor == NULL) { + if (!cursor) { cursor = ::LoadCursor(NULL, IDC_ARROW); ICONINFO info; if (::GetIconInfo(cursor, &info)) { BITMAP bmp; if (::GetObject(info.hbmMask, sizeof(bmp), &bmp)) { FlipBitmap(info.hbmMask, bmp.bmWidth, bmp.bmHeight); - if (info.hbmColor != NULL) + if (info.hbmColor) FlipBitmap(info.hbmColor, bmp.bmWidth, bmp.bmHeight); - info.xHotspot = (DWORD)bmp.bmWidth - 1 - info.xHotspot; + info.xHotspot = bmp.bmWidth - 1 - info.xHotspot; reverseArrowCursor = ::CreateIconIndirect(&info); - if (reverseArrowCursor != NULL) + if (reverseArrowCursor) cursor = reverseArrowCursor; } ::DeleteObject(info.hbmMask); - if (info.hbmColor != NULL) + if (info.hbmColor) ::DeleteObject(info.hbmColor); } } @@ -1930,6 +1856,8 @@ static HCURSOR GetReverseArrowCursor() { return cursor; } +} + void Window::SetCursor(Cursor curs) { switch (curs) { case cursorText: @@ -1960,22 +1888,15 @@ void Window::SetCursor(Cursor curs) { } } -void Window::SetTitle(const char *s) { - ::SetWindowTextA(reinterpret_cast(wid), s); -} - /* Returns rectangle of monitor pt is on, both rect and pt are in Window's coordinates */ PRectangle Window::GetMonitorRect(Point pt) { - // MonitorFromPoint and GetMonitorInfo are not available on Windows 95 and NT 4. - PRectangle rcPosition = GetPosition(); + const PRectangle rcPosition = GetPosition(); POINT ptDesktop = {static_cast(pt.x + rcPosition.left), static_cast(pt.y + rcPosition.top)}; - HMONITOR hMonitor = NULL; - if (MonitorFromPointFn) - hMonitor = MonitorFromPointFn(ptDesktop, MONITOR_DEFAULTTONEAREST); + HMONITOR hMonitor = MonitorFromPoint(ptDesktop, MONITOR_DEFAULTTONEAREST); - RECT rcWork = RectFromMonitor(hMonitor); + const RECT rcWork = RectFromMonitor(hMonitor); if (rcWork.left < rcWork.right) { PRectangle rcMonitor( rcWork.left - rcPosition.left, @@ -1999,25 +1920,20 @@ class LineToItem { std::vector data; public: - LineToItem() { - } - ~LineToItem() { - Clear(); - } - void Clear() { + void Clear() noexcept { words.clear(); data.clear(); } - ListItemData Get(int index) const { - if (index >= 0 && index < static_cast(data.size())) { + ListItemData Get(size_t index) const { + if (index < data.size()) { return data[index]; } else { ListItemData missing = {"", -1}; return missing; } } - int Count() const { + int Count() const noexcept { return static_cast(data.size()); } @@ -2034,7 +1950,7 @@ public: const TCHAR ListBoxX_ClassName[] = TEXT("ListBoxX"); -ListBox::ListBox() { +ListBox::ListBox() noexcept { } ListBox::~ListBox() { @@ -2053,11 +1969,10 @@ class ListBoxX : public ListBox { unsigned int aveCharWidth; Window *parent; int ctrlID; - CallBackAction doubleClickAction; - void *doubleClickActionData; + IListBoxDelegate *delegate; const char *widestItem; unsigned int maxCharWidth; - int resizeHit; + WPARAM resizeHit; PRectangle rcPreSize; Point dragOffset; Point location; // Caret location at which the list is opened @@ -2074,6 +1989,7 @@ class ListBoxX : public ListBox { POINT MaxTrackSize() const; void SetRedraw(bool on); void OnDoubleClick(); + void OnSelChange(); void ResizeToCursor(); void StartResize(WPARAM); LRESULT NcHitTest(WPARAM, LPARAM) const; @@ -2086,39 +2002,37 @@ class ListBoxX : public ListBox { static const Point ImageInset; // Padding around image public: - ListBoxX() : lineHeight(10), fontCopy(0), technology(0), lb(0), unicodeMode(false), - desiredVisibleRows(5), maxItemCharacters(0), aveCharWidth(8), - parent(NULL), ctrlID(0), doubleClickAction(NULL), doubleClickActionData(NULL), - widestItem(NULL), maxCharWidth(1), resizeHit(0), wheelDelta(0) { + ListBoxX() : lineHeight(10), fontCopy{}, technology(0), lb{}, unicodeMode(false), + desiredVisibleRows(9), maxItemCharacters(0), aveCharWidth(8), + parent(nullptr), ctrlID(0), + delegate(nullptr), + widestItem(nullptr), maxCharWidth(1), resizeHit(0), wheelDelta(0) { } - virtual ~ListBoxX() { + ~ListBoxX() override { if (fontCopy) { ::DeleteObject(fontCopy); fontCopy = 0; } } - virtual void SetFont(Font &font); - virtual void Create(Window &parent_, int ctrlID_, Point location_, int lineHeight_, bool unicodeMode_, int technology_); - virtual void SetAverageCharWidth(int width); - virtual void SetVisibleRows(int rows); - virtual int GetVisibleRows() const; - virtual PRectangle GetDesiredRect(); - virtual int CaretFromEdge(); - virtual void Clear(); - virtual void Append(char *s, int type = -1); - virtual int Length(); - virtual void Select(int n); - virtual int GetSelection(); - virtual int Find(const char *prefix); - virtual void GetValue(int n, char *value, int len); - virtual void RegisterImage(int type, const char *xpm_data); - virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage); - virtual void ClearRegisteredImages(); - virtual void SetDoubleClickAction(CallBackAction action, void *data) { - doubleClickAction = action; - doubleClickActionData = data; - } - virtual void SetList(const char *list, char separator, char typesep); + void SetFont(Font &font) override; + void Create(Window &parent_, int ctrlID_, Point location_, int lineHeight_, bool unicodeMode_, int technology_) override; + void SetAverageCharWidth(int width) override; + void SetVisibleRows(int rows) override; + int GetVisibleRows() const override; + PRectangle GetDesiredRect() override; + int CaretFromEdge() override; + void Clear() override; + void Append(char *s, int type = -1) override; + int Length() override; + void Select(int n) override; + int GetSelection() override; + int Find(const char *prefix) override; + void GetValue(int n, char *value, int len) override; + void RegisterImage(int type, const char *xpm_data) override; + void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) override; + void ClearRegisteredImages() override; + void SetDelegate(IListBoxDelegate *lbDelegate) override; + void SetList(const char *list, char separator, char typesep) override; void Draw(DRAWITEMSTRUCT *pDrawItem); LRESULT WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam); static LRESULT PASCAL StaticWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam); @@ -2140,7 +2054,7 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei lineHeight = lineHeight_; unicodeMode = unicodeMode_; technology = technology_; - HWND hwndParent = reinterpret_cast(parent->GetID()); + HWND hwndParent = HwndFromWindowID(parent->GetID()); HINSTANCE hinstanceParent = GetWindowInstance(hwndParent); // Window created as popup so not clipped within parent client area wid = ::CreateWindowEx( @@ -2162,7 +2076,7 @@ void ListBoxX::SetFont(Font &font) { ::DeleteObject(fontCopy); fontCopy = 0; } - FormatAndMetrics *pfm = reinterpret_cast(font.GetID()); + FormatAndMetrics *pfm = static_cast(font.GetID()); fontCopy = pfm->HFont(); ::SendMessage(lb, WM_SETFONT, reinterpret_cast(fontCopy), 0); } @@ -2181,7 +2095,7 @@ int ListBoxX::GetVisibleRows() const { } HWND ListBoxX::GetHWND() const { - return reinterpret_cast(GetID()); + return HwndFromWindowID(GetID()); } PRectangle ListBoxX::GetDesiredRect() { @@ -2212,7 +2126,7 @@ PRectangle ListBoxX::GetDesiredRect() { SelectFont(hdc, oldFont); ::ReleaseDC(lb, hdc); - int widthDesired = Platform::Maximum(textSize.cx, (len + 1) * tm.tmAveCharWidth); + const int widthDesired = std::max(textSize.cx, (len + 1) * tm.tmAveCharWidth); if (width < widthDesired) width = widthDesired; @@ -2225,7 +2139,7 @@ PRectangle ListBoxX::GetDesiredRect() { } int ListBoxX::TextOffset() const { - int pixWidth = images.GetWidth(); + const int pixWidth = images.GetWidth(); return static_cast(pixWidth == 0 ? ItemInset.x : ItemInset.x + pixWidth + (ImageInset.x * 2)); } @@ -2238,7 +2152,7 @@ int ListBoxX::CaretFromEdge() { void ListBoxX::Clear() { ::SendMessage(lb, LB_RESETCONTENT, 0, 0); maxItemCharacters = 0; - widestItem = NULL; + widestItem = nullptr; lti.Clear(); } @@ -2258,6 +2172,7 @@ void ListBoxX::Select(int n) { SetRedraw(false); CentreItem(n); ::SendMessage(lb, LB_SETCURSEL, n, 0); + OnSelChange(); SetRedraw(true); } @@ -2271,7 +2186,7 @@ int ListBoxX::Find(const char *) { } void ListBoxX::GetValue(int n, char *value, int len) { - ListItemData item = lti.Get(n); + const ListItemData item = lti.Get(n); strncpy(value, item.text, len); value[len-1] = '\0'; } @@ -2307,10 +2222,10 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { ::SetTextColor(pDrawItem->hDC, ::GetSysColor(COLOR_WINDOWTEXT)); } - ListItemData item = lti.Get(pDrawItem->itemID); - int pixId = item.pixId; + const ListItemData item = lti.Get(pDrawItem->itemID); + const int pixId = item.pixId; const char *text = item.text; - int len = static_cast(strlen(text)); + const int len = static_cast(strlen(text)); RECT rcText = rcBox; ::InsetRect(&rcText, static_cast(TextInset.x), static_cast(TextInset.y)); @@ -2321,61 +2236,50 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { } else { ::DrawTextA(pDrawItem->hDC, text, len, &rcText, DT_NOPREFIX|DT_END_ELLIPSIS|DT_SINGLELINE|DT_NOCLIP); } - if (pDrawItem->itemState & ODS_SELECTED) { - ::DrawFocusRect(pDrawItem->hDC, &rcBox); - } // Draw the image, if any - RGBAImage *pimage = images.Get(pixId); + const RGBAImage *pimage = images.Get(pixId); if (pimage) { - Surface *surfaceItem = Surface::Allocate(technology); - if (surfaceItem) { - if (technology == SCWIN_TECH_GDI) { - surfaceItem->Init(pDrawItem->hDC, pDrawItem->hwndItem); - long left = pDrawItem->rcItem.left + static_cast(ItemInset.x + ImageInset.x); - PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, - left + images.GetWidth(), pDrawItem->rcItem.bottom); - surfaceItem->DrawRGBAImage(rcImage, - pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels()); - delete surfaceItem; - ::SetTextAlign(pDrawItem->hDC, TA_TOP); - } else { + std::unique_ptr surfaceItem(Surface::Allocate(technology)); + if (technology == SCWIN_TECH_GDI) { + surfaceItem->Init(pDrawItem->hDC, pDrawItem->hwndItem); + const long left = pDrawItem->rcItem.left + static_cast(ItemInset.x + ImageInset.x); + const PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, + left + images.GetWidth(), pDrawItem->rcItem.bottom); + surfaceItem->DrawRGBAImage(rcImage, + pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels()); + ::SetTextAlign(pDrawItem->hDC, TA_TOP); + } else { #if defined(USE_D2D) - D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties( - D2D1_RENDER_TARGET_TYPE_DEFAULT, - D2D1::PixelFormat( - DXGI_FORMAT_B8G8R8A8_UNORM, - D2D1_ALPHA_MODE_IGNORE), - 0, - 0, - D2D1_RENDER_TARGET_USAGE_NONE, - D2D1_FEATURE_LEVEL_DEFAULT - ); - ID2D1DCRenderTarget *pDCRT = 0; - HRESULT hr = pD2DFactory->CreateDCRenderTarget(&props, &pDCRT); + const D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties( + D2D1_RENDER_TARGET_TYPE_DEFAULT, + D2D1::PixelFormat( + DXGI_FORMAT_B8G8R8A8_UNORM, + D2D1_ALPHA_MODE_IGNORE), + 0, + 0, + D2D1_RENDER_TARGET_USAGE_NONE, + D2D1_FEATURE_LEVEL_DEFAULT + ); + ID2D1DCRenderTarget *pDCRT = nullptr; + HRESULT hr = pD2DFactory->CreateDCRenderTarget(&props, &pDCRT); + if (SUCCEEDED(hr)) { + RECT rcWindow; + GetClientRect(pDrawItem->hwndItem, &rcWindow); + hr = pDCRT->BindDC(pDrawItem->hDC, &rcWindow); if (SUCCEEDED(hr)) { - RECT rcWindow; - GetClientRect(pDrawItem->hwndItem, &rcWindow); - hr = pDCRT->BindDC(pDrawItem->hDC, &rcWindow); - if (SUCCEEDED(hr)) { - surfaceItem->Init(pDCRT, pDrawItem->hwndItem); - pDCRT->BeginDraw(); - long left = pDrawItem->rcItem.left + static_cast(ItemInset.x + ImageInset.x); - PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, - left + images.GetWidth(), pDrawItem->rcItem.bottom); - surfaceItem->DrawRGBAImage(rcImage, - pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels()); - delete surfaceItem; - pDCRT->EndDraw(); - pDCRT->Release(); - } else { - delete surfaceItem; - } - } else { - delete surfaceItem; + surfaceItem->Init(pDCRT, pDrawItem->hwndItem); + pDCRT->BeginDraw(); + const long left = pDrawItem->rcItem.left + static_cast(ItemInset.x + ImageInset.x); + const PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, + left + images.GetWidth(), pDrawItem->rcItem.bottom); + surfaceItem->DrawRGBAImage(rcImage, + pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels()); + pDCRT->EndDraw(); + pDCRT->Release(); } -#endif } +#endif } } } @@ -2392,22 +2296,26 @@ void ListBoxX::AppendListItem(const char *text, const char *numword) { } lti.AllocItem(text, pixId); - unsigned int len = static_cast(strlen(text)); + const unsigned int len = static_cast(strlen(text)); if (maxItemCharacters < len) { maxItemCharacters = len; widestItem = text; } } +void ListBoxX::SetDelegate(IListBoxDelegate *lbDelegate) { + delegate = lbDelegate; +} + void ListBoxX::SetList(const char *list, char separator, char typesep) { // Turn off redraw while populating the list - this has a significant effect, even if // the listbox is not visible. SetRedraw(false); Clear(); - size_t size = strlen(list); + const size_t size = strlen(list); char *words = lti.SetWords(list); char *startword = words; - char *numword = NULL; + char *numword = nullptr; for (size_t i=0; i < size; i++) { if (words[i] == separator) { words[i] = '\0'; @@ -2415,7 +2323,7 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) { *numword = '\0'; AppendListItem(startword, numword); startword = words + i + 1; - numword = NULL; + numword = nullptr; } else if (words[i] == typesep) { numword = words + i; } @@ -2427,7 +2335,7 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) { } // Finally populate the listbox itself with the correct number of items - int count = lti.Count(); + const int count = lti.Count(); ::SendMessage(lb, LB_INITSTORAGE, count, 0); for (int j=0; j(TextInset.y) * 2); - int pixHeight = images.GetHeight() + (static_cast(ImageInset.y) * 2); + const int pixHeight = images.GetHeight() + (static_cast(ImageInset.y) * 2); if (itemHeight < pixHeight) { itemHeight = pixHeight; } @@ -2463,7 +2371,7 @@ POINT ListBoxX::MinTrackSize() const { POINT ListBoxX::MaxTrackSize() const { PRectangle rc = PRectangle::FromInts(0, 0, - Platform::Maximum(MinClientWidth(), + std::max(static_cast(MinClientWidth()), maxCharWidth * maxItemCharacters + static_cast(TextInset.x) * 2 + TextOffset() + ::GetSystemMetrics(SM_CXVSCROLL)), ItemHeight() * lti.Count()); @@ -2473,32 +2381,16 @@ POINT ListBoxX::MaxTrackSize() const { } void ListBoxX::SetRedraw(bool on) { - ::SendMessage(lb, WM_SETREDRAW, static_cast(on), 0); + ::SendMessage(lb, WM_SETREDRAW, on, 0); if (on) - ::InvalidateRect(lb, NULL, TRUE); -} - -static XYPOSITION XYMinimum(XYPOSITION a, XYPOSITION b) { - if (a < b) - return a; - else - return b; -} - -static XYPOSITION XYMaximum(XYPOSITION a, XYPOSITION b) { - if (a > b) - return a; - else - return b; + ::InvalidateRect(lb, nullptr, TRUE); } void ListBoxX::ResizeToCursor() { PRectangle rc = GetPosition(); POINT ptw; ::GetCursorPos(&ptw); - Point pt = Point::FromInts(ptw.x, ptw.y); - pt.x += dragOffset.x; - pt.y += dragOffset.y; + const Point pt = Point::FromInts(ptw.x, ptw.y) + dragOffset; switch (resizeHit) { case HTLEFT: @@ -2531,13 +2423,13 @@ void ListBoxX::ResizeToCursor() { break; } - POINT ptMin = MinTrackSize(); - POINT ptMax = MaxTrackSize(); + const POINT ptMin = MinTrackSize(); + const POINT ptMax = MaxTrackSize(); // We don't allow the left edge to move at present, but just in case - rc.left = XYMaximum(XYMinimum(rc.left, rcPreSize.right - ptMin.x), rcPreSize.right - ptMax.x); - rc.top = XYMaximum(XYMinimum(rc.top, rcPreSize.bottom - ptMin.y), rcPreSize.bottom - ptMax.y); - rc.right = XYMaximum(XYMinimum(rc.right, rcPreSize.left + ptMax.x), rcPreSize.left + ptMin.x); - rc.bottom = XYMaximum(XYMinimum(rc.bottom, rcPreSize.top + ptMax.y), rcPreSize.top + ptMin.y); + rc.left = Sci::clamp(rc.left, rcPreSize.right - ptMax.x, rcPreSize.right - ptMin.x); + rc.top = Sci::clamp(rc.top, rcPreSize.bottom - ptMax.y, rcPreSize.bottom - ptMin.y); + rc.right = Sci::clamp(rc.right, rcPreSize.left + ptMin.x, rcPreSize.left + ptMax.x); + rc.bottom = Sci::clamp(rc.bottom, rcPreSize.top + ptMin.y, rcPreSize.top + ptMax.y); SetPosition(rc); } @@ -2578,19 +2470,20 @@ void ListBoxX::StartResize(WPARAM hitCode) { } ::SetCapture(GetHWND()); - resizeHit = static_cast(hitCode); + resizeHit = hitCode; } LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const { + const PRectangle rc = GetPosition(); + LRESULT hit = ::DefWindowProc(GetHWND(), WM_NCHITTEST, wParam, lParam); // There is an apparent bug in the DefWindowProc hit test code whereby it will // return HTTOPXXX if the window in question is shorter than the default // window caption height + frame, even if one is hovering over the bottom edge of // the frame, so workaround that here if (hit >= HTTOP && hit <= HTTOPRIGHT) { - int minHeight = GetSystemMetrics(SM_CYMINTRACK); - PRectangle rc = const_cast(this)->GetPosition(); - int yPos = GET_Y_LPARAM(lParam); + const int minHeight = GetSystemMetrics(SM_CYMINTRACK); + const int yPos = GET_Y_LPARAM(lParam); if ((rc.Height() < minHeight) && (yPos > ((rc.top + rc.bottom)/2))) { hit += HTBOTTOM - HTTOP; } @@ -2607,7 +2500,6 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const { case HTTOP: case HTTOPRIGHT: { - PRectangle rc = const_cast(this)->GetPosition(); // Valid only if caret below list if (location.y < rc.top) hit = HTERROR; @@ -2616,9 +2508,8 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const { case HTBOTTOM: case HTBOTTOMRIGHT: { - PRectangle rc = const_cast(this)->GetPosition(); // Valid only if caret above list - if (rc.bottom < location.y) + if (rc.bottom <= location.y) hit = HTERROR; } break; @@ -2628,28 +2519,34 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const { } void ListBoxX::OnDoubleClick() { + if (delegate) { + ListBoxEvent event(ListBoxEvent::EventType::doubleClick); + delegate->ListNotify(&event); + } +} - if (doubleClickAction != NULL) { - doubleClickAction(doubleClickActionData); +void ListBoxX::OnSelChange() { + if (delegate) { + ListBoxEvent event(ListBoxEvent::EventType::selectionChange); + delegate->ListNotify(&event); } } POINT ListBoxX::GetClientExtent() const { - PRectangle rc = const_cast(this)->GetClientPosition(); - POINT ret; - ret.x = static_cast(rc.Width()); - ret.y = static_cast(rc.Height()); + RECT rc; + ::GetWindowRect(HwndFromWindowID(wid), &rc); + POINT ret { rc.right - rc.left, rc.bottom - rc.top }; return ret; } void ListBoxX::CentreItem(int n) { // If below mid point, scroll up to centre, but with more items below if uneven if (n >= 0) { - POINT extent = GetClientExtent(); - int visible = extent.y/ItemHeight(); + const POINT extent = GetClientExtent(); + const int visible = extent.y/ItemHeight(); if (visible < Length()) { - LRESULT top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0); - int half = (visible - 1) / 2; + const LRESULT top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0); + const int half = (visible - 1) / 2; if (n > (top + half)) ::SendMessage(lb, LB_SETTOPINDEX, n - half , 0); } @@ -2658,37 +2555,38 @@ void ListBoxX::CentreItem(int n) { // Performs a double-buffered paint operation to avoid flicker void ListBoxX::Paint(HDC hDC) { - POINT extent = GetClientExtent(); + const POINT extent = GetClientExtent(); HBITMAP hBitmap = ::CreateCompatibleBitmap(hDC, extent.x, extent.y); HDC bitmapDC = ::CreateCompatibleDC(hDC); HBITMAP hBitmapOld = SelectBitmap(bitmapDC, hBitmap); // The list background is mainly erased during painting, but can be a small // unpainted area when at the end of a non-integrally sized list with a // vertical scroll bar - RECT rc = { 0, 0, extent.x, extent.y }; + const RECT rc = { 0, 0, extent.x, extent.y }; ::FillRect(bitmapDC, &rc, reinterpret_cast(COLOR_WINDOW+1)); // Paint the entire client area and vertical scrollbar ::SendMessage(lb, WM_PRINT, reinterpret_cast(bitmapDC), PRF_CLIENT|PRF_NONCLIENT); ::BitBlt(hDC, 0, 0, extent.x, extent.y, bitmapDC, 0, 0, SRCCOPY); // Select a stock brush to prevent warnings from BoundsChecker - ::SelectObject(bitmapDC, GetStockFont(WHITE_BRUSH)); + SelectBrush(bitmapDC, GetStockBrush(WHITE_BRUSH)); SelectBitmap(bitmapDC, hBitmapOld); ::DeleteDC(bitmapDC); ::DeleteObject(hBitmap); } -LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { +LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { try { - switch (uMsg) { + ListBoxX *lbx = static_cast(PointerFromWindow(::GetParent(hWnd))); + switch (iMessage) { case WM_ERASEBKGND: return TRUE; case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = ::BeginPaint(hWnd, &ps); - ListBoxX *lbx = reinterpret_cast(PointerFromWindow(::GetParent(hWnd))); - if (lbx) + if (lbx) { lbx->Paint(hDC); + } ::EndPaint(hWnd, &ps); } return 0; @@ -2700,10 +2598,13 @@ LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA case WM_LBUTTONDOWN: { // We must take control of selection to prevent the ListBox activating // the popup - LRESULT lResult = ::SendMessage(hWnd, LB_ITEMFROMPOINT, 0, lParam); - int item = LOWORD(lResult); + const LRESULT lResult = ::SendMessage(hWnd, LB_ITEMFROMPOINT, 0, lParam); + const int item = LOWORD(lResult); if (HIWORD(lResult) == 0 && item >= 0) { ::SendMessage(hWnd, LB_SETCURSEL, item, 0); + if (lbx) { + lbx->OnSelChange(); + } } } return 0; @@ -2712,7 +2613,6 @@ LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA return 0; case WM_LBUTTONDBLCLK: { - ListBoxX *lbx = reinterpret_cast(PointerFromWindow(::GetParent(hWnd))); if (lbx) { lbx->OnDoubleClick(); } @@ -2726,19 +2626,19 @@ LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA WNDPROC prevWndProc = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); if (prevWndProc) { - return ::CallWindowProc(prevWndProc, hWnd, uMsg, wParam, lParam); + return ::CallWindowProc(prevWndProc, hWnd, iMessage, wParam, lParam); } else { - return ::DefWindowProc(hWnd, uMsg, wParam, lParam); + return ::DefWindowProc(hWnd, iMessage, wParam, lParam); } } catch (...) { } - return ::DefWindowProc(hWnd, uMsg, wParam, lParam); + return ::DefWindowProc(hWnd, iMessage, wParam, lParam); } LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { switch (iMessage) { case WM_CREATE: { - HINSTANCE hinstanceParent = GetWindowInstance(reinterpret_cast(parent->GetID())); + HINSTANCE hinstanceParent = GetWindowInstance(HwndFromWindowID(parent->GetID())); // Note that LBS_NOINTEGRALHEIGHT is specified to fix cosmetic issue when resizing the list // but has useful side effect of speeding up list population significantly lb = ::CreateWindowEx( @@ -2749,7 +2649,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam reinterpret_cast(static_cast(ctrlID)), hinstanceParent, 0); - WNDPROC prevWndProc = reinterpret_cast(::SetWindowLongPtr(lb, GWLP_WNDPROC, reinterpret_cast(ControlWndProc))); + WNDPROC prevWndProc = SubclassWindow(lb, ControlWndProc); ::SetWindowLongPtr(lb, GWLP_USERDATA, reinterpret_cast(prevWndProc)); } break; @@ -2774,12 +2674,12 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam case WM_COMMAND: // This is not actually needed now - the registered double click action is used // directly to action a choice from the list. - ::SendMessage(reinterpret_cast(parent->GetID()), iMessage, wParam, lParam); + ::SendMessage(HwndFromWindowID(parent->GetID()), iMessage, wParam, lParam); break; case WM_MEASUREITEM: { MEASUREITEMSTRUCT *pMeasureItem = reinterpret_cast(lParam); - pMeasureItem->itemHeight = static_cast(ItemHeight()); + pMeasureItem->itemHeight = ItemHeight(); } break; @@ -2832,11 +2732,10 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam ::ReleaseCapture(); } return ::DefWindowProc(hWnd, iMessage, wParam, lParam); - case WM_MOUSEWHEEL: - wheelDelta -= static_cast(HIWORD(wParam)); - if (abs(wheelDelta) >= WHEEL_DELTA) { - int nRows = GetVisibleRows(); + wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam); + if (std::abs(wheelDelta) >= WHEEL_DELTA) { + const int nRows = GetVisibleRows(); int linesToScroll = 1; if (nRows > 1) { linesToScroll = nRows - 1; @@ -2872,7 +2771,7 @@ LRESULT PASCAL ListBoxX::StaticWndProc( SetWindowPointer(hWnd, pCreate->lpCreateParams); } // Find C++ object associated with window. - ListBoxX *lbx = reinterpret_cast(PointerFromWindow(hWnd)); + ListBoxX *lbx = static_cast(PointerFromWindow(hWnd)); if (lbx) { return lbx->WndProc(hWnd, iMessage, wParam, lParam); } else { @@ -2880,32 +2779,31 @@ LRESULT PASCAL ListBoxX::StaticWndProc( } } -static bool ListBoxX_Register() { - WNDCLASSEX wndclassc; +namespace { + +bool ListBoxX_Register() noexcept { + WNDCLASSEX wndclassc {}; wndclassc.cbSize = sizeof(wndclassc); // We need CS_HREDRAW and CS_VREDRAW because of the ellipsis that might be drawn for // truncated items in the list and the appearance/disappearance of the vertical scroll bar. // The list repaint is double-buffered to avoid the flicker this would otherwise cause. wndclassc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW; - wndclassc.cbClsExtra = 0; wndclassc.cbWndExtra = sizeof(ListBoxX *); wndclassc.hInstance = hinstPlatformRes; - wndclassc.hIcon = NULL; - wndclassc.hbrBackground = NULL; - wndclassc.lpszMenuName = NULL; wndclassc.lpfnWndProc = ListBoxX::StaticWndProc; wndclassc.hCursor = ::LoadCursor(NULL, IDC_ARROW); wndclassc.lpszClassName = ListBoxX_ClassName; - wndclassc.hIconSm = 0; return ::RegisterClassEx(&wndclassc) != 0; } -bool ListBoxX_Unregister() { +bool ListBoxX_Unregister() noexcept { return ::UnregisterClass(ListBoxX_ClassName, hinstPlatformRes) != 0; } -Menu::Menu() : mid(0) { +} + +Menu::Menu() noexcept : mid{} { } void Menu::CreatePopUp() { @@ -2915,81 +2813,33 @@ void Menu::CreatePopUp() { void Menu::Destroy() { if (mid) - ::DestroyMenu(reinterpret_cast(mid)); + ::DestroyMenu(static_cast(mid)); mid = 0; } void Menu::Show(Point pt, Window &w) { - ::TrackPopupMenu(reinterpret_cast(mid), + ::TrackPopupMenu(static_cast(mid), TPM_RIGHTBUTTON, static_cast(pt.x - 4), static_cast(pt.y), 0, - reinterpret_cast(w.GetID()), NULL); + HwndFromWindowID(w.GetID()), nullptr); Destroy(); } -static bool initialisedET = false; -static bool usePerformanceCounter = false; -static LARGE_INTEGER frequency; - -ElapsedTime::ElapsedTime() { - if (!initialisedET) { - usePerformanceCounter = ::QueryPerformanceFrequency(&frequency) != 0; - initialisedET = true; - } - if (usePerformanceCounter) { - LARGE_INTEGER timeVal; - ::QueryPerformanceCounter(&timeVal); - bigBit = timeVal.HighPart; - littleBit = timeVal.LowPart; - } else { - bigBit = clock(); - littleBit = 0; - } -} - -double ElapsedTime::Duration(bool reset) { - double result; - long endBigBit; - long endLittleBit; - - if (usePerformanceCounter) { - LARGE_INTEGER lEnd; - ::QueryPerformanceCounter(&lEnd); - endBigBit = lEnd.HighPart; - endLittleBit = lEnd.LowPart; - LARGE_INTEGER lBegin; - lBegin.HighPart = bigBit; - lBegin.LowPart = littleBit; - double elapsed = static_cast(lEnd.QuadPart - lBegin.QuadPart); - result = elapsed / static_cast(frequency.QuadPart); - } else { - endBigBit = clock(); - endLittleBit = 0; - double elapsed = endBigBit - bigBit; - result = elapsed / CLOCKS_PER_SEC; - } - if (reset) { - bigBit = endBigBit; - littleBit = endLittleBit; - } - return result; -} - class DynamicLibraryImpl : public DynamicLibrary { protected: HMODULE h; public: - explicit DynamicLibraryImpl(const char *modulePath) { + explicit DynamicLibraryImpl(const char *modulePath) noexcept { h = ::LoadLibraryA(modulePath); } - virtual ~DynamicLibraryImpl() { - if (h != NULL) + ~DynamicLibraryImpl() override { + if (h) ::FreeLibrary(h); } // Use GetProcAddress to get a pointer to the relevant function. - virtual Function FindFunction(const char *name) { - if (h != NULL) { + Function FindFunction(const char *name) noexcept override { + if (h) { // C++ standard doesn't like casts between function pointers and void pointers so use a union union { FARPROC fp; @@ -2998,11 +2848,11 @@ public: fnConv.fp = ::GetProcAddress(h, name); return fnConv.f; } else { - return NULL; + return nullptr; } } - virtual bool IsValid() { + bool IsValid() noexcept override { return h != NULL; } }; @@ -3012,11 +2862,11 @@ DynamicLibrary *DynamicLibrary::Load(const char *modulePath) { } ColourDesired Platform::Chrome() { - return ::GetSysColor(COLOR_3DFACE); + return ColourDesired(::GetSysColor(COLOR_3DFACE)); } ColourDesired Platform::ChromeHighlight() { - return ::GetSysColor(COLOR_3DHIGHLIGHT); + return ColourDesired(::GetSysColor(COLOR_3DHIGHLIGHT)); } const char *Platform::DefaultFont() { @@ -3031,85 +2881,10 @@ unsigned int Platform::DoubleClickTime() { return ::GetDoubleClickTime(); } -bool Platform::MouseButtonBounce() { - return false; -} - void Platform::DebugDisplay(const char *s) { ::OutputDebugStringA(s); } -bool Platform::IsKeyDown(int key) { - return (::GetKeyState(key) & 0x80000000) != 0; -} - -long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) { - // This should never be called - its here to satisfy an old interface - return static_cast(::SendMessage(reinterpret_cast(w), msg, wParam, lParam)); -} - -long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) { - // This should never be called - its here to satisfy an old interface - return static_cast(::SendMessage(reinterpret_cast(w), msg, wParam, - reinterpret_cast(lParam))); -} - -bool Platform::IsDBCSLeadByte(int codePage, char ch) { - // Byte ranges found in Wikipedia articles with relevant search strings in each case - unsigned char uch = static_cast(ch); - switch (codePage) { - case 932: - // Shift_jis - return ((uch >= 0x81) && (uch <= 0x9F)) || - ((uch >= 0xE0) && (uch <= 0xEF)); - case 936: - // GBK - return (uch >= 0x81) && (uch <= 0xFE); - case 949: - // Korean Wansung KS C-5601-1987 - return (uch >= 0x81) && (uch <= 0xFE); - case 950: - // Big5 - return (uch >= 0x81) && (uch <= 0xFE); - case 1361: - // Korean Johab KS C-5601-1992 - return - ((uch >= 0x84) && (uch <= 0xD3)) || - ((uch >= 0xD8) && (uch <= 0xDE)) || - ((uch >= 0xE0) && (uch <= 0xF9)); - } - return false; -} - -int Platform::DBCSCharLength(int codePage, const char *s) { - if (codePage == 932 || codePage == 936 || codePage == 949 || - codePage == 950 || codePage == 1361) { - return Platform::IsDBCSLeadByte(codePage, s[0]) ? 2 : 1; - } else { - return 1; - } -} - -int Platform::DBCSCharMaxLength() { - return 2; -} - -// These are utility functions not really tied to a platform - -int Platform::Minimum(int a, int b) { - if (a < b) - return a; - else - return b; -} - -int Platform::Maximum(int a, int b) { - if (a > b) - return a; - else - return b; -} - //#define TRACE #ifdef TRACE @@ -3129,7 +2904,7 @@ void Platform::DebugPrintf(const char *, ...) { static bool assertionPopUps = true; bool Platform::ShowAssertionPopUps(bool assertionPopUps_) { - bool ret = assertionPopUps; + const bool ret = assertionPopUps; assertionPopUps = assertionPopUps_; return ret; } @@ -3138,7 +2913,7 @@ void Platform::Assert(const char *c, const char *file, int line) { char buffer[2000]; sprintf(buffer, "Assertion [%s] failed at %s %d%s", c, file, line, assertionPopUps ? "" : "\r\n"); if (assertionPopUps) { - int idButton = ::MessageBoxA(0, buffer, "Assertion failure", + const int idButton = ::MessageBoxA(0, buffer, "Assertion failure", MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); if (idButton == IDRETRY) { ::DebugBreak(); @@ -3154,65 +2929,30 @@ void Platform::Assert(const char *c, const char *file, int line) { } } -int Platform::Clamp(int val, int minVal, int maxVal) { - if (val > maxVal) - val = maxVal; - if (val < minVal) - val = minVal; - return val; -} - -#ifdef _MSC_VER -// GetVersionEx has been deprecated fro Windows 8.1 but called here to determine if Windows 9x. -// Too dangerous to find alternate check. -#pragma warning(disable: 4996) -#endif - void Platform_Initialise(void *hInstance) { ::InitializeCriticalSection(&crPlatformLock); - hinstPlatformRes = reinterpret_cast(hInstance); - // This may be called from DllMain, in which case the call to LoadLibrary - // is bad because it can upset the DLL load order. - if (!hDLLImage) { - hDLLImage = ::LoadLibrary(TEXT("Msimg32")); - } - if (hDLLImage) { - AlphaBlendFn = (AlphaBlendSig)::GetProcAddress(hDLLImage, "AlphaBlend"); - } - if (!hDLLUser32) { - hDLLUser32 = ::LoadLibrary(TEXT("User32")); - } - if (hDLLUser32) { - MonitorFromPointFn = (MonitorFromPointSig)::GetProcAddress(hDLLUser32, "MonitorFromPoint"); - MonitorFromRectFn = (MonitorFromRectSig)::GetProcAddress(hDLLUser32, "MonitorFromRect"); - GetMonitorInfoFn = (GetMonitorInfoSig)::GetProcAddress(hDLLUser32, "GetMonitorInfoA"); - } - + hinstPlatformRes = static_cast(hInstance); ListBoxX_Register(); } -#ifdef _MSC_VER -#pragma warning(default: 4996) -#endif - void Platform_Finalise(bool fromDllMain) { #if defined(USE_D2D) if (!fromDllMain) { if (defaultRenderingParams) { defaultRenderingParams->Release(); - defaultRenderingParams = 0; + defaultRenderingParams = nullptr; } if (customClearTypeRenderingParams) { customClearTypeRenderingParams->Release(); - customClearTypeRenderingParams = 0; + customClearTypeRenderingParams = nullptr; } if (pIDWriteFactory) { pIDWriteFactory->Release(); - pIDWriteFactory = 0; + pIDWriteFactory = nullptr; } if (pD2DFactory) { pD2DFactory->Release(); - pD2DFactory = 0; + pD2DFactory = nullptr; } if (hDLLDWrite) { FreeLibrary(hDLLDWrite); @@ -3224,20 +2964,10 @@ void Platform_Finalise(bool fromDllMain) { } } #endif - if (reverseArrowCursor != NULL) + if (reverseArrowCursor) ::DestroyCursor(reverseArrowCursor); ListBoxX_Unregister(); ::DeleteCriticalSection(&crPlatformLock); - if (hDLLUser32) { - FreeLibrary(hDLLUser32); - hDLLUser32 = NULL; - } - if (hDLLImage) { - FreeLibrary(hDLLImage); - hDLLImage = NULL; - } } -#ifdef SCI_NAMESPACE } -#endif diff --git a/dep/scintilla/scintilla-3.6.0/win32/PlatWin.h b/dep/scintilla/scintilla-3.10.6/win32/PlatWin.h similarity index 73% rename from dep/scintilla/scintilla-3.6.0/win32/PlatWin.h rename to dep/scintilla/scintilla-3.10.6/win32/PlatWin.h index e5913ba1..2a1bcb64 100644 --- a/dep/scintilla/scintilla-3.6.0/win32/PlatWin.h +++ b/dep/scintilla/scintilla-3.10.6/win32/PlatWin.h @@ -8,21 +8,23 @@ #ifndef PLATWIN_H #define PLATWIN_H -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif extern void Platform_Initialise(void *hInstance); extern void Platform_Finalise(bool fromDllMain); +RECT RectFromPRectangle(PRectangle prc) noexcept { + RECT rc = { static_cast(prc.left), static_cast(prc.top), + static_cast(prc.right), static_cast(prc.bottom) }; + return rc; +} + #if defined(USE_D2D) extern bool LoadD2D(); extern ID2D1Factory *pD2DFactory; extern IDWriteFactory *pIDWriteFactory; #endif -#ifdef SCI_NAMESPACE } -#endif #endif diff --git a/dep/scintilla/scintilla-3.6.0/win32/SciLexer.vcxproj b/dep/scintilla/scintilla-3.10.6/win32/SciLexer.vcxproj similarity index 90% rename from dep/scintilla/scintilla-3.6.0/win32/SciLexer.vcxproj rename to dep/scintilla/scintilla-3.10.6/win32/SciLexer.vcxproj index a151c02d..4836b8d0 100644 --- a/dep/scintilla/scintilla-3.6.0/win32/SciLexer.vcxproj +++ b/dep/scintilla/scintilla-3.10.6/win32/SciLexer.vcxproj @@ -1,130 +1,131 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {FBE04237-9C7B-4973-9C60-505975998B39} - Win32Proj - SciLexer - - - - DynamicLibrary - Unicode - v120 - - - true - - - true - - - false - true - - - false - true - - - - - - - - - - false - - - - Level4 - WIN32;SCI_LEXER;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - ..\include;..\src;..\lexlib; - true - true - false - ProgramDatabase - - - Windows - true - imm32.lib;%(AdditionalDependencies) - - - - - _DEBUG;%(PreprocessorDefinitions) - - - Default - - - - - _DEBUG;%(PreprocessorDefinitions) - - - Default - - - - - true - true - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - true - true - NDEBUG;%(PreprocessorDefinitions) - - - true - true - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {FBE04237-9C7B-4973-9C60-505975998B39} + Win32Proj + SciLexer + + + + DynamicLibrary + Unicode + v140 + + + true + + + true + + + false + true + + + false + true + + + + + + + + + + false + + + + Level4 + WIN32;SCI_LEXER;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + ..\include;..\src;..\lexlib; + true + true + false + ProgramDatabase + + + Windows + true + imm32.lib;msimg32.lib;%(AdditionalDependencies) + + + + + _DEBUG;%(PreprocessorDefinitions) + + + Default + + + + + _DEBUG;%(PreprocessorDefinitions) + + + Default + + + + + true + true + NDEBUG;%(PreprocessorDefinitions) + + + true + true + + + + + true + true + NDEBUG;%(PreprocessorDefinitions) + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dep/scintilla/scintilla-3.6.0/win32/SciTE.properties b/dep/scintilla/scintilla-3.10.6/win32/SciTE.properties similarity index 100% rename from dep/scintilla/scintilla-3.6.0/win32/SciTE.properties rename to dep/scintilla/scintilla-3.10.6/win32/SciTE.properties diff --git a/dep/scintilla/scintilla-3.6.0/win32/ScintRes.rc b/dep/scintilla/scintilla-3.10.6/win32/ScintRes.rc similarity index 93% rename from dep/scintilla/scintilla-3.6.0/win32/ScintRes.rc rename to dep/scintilla/scintilla-3.10.6/win32/ScintRes.rc index 5f3f09cd..aee0f059 100644 --- a/dep/scintilla/scintilla-3.6.0/win32/ScintRes.rc +++ b/dep/scintilla/scintilla-3.10.6/win32/ScintRes.rc @@ -4,8 +4,8 @@ #include -#define VERSION_SCINTILLA "3.6.0" -#define VERSION_WORDS 3, 6, 0, 0 +#define VERSION_SCINTILLA "3.10.6" +#define VERSION_WORDS 3, 10, 6, 0 VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_WORDS diff --git a/dep/scintilla/scintilla-3.6.0/win32/Scintilla.def b/dep/scintilla/scintilla-3.10.6/win32/Scintilla.def similarity index 100% rename from dep/scintilla/scintilla-3.6.0/win32/Scintilla.def rename to dep/scintilla/scintilla-3.10.6/win32/Scintilla.def diff --git a/dep/scintilla/scintilla-3.10.6/win32/ScintillaDLL.cxx b/dep/scintilla/scintilla-3.10.6/win32/ScintillaDLL.cxx new file mode 100644 index 00000000..1ecf1c16 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/win32/ScintillaDLL.cxx @@ -0,0 +1,35 @@ +// Scintilla source code edit control +/** @file ScintillaDLL.cxx + ** DLL entry point for Scintilla. + **/ +// Copyright 1998-2018 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 +#undef WINVER +#define WINVER 0x0500 +#include + +#include "Scintilla.h" +#include "ScintillaWin.h" + +extern "C" +__declspec(dllexport) +sptr_t __stdcall Scintilla_DirectFunction( + ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam) { + return Scintilla::DirectFunction(sci, iMessage, wParam, lParam); +} + +extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved) { + //Platform::DebugPrintf("Scintilla::DllMain %d %d\n", hInstance, dwReason); + if (dwReason == DLL_PROCESS_ATTACH) { + if (!Scintilla_RegisterClasses(hInstance)) + return FALSE; + } else if (dwReason == DLL_PROCESS_DETACH) { + if (lpvReserved == NULL) { + Scintilla::ResourcesRelease(true); + } + } + return TRUE; +} diff --git a/dep/scintilla/scintilla-3.6.0/win32/ScintillaWin.cxx b/dep/scintilla/scintilla-3.10.6/win32/ScintillaWin.cxx similarity index 66% rename from dep/scintilla/scintilla-3.6.0/win32/ScintillaWin.cxx rename to dep/scintilla/scintilla-3.10.6/win32/ScintillaWin.cxx index db1e2b4d..265cb236 100644 --- a/dep/scintilla/scintilla-3.6.0/win32/ScintillaWin.cxx +++ b/dep/scintilla/scintilla-3.10.6/win32/ScintillaWin.cxx @@ -5,20 +5,22 @@ // Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#include -#include -#include -#include -#include -#include - +#include +#include +#include +#include +#include #include +#include + #include #include #include #include #include #include +#include +#include #undef _WIN32_WINNT #define _WIN32_WINNT 0x0500 @@ -31,7 +33,7 @@ #include #include -#if defined(NTDDI_WIN7) && !defined(DISABLE_D2D) +#if !defined(DISABLE_D2D) #define USE_D2D 1 #endif @@ -42,6 +44,7 @@ #include "Platform.h" +#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" @@ -49,10 +52,12 @@ #include "SciLexer.h" #endif #include "StringCopy.h" +#include "CharacterCategory.h" #ifdef SCI_LEXER #include "LexerModule.h" #endif #include "Position.h" +#include "UniqueString.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -61,7 +66,6 @@ #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -77,6 +81,7 @@ #include "MarginView.h" #include "EditView.h" #include "Editor.h" +#include "ElapsedPeriod.h" #include "AutoComplete.h" #include "ScintillaBase.h" @@ -87,6 +92,7 @@ #include "PlatWin.h" #include "HanjaDic.h" +#include "ScintillaWin.h" #ifndef SPI_GETWHEELSCROLLLINES #define SPI_GETWHEELSCROLLLINES 104 @@ -100,50 +106,81 @@ #define UNICODE_NOCHAR 0xFFFF #endif +#ifndef IS_HIGH_SURROGATE +#define IS_HIGH_SURROGATE(x) ((x) >= SURROGATE_LEAD_FIRST && (x) <= SURROGATE_LEAD_LAST) +#endif + +#ifndef IS_LOW_SURROGATE +#define IS_LOW_SURROGATE(x) ((x) >= SURROGATE_TRAIL_FIRST && (x) <= SURROGATE_TRAIL_LAST) +#endif + #ifndef MK_ALT #define MK_ALT 32 #endif -#define SC_WIN_IDLE 5001 +// Two idle messages SC_WIN_IDLE and SC_WORK_IDLE. + +// SC_WIN_IDLE is low priority so should occur after the next WM_PAINT +// It is for lengthy actions like wrapping and background styling +constexpr UINT SC_WIN_IDLE = 5001; +// SC_WORK_IDLE is high priority and should occur before the next WM_PAINT +// It is for shorter actions like restyling the text just inserted +// and delivering SCN_UPDATEUI +constexpr UINT SC_WORK_IDLE = 5002; #define SC_INDICATOR_INPUT INDIC_IME #define SC_INDICATOR_TARGET INDIC_IME+1 #define SC_INDICATOR_CONVERTED INDIC_IME+2 #define SC_INDICATOR_UNKNOWN INDIC_IME_MAX -typedef BOOL (WINAPI *TrackMouseEventSig)(LPTRACKMOUSEEVENT); +#ifndef SCS_CAP_SETRECONVERTSTRING +#define SCS_CAP_SETRECONVERTSTRING 0x00000004 +#define SCS_QUERYRECONVERTSTRING 0x00020000 +#define SCS_SETRECONVERTSTRING 0x00010000 +#endif + typedef UINT_PTR (WINAPI *SetCoalescableTimerSig)(HWND hwnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc, ULONG uToleranceDelay); // GCC has trouble with the standard COM ABI so do it the old C way with explicit vtables. +using namespace Scintilla; + +namespace { + const TCHAR callClassName[] = TEXT("CallTip"); -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -static void *PointerFromWindow(HWND hWnd) { +void *PointerFromWindow(HWND hWnd) noexcept { return reinterpret_cast(::GetWindowLongPtr(hWnd, 0)); } -static void SetWindowPointer(HWND hWnd, void *ptr) { +void SetWindowPointer(HWND hWnd, void *ptr) noexcept { ::SetWindowLongPtr(hWnd, 0, reinterpret_cast(ptr)); } -static void SetWindowID(HWND hWnd, int identifier) { +void SetWindowID(HWND hWnd, int identifier) noexcept { ::SetWindowLongPtr(hWnd, GWLP_ID, identifier); } -static Point PointFromPOINT(POINT pt) { +Point PointFromPOINT(POINT pt) noexcept { return Point::FromInts(pt.x, pt.y); } +Point PointFromLParam(sptr_t lpoint) noexcept { + return Point::FromInts(GET_X_LPARAM(lpoint), GET_Y_LPARAM(lpoint)); +} +constexpr POINT POINTFromPoint(Point pt) noexcept { + return POINT{ static_cast(pt.x), static_cast(pt.y) }; +} +bool KeyboardIsKeyDown(int key) noexcept { + return (::GetKeyState(key) & 0x80000000) != 0; +} + +} class ScintillaWin; // Forward declaration for COM interface subobjects typedef void VFunction(void); -static HMODULE commctrl32 = 0; /** */ @@ -162,7 +199,7 @@ class DropSource { public: VFunction **vtbl; ScintillaWin *sci; - DropSource(); + DropSource() noexcept; }; /** @@ -171,7 +208,7 @@ class DataObject { public: VFunction **vtbl; ScintillaWin *sci; - DataObject(); + DataObject() noexcept; }; /** @@ -180,19 +217,59 @@ class DropTarget { public: VFunction **vtbl; ScintillaWin *sci; - DropTarget(); + DropTarget() noexcept; }; +namespace { + +class IMContext { + HWND hwnd; +public: + HIMC hIMC; + IMContext(HWND hwnd_) noexcept : + hwnd(hwnd_), hIMC(::ImmGetContext(hwnd_)) { + } + // Deleted so IMContext objects can not be copied. + IMContext(const IMContext &) = delete; + IMContext(IMContext &&) = delete; + IMContext &operator=(const IMContext &) = delete; + IMContext &operator=(IMContext &&) = delete; + ~IMContext() { + if (hIMC) + ::ImmReleaseContext(hwnd, hIMC); + } + + unsigned int GetImeCaretPos() const noexcept { + return ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, nullptr, 0); + } + + std::vector GetImeAttributes() { + const int attrLen = ::ImmGetCompositionStringW(hIMC, GCS_COMPATTR, nullptr, 0); + std::vector attr(attrLen, 0); + ::ImmGetCompositionStringW(hIMC, GCS_COMPATTR, &attr[0], static_cast(attr.size())); + return attr; + } + + std::wstring GetCompositionString(DWORD dwIndex) { + const LONG byteLen = ::ImmGetCompositionStringW(hIMC, dwIndex, nullptr, 0); + std::wstring wcs(byteLen / 2, 0); + ::ImmGetCompositionStringW(hIMC, dwIndex, &wcs[0], byteLen); + return wcs; + } +}; + +} + /** */ class ScintillaWin : public ScintillaBase { bool lastKeyDownConsumed; + wchar_t lastHighSurrogateChar; bool capturedMouse; bool trackedMouseLeave; - TrackMouseEventSig TrackMouseEventFn; SetCoalescableTimerSig SetCoalescableTimerFn; unsigned int linesPerScroll; ///< Intellimouse support @@ -222,17 +299,20 @@ class ScintillaWin : #endif explicit ScintillaWin(HWND hwnd); - ScintillaWin(const ScintillaWin &); - virtual ~ScintillaWin(); - ScintillaWin &operator=(const ScintillaWin &); + // Deleted so ScintillaWin objects can not be copied. + ScintillaWin(const ScintillaWin &) = delete; + ScintillaWin(ScintillaWin &&) = delete; + ScintillaWin &operator=(const ScintillaWin &) = delete; + ScintillaWin &operator=(ScintillaWin &&) = delete; + // ~ScintillaWin() in public section - virtual void Initialise(); - virtual void Finalise(); + void Init(); + void Finalise() override; #if defined(USE_D2D) void EnsureRenderTarget(HDC hdc); void DropRenderTarget(); #endif - HWND MainHWND(); + HWND MainHWND() const noexcept; static sptr_t DirectFunction( sptr_t ptr, UINT iMessage, uptr_t wParam, sptr_t lParam); @@ -243,78 +323,87 @@ class ScintillaWin : enum { invalidTimerID, standardTimerID, idleTimerID, fineTimerStart }; - virtual bool DragThreshold(Point ptStart, Point ptNow); - virtual void StartDrag(); - int TargetAsUTF8(char *text); - int EncodedFromUTF8(char *utf8, char *encoded) const; - sptr_t WndPaint(uptr_t wParam); + bool DragThreshold(Point ptStart, Point ptNow) override; + void StartDrag() override; + static int MouseModifiers(uptr_t wParam) noexcept; + + Sci::Position TargetAsUTF8(char *text) const; + void AddCharUTF16(wchar_t const *wcs, unsigned int wclen); + Sci::Position EncodedFromUTF8(const char *utf8, char *encoded) const; + sptr_t WndPaint(); sptr_t HandleCompositionWindowed(uptr_t wParam, sptr_t lParam); sptr_t HandleCompositionInline(uptr_t wParam, sptr_t lParam); - static bool KoreanIME(); - void MoveImeCarets(int offset); + static bool KoreanIME() noexcept; + void MoveImeCarets(Sci::Position offset); void DrawImeIndicator(int indicator, int len); void SetCandidateWindowPos(); void SelectionToHangul(); void EscapeHanja(); void ToggleHanja(); + void AddWString(std::wstring wcs); UINT CodePageOfDocument() const; - virtual bool ValidCodePage(int codePage) const; - virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); - virtual bool SetIdle(bool on); - UINT_PTR timers[tickDwell+1]; - virtual bool FineTickerAvailable(); - virtual bool FineTickerRunning(TickReason reason); - virtual void FineTickerStart(TickReason reason, int millis, int tolerance); - virtual void FineTickerCancel(TickReason reason); - virtual void SetMouseCapture(bool on); - virtual bool HaveMouseCapture(); - virtual void SetTrackMouseLeaveEvent(bool on); - virtual bool PaintContains(PRectangle rc); - virtual void ScrollText(int linesToMove); - virtual void UpdateSystemCaret(); - virtual void SetVerticalScrollPos(); - virtual void SetHorizontalScrollPos(); - virtual bool ModifyScrollBars(int nMax, int nPage); - virtual void NotifyChange(); - virtual void NotifyFocus(bool focus); - virtual void SetCtrlID(int identifier); - virtual int GetCtrlID(); - virtual void NotifyParent(SCNotification scn); - virtual void NotifyDoubleClick(Point pt, int modifiers); - virtual CaseFolder *CaseFolderForEncoding(); - virtual std::string CaseMapString(const std::string &s, int caseMapping); - virtual void Copy(); - virtual void CopyAllowLine(); - virtual bool CanPaste(); - virtual void Paste(); - virtual void CreateCallTipWindow(PRectangle rc); - virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true); - virtual void ClaimSelection(); + bool ValidCodePage(int codePage) const override; + sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; + void IdleWork() override; + void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) override; + bool SetIdle(bool on) override; + UINT_PTR timers[tickDwell+1] {}; + bool FineTickerRunning(TickReason reason) override; + void FineTickerStart(TickReason reason, int millis, int tolerance) override; + void FineTickerCancel(TickReason reason) override; + void SetMouseCapture(bool on) override; + bool HaveMouseCapture() override; + void SetTrackMouseLeaveEvent(bool on) noexcept; + bool PaintContains(PRectangle rc) override; + void ScrollText(Sci::Line linesToMove) override; + void NotifyCaretMove() override; + void UpdateSystemCaret() override; + void SetVerticalScrollPos() override; + void SetHorizontalScrollPos() override; + bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) override; + void NotifyChange() override; + void NotifyFocus(bool focus) override; + void SetCtrlID(int identifier) override; + int GetCtrlID() override; + void NotifyParent(SCNotification scn) override; + void NotifyDoubleClick(Point pt, int modifiers) override; + CaseFolder *CaseFolderForEncoding() override; + std::string CaseMapString(const std::string &s, int caseMapping) override; + void Copy() override; + void CopyAllowLine() override; + bool CanPaste() override; + void Paste() override; + void CreateCallTipWindow(PRectangle rc) override; + void AddToPopUp(const char *label, int cmd = 0, bool enabled = true) override; + void ClaimSelection() override; // DBCS void ImeStartComposition(); void ImeEndComposition(); + LRESULT ImeOnReconvert(LPARAM lParam); - void GetIntelliMouseParameters(); - virtual void CopyToClipboard(const SelectionText &selectedText); + void GetIntelliMouseParameters() noexcept; + void CopyToClipboard(const SelectionText &selectedText) override; void ScrollMessage(WPARAM wParam); void HorizontalScrollMessage(WPARAM wParam); void FullPaint(); - void FullPaintDC(HDC dc); - bool IsCompatibleDC(HDC dc); - DWORD EffectFromState(DWORD grfKeyState) const; + void FullPaintDC(HDC hdc); + bool IsCompatibleDC(HDC hOtherDC) noexcept; + DWORD EffectFromState(DWORD grfKeyState) const noexcept; - virtual int SetScrollInfo(int nBar, LPCSCROLLINFO lpsi, BOOL bRedraw); - virtual bool GetScrollInfo(int nBar, LPSCROLLINFO lpsi); - void ChangeScrollPos(int barType, int pos); + int SetScrollInfo(int nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) noexcept; + bool GetScrollInfo(int nBar, LPSCROLLINFO lpsi) noexcept; + void ChangeScrollPos(int barType, Sci::Position pos); sptr_t GetTextLength(); sptr_t GetText(uptr_t wParam, sptr_t lParam); public: + ~ScintillaWin() override; + // Public for benefit of Scintilla_DirectFunction - virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); + sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; /// Implement IUnknown STDMETHODIMP QueryInterface(REFIID riid, PVOID *ppv); @@ -332,38 +421,39 @@ public: /// Implement important part of IDataObject STDMETHODIMP GetData(FORMATETC *pFEIn, STGMEDIUM *pSTM); - static bool Register(HINSTANCE hInstance_); - static bool Unregister(); + static bool Register(HINSTANCE hInstance_) noexcept; + static bool Unregister() noexcept; friend class DropSource; friend class DataObject; friend class DropTarget; - bool DragIsRectangularOK(CLIPFORMAT fmt) const { + bool DragIsRectangularOK(CLIPFORMAT fmt) const noexcept { return drag.rectangular && (fmt == cfColumnSelect); } private: // For use in creating a system caret - bool HasCaretSizeChanged() const; + bool HasCaretSizeChanged() const noexcept; BOOL CreateSystemCaret(); - BOOL DestroySystemCaret(); + BOOL DestroySystemCaret() noexcept; HBITMAP sysCaretBitmap; int sysCaretWidth; int sysCaretHeight; + bool styleIdleInQueue; }; -HINSTANCE ScintillaWin::hInstance = 0; +HINSTANCE ScintillaWin::hInstance {}; ATOM ScintillaWin::scintillaClassAtom = 0; ATOM ScintillaWin::callClassAtom = 0; ScintillaWin::ScintillaWin(HWND hwnd) { lastKeyDownConsumed = false; + lastHighSurrogateChar = 0; capturedMouse = false; trackedMouseLeave = false; - TrackMouseEventFn = 0; - SetCoalescableTimerFn = 0; + SetCoalescableTimerFn = nullptr; linesPerScroll = 0; wheelDelta = 0; // Wheel delta from roll @@ -396,8 +486,10 @@ ScintillaWin::ScintillaWin(HWND hwnd) { sysCaretWidth = 0; sysCaretHeight = 0; + styleIdleInQueue = false; + #if defined(USE_D2D) - pRenderTarget = 0; + pRenderTarget = nullptr; renderTargetValid = true; #endif @@ -405,35 +497,24 @@ ScintillaWin::ScintillaWin(HWND hwnd) { if (caret.period < 0) caret.period = 0; - Initialise(); + Init(); } ScintillaWin::~ScintillaWin() {} -void ScintillaWin::Initialise() { +void ScintillaWin::Init() { // Initialize COM. If the app has already done this it will have // no effect. If the app hasn't, we really shouldn't ask them to call // it just so this internal feature works. - hrOle = ::OleInitialize(NULL); + hrOle = ::OleInitialize(nullptr); - // Find TrackMouseEvent which is available on Windows > 95 + // Find SetCoalescableTimer which is only available from Windows 8+ HMODULE user32 = ::GetModuleHandle(TEXT("user32.dll")); if (user32) { - TrackMouseEventFn = (TrackMouseEventSig)::GetProcAddress(user32, "TrackMouseEvent"); - SetCoalescableTimerFn = (SetCoalescableTimerSig)::GetProcAddress(user32, "SetCoalescableTimer"); - } - if (TrackMouseEventFn == NULL) { - // Windows 95 has an emulation in comctl32.dll:_TrackMouseEvent - if (!commctrl32) - commctrl32 = ::LoadLibrary(TEXT("comctl32.dll")); - if (commctrl32 != NULL) { - TrackMouseEventFn = (TrackMouseEventSig) - ::GetProcAddress(commctrl32, "_TrackMouseEvent"); - } - } - for (TickReason tr = tickCaret; tr <= tickDwell; tr = static_cast(tr + 1)) { - timers[tr] = 0; + SetCoalescableTimerFn = reinterpret_cast( + ::GetProcAddress(user32, "SetCoalescableTimer")); } + vs.indicators[SC_INDICATOR_UNKNOWN] = Indicator(INDIC_HIDDEN, ColourDesired(0, 0, 0xff)); vs.indicators[SC_INDICATOR_INPUT] = Indicator(INDIC_DOTS, ColourDesired(0, 0, 0xff)); vs.indicators[SC_INDICATOR_CONVERTED] = Indicator(INDIC_COMPOSITIONTHICK, ColourDesired(0, 0, 0xff)); @@ -463,11 +544,11 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) { renderTargetValid = true; } if (pD2DFactory && !pRenderTarget) { - RECT rc; HWND hw = MainHWND(); + RECT rc; GetClientRect(hw, &rc); - D2D1_SIZE_U size = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top); + const D2D1_SIZE_U size = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top); // Create a Direct2D render target. #if 1 @@ -485,13 +566,13 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) { drtp.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE); - ID2D1DCRenderTarget *pDCRT = NULL; - HRESULT hr = pD2DFactory->CreateDCRenderTarget(&drtp, &pDCRT); + ID2D1DCRenderTarget *pDCRT = nullptr; + const HRESULT hr = pD2DFactory->CreateDCRenderTarget(&drtp, &pDCRT); if (SUCCEEDED(hr)) { pRenderTarget = pDCRT; } else { - Platform::DebugPrintf("Failed CreateDCRenderTarget 0x%x\n", hr); - pRenderTarget = NULL; + Platform::DebugPrintf("Failed CreateDCRenderTarget 0x%lx\n", hr); + pRenderTarget = nullptr; } } else { @@ -501,13 +582,13 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) { dhrtp.presentOptions = (technology == SC_TECHNOLOGY_DIRECTWRITERETAIN) ? D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS : D2D1_PRESENT_OPTIONS_NONE; - ID2D1HwndRenderTarget *pHwndRenderTarget = NULL; - HRESULT hr = pD2DFactory->CreateHwndRenderTarget(drtp, dhrtp, &pHwndRenderTarget); + ID2D1HwndRenderTarget *pHwndRenderTarget = nullptr; + const HRESULT hr = pD2DFactory->CreateHwndRenderTarget(drtp, dhrtp, &pHwndRenderTarget); if (SUCCEEDED(hr)) { pRenderTarget = pHwndRenderTarget; } else { - Platform::DebugPrintf("Failed CreateHwndRenderTarget 0x%x\n", hr); - pRenderTarget = NULL; + Platform::DebugPrintf("Failed CreateHwndRenderTarget 0x%lx\n", hr); + pRenderTarget = nullptr; } } #else @@ -527,9 +608,9 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) { if ((technology == SC_TECHNOLOGY_DIRECTWRITEDC) && pRenderTarget) { RECT rcWindow; GetClientRect(MainHWND(), &rcWindow); - HRESULT hr = static_cast(pRenderTarget)->BindDC(hdc, &rcWindow); + const HRESULT hr = static_cast(pRenderTarget)->BindDC(hdc, &rcWindow); if (FAILED(hr)) { - Platform::DebugPrintf("BindDC failed 0x%x\n", hr); + Platform::DebugPrintf("BindDC failed 0x%lx\n", hr); DropRenderTarget(); } } @@ -538,19 +619,20 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) { void ScintillaWin::DropRenderTarget() { if (pRenderTarget) { pRenderTarget->Release(); - pRenderTarget = 0; + pRenderTarget = nullptr; } } #endif -HWND ScintillaWin::MainHWND() { - return reinterpret_cast(wMain.GetID()); +HWND ScintillaWin::MainHWND() const noexcept { + return static_cast(wMain.GetID()); } bool ScintillaWin::DragThreshold(Point ptStart, Point ptNow) { - int xMove = static_cast(std::abs(ptStart.x - ptNow.x)); - int yMove = static_cast(std::abs(ptStart.y - ptNow.y)); + const Point ptDifference = ptStart - ptNow; + const XYPOSITION xMove = std::trunc(std::abs(ptDifference.x)); + const XYPOSITION yMove = std::trunc(std::abs(ptDifference.y)); return (xMove > ::GetSystemMetrics(SM_CXDRAG)) || (yMove > ::GetSystemMetrics(SM_CYDRAG)); } @@ -562,7 +644,7 @@ void ScintillaWin::StartDrag() { IDataObject *pDataObject = reinterpret_cast(&dob); IDropSource *pDropSource = reinterpret_cast(&ds); //Platform::DebugPrintf("About to DoDragDrop %x %x\n", pDataObject, pDropSource); - HRESULT hr = ::DoDragDrop( + const HRESULT hr = ::DoDragDrop( pDataObject, pDropSource, DROPEFFECT_COPY | DROPEFFECT_MOVE, &dwEffect); @@ -574,23 +656,22 @@ void ScintillaWin::StartDrag() { } } inDragDrop = ddNone; - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); } -// Avoid warnings everywhere for old style casts by concentrating them here -static WORD LoWord(uptr_t l) { - return LOWORD(l); +int ScintillaWin::MouseModifiers(uptr_t wParam) noexcept { + return ModifierFlags((wParam & MK_SHIFT) != 0, + (wParam & MK_CONTROL) != 0, + KeyboardIsKeyDown(VK_MENU)); } -static WORD HiWord(uptr_t l) { - return HIWORD(l); -} +namespace { -static int InputCodePage() { +int InputCodePage() noexcept { HKL inputLocale = ::GetKeyboardLayout(0); - LANGID inputLang = LOWORD(inputLocale); + const LANGID inputLang = LOWORD(inputLocale); char sCodePage[10]; - int res = ::GetLocaleInfoA(MAKELCID(inputLang, SORT_DEFAULT), + const int res = ::GetLocaleInfoA(MAKELCID(inputLang, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, sCodePage, sizeof(sCodePage)); if (!res) return 0; @@ -598,7 +679,7 @@ static int InputCodePage() { } /** Map the key codes to their equivalent SCK_ form. */ -static int KeyTranslate(int keyIn) { +int KeyTranslate(int keyIn) noexcept { //PLATFORM_ASSERT(!keyIn); switch (keyIn) { case VK_DOWN: return SCK_DOWN; @@ -630,19 +711,19 @@ static int KeyTranslate(int keyIn) { } } -static bool BoundsContains(PRectangle rcBounds, HRGN hRgnBounds, PRectangle rcCheck) { +bool BoundsContains(PRectangle rcBounds, HRGN hRgnBounds, PRectangle rcCheck) noexcept { bool contains = true; if (!rcCheck.Empty()) { if (!rcBounds.Contains(rcCheck)) { contains = false; } else if (hRgnBounds) { // In bounding rectangle so check more accurately using region - HRGN hRgnCheck = ::CreateRectRgn(static_cast(rcCheck.left), static_cast(rcCheck.top), - static_cast(rcCheck.right), static_cast(rcCheck.bottom)); + const RECT rcw = RectFromPRectangle(rcCheck); + HRGN hRgnCheck = ::CreateRectRgnIndirect(&rcw); if (hRgnCheck) { HRGN hRgnDifference = ::CreateRectRgn(0, 0, 0, 0); if (hRgnDifference) { - int combination = ::CombineRgn(hRgnDifference, hRgnCheck, hRgnBounds, RGN_DIFF); + const int combination = ::CombineRgn(hRgnDifference, hRgnCheck, hRgnBounds, RGN_DIFF); if (combination != NULLREGION) { contains = false; } @@ -655,24 +736,52 @@ static bool BoundsContains(PRectangle rcBounds, HRGN hRgnBounds, PRectangle rcCh return contains; } +std::string StringEncode(const std::wstring &s, int codePage) { + const int cchMulti = s.length() ? ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast(s.length()), NULL, 0, NULL, NULL) : 0; + std::string sMulti(cchMulti, 0); + if (cchMulti) { + ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast(s.size()), &sMulti[0], cchMulti, NULL, NULL); + } + return sMulti; +} + +std::wstring StringDecode(const std::string &s, int codePage) { + const int cchWide = s.length() ? ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast(s.length()), NULL, 0) : 0; + std::wstring sWide(cchWide, 0); + if (cchWide) { + ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast(s.length()), &sWide[0], cchWide); + } + return sWide; +} + +std::wstring StringMapCase(const std::wstring &ws, DWORD mapFlags) { + const int charsConverted = ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags, + ws.c_str(), static_cast(ws.length()), nullptr, 0); + std::wstring wsConverted(charsConverted, 0); + if (charsConverted) { + ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags, + ws.c_str(), static_cast(ws.length()), &wsConverted[0], charsConverted); + } + return wsConverted; +} + +} + // Returns the target converted to UTF8. // Return the length in bytes. -int ScintillaWin::TargetAsUTF8(char *text) { - int targetLength = targetEnd - targetStart; +Sci::Position ScintillaWin::TargetAsUTF8(char *text) const { + const Sci::Position targetLength = targetEnd - targetStart; if (IsUnicodeMode()) { if (text) { pdoc->GetCharRange(text, targetStart, targetLength); } } else { // Need to convert - std::string s = RangeText(targetStart, targetEnd); - int charsLen = ::MultiByteToWideChar(CodePageOfDocument(), 0, &s[0], targetLength, NULL, 0); - std::wstring characters(charsLen, '\0'); - ::MultiByteToWideChar(CodePageOfDocument(), 0, &s[0], targetLength, &characters[0], charsLen); - - int utf8Len = ::WideCharToMultiByte(CP_UTF8, 0, &characters[0], charsLen, NULL, 0, 0, 0); + const std::string s = RangeText(targetStart, targetEnd); + const std::wstring characters = StringDecode(s, CodePageOfDocument()); + const int utf8Len = ::WideCharToMultiByte(CP_UTF8, 0, characters.c_str(), static_cast(characters.length()), NULL, 0, 0, 0); if (text) { - ::WideCharToMultiByte(CP_UTF8, 0, &characters[0], charsLen, text, utf8Len, 0, 0); + ::WideCharToMultiByte(CP_UTF8, 0, characters.c_str(), static_cast(characters.length()), text, utf8Len, 0, 0); text[utf8Len] = '\0'; } return utf8Len; @@ -682,8 +791,8 @@ int ScintillaWin::TargetAsUTF8(char *text) { // Translates a nul terminated UTF8 string into the document encoding. // Return the length of the result in bytes. -int ScintillaWin::EncodedFromUTF8(char *utf8, char *encoded) const { - int inputLength = (lengthForEncode >= 0) ? lengthForEncode : static_cast(strlen(utf8)); +Sci::Position ScintillaWin::EncodedFromUTF8(const char *utf8, char *encoded) const { + const Sci::Position inputLength = (lengthForEncode >= 0) ? lengthForEncode : strlen(utf8); if (IsUnicodeMode()) { if (encoded) { memcpy(encoded, utf8, inputLength); @@ -691,11 +800,11 @@ int ScintillaWin::EncodedFromUTF8(char *utf8, char *encoded) const { return inputLength; } else { // Need to convert - int charsLen = ::MultiByteToWideChar(CP_UTF8, 0, utf8, inputLength, NULL, 0); + const int charsLen = ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast(inputLength), NULL, 0); std::wstring characters(charsLen, '\0'); - ::MultiByteToWideChar(CP_UTF8, 0, utf8, inputLength, &characters[0], charsLen); + ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast(inputLength), &characters[0], charsLen); - int encodedLen = ::WideCharToMultiByte(CodePageOfDocument(), + const int encodedLen = ::WideCharToMultiByte(CodePageOfDocument(), 0, &characters[0], charsLen, NULL, 0, 0, 0); if (encoded) { ::WideCharToMultiByte(CodePageOfDocument(), 0, &characters[0], charsLen, encoded, encodedLen, 0, 0); @@ -705,46 +814,58 @@ int ScintillaWin::EncodedFromUTF8(char *utf8, char *encoded) const { } } -sptr_t ScintillaWin::WndPaint(uptr_t wParam) { - //ElapsedTime et; +// Add one character from a UTF-16 string, by converting to either UTF-8 or +// the current codepage. Code is similar to HandleCompositionWindowed(). +void ScintillaWin::AddCharUTF16(wchar_t const *wcs, unsigned int wclen) { + if (IsUnicodeMode()) { + size_t len = UTF8Length(wcs, wclen); + char utfval[maxLenInputIME * 3]; + UTF8FromUTF16(wcs, wclen, utfval, len); + utfval[len] = '\0'; + AddCharUTF(utfval, static_cast(len)); + } else { + const UINT cpDest = CodePageOfDocument(); + char inBufferCP[maxLenInputIME * 2]; + const int size = ::WideCharToMultiByte(cpDest, + 0, wcs, wclen, inBufferCP, sizeof(inBufferCP) - 1, 0, 0); + for (int i=0; i(wParam); - } else { - ::GetUpdateRgn(MainHWND(), hRgnUpdate, FALSE); - pps = &ps; - ::BeginPaint(MainHWND(), pps); - } - rcPaint = PRectangle::FromInts(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom); - PRectangle rcClient = GetClientRectangle(); + ::GetUpdateRgn(MainHWND(), hRgnUpdate, FALSE); + ::BeginPaint(MainHWND(), &ps); + rcPaint = PRectangle::FromInts(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); + const PRectangle rcClient = GetClientRectangle(); paintingAllText = BoundsContains(rcPaint, hRgnUpdate, rcClient); if (technology == SC_TECHNOLOGY_DEFAULT) { - AutoSurface surfaceWindow(pps->hdc, this); + AutoSurface surfaceWindow(ps.hdc, this); if (surfaceWindow) { Paint(surfaceWindow, rcPaint); surfaceWindow->Release(); } } else { #if defined(USE_D2D) - EnsureRenderTarget(pps->hdc); + EnsureRenderTarget(ps.hdc); AutoSurface surfaceWindow(pRenderTarget, this); if (surfaceWindow) { pRenderTarget->BeginDraw(); Paint(surfaceWindow, rcPaint); surfaceWindow->Release(); - HRESULT hr = pRenderTarget->EndDraw(); - if (hr == D2DERR_RECREATE_TARGET) { + const HRESULT hr = pRenderTarget->EndDraw(); + if (hr == static_cast(D2DERR_RECREATE_TARGET)) { DropRenderTarget(); paintState = paintAbandoned; } @@ -756,70 +877,48 @@ sptr_t ScintillaWin::WndPaint(uptr_t wParam) { hRgnUpdate = 0; } - if (!IsOcxCtrl) - ::EndPaint(MainHWND(), pps); + ::EndPaint(MainHWND(), &ps); if (paintState == paintAbandoned) { // Painting area was insufficient to cover new styling or brace highlight positions - if (IsOcxCtrl) { - FullPaintDC(pps->hdc); - } else { - FullPaint(); - } + FullPaint(); + ::ValidateRect(MainHWND(), nullptr); } paintState = notPainting; // Restore debug output state Platform::ShowAssertionPopUps(assertsPopup); - //Platform::DebugPrintf("Paint took %g\n", et.Duration()); - return 0l; + //Platform::DebugPrintf("Paint took %g\n", ep.Duration()); + return 0; } sptr_t ScintillaWin::HandleCompositionWindowed(uptr_t wParam, sptr_t lParam) { if (lParam & GCS_RESULTSTR) { - HIMC hIMC = ::ImmGetContext(MainHWND()); - if (hIMC) { - wchar_t wcs[maxLenInputIME]; - LONG bytes = ::ImmGetCompositionStringW(hIMC, - GCS_RESULTSTR, wcs, (maxLenInputIME-1)*2); - int wides = bytes / 2; - if (IsUnicodeMode()) { - char utfval[maxLenInputIME * 3]; - unsigned int len = UTF8Length(wcs, wides); - UTF8FromUTF16(wcs, wides, utfval, len); - utfval[len] = '\0'; - AddCharUTF(utfval, len); - } else { - char dbcsval[maxLenInputIME * 2]; - int size = ::WideCharToMultiByte(InputCodePage(), - 0, wcs, wides, dbcsval, sizeof(dbcsval) - 1, 0, 0); - for (int i=0; i(pos.x); - CompForm.ptCurrentPos.y = static_cast(pos.y); - ::ImmSetCompositionWindow(hIMC, &CompForm); - ::ImmReleaseContext(MainHWND(), hIMC); + CompForm.ptCurrentPos = POINTFromPoint(pos); + ::ImmSetCompositionWindow(imc.hIMC, &CompForm); } return 0; } return ::DefWindowProc(MainHWND(), WM_IME_COMPOSITION, wParam, lParam); } -bool ScintillaWin::KoreanIME() { +bool ScintillaWin::KoreanIME() noexcept { const int codePage = InputCodePage(); return codePage == 949 || codePage == 1361; } -void ScintillaWin::MoveImeCarets(int offset) { +void ScintillaWin::MoveImeCarets(Sci::Position offset) { // Move carets relatively by bytes. for (size_t r=0; r INDIC_MAX) { return; } - pdoc->decorations.SetCurrentIndicator(indicator); + pdoc->DecorationSetCurrentIndicator(indicator); for (size_t r=0; rDecorationFillRange(positionInsert - len, 1, len); } } void ScintillaWin::SetCandidateWindowPos() { - HIMC hIMC = ::ImmGetContext(MainHWND()); - if (hIMC) { - Point pos = PointMainCaret(); + IMContext imc(MainHWND()); + if (imc.hIMC) { + const Point pos = PointMainCaret(); CANDIDATEFORM CandForm; CandForm.dwIndex = 0; CandForm.dwStyle = CFS_CANDIDATEPOS; CandForm.ptCurrentPos.x = static_cast(pos.x); CandForm.ptCurrentPos.y = static_cast(pos.y + vs.lineHeight); - ::ImmSetCandidateWindow(hIMC, &CandForm); - ::ImmReleaseContext(MainHWND(), hIMC); - } -} - -static std::string StringEncode(std::wstring s, int codePage) { - if (s.length()) { - int cchMulti = ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast(s.length()), NULL, 0, NULL, NULL); - std::string sMulti(cchMulti, 0); - ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast(s.size()), &sMulti[0], cchMulti, NULL, NULL); - return sMulti; - } else { - return std::string(); - } -} - -static std::wstring StringDecode(std::string s, int codePage) { - if (s.length()) { - int cchWide = ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast(s.length()), NULL, 0); - std::wstring sWide(cchWide, 0); - ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast(s.length()), &sWide[0], cchWide); - return sWide; - } else { - return std::wstring(); + ::ImmSetCandidateWindow(imc.hIMC, &CandForm); } } void ScintillaWin::SelectionToHangul() { // Convert every hanja to hangul within the main range. - const int selStart = sel.RangeMain().Start().Position(); - const int documentStrLen = sel.RangeMain().Length(); - const int selEnd = selStart + documentStrLen; - const int utf16Len = pdoc->CountUTF16(selStart, selEnd); + const Sci::Position selStart = sel.RangeMain().Start().Position(); + const Sci::Position documentStrLen = sel.RangeMain().Length(); + const Sci::Position selEnd = selStart + documentStrLen; + const Sci::Position utf16Len = pdoc->CountUTF16(selStart, selEnd); if (utf16Len > 0) { std::string documentStr(documentStrLen, '\0'); pdoc->GetCharRange(&documentStr[0], selStart, documentStrLen); std::wstring uniStr = StringDecode(documentStr, CodePageOfDocument()); - int converted = HanjaDict::GetHangulOfHanja(&uniStr[0]); + const int converted = HanjaDict::GetHangulOfHanja(&uniStr[0]); documentStr = StringEncode(uniStr, CodePageOfDocument()); if (converted > 0) { pdoc->BeginUndoAction(); ClearSelection(); - InsertPaste(&documentStr[0], static_cast(documentStr.size())); + InsertPaste(&documentStr[0], documentStr.size()); pdoc->EndUndoAction(); } } @@ -907,8 +983,8 @@ void ScintillaWin::EscapeHanja() { if (sel.Count() > 1) { return; // Do not allow multi carets. } - int currentPos = CurrentPosition(); - int oneCharLen = pdoc->LenChar(currentPos); + const Sci::Position currentPos = CurrentPosition(); + const int oneCharLen = pdoc->LenChar(currentPos); if (oneCharLen < 2) { return; // No need to handle SBCS. @@ -922,20 +998,19 @@ void ScintillaWin::EscapeHanja() { std::wstring uniChar = StringDecode(oneChar, CodePageOfDocument()); - HIMC hIMC=ImmGetContext(MainHWND()); - if (hIMC) { + IMContext imc(MainHWND()); + if (imc.hIMC) { // Set the candidate box position since IME may show it. SetCandidateWindowPos(); // IME_ESC_HANJA_MODE appears to receive the first character only. - if (ImmEscapeW(GetKeyboardLayout(0), hIMC, IME_ESC_HANJA_MODE, &uniChar[0])) { - SetSelection (currentPos, currentPos + oneCharLen); + if (ImmEscapeW(GetKeyboardLayout(0), imc.hIMC, IME_ESC_HANJA_MODE, &uniChar[0])) { + SetSelection(currentPos, currentPos + oneCharLen); } - ::ImmReleaseContext(MainHWND(), hIMC); } } void ScintillaWin::ToggleHanja() { - // If selection, convert every hanja to hangul within the main range. + // If selection, convert every hanja to hangul within the main range. // If no selection, commit to IME. if (sel.Count() > 1) { return; // Do not allow multi carets. @@ -948,135 +1023,120 @@ void ScintillaWin::ToggleHanja() { } } +namespace { + +std::vector MapImeIndicators(std::vector inputStyle) { + std::vector imeIndicator(inputStyle.size(), SC_INDICATOR_UNKNOWN); + for (size_t i = 0; i < inputStyle.size(); i++) { + switch (static_cast(inputStyle.at(i))) { + case ATTR_INPUT: + imeIndicator[i] = SC_INDICATOR_INPUT; + break; + case ATTR_TARGET_NOTCONVERTED: + case ATTR_TARGET_CONVERTED: + imeIndicator[i] = SC_INDICATOR_TARGET; + break; + case ATTR_CONVERTED: + imeIndicator[i] = SC_INDICATOR_CONVERTED; + break; + default: + imeIndicator[i] = SC_INDICATOR_UNKNOWN; + break; + } + } + return imeIndicator; +} + +} + +void ScintillaWin::AddWString(std::wstring wcs) { + if (wcs.empty()) + return; + + const int codePage = CodePageOfDocument(); + for (size_t i = 0; i < wcs.size(); ) { + const size_t ucWidth = UTF16CharLength(wcs[i]); + const std::wstring uniChar(wcs, i, ucWidth); + std::string docChar = StringEncode(uniChar, codePage); + + AddCharUTF(docChar.c_str(), static_cast(docChar.size())); + i += ucWidth; + } +} + sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { // Copy & paste by johnsonj with a lot of helps of Neil. // Great thanks for my foreruners, jiniya and BLUEnLIVE. - HIMC hIMC = ::ImmGetContext(MainHWND()); - if (!hIMC) { + IMContext imc(MainHWND()); + if (!imc.hIMC) + return 0; + if (pdoc->IsReadOnly() || SelectionContainsProtected()) { + ::ImmNotifyIME(imc.hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0); return 0; } + bool initialCompose = false; if (pdoc->TentativeActive()) { pdoc->TentativeUndo(); } else { // No tentative undo means start of this composition so // fill in any virtual spaces. - FillVirtualSpace(); + initialCompose = true; } view.imeCaretBlockOverride = false; if (lParam & GCS_COMPSTR) { - wchar_t wcs[maxLenInputIME] = { 0 }; - long bytes = ::ImmGetCompositionStringW - (hIMC, GCS_COMPSTR, wcs, maxLenInputIME); - unsigned int wcsLen = bytes / 2; - - if ((wcsLen == 0) || (wcsLen >= maxLenInputIME)) { + const std::wstring wcs = imc.GetCompositionString(GCS_COMPSTR); + if ((wcs.size() == 0) || (wcs.size() >= maxLenInputIME)) { ShowCaretAtCurrentPosition(); - ::ImmReleaseContext(MainHWND(), hIMC); return 0; } + if (initialCompose) + ClearBeforeTentativeStart(); pdoc->TentativeStart(); // TentativeActive from now on. - // Get attribute information from composition string. - BYTE compAttr[maxLenInputIME] = { 0 }; - unsigned int imeCursorPos = 0; + std::vector imeIndicator = MapImeIndicators(imc.GetImeAttributes()); - if (lParam & GCS_COMPATTR) { - ImmGetCompositionStringW(hIMC, GCS_COMPATTR, compAttr, sizeof(compAttr)); - } - if (lParam & GCS_CURSORPOS) { - imeCursorPos = ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, NULL, 0); - } - - // Display character by character. - int numBytes = 0; - int imeCharPos[maxLenInputIME + 1] = { 0 }; - - bool tmpRecordingMacro = recordingMacro; + const bool tmpRecordingMacro = recordingMacro; recordingMacro = false; - for (size_t i = 0; i < wcsLen; ) { + const int codePage = CodePageOfDocument(); + for (size_t i = 0; i < wcs.size(); ) { const size_t ucWidth = UTF16CharLength(wcs[i]); - const std::wstring uniChar(wcs+i, ucWidth); - char oneChar[UTF8MaxBytes + 1] = "\0\0\0\0"; // Maximum 4 bytes in utf8 - unsigned int oneCharLen = 0; + const std::wstring uniChar(wcs, i, ucWidth); + std::string docChar = StringEncode(uniChar, codePage); - if (IsUnicodeMode()) { - oneCharLen = UTF8Length(uniChar.c_str(), static_cast(uniChar.length())); - UTF8FromUTF16(uniChar.c_str(), static_cast(uniChar.length()), oneChar, oneCharLen); - } else { - oneCharLen = ::WideCharToMultiByte(InputCodePage(), 0, - uniChar.c_str(), static_cast(uniChar.length()), oneChar, sizeof(oneChar)-1, 0, 0); - } - oneChar[oneCharLen] = '\0'; + AddCharUTF(docChar.c_str(), static_cast(docChar.size())); - // Display a character. - AddCharUTF(oneChar, oneCharLen); - - // Record compstr character positions for moving IME carets. - numBytes += oneCharLen; - imeCharPos[i + 1] = numBytes; - - // Draw an indicator on the character. - int indicator = SC_INDICATOR_UNKNOWN; - switch ((int)compAttr[i]) { - case ATTR_INPUT: - indicator = SC_INDICATOR_INPUT; - break; - case ATTR_TARGET_NOTCONVERTED: - case ATTR_TARGET_CONVERTED: - indicator = SC_INDICATOR_TARGET; - break; - case ATTR_CONVERTED: - indicator = SC_INDICATOR_CONVERTED; - break; - } - DrawImeIndicator(indicator, oneCharLen); + DrawImeIndicator(imeIndicator[i], static_cast(docChar.size())); i += ucWidth; } recordingMacro = tmpRecordingMacro; - // Move IME caret position. - MoveImeCarets(-imeCharPos[wcsLen] + imeCharPos[imeCursorPos]); + // Move IME caret from current last position to imeCaretPos. + const int imeEndToImeCaretU16 = imc.GetImeCaretPos() - static_cast(wcs.size()); + const Sci::Position imeCaretPosDoc = pdoc->GetRelativePositionUTF16(CurrentPosition(), imeEndToImeCaretU16); + + MoveImeCarets(- CurrentPosition() + imeCaretPosDoc); + if (KoreanIME()) { view.imeCaretBlockOverride = true; } } else if (lParam & GCS_RESULTSTR) { - wchar_t wcs[maxLenInputIME] = { 0 }; - long bytes = ::ImmGetCompositionStringW - (hIMC, GCS_RESULTSTR, wcs, maxLenInputIME); - unsigned int wcsLen = bytes / 2; - - for (size_t i = 0; i < wcsLen;) { - const size_t ucWidth = UTF16CharLength(wcs[i]); - const std::wstring uniChar(wcs+i, ucWidth); - char oneChar[UTF8MaxBytes+1] = "\0\0\0\0"; // Maximum 4 bytes in UTF-8. - unsigned int oneCharLen = 0; - - if (IsUnicodeMode()) { - oneCharLen = UTF8Length(uniChar.c_str(), static_cast(uniChar.length())); - UTF8FromUTF16(uniChar.c_str(), static_cast(uniChar.length()), oneChar, oneCharLen); - } else { - oneCharLen = ::WideCharToMultiByte(InputCodePage(), 0, - uniChar.c_str(), static_cast(uniChar.length()), oneChar, sizeof(oneChar)-1, 0, 0); - } - oneChar[oneCharLen] = '\0'; - AddCharUTF(oneChar, oneCharLen); - i += ucWidth; - } + AddWString(imc.GetCompositionString(GCS_RESULTSTR)); } EnsureCaretVisible(); SetCandidateWindowPos(); ShowCaretAtCurrentPosition(); - ::ImmReleaseContext(MainHWND(), hIMC); return 0; } +namespace { + // Translate message IDs from WM_* and EM_* to SCI_* so can partly emulate Windows Edit control -static unsigned int SciMessageFromEM(unsigned int iMessage) { +unsigned int SciMessageFromEM(unsigned int iMessage) noexcept { switch (iMessage) { case EM_CANPASTE: return SCI_CANPASTE; case EM_CANUNDO: return SCI_CANUNDO; @@ -1103,13 +1163,17 @@ static unsigned int SciMessageFromEM(unsigned int iMessage) { return iMessage; } -UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) { +} + +namespace Scintilla { + +UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) noexcept { if (documentCodePage == SC_CP_UTF8) { return SC_CP_UTF8; } switch (characterSet) { case SC_CHARSET_ANSI: return 1252; - case SC_CHARSET_DEFAULT: return documentCodePage; + case SC_CHARSET_DEFAULT: return documentCodePage ? documentCodePage : 1252; case SC_CHARSET_BALTIC: return 1257; case SC_CHARSET_CHINESEBIG5: return 950; case SC_CHARSET_EASTEUROPE: return 1250; @@ -1134,6 +1198,8 @@ UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) { return documentCodePage; } +} + UINT ScintillaWin::CodePageOfDocument() const { return CodePageFromCharSet(vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage); } @@ -1144,7 +1210,7 @@ sptr_t ScintillaWin::GetTextLength() { std::vector docBytes(pdoc->Length(), '\0'); pdoc->GetCharRange(&docBytes[0], 0, pdoc->Length()); if (IsUnicodeMode()) { - return UTF16Length(&docBytes[0], static_cast(docBytes.size())); + return UTF16Length(&docBytes[0], docBytes.size()); } else { return ::MultiByteToWideChar(CodePageOfDocument(), 0, &docBytes[0], static_cast(docBytes.size()), NULL, 0); @@ -1152,7 +1218,7 @@ sptr_t ScintillaWin::GetTextLength() { } sptr_t ScintillaWin::GetText(uptr_t wParam, sptr_t lParam) { - wchar_t *ptr = reinterpret_cast(lParam); + wchar_t *ptr = static_cast(PtrFromSPtr(lParam)); if (pdoc->Length() == 0) { *ptr = L'\0'; return 0; @@ -1160,13 +1226,13 @@ sptr_t ScintillaWin::GetText(uptr_t wParam, sptr_t lParam) { std::vector docBytes(pdoc->Length(), '\0'); pdoc->GetCharRange(&docBytes[0], 0, pdoc->Length()); if (IsUnicodeMode()) { - size_t lengthUTF16 = UTF16Length(&docBytes[0], static_cast(docBytes.size())); + const size_t lengthUTF16 = UTF16Length(&docBytes[0], docBytes.size()); if (lParam == 0) return lengthUTF16; if (wParam == 0) return 0; size_t uLen = UTF16FromUTF8(&docBytes[0], docBytes.size(), - ptr, static_cast(wParam) - 1); + ptr, wParam - 1); ptr[uLen] = L'\0'; return uLen; } else { @@ -1192,18 +1258,16 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam switch (iMessage) { case WM_CREATE: - ctrlID = ::GetDlgCtrlID(reinterpret_cast(wMain.GetID())); + ctrlID = ::GetDlgCtrlID(static_cast(wMain.GetID())); // Get Intellimouse scroll line parameters GetIntelliMouseParameters(); ::RegisterDragDrop(MainHWND(), reinterpret_cast(&dt)); break; - case WM_COMMAND: - Command(LoWord(wParam)); + Command(LOWORD(wParam)); break; - case WM_PAINT: - return WndPaint(wParam); + return WndPaint(); case WM_PRINTCLIENT: { HDC hdc = reinterpret_cast(wParam); @@ -1230,15 +1294,27 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam renderTargetValid = false; } #endif - //Platform::DebugPrintf("Scintilla WM_SIZE %d %d\n", LoWord(lParam), HiWord(lParam)); + //Platform::DebugPrintf("Scintilla WM_SIZE %d %d\n", LOWORD(lParam), HIWORD(lParam)); ChangeSize(); } break; case WM_MOUSEWHEEL: + if (!mouseWheelCaptures) { + // if the mouse wheel is not captured, test if the mouse + // pointer is over the editor window and if not, don't + // handle the message but pass it on. + RECT rc; + GetWindowRect(MainHWND(), &rc); + POINT pt; + pt.x = GET_X_LPARAM(lParam); + pt.y = GET_Y_LPARAM(lParam); + if (!PtInRect(&rc, pt)) + return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); + } // if autocomplete list active then send mousewheel message to it if (ac.Active()) { - HWND hWnd = reinterpret_cast(ac.lb->GetID()); + HWND hWnd = static_cast(ac.lb->GetID()); ::SendMessage(hWnd, iMessage, wParam, lParam); break; } @@ -1250,11 +1326,10 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam if (wParam & MK_SHIFT) { return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); } - // Either SCROLL or ZOOM. We handle the wheel steppings calculation - wheelDelta -= static_cast(HiWord(wParam)); - if (abs(wheelDelta) >= WHEEL_DELTA && linesPerScroll > 0) { - int linesToScroll = linesPerScroll; + wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam); + if (std::abs(wheelDelta) >= WHEEL_DELTA && linesPerScroll > 0) { + Sci::Line linesToScroll = linesPerScroll; if (linesPerScroll == WHEEL_PAGESCROLL) linesToScroll = LinesOnScreen() - 1; if (linesToScroll == 0) { @@ -1292,7 +1367,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case SC_WIN_IDLE: // wParam=dwTickCountInitial, or 0 to initialize. lParam=bSkipUserInputTest if (idler.state) { - if (lParam || (WAIT_TIMEOUT == MsgWaitForMultipleObjects(0, 0, 0, 0, QS_INPUT|QS_HOTKEY))) { + if (lParam || (WAIT_TIMEOUT == MsgWaitForMultipleObjects(0, nullptr, 0, 0, QS_INPUT|QS_HOTKEY))) { if (Idle()) { // User input was given priority above, but all events do get a turn. Other // messages, notifications, etc. will get interleaved with the idle messages. @@ -1301,8 +1376,14 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam // when there's a message posted. So, several times a second, we stop and let // the low priority events have a turn (after which the timer will fire again). - DWORD dwCurrent = GetTickCount(); - DWORD dwStart = wParam ? static_cast(wParam) : dwCurrent; + // Suppress a warning from Code Analysis that the GetTickCount function + // wraps after 49 days. The WM_TIMER will kick off another SC_WIN_IDLE + // after the wrap. +#ifdef _MSC_VER +#pragma warning(suppress: 28159) +#endif + const DWORD dwCurrent = GetTickCount(); + const DWORD dwStart = wParam ? static_cast(wParam) : dwCurrent; const DWORD maxWorkTime = 50; if (dwCurrent >= dwStart && dwCurrent > maxWorkTime && dwCurrent - maxWorkTime < dwStart) @@ -1314,38 +1395,36 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam } break; + case SC_WORK_IDLE: + IdleWork(); + break; + case WM_GETMINMAXINFO: return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); case WM_LBUTTONDOWN: { // For IME, set the composition string as the result string. - HIMC hIMC = ::ImmGetContext(MainHWND()); - ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); - ::ImmReleaseContext(MainHWND(), hIMC); + IMContext imc(MainHWND()); + ::ImmNotifyIME(imc.hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); // //Platform::DebugPrintf("Buttdown %d %x %x %x %x %x\n",iMessage, wParam, lParam, - // Platform::IsKeyDown(VK_SHIFT), - // Platform::IsKeyDown(VK_CONTROL), - // Platform::IsKeyDown(VK_MENU)); + // KeyboardIsKeyDown(VK_SHIFT), + // KeyboardIsKeyDown(VK_CONTROL), + // KeyboardIsKeyDown(VK_MENU)); ::SetFocus(MainHWND()); - ButtonDown(Point::FromLong(static_cast(lParam)), ::GetMessageTime(), - (wParam & MK_SHIFT) != 0, - (wParam & MK_CONTROL) != 0, - Platform::IsKeyDown(VK_MENU)); + ButtonDownWithModifiers(PointFromLParam(lParam), ::GetMessageTime(), + MouseModifiers(wParam)); } break; case WM_MOUSEMOVE: { - const Point pt = Point::FromLong(static_cast(lParam)); + const Point pt = PointFromLParam(lParam); // Windows might send WM_MOUSEMOVE even though the mouse has not been moved: // http://blogs.msdn.com/b/oldnewthing/archive/2003/10/01/55108.aspx - if (ptMouseLast.x != pt.x || ptMouseLast.y != pt.y) { + if (ptMouseLast != pt) { SetTrackMouseLeaveEvent(true); - ButtonMoveWithModifiers(pt, - ((wParam & MK_SHIFT) != 0 ? SCI_SHIFT : 0) | - ((wParam & MK_CONTROL) != 0 ? SCI_CTRL : 0) | - (Platform::IsKeyDown(VK_MENU) ? SCI_ALT : 0)); + ButtonMoveWithModifiers(pt, ::GetMessageTime(), MouseModifiers(wParam)); } } break; @@ -1356,21 +1435,23 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); case WM_LBUTTONUP: - ButtonUp(Point::FromLong(static_cast(lParam)), - ::GetMessageTime(), - (wParam & MK_CONTROL) != 0); + ButtonUpWithModifiers(PointFromLParam(lParam), + ::GetMessageTime(), MouseModifiers(wParam)); break; - case WM_RBUTTONDOWN: - ::SetFocus(MainHWND()); - if (!PointInSelection(Point::FromLong(static_cast(lParam)))) { - CancelModes(); - SetEmptySelection(PositionFromLocation(Point::FromLong(static_cast(lParam)))); + case WM_RBUTTONDOWN: { + ::SetFocus(MainHWND()); + const Point pt = PointFromLParam(lParam); + if (!PointInSelection(pt)) { + CancelModes(); + SetEmptySelection(PositionFromLocation(PointFromLParam(lParam))); + } + + RightButtonDownWithModifiers(pt, ::GetMessageTime(), MouseModifiers(wParam)); } break; - case WM_SETCURSOR: - if (LoWord(lParam) == HTCLIENT) { + if (LOWORD(lParam) == HTCLIENT) { if (inDragDrop == ddDragging) { DisplayCursor(Window::cursorUp); } else { @@ -1396,50 +1477,42 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case WM_CHAR: if (((wParam >= 128) || !iscntrl(static_cast(wParam))) || !lastKeyDownConsumed) { - wchar_t wcs[2] = {static_cast(wParam), 0}; - if (IsUnicodeMode()) { - // For a wide character version of the window: - char utfval[UTF8MaxBytes]; - unsigned int len = UTF8Length(wcs, 1); - UTF8FromUTF16(wcs, 1, utfval, len); - AddCharUTF(utfval, len); - } else { - UINT cpDest = CodePageOfDocument(); - char inBufferCP[20]; - int size = ::WideCharToMultiByte(cpDest, - 0, wcs, 1, inBufferCP, sizeof(inBufferCP) - 1, 0, 0); - inBufferCP[size] = '\0'; - AddCharUTF(inBufferCP, size); + wchar_t wcs[3] = {static_cast(wParam), 0}; + unsigned int wclen = 1; + if (IS_HIGH_SURROGATE(wcs[0])) { + // If this is a high surrogate character, we need a second one + lastHighSurrogateChar = wcs[0]; + return 0; + } else if (IS_LOW_SURROGATE(wcs[0])) { + wcs[1] = wcs[0]; + wcs[0] = lastHighSurrogateChar; + lastHighSurrogateChar = 0; + wclen = 2; } + AddCharUTF16(wcs, wclen); } return 0; case WM_UNICHAR: if (wParam == UNICODE_NOCHAR) { - return IsUnicodeMode() ? 1 : 0; + return TRUE; } else if (lastKeyDownConsumed) { return 1; } else { - if (IsUnicodeMode()) { - char utfval[UTF8MaxBytes]; - wchar_t wcs[2] = {static_cast(wParam), 0}; - unsigned int len = UTF8Length(wcs, 1); - UTF8FromUTF16(wcs, 1, utfval, len); - AddCharUTF(utfval, len); - return 1; - } else { - return 0; - } + wchar_t wcs[3] = {0}; + const unsigned int wclen = UTF16FromUTF32Character(static_cast(wParam), wcs); + AddCharUTF16(wcs, wclen); + return FALSE; } case WM_SYSKEYDOWN: case WM_KEYDOWN: { //Platform::DebugPrintf("S keydown %d %x %x %x %x\n",iMessage, wParam, lParam, ::IsKeyDown(VK_SHIFT), ::IsKeyDown(VK_CONTROL)); lastKeyDownConsumed = false; - int ret = KeyDown(KeyTranslate(static_cast(wParam)), - Platform::IsKeyDown(VK_SHIFT), - Platform::IsKeyDown(VK_CONTROL), - Platform::IsKeyDown(VK_MENU), + const int ret = KeyDownWithModifiers(KeyTranslate(static_cast(wParam)), + ModifierFlags(KeyboardIsKeyDown(VK_SHIFT), + KeyboardIsKeyDown(VK_CONTROL), + KeyboardIsKeyDown(VK_MENU)), &lastKeyDownConsumed); if (!ret && !lastKeyDownConsumed) { return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); @@ -1454,6 +1527,13 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); } + case WM_IME_REQUEST: { + if (wParam == IMR_RECONVERTSTRING) { + return ImeOnReconvert(lParam); + } + return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); + } + case WM_KEYUP: //Platform::DebugPrintf("S keyup %d %x %x\n",iMessage, wParam, lParam); return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); @@ -1471,17 +1551,16 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case WM_KILLFOCUS: { HWND wOther = reinterpret_cast(wParam); HWND wThis = MainHWND(); - HWND wCT = reinterpret_cast(ct.wCallTip.GetID()); + const HWND wCT = static_cast(ct.wCallTip.GetID()); if (!wParam || !(::IsChild(wThis, wOther) || (wOther == wCT))) { SetFocusState(false); DestroySystemCaret(); } // Explicitly complete any IME composition - HIMC hIMC = ImmGetContext(MainHWND()); - if (hIMC) { - ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); - ::ImmReleaseContext(MainHWND(), hIMC); + IMContext imc(MainHWND()); + if (imc.hIMC) { + ::ImmNotifyIME(imc.hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); } } break; @@ -1510,31 +1589,32 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); case WM_IME_COMPOSITION: - if (KoreanIME() || imeInteraction == imeInline) { + if (KoreanIME() || imeInteraction == imeInline) { return HandleCompositionInline(wParam, lParam); } else { return HandleCompositionWindowed(wParam, lParam); } - case WM_CONTEXTMENU: - if (displayPopupMenu) { - Point pt = Point::FromLong(static_cast(lParam)); - if ((pt.x == -1) && (pt.y == -1)) { - // Caused by keyboard so display menu near caret - pt = PointMainCaret(); - POINT spt = {static_cast(pt.x), static_cast(pt.y)}; - ::ClientToScreen(MainHWND(), &spt); - pt = PointFromPOINT(spt); + case WM_CONTEXTMENU: { + Point pt = PointFromLParam(lParam); + POINT rpt = {static_cast(pt.x), static_cast(pt.y)}; + ::ScreenToClient(MainHWND(), &rpt); + const Point ptClient = PointFromPOINT(rpt); + if (ShouldDisplayPopup(ptClient)) { + if ((pt.x == -1) && (pt.y == -1)) { + // Caused by keyboard so display menu near caret + pt = PointMainCaret(); + POINT spt = POINTFromPoint(pt); + ::ClientToScreen(MainHWND(), &spt); + pt = PointFromPOINT(spt); + } + ContextMenu(pt); + return 0; } - ContextMenu(pt); - return 0; } return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); - case WM_INPUTLANGCHANGE: - //::SetThreadLocale(LOWORD(lParam)); return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); - case WM_INPUTLANGCHANGEREQUEST: return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); @@ -1588,37 +1668,33 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case EM_GETSEL: if (wParam) { - *reinterpret_cast(wParam) = SelectionStart().Position(); + *reinterpret_cast(wParam) = static_cast(SelectionStart().Position()); } if (lParam) { - *reinterpret_cast(lParam) = SelectionEnd().Position(); + *reinterpret_cast(lParam) = static_cast(SelectionEnd().Position()); } - return MAKELONG(SelectionStart().Position(), SelectionEnd().Position()); + return MAKELRESULT(SelectionStart().Position(), SelectionEnd().Position()); case EM_EXGETSEL: { if (lParam == 0) { return 0; } Sci_CharacterRange *pCR = reinterpret_cast(lParam); - pCR->cpMin = SelectionStart().Position(); - pCR->cpMax = SelectionEnd().Position(); + pCR->cpMin = static_cast(SelectionStart().Position()); + pCR->cpMax = static_cast(SelectionEnd().Position()); } break; case EM_SETSEL: { - int nStart = static_cast(wParam); - int nEnd = static_cast(lParam); + Sci::Position nStart = static_cast(wParam); + Sci::Position nEnd = lParam; if (nStart == 0 && nEnd == -1) { nEnd = pdoc->Length(); } if (nStart == -1) { nStart = nEnd; // Remove selection } - if (nStart > nEnd) { - SetSelection(nEnd, nStart); - } else { - SetSelection(nStart, nEnd); - } + SetSelection(nEnd, nStart); EnsureCaretVisible(); } break; @@ -1627,7 +1703,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam if (lParam == 0) { return 0; } - Sci_CharacterRange *pCR = reinterpret_cast(lParam); + const Sci_CharacterRange *pCR = reinterpret_cast(lParam); sel.selType = Selection::selStream; if (pCR->cpMin == 0 && pCR->cpMax == -1) { SetSelection(pCR->cpMin, pdoc->Length()); @@ -1657,12 +1733,13 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam #endif case SCI_SETTECHNOLOGY: - if ((wParam == SC_TECHNOLOGY_DEFAULT) || + if ((wParam == SC_TECHNOLOGY_DEFAULT) || (wParam == SC_TECHNOLOGY_DIRECTWRITERETAIN) || (wParam == SC_TECHNOLOGY_DIRECTWRITEDC) || (wParam == SC_TECHNOLOGY_DIRECTWRITE)) { - if (technology != static_cast(wParam)) { - if (static_cast(wParam) > SC_TECHNOLOGY_DEFAULT) { + const int technologyNew = static_cast(wParam); + if (technology != technologyNew) { + if (technologyNew > SC_TECHNOLOGY_DEFAULT) { #if defined(USE_D2D) if (!LoadD2D()) // Failed to load Direct2D or DirectWrite so no effect @@ -1674,7 +1751,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam #if defined(USE_D2D) DropRenderTarget(); #endif - technology = static_cast(wParam); + technology = technologyNew; // Invalidate all cached information including layout. DropGraphics(true); InvalidateStyleRedraw(); @@ -1684,16 +1761,16 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam #ifdef SCI_LEXER case SCI_LOADLEXERLIBRARY: - LexerManager::GetInstance()->Load(reinterpret_cast(lParam)); + LexerManager::GetInstance()->Load(ConstCharPtrFromSPtr(lParam)); break; #endif case SCI_TARGETASUTF8: - return TargetAsUTF8(reinterpret_cast(lParam)); + return TargetAsUTF8(CharPtrFromSPtr(lParam)); case SCI_ENCODEDFROMUTF8: - return EncodedFromUTF8(reinterpret_cast(wParam), - reinterpret_cast(lParam)); + return EncodedFromUTF8(ConstCharPtrFromUPtr(wParam), + CharPtrFromSPtr(lParam)); default: return ScintillaBase::WndProc(iMessage, wParam, lParam); @@ -1703,7 +1780,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam } catch (...) { errorStatus = SC_STATUS_FAILURE; } - return 0l; + return 0; } bool ScintillaWin::ValidCodePage(int codePage) const { @@ -1716,13 +1793,6 @@ sptr_t ScintillaWin::DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPa return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); } -/** -* Report that this Editor subclass has a working implementation of FineTickerStart. -*/ -bool ScintillaWin::FineTickerAvailable() { - return true; -} - bool ScintillaWin::FineTickerRunning(TickReason reason) { return timers[reason] != 0; } @@ -1730,9 +1800,9 @@ bool ScintillaWin::FineTickerRunning(TickReason reason) { void ScintillaWin::FineTickerStart(TickReason reason, int millis, int tolerance) { FineTickerCancel(reason); if (SetCoalescableTimerFn && tolerance) { - timers[reason] = SetCoalescableTimerFn(MainHWND(), fineTimerStart + reason, millis, NULL, tolerance); + timers[reason] = SetCoalescableTimerFn(MainHWND(), fineTimerStart + reason, millis, nullptr, tolerance); } else { - timers[reason] = ::SetTimer(MainHWND(), fineTimerStart + reason, millis, NULL); + timers[reason] = ::SetTimer(MainHWND(), fineTimerStart + reason, millis, nullptr); } } @@ -1750,7 +1820,7 @@ bool ScintillaWin::SetIdle(bool on) { // and are only posted when the message queue is empty, i.e. during idle time. if (idler.state != on) { if (on) { - idler.idlerID = ::SetTimer(MainHWND(), idleTimerID, 10, NULL) + idler.idlerID = ::SetTimer(MainHWND(), idleTimerID, 10, nullptr) ? reinterpret_cast(idleTimerID) : 0; } else { ::KillTimer(MainHWND(), reinterpret_cast(idler.idlerID)); @@ -1761,6 +1831,20 @@ bool ScintillaWin::SetIdle(bool on) { return idler.state; } +void ScintillaWin::IdleWork() { + styleIdleInQueue = false; + Editor::IdleWork(); +} + +void ScintillaWin::QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) { + Editor::QueueIdleWork(items, upTo); + if (!styleIdleInQueue) { + if (PostMessage(MainHWND(), SC_WORK_IDLE, 0, 0)) { + styleIdleInQueue = true; + } + } +} + void ScintillaWin::SetMouseCapture(bool on) { if (mouseDownCaptures) { if (on) { @@ -1778,14 +1862,14 @@ bool ScintillaWin::HaveMouseCapture() { //return capturedMouse && (::GetCapture() == MainHWND()); } -void ScintillaWin::SetTrackMouseLeaveEvent(bool on) { - if (on && TrackMouseEventFn && !trackedMouseLeave) { +void ScintillaWin::SetTrackMouseLeaveEvent(bool on) noexcept { + if (on && !trackedMouseLeave) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof(tme); tme.dwFlags = TME_LEAVE; tme.hwndTrack = MainHWND(); tme.dwHoverTime = HOVER_DEFAULT; // Unused but triggers Dr. Memory if not initialized - TrackMouseEventFn(&tme); + TrackMouseEvent(&tme); } trackedMouseLeave = on; } @@ -1797,7 +1881,7 @@ bool ScintillaWin::PaintContains(PRectangle rc) { return true; } -void ScintillaWin::ScrollText(int /* linesToMove */) { +void ScintillaWin::ScrollText(Sci::Line /* linesToMove */) { //Platform::DebugPrintf("ScintillaWin::ScrollText %d\n", linesToMove); //::ScrollWindow(MainHWND(), 0, // vs.lineHeight * linesToMove, 0, 0); @@ -1806,27 +1890,31 @@ void ScintillaWin::ScrollText(int /* linesToMove */) { UpdateSystemCaret(); } +void ScintillaWin::NotifyCaretMove() { + NotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, MainHWND(), OBJID_CARET, CHILDID_SELF); +} + void ScintillaWin::UpdateSystemCaret() { if (hasFocus) { if (HasCaretSizeChanged()) { DestroySystemCaret(); CreateSystemCaret(); } - Point pos = PointMainCaret(); + const Point pos = PointMainCaret(); ::SetCaretPos(static_cast(pos.x), static_cast(pos.y)); } } -int ScintillaWin::SetScrollInfo(int nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) { +int ScintillaWin::SetScrollInfo(int nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) noexcept { return ::SetScrollInfo(MainHWND(), nBar, lpsi, bRedraw); } -bool ScintillaWin::GetScrollInfo(int nBar, LPSCROLLINFO lpsi) { +bool ScintillaWin::GetScrollInfo(int nBar, LPSCROLLINFO lpsi) noexcept { return ::GetScrollInfo(MainHWND(), nBar, lpsi) ? true : false; } // Change the scroll position but avoid repaint if changing to same value -void ScintillaWin::ChangeScrollPos(int barType, int pos) { +void ScintillaWin::ChangeScrollPos(int barType, Sci::Position pos) { SCROLLINFO sci = { sizeof(sci), 0, 0, 0, 0, 0, 0 }; @@ -1834,7 +1922,7 @@ void ScintillaWin::ChangeScrollPos(int barType, int pos) { GetScrollInfo(barType, &sci); if (sci.nPos != pos) { DwellEnd(true); - sci.nPos = pos; + sci.nPos = static_cast(pos); SetScrollInfo(barType, &sci, TRUE); } } @@ -1847,14 +1935,14 @@ void ScintillaWin::SetHorizontalScrollPos() { ChangeScrollPos(SB_HORZ, xOffset); } -bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) { +bool ScintillaWin::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) { bool modified = false; SCROLLINFO sci = { sizeof(sci), 0, 0, 0, 0, 0, 0 }; sci.fMask = SIF_PAGE | SIF_RANGE; GetScrollInfo(SB_VERT, &sci); - int vertEndPreferred = nMax; + const Sci::Line vertEndPreferred = nMax; if (!verticalScrollBarVisible) nPage = vertEndPreferred + 1; if ((sci.nMin != 0) || @@ -1863,26 +1951,26 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) { (sci.nPos != 0)) { sci.fMask = SIF_PAGE | SIF_RANGE; sci.nMin = 0; - sci.nMax = vertEndPreferred; - sci.nPage = nPage; + sci.nMax = static_cast(vertEndPreferred); + sci.nPage = static_cast(nPage); sci.nPos = 0; sci.nTrackPos = 1; SetScrollInfo(SB_VERT, &sci, TRUE); modified = true; } - PRectangle rcText = GetTextRectangle(); + const PRectangle rcText = GetTextRectangle(); int horizEndPreferred = scrollWidth; if (horizEndPreferred < 0) horizEndPreferred = 0; - unsigned int pageWidth = static_cast(rcText.Width()); + int pageWidth = static_cast(rcText.Width()); if (!horizontalScrollBarVisible || Wrapping()) pageWidth = horizEndPreferred + 1; sci.fMask = SIF_PAGE | SIF_RANGE; GetScrollInfo(SB_HORZ, &sci); if ((sci.nMin != 0) || (sci.nMax != horizEndPreferred) || - (sci.nPage != pageWidth) || + (sci.nPage != static_cast(pageWidth)) || (sci.nPos != 0)) { sci.fMask = SIF_PAGE | SIF_RANGE; sci.nMin = 0; @@ -1892,7 +1980,7 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) { sci.nTrackPos = 1; SetScrollInfo(SB_HORZ, &sci, TRUE); modified = true; - if (scrollWidth < static_cast(pageWidth)) { + if (scrollWidth < pageWidth) { HorizontalScrollTo(0); } } @@ -1901,23 +1989,25 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) { void ScintillaWin::NotifyChange() { ::SendMessage(::GetParent(MainHWND()), WM_COMMAND, - MAKELONG(GetCtrlID(), SCEN_CHANGE), + MAKEWPARAM(GetCtrlID(), SCEN_CHANGE), reinterpret_cast(MainHWND())); } void ScintillaWin::NotifyFocus(bool focus) { - ::SendMessage(::GetParent(MainHWND()), WM_COMMAND, - MAKELONG(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), - reinterpret_cast(MainHWND())); + if (commandEvents) { + ::SendMessage(::GetParent(MainHWND()), WM_COMMAND, + MAKEWPARAM(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), + reinterpret_cast(MainHWND())); + } Editor::NotifyFocus(focus); } void ScintillaWin::SetCtrlID(int identifier) { - ::SetWindowID(reinterpret_cast(wMain.GetID()), identifier); + ::SetWindowID(static_cast(wMain.GetID()), identifier); } int ScintillaWin::GetCtrlID() { - return ::GetDlgCtrlID(reinterpret_cast(wMain.GetID())); + return ::GetDlgCtrlID(static_cast(wMain.GetID())); } void ScintillaWin::NotifyParent(SCNotification scn) { @@ -1947,7 +2037,7 @@ public: explicit CaseFolderDBCS(UINT cp_) : cp(cp_) { StandardASCII(); } - virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) { + size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override { if ((lenMixed == 1) && (sizeFolded > 0)) { folded[0] = mapping[static_cast(mixed[0])]; return 1; @@ -1955,7 +2045,7 @@ public: if (lenMixed > utf16Mixed.size()) { utf16Mixed.resize(lenMixed + 8); } - size_t nUtf16Mixed = ::MultiByteToWideChar(cp, 0, mixed, + const size_t nUtf16Mixed = ::MultiByteToWideChar(cp, 0, mixed, static_cast(lenMixed), &utf16Mixed[0], static_cast(utf16Mixed.size())); @@ -1966,7 +2056,7 @@ public: return 1; } - unsigned int lenFlat = 0; + size_t lenFlat = 0; for (size_t mixIndex=0; mixIndex < nUtf16Mixed; mixIndex++) { if ((lenFlat + 20) > utf16Folded.size()) utf16Folded.resize(lenFlat + 60); @@ -1974,7 +2064,7 @@ public: if (foldedUTF8) { // Maximum length of a case conversion is 6 bytes, 3 characters wchar_t wFolded[20]; - size_t charsConverted = UTF16FromUTF8(foldedUTF8, + const size_t charsConverted = UTF16FromUTF8(foldedUTF8, strlen(foldedUTF8), wFolded, ELEMENTS(wFolded)); for (size_t j=0; jStandardASCII(); // Only for single byte encodings - UINT cpDoc = CodePageOfDocument(); for (int i=0x80; i<0x100; i++) { char sCharacter[2] = "A"; sCharacter[0] = static_cast(i); wchar_t wCharacter[20]; - unsigned int lengthUTF16 = ::MultiByteToWideChar(cpDoc, 0, sCharacter, 1, + const unsigned int lengthUTF16 = ::MultiByteToWideChar(cpDest, 0, sCharacter, 1, wCharacter, ELEMENTS(wCharacter)); if (lengthUTF16 == 1) { const char *caseFolded = CaseConvert(wCharacter[0], CaseConversionFold); if (caseFolded) { wchar_t wLower[20]; - size_t charsConverted = UTF16FromUTF8(caseFolded, + const size_t charsConverted = UTF16FromUTF8(caseFolded, strlen(caseFolded), wLower, ELEMENTS(wLower)); if (charsConverted == 1) { char sCharacterLowered[20]; - unsigned int lengthConverted = ::WideCharToMultiByte(cpDoc, 0, + const unsigned int lengthConverted = ::WideCharToMultiByte(cpDest, 0, wLower, static_cast(charsConverted), sCharacterLowered, ELEMENTS(sCharacterLowered), NULL, 0); if ((lengthConverted == 1) && (sCharacter[0] != sCharacterLowered[0])) { @@ -2046,44 +2135,24 @@ std::string ScintillaWin::CaseMapString(const std::string &s, int caseMapping) { if ((s.size() == 0) || (caseMapping == cmSame)) return s; - UINT cpDoc = CodePageOfDocument(); + const UINT cpDoc = CodePageOfDocument(); if (cpDoc == SC_CP_UTF8) { - std::string retMapped(s.length() * maxExpansionCaseConversion, 0); - size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(), - (caseMapping == cmUpper) ? CaseConversionUpper : CaseConversionLower); - retMapped.resize(lenMapped); - return retMapped; + return CaseConvertString(s, (caseMapping == cmUpper) ? CaseConversionUpper : CaseConversionLower); } - unsigned int lengthUTF16 = ::MultiByteToWideChar(cpDoc, 0, s.c_str(), - static_cast(s.size()), NULL, 0); - if (lengthUTF16 == 0) // Failed to convert - return s; + // Change text to UTF-16 + const std::wstring wsText = StringDecode(s, cpDoc); - DWORD mapFlags = LCMAP_LINGUISTIC_CASING | + const DWORD mapFlags = LCMAP_LINGUISTIC_CASING | ((caseMapping == cmUpper) ? LCMAP_UPPERCASE : LCMAP_LOWERCASE); - // Change text to UTF-16 - std::vector vwcText(lengthUTF16); - ::MultiByteToWideChar(cpDoc, 0, s.c_str(), static_cast(s.size()), &vwcText[0], lengthUTF16); - // Change case - int charsConverted = ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags, - &vwcText[0], lengthUTF16, NULL, 0); - std::vector vwcConverted(charsConverted); - ::LCMapStringW(LOCALE_SYSTEM_DEFAULT, mapFlags, - &vwcText[0], lengthUTF16, &vwcConverted[0], charsConverted); + const std::wstring wsConverted = StringMapCase(wsText, mapFlags); // Change back to document encoding - unsigned int lengthConverted = ::WideCharToMultiByte(cpDoc, 0, - &vwcConverted[0], static_cast(vwcConverted.size()), - NULL, 0, NULL, 0); - std::vector vcConverted(lengthConverted); - ::WideCharToMultiByte(cpDoc, 0, - &vwcConverted[0], static_cast(vwcConverted.size()), - &vcConverted[0], static_cast(vcConverted.size()), NULL, 0); + std::string sConverted = StringEncode(wsConverted, cpDoc); - return std::string(&vcConverted[0], vcConverted.size()); + return sConverted; } void ScintillaWin::Copy() { @@ -2111,52 +2180,77 @@ bool ScintillaWin::CanPaste() { return false; } +namespace { + class GlobalMemory { - HGLOBAL hand; + HGLOBAL hand {}; public: - void *ptr; - GlobalMemory() : hand(0), ptr(0) { + void *ptr {}; + GlobalMemory() noexcept { } - explicit GlobalMemory(HGLOBAL hand_) : hand(hand_), ptr(0) { + explicit GlobalMemory(HGLOBAL hand_) noexcept : hand(hand_) { if (hand) { ptr = ::GlobalLock(hand); } } + // Deleted so GlobalMemory objects can not be copied. + GlobalMemory(const GlobalMemory &) = delete; + GlobalMemory(GlobalMemory &&) = delete; + GlobalMemory &operator=(const GlobalMemory &) = delete; + GlobalMemory &operator=(GlobalMemory &&) = delete; ~GlobalMemory() { - PLATFORM_ASSERT(!ptr); + assert(!ptr); assert(!hand); } - void Allocate(size_t bytes) { + void Allocate(size_t bytes) noexcept { assert(!hand); hand = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, bytes); if (hand) { ptr = ::GlobalLock(hand); } } - HGLOBAL Unlock() { - PLATFORM_ASSERT(ptr); + HGLOBAL Unlock() noexcept { + assert(ptr); HGLOBAL handCopy = hand; ::GlobalUnlock(hand); - ptr = 0; - hand = 0; + ptr = nullptr; + hand = {}; return handCopy; } - void SetClip(UINT uFormat) { + void SetClip(UINT uFormat) noexcept { ::SetClipboardData(uFormat, Unlock()); } - operator bool() const { - return ptr != 0; + operator bool() const noexcept { + return ptr != nullptr; } - SIZE_T Size() { + SIZE_T Size() const noexcept { return ::GlobalSize(hand); } }; +// OpenClipboard may fail if another application has opened the clipboard. +// Try up to 8 times, with an initial delay of 1 ms and an exponential back off +// for a maximum total delay of 127 ms (1+2+4+8+16+32+64). +bool OpenClipboardRetry(HWND hwnd) noexcept { + for (int attempt=0; attempt<8; attempt++) { + if (attempt > 0) { + ::Sleep(1 << (attempt-1)); + } + if (::OpenClipboard(hwnd)) { + return true; + } + } + return false; +} + +} + void ScintillaWin::Paste() { - if (!::OpenClipboard(MainHWND())) + if (!::OpenClipboardRetry(MainHWND())) { return; + } UndoGroup ug(pdoc); - const bool isLine = SelectionEmpty() && + const bool isLine = SelectionEmpty() && (::IsClipboardFormatAvailable(cfLineSelect) || ::IsClipboardFormatAvailable(cfVSLineTag)); ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH); bool isRectangular = (::IsClipboardFormatAvailable(cfColumnSelect) != 0); @@ -2174,25 +2268,25 @@ void ScintillaWin::Paste() { // Always use CF_UNICODETEXT if available GlobalMemory memUSelection(::GetClipboardData(CF_UNICODETEXT)); if (memUSelection) { - wchar_t *uptr = static_cast(memUSelection.ptr); + const wchar_t *uptr = static_cast(memUSelection.ptr); if (uptr) { - unsigned int len; + size_t len; std::vector putf; // Default Scintilla behaviour in Unicode mode if (IsUnicodeMode()) { - unsigned int bytes = static_cast(memUSelection.Size()); + const size_t bytes = memUSelection.Size(); len = UTF8Length(uptr, bytes / 2); putf.resize(len + 1); UTF8FromUTF16(uptr, bytes / 2, &putf[0], len); } else { // CF_UNICODETEXT available, but not in Unicode mode // Convert from Unicode to current Scintilla code page - UINT cpDest = CodePageOfDocument(); + const UINT cpDest = CodePageOfDocument(); len = ::WideCharToMultiByte(cpDest, 0, uptr, -1, NULL, 0, NULL, NULL) - 1; // subtract 0 terminator putf.resize(len + 1); ::WideCharToMultiByte(cpDest, 0, uptr, -1, - &putf[0], len + 1, NULL, NULL); + &putf[0], static_cast(len) + 1, NULL, NULL); } InsertPasteShape(&putf[0], len, pasteShape); @@ -2202,11 +2296,11 @@ void ScintillaWin::Paste() { // CF_UNICODETEXT not available, paste ANSI text GlobalMemory memSelection(::GetClipboardData(CF_TEXT)); if (memSelection) { - char *ptr = static_cast(memSelection.ptr); + const char *ptr = static_cast(memSelection.ptr); if (ptr) { - unsigned int bytes = static_cast(memSelection.Size()); - unsigned int len = bytes; - for (unsigned int i = 0; i < bytes; i++) { + const size_t bytes = memSelection.Size(); + size_t len = bytes; + for (size_t i = 0; i < bytes; i++) { if ((len == bytes) && (0 == ptr[i])) len = i; } @@ -2215,10 +2309,11 @@ void ScintillaWin::Paste() { if (IsUnicodeMode()) { std::vector uptr(len+1); - unsigned int ulen = ::MultiByteToWideChar(CP_ACP, 0, - ptr, len, &uptr[0], len+1); + const int ilen = static_cast(len); + const size_t ulen = ::MultiByteToWideChar(CP_ACP, 0, + ptr, ilen, &uptr[0], ilen +1); - unsigned int mlen = UTF8Length(&uptr[0], ulen); + const size_t mlen = UTF8Length(&uptr[0], ulen); std::vector putf(mlen+1); UTF8FromUTF16(&uptr[0], ulen, &putf[0], mlen); @@ -2236,17 +2331,18 @@ void ScintillaWin::Paste() { void ScintillaWin::CreateCallTipWindow(PRectangle) { if (!ct.wCallTip.Created()) { - ct.wCallTip = ::CreateWindow(callClassName, TEXT("ACallTip"), + HWND wnd = ::CreateWindow(callClassName, TEXT("ACallTip"), WS_POPUP, 100, 100, 150, 20, MainHWND(), 0, GetWindowInstance(MainHWND()), this); - ct.wDraw = ct.wCallTip; + ct.wCallTip = wnd; + ct.wDraw = wnd; } } void ScintillaWin::AddToPopUp(const char *label, int cmd, bool enabled) { - HMENU hmenuPopup = reinterpret_cast(popup.GetID()); + HMENU hmenuPopup = static_cast(popup.GetID()); if (!label[0]) ::AppendMenuA(hmenuPopup, MF_SEPARATOR, 0, ""); else if (enabled) @@ -2264,7 +2360,7 @@ void ScintillaWin::ClaimSelection() { STDMETHODIMP_(ULONG)FormatEnumerator_AddRef(FormatEnumerator *fe); STDMETHODIMP FormatEnumerator_QueryInterface(FormatEnumerator *fe, REFIID riid, PVOID *ppv) { //Platform::DebugPrintf("EFE QI"); - *ppv = NULL; + *ppv = nullptr; if (riid == IID_IUnknown) *ppv = reinterpret_cast(fe); if (riid == IID_IEnumFORMATETC) @@ -2286,11 +2382,11 @@ STDMETHODIMP_(ULONG)FormatEnumerator_Release(FormatEnumerator *fe) { } /// Implement IEnumFORMATETC STDMETHODIMP FormatEnumerator_Next(FormatEnumerator *fe, ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched) { - if (rgelt == NULL) return E_POINTER; + if (!rgelt) return E_POINTER; unsigned int putPos = 0; while ((fe->pos < fe->formats.size()) && (putPos < celt)) { rgelt->cfFormat = fe->formats[fe->pos]; - rgelt->ptd = 0; + rgelt->ptd = nullptr; rgelt->dwAspect = DVASPECT_CONTENT; rgelt->lindex = -1; rgelt->tymed = TYMED_HGLOBAL; @@ -2370,9 +2466,9 @@ static VFunction *vtDropSource[] = { (VFunction *)(DropSource_GiveFeedback) }; -DropSource::DropSource() { +DropSource::DropSource() noexcept { vtbl = vtDropSource; - sci = 0; + sci = nullptr; } /// Implement IUnkown @@ -2398,7 +2494,7 @@ STDMETHODIMP DataObject_GetDataHere(DataObject *, FORMATETC *, STGMEDIUM *) { STDMETHODIMP DataObject_QueryGetData(DataObject *pd, FORMATETC *pFE) { if (pd->sci->DragIsRectangularOK(pFE->cfFormat) && - pFE->ptd == 0 && + pFE->ptd == nullptr && (pFE->dwAspect & DVASPECT_CONTENT) != 0 && pFE->lindex == -1 && (pFE->tymed & TYMED_HGLOBAL) != 0 @@ -2406,10 +2502,10 @@ STDMETHODIMP DataObject_QueryGetData(DataObject *pd, FORMATETC *pFE) { return S_OK; } - bool formatOK = (pFE->cfFormat == CF_TEXT) || + const bool formatOK = (pFE->cfFormat == CF_TEXT) || ((pFE->cfFormat == CF_UNICODETEXT) && pd->sci->IsUnicodeMode()); if (!formatOK || - pFE->ptd != 0 || + pFE->ptd != nullptr || (pFE->dwAspect & DVASPECT_CONTENT) == 0 || pFE->lindex != -1 || (pFE->tymed & TYMED_HGLOBAL) == 0 @@ -2428,7 +2524,7 @@ STDMETHODIMP DataObject_GetCanonicalFormatEtc(DataObject *pd, FORMATETC *, FORMA pFEOut->cfFormat = CF_UNICODETEXT; else pFEOut->cfFormat = CF_TEXT; - pFEOut->ptd = 0; + pFEOut->ptd = nullptr; pFEOut->dwAspect = DVASPECT_CONTENT; pFEOut->lindex = -1; pFEOut->tymed = TYMED_HGLOBAL; @@ -2444,7 +2540,7 @@ STDMETHODIMP DataObject_EnumFormatEtc(DataObject *pd, DWORD dwDirection, IEnumFO try { //Platform::DebugPrintf("DOB EnumFormatEtc %d\n", dwDirection); if (dwDirection != DATADIR_GET) { - *ppEnum = 0; + *ppEnum = nullptr; return E_FAIL; } FormatEnumerator *pfe; @@ -2496,9 +2592,9 @@ static VFunction *vtDataObject[] = { (VFunction *)(DataObject_EnumDAdvise) }; -DataObject::DataObject() { +DataObject::DataObject() noexcept { vtbl = vtDataObject; - sci = 0; + sci = nullptr; } /// Implement IUnknown @@ -2559,9 +2655,9 @@ static VFunction *vtDropTarget[] = { (VFunction *)(DropTarget_Drop) }; -DropTarget::DropTarget() { +DropTarget::DropTarget() noexcept { vtbl = vtDropTarget; - sci = 0; + sci = nullptr; } /** @@ -2571,20 +2667,19 @@ DropTarget::DropTarget() { void ScintillaWin::ImeStartComposition() { if (caret.active) { // Move IME Window to current caret position - HIMC hIMC = ::ImmGetContext(MainHWND()); - Point pos = PointMainCaret(); + IMContext imc(MainHWND()); + const Point pos = PointMainCaret(); COMPOSITIONFORM CompForm; CompForm.dwStyle = CFS_POINT; - CompForm.ptCurrentPos.x = static_cast(pos.x); - CompForm.ptCurrentPos.y = static_cast(pos.y); + CompForm.ptCurrentPos = POINTFromPoint(pos); - ::ImmSetCompositionWindow(hIMC, &CompForm); + ::ImmSetCompositionWindow(imc.hIMC, &CompForm); // Set font of IME window to same as surrounded text. if (stylesValid) { // Since the style creation code has been made platform independent, // The logfont for the IME is recreated here. - int styleHere = (pdoc->StyleAt(sel.MainCaret())) & 31; + const int styleHere = pdoc->StyleIndexAt(sel.MainCaret()); LOGFONTW lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L""}; int sizeZoomed = vs.styles[styleHere].size + vs.zoomLevel * SC_FONT_SIZE_MULTIPLIER; if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1 @@ -2595,7 +2690,7 @@ void ScintillaWin::ImeStartComposition() { deviceHeight = (sizeZoomed * surface->LogPixelsY()) / 72; } // The negative is to allow for leading - lf.lfHeight = -(abs(deviceHeight / SC_FONT_SIZE_MULTIPLIER)); + lf.lfHeight = -(std::abs(deviceHeight / SC_FONT_SIZE_MULTIPLIER)); lf.lfWeight = vs.styles[styleHere].weight; lf.lfItalic = static_cast(vs.styles[styleHere].italic ? 1 : 0); lf.lfCharSet = DEFAULT_CHARSET; @@ -2605,9 +2700,8 @@ void ScintillaWin::ImeStartComposition() { UTF16FromUTF8(fontName, strlen(fontName)+1, lf.lfFaceName, LF_FACESIZE); } - ::ImmSetCompositionFontW(hIMC, &lf); + ::ImmSetCompositionFontW(imc.hIMC, &lf); } - ::ImmReleaseContext(MainHWND(), hIMC); // Caret is displayed in IME window. So, caret in Scintilla is useless. DropCaret(); } @@ -2618,22 +2712,105 @@ void ScintillaWin::ImeEndComposition() { ShowCaretAtCurrentPosition(); } -void ScintillaWin::GetIntelliMouseParameters() { +LRESULT ScintillaWin::ImeOnReconvert(LPARAM lParam) { + // Reconversion on windows limits within one line without eol. + // Look around: baseStart <-- (|mainStart| -- mainEnd) --> baseEnd. + const Sci::Position mainStart = sel.RangeMain().Start().Position(); + const Sci::Position mainEnd = sel.RangeMain().End().Position(); + const Sci::Line curLine = pdoc->SciLineFromPosition(mainStart); + if (curLine != pdoc->LineFromPosition(mainEnd)) + return 0; + const Sci::Position baseStart = pdoc->LineStart(curLine); + const Sci::Position baseEnd = pdoc->LineEnd(curLine); + if ((baseStart == baseEnd) || (mainEnd > baseEnd)) + return 0; + + const int codePage = CodePageOfDocument(); + const std::wstring rcFeed = StringDecode(RangeText(baseStart, baseEnd), codePage); + const int rcFeedLen = static_cast(rcFeed.length()) * sizeof(wchar_t); + const int rcSize = sizeof(RECONVERTSTRING) + rcFeedLen + sizeof(wchar_t); + + RECONVERTSTRING *rc = static_cast(PtrFromSPtr(lParam)); + if (!rc) + return rcSize; // Immediately be back with rcSize of memory block. + + wchar_t *rcFeedStart = reinterpret_cast(rc + 1); + memcpy(rcFeedStart, &rcFeed[0], rcFeedLen); + + std::string rcCompString = RangeText(mainStart, mainEnd); + std::wstring rcCompWstring = StringDecode(rcCompString, codePage); + std::string rcCompStart = RangeText(baseStart, mainStart); + std::wstring rcCompWstart = StringDecode(rcCompStart, codePage); + + // Map selection to dwCompStr. + // No selection assumes current caret as rcCompString without length. + rc->dwVersion = 0; // It should be absolutely 0. + rc->dwStrLen = static_cast(rcFeed.length()); + rc->dwStrOffset = sizeof(RECONVERTSTRING); + rc->dwCompStrLen = static_cast(rcCompWstring.length()); + rc->dwCompStrOffset = static_cast(rcCompWstart.length()) * sizeof(wchar_t); + rc->dwTargetStrLen = rc->dwCompStrLen; + rc->dwTargetStrOffset =rc->dwCompStrOffset; + + IMContext imc(MainHWND()); + if (!imc.hIMC) + return 0; + + if (!::ImmSetCompositionStringW(imc.hIMC, SCS_QUERYRECONVERTSTRING, rc, rcSize, nullptr, 0)) + return 0; + + // No selection asks IME to fill target fields with its own value. + const int tgWlen = rc->dwTargetStrLen; + const int tgWstart = rc->dwTargetStrOffset / sizeof(wchar_t); + + std::string tgCompStart = StringEncode(rcFeed.substr(0, tgWstart), codePage); + std::string tgComp = StringEncode(rcFeed.substr(tgWstart, tgWlen), codePage); + + // No selection needs to adjust reconvert start position for IME set. + const int adjust = static_cast(tgCompStart.length() - rcCompStart.length()); + const int docCompLen = static_cast(tgComp.length()); + + // Make place for next composition string to sit in. + for (size_t r=0; rLineEnd(pdoc->LineFromPosition(rBase)); + const Sci::Position overflow = (docCompStart + docCompLen) - lineEnd; + if (overflow > 0) { + pdoc->DeleteChars(docCompStart, docCompLen - overflow); + } else { + pdoc->DeleteChars(docCompStart, docCompLen); + } + } + } + // Immediately Target Input or candidate box choice with GCS_COMPSTR. + return rcSize; +} + +void ScintillaWin::GetIntelliMouseParameters() noexcept { // This retrieves the number of lines per scroll as configured inthe Mouse Properties sheet in Control Panel ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &linesPerScroll, 0); } void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) { - if (!::OpenClipboard(MainHWND())) + if (!::OpenClipboardRetry(MainHWND())) { return; + } ::EmptyClipboard(); GlobalMemory uniText; // Default Scintilla behaviour in Unicode mode if (IsUnicodeMode()) { - size_t uchars = UTF16Length(selectedText.Data(), - static_cast(selectedText.LengthWithTerminator())); + const size_t uchars = UTF16Length(selectedText.Data(), + selectedText.LengthWithTerminator()); uniText.Allocate(2 * uchars); if (uniText) { UTF16FromUTF8(selectedText.Data(), selectedText.LengthWithTerminator(), @@ -2642,9 +2819,9 @@ void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) { } else { // Not Unicode mode // Convert to Unicode using the current Scintilla code page - UINT cpSrc = CodePageFromCharSet( + const UINT cpSrc = CodePageFromCharSet( selectedText.characterSet, selectedText.codePage); - int uLen = ::MultiByteToWideChar(cpSrc, 0, selectedText.Data(), + const int uLen = ::MultiByteToWideChar(cpSrc, 0, selectedText.Data(), static_cast(selectedText.LengthWithTerminator()), 0, 0); uniText.Allocate(2 * uLen); if (uniText) { @@ -2661,7 +2838,7 @@ void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) { GlobalMemory ansiText; ansiText.Allocate(selectedText.LengthWithTerminator()); if (ansiText) { - memcpy(static_cast(ansiText.ptr), selectedText.Data(), selectedText.LengthWithTerminator()); + memcpy(ansiText.ptr, selectedText.Data(), selectedText.LengthWithTerminator()); ansiText.SetClip(CF_TEXT); } } @@ -2697,9 +2874,8 @@ void ScintillaWin::ScrollMessage(WPARAM wParam) { //Platform::DebugPrintf("ScrollInfo %d mask=%x min=%d max=%d page=%d pos=%d track=%d\n", b,sci.fMask, //sci.nMin, sci.nMax, sci.nPage, sci.nPos, sci.nTrackPos); - - int topLineNew = topLine; - switch (LoWord(wParam)) { + Sci::Line topLineNew = topLine; + switch (LOWORD(wParam)) { case SB_LINEUP: topLineNew -= 1; break; @@ -2719,9 +2895,9 @@ void ScintillaWin::ScrollMessage(WPARAM wParam) { void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) { int xPos = xOffset; - PRectangle rcText = GetTextRectangle(); - int pageWidth = static_cast(rcText.Width() * 2 / 3); - switch (LoWord(wParam)) { + const PRectangle rcText = GetTextRectangle(); + const int pageWidth = static_cast(rcText.Width() * 2 / 3); + switch (LOWORD(wParam)) { case SB_LINEUP: xPos -= 20; break; @@ -2794,8 +2970,8 @@ void ScintillaWin::FullPaintDC(HDC hdc) { pRenderTarget->BeginDraw(); Paint(surfaceWindow, rcPaint); surfaceWindow->Release(); - HRESULT hr = pRenderTarget->EndDraw(); - if (hr == D2DERR_RECREATE_TARGET) { + const HRESULT hr = pRenderTarget->EndDraw(); + if (hr == static_cast(D2DERR_RECREATE_TARGET)) { DropRenderTarget(); } } @@ -2804,13 +2980,17 @@ void ScintillaWin::FullPaintDC(HDC hdc) { paintState = notPainting; } -static bool CompareDevCap(HDC hdc, HDC hOtherDC, int nIndex) { +namespace { + +bool CompareDevCap(HDC hdc, HDC hOtherDC, int nIndex) noexcept { return ::GetDeviceCaps(hdc, nIndex) == ::GetDeviceCaps(hOtherDC, nIndex); } -bool ScintillaWin::IsCompatibleDC(HDC hOtherDC) { +} + +bool ScintillaWin::IsCompatibleDC(HDC hOtherDC) noexcept { HDC hdc = ::GetDC(MainHWND()); - bool isCompatible = + const bool isCompatible = CompareDevCap(hdc, hOtherDC, TECHNOLOGY) && CompareDevCap(hdc, hOtherDC, LOGPIXELSY) && CompareDevCap(hdc, hOtherDC, LOGPIXELSX) && @@ -2820,7 +3000,7 @@ bool ScintillaWin::IsCompatibleDC(HDC hOtherDC) { return isCompatible; } -DWORD ScintillaWin::EffectFromState(DWORD grfKeyState) const { +DWORD ScintillaWin::EffectFromState(DWORD grfKeyState) const noexcept { // These are the Wordpad semantics. DWORD dwEffect; if (inDragDrop == ddDragging) // Internal defaults to move @@ -2836,7 +3016,7 @@ DWORD ScintillaWin::EffectFromState(DWORD grfKeyState) const { /// Implement IUnknown STDMETHODIMP ScintillaWin::QueryInterface(REFIID riid, PVOID *ppv) { - *ppv = NULL; + *ppv = nullptr; if (riid == IID_IUnknown) *ppv = reinterpret_cast(&dt); if (riid == IID_IDropSource) @@ -2861,14 +3041,14 @@ STDMETHODIMP_(ULONG) ScintillaWin::Release() { /// Implement IDropTarget STDMETHODIMP ScintillaWin::DragEnter(LPDATAOBJECT pIDataSource, DWORD grfKeyState, POINTL, PDWORD pdwEffect) { - if (pIDataSource == NULL) + if (!pIDataSource ) return E_POINTER; - FORMATETC fmtu = {CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - HRESULT hrHasUText = pIDataSource->QueryGetData(&fmtu); + FORMATETC fmtu = {CF_UNICODETEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + const HRESULT hrHasUText = pIDataSource->QueryGetData(&fmtu); hasOKText = (hrHasUText == S_OK); if (!hasOKText) { - FORMATETC fmte = {CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - HRESULT hrHasText = pIDataSource->QueryGetData(&fmte); + FORMATETC fmte = {CF_TEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + const HRESULT hrHasText = pIDataSource->QueryGetData(&fmte); hasOKText = (hrHasText == S_OK); } if (!hasOKText) { @@ -2903,7 +3083,7 @@ STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffe STDMETHODIMP ScintillaWin::DragLeave() { try { - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); return S_OK; } catch (...) { errorStatus = SC_STATUS_FAILURE; @@ -2916,25 +3096,25 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, try { *pdwEffect = EffectFromState(grfKeyState); - if (pIDataSource == NULL) + if (!pIDataSource) return E_POINTER; - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); - STGMEDIUM medium = {0, {0}, 0}; + STGMEDIUM medium {}; std::vector data; // Includes terminating NUL - FORMATETC fmtu = {CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + FORMATETC fmtu = {CF_UNICODETEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; HRESULT hr = pIDataSource->GetData(&fmtu, &medium); if (SUCCEEDED(hr) && medium.hGlobal) { GlobalMemory memUDrop(medium.hGlobal); - wchar_t *udata = static_cast(memUDrop.ptr); + const wchar_t *udata = static_cast(memUDrop.ptr); if (udata) { if (IsUnicodeMode()) { - int tlen = static_cast(memUDrop.Size()); + const size_t tlen = memUDrop.Size(); // Convert UTF-16 to UTF-8 - int dataLen = UTF8Length(udata, tlen/2); + const size_t dataLen = UTF8Length(udata, tlen/2); data.resize(dataLen+1); UTF8FromUTF16(udata, tlen/2, &data[0], dataLen); } else { @@ -2943,8 +3123,8 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, // Default Scintilla behavior in Unicode mode // CF_UNICODETEXT available, but not in Unicode mode // Convert from Unicode to current Scintilla code page - UINT cpDest = CodePageOfDocument(); - int tlen = ::WideCharToMultiByte(cpDest, 0, udata, -1, + const UINT cpDest = CodePageOfDocument(); + const int tlen = ::WideCharToMultiByte(cpDest, 0, udata, -1, NULL, 0, NULL, NULL) - 1; // subtract 0 terminator data.resize(tlen + 1); ::WideCharToMultiByte(cpDest, 0, udata, -1, @@ -2953,11 +3133,11 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, } memUDrop.Unlock(); } else { - FORMATETC fmte = {CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + FORMATETC fmte = {CF_TEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; hr = pIDataSource->GetData(&fmte, &medium); if (SUCCEEDED(hr) && medium.hGlobal) { GlobalMemory memDrop(medium.hGlobal); - const char *cdata = static_cast(memDrop.ptr); + const char *cdata = static_cast(memDrop.ptr); if (cdata) data.assign(cdata, cdata+strlen(cdata)+1); memDrop.Unlock(); @@ -2969,17 +3149,17 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, return hr; } - FORMATETC fmtr = {cfColumnSelect, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; - HRESULT hrRectangular = pIDataSource->QueryGetData(&fmtr); + FORMATETC fmtr = {cfColumnSelect, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; + const HRESULT hrRectangular = pIDataSource->QueryGetData(&fmtr); POINT rpt = {pt.x, pt.y}; ::ScreenToClient(MainHWND(), &rpt); - SelectionPosition movePos = SPositionFromLocation(PointFromPOINT(rpt), false, false, UserVirtualSpace()); + const SelectionPosition movePos = SPositionFromLocation(PointFromPOINT(rpt), false, false, UserVirtualSpace()); DropAt(movePos, &data[0], data.size() - 1, *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK); // Free data - if (medium.pUnkForRelease != NULL) + if (medium.pUnkForRelease) medium.pUnkForRelease->Release(); else ::GlobalFree(medium.hGlobal); @@ -2993,10 +3173,10 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, /// Implement important part of IDataObject STDMETHODIMP ScintillaWin::GetData(FORMATETC *pFEIn, STGMEDIUM *pSTM) { - bool formatOK = (pFEIn->cfFormat == CF_TEXT) || + const bool formatOK = (pFEIn->cfFormat == CF_TEXT) || ((pFEIn->cfFormat == CF_UNICODETEXT) && IsUnicodeMode()); if (!formatOK || - pFEIn->ptd != 0 || + pFEIn->ptd != nullptr || (pFEIn->dwAspect & DVASPECT_CONTENT) == 0 || pFEIn->lindex != -1 || (pFEIn->tymed & TYMED_HGLOBAL) == 0 @@ -3009,7 +3189,7 @@ STDMETHODIMP ScintillaWin::GetData(FORMATETC *pFEIn, STGMEDIUM *pSTM) { GlobalMemory text; if (pFEIn->cfFormat == CF_UNICODETEXT) { - size_t uchars = UTF16Length(drag.Data(), static_cast(drag.LengthWithTerminator())); + const size_t uchars = UTF16Length(drag.Data(), drag.LengthWithTerminator()); text.Allocate(2 * uchars); if (text) { UTF16FromUTF8(drag.Data(), drag.LengthWithTerminator(), @@ -3018,52 +3198,40 @@ STDMETHODIMP ScintillaWin::GetData(FORMATETC *pFEIn, STGMEDIUM *pSTM) { } else { text.Allocate(drag.LengthWithTerminator()); if (text) { - memcpy(static_cast(text.ptr), drag.Data(), drag.LengthWithTerminator()); + memcpy(text.ptr, drag.Data(), drag.LengthWithTerminator()); } } pSTM->hGlobal = text ? text.Unlock() : 0; - pSTM->pUnkForRelease = 0; + pSTM->pUnkForRelease = nullptr; return S_OK; } -bool ScintillaWin::Register(HINSTANCE hInstance_) { +bool ScintillaWin::Register(HINSTANCE hInstance_) noexcept { hInstance = hInstance_; - bool result; // Register the Scintilla class // Register Scintilla as a wide character window - WNDCLASSEXW wndclass; + WNDCLASSEXW wndclass {}; wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = ScintillaWin::SWndProc; - wndclass.cbClsExtra = 0; wndclass.cbWndExtra = sizeof(ScintillaWin *); wndclass.hInstance = hInstance; - wndclass.hIcon = NULL; - wndclass.hCursor = NULL; - wndclass.hbrBackground = NULL; - wndclass.lpszMenuName = NULL; wndclass.lpszClassName = L"Scintilla"; - wndclass.hIconSm = 0; scintillaClassAtom = ::RegisterClassExW(&wndclass); - result = 0 != scintillaClassAtom; + bool result = 0 != scintillaClassAtom; if (result) { // Register the CallTip class - WNDCLASSEX wndclassc; + WNDCLASSEX wndclassc {}; wndclassc.cbSize = sizeof(wndclassc); wndclassc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW; - wndclassc.cbClsExtra = 0; wndclassc.cbWndExtra = sizeof(ScintillaWin *); wndclassc.hInstance = hInstance; - wndclassc.hIcon = NULL; - wndclassc.hbrBackground = NULL; - wndclassc.lpszMenuName = NULL; wndclassc.lpfnWndProc = ScintillaWin::CTWndProc; wndclassc.hCursor = ::LoadCursor(NULL, IDC_ARROW); wndclassc.lpszClassName = callClassName; - wndclassc.hIconSm = 0; callClassAtom = ::RegisterClassEx(&wndclassc); result = 0 != callClassAtom; @@ -3072,7 +3240,7 @@ bool ScintillaWin::Register(HINSTANCE hInstance_) { return result; } -bool ScintillaWin::Unregister() { +bool ScintillaWin::Unregister() noexcept { bool result = true; if (0 != scintillaClassAtom) { if (::UnregisterClass(MAKEINTATOM(scintillaClassAtom), hInstance) == 0) { @@ -3089,7 +3257,7 @@ bool ScintillaWin::Unregister() { return result; } -bool ScintillaWin::HasCaretSizeChanged() const { +bool ScintillaWin::HasCaretSizeChanged() const noexcept { if ( ( (0 != vs.caretWidth) && (sysCaretWidth != vs.caretWidth) ) || ((0 != vs.lineHeight) && (sysCaretHeight != vs.lineHeight)) @@ -3105,12 +3273,12 @@ BOOL ScintillaWin::CreateSystemCaret() { sysCaretWidth = 1; } sysCaretHeight = vs.lineHeight; - int bitmapSize = (((sysCaretWidth + 15) & ~15) >> 3) * + const int bitmapSize = (((sysCaretWidth + 15) & ~15) >> 3) * sysCaretHeight; - std::vector bits(bitmapSize); + std::vector bits(bitmapSize); sysCaretBitmap = ::CreateBitmap(sysCaretWidth, sysCaretHeight, 1, - 1, reinterpret_cast(&bits[0])); - BOOL retval = ::CreateCaret( + 1, &bits[0]); + const BOOL retval = ::CreateCaret( MainHWND(), sysCaretBitmap, sysCaretWidth, sysCaretHeight); if (technology == SC_TECHNOLOGY_DEFAULT) { @@ -3120,9 +3288,9 @@ BOOL ScintillaWin::CreateSystemCaret() { return retval; } -BOOL ScintillaWin::DestroySystemCaret() { +BOOL ScintillaWin::DestroySystemCaret() noexcept { ::HideCaret(MainHWND()); - BOOL retval = ::DestroyCaret(); + const BOOL retval = ::DestroyCaret(); if (sysCaretBitmap) { ::DeleteObject(sysCaretBitmap); sysCaretBitmap = 0; @@ -3133,13 +3301,13 @@ BOOL ScintillaWin::DestroySystemCaret() { LRESULT PASCAL ScintillaWin::CTWndProc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { // Find C++ object associated with window. - ScintillaWin *sciThis = reinterpret_cast(PointerFromWindow(hWnd)); + ScintillaWin *sciThis = static_cast(PointerFromWindow(hWnd)); try { // ctp will be zero if WM_CREATE not seen yet - if (sciThis == 0) { + if (sciThis == nullptr) { if (iMessage == WM_CREATE) { // Associate CallTip object with window - CREATESTRUCT *pCreate = reinterpret_cast(lParam); + CREATESTRUCT *pCreate = static_cast(PtrFromSPtr(lParam)); SetWindowPointer(hWnd, pCreate->lpCreateParams); return 0; } else { @@ -3152,70 +3320,66 @@ LRESULT PASCAL ScintillaWin::CTWndProc( } else if (iMessage == WM_PAINT) { PAINTSTRUCT ps; ::BeginPaint(hWnd, &ps); - Surface *surfaceWindow = Surface::Allocate(sciThis->technology); - if (surfaceWindow) { + std::unique_ptr surfaceWindow(Surface::Allocate(sciThis->technology)); #if defined(USE_D2D) - ID2D1HwndRenderTarget *pCTRenderTarget = 0; + ID2D1HwndRenderTarget *pCTRenderTarget = nullptr; #endif - RECT rc; - GetClientRect(hWnd, &rc); - // Create a Direct2D render target. - if (sciThis->technology == SC_TECHNOLOGY_DEFAULT) { - surfaceWindow->Init(ps.hdc, hWnd); - } else { + RECT rc; + GetClientRect(hWnd, &rc); + // Create a Direct2D render target. + if (sciThis->technology == SC_TECHNOLOGY_DEFAULT) { + surfaceWindow->Init(ps.hdc, hWnd); + } else { #if defined(USE_D2D) - D2D1_HWND_RENDER_TARGET_PROPERTIES dhrtp; - dhrtp.hwnd = hWnd; - dhrtp.pixelSize = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top); - dhrtp.presentOptions = (sciThis->technology == SC_TECHNOLOGY_DIRECTWRITERETAIN) ? - D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS : D2D1_PRESENT_OPTIONS_NONE; + D2D1_HWND_RENDER_TARGET_PROPERTIES dhrtp; + dhrtp.hwnd = hWnd; + dhrtp.pixelSize = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top); + dhrtp.presentOptions = (sciThis->technology == SC_TECHNOLOGY_DIRECTWRITERETAIN) ? + D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS : D2D1_PRESENT_OPTIONS_NONE; - D2D1_RENDER_TARGET_PROPERTIES drtp; - drtp.type = D2D1_RENDER_TARGET_TYPE_DEFAULT; - drtp.pixelFormat.format = DXGI_FORMAT_UNKNOWN; - drtp.pixelFormat.alphaMode = D2D1_ALPHA_MODE_UNKNOWN; - drtp.dpiX = 96.0; - drtp.dpiY = 96.0; - drtp.usage = D2D1_RENDER_TARGET_USAGE_NONE; - drtp.minLevel = D2D1_FEATURE_LEVEL_DEFAULT; + D2D1_RENDER_TARGET_PROPERTIES drtp; + drtp.type = D2D1_RENDER_TARGET_TYPE_DEFAULT; + drtp.pixelFormat.format = DXGI_FORMAT_UNKNOWN; + drtp.pixelFormat.alphaMode = D2D1_ALPHA_MODE_UNKNOWN; + drtp.dpiX = 96.0; + drtp.dpiY = 96.0; + drtp.usage = D2D1_RENDER_TARGET_USAGE_NONE; + drtp.minLevel = D2D1_FEATURE_LEVEL_DEFAULT; - if (!SUCCEEDED(pD2DFactory->CreateHwndRenderTarget(drtp, dhrtp, &pCTRenderTarget))) { - surfaceWindow->Release(); - delete surfaceWindow; - ::EndPaint(hWnd, &ps); - return 0; - } - surfaceWindow->Init(pCTRenderTarget, hWnd); - pCTRenderTarget->BeginDraw(); -#endif + if (!SUCCEEDED(pD2DFactory->CreateHwndRenderTarget(drtp, dhrtp, &pCTRenderTarget))) { + surfaceWindow->Release(); + ::EndPaint(hWnd, &ps); + return 0; } - surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == sciThis->ct.codePage); - surfaceWindow->SetDBCSMode(sciThis->ct.codePage); - sciThis->ct.PaintCT(surfaceWindow); -#if defined(USE_D2D) - if (pCTRenderTarget) - pCTRenderTarget->EndDraw(); -#endif - surfaceWindow->Release(); - delete surfaceWindow; -#if defined(USE_D2D) - if (pCTRenderTarget) - pCTRenderTarget->Release(); + // If above SUCCEEDED, then pCTRenderTarget not nullptr + assert(pCTRenderTarget); + surfaceWindow->Init(pCTRenderTarget, hWnd); + pCTRenderTarget->BeginDraw(); #endif } + surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == sciThis->ct.codePage); + surfaceWindow->SetDBCSMode(sciThis->ct.codePage); + sciThis->ct.PaintCT(surfaceWindow.get()); +#if defined(USE_D2D) + if (pCTRenderTarget) + pCTRenderTarget->EndDraw(); +#endif + surfaceWindow->Release(); +#if defined(USE_D2D) + if (pCTRenderTarget) + pCTRenderTarget->Release(); +#endif ::EndPaint(hWnd, &ps); return 0; } else if ((iMessage == WM_NCLBUTTONDOWN) || (iMessage == WM_NCLBUTTONDBLCLK)) { - POINT pt; - pt.x = static_cast(LOWORD(lParam)); - pt.y = static_cast(HIWORD(lParam)); + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; ScreenToClient(hWnd, &pt); sciThis->ct.MouseClick(PointFromPOINT(pt)); sciThis->CallTipClick(); return 0; } else if (iMessage == WM_LBUTTONDOWN) { // This does not fire due to the hit test code - sciThis->ct.MouseClick(Point::FromLong(static_cast(lParam))); + sciThis->ct.MouseClick(PointFromLParam(lParam)); sciThis->CallTipClick(); return 0; } else if (iMessage == WM_SETCURSOR) { @@ -3235,27 +3399,27 @@ LRESULT PASCAL ScintillaWin::CTWndProc( sptr_t ScintillaWin::DirectFunction( sptr_t ptr, UINT iMessage, uptr_t wParam, sptr_t lParam) { - PLATFORM_ASSERT(::GetCurrentThreadId() == ::GetWindowThreadProcessId(reinterpret_cast(ptr)->MainHWND(), NULL)); + PLATFORM_ASSERT(::GetCurrentThreadId() == ::GetWindowThreadProcessId(reinterpret_cast(ptr)->MainHWND(), nullptr)); return reinterpret_cast(ptr)->WndProc(iMessage, wParam, lParam); } -extern "C" -#ifndef STATIC_BUILD -__declspec(dllexport) -#endif -sptr_t __stdcall Scintilla_DirectFunction( +namespace Scintilla { + +sptr_t DirectFunction( ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam) { return sci->WndProc(iMessage, wParam, lParam); } +} + LRESULT PASCAL ScintillaWin::SWndProc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { //Platform::DebugPrintf("S W:%x M:%x WP:%x L:%x\n", hWnd, iMessage, wParam, lParam); // Find C++ object associated with window. - ScintillaWin *sci = reinterpret_cast(PointerFromWindow(hWnd)); + ScintillaWin *sci = static_cast(PointerFromWindow(hWnd)); // sci will be zero if WM_CREATE not seen yet - if (sci == 0) { + if (sci == nullptr) { try { if (iMessage == WM_CREATE) { // Create C++ object associated with window @@ -3285,39 +3449,24 @@ LRESULT PASCAL ScintillaWin::SWndProc( // Must be called once only. int Scintilla_RegisterClasses(void *hInstance) { Platform_Initialise(hInstance); - bool result = ScintillaWin::Register(reinterpret_cast(hInstance)); + const bool result = ScintillaWin::Register(static_cast(hInstance)); #ifdef SCI_LEXER Scintilla_LinkLexers(); #endif return result; } -static int ResourcesRelease(bool fromDllMain) { - bool result = ScintillaWin::Unregister(); - if (commctrl32) { - FreeLibrary(commctrl32); - commctrl32 = NULL; - } +namespace Scintilla { + +int ResourcesRelease(bool fromDllMain) { + const bool result = ScintillaWin::Unregister(); Platform_Finalise(fromDllMain); return result; } -// This function is externally visible so it can be called from container when building statically. -int Scintilla_ReleaseResources() { - return ResourcesRelease(false); } -#ifndef STATIC_BUILD -extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved) { - //Platform::DebugPrintf("Scintilla::DllMain %d %d\n", hInstance, dwReason); - if (dwReason == DLL_PROCESS_ATTACH) { - if (!Scintilla_RegisterClasses(hInstance)) - return FALSE; - } else if (dwReason == DLL_PROCESS_DETACH) { - if (lpvReserved == NULL) { - ResourcesRelease(true); - } - } - return TRUE; +// This function is externally visible so it can be called from container when building statically. +int Scintilla_ReleaseResources() { + return Scintilla::ResourcesRelease(false); } -#endif diff --git a/dep/scintilla/scintilla-3.10.6/win32/ScintillaWin.h b/dep/scintilla/scintilla-3.10.6/win32/ScintillaWin.h new file mode 100644 index 00000000..6d4d2ce2 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/win32/ScintillaWin.h @@ -0,0 +1,15 @@ +// Scintilla source code edit control +/** @file ScintillaWin.h + ** Define functions from ScintillaWin.cxx that can be called from ScintillaDLL.cxx. + **/ +// Copyright 1998-2018 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +class ScintillaWin; + +namespace Scintilla { + +int ResourcesRelease(bool fromDllMain); +sptr_t DirectFunction(ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam); + +} diff --git a/dep/scintilla/scintilla-3.10.6/win32/deps.mak b/dep/scintilla/scintilla-3.10.6/win32/deps.mak new file mode 100644 index 00000000..8c53840a --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/win32/deps.mak @@ -0,0 +1,1985 @@ +# Created by DepGen.py. To recreate, run 'python DepGen.py'. +HanjaDic.o: \ + HanjaDic.cxx \ + ../src/UniConversion.h \ + HanjaDic.h +PlatWin.o: \ + PlatWin.cxx \ + ../include/Platform.h \ + ../src/XPM.h \ + ../src/UniConversion.h \ + ../src/DBCS.h \ + ../src/FontQuality.h \ + PlatWin.h +ScintillaDLL.o: \ + ScintillaDLL.cxx \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ScintillaWin.h +ScintillaWin.o: \ + ScintillaWin.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/CallTip.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/CaseConvert.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/ElapsedPeriod.h \ + ../src/AutoComplete.h \ + ../src/ScintillaBase.h \ + ../src/ExternalLexer.h \ + PlatWin.h \ + HanjaDic.h \ + ScintillaWin.h +ScintillaWinL.o: \ + ScintillaWin.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/CallTip.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/CaseConvert.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/ElapsedPeriod.h \ + ../src/AutoComplete.h \ + ../src/ScintillaBase.h \ + ../src/ExternalLexer.h \ + PlatWin.h \ + HanjaDic.h \ + ScintillaWin.h +AutoComplete.o: \ + ../src/AutoComplete.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../lexlib/CharacterSet.h \ + ../src/Position.h \ + ../src/AutoComplete.h +CallTip.o: \ + ../src/CallTip.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/IntegerRectangle.h \ + ../src/CallTip.h +CaseConvert.o: \ + ../src/CaseConvert.cxx \ + ../src/CaseConvert.h \ + ../src/UniConversion.h +CaseFolder.o: \ + ../src/CaseFolder.cxx \ + ../src/CaseFolder.h \ + ../src/CaseConvert.h +Catalogue.o: \ + ../src/Catalogue.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/LexerModule.h \ + ../src/Catalogue.h +CellBuffer.o: \ + ../src/CellBuffer.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/CellBuffer.h \ + ../src/UniConversion.h +CharClassify.o: \ + ../src/CharClassify.cxx \ + ../lexlib/CharacterSet.h \ + ../src/CharClassify.h +ContractionState.o: \ + ../src/ContractionState.cxx \ + ../include/Platform.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/SparseVector.h \ + ../src/ContractionState.h +DBCS.o: \ + ../src/DBCS.cxx \ + ../src/DBCS.h +Decoration.o: \ + ../src/Decoration.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/Decoration.h +Document.o: \ + ../src/Document.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/CellBuffer.h \ + ../src/PerLine.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/RESearch.h \ + ../src/UniConversion.h \ + ../src/ElapsedPeriod.h +EditModel.o: \ + ../src/EditModel.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h +Editor.o: \ + ../src/Editor.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/PerLine.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/ElapsedPeriod.h +EditView.o: \ + ../src/EditView.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/IntegerRectangle.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/PerLine.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/ElapsedPeriod.h +ExternalLexer.o: \ + ../src/ExternalLexer.cxx \ + ../include/Platform.h \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/LexerModule.h \ + ../src/Catalogue.h \ + ../src/ExternalLexer.h +Indicator.o: \ + ../src/Indicator.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/IntegerRectangle.h \ + ../src/Indicator.h \ + ../src/XPM.h +KeyMap.o: \ + ../src/KeyMap.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/KeyMap.h +LineMarker.o: \ + ../src/LineMarker.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/IntegerRectangle.h \ + ../src/XPM.h \ + ../src/LineMarker.h +MarginView.o: \ + ../src/MarginView.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/IntegerRectangle.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h +PerLine.o: \ + ../src/PerLine.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/CellBuffer.h \ + ../src/PerLine.h +PositionCache.o: \ + ../src/PositionCache.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h +RESearch.o: \ + ../src/RESearch.cxx \ + ../src/Position.h \ + ../src/CharClassify.h \ + ../src/RESearch.h +RunStyles.o: \ + ../src/RunStyles.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h +ScintillaBase.o: \ + ../src/ScintillaBase.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../src/Catalogue.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/CallTip.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/AutoComplete.h \ + ../src/ScintillaBase.h +ScintillaBaseL.o: \ + ../src/ScintillaBase.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../src/Catalogue.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/CallTip.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/AutoComplete.h \ + ../src/ScintillaBase.h +Selection.o: \ + ../src/Selection.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/Selection.h +Style.o: \ + ../src/Style.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Style.h +UniConversion.o: \ + ../src/UniConversion.cxx \ + ../src/UniConversion.h +UniqueString.o: \ + ../src/UniqueString.cxx \ + ../src/UniqueString.h +ViewStyle.o: \ + ../src/ViewStyle.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/Indicator.h \ + ../src/XPM.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h +XPM.o: \ + ../src/XPM.cxx \ + ../include/Platform.h \ + ../src/XPM.h +Accessor.o: \ + ../lexlib/Accessor.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h +CharacterCategory.o: \ + ../lexlib/CharacterCategory.cxx \ + ../lexlib/CharacterCategory.h +CharacterSet.o: \ + ../lexlib/CharacterSet.cxx \ + ../lexlib/CharacterSet.h +DefaultLexer.o: \ + ../lexlib/DefaultLexer.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h +LexerBase.o: \ + ../lexlib/LexerBase.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/LexerBase.h +LexerModule.o: \ + ../lexlib/LexerModule.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/LexerBase.h \ + ../lexlib/LexerSimple.h +LexerNoExceptions.o: \ + ../lexlib/LexerNoExceptions.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/LexerBase.h \ + ../lexlib/LexerNoExceptions.h +LexerSimple.o: \ + ../lexlib/LexerSimple.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/LexerBase.h \ + ../lexlib/LexerSimple.h +PropSetSimple.o: \ + ../lexlib/PropSetSimple.cxx \ + ../lexlib/PropSetSimple.h +StyleContext.o: \ + ../lexlib/StyleContext.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h +WordList.o: \ + ../lexlib/WordList.cxx \ + ../lexlib/WordList.h +LexA68k.o: \ + ../lexers/LexA68k.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexAbaqus.o: \ + ../lexers/LexAbaqus.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexAda.o: \ + ../lexers/LexAda.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexAPDL.o: \ + ../lexers/LexAPDL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexAsm.o: \ + ../lexers/LexAsm.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexAsn1.o: \ + ../lexers/LexAsn1.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexASY.o: \ + ../lexers/LexASY.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexAU3.o: \ + ../lexers/LexAU3.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexAVE.o: \ + ../lexers/LexAVE.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexAVS.o: \ + ../lexers/LexAVS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexBaan.o: \ + ../lexers/LexBaan.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexBash.o: \ + ../lexers/LexBash.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SubStyles.h \ + ../lexlib/DefaultLexer.h +LexBasic.o: \ + ../lexers/LexBasic.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexBatch.o: \ + ../lexers/LexBatch.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexBibTeX.o: \ + ../lexers/LexBibTeX.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexBullant.o: \ + ../lexers/LexBullant.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexCaml.o: \ + ../lexers/LexCaml.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../src/ExternalLexer.h +LexCIL.o: \ + ../lexers/LexCIL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexCLW.o: \ + ../lexers/LexCLW.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexCmake.o: \ + ../lexers/LexCmake.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexCOBOL.o: \ + ../lexers/LexCOBOL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexCoffeeScript.o: \ + ../lexers/LexCoffeeScript.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexConf.o: \ + ../lexers/LexConf.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexCPP.o: \ + ../lexers/LexCPP.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SparseState.h \ + ../lexlib/SubStyles.h +LexCrontab.o: \ + ../lexers/LexCrontab.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexCsound.o: \ + ../lexers/LexCsound.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexCSS.o: \ + ../lexers/LexCSS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexD.o: \ + ../lexers/LexD.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexDiff.o: \ + ../lexers/LexDiff.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexDMAP.o: \ + ../lexers/LexDMAP.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexDMIS.o: \ + ../lexers/LexDMIS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h +LexECL.o: \ + ../lexers/LexECL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h +LexEDIFACT.o: \ + ../lexers/LexEDIFACT.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h +LexEiffel.o: \ + ../lexers/LexEiffel.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexErlang.o: \ + ../lexers/LexErlang.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexErrorList.o: \ + ../lexers/LexErrorList.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexEScript.o: \ + ../lexers/LexEScript.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexFlagship.o: \ + ../lexers/LexFlagship.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexForth.o: \ + ../lexers/LexForth.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexFortran.o: \ + ../lexers/LexFortran.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexGAP.o: \ + ../lexers/LexGAP.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexGui4Cli.o: \ + ../lexers/LexGui4Cli.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexHaskell.o: \ + ../lexers/LexHaskell.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexHex.o: \ + ../lexers/LexHex.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexHTML.o: \ + ../lexers/LexHTML.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexIndent.o: \ + ../lexers/LexIndent.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexInno.o: \ + ../lexers/LexInno.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexJSON.o: \ + ../lexers/LexJSON.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexKix.o: \ + ../lexers/LexKix.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexKVIrc.o: \ + ../lexers/LexKVIrc.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexLaTeX.o: \ + ../lexers/LexLaTeX.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h \ + ../lexlib/LexerBase.h +LexLisp.o: \ + ../lexers/LexLisp.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexLout.o: \ + ../lexers/LexLout.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexLua.o: \ + ../lexers/LexLua.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMagik.o: \ + ../lexers/LexMagik.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMake.o: \ + ../lexers/LexMake.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMarkdown.o: \ + ../lexers/LexMarkdown.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMatlab.o: \ + ../lexers/LexMatlab.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMaxima.o: \ + ../lexers/LexMaxima.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMetapost.o: \ + ../lexers/LexMetapost.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMMIXAL.o: \ + ../lexers/LexMMIXAL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexModula.o: \ + ../lexers/LexModula.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMPT.o: \ + ../lexers/LexMPT.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMSSQL.o: \ + ../lexers/LexMSSQL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexMySQL.o: \ + ../lexers/LexMySQL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexNim.o: \ + ../lexers/LexNim.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexNimrod.o: \ + ../lexers/LexNimrod.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexNsis.o: \ + ../lexers/LexNsis.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexNull.o: \ + ../lexers/LexNull.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexOpal.o: \ + ../lexers/LexOpal.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexOScript.o: \ + ../lexers/LexOScript.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexPascal.o: \ + ../lexers/LexPascal.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexPB.o: \ + ../lexers/LexPB.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexPerl.o: \ + ../lexers/LexPerl.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexPLM.o: \ + ../lexers/LexPLM.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexPO.o: \ + ../lexers/LexPO.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexPOV.o: \ + ../lexers/LexPOV.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexPowerPro.o: \ + ../lexers/LexPowerPro.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexPowerShell.o: \ + ../lexers/LexPowerShell.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexProgress.o: \ + ../lexers/LexProgress.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SparseState.h \ + ../lexlib/DefaultLexer.h +LexProps.o: \ + ../lexers/LexProps.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexPS.o: \ + ../lexers/LexPS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexPython.o: \ + ../lexers/LexPython.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SubStyles.h \ + ../lexlib/DefaultLexer.h +LexR.o: \ + ../lexers/LexR.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexRebol.o: \ + ../lexers/LexRebol.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexRegistry.o: \ + ../lexers/LexRegistry.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexRuby.o: \ + ../lexers/LexRuby.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexRust.o: \ + ../lexers/LexRust.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexSAS.o: \ + ../lexers/LexSAS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexScriptol.o: \ + ../lexers/LexScriptol.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexSmalltalk.o: \ + ../lexers/LexSmalltalk.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexSML.o: \ + ../lexers/LexSML.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexSorcus.o: \ + ../lexers/LexSorcus.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexSpecman.o: \ + ../lexers/LexSpecman.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexSpice.o: \ + ../lexers/LexSpice.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexSQL.o: \ + ../lexers/LexSQL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SparseState.h \ + ../lexlib/DefaultLexer.h +LexStata.o: \ + ../lexers/LexStata.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexSTTXT.o: \ + ../lexers/LexSTTXT.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexTACL.o: \ + ../lexers/LexTACL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexTADS3.o: \ + ../lexers/LexTADS3.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexTAL.o: \ + ../lexers/LexTAL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexTCL.o: \ + ../lexers/LexTCL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexTCMD.o: \ + ../lexers/LexTCMD.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexTeX.o: \ + ../lexers/LexTeX.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexTxt2tags.o: \ + ../lexers/LexTxt2tags.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexVB.o: \ + ../lexers/LexVB.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexVerilog.o: \ + ../lexers/LexVerilog.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SubStyles.h \ + ../lexlib/DefaultLexer.h +LexVHDL.o: \ + ../lexers/LexVHDL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +LexVisualProlog.o: \ + ../lexers/LexVisualProlog.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +LexX12.o: \ + ../lexers/LexX12.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h +LexYAML.o: \ + ../lexers/LexYAML.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h diff --git a/dep/scintilla/scintilla-3.10.6/win32/makefile b/dep/scintilla/scintilla-3.10.6/win32/makefile new file mode 100644 index 00000000..bc96c76b --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/win32/makefile @@ -0,0 +1,167 @@ +# Make file for Scintilla on Windows +# Copyright 1998-2010 by Neil Hodgson +# The License.txt file describes the conditions under which this software may be distributed. +# This makefile assumes the MinGW32 version of GCC 4.8+ is used and changes will +# be needed to use other compilers. + +.SUFFIXES: .cxx + +DIR_BIN=../bin + +COMPONENT = $(DIR_BIN)/Scintilla.dll +LEXCOMPONENT = $(DIR_BIN)/SciLexer.dll +LIBSCI = $(DIR_BIN)/libscintilla.a + +ifdef CLANG +CXX = clang++ +# Clang doesn't like omitting braces in array initialization but they just add noise, +# __uuidof is a Microsoft extension but makes COM code neater, +# public visibility avoids warnings like 'locally defined symbol __std_terminate imported' +CLANG_OPTS = -Wno-missing-braces -Wno-language-extension-token -Xclang -flto-visibility-public-std +else +# MinGW GCC +LDMINGW = -Wl,--enable-runtime-pseudo-reloc-v2 -Wl,--add-stdcall-alias +LIBSMINGW = -lstdc++ +STRIPOPTION = -s +CXXSTD = gnu++0x +endif + +ifeq ($(OS),Windows_NT) +DEL = $(if $(wildcard $(dir $(SHELL))rm.exe), $(dir $(SHELL))rm.exe -f, del /q) +else +DEL = rm -f +endif +RANLIB ?= ranlib +WINDRES ?= windres + +vpath %.h ../src ../include ../lexlib +vpath %.cxx ../src ../lexlib ../lexers +vpath %.c ../lua/src + +LDFLAGS=-shared -static -mwindows $(LDMINGW) +LIBS=-lgdi32 -luser32 -limm32 -lole32 -luuid -loleaut32 -lmsimg32 $(LIBSMINGW) +# Add -MMD to get dependencies +INCLUDEDIRS=-I ../include -I ../src -I../lexlib + +CXXBASEFLAGS=--std=$(CXXSTD) -Wall -pedantic $(INCLUDEDIRS) -D_CRT_SECURE_NO_DEPRECATE=1 $(CLANG_OPTS) + +ifdef NO_CXX11_REGEX +REFLAGS=-DNO_CXX11_REGEX +endif + +ifdef DEBUG +CXXFLAGS=-DDEBUG -g $(CXXBASEFLAGS) +else +CXXFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) +STRIPFLAG=$(STRIPOPTION) +endif + +all: $(COMPONENT) $(LEXCOMPONENT) $(LIBSCI) + +clean: + $(DEL) *.exe *.o *.a *.obj *.dll *.res *.map *.plist + +ifdef LPEG_LEXER +CXXFLAGS+=-DLPEG_LEXER -I ../lua/src +LUAOBJS:=lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o linit.o \ + llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o \ + ltable.o ltm.o lundump.o lvm.o lzio.o \ + lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \ + lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o \ + lpcap.o lpcode.o lpprint.o lptree.o lpvm.o +endif + +.cxx.o: + $(CXX) $(CXXFLAGS) $(REFLAGS) -c $< + +.c.o: + $(CC) $(CFLAGS) -c $< + +analyze: + $(CXX) --analyze $(CXXFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx + +depend deps.mak: + python DepGen.py + +LEXOBJS:=$(addsuffix .o,$(basename $(sort $(notdir $(wildcard ../lexers/Lex*.cxx))))) + +# Required for base Scintilla +BASEOBJS = \ + AutoComplete.o \ + CallTip.o \ + CaseConvert.o \ + CaseFolder.o \ + CellBuffer.o \ + CharacterCategory.o \ + CharacterSet.o \ + CharClassify.o \ + ContractionState.o \ + DBCS.o \ + Decoration.o \ + Document.o \ + EditModel.o \ + Editor.o \ + EditView.o \ + KeyMap.o \ + Indicator.o \ + LineMarker.o \ + MarginView.o \ + PerLine.o \ + PlatWin.o \ + PositionCache.o \ + PropSetSimple.o \ + RESearch.o \ + RunStyles.o \ + ScintRes.o \ + Selection.o \ + Style.o \ + UniConversion.o \ + UniqueString.o \ + ViewStyle.o \ + XPM.o \ + HanjaDic.o + +SOBJS = ScintillaDLL.o ScintillaWin.o ScintillaBase.o $(BASEOBJS) + +# Required by lexers +LEXLIBOBJS=\ + Accessor.o \ + Catalogue.o \ + ExternalLexer.o \ + DefaultLexer.o \ + LexerBase.o \ + LexerModule.o \ + LexerSimple.o \ + StyleContext.o \ + WordList.o \ + +# Required by libraries and DLLs that include lexing +SCILEXOBJS=\ + $(BASEOBJS) \ + $(LEXLIBOBJS) \ + $(LEXOBJS) \ + $(LUAOBJS) \ + ScintillaBaseL.o + +$(COMPONENT): $(SOBJS) Scintilla.def + $(CXX) $(LDFLAGS) -o $@ $(STRIPFLAG) $(SOBJS) $(CXXFLAGS) $(LIBS) + +$(LEXCOMPONENT): ScintillaDLL.o ScintillaWinL.o $(SCILEXOBJS) Scintilla.def + $(CXX) $(LDFLAGS) -o $@ $(STRIPFLAG) ScintillaDLL.o ScintillaWinL.o $(SCILEXOBJS) $(CXXFLAGS) $(LIBS) + +$(LIBSCI): ScintillaWin.o $(SCILEXOBJS) + $(AR) rc $@ $^ + $(RANLIB) $@ + +# Automatically generate dependencies for most files with "make deps" +include deps.mak + +ScintillaBaseL.o: + $(CXX) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@ + +ScintillaWinL.o: + $(CXX) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@ + +ScintRes.o: ScintRes.rc + $(WINDRES) ScintRes.rc $@ + diff --git a/dep/scintilla/scintilla-3.10.6/win32/nmdeps.mak b/dep/scintilla/scintilla-3.10.6/win32/nmdeps.mak new file mode 100644 index 00000000..8ddedfc7 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/win32/nmdeps.mak @@ -0,0 +1,1985 @@ +# Created by DepGen.py. To recreate, run 'python DepGen.py'. +$(DIR_O)/HanjaDic.obj: \ + HanjaDic.cxx \ + ../src/UniConversion.h \ + HanjaDic.h +$(DIR_O)/PlatWin.obj: \ + PlatWin.cxx \ + ../include/Platform.h \ + ../src/XPM.h \ + ../src/UniConversion.h \ + ../src/DBCS.h \ + ../src/FontQuality.h \ + PlatWin.h +$(DIR_O)/ScintillaDLL.obj: \ + ScintillaDLL.cxx \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ScintillaWin.h +$(DIR_O)/ScintillaWin.obj: \ + ScintillaWin.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/CallTip.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/CaseConvert.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/ElapsedPeriod.h \ + ../src/AutoComplete.h \ + ../src/ScintillaBase.h \ + ../src/ExternalLexer.h \ + PlatWin.h \ + HanjaDic.h \ + ScintillaWin.h +$(DIR_O)/ScintillaWinL.obj: \ + ScintillaWin.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/CallTip.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/CaseConvert.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/ElapsedPeriod.h \ + ../src/AutoComplete.h \ + ../src/ScintillaBase.h \ + ../src/ExternalLexer.h \ + PlatWin.h \ + HanjaDic.h \ + ScintillaWin.h +$(DIR_O)/AutoComplete.obj: \ + ../src/AutoComplete.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../lexlib/CharacterSet.h \ + ../src/Position.h \ + ../src/AutoComplete.h +$(DIR_O)/CallTip.obj: \ + ../src/CallTip.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/IntegerRectangle.h \ + ../src/CallTip.h +$(DIR_O)/CaseConvert.obj: \ + ../src/CaseConvert.cxx \ + ../src/CaseConvert.h \ + ../src/UniConversion.h +$(DIR_O)/CaseFolder.obj: \ + ../src/CaseFolder.cxx \ + ../src/CaseFolder.h \ + ../src/CaseConvert.h +$(DIR_O)/Catalogue.obj: \ + ../src/Catalogue.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/LexerModule.h \ + ../src/Catalogue.h +$(DIR_O)/CellBuffer.obj: \ + ../src/CellBuffer.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/CellBuffer.h \ + ../src/UniConversion.h +$(DIR_O)/CharClassify.obj: \ + ../src/CharClassify.cxx \ + ../lexlib/CharacterSet.h \ + ../src/CharClassify.h +$(DIR_O)/ContractionState.obj: \ + ../src/ContractionState.cxx \ + ../include/Platform.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/SparseVector.h \ + ../src/ContractionState.h +$(DIR_O)/DBCS.obj: \ + ../src/DBCS.cxx \ + ../src/DBCS.h +$(DIR_O)/Decoration.obj: \ + ../src/Decoration.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/Decoration.h +$(DIR_O)/Document.obj: \ + ../src/Document.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/CellBuffer.h \ + ../src/PerLine.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/RESearch.h \ + ../src/UniConversion.h \ + ../src/ElapsedPeriod.h +$(DIR_O)/EditModel.obj: \ + ../src/EditModel.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h +$(DIR_O)/Editor.obj: \ + ../src/Editor.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/PerLine.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/ElapsedPeriod.h +$(DIR_O)/EditView.obj: \ + ../src/EditView.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/IntegerRectangle.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/PerLine.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/ElapsedPeriod.h +$(DIR_O)/ExternalLexer.obj: \ + ../src/ExternalLexer.cxx \ + ../include/Platform.h \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/LexerModule.h \ + ../src/Catalogue.h \ + ../src/ExternalLexer.h +$(DIR_O)/Indicator.obj: \ + ../src/Indicator.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/IntegerRectangle.h \ + ../src/Indicator.h \ + ../src/XPM.h +$(DIR_O)/KeyMap.obj: \ + ../src/KeyMap.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/KeyMap.h +$(DIR_O)/LineMarker.obj: \ + ../src/LineMarker.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/IntegerRectangle.h \ + ../src/XPM.h \ + ../src/LineMarker.h +$(DIR_O)/MarginView.obj: \ + ../src/MarginView.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/IntegerRectangle.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h +$(DIR_O)/PerLine.obj: \ + ../src/PerLine.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/CellBuffer.h \ + ../src/PerLine.h +$(DIR_O)/PositionCache.obj: \ + ../src/PositionCache.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../lexlib/CharacterCategory.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/UniConversion.h \ + ../src/Selection.h \ + ../src/PositionCache.h +$(DIR_O)/RESearch.obj: \ + ../src/RESearch.cxx \ + ../src/Position.h \ + ../src/CharClassify.h \ + ../src/RESearch.h +$(DIR_O)/RunStyles.obj: \ + ../src/RunStyles.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h +$(DIR_O)/ScintillaBase.obj: \ + ../src/ScintillaBase.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../src/Catalogue.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/CallTip.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/AutoComplete.h \ + ../src/ScintillaBase.h +$(DIR_O)/ScintillaBaseL.obj: \ + ../src/ScintillaBase.cxx \ + ../include/Platform.h \ + ../include/ILoader.h \ + ../include/Sci_Position.h \ + ../include/ILexer.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../src/Catalogue.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/SplitVector.h \ + ../src/Partitioning.h \ + ../src/RunStyles.h \ + ../src/ContractionState.h \ + ../src/CellBuffer.h \ + ../src/CallTip.h \ + ../src/KeyMap.h \ + ../src/Indicator.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h \ + ../src/CharClassify.h \ + ../src/Decoration.h \ + ../src/CaseFolder.h \ + ../src/Document.h \ + ../src/Selection.h \ + ../src/PositionCache.h \ + ../src/EditModel.h \ + ../src/MarginView.h \ + ../src/EditView.h \ + ../src/Editor.h \ + ../src/AutoComplete.h \ + ../src/ScintillaBase.h +$(DIR_O)/Selection.obj: \ + ../src/Selection.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/Selection.h +$(DIR_O)/Style.obj: \ + ../src/Style.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Style.h +$(DIR_O)/UniConversion.obj: \ + ../src/UniConversion.cxx \ + ../src/UniConversion.h +$(DIR_O)/UniqueString.obj: \ + ../src/UniqueString.cxx \ + ../src/UniqueString.h +$(DIR_O)/ViewStyle.obj: \ + ../src/ViewStyle.cxx \ + ../include/Platform.h \ + ../include/Scintilla.h \ + ../include/Sci_Position.h \ + ../src/Position.h \ + ../src/UniqueString.h \ + ../src/Indicator.h \ + ../src/XPM.h \ + ../src/LineMarker.h \ + ../src/Style.h \ + ../src/ViewStyle.h +$(DIR_O)/XPM.obj: \ + ../src/XPM.cxx \ + ../include/Platform.h \ + ../src/XPM.h +$(DIR_O)/Accessor.obj: \ + ../lexlib/Accessor.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h +$(DIR_O)/CharacterCategory.obj: \ + ../lexlib/CharacterCategory.cxx \ + ../lexlib/CharacterCategory.h +$(DIR_O)/CharacterSet.obj: \ + ../lexlib/CharacterSet.cxx \ + ../lexlib/CharacterSet.h +$(DIR_O)/DefaultLexer.obj: \ + ../lexlib/DefaultLexer.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexerBase.obj: \ + ../lexlib/LexerBase.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/LexerBase.h +$(DIR_O)/LexerModule.obj: \ + ../lexlib/LexerModule.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/LexerBase.h \ + ../lexlib/LexerSimple.h +$(DIR_O)/LexerNoExceptions.obj: \ + ../lexlib/LexerNoExceptions.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/LexerBase.h \ + ../lexlib/LexerNoExceptions.h +$(DIR_O)/LexerSimple.obj: \ + ../lexlib/LexerSimple.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/LexerBase.h \ + ../lexlib/LexerSimple.h +$(DIR_O)/PropSetSimple.obj: \ + ../lexlib/PropSetSimple.cxx \ + ../lexlib/PropSetSimple.h +$(DIR_O)/StyleContext.obj: \ + ../lexlib/StyleContext.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h +$(DIR_O)/WordList.obj: \ + ../lexlib/WordList.cxx \ + ../lexlib/WordList.h +$(DIR_O)/LexA68k.obj: \ + ../lexers/LexA68k.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexAbaqus.obj: \ + ../lexers/LexAbaqus.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexAda.obj: \ + ../lexers/LexAda.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexAPDL.obj: \ + ../lexers/LexAPDL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexAsm.obj: \ + ../lexers/LexAsm.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexAsn1.obj: \ + ../lexers/LexAsn1.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexASY.obj: \ + ../lexers/LexASY.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexAU3.obj: \ + ../lexers/LexAU3.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexAVE.obj: \ + ../lexers/LexAVE.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexAVS.obj: \ + ../lexers/LexAVS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexBaan.obj: \ + ../lexers/LexBaan.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexBash.obj: \ + ../lexers/LexBash.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SubStyles.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexBasic.obj: \ + ../lexers/LexBasic.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexBatch.obj: \ + ../lexers/LexBatch.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexBibTeX.obj: \ + ../lexers/LexBibTeX.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexBullant.obj: \ + ../lexers/LexBullant.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexCaml.obj: \ + ../lexers/LexCaml.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../src/ExternalLexer.h +$(DIR_O)/LexCIL.obj: \ + ../lexers/LexCIL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexCLW.obj: \ + ../lexers/LexCLW.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexCmake.obj: \ + ../lexers/LexCmake.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexCOBOL.obj: \ + ../lexers/LexCOBOL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexCoffeeScript.obj: \ + ../lexers/LexCoffeeScript.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexConf.obj: \ + ../lexers/LexConf.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexCPP.obj: \ + ../lexers/LexCPP.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SparseState.h \ + ../lexlib/SubStyles.h +$(DIR_O)/LexCrontab.obj: \ + ../lexers/LexCrontab.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexCsound.obj: \ + ../lexers/LexCsound.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexCSS.obj: \ + ../lexers/LexCSS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexD.obj: \ + ../lexers/LexD.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexDiff.obj: \ + ../lexers/LexDiff.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexDMAP.obj: \ + ../lexers/LexDMAP.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexDMIS.obj: \ + ../lexers/LexDMIS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexECL.obj: \ + ../lexers/LexECL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h +$(DIR_O)/LexEDIFACT.obj: \ + ../lexers/LexEDIFACT.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexEiffel.obj: \ + ../lexers/LexEiffel.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexErlang.obj: \ + ../lexers/LexErlang.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexErrorList.obj: \ + ../lexers/LexErrorList.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexEScript.obj: \ + ../lexers/LexEScript.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexFlagship.obj: \ + ../lexers/LexFlagship.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexForth.obj: \ + ../lexers/LexForth.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexFortran.obj: \ + ../lexers/LexFortran.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexGAP.obj: \ + ../lexers/LexGAP.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexGui4Cli.obj: \ + ../lexers/LexGui4Cli.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexHaskell.obj: \ + ../lexers/LexHaskell.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexHex.obj: \ + ../lexers/LexHex.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexHTML.obj: \ + ../lexers/LexHTML.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexIndent.obj: \ + ../lexers/LexIndent.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexInno.obj: \ + ../lexers/LexInno.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexJSON.obj: \ + ../lexers/LexJSON.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexKix.obj: \ + ../lexers/LexKix.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexKVIrc.obj: \ + ../lexers/LexKVIrc.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexLaTeX.obj: \ + ../lexers/LexLaTeX.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h \ + ../lexlib/LexerBase.h +$(DIR_O)/LexLisp.obj: \ + ../lexers/LexLisp.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexLout.obj: \ + ../lexers/LexLout.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexLua.obj: \ + ../lexers/LexLua.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMagik.obj: \ + ../lexers/LexMagik.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMake.obj: \ + ../lexers/LexMake.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMarkdown.obj: \ + ../lexers/LexMarkdown.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMatlab.obj: \ + ../lexers/LexMatlab.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMaxima.obj: \ + ../lexers/LexMaxima.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMetapost.obj: \ + ../lexers/LexMetapost.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMMIXAL.obj: \ + ../lexers/LexMMIXAL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexModula.obj: \ + ../lexers/LexModula.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMPT.obj: \ + ../lexers/LexMPT.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMSSQL.obj: \ + ../lexers/LexMSSQL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexMySQL.obj: \ + ../lexers/LexMySQL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexNim.obj: \ + ../lexers/LexNim.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexNimrod.obj: \ + ../lexers/LexNimrod.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexNsis.obj: \ + ../lexers/LexNsis.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexNull.obj: \ + ../lexers/LexNull.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexOpal.obj: \ + ../lexers/LexOpal.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexOScript.obj: \ + ../lexers/LexOScript.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexPascal.obj: \ + ../lexers/LexPascal.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexPB.obj: \ + ../lexers/LexPB.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexPerl.obj: \ + ../lexers/LexPerl.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexPLM.obj: \ + ../lexers/LexPLM.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexPO.obj: \ + ../lexers/LexPO.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexPOV.obj: \ + ../lexers/LexPOV.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexPowerPro.obj: \ + ../lexers/LexPowerPro.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexPowerShell.obj: \ + ../lexers/LexPowerShell.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexProgress.obj: \ + ../lexers/LexProgress.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SparseState.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexProps.obj: \ + ../lexers/LexProps.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexPS.obj: \ + ../lexers/LexPS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexPython.obj: \ + ../lexers/LexPython.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/StringCopy.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SubStyles.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexR.obj: \ + ../lexers/LexR.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexRebol.obj: \ + ../lexers/LexRebol.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexRegistry.obj: \ + ../lexers/LexRegistry.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexRuby.obj: \ + ../lexers/LexRuby.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexRust.obj: \ + ../lexers/LexRust.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/PropSetSimple.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexSAS.obj: \ + ../lexers/LexSAS.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexScriptol.obj: \ + ../lexers/LexScriptol.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexSmalltalk.obj: \ + ../lexers/LexSmalltalk.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexSML.obj: \ + ../lexers/LexSML.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexSorcus.obj: \ + ../lexers/LexSorcus.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexSpecman.obj: \ + ../lexers/LexSpecman.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexSpice.obj: \ + ../lexers/LexSpice.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexSQL.obj: \ + ../lexers/LexSQL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SparseState.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexStata.obj: \ + ../lexers/LexStata.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexSTTXT.obj: \ + ../lexers/LexSTTXT.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexTACL.obj: \ + ../lexers/LexTACL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexTADS3.obj: \ + ../lexers/LexTADS3.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexTAL.obj: \ + ../lexers/LexTAL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexTCL.obj: \ + ../lexers/LexTCL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexTCMD.obj: \ + ../lexers/LexTCMD.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexTeX.obj: \ + ../lexers/LexTeX.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexTxt2tags.obj: \ + ../lexers/LexTxt2tags.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexVB.obj: \ + ../lexers/LexVB.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexVerilog.obj: \ + ../lexers/LexVerilog.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/SubStyles.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexVHDL.obj: \ + ../lexers/LexVHDL.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h +$(DIR_O)/LexVisualProlog.obj: \ + ../lexers/LexVisualProlog.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/CharacterCategory.h \ + ../lexlib/LexerModule.h \ + ../lexlib/OptionSet.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexX12.obj: \ + ../lexers/LexX12.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/LexerModule.h \ + ../lexlib/DefaultLexer.h +$(DIR_O)/LexYAML.obj: \ + ../lexers/LexYAML.cxx \ + ../include/ILexer.h \ + ../include/Sci_Position.h \ + ../include/Scintilla.h \ + ../include/SciLexer.h \ + ../lexlib/WordList.h \ + ../lexlib/LexAccessor.h \ + ../lexlib/Accessor.h \ + ../lexlib/StyleContext.h \ + ../lexlib/CharacterSet.h \ + ../lexlib/LexerModule.h diff --git a/dep/scintilla/scintilla-3.10.6/win32/scintilla.mak b/dep/scintilla/scintilla-3.10.6/win32/scintilla.mak new file mode 100644 index 00000000..49ae58a2 --- /dev/null +++ b/dep/scintilla/scintilla-3.10.6/win32/scintilla.mak @@ -0,0 +1,282 @@ +# Make file for Scintilla on Windows Visual C++ version +# Copyright 1998-2010 by Neil Hodgson +# The License.txt file describes the conditions under which this software may be distributed. +# This makefile is for using Visual C++ with nmake. +# Usage for Microsoft: +# nmake -f scintilla.mak +# For debug versions define DEBUG on the command line: +# nmake DEBUG=1 -f scintilla.mak +# The main makefile uses mingw32 gcc and may be more current than this file. + +.SUFFIXES: .cxx + +DIR_O=. +DIR_BIN=..\bin + +COMPONENT=$(DIR_BIN)\Scintilla.dll +LEXCOMPONENT=$(DIR_BIN)\SciLexer.dll +LIBSCI=$(DIR_BIN)\libscintilla.lib + +LD=link + +!IFDEF SUPPORT_XP +XP_DEFINE=-D_USING_V110_SDK71_ +XP_LINK=-SUBSYSTEM:WINDOWS,5.01 +!ENDIF + +CRTFLAGS=-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1 -D_CRT_SECURE_NO_DEPRECATE=1 -D_SCL_SECURE_NO_WARNINGS=1 $(XP_DEFINE) +CXXFLAGS=-Zi -TP -MP -W4 -EHsc $(CRTFLAGS) +CXXDEBUG=-Od -MTd -DDEBUG +CXXNDEBUG=-O1 -MT -DNDEBUG -GL +NAME=-Fo +LDFLAGS=-OPT:REF -LTCG -IGNORE:4197 -DEBUG $(XP_LINK) +LDDEBUG= +LIBS=KERNEL32.lib USER32.lib GDI32.lib IMM32.lib OLE32.lib OLEAUT32.lib MSIMG32.lib +NOLOGO=-nologo + +!IFDEF QUIET +CXX=@$(CXX) +CXXFLAGS=$(CXXFLAGS) $(NOLOGO) +LDFLAGS=$(LDFLAGS) $(NOLOGO) +!ENDIF + +!IFDEF NO_CXX11_REGEX +CXXFLAGS=$(CXXFLAGS) -DNO_CXX11_REGEX +!ENDIF + +!IFDEF DEBUG +CXXFLAGS=$(CXXFLAGS) $(CXXDEBUG) +LDFLAGS=$(LDDEBUG) $(LDFLAGS) +!ELSE +CXXFLAGS=$(CXXFLAGS) $(CXXNDEBUG) +!ENDIF + +INCLUDEDIRS=-I../include -I../src -I../lexlib +CXXFLAGS=$(CXXFLAGS) $(INCLUDEDIRS) + +all: $(COMPONENT) $(LEXCOMPONENT) $(LIBSCI) + +clean: + -del /q $(DIR_O)\*.obj $(DIR_O)\*.pdb $(DIR_O)\*.asm $(COMPONENT) $(LEXCOMPONENT) \ + $(DIR_O)\*.res $(DIR_BIN)\*.map $(DIR_BIN)\*.exp $(DIR_BIN)\*.pdb $(DIR_BIN)\*.lib + +depend: + python DepGen.py + +# Required for base Scintilla +BASEOBJS=\ + $(DIR_O)\AutoComplete.obj \ + $(DIR_O)\CallTip.obj \ + $(DIR_O)\CaseConvert.obj \ + $(DIR_O)\CaseFolder.obj \ + $(DIR_O)\CellBuffer.obj \ + $(DIR_O)\CharacterCategory.obj \ + $(DIR_O)\CharacterSet.obj \ + $(DIR_O)\CharClassify.obj \ + $(DIR_O)\ContractionState.obj \ + $(DIR_O)\DBCS.obj \ + $(DIR_O)\Decoration.obj \ + $(DIR_O)\Document.obj \ + $(DIR_O)\EditModel.obj \ + $(DIR_O)\Editor.obj \ + $(DIR_O)\EditView.obj \ + $(DIR_O)\Indicator.obj \ + $(DIR_O)\KeyMap.obj \ + $(DIR_O)\LineMarker.obj \ + $(DIR_O)\MarginView.obj \ + $(DIR_O)\PerLine.obj \ + $(DIR_O)\PlatWin.obj \ + $(DIR_O)\PositionCache.obj \ + $(DIR_O)\PropSetSimple.obj \ + $(DIR_O)\RESearch.obj \ + $(DIR_O)\RunStyles.obj \ + $(DIR_O)\Selection.obj \ + $(DIR_O)\Style.obj \ + $(DIR_O)\UniConversion.obj \ + $(DIR_O)\UniqueString.obj \ + $(DIR_O)\ViewStyle.obj \ + $(DIR_O)\XPM.obj \ + $(DIR_O)\HanjaDic.obj \ + +SOBJS=\ + $(BASEOBJS) \ + $(DIR_O)\ScintillaBase.obj \ + $(DIR_O)\ScintillaWin.obj \ + $(DIR_O)\ScintillaDLL.obj + +#++Autogenerated -- run scripts/LexGen.py to regenerate +#**LEXOBJS=\\\n\(\t$(DIR_O)\\\*.obj \\\n\) +LEXOBJS=\ + $(DIR_O)\LexA68k.obj \ + $(DIR_O)\LexAbaqus.obj \ + $(DIR_O)\LexAda.obj \ + $(DIR_O)\LexAPDL.obj \ + $(DIR_O)\LexAsm.obj \ + $(DIR_O)\LexAsn1.obj \ + $(DIR_O)\LexASY.obj \ + $(DIR_O)\LexAU3.obj \ + $(DIR_O)\LexAVE.obj \ + $(DIR_O)\LexAVS.obj \ + $(DIR_O)\LexBaan.obj \ + $(DIR_O)\LexBash.obj \ + $(DIR_O)\LexBasic.obj \ + $(DIR_O)\LexBatch.obj \ + $(DIR_O)\LexBibTeX.obj \ + $(DIR_O)\LexBullant.obj \ + $(DIR_O)\LexCaml.obj \ + $(DIR_O)\LexCIL.obj \ + $(DIR_O)\LexCLW.obj \ + $(DIR_O)\LexCmake.obj \ + $(DIR_O)\LexCOBOL.obj \ + $(DIR_O)\LexCoffeeScript.obj \ + $(DIR_O)\LexConf.obj \ + $(DIR_O)\LexCPP.obj \ + $(DIR_O)\LexCrontab.obj \ + $(DIR_O)\LexCsound.obj \ + $(DIR_O)\LexCSS.obj \ + $(DIR_O)\LexD.obj \ + $(DIR_O)\LexDiff.obj \ + $(DIR_O)\LexDMAP.obj \ + $(DIR_O)\LexDMIS.obj \ + $(DIR_O)\LexECL.obj \ + $(DIR_O)\LexEDIFACT.obj \ + $(DIR_O)\LexEiffel.obj \ + $(DIR_O)\LexErlang.obj \ + $(DIR_O)\LexErrorList.obj \ + $(DIR_O)\LexEScript.obj \ + $(DIR_O)\LexFlagship.obj \ + $(DIR_O)\LexForth.obj \ + $(DIR_O)\LexFortran.obj \ + $(DIR_O)\LexGAP.obj \ + $(DIR_O)\LexGui4Cli.obj \ + $(DIR_O)\LexHaskell.obj \ + $(DIR_O)\LexHex.obj \ + $(DIR_O)\LexHTML.obj \ + $(DIR_O)\LexIndent.obj \ + $(DIR_O)\LexInno.obj \ + $(DIR_O)\LexJSON.obj \ + $(DIR_O)\LexKix.obj \ + $(DIR_O)\LexKVIrc.obj \ + $(DIR_O)\LexLaTeX.obj \ + $(DIR_O)\LexLisp.obj \ + $(DIR_O)\LexLout.obj \ + $(DIR_O)\LexLPeg.obj \ + $(DIR_O)\LexLua.obj \ + $(DIR_O)\LexMagik.obj \ + $(DIR_O)\LexMake.obj \ + $(DIR_O)\LexMarkdown.obj \ + $(DIR_O)\LexMatlab.obj \ + $(DIR_O)\LexMaxima.obj \ + $(DIR_O)\LexMetapost.obj \ + $(DIR_O)\LexMMIXAL.obj \ + $(DIR_O)\LexModula.obj \ + $(DIR_O)\LexMPT.obj \ + $(DIR_O)\LexMSSQL.obj \ + $(DIR_O)\LexMySQL.obj \ + $(DIR_O)\LexNim.obj \ + $(DIR_O)\LexNimrod.obj \ + $(DIR_O)\LexNsis.obj \ + $(DIR_O)\LexNull.obj \ + $(DIR_O)\LexOpal.obj \ + $(DIR_O)\LexOScript.obj \ + $(DIR_O)\LexPascal.obj \ + $(DIR_O)\LexPB.obj \ + $(DIR_O)\LexPerl.obj \ + $(DIR_O)\LexPLM.obj \ + $(DIR_O)\LexPO.obj \ + $(DIR_O)\LexPOV.obj \ + $(DIR_O)\LexPowerPro.obj \ + $(DIR_O)\LexPowerShell.obj \ + $(DIR_O)\LexProgress.obj \ + $(DIR_O)\LexProps.obj \ + $(DIR_O)\LexPS.obj \ + $(DIR_O)\LexPython.obj \ + $(DIR_O)\LexR.obj \ + $(DIR_O)\LexRebol.obj \ + $(DIR_O)\LexRegistry.obj \ + $(DIR_O)\LexRuby.obj \ + $(DIR_O)\LexRust.obj \ + $(DIR_O)\LexSAS.obj \ + $(DIR_O)\LexScriptol.obj \ + $(DIR_O)\LexSmalltalk.obj \ + $(DIR_O)\LexSML.obj \ + $(DIR_O)\LexSorcus.obj \ + $(DIR_O)\LexSpecman.obj \ + $(DIR_O)\LexSpice.obj \ + $(DIR_O)\LexSQL.obj \ + $(DIR_O)\LexStata.obj \ + $(DIR_O)\LexSTTXT.obj \ + $(DIR_O)\LexTACL.obj \ + $(DIR_O)\LexTADS3.obj \ + $(DIR_O)\LexTAL.obj \ + $(DIR_O)\LexTCL.obj \ + $(DIR_O)\LexTCMD.obj \ + $(DIR_O)\LexTeX.obj \ + $(DIR_O)\LexTxt2tags.obj \ + $(DIR_O)\LexVB.obj \ + $(DIR_O)\LexVerilog.obj \ + $(DIR_O)\LexVHDL.obj \ + $(DIR_O)\LexVisualProlog.obj \ + $(DIR_O)\LexX12.obj \ + $(DIR_O)\LexYAML.obj \ + +#--Autogenerated -- end of automatically generated section + +# Required by lexers +LEXLIBOBJS=\ + $(DIR_O)\Accessor.obj \ + $(DIR_O)\Catalogue.obj \ + $(DIR_O)\ExternalLexer.obj \ + $(DIR_O)\DefaultLexer.obj \ + $(DIR_O)\LexerBase.obj \ + $(DIR_O)\LexerModule.obj \ + $(DIR_O)\LexerSimple.obj \ + $(DIR_O)\StyleContext.obj \ + $(DIR_O)\WordList.obj \ + +# Required by libraries and DLLs that include lexing +SCILEXOBJS=\ + $(BASEOBJS) \ + $(LEXLIBOBJS) \ + $(LEXOBJS) \ + $(DIR_O)\ScintillaBaseL.obj + +$(DIR_O)\ScintRes.res : ScintRes.rc + $(RC) -fo$@ $** + +$(COMPONENT): $(SOBJS) $(DIR_O)\ScintRes.res + $(LD) $(LDFLAGS) -DEF:Scintilla.def -DLL -OUT:$@ $** $(LIBS) + +$(LEXCOMPONENT): $(SCILEXOBJS) $(DIR_O)\ScintillaDLL.obj $(DIR_O)\ScintillaWinL.obj $(DIR_O)\ScintRes.res + $(LD) $(LDFLAGS) -DEF:Scintilla.def -DLL -OUT:$@ $** $(LIBS) + +$(LIBSCI): $(SCILEXOBJS) $(DIR_O)\ScintillaWin.obj + LIB /OUT:$@ $** + +# Define how to build all the objects and what they depend on + +{..\src}.cxx{$(DIR_O)}.obj:: + $(CXX) $(CXXFLAGS) -c $(NAME)$(DIR_O)\ $< +{..\lexlib}.cxx{$(DIR_O)}.obj:: + $(CXX) $(CXXFLAGS) -c $(NAME)$(DIR_O)\ $< +{..\lexers}.cxx{$(DIR_O)}.obj:: + $(CXX) $(CXXFLAGS) -c $(NAME)$(DIR_O)\ $< +{.}.cxx{$(DIR_O)}.obj:: + $(CXX) $(CXXFLAGS) -c $(NAME)$(DIR_O)\ $< + +# Some source files are compiled into more than one object because of different conditional compilation +$(DIR_O)\ScintillaBaseL.obj: ..\src\ScintillaBase.cxx + $(CXX) $(CXXFLAGS) -DSCI_LEXER -c $(NAME)$@ ..\src\ScintillaBase.cxx + +$(DIR_O)\ScintillaWinL.obj: ScintillaWin.cxx + $(CXX) $(CXXFLAGS) -DSCI_LEXER -c $(NAME)$@ ScintillaWin.cxx + +# Dependencies + +!IF EXISTS(nmdeps.mak) + +# Protect with !IF EXISTS to handle accidental deletion - just 'nmake -f scintilla.mak deps' + +!INCLUDE nmdeps.mak + +!ENDIF diff --git a/dep/scintilla/scintilla-3.6.0/zipsrc.bat b/dep/scintilla/scintilla-3.10.6/zipsrc.bat similarity index 100% rename from dep/scintilla/scintilla-3.6.0/zipsrc.bat rename to dep/scintilla/scintilla-3.10.6/zipsrc.bat diff --git a/dep/scintilla/scintilla-3.6.0/.hg_archival.txt b/dep/scintilla/scintilla-3.6.0/.hg_archival.txt deleted file mode 100644 index ea07f98b..00000000 --- a/dep/scintilla/scintilla-3.6.0/.hg_archival.txt +++ /dev/null @@ -1,4 +0,0 @@ -repo: bdf8c3ef2fb01ea24578e726337888e706d10b92 -node: 87a4e0fa293ec1dc47d9d4d4288a139a5e240c6f -branch: default -tag: rel-3-6-0 diff --git a/dep/scintilla/scintilla-3.6.0/License.txt b/dep/scintilla/scintilla-3.6.0/License.txt deleted file mode 100644 index cbe25b2f..00000000 --- a/dep/scintilla/scintilla-3.6.0/License.txt +++ /dev/null @@ -1,20 +0,0 @@ -License for Scintilla and SciTE - -Copyright 1998-2003 by Neil Hodgson - -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. - -NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE -OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/English.lproj/MainMenu.xib b/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/English.lproj/MainMenu.xib deleted file mode 100644 index e2d93cca..00000000 --- a/dep/scintilla/scintilla-3.6.0/cocoa/ScintillaTest/English.lproj/MainMenu.xib +++ /dev/null @@ -1,3992 +0,0 @@ - - - - 1050 - 10D573 - 762 - 1038.29 - 460.00 - - com.apple.InterfaceBuilder.CocoaPlugin - 762 - - - YES - - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - - - YES - - YES - - - YES - - - - YES - - NSApplication - - - FirstResponder - - - NSApplication - - - AMainMenu - - YES - - - NewApplication - - 1048576 - 2147483647 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - - submenuAction: - - NewApplication - - YES - - - About NewApplication - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Preferences… - , - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Services - - 1048576 - 2147483647 - - - submenuAction: - - Services - - YES - - _NSServicesMenu - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Hide NewApplication - h - 1048576 - 2147483647 - - - - - - Hide Others - h - 1572864 - 2147483647 - - - - - - Show All - - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Quit NewApplication - q - 1048576 - 2147483647 - - - - - _NSAppleMenu - - - - - File - - 1048576 - 2147483647 - - - submenuAction: - - File - - YES - - - New - n - 1048576 - 2147483647 - - - - - - Open… - o - 1048576 - 2147483647 - - - - - - Open Recent - - 1048576 - 2147483647 - - - submenuAction: - - Open Recent - - YES - - - Clear Menu - - 1048576 - 2147483647 - - - - - _NSRecentDocumentsMenu - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Close - w - 1048576 - 2147483647 - - - - - - Save - s - 1048576 - 2147483647 - - - - - - Save As… - S - 1179648 - 2147483647 - - - - - - Revert to Saved - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Page Setup... - P - 1179648 - 2147483647 - - - - - - - Print… - p - 1048576 - 2147483647 - - - - - - - - - Edit - - 1048576 - 2147483647 - - - submenuAction: - - Edit - - YES - - - Undo - z - 1048576 - 2147483647 - - - - - - Redo - Z - 1179648 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Cut - x - 1048576 - 2147483647 - - - - - - Copy - c - 1048576 - 2147483647 - - - - - - Paste - v - 1048576 - 2147483647 - - - - - - Delete - - 1048576 - 2147483647 - - - - - - Select All - a - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Find - - 1048576 - 2147483647 - - - submenuAction: - - Find - - YES - - - Find… - f - 1048576 - 2147483647 - - - 1 - - - - Find Next - g - 1048576 - 2147483647 - - - 2 - - - - Find Previous - G - 1179648 - 2147483647 - - - 3 - - - - Use Selection for Find - e - 1048576 - 2147483647 - - - 7 - - - - Jump to Selection - j - 1048576 - 2147483647 - - - - - - - - - Spelling and Grammar - - 1048576 - 2147483647 - - - submenuAction: - - Spelling and Grammar - - YES - - - Show Spelling… - : - 1048576 - 2147483647 - - - - - - Check Spelling - ; - 1048576 - 2147483647 - - - - - - Check Spelling While Typing - - 1048576 - 2147483647 - - - - - - Check Grammar With Spelling - - 1048576 - 2147483647 - - - - - - - - - Substitutions - - 1048576 - 2147483647 - - - submenuAction: - - Substitutions - - YES - - - Smart Copy/Paste - f - 1048576 - 2147483647 - - - 1 - - - - Smart Quotes - g - 1048576 - 2147483647 - - - 2 - - - - Smart Links - G - 1179648 - 2147483647 - - - 3 - - - - - - - Speech - - 1048576 - 2147483647 - - - submenuAction: - - Speech - - YES - - - Start Speaking - - 1048576 - 2147483647 - - - - - - Stop Speaking - - 1048576 - 2147483647 - - - - - - - - - - - - Format - - 2147483647 - - - submenuAction: - - Format - - YES - - - Font - - 2147483647 - - - submenuAction: - - Font - - YES - - - Show Fonts - t - 1048576 - 2147483647 - - - - - - Bold - b - 1048576 - 2147483647 - - - 2 - - - - Italic - i - 1048576 - 2147483647 - - - 1 - - - - Underline - u - 1048576 - 2147483647 - - - - - - YES - YES - - - 2147483647 - - - - - - Bigger - + - 1048576 - 2147483647 - - - 3 - - - - Smaller - - - 1048576 - 2147483647 - - - 4 - - - - YES - YES - - - 2147483647 - - - - - - Kern - - 2147483647 - - - submenuAction: - - Kern - - YES - - - Use Default - - 2147483647 - - - - - - Use None - - 2147483647 - - - - - - Tighten - - 2147483647 - - - - - - Loosen - - 2147483647 - - - - - - - - - Ligature - - 2147483647 - - - submenuAction: - - Ligature - - YES - - - Use Default - - 2147483647 - - - - - - Use None - - 2147483647 - - - - - - Use All - - 2147483647 - - - - - - - - - Baseline - - 2147483647 - - - submenuAction: - - Baseline - - YES - - - Use Default - - 2147483647 - - - - - - Superscript - - 2147483647 - - - - - - Subscript - - 2147483647 - - - - - - Raise - - 2147483647 - - - - - - Lower - - 2147483647 - - - - - - - - - Font Quality - - 2147483647 - - - submenuAction: - - Font Quality - - YES - - - Default - - 2147483647 - - - - - - Non-antialiased - - 2147483647 - - - 1 - - - - Antialiased - - 2147483647 - - - 2 - - - - LCD Optimized - - 2147483647 - - - 3 - - - - - - - YES - YES - - - 2147483647 - - - - - - Show Colors - C - 1048576 - 2147483647 - - - - - - YES - YES - - - 2147483647 - - - - - - Copy Style - c - 1572864 - 2147483647 - - - - - - Paste Style - v - 1572864 - 2147483647 - - - - - _NSFontMenu - - - - - Text - - 2147483647 - - - submenuAction: - - Text - - YES - - - Align Left - { - 1048576 - 2147483647 - - - - - - Center - | - 1048576 - 2147483647 - - - - - - Justify - - 2147483647 - - - - - - Align Right - } - 1048576 - 2147483647 - - - - - - YES - YES - - - 2147483647 - - - - - - Show Ruler - - 2147483647 - - - - - - Copy Ruler - c - 1310720 - 2147483647 - - - - - - Paste Ruler - v - 1310720 - 2147483647 - - - - - - - - - - - - View - - 1048576 - 2147483647 - - - submenuAction: - - View - - YES - - - Show Toolbar - t - 1572864 - 2147483647 - - - - - - Customize Toolbar… - - 1048576 - 2147483647 - - - - - - - - - Window - - 1048576 - 2147483647 - - - submenuAction: - - Window - - YES - - - Minimize - m - 1048576 - 2147483647 - - - - - - Zoom - - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Bring All to Front - - 1048576 - 2147483647 - - - - - _NSWindowsMenu - - - - - Help - - 1048576 - 2147483647 - - - submenuAction: - - Help - - YES - - - NewApplication Help - ? - 1048576 - 2147483647 - - - - - - - - _NSMainMenu - - - 15 - 2 - {{335, 58}, {982, 692}} - 1946157056 - Window - NSWindow - - {1.79769e+308, 1.79769e+308} - - - 319 - - YES - - - 18 - - YES - - - 256 - {{1, 1}, {842, 590}} - - - - {{17, 16}, {844, 606}} - - {0, 0} - - 67239424 - 0 - Scintilla Editor - - LucidaGrande - 11 - 3100 - - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 3 - MCAwLjgwMDAwMDAxAA - - - - 1 - 0 - 2 - NO - - - - 289 - {{872, 12}, {96, 32}} - - YES - - 67239424 - 134217728 - Quit - - LucidaGrande - 13 - 1044 - - - -2038284033 - 129 - - - 200 - 25 - - - - - 268 - {{20, 630}, {287, 22}} - - YES - - 343014976 - 268436480 - - - - YES - 1 - - - 6 - System - controlTextColor - - 3 - MAA - - - - 130560 - 0 - search - - _searchFieldSearch: - - 138690815 - 0 - - 400 - 75 - - - 130560 - 0 - clear - - YES - - YES - - YES - AXDescription - NSAccessibilityEncodedAttributesValueType - - - YES - cancel - - - - - - _searchFieldCancel: - - 138690815 - 0 - - 400 - 75 - - 255 - - - - {982, 692} - - - {{0, 0}, {1440, 878}} - {1.79769e+308, 1.79769e+308} - - - NSFontManager - - - AppController - - - - - YES - - - performMiniaturize: - - - - 37 - - - - arrangeInFront: - - - - 39 - - - - print: - - - - 86 - - - - runPageLayout: - - - - 87 - - - - clearRecentDocuments: - - - - 127 - - - - orderFrontStandardAboutPanel: - - - - 142 - - - - performClose: - - - - 193 - - - - toggleContinuousSpellChecking: - - - - 222 - - - - undo: - - - - 223 - - - - copy: - - - - 224 - - - - checkSpelling: - - - - 225 - - - - paste: - - - - 226 - - - - stopSpeaking: - - - - 227 - - - - cut: - - - - 228 - - - - showGuessPanel: - - - - 230 - - - - redo: - - - - 231 - - - - selectAll: - - - - 232 - - - - startSpeaking: - - - - 233 - - - - delete: - - - - 235 - - - - performZoom: - - - - 240 - - - - performFindPanelAction: - - - - 241 - - - - centerSelectionInVisibleArea: - - - - 245 - - - - toggleGrammarChecking: - - - - 347 - - - - toggleSmartInsertDelete: - - - - 355 - - - - toggleAutomaticQuoteSubstitution: - - - - 356 - - - - toggleAutomaticLinkDetection: - - - - 357 - - - - showHelp: - - - - 360 - - - - saveDocument: - - - - 362 - - - - saveDocumentAs: - - - - 363 - - - - revertDocumentToSaved: - - - - 364 - - - - runToolbarCustomizationPalette: - - - - 365 - - - - toggleToolbarShown: - - - - 366 - - - - hide: - - - - 367 - - - - hideOtherApplications: - - - - 368 - - - - unhideAllApplications: - - - - 370 - - - - newDocument: - - - - 373 - - - - openDocument: - - - - 374 - - - - addFontTrait: - - - - 421 - - - - addFontTrait: - - - - 422 - - - - modifyFont: - - - - 423 - - - - orderFrontFontPanel: - - - - 424 - - - - modifyFont: - - - - 425 - - - - raiseBaseline: - - - - 426 - - - - lowerBaseline: - - - - 427 - - - - copyFont: - - - - 428 - - - - subscript: - - - - 429 - - - - superscript: - - - - 430 - - - - tightenKerning: - - - - 431 - - - - underline: - - - - 432 - - - - orderFrontColorPanel: - - - - 433 - - - - useAllLigatures: - - - - 434 - - - - loosenKerning: - - - - 435 - - - - pasteFont: - - - - 436 - - - - unscript: - - - - 437 - - - - useStandardKerning: - - - - 438 - - - - useStandardLigatures: - - - - 439 - - - - turnOffLigatures: - - - - 440 - - - - turnOffKerning: - - - - 441 - - - - alignLeft: - - - - 442 - - - - alignJustified: - - - - 443 - - - - copyRuler: - - - - 444 - - - - alignCenter: - - - - 445 - - - - toggleRuler: - - - - 446 - - - - alignRight: - - - - 447 - - - - pasteRuler: - - - - 448 - - - - terminate: - - - - 449 - - - - mEditHost - - - - 454 - - - - terminate: - - - - 455 - - - - searchText: - - - - 468 - - - - setFontQuality: - - - - 475 - - - - setFontQuality: - - - - 476 - - - - setFontQuality: - - - - 477 - - - - setFontQuality: - - - - 478 - - - - - YES - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 29 - - - YES - - - - - - - - - - MainMenu - - - 19 - - - YES - - - - - - 56 - - - YES - - - - - - 103 - - - YES - - - - 1 - - - 217 - - - YES - - - - - - 83 - - - YES - - - - - - 81 - - - YES - - - - - - - - - - - - - - - - 75 - - - 3 - - - 80 - - - 8 - - - 78 - - - 6 - - - 72 - - - - - 82 - - - 9 - - - 124 - - - YES - - - - - - 77 - - - 5 - - - 73 - - - 1 - - - 79 - - - 7 - - - 112 - - - 10 - - - 74 - - - 2 - - - 125 - - - YES - - - - - - 126 - - - - - 205 - - - YES - - - - - - - - - - - - - - - - - - 202 - - - - - 198 - - - - - 207 - - - - - 214 - - - - - 199 - - - - - 203 - - - - - 197 - - - - - 206 - - - - - 215 - - - - - 218 - - - YES - - - - - - 216 - - - YES - - - - - - 200 - - - YES - - - - - - - - - 219 - - - - - 201 - - - - - 204 - - - - - 220 - - - YES - - - - - - - - - - 213 - - - - - 210 - - - - - 221 - - - - - 208 - - - - - 209 - - - - - 106 - - - YES - - - - 2 - - - 111 - - - - - 57 - - - YES - - - - - - - - - - - - - - - - 58 - - - - - 134 - - - - - 150 - - - - - 136 - - - 1111 - - - 144 - - - - - 129 - - - 121 - - - 143 - - - - - 236 - - - - - 131 - - - YES - - - - - - 149 - - - - - 145 - - - - - 130 - - - - - 24 - - - YES - - - - - - - - - 92 - - - - - 5 - - - - - 239 - - - - - 23 - - - - - 295 - - - YES - - - - - - 296 - - - YES - - - - - - - 297 - - - - - 298 - - - - - 211 - - - YES - - - - - - 212 - - - YES - - - - - - - 195 - - - - - 196 - - - - - 346 - - - - - 348 - - - YES - - - - - - 349 - - - YES - - - - - - - - 350 - - - - - 351 - - - - - 354 - - - - - 371 - - - YES - - - - - - 372 - - - YES - - - - - - - - 375 - - - YES - - - - - - 376 - - - YES - - - - - - - 377 - - - YES - - - - - - 378 - - - YES - - - - - - 379 - - - YES - - - - - - - - - - - - - 380 - - - - - 381 - - - - - 382 - - - - - 383 - - - - - 384 - - - - - 385 - - - - - 386 - - - - - 387 - - - - - 388 - - - YES - - - - - - - - - - - - - - - - - - - - - - 389 - - - - - 390 - - - - - 391 - - - - - 392 - - - - - 393 - - - - - 394 - - - - - 395 - - - - - 396 - - - - - 397 - - - YES - - - - - - 398 - - - YES - - - - - - 399 - - - YES - - - - - - 400 - - - - - 401 - - - - - 402 - - - - - 403 - - - - - 404 - - - - - 405 - - - YES - - - - - - - - - - 406 - - - - - 407 - - - - - 408 - - - - - 409 - - - - - 410 - - - - - 411 - - - YES - - - - - - - - 412 - - - - - 413 - - - - - 414 - - - - - 415 - - - YES - - - - - - - - - 416 - - - - - 417 - - - - - 418 - - - - - 419 - - - - - 420 - - - - - 450 - - - - - 451 - - - - - 452 - - - YES - - - - - - 453 - - - - - 466 - - - YES - - - - - - 467 - - - - - 469 - - - YES - - - - - - 470 - - - YES - - - - - - - - - 471 - - - - - 472 - - - - - 473 - - - - - 474 - - - - - - - YES - - YES - -3.IBPluginDependency - 103.IBPluginDependency - 103.ImportedFromIB2 - 106.IBPluginDependency - 106.ImportedFromIB2 - 106.editorWindowContentRectSynchronizationRect - 111.IBPluginDependency - 111.ImportedFromIB2 - 112.IBPluginDependency - 112.ImportedFromIB2 - 124.IBPluginDependency - 124.ImportedFromIB2 - 125.IBPluginDependency - 125.ImportedFromIB2 - 125.editorWindowContentRectSynchronizationRect - 126.IBPluginDependency - 126.ImportedFromIB2 - 129.IBPluginDependency - 129.ImportedFromIB2 - 130.IBPluginDependency - 130.ImportedFromIB2 - 130.editorWindowContentRectSynchronizationRect - 131.IBPluginDependency - 131.ImportedFromIB2 - 134.IBPluginDependency - 134.ImportedFromIB2 - 136.IBPluginDependency - 136.ImportedFromIB2 - 143.IBPluginDependency - 143.ImportedFromIB2 - 144.IBPluginDependency - 144.ImportedFromIB2 - 145.IBPluginDependency - 145.ImportedFromIB2 - 149.IBPluginDependency - 149.ImportedFromIB2 - 150.IBPluginDependency - 150.ImportedFromIB2 - 19.IBPluginDependency - 19.ImportedFromIB2 - 195.IBPluginDependency - 195.ImportedFromIB2 - 196.IBPluginDependency - 196.ImportedFromIB2 - 197.IBPluginDependency - 197.ImportedFromIB2 - 198.IBPluginDependency - 198.ImportedFromIB2 - 199.IBPluginDependency - 199.ImportedFromIB2 - 200.IBPluginDependency - 200.ImportedFromIB2 - 200.editorWindowContentRectSynchronizationRect - 201.IBPluginDependency - 201.ImportedFromIB2 - 202.IBPluginDependency - 202.ImportedFromIB2 - 203.IBPluginDependency - 203.ImportedFromIB2 - 204.IBPluginDependency - 204.ImportedFromIB2 - 205.IBPluginDependency - 205.ImportedFromIB2 - 205.editorWindowContentRectSynchronizationRect - 206.IBPluginDependency - 206.ImportedFromIB2 - 207.IBPluginDependency - 207.ImportedFromIB2 - 208.IBPluginDependency - 208.ImportedFromIB2 - 209.IBPluginDependency - 209.ImportedFromIB2 - 210.IBPluginDependency - 210.ImportedFromIB2 - 211.IBPluginDependency - 211.ImportedFromIB2 - 212.IBPluginDependency - 212.ImportedFromIB2 - 212.editorWindowContentRectSynchronizationRect - 213.IBPluginDependency - 213.ImportedFromIB2 - 214.IBPluginDependency - 214.ImportedFromIB2 - 215.IBPluginDependency - 215.ImportedFromIB2 - 216.IBPluginDependency - 216.ImportedFromIB2 - 217.IBPluginDependency - 217.ImportedFromIB2 - 218.IBPluginDependency - 218.ImportedFromIB2 - 219.IBPluginDependency - 219.ImportedFromIB2 - 220.IBPluginDependency - 220.ImportedFromIB2 - 220.editorWindowContentRectSynchronizationRect - 221.IBPluginDependency - 221.ImportedFromIB2 - 23.IBPluginDependency - 23.ImportedFromIB2 - 236.IBPluginDependency - 236.ImportedFromIB2 - 239.IBPluginDependency - 239.ImportedFromIB2 - 24.IBPluginDependency - 24.ImportedFromIB2 - 24.editorWindowContentRectSynchronizationRect - 29.IBEditorWindowLastContentRect - 29.IBPluginDependency - 29.ImportedFromIB2 - 29.WindowOrigin - 29.editorWindowContentRectSynchronizationRect - 295.IBPluginDependency - 296.IBPluginDependency - 296.editorWindowContentRectSynchronizationRect - 297.IBPluginDependency - 298.IBPluginDependency - 346.IBPluginDependency - 346.ImportedFromIB2 - 348.IBPluginDependency - 348.ImportedFromIB2 - 349.IBPluginDependency - 349.ImportedFromIB2 - 349.editorWindowContentRectSynchronizationRect - 350.IBPluginDependency - 350.ImportedFromIB2 - 351.IBPluginDependency - 351.ImportedFromIB2 - 354.IBPluginDependency - 354.ImportedFromIB2 - 371.IBEditorWindowLastContentRect - 371.IBPluginDependency - 371.IBWindowTemplateEditedContentRect - 371.NSWindowTemplate.visibleAtLaunch - 371.editorWindowContentRectSynchronizationRect - 371.windowTemplate.maxSize - 372.IBPluginDependency - 375.IBPluginDependency - 376.IBEditorWindowLastContentRect - 376.IBPluginDependency - 377.IBPluginDependency - 378.IBPluginDependency - 379.IBPluginDependency - 380.IBPluginDependency - 381.IBPluginDependency - 382.IBPluginDependency - 383.IBPluginDependency - 384.IBPluginDependency - 385.IBPluginDependency - 386.IBPluginDependency - 387.IBPluginDependency - 388.IBEditorWindowLastContentRect - 388.IBPluginDependency - 389.IBPluginDependency - 390.IBPluginDependency - 391.IBPluginDependency - 392.IBPluginDependency - 393.IBPluginDependency - 394.IBPluginDependency - 395.IBPluginDependency - 396.IBPluginDependency - 397.IBPluginDependency - 398.IBPluginDependency - 399.IBPluginDependency - 400.IBPluginDependency - 401.IBPluginDependency - 402.IBPluginDependency - 403.IBPluginDependency - 404.IBPluginDependency - 405.IBPluginDependency - 406.IBPluginDependency - 407.IBPluginDependency - 408.IBPluginDependency - 409.IBPluginDependency - 410.IBPluginDependency - 411.IBPluginDependency - 412.IBPluginDependency - 413.IBPluginDependency - 414.IBPluginDependency - 415.IBPluginDependency - 416.IBPluginDependency - 417.IBPluginDependency - 418.IBPluginDependency - 419.IBPluginDependency - 451.IBPluginDependency - 452.IBPluginDependency - 453.IBPluginDependency - 466.IBPluginDependency - 467.IBPluginDependency - 5.IBPluginDependency - 5.ImportedFromIB2 - 56.IBPluginDependency - 56.ImportedFromIB2 - 57.IBEditorWindowLastContentRect - 57.IBPluginDependency - 57.ImportedFromIB2 - 57.editorWindowContentRectSynchronizationRect - 58.IBPluginDependency - 58.ImportedFromIB2 - 72.IBPluginDependency - 72.ImportedFromIB2 - 73.IBPluginDependency - 73.ImportedFromIB2 - 74.IBPluginDependency - 74.ImportedFromIB2 - 75.IBPluginDependency - 75.ImportedFromIB2 - 77.IBPluginDependency - 77.ImportedFromIB2 - 78.IBPluginDependency - 78.ImportedFromIB2 - 79.IBPluginDependency - 79.ImportedFromIB2 - 80.IBPluginDependency - 80.ImportedFromIB2 - 81.IBPluginDependency - 81.ImportedFromIB2 - 81.editorWindowContentRectSynchronizationRect - 82.IBPluginDependency - 82.ImportedFromIB2 - 83.IBPluginDependency - 83.ImportedFromIB2 - 92.IBPluginDependency - 92.ImportedFromIB2 - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{596, 852}, {216, 23}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{522, 812}, {146, 23}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{436, 809}, {64, 6}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{608, 612}, {275, 83}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{187, 434}, {243, 243}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{608, 612}, {167, 43}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{608, 612}, {241, 103}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{525, 802}, {197, 73}} - {{207, 285}, {478, 20}} - com.apple.InterfaceBuilder.CocoaPlugin - - {74, 862} - {{6, 978}, {478, 20}} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{475, 832}, {234, 43}} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{608, 612}, {215, 63}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{274, 370}, {982, 692}} - com.apple.InterfaceBuilder.CocoaPlugin - {{274, 370}, {982, 692}} - - {{33, 99}, {480, 360}} - {3.40282e+38, 3.40282e+38} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{437, 242}, {86, 43}} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{523, 2}, {178, 283}} - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{219, 102}, {245, 183}} - com.apple.InterfaceBuilder.CocoaPlugin - - {{23, 794}, {245, 183}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - {{145, 474}, {199, 203}} - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - - - - YES - - - YES - - - - - YES - - - YES - - - - 468 - - - - YES - - AppController - NSObject - - searchText: - id - - - mEditHost - NSBox - - - IBProjectSource - AppController.h - - - - - YES - - NSActionCell - NSCell - - IBFrameworkSource - AppKit.framework/Headers/NSActionCell.h - - - - NSApplication - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSApplication.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSApplicationScripting.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSColorPanel.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSHelpManager.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSPageLayout.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSUserInterfaceItemSearching.h - - - - NSBox - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSBox.h - - - - NSBrowser - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSBrowser.h - - - - NSButton - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSButton.h - - - - NSButtonCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSButtonCell.h - - - - NSCell - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSCell.h - - - - NSControl - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSControl.h - - - - NSDocument - NSObject - - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - id - id - id - id - id - id - - - - IBFrameworkSource - AppKit.framework/Headers/NSDocument.h - - - - NSDocument - - IBFrameworkSource - AppKit.framework/Headers/NSDocumentScripting.h - - - - NSDocumentController - NSObject - - YES - - YES - clearRecentDocuments: - newDocument: - openDocument: - saveAllDocuments: - - - YES - id - id - id - id - - - - IBFrameworkSource - AppKit.framework/Headers/NSDocumentController.h - - - - NSFontManager - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontManager.h - - - - NSFormatter - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFormatter.h - - - - NSMatrix - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSMatrix.h - - - - NSMenu - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenu.h - - - - NSMenuItem - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenuItem.h - - - - NSMovieView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSMovieView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSAccessibility.h - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDictionaryController.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDragging.h - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontPanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSKeyValueBinding.h - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSNibLoading.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSOutlineView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSPasteboard.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSavePanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTableView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSToolbarItem.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSView.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSError.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFileManager.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueObserving.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyedArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObject.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObjectScripting.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSPortCoder.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSRunLoop.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptObjectSpecifiers.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptWhoseTests.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSThread.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURL.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLConnection.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLDownload.h - - - - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSInterfaceStyle.h - - - - NSResponder - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSResponder.h - - - - NSSearchField - NSTextField - - IBFrameworkSource - AppKit.framework/Headers/NSSearchField.h - - - - NSSearchFieldCell - NSTextFieldCell - - IBFrameworkSource - AppKit.framework/Headers/NSSearchFieldCell.h - - - - NSTableView - NSControl - - - - NSText - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSText.h - - - - NSTextField - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSTextField.h - - - - NSTextFieldCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSTextFieldCell.h - - - - NSTextView - NSText - - IBFrameworkSource - AppKit.framework/Headers/NSTextView.h - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSClipView.h - - - - NSView - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSRulerView.h - - - - NSView - NSResponder - - - - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSDrawer.h - - - - NSWindow - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSWindow.h - - - - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSWindowScripting.h - - - - - 0 - IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 - - - YES - ../ScintillaTest.xcodeproj - 3 - - YES - - YES - NSMenuCheckmark - NSMenuMixedState - - - YES - {9, 8} - {7, 2} - - - - diff --git a/dep/scintilla/scintilla-3.6.0/cppcheck.suppress b/dep/scintilla/scintilla-3.6.0/cppcheck.suppress deleted file mode 100644 index edbff28e..00000000 --- a/dep/scintilla/scintilla-3.6.0/cppcheck.suppress +++ /dev/null @@ -1,45 +0,0 @@ -// File to suppress cppcheck warnings for files that will not be fixed. -// Does not suppress warnings where an additional occurrence of the warning may be of interest. - -// Coding style is to use assignments in constructor when there are many -// members to initialize or the initialization is complex or has comments. -useInitializationList - -// Some non-explicit constructors are used for conversions or are private to lexers -noExplicitConstructor -noExplicitCopyMoveConstructor - -// cppcheck does not understand private methods can be called from static methods -unusedPrivateFunction:scintilla/win32/PlatWin.cxx - -// Suppress most lexer warnings since the lexers are maintained by others -useInitializationList:scintilla/lexers/LexAsm.cxx -useInitializationList:scintilla/lexers/LexBasic.cxx -noCopyConstructor:scintilla/lexers/LexBash.cxx -variableScope:scintilla/lexers/LexBash.cxx -variableScope:scintilla/lexers/LexBatch.cxx -variableScope:scintilla/lexers/LexCmake.cxx -variableScope:scintilla/lexers/LexCSS.cxx -useInitializationList:scintilla/lexers/LexD.cxx -variableScope:scintilla/lexers/LexErlang.cxx -variableScope:scintilla/lexers/LexGui4Cli.cxx -variableScope:scintilla/lexers/LexInno.cxx -variableScope:scintilla/lexers/LexLaTeX.cxx -variableScope:scintilla/lexers/LexMetapost.cxx -variableScope:scintilla/lexers/LexModula.cxx -variableScope:scintilla/lexers/LexNimrod.cxx -variableScope:scintilla/lexers/LexNsis.cxx -variableScope:scintilla/lexers/LexOpal.cxx -variableScope:scintilla/lexers/LexPB.cxx -noCopyConstructor:scintilla/lexers/LexPerl.cxx -variableScope:scintilla/lexers/LexRuby.cxx -uninitMemberVar:scintilla/lexers/LexRuby.cxx -variableScope:scintilla/lexers/LexSpecman.cxx -unreadVariable:scintilla/lexers/LexSpice.cxx -clarifyCalculation:scintilla/lexers/LexTADS3.cxx -invalidscanf:scintilla/lexers/LexTCMD.cxx -variableScope:scintilla/lexers/LexTeX.cxx -variableScope:scintilla/lexers/LexVHDL.cxx - -// Suppress everything in catch.hpp as won't be changing -*:scintilla/test/unit/catch.hpp diff --git a/dep/scintilla/scintilla-3.6.0/delbin.bat b/dep/scintilla/scintilla-3.6.0/delbin.bat deleted file mode 100755 index 6d4e91a3..00000000 --- a/dep/scintilla/scintilla-3.6.0/delbin.bat +++ /dev/null @@ -1 +0,0 @@ -del /S /Q *.a *.aps *.bsc *.dll *.dsw *.exe *.idb *.ilc *.ild *.ilf *.ilk *.ils *.lib *.map *.ncb *.obj *.o *.opt *.pdb *.plg *.res *.sbr *.tds *.exp *.tlog >NUL: diff --git a/dep/scintilla/scintilla-3.6.0/delcvs.bat b/dep/scintilla/scintilla-3.6.0/delcvs.bat deleted file mode 100755 index 6c326531..00000000 --- a/dep/scintilla/scintilla-3.6.0/delcvs.bat +++ /dev/null @@ -1 +0,0 @@ -del /S /Q .cvsignore diff --git a/dep/scintilla/scintilla-3.6.0/doc/Indicators.png b/dep/scintilla/scintilla-3.6.0/doc/Indicators.png deleted file mode 100644 index 33e31f87..00000000 Binary files a/dep/scintilla/scintilla-3.6.0/doc/Indicators.png and /dev/null differ diff --git a/dep/scintilla/scintilla-3.6.0/doc/Markers.png b/dep/scintilla/scintilla-3.6.0/doc/Markers.png deleted file mode 100644 index 6eee926e..00000000 Binary files a/dep/scintilla/scintilla-3.6.0/doc/Markers.png and /dev/null differ diff --git a/dep/scintilla/scintilla-3.6.0/doc/SciTEIco.png b/dep/scintilla/scintilla-3.6.0/doc/SciTEIco.png deleted file mode 100644 index d0cc869b..00000000 Binary files a/dep/scintilla/scintilla-3.6.0/doc/SciTEIco.png and /dev/null differ diff --git a/dep/scintilla/scintilla-3.6.0/doc/annotations.png b/dep/scintilla/scintilla-3.6.0/doc/annotations.png deleted file mode 100644 index 9d9b2470..00000000 Binary files a/dep/scintilla/scintilla-3.6.0/doc/annotations.png and /dev/null differ diff --git a/dep/scintilla/scintilla-3.6.0/doc/styledmargin.png b/dep/scintilla/scintilla-3.6.0/doc/styledmargin.png deleted file mode 100644 index 3aaf35b0..00000000 Binary files a/dep/scintilla/scintilla-3.6.0/doc/styledmargin.png and /dev/null differ diff --git a/dep/scintilla/scintilla-3.6.0/gtk/Converter.h b/dep/scintilla/scintilla-3.6.0/gtk/Converter.h deleted file mode 100644 index be530341..00000000 --- a/dep/scintilla/scintilla-3.6.0/gtk/Converter.h +++ /dev/null @@ -1,83 +0,0 @@ -// Scintilla source code edit control -// Converter.h - Encapsulation of iconv -// Copyright 2004 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef CONVERTER_H -#define CONVERTER_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -typedef GIConv ConverterHandle; -const ConverterHandle iconvhBad = (ConverterHandle)(-1); -// Since various versions of iconv can not agree on whether the src argument -// is char ** or const char ** provide a templatised adaptor. -template -size_t iconv_adaptor(size_t(*f_iconv)(ConverterHandle, T, size_t *, char **, size_t *), - ConverterHandle cd, char** src, size_t *srcleft, - char **dst, size_t *dstleft) { - return f_iconv(cd, (T)src, srcleft, dst, dstleft); -} -/** - * Encapsulate iconv safely and avoid iconv_adaptor complexity in client code. - */ -class Converter { - ConverterHandle iconvh; - void OpenHandle(const char *fullDestination, const char *charSetSource) { - iconvh = g_iconv_open(fullDestination, charSetSource); - } - bool Succeeded() const { - return iconvh != iconvhBad; - } -public: - Converter() { - iconvh = iconvhBad; - } - Converter(const char *charSetDestination, const char *charSetSource, bool transliterations) { - iconvh = iconvhBad; - Open(charSetDestination, charSetSource, transliterations); - } - ~Converter() { - Close(); - } - operator bool() const { - return Succeeded(); - } - void Open(const char *charSetDestination, const char *charSetSource, bool transliterations=true) { - Close(); - if (*charSetSource) { - // Try allowing approximate transliterations - if (transliterations) { - char fullDest[200]; - g_strlcpy(fullDest, charSetDestination, sizeof(fullDest)); - g_strlcat(fullDest, "//TRANSLIT", sizeof(fullDest)); - OpenHandle(fullDest, charSetSource); - } - if (!Succeeded()) { - // Transliterations failed so try basic name - OpenHandle(charSetDestination, charSetSource); - } - } - } - void Close() { - if (Succeeded()) { - g_iconv_close(iconvh); - iconvh = iconvhBad; - } - } - size_t Convert(char** src, size_t *srcleft, char **dst, size_t *dstleft) const { - if (!Succeeded()) { - return (size_t)(-1); - } else { - return iconv_adaptor(g_iconv, iconvh, src, srcleft, dst, dstleft); - } - } -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/gtk/deps.mak b/dep/scintilla/scintilla-3.6.0/gtk/deps.mak deleted file mode 100644 index 5b826358..00000000 --- a/dep/scintilla/scintilla-3.6.0/gtk/deps.mak +++ /dev/null @@ -1,679 +0,0 @@ -PlatGTK.o: PlatGTK.cxx \ - ../include/Scintilla.h ../include/Sci_Position.h \ - ../include/ScintillaWidget.h ../lexlib/StringCopy.h ../src/XPM.h \ - ../src/UniConversion.h Converter.h -ScintillaGTK.o: ScintillaGTK.cxx \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../include/ScintillaWidget.h ../include/SciLexer.h \ - ../lexlib/StringCopy.h ../lexlib/LexerModule.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/RunStyles.h \ - ../src/ContractionState.h ../src/CellBuffer.h ../src/CallTip.h \ - ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h \ - ../src/Style.h ../src/ViewStyle.h ../src/CharClassify.h \ - ../src/Decoration.h ../src/CaseFolder.h ../src/Document.h \ - ../src/CaseConvert.h ../src/UniConversion.h ../src/UnicodeFromUTF8.h \ - ../src/Selection.h ../src/PositionCache.h ../src/EditModel.h \ - ../src/MarginView.h ../src/EditView.h ../src/Editor.h \ - ../src/AutoComplete.h ../src/ScintillaBase.h ../src/ExternalLexer.h \ - scintilla-marshal.h Converter.h -AutoComplete.o: ../src/AutoComplete.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h \ - ../lexlib/CharacterSet.h ../src/Position.h ../src/AutoComplete.h -CallTip.o: ../src/CallTip.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../lexlib/StringCopy.h \ - ../src/Position.h ../src/CallTip.h -CaseConvert.o: ../src/CaseConvert.cxx ../lexlib/StringCopy.h \ - ../src/CaseConvert.h ../src/UniConversion.h ../src/UnicodeFromUTF8.h -CaseFolder.o: ../src/CaseFolder.cxx ../src/CaseFolder.h \ - ../src/CaseConvert.h ../src/UniConversion.h -Catalogue.o: ../src/Catalogue.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/LexerModule.h ../src/Catalogue.h -CellBuffer.o: ../src/CellBuffer.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/CellBuffer.h \ - ../src/UniConversion.h -CharClassify.o: ../src/CharClassify.cxx ../src/CharClassify.h -ContractionState.o: ../src/ContractionState.cxx ../include/Platform.h \ - ../src/Position.h ../src/SplitVector.h ../src/Partitioning.h \ - ../src/RunStyles.h ../src/ContractionState.h -Decoration.o: ../src/Decoration.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/RunStyles.h \ - ../src/Decoration.h -Document.o: ../src/Document.cxx ../include/Platform.h ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h \ - ../lexlib/CharacterSet.h ../src/Position.h ../src/SplitVector.h \ - ../src/Partitioning.h ../src/RunStyles.h ../src/CellBuffer.h \ - ../src/PerLine.h ../src/CharClassify.h ../src/Decoration.h \ - ../src/CaseFolder.h ../src/Document.h ../src/RESearch.h \ - ../src/UniConversion.h ../src/UnicodeFromUTF8.h -EditModel.o: ../src/EditModel.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../lexlib/StringCopy.h ../src/Position.h ../src/SplitVector.h \ - ../src/Partitioning.h ../src/RunStyles.h ../src/ContractionState.h \ - ../src/CellBuffer.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \ - ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/UniConversion.h ../src/Selection.h \ - ../src/PositionCache.h ../src/EditModel.h -Editor.o: ../src/Editor.cxx ../include/Platform.h ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../lexlib/StringCopy.h \ - ../src/Position.h ../src/SplitVector.h ../src/Partitioning.h \ - ../src/RunStyles.h ../src/ContractionState.h ../src/CellBuffer.h \ - ../src/PerLine.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \ - ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/UniConversion.h ../src/Selection.h \ - ../src/PositionCache.h ../src/EditModel.h ../src/MarginView.h \ - ../src/EditView.h ../src/Editor.h -EditView.o: ../src/EditView.cxx ../include/Platform.h ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../lexlib/StringCopy.h \ - ../src/Position.h ../src/SplitVector.h ../src/Partitioning.h \ - ../src/RunStyles.h ../src/ContractionState.h ../src/CellBuffer.h \ - ../src/PerLine.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \ - ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/UniConversion.h ../src/Selection.h \ - ../src/PositionCache.h ../src/EditModel.h ../src/MarginView.h \ - ../src/EditView.h -ExternalLexer.o: ../src/ExternalLexer.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../include/SciLexer.h ../lexlib/LexerModule.h ../src/Catalogue.h \ - ../src/ExternalLexer.h -Indicator.o: ../src/Indicator.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Indicator.h \ - ../src/XPM.h -KeyMap.o: ../src/KeyMap.cxx ../include/Platform.h ../include/Scintilla.h \ - ../include/Sci_Position.h ../src/KeyMap.h -LineMarker.o: ../src/LineMarker.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../lexlib/StringCopy.h \ - ../src/XPM.h ../src/LineMarker.h -MarginView.o: ../src/MarginView.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../lexlib/StringCopy.h ../src/Position.h ../src/SplitVector.h \ - ../src/Partitioning.h ../src/RunStyles.h ../src/ContractionState.h \ - ../src/CellBuffer.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \ - ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/UniConversion.h ../src/Selection.h \ - ../src/PositionCache.h ../src/EditModel.h ../src/MarginView.h \ - ../src/EditView.h -PerLine.o: ../src/PerLine.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/CellBuffer.h \ - ../src/PerLine.h -PositionCache.o: ../src/PositionCache.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../src/Position.h ../src/SplitVector.h ../src/Partitioning.h \ - ../src/RunStyles.h ../src/ContractionState.h ../src/CellBuffer.h \ - ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h \ - ../src/Style.h ../src/ViewStyle.h ../src/CharClassify.h \ - ../src/Decoration.h ../src/CaseFolder.h ../src/Document.h \ - ../src/UniConversion.h ../src/Selection.h ../src/PositionCache.h -RESearch.o: ../src/RESearch.cxx ../src/Position.h ../src/CharClassify.h \ - ../src/RESearch.h -RunStyles.o: ../src/RunStyles.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/RunStyles.h -ScintillaBase.o: ../src/ScintillaBase.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../include/SciLexer.h ../lexlib/PropSetSimple.h ../lexlib/LexerModule.h \ - ../src/Catalogue.h ../src/Position.h ../src/SplitVector.h \ - ../src/Partitioning.h ../src/RunStyles.h ../src/ContractionState.h \ - ../src/CellBuffer.h ../src/CallTip.h ../src/KeyMap.h ../src/Indicator.h \ - ../src/XPM.h ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/Selection.h ../src/PositionCache.h \ - ../src/EditModel.h ../src/MarginView.h ../src/EditView.h ../src/Editor.h \ - ../src/AutoComplete.h ../src/ScintillaBase.h -Selection.o: ../src/Selection.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/Selection.h -Style.o: ../src/Style.cxx ../include/Platform.h ../include/Scintilla.h \ - ../include/Sci_Position.h ../src/Style.h -UniConversion.o: ../src/UniConversion.cxx ../src/UniConversion.h -ViewStyle.o: ../src/ViewStyle.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/RunStyles.h \ - ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h ../src/Style.h \ - ../src/ViewStyle.h -XPM.o: ../src/XPM.cxx ../include/Platform.h ../src/XPM.h -Accessor.o: ../lexlib/Accessor.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h -CharacterCategory.o: ../lexlib/CharacterCategory.cxx \ - ../lexlib/StringCopy.h ../lexlib/CharacterCategory.h -CharacterSet.o: ../lexlib/CharacterSet.cxx ../lexlib/CharacterSet.h -LexerBase.o: ../lexlib/LexerBase.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/LexerModule.h ../lexlib/LexerBase.h -LexerModule.o: ../lexlib/LexerModule.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/LexerModule.h ../lexlib/LexerBase.h \ - ../lexlib/LexerSimple.h -LexerNoExceptions.o: ../lexlib/LexerNoExceptions.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/LexerModule.h ../lexlib/LexerBase.h \ - ../lexlib/LexerNoExceptions.h -LexerSimple.o: ../lexlib/LexerSimple.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/LexerModule.h ../lexlib/LexerBase.h \ - ../lexlib/LexerSimple.h -PropSetSimple.o: ../lexlib/PropSetSimple.cxx ../lexlib/PropSetSimple.h -StyleContext.o: ../lexlib/StyleContext.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h -WordList.o: ../lexlib/WordList.cxx ../lexlib/StringCopy.h \ - ../lexlib/WordList.h -LexA68k.o: ../lexers/LexA68k.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAbaqus.o: ../lexers/LexAbaqus.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAda.o: ../lexers/LexAda.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAPDL.o: ../lexers/LexAPDL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAsm.o: ../lexers/LexAsm.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexAsn1.o: ../lexers/LexAsn1.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexASY.o: ../lexers/LexASY.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAU3.o: ../lexers/LexAU3.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAVE.o: ../lexers/LexAVE.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAVS.o: ../lexers/LexAVS.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBaan.o: ../lexers/LexBaan.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBash.o: ../lexers/LexBash.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBasic.o: ../lexers/LexBasic.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexBatch.o: ../lexers/LexBatch.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBibTeX.o: ../lexers/LexBibTeX.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBullant.o: ../lexers/LexBullant.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCaml.o: ../lexers/LexCaml.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCLW.o: ../lexers/LexCLW.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCmake.o: ../lexers/LexCmake.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCOBOL.o: ../lexers/LexCOBOL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCoffeeScript.o: ../lexers/LexCoffeeScript.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../include/SciLexer.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexConf.o: ../lexers/LexConf.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCPP.o: ../lexers/LexCPP.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h ../lexlib/SparseState.h \ - ../lexlib/SubStyles.h -LexCrontab.o: ../lexers/LexCrontab.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCsound.o: ../lexers/LexCsound.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCSS.o: ../lexers/LexCSS.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexD.o: ../lexers/LexD.cxx ../include/ILexer.h ../include/Sci_Position.h \ - ../include/Scintilla.h ../include/SciLexer.h ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexDiff.o: ../lexers/LexDiff.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexDMAP.o: ../lexers/LexDMAP.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexDMIS.o: ../lexers/LexDMIS.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h -LexECL.o: ../lexers/LexECL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexEiffel.o: ../lexers/LexEiffel.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexErlang.o: ../lexers/LexErlang.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexErrorList.o: ../lexers/LexErrorList.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexEScript.o: ../lexers/LexEScript.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexFlagship.o: ../lexers/LexFlagship.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexForth.o: ../lexers/LexForth.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexFortran.o: ../lexers/LexFortran.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexGAP.o: ../lexers/LexGAP.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexGui4Cli.o: ../lexers/LexGui4Cli.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexHaskell.o: ../lexers/LexHaskell.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/CharacterCategory.h ../lexlib/LexerModule.h \ - ../lexlib/OptionSet.h -LexHex.o: ../lexers/LexHex.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexHTML.o: ../lexers/LexHTML.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/StringCopy.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexInno.o: ../lexers/LexInno.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexKix.o: ../lexers/LexKix.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexKVIrc.o: ../lexers/LexKVIrc.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexLaTeX.o: ../lexers/LexLaTeX.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/LexerBase.h -LexLisp.o: ../lexers/LexLisp.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexLout.o: ../lexers/LexLout.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexLua.o: ../lexers/LexLua.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMagik.o: ../lexers/LexMagik.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMake.o: ../lexers/LexMake.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMarkdown.o: ../lexers/LexMarkdown.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMatlab.o: ../lexers/LexMatlab.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMetapost.o: ../lexers/LexMetapost.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMMIXAL.o: ../lexers/LexMMIXAL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexModula.o: ../lexers/LexModula.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMPT.o: ../lexers/LexMPT.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMSSQL.o: ../lexers/LexMSSQL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMySQL.o: ../lexers/LexMySQL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexNimrod.o: ../lexers/LexNimrod.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexNsis.o: ../lexers/LexNsis.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexNull.o: ../lexers/LexNull.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexOpal.o: ../lexers/LexOpal.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexOScript.o: ../lexers/LexOScript.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPascal.o: ../lexers/LexPascal.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPB.o: ../lexers/LexPB.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPerl.o: ../lexers/LexPerl.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexPLM.o: ../lexers/LexPLM.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPO.o: ../lexers/LexPO.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPOV.o: ../lexers/LexPOV.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPowerPro.o: ../lexers/LexPowerPro.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPowerShell.o: ../lexers/LexPowerShell.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexProgress.o: ../lexers/LexProgress.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexProps.o: ../lexers/LexProps.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPS.o: ../lexers/LexPS.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPython.o: ../lexers/LexPython.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h ../lexlib/SubStyles.h -LexR.o: ../lexers/LexR.cxx ../include/ILexer.h ../include/Sci_Position.h \ - ../include/Scintilla.h ../include/SciLexer.h ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h ../lexlib/Accessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h -LexRebol.o: ../lexers/LexRebol.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexRegistry.o: ../lexers/LexRegistry.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexRuby.o: ../lexers/LexRuby.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexRust.o: ../lexers/LexRust.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexScriptol.o: ../lexers/LexScriptol.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSmalltalk.o: ../lexers/LexSmalltalk.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSML.o: ../lexers/LexSML.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSorcus.o: ../lexers/LexSorcus.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSpecman.o: ../lexers/LexSpecman.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSpice.o: ../lexers/LexSpice.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSQL.o: ../lexers/LexSQL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h ../lexlib/SparseState.h -LexSTTXT.o: ../lexers/LexSTTXT.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTACL.o: ../lexers/LexTACL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTADS3.o: ../lexers/LexTADS3.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTAL.o: ../lexers/LexTAL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTCL.o: ../lexers/LexTCL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTCMD.o: ../lexers/LexTCMD.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTeX.o: ../lexers/LexTeX.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTxt2tags.o: ../lexers/LexTxt2tags.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexVB.o: ../lexers/LexVB.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexVerilog.o: ../lexers/LexVerilog.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h ../lexlib/SubStyles.h -LexVHDL.o: ../lexers/LexVHDL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexVisualProlog.o: ../lexers/LexVisualProlog.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/CharacterCategory.h ../lexlib/LexerModule.h \ - ../lexlib/OptionSet.h -LexYAML.o: ../lexers/LexYAML.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h diff --git a/dep/scintilla/scintilla-3.6.0/gtk/makefile b/dep/scintilla/scintilla-3.6.0/gtk/makefile deleted file mode 100644 index cdf1aa16..00000000 --- a/dep/scintilla/scintilla-3.6.0/gtk/makefile +++ /dev/null @@ -1,106 +0,0 @@ -# Make file for Scintilla on Linux or compatible OS -# Copyright 1998-2010 by Neil Hodgson -# The License.txt file describes the conditions under which this software may be distributed. -# This makefile assumes GCC 4.3 is used and changes will be needed to use other compilers. -# GNU make does not like \r\n line endings so should be saved to CVS in binary form. -# Builds for GTK+ 2 and no longer supports GTK+ 1. -# Also works with ming32-make on Windows. - -.SUFFIXES: .cxx .c .o .h .a -ifdef CLANG -CXX = clang++ -Wno-deprecated-register -CC = clang -# Can choose aspect to sanitize: address and undefined can simply change SANITIZE but for -# thread also need to create Position Independent Executable -> search online documentation -SANITIZE = address -#SANITIZE = undefined -endif -RANLIB = touch - -ifdef GTK3 -GTKVERSION=gtk+-3.0 -else -GTKVERSION=gtk+-2.0 -endif - -# Environment variable windir always defined on Win32 - -ifndef windir -ifeq ($(shell uname),Darwin) -RANLIB = ranlib -endif -endif - -ifdef windir -DEL = del /q -COMPLIB=..\bin\scintilla.a -else -DEL = rm -f -COMPLIB=../bin/scintilla.a -endif - -vpath %.h ../src ../include ../lexlib -vpath %.cxx ../src ../lexlib ../lexers - -INCLUDEDIRS=-I ../include -I ../src -I ../lexlib -ifdef CHECK_DEPRECATED -DEPRECATED=-DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DDISABLE_GDK_FONT -endif -CXXBASEFLAGS=-Wall -pedantic -DGTK -DSCI_LEXER $(INCLUDEDIRS) $(DEPRECATED) - -ifdef NOTHREADS -THREADFLAGS=-DG_THREADS_IMPL_NONE -else -THREADFLAGS= -endif - -ifdef CXX11_REGEX -REFLAGS=-DCXX11_REGEX -endif - -ifdef DEBUG -ifdef CLANG -CTFLAGS=-DDEBUG -g -fsanitize=$(SANITIZE) $(CXXBASEFLAGS) $(THREADFLAGS) -else -CTFLAGS=-DDEBUG -g $(CXXBASEFLAGS) $(THREADFLAGS) -endif -else -CTFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS) -endif - -CFLAGS:=$(CTFLAGS) -CXXTFLAGS:=--std=c++0x $(CTFLAGS) $(REFLAGS) - -CONFIGFLAGS:=$(shell pkg-config --cflags $(GTKVERSION)) -MARSHALLER=scintilla-marshal.o - -.cxx.o: - $(CXX) $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) -c $< -.c.o: - $(CC) $(CONFIGFLAGS) $(CFLAGS) -w -c $< - -LEXOBJS:=$(addsuffix .o,$(basename $(notdir $(wildcard ../lexers/Lex*.cxx)))) - -all: $(COMPLIB) - -clean: - $(DEL) *.o $(COMPLIB) *.plist - -analyze: - clang --analyze $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx - -deps: - $(CXX) -MM $(CONFIGFLAGS) $(CXXTFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx | sed -e 's/\/usr.* //' | grep [a-zA-Z] >deps.mak - -$(COMPLIB): Accessor.o CharacterSet.o LexerBase.o LexerModule.o LexerSimple.o StyleContext.o WordList.o \ - CharClassify.o Decoration.o Document.o PerLine.o Catalogue.o CallTip.o CaseConvert.o CaseFolder.o \ - ScintillaBase.o ContractionState.o EditModel.o Editor.o EditView.o ExternalLexer.o MarginView.o \ - PropSetSimple.o PlatGTK.o \ - KeyMap.o LineMarker.o PositionCache.o ScintillaGTK.o CellBuffer.o CharacterCategory.o ViewStyle.o \ - RESearch.o RunStyles.o Selection.o Style.o Indicator.o AutoComplete.o UniConversion.o XPM.o \ - $(MARSHALLER) $(LEXOBJS) - $(AR) rc $@ $^ - $(RANLIB) $@ - -# Automatically generate header dependencies with "make deps" -include deps.mak diff --git a/dep/scintilla/scintilla-3.6.0/gtk/scintilla-marshal.h b/dep/scintilla/scintilla-3.6.0/gtk/scintilla-marshal.h deleted file mode 100644 index 9116a56c..00000000 --- a/dep/scintilla/scintilla-3.6.0/gtk/scintilla-marshal.h +++ /dev/null @@ -1,21 +0,0 @@ - -#ifndef __scintilla_marshal_MARSHAL_H__ -#define __scintilla_marshal_MARSHAL_H__ - -#include - -G_BEGIN_DECLS - -/* NONE:INT,POINTER (scintilla-marshal.list:1) */ -extern void scintilla_marshal_VOID__INT_POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -#define scintilla_marshal_NONE__INT_POINTER scintilla_marshal_VOID__INT_POINTER - -G_END_DECLS - -#endif /* __scintilla_marshal_MARSHAL_H__ */ - diff --git a/dep/scintilla/scintilla-3.6.0/gtk/scintilla-marshal.list b/dep/scintilla/scintilla-3.6.0/gtk/scintilla-marshal.list deleted file mode 100644 index e5750ecb..00000000 --- a/dep/scintilla/scintilla-3.6.0/gtk/scintilla-marshal.list +++ /dev/null @@ -1 +0,0 @@ -NONE:INT,POINTER diff --git a/dep/scintilla/scintilla-3.6.0/include/ScintillaWidget.h b/dep/scintilla/scintilla-3.6.0/include/ScintillaWidget.h deleted file mode 100644 index f8cd212b..00000000 --- a/dep/scintilla/scintilla-3.6.0/include/ScintillaWidget.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Scintilla source code edit control */ -/** @file ScintillaWidget.h - ** Definition of Scintilla widget for GTK+. - ** Only needed by GTK+ code but is harmless on other platforms. - **/ -/* Copyright 1998-2001 by Neil Hodgson - * The License.txt file describes the conditions under which this software may be distributed. */ - -#ifndef SCINTILLAWIDGET_H -#define SCINTILLAWIDGET_H - -#if defined(GTK) - -#ifdef __cplusplus -extern "C" { -#endif - -#define SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, scintilla_get_type (), ScintillaObject) -#define SCINTILLA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, scintilla_get_type (), ScintillaClass) -#define IS_SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, scintilla_get_type ()) - -typedef struct _ScintillaObject ScintillaObject; -typedef struct _ScintillaClass ScintillaClass; - -struct _ScintillaObject { - GtkContainer cont; - void *pscin; -}; - -struct _ScintillaClass { - GtkContainerClass parent_class; - - void (* command) (ScintillaObject *ttt); - void (* notify) (ScintillaObject *ttt); -}; - -GType scintilla_get_type (void); -GtkWidget* scintilla_new (void); -void scintilla_set_id (ScintillaObject *sci, uptr_t id); -sptr_t scintilla_send_message (ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam); -void scintilla_release_resources(void); - -#define SCINTILLA_NOTIFY "sci-notify" - -#ifdef __cplusplus -} -#endif - -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/lexers/LexBaan.cxx b/dep/scintilla/scintilla-3.6.0/lexers/LexBaan.cxx deleted file mode 100644 index 8da2f3a3..00000000 --- a/dep/scintilla/scintilla-3.6.0/lexers/LexBaan.cxx +++ /dev/null @@ -1,196 +0,0 @@ -// Scintilla source code edit control -/** @file LexBaan.cxx - ** Lexer for Baan. - ** Based heavily on LexCPP.cxx - **/ -// Copyright 2001- by Vamsi Potluru & Praveen Ambekar -// The License.txt file describes the conditions under which this software may be distributed. - -#include -#include -#include -#include -#include -#include - -#include "ILexer.h" -#include "Scintilla.h" -#include "SciLexer.h" - -#include "WordList.h" -#include "LexAccessor.h" -#include "Accessor.h" -#include "StyleContext.h" -#include "CharacterSet.h" -#include "LexerModule.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -static inline bool IsAWordChar(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '$' || ch == ':'); -} - -static inline bool IsAWordStart(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '_'); -} - -static void ColouriseBaanDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], - Accessor &styler) { - - WordList &keywords = *keywordlists[0]; - WordList &keywords2 = *keywordlists[1]; - bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0; - - if (initStyle == SCE_BAAN_STRINGEOL) // Does not leak onto next line - initStyle = SCE_BAAN_DEFAULT; - - int visibleChars = 0; - - StyleContext sc(startPos, length, initStyle, styler); - - for (; sc.More(); sc.Forward()) { - - if (sc.state == SCE_BAAN_OPERATOR) { - sc.SetState(SCE_BAAN_DEFAULT); - } else if (sc.state == SCE_BAAN_NUMBER) { - if (!IsAWordChar(sc.ch)) { - sc.SetState(SCE_BAAN_DEFAULT); - } - } else if (sc.state == SCE_BAAN_IDENTIFIER) { - if (!IsAWordChar(sc.ch)) { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (keywords.InList(s)) { - sc.ChangeState(SCE_BAAN_WORD); - } else if (keywords2.InList(s)) { - sc.ChangeState(SCE_BAAN_WORD2); - } - sc.SetState(SCE_BAAN_DEFAULT); - } - } else if (sc.state == SCE_BAAN_PREPROCESSOR) { - if (stylingWithinPreprocessor) { - if (IsASpace(sc.ch)) { - sc.SetState(SCE_BAAN_DEFAULT); - } - } else { - if (sc.atLineEnd && (sc.chNext != '^')) { - sc.SetState(SCE_BAAN_DEFAULT); - } - } - } else if (sc.state == SCE_BAAN_COMMENT) { - if (sc.atLineEnd) { - sc.SetState(SCE_BAAN_DEFAULT); - } - } else if (sc.state == SCE_BAAN_COMMENTDOC) { - if (sc.MatchIgnoreCase("enddllusage")) { - for (unsigned int i = 0; i < 10; i++){ - sc.Forward(); - } - sc.ForwardSetState(SCE_BAAN_DEFAULT); - } - } else if (sc.state == SCE_BAAN_STRING) { - if (sc.ch == '\"') { - sc.ForwardSetState(SCE_BAAN_DEFAULT); - } else if ((sc.atLineEnd) && (sc.chNext != '^')) { - sc.ChangeState(SCE_BAAN_STRINGEOL); - sc.ForwardSetState(SCE_C_DEFAULT); - visibleChars = 0; - } - } - - if (sc.state == SCE_BAAN_DEFAULT) { - if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { - sc.SetState(SCE_BAAN_NUMBER); - } else if (sc.MatchIgnoreCase("dllusage")){ - sc.SetState(SCE_BAAN_COMMENTDOC); - do { - sc.Forward(); - } while ((!sc.atLineEnd) && sc.More()); - } else if (IsAWordStart(sc.ch)) { - sc.SetState(SCE_BAAN_IDENTIFIER); - } else if (sc.Match('|')){ - sc.SetState(SCE_BAAN_COMMENT); - } else if (sc.ch == '\"') { - sc.SetState(SCE_BAAN_STRING); - } else if (sc.ch == '#' && visibleChars == 0) { - // Preprocessor commands are alone on their line - sc.SetState(SCE_BAAN_PREPROCESSOR); - // Skip whitespace between # and preprocessor word - do { - sc.Forward(); - } while (IsASpace(sc.ch) && sc.More()); - } else if (isoperator(static_cast(sc.ch))) { - sc.SetState(SCE_BAAN_OPERATOR); - } - } - if (sc.atLineEnd) { - // Reset states to begining of colourise so no surprises - // if different sets of lines lexed. - visibleChars = 0; - } - if (!IsASpace(sc.ch)) { - visibleChars++; - } - } - sc.Complete(); -} - -static void FoldBaanDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], - Accessor &styler) { - bool foldComment = styler.GetPropertyInt("fold.comment") != 0; - bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - Sci_PositionU endPos = startPos + length; - int visibleChars = 0; - Sci_Position 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; - for (Sci_PositionU 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 && - (style == SCE_BAAN_COMMENT || style == SCE_BAAN_COMMENTDOC)) { - if (style != stylePrev) { - levelCurrent++; - } else if ((style != styleNext) && !atEOL) { - // Comments don't end at end of line and the next character may be unstyled. - levelCurrent--; - } - } - if (style == SCE_BAAN_OPERATOR) { - if (ch == '{') { - levelCurrent++; - } else if (ch == '}') { - 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); -} - -LexerModule lmBaan(SCLEX_BAAN, ColouriseBaanDoc, "baan", FoldBaanDoc); diff --git a/dep/scintilla/scintilla-3.6.0/lexers/LexProgress.cxx b/dep/scintilla/scintilla-3.6.0/lexers/LexProgress.cxx deleted file mode 100644 index 844b635a..00000000 --- a/dep/scintilla/scintilla-3.6.0/lexers/LexProgress.cxx +++ /dev/null @@ -1,282 +0,0 @@ -// Scintilla source code edit control -/** @file LexProgress.cxx - ** Lexer for Progress 4GL. - ** Based on LexCPP.cxx of Neil Hodgson - **/ -// Copyright 2006-2007 by Yuval Papish -// 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 -Support more than 6 comments levels -**/ -#include -#include -#include -#include -#include -#include - -#include "ILexer.h" -#include "Scintilla.h" -#include "SciLexer.h" - -#include "WordList.h" -#include "LexAccessor.h" -#include "Accessor.h" -#include "StyleContext.h" -#include "CharacterSet.h" -#include "LexerModule.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(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], - Accessor &styler) { - - WordList &keywords1 = *keywordlists[0]; // regular keywords - WordList &keywords2 = *keywordlists[1]; // block opening keywords, only when SentenceStart - WordList &keywords3 = *keywordlists[2]; // block opening keywords - //WordList &keywords4 = *keywordlists[3]; // preprocessor keywords. Not implemented - - - 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.state & 0xf) < SCE_4GL_COMMENT1) { - if (sc.ch == '~') { - if (sc.chNext > ' ') { - // skip special char after ~ - sc.Forward(); - continue; - } - else { - // Skip whitespace between ~ and EOL - while (sc.More() && (sc.chNext == ' ' || sc.chNext == '\t') ) { - sc.Forward(); - } - 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); - } - /* code removed to allow comments inside preprocessor - else if (sc.ch == '*' && sc.chNext == '/') { - sc.ForwardSetState(SCE_4GL_DEFAULT | sentenceStartState); } */ - 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(sc.ch))) { - /* This code allows highlight of handles. Alas, it would cause the phrase "last-event:function" - to be recognized as a BlockBegin */ - - 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(Sci_PositionU startPos, Sci_Position 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; - Sci_PositionU endPos = startPos + length; - int visibleChars = 0; - Sci_Position 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(tolower(styler[startPos])); - int styleNext = styler.StyleAt(startPos); - int style = initStyle; - for (Sci_PositionU i = startPos; i < endPos; i++) { - char ch = chNext; - chNext = static_cast(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(Sci_PositionU startPos, Sci_Position 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_PROGRESS, Colourise4glDoc, "progress", Fold4glDoc, FglWordLists); diff --git a/dep/scintilla/scintilla-3.6.0/lexlib/CharacterCategory.h b/dep/scintilla/scintilla-3.6.0/lexlib/CharacterCategory.h deleted file mode 100644 index c8600504..00000000 --- a/dep/scintilla/scintilla-3.6.0/lexlib/CharacterCategory.h +++ /dev/null @@ -1,31 +0,0 @@ -// Scintilla source code edit control -/** @file CharacterCategory.h - ** Returns the Unicode general category of a character. - **/ -// Copyright 2013 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef CHARACTERCATEGORY_H -#define CHARACTERCATEGORY_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -enum CharacterCategory { - ccLu, ccLl, ccLt, ccLm, ccLo, - ccMn, ccMc, ccMe, - ccNd, ccNl, ccNo, - ccPc, ccPd, ccPs, ccPe, ccPi, ccPf, ccPo, - ccSm, ccSc, ccSk, ccSo, - ccZs, ccZl, ccZp, - ccCc, ccCf, ccCs, ccCo, ccCn -}; - -CharacterCategory CategoriseCharacter(int character); - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/lexlib/LexerBase.h b/dep/scintilla/scintilla-3.6.0/lexlib/LexerBase.h deleted file mode 100644 index d8849d2f..00000000 --- a/dep/scintilla/scintilla-3.6.0/lexlib/LexerBase.h +++ /dev/null @@ -1,41 +0,0 @@ -// Scintilla source code edit control -/** @file LexerBase.h - ** A simple lexer with no state. - **/ -// Copyright 1998-2010 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef LEXERBASE_H -#define LEXERBASE_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -// A simple lexer with no state -class LexerBase : public ILexer { -protected: - PropSetSimple props; - enum {numWordLists=KEYWORDSET_MAX+1}; - WordList *keyWordLists[numWordLists+1]; -public: - LexerBase(); - virtual ~LexerBase(); - void SCI_METHOD Release(); - int SCI_METHOD Version() const; - const char * SCI_METHOD PropertyNames(); - int SCI_METHOD PropertyType(const char *name); - const char * SCI_METHOD DescribeProperty(const char *name); - Sci_Position SCI_METHOD PropertySet(const char *key, const char *val); - const char * SCI_METHOD DescribeWordListSets(); - Sci_Position SCI_METHOD WordListSet(int n, const char *wl); - void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) = 0; - void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) = 0; - void * SCI_METHOD PrivateCall(int operation, void *pointer); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.cpp b/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.cpp deleted file mode 100644 index c6f2aba6..00000000 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.cpp +++ /dev/null @@ -1,2784 +0,0 @@ -// ScintillaEdit.cpp -// Extended version of ScintillaEditBase with a method for each API -// Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware - -#include "ScintillaEdit.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -ScintillaEdit::ScintillaEdit(QWidget *parent) : ScintillaEditBase(parent) { -} - -ScintillaEdit::~ScintillaEdit() { -} - -QByteArray ScintillaEdit::TextReturner(int message, uptr_t wParam) const { - int length = send(message, wParam, 0); - QByteArray ba(length, '\0'); - send(message, wParam, (sptr_t)ba.data()); - // Remove extra NULs - if (ba.size() > 0 && ba.at(ba.size()-1) == 0) - ba.chop(1); - return ba; -} - -QPairScintillaEdit::find_text(int flags, const char *text, int cpMin, int cpMax) { - struct TextToFind ft = {{0, 0}, 0, {0, 0}}; - ft.chrg.cpMin = cpMin; - ft.chrg.cpMax = cpMax; - ft.chrgText.cpMin = cpMin; - ft.chrgText.cpMax = cpMax; - ft.lpstrText = const_cast(text); - - int start = send(SCI_FINDTEXT, flags, (uptr_t) (&ft)); - - return QPair(start, ft.chrgText.cpMax); -} - -QByteArray ScintillaEdit::get_text_range(int start, int end) { - if (start > end) - start = end; - - int length = end-start; - QByteArray ba(length+1, '\0'); - struct TextRange tr = {{start, end}, ba.data()}; - - send(SCI_GETTEXTRANGE, 0, (sptr_t)&tr); - ba.chop(1); // Remove extra NUL - - return ba; -} - -ScintillaDocument *ScintillaEdit::get_doc() { - return new ScintillaDocument(0, (void *)send(SCI_GETDOCPOINTER, 0, 0)); -} - -void ScintillaEdit::set_doc(ScintillaDocument *pdoc_) { - send(SCI_SETDOCPOINTER, 0, (sptr_t)(pdoc_->pointer())); -} - -long ScintillaEdit::format_range(bool draw, QPaintDevice* target, QPaintDevice* measure, - const QRect& print_rect, const QRect& page_rect, - long range_start, long range_end) -{ - Sci_RangeToFormat to_format; - - to_format.hdc = target; - to_format.hdcTarget = measure; - - to_format.rc.left = print_rect.left(); - to_format.rc.top = print_rect.top(); - to_format.rc.right = print_rect.right(); - to_format.rc.bottom = print_rect.bottom(); - - to_format.rcPage.left = page_rect.left(); - to_format.rcPage.top = page_rect.top(); - to_format.rcPage.right = page_rect.right(); - to_format.rcPage.bottom = page_rect.bottom(); - - to_format.chrg.cpMin = range_start; - to_format.chrg.cpMax = range_end; - - return send(SCI_FORMATRANGE, draw, reinterpret_cast(&to_format)); -} - -/* ++Autogenerated -- start of section automatically generated from Scintilla.iface */ -void ScintillaEdit::addText(sptr_t length, const char * text) { - send(SCI_ADDTEXT, length, (sptr_t)text); -} - -void ScintillaEdit::addStyledText(sptr_t length, const char * c) { - send(SCI_ADDSTYLEDTEXT, length, (sptr_t)c); -} - -void ScintillaEdit::insertText(sptr_t pos, const char * text) { - send(SCI_INSERTTEXT, pos, (sptr_t)text); -} - -void ScintillaEdit::changeInsertion(sptr_t length, const char * text) { - send(SCI_CHANGEINSERTION, length, (sptr_t)text); -} - -void ScintillaEdit::clearAll() { - send(SCI_CLEARALL, 0, 0); -} - -void ScintillaEdit::deleteRange(sptr_t pos, sptr_t deleteLength) { - send(SCI_DELETERANGE, pos, deleteLength); -} - -void ScintillaEdit::clearDocumentStyle() { - send(SCI_CLEARDOCUMENTSTYLE, 0, 0); -} - -sptr_t ScintillaEdit::length() const { - return send(SCI_GETLENGTH, 0, 0); -} - -sptr_t ScintillaEdit::charAt(sptr_t pos) const { - return send(SCI_GETCHARAT, pos, 0); -} - -sptr_t ScintillaEdit::currentPos() const { - return send(SCI_GETCURRENTPOS, 0, 0); -} - -sptr_t ScintillaEdit::anchor() const { - return send(SCI_GETANCHOR, 0, 0); -} - -sptr_t ScintillaEdit::styleAt(sptr_t pos) const { - return send(SCI_GETSTYLEAT, pos, 0); -} - -void ScintillaEdit::redo() { - send(SCI_REDO, 0, 0); -} - -void ScintillaEdit::setUndoCollection(bool collectUndo) { - send(SCI_SETUNDOCOLLECTION, collectUndo, 0); -} - -void ScintillaEdit::selectAll() { - send(SCI_SELECTALL, 0, 0); -} - -void ScintillaEdit::setSavePoint() { - send(SCI_SETSAVEPOINT, 0, 0); -} - -bool ScintillaEdit::canRedo() { - return send(SCI_CANREDO, 0, 0); -} - -sptr_t ScintillaEdit::markerLineFromHandle(sptr_t handle) { - return send(SCI_MARKERLINEFROMHANDLE, handle, 0); -} - -void ScintillaEdit::markerDeleteHandle(sptr_t handle) { - send(SCI_MARKERDELETEHANDLE, handle, 0); -} - -bool ScintillaEdit::undoCollection() const { - return send(SCI_GETUNDOCOLLECTION, 0, 0); -} - -sptr_t ScintillaEdit::viewWS() const { - return send(SCI_GETVIEWWS, 0, 0); -} - -void ScintillaEdit::setViewWS(sptr_t viewWS) { - send(SCI_SETVIEWWS, viewWS, 0); -} - -sptr_t ScintillaEdit::positionFromPoint(sptr_t x, sptr_t y) { - return send(SCI_POSITIONFROMPOINT, x, y); -} - -sptr_t ScintillaEdit::positionFromPointClose(sptr_t x, sptr_t y) { - return send(SCI_POSITIONFROMPOINTCLOSE, x, y); -} - -void ScintillaEdit::gotoLine(sptr_t line) { - send(SCI_GOTOLINE, line, 0); -} - -void ScintillaEdit::gotoPos(sptr_t pos) { - send(SCI_GOTOPOS, pos, 0); -} - -void ScintillaEdit::setAnchor(sptr_t posAnchor) { - send(SCI_SETANCHOR, posAnchor, 0); -} - -QByteArray ScintillaEdit::getCurLine(sptr_t length) { - return TextReturner(SCI_GETCURLINE, length); -} - -sptr_t ScintillaEdit::endStyled() const { - return send(SCI_GETENDSTYLED, 0, 0); -} - -void ScintillaEdit::convertEOLs(sptr_t eolMode) { - send(SCI_CONVERTEOLS, eolMode, 0); -} - -sptr_t ScintillaEdit::eOLMode() const { - return send(SCI_GETEOLMODE, 0, 0); -} - -void ScintillaEdit::setEOLMode(sptr_t eolMode) { - send(SCI_SETEOLMODE, eolMode, 0); -} - -void ScintillaEdit::startStyling(sptr_t pos, sptr_t mask) { - send(SCI_STARTSTYLING, pos, mask); -} - -void ScintillaEdit::setStyling(sptr_t length, sptr_t style) { - send(SCI_SETSTYLING, length, style); -} - -bool ScintillaEdit::bufferedDraw() const { - return send(SCI_GETBUFFEREDDRAW, 0, 0); -} - -void ScintillaEdit::setBufferedDraw(bool buffered) { - send(SCI_SETBUFFEREDDRAW, buffered, 0); -} - -void ScintillaEdit::setTabWidth(sptr_t tabWidth) { - send(SCI_SETTABWIDTH, tabWidth, 0); -} - -sptr_t ScintillaEdit::tabWidth() const { - return send(SCI_GETTABWIDTH, 0, 0); -} - -void ScintillaEdit::clearTabStops(sptr_t line) { - send(SCI_CLEARTABSTOPS, line, 0); -} - -void ScintillaEdit::addTabStop(sptr_t line, sptr_t x) { - send(SCI_ADDTABSTOP, line, x); -} - -sptr_t ScintillaEdit::getNextTabStop(sptr_t line, sptr_t x) { - return send(SCI_GETNEXTTABSTOP, line, x); -} - -void ScintillaEdit::setCodePage(sptr_t codePage) { - send(SCI_SETCODEPAGE, codePage, 0); -} - -sptr_t ScintillaEdit::iMEInteraction() const { - return send(SCI_GETIMEINTERACTION, 0, 0); -} - -void ScintillaEdit::setIMEInteraction(sptr_t imeInteraction) { - send(SCI_SETIMEINTERACTION, imeInteraction, 0); -} - -void ScintillaEdit::markerDefine(sptr_t markerNumber, sptr_t markerSymbol) { - send(SCI_MARKERDEFINE, markerNumber, markerSymbol); -} - -void ScintillaEdit::markerSetFore(sptr_t markerNumber, sptr_t fore) { - send(SCI_MARKERSETFORE, markerNumber, fore); -} - -void ScintillaEdit::markerSetBack(sptr_t markerNumber, sptr_t back) { - send(SCI_MARKERSETBACK, markerNumber, back); -} - -void ScintillaEdit::markerSetBackSelected(sptr_t markerNumber, sptr_t back) { - send(SCI_MARKERSETBACKSELECTED, markerNumber, back); -} - -void ScintillaEdit::markerEnableHighlight(bool enabled) { - send(SCI_MARKERENABLEHIGHLIGHT, enabled, 0); -} - -sptr_t ScintillaEdit::markerAdd(sptr_t line, sptr_t markerNumber) { - return send(SCI_MARKERADD, line, markerNumber); -} - -void ScintillaEdit::markerDelete(sptr_t line, sptr_t markerNumber) { - send(SCI_MARKERDELETE, line, markerNumber); -} - -void ScintillaEdit::markerDeleteAll(sptr_t markerNumber) { - send(SCI_MARKERDELETEALL, markerNumber, 0); -} - -sptr_t ScintillaEdit::markerGet(sptr_t line) { - return send(SCI_MARKERGET, line, 0); -} - -sptr_t ScintillaEdit::markerNext(sptr_t lineStart, sptr_t markerMask) { - return send(SCI_MARKERNEXT, lineStart, markerMask); -} - -sptr_t ScintillaEdit::markerPrevious(sptr_t lineStart, sptr_t markerMask) { - return send(SCI_MARKERPREVIOUS, lineStart, markerMask); -} - -void ScintillaEdit::markerDefinePixmap(sptr_t markerNumber, const char * pixmap) { - send(SCI_MARKERDEFINEPIXMAP, markerNumber, (sptr_t)pixmap); -} - -void ScintillaEdit::markerAddSet(sptr_t line, sptr_t set) { - send(SCI_MARKERADDSET, line, set); -} - -void ScintillaEdit::markerSetAlpha(sptr_t markerNumber, sptr_t alpha) { - send(SCI_MARKERSETALPHA, markerNumber, alpha); -} - -void ScintillaEdit::setMarginTypeN(sptr_t margin, sptr_t marginType) { - send(SCI_SETMARGINTYPEN, margin, marginType); -} - -sptr_t ScintillaEdit::marginTypeN(sptr_t margin) const { - return send(SCI_GETMARGINTYPEN, margin, 0); -} - -void ScintillaEdit::setMarginWidthN(sptr_t margin, sptr_t pixelWidth) { - send(SCI_SETMARGINWIDTHN, margin, pixelWidth); -} - -sptr_t ScintillaEdit::marginWidthN(sptr_t margin) const { - return send(SCI_GETMARGINWIDTHN, margin, 0); -} - -void ScintillaEdit::setMarginMaskN(sptr_t margin, sptr_t mask) { - send(SCI_SETMARGINMASKN, margin, mask); -} - -sptr_t ScintillaEdit::marginMaskN(sptr_t margin) const { - return send(SCI_GETMARGINMASKN, margin, 0); -} - -void ScintillaEdit::setMarginSensitiveN(sptr_t margin, bool sensitive) { - send(SCI_SETMARGINSENSITIVEN, margin, sensitive); -} - -bool ScintillaEdit::marginSensitiveN(sptr_t margin) const { - return send(SCI_GETMARGINSENSITIVEN, margin, 0); -} - -void ScintillaEdit::setMarginCursorN(sptr_t margin, sptr_t cursor) { - send(SCI_SETMARGINCURSORN, margin, cursor); -} - -sptr_t ScintillaEdit::marginCursorN(sptr_t margin) const { - return send(SCI_GETMARGINCURSORN, margin, 0); -} - -void ScintillaEdit::styleClearAll() { - send(SCI_STYLECLEARALL, 0, 0); -} - -void ScintillaEdit::styleSetFore(sptr_t style, sptr_t fore) { - send(SCI_STYLESETFORE, style, fore); -} - -void ScintillaEdit::styleSetBack(sptr_t style, sptr_t back) { - send(SCI_STYLESETBACK, style, back); -} - -void ScintillaEdit::styleSetBold(sptr_t style, bool bold) { - send(SCI_STYLESETBOLD, style, bold); -} - -void ScintillaEdit::styleSetItalic(sptr_t style, bool italic) { - send(SCI_STYLESETITALIC, style, italic); -} - -void ScintillaEdit::styleSetSize(sptr_t style, sptr_t sizePoints) { - send(SCI_STYLESETSIZE, style, sizePoints); -} - -void ScintillaEdit::styleSetFont(sptr_t style, const char * fontName) { - send(SCI_STYLESETFONT, style, (sptr_t)fontName); -} - -void ScintillaEdit::styleSetEOLFilled(sptr_t style, bool filled) { - send(SCI_STYLESETEOLFILLED, style, filled); -} - -void ScintillaEdit::styleResetDefault() { - send(SCI_STYLERESETDEFAULT, 0, 0); -} - -void ScintillaEdit::styleSetUnderline(sptr_t style, bool underline) { - send(SCI_STYLESETUNDERLINE, style, underline); -} - -sptr_t ScintillaEdit::styleFore(sptr_t style) const { - return send(SCI_STYLEGETFORE, style, 0); -} - -sptr_t ScintillaEdit::styleBack(sptr_t style) const { - return send(SCI_STYLEGETBACK, style, 0); -} - -bool ScintillaEdit::styleBold(sptr_t style) const { - return send(SCI_STYLEGETBOLD, style, 0); -} - -bool ScintillaEdit::styleItalic(sptr_t style) const { - return send(SCI_STYLEGETITALIC, style, 0); -} - -sptr_t ScintillaEdit::styleSize(sptr_t style) const { - return send(SCI_STYLEGETSIZE, style, 0); -} - -QByteArray ScintillaEdit::styleFont(sptr_t style) const { - return TextReturner(SCI_STYLEGETFONT, style); -} - -bool ScintillaEdit::styleEOLFilled(sptr_t style) const { - return send(SCI_STYLEGETEOLFILLED, style, 0); -} - -bool ScintillaEdit::styleUnderline(sptr_t style) const { - return send(SCI_STYLEGETUNDERLINE, style, 0); -} - -sptr_t ScintillaEdit::styleCase(sptr_t style) const { - return send(SCI_STYLEGETCASE, style, 0); -} - -sptr_t ScintillaEdit::styleCharacterSet(sptr_t style) const { - return send(SCI_STYLEGETCHARACTERSET, style, 0); -} - -bool ScintillaEdit::styleVisible(sptr_t style) const { - return send(SCI_STYLEGETVISIBLE, style, 0); -} - -bool ScintillaEdit::styleChangeable(sptr_t style) const { - return send(SCI_STYLEGETCHANGEABLE, style, 0); -} - -bool ScintillaEdit::styleHotSpot(sptr_t style) const { - return send(SCI_STYLEGETHOTSPOT, style, 0); -} - -void ScintillaEdit::styleSetCase(sptr_t style, sptr_t caseForce) { - send(SCI_STYLESETCASE, style, caseForce); -} - -void ScintillaEdit::styleSetSizeFractional(sptr_t style, sptr_t caseForce) { - send(SCI_STYLESETSIZEFRACTIONAL, style, caseForce); -} - -sptr_t ScintillaEdit::styleSizeFractional(sptr_t style) const { - return send(SCI_STYLEGETSIZEFRACTIONAL, style, 0); -} - -void ScintillaEdit::styleSetWeight(sptr_t style, sptr_t weight) { - send(SCI_STYLESETWEIGHT, style, weight); -} - -sptr_t ScintillaEdit::styleWeight(sptr_t style) const { - return send(SCI_STYLEGETWEIGHT, style, 0); -} - -void ScintillaEdit::styleSetCharacterSet(sptr_t style, sptr_t characterSet) { - send(SCI_STYLESETCHARACTERSET, style, characterSet); -} - -void ScintillaEdit::styleSetHotSpot(sptr_t style, bool hotspot) { - send(SCI_STYLESETHOTSPOT, style, hotspot); -} - -void ScintillaEdit::setSelFore(bool useSetting, sptr_t fore) { - send(SCI_SETSELFORE, useSetting, fore); -} - -void ScintillaEdit::setSelBack(bool useSetting, sptr_t back) { - send(SCI_SETSELBACK, useSetting, back); -} - -sptr_t ScintillaEdit::selAlpha() const { - return send(SCI_GETSELALPHA, 0, 0); -} - -void ScintillaEdit::setSelAlpha(sptr_t alpha) { - send(SCI_SETSELALPHA, alpha, 0); -} - -bool ScintillaEdit::selEOLFilled() const { - return send(SCI_GETSELEOLFILLED, 0, 0); -} - -void ScintillaEdit::setSelEOLFilled(bool filled) { - send(SCI_SETSELEOLFILLED, filled, 0); -} - -void ScintillaEdit::setCaretFore(sptr_t fore) { - send(SCI_SETCARETFORE, fore, 0); -} - -void ScintillaEdit::assignCmdKey(sptr_t km, sptr_t msg) { - send(SCI_ASSIGNCMDKEY, km, msg); -} - -void ScintillaEdit::clearCmdKey(sptr_t km) { - send(SCI_CLEARCMDKEY, km, 0); -} - -void ScintillaEdit::clearAllCmdKeys() { - send(SCI_CLEARALLCMDKEYS, 0, 0); -} - -void ScintillaEdit::setStylingEx(sptr_t length, const char * styles) { - send(SCI_SETSTYLINGEX, length, (sptr_t)styles); -} - -void ScintillaEdit::styleSetVisible(sptr_t style, bool visible) { - send(SCI_STYLESETVISIBLE, style, visible); -} - -sptr_t ScintillaEdit::caretPeriod() const { - return send(SCI_GETCARETPERIOD, 0, 0); -} - -void ScintillaEdit::setCaretPeriod(sptr_t periodMilliseconds) { - send(SCI_SETCARETPERIOD, periodMilliseconds, 0); -} - -void ScintillaEdit::setWordChars(const char * characters) { - send(SCI_SETWORDCHARS, 0, (sptr_t)characters); -} - -QByteArray ScintillaEdit::wordChars() const { - return TextReturner(SCI_GETWORDCHARS, 0); -} - -void ScintillaEdit::beginUndoAction() { - send(SCI_BEGINUNDOACTION, 0, 0); -} - -void ScintillaEdit::endUndoAction() { - send(SCI_ENDUNDOACTION, 0, 0); -} - -void ScintillaEdit::indicSetStyle(sptr_t indic, sptr_t style) { - send(SCI_INDICSETSTYLE, indic, style); -} - -sptr_t ScintillaEdit::indicStyle(sptr_t indic) const { - return send(SCI_INDICGETSTYLE, indic, 0); -} - -void ScintillaEdit::indicSetFore(sptr_t indic, sptr_t fore) { - send(SCI_INDICSETFORE, indic, fore); -} - -sptr_t ScintillaEdit::indicFore(sptr_t indic) const { - return send(SCI_INDICGETFORE, indic, 0); -} - -void ScintillaEdit::indicSetUnder(sptr_t indic, bool under) { - send(SCI_INDICSETUNDER, indic, under); -} - -bool ScintillaEdit::indicUnder(sptr_t indic) const { - return send(SCI_INDICGETUNDER, indic, 0); -} - -void ScintillaEdit::indicSetHoverStyle(sptr_t indic, sptr_t style) { - send(SCI_INDICSETHOVERSTYLE, indic, style); -} - -sptr_t ScintillaEdit::indicHoverStyle(sptr_t indic) const { - return send(SCI_INDICGETHOVERSTYLE, indic, 0); -} - -void ScintillaEdit::indicSetHoverFore(sptr_t indic, sptr_t fore) { - send(SCI_INDICSETHOVERFORE, indic, fore); -} - -sptr_t ScintillaEdit::indicHoverFore(sptr_t indic) const { - return send(SCI_INDICGETHOVERFORE, indic, 0); -} - -void ScintillaEdit::indicSetFlags(sptr_t indic, sptr_t flags) { - send(SCI_INDICSETFLAGS, indic, flags); -} - -sptr_t ScintillaEdit::indicFlags(sptr_t indic) const { - return send(SCI_INDICGETFLAGS, indic, 0); -} - -void ScintillaEdit::setWhitespaceFore(bool useSetting, sptr_t fore) { - send(SCI_SETWHITESPACEFORE, useSetting, fore); -} - -void ScintillaEdit::setWhitespaceBack(bool useSetting, sptr_t back) { - send(SCI_SETWHITESPACEBACK, useSetting, back); -} - -void ScintillaEdit::setWhitespaceSize(sptr_t size) { - send(SCI_SETWHITESPACESIZE, size, 0); -} - -sptr_t ScintillaEdit::whitespaceSize() const { - return send(SCI_GETWHITESPACESIZE, 0, 0); -} - -void ScintillaEdit::setStyleBits(sptr_t bits) { - send(SCI_SETSTYLEBITS, bits, 0); -} - -sptr_t ScintillaEdit::styleBits() const { - return send(SCI_GETSTYLEBITS, 0, 0); -} - -void ScintillaEdit::setLineState(sptr_t line, sptr_t state) { - send(SCI_SETLINESTATE, line, state); -} - -sptr_t ScintillaEdit::lineState(sptr_t line) const { - return send(SCI_GETLINESTATE, line, 0); -} - -sptr_t ScintillaEdit::maxLineState() const { - return send(SCI_GETMAXLINESTATE, 0, 0); -} - -bool ScintillaEdit::caretLineVisible() const { - return send(SCI_GETCARETLINEVISIBLE, 0, 0); -} - -void ScintillaEdit::setCaretLineVisible(bool show) { - send(SCI_SETCARETLINEVISIBLE, show, 0); -} - -sptr_t ScintillaEdit::caretLineBack() const { - return send(SCI_GETCARETLINEBACK, 0, 0); -} - -void ScintillaEdit::setCaretLineBack(sptr_t back) { - send(SCI_SETCARETLINEBACK, back, 0); -} - -void ScintillaEdit::styleSetChangeable(sptr_t style, bool changeable) { - send(SCI_STYLESETCHANGEABLE, style, changeable); -} - -void ScintillaEdit::autoCShow(sptr_t lenEntered, const char * itemList) { - send(SCI_AUTOCSHOW, lenEntered, (sptr_t)itemList); -} - -void ScintillaEdit::autoCCancel() { - send(SCI_AUTOCCANCEL, 0, 0); -} - -bool ScintillaEdit::autoCActive() { - return send(SCI_AUTOCACTIVE, 0, 0); -} - -sptr_t ScintillaEdit::autoCPosStart() { - return send(SCI_AUTOCPOSSTART, 0, 0); -} - -void ScintillaEdit::autoCComplete() { - send(SCI_AUTOCCOMPLETE, 0, 0); -} - -void ScintillaEdit::autoCStops(const char * characterSet) { - send(SCI_AUTOCSTOPS, 0, (sptr_t)characterSet); -} - -void ScintillaEdit::autoCSetSeparator(sptr_t separatorCharacter) { - send(SCI_AUTOCSETSEPARATOR, separatorCharacter, 0); -} - -sptr_t ScintillaEdit::autoCSeparator() const { - return send(SCI_AUTOCGETSEPARATOR, 0, 0); -} - -void ScintillaEdit::autoCSelect(const char * text) { - send(SCI_AUTOCSELECT, 0, (sptr_t)text); -} - -void ScintillaEdit::autoCSetCancelAtStart(bool cancel) { - send(SCI_AUTOCSETCANCELATSTART, cancel, 0); -} - -bool ScintillaEdit::autoCCancelAtStart() const { - return send(SCI_AUTOCGETCANCELATSTART, 0, 0); -} - -void ScintillaEdit::autoCSetFillUps(const char * characterSet) { - send(SCI_AUTOCSETFILLUPS, 0, (sptr_t)characterSet); -} - -void ScintillaEdit::autoCSetChooseSingle(bool chooseSingle) { - send(SCI_AUTOCSETCHOOSESINGLE, chooseSingle, 0); -} - -bool ScintillaEdit::autoCChooseSingle() const { - return send(SCI_AUTOCGETCHOOSESINGLE, 0, 0); -} - -void ScintillaEdit::autoCSetIgnoreCase(bool ignoreCase) { - send(SCI_AUTOCSETIGNORECASE, ignoreCase, 0); -} - -bool ScintillaEdit::autoCIgnoreCase() const { - return send(SCI_AUTOCGETIGNORECASE, 0, 0); -} - -void ScintillaEdit::userListShow(sptr_t listType, const char * itemList) { - send(SCI_USERLISTSHOW, listType, (sptr_t)itemList); -} - -void ScintillaEdit::autoCSetAutoHide(bool autoHide) { - send(SCI_AUTOCSETAUTOHIDE, autoHide, 0); -} - -bool ScintillaEdit::autoCAutoHide() const { - return send(SCI_AUTOCGETAUTOHIDE, 0, 0); -} - -void ScintillaEdit::autoCSetDropRestOfWord(bool dropRestOfWord) { - send(SCI_AUTOCSETDROPRESTOFWORD, dropRestOfWord, 0); -} - -bool ScintillaEdit::autoCDropRestOfWord() const { - return send(SCI_AUTOCGETDROPRESTOFWORD, 0, 0); -} - -void ScintillaEdit::registerImage(sptr_t type, const char * xpmData) { - send(SCI_REGISTERIMAGE, type, (sptr_t)xpmData); -} - -void ScintillaEdit::clearRegisteredImages() { - send(SCI_CLEARREGISTEREDIMAGES, 0, 0); -} - -sptr_t ScintillaEdit::autoCTypeSeparator() const { - return send(SCI_AUTOCGETTYPESEPARATOR, 0, 0); -} - -void ScintillaEdit::autoCSetTypeSeparator(sptr_t separatorCharacter) { - send(SCI_AUTOCSETTYPESEPARATOR, separatorCharacter, 0); -} - -void ScintillaEdit::autoCSetMaxWidth(sptr_t characterCount) { - send(SCI_AUTOCSETMAXWIDTH, characterCount, 0); -} - -sptr_t ScintillaEdit::autoCMaxWidth() const { - return send(SCI_AUTOCGETMAXWIDTH, 0, 0); -} - -void ScintillaEdit::autoCSetMaxHeight(sptr_t rowCount) { - send(SCI_AUTOCSETMAXHEIGHT, rowCount, 0); -} - -sptr_t ScintillaEdit::autoCMaxHeight() const { - return send(SCI_AUTOCGETMAXHEIGHT, 0, 0); -} - -void ScintillaEdit::setIndent(sptr_t indentSize) { - send(SCI_SETINDENT, indentSize, 0); -} - -sptr_t ScintillaEdit::indent() const { - return send(SCI_GETINDENT, 0, 0); -} - -void ScintillaEdit::setUseTabs(bool useTabs) { - send(SCI_SETUSETABS, useTabs, 0); -} - -bool ScintillaEdit::useTabs() const { - return send(SCI_GETUSETABS, 0, 0); -} - -void ScintillaEdit::setLineIndentation(sptr_t line, sptr_t indentSize) { - send(SCI_SETLINEINDENTATION, line, indentSize); -} - -sptr_t ScintillaEdit::lineIndentation(sptr_t line) const { - return send(SCI_GETLINEINDENTATION, line, 0); -} - -sptr_t ScintillaEdit::lineIndentPosition(sptr_t line) const { - return send(SCI_GETLINEINDENTPOSITION, line, 0); -} - -sptr_t ScintillaEdit::column(sptr_t pos) const { - return send(SCI_GETCOLUMN, pos, 0); -} - -sptr_t ScintillaEdit::countCharacters(sptr_t startPos, sptr_t endPos) { - return send(SCI_COUNTCHARACTERS, startPos, endPos); -} - -void ScintillaEdit::setHScrollBar(bool show) { - send(SCI_SETHSCROLLBAR, show, 0); -} - -bool ScintillaEdit::hScrollBar() const { - return send(SCI_GETHSCROLLBAR, 0, 0); -} - -void ScintillaEdit::setIndentationGuides(sptr_t indentView) { - send(SCI_SETINDENTATIONGUIDES, indentView, 0); -} - -sptr_t ScintillaEdit::indentationGuides() const { - return send(SCI_GETINDENTATIONGUIDES, 0, 0); -} - -void ScintillaEdit::setHighlightGuide(sptr_t column) { - send(SCI_SETHIGHLIGHTGUIDE, column, 0); -} - -sptr_t ScintillaEdit::highlightGuide() const { - return send(SCI_GETHIGHLIGHTGUIDE, 0, 0); -} - -sptr_t ScintillaEdit::lineEndPosition(sptr_t line) const { - return send(SCI_GETLINEENDPOSITION, line, 0); -} - -sptr_t ScintillaEdit::codePage() const { - return send(SCI_GETCODEPAGE, 0, 0); -} - -sptr_t ScintillaEdit::caretFore() const { - return send(SCI_GETCARETFORE, 0, 0); -} - -bool ScintillaEdit::readOnly() const { - return send(SCI_GETREADONLY, 0, 0); -} - -void ScintillaEdit::setCurrentPos(sptr_t pos) { - send(SCI_SETCURRENTPOS, pos, 0); -} - -void ScintillaEdit::setSelectionStart(sptr_t pos) { - send(SCI_SETSELECTIONSTART, pos, 0); -} - -sptr_t ScintillaEdit::selectionStart() const { - return send(SCI_GETSELECTIONSTART, 0, 0); -} - -void ScintillaEdit::setSelectionEnd(sptr_t pos) { - send(SCI_SETSELECTIONEND, pos, 0); -} - -sptr_t ScintillaEdit::selectionEnd() const { - return send(SCI_GETSELECTIONEND, 0, 0); -} - -void ScintillaEdit::setEmptySelection(sptr_t pos) { - send(SCI_SETEMPTYSELECTION, pos, 0); -} - -void ScintillaEdit::setPrintMagnification(sptr_t magnification) { - send(SCI_SETPRINTMAGNIFICATION, magnification, 0); -} - -sptr_t ScintillaEdit::printMagnification() const { - return send(SCI_GETPRINTMAGNIFICATION, 0, 0); -} - -void ScintillaEdit::setPrintColourMode(sptr_t mode) { - send(SCI_SETPRINTCOLOURMODE, mode, 0); -} - -sptr_t ScintillaEdit::printColourMode() const { - return send(SCI_GETPRINTCOLOURMODE, 0, 0); -} - -sptr_t ScintillaEdit::firstVisibleLine() const { - return send(SCI_GETFIRSTVISIBLELINE, 0, 0); -} - -QByteArray ScintillaEdit::getLine(sptr_t line) { - return TextReturner(SCI_GETLINE, line); -} - -sptr_t ScintillaEdit::lineCount() const { - return send(SCI_GETLINECOUNT, 0, 0); -} - -void ScintillaEdit::setMarginLeft(sptr_t pixelWidth) { - send(SCI_SETMARGINLEFT, 0, pixelWidth); -} - -sptr_t ScintillaEdit::marginLeft() const { - return send(SCI_GETMARGINLEFT, 0, 0); -} - -void ScintillaEdit::setMarginRight(sptr_t pixelWidth) { - send(SCI_SETMARGINRIGHT, 0, pixelWidth); -} - -sptr_t ScintillaEdit::marginRight() const { - return send(SCI_GETMARGINRIGHT, 0, 0); -} - -bool ScintillaEdit::modify() const { - return send(SCI_GETMODIFY, 0, 0); -} - -void ScintillaEdit::setSel(sptr_t start, sptr_t end) { - send(SCI_SETSEL, start, end); -} - -QByteArray ScintillaEdit::getSelText() { - return TextReturner(SCI_GETSELTEXT, 0); -} - -void ScintillaEdit::hideSelection(bool normal) { - send(SCI_HIDESELECTION, normal, 0); -} - -sptr_t ScintillaEdit::pointXFromPosition(sptr_t pos) { - return send(SCI_POINTXFROMPOSITION, 0, pos); -} - -sptr_t ScintillaEdit::pointYFromPosition(sptr_t pos) { - return send(SCI_POINTYFROMPOSITION, 0, pos); -} - -sptr_t ScintillaEdit::lineFromPosition(sptr_t pos) { - return send(SCI_LINEFROMPOSITION, pos, 0); -} - -sptr_t ScintillaEdit::positionFromLine(sptr_t line) { - return send(SCI_POSITIONFROMLINE, line, 0); -} - -void ScintillaEdit::lineScroll(sptr_t columns, sptr_t lines) { - send(SCI_LINESCROLL, columns, lines); -} - -void ScintillaEdit::scrollCaret() { - send(SCI_SCROLLCARET, 0, 0); -} - -void ScintillaEdit::scrollRange(sptr_t secondary, sptr_t primary) { - send(SCI_SCROLLRANGE, secondary, primary); -} - -void ScintillaEdit::replaceSel(const char * text) { - send(SCI_REPLACESEL, 0, (sptr_t)text); -} - -void ScintillaEdit::setReadOnly(bool readOnly) { - send(SCI_SETREADONLY, readOnly, 0); -} - -void ScintillaEdit::null() { - send(SCI_NULL, 0, 0); -} - -bool ScintillaEdit::canPaste() { - return send(SCI_CANPASTE, 0, 0); -} - -bool ScintillaEdit::canUndo() { - return send(SCI_CANUNDO, 0, 0); -} - -void ScintillaEdit::emptyUndoBuffer() { - send(SCI_EMPTYUNDOBUFFER, 0, 0); -} - -void ScintillaEdit::undo() { - send(SCI_UNDO, 0, 0); -} - -void ScintillaEdit::cut() { - send(SCI_CUT, 0, 0); -} - -void ScintillaEdit::copy() { - send(SCI_COPY, 0, 0); -} - -void ScintillaEdit::paste() { - send(SCI_PASTE, 0, 0); -} - -void ScintillaEdit::clear() { - send(SCI_CLEAR, 0, 0); -} - -void ScintillaEdit::setText(const char * text) { - send(SCI_SETTEXT, 0, (sptr_t)text); -} - -QByteArray ScintillaEdit::getText(sptr_t length) { - return TextReturner(SCI_GETTEXT, length); -} - -sptr_t ScintillaEdit::textLength() const { - return send(SCI_GETTEXTLENGTH, 0, 0); -} - -sptr_t ScintillaEdit::directFunction() const { - return send(SCI_GETDIRECTFUNCTION, 0, 0); -} - -sptr_t ScintillaEdit::directPointer() const { - return send(SCI_GETDIRECTPOINTER, 0, 0); -} - -void ScintillaEdit::setOvertype(bool overtype) { - send(SCI_SETOVERTYPE, overtype, 0); -} - -bool ScintillaEdit::overtype() const { - return send(SCI_GETOVERTYPE, 0, 0); -} - -void ScintillaEdit::setCaretWidth(sptr_t pixelWidth) { - send(SCI_SETCARETWIDTH, pixelWidth, 0); -} - -sptr_t ScintillaEdit::caretWidth() const { - return send(SCI_GETCARETWIDTH, 0, 0); -} - -void ScintillaEdit::setTargetStart(sptr_t pos) { - send(SCI_SETTARGETSTART, pos, 0); -} - -sptr_t ScintillaEdit::targetStart() const { - return send(SCI_GETTARGETSTART, 0, 0); -} - -void ScintillaEdit::setTargetEnd(sptr_t pos) { - send(SCI_SETTARGETEND, pos, 0); -} - -sptr_t ScintillaEdit::targetEnd() const { - return send(SCI_GETTARGETEND, 0, 0); -} - -void ScintillaEdit::setTargetRange(sptr_t start, sptr_t end) { - send(SCI_SETTARGETRANGE, start, end); -} - -QByteArray ScintillaEdit::targetText() const { - return TextReturner(SCI_GETTARGETTEXT, 0); -} - -void ScintillaEdit::targetFromSelection() { - send(SCI_TARGETFROMSELECTION, 0, 0); -} - -void ScintillaEdit::targetWholeDocument() { - send(SCI_TARGETWHOLEDOCUMENT, 0, 0); -} - -sptr_t ScintillaEdit::replaceTarget(sptr_t length, const char * text) { - return send(SCI_REPLACETARGET, length, (sptr_t)text); -} - -sptr_t ScintillaEdit::replaceTargetRE(sptr_t length, const char * text) { - return send(SCI_REPLACETARGETRE, length, (sptr_t)text); -} - -sptr_t ScintillaEdit::searchInTarget(sptr_t length, const char * text) { - return send(SCI_SEARCHINTARGET, length, (sptr_t)text); -} - -void ScintillaEdit::setSearchFlags(sptr_t flags) { - send(SCI_SETSEARCHFLAGS, flags, 0); -} - -sptr_t ScintillaEdit::searchFlags() const { - return send(SCI_GETSEARCHFLAGS, 0, 0); -} - -void ScintillaEdit::callTipShow(sptr_t pos, const char * definition) { - send(SCI_CALLTIPSHOW, pos, (sptr_t)definition); -} - -void ScintillaEdit::callTipCancel() { - send(SCI_CALLTIPCANCEL, 0, 0); -} - -bool ScintillaEdit::callTipActive() { - return send(SCI_CALLTIPACTIVE, 0, 0); -} - -sptr_t ScintillaEdit::callTipPosStart() { - return send(SCI_CALLTIPPOSSTART, 0, 0); -} - -void ScintillaEdit::callTipSetPosStart(sptr_t posStart) { - send(SCI_CALLTIPSETPOSSTART, posStart, 0); -} - -void ScintillaEdit::callTipSetHlt(sptr_t start, sptr_t end) { - send(SCI_CALLTIPSETHLT, start, end); -} - -void ScintillaEdit::callTipSetBack(sptr_t back) { - send(SCI_CALLTIPSETBACK, back, 0); -} - -void ScintillaEdit::callTipSetFore(sptr_t fore) { - send(SCI_CALLTIPSETFORE, fore, 0); -} - -void ScintillaEdit::callTipSetForeHlt(sptr_t fore) { - send(SCI_CALLTIPSETFOREHLT, fore, 0); -} - -void ScintillaEdit::callTipUseStyle(sptr_t tabSize) { - send(SCI_CALLTIPUSESTYLE, tabSize, 0); -} - -void ScintillaEdit::callTipSetPosition(bool above) { - send(SCI_CALLTIPSETPOSITION, above, 0); -} - -sptr_t ScintillaEdit::visibleFromDocLine(sptr_t line) { - return send(SCI_VISIBLEFROMDOCLINE, line, 0); -} - -sptr_t ScintillaEdit::docLineFromVisible(sptr_t lineDisplay) { - return send(SCI_DOCLINEFROMVISIBLE, lineDisplay, 0); -} - -sptr_t ScintillaEdit::wrapCount(sptr_t line) { - return send(SCI_WRAPCOUNT, line, 0); -} - -void ScintillaEdit::setFoldLevel(sptr_t line, sptr_t level) { - send(SCI_SETFOLDLEVEL, line, level); -} - -sptr_t ScintillaEdit::foldLevel(sptr_t line) const { - return send(SCI_GETFOLDLEVEL, line, 0); -} - -sptr_t ScintillaEdit::lastChild(sptr_t line, sptr_t level) const { - return send(SCI_GETLASTCHILD, line, level); -} - -sptr_t ScintillaEdit::foldParent(sptr_t line) const { - return send(SCI_GETFOLDPARENT, line, 0); -} - -void ScintillaEdit::showLines(sptr_t lineStart, sptr_t lineEnd) { - send(SCI_SHOWLINES, lineStart, lineEnd); -} - -void ScintillaEdit::hideLines(sptr_t lineStart, sptr_t lineEnd) { - send(SCI_HIDELINES, lineStart, lineEnd); -} - -bool ScintillaEdit::lineVisible(sptr_t line) const { - return send(SCI_GETLINEVISIBLE, line, 0); -} - -bool ScintillaEdit::allLinesVisible() const { - return send(SCI_GETALLLINESVISIBLE, 0, 0); -} - -void ScintillaEdit::setFoldExpanded(sptr_t line, bool expanded) { - send(SCI_SETFOLDEXPANDED, line, expanded); -} - -bool ScintillaEdit::foldExpanded(sptr_t line) const { - return send(SCI_GETFOLDEXPANDED, line, 0); -} - -void ScintillaEdit::toggleFold(sptr_t line) { - send(SCI_TOGGLEFOLD, line, 0); -} - -void ScintillaEdit::foldLine(sptr_t line, sptr_t action) { - send(SCI_FOLDLINE, line, action); -} - -void ScintillaEdit::foldChildren(sptr_t line, sptr_t action) { - send(SCI_FOLDCHILDREN, line, action); -} - -void ScintillaEdit::expandChildren(sptr_t line, sptr_t level) { - send(SCI_EXPANDCHILDREN, line, level); -} - -void ScintillaEdit::foldAll(sptr_t action) { - send(SCI_FOLDALL, action, 0); -} - -void ScintillaEdit::ensureVisible(sptr_t line) { - send(SCI_ENSUREVISIBLE, line, 0); -} - -void ScintillaEdit::setAutomaticFold(sptr_t automaticFold) { - send(SCI_SETAUTOMATICFOLD, automaticFold, 0); -} - -sptr_t ScintillaEdit::automaticFold() const { - return send(SCI_GETAUTOMATICFOLD, 0, 0); -} - -void ScintillaEdit::setFoldFlags(sptr_t flags) { - send(SCI_SETFOLDFLAGS, flags, 0); -} - -void ScintillaEdit::ensureVisibleEnforcePolicy(sptr_t line) { - send(SCI_ENSUREVISIBLEENFORCEPOLICY, line, 0); -} - -void ScintillaEdit::setTabIndents(bool tabIndents) { - send(SCI_SETTABINDENTS, tabIndents, 0); -} - -bool ScintillaEdit::tabIndents() const { - return send(SCI_GETTABINDENTS, 0, 0); -} - -void ScintillaEdit::setBackSpaceUnIndents(bool bsUnIndents) { - send(SCI_SETBACKSPACEUNINDENTS, bsUnIndents, 0); -} - -bool ScintillaEdit::backSpaceUnIndents() const { - return send(SCI_GETBACKSPACEUNINDENTS, 0, 0); -} - -void ScintillaEdit::setMouseDwellTime(sptr_t periodMilliseconds) { - send(SCI_SETMOUSEDWELLTIME, periodMilliseconds, 0); -} - -sptr_t ScintillaEdit::mouseDwellTime() const { - return send(SCI_GETMOUSEDWELLTIME, 0, 0); -} - -sptr_t ScintillaEdit::wordStartPosition(sptr_t pos, bool onlyWordCharacters) { - return send(SCI_WORDSTARTPOSITION, pos, onlyWordCharacters); -} - -sptr_t ScintillaEdit::wordEndPosition(sptr_t pos, bool onlyWordCharacters) { - return send(SCI_WORDENDPOSITION, pos, onlyWordCharacters); -} - -bool ScintillaEdit::isRangeWord(sptr_t start, sptr_t end) { - return send(SCI_ISRANGEWORD, start, end); -} - -void ScintillaEdit::setWrapMode(sptr_t mode) { - send(SCI_SETWRAPMODE, mode, 0); -} - -sptr_t ScintillaEdit::wrapMode() const { - return send(SCI_GETWRAPMODE, 0, 0); -} - -void ScintillaEdit::setWrapVisualFlags(sptr_t wrapVisualFlags) { - send(SCI_SETWRAPVISUALFLAGS, wrapVisualFlags, 0); -} - -sptr_t ScintillaEdit::wrapVisualFlags() const { - return send(SCI_GETWRAPVISUALFLAGS, 0, 0); -} - -void ScintillaEdit::setWrapVisualFlagsLocation(sptr_t wrapVisualFlagsLocation) { - send(SCI_SETWRAPVISUALFLAGSLOCATION, wrapVisualFlagsLocation, 0); -} - -sptr_t ScintillaEdit::wrapVisualFlagsLocation() const { - return send(SCI_GETWRAPVISUALFLAGSLOCATION, 0, 0); -} - -void ScintillaEdit::setWrapStartIndent(sptr_t indent) { - send(SCI_SETWRAPSTARTINDENT, indent, 0); -} - -sptr_t ScintillaEdit::wrapStartIndent() const { - return send(SCI_GETWRAPSTARTINDENT, 0, 0); -} - -void ScintillaEdit::setWrapIndentMode(sptr_t mode) { - send(SCI_SETWRAPINDENTMODE, mode, 0); -} - -sptr_t ScintillaEdit::wrapIndentMode() const { - return send(SCI_GETWRAPINDENTMODE, 0, 0); -} - -void ScintillaEdit::setLayoutCache(sptr_t mode) { - send(SCI_SETLAYOUTCACHE, mode, 0); -} - -sptr_t ScintillaEdit::layoutCache() const { - return send(SCI_GETLAYOUTCACHE, 0, 0); -} - -void ScintillaEdit::setScrollWidth(sptr_t pixelWidth) { - send(SCI_SETSCROLLWIDTH, pixelWidth, 0); -} - -sptr_t ScintillaEdit::scrollWidth() const { - return send(SCI_GETSCROLLWIDTH, 0, 0); -} - -void ScintillaEdit::setScrollWidthTracking(bool tracking) { - send(SCI_SETSCROLLWIDTHTRACKING, tracking, 0); -} - -bool ScintillaEdit::scrollWidthTracking() const { - return send(SCI_GETSCROLLWIDTHTRACKING, 0, 0); -} - -sptr_t ScintillaEdit::textWidth(sptr_t style, const char * text) { - return send(SCI_TEXTWIDTH, style, (sptr_t)text); -} - -void ScintillaEdit::setEndAtLastLine(bool endAtLastLine) { - send(SCI_SETENDATLASTLINE, endAtLastLine, 0); -} - -bool ScintillaEdit::endAtLastLine() const { - return send(SCI_GETENDATLASTLINE, 0, 0); -} - -sptr_t ScintillaEdit::textHeight(sptr_t line) { - return send(SCI_TEXTHEIGHT, line, 0); -} - -void ScintillaEdit::setVScrollBar(bool show) { - send(SCI_SETVSCROLLBAR, show, 0); -} - -bool ScintillaEdit::vScrollBar() const { - return send(SCI_GETVSCROLLBAR, 0, 0); -} - -void ScintillaEdit::appendText(sptr_t length, const char * text) { - send(SCI_APPENDTEXT, length, (sptr_t)text); -} - -bool ScintillaEdit::twoPhaseDraw() const { - return send(SCI_GETTWOPHASEDRAW, 0, 0); -} - -void ScintillaEdit::setTwoPhaseDraw(bool twoPhase) { - send(SCI_SETTWOPHASEDRAW, twoPhase, 0); -} - -sptr_t ScintillaEdit::phasesDraw() const { - return send(SCI_GETPHASESDRAW, 0, 0); -} - -void ScintillaEdit::setPhasesDraw(sptr_t phases) { - send(SCI_SETPHASESDRAW, phases, 0); -} - -void ScintillaEdit::setFontQuality(sptr_t fontQuality) { - send(SCI_SETFONTQUALITY, fontQuality, 0); -} - -sptr_t ScintillaEdit::fontQuality() const { - return send(SCI_GETFONTQUALITY, 0, 0); -} - -void ScintillaEdit::setFirstVisibleLine(sptr_t lineDisplay) { - send(SCI_SETFIRSTVISIBLELINE, lineDisplay, 0); -} - -void ScintillaEdit::setMultiPaste(sptr_t multiPaste) { - send(SCI_SETMULTIPASTE, multiPaste, 0); -} - -sptr_t ScintillaEdit::multiPaste() const { - return send(SCI_GETMULTIPASTE, 0, 0); -} - -QByteArray ScintillaEdit::tag(sptr_t tagNumber) const { - return TextReturner(SCI_GETTAG, tagNumber); -} - -void ScintillaEdit::linesJoin() { - send(SCI_LINESJOIN, 0, 0); -} - -void ScintillaEdit::linesSplit(sptr_t pixelWidth) { - send(SCI_LINESSPLIT, pixelWidth, 0); -} - -void ScintillaEdit::setFoldMarginColour(bool useSetting, sptr_t back) { - send(SCI_SETFOLDMARGINCOLOUR, useSetting, back); -} - -void ScintillaEdit::setFoldMarginHiColour(bool useSetting, sptr_t fore) { - send(SCI_SETFOLDMARGINHICOLOUR, useSetting, fore); -} - -void ScintillaEdit::lineDown() { - send(SCI_LINEDOWN, 0, 0); -} - -void ScintillaEdit::lineDownExtend() { - send(SCI_LINEDOWNEXTEND, 0, 0); -} - -void ScintillaEdit::lineUp() { - send(SCI_LINEUP, 0, 0); -} - -void ScintillaEdit::lineUpExtend() { - send(SCI_LINEUPEXTEND, 0, 0); -} - -void ScintillaEdit::charLeft() { - send(SCI_CHARLEFT, 0, 0); -} - -void ScintillaEdit::charLeftExtend() { - send(SCI_CHARLEFTEXTEND, 0, 0); -} - -void ScintillaEdit::charRight() { - send(SCI_CHARRIGHT, 0, 0); -} - -void ScintillaEdit::charRightExtend() { - send(SCI_CHARRIGHTEXTEND, 0, 0); -} - -void ScintillaEdit::wordLeft() { - send(SCI_WORDLEFT, 0, 0); -} - -void ScintillaEdit::wordLeftExtend() { - send(SCI_WORDLEFTEXTEND, 0, 0); -} - -void ScintillaEdit::wordRight() { - send(SCI_WORDRIGHT, 0, 0); -} - -void ScintillaEdit::wordRightExtend() { - send(SCI_WORDRIGHTEXTEND, 0, 0); -} - -void ScintillaEdit::home() { - send(SCI_HOME, 0, 0); -} - -void ScintillaEdit::homeExtend() { - send(SCI_HOMEEXTEND, 0, 0); -} - -void ScintillaEdit::lineEnd() { - send(SCI_LINEEND, 0, 0); -} - -void ScintillaEdit::lineEndExtend() { - send(SCI_LINEENDEXTEND, 0, 0); -} - -void ScintillaEdit::documentStart() { - send(SCI_DOCUMENTSTART, 0, 0); -} - -void ScintillaEdit::documentStartExtend() { - send(SCI_DOCUMENTSTARTEXTEND, 0, 0); -} - -void ScintillaEdit::documentEnd() { - send(SCI_DOCUMENTEND, 0, 0); -} - -void ScintillaEdit::documentEndExtend() { - send(SCI_DOCUMENTENDEXTEND, 0, 0); -} - -void ScintillaEdit::pageUp() { - send(SCI_PAGEUP, 0, 0); -} - -void ScintillaEdit::pageUpExtend() { - send(SCI_PAGEUPEXTEND, 0, 0); -} - -void ScintillaEdit::pageDown() { - send(SCI_PAGEDOWN, 0, 0); -} - -void ScintillaEdit::pageDownExtend() { - send(SCI_PAGEDOWNEXTEND, 0, 0); -} - -void ScintillaEdit::editToggleOvertype() { - send(SCI_EDITTOGGLEOVERTYPE, 0, 0); -} - -void ScintillaEdit::cancel() { - send(SCI_CANCEL, 0, 0); -} - -void ScintillaEdit::deleteBack() { - send(SCI_DELETEBACK, 0, 0); -} - -void ScintillaEdit::tab() { - send(SCI_TAB, 0, 0); -} - -void ScintillaEdit::backTab() { - send(SCI_BACKTAB, 0, 0); -} - -void ScintillaEdit::newLine() { - send(SCI_NEWLINE, 0, 0); -} - -void ScintillaEdit::formFeed() { - send(SCI_FORMFEED, 0, 0); -} - -void ScintillaEdit::vCHome() { - send(SCI_VCHOME, 0, 0); -} - -void ScintillaEdit::vCHomeExtend() { - send(SCI_VCHOMEEXTEND, 0, 0); -} - -void ScintillaEdit::zoomIn() { - send(SCI_ZOOMIN, 0, 0); -} - -void ScintillaEdit::zoomOut() { - send(SCI_ZOOMOUT, 0, 0); -} - -void ScintillaEdit::delWordLeft() { - send(SCI_DELWORDLEFT, 0, 0); -} - -void ScintillaEdit::delWordRight() { - send(SCI_DELWORDRIGHT, 0, 0); -} - -void ScintillaEdit::delWordRightEnd() { - send(SCI_DELWORDRIGHTEND, 0, 0); -} - -void ScintillaEdit::lineCut() { - send(SCI_LINECUT, 0, 0); -} - -void ScintillaEdit::lineDelete() { - send(SCI_LINEDELETE, 0, 0); -} - -void ScintillaEdit::lineTranspose() { - send(SCI_LINETRANSPOSE, 0, 0); -} - -void ScintillaEdit::lineDuplicate() { - send(SCI_LINEDUPLICATE, 0, 0); -} - -void ScintillaEdit::lowerCase() { - send(SCI_LOWERCASE, 0, 0); -} - -void ScintillaEdit::upperCase() { - send(SCI_UPPERCASE, 0, 0); -} - -void ScintillaEdit::lineScrollDown() { - send(SCI_LINESCROLLDOWN, 0, 0); -} - -void ScintillaEdit::lineScrollUp() { - send(SCI_LINESCROLLUP, 0, 0); -} - -void ScintillaEdit::deleteBackNotLine() { - send(SCI_DELETEBACKNOTLINE, 0, 0); -} - -void ScintillaEdit::homeDisplay() { - send(SCI_HOMEDISPLAY, 0, 0); -} - -void ScintillaEdit::homeDisplayExtend() { - send(SCI_HOMEDISPLAYEXTEND, 0, 0); -} - -void ScintillaEdit::lineEndDisplay() { - send(SCI_LINEENDDISPLAY, 0, 0); -} - -void ScintillaEdit::lineEndDisplayExtend() { - send(SCI_LINEENDDISPLAYEXTEND, 0, 0); -} - -void ScintillaEdit::homeWrap() { - send(SCI_HOMEWRAP, 0, 0); -} - -void ScintillaEdit::homeWrapExtend() { - send(SCI_HOMEWRAPEXTEND, 0, 0); -} - -void ScintillaEdit::lineEndWrap() { - send(SCI_LINEENDWRAP, 0, 0); -} - -void ScintillaEdit::lineEndWrapExtend() { - send(SCI_LINEENDWRAPEXTEND, 0, 0); -} - -void ScintillaEdit::vCHomeWrap() { - send(SCI_VCHOMEWRAP, 0, 0); -} - -void ScintillaEdit::vCHomeWrapExtend() { - send(SCI_VCHOMEWRAPEXTEND, 0, 0); -} - -void ScintillaEdit::lineCopy() { - send(SCI_LINECOPY, 0, 0); -} - -void ScintillaEdit::moveCaretInsideView() { - send(SCI_MOVECARETINSIDEVIEW, 0, 0); -} - -sptr_t ScintillaEdit::lineLength(sptr_t line) { - return send(SCI_LINELENGTH, line, 0); -} - -void ScintillaEdit::braceHighlight(sptr_t pos1, sptr_t pos2) { - send(SCI_BRACEHIGHLIGHT, pos1, pos2); -} - -void ScintillaEdit::braceHighlightIndicator(bool useBraceHighlightIndicator, sptr_t indicator) { - send(SCI_BRACEHIGHLIGHTINDICATOR, useBraceHighlightIndicator, indicator); -} - -void ScintillaEdit::braceBadLight(sptr_t pos) { - send(SCI_BRACEBADLIGHT, pos, 0); -} - -void ScintillaEdit::braceBadLightIndicator(bool useBraceBadLightIndicator, sptr_t indicator) { - send(SCI_BRACEBADLIGHTINDICATOR, useBraceBadLightIndicator, indicator); -} - -sptr_t ScintillaEdit::braceMatch(sptr_t pos) { - return send(SCI_BRACEMATCH, pos, 0); -} - -bool ScintillaEdit::viewEOL() const { - return send(SCI_GETVIEWEOL, 0, 0); -} - -void ScintillaEdit::setViewEOL(bool visible) { - send(SCI_SETVIEWEOL, visible, 0); -} - -sptr_t ScintillaEdit::docPointer() const { - return send(SCI_GETDOCPOINTER, 0, 0); -} - -void ScintillaEdit::setDocPointer(sptr_t pointer) { - send(SCI_SETDOCPOINTER, 0, pointer); -} - -void ScintillaEdit::setModEventMask(sptr_t mask) { - send(SCI_SETMODEVENTMASK, mask, 0); -} - -sptr_t ScintillaEdit::edgeColumn() const { - return send(SCI_GETEDGECOLUMN, 0, 0); -} - -void ScintillaEdit::setEdgeColumn(sptr_t column) { - send(SCI_SETEDGECOLUMN, column, 0); -} - -sptr_t ScintillaEdit::edgeMode() const { - return send(SCI_GETEDGEMODE, 0, 0); -} - -void ScintillaEdit::setEdgeMode(sptr_t mode) { - send(SCI_SETEDGEMODE, mode, 0); -} - -sptr_t ScintillaEdit::edgeColour() const { - return send(SCI_GETEDGECOLOUR, 0, 0); -} - -void ScintillaEdit::setEdgeColour(sptr_t edgeColour) { - send(SCI_SETEDGECOLOUR, edgeColour, 0); -} - -void ScintillaEdit::searchAnchor() { - send(SCI_SEARCHANCHOR, 0, 0); -} - -sptr_t ScintillaEdit::searchNext(sptr_t flags, const char * text) { - return send(SCI_SEARCHNEXT, flags, (sptr_t)text); -} - -sptr_t ScintillaEdit::searchPrev(sptr_t flags, const char * text) { - return send(SCI_SEARCHPREV, flags, (sptr_t)text); -} - -sptr_t ScintillaEdit::linesOnScreen() const { - return send(SCI_LINESONSCREEN, 0, 0); -} - -void ScintillaEdit::usePopUp(bool allowPopUp) { - send(SCI_USEPOPUP, allowPopUp, 0); -} - -bool ScintillaEdit::selectionIsRectangle() const { - return send(SCI_SELECTIONISRECTANGLE, 0, 0); -} - -void ScintillaEdit::setZoom(sptr_t zoom) { - send(SCI_SETZOOM, zoom, 0); -} - -sptr_t ScintillaEdit::zoom() const { - return send(SCI_GETZOOM, 0, 0); -} - -sptr_t ScintillaEdit::createDocument() { - return send(SCI_CREATEDOCUMENT, 0, 0); -} - -void ScintillaEdit::addRefDocument(sptr_t doc) { - send(SCI_ADDREFDOCUMENT, 0, doc); -} - -void ScintillaEdit::releaseDocument(sptr_t doc) { - send(SCI_RELEASEDOCUMENT, 0, doc); -} - -sptr_t ScintillaEdit::modEventMask() const { - return send(SCI_GETMODEVENTMASK, 0, 0); -} - -void ScintillaEdit::setFocus(bool focus) { - send(SCI_SETFOCUS, focus, 0); -} - -bool ScintillaEdit::focus() const { - return send(SCI_GETFOCUS, 0, 0); -} - -void ScintillaEdit::setStatus(sptr_t statusCode) { - send(SCI_SETSTATUS, statusCode, 0); -} - -sptr_t ScintillaEdit::status() const { - return send(SCI_GETSTATUS, 0, 0); -} - -void ScintillaEdit::setMouseDownCaptures(bool captures) { - send(SCI_SETMOUSEDOWNCAPTURES, captures, 0); -} - -bool ScintillaEdit::mouseDownCaptures() const { - return send(SCI_GETMOUSEDOWNCAPTURES, 0, 0); -} - -void ScintillaEdit::setCursor(sptr_t cursorType) { - send(SCI_SETCURSOR, cursorType, 0); -} - -sptr_t ScintillaEdit::cursor() const { - return send(SCI_GETCURSOR, 0, 0); -} - -void ScintillaEdit::setControlCharSymbol(sptr_t symbol) { - send(SCI_SETCONTROLCHARSYMBOL, symbol, 0); -} - -sptr_t ScintillaEdit::controlCharSymbol() const { - return send(SCI_GETCONTROLCHARSYMBOL, 0, 0); -} - -void ScintillaEdit::wordPartLeft() { - send(SCI_WORDPARTLEFT, 0, 0); -} - -void ScintillaEdit::wordPartLeftExtend() { - send(SCI_WORDPARTLEFTEXTEND, 0, 0); -} - -void ScintillaEdit::wordPartRight() { - send(SCI_WORDPARTRIGHT, 0, 0); -} - -void ScintillaEdit::wordPartRightExtend() { - send(SCI_WORDPARTRIGHTEXTEND, 0, 0); -} - -void ScintillaEdit::setVisiblePolicy(sptr_t visiblePolicy, sptr_t visibleSlop) { - send(SCI_SETVISIBLEPOLICY, visiblePolicy, visibleSlop); -} - -void ScintillaEdit::delLineLeft() { - send(SCI_DELLINELEFT, 0, 0); -} - -void ScintillaEdit::delLineRight() { - send(SCI_DELLINERIGHT, 0, 0); -} - -void ScintillaEdit::setXOffset(sptr_t newOffset) { - send(SCI_SETXOFFSET, newOffset, 0); -} - -sptr_t ScintillaEdit::xOffset() const { - return send(SCI_GETXOFFSET, 0, 0); -} - -void ScintillaEdit::chooseCaretX() { - send(SCI_CHOOSECARETX, 0, 0); -} - -void ScintillaEdit::grabFocus() { - send(SCI_GRABFOCUS, 0, 0); -} - -void ScintillaEdit::setXCaretPolicy(sptr_t caretPolicy, sptr_t caretSlop) { - send(SCI_SETXCARETPOLICY, caretPolicy, caretSlop); -} - -void ScintillaEdit::setYCaretPolicy(sptr_t caretPolicy, sptr_t caretSlop) { - send(SCI_SETYCARETPOLICY, caretPolicy, caretSlop); -} - -void ScintillaEdit::setPrintWrapMode(sptr_t mode) { - send(SCI_SETPRINTWRAPMODE, mode, 0); -} - -sptr_t ScintillaEdit::printWrapMode() const { - return send(SCI_GETPRINTWRAPMODE, 0, 0); -} - -void ScintillaEdit::setHotspotActiveFore(bool useSetting, sptr_t fore) { - send(SCI_SETHOTSPOTACTIVEFORE, useSetting, fore); -} - -sptr_t ScintillaEdit::hotspotActiveFore() const { - return send(SCI_GETHOTSPOTACTIVEFORE, 0, 0); -} - -void ScintillaEdit::setHotspotActiveBack(bool useSetting, sptr_t back) { - send(SCI_SETHOTSPOTACTIVEBACK, useSetting, back); -} - -sptr_t ScintillaEdit::hotspotActiveBack() const { - return send(SCI_GETHOTSPOTACTIVEBACK, 0, 0); -} - -void ScintillaEdit::setHotspotActiveUnderline(bool underline) { - send(SCI_SETHOTSPOTACTIVEUNDERLINE, underline, 0); -} - -bool ScintillaEdit::hotspotActiveUnderline() const { - return send(SCI_GETHOTSPOTACTIVEUNDERLINE, 0, 0); -} - -void ScintillaEdit::setHotspotSingleLine(bool singleLine) { - send(SCI_SETHOTSPOTSINGLELINE, singleLine, 0); -} - -bool ScintillaEdit::hotspotSingleLine() const { - return send(SCI_GETHOTSPOTSINGLELINE, 0, 0); -} - -void ScintillaEdit::paraDown() { - send(SCI_PARADOWN, 0, 0); -} - -void ScintillaEdit::paraDownExtend() { - send(SCI_PARADOWNEXTEND, 0, 0); -} - -void ScintillaEdit::paraUp() { - send(SCI_PARAUP, 0, 0); -} - -void ScintillaEdit::paraUpExtend() { - send(SCI_PARAUPEXTEND, 0, 0); -} - -sptr_t ScintillaEdit::positionBefore(sptr_t pos) { - return send(SCI_POSITIONBEFORE, pos, 0); -} - -sptr_t ScintillaEdit::positionAfter(sptr_t pos) { - return send(SCI_POSITIONAFTER, pos, 0); -} - -sptr_t ScintillaEdit::positionRelative(sptr_t pos, sptr_t relative) { - return send(SCI_POSITIONRELATIVE, pos, relative); -} - -void ScintillaEdit::copyRange(sptr_t start, sptr_t end) { - send(SCI_COPYRANGE, start, end); -} - -void ScintillaEdit::copyText(sptr_t length, const char * text) { - send(SCI_COPYTEXT, length, (sptr_t)text); -} - -void ScintillaEdit::setSelectionMode(sptr_t mode) { - send(SCI_SETSELECTIONMODE, mode, 0); -} - -sptr_t ScintillaEdit::selectionMode() const { - return send(SCI_GETSELECTIONMODE, 0, 0); -} - -sptr_t ScintillaEdit::getLineSelStartPosition(sptr_t line) { - return send(SCI_GETLINESELSTARTPOSITION, line, 0); -} - -sptr_t ScintillaEdit::getLineSelEndPosition(sptr_t line) { - return send(SCI_GETLINESELENDPOSITION, line, 0); -} - -void ScintillaEdit::lineDownRectExtend() { - send(SCI_LINEDOWNRECTEXTEND, 0, 0); -} - -void ScintillaEdit::lineUpRectExtend() { - send(SCI_LINEUPRECTEXTEND, 0, 0); -} - -void ScintillaEdit::charLeftRectExtend() { - send(SCI_CHARLEFTRECTEXTEND, 0, 0); -} - -void ScintillaEdit::charRightRectExtend() { - send(SCI_CHARRIGHTRECTEXTEND, 0, 0); -} - -void ScintillaEdit::homeRectExtend() { - send(SCI_HOMERECTEXTEND, 0, 0); -} - -void ScintillaEdit::vCHomeRectExtend() { - send(SCI_VCHOMERECTEXTEND, 0, 0); -} - -void ScintillaEdit::lineEndRectExtend() { - send(SCI_LINEENDRECTEXTEND, 0, 0); -} - -void ScintillaEdit::pageUpRectExtend() { - send(SCI_PAGEUPRECTEXTEND, 0, 0); -} - -void ScintillaEdit::pageDownRectExtend() { - send(SCI_PAGEDOWNRECTEXTEND, 0, 0); -} - -void ScintillaEdit::stutteredPageUp() { - send(SCI_STUTTEREDPAGEUP, 0, 0); -} - -void ScintillaEdit::stutteredPageUpExtend() { - send(SCI_STUTTEREDPAGEUPEXTEND, 0, 0); -} - -void ScintillaEdit::stutteredPageDown() { - send(SCI_STUTTEREDPAGEDOWN, 0, 0); -} - -void ScintillaEdit::stutteredPageDownExtend() { - send(SCI_STUTTEREDPAGEDOWNEXTEND, 0, 0); -} - -void ScintillaEdit::wordLeftEnd() { - send(SCI_WORDLEFTEND, 0, 0); -} - -void ScintillaEdit::wordLeftEndExtend() { - send(SCI_WORDLEFTENDEXTEND, 0, 0); -} - -void ScintillaEdit::wordRightEnd() { - send(SCI_WORDRIGHTEND, 0, 0); -} - -void ScintillaEdit::wordRightEndExtend() { - send(SCI_WORDRIGHTENDEXTEND, 0, 0); -} - -void ScintillaEdit::setWhitespaceChars(const char * characters) { - send(SCI_SETWHITESPACECHARS, 0, (sptr_t)characters); -} - -QByteArray ScintillaEdit::whitespaceChars() const { - return TextReturner(SCI_GETWHITESPACECHARS, 0); -} - -void ScintillaEdit::setPunctuationChars(const char * characters) { - send(SCI_SETPUNCTUATIONCHARS, 0, (sptr_t)characters); -} - -QByteArray ScintillaEdit::punctuationChars() const { - return TextReturner(SCI_GETPUNCTUATIONCHARS, 0); -} - -void ScintillaEdit::setCharsDefault() { - send(SCI_SETCHARSDEFAULT, 0, 0); -} - -sptr_t ScintillaEdit::autoCCurrent() const { - return send(SCI_AUTOCGETCURRENT, 0, 0); -} - -QByteArray ScintillaEdit::autoCCurrentText() const { - return TextReturner(SCI_AUTOCGETCURRENTTEXT, 0); -} - -void ScintillaEdit::autoCSetCaseInsensitiveBehaviour(sptr_t behaviour) { - send(SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR, behaviour, 0); -} - -sptr_t ScintillaEdit::autoCCaseInsensitiveBehaviour() const { - return send(SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR, 0, 0); -} - -void ScintillaEdit::autoCSetMulti(sptr_t multi) { - send(SCI_AUTOCSETMULTI, multi, 0); -} - -sptr_t ScintillaEdit::autoCMulti() const { - return send(SCI_AUTOCGETMULTI, 0, 0); -} - -void ScintillaEdit::autoCSetOrder(sptr_t order) { - send(SCI_AUTOCSETORDER, order, 0); -} - -sptr_t ScintillaEdit::autoCOrder() const { - return send(SCI_AUTOCGETORDER, 0, 0); -} - -void ScintillaEdit::allocate(sptr_t bytes) { - send(SCI_ALLOCATE, bytes, 0); -} - -QByteArray ScintillaEdit::targetAsUTF8() { - return TextReturner(SCI_TARGETASUTF8, 0); -} - -void ScintillaEdit::setLengthForEncode(sptr_t bytes) { - send(SCI_SETLENGTHFORENCODE, bytes, 0); -} - -QByteArray ScintillaEdit::encodedFromUTF8(const char * utf8) { - return TextReturner(SCI_ENCODEDFROMUTF8, (sptr_t)utf8); -} - -sptr_t ScintillaEdit::findColumn(sptr_t line, sptr_t column) { - return send(SCI_FINDCOLUMN, line, column); -} - -sptr_t ScintillaEdit::caretSticky() const { - return send(SCI_GETCARETSTICKY, 0, 0); -} - -void ScintillaEdit::setCaretSticky(sptr_t useCaretStickyBehaviour) { - send(SCI_SETCARETSTICKY, useCaretStickyBehaviour, 0); -} - -void ScintillaEdit::toggleCaretSticky() { - send(SCI_TOGGLECARETSTICKY, 0, 0); -} - -void ScintillaEdit::setPasteConvertEndings(bool convert) { - send(SCI_SETPASTECONVERTENDINGS, convert, 0); -} - -bool ScintillaEdit::pasteConvertEndings() const { - return send(SCI_GETPASTECONVERTENDINGS, 0, 0); -} - -void ScintillaEdit::selectionDuplicate() { - send(SCI_SELECTIONDUPLICATE, 0, 0); -} - -void ScintillaEdit::setCaretLineBackAlpha(sptr_t alpha) { - send(SCI_SETCARETLINEBACKALPHA, alpha, 0); -} - -sptr_t ScintillaEdit::caretLineBackAlpha() const { - return send(SCI_GETCARETLINEBACKALPHA, 0, 0); -} - -void ScintillaEdit::setCaretStyle(sptr_t caretStyle) { - send(SCI_SETCARETSTYLE, caretStyle, 0); -} - -sptr_t ScintillaEdit::caretStyle() const { - return send(SCI_GETCARETSTYLE, 0, 0); -} - -void ScintillaEdit::setIndicatorCurrent(sptr_t indicator) { - send(SCI_SETINDICATORCURRENT, indicator, 0); -} - -sptr_t ScintillaEdit::indicatorCurrent() const { - return send(SCI_GETINDICATORCURRENT, 0, 0); -} - -void ScintillaEdit::setIndicatorValue(sptr_t value) { - send(SCI_SETINDICATORVALUE, value, 0); -} - -sptr_t ScintillaEdit::indicatorValue() const { - return send(SCI_GETINDICATORVALUE, 0, 0); -} - -void ScintillaEdit::indicatorFillRange(sptr_t position, sptr_t fillLength) { - send(SCI_INDICATORFILLRANGE, position, fillLength); -} - -void ScintillaEdit::indicatorClearRange(sptr_t position, sptr_t clearLength) { - send(SCI_INDICATORCLEARRANGE, position, clearLength); -} - -sptr_t ScintillaEdit::indicatorAllOnFor(sptr_t position) { - return send(SCI_INDICATORALLONFOR, position, 0); -} - -sptr_t ScintillaEdit::indicatorValueAt(sptr_t indicator, sptr_t position) { - return send(SCI_INDICATORVALUEAT, indicator, position); -} - -sptr_t ScintillaEdit::indicatorStart(sptr_t indicator, sptr_t position) { - return send(SCI_INDICATORSTART, indicator, position); -} - -sptr_t ScintillaEdit::indicatorEnd(sptr_t indicator, sptr_t position) { - return send(SCI_INDICATOREND, indicator, position); -} - -void ScintillaEdit::setPositionCache(sptr_t size) { - send(SCI_SETPOSITIONCACHE, size, 0); -} - -sptr_t ScintillaEdit::positionCache() const { - return send(SCI_GETPOSITIONCACHE, 0, 0); -} - -void ScintillaEdit::copyAllowLine() { - send(SCI_COPYALLOWLINE, 0, 0); -} - -sptr_t ScintillaEdit::characterPointer() const { - return send(SCI_GETCHARACTERPOINTER, 0, 0); -} - -sptr_t ScintillaEdit::rangePointer(sptr_t position, sptr_t rangeLength) const { - return send(SCI_GETRANGEPOINTER, position, rangeLength); -} - -sptr_t ScintillaEdit::gapPosition() const { - return send(SCI_GETGAPPOSITION, 0, 0); -} - -void ScintillaEdit::indicSetAlpha(sptr_t indicator, sptr_t alpha) { - send(SCI_INDICSETALPHA, indicator, alpha); -} - -sptr_t ScintillaEdit::indicAlpha(sptr_t indicator) const { - return send(SCI_INDICGETALPHA, indicator, 0); -} - -void ScintillaEdit::indicSetOutlineAlpha(sptr_t indicator, sptr_t alpha) { - send(SCI_INDICSETOUTLINEALPHA, indicator, alpha); -} - -sptr_t ScintillaEdit::indicOutlineAlpha(sptr_t indicator) const { - return send(SCI_INDICGETOUTLINEALPHA, indicator, 0); -} - -void ScintillaEdit::setExtraAscent(sptr_t extraAscent) { - send(SCI_SETEXTRAASCENT, extraAscent, 0); -} - -sptr_t ScintillaEdit::extraAscent() const { - return send(SCI_GETEXTRAASCENT, 0, 0); -} - -void ScintillaEdit::setExtraDescent(sptr_t extraDescent) { - send(SCI_SETEXTRADESCENT, extraDescent, 0); -} - -sptr_t ScintillaEdit::extraDescent() const { - return send(SCI_GETEXTRADESCENT, 0, 0); -} - -sptr_t ScintillaEdit::markerSymbolDefined(sptr_t markerNumber) { - return send(SCI_MARKERSYMBOLDEFINED, markerNumber, 0); -} - -void ScintillaEdit::marginSetText(sptr_t line, const char * text) { - send(SCI_MARGINSETTEXT, line, (sptr_t)text); -} - -QByteArray ScintillaEdit::marginText(sptr_t line) const { - return TextReturner(SCI_MARGINGETTEXT, line); -} - -void ScintillaEdit::marginSetStyle(sptr_t line, sptr_t style) { - send(SCI_MARGINSETSTYLE, line, style); -} - -sptr_t ScintillaEdit::marginStyle(sptr_t line) const { - return send(SCI_MARGINGETSTYLE, line, 0); -} - -void ScintillaEdit::marginSetStyles(sptr_t line, const char * styles) { - send(SCI_MARGINSETSTYLES, line, (sptr_t)styles); -} - -QByteArray ScintillaEdit::marginStyles(sptr_t line) const { - return TextReturner(SCI_MARGINGETSTYLES, line); -} - -void ScintillaEdit::marginTextClearAll() { - send(SCI_MARGINTEXTCLEARALL, 0, 0); -} - -void ScintillaEdit::marginSetStyleOffset(sptr_t style) { - send(SCI_MARGINSETSTYLEOFFSET, style, 0); -} - -sptr_t ScintillaEdit::marginStyleOffset() const { - return send(SCI_MARGINGETSTYLEOFFSET, 0, 0); -} - -void ScintillaEdit::setMarginOptions(sptr_t marginOptions) { - send(SCI_SETMARGINOPTIONS, marginOptions, 0); -} - -sptr_t ScintillaEdit::marginOptions() const { - return send(SCI_GETMARGINOPTIONS, 0, 0); -} - -void ScintillaEdit::annotationSetText(sptr_t line, const char * text) { - send(SCI_ANNOTATIONSETTEXT, line, (sptr_t)text); -} - -QByteArray ScintillaEdit::annotationText(sptr_t line) const { - return TextReturner(SCI_ANNOTATIONGETTEXT, line); -} - -void ScintillaEdit::annotationSetStyle(sptr_t line, sptr_t style) { - send(SCI_ANNOTATIONSETSTYLE, line, style); -} - -sptr_t ScintillaEdit::annotationStyle(sptr_t line) const { - return send(SCI_ANNOTATIONGETSTYLE, line, 0); -} - -void ScintillaEdit::annotationSetStyles(sptr_t line, const char * styles) { - send(SCI_ANNOTATIONSETSTYLES, line, (sptr_t)styles); -} - -QByteArray ScintillaEdit::annotationStyles(sptr_t line) const { - return TextReturner(SCI_ANNOTATIONGETSTYLES, line); -} - -sptr_t ScintillaEdit::annotationLines(sptr_t line) const { - return send(SCI_ANNOTATIONGETLINES, line, 0); -} - -void ScintillaEdit::annotationClearAll() { - send(SCI_ANNOTATIONCLEARALL, 0, 0); -} - -void ScintillaEdit::annotationSetVisible(sptr_t visible) { - send(SCI_ANNOTATIONSETVISIBLE, visible, 0); -} - -sptr_t ScintillaEdit::annotationVisible() const { - return send(SCI_ANNOTATIONGETVISIBLE, 0, 0); -} - -void ScintillaEdit::annotationSetStyleOffset(sptr_t style) { - send(SCI_ANNOTATIONSETSTYLEOFFSET, style, 0); -} - -sptr_t ScintillaEdit::annotationStyleOffset() const { - return send(SCI_ANNOTATIONGETSTYLEOFFSET, 0, 0); -} - -void ScintillaEdit::releaseAllExtendedStyles() { - send(SCI_RELEASEALLEXTENDEDSTYLES, 0, 0); -} - -sptr_t ScintillaEdit::allocateExtendedStyles(sptr_t numberStyles) { - return send(SCI_ALLOCATEEXTENDEDSTYLES, numberStyles, 0); -} - -void ScintillaEdit::addUndoAction(sptr_t token, sptr_t flags) { - send(SCI_ADDUNDOACTION, token, flags); -} - -sptr_t ScintillaEdit::charPositionFromPoint(sptr_t x, sptr_t y) { - return send(SCI_CHARPOSITIONFROMPOINT, x, y); -} - -sptr_t ScintillaEdit::charPositionFromPointClose(sptr_t x, sptr_t y) { - return send(SCI_CHARPOSITIONFROMPOINTCLOSE, x, y); -} - -void ScintillaEdit::setMouseSelectionRectangularSwitch(bool mouseSelectionRectangularSwitch) { - send(SCI_SETMOUSESELECTIONRECTANGULARSWITCH, mouseSelectionRectangularSwitch, 0); -} - -bool ScintillaEdit::mouseSelectionRectangularSwitch() const { - return send(SCI_GETMOUSESELECTIONRECTANGULARSWITCH, 0, 0); -} - -void ScintillaEdit::setMultipleSelection(bool multipleSelection) { - send(SCI_SETMULTIPLESELECTION, multipleSelection, 0); -} - -bool ScintillaEdit::multipleSelection() const { - return send(SCI_GETMULTIPLESELECTION, 0, 0); -} - -void ScintillaEdit::setAdditionalSelectionTyping(bool additionalSelectionTyping) { - send(SCI_SETADDITIONALSELECTIONTYPING, additionalSelectionTyping, 0); -} - -bool ScintillaEdit::additionalSelectionTyping() const { - return send(SCI_GETADDITIONALSELECTIONTYPING, 0, 0); -} - -void ScintillaEdit::setAdditionalCaretsBlink(bool additionalCaretsBlink) { - send(SCI_SETADDITIONALCARETSBLINK, additionalCaretsBlink, 0); -} - -bool ScintillaEdit::additionalCaretsBlink() const { - return send(SCI_GETADDITIONALCARETSBLINK, 0, 0); -} - -void ScintillaEdit::setAdditionalCaretsVisible(bool additionalCaretsBlink) { - send(SCI_SETADDITIONALCARETSVISIBLE, additionalCaretsBlink, 0); -} - -bool ScintillaEdit::additionalCaretsVisible() const { - return send(SCI_GETADDITIONALCARETSVISIBLE, 0, 0); -} - -sptr_t ScintillaEdit::selections() const { - return send(SCI_GETSELECTIONS, 0, 0); -} - -bool ScintillaEdit::selectionEmpty() const { - return send(SCI_GETSELECTIONEMPTY, 0, 0); -} - -void ScintillaEdit::clearSelections() { - send(SCI_CLEARSELECTIONS, 0, 0); -} - -sptr_t ScintillaEdit::setSelection(sptr_t caret, sptr_t anchor) { - return send(SCI_SETSELECTION, caret, anchor); -} - -sptr_t ScintillaEdit::addSelection(sptr_t caret, sptr_t anchor) { - return send(SCI_ADDSELECTION, caret, anchor); -} - -void ScintillaEdit::dropSelectionN(sptr_t selection) { - send(SCI_DROPSELECTIONN, selection, 0); -} - -void ScintillaEdit::setMainSelection(sptr_t selection) { - send(SCI_SETMAINSELECTION, selection, 0); -} - -sptr_t ScintillaEdit::mainSelection() const { - return send(SCI_GETMAINSELECTION, 0, 0); -} - -void ScintillaEdit::setSelectionNCaret(sptr_t selection, sptr_t pos) { - send(SCI_SETSELECTIONNCARET, selection, pos); -} - -sptr_t ScintillaEdit::selectionNCaret(sptr_t selection) const { - return send(SCI_GETSELECTIONNCARET, selection, 0); -} - -void ScintillaEdit::setSelectionNAnchor(sptr_t selection, sptr_t posAnchor) { - send(SCI_SETSELECTIONNANCHOR, selection, posAnchor); -} - -sptr_t ScintillaEdit::selectionNAnchor(sptr_t selection) const { - return send(SCI_GETSELECTIONNANCHOR, selection, 0); -} - -void ScintillaEdit::setSelectionNCaretVirtualSpace(sptr_t selection, sptr_t space) { - send(SCI_SETSELECTIONNCARETVIRTUALSPACE, selection, space); -} - -sptr_t ScintillaEdit::selectionNCaretVirtualSpace(sptr_t selection) const { - return send(SCI_GETSELECTIONNCARETVIRTUALSPACE, selection, 0); -} - -void ScintillaEdit::setSelectionNAnchorVirtualSpace(sptr_t selection, sptr_t space) { - send(SCI_SETSELECTIONNANCHORVIRTUALSPACE, selection, space); -} - -sptr_t ScintillaEdit::selectionNAnchorVirtualSpace(sptr_t selection) const { - return send(SCI_GETSELECTIONNANCHORVIRTUALSPACE, selection, 0); -} - -void ScintillaEdit::setSelectionNStart(sptr_t selection, sptr_t pos) { - send(SCI_SETSELECTIONNSTART, selection, pos); -} - -sptr_t ScintillaEdit::selectionNStart(sptr_t selection) const { - return send(SCI_GETSELECTIONNSTART, selection, 0); -} - -void ScintillaEdit::setSelectionNEnd(sptr_t selection, sptr_t pos) { - send(SCI_SETSELECTIONNEND, selection, pos); -} - -sptr_t ScintillaEdit::selectionNEnd(sptr_t selection) const { - return send(SCI_GETSELECTIONNEND, selection, 0); -} - -void ScintillaEdit::setRectangularSelectionCaret(sptr_t pos) { - send(SCI_SETRECTANGULARSELECTIONCARET, pos, 0); -} - -sptr_t ScintillaEdit::rectangularSelectionCaret() const { - return send(SCI_GETRECTANGULARSELECTIONCARET, 0, 0); -} - -void ScintillaEdit::setRectangularSelectionAnchor(sptr_t posAnchor) { - send(SCI_SETRECTANGULARSELECTIONANCHOR, posAnchor, 0); -} - -sptr_t ScintillaEdit::rectangularSelectionAnchor() const { - return send(SCI_GETRECTANGULARSELECTIONANCHOR, 0, 0); -} - -void ScintillaEdit::setRectangularSelectionCaretVirtualSpace(sptr_t space) { - send(SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE, space, 0); -} - -sptr_t ScintillaEdit::rectangularSelectionCaretVirtualSpace() const { - return send(SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE, 0, 0); -} - -void ScintillaEdit::setRectangularSelectionAnchorVirtualSpace(sptr_t space) { - send(SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE, space, 0); -} - -sptr_t ScintillaEdit::rectangularSelectionAnchorVirtualSpace() const { - return send(SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE, 0, 0); -} - -void ScintillaEdit::setVirtualSpaceOptions(sptr_t virtualSpaceOptions) { - send(SCI_SETVIRTUALSPACEOPTIONS, virtualSpaceOptions, 0); -} - -sptr_t ScintillaEdit::virtualSpaceOptions() const { - return send(SCI_GETVIRTUALSPACEOPTIONS, 0, 0); -} - -void ScintillaEdit::setRectangularSelectionModifier(sptr_t modifier) { - send(SCI_SETRECTANGULARSELECTIONMODIFIER, modifier, 0); -} - -sptr_t ScintillaEdit::rectangularSelectionModifier() const { - return send(SCI_GETRECTANGULARSELECTIONMODIFIER, 0, 0); -} - -void ScintillaEdit::setAdditionalSelFore(sptr_t fore) { - send(SCI_SETADDITIONALSELFORE, fore, 0); -} - -void ScintillaEdit::setAdditionalSelBack(sptr_t back) { - send(SCI_SETADDITIONALSELBACK, back, 0); -} - -void ScintillaEdit::setAdditionalSelAlpha(sptr_t alpha) { - send(SCI_SETADDITIONALSELALPHA, alpha, 0); -} - -sptr_t ScintillaEdit::additionalSelAlpha() const { - return send(SCI_GETADDITIONALSELALPHA, 0, 0); -} - -void ScintillaEdit::setAdditionalCaretFore(sptr_t fore) { - send(SCI_SETADDITIONALCARETFORE, fore, 0); -} - -sptr_t ScintillaEdit::additionalCaretFore() const { - return send(SCI_GETADDITIONALCARETFORE, 0, 0); -} - -void ScintillaEdit::rotateSelection() { - send(SCI_ROTATESELECTION, 0, 0); -} - -void ScintillaEdit::swapMainAnchorCaret() { - send(SCI_SWAPMAINANCHORCARET, 0, 0); -} - -void ScintillaEdit::multipleSelectAddNext() { - send(SCI_MULTIPLESELECTADDNEXT, 0, 0); -} - -void ScintillaEdit::multipleSelectAddEach() { - send(SCI_MULTIPLESELECTADDEACH, 0, 0); -} - -sptr_t ScintillaEdit::changeLexerState(sptr_t start, sptr_t end) { - return send(SCI_CHANGELEXERSTATE, start, end); -} - -sptr_t ScintillaEdit::contractedFoldNext(sptr_t lineStart) { - return send(SCI_CONTRACTEDFOLDNEXT, lineStart, 0); -} - -void ScintillaEdit::verticalCentreCaret() { - send(SCI_VERTICALCENTRECARET, 0, 0); -} - -void ScintillaEdit::moveSelectedLinesUp() { - send(SCI_MOVESELECTEDLINESUP, 0, 0); -} - -void ScintillaEdit::moveSelectedLinesDown() { - send(SCI_MOVESELECTEDLINESDOWN, 0, 0); -} - -void ScintillaEdit::setIdentifier(sptr_t identifier) { - send(SCI_SETIDENTIFIER, identifier, 0); -} - -sptr_t ScintillaEdit::identifier() const { - return send(SCI_GETIDENTIFIER, 0, 0); -} - -void ScintillaEdit::rGBAImageSetWidth(sptr_t width) { - send(SCI_RGBAIMAGESETWIDTH, width, 0); -} - -void ScintillaEdit::rGBAImageSetHeight(sptr_t height) { - send(SCI_RGBAIMAGESETHEIGHT, height, 0); -} - -void ScintillaEdit::rGBAImageSetScale(sptr_t scalePercent) { - send(SCI_RGBAIMAGESETSCALE, scalePercent, 0); -} - -void ScintillaEdit::markerDefineRGBAImage(sptr_t markerNumber, const char * pixels) { - send(SCI_MARKERDEFINERGBAIMAGE, markerNumber, (sptr_t)pixels); -} - -void ScintillaEdit::registerRGBAImage(sptr_t type, const char * pixels) { - send(SCI_REGISTERRGBAIMAGE, type, (sptr_t)pixels); -} - -void ScintillaEdit::scrollToStart() { - send(SCI_SCROLLTOSTART, 0, 0); -} - -void ScintillaEdit::scrollToEnd() { - send(SCI_SCROLLTOEND, 0, 0); -} - -void ScintillaEdit::setTechnology(sptr_t technology) { - send(SCI_SETTECHNOLOGY, technology, 0); -} - -sptr_t ScintillaEdit::technology() const { - return send(SCI_GETTECHNOLOGY, 0, 0); -} - -sptr_t ScintillaEdit::createLoader(sptr_t bytes) { - return send(SCI_CREATELOADER, bytes, 0); -} - -void ScintillaEdit::findIndicatorShow(sptr_t start, sptr_t end) { - send(SCI_FINDINDICATORSHOW, start, end); -} - -void ScintillaEdit::findIndicatorFlash(sptr_t start, sptr_t end) { - send(SCI_FINDINDICATORFLASH, start, end); -} - -void ScintillaEdit::findIndicatorHide() { - send(SCI_FINDINDICATORHIDE, 0, 0); -} - -void ScintillaEdit::vCHomeDisplay() { - send(SCI_VCHOMEDISPLAY, 0, 0); -} - -void ScintillaEdit::vCHomeDisplayExtend() { - send(SCI_VCHOMEDISPLAYEXTEND, 0, 0); -} - -bool ScintillaEdit::caretLineVisibleAlways() const { - return send(SCI_GETCARETLINEVISIBLEALWAYS, 0, 0); -} - -void ScintillaEdit::setCaretLineVisibleAlways(bool alwaysVisible) { - send(SCI_SETCARETLINEVISIBLEALWAYS, alwaysVisible, 0); -} - -void ScintillaEdit::setLineEndTypesAllowed(sptr_t lineEndBitSet) { - send(SCI_SETLINEENDTYPESALLOWED, lineEndBitSet, 0); -} - -sptr_t ScintillaEdit::lineEndTypesAllowed() const { - return send(SCI_GETLINEENDTYPESALLOWED, 0, 0); -} - -sptr_t ScintillaEdit::lineEndTypesActive() const { - return send(SCI_GETLINEENDTYPESACTIVE, 0, 0); -} - -void ScintillaEdit::setRepresentation(const char * encodedCharacter, const char * representation) { - send(SCI_SETREPRESENTATION, (sptr_t)encodedCharacter, (sptr_t)representation); -} - -QByteArray ScintillaEdit::representation(const char * encodedCharacter) const { - return TextReturner(SCI_GETREPRESENTATION, (sptr_t)encodedCharacter); -} - -void ScintillaEdit::clearRepresentation(const char * encodedCharacter) { - send(SCI_CLEARREPRESENTATION, (sptr_t)encodedCharacter, 0); -} - -void ScintillaEdit::startRecord() { - send(SCI_STARTRECORD, 0, 0); -} - -void ScintillaEdit::stopRecord() { - send(SCI_STOPRECORD, 0, 0); -} - -void ScintillaEdit::setLexer(sptr_t lexer) { - send(SCI_SETLEXER, lexer, 0); -} - -sptr_t ScintillaEdit::lexer() const { - return send(SCI_GETLEXER, 0, 0); -} - -void ScintillaEdit::colourise(sptr_t start, sptr_t end) { - send(SCI_COLOURISE, start, end); -} - -void ScintillaEdit::setProperty(const char * key, const char * value) { - send(SCI_SETPROPERTY, (sptr_t)key, (sptr_t)value); -} - -void ScintillaEdit::setKeyWords(sptr_t keywordSet, const char * keyWords) { - send(SCI_SETKEYWORDS, keywordSet, (sptr_t)keyWords); -} - -void ScintillaEdit::setLexerLanguage(const char * language) { - send(SCI_SETLEXERLANGUAGE, 0, (sptr_t)language); -} - -void ScintillaEdit::loadLexerLibrary(const char * path) { - send(SCI_LOADLEXERLIBRARY, 0, (sptr_t)path); -} - -QByteArray ScintillaEdit::property(const char * key) const { - return TextReturner(SCI_GETPROPERTY, (sptr_t)key); -} - -QByteArray ScintillaEdit::propertyExpanded(const char * key) const { - return TextReturner(SCI_GETPROPERTYEXPANDED, (sptr_t)key); -} - -sptr_t ScintillaEdit::propertyInt(const char * key) const { - return send(SCI_GETPROPERTYINT, (sptr_t)key, 0); -} - -sptr_t ScintillaEdit::styleBitsNeeded() const { - return send(SCI_GETSTYLEBITSNEEDED, 0, 0); -} - -QByteArray ScintillaEdit::lexerLanguage() const { - return TextReturner(SCI_GETLEXERLANGUAGE, 0); -} - -sptr_t ScintillaEdit::privateLexerCall(sptr_t operation, sptr_t pointer) { - return send(SCI_PRIVATELEXERCALL, operation, pointer); -} - -QByteArray ScintillaEdit::propertyNames() { - return TextReturner(SCI_PROPERTYNAMES, 0); -} - -sptr_t ScintillaEdit::propertyType(const char * name) { - return send(SCI_PROPERTYTYPE, (sptr_t)name, 0); -} - -QByteArray ScintillaEdit::describeProperty(const char * name) { - return TextReturner(SCI_DESCRIBEPROPERTY, (sptr_t)name); -} - -QByteArray ScintillaEdit::describeKeyWordSets() { - return TextReturner(SCI_DESCRIBEKEYWORDSETS, 0); -} - -sptr_t ScintillaEdit::lineEndTypesSupported() const { - return send(SCI_GETLINEENDTYPESSUPPORTED, 0, 0); -} - -sptr_t ScintillaEdit::allocateSubStyles(sptr_t styleBase, sptr_t numberStyles) { - return send(SCI_ALLOCATESUBSTYLES, styleBase, numberStyles); -} - -sptr_t ScintillaEdit::subStylesStart(sptr_t styleBase) const { - return send(SCI_GETSUBSTYLESSTART, styleBase, 0); -} - -sptr_t ScintillaEdit::subStylesLength(sptr_t styleBase) const { - return send(SCI_GETSUBSTYLESLENGTH, styleBase, 0); -} - -sptr_t ScintillaEdit::styleFromSubStyle(sptr_t subStyle) const { - return send(SCI_GETSTYLEFROMSUBSTYLE, subStyle, 0); -} - -sptr_t ScintillaEdit::primaryStyleFromStyle(sptr_t style) const { - return send(SCI_GETPRIMARYSTYLEFROMSTYLE, style, 0); -} - -void ScintillaEdit::freeSubStyles() { - send(SCI_FREESUBSTYLES, 0, 0); -} - -void ScintillaEdit::setIdentifiers(sptr_t style, const char * identifiers) { - send(SCI_SETIDENTIFIERS, style, (sptr_t)identifiers); -} - -sptr_t ScintillaEdit::distanceToSecondaryStyles() const { - return send(SCI_DISTANCETOSECONDARYSTYLES, 0, 0); -} - -QByteArray ScintillaEdit::subStyleBases() const { - return TextReturner(SCI_GETSUBSTYLEBASES, 0); -} - -/* --Autogenerated -- end of section automatically generated from Scintilla.iface */ diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.h b/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.h deleted file mode 100644 index 7ac6bc3e..00000000 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEdit/ScintillaEdit.h +++ /dev/null @@ -1,748 +0,0 @@ -// ScintillaEdit.h -// Extended version of ScintillaEditBase with a method for each API -// Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware - -#ifndef SCINTILLAEDIT_H -#define SCINTILLAEDIT_H - -#include - -#include "ScintillaEditBase.h" -#include "ScintillaDocument.h" - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -#ifndef EXPORT_IMPORT_API -#ifdef WIN32 -#ifdef MAKING_LIBRARY -#define EXPORT_IMPORT_API __declspec(dllexport) -#else -// Defining dllimport upsets moc -#define EXPORT_IMPORT_API __declspec(dllimport) -//#define EXPORT_IMPORT_API -#endif -#else -#define EXPORT_IMPORT_API -#endif -#endif - -class EXPORT_IMPORT_API ScintillaEdit : public ScintillaEditBase { - Q_OBJECT - -public: - ScintillaEdit(QWidget *parent = 0); - virtual ~ScintillaEdit(); - - QByteArray TextReturner(int message, uptr_t wParam) const; - - QPairfind_text(int flags, const char *text, int cpMin, int cpMax); - QByteArray get_text_range(int start, int end); - ScintillaDocument *get_doc(); - void set_doc(ScintillaDocument *pdoc_); - - // Same as previous two methods but with Qt style names - QPairfindText(int flags, const char *text, int cpMin, int cpMax) { - return find_text(flags, text, cpMin, cpMax); - } - - QByteArray textRange(int start, int end) { - return get_text_range(start, end); - } - - // Exposing the FORMATRANGE api with both underscore & qt style names - long format_range(bool draw, QPaintDevice* target, QPaintDevice* measure, - const QRect& print_rect, const QRect& page_rect, - long range_start, long range_end); - long formatRange(bool draw, QPaintDevice* target, QPaintDevice* measure, - const QRect& print_rect, const QRect& page_rect, - long range_start, long range_end) { - return format_range(draw, target, measure, print_rect, page_rect, - range_start, range_end); - } - -/* ++Autogenerated -- start of section automatically generated from Scintilla.iface */ - void addText(sptr_t length, const char * text); - void addStyledText(sptr_t length, const char * c); - void insertText(sptr_t pos, const char * text); - void changeInsertion(sptr_t length, const char * text); - void clearAll(); - void deleteRange(sptr_t pos, sptr_t deleteLength); - void clearDocumentStyle(); - sptr_t length() const; - sptr_t charAt(sptr_t pos) const; - sptr_t currentPos() const; - sptr_t anchor() const; - sptr_t styleAt(sptr_t pos) const; - void redo(); - void setUndoCollection(bool collectUndo); - void selectAll(); - void setSavePoint(); - bool canRedo(); - sptr_t markerLineFromHandle(sptr_t handle); - void markerDeleteHandle(sptr_t handle); - bool undoCollection() const; - sptr_t viewWS() const; - void setViewWS(sptr_t viewWS); - sptr_t positionFromPoint(sptr_t x, sptr_t y); - sptr_t positionFromPointClose(sptr_t x, sptr_t y); - void gotoLine(sptr_t line); - void gotoPos(sptr_t pos); - void setAnchor(sptr_t posAnchor); - QByteArray getCurLine(sptr_t length); - sptr_t endStyled() const; - void convertEOLs(sptr_t eolMode); - sptr_t eOLMode() const; - void setEOLMode(sptr_t eolMode); - void startStyling(sptr_t pos, sptr_t mask); - void setStyling(sptr_t length, sptr_t style); - bool bufferedDraw() const; - void setBufferedDraw(bool buffered); - void setTabWidth(sptr_t tabWidth); - sptr_t tabWidth() const; - void clearTabStops(sptr_t line); - void addTabStop(sptr_t line, sptr_t x); - sptr_t getNextTabStop(sptr_t line, sptr_t x); - void setCodePage(sptr_t codePage); - sptr_t iMEInteraction() const; - void setIMEInteraction(sptr_t imeInteraction); - void markerDefine(sptr_t markerNumber, sptr_t markerSymbol); - void markerSetFore(sptr_t markerNumber, sptr_t fore); - void markerSetBack(sptr_t markerNumber, sptr_t back); - void markerSetBackSelected(sptr_t markerNumber, sptr_t back); - void markerEnableHighlight(bool enabled); - sptr_t markerAdd(sptr_t line, sptr_t markerNumber); - void markerDelete(sptr_t line, sptr_t markerNumber); - void markerDeleteAll(sptr_t markerNumber); - sptr_t markerGet(sptr_t line); - sptr_t markerNext(sptr_t lineStart, sptr_t markerMask); - sptr_t markerPrevious(sptr_t lineStart, sptr_t markerMask); - void markerDefinePixmap(sptr_t markerNumber, const char * pixmap); - void markerAddSet(sptr_t line, sptr_t set); - void markerSetAlpha(sptr_t markerNumber, sptr_t alpha); - void setMarginTypeN(sptr_t margin, sptr_t marginType); - sptr_t marginTypeN(sptr_t margin) const; - void setMarginWidthN(sptr_t margin, sptr_t pixelWidth); - sptr_t marginWidthN(sptr_t margin) const; - void setMarginMaskN(sptr_t margin, sptr_t mask); - sptr_t marginMaskN(sptr_t margin) const; - void setMarginSensitiveN(sptr_t margin, bool sensitive); - bool marginSensitiveN(sptr_t margin) const; - void setMarginCursorN(sptr_t margin, sptr_t cursor); - sptr_t marginCursorN(sptr_t margin) const; - void styleClearAll(); - void styleSetFore(sptr_t style, sptr_t fore); - void styleSetBack(sptr_t style, sptr_t back); - void styleSetBold(sptr_t style, bool bold); - void styleSetItalic(sptr_t style, bool italic); - void styleSetSize(sptr_t style, sptr_t sizePoints); - void styleSetFont(sptr_t style, const char * fontName); - void styleSetEOLFilled(sptr_t style, bool filled); - void styleResetDefault(); - void styleSetUnderline(sptr_t style, bool underline); - sptr_t styleFore(sptr_t style) const; - sptr_t styleBack(sptr_t style) const; - bool styleBold(sptr_t style) const; - bool styleItalic(sptr_t style) const; - sptr_t styleSize(sptr_t style) const; - QByteArray styleFont(sptr_t style) const; - bool styleEOLFilled(sptr_t style) const; - bool styleUnderline(sptr_t style) const; - sptr_t styleCase(sptr_t style) const; - sptr_t styleCharacterSet(sptr_t style) const; - bool styleVisible(sptr_t style) const; - bool styleChangeable(sptr_t style) const; - bool styleHotSpot(sptr_t style) const; - void styleSetCase(sptr_t style, sptr_t caseForce); - void styleSetSizeFractional(sptr_t style, sptr_t caseForce); - sptr_t styleSizeFractional(sptr_t style) const; - void styleSetWeight(sptr_t style, sptr_t weight); - sptr_t styleWeight(sptr_t style) const; - void styleSetCharacterSet(sptr_t style, sptr_t characterSet); - void styleSetHotSpot(sptr_t style, bool hotspot); - void setSelFore(bool useSetting, sptr_t fore); - void setSelBack(bool useSetting, sptr_t back); - sptr_t selAlpha() const; - void setSelAlpha(sptr_t alpha); - bool selEOLFilled() const; - void setSelEOLFilled(bool filled); - void setCaretFore(sptr_t fore); - void assignCmdKey(sptr_t km, sptr_t msg); - void clearCmdKey(sptr_t km); - void clearAllCmdKeys(); - void setStylingEx(sptr_t length, const char * styles); - void styleSetVisible(sptr_t style, bool visible); - sptr_t caretPeriod() const; - void setCaretPeriod(sptr_t periodMilliseconds); - void setWordChars(const char * characters); - QByteArray wordChars() const; - void beginUndoAction(); - void endUndoAction(); - void indicSetStyle(sptr_t indic, sptr_t style); - sptr_t indicStyle(sptr_t indic) const; - void indicSetFore(sptr_t indic, sptr_t fore); - sptr_t indicFore(sptr_t indic) const; - void indicSetUnder(sptr_t indic, bool under); - bool indicUnder(sptr_t indic) const; - void indicSetHoverStyle(sptr_t indic, sptr_t style); - sptr_t indicHoverStyle(sptr_t indic) const; - void indicSetHoverFore(sptr_t indic, sptr_t fore); - sptr_t indicHoverFore(sptr_t indic) const; - void indicSetFlags(sptr_t indic, sptr_t flags); - sptr_t indicFlags(sptr_t indic) const; - void setWhitespaceFore(bool useSetting, sptr_t fore); - void setWhitespaceBack(bool useSetting, sptr_t back); - void setWhitespaceSize(sptr_t size); - sptr_t whitespaceSize() const; - void setStyleBits(sptr_t bits); - sptr_t styleBits() const; - void setLineState(sptr_t line, sptr_t state); - sptr_t lineState(sptr_t line) const; - sptr_t maxLineState() const; - bool caretLineVisible() const; - void setCaretLineVisible(bool show); - sptr_t caretLineBack() const; - void setCaretLineBack(sptr_t back); - void styleSetChangeable(sptr_t style, bool changeable); - void autoCShow(sptr_t lenEntered, const char * itemList); - void autoCCancel(); - bool autoCActive(); - sptr_t autoCPosStart(); - void autoCComplete(); - void autoCStops(const char * characterSet); - void autoCSetSeparator(sptr_t separatorCharacter); - sptr_t autoCSeparator() const; - void autoCSelect(const char * text); - void autoCSetCancelAtStart(bool cancel); - bool autoCCancelAtStart() const; - void autoCSetFillUps(const char * characterSet); - void autoCSetChooseSingle(bool chooseSingle); - bool autoCChooseSingle() const; - void autoCSetIgnoreCase(bool ignoreCase); - bool autoCIgnoreCase() const; - void userListShow(sptr_t listType, const char * itemList); - void autoCSetAutoHide(bool autoHide); - bool autoCAutoHide() const; - void autoCSetDropRestOfWord(bool dropRestOfWord); - bool autoCDropRestOfWord() const; - void registerImage(sptr_t type, const char * xpmData); - void clearRegisteredImages(); - sptr_t autoCTypeSeparator() const; - void autoCSetTypeSeparator(sptr_t separatorCharacter); - void autoCSetMaxWidth(sptr_t characterCount); - sptr_t autoCMaxWidth() const; - void autoCSetMaxHeight(sptr_t rowCount); - sptr_t autoCMaxHeight() const; - void setIndent(sptr_t indentSize); - sptr_t indent() const; - void setUseTabs(bool useTabs); - bool useTabs() const; - void setLineIndentation(sptr_t line, sptr_t indentSize); - sptr_t lineIndentation(sptr_t line) const; - sptr_t lineIndentPosition(sptr_t line) const; - sptr_t column(sptr_t pos) const; - sptr_t countCharacters(sptr_t startPos, sptr_t endPos); - void setHScrollBar(bool show); - bool hScrollBar() const; - void setIndentationGuides(sptr_t indentView); - sptr_t indentationGuides() const; - void setHighlightGuide(sptr_t column); - sptr_t highlightGuide() const; - sptr_t lineEndPosition(sptr_t line) const; - sptr_t codePage() const; - sptr_t caretFore() const; - bool readOnly() const; - void setCurrentPos(sptr_t pos); - void setSelectionStart(sptr_t pos); - sptr_t selectionStart() const; - void setSelectionEnd(sptr_t pos); - sptr_t selectionEnd() const; - void setEmptySelection(sptr_t pos); - void setPrintMagnification(sptr_t magnification); - sptr_t printMagnification() const; - void setPrintColourMode(sptr_t mode); - sptr_t printColourMode() const; - sptr_t firstVisibleLine() const; - QByteArray getLine(sptr_t line); - sptr_t lineCount() const; - void setMarginLeft(sptr_t pixelWidth); - sptr_t marginLeft() const; - void setMarginRight(sptr_t pixelWidth); - sptr_t marginRight() const; - bool modify() const; - void setSel(sptr_t start, sptr_t end); - QByteArray getSelText(); - void hideSelection(bool normal); - sptr_t pointXFromPosition(sptr_t pos); - sptr_t pointYFromPosition(sptr_t pos); - sptr_t lineFromPosition(sptr_t pos); - sptr_t positionFromLine(sptr_t line); - void lineScroll(sptr_t columns, sptr_t lines); - void scrollCaret(); - void scrollRange(sptr_t secondary, sptr_t primary); - void replaceSel(const char * text); - void setReadOnly(bool readOnly); - void null(); - bool canPaste(); - bool canUndo(); - void emptyUndoBuffer(); - void undo(); - void cut(); - void copy(); - void paste(); - void clear(); - void setText(const char * text); - QByteArray getText(sptr_t length); - sptr_t textLength() const; - sptr_t directFunction() const; - sptr_t directPointer() const; - void setOvertype(bool overtype); - bool overtype() const; - void setCaretWidth(sptr_t pixelWidth); - sptr_t caretWidth() const; - void setTargetStart(sptr_t pos); - sptr_t targetStart() const; - void setTargetEnd(sptr_t pos); - sptr_t targetEnd() const; - void setTargetRange(sptr_t start, sptr_t end); - QByteArray targetText() const; - void targetFromSelection(); - void targetWholeDocument(); - sptr_t replaceTarget(sptr_t length, const char * text); - sptr_t replaceTargetRE(sptr_t length, const char * text); - sptr_t searchInTarget(sptr_t length, const char * text); - void setSearchFlags(sptr_t flags); - sptr_t searchFlags() const; - void callTipShow(sptr_t pos, const char * definition); - void callTipCancel(); - bool callTipActive(); - sptr_t callTipPosStart(); - void callTipSetPosStart(sptr_t posStart); - void callTipSetHlt(sptr_t start, sptr_t end); - void callTipSetBack(sptr_t back); - void callTipSetFore(sptr_t fore); - void callTipSetForeHlt(sptr_t fore); - void callTipUseStyle(sptr_t tabSize); - void callTipSetPosition(bool above); - sptr_t visibleFromDocLine(sptr_t line); - sptr_t docLineFromVisible(sptr_t lineDisplay); - sptr_t wrapCount(sptr_t line); - void setFoldLevel(sptr_t line, sptr_t level); - sptr_t foldLevel(sptr_t line) const; - sptr_t lastChild(sptr_t line, sptr_t level) const; - sptr_t foldParent(sptr_t line) const; - void showLines(sptr_t lineStart, sptr_t lineEnd); - void hideLines(sptr_t lineStart, sptr_t lineEnd); - bool lineVisible(sptr_t line) const; - bool allLinesVisible() const; - void setFoldExpanded(sptr_t line, bool expanded); - bool foldExpanded(sptr_t line) const; - void toggleFold(sptr_t line); - void foldLine(sptr_t line, sptr_t action); - void foldChildren(sptr_t line, sptr_t action); - void expandChildren(sptr_t line, sptr_t level); - void foldAll(sptr_t action); - void ensureVisible(sptr_t line); - void setAutomaticFold(sptr_t automaticFold); - sptr_t automaticFold() const; - void setFoldFlags(sptr_t flags); - void ensureVisibleEnforcePolicy(sptr_t line); - void setTabIndents(bool tabIndents); - bool tabIndents() const; - void setBackSpaceUnIndents(bool bsUnIndents); - bool backSpaceUnIndents() const; - void setMouseDwellTime(sptr_t periodMilliseconds); - sptr_t mouseDwellTime() const; - sptr_t wordStartPosition(sptr_t pos, bool onlyWordCharacters); - sptr_t wordEndPosition(sptr_t pos, bool onlyWordCharacters); - bool isRangeWord(sptr_t start, sptr_t end); - void setWrapMode(sptr_t mode); - sptr_t wrapMode() const; - void setWrapVisualFlags(sptr_t wrapVisualFlags); - sptr_t wrapVisualFlags() const; - void setWrapVisualFlagsLocation(sptr_t wrapVisualFlagsLocation); - sptr_t wrapVisualFlagsLocation() const; - void setWrapStartIndent(sptr_t indent); - sptr_t wrapStartIndent() const; - void setWrapIndentMode(sptr_t mode); - sptr_t wrapIndentMode() const; - void setLayoutCache(sptr_t mode); - sptr_t layoutCache() const; - void setScrollWidth(sptr_t pixelWidth); - sptr_t scrollWidth() const; - void setScrollWidthTracking(bool tracking); - bool scrollWidthTracking() const; - sptr_t textWidth(sptr_t style, const char * text); - void setEndAtLastLine(bool endAtLastLine); - bool endAtLastLine() const; - sptr_t textHeight(sptr_t line); - void setVScrollBar(bool show); - bool vScrollBar() const; - void appendText(sptr_t length, const char * text); - bool twoPhaseDraw() const; - void setTwoPhaseDraw(bool twoPhase); - sptr_t phasesDraw() const; - void setPhasesDraw(sptr_t phases); - void setFontQuality(sptr_t fontQuality); - sptr_t fontQuality() const; - void setFirstVisibleLine(sptr_t lineDisplay); - void setMultiPaste(sptr_t multiPaste); - sptr_t multiPaste() const; - QByteArray tag(sptr_t tagNumber) const; - void linesJoin(); - void linesSplit(sptr_t pixelWidth); - void setFoldMarginColour(bool useSetting, sptr_t back); - void setFoldMarginHiColour(bool useSetting, sptr_t fore); - void lineDown(); - void lineDownExtend(); - void lineUp(); - void lineUpExtend(); - void charLeft(); - void charLeftExtend(); - void charRight(); - void charRightExtend(); - void wordLeft(); - void wordLeftExtend(); - void wordRight(); - void wordRightExtend(); - void home(); - void homeExtend(); - void lineEnd(); - void lineEndExtend(); - void documentStart(); - void documentStartExtend(); - void documentEnd(); - void documentEndExtend(); - void pageUp(); - void pageUpExtend(); - void pageDown(); - void pageDownExtend(); - void editToggleOvertype(); - void cancel(); - void deleteBack(); - void tab(); - void backTab(); - void newLine(); - void formFeed(); - void vCHome(); - void vCHomeExtend(); - void zoomIn(); - void zoomOut(); - void delWordLeft(); - void delWordRight(); - void delWordRightEnd(); - void lineCut(); - void lineDelete(); - void lineTranspose(); - void lineDuplicate(); - void lowerCase(); - void upperCase(); - void lineScrollDown(); - void lineScrollUp(); - void deleteBackNotLine(); - void homeDisplay(); - void homeDisplayExtend(); - void lineEndDisplay(); - void lineEndDisplayExtend(); - void homeWrap(); - void homeWrapExtend(); - void lineEndWrap(); - void lineEndWrapExtend(); - void vCHomeWrap(); - void vCHomeWrapExtend(); - void lineCopy(); - void moveCaretInsideView(); - sptr_t lineLength(sptr_t line); - void braceHighlight(sptr_t pos1, sptr_t pos2); - void braceHighlightIndicator(bool useBraceHighlightIndicator, sptr_t indicator); - void braceBadLight(sptr_t pos); - void braceBadLightIndicator(bool useBraceBadLightIndicator, sptr_t indicator); - sptr_t braceMatch(sptr_t pos); - bool viewEOL() const; - void setViewEOL(bool visible); - sptr_t docPointer() const; - void setDocPointer(sptr_t pointer); - void setModEventMask(sptr_t mask); - sptr_t edgeColumn() const; - void setEdgeColumn(sptr_t column); - sptr_t edgeMode() const; - void setEdgeMode(sptr_t mode); - sptr_t edgeColour() const; - void setEdgeColour(sptr_t edgeColour); - void searchAnchor(); - sptr_t searchNext(sptr_t flags, const char * text); - sptr_t searchPrev(sptr_t flags, const char * text); - sptr_t linesOnScreen() const; - void usePopUp(bool allowPopUp); - bool selectionIsRectangle() const; - void setZoom(sptr_t zoom); - sptr_t zoom() const; - sptr_t createDocument(); - void addRefDocument(sptr_t doc); - void releaseDocument(sptr_t doc); - sptr_t modEventMask() const; - void setFocus(bool focus); - bool focus() const; - void setStatus(sptr_t statusCode); - sptr_t status() const; - void setMouseDownCaptures(bool captures); - bool mouseDownCaptures() const; - void setCursor(sptr_t cursorType); - sptr_t cursor() const; - void setControlCharSymbol(sptr_t symbol); - sptr_t controlCharSymbol() const; - void wordPartLeft(); - void wordPartLeftExtend(); - void wordPartRight(); - void wordPartRightExtend(); - void setVisiblePolicy(sptr_t visiblePolicy, sptr_t visibleSlop); - void delLineLeft(); - void delLineRight(); - void setXOffset(sptr_t newOffset); - sptr_t xOffset() const; - void chooseCaretX(); - void grabFocus(); - void setXCaretPolicy(sptr_t caretPolicy, sptr_t caretSlop); - void setYCaretPolicy(sptr_t caretPolicy, sptr_t caretSlop); - void setPrintWrapMode(sptr_t mode); - sptr_t printWrapMode() const; - void setHotspotActiveFore(bool useSetting, sptr_t fore); - sptr_t hotspotActiveFore() const; - void setHotspotActiveBack(bool useSetting, sptr_t back); - sptr_t hotspotActiveBack() const; - void setHotspotActiveUnderline(bool underline); - bool hotspotActiveUnderline() const; - void setHotspotSingleLine(bool singleLine); - bool hotspotSingleLine() const; - void paraDown(); - void paraDownExtend(); - void paraUp(); - void paraUpExtend(); - sptr_t positionBefore(sptr_t pos); - sptr_t positionAfter(sptr_t pos); - sptr_t positionRelative(sptr_t pos, sptr_t relative); - void copyRange(sptr_t start, sptr_t end); - void copyText(sptr_t length, const char * text); - void setSelectionMode(sptr_t mode); - sptr_t selectionMode() const; - sptr_t getLineSelStartPosition(sptr_t line); - sptr_t getLineSelEndPosition(sptr_t line); - void lineDownRectExtend(); - void lineUpRectExtend(); - void charLeftRectExtend(); - void charRightRectExtend(); - void homeRectExtend(); - void vCHomeRectExtend(); - void lineEndRectExtend(); - void pageUpRectExtend(); - void pageDownRectExtend(); - void stutteredPageUp(); - void stutteredPageUpExtend(); - void stutteredPageDown(); - void stutteredPageDownExtend(); - void wordLeftEnd(); - void wordLeftEndExtend(); - void wordRightEnd(); - void wordRightEndExtend(); - void setWhitespaceChars(const char * characters); - QByteArray whitespaceChars() const; - void setPunctuationChars(const char * characters); - QByteArray punctuationChars() const; - void setCharsDefault(); - sptr_t autoCCurrent() const; - QByteArray autoCCurrentText() const; - void autoCSetCaseInsensitiveBehaviour(sptr_t behaviour); - sptr_t autoCCaseInsensitiveBehaviour() const; - void autoCSetMulti(sptr_t multi); - sptr_t autoCMulti() const; - void autoCSetOrder(sptr_t order); - sptr_t autoCOrder() const; - void allocate(sptr_t bytes); - QByteArray targetAsUTF8(); - void setLengthForEncode(sptr_t bytes); - QByteArray encodedFromUTF8(const char * utf8); - sptr_t findColumn(sptr_t line, sptr_t column); - sptr_t caretSticky() const; - void setCaretSticky(sptr_t useCaretStickyBehaviour); - void toggleCaretSticky(); - void setPasteConvertEndings(bool convert); - bool pasteConvertEndings() const; - void selectionDuplicate(); - void setCaretLineBackAlpha(sptr_t alpha); - sptr_t caretLineBackAlpha() const; - void setCaretStyle(sptr_t caretStyle); - sptr_t caretStyle() const; - void setIndicatorCurrent(sptr_t indicator); - sptr_t indicatorCurrent() const; - void setIndicatorValue(sptr_t value); - sptr_t indicatorValue() const; - void indicatorFillRange(sptr_t position, sptr_t fillLength); - void indicatorClearRange(sptr_t position, sptr_t clearLength); - sptr_t indicatorAllOnFor(sptr_t position); - sptr_t indicatorValueAt(sptr_t indicator, sptr_t position); - sptr_t indicatorStart(sptr_t indicator, sptr_t position); - sptr_t indicatorEnd(sptr_t indicator, sptr_t position); - void setPositionCache(sptr_t size); - sptr_t positionCache() const; - void copyAllowLine(); - sptr_t characterPointer() const; - sptr_t rangePointer(sptr_t position, sptr_t rangeLength) const; - sptr_t gapPosition() const; - void indicSetAlpha(sptr_t indicator, sptr_t alpha); - sptr_t indicAlpha(sptr_t indicator) const; - void indicSetOutlineAlpha(sptr_t indicator, sptr_t alpha); - sptr_t indicOutlineAlpha(sptr_t indicator) const; - void setExtraAscent(sptr_t extraAscent); - sptr_t extraAscent() const; - void setExtraDescent(sptr_t extraDescent); - sptr_t extraDescent() const; - sptr_t markerSymbolDefined(sptr_t markerNumber); - void marginSetText(sptr_t line, const char * text); - QByteArray marginText(sptr_t line) const; - void marginSetStyle(sptr_t line, sptr_t style); - sptr_t marginStyle(sptr_t line) const; - void marginSetStyles(sptr_t line, const char * styles); - QByteArray marginStyles(sptr_t line) const; - void marginTextClearAll(); - void marginSetStyleOffset(sptr_t style); - sptr_t marginStyleOffset() const; - void setMarginOptions(sptr_t marginOptions); - sptr_t marginOptions() const; - void annotationSetText(sptr_t line, const char * text); - QByteArray annotationText(sptr_t line) const; - void annotationSetStyle(sptr_t line, sptr_t style); - sptr_t annotationStyle(sptr_t line) const; - void annotationSetStyles(sptr_t line, const char * styles); - QByteArray annotationStyles(sptr_t line) const; - sptr_t annotationLines(sptr_t line) const; - void annotationClearAll(); - void annotationSetVisible(sptr_t visible); - sptr_t annotationVisible() const; - void annotationSetStyleOffset(sptr_t style); - sptr_t annotationStyleOffset() const; - void releaseAllExtendedStyles(); - sptr_t allocateExtendedStyles(sptr_t numberStyles); - void addUndoAction(sptr_t token, sptr_t flags); - sptr_t charPositionFromPoint(sptr_t x, sptr_t y); - sptr_t charPositionFromPointClose(sptr_t x, sptr_t y); - void setMouseSelectionRectangularSwitch(bool mouseSelectionRectangularSwitch); - bool mouseSelectionRectangularSwitch() const; - void setMultipleSelection(bool multipleSelection); - bool multipleSelection() const; - void setAdditionalSelectionTyping(bool additionalSelectionTyping); - bool additionalSelectionTyping() const; - void setAdditionalCaretsBlink(bool additionalCaretsBlink); - bool additionalCaretsBlink() const; - void setAdditionalCaretsVisible(bool additionalCaretsBlink); - bool additionalCaretsVisible() const; - sptr_t selections() const; - bool selectionEmpty() const; - void clearSelections(); - sptr_t setSelection(sptr_t caret, sptr_t anchor); - sptr_t addSelection(sptr_t caret, sptr_t anchor); - void dropSelectionN(sptr_t selection); - void setMainSelection(sptr_t selection); - sptr_t mainSelection() const; - void setSelectionNCaret(sptr_t selection, sptr_t pos); - sptr_t selectionNCaret(sptr_t selection) const; - void setSelectionNAnchor(sptr_t selection, sptr_t posAnchor); - sptr_t selectionNAnchor(sptr_t selection) const; - void setSelectionNCaretVirtualSpace(sptr_t selection, sptr_t space); - sptr_t selectionNCaretVirtualSpace(sptr_t selection) const; - void setSelectionNAnchorVirtualSpace(sptr_t selection, sptr_t space); - sptr_t selectionNAnchorVirtualSpace(sptr_t selection) const; - void setSelectionNStart(sptr_t selection, sptr_t pos); - sptr_t selectionNStart(sptr_t selection) const; - void setSelectionNEnd(sptr_t selection, sptr_t pos); - sptr_t selectionNEnd(sptr_t selection) const; - void setRectangularSelectionCaret(sptr_t pos); - sptr_t rectangularSelectionCaret() const; - void setRectangularSelectionAnchor(sptr_t posAnchor); - sptr_t rectangularSelectionAnchor() const; - void setRectangularSelectionCaretVirtualSpace(sptr_t space); - sptr_t rectangularSelectionCaretVirtualSpace() const; - void setRectangularSelectionAnchorVirtualSpace(sptr_t space); - sptr_t rectangularSelectionAnchorVirtualSpace() const; - void setVirtualSpaceOptions(sptr_t virtualSpaceOptions); - sptr_t virtualSpaceOptions() const; - void setRectangularSelectionModifier(sptr_t modifier); - sptr_t rectangularSelectionModifier() const; - void setAdditionalSelFore(sptr_t fore); - void setAdditionalSelBack(sptr_t back); - void setAdditionalSelAlpha(sptr_t alpha); - sptr_t additionalSelAlpha() const; - void setAdditionalCaretFore(sptr_t fore); - sptr_t additionalCaretFore() const; - void rotateSelection(); - void swapMainAnchorCaret(); - void multipleSelectAddNext(); - void multipleSelectAddEach(); - sptr_t changeLexerState(sptr_t start, sptr_t end); - sptr_t contractedFoldNext(sptr_t lineStart); - void verticalCentreCaret(); - void moveSelectedLinesUp(); - void moveSelectedLinesDown(); - void setIdentifier(sptr_t identifier); - sptr_t identifier() const; - void rGBAImageSetWidth(sptr_t width); - void rGBAImageSetHeight(sptr_t height); - void rGBAImageSetScale(sptr_t scalePercent); - void markerDefineRGBAImage(sptr_t markerNumber, const char * pixels); - void registerRGBAImage(sptr_t type, const char * pixels); - void scrollToStart(); - void scrollToEnd(); - void setTechnology(sptr_t technology); - sptr_t technology() const; - sptr_t createLoader(sptr_t bytes); - void findIndicatorShow(sptr_t start, sptr_t end); - void findIndicatorFlash(sptr_t start, sptr_t end); - void findIndicatorHide(); - void vCHomeDisplay(); - void vCHomeDisplayExtend(); - bool caretLineVisibleAlways() const; - void setCaretLineVisibleAlways(bool alwaysVisible); - void setLineEndTypesAllowed(sptr_t lineEndBitSet); - sptr_t lineEndTypesAllowed() const; - sptr_t lineEndTypesActive() const; - void setRepresentation(const char * encodedCharacter, const char * representation); - QByteArray representation(const char * encodedCharacter) const; - void clearRepresentation(const char * encodedCharacter); - void startRecord(); - void stopRecord(); - void setLexer(sptr_t lexer); - sptr_t lexer() const; - void colourise(sptr_t start, sptr_t end); - void setProperty(const char * key, const char * value); - void setKeyWords(sptr_t keywordSet, const char * keyWords); - void setLexerLanguage(const char * language); - void loadLexerLibrary(const char * path); - QByteArray property(const char * key) const; - QByteArray propertyExpanded(const char * key) const; - sptr_t propertyInt(const char * key) const; - sptr_t styleBitsNeeded() const; - QByteArray lexerLanguage() const; - sptr_t privateLexerCall(sptr_t operation, sptr_t pointer); - QByteArray propertyNames(); - sptr_t propertyType(const char * name); - QByteArray describeProperty(const char * name); - QByteArray describeKeyWordSets(); - sptr_t lineEndTypesSupported() const; - sptr_t allocateSubStyles(sptr_t styleBase, sptr_t numberStyles); - sptr_t subStylesStart(sptr_t styleBase) const; - sptr_t subStylesLength(sptr_t styleBase) const; - sptr_t styleFromSubStyle(sptr_t subStyle) const; - sptr_t primaryStyleFromStyle(sptr_t style) const; - void freeSubStyles(); - void setIdentifiers(sptr_t style, const char * identifiers); - sptr_t distanceToSecondaryStyles() const; - QByteArray subStyleBases() const; -/* --Autogenerated -- end of section automatically generated from Scintilla.iface */ - -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif /* SCINTILLAEDIT_H */ diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/PlatQt.h b/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/PlatQt.h deleted file mode 100644 index be35d818..00000000 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditBase/PlatQt.h +++ /dev/null @@ -1,132 +0,0 @@ -// -// Copyright (c) 1990-2011, Scientific Toolworks, Inc. -// -// The License.txt file describes the conditions under which this software may be distributed. -// -// Author: Jason Haslam -// -// Additions Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware -// Scintilla platform layer for Qt - -#ifndef PLATQT_H -#define PLATQT_H - -#include "Platform.h" - -#include -#include -#include - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -const char *CharacterSetID(int characterSet); - -inline QColor QColorFromCA(ColourDesired ca) -{ - long c = ca.AsLong(); - return QColor(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); -} - -inline QRect QRectFromPRect(PRectangle pr) -{ - return QRect(pr.left, pr.top, pr.Width(), pr.Height()); -} - -inline QRectF QRectFFromPRect(PRectangle pr) -{ - return QRectF(pr.left, pr.top, pr.Width(), pr.Height()); -} - -inline PRectangle PRectFromQRect(QRect qr) -{ - return PRectangle(qr.x(), qr.y(), qr.x() + qr.width(), qr.y() + qr.height()); -} - -inline Point PointFromQPoint(QPoint qp) -{ - return Point(qp.x(), qp.y()); -} - -class SurfaceImpl : public Surface { -private: - QPaintDevice *device; - QPainter *painter; - bool deviceOwned; - bool painterOwned; - float x, y; - bool unicodeMode; - int codePage; - const char *codecName; - QTextCodec *codec; - -public: - SurfaceImpl(); - virtual ~SurfaceImpl(); - - virtual void Init(WindowID wid); - virtual void Init(SurfaceID sid, WindowID wid); - virtual void InitPixMap(int width, int height, - Surface *surface, WindowID wid); - - virtual void Release(); - virtual bool Initialised(); - virtual void PenColour(ColourDesired fore); - virtual int LogPixelsY(); - virtual int DeviceHeightFont(int points); - virtual void MoveTo(int x, int y); - virtual void LineTo(int x, int y); - virtual void Polygon(Point *pts, int npts, ColourDesired fore, - ColourDesired back); - virtual void RectangleDraw(PRectangle rc, ColourDesired fore, - ColourDesired back); - virtual void FillRectangle(PRectangle rc, ColourDesired back); - virtual void FillRectangle(PRectangle rc, Surface &surfacePattern); - virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, - ColourDesired back); - virtual void AlphaRectangle(PRectangle rc, int corner, ColourDesired fill, - int alphaFill, ColourDesired outline, int alphaOutline, int flags); - virtual void DrawRGBAImage(PRectangle rc, int width, int height, - const unsigned char *pixelsImage); - virtual void Ellipse(PRectangle rc, ColourDesired fore, - ColourDesired back); - virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource); - - virtual void DrawTextNoClip(PRectangle rc, Font &font, XYPOSITION ybase, - const char *s, int len, ColourDesired fore, ColourDesired back); - virtual void DrawTextClipped(PRectangle rc, Font &font, XYPOSITION ybase, - const char *s, int len, ColourDesired fore, ColourDesired back); - virtual void DrawTextTransparent(PRectangle rc, Font &font, XYPOSITION ybase, - const char *s, int len, ColourDesired fore); - virtual void MeasureWidths(Font &font, const char *s, int len, - XYPOSITION *positions); - virtual XYPOSITION WidthText(Font &font, const char *s, int len); - virtual XYPOSITION WidthChar(Font &font, char ch); - virtual XYPOSITION Ascent(Font &font); - virtual XYPOSITION Descent(Font &font); - virtual XYPOSITION InternalLeading(Font &font); - virtual XYPOSITION ExternalLeading(Font &font); - virtual XYPOSITION Height(Font &font); - virtual XYPOSITION AverageCharWidth(Font &font); - - virtual void SetClip(PRectangle rc); - virtual void FlushCachedState(); - - virtual void SetUnicodeMode(bool unicodeMode); - virtual void SetDBCSMode(int codePage); - - void BrushColour(ColourDesired back); - void SetCodec(Font &font); - void SetFont(Font &font); - - QPaintDevice *GetPaintDevice(); - void SetPainter(QPainter *painter); - QPainter *GetPainter(); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/ScintillaConstants.py b/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/ScintillaConstants.py deleted file mode 100644 index b07e4016..00000000 --- a/dep/scintilla/scintilla-3.6.0/qt/ScintillaEditPy/ScintillaConstants.py +++ /dev/null @@ -1,2385 +0,0 @@ -# ScintillaConstants.py -# Define all the symbolic constants from Scintilla.iface so Python code can use them -# Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware - -# ++Autogenerated -- start of section automatically generated from Scintilla.iface */ -INVALID_POSITION=-1 -SCI_START=2000 -SCI_OPTIONAL_START=3000 -SCI_LEXER_START=4000 -SCI_ADDTEXT=2001 -SCI_ADDSTYLEDTEXT=2002 -SCI_INSERTTEXT=2003 -SCI_CHANGEINSERTION=2672 -SCI_CLEARALL=2004 -SCI_DELETERANGE=2645 -SCI_CLEARDOCUMENTSTYLE=2005 -SCI_REDO=2011 -SCI_SELECTALL=2013 -SCI_SETSAVEPOINT=2014 -SCI_GETSTYLEDTEXT=2015 -SCI_CANREDO=2016 -SCI_MARKERLINEFROMHANDLE=2017 -SCI_MARKERDELETEHANDLE=2018 -SCWS_INVISIBLE=0 -SCWS_VISIBLEALWAYS=1 -SCWS_VISIBLEAFTERINDENT=2 -SCI_POSITIONFROMPOINT=2022 -SCI_POSITIONFROMPOINTCLOSE=2023 -SCI_GOTOLINE=2024 -SCI_GOTOPOS=2025 -SCI_GETCURLINE=2027 -SC_EOL_CRLF=0 -SC_EOL_CR=1 -SC_EOL_LF=2 -SCI_CONVERTEOLS=2029 -SCI_STARTSTYLING=2032 -SCI_SETSTYLING=2033 -SCI_CLEARTABSTOPS=2675 -SCI_ADDTABSTOP=2676 -SCI_GETNEXTTABSTOP=2677 -SC_CP_UTF8=65001 -SC_IME_WINDOWED=0 -SC_IME_INLINE=1 -MARKER_MAX=31 -SC_MARK_CIRCLE=0 -SC_MARK_ROUNDRECT=1 -SC_MARK_ARROW=2 -SC_MARK_SMALLRECT=3 -SC_MARK_SHORTARROW=4 -SC_MARK_EMPTY=5 -SC_MARK_ARROWDOWN=6 -SC_MARK_MINUS=7 -SC_MARK_PLUS=8 -SC_MARK_VLINE=9 -SC_MARK_LCORNER=10 -SC_MARK_TCORNER=11 -SC_MARK_BOXPLUS=12 -SC_MARK_BOXPLUSCONNECTED=13 -SC_MARK_BOXMINUS=14 -SC_MARK_BOXMINUSCONNECTED=15 -SC_MARK_LCORNERCURVE=16 -SC_MARK_TCORNERCURVE=17 -SC_MARK_CIRCLEPLUS=18 -SC_MARK_CIRCLEPLUSCONNECTED=19 -SC_MARK_CIRCLEMINUS=20 -SC_MARK_CIRCLEMINUSCONNECTED=21 -SC_MARK_BACKGROUND=22 -SC_MARK_DOTDOTDOT=23 -SC_MARK_ARROWS=24 -SC_MARK_PIXMAP=25 -SC_MARK_FULLRECT=26 -SC_MARK_LEFTRECT=27 -SC_MARK_AVAILABLE=28 -SC_MARK_UNDERLINE=29 -SC_MARK_RGBAIMAGE=30 -SC_MARK_BOOKMARK=31 -SC_MARK_CHARACTER=10000 -SC_MARKNUM_FOLDEREND=25 -SC_MARKNUM_FOLDEROPENMID=26 -SC_MARKNUM_FOLDERMIDTAIL=27 -SC_MARKNUM_FOLDERTAIL=28 -SC_MARKNUM_FOLDERSUB=29 -SC_MARKNUM_FOLDER=30 -SC_MARKNUM_FOLDEROPEN=31 -SC_MASK_FOLDERS=0xFE000000 -SCI_MARKERDEFINE=2040 -SCI_MARKERENABLEHIGHLIGHT=2293 -SCI_MARKERADD=2043 -SCI_MARKERDELETE=2044 -SCI_MARKERDELETEALL=2045 -SCI_MARKERGET=2046 -SCI_MARKERNEXT=2047 -SCI_MARKERPREVIOUS=2048 -SCI_MARKERDEFINEPIXMAP=2049 -SCI_MARKERADDSET=2466 -SC_MAX_MARGIN=4 -SC_MARGIN_SYMBOL=0 -SC_MARGIN_NUMBER=1 -SC_MARGIN_BACK=2 -SC_MARGIN_FORE=3 -SC_MARGIN_TEXT=4 -SC_MARGIN_RTEXT=5 -STYLE_DEFAULT=32 -STYLE_LINENUMBER=33 -STYLE_BRACELIGHT=34 -STYLE_BRACEBAD=35 -STYLE_CONTROLCHAR=36 -STYLE_INDENTGUIDE=37 -STYLE_CALLTIP=38 -STYLE_LASTPREDEFINED=39 -STYLE_MAX=255 -SC_CHARSET_ANSI=0 -SC_CHARSET_DEFAULT=1 -SC_CHARSET_BALTIC=186 -SC_CHARSET_CHINESEBIG5=136 -SC_CHARSET_EASTEUROPE=238 -SC_CHARSET_GB2312=134 -SC_CHARSET_GREEK=161 -SC_CHARSET_HANGUL=129 -SC_CHARSET_MAC=77 -SC_CHARSET_OEM=255 -SC_CHARSET_RUSSIAN=204 -SC_CHARSET_CYRILLIC=1251 -SC_CHARSET_SHIFTJIS=128 -SC_CHARSET_SYMBOL=2 -SC_CHARSET_TURKISH=162 -SC_CHARSET_JOHAB=130 -SC_CHARSET_HEBREW=177 -SC_CHARSET_ARABIC=178 -SC_CHARSET_VIETNAMESE=163 -SC_CHARSET_THAI=222 -SC_CHARSET_8859_15=1000 -SCI_STYLECLEARALL=2050 -SCI_STYLERESETDEFAULT=2058 -SC_CASE_MIXED=0 -SC_CASE_UPPER=1 -SC_CASE_LOWER=2 -SC_CASE_CAMEL=3 -SC_FONT_SIZE_MULTIPLIER=100 -SC_WEIGHT_NORMAL=400 -SC_WEIGHT_SEMIBOLD=600 -SC_WEIGHT_BOLD=700 -SCI_SETSELFORE=2067 -SCI_SETSELBACK=2068 -SCI_ASSIGNCMDKEY=2070 -SCI_CLEARCMDKEY=2071 -SCI_CLEARALLCMDKEYS=2072 -SCI_SETSTYLINGEX=2073 -SCI_BEGINUNDOACTION=2078 -SCI_ENDUNDOACTION=2079 -INDIC_PLAIN=0 -INDIC_SQUIGGLE=1 -INDIC_TT=2 -INDIC_DIAGONAL=3 -INDIC_STRIKE=4 -INDIC_HIDDEN=5 -INDIC_BOX=6 -INDIC_ROUNDBOX=7 -INDIC_STRAIGHTBOX=8 -INDIC_DASH=9 -INDIC_DOTS=10 -INDIC_SQUIGGLELOW=11 -INDIC_DOTBOX=12 -INDIC_SQUIGGLEPIXMAP=13 -INDIC_COMPOSITIONTHICK=14 -INDIC_COMPOSITIONTHIN=15 -INDIC_FULLBOX=16 -INDIC_TEXTFORE=17 -INDIC_IME=32 -INDIC_IME_MAX=35 -INDIC_MAX=35 -INDIC_CONTAINER=8 -INDIC0_MASK=0x20 -INDIC1_MASK=0x40 -INDIC2_MASK=0x80 -INDICS_MASK=0xE0 -SC_INDICVALUEBIT=0x1000000 -SC_INDICVALUEMASK=0xFFFFFF -SC_INDICFLAG_VALUEFORE=1 -SCI_SETWHITESPACEFORE=2084 -SCI_SETWHITESPACEBACK=2085 -SCI_AUTOCSHOW=2100 -SCI_AUTOCCANCEL=2101 -SCI_AUTOCACTIVE=2102 -SCI_AUTOCPOSSTART=2103 -SCI_AUTOCCOMPLETE=2104 -SCI_AUTOCSTOPS=2105 -SCI_AUTOCSELECT=2108 -SCI_USERLISTSHOW=2117 -SCI_REGISTERIMAGE=2405 -SCI_CLEARREGISTEREDIMAGES=2408 -SCI_COUNTCHARACTERS=2633 -SC_IV_NONE=0 -SC_IV_REAL=1 -SC_IV_LOOKFORWARD=2 -SC_IV_LOOKBOTH=3 -SCI_SETEMPTYSELECTION=2556 -SC_PRINT_NORMAL=0 -SC_PRINT_INVERTLIGHT=1 -SC_PRINT_BLACKONWHITE=2 -SC_PRINT_COLOURONWHITE=3 -SC_PRINT_COLOURONWHITEDEFAULTBG=4 -SCFIND_WHOLEWORD=0x2 -SCFIND_MATCHCASE=0x4 -SCFIND_WORDSTART=0x00100000 -SCFIND_REGEXP=0x00200000 -SCFIND_POSIX=0x00400000 -SCFIND_CXX11REGEX=0x00800000 -SCI_FINDTEXT=2150 -SCI_FORMATRANGE=2151 -SCI_GETLINE=2153 -SCI_SETSEL=2160 -SCI_GETSELTEXT=2161 -SCI_GETTEXTRANGE=2162 -SCI_HIDESELECTION=2163 -SCI_POINTXFROMPOSITION=2164 -SCI_POINTYFROMPOSITION=2165 -SCI_LINEFROMPOSITION=2166 -SCI_POSITIONFROMLINE=2167 -SCI_LINESCROLL=2168 -SCI_SCROLLCARET=2169 -SCI_SCROLLRANGE=2569 -SCI_REPLACESEL=2170 -SCI_NULL=2172 -SCI_CANPASTE=2173 -SCI_CANUNDO=2174 -SCI_EMPTYUNDOBUFFER=2175 -SCI_UNDO=2176 -SCI_CUT=2177 -SCI_COPY=2178 -SCI_PASTE=2179 -SCI_CLEAR=2180 -SCI_SETTEXT=2181 -SCI_GETTEXT=2182 -SCI_SETTARGETRANGE=2686 -SCI_TARGETFROMSELECTION=2287 -SCI_TARGETWHOLEDOCUMENT=2690 -SCI_REPLACETARGET=2194 -SCI_REPLACETARGETRE=2195 -SCI_SEARCHINTARGET=2197 -SCI_CALLTIPSHOW=2200 -SCI_CALLTIPCANCEL=2201 -SCI_CALLTIPACTIVE=2202 -SCI_CALLTIPPOSSTART=2203 -SCI_CALLTIPSETHLT=2204 -SCI_VISIBLEFROMDOCLINE=2220 -SCI_DOCLINEFROMVISIBLE=2221 -SCI_WRAPCOUNT=2235 -SC_FOLDLEVELBASE=0x400 -SC_FOLDLEVELWHITEFLAG=0x1000 -SC_FOLDLEVELHEADERFLAG=0x2000 -SC_FOLDLEVELNUMBERMASK=0x0FFF -SCI_SHOWLINES=2226 -SCI_HIDELINES=2227 -SCI_TOGGLEFOLD=2231 -SC_FOLDACTION_CONTRACT=0 -SC_FOLDACTION_EXPAND=1 -SC_FOLDACTION_TOGGLE=2 -SCI_FOLDLINE=2237 -SCI_FOLDCHILDREN=2238 -SCI_EXPANDCHILDREN=2239 -SCI_FOLDALL=2662 -SCI_ENSUREVISIBLE=2232 -SC_AUTOMATICFOLD_SHOW=0x0001 -SC_AUTOMATICFOLD_CLICK=0x0002 -SC_AUTOMATICFOLD_CHANGE=0x0004 -SC_FOLDFLAG_LINEBEFORE_EXPANDED=0x0002 -SC_FOLDFLAG_LINEBEFORE_CONTRACTED=0x0004 -SC_FOLDFLAG_LINEAFTER_EXPANDED=0x0008 -SC_FOLDFLAG_LINEAFTER_CONTRACTED=0x0010 -SC_FOLDFLAG_LEVELNUMBERS=0x0040 -SC_FOLDFLAG_LINESTATE=0x0080 -SCI_ENSUREVISIBLEENFORCEPOLICY=2234 -SC_TIME_FOREVER=10000000 -SCI_WORDSTARTPOSITION=2266 -SCI_WORDENDPOSITION=2267 -SCI_ISRANGEWORD=2691 -SC_WRAP_NONE=0 -SC_WRAP_WORD=1 -SC_WRAP_CHAR=2 -SC_WRAP_WHITESPACE=3 -SC_WRAPVISUALFLAG_NONE=0x0000 -SC_WRAPVISUALFLAG_END=0x0001 -SC_WRAPVISUALFLAG_START=0x0002 -SC_WRAPVISUALFLAG_MARGIN=0x0004 -SC_WRAPVISUALFLAGLOC_DEFAULT=0x0000 -SC_WRAPVISUALFLAGLOC_END_BY_TEXT=0x0001 -SC_WRAPVISUALFLAGLOC_START_BY_TEXT=0x0002 -SC_WRAPINDENT_FIXED=0 -SC_WRAPINDENT_SAME=1 -SC_WRAPINDENT_INDENT=2 -SC_CACHE_NONE=0 -SC_CACHE_CARET=1 -SC_CACHE_PAGE=2 -SC_CACHE_DOCUMENT=3 -SCI_TEXTWIDTH=2276 -SCI_TEXTHEIGHT=2279 -SCI_APPENDTEXT=2282 -SC_PHASES_ONE=0 -SC_PHASES_TWO=1 -SC_PHASES_MULTIPLE=2 -SC_EFF_QUALITY_MASK=0xF -SC_EFF_QUALITY_DEFAULT=0 -SC_EFF_QUALITY_NON_ANTIALIASED=1 -SC_EFF_QUALITY_ANTIALIASED=2 -SC_EFF_QUALITY_LCD_OPTIMIZED=3 -SC_MULTIPASTE_ONCE=0 -SC_MULTIPASTE_EACH=1 -SCI_LINESJOIN=2288 -SCI_LINESSPLIT=2289 -SCI_SETFOLDMARGINCOLOUR=2290 -SCI_SETFOLDMARGINHICOLOUR=2291 -SCI_LINEDOWN=2300 -SCI_LINEDOWNEXTEND=2301 -SCI_LINEUP=2302 -SCI_LINEUPEXTEND=2303 -SCI_CHARLEFT=2304 -SCI_CHARLEFTEXTEND=2305 -SCI_CHARRIGHT=2306 -SCI_CHARRIGHTEXTEND=2307 -SCI_WORDLEFT=2308 -SCI_WORDLEFTEXTEND=2309 -SCI_WORDRIGHT=2310 -SCI_WORDRIGHTEXTEND=2311 -SCI_HOME=2312 -SCI_HOMEEXTEND=2313 -SCI_LINEEND=2314 -SCI_LINEENDEXTEND=2315 -SCI_DOCUMENTSTART=2316 -SCI_DOCUMENTSTARTEXTEND=2317 -SCI_DOCUMENTEND=2318 -SCI_DOCUMENTENDEXTEND=2319 -SCI_PAGEUP=2320 -SCI_PAGEUPEXTEND=2321 -SCI_PAGEDOWN=2322 -SCI_PAGEDOWNEXTEND=2323 -SCI_EDITTOGGLEOVERTYPE=2324 -SCI_CANCEL=2325 -SCI_DELETEBACK=2326 -SCI_TAB=2327 -SCI_BACKTAB=2328 -SCI_NEWLINE=2329 -SCI_FORMFEED=2330 -SCI_VCHOME=2331 -SCI_VCHOMEEXTEND=2332 -SCI_ZOOMIN=2333 -SCI_ZOOMOUT=2334 -SCI_DELWORDLEFT=2335 -SCI_DELWORDRIGHT=2336 -SCI_DELWORDRIGHTEND=2518 -SCI_LINECUT=2337 -SCI_LINEDELETE=2338 -SCI_LINETRANSPOSE=2339 -SCI_LINEDUPLICATE=2404 -SCI_LOWERCASE=2340 -SCI_UPPERCASE=2341 -SCI_LINESCROLLDOWN=2342 -SCI_LINESCROLLUP=2343 -SCI_DELETEBACKNOTLINE=2344 -SCI_HOMEDISPLAY=2345 -SCI_HOMEDISPLAYEXTEND=2346 -SCI_LINEENDDISPLAY=2347 -SCI_LINEENDDISPLAYEXTEND=2348 -SCI_HOMEWRAP=2349 -SCI_HOMEWRAPEXTEND=2450 -SCI_LINEENDWRAP=2451 -SCI_LINEENDWRAPEXTEND=2452 -SCI_VCHOMEWRAP=2453 -SCI_VCHOMEWRAPEXTEND=2454 -SCI_LINECOPY=2455 -SCI_MOVECARETINSIDEVIEW=2401 -SCI_LINELENGTH=2350 -SCI_BRACEHIGHLIGHT=2351 -SCI_BRACEHIGHLIGHTINDICATOR=2498 -SCI_BRACEBADLIGHT=2352 -SCI_BRACEBADLIGHTINDICATOR=2499 -SCI_BRACEMATCH=2353 -EDGE_NONE=0 -EDGE_LINE=1 -EDGE_BACKGROUND=2 -SCI_SEARCHANCHOR=2366 -SCI_SEARCHNEXT=2367 -SCI_SEARCHPREV=2368 -SCI_USEPOPUP=2371 -SCI_CREATEDOCUMENT=2375 -SCI_ADDREFDOCUMENT=2376 -SCI_RELEASEDOCUMENT=2377 -SC_STATUS_OK=0 -SC_STATUS_FAILURE=1 -SC_STATUS_BADALLOC=2 -SC_STATUS_WARN_START=1000 -SC_STATUS_WARN_REGEX=1001 -SC_CURSORNORMAL=-1 -SC_CURSORARROW=2 -SC_CURSORWAIT=4 -SC_CURSORREVERSEARROW=7 -SCI_WORDPARTLEFT=2390 -SCI_WORDPARTLEFTEXTEND=2391 -SCI_WORDPARTRIGHT=2392 -SCI_WORDPARTRIGHTEXTEND=2393 -VISIBLE_SLOP=0x01 -VISIBLE_STRICT=0x04 -SCI_SETVISIBLEPOLICY=2394 -SCI_DELLINELEFT=2395 -SCI_DELLINERIGHT=2396 -SCI_CHOOSECARETX=2399 -SCI_GRABFOCUS=2400 -CARET_SLOP=0x01 -CARET_STRICT=0x04 -CARET_JUMPS=0x10 -CARET_EVEN=0x08 -SCI_SETXCARETPOLICY=2402 -SCI_SETYCARETPOLICY=2403 -SCI_PARADOWN=2413 -SCI_PARADOWNEXTEND=2414 -SCI_PARAUP=2415 -SCI_PARAUPEXTEND=2416 -SCI_POSITIONBEFORE=2417 -SCI_POSITIONAFTER=2418 -SCI_POSITIONRELATIVE=2670 -SCI_COPYRANGE=2419 -SCI_COPYTEXT=2420 -SC_SEL_STREAM=0 -SC_SEL_RECTANGLE=1 -SC_SEL_LINES=2 -SC_SEL_THIN=3 -SCI_GETLINESELSTARTPOSITION=2424 -SCI_GETLINESELENDPOSITION=2425 -SCI_LINEDOWNRECTEXTEND=2426 -SCI_LINEUPRECTEXTEND=2427 -SCI_CHARLEFTRECTEXTEND=2428 -SCI_CHARRIGHTRECTEXTEND=2429 -SCI_HOMERECTEXTEND=2430 -SCI_VCHOMERECTEXTEND=2431 -SCI_LINEENDRECTEXTEND=2432 -SCI_PAGEUPRECTEXTEND=2433 -SCI_PAGEDOWNRECTEXTEND=2434 -SCI_STUTTEREDPAGEUP=2435 -SCI_STUTTEREDPAGEUPEXTEND=2436 -SCI_STUTTEREDPAGEDOWN=2437 -SCI_STUTTEREDPAGEDOWNEXTEND=2438 -SCI_WORDLEFTEND=2439 -SCI_WORDLEFTENDEXTEND=2440 -SCI_WORDRIGHTEND=2441 -SCI_WORDRIGHTENDEXTEND=2442 -SCI_SETCHARSDEFAULT=2444 -SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE=0 -SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE=1 -SC_MULTIAUTOC_ONCE=0 -SC_MULTIAUTOC_EACH=1 -SC_ORDER_PRESORTED=0 -SC_ORDER_PERFORMSORT=1 -SC_ORDER_CUSTOM=2 -SCI_ALLOCATE=2446 -SCI_TARGETASUTF8=2447 -SCI_SETLENGTHFORENCODE=2448 -SCI_ENCODEDFROMUTF8=2449 -SCI_FINDCOLUMN=2456 -SC_CARETSTICKY_OFF=0 -SC_CARETSTICKY_ON=1 -SC_CARETSTICKY_WHITESPACE=2 -SCI_TOGGLECARETSTICKY=2459 -SCI_SELECTIONDUPLICATE=2469 -SC_ALPHA_TRANSPARENT=0 -SC_ALPHA_OPAQUE=255 -SC_ALPHA_NOALPHA=256 -CARETSTYLE_INVISIBLE=0 -CARETSTYLE_LINE=1 -CARETSTYLE_BLOCK=2 -SCI_INDICATORFILLRANGE=2504 -SCI_INDICATORCLEARRANGE=2505 -SCI_INDICATORALLONFOR=2506 -SCI_INDICATORVALUEAT=2507 -SCI_INDICATORSTART=2508 -SCI_INDICATOREND=2509 -SCI_COPYALLOWLINE=2519 -SCI_MARKERSYMBOLDEFINED=2529 -SCI_MARGINTEXTCLEARALL=2536 -SC_MARGINOPTION_NONE=0 -SC_MARGINOPTION_SUBLINESELECT=1 -SCI_ANNOTATIONCLEARALL=2547 -ANNOTATION_HIDDEN=0 -ANNOTATION_STANDARD=1 -ANNOTATION_BOXED=2 -ANNOTATION_INDENTED=3 -SCI_RELEASEALLEXTENDEDSTYLES=2552 -SCI_ALLOCATEEXTENDEDSTYLES=2553 -UNDO_MAY_COALESCE=1 -SCI_ADDUNDOACTION=2560 -SCI_CHARPOSITIONFROMPOINT=2561 -SCI_CHARPOSITIONFROMPOINTCLOSE=2562 -SCI_CLEARSELECTIONS=2571 -SCI_SETSELECTION=2572 -SCI_ADDSELECTION=2573 -SCI_DROPSELECTIONN=2671 -SCVS_NONE=0 -SCVS_RECTANGULARSELECTION=1 -SCVS_USERACCESSIBLE=2 -SCI_ROTATESELECTION=2606 -SCI_SWAPMAINANCHORCARET=2607 -SCI_MULTIPLESELECTADDNEXT=2688 -SCI_MULTIPLESELECTADDEACH=2689 -SCI_CHANGELEXERSTATE=2617 -SCI_CONTRACTEDFOLDNEXT=2618 -SCI_VERTICALCENTRECARET=2619 -SCI_MOVESELECTEDLINESUP=2620 -SCI_MOVESELECTEDLINESDOWN=2621 -SCI_MARKERDEFINERGBAIMAGE=2626 -SCI_REGISTERRGBAIMAGE=2627 -SCI_SCROLLTOSTART=2628 -SCI_SCROLLTOEND=2629 -SC_TECHNOLOGY_DEFAULT=0 -SC_TECHNOLOGY_DIRECTWRITE=1 -SC_TECHNOLOGY_DIRECTWRITERETAIN=2 -SC_TECHNOLOGY_DIRECTWRITEDC=3 -SCI_CREATELOADER=2632 -SCI_FINDINDICATORSHOW=2640 -SCI_FINDINDICATORFLASH=2641 -SCI_FINDINDICATORHIDE=2642 -SCI_VCHOMEDISPLAY=2652 -SCI_VCHOMEDISPLAYEXTEND=2653 -SC_LINE_END_TYPE_DEFAULT=0 -SC_LINE_END_TYPE_UNICODE=1 -SCI_CLEARREPRESENTATION=2667 -SCI_STARTRECORD=3001 -SCI_STOPRECORD=3002 -SCI_COLOURISE=4003 -KEYWORDSET_MAX=8 -SCI_LOADLEXERLIBRARY=4007 -SCI_PRIVATELEXERCALL=4013 -SCI_PROPERTYNAMES=4014 -SC_TYPE_BOOLEAN=0 -SC_TYPE_INTEGER=1 -SC_TYPE_STRING=2 -SCI_PROPERTYTYPE=4015 -SCI_DESCRIBEPROPERTY=4016 -SCI_DESCRIBEKEYWORDSETS=4017 -SCI_ALLOCATESUBSTYLES=4020 -SCI_FREESUBSTYLES=4023 -SC_MOD_INSERTTEXT=0x1 -SC_MOD_DELETETEXT=0x2 -SC_MOD_CHANGESTYLE=0x4 -SC_MOD_CHANGEFOLD=0x8 -SC_PERFORMED_USER=0x10 -SC_PERFORMED_UNDO=0x20 -SC_PERFORMED_REDO=0x40 -SC_MULTISTEPUNDOREDO=0x80 -SC_LASTSTEPINUNDOREDO=0x100 -SC_MOD_CHANGEMARKER=0x200 -SC_MOD_BEFOREINSERT=0x400 -SC_MOD_BEFOREDELETE=0x800 -SC_MULTILINEUNDOREDO=0x1000 -SC_STARTACTION=0x2000 -SC_MOD_CHANGEINDICATOR=0x4000 -SC_MOD_CHANGELINESTATE=0x8000 -SC_MOD_CHANGEMARGIN=0x10000 -SC_MOD_CHANGEANNOTATION=0x20000 -SC_MOD_CONTAINER=0x40000 -SC_MOD_LEXERSTATE=0x80000 -SC_MOD_INSERTCHECK=0x100000 -SC_MOD_CHANGETABSTOPS=0x200000 -SC_MODEVENTMASKALL=0x3FFFFF -SC_UPDATE_CONTENT=0x1 -SC_UPDATE_SELECTION=0x2 -SC_UPDATE_V_SCROLL=0x4 -SC_UPDATE_H_SCROLL=0x8 -SCEN_CHANGE=768 -SCEN_SETFOCUS=512 -SCEN_KILLFOCUS=256 -SCK_DOWN=300 -SCK_UP=301 -SCK_LEFT=302 -SCK_RIGHT=303 -SCK_HOME=304 -SCK_END=305 -SCK_PRIOR=306 -SCK_NEXT=307 -SCK_DELETE=308 -SCK_INSERT=309 -SCK_ESCAPE=7 -SCK_BACK=8 -SCK_TAB=9 -SCK_RETURN=13 -SCK_ADD=310 -SCK_SUBTRACT=311 -SCK_DIVIDE=312 -SCK_WIN=313 -SCK_RWIN=314 -SCK_MENU=315 -SCMOD_NORM=0 -SCMOD_SHIFT=1 -SCMOD_CTRL=2 -SCMOD_ALT=4 -SCMOD_SUPER=8 -SCMOD_META=16 -SC_AC_FILLUP=1 -SC_AC_DOUBLECLICK=2 -SC_AC_TAB=3 -SC_AC_NEWLINE=4 -SC_AC_COMMAND=5 -SCLEX_CONTAINER=0 -SCLEX_NULL=1 -SCLEX_PYTHON=2 -SCLEX_CPP=3 -SCLEX_HTML=4 -SCLEX_XML=5 -SCLEX_PERL=6 -SCLEX_SQL=7 -SCLEX_VB=8 -SCLEX_PROPERTIES=9 -SCLEX_ERRORLIST=10 -SCLEX_MAKEFILE=11 -SCLEX_BATCH=12 -SCLEX_XCODE=13 -SCLEX_LATEX=14 -SCLEX_LUA=15 -SCLEX_DIFF=16 -SCLEX_CONF=17 -SCLEX_PASCAL=18 -SCLEX_AVE=19 -SCLEX_ADA=20 -SCLEX_LISP=21 -SCLEX_RUBY=22 -SCLEX_EIFFEL=23 -SCLEX_EIFFELKW=24 -SCLEX_TCL=25 -SCLEX_NNCRONTAB=26 -SCLEX_BULLANT=27 -SCLEX_VBSCRIPT=28 -SCLEX_BAAN=31 -SCLEX_MATLAB=32 -SCLEX_SCRIPTOL=33 -SCLEX_ASM=34 -SCLEX_CPPNOCASE=35 -SCLEX_FORTRAN=36 -SCLEX_F77=37 -SCLEX_CSS=38 -SCLEX_POV=39 -SCLEX_LOUT=40 -SCLEX_ESCRIPT=41 -SCLEX_PS=42 -SCLEX_NSIS=43 -SCLEX_MMIXAL=44 -SCLEX_CLW=45 -SCLEX_CLWNOCASE=46 -SCLEX_LOT=47 -SCLEX_YAML=48 -SCLEX_TEX=49 -SCLEX_METAPOST=50 -SCLEX_POWERBASIC=51 -SCLEX_FORTH=52 -SCLEX_ERLANG=53 -SCLEX_OCTAVE=54 -SCLEX_MSSQL=55 -SCLEX_VERILOG=56 -SCLEX_KIX=57 -SCLEX_GUI4CLI=58 -SCLEX_SPECMAN=59 -SCLEX_AU3=60 -SCLEX_APDL=61 -SCLEX_BASH=62 -SCLEX_ASN1=63 -SCLEX_VHDL=64 -SCLEX_CAML=65 -SCLEX_BLITZBASIC=66 -SCLEX_PUREBASIC=67 -SCLEX_HASKELL=68 -SCLEX_PHPSCRIPT=69 -SCLEX_TADS3=70 -SCLEX_REBOL=71 -SCLEX_SMALLTALK=72 -SCLEX_FLAGSHIP=73 -SCLEX_CSOUND=74 -SCLEX_FREEBASIC=75 -SCLEX_INNOSETUP=76 -SCLEX_OPAL=77 -SCLEX_SPICE=78 -SCLEX_D=79 -SCLEX_CMAKE=80 -SCLEX_GAP=81 -SCLEX_PLM=82 -SCLEX_PROGRESS=83 -SCLEX_ABAQUS=84 -SCLEX_ASYMPTOTE=85 -SCLEX_R=86 -SCLEX_MAGIK=87 -SCLEX_POWERSHELL=88 -SCLEX_MYSQL=89 -SCLEX_PO=90 -SCLEX_TAL=91 -SCLEX_COBOL=92 -SCLEX_TACL=93 -SCLEX_SORCUS=94 -SCLEX_POWERPRO=95 -SCLEX_NIMROD=96 -SCLEX_SML=97 -SCLEX_MARKDOWN=98 -SCLEX_TXT2TAGS=99 -SCLEX_A68K=100 -SCLEX_MODULA=101 -SCLEX_COFFEESCRIPT=102 -SCLEX_TCMD=103 -SCLEX_AVS=104 -SCLEX_ECL=105 -SCLEX_OSCRIPT=106 -SCLEX_VISUALPROLOG=107 -SCLEX_LITERATEHASKELL=108 -SCLEX_STTXT=109 -SCLEX_KVIRC=110 -SCLEX_RUST=111 -SCLEX_DMAP=112 -SCLEX_AS=113 -SCLEX_DMIS=114 -SCLEX_REGISTRY=115 -SCLEX_BIBTEX=116 -SCLEX_SREC=117 -SCLEX_IHEX=118 -SCLEX_TEHEX=119 -SCLEX_AUTOMATIC=1000 -SCE_P_DEFAULT=0 -SCE_P_COMMENTLINE=1 -SCE_P_NUMBER=2 -SCE_P_STRING=3 -SCE_P_CHARACTER=4 -SCE_P_WORD=5 -SCE_P_TRIPLE=6 -SCE_P_TRIPLEDOUBLE=7 -SCE_P_CLASSNAME=8 -SCE_P_DEFNAME=9 -SCE_P_OPERATOR=10 -SCE_P_IDENTIFIER=11 -SCE_P_COMMENTBLOCK=12 -SCE_P_STRINGEOL=13 -SCE_P_WORD2=14 -SCE_P_DECORATOR=15 -SCE_C_DEFAULT=0 -SCE_C_COMMENT=1 -SCE_C_COMMENTLINE=2 -SCE_C_COMMENTDOC=3 -SCE_C_NUMBER=4 -SCE_C_WORD=5 -SCE_C_STRING=6 -SCE_C_CHARACTER=7 -SCE_C_UUID=8 -SCE_C_PREPROCESSOR=9 -SCE_C_OPERATOR=10 -SCE_C_IDENTIFIER=11 -SCE_C_STRINGEOL=12 -SCE_C_VERBATIM=13 -SCE_C_REGEX=14 -SCE_C_COMMENTLINEDOC=15 -SCE_C_WORD2=16 -SCE_C_COMMENTDOCKEYWORD=17 -SCE_C_COMMENTDOCKEYWORDERROR=18 -SCE_C_GLOBALCLASS=19 -SCE_C_STRINGRAW=20 -SCE_C_TRIPLEVERBATIM=21 -SCE_C_HASHQUOTEDSTRING=22 -SCE_C_PREPROCESSORCOMMENT=23 -SCE_C_PREPROCESSORCOMMENTDOC=24 -SCE_C_USERLITERAL=25 -SCE_C_TASKMARKER=26 -SCE_C_ESCAPESEQUENCE=27 -SCE_D_DEFAULT=0 -SCE_D_COMMENT=1 -SCE_D_COMMENTLINE=2 -SCE_D_COMMENTDOC=3 -SCE_D_COMMENTNESTED=4 -SCE_D_NUMBER=5 -SCE_D_WORD=6 -SCE_D_WORD2=7 -SCE_D_WORD3=8 -SCE_D_TYPEDEF=9 -SCE_D_STRING=10 -SCE_D_STRINGEOL=11 -SCE_D_CHARACTER=12 -SCE_D_OPERATOR=13 -SCE_D_IDENTIFIER=14 -SCE_D_COMMENTLINEDOC=15 -SCE_D_COMMENTDOCKEYWORD=16 -SCE_D_COMMENTDOCKEYWORDERROR=17 -SCE_D_STRINGB=18 -SCE_D_STRINGR=19 -SCE_D_WORD5=20 -SCE_D_WORD6=21 -SCE_D_WORD7=22 -SCE_TCL_DEFAULT=0 -SCE_TCL_COMMENT=1 -SCE_TCL_COMMENTLINE=2 -SCE_TCL_NUMBER=3 -SCE_TCL_WORD_IN_QUOTE=4 -SCE_TCL_IN_QUOTE=5 -SCE_TCL_OPERATOR=6 -SCE_TCL_IDENTIFIER=7 -SCE_TCL_SUBSTITUTION=8 -SCE_TCL_SUB_BRACE=9 -SCE_TCL_MODIFIER=10 -SCE_TCL_EXPAND=11 -SCE_TCL_WORD=12 -SCE_TCL_WORD2=13 -SCE_TCL_WORD3=14 -SCE_TCL_WORD4=15 -SCE_TCL_WORD5=16 -SCE_TCL_WORD6=17 -SCE_TCL_WORD7=18 -SCE_TCL_WORD8=19 -SCE_TCL_COMMENT_BOX=20 -SCE_TCL_BLOCK_COMMENT=21 -SCE_H_DEFAULT=0 -SCE_H_TAG=1 -SCE_H_TAGUNKNOWN=2 -SCE_H_ATTRIBUTE=3 -SCE_H_ATTRIBUTEUNKNOWN=4 -SCE_H_NUMBER=5 -SCE_H_DOUBLESTRING=6 -SCE_H_SINGLESTRING=7 -SCE_H_OTHER=8 -SCE_H_COMMENT=9 -SCE_H_ENTITY=10 -SCE_H_TAGEND=11 -SCE_H_XMLSTART=12 -SCE_H_XMLEND=13 -SCE_H_SCRIPT=14 -SCE_H_ASP=15 -SCE_H_ASPAT=16 -SCE_H_CDATA=17 -SCE_H_QUESTION=18 -SCE_H_VALUE=19 -SCE_H_XCCOMMENT=20 -SCE_H_SGML_DEFAULT=21 -SCE_H_SGML_COMMAND=22 -SCE_H_SGML_1ST_PARAM=23 -SCE_H_SGML_DOUBLESTRING=24 -SCE_H_SGML_SIMPLESTRING=25 -SCE_H_SGML_ERROR=26 -SCE_H_SGML_SPECIAL=27 -SCE_H_SGML_ENTITY=28 -SCE_H_SGML_COMMENT=29 -SCE_H_SGML_1ST_PARAM_COMMENT=30 -SCE_H_SGML_BLOCK_DEFAULT=31 -SCE_HJ_START=40 -SCE_HJ_DEFAULT=41 -SCE_HJ_COMMENT=42 -SCE_HJ_COMMENTLINE=43 -SCE_HJ_COMMENTDOC=44 -SCE_HJ_NUMBER=45 -SCE_HJ_WORD=46 -SCE_HJ_KEYWORD=47 -SCE_HJ_DOUBLESTRING=48 -SCE_HJ_SINGLESTRING=49 -SCE_HJ_SYMBOLS=50 -SCE_HJ_STRINGEOL=51 -SCE_HJ_REGEX=52 -SCE_HJA_START=55 -SCE_HJA_DEFAULT=56 -SCE_HJA_COMMENT=57 -SCE_HJA_COMMENTLINE=58 -SCE_HJA_COMMENTDOC=59 -SCE_HJA_NUMBER=60 -SCE_HJA_WORD=61 -SCE_HJA_KEYWORD=62 -SCE_HJA_DOUBLESTRING=63 -SCE_HJA_SINGLESTRING=64 -SCE_HJA_SYMBOLS=65 -SCE_HJA_STRINGEOL=66 -SCE_HJA_REGEX=67 -SCE_HB_START=70 -SCE_HB_DEFAULT=71 -SCE_HB_COMMENTLINE=72 -SCE_HB_NUMBER=73 -SCE_HB_WORD=74 -SCE_HB_STRING=75 -SCE_HB_IDENTIFIER=76 -SCE_HB_STRINGEOL=77 -SCE_HBA_START=80 -SCE_HBA_DEFAULT=81 -SCE_HBA_COMMENTLINE=82 -SCE_HBA_NUMBER=83 -SCE_HBA_WORD=84 -SCE_HBA_STRING=85 -SCE_HBA_IDENTIFIER=86 -SCE_HBA_STRINGEOL=87 -SCE_HP_START=90 -SCE_HP_DEFAULT=91 -SCE_HP_COMMENTLINE=92 -SCE_HP_NUMBER=93 -SCE_HP_STRING=94 -SCE_HP_CHARACTER=95 -SCE_HP_WORD=96 -SCE_HP_TRIPLE=97 -SCE_HP_TRIPLEDOUBLE=98 -SCE_HP_CLASSNAME=99 -SCE_HP_DEFNAME=100 -SCE_HP_OPERATOR=101 -SCE_HP_IDENTIFIER=102 -SCE_HPHP_COMPLEX_VARIABLE=104 -SCE_HPA_START=105 -SCE_HPA_DEFAULT=106 -SCE_HPA_COMMENTLINE=107 -SCE_HPA_NUMBER=108 -SCE_HPA_STRING=109 -SCE_HPA_CHARACTER=110 -SCE_HPA_WORD=111 -SCE_HPA_TRIPLE=112 -SCE_HPA_TRIPLEDOUBLE=113 -SCE_HPA_CLASSNAME=114 -SCE_HPA_DEFNAME=115 -SCE_HPA_OPERATOR=116 -SCE_HPA_IDENTIFIER=117 -SCE_HPHP_DEFAULT=118 -SCE_HPHP_HSTRING=119 -SCE_HPHP_SIMPLESTRING=120 -SCE_HPHP_WORD=121 -SCE_HPHP_NUMBER=122 -SCE_HPHP_VARIABLE=123 -SCE_HPHP_COMMENT=124 -SCE_HPHP_COMMENTLINE=125 -SCE_HPHP_HSTRING_VARIABLE=126 -SCE_HPHP_OPERATOR=127 -SCE_PL_DEFAULT=0 -SCE_PL_ERROR=1 -SCE_PL_COMMENTLINE=2 -SCE_PL_POD=3 -SCE_PL_NUMBER=4 -SCE_PL_WORD=5 -SCE_PL_STRING=6 -SCE_PL_CHARACTER=7 -SCE_PL_PUNCTUATION=8 -SCE_PL_PREPROCESSOR=9 -SCE_PL_OPERATOR=10 -SCE_PL_IDENTIFIER=11 -SCE_PL_SCALAR=12 -SCE_PL_ARRAY=13 -SCE_PL_HASH=14 -SCE_PL_SYMBOLTABLE=15 -SCE_PL_VARIABLE_INDEXER=16 -SCE_PL_REGEX=17 -SCE_PL_REGSUBST=18 -SCE_PL_LONGQUOTE=19 -SCE_PL_BACKTICKS=20 -SCE_PL_DATASECTION=21 -SCE_PL_HERE_DELIM=22 -SCE_PL_HERE_Q=23 -SCE_PL_HERE_QQ=24 -SCE_PL_HERE_QX=25 -SCE_PL_STRING_Q=26 -SCE_PL_STRING_QQ=27 -SCE_PL_STRING_QX=28 -SCE_PL_STRING_QR=29 -SCE_PL_STRING_QW=30 -SCE_PL_POD_VERB=31 -SCE_PL_SUB_PROTOTYPE=40 -SCE_PL_FORMAT_IDENT=41 -SCE_PL_FORMAT=42 -SCE_PL_STRING_VAR=43 -SCE_PL_XLAT=44 -SCE_PL_REGEX_VAR=54 -SCE_PL_REGSUBST_VAR=55 -SCE_PL_BACKTICKS_VAR=57 -SCE_PL_HERE_QQ_VAR=61 -SCE_PL_HERE_QX_VAR=62 -SCE_PL_STRING_QQ_VAR=64 -SCE_PL_STRING_QX_VAR=65 -SCE_PL_STRING_QR_VAR=66 -SCE_RB_DEFAULT=0 -SCE_RB_ERROR=1 -SCE_RB_COMMENTLINE=2 -SCE_RB_POD=3 -SCE_RB_NUMBER=4 -SCE_RB_WORD=5 -SCE_RB_STRING=6 -SCE_RB_CHARACTER=7 -SCE_RB_CLASSNAME=8 -SCE_RB_DEFNAME=9 -SCE_RB_OPERATOR=10 -SCE_RB_IDENTIFIER=11 -SCE_RB_REGEX=12 -SCE_RB_GLOBAL=13 -SCE_RB_SYMBOL=14 -SCE_RB_MODULE_NAME=15 -SCE_RB_INSTANCE_VAR=16 -SCE_RB_CLASS_VAR=17 -SCE_RB_BACKTICKS=18 -SCE_RB_DATASECTION=19 -SCE_RB_HERE_DELIM=20 -SCE_RB_HERE_Q=21 -SCE_RB_HERE_QQ=22 -SCE_RB_HERE_QX=23 -SCE_RB_STRING_Q=24 -SCE_RB_STRING_QQ=25 -SCE_RB_STRING_QX=26 -SCE_RB_STRING_QR=27 -SCE_RB_STRING_QW=28 -SCE_RB_WORD_DEMOTED=29 -SCE_RB_STDIN=30 -SCE_RB_STDOUT=31 -SCE_RB_STDERR=40 -SCE_RB_UPPER_BOUND=41 -SCE_B_DEFAULT=0 -SCE_B_COMMENT=1 -SCE_B_NUMBER=2 -SCE_B_KEYWORD=3 -SCE_B_STRING=4 -SCE_B_PREPROCESSOR=5 -SCE_B_OPERATOR=6 -SCE_B_IDENTIFIER=7 -SCE_B_DATE=8 -SCE_B_STRINGEOL=9 -SCE_B_KEYWORD2=10 -SCE_B_KEYWORD3=11 -SCE_B_KEYWORD4=12 -SCE_B_CONSTANT=13 -SCE_B_ASM=14 -SCE_B_LABEL=15 -SCE_B_ERROR=16 -SCE_B_HEXNUMBER=17 -SCE_B_BINNUMBER=18 -SCE_B_COMMENTBLOCK=19 -SCE_B_DOCLINE=20 -SCE_B_DOCBLOCK=21 -SCE_B_DOCKEYWORD=22 -SCE_PROPS_DEFAULT=0 -SCE_PROPS_COMMENT=1 -SCE_PROPS_SECTION=2 -SCE_PROPS_ASSIGNMENT=3 -SCE_PROPS_DEFVAL=4 -SCE_PROPS_KEY=5 -SCE_L_DEFAULT=0 -SCE_L_COMMAND=1 -SCE_L_TAG=2 -SCE_L_MATH=3 -SCE_L_COMMENT=4 -SCE_L_TAG2=5 -SCE_L_MATH2=6 -SCE_L_COMMENT2=7 -SCE_L_VERBATIM=8 -SCE_L_SHORTCMD=9 -SCE_L_SPECIAL=10 -SCE_L_CMDOPT=11 -SCE_L_ERROR=12 -SCE_LUA_DEFAULT=0 -SCE_LUA_COMMENT=1 -SCE_LUA_COMMENTLINE=2 -SCE_LUA_COMMENTDOC=3 -SCE_LUA_NUMBER=4 -SCE_LUA_WORD=5 -SCE_LUA_STRING=6 -SCE_LUA_CHARACTER=7 -SCE_LUA_LITERALSTRING=8 -SCE_LUA_PREPROCESSOR=9 -SCE_LUA_OPERATOR=10 -SCE_LUA_IDENTIFIER=11 -SCE_LUA_STRINGEOL=12 -SCE_LUA_WORD2=13 -SCE_LUA_WORD3=14 -SCE_LUA_WORD4=15 -SCE_LUA_WORD5=16 -SCE_LUA_WORD6=17 -SCE_LUA_WORD7=18 -SCE_LUA_WORD8=19 -SCE_LUA_LABEL=20 -SCE_ERR_DEFAULT=0 -SCE_ERR_PYTHON=1 -SCE_ERR_GCC=2 -SCE_ERR_MS=3 -SCE_ERR_CMD=4 -SCE_ERR_BORLAND=5 -SCE_ERR_PERL=6 -SCE_ERR_NET=7 -SCE_ERR_LUA=8 -SCE_ERR_CTAG=9 -SCE_ERR_DIFF_CHANGED=10 -SCE_ERR_DIFF_ADDITION=11 -SCE_ERR_DIFF_DELETION=12 -SCE_ERR_DIFF_MESSAGE=13 -SCE_ERR_PHP=14 -SCE_ERR_ELF=15 -SCE_ERR_IFC=16 -SCE_ERR_IFORT=17 -SCE_ERR_ABSF=18 -SCE_ERR_TIDY=19 -SCE_ERR_JAVA_STACK=20 -SCE_ERR_VALUE=21 -SCE_ERR_GCC_INCLUDED_FROM=22 -SCE_BAT_DEFAULT=0 -SCE_BAT_COMMENT=1 -SCE_BAT_WORD=2 -SCE_BAT_LABEL=3 -SCE_BAT_HIDE=4 -SCE_BAT_COMMAND=5 -SCE_BAT_IDENTIFIER=6 -SCE_BAT_OPERATOR=7 -SCE_TCMD_DEFAULT=0 -SCE_TCMD_COMMENT=1 -SCE_TCMD_WORD=2 -SCE_TCMD_LABEL=3 -SCE_TCMD_HIDE=4 -SCE_TCMD_COMMAND=5 -SCE_TCMD_IDENTIFIER=6 -SCE_TCMD_OPERATOR=7 -SCE_TCMD_ENVIRONMENT=8 -SCE_TCMD_EXPANSION=9 -SCE_TCMD_CLABEL=10 -SCE_MAKE_DEFAULT=0 -SCE_MAKE_COMMENT=1 -SCE_MAKE_PREPROCESSOR=2 -SCE_MAKE_IDENTIFIER=3 -SCE_MAKE_OPERATOR=4 -SCE_MAKE_TARGET=5 -SCE_MAKE_IDEOL=9 -SCE_DIFF_DEFAULT=0 -SCE_DIFF_COMMENT=1 -SCE_DIFF_COMMAND=2 -SCE_DIFF_HEADER=3 -SCE_DIFF_POSITION=4 -SCE_DIFF_DELETED=5 -SCE_DIFF_ADDED=6 -SCE_DIFF_CHANGED=7 -SCE_CONF_DEFAULT=0 -SCE_CONF_COMMENT=1 -SCE_CONF_NUMBER=2 -SCE_CONF_IDENTIFIER=3 -SCE_CONF_EXTENSION=4 -SCE_CONF_PARAMETER=5 -SCE_CONF_STRING=6 -SCE_CONF_OPERATOR=7 -SCE_CONF_IP=8 -SCE_CONF_DIRECTIVE=9 -SCE_AVE_DEFAULT=0 -SCE_AVE_COMMENT=1 -SCE_AVE_NUMBER=2 -SCE_AVE_WORD=3 -SCE_AVE_STRING=6 -SCE_AVE_ENUM=7 -SCE_AVE_STRINGEOL=8 -SCE_AVE_IDENTIFIER=9 -SCE_AVE_OPERATOR=10 -SCE_AVE_WORD1=11 -SCE_AVE_WORD2=12 -SCE_AVE_WORD3=13 -SCE_AVE_WORD4=14 -SCE_AVE_WORD5=15 -SCE_AVE_WORD6=16 -SCE_ADA_DEFAULT=0 -SCE_ADA_WORD=1 -SCE_ADA_IDENTIFIER=2 -SCE_ADA_NUMBER=3 -SCE_ADA_DELIMITER=4 -SCE_ADA_CHARACTER=5 -SCE_ADA_CHARACTEREOL=6 -SCE_ADA_STRING=7 -SCE_ADA_STRINGEOL=8 -SCE_ADA_LABEL=9 -SCE_ADA_COMMENTLINE=10 -SCE_ADA_ILLEGAL=11 -SCE_BAAN_DEFAULT=0 -SCE_BAAN_COMMENT=1 -SCE_BAAN_COMMENTDOC=2 -SCE_BAAN_NUMBER=3 -SCE_BAAN_WORD=4 -SCE_BAAN_STRING=5 -SCE_BAAN_PREPROCESSOR=6 -SCE_BAAN_OPERATOR=7 -SCE_BAAN_IDENTIFIER=8 -SCE_BAAN_STRINGEOL=9 -SCE_BAAN_WORD2=10 -SCE_LISP_DEFAULT=0 -SCE_LISP_COMMENT=1 -SCE_LISP_NUMBER=2 -SCE_LISP_KEYWORD=3 -SCE_LISP_KEYWORD_KW=4 -SCE_LISP_SYMBOL=5 -SCE_LISP_STRING=6 -SCE_LISP_STRINGEOL=8 -SCE_LISP_IDENTIFIER=9 -SCE_LISP_OPERATOR=10 -SCE_LISP_SPECIAL=11 -SCE_LISP_MULTI_COMMENT=12 -SCE_EIFFEL_DEFAULT=0 -SCE_EIFFEL_COMMENTLINE=1 -SCE_EIFFEL_NUMBER=2 -SCE_EIFFEL_WORD=3 -SCE_EIFFEL_STRING=4 -SCE_EIFFEL_CHARACTER=5 -SCE_EIFFEL_OPERATOR=6 -SCE_EIFFEL_IDENTIFIER=7 -SCE_EIFFEL_STRINGEOL=8 -SCE_NNCRONTAB_DEFAULT=0 -SCE_NNCRONTAB_COMMENT=1 -SCE_NNCRONTAB_TASK=2 -SCE_NNCRONTAB_SECTION=3 -SCE_NNCRONTAB_KEYWORD=4 -SCE_NNCRONTAB_MODIFIER=5 -SCE_NNCRONTAB_ASTERISK=6 -SCE_NNCRONTAB_NUMBER=7 -SCE_NNCRONTAB_STRING=8 -SCE_NNCRONTAB_ENVIRONMENT=9 -SCE_NNCRONTAB_IDENTIFIER=10 -SCE_FORTH_DEFAULT=0 -SCE_FORTH_COMMENT=1 -SCE_FORTH_COMMENT_ML=2 -SCE_FORTH_IDENTIFIER=3 -SCE_FORTH_CONTROL=4 -SCE_FORTH_KEYWORD=5 -SCE_FORTH_DEFWORD=6 -SCE_FORTH_PREWORD1=7 -SCE_FORTH_PREWORD2=8 -SCE_FORTH_NUMBER=9 -SCE_FORTH_STRING=10 -SCE_FORTH_LOCALE=11 -SCE_MATLAB_DEFAULT=0 -SCE_MATLAB_COMMENT=1 -SCE_MATLAB_COMMAND=2 -SCE_MATLAB_NUMBER=3 -SCE_MATLAB_KEYWORD=4 -SCE_MATLAB_STRING=5 -SCE_MATLAB_OPERATOR=6 -SCE_MATLAB_IDENTIFIER=7 -SCE_MATLAB_DOUBLEQUOTESTRING=8 -SCE_SCRIPTOL_DEFAULT=0 -SCE_SCRIPTOL_WHITE=1 -SCE_SCRIPTOL_COMMENTLINE=2 -SCE_SCRIPTOL_PERSISTENT=3 -SCE_SCRIPTOL_CSTYLE=4 -SCE_SCRIPTOL_COMMENTBLOCK=5 -SCE_SCRIPTOL_NUMBER=6 -SCE_SCRIPTOL_STRING=7 -SCE_SCRIPTOL_CHARACTER=8 -SCE_SCRIPTOL_STRINGEOL=9 -SCE_SCRIPTOL_KEYWORD=10 -SCE_SCRIPTOL_OPERATOR=11 -SCE_SCRIPTOL_IDENTIFIER=12 -SCE_SCRIPTOL_TRIPLE=13 -SCE_SCRIPTOL_CLASSNAME=14 -SCE_SCRIPTOL_PREPROCESSOR=15 -SCE_ASM_DEFAULT=0 -SCE_ASM_COMMENT=1 -SCE_ASM_NUMBER=2 -SCE_ASM_STRING=3 -SCE_ASM_OPERATOR=4 -SCE_ASM_IDENTIFIER=5 -SCE_ASM_CPUINSTRUCTION=6 -SCE_ASM_MATHINSTRUCTION=7 -SCE_ASM_REGISTER=8 -SCE_ASM_DIRECTIVE=9 -SCE_ASM_DIRECTIVEOPERAND=10 -SCE_ASM_COMMENTBLOCK=11 -SCE_ASM_CHARACTER=12 -SCE_ASM_STRINGEOL=13 -SCE_ASM_EXTINSTRUCTION=14 -SCE_ASM_COMMENTDIRECTIVE=15 -SCE_F_DEFAULT=0 -SCE_F_COMMENT=1 -SCE_F_NUMBER=2 -SCE_F_STRING1=3 -SCE_F_STRING2=4 -SCE_F_STRINGEOL=5 -SCE_F_OPERATOR=6 -SCE_F_IDENTIFIER=7 -SCE_F_WORD=8 -SCE_F_WORD2=9 -SCE_F_WORD3=10 -SCE_F_PREPROCESSOR=11 -SCE_F_OPERATOR2=12 -SCE_F_LABEL=13 -SCE_F_CONTINUATION=14 -SCE_CSS_DEFAULT=0 -SCE_CSS_TAG=1 -SCE_CSS_CLASS=2 -SCE_CSS_PSEUDOCLASS=3 -SCE_CSS_UNKNOWN_PSEUDOCLASS=4 -SCE_CSS_OPERATOR=5 -SCE_CSS_IDENTIFIER=6 -SCE_CSS_UNKNOWN_IDENTIFIER=7 -SCE_CSS_VALUE=8 -SCE_CSS_COMMENT=9 -SCE_CSS_ID=10 -SCE_CSS_IMPORTANT=11 -SCE_CSS_DIRECTIVE=12 -SCE_CSS_DOUBLESTRING=13 -SCE_CSS_SINGLESTRING=14 -SCE_CSS_IDENTIFIER2=15 -SCE_CSS_ATTRIBUTE=16 -SCE_CSS_IDENTIFIER3=17 -SCE_CSS_PSEUDOELEMENT=18 -SCE_CSS_EXTENDED_IDENTIFIER=19 -SCE_CSS_EXTENDED_PSEUDOCLASS=20 -SCE_CSS_EXTENDED_PSEUDOELEMENT=21 -SCE_CSS_MEDIA=22 -SCE_CSS_VARIABLE=23 -SCE_POV_DEFAULT=0 -SCE_POV_COMMENT=1 -SCE_POV_COMMENTLINE=2 -SCE_POV_NUMBER=3 -SCE_POV_OPERATOR=4 -SCE_POV_IDENTIFIER=5 -SCE_POV_STRING=6 -SCE_POV_STRINGEOL=7 -SCE_POV_DIRECTIVE=8 -SCE_POV_BADDIRECTIVE=9 -SCE_POV_WORD2=10 -SCE_POV_WORD3=11 -SCE_POV_WORD4=12 -SCE_POV_WORD5=13 -SCE_POV_WORD6=14 -SCE_POV_WORD7=15 -SCE_POV_WORD8=16 -SCE_LOUT_DEFAULT=0 -SCE_LOUT_COMMENT=1 -SCE_LOUT_NUMBER=2 -SCE_LOUT_WORD=3 -SCE_LOUT_WORD2=4 -SCE_LOUT_WORD3=5 -SCE_LOUT_WORD4=6 -SCE_LOUT_STRING=7 -SCE_LOUT_OPERATOR=8 -SCE_LOUT_IDENTIFIER=9 -SCE_LOUT_STRINGEOL=10 -SCE_ESCRIPT_DEFAULT=0 -SCE_ESCRIPT_COMMENT=1 -SCE_ESCRIPT_COMMENTLINE=2 -SCE_ESCRIPT_COMMENTDOC=3 -SCE_ESCRIPT_NUMBER=4 -SCE_ESCRIPT_WORD=5 -SCE_ESCRIPT_STRING=6 -SCE_ESCRIPT_OPERATOR=7 -SCE_ESCRIPT_IDENTIFIER=8 -SCE_ESCRIPT_BRACE=9 -SCE_ESCRIPT_WORD2=10 -SCE_ESCRIPT_WORD3=11 -SCE_PS_DEFAULT=0 -SCE_PS_COMMENT=1 -SCE_PS_DSC_COMMENT=2 -SCE_PS_DSC_VALUE=3 -SCE_PS_NUMBER=4 -SCE_PS_NAME=5 -SCE_PS_KEYWORD=6 -SCE_PS_LITERAL=7 -SCE_PS_IMMEVAL=8 -SCE_PS_PAREN_ARRAY=9 -SCE_PS_PAREN_DICT=10 -SCE_PS_PAREN_PROC=11 -SCE_PS_TEXT=12 -SCE_PS_HEXSTRING=13 -SCE_PS_BASE85STRING=14 -SCE_PS_BADSTRINGCHAR=15 -SCE_NSIS_DEFAULT=0 -SCE_NSIS_COMMENT=1 -SCE_NSIS_STRINGDQ=2 -SCE_NSIS_STRINGLQ=3 -SCE_NSIS_STRINGRQ=4 -SCE_NSIS_FUNCTION=5 -SCE_NSIS_VARIABLE=6 -SCE_NSIS_LABEL=7 -SCE_NSIS_USERDEFINED=8 -SCE_NSIS_SECTIONDEF=9 -SCE_NSIS_SUBSECTIONDEF=10 -SCE_NSIS_IFDEFINEDEF=11 -SCE_NSIS_MACRODEF=12 -SCE_NSIS_STRINGVAR=13 -SCE_NSIS_NUMBER=14 -SCE_NSIS_SECTIONGROUP=15 -SCE_NSIS_PAGEEX=16 -SCE_NSIS_FUNCTIONDEF=17 -SCE_NSIS_COMMENTBOX=18 -SCE_MMIXAL_LEADWS=0 -SCE_MMIXAL_COMMENT=1 -SCE_MMIXAL_LABEL=2 -SCE_MMIXAL_OPCODE=3 -SCE_MMIXAL_OPCODE_PRE=4 -SCE_MMIXAL_OPCODE_VALID=5 -SCE_MMIXAL_OPCODE_UNKNOWN=6 -SCE_MMIXAL_OPCODE_POST=7 -SCE_MMIXAL_OPERANDS=8 -SCE_MMIXAL_NUMBER=9 -SCE_MMIXAL_REF=10 -SCE_MMIXAL_CHAR=11 -SCE_MMIXAL_STRING=12 -SCE_MMIXAL_REGISTER=13 -SCE_MMIXAL_HEX=14 -SCE_MMIXAL_OPERATOR=15 -SCE_MMIXAL_SYMBOL=16 -SCE_MMIXAL_INCLUDE=17 -SCE_CLW_DEFAULT=0 -SCE_CLW_LABEL=1 -SCE_CLW_COMMENT=2 -SCE_CLW_STRING=3 -SCE_CLW_USER_IDENTIFIER=4 -SCE_CLW_INTEGER_CONSTANT=5 -SCE_CLW_REAL_CONSTANT=6 -SCE_CLW_PICTURE_STRING=7 -SCE_CLW_KEYWORD=8 -SCE_CLW_COMPILER_DIRECTIVE=9 -SCE_CLW_RUNTIME_EXPRESSIONS=10 -SCE_CLW_BUILTIN_PROCEDURES_FUNCTION=11 -SCE_CLW_STRUCTURE_DATA_TYPE=12 -SCE_CLW_ATTRIBUTE=13 -SCE_CLW_STANDARD_EQUATE=14 -SCE_CLW_ERROR=15 -SCE_CLW_DEPRECATED=16 -SCE_LOT_DEFAULT=0 -SCE_LOT_HEADER=1 -SCE_LOT_BREAK=2 -SCE_LOT_SET=3 -SCE_LOT_PASS=4 -SCE_LOT_FAIL=5 -SCE_LOT_ABORT=6 -SCE_YAML_DEFAULT=0 -SCE_YAML_COMMENT=1 -SCE_YAML_IDENTIFIER=2 -SCE_YAML_KEYWORD=3 -SCE_YAML_NUMBER=4 -SCE_YAML_REFERENCE=5 -SCE_YAML_DOCUMENT=6 -SCE_YAML_TEXT=7 -SCE_YAML_ERROR=8 -SCE_YAML_OPERATOR=9 -SCE_TEX_DEFAULT=0 -SCE_TEX_SPECIAL=1 -SCE_TEX_GROUP=2 -SCE_TEX_SYMBOL=3 -SCE_TEX_COMMAND=4 -SCE_TEX_TEXT=5 -SCE_METAPOST_DEFAULT=0 -SCE_METAPOST_SPECIAL=1 -SCE_METAPOST_GROUP=2 -SCE_METAPOST_SYMBOL=3 -SCE_METAPOST_COMMAND=4 -SCE_METAPOST_TEXT=5 -SCE_METAPOST_EXTRA=6 -SCE_ERLANG_DEFAULT=0 -SCE_ERLANG_COMMENT=1 -SCE_ERLANG_VARIABLE=2 -SCE_ERLANG_NUMBER=3 -SCE_ERLANG_KEYWORD=4 -SCE_ERLANG_STRING=5 -SCE_ERLANG_OPERATOR=6 -SCE_ERLANG_ATOM=7 -SCE_ERLANG_FUNCTION_NAME=8 -SCE_ERLANG_CHARACTER=9 -SCE_ERLANG_MACRO=10 -SCE_ERLANG_RECORD=11 -SCE_ERLANG_PREPROC=12 -SCE_ERLANG_NODE_NAME=13 -SCE_ERLANG_COMMENT_FUNCTION=14 -SCE_ERLANG_COMMENT_MODULE=15 -SCE_ERLANG_COMMENT_DOC=16 -SCE_ERLANG_COMMENT_DOC_MACRO=17 -SCE_ERLANG_ATOM_QUOTED=18 -SCE_ERLANG_MACRO_QUOTED=19 -SCE_ERLANG_RECORD_QUOTED=20 -SCE_ERLANG_NODE_NAME_QUOTED=21 -SCE_ERLANG_BIFS=22 -SCE_ERLANG_MODULES=23 -SCE_ERLANG_MODULES_ATT=24 -SCE_ERLANG_UNKNOWN=31 -SCE_MSSQL_DEFAULT=0 -SCE_MSSQL_COMMENT=1 -SCE_MSSQL_LINE_COMMENT=2 -SCE_MSSQL_NUMBER=3 -SCE_MSSQL_STRING=4 -SCE_MSSQL_OPERATOR=5 -SCE_MSSQL_IDENTIFIER=6 -SCE_MSSQL_VARIABLE=7 -SCE_MSSQL_COLUMN_NAME=8 -SCE_MSSQL_STATEMENT=9 -SCE_MSSQL_DATATYPE=10 -SCE_MSSQL_SYSTABLE=11 -SCE_MSSQL_GLOBAL_VARIABLE=12 -SCE_MSSQL_FUNCTION=13 -SCE_MSSQL_STORED_PROCEDURE=14 -SCE_MSSQL_DEFAULT_PREF_DATATYPE=15 -SCE_MSSQL_COLUMN_NAME_2=16 -SCE_V_DEFAULT=0 -SCE_V_COMMENT=1 -SCE_V_COMMENTLINE=2 -SCE_V_COMMENTLINEBANG=3 -SCE_V_NUMBER=4 -SCE_V_WORD=5 -SCE_V_STRING=6 -SCE_V_WORD2=7 -SCE_V_WORD3=8 -SCE_V_PREPROCESSOR=9 -SCE_V_OPERATOR=10 -SCE_V_IDENTIFIER=11 -SCE_V_STRINGEOL=12 -SCE_V_USER=19 -SCE_V_COMMENT_WORD=20 -SCE_V_INPUT=21 -SCE_V_OUTPUT=22 -SCE_V_INOUT=23 -SCE_V_PORT_CONNECT=24 -SCE_KIX_DEFAULT=0 -SCE_KIX_COMMENT=1 -SCE_KIX_STRING1=2 -SCE_KIX_STRING2=3 -SCE_KIX_NUMBER=4 -SCE_KIX_VAR=5 -SCE_KIX_MACRO=6 -SCE_KIX_KEYWORD=7 -SCE_KIX_FUNCTIONS=8 -SCE_KIX_OPERATOR=9 -SCE_KIX_COMMENTSTREAM=10 -SCE_KIX_IDENTIFIER=31 -SCE_GC_DEFAULT=0 -SCE_GC_COMMENTLINE=1 -SCE_GC_COMMENTBLOCK=2 -SCE_GC_GLOBAL=3 -SCE_GC_EVENT=4 -SCE_GC_ATTRIBUTE=5 -SCE_GC_CONTROL=6 -SCE_GC_COMMAND=7 -SCE_GC_STRING=8 -SCE_GC_OPERATOR=9 -SCE_SN_DEFAULT=0 -SCE_SN_CODE=1 -SCE_SN_COMMENTLINE=2 -SCE_SN_COMMENTLINEBANG=3 -SCE_SN_NUMBER=4 -SCE_SN_WORD=5 -SCE_SN_STRING=6 -SCE_SN_WORD2=7 -SCE_SN_WORD3=8 -SCE_SN_PREPROCESSOR=9 -SCE_SN_OPERATOR=10 -SCE_SN_IDENTIFIER=11 -SCE_SN_STRINGEOL=12 -SCE_SN_REGEXTAG=13 -SCE_SN_SIGNAL=14 -SCE_SN_USER=19 -SCE_AU3_DEFAULT=0 -SCE_AU3_COMMENT=1 -SCE_AU3_COMMENTBLOCK=2 -SCE_AU3_NUMBER=3 -SCE_AU3_FUNCTION=4 -SCE_AU3_KEYWORD=5 -SCE_AU3_MACRO=6 -SCE_AU3_STRING=7 -SCE_AU3_OPERATOR=8 -SCE_AU3_VARIABLE=9 -SCE_AU3_SENT=10 -SCE_AU3_PREPROCESSOR=11 -SCE_AU3_SPECIAL=12 -SCE_AU3_EXPAND=13 -SCE_AU3_COMOBJ=14 -SCE_AU3_UDF=15 -SCE_APDL_DEFAULT=0 -SCE_APDL_COMMENT=1 -SCE_APDL_COMMENTBLOCK=2 -SCE_APDL_NUMBER=3 -SCE_APDL_STRING=4 -SCE_APDL_OPERATOR=5 -SCE_APDL_WORD=6 -SCE_APDL_PROCESSOR=7 -SCE_APDL_COMMAND=8 -SCE_APDL_SLASHCOMMAND=9 -SCE_APDL_STARCOMMAND=10 -SCE_APDL_ARGUMENT=11 -SCE_APDL_FUNCTION=12 -SCE_SH_DEFAULT=0 -SCE_SH_ERROR=1 -SCE_SH_COMMENTLINE=2 -SCE_SH_NUMBER=3 -SCE_SH_WORD=4 -SCE_SH_STRING=5 -SCE_SH_CHARACTER=6 -SCE_SH_OPERATOR=7 -SCE_SH_IDENTIFIER=8 -SCE_SH_SCALAR=9 -SCE_SH_PARAM=10 -SCE_SH_BACKTICKS=11 -SCE_SH_HERE_DELIM=12 -SCE_SH_HERE_Q=13 -SCE_ASN1_DEFAULT=0 -SCE_ASN1_COMMENT=1 -SCE_ASN1_IDENTIFIER=2 -SCE_ASN1_STRING=3 -SCE_ASN1_OID=4 -SCE_ASN1_SCALAR=5 -SCE_ASN1_KEYWORD=6 -SCE_ASN1_ATTRIBUTE=7 -SCE_ASN1_DESCRIPTOR=8 -SCE_ASN1_TYPE=9 -SCE_ASN1_OPERATOR=10 -SCE_VHDL_DEFAULT=0 -SCE_VHDL_COMMENT=1 -SCE_VHDL_COMMENTLINEBANG=2 -SCE_VHDL_NUMBER=3 -SCE_VHDL_STRING=4 -SCE_VHDL_OPERATOR=5 -SCE_VHDL_IDENTIFIER=6 -SCE_VHDL_STRINGEOL=7 -SCE_VHDL_KEYWORD=8 -SCE_VHDL_STDOPERATOR=9 -SCE_VHDL_ATTRIBUTE=10 -SCE_VHDL_STDFUNCTION=11 -SCE_VHDL_STDPACKAGE=12 -SCE_VHDL_STDTYPE=13 -SCE_VHDL_USERWORD=14 -SCE_VHDL_BLOCK_COMMENT=15 -SCE_CAML_DEFAULT=0 -SCE_CAML_IDENTIFIER=1 -SCE_CAML_TAGNAME=2 -SCE_CAML_KEYWORD=3 -SCE_CAML_KEYWORD2=4 -SCE_CAML_KEYWORD3=5 -SCE_CAML_LINENUM=6 -SCE_CAML_OPERATOR=7 -SCE_CAML_NUMBER=8 -SCE_CAML_CHAR=9 -SCE_CAML_WHITE=10 -SCE_CAML_STRING=11 -SCE_CAML_COMMENT=12 -SCE_CAML_COMMENT1=13 -SCE_CAML_COMMENT2=14 -SCE_CAML_COMMENT3=15 -SCE_HA_DEFAULT=0 -SCE_HA_IDENTIFIER=1 -SCE_HA_KEYWORD=2 -SCE_HA_NUMBER=3 -SCE_HA_STRING=4 -SCE_HA_CHARACTER=5 -SCE_HA_CLASS=6 -SCE_HA_MODULE=7 -SCE_HA_CAPITAL=8 -SCE_HA_DATA=9 -SCE_HA_IMPORT=10 -SCE_HA_OPERATOR=11 -SCE_HA_INSTANCE=12 -SCE_HA_COMMENTLINE=13 -SCE_HA_COMMENTBLOCK=14 -SCE_HA_COMMENTBLOCK2=15 -SCE_HA_COMMENTBLOCK3=16 -SCE_HA_PRAGMA=17 -SCE_HA_PREPROCESSOR=18 -SCE_HA_STRINGEOL=19 -SCE_HA_RESERVED_OPERATOR=20 -SCE_HA_LITERATE_COMMENT=21 -SCE_HA_LITERATE_CODEDELIM=22 -SCE_T3_DEFAULT=0 -SCE_T3_X_DEFAULT=1 -SCE_T3_PREPROCESSOR=2 -SCE_T3_BLOCK_COMMENT=3 -SCE_T3_LINE_COMMENT=4 -SCE_T3_OPERATOR=5 -SCE_T3_KEYWORD=6 -SCE_T3_NUMBER=7 -SCE_T3_IDENTIFIER=8 -SCE_T3_S_STRING=9 -SCE_T3_D_STRING=10 -SCE_T3_X_STRING=11 -SCE_T3_LIB_DIRECTIVE=12 -SCE_T3_MSG_PARAM=13 -SCE_T3_HTML_TAG=14 -SCE_T3_HTML_DEFAULT=15 -SCE_T3_HTML_STRING=16 -SCE_T3_USER1=17 -SCE_T3_USER2=18 -SCE_T3_USER3=19 -SCE_T3_BRACE=20 -SCE_REBOL_DEFAULT=0 -SCE_REBOL_COMMENTLINE=1 -SCE_REBOL_COMMENTBLOCK=2 -SCE_REBOL_PREFACE=3 -SCE_REBOL_OPERATOR=4 -SCE_REBOL_CHARACTER=5 -SCE_REBOL_QUOTEDSTRING=6 -SCE_REBOL_BRACEDSTRING=7 -SCE_REBOL_NUMBER=8 -SCE_REBOL_PAIR=9 -SCE_REBOL_TUPLE=10 -SCE_REBOL_BINARY=11 -SCE_REBOL_MONEY=12 -SCE_REBOL_ISSUE=13 -SCE_REBOL_TAG=14 -SCE_REBOL_FILE=15 -SCE_REBOL_EMAIL=16 -SCE_REBOL_URL=17 -SCE_REBOL_DATE=18 -SCE_REBOL_TIME=19 -SCE_REBOL_IDENTIFIER=20 -SCE_REBOL_WORD=21 -SCE_REBOL_WORD2=22 -SCE_REBOL_WORD3=23 -SCE_REBOL_WORD4=24 -SCE_REBOL_WORD5=25 -SCE_REBOL_WORD6=26 -SCE_REBOL_WORD7=27 -SCE_REBOL_WORD8=28 -SCE_SQL_DEFAULT=0 -SCE_SQL_COMMENT=1 -SCE_SQL_COMMENTLINE=2 -SCE_SQL_COMMENTDOC=3 -SCE_SQL_NUMBER=4 -SCE_SQL_WORD=5 -SCE_SQL_STRING=6 -SCE_SQL_CHARACTER=7 -SCE_SQL_SQLPLUS=8 -SCE_SQL_SQLPLUS_PROMPT=9 -SCE_SQL_OPERATOR=10 -SCE_SQL_IDENTIFIER=11 -SCE_SQL_SQLPLUS_COMMENT=13 -SCE_SQL_COMMENTLINEDOC=15 -SCE_SQL_WORD2=16 -SCE_SQL_COMMENTDOCKEYWORD=17 -SCE_SQL_COMMENTDOCKEYWORDERROR=18 -SCE_SQL_USER1=19 -SCE_SQL_USER2=20 -SCE_SQL_USER3=21 -SCE_SQL_USER4=22 -SCE_SQL_QUOTEDIDENTIFIER=23 -SCE_SQL_QOPERATOR=24 -SCE_ST_DEFAULT=0 -SCE_ST_STRING=1 -SCE_ST_NUMBER=2 -SCE_ST_COMMENT=3 -SCE_ST_SYMBOL=4 -SCE_ST_BINARY=5 -SCE_ST_BOOL=6 -SCE_ST_SELF=7 -SCE_ST_SUPER=8 -SCE_ST_NIL=9 -SCE_ST_GLOBAL=10 -SCE_ST_RETURN=11 -SCE_ST_SPECIAL=12 -SCE_ST_KWSEND=13 -SCE_ST_ASSIGN=14 -SCE_ST_CHARACTER=15 -SCE_ST_SPEC_SEL=16 -SCE_FS_DEFAULT=0 -SCE_FS_COMMENT=1 -SCE_FS_COMMENTLINE=2 -SCE_FS_COMMENTDOC=3 -SCE_FS_COMMENTLINEDOC=4 -SCE_FS_COMMENTDOCKEYWORD=5 -SCE_FS_COMMENTDOCKEYWORDERROR=6 -SCE_FS_KEYWORD=7 -SCE_FS_KEYWORD2=8 -SCE_FS_KEYWORD3=9 -SCE_FS_KEYWORD4=10 -SCE_FS_NUMBER=11 -SCE_FS_STRING=12 -SCE_FS_PREPROCESSOR=13 -SCE_FS_OPERATOR=14 -SCE_FS_IDENTIFIER=15 -SCE_FS_DATE=16 -SCE_FS_STRINGEOL=17 -SCE_FS_CONSTANT=18 -SCE_FS_WORDOPERATOR=19 -SCE_FS_DISABLEDCODE=20 -SCE_FS_DEFAULT_C=21 -SCE_FS_COMMENTDOC_C=22 -SCE_FS_COMMENTLINEDOC_C=23 -SCE_FS_KEYWORD_C=24 -SCE_FS_KEYWORD2_C=25 -SCE_FS_NUMBER_C=26 -SCE_FS_STRING_C=27 -SCE_FS_PREPROCESSOR_C=28 -SCE_FS_OPERATOR_C=29 -SCE_FS_IDENTIFIER_C=30 -SCE_FS_STRINGEOL_C=31 -SCE_CSOUND_DEFAULT=0 -SCE_CSOUND_COMMENT=1 -SCE_CSOUND_NUMBER=2 -SCE_CSOUND_OPERATOR=3 -SCE_CSOUND_INSTR=4 -SCE_CSOUND_IDENTIFIER=5 -SCE_CSOUND_OPCODE=6 -SCE_CSOUND_HEADERSTMT=7 -SCE_CSOUND_USERKEYWORD=8 -SCE_CSOUND_COMMENTBLOCK=9 -SCE_CSOUND_PARAM=10 -SCE_CSOUND_ARATE_VAR=11 -SCE_CSOUND_KRATE_VAR=12 -SCE_CSOUND_IRATE_VAR=13 -SCE_CSOUND_GLOBAL_VAR=14 -SCE_CSOUND_STRINGEOL=15 -SCE_INNO_DEFAULT=0 -SCE_INNO_COMMENT=1 -SCE_INNO_KEYWORD=2 -SCE_INNO_PARAMETER=3 -SCE_INNO_SECTION=4 -SCE_INNO_PREPROC=5 -SCE_INNO_INLINE_EXPANSION=6 -SCE_INNO_COMMENT_PASCAL=7 -SCE_INNO_KEYWORD_PASCAL=8 -SCE_INNO_KEYWORD_USER=9 -SCE_INNO_STRING_DOUBLE=10 -SCE_INNO_STRING_SINGLE=11 -SCE_INNO_IDENTIFIER=12 -SCE_OPAL_SPACE=0 -SCE_OPAL_COMMENT_BLOCK=1 -SCE_OPAL_COMMENT_LINE=2 -SCE_OPAL_INTEGER=3 -SCE_OPAL_KEYWORD=4 -SCE_OPAL_SORT=5 -SCE_OPAL_STRING=6 -SCE_OPAL_PAR=7 -SCE_OPAL_BOOL_CONST=8 -SCE_OPAL_DEFAULT=32 -SCE_SPICE_DEFAULT=0 -SCE_SPICE_IDENTIFIER=1 -SCE_SPICE_KEYWORD=2 -SCE_SPICE_KEYWORD2=3 -SCE_SPICE_KEYWORD3=4 -SCE_SPICE_NUMBER=5 -SCE_SPICE_DELIMITER=6 -SCE_SPICE_VALUE=7 -SCE_SPICE_COMMENTLINE=8 -SCE_CMAKE_DEFAULT=0 -SCE_CMAKE_COMMENT=1 -SCE_CMAKE_STRINGDQ=2 -SCE_CMAKE_STRINGLQ=3 -SCE_CMAKE_STRINGRQ=4 -SCE_CMAKE_COMMANDS=5 -SCE_CMAKE_PARAMETERS=6 -SCE_CMAKE_VARIABLE=7 -SCE_CMAKE_USERDEFINED=8 -SCE_CMAKE_WHILEDEF=9 -SCE_CMAKE_FOREACHDEF=10 -SCE_CMAKE_IFDEFINEDEF=11 -SCE_CMAKE_MACRODEF=12 -SCE_CMAKE_STRINGVAR=13 -SCE_CMAKE_NUMBER=14 -SCE_GAP_DEFAULT=0 -SCE_GAP_IDENTIFIER=1 -SCE_GAP_KEYWORD=2 -SCE_GAP_KEYWORD2=3 -SCE_GAP_KEYWORD3=4 -SCE_GAP_KEYWORD4=5 -SCE_GAP_STRING=6 -SCE_GAP_CHAR=7 -SCE_GAP_OPERATOR=8 -SCE_GAP_COMMENT=9 -SCE_GAP_NUMBER=10 -SCE_GAP_STRINGEOL=11 -SCE_PLM_DEFAULT=0 -SCE_PLM_COMMENT=1 -SCE_PLM_STRING=2 -SCE_PLM_NUMBER=3 -SCE_PLM_IDENTIFIER=4 -SCE_PLM_OPERATOR=5 -SCE_PLM_CONTROL=6 -SCE_PLM_KEYWORD=7 -SCE_4GL_DEFAULT=0 -SCE_4GL_NUMBER=1 -SCE_4GL_WORD=2 -SCE_4GL_STRING=3 -SCE_4GL_CHARACTER=4 -SCE_4GL_PREPROCESSOR=5 -SCE_4GL_OPERATOR=6 -SCE_4GL_IDENTIFIER=7 -SCE_4GL_BLOCK=8 -SCE_4GL_END=9 -SCE_4GL_COMMENT1=10 -SCE_4GL_COMMENT2=11 -SCE_4GL_COMMENT3=12 -SCE_4GL_COMMENT4=13 -SCE_4GL_COMMENT5=14 -SCE_4GL_COMMENT6=15 -SCE_4GL_DEFAULT_=16 -SCE_4GL_NUMBER_=17 -SCE_4GL_WORD_=18 -SCE_4GL_STRING_=19 -SCE_4GL_CHARACTER_=20 -SCE_4GL_PREPROCESSOR_=21 -SCE_4GL_OPERATOR_=22 -SCE_4GL_IDENTIFIER_=23 -SCE_4GL_BLOCK_=24 -SCE_4GL_END_=25 -SCE_4GL_COMMENT1_=26 -SCE_4GL_COMMENT2_=27 -SCE_4GL_COMMENT3_=28 -SCE_4GL_COMMENT4_=29 -SCE_4GL_COMMENT5_=30 -SCE_4GL_COMMENT6_=31 -SCE_ABAQUS_DEFAULT=0 -SCE_ABAQUS_COMMENT=1 -SCE_ABAQUS_COMMENTBLOCK=2 -SCE_ABAQUS_NUMBER=3 -SCE_ABAQUS_STRING=4 -SCE_ABAQUS_OPERATOR=5 -SCE_ABAQUS_WORD=6 -SCE_ABAQUS_PROCESSOR=7 -SCE_ABAQUS_COMMAND=8 -SCE_ABAQUS_SLASHCOMMAND=9 -SCE_ABAQUS_STARCOMMAND=10 -SCE_ABAQUS_ARGUMENT=11 -SCE_ABAQUS_FUNCTION=12 -SCE_ASY_DEFAULT=0 -SCE_ASY_COMMENT=1 -SCE_ASY_COMMENTLINE=2 -SCE_ASY_NUMBER=3 -SCE_ASY_WORD=4 -SCE_ASY_STRING=5 -SCE_ASY_CHARACTER=6 -SCE_ASY_OPERATOR=7 -SCE_ASY_IDENTIFIER=8 -SCE_ASY_STRINGEOL=9 -SCE_ASY_COMMENTLINEDOC=10 -SCE_ASY_WORD2=11 -SCE_R_DEFAULT=0 -SCE_R_COMMENT=1 -SCE_R_KWORD=2 -SCE_R_BASEKWORD=3 -SCE_R_OTHERKWORD=4 -SCE_R_NUMBER=5 -SCE_R_STRING=6 -SCE_R_STRING2=7 -SCE_R_OPERATOR=8 -SCE_R_IDENTIFIER=9 -SCE_R_INFIX=10 -SCE_R_INFIXEOL=11 -SCE_MAGIK_DEFAULT=0 -SCE_MAGIK_COMMENT=1 -SCE_MAGIK_HYPER_COMMENT=16 -SCE_MAGIK_STRING=2 -SCE_MAGIK_CHARACTER=3 -SCE_MAGIK_NUMBER=4 -SCE_MAGIK_IDENTIFIER=5 -SCE_MAGIK_OPERATOR=6 -SCE_MAGIK_FLOW=7 -SCE_MAGIK_CONTAINER=8 -SCE_MAGIK_BRACKET_BLOCK=9 -SCE_MAGIK_BRACE_BLOCK=10 -SCE_MAGIK_SQBRACKET_BLOCK=11 -SCE_MAGIK_UNKNOWN_KEYWORD=12 -SCE_MAGIK_KEYWORD=13 -SCE_MAGIK_PRAGMA=14 -SCE_MAGIK_SYMBOL=15 -SCE_POWERSHELL_DEFAULT=0 -SCE_POWERSHELL_COMMENT=1 -SCE_POWERSHELL_STRING=2 -SCE_POWERSHELL_CHARACTER=3 -SCE_POWERSHELL_NUMBER=4 -SCE_POWERSHELL_VARIABLE=5 -SCE_POWERSHELL_OPERATOR=6 -SCE_POWERSHELL_IDENTIFIER=7 -SCE_POWERSHELL_KEYWORD=8 -SCE_POWERSHELL_CMDLET=9 -SCE_POWERSHELL_ALIAS=10 -SCE_POWERSHELL_FUNCTION=11 -SCE_POWERSHELL_USER1=12 -SCE_POWERSHELL_COMMENTSTREAM=13 -SCE_POWERSHELL_HERE_STRING=14 -SCE_POWERSHELL_HERE_CHARACTER=15 -SCE_POWERSHELL_COMMENTDOCKEYWORD=16 -SCE_MYSQL_DEFAULT=0 -SCE_MYSQL_COMMENT=1 -SCE_MYSQL_COMMENTLINE=2 -SCE_MYSQL_VARIABLE=3 -SCE_MYSQL_SYSTEMVARIABLE=4 -SCE_MYSQL_KNOWNSYSTEMVARIABLE=5 -SCE_MYSQL_NUMBER=6 -SCE_MYSQL_MAJORKEYWORD=7 -SCE_MYSQL_KEYWORD=8 -SCE_MYSQL_DATABASEOBJECT=9 -SCE_MYSQL_PROCEDUREKEYWORD=10 -SCE_MYSQL_STRING=11 -SCE_MYSQL_SQSTRING=12 -SCE_MYSQL_DQSTRING=13 -SCE_MYSQL_OPERATOR=14 -SCE_MYSQL_FUNCTION=15 -SCE_MYSQL_IDENTIFIER=16 -SCE_MYSQL_QUOTEDIDENTIFIER=17 -SCE_MYSQL_USER1=18 -SCE_MYSQL_USER2=19 -SCE_MYSQL_USER3=20 -SCE_MYSQL_HIDDENCOMMAND=21 -SCE_MYSQL_PLACEHOLDER=22 -SCE_PO_DEFAULT=0 -SCE_PO_COMMENT=1 -SCE_PO_MSGID=2 -SCE_PO_MSGID_TEXT=3 -SCE_PO_MSGSTR=4 -SCE_PO_MSGSTR_TEXT=5 -SCE_PO_MSGCTXT=6 -SCE_PO_MSGCTXT_TEXT=7 -SCE_PO_FUZZY=8 -SCE_PO_PROGRAMMER_COMMENT=9 -SCE_PO_REFERENCE=10 -SCE_PO_FLAGS=11 -SCE_PO_MSGID_TEXT_EOL=12 -SCE_PO_MSGSTR_TEXT_EOL=13 -SCE_PO_MSGCTXT_TEXT_EOL=14 -SCE_PO_ERROR=15 -SCE_PAS_DEFAULT=0 -SCE_PAS_IDENTIFIER=1 -SCE_PAS_COMMENT=2 -SCE_PAS_COMMENT2=3 -SCE_PAS_COMMENTLINE=4 -SCE_PAS_PREPROCESSOR=5 -SCE_PAS_PREPROCESSOR2=6 -SCE_PAS_NUMBER=7 -SCE_PAS_HEXNUMBER=8 -SCE_PAS_WORD=9 -SCE_PAS_STRING=10 -SCE_PAS_STRINGEOL=11 -SCE_PAS_CHARACTER=12 -SCE_PAS_OPERATOR=13 -SCE_PAS_ASM=14 -SCE_SORCUS_DEFAULT=0 -SCE_SORCUS_COMMAND=1 -SCE_SORCUS_PARAMETER=2 -SCE_SORCUS_COMMENTLINE=3 -SCE_SORCUS_STRING=4 -SCE_SORCUS_STRINGEOL=5 -SCE_SORCUS_IDENTIFIER=6 -SCE_SORCUS_OPERATOR=7 -SCE_SORCUS_NUMBER=8 -SCE_SORCUS_CONSTANT=9 -SCE_POWERPRO_DEFAULT=0 -SCE_POWERPRO_COMMENTBLOCK=1 -SCE_POWERPRO_COMMENTLINE=2 -SCE_POWERPRO_NUMBER=3 -SCE_POWERPRO_WORD=4 -SCE_POWERPRO_WORD2=5 -SCE_POWERPRO_WORD3=6 -SCE_POWERPRO_WORD4=7 -SCE_POWERPRO_DOUBLEQUOTEDSTRING=8 -SCE_POWERPRO_SINGLEQUOTEDSTRING=9 -SCE_POWERPRO_LINECONTINUE=10 -SCE_POWERPRO_OPERATOR=11 -SCE_POWERPRO_IDENTIFIER=12 -SCE_POWERPRO_STRINGEOL=13 -SCE_POWERPRO_VERBATIM=14 -SCE_POWERPRO_ALTQUOTE=15 -SCE_POWERPRO_FUNCTION=16 -SCE_SML_DEFAULT=0 -SCE_SML_IDENTIFIER=1 -SCE_SML_TAGNAME=2 -SCE_SML_KEYWORD=3 -SCE_SML_KEYWORD2=4 -SCE_SML_KEYWORD3=5 -SCE_SML_LINENUM=6 -SCE_SML_OPERATOR=7 -SCE_SML_NUMBER=8 -SCE_SML_CHAR=9 -SCE_SML_STRING=11 -SCE_SML_COMMENT=12 -SCE_SML_COMMENT1=13 -SCE_SML_COMMENT2=14 -SCE_SML_COMMENT3=15 -SCE_MARKDOWN_DEFAULT=0 -SCE_MARKDOWN_LINE_BEGIN=1 -SCE_MARKDOWN_STRONG1=2 -SCE_MARKDOWN_STRONG2=3 -SCE_MARKDOWN_EM1=4 -SCE_MARKDOWN_EM2=5 -SCE_MARKDOWN_HEADER1=6 -SCE_MARKDOWN_HEADER2=7 -SCE_MARKDOWN_HEADER3=8 -SCE_MARKDOWN_HEADER4=9 -SCE_MARKDOWN_HEADER5=10 -SCE_MARKDOWN_HEADER6=11 -SCE_MARKDOWN_PRECHAR=12 -SCE_MARKDOWN_ULIST_ITEM=13 -SCE_MARKDOWN_OLIST_ITEM=14 -SCE_MARKDOWN_BLOCKQUOTE=15 -SCE_MARKDOWN_STRIKEOUT=16 -SCE_MARKDOWN_HRULE=17 -SCE_MARKDOWN_LINK=18 -SCE_MARKDOWN_CODE=19 -SCE_MARKDOWN_CODE2=20 -SCE_MARKDOWN_CODEBK=21 -SCE_TXT2TAGS_DEFAULT=0 -SCE_TXT2TAGS_LINE_BEGIN=1 -SCE_TXT2TAGS_STRONG1=2 -SCE_TXT2TAGS_STRONG2=3 -SCE_TXT2TAGS_EM1=4 -SCE_TXT2TAGS_EM2=5 -SCE_TXT2TAGS_HEADER1=6 -SCE_TXT2TAGS_HEADER2=7 -SCE_TXT2TAGS_HEADER3=8 -SCE_TXT2TAGS_HEADER4=9 -SCE_TXT2TAGS_HEADER5=10 -SCE_TXT2TAGS_HEADER6=11 -SCE_TXT2TAGS_PRECHAR=12 -SCE_TXT2TAGS_ULIST_ITEM=13 -SCE_TXT2TAGS_OLIST_ITEM=14 -SCE_TXT2TAGS_BLOCKQUOTE=15 -SCE_TXT2TAGS_STRIKEOUT=16 -SCE_TXT2TAGS_HRULE=17 -SCE_TXT2TAGS_LINK=18 -SCE_TXT2TAGS_CODE=19 -SCE_TXT2TAGS_CODE2=20 -SCE_TXT2TAGS_CODEBK=21 -SCE_TXT2TAGS_COMMENT=22 -SCE_TXT2TAGS_OPTION=23 -SCE_TXT2TAGS_PREPROC=24 -SCE_TXT2TAGS_POSTPROC=25 -SCE_A68K_DEFAULT=0 -SCE_A68K_COMMENT=1 -SCE_A68K_NUMBER_DEC=2 -SCE_A68K_NUMBER_BIN=3 -SCE_A68K_NUMBER_HEX=4 -SCE_A68K_STRING1=5 -SCE_A68K_OPERATOR=6 -SCE_A68K_CPUINSTRUCTION=7 -SCE_A68K_EXTINSTRUCTION=8 -SCE_A68K_REGISTER=9 -SCE_A68K_DIRECTIVE=10 -SCE_A68K_MACRO_ARG=11 -SCE_A68K_LABEL=12 -SCE_A68K_STRING2=13 -SCE_A68K_IDENTIFIER=14 -SCE_A68K_MACRO_DECLARATION=15 -SCE_A68K_COMMENT_WORD=16 -SCE_A68K_COMMENT_SPECIAL=17 -SCE_A68K_COMMENT_DOXYGEN=18 -SCE_MODULA_DEFAULT=0 -SCE_MODULA_COMMENT=1 -SCE_MODULA_DOXYCOMM=2 -SCE_MODULA_DOXYKEY=3 -SCE_MODULA_KEYWORD=4 -SCE_MODULA_RESERVED=5 -SCE_MODULA_NUMBER=6 -SCE_MODULA_BASENUM=7 -SCE_MODULA_FLOAT=8 -SCE_MODULA_STRING=9 -SCE_MODULA_STRSPEC=10 -SCE_MODULA_CHAR=11 -SCE_MODULA_CHARSPEC=12 -SCE_MODULA_PROC=13 -SCE_MODULA_PRAGMA=14 -SCE_MODULA_PRGKEY=15 -SCE_MODULA_OPERATOR=16 -SCE_MODULA_BADSTR=17 -SCE_COFFEESCRIPT_DEFAULT=0 -SCE_COFFEESCRIPT_COMMENT=1 -SCE_COFFEESCRIPT_COMMENTLINE=2 -SCE_COFFEESCRIPT_COMMENTDOC=3 -SCE_COFFEESCRIPT_NUMBER=4 -SCE_COFFEESCRIPT_WORD=5 -SCE_COFFEESCRIPT_STRING=6 -SCE_COFFEESCRIPT_CHARACTER=7 -SCE_COFFEESCRIPT_UUID=8 -SCE_COFFEESCRIPT_PREPROCESSOR=9 -SCE_COFFEESCRIPT_OPERATOR=10 -SCE_COFFEESCRIPT_IDENTIFIER=11 -SCE_COFFEESCRIPT_STRINGEOL=12 -SCE_COFFEESCRIPT_VERBATIM=13 -SCE_COFFEESCRIPT_REGEX=14 -SCE_COFFEESCRIPT_COMMENTLINEDOC=15 -SCE_COFFEESCRIPT_WORD2=16 -SCE_COFFEESCRIPT_COMMENTDOCKEYWORD=17 -SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR=18 -SCE_COFFEESCRIPT_GLOBALCLASS=19 -SCE_COFFEESCRIPT_STRINGRAW=20 -SCE_COFFEESCRIPT_TRIPLEVERBATIM=21 -SCE_COFFEESCRIPT_COMMENTBLOCK=22 -SCE_COFFEESCRIPT_VERBOSE_REGEX=23 -SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT=24 -SCE_AVS_DEFAULT=0 -SCE_AVS_COMMENTBLOCK=1 -SCE_AVS_COMMENTBLOCKN=2 -SCE_AVS_COMMENTLINE=3 -SCE_AVS_NUMBER=4 -SCE_AVS_OPERATOR=5 -SCE_AVS_IDENTIFIER=6 -SCE_AVS_STRING=7 -SCE_AVS_TRIPLESTRING=8 -SCE_AVS_KEYWORD=9 -SCE_AVS_FILTER=10 -SCE_AVS_PLUGIN=11 -SCE_AVS_FUNCTION=12 -SCE_AVS_CLIPPROP=13 -SCE_AVS_USERDFN=14 -SCE_ECL_DEFAULT=0 -SCE_ECL_COMMENT=1 -SCE_ECL_COMMENTLINE=2 -SCE_ECL_NUMBER=3 -SCE_ECL_STRING=4 -SCE_ECL_WORD0=5 -SCE_ECL_OPERATOR=6 -SCE_ECL_CHARACTER=7 -SCE_ECL_UUID=8 -SCE_ECL_PREPROCESSOR=9 -SCE_ECL_UNKNOWN=10 -SCE_ECL_IDENTIFIER=11 -SCE_ECL_STRINGEOL=12 -SCE_ECL_VERBATIM=13 -SCE_ECL_REGEX=14 -SCE_ECL_COMMENTLINEDOC=15 -SCE_ECL_WORD1=16 -SCE_ECL_COMMENTDOCKEYWORD=17 -SCE_ECL_COMMENTDOCKEYWORDERROR=18 -SCE_ECL_WORD2=19 -SCE_ECL_WORD3=20 -SCE_ECL_WORD4=21 -SCE_ECL_WORD5=22 -SCE_ECL_COMMENTDOC=23 -SCE_ECL_ADDED=24 -SCE_ECL_DELETED=25 -SCE_ECL_CHANGED=26 -SCE_ECL_MOVED=27 -SCE_OSCRIPT_DEFAULT=0 -SCE_OSCRIPT_LINE_COMMENT=1 -SCE_OSCRIPT_BLOCK_COMMENT=2 -SCE_OSCRIPT_DOC_COMMENT=3 -SCE_OSCRIPT_PREPROCESSOR=4 -SCE_OSCRIPT_NUMBER=5 -SCE_OSCRIPT_SINGLEQUOTE_STRING=6 -SCE_OSCRIPT_DOUBLEQUOTE_STRING=7 -SCE_OSCRIPT_CONSTANT=8 -SCE_OSCRIPT_IDENTIFIER=9 -SCE_OSCRIPT_GLOBAL=10 -SCE_OSCRIPT_KEYWORD=11 -SCE_OSCRIPT_OPERATOR=12 -SCE_OSCRIPT_LABEL=13 -SCE_OSCRIPT_TYPE=14 -SCE_OSCRIPT_FUNCTION=15 -SCE_OSCRIPT_OBJECT=16 -SCE_OSCRIPT_PROPERTY=17 -SCE_OSCRIPT_METHOD=18 -SCE_VISUALPROLOG_DEFAULT=0 -SCE_VISUALPROLOG_KEY_MAJOR=1 -SCE_VISUALPROLOG_KEY_MINOR=2 -SCE_VISUALPROLOG_KEY_DIRECTIVE=3 -SCE_VISUALPROLOG_COMMENT_BLOCK=4 -SCE_VISUALPROLOG_COMMENT_LINE=5 -SCE_VISUALPROLOG_COMMENT_KEY=6 -SCE_VISUALPROLOG_COMMENT_KEY_ERROR=7 -SCE_VISUALPROLOG_IDENTIFIER=8 -SCE_VISUALPROLOG_VARIABLE=9 -SCE_VISUALPROLOG_ANONYMOUS=10 -SCE_VISUALPROLOG_NUMBER=11 -SCE_VISUALPROLOG_OPERATOR=12 -SCE_VISUALPROLOG_CHARACTER=13 -SCE_VISUALPROLOG_CHARACTER_TOO_MANY=14 -SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR=15 -SCE_VISUALPROLOG_STRING=16 -SCE_VISUALPROLOG_STRING_ESCAPE=17 -SCE_VISUALPROLOG_STRING_ESCAPE_ERROR=18 -SCE_VISUALPROLOG_STRING_EOL_OPEN=19 -SCE_VISUALPROLOG_STRING_VERBATIM=20 -SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL=21 -SCE_VISUALPROLOG_STRING_VERBATIM_EOL=22 -SCE_STTXT_DEFAULT=0 -SCE_STTXT_COMMENT=1 -SCE_STTXT_COMMENTLINE=2 -SCE_STTXT_KEYWORD=3 -SCE_STTXT_TYPE=4 -SCE_STTXT_FUNCTION=5 -SCE_STTXT_FB=6 -SCE_STTXT_NUMBER=7 -SCE_STTXT_HEXNUMBER=8 -SCE_STTXT_PRAGMA=9 -SCE_STTXT_OPERATOR=10 -SCE_STTXT_CHARACTER=11 -SCE_STTXT_STRING1=12 -SCE_STTXT_STRING2=13 -SCE_STTXT_STRINGEOL=14 -SCE_STTXT_IDENTIFIER=15 -SCE_STTXT_DATETIME=16 -SCE_STTXT_VARS=17 -SCE_STTXT_PRAGMAS=18 -SCE_KVIRC_DEFAULT=0 -SCE_KVIRC_COMMENT=1 -SCE_KVIRC_COMMENTBLOCK=2 -SCE_KVIRC_STRING=3 -SCE_KVIRC_WORD=4 -SCE_KVIRC_KEYWORD=5 -SCE_KVIRC_FUNCTION_KEYWORD=6 -SCE_KVIRC_FUNCTION=7 -SCE_KVIRC_VARIABLE=8 -SCE_KVIRC_NUMBER=9 -SCE_KVIRC_OPERATOR=10 -SCE_KVIRC_STRING_FUNCTION=11 -SCE_KVIRC_STRING_VARIABLE=12 -SCE_RUST_DEFAULT=0 -SCE_RUST_COMMENTBLOCK=1 -SCE_RUST_COMMENTLINE=2 -SCE_RUST_COMMENTBLOCKDOC=3 -SCE_RUST_COMMENTLINEDOC=4 -SCE_RUST_NUMBER=5 -SCE_RUST_WORD=6 -SCE_RUST_WORD2=7 -SCE_RUST_WORD3=8 -SCE_RUST_WORD4=9 -SCE_RUST_WORD5=10 -SCE_RUST_WORD6=11 -SCE_RUST_WORD7=12 -SCE_RUST_STRING=13 -SCE_RUST_STRINGR=14 -SCE_RUST_CHARACTER=15 -SCE_RUST_OPERATOR=16 -SCE_RUST_IDENTIFIER=17 -SCE_RUST_LIFETIME=18 -SCE_RUST_MACRO=19 -SCE_RUST_LEXERROR=20 -SCE_RUST_BYTESTRING=21 -SCE_RUST_BYTESTRINGR=22 -SCE_RUST_BYTECHARACTER=23 -SCE_DMAP_DEFAULT=0 -SCE_DMAP_COMMENT=1 -SCE_DMAP_NUMBER=2 -SCE_DMAP_STRING1=3 -SCE_DMAP_STRING2=4 -SCE_DMAP_STRINGEOL=5 -SCE_DMAP_OPERATOR=6 -SCE_DMAP_IDENTIFIER=7 -SCE_DMAP_WORD=8 -SCE_DMAP_WORD2=9 -SCE_DMAP_WORD3=10 -SCE_DMIS_DEFAULT=0 -SCE_DMIS_COMMENT=1 -SCE_DMIS_STRING=2 -SCE_DMIS_NUMBER=3 -SCE_DMIS_KEYWORD=4 -SCE_DMIS_MAJORWORD=5 -SCE_DMIS_MINORWORD=6 -SCE_DMIS_UNSUPPORTED_MAJOR=7 -SCE_DMIS_UNSUPPORTED_MINOR=8 -SCE_DMIS_LABEL=9 -SCE_REG_DEFAULT=0 -SCE_REG_COMMENT=1 -SCE_REG_VALUENAME=2 -SCE_REG_STRING=3 -SCE_REG_HEXDIGIT=4 -SCE_REG_VALUETYPE=5 -SCE_REG_ADDEDKEY=6 -SCE_REG_DELETEDKEY=7 -SCE_REG_ESCAPED=8 -SCE_REG_KEYPATH_GUID=9 -SCE_REG_STRING_GUID=10 -SCE_REG_PARAMETER=11 -SCE_REG_OPERATOR=12 -SCE_BIBTEX_DEFAULT=0 -SCE_BIBTEX_ENTRY=1 -SCE_BIBTEX_UNKNOWN_ENTRY=2 -SCE_BIBTEX_KEY=3 -SCE_BIBTEX_PARAMETER=4 -SCE_BIBTEX_VALUE=5 -SCE_BIBTEX_COMMENT=6 -SCE_HEX_DEFAULT=0 -SCE_HEX_RECSTART=1 -SCE_HEX_RECTYPE=2 -SCE_HEX_RECTYPE_UNKNOWN=3 -SCE_HEX_BYTECOUNT=4 -SCE_HEX_BYTECOUNT_WRONG=5 -SCE_HEX_NOADDRESS=6 -SCE_HEX_DATAADDRESS=7 -SCE_HEX_RECCOUNT=8 -SCE_HEX_STARTADDRESS=9 -SCE_HEX_ADDRESSFIELD_UNKNOWN=10 -SCE_HEX_EXTENDEDADDRESS=11 -SCE_HEX_DATA_ODD=12 -SCE_HEX_DATA_EVEN=13 -SCE_HEX_DATA_UNKNOWN=14 -SCE_HEX_DATA_EMPTY=15 -SCE_HEX_CHECKSUM=16 -SCE_HEX_CHECKSUM_WRONG=17 -SCE_HEX_GARBAGE=18 -SCN_STYLENEEDED=2000 -SCN_CHARADDED=2001 -SCN_SAVEPOINTREACHED=2002 -SCN_SAVEPOINTLEFT=2003 -SCN_MODIFYATTEMPTRO=2004 -SCN_KEY=2005 -SCN_DOUBLECLICK=2006 -SCN_UPDATEUI=2007 -SCN_MODIFIED=2008 -SCN_MACRORECORD=2009 -SCN_MARGINCLICK=2010 -SCN_NEEDSHOWN=2011 -SCN_PAINTED=2013 -SCN_USERLISTSELECTION=2014 -SCN_URIDROPPED=2015 -SCN_DWELLSTART=2016 -SCN_DWELLEND=2017 -SCN_ZOOM=2018 -SCN_HOTSPOTCLICK=2019 -SCN_HOTSPOTDOUBLECLICK=2020 -SCN_CALLTIPCLICK=2021 -SCN_AUTOCSELECTION=2022 -SCN_INDICATORCLICK=2023 -SCN_INDICATORRELEASE=2024 -SCN_AUTOCCANCELLED=2025 -SCN_AUTOCCHARDELETED=2026 -SCN_HOTSPOTRELEASECLICK=2027 -SCN_FOCUSIN=2028 -SCN_FOCUSOUT=2029 -SCN_AUTOCCOMPLETED=2030 -# --Autogenerated -- end of section automatically generated from Scintilla.iface */ diff --git a/dep/scintilla/scintilla-3.6.0/scripts/Face.pyc b/dep/scintilla/scintilla-3.6.0/scripts/Face.pyc deleted file mode 100644 index a9213a64..00000000 Binary files a/dep/scintilla/scintilla-3.6.0/scripts/Face.pyc and /dev/null differ diff --git a/dep/scintilla/scintilla-3.6.0/scripts/FileGenerator.pyc b/dep/scintilla/scintilla-3.6.0/scripts/FileGenerator.pyc deleted file mode 100644 index b30013a2..00000000 Binary files a/dep/scintilla/scintilla-3.6.0/scripts/FileGenerator.pyc and /dev/null differ diff --git a/dep/scintilla/scintilla-3.6.0/scripts/LexGen.py b/dep/scintilla/scintilla-3.6.0/scripts/LexGen.py deleted file mode 100755 index f2496be2..00000000 --- a/dep/scintilla/scintilla-3.6.0/scripts/LexGen.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# LexGen.py - implemented 2002 by Neil Hodgson neilh@scintilla.org -# Released to the public domain. - -# Regenerate the Scintilla source files that list all the lexers. -# Should be run whenever a new lexer is added or removed. -# Requires Python 2.5 or later -# Files are regenerated in place with templates stored in comments. -# The format of generation comments is documented in FileGenerator.py. - -from FileGenerator import Regenerate, UpdateLineInFile, ReplaceREInFile -import ScintillaData -import HFacer - -def UpdateVersionNumbers(sci, root): - UpdateLineInFile(root + "win32/ScintRes.rc", "#define VERSION_SCINTILLA", - "#define VERSION_SCINTILLA \"" + sci.versionDotted + "\"") - UpdateLineInFile(root + "win32/ScintRes.rc", "#define VERSION_WORDS", - "#define VERSION_WORDS " + sci.versionCommad) - UpdateLineInFile(root + "qt/ScintillaEditBase/ScintillaEditBase.pro", - "VERSION =", - "VERSION = " + sci.versionDotted) - UpdateLineInFile(root + "qt/ScintillaEdit/ScintillaEdit.pro", - "VERSION =", - "VERSION = " + sci.versionDotted) - UpdateLineInFile(root + "doc/ScintillaDownload.html", " Release", - " Release " + sci.versionDotted) - ReplaceREInFile(root + "doc/ScintillaDownload.html", - r"/www.scintilla.org/([a-zA-Z]+)\d\d\d", - r"/www.scintilla.org/\g<1>" + sci.version) - UpdateLineInFile(root + "doc/index.html", - ' Release version', - ' Release version ' +\ - sci.versionDotted + '
    ') - UpdateLineInFile(root + "doc/index.html", - ' Site last modified', - ' Site last modified ' + sci.mdyModified + '
    ') - UpdateLineInFile(root + "doc/ScintillaHistory.html", - ' Released ', - ' Released ' + sci.dmyModified + '.') - -def RegenerateAll(root): - - sci = ScintillaData.ScintillaData(root) - - Regenerate(root + "src/Catalogue.cxx", "//", sci.lexerModules) - Regenerate(root + "win32/scintilla.mak", "#", sci.lexFiles) - - UpdateVersionNumbers(sci, root) - - HFacer.RegenerateAll(root, False) - -if __name__=="__main__": - RegenerateAll("../") diff --git a/dep/scintilla/scintilla-3.6.0/src/CellBuffer.cxx b/dep/scintilla/scintilla-3.6.0/src/CellBuffer.cxx deleted file mode 100644 index 491db403..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/CellBuffer.cxx +++ /dev/null @@ -1,820 +0,0 @@ -// Scintilla source code edit control -/** @file CellBuffer.cxx - ** Manages a buffer of cells. - **/ -// Copyright 1998-2001 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#include -#include -#include -#include - -#include -#include - -#include "Platform.h" - -#include "Scintilla.h" -#include "Position.h" -#include "SplitVector.h" -#include "Partitioning.h" -#include "CellBuffer.h" -#include "UniConversion.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -LineVector::LineVector() : starts(256), perLine(0) { - Init(); -} - -LineVector::~LineVector() { - starts.DeleteAll(); -} - -void LineVector::Init() { - starts.DeleteAll(); - if (perLine) { - perLine->Init(); - } -} - -void LineVector::SetPerLine(PerLine *pl) { - perLine = pl; -} - -void LineVector::InsertText(int line, int delta) { - starts.InsertText(line, delta); -} - -void LineVector::InsertLine(int line, int position, bool lineStart) { - starts.InsertPartition(line, position); - if (perLine) { - if ((line > 0) && lineStart) - line--; - perLine->InsertLine(line); - } -} - -void LineVector::SetLineStart(int line, int position) { - starts.SetPartitionStartPosition(line, position); -} - -void LineVector::RemoveLine(int line) { - starts.RemovePartition(line); - if (perLine) { - perLine->RemoveLine(line); - } -} - -int LineVector::LineFromPosition(int pos) const { - return starts.PartitionFromPosition(pos); -} - -Action::Action() { - at = startAction; - position = 0; - data = 0; - lenData = 0; - mayCoalesce = false; -} - -Action::~Action() { - Destroy(); -} - -void Action::Create(actionType at_, int position_, const char *data_, int lenData_, bool mayCoalesce_) { - delete []data; - data = NULL; - position = position_; - at = at_; - if (lenData_) { - data = new char[lenData_]; - memcpy(data, data_, lenData_); - } - lenData = lenData_; - mayCoalesce = mayCoalesce_; -} - -void Action::Destroy() { - delete []data; - data = 0; -} - -void Action::Grab(Action *source) { - delete []data; - - position = source->position; - at = source->at; - data = source->data; - lenData = source->lenData; - mayCoalesce = source->mayCoalesce; - - // Ownership of source data transferred to this - source->position = 0; - source->at = startAction; - source->data = 0; - source->lenData = 0; - source->mayCoalesce = true; -} - -// The undo history stores a sequence of user operations that represent the user's view of the -// commands executed on the text. -// Each user operation contains a sequence of text insertion and text deletion actions. -// All the user operations are stored in a list of individual actions with 'start' actions used -// as delimiters between user operations. -// Initially there is one start action in the history. -// As each action is performed, it is recorded in the history. The action may either become -// part of the current user operation or may start a new user operation. If it is to be part of the -// current operation, then it overwrites the current last action. If it is to be part of a new -// operation, it is appended after the current last action. -// After writing the new action, a new start action is appended at the end of the history. -// The decision of whether to start a new user operation is based upon two factors. If a -// compound operation has been explicitly started by calling BeginUndoAction and no matching -// EndUndoAction (these calls nest) has been called, then the action is coalesced into the current -// operation. If there is no outstanding BeginUndoAction call then a new operation is started -// unless it looks as if the new action is caused by the user typing or deleting a stream of text. -// Sequences that look like typing or deletion are coalesced into a single user operation. - -UndoHistory::UndoHistory() { - - lenActions = 100; - actions = new Action[lenActions]; - maxAction = 0; - currentAction = 0; - undoSequenceDepth = 0; - savePoint = 0; - tentativePoint = -1; - - actions[currentAction].Create(startAction); -} - -UndoHistory::~UndoHistory() { - delete []actions; - actions = 0; -} - -void UndoHistory::EnsureUndoRoom() { - // Have to test that there is room for 2 more actions in the array - // as two actions may be created by the calling function - if (currentAction >= (lenActions - 2)) { - // Run out of undo nodes so extend the array - int lenActionsNew = lenActions * 2; - Action *actionsNew = new Action[lenActionsNew]; - for (int act = 0; act <= currentAction; act++) - actionsNew[act].Grab(&actions[act]); - delete []actions; - lenActions = lenActionsNew; - actions = actionsNew; - } -} - -const char *UndoHistory::AppendAction(actionType at, int position, const char *data, int lengthData, - bool &startSequence, bool mayCoalesce) { - EnsureUndoRoom(); - //Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction); - //Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at, - // actions[currentAction - 1].position, actions[currentAction - 1].lenData); - if (currentAction < savePoint) { - savePoint = -1; - } - int oldCurrentAction = currentAction; - if (currentAction >= 1) { - if (0 == undoSequenceDepth) { - // Top level actions may not always be coalesced - int targetAct = -1; - const Action *actPrevious = &(actions[currentAction + targetAct]); - // Container actions may forward the coalesce state of Scintilla Actions. - while ((actPrevious->at == containerAction) && actPrevious->mayCoalesce) { - targetAct--; - actPrevious = &(actions[currentAction + targetAct]); - } - // See if current action can be coalesced into previous action - // Will work if both are inserts or deletes and position is same -#if defined(_MSC_VER) && defined(_PREFAST_) - // Visual Studio 2013 Code Analysis wrongly believes actions can be NULL at its next reference - __analysis_assume(actions); -#endif - if ((currentAction == savePoint) || (currentAction == tentativePoint)) { - currentAction++; - } else if (!actions[currentAction].mayCoalesce) { - // Not allowed to coalesce if this set - currentAction++; - } else if (!mayCoalesce || !actPrevious->mayCoalesce) { - currentAction++; - } else if (at == containerAction || actions[currentAction].at == containerAction) { - ; // A coalescible containerAction - } else if ((at != actPrevious->at) && (actPrevious->at != startAction)) { - currentAction++; - } else if ((at == insertAction) && - (position != (actPrevious->position + actPrevious->lenData))) { - // Insertions must be immediately after to coalesce - currentAction++; - } else if (at == removeAction) { - if ((lengthData == 1) || (lengthData == 2)) { - if ((position + lengthData) == actPrevious->position) { - ; // Backspace -> OK - } else if (position == actPrevious->position) { - ; // Delete -> OK - } else { - // Removals must be at same position to coalesce - currentAction++; - } - } else { - // Removals must be of one character to coalesce - currentAction++; - } - } else { - // Action coalesced. - } - - } else { - // Actions not at top level are always coalesced unless this is after return to top level - if (!actions[currentAction].mayCoalesce) - currentAction++; - } - } else { - currentAction++; - } - startSequence = oldCurrentAction != currentAction; - int actionWithData = currentAction; - actions[currentAction].Create(at, position, data, lengthData, mayCoalesce); - currentAction++; - actions[currentAction].Create(startAction); - maxAction = currentAction; - return actions[actionWithData].data; -} - -void UndoHistory::BeginUndoAction() { - EnsureUndoRoom(); - if (undoSequenceDepth == 0) { - if (actions[currentAction].at != startAction) { - currentAction++; - actions[currentAction].Create(startAction); - maxAction = currentAction; - } - actions[currentAction].mayCoalesce = false; - } - undoSequenceDepth++; -} - -void UndoHistory::EndUndoAction() { - PLATFORM_ASSERT(undoSequenceDepth > 0); - EnsureUndoRoom(); - undoSequenceDepth--; - if (0 == undoSequenceDepth) { - if (actions[currentAction].at != startAction) { - currentAction++; - actions[currentAction].Create(startAction); - maxAction = currentAction; - } - actions[currentAction].mayCoalesce = false; - } -} - -void UndoHistory::DropUndoSequence() { - undoSequenceDepth = 0; -} - -void UndoHistory::DeleteUndoHistory() { - for (int i = 1; i < maxAction; i++) - actions[i].Destroy(); - maxAction = 0; - currentAction = 0; - actions[currentAction].Create(startAction); - savePoint = 0; - tentativePoint = -1; -} - -void UndoHistory::SetSavePoint() { - savePoint = currentAction; -} - -bool UndoHistory::IsSavePoint() const { - return savePoint == currentAction; -} - -void UndoHistory::TentativeStart() { - tentativePoint = currentAction; -} - -void UndoHistory::TentativeCommit() { - tentativePoint = -1; - // Truncate undo history - maxAction = currentAction; -} - -int UndoHistory::TentativeSteps() { - // Drop any trailing startAction - if (actions[currentAction].at == startAction && currentAction > 0) - currentAction--; - if (tentativePoint >= 0) - return currentAction - tentativePoint; - else - return -1; -} - -bool UndoHistory::CanUndo() const { - return (currentAction > 0) && (maxAction > 0); -} - -int UndoHistory::StartUndo() { - // Drop any trailing startAction - if (actions[currentAction].at == startAction && currentAction > 0) - currentAction--; - - // Count the steps in this action - int act = currentAction; - while (actions[act].at != startAction && act > 0) { - act--; - } - return currentAction - act; -} - -const Action &UndoHistory::GetUndoStep() const { - return actions[currentAction]; -} - -void UndoHistory::CompletedUndoStep() { - currentAction--; -} - -bool UndoHistory::CanRedo() const { - return maxAction > currentAction; -} - -int UndoHistory::StartRedo() { - // Drop any leading startAction - if (actions[currentAction].at == startAction && currentAction < maxAction) - currentAction++; - - // Count the steps in this action - int act = currentAction; - while (actions[act].at != startAction && act < maxAction) { - act++; - } - return act - currentAction; -} - -const Action &UndoHistory::GetRedoStep() const { - return actions[currentAction]; -} - -void UndoHistory::CompletedRedoStep() { - currentAction++; -} - -CellBuffer::CellBuffer() { - readOnly = false; - utf8LineEnds = 0; - collectingUndo = true; -} - -CellBuffer::~CellBuffer() { -} - -char CellBuffer::CharAt(int position) const { - return substance.ValueAt(position); -} - -void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) const { - if (lengthRetrieve <= 0) - return; - if (position < 0) - return; - if ((position + lengthRetrieve) > substance.Length()) { - Platform::DebugPrintf("Bad GetCharRange %d for %d of %d\n", position, - lengthRetrieve, substance.Length()); - return; - } - substance.GetRange(buffer, position, lengthRetrieve); -} - -char CellBuffer::StyleAt(int position) const { - return style.ValueAt(position); -} - -void CellBuffer::GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const { - if (lengthRetrieve < 0) - return; - if (position < 0) - return; - if ((position + lengthRetrieve) > style.Length()) { - Platform::DebugPrintf("Bad GetStyleRange %d for %d of %d\n", position, - lengthRetrieve, style.Length()); - return; - } - style.GetRange(reinterpret_cast(buffer), position, lengthRetrieve); -} - -const char *CellBuffer::BufferPointer() { - return substance.BufferPointer(); -} - -const char *CellBuffer::RangePointer(int position, int rangeLength) { - return substance.RangePointer(position, rangeLength); -} - -int CellBuffer::GapPosition() const { - return substance.GapPosition(); -} - -// 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) { - // InsertString and DeleteChars are the bottleneck though which all changes occur - const char *data = s; - 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 = uh.AppendAction(insertAction, position, s, insertLength, startSequence); - } - - BasicInsertString(position, s, insertLength); - } - return data; -} - -bool CellBuffer::SetStyleAt(int position, char styleValue) { - char curVal = style.ValueAt(position); - if (curVal != styleValue) { - style.SetValueAt(position, styleValue); - return true; - } else { - return false; - } -} - -bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue) { - bool changed = false; - PLATFORM_ASSERT(lengthStyle == 0 || - (lengthStyle > 0 && lengthStyle + position <= style.Length())); - while (lengthStyle--) { - char curVal = style.ValueAt(position); - if (curVal != styleValue) { - style.SetValueAt(position, styleValue); - changed = true; - } - position++; - } - return changed; -} - -// 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); - const char *data = 0; - if (!readOnly) { - if (collectingUndo) { - // Save into the undo/redo stack, but only the characters - not the formatting - // The gap would be moved to position anyway for the deletion so this doesn't cost extra - data = substance.RangePointer(position, deleteLength); - data = uh.AppendAction(removeAction, position, data, deleteLength, startSequence); - } - - BasicDeleteChars(position, deleteLength); - } - return data; -} - -int CellBuffer::Length() const { - return substance.Length(); -} - -void CellBuffer::Allocate(int newSize) { - substance.ReAllocate(newSize); - style.ReAllocate(newSize); -} - -void CellBuffer::SetLineEndTypes(int utf8LineEnds_) { - if (utf8LineEnds != utf8LineEnds_) { - utf8LineEnds = utf8LineEnds_; - ResetLineEnds(); - } -} - -void CellBuffer::SetPerLine(PerLine *pl) { - lv.SetPerLine(pl); -} - -int CellBuffer::Lines() const { - return lv.Lines(); -} - -int CellBuffer::LineStart(int line) const { - if (line < 0) - return 0; - else if (line >= Lines()) - return Length(); - else - return lv.LineStart(line); -} - -bool CellBuffer::IsReadOnly() const { - return readOnly; -} - -void CellBuffer::SetReadOnly(bool set) { - readOnly = set; -} - -void CellBuffer::SetSavePoint() { - uh.SetSavePoint(); -} - -bool CellBuffer::IsSavePoint() const { - return uh.IsSavePoint(); -} - -void CellBuffer::TentativeStart() { - uh.TentativeStart(); -} - -void CellBuffer::TentativeCommit() { - uh.TentativeCommit(); -} - -int CellBuffer::TentativeSteps() { - return uh.TentativeSteps(); -} - -bool CellBuffer::TentativeActive() const { - return uh.TentativeActive(); -} - -// Without undo - -void CellBuffer::InsertLine(int line, int position, bool lineStart) { - lv.InsertLine(line, position, lineStart); -} - -void CellBuffer::RemoveLine(int line) { - lv.RemoveLine(line); -} - -bool CellBuffer::UTF8LineEndOverlaps(int position) const { - unsigned char bytes[] = { - static_cast(substance.ValueAt(position-2)), - static_cast(substance.ValueAt(position-1)), - static_cast(substance.ValueAt(position)), - static_cast(substance.ValueAt(position+1)), - }; - return UTF8IsSeparator(bytes) || UTF8IsSeparator(bytes+1) || UTF8IsNEL(bytes+1); -} - -void CellBuffer::ResetLineEnds() { - // Reinitialize line data -- too much work to preserve - lv.Init(); - - int position = 0; - int length = Length(); - int lineInsert = 1; - bool atLineStart = true; - lv.InsertText(lineInsert-1, length); - unsigned char chBeforePrev = 0; - unsigned char chPrev = 0; - for (int i = 0; i < length; i++) { - unsigned char ch = substance.ValueAt(position + i); - if (ch == '\r') { - InsertLine(lineInsert, (position + i) + 1, atLineStart); - lineInsert++; - } else if (ch == '\n') { - if (chPrev == '\r') { - // Patch up what was end of line - lv.SetLineStart(lineInsert - 1, (position + i) + 1); - } else { - InsertLine(lineInsert, (position + i) + 1, atLineStart); - lineInsert++; - } - } else if (utf8LineEnds) { - unsigned char back3[3] = {chBeforePrev, chPrev, ch}; - if (UTF8IsSeparator(back3) || UTF8IsNEL(back3+1)) { - InsertLine(lineInsert, (position + i) + 1, atLineStart); - lineInsert++; - } - } - chBeforePrev = chPrev; - chPrev = ch; - } -} - -void CellBuffer::BasicInsertString(int position, const char *s, int insertLength) { - if (insertLength == 0) - return; - PLATFORM_ASSERT(insertLength > 0); - - unsigned char chAfter = substance.ValueAt(position); - bool breakingUTF8LineEnd = false; - if (utf8LineEnds && UTF8IsTrailByte(chAfter)) { - breakingUTF8LineEnd = UTF8LineEndOverlaps(position); - } - - substance.InsertFromArray(position, s, 0, insertLength); - style.InsertValue(position, insertLength, 0); - - int lineInsert = lv.LineFromPosition(position) + 1; - bool atLineStart = lv.LineStart(lineInsert-1) == position; - // Point all the lines after the insertion point further along in the buffer - lv.InsertText(lineInsert-1, insertLength); - unsigned char chBeforePrev = substance.ValueAt(position - 2); - unsigned char chPrev = substance.ValueAt(position - 1); - if (chPrev == '\r' && chAfter == '\n') { - // Splitting up a crlf pair at position - InsertLine(lineInsert, position, false); - lineInsert++; - } - if (breakingUTF8LineEnd) { - RemoveLine(lineInsert); - } - unsigned char ch = ' '; - for (int i = 0; i < insertLength; i++) { - ch = s[i]; - if (ch == '\r') { - InsertLine(lineInsert, (position + i) + 1, atLineStart); - lineInsert++; - } else if (ch == '\n') { - if (chPrev == '\r') { - // Patch up what was end of line - lv.SetLineStart(lineInsert - 1, (position + i) + 1); - } else { - InsertLine(lineInsert, (position + i) + 1, atLineStart); - lineInsert++; - } - } else if (utf8LineEnds) { - unsigned char back3[3] = {chBeforePrev, chPrev, ch}; - if (UTF8IsSeparator(back3) || UTF8IsNEL(back3+1)) { - InsertLine(lineInsert, (position + i) + 1, atLineStart); - lineInsert++; - } - } - chBeforePrev = chPrev; - chPrev = ch; - } - // Joining two lines where last insertion is cr and following substance starts with lf - if (chAfter == '\n') { - if (ch == '\r') { - // End of line already in buffer so drop the newly created one - RemoveLine(lineInsert - 1); - } - } else if (utf8LineEnds && !UTF8IsAscii(chAfter)) { - // May have end of UTF-8 line end in buffer and start in insertion - for (int j = 0; j < UTF8SeparatorLength-1; j++) { - unsigned char chAt = substance.ValueAt(position + insertLength + j); - unsigned char back3[3] = {chBeforePrev, chPrev, chAt}; - if (UTF8IsSeparator(back3)) { - InsertLine(lineInsert, (position + insertLength + j) + 1, atLineStart); - lineInsert++; - } - if ((j == 0) && UTF8IsNEL(back3+1)) { - InsertLine(lineInsert, (position + insertLength + j) + 1, atLineStart); - lineInsert++; - } - chBeforePrev = chPrev; - chPrev = chAt; - } - } -} - -void CellBuffer::BasicDeleteChars(int position, int deleteLength) { - if (deleteLength == 0) - return; - - if ((position == 0) && (deleteLength == substance.Length())) { - // If whole buffer is being deleted, faster to reinitialise lines data - // than to delete each line. - 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) + 1; - lv.InsertText(lineRemove-1, - (deleteLength)); - unsigned char chPrev = substance.ValueAt(position - 1); - unsigned char chBefore = chPrev; - unsigned char chNext = substance.ValueAt(position); - bool ignoreNL = false; - if (chPrev == '\r' && chNext == '\n') { - // Move back one - lv.SetLineStart(lineRemove, position); - lineRemove++; - ignoreNL = true; // First \n is not real deletion - } - if (utf8LineEnds && UTF8IsTrailByte(chNext)) { - if (UTF8LineEndOverlaps(position)) { - RemoveLine(lineRemove); - } - } - - unsigned char ch = chNext; - for (int i = 0; i < deleteLength; i++) { - chNext = substance.ValueAt(position + i + 1); - if (ch == '\r') { - if (chNext != '\n') { - RemoveLine(lineRemove); - } - } else if (ch == '\n') { - if (ignoreNL) { - ignoreNL = false; // Further \n are real deletions - } else { - RemoveLine(lineRemove); - } - } else if (utf8LineEnds) { - if (!UTF8IsAscii(ch)) { - unsigned char next3[3] = {ch, chNext, - static_cast(substance.ValueAt(position + i + 2))}; - if (UTF8IsSeparator(next3) || UTF8IsNEL(next3)) { - RemoveLine(lineRemove); - } - } - } - - ch = chNext; - } - // 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 = substance.ValueAt(position + deleteLength); - if (chBefore == '\r' && chAfter == '\n') { - // Using lineRemove-1 as cr ended line before start of deletion - RemoveLine(lineRemove - 1); - lv.SetLineStart(lineRemove - 1, position + 1); - } - } - substance.DeleteRange(position, deleteLength); - style.DeleteRange(position, deleteLength); -} - -bool CellBuffer::SetUndoCollection(bool collectUndo) { - collectingUndo = collectUndo; - uh.DropUndoSequence(); - return collectingUndo; -} - -bool CellBuffer::IsCollectingUndo() const { - return collectingUndo; -} - -void CellBuffer::BeginUndoAction() { - uh.BeginUndoAction(); -} - -void CellBuffer::EndUndoAction() { - uh.EndUndoAction(); -} - -void CellBuffer::AddUndoAction(int token, bool mayCoalesce) { - bool startSequence; - uh.AppendAction(containerAction, token, 0, 0, startSequence, mayCoalesce); -} - -void CellBuffer::DeleteUndoHistory() { - uh.DeleteUndoHistory(); -} - -bool CellBuffer::CanUndo() const { - return uh.CanUndo(); -} - -int CellBuffer::StartUndo() { - return uh.StartUndo(); -} - -const Action &CellBuffer::GetUndoStep() const { - return uh.GetUndoStep(); -} - -void CellBuffer::PerformUndoStep() { - const Action &actionStep = uh.GetUndoStep(); - if (actionStep.at == insertAction) { - PLATFORM_ASSERT(substance.Length() >= actionStep.lenData); - BasicDeleteChars(actionStep.position, actionStep.lenData); - } else if (actionStep.at == removeAction) { - BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData); - } - uh.CompletedUndoStep(); -} - -bool CellBuffer::CanRedo() const { - return uh.CanRedo(); -} - -int CellBuffer::StartRedo() { - return uh.StartRedo(); -} - -const Action &CellBuffer::GetRedoStep() const { - return uh.GetRedoStep(); -} - -void CellBuffer::PerformRedoStep() { - const Action &actionStep = uh.GetRedoStep(); - if (actionStep.at == insertAction) { - BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData); - } else if (actionStep.at == removeAction) { - BasicDeleteChars(actionStep.position, actionStep.lenData); - } - uh.CompletedRedoStep(); -} - diff --git a/dep/scintilla/scintilla-3.6.0/src/CellBuffer.h b/dep/scintilla/scintilla-3.6.0/src/CellBuffer.h deleted file mode 100644 index 5e4fc7c8..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/CellBuffer.h +++ /dev/null @@ -1,231 +0,0 @@ -// Scintilla source code edit control -/** @file CellBuffer.h - ** Manages the text of the document. - **/ -// Copyright 1998-2004 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef CELLBUFFER_H -#define CELLBUFFER_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -// Interface to per-line data that wants to see each line insertion and deletion -class PerLine { -public: - virtual ~PerLine() {} - virtual void Init()=0; - virtual void InsertLine(int line)=0; - virtual void RemoveLine(int line)=0; -}; - -/** - * The line vector contains information about each of the lines in a cell buffer. - */ -class LineVector { - - Partitioning starts; - PerLine *perLine; - -public: - - LineVector(); - ~LineVector(); - void Init(); - void SetPerLine(PerLine *pl); - - void InsertText(int line, int delta); - void InsertLine(int line, int position, bool lineStart); - void SetLineStart(int line, int position); - void RemoveLine(int line); - int Lines() const { - return starts.Partitions(); - } - int LineFromPosition(int pos) const; - 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); - void DeleteMarkFromHandle(int markerHandle); - int LineFromHandle(int markerHandle); - - void ClearLevels(); - int SetLevel(int line, int level); - int GetLevel(int line); - - int SetLineState(int line, int state); - int GetLineState(int line); - int GetMaxLineState(); - -}; - -enum actionType { insertAction, removeAction, startAction, containerAction }; - -/** - * Actions are used to store all the information required to perform one undo/redo step. - */ -class Action { -public: - actionType at; - int position; - char *data; - int lenData; - bool mayCoalesce; - - Action(); - ~Action(); - void Create(actionType at_, int position_=0, const char *data_=0, int lenData_=0, bool mayCoalesce_=true); - void Destroy(); - void Grab(Action *source); -}; - -/** - * - */ -class UndoHistory { - Action *actions; - int lenActions; - int maxAction; - int currentAction; - int undoSequenceDepth; - int savePoint; - int tentativePoint; - - void EnsureUndoRoom(); - - // Private so UndoHistory objects can not be copied - UndoHistory(const UndoHistory &); - -public: - UndoHistory(); - ~UndoHistory(); - - const char *AppendAction(actionType at, int position, const char *data, int length, bool &startSequence, bool mayCoalesce=true); - - void BeginUndoAction(); - void EndUndoAction(); - void DropUndoSequence(); - void DeleteUndoHistory(); - - /// The save point is a marker in the undo stack where the container has stated that - /// the buffer was saved. Undo and redo can move over the save point. - void SetSavePoint(); - bool IsSavePoint() const; - - // Tentative actions are used for input composition so that it can be undone cleanly - void TentativeStart(); - void TentativeCommit(); - bool TentativeActive() const { return tentativePoint >= 0; } - int TentativeSteps(); - - /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is - /// called that many times. Similarly for redo. - bool CanUndo() const; - int StartUndo(); - const Action &GetUndoStep() const; - void CompletedUndoStep(); - bool CanRedo() const; - int StartRedo(); - const Action &GetRedoStep() const; - void CompletedRedoStep(); -}; - -/** - * Holder for an expandable array of characters that supports undo and line markers. - * Based on article "Data Structures in a Bit-Mapped Text Editor" - * by Wilfred J. Hansen, Byte January 1987, page 183. - */ -class CellBuffer { -private: - SplitVector substance; - SplitVector style; - bool readOnly; - int utf8LineEnds; - - bool collectingUndo; - UndoHistory uh; - - LineVector lv; - - bool UTF8LineEndOverlaps(int position) const; - void ResetLineEnds(); - /// Actions without undo - void BasicInsertString(int position, const char *s, int insertLength); - void BasicDeleteChars(int position, int deleteLength); - -public: - - CellBuffer(); - ~CellBuffer(); - - /// Retrieving positions outside the range of the buffer works and returns 0 - char CharAt(int position) const; - void GetCharRange(char *buffer, int position, int lengthRetrieve) const; - char StyleAt(int position) const; - void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const; - const char *BufferPointer(); - const char *RangePointer(int position, int rangeLength); - int GapPosition() const; - - int Length() const; - void Allocate(int newSize); - int GetLineEndTypes() const { return utf8LineEnds; } - void SetLineEndTypes(int utf8LineEnds_); - void SetPerLine(PerLine *pl); - int Lines() const; - int LineStart(int line) const; - int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); } - void InsertLine(int line, int position, bool lineStart); - 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 styleValue); - bool SetStyleFor(int position, int length, char styleValue); - - const char *DeleteChars(int position, int deleteLength, bool &startSequence); - - bool IsReadOnly() const; - void SetReadOnly(bool set); - - /// The save point is a marker in the undo stack where the container has stated that - /// the buffer was saved. Undo and redo can move over the save point. - void SetSavePoint(); - bool IsSavePoint() const; - - void TentativeStart(); - void TentativeCommit(); - bool TentativeActive() const; - int TentativeSteps(); - - bool SetUndoCollection(bool collectUndo); - bool IsCollectingUndo() const; - void BeginUndoAction(); - void EndUndoAction(); - void AddUndoAction(int token, bool mayCoalesce); - void DeleteUndoHistory(); - - /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is - /// called that many times. Similarly for redo. - bool CanUndo() const; - int StartUndo(); - const Action &GetUndoStep() const; - void PerformUndoStep(); - bool CanRedo() const; - int StartRedo(); - const Action &GetRedoStep() const; - void PerformRedoStep(); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/ContractionState.cxx b/dep/scintilla/scintilla-3.6.0/src/ContractionState.cxx deleted file mode 100644 index 80f79de2..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/ContractionState.cxx +++ /dev/null @@ -1,286 +0,0 @@ -// Scintilla source code edit control -/** @file ContractionState.cxx - ** Manages visibility of lines for folding and wrapping. - **/ -// Copyright 1998-2007 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#include - -#include -#include - -#include "Platform.h" - -#include "Position.h" -#include "SplitVector.h" -#include "Partitioning.h" -#include "RunStyles.h" -#include "ContractionState.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -ContractionState::ContractionState() : visible(0), expanded(0), heights(0), displayLines(0), linesInDocument(1) { - //InsertLine(0); -} - -ContractionState::~ContractionState() { - Clear(); -} - -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 visible; - visible = 0; - delete expanded; - expanded = 0; - delete heights; - heights = 0; - delete displayLines; - displayLines = 0; - linesInDocument = 1; -} - -int ContractionState::LinesInDoc() const { - if (OneToOne()) { - return linesInDocument; - } else { - return displayLines->Partitions() - 1; - } -} - -int ContractionState::LinesDisplayed() const { - if (OneToOne()) { - return linesInDocument; - } else { - return displayLines->PositionFromPartition(LinesInDoc()); - } -} - -int ContractionState::DisplayFromDoc(int lineDoc) const { - if (OneToOne()) { - return (lineDoc <= linesInDocument) ? lineDoc : linesInDocument; - } else { - if (lineDoc > displayLines->Partitions()) - lineDoc = displayLines->Partitions(); - return displayLines->PositionFromPartition(lineDoc); - } -} - -int ContractionState::DisplayLastFromDoc(int lineDoc) const { - return DisplayFromDoc(lineDoc) + GetHeight(lineDoc) - 1; -} - -int ContractionState::DocFromDisplay(int lineDisplay) const { - if (OneToOne()) { - return lineDisplay; - } else { - 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::InsertLine(int lineDoc) { - if (OneToOne()) { - linesInDocument++; - } else { - 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) { - for (int l = 0; l < lineCount; l++) { - InsertLine(lineDoc + l); - } - 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); - } -} - -void ContractionState::DeleteLines(int lineDoc, int lineCount) { - for (int l = 0; l < lineCount; l++) { - DeleteLine(lineDoc); - } - Check(); -} - -bool ContractionState::GetVisible(int lineDoc) const { - if (OneToOne()) { - return true; - } else { - if (lineDoc >= visible->Length()) - return true; - return visible->ValueAt(lineDoc) == 1; - } -} - -bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool isVisible) { - if (OneToOne() && isVisible) { - return false; - } else { - EnsureData(); - int delta = 0; - Check(); - if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) { - for (int line = lineDocStart; line <= lineDocEnd; line++) { - if (GetVisible(line) != isVisible) { - int difference = isVisible ? heights->ValueAt(line) : -heights->ValueAt(line); - visible->SetValueAt(line, isVisible ? 1 : 0); - displayLines->InsertText(line, difference); - delta += difference; - } - } - } else { - return false; - } - Check(); - return delta != 0; - } -} - -bool ContractionState::HiddenLines() const { - if (OneToOne()) { - return false; - } else { - return !visible->AllSameAs(1); - } -} - -bool ContractionState::GetExpanded(int lineDoc) const { - if (OneToOne()) { - return true; - } else { - Check(); - return expanded->ValueAt(lineDoc) == 1; - } -} - -bool ContractionState::SetExpanded(int lineDoc, bool isExpanded) { - if (OneToOne() && isExpanded) { - return false; - } else { - EnsureData(); - if (isExpanded != (expanded->ValueAt(lineDoc) == 1)) { - expanded->SetValueAt(lineDoc, isExpanded ? 1 : 0); - Check(); - return true; - } else { - Check(); - return false; - } - } -} - -int ContractionState::ContractedNext(int lineDocStart) const { - if (OneToOne()) { - return -1; - } else { - Check(); - if (!expanded->ValueAt(lineDocStart)) { - return lineDocStart; - } else { - int lineDocNextChange = expanded->EndRun(lineDocStart); - if (lineDocNextChange < LinesInDoc()) - return lineDocNextChange; - else - return -1; - } - } -} - -int ContractionState::GetHeight(int lineDoc) const { - if (OneToOne()) { - return 1; - } else { - 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 (OneToOne() && (height == 1)) { - return false; - } else if (lineDoc < LinesInDoc()) { - 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; - } - } else { - return false; - } -} - -void ContractionState::ShowAll() { - 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 -} diff --git a/dep/scintilla/scintilla-3.6.0/src/ContractionState.h b/dep/scintilla/scintilla-3.6.0/src/ContractionState.h deleted file mode 100644 index 96cbf076..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/ContractionState.h +++ /dev/null @@ -1,69 +0,0 @@ -// Scintilla source code edit control -/** @file ContractionState.h - ** Manages visibility of lines for folding and wrapping. - **/ -// Copyright 1998-2007 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef CONTRACTIONSTATE_H -#define CONTRACTIONSTATE_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -/** - */ -class ContractionState { - // 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(); - virtual ~ContractionState(); - - void Clear(); - - int LinesInDoc() const; - int LinesDisplayed() const; - int DisplayFromDoc(int lineDoc) const; - int DisplayLastFromDoc(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 SetVisible(int lineDocStart, int lineDocEnd, bool isVisible); - bool HiddenLines() const; - - bool GetExpanded(int lineDoc) const; - bool SetExpanded(int lineDoc, bool isExpanded); - int ContractedNext(int lineDocStart) const; - - int GetHeight(int lineDoc) const; - bool SetHeight(int lineDoc, int height); - - void ShowAll(); - void Check() const; -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/Decoration.cxx b/dep/scintilla/scintilla-3.6.0/src/Decoration.cxx deleted file mode 100644 index 389db502..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/Decoration.cxx +++ /dev/null @@ -1,198 +0,0 @@ -/** @file Decoration.cxx - ** Visual elements added over text. - **/ -// Copyright 1998-2007 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#include -#include -#include -#include - -#include -#include - -#include "Platform.h" - -#include "Scintilla.h" -#include "Position.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() const { - return (rs.Runs() == 1) && (rs.AllSameAs(0)); -} - -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) { - const bool atEnd = position == lengthDocument; - lengthDocument += insertLength; - for (Decoration *deco=root; deco; deco = deco->next) { - deco->rs.InsertSpace(position, insertLength); - if (atEnd) { - deco->rs.FillRange(position, 0, 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 ((lengthDocument == 0) || deco->Empty()) { - Delete(deco->indicator); - deco = root; - } else { - deco = deco->next; - } - } -} - -int DecorationList::AllOnFor(int position) const { - int mask = 0; - for (Decoration *deco=root; deco; deco = deco->next) { - if (deco->rs.ValueAt(position)) { - if (deco->indicator < INDIC_IME) { - 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; -} diff --git a/dep/scintilla/scintilla-3.6.0/src/Decoration.h b/dep/scintilla/scintilla-3.6.0/src/Decoration.h deleted file mode 100644 index a0c434af..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/Decoration.h +++ /dev/null @@ -1,64 +0,0 @@ -/** @file Decoration.h - ** Visual elements added over text. - **/ -// Copyright 1998-2007 by Neil Hodgson -// 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; - - explicit Decoration(int indicator_); - ~Decoration(); - - bool Empty() const; -}; - -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() const { return currentIndicator; } - - void SetCurrentValue(int value); - int GetCurrentValue() const { 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) const; - int ValueAt(int indicator, int position); - int Start(int indicator, int position); - int End(int indicator, int position); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/Document.h b/dep/scintilla/scintilla-3.6.0/src/Document.h deleted file mode 100644 index ea8ddfbe..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/Document.h +++ /dev/null @@ -1,535 +0,0 @@ -// Scintilla source code edit control -/** @file Document.h - ** Text document that handles notifications, DBCS, styling, words and end of line. - **/ -// Copyright 1998-2011 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#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. - */ -typedef int Position; -const Position invalidPosition = -1; - -enum EncodingFamily { efEightBit, efUnicode, efDBCS }; - -/** - * The range class represents a range of text in a document. - * The two values are not sorted as one end may be more significant than the other - * as is the case for the selection where the end position is the position of the caret. - * If either position is invalidPosition then the range is invalid and most operations will fail. - */ -class Range { -public: - Position start; - Position end; - - explicit Range(Position pos=0) : - start(pos), end(pos) { - } - Range(Position start_, Position end_) : - start(start_), end(end_) { - } - - bool operator==(const Range &other) const { - return (start == other.start) && (end == other.end); - } - - bool Valid() const { - return (start != invalidPosition) && (end != invalidPosition); - } - - Position First() const { - return (start <= end) ? start : end; - } - - Position Last() const { - return (start > end) ? start : end; - } - - // Is the position within the range? - bool Contains(Position pos) const { - if (start < end) { - return (pos >= start && pos <= end); - } else { - return (pos <= start && pos >= end); - } - } - - // Is the character after pos within the range? - bool ContainsCharacter(Position pos) const { - if (start < end) { - return (pos >= start && pos < end); - } else { - return (pos < start && pos >= end); - } - } - - bool Contains(Range other) const { - return Contains(other.start) && Contains(other.end); - } - - bool Overlaps(Range other) const { - return - Contains(other.start) || - Contains(other.end) || - other.Contains(start) || - other.Contains(end); - } -}; - -class DocWatcher; -class DocModification; -class Document; - -/** - * Interface class for regular expression searching - */ -class RegexSearchBase { -public: - virtual ~RegexSearchBase() {} - - virtual long FindText(Document *doc, int minPos, int maxPos, const char *s, - bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0; - - ///@return String with the substitutions, must remain valid until the next call or destruction - virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length) = 0; -}; - -/// Factory function for RegexSearchBase -extern RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable); - -struct StyledText { - size_t length; - const char *text; - bool multipleStyles; - size_t style; - const unsigned char *styles; - StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) : - length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) { - } - // Return number of bytes from start to before '\n' or end of text. - // Return 1 when start is outside text - size_t LineLength(size_t start) const { - size_t cur = start; - while ((cur < length) && (text[cur] != '\n')) - cur++; - return cur-start; - } - size_t StyleAt(size_t i) const { - return multipleStyles ? styles[i] : style; - } -}; - -class HighlightDelimiter { -public: - HighlightDelimiter() : isEnabled(false) { - Clear(); - } - - void Clear() { - beginFoldBlock = -1; - endFoldBlock = -1; - firstChangeableLineBefore = -1; - firstChangeableLineAfter = -1; - } - - bool NeedsDrawing(int line) const { - return isEnabled && (line <= firstChangeableLineBefore || line >= firstChangeableLineAfter); - } - - bool IsFoldBlockHighlighted(int line) const { - return isEnabled && beginFoldBlock != -1 && beginFoldBlock <= line && line <= endFoldBlock; - } - - bool IsHeadOfFoldBlock(int line) const { - return beginFoldBlock == line && line < endFoldBlock; - } - - bool IsBodyOfFoldBlock(int line) const { - return beginFoldBlock != -1 && beginFoldBlock < line && line < endFoldBlock; - } - - bool IsTailOfFoldBlock(int line) const { - return beginFoldBlock != -1 && beginFoldBlock < line && line == endFoldBlock; - } - - int beginFoldBlock; // Begin of current fold block - int endFoldBlock; // End of current fold block - int firstChangeableLineBefore; // First line that triggers repaint before starting line that determined current fold block - int firstChangeableLineAfter; // First line that triggers repaint after starting line that determined current fold block - bool isEnabled; -}; - -class Document; - -class LexInterface { -protected: - Document *pdoc; - ILexer *instance; - bool performingStyle; ///< Prevent reentrance -public: - explicit LexInterface(Document *pdoc_) : pdoc(pdoc_), instance(0), performingStyle(false) { - } - virtual ~LexInterface() { - } - void Colourise(int start, int end); - int LineEndTypesSupported(); - bool UseContainerLexing() const { - return instance == 0; - } -}; - -struct RegexError : public std::runtime_error { - RegexError() : std::runtime_error("regex failure") {} -}; - -/** - */ -class Document : PerLine, public IDocumentWithLineEnd, public ILoader { - -public: - /** Used to pair watcher pointer with user data. */ - struct WatcherWithUserData { - DocWatcher *watcher; - void *userData; - WatcherWithUserData(DocWatcher *watcher_=0, void *userData_=0) : - watcher(watcher_), userData(userData_) { - } - bool operator==(const WatcherWithUserData &other) const { - return (watcher == other.watcher) && (userData == other.userData); - } - }; - -private: - int refCount; - CellBuffer cb; - CharClassify charClass; - CaseFolder *pcf; - int endStyled; - int styleClock; - int enteredModification; - int enteredStyling; - int enteredReadOnlyCount; - - bool insertionSet; - std::string insertion; - - std::vector watchers; - - // ldSize is not real data - it is for dimensions and loops - enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize }; - PerLine *perLineData[ldSize]; - - bool matchesValid; - RegexSearchBase *regex; - -public: - - LexInterface *pli; - - int eolMode; - /// Can also be SC_CP_UTF8 to enable UTF-8 mode - int dbcsCodePage; - int lineEndBitSet; - int tabInChars; - int indentInChars; - int actualIndentInChars; - bool useTabs; - bool tabIndents; - bool backspaceUnindents; - - DecorationList decorations; - - Document(); - virtual ~Document(); - - int AddRef(); - int SCI_METHOD Release(); - - virtual void Init(); - int LineEndTypesSupported() const; - bool SetDBCSCodePage(int dbcsCodePage_); - int GetLineEndTypesAllowed() const { return cb.GetLineEndTypes(); } - bool SetLineEndTypesAllowed(int lineEndBitSet_); - int GetLineEndTypesActive() const { return cb.GetLineEndTypes(); } - virtual void InsertLine(int line); - virtual void RemoveLine(int line); - - int SCI_METHOD Version() const { - return dvLineEnd; - } - - void SCI_METHOD SetErrorStatus(int status); - - Sci_Position SCI_METHOD LineFromPosition(Sci_Position pos) const; - int ClampPositionIntoDocument(int pos) const; - bool IsCrLf(int pos) const; - int LenChar(int pos); - bool InGoodUTF8(int pos, int &start, int &end) const; - int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const; - int NextPosition(int pos, int moveDir) const; - bool NextCharacter(int &pos, int moveDir) const; // Returns true if pos changed - Sci_Position SCI_METHOD GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const; - int GetRelativePositionUTF16(int positionStart, int characterOffset) const; - int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const; - int SCI_METHOD CodePage() const; - bool SCI_METHOD IsDBCSLeadByte(char ch) const; - int SafeSegment(const char *text, int length, int lengthSegment) const; - EncodingFamily CodePageFamily() const; - - // Gateways to modifying document - void ModifiedAt(int pos); - void CheckReadOnly(); - bool DeleteChars(int pos, int len); - int InsertString(int position, const char *s, int insertLength); - void ChangeInsertion(const char *s, int length); - int SCI_METHOD AddData(char *data, Sci_Position length); - void * SCI_METHOD ConvertToDocument(); - int Undo(); - int Redo(); - bool CanUndo() const { return cb.CanUndo(); } - bool CanRedo() const { return cb.CanRedo(); } - void DeleteUndoHistory() { cb.DeleteUndoHistory(); } - bool SetUndoCollection(bool collectUndo) { - return cb.SetUndoCollection(collectUndo); - } - bool IsCollectingUndo() const { return cb.IsCollectingUndo(); } - void BeginUndoAction() { cb.BeginUndoAction(); } - void EndUndoAction() { cb.EndUndoAction(); } - void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); } - void SetSavePoint(); - bool IsSavePoint() const { return cb.IsSavePoint(); } - - void TentativeStart() { cb.TentativeStart(); } - void TentativeCommit() { cb.TentativeCommit(); } - void TentativeUndo(); - bool TentativeActive() const { return cb.TentativeActive(); } - - const char * SCI_METHOD BufferPointer() { return cb.BufferPointer(); } - const char *RangePointer(int position, int rangeLength) { return cb.RangePointer(position, rangeLength); } - int GapPosition() const { return cb.GapPosition(); } - - int SCI_METHOD GetLineIndentation(Sci_Position line); - int SetLineIndentation(int line, int indent); - int GetLineIndentPosition(int line) const; - int GetColumn(int position); - int CountCharacters(int startPos, int endPos) const; - int CountUTF16(int startPos, int endPos) const; - int FindColumn(int line, int column); - void Indent(bool forwards, int lineBottom, int lineTop); - static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted); - void ConvertLineEnds(int eolModeSet); - void SetReadOnly(bool set) { cb.SetReadOnly(set); } - bool IsReadOnly() const { return cb.IsReadOnly(); } - - void DelChar(int pos); - void DelCharBack(int pos); - - char CharAt(int position) const { return cb.CharAt(position); } - void SCI_METHOD GetCharRange(char *buffer, Sci_Position position, Sci_Position lengthRetrieve) const { - cb.GetCharRange(buffer, position, lengthRetrieve); - } - char SCI_METHOD StyleAt(Sci_Position position) const { return cb.StyleAt(position); } - void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const { - cb.GetStyleRange(buffer, position, lengthRetrieve); - } - int GetMark(int line); - int MarkerNext(int lineStart, int mask) const; - int AddMark(int line, int markerNum); - void AddMarkSet(int line, int valueSet); - void DeleteMark(int line, int markerNum); - void DeleteMarkFromHandle(int markerHandle); - void DeleteAllMarks(int markerNum); - int LineFromHandle(int markerHandle); - Sci_Position SCI_METHOD LineStart(Sci_Position line) const; - bool IsLineStartPosition(int position) const; - Sci_Position SCI_METHOD LineEnd(Sci_Position line) const; - int LineEndPosition(int position) const; - bool IsLineEndPosition(int position) const; - bool IsPositionInLineEnd(int position) const; - int VCHomePosition(int position) const; - - int SCI_METHOD SetLevel(Sci_Position line, int level); - int SCI_METHOD GetLevel(Sci_Position line) const; - void ClearLevels(); - int GetLastChild(int lineParent, int level=-1, int lastLine=-1); - int GetFoldParent(int line) const; - void GetHighlightDelimiters(HighlightDelimiter &hDelimiter, int line, int lastLine); - - void Indent(bool forwards); - int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false); - int NextWordStart(int pos, int delta); - int NextWordEnd(int pos, int delta); - Sci_Position SCI_METHOD Length() const { return cb.Length(); } - void Allocate(int newSize) { cb.Allocate(newSize); } - - struct CharacterExtracted { - unsigned int character; - unsigned int widthBytes; - CharacterExtracted(unsigned int character_, unsigned int widthBytes_) : - character(character_), widthBytes(widthBytes_) { - } - }; - CharacterExtracted ExtractCharacter(int position) const; - - bool IsWordStartAt(int pos) const; - bool IsWordEndAt(int pos) const; - bool IsWordAt(int start, int end) const; - - bool MatchesWordOptions(bool word, bool wordStart, int pos, int length) const; - bool HasCaseFolder(void) const; - void SetCaseFolder(CaseFolder *pcf_); - long FindText(int minPos, int maxPos, const char *search, int flags, int *length); - const char *SubstituteByPosition(const char *text, int *length); - int LinesTotal() const; - - void SetDefaultCharClasses(bool includeWordClass); - void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass); - int GetCharsOfClass(CharClassify::cc characterClass, unsigned char *buffer); - void SCI_METHOD StartStyling(Sci_Position position, char mask); - bool SCI_METHOD SetStyleFor(Sci_Position length, char style); - bool SCI_METHOD SetStyles(Sci_Position length, const char *styles); - int GetEndStyled() const { return endStyled; } - void EnsureStyledTo(int pos); - void LexerChanged(); - int GetStyleClock() const { return styleClock; } - void IncrementStyleClock(); - void SCI_METHOD DecorationSetCurrentIndicator(int indicator) { - decorations.SetCurrentIndicator(indicator); - } - void SCI_METHOD DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength); - - int SCI_METHOD SetLineState(Sci_Position line, int state); - int SCI_METHOD GetLineState(Sci_Position line) const; - int GetMaxLineState(); - void SCI_METHOD ChangeLexerState(Sci_Position start, Sci_Position end); - - StyledText MarginStyledText(int line) const; - void MarginSetStyle(int line, int style); - void MarginSetStyles(int line, const unsigned char *styles); - void MarginSetText(int line, const char *text); - void MarginClearAll(); - - StyledText AnnotationStyledText(int line) const; - void AnnotationSetText(int line, const char *text); - void AnnotationSetStyle(int line, int style); - void AnnotationSetStyles(int line, const unsigned char *styles); - int AnnotationLines(int line) const; - void AnnotationClearAll(); - - bool AddWatcher(DocWatcher *watcher, void *userData); - bool RemoveWatcher(DocWatcher *watcher, void *userData); - - CharClassify::cc WordCharClass(unsigned char ch) const; - bool IsWordPartSeparator(char ch) const; - int WordPartLeft(int pos); - int WordPartRight(int pos); - int ExtendStyleRange(int pos, int delta, bool singleLine = false); - bool IsWhiteLine(int line) const; - int ParaUp(int pos) const; - int ParaDown(int pos) const; - int IndentSize() const { return actualIndentInChars; } - int BraceMatch(int position, int maxReStyle); - -private: - void NotifyModifyAttempt(); - void NotifySavePoint(bool atSavePoint); - void NotifyModified(DocModification mh); -}; - -class UndoGroup { - Document *pdoc; - bool groupNeeded; -public: - UndoGroup(Document *pdoc_, bool groupNeeded_=true) : - pdoc(pdoc_), groupNeeded(groupNeeded_) { - if (groupNeeded) { - pdoc->BeginUndoAction(); - } - } - ~UndoGroup() { - if (groupNeeded) { - pdoc->EndUndoAction(); - } - } - bool Needed() const { - return groupNeeded; - } -}; - - -/** - * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the - * scope of the change. - * If the DocWatcher is a document view then this can be used to optimise screen updating. - */ -class DocModification { -public: - int modificationType; - int position; - int length; - int linesAdded; /**< Negative if lines deleted. */ - const char *text; /**< Only valid for changes to text, not for changes to style. */ - int line; - int foldLevelNow; - int foldLevelPrev; - int annotationLinesAdded; - int token; - - DocModification(int modificationType_, int position_=0, int length_=0, - int linesAdded_=0, const char *text_=0, int line_=0) : - modificationType(modificationType_), - position(position_), - length(length_), - linesAdded(linesAdded_), - text(text_), - line(line_), - foldLevelNow(0), - foldLevelPrev(0), - annotationLinesAdded(0), - token(0) {} - - DocModification(int modificationType_, const Action &act, int linesAdded_=0) : - modificationType(modificationType_), - position(act.position), - length(act.lenData), - linesAdded(linesAdded_), - text(act.data), - line(0), - foldLevelNow(0), - foldLevelPrev(0), - annotationLinesAdded(0), - token(0) {} -}; - -/** - * A class that wants to receive notifications from a Document must be derived from DocWatcher - * and implement the notification methods. It can then be added to the watcher list with AddWatcher. - */ -class DocWatcher { -public: - virtual ~DocWatcher() {} - - virtual void NotifyModifyAttempt(Document *doc, void *userData) = 0; - virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0; - virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0; - virtual void NotifyDeleted(Document *doc, void *userData) = 0; - virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0; - virtual void NotifyLexerChanged(Document *doc, void *userData) = 0; - virtual void NotifyErrorOccurred(Document *doc, void *userData, int status) = 0; -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/LineMarker.h b/dep/scintilla/scintilla-3.6.0/src/LineMarker.h deleted file mode 100644 index 6a5fe749..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/LineMarker.h +++ /dev/null @@ -1,86 +0,0 @@ -// Scintilla source code edit control -/** @file LineMarker.h - ** Defines the look of a line marker in the margin . - **/ -// Copyright 1998-2011 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef LINEMARKER_H -#define LINEMARKER_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -typedef void (*DrawLineMarkerFn)(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, int tFold, int marginStyle, const void *lineMarker); - -/** - */ -class LineMarker { -public: - enum typeOfFold { undefined, head, body, tail, headWithTail }; - - int markType; - ColourDesired fore; - ColourDesired back; - ColourDesired backSelected; - int alpha; - XPM *pxpm; - RGBAImage *image; - /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native - * Draw function for drawing line markers. Allow those platforms to override - * it instead of creating a new method(s) in the Surface class that existing - * platforms must implement as empty. */ - DrawLineMarkerFn customDraw; - LineMarker() { - markType = SC_MARK_CIRCLE; - fore = ColourDesired(0,0,0); - back = ColourDesired(0xff,0xff,0xff); - backSelected = ColourDesired(0xff,0x00,0x00); - alpha = SC_ALPHA_NOALPHA; - pxpm = NULL; - image = NULL; - customDraw = NULL; - } - LineMarker(const LineMarker &) { - // Defined to avoid pxpm being blindly copied, not as a complete copy constructor - markType = SC_MARK_CIRCLE; - fore = ColourDesired(0,0,0); - back = ColourDesired(0xff,0xff,0xff); - backSelected = ColourDesired(0xff,0x00,0x00); - alpha = SC_ALPHA_NOALPHA; - pxpm = NULL; - image = NULL; - customDraw = NULL; - } - ~LineMarker() { - delete pxpm; - delete image; - } - LineMarker &operator=(const LineMarker &other) { - // Defined to avoid pxpm being blindly copied, not as a complete assignment operator - if (this != &other) { - markType = SC_MARK_CIRCLE; - fore = ColourDesired(0,0,0); - back = ColourDesired(0xff,0xff,0xff); - backSelected = ColourDesired(0xff,0x00,0x00); - alpha = SC_ALPHA_NOALPHA; - delete pxpm; - pxpm = NULL; - delete image; - image = NULL; - customDraw = NULL; - } - return *this; - } - void SetXPM(const char *textForm); - void SetXPM(const char *const *linesForm); - void SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage); - void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const; -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/PerLine.h b/dep/scintilla/scintilla-3.6.0/src/PerLine.h deleted file mode 100644 index 4bf1c88f..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/PerLine.h +++ /dev/null @@ -1,136 +0,0 @@ -// Scintilla source code edit control -/** @file PerLine.h - ** Manages data associated with each line of the document - **/ -// Copyright 1998-2009 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef PERLINE_H -#define PERLINE_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -/** - * This holds the marker identifier and the marker type to display. - * MarkerHandleNumbers are members of lists. - */ -struct MarkerHandleNumber { - int handle; - int number; - MarkerHandleNumber *next; -}; - -/** - * A marker handle set contains any number of MarkerHandleNumbers. - */ -class MarkerHandleSet { - MarkerHandleNumber *root; - -public: - MarkerHandleSet(); - ~MarkerHandleSet(); - int Length() 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, bool all); - void CombineWith(MarkerHandleSet *other); -}; - -class LineMarkers : public PerLine { - SplitVector markers; - /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big. - int handleCurrent; -public: - LineMarkers() : handleCurrent(0) { - } - virtual ~LineMarkers(); - virtual void Init(); - virtual void InsertLine(int line); - virtual void RemoveLine(int line); - - int MarkValue(int line); - int MarkerNext(int lineStart, int mask) const; - int AddMark(int line, int marker, int lines); - void MergeMarkers(int pos); - bool DeleteMark(int line, int markerNum, bool all); - void DeleteMarkFromHandle(int markerHandle); - int LineFromHandle(int markerHandle); -}; - -class LineLevels : public PerLine { - SplitVector levels; -public: - virtual ~LineLevels(); - virtual void Init(); - virtual void InsertLine(int line); - virtual void RemoveLine(int line); - - void ExpandLevels(int sizeNew=-1); - void ClearLevels(); - int SetLevel(int line, int level, int lines); - int GetLevel(int line) const; -}; - -class LineState : public PerLine { - SplitVector lineStates; -public: - LineState() { - } - virtual ~LineState(); - virtual void Init(); - virtual void InsertLine(int line); - virtual void RemoveLine(int line); - - int SetLineState(int line, int state); - int GetLineState(int line); - int GetMaxLineState() const; -}; - -class LineAnnotation : public PerLine { - SplitVector annotations; -public: - LineAnnotation() { - } - virtual ~LineAnnotation(); - virtual void Init(); - virtual void InsertLine(int line); - virtual void RemoveLine(int line); - - bool MultipleStyles(int line) const; - int Style(int line) const; - const char *Text(int line) const; - const unsigned char *Styles(int line) const; - void SetText(int line, const char *text); - void ClearAll(); - void SetStyle(int line, int style); - void SetStyles(int line, const unsigned char *styles); - int Length(int line) const; - int Lines(int line) const; -}; - -typedef std::vector TabstopList; - -class LineTabstops : public PerLine { - SplitVector tabstops; -public: - LineTabstops() { - } - virtual ~LineTabstops(); - virtual void Init(); - virtual void InsertLine(int line); - virtual void RemoveLine(int line); - - bool ClearTabstops(int line); - bool AddTabstop(int line, int x); - int GetNextTabstop(int line, int x) const; -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/Position.h b/dep/scintilla/scintilla-3.6.0/src/Position.h deleted file mode 100644 index 4ef65526..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/Position.h +++ /dev/null @@ -1,22 +0,0 @@ -// Scintilla source code edit control -/** @file Position.h - ** Will define global type name Position in the Sci internal namespace. - **/ -// Copyright 2015 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef POSITION_H -#define POSITION_H - -namespace Sci { - -// After 3.6.0: -// typedef int Position; - -// A later version (4.x) of this file may: -//#if defined(SCI_LARGE_FILE_SUPPORT) -//typedef ptrdiff_t Position; - -} - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/RunStyles.cxx b/dep/scintilla/scintilla-3.6.0/src/RunStyles.cxx deleted file mode 100644 index a43dd90b..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/RunStyles.cxx +++ /dev/null @@ -1,261 +0,0 @@ -/** @file RunStyles.cxx - ** Data structure used to store sparse styles. - **/ -// Copyright 1998-2007 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#include -#include -#include -#include - -#include -#include - -#include "Platform.h" - -#include "Scintilla.h" -#include "Position.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) const { - 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(); - styles->InsertValue(0, 2, 0); -} - -RunStyles::~RunStyles() { - delete starts; - starts = NULL; - delete styles; - styles = NULL; -} - -int RunStyles::Length() const { - return starts->PositionFromPartition(starts->Partitions()); -} - -int RunStyles::ValueAt(int position) const { - return styles->ValueAt(starts->PartitionFromPosition(position)); -} - -int RunStyles::FindNextChange(int position, int end) const { - 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) const { - return starts->PositionFromPartition(starts->PartitionFromPosition(position)); -} - -int RunStyles::EndRun(int position) const { - return starts->PositionFromPartition(starts->PartitionFromPosition(position) + 1); -} - -bool RunStyles::FillRange(int &position, int value, int &fillLength) { - if (fillLength <= 0) { - return false; - } - int end = position + fillLength; - if (end > Length()) { - return false; - } - 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; runPositionFromPartition(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(); - 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); - RemoveRunIfEmpty(runStart); - } else { - runStart = SplitRun(position); - runEnd = SplitRun(end); - starts->InsertText(runStart, -deleteLength); - // Remove each old run over the range - for (int run=runStart; runPartitions(); -} - -bool RunStyles::AllSame() const { - for (int run = 1; run < starts->Partitions(); run++) { - if (styles->ValueAt(run) != styles->ValueAt(run - 1)) - return false; - } - return true; -} - -bool RunStyles::AllSameAs(int value) const { - return AllSame() && (styles->ValueAt(0) == value); -} - -int RunStyles::Find(int value, int start) const { - if (start < Length()) { - int run = start ? RunFromPosition(start) : 0; - if (styles->ValueAt(run) == value) - return start; - run++; - while (run < starts->Partitions()) { - if (styles->ValueAt(run) == value) - return starts->PositionFromPartition(run); - run++; - } - } - return -1; -} diff --git a/dep/scintilla/scintilla-3.6.0/src/RunStyles.h b/dep/scintilla/scintilla-3.6.0/src/RunStyles.h deleted file mode 100644 index 0984864e..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/RunStyles.h +++ /dev/null @@ -1,52 +0,0 @@ -/** @file RunStyles.h - ** Data structure used to store sparse styles. - **/ -// Copyright 1998-2007 by Neil Hodgson -// 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. - -#ifndef RUNSTYLES_H -#define RUNSTYLES_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -class RunStyles { -private: - Partitioning *starts; - SplitVector *styles; - int RunFromPosition(int position) const; - int SplitRun(int position); - void RemoveRun(int run); - void RemoveRunIfEmpty(int run); - void RemoveRunIfSameAsPrevious(int run); - // Private so RunStyles objects can not be copied - RunStyles(const RunStyles &); -public: - RunStyles(); - ~RunStyles(); - int Length() const; - int ValueAt(int position) const; - int FindNextChange(int position, int end) const; - int StartRun(int position) const; - int EndRun(int position) const; - // 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); - int Runs() const; - bool AllSame() const; - bool AllSameAs(int value) const; - int Find(int value, int start) const; -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/Selection.h b/dep/scintilla/scintilla-3.6.0/src/Selection.h deleted file mode 100644 index 22c01bef..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/Selection.h +++ /dev/null @@ -1,195 +0,0 @@ -// Scintilla source code edit control -/** @file Selection.h - ** Classes maintaining the selection. - **/ -// Copyright 2009 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef SELECTION_H -#define SELECTION_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -class SelectionPosition { - int position; - int virtualSpace; -public: - explicit SelectionPosition(int position_=INVALID_POSITION, int virtualSpace_=0) : position(position_), virtualSpace(virtualSpace_) { - PLATFORM_ASSERT(virtualSpace < 800000); - if (virtualSpace < 0) - virtualSpace = 0; - } - void Reset() { - position = 0; - virtualSpace = 0; - } - void MoveForInsertDelete(bool insertion, int startChange, int length); - bool operator ==(const SelectionPosition &other) const { - return position == other.position && virtualSpace == other.virtualSpace; - } - bool operator <(const SelectionPosition &other) const; - bool operator >(const SelectionPosition &other) const; - bool operator <=(const SelectionPosition &other) const; - bool operator >=(const SelectionPosition &other) const; - int Position() const { - return position; - } - void SetPosition(int position_) { - position = position_; - virtualSpace = 0; - } - int VirtualSpace() const { - return virtualSpace; - } - void SetVirtualSpace(int virtualSpace_) { - PLATFORM_ASSERT(virtualSpace_ < 800000); - if (virtualSpace_ >= 0) - virtualSpace = virtualSpace_; - } - void Add(int increment) { - position = position + increment; - } - bool IsValid() const { - return position >= 0; - } -}; - -// Ordered range to make drawing simpler -struct SelectionSegment { - SelectionPosition start; - SelectionPosition end; - SelectionSegment() : start(), end() { - } - SelectionSegment(SelectionPosition a, SelectionPosition b) { - if (a < b) { - start = a; - end = b; - } else { - start = b; - end = a; - } - } - bool Empty() const { - return start == end; - } - void Extend(SelectionPosition p) { - if (start > p) - start = p; - if (end < p) - end = p; - } -}; - -struct SelectionRange { - SelectionPosition caret; - SelectionPosition anchor; - - SelectionRange() : caret(), anchor() { - } - explicit SelectionRange(SelectionPosition single) : caret(single), anchor(single) { - } - explicit SelectionRange(int single) : caret(single), anchor(single) { - } - SelectionRange(SelectionPosition caret_, SelectionPosition anchor_) : caret(caret_), anchor(anchor_) { - } - SelectionRange(int caret_, int anchor_) : caret(caret_), anchor(anchor_) { - } - bool Empty() const { - return anchor == caret; - } - int Length() const; - // int Width() const; // Like Length but takes virtual space into account - bool operator ==(const SelectionRange &other) const { - return caret == other.caret && anchor == other.anchor; - } - bool operator <(const SelectionRange &other) const { - return caret < other.caret || ((caret == other.caret) && (anchor < other.anchor)); - } - void Reset() { - anchor.Reset(); - caret.Reset(); - } - void ClearVirtualSpace() { - anchor.SetVirtualSpace(0); - caret.SetVirtualSpace(0); - } - void MoveForInsertDelete(bool insertion, int startChange, int length); - bool Contains(int pos) const; - bool Contains(SelectionPosition sp) const; - bool ContainsCharacter(int posCharacter) const; - SelectionSegment Intersect(SelectionSegment check) const; - SelectionPosition Start() const { - return (anchor < caret) ? anchor : caret; - } - SelectionPosition End() const { - return (anchor < caret) ? caret : anchor; - } - bool Trim(SelectionRange range); - // If range is all virtual collapse to start of virtual space - void MinimizeVirtualSpace(); -}; - -class Selection { - std::vector ranges; - std::vector rangesSaved; - SelectionRange rangeRectangular; - size_t mainRange; - bool moveExtends; - bool tentativeMain; -public: - enum selTypes { noSel, selStream, selRectangle, selLines, selThin }; - selTypes selType; - - Selection(); - ~Selection(); - bool IsRectangular() const; - int MainCaret() const; - int MainAnchor() const; - SelectionRange &Rectangular(); - SelectionSegment Limits() const; - // This is for when you want to move the caret in response to a - // user direction command - for rectangular selections, use the range - // that covers all selected text otherwise return the main selection. - SelectionSegment LimitsForRectangularElseMain() const; - size_t Count() const; - size_t Main() const; - void SetMain(size_t r); - SelectionRange &Range(size_t r); - const SelectionRange &Range(size_t r) const; - SelectionRange &RangeMain(); - const SelectionRange &RangeMain() const; - SelectionPosition Start() const; - bool MoveExtends() const; - void SetMoveExtends(bool moveExtends_); - bool Empty() const; - SelectionPosition Last() const; - int Length() const; - void MovePositions(bool insertion, int startChange, int length); - void TrimSelection(SelectionRange range); - void TrimOtherSelections(size_t r, SelectionRange range); - void SetSelection(SelectionRange range); - void AddSelection(SelectionRange range); - void AddSelectionWithoutTrim(SelectionRange range); - void DropSelection(size_t r); - void DropAdditionalRanges(); - void TentativeSelection(SelectionRange range); - void CommitTentative(); - int CharacterInSelection(int posCharacter) const; - int InSelectionForEOL(int pos) const; - int VirtualSpaceFor(int pos) const; - void Clear(); - void RemoveDuplicates(); - void RotateMain(); - bool Tentative() const { return tentativeMain; } - std::vector RangesCopy() const { - return ranges; - } -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/SplitVector.h b/dep/scintilla/scintilla-3.6.0/src/SplitVector.h deleted file mode 100644 index c2438194..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/SplitVector.h +++ /dev/null @@ -1,293 +0,0 @@ -// 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 -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef SPLITVECTOR_H -#define SPLITVECTOR_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -template -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) { - while (growSize < size / 6) - 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) { - PLATFORM_ASSERT(newSize >= 0); - - 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); - std::fill(&body[part1Length], &body[part1Length + insertLength], 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); - } - - // Retrieve a range of elements into an array - void GetRange(T *buffer, int position, int retrieveLength) const { - // Split into up to 2 ranges, before and after the split then use memcpy on each. - int range1Length = 0; - if (position < part1Length) { - int part1AfterPosition = part1Length - position; - range1Length = retrieveLength; - if (range1Length > part1AfterPosition) - range1Length = part1AfterPosition; - } - memcpy(buffer, body + position, range1Length * sizeof(T)); - buffer += range1Length; - position = position + range1Length + gapLength; - int range2Length = retrieveLength - range1Length; - memcpy(buffer, body + position, range2Length * sizeof(T)); - } - - T *BufferPointer() { - RoomFor(1); - GapTo(lengthBody); - body[lengthBody] = 0; - return body; - } - - T *RangePointer(int position, int rangeLength) { - if (position < part1Length) { - if ((position + rangeLength) > part1Length) { - // Range overlaps gap, so move gap to start of range. - GapTo(position); - return body + position + gapLength; - } else { - return body + position; - } - } else { - return body + position + gapLength; - } - } - - int GapPosition() const { - return part1Length; - } -}; - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/UniConversion.cxx b/dep/scintilla/scintilla-3.6.0/src/UniConversion.cxx deleted file mode 100644 index c12ca34c..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/UniConversion.cxx +++ /dev/null @@ -1,313 +0,0 @@ -// Scintilla source code edit control -/** @file UniConversion.cxx - ** Functions to handle UTF-8 and UTF-16 strings. - **/ -// Copyright 1998-2001 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#include - -#include - -#include "UniConversion.h" - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -enum { SURROGATE_TRAIL_FIRST = 0xDC00 }; -enum { SURROGATE_TRAIL_LAST = 0xDFFF }; -enum { SUPPLEMENTAL_PLANE_FIRST = 0x10000 }; - -unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) { - unsigned int len = 0; - for (unsigned int i = 0; i < tlen && uptr[i];) { - unsigned int uch = uptr[i]; - if (uch < 0x80) { - len++; - } else if (uch < 0x800) { - len += 2; - } else if ((uch >= SURROGATE_LEAD_FIRST) && - (uch <= SURROGATE_TRAIL_LAST)) { - len += 4; - i++; - } else { - len += 3; - } - i++; - } - return len; -} - -void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) { - unsigned int k = 0; - for (unsigned int i = 0; i < tlen && uptr[i];) { - unsigned int uch = uptr[i]; - if (uch < 0x80) { - putf[k++] = static_cast(uch); - } else if (uch < 0x800) { - putf[k++] = static_cast(0xC0 | (uch >> 6)); - putf[k++] = static_cast(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(0xF0 | (xch >> 18)); - putf[k++] = static_cast(0x80 | ((xch >> 12) & 0x3f)); - putf[k++] = static_cast(0x80 | ((xch >> 6) & 0x3f)); - putf[k++] = static_cast(0x80 | (xch & 0x3f)); - } else { - putf[k++] = static_cast(0xE0 | (uch >> 12)); - putf[k++] = static_cast(0x80 | ((uch >> 6) & 0x3f)); - putf[k++] = static_cast(0x80 | (uch & 0x3f)); - } - i++; - } - if (k < len) - putf[k] = '\0'; -} - -unsigned int UTF8CharLength(unsigned char ch) { - if (ch < 0x80) { - return 1; - } else if (ch < 0x80 + 0x40 + 0x20) { - return 2; - } else if (ch < 0x80 + 0x40 + 0x20 + 0x10) { - return 3; - } else { - return 4; - } -} - -size_t UTF16Length(const char *s, size_t len) { - size_t ulen = 0; - size_t charLen; - for (size_t i = 0; i(s[i]); - 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; -} - -size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen) { - size_t ui = 0; - const unsigned char *us = reinterpret_cast(s); - size_t i = 0; - while ((i((ch & 0x1F) << 6); - ch = us[i++]; - tbuf[ui] = static_cast(tbuf[ui] + (ch & 0x7F)); - } else if (ch < 0x80 + 0x40 + 0x20 + 0x10) { - tbuf[ui] = static_cast((ch & 0xF) << 12); - ch = us[i++]; - tbuf[ui] = static_cast(tbuf[ui] + ((ch & 0x7F) << 6)); - ch = us[i++]; - tbuf[ui] = static_cast(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(((val - 0x10000) >> 10) + SURROGATE_LEAD_FIRST); - ui++; - tbuf[ui] = static_cast((val & 0x3ff) + SURROGATE_TRAIL_FIRST); - } - ui++; - } - return ui; -} - -unsigned int UTF32FromUTF8(const char *s, unsigned int len, unsigned int *tbuf, unsigned int tlen) { - unsigned int ui=0; - const unsigned char *us = reinterpret_cast(s); - unsigned int i=0; - while ((i= 1) && (ch < 0x80 + 0x40 + 0x20)) { - value = (ch & 0x1F) << 6; - ch = us[i++]; - value += ch & 0x7F; - } else if (((len-i) >= 2) && (ch < 0x80 + 0x40 + 0x20 + 0x10)) { - value = (ch & 0xF) << 12; - ch = us[i++]; - value += (ch & 0x7F) << 6; - ch = us[i++]; - value += ch & 0x7F; - } else if ((len-i) >= 3) { - value = (ch & 0x7) << 18; - ch = us[i++]; - value += (ch & 0x3F) << 12; - ch = us[i++]; - value += (ch & 0x3F) << 6; - ch = us[i++]; - value += ch & 0x3F; - } - tbuf[ui] = value; - ui++; - } - return ui; -} - -unsigned int UTF16FromUTF32Character(unsigned int val, wchar_t *tbuf) { - if (val < SUPPLEMENTAL_PLANE_FIRST) { - tbuf[0] = static_cast(val); - return 1; - } else { - tbuf[0] = static_cast(((val - SUPPLEMENTAL_PLANE_FIRST) >> 10) + SURROGATE_LEAD_FIRST); - tbuf[1] = static_cast((val & 0x3ff) + SURROGATE_TRAIL_FIRST); - return 2; - } -} - -int UTF8BytesOfLead[256]; -static bool initialisedBytesOfLead = false; - -static int BytesFromLead(int leadByte) { - if (leadByte < 0xC2) { - // Single byte or invalid - return 1; - } else if (leadByte < 0xE0) { - return 2; - } else if (leadByte < 0xF0) { - return 3; - } else if (leadByte < 0xF5) { - return 4; - } else { - // Characters longer than 4 bytes not possible in current UTF-8 - return 1; - } -} - -void UTF8BytesOfLeadInitialise() { - if (!initialisedBytesOfLead) { - for (int i=0; i<256; i++) { - UTF8BytesOfLead[i] = BytesFromLead(i); - } - initialisedBytesOfLead = true; - } -} - -// Return both the width of the first character in the string and a status -// saying whether it is valid or invalid. -// Most invalid sequences return a width of 1 so are treated as isolated bytes but -// the non-characters *FFFE, *FFFF and FDD0 .. FDEF return 3 or 4 as they can be -// reasonably treated as code points in some circumstances. They will, however, -// not have associated glyphs. -int UTF8Classify(const unsigned char *us, int len) { - // For the rules: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - if (*us < 0x80) { - // Single bytes easy - return 1; - } else if (*us > 0xf4) { - // Characters longer than 4 bytes not possible in current UTF-8 - return UTF8MaskInvalid | 1; - } else if (*us >= 0xf0) { - // 4 bytes - if (len < 4) - return UTF8MaskInvalid | 1; - if (UTF8IsTrailByte(us[1]) && UTF8IsTrailByte(us[2]) && UTF8IsTrailByte(us[3])) { - if (((us[1] & 0xf) == 0xf) && (us[2] == 0xbf) && ((us[3] == 0xbe) || (us[3] == 0xbf))) { - // *FFFE or *FFFF non-character - return UTF8MaskInvalid | 4; - } - if (*us == 0xf4) { - // Check if encoding a value beyond the last Unicode character 10FFFF - if (us[1] > 0x8f) { - return UTF8MaskInvalid | 1; - } else if (us[1] == 0x8f) { - if (us[2] > 0xbf) { - return UTF8MaskInvalid | 1; - } else if (us[2] == 0xbf) { - if (us[3] > 0xbf) { - return UTF8MaskInvalid | 1; - } - } - } - } else if ((*us == 0xf0) && ((us[1] & 0xf0) == 0x80)) { - // Overlong - return UTF8MaskInvalid | 1; - } - return 4; - } else { - return UTF8MaskInvalid | 1; - } - } else if (*us >= 0xe0) { - // 3 bytes - if (len < 3) - return UTF8MaskInvalid | 1; - if (UTF8IsTrailByte(us[1]) && UTF8IsTrailByte(us[2])) { - if ((*us == 0xe0) && ((us[1] & 0xe0) == 0x80)) { - // Overlong - return UTF8MaskInvalid | 1; - } - if ((*us == 0xed) && ((us[1] & 0xe0) == 0xa0)) { - // Surrogate - return UTF8MaskInvalid | 1; - } - if ((*us == 0xef) && (us[1] == 0xbf) && (us[2] == 0xbe)) { - // U+FFFE non-character - 3 bytes long - return UTF8MaskInvalid | 3; - } - if ((*us == 0xef) && (us[1] == 0xbf) && (us[2] == 0xbf)) { - // U+FFFF non-character - 3 bytes long - return UTF8MaskInvalid | 3; - } - if ((*us == 0xef) && (us[1] == 0xb7) && (((us[2] & 0xf0) == 0x90) || ((us[2] & 0xf0) == 0xa0))) { - // U+FDD0 .. U+FDEF - return UTF8MaskInvalid | 3; - } - return 3; - } else { - return UTF8MaskInvalid | 1; - } - } else if (*us >= 0xc2) { - // 2 bytes - if (len < 2) - return UTF8MaskInvalid | 1; - if (UTF8IsTrailByte(us[1])) { - return 2; - } else { - return UTF8MaskInvalid | 1; - } - } else { - // 0xc0 .. 0xc1 is overlong encoding - // 0x80 .. 0xbf is trail byte - return UTF8MaskInvalid | 1; - } -} - -int UTF8DrawBytes(const unsigned char *us, int len) { - int utf8StatusNext = UTF8Classify(us, len); - return (utf8StatusNext & UTF8MaskInvalid) ? 1 : (utf8StatusNext & UTF8MaskWidth); -} - -#ifdef SCI_NAMESPACE -} -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/UniConversion.h b/dep/scintilla/scintilla-3.6.0/src/UniConversion.h deleted file mode 100644 index 08898cac..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/UniConversion.h +++ /dev/null @@ -1,68 +0,0 @@ -// Scintilla source code edit control -/** @file UniConversion.h - ** Functions to handle UTF-8 and UTF-16 strings. - **/ -// Copyright 1998-2001 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef UNICONVERSION_H -#define UNICONVERSION_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -const int UTF8MaxBytes = 4; - -const int unicodeReplacementChar = 0xFFFD; - -unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen); -void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len); -unsigned int UTF8CharLength(unsigned char ch); -size_t UTF16Length(const char *s, size_t len); -size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen); -unsigned int UTF32FromUTF8(const char *s, unsigned int len, unsigned int *tbuf, unsigned int tlen); -unsigned int UTF16FromUTF32Character(unsigned int val, wchar_t *tbuf); - -extern int UTF8BytesOfLead[256]; -void UTF8BytesOfLeadInitialise(); - -inline bool UTF8IsTrailByte(int ch) { - return (ch >= 0x80) && (ch < 0xc0); -} - -inline bool UTF8IsAscii(int ch) { - return ch < 0x80; -} - -enum { UTF8MaskWidth=0x7, UTF8MaskInvalid=0x8 }; -int UTF8Classify(const unsigned char *us, int len); - -// Similar to UTF8Classify but returns a length of 1 for invalid bytes -// instead of setting the invalid flag -int UTF8DrawBytes(const unsigned char *us, int len); - -// Line separator is U+2028 \xe2\x80\xa8 -// Paragraph separator is U+2029 \xe2\x80\xa9 -const int UTF8SeparatorLength = 3; -inline bool UTF8IsSeparator(const unsigned char *us) { - return (us[0] == 0xe2) && (us[1] == 0x80) && ((us[2] == 0xa8) || (us[2] == 0xa9)); -} - -// NEL is U+0085 \xc2\x85 -const int UTF8NELLength = 2; -inline bool UTF8IsNEL(const unsigned char *us) { - return (us[0] == 0xc2) && (us[1] == 0x85); -} - -enum { SURROGATE_LEAD_FIRST = 0xD800 }; -enum { SURROGATE_LEAD_LAST = 0xDBFF }; -inline unsigned int UTF16CharLength(wchar_t uch) { - return ((uch >= SURROGATE_LEAD_FIRST) && (uch <= SURROGATE_LEAD_LAST)) ? 2 : 1; -} - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/src/UnicodeFromUTF8.h b/dep/scintilla/scintilla-3.6.0/src/UnicodeFromUTF8.h deleted file mode 100644 index ae66cb0a..00000000 --- a/dep/scintilla/scintilla-3.6.0/src/UnicodeFromUTF8.h +++ /dev/null @@ -1,32 +0,0 @@ -// Scintilla source code edit control -/** @file UnicodeFromUTF8.h - ** Lexer infrastructure. - **/ -// Copyright 2013 by Neil Hodgson -// This file is in the public domain. - -#ifndef UNICODEFROMUTF8_H -#define UNICODEFROMUTF8_H - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -inline int UnicodeFromUTF8(const unsigned char *us) { - if (us[0] < 0xC2) { - return us[0]; - } else if (us[0] < 0xE0) { - return ((us[0] & 0x1F) << 6) + (us[1] & 0x3F); - } else if (us[0] < 0xF0) { - return ((us[0] & 0xF) << 12) + ((us[1] & 0x3F) << 6) + (us[2] & 0x3F); - } else if (us[0] < 0xF5) { - return ((us[0] & 0x7) << 18) + ((us[1] & 0x3F) << 12) + ((us[2] & 0x3F) << 6) + (us[3] & 0x3F); - } - return us[0]; -} - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/dep/scintilla/scintilla-3.6.0/test/lexTests.py b/dep/scintilla/scintilla-3.6.0/test/lexTests.py deleted file mode 100644 index a53db7eb..00000000 --- a/dep/scintilla/scintilla-3.6.0/test/lexTests.py +++ /dev/null @@ -1,126 +0,0 @@ -# -*- coding: utf-8 -*- -# Requires Python 2.7 or later - -import io, os, sys, unittest - -if sys.platform == "win32": - import XiteWin as Xite -else: - import XiteQt as Xite - -keywordsHTML = [ -b"b body content head href html link meta " - b"name rel script strong title type xmlns", -b"function", -b"sub" -] - -class TestLexers(unittest.TestCase): - - def setUp(self): - self.xite = Xite.xiteFrame - self.ed = self.xite.ed - self.ed.ClearAll() - self.ed.EmptyUndoBuffer() - - def AsStyled(self): - text = self.ed.Contents() - data = io.BytesIO() - prevStyle = -1 - for o in range(self.ed.Length): - styleNow = self.ed.GetStyleAt(o) - if styleNow != prevStyle: - styleBuf = "{%0d}" % styleNow - data.write(styleBuf.encode('utf-8')) - prevStyle = styleNow - data.write(text[o:o+1]) - return data.getvalue() - - def LexExample(self, name, lexerName, keywords=None): - if keywords is None: - keywords = [] - self.ed.SetCodePage(65001) - self.ed.LexerLanguage = lexerName - bits = self.ed.StyleBitsNeeded - mask = 2 << bits - 1 - self.ed.StyleBits = bits - for i in range(len(keywords)): - self.ed.SetKeyWords(i, keywords[i]) - - nameExample = os.path.join("examples", name) - namePrevious = nameExample +".styled" - nameNew = nameExample +".new" - with open(nameExample, "rb") as f: - prog = f.read() - BOM = b"\xEF\xBB\xBF" - if prog.startswith(BOM): - prog = prog[len(BOM):] - lenDocument = len(prog) - self.ed.AddText(lenDocument, prog) - self.ed.Colourise(0, lenDocument) - self.assertEquals(self.ed.EndStyled, lenDocument) - try: - with open(namePrevious, "rb") as f: - prevStyled = f.read() - except FileNotFoundError: - prevStyled = "" - progStyled = self.AsStyled() - if progStyled != prevStyled: - with open(nameNew, "wb") as f: - f.write(progStyled) - print(progStyled) - print(prevStyled) - self.assertEquals(progStyled, prevStyled) - # The whole file doesn't parse like it did before so don't try line by line - # as that is likely to fail many times. - return - - # Try partial lexes from the start of every line which should all be identical. - for line in range(self.ed.LineCount): - lineStart = self.ed.PositionFromLine(line) - self.ed.StartStyling(lineStart, mask) - self.assertEquals(self.ed.EndStyled, lineStart) - self.ed.Colourise(lineStart, lenDocument) - progStyled = self.AsStyled() - if progStyled != prevStyled: - with open(nameNew, "wb") as f: - f.write(progStyled) - self.assertEquals(progStyled, prevStyled) - # Give up after one failure - return - - def testCXX(self): - self.LexExample("x.cxx", b"cpp", [b"int"]) - - def testPython(self): - self.LexExample("x.py", b"python", - [b"class def else for if import in print return while"]) - - def testHTML(self): - self.LexExample("x.html", b"hypertext", keywordsHTML) - - def testASP(self): - self.LexExample("x.asp", b"hypertext", keywordsHTML) - - def testPHP(self): - self.LexExample("x.php", b"hypertext", keywordsHTML) - - def testVB(self): - self.LexExample("x.vb", b"vb", [b"as dim or string"]) - - def testLua(self): - self.LexExample("x.lua", b"lua", [b"function end"]) - - def testRuby(self): - self.LexExample("x.rb", b"ruby", [b"class def end"]) - - def testPerl(self): - self.LexExample("x.pl", b"perl", [b"printf sleep use while"]) - - def testD(self): - self.LexExample("x.d", b"d", - [b"keyword1", b"keyword2", b"", b"keyword4", b"keyword5", - b"keyword6", b"keyword7"]) - -if __name__ == '__main__': - Xite.main("lexTests") diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/catch.hpp b/dep/scintilla/scintilla-3.6.0/test/unit/catch.hpp deleted file mode 100644 index a8aec02d..00000000 --- a/dep/scintilla/scintilla-3.6.0/test/unit/catch.hpp +++ /dev/null @@ -1,8734 +0,0 @@ -/* - * CATCH v1.0 build 47 (master branch) - * Generated: 2014-05-20 19:02:15.946806 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED - -#define TWOBLUECUBES_CATCH_HPP_INCLUDED - -// #included from: internal/catch_suppress_warnings.h - -#define TWOBLUECUBES_CATCH_SUPPRESS_WARNINGS_H_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wglobal-constructors" -#pragma clang diagnostic ignored "-Wvariadic-macros" -#pragma clang diagnostic ignored "-Wc99-extensions" -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#pragma clang diagnostic ignored "-Wc++98-compat" -#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif - -#ifdef CATCH_CONFIG_MAIN -# define CATCH_CONFIG_RUNNER -#endif - -#ifdef CATCH_CONFIG_RUNNER -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// #included from: internal/catch_notimplemented_exception.h -#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED - -// #included from: catch_common.h -#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED - -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) - -#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr -#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr ) - -#include -#include -#include - -// #included from: catch_compiler_capabilities.h -#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED - -// Much of the following code is based on Boost (1.53) - -#ifdef __clang__ - -# if __has_feature(cxx_nullptr) -# define CATCH_CONFIG_CPP11_NULLPTR -# endif - -# if __has_feature(cxx_noexcept) -# define CATCH_CONFIG_CPP11_NOEXCEPT -# endif - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Borland -#ifdef __BORLANDC__ - -#if (__BORLANDC__ > 0x582 ) -//#define CATCH_CONFIG_SFINAE // Not confirmed -#endif - -#endif // __BORLANDC__ - -//////////////////////////////////////////////////////////////////////////////// -// EDG -#ifdef __EDG_VERSION__ - -#if (__EDG_VERSION__ > 238 ) -//#define CATCH_CONFIG_SFINAE // Not confirmed -#endif - -#endif // __EDG_VERSION__ - -//////////////////////////////////////////////////////////////////////////////// -// Digital Mars -#ifdef __DMC__ - -#if (__DMC__ > 0x840 ) -//#define CATCH_CONFIG_SFINAE // Not confirmed -#endif - -#endif // __DMC__ - -//////////////////////////////////////////////////////////////////////////////// -// GCC -#ifdef __GNUC__ - -#if __GNUC__ < 3 - -#if (__GNUC_MINOR__ >= 96 ) -//#define CATCH_CONFIG_SFINAE -#endif - -#elif __GNUC__ >= 3 - -// #define CATCH_CONFIG_SFINAE // Taking this out completely for now - -#endif // __GNUC__ < 3 - -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) ) - -#define CATCH_CONFIG_CPP11_NULLPTR -#endif - -#endif // __GNUC__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#ifdef _MSC_VER - -#if (_MSC_VER >= 1310 ) // (VC++ 7.0+) -//#define CATCH_CONFIG_SFINAE // Not confirmed -#endif - -#endif // _MSC_VER - -// Use variadic macros if the compiler supports them -#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \ - ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \ - ( defined __GNUC__ && __GNUC__ >= 3 ) || \ - ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) - -#ifndef CATCH_CONFIG_NO_VARIADIC_MACROS -#define CATCH_CONFIG_VARIADIC_MACROS -#endif - -#endif - -//////////////////////////////////////////////////////////////////////////////// -// C++ language feature support - -// detect language version: -#if (__cplusplus == 201103L) -# define CATCH_CPP11 -# define CATCH_CPP11_OR_GREATER -#elif (__cplusplus >= 201103L) -# define CATCH_CPP11_OR_GREATER -#endif - -// noexcept support: -#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) -# define CATCH_NOEXCEPT noexcept -# define CATCH_NOEXCEPT_IS(x) noexcept(x) -#else -# define CATCH_NOEXCEPT throw() -# define CATCH_NOEXCEPT_IS(x) -#endif - -namespace Catch { - - class NonCopyable { - NonCopyable( NonCopyable const& ); - void operator = ( NonCopyable const& ); - protected: - NonCopyable() {} - virtual ~NonCopyable(); - }; - - class SafeBool { - public: - typedef void (SafeBool::*type)() const; - - static type makeSafe( bool value ) { - return value ? &SafeBool::trueValue : 0; - } - private: - void trueValue() const {} - }; - - template - inline void deleteAll( ContainerT& container ) { - typename ContainerT::const_iterator it = container.begin(); - typename ContainerT::const_iterator itEnd = container.end(); - for(; it != itEnd; ++it ) - delete *it; - } - template - inline void deleteAllValues( AssociativeContainerT& container ) { - typename AssociativeContainerT::const_iterator it = container.begin(); - typename AssociativeContainerT::const_iterator itEnd = container.end(); - for(; it != itEnd; ++it ) - delete it->second; - } - - bool startsWith( std::string const& s, std::string const& prefix ); - bool endsWith( std::string const& s, std::string const& suffix ); - bool contains( std::string const& s, std::string const& infix ); - void toLowerInPlace( std::string& s ); - std::string toLower( std::string const& s ); - std::string trim( std::string const& str ); - - struct pluralise { - pluralise( std::size_t count, std::string const& label ); - - friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); - - std::size_t m_count; - std::string m_label; - }; - - struct SourceLineInfo { - - SourceLineInfo(); - SourceLineInfo( char const* _file, std::size_t _line ); - SourceLineInfo( SourceLineInfo const& other ); -# ifdef CATCH_CPP11_OR_GREATER - SourceLineInfo( SourceLineInfo && ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo& operator = ( SourceLineInfo && ) = default; -# endif - bool empty() const; - bool operator == ( SourceLineInfo const& other ) const; - - std::string file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // This is just here to avoid compiler warnings with macro constants and boolean literals - inline bool isTrue( bool value ){ return value; } - - void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() { - return std::string(); - } - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) -#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO ); - -#include - -namespace Catch { - - class NotImplementedException : public std::exception - { - public: - NotImplementedException( SourceLineInfo const& lineInfo ); - NotImplementedException( NotImplementedException const& ) {} - - virtual ~NotImplementedException() CATCH_NOEXCEPT {} - - virtual const char* what() const CATCH_NOEXCEPT; - - private: - std::string m_what; - SourceLineInfo m_lineInfo; - }; - -} // end namespace Catch - -/////////////////////////////////////////////////////////////////////////////// -#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO ) - -// #included from: internal/catch_context.h -#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED - -// #included from: catch_interfaces_generators.h -#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED - -#include - -namespace Catch { - - struct IGeneratorInfo { - virtual ~IGeneratorInfo(); - virtual bool moveNext() = 0; - virtual std::size_t getCurrentIndex() const = 0; - }; - - struct IGeneratorsForTest { - virtual ~IGeneratorsForTest(); - - virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0; - virtual bool moveNext() = 0; - }; - - IGeneratorsForTest* createGeneratorsForTest(); - -} // end namespace Catch - -// #included from: catch_ptr.hpp -#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - - // An intrusive reference counting smart pointer. - // T must implement addRef() and release() methods - // typically implementing the IShared interface - template - class Ptr { - public: - Ptr() : m_p( NULL ){} - Ptr( T* p ) : m_p( p ){ - if( m_p ) - m_p->addRef(); - } - Ptr( Ptr const& other ) : m_p( other.m_p ){ - if( m_p ) - m_p->addRef(); - } - ~Ptr(){ - if( m_p ) - m_p->release(); - } - void reset() { - if( m_p ) - m_p->release(); - m_p = NULL; - } - Ptr& operator = ( T* p ){ - Ptr temp( p ); - swap( temp ); - return *this; - } - Ptr& operator = ( Ptr const& other ){ - Ptr temp( other ); - swap( temp ); - return *this; - } - void swap( Ptr& other ) { std::swap( m_p, other.m_p ); } - T* get() { return m_p; } - const T* get() const{ return m_p; } - T& operator*() const { return *m_p; } - T* operator->() const { return m_p; } - bool operator !() const { return m_p == NULL; } - operator SafeBool::type() const { return SafeBool::makeSafe( m_p != NULL ); } - - private: - T* m_p; - }; - - struct IShared : NonCopyable { - virtual ~IShared(); - virtual void addRef() const = 0; - virtual void release() const = 0; - }; - - template - struct SharedImpl : T { - - SharedImpl() : m_rc( 0 ){} - - virtual void addRef() const { - ++m_rc; - } - virtual void release() const { - if( --m_rc == 0 ) - delete this; - } - - mutable unsigned int m_rc; - }; - -} // end namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#include -#include -#include - -namespace Catch { - - class TestCase; - class Stream; - struct IResultCapture; - struct IRunner; - struct IGeneratorsForTest; - struct IConfig; - - struct IContext - { - virtual ~IContext(); - - virtual IResultCapture* getResultCapture() = 0; - virtual IRunner* getRunner() = 0; - virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0; - virtual bool advanceGeneratorsForCurrentTest() = 0; - virtual Ptr getConfig() const = 0; - }; - - struct IMutableContext : IContext - { - virtual ~IMutableContext(); - virtual void setResultCapture( IResultCapture* resultCapture ) = 0; - virtual void setRunner( IRunner* runner ) = 0; - virtual void setConfig( Ptr const& config ) = 0; - }; - - IContext& getCurrentContext(); - IMutableContext& getCurrentMutableContext(); - void cleanUpContext(); - Stream createStream( std::string const& streamName ); - -} - -// #included from: internal/catch_test_registry.hpp -#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED - -// #included from: catch_interfaces_testcase.h -#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED - -#include - -namespace Catch { - - class TestSpec; - - struct ITestCase : IShared { - virtual void invoke () const = 0; - protected: - virtual ~ITestCase(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector& matchingTestCases ) const = 0; - - }; -} - -namespace Catch { - -template -class MethodTestCase : public SharedImpl { - -public: - MethodTestCase( void (C::*method)() ) : m_method( method ) {} - - virtual void invoke() const { - C obj; - (obj.*m_method)(); - } - -private: - virtual ~MethodTestCase() {} - - void (C::*m_method)(); -}; - -typedef void(*TestFunction)(); - -struct NameAndDesc { - NameAndDesc( const char* _name = "", const char* _description= "" ) - : name( _name ), description( _description ) - {} - - const char* name; - const char* description; -}; - -struct AutoReg { - - AutoReg( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ); - - template - AutoReg( void (C::*method)(), - char const* className, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ) { - registerTestCase( new MethodTestCase( method ), - className, - nameAndDesc, - lineInfo ); - } - - void registerTestCase( ITestCase* testCase, - char const* className, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ); - - ~AutoReg(); - -private: - AutoReg( AutoReg const& ); - void operator= ( AutoReg const& ); -}; - -} // end namespace Catch - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TESTCASE( ... ) \ - static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\ - static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )() - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... )\ - namespace{ \ - struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \ - void test(); \ - }; \ - Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \ - } \ - void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test() - -#else - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \ - static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\ - static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )() - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\ - namespace{ \ - struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \ - void test(); \ - }; \ - Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \ - } \ - void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test() - -#endif - -// #included from: internal/catch_capture.hpp -#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED - -// #included from: catch_expression_decomposer.hpp -#define TWOBLUECUBES_CATCH_EXPRESSION_DECOMPOSER_HPP_INCLUDED - -// #included from: catch_expression_lhs.hpp -#define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED - -// #included from: catch_expressionresult_builder.h -#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_BUILDER_H_INCLUDED - -// #included from: catch_tostring.h -#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED - -// #included from: catch_sfinae.hpp -#define TWOBLUECUBES_CATCH_SFINAE_HPP_INCLUDED - -// Try to detect if the current compiler supports SFINAE - -namespace Catch { - - struct TrueType { - static const bool value = true; - typedef void Enable; - char sizer[1]; - }; - struct FalseType { - static const bool value = false; - typedef void Disable; - char sizer[2]; - }; - -#ifdef CATCH_CONFIG_SFINAE - - template struct NotABooleanExpression; - - template struct If : NotABooleanExpression {}; - template<> struct If : TrueType {}; - template<> struct If : FalseType {}; - - template struct SizedIf; - template<> struct SizedIf : TrueType {}; - template<> struct SizedIf : FalseType {}; - -#endif // CATCH_CONFIG_SFINAE - -} // end namespace Catch - -#include -#include -#include -#include -#include - -#ifdef __OBJC__ -// #included from: catch_objc_arc.hpp -#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED - -#import - -#ifdef __has_feature -#define CATCH_ARC_ENABLED __has_feature(objc_arc) -#else -#define CATCH_ARC_ENABLED 0 -#endif - -void arcSafeRelease( NSObject* obj ); -id performOptionalSelector( id obj, SEL sel ); - -#if !CATCH_ARC_ENABLED -inline void arcSafeRelease( NSObject* obj ) { - [obj release]; -} -inline id performOptionalSelector( id obj, SEL sel ) { - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; - return nil; -} -#define CATCH_UNSAFE_UNRETAINED -#define CATCH_ARC_STRONG -#else -inline void arcSafeRelease( NSObject* ){} -inline id performOptionalSelector( id obj, SEL sel ) { -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-performSelector-leaks" -#endif - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - return nil; -} -#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained -#define CATCH_ARC_STRONG __strong -#endif - -#endif - -namespace Catch { -namespace Detail { - -// SFINAE is currently disabled by default for all compilers. -// If the non SFINAE version of IsStreamInsertable is ambiguous for you -// and your compiler supports SFINAE, try #defining CATCH_CONFIG_SFINAE -#ifdef CATCH_CONFIG_SFINAE - - template - class IsStreamInsertableHelper { - template struct TrueIfSizeable : TrueType {}; - - template - static TrueIfSizeable dummy(T2*); - static FalseType dummy(...); - - public: - typedef SizedIf type; - }; - - template - struct IsStreamInsertable : IsStreamInsertableHelper::type {}; - -#else - - struct BorgType { - template BorgType( T const& ); - }; - - TrueType& testStreamable( std::ostream& ); - FalseType testStreamable( FalseType ); - - FalseType operator<<( std::ostream const&, BorgType const& ); - - template - struct IsStreamInsertable { - static std::ostream &s; - static T const&t; - enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) }; - }; - -#endif - - template - struct StringMakerBase { - template - static std::string convert( T const& ) { return "{?}"; } - }; - - template<> - struct StringMakerBase { - template - static std::string convert( T const& _value ) { - std::ostringstream oss; - oss << _value; - return oss.str(); - } - }; - - struct Endianness { - enum Arch { Big, Little }; - - static Arch which() { - union _{ - int asInt; - char asChar[sizeof (int)]; - } u; - - u.asInt = 1; - return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little; - } - }; - - // Writes the raw memory into a string, considering endianness - template - std::string rawMemoryToString( T value ) { - union _ { - T typedValue; - unsigned char bytes[sizeof(T)]; - } u; - - u.typedValue = value; - - std::ostringstream oss; - oss << "0x"; - - int i = 0, end = sizeof(T), inc = 1; - if( Endianness::which() == Endianness::Little ) { - i = end-1; - end = inc = -1; - } - for( ; i != end; i += inc ) - oss << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)u.bytes[i]; - return oss.str(); - } - -} // end namespace Detail - -template -std::string toString( T const& value ); - -template -struct StringMaker : - Detail::StringMakerBase::value> {}; - -template -struct StringMaker { - template - static std::string convert( U* p ) { - if( !p ) - return INTERNAL_CATCH_STRINGIFY( NULL ); - else - return Detail::rawMemoryToString( p ); - } -}; - -template -struct StringMaker { - static std::string convert( R C::* p ) { - if( !p ) - return INTERNAL_CATCH_STRINGIFY( NULL ); - else - return Detail::rawMemoryToString( p ); - } -}; - -namespace Detail { - template - std::string rangeToString( InputIterator first, InputIterator last ); -} - -template -struct StringMaker > { - static std::string convert( std::vector const& v ) { - return Detail::rangeToString( v.begin(), v.end() ); - } -}; - -namespace Detail { - template - std::string makeString( T const& value ) { - return StringMaker::convert( value ); - } -} // end namespace Detail - -/// \brief converts any type to a string -/// -/// The default template forwards on to ostringstream - except when an -/// ostringstream overload does not exist - in which case it attempts to detect -/// that and writes {?}. -/// Overload (not specialise) this template for custom typs that you don't want -/// to provide an ostream overload for. -template -std::string toString( T const& value ) { - return StringMaker::convert( value ); -} - -// Built in overloads - -std::string toString( std::string const& value ); -std::string toString( std::wstring const& value ); -std::string toString( const char* const value ); -std::string toString( char* const value ); -std::string toString( int value ); -std::string toString( unsigned long value ); -std::string toString( unsigned int value ); -std::string toString( const double value ); -std::string toString( bool value ); -std::string toString( char value ); -std::string toString( signed char value ); -std::string toString( unsigned char value ); - -#ifdef CATCH_CONFIG_CPP11_NULLPTR -std::string toString( std::nullptr_t ); -#endif - -#ifdef __OBJC__ - std::string toString( NSString const * const& nsstring ); - std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ); - std::string toString( NSObject* const& nsObject ); -#endif - - namespace Detail { - template - std::string rangeToString( InputIterator first, InputIterator last ) { - std::ostringstream oss; - oss << "{ "; - if( first != last ) { - oss << toString( *first ); - for( ++first ; first != last ; ++first ) { - oss << ", " << toString( *first ); - } - } - oss << " }"; - return oss.str(); - } -} - -} // end namespace Catch - -// #included from: catch_assertionresult.h -#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED - -#include -// #included from: catch_result_type.h -#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED - -namespace Catch { - - // ResultWas::OfType enum - struct ResultWas { enum OfType { - Unknown = -1, - Ok = 0, - Info = 1, - Warning = 2, - - FailureBit = 0x10, - - ExpressionFailed = FailureBit | 1, - ExplicitFailure = FailureBit | 2, - - Exception = 0x100 | FailureBit, - - ThrewException = Exception | 1, - DidntThrowException = Exception | 2 - - }; }; - - inline bool isOk( ResultWas::OfType resultType ) { - return ( resultType & ResultWas::FailureBit ) == 0; - } - inline bool isJustInfo( int flags ) { - return flags == ResultWas::Info; - } - - // ResultAction::Value enum - struct ResultAction { enum Value { - None, - Failed = 1, // Failure - but no debug break if Debug bit not set - Debug = 2, // If this bit is set, invoke the debugger - Abort = 4 // Test run should abort - }; }; - - // ResultDisposition::Flags enum - struct ResultDisposition { enum Flags { - Normal = 0x00, - - ContinueOnFailure = 0x01, // Failures fail test, but execution continues - NegateResult = 0x02, // Prefix expressiom with ! - SuppressFail = 0x04 // Failures are reported but do not fail the test - }; }; - - inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { - return static_cast( static_cast( lhs ) | static_cast( rhs ) ); - } - - inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } - inline bool shouldNegate( int flags ) { return ( flags & ResultDisposition::NegateResult ) != 0; } - inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } - -} // end namespace Catch - - -namespace Catch { - - struct AssertionInfo - { - AssertionInfo() {} - AssertionInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - std::string const& _capturedExpression, - ResultDisposition::Flags _resultDisposition ); - - std::string macroName; - SourceLineInfo lineInfo; - std::string capturedExpression; - ResultDisposition::Flags resultDisposition; - }; - - struct AssertionResultData - { - AssertionResultData() : resultType( ResultWas::Unknown ) {} - - std::string reconstructedExpression; - std::string message; - ResultWas::OfType resultType; - }; - - class AssertionResult { - public: - AssertionResult(); - AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); - ~AssertionResult(); -# ifdef CATCH_CPP11_OR_GREATER - AssertionResult( AssertionResult const& ) = default; - AssertionResult( AssertionResult && ) = default; - AssertionResult& operator = ( AssertionResult const& ) = default; - AssertionResult& operator = ( AssertionResult && ) = default; -# endif - - bool isOk() const; - bool succeeded() const; - ResultWas::OfType getResultType() const; - bool hasExpression() const; - bool hasMessage() const; - std::string getExpression() const; - std::string getExpressionInMacro() const; - bool hasExpandedExpression() const; - std::string getExpandedExpression() const; - std::string getMessage() const; - SourceLineInfo getSourceInfo() const; - std::string getTestMacroName() const; - - protected: - AssertionInfo m_info; - AssertionResultData m_resultData; - }; - -} // end namespace Catch - -// #included from: catch_evaluate.hpp -#define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4389) // '==' : signed/unsigned mismatch -#endif - -#include - -namespace Catch { -namespace Internal { - - enum Operator { - IsEqualTo, - IsNotEqualTo, - IsLessThan, - IsGreaterThan, - IsLessThanOrEqualTo, - IsGreaterThanOrEqualTo - }; - - template struct OperatorTraits { static const char* getName(){ return "*error*"; } }; - template<> struct OperatorTraits { static const char* getName(){ return "=="; } }; - template<> struct OperatorTraits { static const char* getName(){ return "!="; } }; - template<> struct OperatorTraits { static const char* getName(){ return "<"; } }; - template<> struct OperatorTraits { static const char* getName(){ return ">"; } }; - template<> struct OperatorTraits { static const char* getName(){ return "<="; } }; - template<> struct OperatorTraits{ static const char* getName(){ return ">="; } }; - - template - inline T& opCast(T const& t) { return const_cast(t); } - -// nullptr_t support based on pull request #154 from Konstantin Baumann -#ifdef CATCH_CONFIG_CPP11_NULLPTR - inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; } -#endif // CATCH_CONFIG_CPP11_NULLPTR - - // So the compare overloads can be operator agnostic we convey the operator as a template - // enum, which is used to specialise an Evaluator for doing the comparison. - template - class Evaluator{}; - - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs) { - return opCast( lhs ) == opCast( rhs ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return opCast( lhs ) != opCast( rhs ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return opCast( lhs ) < opCast( rhs ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return opCast( lhs ) > opCast( rhs ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return opCast( lhs ) >= opCast( rhs ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return opCast( lhs ) <= opCast( rhs ); - } - }; - - template - bool applyEvaluator( T1 const& lhs, T2 const& rhs ) { - return Evaluator::evaluate( lhs, rhs ); - } - - // This level of indirection allows us to specialise for integer types - // to avoid signed/ unsigned warnings - - // "base" overload - template - bool compare( T1 const& lhs, T2 const& rhs ) { - return Evaluator::evaluate( lhs, rhs ); - } - - // unsigned X to int - template bool compare( unsigned int lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned long lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned char lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - - // unsigned X to long - template bool compare( unsigned int lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned long lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned char lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - - // int to unsigned X - template bool compare( int lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( int lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( int lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // long to unsigned X - template bool compare( long lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // pointer to long (when comparing against NULL) - template bool compare( long lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, long rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } - - // pointer to int (when comparing against NULL) - template bool compare( int lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, int rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } - -#ifdef CATCH_CONFIG_CPP11_NULLPTR - // pointer to nullptr_t (when comparing against nullptr) - template bool compare( std::nullptr_t, T* rhs ) { - return Evaluator::evaluate( NULL, rhs ); - } - template bool compare( T* lhs, std::nullptr_t ) { - return Evaluator::evaluate( lhs, NULL ); - } -#endif // CATCH_CONFIG_CPP11_NULLPTR - -} // end of namespace Internal -} // end of namespace Catch - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -namespace Catch { - -struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; - -// Wraps the (stringised versions of) the lhs, operator and rhs of an expression - as well as -// the result of evaluating it. This is used to build an AssertionResult object -class ExpressionResultBuilder { -public: - - ExpressionResultBuilder( ResultWas::OfType resultType = ResultWas::Unknown ); - ExpressionResultBuilder( ExpressionResultBuilder const& other ); - ExpressionResultBuilder& operator=(ExpressionResultBuilder const& other ); - - ExpressionResultBuilder& setResultType( ResultWas::OfType result ); - ExpressionResultBuilder& setResultType( bool result ); - ExpressionResultBuilder& setLhs( std::string const& lhs ); - ExpressionResultBuilder& setRhs( std::string const& rhs ); - ExpressionResultBuilder& setOp( std::string const& op ); - - ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition ); - - template - ExpressionResultBuilder& operator << ( T const& value ) { - m_stream << value; - return *this; - } - - std::string reconstructExpression( AssertionInfo const& info ) const; - - AssertionResult buildResult( AssertionInfo const& info ) const; - - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& ); - -private: - AssertionResultData m_data; - struct ExprComponents { - ExprComponents() : shouldNegate( false ) {} - bool shouldNegate; - std::string lhs, rhs, op; - } m_exprComponents; - std::ostringstream m_stream; -}; - -} // end namespace Catch - -namespace Catch { - -// Wraps the LHS of an expression and captures the operator and RHS (if any) - -// wrapping them all in an ExpressionResultBuilder object -template -class ExpressionLhs { - ExpressionLhs& operator = ( ExpressionLhs const& ); -# ifdef CATCH_CPP11_OR_GREATER - ExpressionLhs& operator = ( ExpressionLhs && ) = delete; -# endif - -public: - ExpressionLhs( T lhs ) : m_lhs( lhs ) {} -# ifdef CATCH_CPP11_OR_GREATER - ExpressionLhs( ExpressionLhs const& ) = default; - ExpressionLhs( ExpressionLhs && ) = default; -# endif - - template - ExpressionResultBuilder& operator == ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ExpressionResultBuilder& operator != ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ExpressionResultBuilder& operator < ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ExpressionResultBuilder& operator > ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ExpressionResultBuilder& operator <= ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - ExpressionResultBuilder& operator >= ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - ExpressionResultBuilder& operator == ( bool rhs ) { - return captureExpression( rhs ); - } - - ExpressionResultBuilder& operator != ( bool rhs ) { - return captureExpression( rhs ); - } - - ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition ) { - bool value = m_lhs ? true : false; - return m_result - .setLhs( Catch::toString( value ) ) - .setResultType( value ) - .endExpression( resultDisposition ); - } - - // Only simple binary expressions are allowed on the LHS. - // If more complex compositions are required then place the sub expression in parentheses - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& ); - -private: - template - ExpressionResultBuilder& captureExpression( RhsT const& rhs ) { - return m_result - .setResultType( Internal::compare( m_lhs, rhs ) ) - .setLhs( Catch::toString( m_lhs ) ) - .setRhs( Catch::toString( rhs ) ) - .setOp( Internal::OperatorTraits::getName() ); - } - -private: - ExpressionResultBuilder m_result; - T m_lhs; -}; - -} // end namespace Catch - -namespace Catch { - -// Captures the LHS of the expression and wraps it in an Expression Lhs object -class ExpressionDecomposer { -public: - - template - ExpressionLhs operator->* ( T const& operand ) { - return ExpressionLhs( operand ); - } - - ExpressionLhs operator->* ( bool value ) { - return ExpressionLhs( value ); - } -}; - -} // end namespace Catch - -// #included from: catch_message.h -#define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED - -#include - -namespace Catch { - - struct MessageInfo { - MessageInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ); - - std::string macroName; - SourceLineInfo lineInfo; - ResultWas::OfType type; - std::string message; - unsigned int sequence; - - bool operator == ( MessageInfo const& other ) const { - return sequence == other.sequence; - } - bool operator < ( MessageInfo const& other ) const { - return sequence < other.sequence; - } - private: - static unsigned int globalCount; - }; - - struct MessageBuilder { - MessageBuilder( std::string const& macroName, - SourceLineInfo const& lineInfo, - ResultWas::OfType type ) - : m_info( macroName, lineInfo, type ) - {} - - template - MessageBuilder& operator << ( T const& value ) { - m_stream << value; - return *this; - } - - MessageInfo m_info; - std::ostringstream m_stream; - }; - - class ScopedMessage { - public: - ScopedMessage( MessageBuilder const& builder ); - ScopedMessage( ScopedMessage const& other ); - ~ScopedMessage(); - - MessageInfo m_info; - }; - -} // end namespace Catch - -// #included from: catch_interfaces_capture.h -#define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED - -#include - -namespace Catch { - - class TestCase; - class ExpressionResultBuilder; - class AssertionResult; - struct AssertionInfo; - struct SectionInfo; - struct MessageInfo; - class ScopedMessageBuilder; - struct Counts; - - struct IResultCapture { - - virtual ~IResultCapture(); - - virtual void assertionEnded( AssertionResult const& result ) = 0; - virtual bool sectionStarted( SectionInfo const& sectionInfo, - Counts& assertions ) = 0; - virtual void sectionEnded( SectionInfo const& name, Counts const& assertions, double _durationInSeconds ) = 0; - virtual void pushScopedMessage( MessageInfo const& message ) = 0; - virtual void popScopedMessage( MessageInfo const& message ) = 0; - - virtual bool shouldDebugBreak() const = 0; - - virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) = 0; - - virtual std::string getCurrentTestName() const = 0; - virtual const AssertionResult* getLastResult() const = 0; - }; -} - -// #included from: catch_debugger.h -#define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED - -// #included from: catch_platform.h -#define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED - -#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -#define CATCH_PLATFORM_MAC -#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -#define CATCH_PLATFORM_IPHONE -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) -#define CATCH_PLATFORM_WINDOWS -#endif - -#include - -namespace Catch{ - - bool isDebuggerActive(); - void writeToDebugConsole( std::string const& text ); -} - -#ifdef CATCH_PLATFORM_MAC - - // The following code snippet based on: - // http://cocoawithlove.com/2008/03/break-into-debugger.html - #ifdef DEBUG - #if defined(__ppc64__) || defined(__ppc__) - #define CATCH_BREAK_INTO_DEBUGGER() \ - if( Catch::isDebuggerActive() ) { \ - __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ - : : : "memory","r0","r3","r4" ); \ - } - #else - #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );} - #endif - #endif - -#elif defined(_MSC_VER) - #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { __debugbreak(); } -#elif defined(__MINGW32__) - extern "C" __declspec(dllimport) void __stdcall DebugBreak(); - #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { DebugBreak(); } -#endif - -#ifndef CATCH_BREAK_INTO_DEBUGGER -#define CATCH_BREAK_INTO_DEBUGGER() Catch::isTrue( true ); -#endif - -// #included from: catch_interfaces_registry_hub.h -#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED - -#include - -namespace Catch { - - class TestCase; - struct ITestCaseRegistry; - struct IExceptionTranslatorRegistry; - struct IExceptionTranslator; - struct IReporterRegistry; - struct IReporterFactory; - - struct IRegistryHub { - virtual ~IRegistryHub(); - - virtual IReporterRegistry const& getReporterRegistry() const = 0; - virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; - virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; - }; - - struct IMutableRegistryHub { - virtual ~IMutableRegistryHub(); - virtual void registerReporter( std::string const& name, IReporterFactory* factory ) = 0; - virtual void registerTest( TestCase const& testInfo ) = 0; - virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; - }; - - IRegistryHub& getRegistryHub(); - IMutableRegistryHub& getMutableRegistryHub(); - void cleanUp(); - std::string translateActiveException(); - -} - -// #included from: catch_interfaces_config.h -#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED - -#include -#include -#include - -namespace Catch { - - struct Verbosity { enum Level { - NoOutput = 0, - Quiet, - Normal - }; }; - - struct WarnAbout { enum What { - Nothing = 0x00, - NoAssertions = 0x01 - }; }; - - struct ShowDurations { enum OrNot { - DefaultForReporter, - Always, - Never - }; }; - - class TestSpec; - - struct IConfig : IShared { - - virtual ~IConfig(); - - virtual bool allowThrows() const = 0; - virtual std::ostream& stream() const = 0; - virtual std::string name() const = 0; - virtual bool includeSuccessfulResults() const = 0; - virtual bool shouldDebugBreak() const = 0; - virtual bool warnAboutMissingAssertions() const = 0; - virtual int abortAfter() const = 0; - virtual bool showInvisibles() const = 0; - virtual ShowDurations::OrNot showDurations() const = 0; - virtual TestSpec const& testSpec() const = 0; - }; -} - -#include - -namespace Catch { - - inline IResultCapture& getResultCapture() { - if( IResultCapture* capture = getCurrentContext().getResultCapture() ) - return *capture; - else - throw std::logic_error( "No result capture instance" ); - } - - template - ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher, - std::string const& matcherCallAsString ) { - std::string matcherAsString = matcher.toString(); - if( matcherAsString == "{?}" ) - matcherAsString = matcherCallAsString; - return ExpressionResultBuilder() - .setRhs( matcherAsString ) - .setOp( "matches" ); - } - - template - ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher, - ArgT const& arg, - std::string const& matcherCallAsString ) { - return expressionResultBuilderFromMatcher( matcher, matcherCallAsString ) - .setLhs( Catch::toString( arg ) ) - .setResultType( matcher.match( arg ) ); - } - - template - ExpressionResultBuilder expressionResultBuilderFromMatcher( MatcherT const& matcher, - ArgT* arg, - std::string const& matcherCallAsString ) { - return expressionResultBuilderFromMatcher( matcher, matcherCallAsString ) - .setLhs( Catch::toString( arg ) ) - .setResultType( matcher.match( arg ) ); - } - -struct TestFailureException{}; - -} // end namespace Catch - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_ACCEPT_EXPR( evaluatedExpr, resultDisposition, originalExpr ) \ - if( Catch::ResultAction::Value internal_catch_action = Catch::getResultCapture().acceptExpression( evaluatedExpr, __assertionInfo ) ) { \ - if( internal_catch_action & Catch::ResultAction::Debug ) CATCH_BREAK_INTO_DEBUGGER(); \ - if( internal_catch_action & Catch::ResultAction::Abort ) throw Catch::TestFailureException(); \ - if( !Catch::shouldContinueOnFailure( resultDisposition ) ) throw Catch::TestFailureException(); \ - Catch::isTrue( false && originalExpr ); \ - } - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \ - do { \ - Catch::AssertionInfo __assertionInfo( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - try { \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionDecomposer()->*expr ).endExpression( resultDisposition ), resultDisposition, expr ); \ - } catch( Catch::TestFailureException& ) { \ - throw; \ - } catch( ... ) { \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), \ - Catch::ResultDisposition::Normal, expr ); \ - } \ - } while( Catch::isTrue( false ) ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ - INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ - if( Catch::getResultCapture().getLastResult()->succeeded() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \ - INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \ - if( !Catch::getResultCapture().getLastResult()->succeeded() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \ - do { \ - Catch::AssertionInfo __assertionInfo( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - try { \ - expr; \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), resultDisposition, false ); \ - } \ - catch( ... ) { \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException(), resultDisposition, false ); \ - } \ -} while( Catch::isTrue( false ) ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \ - try { \ - if( Catch::getCurrentContext().getConfig()->allowThrows() ) { \ - expr; \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::DidntThrowException ), resultDisposition, false ); \ - } \ - } \ - catch( Catch::TestFailureException& ) { \ - throw; \ - } \ - catch( exceptionType ) { \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( Catch::ResultWas::Ok ), resultDisposition, false ); \ - } - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_THROWS( expr, exceptionType, resultDisposition, macroName ) \ - do { \ - Catch::AssertionInfo __assertionInfo( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \ - } while( Catch::isTrue( false ) ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \ - do { \ - Catch::AssertionInfo __assertionInfo( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \ - catch( ... ) { \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), \ - resultDisposition | Catch::ResultDisposition::ContinueOnFailure, false ); \ - } \ - } while( Catch::isTrue( false ) ) - -/////////////////////////////////////////////////////////////////////////////// -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, ... ) \ - do { \ - Catch::AssertionInfo __assertionInfo( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( messageType ) << __VA_ARGS__ +::Catch::StreamEndStop(), resultDisposition, true ) \ - } while( Catch::isTrue( false ) ) -#else - #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, log ) \ - do { \ - Catch::AssertionInfo __assertionInfo( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ - INTERNAL_CATCH_ACCEPT_EXPR( Catch::ExpressionResultBuilder( messageType ) << log, resultDisposition, true ) \ - } while( Catch::isTrue( false ) ) -#endif - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_INFO( log, macroName ) \ - Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log; - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \ - do { \ - Catch::AssertionInfo __assertionInfo( macroName, CATCH_INTERNAL_LINEINFO, #arg " " #matcher, resultDisposition ); \ - try { \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::expressionResultBuilderFromMatcher( ::Catch::Matchers::matcher, arg, #matcher ) ), resultDisposition, false ); \ - } catch( Catch::TestFailureException& ) { \ - throw; \ - } catch( ... ) { \ - INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionResultBuilder( Catch::ResultWas::ThrewException ) << Catch::translateActiveException() ), \ - resultDisposition | Catch::ResultDisposition::ContinueOnFailure, false ); \ - } \ - } while( Catch::isTrue( false ) ) - -// #included from: internal/catch_section.h -#define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED - -// #included from: catch_section_info.h -#define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED - -namespace Catch { - - struct SectionInfo { - SectionInfo( std::string const& _name, - std::string const& _description, - SourceLineInfo const& _lineInfo ) - : name( _name ), - description( _description ), - lineInfo( _lineInfo ) - {} - - std::string name; - std::string description; - SourceLineInfo lineInfo; - }; - -} // end namespace Catch - -// #included from: catch_totals.hpp -#define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED - -#include - -namespace Catch { - - struct Counts { - Counts() : passed( 0 ), failed( 0 ) {} - - Counts operator - ( Counts const& other ) const { - Counts diff; - diff.passed = passed - other.passed; - diff.failed = failed - other.failed; - return diff; - } - Counts& operator += ( Counts const& other ) { - passed += other.passed; - failed += other.failed; - return *this; - } - - std::size_t total() const { - return passed + failed; - } - - std::size_t passed; - std::size_t failed; - }; - - struct Totals { - - Totals operator - ( Totals const& other ) const { - Totals diff; - diff.assertions = assertions - other.assertions; - diff.testCases = testCases - other.testCases; - return diff; - } - - Totals delta( Totals const& prevTotals ) const { - Totals diff = *this - prevTotals; - if( diff.assertions.failed > 0 ) - ++diff.testCases.failed; - else - ++diff.testCases.passed; - return diff; - } - - Totals& operator += ( Totals const& other ) { - assertions += other.assertions; - testCases += other.testCases; - return *this; - } - - Counts assertions; - Counts testCases; - }; -} - -// #included from: catch_timer.h -#define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED - -#ifdef CATCH_PLATFORM_WINDOWS -typedef unsigned long long uint64_t; -#else -#include -#endif - -namespace Catch { - - class Timer { - public: - Timer() : m_ticks( 0 ) {} - void start(); - unsigned int getElapsedNanoseconds() const; - unsigned int getElapsedMilliseconds() const; - double getElapsedSeconds() const; - - private: - uint64_t m_ticks; - }; - -} // namespace Catch - -#include - -namespace Catch { - - class Section { - public: - Section( SourceLineInfo const& lineInfo, - std::string const& name, - std::string const& description = "" ); - ~Section(); -# ifdef CATCH_CPP11_OR_GREATER - Section( Section const& ) = default; - Section( Section && ) = default; - Section& operator = ( Section const& ) = default; - Section& operator = ( Section && ) = default; -# endif - - // This indicates whether the section should be executed or not - operator bool(); - - private: - - SectionInfo m_info; - - std::string m_name; - Counts m_assertions; - bool m_sectionIncluded; - Timer m_timer; - }; - -} // end namespace Catch - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define INTERNAL_CATCH_SECTION( ... ) \ - if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) -#else - #define INTERNAL_CATCH_SECTION( name, desc ) \ - if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( CATCH_INTERNAL_LINEINFO, name, desc ) ) -#endif - -// #included from: internal/catch_generators.hpp -#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - -template -struct IGenerator { - virtual ~IGenerator() {} - virtual T getValue( std::size_t index ) const = 0; - virtual std::size_t size () const = 0; -}; - -template -class BetweenGenerator : public IGenerator { -public: - BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){} - - virtual T getValue( std::size_t index ) const { - return m_from+static_cast( index ); - } - - virtual std::size_t size() const { - return static_cast( 1+m_to-m_from ); - } - -private: - - T m_from; - T m_to; -}; - -template -class ValuesGenerator : public IGenerator { -public: - ValuesGenerator(){} - - void add( T value ) { - m_values.push_back( value ); - } - - virtual T getValue( std::size_t index ) const { - return m_values[index]; - } - - virtual std::size_t size() const { - return m_values.size(); - } - -private: - std::vector m_values; -}; - -template -class CompositeGenerator { -public: - CompositeGenerator() : m_totalSize( 0 ) {} - - // *** Move semantics, similar to auto_ptr *** - CompositeGenerator( CompositeGenerator& other ) - : m_fileInfo( other.m_fileInfo ), - m_totalSize( 0 ) - { - move( other ); - } - - CompositeGenerator& setFileInfo( const char* fileInfo ) { - m_fileInfo = fileInfo; - return *this; - } - - ~CompositeGenerator() { - deleteAll( m_composed ); - } - - operator T () const { - size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize ); - - typename std::vector*>::const_iterator it = m_composed.begin(); - typename std::vector*>::const_iterator itEnd = m_composed.end(); - for( size_t index = 0; it != itEnd; ++it ) - { - const IGenerator* generator = *it; - if( overallIndex >= index && overallIndex < index + generator->size() ) - { - return generator->getValue( overallIndex-index ); - } - index += generator->size(); - } - CATCH_INTERNAL_ERROR( "Indexed past end of generated range" ); - return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so - } - - void add( const IGenerator* generator ) { - m_totalSize += generator->size(); - m_composed.push_back( generator ); - } - - CompositeGenerator& then( CompositeGenerator& other ) { - move( other ); - return *this; - } - - CompositeGenerator& then( T value ) { - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( value ); - add( valuesGen ); - return *this; - } - -private: - - void move( CompositeGenerator& other ) { - std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) ); - m_totalSize += other.m_totalSize; - other.m_composed.clear(); - } - - std::vector*> m_composed; - std::string m_fileInfo; - size_t m_totalSize; -}; - -namespace Generators -{ - template - CompositeGenerator between( T from, T to ) { - CompositeGenerator generators; - generators.add( new BetweenGenerator( from, to ) ); - return generators; - } - - template - CompositeGenerator values( T val1, T val2 ) { - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - generators.add( valuesGen ); - return generators; - } - - template - CompositeGenerator values( T val1, T val2, T val3 ){ - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - valuesGen->add( val3 ); - generators.add( valuesGen ); - return generators; - } - - template - CompositeGenerator values( T val1, T val2, T val3, T val4 ) { - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - valuesGen->add( val3 ); - valuesGen->add( val4 ); - generators.add( valuesGen ); - return generators; - } - -} // end namespace Generators - -using namespace Generators; - -} // end namespace Catch - -#define INTERNAL_CATCH_LINESTR2( line ) #line -#define INTERNAL_CATCH_LINESTR( line ) INTERNAL_CATCH_LINESTR2( line ) - -#define INTERNAL_CATCH_GENERATE( expr ) expr.setFileInfo( __FILE__ "(" INTERNAL_CATCH_LINESTR( __LINE__ ) ")" ) - -// #included from: internal/catch_interfaces_exception.h -#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED - -#include - -namespace Catch { - - typedef std::string(*exceptionTranslateFunction)(); - - struct IExceptionTranslator { - virtual ~IExceptionTranslator(); - virtual std::string translate() const = 0; - }; - - struct IExceptionTranslatorRegistry { - virtual ~IExceptionTranslatorRegistry(); - - virtual std::string translateActiveException() const = 0; - }; - - class ExceptionTranslatorRegistrar { - template - class ExceptionTranslator : public IExceptionTranslator { - public: - - ExceptionTranslator( std::string(*translateFunction)( T& ) ) - : m_translateFunction( translateFunction ) - {} - - virtual std::string translate() const { - try { - throw; - } - catch( T& ex ) { - return m_translateFunction( ex ); - } - } - - protected: - std::string(*m_translateFunction)( T& ); - }; - - public: - template - ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) { - getMutableRegistryHub().registerTranslator - ( new ExceptionTranslator( translateFunction ) ); - } - }; -} - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) \ - static std::string INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator )( signature ); \ - namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ) ); }\ - static std::string INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator )( signature ) - -// #included from: internal/catch_approx.hpp -#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED - -#include -#include - -namespace Catch { -namespace Detail { - - class Approx { - public: - explicit Approx ( double value ) - : m_epsilon( std::numeric_limits::epsilon()*100 ), - m_scale( 1.0 ), - m_value( value ) - {} - - Approx( Approx const& other ) - : m_epsilon( other.m_epsilon ), - m_scale( other.m_scale ), - m_value( other.m_value ) - {} - - static Approx custom() { - return Approx( 0 ); - } - - Approx operator()( double value ) { - Approx approx( value ); - approx.epsilon( m_epsilon ); - approx.scale( m_scale ); - return approx; - } - - friend bool operator == ( double lhs, Approx const& rhs ) { - // Thanks to Richard Harris for his help refining this formula - return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) ); - } - - friend bool operator == ( Approx const& lhs, double rhs ) { - return operator==( rhs, lhs ); - } - - friend bool operator != ( double lhs, Approx const& rhs ) { - return !operator==( lhs, rhs ); - } - - friend bool operator != ( Approx const& lhs, double rhs ) { - return !operator==( rhs, lhs ); - } - - Approx& epsilon( double newEpsilon ) { - m_epsilon = newEpsilon; - return *this; - } - - Approx& scale( double newScale ) { - m_scale = newScale; - return *this; - } - - std::string toString() const { - std::ostringstream oss; - oss << "Approx( " << Catch::toString( m_value ) << " )"; - return oss.str(); - } - - private: - double m_epsilon; - double m_scale; - double m_value; - }; -} - -template<> -inline std::string toString( Detail::Approx const& value ) { - return value.toString(); -} - -} // end namespace Catch - -// #included from: internal/catch_matchers.hpp -#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED - -namespace Catch { -namespace Matchers { - namespace Impl { - - template - struct Matcher : SharedImpl - { - typedef ExpressionT ExpressionType; - - virtual ~Matcher() {} - virtual Ptr clone() const = 0; - virtual bool match( ExpressionT const& expr ) const = 0; - virtual std::string toString() const = 0; - }; - - template - struct MatcherImpl : Matcher { - - virtual Ptr > clone() const { - return Ptr >( new DerivedT( static_cast( *this ) ) ); - } - }; - - namespace Generic { - - template - class AllOf : public MatcherImpl, ExpressionT> { - public: - - AllOf() {} - AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {} - - AllOf& add( Matcher const& matcher ) { - m_matchers.push_back( matcher.clone() ); - return *this; - } - virtual bool match( ExpressionT const& expr ) const - { - for( std::size_t i = 0; i < m_matchers.size(); ++i ) - if( !m_matchers[i]->match( expr ) ) - return false; - return true; - } - virtual std::string toString() const { - std::ostringstream oss; - oss << "( "; - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if( i != 0 ) - oss << " and "; - oss << m_matchers[i]->toString(); - } - oss << " )"; - return oss.str(); - } - - private: - std::vector > > m_matchers; - }; - - template - class AnyOf : public MatcherImpl, ExpressionT> { - public: - - AnyOf() {} - AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {} - - AnyOf& add( Matcher const& matcher ) { - m_matchers.push_back( matcher.clone() ); - return *this; - } - virtual bool match( ExpressionT const& expr ) const - { - for( std::size_t i = 0; i < m_matchers.size(); ++i ) - if( m_matchers[i]->match( expr ) ) - return true; - return false; - } - virtual std::string toString() const { - std::ostringstream oss; - oss << "( "; - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if( i != 0 ) - oss << " or "; - oss << m_matchers[i]->toString(); - } - oss << " )"; - return oss.str(); - } - - private: - std::vector > > m_matchers; - }; - - } - - namespace StdString { - - inline std::string makeString( std::string const& str ) { return str; } - inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); } - - struct Equals : MatcherImpl { - Equals( std::string const& str ) : m_str( str ){} - Equals( Equals const& other ) : m_str( other.m_str ){} - - virtual ~Equals(); - - virtual bool match( std::string const& expr ) const { - return m_str == expr; - } - virtual std::string toString() const { - return "equals: \"" + m_str + "\""; - } - - std::string m_str; - }; - - struct Contains : MatcherImpl { - Contains( std::string const& substr ) : m_substr( substr ){} - Contains( Contains const& other ) : m_substr( other.m_substr ){} - - virtual ~Contains(); - - virtual bool match( std::string const& expr ) const { - return expr.find( m_substr ) != std::string::npos; - } - virtual std::string toString() const { - return "contains: \"" + m_substr + "\""; - } - - std::string m_substr; - }; - - struct StartsWith : MatcherImpl { - StartsWith( std::string const& substr ) : m_substr( substr ){} - StartsWith( StartsWith const& other ) : m_substr( other.m_substr ){} - - virtual ~StartsWith(); - - virtual bool match( std::string const& expr ) const { - return expr.find( m_substr ) == 0; - } - virtual std::string toString() const { - return "starts with: \"" + m_substr + "\""; - } - - std::string m_substr; - }; - - struct EndsWith : MatcherImpl { - EndsWith( std::string const& substr ) : m_substr( substr ){} - EndsWith( EndsWith const& other ) : m_substr( other.m_substr ){} - - virtual ~EndsWith(); - - virtual bool match( std::string const& expr ) const { - return expr.find( m_substr ) == expr.size() - m_substr.size(); - } - virtual std::string toString() const { - return "ends with: \"" + m_substr + "\""; - } - - std::string m_substr; - }; - } // namespace StdString - } // namespace Impl - - // The following functions create the actual matcher objects. - // This allows the types to be inferred - template - inline Impl::Generic::AllOf AllOf( Impl::Matcher const& m1, - Impl::Matcher const& m2 ) { - return Impl::Generic::AllOf().add( m1 ).add( m2 ); - } - template - inline Impl::Generic::AllOf AllOf( Impl::Matcher const& m1, - Impl::Matcher const& m2, - Impl::Matcher const& m3 ) { - return Impl::Generic::AllOf().add( m1 ).add( m2 ).add( m3 ); - } - template - inline Impl::Generic::AnyOf AnyOf( Impl::Matcher const& m1, - Impl::Matcher const& m2 ) { - return Impl::Generic::AnyOf().add( m1 ).add( m2 ); - } - template - inline Impl::Generic::AnyOf AnyOf( Impl::Matcher const& m1, - Impl::Matcher const& m2, - Impl::Matcher const& m3 ) { - return Impl::Generic::AnyOf().add( m1 ).add( m2 ).add( m3 ); - } - - inline Impl::StdString::Equals Equals( std::string const& str ) { - return Impl::StdString::Equals( str ); - } - inline Impl::StdString::Equals Equals( const char* str ) { - return Impl::StdString::Equals( Impl::StdString::makeString( str ) ); - } - inline Impl::StdString::Contains Contains( std::string const& substr ) { - return Impl::StdString::Contains( substr ); - } - inline Impl::StdString::Contains Contains( const char* substr ) { - return Impl::StdString::Contains( Impl::StdString::makeString( substr ) ); - } - inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) { - return Impl::StdString::StartsWith( substr ); - } - inline Impl::StdString::StartsWith StartsWith( const char* substr ) { - return Impl::StdString::StartsWith( Impl::StdString::makeString( substr ) ); - } - inline Impl::StdString::EndsWith EndsWith( std::string const& substr ) { - return Impl::StdString::EndsWith( substr ); - } - inline Impl::StdString::EndsWith EndsWith( const char* substr ) { - return Impl::StdString::EndsWith( Impl::StdString::makeString( substr ) ); - } - -} // namespace Matchers - -using namespace Matchers; - -} // namespace Catch - -// These files are included here so the single_include script doesn't put them -// in the conditionally compiled sections -// #included from: internal/catch_test_case_info.h -#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED - -#include -#include - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - - struct ITestCase; - - struct TestCaseInfo { - TestCaseInfo( std::string const& _name, - std::string const& _className, - std::string const& _description, - std::set const& _tags, - bool _isHidden, - SourceLineInfo const& _lineInfo ); - - TestCaseInfo( TestCaseInfo const& other ); - - std::string name; - std::string className; - std::string description; - std::set tags; - std::set lcaseTags; - std::string tagsAsString; - SourceLineInfo lineInfo; - bool isHidden; - bool throws; - }; - - class TestCase : public TestCaseInfo { - public: - - TestCase( ITestCase* testCase, TestCaseInfo const& info ); - TestCase( TestCase const& other ); - - TestCase withName( std::string const& _newName ) const; - - void invoke() const; - - TestCaseInfo const& getTestCaseInfo() const; - - bool isHidden() const; - bool throws() const; - - void swap( TestCase& other ); - bool operator == ( TestCase const& other ) const; - bool operator < ( TestCase const& other ) const; - TestCase& operator = ( TestCase const& other ); - - private: - Ptr test; - }; - - TestCase makeTestCase( ITestCase* testCase, - std::string const& className, - std::string const& name, - std::string const& description, - SourceLineInfo const& lineInfo ); -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -// #included from: internal/catch_interfaces_runner.h -#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED - -namespace Catch { - class TestCase; - - struct IRunner { - virtual ~IRunner(); - }; -} - - -#ifdef __OBJC__ -// #included from: internal/catch_objc.hpp -#define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED - -#import - -#include - -// NB. Any general catch headers included here must be included -// in catch.hpp first to make sure they are included by the single -// header for non obj-usage - -/////////////////////////////////////////////////////////////////////////////// -// This protocol is really only here for (self) documenting purposes, since -// all its methods are optional. -@protocol OcFixture - -@optional - --(void) setUp; --(void) tearDown; - -@end - -namespace Catch { - - class OcMethod : public SharedImpl { - - public: - OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {} - - virtual void invoke() const { - id obj = [[m_cls alloc] init]; - - performOptionalSelector( obj, @selector(setUp) ); - performOptionalSelector( obj, m_sel ); - performOptionalSelector( obj, @selector(tearDown) ); - - arcSafeRelease( obj ); - } - private: - virtual ~OcMethod() {} - - Class m_cls; - SEL m_sel; - }; - - namespace Detail{ - - inline std::string getAnnotation( Class cls, - std::string const& annotationName, - std::string const& testCaseName ) { - NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; - SEL sel = NSSelectorFromString( selStr ); - arcSafeRelease( selStr ); - id value = performOptionalSelector( cls, sel ); - if( value ) - return [(NSString*)value UTF8String]; - return ""; - } - } - - inline size_t registerTestMethods() { - size_t noTestMethods = 0; - int noClasses = objc_getClassList( NULL, 0 ); - - Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); - objc_getClassList( classes, noClasses ); - - for( int c = 0; c < noClasses; c++ ) { - Class cls = classes[c]; - { - u_int count; - Method* methods = class_copyMethodList( cls, &count ); - for( u_int m = 0; m < count ; m++ ) { - SEL selector = method_getName(methods[m]); - std::string methodName = sel_getName(selector); - if( startsWith( methodName, "Catch_TestCase_" ) ) { - std::string testCaseName = methodName.substr( 15 ); - std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); - std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); - const char* className = class_getName( cls ); - - getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) ); - noTestMethods++; - } - } - free(methods); - } - } - return noTestMethods; - } - - namespace Matchers { - namespace Impl { - namespace NSStringMatchers { - - template - struct StringHolder : MatcherImpl{ - StringHolder( NSString* substr ) : m_substr( [substr copy] ){} - StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} - StringHolder() { - arcSafeRelease( m_substr ); - } - - NSString* m_substr; - }; - - struct Equals : StringHolder { - Equals( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( ExpressionType const& str ) const { - return (str != nil || m_substr == nil ) && - [str isEqualToString:m_substr]; - } - - virtual std::string toString() const { - return "equals string: \"" + Catch::toString( m_substr ) + "\""; - } - }; - - struct Contains : StringHolder { - Contains( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( ExpressionType const& str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location != NSNotFound; - } - - virtual std::string toString() const { - return "contains string: \"" + Catch::toString( m_substr ) + "\""; - } - }; - - struct StartsWith : StringHolder { - StartsWith( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( ExpressionType const& str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location == 0; - } - - virtual std::string toString() const { - return "starts with: \"" + Catch::toString( m_substr ) + "\""; - } - }; - struct EndsWith : StringHolder { - EndsWith( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( ExpressionType const& str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location == [str length] - [m_substr length]; - } - - virtual std::string toString() const { - return "ends with: \"" + Catch::toString( m_substr ) + "\""; - } - }; - - } // namespace NSStringMatchers - } // namespace Impl - - inline Impl::NSStringMatchers::Equals - Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); } - - inline Impl::NSStringMatchers::Contains - Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); } - - inline Impl::NSStringMatchers::StartsWith - StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); } - - inline Impl::NSStringMatchers::EndsWith - EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); } - - } // namespace Matchers - - using namespace Matchers; - -} // namespace Catch - -/////////////////////////////////////////////////////////////////////////////// -#define OC_TEST_CASE( name, desc )\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \ -{\ -return @ name; \ -}\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Description_test ) \ -{ \ -return @ desc; \ -} \ --(void) INTERNAL_CATCH_UNIQUE_NAME( Catch_TestCase_test ) - -#endif - -#ifdef CATCH_CONFIG_RUNNER -// #included from: internal/catch_impl.hpp -#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED - -// Collect all the implementation files together here -// These are the equivalent of what would usually be cpp files - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wweak-vtables" -#endif - -// #included from: catch_runner.hpp -#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED - -// #included from: internal/catch_commandline.hpp -#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED - -// #included from: catch_config.hpp -#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED - -// #included from: catch_test_spec_parser.hpp -#define TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -// #included from: catch_test_spec.hpp -#define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -#include -#include - -namespace Catch { - - class TestSpec { - struct Pattern : SharedImpl<> { - virtual ~Pattern(); - virtual bool matches( TestCaseInfo const& testCase ) const = 0; - }; - class NamePattern : public Pattern { - enum WildcardPosition { - NoWildcard = 0, - WildcardAtStart = 1, - WildcardAtEnd = 2, - WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd - }; - - public: - NamePattern( std::string const& name ) : m_name( toLower( name ) ), m_wildcard( NoWildcard ) { - if( startsWith( m_name, "*" ) ) { - m_name = m_name.substr( 1 ); - m_wildcard = WildcardAtStart; - } - if( endsWith( m_name, "*" ) ) { - m_name = m_name.substr( 0, m_name.size()-1 ); - m_wildcard = (WildcardPosition)( m_wildcard | WildcardAtEnd ); - } - } - virtual ~NamePattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - switch( m_wildcard ) { - case NoWildcard: - return m_name == toLower( testCase.name ); - case WildcardAtStart: - return endsWith( toLower( testCase.name ), m_name ); - case WildcardAtEnd: - return startsWith( toLower( testCase.name ), m_name ); - case WildcardAtBothEnds: - return contains( toLower( testCase.name ), m_name ); - } - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunreachable-code" -#endif - throw std::logic_error( "Unknown enum" ); -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - } - private: - std::string m_name; - WildcardPosition m_wildcard; - }; - class TagPattern : public Pattern { - public: - TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} - virtual ~TagPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - return testCase.lcaseTags.find( m_tag ) != testCase.lcaseTags.end(); - } - private: - std::string m_tag; - }; - class ExcludedPattern : public Pattern { - public: - ExcludedPattern( Ptr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} - virtual ~ExcludedPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); } - private: - Ptr m_underlyingPattern; - }; - - struct Filter { - std::vector > m_patterns; - - bool matches( TestCaseInfo const& testCase ) const { - // All patterns in a filter must match for the filter to be a match - for( std::vector >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it ) - if( !(*it)->matches( testCase ) ) - return false; - return true; - } - }; - - public: - bool hasFilters() const { - return !m_filters.empty(); - } - bool matches( TestCaseInfo const& testCase ) const { - // A TestSpec matches if any filter matches - for( std::vector::const_iterator it = m_filters.begin(), itEnd = m_filters.end(); it != itEnd; ++it ) - if( it->matches( testCase ) ) - return true; - return false; - } - - private: - std::vector m_filters; - - friend class TestSpecParser; - }; -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -namespace Catch { - - class TestSpecParser { - enum Mode{ None, Name, QuotedName, Tag }; - Mode m_mode; - bool m_exclusion; - std::size_t m_start, m_pos; - std::string m_arg; - TestSpec::Filter m_currentFilter; - TestSpec m_testSpec; - - public: - TestSpecParser parse( std::string const& arg ) { - m_mode = None; - m_exclusion = false; - m_start = std::string::npos; - m_arg = arg; - for( m_pos = 0; m_pos < m_arg.size(); ++m_pos ) - visitChar( m_arg[m_pos] ); - if( m_mode == Name ) - addPattern(); - return *this; - } - TestSpec testSpec() { - addFilter(); - return m_testSpec; - } - private: - void visitChar( char c ) { - if( m_mode == None ) { - switch( c ) { - case ' ': return; - case '~': m_exclusion = true; return; - case '[': return startNewMode( Tag, ++m_pos ); - case '"': return startNewMode( QuotedName, ++m_pos ); - default: startNewMode( Name, m_pos ); break; - } - } - if( m_mode == Name ) { - if( c == ',' ) { - addPattern(); - addFilter(); - } - else if( c == '[' ) { - if( subString() == "exclude:" ) - m_exclusion = true; - else - addPattern(); - startNewMode( Tag, ++m_pos ); - } - } - else if( m_mode == QuotedName && c == '"' ) - addPattern(); - else if( m_mode == Tag && c == ']' ) - addPattern(); - } - void startNewMode( Mode mode, std::size_t start ) { - m_mode = mode; - m_start = start; - } - std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); } - template - void addPattern() { - std::string token = subString(); - if( startsWith( token, "exclude:" ) ) { - m_exclusion = true; - token = token.substr( 8 ); - } - if( !token.empty() ) { - Ptr pattern = new T( token ); - if( m_exclusion ) - pattern = new TestSpec::ExcludedPattern( pattern ); - m_currentFilter.m_patterns.push_back( pattern ); - } - m_exclusion = false; - m_mode = None; - } - void addFilter() { - if( !m_currentFilter.m_patterns.empty() ) { - m_testSpec.m_filters.push_back( m_currentFilter ); - m_currentFilter = TestSpec::Filter(); - } - } - }; - inline TestSpec parseTestSpec( std::string const& arg ) { - return TestSpecParser().parse( arg ).testSpec(); - } - -} // namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -// #included from: catch_stream.h -#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED - -#include - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - - class Stream { - public: - Stream(); - Stream( std::streambuf* _streamBuf, bool _isOwned ); - void release(); - - std::streambuf* streamBuf; - - private: - bool isOwned; - }; -} - -#include -#include -#include -#include - -#ifndef CATCH_CONFIG_CONSOLE_WIDTH -#define CATCH_CONFIG_CONSOLE_WIDTH 80 -#endif - -namespace Catch { - - struct ConfigData { - - ConfigData() - : listTests( false ), - listTags( false ), - listReporters( false ), - listTestNamesOnly( false ), - showSuccessfulTests( false ), - shouldDebugBreak( false ), - noThrow( false ), - showHelp( false ), - showInvisibles( false ), - abortAfter( -1 ), - verbosity( Verbosity::Normal ), - warnings( WarnAbout::Nothing ), - showDurations( ShowDurations::DefaultForReporter ) - {} - - bool listTests; - bool listTags; - bool listReporters; - bool listTestNamesOnly; - - bool showSuccessfulTests; - bool shouldDebugBreak; - bool noThrow; - bool showHelp; - bool showInvisibles; - - int abortAfter; - - Verbosity::Level verbosity; - WarnAbout::What warnings; - ShowDurations::OrNot showDurations; - - std::string reporterName; - std::string outputFilename; - std::string name; - std::string processName; - - std::vector testsOrTags; - }; - - class Config : public SharedImpl { - private: - Config( Config const& other ); - Config& operator = ( Config const& other ); - virtual void dummy(); - public: - - Config() - : m_os( std::cout.rdbuf() ) - {} - - Config( ConfigData const& data ) - : m_data( data ), - m_os( std::cout.rdbuf() ) - { - if( !data.testsOrTags.empty() ) { - TestSpecParser parser; - for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) - parser.parse( data.testsOrTags[i] ); - m_testSpec = parser.testSpec(); - } - } - - virtual ~Config() { - m_os.rdbuf( std::cout.rdbuf() ); - m_stream.release(); - } - - void setFilename( std::string const& filename ) { - m_data.outputFilename = filename; - } - - std::string const& getFilename() const { - return m_data.outputFilename ; - } - - bool listTests() const { return m_data.listTests; } - bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } - bool listTags() const { return m_data.listTags; } - bool listReporters() const { return m_data.listReporters; } - - std::string getProcessName() const { return m_data.processName; } - - bool shouldDebugBreak() const { return m_data.shouldDebugBreak; } - - void setStreamBuf( std::streambuf* buf ) { - m_os.rdbuf( buf ? buf : std::cout.rdbuf() ); - } - - void useStream( std::string const& streamName ) { - Stream stream = createStream( streamName ); - setStreamBuf( stream.streamBuf ); - m_stream.release(); - m_stream = stream; - } - - std::string getReporterName() const { return m_data.reporterName; } - - int abortAfter() const { return m_data.abortAfter; } - - TestSpec const& testSpec() const { return m_testSpec; } - - bool showHelp() const { return m_data.showHelp; } - bool showInvisibles() const { return m_data.showInvisibles; } - - // IConfig interface - virtual bool allowThrows() const { return !m_data.noThrow; } - virtual std::ostream& stream() const { return m_os; } - virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } - virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; } - virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; } - virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; } - - private: - ConfigData m_data; - - Stream m_stream; - mutable std::ostream m_os; - TestSpec m_testSpec; - }; - -} // end namespace Catch - -// #included from: catch_clara.h -#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED - -// Use Catch's value for console width (store Clara's off to the side, if present) -#ifdef CLARA_CONFIG_CONSOLE_WIDTH -#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CLARA_CONFIG_CONSOLE_WIDTH -#undef CLARA_CONFIG_CONSOLE_WIDTH -#endif -#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH - -// Declare Clara inside the Catch namespace -#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch { -// #included from: ../external/clara.h - -// Only use header guard if we are not using an outer namespace -#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE) - -#ifndef STITCH_CLARA_OPEN_NAMESPACE -#define TWOBLUECUBES_CLARA_H_INCLUDED -#define STITCH_CLARA_OPEN_NAMESPACE -#define STITCH_CLARA_CLOSE_NAMESPACE -#else -#define STITCH_CLARA_CLOSE_NAMESPACE } -#endif - -#define STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE - -// ----------- #included from tbc_text_format.h ----------- - -// Only use header guard if we are not using an outer namespace -#if !defined(TBC_TEXT_FORMAT_H_INCLUDED) || defined(STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE) -#ifndef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE -#define TBC_TEXT_FORMAT_H_INCLUDED -#endif - -#include -#include -#include - -// Use optional outer namespace -#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE -namespace STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE { -#endif - -namespace Tbc { - -#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH - const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; -#else - const unsigned int consoleWidth = 80; -#endif - - struct TextAttributes { - TextAttributes() - : initialIndent( std::string::npos ), - indent( 0 ), - width( consoleWidth-1 ), - tabChar( '\t' ) - {} - - TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; } - TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; } - TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; } - TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; } - - std::size_t initialIndent; // indent of first line, or npos - std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos - std::size_t width; // maximum width of text, including indent. Longer text will wrap - char tabChar; // If this char is seen the indent is changed to current pos - }; - - class Text { - public: - Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() ) - : attr( _attr ) - { - std::string wrappableChars = " [({.,/|\\-"; - std::size_t indent = _attr.initialIndent != std::string::npos - ? _attr.initialIndent - : _attr.indent; - std::string remainder = _str; - - while( !remainder.empty() ) { - if( lines.size() >= 1000 ) { - lines.push_back( "... message truncated due to excessive size" ); - return; - } - std::size_t tabPos = std::string::npos; - std::size_t width = (std::min)( remainder.size(), _attr.width - indent ); - std::size_t pos = remainder.find_first_of( '\n' ); - if( pos <= width ) { - width = pos; - } - pos = remainder.find_last_of( _attr.tabChar, width ); - if( pos != std::string::npos ) { - tabPos = pos; - if( remainder[width] == '\n' ) - width--; - remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 ); - } - - if( width == remainder.size() ) { - spliceLine( indent, remainder, width ); - } - else if( remainder[width] == '\n' ) { - spliceLine( indent, remainder, width ); - if( width <= 1 || remainder.size() != 1 ) - remainder = remainder.substr( 1 ); - indent = _attr.indent; - } - else { - pos = remainder.find_last_of( wrappableChars, width ); - if( pos != std::string::npos && pos > 0 ) { - spliceLine( indent, remainder, pos ); - if( remainder[0] == ' ' ) - remainder = remainder.substr( 1 ); - } - else { - spliceLine( indent, remainder, width-1 ); - lines.back() += "-"; - } - if( lines.size() == 1 ) - indent = _attr.indent; - if( tabPos != std::string::npos ) - indent += tabPos; - } - } - } - - void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) { - lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) ); - _remainder = _remainder.substr( _pos ); - } - - typedef std::vector::const_iterator const_iterator; - - const_iterator begin() const { return lines.begin(); } - const_iterator end() const { return lines.end(); } - std::string const& last() const { return lines.back(); } - std::size_t size() const { return lines.size(); } - std::string const& operator[]( std::size_t _index ) const { return lines[_index]; } - std::string toString() const { - std::ostringstream oss; - oss << *this; - return oss.str(); - } - - inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) { - for( Text::const_iterator it = _text.begin(), itEnd = _text.end(); - it != itEnd; ++it ) { - if( it != _text.begin() ) - _stream << "\n"; - _stream << *it; - } - return _stream; - } - - private: - std::string str; - TextAttributes attr; - std::vector lines; - }; - -} // end namespace Tbc - -#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE -} // end outer namespace -#endif - -#endif // TBC_TEXT_FORMAT_H_INCLUDED - -// ----------- end of #include from tbc_text_format.h ----------- -// ........... back in /Users/philnash/Dev/OSS/Clara/srcs/clara.h - -#undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE - -#include -#include -#include -#include - -// Use optional outer namespace -#ifdef STITCH_CLARA_OPEN_NAMESPACE -STITCH_CLARA_OPEN_NAMESPACE -#endif - -namespace Clara { - - struct UnpositionalTag {}; - - extern UnpositionalTag _; - -#ifdef CLARA_CONFIG_MAIN - UnpositionalTag _; -#endif - - namespace Detail { - -#ifdef CLARA_CONSOLE_WIDTH - const unsigned int consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH; -#else - const unsigned int consoleWidth = 80; -#endif - - using namespace Tbc; - - inline bool startsWith( std::string const& str, std::string const& prefix ) { - return str.size() >= prefix.size() && str.substr( 0, prefix.size() ) == prefix; - } - - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - - template struct IsBool { static const bool value = false; }; - template<> struct IsBool { static const bool value = true; }; - - template - void convertInto( std::string const& _source, T& _dest ) { - std::stringstream ss; - ss << _source; - ss >> _dest; - if( ss.fail() ) - throw std::runtime_error( "Unable to convert " + _source + " to destination type" ); - } - inline void convertInto( std::string const& _source, std::string& _dest ) { - _dest = _source; - } - inline void convertInto( std::string const& _source, bool& _dest ) { - std::string sourceLC = _source; - std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower ); - if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" ) - _dest = true; - else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" ) - _dest = false; - else - throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" ); - } - inline void convertInto( bool _source, bool& _dest ) { - _dest = _source; - } - template - inline void convertInto( bool, T& ) { - throw std::runtime_error( "Invalid conversion" ); - } - - template - struct IArgFunction { - virtual ~IArgFunction() {} -# ifdef CATCH_CPP11_OR_GREATER - IArgFunction() = default; - IArgFunction( IArgFunction const& ) = default; -# endif - virtual void set( ConfigT& config, std::string const& value ) const = 0; - virtual void setFlag( ConfigT& config ) const = 0; - virtual bool takesArg() const = 0; - virtual IArgFunction* clone() const = 0; - }; - - template - class BoundArgFunction { - public: - BoundArgFunction() : functionObj( NULL ) {} - BoundArgFunction( IArgFunction* _functionObj ) : functionObj( _functionObj ) {} - BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : NULL ) {} - BoundArgFunction& operator = ( BoundArgFunction const& other ) { - IArgFunction* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL; - delete functionObj; - functionObj = newFunctionObj; - return *this; - } - ~BoundArgFunction() { delete functionObj; } - - void set( ConfigT& config, std::string const& value ) const { - functionObj->set( config, value ); - } - void setFlag( ConfigT& config ) const { - functionObj->setFlag( config ); - } - bool takesArg() const { return functionObj->takesArg(); } - - bool isSet() const { - return functionObj != NULL; - } - private: - IArgFunction* functionObj; - }; - - template - struct NullBinder : IArgFunction{ - virtual void set( C&, std::string const& ) const {} - virtual void setFlag( C& ) const {} - virtual bool takesArg() const { return true; } - virtual IArgFunction* clone() const { return new NullBinder( *this ); } - }; - - template - struct BoundDataMember : IArgFunction{ - BoundDataMember( M C::* _member ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - convertInto( stringValue, p.*member ); - } - virtual void setFlag( C& p ) const { - convertInto( true, p.*member ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundDataMember( *this ); } - M C::* member; - }; - template - struct BoundUnaryMethod : IArgFunction{ - BoundUnaryMethod( void (C::*_member)( M ) ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - typename RemoveConstRef::type value; - convertInto( stringValue, value ); - (p.*member)( value ); - } - virtual void setFlag( C& p ) const { - typename RemoveConstRef::type value; - convertInto( true, value ); - (p.*member)( value ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundUnaryMethod( *this ); } - void (C::*member)( M ); - }; - template - struct BoundNullaryMethod : IArgFunction{ - BoundNullaryMethod( void (C::*_member)() ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - bool value; - convertInto( stringValue, value ); - if( value ) - (p.*member)(); - } - virtual void setFlag( C& p ) const { - (p.*member)(); - } - virtual bool takesArg() const { return false; } - virtual IArgFunction* clone() const { return new BoundNullaryMethod( *this ); } - void (C::*member)(); - }; - - template - struct BoundUnaryFunction : IArgFunction{ - BoundUnaryFunction( void (*_function)( C& ) ) : function( _function ) {} - virtual void set( C& obj, std::string const& stringValue ) const { - bool value; - convertInto( stringValue, value ); - if( value ) - function( obj ); - } - virtual void setFlag( C& p ) const { - function( p ); - } - virtual bool takesArg() const { return false; } - virtual IArgFunction* clone() const { return new BoundUnaryFunction( *this ); } - void (*function)( C& ); - }; - - template - struct BoundBinaryFunction : IArgFunction{ - BoundBinaryFunction( void (*_function)( C&, T ) ) : function( _function ) {} - virtual void set( C& obj, std::string const& stringValue ) const { - typename RemoveConstRef::type value; - convertInto( stringValue, value ); - function( obj, value ); - } - virtual void setFlag( C& obj ) const { - typename RemoveConstRef::type value; - convertInto( true, value ); - function( obj, value ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundBinaryFunction( *this ); } - void (*function)( C&, T ); - }; - - } // namespace Detail - - struct Parser { - Parser() : separators( " \t=:" ) {} - - struct Token { - enum Type { Positional, ShortOpt, LongOpt }; - Token( Type _type, std::string const& _data ) : type( _type ), data( _data ) {} - Type type; - std::string data; - }; - - void parseIntoTokens( int argc, char const * const * argv, std::vector& tokens ) const { - const std::string doubleDash = "--"; - for( int i = 1; i < argc && argv[i] != doubleDash; ++i ) - parseIntoTokens( argv[i] , tokens); - } - void parseIntoTokens( std::string arg, std::vector& tokens ) const { - while( !arg.empty() ) { - Parser::Token token( Parser::Token::Positional, arg ); - arg = ""; - if( token.data[0] == '-' ) { - if( token.data.size() > 1 && token.data[1] == '-' ) { - token = Parser::Token( Parser::Token::LongOpt, token.data.substr( 2 ) ); - } - else { - token = Parser::Token( Parser::Token::ShortOpt, token.data.substr( 1 ) ); - if( token.data.size() > 1 && separators.find( token.data[1] ) == std::string::npos ) { - arg = "-" + token.data.substr( 1 ); - token.data = token.data.substr( 0, 1 ); - } - } - } - if( token.type != Parser::Token::Positional ) { - std::size_t pos = token.data.find_first_of( separators ); - if( pos != std::string::npos ) { - arg = token.data.substr( pos+1 ); - token.data = token.data.substr( 0, pos ); - } - } - tokens.push_back( token ); - } - } - std::string separators; - }; - - template - struct CommonArgProperties { - CommonArgProperties() {} - CommonArgProperties( Detail::BoundArgFunction const& _boundField ) : boundField( _boundField ) {} - - Detail::BoundArgFunction boundField; - std::string description; - std::string detail; - std::string placeholder; // Only value if boundField takes an arg - - bool takesArg() const { - return !placeholder.empty(); - } - void validate() const { - if( !boundField.isSet() ) - throw std::logic_error( "option not bound" ); - } - }; - struct OptionArgProperties { - std::vector shortNames; - std::string longName; - - bool hasShortName( std::string const& shortName ) const { - return std::find( shortNames.begin(), shortNames.end(), shortName ) != shortNames.end(); - } - bool hasLongName( std::string const& _longName ) const { - return _longName == longName; - } - }; - struct PositionalArgProperties { - PositionalArgProperties() : position( -1 ) {} - int position; // -1 means non-positional (floating) - - bool isFixedPositional() const { - return position != -1; - } - }; - - template - class CommandLine { - - struct Arg : CommonArgProperties, OptionArgProperties, PositionalArgProperties { - Arg() {} - Arg( Detail::BoundArgFunction const& _boundField ) : CommonArgProperties( _boundField ) {} - - using CommonArgProperties::placeholder; // !TBD - - std::string dbgName() const { - if( !longName.empty() ) - return "--" + longName; - if( !shortNames.empty() ) - return "-" + shortNames[0]; - return "positional args"; - } - std::string commands() const { - std::ostringstream oss; - bool first = true; - std::vector::const_iterator it = shortNames.begin(), itEnd = shortNames.end(); - for(; it != itEnd; ++it ) { - if( first ) - first = false; - else - oss << ", "; - oss << "-" << *it; - } - if( !longName.empty() ) { - if( !first ) - oss << ", "; - oss << "--" << longName; - } - if( !placeholder.empty() ) - oss << " <" << placeholder << ">"; - return oss.str(); - } - }; - - // NOTE: std::auto_ptr is deprecated in c++11/c++0x -#if defined(__cplusplus) && __cplusplus > 199711L - typedef std::unique_ptr ArgAutoPtr; -#else - typedef std::auto_ptr ArgAutoPtr; -#endif - - friend void addOptName( Arg& arg, std::string const& optName ) - { - if( optName.empty() ) - return; - if( Detail::startsWith( optName, "--" ) ) { - if( !arg.longName.empty() ) - throw std::logic_error( "Only one long opt may be specified. '" - + arg.longName - + "' already specified, now attempting to add '" - + optName + "'" ); - arg.longName = optName.substr( 2 ); - } - else if( Detail::startsWith( optName, "-" ) ) - arg.shortNames.push_back( optName.substr( 1 ) ); - else - throw std::logic_error( "option must begin with - or --. Option was: '" + optName + "'" ); - } - friend void setPositionalArg( Arg& arg, int position ) - { - arg.position = position; - } - - class ArgBuilder { - public: - ArgBuilder( Arg* arg ) : m_arg( arg ) {} - - // Bind a non-boolean data member (requires placeholder string) - template - void bind( M C::* field, std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundDataMember( field ); - m_arg->placeholder = placeholder; - } - // Bind a boolean data member (no placeholder required) - template - void bind( bool C::* field ) { - m_arg->boundField = new Detail::BoundDataMember( field ); - } - - // Bind a method taking a single, non-boolean argument (requires a placeholder string) - template - void bind( void (C::* unaryMethod)( M ), std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundUnaryMethod( unaryMethod ); - m_arg->placeholder = placeholder; - } - - // Bind a method taking a single, boolean argument (no placeholder string required) - template - void bind( void (C::* unaryMethod)( bool ) ) { - m_arg->boundField = new Detail::BoundUnaryMethod( unaryMethod ); - } - - // Bind a method that takes no arguments (will be called if opt is present) - template - void bind( void (C::* nullaryMethod)() ) { - m_arg->boundField = new Detail::BoundNullaryMethod( nullaryMethod ); - } - - // Bind a free function taking a single argument - the object to operate on (no placeholder string required) - template - void bind( void (* unaryFunction)( C& ) ) { - m_arg->boundField = new Detail::BoundUnaryFunction( unaryFunction ); - } - - // Bind a free function taking a single argument - the object to operate on (requires a placeholder string) - template - void bind( void (* binaryFunction)( C&, T ), std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundBinaryFunction( binaryFunction ); - m_arg->placeholder = placeholder; - } - - ArgBuilder& describe( std::string const& description ) { - m_arg->description = description; - return *this; - } - ArgBuilder& detail( std::string const& detail ) { - m_arg->detail = detail; - return *this; - } - - protected: - Arg* m_arg; - }; - - class OptBuilder : public ArgBuilder { - public: - OptBuilder( Arg* arg ) : ArgBuilder( arg ) {} - OptBuilder( OptBuilder& other ) : ArgBuilder( other ) {} - - OptBuilder& operator[]( std::string const& optName ) { - addOptName( *ArgBuilder::m_arg, optName ); - return *this; - } - }; - - public: - - CommandLine() - : m_boundProcessName( new Detail::NullBinder() ), - m_highestSpecifiedArgPosition( 0 ), - m_throwOnUnrecognisedTokens( false ) - {} - CommandLine( CommandLine const& other ) - : m_boundProcessName( other.m_boundProcessName ), - m_options ( other.m_options ), - m_positionalArgs( other.m_positionalArgs ), - m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ), - m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens ) - { - if( other.m_floatingArg.get() ) - m_floatingArg = ArgAutoPtr( new Arg( *other.m_floatingArg ) ); - } - - CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) { - m_throwOnUnrecognisedTokens = shouldThrow; - return *this; - } - - OptBuilder operator[]( std::string const& optName ) { - m_options.push_back( Arg() ); - addOptName( m_options.back(), optName ); - OptBuilder builder( &m_options.back() ); - return builder; - } - - ArgBuilder operator[]( int position ) { - m_positionalArgs.insert( std::make_pair( position, Arg() ) ); - if( position > m_highestSpecifiedArgPosition ) - m_highestSpecifiedArgPosition = position; - setPositionalArg( m_positionalArgs[position], position ); - ArgBuilder builder( &m_positionalArgs[position] ); - return builder; - } - - // Invoke this with the _ instance - ArgBuilder operator[]( UnpositionalTag ) { - if( m_floatingArg.get() ) - throw std::logic_error( "Only one unpositional argument can be added" ); - m_floatingArg = ArgAutoPtr( new Arg() ); - ArgBuilder builder( m_floatingArg.get() ); - return builder; - } - - template - void bindProcessName( M C::* field ) { - m_boundProcessName = new Detail::BoundDataMember( field ); - } - template - void bindProcessName( void (C::*_unaryMethod)( M ) ) { - m_boundProcessName = new Detail::BoundUnaryMethod( _unaryMethod ); - } - - void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const { - typename std::vector::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it; - std::size_t maxWidth = 0; - for( it = itBegin; it != itEnd; ++it ) - maxWidth = (std::max)( maxWidth, it->commands().size() ); - - for( it = itBegin; it != itEnd; ++it ) { - Detail::Text usage( it->commands(), Detail::TextAttributes() - .setWidth( maxWidth+indent ) - .setIndent( indent ) ); - Detail::Text desc( it->description, Detail::TextAttributes() - .setWidth( width - maxWidth - 3 ) ); - - for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) { - std::string usageCol = i < usage.size() ? usage[i] : ""; - os << usageCol; - - if( i < desc.size() && !desc[i].empty() ) - os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' ) - << desc[i]; - os << "\n"; - } - } - } - std::string optUsage() const { - std::ostringstream oss; - optUsage( oss ); - return oss.str(); - } - - void argSynopsis( std::ostream& os ) const { - for( int i = 1; i <= m_highestSpecifiedArgPosition; ++i ) { - if( i > 1 ) - os << " "; - typename std::map::const_iterator it = m_positionalArgs.find( i ); - if( it != m_positionalArgs.end() ) - os << "<" << it->second.placeholder << ">"; - else if( m_floatingArg.get() ) - os << "<" << m_floatingArg->placeholder << ">"; - else - throw std::logic_error( "non consecutive positional arguments with no floating args" ); - } - // !TBD No indication of mandatory args - if( m_floatingArg.get() ) { - if( m_highestSpecifiedArgPosition > 1 ) - os << " "; - os << "[<" << m_floatingArg->placeholder << "> ...]"; - } - } - std::string argSynopsis() const { - std::ostringstream oss; - argSynopsis( oss ); - return oss.str(); - } - - void usage( std::ostream& os, std::string const& procName ) const { - validate(); - os << "usage:\n " << procName << " "; - argSynopsis( os ); - if( !m_options.empty() ) { - os << " [options]\n\nwhere options are: \n"; - optUsage( os, 2 ); - } - os << "\n"; - } - std::string usage( std::string const& procName ) const { - std::ostringstream oss; - usage( oss, procName ); - return oss.str(); - } - - ConfigT parse( int argc, char const * const * argv ) const { - ConfigT config; - parseInto( argc, argv, config ); - return config; - } - - std::vector parseInto( int argc, char const * const * argv, ConfigT& config ) const { - std::string processName = argv[0]; - std::size_t lastSlash = processName.find_last_of( "/\\" ); - if( lastSlash != std::string::npos ) - processName = processName.substr( lastSlash+1 ); - m_boundProcessName.set( config, processName ); - std::vector tokens; - Parser parser; - parser.parseIntoTokens( argc, argv, tokens ); - return populate( tokens, config ); - } - - std::vector populate( std::vector const& tokens, ConfigT& config ) const { - validate(); - std::vector unusedTokens = populateOptions( tokens, config ); - unusedTokens = populateFixedArgs( unusedTokens, config ); - unusedTokens = populateFloatingArgs( unusedTokens, config ); - return unusedTokens; - } - - std::vector populateOptions( std::vector const& tokens, ConfigT& config ) const { - std::vector unusedTokens; - std::vector errors; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - typename std::vector::const_iterator it = m_options.begin(), itEnd = m_options.end(); - for(; it != itEnd; ++it ) { - Arg const& arg = *it; - - try { - if( ( token.type == Parser::Token::ShortOpt && arg.hasShortName( token.data ) ) || - ( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) { - if( arg.takesArg() ) { - if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional ) - errors.push_back( "Expected argument to option: " + token.data ); - else - arg.boundField.set( config, tokens[++i].data ); - } - else { - arg.boundField.setFlag( config ); - } - break; - } - } - catch( std::exception& ex ) { - errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" ); - } - } - if( it == itEnd ) { - if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens ) - unusedTokens.push_back( token ); - else if( m_throwOnUnrecognisedTokens ) - errors.push_back( "unrecognised option: " + token.data ); - } - } - if( !errors.empty() ) { - std::ostringstream oss; - for( std::vector::const_iterator it = errors.begin(), itEnd = errors.end(); - it != itEnd; - ++it ) { - if( it != errors.begin() ) - oss << "\n"; - oss << *it; - } - throw std::runtime_error( oss.str() ); - } - return unusedTokens; - } - std::vector populateFixedArgs( std::vector const& tokens, ConfigT& config ) const { - std::vector unusedTokens; - int position = 1; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - typename std::map::const_iterator it = m_positionalArgs.find( position ); - if( it != m_positionalArgs.end() ) - it->second.boundField.set( config, token.data ); - else - unusedTokens.push_back( token ); - if( token.type == Parser::Token::Positional ) - position++; - } - return unusedTokens; - } - std::vector populateFloatingArgs( std::vector const& tokens, ConfigT& config ) const { - if( !m_floatingArg.get() ) - return tokens; - std::vector unusedTokens; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - if( token.type == Parser::Token::Positional ) - m_floatingArg->boundField.set( config, token.data ); - else - unusedTokens.push_back( token ); - } - return unusedTokens; - } - - void validate() const - { - if( m_options.empty() && m_positionalArgs.empty() && !m_floatingArg.get() ) - throw std::logic_error( "No options or arguments specified" ); - - for( typename std::vector::const_iterator it = m_options.begin(), - itEnd = m_options.end(); - it != itEnd; ++it ) - it->validate(); - } - - private: - Detail::BoundArgFunction m_boundProcessName; - std::vector m_options; - std::map m_positionalArgs; - ArgAutoPtr m_floatingArg; - int m_highestSpecifiedArgPosition; - bool m_throwOnUnrecognisedTokens; - }; - -} // end namespace Clara - -STITCH_CLARA_CLOSE_NAMESPACE -#undef STITCH_CLARA_OPEN_NAMESPACE -#undef STITCH_CLARA_CLOSE_NAMESPACE - -#endif // TWOBLUECUBES_CLARA_H_INCLUDED -#undef STITCH_CLARA_OPEN_NAMESPACE - -// Restore Clara's value for console width, if present -#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH -#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH -#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH -#endif - -#include - -namespace Catch { - - inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; } - inline void abortAfterX( ConfigData& config, int x ) { - if( x < 1 ) - throw std::runtime_error( "Value after -x or --abortAfter must be greater than zero" ); - config.abortAfter = x; - } - inline void addTestOrTags( ConfigData& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); } - - inline void addWarning( ConfigData& config, std::string const& _warning ) { - if( _warning == "NoAssertions" ) - config.warnings = (WarnAbout::What)( config.warnings | WarnAbout::NoAssertions ); - else - throw std::runtime_error( "Unrecognised warning: '" + _warning + "'" ); - - } - inline void setVerbosity( ConfigData& config, int level ) { - // !TBD: accept strings? - config.verbosity = (Verbosity::Level)level; - } - inline void setShowDurations( ConfigData& config, bool _showDurations ) { - config.showDurations = _showDurations - ? ShowDurations::Always - : ShowDurations::Never; - } - inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) { - std::ifstream f( _filename.c_str() ); - if( !f.is_open() ) - throw std::domain_error( "Unable to load input file: " + _filename ); - - std::string line; - while( std::getline( f, line ) ) { - line = trim(line); - if( !line.empty() && !startsWith( line, "#" ) ) - addTestOrTags( config, "\"" + line + "\"," ); - } - } - - inline Clara::CommandLine makeCommandLineParser() { - - using namespace Clara; - CommandLine cli; - - cli.bindProcessName( &ConfigData::processName ); - - cli["-?"]["-h"]["--help"] - .describe( "display usage information" ) - .bind( &ConfigData::showHelp ); - - cli["-l"]["--list-tests"] - .describe( "list all/matching test cases" ) - .bind( &ConfigData::listTests ); - - cli["-t"]["--list-tags"] - .describe( "list all/matching tags" ) - .bind( &ConfigData::listTags ); - - cli["-s"]["--success"] - .describe( "include successful tests in output" ) - .bind( &ConfigData::showSuccessfulTests ); - - cli["-b"]["--break"] - .describe( "break into debugger on failure" ) - .bind( &ConfigData::shouldDebugBreak ); - - cli["-e"]["--nothrow"] - .describe( "skip exception tests" ) - .bind( &ConfigData::noThrow ); - - cli["-i"]["--invisibles"] - .describe( "show invisibles (tabs, newlines)" ) - .bind( &ConfigData::showInvisibles ); - - cli["-o"]["--out"] - .describe( "output filename" ) - .bind( &ConfigData::outputFilename, "filename" ); - - cli["-r"]["--reporter"] -// .placeholder( "name[:filename]" ) - .describe( "reporter to use (defaults to console)" ) - .bind( &ConfigData::reporterName, "name" ); - - cli["-n"]["--name"] - .describe( "suite name" ) - .bind( &ConfigData::name, "name" ); - - cli["-a"]["--abort"] - .describe( "abort at first failure" ) - .bind( &abortAfterFirst ); - - cli["-x"]["--abortx"] - .describe( "abort after x failures" ) - .bind( &abortAfterX, "no. failures" ); - - cli["-w"]["--warn"] - .describe( "enable warnings" ) - .bind( &addWarning, "warning name" ); - -// - needs updating if reinstated -// cli.into( &setVerbosity ) -// .describe( "level of verbosity (0=no output)" ) -// .shortOpt( "v") -// .longOpt( "verbosity" ) -// .placeholder( "level" ); - - cli[_] - .describe( "which test or tests to use" ) - .bind( &addTestOrTags, "test name, pattern or tags" ); - - cli["-d"]["--durations"] - .describe( "show test durations" ) - .bind( &setShowDurations, "yes/no" ); - - cli["-f"]["--input-file"] - .describe( "load test names to run from a file" ) - .bind( &loadTestNamesFromFile, "filename" ); - - // Less common commands which don't have a short form - cli["--list-test-names-only"] - .describe( "list all/matching test cases names only" ) - .bind( &ConfigData::listTestNamesOnly ); - - cli["--list-reporters"] - .describe( "list all reporters" ) - .bind( &ConfigData::listReporters ); - - return cli; - } - -} // end namespace Catch - -// #included from: internal/catch_list.hpp -#define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED - -// #included from: catch_text.h -#define TWOBLUECUBES_CATCH_TEXT_H_INCLUDED - -#define TBC_TEXT_FORMAT_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH - -#define CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE Catch -// #included from: ../external/tbc_text_format.h -// Only use header guard if we are not using an outer namespace -#ifndef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -# ifdef TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED -# ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -# define TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -# endif -# else -# define TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED -# endif -#endif -#ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -#include -#include -#include - -// Use optional outer namespace -#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -namespace CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE { -#endif - -namespace Tbc { - -#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH - const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; -#else - const unsigned int consoleWidth = 80; -#endif - - struct TextAttributes { - TextAttributes() - : initialIndent( std::string::npos ), - indent( 0 ), - width( consoleWidth-1 ), - tabChar( '\t' ) - {} - - TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; } - TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; } - TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; } - TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; } - - std::size_t initialIndent; // indent of first line, or npos - std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos - std::size_t width; // maximum width of text, including indent. Longer text will wrap - char tabChar; // If this char is seen the indent is changed to current pos - }; - - class Text { - public: - Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() ) - : attr( _attr ) - { - std::string wrappableChars = " [({.,/|\\-"; - std::size_t indent = _attr.initialIndent != std::string::npos - ? _attr.initialIndent - : _attr.indent; - std::string remainder = _str; - - while( !remainder.empty() ) { - if( lines.size() >= 1000 ) { - lines.push_back( "... message truncated due to excessive size" ); - return; - } - std::size_t tabPos = std::string::npos; - std::size_t width = (std::min)( remainder.size(), _attr.width - indent ); - std::size_t pos = remainder.find_first_of( '\n' ); - if( pos <= width ) { - width = pos; - } - pos = remainder.find_last_of( _attr.tabChar, width ); - if( pos != std::string::npos ) { - tabPos = pos; - if( remainder[width] == '\n' ) - width--; - remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 ); - } - - if( width == remainder.size() ) { - spliceLine( indent, remainder, width ); - } - else if( remainder[width] == '\n' ) { - spliceLine( indent, remainder, width ); - if( width <= 1 || remainder.size() != 1 ) - remainder = remainder.substr( 1 ); - indent = _attr.indent; - } - else { - pos = remainder.find_last_of( wrappableChars, width ); - if( pos != std::string::npos && pos > 0 ) { - spliceLine( indent, remainder, pos ); - if( remainder[0] == ' ' ) - remainder = remainder.substr( 1 ); - } - else { - spliceLine( indent, remainder, width-1 ); - lines.back() += "-"; - } - if( lines.size() == 1 ) - indent = _attr.indent; - if( tabPos != std::string::npos ) - indent += tabPos; - } - } - } - - void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) { - lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) ); - _remainder = _remainder.substr( _pos ); - } - - typedef std::vector::const_iterator const_iterator; - - const_iterator begin() const { return lines.begin(); } - const_iterator end() const { return lines.end(); } - std::string const& last() const { return lines.back(); } - std::size_t size() const { return lines.size(); } - std::string const& operator[]( std::size_t _index ) const { return lines[_index]; } - std::string toString() const { - std::ostringstream oss; - oss << *this; - return oss.str(); - } - - inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) { - for( Text::const_iterator it = _text.begin(), itEnd = _text.end(); - it != itEnd; ++it ) { - if( it != _text.begin() ) - _stream << "\n"; - _stream << *it; - } - return _stream; - } - - private: - std::string str; - TextAttributes attr; - std::vector lines; - }; - -} // end namespace Tbc - -#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -} // end outer namespace -#endif - -#endif // TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -#undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE - -namespace Catch { - using Tbc::Text; - using Tbc::TextAttributes; -} - -// #included from: catch_console_colour.hpp -#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED - -namespace Catch { - - namespace Detail { - struct IColourImpl; - } - - struct Colour { - enum Code { - None = 0, - - White, - Red, - Green, - Blue, - Cyan, - Yellow, - Grey, - - Bright = 0x10, - - BrightRed = Bright | Red, - BrightGreen = Bright | Green, - LightGrey = Bright | Grey, - BrightWhite = Bright | White, - - // By intention - FileName = LightGrey, - ResultError = BrightRed, - ResultSuccess = BrightGreen, - - Error = BrightRed, - Success = Green, - - OriginalExpression = Cyan, - ReconstructedExpression = Yellow, - - SecondaryText = LightGrey, - Headers = White - }; - - // Use constructed object for RAII guard - Colour( Code _colourCode ); - ~Colour(); - - // Use static method for one-shot changes - static void use( Code _colourCode ); - - private: - Colour( Colour const& other ); - static Detail::IColourImpl* impl(); - }; - -} // end namespace Catch - -// #included from: catch_interfaces_reporter.h -#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED - -// #included from: catch_option.hpp -#define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED - -namespace Catch { - - // An optional type - template - class Option { - public: - Option() : nullableValue( NULL ) {} - Option( T const& _value ) - : nullableValue( new( storage ) T( _value ) ) - {} - Option( Option const& _other ) - : nullableValue( _other ? new( storage ) T( *_other ) : NULL ) - {} - - ~Option() { - reset(); - } - - Option& operator= ( Option const& _other ) { - if( &_other != this ) { - reset(); - if( _other ) - nullableValue = new( storage ) T( *_other ); - } - return *this; - } - Option& operator = ( T const& _value ) { - reset(); - nullableValue = new( storage ) T( _value ); - return *this; - } - - void reset() { - if( nullableValue ) - nullableValue->~T(); - nullableValue = NULL; - } - - T& operator*() { return *nullableValue; } - T const& operator*() const { return *nullableValue; } - T* operator->() { return nullableValue; } - const T* operator->() const { return nullableValue; } - - T valueOr( T const& defaultValue ) const { - return nullableValue ? *nullableValue : defaultValue; - } - - bool some() const { return nullableValue != NULL; } - bool none() const { return nullableValue == NULL; } - - bool operator !() const { return nullableValue == NULL; } - operator SafeBool::type() const { - return SafeBool::makeSafe( some() ); - } - - private: - T* nullableValue; - char storage[sizeof(T)]; - }; - -} // end namespace Catch - -#include -#include -#include -#include - -namespace Catch -{ - struct ReporterConfig { - explicit ReporterConfig( Ptr const& _fullConfig ) - : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} - - ReporterConfig( Ptr const& _fullConfig, std::ostream& _stream ) - : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} - - std::ostream& stream() const { return *m_stream; } - Ptr fullConfig() const { return m_fullConfig; } - - private: - std::ostream* m_stream; - Ptr m_fullConfig; - }; - - struct ReporterPreferences { - ReporterPreferences() - : shouldRedirectStdOut( false ) - {} - - bool shouldRedirectStdOut; - }; - - template - struct LazyStat : Option { - LazyStat() : used( false ) {} - LazyStat& operator=( T const& _value ) { - Option::operator=( _value ); - used = false; - return *this; - } - void reset() { - Option::reset(); - used = false; - } - bool used; - }; - - struct TestRunInfo { - TestRunInfo( std::string const& _name ) : name( _name ) {} - std::string name; - }; - struct GroupInfo { - GroupInfo( std::string const& _name, - std::size_t _groupIndex, - std::size_t _groupsCount ) - : name( _name ), - groupIndex( _groupIndex ), - groupsCounts( _groupsCount ) - {} - - std::string name; - std::size_t groupIndex; - std::size_t groupsCounts; - }; - - struct AssertionStats { - AssertionStats( AssertionResult const& _assertionResult, - std::vector const& _infoMessages, - Totals const& _totals ) - : assertionResult( _assertionResult ), - infoMessages( _infoMessages ), - totals( _totals ) - { - if( assertionResult.hasMessage() ) { - // Copy message into messages list. - // !TBD This should have been done earlier, somewhere - MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); - builder << assertionResult.getMessage(); - builder.m_info.message = builder.m_stream.str(); - - infoMessages.push_back( builder.m_info ); - } - } - virtual ~AssertionStats(); - -# ifdef CATCH_CPP11_OR_GREATER - AssertionStats( AssertionStats const& ) = default; - AssertionStats( AssertionStats && ) = default; - AssertionStats& operator = ( AssertionStats const& ) = default; - AssertionStats& operator = ( AssertionStats && ) = default; -# endif - - AssertionResult assertionResult; - std::vector infoMessages; - Totals totals; - }; - - struct SectionStats { - SectionStats( SectionInfo const& _sectionInfo, - Counts const& _assertions, - double _durationInSeconds, - bool _missingAssertions ) - : sectionInfo( _sectionInfo ), - assertions( _assertions ), - durationInSeconds( _durationInSeconds ), - missingAssertions( _missingAssertions ) - {} - virtual ~SectionStats(); -# ifdef CATCH_CPP11_OR_GREATER - SectionStats( SectionStats const& ) = default; - SectionStats( SectionStats && ) = default; - SectionStats& operator = ( SectionStats const& ) = default; - SectionStats& operator = ( SectionStats && ) = default; -# endif - - SectionInfo sectionInfo; - Counts assertions; - double durationInSeconds; - bool missingAssertions; - }; - - struct TestCaseStats { - TestCaseStats( TestCaseInfo const& _testInfo, - Totals const& _totals, - std::string const& _stdOut, - std::string const& _stdErr, - bool _aborting ) - : testInfo( _testInfo ), - totals( _totals ), - stdOut( _stdOut ), - stdErr( _stdErr ), - aborting( _aborting ) - {} - virtual ~TestCaseStats(); - -# ifdef CATCH_CPP11_OR_GREATER - TestCaseStats( TestCaseStats const& ) = default; - TestCaseStats( TestCaseStats && ) = default; - TestCaseStats& operator = ( TestCaseStats const& ) = default; - TestCaseStats& operator = ( TestCaseStats && ) = default; -# endif - - TestCaseInfo testInfo; - Totals totals; - std::string stdOut; - std::string stdErr; - bool aborting; - }; - - struct TestGroupStats { - TestGroupStats( GroupInfo const& _groupInfo, - Totals const& _totals, - bool _aborting ) - : groupInfo( _groupInfo ), - totals( _totals ), - aborting( _aborting ) - {} - TestGroupStats( GroupInfo const& _groupInfo ) - : groupInfo( _groupInfo ), - aborting( false ) - {} - virtual ~TestGroupStats(); - -# ifdef CATCH_CPP11_OR_GREATER - TestGroupStats( TestGroupStats const& ) = default; - TestGroupStats( TestGroupStats && ) = default; - TestGroupStats& operator = ( TestGroupStats const& ) = default; - TestGroupStats& operator = ( TestGroupStats && ) = default; -# endif - - GroupInfo groupInfo; - Totals totals; - bool aborting; - }; - - struct TestRunStats { - TestRunStats( TestRunInfo const& _runInfo, - Totals const& _totals, - bool _aborting ) - : runInfo( _runInfo ), - totals( _totals ), - aborting( _aborting ) - {} - virtual ~TestRunStats(); - -# ifndef CATCH_CPP11_OR_GREATER - TestRunStats( TestRunStats const& _other ) - : runInfo( _other.runInfo ), - totals( _other.totals ), - aborting( _other.aborting ) - {} -# else - TestRunStats( TestRunStats const& ) = default; - TestRunStats( TestRunStats && ) = default; - TestRunStats& operator = ( TestRunStats const& ) = default; - TestRunStats& operator = ( TestRunStats && ) = default; -# endif - - TestRunInfo runInfo; - Totals totals; - bool aborting; - }; - - struct IStreamingReporter : IShared { - virtual ~IStreamingReporter(); - - // Implementing class must also provide the following static method: - // static std::string getDescription(); - - virtual ReporterPreferences getPreferences() const = 0; - - virtual void noMatchingTestCases( std::string const& spec ) = 0; - - virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; - virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; - virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; - - virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; - - virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; - virtual void sectionEnded( SectionStats const& sectionStats ) = 0; - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; - virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; - }; - - struct IReporterFactory { - virtual ~IReporterFactory(); - virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0; - virtual std::string getDescription() const = 0; - }; - - struct IReporterRegistry { - typedef std::map FactoryMap; - - virtual ~IReporterRegistry(); - virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const = 0; - virtual FactoryMap const& getFactories() const = 0; - }; - -} - -#include -#include - -namespace Catch { - - inline std::size_t listTests( Config const& config ) { - - TestSpec testSpec = config.testSpec(); - if( config.testSpec().hasFilters() ) - std::cout << "Matching test cases:\n"; - else { - std::cout << "All available test cases:\n"; - testSpec = TestSpecParser().parse( "*" ).testSpec(); - } - - std::size_t matchedTests = 0; - TextAttributes nameAttr, tagsAttr; - nameAttr.setInitialIndent( 2 ).setIndent( 4 ); - tagsAttr.setIndent( 6 ); - - std::vector matchedTestCases; - getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, config, matchedTestCases ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - matchedTests++; - TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); - Colour::Code colour = testCaseInfo.isHidden - ? Colour::SecondaryText - : Colour::None; - Colour colourGuard( colour ); - - std::cout << Text( testCaseInfo.name, nameAttr ) << std::endl; - if( !testCaseInfo.tags.empty() ) - std::cout << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl; - } - - if( !config.testSpec().hasFilters() ) - std::cout << pluralise( matchedTests, "test case" ) << "\n" << std::endl; - else - std::cout << pluralise( matchedTests, "matching test case" ) << "\n" << std::endl; - return matchedTests; - } - - inline std::size_t listTestsNamesOnly( Config const& config ) { - TestSpec testSpec = config.testSpec(); - if( !config.testSpec().hasFilters() ) - testSpec = TestSpecParser().parse( "*" ).testSpec(); - std::size_t matchedTests = 0; - std::vector matchedTestCases; - getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, config, matchedTestCases ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - matchedTests++; - TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); - std::cout << testCaseInfo.name << std::endl; - } - return matchedTests; - } - - struct TagInfo { - TagInfo() : count ( 0 ) {} - void add( std::string const& spelling ) { - ++count; - spellings.insert( spelling ); - } - std::string all() const { - std::string out; - for( std::set::const_iterator it = spellings.begin(), itEnd = spellings.end(); - it != itEnd; - ++it ) - out += "[" + *it + "]"; - return out; - } - std::set spellings; - std::size_t count; - }; - - inline std::size_t listTags( Config const& config ) { - TestSpec testSpec = config.testSpec(); - if( config.testSpec().hasFilters() ) - std::cout << "Tags for matching test cases:\n"; - else { - std::cout << "All available tags:\n"; - testSpec = TestSpecParser().parse( "*" ).testSpec(); - } - - std::map tagCounts; - - std::vector matchedTestCases; - getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, config, matchedTestCases ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - for( std::set::const_iterator tagIt = it->getTestCaseInfo().tags.begin(), - tagItEnd = it->getTestCaseInfo().tags.end(); - tagIt != tagItEnd; - ++tagIt ) { - std::string tagName = *tagIt; - std::string lcaseTagName = toLower( tagName ); - std::map::iterator countIt = tagCounts.find( lcaseTagName ); - if( countIt == tagCounts.end() ) - countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first; - countIt->second.add( tagName ); - } - } - - for( std::map::const_iterator countIt = tagCounts.begin(), - countItEnd = tagCounts.end(); - countIt != countItEnd; - ++countIt ) { - std::ostringstream oss; - oss << " " << std::setw(2) << countIt->second.count << " "; - Text wrapper( countIt->second.all(), TextAttributes() - .setInitialIndent( 0 ) - .setIndent( oss.str().size() ) - .setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) ); - std::cout << oss.str() << wrapper << "\n"; - } - std::cout << pluralise( tagCounts.size(), "tag" ) << "\n" << std::endl; - return tagCounts.size(); - } - - inline std::size_t listReporters( Config const& /*config*/ ) { - std::cout << "Available reports:\n"; - IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); - IReporterRegistry::FactoryMap::const_iterator itBegin = factories.begin(), itEnd = factories.end(), it; - std::size_t maxNameLen = 0; - for(it = itBegin; it != itEnd; ++it ) - maxNameLen = (std::max)( maxNameLen, it->first.size() ); - - for(it = itBegin; it != itEnd; ++it ) { - Text wrapper( it->second->getDescription(), TextAttributes() - .setInitialIndent( 0 ) - .setIndent( 7+maxNameLen ) - .setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) ); - std::cout << " " - << it->first - << ":" - << std::string( maxNameLen - it->first.size() + 2, ' ' ) - << wrapper << "\n"; - } - std::cout << std::endl; - return factories.size(); - } - - inline Option list( Config const& config ) { - Option listedCount; - if( config.listTests() ) - listedCount = listedCount.valueOr(0) + listTests( config ); - if( config.listTestNamesOnly() ) - listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config ); - if( config.listTags() ) - listedCount = listedCount.valueOr(0) + listTags( config ); - if( config.listReporters() ) - listedCount = listedCount.valueOr(0) + listReporters( config ); - return listedCount; - } - -} // end namespace Catch - -// #included from: internal/catch_runner_impl.hpp -#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED - -// #included from: catch_test_case_tracker.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED - -#include -#include -#include - -namespace Catch { -namespace SectionTracking { - - class TrackedSection { - - typedef std::map TrackedSections; - - public: - enum RunState { - NotStarted, - Executing, - ExecutingChildren, - Completed - }; - - TrackedSection( std::string const& name, TrackedSection* parent ) - : m_name( name ), m_runState( NotStarted ), m_parent( parent ) - {} - - RunState runState() const { return m_runState; } - - TrackedSection* findChild( std::string const& childName ) { - TrackedSections::iterator it = m_children.find( childName ); - return it != m_children.end() - ? &it->second - : NULL; - } - TrackedSection* acquireChild( std::string const& childName ) { - if( TrackedSection* child = findChild( childName ) ) - return child; - m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) ); - return findChild( childName ); - } - void enter() { - if( m_runState == NotStarted ) - m_runState = Executing; - } - void leave() { - for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end(); - it != itEnd; - ++it ) - if( it->second.runState() != Completed ) { - m_runState = ExecutingChildren; - return; - } - m_runState = Completed; - } - TrackedSection* getParent() { - return m_parent; - } - bool hasChildren() const { - return !m_children.empty(); - } - - private: - std::string m_name; - RunState m_runState; - TrackedSections m_children; - TrackedSection* m_parent; - - }; - - class TestCaseTracker { - public: - TestCaseTracker( std::string const& testCaseName ) - : m_testCase( testCaseName, NULL ), - m_currentSection( &m_testCase ), - m_completedASectionThisRun( false ) - {} - - bool enterSection( std::string const& name ) { - TrackedSection* child = m_currentSection->acquireChild( name ); - if( m_completedASectionThisRun || child->runState() == TrackedSection::Completed ) - return false; - - m_currentSection = child; - m_currentSection->enter(); - return true; - } - void leaveSection() { - m_currentSection->leave(); - m_currentSection = m_currentSection->getParent(); - assert( m_currentSection != NULL ); - m_completedASectionThisRun = true; - } - - bool currentSectionHasChildren() const { - return m_currentSection->hasChildren(); - } - bool isCompleted() const { - return m_testCase.runState() == TrackedSection::Completed; - } - - class Guard { - public: - Guard( TestCaseTracker& tracker ) : m_tracker( tracker ) { - m_tracker.enterTestCase(); - } - ~Guard() { - m_tracker.leaveTestCase(); - } - private: - Guard( Guard const& ); - void operator = ( Guard const& ); - TestCaseTracker& m_tracker; - }; - - private: - void enterTestCase() { - m_currentSection = &m_testCase; - m_completedASectionThisRun = false; - m_testCase.enter(); - } - void leaveTestCase() { - m_testCase.leave(); - } - - TrackedSection m_testCase; - TrackedSection* m_currentSection; - bool m_completedASectionThisRun; - }; - -} // namespace SectionTracking - -using SectionTracking::TestCaseTracker; - -} // namespace Catch - -#include -#include - -namespace Catch { - - class StreamRedirect { - - public: - StreamRedirect( std::ostream& stream, std::string& targetString ) - : m_stream( stream ), - m_prevBuf( stream.rdbuf() ), - m_targetString( targetString ) - { - stream.rdbuf( m_oss.rdbuf() ); - } - - ~StreamRedirect() { - m_targetString += m_oss.str(); - m_stream.rdbuf( m_prevBuf ); - } - - private: - std::ostream& m_stream; - std::streambuf* m_prevBuf; - std::ostringstream m_oss; - std::string& m_targetString; - }; - - /////////////////////////////////////////////////////////////////////////// - - class RunContext : public IResultCapture, public IRunner { - - RunContext( RunContext const& ); - void operator =( RunContext const& ); - - public: - - explicit RunContext( Ptr const& config, Ptr const& reporter ) - : m_runInfo( config->name() ), - m_context( getCurrentMutableContext() ), - m_activeTestCase( NULL ), - m_config( config ), - m_reporter( reporter ), - m_prevRunner( m_context.getRunner() ), - m_prevResultCapture( m_context.getResultCapture() ), - m_prevConfig( m_context.getConfig() ) - { - m_context.setRunner( this ); - m_context.setConfig( m_config ); - m_context.setResultCapture( this ); - m_reporter->testRunStarting( m_runInfo ); - } - - virtual ~RunContext() { - m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) ); - m_context.setRunner( m_prevRunner ); - m_context.setConfig( NULL ); - m_context.setResultCapture( m_prevResultCapture ); - m_context.setConfig( m_prevConfig ); - } - - void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) { - m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) ); - } - void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) { - m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) ); - } - - Totals runTest( TestCase const& testCase ) { - Totals prevTotals = m_totals; - - std::string redirectedCout; - std::string redirectedCerr; - - TestCaseInfo testInfo = testCase.getTestCaseInfo(); - - m_reporter->testCaseStarting( testInfo ); - - m_activeTestCase = &testCase; - m_testCaseTracker = TestCaseTracker( testInfo.name ); - - do { - do { - runCurrentTest( redirectedCout, redirectedCerr ); - } - while( !m_testCaseTracker->isCompleted() && !aborting() ); - } - while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() ); - - Totals deltaTotals = m_totals.delta( prevTotals ); - m_totals.testCases += deltaTotals.testCases; - m_reporter->testCaseEnded( TestCaseStats( testInfo, - deltaTotals, - redirectedCout, - redirectedCerr, - aborting() ) ); - - m_activeTestCase = NULL; - m_testCaseTracker.reset(); - - return deltaTotals; - } - - Ptr config() const { - return m_config; - } - - private: // IResultCapture - - virtual ResultAction::Value acceptExpression( ExpressionResultBuilder const& assertionResult, AssertionInfo const& assertionInfo ) { - m_lastAssertionInfo = assertionInfo; - return actOnCurrentResult( assertionResult.buildResult( assertionInfo ) ); - } - - virtual void assertionEnded( AssertionResult const& result ) { - if( result.getResultType() == ResultWas::Ok ) { - m_totals.assertions.passed++; - } - else if( !result.isOk() ) { - m_totals.assertions.failed++; - } - - if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) ) - m_messages.clear(); - - // Reset working state - m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition ); - } - - virtual bool sectionStarted ( - SectionInfo const& sectionInfo, - Counts& assertions - ) - { - std::ostringstream oss; - oss << sectionInfo.name << "@" << sectionInfo.lineInfo; - - if( !m_testCaseTracker->enterSection( oss.str() ) ) - return false; - - m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; - - m_reporter->sectionStarting( sectionInfo ); - - assertions = m_totals.assertions; - - return true; - } - bool testForMissingAssertions( Counts& assertions ) { - if( assertions.total() != 0 || - !m_config->warnAboutMissingAssertions() || - m_testCaseTracker->currentSectionHasChildren() ) - return false; - m_totals.assertions.failed++; - assertions.failed++; - return true; - } - - virtual void sectionEnded( SectionInfo const& info, Counts const& prevAssertions, double _durationInSeconds ) { - if( std::uncaught_exception() ) { - m_unfinishedSections.push_back( UnfinishedSections( info, prevAssertions, _durationInSeconds ) ); - return; - } - - Counts assertions = m_totals.assertions - prevAssertions; - bool missingAssertions = testForMissingAssertions( assertions ); - - m_testCaseTracker->leaveSection(); - - m_reporter->sectionEnded( SectionStats( info, assertions, _durationInSeconds, missingAssertions ) ); - m_messages.clear(); - } - - virtual void pushScopedMessage( MessageInfo const& message ) { - m_messages.push_back( message ); - } - - virtual void popScopedMessage( MessageInfo const& message ) { - m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() ); - } - - virtual bool shouldDebugBreak() const { - return m_config->shouldDebugBreak(); - } - - virtual std::string getCurrentTestName() const { - return m_activeTestCase - ? m_activeTestCase->getTestCaseInfo().name - : ""; - } - - virtual const AssertionResult* getLastResult() const { - return &m_lastResult; - } - - public: - // !TBD We need to do this another way! - bool aborting() const { - return m_totals.assertions.failed == static_cast( m_config->abortAfter() ); - } - - private: - - ResultAction::Value actOnCurrentResult( AssertionResult const& result ) { - m_lastResult = result; - assertionEnded( m_lastResult ); - - ResultAction::Value action = ResultAction::None; - - if( !m_lastResult.isOk() ) { - action = ResultAction::Failed; - if( shouldDebugBreak() ) - action = (ResultAction::Value)( action | ResultAction::Debug ); - if( aborting() ) - action = (ResultAction::Value)( action | ResultAction::Abort ); - } - return action; - } - - void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) { - TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); - SectionInfo testCaseSection( testCaseInfo.name, testCaseInfo.description, testCaseInfo.lineInfo ); - m_reporter->sectionStarting( testCaseSection ); - Counts prevAssertions = m_totals.assertions; - double duration = 0; - try { - m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal ); - TestCaseTracker::Guard guard( *m_testCaseTracker ); - - Timer timer; - timer.start(); - if( m_reporter->getPreferences().shouldRedirectStdOut ) { - StreamRedirect coutRedir( std::cout, redirectedCout ); - StreamRedirect cerrRedir( std::cerr, redirectedCerr ); - m_activeTestCase->invoke(); - } - else { - m_activeTestCase->invoke(); - } - duration = timer.getElapsedSeconds(); - } - catch( TestFailureException& ) { - // This just means the test was aborted due to failure - } - catch(...) { - ExpressionResultBuilder exResult( ResultWas::ThrewException ); - exResult << translateActiveException(); - actOnCurrentResult( exResult.buildResult( m_lastAssertionInfo ) ); - } - // If sections ended prematurely due to an exception we stored their - // infos here so we can tear them down outside the unwind process. - for( std::vector::const_reverse_iterator it = m_unfinishedSections.rbegin(), - itEnd = m_unfinishedSections.rend(); - it != itEnd; - ++it ) - sectionEnded( it->info, it->prevAssertions, it->durationInSeconds ); - m_unfinishedSections.clear(); - m_messages.clear(); - - Counts assertions = m_totals.assertions - prevAssertions; - bool missingAssertions = testForMissingAssertions( assertions ); - - SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions ); - m_reporter->sectionEnded( testCaseSectionStats ); - } - - private: - struct UnfinishedSections { - UnfinishedSections( SectionInfo const& _info, Counts const& _prevAssertions, double _durationInSeconds ) - : info( _info ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds ) - {} - - SectionInfo info; - Counts prevAssertions; - double durationInSeconds; - }; - - TestRunInfo m_runInfo; - IMutableContext& m_context; - TestCase const* m_activeTestCase; - Option m_testCaseTracker; - AssertionResult m_lastResult; - - Ptr m_config; - Totals m_totals; - Ptr m_reporter; - std::vector m_messages; - IRunner* m_prevRunner; - IResultCapture* m_prevResultCapture; - Ptr m_prevConfig; - AssertionInfo m_lastAssertionInfo; - std::vector m_unfinishedSections; - }; - -} // end namespace Catch - -// #included from: internal/catch_version.h -#define TWOBLUECUBES_CATCH_VERSION_H_INCLUDED - -namespace Catch { - - // Versioning information - struct Version { - Version( unsigned int _majorVersion, - unsigned int _minorVersion, - unsigned int _buildNumber, - char const* const _branchName ) - : majorVersion( _majorVersion ), - minorVersion( _minorVersion ), - buildNumber( _buildNumber ), - branchName( _branchName ) - {} - - unsigned int const majorVersion; - unsigned int const minorVersion; - unsigned int const buildNumber; - char const* const branchName; - - private: - void operator=( Version const& ); - }; - - extern Version libraryVersion; -} - -#include -#include -#include - -namespace Catch { - - class Runner { - - public: - Runner( Ptr const& config ) - : m_config( config ) - { - openStream(); - makeReporter(); - } - - Totals runTests() { - - RunContext context( m_config.get(), m_reporter ); - - Totals totals; - - context.testGroupStarting( "", 1, 1 ); // deprecated? - - TestSpec testSpec = m_config->testSpec(); - if( !testSpec.hasFilters() ) - testSpec = TestSpecParser().parse( "~[.]" ).testSpec(); // All not hidden tests - - std::vector testCases; - getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, *m_config, testCases ); - - int testsRunForGroup = 0; - for( std::vector::const_iterator it = testCases.begin(), itEnd = testCases.end(); - it != itEnd; - ++it ) { - testsRunForGroup++; - if( m_testsAlreadyRun.find( *it ) == m_testsAlreadyRun.end() ) { - - if( context.aborting() ) - break; - - totals += context.runTest( *it ); - m_testsAlreadyRun.insert( *it ); - } - } - context.testGroupEnded( "", totals, 1, 1 ); - return totals; - } - - private: - void openStream() { - // Open output file, if specified - if( !m_config->getFilename().empty() ) { - m_ofs.open( m_config->getFilename().c_str() ); - if( m_ofs.fail() ) { - std::ostringstream oss; - oss << "Unable to open file: '" << m_config->getFilename() << "'"; - throw std::domain_error( oss.str() ); - } - m_config->setStreamBuf( m_ofs.rdbuf() ); - } - } - void makeReporter() { - std::string reporterName = m_config->getReporterName().empty() - ? "console" - : m_config->getReporterName(); - - m_reporter = getRegistryHub().getReporterRegistry().create( reporterName, m_config.get() ); - if( !m_reporter ) { - std::ostringstream oss; - oss << "No reporter registered with name: '" << reporterName << "'"; - throw std::domain_error( oss.str() ); - } - } - - private: - Ptr m_config; - std::ofstream m_ofs; - Ptr m_reporter; - std::set m_testsAlreadyRun; - }; - - class Session { - static bool alreadyInstantiated; - - public: - - struct OnUnusedOptions { enum DoWhat { Ignore, Fail }; }; - - Session() - : m_cli( makeCommandLineParser() ) { - if( alreadyInstantiated ) { - std::string msg = "Only one instance of Catch::Session can ever be used"; - std::cerr << msg << std::endl; - throw std::logic_error( msg ); - } - alreadyInstantiated = true; - } - ~Session() { - Catch::cleanUp(); - } - - void showHelp( std::string const& processName ) { - std::cout << "\nCatch v" << libraryVersion.majorVersion << "." - << libraryVersion.minorVersion << " build " - << libraryVersion.buildNumber; - if( libraryVersion.branchName != std::string( "master" ) ) - std::cout << " (" << libraryVersion.branchName << " branch)"; - std::cout << "\n"; - - m_cli.usage( std::cout, processName ); - std::cout << "For more detail usage please see the project docs\n" << std::endl; - } - - int applyCommandLine( int argc, char* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) { - try { - m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail ); - m_unusedTokens = m_cli.parseInto( argc, argv, m_configData ); - if( m_configData.showHelp ) - showHelp( m_configData.processName ); - m_config.reset(); - } - catch( std::exception& ex ) { - { - Colour colourGuard( Colour::Red ); - std::cerr << "\nError(s) in input:\n" - << Text( ex.what(), TextAttributes().setIndent(2) ) - << "\n\n"; - } - m_cli.usage( std::cout, m_configData.processName ); - return (std::numeric_limits::max)(); - } - return 0; - } - - void useConfigData( ConfigData const& _configData ) { - m_configData = _configData; - m_config.reset(); - } - - int run( int argc, char* const argv[] ) { - - int returnCode = applyCommandLine( argc, argv ); - if( returnCode == 0 ) - returnCode = run(); - return returnCode; - } - - int run() { - if( m_configData.showHelp ) - return 0; - - try - { - config(); // Force config to be constructed - Runner runner( m_config ); - - // Handle list request - if( Option listed = list( config() ) ) - return static_cast( *listed ); - - return static_cast( runner.runTests().assertions.failed ); - } - catch( std::exception& ex ) { - std::cerr << ex.what() << std::endl; - return (std::numeric_limits::max)(); - } - } - - Clara::CommandLine const& cli() const { - return m_cli; - } - std::vector const& unusedTokens() const { - return m_unusedTokens; - } - ConfigData& configData() { - return m_configData; - } - Config& config() { - if( !m_config ) - m_config = new Config( m_configData ); - return *m_config; - } - - private: - Clara::CommandLine m_cli; - std::vector m_unusedTokens; - ConfigData m_configData; - Ptr m_config; - }; - - bool Session::alreadyInstantiated = false; - -} // end namespace Catch - -// #included from: catch_registry_hub.hpp -#define TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED - -// #included from: catch_test_case_registry_impl.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - class TestRegistry : public ITestCaseRegistry { - public: - TestRegistry() : m_unnamedCount( 0 ) {} - virtual ~TestRegistry(); - - virtual void registerTest( TestCase const& testCase ) { - std::string name = testCase.getTestCaseInfo().name; - if( name == "" ) { - std::ostringstream oss; - oss << "Anonymous test case " << ++m_unnamedCount; - return registerTest( testCase.withName( oss.str() ) ); - } - - if( m_functions.find( testCase ) == m_functions.end() ) { - m_functions.insert( testCase ); - m_functionsInOrder.push_back( testCase ); - if( !testCase.isHidden() ) - m_nonHiddenFunctions.push_back( testCase ); - } - else { - TestCase const& prev = *m_functions.find( testCase ); - { - Colour colourGuard( Colour::Red ); - std::cerr << "error: TEST_CASE( \"" << name << "\" ) already defined.\n" - << "\tFirst seen at " << prev.getTestCaseInfo().lineInfo << "\n" - << "\tRedefined at " << testCase.getTestCaseInfo().lineInfo << std::endl; - } - exit(1); - } - } - - virtual std::vector const& getAllTests() const { - return m_functionsInOrder; - } - - virtual std::vector const& getAllNonHiddenTests() const { - return m_nonHiddenFunctions; - } - - virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector& matchingTestCases ) const { - for( std::vector::const_iterator it = m_functionsInOrder.begin(), - itEnd = m_functionsInOrder.end(); - it != itEnd; - ++it ) { - if( testSpec.matches( *it ) && ( config.allowThrows() || !it->throws() ) ) - matchingTestCases.push_back( *it ); - } - } - - private: - - std::set m_functions; - std::vector m_functionsInOrder; - std::vector m_nonHiddenFunctions; - size_t m_unnamedCount; - }; - - /////////////////////////////////////////////////////////////////////////// - - class FreeFunctionTestCase : public SharedImpl { - public: - - FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {} - - virtual void invoke() const { - m_fun(); - } - - private: - virtual ~FreeFunctionTestCase(); - - TestFunction m_fun; - }; - - inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) { - std::string className = classOrQualifiedMethodName; - if( startsWith( className, "&" ) ) - { - std::size_t lastColons = className.rfind( "::" ); - std::size_t penultimateColons = className.rfind( "::", lastColons-1 ); - if( penultimateColons == std::string::npos ) - penultimateColons = 1; - className = className.substr( penultimateColons, lastColons-penultimateColons ); - } - return className; - } - - /////////////////////////////////////////////////////////////////////////// - - AutoReg::AutoReg( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ) { - registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo ); - } - - AutoReg::~AutoReg() {} - - void AutoReg::registerTestCase( ITestCase* testCase, - char const* classOrQualifiedMethodName, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ) { - - getMutableRegistryHub().registerTest - ( makeTestCase( testCase, - extractClassName( classOrQualifiedMethodName ), - nameAndDesc.name, - nameAndDesc.description, - lineInfo ) ); - } - -} // end namespace Catch - -// #included from: catch_reporter_registry.hpp -#define TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED - -#include - -namespace Catch { - - class ReporterRegistry : public IReporterRegistry { - - public: - - virtual ~ReporterRegistry() { - deleteAllValues( m_factories ); - } - - virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const { - FactoryMap::const_iterator it = m_factories.find( name ); - if( it == m_factories.end() ) - return NULL; - return it->second->create( ReporterConfig( config ) ); - } - - void registerReporter( std::string const& name, IReporterFactory* factory ) { - m_factories.insert( std::make_pair( name, factory ) ); - } - - FactoryMap const& getFactories() const { - return m_factories; - } - - private: - FactoryMap m_factories; - }; -} - -// #included from: catch_exception_translator_registry.hpp -#define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED - -#ifdef __OBJC__ -#import "Foundation/Foundation.h" -#endif - -namespace Catch { - - class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { - public: - ~ExceptionTranslatorRegistry() { - deleteAll( m_translators ); - } - - virtual void registerTranslator( const IExceptionTranslator* translator ) { - m_translators.push_back( translator ); - } - - virtual std::string translateActiveException() const { - try { -#ifdef __OBJC__ - // In Objective-C try objective-c exceptions first - @try { - throw; - } - @catch (NSException *exception) { - return toString( [exception description] ); - } -#else - throw; -#endif - } - catch( std::exception& ex ) { - return ex.what(); - } - catch( std::string& msg ) { - return msg; - } - catch( const char* msg ) { - return msg; - } - catch(...) { - return tryTranslators( m_translators.begin() ); - } - } - - std::string tryTranslators( std::vector::const_iterator it ) const { - if( it == m_translators.end() ) - return "Unknown exception"; - - try { - return (*it)->translate(); - } - catch(...) { - return tryTranslators( it+1 ); - } - } - - private: - std::vector m_translators; - }; -} - -namespace Catch { - - namespace { - - class RegistryHub : public IRegistryHub, public IMutableRegistryHub { - - RegistryHub( RegistryHub const& ); - void operator=( RegistryHub const& ); - - public: // IRegistryHub - RegistryHub() { - } - virtual IReporterRegistry const& getReporterRegistry() const { - return m_reporterRegistry; - } - virtual ITestCaseRegistry const& getTestCaseRegistry() const { - return m_testCaseRegistry; - } - virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() { - return m_exceptionTranslatorRegistry; - } - - public: // IMutableRegistryHub - virtual void registerReporter( std::string const& name, IReporterFactory* factory ) { - m_reporterRegistry.registerReporter( name, factory ); - } - virtual void registerTest( TestCase const& testInfo ) { - m_testCaseRegistry.registerTest( testInfo ); - } - virtual void registerTranslator( const IExceptionTranslator* translator ) { - m_exceptionTranslatorRegistry.registerTranslator( translator ); - } - - private: - TestRegistry m_testCaseRegistry; - ReporterRegistry m_reporterRegistry; - ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; - }; - - // Single, global, instance - inline RegistryHub*& getTheRegistryHub() { - static RegistryHub* theRegistryHub = NULL; - if( !theRegistryHub ) - theRegistryHub = new RegistryHub(); - return theRegistryHub; - } - } - - IRegistryHub& getRegistryHub() { - return *getTheRegistryHub(); - } - IMutableRegistryHub& getMutableRegistryHub() { - return *getTheRegistryHub(); - } - void cleanUp() { - delete getTheRegistryHub(); - getTheRegistryHub() = NULL; - cleanUpContext(); - } - std::string translateActiveException() { - return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException(); - } - -} // end namespace Catch - -// #included from: catch_notimplemented_exception.hpp -#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED - -#include - -namespace Catch { - - NotImplementedException::NotImplementedException( SourceLineInfo const& lineInfo ) - : m_lineInfo( lineInfo ) { - std::ostringstream oss; - oss << lineInfo << ": function "; - oss << "not implemented"; - m_what = oss.str(); - } - - const char* NotImplementedException::what() const CATCH_NOEXCEPT { - return m_what.c_str(); - } - -} // end namespace Catch - -// #included from: catch_context_impl.hpp -#define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED - -// #included from: catch_stream.hpp -#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED - -// #included from: catch_streambuf.h -#define TWOBLUECUBES_CATCH_STREAMBUF_H_INCLUDED - -#include - -namespace Catch { - - class StreamBufBase : public std::streambuf { - public: - virtual ~StreamBufBase() CATCH_NOEXCEPT; - }; -} - -#include -#include - -namespace Catch { - - template - class StreamBufImpl : public StreamBufBase { - char data[bufferSize]; - WriterF m_writer; - - public: - StreamBufImpl() { - setp( data, data + sizeof(data) ); - } - - ~StreamBufImpl() CATCH_NOEXCEPT { - sync(); - } - - private: - int overflow( int c ) { - sync(); - - if( c != EOF ) { - if( pbase() == epptr() ) - m_writer( std::string( 1, static_cast( c ) ) ); - else - sputc( static_cast( c ) ); - } - return 0; - } - - int sync() { - if( pbase() != pptr() ) { - m_writer( std::string( pbase(), static_cast( pptr() - pbase() ) ) ); - setp( pbase(), epptr() ); - } - return 0; - } - }; - - /////////////////////////////////////////////////////////////////////////// - - struct OutputDebugWriter { - - void operator()( std::string const&str ) { - writeToDebugConsole( str ); - } - }; - - Stream::Stream() - : streamBuf( NULL ), isOwned( false ) - {} - - Stream::Stream( std::streambuf* _streamBuf, bool _isOwned ) - : streamBuf( _streamBuf ), isOwned( _isOwned ) - {} - - void Stream::release() { - if( isOwned ) { - delete streamBuf; - streamBuf = NULL; - isOwned = false; - } - } -} - -namespace Catch { - - class Context : public IMutableContext { - - Context() : m_config( NULL ), m_runner( NULL ), m_resultCapture( NULL ) {} - Context( Context const& ); - void operator=( Context const& ); - - public: // IContext - virtual IResultCapture* getResultCapture() { - return m_resultCapture; - } - virtual IRunner* getRunner() { - return m_runner; - } - virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) { - return getGeneratorsForCurrentTest() - .getGeneratorInfo( fileInfo, totalSize ) - .getCurrentIndex(); - } - virtual bool advanceGeneratorsForCurrentTest() { - IGeneratorsForTest* generators = findGeneratorsForCurrentTest(); - return generators && generators->moveNext(); - } - - virtual Ptr getConfig() const { - return m_config; - } - - public: // IMutableContext - virtual void setResultCapture( IResultCapture* resultCapture ) { - m_resultCapture = resultCapture; - } - virtual void setRunner( IRunner* runner ) { - m_runner = runner; - } - virtual void setConfig( Ptr const& config ) { - m_config = config; - } - - friend IMutableContext& getCurrentMutableContext(); - - private: - IGeneratorsForTest* findGeneratorsForCurrentTest() { - std::string testName = getResultCapture()->getCurrentTestName(); - - std::map::const_iterator it = - m_generatorsByTestName.find( testName ); - return it != m_generatorsByTestName.end() - ? it->second - : NULL; - } - - IGeneratorsForTest& getGeneratorsForCurrentTest() { - IGeneratorsForTest* generators = findGeneratorsForCurrentTest(); - if( !generators ) { - std::string testName = getResultCapture()->getCurrentTestName(); - generators = createGeneratorsForTest(); - m_generatorsByTestName.insert( std::make_pair( testName, generators ) ); - } - return *generators; - } - - private: - Ptr m_config; - IRunner* m_runner; - IResultCapture* m_resultCapture; - std::map m_generatorsByTestName; - }; - - namespace { - Context* currentContext = NULL; - } - IMutableContext& getCurrentMutableContext() { - if( !currentContext ) - currentContext = new Context(); - return *currentContext; - } - IContext& getCurrentContext() { - return getCurrentMutableContext(); - } - - Stream createStream( std::string const& streamName ) { - if( streamName == "stdout" ) return Stream( std::cout.rdbuf(), false ); - if( streamName == "stderr" ) return Stream( std::cerr.rdbuf(), false ); - if( streamName == "debug" ) return Stream( new StreamBufImpl, true ); - - throw std::domain_error( "Unknown stream: " + streamName ); - } - - void cleanUpContext() { - delete currentContext; - currentContext = NULL; - } -} - -// #included from: catch_console_colour_impl.hpp -#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED - -namespace Catch { namespace Detail { - struct IColourImpl { - virtual ~IColourImpl() {} - virtual void use( Colour::Code _colourCode ) = 0; - }; -}} - -#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// - -#ifndef NOMINMAX -#define NOMINMAX -#endif - -#ifdef __AFXDLL -#include -#else -#include -#endif - -namespace Catch { -namespace { - - class Win32ColourImpl : public Detail::IColourImpl { - public: - Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) ) - { - CONSOLE_SCREEN_BUFFER_INFO csbiInfo; - GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); - originalAttributes = csbiInfo.wAttributes; - } - - virtual void use( Colour::Code _colourCode ) { - switch( _colourCode ) { - case Colour::None: return setTextAttribute( originalAttributes ); - case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); - case Colour::Red: return setTextAttribute( FOREGROUND_RED ); - case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); - case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE ); - case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN ); - case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN ); - case Colour::Grey: return setTextAttribute( 0 ); - - case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY ); - case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED ); - case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN ); - case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); - - case Colour::Bright: throw std::logic_error( "not a colour" ); - } - } - - private: - void setTextAttribute( WORD _textAttribute ) { - SetConsoleTextAttribute( stdoutHandle, _textAttribute ); - } - HANDLE stdoutHandle; - WORD originalAttributes; - }; - - inline bool shouldUseColourForPlatform() { - return true; - } - - static Detail::IColourImpl* platformColourInstance() { - static Win32ColourImpl s_instance; - return &s_instance; - } - -} // end anon namespace -} // end namespace Catch - -#else // Not Windows - assumed to be POSIX compatible ////////////////////////// - -#include - -namespace Catch { -namespace { - - // use POSIX/ ANSI console terminal codes - // Thanks to Adam Strzelecki for original contribution - // (http://github.com/nanoant) - // https://github.com/philsquared/Catch/pull/131 - class PosixColourImpl : public Detail::IColourImpl { - public: - virtual void use( Colour::Code _colourCode ) { - switch( _colourCode ) { - case Colour::None: - case Colour::White: return setColour( "[0m" ); - case Colour::Red: return setColour( "[0;31m" ); - case Colour::Green: return setColour( "[0;32m" ); - case Colour::Blue: return setColour( "[0:34m" ); - case Colour::Cyan: return setColour( "[0;36m" ); - case Colour::Yellow: return setColour( "[0;33m" ); - case Colour::Grey: return setColour( "[1;30m" ); - - case Colour::LightGrey: return setColour( "[0;37m" ); - case Colour::BrightRed: return setColour( "[1;31m" ); - case Colour::BrightGreen: return setColour( "[1;32m" ); - case Colour::BrightWhite: return setColour( "[1;37m" ); - - case Colour::Bright: throw std::logic_error( "not a colour" ); - } - } - private: - void setColour( const char* _escapeCode ) { - std::cout << '\033' << _escapeCode; - } - }; - - inline bool shouldUseColourForPlatform() { - return isatty(STDOUT_FILENO); - } - - static Detail::IColourImpl* platformColourInstance() { - static PosixColourImpl s_instance; - return &s_instance; - } - -} // end anon namespace -} // end namespace Catch - -#endif // not Windows - -namespace Catch { - - namespace { - struct NoColourImpl : Detail::IColourImpl { - void use( Colour::Code ) {} - - static IColourImpl* instance() { - static NoColourImpl s_instance; - return &s_instance; - } - }; - static bool shouldUseColour() { - return shouldUseColourForPlatform() && !isDebuggerActive(); - } - } - - Colour::Colour( Code _colourCode ){ use( _colourCode ); } - Colour::~Colour(){ use( None ); } - void Colour::use( Code _colourCode ) { - impl()->use( _colourCode ); - } - - Detail::IColourImpl* Colour::impl() { - return shouldUseColour() - ? platformColourInstance() - : NoColourImpl::instance(); - } - -} // end namespace Catch - -// #included from: catch_generators_impl.hpp -#define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED - -#include -#include -#include - -namespace Catch { - - struct GeneratorInfo : IGeneratorInfo { - - GeneratorInfo( std::size_t size ) - : m_size( size ), - m_currentIndex( 0 ) - {} - - bool moveNext() { - if( ++m_currentIndex == m_size ) { - m_currentIndex = 0; - return false; - } - return true; - } - - std::size_t getCurrentIndex() const { - return m_currentIndex; - } - - std::size_t m_size; - std::size_t m_currentIndex; - }; - - /////////////////////////////////////////////////////////////////////////// - - class GeneratorsForTest : public IGeneratorsForTest { - - public: - ~GeneratorsForTest() { - deleteAll( m_generatorsInOrder ); - } - - IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) { - std::map::const_iterator it = m_generatorsByName.find( fileInfo ); - if( it == m_generatorsByName.end() ) { - IGeneratorInfo* info = new GeneratorInfo( size ); - m_generatorsByName.insert( std::make_pair( fileInfo, info ) ); - m_generatorsInOrder.push_back( info ); - return *info; - } - return *it->second; - } - - bool moveNext() { - std::vector::const_iterator it = m_generatorsInOrder.begin(); - std::vector::const_iterator itEnd = m_generatorsInOrder.end(); - for(; it != itEnd; ++it ) { - if( (*it)->moveNext() ) - return true; - } - return false; - } - - private: - std::map m_generatorsByName; - std::vector m_generatorsInOrder; - }; - - IGeneratorsForTest* createGeneratorsForTest() - { - return new GeneratorsForTest(); - } - -} // end namespace Catch - -// #included from: catch_assertionresult.hpp -#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED - -namespace Catch { - - AssertionInfo::AssertionInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - std::string const& _capturedExpression, - ResultDisposition::Flags _resultDisposition ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - capturedExpression( _capturedExpression ), - resultDisposition( _resultDisposition ) - {} - - AssertionResult::AssertionResult() {} - - AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) - : m_info( info ), - m_resultData( data ) - {} - - AssertionResult::~AssertionResult() {} - - // Result was a success - bool AssertionResult::succeeded() const { - return Catch::isOk( m_resultData.resultType ); - } - - // Result was a success, or failure is suppressed - bool AssertionResult::isOk() const { - return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); - } - - ResultWas::OfType AssertionResult::getResultType() const { - return m_resultData.resultType; - } - - bool AssertionResult::hasExpression() const { - return !m_info.capturedExpression.empty(); - } - - bool AssertionResult::hasMessage() const { - return !m_resultData.message.empty(); - } - - std::string AssertionResult::getExpression() const { - if( shouldNegate( m_info.resultDisposition ) ) - return "!" + m_info.capturedExpression; - else - return m_info.capturedExpression; - } - std::string AssertionResult::getExpressionInMacro() const { - if( m_info.macroName.empty() ) - return m_info.capturedExpression; - else - return m_info.macroName + "( " + m_info.capturedExpression + " )"; - } - - bool AssertionResult::hasExpandedExpression() const { - return hasExpression() && getExpandedExpression() != getExpression(); - } - - std::string AssertionResult::getExpandedExpression() const { - return m_resultData.reconstructedExpression; - } - - std::string AssertionResult::getMessage() const { - return m_resultData.message; - } - SourceLineInfo AssertionResult::getSourceInfo() const { - return m_info.lineInfo; - } - - std::string AssertionResult::getTestMacroName() const { - return m_info.macroName; - } - -} // end namespace Catch - -// #included from: catch_expressionresult_builder.hpp -#define TWOBLUECUBES_CATCH_EXPRESSIONRESULT_BUILDER_HPP_INCLUDED - -#include - -namespace Catch { - - ExpressionResultBuilder::ExpressionResultBuilder( ResultWas::OfType resultType ) { - m_data.resultType = resultType; - } - ExpressionResultBuilder::ExpressionResultBuilder( ExpressionResultBuilder const& other ) - : m_data( other.m_data ), - m_exprComponents( other.m_exprComponents ) - { - m_stream << other.m_stream.str(); - } - ExpressionResultBuilder& ExpressionResultBuilder::operator=(ExpressionResultBuilder const& other ) { - m_data = other.m_data; - m_exprComponents = other.m_exprComponents; - m_stream.str(""); - m_stream << other.m_stream.str(); - return *this; - } - ExpressionResultBuilder& ExpressionResultBuilder::setResultType( ResultWas::OfType result ) { - m_data.resultType = result; - return *this; - } - ExpressionResultBuilder& ExpressionResultBuilder::setResultType( bool result ) { - m_data.resultType = result ? ResultWas::Ok : ResultWas::ExpressionFailed; - return *this; - } - ExpressionResultBuilder& ExpressionResultBuilder::endExpression( ResultDisposition::Flags resultDisposition ) { - m_exprComponents.shouldNegate = shouldNegate( resultDisposition ); - return *this; - } - ExpressionResultBuilder& ExpressionResultBuilder::setLhs( std::string const& lhs ) { - m_exprComponents.lhs = lhs; - return *this; - } - ExpressionResultBuilder& ExpressionResultBuilder::setRhs( std::string const& rhs ) { - m_exprComponents.rhs = rhs; - return *this; - } - ExpressionResultBuilder& ExpressionResultBuilder::setOp( std::string const& op ) { - m_exprComponents.op = op; - return *this; - } - AssertionResult ExpressionResultBuilder::buildResult( AssertionInfo const& info ) const - { - assert( m_data.resultType != ResultWas::Unknown ); - - AssertionResultData data = m_data; - - // Flip bool results if shouldNegate is set - if( m_exprComponents.shouldNegate && data.resultType == ResultWas::Ok ) - data.resultType = ResultWas::ExpressionFailed; - else if( m_exprComponents.shouldNegate && data.resultType == ResultWas::ExpressionFailed ) - data.resultType = ResultWas::Ok; - - data.message = m_stream.str(); - data.reconstructedExpression = reconstructExpression( info ); - if( m_exprComponents.shouldNegate ) { - if( m_exprComponents.op == "" ) - data.reconstructedExpression = "!" + data.reconstructedExpression; - else - data.reconstructedExpression = "!(" + data.reconstructedExpression + ")"; - } - return AssertionResult( info, data ); - } - std::string ExpressionResultBuilder::reconstructExpression( AssertionInfo const& info ) const { - if( m_exprComponents.op == "" ) - return m_exprComponents.lhs.empty() ? info.capturedExpression : m_exprComponents.op + m_exprComponents.lhs; - else if( m_exprComponents.op == "matches" ) - return m_exprComponents.lhs + " " + m_exprComponents.rhs; - else if( m_exprComponents.op != "!" ) { - if( m_exprComponents.lhs.size() + m_exprComponents.rhs.size() < 40 && - m_exprComponents.lhs.find("\n") == std::string::npos && - m_exprComponents.rhs.find("\n") == std::string::npos ) - return m_exprComponents.lhs + " " + m_exprComponents.op + " " + m_exprComponents.rhs; - else - return m_exprComponents.lhs + "\n" + m_exprComponents.op + "\n" + m_exprComponents.rhs; - } - else - return "{can't expand - use " + info.macroName + "_FALSE( " + info.capturedExpression.substr(1) + " ) instead of " + info.macroName + "( " + info.capturedExpression + " ) for better diagnostics}"; - } - -} // end namespace Catch - -// #included from: catch_test_case_info.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED - -namespace Catch { - - inline bool isSpecialTag( std::string const& tag ) { - return tag == "." || - tag == "hide" || - tag == "!hide" || - tag == "!throws"; - } - inline bool isReservedTag( std::string const& tag ) { - return !isSpecialTag( tag ) && tag.size() > 0 && !isalnum( tag[0] ); - } - inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { - if( isReservedTag( tag ) ) { - { - Colour colourGuard( Colour::Red ); - std::cerr - << "Tag name [" << tag << "] not allowed.\n" - << "Tag names starting with non alpha-numeric characters are reserved\n"; - } - { - Colour colourGuard( Colour::FileName ); - std::cerr << _lineInfo << std::endl; - } - exit(1); - } - } - - TestCase makeTestCase( ITestCase* _testCase, - std::string const& _className, - std::string const& _name, - std::string const& _descOrTags, - SourceLineInfo const& _lineInfo ) - { - bool isHidden( startsWith( _name, "./" ) ); // Legacy support - - // Parse out tags - std::set tags; - std::string desc, tag; - bool inTag = false; - for( std::size_t i = 0; i < _descOrTags.size(); ++i ) { - char c = _descOrTags[i]; - if( !inTag ) { - if( c == '[' ) - inTag = true; - else - desc += c; - } - else { - if( c == ']' ) { - enforceNotReservedTag( tag, _lineInfo ); - - inTag = false; - if( tag == "hide" || tag == "." ) - isHidden = true; - else - tags.insert( tag ); - tag.clear(); - } - else - tag += c; - } - } - if( isHidden ) { - tags.insert( "hide" ); - tags.insert( "." ); - } - - TestCaseInfo info( _name, _className, desc, tags, isHidden, _lineInfo ); - return TestCase( _testCase, info ); - } - - TestCaseInfo::TestCaseInfo( std::string const& _name, - std::string const& _className, - std::string const& _description, - std::set const& _tags, - bool _isHidden, - SourceLineInfo const& _lineInfo ) - : name( _name ), - className( _className ), - description( _description ), - tags( _tags ), - lineInfo( _lineInfo ), - isHidden( _isHidden ), - throws( false ) - { - std::ostringstream oss; - for( std::set::const_iterator it = _tags.begin(), itEnd = _tags.end(); it != itEnd; ++it ) { - oss << "[" << *it << "]"; - if( *it == "!throws" ) - throws = true; - lcaseTags.insert( toLower( *it ) ); - } - tagsAsString = oss.str(); - } - - TestCaseInfo::TestCaseInfo( TestCaseInfo const& other ) - : name( other.name ), - className( other.className ), - description( other.description ), - tags( other.tags ), - lcaseTags( other.lcaseTags ), - tagsAsString( other.tagsAsString ), - lineInfo( other.lineInfo ), - isHidden( other.isHidden ), - throws( other.throws ) - {} - - TestCase::TestCase( ITestCase* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {} - - TestCase::TestCase( TestCase const& other ) - : TestCaseInfo( other ), - test( other.test ) - {} - - TestCase TestCase::withName( std::string const& _newName ) const { - TestCase other( *this ); - other.name = _newName; - return other; - } - - void TestCase::swap( TestCase& other ) { - test.swap( other.test ); - name.swap( other.name ); - className.swap( other.className ); - description.swap( other.description ); - tags.swap( other.tags ); - lcaseTags.swap( other.lcaseTags ); - tagsAsString.swap( other.tagsAsString ); - std::swap( TestCaseInfo::isHidden, static_cast( other ).isHidden ); - std::swap( TestCaseInfo::throws, static_cast( other ).throws ); - std::swap( lineInfo, other.lineInfo ); - } - - void TestCase::invoke() const { - test->invoke(); - } - - bool TestCase::isHidden() const { - return TestCaseInfo::isHidden; - } - bool TestCase::throws() const { - return TestCaseInfo::throws; - } - - bool TestCase::operator == ( TestCase const& other ) const { - return test.get() == other.test.get() && - name == other.name && - className == other.className; - } - - bool TestCase::operator < ( TestCase const& other ) const { - return name < other.name; - } - TestCase& TestCase::operator = ( TestCase const& other ) { - TestCase temp( other ); - swap( temp ); - return *this; - } - - TestCaseInfo const& TestCase::getTestCaseInfo() const - { - return *this; - } - -} // end namespace Catch - -// #included from: catch_version.hpp -#define TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED - -namespace Catch { - - // These numbers are maintained by a script - Version libraryVersion( 1, 0, 47, "master" ); -} - -// #included from: catch_message.hpp -#define TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED - -namespace Catch { - - MessageInfo::MessageInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - type( _type ), - sequence( ++globalCount ) - {} - - // This may need protecting if threading support is added - unsigned int MessageInfo::globalCount = 0; - - //////////////////////////////////////////////////////////////////////////// - - ScopedMessage::ScopedMessage( MessageBuilder const& builder ) - : m_info( builder.m_info ) - { - m_info.message = builder.m_stream.str(); - getResultCapture().pushScopedMessage( m_info ); - } - ScopedMessage::ScopedMessage( ScopedMessage const& other ) - : m_info( other.m_info ) - {} - - ScopedMessage::~ScopedMessage() { - getResultCapture().popScopedMessage( m_info ); - } - -} // end namespace Catch - -// #included from: catch_legacy_reporter_adapter.hpp -#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED - -// #included from: catch_legacy_reporter_adapter.h -#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED - -namespace Catch -{ - // Deprecated - struct IReporter : IShared { - virtual ~IReporter(); - - virtual bool shouldRedirectStdout() const = 0; - - virtual void StartTesting() = 0; - virtual void EndTesting( Totals const& totals ) = 0; - virtual void StartGroup( std::string const& groupName ) = 0; - virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0; - virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0; - virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0; - virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0; - virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0; - virtual void NoAssertionsInSection( std::string const& sectionName ) = 0; - virtual void NoAssertionsInTestCase( std::string const& testName ) = 0; - virtual void Aborted() = 0; - virtual void Result( AssertionResult const& result ) = 0; - }; - - class LegacyReporterAdapter : public SharedImpl - { - public: - LegacyReporterAdapter( Ptr const& legacyReporter ); - virtual ~LegacyReporterAdapter(); - - virtual ReporterPreferences getPreferences() const; - virtual void noMatchingTestCases( std::string const& ); - virtual void testRunStarting( TestRunInfo const& ); - virtual void testGroupStarting( GroupInfo const& groupInfo ); - virtual void testCaseStarting( TestCaseInfo const& testInfo ); - virtual void sectionStarting( SectionInfo const& sectionInfo ); - virtual void assertionStarting( AssertionInfo const& ); - virtual bool assertionEnded( AssertionStats const& assertionStats ); - virtual void sectionEnded( SectionStats const& sectionStats ); - virtual void testCaseEnded( TestCaseStats const& testCaseStats ); - virtual void testGroupEnded( TestGroupStats const& testGroupStats ); - virtual void testRunEnded( TestRunStats const& testRunStats ); - - private: - Ptr m_legacyReporter; - }; -} - -namespace Catch -{ - LegacyReporterAdapter::LegacyReporterAdapter( Ptr const& legacyReporter ) - : m_legacyReporter( legacyReporter ) - {} - LegacyReporterAdapter::~LegacyReporterAdapter() {} - - ReporterPreferences LegacyReporterAdapter::getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout(); - return prefs; - } - - void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {} - void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) { - m_legacyReporter->StartTesting(); - } - void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) { - m_legacyReporter->StartGroup( groupInfo.name ); - } - void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) { - m_legacyReporter->StartTestCase( testInfo ); - } - void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) { - m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description ); - } - void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) { - // Not on legacy interface - } - - bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) { - if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) { - for( std::vector::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); - it != itEnd; - ++it ) { - if( it->type == ResultWas::Info ) { - ExpressionResultBuilder expressionBuilder( it->type ); - expressionBuilder << it->message; - AssertionInfo info( it->macroName, it->lineInfo, "", ResultDisposition::Normal ); - AssertionResult result = expressionBuilder.buildResult( info ); - m_legacyReporter->Result( result ); - } - } - } - m_legacyReporter->Result( assertionStats.assertionResult ); - return true; - } - void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) { - if( sectionStats.missingAssertions ) - m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name ); - m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions ); - } - void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) { - m_legacyReporter->EndTestCase - ( testCaseStats.testInfo, - testCaseStats.totals, - testCaseStats.stdOut, - testCaseStats.stdErr ); - } - void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) { - if( testGroupStats.aborting ) - m_legacyReporter->Aborted(); - m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals ); - } - void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) { - m_legacyReporter->EndTesting( testRunStats.totals ); - } -} - -// #included from: catch_timer.hpp - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++11-long-long" -#endif - -#ifdef CATCH_PLATFORM_WINDOWS -#include -#else -#include -#endif - -namespace Catch { - - namespace { -#ifdef CATCH_PLATFORM_WINDOWS - uint64_t getCurrentTicks() { - static uint64_t hz=0, hzo=0; - if (!hz) { - QueryPerformanceFrequency((LARGE_INTEGER*)&hz); - QueryPerformanceCounter((LARGE_INTEGER*)&hzo); - } - uint64_t t; - QueryPerformanceCounter((LARGE_INTEGER*)&t); - return ((t-hzo)*1000000)/hz; - } -#else - uint64_t getCurrentTicks() { - timeval t; - gettimeofday(&t,NULL); - return (uint64_t)t.tv_sec * 1000000ull + (uint64_t)t.tv_usec; - } -#endif - } - - void Timer::start() { - m_ticks = getCurrentTicks(); - } - unsigned int Timer::getElapsedNanoseconds() const { - return (unsigned int)(getCurrentTicks() - m_ticks); - } - unsigned int Timer::getElapsedMilliseconds() const { - return (unsigned int)((getCurrentTicks() - m_ticks)/1000); - } - double Timer::getElapsedSeconds() const { - return (getCurrentTicks() - m_ticks)/1000000.0; - } - -} // namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -// #included from: catch_common.hpp -#define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED - -namespace Catch { - - bool startsWith( std::string const& s, std::string const& prefix ) { - return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix; - } - bool endsWith( std::string const& s, std::string const& suffix ) { - return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix; - } - bool contains( std::string const& s, std::string const& infix ) { - return s.find( infix ) != std::string::npos; - } - void toLowerInPlace( std::string& s ) { - std::transform( s.begin(), s.end(), s.begin(), ::tolower ); - } - std::string toLower( std::string const& s ) { - std::string lc = s; - toLowerInPlace( lc ); - return lc; - } - std::string trim( std::string const& str ) { - static char const* whitespaceChars = "\n\r\t "; - std::string::size_type start = str.find_first_not_of( whitespaceChars ); - std::string::size_type end = str.find_last_not_of( whitespaceChars ); - - return start != std::string::npos ? str.substr( start, 1+end-start ) : ""; - } - - pluralise::pluralise( std::size_t count, std::string const& label ) - : m_count( count ), - m_label( label ) - {} - - std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { - os << pluraliser.m_count << " " << pluraliser.m_label; - if( pluraliser.m_count != 1 ) - os << "s"; - return os; - } - - SourceLineInfo::SourceLineInfo() : line( 0 ){} - SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line ) - : file( _file ), - line( _line ) - {} - SourceLineInfo::SourceLineInfo( SourceLineInfo const& other ) - : file( other.file ), - line( other.line ) - {} - bool SourceLineInfo::empty() const { - return file.empty(); - } - bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const { - return line == other.line && file == other.file; - } - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { -#ifndef __GNUG__ - os << info.file << "(" << info.line << ")"; -#else - os << info.file << ":" << info.line; -#endif - return os; - } - - void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) { - std::ostringstream oss; - oss << locationInfo << ": Internal Catch error: '" << message << "'"; - if( isTrue( true )) - throw std::logic_error( oss.str() ); - } -} - -// #included from: catch_section.hpp -#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED - -namespace Catch { - - Section::Section( SourceLineInfo const& lineInfo, - std::string const& name, - std::string const& description ) - : m_info( name, description, lineInfo ), - m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) - { - m_timer.start(); - } - - Section::~Section() { - if( m_sectionIncluded ) - getResultCapture().sectionEnded( m_info, m_assertions, m_timer.getElapsedSeconds() ); - } - - // This indicates whether the section should be executed or not - Section::operator bool() { - return m_sectionIncluded; - } - -} // end namespace Catch - -// #included from: catch_debugger.hpp -#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED - -#include - -#ifdef CATCH_PLATFORM_MAC - - #include - #include - #include - #include - #include - - namespace Catch{ - - // The following function is taken directly from the following technical note: - // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html - - // Returns true if the current process is being debugged (either - // running under the debugger or has a debugger attached post facto). - bool isDebuggerActive(){ - - int mib[4]; - struct kinfo_proc info; - size_t size; - - // Initialize the flags so that, if sysctl fails for some bizarre - // reason, we get a predictable result. - - info.kp_proc.p_flag = 0; - - // Initialize mib, which tells sysctl the info we want, in this case - // we're looking for information about a specific process ID. - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - - // Call sysctl. - - size = sizeof(info); - if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0) != 0 ) { - std::cerr << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; - return false; - } - - // We're being debugged if the P_TRACED flag is set. - - return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); - } - } // namespace Catch - -#elif defined(_MSC_VER) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - namespace Catch { - bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } - } -#elif defined(__MINGW32__) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - namespace Catch { - bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } - } -#else - namespace Catch { - inline bool isDebuggerActive() { return false; } - } -#endif // Platform - -#ifdef CATCH_PLATFORM_WINDOWS - extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* ); - namespace Catch { - void writeToDebugConsole( std::string const& text ) { - ::OutputDebugStringA( text.c_str() ); - } - } -#else - namespace Catch { - void writeToDebugConsole( std::string const& text ) { - // !TBD: Need a version for Mac/ XCode and other IDEs - std::cout << text; - } - } -#endif // Platform - -// #included from: catch_tostring.hpp -#define TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED - -namespace Catch { - -std::string toString( std::string const& value ) { - std::string s = value; - if( getCurrentContext().getConfig()->showInvisibles() ) { - for(size_t i = 0; i < s.size(); ++i ) { - std::string subs; - switch( s[i] ) { - case '\n': subs = "\\n"; break; - case '\t': subs = "\\t"; break; - default: break; - } - if( !subs.empty() ) { - s = s.substr( 0, i ) + subs + s.substr( i+1 ); - ++i; - } - } - } - return "\"" + s + "\""; -} -std::string toString( std::wstring const& value ) { - - std::string s; - s.reserve( value.size() ); - for(size_t i = 0; i < value.size(); ++i ) - s += value[i] <= 0xff ? static_cast( value[i] ) : '?'; - return toString( s ); -} - -std::string toString( const char* const value ) { - return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" ); -} - -std::string toString( char* const value ) { - return Catch::toString( static_cast( value ) ); -} - -std::string toString( int value ) { - std::ostringstream oss; - oss << value; - return oss.str(); -} - -std::string toString( unsigned long value ) { - std::ostringstream oss; - if( value > 8192 ) - oss << "0x" << std::hex << value; - else - oss << value; - return oss.str(); -} - -std::string toString( unsigned int value ) { - return toString( static_cast( value ) ); -} - -std::string toString( const double value ) { - std::ostringstream oss; - oss << std::setprecision( 10 ) - << std::fixed - << value; - std::string d = oss.str(); - std::size_t i = d.find_last_not_of( '0' ); - if( i != std::string::npos && i != d.size()-1 ) { - if( d[i] == '.' ) - i++; - d = d.substr( 0, i+1 ); - } - return d; -} - -std::string toString( bool value ) { - return value ? "true" : "false"; -} - -std::string toString( char value ) { - return value < ' ' - ? toString( static_cast( value ) ) - : Detail::makeString( value ); -} - -std::string toString( signed char value ) { - return toString( static_cast( value ) ); -} - -std::string toString( unsigned char value ) { - return toString( static_cast( value ) ); -} - -#ifdef CATCH_CONFIG_CPP11_NULLPTR -std::string toString( std::nullptr_t ) { - return "nullptr"; -} -#endif - -#ifdef __OBJC__ - std::string toString( NSString const * const& nsstring ) { - if( !nsstring ) - return "nil"; - return std::string( "@\"" ) + [nsstring UTF8String] + "\""; - } - std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) { - if( !nsstring ) - return "nil"; - return std::string( "@\"" ) + [nsstring UTF8String] + "\""; - } - std::string toString( NSObject* const& nsObject ) { - return toString( [nsObject description] ); - } -#endif - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_xml.hpp -#define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED - -// #included from: catch_reporter_bases.hpp -#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED - -namespace Catch { - - struct StreamingReporterBase : SharedImpl { - - StreamingReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - {} - - virtual ~StreamingReporterBase(); - - virtual void noMatchingTestCases( std::string const& ) {} - - virtual void testRunStarting( TestRunInfo const& _testRunInfo ) { - currentTestRunInfo = _testRunInfo; - } - virtual void testGroupStarting( GroupInfo const& _groupInfo ) { - currentGroupInfo = _groupInfo; - } - - virtual void testCaseStarting( TestCaseInfo const& _testInfo ) { - currentTestCaseInfo = _testInfo; - } - virtual void sectionStarting( SectionInfo const& _sectionInfo ) { - m_sectionStack.push_back( _sectionInfo ); - } - - virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) { - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) { - currentTestCaseInfo.reset(); - assert( m_sectionStack.empty() ); - } - virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) { - currentGroupInfo.reset(); - } - virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) { - currentTestCaseInfo.reset(); - currentGroupInfo.reset(); - currentTestRunInfo.reset(); - } - - Ptr m_config; - std::ostream& stream; - - LazyStat currentTestRunInfo; - LazyStat currentGroupInfo; - LazyStat currentTestCaseInfo; - - std::vector m_sectionStack; - }; - - struct CumulativeReporterBase : SharedImpl { - template - struct Node : SharedImpl<> { - explicit Node( T const& _value ) : value( _value ) {} - virtual ~Node() {} - - typedef std::vector > ChildNodes; - T value; - ChildNodes children; - }; - struct SectionNode : SharedImpl<> { - explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {} - virtual ~SectionNode(); - - bool operator == ( SectionNode const& other ) const { - return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; - } - bool operator == ( Ptr const& other ) const { - return operator==( *other ); - } - - SectionStats stats; - typedef std::vector > ChildSections; - typedef std::vector Assertions; - ChildSections childSections; - Assertions assertions; - std::string stdOut; - std::string stdErr; - }; - - struct BySectionInfo { - BySectionInfo( SectionInfo const& other ) : m_other( other ) {} - BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} - bool operator() ( Ptr const& node ) const { - return node->stats.sectionInfo.lineInfo == m_other.lineInfo; - } - private: - void operator=( BySectionInfo const& ); - SectionInfo const& m_other; - }; - - typedef Node TestCaseNode; - typedef Node TestGroupNode; - typedef Node TestRunNode; - - CumulativeReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - {} - ~CumulativeReporterBase(); - - virtual void testRunStarting( TestRunInfo const& ) {} - virtual void testGroupStarting( GroupInfo const& ) {} - - virtual void testCaseStarting( TestCaseInfo const& ) {} - - virtual void sectionStarting( SectionInfo const& sectionInfo ) { - SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); - Ptr node; - if( m_sectionStack.empty() ) { - if( !m_rootSection ) - m_rootSection = new SectionNode( incompleteStats ); - node = m_rootSection; - } - else { - SectionNode& parentNode = *m_sectionStack.back(); - SectionNode::ChildSections::const_iterator it = - std::find_if( parentNode.childSections.begin(), - parentNode.childSections.end(), - BySectionInfo( sectionInfo ) ); - if( it == parentNode.childSections.end() ) { - node = new SectionNode( incompleteStats ); - parentNode.childSections.push_back( node ); - } - else - node = *it; - } - m_sectionStack.push_back( node ); - m_deepestSection = node; - } - - virtual void assertionStarting( AssertionInfo const& ) {} - - virtual bool assertionEnded( AssertionStats const& assertionStats ) { - assert( !m_sectionStack.empty() ); - SectionNode& sectionNode = *m_sectionStack.back(); - sectionNode.assertions.push_back( assertionStats ); - return true; - } - virtual void sectionEnded( SectionStats const& sectionStats ) { - assert( !m_sectionStack.empty() ); - SectionNode& node = *m_sectionStack.back(); - node.stats = sectionStats; - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) { - Ptr node = new TestCaseNode( testCaseStats ); - assert( m_sectionStack.size() == 0 ); - node->children.push_back( m_rootSection ); - m_testCases.push_back( node ); - m_rootSection.reset(); - - assert( m_deepestSection ); - m_deepestSection->stdOut = testCaseStats.stdOut; - m_deepestSection->stdErr = testCaseStats.stdErr; - } - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) { - Ptr node = new TestGroupNode( testGroupStats ); - node->children.swap( m_testCases ); - m_testGroups.push_back( node ); - } - virtual void testRunEnded( TestRunStats const& testRunStats ) { - Ptr node = new TestRunNode( testRunStats ); - node->children.swap( m_testGroups ); - m_testRuns.push_back( node ); - testRunEndedCumulative(); - } - virtual void testRunEndedCumulative() = 0; - - Ptr m_config; - std::ostream& stream; - std::vector m_assertions; - std::vector > > m_sections; - std::vector > m_testCases; - std::vector > m_testGroups; - - std::vector > m_testRuns; - - Ptr m_rootSection; - Ptr m_deepestSection; - std::vector > m_sectionStack; - - }; - -} // end namespace Catch - -// #included from: ../internal/catch_reporter_registrars.hpp -#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED - -namespace Catch { - - template - class LegacyReporterRegistrar { - - class ReporterFactory : public IReporterFactory { - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new LegacyReporterAdapter( new T( config ) ); - } - - virtual std::string getDescription() const { - return T::getDescription(); - } - }; - - public: - - LegacyReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); - } - }; - - template - class ReporterRegistrar { - - class ReporterFactory : public IReporterFactory { - - // *** Please Note ***: - // - If you end up here looking at a compiler error because it's trying to register - // your custom reporter class be aware that the native reporter interface has changed - // to IStreamingReporter. The "legacy" interface, IReporter, is still supported via - // an adapter. Just use REGISTER_LEGACY_REPORTER to take advantage of the adapter. - // However please consider updating to the new interface as the old one is now - // deprecated and will probably be removed quite soon! - // Please contact me via github if you have any questions at all about this. - // In fact, ideally, please contact me anyway to let me know you've hit this - as I have - // no idea who is actually using custom reporters at all (possibly no-one!). - // The new interface is designed to minimise exposure to interface changes in the future. - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new T( config ); - } - - virtual std::string getDescription() const { - return T::getDescription(); - } - }; - - public: - - ReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); - } - }; -} - -#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \ - namespace{ Catch::LegacyReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } -#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \ - namespace{ Catch::ReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } - -// #included from: ../internal/catch_xmlwriter.hpp -#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - class XmlWriter { - public: - - class ScopedElement { - public: - ScopedElement( XmlWriter* writer ) - : m_writer( writer ) - {} - - ScopedElement( ScopedElement const& other ) - : m_writer( other.m_writer ){ - other.m_writer = NULL; - } - - ~ScopedElement() { - if( m_writer ) - m_writer->endElement(); - } - - ScopedElement& writeText( std::string const& text, bool indent = true ) { - m_writer->writeText( text, indent ); - return *this; - } - - template - ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { - m_writer->writeAttribute( name, attribute ); - return *this; - } - - private: - mutable XmlWriter* m_writer; - }; - - XmlWriter() - : m_tagIsOpen( false ), - m_needsNewline( false ), - m_os( &std::cout ) - {} - - XmlWriter( std::ostream& os ) - : m_tagIsOpen( false ), - m_needsNewline( false ), - m_os( &os ) - {} - - ~XmlWriter() { - while( !m_tags.empty() ) - endElement(); - } - -//# ifndef CATCH_CPP11_OR_GREATER -// XmlWriter& operator = ( XmlWriter const& other ) { -// XmlWriter temp( other ); -// swap( temp ); -// return *this; -// } -//# else -// XmlWriter( XmlWriter const& ) = default; -// XmlWriter( XmlWriter && ) = default; -// XmlWriter& operator = ( XmlWriter const& ) = default; -// XmlWriter& operator = ( XmlWriter && ) = default; -//# endif -// -// void swap( XmlWriter& other ) { -// std::swap( m_tagIsOpen, other.m_tagIsOpen ); -// std::swap( m_needsNewline, other.m_needsNewline ); -// std::swap( m_tags, other.m_tags ); -// std::swap( m_indent, other.m_indent ); -// std::swap( m_os, other.m_os ); -// } - - XmlWriter& startElement( std::string const& name ) { - ensureTagClosed(); - newlineIfNecessary(); - stream() << m_indent << "<" << name; - m_tags.push_back( name ); - m_indent += " "; - m_tagIsOpen = true; - return *this; - } - - ScopedElement scopedElement( std::string const& name ) { - ScopedElement scoped( this ); - startElement( name ); - return scoped; - } - - XmlWriter& endElement() { - newlineIfNecessary(); - m_indent = m_indent.substr( 0, m_indent.size()-2 ); - if( m_tagIsOpen ) { - stream() << "/>\n"; - m_tagIsOpen = false; - } - else { - stream() << m_indent << "\n"; - } - m_tags.pop_back(); - return *this; - } - - XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) { - if( !name.empty() && !attribute.empty() ) { - stream() << " " << name << "=\""; - writeEncodedText( attribute ); - stream() << "\""; - } - return *this; - } - - XmlWriter& writeAttribute( std::string const& name, bool attribute ) { - stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\""; - return *this; - } - - template - XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { - if( !name.empty() ) - stream() << " " << name << "=\"" << attribute << "\""; - return *this; - } - - XmlWriter& writeText( std::string const& text, bool indent = true ) { - if( !text.empty() ){ - bool tagWasOpen = m_tagIsOpen; - ensureTagClosed(); - if( tagWasOpen && indent ) - stream() << m_indent; - writeEncodedText( text ); - m_needsNewline = true; - } - return *this; - } - - XmlWriter& writeComment( std::string const& text ) { - ensureTagClosed(); - stream() << m_indent << ""; - m_needsNewline = true; - return *this; - } - - XmlWriter& writeBlankLine() { - ensureTagClosed(); - stream() << "\n"; - return *this; - } - - void setStream( std::ostream& os ) { - m_os = &os; - } - - private: - XmlWriter( XmlWriter const& ); - void operator=( XmlWriter const& ); - - std::ostream& stream() { - return *m_os; - } - - void ensureTagClosed() { - if( m_tagIsOpen ) { - stream() << ">\n"; - m_tagIsOpen = false; - } - } - - void newlineIfNecessary() { - if( m_needsNewline ) { - stream() << "\n"; - m_needsNewline = false; - } - } - - void writeEncodedText( std::string const& text ) { - static const char* charsToEncode = "<&\""; - std::string mtext = text; - std::string::size_type pos = mtext.find_first_of( charsToEncode ); - while( pos != std::string::npos ) { - stream() << mtext.substr( 0, pos ); - - switch( mtext[pos] ) { - case '<': - stream() << "<"; - break; - case '&': - stream() << "&"; - break; - case '\"': - stream() << """; - break; - } - mtext = mtext.substr( pos+1 ); - pos = mtext.find_first_of( charsToEncode ); - } - stream() << mtext; - } - - bool m_tagIsOpen; - bool m_needsNewline; - std::vector m_tags; - std::string m_indent; - std::ostream* m_os; - }; - -} -namespace Catch { - class XmlReporter : public SharedImpl { - public: - XmlReporter( ReporterConfig const& config ) : m_config( config ), m_sectionDepth( 0 ) {} - - static std::string getDescription() { - return "Reports test results as an XML document"; - } - virtual ~XmlReporter(); - - private: // IReporter - - virtual bool shouldRedirectStdout() const { - return true; - } - - virtual void StartTesting() { - m_xml.setStream( m_config.stream() ); - m_xml.startElement( "Catch" ); - if( !m_config.fullConfig()->name().empty() ) - m_xml.writeAttribute( "name", m_config.fullConfig()->name() ); - } - - virtual void EndTesting( const Totals& totals ) { - m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes", totals.assertions.passed ) - .writeAttribute( "failures", totals.assertions.failed ); - m_xml.endElement(); - } - - virtual void StartGroup( const std::string& groupName ) { - m_xml.startElement( "Group" ) - .writeAttribute( "name", groupName ); - } - - virtual void EndGroup( const std::string&, const Totals& totals ) { - m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes", totals.assertions.passed ) - .writeAttribute( "failures", totals.assertions.failed ); - m_xml.endElement(); - } - - virtual void StartSection( const std::string& sectionName, const std::string& description ) { - if( m_sectionDepth++ > 0 ) { - m_xml.startElement( "Section" ) - .writeAttribute( "name", trim( sectionName ) ) - .writeAttribute( "description", description ); - } - } - virtual void NoAssertionsInSection( const std::string& ) {} - virtual void NoAssertionsInTestCase( const std::string& ) {} - - virtual void EndSection( const std::string& /*sectionName*/, const Counts& assertions ) { - if( --m_sectionDepth > 0 ) { - m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes", assertions.passed ) - .writeAttribute( "failures", assertions.failed ); - m_xml.endElement(); - } - } - - virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) { - m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) ); - m_currentTestSuccess = true; - } - - virtual void Result( const Catch::AssertionResult& assertionResult ) { - if( !m_config.fullConfig()->includeSuccessfulResults() && assertionResult.getResultType() == ResultWas::Ok ) - return; - - if( assertionResult.hasExpression() ) { - m_xml.startElement( "Expression" ) - .writeAttribute( "success", assertionResult.succeeded() ) - .writeAttribute( "filename", assertionResult.getSourceInfo().file ) - .writeAttribute( "line", assertionResult.getSourceInfo().line ); - - m_xml.scopedElement( "Original" ) - .writeText( assertionResult.getExpression() ); - m_xml.scopedElement( "Expanded" ) - .writeText( assertionResult.getExpandedExpression() ); - m_currentTestSuccess &= assertionResult.succeeded(); - } - - switch( assertionResult.getResultType() ) { - case ResultWas::ThrewException: - m_xml.scopedElement( "Exception" ) - .writeAttribute( "filename", assertionResult.getSourceInfo().file ) - .writeAttribute( "line", assertionResult.getSourceInfo().line ) - .writeText( assertionResult.getMessage() ); - m_currentTestSuccess = false; - break; - case ResultWas::Info: - m_xml.scopedElement( "Info" ) - .writeText( assertionResult.getMessage() ); - break; - case ResultWas::Warning: - m_xml.scopedElement( "Warning" ) - .writeText( assertionResult.getMessage() ); - break; - case ResultWas::ExplicitFailure: - m_xml.scopedElement( "Failure" ) - .writeText( assertionResult.getMessage() ); - m_currentTestSuccess = false; - break; - case ResultWas::Unknown: - case ResultWas::Ok: - case ResultWas::FailureBit: - case ResultWas::ExpressionFailed: - case ResultWas::Exception: - case ResultWas::DidntThrowException: - break; - } - if( assertionResult.hasExpression() ) - m_xml.endElement(); - } - - virtual void Aborted() { - // !TBD - } - - virtual void EndTestCase( const Catch::TestCaseInfo&, const Totals&, const std::string&, const std::string& ) { - m_xml.scopedElement( "OverallResult" ).writeAttribute( "success", m_currentTestSuccess ); - m_xml.endElement(); - } - - private: - ReporterConfig m_config; - bool m_currentTestSuccess; - XmlWriter m_xml; - int m_sectionDepth; - }; - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_junit.hpp -#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED - -#include - -namespace Catch { - - class JunitReporter : public CumulativeReporterBase { - public: - JunitReporter( ReporterConfig const& _config ) - : CumulativeReporterBase( _config ), - xml( _config.stream() ) - {} - - ~JunitReporter(); - - static std::string getDescription() { - return "Reports test results in an XML format that looks like Ant's junitreport target"; - } - - virtual void noMatchingTestCases( std::string const& /*spec*/ ) {} - - virtual ReporterPreferences getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = true; - return prefs; - } - - virtual void testRunStarting( TestRunInfo const& runInfo ) { - CumulativeReporterBase::testRunStarting( runInfo ); - xml.startElement( "testsuites" ); - } - - virtual void testGroupStarting( GroupInfo const& groupInfo ) { - suiteTimer.start(); - stdOutForSuite.str(""); - stdErrForSuite.str(""); - unexpectedExceptions = 0; - CumulativeReporterBase::testGroupStarting( groupInfo ); - } - - virtual bool assertionEnded( AssertionStats const& assertionStats ) { - if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException ) - unexpectedExceptions++; - return CumulativeReporterBase::assertionEnded( assertionStats ); - } - - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) { - stdOutForSuite << testCaseStats.stdOut; - stdErrForSuite << testCaseStats.stdErr; - CumulativeReporterBase::testCaseEnded( testCaseStats ); - } - - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) { - double suiteTime = suiteTimer.getElapsedSeconds(); - CumulativeReporterBase::testGroupEnded( testGroupStats ); - writeGroup( *m_testGroups.back(), suiteTime ); - } - - virtual void testRunEndedCumulative() { - xml.endElement(); - } - - void writeGroup( TestGroupNode const& groupNode, double suiteTime ) { - XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" ); - TestGroupStats const& stats = groupNode.value; - xml.writeAttribute( "name", stats.groupInfo.name ); - xml.writeAttribute( "errors", unexpectedExceptions ); - xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions ); - xml.writeAttribute( "tests", stats.totals.assertions.total() ); - xml.writeAttribute( "hostname", "tbd" ); // !TBD - if( m_config->showDurations() == ShowDurations::Never ) - xml.writeAttribute( "time", "" ); - else - xml.writeAttribute( "time", suiteTime ); - xml.writeAttribute( "timestamp", "tbd" ); // !TBD - - // Write test cases - for( TestGroupNode::ChildNodes::const_iterator - it = groupNode.children.begin(), itEnd = groupNode.children.end(); - it != itEnd; - ++it ) - writeTestCase( **it ); - - xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite.str() ), false ); - xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite.str() ), false ); - } - - void writeTestCase( TestCaseNode const& testCaseNode ) { - TestCaseStats const& stats = testCaseNode.value; - - // All test cases have exactly one section - which represents the - // test case itself. That section may have 0-n nested sections - assert( testCaseNode.children.size() == 1 ); - SectionNode const& rootSection = *testCaseNode.children.front(); - - std::string className = stats.testInfo.className; - - if( className.empty() ) { - if( rootSection.childSections.empty() ) - className = "global"; - } - writeSection( className, "", rootSection ); - } - - void writeSection( std::string const& className, - std::string const& rootName, - SectionNode const& sectionNode ) { - std::string name = trim( sectionNode.stats.sectionInfo.name ); - if( !rootName.empty() ) - name = rootName + "/" + name; - - if( !sectionNode.assertions.empty() || - !sectionNode.stdOut.empty() || - !sectionNode.stdErr.empty() ) { - XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); - if( className.empty() ) { - xml.writeAttribute( "classname", name ); - xml.writeAttribute( "name", "root" ); - } - else { - xml.writeAttribute( "classname", className ); - xml.writeAttribute( "name", name ); - } - xml.writeAttribute( "time", toString( sectionNode.stats.durationInSeconds ) ); - - writeAssertions( sectionNode ); - - if( !sectionNode.stdOut.empty() ) - xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false ); - if( !sectionNode.stdErr.empty() ) - xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false ); - } - for( SectionNode::ChildSections::const_iterator - it = sectionNode.childSections.begin(), - itEnd = sectionNode.childSections.end(); - it != itEnd; - ++it ) - if( className.empty() ) - writeSection( name, "", **it ); - else - writeSection( className, name, **it ); - } - - void writeAssertions( SectionNode const& sectionNode ) { - for( SectionNode::Assertions::const_iterator - it = sectionNode.assertions.begin(), itEnd = sectionNode.assertions.end(); - it != itEnd; - ++it ) - writeAssertion( *it ); - } - void writeAssertion( AssertionStats const& stats ) { - AssertionResult const& result = stats.assertionResult; - if( !result.isOk() ) { - std::string elementName; - switch( result.getResultType() ) { - case ResultWas::ThrewException: - elementName = "error"; - break; - case ResultWas::ExplicitFailure: - elementName = "failure"; - break; - case ResultWas::ExpressionFailed: - elementName = "failure"; - break; - case ResultWas::DidntThrowException: - elementName = "failure"; - break; - - // We should never see these here: - case ResultWas::Info: - case ResultWas::Warning: - case ResultWas::Ok: - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - elementName = "internalError"; - break; - } - - XmlWriter::ScopedElement e = xml.scopedElement( elementName ); - - xml.writeAttribute( "message", result.getExpandedExpression() ); - xml.writeAttribute( "type", result.getTestMacroName() ); - - std::ostringstream oss; - if( !result.getMessage().empty() ) - oss << result.getMessage() << "\n"; - for( std::vector::const_iterator - it = stats.infoMessages.begin(), - itEnd = stats.infoMessages.end(); - it != itEnd; - ++it ) - if( it->type == ResultWas::Info ) - oss << it->message << "\n"; - - oss << "at " << result.getSourceInfo(); - xml.writeText( oss.str(), false ); - } - } - - XmlWriter xml; - Timer suiteTimer; - std::ostringstream stdOutForSuite; - std::ostringstream stdErrForSuite; - unsigned int unexpectedExceptions; - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter ) - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_console.hpp -#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED - -#include - -namespace Catch { - - struct ConsoleReporter : StreamingReporterBase { - ConsoleReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ), - m_headerPrinted( false ), - m_atLeastOneTestCasePrinted( false ) - {} - - virtual ~ConsoleReporter(); - static std::string getDescription() { - return "Reports test results as plain lines of text"; - } - virtual ReporterPreferences getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = false; - return prefs; - } - - virtual void noMatchingTestCases( std::string const& spec ) { - stream << "No test cases matched '" << spec << "'" << std::endl; - } - - virtual void assertionStarting( AssertionInfo const& ) { - } - - virtual bool assertionEnded( AssertionStats const& _assertionStats ) { - AssertionResult const& result = _assertionStats.assertionResult; - - bool printInfoMessages = true; - - // Drop out if result was successful and we're not printing those - if( !m_config->includeSuccessfulResults() && result.isOk() ) { - if( result.getResultType() != ResultWas::Warning ) - return false; - printInfoMessages = false; - } - - lazyPrint(); - - AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); - printer.print(); - stream << std::endl; - return true; - } - - virtual void sectionStarting( SectionInfo const& _sectionInfo ) { - m_headerPrinted = false; - StreamingReporterBase::sectionStarting( _sectionInfo ); - } - virtual void sectionEnded( SectionStats const& _sectionStats ) { - if( _sectionStats.missingAssertions ) { - lazyPrint(); - Colour colour( Colour::ResultError ); - if( m_sectionStack.size() > 1 ) - stream << "\nNo assertions in section"; - else - stream << "\nNo assertions in test case"; - stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; - } - if( m_headerPrinted ) { - if( m_config->showDurations() == ShowDurations::Always ) - stream << "Completed in " << _sectionStats.durationInSeconds << "s" << std::endl; - m_headerPrinted = false; - } - else { - if( m_config->showDurations() == ShowDurations::Always ) - stream << _sectionStats.sectionInfo.name << " completed in " << _sectionStats.durationInSeconds << "s" << std::endl; - } - StreamingReporterBase::sectionEnded( _sectionStats ); - } - - virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) { - StreamingReporterBase::testCaseEnded( _testCaseStats ); - m_headerPrinted = false; - } - virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) { - if( currentGroupInfo.used ) { - printSummaryDivider(); - stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n"; - printTotals( _testGroupStats.totals ); - stream << "\n" << std::endl; - } - StreamingReporterBase::testGroupEnded( _testGroupStats ); - } - virtual void testRunEnded( TestRunStats const& _testRunStats ) { - if( m_atLeastOneTestCasePrinted ) - printTotalsDivider(); - printTotals( _testRunStats.totals ); - stream << "\n" << std::endl; - StreamingReporterBase::testRunEnded( _testRunStats ); - } - - private: - - class AssertionPrinter { - void operator= ( AssertionPrinter const& ); - public: - AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) - : stream( _stream ), - stats( _stats ), - result( _stats.assertionResult ), - colour( Colour::None ), - message( result.getMessage() ), - messages( _stats.infoMessages ), - printInfoMessages( _printInfoMessages ) - { - switch( result.getResultType() ) { - case ResultWas::Ok: - colour = Colour::Success; - passOrFail = "PASSED"; - //if( result.hasMessage() ) - if( _stats.infoMessages.size() == 1 ) - messageLabel = "with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "with messages"; - break; - case ResultWas::ExpressionFailed: - if( result.isOk() ) { - colour = Colour::Success; - passOrFail = "FAILED - but was ok"; - } - else { - colour = Colour::Error; - passOrFail = "FAILED"; - } - if( _stats.infoMessages.size() == 1 ) - messageLabel = "with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "with messages"; - break; - case ResultWas::ThrewException: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "due to unexpected exception with message"; - break; - case ResultWas::DidntThrowException: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "because no exception was thrown where one was expected"; - break; - case ResultWas::Info: - messageLabel = "info"; - break; - case ResultWas::Warning: - messageLabel = "warning"; - break; - case ResultWas::ExplicitFailure: - passOrFail = "FAILED"; - colour = Colour::Error; - if( _stats.infoMessages.size() == 1 ) - messageLabel = "explicitly with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "explicitly with messages"; - break; - // These cases are here to prevent compiler warnings - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - passOrFail = "** internal error **"; - colour = Colour::Error; - break; - } - } - - void print() const { - printSourceInfo(); - if( stats.totals.assertions.total() > 0 ) { - if( result.isOk() ) - stream << "\n"; - printResultType(); - printOriginalExpression(); - printReconstructedExpression(); - } - else { - stream << "\n"; - } - printMessage(); - } - - private: - void printResultType() const { - if( !passOrFail.empty() ) { - Colour colourGuard( colour ); - stream << passOrFail << ":\n"; - } - } - void printOriginalExpression() const { - if( result.hasExpression() ) { - Colour colourGuard( Colour::OriginalExpression ); - stream << " "; - stream << result.getExpressionInMacro(); - stream << "\n"; - } - } - void printReconstructedExpression() const { - if( result.hasExpandedExpression() ) { - stream << "with expansion:\n"; - Colour colourGuard( Colour::ReconstructedExpression ); - stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << "\n"; - } - } - void printMessage() const { - if( !messageLabel.empty() ) - stream << messageLabel << ":" << "\n"; - for( std::vector::const_iterator it = messages.begin(), itEnd = messages.end(); - it != itEnd; - ++it ) { - // If this assertion is a warning ignore any INFO messages - if( printInfoMessages || it->type != ResultWas::Info ) - stream << Text( it->message, TextAttributes().setIndent(2) ) << "\n"; - } - } - void printSourceInfo() const { - Colour colourGuard( Colour::FileName ); - stream << result.getSourceInfo() << ": "; - } - - std::ostream& stream; - AssertionStats const& stats; - AssertionResult const& result; - Colour::Code colour; - std::string passOrFail; - std::string messageLabel; - std::string message; - std::vector messages; - bool printInfoMessages; - }; - - void lazyPrint() { - - if( !currentTestRunInfo.used ) - lazyPrintRunInfo(); - if( !currentGroupInfo.used ) - lazyPrintGroupInfo(); - - if( !m_headerPrinted ) { - printTestCaseAndSectionHeader(); - m_headerPrinted = true; - } - m_atLeastOneTestCasePrinted = true; - } - void lazyPrintRunInfo() { - stream << "\n" << getLineOfChars<'~'>() << "\n"; - Colour colour( Colour::SecondaryText ); - stream << currentTestRunInfo->name - << " is a Catch v" << libraryVersion.majorVersion << "." - << libraryVersion.minorVersion << " b" - << libraryVersion.buildNumber; - if( libraryVersion.branchName != std::string( "master" ) ) - stream << " (" << libraryVersion.branchName << ")"; - stream << " host application.\n" - << "Run with -? for options\n\n"; - - currentTestRunInfo.used = true; - } - void lazyPrintGroupInfo() { - if( !currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1 ) { - printClosedHeader( "Group: " + currentGroupInfo->name ); - currentGroupInfo.used = true; - } - } - void printTestCaseAndSectionHeader() { - assert( !m_sectionStack.empty() ); - printOpenHeader( currentTestCaseInfo->name ); - - if( m_sectionStack.size() > 1 ) { - Colour colourGuard( Colour::Headers ); - - std::vector::const_iterator - it = m_sectionStack.begin()+1, // Skip first section (test case) - itEnd = m_sectionStack.end(); - for( ; it != itEnd; ++it ) - printHeaderString( it->name, 2 ); - } - - SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; - - if( !lineInfo.empty() ){ - stream << getLineOfChars<'-'>() << "\n"; - Colour colourGuard( Colour::FileName ); - stream << lineInfo << "\n"; - } - stream << getLineOfChars<'.'>() << "\n" << std::endl; - } - - void printClosedHeader( std::string const& _name ) { - printOpenHeader( _name ); - stream << getLineOfChars<'.'>() << "\n"; - } - void printOpenHeader( std::string const& _name ) { - stream << getLineOfChars<'-'>() << "\n"; - { - Colour colourGuard( Colour::Headers ); - printHeaderString( _name ); - } - } - - // if string has a : in first line will set indent to follow it on - // subsequent lines - void printHeaderString( std::string const& _string, std::size_t indent = 0 ) { - std::size_t i = _string.find( ": " ); - if( i != std::string::npos ) - i+=2; - else - i = 0; - stream << Text( _string, TextAttributes() - .setIndent( indent+i) - .setInitialIndent( indent ) ) << "\n"; - } - - void printTotals( const Totals& totals ) { - if( totals.testCases.total() == 0 ) { - stream << "No tests ran"; - } - else if( totals.assertions.total() == 0 ) { - Colour colour( Colour::Yellow ); - printCounts( "test case", totals.testCases ); - stream << " (no assertions)"; - } - else if( totals.assertions.failed ) { - Colour colour( Colour::ResultError ); - printCounts( "test case", totals.testCases ); - if( totals.testCases.failed > 0 ) { - stream << " ("; - printCounts( "assertion", totals.assertions ); - stream << ")"; - } - } - else { - Colour colour( Colour::ResultSuccess ); - stream << "All tests passed (" - << pluralise( totals.assertions.passed, "assertion" ) << " in " - << pluralise( totals.testCases.passed, "test case" ) << ")"; - } - } - void printCounts( std::string const& label, Counts const& counts ) { - if( counts.total() == 1 ) { - stream << "1 " << label << " - "; - if( counts.failed ) - stream << "failed"; - else - stream << "passed"; - } - else { - stream << counts.total() << " " << label << "s "; - if( counts.passed ) { - if( counts.failed ) - stream << "- " << counts.failed << " failed"; - else if( counts.passed == 2 ) - stream << "- both passed"; - else - stream << "- all passed"; - } - else { - if( counts.failed == 2 ) - stream << "- both failed"; - else - stream << "- all failed"; - } - } - } - - void printTotalsDivider() { - stream << getLineOfChars<'='>() << "\n"; - } - void printSummaryDivider() { - stream << getLineOfChars<'-'>() << "\n"; - } - template - static char const* getLineOfChars() { - static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; - if( !*line ) { - memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 ); - line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0; - } - return line; - } - - private: - bool m_headerPrinted; - bool m_atLeastOneTestCasePrinted; - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter ) - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_compact.hpp -#define TWOBLUECUBES_CATCH_REPORTER_COMPACT_HPP_INCLUDED - -namespace Catch { - - struct CompactReporter : StreamingReporterBase { - - CompactReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ) - {} - - virtual ~CompactReporter(); - - static std::string getDescription() { - return "Reports test results on a single line, suitable for IDEs"; - } - - virtual ReporterPreferences getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = false; - return prefs; - } - - virtual void noMatchingTestCases( std::string const& spec ) { - stream << "No test cases matched '" << spec << "'" << std::endl; - } - - virtual void assertionStarting( AssertionInfo const& ) { - } - - virtual bool assertionEnded( AssertionStats const& _assertionStats ) { - AssertionResult const& result = _assertionStats.assertionResult; - - bool printInfoMessages = true; - - // Drop out if result was successful and we're not printing those - if( !m_config->includeSuccessfulResults() && result.isOk() ) { - if( result.getResultType() != ResultWas::Warning ) - return false; - printInfoMessages = false; - } - - AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); - printer.print(); - - stream << std::endl; - return true; - } - - virtual void testRunEnded( TestRunStats const& _testRunStats ) { - printTotals( _testRunStats.totals ); - stream << "\n" << std::endl; - StreamingReporterBase::testRunEnded( _testRunStats ); - } - - private: - class AssertionPrinter { - void operator= ( AssertionPrinter const& ); - public: - AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) - : stream( _stream ) - , stats( _stats ) - , result( _stats.assertionResult ) - , messages( _stats.infoMessages ) - , itMessage( _stats.infoMessages.begin() ) - , printInfoMessages( _printInfoMessages ) - {} - - void print() { - printSourceInfo(); - - itMessage = messages.begin(); - - switch( result.getResultType() ) { - case ResultWas::Ok: - printResultType( Colour::ResultSuccess, passedString() ); - printOriginalExpression(); - printReconstructedExpression(); - if ( ! result.hasExpression() ) - printRemainingMessages( Colour::None ); - else - printRemainingMessages(); - break; - case ResultWas::ExpressionFailed: - if( result.isOk() ) - printResultType( Colour::ResultSuccess, failedString() + std::string( " - but was ok" ) ); - else - printResultType( Colour::Error, failedString() ); - printOriginalExpression(); - printReconstructedExpression(); - printRemainingMessages(); - break; - case ResultWas::ThrewException: - printResultType( Colour::Error, failedString() ); - printIssue( "unexpected exception with message:" ); - printMessage(); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::DidntThrowException: - printResultType( Colour::Error, failedString() ); - printIssue( "expected exception, got none" ); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::Info: - printResultType( Colour::None, "info" ); - printMessage(); - printRemainingMessages(); - break; - case ResultWas::Warning: - printResultType( Colour::None, "warning" ); - printMessage(); - printRemainingMessages(); - break; - case ResultWas::ExplicitFailure: - printResultType( Colour::Error, failedString() ); - printIssue( "explicitly" ); - printRemainingMessages( Colour::None ); - break; - // These cases are here to prevent compiler warnings - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - printResultType( Colour::Error, "** internal error **" ); - break; - } - } - - private: - // Colour::LightGrey - - static Colour::Code dimColour() { return Colour::FileName; } - -#ifdef CATCH_PLATFORM_MAC - static const char* failedString() { return "FAILED"; } - static const char* passedString() { return "PASSED"; } -#else - static const char* failedString() { return "failed"; } - static const char* passedString() { return "passed"; } -#endif - - void printSourceInfo() const { - Colour colourGuard( Colour::FileName ); - stream << result.getSourceInfo() << ":"; - } - - void printResultType( Colour::Code colour, std::string passOrFail ) const { - if( !passOrFail.empty() ) { - { - Colour colourGuard( colour ); - stream << " " << passOrFail; - } - stream << ":"; - } - } - - void printIssue( std::string issue ) const { - stream << " " << issue; - } - - void printExpressionWas() { - if( result.hasExpression() ) { - stream << ";"; - { - Colour colour( dimColour() ); - stream << " expression was:"; - } - printOriginalExpression(); - } - } - - void printOriginalExpression() const { - if( result.hasExpression() ) { - stream << " " << result.getExpression(); - } - } - - void printReconstructedExpression() const { - if( result.hasExpandedExpression() ) { - { - Colour colour( dimColour() ); - stream << " for: "; - } - stream << result.getExpandedExpression(); - } - } - - void printMessage() { - if ( itMessage != messages.end() ) { - stream << " '" << itMessage->message << "'"; - ++itMessage; - } - } - - void printRemainingMessages( Colour::Code colour = dimColour() ) { - if ( itMessage == messages.end() ) - return; - - // using messages.end() directly yields compilation error: - std::vector::const_iterator itEnd = messages.end(); - const std::size_t N = static_cast( std::distance( itMessage, itEnd ) ); - - { - Colour colourGuard( colour ); - stream << " with " << pluralise( N, "message" ) << ":"; - } - - for(; itMessage != itEnd; ) { - // If this assertion is a warning ignore any INFO messages - if( printInfoMessages || itMessage->type != ResultWas::Info ) { - stream << " '" << itMessage->message << "'"; - if ( ++itMessage != itEnd ) { - Colour colourGuard( dimColour() ); - stream << " and"; - } - } - } - } - - private: - std::ostream& stream; - AssertionStats const& stats; - AssertionResult const& result; - std::vector messages; - std::vector::const_iterator itMessage; - bool printInfoMessages; - }; - - // Colour, message variants: - // - white: No tests ran. - // - red: Failed [both/all] N test cases, failed [both/all] M assertions. - // - white: Passed [both/all] N test cases (no assertions). - // - red: Failed N tests cases, failed M assertions. - // - green: Passed [both/all] N tests cases with M assertions. - - std::string bothOrAll( std::size_t count ) const { - return count == 1 ? "" : count == 2 ? "both " : "all " ; - } - - void printTotals( const Totals& totals ) const { - if( totals.testCases.total() == 0 ) { - stream << "No tests ran."; - } - else if( totals.testCases.failed == totals.testCases.total() ) { - Colour colour( Colour::ResultError ); - const std::string qualify_assertions_failed = - totals.assertions.failed == totals.assertions.total() ? - bothOrAll( totals.assertions.failed ) : ""; - stream << - "Failed " << bothOrAll( totals.testCases.failed ) - << pluralise( totals.testCases.failed, "test case" ) << ", " - "failed " << qualify_assertions_failed << - pluralise( totals.assertions.failed, "assertion" ) << "."; - } - else if( totals.assertions.total() == 0 ) { - stream << - "Passed " << bothOrAll( totals.testCases.total() ) - << pluralise( totals.testCases.total(), "test case" ) - << " (no assertions)."; - } - else if( totals.assertions.failed ) { - Colour colour( Colour::ResultError ); - stream << - "Failed " << pluralise( totals.testCases.failed, "test case" ) << ", " - "failed " << pluralise( totals.assertions.failed, "assertion" ) << "."; - } - else { - Colour colour( Colour::ResultSuccess ); - stream << - "Passed " << bothOrAll( totals.testCases.passed ) - << pluralise( totals.testCases.passed, "test case" ) << - " with " << pluralise( totals.assertions.passed, "assertion" ) << "."; - } - } - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "compact", CompactReporter ) - -} // end namespace Catch - -namespace Catch { - NonCopyable::~NonCopyable() {} - IShared::~IShared() {} - StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {} - IContext::~IContext() {} - IResultCapture::~IResultCapture() {} - ITestCase::~ITestCase() {} - ITestCaseRegistry::~ITestCaseRegistry() {} - IRegistryHub::~IRegistryHub() {} - IMutableRegistryHub::~IMutableRegistryHub() {} - IExceptionTranslator::~IExceptionTranslator() {} - IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {} - IReporter::~IReporter() {} - IReporterFactory::~IReporterFactory() {} - IReporterRegistry::~IReporterRegistry() {} - IStreamingReporter::~IStreamingReporter() {} - AssertionStats::~AssertionStats() {} - SectionStats::~SectionStats() {} - TestCaseStats::~TestCaseStats() {} - TestGroupStats::~TestGroupStats() {} - TestRunStats::~TestRunStats() {} - CumulativeReporterBase::SectionNode::~SectionNode() {} - CumulativeReporterBase::~CumulativeReporterBase() {} - - StreamingReporterBase::~StreamingReporterBase() {} - ConsoleReporter::~ConsoleReporter() {} - CompactReporter::~CompactReporter() {} - IRunner::~IRunner() {} - IMutableContext::~IMutableContext() {} - IConfig::~IConfig() {} - XmlReporter::~XmlReporter() {} - JunitReporter::~JunitReporter() {} - TestRegistry::~TestRegistry() {} - FreeFunctionTestCase::~FreeFunctionTestCase() {} - IGeneratorInfo::~IGeneratorInfo() {} - IGeneratorsForTest::~IGeneratorsForTest() {} - TestSpec::Pattern::~Pattern() {} - TestSpec::NamePattern::~NamePattern() {} - TestSpec::TagPattern::~TagPattern() {} - TestSpec::ExcludedPattern::~ExcludedPattern() {} - - Matchers::Impl::StdString::Equals::~Equals() {} - Matchers::Impl::StdString::Contains::~Contains() {} - Matchers::Impl::StdString::StartsWith::~StartsWith() {} - Matchers::Impl::StdString::EndsWith::~EndsWith() {} - - void Config::dummy() {} - - INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( "xml", XmlReporter ) -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#endif - -#ifdef CATCH_CONFIG_MAIN -// #included from: internal/catch_default_main.hpp -#define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED - -#ifndef __OBJC__ - -// Standard C/C++ main entry point -int main (int argc, char * const argv[]) { - return Catch::Session().run( argc, argv ); -} - -#else // __OBJC__ - -// Objective-C entry point -int main (int argc, char * const argv[]) { -#if !CATCH_ARC_ENABLED - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; -#endif - - Catch::registerTestMethods(); - int result = Catch::Session().run( argc, (char* const*)argv ); - -#if !CATCH_ARC_ENABLED - [pool drain]; -#endif - - return result; -} - -#endif // __OBJC__ - -#endif - -#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED -# undef CLARA_CONFIG_MAIN -#endif - -////// - -// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ -#ifdef CATCH_CONFIG_PREFIX_ALL - -#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" ) -#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::NegateResult, "CATCH_REQUIRE_FALSE" ) - -#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS" ) -#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" ) -#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" ) - -#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" ) -#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::NegateResult, "CATCH_CHECK_FALSE" ) -#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_IF" ) -#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_ELSE" ) -#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CATCH_CHECK_NOFAIL" ) - -#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" ) -#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" ) -#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" ) - -#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" ) -#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" ) - -#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) -#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg ) -#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) -#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) -#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) - #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) - #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) - #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) - #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ ) - #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ ) -#else - #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) - #define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) - #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) - #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) - #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg ) - #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg ) -#endif -#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) - -#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) -#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) - -#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) - -// "BDD-style" convenience wrappers -#ifdef CATCH_CONFIG_VARIADIC_MACROS -#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) -#else -#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags ) -#endif -#define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" ) -#define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" ) -#define CATCH_AND_WHEN( desc ) CATCH_SECTION( " And: " desc, "" ) -#define CATCH_THEN( desc ) CATCH_SECTION( " Then: " desc, "" ) -#define CATCH_AND_THEN( desc ) CATCH_SECTION( " And: " desc, "" ) - -// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required -#else - -#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" ) -#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::NegateResult, "REQUIRE_FALSE" ) - -#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::Normal, "REQUIRE_THROWS" ) -#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" ) -#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" ) - -#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" ) -#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::NegateResult, "CHECK_FALSE" ) -#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" ) -#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" ) -#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" ) - -#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS" ) -#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" ) -#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" ) - -#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" ) -#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" ) - -#define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) -#define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg ) -#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) -#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) -#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) - #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) - #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) - #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) - #define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ ) - #define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ ) -#else - #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) - #define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) - #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) - #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) - #define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg ) - #define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg ) -#endif -#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) - -#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) -#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) - -#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) - -#endif - -#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) - -// "BDD-style" convenience wrappers -#ifdef CATCH_CONFIG_VARIADIC_MACROS -#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) -#else -#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags ) -#endif -#define GIVEN( desc ) SECTION( " Given: " desc, "" ) -#define WHEN( desc ) SECTION( " When: " desc, "" ) -#define AND_WHEN( desc ) SECTION( "And when: " desc, "" ) -#define THEN( desc ) SECTION( " Then: " desc, "" ) -#define AND_THEN( desc ) SECTION( " And: " desc, "" ) - -using Catch::Detail::Approx; - -// #included from: internal/catch_reenable_warnings.h - -#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED - diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/testCellBuffer.cxx b/dep/scintilla/scintilla-3.6.0/test/unit/testCellBuffer.cxx deleted file mode 100644 index 86ab3a59..00000000 --- a/dep/scintilla/scintilla-3.6.0/test/unit/testCellBuffer.cxx +++ /dev/null @@ -1,141 +0,0 @@ -// Unit Tests for Scintilla internal data structures - -#include -#include -#include - -#include "Platform.h" - -#include "Position.h" -#include "SplitVector.h" -#include "Partitioning.h" -#include "RunStyles.h" -#include "CellBuffer.h" - -#include "catch.hpp" - -// Test CellBuffer. - -TEST_CASE("CellBuffer") { - - const char sText[] = "Scintilla"; - const size_t sLength = strlen(sText); - - CellBuffer cb; - - SECTION("InsertOneLine") { - bool startSequence = false; - const char *cpChange = cb.InsertString(0, sText, sLength, startSequence); - REQUIRE(startSequence); - REQUIRE(sLength == cb.Length()); - REQUIRE(memcmp(cpChange, sText, sLength) == 0); - REQUIRE(1 == cb.Lines()); - REQUIRE(0 == cb.LineStart(0)); - REQUIRE(0 == cb.LineFromPosition(0)); - REQUIRE(sLength == cb.LineStart(1)); - REQUIRE(0 == cb.LineFromPosition(sLength)); - REQUIRE(cb.CanUndo()); - REQUIRE(!cb.CanRedo()); - } - - SECTION("InsertTwoLines") { - const char sText2[] = "Two\nLines"; - const size_t sLength2 = strlen(sText2); - bool startSequence = false; - const char *cpChange = cb.InsertString(0, sText2, sLength2, startSequence); - REQUIRE(startSequence); - REQUIRE(sLength2 == cb.Length()); - REQUIRE(memcmp(cpChange, sText2, sLength2) == 0); - REQUIRE(2 == cb.Lines()); - REQUIRE(0 == cb.LineStart(0)); - REQUIRE(0 == cb.LineFromPosition(0)); - REQUIRE(4 == cb.LineStart(1)); - REQUIRE(1 == cb.LineFromPosition(5)); - REQUIRE(sLength2 == cb.LineStart(2)); - REQUIRE(1 == cb.LineFromPosition(sLength2)); - REQUIRE(cb.CanUndo()); - REQUIRE(!cb.CanRedo()); - } - - SECTION("UndoOff") { - REQUIRE(cb.IsCollectingUndo()); - cb.SetUndoCollection(false); - REQUIRE(!cb.IsCollectingUndo()); - bool startSequence = false; - const char *cpChange = cb.InsertString(0, sText, sLength, startSequence); - REQUIRE(!startSequence); - REQUIRE(sLength == cb.Length()); - REQUIRE(memcmp(cpChange, sText, sLength) == 0); - REQUIRE(!cb.CanUndo()); - REQUIRE(!cb.CanRedo()); - } - - SECTION("UndoRedo") { - const char sTextDeleted[] = "ci"; - const char sTextAfterDeletion[] = "Sntilla"; - bool startSequence = false; - const char *cpChange = cb.InsertString(0, sText, sLength, startSequence); - REQUIRE(startSequence); - REQUIRE(sLength == cb.Length()); - REQUIRE(memcmp(cpChange, sText, sLength) == 0); - REQUIRE(memcmp(cb.BufferPointer(), sText, sLength) == 0); - REQUIRE(cb.CanUndo()); - REQUIRE(!cb.CanRedo()); - const char *cpDeletion = cb.DeleteChars(1, 2, startSequence); - REQUIRE(startSequence); - REQUIRE(memcmp(cpDeletion, sTextDeleted, strlen(sTextDeleted)) == 0); - REQUIRE(memcmp(cb.BufferPointer(), sTextAfterDeletion, strlen(sTextAfterDeletion)) == 0); - REQUIRE(cb.CanUndo()); - REQUIRE(!cb.CanRedo()); - - int steps = cb.StartUndo(); - REQUIRE(steps == 1); - cb.PerformUndoStep(); - REQUIRE(memcmp(cb.BufferPointer(), sText, sLength) == 0); - REQUIRE(cb.CanUndo()); - REQUIRE(cb.CanRedo()); - - steps = cb.StartUndo(); - REQUIRE(steps == 1); - cb.PerformUndoStep(); - REQUIRE(cb.Length() == 0); - REQUIRE(!cb.CanUndo()); - REQUIRE(cb.CanRedo()); - - steps = cb.StartRedo(); - REQUIRE(steps == 1); - cb.PerformRedoStep(); - REQUIRE(memcmp(cb.BufferPointer(), sText, sLength) == 0); - REQUIRE(cb.CanUndo()); - REQUIRE(cb.CanRedo()); - - steps = cb.StartRedo(); - REQUIRE(steps == 1); - cb.PerformRedoStep(); - REQUIRE(memcmp(cb.BufferPointer(), sTextAfterDeletion, strlen(sTextAfterDeletion)) == 0); - REQUIRE(cb.CanUndo()); - REQUIRE(!cb.CanRedo()); - - cb.DeleteUndoHistory(); - REQUIRE(!cb.CanUndo()); - REQUIRE(!cb.CanRedo()); - } - - SECTION("LineEndTypes") { - REQUIRE(cb.GetLineEndTypes() == 0); - cb.SetLineEndTypes(1); - REQUIRE(cb.GetLineEndTypes() == 1); - cb.SetLineEndTypes(0); - REQUIRE(cb.GetLineEndTypes() == 0); - } - - SECTION("ReadOnly") { - REQUIRE(!cb.IsReadOnly()); - cb.SetReadOnly(true); - REQUIRE(cb.IsReadOnly()); - bool startSequence = false; - cb.InsertString(0, sText, sLength, startSequence); - REQUIRE(cb.Length() == 0); - } - -} diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/testContractionState.cxx b/dep/scintilla/scintilla-3.6.0/test/unit/testContractionState.cxx deleted file mode 100644 index 58466426..00000000 --- a/dep/scintilla/scintilla-3.6.0/test/unit/testContractionState.cxx +++ /dev/null @@ -1,142 +0,0 @@ -// Unit Tests for Scintilla internal data structures - -#include - -#include -#include - -#include "Platform.h" - -#include "Position.h" -#include "SplitVector.h" -#include "Partitioning.h" -#include "RunStyles.h" -#include "ContractionState.h" - -#include "catch.hpp" - -// Test ContractionState. - -TEST_CASE("ContractionState") { - - ContractionState cs; - - SECTION("IsEmptyInitially") { - REQUIRE(1 == cs.LinesInDoc()); - REQUIRE(1 == cs.LinesDisplayed()); - REQUIRE(0 == cs.DisplayFromDoc(0)); - REQUIRE(0 == cs.DocFromDisplay(0)); - } - - SECTION("OneLine") { - cs.InsertLine(0); - REQUIRE(2 == cs.LinesInDoc()); - REQUIRE(2 == cs.LinesDisplayed()); - REQUIRE(0 == cs.DisplayFromDoc(0)); - REQUIRE(0 == cs.DocFromDisplay(0)); - REQUIRE(1 == cs.DisplayFromDoc(1)); - REQUIRE(1 == cs.DocFromDisplay(1)); - } - - SECTION("InsertionThenDeletions") { - cs.InsertLines(0,4); - cs.DeleteLine(1); - - REQUIRE(4 == cs.LinesInDoc()); - REQUIRE(4 == cs.LinesDisplayed()); - for (int l=0;l<4;l++) { - REQUIRE(l == cs.DisplayFromDoc(l)); - REQUIRE(l == cs.DocFromDisplay(l)); - } - - cs.DeleteLines(0,2); - REQUIRE(2 == cs.LinesInDoc()); - REQUIRE(2 == cs.LinesDisplayed()); - for (int l=0;l<2;l++) { - REQUIRE(l == cs.DisplayFromDoc(l)); - REQUIRE(l == cs.DocFromDisplay(l)); - } - } - - SECTION("ShowHide") { - cs.InsertLines(0,4); - REQUIRE(true == cs.GetVisible(0)); - REQUIRE(true == cs.GetVisible(1)); - REQUIRE(true == cs.GetVisible(2)); - REQUIRE(5 == cs.LinesDisplayed()); - - cs.SetVisible(1, 1, false); - REQUIRE(true == cs.GetVisible(0)); - REQUIRE(0 == cs.GetVisible(1)); - REQUIRE(true == cs.GetVisible(2)); - REQUIRE(4 == cs.LinesDisplayed()); - REQUIRE(1 == cs.HiddenLines()); - - cs.SetVisible(1, 2, true); - for (int l=0;l<4;l++) { - REQUIRE(true == cs.GetVisible(0)); - } - - cs.SetVisible(1, 1, false); - REQUIRE(0 == cs.GetVisible(1)); - cs.ShowAll(); - for (int l=0;l<4;l++) { - REQUIRE(true == cs.GetVisible(0)); - } - REQUIRE(0 == cs.HiddenLines()); - } - - SECTION("Hidden") { - cs.InsertLines(0,1); - for (int l=0;l<2;l++) { - REQUIRE(true == cs.GetVisible(0)); - } - REQUIRE(0 == cs.HiddenLines()); - - cs.SetVisible(1, 1, false); - REQUIRE(true == cs.GetVisible(0)); - REQUIRE(0 == cs.GetVisible(1)); - REQUIRE(1 == cs.HiddenLines()); - - cs.SetVisible(1, 1, true); - for (int l=0;l<2;l++) { - REQUIRE(true == cs.GetVisible(0)); - } - REQUIRE(0 == cs.HiddenLines()); - } - - SECTION("Contracting") { - cs.InsertLines(0,4); - for (int l=0;l<4;l++) { - REQUIRE(true == cs.GetExpanded(l)); - } - - cs.SetExpanded(2, false); - REQUIRE(true == cs.GetExpanded(1)); - REQUIRE(0 == cs.GetExpanded(2)); - REQUIRE(true == cs.GetExpanded(3)); - - REQUIRE(2 == cs.ContractedNext(0)); - REQUIRE(2 == cs.ContractedNext(1)); - REQUIRE(2 == cs.ContractedNext(2)); - REQUIRE(-1 == cs.ContractedNext(3)); - - cs.SetExpanded(2, true); - REQUIRE(true == cs.GetExpanded(1)); - REQUIRE(true == cs.GetExpanded(2)); - REQUIRE(true == cs.GetExpanded(3)); - } - - SECTION("ChangeHeight") { - cs.InsertLines(0,4); - for (int l=0;l<4;l++) { - REQUIRE(1 == cs.GetHeight(l)); - } - - cs.SetHeight(1, 2); - REQUIRE(1 == cs.GetHeight(0)); - REQUIRE(2 == cs.GetHeight(1)); - REQUIRE(1 == cs.GetHeight(2)); - } - -} diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/testDecoration.cxx b/dep/scintilla/scintilla-3.6.0/test/unit/testDecoration.cxx deleted file mode 100644 index 0d45e562..00000000 --- a/dep/scintilla/scintilla-3.6.0/test/unit/testDecoration.cxx +++ /dev/null @@ -1,90 +0,0 @@ -// Unit Tests for Scintilla internal data structures - -#include - -#include -#include - -#include "Platform.h" - -#include "Position.h" -#include "SplitVector.h" -#include "Partitioning.h" -#include "RunStyles.h" -#include "Decoration.h" - -#include "catch.hpp" - -const int indicator=4; - -// Test Decoration. - -TEST_CASE("Decoration") { - - Decoration deco(indicator); - - SECTION("HasCorrectIndicator") { - REQUIRE(indicator == deco.indicator); - } - - SECTION("IsEmptyInitially") { - REQUIRE(0 == deco.rs.Length()); - REQUIRE(1 == deco.rs.Runs()); - REQUIRE(deco.Empty()); - } - - SECTION("SimpleSpace") { - deco.rs.InsertSpace(0, 1); - REQUIRE(deco.Empty()); - } - - SECTION("SimpleRun") { - deco.rs.InsertSpace(0, 1); - deco.rs.SetValueAt(0, 2); - REQUIRE(!deco.Empty()); - } -} - -// Test DecorationList. - -TEST_CASE("DecorationList") { - - DecorationList decol; - - SECTION("HasCorrectIndicator") { - decol.SetCurrentIndicator(indicator); - REQUIRE(indicator == decol.GetCurrentIndicator()); - } - - SECTION("HasCorrectCurrentValue") { - const int value = 55; - decol.SetCurrentValue(value); - REQUIRE(value == decol.GetCurrentValue()); - } - - SECTION("ExpandSetValues") { - decol.SetCurrentIndicator(indicator); - decol.InsertSpace(0, 9); - const int value = 59; - int position = 4; - int fillLength = 3; - bool changed = decol.FillRange(position, value, fillLength); - REQUIRE(changed); - REQUIRE(position == 4); - REQUIRE(fillLength == 3); - REQUIRE(fillLength == 3); - REQUIRE(decol.ValueAt(indicator, 5) == value); - REQUIRE(decol.AllOnFor(5) == (1 << indicator)); - REQUIRE(decol.Start(indicator, 5) == 4); - REQUIRE(decol.End(indicator, 5) == 7); - const int indicatorB=6; - decol.SetCurrentIndicator(indicatorB); - changed = decol.FillRange(position, value, fillLength); - REQUIRE(changed); - REQUIRE(decol.AllOnFor(5) == ((1 << indicator) | (1 << indicatorB))); - decol.DeleteRange(5, 1); - REQUIRE(decol.Start(indicatorB, 5) == 4); - REQUIRE(decol.End(indicatorB, 5) == 6); - } - -} diff --git a/dep/scintilla/scintilla-3.6.0/test/unit/testUnicodeFromUTF8.cxx b/dep/scintilla/scintilla-3.6.0/test/unit/testUnicodeFromUTF8.cxx deleted file mode 100644 index 841a9c68..00000000 --- a/dep/scintilla/scintilla-3.6.0/test/unit/testUnicodeFromUTF8.cxx +++ /dev/null @@ -1,44 +0,0 @@ -// Unit Tests for Scintilla internal data structures - -#include - -#include - -#include "Platform.h" - -#include "UnicodeFromUTF8.h" - -#include "catch.hpp" - -// Test UnicodeFromUTF8. -// Use examples from Wikipedia: -// http://en.wikipedia.org/wiki/UTF-8 - -TEST_CASE("UnicodeFromUTF8") { - - SECTION("ASCII") { - const unsigned char s[]={'a', 0}; - REQUIRE(UnicodeFromUTF8(s) == 'a'); - } - - SECTION("Example1") { - const unsigned char s[]={0x24, 0}; - REQUIRE(UnicodeFromUTF8(s) == 0x24); - } - - SECTION("Example2") { - const unsigned char s[]={0xC2, 0xA2, 0}; - REQUIRE(UnicodeFromUTF8(s) == 0xA2); - } - - SECTION("Example3") { - const unsigned char s[]={0xE2, 0x82, 0xAC, 0}; - REQUIRE(UnicodeFromUTF8(s) == 0x20AC); - } - - SECTION("Example4") { - const unsigned char s[]={0xF0, 0x90, 0x8D, 0x88, 0}; - REQUIRE(UnicodeFromUTF8(s) == 0x10348); - } - -} diff --git a/dep/scintilla/scintilla-3.6.0/version.txt b/dep/scintilla/scintilla-3.6.0/version.txt deleted file mode 100644 index 2921a158..00000000 --- a/dep/scintilla/scintilla-3.6.0/version.txt +++ /dev/null @@ -1 +0,0 @@ -360 diff --git a/dep/scintilla/scintilla-3.6.0/win32/CheckD2D.cxx b/dep/scintilla/scintilla-3.6.0/win32/CheckD2D.cxx deleted file mode 100644 index 80f5d46d..00000000 --- a/dep/scintilla/scintilla-3.6.0/win32/CheckD2D.cxx +++ /dev/null @@ -1,3 +0,0 @@ -// This file is compiled to check whether Direct2D and DirectWrite headers are available. -#include -#include diff --git a/dep/scintilla/scintilla-3.6.0/win32/deps.mak b/dep/scintilla/scintilla-3.6.0/win32/deps.mak deleted file mode 100644 index 9922ef59..00000000 --- a/dep/scintilla/scintilla-3.6.0/win32/deps.mak +++ /dev/null @@ -1,675 +0,0 @@ -CheckD2D.o: CheckD2D.cxx -HanjaDic.o: HanjaDic.cxx ../src/UniConversion.h HanjaDic.h -PlatWin.o: PlatWin.cxx ../include/Platform.h ../lexlib/StringCopy.h \ - ../src/XPM.h ../src/UniConversion.h ../src/FontQuality.h -ScintillaWin.o: ScintillaWin.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../lexlib/StringCopy.h ../src/Position.h ../src/SplitVector.h \ - ../src/Partitioning.h ../src/RunStyles.h ../src/ContractionState.h \ - ../src/CellBuffer.h ../src/CallTip.h ../src/KeyMap.h ../src/Indicator.h \ - ../src/XPM.h ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/CaseConvert.h ../src/UniConversion.h \ - ../src/Selection.h ../src/PositionCache.h ../src/EditModel.h \ - ../src/MarginView.h ../src/EditView.h ../src/Editor.h \ - ../src/AutoComplete.h ../src/ScintillaBase.h PlatWin.h HanjaDic.h -AutoComplete.o: ../src/AutoComplete.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h \ - ../lexlib/CharacterSet.h ../src/Position.h ../src/AutoComplete.h -CallTip.o: ../src/CallTip.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../lexlib/StringCopy.h \ - ../src/Position.h ../src/CallTip.h -CaseConvert.o: ../src/CaseConvert.cxx ../lexlib/StringCopy.h \ - ../src/CaseConvert.h ../src/UniConversion.h ../src/UnicodeFromUTF8.h -CaseFolder.o: ../src/CaseFolder.cxx ../src/CaseFolder.h \ - ../src/CaseConvert.h ../src/UniConversion.h -Catalogue.o: ../src/Catalogue.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/LexerModule.h ../src/Catalogue.h -CellBuffer.o: ../src/CellBuffer.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/CellBuffer.h \ - ../src/UniConversion.h -CharClassify.o: ../src/CharClassify.cxx ../src/CharClassify.h -ContractionState.o: ../src/ContractionState.cxx ../include/Platform.h \ - ../src/Position.h ../src/SplitVector.h ../src/Partitioning.h \ - ../src/RunStyles.h ../src/ContractionState.h -Decoration.o: ../src/Decoration.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/RunStyles.h \ - ../src/Decoration.h -Document.o: ../src/Document.cxx ../include/Platform.h ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h \ - ../lexlib/CharacterSet.h ../src/Position.h ../src/SplitVector.h \ - ../src/Partitioning.h ../src/RunStyles.h ../src/CellBuffer.h \ - ../src/PerLine.h ../src/CharClassify.h ../src/Decoration.h \ - ../src/CaseFolder.h ../src/Document.h ../src/RESearch.h \ - ../src/UniConversion.h ../src/UnicodeFromUTF8.h -EditModel.o: ../src/EditModel.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../lexlib/StringCopy.h ../src/Position.h ../src/SplitVector.h \ - ../src/Partitioning.h ../src/RunStyles.h ../src/ContractionState.h \ - ../src/CellBuffer.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \ - ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/UniConversion.h ../src/Selection.h \ - ../src/PositionCache.h ../src/EditModel.h -Editor.o: ../src/Editor.cxx ../include/Platform.h ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../lexlib/StringCopy.h \ - ../src/Position.h ../src/SplitVector.h ../src/Partitioning.h \ - ../src/RunStyles.h ../src/ContractionState.h ../src/CellBuffer.h \ - ../src/PerLine.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \ - ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/UniConversion.h ../src/Selection.h \ - ../src/PositionCache.h ../src/EditModel.h ../src/MarginView.h \ - ../src/EditView.h ../src/Editor.h -EditView.o: ../src/EditView.cxx ../include/Platform.h ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../lexlib/StringCopy.h \ - ../src/Position.h ../src/SplitVector.h ../src/Partitioning.h \ - ../src/RunStyles.h ../src/ContractionState.h ../src/CellBuffer.h \ - ../src/PerLine.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \ - ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/UniConversion.h ../src/Selection.h \ - ../src/PositionCache.h ../src/EditModel.h ../src/MarginView.h \ - ../src/EditView.h -ExternalLexer.o: ../src/ExternalLexer.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../include/SciLexer.h ../lexlib/LexerModule.h ../src/Catalogue.h \ - ../src/ExternalLexer.h -Indicator.o: ../src/Indicator.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Indicator.h \ - ../src/XPM.h -KeyMap.o: ../src/KeyMap.cxx ../include/Platform.h ../include/Scintilla.h \ - ../include/Sci_Position.h ../src/KeyMap.h -LineMarker.o: ../src/LineMarker.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../lexlib/StringCopy.h \ - ../src/XPM.h ../src/LineMarker.h -MarginView.o: ../src/MarginView.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../lexlib/StringCopy.h ../src/Position.h ../src/SplitVector.h \ - ../src/Partitioning.h ../src/RunStyles.h ../src/ContractionState.h \ - ../src/CellBuffer.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \ - ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/UniConversion.h ../src/Selection.h \ - ../src/PositionCache.h ../src/EditModel.h ../src/MarginView.h \ - ../src/EditView.h -PerLine.o: ../src/PerLine.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/CellBuffer.h \ - ../src/PerLine.h -PositionCache.o: ../src/PositionCache.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../src/Position.h ../src/SplitVector.h ../src/Partitioning.h \ - ../src/RunStyles.h ../src/ContractionState.h ../src/CellBuffer.h \ - ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h \ - ../src/Style.h ../src/ViewStyle.h ../src/CharClassify.h \ - ../src/Decoration.h ../src/CaseFolder.h ../src/Document.h \ - ../src/UniConversion.h ../src/Selection.h ../src/PositionCache.h -RESearch.o: ../src/RESearch.cxx ../src/Position.h ../src/CharClassify.h \ - ../src/RESearch.h -RunStyles.o: ../src/RunStyles.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/RunStyles.h -ScintillaBase.o: ../src/ScintillaBase.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../lexlib/PropSetSimple.h ../src/Position.h ../src/SplitVector.h \ - ../src/Partitioning.h ../src/RunStyles.h ../src/ContractionState.h \ - ../src/CellBuffer.h ../src/CallTip.h ../src/KeyMap.h ../src/Indicator.h \ - ../src/XPM.h ../src/LineMarker.h ../src/Style.h ../src/ViewStyle.h \ - ../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \ - ../src/Document.h ../src/Selection.h ../src/PositionCache.h \ - ../src/EditModel.h ../src/MarginView.h ../src/EditView.h ../src/Editor.h \ - ../src/AutoComplete.h ../src/ScintillaBase.h -Selection.o: ../src/Selection.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/Selection.h -Style.o: ../src/Style.cxx ../include/Platform.h ../include/Scintilla.h \ - ../include/Sci_Position.h ../src/Style.h -UniConversion.o: ../src/UniConversion.cxx ../src/UniConversion.h -ViewStyle.o: ../src/ViewStyle.cxx ../include/Platform.h \ - ../include/Scintilla.h ../include/Sci_Position.h ../src/Position.h \ - ../src/SplitVector.h ../src/Partitioning.h ../src/RunStyles.h \ - ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h ../src/Style.h \ - ../src/ViewStyle.h -XPM.o: ../src/XPM.cxx ../include/Platform.h ../src/XPM.h -Accessor.o: ../lexlib/Accessor.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h -CharacterCategory.o: ../lexlib/CharacterCategory.cxx \ - ../lexlib/StringCopy.h ../lexlib/CharacterCategory.h -CharacterSet.o: ../lexlib/CharacterSet.cxx ../lexlib/CharacterSet.h -LexerBase.o: ../lexlib/LexerBase.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/LexerModule.h ../lexlib/LexerBase.h -LexerModule.o: ../lexlib/LexerModule.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/LexerModule.h ../lexlib/LexerBase.h \ - ../lexlib/LexerSimple.h -LexerNoExceptions.o: ../lexlib/LexerNoExceptions.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/LexerModule.h ../lexlib/LexerBase.h \ - ../lexlib/LexerNoExceptions.h -LexerSimple.o: ../lexlib/LexerSimple.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/LexerModule.h ../lexlib/LexerBase.h \ - ../lexlib/LexerSimple.h -PropSetSimple.o: ../lexlib/PropSetSimple.cxx ../lexlib/PropSetSimple.h -StyleContext.o: ../lexlib/StyleContext.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h -WordList.o: ../lexlib/WordList.cxx ../lexlib/StringCopy.h \ - ../lexlib/WordList.h -LexA68k.o: ../lexers/LexA68k.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAbaqus.o: ../lexers/LexAbaqus.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAda.o: ../lexers/LexAda.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAPDL.o: ../lexers/LexAPDL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAsm.o: ../lexers/LexAsm.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexAsn1.o: ../lexers/LexAsn1.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexASY.o: ../lexers/LexASY.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAU3.o: ../lexers/LexAU3.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAVE.o: ../lexers/LexAVE.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexAVS.o: ../lexers/LexAVS.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBaan.o: ../lexers/LexBaan.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBash.o: ../lexers/LexBash.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBasic.o: ../lexers/LexBasic.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexBatch.o: ../lexers/LexBatch.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBibTeX.o: ../lexers/LexBibTeX.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexBullant.o: ../lexers/LexBullant.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCaml.o: ../lexers/LexCaml.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCLW.o: ../lexers/LexCLW.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCmake.o: ../lexers/LexCmake.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCOBOL.o: ../lexers/LexCOBOL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCoffeeScript.o: ../lexers/LexCoffeeScript.cxx ../include/Platform.h \ - ../include/ILexer.h ../include/Sci_Position.h ../include/Scintilla.h \ - ../include/SciLexer.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexConf.o: ../lexers/LexConf.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCPP.o: ../lexers/LexCPP.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h ../lexlib/SparseState.h \ - ../lexlib/SubStyles.h -LexCrontab.o: ../lexers/LexCrontab.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCsound.o: ../lexers/LexCsound.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexCSS.o: ../lexers/LexCSS.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexD.o: ../lexers/LexD.cxx ../include/ILexer.h ../include/Sci_Position.h \ - ../include/Scintilla.h ../include/SciLexer.h ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexDiff.o: ../lexers/LexDiff.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexDMAP.o: ../lexers/LexDMAP.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexDMIS.o: ../lexers/LexDMIS.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h -LexECL.o: ../lexers/LexECL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexEiffel.o: ../lexers/LexEiffel.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexErlang.o: ../lexers/LexErlang.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexErrorList.o: ../lexers/LexErrorList.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexEScript.o: ../lexers/LexEScript.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexFlagship.o: ../lexers/LexFlagship.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexForth.o: ../lexers/LexForth.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexFortran.o: ../lexers/LexFortran.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexGAP.o: ../lexers/LexGAP.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexGui4Cli.o: ../lexers/LexGui4Cli.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexHaskell.o: ../lexers/LexHaskell.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/CharacterCategory.h ../lexlib/LexerModule.h \ - ../lexlib/OptionSet.h -LexHex.o: ../lexers/LexHex.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexHTML.o: ../lexers/LexHTML.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/StringCopy.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexInno.o: ../lexers/LexInno.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexKix.o: ../lexers/LexKix.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexKVIrc.o: ../lexers/LexKVIrc.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexLaTeX.o: ../lexers/LexLaTeX.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/LexerBase.h -LexLisp.o: ../lexers/LexLisp.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexLout.o: ../lexers/LexLout.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexLua.o: ../lexers/LexLua.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMagik.o: ../lexers/LexMagik.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMake.o: ../lexers/LexMake.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMarkdown.o: ../lexers/LexMarkdown.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMatlab.o: ../lexers/LexMatlab.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMetapost.o: ../lexers/LexMetapost.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMMIXAL.o: ../lexers/LexMMIXAL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexModula.o: ../lexers/LexModula.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMPT.o: ../lexers/LexMPT.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMSSQL.o: ../lexers/LexMSSQL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexMySQL.o: ../lexers/LexMySQL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexNimrod.o: ../lexers/LexNimrod.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexNsis.o: ../lexers/LexNsis.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexNull.o: ../lexers/LexNull.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexOpal.o: ../lexers/LexOpal.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexOScript.o: ../lexers/LexOScript.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPascal.o: ../lexers/LexPascal.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPB.o: ../lexers/LexPB.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPerl.o: ../lexers/LexPerl.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexPLM.o: ../lexers/LexPLM.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPO.o: ../lexers/LexPO.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPOV.o: ../lexers/LexPOV.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPowerPro.o: ../lexers/LexPowerPro.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPowerShell.o: ../lexers/LexPowerShell.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexProgress.o: ../lexers/LexProgress.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexProps.o: ../lexers/LexProps.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPS.o: ../lexers/LexPS.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexPython.o: ../lexers/LexPython.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h ../lexlib/SubStyles.h -LexR.o: ../lexers/LexR.cxx ../include/ILexer.h ../include/Sci_Position.h \ - ../include/Scintilla.h ../include/SciLexer.h ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h ../lexlib/Accessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h -LexRebol.o: ../lexers/LexRebol.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexRegistry.o: ../lexers/LexRegistry.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexRuby.o: ../lexers/LexRuby.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexRust.o: ../lexers/LexRust.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h ../lexlib/WordList.h ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h -LexScriptol.o: ../lexers/LexScriptol.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSmalltalk.o: ../lexers/LexSmalltalk.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSML.o: ../lexers/LexSML.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSorcus.o: ../lexers/LexSorcus.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSpecman.o: ../lexers/LexSpecman.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSpice.o: ../lexers/LexSpice.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexSQL.o: ../lexers/LexSQL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h ../lexlib/SparseState.h -LexSTTXT.o: ../lexers/LexSTTXT.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTACL.o: ../lexers/LexTACL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTADS3.o: ../lexers/LexTADS3.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTAL.o: ../lexers/LexTAL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTCL.o: ../lexers/LexTCL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTCMD.o: ../lexers/LexTCMD.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTeX.o: ../lexers/LexTeX.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexTxt2tags.o: ../lexers/LexTxt2tags.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexVB.o: ../lexers/LexVB.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexVerilog.o: ../lexers/LexVerilog.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h ../lexlib/OptionSet.h ../lexlib/SubStyles.h -LexVHDL.o: ../lexers/LexVHDL.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h -LexVisualProlog.o: ../lexers/LexVisualProlog.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/CharacterCategory.h ../lexlib/LexerModule.h \ - ../lexlib/OptionSet.h -LexYAML.o: ../lexers/LexYAML.cxx ../include/ILexer.h \ - ../include/Sci_Position.h ../include/Scintilla.h ../include/SciLexer.h \ - ../lexlib/WordList.h ../lexlib/LexAccessor.h ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h diff --git a/dep/scintilla/scintilla-3.6.0/win32/makefile b/dep/scintilla/scintilla-3.6.0/win32/makefile deleted file mode 100644 index 6aa0d613..00000000 --- a/dep/scintilla/scintilla-3.6.0/win32/makefile +++ /dev/null @@ -1,171 +0,0 @@ -# Make file for Scintilla on Windows -# Copyright 1998-2010 by Neil Hodgson -# The License.txt file describes the conditions under which this software may be distributed. -# This makefile assumes the MinGW32 version of GCC 4.x is used and changes will -# be needed to use other compilers. - -.SUFFIXES: .cxx -ifeq ($(OS),Windows_NT) -DEL = del /q -else -DEL = rm -f -endif -RANLIB ?= ranlib -WINDRES ?= windres - -COMPONENT = ../bin/Scintilla.dll -LEXCOMPONENT = ../bin/SciLexer.dll -LEXLIB = Lexers.a - -vpath %.h ../src ../include ../lexlib -vpath %.cxx ../src ../lexlib ../lexers - -LDFLAGS=-shared -static -Wl,--enable-runtime-pseudo-reloc-v2 -mwindows -Wl,--add-stdcall-alias -LIBS=-lstdc++ -limm32 -lole32 -luuid -loleaut32 -# Add -MMD to get dependencies -INCLUDEDIRS=-I ../include -I ../src -I../lexlib - -# Check if Direct2D headers are available by trying to compile a file that includes them. -# Most distributions of MinGW32 do not include Direct2D support but MinGW64 does. -ifneq "$(shell g++ -c CheckD2D.cxx 2>&1)" "" -D2DFLAGS=-DDISABLE_D2D -endif - -CXXBASEFLAGS=--std=c++0x -Wall -pedantic $(INCLUDEDIRS) -fno-rtti $(D2DFLAGS) - -ifdef CXX11_REGEX -REFLAGS=-DCXX11_REGEX -endif - -ifdef DEBUG -CXXFLAGS=-DDEBUG -g $(CXXBASEFLAGS) -else -CXXFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) -STRIPFLAG=-s -endif - -.cxx.o: - $(CXX) $(CXXFLAGS) $(REFLAGS) -c $< - -ALL: $(COMPONENT) $(LEXCOMPONENT) $(LEXLIB) ScintillaWinS.o - -clean: - $(DEL) *.exe *.o *.obj *.dll *.res *.map *.plist - -analyze: - clang --analyze -D DISABLE_D2D $(CXXFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx - -deps: - $(CXX) -MM $(CXXFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx >deps.mak - -LEXOBJS:=$(addsuffix .o,$(basename $(notdir $(wildcard ../lexers/Lex*.cxx)))) - - -BASEOBJS = \ - AutoComplete.o \ - CallTip.o \ - CaseConvert.o \ - CaseFolder.o \ - CellBuffer.o \ - CharacterCategory.o \ - CharacterSet.o \ - CharClassify.o \ - ContractionState.o \ - Decoration.o \ - Document.o \ - EditModel.o \ - Editor.o \ - EditView.o \ - KeyMap.o \ - Indicator.o \ - LineMarker.o \ - MarginView.o \ - PerLine.o \ - PlatWin.o \ - PositionCache.o \ - PropSetSimple.o \ - RESearch.o \ - RunStyles.o \ - ScintRes.o \ - Selection.o \ - Style.o \ - UniConversion.o \ - ViewStyle.o \ - XPM.o \ - HanjaDic.o - -SOBJS = ScintillaWin.o ScintillaBase.o $(BASEOBJS) - -$(COMPONENT): $(SOBJS) Scintilla.def - $(CXX) $(LDFLAGS) -o $@ $(STRIPFLAG) $(SOBJS) $(CXXFLAGS) $(LIBS) - -LOBJS = \ - Accessor.o \ - Catalogue.o \ - ExternalLexer.o \ - LexerBase.o \ - LexerModule.o \ - LexerSimple.o \ - ScintillaWinL.o \ - ScintillaBaseL.o \ - StyleContext.o \ - WordList.o \ - $(BASEOBJS) \ - $(LEXOBJS) -$(LEXCOMPONENT): $(LOBJS) Scintilla.def - $(CXX) $(LDFLAGS) -o $@ $(STRIPFLAG) $(LOBJS) $(CXXFLAGS) $(LIBS) - -$(LEXLIB): $(LEXOBJS) - $(AR) rc $@ $^ - $(RANLIB) $@ - -# Automatically generate dependencies for most files with "make deps" -include deps.mak - -# These dependencies are maintained by hand as they do not use the default output name - -ScintillaBaseL.o: ScintillaBase.cxx Platform.h \ - ILexer.h Scintilla.h SciLexer.h PropSetSimple.h \ - SplitVector.h Partitioning.h RunStyles.h \ - ContractionState.h CellBuffer.h CallTip.h \ - KeyMap.h Indicator.h XPM.h LineMarker.h \ - Style.h ViewStyle.h AutoComplete.h \ - CharClassify.h Decoration.h Document.h \ - Selection.h PositionCache.h EditModel.h Editor.h EditView.h \ - ScintillaBase.h LexAccessor.h Accessor.h \ - LexerModule.h Catalogue.h CaseFolder.h - -ScintillaWinL.o: ScintillaWin.cxx Platform.h \ - ILexer.h Scintilla.h SplitVector.h \ - Partitioning.h RunStyles.h ContractionState.h \ - CellBuffer.h CallTip.h KeyMap.h Indicator.h \ - XPM.h LineMarker.h Style.h AutoComplete.h \ - ViewStyle.h CharClassify.h Decoration.h \ - Document.h Selection.h PositionCache.h \ - EditModel.h Editor.h EditView.h ScintillaBase.h UniConversion.h \ - LexAccessor.h Accessor.h \ - LexerModule.h Catalogue.h CaseConvert.h \ - CaseFolder.h - -ScintillaWinS.o: ScintillaWin.cxx Platform.h \ - ILexer.h Scintilla.h SplitVector.h \ - Partitioning.h RunStyles.h ContractionState.h \ - CellBuffer.h CallTip.h KeyMap.h Indicator.h \ - XPM.h LineMarker.h Style.h AutoComplete.h \ - ViewStyle.h CharClassify.h Decoration.h \ - Document.h Selection.h PositionCache.h \ - EditModel.h Editor.h EditView.h ScintillaBase.h UniConversion.h \ - CaseConvert.h CaseFolder.h - -ScintillaBaseL.o: - $(CXX) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@ - -ScintillaWinS.o: - $(CXX) $(CXXFLAGS) -D STATIC_BUILD -c $< -o $@ - -ScintillaWinL.o: - $(CXX) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@ - -ScintRes.o: ScintRes.rc - $(WINDRES) ScintRes.rc $@ - diff --git a/dep/scintilla/scintilla-3.6.0/win32/scintilla.mak b/dep/scintilla/scintilla-3.6.0/win32/scintilla.mak deleted file mode 100644 index 4db9494c..00000000 --- a/dep/scintilla/scintilla-3.6.0/win32/scintilla.mak +++ /dev/null @@ -1,1065 +0,0 @@ -# Make file for Scintilla on Windows Visual C++ version -# Copyright 1998-2010 by Neil Hodgson -# The License.txt file describes the conditions under which this software may be distributed. -# This makefile is for using Visual C++ with nmake. -# Usage for Microsoft: -# nmake -f scintilla.mak -# For debug versions define DEBUG on the command line: -# nmake DEBUG=1 -f scintilla.mak -# The main makefile uses mingw32 gcc and may be more current than this file. - -.SUFFIXES: .cxx - -DIR_O=. -DIR_BIN=..\bin - -COMPONENT=$(DIR_BIN)\Scintilla.dll -LEXCOMPONENT=$(DIR_BIN)\SciLexer.dll -LEXLIB=Lexers.lib - -LD=link - -CRTFLAGS=-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1 -D_CRT_SECURE_NO_DEPRECATE=1 -CXXFLAGS=-Zi -TP -MP -W4 -EHsc -Zc:forScope -Zc:wchar_t $(CRTFLAGS) -CXXDEBUG=-Od -MTd -DDEBUG -CXXNDEBUG=-O1 -MT -DNDEBUG -GL -NAME=-Fo -LDFLAGS=-OPT:REF -LTCG -DEBUG -LDDEBUG= -LIBS=KERNEL32.lib USER32.lib GDI32.lib IMM32.lib OLE32.LIB OLEAUT32.LIB -NOLOGO=-nologo - -!IFDEF QUIET -CXX=@$(CXX) -CXXFLAGS=$(CXXFLAGS) $(NOLOGO) -LDFLAGS=$(LDFLAGS) $(NOLOGO) -!ENDIF - -!IF [cl -c -nologo CheckD2D.cxx >NUL:] -CXXFLAGS=$(CXXFLAGS) -DDISABLE_D2D -!MESSAGE Direct2D is not available -!ENDIF - -!IFDEF CXX11_REGEX -CXXFLAGS=$(CXXFLAGS) -DCXX11_REGEX -!ENDIF - -!IFDEF DEBUG -CXXFLAGS=$(CXXFLAGS) $(CXXDEBUG) -LDFLAGS=$(LDDEBUG) $(LDFLAGS) -!ELSE -CXXFLAGS=$(CXXFLAGS) $(CXXNDEBUG) -!ENDIF - -INCLUDEDIRS=-I../include -I../src -I../lexlib -CXXFLAGS=$(CXXFLAGS) $(INCLUDEDIRS) - -ALL: $(COMPONENT) $(LEXCOMPONENT) $(LEXLIB) $(DIR_O)\ScintillaWinS.obj - -clean: - -del /q $(DIR_O)\*.obj $(DIR_O)\*.pdb $(COMPONENT) $(LEXCOMPONENT) \ - $(DIR_O)\*.res $(DIR_BIN)\*.map $(DIR_BIN)\*.exp $(DIR_BIN)\*.pdb $(DIR_BIN)\*.lib - -SHAREDOBJS=\ - $(DIR_O)\AutoComplete.obj \ - $(DIR_O)\CallTip.obj \ - $(DIR_O)\CaseConvert.obj \ - $(DIR_O)\CaseFolder.obj \ - $(DIR_O)\CellBuffer.obj \ - $(DIR_O)\CharacterCategory.obj \ - $(DIR_O)\CharacterSet.obj \ - $(DIR_O)\CharClassify.obj \ - $(DIR_O)\ContractionState.obj \ - $(DIR_O)\Decoration.obj \ - $(DIR_O)\Document.obj \ - $(DIR_O)\EditModel.obj \ - $(DIR_O)\Editor.obj \ - $(DIR_O)\EditView.obj \ - $(DIR_O)\Indicator.obj \ - $(DIR_O)\KeyMap.obj \ - $(DIR_O)\LineMarker.obj \ - $(DIR_O)\MarginView.obj \ - $(DIR_O)\PerLine.obj \ - $(DIR_O)\PlatWin.obj \ - $(DIR_O)\PositionCache.obj \ - $(DIR_O)\PropSetSimple.obj \ - $(DIR_O)\RESearch.obj \ - $(DIR_O)\RunStyles.obj \ - $(DIR_O)\Selection.obj \ - $(DIR_O)\Style.obj \ - $(DIR_O)\UniConversion.obj \ - $(DIR_O)\ViewStyle.obj \ - $(DIR_O)\XPM.obj \ - $(DIR_O)\HanjaDic.obj \ - -SOBJS=\ - $(SHAREDOBJS) \ - $(DIR_O)\ScintillaBase.obj \ - $(DIR_O)\ScintillaWin.obj - -#++Autogenerated -- run scripts/LexGen.py to regenerate -#**LEXOBJS=\\\n\(\t$(DIR_O)\\\*.obj \\\n\) -LEXOBJS=\ - $(DIR_O)\LexA68k.obj \ - $(DIR_O)\LexAbaqus.obj \ - $(DIR_O)\LexAda.obj \ - $(DIR_O)\LexAPDL.obj \ - $(DIR_O)\LexAsm.obj \ - $(DIR_O)\LexAsn1.obj \ - $(DIR_O)\LexASY.obj \ - $(DIR_O)\LexAU3.obj \ - $(DIR_O)\LexAVE.obj \ - $(DIR_O)\LexAVS.obj \ - $(DIR_O)\LexBaan.obj \ - $(DIR_O)\LexBash.obj \ - $(DIR_O)\LexBasic.obj \ - $(DIR_O)\LexBatch.obj \ - $(DIR_O)\LexBibTeX.obj \ - $(DIR_O)\LexBullant.obj \ - $(DIR_O)\LexCaml.obj \ - $(DIR_O)\LexCLW.obj \ - $(DIR_O)\LexCmake.obj \ - $(DIR_O)\LexCOBOL.obj \ - $(DIR_O)\LexCoffeeScript.obj \ - $(DIR_O)\LexConf.obj \ - $(DIR_O)\LexCPP.obj \ - $(DIR_O)\LexCrontab.obj \ - $(DIR_O)\LexCsound.obj \ - $(DIR_O)\LexCSS.obj \ - $(DIR_O)\LexD.obj \ - $(DIR_O)\LexDiff.obj \ - $(DIR_O)\LexDMAP.obj \ - $(DIR_O)\LexDMIS.obj \ - $(DIR_O)\LexECL.obj \ - $(DIR_O)\LexEiffel.obj \ - $(DIR_O)\LexErlang.obj \ - $(DIR_O)\LexErrorList.obj \ - $(DIR_O)\LexEScript.obj \ - $(DIR_O)\LexFlagship.obj \ - $(DIR_O)\LexForth.obj \ - $(DIR_O)\LexFortran.obj \ - $(DIR_O)\LexGAP.obj \ - $(DIR_O)\LexGui4Cli.obj \ - $(DIR_O)\LexHaskell.obj \ - $(DIR_O)\LexHex.obj \ - $(DIR_O)\LexHTML.obj \ - $(DIR_O)\LexInno.obj \ - $(DIR_O)\LexKix.obj \ - $(DIR_O)\LexKVIrc.obj \ - $(DIR_O)\LexLaTeX.obj \ - $(DIR_O)\LexLisp.obj \ - $(DIR_O)\LexLout.obj \ - $(DIR_O)\LexLua.obj \ - $(DIR_O)\LexMagik.obj \ - $(DIR_O)\LexMake.obj \ - $(DIR_O)\LexMarkdown.obj \ - $(DIR_O)\LexMatlab.obj \ - $(DIR_O)\LexMetapost.obj \ - $(DIR_O)\LexMMIXAL.obj \ - $(DIR_O)\LexModula.obj \ - $(DIR_O)\LexMPT.obj \ - $(DIR_O)\LexMSSQL.obj \ - $(DIR_O)\LexMySQL.obj \ - $(DIR_O)\LexNimrod.obj \ - $(DIR_O)\LexNsis.obj \ - $(DIR_O)\LexNull.obj \ - $(DIR_O)\LexOpal.obj \ - $(DIR_O)\LexOScript.obj \ - $(DIR_O)\LexPascal.obj \ - $(DIR_O)\LexPB.obj \ - $(DIR_O)\LexPerl.obj \ - $(DIR_O)\LexPLM.obj \ - $(DIR_O)\LexPO.obj \ - $(DIR_O)\LexPOV.obj \ - $(DIR_O)\LexPowerPro.obj \ - $(DIR_O)\LexPowerShell.obj \ - $(DIR_O)\LexProgress.obj \ - $(DIR_O)\LexProps.obj \ - $(DIR_O)\LexPS.obj \ - $(DIR_O)\LexPython.obj \ - $(DIR_O)\LexR.obj \ - $(DIR_O)\LexRebol.obj \ - $(DIR_O)\LexRegistry.obj \ - $(DIR_O)\LexRuby.obj \ - $(DIR_O)\LexRust.obj \ - $(DIR_O)\LexScriptol.obj \ - $(DIR_O)\LexSmalltalk.obj \ - $(DIR_O)\LexSML.obj \ - $(DIR_O)\LexSorcus.obj \ - $(DIR_O)\LexSpecman.obj \ - $(DIR_O)\LexSpice.obj \ - $(DIR_O)\LexSQL.obj \ - $(DIR_O)\LexSTTXT.obj \ - $(DIR_O)\LexTACL.obj \ - $(DIR_O)\LexTADS3.obj \ - $(DIR_O)\LexTAL.obj \ - $(DIR_O)\LexTCL.obj \ - $(DIR_O)\LexTCMD.obj \ - $(DIR_O)\LexTeX.obj \ - $(DIR_O)\LexTxt2tags.obj \ - $(DIR_O)\LexVB.obj \ - $(DIR_O)\LexVerilog.obj \ - $(DIR_O)\LexVHDL.obj \ - $(DIR_O)\LexVisualProlog.obj \ - $(DIR_O)\LexYAML.obj \ - -#--Autogenerated -- end of automatically generated section - -LOBJS=\ - $(SHAREDOBJS) \ - $(DIR_O)\Accessor.obj \ - $(DIR_O)\Catalogue.obj \ - $(DIR_O)\ExternalLexer.obj \ - $(DIR_O)\LexerBase.obj \ - $(DIR_O)\LexerModule.obj \ - $(DIR_O)\LexerSimple.obj \ - $(DIR_O)\StyleContext.obj \ - $(DIR_O)\WordList.obj \ - $(DIR_O)\ScintillaBaseL.obj \ - $(DIR_O)\ScintillaWinL.obj \ - $(LEXOBJS) - -$(DIR_O)\ScintRes.res : ScintRes.rc - $(RC) -fo$@ $** - -$(COMPONENT): $(SOBJS) $(DIR_O)\ScintRes.res - $(LD) $(LDFLAGS) -DEF:Scintilla.def -DLL -OUT:$@ $** $(LIBS) - -$(LEXCOMPONENT): $(LOBJS) $(DIR_O)\ScintRes.res - $(LD) $(LDFLAGS) -DEF:Scintilla.def -DLL -OUT:$@ $** $(LIBS) - -$(LEXLIB): $(LEXOBJS) - LIB /OUT:$@ $(LEXOBJS) - -# Define how to build all the objects and what they depend on - -{..\src}.cxx{$(DIR_O)}.obj:: - $(CXX) $(CXXFLAGS) -c $(NAME)$(DIR_O)\ $< -{..\lexlib}.cxx{$(DIR_O)}.obj:: - $(CXX) $(CXXFLAGS) -c $(NAME)$(DIR_O)\ $< -{..\lexers}.cxx{$(DIR_O)}.obj:: - $(CXX) $(CXXFLAGS) -c $(NAME)$(DIR_O)\ $< -{.}.cxx{$(DIR_O)}.obj:: - $(CXX) $(CXXFLAGS) -c $(NAME)$(DIR_O)\ $< - -# Some source files are compiled into more than one object because of different conditional compilation -$(DIR_O)\ScintillaBaseL.obj: ..\src\ScintillaBase.cxx - $(CXX) $(CXXFLAGS) -DSCI_LEXER -c $(NAME)$@ ..\src\ScintillaBase.cxx - -$(DIR_O)\ScintillaWinL.obj: ScintillaWin.cxx - $(CXX) $(CXXFLAGS) -DSCI_LEXER -c $(NAME)$@ ScintillaWin.cxx - -$(DIR_O)\ScintillaWinS.obj: ScintillaWin.cxx - $(CXX) $(CXXFLAGS) -DSTATIC_BUILD -c $(NAME)$@ ScintillaWin.cxx - -# Dependencies - -# All lexers depend on this set of headers -LEX_HEADERS= \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../include/SciLexer.h \ - ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h \ - ../lexlib/CharacterSet.h \ - ../lexlib/LexerModule.h \ - ../lexlib/OptionSet.h \ - ../lexlib/SparseState.h \ - ../lexlib/SubStyles.h - -$(DIR_O)\Accessor.obj: \ - ../lexlib/Accessor.cxx \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h \ - ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h -$(DIR_O)\AutoComplete.obj: \ - ../src/AutoComplete.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../lexlib/CharacterSet.h \ - ../src/Position.h \ - ../src/AutoComplete.h -$(DIR_O)\CallTip.obj: \ - ../src/CallTip.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../lexlib/StringCopy.h \ - ../src/Position.h \ - ../src/CallTip.h -$(DIR_O)\CaseConvert.obj: \ - ../src/CaseConvert.cxx \ - ../lexlib/StringCopy.h \ - ../src/CaseConvert.h \ - ../src/UniConversion.h \ - ../src/UnicodeFromUTF8.h -$(DIR_O)\CaseFolder.obj: \ - ../src/CaseFolder.cxx \ - ../src/CaseFolder.h \ - ../src/CaseConvert.h \ - ../src/UniConversion.h -$(DIR_O)\Catalogue.obj: \ - ../src/Catalogue.cxx \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../include/SciLexer.h \ - ../lexlib/LexerModule.h \ - ../src/Catalogue.h -$(DIR_O)\CellBuffer.obj: \ - ../src/CellBuffer.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/CellBuffer.h \ - ../src/UniConversion.h -$(DIR_O)\CharacterCategory.obj: \ - ../lexlib/CharacterCategory.cxx \ - ../lexlib/StringCopy.h \ - ../lexlib/CharacterCategory.h -$(DIR_O)\CharacterSet.obj: \ - ../lexlib/CharacterSet.cxx \ - ../lexlib/CharacterSet.h -$(DIR_O)\CharClassify.obj: \ - ../src/CharClassify.cxx \ - ../src/CharClassify.h -$(DIR_O)\ContractionState.obj: \ - ../src/ContractionState.cxx \ - ../include/Platform.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h -$(DIR_O)\Decoration.obj: \ - ../src/Decoration.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/Decoration.h -$(DIR_O)\Document.obj: \ - ../src/Document.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/CharacterSet.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/CellBuffer.h \ - ../src/PerLine.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/RESearch.h \ - ../src/UniConversion.h \ - ../src/UnicodeFromUTF8.h -$(DIR_O)\EditModel.obj: \ - ../src/EditModel.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/StringCopy.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h -$(DIR_O)\Editor.obj: \ - ../src/Editor.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/StringCopy.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/PerLine.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h \ - ../src/Editor.h -$(DIR_O)\EditView.obj: \ - ../src/EditView.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/StringCopy.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/PerLine.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h -$(DIR_O)\ExternalLexer.obj: \ - ../src/ExternalLexer.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../include/SciLexer.h \ - ../lexlib/LexerModule.h \ - ../src/Catalogue.h \ - ../src/ExternalLexer.h -$(DIR_O)\Indicator.obj: \ - ../src/Indicator.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../src/Indicator.h \ - ../src/XPM.h -$(DIR_O)\KeyMap.obj: \ - ../src/KeyMap.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../src/KeyMap.h - -#++Autogenerated -- run scripts/LexGen.py to regenerate -#**\n\($(DIR_O)\\\*.obj: ..\\lexers\\\*.cxx $(LEX_HEADERS)\n\n\) - -$(DIR_O)\LexA68k.obj: ..\lexers\LexA68k.cxx $(LEX_HEADERS) - -$(DIR_O)\LexAbaqus.obj: ..\lexers\LexAbaqus.cxx $(LEX_HEADERS) - -$(DIR_O)\LexAda.obj: ..\lexers\LexAda.cxx $(LEX_HEADERS) - -$(DIR_O)\LexAPDL.obj: ..\lexers\LexAPDL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexAsm.obj: ..\lexers\LexAsm.cxx $(LEX_HEADERS) - -$(DIR_O)\LexAsn1.obj: ..\lexers\LexAsn1.cxx $(LEX_HEADERS) - -$(DIR_O)\LexASY.obj: ..\lexers\LexASY.cxx $(LEX_HEADERS) - -$(DIR_O)\LexAU3.obj: ..\lexers\LexAU3.cxx $(LEX_HEADERS) - -$(DIR_O)\LexAVE.obj: ..\lexers\LexAVE.cxx $(LEX_HEADERS) - -$(DIR_O)\LexAVS.obj: ..\lexers\LexAVS.cxx $(LEX_HEADERS) - -$(DIR_O)\LexBaan.obj: ..\lexers\LexBaan.cxx $(LEX_HEADERS) - -$(DIR_O)\LexBash.obj: ..\lexers\LexBash.cxx $(LEX_HEADERS) - -$(DIR_O)\LexBasic.obj: ..\lexers\LexBasic.cxx $(LEX_HEADERS) - -$(DIR_O)\LexBatch.obj: ..\lexers\LexBatch.cxx $(LEX_HEADERS) - -$(DIR_O)\LexBibTeX.obj: ..\lexers\LexBibTeX.cxx $(LEX_HEADERS) - -$(DIR_O)\LexBullant.obj: ..\lexers\LexBullant.cxx $(LEX_HEADERS) - -$(DIR_O)\LexCaml.obj: ..\lexers\LexCaml.cxx $(LEX_HEADERS) - -$(DIR_O)\LexCLW.obj: ..\lexers\LexCLW.cxx $(LEX_HEADERS) - -$(DIR_O)\LexCmake.obj: ..\lexers\LexCmake.cxx $(LEX_HEADERS) - -$(DIR_O)\LexCOBOL.obj: ..\lexers\LexCOBOL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexCoffeeScript.obj: ..\lexers\LexCoffeeScript.cxx $(LEX_HEADERS) - -$(DIR_O)\LexConf.obj: ..\lexers\LexConf.cxx $(LEX_HEADERS) - -$(DIR_O)\LexCPP.obj: ..\lexers\LexCPP.cxx $(LEX_HEADERS) - -$(DIR_O)\LexCrontab.obj: ..\lexers\LexCrontab.cxx $(LEX_HEADERS) - -$(DIR_O)\LexCsound.obj: ..\lexers\LexCsound.cxx $(LEX_HEADERS) - -$(DIR_O)\LexCSS.obj: ..\lexers\LexCSS.cxx $(LEX_HEADERS) - -$(DIR_O)\LexD.obj: ..\lexers\LexD.cxx $(LEX_HEADERS) - -$(DIR_O)\LexDiff.obj: ..\lexers\LexDiff.cxx $(LEX_HEADERS) - -$(DIR_O)\LexDMAP.obj: ..\lexers\LexDMAP.cxx $(LEX_HEADERS) - -$(DIR_O)\LexDMIS.obj: ..\lexers\LexDMIS.cxx $(LEX_HEADERS) - -$(DIR_O)\LexECL.obj: ..\lexers\LexECL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexEiffel.obj: ..\lexers\LexEiffel.cxx $(LEX_HEADERS) - -$(DIR_O)\LexErlang.obj: ..\lexers\LexErlang.cxx $(LEX_HEADERS) - -$(DIR_O)\LexErrorList.obj: ..\lexers\LexErrorList.cxx $(LEX_HEADERS) - -$(DIR_O)\LexEScript.obj: ..\lexers\LexEScript.cxx $(LEX_HEADERS) - -$(DIR_O)\LexFlagship.obj: ..\lexers\LexFlagship.cxx $(LEX_HEADERS) - -$(DIR_O)\LexForth.obj: ..\lexers\LexForth.cxx $(LEX_HEADERS) - -$(DIR_O)\LexFortran.obj: ..\lexers\LexFortran.cxx $(LEX_HEADERS) - -$(DIR_O)\LexGAP.obj: ..\lexers\LexGAP.cxx $(LEX_HEADERS) - -$(DIR_O)\LexGui4Cli.obj: ..\lexers\LexGui4Cli.cxx $(LEX_HEADERS) - -$(DIR_O)\LexHaskell.obj: ..\lexers\LexHaskell.cxx $(LEX_HEADERS) - -$(DIR_O)\LexHex.obj: ..\lexers\LexHex.cxx $(LEX_HEADERS) - -$(DIR_O)\LexHTML.obj: ..\lexers\LexHTML.cxx $(LEX_HEADERS) - -$(DIR_O)\LexInno.obj: ..\lexers\LexInno.cxx $(LEX_HEADERS) - -$(DIR_O)\LexKix.obj: ..\lexers\LexKix.cxx $(LEX_HEADERS) - -$(DIR_O)\LexKVIrc.obj: ..\lexers\LexKVIrc.cxx $(LEX_HEADERS) - -$(DIR_O)\LexLaTeX.obj: ..\lexers\LexLaTeX.cxx $(LEX_HEADERS) - -$(DIR_O)\LexLisp.obj: ..\lexers\LexLisp.cxx $(LEX_HEADERS) - -$(DIR_O)\LexLout.obj: ..\lexers\LexLout.cxx $(LEX_HEADERS) - -$(DIR_O)\LexLua.obj: ..\lexers\LexLua.cxx $(LEX_HEADERS) - -$(DIR_O)\LexMagik.obj: ..\lexers\LexMagik.cxx $(LEX_HEADERS) - -$(DIR_O)\LexMake.obj: ..\lexers\LexMake.cxx $(LEX_HEADERS) - -$(DIR_O)\LexMarkdown.obj: ..\lexers\LexMarkdown.cxx $(LEX_HEADERS) - -$(DIR_O)\LexMatlab.obj: ..\lexers\LexMatlab.cxx $(LEX_HEADERS) - -$(DIR_O)\LexMetapost.obj: ..\lexers\LexMetapost.cxx $(LEX_HEADERS) - -$(DIR_O)\LexMMIXAL.obj: ..\lexers\LexMMIXAL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexModula.obj: ..\lexers\LexModula.cxx $(LEX_HEADERS) - -$(DIR_O)\LexMPT.obj: ..\lexers\LexMPT.cxx $(LEX_HEADERS) - -$(DIR_O)\LexMSSQL.obj: ..\lexers\LexMSSQL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexMySQL.obj: ..\lexers\LexMySQL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexNimrod.obj: ..\lexers\LexNimrod.cxx $(LEX_HEADERS) - -$(DIR_O)\LexNsis.obj: ..\lexers\LexNsis.cxx $(LEX_HEADERS) - -$(DIR_O)\LexNull.obj: ..\lexers\LexNull.cxx $(LEX_HEADERS) - -$(DIR_O)\LexOpal.obj: ..\lexers\LexOpal.cxx $(LEX_HEADERS) - -$(DIR_O)\LexOScript.obj: ..\lexers\LexOScript.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPascal.obj: ..\lexers\LexPascal.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPB.obj: ..\lexers\LexPB.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPerl.obj: ..\lexers\LexPerl.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPLM.obj: ..\lexers\LexPLM.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPO.obj: ..\lexers\LexPO.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPOV.obj: ..\lexers\LexPOV.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPowerPro.obj: ..\lexers\LexPowerPro.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPowerShell.obj: ..\lexers\LexPowerShell.cxx $(LEX_HEADERS) - -$(DIR_O)\LexProgress.obj: ..\lexers\LexProgress.cxx $(LEX_HEADERS) - -$(DIR_O)\LexProps.obj: ..\lexers\LexProps.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPS.obj: ..\lexers\LexPS.cxx $(LEX_HEADERS) - -$(DIR_O)\LexPython.obj: ..\lexers\LexPython.cxx $(LEX_HEADERS) - -$(DIR_O)\LexR.obj: ..\lexers\LexR.cxx $(LEX_HEADERS) - -$(DIR_O)\LexRebol.obj: ..\lexers\LexRebol.cxx $(LEX_HEADERS) - -$(DIR_O)\LexRegistry.obj: ..\lexers\LexRegistry.cxx $(LEX_HEADERS) - -$(DIR_O)\LexRuby.obj: ..\lexers\LexRuby.cxx $(LEX_HEADERS) - -$(DIR_O)\LexRust.obj: ..\lexers\LexRust.cxx $(LEX_HEADERS) - -$(DIR_O)\LexScriptol.obj: ..\lexers\LexScriptol.cxx $(LEX_HEADERS) - -$(DIR_O)\LexSmalltalk.obj: ..\lexers\LexSmalltalk.cxx $(LEX_HEADERS) - -$(DIR_O)\LexSML.obj: ..\lexers\LexSML.cxx $(LEX_HEADERS) - -$(DIR_O)\LexSorcus.obj: ..\lexers\LexSorcus.cxx $(LEX_HEADERS) - -$(DIR_O)\LexSpecman.obj: ..\lexers\LexSpecman.cxx $(LEX_HEADERS) - -$(DIR_O)\LexSpice.obj: ..\lexers\LexSpice.cxx $(LEX_HEADERS) - -$(DIR_O)\LexSQL.obj: ..\lexers\LexSQL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexSTTXT.obj: ..\lexers\LexSTTXT.cxx $(LEX_HEADERS) - -$(DIR_O)\LexTACL.obj: ..\lexers\LexTACL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexTADS3.obj: ..\lexers\LexTADS3.cxx $(LEX_HEADERS) - -$(DIR_O)\LexTAL.obj: ..\lexers\LexTAL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexTCL.obj: ..\lexers\LexTCL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexTCMD.obj: ..\lexers\LexTCMD.cxx $(LEX_HEADERS) - -$(DIR_O)\LexTeX.obj: ..\lexers\LexTeX.cxx $(LEX_HEADERS) - -$(DIR_O)\LexTxt2tags.obj: ..\lexers\LexTxt2tags.cxx $(LEX_HEADERS) - -$(DIR_O)\LexVB.obj: ..\lexers\LexVB.cxx $(LEX_HEADERS) - -$(DIR_O)\LexVerilog.obj: ..\lexers\LexVerilog.cxx $(LEX_HEADERS) - -$(DIR_O)\LexVHDL.obj: ..\lexers\LexVHDL.cxx $(LEX_HEADERS) - -$(DIR_O)\LexVisualProlog.obj: ..\lexers\LexVisualProlog.cxx $(LEX_HEADERS) - -$(DIR_O)\LexYAML.obj: ..\lexers\LexYAML.cxx $(LEX_HEADERS) - - -#--Autogenerated -- end of automatically generated section - -$(DIR_O)\LexerBase.obj: \ - ../lexlib/LexerBase.cxx \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h \ - ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h \ - ../lexlib/LexerModule.h \ - ../lexlib/LexerBase.h -$(DIR_O)\LexerModule.obj: \ - ../lexlib/LexerModule.cxx \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h \ - ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h \ - ../lexlib/LexerModule.h \ - ../lexlib/LexerBase.h \ - ../lexlib/LexerSimple.h -$(DIR_O)\LexerNoExceptions.obj: \ - ../lexlib/LexerNoExceptions.cxx \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h \ - ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h \ - ../lexlib/LexerModule.h \ - ../lexlib/LexerBase.h \ - ../lexlib/LexerNoExceptions.h -$(DIR_O)\LexerSimple.obj: \ - ../lexlib/LexerSimple.cxx \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../include/SciLexer.h \ - ../lexlib/PropSetSimple.h \ - ../lexlib/WordList.h \ - ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h \ - ../lexlib/LexerModule.h \ - ../lexlib/LexerBase.h \ - ../lexlib/LexerSimple.h -$(DIR_O)\LineMarker.obj: \ - ../src/LineMarker.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../lexlib/StringCopy.h \ - ../src/XPM.h \ - ../src/LineMarker.h -$(DIR_O)\MarginView.obj: \ - ../src/MarginView.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/StringCopy.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h -$(DIR_O)\PerLine.obj: \ - ../src/PerLine.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/CellBuffer.h \ - ../src/PerLine.h -$(DIR_O)\PlatWin.obj: \ - PlatWin.cxx \ - ../include/Platform.h \ - ../lexlib/StringCopy.h \ - ../src/XPM.h \ - ../src/UniConversion.h \ - ../src/FontQuality.h -$(DIR_O)\PositionCache.obj: \ - ../src/PositionCache.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h -$(DIR_O)\PropSetSimple.obj: \ - ../lexlib/PropSetSimple.cxx \ - ../lexlib/PropSetSimple.h -$(DIR_O)\RESearch.obj: \ - ../src/RESearch.cxx \ - ../src/Position.h \ - ../src/CharClassify.h \ - ../src/RESearch.h -$(DIR_O)\RunStyles.obj: \ - ../src/RunStyles.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h -$(DIR_O)\ScintillaBase.obj: \ - ../src/ScintillaBase.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/PropSetSimple.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/CallTip.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h \ - ../src/Editor.h \ - ../src/AutoComplete.h \ - ../src/ScintillaBase.h -$(DIR_O)\ScintillaBaseL.obj: \ - ../src/ScintillaBase.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/PropSetSimple.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/CallTip.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h \ - ../src/Editor.h \ - ../src/AutoComplete.h \ - ../src/ScintillaBase.h -$(DIR_O)\ScintillaWin.obj: \ - ScintillaWin.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/StringCopy.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/CallTip.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/CaseConvert.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h \ - ../src/Editor.h \ - ../src/AutoComplete.h \ - ../src/ScintillaBase.h \ - PlatWin.h \ - HanjaDic.h -$(DIR_O)\ScintillaWinL.obj: \ - ScintillaWin.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/StringCopy.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/CallTip.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/CaseConvert.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h \ - ../src/Editor.h \ - ../src/AutoComplete.h \ - ../src/ScintillaBase.h \ - PlatWin.h \ - HanjaDic.h -$(DIR_O)\ScintillaWinS.obj: \ - ScintillaWin.cxx \ - ../include/Platform.h \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../include/Scintilla.h \ - ../lexlib/StringCopy.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/CallTip.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/CaseConvert.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h \ - ../src/Editor.h \ - ../src/AutoComplete.h \ - ../src/ScintillaBase.h \ - PlatWin.h \ - HanjaDic.h -$(DIR_O)\Selection.obj: \ - ../src/Selection.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../src/Position.h \ - ../src/Selection.h -$(DIR_O)\Style.obj: \ - ../src/Style.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../src/Style.h -$(DIR_O)\StyleContext.obj: \ - ../lexlib/StyleContext.cxx \ - ../include/ILexer.h \ - ../include/Sci_Position.h \ - ../lexlib/LexAccessor.h \ - ../lexlib/Accessor.h \ - ../lexlib/StyleContext.h -$(DIR_O)\UniConversion.obj: \ - ../src/UniConversion.cxx \ - ../src/UniConversion.h -$(DIR_O)\ViewStyle.obj: \ - ../src/ViewStyle.cxx \ - ../include/Platform.h \ - ../include/Scintilla.h \ - ../include/Sci_Position.h \ - ../src/Position.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/Indicator.h \ - ../src/XPM.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h -$(DIR_O)\WordList.obj: \ - ../lexlib/WordList.cxx \ - ../lexlib/StringCopy.h \ - ../lexlib/WordList.h -$(DIR_O)\XPM.obj: \ - ../src/XPM.cxx \ - ../include/Platform.h \ - ../src/XPM.h -$(DIR_O)\HanjaDic: \ - HanjaDic.cxx \ - ../src/UniConversion.h \ - HanjaDic.h diff --git a/dep/scintillua/CMakeLists.txt b/dep/scintillua/CMakeLists.txt deleted file mode 100644 index 3b9a1069..00000000 --- a/dep/scintillua/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(SCINTILLUA_DIR scintillua-3.6.0) - -set(SCINTILLUA_LEXERS_DIR - ${CMAKE_CURRENT_SOURCE_DIR}/${SCINTILLUA_DIR}/lexers CACHE INTERNAL "" -) diff --git a/dep/scintillua/scintillua-3.6.0/.hg_archival.txt b/dep/scintillua/scintillua-3.6.0/.hg_archival.txt deleted file mode 100644 index c9dcf5df..00000000 --- a/dep/scintillua/scintillua-3.6.0/.hg_archival.txt +++ /dev/null @@ -1,5 +0,0 @@ -repo: 6ae31e000a3d5f03dfa50c585a2007e2422cdca9 -node: bd33edcbf0833157c55fa1906b3ea13a3dc62550 -branch: default -latesttag: scintillua_3.5.7-1 -latesttagdistance: 5 diff --git a/dep/scintillua/scintillua-3.6.0/.hgtags b/dep/scintillua/scintillua-3.6.0/.hgtags deleted file mode 100644 index 2dfbefff..00000000 --- a/dep/scintillua/scintillua-3.6.0/.hgtags +++ /dev/null @@ -1,30 +0,0 @@ -413d31a86b1a3b9fd30b64160281b0a005b29b9f scintillua201-1 -aa32ec533f486951d37c5ce1e1d72813049f34e3 scintillua222-1 -e4c04769a0cae3a4ecc12bb1bf2377f04b335807 scintillua223-1 -7010c5af540ef3f84513a08eb5ed3e0be4df998a scintillua224-1 -fd5f095a410862369676d17c5920c35e8517396c scintillua225-1 -eb4d33afc6480fe55d799f52b065333163b824a7 scintillua226-1 -554c9360594e9912ee7fb89fa931868e9855fe37 scintillua227-1 -1752c9d1c4d10b154dc18cc8fbf4846e7415b07d scintillua229-1 -45272d49b1098168fa8542c387e1f012c2956f5e scintillua3.0.2-1 -1c76d9c5bb2fa8a0d3c0e0715369f60f5316c427 scintillua3.0.3-1 -0b66d43df96baddcd2823e15b14bf19c72a29aa8 scintillua3.0.4-1 -9917cc0b90394934fe7095eb43295b597a2c278a scintillua3.1.0-1 -b38065bfc421bd0ae51899046946c6a039758ab5 scintillua3.2.0-1 -3f62cfd3cf48ce165578867ae1091ee7d726c65b scintillua3.2.1-1 -9b08ae35a875f1d3f614c313c95aaf5e3cca3d48 scintillua3.2.2-1 -ad0fa70df31b8db25d8913fc5882b33bd6398e79 scintillua3.2.3-1 -7cce4bc41314d2a93ddf34f7bd2aa0565520b251 scintillua3.2.4-1 -3219a4bd5965877547697eebd86ed4b787257cfa scintillua3.3.0-1 -e1ef73bf140578281611edd20371f4020f58fbd2 scintillua3.3.2-1 -e4687008bad2fe48926e9c0a0784c1c923ba2cf0 scintillua3.3.7-1 -660cf02ef838089124cdeae97e34c1906762bcbd scintillua3.3.9-1 -5aedcd8bfe5ff4472548d6c7a844ddb028c149c3 scintillua_3.4.4-1 -758492493171d9be44888ed67b9f6425afa29337 scintillua_3.5.0-1 -c7521631ebece938b3437346db2af53899e4cdb5 scintillua_3.5.1-1 -0db7907df9e49101639ec62cf1ebfcc114036897 scintillua_3.5.2-1 -8e023d82f07ac0ccf2a6d4283ad1190c6320a634 scintillua_3.5.3-1 -37d50d6447d183d9d6812d5fc8a7f1bc828f5077 scintillua_3.5.4-1 -cc3cac1b91fd960a16177e9ebb191bd7fdd73636 scintillua_3.5.5-1 -7d75d1442f6ca3ba33c44a07118fc822118952bf scintillua_3.5.6-1 -14dea178ae619d3dce5c1e4346badd08b5080997 scintillua_3.5.7-1 diff --git a/dep/scintillua/scintillua-3.6.0/CHANGELOG.md b/dep/scintillua/scintillua-3.6.0/CHANGELOG.md deleted file mode 100644 index 448ebad5..00000000 --- a/dep/scintillua/scintillua-3.6.0/CHANGELOG.md +++ /dev/null @@ -1,821 +0,0 @@ -# Changelog - -[Atom Feed][] - -[Atom Feed]: feed - -## 3.6.0-1 (03 Aug 2015) - -Download: - -* [Scintillua 3.6.0-1][] - -Bugfixes: - -* None. - -Changes: - -* Improved performance in some scripting-language lexers. -* Updated Python lexer. -* Updated to [Scintilla][]/[SciTE][] 3.6.0. - -[Scintillua 3.6.0-1]: download/scintillua_3.6.0-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.5.7-1 (23 Jun 2015) - -Download: - -* [Scintillua 3.5.7-1][] - -Bugfixes: - -* None. - -Changes: - -* Added Windows Script File lexer. -* Updated to [Scintilla][]/[SciTE][] 3.5.7. - -[Scintillua 3.5.7-1]: download/scintillua_3.5.7-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.5.6-1 (26 May 2015) - -Download: - -* [Scintillua 3.5.6-1][] - -Bugfixes: - -* Fixed ASP, Applescript, and Perl lexers. -* Fixed segfault in parsing some instances of style definitions. - -Changes: - -* Added Elixir lexer. -* Updated to [Scintilla][]/[SciTE][] 3.5.6. - -[Scintillua 3.5.6-1]: download/scintillua_3.5.6-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.5.5-1 (18 Apr 2015) - -Download: - -* [Scintillua 3.5.5-1][] - -Bugfixes: - -* Fixed Perl lexer corner-case. -* VB lexer keywords are case-insensitive now. - -Changes: - -* Renamed Nimrod lexer to Nim. -* Added Rust lexer. -* Added TOML lexer. -* Lexers that fold by indentation should make use of [`_FOLDBYINDENTATION`][] - field now. -* Added PowerShell lexer. -* Updated to [Scintilla][]/[SciTE][] 3.5.5. - -[Scintillua 3.5.5-1]: download/scintillua_3.5.5-1.zip -[`_FOLDBYINDENTATION`]: api.html#lexer.Fold.by.Indentation -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.5.4-1 (09 Mar 2015) - -Download: - -* [Scintillua 3.5.4-1][] - -Bugfixes: - -* Improved `fold.by.indentation`. - -Changes: - -* Updated PHP and Python lexers. -* Added Fish lexer. -* Removed extinct B lexer. -* Updated to [LPeg][] 0.12.2. -* Updated to [Scintilla][]/[SciTE][] 3.5.4. - -[Scintillua 3.5.4-1]: download/scintillua_3.5.4-1.zip -[LPeg]: http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.5.3-1 (20 Jan 2015) - -Download: - -* [Scintillua 3.5.3-1][] - -Bugfixes: - -* Fixed bug in overwriting fold levels set by custom fold functions. - -Changes: - -* Added vCard and Texinfo lexers. -* Updates to allow Scintillua to be compiled against Lua 5.3. -* Updated Lua lexer for Lua 5.3. -* Updated to [Scintilla][]/[SciTE][] 3.5.3. - -[Scintillua 3.5.3-1]: download/scintillua_3.5.3-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.5.2-1 (10 Dec 2014) - -Download: - -* [Scintillua 3.5.2-1][] - -Bugfixes: - -* Improved folding by indentation. - -Changes: - -* Updated Tcl lexer. -* Added `fold.on.zero.sum.line` property for folding on `} else {`-style lines. -* Updated to [Scintilla][]/[SciTE][] 3.5.2. - -[Scintillua 3.5.2-1]: download/scintillua_3.5.2-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.5.1-1 (01 Oct 2014) - -Download: - -* [Scintillua 3.5.1-1][] - -Bugfixes: - -* None. - -Changes: - -* Added Xtend lexer. -* Improved performance for lexers with no grammars and no fold rules. -* Updated to [Scintilla][]/[SciTE][] 3.5.1. - -[Scintillua 3.5.1-1]: download/scintillua_3.5.1-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.5.0-1 (01 Sep 2014) - -Download: - -* [Scintillua 3.5.0-1][] - -Bugfixes: - -* None. - -Changes: - -* Updated to [LPeg][] 0.12. -* Updated to [Scintilla][]/[SciTE][] 3.5.0. - -[Scintillua 3.5.0-1]: download/scintillua_3.5.0-1.zip -[LPeg]: http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.4.4-1 (04 Jul 2014) - -Download: - -* [Scintillua 3.4.4-1][] - -Bugfixes: - -* Fixed cases of incorrect Markdown header highlighting. -* Fixed some folding by indentation edge cases. -* Fixed `#RRGGBB` color interpretation for styles. -* Fixed Bash heredoc highlighting. - -Changes: - -* Added reST and YAML lexers. -* Updated D lexer. -* Updated to [Scintilla][]/[SciTE][] 3.4.4. - -[Scintillua 3.4.4-1]: download/scintillua_3.4.4-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 3.3.9-1 (05 Feb 2014) - -Download: - -* [Scintillua 3.3.9-1][] - -Bugfixes: - -* None. - -Changes: - -* Updated HTML, LaTeX, and Go lexers. -* Enable Scintillua to be used as a stand-alone [Lua library][]. -* Scintillua can accept and use [external Lua states][]. - -[Scintillua 3.3.9-1]: download/scintillua3.3.9-1.zip -[Lua library]: manual.html#Using.Scintillua.as.a.Lua.Library -[external Lua states]: api.html#SCI_CHANGELEXERSTATE - -## 3.3.7-1 (21 Dec 2013) - -Scintillua 3.3.7-1 is a major change from 3.3.2-1. It has a completely new -[theme implementation][] and many lexer structure and API changes. Custom lexers -and themes will need to be updated. - -Download: - -* [Scintillua 3.3.7-1][] - -Bugfixes: - -* Ensure the default style is not considered a whitespace style in - multi-language lexers. -* Fixed occasional crash when getting the lexer name in a multi-language lexer. -* Disable folding when `fold` property is `0`. -* HTML and XML lexers maintain their states better. -* Fixed slowdown in processing long lines for folding. -* Fixed slowdown with large HTML files. - -Changes: - -* Completely new [theme implementation][]; removed `lexer.style()` and - `lexer.color()` functions. -* Changed [`lexer._tokenstyles`][] to be a map instead of a list. -* Changed `lexer.get_fold_level()`, `lexer.get_indent_amount()`, - `lexer.get_property()`, and `lexer.get_style_at()` functions to be - [`lexer.fold_level`][], [`lexer.indent_amount`][], [`lexer.property`][], and - [`lexer.style_at`][] tables, respectively. -* Added [`lexer.property_int`][] and [`lexer.property_expanded`][] tables. -* Changed API for [`lexer.delimited_range()`][] and [`lexer.nested_pair()`][]. -* Only enable `fold.by.indentation` property by default in - whitespace-significant languages. -* Updated D lexer. -* Added Nimrod lexer. -* Added additional parameter to [`lexer.load()`][] to allow child lexers to be - embedded multiple times with different start/end tokens. -* Lexers do not need an "any\_char" [rule][] anymore; it is included by default. -* [Child lexers][] do not need an explicit `M._lexer = parent` declaration - anymore; it is done automatically. -* Added NASM Assembly lexer. -* Separated C/C++ lexer into ANSI C and C++ lexers. -* Added Dart lexer. -* Renamed "hypertext" and "Io" lexers to "html" and "io\_lang" internally. - -[theme implementation]: api.html#lexer.Styles.and.Styling -[Scintillua 3.3.7-1]: download/scintillua3.3.7-1.zip -[`lexer._tokenstyles`]: api.html#lexer.Token.Styles -[`lexer.fold_level`]: api.html#lexer.fold_level -[`lexer.indent_amount`]: api.html#lexer.indent_amount -[`lexer.property`]: api.html#lexer.property -[`lexer.style_at`]: api.html#lexer.style_at -[`lexer.property_int`]: api.html#lexer.property_int -[`lexer.property_expanded`]: api.html#lexer.property_expanded -[`lexer.delimited_range()`]: api.html#lexer.delimited_range -[`lexer.nested_pair()`]: api.html#lexer.nested_pair -[`lexer.load()`]: api.html#lexer.load -[rule]: api.html#lexer.Rules -[Child lexers]: api.html#lexer.Child.Lexer - -## 3.3.2-1 (25 May 2013) - -Download: - -* [Scintillua 3.3.2-1][] - -Bugfixes: - -* None. - -Changes: - -* No need for '!' in front of font faces in GTK anymore. -* Scintillua supports multiple curses platforms, not just ncurses. -* [SCI\_GETLEXERLANGUAGE][] returns "lexer/current" for multi-lang lexers. -* Updated D lexer. - -[Scintillua 3.3.2-1]: download/scintillua3.3.2-1.zip -[SCI\_GETLEXERLANGUAGE]: api.html#SCI_GETLEXERLANGUAGE - -## 3.3.0-1 (31 Mar 2013) - -Download: - -* [Scintillua 3.3.0-1][] - -Bugfixes: - -* Fixed crash when attempting to load a non-existant lexer. -* Fixed CSS preprocessor styling. - -Changes: - -* Added Less, Literal Coffeescript, and Sass lexers. - -[Scintillua 3.3.0-1]: download/scintillua3.3.0-1.zip - -## 3.2.4-1 (18 Jan 2013) - -Download: - -* [Scintillua 3.2.4-1][] - -Bugfixes: - -* Fixed some operators in Bash lexer. - -Changes: - -* Rewrote Makefile lexer. -* Rewrote documentation. -* Improved speed and memory usage of lexers. - -[Scintillua 3.2.4-1]: download/scintillua3.2.4-1.zip - -## 3.2.3-1 (22 Oct 2012) - -Download: - -* [Scintillua 3.2.3-1][] - -Bugfixes: - -* Include `_` as identifier char in Desktop lexer. - -Changes: - -* Copied `container` lexer to a new `text` lexer for containers that prefer to - use the latter. -* Added SciTE usage note on themes. - -[Scintillua 3.2.3-1]: download/scintillua3.2.3-1.zip - -## 3.2.2-1 (31 Aug 2012) - -Download: - -* [Scintillua 3.2.2-1][] - -Bugfixes: - -* Fixed bug with `$$` variables in Perl lexer. - -Changes: - -* Added support for ncurses via [scinterm][]. -* Added `__DATA__` and `__END__` markers to Perl lexer. -* Added new [`lexer.last_char_includes()`][] function for better regex - detection. -* Updated AWK lexer. - -[Scintillua 3.2.2-1]: download/scintillua3.2.2-1.zip -[scinterm]: http://foicica.com/scinterm -[`lexer.last_char_includes()`]: api.html#lexer.last_char_includes - -## 3.2.1-1 (15 Jul 2012) - -Download: - -* [Scintillua 3.2.1-1][] - -Bugfixes: - -* None. - -Changes: - -* Updated AWK lexer. -* Updated HTML lexer to recognize HTML5 'script' and 'style' tags. - -[Scintillua 3.2.1-1]: download/scintillua3.2.1-1.zip - -## 3.2.0-1 (01 Jun 2012) - -Download: - -* [Scintillua 3.2.0-1][] - -Bugfixes: - -* Fixed bug with SciTE italic and underlined style properties. - -Changes: - -* Identify more file extensions. -* Updated Batch lexer. - -[Scintillua 3.2.0-1]: download/scintillua3.2.0-1.zip - -## 3.1.0-1 (23 Apr 2012) - -Download: - -* [Scintillua 3.1.0-1][] - -Bugfixes: - -* Fixed bug with Python lexer identification in SciTE. - -Changes: - -* Improved the speed of simple code folding. -* Check for lexer grammar before lexing. - -[Scintillua 3.1.0-1]: download/scintillua3.1.0-1.zip - -## 3.0.4-1 (11 Mar 2012) - -Download: - -* [Scintillua 3.0.4-1][] - -Bugfixes: - -* None. - -Changes: - -* Allow container styling. -* Updated VB and VBScript lexers. -* All new documentation in the `doc/` directory. - -[Scintillua 3.0.4-1]: download/scintillua3.0.4-1.zip - -## 3.0.3-1 (28 Jan 2012) - -Download: - -* [Scintillua 3.0.3-1][] - -Bugfixes: - -* Fixed bug in Matlab lexer for operators. - -Changes: - -* Removed unused Apache conf lexer. -* Updated D lexer. -* Added ChucK lexer. - -[Scintillua 3.0.3-1]: download/scintillua3.0.3-1.zip - -## 3.0.2-1 (08 Dec 2011) - -Download: - -* [Scintillua 3.0.2-1][] - -Bugfixes: - -* Detect and use Scala lexer. -* Fixed bug with folding line comments. -* Fixed multi-line delimited and token strings in D lexer. -* Detect and use XML lexer. -* Fixed highlighting of variables in Bash. - -Changes: - -* Added `l.REGEX` and `l.LABEL` [tokens][]. -* All lexer `_tokenstyles` tables use standard styles. -* Removed `l.style_char` style. -* All new light and dark themes. -* Added Lua libraries and library functions to Lua lexer. -* Updated lexers and [API documentation][] to [Lua 5.2][]. - -[Scintillua 3.0.2-1]: download/scintillua3.0.2-1.zip -[tokens]: api.html#lexer.Tokens -[API documentation]: api.html#lexer -[Lua 5.2]: http://www.lua.org/manual/5.2/ - -## 3.0.0-1 (01 Nov 2011) - -Download: - -* [Scintillua 3.0.0-1][] - -Bugfixes: - -* None. - -Changes: - -* None. - -[Scintillua 3.0.0-1]: download/scintillua3.0.0-1.zip - -## 2.29-1 (19 Sep 2011) - -Download: - -* [Scintillua 2.29-1][] - -Bugfixes: - -* Fixed Lua long comment folding bug. -* Fixed a segfault when `props` is `null` (C++ containers). -* Fixed Markdown lexer styles. -* Fixed bug in folding single HTML/XML tags. -* Fixed some general bugs in folding. -* Fixed Scala symbol highlighting. - -Changes: - -* Updated Coffeescript lexer. -* Added HTML5 data attributes to HTML lexer. -* Multiple single-line comments can be folded with the `fold.line.comments` - property set to 1. -* Added ConTeXt lexer. -* Updated LaTeX and TeX lexers. -* Added `l.style_embedded` to `themes/scite.lua` theme. - -[Scintillua 2.29-1]: download/scintillua229-1.zip - -## 2.27-1 (20 Jun 2011) - -Download: - -* [Scintillua 2.27-1][] - -Bugfixes: - -* Colors are now styled correctly in the Properties lexer. - -Changes: - -* Added Scala lexer. - -[Scintillua 2.27-1]: download/scintillua227-1.zip - -## 2.26-1 (10 Jun 2011) - -Download: - -* [Scintillua 2.26-1][] - -Bugfixes: - -* Fixed bug in `fold.by.indentation`. - -Changes: - -* [`get_style_at()`][] returns a string, not an integer. -* Added regex support for Coffeescript lexer. -* Embed Coffeescript lexer in HTML lexer. -* Writing custom folding for lexers is much [easier][] now. -* Added native folding for more than 60% of existing lexers. The rest still use - folding by indentation by default. - -[Scintillua 2.26-1]: download/scintillua226-1.zip -[`get_style_at()`]: api.html#lexer.style_at -[easier]: api.html#lexer.Code.Folding - -## 2.25-1 (20 Mar 2011) - -Download: - -* [Scintillua 2.25-1][] - -Bugfixes: - -* LPeg lexer restores properly for SciTE. -* Fixed bug with nested embedded lexers. -* Re-init immediately upon setting `lexer.name` property. - -Changes: - -* Added primitive classes as types in Java lexer. -* Updated BibTeX lexer. -* Added Ruby on Rails lexer, use it instead of Ruby lexer in RHTML lexer. -* Updated `lpeg.properties` file with SciTE changes. - -[Scintillua 2.25-1]: download/scintillua225-1.zip - -## 2.24-1 (03 Feb 2011) - -Download: - -* [Scintillua 2.24-1][] - -Bugfixes: - -* Fixed comment bug in CAML lexer. - -Changes: - -* Added Markdown, BibTeX, CMake, CUDA, Desktop Entry, F#, GLSL, and Nemerle - lexers. -* HTML lexer is more flexible. -* Update Lua functions and constants to Lua 5.1. - -[Scintillua 2.24-1]: download/scintillua224-1.zip - -## 2.23-1 (07 Dec 2010) - -Download: - -* [Scintillua 2.23-1][] - -Bugfixes: - -* Fixed bug in Tcl lexer with comments. - -Changes: - -* Renamed `MAC` flag to `OSX`. -* Removed unused Errorlist and Maxima lexers. - -[Scintillua 2.23-1]: download/scintillua223-1.zip - -## 2.22-1 (27 Oct 2010) - -Download: - -* [Scintillua 2.22-1][] - -Bugfixes: - -* Comments do not need to begin the line in Properties lexer. -* Fixed bug caused by not properly resetting styles. - -Changes: - -* Added coffeescript lexer. -* Updated D and Java lexers. -* Multi-language lexers are as fast as single language lexers. -* Added JSP lexer. -* Updated XML lexer. -* Scintillua can be dropped into a [SciTE][] install. - -[Scintillua 2.22-1]: download/scintillua222-1.zip -[SciTE]: http://scintilla.org/SciTE.html - -## 2.22-pre-1 (13 Sep 2010) - -Download: - -* [Scintillua 2.22-pre-1][] - -Bugfixes: - -* Do not crash if LexLPeg properties are not set correctly. - -Changes: - -* No need to modify parent `_RULES` from child lexer. -* Renamed `lexers/ocaml.lua` to `lexers/caml.lua` and `lexers/postscript.lua` to - `lexers/ps.lua` to conform to Scintilla names. - -[Scintillua 2.22-pre-1]: download/scintillua222-pre-1.zip - -## 2.21-1 (01 Sep 2010) - -Bugfixes: - -* Handle strings properly in Groovy and Vala lexers. - -Changes: - -* `LexLPeg.cxx` can be compiled as an external lexer. - -## 2.20-1 (17 Aug 2010) - -Download: - -* [Scintillua 2.20-1][] - -Bugfixes: - -* Fixed bug with child's main lexer not having a `_tokenstyles` table. - -Changes: - -* Added Gtkrc, Prolog, and Go lexers. -* CSS lexer is more flexible. -* Diff lexer is more accurate. -* Updated TeX lexer. -* Only highlight C/C++ preprocessor words, not the whole line. -* Updated to [Scintilla][]/[SciTE][] 2.20. - -[Scintillua 2.20-1]: download/scintillua220-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 2.12-1 (15 Jun 2010) - -Download: - -* [Scintillua 2.12-1][] - -Bugfixes: - -* Differentiate between division and regex in Javascript lexer. - -Changes: - -* Added `enum` keyword to Java lexer. -* Updated D lexer. -* Updated to [Scintilla][]/[SciTE][] 2.12. - -[Scintillua 2.12-1]: download/scintillua212-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 2.11-1 (30 Apr 2010) - -Download: - -* [Scintillua 2.11-1][] - -Bugfixes: - -* Fixed bug in multi-language lexer detection. -* Close `lua_State` on lexer load error. -* Fixed bug with style metatables. -* Fixed bug with XML namespaces. -* Added Java annotations to Java lexer. - -Changes: - -* Updated Haskell lexer. -* Added Matlab/Octave lexer. -* Improve speed by using `SCI_GETCHARACTERPOINTER` instead of copying strings. -* Updated D lexer. -* Renamed `lexers/b.lua` to `lexers/b_lang.lua`and `lexers/r.lua` to - `lexers/rstats.lua`. -* Allow multiple character escape sequences. -* Added Inform lexer. -* Added Lilypond and NSIS lexers. -* Updated LaTeX lexer. -* Updated to [Scintilla][]/[SciTE][] 2.11. - -[Scintillua 2.11-1]: download/scintillua211-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 2.03-1 (22 Feb 2010) - -Download: - -* [Scintillua 2.03-1][] - -Bugfixes: - -* Various bugfixes. -* Fixed bug with fonts for files open on command line. - -Changes: - -* Updated to [Scintilla][]/[SciTE][] 2.03. - -[Scintillua 2.03-1]: download/scintillua203-1.zip -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 2.02-1 (26 Jan 2010) - -Download: - -* [Scintillua 2.02-1][] - -Bugfixes: - -* None. - -Changes: - -* Renamed `lexers/io.lua` to `lexers/Io.lua`. -* Rearranged tokens in various lexers for speed. -* Allow for [MinGW][] compilation on Windows. -* Call `ruby.LoadStyles()` from RHTML lexer. -* Updated to [Scintilla][]/[SciTE][] 2.02. - -[Scintillua 2.02-1]: download/scintillua202-1.zip -[MinGW]: http://mingw.org -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html - -## 2.01-1 (13 Jan 2010) - -* Initial release for [Scintilla][]/[SciTE][] 2.01. - -[Scintilla]: http://scintilla.org -[SciTE]: http://scintilla.org/SciTE.html diff --git a/dep/scintillua/scintillua-3.6.0/LexLPeg.def b/dep/scintillua/scintillua-3.6.0/LexLPeg.def deleted file mode 100644 index 0f54acba..00000000 --- a/dep/scintillua/scintillua-3.6.0/LexLPeg.def +++ /dev/null @@ -1,4 +0,0 @@ -EXPORTS - GetLexerCount - GetLexerName - GetLexerFactory diff --git a/dep/scintillua/scintillua-3.6.0/LexerList.md b/dep/scintillua/scintillua-3.6.0/LexerList.md deleted file mode 100644 index 44d6ed8b..00000000 --- a/dep/scintillua/scintillua-3.6.0/LexerList.md +++ /dev/null @@ -1,112 +0,0 @@ -# Language Lexers - -Scintillua has lexers for the languages below. Languages denoted by a `*` have -native [folders][]. For languages without native folding support, folding based -on indentation can be used if [`fold.by.indentation`][] is enabled. For SciTE, -see `lexers/lpeg.properties`. - -1. Actionscript`*` -1. Ada -1. ANTLR`*` -1. APDL`*` -1. Applescript -1. ASM`*` (NASM) -1. ASP`*` -1. AWK`*` -1. Batch`*` -1. BibTeX`*` -1. Boo -1. C`*` -1. C++`*` -1. C#`*` -1. ChucK -1. CMake`*` -1. Coffeescript -1. ConTeXt`*` -1. CSS`*` -1. CUDA`*` -1. D`*` -1. Dart`*` -1. Desktop Entry -1. Diff -1. Django`*` -1. Dot`*` -1. Eiffel`*` -1. Elixir -1. Erlang`*` -1. F# -1. Fish`*` -1. Forth -1. Fortran -1. GAP`*` -1. gettext -1. GLSL`*` -1. Gnuplot -1. Go`*` -1. Groovy`*` -1. Gtkrc`*` -1. Haskell -1. HTML`*` -1. IDL -1. Inform -1. ini -1. Io`*` -1. Java`*` -1. Javascript`*` -1. JSON`*` -1. JSP`*` -1. LaTeX`*` -1. LESS`*` -1. LilyPond -1. Lisp`*` -1. Literate Coffeescript -1. Lua`*` -1. Makefile -1. Markdown -1. MATLAB`*` -1. Nemerle`*` -1. Nim -1. NSIS -1. Objective-C`*` -1. OCaml -1. Pascal -1. Perl`*` -1. PHP`*` -1. Pike`*` -1. PKGBUILD`*` -1. Postscript -1. PowerShell`*` -1. Prolog -1. Properties -1. Python -1. R -1. REBOL`*` -1. Rexx`*` -1. ReStructuredText`*` -1. RHTML`*` -1. Ruby`*` -1. Ruby on Rails`*` -1. Rust`*` -1. Sass`*` -1. Scala`*` -1. Scheme`*` -1. Shell`*` -1. Smalltalk`*` -1. SQL -1. Tcl`*` -1. TeX`*` -1. Texinfo`*` -1. TOML -1. Vala`*` -1. VBScript -1. vCard`*` -1. Verilog`*` -1. VHDL -1. Visual Basic -1. Windows Script File`*` -1. XML`*` -1. Xtend`*` -1. YAML - -[folders]: api.html#lexer.Code.Folding -[`fold.by.indentation`]: manual.html#Using.Scintillua.with.Other.Apps diff --git a/dep/scintillua/scintillua-3.6.0/Makefile b/dep/scintillua/scintillua-3.6.0/Makefile deleted file mode 100644 index 201f3429..00000000 --- a/dep/scintillua/scintillua-3.6.0/Makefile +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright 2010-2015 Mitchell mitchell.att.foicica.com -# Make file for LexLPeg external lexer for Scintilla. - -ifeq (win, $(findstring win, $(MAKECMDGOALS))) - CC = i686-w64-mingw32-gcc - CPP = i686-w64-mingw32-g++ - plat_flag = - LUA_CFLAGS = -D_WIN32 -DWIN32 - LDFLAGS = -g -static -mwindows -s LexLPeg.def -Wl,--enable-stdcall-fixup - lexer = lexers/LexLPeg.dll - luadoc = luadoc_start.bat -else - CC = gcc -fPIC - CPP = g++ -fPIC - plat_flag = -DGTK - LUA_CFLAGS = -DLUA_USE_LINUX - LDFLAGS = -g -Wl,-soname,liblexlpeg.so.0 -Wl,-fvisibility=hidden - lexer = lexers/liblexlpeg.so - luadoc = luadoc -endif - -# Scintilla. -sci_flags = -g -pedantic $(plat_flag) -Iscintilla/include -Iscintilla/lexlib \ - -DSCI_LEXER -Wall -lex_objs = PropSetSimple.o WordList.o LexerModule.o LexerSimple.o LexerBase.o \ - Accessor.o - -# Lua. -lua_objs = lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ - lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ - lundump.o lvm.o lzio.o \ - lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o ltablib.o \ - lstrlib.o loadlib.o loslib.o linit.o -lua_lib_objs = lpcap.o lpcode.o lpprint.o lptree.o lpvm.o - -# Build. - -all: $(lexer) -win32: $(lexer) -deps: scintilla lua lua/src/lib/lpeg doc/bombay - -$(lex_objs): %.o: scintilla/lexlib/%.cxx ; $(CPP) $(sci_flags) -c $< -$(lua_objs): %.o: lua/src/%.c ; $(CC) -Os -Ilua/src $(LUA_CFLAGS) -c $< -$(lua_lib_objs): %.o: lua/src/lib/%.c ; $(CC) -Os -Ilua/src $(LUA_CFLAGS) -c $< -LexLPeg.o: LexLPeg.cxx - $(CPP) $(sci_flags) $(LUA_CFLAGS) -DLPEG_LEXER_EXTERNAL -Ilua/src -c $< -$(lexer): $(lex_objs) $(lua_objs) $(lua_lib_objs) LexLPeg.o - $(CPP) -shared $(LDFLAGS) -o $@ $^ -clean: ; rm -f *.o - -# Documentation. - -doc: manual luadoc -manual: doc/*.md *.md | doc/bombay - $| -d doc -t doc --title Scintillua $^ -luadoc: lexers/lexer.lua scintillua.luadoc - $(luadoc) -d doc -t doc --doclet doc/markdowndoc $^ -cleandoc: ; rm -rf doc/manual.html doc/api.html - -# Releases. - -ifndef NIGHTLY - basedir = scintillua_$(shell grep '^\#\#' CHANGELOG.md | head -1 | \ - cut -d ' ' -f 2) -else - basedir = scintillua_NIGHTLY_$(shell date +"%F") -endif - -$(basedir): ; hg archive $@ -X ".hg*" -release: $(basedir) - make deps doc - make -j4 - make -j4 clean - make -j4 CC=i586-mingw32msvc-gcc CPP=i586-mingw32msvc-g++ win32 - cp -r doc $< - cp lexers/*.so lexers/*.dll $ (c) 2006-2015 Mitchell mitchell.att.foicica.com <- diff --git a/dep/scintillua/scintillua-3.6.0/doc/.header.md b/dep/scintillua/scintillua-3.6.0/doc/.header.md deleted file mode 100644 index 4eb50fca..00000000 --- a/dep/scintillua/scintillua-3.6.0/doc/.header.md +++ /dev/null @@ -1,9 +0,0 @@ -# ![](images/icon.png) Scintillua - -* [Home](README.html) | -* [Download](http://foicica.com/scintillua/download) | -* [Manual](manual.html) | -* [API](api.html) | -* [Source](http://foicica.com/hg/scintillua) | -* [Stats](http://foicica.com/stats.html#Scintillua) | -* [Mailing List](http://foicica.com/lists) diff --git a/dep/scintillua/scintillua-3.6.0/doc/icon.png b/dep/scintillua/scintillua-3.6.0/doc/icon.png deleted file mode 100644 index 0e3eb8b1..00000000 Binary files a/dep/scintillua/scintillua-3.6.0/doc/icon.png and /dev/null differ diff --git a/dep/scintillua/scintillua-3.6.0/doc/images/icon.png b/dep/scintillua/scintillua-3.6.0/doc/images/icon.png deleted file mode 100644 index 143ad358..00000000 Binary files a/dep/scintillua/scintillua-3.6.0/doc/images/icon.png and /dev/null differ diff --git a/dep/scintillua/scintillua-3.6.0/doc/manual.md b/dep/scintillua/scintillua-3.6.0/doc/manual.md deleted file mode 100644 index 85b87433..00000000 --- a/dep/scintillua/scintillua-3.6.0/doc/manual.md +++ /dev/null @@ -1,211 +0,0 @@ -# Installation - -## Drop-in External Lexer - -The environments of Scintilla-based applications vary greatly, but as long as -external lexers are supported, Scintillua can be dropped into any existing -installation. - -### Using Scintillua with SciTE - -[SciTE][] is the SCIntilla based Text Editor. Scintillua can be easily dropped -into any SciTE installation of version 2.25 or higher with or without -administrative privilages. - -[SciTE]: http://scintilla.org/SciTE.html - -#### Installing for All Users - -Installing Scintillua for all users will likely require administrator -privilages. - -1. Locate your SciTE installation, typically `C:\Program Files\SciTE\` for - Windows and `/usr/share/scite/` for Linux. -2. Unpack Scintillua to a temporary directory and move the `lexers/` directory - to the root of your SciTE installation. -3. Add the following to the end of your `SciTEGlobal.properties`: - - import lexers/lpeg - -#### Installing for One User - -Installing Scintillua for one user will not require administrator privilages -provided you have access to the user's home directory. This is always the case -for the current user. - -1. Locate your home directory, typically `C:\Documents and Settings\username\` - for Windows XP, `C:\Users\username\` for Windows 7, and `/home/username/` for - Linux. This is also likely stored in your operating system's `HOME` - environment variable. -2. Unpack Scintillua to a temporary directory and move the `lexers/` directory - to the root of your home directory or any other place you would prefer. -3. Add the following to the end of your `SciTEUser.properties` on Windows or - `.SciTEUser.properties` on Linux: - - import lexers/lpeg - - but change `lexers` to the directory you put `lexers/` if not in the root of - your home directory. -4. Open Scintillua's `lexers/lpeg.properties` file for editing and change the - line: - - lexer.lpeg.home=$(SciteDefaultHome)/lexers - - to - - lexer.lpeg.home=$(SciteUserHome)/lexers - - or to wherever you preferred to put Scintillua's `lexers/` directory. -5. If you are running a 64-bit Linux operating system, you will have to rename - `lexers/liblexlpeg.x86_64.so` to `lexers/liblexlpeg.so` so the 64-bit - external lexer will be loaded. - -#### Usage Notes - -By default, SciTE will use LPeg lexers whenever possible, as indicated in -`lexers/lpeg.properties`, and fall back onto Scintilla's lexers when necessary. -If an LPeg lexer is loaded but you prefer to use the Scintilla lexer instead, -edit `lexers/lpeg.properties` by commenting out the desired lexer's -`file.pattern.lexer` and `lexer.$(file.pattern.lexer)` property lines. - -Themes are located in the `lexers/themes/` folder and set in -`lexers/lpeg.properties`. You can define the overall fonts and styles used by -LPeg lexers using themes. - -#### Troubleshooting - -If you get incorrect or no syntax highlighting, please check the following: - -1. Does the language in question have a Lua LPeg lexer in Scintillua's `lexers/` - directory? If not, you will have to [write one][]. -2. Does Scintillua's `lexers/lpeg.properties` have your language's file - extension defined? If not, add it to the `file.patterns.lexer` property. -3. Does the file extension recognized in Scintillua's `lexers/lpeg.properties` - correspond to the language in question? If not, add or re-assign it to the - appropriate Lua LPeg lexer. - -Please note file extensions are not an exact science so `lexers/lpeg.properties` -may not have the most up to date or appropriate extensions defined. Feel free -to [submit][] corrections or additions. - -Any Scintilla lexer-specific features in SciTE do not work in LPeg lexers. These -include, but are not limited to: - -* Style, keyword, and folding properties in `*.properties` files. -* Python colon matching. -* HTML/XML tag auto-completion. - -[write one]: api.html#lexer -[submit]: README.html#Contact - -### Using Scintillua with Other Apps - -In order to use Scintillua with an instance of Scintilla, the following -[Scintilla properties][] *must* be set for the external lexer after -initialization: - -* `lexer.lpeg.home` - - The directory containing the Lua LPeg lexers. For application developers, this - is the path of where you included Scintillua's `lexers/` directory in your - application's installation location. For end-users, this is where you chose to - put Scintillua's `lexers/` folder. Please see the SciTE examples above for - more information. - -[Scintilla properties]: http://scintilla.org/ScintillaDoc.html#SCI_SETPROPERTY - -The following properties are optional and may or may not be set: - -* `lexer.lpeg.color.theme` - - The color theme to use. Color themes are located in the `lexers/themes/` - directory. Currently supported themes are `light`, `dark`, and `scite`. Your - application can define colors and styles manually through Scintilla - properties. The theme files have examples. - -* `fold.by.indentation` - - For LPeg lexers that do not have a folder, if `fold.by.indentation` is set to - `1`, folding is done based on indentation level (like Python). The default is - `0`. - -* `fold.line.comments` - - If `fold.line.comments` is set to `1`, multiple, consecutive, line comments - are folded and only the top-level comment is shown. There is a small - performance penalty for large source files when this option and folding are - enabled. The default is `0`. - -* `fold.on.zero.sum.lines` - - If `fold.on.zero.sum.lines` is set to `1`, lines that contain both an ending - and starting fold point are marked as fold points. For example, the C line - `} else {` would be marked as a fold point. The default is `0`. - -### Using Scintillua as a Lua Library - -In order to use Scintillua as a Lua library, simply place the `lexers/` -directory in your Lua path (or modify Lua's `package.path` accordingly), -`require()` the library and [`load()`][] a lexer, and call that lexer's -[`lex()`][] function. Here is an example interactive Lua session doing this: - - $> lua - Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio - > lexer_path = '/home/mitchell/code/scintillua/lexers/?.lua' - > package.path = package.path..';'..lexer_path - > c = require('lexer').load('ansi_c') - > tokens = c:lex('int void main() { return 0; }') - > for i = 1, #tokens, 2 do print(tokens[i], tokens[i+1]) end - type 4 - ansi_c_whitespace 5 - type 9 - ansi_c_whitespace 10 - identifier 14 - operator 15 - operator 16 - ansi_c_whitespace 17 - operator 18 - ansi_c_whitespace 19 - keyword 25 - ansi_c_whitespace 26 - number 27 - operator 28 - ansi_c_whitespace 29 - operator 30 - -[`load()`]: api.html#lexer.load -[`lex()`]: api.html#lexer.lex - -## Compiling Scintillua with Scintilla - -For native LPeg support, developers can add the included `LexLPeg.cxx` Scintilla -lexer and download and include [Lua][] and [LPeg][] sources files to their -toolchains for compiling Scintilla. Scintillua supports both Lua 5.1 and -Lua 5.2. A sample portion of a `Makefile` with Lua 5.2 is shown below. - - # Sample Makefile portion for compiling Scintillua with Scintilla - - # ... - - SCIFLAGS = [flags used to compile Scintilla] - SCINTILLUA_LEXER = LexLPeg.o - SCINTILLUA_SRC = LexLPeg.cxx - LUAFLAGS = -Iscintillua/lua/src - LUA_OBJS = lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o \ - linit.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o \ - ltable.o ltm.o lundump.o lvm.o lzio.o \ - lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o lmathlib.o \ - loadlib.o loslib.o ltablib.o lstrlib.o \ - lpeg.o - LUA_SRCS = scintillua/lua/src/*.c scintillua/lua/src/lib/*.c - $(SCINTILLUA_LEXER): $(SCINTILLUA_SRC) - g++ $(SCIFLAGS) $(LUAFLAGS) -DLPEG_LEXER -c $< -o $@ - $(LUA_OBJS): $(LUA_SRCS) - gcc $(LUAFLAGS) $(INCLUDEDIRS) -c $^ - - # ... - - [your app]: [your dependencies] $(SCINTILLUA_LEXER) $(LUA_OBJS) - -[Lua]: http://lua.org -[LPeg]: http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html diff --git a/dep/scintillua/scintillua-3.6.0/doc/markdowndoc.lua b/dep/scintillua/scintillua-3.6.0/doc/markdowndoc.lua deleted file mode 100644 index 3ac93ad7..00000000 --- a/dep/scintillua/scintillua-3.6.0/doc/markdowndoc.lua +++ /dev/null @@ -1,229 +0,0 @@ --- Copyright 2007-2015 Mitchell mitchell.att.foicica.com. See LICENSE. - -local ipairs, type = ipairs, type -local io_open, io_popen = io.open, io.popen -local string_format, string_rep = string.format, string.rep -local table_concat = table.concat - --- Markdown doclet for Luadoc. --- Requires Discount (http://www.pell.portland.or.us/~orc/Code/discount/). --- @usage luadoc -d [output_path] -doclet path/to/markdowndoc [file(s)] -local M = {} - -local NAVFILE = '1. [%s](%s)\n' -local SCINTILLUA = '\n# %s\n\n' -local MODULE = '\n# The `%s` Module\n\n' -local FIELD = '\n### `%s` %s\n\n' -local FUNCTION = '\n### `%s` (%s)\n\n' -local DESCRIPTION = '%s\n\n' -local LIST_TITLE = '%s:\n\n' -local PARAM = '* `%s`: %s\n' -local USAGE = '* `%s`\n' -local RETURN = '* %s\n' -local SEE = '* [`%s`](#%s)\n' -local TABLE = '\n### `%s`\n\n' -local TFIELD = '* `%s`: %s\n' -local HTML = [[ - - - - %(title) - - - - - -
    - -
    -

    Scintillua API Documentation

    -

    Modules

    - %(toc) -
    - %(main) -
    - -
    - - -]] -local titles = { - [PARAM] = 'Parameters', [USAGE] = 'Usage', [RETURN] = 'Return', - [SEE] = 'See also', [TFIELD] = 'Fields' -} - --- Writes a LuaDoc description to the given file. --- @param f The markdown file being written to. --- @param description The description. --- @param name The name of the module the description belongs to. Used for --- headers in module descriptions. -local function write_description(f, description, name) - if name then - -- Add anchors for module description headers. - description = description:gsub('\n(#+%s+([^\n]+))', function(header, text) - return string_format("\n\n\n\n%s", name, - text:gsub(' ', '.'), header) - end) - end - -- Substitute custom [`code`]() link convention with [`code`](#code) links. - local self_link = '(%[`([^`(]+)%(?%)?`%])%(%)' - description = description:gsub(self_link, function(link, id) - return string_format("%s(#%s)", link, id:gsub(':', '.')) - end) - f:write(string_format(DESCRIPTION, description)) -end - --- Writes a LuaDoc list to the given file. --- @param f The markdown file being written to. --- @param fmt The format of a list item. --- @param list The LuaDoc list. --- @param name The name of the module the list belongs to. Used for @see. -local function write_list(f, fmt, list, name) - if not list or #list == 0 then return end - if type(list) == 'string' then list = {list} end - f:write(string_format(LIST_TITLE, titles[fmt])) - for _, value in ipairs(list) do - if fmt == SEE and name ~= 'Scintillua' then - -- Prepend module name to identifier if necessary. - if not value:find('%.') then value = name..'.'..value end - end - f:write(string_format(fmt, value, value)) - end - f:write('\n') -end - --- Writes a LuaDoc hashmap to the given file. --- @param f The markdown file being written to. --- @param fmt The format of a hashmap item. --- @param list The LuaDoc hashmap. -local function write_hashmap(f, fmt, hashmap) - if not hashmap or #hashmap == 0 then return end - f:write(string_format(LIST_TITLE, titles[fmt])) - for _, name in ipairs(hashmap) do - f:write(string_format(fmt, name, hashmap[name] or '')) - end - f:write('\n') -end - --- Called by LuaDoc to process a doc object. --- @param doc The LuaDoc doc object. -function M.start(doc) - local template = {title = '', header = '', toc = '', main = '', footer = ''} - local modules, files = doc.modules, doc.files - - -- Create the header and footer, if given a template. - if M.options.template_dir ~= 'luadoc/doclet/html/' then - local p = io.popen('markdown "'..M.options.template_dir..'.header.md"') - template.header = p:read('*a') - p:close() - p = io.popen('markdown "'..M.options.template_dir..'.footer.md"') - template.footer = p:read('*a') - p:close() - end - - -- Create the table of contents. - local tocfile = M.options.output_dir..'/.api_toc.md' - local f = io_open(tocfile, 'wb') - for _, name in ipairs(modules) do - f:write(string_format(NAVFILE, name, '#'..name)) - end - f:close() - local p = io_popen('markdown "'..tocfile..'"') - local toc = p:read('*a') - p:close() - os.remove(tocfile) - - -- Create a map of doc objects to file names so their Markdown doc comments - -- can be extracted. - local filedocs = {} - for _, name in ipairs(files) do filedocs[files[name].doc] = name end - - -- Loop over modules, creating Markdown documents. - local mdfile = M.options.output_dir..'/api.md' - local f = io_open(mdfile, 'wb') - for _, name in ipairs(modules) do - local module = modules[name] - local filename = filedocs[module.doc] - - -- Write the header and description. - if name == 'Scintillua' then - f:write(string_format(SCINTILLUA, name, name)) - else - f:write(string_format(MODULE, name, name)) - end - f:write('- - -\n\n') - write_description(f, module.description, name) - - -- Write fields. - if module.doc[1].class == 'module' then - local fields = module.doc[1].field - if fields and #fields > 0 then - table.sort(fields) - f:write('## Fields defined by `', name, '`\n\n') - for _, field in ipairs(fields) do - local type, description = fields[field]:match('^(%b())%s*(.+)$') - if not field:find('%.') then field = name..'.'..field end - f:write(string_format(FIELD, field, field, type or '')) - write_description(f, description or fields[field]) - end - f:write('\n') - end - end - - -- Write functions. - local funcs = module.functions - if #funcs > 0 then - f:write('## Functions defined by `', name, '`\n\n') - for _, fname in ipairs(funcs) do - local func = funcs[fname] - local params = table_concat(func.param, ', '):gsub('_', '\\_') - if name == 'Scintillua' then - f:write(string_format(FUNCTION, func.name, 'SCI_PRIVATELEXERCALL', - params)) - else - if not func.name:find('%.') then func.name = name..'.'..func.name end - f:write(string_format(FUNCTION, func.name, func.name, params)) - end - write_description(f, func.description) - write_hashmap(f, PARAM, func.param) - write_list(f, USAGE, func.usage) - write_list(f, RETURN, func.ret) - write_list(f, SEE, func.see, name) - end - f:write('\n') - end - - -- Write tables. - local tables = module.tables - if #tables > 0 then - f:write('## Tables defined by `', name, '`\n\n') - for _, tname in ipairs(tables) do - local tbl = tables[tname] - if not tbl.name:find('%.') then tbl.name = name..'.'..tbl.name end - f:write(string_format(TABLE, tbl.name, tbl.name)) - write_description(f, tbl.description) - write_hashmap(f, TFIELD, tbl.field) - write_list(f, USAGE, tbl.usage) - write_list(f, SEE, tbl.see, name) - end - end - f:write('- - -\n\n') - end - - -- Write HTML. - template.title = 'Scintillua API' - template.toc = toc - local p = io_popen('markdown "'..mdfile..'"') - template.main = p:read('*a') - p:close() - f = io_open(M.options.output_dir..'/api.html', 'wb') - local html = HTML:gsub('%%%(([^)]+)%)', template) - f:write(html) - f:close() -end - -return M diff --git a/dep/scintillua/scintillua-3.6.0/gen_lexer_props.lua b/dep/scintillua/scintillua-3.6.0/gen_lexer_props.lua deleted file mode 100755 index 4ece5a64..00000000 --- a/dep/scintillua/scintillua-3.6.0/gen_lexer_props.lua +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/lua - -local format, concat = string.format, table.concat - --- Do not glob these files. (e.g. *.foo) -local noglobs = { - GNUmakefile = true, - Makefile = true, - makefile = true, - Rakefile = true, - ['Rout.save'] = true, - ['Rout.fail'] = true, -} - -local alt_name = { - actionscript = 'flash', - ansi_c = 'c', - dmd = 'd', - javascript = 'js', - python = 'py', - rstats = 'r', - ruby = 'rb', -} - --- Process file patterns and lexer definitions from Textadept. -local f = io.open('../textadept/modules/textadept/file_types.lua') -local definitions = f:read('*all'):match('M%.extensions = (%b{})') -f:close() - -local output = {'# Lexer definitions ('} -local lexer, ext, last_lexer -local exts = {} -for ext, lexer in definitions:gmatch("([^,'%]]+)'?%]?='([%w_]+)'") do - if lexer ~= last_lexer and #exts > 0 then - local name = alt_name[last_lexer] or last_lexer - output[#output + 1] = format('file.patterns.%s=%s', name, - concat(exts, ';')) - output[#output + 1] = format('lexer.$(file.patterns.%s)=lpeg_%s', name, - last_lexer) - exts = {} - end - exts[#exts + 1] = not noglobs[ext] and '*.'..ext or ext - last_lexer = lexer -end -local name = alt_name[last_lexer] or last_lexer -output[#output + 1] = format('file.patterns.%s=%s', name, concat(exts, ';')) -output[#output + 1] = format('lexer.$(file.patterns.%s)=lpeg_%s', name, - last_lexer) -output[#output + 1] = '# )' - --- Write to lpeg.properties. -f = io.open('lexers/lpeg.properties') -local text = f:read('*all') -text = text:gsub('# Lexer definitions %b()', table.concat(output, '\n'), 1) -f:close() -f = io.open('lexers/lpeg.properties', 'wb') -f:write(text) -f:close() diff --git a/dep/scintillua/scintillua-3.6.0/lexers/actionscript.lua b/dep/scintillua/scintillua-3.6.0/lexers/actionscript.lua deleted file mode 100644 index 0aafe637..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/actionscript.lua +++ /dev/null @@ -1,75 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Actionscript LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'actionscript'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local ml_str = '')^0 * ']]>' -local string = token(l.STRING, sq_str + dq_str + ml_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * S('LlUuFf')^-2) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'break', 'continue', 'delete', 'do', 'else', 'for', 'function', 'if', 'in', - 'new', 'on', 'return', 'this', 'typeof', 'var', 'void', 'while', 'with', - 'NaN', 'Infinity', 'false', 'null', 'true', 'undefined', - -- Reserved for future use. - 'abstract', 'case', 'catch', 'class', 'const', 'debugger', 'default', - 'export', 'extends', 'final', 'finally', 'goto', 'implements', 'import', - 'instanceof', 'interface', 'native', 'package', 'private', 'Void', - 'protected', 'public', 'dynamic', 'static', 'super', 'switch', 'synchonized', - 'throw', 'throws', 'transient', 'try', 'volatile' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'Array', 'Boolean', 'Color', 'Date', 'Function', 'Key', 'MovieClip', 'Math', - 'Mouse', 'Number', 'Object', 'Selection', 'Sound', 'String', 'XML', 'XMLNode', - 'XMLSocket', - -- Reserved for future use. - 'boolean', 'byte', 'char', 'double', 'enum', 'float', 'int', 'long', 'short' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('=!<>+-/*%&|^~.,;?()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//', ''}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = { - ['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//') - }, - [l.STRING] = {[''] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/ada.lua b/dep/scintillua/scintillua-3.6.0/lexers/ada.lua deleted file mode 100644 index cbcb6513..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/ada.lua +++ /dev/null @@ -1,68 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Ada LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'ada'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '--' * l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range('"', true, true)) - --- Numbers. -local hex_num = 'O' * S('xX') * (l.xdigit + '_')^1 -local integer = l.digit^1 * ('_' * l.digit^1)^0 -local float = integer^1 * ('.' * integer^0)^-1 * S('eE') * S('+-')^-1 * integer -local number = token(l.NUMBER, hex_num + S('+-')^-1 * (float + integer) * - S('LlUuFf')^-3) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'abort', 'abs', 'accept', 'all', 'and', 'begin', 'body', 'case', 'declare', - 'delay', 'do', 'else', 'elsif', 'end', 'entry', 'exception', 'exit', 'for', - 'generic', 'goto', 'if', 'in', 'is', 'loop', 'mod', 'new', 'not', 'null', - 'or', 'others', 'out', 'protected', 'raise', 'record', 'rem', 'renames', - 'requeue', 'reverse', 'select', 'separate', 'subtype', 'task', 'terminate', - 'then', 'type', 'until', 'when', 'while', 'xor', - -- Preprocessor. - 'package', 'pragma', 'use', 'with', - -- Function - 'function', 'procedure', 'return', - -- Storage class. - 'abstract', 'access', 'aliased', 'array', 'at', 'constant', 'delta', 'digits', - 'interface', 'limited', 'of', 'private', 'range', 'tagged', 'synchronized', - -- Boolean. - 'true', 'false' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'boolean', 'character', 'count', 'duration', 'float', 'integer', 'long_float', - 'long_integer', 'priority', 'short_float', 'short_integer', 'string' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S(':;=<>&+-*/.()')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/ansi_c.lua b/dep/scintillua/scintillua-3.6.0/lexers/ansi_c.lua deleted file mode 100644 index e7e04d5e..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/ansi_c.lua +++ /dev/null @@ -1,72 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- C LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'ansi_c'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = P('L')^-1 * l.delimited_range("'", true) -local dq_str = P('L')^-1 * l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Preprocessor. -local preproc_word = word_match{ - 'define', 'elif', 'else', 'endif', 'if', 'ifdef', 'ifndef', 'include', 'line', - 'pragma', 'undef' -} -local preproc = token(l.PREPROCESSOR, - l.starts_line('#') * S('\t ')^0 * preproc_word) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'auto', 'break', 'case', 'const', 'continue', 'default', 'do', 'else', - 'extern', 'for', 'goto', 'if', 'inline', 'register', 'restrict', 'return', - 'sizeof', 'static', 'switch', 'typedef', 'volatile', 'while' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'char', 'double', 'enum', 'float', 'int', 'long', 'short', 'signed', 'struct', - 'union', 'unsigned', 'void', '_Bool', '_Complex', '_Imaginary' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>~!=^&|?~:;,.()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'preproc', preproc}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'%l+', '[{}]', '/%*', '%*/', '//'}, - [l.PREPROCESSOR] = {['if'] = 1, ifdef = 1, ifndef = 1, endif = -1}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/antlr.lua b/dep/scintillua/scintillua-3.6.0/lexers/antlr.lua deleted file mode 100644 index 7c9e4449..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/antlr.lua +++ /dev/null @@ -1,74 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- ANTLR LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'antlr'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local string = token(l.STRING, l.delimited_range("'", true)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'abstract', 'break', 'case', 'catch', 'continue', 'default', 'do', 'else', - 'extends', 'final', 'finally', 'for', 'if', 'implements', 'instanceof', - 'native', 'new', 'private', 'protected', 'public', 'return', 'static', - 'switch', 'synchronized', 'throw', 'throws', 'transient', 'try', 'volatile', - 'while', 'package', 'import', 'header', 'options', 'tokens', 'strictfp', - 'false', 'null', 'super', 'this', 'true' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'boolean', 'byte', 'char', 'class', 'double', 'float', 'int', 'interface', - 'long', 'short', 'void' -}) - --- Functions. -local func = token(l.FUNCTION, 'assert') - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('$@:;|.=+*?~!^>-()[]{}')) - --- Actions. -local action = #P('{') * operator * token('action', (1 - P('}'))^0) * - (#P('}') * operator)^-1 - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'action', action}, - {'operator', operator}, -} - -M._tokenstyles = { - action = l.STYLE_NOTHING -} - -M._foldsymbols = { - _patterns = {'[:;%(%){}]', '/%*', '%*/', '//'}, - [l.OPERATOR] = { - [':'] = 1, [';'] = -1, ['('] = 1, [')'] = -1, ['{'] = 1, ['}'] = -1 - }, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/apdl.lua b/dep/scintillua/scintillua-3.6.0/lexers/apdl.lua deleted file mode 100644 index 97d8d2cd..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/apdl.lua +++ /dev/null @@ -1,102 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- APDL LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'apdl'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '!' * l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range("'", true, true)) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - '*abbr', '*abb', '*afun', '*afu', '*ask', '*cfclos', '*cfc', '*cfopen', - '*cfo', '*cfwrite', '*cfw', '*create', '*cre', '*cycle', '*cyc', '*del', - '*dim', '*do', '*elseif', '*else', '*enddo', '*endif', '*end', '*eval', - '*eva', '*exit', '*exi', '*get', '*go', '*if', '*list', '*lis', '*mfouri', - '*mfo', '*mfun', '*mfu', '*mooney', '*moo', '*moper', '*mop', '*msg', - '*repeat', '*rep', '*set', '*status', '*sta', '*tread', '*tre', '*ulib', - '*uli', '*use', '*vabs', '*vab', '*vcol', '*vco', '*vcum', '*vcu', '*vedit', - '*ved', '*vfact', '*vfa', '*vfill', '*vfi', '*vfun', '*vfu', '*vget', '*vge', - '*vitrp', '*vit', '*vlen', '*vle', '*vmask', '*vma', '*voper', '*vop', - '*vplot', '*vpl', '*vput', '*vpu', '*vread', '*vre', '*vscfun', '*vsc', - '*vstat', '*vst', '*vwrite', '*vwr', '/anfile', '/anf', '/angle', '/ang', - '/annot', '/ann', '/anum', '/anu', '/assign', '/ass', '/auto', '/aut', - '/aux15', '/aux2', '/aux', '/axlab', '/axl', '/batch', '/bat', '/clabel', - '/cla', '/clear', '/cle', '/clog', '/clo', '/cmap', '/cma', '/color', '/col', - '/com', '/config', '/contour', '/con', '/copy', '/cop', '/cplane', '/cpl', - '/ctype', '/cty', '/cval', '/cva', '/delete', '/del', '/devdisp', '/device', - '/dev', '/dist', '/dis', '/dscale', '/dsc', '/dv3d', '/dv3', '/edge', '/edg', - '/efacet', '/efa', '/eof', '/erase', '/era', '/eshape', '/esh', '/exit', - '/exi', '/expand', '/exp', '/facet', '/fac', '/fdele', '/fde', '/filname', - '/fil', '/focus', '/foc', '/format', '/for', '/ftype', '/fty', '/gcmd', - '/gcm', '/gcolumn', '/gco', '/gfile', '/gfi', '/gformat', '/gfo', '/gline', - '/gli', '/gmarker', '/gma', '/golist', '/gol', '/gopr', '/gop', '/go', - '/graphics', '/gra', '/gresume', '/gre', '/grid', '/gri', '/gropt', '/gro', - '/grtyp', '/grt', '/gsave', '/gsa', '/gst', '/gthk', '/gth', '/gtype', '/gty', - '/header', '/hea', '/input', '/inp', '/larc', '/lar', '/light', '/lig', - '/line', '/lin', '/lspec', '/lsp', '/lsymbol', '/lsy', '/menu', '/men', - '/mplib', '/mpl', '/mrep', '/mre', '/mstart', '/mst', '/nerr', '/ner', - '/noerase', '/noe', '/nolist', '/nol', '/nopr', '/nop', '/normal', '/nor', - '/number', '/num', '/opt', '/output', '/out', '/page', '/pag', '/pbc', '/pbf', - '/pcircle', '/pci', '/pcopy', '/pco', '/plopts', '/plo', '/pmacro', '/pma', - '/pmeth', '/pme', '/pmore', '/pmo', '/pnum', '/pnu', '/polygon', '/pol', - '/post26', '/post1', '/pos', '/prep7', '/pre', '/psearch', '/pse', '/psf', - '/pspec', '/psp', '/pstatus', '/pst', '/psymb', '/psy', '/pwedge', '/pwe', - '/quit', '/qui', '/ratio', '/rat', '/rename', '/ren', '/replot', '/rep', - '/reset', '/res', '/rgb', '/runst', '/run', '/seclib', '/sec', '/seg', - '/shade', '/sha', '/showdisp', '/show', '/sho', '/shrink', '/shr', '/solu', - '/sol', '/sscale', '/ssc', '/status', '/sta', '/stitle', '/sti', '/syp', - '/sys', '/title', '/tit', '/tlabel', '/tla', '/triad', '/tri', '/trlcy', - '/trl', '/tspec', '/tsp', '/type', '/typ', '/ucmd', '/ucm', '/uis', '/ui', - '/units', '/uni', '/user', '/use', '/vcone', '/vco', '/view', '/vie', - '/vscale', '/vsc', '/vup', '/wait', '/wai', '/window', '/win', '/xrange', - '/xra', '/yrange', '/yra', '/zoom', '/zoo' -}, '*/', true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Functions. -local func = token(l.FUNCTION, l.delimited_range('%', true, true)) - --- Operators. -local operator = token(l.OPERATOR, S('+-*/$=,;()')) - --- Labels. -local label = token(l.LABEL, l.starts_line(':') * l.word) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'number', number}, - {'function', func}, - {'label', label}, - {'comment', comment}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'%*[A-Za-z]+', '!'}, - [l.KEYWORD] = { - ['*if'] = 1, ['*IF'] = 1, ['*do'] = 1, ['*DO'] = 1, ['*dowhile'] = 1, - ['*DOWHILE'] = 1, - ['*endif'] = -1, ['*ENDIF'] = -1, ['*enddo'] = -1, ['*ENDDO'] = -1 - }, - [l.COMMENT] = {['!'] = l.fold_line_comments('!')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/applescript.lua b/dep/scintillua/scintillua-3.6.0/lexers/applescript.lua deleted file mode 100644 index 08b34327..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/applescript.lua +++ /dev/null @@ -1,82 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Applescript LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'applescript'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '--' * l.nonnewline^0 -local block_comment = '(*' * (l.any - '*)')^0 * P('*)')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local string = token(l.STRING, l.delimited_range('"', true)) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'script', 'property', 'prop', 'end', 'copy', 'to', 'set', 'global', 'local', - 'on', 'to', 'of', 'in', 'given', 'with', 'without', 'return', 'continue', - 'tell', 'if', 'then', 'else', 'repeat', 'times', 'while', 'until', 'from', - 'exit', 'try', 'error', 'considering', 'ignoring', 'timeout', 'transaction', - 'my', 'get', 'put', 'into', 'is', - -- References. - 'each', 'some', 'every', 'whose', 'where', 'id', 'index', 'first', 'second', - 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', - 'last', 'front', 'back', 'st', 'nd', 'rd', 'th', 'middle', 'named', 'through', - 'thru', 'before', 'after', 'beginning', 'the', - -- Commands. - 'close', 'copy', 'count', 'delete', 'duplicate', 'exists', 'launch', 'make', - 'move', 'open', 'print', 'quit', 'reopen', 'run', 'save', 'saving', - -- Operators. - 'div', 'mod', 'and', 'not', 'or', 'as', 'contains', 'equal', 'equals', - 'isn\'t', -}, "'", true)) - --- Constants. -local constant = token(l.CONSTANT, word_match({ - 'case', 'diacriticals', 'expansion', 'hyphens', 'punctuation', - -- Predefined variables. - 'it', 'me', 'version', 'pi', 'result', 'space', 'tab', 'anything', - -- Text styles. - 'bold', 'condensed', 'expanded', 'hidden', 'italic', 'outline', 'plain', - 'shadow', 'strikethrough', 'subscript', 'superscript', 'underline', - -- Save options. - 'ask', 'no', 'yes', - -- Booleans. - 'false', 'true', - -- Date and time. - 'weekday', 'monday', 'mon', 'tuesday', 'tue', 'wednesday', 'wed', 'thursday', - 'thu', 'friday', 'fri', 'saturday', 'sat', 'sunday', 'sun', 'month', - 'january', 'jan', 'february', 'feb', 'march', 'mar', 'april', 'apr', 'may', - 'june', 'jun', 'july', 'jul', 'august', 'aug', 'september', 'sep', 'october', - 'oct', 'november', 'nov', 'december', 'dec', 'minutes', 'hours', 'days', - 'weeks' -}, nil, true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, (l.alpha + '_') * l.alnum^0) - --- Operators. -local operator = token(l.OPERATOR, S('+-^*/&<>=:,(){}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'constant', constant}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/asm.lua b/dep/scintillua/scintillua-3.6.0/lexers/asm.lua deleted file mode 100644 index 1cba511a..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/asm.lua +++ /dev/null @@ -1,476 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- NASM Assembly LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'asm'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, ';' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer * S('hqb')^-1) - --- Preprocessor. -local preproc_word = word_match{ - 'arg', 'assign', 'clear', 'define', 'defstr', 'deftok', 'depend', 'elif', - 'elifctx', 'elifdef', 'elifempty', 'elifenv', 'elifid', 'elifidn', 'elifidni', - 'elifmacro', 'elifn', 'elifnctx', 'elifndef', 'elifnempty', 'elifnenv', - 'elifnid', 'elifnidn', 'elifnidni', 'elifnmacro', 'elifnnum', 'elifnstr', - 'elifntoken', 'elifnum', 'elifstr', 'eliftoken', 'else', 'endif', 'endmacro', - 'endrep', 'endwhile', 'error', 'exitmacro', 'exitrep', 'exitwhile', 'fatal', - 'final', 'idefine', 'idefstr', 'ideftok', 'if', 'ifctx', 'ifdef', 'ifempty', - 'ifenv', 'ifid', 'ifidn', 'ifidni', 'ifmacro', 'ifn', 'ifnctx', 'ifndef', - 'ifnempty', 'ifnenv', 'ifnid', 'ifnidn', 'ifnidni', 'ifnmacro', 'ifnnum', - 'ifnstr', 'ifntoken', 'ifnum', 'ifstr', 'iftoken', 'imacro', 'include', - 'ixdefine', 'line', 'local', 'macro', 'pathsearch', 'pop', 'push', 'rep', - 'repl', 'rmacro', 'rotate', 'stacksize', 'strcat', 'strlen', 'substr', - 'undef', 'unmacro', 'use', 'warning', 'while', 'xdefine', -} -local preproc_symbol = '??' + S('!$+?') + '%' * -l.space + R('09')^1 -local preproc = token(l.PREPROCESSOR, '%' * (preproc_word + preproc_symbol)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - -- Preprocessor macros. - 'struc', 'endstruc', 'istruc', 'at', 'iend', 'align', 'alignb', 'sectalign', - '.nolist', - -- Preprocessor Packages. - --'altreg', 'smartalign', 'fp', 'ifunc' - -- Directives. - 'absolute', 'bits', 'class', 'common', 'common', 'cpu', 'default', 'export', - 'extern', 'float', 'global', 'group', 'import', 'osabi', 'overlay', 'private', - 'public', '__SECT__', 'section', 'segment', 'stack', 'use16', 'use32', - 'use64', - -- Section Names. - '.bss', '.comment', '.data', '.lbss', '.ldata', '.lrodata', '.rdata', - '.rodata', '.tbss', '.tdata', '.text', - -- Section Qualifiers. - 'alloc', 'bss', 'code', 'exec', 'data', 'noalloc', 'nobits', 'noexec', - 'nowrite', 'progbits', 'rdata', 'tls', 'write', - -- Operators. - 'abs', 'rel', 'seg', 'wrt', 'strict', - '__utf16__', '__utf16be__', '__utf16le__', '__utf32__', '__utf32be__', - '__utf32le__', -}, '.')) - --- Instructions. --- awk '{print $1}'|uniq|tr '[:upper:]' '[:lower:]'| --- lua -e "for l in io.lines() do print(\"'\"..l..\"',\") end"|fmt -w 78 -local instruction = token('instruction', word_match{ - -- Special Instructions. - 'db', 'dd', 'do', 'dq', 'dt', 'dw', 'dy', 'resb', 'resd', 'reso', 'resq', - 'rest', 'resw', 'resy', - -- Conventional Instructions. - 'aaa', 'aad', 'aam', 'aas', 'adc', 'add', 'and', 'arpl', 'bb0_reset', - 'bb1_reset', 'bound', 'bsf', 'bsr', 'bswap', 'bt', 'btc', 'btr', 'bts', - 'call', 'cbw', 'cdq', 'cdqe', 'clc', 'cld', 'cli', 'clts', 'cmc', 'cmp', - 'cmpsb', 'cmpsd', 'cmpsq', 'cmpsw', 'cmpxchg', 'cmpxchg486', 'cmpxchg8b', - 'cmpxchg16b', 'cpuid', 'cpu_read', 'cpu_write', 'cqo', 'cwd', 'cwde', 'daa', - 'das', 'dec', 'div', 'dmint', 'emms', 'enter', 'equ', 'f2xm1', 'fabs', - 'fadd', 'faddp', 'fbld', 'fbstp', 'fchs', 'fclex', 'fcmovb', 'fcmovbe', - 'fcmove', 'fcmovnb', 'fcmovnbe', 'fcmovne', 'fcmovnu', 'fcmovu', 'fcom', - 'fcomi', 'fcomip', 'fcomp', 'fcompp', 'fcos', 'fdecstp', 'fdisi', 'fdiv', - 'fdivp', 'fdivr', 'fdivrp', 'femms', 'feni', 'ffree', 'ffreep', 'fiadd', - 'ficom', 'ficomp', 'fidiv', 'fidivr', 'fild', 'fimul', 'fincstp', 'finit', - 'fist', 'fistp', 'fisttp', 'fisub', 'fisubr', 'fld', 'fld1', 'fldcw', - 'fldenv', 'fldl2e', 'fldl2t', 'fldlg2', 'fldln2', 'fldpi', 'fldz', 'fmul', - 'fmulp', 'fnclex', 'fndisi', 'fneni', 'fninit', 'fnop', 'fnsave', 'fnstcw', - 'fnstenv', 'fnstsw', 'fpatan', 'fprem', 'fprem1', 'fptan', 'frndint', - 'frstor', 'fsave', 'fscale', 'fsetpm', 'fsin', 'fsincos', 'fsqrt', - 'fst', 'fstcw', 'fstenv', 'fstp', 'fstsw', 'fsub', 'fsubp', 'fsubr', - 'fsubrp', 'ftst', 'fucom', 'fucomi', 'fucomip', 'fucomp', 'fucompp', - 'fxam', 'fxch', 'fxtract', 'fyl2x', 'fyl2xp1', 'hlt', 'ibts', 'icebp', - 'idiv', 'imul', 'in', 'inc', 'incbin', 'insb', 'insd', 'insw', 'int', - 'int01', 'int1', 'int03', 'int3', 'into', 'invd', 'invpcid', 'invlpg', - 'invlpga', 'iret', 'iretd', 'iretq', 'iretw', 'jcxz', 'jecxz', 'jrcxz', - 'jmp', 'jmpe', 'lahf', 'lar', 'lds', 'lea', 'leave', 'les', 'lfence', - 'lfs', 'lgdt', 'lgs', 'lidt', 'lldt', 'lmsw', 'loadall', 'loadall286', - 'lodsb', 'lodsd', 'lodsq', 'lodsw', 'loop', 'loope', 'loopne', 'loopnz', - 'loopz', 'lsl', 'lss', 'ltr', 'mfence', 'monitor', 'mov', 'movd', 'movq', - 'movsb', 'movsd', 'movsq', 'movsw', 'movsx', 'movsxd', 'movsx', 'movzx', - 'mul', 'mwait', 'neg', 'nop', 'not', 'or', 'out', 'outsb', 'outsd', 'outsw', - 'packssdw', 'packsswb', 'packuswb', 'paddb', 'paddd', 'paddsb', 'paddsiw', - 'paddsw', 'paddusb', 'paddusw', 'paddw', 'pand', 'pandn', 'pause', 'paveb', - 'pavgusb', 'pcmpeqb', 'pcmpeqd', 'pcmpeqw', 'pcmpgtb', 'pcmpgtd', 'pcmpgtw', - 'pdistib', 'pf2id', 'pfacc', 'pfadd', 'pfcmpeq', 'pfcmpge', 'pfcmpgt', - 'pfmax', 'pfmin', 'pfmul', 'pfrcp', 'pfrcpit1', 'pfrcpit2', 'pfrsqit1', - 'pfrsqrt', 'pfsub', 'pfsubr', 'pi2fd', 'pmachriw', 'pmaddwd', 'pmagw', - 'pmulhriw', 'pmulhrwa', 'pmulhrwc', 'pmulhw', 'pmullw', 'pmvgezb', 'pmvlzb', - 'pmvnzb', 'pmvzb', 'pop', 'popa', 'popad', 'popaw', 'popf', 'popfd', - 'popfq', 'popfw', 'por', 'prefetch', 'prefetchw', 'pslld', 'psllq', - 'psllw', 'psrad', 'psraw', 'psrld', 'psrlq', 'psrlw', 'psubb', 'psubd', - 'psubsb', 'psubsiw', 'psubsw', 'psubusb', 'psubusw', 'psubw', 'punpckhbw', - 'punpckhdq', 'punpckhwd', 'punpcklbw', 'punpckldq', 'punpcklwd', 'push', - 'pusha', 'pushad', 'pushaw', 'pushf', 'pushfd', 'pushfq', 'pushfw', 'pxor', - 'rcl', 'rcr', 'rdshr', 'rdmsr', 'rdpmc', 'rdtsc', 'rdtscp', 'ret', 'retf', - 'retn', 'rol', 'ror', 'rdm', 'rsdc', 'rsldt', 'rsm', 'rsts', 'sahf', 'sal', - 'salc', 'sar', 'sbb', 'scasb', 'scasd', 'scasq', 'scasw', 'sfence', 'sgdt', - 'shl', 'shld', 'shr', 'shrd', 'sidt', 'sldt', 'skinit', 'smi', 'smint', - 'smintold', 'smsw', 'stc', 'std', 'sti', 'stosb', 'stosd', 'stosq', 'stosw', - 'str', 'sub', 'svdc', 'svldt', 'svts', 'swapgs', 'syscall', 'sysenter', - 'sysexit', 'sysret', 'test', 'ud0', 'ud1', 'ud2b', 'ud2', 'ud2a', 'umov', - 'verr', 'verw', 'fwait', 'wbinvd', 'wrshr', 'wrmsr', 'xadd', 'xbts', - 'xchg', 'xlatb', 'xlat', 'xor', 'cmovcc', 'jcc', 'setcc', - -- Katmai Streaming SIMD instructions (SSE -- a.k.a. KNI, XMM, MMX2). - 'addps', 'addss', 'andnps', 'andps', 'cmpeqps', 'cmpeqss', 'cmpleps', - 'cmpless', 'cmpltps', 'cmpltss', 'cmpneqps', 'cmpneqss', 'cmpnleps', - 'cmpnless', 'cmpnltps', 'cmpnltss', 'cmpordps', 'cmpordss', 'cmpunordps', - 'cmpunordss', 'cmpps', 'cmpss', 'comiss', 'cvtpi2ps', 'cvtps2pi', 'cvtsi2ss', - 'cvtss2si', 'cvttps2pi', 'cvttss2si', 'divps', 'divss', 'ldmxcsr', 'maxps', - 'maxss', 'minps', 'minss', 'movaps', 'movhps', 'movlhps', 'movlps', - 'movhlps', 'movmskps', 'movntps', 'movss', 'movups', 'mulps', 'mulss', - 'orps', 'rcpps', 'rcpss', 'rsqrtps', 'rsqrtss', 'shufps', 'sqrtps', 'sqrtss', - 'stmxcsr', 'subps', 'subss', 'ucomiss', 'unpckhps', 'unpcklps', 'xorps', - -- Introduced in Deschutes but necessary for SSE support. - 'fxrstor', 'fxrstor64', 'fxsave', 'fxsave64', - -- XSAVE group (AVX and extended state). - 'xgetbv', 'xsetbv', 'xsave', 'xsave64', 'xsaveopt', 'xsaveopt64', 'xrstor', - 'xrstor64', - -- Generic memory operations. - 'prefetchnta', 'prefetcht0', 'prefetcht1', 'prefetcht2', 'sfence', - -- New MMX instructions introduced in Katmai. - 'maskmovq', 'movntq', 'pavgb', 'pavgw', 'pextrw', 'pinsrw', 'pmaxsw', - 'pmaxub', 'pminsw', 'pminub', 'pmovmskb', 'pmulhuw', 'psadbw', 'pshufw', - -- AMD Enhanced 3DNow! (Athlon) instructions. - 'pf2iw', 'pfnacc', 'pfpnacc', 'pi2fw', 'pswapd', - -- Willamette SSE2 Cacheability Instructions. - 'maskmovdqu', 'clflush', 'movntdq', 'movnti', 'movntpd', 'lfence', 'mfence', - -- Willamette MMX instructions (SSE2 SIMD Integer Instructions). - 'movd', 'movdqa', 'movdqu', 'movdq2q', 'movq', 'movq2dq', 'packsswb', - 'packssdw', 'packuswb', 'paddb', 'paddw', 'paddd', 'paddq', 'paddsb', - 'paddsw', 'paddusb', 'paddusw', 'pand', 'pandn', 'pavgb', 'pavgw', 'pcmpeqb', - 'pcmpeqw', 'pcmpeqd', 'pcmpgtb', 'pcmpgtw', 'pcmpgtd', 'pextrw', 'pinsrw', - 'pmaddwd', 'pmaxsw', 'pmaxub', 'pminsw', 'pminub', 'pmovmskb', 'pmulhuw', - 'pmulhw', 'pmullw', 'pmuludq', 'por', 'psadbw', 'pshufd', 'pshufhw', - 'pshuflw', 'pslldq', 'psllw', 'pslld', 'psllq', 'psraw', 'psrad', 'psrldq', - 'psrlw', 'psrld', 'psrlq', 'psubb', 'psubw', 'psubd', 'psubq', 'psubsb', - 'psubsw', 'psubusb', 'psubusw', 'punpckhbw', 'punpckhwd', 'punpckhdq', - 'punpckhqdq', 'punpcklbw', 'punpcklwd', 'punpckldq', 'punpcklqdq', 'pxor', - -- Willamette Streaming SIMD instructions (SSE2). - 'addpd', 'addsd', 'andnpd', 'andpd', 'cmpeqpd', 'cmpeqsd', 'cmplepd', - 'cmplesd', 'cmpltpd', 'cmpltsd', 'cmpneqpd', 'cmpneqsd', 'cmpnlepd', - 'cmpnlesd', 'cmpnltpd', 'cmpnltsd', 'cmpordpd', 'cmpordsd', 'cmpunordpd', - 'cmpunordsd', 'cmppd', 'cmpsd', 'comisd', 'cvtdq2pd', 'cvtdq2ps', - 'cvtpd2dq', 'cvtpd2pi', 'cvtpd2ps', 'cvtpi2pd', 'cvtps2dq', 'cvtps2pd', - 'cvtsd2si', 'cvtsd2ss', 'cvtsi2sd', 'cvtss2sd', 'cvttpd2pi', 'cvttpd2dq', - 'cvttps2dq', 'cvttsd2si', 'divpd', 'divsd', 'maxpd', 'maxsd', 'minpd', - 'minsd', 'movapd', 'movhpd', 'movlpd', 'movmskpd', 'movsd', 'movupd', - 'mulpd', 'mulsd', 'orpd', 'shufpd', 'sqrtpd', 'sqrtsd', 'subpd', 'subsd', - 'ucomisd', 'unpckhpd', 'unpcklpd', 'xorpd', - -- Prescott New Instructions (SSE3). - 'addsubpd', 'addsubps', 'haddpd', 'haddps', 'hsubpd', 'hsubps', 'lddqu', - 'movddup', 'movshdup', 'movsldup', - -- VMX/SVM Instructions. - 'clgi', 'stgi', 'vmcall', 'vmclear', 'vmfunc', 'vmlaunch', 'vmload', - 'vmmcall', 'vmptrld', 'vmptrst', 'vmread', 'vmresume', 'vmrun', 'vmsave', - 'vmwrite', 'vmxoff', 'vmxon', - -- Extended Page Tables VMX instructions. - 'invept', 'invvpid', - -- Tejas New Instructions (SSSE3). - 'pabsb', 'pabsw', 'pabsd', 'palignr', 'phaddw', 'phaddd', 'phaddsw', - 'phsubw', 'phsubd', 'phsubsw', 'pmaddubsw', 'pmulhrsw', 'pshufb', 'psignb', - 'psignw', 'psignd', - -- AMD SSE4A. - 'extrq', 'insertq', 'movntsd', 'movntss', - -- New instructions in Barcelona. - 'lzcnt', - -- Penryn New Instructions (SSE4.1). - 'blendpd', 'blendps', 'blendvpd', 'blendvps', 'dppd', 'dpps', 'extractps', - 'insertps', 'movntdqa', 'mpsadbw', 'packusdw', 'pblendvb', 'pblendw', - 'pcmpeqq', 'pextrb', 'pextrd', 'pextrq', 'pextrw', 'phminposuw', 'pinsrb', - 'pinsrd', 'pinsrq', 'pmaxsb', 'pmaxsd', 'pmaxud', 'pmaxuw', 'pminsb', - 'pminsd', 'pminud', 'pminuw', 'pmovsxbw', 'pmovsxbd', 'pmovsxbq', 'pmovsxwd', - 'pmovsxwq', 'pmovsxdq', 'pmovzxbw', 'pmovzxbd', 'pmovzxbq', 'pmovzxwd', - 'pmovzxwq', 'pmovzxdq', 'pmuldq', 'pmulld', 'ptest', 'roundpd', 'roundps', - 'roundsd', 'roundss', - -- Nehalem New Instructions (SSE4.2). - 'crc32', 'pcmpestri', 'pcmpestrm', 'pcmpistri', 'pcmpistrm', 'pcmpgtq', - 'popcnt', - -- Intel SMX. - 'getsec', - -- Geode (Cyrix) 3DNow! additions. - 'pfrcpv', 'pfrsqrtv', - -- Intel new instructions in ???. - 'movbe', - -- Intel AES instructions. - 'aesenc', 'aesenclast', 'aesdec', 'aesdeclast', 'aesimc', 'aeskeygenassist', - -- Intel AVX AES instructions. - 'vaesenc', 'vaesenclast', 'vaesdec', 'vaesdeclast', 'vaesimc', - 'vaeskeygenassist', - -- Intel AVX instructions. - 'vaddpd', 'vaddps', 'vaddsd', 'vaddss', 'vaddsubpd', 'vaddsubps', - 'vandpd', 'vandps', 'vandnpd', 'vandnps', 'vblendpd', 'vblendps', - 'vblendvpd', 'vblendvps', 'vbroadcastss', 'vbroadcastsd', 'vbroadcastf128', - 'vcmpeq_ospd', 'vcmpeqpd', 'vcmplt_ospd', 'vcmpltpd', 'vcmple_ospd', - 'vcmplepd', 'vcmpunord_qpd', 'vcmpunordpd', 'vcmpneq_uqpd', 'vcmpneqpd', - 'vcmpnlt_uspd', 'vcmpnltpd', 'vcmpnle_uspd', 'vcmpnlepd', 'vcmpord_qpd', - 'vcmpordpd', 'vcmpeq_uqpd', 'vcmpnge_uspd', 'vcmpngepd', 'vcmpngt_uspd', - 'vcmpngtpd', 'vcmpfalse_oqpd', 'vcmpfalsepd', 'vcmpneq_oqpd', 'vcmpge_ospd', - 'vcmpgepd', 'vcmpgt_ospd', 'vcmpgtpd', 'vcmptrue_uqpd', 'vcmptruepd', - 'vcmpeq_ospd', 'vcmplt_oqpd', 'vcmple_oqpd', 'vcmpunord_spd', 'vcmpneq_uspd', - 'vcmpnlt_uqpd', 'vcmpnle_uqpd', 'vcmpord_spd', 'vcmpeq_uspd', 'vcmpnge_uqpd', - 'vcmpngt_uqpd', 'vcmpfalse_ospd', 'vcmpneq_ospd', 'vcmpge_oqpd', - 'vcmpgt_oqpd', 'vcmptrue_uspd', 'vcmppd', 'vcmpeq_osps', 'vcmpeqps', - 'vcmplt_osps', 'vcmpltps', 'vcmple_osps', 'vcmpleps', 'vcmpunord_qps', - 'vcmpunordps', 'vcmpneq_uqps', 'vcmpneqps', 'vcmpnlt_usps', 'vcmpnltps', - 'vcmpnle_usps', 'vcmpnleps', 'vcmpord_qps', 'vcmpordps', 'vcmpeq_uqps', - 'vcmpnge_usps', 'vcmpngeps', 'vcmpngt_usps', 'vcmpngtps', 'vcmpfalse_oqps', - 'vcmpfalseps', 'vcmpneq_oqps', 'vcmpge_osps', 'vcmpgeps', 'vcmpgt_osps', - 'vcmpgtps', 'vcmptrue_uqps', 'vcmptrueps', 'vcmpeq_osps', 'vcmplt_oqps', - 'vcmple_oqps', 'vcmpunord_sps', 'vcmpneq_usps', 'vcmpnlt_uqps', - 'vcmpnle_uqps', 'vcmpord_sps', 'vcmpeq_usps', 'vcmpnge_uqps', - 'vcmpngt_uqps', 'vcmpfalse_osps', 'vcmpneq_osps', 'vcmpge_oqps', - 'vcmpgt_oqps', 'vcmptrue_usps', 'vcmpps', 'vcmpeq_ossd', 'vcmpeqsd', - 'vcmplt_ossd', 'vcmpltsd', 'vcmple_ossd', 'vcmplesd', 'vcmpunord_qsd', - 'vcmpunordsd', 'vcmpneq_uqsd', 'vcmpneqsd', 'vcmpnlt_ussd', 'vcmpnltsd', - 'vcmpnle_ussd', 'vcmpnlesd', 'vcmpord_qsd', 'vcmpordsd', 'vcmpeq_uqsd', - 'vcmpnge_ussd', 'vcmpngesd', 'vcmpngt_ussd', 'vcmpngtsd', 'vcmpfalse_oqsd', - 'vcmpfalsesd', 'vcmpneq_oqsd', 'vcmpge_ossd', 'vcmpgesd', 'vcmpgt_ossd', - 'vcmpgtsd', 'vcmptrue_uqsd', 'vcmptruesd', 'vcmpeq_ossd', 'vcmplt_oqsd', - 'vcmple_oqsd', 'vcmpunord_ssd', 'vcmpneq_ussd', 'vcmpnlt_uqsd', - 'vcmpnle_uqsd', 'vcmpord_ssd', 'vcmpeq_ussd', 'vcmpnge_uqsd', - 'vcmpngt_uqsd', 'vcmpfalse_ossd', 'vcmpneq_ossd', 'vcmpge_oqsd', - 'vcmpgt_oqsd', 'vcmptrue_ussd', 'vcmpsd', 'vcmpeq_osss', 'vcmpeqss', - 'vcmplt_osss', 'vcmpltss', 'vcmple_osss', 'vcmpless', 'vcmpunord_qss', - 'vcmpunordss', 'vcmpneq_uqss', 'vcmpneqss', 'vcmpnlt_usss', 'vcmpnltss', - 'vcmpnle_usss', 'vcmpnless', 'vcmpord_qss', 'vcmpordss', 'vcmpeq_uqss', - 'vcmpnge_usss', 'vcmpngess', 'vcmpngt_usss', 'vcmpngtss', 'vcmpfalse_oqss', - 'vcmpfalsess', 'vcmpneq_oqss', 'vcmpge_osss', 'vcmpgess', 'vcmpgt_osss', - 'vcmpgtss', 'vcmptrue_uqss', 'vcmptruess', 'vcmpeq_osss', 'vcmplt_oqss', - 'vcmple_oqss', 'vcmpunord_sss', 'vcmpneq_usss', 'vcmpnlt_uqss', - 'vcmpnle_uqss', 'vcmpord_sss', 'vcmpeq_usss', 'vcmpnge_uqss', - 'vcmpngt_uqss', 'vcmpfalse_osss', 'vcmpneq_osss', 'vcmpge_oqss', - 'vcmpgt_oqss', 'vcmptrue_usss', 'vcmpss', 'vcomisd', 'vcomiss', - 'vcvtdq2pd', 'vcvtdq2ps', 'vcvtpd2dq', 'vcvtpd2ps', 'vcvtps2dq', - 'vcvtps2pd', 'vcvtsd2si', 'vcvtsd2ss', 'vcvtsi2sd', 'vcvtsi2ss', - 'vcvtss2sd', 'vcvtss2si', 'vcvttpd2dq', 'vcvttps2dq', 'vcvttsd2si', - 'vcvttss2si', 'vdivpd', 'vdivps', 'vdivsd', 'vdivss', 'vdppd', 'vdpps', - 'vextractf128', 'vextractps', 'vhaddpd', 'vhaddps', 'vhsubpd', 'vhsubps', - 'vinsertf128', 'vinsertps', 'vlddqu', 'vldqqu', 'vlddqu', 'vldmxcsr', - 'vmaskmovdqu', 'vmaskmovps', 'vmaskmovpd', 'vmaxpd', 'vmaxps', 'vmaxsd', - 'vmaxss', 'vminpd', 'vminps', 'vminsd', 'vminss', 'vmovapd', 'vmovaps', - 'vmovd', 'vmovq', 'vmovddup', 'vmovdqa', 'vmovqqa', 'vmovdqa', 'vmovdqu', - 'vmovqqu', 'vmovdqu', 'vmovhlps', 'vmovhpd', 'vmovhps', 'vmovlhps', - 'vmovlpd', 'vmovlps', 'vmovmskpd', 'vmovmskps', 'vmovntdq', 'vmovntqq', - 'vmovntdq', 'vmovntdqa', 'vmovntpd', 'vmovntps', 'vmovsd', 'vmovshdup', - 'vmovsldup', 'vmovss', 'vmovupd', 'vmovups', 'vmpsadbw', 'vmulpd', - 'vmulps', 'vmulsd', 'vmulss', 'vorpd', 'vorps', 'vpabsb', 'vpabsw', - 'vpabsd', 'vpacksswb', 'vpackssdw', 'vpackuswb', 'vpackusdw', 'vpaddb', - 'vpaddw', 'vpaddd', 'vpaddq', 'vpaddsb', 'vpaddsw', 'vpaddusb', 'vpaddusw', - 'vpalignr', 'vpand', 'vpandn', 'vpavgb', 'vpavgw', 'vpblendvb', 'vpblendw', - 'vpcmpestri', 'vpcmpestrm', 'vpcmpistri', 'vpcmpistrm', 'vpcmpeqb', - 'vpcmpeqw', 'vpcmpeqd', 'vpcmpeqq', 'vpcmpgtb', 'vpcmpgtw', 'vpcmpgtd', - 'vpcmpgtq', 'vpermilpd', 'vpermilps', 'vperm2f128', 'vpextrb', 'vpextrw', - 'vpextrd', 'vpextrq', 'vphaddw', 'vphaddd', 'vphaddsw', 'vphminposuw', - 'vphsubw', 'vphsubd', 'vphsubsw', 'vpinsrb', 'vpinsrw', 'vpinsrd', - 'vpinsrq', 'vpmaddwd', 'vpmaddubsw', 'vpmaxsb', 'vpmaxsw', 'vpmaxsd', - 'vpmaxub', 'vpmaxuw', 'vpmaxud', 'vpminsb', 'vpminsw', 'vpminsd', 'vpminub', - 'vpminuw', 'vpminud', 'vpmovmskb', 'vpmovsxbw', 'vpmovsxbd', 'vpmovsxbq', - 'vpmovsxwd', 'vpmovsxwq', 'vpmovsxdq', 'vpmovzxbw', 'vpmovzxbd', 'vpmovzxbq', - 'vpmovzxwd', 'vpmovzxwq', 'vpmovzxdq', 'vpmulhuw', 'vpmulhrsw', 'vpmulhw', - 'vpmullw', 'vpmulld', 'vpmuludq', 'vpmuldq', 'vpor', 'vpsadbw', 'vpshufb', - 'vpshufd', 'vpshufhw', 'vpshuflw', 'vpsignb', 'vpsignw', 'vpsignd', - 'vpslldq', 'vpsrldq', 'vpsllw', 'vpslld', 'vpsllq', 'vpsraw', 'vpsrad', - 'vpsrlw', 'vpsrld', 'vpsrlq', 'vptest', 'vpsubb', 'vpsubw', 'vpsubd', - 'vpsubq', 'vpsubsb', 'vpsubsw', 'vpsubusb', 'vpsubusw', 'vpunpckhbw', - 'vpunpckhwd', 'vpunpckhdq', 'vpunpckhqdq', 'vpunpcklbw', 'vpunpcklwd', - 'vpunpckldq', 'vpunpcklqdq', 'vpxor', 'vrcpps', 'vrcpss', 'vrsqrtps', - 'vrsqrtss', 'vroundpd', 'vroundps', 'vroundsd', 'vroundss', 'vshufpd', - 'vshufps', 'vsqrtpd', 'vsqrtps', 'vsqrtsd', 'vsqrtss', 'vstmxcsr', 'vsubpd', - 'vsubps', 'vsubsd', 'vsubss', 'vtestps', 'vtestpd', 'vucomisd', 'vucomiss', - 'vunpckhpd', 'vunpckhps', 'vunpcklpd', 'vunpcklps', 'vxorpd', 'vxorps', - 'vzeroall', 'vzeroupper', - -- Intel Carry-Less Multiplication instructions (CLMUL). - 'pclmullqlqdq', 'pclmulhqlqdq', 'pclmullqhqdq', 'pclmulhqhqdq', 'pclmulqdq', - -- Intel AVX Carry-Less Multiplication instructions (CLMUL). - 'vpclmullqlqdq', 'vpclmulhqlqdq', 'vpclmullqhqdq', 'vpclmulhqhqdq', - 'vpclmulqdq', - -- Intel Fused Multiply-Add instructions (FMA). - 'vfmadd132ps', 'vfmadd132pd', 'vfmadd312ps', 'vfmadd312pd', 'vfmadd213ps', - 'vfmadd213pd', 'vfmadd123ps', 'vfmadd123pd', 'vfmadd231ps', 'vfmadd231pd', - 'vfmadd321ps', 'vfmadd321pd', 'vfmaddsub132ps', 'vfmaddsub132pd', - 'vfmaddsub312ps', 'vfmaddsub312pd', 'vfmaddsub213ps', 'vfmaddsub213pd', - 'vfmaddsub123ps', 'vfmaddsub123pd', 'vfmaddsub231ps', 'vfmaddsub231pd', - 'vfmaddsub321ps', 'vfmaddsub321pd', 'vfmsub132ps', 'vfmsub132pd', - 'vfmsub312ps', 'vfmsub312pd', 'vfmsub213ps', 'vfmsub213pd', 'vfmsub123ps', - 'vfmsub123pd', 'vfmsub231ps', 'vfmsub231pd', 'vfmsub321ps', 'vfmsub321pd', - 'vfmsubadd132ps', 'vfmsubadd132pd', 'vfmsubadd312ps', 'vfmsubadd312pd', - 'vfmsubadd213ps', 'vfmsubadd213pd', 'vfmsubadd123ps', 'vfmsubadd123pd', - 'vfmsubadd231ps', 'vfmsubadd231pd', 'vfmsubadd321ps', 'vfmsubadd321pd', - 'vfnmadd132ps', 'vfnmadd132pd', 'vfnmadd312ps', 'vfnmadd312pd', - 'vfnmadd213ps', 'vfnmadd213pd', 'vfnmadd123ps', 'vfnmadd123pd', - 'vfnmadd231ps', 'vfnmadd231pd', 'vfnmadd321ps', 'vfnmadd321pd', - 'vfnmsub132ps', 'vfnmsub132pd', 'vfnmsub312ps', 'vfnmsub312pd', - 'vfnmsub213ps', 'vfnmsub213pd', 'vfnmsub123ps', 'vfnmsub123pd', - 'vfnmsub231ps', 'vfnmsub231pd', 'vfnmsub321ps', 'vfnmsub321pd', - 'vfmadd132ss', 'vfmadd132sd', 'vfmadd312ss', 'vfmadd312sd', 'vfmadd213ss', - 'vfmadd213sd', 'vfmadd123ss', 'vfmadd123sd', 'vfmadd231ss', 'vfmadd231sd', - 'vfmadd321ss', 'vfmadd321sd', 'vfmsub132ss', 'vfmsub132sd', 'vfmsub312ss', - 'vfmsub312sd', 'vfmsub213ss', 'vfmsub213sd', 'vfmsub123ss', 'vfmsub123sd', - 'vfmsub231ss', 'vfmsub231sd', 'vfmsub321ss', 'vfmsub321sd', 'vfnmadd132ss', - 'vfnmadd132sd', 'vfnmadd312ss', 'vfnmadd312sd', 'vfnmadd213ss', - 'vfnmadd213sd', 'vfnmadd123ss', 'vfnmadd123sd', 'vfnmadd231ss', - 'vfnmadd231sd', 'vfnmadd321ss', 'vfnmadd321sd', 'vfnmsub132ss', - 'vfnmsub132sd', 'vfnmsub312ss', 'vfnmsub312sd', 'vfnmsub213ss', - 'vfnmsub213sd', 'vfnmsub123ss', 'vfnmsub123sd', 'vfnmsub231ss', - 'vfnmsub231sd', 'vfnmsub321ss', 'vfnmsub321sd', - -- Intel post-32 nm processor instructions. - 'rdfsbase', 'rdgsbase', 'rdrand', 'wrfsbase', 'wrgsbase', 'vcvtph2ps', - 'vcvtps2ph', 'adcx', 'adox', 'rdseed', 'clac', 'stac', - -- VIA (Centaur) security instructions. - 'xstore', 'xcryptecb', 'xcryptcbc', 'xcryptctr', 'xcryptcfb', 'xcryptofb', - 'montmul', 'xsha1', 'xsha256', - -- AMD Lightweight Profiling (LWP) instructions. - 'llwpcb', 'slwpcb', 'lwpval', 'lwpins', - -- AMD XOP and FMA4 instructions (SSE5). - 'vfmaddpd', 'vfmaddps', 'vfmaddsd', 'vfmaddss', 'vfmaddsubpd', - 'vfmaddsubps', 'vfmsubaddpd', 'vfmsubaddps', 'vfmsubpd', 'vfmsubps', - 'vfmsubsd', 'vfmsubss', 'vfnmaddpd', 'vfnmaddps', 'vfnmaddsd', 'vfnmaddss', - 'vfnmsubpd', 'vfnmsubps', 'vfnmsubsd', 'vfnmsubss', 'vfrczpd', 'vfrczps', - 'vfrczsd', 'vfrczss', 'vpcmov', 'vpcomb', 'vpcomd', 'vpcomq', 'vpcomub', - 'vpcomud', 'vpcomuq', 'vpcomuw', 'vpcomw', 'vphaddbd', 'vphaddbq', - 'vphaddbw', 'vphadddq', 'vphaddubd', 'vphaddubq', 'vphaddubw', 'vphaddudq', - 'vphadduwd', 'vphadduwq', 'vphaddwd', 'vphaddwq', 'vphsubbw', 'vphsubdq', - 'vphsubwd', 'vpmacsdd', 'vpmacsdqh', 'vpmacsdql', 'vpmacssdd', 'vpmacssdqh', - 'vpmacssdql', 'vpmacsswd', 'vpmacssww', 'vpmacswd', 'vpmacsww', 'vpmadcsswd', - 'vpmadcswd', 'vpperm', 'vprotb', 'vprotd', 'vprotq', 'vprotw', 'vpshab', - 'vpshad', 'vpshaq', 'vpshaw', 'vpshlb', 'vpshld', 'vpshlq', 'vpshlw', - -- Intel AVX2 instructions. - 'vmpsadbw', 'vpabsb', 'vpabsw', 'vpabsd', 'vpacksswb', 'vpackssdw', - 'vpackusdw', 'vpackuswb', 'vpaddb', 'vpaddw', 'vpaddd', 'vpaddq', - 'vpaddsb', 'vpaddsw', 'vpaddusb', 'vpaddusw', 'vpalignr', 'vpand', - 'vpandn', 'vpavgb', 'vpavgw', 'vpblendvb', 'vpblendw', 'vpcmpeqb', - 'vpcmpeqw', 'vpcmpeqd', 'vpcmpeqq', 'vpcmpgtb', 'vpcmpgtw', 'vpcmpgtd', - 'vpcmpgtq', 'vphaddw', 'vphaddd', 'vphaddsw', 'vphsubw', 'vphsubd', - 'vphsubsw', 'vpmaddubsw', 'vpmaddwd', 'vpmaxsb', 'vpmaxsw', 'vpmaxsd', - 'vpmaxub', 'vpmaxuw', 'vpmaxud', 'vpminsb', 'vpminsw', 'vpminsd', 'vpminub', - 'vpminuw', 'vpminud', 'vpmovmskb', 'vpmovsxbw', 'vpmovsxbd', 'vpmovsxbq', - 'vpmovsxwd', 'vpmovsxwq', 'vpmovsxdq', 'vpmovzxbw', 'vpmovzxbd', 'vpmovzxbq', - 'vpmovzxwd', 'vpmovzxwq', 'vpmovzxdq', 'vpmuldq', 'vpmulhrsw', 'vpmulhuw', - 'vpmulhw', 'vpmullw', 'vpmulld', 'vpmuludq', 'vpor', 'vpsadbw', 'vpshufb', - 'vpshufd', 'vpshufhw', 'vpshuflw', 'vpsignb', 'vpsignw', 'vpsignd', - 'vpslldq', 'vpsllw', 'vpslld', 'vpsllq', 'vpsraw', 'vpsrad', 'vpsrldq', - 'vpsrlw', 'vpsrld', 'vpsrlq', 'vpsubb', 'vpsubw', 'vpsubd', 'vpsubq', - 'vpsubsb', 'vpsubsw', 'vpsubusb', 'vpsubusw', 'vpunpckhbw', 'vpunpckhwd', - 'vpunpckhdq', 'vpunpckhqdq', 'vpunpcklbw', 'vpunpcklwd', 'vpunpckldq', - 'vpunpcklqdq', 'vpxor', 'vmovntdqa', 'vbroadcastss', 'vbroadcastsd', - 'vbroadcasti128', 'vpblendd', 'vpbroadcastb', 'vpbroadcastw', 'vpbroadcastd', - 'vpbroadcastq', 'vpermd', 'vpermpd', 'vpermps', 'vpermq', 'vperm2i128', - 'vextracti128', 'vinserti128', 'vpmaskmovd', 'vpmaskmovq', 'vpmaskmovd', - 'vpmaskmovq', 'vpsllvd', 'vpsllvq', 'vpsllvd', 'vpsllvq', 'vpsravd', - 'vpsrlvd', 'vpsrlvq', 'vpsrlvd', 'vpsrlvq', 'vgatherdpd', 'vgatherqpd', - 'vgatherdpd', 'vgatherqpd', 'vgatherdps', 'vgatherqps', 'vgatherdps', - 'vgatherqps', 'vpgatherdd', 'vpgatherqd', 'vpgatherdd', 'vpgatherqd', - 'vpgatherdq', 'vpgatherqq', 'vpgatherdq', 'vpgatherqq', - -- Transactional Synchronization Extensions (TSX). - 'xabort', 'xbegin', 'xend', 'xtest', - -- Intel BMI1 and BMI2 instructions, AMD TBM instructions. - 'andn', 'bextr', 'blci', 'blcic', 'blsi', 'blsic', 'blcfill', 'blsfill', - 'blcmsk', 'blsmsk', 'blsr', 'blcs', 'bzhi', 'mulx', 'pdep', 'pext', 'rorx', - 'sarx', 'shlx', 'shrx', 'tzcnt', 'tzmsk', 't1mskc', - -- Systematic names for the hinting nop instructions. - 'hint_nop0', 'hint_nop1', 'hint_nop2', 'hint_nop3', 'hint_nop4', - 'hint_nop5', 'hint_nop6', 'hint_nop7', 'hint_nop8', 'hint_nop9', - 'hint_nop10', 'hint_nop11', 'hint_nop12', 'hint_nop13', 'hint_nop14', - 'hint_nop15', 'hint_nop16', 'hint_nop17', 'hint_nop18', 'hint_nop19', - 'hint_nop20', 'hint_nop21', 'hint_nop22', 'hint_nop23', 'hint_nop24', - 'hint_nop25', 'hint_nop26', 'hint_nop27', 'hint_nop28', 'hint_nop29', - 'hint_nop30', 'hint_nop31', 'hint_nop32', 'hint_nop33', 'hint_nop34', - 'hint_nop35', 'hint_nop36', 'hint_nop37', 'hint_nop38', 'hint_nop39', - 'hint_nop40', 'hint_nop41', 'hint_nop42', 'hint_nop43', 'hint_nop44', - 'hint_nop45', 'hint_nop46', 'hint_nop47', 'hint_nop48', 'hint_nop49', - 'hint_nop50', 'hint_nop51', 'hint_nop52', 'hint_nop53', 'hint_nop54', - 'hint_nop55', 'hint_nop56', 'hint_nop57', 'hint_nop58', 'hint_nop59', - 'hint_nop60', 'hint_nop61', 'hint_nop62', 'hint_nop63', -}) - --- Types. -local sizes = word_match{ - 'byte', 'word', 'dword', 'qword', 'tword', 'oword', 'yword', - 'a16', 'a32', 'a64', 'o16', 'o32', 'o64' -- instructions -} -local wrt_types = '..' * word_match{ - 'start', 'gotpc', 'gotoff', 'gottpoff', 'got', 'plt', 'sym', 'tlsie' -} -local type = token(l.TYPE, sizes + wrt_types) - --- Registers. -local register = token('register', word_match{ - -- 32-bit registers. - 'ah', 'al', 'ax', 'bh', 'bl', 'bp', 'bx', 'ch', 'cl', 'cx', 'dh', 'di', 'dl', - 'dx', 'eax', 'ebx', 'ebx', 'ecx', 'edi', 'edx', 'esi', 'esp', 'fs', 'mm0', - 'mm1', 'mm2', 'mm3', 'mm4', 'mm5', 'mm6', 'mm7', 'si', 'st0', 'st1', 'st2', - 'st3', 'st4', 'st5', 'st6', 'st7', 'xmm0', 'xmm1', 'xmm2', 'xmm3', 'xmm4', - 'xmm5', 'xmm6', 'xmm7', 'ymm0', 'ymm1', 'ymm2', 'ymm3', 'ymm4', 'ymm5', - 'ymm6', 'ymm7', - -- 64-bit registers. - 'bpl', 'dil', 'gs', 'r8', 'r8b', 'r8w', 'r9', 'r9b', 'r9w', 'r10', 'r10b', - 'r10w', 'r11', 'r11b', 'r11w', 'r12', 'r12b', 'r12w', 'r13', 'r13b', 'r13w', - 'r14', 'r14b', 'r14w', 'r15', 'r15b', 'r15w', 'rax', 'rbp', 'rbx', 'rcx', - 'rdi', 'rdx', 'rsi', 'rsp', 'sil', 'xmm8', 'xmm9', 'xmm10', 'xmm11', 'xmm12', - 'xmm13', 'xmm14', 'xmm15', 'ymm8', 'ymm9', 'ymm10', 'ymm11', 'ymm12', 'ymm13', - 'ymm14', 'ymm15' -}) - -local word = (l.alpha + S('$._?')) * (l.alnum + S('$._?#@~'))^0 - --- Labels. -local label = token(l.LABEL, word * ':') - --- Identifiers. -local identifier = token(l.IDENTIFIER, word) - --- Constants. -local constants = word_match{ - '__float8__', '__float16__', '__float32__', '__float64__', '__float80m__', - '__float80e__', '__float128l__', '__float128h__', '__Infinity__', '__QNaN__', - '__NaN__', '__SNaN__' -} -local constant = token(l.CONSTANT, constants + '$' * P('$')^-1 * -identifier) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|~:,()[]')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'instruction', instruction}, - {'register', register}, - {'type', type}, - {'constant', constant}, - {'label', label}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'preproc', preproc}, - {'operator', operator}, -} - -M._tokenstyles = { - instruction = l.STYLE_FUNCTION, - register = l.STYLE_CONSTANT, -} - -M._foldsymbols = { - _patterns = {'%l+', '//'}, - [l.PREPROCESSOR] = { - ['if'] = 1, endif = -1, macro = 1, endmacro = -1, rep = 1, endrep = -1, - ['while'] = 1, endwhile = -1, - }, - [l.KEYWORD] = {struc = 1, endstruc = -1}, - [l.COMMENT] = {['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/asp.lua b/dep/scintillua/scintillua-3.6.0/lexers/asp.lua deleted file mode 100644 index 044966ca..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/asp.lua +++ /dev/null @@ -1,42 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- ASP LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'asp'} - --- Embedded in HTML. -local html = l.load('html') - --- Embedded VB. -local vb = l.load('vb') -local vb_start_rule = token('asp_tag', '<%' * P('=')^-1) -local vb_end_rule = token('asp_tag', '%>') -l.embed_lexer(html, vb, vb_start_rule, vb_end_rule) - --- Embedded VBScript. -local vbs = l.load('vbscript') -local script_element = word_match({'script'}, nil, html.case_insensitive_tags) -local vbs_start_rule = #(P('<') * script_element * (P(function(input, index) - if input:find('^%s+language%s*=%s*(["\'])vbscript%1', index) or - input:find('^%s+type%s*=%s*(["\'])text/vbscript%1', index) then - return index - end -end) + '>')) * html.embed_start_tag -- -l.embed_lexer(html, vbs, vbs_start_rule, vbs_end_rule) - -M._tokenstyles = { - asp_tag = l.STYLE_EMBEDDED -} - -local _foldsymbols = html._foldsymbols -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '<%%' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '%%>' -_foldsymbols.asp_tag = {['<%'] = 1, ['%>'] = -1} -M._foldsymbols = _foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/bash.lua b/dep/scintillua/scintillua-3.6.0/lexers/bash.lua deleted file mode 100644 index f15e51aa..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/bash.lua +++ /dev/null @@ -1,74 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Shell LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'bash'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", false, true) -local dq_str = l.delimited_range('"') -local ex_str = l.delimited_range('`') -local heredoc = '<<' * P(function(input, index) - local s, e, _, delimiter = - input:find('%-?(["\']?)([%a_][%w_]*)%1[\n\r\f;]+', index) - if s == index and delimiter then - local _, e = input:find('[\n\r\f]+'..delimiter, e) - return e and e + 1 or #input + 1 - end -end) -local string = token(l.STRING, sq_str + dq_str + ex_str + heredoc) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'if', 'then', 'elif', 'else', 'fi', 'case', 'in', 'esac', 'while', 'for', - 'do', 'done', 'continue', 'local', 'return', 'select', - -- Operators. - '-a', '-b', '-c', '-d', '-e', '-f', '-g', '-h', '-k', '-p', '-r', '-s', '-t', - '-u', '-w', '-x', '-O', '-G', '-L', '-S', '-N', '-nt', '-ot', '-ef', '-o', - '-z', '-n', '-eq', '-ne', '-lt', '-le', '-gt', '-ge' -}, '-')) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Variables. -local variable = token(l.VARIABLE, - '$' * (S('!#?*@$') + l.digit^1 + l.word + - l.delimited_range('{}', true, true))) - --- Operators. -local operator = token(l.OPERATOR, S('=!<>+-/*^&|~.,:;?()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'variable', variable}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[a-z]+', '[{}]', '#'}, - [l.KEYWORD] = { - ['if'] = 1, fi = -1, case = 1, esac = -1, ['do'] = 1, done = -1 - }, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['#'] = l.fold_line_comments('#')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/batch.lua b/dep/scintillua/scintillua-3.6.0/lexers/batch.lua deleted file mode 100644 index d3e1ecec..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/batch.lua +++ /dev/null @@ -1,71 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Batch LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'batch'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local rem = (P('REM') + 'rem') * l.space -local comment = token(l.COMMENT, (rem + '::') * l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range('"', true)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'cd', 'chdir', 'md', 'mkdir', 'cls', 'for', 'if', 'echo', 'echo.', 'move', - 'copy', 'ren', 'del', 'set', 'call', 'exit', 'setlocal', 'shift', - 'endlocal', 'pause', 'defined', 'exist', 'errorlevel', 'else', 'in', 'do', - 'NUL', 'AUX', 'PRN', 'not', 'goto', 'pushd', 'popd' -}, nil, true)) - --- Functions. -local func = token(l.FUNCTION, word_match({ - 'APPEND', 'ATTRIB', 'CHKDSK', 'CHOICE', 'DEBUG', 'DEFRAG', 'DELTREE', - 'DISKCOMP', 'DISKCOPY', 'DOSKEY', 'DRVSPACE', 'EMM386', 'EXPAND', 'FASTOPEN', - 'FC', 'FDISK', 'FIND', 'FORMAT', 'GRAPHICS', 'KEYB', 'LABEL', 'LOADFIX', - 'MEM', 'MODE', 'MORE', 'MOVE', 'MSCDEX', 'NLSFUNC', 'POWER', 'PRINT', 'RD', - 'REPLACE', 'RESTORE', 'SETVER', 'SHARE', 'SORT', 'SUBST', 'SYS', 'TREE', - 'UNDELETE', 'UNFORMAT', 'VSAFE', 'XCOPY' -}, nil, true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Variables. -local variable = token(l.VARIABLE, - '%' * (l.digit + '%' * l.alpha) + - l.delimited_range('%', true, true)) - --- Operators. -local operator = token(l.OPERATOR, S('+|&!<>=')) - --- Labels. -local label = token(l.LABEL, ':' * l.word) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'comment', comment}, - {'identifier', identifier}, - {'string', string}, - {'variable', variable}, - {'label', label}, - {'operator', operator}, -} - -M._LEXBYLINE = true - -M._foldsymbols = { - _patterns = {'[A-Za-z]+'}, - [l.KEYWORD] = {setlocal = 1, endlocal = -1, SETLOCAL = 1, ENDLOCAL = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/bibtex.lua b/dep/scintillua/scintillua-3.6.0/lexers/bibtex.lua deleted file mode 100644 index 992667a1..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/bibtex.lua +++ /dev/null @@ -1,58 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Bibtex LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'bibtex'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Strings. -local string = token(l.STRING, l.delimited_range('"') + - l.delimited_range('{}', false, true, true)) - --- Fields. -local field = token('field', word_match{ - 'author', 'title', 'journal', 'year', 'volume', 'number', 'pages', 'month', - 'note', 'key', 'publisher', 'editor', 'series', 'address', 'edition', - 'howpublished', 'booktitle', 'organization', 'chapter', 'school', - 'institution', 'type', 'isbn', 'issn', 'affiliation', 'issue', 'keyword', - 'url' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S(',=')) - -M._rules = { - {'whitespace', ws}, - {'field', field}, - {'identifier', identifier}, - {'string', string}, - {'operator', operator}, -} - --- Embedded in Latex. -local latex = l.load('latex') - --- Embedded Bibtex. -local entry = token('entry', P('@') * word_match({ - 'book', 'article', 'booklet', 'conference', 'inbook', 'incollection', - 'inproceedings', 'manual', 'mastersthesis', 'lambda', 'misc', 'phdthesis', - 'proceedings', 'techreport', 'unpublished' -}, nil, true)) -local bibtex_start_rule = entry * ws^0 * token(l.OPERATOR, P('{')) -local bibtex_end_rule = token(l.OPERATOR, P('}')) -l.embed_lexer(latex, M, bibtex_start_rule, bibtex_end_rule) - -M._tokenstyles = { - field = l.STYLE_CONSTANT, - entry = l.STYLE_PREPROCESSOR -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/boo.lua b/dep/scintillua/scintillua-3.6.0/lexers/boo.lua deleted file mode 100644 index 54ad1a67..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/boo.lua +++ /dev/null @@ -1,81 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Boo LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'boo'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '#' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local triple_dq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 -local regex_str = #('/') * l.last_char_includes('!%^&*([{-=+|:;,?<>~') * - l.delimited_range('/', true) -local string = token(l.STRING, triple_dq_str + sq_str + dq_str) + - token(l.REGEX, regex_str) - - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * - (S('msdhsfFlL') + 'ms')^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'and', 'break', 'cast', 'continue', 'elif', 'else', 'ensure', 'except', 'for', - 'given', 'goto', 'if', 'in', 'isa', 'is', 'not', 'or', 'otherwise', 'pass', - 'raise', 'ref', 'try', 'unless', 'when', 'while', - -- Definitions. - 'abstract', 'callable', 'class', 'constructor', 'def', 'destructor', 'do', - 'enum', 'event', 'final', 'get', 'interface', 'internal', 'of', 'override', - 'partial', 'private', 'protected', 'public', 'return', 'set', 'static', - 'struct', 'transient', 'virtual', 'yield', - -- Namespaces. - 'as', 'from', 'import', 'namespace', - -- Other. - 'self', 'super', 'null', 'true', 'false' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'bool', 'byte', 'char', 'date', 'decimal', 'double', 'duck', 'float', 'int', - 'long', 'object', 'operator', 'regex', 'sbyte', 'short', 'single', 'string', - 'timespan', 'uint', 'ulong', 'ushort' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'array', 'assert', 'checked', 'enumerate', '__eval__', 'filter', 'getter', - 'len', 'lock', 'map', 'matrix', 'max', 'min', 'normalArrayIndexing', 'print', - 'property', 'range', 'rawArrayIndexing', 'required', '__switch__', 'typeof', - 'unchecked', 'using', 'yieldAll', 'zip' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('!%^&*()[]{}-=+/|:;.,?<>~`')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/caml.lua b/dep/scintillua/scintillua-3.6.0/lexers/caml.lua deleted file mode 100644 index b7013062..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/caml.lua +++ /dev/null @@ -1,83 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- OCaml LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'caml'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, l.nested_pair('(*', '*)')) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'and', 'as', 'asr', 'begin', 'class', 'closed', 'constraint', 'do', 'done', - 'downto', 'else', 'end', 'exception', 'external', 'failwith', 'false', - 'flush', 'for', 'fun', 'function', 'functor', 'if', 'in', 'include', - 'inherit', 'incr', 'land', 'let', 'load', 'los', 'lsl', 'lsr', 'lxor', - 'match', 'method', 'mod', 'module', 'mutable', 'new', 'not', 'of', 'open', - 'option', 'or', 'parser', 'private', 'ref', 'rec', 'raise', 'regexp', 'sig', - 'struct', 'stdout', 'stdin', 'stderr', 'then', 'to', 'true', 'try', 'type', - 'val', 'virtual', 'when', 'while', 'with' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'int', 'float', 'bool', 'char', 'string', 'unit' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'raise', 'invalid_arg', 'failwith', 'compare', 'min', 'max', 'succ', 'pred', - 'mod', 'abs', 'max_int', 'min_int', 'sqrt', 'exp', 'log', 'log10', 'cos', - 'sin', 'tan', 'acos', 'asin', 'atan', 'atan2', 'cosh', 'sinh', 'tanh', 'ceil', - 'floor', 'abs_float', 'mod_float', 'frexp', 'ldexp', 'modf', 'float', - 'float_of_int', 'truncate', 'int_of_float', 'infinity', 'nan', 'max_float', - 'min_float', 'epsilon_float', 'classify_float', 'int_of_char', 'char_of_int', - 'ignore', 'string_of_bool', 'bool_of_string', 'string_of_int', - 'int_of_string', 'string_of_float', 'float_of_string', 'fst', 'snd', 'stdin', - 'stdout', 'stderr', 'print_char', 'print_string', 'print_int', 'print_float', - 'print_endline', 'print_newline', 'prerr_char', 'prerr_string', 'prerr_int', - 'prerr_float', 'prerr_endline', 'prerr_newline', 'read_line', 'read_int', - 'read_float', 'open_out', 'open_out_bin', 'open_out_gen', 'flush', - 'flush_all', 'output_char', 'output_string', 'output', 'output_byte', - 'output_binary_int', 'output_value', 'seek_out', 'pos_out', - 'out_channel_length', 'close_out', 'close_out_noerr', 'set_binary_mode_out', - 'open_in', 'open_in_bin', 'open_in_gen', 'input_char', 'input_line', 'input', - 'really_input', 'input_byte', 'input_binary_int', 'input_value', 'seek_in', - 'pos_in', 'in_channel_length', 'close_in', 'close_in_noerr', - 'set_binary_mode_in', 'incr', 'decr', 'string_of_format', 'format_of_string', - 'exit', 'at_exit' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('=<>+-*/.,:;~!#%^&|?[](){}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/chuck.lua b/dep/scintillua/scintillua-3.6.0/lexers/chuck.lua deleted file mode 100644 index 3efe7042..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/chuck.lua +++ /dev/null @@ -1,115 +0,0 @@ --------------------------------------------------------------------------------- --- The MIT License --- --- Copyright (c) 2010 Martin Morawetz --- --- Permission is hereby granted, free of charge, to any person obtaining a copy --- of this software and associated documentation files (the "Software"), to deal --- in the Software without restriction, including without limitation the rights --- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --- copies of the Software, and to permit persons to whom the Software is --- furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. --------------------------------------------------------------------------------- - --- Based on lexer code from Mitchell mitchell.att.foicica.com. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'chuck'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = P('L')^-1 * l.delimited_range("'", true) -local dq_str = P('L')^-1 * l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Constants. -local constant = token(l.CONSTANT, word_match{ - -- special values - 'false', 'maybe', 'me', 'null', 'NULL', 'pi', 'true' -}) - --- Special special value. -local now = token('now', P('now')) - --- Times. -local time = token('time', word_match{ - 'samp', 'ms', 'second', 'minute', 'hour', 'day', 'week' -}) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - -- Control structures. - 'break', 'continue', 'else', 'for', 'if', 'repeat', 'return', 'switch', - 'until', 'while', - -- Other chuck keywords. - 'function', 'fun', 'spork', 'const', 'new' -}) - --- Classes. -local class = token(l.CLASS, word_match{ - -- Class keywords. - 'class', 'extends', 'implements', 'interface', 'private', 'protected', - 'public', 'pure', 'super', 'static', 'this' -}) - --- Types. -local types = token(l.TYPE, word_match{ - 'float', 'int', 'time', 'dur', 'void', 'same' -}) - --- Global ugens. -local ugen = token('ugen', word_match{'dac', 'adc', 'blackhole'}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}@')) - -M._rules = { - {'whitespace', ws}, - {'string', string}, - {'keyword', keyword}, - {'constant', constant}, - {'type', types}, - {'class', class}, - {'ugen', ugen}, - {'time', time}, - {'now', now}, - {'identifier', identifier}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._tokenstyles = { - ugen = l.STYLE_CONSTANT, - time = l.STYLE_NUMBER, - now = l.STYLE_CONSTANT..',bold' -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/cmake.lua b/dep/scintillua/scintillua-3.6.0/lexers/cmake.lua deleted file mode 100644 index fcc3493e..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/cmake.lua +++ /dev/null @@ -1,173 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- CMake LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'cmake'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range('"')) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'IF', 'ENDIF', 'FOREACH', 'ENDFOREACH', 'WHILE', 'ENDWHILE', 'ELSE', 'ELSEIF' -}, nil, true)) - --- Commands. -local command = token(l.FUNCTION, word_match({ - 'ADD_CUSTOM_COMMAND', 'ADD_CUSTOM_TARGET', 'ADD_DEFINITIONS', - 'ADD_DEPENDENCIES', 'ADD_EXECUTABLE', 'ADD_LIBRARY', 'ADD_SUBDIRECTORY', - 'ADD_TEST', 'AUX_SOURCE_DIRECTORY', 'BUILD_COMMAND', 'BUILD_NAME', - 'CMAKE_MINIMUM_REQUIRED', 'CONFIGURE_FILE', 'CREATE_TEST_SOURCELIST', - 'ENABLE_LANGUAGE', 'ENABLE_TESTING', 'ENDMACRO', 'EXECUTE_PROCESS', - 'EXEC_PROGRAM', 'EXPORT_LIBRARY_DEPENDENCIES', 'FILE', 'FIND_FILE', - 'FIND_LIBRARY', 'FIND_PACKAGE', 'FIND_PATH', 'FIND_PROGRAM', 'FLTK_WRAP_UI', - 'GET_CMAKE_PROPERTY', 'GET_DIRECTORY_PROPERTY', 'GET_FILENAME_COMPONENT', - 'GET_SOURCE_FILE_PROPERTY', 'GET_TARGET_PROPERTY', 'GET_TEST_PROPERTY', - 'INCLUDE', 'INCLUDE_DIRECTORIES', 'INCLUDE_EXTERNAL_MSPROJECT', - 'INCLUDE_REGULAR_EXPRESSION', 'INSTALL', 'INSTALL_FILES', 'INSTALL_PROGRAMS', - 'INSTALL_TARGETS', 'LINK_DIRECTORIES', 'LINK_LIBRARIES', 'LIST', 'LOAD_CACHE', - 'LOAD_COMMAND', 'MACRO', 'MAKE_DIRECTORY', 'MARK_AS_ADVANCED', 'MATH', - 'MESSAGE', 'OPTION', 'OUTPUT_REQUIRED_FILES', 'PROJECT', 'QT_WRAP_CPP', - 'QT_WRAP_UI', 'REMOVE', 'REMOVE_DEFINITIONS', 'SEPARATE_ARGUMENTS', 'SET', - 'SET_DIRECTORY_PROPERTIES', 'SET_SOURCE_FILES_PROPERTIES', - 'SET_TARGET_PROPERTIES', 'SET_TESTS_PROPERTIES', 'SITE_NAME', 'SOURCE_GROUP', - 'STRING', 'SUBDIRS', 'SUBDIR_DEPENDS', 'TARGET_LINK_LIBRARIES', 'TRY_COMPILE', - 'TRY_RUN', 'USE_MANGLED_MESA', 'UTILITY_SOURCE', 'VARIABLE_REQUIRES', - 'VTK_MAKE_INSTANTIATOR', 'VTK_WRAP_JAVA', 'VTK_WRAP_PYTHON', 'VTK_WRAP_TCL', - 'WRITE_FILE', -}, nil, true)) - --- Constants. -local constant = token(l.CONSTANT, word_match({ - 'BOOL', 'CACHE', 'FALSE', 'N', 'NO', 'ON', 'OFF', 'NOTFOUND', 'TRUE' -}, nil, true)) - --- Variables. -local variable = token(l.VARIABLE, word_match{ - 'APPLE', 'BORLAND', 'CMAKE_AR', 'CMAKE_BACKWARDS_COMPATIBILITY', - 'CMAKE_BASE_NAME', 'CMAKE_BINARY_DIR', 'CMAKE_BUILD_TOOL', 'CMAKE_BUILD_TYPE', - 'CMAKE_CACHEFILE_DIR', 'CMAKE_CACHE_MAJOR_VERSION', - 'CMAKE_CACHE_MINOR_VERSION', 'CMAKE_CACHE_RELEASE_VERSION', - 'CMAKE_CFG_INTDIR', 'CMAKE_COLOR_MAKEFILE', 'CMAKE_COMMAND', - 'CMAKE_COMPILER_IS_GNUCC', 'CMAKE_COMPILER_IS_GNUCC_RUN', - 'CMAKE_COMPILER_IS_GNUCXX', 'CMAKE_COMPILER_IS_GNUCXX_RUN', - 'CMAKE_CTEST_COMMAND', 'CMAKE_CURRENT_BINARY_DIR', 'CMAKE_CURRENT_SOURCE_DIR', - 'CMAKE_CXX_COMPILER', 'CMAKE_CXX_COMPILER_ARG1', 'CMAKE_CXX_COMPILER_ENV_VAR', - 'CMAKE_CXX_COMPILER_FULLPATH', 'CMAKE_CXX_COMPILER_LOADED', - 'CMAKE_CXX_COMPILER_WORKS', 'CMAKE_CXX_COMPILE_OBJECT', - 'CMAKE_CXX_CREATE_SHARED_LIBRARY', - 'CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS', - 'CMAKE_CXX_CREATE_SHARED_MODULE', 'CMAKE_CXX_CREATE_STATIC_LIBRARY', - 'CMAKE_CXX_FLAGS', 'CMAKE_CXX_FLAGS_DEBUG', 'CMAKE_CXX_FLAGS_DEBUG_INIT', - 'CMAKE_CXX_FLAGS_INIT', 'CMAKE_CXX_FLAGS_MINSIZEREL', - 'CMAKE_CXX_FLAGS_MINSIZEREL_INIT', 'CMAKE_CXX_FLAGS_RELEASE', - 'CMAKE_CXX_FLAGS_RELEASE_INIT', 'CMAKE_CXX_FLAGS_RELWITHDEBINFO', - 'CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT', 'CMAKE_CXX_IGNORE_EXTENSIONS', - 'CMAKE_CXX_INFORMATION_LOADED', 'CMAKE_CXX_LINKER_PREFERENCE', - 'CMAKE_CXX_LINK_EXECUTABLE', 'CMAKE_CXX_LINK_FLAGS', - 'CMAKE_CXX_OUTPUT_EXTENSION', 'CMAKE_CXX_SOURCE_FILE_EXTENSIONS', - 'CMAKE_C_COMPILER', 'CMAKE_C_COMPILER_ARG1', 'CMAKE_C_COMPILER_ENV_VAR', - 'CMAKE_C_COMPILER_FULLPATH', 'CMAKE_C_COMPILER_LOADED', - 'CMAKE_C_COMPILER_WORKS', 'CMAKE_C_COMPILE_OBJECT', - 'CMAKE_C_CREATE_SHARED_LIBRARY', - 'CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS', - 'CMAKE_C_CREATE_SHARED_MODULE', 'CMAKE_C_CREATE_STATIC_LIBRARY', - 'CMAKE_C_FLAGS', 'CMAKE_C_FLAGS_DEBUG', 'CMAKE_C_FLAGS_DEBUG_INIT', - 'CMAKE_C_FLAGS_INIT', 'CMAKE_C_FLAGS_MINSIZEREL', - 'CMAKE_C_FLAGS_MINSIZEREL_INIT', 'CMAKE_C_FLAGS_RELEASE', - 'CMAKE_C_FLAGS_RELEASE_INIT', 'CMAKE_C_FLAGS_RELWITHDEBINFO', - 'CMAKE_C_FLAGS_RELWITHDEBINFO_INIT', 'CMAKE_C_IGNORE_EXTENSIONS', - 'CMAKE_C_INFORMATION_LOADED', 'CMAKE_C_LINKER_PREFERENCE', - 'CMAKE_C_LINK_EXECUTABLE', 'CMAKE_C_LINK_FLAGS', 'CMAKE_C_OUTPUT_EXTENSION', - 'CMAKE_C_SOURCE_FILE_EXTENSIONS', 'CMAKE_DL_LIBS', 'CMAKE_EDIT_COMMAND', - 'CMAKE_EXECUTABLE_SUFFIX', 'CMAKE_EXE_LINKER_FLAGS', - 'CMAKE_EXE_LINKER_FLAGS_DEBUG', 'CMAKE_EXE_LINKER_FLAGS_MINSIZEREL', - 'CMAKE_EXE_LINKER_FLAGS_RELEASE', 'CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO', - 'CMAKE_FILES_DIRECTORY', 'CMAKE_FIND_APPBUNDLE', 'CMAKE_FIND_FRAMEWORK', - 'CMAKE_FIND_LIBRARY_PREFIXES', 'CMAKE_FIND_LIBRARY_SUFFIXES', - 'CMAKE_GENERATOR', 'CMAKE_HOME_DIRECTORY', 'CMAKE_INCLUDE_FLAG_C', - 'CMAKE_INCLUDE_FLAG_CXX', 'CMAKE_INCLUDE_FLAG_C_SEP', 'CMAKE_INIT_VALUE', - 'CMAKE_INSTALL_PREFIX', 'CMAKE_LIBRARY_PATH_FLAG', 'CMAKE_LINK_LIBRARY_FLAG', - 'CMAKE_LINK_LIBRARY_SUFFIX', 'CMAKE_MAJOR_VERSION', 'CMAKE_MAKE_PROGRAM', - 'CMAKE_MINOR_VERSION', 'CMAKE_MODULE_EXISTS', 'CMAKE_MODULE_LINKER_FLAGS', - 'CMAKE_MODULE_LINKER_FLAGS_DEBUG', 'CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL', - 'CMAKE_MODULE_LINKER_FLAGS_RELEASE', - 'CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO', - 'CMAKE_MacOSX_Content_COMPILE_OBJECT', 'CMAKE_NUMBER_OF_LOCAL_GENERATORS', - 'CMAKE_OSX_ARCHITECTURES', 'CMAKE_OSX_SYSROOT', 'CMAKE_PARENT_LIST_FILE', - 'CMAKE_PATCH_VERSION', 'CMAKE_PLATFORM_HAS_INSTALLNAME', - 'CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES', 'CMAKE_PLATFORM_ROOT_BIN', - 'CMAKE_PROJECT_NAME', 'CMAKE_RANLIB', 'CMAKE_ROOT', - 'CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS', - 'CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS', - 'CMAKE_SHARED_LIBRARY_CXX_FLAGS', 'CMAKE_SHARED_LIBRARY_C_FLAGS', - 'CMAKE_SHARED_LIBRARY_LINK_C_FLAGS', 'CMAKE_SHARED_LIBRARY_PREFIX', - 'CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG', - 'CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP', - 'CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG', 'CMAKE_SHARED_LIBRARY_SONAME_C_FLAG', - 'CMAKE_SHARED_LIBRARY_SUFFIX', 'CMAKE_SHARED_LINKER_FLAGS', - 'CMAKE_SHARED_LINKER_FLAGS_DEBUG', 'CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL', - 'CMAKE_SHARED_LINKER_FLAGS_RELEASE', - 'CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO', - 'CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS', 'CMAKE_SHARED_MODULE_CREATE_C_FLAGS', - 'CMAKE_SHARED_MODULE_PREFIX', 'CMAKE_SHARED_MODULE_SUFFIX', - 'CMAKE_SIZEOF_VOID_P', 'CMAKE_SKIP_RPATH', 'CMAKE_SOURCE_DIR', - 'CMAKE_STATIC_LIBRARY_PREFIX', 'CMAKE_STATIC_LIBRARY_SUFFIX', 'CMAKE_SYSTEM', - 'CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE', - 'CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE', 'CMAKE_SYSTEM_APPBUNDLE_PATH', - 'CMAKE_SYSTEM_FRAMEWORK_PATH', 'CMAKE_SYSTEM_INCLUDE_PATH', - 'CMAKE_SYSTEM_INFO_FILE', 'CMAKE_SYSTEM_LIBRARY_PATH', 'CMAKE_SYSTEM_LOADED', - 'CMAKE_SYSTEM_NAME', 'CMAKE_SYSTEM_PROCESSOR', 'CMAKE_SYSTEM_PROGRAM_PATH', - 'CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED', 'CMAKE_SYSTEM_VERSION', - 'CMAKE_UNAME', 'CMAKE_USE_RELATIVE_PATHS', 'CMAKE_VERBOSE_MAKEFILE', 'CYGWIN', - 'EXECUTABLE_OUTPUT_PATH', 'FORCE', 'HAVE_CMAKE_SIZEOF_VOID_P', - 'LIBRARY_OUTPUT_PATH', 'MACOSX_BUNDLE', 'MINGW', 'MSVC60', 'MSVC70', 'MSVC71', - 'MSVC80', 'MSVC', 'MSVC_IDE', 'PROJECT_BINARY_DIR', 'PROJECT_NAME', - 'PROJECT_SOURCE_DIR', 'PROJECT_BINARY_DIR', 'PROJECT_SOURCE_DIR', - 'RUN_CONFIGURE', 'UNIX', 'WIN32', '_CMAKE_OSX_MACHINE', - -- More variables. - 'LOCATION', 'TARGET', 'POST_BUILD', 'PRE_BUILD', 'ARGS' -} + P('$') * l.delimited_range('{}', false, true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, word_match({ - 'AND', 'COMMAND', 'DEFINED', 'DOC', 'EQUAL', 'EXISTS', 'GREATER', 'INTERNAL', - 'LESS', 'MATCHES', 'NAME', 'NAMES', 'NAME_WE', 'NOT', 'OR', 'PATH', 'PATHS', - 'PROGRAM', 'STREQUAL', 'STRGREATER', 'STRINGS', 'STRLESS' -}) + S('=(){}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'command', command}, - {'constant', constant}, - {'variable', variable}, - {'operator', operator}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, -} - -M._foldsymbols = { - _patterns = {'[A-Z]+', '[%(%){}]', '#'}, - [l.KEYWORD] = { - IF = 1, ENDIF = -1, FOREACH = 1, ENDFOREACH = -1, WHILE = 1, ENDWHILE = -1 - }, - [l.FUNCTION] = {MACRO = 1, ENDMACRO = -1}, - [l.OPERATOR] = {['('] = 1, [')'] = -1, ['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['#'] = l.fold_line_comments('#')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/coffeescript.lua b/dep/scintillua/scintillua-3.6.0/lexers/coffeescript.lua deleted file mode 100644 index b1c649ee..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/coffeescript.lua +++ /dev/null @@ -1,62 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- CoffeeScript LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, S = lpeg.P, lpeg.S - -local M = {_NAME = 'coffeescript'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local block_comment = '###' * (l.any - '###')^0 * P('###')^-1 -local line_comment = '#' * l.nonnewline_esc^0 -local comment = token(l.COMMENT, block_comment + line_comment) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local regex_str = #P('/') * l.last_char_includes('+-*%<>!=^&|?~:;,([{') * - l.delimited_range('/', true) * S('igm')^0 -local string = token(l.STRING, sq_str + dq_str) + token(l.REGEX, regex_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'all', 'and', 'bind', 'break', 'by', 'case', 'catch', 'class', 'const', - 'continue', 'default', 'delete', 'do', 'each', 'else', 'enum', 'export', - 'extends', 'false', 'for', 'finally', 'function', 'if', 'import', 'in', - 'instanceof', 'is', 'isnt', 'let', 'loop', 'native', 'new', 'no', 'not', 'of', - 'off', 'on', 'or', 'return', 'super', 'switch', 'then', 'this', 'throw', - 'true', 'try', 'typeof', 'unless', 'until', 'var', 'void', 'with', 'when', - 'while', 'yes' -}) - --- Fields: object properties and methods. -local field = token(l.FUNCTION, '.' * (S('_$') + l.alpha) * - (S('_$') + l.alnum)^0) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|?~:;,.()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'field', field}, - {'identifier', identifier}, - {'comment', comment}, - {'number', number}, - {'string', string}, - {'operator', operator}, -} - -M._FOLDBYINDENTATION = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/container.lua b/dep/scintillua/scintillua-3.6.0/lexers/container.lua deleted file mode 100644 index 6223f2eb..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/container.lua +++ /dev/null @@ -1,7 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Container LPeg lexer. --- This is SciTE's plain text lexer. - -local M = {_NAME = 'container'} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/context.lua b/dep/scintillua/scintillua-3.6.0/lexers/context.lua deleted file mode 100644 index 30ec1b0c..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/context.lua +++ /dev/null @@ -1,59 +0,0 @@ --- Copyright 2006-2013 Robert Gieseke. See LICENSE. --- ConTeXt LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'context'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '%' * l.nonnewline^0) - --- Commands. -local command = token(l.KEYWORD, '\\' * (l.alpha^1 + S('#$&~_^%{}'))) - --- Sections. -local section = token('section', '\\' * word_match{ - 'part', 'chapter', 'section', 'subsection', 'subsubsection', 'title', - 'subject', 'subsubject', 'subsubsubject' -}) - --- ConTeXt environments. -local environment = token('environment', '\\' * (P('start') + 'stop') * l.word) - --- Operators. -local operator = token(l.OPERATOR, S('$&#{}[]')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'environment', environment}, - {'section', section}, - {'keyword', command}, - {'operator', operator}, -} - -M._tokenstyles = { - environment = l.STYLE_KEYWORD, - section = l.STYLE_CLASS -} - -M._foldsymbols = { - _patterns = {'\\start', '\\stop', '[{}]', '%%'}, - ['environment'] = {['\\start'] = 1, ['\\stop'] = -1}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['%'] = l.fold_line_comments('%')} -} - --- Embedded Lua. -local luatex = l.load('lua') -local luatex_start_rule = #P('\\startluacode') * environment -local luatex_end_rule = #P('\\stopluacode') * environment -l.embed_lexer(M, luatex, luatex_start_rule, luatex_end_rule) - - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/cpp.lua b/dep/scintillua/scintillua-3.6.0/lexers/cpp.lua deleted file mode 100644 index 3d64c93c..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/cpp.lua +++ /dev/null @@ -1,87 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- C++ LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'cpp'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = P('L')^-1 * l.delimited_range("'", true) -local dq_str = P('L')^-1 * l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Preprocessor. -local preproc_word = word_match{ - 'define', 'elif', 'else', 'endif', 'error', 'if', 'ifdef', 'ifndef', 'import', - 'include', 'line', 'pragma', 'undef', 'using', 'warning' -} -local preproc = token(l.PREPROCESSOR, - l.starts_line('#') * S('\t ')^0 * preproc_word) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'asm', 'auto', 'break', 'case', 'catch', 'class', 'const', 'const_cast', - 'continue', 'default', 'delete', 'do', 'dynamic_cast', 'else', 'explicit', - 'export', 'extern', 'false', 'for', 'friend', 'goto', 'if', 'inline', - 'mutable', 'namespace', 'new', 'operator', 'private', 'protected', 'public', - 'register', 'reinterpret_cast', 'return', 'sizeof', 'static', 'static_cast', - 'switch', 'template', 'this', 'throw', 'true', 'try', 'typedef', 'typeid', - 'typename', 'using', 'virtual', 'volatile', 'while', - -- Operators - 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not', 'not_eq', 'or', 'or_eq', - 'xor', 'xor_eq', - -- C++11 - 'alignas', 'alignof', 'constexpr', 'decltype', 'final', 'noexcept', - 'override', 'static_assert', 'thread_local' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'bool', 'char', 'double', 'enum', 'float', 'int', 'long', 'short', 'signed', - 'struct', 'union', 'unsigned', 'void', 'wchar_t', - -- C++11 - 'char16_t', 'char32_t', 'nullptr' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|?~:;,.()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'preproc', preproc}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'%l+', '[{}]', '/%*', '%*/', '//'}, - [l.PREPROCESSOR] = { - region = 1, endregion = -1, - ['if'] = 1, ifdef = 1, ifndef = 1, endif = -1 - }, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/csharp.lua b/dep/scintillua/scintillua-3.6.0/lexers/csharp.lua deleted file mode 100644 index 6f7ab797..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/csharp.lua +++ /dev/null @@ -1,84 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- C# LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'csharp'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local ml_str = P('@')^-1 * l.delimited_range('"', false, true) -local string = token(l.STRING, sq_str + dq_str + ml_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * S('lLdDfFMm')^-1) - --- Preprocessor. -local preproc_word = word_match{ - 'define', 'elif', 'else', 'endif', 'error', 'if', 'line', 'undef', 'warning', - 'region', 'endregion' -} -local preproc = token(l.PREPROCESSOR, - l.starts_line('#') * S('\t ')^0 * preproc_word * - (l.nonnewline_esc^1 + l.space * l.nonnewline_esc^0)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'class', 'delegate', 'enum', 'event', 'interface', 'namespace', 'struct', - 'using', 'abstract', 'const', 'explicit', 'extern', 'fixed', 'implicit', - 'internal', 'lock', 'out', 'override', 'params', 'partial', 'private', - 'protected', 'public', 'ref', 'sealed', 'static', 'readonly', 'unsafe', - 'virtual', 'volatile', 'add', 'as', 'assembly', 'base', 'break', 'case', - 'catch', 'checked', 'continue', 'default', 'do', 'else', 'finally', 'for', - 'foreach', 'get', 'goto', 'if', 'in', 'is', 'new', 'remove', 'return', 'set', - 'sizeof', 'stackalloc', 'super', 'switch', 'this', 'throw', 'try', 'typeof', - 'unchecked', 'value', 'void', 'while', 'yield', - 'null', 'true', 'false' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'bool', 'byte', 'char', 'decimal', 'double', 'float', 'int', 'long', 'object', - 'operator', 'sbyte', 'short', 'string', 'uint', 'ulong', 'ushort' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('~!.,:;+-*/<>=\\^|&%?()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'preproc', preproc}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'%l+', '[{}]', '/%*', '%*/', '//'}, - [l.PREPROCESSOR] = { - region = 1, endregion = -1, - ['if'] = 1, ifdef = 1, ifndef = 1, endif = -1 - }, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/css.lua b/dep/scintillua/scintillua-3.6.0/lexers/css.lua deleted file mode 100644 index a753cc72..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/css.lua +++ /dev/null @@ -1,166 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- CSS LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V - -local M = {_NAME = 'css'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '/*' * (l.any - '*/')^0 * P('*/')^-1) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.digit^1) - --- Keywords. -local css1_property = word_match({ - 'color', 'background-color', 'background-image', 'background-repeat', - 'background-attachment', 'background-position', 'background', 'font-family', - 'font-style', 'font-variant', 'font-weight', 'font-size', 'font', - 'word-spacing', 'letter-spacing', 'text-decoration', 'vertical-align', - 'text-transform', 'text-align', 'text-indent', 'line-height', 'margin-top', - 'margin-right', 'margin-bottom', 'margin-left', 'margin', 'padding-top', - 'padding-right', 'padding-bottom', 'padding-left', 'padding', - 'border-top-width', 'border-right-width', 'border-bottom-width', - 'border-left-width', 'border-width', 'border-top', 'border-right', - 'border-bottom', 'border-left', 'border', 'border-color', 'border-style', - 'width', 'height', 'float', 'clear', 'display', 'white-space', - 'list-style-type', 'list-style-image', 'list-style-position', 'list-style' -}, '-') -local css1_value = word_match({ - 'auto', 'none', 'normal', 'italic', 'oblique', 'small-caps', 'bold', 'bolder', - 'lighter', 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', - 'xx-large', 'larger', 'smaller', 'transparent', 'repeat', 'repeat-x', - 'repeat-y', 'no-repeat', 'scroll', 'fixed', 'top', 'bottom', 'left', 'center', - 'right', 'justify', 'both', 'underline', 'overline', 'line-through', 'blink', - 'baseline', 'sub', 'super', 'text-top', 'middle', 'text-bottom', 'capitalize', - 'uppercase', 'lowercase', 'thin', 'medium', 'thick', 'dotted', 'dashed', - 'solid', 'double', 'groove', 'ridge', 'inset', 'outset', 'block', 'inline', - 'list-item', 'pre', 'no-wrap', 'inside', 'outside', 'disc', 'circle', - 'square', 'decimal', 'lower-roman', 'upper-roman', 'lower-alpha', - 'upper-alpha', 'aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', 'lime', - 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', - 'yellow' -}, '-') -local css2_property = word_match({ - 'border-top-color', 'border-right-color', 'border-bottom-color', - 'border-left-color', 'border-color', 'border-top-style', 'border-right-style', - 'border-bottom-style', 'border-left-style', 'border-style', 'top', 'right', - 'bottom', 'left', 'position', 'z-index', 'direction', 'unicode-bidi', - 'min-width', 'max-width', 'min-height', 'max-height', 'overflow', 'clip', - 'visibility', 'content', 'quotes', 'counter-reset', 'counter-increment', - 'marker-offset', 'size', 'marks', 'page-break-before', 'page-break-after', - 'page-break-inside', 'page', 'orphans', 'widows', 'font-stretch', - 'font-size-adjust', 'unicode-range', 'units-per-em', 'src', 'panose-1', - 'stemv', 'stemh', 'slope', 'cap-height', 'x-height', 'ascent', 'descent', - 'widths', 'bbox', 'definition-src', 'baseline', 'centerline', 'mathline', - 'topline', 'text-shadow', 'caption-side', 'table-layout', 'border-collapse', - 'border-spacing', 'empty-cells', 'speak-header', 'cursor', 'outline', - 'outline-width', 'outline-style', 'outline-color', 'volume', 'speak', - 'pause-before', 'pause-after', 'pause', 'cue-before', 'cue-after', 'cue', - 'play-during', 'azimuth', 'elevation', 'speech-rate', 'voice-family', 'pitch', - 'pitch-range', 'stress', 'richness', 'speak-punctuation', 'speak-numeral' -}, '-') -local css2_value = word_match({ - 'inherit', 'run-in', 'compact', 'marker', 'table', 'inline-table', - 'table-row-group', 'table-header-group', 'table-footer-group', 'table-row', - 'table-column-group', 'table-column', 'table-cell', 'table-caption', 'static', - 'relative', 'absolute', 'fixed', 'ltr', 'rtl', 'embed', 'bidi-override', - 'visible', 'hidden', 'scroll', 'collapse', 'open-quote', 'close-quote', - 'no-open-quote', 'no-close-quote', 'decimal-leading-zero', 'lower-greek', - 'lower-latin', 'upper-latin', 'hebrew', 'armenian', 'georgian', - 'cjk-ideographic', 'hiragana', 'katakana', 'hiragana-iroha', 'katakana-iroha', - 'landscape', 'portrait', 'crop', 'cross', 'always', 'avoid', 'wider', - 'narrower', 'ultra-condensed', 'extra-condensed', 'condensed', - 'semi-condensed', 'semi-expanded', 'expanded', 'extra-expanded', - 'ultra-expanded', 'caption', 'icon', 'menu', 'message-box', 'small-caption', - 'status-bar', 'separate', 'show', 'hide', 'once', 'crosshair', 'default', - 'pointer', 'move', 'text', 'wait', 'help', 'e-resize', 'ne-resize', - 'nw-resize', 'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', - 'ActiveBorder', 'ActiveCaption', 'AppWorkspace', 'Background', 'ButtonFace', - 'ButtonHighlight', 'ButtonShadow', 'InactiveCaptionText', 'ButtonText', - 'CaptionText', 'GrayText', 'Highlight', 'HighlightText', 'InactiveBorder', - 'InactiveCaption', 'InfoBackground', 'InfoText', 'Menu', 'MenuText', - 'Scrollbar', 'ThreeDDarkShadow', 'ThreeDFace', 'ThreeDHighlight', - 'ThreeDLightShadow', 'ThreeDShadow', 'Window', 'WindowFrame', 'WindowText', - 'silent', 'x-soft', 'soft', 'medium', 'loud', 'x-loud', 'spell-out', 'mix', - 'left-side', 'far-left', 'center-left', 'center-right', 'far-right', - 'right-side', 'behind', 'leftwards', 'rightwards', 'below', 'level', 'above', - 'higher', 'lower', 'x-slow', 'slow', 'medium', 'fast', 'x-fast', 'faster', - 'slower', 'male', 'female', 'child', 'x-low', 'low', 'high', 'x-high', 'code', - 'digits', 'continous' -}, '-') -local property = token(l.KEYWORD, css1_property + css2_property) -local value = token('value', css1_value + css2_value) -local keyword = property + value - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.alpha * (l.alnum + S('_-'))^0) - --- Operators. -local operator = token(l.OPERATOR, S('~!#*>+=|.,:;()[]{}')) - --- At rule. -local at_rule = token('at_rule', P('@') * word_match{ - 'charset', 'font-face', 'media', 'page', 'import' -}) - --- Colors. -local xdigit = l.xdigit -local hex_color = '#' * xdigit * xdigit * xdigit * (xdigit * xdigit * xdigit)^-1 -local color_name = word_match{ - 'aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', - 'olive', 'orange', 'purple', 'red', 'silver', 'teal', 'white', 'yellow' -} -local color = token('color', hex_color + color_name) - --- Pseudo. -local pseudo = token(l.CONSTANT, word_match({ - -- Pseudo elements. - 'first-line', 'first-letter', 'before', 'after', - -- Pseudo classes. - 'first-child', 'link', 'visited', 'hover', 'active', 'focus', 'lang', -}, '-')) - --- Units. -local unit = token('unit', word_match{ - 'em', 'ex', 'px', 'pt', 'pc', 'in', 'ft', 'mm', 'cm', 'kHz', 'Hz', 'deg', - 'rad', 'grad', 'ms', 's' -} + '%') - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'pseudo', pseudo}, - {'color', color}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number * unit^-1}, - {'operator', operator}, - {'at_rule', at_rule}, -} - -M._tokenstyles = { - unit = l.STYLE_LABEL, - value = l.STYLE_CONSTANT, - color = l.STYLE_NUMBER, - at_rule = l.STYLE_PREPROCESSOR -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/cuda.lua b/dep/scintillua/scintillua-3.6.0/lexers/cuda.lua deleted file mode 100644 index 0cf22e62..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/cuda.lua +++ /dev/null @@ -1,92 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- CUDA LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S -local table = _G.table - -local M = {_NAME = 'cuda'} - --- Whitespace -local ws = token(l.WHITESPACE, l.space^1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - '__global__', '__host__', '__device__', '__constant__', '__shared__' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - -- Atom. - 'atomicAdd', 'atomicAnd', 'atomicCAS', 'atomicDec', 'atomicExch', 'atomicInc', - 'atomicMax', 'atomicMin', 'atomicOr', 'atomicSub', 'atomicXor', - -- Dev. - 'tex1D', 'tex1Dfetch', 'tex2D', '__float_as_int', '__int_as_float', - '__float2int_rn', '__float2int_rz', '__float2int_ru', '__float2int_rd', - '__float2uint_rn', '__float2uint_rz', '__float2uint_ru', '__float2uint_rd', - '__int2float_rn', '__int2float_rz', '__int2float_ru', '__int2float_rd', - '__uint2float_rn', '__uint2float_rz', '__uint2float_ru', '__uint2float_rd', - '__fadd_rz', '__fmul_rz', '__fdividef', '__mul24', '__umul24', '__mulhi', - '__umulhi', '__mul64hi', '__umul64hi', 'min', 'umin', 'fminf', 'fmin', 'max', - 'umax', 'fmaxf', 'fmax', 'abs', 'fabsf', 'fabs', 'sqrtf', 'sqrt', 'sinf', - '__sinf', 'sin', 'cosf', '__cosf', 'cos', 'sincosf', '__sincosf', 'expf', - '__expf', 'exp', 'logf', '__logf', 'log', - -- Runtime. - 'cudaBindTexture', 'cudaBindTextureToArray', 'cudaChooseDevice', - 'cudaConfigureCall', 'cudaCreateChannelDesc', 'cudaD3D10GetDevice', - 'cudaD3D10MapResources', 'cudaD3D10RegisterResource', - 'cudaD3D10ResourceGetMappedArray', 'cudaD3D10ResourceGetMappedPitch', - 'cudaD3D10ResourceGetMappedPointer', 'cudaD3D10ResourceGetMappedSize', - 'cudaD3D10ResourceGetSurfaceDimensions', 'cudaD3D10ResourceSetMapFlags', - 'cudaD3D10SetDirect3DDevice', 'cudaD3D10UnmapResources', - 'cudaD3D10UnregisterResource', 'cudaD3D9GetDevice', - 'cudaD3D9GetDirect3DDevice', 'cudaD3D9MapResources', - 'cudaD3D9RegisterResource', 'cudaD3D9ResourceGetMappedArray', - 'cudaD3D9ResourceGetMappedPitch', 'cudaD3D9ResourceGetMappedPointer', - 'cudaD3D9ResourceGetMappedSize', 'cudaD3D9ResourceGetSurfaceDimensions', - 'cudaD3D9ResourceSetMapFlags', 'cudaD3D9SetDirect3DDevice', - 'cudaD3D9UnmapResources', 'cudaD3D9UnregisterResource', 'cudaEventCreate', - 'cudaEventDestroy', 'cudaEventElapsedTime', 'cudaEventQuery', - 'cudaEventRecord', 'cudaEventSynchronize', 'cudaFree', 'cudaFreeArray', - 'cudaFreeHost', 'cudaGetChannelDesc', 'cudaGetDevice', 'cudaGetDeviceCount', - 'cudaGetDeviceProperties', 'cudaGetErrorString', 'cudaGetLastError', - 'cudaGetSymbolAddress', 'cudaGetSymbolSize', 'cudaGetTextureAlignmentOffset', - 'cudaGetTextureReference', 'cudaGLMapBufferObject', - 'cudaGLRegisterBufferObject', 'cudaGLSetGLDevice', 'cudaGLUnmapBufferObject', - 'cudaGLUnregisterBufferObject', 'cudaLaunch', 'cudaMalloc', 'cudaMalloc3D', - 'cudaMalloc3DArray', 'cudaMallocArray', 'cudaMallocHost', 'cudaMallocPitch', - 'cudaMemcpy', 'cudaMemcpy2D', 'cudaMemcpy2DArrayToArray', - 'cudaMemcpy2DFromArray', 'cudaMemcpy2DToArray', 'cudaMemcpy3D', - 'cudaMemcpyArrayToArray', 'cudaMemcpyFromArray', 'cudaMemcpyFromSymbol', - 'cudaMemcpyToArray', 'cudaMemcpyToSymbol', 'cudaMemset', 'cudaMemset2D', - 'cudaMemset3D', 'cudaSetDevice', 'cudaSetupArgument', 'cudaStreamCreate', - 'cudaStreamDestroy', 'cudaStreamQuery', 'cudaStreamSynchronize', - 'cudaThreadExit', 'cudaThreadSynchronize', 'cudaUnbindTexture' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'uint', 'int1', 'uint1', 'int2', 'uint2', 'int3', 'uint3', 'int4', 'uint4', - 'float1', 'float2', 'float3', 'float4', 'char1', 'char2', 'char3', 'char4', - 'uchar1', 'uchar2', 'uchar3', 'uchar4', 'short1', 'short2', 'short3', - 'short4', 'dim1', 'dim2', 'dim3', 'dim4' -}) - --- Variables. -local variable = token(l.VARIABLE, word_match{ - 'gridDim', 'blockIdx', 'blockDim', 'threadIdx' -}) - --- Extend cpp lexer to include CUDA elements. -local cpp = l.load('cpp') -local _rules = cpp._rules -_rules[1] = {'whitespace', ws} -table.insert(_rules, 2, {'cuda_keyword', keyword}) -table.insert(_rules, 3, {'cuda_function', func}) -table.insert(_rules, 4, {'cuda_type', type}) -table.insert(_rules, 5, {'cuda_variable', variable}) -M._rules = _rules -M._foldsymbols = cpp._foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/dart.lua b/dep/scintillua/scintillua-3.6.0/lexers/dart.lua deleted file mode 100644 index c2371289..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/dart.lua +++ /dev/null @@ -1,77 +0,0 @@ --- Dart LPeg lexer. --- Written by Brian Schott (@Hackerpilot on Github). - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'dart'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local nested_comment = l.nested_pair('/*', '*/') -local comment = token(l.COMMENT, line_comment + nested_comment) - --- Strings. -local sq_str = S('r')^-1 * l.delimited_range("'", true) -local dq_str = S('r')^-1 * l.delimited_range('"', true) -local sq_str_multiline = S('r')^-1 * l.delimited_range('"""') -local dq_str_multiline = S('r')^-1 * l.delimited_range("''' ") -local string = token(l.STRING, - sq_str + dq_str + sq_str_multiline + dq_str_multiline) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.hex_num)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'assert', 'break', 'case', 'catch', 'class', 'const', 'continue', 'default', - 'do', 'else', 'enum', 'extends', 'false', 'final' , 'finally', 'for', 'if', - 'in', 'is', 'new', 'null', 'rethrow', 'return', 'super', 'switch', 'this', - 'throw', 'true', 'try', 'var', 'void', 'while', 'with', -}) - -local builtin_identifiers = token(l.CONSTANT, word_match{ - 'abstract', 'as', 'dynamic', 'export', 'external', 'factory', 'get', - 'implements', 'import', 'library', 'operator', 'part', 'set', 'static', - 'typedef' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('#?=!<>+-*$/%&|^~.,;()[]{}')) - --- Preprocs. -local annotation = token('annotation', '@' * l.word^1) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'constant', builtin_identifiers}, - {'string', string}, - {'identifier', identifier}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, - {'annotation', annotation}, -} - -M._tokenstyles = { - annotation = l.STYLE_PREPROCESSOR, -} - -M._foldsymbols = { - _patterns = {'[{}]', '/[*+]', '[*+]/', '//'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = { - ['/*'] = 1, ['*/'] = -1, ['/+'] = 1, ['+/'] = -1, - ['//'] = l.fold_line_comments('//') - } -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/desktop.lua b/dep/scintillua/scintillua-3.6.0/lexers/desktop.lua deleted file mode 100644 index 267f3664..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/desktop.lua +++ /dev/null @@ -1,62 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Desktop Entry LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'desktop'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range('"')) - --- Group headers. -local group_header = l.starts_line(token(l.STRING, - l.delimited_range('[]', false, true))) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{'true', 'false'}) - --- Locales. -local locale = token(l.CLASS, l.delimited_range('[]', false, true)) - --- Keys. -local key = token(l.VARIABLE, word_match{ - 'Type', 'Version', 'Name', 'GenericName', 'NoDisplay', 'Comment', 'Icon', - 'Hidden', 'OnlyShowIn', 'NotShowIn', 'TryExec', 'Exec', 'Exec', 'Path', - 'Terminal', 'MimeType', 'Categories', 'StartupNotify', 'StartupWMClass', 'URL' -}) - --- Field codes. -local code = l.token(l.CONSTANT, P('%') * S('fFuUdDnNickvm')) - --- Identifiers. -local identifier = l.token(l.IDENTIFIER, l.alpha * (l.alnum + S('_-'))^0) - --- Operators. -local operator = token(l.OPERATOR, S('=')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'key', key}, - {'identifier', identifier}, - {'group_header', group_header}, - {'locale', locale}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'code', code}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/diff.lua b/dep/scintillua/scintillua-3.6.0/lexers/diff.lua deleted file mode 100644 index 53b7f17f..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/diff.lua +++ /dev/null @@ -1,44 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Diff LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'diff'} - --- Text, separators, and file headers. -local index = token(l.COMMENT, 'Index: ' * l.any^0 * P(-1)) -local separator = token(l.COMMENT, ('---' + P('*')^4 + P('=')^1) * l.space^0 * - -1) -local header = token('header', (P('*** ') + '--- ' + '+++ ') * l.any^1) - --- Location. -local location = token(l.NUMBER, ('@@' + l.digit^1 + '****') * l.any^1) - --- Additions, deletions, and changes. -local addition = token('addition', S('>+') * l.any^0) -local deletion = token('deletion', S('<-') * l.any^0) -local change = token('change', '! ' * l.any^0) - -M._rules = { - {'index', index}, - {'separator', separator}, - {'header', header}, - {'location', location}, - {'addition', addition}, - {'deletion', deletion}, - {'change', change}, - {'any_line', token('default', l.any^1)}, -} - -M._tokenstyles = { - header = l.STYLE_COMMENT, - addition = 'fore:$(color.green)', - deletion = 'fore:$(color.red)', - change = 'fore:$(color.yellow)' -} - -M._LEXBYLINE = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/django.lua b/dep/scintillua/scintillua-3.6.0/lexers/django.lua deleted file mode 100644 index 13a53417..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/django.lua +++ /dev/null @@ -1,77 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Django LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V - -local M = {_NAME = 'django'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '{#' * (l.any - l.newline - '#}')^0 * - P('#}')^-1) - --- Strings. -local string = token(l.STRING, l.delimited_range('"', false, true)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'as', 'block', 'blocktrans', 'by', 'endblock', 'endblocktrans', 'comment', - 'endcomment', 'cycle', 'date', 'debug', 'else', 'extends', 'filter', - 'endfilter', 'firstof', 'for', 'endfor', 'if', 'endif', 'ifchanged', - 'endifchanged', 'ifnotequal', 'endifnotequal', 'in', 'load', 'not', 'now', - 'or', 'parsed', 'regroup', 'ssi', 'trans', 'with', 'widthratio' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'add', 'addslashes', 'capfirst', 'center', 'cut', 'date', 'default', - 'dictsort', 'dictsortreversed', 'divisibleby', 'escape', 'filesizeformat', - 'first', 'fix_ampersands', 'floatformat', 'get_digit', 'join', 'length', - 'length_is', 'linebreaks', 'linebreaksbr', 'linenumbers', 'ljust', 'lower', - 'make_list', 'phone2numeric', 'pluralize', 'pprint', 'random', 'removetags', - 'rjust', 'slice', 'slugify', 'stringformat', 'striptags', 'time', 'timesince', - 'title', 'truncatewords', 'unordered_list', 'upper', 'urlencode', 'urlize', - 'urlizetrunc', 'wordcount', 'wordwrap', 'yesno', -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S(':,.|')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'operator', operator}, -} - --- Embedded in HTML. -local html = l.load('html') - --- Embedded Django. -local django_start_rule = token('django_tag', '{' * S('{%')) -local django_end_rule = token('django_tag', S('%}') * '}') -l.embed_lexer(html, M, django_start_rule, django_end_rule) --- Modify HTML patterns to embed Django. -html._RULES['comment'] = html._RULES['comment'] + comment - -M._tokenstyles = { - django_tag = l.STYLE_EMBEDDED -} - -local _foldsymbols = html._foldsymbols -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '{[%%{]' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '[%%}]}' -_foldsymbols.django_tag = {['{{'] = 1, ['}}'] = -1, ['{%'] = 1, ['%}'] = -1} -M._foldsymbols = _foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/dot.lua b/dep/scintillua/scintillua-3.6.0/lexers/dot.lua deleted file mode 100644 index 5ff845b5..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/dot.lua +++ /dev/null @@ -1,71 +0,0 @@ --- Copyright 2006-2013 Brian "Sir Alaran" Schott. See LICENSE. --- Dot LPeg lexer. --- Based off of lexer code by Mitchell. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'dot'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.digit^1 + l.float) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'graph', 'node', 'edge', 'digraph', 'fontsize', 'rankdir', - 'fontname', 'shape', 'label', 'arrowhead', 'arrowtail', 'arrowsize', - 'color', 'comment', 'constraint', 'decorate', 'dir', 'headlabel', 'headport', - 'headURL', 'labelangle', 'labeldistance', 'labelfloat', 'labelfontcolor', - 'labelfontname', 'labelfontsize', 'layer', 'lhead', 'ltail', 'minlen', - 'samehead', 'sametail', 'style', 'taillabel', 'tailport', 'tailURL', 'weight', - 'subgraph' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'box', 'polygon', 'ellipse', 'circle', 'point', 'egg', 'triangle', - 'plaintext', 'diamond', 'trapezium', 'parallelogram', 'house', 'pentagon', - 'hexagon', 'septagon', 'octagon', 'doublecircle', 'doubleoctagon', - 'tripleoctagon', 'invtriangle', 'invtrapezium', 'invhouse', 'Mdiamond', - 'Msquare', 'Mcircle', 'rect', 'rectangle', 'none', 'note', 'tab', 'folder', - 'box3d', 'record' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('->()[]{};')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'number', number}, - {'string', string}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/eiffel.lua b/dep/scintillua/scintillua-3.6.0/lexers/eiffel.lua deleted file mode 100644 index 871ed8f4..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/eiffel.lua +++ /dev/null @@ -1,69 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Eiffel LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'eiffel'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '--' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'alias', 'all', 'and', 'as', 'check', 'class', 'creation', 'debug', - 'deferred', 'do', 'else', 'elseif', 'end', 'ensure', 'expanded', 'export', - 'external', 'feature', 'from', 'frozen', 'if', 'implies', 'indexing', 'infix', - 'inherit', 'inspect', 'invariant', 'is', 'like', 'local', 'loop', 'not', - 'obsolete', 'old', 'once', 'or', 'prefix', 'redefine', 'rename', 'require', - 'rescue', 'retry', 'select', 'separate', 'then', 'undefine', 'until', - 'variant', 'when', 'xor', - 'current', 'false', 'precursor', 'result', 'strip', 'true', 'unique', 'void' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'character', 'string', 'bit', 'boolean', 'integer', 'real', 'none', 'any' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('=!<>+-/*%&|^~.,:;?()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[a-z]+', '%-%-'}, - [l.KEYWORD] = { - check = 1, debug = 1, deferred = 1, ['do'] = 1, from = 1, ['if'] = 1, - inspect = 1, once = 1, class = function(text, pos, line, s) - return line:find('deferred%s+class') and 0 or 1 - end, ['end'] = -1 - }, - [l.COMMENT] = {['--'] = l.fold_line_comments('--')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/elixir.lua b/dep/scintillua/scintillua-3.6.0/lexers/elixir.lua deleted file mode 100644 index 015f29b8..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/elixir.lua +++ /dev/null @@ -1,122 +0,0 @@ --- Copyright 2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Contributed by Richard Philips. --- Elixer LPeg lexer. - -local l = lexer -local token, style, color, word_match = l.token, l.style, l.color, l.word_match -local B, P, R, S = lpeg.B, lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'elixir'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline_esc^0) - --- Strings. -local dq_str = l.delimited_range('"', false) -local triple_dq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 -local string = token(l.STRING, triple_dq_str + dq_str) - --- Numbers -local dec = l.digit * (l.digit + P("_"))^0 -local bin = '0b' * S('01')^1 -local oct = '0o' * R('07')^1 -local integer = bin + l.hex_num + oct + dec -local float = l.digit^1 * P(".") * l.digit^1 * S("eE") * - (S('+-')^-1 * l.digit^1)^-1 -local number_token = B(1 - R('az', 'AZ', '__')) * - (S('+-')^-1) * token(l.NUMBER, (float + integer)) - --- Keywords. -local keyword_token = token(l.KEYWORD, word_match{ - "is_atom", "is_binary", "is_bitstring", "is_boolean", "is_float", - "is_function", "is_integer", "is_list", "is_map", "is_number", "is_pid", - "is_port", "is_record", "is_reference", "is_tuple", "is_exception", "case", - "when", "cond", "for", "if", "unless", "try", "receive", "send", "exit", - "raise", "throw", "after", "rescue", "catch", "else", "do", "end", "quote", - "unquote", "super", "import", "require", "alias", "use", "self" -}) - --- Functions -local function_token = token(l.FUNCTION, word_match{ - "defstruct", "defrecordp", "defrecord", "defprotocol", "defp", - "defoverridable", "defmodule", "defmacrop", "defmacro", "defimpl", - "defexception", "defdelegate", "defcallback", "def" -}) - --- Sigils -local sigil11 = P("~") * S("CRSW") * l.delimited_range('<>', false, true) -local sigil12 = P("~") * S("CRSW") * l.delimited_range('{}', false, true) -local sigil13 = P("~") * S("CRSW") * l.delimited_range('[]', false, true) -local sigil14 = P("~") * S("CRSW") * l.delimited_range('()', false, true) -local sigil15 = P("~") * S("CRSW") * l.delimited_range('|', false, true) -local sigil16 = P("~") * S("CRSW") * l.delimited_range('/', false, true) -local sigil17 = P("~") * S("CRSW") * l.delimited_range('"', false, true) -local sigil18 = P("~") * S("CRSW") * l.delimited_range("'", false, true) -local sigil19 = P("~") * S("CRSW") * '"""' * (l.any - '"""')^0 * P('"""')^-1 -local sigil10 = P("~") * S("CRSW") * "'''" * (l.any - "'''")^0 * P("'''")^-1 -local sigil21 = P("~") * S("crsw") * l.delimited_range('<>', false, false) -local sigil22 = P("~") * S("crsw") * l.delimited_range('{}', false, false) -local sigil23 = P("~") * S("crsw") * l.delimited_range('[]', false, false) -local sigil24 = P("~") * S("crsw") * l.delimited_range('()', false, false) -local sigil25 = P("~") * S("crsw") * l.delimited_range('|', false, false) -local sigil26 = P("~") * S("crsw") * l.delimited_range('/', false, false) -local sigil27 = P("~") * S("crsw") * l.delimited_range('"', false, false) -local sigil28 = P("~") * S("crsw") * l.delimited_range("'", false, false) -local sigil29 = P("~") * S("csrw") * '"""' * (l.any - '"""')^0 * P('"""')^-1 -local sigil20 = P("~") * S("csrw") * "'''" * (l.any - "'''")^0 * P("'''")^-1 -local sigil_token = token(l.REGEX, sigil10 + sigil19 + sigil11 + sigil12 + - sigil13 + sigil14 + sigil15 + sigil16 + - sigil17 + sigil18 + sigil20 + sigil29 + - sigil21 + sigil22 + sigil23 + sigil24 + - sigil25 + sigil26 + sigil27 + sigil28) -local sigiladdon_token = token(l.EMBEDDED, R('az', 'AZ')^0) - --- Attributes -local attribute_token = token(l.LABEL, B(1 - R('az', 'AZ', '__')) * P('@') * - R('az','AZ') * R('az','AZ','09','__')^0) - --- Booleans -local boolean_token = token(l.NUMBER, - P(':')^-1 * word_match{"true", "false", "nil"}) - --- Identifiers -local identifier = token(l.IDENTIFIER, R('az', '__') * - R('az', 'AZ', '__', '09')^0 * S('?!')^-1) - --- Atoms -local atom1 = B(1 - P(':')) * P(':') * dq_str -local atom2 = B(1 - P(':')) * P(':') * R('az', 'AZ') * - R('az', 'AZ', '__', '@@', '09')^0 * S('?!')^-1 -local atom3 = B(1 - R('az', 'AZ', '__', '09', '::')) * - R('AZ') * R('az', 'AZ', '__', '@@', '09')^0 * S('?!')^-1 -local atom_token = token(l.CONSTANT, atom1 + atom2 + atom3) - --- Operators -local operator1 = word_match{"and", "or", "not", "when", "xor", "in"} -local operator2 = P('!==') + '!=' + '!' + '=~' + '===' + '==' + '=' + '<<<' + - '<<' + '<=' + '<-' + '<' + '>>>' + '>>' + '>=' + '>' + '->' + - '--' + '-' + '++' + '+' + '&&&' + '&&' + '&' + '|||' + '||' + - '|>' + '|' + '..' + '.' + '^^^' + '^' + '\\\\' + '::' + '*' + - '/' + '~~~' + '@' -local operator_token = token(l.OPERATOR, operator1 + operator2) - -M._rules = { - {'sigil', sigil_token * sigiladdon_token}, - {'atom', atom_token}, - {'string', string}, - {'comment', comment}, - {'attribute', attribute_token}, - {'boolean', boolean_token}, - {'function', function_token}, - {'keyword', keyword_token}, - {'operator', operator_token}, - {'identifier', identifier}, - {'number', number_token}, -} - -M._FOLDBYINDENTATION = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/erlang.lua b/dep/scintillua/scintillua-3.6.0/lexers/erlang.lua deleted file mode 100644 index 73321fa1..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/erlang.lua +++ /dev/null @@ -1,100 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Erlang LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'erlang'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '%' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"') -local literal = '$' * l.any * l.alnum^0 -local string = token(l.STRING, sq_str + dq_str + literal) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'after', 'begin', 'case', 'catch', 'cond', 'end', 'fun', 'if', 'let', 'of', - 'query', 'receive', 'when', - -- Operators. - 'div', 'rem', 'or', 'xor', 'bor', 'bxor', 'bsl', 'bsr', 'and', 'band', 'not', - 'bnot', - 'badarg', 'nocookie', 'false', 'true' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'abs', 'alive', 'apply', 'atom_to_list', 'binary_to_list', 'binary_to_term', - 'concat_binary', 'date', 'disconnect_node', 'element', 'erase', 'exit', - 'float', 'float_to_list', 'get', 'get_keys', 'group_leader', 'halt', 'hd', - 'integer_to_list', 'is_alive', 'length', 'link', 'list_to_atom', - 'list_to_binary', 'list_to_float', 'list_to_integer', 'list_to_pid', - 'list_to_tuple', 'load_module', 'make_ref', 'monitor_node', 'node', 'nodes', - 'now', 'open_port', 'pid_to_list', 'process_flag', 'process_info', 'process', - 'put', 'register', 'registered', 'round', 'self', 'setelement', 'size', - 'spawn', 'spawn_link', 'split_binary', 'statistics', 'term_to_binary', - 'throw', 'time', 'tl', 'trunc', 'tuple_to_list', 'unlink', 'unregister', - 'whereis', - -- Others. - 'atom', 'binary', 'constant', 'function', 'integer', 'list', 'number', 'pid', - 'ports', 'port_close', 'port_info', 'reference', 'record', - -- Erlang:. - 'check_process_code', 'delete_module', 'get_cookie', 'hash', 'math', - 'module_loaded', 'preloaded', 'processes', 'purge_module', 'set_cookie', - 'set_node', - -- Math. - 'acos', 'asin', 'atan', 'atan2', 'cos', 'cosh', 'exp', 'log', 'log10', 'pi', - 'pow', 'power', 'sin', 'sinh', 'sqrt', 'tan', 'tanh' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('-<>.;=/|#+*:,?!()[]{}')) - --- Directives. -local directive = token('directive', '-' * word_match{ - 'author', 'compile', 'copyright', 'define', 'doc', 'else', 'endif', 'export', - 'file', 'ifdef', 'ifndef', 'import', 'include_lib', 'include', 'module', - 'record', 'undef' -}) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'identifier', identifier}, - {'directive', directive}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._tokenstyles = { - directive = l.STYLE_PREPROCESSOR -} - -M._foldsymbols = { - _patterns = {'[a-z]+', '[%(%)%[%]{}]', '%%'}, - [l.KEYWORD] = { - case = 1, fun = 1, ['if'] = 1, query = 1, receive = 1, ['end'] = -1 - }, - [l.OPERATOR] = { - ['('] = 1, [')'] = -1, ['['] = 1, [']'] = -1, ['{'] = 1, ['}'] = -1 - }, - [l.COMMENT] = {['%'] = l.fold_line_comments('%')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/fish.lua b/dep/scintillua/scintillua-3.6.0/lexers/fish.lua deleted file mode 100644 index 9142d600..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/fish.lua +++ /dev/null @@ -1,76 +0,0 @@ --- Copyright 2015 Jason Schindler. See LICENSE. --- Fish (http://fishshell.com/) script LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'fish'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- shebang -local shebang = token('shebang', '#!/' * l.nonnewline^0) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", false, true) -local dq_str = l.delimited_range('"') - -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'alias', 'and', 'begin', 'bg', 'bind', 'block', 'break', 'breakpoint', - 'builtin', 'case', 'cd', 'command', 'commandline', 'complete', 'contains', - 'continue', 'count', 'dirh', 'dirs', 'echo', 'else', 'emit', 'end', 'eval', - 'exec', 'exit', 'fg', 'fish', 'fish_config', 'fish_indent', 'fish_pager', - 'fish_prompt', 'fish_right_prompt', 'fish_update_completions', 'fishd', 'for', - 'funced', 'funcsave', 'function', 'functions', 'help', 'history', 'if', 'in', - 'isatty', 'jobs', 'math', 'mimedb', 'nextd', 'not', 'open', 'or', 'popd', - 'prevd', 'psub', 'pushd', 'pwd', 'random', 'read', 'return', 'set', - 'set_color', 'source', 'status', 'switch', 'test', 'trap', 'type', 'ulimit', - 'umask', 'vared', 'while' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Variables. -local variable = token(l.VARIABLE, - '$' * l.word + '$' * l.delimited_range('{}', true, true)) - --- Operators. -local operator = token(l.OPERATOR, S('=!<>+-/*^&|~.,:;?()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'shebang', shebang}, - {'keyword', keyword}, - {'identifier', identifier}, - {'variable', variable}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._tokenstyles = { - shebang = l.STYLE_LABEL -} - -M._foldsymbols = { - _patterns = {'%l+'}, - [l.KEYWORD] = { - begin = 1, ['for'] = 1, ['function'] = 1, ['if'] = 1, switch = 1, - ['while'] = 1, ['end'] = -1 - } -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/forth.lua b/dep/scintillua/scintillua-3.6.0/lexers/forth.lua deleted file mode 100644 index 450f528e..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/forth.lua +++ /dev/null @@ -1,57 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Forth LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'forth'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = S('|\\') * l.nonnewline^0 -local block_comment = '(*' * (l.any - '*)')^0 * P('*)')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local s_str = 's' * l.delimited_range('"', true, true) -local dot_str = '.' * l.delimited_range('"', true, true) -local f_str = 'f' * l.delimited_range('"', true, true) -local dq_str = l.delimited_range('"', true, true) -local string = token(l.STRING, s_str + dot_str + f_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, P('-')^-1 * l.digit^1 * (S('./') * l.digit^1)^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'swap', 'drop', 'dup', 'nip', 'over', 'rot', '-rot', '2dup', '2drop', '2over', - '2swap', '>r', 'r>', - 'and', 'or', 'xor', '>>', '<<', 'not', 'negate', 'mod', '/mod', '1+', '1-', - 'base', 'hex', 'decimal', 'binary', 'octal', - '@', '!', 'c@', 'c!', '+!', 'cell+', 'cells', 'char+', 'chars', - 'create', 'does>', 'variable', 'variable,', 'literal', 'last', '1,', '2,', - '3,', ',', 'here', 'allot', 'parse', 'find', 'compile', - -- Operators. - 'if', '=if', 'if', '<>if', 'then', 'repeat', 'until', 'forth', 'macro' -}, '2><1-@!+3,=')) - --- Identifiers. -local identifier = token(l.IDENTIFIER, (l.alnum + S('+-*=<>.?/\'%,_$'))^1) - --- Operators. -local operator = token(l.OPERATOR, S(':;<>+*-/()[]')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'string', string}, - {'identifier', identifier}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/fortran.lua b/dep/scintillua/scintillua-3.6.0/lexers/fortran.lua deleted file mode 100644 index c85cbff5..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/fortran.lua +++ /dev/null @@ -1,91 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Fortran LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'fortran'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local c_comment = l.starts_line(S('Cc')) * l.nonnewline^0 -local d_comment = l.starts_line(S('Dd')) * l.nonnewline^0 -local ex_comment = l.starts_line('!') * l.nonnewline^0 -local ast_comment = l.starts_line('*') * l.nonnewline^0 -local line_comment = '!' * l.nonnewline^0 -local comment = token(l.COMMENT, c_comment + d_comment + ex_comment + - ast_comment + line_comment) - --- Strings. -local sq_str = l.delimited_range("'", true, true) -local dq_str = l.delimited_range('"', true, true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * -l.alpha) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'include', 'program', 'module', 'subroutine', 'function', 'contains', 'use', - 'call', 'return', - -- Statements. - 'case', 'select', 'default', 'continue', 'cycle', 'do', 'while', 'else', 'if', - 'elseif', 'then', 'elsewhere', 'end', 'endif', 'enddo', 'forall', 'where', - 'exit', 'goto', 'pause', 'stop', - -- Operators. - '.not.', '.and.', '.or.', '.xor.', '.eqv.', '.neqv.', '.eq.', '.ne.', '.gt.', - '.ge.', '.lt.', '.le.', - -- Logical. - '.false.', '.true.' -}, '.', true)) - --- Functions. -local func = token(l.FUNCTION, word_match({ - -- I/O. - 'backspace', 'close', 'endfile', 'inquire', 'open', 'print', 'read', 'rewind', - 'write', 'format', - -- Type conversion, utility, and math. - 'aimag', 'aint', 'amax0', 'amin0', 'anint', 'ceiling', 'cmplx', 'conjg', - 'dble', 'dcmplx', 'dfloat', 'dim', 'dprod', 'float', 'floor', 'ifix', 'imag', - 'int', 'logical', 'modulo', 'nint', 'real', 'sign', 'sngl', 'transfer', - 'zext', 'abs', 'acos', 'aimag', 'aint', 'alog', 'alog10', 'amax0', 'amax1', - 'amin0', 'amin1', 'amod', 'anint', 'asin', 'atan', 'atan2', 'cabs', 'ccos', - 'char', 'clog', 'cmplx', 'conjg', 'cos', 'cosh', 'csin', 'csqrt', 'dabs', - 'dacos', 'dasin', 'datan', 'datan2', 'dble', 'dcos', 'dcosh', 'ddim', 'dexp', - 'dim', 'dint', 'dlog', 'dlog10', 'dmax1', 'dmin1', 'dmod', 'dnint', 'dprod', - 'dreal', 'dsign', 'dsin', 'dsinh', 'dsqrt', 'dtan', 'dtanh', 'exp', 'float', - 'iabs', 'ichar', 'idim', 'idint', 'idnint', 'ifix', 'index', 'int', 'isign', - 'len', 'lge', 'lgt', 'lle', 'llt', 'log', 'log10', 'max', 'max0', 'max1', - 'min', 'min0', 'min1', 'mod', 'nint', 'real', 'sign', 'sin', 'sinh', 'sngl', - 'sqrt', 'tan', 'tanh' -}, nil, true)) - --- Types. -local type = token(l.TYPE, word_match({ - 'implicit', 'explicit', 'none', 'data', 'parameter', 'allocate', - 'allocatable', 'allocated', 'deallocate', 'integer', 'real', 'double', - 'precision', 'complex', 'logical', 'character', 'dimension', 'kind', -}, nil, true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.alnum^1) - --- Operators. -local operator = token(l.OPERATOR, S('<>=&+-/*,()')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'keyword', keyword}, - {'function', func}, - {'type', type}, - {'number', number}, - {'identifier', identifier}, - {'string', string}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/fsharp.lua b/dep/scintillua/scintillua-3.6.0/lexers/fsharp.lua deleted file mode 100644 index b620552d..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/fsharp.lua +++ /dev/null @@ -1,76 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- F# LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'fsharp'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = P('//') * l.nonnewline^0 -local block_comment = l.nested_pair('(*', '*)') -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer * S('uUlL')^-1)) - --- Preprocessor. -local preproc_word = word_match{ - 'ifndef', 'ifdef', 'if', 'else', 'endif', 'light', 'region', 'endregion' -} -local preproc = token(l.PREPROCESSOR, - l.starts_line('#') * S('\t ')^0 * preproc_word * - (l.nonnewline_esc^1 + l.space * l.nonnewline_esc^0)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'abstract', 'and', 'as', 'assert', 'asr', 'begin', 'class', 'default', - 'delegate', 'do', 'done', 'downcast', 'downto', 'else', 'end', 'enum', - 'exception', 'false', 'finaly', 'for', 'fun', 'function', 'if', 'in', - 'iherit', 'interface', 'land', 'lazy', 'let', 'lor', 'lsl', 'lsr', 'lxor', - 'match', 'member', 'mod', 'module', 'mutable', 'namespace', 'new', 'null', - 'of', 'open', 'or', 'override', 'sig', 'static', 'struct', 'then', 'to', - 'true', 'try', 'type', 'val', 'when', 'inline', 'upcast', 'while', 'with', - 'async', 'atomic', 'break', 'checked', 'component', 'const', 'constructor', - 'continue', 'eager', 'event', 'external', 'fixed', 'functor', 'include', - 'method', 'mixin', 'process', 'property', 'protected', 'public', 'pure', - 'readonly', 'return', 'sealed', 'switch', 'virtual', 'void', 'volatile', - 'where', - -- Booleans. - 'true', 'false' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'bool', 'byte', 'sbyte', 'int16', 'uint16', 'int', 'uint32', 'int64', - 'uint64', 'nativeint', 'unativeint', 'char', 'string', 'decimal', 'unit', - 'void', 'float32', 'single', 'float', 'double' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('=<>+-*/^.,:;~!@#%^&|?[](){}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/gap.lua b/dep/scintillua/scintillua-3.6.0/lexers/gap.lua deleted file mode 100644 index 78a4b779..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/gap.lua +++ /dev/null @@ -1,56 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Gap LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'gap'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.digit^1 * -l.alpha) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'and', 'break', 'continue', 'do', 'elif', 'else', 'end', 'fail', 'false', - 'fi', 'for', 'function', 'if', 'in', 'infinity', 'local', 'not', 'od', 'or', - 'rec', 'repeat', 'return', 'then', 'true', 'until', 'while' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('*+-,./:;<=>~^#()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[a-z]+', '#'}, - [l.KEYWORD] = { - ['function'] = 1, ['end'] = -1, ['do'] = 1, od = -1, ['if'] = 1, fi = -1, - ['repeat'] = 1, ['until'] = -1 - }, - [l.COMMENT] = {['#'] = l.fold_line_comments('#')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/gettext.lua b/dep/scintillua/scintillua-3.6.0/lexers/gettext.lua deleted file mode 100644 index d63ef41c..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/gettext.lua +++ /dev/null @@ -1,39 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Gettext LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'gettext'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * S(': .~') * l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range('"', true)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'msgid', 'msgid_plural', 'msgstr', 'fuzzy', 'c-format', 'no-c-format' -}, '-', true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Variables. -local variable = token(l.VARIABLE, S('%$@') * l.word) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'string', string}, - {'keyword', keyword}, - {'identifier', identifier}, - {'variable', variable}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/glsl.lua b/dep/scintillua/scintillua-3.6.0/lexers/glsl.lua deleted file mode 100644 index 65f83033..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/glsl.lua +++ /dev/null @@ -1,132 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- GLSL LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S -local table = _G.table - -local M = {_NAME = 'glsl'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'attribute', 'const', 'in', 'inout', 'out', 'uniform', 'varying', 'invariant', - 'centroid', 'flat', 'smooth', 'noperspective', 'layout', 'patch', 'sample', - 'subroutine', 'lowp', 'mediump', 'highp', 'precision', - -- Macros. - '__VERSION__', '__LINE__', '__FILE__', -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'radians', 'degrees', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'sinh', - 'cosh', 'tanh', 'asinh', 'acosh', 'atanh', 'pow', 'exp', 'log', 'exp2', - 'log2', 'sqrt', 'inversesqrt', 'abs', 'sign', 'floor', 'trunc', 'round', - 'roundEven', 'ceil', 'fract', 'mod', 'modf', 'min', 'max', 'clamp', 'mix', - 'step', 'smoothstep', 'isnan', 'isinf', 'floatBitsToInt', 'floatBitsToUint', - 'intBitsToFloat', 'uintBitsToFloat', 'fma', 'frexp', 'ldexp', 'packUnorm2x16', - 'packUnorm4x8', 'packSnorm4x8', 'unpackUnorm2x16', 'unpackUnorm4x8', - 'unpackSnorm4x8', 'packDouble2x32', 'unpackDouble2x32', 'length', 'distance', - 'dot', 'cross', 'normalize', 'ftransform', 'faceforward', 'reflect', - 'refract', 'matrixCompMult', 'outerProduct', 'transpose', 'determinant', - 'inverse', 'lessThan', 'lessThanEqual', 'greaterThan', 'greaterThanEqual', - 'equal', 'notEqual', 'any', 'all', 'not', 'uaddCarry', 'usubBorrow', - 'umulExtended', 'imulExtended', 'bitfieldExtract', 'bitfildInsert', - 'bitfieldReverse', 'bitCount', 'findLSB', 'findMSB', 'textureSize', - 'textureQueryLOD', 'texture', 'textureProj', 'textureLod', 'textureOffset', - 'texelFetch', 'texelFetchOffset', 'textureProjOffset', 'textureLodOffset', - 'textureProjLod', 'textureProjLodOffset', 'textureGrad', 'textureGradOffset', - 'textureProjGrad', 'textureProjGradOffset', 'textureGather', - 'textureGatherOffset', 'texture1D', 'texture2D', 'texture3D', 'texture1DProj', - 'texture2DProj', 'texture3DProj', 'texture1DLod', 'texture2DLod', - 'texture3DLod', 'texture1DProjLod', 'texture2DProjLod', 'texture3DProjLod', - 'textureCube', 'textureCubeLod', 'shadow1D', 'shadow2D', 'shadow1DProj', - 'shadow2DProj', 'shadow1DLod', 'shadow2DLod', 'shadow1DProjLod', - 'shadow2DProjLod', 'dFdx', 'dFdy', 'fwidth', 'interpolateAtCentroid', - 'interpolateAtSample', 'interpolateAtOffset', 'noise1', 'noise2', 'noise3', - 'noise4', 'EmitStreamVertex', 'EndStreamPrimitive', 'EmitVertex', - 'EndPrimitive', 'barrier' -}) - --- Types. -local type = token(l.TYPE, - S('bdiu')^-1 * 'vec' * R('24') + - P('d')^-1 * 'mat' * R('24') * ('x' * R('24')^-1) + - S('iu')^-1 * 'sampler' * R('13') * 'D' + - 'sampler' * R('12') * 'D' * P('Array')^-1 * 'Shadow' + - S('iu')^-1 * 'sampler' * (R('12') * 'DArray' + word_match{ - 'Cube', '2DRect', 'Buffer', '2DMS', '2DMSArray', - '2DMSCubeArray' - }) + - word_match{ - 'samplerCubeShadow', 'sampler2DRectShadow', - 'samplerCubeArrayShadow' - }) - --- Variables. -local variable = token(l.VARIABLE, word_match{ - 'gl_VertexID', 'gl_InstanceID', 'gl_Position', 'gl_PointSize', - 'gl_ClipDistance', 'gl_PrimitiveIDIn', 'gl_InvocationID', 'gl_PrimitiveID', - 'gl_Layer', 'gl_PatchVerticesIn', 'gl_TessLevelOuter', 'gl_TessLevelInner', - 'gl_TessCoord', 'gl_FragCoord', 'gl_FrontFacing', 'gl_PointCoord', - 'gl_SampleID', 'gl_SamplePosition', 'gl_FragColor', 'gl_FragData', - 'gl_FragDepth', 'gl_SampleMask', 'gl_ClipVertex', 'gl_FrontColor', - 'gl_BackColor', 'gl_FrontSecondaryColor', 'gl_BackSecondaryColor', - 'gl_TexCoord', 'gl_FogFragCoord', 'gl_Color', 'gl_SecondaryColor', - 'gl_Normal', 'gl_Vertex', 'gl_MultiTexCoord0', 'gl_MultiTexCoord1', - 'gl_MultiTexCoord2', 'gl_MultiTexCoord3', 'gl_MultiTexCoord4', - 'gl_MultiTexCoord5', 'gl_MultiTexCoord6', 'gl_MultiTexCoord7', 'gl_FogCoord' -}) - --- Constants. -local constant = token(l.CONSTANT, word_match{ - 'gl_MaxVertexAttribs', 'gl_MaxVertexUniformComponents', 'gl_MaxVaryingFloats', - 'gl_MaxVaryingComponents', 'gl_MaxVertexOutputComponents', - 'gl_MaxGeometryInputComponents', 'gl_MaxGeometryOutputComponents', - 'gl_MaxFragmentInputComponents', 'gl_MaxVertexTextureImageUnits', - 'gl_MaxCombinedTextureImageUnits', 'gl_MaxTextureImageUnits', - 'gl_MaxFragmentUniformComponents', 'gl_MaxDrawBuffers', 'gl_MaxClipDistances', - 'gl_MaxGeometryTextureImageUnits', 'gl_MaxGeometryOutputVertices', - 'gl_MaxGeometryTotalOutputComponents', 'gl_MaxGeometryUniformComponents', - 'gl_MaxGeometryVaryingComponents', 'gl_MaxTessControlInputComponents', - 'gl_MaxTessControlOutputComponents', 'gl_MaxTessControlTextureImageUnits', - 'gl_MaxTessControlUniformComponents', - 'gl_MaxTessControlTotalOutputComponents', - 'gl_MaxTessEvaluationInputComponents', 'gl_MaxTessEvaluationOutputComponents', - 'gl_MaxTessEvaluationTextureImageUnits', - 'gl_MaxTessEvaluationUniformComponents', 'gl_MaxTessPatchComponents', - 'gl_MaxPatchVertices', 'gl_MaxTessGenLevel', 'gl_MaxTextureUnits', - 'gl_MaxTextureCoords', 'gl_MaxClipPlanes', - - 'gl_DepthRange', 'gl_ModelViewMatrix', 'gl_ProjectionMatrix', - 'gl_ModelViewProjectionMatrix', 'gl_TextureMatrix', 'gl_NormalMatrix', - 'gl_ModelViewMatrixInverse', 'gl_ProjectionMatrixInverse', - 'gl_ModelViewProjectionMatrixInverse', 'gl_TextureMatrixInverse', - 'gl_ModelViewMatrixTranspose', 'gl_ProjectionMatrixTranspose', - 'gl_ModelViewProjectionMatrixTranspose', 'gl_TextureMatrixTranspose', - 'gl_ModelViewMatrixInverseTranspose', 'gl_ProjectionMatrixInverseTranspose', - 'gl_ModelViewProjectionMatrixInverseTranspose', - 'gl_TextureMatrixInverseTranspose', 'gl_NormalScale', 'gl_ClipPlane', - 'gl_Point', 'gl_FrontMaterial', 'gl_BackMaterial', 'gl_LightSource', - 'gl_LightModel', 'gl_FrontLightModelProduct', 'gl_BackLightModelProduct', - 'gl_FrontLightProduct', 'gl_BackLightProduct', 'gl_TextureEnvColor', - 'gl_EyePlaneS', 'gl_EyePlaneT', 'gl_EyePlaneR', 'gl_EyePlaneQ', - 'gl_ObjectPlaneS', 'gl_ObjectPlaneT', 'gl_ObjectPlaneR', 'gl_ObjectPlaneQ', - 'gl_Fog' -}) - --- Extend cpp lexer to include GLSL elements. -local cpp = l.load('cpp') -local _rules = cpp._rules -_rules[1] = {'whitespace', ws} -table.insert(_rules, 2, {'glsl_keyword', keyword}) -table.insert(_rules, 3, {'glsl_function', func}) -table.insert(_rules, 4, {'glsl_type', type}) -table.insert(_rules, 5, {'glsl_variable', variable}) -M._rules = _rules -M._foldsymbols = cpp._foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/gnuplot.lua b/dep/scintillua/scintillua-3.6.0/lexers/gnuplot.lua deleted file mode 100644 index 8561812f..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/gnuplot.lua +++ /dev/null @@ -1,80 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Gnuplot LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'gnuplot'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local bk_str = l.delimited_range('[]', true) -local bc_str = l.delimited_range('{}', true) -local string = token(l.STRING, sq_str + dq_str + bk_str + bc_str) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'cd', 'call', 'clear', 'exit', 'fit', 'help', 'history', 'if', 'load', - 'pause', 'plot', 'using', 'with', 'index', 'every', 'smooth', 'thru', 'print', - 'pwd', 'quit', 'replot', 'reread', 'reset', 'save', 'set', 'show', 'unset', - 'shell', 'splot', 'system', 'test', 'unset', 'update' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'abs', 'acos', 'acosh', 'arg', 'asin', 'asinh', 'atan', 'atan2', 'atanh', - 'besj0', 'besj1', 'besy0', 'besy1', 'ceil', 'cos', 'cosh', 'erf', 'erfc', - 'exp', 'floor', 'gamma', 'ibeta', 'inverf', 'igamma', 'imag', 'invnorm', - 'int', 'lambertw', 'lgamma', 'log', 'log10', 'norm', 'rand', 'real', 'sgn', - 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'column', 'defined', 'tm_hour', - 'tm_mday', 'tm_min', 'tm_mon', 'tm_sec', 'tm_wday', 'tm_yday', 'tm_year', - 'valid' -}) - --- Variables. -local variable = token(l.VARIABLE, word_match{ - 'angles', 'arrow', 'autoscale', 'bars', 'bmargin', 'border', 'boxwidth', - 'clabel', 'clip', 'cntrparam', 'colorbox', 'contour', 'datafile ', - 'decimalsign', 'dgrid3d', 'dummy', 'encoding', 'fit', 'fontpath', 'format', - 'functions', 'function', 'grid', 'hidden3d', 'historysize', 'isosamples', - 'key', 'label', 'lmargin', 'loadpath', 'locale', 'logscale', 'mapping', - 'margin', 'mouse', 'multiplot', 'mx2tics', 'mxtics', 'my2tics', 'mytics', - 'mztics', 'offsets', 'origin', 'output', 'parametric', 'plot', 'pm3d', - 'palette', 'pointsize', 'polar', 'print', 'rmargin', 'rrange', 'samples', - 'size', 'style', 'surface', 'terminal', 'tics', 'ticslevel', 'ticscale', - 'timestamp', 'timefmt', 'title', 'tmargin', 'trange', 'urange', 'variables', - 'version', 'view', 'vrange', 'x2data', 'x2dtics', 'x2label', 'x2mtics', - 'x2range', 'x2tics', 'x2zeroaxis', 'xdata', 'xdtics', 'xlabel', 'xmtics', - 'xrange', 'xtics', 'xzeroaxis', 'y2data', 'y2dtics', 'y2label', 'y2mtics', - 'y2range', 'y2tics', 'y2zeroaxis', 'ydata', 'ydtics', 'ylabel', 'ymtics', - 'yrange', 'ytics', 'yzeroaxis', 'zdata', 'zdtics', 'cbdata', 'cbdtics', - 'zero', 'zeroaxis', 'zlabel', 'zmtics', 'zrange', 'ztics', 'cblabel', - 'cbmtics', 'cbrange', 'cbtics' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('-+~!$*%=<>&|^?:()')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'variable', variable}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/go.lua b/dep/scintillua/scintillua-3.6.0/lexers/go.lua deleted file mode 100644 index 9cc79840..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/go.lua +++ /dev/null @@ -1,78 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Go LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'go'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline^0 -local block_comment = '/*' * (l.any - '*/')^0 * '*/' -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local raw_str = l.delimited_range('`', false, true) -local string = token(l.STRING, sq_str + dq_str + raw_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * P('i')^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'break', 'case', 'chan', 'const', 'continue', 'default', 'defer', 'else', - 'fallthrough', 'for', 'func', 'go', 'goto', 'if', 'import', 'interface', - 'map', 'package', 'range', 'return', 'select', 'struct', 'switch', 'type', - 'var' -}) - --- Constants. -local constant = token(l.CONSTANT, word_match{ - 'true', 'false', 'iota', 'nil' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'bool', 'byte', 'complex64', 'complex128', 'error', 'float32', 'float64', - 'int', 'int8', 'int16', 'int32', 'int64', 'rune', 'string', 'uint', 'uint8', - 'uint16', 'uint32', 'uint64', 'uintptr' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'append', 'cap', 'close', 'complex', 'copy', 'delete', 'imag', 'len', 'make', - 'new', 'panic', 'print', 'println', 'real', 'recover' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-*/%&|^<>=!:;.,()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'constant', constant}, - {'type', type}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/groovy.lua b/dep/scintillua/scintillua-3.6.0/lexers/groovy.lua deleted file mode 100644 index 92013a7f..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/groovy.lua +++ /dev/null @@ -1,89 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Groovy LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'groovy'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local triple_sq_str = "'''" * (l.any - "'''")^0 * P("'''")^-1 -local triple_dq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 -local regex_str = #P('/') * l.last_char_includes('=~|!<>+-*?&,:;([{') * - l.delimited_range('/', true) -local string = token(l.STRING, triple_sq_str + triple_dq_str + sq_str + - dq_str) + - token(l.REGEX, regex_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'abstract', 'break', 'case', 'catch', 'continue', 'default', 'do', 'else', - 'extends', 'final', 'finally', 'for', 'if', 'implements', 'instanceof', - 'native', 'new', 'private', 'protected', 'public', 'return', 'static', - 'switch', 'synchronized', 'throw', 'throws', 'transient', 'try', 'volatile', - 'while', 'strictfp', 'package', 'import', 'as', 'assert', 'def', 'mixin', - 'property', 'test', 'using', 'in', - 'false', 'null', 'super', 'this', 'true', 'it' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'abs', 'any', 'append', 'asList', 'asWritable', 'call', 'collect', - 'compareTo', 'count', 'div', 'dump', 'each', 'eachByte', 'eachFile', - 'eachLine', 'every', 'find', 'findAll', 'flatten', 'getAt', 'getErr', 'getIn', - 'getOut', 'getText', 'grep', 'immutable', 'inject', 'inspect', 'intersect', - 'invokeMethods', 'isCase', 'join', 'leftShift', 'minus', 'multiply', - 'newInputStream', 'newOutputStream', 'newPrintWriter', 'newReader', - 'newWriter', 'next', 'plus', 'pop', 'power', 'previous', 'print', 'println', - 'push', 'putAt', 'read', 'readBytes', 'readLines', 'reverse', 'reverseEach', - 'round', 'size', 'sort', 'splitEachLine', 'step', 'subMap', 'times', - 'toInteger', 'toList', 'tokenize', 'upto', 'waitForOrKill', 'withPrintWriter', - 'withReader', 'withStream', 'withWriter', 'withWriterAppend', 'write', - 'writeLine' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'boolean', 'byte', 'char', 'class', 'double', 'float', 'int', 'interface', - 'long', 'short', 'void' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('=~|!<>+-/*?&.,:;()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'type', type}, - {'identifier', identifier}, - {'comment', comment}, - {'string', string}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/gtkrc.lua b/dep/scintillua/scintillua-3.6.0/lexers/gtkrc.lua deleted file mode 100644 index 8aec8c37..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/gtkrc.lua +++ /dev/null @@ -1,71 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Gtkrc LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'gtkrc'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.digit^1 * ('.' * l.digit^1)^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'binding', 'class', 'include', 'module_path', 'pixmap_path', 'im_module_file', - 'style', 'widget', 'widget_class' -}) - --- Variables. -local variable = token(l.VARIABLE, word_match{ - 'bg', 'fg', 'base', 'text', 'xthickness', 'ythickness', 'bg_pixmap', 'font', - 'fontset', 'font_name', 'stock', 'color', 'engine' -}) - --- States. -local state = token(l.CONSTANT, word_match{ - 'ACTIVE', 'SELECTED', 'NORMAL', 'PRELIGHT', 'INSENSITIVE', 'TRUE', 'FALSE' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'mix', 'shade', 'lighter', 'darker' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.alpha * (l.alnum + S('_-'))^0) - --- Operators. -local operator = token(l.OPERATOR, S(':=,*()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'variable', variable}, - {'state', state}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '#'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['#'] = l.fold_line_comments('#')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/haskell.lua b/dep/scintillua/scintillua-3.6.0/lexers/haskell.lua deleted file mode 100644 index 46b54342..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/haskell.lua +++ /dev/null @@ -1,60 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Haskell LPeg lexer. --- Modified by Alex Suraci. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'haskell'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '--' * l.nonnewline_esc^0 -local block_comment = '{-' * (l.any - '-}')^0 * P('-}')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local string = token(l.STRING, l.delimited_range('"')) - --- Chars. -local char = token(l.STRING, l.delimited_range("'", true)) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'case', 'class', 'data', 'default', 'deriving', 'do', 'else', 'if', 'import', - 'in', 'infix', 'infixl', 'infixr', 'instance', 'let', 'module', 'newtype', - 'of', 'then', 'type', 'where', '_', 'as', 'qualified', 'hiding' -}) - --- Identifiers. -local word = (l.alnum + S("._'#"))^0 -local identifier = token(l.IDENTIFIER, (l.alpha + '_') * word) - --- Operators. -local op = l.punct - S('()[]{}') -local operator = token(l.OPERATOR, op) - --- Types & type constructors. -local constructor = token(l.TYPE, (l.upper * word) + (P(":") * (op^1 - P(":")))) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', constructor}, - {'identifier', identifier}, - {'string', string}, - {'char', char}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._FOLDBYINDENTATION = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/html.lua b/dep/scintillua/scintillua-3.6.0/lexers/html.lua deleted file mode 100644 index 6034702d..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/html.lua +++ /dev/null @@ -1,166 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- HTML LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V - -local M = {_NAME = 'html'} - -case_insensitive_tags = true - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '')^0 * P('-->')^-1) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local string = #S('\'"') * l.last_char_includes('=') * - token(l.STRING, sq_str + dq_str) - --- TODO: performance is terrible on large files. -local in_tag = P(function(input, index) - local before = input:sub(1, index - 1) - local s, e = before:find('<[^>]-$'), before:find('>[^<]-$') - if s and e then return s > e and index or nil end - if s then return index end - return input:find('^[^<]->', index) and index or nil -end) - --- Numbers. -local number = #l.digit * l.last_char_includes('=') * - token(l.NUMBER, l.digit^1 * P('%')^-1) --* in_tag - --- Elements. -local known_element = token('element', '<' * P('/')^-1 * word_match({ - 'a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', - 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', - 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', - 'decorator', 'del', 'details', 'dfn', 'div', 'dl', 'dt', 'element', 'em', - 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', - 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hr', 'html', 'i', 'iframe', 'img', - 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', - 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', - 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', - 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', - 'select', 'shadow', 'small', 'source', 'spacer', 'spacer', 'span', 'strong', - 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', - 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', - 'var', 'video', 'wbr' -}, nil, case_insensitive_tags)) -local unknown_element = token('unknown_element', '<' * P('/')^-1 * l.word) -local element = known_element + unknown_element - --- Attributes. -local known_attribute = token('attribute', word_match({ - 'accept', 'accept-charset', 'accesskey', 'action', 'align', 'alt', 'async', - 'autocomplete', 'autofocus', 'autoplay', 'bgcolor', 'border', 'buffered', - 'challenge', 'charset', 'checked', 'cite', 'class', 'code', 'codebase', - 'color', 'cols', 'colspan', 'content', 'contenteditable', 'contextmenu', - 'controls', 'coords', 'data', 'data-', 'datetime', 'default', 'defer', 'dir', - 'dirname', 'disabled', 'download', 'draggable', 'dropzone', 'enctype', 'for', - 'form', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', - 'http-equiv', 'icon', 'id', 'ismap', 'itemprop', 'keytype', 'kind', 'label', - 'lang', 'language', 'list', 'loop', 'low', 'manifest', 'max', 'maxlength', - 'media', 'method', 'min', 'multiple', 'name', 'novalidate', 'open', 'optimum', - 'pattern', 'ping', 'placeholder', 'poster', 'preload', 'pubdate', - 'radiogroup', 'readonly', 'rel', 'required', 'reversed', 'role', 'rows', - 'rowspan', 'sandbox', 'spellcheck', 'scope', 'scoped', 'seamless', 'selected', - 'shape', 'size', 'sizes', 'span', 'src', 'srcdoc', 'srclang', 'start', - 'step', 'style', 'summary', 'tabindex', 'target', 'title', 'type', 'usemap', - 'value', 'width', 'wrap' -}, '-', case_insensitive_tags) + ((P('data-') + 'aria-') * (l.alnum + '-')^1)) -local unknown_attribute = token('unknown_attribute', l.word) -local attribute = (known_attribute + unknown_attribute) * #(l.space^0 * '=') - --- Closing tags. -local tag_close = token('element', P('/')^-1 * '>') - --- Equals. -local equals = token(l.OPERATOR, '=') --* in_tag - --- Entities. -local entity = token('entity', '&' * (l.any - l.space - ';')^1 * ';') - --- Doctype. -local doctype = token('doctype', '')^1 * '>') - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'doctype', doctype}, - {'element', element}, - {'tag_close', tag_close}, - {'attribute', attribute}, --- {'equals', equals}, - {'string', string}, - {'number', number}, - {'entity', entity}, -} - -M._tokenstyles = { - element = l.STYLE_KEYWORD, - unknown_element = l.STYLE_KEYWORD..',italics', - attribute = l.STYLE_TYPE, - unknown_attribute = l.STYLE_TYPE..',italics', - entity = l.STYLE_OPERATOR, - doctype = l.STYLE_COMMENT -} - --- Tags that start embedded languages. -M.embed_start_tag = element * - (ws^1 * attribute * ws^0 * equals * ws^0 * string)^0 * - ws^0 * tag_close -M.embed_end_tag = element * tag_close - --- Embedded CSS. -local css = l.load('css') -local style_element = word_match({'style'}, nil, case_insensitive_tags) -local css_start_rule = #(P('<') * style_element * - ('>' + P(function(input, index) - if input:find('^%s+type%s*=%s*(["\'])text/css%1', index) then - return index - end -end))) * M.embed_start_tag -- -l.embed_lexer(M, css, css_start_rule, css_end_rule) - --- Embedded JavaScript. -local js = l.load('javascript') -local script_element = word_match({'script'}, nil, case_insensitive_tags) -local js_start_rule = #(P('<') * script_element * - ('>' + P(function(input, index) - if input:find('^%s+type%s*=%s*(["\'])text/javascript%1', index) then - return index - end -end))) * M.embed_start_tag -- -l.embed_lexer(M, js, js_start_rule, js_end_rule) - --- Embedded CoffeeScript. -local cs = l.load('coffeescript') -local script_element = word_match({'script'}, nil, case_insensitive_tags) -local cs_start_rule = #(P('<') * script_element * P(function(input, index) - if input:find('^[^>]+type%s*=%s*(["\'])text/coffeescript%1', index) then - return index - end -end)) * M.embed_start_tag -- -l.embed_lexer(M, cs, cs_start_rule, cs_end_rule) - -M._foldsymbols = { - _patterns = {'', ''}, - element = {['<'] = 1, ['/>'] = -1, [''] = -1, [''] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/idl.lua b/dep/scintillua/scintillua-3.6.0/lexers/idl.lua deleted file mode 100644 index bc5cbff2..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/idl.lua +++ /dev/null @@ -1,68 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- IDL LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'idl'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Preprocessor. -local preproc_word = word_match{ - 'define', 'undef', 'ifdef', 'ifndef', 'if', 'elif', 'else', 'endif', - 'include', 'warning', 'pragma' -} -local preproc = token(l.PREPROCESSOR, - l.starts_line('#') * preproc_word * l.nonnewline^0) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'abstract', 'attribute', 'case', 'const', 'context', 'custom', 'default', - 'exception', 'enum', 'factory', 'FALSE', 'in', 'inout', 'interface', 'local', - 'module', 'native', 'oneway', 'out', 'private', 'public', 'raises', - 'readonly', 'struct', 'support', 'switch', 'TRUE', 'truncatable', 'typedef', - 'union', 'valuetype' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'any', 'boolean', 'char', 'double', 'fixed', 'float', 'long', 'Object', - 'octet', 'sequence', 'short', 'string', 'unsigned', 'ValueBase', 'void', - 'wchar', 'wstring' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('!<>=+-/*%&|^~.,:;?()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'preprocessor', preproc}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/inform.lua b/dep/scintillua/scintillua-3.6.0/lexers/inform.lua deleted file mode 100644 index 94049fa6..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/inform.lua +++ /dev/null @@ -1,96 +0,0 @@ --- Inform LPeg lexer for Scintillua. --- JMS 2010-04-25. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'inform'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '!' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local inform_hex = '$' * l.xdigit^1 -local inform_bin = '$$' * S('01')^1 -local number = token(l.NUMBER, l.integer + inform_hex + inform_bin) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'Abbreviate', 'Array', 'Attribute', 'Class', 'Constant', 'Default', 'End', - 'Endif', 'Extend', 'Global', 'Ifdef', 'Iffalse', 'Ifndef', 'Ifnot', 'Iftrue', - 'Import', 'Include', 'Link', 'Lowstring', 'Message', 'Object', 'Property', - 'Release', 'Replace', 'Serial', 'StartDaemon', 'Statusline', 'StopDaemon', - 'Switches', 'Verb', 'absent', 'action', 'actor', 'add_to_scope', 'address', - 'additive', 'after', 'and', 'animate', 'article', 'articles', 'before', - 'bold', 'box', 'break', 'cant_go', 'capacity', 'char', 'class', 'child', - 'children', 'clothing', 'concealed', 'container', 'continue', 'creature', - 'daemon', 'deadflag', 'default', 'describe', 'description', 'do', 'door', - 'door_dir', 'door_to', 'd_to', 'd_obj', 'e_to', 'e_obj', 'each_turn', - 'edible', 'else', 'enterable', 'false', 'female', 'first', 'font', 'for', - 'found_in', 'general', 'give', 'grammar', 'has', 'hasnt', 'held', 'if', 'in', - 'in_to', 'in_obj', 'initial', 'inside_description', 'invent', 'jump', 'last', - 'life', 'light', 'list_together', 'location', 'lockable', 'locked', 'male', - 'move', 'moved', 'multi', 'multiexcept', 'multiheld', 'multiinside', 'n_to', - 'n_obj', 'ne_to', 'ne_obj', 'nw_to', 'nw_obj', 'name', 'neuter', 'new_line', - 'nothing', 'notin', 'noun', 'number', 'objectloop', 'ofclass', 'off', 'on', - 'only', 'open', 'openable', 'or', 'orders', 'out_to', 'out_obj', 'parent', - 'parse_name', 'player', 'plural', 'pluralname', 'print', 'print_ret', - 'private', 'proper', 'provides', 'random', 'react_after', 'react_before', - 'remove', 'replace', 'return', 'reverse', 'rfalse','roman', 'rtrue', 's_to', - 's_obj', 'se_to', 'se_obj', 'sw_to', 'sw_obj', 'scenery', 'scope', 'score', - 'scored', 'second', 'self', 'short_name', 'short_name_indef', 'sibling', - 'spaces', 'static', 'string', 'style', 'supporter', 'switch', 'switchable', - 'talkable', 'thedark', 'time_left', 'time_out', 'to', 'topic', 'transparent', - 'true', 'underline', 'u_to', 'u_obj', 'visited', 'w_to', 'w_obj', - 'when_closed', 'when_off', 'when_on', 'when_open', 'while', 'with', - 'with_key', 'workflag', 'worn' -}) - --- Library actions. -local action = token('action', word_match{ - 'Answer', 'Ask', 'AskFor', 'Attack', 'Blow', 'Burn', 'Buy', 'Climb', 'Close', - 'Consult', 'Cut', 'Dig', 'Disrobe', 'Drink', 'Drop', 'Eat', 'Empty', 'EmptyT', - 'Enter', 'Examine', 'Exit', 'Fill', 'FullScore', 'GetOff', 'Give', 'Go', - 'GoIn', 'Insert', 'Inv', 'InvTall', 'InvWide', 'Jump', 'JumpOver', 'Kiss', - 'LetGo', 'Listen', 'LMode1', 'LMode2', 'LMode3', 'Lock', 'Look', 'LookUnder', - 'Mild', 'No', 'NotifyOff', 'NotifyOn', 'Objects', 'Open', 'Order', 'Places', - 'Pray', 'Pronouns', 'Pull', 'Push', 'PushDir', 'PutOn', 'Quit', 'Receive', - 'Remove', 'Restart', 'Restore', 'Rub', 'Save', 'Score', 'ScriptOff', - 'ScriptOn', 'Search', 'Set', 'SetTo', 'Show', 'Sing', 'Sleep', 'Smell', - 'Sorry', 'Squeeze', 'Strong', 'Swim', 'Swing', 'SwitchOff', 'SwitchOn', - 'Take', 'Taste', 'Tell', 'Think', 'ThrowAt', 'ThrownAt', 'Tie', 'Touch', - 'Transfer', 'Turn', 'Unlock', 'VagueGo', 'Verify', 'Version', 'Wake', - 'WakeOther', 'Wait', 'Wave', 'WaveHands', 'Wear', 'Yes' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('@~=+-*/%^#=<>;:,.{}[]()&|?')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'string', string}, - {'number', number}, - {'keyword', keyword}, - {'action', action}, - {'identifier', identifier}, - {'operator', operator}, -} - -_styles = { - {'action', l.STYLE_VARIABLE} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/ini.lua b/dep/scintillua/scintillua-3.6.0/lexers/ini.lua deleted file mode 100644 index 15ea7fa8..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/ini.lua +++ /dev/null @@ -1,52 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Ini LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'ini'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, l.starts_line(S(';#')) * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local label = l.delimited_range('[]', true, true) -local string = token(l.STRING, sq_str + dq_str + label) - --- Numbers. -local dec = l.digit^1 * ('_' * l.digit^1)^0 -local oct_num = '0' * S('01234567_')^1 -local integer = S('+-')^-1 * (l.hex_num + oct_num + dec) -local number = token(l.NUMBER, (l.float + integer)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'true', 'false', 'on', 'off', 'yes', 'no' -}) - --- Identifiers. -local word = (l.alpha + '_') * (l.alnum + S('_.'))^0 -local identifier = token(l.IDENTIFIER, word) - --- Operators. -local operator = token(l.OPERATOR, '=') - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._LEXBYLINE = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/io_lang.lua b/dep/scintillua/scintillua-3.6.0/lexers/io_lang.lua deleted file mode 100644 index 540628c5..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/io_lang.lua +++ /dev/null @@ -1,66 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Io LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'io_lang'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = (P('#') + '//') * l.nonnewline^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local tq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 -local string = token(l.STRING, tq_str + sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'block', 'method', 'while', 'foreach', 'if', 'else', 'do', 'super', 'self', - 'clone', 'proto', 'setSlot', 'hasSlot', 'type', 'write', 'print', 'forward' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'Block', 'Buffer', 'CFunction', 'Date', 'Duration', 'File', 'Future', 'List', - 'LinkedList', 'Map', 'Nop', 'Message', 'Nil', 'Number', 'Object', 'String', - 'WeakLink' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('`~@$%^&*-+/=\\<>?.,:;()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[%(%)]', '/%*', '%*/', '#', '//'}, - [l.OPERATOR] = {['('] = 1, [')'] = -1}, - [l.COMMENT] = { - ['/*'] = 1, ['*/'] = -1, ['#'] = l.fold_line_comments('#'), - ['//'] = l.fold_line_comments('//') - } -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/java.lua b/dep/scintillua/scintillua-3.6.0/lexers/java.lua deleted file mode 100644 index a94ae6dc..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/java.lua +++ /dev/null @@ -1,86 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Java LPeg lexer. --- Modified by Brian Schott. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'java'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * S('LlFfDd')^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'abstract', 'assert', 'break', 'case', 'catch', 'class', 'const', 'continue', - 'default', 'do', 'else', 'enum', 'extends', 'final', 'finally', 'for', 'goto', - 'if', 'implements', 'import', 'instanceof', 'interface', 'native', 'new', - 'package', 'private', 'protected', 'public', 'return', 'static', 'strictfp', - 'super', 'switch', 'synchronized', 'this', 'throw', 'throws', 'transient', - 'try', 'while', 'volatile', - -- Literals. - 'true', 'false', 'null' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'boolean', 'byte', 'char', 'double', 'float', 'int', 'long', 'short', 'void', - 'Boolean', 'Byte', 'Character', 'Double', 'Float', 'Integer', 'Long', 'Short', - 'String' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}')) - --- Annotations. -local annotation = token('annotation', '@' * l.word) - --- Functions. -local func = token(l.FUNCTION, l.word) * #P('(') - --- Classes. -local class_sequence = token(l.KEYWORD, P('class')) * ws^1 * - token(l.CLASS, l.word) - -M._rules = { - {'whitespace', ws}, - {'class', class_sequence}, - {'keyword', keyword}, - {'type', type}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'annotation', annotation}, - {'operator', operator}, -} - -M._tokenstyles = { - annotation = l.STYLE_PREPROCESSOR -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/javascript.lua b/dep/scintillua/scintillua-3.6.0/lexers/javascript.lua deleted file mode 100644 index a9f469bf..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/javascript.lua +++ /dev/null @@ -1,62 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- JavaScript LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'javascript'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local regex_str = #P('/') * l.last_char_includes('+-*%^!=&|?:;,([{<>') * - l.delimited_range('/', true) * S('igm')^0 -local string = token(l.STRING, sq_str + dq_str) + token(l.REGEX, regex_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'abstract', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', - 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'double', 'else', - 'enum', 'export', 'extends', 'false', 'final', 'finally', 'float', 'for', - 'function', 'goto', 'if', 'implements', 'import', 'in', 'instanceof', 'int', - 'interface', 'let', 'long', 'native', 'new', 'null', 'package', 'private', - 'protected', 'public', 'return', 'short', 'static', 'super', 'switch', - 'synchronized', 'this', 'throw', 'throws', 'transient', 'true', 'try', - 'typeof', 'var', 'void', 'volatile', 'while', 'with', 'yield' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%^!=&|?:;,.()[]{}<>')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'comment', comment}, - {'number', number}, - {'string', string}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/json.lua b/dep/scintillua/scintillua-3.6.0/lexers/json.lua deleted file mode 100644 index 6dcebecb..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/json.lua +++ /dev/null @@ -1,47 +0,0 @@ --- Copyright 2006-2013 Brian "Sir Alaran" Schott. See LICENSE. --- JSON LPeg lexer. --- Based off of lexer code by Mitchell. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'json'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '/*' * (l.any - '*/')^0 * P('*/')^-1) - --- Strings. -local sq_str = P('u')^-1 * l.delimited_range("'", true) -local dq_str = P('U')^-1 * l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local integer = S('+-')^-1 * l.digit^1 * S('Ll')^-1 -local number = token(l.NUMBER, l.float + integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{"true", "false", "null"}) - --- Operators. -local operator = token(l.OPERATOR, S('[]{}:,')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'string', string}, - {'number', number}, - {'keyword', keyword}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[%[%]{}]', '/%*', '%*/'}, - [l.OPERATOR] = {['['] = 1, [']'] = -1, ['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/jsp.lua b/dep/scintillua/scintillua-3.6.0/lexers/jsp.lua deleted file mode 100644 index 946fe7ef..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/jsp.lua +++ /dev/null @@ -1,29 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- JSP LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'jsp'} - --- Embedded in HTML. -local html = l.load('html') - --- Embedded Java. -local java = l.load('java') -local java_start_rule = token('jsp_tag', '<%' * P('=')^-1) -local java_end_rule = token('jsp_tag', '%>') -l.embed_lexer(html, java, java_start_rule, java_end_rule, true) - -M._tokenstyles = { - jsp_tag = l.STYLE_EMBEDDED -} - -local _foldsymbols = html._foldsymbols -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '<%%' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '%%>' -_foldsymbols.jsp_tag = {['<%'] = 1, ['%>'] = -1} -M._foldsymbols = _foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/latex.lua b/dep/scintillua/scintillua-3.6.0/lexers/latex.lua deleted file mode 100644 index e3eaa272..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/latex.lua +++ /dev/null @@ -1,73 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Latex LPeg lexer. --- Modified by Brian Schott. --- Modified by Robert Gieseke. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'latex'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '%' * l.nonnewline^0 -local block_comment = '\\begin' * P(' ')^0 * '{comment}' * - (l.any - '\\end' * P(' ')^0 * '{comment}')^0 * - P('\\end' * P(' ')^0 * '{comment}')^-1 --- Note: need block_comment before line_comment or LPeg cannot compile rule. -local comment = token(l.COMMENT, block_comment + line_comment) - --- Sections. -local section = token('section', '\\' * word_match{ - 'part', 'chapter', 'section', 'subsection', 'subsubsection', 'paragraph', - 'subparagraph' -} * P('*')^-1) - --- Math environments. -local math_word = word_match{ - 'align', 'displaymath', 'eqnarray', 'equation', 'gather', 'math', 'multline' -} -local math_begin_end = (P('begin') + P('end')) * P(' ')^0 * - '{' * math_word * P('*')^-1 * '}' -local math = token('math', '$' + '\\' * (S('[]()') + math_begin_end)) - --- LaTeX environments. -local environment = token('environment', '\\' * (P('begin') + P('end')) * - P(' ')^0 * - '{' * l.word * P('*')^-1 * '}') - --- Commands. -local command = token(l.KEYWORD, '\\' * (l.alpha^1 + S('#$&~_^%{}'))) - --- Operators. -local operator = token(l.OPERATOR, S('&#{}[]')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'math', math}, - {'environment', environment}, - {'section', section}, - {'keyword', command}, - {'operator', operator}, -} - -M._tokenstyles = { - environment = l.STYLE_KEYWORD, - math = l.STYLE_FUNCTION, - section = l.STYLE_CLASS -} - -M._foldsymbols = { - _patterns = {'\\[a-z]+', '[{}]', '%%'}, - [l.COMMENT] = { - ['\\begin'] = 1, ['\\end'] = -1, ['%'] = l.fold_line_comments('%') - }, - ['environment'] = {['\\begin'] = 1, ['\\end'] = -1}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/less.lua b/dep/scintillua/scintillua-3.6.0/lexers/less.lua deleted file mode 100644 index 2ca3c387..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/less.lua +++ /dev/null @@ -1,27 +0,0 @@ --- Copyright 2006-2013 Robert Gieseke. See LICENSE. --- Less CSS LPeg lexer. --- http://lesscss.org - -local l = require('lexer') -local token = l.token -local S = lpeg.S - -local M = {_NAME = 'less'} - --- Line comments. -local line_comment = token(l.COMMENT, '//' * l.nonnewline^0) - --- Variables. -local variable = token(l.VARIABLE, '@' * (l.alnum + S('_-{}'))^1) - -local css = l.load('css') -local _rules = css._rules -table.insert(_rules, #_rules - 1, {'line_comment', line_comment}) -table.insert(_rules, #_rules - 1, {'variable', variable}) -M._rules = _rules - -M._tokenstyles = css._tokenstyles - -M._foldsymbols = css._foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/lilypond.lua b/dep/scintillua/scintillua-3.6.0/lexers/lilypond.lua deleted file mode 100644 index f5af7716..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/lilypond.lua +++ /dev/null @@ -1,40 +0,0 @@ --- Copyright 2006-2013 Robert Gieseke. See LICENSE. --- Lilypond LPeg lexer. --- TODO Embed Scheme; Notes?, Numbers? - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'lilypond'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '%' * l.nonnewline^0 --- TODO: block comment. -local comment = token(l.COMMENT, line_comment) - --- Strings. -local string = token(l.STRING, l.delimited_range('"', false, true)) - --- Keywords, commands. -local keyword = token(l.KEYWORD, '\\' * l.word) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S("{}'~<>|")) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'string', string}, - {'keyword', keyword}, - {'operator', operator}, - {'identifier', identifier}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/lisp.lua b/dep/scintillua/scintillua-3.6.0/lexers/lisp.lua deleted file mode 100644 index cdc71265..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/lisp.lua +++ /dev/null @@ -1,84 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Lisp LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'lisp'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = ';' * l.nonnewline^0 -local block_comment = '#|' * (l.any - '|#')^0 * P('|#')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - -local word = l.alpha * (l.alnum + '_' + '-')^0 - --- Strings. -local literal = "'" * word -local dq_str = l.delimited_range('"') -local string = token(l.STRING, literal + dq_str) - --- Numbers. -local number = token(l.NUMBER, P('-')^-1 * l.digit^1 * (S('./') * l.digit^1)^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'defclass', 'defconstant', 'defgeneric', 'define-compiler-macro', - 'define-condition', 'define-method-combination', 'define-modify-macro', - 'define-setf-expander', 'define-symbol-macro', 'defmacro', 'defmethod', - 'defpackage', 'defparameter', 'defsetf', 'defstruct', 'deftype', 'defun', - 'defvar', - 'abort', 'assert', 'block', 'break', 'case', 'catch', 'ccase', 'cerror', - 'cond', 'ctypecase', 'declaim', 'declare', 'do', 'do*', 'do-all-symbols', - 'do-external-symbols', 'do-symbols', 'dolist', 'dotimes', 'ecase', 'error', - 'etypecase', 'eval-when', 'flet', 'handler-bind', 'handler-case', 'if', - 'ignore-errors', 'in-package', 'labels', 'lambda', 'let', 'let*', 'locally', - 'loop', 'macrolet', 'multiple-value-bind', 'proclaim', 'prog', 'prog*', - 'prog1', 'prog2', 'progn', 'progv', 'provide', 'require', 'restart-bind', - 'restart-case', 'restart-name', 'return', 'return-from', 'signal', - 'symbol-macrolet', 'tagbody', 'the', 'throw', 'typecase', 'unless', - 'unwind-protect', 'when', 'with-accessors', 'with-compilation-unit', - 'with-condition-restarts', 'with-hash-table-iterator', - 'with-input-from-string', 'with-open-file', 'with-open-stream', - 'with-output-to-string', 'with-package-iterator', 'with-simple-restart', - 'with-slots', 'with-standard-io-syntax', - 't', 'nil' -}, '-')) - --- Identifiers. -local identifier = token(l.IDENTIFIER, word) - --- Operators. -local operator = token(l.OPERATOR, S('<>=*/+-`@%()')) - --- Entities. -local entity = token('entity', '&' * word) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, - {'entity', entity}, -} - -M._tokenstyles = { - entity = l.STYLE_VARIABLE -} - -M._foldsymbols = { - _patterns = {'[%(%)%[%]{}]', '#|', '|#', ';'}, - [l.OPERATOR] = { - ['('] = 1, [')'] = -1, ['['] = 1, [']'] = -1, ['{'] = 1, ['}'] = -1 - }, - [l.COMMENT] = {['#|'] = 1, ['|#'] = -1, [';'] = l.fold_line_comments(';')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/litcoffee.lua b/dep/scintillua/scintillua-3.6.0/lexers/litcoffee.lua deleted file mode 100644 index f31a2d1e..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/litcoffee.lua +++ /dev/null @@ -1,21 +0,0 @@ --- Copyright 2006-2013 Robert Gieseke. See LICENSE. --- Literate CoffeeScript LPeg lexer. --- http://coffeescript.org/#literate - -local l = require('lexer') -local token = l.token -local P = lpeg.P - -local M = {_NAME = 'litcoffee'} - --- Embedded in Markdown. -local markdown = l.load('markdown') -M._lexer = markdown -- ensure markdown's rules are loaded, not HTML's - --- Embedded CoffeeScript. -local coffeescript = l.load('coffeescript') -local coffee_start_rule = token(l.STYLE_EMBEDDED, (P(' ')^4 + P('\t'))) -local coffee_end_rule = token(l.STYLE_EMBEDDED, l.newline) -l.embed_lexer(markdown, coffeescript, coffee_start_rule, coffee_end_rule) - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/lpeg.properties b/dep/scintillua/scintillua-3.6.0/lexers/lpeg.properties deleted file mode 100644 index 08f1d4f8..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/lpeg.properties +++ /dev/null @@ -1,208 +0,0 @@ -# LPeg lexer properties for SciTE -# To use, add 'import lexers/lpeg' to your SciTEGlobal.properties or -# SciTEUser.properties. - -lexer.lpeg.home=$(SciteDefaultHome)/lexers -lexer.lpeg.color.theme=scite -fold.by.indentation=0 -fold.line.comments=0 -if PLAT_WIN - lexerpath.*.lpeg=$(lexer.lpeg.home)/LexLPeg.dll -if PLAT_GTK - lexerpath.*.lpeg=$(lexer.lpeg.home)/liblexlpeg.so -lexer.*.lpeg=lpeg - -# Lexer definitions ( -file.patterns.flash=*.as;*.asc -lexer.$(file.patterns.flash)=lpeg_actionscript -file.patterns.ada=*.adb;*.ads -lexer.$(file.patterns.ada)=lpeg_ada -file.patterns.antlr=*.g;*.g4 -lexer.$(file.patterns.antlr)=lpeg_antlr -file.patterns.apdl=*.ans;*.inp;*.mac -lexer.$(file.patterns.apdl)=lpeg_apdl -file.patterns.applescript=*.applescript -lexer.$(file.patterns.applescript)=lpeg_applescript -file.patterns.asm=*.asm;*.ASM;*.s;*.S -lexer.$(file.patterns.asm)=lpeg_asm -file.patterns.asp=*.asa;*.asp;*.hta -lexer.$(file.patterns.asp)=lpeg_asp -file.patterns.awk=*.awk -lexer.$(file.patterns.awk)=lpeg_awk -file.patterns.batch=*.bat;*.cmd -lexer.$(file.patterns.batch)=lpeg_batch -file.patterns.bibtex=*.bib -lexer.$(file.patterns.bibtex)=lpeg_bibtex -file.patterns.boo=*.boo -lexer.$(file.patterns.boo)=lpeg_boo -file.patterns.csharp=*.cs -lexer.$(file.patterns.csharp)=lpeg_csharp -file.patterns.c=*.c;*.cc;*.C -lexer.$(file.patterns.c)=lpeg_ansi_c -file.patterns.cpp=*.cpp;*.cxx;*.c++;*.h;*.hh;*.hpp;*.hxx;*.h++ -lexer.$(file.patterns.cpp)=lpeg_cpp -file.patterns.chuck=*.ck -lexer.$(file.patterns.chuck)=lpeg_chuck -file.patterns.cmake=*.cmake;*.cmake.in;*.ctest;*.ctest.in -lexer.$(file.patterns.cmake)=lpeg_cmake -file.patterns.coffeescript=*.coffee -lexer.$(file.patterns.coffeescript)=lpeg_coffeescript -file.patterns.css=*.css -lexer.$(file.patterns.css)=lpeg_css -file.patterns.cuda=*.cu;*.cuh -lexer.$(file.patterns.cuda)=lpeg_cuda -file.patterns.d=*.d;*.di -lexer.$(file.patterns.d)=lpeg_dmd -file.patterns.dart=*.dart -lexer.$(file.patterns.dart)=lpeg_dart -file.patterns.desktop=*.desktop -lexer.$(file.patterns.desktop)=lpeg_desktop -file.patterns.diff=*.diff;*.patch -lexer.$(file.patterns.diff)=lpeg_diff -file.patterns.dot=*.dot -lexer.$(file.patterns.dot)=lpeg_dot -file.patterns.eiffel=*.e;*.eif -lexer.$(file.patterns.eiffel)=lpeg_eiffel -file.patterns.elixir=*.ex;*.exs -lexer.$(file.patterns.elixir)=lpeg_elixir -file.patterns.erlang=*.erl;*.hrl -lexer.$(file.patterns.erlang)=lpeg_erlang -file.patterns.fsharp=*.fs -lexer.$(file.patterns.fsharp)=lpeg_fsharp -file.patterns.fish=*.fish -lexer.$(file.patterns.fish)=lpeg_fish -file.patterns.forth=*.forth;*.frt;*.fs -lexer.$(file.patterns.forth)=lpeg_forth -file.patterns.fortran=*.f;*.for;*.ftn;*.fpp;*.f77;*.f90;*.f95;*.f03;*.f08 -lexer.$(file.patterns.fortran)=lpeg_fortran -file.patterns.gap=*.g;*.gd;*.gi;*.gap -lexer.$(file.patterns.gap)=lpeg_gap -file.patterns.gettext=*.po;*.pot -lexer.$(file.patterns.gettext)=lpeg_gettext -file.patterns.glsl=*.glslf;*.glslv -lexer.$(file.patterns.glsl)=lpeg_glsl -file.patterns.gnuplot=*.dem;*.plt -lexer.$(file.patterns.gnuplot)=lpeg_gnuplot -file.patterns.go=*.go -lexer.$(file.patterns.go)=lpeg_go -file.patterns.groovy=*.groovy;*.gvy -lexer.$(file.patterns.groovy)=lpeg_groovy -file.patterns.gtkrc=*.gtkrc -lexer.$(file.patterns.gtkrc)=lpeg_gtkrc -file.patterns.haskell=*.hs -lexer.$(file.patterns.haskell)=lpeg_haskell -file.patterns.html=*.htm;*.html;*.shtm;*.shtml;*.xhtml -lexer.$(file.patterns.html)=lpeg_html -file.patterns.idl=*.idl;*.odl -lexer.$(file.patterns.idl)=lpeg_idl -file.patterns.inform=*.inf;*.ni -lexer.$(file.patterns.inform)=lpeg_inform -file.patterns.ini=*.cfg;*.cnf;*.inf;*.ini;*.reg -lexer.$(file.patterns.ini)=lpeg_ini -file.patterns.io_lang=*.io -lexer.$(file.patterns.io_lang)=lpeg_io_lang -file.patterns.java=*.bsh;*.java -lexer.$(file.patterns.java)=lpeg_java -file.patterns.js=*.js;*.jsfl -lexer.$(file.patterns.js)=lpeg_javascript -file.patterns.json=*.json -lexer.$(file.patterns.json)=lpeg_json -file.patterns.jsp=*.jsp -lexer.$(file.patterns.jsp)=lpeg_jsp -file.patterns.latex=*.bbl;*.dtx;*.ins;*.ltx;*.tex;*.sty -lexer.$(file.patterns.latex)=lpeg_latex -file.patterns.less=*.less -lexer.$(file.patterns.less)=lpeg_less -file.patterns.lilypond=*.lily;*.ly -lexer.$(file.patterns.lilypond)=lpeg_lilypond -file.patterns.lisp=*.cl;*.el;*.lisp;*.lsp -lexer.$(file.patterns.lisp)=lpeg_lisp -file.patterns.litcoffee=*.litcoffee -lexer.$(file.patterns.litcoffee)=lpeg_litcoffee -file.patterns.lua=*.lua -lexer.$(file.patterns.lua)=lpeg_lua -file.patterns.makefile=GNUmakefile;*.iface;*.mak;makefile;Makefile -lexer.$(file.patterns.makefile)=lpeg_makefile -file.patterns.markdown=*.md -lexer.$(file.patterns.markdown)=lpeg_markdown -file.patterns.nemerle=*.n -lexer.$(file.patterns.nemerle)=lpeg_nemerle -file.patterns.nim=*.nim -lexer.$(file.patterns.nim)=lpeg_nim -file.patterns.nsis=*.nsh;*.nsi;*.nsis -lexer.$(file.patterns.nsis)=lpeg_nsis -file.patterns.objective_c=*.m;*.mm;*.objc -lexer.$(file.patterns.objective_c)=lpeg_objective_c -file.patterns.caml=*.caml;*.ml;*.mli;*.mll;*.mly -lexer.$(file.patterns.caml)=lpeg_caml -file.patterns.pascal=*.dpk;*.dpr;*.p;*.pas -lexer.$(file.patterns.pascal)=lpeg_pascal -file.patterns.perl=*.al;*.perl;*.pl;*.pm;*.pod -lexer.$(file.patterns.perl)=lpeg_perl -file.patterns.php=*.inc;*.php;*.php3;*.php4;*.phtml -lexer.$(file.patterns.php)=lpeg_php -file.patterns.pike=*.pike;*.pmod -lexer.$(file.patterns.pike)=lpeg_pike -file.patterns.pkgbuild=*.PKGBUILD -lexer.$(file.patterns.pkgbuild)=lpeg_pkgbuild -file.patterns.powershell=*.ps1 -lexer.$(file.patterns.powershell)=lpeg_powershell -file.patterns.ps=*.eps;*.ps -lexer.$(file.patterns.ps)=lpeg_ps -file.patterns.prolog=*.prolog -lexer.$(file.patterns.prolog)=lpeg_prolog -file.patterns.props=*.props;*.properties -lexer.$(file.patterns.props)=lpeg_props -file.patterns.py=*.sc;*.py;*.pyw -lexer.$(file.patterns.py)=lpeg_python -file.patterns.r=*.R;*.Rout;*.Rhistory;*.Rt;Rout.save;Rout.fail;*.S -lexer.$(file.patterns.r)=lpeg_rstats -file.patterns.rebol=*.r;*.reb -lexer.$(file.patterns.rebol)=lpeg_rebol -file.patterns.rest=*.rst -lexer.$(file.patterns.rest)=lpeg_rest -file.patterns.rexx=*.orx;*.rex -lexer.$(file.patterns.rexx)=lpeg_rexx -file.patterns.rhtml=*.erb;*.rhtml -lexer.$(file.patterns.rhtml)=lpeg_rhtml -file.patterns.rb=Rakefile;*.rake;*.rb;*.rbw -lexer.$(file.patterns.rb)=lpeg_ruby -file.patterns.rust=*.rs -lexer.$(file.patterns.rust)=lpeg_rust -file.patterns.sass=*.sass;*.scss -lexer.$(file.patterns.sass)=lpeg_sass -file.patterns.scala=*.scala -lexer.$(file.patterns.scala)=lpeg_scala -file.patterns.scheme=*.sch;*.scm -lexer.$(file.patterns.scheme)=lpeg_scheme -file.patterns.bash=*.bash;*.bashrc;*.bash_profile;*.configure;*.csh;*.sh;*.zsh -lexer.$(file.patterns.bash)=lpeg_bash -file.patterns.smalltalk=*.changes;*.st;*.sources -lexer.$(file.patterns.smalltalk)=lpeg_smalltalk -file.patterns.sql=*.ddl;*.sql -lexer.$(file.patterns.sql)=lpeg_sql -file.patterns.tcl=*.tcl;*.tk -lexer.$(file.patterns.tcl)=lpeg_tcl -file.patterns.texinfo=*.texi -lexer.$(file.patterns.texinfo)=lpeg_texinfo -file.patterns.toml=*.toml -lexer.$(file.patterns.toml)=lpeg_toml -file.patterns.vala=*.vala -lexer.$(file.patterns.vala)=lpeg_vala -file.patterns.vcard=*.vcf;*.vcard -lexer.$(file.patterns.vcard)=lpeg_vcard -file.patterns.verilog=*.v;*.ver -lexer.$(file.patterns.verilog)=lpeg_verilog -file.patterns.vhdl=*.vh;*.vhd;*.vhdl -lexer.$(file.patterns.vhdl)=lpeg_vhdl -file.patterns.vb=*.asa;*.bas;*.cls;*.ctl;*.dob;*.dsm;*.dsr;*.frm;*.pag;*.vb;*.vba;*.vbs -lexer.$(file.patterns.vb)=lpeg_vb -file.patterns.wsf=*.wsf -lexer.$(file.patterns.wsf)=lpeg_wsf -file.patterns.xml=*.dtd;*.svg;*.xml;*.xsd;*.xsl;*.xslt;*.xul -lexer.$(file.patterns.xml)=lpeg_xml -file.patterns.xtend=*.xtend -lexer.$(file.patterns.xtend)=lpeg_xtend -file.patterns.yaml=*.yaml -lexer.$(file.patterns.yaml)=lpeg_yaml -# ) diff --git a/dep/scintillua/scintillua-3.6.0/lexers/lua.lua b/dep/scintillua/scintillua-3.6.0/lexers/lua.lua deleted file mode 100644 index 2ad11900..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/lua.lua +++ /dev/null @@ -1,190 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Lua LPeg lexer. --- Original written by Peter Odding, 2007/04/04. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'lua'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - -local longstring = lpeg.Cmt('[' * lpeg.C(P('=')^0) * '[', - function(input, index, eq) - local _, e = input:find(']'..eq..']', index, true) - return (e or #input) + 1 - end) - --- Comments. -local line_comment = '--' * l.nonnewline^0 -local block_comment = '--' * longstring -local comment = token(l.COMMENT, block_comment + line_comment) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local string = token(l.STRING, sq_str + dq_str) + - token('longstring', longstring) - --- Numbers. -local lua_integer = P('-')^-1 * (l.hex_num + l.dec_num) -local number = token(l.NUMBER, l.float + lua_integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', - 'goto', 'if', 'in', 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', - 'true', 'until', 'while' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'assert', 'collectgarbage', 'dofile', 'error', 'getmetatable', 'ipairs', - 'load', 'loadfile', 'next', 'pairs', 'pcall', 'print', 'rawequal', 'rawget', - 'rawset', 'require', 'select', 'setmetatable', 'tonumber', 'tostring', 'type', - 'xpcall', - -- Added in 5.2. - 'rawlen' -}) - --- Deprecated functions. -local deprecated_func = token('deprecated_function', word_match{ - -- Deprecated in 5.2. - 'getfenv', 'loadstring', 'module', 'setfenv', 'unpack' -}) - --- Constants. -local constant = token(l.CONSTANT, word_match{ - '_G', '_VERSION', - -- Added in 5.2. - '_ENV' -}) - --- Libraries. -local library = token('library', word_match({ - -- Coroutine. - 'coroutine', 'coroutine.create', 'coroutine.resume', 'coroutine.running', - 'coroutine.status', 'coroutine.wrap', 'coroutine.yield', - -- Coroutine added in 5.3. - 'coroutine.isyieldable', - -- Module. - 'package', 'package.cpath', 'package.loaded', 'package.loadlib', - 'package.path', 'package.preload', - -- Module added in 5.2. - 'package.config', 'package.searchers', 'package.searchpath', - -- UTF-8 added in 5.3. - 'utf8', 'utf8.char', 'utf8.charpattern', 'utf8.codepoint', 'utf8.codes', - 'utf8.len', 'utf8.offset', - -- String. - 'string', 'string.byte', 'string.char', 'string.dump', 'string.find', - 'string.format', 'string.gmatch', 'string.gsub', 'string.len', 'string.lower', - 'string.match', 'string.rep', 'string.reverse', 'string.sub', 'string.upper', - -- String added in 5.3. - 'string.pack', 'string.packsize', 'string.unpack', - -- Table. - 'table', 'table.concat', 'table.insert', 'table.remove', 'table.sort', - -- Table added in 5.2. - 'table.pack', 'table.unpack', - -- Table added in 5.3. - 'table.move', - -- Math. - 'math', 'math.abs', 'math.acos', 'math.asin', 'math.atan', 'math.ceil', - 'math.cos', 'math.deg', 'math.exp', 'math.floor', 'math.fmod', 'math.huge', - 'math.log', 'math.max', 'math.min', 'math.modf', 'math.pi', 'math.rad', - 'math.random', 'math.randomseed', 'math.sin', 'math.sqrt', 'math.tan', - -- Math added in 5.3. - 'math.maxinteger', 'math.mininteger', 'math.tointeger', 'math.type', - 'math.ult', - -- IO. - 'io', 'io.close', 'io.flush', 'io.input', 'io.lines', 'io.open', 'io.output', - 'io.popen', 'io.read', 'io.stderr', 'io.stdin', 'io.stdout', 'io.tmpfile', - 'io.type', 'io.write', - -- OS. - 'os', 'os.clock', 'os.date', 'os.difftime', 'os.execute', 'os.exit', - 'os.getenv', 'os.remove', 'os.rename', 'os.setlocale', 'os.time', - 'os.tmpname', - -- Debug. - 'debug', 'debug.debug', 'debug.gethook', 'debug.getinfo', 'debug.getlocal', - 'debug.getmetatable', 'debug.getregistry', 'debug.getupvalue', - 'debug.sethook', 'debug.setlocal', 'debug.setmetatable', 'debug.setupvalue', - 'debug.traceback', - -- Debug added in 5.2. - 'debug.getuservalue', 'debug.setuservalue', 'debug.upvalueid', - 'debug.upvaluejoin', -}, '.')) - --- Deprecated libraries. -local deprecated_library = token('deprecated_library', word_match({ - -- Module deprecated in 5.2. - 'package.loaders', 'package.seeall', - -- Table deprecated in 5.2. - 'table.maxn', - -- Math deprecated in 5.2. - 'math.log10', - -- Math deprecated in 5.3. - 'math.atan2', 'math.cosh', 'math.frexp', 'math.ldexp', 'math.pow', - 'math.sinh', 'math.tanh', - -- Bit32 deprecated in 5.3. - 'bit32', 'bit32.arshift', 'bit32.band', 'bit32.bnot', 'bit32.bor', - 'bit32.btest', 'bit32.extract', 'bit32.lrotate', 'bit32.lshift', - 'bit32.replace', 'bit32.rrotate', 'bit32.rshift', 'bit32.xor', - -- Debug deprecated in 5.2. - 'debug.getfenv', 'debug.setfenv' -}, '.')) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Labels. -local label = token(l.LABEL, '::' * l.word * '::') - --- Operators. -local operator = token(l.OPERATOR, S('+-*/%^#=<>&|~;:,.{}[]()')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func + deprecated_func}, - {'constant', constant}, - {'library', library + deprecated_library}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'label', label}, - {'operator', operator}, -} - -M._tokenstyles = { - longstring = l.STYLE_STRING, - deprecated_function = l.STYLE_FUNCTION..',italics', - library = l.STYLE_TYPE, - deprecated_library = l.STYLE_TYPE..',italics' -} - -local function fold_longcomment(text, pos, line, s, match) - if match == '[' then - if line:find('^%[=*%[', s) then return 1 end - elseif match == ']' then - if line:find('^%]=*%]', s) then return -1 end - end - return 0 -end - -M._foldsymbols = { - _patterns = {'%l+', '[%({%)}]', '[%[%]]', '%-%-'}, - [l.KEYWORD] = { - ['if'] = 1, ['do'] = 1, ['function'] = 1, ['end'] = -1, ['repeat'] = 1, - ['until'] = -1 - }, - [l.COMMENT] = { - ['['] = fold_longcomment, [']'] = fold_longcomment, - ['--'] = l.fold_line_comments('--') - }, - longstring = {['['] = 1, [']'] = -1}, - [l.OPERATOR] = {['('] = 1, ['{'] = 1, [')'] = -1, ['}'] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/makefile.lua b/dep/scintillua/scintillua-3.6.0/lexers/makefile.lua deleted file mode 100644 index 480e032e..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/makefile.lua +++ /dev/null @@ -1,108 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Makefile LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'makefile'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Keywords. -local keyword = token(l.KEYWORD, P('!')^-1 * l.word_match({ - -- GNU Make conditionals. - 'ifeq', 'ifneq', 'ifdef', 'ifndef', 'else', 'endif', - -- Other conditionals. - 'if', 'elseif', 'elseifdef', 'elseifndef', - -- Directives and other keywords. - 'define', 'endef', 'export', 'include', 'override', 'private', 'undefine', - 'unexport', 'vpath' -}, nil, true)) - --- Functions. -local func = token(l.FUNCTION, l.word_match({ - -- Functions for String Substitution and Analysis. - 'subst', 'patsubst', 'strip', 'findstring', 'filter', 'filter-out', 'sort', - 'word', 'wordlist', 'words', 'firstword', 'lastword', - -- Functions for File Names. - 'dir', 'notdir', 'suffix', 'basename', 'addsuffix', 'addprefix', 'join', - 'wildcard', 'realpath', 'abspath', - -- Functions for Conditionals. - 'if', 'or', 'and', - -- Miscellaneous Functions. - 'foreach', 'call', 'value', 'eval', 'origin', 'flavor', 'shell', - -- Functions That Control Make. - 'error', 'warning', 'info' -}), '-') - --- Variables. -local word_char, assign = l.any - l.space - S(':#=(){}'), S(':+?')^-1 * '=' -local expanded_var = '$' * ('(' * word_char^1 * ')' + '{' * word_char^1 * '}') -local auto_var = '$' * S('@%'), - function(input, index) - local _, e = input:find('\n[ \t]*\r?\n', - index) - return (e or #input) + 1 - end)) - -local blockcode = token('code', l.starts_line(P(' ')^4 + P('\t')) * -P('<') * - l.nonnewline^0) - -local hr = token('hr', lpeg.Cmt(l.starts_line(S(' \t')^0 * lpeg.C(S('*-_'))), - function(input, index, c) - local line = input:match('[^\n]+', index) - line = line:gsub('[ \t]', '') - if line:find('[^'..c..']') or #line < 2 then - return nil - end - return (input:find('\n', index) or #input) + 1 - end)) - --- Span elements. -local dq_str = token(l.STRING, l.delimited_range('"', false, true)) -local sq_str = token(l.STRING, l.delimited_range("'", false, true)) -local paren_str = token(l.STRING, l.delimited_range('()')) -local link = token('link', P('!')^-1 * l.delimited_range('[]') * - (P('(') * (l.any - S(') \t'))^0 * - (S(' \t')^1 * - l.delimited_range('"', false, true))^-1 * ')' + - S(' \t')^0 * l.delimited_range('[]')) + - P('http://') * (l.any - l.space)^1) -local link_label = ws^0 * token('link_label', l.delimited_range('[]') * ':') * - ws * token('link_url', (l.any - l.space)^1) * - (ws * (dq_str + sq_str + paren_str))^-1 - -local strong = token('strong', (P('**') * (l.any - '**')^0 * P('**')^-1) + - (P('__') * (l.any - '__')^0 * P('__')^-1)) -local em = token('em', - l.delimited_range('*', true) + l.delimited_range('_', true)) -local code = token('code', (P('``') * (l.any - '``')^0 * P('``')^-1) + - l.delimited_range('`', true)) - -local escape = token(l.DEFAULT, P('\\') * 1) - -local list = token('list', - l.starts_line(S(' \t')^0 * (S('*+-') + R('09')^1 * '.')) * - S(' \t')) - -M._rules = { - {'header', header}, - {'blockquote', blockquote}, - {'blockcode', blockcode}, - {'hr', hr}, - {'list', list}, - {'whitespace', ws + newline}, - {'link_label', link_label}, - {'escape', escape}, - {'link', link}, - {'strong', strong}, - {'em', em}, - {'code', code}, -} - -local font_size = 10 -local hstyle = 'fore:$(color.red)' -M._tokenstyles = { - h6 = hstyle, - h5 = hstyle..',size:'..(font_size + 1), - h4 = hstyle..',size:'..(font_size + 2), - h3 = hstyle..',size:'..(font_size + 3)..',bold', - h2 = hstyle..',size:'..(font_size + 4)..',bold', - h1 = hstyle..',size:'..(font_size + 5)..',bold', - code = l.STYLE_EMBEDDED..',eolfilled', - hr = 'back:$(color.grey),eolfilled', - link = 'underlined', - link_url = 'underlined', - link_label = l.STYLE_LABEL, - strong = 'bold', - em = 'italics', - list = l.STYLE_CONSTANT, -} - --- Embedded HTML. -local html = l.load('html') -local start_rule = token('tag', l.starts_line(S(' \t')^0 * '<')) -local end_rule = token(l.DEFAULT, P('\n')) -- TODO: l.WHITESPACE causes errors -l.embed_lexer(M, html, start_rule, end_rule) - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/matlab.lua b/dep/scintillua/scintillua-3.6.0/lexers/matlab.lua deleted file mode 100644 index 5385a410..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/matlab.lua +++ /dev/null @@ -1,105 +0,0 @@ --- Copyright 2006-2013 Martin Morawetz. See LICENSE. --- Matlab LPeg lexer. --- Based off of lexer code by Mitchell. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'matlab'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = (P('%') + '#') * l.nonnewline^0 -local block_comment = '%{' * (l.any - '%}')^0 * P('%}')^-1 -local comment = token(l.COMMENT, block_comment + line_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"') -local bt_str = l.delimited_range('`') -local string = token(l.STRING, sq_str + dq_str + bt_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer + l.dec_num + l.hex_num + - l.oct_num) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'break', 'case', 'catch', 'continue', 'do', 'else', 'elseif', 'end', - 'end_try_catch', 'end_unwind_protect', 'endfor', 'endif', 'endswitch', - 'endwhile', 'for', 'function', 'endfunction', 'global', 'if', 'otherwise', - 'persistent', 'replot', 'return', 'static', 'switch', 'try', 'until', - 'unwind_protect', 'unwind_protect_cleanup', 'varargin', 'varargout', 'while' -}, nil, true)) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'abs', 'any', 'argv','atan2', 'axes', 'axis', 'ceil', 'cla', 'clear', 'clf', - 'columns', 'cos', 'delete', 'diff', 'disp', 'doc', 'double', 'drawnow', 'exp', - 'figure', 'find', 'fix', 'floor', 'fprintf', 'gca', 'gcf', 'get', 'grid', - 'help', 'hist', 'hold', 'isempty', 'isnull', 'length', 'load', 'log', 'log10', - 'loglog', 'max', 'mean', 'median', 'min', 'mod', 'ndims', 'numel', 'num2str', - 'ones', 'pause', 'plot', 'printf', 'quit', 'rand', 'randn', 'rectangle', - 'rem', 'repmat', 'reshape', 'round', 'rows', 'save', 'semilogx', 'semilogy', - 'set', 'sign', 'sin', 'size', 'sizeof', 'size_equal', 'sort', 'sprintf', - 'squeeze', 'sqrt', 'std', 'strcmp', 'subplot', 'sum', 'tan', 'tic', 'title', - 'toc', 'uicontrol', 'who', 'xlabel', 'ylabel', 'zeros' -}) - --- Constants. -local constant = token(l.CONSTANT, word_match{ - 'EDITOR', 'I', 'IMAGEPATH', 'INFO_FILE', 'J', 'LOADPATH', 'OCTAVE_VERSION', - 'PAGER', 'PS1', 'PS2', 'PS4', 'PWD' -}) - --- Variable. -local variable = token(l.VARIABLE, word_match{ - 'ans', 'automatic_replot', 'default_return_value', 'do_fortran_indexing', - 'define_all_return_values', 'empty_list_elements_ok', 'eps', 'false', - 'gnuplot_binary', 'ignore_function_time_stamp', 'implicit_str_to_num_ok', - 'Inf', 'inf', 'NaN', 'nan', 'ok_to_lose_imaginary_part', - 'output_max_field_width', 'output_precision', 'page_screen_output', 'pi', - 'prefer_column_vectors', 'prefer_zero_one_indexing', 'print_answer_id_name', - 'print_empty_dimensions', 'realmax', 'realmin', 'resize_on_range_error', - 'return_last_computed_value', 'save_precision', 'silent_functions', - 'split_long_rows', 'suppress_verbose_help_message', 'treat_neg_dim_as_zero', - 'true', 'warn_assign_as_truth_value', 'warn_comma_in_global_decl', - 'warn_divide_by_zero', 'warn_function_name_clash', - 'whitespace_in_literal_matrix' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('!%^&*()[]{}-=+/\\|:;.,?<>~`´')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'constant', constant}, - {'variable', variable}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[a-z]+', '[%(%)%[%]]', '%%[{}]?', '#'}, - [l.KEYWORD] = { - ['if'] = 1, ['for'] = 1, ['while'] = 1, switch = 1, ['end'] = -1 - }, - [l.OPERATOR] = {['('] = 1, [')'] = -1, ['['] = 1, [']'] = -1}, - [l.COMMENT] = { - ['%{'] = 1, ['%}'] = -1, ['%'] = l.fold_line_comments('%'), - ['#'] = l.fold_line_comments('#') - } -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/nemerle.lua b/dep/scintillua/scintillua-3.6.0/lexers/nemerle.lua deleted file mode 100644 index d628c8a6..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/nemerle.lua +++ /dev/null @@ -1,81 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Nemerle LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'nemerle'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = P('L')^-1 * l.delimited_range("'", true) -local dq_str = P('L')^-1 * l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Preprocessor. -local preproc_word = word_match{ - 'define', 'elif', 'else', 'endif', 'endregion', 'error', 'if', 'ifdef', - 'ifndef', 'line', 'pragma', 'region', 'undef', 'using', 'warning' -} -local preproc = token(l.PREPROCESSOR, - l.starts_line('#') * S('\t ')^0 * preproc_word) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - '_', 'abstract', 'and', 'array', 'as', 'base', 'catch', 'class', 'def', 'do', - 'else', 'extends', 'extern', 'finally', 'foreach', 'for', 'fun', 'if', - 'implements', 'in', 'interface', 'internal', 'lock', 'macro', 'match', - 'module', 'mutable', 'namespace', 'new', 'out', 'override', 'params', - 'private', 'protected', 'public', 'ref', 'repeat', 'sealed', 'static', - 'struct', 'syntax', 'this', 'throw', 'try', 'type', 'typeof', 'unless', - 'until', 'using', 'variant', 'virtual', 'when', 'where', 'while', - -- Values. - 'null', 'true', 'false' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'bool', 'byte', 'char', 'decimal', 'double', 'float', 'int', 'list', 'long', - 'object', 'sbyte', 'short', 'string', 'uint', 'ulong', 'ushort', 'void' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'preproc', preproc}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'%l+', '[{}]', '/%*', '%*/', '//'}, - [l.PREPROCESSOR] = { - region = 1, endregion = -1, - ['if'] = 1, ifdef = 1, ifndef = 1, endif = -1 - }, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/nim.lua b/dep/scintillua/scintillua-3.6.0/lexers/nim.lua deleted file mode 100644 index d830774a..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/nim.lua +++ /dev/null @@ -1,124 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Nim LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'nim'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline_esc^0) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local triple_dq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 -local raw_dq_str = 'r' * l.delimited_range('"', false, true) -local string = token(l.STRING, triple_dq_str + sq_str + dq_str + raw_dq_str) - --- Numbers. -local dec = l.digit^1 * ('_' * l.digit^1)^0 -local hex = '0' * S('xX') * l.xdigit^1 * ('_' * l.xdigit^1)^0 -local bin = '0' * S('bB') * S('01')^1 * ('_' * S('01')^1)^0 -local oct = '0o' * R('07')^1 -local integer = S('+-')^-1 * (bin + hex + oct + dec) * - ("'" * S('iIuUfF') * (P('8') + '16' + '32' + '64'))^-1 -local float = l.digit^1 * ('_' * l.digit^1)^0 * ('.' * ('_' * l.digit)^0)^-1 * - S('eE') * S('+-')^-1 * l.digit^1 * ('_' * l.digit^1)^0 -local number = token(l.NUMBER, l.float + integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'addr', 'and', 'as', 'asm', 'atomic', 'bind', 'block', 'break', 'case', - 'cast', 'const', 'continue', 'converter', 'discard', 'distinct', 'div', 'do', - 'elif', 'else', 'end', 'enum', 'except', 'export', 'finally', 'for', 'from', - 'generic', 'if', 'import', 'in', 'include', 'interface', 'is', 'isnot', - 'iterator', 'lambda', 'let', 'macro', 'method', 'mixin', 'mod', 'nil', 'not', - 'notin', 'object', 'of', 'or', 'out', 'proc', 'ptr', 'raise', 'ref', 'return', - 'shared', 'shl', 'static', 'template', 'try', 'tuple', 'type', 'var', 'when', - 'while', 'with', 'without', 'xor', 'yield' -}, nil, true)) - --- Functions. -local func = token(l.FUNCTION, word_match({ - -- Procs. - 'defined', 'definedInScope', 'new', 'unsafeNew', 'internalNew', 'reset', - 'high', 'low', 'sizeof', 'succ', 'pred', 'inc', 'dec', 'newSeq', 'len', - 'incl', 'excl', 'card', 'ord', 'chr', 'ze', 'ze64', 'toU8', 'toU16', 'toU32', - 'abs', 'min', 'max', 'contains', 'cmp', 'setLen', 'newString', - 'newStringOfCap', 'add', 'compileOption', 'quit', 'shallowCopy', 'del', - 'delete', 'insert', 'repr', 'toFloat', 'toBiggestFloat', 'toInt', - 'toBiggestInt', 'addQuitProc', 'substr', 'zeroMem', 'copyMem', 'moveMem', - 'equalMem', 'swap', 'getRefcount', 'clamp', 'isNil', 'find', 'contains', - 'pop', 'each', 'map', 'GC_ref', 'GC_unref', 'echo', 'debugEcho', - 'getTypeInfo', 'Open', 'repopen', 'Close', 'EndOfFile', 'readChar', - 'FlushFile', 'readAll', 'readFile', 'writeFile', 'write', 'readLine', - 'writeln', 'getFileSize', 'ReadBytes', 'ReadChars', 'readBuffer', - 'writeBytes', 'writeChars', 'writeBuffer', 'setFilePos', 'getFilePos', - 'fileHandle', 'cstringArrayToSeq', 'allocCStringArray', 'deallocCStringArray', - 'atomicInc', 'atomicDec', 'compareAndSwap', 'setControlCHook', - 'writeStackTrace', 'getStackTrace', 'alloc', 'alloc0', 'dealloc', 'realloc', - 'getFreeMem', 'getTotalMem', 'getOccupiedMem', 'allocShared', 'allocShared0', - 'deallocShared', 'reallocShared', 'IsOnStack', 'GC_addCycleRoot', - 'GC_disable', 'GC_enable', 'GC_setStrategy', 'GC_enableMarkAndSweep', - 'GC_disableMarkAndSweep', 'GC_fullCollect', 'GC_getStatistics', - 'nimDestroyRange', 'getCurrentException', 'getCurrentExceptionMsg', 'onRaise', - 'likely', 'unlikely', 'rawProc', 'rawEnv', 'finished', 'slurp', 'staticRead', - 'gorge', 'staticExec', 'rand', 'astToStr', 'InstatiationInfo', 'raiseAssert', - 'shallow', 'compiles', 'safeAdd', 'locals', - -- Iterators. - 'countdown', 'countup', 'items', 'pairs', 'fields', 'fieldPairs', 'lines', - -- Templates. - 'accumulateResult', 'newException', 'CurrentSourcePath', 'assert', 'doAssert', - 'onFailedAssert', 'eval', - -- Threads. - 'running', 'joinThread', 'joinThreads', 'createThread', 'threadId', - 'myThreadId', - -- Channels. - 'send', 'recv', 'peek', 'ready' -}, nil, true)) - --- Types. -local type = token(l.TYPE , word_match({ - 'int', 'int8', 'int16', 'int32', 'int64', 'uint', 'uint8', 'uint16', 'uint32', - 'uint64', 'float', 'float32', 'float64', 'bool', 'char', 'string', 'cstring', - 'pointer', 'Ordinal', 'auto', 'any', 'TSignedInt', 'TUnsignedInt', 'TInteger', - 'TOrdinal', 'TReal', 'TNumber', 'range', 'array', 'openarray', 'varargs', - 'seq', 'set', 'TSlice', 'TThread', 'TChannel', - -- Meta Types. - 'expr', 'stmt', 'typeDesc', 'void', -}, nil, true)) - --- Constants. -local constant = token(l.CONSTANT, word_match{ - 'on', 'off', 'isMainModule', 'CompileDate', 'CompileTime', 'NimVersion', - 'NimMajor', 'NimMinor', 'NimPatch', 'cpuEndian', 'hostOS', 'hostCPU', - 'appType', 'QuitSuccess', 'QuitFailure', 'inf', 'neginf', 'nan' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('=+-*/<>@$~&%|!?^.:\\`()[]{},;')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'type', type}, - {'constant', constant}, - {'identifier', identifier}, - {'comment', comment}, - {'string', string}, - {'number', number}, - {'operator', operator}, -} - -M._FOLDBYINDENTATION = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/nsis.lua b/dep/scintillua/scintillua-3.6.0/lexers/nsis.lua deleted file mode 100644 index 184858a2..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/nsis.lua +++ /dev/null @@ -1,182 +0,0 @@ --- Copyright 2006-2013 Robert Gieseke. See LICENSE. --- NSIS LPeg lexer --- Based on NSIS 2.46 docs: http://nsis.sourceforge.net/Docs/. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'nsis'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments (4.1). -local line_comment = (';' * l.nonnewline^0) + ('#' * l.nonnewline^0) -local block_comment = '/*' * (l.any - '*/')^0 * '*/' -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local ex_str = l.delimited_range('`') -local string = token(l.STRING, sq_str + dq_str + ex_str) - --- Numbers. -local number = token(l.NUMBER, l.integer) - --- Variables (4.2). -local variable = token(l.VARIABLE, word_match({ - '$0', '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9', - '$R0', '$R1', '$R2', '$R3', '$R4', '$R5', '$R6', '$R7', '$R8', '$R9', - '$INSTDIR', '$OUTDIR', '$CMDLINE', '$LANGUAGE', - 'Var', '/GLOBAL' -}, '$/') + ('$' * l.word)) - --- Constants (4.2.3). -local constant = token(l.CONSTANT, word_match({ - '$PROGRAMFILES', '$PROGRAMFILES32', '$PROGRAMFILES64', - '$COMMONFILES', '$COMMONFILES32', '$COMMONFILES64', - '$DESKTOP', '$EXEDIR', '$EXEFILE', '$EXEPATH', '${NSISDIR}', '$WINDIR', - '$SYSDIR', '$TEMP', '$STARTMENU', '$SMPROGRAMS', '$SMSTARTUP', - '$QUICKLAUNCH','$DOCUMENTS', '$SENDTO', '$RECENT', '$FAVORITES', '$MUSIC', - '$PICTURES', '$VIDEOS', '$NETHOOD', '$FONTS', '$TEMPLATES', '$APPDATA', - '$LOCALAPPDATA', '$PRINTHOOD', '$INTERNET_CACHE', '$COOKIES', '$HISTORY', - '$PROFILE', '$ADMINTOOLS', '$RESOURCES', '$RESOURCES_LOCALIZED', - '$CDBURN_AREA', '$HWNDPARENT', '$PLUGINSDIR', -}, '$_{}')) --- TODO? Constants used in strings: $$ $\r $\n $\t - --- Labels (4.3). -local label = token(l.LABEL, l.word * ':') - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ --- Pages (4.5). - 'Page', 'UninstPage', 'PageEx', 'PageEnd', 'PageExEnd', --- Section commands (4.6). - 'AddSize', 'Section', 'SectionEnd', 'SectionIn', 'SectionGroup', - 'SectionGroupEnd', --- Functions (4.7). - 'Function', 'FunctionEnd', --- Callbacks (4.7.2). - '.onGUIInit', '.onInit', '.onInstFailed', '.onInstSuccess', '.onGUIEnd', - '.onMouseOverSection', '.onRebootFailed', '.onSelChange', '.onUserAbort', - '.onVerifyInstDir', 'un.onGUIInit', 'un.onInit', 'un.onUninstFailed', - 'un.onUninstSuccess', 'un.onGUIEnd', 'un.onRebootFailed', 'un.onSelChange', - 'un.onUserAbort', --- General Attributes (4.8.1). - 'AddBrandingImage', 'AllowRootDirInstall', 'AutoCloseWindow', 'BGFont', - 'BGFont', 'BrandingText', '/TRIMLEFT', '/TRIMRIGHT', '/TRIMCENTER', 'Caption', - 'ChangeUI', 'CheckBitmap', 'CompletedText', 'ComponentText', 'CRCCheck', - 'DetailsButtonText', 'DirText', 'DirVar', 'DirVerify', 'FileErrorText', - 'Icon', 'InstallButtonText', 'InstallColors', 'InstallDir', - 'InstallDirRegKey', 'InstProgressFlags', 'InstType', 'LicenseBkColor', - 'LicenseData', 'LicenseForceSelection', 'LicenseText', 'MiscButtonText', - 'Name', 'OutFile', 'RequestExecutionLevel', 'SetFont', 'ShowInstDetails', - 'ShowUninstDetails', 'SilentInstall', 'SilentUnInstall', 'SpaceTexts', - 'SubCaption', 'UninstallButtonText', 'UninstallCaption', 'UninstallIcon', - 'UninstallSubCaption', 'UninstallText', 'WindowIcon', 'XPStyle', 'admin', - 'auto', 'bottom', 'checkbox', 'false', 'force', 'height', 'hide', 'highest', - 'leave', 'left', 'nevershow', 'none', 'normal', 'off', 'on', 'radiobuttons', - 'right', 'show', 'silent', 'silentlog', 'top', 'true', 'user', 'width', --- Compiler Flags (4.8.2). - 'AllowSkipFiles', 'FileBufSize', 'SetCompress', 'SetCompressor', - '/SOLID', '/FINAL', 'zlib', 'bzip2', 'lzma', 'SetCompressorDictSize', - 'SetDatablockOptimize', 'SetDateSave', 'SetOverwrite', 'ifnewer', 'ifdiff', - 'lastused', 'try', --- Version Information (4.8.3). - 'VIAddVersionKey', 'VIProductVersion', '/LANG', - 'ProductName', 'Comments', 'CompanyName', 'LegalCopyright', 'FileDescription', - 'FileVersion', 'ProductVersion', 'InternalName', 'LegalTrademarks', - 'OriginalFilename', 'PrivateBuild', 'SpecialBuild', --- Basic Instructions (4.9.1). - 'Delete', '/REBOOTOK', 'Exec', 'ExecShell', 'ExecShell', 'File', '/nonfatal', - 'Rename', 'ReserveFile', 'RMDir', 'SetOutPath', --- Registry, INI, File Instructions (4.9.2). - 'DeleteINISec', 'DeleteINIStr', 'DeleteRegKey', '/ifempty', - 'DeleteRegValue', 'EnumRegKey', 'EnumRegValue', 'ExpandEnvStrings', - 'FlushINI', 'ReadEnvStr', 'ReadINIStr', 'ReadRegDWORD', 'ReadRegStr', - 'WriteINIStr', 'WriteRegBin', 'WriteRegDWORD', 'WriteRegStr', - 'WriteRegExpandStr', 'HKCR', 'HKEY_CLASSES_ROOT', 'HKLM', 'HKEY_LOCAL_MACHINE', - 'HKCU', 'HKEY_CURRENT_USER', 'HKU', 'HKEY_USERS', 'HKCC', - 'HKEY_CURRENT_CONFIG', 'HKDD', 'HKEY_DYN_DATA', 'HKPD', - 'HKEY_PERFORMANCE_DATA', 'SHCTX', 'SHELL_CONTEXT', - --- General Purpose Instructions (4.9.3). - 'CallInstDLL', 'CopyFiles', - '/SILENT', '/FILESONLY', 'CreateDirectory', 'CreateShortCut', 'GetDLLVersion', - 'GetDLLVersionLocal', 'GetFileTime', 'GetFileTimeLocal', 'GetFullPathName', - '/SHORT', 'GetTempFileName', 'SearchPath', 'SetFileAttributes', 'RegDLL', - 'UnRegDLL', --- Flow Control Instructions (4.9.4). - 'Abort', 'Call', 'ClearErrors', 'GetCurrentAddress', 'GetFunctionAddress', - 'GetLabelAddress', 'Goto', 'IfAbort', 'IfErrors', 'IfFileExists', - 'IfRebootFlag', 'IfSilent', 'IntCmp', 'IntCmpU', 'MessageBox', 'MB_OK', - 'MB_OKCANCEL', 'MB_ABORTRETRYIGNORE', 'MB_RETRYCANCEL', 'MB_YESNO', - 'MB_YESNOCANCEL', 'MB_ICONEXCLAMATION', 'MB_ICONINFORMATION', - 'MB_ICONQUESTION', 'MB_ICONSTOP', 'MB_USERICON', 'MB_TOPMOST', - 'MB_SETFOREGROUND', 'MB_RIGHT', 'MB_RTLREADING', 'MB_DEFBUTTON1', - 'MB_DEFBUTTON2', 'MB_DEFBUTTON3', 'MB_DEFBUTTON4', 'IDABORT', 'IDCANCEL', - 'IDIGNORE', 'IDNO', 'IDOK', 'IDRETRY', 'IDYES', 'Return', 'Quit', 'SetErrors', - 'StrCmp', 'StrCmpS', --- File Instructions (4.9.5). - 'FileClose', 'FileOpen', 'FileRead', 'FileReadByte', 'FileSeek', 'FileWrite', - 'FileWriteByte', 'FindClose', 'FindFirst', 'FindNext', --- Uninstaller Instructions (4.9.6). - 'WriteUninstaller', --- Miscellaneous Instructions (4.9.7). - 'GetErrorLevel', 'GetInstDirError', 'InitPluginsDir', 'Nop', 'SetErrorLevel', - 'SetRegView', 'SetShellVarContext', 'all', 'current', 'Sleep', --- String Manipulation Instructions (4.9.8). - 'StrCpy', 'StrLen', --- Stack Support (4.9.9). - 'Exch', 'Pop', 'Push', --- Integer Support (4.9.10). - 'IntFmt', 'IntOp', --- Reboot Instructions (4.9.11). - 'Reboot', 'SetRebootFlag', --- Install Logging Instructions (4.9.12). - 'LogSet', 'LogText', --- Section Management (4.9.13). - 'SectionSetFlags', 'SectionGetFlags', 'SectionGetFlags', - 'SectionSetText', 'SectionGetText', 'SectionSetInstTypes', - 'SectionGetInstTypes', 'SectionSetSize', 'SectionGetSize', 'SetCurInstType', - 'GetCurInstType', 'InstTypeSetText', 'InstTypeGetText', --- User Interface Instructions (4.9.14). - 'BringToFront', 'CreateFont', 'DetailPrint', 'EnableWindow', 'FindWindow', - 'GetDlgItem', 'HideWindow', 'IsWindow', 'LockWindow', 'SendMessage', - 'SetAutoClose', 'SetBrandingImage', 'SetDetailsView', 'SetDetailsPrint', - 'listonly','textonly', 'both', 'SetCtlColors', '/BRANDING', 'SetSilent', - 'ShowWindow', --- Multiple Languages Instructions (4.9.15). - 'LoadLanguageFile', 'LangString', 'LicenseLangString', --- Compile time commands (5). - '!include', '!addincludedir', '!addplugindir', '!appendfile', '!cd', - '!delfile', '!echo', '!error', '!execute', '!packhdr', '!system', '!tempfile', - '!warning', '!verbose', '{__FILE__}', '{__LINE__}', '{__DATE__}', - '{__TIME__}', '{__TIMESTAMP__}', '{NSIS_VERSION}', '!define', '!undef', - '!ifdef', '!ifndef', '!if', '!ifmacrodef', '!ifmacrondef', '!else', '!endif', - '!insertmacro', '!macro', '!macroend', '!searchparse', '!searchreplace', -}, '/!.{}_')) - --- Operators. -local operator = token(l.OPERATOR, S('+-*/%|&^~!<>')) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'string', string}, - {'constant', constant}, - {'variable', variable}, - {'keyword', keyword}, - {'number', number}, - {'operator', operator}, - {'label', label}, - {'identifier', identifier}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/null.lua b/dep/scintillua/scintillua-3.6.0/lexers/null.lua deleted file mode 100644 index d5a11313..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/null.lua +++ /dev/null @@ -1,6 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Null LPeg lexer. - -local M = {_NAME = 'null'} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/objective_c.lua b/dep/scintillua/scintillua-3.6.0/lexers/objective_c.lua deleted file mode 100644 index db8a5a2d..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/objective_c.lua +++ /dev/null @@ -1,87 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Objective C LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'objective_c'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = P('L')^-1 * l.delimited_range("'", true) -local dq_str = P('L')^-1 * l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Preprocessor. -local preproc_word = word_match{ - 'define', 'elif', 'else', 'endif', 'error', 'if', 'ifdef', - 'ifndef', 'import', 'include', 'line', 'pragma', 'undef', - 'warning' -} -local preproc = token(l.PREPROCESSOR, - l.starts_line('#') * S('\t ')^0 * preproc_word * - (l.nonnewline_esc^1 + l.space * l.nonnewline_esc^0)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - -- From C. - 'asm', 'auto', 'break', 'case', 'const', 'continue', 'default', 'do', 'else', - 'extern', 'false', 'for', 'goto', 'if', 'inline', 'register', 'return', - 'sizeof', 'static', 'switch', 'true', 'typedef', 'void', 'volatile', 'while', - 'restrict', '_Bool', '_Complex', '_Pragma', '_Imaginary', - -- Objective C. - 'oneway', 'in', 'out', 'inout', 'bycopy', 'byref', 'self', 'super', - -- Preprocessor directives. - '@interface', '@implementation', '@protocol', '@end', '@private', - '@protected', '@public', '@class', '@selector', '@encode', '@defs', - '@synchronized', '@try', '@throw', '@catch', '@finally', - -- Constants. - 'TRUE', 'FALSE', 'YES', 'NO', 'NULL', 'nil', 'Nil', 'METHOD_NULL' -}, '@')) - --- Types. -local type = token(l.TYPE, word_match{ - 'apply_t', 'id', 'Class', 'MetaClass', 'Object', 'Protocol', 'retval_t', - 'SEL', 'STR', 'IMP', 'BOOL', 'TypedStream' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'string', string}, - {'identifier', identifier}, - {'comment', comment}, - {'number', number}, - {'preproc', preproc}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'%l+', '[{}]', '/%*', '%*/', '//'}, - [l.PREPROCESSOR] = { - region = 1, endregion = -1, - ['if'] = 1, ifdef = 1, ifndef = 1, endif = -1 - }, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/pascal.lua b/dep/scintillua/scintillua-3.6.0/lexers/pascal.lua deleted file mode 100644 index 20a78006..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/pascal.lua +++ /dev/null @@ -1,78 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Pascal LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'pascal'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local bblock_comment = '{' * (l.any - '}')^0 * P('}')^-1 -local pblock_comment = '(*' * (l.any - '*)')^0 * P('*)')^-1 -local comment = token(l.COMMENT, line_comment + bblock_comment + pblock_comment) - --- Strings. -local string = token(l.STRING, S('uUrR')^-1 * - l.delimited_range("'", true, true)) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * S('LlDdFf')^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'and', 'array', 'as', 'at', 'asm', 'begin', 'case', 'class', 'const', - 'constructor', 'destructor', 'dispinterface', 'div', 'do', 'downto', 'else', - 'end', 'except', 'exports', 'file', 'final', 'finalization', 'finally', 'for', - 'function', 'goto', 'if', 'implementation', 'in', 'inherited', - 'initialization', 'inline', 'interface', 'is', 'label', 'mod', 'not', - 'object', 'of', 'on', 'or', 'out', 'packed', 'procedure', 'program', - 'property', 'raise', 'record', 'repeat', 'resourcestring', 'set', 'sealed', - 'shl', 'shr', 'static', 'string', 'then', 'threadvar', 'to', 'try', 'type', - 'unit', 'unsafe', 'until', 'uses', 'var', 'while', 'with', 'xor', - 'absolute', 'abstract', 'assembler', 'automated', 'cdecl', 'contains', - 'default', 'deprecated', 'dispid', 'dynamic', 'export', 'external', 'far', - 'forward', 'implements', 'index', 'library', 'local', 'message', 'name', - 'namespaces', 'near', 'nodefault', 'overload', 'override', 'package', - 'pascal', 'platform', 'private', 'protected', 'public', 'published', 'read', - 'readonly', 'register', 'reintroduce', 'requires', 'resident', 'safecall', - 'stdcall', 'stored', 'varargs', 'virtual', 'write', 'writeln', 'writeonly', - 'false', 'nil', 'self', 'true' -}, nil, true)) - --- Functions. -local func = token(l.FUNCTION, word_match({ - 'chr', 'ord', 'succ', 'pred', 'abs', 'round', 'trunc', 'sqr', 'sqrt', - 'arctan', 'cos', 'sin', 'exp', 'ln', 'odd', 'eof', 'eoln' -}, nil, true)) - --- Types. -local type = token(l.TYPE, word_match({ - 'shortint', 'byte', 'char', 'smallint', 'integer', 'word', 'longint', - 'cardinal', 'boolean', 'bytebool', 'wordbool', 'longbool', 'real', 'single', - 'double', 'extended', 'comp', 'currency', 'pointer' -}, nil, true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('.,;^@:=<>+-/*()[]')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'type', type}, - {'string', string}, - {'identifier', identifier}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/perl.lua b/dep/scintillua/scintillua-3.6.0/lexers/perl.lua deleted file mode 100644 index a80248c5..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/perl.lua +++ /dev/null @@ -1,161 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Perl LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V - -local M = {_NAME = 'perl'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '#' * l.nonnewline_esc^0 -local block_comment = l.starts_line('=') * l.alpha * - (l.any - l.newline * '=cut')^0 * (l.newline * '=cut')^-1 -local comment = token(l.COMMENT, block_comment + line_comment) - -local delimiter_matches = {['('] = ')', ['['] = ']', ['{'] = '}', ['<'] = '>'} -local literal_delimitted = P(function(input, index) -- for single delimiter sets - local delimiter = input:sub(index, index) - if not delimiter:find('%w') then -- only non alpha-numerics - local match_pos, patt - if delimiter_matches[delimiter] then - -- Handle nested delimiter/matches in strings. - local s, e = delimiter, delimiter_matches[delimiter] - patt = l.delimited_range(s..e, false, false, true) - else - patt = l.delimited_range(delimiter) - end - match_pos = lpeg.match(patt, input, index) - return match_pos or #input + 1 - end -end) -local literal_delimitted2 = P(function(input, index) -- for 2 delimiter sets - local delimiter = input:sub(index, index) - -- Only consider non-alpha-numerics and non-spaces as delimiters. The - -- non-spaces are used to ignore operators like "-s". - if not delimiter:find('[%w ]') then - local match_pos, patt - if delimiter_matches[delimiter] then - -- Handle nested delimiter/matches in strings. - local s, e = delimiter, delimiter_matches[delimiter] - patt = l.delimited_range(s..e, false, false, true) - else - patt = l.delimited_range(delimiter) - end - first_match_pos = lpeg.match(patt, input, index) - final_match_pos = lpeg.match(patt, input, first_match_pos - 1) - if not final_match_pos then -- using (), [], {}, or <> notation - final_match_pos = lpeg.match(l.space^0 * patt, input, first_match_pos) - end - return final_match_pos or #input + 1 - end -end) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local cmd_str = l.delimited_range('`') -local heredoc = '<<' * P(function(input, index) - local s, e, delimiter = input:find('([%a_][%w_]*)[\n\r\f;]+', index) - if s == index and delimiter then - local end_heredoc = '[\n\r\f]+' - local _, e = input:find(end_heredoc..delimiter, e) - return e and e + 1 or #input + 1 - end -end) -local lit_str = 'q' * P('q')^-1 * literal_delimitted -local lit_array = 'qw' * literal_delimitted -local lit_cmd = 'qx' * literal_delimitted -local lit_tr = (P('tr') + 'y') * literal_delimitted2 * S('cds')^0 -local regex_str = #P('/') * l.last_char_includes('-<>+*!~\\=%&|^?:;([{') * - l.delimited_range('/', true) * S('imosx')^0 -local lit_regex = 'qr' * literal_delimitted * S('imosx')^0 -local lit_match = 'm' * literal_delimitted * S('cgimosx')^0 -local lit_sub = 's' * literal_delimitted2 * S('ecgimosx')^0 -local string = token(l.STRING, sq_str + dq_str + cmd_str + heredoc + lit_str + - lit_array + lit_cmd + lit_tr) + - token(l.REGEX, regex_str + lit_regex + lit_match + lit_sub) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'STDIN', 'STDOUT', 'STDERR', 'BEGIN', 'END', 'CHECK', 'INIT', - 'require', 'use', - 'break', 'continue', 'do', 'each', 'else', 'elsif', 'foreach', 'for', 'if', - 'last', 'local', 'my', 'next', 'our', 'package', 'return', 'sub', 'unless', - 'until', 'while', '__FILE__', '__LINE__', '__PACKAGE__', - 'and', 'or', 'not', 'eq', 'ne', 'lt', 'gt', 'le', 'ge' -}) - --- Functions. -local func = token(l.FUNCTION, word_match({ - 'abs', 'accept', 'alarm', 'atan2', 'bind', 'binmode', 'bless', 'caller', - 'chdir', 'chmod', 'chomp', 'chop', 'chown', 'chr', 'chroot', 'closedir', - 'close', 'connect', 'cos', 'crypt', 'dbmclose', 'dbmopen', 'defined', - 'delete', 'die', 'dump', 'each', 'endgrent', 'endhostent', 'endnetent', - 'endprotoent', 'endpwent', 'endservent', 'eof', 'eval', 'exec', 'exists', - 'exit', 'exp', 'fcntl', 'fileno', 'flock', 'fork', 'format', 'formline', - 'getc', 'getgrent', 'getgrgid', 'getgrnam', 'gethostbyaddr', 'gethostbyname', - 'gethostent', 'getlogin', 'getnetbyaddr', 'getnetbyname', 'getnetent', - 'getpeername', 'getpgrp', 'getppid', 'getpriority', 'getprotobyname', - 'getprotobynumber', 'getprotoent', 'getpwent', 'getpwnam', 'getpwuid', - 'getservbyname', 'getservbyport', 'getservent', 'getsockname', 'getsockopt', - 'glob', 'gmtime', 'goto', 'grep', 'hex', 'import', 'index', 'int', 'ioctl', - 'join', 'keys', 'kill', 'lcfirst', 'lc', 'length', 'link', 'listen', - 'localtime', 'log', 'lstat', 'map', 'mkdir', 'msgctl', 'msgget', 'msgrcv', - 'msgsnd', 'new', 'oct', 'opendir', 'open', 'ord', 'pack', 'pipe', 'pop', - 'pos', 'printf', 'print', 'prototype', 'push', 'quotemeta', 'rand', 'readdir', - 'read', 'readlink', 'recv', 'redo', 'ref', 'rename', 'reset', 'reverse', - 'rewinddir', 'rindex', 'rmdir', 'scalar', 'seekdir', 'seek', 'select', - 'semctl', 'semget', 'semop', 'send', 'setgrent', 'sethostent', 'setnetent', - 'setpgrp', 'setpriority', 'setprotoent', 'setpwent', 'setservent', - 'setsockopt', 'shift', 'shmctl', 'shmget', 'shmread', 'shmwrite', 'shutdown', - 'sin', 'sleep', 'socket', 'socketpair', 'sort', 'splice', 'split', 'sprintf', - 'sqrt', 'srand', 'stat', 'study', 'substr', 'symlink', 'syscall', 'sysread', - 'sysseek', 'system', 'syswrite', 'telldir', 'tell', 'tied', 'tie', 'time', - 'times', 'truncate', 'ucfirst', 'uc', 'umask', 'undef', 'unlink', 'unpack', - 'unshift', 'untie', 'utime', 'values', 'vec', 'wait', 'waitpid', 'wantarray', - 'warn', 'write' -}, '2')) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Variables. -local special_var = '$' * ('^' * S('ADEFHILMOPSTWX')^-1 + - S('\\"[]\'&`+*.,;=%~?@<>(|/!-') + - ':' * (l.any - ':') + P('$') * -l.word + l.digit^1) -local plain_var = ('$#' + S('$@%')) * P('$')^0 * l.word + '$#' -local variable = token(l.VARIABLE, special_var + plain_var) - --- Operators. -local operator = token(l.OPERATOR, S('-<>+*!~\\=/%&|^.?:;()[]{}')) - --- Markers. -local marker = token(l.COMMENT, word_match{'__DATA__', '__END__'} * l.any^0) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'marker', marker}, - {'function', func}, - {'string', string}, - {'identifier', identifier}, - {'comment', comment}, - {'number', number}, - {'variable', variable}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[%[%]{}]', '#'}, - [l.OPERATOR] = {['['] = 1, [']'] = -1, ['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['#'] = l.fold_line_comments('#')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/php.lua b/dep/scintillua/scintillua-3.6.0/lexers/php.lua deleted file mode 100644 index feaa670a..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/php.lua +++ /dev/null @@ -1,99 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- PHP LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V - -local M = {_NAME = 'php'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = (P('//') + '#') * l.nonnewline^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, block_comment + line_comment) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local bt_str = l.delimited_range('`') -local heredoc = '<<<' * P(function(input, index) - local _, e, delimiter = input:find('([%a_][%w_]*)[\n\r\f]+', index) - if delimiter then - local _, e = input:find('[\n\r\f]+'..delimiter, e) - return e and e + 1 - end -end) -local string = token(l.STRING, sq_str + dq_str + bt_str + heredoc) --- TODO: interpolated code. - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'and', 'array', 'as', 'bool', 'boolean', 'break', 'case', - 'cfunction', 'class', 'const', 'continue', 'declare', 'default', - 'die', 'directory', 'do', 'double', 'echo', 'else', 'elseif', - 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', - 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'false', - 'float', 'for', 'foreach', 'function', 'global', 'if', 'include', - 'include_once', 'int', 'integer', 'isset', 'list', 'new', 'null', - 'object', 'old_function', 'or', 'parent', 'print', 'real', - 'require', 'require_once', 'resource', 'return', 'static', - 'stdclass', 'string', 'switch', 'true', 'unset', 'use', 'var', - 'while', 'xor', '__class__', '__file__', '__function__', - '__line__', '__sleep', '__wakeup' -}) - --- Variables. -local word = (l.alpha + '_' + R('\127\255')) * (l.alnum + '_' + R('\127\255'))^0 -local variable = token(l.VARIABLE, '$' * word) - --- Identifiers. -local identifier = token(l.IDENTIFIER, word) - --- Operators. -local operator = token(l.OPERATOR, S('!@%^*&()-+=|/.,;:<>[]{}') + '?' * -P('>')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'variable', variable}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - --- Embedded in HTML. -local html = l.load('html') - --- Embedded PHP. -local php_start_rule = token('php_tag', '') -l.embed_lexer(html, M, php_start_rule, php_end_rule) - -M._tokenstyles = { - php_tag = l.STYLE_EMBEDDED -} - -local _foldsymbols = html._foldsymbols -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '<%?' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '%?>' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '/%*' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '%*/' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '//' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '#' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '[{}()]' -_foldsymbols.php_tag = {[''] = -1} -_foldsymbols[l.COMMENT]['/*'], _foldsymbols[l.COMMENT]['*/'] = 1, -1 -_foldsymbols[l.COMMENT]['//'] = l.fold_line_comments('//') -_foldsymbols[l.COMMENT]['#'] = l.fold_line_comments('#') -_foldsymbols[l.OPERATOR] = {['{'] = 1, ['}'] = -1, ['('] = 1, [')'] = -1} -M._foldsymbols = _foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/pike.lua b/dep/scintillua/scintillua-3.6.0/lexers/pike.lua deleted file mode 100644 index d5a130c0..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/pike.lua +++ /dev/null @@ -1,70 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Pike LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'pike'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local nested_comment = l.nested_pair('/*', '*/') -local comment = token(l.COMMENT, line_comment + nested_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local lit_str = '#' * l.delimited_range('"') -local string = token(l.STRING, sq_str + dq_str + lit_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * S('lLdDfF')^-1) - --- Preprocessors. -local preproc = token(l.PREPROCESSOR, l.starts_line('#') * l.nonnewline^0) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'break', 'case', 'catch', 'continue', 'default', 'do', 'else', 'for', - 'foreach', 'gauge', 'if', 'lambda', 'return', 'sscanf', 'switch', 'while', - 'import', 'inherit', - -- Type modifiers. - 'constant', 'extern', 'final', 'inline', 'local', 'nomask', 'optional', - 'private', 'protected', 'public', 'static', 'variant' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'array', 'class', 'float', 'function', 'int', 'mapping', 'mixed', 'multiset', - 'object', 'program', 'string', 'void' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('<>=!+-/*%&|^~@`.,:;()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'preproc', preproc}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/pkgbuild.lua b/dep/scintillua/scintillua-3.6.0/lexers/pkgbuild.lua deleted file mode 100644 index 22aa275f..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/pkgbuild.lua +++ /dev/null @@ -1,89 +0,0 @@ --- Copyright 2006-2013 gwash. See LICENSE. --- Archlinux PKGBUILD LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'pkgbuild'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", false, true) -local dq_str = l.delimited_range('"') -local ex_str = l.delimited_range('`') -local heredoc = '<<' * P(function(input, index) - local s, e, _, delimiter = - input:find('(["\']?)([%a_][%w_]*)%1[\n\r\f;]+', index) - if s == index and delimiter then - local _, e = input:find('[\n\r\f]+'..delimiter, e) - return e and e + 1 or #input + 1 - end -end) -local string = token(l.STRING, sq_str + dq_str + ex_str + heredoc) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'patch', 'cd', 'make', 'patch', 'mkdir', 'cp', 'sed', 'install', 'rm', - 'if', 'then', 'elif', 'else', 'fi', 'case', 'in', 'esac', 'while', 'for', - 'do', 'done', 'continue', 'local', 'return', 'git', 'svn', 'co', 'clone', - 'gconf-merge-schema', 'msg', 'echo', 'ln', - -- Operators. - '-a', '-b', '-c', '-d', '-e', '-f', '-g', '-h', '-k', '-p', '-r', '-s', '-t', - '-u', '-w', '-x', '-O', '-G', '-L', '-S', '-N', '-nt', '-ot', '-ef', '-o', - '-z', '-n', '-eq', '-ne', '-lt', '-le', '-gt', '-ge', '-Np', '-i' -}, '-')) - --- Functions. -local func = token(l.FUNCTION, word_match{'build'}) - -local constant = token(l.CONSTANT, word_match{ - 'pkgname', 'pkgver', 'pkgrel', 'pkgdesc', 'arch', 'url', - 'license', 'optdepends', 'depends', 'makedepends', 'provides', - 'conflicts', 'replaces', 'install', 'source', 'md5sums', - 'pkgdir', 'srcdir' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Variables. -local variable = token(l.VARIABLE, - '$' * (S('!#?*@$') + - l.delimited_range('()', true, true) + - l.delimited_range('[]', true, true) + - l.delimited_range('{}', true, true) + - l.delimited_range('`', true, true) + - l.digit^1 + l.word)) - --- Operators. -local operator = token(l.OPERATOR, S('=!<>+-/*^~.,:;?()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'string', string}, - {'number', number}, - {'keyword', keyword}, - {'function', func}, - {'constant', constant}, - {'identifier', identifier}, - {'variable', variable}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[%(%){}]', '#'}, - [l.OPERATOR] = {['('] = 1, [')'] = -1, ['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['#'] = l.fold_line_comments('#')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/powershell.lua b/dep/scintillua/scintillua-3.6.0/lexers/powershell.lua deleted file mode 100644 index a94938bf..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/powershell.lua +++ /dev/null @@ -1,82 +0,0 @@ --- Copyright 2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- PowerShell LPeg lexer. --- Contributed by Jeff Stone. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'powershell'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'Begin', 'Break', 'Continue', 'Do', 'Else', 'End', 'Exit', 'For', 'ForEach', - 'ForEach-Object', 'Get-Date', 'Get-Random', 'If', 'Param', 'Pause', - 'Powershell', 'Process', 'Read-Host', 'Return', 'Switch', 'While', - 'Write-Host' -}, '-', true)) - --- Comparison Operators. -local comparison = token(l.KEYWORD, '-' * word_match({ - 'and', 'as', 'band', 'bor', 'contains', 'eq', 'ge', 'gt', 'is', 'isnot', 'le', - 'like', 'lt', 'match', 'ne', 'nomatch', 'not', 'notcontains', 'notlike', 'or', - 'replace' -}, nil, true)) - --- Parameters. -local parameter = token(l.KEYWORD, '-' * word_match({ - 'Confirm', 'Debug', 'ErrorAction', 'ErrorVariable', 'OutBuffer', - 'OutVariable', 'Verbose', 'WhatIf' -}, nil, true)) - --- Properties. -local property = token(l.KEYWORD, '.' * word_match({ - 'day', 'dayofweek', 'dayofyear', 'hour', 'millisecond', 'minute', 'month', - 'second', 'timeofday', 'year' -}, nil, true)) - --- Types. -local type = token(l.KEYWORD, '[' * word_match({ - 'array', 'boolean', 'byte', 'char', 'datetime', 'decimal', 'double', - 'hashtable', 'int', 'long', 'single', 'string', 'xml' -}, nil, true) * ']') - --- Variables. -local variable = token(l.VARIABLE, '$' * (l.digit^1 + l.word + - l.delimited_range('{}', true, true))) - --- Strings. -local string = token(l.STRING, l.delimited_range('"', true)) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Operators. -local operator = token(l.OPERATOR, S('=!<>+-/*^&|~.,:;?()[]{}%`')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'keyword', keyword}, - {'comparison', comparison}, - {'parameter', parameter}, - {'property', property}, - {'type', type}, - {'variable', variable}, - {'string', string}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/prolog.lua b/dep/scintillua/scintillua-3.6.0/lexers/prolog.lua deleted file mode 100644 index 8fe63dc5..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/prolog.lua +++ /dev/null @@ -1,64 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Prolog LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'prolog'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '%' * l.nonnewline^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.digit^1 * ('.' * l.digit^1)^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'module', 'meta_predicate', 'multifile', 'dynamic', 'abolish', - 'current_output', 'peek_code', 'append', 'current_predicate', 'put_byte', - 'arg', 'current_prolog_flag', 'put_char', 'asserta', 'assert', 'fail', - 'put_code', 'assertz', 'findall', 'read', 'at_end_of_stream', 'float', - 'read_term', 'atom', 'flush_output', 'repeat', 'atom_chars', 'functor', - 'retract', 'atom_codes', 'get_byte', 'set_input', 'atom_concat', 'get_char', - 'set_output', 'atom_length', 'get_code', 'set_prolog_flag', 'atomic', 'halt', - 'set_stream_position', 'bagof', 'integer', 'setof', 'call', 'is', - 'stream_property', 'catch', 'nl', 'sub_atom', 'char_code', 'nonvar', 'throw', - 'char_conversion', 'number', 'clause', 'number_chars', - 'unify_with_occurs_check', 'close', 'number_codes', 'var', 'compound', 'once', - 'copy_term', 'op', 'write', 'writeln', 'write_canonical', 'write_term', - 'writeq', 'current_char_conversion', 'open', 'current_input', 'peek_byte', - 'current_op', 'peek_char', 'false', 'true', 'consult', 'member', 'memberchk', - 'reverse', 'permutation', 'delete', - -- Math. - 'mod', 'div', 'abs', 'exp', 'ln', 'log', 'sqrt', 'round', 'trunc', 'val', - 'cos', 'sin', 'tan', 'arctan', 'random', 'randominit' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('-!+\\|=:;&<>()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/props.lua b/dep/scintillua/scintillua-3.6.0/lexers/props.lua deleted file mode 100644 index ef5edad7..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/props.lua +++ /dev/null @@ -1,47 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Props LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'props'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Equals. -local equals = token(l.OPERATOR, '=') - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local string = token(l.STRING, sq_str + dq_str) - --- Variables. -local variable = token(l.VARIABLE, '$(' * (l.any - ')')^1 * ')') - --- Colors. -local xdigit = l.xdigit -local color = token('color', '#' * xdigit * xdigit * xdigit * xdigit * xdigit * - xdigit) - -M._rules = { - {'whitespace', ws}, - {'color', color}, - {'comment', comment}, - {'equals', equals}, - {'string', string}, - {'variable', variable}, -} - -M._tokenstyles = { - color = l.STYLE_NUMBER -} - -M._LEXBYLINE = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/ps.lua b/dep/scintillua/scintillua-3.6.0/lexers/ps.lua deleted file mode 100644 index 5aa8d629..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/ps.lua +++ /dev/null @@ -1,61 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Postscript LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'ps'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '%' * l.nonnewline^0) - --- Strings. -local arrow_string = l.delimited_range('<>') -local nested_string = l.delimited_range('()', false, false, true) -local string = token(l.STRING, arrow_string + nested_string) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'pop', 'exch', 'dup', 'copy', 'roll', 'clear', 'count', 'mark', 'cleartomark', - 'counttomark', 'exec', 'if', 'ifelse', 'for', 'repeat', 'loop', 'exit', - 'stop', 'stopped', 'countexecstack', 'execstack', 'quit', 'start', - 'true', 'false', 'NULL' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'add', 'div', 'idiv', 'mod', 'mul', 'sub', 'abs', 'ned', 'ceiling', 'floor', - 'round', 'truncate', 'sqrt', 'atan', 'cos', 'sin', 'exp', 'ln', 'log', 'rand', - 'srand', 'rrand' -}) - --- Identifiers. -local word = (l.alpha + '-') * (l.alnum + '-')^0 -local identifier = token(l.IDENTIFIER, word) - --- Operators. -local operator = token(l.OPERATOR, S('[]{}')) - --- Labels. -local label = token(l.LABEL, '/' * word) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'label', label}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/python.lua b/dep/scintillua/scintillua-3.6.0/lexers/python.lua deleted file mode 100644 index a96ac601..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/python.lua +++ /dev/null @@ -1,134 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Python LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'python'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline_esc^0) - --- Strings. -local sq_str = P('u')^-1 * l.delimited_range("'", true) -local dq_str = P('U')^-1 * l.delimited_range('"', true) -local triple_sq_str = "'''" * (l.any - "'''")^0 * P("'''")^-1 -local triple_dq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 --- TODO: raw_strs cannot end in single \. -local raw_sq_str = P('u')^-1 * 'r' * l.delimited_range("'", false, true) -local raw_dq_str = P('U')^-1 * 'R' * l.delimited_range('"', false, true) -local string = token(l.STRING, triple_sq_str + triple_dq_str + sq_str + dq_str + - raw_sq_str + raw_dq_str) - --- Numbers. -local dec = l.digit^1 * S('Ll')^-1 -local bin = '0b' * S('01')^1 * ('_' * S('01')^1)^0 -local oct = '0' * R('07')^1 * S('Ll')^-1 -local integer = S('+-')^-1 * (bin + l.hex_num + oct + dec) -local number = token(l.NUMBER, l.float + integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', - 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', - 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'print', 'raise', - 'return', 'try', 'while', 'with', 'yield', - -- Descriptors/attr access. - '__get__', '__set__', '__delete__', '__slots__', - -- Class. - '__new__', '__init__', '__del__', '__repr__', '__str__', '__cmp__', - '__index__', '__lt__', '__le__', '__gt__', '__ge__', '__eq__', '__ne__', - '__hash__', '__nonzero__', '__getattr__', '__getattribute__', '__setattr__', - '__delattr__', '__call__', - -- Operator. - '__add__', '__sub__', '__mul__', '__div__', '__floordiv__', '__mod__', - '__divmod__', '__pow__', '__and__', '__xor__', '__or__', '__lshift__', - '__rshift__', '__nonzero__', '__neg__', '__pos__', '__abs__', '__invert__', - '__iadd__', '__isub__', '__imul__', '__idiv__', '__ifloordiv__', '__imod__', - '__ipow__', '__iand__', '__ixor__', '__ior__', '__ilshift__', '__irshift__', - -- Conversions. - '__int__', '__long__', '__float__', '__complex__', '__oct__', '__hex__', - '__coerce__', - -- Containers. - '__len__', '__getitem__', '__missing__', '__setitem__', '__delitem__', - '__contains__', '__iter__', '__getslice__', '__setslice__', '__delslice__', - -- Module and class attribs. - '__doc__', '__name__', '__dict__', '__file__', '__path__', '__module__', - '__bases__', '__class__', '__self__', - -- Stdlib/sys. - '__builtin__', '__future__', '__main__', '__import__', '__stdin__', - '__stdout__', '__stderr__', - -- Other. - '__debug__', '__doc__', '__import__', '__name__' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'abs', 'all', 'any', 'apply', 'basestring', 'bool', 'buffer', 'callable', - 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'copyright', - 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', - 'execfile', 'exit', 'file', 'filter', 'float', 'frozenset', 'getattr', - 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'intern', - 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', - 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', - 'property', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', - 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', - 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', - 'zip' -}) - --- Constants. -local constant = token(l.CONSTANT, word_match{ - 'ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', - 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', - 'False', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', - 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', - 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', - 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', - 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', - 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', - 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', - 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', - 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', - 'ValueError', 'Warning', 'ZeroDivisionError' -}) - --- Self. -local self = token('self', P('self')) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('!%^&*()[]{}-=+/|:;.,?<>~`')) - --- Decorators. -local decorator = token('decorator', l.starts_line('@') * l.nonnewline^0) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'constant', constant}, - {'self', self}, - {'identifier', identifier}, - {'comment', comment}, - {'string', string}, - {'number', number}, - {'decorator', decorator}, - {'operator', operator}, -} - - -M._tokenstyles = { - self = l.STYLE_TYPE, - decorator = l.STYLE_PREPROCESSOR -} - -M._FOLDBYINDENTATION = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/rails.lua b/dep/scintillua/scintillua-3.6.0/lexers/rails.lua deleted file mode 100644 index 07f463c8..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/rails.lua +++ /dev/null @@ -1,65 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Ruby on Rails LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S -local table = _G.table - -local M = {_NAME = 'rails'} - --- Whitespace -local ws = token(l.WHITESPACE, l.space^1) - --- Functions. - -local actionpack = token(l.FUNCTION, word_match{ - 'before_filter', 'skip_before_filter', 'skip_after_filter', 'after_filter', - 'around_filter', 'filter', 'filter_parameter_logging', 'layout', - 'require_dependency', 'render', 'render_action', 'render_text', 'render_file', - 'render_template', 'render_nothing', 'render_component', - 'render_without_layout', 'rescue_from', 'url_for', 'redirect_to', - 'redirect_to_path', 'redirect_to_url', 'respond_to', 'helper', - 'helper_method', 'model', 'service', 'observer', 'serialize', 'scaffold', - 'verify', 'hide_action' -}) - -local view_helpers = token(l.FUNCTION, word_match{ - 'check_box', 'content_for', 'error_messages_for', 'form_for', 'fields_for', - 'file_field', 'hidden_field', 'image_submit_tag', 'label', 'link_to', - 'password_field', 'radio_button', 'submit', 'text_field', 'text_area' -}) - -local activerecord = token(l.FUNCTION, word_match{ - 'after_create', 'after_destroy', 'after_save', 'after_update', - 'after_validation', 'after_validation_on_create', - 'after_validation_on_update', 'before_create', 'before_destroy', - 'before_save', 'before_update', 'before_validation', - 'before_validation_on_create', 'before_validation_on_update', 'composed_of', - 'belongs_to', 'has_one', 'has_many', 'has_and_belongs_to_many', 'validate', - 'validates', 'validate_on_create', 'validates_numericality_of', - 'validate_on_update', 'validates_acceptance_of', 'validates_associated', - 'validates_confirmation_of', 'validates_each', 'validates_format_of', - 'validates_inclusion_of', 'validates_exclusion_of', 'validates_length_of', - 'validates_presence_of', 'validates_size_of', 'validates_uniqueness_of', - 'attr_protected', 'attr_accessible', 'attr_readonly', - 'accepts_nested_attributes_for', 'default_scope', 'scope' -}) - -local active_support = token(l.FUNCTION, word_match{ - 'alias_method_chain', 'alias_attribute', 'delegate', 'cattr_accessor', - 'mattr_accessor', 'returning', 'memoize' -}) - --- Extend Ruby lexer to include Rails methods. -local ruby = l.load('ruby') -local _rules = ruby._rules -_rules[1] = {'whitespace', ws} -table.insert(_rules, 3, {'actionpack', actionpack}) -table.insert(_rules, 4, {'view_helpers', view_helpers}) -table.insert(_rules, 5, {'activerecord', activerecord}) -table.insert(_rules, 6, {'active_support', active_support}) -M._rules = _rules -M._foldsymbols = ruby._foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/rebol.lua b/dep/scintillua/scintillua-3.6.0/lexers/rebol.lua deleted file mode 100644 index ecedd5a4..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/rebol.lua +++ /dev/null @@ -1,129 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Rebol LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'rebol'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = ';' * l.nonnewline^0; -local block_comment = 'comment' * P(' ')^-1 * - l.delimited_range('{}', false, true) -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sl_string = l.delimited_range('"', true) -local ml_string = l.delimited_range('{}') -local lit_string = "'" * l.word -local string = token(l.STRING, sl_string + ml_string + lit_string) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'abs', 'absolute', 'add', 'and~', 'at', 'back', 'change', 'clear', - 'complement', 'copy', 'cp', 'divide', 'fifth', 'find', 'first', 'fourth', - 'head', 'insert', 'last', 'make', 'max', 'maximum', 'min', 'minimum', - 'multiply', 'negate', 'next', 'or~', 'pick', 'poke', 'power', 'random', - 'remainder', 'remove', 'second', 'select', 'skip', 'sort', 'subtract', 'tail', - 'third', 'to', 'trim', 'xor~', 'alias', 'all', 'any', 'arccosine', 'arcsine', - 'arctangent', 'bind', 'break', 'browse', 'call', 'caret-to-offset', 'catch', - 'checksum', 'close', 'comment', 'compose', 'compress', 'cosine', 'debase', - 'decompress', 'dehex', 'detab', 'dh-compute-key', 'dh-generate-key', - 'dh-make-key', 'difference', 'disarm', 'do', 'dsa-generate-key', - 'dsa-make-key', 'dsa-make-signature', 'dsa-verify-signature', 'either', - 'else', 'enbase', 'entab', 'exclude', 'exit', 'exp', 'foreach', 'form', - 'free', 'get', 'get-modes', 'halt', 'hide', 'if', 'in', 'intersect', 'load', - 'log-10', 'log-2', 'log-e', 'loop', 'lowercase', 'maximum-of', 'minimum-of', - 'mold', 'not', 'now', 'offset-to-caret', 'open', 'parse', 'prin', 'print', - 'protect', 'q', 'query', 'quit', 'read', 'read-io', 'recycle', 'reduce', - 'repeat', 'return', 'reverse', 'rsa-encrypt', 'rsa-generate-key', - 'rsa-make-key', 'save', 'secure', 'set', 'set-modes', 'show', 'sine', - 'size-text', 'square-root', 'tangent', 'textinfo', 'throw', 'to-hex', - 'to-local-file', 'to-rebol-file', 'trace', 'try', 'union', 'unique', - 'unprotect', 'unset', 'until', 'update', 'uppercase', 'use', 'wait', 'while', - 'write', 'write-io', 'basic-syntax-header', 'crlf', 'font-fixed', - 'font-sans-serif', 'font-serif', 'list-words', 'outstr', 'val', 'value', - 'about', 'alert', 'alter', 'append', 'array', 'ask', 'boot-prefs', - 'build-tag', 'center-face', 'change-dir', 'charset', 'choose', 'clean-path', - 'clear-fields', 'confine', 'confirm', 'context', 'cvs-date', 'cvs-version', - 'decode-cgi', 'decode-url', 'deflag-face', 'delete', 'demo', 'desktop', - 'dirize', 'dispatch', 'do-boot', 'do-events', 'do-face', 'do-face-alt', - 'does', 'dump-face', 'dump-pane', 'echo', 'editor', 'emailer', 'emit', - 'extract', 'find-by-type', 'find-key-face', 'find-window', 'flag-face', - 'flash', 'focus', 'for', 'forall', 'forever', 'forskip', 'func', 'function', - 'get-net-info', 'get-style', 'has', 'help', 'hide-popup', 'import-email', - 'inform', 'input', 'insert-event-func', 'join', 'launch', 'launch-thru', - 'layout', 'license', 'list-dir', 'load-image', 'load-prefs', 'load-thru', - 'make-dir', 'make-face', 'net-error', 'open-events', 'parse-email-addrs', - 'parse-header', 'parse-header-date', 'parse-xml', 'path-thru', 'probe', - 'protect-system', 'read-net', 'read-thru', 'reboot', 'reform', 'rejoin', - 'remold', 'remove-event-func', 'rename', 'repend', 'replace', 'request', - 'request-color', 'request-date', 'request-download', 'request-file', - 'request-list', 'request-pass', 'request-text', 'resend', 'save-prefs', - 'save-user', 'scroll-para', 'send', 'set-font', 'set-net', 'set-para', - 'set-style', 'set-user', 'set-user-name', 'show-popup', 'source', - 'split-path', 'stylize', 'switch', 'throw-on-error', 'to-binary', - 'to-bitset', 'to-block', 'to-char', 'to-date', 'to-decimal', 'to-email', - 'to-event', 'to-file', 'to-get-word', 'to-hash', 'to-idate', 'to-image', - 'to-integer', 'to-issue', 'to-list', 'to-lit-path', 'to-lit-word', 'to-logic', - 'to-money', 'to-none', 'to-pair', 'to-paren', 'to-path', 'to-refinement', - 'to-set-path', 'to-set-word', 'to-string', 'to-tag', 'to-time', 'to-tuple', - 'to-url', 'to-word', 'unfocus', 'uninstall', 'unview', 'upgrade', 'Usage', - 'vbug', 'view', 'view-install', 'view-prefs', 'what', 'what-dir', - 'write-user', 'return', 'at', 'space', 'pad', 'across', 'below', 'origin', - 'guide', 'tabs', 'indent', 'style', 'styles', 'size', 'sense', 'backcolor', - 'do', 'none', - 'action?', 'any-block?', 'any-function?', 'any-string?', 'any-type?', - 'any-word?', 'binary?', 'bitset?', 'block?', 'char?', 'datatype?', 'date?', - 'decimal?', 'email?', 'empty?', 'equal?', 'error?', 'even?', 'event?', - 'file?', 'function?', 'get-word?', 'greater-or-equal?', 'greater?', 'hash?', - 'head?', 'image?', 'index?', 'integer?', 'issue?', 'length?', - 'lesser-or-equal?', 'lesser?', 'library?', 'list?', 'lit-path?', 'lit-word?', - 'logic?', 'money?', 'native?', 'negative?', 'none?', 'not-equal?', 'number?', - 'object?', 'odd?', 'op?', 'pair?', 'paren?', 'path?', 'port?', 'positive?', - 'refinement?', 'routine?', 'same?', 'series?', 'set-path?', 'set-word?', - 'strict-equal?', 'strict-not-equal?', 'string?', 'struct?', 'tag?', 'tail?', - 'time?', 'tuple?', 'unset?', 'url?', 'word?', 'zero?', 'connected?', - 'crypt-strength?', 'exists-key?', 'input?', 'script?', 'type?', 'value?', '?', - '??', 'dir?', 'exists-thru?', 'exists?', 'flag-face?', 'found?', 'in-window?', - 'info?', 'inside?', 'link-app?', 'link?', 'modified?', 'offset?', 'outside?', - 'screen-offset?', 'size?', 'span?', 'view?', 'viewed?', 'win-offset?', - 'within?', - 'action!', 'any-block!', 'any-function!', 'any-string!', 'any-type!', - 'any-word!', 'binary!', 'bitset!', 'block!', 'char!', 'datatype!', 'date!', - 'decimal!', 'email!', 'error!', 'event!', 'file!', 'function!', 'get-word!', - 'hash!', 'image!', 'integer!', 'issue!', 'library!', 'list!', 'lit-path!', - 'lit-word!', 'logic!', 'money!', 'native!', 'none!', 'number!', 'object!', - 'op!', 'pair!', 'paren!', 'path!', 'port!', 'refinement!', 'routine!', - 'series!', 'set-path!', 'set-word!', 'string!', 'struct!', 'symbol!', 'tag!', - 'time!', 'tuple!', 'unset!', 'url!', 'word!', - 'true', 'false', 'self' -}, '~-?!')) - --- Identifiers. -local word = (l.alpha + '-') * (l.alnum + '-')^0 -local identifier = token(l.IDENTIFIER, word) - --- Operators. -local operator = token(l.OPERATOR, S('=<>+/*:()[]')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[%[%]{}]', ';'}, - [l.COMMENT] = {['{'] = 1, ['}'] = -1, [';'] = l.fold_line_comments(';')}, - [l.OPERATOR] = {['['] = 1, [']'] = -1, ['{'] = 1, ['}'] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/rexx.lua b/dep/scintillua/scintillua-3.6.0/lexers/rexx.lua deleted file mode 100644 index 6e13dd3a..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/rexx.lua +++ /dev/null @@ -1,97 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Rexx LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'rexx'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '--' * l.nonnewline_esc^0 -local block_comment = l.nested_pair('/*', '*/') -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Preprocessor. -local preproc = token(l.PREPROCESSOR, l.starts_line('#') * l.nonnewline^0) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'address', 'arg', 'by', 'call', 'class', 'do', 'drop', 'else', 'end', 'exit', - 'expose', 'forever', 'forward', 'guard', 'if', 'interpret', 'iterate', - 'leave', 'method', 'nop', 'numeric', 'otherwise', 'parse', 'procedure', - 'pull', 'push', 'queue', 'raise', 'reply', 'requires', 'return', 'routine', - 'result', 'rc', 'say', 'select', 'self', 'sigl', 'signal', 'super', 'then', - 'to', 'trace', 'use', 'when', 'while', 'until' -}, nil, true)) - --- Functions. -local func = token(l.FUNCTION, word_match({ - 'abbrev', 'abs', 'address', 'arg', 'beep', 'bitand', 'bitor', 'bitxor', 'b2x', - 'center', 'changestr', 'charin', 'charout', 'chars', 'compare', 'consition', - 'copies', 'countstr', 'c2d', 'c2x', 'datatype', 'date', 'delstr', 'delword', - 'digits', 'directory', 'd2c', 'd2x', 'errortext', 'filespec', 'form', - 'format', 'fuzz', 'insert', 'lastpos', 'left', 'length', 'linein', 'lineout', - 'lines', 'max', 'min', 'overlay', 'pos', 'queued', 'random', 'reverse', - 'right', 'sign', 'sourceline', 'space', 'stream', 'strip', 'substr', - 'subword', 'symbol', 'time', 'trace', 'translate', 'trunc', 'value', 'var', - 'verify', 'word', 'wordindex', 'wordlength', 'wordpos', 'words', 'xrange', - 'x2b', 'x2c', 'x2d', 'rxfuncadd', 'rxfuncdrop', 'rxfuncquery', 'rxmessagebox', - 'rxwinexec', 'sysaddrexxmacro', 'sysbootdrive', 'sysclearrexxmacrospace', - 'syscloseeventsem', 'sysclosemutexsem', 'syscls', 'syscreateeventsem', - 'syscreatemutexsem', 'syscurpos', 'syscurstate', 'sysdriveinfo', - 'sysdrivemap', 'sysdropfuncs', 'sysdroprexxmacro', 'sysdumpvariables', - 'sysfiledelete', 'sysfilesearch', 'sysfilesystemtype', 'sysfiletree', - 'sysfromunicode', 'systounicode', 'sysgeterrortext', 'sysgetfiledatetime', - 'sysgetkey', 'sysini', 'sysloadfuncs', 'sysloadrexxmacrospace', 'sysmkdir', - 'sysopeneventsem', 'sysopenmutexsem', 'sysposteventsem', 'syspulseeventsem', - 'sysqueryprocess', 'sysqueryrexxmacro', 'sysreleasemutexsem', - 'sysreorderrexxmacro', 'sysrequestmutexsem', 'sysreseteventsem', 'sysrmdir', - 'syssaverexxmacrospace', 'syssearchpath', 'syssetfiledatetime', - 'syssetpriority', 'syssleep', 'sysstemcopy', 'sysstemdelete', 'syssteminsert', - 'sysstemsort', 'sysswitchsession', 'syssystemdirectory', 'systempfilename', - 'systextscreenread', 'systextscreensize', 'sysutilversion', 'sysversion', - 'sysvolumelabel', 'syswaiteventsem', 'syswaitnamedpipe', 'syswindecryptfile', - 'syswinencryptfile', 'syswinver' -}, '2', true)) - --- Identifiers. -local word = l.alpha * (l.alnum + S('@#$\\.!?_')^0) -local identifier = token(l.IDENTIFIER, word) - --- Operators. -local operator = token(l.OPERATOR, S('=!<>+-/\\*%&|^~.,:;(){}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'preproc', preproc}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[a-z]+', '/%*', '%*/', '%-%-', ':'}, - [l.KEYWORD] = {['do'] = 1, select = 1, ['end'] = -1, ['return'] = -1}, - [l.COMMENT] = { - ['/*'] = 1, ['*/'] = -1, ['--'] = l.fold_line_comments('--') - }, - [l.OPERATOR] = {[':'] = 1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/rhtml.lua b/dep/scintillua/scintillua-3.6.0/lexers/rhtml.lua deleted file mode 100644 index 00dee38d..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/rhtml.lua +++ /dev/null @@ -1,29 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- RHTML LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'rhtml'} - --- Embedded in HTML. -local html = l.load('html') - --- Embedded Ruby. -local ruby = l.load('rails') -local ruby_start_rule = token('rhtml_tag', '<%' * P('=')^-1) -local ruby_end_rule = token('rhtml_tag', '%>') -l.embed_lexer(html, ruby, ruby_start_rule, ruby_end_rule) - -M._tokenstyles = { - rhtml_tag = l.STYLE_EMBEDDED -} - -local _foldsymbols = html._foldsymbols -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '<%%' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '%%>' -_foldsymbols.rhtml_tag = {['<%'] = 1, ['%>'] = -1} -M._foldsymbols = _foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/rstats.lua b/dep/scintillua/scintillua-3.6.0/lexers/rstats.lua deleted file mode 100644 index a17bac09..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/rstats.lua +++ /dev/null @@ -1,53 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- R LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'rstats'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * P('i')^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'break', 'else', 'for', 'if', 'in', 'next', 'repeat', 'return', 'switch', - 'try', 'while', 'Inf', 'NA', 'NaN', 'NULL', 'FALSE', 'TRUE' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'array', 'character', 'complex', 'data.frame', 'double', 'factor', 'function', - 'integer', 'list', 'logical', 'matrix', 'numeric', 'vector' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('<->+*/^=.,:;|$()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/ruby.lua b/dep/scintillua/scintillua-3.6.0/lexers/ruby.lua deleted file mode 100644 index 910b906d..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/ruby.lua +++ /dev/null @@ -1,148 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Ruby LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'ruby'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '#' * l.nonnewline_esc^0 -local block_comment = l.starts_line('=begin') * (l.any - l.newline * '=end')^0 * - (l.newline * '=end')^-1 -local comment = token(l.COMMENT, block_comment + line_comment) - -local delimiter_matches = {['('] = ')', ['['] = ']', ['{'] = '}'} -local literal_delimitted = P(function(input, index) - local delimiter = input:sub(index, index) - if not delimiter:find('[%w\r\n\f\t ]') then -- only non alpha-numerics - local match_pos, patt - if delimiter_matches[delimiter] then - -- Handle nested delimiter/matches in strings. - local s, e = delimiter, delimiter_matches[delimiter] - patt = l.delimited_range(s..e, false, false, true) - else - patt = l.delimited_range(delimiter) - end - match_pos = lpeg.match(patt, input, index) - return match_pos or #input + 1 - end -end) - --- Strings. -local cmd_str = l.delimited_range('`') -local lit_cmd = '%x' * literal_delimitted -local lit_array = '%w' * literal_delimitted -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local lit_str = '%' * S('qQ')^-1 * literal_delimitted -local heredoc = '<<' * P(function(input, index) - local s, e, indented, _, delimiter = - input:find('(%-?)(["`]?)([%a_][%w_]*)%2[\n\r\f;]+', index) - if s == index and delimiter then - local end_heredoc = (#indented > 0 and '[\n\r\f]+ *' or '[\n\r\f]+') - local _, e = input:find(end_heredoc..delimiter, e) - return e and e + 1 or #input + 1 - end -end) --- TODO: regex_str fails with `obj.method /patt/` syntax. -local regex_str = #P('/') * l.last_char_includes('!%^&*([{-=+|:;,?<>~') * - l.delimited_range('/', true, false) * S('iomx')^0 -local lit_regex = '%r' * literal_delimitted * S('iomx')^0 -local string = token(l.STRING, (sq_str + dq_str + lit_str + heredoc + cmd_str + - lit_cmd + lit_array) * S('f')^-1) + - token(l.REGEX, regex_str + lit_regex) - -local word_char = l.alnum + S('_!?') - --- Numbers. -local dec = l.digit^1 * ('_' * l.digit^1)^0 * S('ri')^-1 -local bin = '0b' * S('01')^1 * ('_' * S('01')^1)^0 -local integer = S('+-')^-1 * (bin + l.hex_num + l.oct_num + dec) --- TODO: meta, control, etc. for numeric_literal. -local numeric_literal = '?' * (l.any - l.space) * -word_char -local number = token(l.NUMBER, l.float * S('ri')^-1 + integer + numeric_literal) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'BEGIN', 'END', 'alias', 'and', 'begin', 'break', 'case', 'class', 'def', - 'defined?', 'do', 'else', 'elsif', 'end', 'ensure', 'false', 'for', 'if', - 'in', 'module', 'next', 'nil', 'not', 'or', 'redo', 'rescue', 'retry', - 'return', 'self', 'super', 'then', 'true', 'undef', 'unless', 'until', 'when', - 'while', 'yield', '__FILE__', '__LINE__' -}, '?!')) - --- Functions. -local func = token(l.FUNCTION, word_match({ - 'at_exit', 'autoload', 'binding', 'caller', 'catch', 'chop', 'chop!', 'chomp', - 'chomp!', 'eval', 'exec', 'exit', 'exit!', 'fail', 'fork', 'format', 'gets', - 'global_variables', 'gsub', 'gsub!', 'iterator?', 'lambda', 'load', - 'local_variables', 'loop', 'open', 'p', 'print', 'printf', 'proc', 'putc', - 'puts', 'raise', 'rand', 'readline', 'readlines', 'require', 'select', - 'sleep', 'split', 'sprintf', 'srand', 'sub', 'sub!', 'syscall', 'system', - 'test', 'trace_var', 'trap', 'untrace_var' -}, '?!')) * -S('.:|') - --- Identifiers. -local word = (l.alpha + '_') * word_char^0 -local identifier = token(l.IDENTIFIER, word) - --- Variables. -local global_var = '$' * (word + S('!@L+`\'=~/\\,.;<>_*"$?:') + l.digit + '-' * - S('0FadiIKlpvw')) -local class_var = '@@' * word -local inst_var = '@' * word -local variable = token(l.VARIABLE, global_var + class_var + inst_var) - --- Symbols. -local symbol = token('symbol', ':' * P(function(input, index) - if input:sub(index - 2, index - 2) ~= ':' then return index end -end) * (word_char^1 + sq_str + dq_str)) - --- Operators. -local operator = token(l.OPERATOR, S('!%^&*()[]{}-=+/|:;.,?<>~')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'identifier', identifier}, - {'comment', comment}, - {'string', string}, - {'number', number}, - {'variable', variable}, - {'symbol', symbol}, - {'operator', operator}, -} - -M._tokenstyles = { - symbol = l.STYLE_CONSTANT -} - -local function disambiguate(text, pos, line, s) - return line:sub(1, s - 1):match('^%s*$') and - not text:sub(1, pos - 1):match('\\[ \t]*\r?\n$') and 1 or 0 -end - -M._foldsymbols = { - _patterns = {'%l+', '[%(%)%[%]{}]', '=begin', '=end', '#'}, - [l.KEYWORD] = { - begin = 1, class = 1, def = 1, ['do'] = 1, ['for'] = 1, ['module'] = 1, - case = 1, - ['if'] = disambiguate, ['while'] = disambiguate, - ['unless'] = disambiguate, ['until'] = disambiguate, - ['end'] = -1 - }, - [l.OPERATOR] = { - ['('] = 1, [')'] = -1, ['['] = 1, [']'] = -1, ['{'] = 1, ['}'] = -1 - }, - [l.COMMENT] = { - ['=begin'] = 1, ['=end'] = -1, ['#'] = l.fold_line_comments('#') - } -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/rust.lua b/dep/scintillua/scintillua-3.6.0/lexers/rust.lua deleted file mode 100644 index 4fef3ae4..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/rust.lua +++ /dev/null @@ -1,87 +0,0 @@ --- Copyright 2015 Alejandro Baez (https://twitter.com/a_baez). See LICENSE. --- Rust LPeg lexer. - -local l = require("lexer") -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'rust'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = P('L')^-1 * l.delimited_range("'") -local dq_str = P('L')^-1 * l.delimited_range('"') -local raw_str = "##" * (l.any - '##')^0 * P("##")^-1 -local string = token(l.STRING, dq_str + raw_str) - --- Numbers. -local number = token(l.NUMBER, l.float + - "0b" * (l.dec_num + "_")^1 + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'abstract', 'alignof', 'as', 'become', 'box', - 'break', 'const', 'continue', 'crate', 'do', - 'else', 'enum', 'extern', 'false', 'final', - 'fn', 'for', 'if', 'impl', 'in', - 'let', 'loop', 'macro', 'match', 'mod', - 'move', 'mut', "offsetof", 'override', 'priv', - 'pub', 'pure', 'ref', 'return', 'sizeof', - 'static', 'self', 'struct', 'super', 'true', - 'trait', 'type', 'typeof', 'unsafe', 'unsized', - 'use', 'virtual', 'where', 'while', 'yield' -}) - --- Library types -local library = token(l.LABEL, l.upper * (l.lower + l.dec_num)^1) - --- syntax extensions -local extension = l.word^1 * S("!") - -local func = token(l.FUNCTION, extension) - --- Types. -local type = token(l.TYPE, word_match{ - '()', 'bool', 'isize', 'usize', 'char', 'str', - 'u8', 'u16', 'u32', 'u64', 'i8', 'i16', 'i32', 'i64', - 'f32','f64', -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=`^~@&|?#~:;,.()[]{}')) - --- Attributes. -local attribute = token(l.PREPROCESSOR, "#[" * - (l.nonnewline - ']')^0 * P("]")^-1) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'library', library}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, - {'preprocessor', attribute}, -} - -M._foldsymbols = { - _patterns = {'%l+', '[{}]', '/%*', '%*/', '//'}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')}, - [l.OPERATOR] = {['('] = 1, ['{'] = 1, [')'] = -1, ['}'] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/sass.lua b/dep/scintillua/scintillua-3.6.0/lexers/sass.lua deleted file mode 100644 index 002df271..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/sass.lua +++ /dev/null @@ -1,32 +0,0 @@ --- Copyright 2006-2013 Robert Gieseke. See LICENSE. --- Sass CSS preprocessor LPeg lexer. --- http://sass-lang.com - -local l = require('lexer') -local token = l.token -local P, S = lpeg.P, lpeg.S - -local M = {_NAME = 'sass'} - --- Line comments. -local line_comment = token(l.COMMENT, '//' * l.nonnewline^0) - --- Variables. -local variable = token(l.VARIABLE, '$' * (l.alnum + S('_-'))^1) - --- Mixins. -local mixin = token('mixin', P('@') * l.word) - -local css = l.load('css') -local _rules = css._rules -table.insert(_rules, #_rules - 1, {'mixin', mixin}) -table.insert(_rules, #_rules - 1, {'line_comment', line_comment}) -table.insert(_rules, #_rules - 1, {'variable', variable}) -M._rules = _rules - -M._tokenstyles = css._tokenstyles -M._tokenstyles['mixin'] = l.STYLE_FUNCTION - -M._foldsymbols = css._foldsymbols - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/scala.lua b/dep/scintillua/scintillua-3.6.0/lexers/scala.lua deleted file mode 100644 index d455996e..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/scala.lua +++ /dev/null @@ -1,75 +0,0 @@ --- Copyright 2006-2013 JMS. See LICENSE. --- Scala LPeg Lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'scala'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local symbol = "'" * l.word -local dq_str = l.delimited_range('"', true) -local tq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 -local string = token(l.STRING, tq_str + symbol + dq_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * S('LlFfDd')^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'abstract', 'case', 'catch', 'class', 'def', 'do', 'else', 'extends', 'false', - 'final', 'finally', 'for', 'forSome', 'if', 'implicit', 'import', 'lazy', - 'match', 'new', 'null', 'object', 'override', 'package', 'private', - 'protected', 'return', 'sealed', 'super', 'this', 'throw', 'trait', 'try', - 'true', 'type', 'val', 'var', 'while', 'with', 'yield' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'Array', 'Boolean', 'Buffer', 'Byte', 'Char', 'Collection', 'Double', 'Float', - 'Int', 'Iterator', 'LinkedList', 'List', 'Long', 'Map', 'None', 'Option', - 'Set', 'Short', 'SortedMap', 'SortedSet', 'String', 'TreeMap', 'TreeSet' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}')) - --- Functions. -local func = token(l.FUNCTION, l.word) * #P('(') - --- Classes. -local class_sequence = token(l.KEYWORD, P('class')) * ws^1 * - token(l.CLASS, l.word) - -M._rules = { - {'whitespace', ws}, - {'class', class_sequence}, - {'keyword', keyword}, - {'type', type}, - {'function', func}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/scheme.lua b/dep/scintillua/scintillua-3.6.0/lexers/scheme.lua deleted file mode 100644 index bec5377c..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/scheme.lua +++ /dev/null @@ -1,104 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Scheme LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'scheme'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = ';' * l.nonnewline^0 -local block_comment = '#|' * (l.any - '|#')^0 * P('|#')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local literal = (P("'") + '#' * S('\\bdox')) * l.word -local dq_str = l.delimited_range('"') -local string = token(l.STRING, literal + dq_str) - --- Numbers. -local number = token(l.NUMBER, P('-')^-1 * l.digit^1 * (S('./') * l.digit^1)^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'and', 'begin', 'case', 'cond', 'cond-expand', 'define', 'define-macro', - 'delay', 'do', 'else', 'fluid-let', 'if', 'lambda', 'let', 'let*', 'letrec', - 'or', 'quasiquote', 'quote', 'set!', -}, '-*!')) - --- Functions. -local func = token(l.FUNCTION, word_match({ - 'abs', 'acos', 'angle', 'append', 'apply', 'asin', 'assoc', 'assq', 'assv', - 'atan', 'car', 'cdr', 'caar', 'cadr', 'cdar', 'cddr', 'caaar', 'caadr', - 'cadar', 'caddr', 'cdaar', 'cdadr', 'cddar', 'cdddr', - 'call-with-current-continuation', 'call-with-input-file', - 'call-with-output-file', 'call-with-values', 'call/cc', 'catch', 'ceiling', - 'char->integer', 'char-downcase', 'char-upcase', 'close-input-port', - 'close-output-port', 'cons', 'cos', 'current-input-port', - 'current-output-port', 'delete-file', 'display', 'dynamic-wind', 'eval', - 'exit', 'exact->inexact', 'exp', 'expt', 'file-or-directory-modify-seconds', - 'floor', 'force', 'for-each', 'gcd', 'gensym', 'get-output-string', 'getenv', - 'imag-part', 'integer->char', 'lcm', 'length', 'list', 'list->string', - 'list->vector', 'list-ref', 'list-tail', 'load', 'log', 'magnitude', - 'make-polar', 'make-rectangular', 'make-string', 'make-vector', 'map', 'max', - 'member', 'memq', 'memv', 'min', 'modulo', 'newline', 'nil', 'not', - 'number->string', 'open-input-file', 'open-input-string', 'open-output-file', - 'open-output-string', 'peek-char', 'quotient', 'read', 'read-char', - 'read-line', 'real-part', 'remainder', 'reverse', 'reverse!', 'round', - 'set-car!', 'set-cdr!', 'sin', 'sqrt', 'string', 'string->list', - 'string->number', 'string->symbol', 'string-append', 'string-copy', - 'string-fill!', 'string-length', 'string-ref', 'string-set!', 'substring', - 'symbol->string', 'system', 'tan', 'truncate', 'values', 'vector', - 'vector->list', 'vector-fill!', 'vector-length', 'vector-ref', 'vector-set!', - 'with-input-from-file', 'with-output-to-file', 'write', 'write-char', - 'boolean?', 'char-alphabetic?', 'char-ci<=?', 'char-ci=?', 'char-ci>?', 'char-lower-case?', 'char-numeric?', 'char-ready?', - 'char-upper-case?', 'char-whitespace?', 'char<=?', 'char=?', 'char>?', 'char?', 'complex?', 'eof-object?', 'eq?', 'equal?', - 'eqv?', 'even?', 'exact?', 'file-exists?', 'inexact?', 'input-port?', - 'integer?', 'list?', 'negative?', 'null?', 'number?', 'odd?', 'output-port?', - 'pair?', 'port?', 'positive?', 'procedure?', 'rational?', 'real?', - 'string-ci<=?', 'string-ci=?', 'string-ci>?', - 'string<=?', 'string=?', 'string>?', 'string?', - 'symbol?', 'vector?', 'zero?', - '#t', '#f' -}, '-/<>!?=#')) - --- Identifiers. -local word = (l.alpha + S('-!?')) * (l.alnum + S('-!?'))^0 -local identifier = token(l.IDENTIFIER, word) - --- Operators. -local operator = token(l.OPERATOR, S('<>=*/+-`@%:()')) - --- Entity. -local entity = token('entity', '&' * word) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, - {'entity', entity}, -} - -M._tokenstyles = { - entity = l.STYLE_VARIABLE -} - -M._foldsymbols = { - _patterns = {'[%(%)%[%]{}]', '#|', '|#', ';'}, - [l.OPERATOR] = { - ['('] = 1, [')'] = -1, ['['] = 1, [']'] = -1, ['{'] = 1, ['}'] = -1 - }, - [l.COMMENT] = {['#|'] = 1, ['|#'] = -1, [';'] = l.fold_line_comments(';')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/smalltalk.lua b/dep/scintillua/scintillua-3.6.0/lexers/smalltalk.lua deleted file mode 100644 index 298173fa..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/smalltalk.lua +++ /dev/null @@ -1,62 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Smalltalk LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'smalltalk'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, l.delimited_range('"', false, true)) - --- Strings. -local sq_str = l.delimited_range("'") -local literal = '$' * l.word -local string = token(l.STRING, sq_str + literal) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'true', 'false', 'nil', 'self', 'super', 'isNil', 'not', 'Smalltalk', - 'Transcript' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'Date', 'Time', 'Boolean', 'True', 'False', 'Character', 'String', 'Array', - 'Symbol', 'Integer', 'Object' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S(':=_<>+-/*!()[]')) - --- Labels. -local label = token(l.LABEL, '#' * l.word) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'label', label}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[%[%]]'}, - [l.OPERATOR] = {['['] = 1, [']'] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/sql.lua b/dep/scintillua/scintillua-3.6.0/lexers/sql.lua deleted file mode 100644 index 1ff5a747..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/sql.lua +++ /dev/null @@ -1,79 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- SQL LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'sql'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = (P('--') + '#') * l.nonnewline^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'") -local dq_str = l.delimited_range('"') -local bt_str = l.delimited_range('`') -local string = token(l.STRING, sq_str + dq_str + bt_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'add', 'all', 'alter', 'analyze', 'and', 'as', 'asc', 'asensitive', 'before', - 'between', 'bigint', 'binary', 'blob', 'both', 'by', 'call', 'cascade', - 'case', 'change', 'char', 'character', 'check', 'collate', 'column', - 'condition', 'connection', 'constraint', 'continue', 'convert', 'create', - 'cross', 'current_date', 'current_time', 'current_timestamp', 'current_user', - 'cursor', 'database', 'databases', 'day_hour', 'day_microsecond', - 'day_minute', 'day_second', 'dec', 'decimal', 'declare', 'default', 'delayed', - 'delete', 'desc', 'describe', 'deterministic', 'distinct', 'distinctrow', - 'div', 'double', 'drop', 'dual', 'each', 'else', 'elseif', 'enclosed', - 'escaped', 'exists', 'exit', 'explain', 'false', 'fetch', 'float', 'for', - 'force', 'foreign', 'from', 'fulltext', 'goto', 'grant', 'group', 'having', - 'high_priority', 'hour_microsecond', 'hour_minute', 'hour_second', 'if', - 'ignore', 'in', 'index', 'infile', 'inner', 'inout', 'insensitive', 'insert', - 'int', 'integer', 'interval', 'into', 'is', 'iterate', 'join', 'key', 'keys', - 'kill', 'leading', 'leave', 'left', 'like', 'limit', 'lines', 'load', - 'localtime', 'localtimestamp', 'lock', 'long', 'longblob', 'longtext', 'loop', - 'low_priority', 'match', 'mediumblob', 'mediumint', 'mediumtext', 'middleint', - 'minute_microsecond', 'minute_second', 'mod', 'modifies', 'natural', 'not', - 'no_write_to_binlog', 'null', 'numeric', 'on', 'optimize', 'option', - 'optionally', 'or', 'order', 'out', 'outer', 'outfile', 'precision', - 'primary', 'procedure', 'purge', 'read', 'reads', 'real', 'references', - 'regexp', 'rename', 'repeat', 'replace', 'require', 'restrict', 'return', - 'revoke', 'right', 'rlike', 'schema', 'schemas', 'second_microsecond', - 'select', 'sensitive', 'separator', 'set', 'show', 'smallint', 'soname', - 'spatial', 'specific', 'sql', 'sqlexception', 'sqlstate', 'sqlwarning', - 'sql_big_result', 'sql_calc_found_rows', 'sql_small_result', 'ssl', - 'starting', 'straight_join', 'table', 'terminated', 'text', 'then', - 'tinyblob', 'tinyint', 'tinytext', 'to', 'trailing', 'trigger', 'true', - 'undo', 'union', 'unique', 'unlock', 'unsigned', 'update', 'usage', 'use', - 'using', 'utc_date', 'utc_time', 'utc_timestamp', 'values', 'varbinary', - 'varchar', 'varcharacter', 'varying', 'when', 'where', 'while', 'with', - 'write', 'xor', 'year_month', 'zerofill' -}, nil, true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S(',()')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/swift.lua b/dep/scintillua/scintillua-3.6.0/lexers/swift.lua deleted file mode 100644 index 6b260f7c..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/swift.lua +++ /dev/null @@ -1,81 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Swift LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'swift'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local string = token(l.STRING, P('L')^-1 * l.delimited_range('"', true)) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Preprocessor. -local preproc_word = word_match{ - 'available', 'column', 'else', 'elseif', 'endif', 'file', 'function', 'if', - 'line', 'selector' -} -local preproc = token(l.PREPROCESSOR, - l.starts_line('#') * S('\t ')^0 * preproc_word) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - -- declarations - 'associatedtype', 'class', 'deinit', 'enum', 'extension', 'func', 'import', - 'init', 'inout', 'internal', 'let', 'operator', 'private', 'protocol', - 'public', 'static', 'struct', 'subscript', 'typealias', 'var', - -- statements - 'break', 'case', 'continue', 'default', 'defer', 'do', 'else', 'fallthrough', - 'for', 'guard', 'if', 'in', 'repeat', 'return', 'switch', 'where', 'while', - -- expressions - 'as', 'catch', 'dynamicType', 'false', 'is', 'nil', 'rethrows', 'super', - 'self', 'Self', 'throw', 'throws', 'true', 'try', - -- context-sensitive - 'associativity', 'convenience', 'dynamic', 'didSet', 'final', 'get', 'infix', - 'indirect', 'lazy', 'left', 'mutating', 'none', 'nonmutating', 'optional', - 'override', 'postfix', 'precedence', 'prefix', 'Protocol', 'required', - 'right', 'set', 'Type', 'unowned', 'weak', 'willSet' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=&|?:;,.()[]{}')) - --- Attributes. -local attribute = token(l.TYPE, '@' * l.word) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'preproc', preproc}, - {'operator', operator}, - {'attribute', attribute}, -} - -M._foldsymbols = { - _patterns = {'%l+', '[{}]', '/%*', '%*/', '//'}, - [l.PREPROCESSOR] = { - ['if'] = 1, endif = -1 - }, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/tcl.lua b/dep/scintillua/scintillua-3.6.0/lexers/tcl.lua deleted file mode 100644 index f014c354..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/tcl.lua +++ /dev/null @@ -1,59 +0,0 @@ --- Copyright 2014-2015 Joshua Krämer. See LICENSE. --- Tcl LPeg lexer. --- This lexer follows the TCL dodekalogue (http://wiki.tcl.tk/10259). --- It is based on the previous lexer by Mitchell. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'tcl'} - --- Whitespace. -local whitespace = token(l.WHITESPACE, l.space^1) - --- Separator (semicolon). -local separator = token(l.CLASS, P(';')) - --- Delimiters. -local braces = token(l.KEYWORD, S('{}')) -local quotes = token(l.FUNCTION, '"') -local brackets = token(l.VARIABLE, S('[]')) - --- Argument expander. -local expander = token(l.LABEL, P('{*}')) - --- Variable substitution. -local variable = token(l.STRING, '$' * (l.alnum + '_' + P(':')^2)^0) - --- Backslash substitution. -local backslash = token(l.TYPE, '\\' * ((l.digit * l.digit^-2) + - ('x' * l.xdigit^1) + ('u' * l.xdigit * l.xdigit^-3) + - ('U' * l.xdigit * l.xdigit^-7) + P(1))) - --- Comment. -local comment = token(l.COMMENT, '#' * P(function(input, index) - local i = index - 2 - while i > 0 and input:find('^[ \t]', i) do i = i - 1 end - if i < 1 or input:find('^[\r\n;]', i) then return index end -end) * l.nonnewline^0) - -M._rules = { - {'whitespace', whitespace}, - {'comment', comment}, - {'separator', separator}, - {'expander', expander}, - {'braces', braces}, - {'quotes', quotes}, - {'brackets', brackets}, - {'variable', variable}, - {'backslash', backslash}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '#'}, - [l.KEYWORD] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['#'] = l.fold_line_comments('#')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/template.txt b/dep/scintillua/scintillua-3.6.0/lexers/template.txt deleted file mode 100644 index 4f8c560d..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/template.txt +++ /dev/null @@ -1,20 +0,0 @@ --- ? LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = '?'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - -M._rules = { - {'whitespace', ws}, -} - -M._tokenstyles = { - -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/tex.lua b/dep/scintillua/scintillua-3.6.0/lexers/tex.lua deleted file mode 100644 index 7eb9e754..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/tex.lua +++ /dev/null @@ -1,45 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Plain TeX LPeg lexer. --- Modified by Robert Gieseke. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'tex'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '%' * l.nonnewline^0) - --- TeX environments. -local environment = token('environment', '\\' * (P('begin') + 'end') * l.word) - --- Commands. -local command = token(l.KEYWORD, '\\' * (l.alpha^1 + S('#$&~_^%{}'))) - --- Operators. -local operator = token(l.OPERATOR, S('$&#{}[]')) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'environment', environment}, - {'keyword', command}, - {'operator', operator}, -} - -M._tokenstyles = { - environment = l.STYLE_KEYWORD -} - -M._foldsymbols = { - _patterns = {'\\begin', '\\end', '[{}]', '%%'}, - [l.COMMENT] = {['%'] = l.fold_line_comments('%')}, - ['environment'] = {['\\begin'] = 1, ['\\end'] = -1}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/texinfo.lua b/dep/scintillua/scintillua-3.6.0/lexers/texinfo.lua deleted file mode 100644 index f9644249..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/texinfo.lua +++ /dev/null @@ -1,270 +0,0 @@ --- Copyright 2014-2015 stef@ailleurs.land. See LICENSE. --- Plain Texinfo version 5.2 LPeg lexer --- Freely inspired from Mitchell work and valuable help from him too ! - --- Directives are processed (more or less) in the Reference Card Texinfo order --- Reference Card page for each directive group is in comment for reference - ---[[ -Note: Improving Fold Points use with Texinfo - -At the very beginning of your Texinfo file, it could be wised to insert theses -alias : - -@alias startchapter = comment -@alias endchapter = comment - -Then use this to begin each chapter : - -@endchapter -------------------------------------------------------------------- -@chapter CHAPTER TITLE -@startchapter ------------------------------------------------------------------ - -With the use of Scintilla's `SCI_FOLDALL(SC_FOLDACTION_TOGGLE)` or Textadept's -`buffer:fold_all(buffer.FOLDACTION_TOGGLE)`, you have then a nice chapter -folding, useful with large documents. -]] - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'texinfo'} - -------------------------------------------------------------------------------- --- Common processing -------------------------------------------------------------------------------- - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '@c' * l.nonnewline_esc^0 ---local line_comment_long = '@comment' * l.nonnewline_esc^0 -local block_comment = '@ignore' * (l.any - '@end ignore')^0 * - P('@end ignore')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local string = token(l.STRING, l.delimited_range('{}', false, true, true)) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Identifiers -local identifier = token(l.IDENTIFIER, l.word) - -------------------------------------------------------------------------------- --- Common keywords -------------------------------------------------------------------------------- - -local keyword_base = word_match({ - 'end', - -- Beginning a Texinfo document (page 1, column 1) - 'setfilename', 'settitle', 'insertcopying', - -- Beginning a Texinfo document > Internationlization (page 1, column 1) - 'documentencoding', 'documentlanguage', 'frenchspacing', - -- Beginning a Texinfo document > Info directory specification and HTML - -- document description (page 1, column 1) - 'dircategory', 'direntry', 'documentdescription', - -- Beginning a Texinfo document > Titre pages (page 1, column 1) - 'shorttitlepage', 'center', 'titlefont', 'title', 'subtitle', 'author', - -- Beginning a Texinfo document > Tables of contents (page 1, column 2) - 'shortcontents', 'summarycontents', 'contents', 'setcontentsaftertitlepage', - 'setshortcontentsaftertitlepage', - -- Nodes (page 1, column 2) - 'node', 'top', 'anchor', 'novalidate', - -- Menus (page 1, column 2) - 'menu', 'detailmenu', - -- Cross references > Within the Info system (page 1, column 3) - 'xref', 'pxref', 'ref', 'inforef', 'xrefautomaticsectiontitle', - -- Cross references > Outside of info (page 1, column 3) - 'url', 'cite', - -- Marking text > Markup for regular text (page 1, column 3) - 'var', 'dfn', 'acronym', 'abbr', - -- Marking text > Markup for litteral text (page 1, column 3) - 'code', 'file', 'command', 'env', 'option', 'kbd', 'key', 'email', - 'indicateurl', 'samp', 'verb', - -- Marking text > GUI sequences (page 2, column 1) - 'clicksequence', 'click', 'clickstyle', 'arrow', - -- Marking text > Math (page 2, column 1) - 'math', 'minus', 'geq', 'leq', - -- Marking text > Explicit font selection (page 2, column 1) - 'sc', 'r', 'i', 'slanted', 'b', 'sansserif', 't', - -- Block environments (page 2, column 1) - 'noindent', 'indent', 'exdent', - -- Block environments > Normally filled displays using regular text fonts - -- (page 2, column 1) - 'quotation', 'smallquotation', 'indentedblock', 'smallindentedblock', - 'raggedright', - -- Block environments > Line-for-line displays using regular test fonts (page - -- 2, column 2) - 'format', 'smallformat', 'display', 'smalldisplay', 'flushleft', 'flushright', - -- Block environments > Displays using fixed-width fonts (page 2, column 2) - 'lisp', 'smalllisp', 'verbatim', - -- List and tables (page 2, column 2) - 'table', 'ftable', 'vtable', 'tab', 'item', 'itemx', 'headitem', - 'headitemfont', 'asis', - -- Indices (page 2, column 3) - 'cindex', 'findex', 'vindex', 'kindex', 'pindex', 'tindex', 'defcodeindex', - 'syncodeindex', 'synindex', 'printindex', - -- Insertions within a paragraph > Characters special to Texinfo (page 2, - -- column 3) - '@', '{', '}', 'backslashcar', 'comma', 'hashcar', ':', '.', '?', '!', 'dmn', - -- Insertions within a paragraph > Accents (page 3, column 1) - -- not implemented - -- Insertions within a paragraph > Non-English characters (page 3, column 1) - -- not implemented - -- Insertions within a paragraph > Other text characters an logos (page 3, - -- column 1) - 'bullet', 'dots', 'enddots', 'euro', 'pounds', 'textdegree', 'copyright', - 'registeredsymbol', 'TeX', 'LaTeX', 'today', - 'guillemetleft', 'guillementright', 'guillemotleft', 'guillemotright', - -- Insertions within a paragraph > Glyphs for code examples (page 3, column 2) - 'equiv', 'error', 'expansion', 'point', 'print', 'result', - -- Making and preventing breaks (page 3, column 2) - '*', '/', '-', 'hyphenation', 'tie', 'w', 'refill', - -- Vertical space (page 3, column 2) - 'sp', 'page', 'need', 'group', 'vskip' - -- Definition commands (page 3, column 2) - -- not implemented -}, nil, true) - -local keyword = token(l.KEYWORD, ('@end' * l.space^1 + '@') * keyword_base) - -------------------------------------------------------------------------------- --- Chapter structuring Keywords -------------------------------------------------------------------------------- - -local chapters_base = word_match({ - -- Chapter structuring (page 1, column 2) - 'lowersections', 'raisesections', 'part', - -- Chapter structuring > Numbered, included in contents (page 1, column 2) - 'chapter', 'centerchap', - -- Chapter structuring > Context-dependent, included in contents (page 1, - -- column 2) - 'section', 'subsection', 'subsubsection', - -- Chapter structuring > Unumbered, included in contents (page 1, column 2) - 'unnumbered', 'unnumberedsec', 'unnumberedsubsec', 'unnumberedsubsection', - 'unnumberedsubsubsec', 'unnumberedsubsubsection', - -- Chapter structuring > Letter and numbered, included in contents (page 1, - -- column 2) - 'appendix', 'appendixsec', 'appendixsection', 'appendixsubsec', - 'appendixsubsection', 'appendixsubsubsec', 'appendixsubsubsection', - -- Chapter structuring > Unumbered, not included in contents, no new page - -- (page 1, column 3) - 'chapheading', 'majorheading', 'heading', 'subheading', 'subsubheading' -}, nil, true) - -local chapters = token('chapters', ('@end' * l.space^1 + '@') * chapters_base) - -------------------------------------------------------------------------------- --- Directives Keywords -------------------------------------------------------------------------------- - -local directives_base = word_match({ - 'end', - -- Custom keywords for chapter folding - 'startchapter', 'endchapter', - -- List and tables (page 2, column 2) - 'itemize', 'enumerate', - -- Beginning a Texinfo document (page 1, column 1) - 'titlepage', 'copying', - -- Block environments (page 2, column 1) - 'cartouche', - -- Block environments > Displays using fixed-width fonts (page 2, column 2) - 'example', 'smallexample', - -- List and tables (page 2, column 2) - 'multitable', - -- Floating Displays (page 2, column 3) - 'float', 'listoffloats', 'caption', 'shortcaption', 'image', - -- Floating Displays > Footnotes (page 2, column 3) - 'footnote', 'footnotestyle', - -- Conditionally (in)visible text > Output formats (page 3, column 3) - 'ifdocbook', 'ifhtml', 'ifinfo', 'ifplaintext', 'iftex', 'ifxml', - 'ifnotdocbook', 'ifnothtml', 'ifnotplaintext', - 'ifnottex', 'ifnotxml', 'ifnotinfo', 'inlinefmt', 'inlinefmtifelse', - -- Conditionally (in)visible text > Raw formatter text (page 4, column 1) - 'docbook', 'html', 'tex', 'xml', 'inlineraw', - -- Conditionally (in)visible text > Documents variables (page 4, column 1) - 'set', 'clear', 'value', 'ifset', 'ifclear', 'inlineifset', 'inlineifclear', - -- Conditionally (in)visible text > Testing for commands (page 4, column 1) - 'ifcommanddefined', 'ifcommandnotdefined', 'end', - -- Defining new Texinfo commands (page 4, column 1) - 'alias', 'macro', 'unmacro', 'definfounclose', - -- File inclusion (page 4, column 1) - 'include', 'verbatiminclude', - -- Formatting and headers footers for TeX (page 4, column 1) - 'allowcodebreaks', 'finalout', 'fonttextsize', - -- Formatting and headers footers for TeX > paper size (page 4, column 2) - 'smallbook', 'afourpaper', 'afivepaper', 'afourlatex', 'afourwide', - 'pagesizes', - -- Formatting and headers footers for TeX > Page headers and footers (page 4, - -- column 2) - -- not implemented - -- Document preferences (page 4, column 2) - -- not implemented - -- Ending a Texinfo document (page 4, column 2) - 'bye' -}, nil, case_insensitive_tags) - -local directives = token('directives', - ('@end' * l.space^1 + '@') * directives_base) - -------------------------------------------------------------------------------- --- Special keywords -------------------------------------------------------------------------------- - --- Italics -local emph = token('emph', '@emph' * l.delimited_range('{}', false, true, true)) - --- Bold -local strong = token('strong', - '@strong' * l.delimited_range('{}', false, true, true)) - -------------------------------------------------------------------------------- --- Rules, Tokenstyles and Folds points -------------------------------------------------------------------------------- - -M._rules = { - {'whitespace', ws}, - {'directives', directives}, - {'chapters', chapters}, - {'keyword', keyword}, - {'emph', emph}, - {'strong', strong}, - {'identifier', identifier}, - {'string', string}, - {'number', number}, - {'comment', comment}, -} - -M._tokenstyles = { - directives = l.STYLE_FUNCTION, - chapters = l.STYLE_CLASS, - emph = l.STYLE_STRING..',italics', - strong = l.STYLE_STRING..',bold' -} - -M._foldsymbols = { - _patterns = {'@end %l+', '@%l+'}, - directives = { - ['@titlepage'] = 1, ['@end titlepage'] = -1, - ['@copying'] = 1, ['@end copying'] = -1, - - ['@ifset'] = 1, ['@end ifset'] = -1, - ['@tex'] = 1, ['@end tex'] = -1, - - ['@itemize'] = 1, ['@end itemize'] = -1, - ['@enumerate'] = 1, ['@end enumerate'] = -1, - ['@multitable'] = 1, ['@end multitable'] = -1, - - ['@example'] = 1, ['@end example'] = -1, - ['@smallexample'] = 1, ['@end smallexample'] = -1, - ['@cartouche'] = 1, ['@end cartouche'] = -1, - - ['@startchapter'] = 1, ['@endchapter'] = -1, - } -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/text.lua b/dep/scintillua/scintillua-3.6.0/lexers/text.lua deleted file mode 100644 index 6331f93e..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/text.lua +++ /dev/null @@ -1,6 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Text LPeg lexer. - -local M = {_NAME = 'text'} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/toml.lua b/dep/scintillua/scintillua-3.6.0/lexers/toml.lua deleted file mode 100644 index d7d29602..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/toml.lua +++ /dev/null @@ -1,68 +0,0 @@ --- Copyright 2015 Alejandro Baez (https://twitter.com/a_baez). See LICENSE. --- TOML LPeg lexer. - -local l = require("lexer") -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'toml'} - --- Whitespace -local indent = #l.starts_line(S(' \t')) * - (token(l.WHITESPACE, ' ') + token('indent_error', '\t'))^1 -local ws = token(l.WHITESPACE, S(' \t')^1 + l.newline^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range("'") + l.delimited_range('"')) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Datetime. -local ts = token('timestamp', l.digit * l.digit * l.digit * l.digit * -- year - '-' * l.digit * l.digit^-1 * -- month - '-' * l.digit * l.digit^-1 * -- day - ((S(' \t')^1 + S('tT'))^-1 * -- separator - l.digit * l.digit^-1 * -- hour - ':' * l.digit * l.digit * -- minute - ':' * l.digit * l.digit * -- second - ('.' * l.digit^0)^-1 * -- fraction - ('Z' + -- timezone - S(' \t')^0 * S('-+') * l.digit * l.digit^-1 * - (':' * l.digit * l.digit)^-1)^-1)^-1) - --- kewwords. -local keyword = token(l.KEYWORD, word_match{ - 'true', 'false' -}) - - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('#=+-,.{}[]()')) - -M._rules = { - {'indent', indent}, - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'operator', operator}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'timestamp', ts}, -} - -M._tokenstyles = { - indent_error = 'back:%(color.red)', - timestamp = l.STYLE_NUMBER, -} - -M._FOLDBYINDENTATION = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/vala.lua b/dep/scintillua/scintillua-3.6.0/lexers/vala.lua deleted file mode 100644 index d9a0a3af..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/vala.lua +++ /dev/null @@ -1,75 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Vala LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'vala'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local tq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 -local ml_str = '@' * l.delimited_range('"', false, true) -local string = token(l.STRING, tq_str + sq_str + dq_str + ml_str) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * S('uUlLfFdDmM')^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'class', 'delegate', 'enum', 'errordomain', 'interface', 'namespace', - 'signal', 'struct', 'using', - -- Modifiers. - 'abstract', 'const', 'dynamic', 'extern', 'inline', 'out', 'override', - 'private', 'protected', 'public', 'ref', 'static', 'virtual', 'volatile', - 'weak', - -- Other. - 'as', 'base', 'break', 'case', 'catch', 'construct', 'continue', 'default', - 'delete', 'do', 'else', 'ensures', 'finally', 'for', 'foreach', 'get', 'if', - 'in', 'is', 'lock', 'new', 'requires', 'return', 'set', 'sizeof', 'switch', - 'this', 'throw', 'throws', 'try', 'typeof', 'value', 'var', 'void', 'while', - -- Etc. - 'null', 'true', 'false' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'bool', 'char', 'double', 'float', 'int', 'int8', 'int16', 'int32', 'int64', - 'long', 'short', 'size_t', 'ssize_t', 'string', 'uchar', 'uint', 'uint8', - 'uint16', 'uint32', 'uint64', 'ulong', 'unichar', 'ushort' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/vb.lua b/dep/scintillua/scintillua-3.6.0/lexers/vb.lua deleted file mode 100644 index 6541a92c..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/vb.lua +++ /dev/null @@ -1,64 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- VisualBasic LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'vb'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, (P("'") + word_match({'rem'}, nil, true)) * - l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range('"', true, true)) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * S('LlUuFf')^-2) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - -- Control. - 'If', 'Then', 'Else', 'ElseIf', 'While', 'Wend', 'For', 'To', 'Each', - 'In', 'Step', 'Case', 'Select', 'Return', 'Continue', 'Do', - 'Until', 'Loop', 'Next', 'With', 'Exit', - -- Operators. - 'Mod', 'And', 'Not', 'Or', 'Xor', 'Is', - -- Storage types. - 'Call', 'Class', 'Const', 'Dim', 'ReDim', 'Preserve', 'Function', 'Sub', - 'Property', 'End', 'Set', 'Let', 'Get', 'New', 'Randomize', 'Option', - 'Explicit', 'On', 'Error', 'Execute', - -- Storage modifiers. - 'Private', 'Public', 'Default', - -- Constants. - 'Empty', 'False', 'Nothing', 'Null', 'True' -}, nil, true)) - --- Types. -local type = token(l.TYPE, word_match({ - 'Boolean', 'Byte', 'Char', 'Date', 'Decimal', 'Double', 'Long', 'Object', - 'Short', 'Single', 'String' -}, nil, true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('=><+-*^&:.,_()')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'comment', comment}, - {'identifier', identifier}, - {'string', string}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/vbscript.lua b/dep/scintillua/scintillua-3.6.0/lexers/vbscript.lua deleted file mode 100644 index f4d9f365..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/vbscript.lua +++ /dev/null @@ -1,63 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- VisualBasic LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'vbscript'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, (P("'") + word_match({'rem'}, nil, true)) * l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range('"', true, true)) - --- Numbers. -local number = token(l.NUMBER, (l.float + l.integer) * S('LlUuFf')^-2) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - -- Control. - 'If', 'Then', 'Else', 'ElseIf', 'While', 'Wend', 'For', 'To', 'Each', - 'In', 'Step', 'Case', 'Select', 'Return', 'Continue', 'Do', - 'Until', 'Loop', 'Next', 'With', 'Exit', - -- Operators. - 'Mod', 'And', 'Not', 'Or', 'Xor', 'Is', - -- Storage types. - 'Call', 'Class', 'Const', 'Dim', 'ReDim', 'Preserve', 'Function', 'Sub', - 'Property', 'End', 'Set', 'Let', 'Get', 'New', 'Randomize', 'Option', - 'Explicit', 'On', 'Error', 'Execute', - -- Storage modifiers. - 'Private', 'Public', 'Default', - -- Constants. - 'Empty', 'False', 'Nothing', 'Null', 'True' -}, nil, true)) - --- Types. -local type = token(l.TYPE, word_match({ - 'Boolean', 'Byte', 'Char', 'Date', 'Decimal', 'Double', 'Long', 'Object', - 'Short', 'Single', 'String' -}, nil, true)) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('=><+-*^&:.,_()')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'type', type}, - {'comment', comment}, - {'identifier', identifier}, - {'string', string}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/verilog.lua b/dep/scintillua/scintillua-3.6.0/lexers/verilog.lua deleted file mode 100644 index bfee3b6d..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/verilog.lua +++ /dev/null @@ -1,101 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- Verilog LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'verilog'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local string = token(l.STRING, l.delimited_range('"')) - --- Numbers. -local bin_suffix = S('bB') * S('01_xXzZ')^1 -local oct_suffix = S('oO') * S('01234567_xXzZ')^1 -local dec_suffix = S('dD') * S('0123456789_xXzZ')^1 -local hex_suffix = S('hH') * S('0123456789abcdefABCDEF_xXzZ')^1 -local number = token(l.NUMBER, (l.digit + '_')^1 + "'" * - (bin_suffix + oct_suffix + dec_suffix + - hex_suffix)) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'always', 'assign', 'begin', 'case', 'casex', 'casez', 'default', 'deassign', - 'disable', 'else', 'end', 'endcase', 'endfunction', 'endgenerate', - 'endmodule', 'endprimitive', 'endspecify', 'endtable', 'endtask', 'for', - 'force', 'forever', 'fork', 'function', 'generate', 'if', 'initial', 'join', - 'macromodule', 'module', 'negedge', 'posedge', 'primitive', 'repeat', - 'release', 'specify', 'table', 'task', 'wait', 'while', - -- Compiler directives. - '`include', '`define', '`undef', '`ifdef', '`ifndef', '`else', '`endif', - '`timescale', '`resetall', '`signed', '`unsigned', '`celldefine', - '`endcelldefine', '`default_nettype', '`unconnected_drive', - '`nounconnected_drive', '`protect', '`endprotect', '`protected', - '`endprotected', '`remove_gatename', '`noremove_gatename', '`remove_netname', - '`noremove_netname', '`expand_vectornets', '`noexpand_vectornets', - '`autoexpand_vectornets', - -- Signal strengths. - 'strong0', 'strong1', 'pull0', 'pull1', 'weak0', 'weak1', 'highz0', 'highz1', - 'small', 'medium', 'large' -}, '`01')) - --- Function. -local func = token(l.FUNCTION, word_match({ - '$stop', '$finish', '$time', '$stime', '$realtime', '$settrace', - '$cleartrace', '$showscopes', '$showvars', '$monitoron', '$monitoroff', - '$random', '$printtimescale', '$timeformat', '$display', - -- Built-in primitives. - 'and', 'nand', 'or', 'nor', 'xor', 'xnor', 'buf', 'bufif0', 'bufif1', 'not', - 'notif0', 'notif1', 'nmos', 'pmos', 'cmos', 'rnmos', 'rpmos', 'rcmos', 'tran', - 'tranif0', 'tranif1', 'rtran', 'rtranif0', 'rtranif1', 'pullup', 'pulldown' -}, '$01')) - --- Types. -local type = token(l.TYPE, word_match({ - 'integer', 'reg', 'time', 'realtime', 'defparam', 'parameter', 'event', - 'wire', 'wand', 'wor', 'tri', 'triand', 'trior', 'tri0', 'tri1', 'trireg', - 'vectored', 'scalared', 'input', 'output', 'inout', - 'supply0', 'supply1' -}, '01')) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('=~+-/*<>%&|^~,:;()[]{}')) - -M._rules = { - {'whitespace', ws}, - {'number', number}, - {'keyword', keyword}, - {'function', func}, - {'type', type}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'operator', operator}, -} - -M._foldsymbols = { - _patterns = {'[a-z]+', '[%(%){}]', '/%*', '%*/', '//'}, - [l.KEYWORD] = { - case = 1, casex = 1, casez = 1, endcase = -1, ['function'] = 1, - endfunction = -1, fork = 1, join = -1, table = 1, endtable = -1, task = 1, - endtask = -1, generate = 1, endgenerate = -1, specify = 1, endspecify = -1, - primitive = 1, endprimitive = -1, ['module'] = 1, endmodule = -1, begin = 1, - ['end'] = -1 - }, - [l.OPERATOR] = {['('] = 1, [')'] = -1, ['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/vhdl.lua b/dep/scintillua/scintillua-3.6.0/lexers/vhdl.lua deleted file mode 100644 index 4cad5f79..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/vhdl.lua +++ /dev/null @@ -1,89 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- VHDL LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'vhdl'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '--' * l.nonnewline^0) - --- Strings. -local sq_str = l.delimited_range("'", true, true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Numbers. -local number = token(l.NUMBER, l.float + l.integer) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - 'access', 'after', 'alias', 'all', 'architecture', 'array', 'assert', - 'attribute', 'begin', 'block', 'body', 'buffer', 'bus', 'case', 'component', - 'configuration', 'constant', 'disconnect', 'downto', 'else', 'elsif', 'end', - 'entity', 'exit', 'file', 'for', 'function', 'generate', 'generic', 'group', - 'guarded', 'if', 'impure', 'in', 'inertial', 'inout', 'is', 'label', - 'library', 'linkage', 'literal', 'loop', 'map', 'new', 'next', 'null', 'of', - 'on', 'open', 'others', 'out', 'package', 'port', 'postponed', 'procedure', - 'process', 'pure', 'range', 'record', 'register', 'reject', 'report', - 'return', 'select', 'severity', 'signal', 'shared', 'subtype', 'then', 'to', - 'transport', 'type', 'unaffected', 'units', 'until', 'use', 'variable', - 'wait', 'when', 'while', 'with', 'note', 'warning', 'error', 'failure', - 'and', 'nand', 'or', 'nor', 'xor', 'xnor', 'rol', 'ror', 'sla', 'sll', 'sra', - 'srl', 'mod', 'rem', 'abs', 'not', - 'false', 'true' -}) - --- Functions. -local func = token(l.FUNCTION, word_match{ - 'rising_edge', 'shift_left', 'shift_right', 'rotate_left', 'rotate_right', - 'resize', 'std_match', 'to_integer', 'to_unsigned', 'to_signed', 'unsigned', - 'signed', 'to_bit', 'to_bitvector', 'to_stdulogic', 'to_stdlogicvector', - 'to_stdulogicvector' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'bit', 'bit_vector', 'character', 'boolean', 'integer', 'real', 'time', - 'string', 'severity_level', 'positive', 'natural', 'signed', 'unsigned', - 'line', 'text', 'std_logic', 'std_logic_vector', 'std_ulogic', - 'std_ulogic_vector', 'qsim_state', 'qsim_state_vector', 'qsim_12state', - 'qsim_12state_vector', 'qsim_strength', 'mux_bit', 'mux_vectory', 'reg_bit', - 'reg_vector', 'wor_bit', 'wor_vector' -}) - --- Constants. -local constant = token(l.CONSTANT, word_match{ - 'EVENT', 'BASE', 'LEFT', 'RIGHT', 'LOW', 'HIGH', 'ASCENDING', 'IMAGE', - 'VALUE', 'POS', 'VAL', 'SUCC', 'VAL', 'POS', 'PRED', 'VAL', 'POS', 'LEFTOF', - 'RIGHTOF', 'LEFT', 'RIGHT', 'LOW', 'HIGH', 'RANGE', 'REVERSE', 'LENGTH', - 'ASCENDING', 'DELAYED', 'STABLE', 'QUIET', 'TRANSACTION', 'EVENT', 'ACTIVE', - 'LAST', 'LAST', 'LAST', 'DRIVING', 'DRIVING', 'SIMPLE', 'INSTANCE', 'PATH' -}) - --- Identifiers. -local word = (l.alpha + "'") * (l.alnum + "_" + "'")^1 -local identifier = token(l.IDENTIFIER, word) - --- Operators. -local operator = token(l.OPERATOR, S('=/!:;<>+-/*%&|^~()')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'function', func}, - {'type', type}, - {'constant', constant}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/wsf.lua b/dep/scintillua/scintillua-3.6.0/lexers/wsf.lua deleted file mode 100644 index fc024b2d..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/wsf.lua +++ /dev/null @@ -1,108 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- WSF LPeg lexer (based on XML). --- Contributed by Jeff Stone. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V - -local M = {_NAME = 'wsf'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '')^0 * P('-->')^-1) - --- Strings. -local sq_str = l.delimited_range("'", false, true) -local dq_str = l.delimited_range('"', false, true) -local string = #S('\'"') * l.last_char_includes('=') * - token(l.STRING, sq_str + dq_str) - -local in_tag = P(function(input, index) - local before = input:sub(1, index - 1) - local s, e = before:find('<[^>]-$'), before:find('>[^<]-$') - if s and e then return s > e and index or nil end - if s then return index end - return input:find('^[^<]->', index) and index or nil -end) - --- Numbers. -local number = #l.digit * l.last_char_includes('=') * - token(l.NUMBER, l.digit^1 * P('%')^-1) * in_tag - -local alpha = R('az', 'AZ', '\127\255') -local word_char = l.alnum + S('_-:.??') -local identifier = (l.alpha + S('_-:.??')) * word_char^0 - --- Elements. -local element = token('element', '<' * P('/')^-1 * identifier) - --- Attributes. -local attribute = token('attribute', identifier) * #(l.space^0 * '=') - --- Closing tags. -local tag_close = token('element', P('/')^-1 * '>') - --- Equals. -local equals = token(l.OPERATOR, '=') * in_tag - --- Entities. -local entity = token('entity', '&' * word_match{ - 'lt', 'gt', 'amp', 'apos', 'quot' -} * ';') - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'element', element}, - {'tag_close', tag_close}, - {'attribute', attribute}, - {'equals', equals}, - {'string', string}, - {'number', number}, - {'entity', entity} -} - -M._tokenstyles = { - element = l.STYLE_KEYWORD, - attribute = l.STYLE_TYPE, - entity = l.STYLE_OPERATOR -} - -M._foldsymbols = { - _patterns = {'', ''}, - element = {['<'] = 1, ['/>'] = -1, [''] = -1}, -} - --- Finally, add JavaScript and VBScript as embedded languages - --- Tags that start embedded languages. -M.embed_start_tag = element * - (ws^1 * attribute * ws^0 * equals * ws^0 * string)^0 * - ws^0 * tag_close -M.embed_end_tag = element * tag_close - --- Embedded JavaScript. -local js = l.load('javascript') -local js_start_rule = #(P('')) * M.embed_start_tag -- -l.embed_lexer(M, js, js_start_rule, js_end_rule) - --- Embedded VBScript. -local vbs = l.load('vbscript') -local vbs_start_rule = #(P('')) * M.embed_start_tag -- -l.embed_lexer(M, vbs, vbs_start_rule, vbs_end_rule) - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/xml.lua b/dep/scintillua/scintillua-3.6.0/lexers/xml.lua deleted file mode 100644 index 25e6e45b..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/xml.lua +++ /dev/null @@ -1,99 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- XML LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V - -local M = {_NAME = 'xml'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments and CDATA. -local comment = token(l.COMMENT, '')^0 * P('-->')^-1) -local cdata = token('cdata', '')^0 * P(']]>')^-1) - --- Strings. -local sq_str = l.delimited_range("'", false, true) -local dq_str = l.delimited_range('"', false, true) -local string = #S('\'"') * l.last_char_includes('=') * - token(l.STRING, sq_str + dq_str) - -local in_tag = P(function(input, index) - local before = input:sub(1, index - 1) - local s, e = before:find('<[^>]-$'), before:find('>[^<]-$') - if s and e then return s > e and index or nil end - if s then return index end - return input:find('^[^<]->', index) and index or nil -end) - --- Numbers. -local number = #l.digit * l.last_char_includes('=') * - token(l.NUMBER, l.digit^1 * P('%')^-1) * in_tag - -local alpha = R('az', 'AZ', '\127\255') -local word_char = l.alnum + S('_-:.??') -local identifier = (l.alpha + S('_-:.??')) * word_char^0 -local namespace = token(l.OPERATOR, ':') * token('namespace', identifier) - --- Elements. -local element = token('element', '<' * P('/')^-1 * identifier) * namespace^-1 - --- Attributes. -local attribute = token('attribute', identifier) * namespace^-1 * - #(l.space^0 * '=') - --- Closing tags. -local close_tag = token('element', P('/')^-1 * '>') - --- Equals. -local equals = token(l.OPERATOR, '=') * in_tag - --- Entities. -local entity = token('entity', '&' * word_match{ - 'lt', 'gt', 'amp', 'apos', 'quot' -} * ';') - --- Doctypes and other markup tags. -local doctype = token('doctype', P(''))^0 * token('doctype', '>') - --- Processing instructions. -local proc_insn = token('proc_insn', P(''))^0 * P('?>')^-1) - -M._rules = { - {'whitespace', ws}, - {'comment', comment}, - {'cdata', cdata}, - {'doctype', doctype}, - {'proc_insn', proc_insn}, - {'element', element}, - {'close_tag', close_tag}, - {'attribute', attribute}, - {'equals', equals}, - {'string', string}, - {'number', number}, - {'entity', entity}, -} - -M._tokenstyles = { - element = l.STYLE_KEYWORD, - namespace = l.STYLE_CLASS, - attribute = l.STYLE_TYPE, - cdata = l.STYLE_COMMENT, - entity = l.STYLE_OPERATOR, - doctype = l.STYLE_COMMENT, - proc_insn = l.STYLE_COMMENT, - --markup = l.STYLE_COMMENT -} - -M._foldsymbols = { - _patterns = {'', '', ''}, - element = {['<'] = 1, ['/>'] = -1, [''] = -1}, - cdata = {[''] = -1} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/xtend.lua b/dep/scintillua/scintillua-3.6.0/lexers/xtend.lua deleted file mode 100644 index 500dc336..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/xtend.lua +++ /dev/null @@ -1,112 +0,0 @@ --- Copyright (c) 2014-2015 Piotr Orzechowski [drzewo.org]. See LICENSE. --- Xtend LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'xtend'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = '//' * l.nonnewline_esc^0 -local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local sq_str = l.delimited_range("'", true) -local dq_str = l.delimited_range('"', true) -local string = token(l.STRING, sq_str + dq_str) - --- Templates. -local templ_str = "'''" * (l.any - P("'''"))^0 * P("'''")^-1 -local template = token('template', templ_str, true) - --- Numbers. -local small_suff = S('lL') -local med_suff = P(S('bB') * S('iI')) -local large_suff = S('dD') + S('fF') + P(S('bB') * S('dD')) -local exp = S('eE') * l.digit^1 - -local dec_inf = ('_' * l.digit^1)^0 -local hex_inf = ('_' * l.xdigit^1)^0 -local float_pref = l.digit^1 * '.' * l.digit^1 -local float_suff = exp^-1 * med_suff^-1 * large_suff^-1 - -local dec = l.digit * dec_inf * (small_suff^-1 + float_suff) -local hex = l.hex_num * hex_inf * P('#' * (small_suff + med_suff))^-1 -local float = float_pref * dec_inf * float_suff - -local number = token(l.NUMBER, float + hex + dec) - --- Keywords. -local keyword = token(l.KEYWORD, word_match{ - -- General. - 'abstract', 'annotation', 'as', 'case', 'catch', 'class', 'create', 'def', - 'default', 'dispatch', 'do', 'else', 'enum', 'extends', 'extension', 'final', - 'finally', 'for', 'if', 'implements', 'import', 'interface', 'instanceof', - 'it', 'new', 'override', 'package', 'private', 'protected', 'public', - 'return', 'self', 'static', 'super', 'switch', 'synchronized', 'this', - 'throw', 'throws', 'try', 'typeof', 'val', 'var', 'while', - -- Templates. - -- 'AFTER', 'BEFORE', 'ENDFOR', 'ENDIF', 'FOR', 'IF', 'SEPARATOR', - -- Literals. - 'true', 'false', 'null' -}) - --- Types. -local type = token(l.TYPE, word_match{ - 'boolean', 'byte', 'char', 'double', 'float', 'int', 'long', 'short', 'void', - 'Boolean', 'Byte', 'Character', 'Double', 'Float', 'Integer', 'Long', 'Short', - 'String' -}) - --- Identifiers. -local identifier = token(l.IDENTIFIER, l.word) - --- Operators. -local operator = token(l.OPERATOR, S('+-/*%<>!=^&|?~:;.()[]{}#')) - --- Annotations. -local annotation = token('annotation', '@' * l.word) - --- Functions. -local func = token(l.FUNCTION, l.word) * #P('(') - --- Classes. -local class = token(l.KEYWORD, P('class')) * ws^1 * token(l.CLASS, l.word) - --- Rules. -M._rules = { - {'whitespace', ws}, - {'class', class}, - {'keyword', keyword}, - {'type', type}, - {'function', func}, - {'identifier', identifier}, - {'template', template}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'annotation', annotation}, - {'operator', operator}, - {'error', token(l.ERROR, l.any)}, -} - --- Token styles. -M._tokenstyles = { - annotation = l.STYLE_PREPROCESSOR, - template = l.STYLE_EMBEDDED -} - --- Folding. -M._foldsymbols = { - _patterns = {'[{}]', '/%*', '%*/', '//', 'import'}, - [l.OPERATOR] = {['{'] = 1, ['}'] = -1}, - [l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')}, - [l.KEYWORD] = {['import'] = l.fold_line_comments('import')} -} - -return M diff --git a/dep/scintillua/scintillua-3.6.0/lexers/yaml.lua b/dep/scintillua/scintillua-3.6.0/lexers/yaml.lua deleted file mode 100644 index 6cdf25ce..00000000 --- a/dep/scintillua/scintillua-3.6.0/lexers/yaml.lua +++ /dev/null @@ -1,110 +0,0 @@ --- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- YAML LPeg lexer. --- It does not keep track of indentation perfectly. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'yaml'} - --- Whitespace. -local indent = #l.starts_line(S(' \t')) * - (token(l.WHITESPACE, ' ') + token('indent_error', '\t'))^1 -local ws = token(l.WHITESPACE, S(' \t')^1 + l.newline^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline^0) - --- Strings. -local string = token(l.STRING, l.delimited_range("'") + l.delimited_range('"')) - --- Numbers. -local integer = l.dec_num + l.hex_num + '0' * S('oO') * R('07')^1 -local special_num = '.' * word_match({'inf', 'nan'}, nil, true) -local number = token(l.NUMBER, special_num + l.float + integer) - --- Timestamps. -local ts = token('timestamp', l.digit * l.digit * l.digit * l.digit * -- year - '-' * l.digit * l.digit^-1 * -- month - '-' * l.digit * l.digit^-1 * -- day - ((S(' \t')^1 + S('tT'))^-1 * -- separator - l.digit * l.digit^-1 * -- hour - ':' * l.digit * l.digit * -- minute - ':' * l.digit * l.digit * -- second - ('.' * l.digit^0)^-1 * -- fraction - ('Z' + -- timezone - S(' \t')^0 * S('-+') * l.digit * l.digit^-1 * - (':' * l.digit * l.digit)^-1)^-1)^-1) - --- Constants. -local constant = token(l.CONSTANT, - word_match({'null', 'true', 'false'}, nil, true)) - --- Types. -local type = token(l.TYPE, '!!' * word_match({ - -- Collection types. - 'map', 'omap', 'pairs', 'set', 'seq', - -- Scalar types. - 'binary', 'bool', 'float', 'int', 'merge', 'null', 'str', 'timestamp', - 'value', 'yaml' -}, nil, true) + '!' * l.delimited_range('<>')) - --- Document boundaries. -local doc_bounds = token('document', l.starts_line(P('---') + '...')) - --- Directives -local directive = token('directive', l.starts_line('%') * l.nonnewline^1) - -local word = (l.alpha + '-' * -l.space) * (l.alnum + '-')^0 - --- Keys and literals. -local colon = S(' \t')^0 * ':' * (l.space + -1) -local key = token(l.KEYWORD, #word * (l.nonnewline - colon)^1 * #colon) -local value = #word * (l.nonnewline - l.space^0 * S(',]}'))^1 -local block = S('|>') * S('+-')^-1 * (l.newline + -1) * function(input, index) - local rest = input:sub(index) - local level = #rest:match('^( *)') - for pos, indent, line in rest:gmatch('() *()([^\r\n]+)') do - if indent - pos < level and line ~= ' ' or level == 0 and pos > 1 then - return index + pos - 1 - end - end - return #input + 1 -end -local literal = token('literal', value + block) - --- Indicators. -local anchor = token(l.LABEL, '&' * word) -local alias = token(l.VARIABLE, '*' * word) -local tag = token('tag', '!' * word * P('!')^-1) -local reserved = token(l.ERROR, S('@`') * word) -local indicator_chars = token(l.OPERATOR, S('-?:,[]{}!')) - -M._rules = { - {'indent', indent}, - {'whitespace', ws}, - {'comment', comment}, - {'doc_bounds', doc_bounds}, - {'key', key}, - {'literal', literal}, - {'timestamp', ts}, - {'number', number}, - {'constant', constant}, - {'type', type}, - {'indicator', tag + indicator_chars + alias + anchor + reserved}, - {'directive', directive}, -} - -M._tokenstyles = { - indent_error = 'back:%(color.red)', - document = l.STYLE_CONSTANT, - literal = l.STYLE_DEFAULT, - timestamp = l.STYLE_NUMBER, - tag = l.STYLE_CLASS, - directive = l.STYLE_PREPROCESSOR, -} - -M._FOLDBYINDENTATION = true - -return M diff --git a/dep/scintillua/scintillua-3.6.0/scintillua.luadoc b/dep/scintillua/scintillua-3.6.0/scintillua.luadoc deleted file mode 100644 index 3456b3de..00000000 --- a/dep/scintillua/scintillua-3.6.0/scintillua.luadoc +++ /dev/null @@ -1,170 +0,0 @@ --- Copyright 2007-2015 Mitchell mitchell.att.foicica.com. See LICENSE. --- This is a DUMMY FILE used for making LuaDoc for the Scintillua API. - ---- --- ## Overview --- --- The Scintillua Scintilla lexer has its own API to avoid any modifications to --- Scintilla itself. It is invoked using [`SCI_PRIVATELEXERCALL`][]. Please note --- that some of the names of the API calls do not make perfect sense. This is a --- tradeoff in order to keep Scintilla unmodified. --- --- [`SCI_PRIVATELEXERCALL`]: http://scintilla.org/ScintillaDoc.html#LexerObjects --- --- The following notation is used: --- --- SCI_PRIVATELEXERCALL (int operation, void *pointer) --- --- This means you would call Scintilla like this: --- --- SendScintilla(sci, SCI_PRIVATELEXERCALL, operation, pointer); --- --- ## Scintillua Usage Example --- --- Here is a pseudo-code example: --- --- init_app() { --- sci = scintilla_new() --- lib = "/home/mitchell/app/lexers/liblexlpeg.so" --- SendScintilla(sci, SCI_LOADLEXERLIBRARY, 0, lib) --- } --- --- create_doc() { --- doc = SendScintilla(sci, SCI_CREATEDOCUMENT) --- SendScintilla(sci, SCI_SETDOCPOINTER, 0, doc) --- SendScintilla(sci, SCI_SETLEXERLANGUAGE, 0, "lpeg") --- home = "/home/mitchell/app/lexers" --- SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.home", home) --- SendScintilla(sci, SCI_SETPROPERTY, "lexer.lpeg.color.theme", "light") --- fn = SendScintilla(sci, SCI_GETDIRECTFUNCTION) --- SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETDIRECTFUNCTION, fn) --- psci = SendScintilla(sci, SCI_GETDIRECTPOINTER) --- SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, psci) --- SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua") --- } --- --- set_lexer(lang) { --- psci = SendScintilla(sci, SCI_GETDIRECTPOINTER) --- SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, psci) --- SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, lang) --- } -module('Scintillua') - ---- --- Tells Scintillua the address of the function that handles Scintilla messages. --- --- Despite the name `SCI_GETDIRECTFUNCTION`, it only notifies Scintillua what --- the value of `SciFnDirect` obtained from [`SCI_GETDIRECTFUNCTION`][] is. It --- does not return anything. --- Use this if you would like to have the Scintillua lexer set all Lua LPeg --- lexer styles automatically. This is useful for maintaining a consistent color --- theme. Do not use this if your application maintains its own color theme. --- --- If you use this call, it *must* be made *once* for each Scintilla buffer that --- was created using [`SCI_CREATEDOCUMENT`][]. You must also use the --- [`SCI_SETDOCPOINTER()`](#SCI_SETDOCPOINTER) Scintillua API call. --- --- [`SCI_GETDIRECTFUNCTION`]: http://scintilla.org/ScintillaDoc.html#SCI_GETDIRECTFUNCTION --- [`SCI_CREATEDOCUMENT`]: http://scintilla.org/ScintillaDoc.html#SCI_CREATEDOCUMENT --- @param SciFnDirect The pointer returned by [`SCI_GETDIRECTFUNCTION`][]. --- @usage fn = SendScintilla(sci, SCI_GETDIRECTFUNCTION) --- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_GETDIRECTFUNCTION, fn) --- @see SCI_SETDOCPOINTER --- @name SCI_GETDIRECTFUNCTION -function SCI_PRIVATELEXERCALL(SCI_GETDIRECTFUNCTION, SciFnDirect) end - ---- --- Tells Scintillua the address of the Scintilla window currently in use. --- --- Despite the name `SCI_SETDOCPOINTER`, it has no relationship to Scintilla --- documents. --- --- Use this call only if you are using the --- [`SCI_GETDIRECTFUNCTION()`](#SCI_GETDIRECTFUNCTION) Scintillua API call. It --- *must* be made *before* each call to the --- [`SCI_SETLEXERLANGUAGE()`](#SCI_SETLEXERLANGUAGE) Scintillua API call. --- @param sci The pointer returned by [`SCI_GETDIRECTPOINTER`][]. --- --- [`SCI_GETDIRECTPOINTER`]: http://scintilla.org/ScintillaDoc.html#SCI_GETDIRECTPOINTER --- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETDOCPOINTER, sci) --- @see SCI_GETDIRECTFUNCTION --- @see SCI_SETLEXERLANGUAGE --- @name SCI_SETDOCPOINTER -function SCI_PRIVATELEXERCALL(SCI_SETDOCPOINTER, sci) end - ---- --- Tells Scintillua to use `lua` as its Lua state instead of creating a separate --- state. --- --- `lua` must have already opened the "base", "string", "table", "package", and --- "lpeg" libraries. If `lua` is a Lua 5.1 state, it must have also opened the --- "io" library. --- --- Scintillua will create a single `lexer` global variable, as well as a number --- of other variables in the `LUA_REGISTRYINDEX` table with the "sci_" prefix. --- --- Instead of including the path to Scintillua's lexers in the `package.path` of --- the given Lua state, set the "lexer.lpeg.home" property appropriately --- instead. Scintillua uses that property to find and load lexers. --- @param lua (`lua_State *`) The Lua state to use. --- @usage lua = luaL_newstate() --- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_CHANGELEXERSTATE, lua) --- @name SCI_CHANGELEXERSTATE -function SCI_PRIVATELEXERCALL(SCI_CHANGELEXERSTATE, lua) end - ---- --- Sets the current Lua LPeg lexer to `languageName`. --- --- If you are having the Scintillua lexer set the Lua LPeg lexer styles --- automatically, make sure you call the --- [`SCI_SETDOCPOINTER()`](#SCI_SETDOCPOINTER) Scintillua API *first*. --- @param languageName (`const char*`) The name of the Lua LPeg lexer to use. --- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, SCI_SETLEXERLANGUAGE, "lua") --- @see SCI_SETDOCPOINTER --- @name SCI_SETLEXERLANGUAGE -function SCI_PRIVATELEXERCALL(SCI_SETLEXERLANGUAGE, languageName) end - ---- --- Returns the length of the string name of the current Lua LPeg lexer or stores --- the name into the given buffer. If the buffer is long enough, the name is --- terminated by a `0` character. --- --- For parent lexers with embedded children or child lexers embedded into --- parents, the name is in "lexer/current" format, where "lexer" is the actual --- lexer's name and "current" is the parent or child lexer at the current caret --- position. In order for this to work, you must have called --- [`SCI_GETDIRECTFUNCTION`](#SCI_GETDIRECTFUNCTION) and --- [`SCI_SETDOCPOINTER`](#SCI_SETDOCPOINTER). --- @param languageName (`char *`) If `0`, returns the length that should be --- allocated to store the string Lua LPeg lexer name. Otherwise fills the --- buffer with the name. --- @name SCI_GETLEXERLANGUAGE -function SCI_PRIVATELEXERCALL(SCI_GETLEXERLANGUAGE, languageName) end - ---- --- Depending on the sign of `styleNum`, returns the length of the associated --- string for the given style number or stores the string into the given buffer. --- If the buffer is long enough, the string is terminated by a `0` character. --- --- For negative `styleNum`, the associated string is a SciTE-formatted style --- definition. Otherwise, the associated string is the name of the token for the --- given style number. --- --- Please see the [SciTE documentation][] for the style definition format --- specified by `style.*.stylenumber`. You can parse these definitions to set --- Lua LPeg lexer styles manually if you chose not to have them set --- automatically using the [`SCI_GETDIRECTFUNCTION()`](#SCI_GETDIRECTFUNCTION) --- and [`SCI_SETDOCPOINTER()`](#SCI_SETDOCPOINTER) Scintillua API calls. --- --- [SciTE documentation]: http://scintilla.org/SciTEDoc.html --- @param styleNum (`int`) For the range `-STYLE_MAX <= styleNum < 0`, uses the --- Scintilla style number `-styleNum - 1` for returning SciTE-formatted style --- definitions. (Style `0` would be `-1`, style `1` would be `-2`, and so on.) --- For the range `0 <= styleNum < STYLE_MAX`, uses the normal Scintilla style --- number for returning token names. --- @param style (`char *`) If `0`, returns the length that should be allocated --- to store the associated string. Otherwise fills the buffer with the string. --- @usage style = SendScintilla(sci, SCI_GETSTYLEAT, pos) --- @usage SendScintilla(sci, SCI_PRIVATELEXERCALL, style, token) --- @usage // token now contains the name of the style at pos -function SCI_PRIVATELEXERCALL(styleNum, style) end diff --git a/src/editor/LexLPeg.cpp b/src/editor/LexLPeg.cpp index dde343f9..a5bfc331 100644 --- a/src/editor/LexLPeg.cpp +++ b/src/editor/LexLPeg.cpp @@ -137,10 +137,13 @@ class LexerLPeg : public ILexer { luaL_argcheck(L, !is_lexer || !newindex, 3, "read-only property"); if (is_lexer) { l_pushlexerp(L, llexer_property); - } else if (!newindex) + } else if (!newindex) { lua_pushstring(L, props->Get(luaL_checkstring(L, 2))); - else - props->Set(luaL_checkstring(L, 2), luaL_checkstring(L, 3)); + } else { + const char *key = luaL_checkstring(L, 2); + const char *val = luaL_checkstring(L, 3); + props->Set(key, val, strlen(key), strlen(val)); + } } else if (strcmp(key, "property_int") == 0) { luaL_argcheck(L, !newindex, 3, "read-only property"); if (is_lexer) { @@ -245,8 +248,11 @@ class LexerLPeg : public ILexer { while (lua_next(L, -2)) { if (lua_isstring(L, -2) && lua_isstring(L, -1)) { lua_pushstring(L, "style."), lua_pushvalue(L, -3), lua_concat(L, 2); - if (!*props.Get(lua_tostring(L, -1))) - props.Set(lua_tostring(L, -1), lua_tostring(L, -2)); + if (!*props.Get(lua_tostring(L, -1))) { + const char *key = lua_tostring(L, -1); + const char *val = lua_tostring(L, -2); + props.Set(key, val, strlen(key), strlen(val)); + } lua_pop(L, 1); // style name } lua_pop(L, 1); // value @@ -526,7 +532,8 @@ public: * @param val The string value. */ Sci_Position SCI_METHOD PropertySet(const char *key, const char *value) { - props.Set(key, *value ? value : " "); // ensure property is cleared + const char *val = *value ? value : " "; + props.Set(key, val, strlen(key), strlen(val)); // ensure property is cleared return -1; // no need to re-lex } diff --git a/src/editor/PlatQt.cpp b/src/editor/PlatQt.cpp index b741a725..10337559 100644 --- a/src/editor/PlatQt.cpp +++ b/src/editor/PlatQt.cpp @@ -19,9 +19,8 @@ #include #include #include -#include #include -#include +#include #include #include #include @@ -31,7 +30,7 @@ namespace Scintilla { #endif -Font::Font() : fid(nullptr) {} +Font::Font() noexcept : fid(nullptr) {} Font::~Font() { @@ -156,7 +155,7 @@ void SurfaceImpl::LineTo(int x_, int y_) void SurfaceImpl::Polygon( Point *pts, - int npts, + size_t npts, ColourDesired fore, ColourDesired back) { @@ -242,6 +241,30 @@ void SurfaceImpl::AlphaRectangle( painter->drawRoundedRect(rect, cornerSize, cornerSize); } +void SurfaceImpl::GradientRectangle( + PRectangle rc, + const std::vector &stops, + GradientOptions options) +{ + QLinearGradient gradient; + switch (options) { + case GradientOptions::leftToRight: + gradient = QLinearGradient(rc.left, rc.top, rc.right, rc.top); + break; + + case GradientOptions::topToBottom: + default: + gradient = QLinearGradient(rc.left, rc.top, rc.left, rc.bottom); + break; + } + + gradient.setSpread(QGradient::RepeatSpread); + for (const ColourStop &stop : stops) + gradient.setColorAt(stop.position, QColorFromCA(stop.colour)); + + GetPainter()->fillRect(QRectFFromPRect(rc), QBrush(gradient)); +} + void SurfaceImpl::DrawRGBAImage( PRectangle rc, int width, @@ -382,12 +405,6 @@ XYPOSITION SurfaceImpl::WidthText(Font &font, const char *s, int len) return metrics.width(QString::fromUtf8(s, len)); } -XYPOSITION SurfaceImpl::WidthChar(Font &font, char ch) -{ - QFontMetricsF metrics(*static_cast(font.GetID()), device); - return metrics.width(ch); -} - XYPOSITION SurfaceImpl::Ascent(Font &font) { QFontMetricsF metrics(*static_cast(font.GetID()), device); @@ -409,12 +426,6 @@ XYPOSITION SurfaceImpl::InternalLeading(Font &font) return 0; } -XYPOSITION SurfaceImpl::ExternalLeading(Font &font) -{ - QFontMetricsF metrics(*static_cast(font.GetID()), device); - return metrics.leading(); -} - XYPOSITION SurfaceImpl::Height(Font &font) { QFontMetricsF metrics(*static_cast(font.GetID()), device); @@ -474,12 +485,7 @@ void Window::Destroy() wid = 0; } -bool Window::HasFocus() -{ - return wid ? window(wid)->hasFocus() : false; -} - -PRectangle Window::GetPosition() +PRectangle Window::GetPosition() const { // Before any size allocated pretend its 1000 wide so not scrolled return wid ? PRectFromQRect(window(wid)->frameGeometry()) : PRectangle(0, 0, 1000, 1000); @@ -491,35 +497,37 @@ void Window::SetPosition(PRectangle rc) window(wid)->setGeometry(QRectFromPRect(rc)); } -void Window::SetPositionRelative(PRectangle rc, Window relativeTo) +void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) { - QPoint oPos = window(relativeTo.wid)->mapToGlobal(QPoint(0,0)); + QPoint oPos = window(relativeTo->wid)->mapToGlobal(QPoint(0,0)); int ox = oPos.x(); int oy = oPos.y(); ox += rc.left; oy += rc.top; - QDesktopWidget *desktop = QApplication::desktop(); - QRect rectDesk = desktop->availableGeometry(QPoint(ox, oy)); - /* do some corrections to fit into screen */ int sizex = rc.right - rc.left; int sizey = rc.bottom - rc.top; - int screenWidth = rectDesk.width(); - if (ox < rectDesk.x()) - ox = rectDesk.x(); - if (sizex > screenWidth) - ox = rectDesk.x(); /* the best we can do */ - else if (ox + sizex > rectDesk.right()) - ox = rectDesk.right() - sizex; - if (oy + sizey > rectDesk.bottom()) - oy = rectDesk.bottom() - sizey; + + if (QScreen *screen = QApplication::screenAt(QPoint(ox, oy))) { + QRect rectDesk = screen->availableGeometry(); + /* do some corrections to fit into screen */ + int screenWidth = rectDesk.width(); + if (ox < rectDesk.x()) + ox = rectDesk.x(); + if (sizex > screenWidth) + ox = rectDesk.x(); /* the best we can do */ + else if (ox + sizex > rectDesk.right()) + ox = rectDesk.right() - sizex; + if (oy + sizey > rectDesk.bottom()) + oy = rectDesk.bottom() - sizey; + } Q_ASSERT(wid); window(wid)->move(ox, oy); window(wid)->resize(sizex, sizey); } -PRectangle Window::GetClientPosition() +PRectangle Window::GetClientPosition() const { // The client position is the window position return GetPosition(); @@ -574,23 +582,20 @@ void Window::SetCursor(Cursor curs) } } -void Window::SetTitle(const char *s) -{ - if (wid) - window(wid)->setWindowTitle(s); -} - /* Returns rectangle of monitor pt is on, both rect and pt are in Window's window coordinates */ PRectangle Window::GetMonitorRect(Point pt) { QPoint originGlobal = window(wid)->mapToGlobal(QPoint(0, 0)); QPoint posGlobal = window(wid)->mapToGlobal(QPoint(pt.x, pt.y)); - QDesktopWidget *desktop = QApplication::desktop(); - QRect rectScreen = desktop->availableGeometry(posGlobal); - rectScreen.translate(-originGlobal.x(), -originGlobal.y()); - return PRectangle(rectScreen.left(), rectScreen.top(), - rectScreen.right(), rectScreen.bottom()); + if (QScreen *screen = QApplication::screenAt(posGlobal)) { + QRect rectScreen = screen->availableGeometry(); + rectScreen.translate(-originGlobal.x(), -originGlobal.y()); + return PRectangle(rectScreen.left(), rectScreen.top(), + rectScreen.right(), rectScreen.bottom()); + } + + return PRectangle(); } @@ -598,307 +603,28 @@ PRectangle Window::GetMonitorRect(Point pt) class ListBoxImpl : public ListBox { public: - ListBoxImpl(); - ~ListBoxImpl(); - - virtual void SetFont(Font &font); - virtual void Create(Window &parent, int ctrlID, Point location, - int lineHeight, bool unicodeMode, int technology); - virtual void SetAverageCharWidth(int width); - virtual void SetVisibleRows(int rows); - virtual int GetVisibleRows() const; - virtual PRectangle GetDesiredRect(); - virtual int CaretFromEdge(); - virtual void Clear(); - virtual void Append(char *s, int type = -1); - virtual int Length(); - virtual void Select(int n); - virtual int GetSelection(); - virtual int Find(const char *prefix); - virtual void GetValue(int n, char *value, int len); - virtual void RegisterImage(int type, const char *xpmData); - virtual void RegisterRGBAImage(int type, int width, int height, - const unsigned char *pixels); - virtual void RegisterQPixmapImage(int type, const QPixmap& pm); - virtual void ClearRegisteredImages(); - virtual void SetDoubleClickAction(CallBackAction action, void *data); - virtual void SetList(const char *list, char separator, char typesep); -private: - bool unicodeMode; - int visibleRows; - QMap images; + void SetFont(Font &) override {} + void Create(Window &, int, Point, int, bool, int) override {} + void SetAverageCharWidth(int) override {} + void SetVisibleRows(int) override {} + int GetVisibleRows() const override { return 0; } + PRectangle GetDesiredRect() override { return PRectangle(); } + int CaretFromEdge() override { return 0; } + void Clear() override {} + void Append(char *, int = -1) override {} + int Length() override { return 0; } + void Select(int) override {} + int GetSelection() override { return 0; } + int Find(const char *) override { return 0; } + void GetValue(int, char *, int) override {} + void RegisterImage(int, const char *) override {} + void RegisterRGBAImage(int, int, int, const unsigned char *) override {} + void ClearRegisteredImages() override {} + void SetDelegate(IListBoxDelegate *) override {} + void SetList(const char *, char, char) override {} }; -class ListWidget : public QListWidget { -public: - explicit ListWidget(QWidget *parent); - virtual ~ListWidget(); - - void setDoubleClickAction(CallBackAction action, void *data); - -protected: - virtual void mouseDoubleClickEvent(QMouseEvent *event); - virtual QStyleOptionViewItem viewOptions() const; - -private: - CallBackAction doubleClickAction; - void *doubleClickActionData; -}; - - -ListBoxImpl::ListBoxImpl() -: unicodeMode(false), visibleRows(5) -{} - -ListBoxImpl::~ListBoxImpl() {} - -void ListBoxImpl::Create( - Window &parent, - int /*ctrlID*/, - Point location, - int /*lineHeight*/, - bool unicodeMode_, - int) -{ - unicodeMode = unicodeMode_; - - QWidget *qparent = static_cast(parent.GetID()); - ListWidget *list = new ListWidget(qparent); - -#if defined(Q_OS_WIN) - // On Windows, Qt::ToolTip causes a crash when the list is clicked on - // so Qt::Tool is used. - list->setParent(0, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); -#else - // On OS X, Qt::Tool takes focus so main window loses focus so - // keyboard stops working. Qt::ToolTip works but its only really - // documented for tooltips. - // On Linux / X this setting allows clicking on list items. - list->setParent(0, Qt::ToolTip | Qt::FramelessWindowHint); -#endif - list->setAttribute(Qt::WA_ShowWithoutActivating); - list->setFocusPolicy(Qt::NoFocus); - list->setUniformItemSizes(true); - list->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - list->move(location.x, location.y); - - int maxIconWidth = 0; - int maxIconHeight = 0; - foreach (QPixmap im, images) { - if (maxIconWidth < im.width()) - maxIconWidth = im.width(); - if (maxIconHeight < im.height()) - maxIconHeight = im.height(); - } - list->setIconSize(QSize(maxIconWidth, maxIconHeight)); - - wid = list; -} - -void ListBoxImpl::SetFont(Font &font) -{ - ListWidget *list = static_cast(wid); - list->setFont(*static_cast(font.GetID())); -} - -void ListBoxImpl::SetAverageCharWidth(int /*width*/) {} - -void ListBoxImpl::SetVisibleRows(int rows) -{ - visibleRows = rows; -} - -int ListBoxImpl::GetVisibleRows() const -{ - return visibleRows; -} - -PRectangle ListBoxImpl::GetDesiredRect() -{ - ListWidget *list = static_cast(wid); - - int rows = Length(); - if (rows == 0 || rows > visibleRows) { - rows = visibleRows; - } - int rowHeight = list->sizeHintForRow(0); - int height = (rows * rowHeight) + (2 * list->frameWidth()); - - QStyle *style = QApplication::style(); - int width = list->sizeHintForColumn(0) + (2 * list->frameWidth()); - if (Length() > rows) { - width += style->pixelMetric(QStyle::PM_ScrollBarExtent); - } - - return PRectangle(0, 0, width, height); -} - -int ListBoxImpl::CaretFromEdge() -{ - ListWidget *list = static_cast(wid); - - int maxIconWidth = 0; - foreach (QPixmap im, images) { - if (maxIconWidth < im.width()) - maxIconWidth = im.width(); - } - - int extra; - // The 12 is from trial and error on OS X and the 7 - // is from trial and error on Windows - there may be - // a better programmatic way to find any padding factors. -#ifdef Q_OS_DARWIN - extra = 12; -#else - extra = 7; -#endif - return maxIconWidth + (2 * list->frameWidth()) + extra; -} - -void ListBoxImpl::Clear() -{ - ListWidget *list = static_cast(wid); - list->clear(); -} - -void ListBoxImpl::Append(char *s, int type) -{ - ListWidget *list = static_cast(wid); - - QString str = unicodeMode ? QString::fromUtf8(s) : QString::fromLocal8Bit(s); - QIcon icon; - if (type >= 0) { - Q_ASSERT(images.contains(type)); - icon = images.value(type); - } - new QListWidgetItem(icon, str, list); -} - -int ListBoxImpl::Length() -{ - ListWidget *list = static_cast(wid); - return list->count(); -} - -void ListBoxImpl::Select(int n) -{ - ListWidget *list = static_cast(wid); - QModelIndex index = list->model()->index(n, 0); - if (index.isValid()) { - QRect row_rect = list->visualRect(index); - if (!list->viewport()->rect().contains(row_rect)) { - list->scrollTo(index, QAbstractItemView::PositionAtTop); - } - } - list->setCurrentRow(n); -} - -int ListBoxImpl::GetSelection() -{ - ListWidget *list = static_cast(wid); - return list->currentRow(); -} - -int ListBoxImpl::Find(const char *prefix) -{ - ListWidget *list = static_cast(wid); - QString sPrefix = unicodeMode ? QString::fromUtf8(prefix) : QString::fromLocal8Bit(prefix); - QList ms = list->findItems(sPrefix, Qt::MatchStartsWith); - - int result = -1; - if (!ms.isEmpty()) { - result = list->row(ms.first()); - } - - return result; -} - -void ListBoxImpl::GetValue(int n, char *value, int len) -{ - ListWidget *list = static_cast(wid); - QListWidgetItem *item = list->item(n); - QString str = item->data(Qt::DisplayRole).toString(); - QByteArray bytes = unicodeMode ? str.toUtf8() : str.toLocal8Bit(); - - strncpy(value, bytes.constData(), len); - value[len-1] = '\0'; -} - -void ListBoxImpl::RegisterQPixmapImage(int type, const QPixmap& pm) -{ - images[type] = pm; - - ListWidget *list = static_cast(wid); - if (list != NULL) { - QSize iconSize = list->iconSize(); - if (pm.width() > iconSize.width() || pm.height() > iconSize.height()) - list->setIconSize(QSize(qMax(pm.width(), iconSize.width()), - qMax(pm.height(), iconSize.height()))); - } - -} - -void ListBoxImpl::RegisterImage(int type, const char *xpmData) -{ - RegisterQPixmapImage(type, QPixmap(reinterpret_cast(xpmData))); -} - -void ListBoxImpl::RegisterRGBAImage( - int type, - int width, - int height, - const unsigned char *pixels) -{ - QImage image(pixels, width, height, QImage::Format_ARGB32_Premultiplied); - RegisterQPixmapImage(type, QPixmap::fromImage(image)); -} - -void ListBoxImpl::ClearRegisteredImages() -{ - images.clear(); - - ListWidget *list = static_cast(wid); - if (list != NULL) - list->setIconSize(QSize(0, 0)); -} - -void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data) -{ - ListWidget *list = static_cast(wid); - list->setDoubleClickAction(action, data); -} - -void ListBoxImpl::SetList(const char *list, char separator, char typesep) -{ - // This method is *not* platform dependent. - // It is borrowed from the GTK implementation. - Clear(); - size_t count = strlen(list) + 1; - std::vector words(list, list+count); - char *startword = &words[0]; - char *numword = NULL; - int i = 0; - for (; words[i]; i++) { - if (words[i] == separator) { - words[i] = '\0'; - if (numword) - *numword = '\0'; - Append(startword, numword?atoi(numword + 1):-1); - startword = &words[0] + i + 1; - numword = NULL; - } else if (words[i] == typesep) { - numword = &words[0] + i; - } - } - if (startword) { - if (numword) - *numword = '\0'; - Append(startword, numword?atoi(numword + 1):-1); - } -} - -ListBox::ListBox() {} +ListBox::ListBox() noexcept {} ListBox::~ListBox() {} @@ -907,35 +633,9 @@ ListBox *ListBox::Allocate() return new ListBoxImpl; } -ListWidget::ListWidget(QWidget *parent) -: QListWidget(parent), doubleClickAction(0), doubleClickActionData(0) -{} - -ListWidget::~ListWidget() {} - -void ListWidget::setDoubleClickAction(CallBackAction action, void *data) -{ - doubleClickAction = action; - doubleClickActionData = data; -} - -void ListWidget::mouseDoubleClickEvent(QMouseEvent * /* event */) -{ - if (doubleClickAction != 0) { - doubleClickAction(doubleClickActionData); - } -} - -QStyleOptionViewItem ListWidget::viewOptions() const -{ - QStyleOptionViewItem result = QListWidget::viewOptions(); - result.state |= QStyle::State_Active; - return result; -} - //---------------------------------------------------------------------- -Menu::Menu() : mid(0) {} +Menu::Menu() noexcept : mid(0) {} void Menu::CreatePopUp() { @@ -976,11 +676,11 @@ public: lib = 0; } - virtual Function FindFunction(const char *name) { + Function FindFunction(const char *name) override { return lib ? reinterpret_cast(lib->resolve(name)) : NULL; } - virtual bool IsValid() { + bool IsValid() override { return lib != NULL; } }; @@ -1023,26 +723,6 @@ unsigned int Platform::DoubleClickTime() return QApplication::doubleClickInterval(); } -bool Platform::MouseButtonBounce() -{ - return false; -} - -int Platform::Minimum(int a, int b) -{ - return qMin(a, b); -} - -int Platform::Maximum(int a, int b) -{ - return qMax(a, b); -} - -int Platform::Clamp(int val, int minVal, int maxVal) -{ - return qBound(minVal, val, maxVal); -} - void Platform::DebugDisplay(const char *s) { qWarning("Scintilla: %s", s); diff --git a/src/editor/PlatQt.h b/src/editor/PlatQt.h index 7d882daf..04ea2af1 100644 --- a/src/editor/PlatQt.h +++ b/src/editor/PlatQt.h @@ -10,6 +10,7 @@ #ifndef PLATQT_H #define PLATQT_H +#include #include "Platform.h" #include #include @@ -23,10 +24,15 @@ namespace Scintilla { inline QColor QColorFromCA(ColourDesired ca) { - long c = ca.AsLong(); + int c = ca.AsInteger(); return QColor(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); } +inline QColor QColorFromCA(ColourAlpha ca) +{ + return QColor(ca.GetRed(), ca.GetGreen(), ca.GetBlue(), ca.GetAlpha()); +} + inline QRect QRectFromPRect(PRectangle pr) { return QRect(pr.left, pr.top, pr.Width(), pr.Height()); @@ -58,56 +64,55 @@ public: SurfaceImpl(); virtual ~SurfaceImpl(); - virtual void Init(WindowID wid); - virtual void Init(SurfaceID sid, WindowID wid); - virtual void InitPixMap(int width, int height, - Surface *surface, WindowID wid); + void Init(WindowID wid) override; + void Init(SurfaceID sid, WindowID wid) override; + void InitPixMap(int width, int height, + Surface *surface, WindowID wid) override; - virtual void Release(); - virtual bool Initialised(); - virtual void PenColour(ColourDesired fore); - virtual int LogPixelsY(); - virtual int DeviceHeightFont(int points); - virtual void MoveTo(int x, int y); - virtual void LineTo(int x, int y); - virtual void Polygon(Point *pts, int npts, ColourDesired fore, - ColourDesired back); - virtual void RectangleDraw(PRectangle rc, ColourDesired fore, - ColourDesired back); - virtual void FillRectangle(PRectangle rc, ColourDesired back); - virtual void FillRectangle(PRectangle rc, Surface &surfacePattern); - virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, - ColourDesired back); - virtual void AlphaRectangle(PRectangle rc, int corner, ColourDesired fill, - int alphaFill, ColourDesired outline, int alphaOutline, int flags); - virtual void DrawRGBAImage(PRectangle rc, int width, int height, - const unsigned char *pixelsImage); - virtual void Ellipse(PRectangle rc, ColourDesired fore, - ColourDesired back); - virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource); + void Release() override; + bool Initialised() override; + void PenColour(ColourDesired fore) override; + int LogPixelsY() override; + int DeviceHeightFont(int points) override; + void MoveTo(int x, int y) override; + void LineTo(int x, int y) override; + void Polygon(Point *pts, size_t npts, ColourDesired fore, + ColourDesired back) override; + void RectangleDraw(PRectangle rc, ColourDesired fore, + ColourDesired back) override; + void FillRectangle(PRectangle rc, ColourDesired back) override; + void FillRectangle(PRectangle rc, Surface &surfacePattern) override; + void RoundedRectangle(PRectangle rc, ColourDesired fore, + ColourDesired back) override; + void AlphaRectangle(PRectangle rc, int corner, ColourDesired fill, + int alphaFill, ColourDesired outline, int alphaOutline, int flags) override; + void GradientRectangle(PRectangle rc, + const std::vector &stops, GradientOptions options) override; + void DrawRGBAImage(PRectangle rc, int width, int height, + const unsigned char *pixelsImage) override; + void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; - virtual void DrawTextNoClip(PRectangle rc, Font &font, XYPOSITION ybase, - const char *s, int len, ColourDesired fore, ColourDesired back); - virtual void DrawTextClipped(PRectangle rc, Font &font, XYPOSITION ybase, - const char *s, int len, ColourDesired fore, ColourDesired back); - virtual void DrawTextTransparent(PRectangle rc, Font &font, XYPOSITION ybase, - const char *s, int len, ColourDesired fore); - virtual void MeasureWidths(Font &font, const char *s, int len, - XYPOSITION *positions); - virtual XYPOSITION WidthText(Font &font, const char *s, int len); - virtual XYPOSITION WidthChar(Font &font, char ch); - virtual XYPOSITION Ascent(Font &font); - virtual XYPOSITION Descent(Font &font); - virtual XYPOSITION InternalLeading(Font &font); - virtual XYPOSITION ExternalLeading(Font &font); - virtual XYPOSITION Height(Font &font); - virtual XYPOSITION AverageCharWidth(Font &font); + void DrawTextNoClip(PRectangle rc, Font &font, XYPOSITION ybase, + const char *s, int len, ColourDesired fore, ColourDesired back) override; + void DrawTextClipped(PRectangle rc, Font &font, XYPOSITION ybase, + const char *s, int len, ColourDesired fore, ColourDesired back) override; + void DrawTextTransparent(PRectangle rc, Font &font, XYPOSITION ybase, + const char *s, int len, ColourDesired fore) override; + void MeasureWidths(Font &font, const char *s, int len, + XYPOSITION *positions) override; + XYPOSITION WidthText(Font &font, const char *s, int len) override; + XYPOSITION Ascent(Font &font) override; + XYPOSITION Descent(Font &font) override; + XYPOSITION InternalLeading(Font &font) override; + XYPOSITION Height(Font &font) override; + XYPOSITION AverageCharWidth(Font &font) override; - virtual void SetClip(PRectangle rc); - virtual void FlushCachedState(); + void SetClip(PRectangle rc) override; + void FlushCachedState() override; - virtual void SetUnicodeMode(bool unicodeMode) {} - virtual void SetDBCSMode(int codePage) {} + void SetUnicodeMode(bool unicodeMode) override {} + void SetDBCSMode(int codePage) override {} QPainter *GetPainter(); }; diff --git a/src/editor/ScintillaIFace.cpp b/src/editor/ScintillaIFace.cpp index 5e4bfa4a..f4fc4907 100644 --- a/src/editor/ScintillaIFace.cpp +++ b/src/editor/ScintillaIFace.cpp @@ -695,16 +695,6 @@ int ScintillaIFace::whitespaceSize() const return (int)send(SCI_GETWHITESPACESIZE, 0, 0); } -void ScintillaIFace::setStyleBits(int bits) -{ - send(SCI_SETSTYLEBITS, (uptr_t)bits, 0); -} - -int ScintillaIFace::styleBits() const -{ - return (int)send(SCI_GETSTYLEBITS, 0, 0); -} - void ScintillaIFace::setLineState(int line, int state) { send(SCI_SETLINESTATE, (uptr_t)line, (sptr_t)state); @@ -3370,11 +3360,6 @@ int ScintillaIFace::propertyInt(const QString & key) const return (int)send(SCI_GETPROPERTYINT, (uptr_t)keyUtf8.constData(), 0); } -int ScintillaIFace::styleBitsNeeded() const -{ - return (int)send(SCI_GETSTYLEBITSNEEDED, 0, 0); -} - int ScintillaIFace::lexerLanguage(char * text) const { return (int)send(SCI_GETLEXERLANGUAGE, 0, (sptr_t)text); diff --git a/src/editor/ScintillaIFace.h b/src/editor/ScintillaIFace.h index 75ac28bb..b8636378 100644 --- a/src/editor/ScintillaIFace.h +++ b/src/editor/ScintillaIFace.h @@ -548,16 +548,6 @@ public: * Get the size of the dots used to mark space characters. */ int whitespaceSize() const; - /** - * Divide each styling byte into lexical class bits (default: 5) and indicator - * bits (default: 3). If a lexer requires more than 32 lexical states, then this - * is used to expand the possible states. - */ - void setStyleBits(int bits); - /** - * Retrieve number of bits in style bytes used to hold the lexical state. - */ - int styleBits() const; /** * Used to hold extra styling information for each line. */ @@ -2762,10 +2752,6 @@ public: * interpreted as an int AFTER any "$()" variable replacement. */ int propertyInt(const QString & key) const; - /** - * Retrieve the number of bits the current lexer needs for styling. - */ - int styleBitsNeeded() const; /** * Retrieve the name of the lexer. * Return the length of the text. diff --git a/src/editor/ScintillaQt.cpp b/src/editor/ScintillaQt.cpp index b56ed031..bd24cbe5 100644 --- a/src/editor/ScintillaQt.cpp +++ b/src/editor/ScintillaQt.cpp @@ -291,7 +291,8 @@ void ScintillaQt::keyPressEvent(QKeyEvent *event) bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; bool consumed = false; - bool added = KeyDown(key, shift, ctrl, alt, &consumed) != 0; + bool added = KeyDownWithModifiers( + key, ModifierFlags(shift, ctrl, alt), &consumed); if (!consumed) consumed = added; @@ -361,7 +362,8 @@ void ScintillaQt::mousePressEvent(QMouseEvent *event) bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; #endif - ButtonDown(pos, time.elapsed(), shift, ctrl, alt); + ButtonDownWithModifiers( + pos, time.elapsed(), ModifierFlags(shift, ctrl, alt)); } } @@ -370,7 +372,8 @@ void ScintillaQt::mouseReleaseEvent(QMouseEvent *event) Point point = PointFromQPoint(event->pos()); bool ctrl = QApplication::keyboardModifiers() & Qt::ControlModifier; if (event->button() == Qt::LeftButton) - ButtonUp(point, time.elapsed(), ctrl); + ButtonUpWithModifiers( + point, time.elapsed(), ModifierFlags(false, ctrl, false)); int pos = send(SCI_POSITIONFROMPOINT, point.x, point.y); int line = send(SCI_LINEFROMPOSITION, pos); @@ -400,9 +403,7 @@ void ScintillaQt::mouseMoveEvent(QMouseEvent *event) bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; #endif - int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); - - ButtonMoveWithModifiers(pos, modifiers); + ButtonMoveWithModifiers(pos, time.elapsed(), ModifierFlags(shift, ctrl, alt)); } void ScintillaQt::contextMenuEvent(QContextMenuEvent *event) @@ -428,7 +429,7 @@ void ScintillaQt::dragEnterEvent(QDragEnterEvent *event) void ScintillaQt::dragLeaveEvent(QDragLeaveEvent *event) { - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); } void ScintillaQt::dragMoveEvent(QDragMoveEvent *event) @@ -481,7 +482,7 @@ void ScintillaQt::DrawImeIndicator(int indicator, int len) if (indicator < 8 || indicator > INDIC_MAX) { return; } - pdoc->decorations.SetCurrentIndicator(indicator); + pdoc->decorations->SetCurrentIndicator(indicator); for (size_t r = 0; r < sel.Count(); ++r) { int positionInsert = sel.Range(r).Start().Position(); pdoc->DecorationFillRange(positionInsert - len, 1, len); @@ -493,12 +494,13 @@ void ScintillaQt::inputMethodEvent(QInputMethodEvent *event) // Copy & paste by johnsonj with a lot of helps of Neil // Great thanks for my forerunners, jiniya and BLUEnLIVE + bool initialCompose = false; if (pdoc->TentativeActive()) { pdoc->TentativeUndo(); } else { // No tentative undo means start of this composition so // Fill in any virtual spaces. - FillVirtualSpace(); + initialCompose = true; } view.imeCaretBlockOverride = false; @@ -525,6 +527,8 @@ void ScintillaQt::inputMethodEvent(QInputMethodEvent *event) return; } + if (initialCompose) + ClearBeforeTentativeStart(); pdoc->TentativeStart(); // TentativeActive() from now on. // Mark segments and get ime caret position. @@ -775,7 +779,7 @@ bool ScintillaQt::ValidCodePage(int codePage) const return (codePage == SC_CP_UTF8); } -void ScintillaQt::ScrollText(int linesToMove) +void ScintillaQt::ScrollText(Sci::Line linesToMove) { viewport()->scroll(0, vs.lineHeight * linesToMove); } @@ -790,7 +794,7 @@ void ScintillaQt::SetHorizontalScrollPos() horizontalScrollBar()->setValue(xOffset); } -bool ScintillaQt::ModifyScrollBars(int nMax, int nPage) +bool ScintillaQt::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) { bool modified = false; @@ -990,11 +994,6 @@ void ScintillaQt::NotifyParent(SCNotification scn) } } -bool ScintillaQt::FineTickerAvailable() -{ - return true; -} - bool ScintillaQt::FineTickerRunning(TickReason reason) { return timers[reason] != 0; @@ -1094,7 +1093,7 @@ void ScintillaQt::StartDrag() } inDragDrop = ddNone; - SetDragPosition(SelectionPosition(invalidPosition)); + SetDragPosition(SelectionPosition(Sci::invalidPosition)); } void ScintillaQt::CreateCallTipWindow(PRectangle rc) diff --git a/src/editor/ScintillaQt.h b/src/editor/ScintillaQt.h index e432bc29..f96d7f9d 100644 --- a/src/editor/ScintillaQt.h +++ b/src/editor/ScintillaQt.h @@ -39,10 +39,13 @@ #include "LineMarker.h" #include "Style.h" #include "AutoComplete.h" +#include "UniqueString.h" #include "ViewStyle.h" #include "CharClassify.h" #include "Decoration.h" #include "CaseFolder.h" +#include "ILoader.h" +#include "CharacterCategory.h" #include "Document.h" #include "Selection.h" #include "PositionCache.h" @@ -147,10 +150,10 @@ private: void Finalise() override; bool DragThreshold(Point ptStart, Point ptNow) override; bool ValidCodePage(int codePage) const override; - void ScrollText(int linesToMove) override; + void ScrollText(Sci::Line linesToMove) override; void SetVerticalScrollPos() override; void SetHorizontalScrollPos() override; - bool ModifyScrollBars(int nMax, int nPage) override; + bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) override; void ReconfigureScrollBars() override; void Copy() override; void CopyToClipboard(const SelectionText &selectedText) override; @@ -158,7 +161,6 @@ private: void ClaimSelection() override; void NotifyChange() override; void NotifyParent(SCNotification scn) override; - bool FineTickerAvailable() override; bool FineTickerRunning(TickReason reason) override; void FineTickerStart(TickReason reason, int millis, int tolerance) override; void FineTickerCancel(TickReason reason) override;