From b922bf5bab4d098000e4a604ac46a60ae685b3f4 Mon Sep 17 00:00:00 2001 From: Thomas Geppert Date: Fri, 18 Oct 2024 14:52:55 +0200 Subject: [PATCH 01/16] Implement the creation of SAFEARRAY(VT_RECORD) from a sequence of COM Records (#2317) * Implemented the creation of SAFEARRAY(VT_RECORD) from a sequence of COM Records and the possibility to use instances of this type as COM Record fields. * Added a untitest for COM Records with SAFEARRAY(VT_RECORD) fields. * Added CHANGELOG entry. --- CHANGES.txt | 3 ++- com/TestSources/PyCOMTest/PyCOMImpl.cpp | 21 ++++++++++++++++ com/TestSources/PyCOMTest/PyCOMImpl.h | 1 + com/TestSources/PyCOMTest/PyCOMTest.idl | 6 +++++ com/win32com/src/PyRecord.cpp | 11 ++++++--- com/win32com/src/oleargs.cpp | 33 ++++++++++++++++++++++--- com/win32com/test/testPyComTest.py | 14 +++++++++++ 7 files changed, 80 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d8978afd5..82cf59213 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -15,7 +15,8 @@ Coming in build 309, as yet unreleased -------------------------------------- * Dropped support for Python 3.7 (#2207, @Avasam) -* Implement record pointers as [in, out] method parameters of a Dispatch Interface (#2310) +* Implement the creation of SAFEARRAY(VT_RECORD) from a sequence of COM Records (#2317, @geppi) +* Implement record pointers as [in, out] method parameters of a Dispatch Interface (#2304, #2310, @geppi) * Fix memory leak converting to PyObject from some SAFEARRAY elements (#2316) * Fix bug where makepy support was unnecessarily generated (#2354, #2353, @geppi) * Fail sooner on invalid `win32timezone.TimeZoneInfo` creation (#2338, @Avasam) diff --git a/com/TestSources/PyCOMTest/PyCOMImpl.cpp b/com/TestSources/PyCOMTest/PyCOMImpl.cpp index d58c00f99..6ba0af0c4 100644 --- a/com/TestSources/PyCOMTest/PyCOMImpl.cpp +++ b/com/TestSources/PyCOMTest/PyCOMImpl.cpp @@ -626,6 +626,27 @@ HRESULT CPyCOMTest::ModifyStruct(TestStruct1 *prec) return S_OK; } +HRESULT CPyCOMTest::VerifyArrayOfStructs(TestStruct2 *prec, VARIANT_BOOL *is_ok) +{ + long i; + TestStruct1 *pdata = NULL; + HRESULT hr; + + hr = SafeArrayAccessData(prec->array_of_records, reinterpret_cast(&pdata)); + if (FAILED(hr)) { + return E_FAIL; + } + *is_ok = VARIANT_TRUE; + for (i = 0; i < prec->rec_count; i++) + { + if (_wcsicmp(pdata[i].str_value, L"This is record number") != 0 || pdata[i].int_value != i + 1) { + *is_ok = VARIANT_FALSE; + break; + } + } + return S_OK; +} + HRESULT CPyCOMTest::DoubleString(BSTR in, BSTR *out) { *out = SysAllocStringLen(NULL, SysStringLen(in) * 2); diff --git a/com/TestSources/PyCOMTest/PyCOMImpl.h b/com/TestSources/PyCOMTest/PyCOMImpl.h index 50eb8dd0d..7b1f83c2b 100644 --- a/com/TestSources/PyCOMTest/PyCOMImpl.h +++ b/com/TestSources/PyCOMTest/PyCOMImpl.h @@ -120,6 +120,7 @@ class CPyCOMTest : public IDispatchImplowner); else if (V_VT(&vret) == (VT_BYREF | VT_ARRAY | VT_RECORD)) { SAFEARRAY *psa = *V_ARRAYREF(&vret); - int d = SafeArrayGetDim(psa); - if (sub_data == NULL) - return PyErr_Format(PyExc_RuntimeError, "Did not get a buffer for the array!"); if (SafeArrayGetDim(psa) != 1) return PyErr_Format(PyExc_TypeError, "Only support single dimensional arrays of records"); IRecordInfo *sub = NULL; @@ -526,7 +523,13 @@ PyObject *PyRecord::getattro(PyObject *self, PyObject *obname) ret_tuple = PyTuple_New(nelems); if (ret_tuple == NULL) goto array_end; - this_data = (BYTE *)sub_data; + // We're dealing here with a Record field that is a SAFEARRAY of Records. + // Therefore the VARIANT that was returned by the call to 'pyrec->pri->GetFieldNoCopy' + // does contain a reference to the SAFEARRAY of Records, i.e. the actual data of the + // Record elements of this SAFEARRAY is referenced by the 'pvData' field of the SAFEARRAY. + // In this particular case the implementation of 'GetFieldNoCopy' returns a NULL pointer + // in the last parameter, i.e. 'sub_data == NULL'. + this_data = (BYTE *)psa->pvData; for (i = 0; i < nelems; i++) { PyTuple_SET_ITEM(ret_tuple, i, new PyRecord(sub, this_data, pyrec->owner)); this_data += element_size; diff --git a/com/win32com/src/oleargs.cpp b/com/win32com/src/oleargs.cpp index a1338bab5..91fded5b1 100644 --- a/com/win32com/src/oleargs.cpp +++ b/com/win32com/src/oleargs.cpp @@ -4,6 +4,7 @@ #include "stdafx.h" #include "PythonCOM.h" +#include "PyRecord.h" extern PyObject *PyObject_FromRecordInfo(IRecordInfo *, void *, ULONG); extern PyObject *PyObject_FromSAFEARRAYRecordInfo(SAFEARRAY *psa); @@ -278,9 +279,23 @@ BOOL PyCom_VariantFromPyObject(PyObject *obj, VARIANT *var) // So make sure this check is after anything else which qualifies. else if (PySequence_Check(obj)) { V_ARRAY(var) = NULL; // not a valid, existing array. - if (!PyCom_SAFEARRAYFromPyObject(obj, &V_ARRAY(var))) - return FALSE; - V_VT(var) = VT_ARRAY | VT_VARIANT; + BOOL is_record_item = false; + if (PyObject_Length(obj) > 0) { + PyObject *obItemCheck = PySequence_GetItem(obj, 0); + is_record_item = PyRecord_Check(obItemCheck); + } + // If the sequence elements are PyRecord objects we do NOT package + // them as VARIANT elements but put them directly into the SAFEARRAY. + if (is_record_item) { + if (!PyCom_SAFEARRAYFromPyObject(obj, &V_ARRAY(var), VT_RECORD)) + return FALSE; + V_VT(var) = VT_ARRAY | VT_RECORD; + } + else { + if (!PyCom_SAFEARRAYFromPyObject(obj, &V_ARRAY(var))) + return FALSE; + V_VT(var) = VT_ARRAY | VT_VARIANT; + } } else if (PyRecord_Check(obj)) { if (!PyObject_AsVARIANTRecordInfo(obj, var)) @@ -554,6 +569,9 @@ static BOOL PyCom_SAFEARRAYFromPyObjectBuildDimension(PyObject *obj, SAFEARRAY * helper.m_reqdType = vt; ok = helper.MakeObjToVariant(item, &element); switch (vt) { + case VT_RECORD: + pvData = V_RECORD(&element); + break; case VT_DISPATCH: pvData = V_DISPATCH(&element); break; @@ -759,7 +777,14 @@ static BOOL PyCom_SAFEARRAYFromPyObjectEx(PyObject *obj, SAFEARRAY **ppSA, bool if (bAllocNewArray) { // OK - Finally can create the array... - *ppSA = SafeArrayCreate(vt, cDims, pBounds); + if (vt == VT_RECORD) { + // SAFEARRAYS of UDTs need a special treatment. + obItemCheck = PySequence_GetItem(obj, 0); + PyRecord *pyrec = (PyRecord *)obItemCheck; + *ppSA = SafeArrayCreateEx(vt, cDims, pBounds, pyrec->pri); + } + else + *ppSA = SafeArrayCreate(vt, cDims, pBounds); if (*ppSA == NULL) { delete[] pBounds; PyErr_SetString(PyExc_MemoryError, "CreatingSafeArray"); diff --git a/com/win32com/test/testPyComTest.py b/com/win32com/test/testPyComTest.py index dbe933669..50330e356 100644 --- a/com/win32com/test/testPyComTest.py +++ b/com/win32com/test/testPyComTest.py @@ -411,6 +411,7 @@ def TestDynamic(): def TestGenerated(): # Create an instance of the server. + from win32com.client import Record from win32com.client.gencache import EnsureDispatch o = EnsureDispatch("PyCOMTest.PyCOMTest") @@ -433,6 +434,19 @@ def TestGenerated(): coclass = GetClass("{B88DD310-BAE8-11D0-AE86-76F2C1000000}")() TestCounter(coclass, True) + # Test records with SAFEARRAY(VT_RECORD) fields. + progress("Testing records with SAFEARRAY(VT_RECORD) fields.") + l = [] + for i in range(3): + rec = Record("TestStruct1", o) + rec.str_value = "This is record number" + rec.int_value = i + 1 + l.append(rec) + test_rec = Record("TestStruct2", o) + test_rec.array_of_records = l + test_rec.rec_count = i + 1 + assert o.VerifyArrayOfStructs(test_rec) + # XXX - this is failing in dynamic tests, but should work fine. i1, i2 = o.GetMultipleInterfaces() # Yay - is now an instance returned! From b9256ff26bb64a85a11defe9c817bdde08ab0560 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 10 Oct 2024 21:17:21 -0400 Subject: [PATCH 02/16] Update configs to use Ruff format instead of Black --- .editorconfig | 2 +- .github/workflows/main.yml | 13 +- .pre-commit-config.yaml | 6 +- adodbapi/adodbapi.py | 19 +- adodbapi/process_connect_string.py | 272 ++++++++++++++--------------- com/win32comext/adsi/demos/scp.py | 2 +- ruff.toml | 3 +- win32/Lib/win32gui_struct.py | 6 +- win32/Lib/win32pdhquery.py | 5 +- win32/test/test_win32file.py | 11 +- 10 files changed, 167 insertions(+), 172 deletions(-) diff --git a/.editorconfig b/.editorconfig index 51baf1204..6874683d6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,7 +9,7 @@ indent_size = 4 max_line_length = 120 # Same as .clang-format [*.py] -max_line_length = 88 # Same as Black +max_line_length = 88 # Same as Ruff's default [*.md] trim_trailing_whitespace = false diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2af0d70a0..db40b4254 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -110,23 +110,22 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - # This job only needs to target the oldest version supported by our checkers - # (black>=24.10.0 supports Python >=3.9) - python-version: "3.9" + # This job only needs to target the oldest supported version + python-version: "3.8" cache: pip cache-dependency-path: .github/workflows/main.yml - run: pip install clang-format pycln - run: pycln . --config=pycln.toml --check - uses: astral-sh/ruff-action@v1 with: - version: "0.4.5" - - uses: psf/black@stable + version: "0.4.9" + - uses: astral-sh/ruff-action@v1 with: - options: "--fast --check --diff --verbose" + version: "0.4.9" + args: "format --check" - run: | # Too many files to fit in a single command, also exclude vendored Scintilla and MAPIStubLibrary clang-format --Werror --dry-run $(git ls-files '*.cpp') clang-format --Werror --dry-run $(git ls-files '*.h' ':!:Pythonwin/Scintilla/' ':!:com/win32comext/mapi/src/MAPIStubLibrary/') - shell: powershell mypy: runs-on: windows-2019 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a89a958b7..566983fae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,11 +29,7 @@ repos: hooks: - id: ruff # Run the linter. args: [--fix] - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.2 - hooks: - - id: black - verbose: true + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-clang-format rev: v18.1.5 hooks: diff --git a/adodbapi/adodbapi.py b/adodbapi/adodbapi.py index 4e85bc525..b63b829d8 100644 --- a/adodbapi/adodbapi.py +++ b/adodbapi/adodbapi.py @@ -395,9 +395,7 @@ def _rollback(self): # If attributes has adXactAbortRetaining it performs retaining aborts that is, # calling RollbackTrans automatically starts a new transaction. Not all providers support this. # If not, we will have to start a new transaction by this command: - if ( - not self.transaction_level - ): # if self.transaction_level == 0 or self.transaction_level is None: + if not self.transaction_level: self.transaction_level = self.connector.BeginTrans() except Exception as e: self._raiseConnectionError(api.ProgrammingError, e) @@ -634,9 +632,8 @@ def _makeDescriptionFromRS(self): if self.rs.EOF or self.rs.BOF: display_size = None else: - display_size = ( - f.ActualSize - ) # TODO: Is this the correct defintion according to the DB API 2 Spec ? + # TODO: Is this the correct defintion according to the DB API 2 Spec ? + display_size = f.ActualSize null_ok = bool(f.Attributes & adc.adFldMayBeNull) # v2.1 Cole desc.append( ( @@ -774,9 +771,8 @@ def get_returned_parameters(self): after the last recordset has been read. In that case, you must coll nextset() until it returns None, then call this method to get your returned information.""" - retLst = ( - [] - ) # store procedures may return altered parameters, including an added "return value" item + # store procedures may return altered parameters, including an added "return value" item + retLst = [] for p in tuple(self.cmd.Parameters): if verbose > 2: print( @@ -907,9 +903,8 @@ def _buildADOparameterList(self, parameters, sproc=False): ) i += 1 else: # -- build own parameter list - if ( - self._parameter_names - ): # we expect a dictionary of parameters, this is the list of expected names + # we expect a dictionary of parameters, this is the list of expected names + if self._parameter_names: for parm_name in self._parameter_names: elem = parameters[parm_name] adotype = api.pyTypeToADOType(elem) diff --git a/adodbapi/process_connect_string.py b/adodbapi/process_connect_string.py index d8b29f280..a134ad656 100644 --- a/adodbapi/process_connect_string.py +++ b/adodbapi/process_connect_string.py @@ -1,137 +1,135 @@ -""" a clumsy attempt at a macro language to let the programmer execute code on the server (ex: determine 64bit)""" - -from . import is64bit - - -def macro_call(macro_name, args, kwargs): - """allow the programmer to perform limited processing on the server by passing macro names and args - - :new_key - the key name the macro will create - :args[0] - macro name - :args[1:] - any arguments - :code - the value of the keyword item - :kwargs - the connection keyword dictionary. ??key has been removed - --> the value to put in for kwargs['name'] = value - """ - if isinstance(args, (str, str)): - args = [ - args - ] # the user forgot to pass a sequence, so make a string into args[0] - new_key = args[0] - try: - if macro_name == "is64bit": - if is64bit.Python(): # if on 64 bit Python - return new_key, args[1] # return first argument - else: - try: - return new_key, args[2] # else return second argument (if defined) - except IndexError: - return new_key, "" # else return blank - - elif ( - macro_name == "getuser" - ): # get the name of the user the server is logged in under - if not new_key in kwargs: - import getpass - - return new_key, getpass.getuser() - - elif macro_name == "getnode": # get the name of the computer running the server - import platform - - try: - return new_key, args[1] % platform.node() - except IndexError: - return new_key, platform.node() - - elif macro_name == "getenv": # expand the server's environment variable args[1] - try: - dflt = args[2] # if not found, default from args[2] - except IndexError: # or blank - dflt = "" - return new_key, os.environ.get(args[1], dflt) - - elif macro_name == "auto_security": - if ( - not "user" in kwargs or not kwargs["user"] - ): # missing, blank, or Null username - return new_key, "Integrated Security=SSPI" - return new_key, "User ID=%(user)s; Password=%(password)s" % kwargs - - elif ( - macro_name == "find_temp_test_path" - ): # helper function for testing ado operation -- undocumented - import os - import tempfile - - return new_key, os.path.join( - tempfile.gettempdir(), "adodbapi_test", args[1] - ) - - raise ValueError(f"Unknown connect string macro={macro_name}") - except: - raise ValueError(f"Error in macro processing {macro_name} {args!r}") - - -def process( - args, kwargs, expand_macros=False -): # --> connection string with keyword arguments processed. - """attempts to inject arguments into a connection string using Python "%" operator for strings - - co: adodbapi connection object - args: positional parameters from the .connect() call - kvargs: keyword arguments from the .connect() call - """ - try: - dsn = args[0] - except IndexError: - dsn = None - if isinstance( - dsn, dict - ): # as a convenience the first argument may be django settings - kwargs.update(dsn) - elif ( - dsn - ): # the connection string is passed to the connection as part of the keyword dictionary - kwargs["connection_string"] = dsn - try: - a1 = args[1] - except IndexError: - a1 = None - # historically, the second positional argument might be a timeout value - if isinstance(a1, int): - kwargs["timeout"] = a1 - # if the second positional argument is a string, then it is user - elif isinstance(a1, str): - kwargs["user"] = a1 - # if the second positional argument is a dictionary, use it as keyword arguments, too - elif isinstance(a1, dict): - kwargs.update(a1) - try: - kwargs["password"] = args[2] # the third positional argument is password - kwargs["host"] = args[3] # the fourth positional argument is host name - kwargs["database"] = args[4] # the fifth positional argument is database name - except IndexError: - pass - - # make sure connection string is defined somehow - if not "connection_string" in kwargs: - try: # perhaps 'dsn' was defined - kwargs["connection_string"] = kwargs["dsn"] - except KeyError: - try: # as a last effort, use the "host" keyword - kwargs["connection_string"] = kwargs["host"] - except KeyError: - raise TypeError("Must define 'connection_string' for ado connections") - if expand_macros: - for kwarg in list(kwargs.keys()): - if kwarg.startswith("macro_"): # If a key defines a macro - macro_name = kwarg[6:] # name without the "macro_" - macro_code = kwargs.pop( - kwarg - ) # we remove the macro_key and get the code to execute - new_key, rslt = macro_call( - macro_name, macro_code, kwargs - ) # run the code in the local context - kwargs[new_key] = rslt # put the result back in the keywords dict - return kwargs +""" a clumsy attempt at a macro language to let the programmer execute code on the server (ex: determine 64bit)""" + +from . import is64bit + + +def macro_call(macro_name, args, kwargs): + """allow the programmer to perform limited processing on the server by passing macro names and args + + :new_key - the key name the macro will create + :args[0] - macro name + :args[1:] - any arguments + :code - the value of the keyword item + :kwargs - the connection keyword dictionary. ??key has been removed + --> the value to put in for kwargs['name'] = value + """ + if isinstance(args, (str, str)): + args = [ + args + ] # the user forgot to pass a sequence, so make a string into args[0] + new_key = args[0] + try: + if macro_name == "is64bit": + if is64bit.Python(): # if on 64 bit Python + return new_key, args[1] # return first argument + else: + try: + return new_key, args[2] # else return second argument (if defined) + except IndexError: + return new_key, "" # else return blank + + elif ( + macro_name == "getuser" + ): # get the name of the user the server is logged in under + if not new_key in kwargs: + import getpass + + return new_key, getpass.getuser() + + elif macro_name == "getnode": # get the name of the computer running the server + import platform + + try: + return new_key, args[1] % platform.node() + except IndexError: + return new_key, platform.node() + + elif macro_name == "getenv": # expand the server's environment variable args[1] + try: + dflt = args[2] # if not found, default from args[2] + except IndexError: # or blank + dflt = "" + return new_key, os.environ.get(args[1], dflt) + + elif macro_name == "auto_security": + if ( + not "user" in kwargs or not kwargs["user"] + ): # missing, blank, or Null username + return new_key, "Integrated Security=SSPI" + return new_key, "User ID=%(user)s; Password=%(password)s" % kwargs + + elif ( + macro_name == "find_temp_test_path" + ): # helper function for testing ado operation -- undocumented + import os + import tempfile + + return new_key, os.path.join( + tempfile.gettempdir(), "adodbapi_test", args[1] + ) + + raise ValueError(f"Unknown connect string macro={macro_name}") + except: + raise ValueError(f"Error in macro processing {macro_name} {args!r}") + + +def process( + args, kwargs, expand_macros=False +): # --> connection string with keyword arguments processed. + """attempts to inject arguments into a connection string using Python "%" operator for strings + + co: adodbapi connection object + args: positional parameters from the .connect() call + kvargs: keyword arguments from the .connect() call + """ + try: + dsn = args[0] + except IndexError: + dsn = None + # as a convenience the first argument may be django settings + if isinstance(dsn, dict): + kwargs.update(dsn) + # the connection string is passed to the connection as part of the keyword dictionary + elif dsn: + kwargs["connection_string"] = dsn + try: + a1 = args[1] + except IndexError: + a1 = None + # historically, the second positional argument might be a timeout value + if isinstance(a1, int): + kwargs["timeout"] = a1 + # if the second positional argument is a string, then it is user + elif isinstance(a1, str): + kwargs["user"] = a1 + # if the second positional argument is a dictionary, use it as keyword arguments, too + elif isinstance(a1, dict): + kwargs.update(a1) + try: + kwargs["password"] = args[2] # the third positional argument is password + kwargs["host"] = args[3] # the fourth positional argument is host name + kwargs["database"] = args[4] # the fifth positional argument is database name + except IndexError: + pass + + # make sure connection string is defined somehow + if not "connection_string" in kwargs: + try: # perhaps 'dsn' was defined + kwargs["connection_string"] = kwargs["dsn"] + except KeyError: + try: # as a last effort, use the "host" keyword + kwargs["connection_string"] = kwargs["host"] + except KeyError: + raise TypeError("Must define 'connection_string' for ado connections") + if expand_macros: + for kwarg in list(kwargs.keys()): + if kwarg.startswith("macro_"): # If a key defines a macro + macro_name = kwarg[6:] # name without the "macro_" + macro_code = kwargs.pop( + kwarg + ) # we remove the macro_key and get the code to execute + new_key, rslt = macro_call( + macro_name, macro_code, kwargs + ) # run the code in the local context + kwargs[new_key] = rslt # put the result back in the keywords dict + return kwargs diff --git a/com/win32comext/adsi/demos/scp.py b/com/win32comext/adsi/demos/scp.py index b2ff016ec..dc5f831e8 100644 --- a/com/win32comext/adsi/demos/scp.py +++ b/com/win32comext/adsi/demos/scp.py @@ -419,7 +419,7 @@ def main(): "--test", action="store_true", help="Execute a mini-test suite, providing defaults for most options and args", - ), + ) parser.add_option( "", diff --git a/ruff.toml b/ruff.toml index eab7fcce1..6d75257db 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,4 +1,6 @@ target-version = "py38" # Target the oldest supported version in editors and default CLI +# This file is not UTF-8 +extend-exclude = ["Pythonwin/pywin/test/_dbgscript.py"] [lint] select = [ @@ -15,7 +17,6 @@ select = [ "FLY", # static-join-to-f-string "G", # flake8-logging-format # Note, we still want to allow multiline ISC - "ISC001", # single-line-implicit-string-concatenation "UP025", # Remove unicode literals from strings "UP030", # Use implicit references for positional format fields # TODO: Still lots of manual fixes needed diff --git a/win32/Lib/win32gui_struct.py b/win32/Lib/win32gui_struct.py index 41ef815fd..a4b7a4f4c 100644 --- a/win32/Lib/win32gui_struct.py +++ b/win32/Lib/win32gui_struct.py @@ -463,7 +463,7 @@ def EmptyTVITEM(hitem, mask=None, text_buf_size=512): else: text_addr = text_buf_size = 0 buf = struct.pack( - _tvitem_fmt, mask, hitem, 0, 0, text_addr, text_buf_size, 0, 0, 0, 0 # text + _tvitem_fmt, mask, hitem, 0, 0, text_addr, text_buf_size, 0, 0, 0, 0 ) return array.array("b", buf), extra @@ -758,7 +758,7 @@ def PackLVCOLUMN(fmt=None, cx=None, text=None, subItem=None, image=None, order=N text_addr, _ = text_buffer.buffer_info() text_len = len(text) buf = struct.pack( - _lvcolumn_fmt, mask, fmt, cx, text_addr, text_len, subItem, image, order # text + _lvcolumn_fmt, mask, fmt, cx, text_addr, text_len, subItem, image, order ) return array.array("b", buf), extra @@ -809,7 +809,7 @@ def EmptyLVCOLUMN(mask=None, text_buf_size=512): else: text_addr = text_buf_size = 0 buf = struct.pack( - _lvcolumn_fmt, mask, 0, 0, text_addr, text_buf_size, 0, 0, 0 # text + _lvcolumn_fmt, mask, 0, 0, text_addr, text_buf_size, 0, 0, 0 ) return array.array("b", buf), extra diff --git a/win32/Lib/win32pdhquery.py b/win32/Lib/win32pdhquery.py index 3f458e0a8..3e51b77b9 100644 --- a/win32/Lib/win32pdhquery.py +++ b/win32/Lib/win32pdhquery.py @@ -331,9 +331,8 @@ def collectdataslave(self, format=win32pdh.PDH_FMT_LONG): if not ok: temp.append(-1) # a better way to signal failure??? return temp - except ( - win32api.error - ): # will happen if, for instance, no counters are part of the query and we attempt to collect data for it. + # will happen if, for instance, no counters are part of the query and we attempt to collect data for it. + except win32api.error: return [-1] * len(self.counters) # pickle functions diff --git a/win32/test/test_win32file.py b/win32/test/test_win32file.py index 4763f9289..12ba8c31d 100644 --- a/win32/test/test_win32file.py +++ b/win32/test/test_win32file.py @@ -641,7 +641,10 @@ def _watcherThread(self, dn, dh, changes): try: print("waiting", dh) changes = win32file.ReadDirectoryChangesW( - dh, 8192, False, flags # sub-tree + dh, + 8192, + False, # sub-tree + flags, ) print("got", changes) except: @@ -655,7 +658,11 @@ def _watcherThreadOverlapped(self, dn, dh, changes): overlapped.hEvent = win32event.CreateEvent(None, 0, 0, None) while 1: win32file.ReadDirectoryChangesW( - dh, buf, False, flags, overlapped # sub-tree + dh, + buf, + False, # sub-tree + flags, + overlapped, ) # Wait for our event, or for 5 seconds. rc = win32event.WaitForSingleObject(overlapped.hEvent, 5000) From b74bfdca97238735adbd1b20d7245cca7070900f Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 14 Oct 2024 13:18:52 -0400 Subject: [PATCH 03/16] Run ruff format --- AutoDuck/Dump2HHC.py | 28 ++--- Pythonwin/pywin/dialogs/list.py | 19 ++-- Pythonwin/pywin/framework/app.py | 3 +- Pythonwin/pywin/framework/scriptutils.py | 4 +- Pythonwin/pywin/framework/stdin.py | 1 + Pythonwin/pywin/mfc/activex.py | 3 +- adodbapi/examples/db_print.py | 2 +- adodbapi/examples/db_table_names.py | 2 +- adodbapi/process_connect_string.py | 2 +- adodbapi/test/adodbapitest.py | 33 +++--- adodbapi/test/dbapi20.py | 14 +-- adodbapi/test/setuptestframework.py | 1 + com/win32com/client/combrowse.py | 27 +++-- com/win32com/client/dynamic.py | 7 +- com/win32com/client/genpy.py | 4 +- com/win32com/client/makepy.py | 7 +- com/win32com/client/selecttlb.py | 3 +- com/win32com/makegw/makegw.py | 102 ++++++++---------- com/win32com/makegw/makegwenum.py | 8 +- com/win32com/makegw/makegwparse.py | 14 +-- com/win32com/olectl.py | 2 +- com/win32com/server/connect.py | 2 +- com/win32com/server/exception.py | 14 +-- com/win32com/servers/interp.py | 14 +-- com/win32com/test/errorSemantics.py | 6 +- com/win32com/test/testExchange.py | 1 - com/win32com/test/testvb.py | 15 +-- com/win32com/util.py | 2 +- com/win32comext/axdebug/adb.py | 3 +- com/win32comext/axdebug/contexts.py | 4 +- com/win32comext/axdebug/documents.py | 3 +- com/win32comext/axdebug/dump.py | 4 +- com/win32comext/axscript/client/error.py | 4 +- com/win32comext/axscript/client/framework.py | 8 +- .../axscript/client/scriptdispatch.py | 6 +- isapi/samples/redirector_with_filter.py | 1 + isapi/simple.py | 1 + isapi/threaded_extension.py | 1 + setup.py | 68 +++--------- win32/Demos/security/GetTokenInformation.py | 4 +- win32/Demos/win32ts_logoff_disconnected.py | 2 +- win32/Lib/win32evtlogutil.py | 3 +- win32/Lib/win32gui_struct.py | 4 +- win32/Lib/win32rcparser.py | 1 + win32/scripts/regsetup.py | 7 +- win32/test/test_win32clipboard.py | 5 +- win32/test/test_win32cred.py | 1 - 47 files changed, 202 insertions(+), 268 deletions(-) diff --git a/AutoDuck/Dump2HHC.py b/AutoDuck/Dump2HHC.py index 343bdbca1..32c728c9d 100644 --- a/AutoDuck/Dump2HHC.py +++ b/AutoDuck/Dump2HHC.py @@ -293,9 +293,7 @@ def _genItemsFromDict(dict, cat, output, target, do_children=1): - """.format( - **locals() - ) + """.format(**locals()) ) if not do_children: continue @@ -339,9 +337,7 @@ def genTOC(cats, output, title, target):
    -""".format( - **locals() - ) +""".format(**locals()) ) for cat in cats: @@ -355,9 +351,7 @@ def genTOC(cats, output, title, target):
      - """.format( - **locals() - ) + """.format(**locals()) ) # Next write the overviews for this category output.write( @@ -368,9 +362,7 @@ def genTOC(cats, output, title, target):
        - """.format( - **locals() - ) + """.format(**locals()) ) _genItemsFromDict(cat.overviewTopics, cat, output, target) _genItemsFromDict(cat.extOverviewTopics, cat, output, target) @@ -387,9 +379,7 @@ def genTOC(cats, output, title, target):
          -""".format( - **locals() - ) +""".format(**locals()) ) _genItemsFromDict(cat.modules, cat, output, target) output.write( @@ -404,9 +394,7 @@ def genTOC(cats, output, title, target): -
            """.format( - **locals() - ) +
              """.format(**locals()) ) # Don't show 'children' for objects - params etc don't need their own child nodes! _genItemsFromDict(cat.objects, cat, output, target, do_children=0) @@ -423,9 +411,7 @@ def genTOC(cats, output, title, target):
                -""".format( - **locals() - ) +""".format(**locals()) ) _genItemsFromDict(cat.constants, cat, output, target) output.write( diff --git a/Pythonwin/pywin/dialogs/list.py b/Pythonwin/pywin/dialogs/list.py index 4e1877955..377a7cade 100644 --- a/Pythonwin/pywin/dialogs/list.py +++ b/Pythonwin/pywin/dialogs/list.py @@ -44,14 +44,17 @@ def OnListClick(self, id, code): return 1 def OnListItemChange(self, std, extra): - (hwndFrom, idFrom, code), ( - itemNotify, - sub, - newState, - oldState, - change, - point, - lparam, + ( + (hwndFrom, idFrom, code), + ( + itemNotify, + sub, + newState, + oldState, + change, + point, + lparam, + ), ) = (std, extra) oldSel = (oldState & commctrl.LVIS_SELECTED) != 0 newSel = (newState & commctrl.LVIS_SELECTED) != 0 diff --git a/Pythonwin/pywin/framework/app.py b/Pythonwin/pywin/framework/app.py index 4e0f09b94..9899e62fa 100644 --- a/Pythonwin/pywin/framework/app.py +++ b/Pythonwin/pywin/framework/app.py @@ -2,7 +2,8 @@ # The application is responsible for managing the main frame window. # # We also grab the FileOpen command, to invoke our Python editor -" The PythonWin application code. Manages most aspects of MDI, etc " +"The PythonWin application code. Manages most aspects of MDI, etc" + from __future__ import annotations import os diff --git a/Pythonwin/pywin/framework/scriptutils.py b/Pythonwin/pywin/framework/scriptutils.py index fe57113dd..32811190b 100644 --- a/Pythonwin/pywin/framework/scriptutils.py +++ b/Pythonwin/pywin/framework/scriptutils.py @@ -27,9 +27,7 @@ debugging_options = """No debugging Step-through in the debugger Run in the debugger -Post-Mortem of unhandled exceptions""".split( - "\n" -) +Post-Mortem of unhandled exceptions""".split("\n") byte_cr = b"\r" byte_lf = b"\n" diff --git a/Pythonwin/pywin/framework/stdin.py b/Pythonwin/pywin/framework/stdin.py index 1614fbe91..b7d71dc19 100644 --- a/Pythonwin/pywin/framework/stdin.py +++ b/Pythonwin/pywin/framework/stdin.py @@ -16,6 +16,7 @@ import sys sys.stdin = sys.stdin.real_file """ + import sys get_input_line = input diff --git a/Pythonwin/pywin/mfc/activex.py b/Pythonwin/pywin/mfc/activex.py index f3d9939a4..3d0207aca 100644 --- a/Pythonwin/pywin/mfc/activex.py +++ b/Pythonwin/pywin/mfc/activex.py @@ -1,5 +1,4 @@ -"""Support for ActiveX control hosting in Pythonwin. -""" +"""Support for ActiveX control hosting in Pythonwin.""" import win32ui import win32uiole diff --git a/adodbapi/examples/db_print.py b/adodbapi/examples/db_print.py index c0eb83ee4..fc86a8b3c 100644 --- a/adodbapi/examples/db_print.py +++ b/adodbapi/examples/db_print.py @@ -1,4 +1,4 @@ -""" db_print.py -- a simple demo for ADO database reads.""" +"""db_print.py -- a simple demo for ADO database reads.""" import sys diff --git a/adodbapi/examples/db_table_names.py b/adodbapi/examples/db_table_names.py index 907bdb85e..17ff58349 100644 --- a/adodbapi/examples/db_table_names.py +++ b/adodbapi/examples/db_table_names.py @@ -1,4 +1,4 @@ -""" db_table_names.py -- a simple demo for ADO database table listing.""" +"""db_table_names.py -- a simple demo for ADO database table listing.""" import sys diff --git a/adodbapi/process_connect_string.py b/adodbapi/process_connect_string.py index a134ad656..b1d4e4e93 100644 --- a/adodbapi/process_connect_string.py +++ b/adodbapi/process_connect_string.py @@ -1,4 +1,4 @@ -""" a clumsy attempt at a macro language to let the programmer execute code on the server (ex: determine 64bit)""" +"""a clumsy attempt at a macro language to let the programmer execute code on the server (ex: determine 64bit)""" from . import is64bit diff --git a/adodbapi/test/adodbapitest.py b/adodbapi/test/adodbapitest.py index 1b50e595f..dd8e9196d 100644 --- a/adodbapi/test/adodbapitest.py +++ b/adodbapi/test/adodbapitest.py @@ -1,4 +1,4 @@ -""" Unit tests version 2.6.1.0 for adodbapi""" +"""Unit tests version 2.6.1.0 for adodbapi""" """ adodbapi - A python DB API 2.0 interface to Microsoft ADO @@ -325,15 +325,16 @@ def helpTestDataType( rs = crsr.fetchone() if allowedReturnValues: allowedTypes = tuple([type(aRV) for aRV in allowedReturnValues]) - assert isinstance( - rs[0], allowedTypes - ), 'result type "%s" must be one of %s' % (type(rs[0]), allowedTypes) + assert isinstance(rs[0], allowedTypes), ( + 'result type "%s" must be one of %s' % (type(rs[0]), allowedTypes) + ) else: - assert isinstance( - rs[0], type(pyData) - ), 'result type "%s" must be instance of %s' % ( - type(rs[0]), - type(pyData), + assert isinstance(rs[0], type(pyData)), ( + 'result type "%s" must be instance of %s' + % ( + type(rs[0]), + type(pyData), + ) ) if compareAlmostEqual and DBAPIDataTypeString == "DATETIME": @@ -343,9 +344,9 @@ def helpTestDataType( elif compareAlmostEqual: s = float(pyData) v = float(rs[0]) - assert ( - abs(v - s) / s < 0.00001 - ), "Values not almost equal recvd=%s, expected=%f" % (rs[0], s) + assert abs(v - s) / s < 0.00001, ( + "Values not almost equal recvd=%s, expected=%f" % (rs[0], s) + ) else: if allowedReturnValues: ok = False @@ -487,7 +488,7 @@ def testDataTypeDate(self): ) def testDataTypeBinary(self): - binfld = b"\x07\x00\xE2\x40*" + binfld = b"\x07\x00\xe2\x40*" arv = [binfld, adodbapi.Binary(binfld), bytes(binfld)] if self.getEngine() == "PostgreSQL": self.helpTestDataType( @@ -692,9 +693,9 @@ def testRowIterator(self): rec = crsr.fetchone() # check that stepping through an emulated row works for j in range(len(inParam)): - assert ( - rec[j] == inParam[j] - ), 'returned value:"%s" != test value:"%s"' % (rec[j], inParam[j]) + assert rec[j] == inParam[j], ( + 'returned value:"%s" != test value:"%s"' % (rec[j], inParam[j]) + ) # check that we can get a complete tuple from a row assert ( tuple(rec) == inParam diff --git a/adodbapi/test/dbapi20.py b/adodbapi/test/dbapi20.py index 5639e4c3c..373b984d6 100644 --- a/adodbapi/test/dbapi20.py +++ b/adodbapi/test/dbapi20.py @@ -1,14 +1,14 @@ #!/usr/bin/env python -""" Python DB API 2.0 driver compliance unit test suite. +"""Python DB API 2.0 driver compliance unit test suite. - This software is Public Domain and may be used without restrictions. + This software is Public Domain and may be used without restrictions. - "Now we have booze and barflies entering the discussion, plus rumours of - DBAs on drugs... and I won't tell you what flashes through my mind each - time I read the subject line with 'Anal Compliance' in it. All around - this is turning out to be a thoroughly unwholesome unit test." +"Now we have booze and barflies entering the discussion, plus rumours of + DBAs on drugs... and I won't tell you what flashes through my mind each + time I read the subject line with 'Anal Compliance' in it. All around + this is turning out to be a thoroughly unwholesome unit test." - -- Ian Bicking + -- Ian Bicking """ __version__ = "$Revision: 1.15.0 $"[11:-2] diff --git a/adodbapi/test/setuptestframework.py b/adodbapi/test/setuptestframework.py index 65b99e990..e09549421 100644 --- a/adodbapi/test/setuptestframework.py +++ b/adodbapi/test/setuptestframework.py @@ -1,6 +1,7 @@ #!/usr/bin/python2 # Configure this in order to run the testcases. "setuptestframework.py v 2.6.0.8" + import os import shutil import tempfile diff --git a/com/win32com/client/combrowse.py b/com/win32com/client/combrowse.py index f83aa9c9b..4587a9aab 100644 --- a/com/win32com/client/combrowse.py +++ b/com/win32com/client/combrowse.py @@ -1,25 +1,25 @@ """A utility for browsing COM objects. - Usage: +Usage: - Command Prompt + Command Prompt - Use the command *"python.exe combrowse.py"*. This will display - display a fairly small, modal dialog. + Use the command *"python.exe combrowse.py"*. This will display + display a fairly small, modal dialog. - Pythonwin + Pythonwin - Use the "Run Script" menu item, and this will create the browser in an - MDI window. This window can be fully resized. + Use the "Run Script" menu item, and this will create the browser in an + MDI window. This window can be fully resized. - Details +Details - This module allows browsing of registered Type Libraries, COM categories, - and running COM objects. The display is similar to the Pythonwin object - browser, and displays the objects in a hierarchical window. + This module allows browsing of registered Type Libraries, COM categories, + and running COM objects. The display is similar to the Pythonwin object + browser, and displays the objects in a hierarchical window. - Note that this module requires the win32ui (ie, Pythonwin) distribution to - work. + Note that this module requires the win32ui (ie, Pythonwin) distribution to + work. """ @@ -581,7 +581,6 @@ def GetSubList(self): def main(modal=True, mdi=False): - root = HLIRoot("COM Browser") if mdi and "pywin.framework.app" in sys.modules: # do it in a MDI window diff --git a/com/win32com/client/dynamic.py b/com/win32com/client/dynamic.py index 7a269d514..3879aed2c 100644 --- a/com/win32com/client/dynamic.py +++ b/com/win32com/client/dynamic.py @@ -389,9 +389,10 @@ def _get_good_object_(self, ob, userName=None, ReturnCLSID=None): elif isinstance(ob, tuple): return tuple( map( - lambda o, s=self, oun=userName, rc=ReturnCLSID: s._get_good_single_object_( - o, oun, rc - ), + lambda o, + s=self, + oun=userName, + rc=ReturnCLSID: s._get_good_single_object_(o, oun, rc), ob, ) ) diff --git a/com/win32com/client/genpy.py b/com/win32com/client/genpy.py index b11d3b85b..c6d8b4319 100644 --- a/com/win32com/client/genpy.py +++ b/com/win32com/client/genpy.py @@ -969,9 +969,7 @@ def _Build_Interface(self, type_info_tuple): return oleItem, vtableItem def BuildOleItemsFromType(self): - assert ( - self.bBuildHidden - ), "This code doesn't look at the hidden flag - I thought everyone set it true!?!?!" + assert self.bBuildHidden, "This code doesn't look at the hidden flag - I thought everyone set it true!?!?!" oleItems = {} enumItems = {} recordItems = {} diff --git a/com/win32com/client/makepy.py b/com/win32com/client/makepy.py index 9f05ab5b5..4d60856ed 100644 --- a/com/win32com/client/makepy.py +++ b/com/win32com/client/makepy.py @@ -15,11 +15,12 @@ """Generate a .py file from an OLE TypeLibrary file. - This module is concerned only with the actual writing of - a .py file. It draws on the @build@ module, which builds - the knowledge of a COM interface. +This module is concerned only with the actual writing of +a .py file. It draws on the @build@ module, which builds +the knowledge of a COM interface. """ + usageHelp = """ \ Usage: diff --git a/com/win32com/client/selecttlb.py b/com/win32com/client/selecttlb.py index bf8627f5f..1d10c9ad8 100644 --- a/com/win32com/client/selecttlb.py +++ b/com/win32com/client/selecttlb.py @@ -1,5 +1,4 @@ -"""Utilities for selecting and enumerating the Type Libraries installed on the system -""" +"""Utilities for selecting and enumerating the Type Libraries installed on the system""" import pythoncom import win32api diff --git a/com/win32com/makegw/makegw.py b/com/win32com/makegw/makegw.py index 61e48ab37..2a12239c8 100644 --- a/com/win32com/makegw/makegw.py +++ b/com/win32com/makegw/makegw.py @@ -1,48 +1,48 @@ """Utility functions for writing out gateway C++ files - This module will generate a C++/Python binding for a specific COM - interface. - - Can be run from command line (passing required arguments) or the old way - (start Python, import this module, change to the directory where the generated code - should be written, and run the public function). - - This module is capable of generating both 'Interfaces' (ie, Python - client side support for the interface) and 'Gateways' (ie, Python - server side support for the interface). Many COM interfaces are useful - both as Client and Server. Other interfaces, however, really only make - sense to implement one side or the other. For example, it would be pointless - for Python to implement Server side for 'IRunningObjectTable', unless we were - implementing core COM for an operating system in Python (hey - now there's an idea!) - - Most COM interface code is totally boiler-plate - it consists of - converting arguments, dispatching the call to Python, and processing - any result values. - - This module automates the generation of such code. It has the ability to - parse a .H file generated by the MIDL tool (ie, almost all COM .h files) - and build almost totally complete C++ code. - - The module understands some of the well known data types, and how to - convert them. There are only a couple of places where hand-editing is - necessary, as detailed below: - - unsupported types -- If a type is not known, the generator will - pretty much ignore it, but write a comment to the generated code. You - may want to add custom support for this type. In some cases, C++ compile errors - will result. These are intentional - generating code to remove these errors would - imply a false sense of security that the generator has done the right thing. - - other return policies -- By default, Python never sees the return SCODE from - a COM function. The interface usually returns None if OK, else a COM exception - if "FAILED(scode)" is TRUE. You may need to change this if: - * EXCEPINFO is passed to the COM function. This is not detected and handled - * For some reason Python should always see the result SCODE, even if it - did fail or succeed. For example, some functions return a BOOLEAN result - in the SCODE, meaning Python should always see it. - * FAILED(scode) for the interface still has valid data to return (by default, - the code generated does not process the return values, and raise an exception - to Python/COM +This module will generate a C++/Python binding for a specific COM +interface. + +Can be run from command line (passing required arguments) or the old way +(start Python, import this module, change to the directory where the generated code +should be written, and run the public function). + +This module is capable of generating both 'Interfaces' (ie, Python +client side support for the interface) and 'Gateways' (ie, Python +server side support for the interface). Many COM interfaces are useful +both as Client and Server. Other interfaces, however, really only make +sense to implement one side or the other. For example, it would be pointless +for Python to implement Server side for 'IRunningObjectTable', unless we were +implementing core COM for an operating system in Python (hey - now there's an idea!) + +Most COM interface code is totally boiler-plate - it consists of +converting arguments, dispatching the call to Python, and processing +any result values. + +This module automates the generation of such code. It has the ability to +parse a .H file generated by the MIDL tool (ie, almost all COM .h files) +and build almost totally complete C++ code. + +The module understands some of the well known data types, and how to +convert them. There are only a couple of places where hand-editing is +necessary, as detailed below: + +unsupported types -- If a type is not known, the generator will +pretty much ignore it, but write a comment to the generated code. You +may want to add custom support for this type. In some cases, C++ compile errors +will result. These are intentional - generating code to remove these errors would +imply a false sense of security that the generator has done the right thing. + +other return policies -- By default, Python never sees the return SCODE from +a COM function. The interface usually returns None if OK, else a COM exception +if "FAILED(scode)" is TRUE. You may need to change this if: +* EXCEPINFO is passed to the COM function. This is not detected and handled +* For some reason Python should always see the result SCODE, even if it + did fail or succeed. For example, some functions return a BOOLEAN result + in the SCODE, meaning Python should always see it. +* FAILED(scode) for the interface still has valid data to return (by default, + the code generated does not process the return values, and raise an exception + to Python/COM """ import argparse @@ -202,9 +202,7 @@ def _write_ifc_cpp(f, interface): return ({name} *)Py{base}::GetI(self); }} -""".format( - **interface.__dict__ - ) +""".format(**interface.__dict__) ) ptr = re.sub(r"[a-z]", "", interface.name) @@ -219,9 +217,7 @@ def _write_ifc_cpp(f, interface): {interfacename} *p{ptr} = GetI(self); if ( p{ptr} == NULL ) return NULL; -""".format( - **strdict - ) +""".format(**strdict) ) argsParseTuple = argsCOM = formatChars = codePost = codePobjects = ( codeCobjects @@ -294,9 +290,7 @@ def _write_ifc_cpp(f, interface): {cleanup_gil} if ( FAILED(hr) ) return PyCom_BuildPyException(hr, p{ptr}, IID_{interfacename} ); -""".format( - **strdict - ) +""".format(**strdict) ) codePre = codePost = formatChars = codeVarsPass = codeDecl = "" for arg in method.args: @@ -348,9 +342,7 @@ def _write_ifc_cpp(f, interface): sizeof(Py{name}), Py{name}_methods, GET_PYCOM_CTOR(Py{name})); -""".format( - **locals() - ) +""".format(**locals()) ) diff --git a/com/win32com/makegw/makegwenum.py b/com/win32com/makegw/makegwenum.py index 3ba274a4e..d3698af75 100644 --- a/com/win32com/makegw/makegwenum.py +++ b/com/win32com/makegw/makegwenum.py @@ -191,9 +191,7 @@ def _write_enumifc_cpp(f, interface): sizeof(PyIEnum{enumtype}), PyIEnum{enumtype}_methods, GET_PYCOM_CTOR(PyIEnum{enumtype})); -""".format( - **locals() - ) +""".format(**locals()) ) @@ -329,7 +327,5 @@ def _write_enumgw_cpp(f, interface): return PyCom_CheckIEnumNextResult(hr, IID_IEnum{enumtype}); }} -""".format( - **locals() - ) +""".format(**locals()) ) diff --git a/com/win32com/makegw/makegwparse.py b/com/win32com/makegw/makegwparse.py index 89a574608..14e800db6 100644 --- a/com/win32com/makegw/makegwparse.py +++ b/com/win32com/makegw/makegwparse.py @@ -1,15 +1,15 @@ """Utilities for makegw - Parse a header file to build an interface - This module contains the core code for parsing a header file describing a - COM interface, and building it into an "Interface" structure. +This module contains the core code for parsing a header file describing a +COM interface, and building it into an "Interface" structure. - Each Interface has methods, and each method has arguments. +Each Interface has methods, and each method has arguments. - Each argument knows how to use Py_BuildValue or Py_ParseTuple to - exchange itself with Python. +Each argument knows how to use Py_BuildValue or Py_ParseTuple to +exchange itself with Python. - See the @win32com.makegw@ module for information in building a COM - interface +See the @win32com.makegw@ module for information in building a COM +interface """ from __future__ import annotations diff --git a/com/win32com/olectl.py b/com/win32com/olectl.py index f6be98bda..3ec5bf6ef 100644 --- a/com/win32com/olectl.py +++ b/com/win32com/olectl.py @@ -1,6 +1,6 @@ """Constants used by COM Controls - Hand created version of OLECTL.H constants. +Hand created version of OLECTL.H constants. """ import winerror diff --git a/com/win32com/server/connect.py b/com/win32com/server/connect.py index e99555a04..1fe7a0313 100644 --- a/com/win32com/server/connect.py +++ b/com/win32com/server/connect.py @@ -1,6 +1,6 @@ """Utilities for Server Side connections. - A collection of helpers for server side connection points. +A collection of helpers for server side connection points. """ import pythoncom diff --git a/com/win32com/server/exception.py b/com/win32com/server/exception.py index a6b3111fe..c31073e1c 100644 --- a/com/win32com/server/exception.py +++ b/com/win32com/server/exception.py @@ -1,15 +1,15 @@ """Exception Handling - Exceptions +Exceptions - To better support COM exceptions, the framework allows for an instance to be - raised. This instance may have a certain number of known attributes, which are - translated into COM exception details. + To better support COM exceptions, the framework allows for an instance to be + raised. This instance may have a certain number of known attributes, which are + translated into COM exception details. - This means, for example, that Python could raise a COM exception that includes details - on a Help file and location, and a description for the user. + This means, for example, that Python could raise a COM exception that includes details + on a Help file and location, and a description for the user. - This module provides a class which provides the necessary attributes. + This module provides a class which provides the necessary attributes. """ import sys diff --git a/com/win32com/servers/interp.py b/com/win32com/servers/interp.py index 37d83bd49..0676e2127 100644 --- a/com/win32com/servers/interp.py +++ b/com/win32com/servers/interp.py @@ -1,14 +1,14 @@ """Python.Interpreter COM Server - This module implements a very very simple COM server which - exposes the Python interpreter. +This module implements a very very simple COM server which +exposes the Python interpreter. - This is designed more as a demonstration than a full blown COM server. - General functionality and Error handling are both limited. +This is designed more as a demonstration than a full blown COM server. +General functionality and Error handling are both limited. - To use this object, ensure it is registered by running this module - from Python.exe. Then, from Visual Basic, use "CreateObject('Python.Interpreter')", - and call its methods! +To use this object, ensure it is registered by running this module +from Python.exe. Then, from Visual Basic, use "CreateObject('Python.Interpreter')", +and call its methods! """ import winerror diff --git a/com/win32com/test/errorSemantics.py b/com/win32com/test/errorSemantics.py index 843395c41..fe5045cc8 100644 --- a/com/win32com/test/errorSemantics.py +++ b/com/win32com/test/errorSemantics.py @@ -158,7 +158,7 @@ def test(): "The source in the exception tuple did not yield the correct string", str(com_exc), ) - assert exc[2] == "\U0001F600", ( + assert exc[2] == "\U0001f600", ( "The description in the exception tuple did not yield the correct string", str(com_exc), ) @@ -213,7 +213,7 @@ def testLogger(): except pythoncom.error as exc: # `excepinfo` is a tuple with elt 2 being the traceback we captured. message = exc.excepinfo[2] - assert message.endswith("Exception: \U0001F600\n") + assert message.endswith("Exception: \U0001f600\n") assert handler.num_emits == 1, handler.num_emits assert handler.last_record.startswith( "pythoncom error: Unexpected exception in gateway method 'Commit'" @@ -228,7 +228,7 @@ def testLogger(): except pythoncom.error as exc: # `excepinfo` is a tuple with elt 2 being the traceback we captured. message = exc.excepinfo[2] - assert message.endswith("Exception: \U0001F600\n") + assert message.endswith("Exception: \U0001f600\n") assert handler.num_emits == 1, handler.num_emits handler.reset() diff --git a/com/win32com/test/testExchange.py b/com/win32com/test/testExchange.py index 119c16a17..f54422bb6 100644 --- a/com/win32com/test/testExchange.py +++ b/com/win32com/test/testExchange.py @@ -91,7 +91,6 @@ def TestUser(session): def test(): - oldcwd = os.getcwd() try: session = gencache.EnsureDispatch("MAPI.Session") diff --git a/com/win32com/test/testvb.py b/com/win32com/test/testvb.py index ca5ab7689..65426559d 100644 --- a/com/win32com/test/testvb.py +++ b/com/win32com/test/testvb.py @@ -95,10 +95,13 @@ def TestVB(vbtest, bUseGenerated): vbtest.VariantProperty == "Hello from Python" ), "Could not set the variant string property correctly." vbtest.VariantProperty = (1.0, 2.0, 3.0) - assert vbtest.VariantProperty == ( - 1.0, - 2.0, - 3.0, + assert ( + vbtest.VariantProperty + == ( + 1.0, + 2.0, + 3.0, + ) ), f"Could not set the variant property to an array of floats correctly - '{vbtest.VariantProperty}'." TestArrays(vbtest, bUseGenerated) @@ -195,8 +198,8 @@ def _getcount(ob): check = [] for item in i: check.append(item) - assert check == list( - expected + assert ( + check == list(expected) ), f"Collection iterator {col_name} didn't have {expected!r} 2nd time around (had {check!r})" # but an iterator is not restartable check = [] diff --git a/com/win32com/util.py b/com/win32com/util.py index 0a5748f1e..2fa8931af 100644 --- a/com/win32com/util.py +++ b/com/win32com/util.py @@ -1,6 +1,6 @@ """General utility functions common to client and server. - This module contains a collection of general purpose utility functions. +This module contains a collection of general purpose utility functions. """ import pythoncom diff --git a/com/win32comext/axdebug/adb.py b/com/win32comext/axdebug/adb.py index 191041809..ee6b620c5 100644 --- a/com/win32comext/axdebug/adb.py +++ b/com/win32comext/axdebug/adb.py @@ -1,5 +1,4 @@ -"""The glue between the Python debugger interface and the Active Debugger interface -""" +"""The glue between the Python debugger interface and the Active Debugger interface""" import _thread import bdb diff --git a/com/win32comext/axdebug/contexts.py b/com/win32comext/axdebug/contexts.py index df6e97760..d732fbae1 100644 --- a/com/win32comext/axdebug/contexts.py +++ b/com/win32comext/axdebug/contexts.py @@ -1,6 +1,4 @@ -""" A module for managing the AXDebug I*Contexts - -""" +"""A module for managing the AXDebug I*Contexts""" from . import adb, axdebug, gateways diff --git a/com/win32comext/axdebug/documents.py b/com/win32comext/axdebug/documents.py index 560901fb4..eb45517e7 100644 --- a/com/win32comext/axdebug/documents.py +++ b/com/win32comext/axdebug/documents.py @@ -1,5 +1,4 @@ -""" Management of documents for AXDebugging. -""" +"""Management of documents for AXDebugging.""" import pythoncom import win32api diff --git a/com/win32comext/axdebug/dump.py b/com/win32comext/axdebug/dump.py index 61a1cfc7a..6500167c0 100644 --- a/com/win32comext/axdebug/dump.py +++ b/com/win32comext/axdebug/dump.py @@ -46,9 +46,7 @@ def dumpall(): e = Enumerator(dm.EnumApplications()) for app in e: print(f"Application: {app.GetName()}") - node = ( - app.GetRootNode() - ) # of type PyIDebugApplicationNode->PyIDebugDocumentProvider->PyIDebugDocumentInfo + node = app.GetRootNode() # of type PyIDebugApplicationNode->PyIDebugDocumentProvider->PyIDebugDocumentInfo DumpDebugApplicationNode(node) diff --git a/com/win32comext/axscript/client/error.py b/com/win32comext/axscript/client/error.py index 5aadbf9bc..f02e66603 100644 --- a/com/win32comext/axscript/client/error.py +++ b/com/win32comext/axscript/client/error.py @@ -1,7 +1,7 @@ """Exception and error handling. - This contains the core exceptions that the implementations should raise - as well as the IActiveScriptError interface code. +This contains the core exceptions that the implementations should raise +as well as the IActiveScriptError interface code. """ from __future__ import annotations diff --git a/com/win32comext/axscript/client/framework.py b/com/win32comext/axscript/client/framework.py index b9f0fd605..c4a04329f 100644 --- a/com/win32comext/axscript/client/framework.py +++ b/com/win32comext/axscript/client/framework.py @@ -1,10 +1,10 @@ """AXScript Client Framework - This module provides a core framework for an ActiveX Scripting client. - Derived classes actually implement the AX Client itself, including the - scoping rules, etc. +This module provides a core framework for an ActiveX Scripting client. +Derived classes actually implement the AX Client itself, including the +scoping rules, etc. - There are classes defined for the engine itself, and for ScriptItems +There are classes defined for the engine itself, and for ScriptItems """ from __future__ import annotations diff --git a/com/win32comext/axscript/client/scriptdispatch.py b/com/win32comext/axscript/client/scriptdispatch.py index ca696fe84..6bd29adcb 100644 --- a/com/win32comext/axscript/client/scriptdispatch.py +++ b/com/win32comext/axscript/client/scriptdispatch.py @@ -1,8 +1,8 @@ """dynamic dispatch objects for AX Script. - This is an IDispatch object that a scripting host may use to - query and invoke methods on the main script. Not may hosts use - this yet, so it is not well tested! +This is an IDispatch object that a scripting host may use to +query and invoke methods on the main script. Not may hosts use +this yet, so it is not well tested! """ from __future__ import annotations diff --git a/isapi/samples/redirector_with_filter.py b/isapi/samples/redirector_with_filter.py index 6d9914c04..393e89d05 100644 --- a/isapi/samples/redirector_with_filter.py +++ b/isapi/samples/redirector_with_filter.py @@ -84,6 +84,7 @@ def Dispatch(self, ecb): # The ISAPI filter. class Filter(SimpleFilter): "Sample Python Redirector" + filter_flags = isapicon.SF_NOTIFY_PREPROC_HEADERS | isapicon.SF_NOTIFY_ORDER_DEFAULT def HttpFilterProc(self, fc): diff --git a/isapi/simple.py b/isapi/simple.py index d5fcb04d7..177e8935c 100644 --- a/isapi/simple.py +++ b/isapi/simple.py @@ -40,6 +40,7 @@ def TerminateExtension(self, status): class SimpleFilter: "Base class for a a simple ISAPI filter" + filter_flags: int | None = None def __init__(self): diff --git a/isapi/threaded_extension.py b/isapi/threaded_extension.py index 044b90987..b6a161a23 100644 --- a/isapi/threaded_extension.py +++ b/isapi/threaded_extension.py @@ -60,6 +60,7 @@ def call_handler(self, cblock): # fully asynch extension. class ThreadPoolExtension(isapi.simple.SimpleExtension): "Base class for an ISAPI extension based around a thread-pool" + max_workers = 20 worker_shutdown_wait = 15000 # 15 seconds for workers to quit... diff --git a/setup.py b/setup.py index e25465fd7..e72edf0ad 100644 --- a/setup.py +++ b/setup.py @@ -1341,9 +1341,7 @@ def finalize_options(self): {win32com}/extensions/PyICancelMethodCalls.cpp {win32com}/extensions/PyIContext.cpp {win32com}/extensions/PyIEnumContextProps.cpp {win32com}/extensions/PyIClientSecurity.cpp {win32com}/extensions/PyIServerSecurity.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), depends=( """ @@ -1370,9 +1368,7 @@ def finalize_options(self): {win32com}/include\\PyICancelMethodCalls.h {win32com}/include\\PyIContext.h {win32com}/include\\PyIEnumContextProps.h {win32com}/include\\PyIClientSecurity.h {win32com}/include\\PyIServerSecurity.h - """.format( - **dirs - ) + """.format(**dirs) ).split(), libraries="oleaut32 ole32 user32 urlmon", export_symbol_file="com/win32com/src/PythonCOM.def", @@ -1400,9 +1396,7 @@ def finalize_options(self): {adsi}/adsilib.i {adsi}/PyADSIUtil.cpp {adsi}/PyDSOPObjects.cpp {adsi}/PyIADs.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), ), WinExt_win32com( @@ -1420,9 +1414,7 @@ def finalize_options(self): {axcontrol}/PyIOleClientSite.cpp {axcontrol}/PyIOleInPlaceSite.cpp {axcontrol}/PyIOleObject.cpp {axcontrol}/PyIViewObject2.cpp {axcontrol}/PyIOleCommandTarget.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), ), WinExt_win32com( @@ -1437,9 +1429,7 @@ def finalize_options(self): {axscript}/PyIActiveScriptParse.cpp {axscript}/PyIActiveScriptParseProcedure.cpp {axscript}/PyIActiveScriptSite.cpp {axscript}/PyIMultiInfos.cpp {axscript}/PyIObjectSafety.cpp {axscript}/stdafx.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), depends=( """ @@ -1448,9 +1438,7 @@ def finalize_options(self): {axscript}/PyIActiveScriptError.h {axscript}/PyIObjectSafety.h {axscript}/PyIProvideMultipleClassInfo.h {axscript}/stdafx.h - """.format( - **dirs - ) + """.format(**dirs) ).split(), extra_compile_args=["-DPY_BUILD_AXSCRIPT"], implib_name="axscript", @@ -1506,9 +1494,7 @@ def finalize_options(self): {axdebug}/PyIRemoteDebugApplicationEvents.cpp {axdebug}/PyIRemoteDebugApplicationThread.cpp {axdebug}/stdafx.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), ), WinExt_win32com( @@ -1521,9 +1507,7 @@ def finalize_options(self): {internet}/PyIInternetPriority.cpp {internet}/PyIInternetProtocol.cpp {internet}/PyIInternetProtocolInfo.cpp {internet}/PyIInternetProtocolRoot.cpp {internet}/PyIInternetProtocolSink.cpp {internet}/PyIInternetSecurityManager.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), depends=["{internet}/internet_pch.h".format(**dirs)], ), @@ -1559,9 +1543,7 @@ def finalize_options(self): {mapi}/mapiguids.cpp {mapi}/MAPIStubLibrary/library/mapiStubLibrary.cpp {mapi}/MAPIStubLibrary/library/stubutils.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), ), WinExt_win32com_mapi( @@ -1577,9 +1559,7 @@ def finalize_options(self): {mapi}/exchangeguids.cpp {mapi}/MAPIStubLibrary/library/mapiStubLibrary.cpp {mapi}/MAPIStubLibrary/library/stubutils.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), ), WinExt_win32com( @@ -1661,9 +1641,7 @@ def finalize_options(self): {shell}/PyIUniformResourceLocator.cpp {shell}/shell.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), ), WinExt_win32com( @@ -1691,9 +1669,7 @@ def finalize_options(self): {propsys}/PyIObjectWithPropertyKey.cpp {propsys}/PyIPropertyChange.cpp {propsys}/PyIPropertyChangeArray.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), implib_name="pypropsys", ), @@ -1709,9 +1685,7 @@ def finalize_options(self): {taskscheduler}/PyITaskScheduler.cpp {taskscheduler}/PyITaskTrigger.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), ), WinExt_win32com( @@ -1732,9 +1706,7 @@ def finalize_options(self): {bits}/PyIEnumBackgroundCopyJobs.cpp {bits}/PyIEnumBackgroundCopyFiles.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), ), WinExt_win32com( @@ -1755,18 +1727,14 @@ def finalize_options(self): {directsound}/PyIDirectSoundBuffer.cpp {directsound}/PyIDirectSoundCapture.cpp {directsound}/PyIDirectSoundCaptureBuffer.cpp {directsound}/PyIDirectSoundNotify.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), depends=( """ {directsound}/directsound_pch.h {directsound}/PyIDirectSound.h {directsound}/PyIDirectSoundBuffer.h {directsound}/PyIDirectSoundCapture.h {directsound}/PyIDirectSoundCaptureBuffer.h {directsound}/PyIDirectSoundNotify.h - """.format( - **dirs - ) + """.format(**dirs) ).split(), optional_headers=["dsound.h"], libraries="user32 dsound dxguid", @@ -1778,9 +1746,7 @@ def finalize_options(self): """ {authorization}/authorization.cpp {authorization}/PyGSecurityInformation.cpp - """.format( - **dirs - ) + """.format(**dirs) ).split(), ), ] diff --git a/win32/Demos/security/GetTokenInformation.py b/win32/Demos/security/GetTokenInformation.py index 192c549e1..745e0e78e 100644 --- a/win32/Demos/security/GetTokenInformation.py +++ b/win32/Demos/security/GetTokenInformation.py @@ -1,5 +1,5 @@ -""" Lists various types of information about current user's access token, - including UAC status on Vista +"""Lists various types of information about current user's access token, +including UAC status on Vista """ import pywintypes diff --git a/win32/Demos/win32ts_logoff_disconnected.py b/win32/Demos/win32ts_logoff_disconnected.py index 2a8bcc940..3b7f882e0 100644 --- a/win32/Demos/win32ts_logoff_disconnected.py +++ b/win32/Demos/win32ts_logoff_disconnected.py @@ -1,4 +1,4 @@ -""" Finds any disconnected terminal service sessions and logs them off""" +"""Finds any disconnected terminal service sessions and logs them off""" import pywintypes import win32ts diff --git a/win32/Lib/win32evtlogutil.py b/win32/Lib/win32evtlogutil.py index 05cabe2b8..58d3326ef 100644 --- a/win32/Lib/win32evtlogutil.py +++ b/win32/Lib/win32evtlogutil.py @@ -1,5 +1,4 @@ -"""Event Log Utilities - helper for win32evtlog.pyd -""" +"""Event Log Utilities - helper for win32evtlog.pyd""" import win32api import win32con diff --git a/win32/Lib/win32gui_struct.py b/win32/Lib/win32gui_struct.py index a4b7a4f4c..5651c7bc8 100644 --- a/win32/Lib/win32gui_struct.py +++ b/win32/Lib/win32gui_struct.py @@ -808,9 +808,7 @@ def EmptyLVCOLUMN(mask=None, text_buf_size=512): text_addr, _ = text_buffer.buffer_info() else: text_addr = text_buf_size = 0 - buf = struct.pack( - _lvcolumn_fmt, mask, 0, 0, text_addr, text_buf_size, 0, 0, 0 - ) + buf = struct.pack(_lvcolumn_fmt, mask, 0, 0, text_addr, text_buf_size, 0, 0, 0) return array.array("b", buf), extra diff --git a/win32/Lib/win32rcparser.py b/win32/Lib/win32rcparser.py index b87bd96fe..183f075b1 100644 --- a/win32/Lib/win32rcparser.py +++ b/win32/Lib/win32rcparser.py @@ -7,6 +7,7 @@ This is a parser for Windows .rc files, which are text files which define dialogs and other Windows UI resources. """ + from __future__ import annotations import os diff --git a/win32/scripts/regsetup.py b/win32/scripts/regsetup.py index da2f870e1..fb33e11dd 100644 --- a/win32/scripts/regsetup.py +++ b/win32/scripts/regsetup.py @@ -447,8 +447,7 @@ def RegisterShellInfo(searchPaths): # FindRegisterApp("win32", ["win32con.pyc", "win32api%s.pyd" % suffix], searchPaths) -usage = ( - """\ +usage = """\ regsetup.py - Setup/maintain the registry for Python apps. Run without options, (but possibly search paths) to repair a totally broken @@ -475,9 +474,7 @@ def RegisterShellInfo(searchPaths): --description -- Print a description of the usage. --examples -- Print examples of usage. -""" - % sys.argv[0] -) +""" % sys.argv[0] description = """\ If no options are processed, the program attempts to validate and set diff --git a/win32/test/test_win32clipboard.py b/win32/test/test_win32clipboard.py index f5d5c28d1..ccfc32e53 100644 --- a/win32/test/test_win32clipboard.py +++ b/win32/test/test_win32clipboard.py @@ -5,7 +5,6 @@ class TestGetSetClipboardData(unittest.TestCase): - def copyData(self, data, format_): win32clipboard.OpenClipboard() ret = None @@ -30,13 +29,13 @@ def test_data(self): test_data = { "Dummy str": win32clipboard.CF_UNICODETEXT, b"Dummy bytes text": win32clipboard.CF_TEXT, - b"Dummy\x00\xFF bytes": win32clipboard.CF_DIB, + b"Dummy\x00\xff bytes": win32clipboard.CF_DIB, } for data, fmt in test_data.items(): self.assertEqual(data, self.copyData(data, fmt)) test_data = { "Dummy str": (win32clipboard.CF_TEXT, win32clipboard.CF_DIB), - b"Dummy\x00\xFF bytes": (win32clipboard.CF_UNICODETEXT,), + b"Dummy\x00\xff bytes": (win32clipboard.CF_UNICODETEXT,), } for data, formats in test_data.items(): for fmt in formats: diff --git a/win32/test/test_win32cred.py b/win32/test/test_win32cred.py index c44fe18b8..4b9fe08d7 100644 --- a/win32/test/test_win32cred.py +++ b/win32/test/test_win32cred.py @@ -5,7 +5,6 @@ class TestCredFunctions(unittest.TestCase): - def setUp(self): self.flags = 0 self.dummy_cred = { From 5a46a21be0fdf9472f1904c54bd301745cfc482d Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 14 Oct 2024 13:21:36 -0400 Subject: [PATCH 04/16] Update git-blame-ignore-revs --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 4816d046a..9309054aa 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -13,3 +13,6 @@ # 2024-05-28 formatted c++ source with clang-format 637448f8252ab142eedd539ddf9b08259b73eecc + +# 2024-10-14 formatted Python source with Ruff format +2b5191d8fc6f1d1fbde01481b49278c1957ef8f1 From 50cfd5958c63a9f9ac5ddd36447fa46219753a3f Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 24 Oct 2024 10:21:31 -0400 Subject: [PATCH 05/16] Fix various typos (#2300) --- AutoDuck/makedfromi.py | 2 +- AutoDuck/py2d.py | 2 +- CHANGES.txt | 4 ++-- Pythonwin/contents.d | 2 +- Pythonwin/pythondoc.h | 14 +++++++------- Pythonwin/pywin/debugger/fail.py | 2 +- Pythonwin/pywin/framework/editor/editor.py | 2 +- Pythonwin/pywin/framework/editor/vss.py | 2 +- Pythonwin/pywin/framework/intpyapp.py | 2 +- Pythonwin/pywin/framework/startup.py | 2 +- Pythonwin/pywin/scintilla/keycodes.py | 2 +- Pythonwin/pywin/scintilla/view.py | 2 +- Pythonwin/win32bitmap.cpp | 2 +- Pythonwin/win32dlg.cpp | 2 +- Pythonwin/win32virt.cpp | 2 +- adodbapi/adodbapi.py | 4 ++-- adodbapi/readme.txt | 2 +- adodbapi/test/adodbapitest.py | 4 ++-- adodbapi/test/dbapi20.py | 4 ++-- adodbapi/test/setuptestframework.py | 2 +- build_env.md | 2 +- com/changes.txt | 2 +- com/win32com/changes.txt | 2 +- com/win32com/server/policy.py | 2 +- com/win32com/server/register.py | 2 +- com/win32com/src/dllmain.cpp | 2 +- com/win32com/src/univgw_dataconv.cpp | 2 +- com/win32comext/axdebug/documents.py | 2 +- com/win32comext/axscript/client/pyscript.py | 2 +- .../axscript/demos/client/ie/demo_intro.htm | 2 +- com/win32comext/bits/src/bits.cpp | 8 ++++---- com/win32comext/shell/demos/servers/folder_view.py | 2 +- com/win32comext/shell/src/PyIShellItem2.cpp | 2 +- ruff.toml | 2 +- win32/Demos/security/set_file_audit.py | 2 +- win32/Lib/pywin32_testutil.py | 4 ++-- win32/Lib/win32cryptcon.py | 2 +- win32/Lib/win32pdhquery.py | 4 ++-- win32/Lib/win32timezone.py | 2 +- win32/scripts/regsetup.py | 4 ++-- win32/src/PySECURITY_DESCRIPTOR.cpp | 4 ++-- win32/src/PythonService.cpp | 2 +- win32/src/win32file.i | 12 ++++++------ 43 files changed, 65 insertions(+), 65 deletions(-) diff --git a/AutoDuck/makedfromi.py b/AutoDuck/makedfromi.py index 4fd2f44ac..53edf0111 100644 --- a/AutoDuck/makedfromi.py +++ b/AutoDuck/makedfromi.py @@ -20,7 +20,7 @@ def GetComments(line, lineNo, lines): if len(data) != 2: break if data[0].strip(): - break # Not a continutation! + break # Not a continuation! if data[1].strip().startswith("@"): # new command break diff --git a/AutoDuck/py2d.py b/AutoDuck/py2d.py index 647fb7121..2b2d779b8 100644 --- a/AutoDuck/py2d.py +++ b/AutoDuck/py2d.py @@ -75,7 +75,7 @@ def format_desc(desc): # 'first_para_of_docstring' # '@comm next para of docstring' # '@comm next para of docstring' ... etc - # BUT - also handling enbedded doctests, where we write + # BUT - also handling embedded doctests, where we write # '@iex >>> etc.' if not desc: return "" diff --git a/CHANGES.txt b/CHANGES.txt index 82cf59213..d02c6fcae 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -68,7 +68,7 @@ as the .chm file, certain MAPI libraries etc, and .exe installers. * `win32com.client.build.error` * `win32com.client.genpy.error` * Add EnumDesktopWindows (#2219, @CristiFati) -* Marked `exc_type` and `exc_traceback` in `win32comext.axscript.client.error.AXScriptException.__init__` as deprecated. (#2236 , @Avasam) +* Marked `exc_type` and `exc_traceback` in `win32comext.axscript.client.error.AXScriptException.__init__` as deprecated. (#2236, @Avasam) They are now unused and all information is taken from the `exc_value` parameter. * Fixed non-overriden `pywin.scintilla.formatter.Formatter.ColorizeString` raising `TypeError` instead of `RuntimeError` due to too many parameters (#2216, @Avasam) * Fixed broken since Python 3 tokenization in `win32comext.axdebug.codecontainer.pySourceCodeContainer.GetSyntaxColorAttributes` (#2216, @Avasam) @@ -189,7 +189,7 @@ as the .chm file, certain MAPI libraries etc, and .exe installers. * Use byte-string (`b""`) for constant bytes values instead of superfluous `.encode` calls (#2046, @Avasam) * Cleaned up unused imports (#1986, #2051, #1990, #2124, #2126, @Avasam) * Removed duplicated declarations, constants and definitions (#2050, #1950, #1990, @Avasam) -* Small generalized optimization by using augmented assignements (in-place operators) where possible (#2274, @Avasam) +* Small generalized optimization by using augmented assignments (in-place operators) where possible (#2274, @Avasam) * General speed and size improvements due to all the removed code. (#2046, #1986, #2050, #1950, #2085, #2087, #2051, #1990, #2106, #2127, #2124, #2126, #2177, #2218, #2202, #2205, #2217) ### adodbapi diff --git a/Pythonwin/contents.d b/Pythonwin/contents.d index 86101de59..581380465 100644 --- a/Pythonwin/contents.d +++ b/Pythonwin/contents.d @@ -119,7 +119,7 @@ it uses overrides the default. Thus, regardless of your preferences, if the fir indent in the file is a tab, Pythonwin uses tabs for the entire file (and similarly, uses spaces if the first block is indented with spaces) -Things can appear to get wierd when editing a file with mixed tabs and spaces. +Things can appear to get weird when editing a file with mixed tabs and spaces. Although mixed tabs and spaces in the same indent is evil, there are a number of source files that have certain classes/functions indented with spaces, and others that use tabs. The editor will not correctly adjust to the current block - whatever diff --git a/Pythonwin/pythondoc.h b/Pythonwin/pythondoc.h index d0c2811d2..fb5f4b13c 100644 --- a/Pythonwin/pythondoc.h +++ b/Pythonwin/pythondoc.h @@ -112,7 +112,7 @@ BOOL CPythonDocTemp

                ::OnSaveDocument(const TCHAR *fileName) // @pyparm string|fileName||The name of the file being saved. // @xref // @comm If a handler is defined for this function, the base (MFC) function will not - // be called. If necessary, the handler must call this function explicitely. + // be called. If necessary, the handler must call this function explicitly. CVirtualHelper helper("OnSaveDocument", this); if (helper.call(fileName)) { int ret; @@ -131,7 +131,7 @@ BOOL CPythonDocTemp

                ::OnOpenDocument(const TCHAR *fileName) // @pyvirtual int|PyCDocument|OnOpenDocument|Called by the MFC architecture. // @xref // @comm If a handler is defined for this function, the base (MFC) function will not - // be called. If necessary, the handler must call this function explicitely. + // be called. If necessary, the handler must call this function explicitly. CVirtualHelper helper("OnOpenDocument", this); if (!helper.HaveHandler()) { PyErr_SetString(ui_module_error, "PyCDocument::OnOpenDocument handler does not exist."); @@ -155,7 +155,7 @@ BOOL CPythonDocTemp

                ::OnNewDocument() // @pyvirtual int|PyCDocument|OnNewDocument|Called by the MFC architecture. // @xref // @comm If a handler is defined for this function, the base (MFC) function will not - // be called. If necessary, the handler must call this function explicitely. + // be called. If necessary, the handler must call this function explicitly. CVirtualHelper helper("OnNewDocument", this); if (!helper.HaveHandler()) { helper.release_full(); @@ -182,7 +182,7 @@ void CPythonDocTemp

                ::OnCloseDocument() // @pyvirtual |PyCDocument|OnCloseDocument|Called by the MFC architecture. // @xref // @comm If a handler is defined for this function, the base (MFC) function will not - // be called. If necessary, the handler must call this function explicitely. + // be called. If necessary, the handler must call this function explicitly. CVirtualHelper helper("OnCloseDocument", this); if (helper.HaveHandler()) { helper.call(); @@ -215,7 +215,7 @@ void CPythonDocTemp

                ::DeleteContents() P::DeleteContents(); } // @comm If a handler is defined for this function, the base (MFC) function will not - // be called. If necessary, the handler must call this function explicitely. + // be called. If necessary, the handler must call this function explicitly. } template BOOL CPythonDocTemp

                ::SaveModified() @@ -223,7 +223,7 @@ BOOL CPythonDocTemp

                ::SaveModified() // @pyvirtual int|PyCDocument|SaveModified|Called by the MFC architecture when a document is closed. // @xref // @comm If a handler is defined for this function, the base (MFC) function will not - // be called. If necessary, the handler must call this function explicitely. + // be called. If necessary, the handler must call this function explicitly. CVirtualHelper helper("SaveModified", this); if (!helper.HaveHandler()) { helper.release_full(); @@ -244,7 +244,7 @@ void CPythonDocTemp

                ::OnChangedViewList() // @pyvirtual int|PyCDocument|OnChangedViewList|Called by the MFC architecture when after a view is attached. // @xref // @comm If a handler is defined for this function, the base (MFC) function will not - // be called. If necessary, the handler must call this function explicitely. + // be called. If necessary, the handler must call this function explicitly. CVirtualHelper helper("OnChangedViewList", this); if (helper.HaveHandler() && helper.call()) { return; diff --git a/Pythonwin/pywin/debugger/fail.py b/Pythonwin/pywin/debugger/fail.py index dbb5320ae..0afc70eb3 100644 --- a/Pythonwin/pywin/debugger/fail.py +++ b/Pythonwin/pywin/debugger/fail.py @@ -28,7 +28,7 @@ def b(): b = 1 pywin.debugger.set_trace() # After importing or running this module, you are likely to be - # sitting at the next line. This is because we explicitely + # sitting at the next line. This is because we explicitly # broke into the debugger using the "set_trace() function # "pywin.debugger.brk()" is a shorter alias for this. c() diff --git a/Pythonwin/pywin/framework/editor/editor.py b/Pythonwin/pywin/framework/editor/editor.py index facb5b23f..1095cbe97 100644 --- a/Pythonwin/pywin/framework/editor/editor.py +++ b/Pythonwin/pywin/framework/editor/editor.py @@ -9,7 +9,7 @@ # We now support reloading of externally modified documented # (eg, presumably by some other process, such as source control or # another editor. -# We also suport auto-loading of externally modified files. +# We also support auto-loading of externally modified files. # - if the current document has not been modified in this # editor, but has been modified on disk, then the file # can be automatically reloaded. diff --git a/Pythonwin/pywin/framework/editor/vss.py b/Pythonwin/pywin/framework/editor/vss.py index 4a772acef..fa3b51ed3 100644 --- a/Pythonwin/pywin/framework/editor/vss.py +++ b/Pythonwin/pywin/framework/editor/vss.py @@ -86,7 +86,7 @@ def CheckoutFile(fileName): project, vssFname, database = rc if g_sourceSafe is None: g_sourceSafe = win32com.client.Dispatch("SourceSafe") - # SS seems a bit wierd. It defaults the arguments as empty strings, but + # SS seems a bit weird. It defaults the arguments as empty strings, but # then complains when they are used - so we pass "Missing" if not database: database = pythoncom.Missing diff --git a/Pythonwin/pywin/framework/intpyapp.py b/Pythonwin/pywin/framework/intpyapp.py index acbd34cc1..de02fdace 100644 --- a/Pythonwin/pywin/framework/intpyapp.py +++ b/Pythonwin/pywin/framework/intpyapp.py @@ -467,7 +467,7 @@ def OnFileLocate(self, id, code): else: win32ui.GetApp().OpenDocumentFile(newName) - # Display all the "options" proprety pages we can find + # Display all the "options" property pages we can find def OnViewOptions(self, id, code): win32ui.InitRichEdit() sheet = dialog.PropertySheet("Pythonwin Options") diff --git a/Pythonwin/pywin/framework/startup.py b/Pythonwin/pywin/framework/startup.py index 3cc6c0169..ca7a44d87 100644 --- a/Pythonwin/pywin/framework/startup.py +++ b/Pythonwin/pywin/framework/startup.py @@ -50,7 +50,7 @@ pywin.__path__[0] = win32ui.FullPath(pywin.__path__[0]) pywin.framework.__path__[0] = win32ui.FullPath(pywin.framework.__path__[0]) -# make a few wierd sys values. This is so later we can clobber sys.argv to trick +# make a few weird sys values. This is so later we can clobber sys.argv to trick # scripts when running under a GUI environment. moduleName = "pywin.framework.intpyapp" diff --git a/Pythonwin/pywin/scintilla/keycodes.py b/Pythonwin/pywin/scintilla/keycodes.py index d94ccda47..12867080a 100644 --- a/Pythonwin/pywin/scintilla/keycodes.py +++ b/Pythonwin/pywin/scintilla/keycodes.py @@ -70,7 +70,7 @@ def get_vk(chardesc): def parse_key_name(name): - name += "-" # Add a sentinal + name += "-" # Add a sentinel start = pos = 0 max = len(name) toks = [] diff --git a/Pythonwin/pywin/scintilla/view.py b/Pythonwin/pywin/scintilla/view.py index 99680f18e..0134f3151 100644 --- a/Pythonwin/pywin/scintilla/view.py +++ b/Pythonwin/pywin/scintilla/view.py @@ -749,7 +749,7 @@ def CalculatePageRanges(self, dc, pInfo): pageStart = self.FormatRange(dc, pageStart, textLen, rc, 0) maxPage += 1 self.starts[maxPage] = pageStart - # And a sentinal for one page past the end + # And a sentinel for one page past the end self.starts[maxPage + 1] = textLen # When actually printing, maxPage doesn't have any effect at this late state. # but is needed to make the Print Preview work correctly. diff --git a/Pythonwin/win32bitmap.cpp b/Pythonwin/win32bitmap.cpp index 157457063..0422fbf75 100644 --- a/Pythonwin/win32bitmap.cpp +++ b/Pythonwin/win32bitmap.cpp @@ -210,7 +210,7 @@ PyObject *ui_bitmap_load_bitmap_file(PyObject *self, PyObject *args) return NULL; } */ - /* Attempt to load wierd bitmap format. + /* Attempt to load weird bitmap format. if (bmFileHeader.bfOffBits) { PyObject *args = Py_BuildValue("(i)", bmFileHeader.bfOffBits); result = gui_call_object(seeker, args); diff --git a/Pythonwin/win32dlg.cpp b/Pythonwin/win32dlg.cpp index 598aae410..6a0e2fecb 100644 --- a/Pythonwin/win32dlg.cpp +++ b/Pythonwin/win32dlg.cpp @@ -162,7 +162,7 @@ PyCDialog::~PyCDialog() GlobalFree(hSaved); } - ui_assoc_object::SetAssocInvalid(); // must call this explicitely, as I ignore SetAssocInvalid + ui_assoc_object::SetAssocInvalid(); // must call this explicitly, as I ignore SetAssocInvalid Py_XDECREF(ddlist); // we can not have the pointer deleted at window destruction time // for a dialog (as MFC still needs it after the dialog has completed BOOL bManDeleteSave = bManualDelete; diff --git a/Pythonwin/win32virt.cpp b/Pythonwin/win32virt.cpp index 5d049fbf3..a53aa58a8 100644 --- a/Pythonwin/win32virt.cpp +++ b/Pythonwin/win32virt.cpp @@ -42,7 +42,7 @@ CVirtualHelper::CVirtualHelper(const char *iname, void *iassoc, EnumVirtualError PyErr_Fetch(&t, &v, &tb); handler = PyObject_GetAttrString(py_bob->virtualInst, (char *)iname); if (handler) { - // explicitely check a method returned, else the classes + // explicitly check a method returned, else the classes // delegation may cause a circular call chain. if (!PyMethod_Check(handler)) { if (!PyCFunction_Check(handler)) { diff --git a/adodbapi/adodbapi.py b/adodbapi/adodbapi.py index b63b829d8..19adbfb30 100644 --- a/adodbapi/adodbapi.py +++ b/adodbapi/adodbapi.py @@ -66,7 +66,7 @@ def getIndexedValue(obj, index): def make_COM_connecter(): try: pythoncom.CoInitialize() # v2.1 Paj - c = Dispatch("ADODB.Connection") # connect _after_ CoIninialize v2.1.1 adamvan + c = Dispatch("ADODB.Connection") # connect _after_ CoInitialize v2.1.1 adamvan except: raise api.InterfaceError( "Windows COM Error: Dispatch('ADODB.Connection') failed." @@ -593,7 +593,7 @@ def _raiseCursorError(self, errorclass, errorvalue): eh(self.connection, self, errorclass, errorvalue) def build_column_info(self, recordset): - self.converters = [] # convertion function for each column + self.converters = [] # conversion function for each column self.columnNames = {} # names of columns {lowercase name : number,...} self._description = None diff --git a/adodbapi/readme.txt b/adodbapi/readme.txt index 00f76f7c2..877c400cb 100644 --- a/adodbapi/readme.txt +++ b/adodbapi/readme.txt @@ -34,7 +34,7 @@ Try: or: adodbapi.apibase.variantConversions[adodbapi.ado_consts.adNumeric] = adodbapi.apibase.cvtFloat or: - adodbapi.apibase.variantConversions[adodbapi.ado_consts.adNumeric] = write_your_own_convertion_function + adodbapi.apibase.variantConversions[adodbapi.ado_consts.adNumeric] = write_your_own_conversion_function ............ notes for 2.6.2: The definitive source has been moved to https://github.com/mhammond/pywin32/tree/master/adodbapi. diff --git a/adodbapi/test/adodbapitest.py b/adodbapi/test/adodbapitest.py index dd8e9196d..88dab1267 100644 --- a/adodbapi/test/adodbapitest.py +++ b/adodbapi/test/adodbapitest.py @@ -213,7 +213,7 @@ def testUserDefinedConversionForExactNumericTypes(self): # now return strings adodbapi.variantConversions[ado_consts.adNumeric] = adodbapi.cvtString self.helpTestDataType("numeric(18,2)", "NUMBER", "3.45") - # now a completly weird user defined convertion + # now a completely weird user defined conversion adodbapi.variantConversions[ado_consts.adNumeric] = ( lambda x: "!!This function returns a funny unicode string %s!!" % x ) @@ -228,7 +228,7 @@ def testUserDefinedConversionForExactNumericTypes(self): finally: # now reset the converter to its original function adodbapi.variantConversions[ado_consts.adNumeric] = ( - oldconverter # Restore the original convertion function + oldconverter # Restore the original conversion function ) def helpTestDataType( diff --git a/adodbapi/test/dbapi20.py b/adodbapi/test/dbapi20.py index 373b984d6..ea920d42b 100644 --- a/adodbapi/test/dbapi20.py +++ b/adodbapi/test/dbapi20.py @@ -71,7 +71,7 @@ # - Now a subclass of TestCase, to avoid requiring the driver stub # to use multiple inheritance # - Reversed the polarity of buggy test in test_description -# - Test exception heirarchy correctly +# - Test exception hierarchy correctly # - self.populate is now self._populate(), so if a driver stub # overrides self.ddl1 this change propogates # - VARCHAR columns now have a width, which will hopefully make the @@ -198,7 +198,7 @@ def test_paramstyle(self): def test_Exceptions(self): # Make sure required exceptions exist, and are in the - # defined heirarchy. + # defined hierarchy. if sys.version[0] == "3": # under Python 3 StardardError no longer exists self.assertTrue(issubclass(self.driver.Warning, Exception)) self.assertTrue(issubclass(self.driver.Error, Exception)) diff --git a/adodbapi/test/setuptestframework.py b/adodbapi/test/setuptestframework.py index e09549421..4b9de6a7d 100644 --- a/adodbapi/test/setuptestframework.py +++ b/adodbapi/test/setuptestframework.py @@ -56,7 +56,7 @@ def makeadopackage(testfolder): shutil.copy(os.path.join(adoPath, f), newpackage) return testfolder else: - raise OSError("Connot find source of adodbapi to test.") + raise OSError("Cannot find source of adodbapi to test.") def makemdb(testfolder, mdb_name): diff --git a/build_env.md b/build_env.md index 4f616bf99..7e166c4d9 100644 --- a/build_env.md +++ b/build_env.md @@ -117,7 +117,7 @@ where mc ``` (Note that the above process for 'mc' doesn't appear necessary for VS2017, but -markh hasn't tried with VS2019 - please share your experiences!) +@mhammond hasn't tried with VS2019 - please share your experiences!) # Build diff --git a/com/changes.txt b/com/changes.txt index f94adde87..27e387a8c 100644 --- a/com/changes.txt +++ b/com/changes.txt @@ -110,7 +110,7 @@ Dec 1, 96 win32com.pythoncom works (and is the "official" way!). - Connection point support added. makepy will now generate code suitable to be used as an OCX, or as a connection point sink. - Slightly wierd connection point demo (client and server!) is in demos\connect.py + Slightly weird connection point demo (client and server!) is in demos\connect.py Note - All old OCX code will be broken. You must regenerate all .py files, AND CHANGE ALL SUPPORT CODE (sorry!). Specifically, the name of the class you should sub-class from will have changed - it diff --git a/com/win32com/changes.txt b/com/win32com/changes.txt index 3b3a0588e..57734d924 100644 --- a/com/win32com/changes.txt +++ b/com/win32com/changes.txt @@ -113,7 +113,7 @@ Dec 1, 96 win32com.pythoncom works (and is the "official" way!). - Connection point support added. makepy will now generate code suitable to be used as an OCX, or as a connection point sink. - Slightly wierd connection point demo (client and server!) is in demos\connect.py + Slightly weird connection point demo (client and server!) is in demos\connect.py Note - All old OCX code will be broken. You must regenerate all .py files, AND CHANGE ALL SUPPORT CODE (sorry!). Specifically, the name of the class you should sub-class from will have changed - it diff --git a/com/win32com/server/policy.py b/com/win32com/server/policy.py index 0c1f92427..f4593b4b9 100644 --- a/com/win32com/server/policy.py +++ b/com/win32com/server/policy.py @@ -321,7 +321,7 @@ def _getidsofnames_(self, names, lcid): # IDispatchEx support for policies. Most of the IDispathEx functionality # by default will raise E_NOTIMPL. Thus it is not necessary for derived - # policies to explicitely implement all this functionality just to not implement it! + # policies to explicitly implement all this functionality just to not implement it! def _GetDispID_(self, name, fdex): return self._getdispid_(name, fdex) diff --git a/com/win32com/server/register.py b/com/win32com/server/register.py index 04ffdca37..760a65701 100644 --- a/com/win32com/server/register.py +++ b/com/win32com/server/register.py @@ -448,7 +448,7 @@ def RegisterClasses(*classes, **flags): win32api.FindFiles(sys.argv[0])[0][8] )[0] except (IndexError, win32api.error): - # Can't find the script file - the user must explicitely set the _reg_... attribute. + # Can't find the script file - the user must explicitly set the _reg_... attribute. raise TypeError( "Can't locate the script hosting the COM object - please set _reg_class_spec_ in your object" ) diff --git a/com/win32com/src/dllmain.cpp b/com/win32com/src/dllmain.cpp index bac646ece..de857ed84 100644 --- a/com/win32com/src/dllmain.cpp +++ b/com/win32com/src/dllmain.cpp @@ -156,7 +156,7 @@ typedef HRESULT(WINAPI *PFNCoInitializeEx)(LPVOID pvReserved, DWORD dwCoInit); // particular about the order of shutdown - in MAPI's case, you MUST // do the CoUninit _before_ the MAPIUninit. // These functions have logic so the Python programmer can call either -// the Init for Term function explicitely, and the framework will detect +// the Init for Term function explicitly, and the framework will detect // it no longer needs doing. // XXX - Needs more thought about threading implications. HRESULT PyCom_CoInitializeEx(LPVOID reserved, DWORD dwInit) diff --git a/com/win32com/src/univgw_dataconv.cpp b/com/win32com/src/univgw_dataconv.cpp index 23107d01d..520adb66b 100644 --- a/com/win32com/src/univgw_dataconv.cpp +++ b/com/win32com/src/univgw_dataconv.cpp @@ -702,7 +702,7 @@ PyObject *dataconv_ReadFromInTuple(PyObject *self, PyObject *args) default: obArg = NULL; PyErr_SetString(PyExc_TypeError, "Unknown/bad type description type!"); - // barf here, we don't wtf they were thinking... + // barf here, we don't know wtf they were thinking... break; } // switch } // if ARRAY diff --git a/com/win32comext/axdebug/documents.py b/com/win32comext/axdebug/documents.py index eb45517e7..723d2bf13 100644 --- a/com/win32comext/axdebug/documents.py +++ b/com/win32comext/axdebug/documents.py @@ -105,7 +105,7 @@ class CodeContainerProvider: Given a Python file name (as the debugger knows it by) this will return a CodeContainer interface suitable for use. - This provides a simple base imlpementation that simply supports + This provides a simple base implementation that simply supports a dictionary of nodes and providers. """ diff --git a/com/win32comext/axscript/client/pyscript.py b/com/win32comext/axscript/client/pyscript.py index fd7806073..e281d16a7 100644 --- a/com/win32comext/axscript/client/pyscript.py +++ b/com/win32comext/axscript/client/pyscript.py @@ -100,7 +100,7 @@ def _FindAttribute_(self, attr): class NamedScriptAttribute: - "An explicitely named object in an objects namespace" + "An explicitly named object in an objects namespace" # Each named object holds a reference to one of these. # Whenever a sub-item appears in a namespace, it is really one of these diff --git a/com/win32comext/axscript/demos/client/ie/demo_intro.htm b/com/win32comext/axscript/demos/client/ie/demo_intro.htm index 9987d8972..c02be1a6e 100644 --- a/com/win32comext/axscript/demos/client/ie/demo_intro.htm +++ b/com/win32comext/axscript/demos/client/ie/demo_intro.htm @@ -30,7 +30,7 @@

                Known bugs and problems

              • Builtin objects such as MARQUEE are giving me grief. Objects accessed via forms are generally no problem.

              • If you are trying to use Python with the Windows Scripting Host, note that -.pys files are not correct registered - you will need to explicitely +.pys files are not correct registered - you will need to explicitly specify either cscript.exe or wscript.exe on the command line.

              diff --git a/com/win32comext/bits/src/bits.cpp b/com/win32comext/bits/src/bits.cpp index f92868f55..6b973f893 100755 --- a/com/win32comext/bits/src/bits.cpp +++ b/com/win32comext/bits/src/bits.cpp @@ -30,7 +30,7 @@ void PyObject_FreeBG_FILE_RANGE_LIST(DWORD num, BG_FILE_RANGE *fr) {} PyObject *PyObject_FromBG_FILE_PROGRESS(BG_FILE_PROGRESS *fp) { - // @object PyObject_FromBG_FILE_PROGRESS|A tuple of 3 elements (bytesTotal, bytesTransfered, completed), (int, int, + // @object PyObject_FromBG_FILE_PROGRESS|A tuple of 3 elements (bytesTotal, bytesTransferred, completed), (int, int, // bool) return Py_BuildValue("NNO", PyLong_FromLongLong(fp->BytesTotal), PyLong_FromLongLong(fp->BytesTransferred), fp->Completed ? Py_True : Py_False); @@ -38,14 +38,14 @@ PyObject *PyObject_FromBG_FILE_PROGRESS(BG_FILE_PROGRESS *fp) PyObject *PyObject_FromBG_JOB_PROGRESS(BG_JOB_PROGRESS *jp) { - // @object PyObject_FromBG_JOB_PROGRESS|A tuple of 4 elements (bytesTotal, bytesTransfered, filesTotal, - // filesTransfered), all ints. + // @object PyObject_FromBG_JOB_PROGRESS|A tuple of 4 elements (bytesTotal, bytesTransferred, filesTotal, + // filesTransferred), all ints. return Py_BuildValue("NNkk", PyLong_FromLongLong(jp->BytesTotal), PyLong_FromLongLong(jp->BytesTransferred), jp->FilesTotal, jp->FilesTransferred); } PyObject *PyObject_FromBG_JOB_REPLY_PROGRESS(BG_JOB_REPLY_PROGRESS *jrs) { - // @object BG_JOB_REPLY_PROGRESS|A tuple of 2 elements (bytesTotal, bytesTransfered), both ints. + // @object BG_JOB_REPLY_PROGRESS|A tuple of 2 elements (bytesTotal, bytesTransferred), both ints. return Py_BuildValue("NN", PyLong_FromLongLong(jrs->BytesTotal), PyLong_FromLongLong(jrs->BytesTransferred)); } diff --git a/com/win32comext/shell/demos/servers/folder_view.py b/com/win32comext/shell/demos/servers/folder_view.py index f2d039a15..f00e383cc 100644 --- a/com/win32comext/shell/demos/servers/folder_view.py +++ b/com/win32comext/shell/demos/servers/folder_view.py @@ -529,7 +529,7 @@ def QueryContextMenu(self, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags): def InvokeCommand(self, ci): mask, hwnd, verb, params, dir, nShow, hotkey, hicon = ci - # this seems very convuluted, but it's what the sample does :) + # this seems very convoluted, but it's what the sample does :) for verb_name, verb_id, flag in folderViewImplContextMenuIDs: if isinstance(verb, int): matches = verb == verb_id diff --git a/com/win32comext/shell/src/PyIShellItem2.cpp b/com/win32comext/shell/src/PyIShellItem2.cpp index eb0c1cdcf..9637882cc 100644 --- a/com/win32comext/shell/src/PyIShellItem2.cpp +++ b/com/win32comext/shell/src/PyIShellItem2.cpp @@ -485,7 +485,7 @@ STDMETHODIMP PyGShellItem2::GetProperty( PyObject *result; /* ??? Something strange with the format: If passing only a single object, and it's a tuple, - and you don't explicitely add the parens, + and you don't explicitly add the parens, the tuple gets unpacked and passed as separate args ??? */ HRESULT hr = InvokeViaPolicy("GetProperty", &result, "(N)", PyObject_FromSHCOLUMNID(&key)); diff --git a/ruff.toml b/ruff.toml index 6d75257db..315a9d41f 100644 --- a/ruff.toml +++ b/ruff.toml @@ -45,7 +45,7 @@ extend-ignore = [ # Explicit re-exports is fine in __init__.py, still a code smell elsewhere. "__init__.py" = ["PLC0414"] # TODO: Make adodbapi changes in their own PRs -"adodbapi/*" = ["C4", "YTT301", "UP031", "UP032", "ISC002"] +"adodbapi/*" = ["C4", "YTT301", "UP031", "UP032"] [lint.isort] combine-as-imports = true diff --git a/win32/Demos/security/set_file_audit.py b/win32/Demos/security/set_file_audit.py index 324d72748..e46d05d77 100644 --- a/win32/Demos/security/set_file_audit.py +++ b/win32/Demos/security/set_file_audit.py @@ -59,7 +59,7 @@ win32con.GENERIC_ALL, my_sid, ) -## keep dir from inheriting any permissions so it only has ACEs explicitely set here +## keep dir from inheriting any permissions so it only has ACEs explicitly set here win32security.SetNamedSecurityInfo( dir_name, SE_FILE_OBJECT, diff --git a/win32/Lib/pywin32_testutil.py b/win32/Lib/pywin32_testutil.py index d9e517913..e2b1b8b3a 100644 --- a/win32/Lib/pywin32_testutil.py +++ b/win32/Lib/pywin32_testutil.py @@ -273,7 +273,7 @@ def _makeResult(self): return TestResult(self.stream, self.descriptions, self.verbosity) -# TestProgream subclass necessary just to get our TestRunner hooked up, +# TestProgram subclass necessary just to get our TestRunner hooked up, # which is necessary to get our TestResult hooked up *sob* class TestProgram(unittest.TestProgram): def runTests(self): @@ -282,7 +282,7 @@ def runTests(self): unittest.TestProgram.runTests(self) -# A convenient entry-point - if used, 'SKIPPED' exceptions will be supressed. +# A convenient entry-point - if used, 'SKIPPED' exceptions will be suppressed. def testmain(*args, **kw): new_kw = kw.copy() if "testLoader" not in new_kw: diff --git a/win32/Lib/win32cryptcon.py b/win32/Lib/win32cryptcon.py index 8d71996a0..92aac96eb 100644 --- a/win32/Lib/win32cryptcon.py +++ b/win32/Lib/win32cryptcon.py @@ -972,7 +972,7 @@ def GET_CMSG_ENCODING_TYPE(X): CMC_FAIL_BAD_REQUEST = 2 CMC_FAIL_BAD_TIME = 3 CMC_FAIL_BAD_CERT_ID = 4 -CMC_FAIL_UNSUPORTED_EXT = 5 +CMC_FAIL_UNSUPORTED_EXT = 5 # Yes Microsoft made a typo in "UNSUPPORTED" CMC_FAIL_MUST_ARCHIVE_KEYS = 6 CMC_FAIL_BAD_IDENTITY = 7 CMC_FAIL_POP_REQUIRED = 8 diff --git a/win32/Lib/win32pdhquery.py b/win32/Lib/win32pdhquery.py index 3e51b77b9..724a668a7 100644 --- a/win32/Lib/win32pdhquery.py +++ b/win32/Lib/win32pdhquery.py @@ -504,10 +504,10 @@ def collectdatafor(self, totalperiod, period=1): def collectdatawhile(self, period=1): """ Threaded collection of performance data: - This method sets up a simple semaphor system for signalling + This method sets up a simple semaphore system for signalling when you would like to start and stop a threaded data collection method. The collection runs every period seconds until the - semaphor attribute is set to a non-true value (which normally + semaphore attribute is set to a non-true value (which normally should be done by calling query.collectdatawhile_stop() .) e.g.: query.collectdatawhile(2) diff --git a/win32/Lib/win32timezone.py b/win32/Lib/win32timezone.py index fdd71c855..01aa08d79 100644 --- a/win32/Lib/win32timezone.py +++ b/win32/Lib/win32timezone.py @@ -463,7 +463,7 @@ def _locate_day(year, cutoff): """ # MS stores Sunday as 0, Python datetime stores Monday as zero target_weekday = (cutoff.day_of_week + 6) % 7 - # For SYSTEMTIMEs relating to time zone inforamtion, cutoff.day + # For SYSTEMTIMEs relating to time zone information, cutoff.day # is the week of the month week_of_month = cutoff.day # so the following is the first day of that week diff --git a/win32/scripts/regsetup.py b/win32/scripts/regsetup.py index fb33e11dd..ca44ed672 100644 --- a/win32/scripts/regsetup.py +++ b/win32/scripts/regsetup.py @@ -497,9 +497,9 @@ def RegisterShellInfo(searchPaths): # Using raw string so that all paths meant to be copied read correctly inline and when printed examples = r""" Examples: -"regsetup c:\wierd\spot\1 c:\wierd\spot\2" +"regsetup c:\weird\spot\1 c:\weird\spot\2" Attempts to setup the core Python. Looks in some standard places, -as well as the 2 wierd spots to locate the core Python files (eg, Python.exe, +as well as the 2 weird spots to locate the core Python files (eg, Python.exe, pythonXX.dll, the standard library and Win32 Extensions). "regsetup -a myappname . .\subdir" diff --git a/win32/src/PySECURITY_DESCRIPTOR.cpp b/win32/src/PySECURITY_DESCRIPTOR.cpp index 4ad9aa1d0..f21cfaae7 100644 --- a/win32/src/PySECURITY_DESCRIPTOR.cpp +++ b/win32/src/PySECURITY_DESCRIPTOR.cpp @@ -451,7 +451,7 @@ PyObject *PySECURITY_DESCRIPTOR::GetSecurityDescriptorOwner(PyObject *self, PyOb PyObject *PySECURITY_DESCRIPTOR::SetSecurityDescriptorOwner(PyObject *self, PyObject *args) { // @pyparm |sid||The sid to be set as owner in the security descriptor. - // @pyparm int|bOwnerDefaulted||Normally set to false since this explicitely set the owner. + // @pyparm int|bOwnerDefaulted||Normally set to false since this explicitly set the owner. BOOL bOwnerDefaulted; PySECURITY_DESCRIPTOR *This = (PySECURITY_DESCRIPTOR *)self; PSID NewOwnerSid = NULL; @@ -494,7 +494,7 @@ PyObject *PySECURITY_DESCRIPTOR::SetSecurityDescriptorOwner(PyObject *self, PyOb PyObject *PySECURITY_DESCRIPTOR::SetSecurityDescriptorGroup(PyObject *self, PyObject *args) { // @pyparm |sid||The group sid to be set in the security descriptor. - // @pyparm int|bOwnerDefaulted||Normally set to false since this explicitely set the owner. + // @pyparm int|bOwnerDefaulted||Normally set to false since this explicitly set the owner. BOOL bGroupDefaulted; PySECURITY_DESCRIPTOR *This = (PySECURITY_DESCRIPTOR *)self; PSECURITY_DESCRIPTOR psd = NULL; diff --git a/win32/src/PythonService.cpp b/win32/src/PythonService.cpp index 181c97b50..c6d8e1364 100644 --- a/win32/src/PythonService.cpp +++ b/win32/src/PythonService.cpp @@ -92,7 +92,7 @@ typedef struct { DWORD g_serviceProcessFlags = 0; // The global SCM dispatch table. A trailing NULL indicates to the SCM -// how many are used, so we allocate one extra for this sentinal +// how many are used, so we allocate one extra for this sentinel static SERVICE_TABLE_ENTRY DispatchTable[MAX_SERVICES + 1] = {{NULL, NULL}}; // A parallel array of Python information for the service. static PY_SERVICE_TABLE_ENTRY PythonServiceTable[MAX_SERVICES]; diff --git a/win32/src/win32file.i b/win32/src/win32file.i index 5b1b010d7..714aed513 100644 --- a/win32/src/win32file.i +++ b/win32/src/win32file.i @@ -2,7 +2,7 @@ // @doc %module win32file // An interface to the win32 File API's -// This module includes the tranactional NTFS operations introduced with +// This module includes the transactional NTFS operations introduced with // Vista. The transacted functions are not wrapped separately, but are invoked by // passing a transaction handle to the corresponding Unicode API function. // This makes it simple to convert a set of file operations into a transaction by @@ -1179,13 +1179,13 @@ static PyObject *myGetQueuedCompletionStatus(PyObject *self, PyObject *args) PyObject *myPostQueuedCompletionStatus(PyObject *self, PyObject *args) { PyObject *obHandle, *obOverlapped = NULL, *obkey=Py_None; - DWORD bytesTransfered = 0; + DWORD bytesTransferred = 0; ULONG_PTR key = 0; // @pyparm |handle||handle to an I/O completion port - // @pyparm int|numberOfbytes|0|value to return via GetQueuedCompletionStatus' first result + // @pyparm int|numberOfBytes|0|value to return via GetQueuedCompletionStatus' first result // @pyparm int|completionKey|0|value to return via GetQueuedCompletionStatus' second result // @pyparm |overlapped|None|value to return via GetQueuedCompletionStatus' third result - if (!PyArg_ParseTuple(args, "O|iOO", &obHandle, &bytesTransfered, &obkey, &obOverlapped)) + if (!PyArg_ParseTuple(args, "O|iOO", &obHandle, &bytesTransferred, &obkey, &obOverlapped)) return NULL; if (obkey!=Py_None) if (!PyWinLong_AsVoidPtr(obkey, (void **)&key)) @@ -1198,7 +1198,7 @@ PyObject *myPostQueuedCompletionStatus(PyObject *self, PyObject *args) return NULL; BOOL ok; Py_BEGIN_ALLOW_THREADS - ok = ::PostQueuedCompletionStatus(handle, bytesTransfered, key, pOverlapped); + ok = ::PostQueuedCompletionStatus(handle, bytesTransferred, key, pOverlapped); Py_END_ALLOW_THREADS if (!ok) return PyWin_SetAPIError("PostQueuedCompletionStatus"); @@ -4168,7 +4168,7 @@ py_ReplaceFile(PyObject *self, PyObject *args) void encryptedfilecontextdestructor(PyObject *obctxt){ if (!PyCapsule_IsValid(obctxt, NULL)) return; // should not happen, but maybe print a warning just in case ? - // Check if context has already been explicitely destroyed + // Check if context has already been explicitly destroyed // The capsule's context is set to this value in CloseEncryptedFileRaw if (PyCapsule_GetContext(obctxt) == INVALID_HANDLE_VALUE) return; From 29c198473334805afa664d6e12da9a0d67588592 Mon Sep 17 00:00:00 2001 From: Cristi Fati Date: Fri, 25 Oct 2024 04:17:28 +0300 Subject: [PATCH 06/16] Last error wrongly set by some modules (#2302) --- CHANGES.txt | 1 + win32/src/PyWinTypes.h | 2 + win32/src/PyWinTypesmodule.cpp | 17 +++++-- win32/src/win32apimodule.cpp | 24 +++------- win32/src/win32consolemodule.cpp | 4 +- win32/src/win32file.i | 25 ++++------ win32/src/win32gui.i | 66 ++++++++++++--------------- win32/src/win32inet.i | 2 +- win32/src/win32job.i | 10 ++-- win32/src/win32net/win32netmodule.cpp | 4 +- win32/src/win32pipe.i | 8 ++-- win32/src/win32process.i | 27 ++++------- win32/src/win32profilemodule.cpp | 5 +- win32/src/win32service.i | 9 ++-- win32/src/win32transactionmodule.cpp | 6 +-- win32/src/win32tsmodule.cpp | 12 ++--- 16 files changed, 92 insertions(+), 130 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d02c6fcae..c66d05f48 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,7 @@ https://mhammond.github.io/pywin32_installers.html. Coming in build 309, as yet unreleased -------------------------------------- +* Last error wrongly set by some modules (#2302, @CristiFati) * Dropped support for Python 3.7 (#2207, @Avasam) * Implement the creation of SAFEARRAY(VT_RECORD) from a sequence of COM Records (#2317, @geppi) * Implement record pointers as [in, out] method parameters of a Dispatch Interface (#2304, #2310, @geppi) diff --git a/win32/src/PyWinTypes.h b/win32/src/PyWinTypes.h index 620aada9c..cd0fe7bdb 100644 --- a/win32/src/PyWinTypes.h +++ b/win32/src/PyWinTypes.h @@ -83,6 +83,8 @@ typedef Py_ssize_t Py_hash_t; #endif // _MSC_VER #endif // BUILD_PYWINTYPES +extern PYWINTYPES_EXPORT HMODULE PyWin_GetOrLoadLibraryHandle(const char *name); + // Py3k uses memoryview object in place of buffer, and we don't yet. extern PYWINTYPES_EXPORT PyObject *PyBuffer_New(Py_ssize_t size); extern PYWINTYPES_EXPORT PyObject *PyBuffer_FromMemory(void *buf, Py_ssize_t size); diff --git a/win32/src/PyWinTypesmodule.cpp b/win32/src/PyWinTypesmodule.cpp index 1564f84d5..e095fdf93 100644 --- a/win32/src/PyWinTypesmodule.cpp +++ b/win32/src/PyWinTypesmodule.cpp @@ -26,6 +26,17 @@ extern PyObject *PyWinMethod_NewHKEY(PyObject *self, PyObject *args); extern BOOL _PyWinDateTime_Init(); extern BOOL _PyWinDateTime_PrepareModuleDict(PyObject *dict); +HMODULE PyWin_GetOrLoadLibraryHandle(const char *name) +{ + DWORD lastErr = GetLastError(); + HMODULE hmodule = GetModuleHandleA(name); + if (hmodule == NULL) + hmodule = LoadLibraryA(name); + if (hmodule != NULL) + SetLastError(lastErr); + return hmodule; +} + // XXX - Needs py3k modernization! // For py3k, a function that returns new memoryview object instead of buffer. // ??? Byte array object is mutable, maybe just use that directly as a substitute ??? @@ -970,10 +981,8 @@ extern "C" __declspec(dllexport) BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwR { FARPROC fp; // dll usually will already be loaded - HMODULE hmodule = GetModuleHandle(_T("AdvAPI32.dll")); - if (hmodule == NULL) - hmodule = LoadLibrary(_T("AdvAPI32.dll")); - if (hmodule) { + HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("advapi32.dll"); + if (hmodule != NULL) { fp = GetProcAddress(hmodule, "AddAccessAllowedAce"); if (fp) addaccessallowedace = (addacefunc)(fp); diff --git a/win32/src/win32apimodule.cpp b/win32/src/win32apimodule.cpp index 026816e69..45d8d532e 100644 --- a/win32/src/win32apimodule.cpp +++ b/win32/src/win32apimodule.cpp @@ -4772,14 +4772,12 @@ static PyObject *PySetSystemTime(PyObject *self, PyObject *args) )) return NULL; PyW32_BEGIN_ALLOW_THREADS result = ::SetSystemTime(&t); - PyW32_END_ALLOW_THREADS + PyW32_END_ALLOW_THREADS; - if (!result) - { + if (!result) { return ReturnAPIError("SetSystemTime"); } - else - { + else { return Py_BuildValue("i", result); } } @@ -6263,17 +6261,13 @@ PYWIN_MODULE_INIT_FUNC(win32api) PyModule_AddIntConstant(module, "VS_FF_PRIVATEBUILD", VS_FF_PRIVATEBUILD); PyModule_AddIntConstant(module, "VS_FF_SPECIALBUILD", VS_FF_SPECIALBUILD); - HMODULE hmodule = GetModuleHandle(TEXT("secur32.dll")); - if (hmodule == NULL) - hmodule = LoadLibrary(TEXT("secur32.dll")); + HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("secur32.dll"); if (hmodule != NULL) { pfnGetUserNameEx = (GetUserNameExfunc)GetProcAddress(hmodule, "GetUserNameExW"); pfnGetComputerObjectName = (GetUserNameExfunc)GetProcAddress(hmodule, "GetComputerObjectNameW"); } - hmodule = GetModuleHandle(TEXT("kernel32.dll")); - if (hmodule == NULL) - hmodule = LoadLibrary(TEXT("kernel32.dll")); + hmodule = PyWin_GetOrLoadLibraryHandle("kernel32.dll"); if (hmodule != NULL) { pfnGetComputerNameEx = (GetComputerNameExfunc)GetProcAddress(hmodule, "GetComputerNameExW"); pfnGetLongPathNameA = (GetLongPathNameAfunc)GetProcAddress(hmodule, "GetLongPathNameA"); @@ -6289,9 +6283,7 @@ PYWIN_MODULE_INIT_FUNC(win32api) pfnGetNativeSystemInfo = (GetNativeSystemInfofunc)GetProcAddress(hmodule, "GetNativeSystemInfo"); } - hmodule = GetModuleHandle(TEXT("user32.dll")); - if (hmodule == NULL) - hmodule = LoadLibrary(TEXT("user32.dll")); + hmodule = PyWin_GetOrLoadLibraryHandle("user32.dll"); if (hmodule != NULL) { pfnEnumDisplayMonitors = (EnumDisplayMonitorsfunc)GetProcAddress(hmodule, "EnumDisplayMonitors"); pfnEnumDisplayDevices = (EnumDisplayDevicesfunc)GetProcAddress(hmodule, "EnumDisplayDevicesW"); @@ -6304,9 +6296,7 @@ PYWIN_MODULE_INIT_FUNC(win32api) pfnGetLastInputInfo = (GetLastInputInfofunc)GetProcAddress(hmodule, "GetLastInputInfo"); } - hmodule = GetModuleHandle(TEXT("Advapi32.dll")); - if (hmodule == NULL) - hmodule = LoadLibrary(TEXT("Advapi32.dll")); + hmodule = PyWin_GetOrLoadLibraryHandle("advapi32.dll"); if (hmodule != NULL) { pfnRegRestoreKey = (RegRestoreKeyfunc)GetProcAddress(hmodule, "RegRestoreKeyW"); pfnRegSaveKeyEx = (RegSaveKeyExfunc)GetProcAddress(hmodule, "RegSaveKeyExW"); diff --git a/win32/src/win32consolemodule.cpp b/win32/src/win32consolemodule.cpp index daae981cf..48e84d727 100644 --- a/win32/src/win32consolemodule.cpp +++ b/win32/src/win32consolemodule.cpp @@ -2079,9 +2079,7 @@ PYWIN_MODULE_INIT_FUNC(win32console) PyDict_SetItemString(dict, "error", PyWinExc_ApiError); // load function pointers - kernel32_dll = GetModuleHandle(L"kernel32.dll"); - if (kernel32_dll == NULL) - kernel32_dll = LoadLibrary(L"kernel32.dll"); + kernel32_dll = PyWin_GetOrLoadLibraryHandle("kernel32.dll"); if (kernel32_dll != NULL) { pfnGetConsoleProcessList = (GetConsoleProcessListfunc)GetProcAddress(kernel32_dll, "GetConsoleProcessList"); pfnGetConsoleDisplayMode = (GetConsoleDisplayModefunc)GetProcAddress(kernel32_dll, "GetConsoleDisplayMode"); diff --git a/win32/src/win32file.i b/win32/src/win32file.i index 714aed513..716b76262 100644 --- a/win32/src/win32file.i +++ b/win32/src/win32file.i @@ -5932,11 +5932,8 @@ PyCFunction pfnpy_OpenFileById=(PyCFunction)py_OpenFileById; ) pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; - HMODULE hmodule; - hmodule=GetModuleHandle(TEXT("AdvAPI32.dll")); - if (hmodule==NULL) - hmodule=LoadLibrary(TEXT("AdvAPI32.dll")); - if (hmodule){ + HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("advapi32.dll"); + if (hmodule != NULL) { pfnEncryptFile=(EncryptFilefunc)GetProcAddress(hmodule, "EncryptFileW"); pfnDecryptFile=(DecryptFilefunc)GetProcAddress(hmodule, "DecryptFileW"); pfnEncryptionDisable=(EncryptionDisablefunc)GetProcAddress(hmodule, "EncryptionDisable"); @@ -5952,12 +5949,10 @@ PyCFunction pfnpy_OpenFileById=(PyCFunction)py_OpenFileById; pfnReadEncryptedFileRaw=(ReadEncryptedFileRawfunc)GetProcAddress(hmodule, "ReadEncryptedFileRaw"); pfnWriteEncryptedFileRaw=(WriteEncryptedFileRawfunc)GetProcAddress(hmodule, "WriteEncryptedFileRaw"); pfnCloseEncryptedFileRaw=(CloseEncryptedFileRawfunc)GetProcAddress(hmodule, "CloseEncryptedFileRaw"); - } + } - hmodule=GetModuleHandle(TEXT("kernel32.dll")); - if (hmodule==NULL) - hmodule=LoadLibrary(TEXT("kernel32.dll")); - if (hmodule){ + hmodule = PyWin_GetOrLoadLibraryHandle("kernel32.dll"); + if (hmodule != NULL) { pfnSetVolumeMountPoint=(SetVolumeMountPointfunc)GetProcAddress(hmodule, "SetVolumeMountPointW"); pfnDeleteVolumeMountPoint=(DeleteVolumeMountPointfunc)GetProcAddress(hmodule, "DeleteVolumeMountPointW"); pfnGetVolumeNameForVolumeMountPoint=(GetVolumeNameForVolumeMountPointfunc)GetProcAddress(hmodule, "GetVolumeNameForVolumeMountPointW"); @@ -6002,15 +5997,13 @@ PyCFunction pfnpy_OpenFileById=(PyCFunction)py_OpenFileById; pfnWow64RevertWow64FsRedirection=(Wow64RevertWow64FsRedirectionfunc)GetProcAddress(hmodule, "Wow64RevertWow64FsRedirection"); pfnReOpenFile=(ReOpenFilefunc)GetProcAddress(hmodule, "ReOpenFile"); pfnOpenFileById=(OpenFileByIdfunc)GetProcAddress(hmodule, "OpenFileById"); - } + } - hmodule=GetModuleHandle(TEXT("sfc.dll")); - if (hmodule==NULL) - hmodule=LoadLibrary(TEXT("sfc.dll")); - if (hmodule){ + hmodule = PyWin_GetOrLoadLibraryHandle("sfc.dll"); + if (hmodule != NULL) { pfnSfcGetNextProtectedFile=(SfcGetNextProtectedFilefunc)GetProcAddress(hmodule, "SfcGetNextProtectedFile"); pfnSfcIsFileProtected=(SfcIsFileProtectedfunc)GetProcAddress(hmodule, "SfcIsFileProtected"); - } + } %} diff --git a/win32/src/win32gui.i b/win32/src/win32gui.i index 518e84cf9..fa0906b7e 100644 --- a/win32/src/win32gui.i +++ b/win32/src/win32gui.i @@ -266,42 +266,36 @@ for (PyMethodDef *pmd = win32guiMethods; pmd->ml_name; pmd++) ) pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; -HMODULE hmodule=GetModuleHandle(TEXT("user32.dll")); -if (hmodule==NULL) - hmodule=LoadLibrary(TEXT("user32.dll")); -if (hmodule){ - pfnSetLayeredWindowAttributes=(SetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"SetLayeredWindowAttributes"); - pfnGetLayeredWindowAttributes=(GetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"GetLayeredWindowAttributes"); - pfnUpdateLayeredWindow=(UpdateLayeredWindowfunc)GetProcAddress(hmodule,"UpdateLayeredWindow"); - pfnAnimateWindow=(AnimateWindowfunc)GetProcAddress(hmodule,"AnimateWindow"); - pfnGetMenuInfo=(GetMenuInfofunc)GetProcAddress(hmodule,"GetMenuInfo"); - pfnSetMenuInfo=(SetMenuInfofunc)GetProcAddress(hmodule,"SetMenuInfo"); - pfnDrawTextW=(DrawTextWfunc)GetProcAddress(hmodule, "DrawTextW"); - } - -hmodule=GetModuleHandle(TEXT("gdi32.dll")); -if (hmodule==NULL) - hmodule=LoadLibrary(TEXT("gdi32.dll")); -if (hmodule){ - pfnAngleArc=(AngleArcfunc)GetProcAddress(hmodule,"AngleArc"); - pfnPlgBlt=(PlgBltfunc)GetProcAddress(hmodule,"PlgBlt"); - pfnGetWorldTransform=(GetWorldTransformfunc)GetProcAddress(hmodule,"GetWorldTransform"); - pfnSetWorldTransform=(SetWorldTransformfunc)GetProcAddress(hmodule,"SetWorldTransform"); - pfnModifyWorldTransform=(ModifyWorldTransformfunc)GetProcAddress(hmodule,"ModifyWorldTransform"); - pfnCombineTransform=(CombineTransformfunc)GetProcAddress(hmodule,"CombineTransform"); - pfnMaskBlt=(MaskBltfunc)GetProcAddress(hmodule,"MaskBlt"); - pfnGetLayout=(GetLayoutfunc)GetProcAddress(hmodule,"GetLayout"); - pfnSetLayout=(SetLayoutfunc)GetProcAddress(hmodule,"SetLayout"); - } - -hmodule=GetModuleHandle(TEXT("msimg32.dll")); -if (hmodule==NULL) - hmodule=LoadLibrary(TEXT("msimg32.dll")); -if (hmodule){ - pfnGradientFill=(GradientFillfunc)GetProcAddress(hmodule,"GradientFill"); - pfnTransparentBlt=(TransparentBltfunc)GetProcAddress(hmodule,"TransparentBlt"); - pfnAlphaBlend=(AlphaBlendfunc)GetProcAddress(hmodule,"AlphaBlend"); - } +HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("user32.dll"); +if (hmodule != NULL) { + pfnSetLayeredWindowAttributes = (SetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"SetLayeredWindowAttributes"); + pfnGetLayeredWindowAttributes = (GetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"GetLayeredWindowAttributes"); + pfnUpdateLayeredWindow = (UpdateLayeredWindowfunc)GetProcAddress(hmodule,"UpdateLayeredWindow"); + pfnAnimateWindow = (AnimateWindowfunc)GetProcAddress(hmodule,"AnimateWindow"); + pfnGetMenuInfo = (GetMenuInfofunc)GetProcAddress(hmodule,"GetMenuInfo"); + pfnSetMenuInfo = (SetMenuInfofunc)GetProcAddress(hmodule,"SetMenuInfo"); + pfnDrawTextW = (DrawTextWfunc)GetProcAddress(hmodule, "DrawTextW"); +} + +hmodule = PyWin_GetOrLoadLibraryHandle("gdi32.dll"); +if (hmodule != NULL) { + pfnAngleArc = (AngleArcfunc)GetProcAddress(hmodule,"AngleArc"); + pfnPlgBlt = (PlgBltfunc)GetProcAddress(hmodule,"PlgBlt"); + pfnGetWorldTransform = (GetWorldTransformfunc)GetProcAddress(hmodule,"GetWorldTransform"); + pfnSetWorldTransform = (SetWorldTransformfunc)GetProcAddress(hmodule,"SetWorldTransform"); + pfnModifyWorldTransform = (ModifyWorldTransformfunc)GetProcAddress(hmodule,"ModifyWorldTransform"); + pfnCombineTransform = (CombineTransformfunc)GetProcAddress(hmodule,"CombineTransform"); + pfnMaskBlt = (MaskBltfunc)GetProcAddress(hmodule,"MaskBlt"); + pfnGetLayout = (GetLayoutfunc)GetProcAddress(hmodule,"GetLayout"); + pfnSetLayout = (SetLayoutfunc)GetProcAddress(hmodule,"SetLayout"); +} + +hmodule = PyWin_GetOrLoadLibraryHandle("msimg32.dll"); +if (hmodule != NULL) { + pfnGradientFill = (GradientFillfunc)GetProcAddress(hmodule,"GradientFill"); + pfnTransparentBlt = (TransparentBltfunc)GetProcAddress(hmodule,"TransparentBlt"); + pfnAlphaBlend = (AlphaBlendfunc)GetProcAddress(hmodule,"AlphaBlend"); +} %} %{ diff --git a/win32/src/win32inet.i b/win32/src/win32inet.i index 33d5afa51..e9edf6c52 100644 --- a/win32/src/win32inet.i +++ b/win32/src/win32inet.i @@ -1941,7 +1941,7 @@ extern PyObject *PyWinHttpOpen(PyObject *, PyObject *); %init %{ PyDict_SetItemString(d, "error", PyWinExc_ApiError); - HMODULE hmod = GetModuleHandle(TEXT("wininet.dll")); + HMODULE hmod = PyWin_GetOrLoadLibraryHandle("wininet.dll"); assert(hmod); PyWin_RegisterErrorMessageModule(INTERNET_ERROR_BASE, INTERNET_ERROR_LAST, diff --git a/win32/src/win32job.i b/win32/src/win32job.i index 1b3af02e2..ccf0faf38 100644 --- a/win32/src/win32job.i +++ b/win32/src/win32job.i @@ -20,12 +20,10 @@ static IsProcessInJobfunc pfnIsProcessInJob=NULL; %init %{ -HMODULE hmodule=GetModuleHandle(L"kernel32.dll"); -if (hmodule==NULL) - hmodule=LoadLibrary(L"kernel32.dll"); -if (hmodule){ - pfnIsProcessInJob=(IsProcessInJobfunc)GetProcAddress(hmodule,"IsProcessInJob"); - } +HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("kernel32.dll"); +if (hmodule != NULL) { + pfnIsProcessInJob = (IsProcessInJobfunc)GetProcAddress(hmodule, "IsProcessInJob"); +} %} diff --git a/win32/src/win32net/win32netmodule.cpp b/win32/src/win32net/win32netmodule.cpp index 1698bfb6f..e4b7ba108 100644 --- a/win32/src/win32net/win32netmodule.cpp +++ b/win32/src/win32net/win32netmodule.cpp @@ -1211,10 +1211,8 @@ PYWIN_MODULE_INIT_FUNC(win32net) AddConstant(dict, "USE_FORCE", USE_FORCE); AddConstant(dict, "USE_LOTS_OF_FORCE", USE_LOTS_OF_FORCE); - HMODULE hmodule = GetModuleHandle(_T("netapi32")); + HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("netapi32.dll"); #if WINVER >= 0x0500 - if (hmodule == NULL) - hmodule = LoadLibrary(_T("netapi32")); if (hmodule != NULL) { pfnNetValidateName = (NetValidateNamefunc)GetProcAddress(hmodule, "NetValidateName"); pfnNetGetJoinInformation = (NetGetJoinInformationfunc)GetProcAddress(hmodule, "NetGetJoinInformation"); diff --git a/win32/src/win32pipe.i b/win32/src/win32pipe.i index 5311900c4..f29125c7c 100644 --- a/win32/src/win32pipe.i +++ b/win32/src/win32pipe.i @@ -25,15 +25,13 @@ static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeServerSessionId = NULL; // All errors raised by this module are of this type. PyDict_SetItemString(d, "error", PyWinExc_ApiError); - HMODULE hmod=GetModuleHandle(_T("Kernel32.dll")); - if (!hmod) - hmod=LoadLibrary(_T("Kernel32.dll")); - if (hmod){ + HMODULE hmod = PyWin_GetOrLoadLibraryHandle("kernel32.dll"); + if (hmod != NULL) { pfnGetNamedPipeClientProcessId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeClientProcessId"); pfnGetNamedPipeServerProcessId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeServerProcessId"); pfnGetNamedPipeClientSessionId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeClientSessionId"); pfnGetNamedPipeServerSessionId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeServerSessionId"); - } + } %} %{ diff --git a/win32/src/win32process.i b/win32/src/win32process.i index 331ed0f23..c938f4566 100644 --- a/win32/src/win32process.i +++ b/win32/src/win32process.i @@ -1686,23 +1686,18 @@ PyObject *PyWriteProcessMemory(PyObject *self, PyObject *args) if (PyType_Ready(&PySTARTUPINFOType) == -1) return NULL; - FARPROC fp=NULL; - HMODULE hmodule=NULL; - hmodule=GetModuleHandle(_T("Psapi.dll")); - if (hmodule==NULL) - hmodule=LoadLibrary(_T("Psapi.dll")); - if (hmodule!=NULL){ + FARPROC fp = NULL; + HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("psapi.dll"); + if (hmodule != NULL) { pfnEnumProcesses = (EnumProcessesfunc)GetProcAddress(hmodule, "EnumProcesses"); pfnEnumProcessModules = (EnumProcessModulesfunc)GetProcAddress(hmodule, "EnumProcessModules"); pfnEnumProcessModulesEx = (EnumProcessModulesExfunc)GetProcAddress(hmodule, "EnumProcessModulesEx"); pfnGetModuleFileNameEx = (GetModuleFileNameExfunc)GetProcAddress(hmodule, "GetModuleFileNameExW"); pfnGetProcessMemoryInfo = (GetProcessMemoryInfofunc)GetProcAddress(hmodule, "GetProcessMemoryInfo"); - } + } - hmodule=GetModuleHandle(_T("Kernel32.dll")); - if (hmodule==NULL) - hmodule=LoadLibrary(_T("Kernel32.dll")); - if (hmodule!=NULL){ + hmodule = PyWin_GetOrLoadLibraryHandle("kernel32.dll"); + if (hmodule != NULL) { pfnGetProcessTimes=(GetProcessTimesfunc)GetProcAddress(hmodule,"GetProcessTimes"); pfnGetProcessIoCounters=(GetProcessIoCountersfunc)GetProcAddress(hmodule,"GetProcessIoCounters"); pfnGetProcessShutdownParameters=(GetProcessShutdownParametersfunc)GetProcAddress(hmodule,"GetProcessShutdownParameters"); @@ -1720,15 +1715,13 @@ PyObject *PyWriteProcessMemory(PyObject *self, PyObject *args) pfnSetProcessAffinityMask=(SetProcessAffinityMaskfunc)GetProcAddress(hmodule,"SetProcessAffinityMask"); pfnGetProcessId=(GetProcessIdfunc)GetProcAddress(hmodule, "GetProcessId"); pfnIsWow64Process=(IsWow64Processfunc)GetProcAddress(hmodule, "IsWow64Process"); - } + } - hmodule=GetModuleHandle(_T("User32.dll")); - if (hmodule==NULL) - hmodule=LoadLibrary(_T("User32.dll")); - if (hmodule!=NULL){ + hmodule = PyWin_GetOrLoadLibraryHandle("user32.dll"); + if (hmodule != NULL) { pfnGetProcessWindowStation=(GetProcessWindowStationfunc)GetProcAddress(hmodule,"GetProcessWindowStation"); pfnGetGuiResources=(GetGuiResourcesfunc)GetProcAddress(hmodule,"GetGuiResources"); - } + } // *sob* - these symbols don't exist in the platform sdk needed to build // using Python 2.3 diff --git a/win32/src/win32profilemodule.cpp b/win32/src/win32profilemodule.cpp index 17299f00b..98c4fac72 100644 --- a/win32/src/win32profilemodule.cpp +++ b/win32/src/win32profilemodule.cpp @@ -489,10 +489,7 @@ PYWIN_MODULE_INIT_FUNC(win32profile) PyModule_AddIntConstant(module, "PT_ROAMING", PT_ROAMING); PyModule_AddIntConstant(module, "PT_TEMPORARY", PT_TEMPORARY); - HMODULE hmodule; - hmodule = GetModuleHandle(L"Userenv.dll"); - if (hmodule == NULL) - hmodule = LoadLibrary(L"Userenv.dll"); + HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("userenv.dll"); if (hmodule != NULL) { pfnDeleteProfile = (DeleteProfilefunc)GetProcAddress(hmodule, "DeleteProfileW"); pfnExpandEnvironmentStringsForUser = diff --git a/win32/src/win32service.i b/win32/src/win32service.i index 1150dff74..b91a0e16b 100644 --- a/win32/src/win32service.i +++ b/win32/src/win32service.i @@ -36,12 +36,9 @@ EnumServicesStatusExfunc fpEnumServicesStatusEx=NULL; PyDict_SetItemString(d, "error", PyWinExc_ApiError); PyDict_SetItemString(d, "HWINSTAType", (PyObject *)&PyHWINSTAType); PyDict_SetItemString(d, "HDESKType", (PyObject *)&PyHDESKType); - HMODULE hmod; FARPROC fp; - hmod=GetModuleHandle(_T("Advapi32")); - if (hmod==NULL) - hmod=LoadLibrary(_T("Advapi32")); - if (hmod!=NULL){ + HMODULE hmod = PyWin_GetOrLoadLibraryHandle("advapi32.dll"); + if (hmod != NULL) { fp=GetProcAddress(hmod,"QueryServiceStatusEx"); if (fp!=NULL) fpQueryServiceStatusEx=(QueryServiceStatusExfunc)fp; @@ -54,7 +51,7 @@ EnumServicesStatusExfunc fpEnumServicesStatusEx=NULL; fp=GetProcAddress(hmod,"EnumServicesStatusExW"); if (fp!=NULL) fpEnumServicesStatusEx=(EnumServicesStatusExfunc)fp; - } + } %} %{ diff --git a/win32/src/win32transactionmodule.cpp b/win32/src/win32transactionmodule.cpp index 27c62d606..df39f67a1 100644 --- a/win32/src/win32transactionmodule.cpp +++ b/win32/src/win32transactionmodule.cpp @@ -235,10 +235,8 @@ PYWIN_MODULE_INIT_FUNC(win32transaction) " transacted NTFS and transacted registry functions."); // Load dll and function pointers to avoid dependency on newer libraries and headers - HMODULE hmodule = GetModuleHandle(L"Ktmw32.dll"); - if (hmodule == NULL) - hmodule = LoadLibrary(L"Ktmw32.dll"); - if (hmodule) { + HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("ktmw32.dll"); + if (hmodule != NULL) { pfnCreateTransaction = (CreateTransactionfunc)GetProcAddress(hmodule, "CreateTransaction"); pfnRollbackTransaction = (RollbackTransactionfunc)GetProcAddress(hmodule, "RollbackTransaction"); pfnRollbackTransactionAsync = (RollbackTransactionAsyncfunc)GetProcAddress(hmodule, "RollbackTransactionAsync"); diff --git a/win32/src/win32tsmodule.cpp b/win32/src/win32tsmodule.cpp index ddd383dee..ac18c03dc 100644 --- a/win32/src/win32tsmodule.cpp +++ b/win32/src/win32tsmodule.cpp @@ -836,10 +836,8 @@ PYWIN_MODULE_INIT_FUNC(win32ts) PyModule_AddIntConstant(module, "NOTIFY_FOR_THIS_SESSION", NOTIFY_FOR_THIS_SESSION); PyModule_AddIntConstant(module, "NOTIFY_FOR_ALL_SESSIONS", NOTIFY_FOR_ALL_SESSIONS); - HMODULE h = GetModuleHandle(L"wtsapi32.dll"); - if (h == NULL) - h = LoadLibrary(L"wtsapi32.dll"); - if (h) { + HMODULE h = PyWin_GetOrLoadLibraryHandle("wtsapi32.dll"); + if (h != NULL) { pfnWTSQueryUserToken = (WTSQueryUserTokenfunc)GetProcAddress(h, "WTSQueryUserToken"); pfnWTSRegisterSessionNotification = (WTSRegisterSessionNotificationfunc)GetProcAddress(h, "WTSRegisterSessionNotification"); @@ -847,10 +845,8 @@ PYWIN_MODULE_INIT_FUNC(win32ts) (WTSUnRegisterSessionNotificationfunc)GetProcAddress(h, "WTSUnRegisterSessionNotification"); } - h = GetModuleHandle(L"kernel32.dll"); - if (h == NULL) - h = LoadLibrary(L"kernel32.dll"); - if (h) { + h = PyWin_GetOrLoadLibraryHandle("kernel32.dll"); + if (h != NULL) { pfnProcessIdToSessionId = (ProcessIdToSessionIdfunc)GetProcAddress(h, "ProcessIdToSessionId"); pfnWTSGetActiveConsoleSessionId = (WTSGetActiveConsoleSessionIdfunc)GetProcAddress(h, "WTSGetActiveConsoleSessionId"); From 30e3a753f5f23e8858b67c337edf7b67ba38aadc Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 24 Oct 2024 21:36:02 -0400 Subject: [PATCH 07/16] Fixed Pythonwin's editor failing due to invalid regex import (#2419) --- .github/workflows/main.yml | 4 ++-- CHANGES.txt | 1 + Pythonwin/pywin/framework/editor/editor.py | 10 +++++----- Pythonwin/pywin/framework/mdi_pychecker.py | 3 +-- Pythonwin/pywin/framework/sgrepmdi.py | 2 -- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index db40b4254..88e5ae6ca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -143,7 +143,7 @@ jobs: cache: pip cache-dependency-path: .github/workflows/main.yml check-latest: true - - run: pip install types-regex types-setuptools PyOpenGL mypy==1.11 + - run: pip install types-setuptools PyOpenGL mypy==1.11 - run: mypy . --python-version=${{ matrix.python-version }} pyright: @@ -162,7 +162,7 @@ jobs: cache-dependency-path: .github/workflows/main.yml check-latest: true # pyright vendors typeshed, but let's make sure we have the most up to date stubs - - run: pip install types-regex types-setuptools PyOpenGL + - run: pip install types-setuptools PyOpenGL - uses: jakebailey/pyright-action@v2 with: python-version: ${{ matrix.python-version }} diff --git a/CHANGES.txt b/CHANGES.txt index c66d05f48..83ca2052e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,7 @@ https://mhammond.github.io/pywin32_installers.html. Coming in build 309, as yet unreleased -------------------------------------- +* Fixed Pythonwin's editor failing due to invalid regex import (#2419, @Avasam) * Last error wrongly set by some modules (#2302, @CristiFati) * Dropped support for Python 3.7 (#2207, @Avasam) * Implement the creation of SAFEARRAY(VT_RECORD) from a sequence of COM Records (#2317, @geppi) diff --git a/Pythonwin/pywin/framework/editor/editor.py b/Pythonwin/pywin/framework/editor/editor.py index 1095cbe97..a83f20312 100644 --- a/Pythonwin/pywin/framework/editor/editor.py +++ b/Pythonwin/pywin/framework/editor/editor.py @@ -19,7 +19,6 @@ import re -import regex import win32api import win32con import win32ui @@ -36,8 +35,8 @@ # from pywin.mfc.docview import EditView as ParentEditorView # from pywin.mfc.docview import Document as ParentEditorDocument -patImport = regex.symcomp(r"import \(.*\)") -patIndent = regex.compile(r"^\([ \t]*[~ \t]\)") +patImport = re.compile(r"import (?P.*)") +patIndent = re.compile(r"^([ \t]*[~ \t])") ID_LOCATE_FILE = 0xE200 ID_GOTO_LINE = 0xE2001 @@ -364,9 +363,10 @@ def OnRClick(self, params): # look for a module name line = self._obj_.GetLine().strip() flags = win32con.MF_STRING | win32con.MF_ENABLED - if patImport.match(line) == len(line): + matchResult = patImport.match(line) + if matchResult and matchResult[0] == line: menu.AppendMenu( - flags, ID_LOCATE_FILE, "&Locate %s.py" % patImport.group("name") + flags, ID_LOCATE_FILE, "&Locate %s.py" % matchResult.group("name") ) menu.AppendMenu(win32con.MF_SEPARATOR) menu.AppendMenu(flags, win32ui.ID_EDIT_UNDO, "&Undo") diff --git a/Pythonwin/pywin/framework/mdi_pychecker.py b/Pythonwin/pywin/framework/mdi_pychecker.py index cd31a9a18..3108c2e81 100644 --- a/Pythonwin/pywin/framework/mdi_pychecker.py +++ b/Pythonwin/pywin/framework/mdi_pychecker.py @@ -145,8 +145,7 @@ def __radd__(self, other): # Group(1) is the filename, group(2) is the lineno. -# regexGrepResult=regex.compile(r"^\([a-zA-Z]:.*\)(\([0-9]+\))") -# regexGrep=re.compile(r"^([a-zA-Z]:[^(]*)\((\d+)\)") +# regexGrep = re.compile(r"^([a-zA-Z]:[^(]*)\((\d+)\)") regexGrep = re.compile(r"^(..[^\(:]+)?[\(:](\d+)[\):]:?\s*(.*)") # these are the atom numbers defined by Windows for basic dialog controls diff --git a/Pythonwin/pywin/framework/sgrepmdi.py b/Pythonwin/pywin/framework/sgrepmdi.py index f318f731f..0016cc854 100644 --- a/Pythonwin/pywin/framework/sgrepmdi.py +++ b/Pythonwin/pywin/framework/sgrepmdi.py @@ -127,8 +127,6 @@ def __radd__(self, other): # Group(1) is the filename, group(2) is the lineno. -# regexGrepResult=regex.compile(r"^\([a-zA-Z]:.*\)(\([0-9]+\))") - regexGrep = re.compile(r"^([a-zA-Z]:[^(]*)\(([0-9]+)\)") # these are the atom numbers defined by Windows for basic dialog controls From d2b2ae5e449a726442e6ca6f18b70adc17effce1 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 26 Oct 2024 15:11:28 -0400 Subject: [PATCH 08/16] Show something useful from `EvtSubscribe_push` demo (#2281) --- CHANGES.txt | 1 + win32/Demos/EvtSubscribe_push.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 83ca2052e..4c153f64a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,7 @@ https://mhammond.github.io/pywin32_installers.html. Coming in build 309, as yet unreleased -------------------------------------- +* The `EvtSubscribe_push` demo now actually demonstrates the callback action and the event context being filled. (#2281, @Avasam) * Fixed Pythonwin's editor failing due to invalid regex import (#2419, @Avasam) * Last error wrongly set by some modules (#2302, @CristiFati) * Dropped support for Python 3.7 (#2207, @Avasam) diff --git a/win32/Demos/EvtSubscribe_push.py b/win32/Demos/EvtSubscribe_push.py index 519ef0d72..fa4feb729 100644 --- a/win32/Demos/EvtSubscribe_push.py +++ b/win32/Demos/EvtSubscribe_push.py @@ -1,4 +1,8 @@ ## Demonstrates a "push" subscription with a callback function +from __future__ import annotations + +from time import sleep + import win32evtlog query_text = '*[System[Provider[@Name="Microsoft-Windows-Winlogon"]]]' @@ -15,7 +19,7 @@ def c(reason, context, evt): return 0 -evttext = [] +evttext: list[str] = [] s = win32evtlog.EvtSubscribe( "System", win32evtlog.EvtSubscribeStartAtOldestRecord, @@ -23,3 +27,6 @@ def c(reason, context, evt): Callback=c, Context=evttext, ) + +sleep(0.001) +print("\n".join(evttext)) From 14df8958df1c20bc4bdb7eb670b89262ae0bd23d Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 26 Oct 2024 15:18:30 -0400 Subject: [PATCH 09/16] Fix `ddeclient` and `ddeserver` demos import error (#2290) --- CHANGES.txt | 1 + win32/Demos/dde/ddeclient.py | 2 +- win32/Demos/dde/ddeserver.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 4c153f64a..1ff2bf9f2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,7 @@ https://mhammond.github.io/pywin32_installers.html. Coming in build 309, as yet unreleased -------------------------------------- +* Fixed `ddeclient` and `ddeserver` demos import error (#2290, @Avasam) * The `EvtSubscribe_push` demo now actually demonstrates the callback action and the event context being filled. (#2281, @Avasam) * Fixed Pythonwin's editor failing due to invalid regex import (#2419, @Avasam) * Last error wrongly set by some modules (#2302, @CristiFati) diff --git a/win32/Demos/dde/ddeclient.py b/win32/Demos/dde/ddeclient.py index f140e2438..6e63c4d6f 100644 --- a/win32/Demos/dde/ddeclient.py +++ b/win32/Demos/dde/ddeclient.py @@ -1,7 +1,7 @@ # 'Request' example added jjk 11/20/98 +import win32ui # isort: skip # Must be imported before dde ! import dde -import win32ui server = dde.CreateServer() server.Create("TestClient") diff --git a/win32/Demos/dde/ddeserver.py b/win32/Demos/dde/ddeserver.py index 0374827f0..57924aba6 100644 --- a/win32/Demos/dde/ddeserver.py +++ b/win32/Demos/dde/ddeserver.py @@ -1,7 +1,7 @@ # 'Request' example added jjk 11/20/98 +import win32ui # isort: skip # Must be imported before dde ! import dde -import win32ui from pywin.mfc import object From 2bb35f5dca914f1048b862e379995c4252e8adbc Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 11 Nov 2024 12:10:25 -0500 Subject: [PATCH 10/16] Avoid exception raising hacks by using Python 3 methods (#2350) --- com/win32com/test/GenTestScripts.py | 6 ++---- com/win32comext/axdebug/util.py | 8 ++------ com/win32comext/axscript/client/debug.py | 7 +------ win32/test/handles.py | 18 +++++++++++++----- win32/test/test_win32api.py | 10 +++++++--- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/com/win32com/test/GenTestScripts.py b/com/win32com/test/GenTestScripts.py index 079f6a984..8b09df077 100644 --- a/com/win32com/test/GenTestScripts.py +++ b/com/win32com/test/GenTestScripts.py @@ -3,6 +3,7 @@ # import os import sys +import traceback import pythoncom import win32com @@ -60,10 +61,7 @@ def GenerateAll(): def CleanAll(): print("Cleaning generated test scripts...") - try: # Clear exceptions! - 1 / 0 - except: - pass + traceback.clear_frames(sys.exc_info()[2]) # Clear exceptions! genPath = GetGenPath() for args in genList: try: diff --git a/com/win32comext/axdebug/util.py b/com/win32comext/axdebug/util.py index 424c529df..a9796a485 100644 --- a/com/win32comext/axdebug/util.py +++ b/com/win32comext/axdebug/util.py @@ -3,6 +3,7 @@ import os import sys +import traceback import win32api import win32com.server.dispatcher @@ -43,13 +44,8 @@ def RaiseNotImpl(who=None): print(f"********* Function {who} Raising E_NOTIMPL ************") # Print a sort-of "traceback", dumping all the frames leading to here. - try: - 1 / 0 - except: - frame = sys.exc_info()[2].tb_frame - while frame: + for frame, i in traceback.walk_stack(sys._getframe()): print(f"File: {frame.f_code.co_filename}, Line: {frame.f_lineno}") - frame = frame.f_back # and raise the exception for COM raise COMException(scode=winerror.E_NOTIMPL) diff --git a/com/win32comext/axscript/client/debug.py b/com/win32comext/axscript/client/debug.py index 352b86453..bf7ef960a 100644 --- a/com/win32comext/axscript/client/debug.py +++ b/com/win32comext/axscript/client/debug.py @@ -125,12 +125,7 @@ def _query_interface_for_debugger_(self, iid): def OnEnterScript(self): trace("OnEnterScript") - try: - 1 / 0 - except: - # Bit of a hack - reach into engine. - baseFrame = sys.exc_info()[2].tb_frame.f_back - self.adb.SetupAXDebugging(baseFrame) + self.adb.SetupAXDebugging(sys._getframe().f_back) def OnLeaveScript(self): trace("OnLeaveScript") diff --git a/win32/test/handles.py b/win32/test/handles.py index 01b7f17ef..9e4f63358 100644 --- a/win32/test/handles.py +++ b/win32/test/handles.py @@ -5,6 +5,14 @@ import win32api +class TestError1(Exception): + pass + + +class TestError2(Exception): + pass + + # A class that will never die vie refcounting, but will die via GC. class Cycle: def __init__(self, handle): @@ -21,7 +29,7 @@ def f1(invalidate): h = win32event.CreateEvent(None, 0, 0, None) if invalidate: win32api.CloseHandle(int(h)) - 1 / 0 + raise TestError1 # If we invalidated, then the object destruction code will attempt # to close an invalid handle. We don't wan't an exception in # this case @@ -30,13 +38,13 @@ def f2(invalidate): """This function should throw an OSError.""" try: f1(invalidate) - except ZeroDivisionError as exc: - raise OSError("raise 2") + except TestError1: + raise TestError2 - self.assertRaises(OSError, f2, False) + self.assertRaises(TestError2, f2, False) # Now do it again, but so the auto object destruction # actually fails. - self.assertRaises(OSError, f2, True) + self.assertRaises(TestError2, f2, True) def testCleanup2(self): # Cause an exception during object destruction. diff --git a/win32/test/test_win32api.py b/win32/test/test_win32api.py index 446315f54..887ff2a36 100644 --- a/win32/test/test_win32api.py +++ b/win32/test/test_win32api.py @@ -14,6 +14,10 @@ from pywin32_testutil import TestSkipped +class TestError(Exception): + pass + + class CurrentUserTestCase(unittest.TestCase): def testGetCurrentUser(self): domain = win32api.GetDomainName() @@ -63,7 +67,7 @@ def test1(self): # This used to leave a stale exception behind. def reg_operation(): hkey = win32api.RegCreateKey(win32con.HKEY_CURRENT_USER, self.key_name) - x = 3 / 0 # or a statement like: raise Exception + raise TestError # do the test try: @@ -71,10 +75,10 @@ def reg_operation(): try: reg_operation() except: - 1 / 0 # Force exception + raise TestError # Force a TestError finally: win32api.RegDeleteKey(win32con.HKEY_CURRENT_USER, self.key_name) - except ZeroDivisionError: + except TestError: pass def testValues(self): From 9806bdb417d737037ae83582a8198feca99b8722 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 11 Nov 2024 12:13:22 -0500 Subject: [PATCH 11/16] Favoring `builtins` over `__builtins__` and removing redundant usages (#2362) --- AutoDuck/py2d.py | 29 +++++++++++++---------------- Pythonwin/pywin/framework/app.py | 5 ++--- com/win32com/client/build.py | 3 ++- com/win32com/test/testPippo.py | 5 ++--- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/AutoDuck/py2d.py b/AutoDuck/py2d.py index 2b2d779b8..5000b5ec6 100644 --- a/AutoDuck/py2d.py +++ b/AutoDuck/py2d.py @@ -7,9 +7,6 @@ def ad_escape(s): return re.sub(r"([^<]*)<([^>]*)>", r"\g<1>\\<\g<2>\\>", s) -Print = __builtins__.__dict__["print"] - - class DocInfo: def __init__(self, name, ob): self.name = name @@ -112,30 +109,30 @@ def build_module(fp, mod_name): elif name.upper() == name and isinstance(ob, (int, str)): constants.append((name, ob)) info = BuildInfo(mod_name, mod) - Print(f"// @module {mod_name}|{format_desc(info.desc)}", file=fp) + print(f"// @module {mod_name}|{format_desc(info.desc)}", file=fp) functions = [f for f in functions if should_build_function(f)] for ob in functions: - Print(f"// @pymeth {ob.name}|{ob.short_desc}", file=fp) + print(f"// @pymeth {ob.name}|{ob.short_desc}", file=fp) for ob in classes: # only classes with docstrings get printed. if not ob.ob.__doc__: continue ob_name = mod_name + "." + ob.name - Print(f"// @pyclass {ob.name}|{ob.short_desc}", file=fp) + print(f"// @pyclass {ob.name}|{ob.short_desc}", file=fp) for ob in functions: - Print( + print( f"// @pymethod |{mod_name}|{ob.name}|{format_desc(ob.desc)}", file=fp, ) for ai in BuildArgInfos(ob.ob): - Print(f"// @pyparm |{ai.name}|{ai.default}|{ai.short_desc}", file=fp) + print(f"// @pyparm |{ai.name}|{ai.default}|{ai.short_desc}", file=fp) for ob in classes: # only classes with docstrings get printed. if not ob.ob.__doc__: continue ob_name = mod_name + "." + ob.name - Print(f"// @object {ob_name}|{format_desc(ob.desc)}", file=fp) + print(f"// @object {ob_name}|{format_desc(ob.desc)}", file=fp) func_infos = [] # We need to iter the keys then to a getattr() so the funky descriptor # things work. @@ -146,20 +143,20 @@ def build_module(fp, mod_name): if should_build_function(info): func_infos.append(info) for fi in func_infos: - Print(f"// @pymeth {fi.name}|{fi.short_desc}", file=fp) + print(f"// @pymeth {fi.name}|{fi.short_desc}", file=fp) for fi in func_infos: - Print( + print( f"// @pymethod |{ob_name}|{fi.name}|{format_desc(fi.desc)}", file=fp, ) if hasattr(fi.ob, "im_self") and fi.ob.im_self is ob.ob: - Print("// @comm This is a @classmethod.", file=fp) - Print( + print("// @comm This is a @classmethod.", file=fp) + print( f"// @pymethod |{ob_name}|{fi.name}|{format_desc(fi.desc)}", file=fp, ) for ai in BuildArgInfos(fi.ob): - Print( + print( f"// @pyparm |{ai.name}|{ai.default}|{ai.short_desc}", file=fp, ) @@ -168,11 +165,11 @@ def build_module(fp, mod_name): desc = f"{name} = {val!r}" if isinstance(val, int): desc += f" (0x{val:x})" - Print(f"// @const {mod_name}|{name}|{desc}", file=fp) + print(f"// @const {mod_name}|{name}|{desc}", file=fp) def main(fp, args): - Print("// @doc", file=fp) + print("// @doc", file=fp) for arg in args: build_module(sys.stdout, arg) diff --git a/Pythonwin/pywin/framework/app.py b/Pythonwin/pywin/framework/app.py index 9899e62fa..ddd64b197 100644 --- a/Pythonwin/pywin/framework/app.py +++ b/Pythonwin/pywin/framework/app.py @@ -6,6 +6,7 @@ from __future__ import annotations +import builtins import os import sys import traceback @@ -393,9 +394,7 @@ def Win32Input(prompt=None): def HookInput(): - import code - - sys.modules["builtins"].input = Win32Input + builtins.input = Win32Input def HaveGoodGUI(): diff --git a/com/win32com/client/build.py b/com/win32com/client/build.py index c0d660800..a1c7d52a5 100644 --- a/com/win32com/client/build.py +++ b/com/win32com/client/build.py @@ -16,6 +16,7 @@ # # OleItem, DispatchItem, MapEntry, BuildCallList() is used by makepy +import builtins import datetime import string from itertools import chain @@ -656,7 +657,7 @@ def MakePublicAttributeName(className, is_global=False): if ret == className: ret = ret.upper() return ret - elif is_global and hasattr(__builtins__, className): + elif is_global and hasattr(builtins, className): # builtins may be mixed case. If capitalizing it doesn't change it, # force to all uppercase (eg, "None", "True" become "NONE", "TRUE" ret = className.capitalize() diff --git a/com/win32com/test/testPippo.py b/com/win32com/test/testPippo.py index 414483b53..765acf97f 100644 --- a/com/win32com/test/testPippo.py +++ b/com/win32com/test/testPippo.py @@ -51,9 +51,8 @@ def testNumpyArrays(self): self._testArray(numpy.array([-3.14, -2, -0.1, 0.0, 1.1, 2.5, 3])) def testByteArrays(self): - if "bytes" in dir(__builtins__): - self._testArray(b"abcdef") - self._testArray(bytearray(b"abcdef")) + self._testArray(b"abcdef") + self._testArray(bytearray(b"abcdef")) def _testArray(self, inArray): outArray = self.object.Method3(inArray) From c8c0e2d613c5e79e33efa92224cd806a3b7c1a4d Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 11 Nov 2024 16:03:55 -0500 Subject: [PATCH 12/16] Fix re-raising exceptions as `QueryError` in `win32pdhquery.BaseQuery.open` (#2318) --- pyrightconfig.json | 1 + setup.py | 2 +- win32/Lib/win32pdhquery.py | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index d96b3fc9d..5a56ef6cf 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -6,6 +6,7 @@ "enableTypeIgnoreComments": true, // Exclude from scanning when running pyright "exclude": [ + ".git/", "build/", // Vendored "Pythonwin/Scintilla/", diff --git a/setup.py b/setup.py index e72edf0ad..fcd1d6381 100644 --- a/setup.py +++ b/setup.py @@ -926,7 +926,7 @@ class my_compiler(MSVCCompiler): # worse! This can probably go away once we kill the VS project files # though, as we can just specify the lowercase name in the module def. _cpp_extensions = MSVCCompiler._cpp_extensions + [".CPP"] - src_extensions = MSVCCompiler.src_extensions + [".CPP"] + src_extensions = MSVCCompiler.src_extensions + [".CPP"] # type: ignore[operator] # TODO: Fix in typeshed def link( self, diff --git a/win32/Lib/win32pdhquery.py b/win32/Lib/win32pdhquery.py index 724a668a7..301b85c16 100644 --- a/win32/Lib/win32pdhquery.py +++ b/win32/Lib/win32pdhquery.py @@ -560,11 +560,11 @@ def __setstate__(self, volatilecounters): self.volatilecounters = volatilecounters -class QueryError: - def __init__(self, query): +class QueryError(Exception): + def __init__(self, query: BaseQuery): self.query = query def __repr__(self): - return "" % repr(self.query) + return f"" __str__ = __repr__ From b8082dc3ffb301adbfb27969d49be3e7d08f7f75 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 12 Nov 2024 00:15:44 -0500 Subject: [PATCH 13/16] Rename capitalized CPP and H (#2409) --- Pythonwin/win32win.cpp | 2 +- com/win32com/makegw/makegw.py | 4 ++-- com/win32com/olectl.py | 2 +- com/win32com/src/ErrorUtils.cpp | 2 +- com/win32comext/adsi/src/PyADSIUtil.cpp | 4 ++-- com/win32comext/axscript/src/{GUIDS.CPP => GUIDs.cpp} | 8 ++++---- com/win32comext/axscript/src/{GUIDS.H => GUIDs.h} | 2 +- .../axscript/src/{MULTINFO.H => multinfo.h} | 0 com/win32comext/mapi/mapitags.py | 2 +- com/win32comext/mapi/src/PyIExchangeManageStore.i | 2 +- com/win32comext/mapi/src/exchange.i | 10 +++++----- com/win32comext/mapi/src/mapi.i | 5 ++--- isapi/src/pyISAPI.cpp | 2 +- isapi/src/pyISAPI.h | 2 +- setup.py | 11 ++--------- win32/Lib/commctrl.py | 2 +- win32/src/_winxptheme.i | 2 +- win32/src/stddde.h | 2 +- win32/src/win32dynamicdialog.cpp | 2 +- win32/src/win32gui.i | 2 +- win32/src/win32security.i | 4 ++-- 21 files changed, 32 insertions(+), 40 deletions(-) rename com/win32comext/axscript/src/{GUIDS.CPP => GUIDs.cpp} (72%) rename com/win32comext/axscript/src/{GUIDS.H => GUIDs.h} (98%) rename com/win32comext/axscript/src/{MULTINFO.H => multinfo.h} (100%) diff --git a/Pythonwin/win32win.cpp b/Pythonwin/win32win.cpp index f7db04170..4d8f9996e 100644 --- a/Pythonwin/win32win.cpp +++ b/Pythonwin/win32win.cpp @@ -25,7 +25,7 @@ generates Windows .hlp files. #include "win32cmdui.h" #include "win32rgn.h" #include "reswin32ui.h" -#include "AFXSTAT_.H" +#include "afxstat_.h" static char *szErrMsgBadHandle = "The window handle does not specify a valid window"; #define CHECK_HWND_VALID(pWnd) \ diff --git a/com/win32com/makegw/makegw.py b/com/win32com/makegw/makegw.py index 2a12239c8..e3c85d61a 100644 --- a/com/win32com/makegw/makegw.py +++ b/com/win32com/makegw/makegw.py @@ -20,7 +20,7 @@ any result values. This module automates the generation of such code. It has the ability to -parse a .H file generated by the MIDL tool (ie, almost all COM .h files) +parse a .h file generated by the MIDL tool (ie, almost all COM .h files) and build almost totally complete C++ code. The module understands some of the well known data types, and how to @@ -61,7 +61,7 @@ def make_framework_support( ): """Generate C++ code for a Python Interface and Gateway - header_file_name -- The full path to the .H file which defines the interface. + header_file_name -- The full path to the .h file which defines the interface. interface_name -- The name of the interface to search for, and to generate. bMakeInterface = 1 -- Should interface (ie, client) support be generated. bMakeGatewayInterface = 1 -- Should gateway (ie, server) support be generated. diff --git a/com/win32com/olectl.py b/com/win32com/olectl.py index 3ec5bf6ef..e2e16b42d 100644 --- a/com/win32com/olectl.py +++ b/com/win32com/olectl.py @@ -1,6 +1,6 @@ """Constants used by COM Controls -Hand created version of OLECTL.H constants. +Hand created version of olectl.h constants. """ import winerror diff --git a/com/win32com/src/ErrorUtils.cpp b/com/win32com/src/ErrorUtils.cpp index ff16d9985..c774e9f99 100644 --- a/com/win32com/src/ErrorUtils.cpp +++ b/com/win32com/src/ErrorUtils.cpp @@ -1115,7 +1115,7 @@ LPCTSTR GetFacilityString(HRESULT hr) _T("FACILITY_0x06"), _T("FACILITY_WIN32"), _T("FACILITY_WINDOWS"), - _T("FACILITY_SSPI/FACILITY_MQ"), // SSPI from ADSERR.H, MQ from mq.h + _T("FACILITY_SSPI/FACILITY_MQ"), // SSPI from AdsErr.h, MQ from mq.h _T("FACILITY_CONTROL"), _T("FACILITY_EDK"), _T("FACILITY_INTERNET"), diff --git a/com/win32comext/adsi/src/PyADSIUtil.cpp b/com/win32comext/adsi/src/PyADSIUtil.cpp index 07f3093d1..06c0ec209 100644 --- a/com/win32comext/adsi/src/PyADSIUtil.cpp +++ b/com/win32comext/adsi/src/PyADSIUtil.cpp @@ -672,11 +672,11 @@ BOOL PyADSIObject_AsADS_SEARCHPREF_INFOs(PyObject *ob, ADS_SEARCHPREF_INFO **ppr // // Error string utility. // -// ADSERR.h is built from a message file. +// AdsErr.h is built from a message file. // Therefore, there _must_ be a DLL around we can call // FormatMessage with. // However, it's not obvious, and this code was cut directly from MSDN. -#include "adserr.h" +#include "AdsErr.h" typedef struct tagADSERRMSG { HRESULT hr; LPCWSTR pszError; diff --git a/com/win32comext/axscript/src/GUIDS.CPP b/com/win32comext/axscript/src/GUIDs.cpp similarity index 72% rename from com/win32comext/axscript/src/GUIDS.CPP rename to com/win32comext/axscript/src/GUIDs.cpp index bce8d8807..9038c1225 100644 --- a/com/win32comext/axscript/src/GUIDS.CPP +++ b/com/win32comext/axscript/src/GUIDs.cpp @@ -1,10 +1,10 @@ /* * FILENAME: - * guids.cpp + * GUIDs.cpp * * DESCRIPTION: - * Define the guids used by the project. Both internally defined - * guids as well as guids from external sources. + * Define the GUIDs used by the project. Both internally defined + * GUIDs as well as GUIDs from external sources. */ #include #pragma data_seg(".text") @@ -17,7 +17,7 @@ #endif // === Project Guids === -#include "GUIDS.H" +#include "GUIDs.h" // NOTE - The standard "activscp.h" header is not good enough - // need to use IE4 SDK or MSVC6 etc #include "activscp.h" diff --git a/com/win32comext/axscript/src/GUIDS.H b/com/win32comext/axscript/src/GUIDs.h similarity index 98% rename from com/win32comext/axscript/src/GUIDS.H rename to com/win32comext/axscript/src/GUIDs.h index 20355e4d9..857a5b43d 100644 --- a/com/win32comext/axscript/src/GUIDS.H +++ b/com/win32comext/axscript/src/GUIDs.h @@ -3,7 +3,7 @@ /* * FILENAME: - * guids.h + * GUIDs.h * * DESCRIPTION: * GUID definitions for the project. diff --git a/com/win32comext/axscript/src/MULTINFO.H b/com/win32comext/axscript/src/multinfo.h similarity index 100% rename from com/win32comext/axscript/src/MULTINFO.H rename to com/win32comext/axscript/src/multinfo.h diff --git a/com/win32comext/mapi/mapitags.py b/com/win32comext/mapi/mapitags.py index e6e9667e0..e3238b662 100644 --- a/com/win32comext/mapi/mapitags.py +++ b/com/win32comext/mapi/mapitags.py @@ -824,7 +824,7 @@ def PROP_TAG(ulPropType, ulPropID): PROP_ID_SECURE_MIN = 26608 PROP_ID_SECURE_MAX = 26623 -# From EDKMDB.H +# From EdkMdb.h pidExchangeXmitReservedMin = 16352 pidExchangeNonXmitReservedMin = 26080 pidProfileMin = 26112 diff --git a/com/win32comext/mapi/src/PyIExchangeManageStore.i b/com/win32comext/mapi/src/PyIExchangeManageStore.i index 36e71e6bd..013136512 100644 --- a/com/win32comext/mapi/src/PyIExchangeManageStore.i +++ b/com/win32comext/mapi/src/PyIExchangeManageStore.i @@ -11,7 +11,7 @@ %include "mapilib.i" %{ -#include +#include #define INITGUID #include #define USES_IID_IExchangeManageStore diff --git a/com/win32comext/mapi/src/exchange.i b/com/win32comext/mapi/src/exchange.i index 8afdf76b0..8287cb008 100644 --- a/com/win32comext/mapi/src/exchange.i +++ b/com/win32comext/mapi/src/exchange.i @@ -26,8 +26,8 @@ #include "PythonCOMServer.h" #include "PythonCOMRegister.h" -#include "MAPIUTIL.H" -#include "EDKMDB.H" +#include "MAPIUtil.h" +#include "EdkMdb.h" #define USES_IID_IExchangeManageStore #include @@ -75,9 +75,9 @@ static int AddIID(PyObject *dict, const char *key, REFGUID guid) */ #ifdef SWIG_PY32BIT %{ -#include "EDKMAPI.H" -#include "EDKCFG.H" -#include "EDKUTILS.H" +#include "EdkMAPI.h" +#include "EdkCfg.h" +#include "EdkUtils.h" %} // @pyswig int, int|HrGetExchangeStatus|Obtains the current state of the server on a computer. diff --git a/com/win32comext/mapi/src/mapi.i b/com/win32comext/mapi/src/mapi.i index b66133443..be270f51d 100644 --- a/com/win32comext/mapi/src/mapi.i +++ b/com/win32comext/mapi/src/mapi.i @@ -52,9 +52,8 @@ #include "IConverterSession.h" #include "PyIConverterSession.h" -#include "MAPISPI.H" -#include "MAPISPI.H" -#include "IMESSAGE.H" +#include "MAPISPI.h" +#include "IMessage.h" #include "MSPST.h" #include "extraMAPIGuids.h" diff --git a/isapi/src/pyISAPI.cpp b/isapi/src/pyISAPI.cpp index 453cc2b99..6cf639351 100644 --- a/isapi/src/pyISAPI.cpp +++ b/isapi/src/pyISAPI.cpp @@ -23,7 +23,7 @@ ====================================================================== */ -// PYISAPI.CPP - Implementation file for your Internet Server +// pyISAPI.cpp - Implementation file for your Internet Server // Python ISAPI Extension #include "stdafx.h" diff --git a/isapi/src/pyISAPI.h b/isapi/src/pyISAPI.h index b5931e538..6a82a9a91 100644 --- a/isapi/src/pyISAPI.h +++ b/isapi/src/pyISAPI.h @@ -25,7 +25,7 @@ #ifndef __PYISAPI_H__ #define __PYISAPI_H__ -// PYISAPI.H - Header file for your Internet Server +// pyISAPI.h - Header file for your Internet Server // Python ISAPI Extension #include "PythonEng.h" diff --git a/setup.py b/setup.py index fcd1d6381..bd63dead1 100644 --- a/setup.py +++ b/setup.py @@ -921,13 +921,6 @@ def my_new_compiler(**kw): class my_compiler(MSVCCompiler): - # Just one GUIDS.CPP and it gives trouble on mainwin too. Maybe I - # should just rename the file, but a case-only rename is likely to be - # worse! This can probably go away once we kill the VS project files - # though, as we can just specify the lowercase name in the module def. - _cpp_extensions = MSVCCompiler._cpp_extensions + [".CPP"] - src_extensions = MSVCCompiler.src_extensions + [".CPP"] # type: ignore[operator] # TODO: Fix in typeshed - def link( self, target_desc, @@ -1422,7 +1415,7 @@ def finalize_options(self): sources=( """ {axscript}/AXScript.cpp - {axscript}/GUIDS.CPP {axscript}/PyGActiveScript.cpp + {axscript}/GUIDS.cpp {axscript}/PyGActiveScript.cpp {axscript}/PyGActiveScriptError.cpp {axscript}/PyGActiveScriptParse.cpp {axscript}/PyGActiveScriptSite.cpp {axscript}/PyGObjectSafety.cpp {axscript}/PyIActiveScript.cpp {axscript}/PyIActiveScriptError.cpp @@ -1434,7 +1427,7 @@ def finalize_options(self): depends=( """ {axscript}/AXScript.h - {axscript}/guids.h {axscript}/PyGActiveScriptError.h + {axscript}/GUIDs.h {axscript}/PyGActiveScriptError.h {axscript}/PyIActiveScriptError.h {axscript}/PyIObjectSafety.h {axscript}/PyIProvideMultipleClassInfo.h {axscript}/stdafx.h diff --git a/win32/Lib/commctrl.py b/win32/Lib/commctrl.py index 26641e845..452fe62ef 100644 --- a/win32/Lib/commctrl.py +++ b/win32/Lib/commctrl.py @@ -1,4 +1,4 @@ -# Generated by h2py from COMMCTRL.H +# Generated by h2py from CommCtrl.h WM_USER = 1024 ICC_LISTVIEW_CLASSES = 1 # listview, header ICC_TREEVIEW_CLASSES = 2 # treeview, tooltips diff --git a/win32/src/_winxptheme.i b/win32/src/_winxptheme.i index 3ef07bbb9..2320b881e 100644 --- a/win32/src/_winxptheme.i +++ b/win32/src/_winxptheme.i @@ -21,7 +21,7 @@ #include "pywinobjects.h" #include "windows.h" #include "Uxtheme.h" -#include "commctrl.h" +#include "CommCtrl.h" %} diff --git a/win32/src/stddde.h b/win32/src/stddde.h index 85688c1f9..3263f4fbd 100644 --- a/win32/src/stddde.h +++ b/win32/src/stddde.h @@ -26,7 +26,7 @@ // // String names for some standard DDE strings not -// defined in DDEML.H +// defined in ddeml.h // #define SZ_READY "Ready" diff --git a/win32/src/win32dynamicdialog.cpp b/win32/src/win32dynamicdialog.cpp index bef647374..2b1992d67 100644 --- a/win32/src/win32dynamicdialog.cpp +++ b/win32/src/win32dynamicdialog.cpp @@ -34,7 +34,7 @@ #include "python.h" #undef PyHANDLE #include -#include "commctrl.h" +#include "CommCtrl.h" #include "windowsx.h" // For edit control hacks. #include "pywintypes.h" diff --git a/win32/src/win32gui.i b/win32/src/win32gui.i index fa0906b7e..172218879 100644 --- a/win32/src/win32gui.i +++ b/win32/src/win32gui.i @@ -14,7 +14,7 @@ #undef PyHANDLE #include "pywinobjects.h" #include "winuser.h" -#include "commctrl.h" +#include "CommCtrl.h" #include "windowsx.h" // For edit control hacks. #include "Dbt.h" // device notification #include "malloc.h" diff --git a/win32/src/win32security.i b/win32/src/win32security.i index c614d3081..48b4d2dc8 100644 --- a/win32/src/win32security.i +++ b/win32/src/win32security.i @@ -1246,9 +1246,9 @@ done: if it fails. If the SID can be constructed successfully, a valid binary SID is returned. - This function requires TCHAR.H and the C runtime library. + This function requires tchar.h and the C runtime library. - The following are macros defined in TCHAR.H that allow this + The following are macros defined in tchar.h that allow this function to be compiled with or without UNICODE defined. To replace these macros with direct calls to their corresponding ANSI functions first make sure this module is not compiled From b64bccb56968862d2aa92820ba39ed904462acd2 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 12 Nov 2024 00:21:42 -0500 Subject: [PATCH 14/16] Fix publishing documentation (#2384) --- .github/workflows/docs.yml | 32 +++++++++++++++++--------------- .github/workflows/main.yml | 7 +++++++ AutoDuck/{README => README.md} | 2 +- AutoDuck/common_top.mak | 17 ++++++++--------- AutoDuck/make.py | 4 +++- 5 files changed, 36 insertions(+), 26 deletions(-) rename AutoDuck/{README => README.md} (77%) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index edeb8e066..0cb4702dd 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,15 +3,18 @@ name: docs on: create: tags: - # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet + # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet - b[0-9][0-9][0-9] - publish-docs* push: branches: - main + pull_request: # Temporary just for test + branches: + - main jobs: - decompile: + generate: runs-on: windows-latest steps: @@ -22,44 +25,43 @@ jobs: with: python-version: '3.9' + # We still need to install pywin32 because + # AutoDuck/py2d.py currently relies on runtime imports for introspection + # Downloading latest release is faster than re-building - name: Install latest release run: pip install --user --upgrade pywin32 - - name: Set Python user site directory - run: python -c "import os,site;open(os.environ['GITHUB_ENV'], 'a').write(f'USER_DIR={site.USER_SITE}\n')" + - name: Generate PyWin32.chm help file + run: python AutoDuck/make.py - - name: Decompile shipped help file - run: hh -decompile site ${env:USER_DIR}\PyWin32.chm + - name: Decompile help file into HTML + run: hh -decompile site PyWin32.chm - name: Rename root HTML file run: mv site\PyWin32.HTML site\index.html - # Compress first to avoid slowly uploading thousands of individual files - - name: Create archive - run: python -m zipfile -c site.zip site - - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: documentation - path: site.zip + path: site/ publish: runs-on: ubuntu-latest needs: - - decompile + - generate # Only publish tags if: github.event_name == 'create' && github.event.ref_type == 'tag' steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: documentation - name: Unpack archive run: python -m zipfile -e site.zip . - - uses: peaceiris/actions-gh-pages@v3 + - uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: site diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 88e5ae6ca..1b004b1f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,6 +43,13 @@ jobs: run: | python setup.py install --user + # This needs to happen *after* installing pywin32 since + # AutoDuck/py2d.py currently relies on runtime imports for introspection + # This isn't included in the wheel (TODO: could we?) + # and only servces as a PR test for the docs.yaml workflow + - name: Generate PyWin32.chm help file + run: python AutoDuck/make.py + - name: Run tests # Run the tests directly from the source dir so support files (eg, .wav files etc) # can be found - they aren't installed into the Python tree. diff --git a/AutoDuck/README b/AutoDuck/README.md similarity index 77% rename from AutoDuck/README rename to AutoDuck/README.md index 5d0520aed..192828d79 100644 --- a/AutoDuck/README +++ b/AutoDuck/README.md @@ -1,4 +1,4 @@ -Just run MAKE.BAT to build the documentation. +Just run [make.py](./make.py) to build the documentation. Main focus these days is on the .chm file - a single .chm provides the best documentation solution. We don't even diff --git a/AutoDuck/common_top.mak b/AutoDuck/common_top.mak index a76ffcda9..a2ebbd9e0 100644 --- a/AutoDuck/common_top.mak +++ b/AutoDuck/common_top.mak @@ -1,13 +1,12 @@ # Common AutoDuck make file -AD = bin\autoduck.exe /Spythonwin.fmt +AD = bin\autoduck.exe /Spythonwin.fmt ADHTMLFMT = bin\autoduck.exe /Spyhtml.fmt ADHTMLLOG = /R html "/L$(GENDIR)\$(TARGET).HHLOG" /N -ADLOG = /R help "/L$(GENDIR)\$(TARGET).HLOG" /N -ADHTML = /R html "/G$(GENDIR)\$(TARGET).DUMP" "/C$(GENDIR)\$(TARGET).HHLOG" "/I$(GENDIR)\$(TARGET).IDX" "/O$(GENDIR)\$(TARGET).HTML" /D "title=$(TITLE)" -ADHLP = /R help "/C$(GENDIR)\$(TARGET).HLOG" "/O$(GENDIR)\$(TARGET).RTF" /D "title=$(TITLE)" -ADDOC = /RD "/O$(GENDIR)\$(TARGET).DOC" /D "doc_header=$(DOCHDR)" -ADTAB = 8 -HC = hcw /a /c /e -HHC = hhc -PYTHON = py -2.7 +ADLOG = /R help "/L$(GENDIR)\$(TARGET).HLOG" /N +ADHTML = /R html "/G$(GENDIR)\$(TARGET).DUMP" "/C$(GENDIR)\$(TARGET).HHLOG" "/I$(GENDIR)\$(TARGET).IDX" "/O$(GENDIR)\$(TARGET).HTML" /D "title=$(TITLE)" +ADHLP = /R help "/C$(GENDIR)\$(TARGET).HLOG" "/O$(GENDIR)\$(TARGET).RTF" /D "title=$(TITLE)" +ADDOC = /RD "/O$(GENDIR)\$(TARGET).DOC" /D "doc_header=$(DOCHDR)" +ADTAB = 8 +HC = hcw /a /c /e +HHC = hhc diff --git a/AutoDuck/make.py b/AutoDuck/make.py index d3b9ee39a..c205aa0da 100644 --- a/AutoDuck/make.py +++ b/AutoDuck/make.py @@ -26,5 +26,7 @@ ).splitlines()[-1] subprocess.run( - [nmake, "-E", "-f", "pywin32.mak"], cwd=os.path.dirname(sys.argv[0]), check=True + [nmake, f'PYTHON="{sys.executable}"', "-E", "-f", "pywin32.mak"], + cwd=os.path.dirname(sys.argv[0]), + check=True, ) From 68aaa099a7df6a61a178d047fac27d1ec38de78b Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 12 Nov 2024 17:19:16 -0500 Subject: [PATCH 15/16] Bumped Scintilla from 1.77 to 4.4.6 (#2425) --- CHANGES.txt | 1 + Pythonwin/Scintilla/License.txt | 28 +- Pythonwin/Scintilla/README | 75 +- Pythonwin/Scintilla/README_pythonwin | 15 +- Pythonwin/Scintilla/include/Accessor.h | 79 - Pythonwin/Scintilla/include/ILexer.h | 85 + Pythonwin/Scintilla/include/ILoader.h | 21 + Pythonwin/Scintilla/include/KeyWords.h | 90 - Pythonwin/Scintilla/include/Platform.h | 560 +- Pythonwin/Scintilla/include/PropSet.h | 104 - Pythonwin/Scintilla/include/SString.h | 289 - Pythonwin/Scintilla/include/SciLexer.h | 783 +- Pythonwin/Scintilla/include/Sci_Position.h | 29 + Pythonwin/Scintilla/include/Scintilla.h | 677 +- Pythonwin/Scintilla/include/Scintilla.iface | 5417 ++++++++++ Pythonwin/Scintilla/include/ScintillaWidget.h | 72 + Pythonwin/Scintilla/include/WinDefs.h | 185 - Pythonwin/Scintilla/include/WindowAccessor.h | 66 - Pythonwin/Scintilla/lexers/LexA68k.cxx | 345 + .../Scintilla/{src => lexers}/LexAPDL.cxx | 27 +- .../Scintilla/{src => lexers}/LexASY.cxx | 46 +- .../Scintilla/{src => lexers}/LexAU3.cxx | 178 +- .../Scintilla/{src => lexers}/LexAVE.cxx | 37 +- Pythonwin/Scintilla/lexers/LexAVS.cxx | 291 + .../Scintilla/{src => lexers}/LexAbaqus.cxx | 96 +- .../Scintilla/{src => lexers}/LexAda.cxx | 65 +- Pythonwin/Scintilla/lexers/LexAsm.cxx | 477 + .../Scintilla/{src => lexers}/LexAsn1.cxx | 23 +- Pythonwin/Scintilla/lexers/LexBaan.cxx | 992 ++ Pythonwin/Scintilla/lexers/LexBash.cxx | 1086 ++ Pythonwin/Scintilla/lexers/LexBasic.cxx | 570 + Pythonwin/Scintilla/lexers/LexBatch.cxx | 576 + Pythonwin/Scintilla/lexers/LexBibTeX.cxx | 308 + .../Scintilla/{src => lexers}/LexBullant.cxx | 33 +- Pythonwin/Scintilla/lexers/LexCIL.cxx | 407 + .../Scintilla/{src => lexers}/LexCLW.cxx | 75 +- Pythonwin/Scintilla/lexers/LexCOBOL.cxx | 379 + Pythonwin/Scintilla/lexers/LexCPP.cxx | 1785 ++++ .../Scintilla/{src => lexers}/LexCSS.cxx | 294 +- .../Scintilla/{src => lexers}/LexCaml.cxx | 215 +- .../Scintilla/{src => lexers}/LexCmake.cxx | 72 +- .../Scintilla/lexers/LexCoffeeScript.cxx | 483 + .../Scintilla/{src => lexers}/LexConf.cxx | 42 +- .../Scintilla/{src => lexers}/LexCrontab.cxx | 36 +- .../Scintilla/{src => lexers}/LexCsound.cxx | 34 +- Pythonwin/Scintilla/lexers/LexD.cxx | 571 + Pythonwin/Scintilla/lexers/LexDMAP.cxx | 226 + Pythonwin/Scintilla/lexers/LexDMIS.cxx | 358 + Pythonwin/Scintilla/lexers/LexDataflex.cxx | 608 ++ Pythonwin/Scintilla/lexers/LexDiff.cxx | 161 + .../{src/LexCPP.cxx => lexers/LexECL.cxx} | 403 +- Pythonwin/Scintilla/lexers/LexEDIFACT.cxx | 403 + .../Scintilla/{src => lexers}/LexEScript.cxx | 35 +- .../Scintilla/{src => lexers}/LexEiffel.cxx | 43 +- Pythonwin/Scintilla/lexers/LexErlang.cxx | 624 ++ Pythonwin/Scintilla/lexers/LexErrorList.cxx | 409 + Pythonwin/Scintilla/lexers/LexFlagship.cxx | 352 + Pythonwin/Scintilla/lexers/LexForth.cxx | 168 + Pythonwin/Scintilla/lexers/LexFortran.cxx | 721 ++ .../Scintilla/{src => lexers}/LexGAP.cxx | 35 +- .../Scintilla/{src => lexers}/LexGui4Cli.cxx | 43 +- .../Scintilla/{src => lexers}/LexHTML.cxx | 1504 +-- Pythonwin/Scintilla/lexers/LexHaskell.cxx | 1116 ++ Pythonwin/Scintilla/lexers/LexHex.cxx | 1045 ++ Pythonwin/Scintilla/lexers/LexHollywood.cxx | 516 + Pythonwin/Scintilla/lexers/LexIndent.cxx | 71 + .../Scintilla/{src => lexers}/LexInno.cxx | 104 +- Pythonwin/Scintilla/lexers/LexJSON.cxx | 502 + Pythonwin/Scintilla/lexers/LexKVIrc.cxx | 471 + .../Scintilla/{src => lexers}/LexKix.cxx | 26 +- Pythonwin/Scintilla/lexers/LexLaTeX.cxx | 559 + .../Scintilla/{src => lexers}/LexLisp.cxx | 52 +- .../Scintilla/{src => lexers}/LexLout.cxx | 31 +- Pythonwin/Scintilla/lexers/LexLua.cxx | 502 + .../Scintilla/{src => lexers}/LexMMIXAL.cxx | 43 +- .../Scintilla/{src => lexers}/LexMPT.cxx | 59 +- .../Scintilla/{src => lexers}/LexMSSQL.cxx | 59 +- .../Scintilla/{src => lexers}/LexMagik.cxx | 39 +- Pythonwin/Scintilla/lexers/LexMake.cxx | 142 + Pythonwin/Scintilla/lexers/LexMarkdown.cxx | 419 + Pythonwin/Scintilla/lexers/LexMatlab.cxx | 389 + Pythonwin/Scintilla/lexers/LexMaxima.cxx | 222 + .../Scintilla/{src => lexers}/LexMetapost.cxx | 60 +- Pythonwin/Scintilla/lexers/LexModula.cxx | 741 ++ Pythonwin/Scintilla/lexers/LexMySQL.cxx | 574 + Pythonwin/Scintilla/lexers/LexNim.cxx | 811 ++ Pythonwin/Scintilla/lexers/LexNimrod.cxx | 431 + .../Scintilla/{src => lexers}/LexNsis.cxx | 74 +- Pythonwin/Scintilla/lexers/LexNull.cxx | 38 + Pythonwin/Scintilla/lexers/LexOScript.cxx | 546 + .../Scintilla/{src => lexers}/LexOpal.cxx | 103 +- Pythonwin/Scintilla/{src => lexers}/LexPB.cxx | 33 +- .../Scintilla/{src => lexers}/LexPLM.cxx | 48 +- Pythonwin/Scintilla/lexers/LexPO.cxx | 211 + .../Scintilla/{src => lexers}/LexPOV.cxx | 35 +- Pythonwin/Scintilla/{src => lexers}/LexPS.cxx | 64 +- Pythonwin/Scintilla/lexers/LexPascal.cxx | 613 ++ Pythonwin/Scintilla/lexers/LexPerl.cxx | 1848 ++++ Pythonwin/Scintilla/lexers/LexPowerPro.cxx | 628 ++ .../{src => lexers}/LexPowerShell.cxx | 113 +- Pythonwin/Scintilla/lexers/LexProgress.cxx | 568 + Pythonwin/Scintilla/lexers/LexProps.cxx | 187 + Pythonwin/Scintilla/lexers/LexPython.cxx | 984 ++ Pythonwin/Scintilla/{src => lexers}/LexR.cxx | 35 +- Pythonwin/Scintilla/lexers/LexRaku.cxx | 1605 +++ .../Scintilla/{src => lexers}/LexRebol.cxx | 29 +- Pythonwin/Scintilla/lexers/LexRegistry.cxx | 419 + .../Scintilla/{src => lexers}/LexRuby.cxx | 1126 +- Pythonwin/Scintilla/lexers/LexRust.cxx | 844 ++ Pythonwin/Scintilla/lexers/LexSAS.cxx | 220 + Pythonwin/Scintilla/lexers/LexSML.cxx | 226 + Pythonwin/Scintilla/lexers/LexSQL.cxx | 970 ++ Pythonwin/Scintilla/lexers/LexSTTXT.cxx | 404 + .../Scintilla/{src => lexers}/LexScriptol.cxx | 87 +- .../{src => lexers}/LexSmalltalk.cxx | 37 +- Pythonwin/Scintilla/lexers/LexSorcus.cxx | 206 + .../Scintilla/{src => lexers}/LexSpecman.cxx | 31 +- .../Scintilla/{src => lexers}/LexSpice.cxx | 59 +- Pythonwin/Scintilla/lexers/LexStata.cxx | 203 + Pythonwin/Scintilla/lexers/LexTACL.cxx | 398 + .../Scintilla/{src => lexers}/LexTADS3.cxx | 55 +- .../{src/LexPascal.cxx => lexers/LexTAL.cxx} | 226 +- Pythonwin/Scintilla/lexers/LexTCL.cxx | 371 + Pythonwin/Scintilla/lexers/LexTCMD.cxx | 504 + .../Scintilla/{src => lexers}/LexTeX.cxx | 100 +- Pythonwin/Scintilla/lexers/LexTxt2tags.cxx | 478 + Pythonwin/Scintilla/{src => lexers}/LexVB.cxx | 73 +- .../Scintilla/{src => lexers}/LexVHDL.cxx | 308 +- Pythonwin/Scintilla/lexers/LexVerilog.cxx | 1081 ++ .../Scintilla/lexers/LexVisualProlog.cxx | 513 + Pythonwin/Scintilla/lexers/LexX12.cxx | 345 + .../Scintilla/{src => lexers}/LexYAML.cxx | 143 +- Pythonwin/Scintilla/lexlib/Accessor.cxx | 73 + Pythonwin/Scintilla/lexlib/Accessor.h | 31 + Pythonwin/Scintilla/lexlib/CatalogueModules.h | 70 + .../Scintilla/lexlib/CharacterCategory.cxx | 4048 +++++++ .../Scintilla/lexlib/CharacterCategory.h | 50 + Pythonwin/Scintilla/lexlib/CharacterSet.cxx | 52 + Pythonwin/Scintilla/lexlib/CharacterSet.h | 208 + Pythonwin/Scintilla/lexlib/DefaultLexer.cxx | 139 + Pythonwin/Scintilla/lexlib/DefaultLexer.h | 57 + Pythonwin/Scintilla/lexlib/LexAccessor.h | 195 + Pythonwin/Scintilla/lexlib/LexerBase.cxx | 155 + Pythonwin/Scintilla/lexlib/LexerBase.h | 57 + Pythonwin/Scintilla/lexlib/LexerModule.cxx | 123 + Pythonwin/Scintilla/lexlib/LexerModule.h | 92 + .../Scintilla/lexlib/LexerNoExceptions.cxx | 62 + .../Scintilla/lexlib/LexerNoExceptions.h | 28 + Pythonwin/Scintilla/lexlib/LexerSimple.cxx | 61 + Pythonwin/Scintilla/lexlib/LexerSimple.h | 29 + Pythonwin/Scintilla/lexlib/OptionSet.h | 149 + Pythonwin/Scintilla/lexlib/PropSetSimple.cxx | 157 + Pythonwin/Scintilla/lexlib/PropSetSimple.h | 28 + Pythonwin/Scintilla/lexlib/SparseState.h | 106 + Pythonwin/Scintilla/lexlib/StringCopy.h | 32 + Pythonwin/Scintilla/lexlib/StyleContext.cxx | 68 + Pythonwin/Scintilla/lexlib/StyleContext.h | 212 + Pythonwin/Scintilla/lexlib/SubStyles.h | 208 + Pythonwin/Scintilla/lexlib/WordList.cxx | 315 + Pythonwin/Scintilla/lexlib/WordList.h | 38 + Pythonwin/Scintilla/src/AutoComplete.cxx | 198 +- Pythonwin/Scintilla/src/AutoComplete.h | 51 +- Pythonwin/Scintilla/src/CallTip.cxx | 382 +- Pythonwin/Scintilla/src/CallTip.h | 77 +- Pythonwin/Scintilla/src/CaseConvert.cxx | 826 ++ Pythonwin/Scintilla/src/CaseConvert.h | 46 + Pythonwin/Scintilla/src/CaseFolder.cxx | 66 + Pythonwin/Scintilla/src/CaseFolder.h | 41 + Pythonwin/Scintilla/src/Catalogue.cxx | 197 + Pythonwin/Scintilla/src/Catalogue.h | 24 + Pythonwin/Scintilla/src/CellBuffer.cxx | 1269 ++- Pythonwin/Scintilla/src/CellBuffer.h | 226 +- Pythonwin/Scintilla/src/CharClassify.cxx | 33 +- Pythonwin/Scintilla/src/CharClassify.h | 12 +- Pythonwin/Scintilla/src/CharacterSet.h | 58 - Pythonwin/Scintilla/src/ContractionState.cxx | 352 +- Pythonwin/Scintilla/src/ContractionState.h | 65 +- Pythonwin/Scintilla/src/DBCS.cxx | 42 + Pythonwin/Scintilla/src/DBCS.h | 25 + Pythonwin/Scintilla/src/Decoration.cxx | 339 +- Pythonwin/Scintilla/src/Decoration.h | 71 +- Pythonwin/Scintilla/src/Document.cxx | 3139 ++++-- Pythonwin/Scintilla/src/Document.h | 582 +- Pythonwin/Scintilla/src/DocumentAccessor.cxx | 199 - Pythonwin/Scintilla/src/DocumentAccessor.h | 76 - Pythonwin/Scintilla/src/EditModel.cxx | 107 + Pythonwin/Scintilla/src/EditModel.h | 76 + Pythonwin/Scintilla/src/EditView.cxx | 2627 +++++ Pythonwin/Scintilla/src/EditView.h | 190 + Pythonwin/Scintilla/src/Editor.cxx | 9264 +++++++++-------- Pythonwin/Scintilla/src/Editor.h | 727 +- Pythonwin/Scintilla/src/ElapsedPeriod.h | 35 + Pythonwin/Scintilla/src/ExternalLexer.cxx | 307 +- Pythonwin/Scintilla/src/ExternalLexer.h | 90 +- Pythonwin/Scintilla/src/FontQuality.h | 27 + Pythonwin/Scintilla/src/Indicator.cxx | 311 +- Pythonwin/Scintilla/src/Indicator.h | 41 +- Pythonwin/Scintilla/src/IntegerRectangle.h | 29 + Pythonwin/Scintilla/src/KeyMap.cxx | 101 +- Pythonwin/Scintilla/src/KeyMap.h | 35 +- Pythonwin/Scintilla/src/KeyWords.cxx | 237 - Pythonwin/Scintilla/src/LexAsm.cxx | 180 - Pythonwin/Scintilla/src/LexBaan.cxx | 193 - Pythonwin/Scintilla/src/LexBash.cxx | 532 - Pythonwin/Scintilla/src/LexBasic.cxx | 373 - Pythonwin/Scintilla/src/LexD.cxx | 358 - Pythonwin/Scintilla/src/LexErlang.cxx | 526 - Pythonwin/Scintilla/src/LexFlagship.cxx | 230 - Pythonwin/Scintilla/src/LexForth.cxx | 352 - Pythonwin/Scintilla/src/LexFortran.cxx | 466 - Pythonwin/Scintilla/src/LexGen.py | 264 - Pythonwin/Scintilla/src/LexHaskell.cxx | 274 - Pythonwin/Scintilla/src/LexLua.cxx | 358 - Pythonwin/Scintilla/src/LexMatlab.cxx | 236 - Pythonwin/Scintilla/src/LexMySQL.cxx | 367 - Pythonwin/Scintilla/src/LexOthers.cxx | 1231 --- Pythonwin/Scintilla/src/LexPerl.cxx | 1295 --- Pythonwin/Scintilla/src/LexProgress.cxx | 276 - Pythonwin/Scintilla/src/LexPython.cxx | 461 - Pythonwin/Scintilla/src/LexSQL.cxx | 346 - Pythonwin/Scintilla/src/LexTCL.cxx | 366 - Pythonwin/Scintilla/src/LexVerilog.cxx | 305 - Pythonwin/Scintilla/src/LineMarker.cxx | 732 +- Pythonwin/Scintilla/src/LineMarker.h | 72 +- Pythonwin/Scintilla/src/MarginView.cxx | 474 + Pythonwin/Scintilla/src/MarginView.h | 46 + Pythonwin/Scintilla/src/Partitioning.h | 160 +- Pythonwin/Scintilla/src/PerLine.cxx | 546 + Pythonwin/Scintilla/src/PerLine.h | 172 + Pythonwin/Scintilla/src/Position.h | 26 + Pythonwin/Scintilla/src/PositionCache.cxx | 738 +- Pythonwin/Scintilla/src/PositionCache.h | 271 +- Pythonwin/Scintilla/src/PropSet.cxx | 755 -- Pythonwin/Scintilla/src/RESearch.cxx | 334 +- Pythonwin/Scintilla/src/RESearch.h | 60 +- Pythonwin/Scintilla/src/RunStyles.cxx | 213 +- Pythonwin/Scintilla/src/RunStyles.h | 62 +- Pythonwin/Scintilla/src/SVector.h | 135 - Pythonwin/Scintilla/src/SciTE.properties | 6 + Pythonwin/Scintilla/src/ScintillaBase.cxx | 916 +- Pythonwin/Scintilla/src/ScintillaBase.h | 73 +- Pythonwin/Scintilla/src/Selection.cxx | 451 + Pythonwin/Scintilla/src/Selection.h | 195 + Pythonwin/Scintilla/src/SparseVector.h | 213 + Pythonwin/Scintilla/src/SplitVector.h | 231 +- Pythonwin/Scintilla/src/Style.cxx | 208 +- Pythonwin/Scintilla/src/Style.h | 88 +- Pythonwin/Scintilla/src/StyleContext.cxx | 55 - Pythonwin/Scintilla/src/StyleContext.h | 179 - Pythonwin/Scintilla/src/UniConversion.cxx | 407 +- Pythonwin/Scintilla/src/UniConversion.h | 99 +- Pythonwin/Scintilla/src/UniqueString.cxx | 56 + Pythonwin/Scintilla/src/UniqueString.h | 46 + Pythonwin/Scintilla/src/ViewStyle.cxx | 729 +- Pythonwin/Scintilla/src/ViewStyle.h | 211 +- Pythonwin/Scintilla/src/WindowAccessor.cxx | 191 - Pythonwin/Scintilla/src/XPM.cxx | 337 +- Pythonwin/Scintilla/src/XPM.h | 120 +- Pythonwin/Scintilla/update.bat | 4 - Pythonwin/Scintilla/win32/DepGen.py | 45 + Pythonwin/Scintilla/win32/HanjaDic.cxx | 128 + Pythonwin/Scintilla/win32/HanjaDic.h | 22 + Pythonwin/Scintilla/win32/Margin.cur | Bin 326 -> 0 bytes Pythonwin/Scintilla/win32/PlatWin.cxx | 3824 ++++--- Pythonwin/Scintilla/win32/PlatWin.h | 91 + Pythonwin/Scintilla/win32/PlatformRes.h | 8 - Pythonwin/Scintilla/win32/SciLexer.vcxproj | 171 + Pythonwin/Scintilla/win32/SciTE.properties | 21 + Pythonwin/Scintilla/win32/ScintRes.rc | 19 +- Pythonwin/Scintilla/win32/Scintilla.vcxproj | 182 + Pythonwin/Scintilla/win32/ScintillaDLL.cxx | 35 + Pythonwin/Scintilla/win32/ScintillaWin.cxx | 3739 ++++--- Pythonwin/Scintilla/win32/ScintillaWin.h | 20 + Pythonwin/Scintilla/win32/deps.mak | 1991 ++++ Pythonwin/Scintilla/win32/makefile | 184 + Pythonwin/Scintilla/win32/nmdeps.mak | 1991 ++++ Pythonwin/Scintilla/win32/scintilla.mak | 524 +- Pythonwin/Scintilla/win32/scintilla_vc6.mak | 517 - Pythonwin/pywin/framework/app.py | 2 +- 279 files changed, 84562 insertions(+), 27380 deletions(-) delete mode 100644 Pythonwin/Scintilla/include/Accessor.h create mode 100644 Pythonwin/Scintilla/include/ILexer.h create mode 100644 Pythonwin/Scintilla/include/ILoader.h delete mode 100644 Pythonwin/Scintilla/include/KeyWords.h delete mode 100644 Pythonwin/Scintilla/include/PropSet.h delete mode 100644 Pythonwin/Scintilla/include/SString.h create mode 100644 Pythonwin/Scintilla/include/Sci_Position.h create mode 100644 Pythonwin/Scintilla/include/Scintilla.iface create mode 100644 Pythonwin/Scintilla/include/ScintillaWidget.h delete mode 100644 Pythonwin/Scintilla/include/WinDefs.h delete mode 100644 Pythonwin/Scintilla/include/WindowAccessor.h create mode 100644 Pythonwin/Scintilla/lexers/LexA68k.cxx rename Pythonwin/Scintilla/{src => lexers}/LexAPDL.cxx (94%) rename Pythonwin/Scintilla/{src => lexers}/LexASY.cxx (89%) rename Pythonwin/Scintilla/{src => lexers}/LexAU3.cxx (89%) rename Pythonwin/Scintilla/{src => lexers}/LexAVE.cxx (91%) create mode 100644 Pythonwin/Scintilla/lexers/LexAVS.cxx rename Pythonwin/Scintilla/{src => lexers}/LexAbaqus.cxx (89%) rename Pythonwin/Scintilla/{src => lexers}/LexAda.cxx (91%) create mode 100644 Pythonwin/Scintilla/lexers/LexAsm.cxx rename Pythonwin/Scintilla/{src => lexers}/LexAsn1.cxx (91%) create mode 100644 Pythonwin/Scintilla/lexers/LexBaan.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexBash.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexBasic.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexBatch.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexBibTeX.cxx rename Pythonwin/Scintilla/{src => lexers}/LexBullant.cxx (89%) create mode 100644 Pythonwin/Scintilla/lexers/LexCIL.cxx rename Pythonwin/Scintilla/{src => lexers}/LexCLW.cxx (92%) create mode 100644 Pythonwin/Scintilla/lexers/LexCOBOL.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexCPP.cxx rename Pythonwin/Scintilla/{src => lexers}/LexCSS.cxx (58%) rename Pythonwin/Scintilla/{src => lexers}/LexCaml.cxx (63%) rename Pythonwin/Scintilla/{src => lexers}/LexCmake.cxx (88%) create mode 100644 Pythonwin/Scintilla/lexers/LexCoffeeScript.cxx rename Pythonwin/Scintilla/{src => lexers}/LexConf.cxx (83%) rename Pythonwin/Scintilla/{src => lexers}/LexCrontab.cxx (90%) rename Pythonwin/Scintilla/{src => lexers}/LexCsound.cxx (91%) create mode 100644 Pythonwin/Scintilla/lexers/LexD.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexDMAP.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexDMIS.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexDataflex.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexDiff.cxx rename Pythonwin/Scintilla/{src/LexCPP.cxx => lexers/LexECL.cxx} (50%) create mode 100644 Pythonwin/Scintilla/lexers/LexEDIFACT.cxx rename Pythonwin/Scintilla/{src => lexers}/LexEScript.cxx (92%) rename Pythonwin/Scintilla/{src => lexers}/LexEiffel.cxx (88%) create mode 100644 Pythonwin/Scintilla/lexers/LexErlang.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexErrorList.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexFlagship.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexForth.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexFortran.cxx rename Pythonwin/Scintilla/{src => lexers}/LexGAP.cxx (89%) rename Pythonwin/Scintilla/{src => lexers}/LexGui4Cli.cxx (91%) rename Pythonwin/Scintilla/{src => lexers}/LexHTML.cxx (57%) create mode 100644 Pythonwin/Scintilla/lexers/LexHaskell.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexHex.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexHollywood.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexIndent.cxx rename Pythonwin/Scintilla/{src => lexers}/LexInno.cxx (69%) create mode 100644 Pythonwin/Scintilla/lexers/LexJSON.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexKVIrc.cxx rename Pythonwin/Scintilla/{src => lexers}/LexKix.cxx (85%) create mode 100644 Pythonwin/Scintilla/lexers/LexLaTeX.cxx rename Pythonwin/Scintilla/{src => lexers}/LexLisp.cxx (84%) rename Pythonwin/Scintilla/{src => lexers}/LexLout.cxx (91%) create mode 100644 Pythonwin/Scintilla/lexers/LexLua.cxx rename Pythonwin/Scintilla/{src => lexers}/LexMMIXAL.cxx (88%) rename Pythonwin/Scintilla/{src => lexers}/LexMPT.cxx (76%) rename Pythonwin/Scintilla/{src => lexers}/LexMSSQL.cxx (89%) rename Pythonwin/Scintilla/{src => lexers}/LexMagik.cxx (93%) create mode 100644 Pythonwin/Scintilla/lexers/LexMake.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexMarkdown.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexMatlab.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexMaxima.cxx rename Pythonwin/Scintilla/{src => lexers}/LexMetapost.cxx (91%) create mode 100644 Pythonwin/Scintilla/lexers/LexModula.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexMySQL.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexNim.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexNimrod.cxx rename Pythonwin/Scintilla/{src => lexers}/LexNsis.cxx (88%) create mode 100644 Pythonwin/Scintilla/lexers/LexNull.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexOScript.cxx rename Pythonwin/Scintilla/{src => lexers}/LexOpal.cxx (81%) rename Pythonwin/Scintilla/{src => lexers}/LexPB.cxx (93%) rename Pythonwin/Scintilla/{src => lexers}/LexPLM.cxx (85%) create mode 100644 Pythonwin/Scintilla/lexers/LexPO.cxx rename Pythonwin/Scintilla/{src => lexers}/LexPOV.cxx (95%) rename Pythonwin/Scintilla/{src => lexers}/LexPS.cxx (89%) create mode 100644 Pythonwin/Scintilla/lexers/LexPascal.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexPerl.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexPowerPro.cxx rename Pythonwin/Scintilla/{src => lexers}/LexPowerShell.cxx (57%) create mode 100644 Pythonwin/Scintilla/lexers/LexProgress.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexProps.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexPython.cxx rename Pythonwin/Scintilla/{src => lexers}/LexR.cxx (90%) create mode 100644 Pythonwin/Scintilla/lexers/LexRaku.cxx rename Pythonwin/Scintilla/{src => lexers}/LexRebol.cxx (94%) create mode 100644 Pythonwin/Scintilla/lexers/LexRegistry.cxx rename Pythonwin/Scintilla/{src => lexers}/LexRuby.cxx (64%) create mode 100644 Pythonwin/Scintilla/lexers/LexRust.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexSAS.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexSML.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexSQL.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexSTTXT.cxx rename Pythonwin/Scintilla/{src => lexers}/LexScriptol.cxx (84%) rename Pythonwin/Scintilla/{src => lexers}/LexSmalltalk.cxx (95%) create mode 100644 Pythonwin/Scintilla/lexers/LexSorcus.cxx rename Pythonwin/Scintilla/{src => lexers}/LexSpecman.cxx (92%) rename Pythonwin/Scintilla/{src => lexers}/LexSpice.cxx (84%) create mode 100644 Pythonwin/Scintilla/lexers/LexStata.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexTACL.cxx rename Pythonwin/Scintilla/{src => lexers}/LexTADS3.cxx (97%) rename Pythonwin/Scintilla/{src/LexPascal.cxx => lexers/LexTAL.cxx} (62%) create mode 100644 Pythonwin/Scintilla/lexers/LexTCL.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexTCMD.cxx rename Pythonwin/Scintilla/{src => lexers}/LexTeX.cxx (89%) create mode 100644 Pythonwin/Scintilla/lexers/LexTxt2tags.cxx rename Pythonwin/Scintilla/{src => lexers}/LexVB.cxx (81%) rename Pythonwin/Scintilla/{src => lexers}/LexVHDL.cxx (61%) create mode 100644 Pythonwin/Scintilla/lexers/LexVerilog.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexVisualProlog.cxx create mode 100644 Pythonwin/Scintilla/lexers/LexX12.cxx rename Pythonwin/Scintilla/{src => lexers}/LexYAML.cxx (68%) create mode 100644 Pythonwin/Scintilla/lexlib/Accessor.cxx create mode 100644 Pythonwin/Scintilla/lexlib/Accessor.h create mode 100644 Pythonwin/Scintilla/lexlib/CatalogueModules.h create mode 100644 Pythonwin/Scintilla/lexlib/CharacterCategory.cxx create mode 100644 Pythonwin/Scintilla/lexlib/CharacterCategory.h create mode 100644 Pythonwin/Scintilla/lexlib/CharacterSet.cxx create mode 100644 Pythonwin/Scintilla/lexlib/CharacterSet.h create mode 100644 Pythonwin/Scintilla/lexlib/DefaultLexer.cxx create mode 100644 Pythonwin/Scintilla/lexlib/DefaultLexer.h create mode 100644 Pythonwin/Scintilla/lexlib/LexAccessor.h create mode 100644 Pythonwin/Scintilla/lexlib/LexerBase.cxx create mode 100644 Pythonwin/Scintilla/lexlib/LexerBase.h create mode 100644 Pythonwin/Scintilla/lexlib/LexerModule.cxx create mode 100644 Pythonwin/Scintilla/lexlib/LexerModule.h create mode 100644 Pythonwin/Scintilla/lexlib/LexerNoExceptions.cxx create mode 100644 Pythonwin/Scintilla/lexlib/LexerNoExceptions.h create mode 100644 Pythonwin/Scintilla/lexlib/LexerSimple.cxx create mode 100644 Pythonwin/Scintilla/lexlib/LexerSimple.h create mode 100644 Pythonwin/Scintilla/lexlib/OptionSet.h create mode 100644 Pythonwin/Scintilla/lexlib/PropSetSimple.cxx create mode 100644 Pythonwin/Scintilla/lexlib/PropSetSimple.h create mode 100644 Pythonwin/Scintilla/lexlib/SparseState.h create mode 100644 Pythonwin/Scintilla/lexlib/StringCopy.h create mode 100644 Pythonwin/Scintilla/lexlib/StyleContext.cxx create mode 100644 Pythonwin/Scintilla/lexlib/StyleContext.h create mode 100644 Pythonwin/Scintilla/lexlib/SubStyles.h create mode 100644 Pythonwin/Scintilla/lexlib/WordList.cxx create mode 100644 Pythonwin/Scintilla/lexlib/WordList.h create mode 100644 Pythonwin/Scintilla/src/CaseConvert.cxx create mode 100644 Pythonwin/Scintilla/src/CaseConvert.h create mode 100644 Pythonwin/Scintilla/src/CaseFolder.cxx create mode 100644 Pythonwin/Scintilla/src/CaseFolder.h create mode 100644 Pythonwin/Scintilla/src/Catalogue.cxx create mode 100644 Pythonwin/Scintilla/src/Catalogue.h delete mode 100644 Pythonwin/Scintilla/src/CharacterSet.h create mode 100644 Pythonwin/Scintilla/src/DBCS.cxx create mode 100644 Pythonwin/Scintilla/src/DBCS.h delete mode 100644 Pythonwin/Scintilla/src/DocumentAccessor.cxx delete mode 100644 Pythonwin/Scintilla/src/DocumentAccessor.h create mode 100644 Pythonwin/Scintilla/src/EditModel.cxx create mode 100644 Pythonwin/Scintilla/src/EditModel.h create mode 100644 Pythonwin/Scintilla/src/EditView.cxx create mode 100644 Pythonwin/Scintilla/src/EditView.h create mode 100644 Pythonwin/Scintilla/src/ElapsedPeriod.h create mode 100644 Pythonwin/Scintilla/src/FontQuality.h create mode 100644 Pythonwin/Scintilla/src/IntegerRectangle.h delete mode 100644 Pythonwin/Scintilla/src/KeyWords.cxx delete mode 100644 Pythonwin/Scintilla/src/LexAsm.cxx delete mode 100644 Pythonwin/Scintilla/src/LexBaan.cxx delete mode 100644 Pythonwin/Scintilla/src/LexBash.cxx delete mode 100644 Pythonwin/Scintilla/src/LexBasic.cxx delete mode 100644 Pythonwin/Scintilla/src/LexD.cxx delete mode 100644 Pythonwin/Scintilla/src/LexErlang.cxx delete mode 100644 Pythonwin/Scintilla/src/LexFlagship.cxx delete mode 100644 Pythonwin/Scintilla/src/LexForth.cxx delete mode 100644 Pythonwin/Scintilla/src/LexFortran.cxx delete mode 100644 Pythonwin/Scintilla/src/LexGen.py delete mode 100644 Pythonwin/Scintilla/src/LexHaskell.cxx delete mode 100644 Pythonwin/Scintilla/src/LexLua.cxx delete mode 100644 Pythonwin/Scintilla/src/LexMatlab.cxx delete mode 100644 Pythonwin/Scintilla/src/LexMySQL.cxx delete mode 100644 Pythonwin/Scintilla/src/LexOthers.cxx delete mode 100644 Pythonwin/Scintilla/src/LexPerl.cxx delete mode 100644 Pythonwin/Scintilla/src/LexProgress.cxx delete mode 100644 Pythonwin/Scintilla/src/LexPython.cxx delete mode 100644 Pythonwin/Scintilla/src/LexSQL.cxx delete mode 100644 Pythonwin/Scintilla/src/LexTCL.cxx delete mode 100644 Pythonwin/Scintilla/src/LexVerilog.cxx create mode 100644 Pythonwin/Scintilla/src/MarginView.cxx create mode 100644 Pythonwin/Scintilla/src/MarginView.h create mode 100644 Pythonwin/Scintilla/src/PerLine.cxx create mode 100644 Pythonwin/Scintilla/src/PerLine.h create mode 100644 Pythonwin/Scintilla/src/Position.h delete mode 100644 Pythonwin/Scintilla/src/PropSet.cxx delete mode 100644 Pythonwin/Scintilla/src/SVector.h create mode 100644 Pythonwin/Scintilla/src/SciTE.properties create mode 100644 Pythonwin/Scintilla/src/Selection.cxx create mode 100644 Pythonwin/Scintilla/src/Selection.h create mode 100644 Pythonwin/Scintilla/src/SparseVector.h delete mode 100644 Pythonwin/Scintilla/src/StyleContext.cxx delete mode 100644 Pythonwin/Scintilla/src/StyleContext.h create mode 100644 Pythonwin/Scintilla/src/UniqueString.cxx create mode 100644 Pythonwin/Scintilla/src/UniqueString.h delete mode 100644 Pythonwin/Scintilla/src/WindowAccessor.cxx delete mode 100755 Pythonwin/Scintilla/update.bat create mode 100644 Pythonwin/Scintilla/win32/DepGen.py create mode 100644 Pythonwin/Scintilla/win32/HanjaDic.cxx create mode 100644 Pythonwin/Scintilla/win32/HanjaDic.h delete mode 100644 Pythonwin/Scintilla/win32/Margin.cur create mode 100644 Pythonwin/Scintilla/win32/PlatWin.h delete mode 100644 Pythonwin/Scintilla/win32/PlatformRes.h create mode 100644 Pythonwin/Scintilla/win32/SciLexer.vcxproj create mode 100644 Pythonwin/Scintilla/win32/SciTE.properties create mode 100644 Pythonwin/Scintilla/win32/Scintilla.vcxproj create mode 100644 Pythonwin/Scintilla/win32/ScintillaDLL.cxx create mode 100644 Pythonwin/Scintilla/win32/ScintillaWin.h create mode 100644 Pythonwin/Scintilla/win32/deps.mak create mode 100644 Pythonwin/Scintilla/win32/makefile create mode 100644 Pythonwin/Scintilla/win32/nmdeps.mak delete mode 100644 Pythonwin/Scintilla/win32/scintilla_vc6.mak diff --git a/CHANGES.txt b/CHANGES.txt index 1ff2bf9f2..f14663b68 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,7 @@ https://mhammond.github.io/pywin32_installers.html. Coming in build 309, as yet unreleased -------------------------------------- +* Pythonwin: Bumped Scintilla from 1.77 to 4.4.6. The full changelog can be found here: https://www.scintilla.org/ScintillaHistory.html * Fixed `ddeclient` and `ddeserver` demos import error (#2290, @Avasam) * The `EvtSubscribe_push` demo now actually demonstrates the callback action and the event context being filled. (#2281, @Avasam) * Fixed Pythonwin's editor failing due to invalid regex import (#2419, @Avasam) diff --git a/Pythonwin/Scintilla/License.txt b/Pythonwin/Scintilla/License.txt index cbe25b2fc..47c792655 100644 --- a/Pythonwin/Scintilla/License.txt +++ b/Pythonwin/Scintilla/License.txt @@ -2,19 +2,19 @@ License for Scintilla and SciTE Copyright 1998-2003 by Neil Hodgson -All Rights Reserved +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. +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 +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/Pythonwin/Scintilla/README b/Pythonwin/Scintilla/README index c66baf66a..618842b42 100644 --- a/Pythonwin/Scintilla/README +++ b/Pythonwin/Scintilla/README @@ -3,12 +3,19 @@ README for building of Scintilla and SciTE Scintilla can be built by itself. To build SciTE, Scintilla must first be built. +Lexers can be either compiled into Scintilla or built separately into a Lexilla +shared library. +A separate Lexilla is the preferred option and will become the only supported +direction in Scintilla 5.0. +See lexilla/src/README for information on building Lexilla. *** GTK+/Linux version *** -You must first have GTK+ 1.2 or later and GCC (3.1 or better) installed. -GTK+ 1.0x will not work and when it did it was very slow. +You must first have GTK+ 2.24 or later and GCC (7.1 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 +25,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 @@ -29,12 +36,8 @@ and make install as this location is compiled into the executable. The global properties file is installed at $prefix/share/scite/SciTEGlobal.properties. The language specific properties files are also installed into this directory. -To build Scintilla for GTK+ 1 rather than the default GTK+ 2, define GTK1 on -the make command line: - make GTK1=1 - To remove SciTE - make uninstall + sudo make uninstall To clean the object files which may be needed to change $prefix make clean @@ -44,26 +47,58 @@ The current make file only supports static linking between SciTE and Scintilla. *** Windows version *** -A C++ compiler is required. Visual Studio .NET 2008 is the development system -used for most development although Mingw32 3.1 is also supported. -Borland did work but the command lines are now too long and the most recent -Borland version does not work. For older versions such as version 5.02, add the -l option. +A C++ 17 compiler is required. +Visual Studio 2017 is the development system used for most development +although Mingw-w64 7.1 is also supported. + +There are versions of Scintilla with lexers (SciLexer.DLL) and without lexers +(Scintilla.DLL). Make builds both versions. To build Scintilla, make in the scintilla/win32 directory cd scintilla\win32 GCC: mingw32-make -VS .NET: nmake -f scintilla.mak -VC++ 6: nmake -f scintilla_vc6.mak -Borland: make -fscintilla.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 -Borland: make -fscite.mak +Visual C++: nmake -f scite.mak + +An executable SciTE will now be in scite/bin. + +*** GTK+/Windows version *** + +Mingw-w64 is known to work. Other compilers will probably not work. + +Only Scintilla will build with GTK+ on Windows. SciTE will not work. + +Make builds both a static library version of Scintilla with lexers (scintilla.a) and +a shared library without lexers (libscintilla.so or or libscintilla.dll). + +To build Scintilla, make in the scintilla/gtk directory + cd scintilla\gtk + mingw32-make + +*** macOS Cocoa version *** + +Xcode 9.2 or later 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. + +There are versions of Scintilla.framework with lexers (ScintillaFramework) and +without lexers (Scintilla). + +To build Scintilla, run xcodebuild in the scintilla/cocoa/ScintillaFramework or +scintilla/cocoa/Scintilla directory + + cd cocoa/Scintilla + or + cd cocoa/ScintillaFramework + + xcodebuild -An executable SciTE will now be in scite\bin. +*** Qt version *** -The Visual C++ 6.0 project (.dsp) files are no longer supported but are left -in the download for people that are prepared to update them. +See the qt/README file to build Scintilla with Qt. diff --git a/Pythonwin/Scintilla/README_pythonwin b/Pythonwin/Scintilla/README_pythonwin index 9a9ede15e..6ad4a6405 100644 --- a/Pythonwin/Scintilla/README_pythonwin +++ b/Pythonwin/Scintilla/README_pythonwin @@ -1,8 +1,13 @@ -This is a copy of Scintilla 1.77 used for Pythonwin. +This is a copy of Scintilla 4.4.6 used for Pythonwin. -Scintilla's home is www.scintilla.org +Scintilla's home is https://www.scintilla.org/ Only the sources relevant to Scintilla under Pythonwin are -included (plus the Scintilla licence and readme). For the -full set of Scintilla sources, including its documentation and -companion editor Scite, see www.scintilla.org. \ No newline at end of file +included (plus the Scintilla Licence.txt and README). +For the full set of Scintilla sources, including its documentation +and companion editor SciTE, see https://www.scintilla.org/. + +When updating the Scintilla source, also update the copyright year +in Pythonwin/pywin/framework/app.py and regenerate +Pythonwin/pywin/scintilla/scintillacon.py using h2py: +https://github.com/python/cpython/blob/3.8/Tools/scripts/h2py.py diff --git a/Pythonwin/Scintilla/include/Accessor.h b/Pythonwin/Scintilla/include/Accessor.h deleted file mode 100644 index d9db9c7bf..000000000 --- a/Pythonwin/Scintilla/include/Accessor.h +++ /dev/null @@ -1,79 +0,0 @@ -// Scintilla source code edit control -/** @file Accessor.h - ** Rapid easy access to contents of a Scintilla. - **/ -// Copyright 1998-2001 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8}; - -class Accessor; - -typedef bool (*PFNIsCommentLeader)(Accessor &styler, int pos, int len); - -/** - * Interface to data in a Scintilla. - */ -class Accessor { -protected: - enum {extremePosition=0x7FFFFFFF}; - /** @a bufferSize is a trade off between time taken to copy the characters - * and retrieval overhead. - * @a slopSize positions the buffer before the desired position - * in case there is some backtracking. */ - enum {bufferSize=4000, slopSize=bufferSize/8}; - char buf[bufferSize+1]; - int startPos; - int endPos; - int codePage; - - virtual bool InternalIsLeadByte(char ch)=0; - virtual void Fill(int position)=0; - -public: - Accessor() : startPos(extremePosition), endPos(0), codePage(0) {} - virtual ~Accessor() {} - char operator[](int position) { - if (position < startPos || position >= endPos) { - Fill(position); - } - return buf[position - startPos]; - } - /** Safe version of operator[], returning a defined value for invalid position. */ - char SafeGetCharAt(int position, char chDefault=' ') { - if (position < startPos || position >= endPos) { - Fill(position); - if (position < startPos || position >= endPos) { - // Position is outside range of document - return chDefault; - } - } - return buf[position - startPos]; - } - bool IsLeadByte(char ch) { - return codePage && InternalIsLeadByte(ch); - } - void SetCodePage(int codePage_) { codePage = codePage_; } - - virtual bool Match(int pos, const char *s)=0; - virtual char StyleAt(int position)=0; - virtual int GetLine(int position)=0; - virtual int LineStart(int line)=0; - virtual int LevelAt(int line)=0; - virtual int Length()=0; - virtual void Flush()=0; - virtual int GetLineState(int line)=0; - virtual int SetLineState(int line, int state)=0; - virtual int GetPropertyInt(const char *key, int defaultValue=0)=0; - virtual char *GetProperties()=0; - - // Style setting - virtual void StartAt(unsigned int start, char chMask=31)=0; - virtual void SetFlags(char chFlags_, char chWhile_)=0; - virtual unsigned int GetStartSegment()=0; - virtual void StartSegment(unsigned int pos)=0; - virtual void ColourTo(unsigned int pos, int chAttr)=0; - virtual void SetLevel(int line, int level)=0; - virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0; - virtual void IndicatorFill(int start, int end, int indicator, int value)=0; -}; diff --git a/Pythonwin/Scintilla/include/ILexer.h b/Pythonwin/Scintilla/include/ILexer.h new file mode 100644 index 000000000..bc9ee1ab5 --- /dev/null +++ b/Pythonwin/Scintilla/include/ILexer.h @@ -0,0 +1,85 @@ +// Scintilla source code edit control +/** @file ILexer.h + ** Interface between Scintilla and lexers. + **/ +// Copyright 1998-2010 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef ILEXER_H +#define ILEXER_H + +#include "Sci_Position.h" + +namespace Scintilla { + +enum { dvRelease4=2 }; + +class IDocument { +public: + virtual int SCI_METHOD Version() const = 0; + virtual void SCI_METHOD SetErrorStatus(int status) = 0; + virtual Sci_Position SCI_METHOD Length() const = 0; + virtual void SCI_METHOD GetCharRange(char *buffer, Sci_Position position, Sci_Position lengthRetrieve) const = 0; + virtual char SCI_METHOD StyleAt(Sci_Position position) const = 0; + virtual Sci_Position SCI_METHOD LineFromPosition(Sci_Position position) const = 0; + virtual Sci_Position SCI_METHOD LineStart(Sci_Position line) const = 0; + virtual int SCI_METHOD GetLevel(Sci_Position line) const = 0; + virtual int SCI_METHOD SetLevel(Sci_Position line, int level) = 0; + virtual int SCI_METHOD GetLineState(Sci_Position line) const = 0; + virtual int SCI_METHOD SetLineState(Sci_Position line, int state) = 0; + virtual void SCI_METHOD StartStyling(Sci_Position position) = 0; + virtual bool SCI_METHOD SetStyleFor(Sci_Position length, char style) = 0; + virtual bool SCI_METHOD SetStyles(Sci_Position length, const char *styles) = 0; + virtual void SCI_METHOD DecorationSetCurrentIndicator(int indicator) = 0; + virtual void SCI_METHOD DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength) = 0; + virtual void SCI_METHOD ChangeLexerState(Sci_Position start, Sci_Position end) = 0; + virtual int SCI_METHOD CodePage() const = 0; + virtual bool SCI_METHOD IsDBCSLeadByte(char ch) const = 0; + virtual const char * SCI_METHOD BufferPointer() = 0; + virtual int SCI_METHOD GetLineIndentation(Sci_Position line) = 0; + virtual Sci_Position SCI_METHOD LineEnd(Sci_Position line) const = 0; + virtual Sci_Position SCI_METHOD GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const = 0; + virtual int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const = 0; +}; + +enum { lvRelease4=2, lvRelease5=3 }; + +class ILexer4 { +public: + virtual int SCI_METHOD Version() const = 0; + virtual void SCI_METHOD Release() = 0; + virtual const char * SCI_METHOD PropertyNames() = 0; + virtual int SCI_METHOD PropertyType(const char *name) = 0; + virtual const char * SCI_METHOD DescribeProperty(const char *name) = 0; + virtual Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) = 0; + virtual const char * SCI_METHOD DescribeWordListSets() = 0; + virtual Sci_Position SCI_METHOD WordListSet(int n, const char *wl) = 0; + virtual void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) = 0; + virtual void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) = 0; + virtual void * SCI_METHOD PrivateCall(int operation, void *pointer) = 0; + virtual int SCI_METHOD LineEndTypesSupported() = 0; + virtual int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) = 0; + virtual int SCI_METHOD SubStylesStart(int styleBase) = 0; + virtual int SCI_METHOD SubStylesLength(int styleBase) = 0; + virtual int SCI_METHOD StyleFromSubStyle(int subStyle) = 0; + virtual int SCI_METHOD PrimaryStyleFromStyle(int style) = 0; + virtual void SCI_METHOD FreeSubStyles() = 0; + virtual void SCI_METHOD SetIdentifiers(int style, const char *identifiers) = 0; + virtual int SCI_METHOD DistanceToSecondaryStyles() = 0; + virtual const char * SCI_METHOD GetSubStyleBases() = 0; + 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; +}; + +class ILexer5 : public ILexer4 { +public: + virtual const char * SCI_METHOD GetName() = 0; + virtual int SCI_METHOD GetIdentifier() = 0; + virtual const char * SCI_METHOD PropertyGet(const char *key) = 0; +}; + +} + +#endif diff --git a/Pythonwin/Scintilla/include/ILoader.h b/Pythonwin/Scintilla/include/ILoader.h new file mode 100644 index 000000000..e989de873 --- /dev/null +++ b/Pythonwin/Scintilla/include/ILoader.h @@ -0,0 +1,21 @@ +// Scintilla source code edit control +/** @file ILoader.h + ** Interface for loading into a Scintilla document from a background thread. + **/ +// Copyright 1998-2017 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef ILOADER_H +#define ILOADER_H + +#include "Sci_Position.h" + +class ILoader { +public: + virtual int SCI_METHOD Release() = 0; + // Returns a status code from SC_STATUS_* + virtual int SCI_METHOD AddData(const char *data, Sci_Position length) = 0; + virtual void * SCI_METHOD ConvertToDocument() = 0; +}; + +#endif diff --git a/Pythonwin/Scintilla/include/KeyWords.h b/Pythonwin/Scintilla/include/KeyWords.h deleted file mode 100644 index 6abae5945..000000000 --- a/Pythonwin/Scintilla/include/KeyWords.h +++ /dev/null @@ -1,90 +0,0 @@ -// Scintilla source code edit control -/** @file KeyWords.h - ** Colourise for particular languages. - **/ -// Copyright 1998-2001 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle, - WordList *keywordlists[], Accessor &styler); - -/** - * A LexerModule is responsible for lexing and folding a particular language. - * The class maintains a list of LexerModules which can be searched to find a - * module appropriate to a particular language. - */ -class LexerModule { -protected: - const LexerModule *next; - int language; - LexerFunction fnLexer; - LexerFunction fnFolder; - const char * const * wordListDescriptions; - int styleBits; - - static const LexerModule *base; - static int nextLanguage; - -public: - const char *languageName; - LexerModule(int language_, - LexerFunction fnLexer_, - const char *languageName_=0, - LexerFunction fnFolder_=0, - const char * const wordListDescriptions_[] = NULL, - int styleBits_=5); - virtual ~LexerModule() { - } - int GetLanguage() const { return language; } - - // -1 is returned if no WordList information is available - int GetNumWordLists() const; - const char *GetWordListDescription(int index) const; - - int GetStyleBitsNeeded() const; - - virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle, - WordList *keywordlists[], Accessor &styler) const; - virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle, - WordList *keywordlists[], Accessor &styler) const; - static const LexerModule *Find(int language); - static const LexerModule *Find(const char *languageName); -}; - -#ifdef SCI_NAMESPACE -} -#endif - -/** - * Check if a character is a space. - * This is ASCII specific but is safe with chars >= 0x80. - */ -inline bool isspacechar(unsigned char ch) { - return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d)); -} - -inline bool iswordchar(char ch) { - return isascii(ch) && (isalnum(ch) || ch == '.' || ch == '_'); -} - -inline bool iswordstart(char ch) { - return isascii(ch) && (isalnum(ch) || ch == '_'); -} - -inline bool isoperator(char ch) { - if (isascii(ch) && isalnum(ch)) - return false; - // '.' left out as it is used to make up numbers - if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || - ch == '(' || ch == ')' || ch == '-' || ch == '+' || - ch == '=' || ch == '|' || ch == '{' || ch == '}' || - ch == '[' || ch == ']' || ch == ':' || ch == ';' || - ch == '<' || ch == '>' || ch == ',' || ch == '/' || - ch == '?' || ch == '!' || ch == '.' || ch == '~') - return true; - return false; -} diff --git a/Pythonwin/Scintilla/include/Platform.h b/Pythonwin/Scintilla/include/Platform.h index 98fd7e042..628611132 100644 --- a/Pythonwin/Scintilla/include/Platform.h +++ b/Pythonwin/Scintilla/include/Platform.h @@ -3,7 +3,7 @@ ** Interface to platform facilities. Also includes some basic utilities. ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows. **/ -// Copyright 1998-2003 by Neil Hodgson +// Copyright 1998-2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef PLATFORM_H @@ -13,13 +13,19 @@ // PLAT_GTK_WIN32 is defined additionally when running PLAT_GTK under Win32 // PLAT_WIN = Win32 API on Win32 OS // PLAT_WX is wxWindows on any supported platform +// PLAT_TK = Tcl/TK on Linux or Win32 #define PLAT_GTK 0 #define PLAT_GTK_WIN32 0 +#define PLAT_GTK_MACOSX 0 #define PLAT_MACOSX 0 #define PLAT_WIN 0 #define PLAT_WX 0 +#define PLAT_QT 0 #define PLAT_FOX 0 +#define PLAT_CURSES 0 +#define PLAT_TK 0 +#define PLAT_HAIKU 0 #if defined(FOX) #undef PLAT_FOX @@ -29,6 +35,22 @@ #undef PLAT_WX #define PLAT_WX 1 +#elif defined(CURSES) +#undef PLAT_CURSES +#define PLAT_CURSES 1 + +#elif defined(__HAIKU__) +#undef PLAT_HAIKU +#define PLAT_HAIKU 1 + +#elif defined(SCINTILLA_QT) +#undef PLAT_QT +#define PLAT_QT 1 + +#elif defined(TK) +#undef PLAT_TK +#define PLAT_TK 1 + #elif defined(GTK) #undef PLAT_GTK #define PLAT_GTK 1 @@ -38,7 +60,13 @@ #define PLAT_GTK_WIN32 1 #endif -#elif defined(MACOSX) +#if defined(__APPLE__) +#undef PLAT_GTK_MACOSX +#define PLAT_GTK_MACOSX 1 +#endif + +#elif defined(__APPLE__) + #undef PLAT_MACOSX #define PLAT_MACOSX 1 @@ -48,9 +76,10 @@ #endif -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif + +typedef float XYPOSITION; +typedef double XYACCUMULATOR; // Underlying the implementation of the platform classes are platform specific types. // Sometimes these need to be passed around by client code so they are defined here @@ -65,257 +94,285 @@ typedef void *IdlerID; /** * A geometric point class. - * Point is exactly the same as the Win32 POINT and GTK+ GdkPoint so can be used interchangeably. + * Point is similar to the Win32 POINT and GTK+ GdkPoint types. */ class Point { public: - int x; - int y; + XYPOSITION x; + XYPOSITION y; - explicit Point(int x_=0, int y_=0) : x(x_), y(y_) { + constexpr explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) noexcept : x(x_), y(y_) { } - // Other automatically defined methods (assignment, copy constructor, destructor) are fine + static constexpr Point FromInts(int x_, int y_) noexcept { + return Point(static_cast(x_), static_cast(y_)); + } + + constexpr bool operator!=(Point other) const noexcept { + return (x != other.x) || (y != other.y); + } - static Point FromLong(long lpoint); + constexpr Point operator+(Point other) const noexcept { + return Point(x + other.x, y + other.y); + } + + constexpr Point operator-(Point other) const noexcept { + return Point(x - other.x, y - other.y); + } + + // Other automatically defined methods (assignment, copy constructor, destructor) are fine }; /** * A geometric rectangle class. - * PRectangle is exactly the same as the Win32 RECT so can be used interchangeably. + * PRectangle is similar to Win32 RECT. * PRectangles contain their top and left sides, but not their right and bottom sides. */ class PRectangle { public: - int left; - int top; - int right; - int bottom; + XYPOSITION left; + XYPOSITION top; + XYPOSITION right; + XYPOSITION bottom; - PRectangle(int left_=0, int top_=0, int right_=0, int bottom_ = 0) : + constexpr explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) noexcept : left(left_), top(top_), right(right_), bottom(bottom_) { } + static constexpr PRectangle FromInts(int left_, int top_, int right_, int bottom_) noexcept { + return PRectangle(static_cast(left_), static_cast(top_), + static_cast(right_), static_cast(bottom_)); + } + // Other automatically defined methods (assignment, copy constructor, destructor) are fine - bool operator==(PRectangle &rc) { + constexpr bool operator==(const PRectangle &rc) const noexcept { return (rc.left == left) && (rc.right == right) && (rc.top == top) && (rc.bottom == bottom); } - bool Contains(Point pt) { + constexpr bool Contains(Point pt) const noexcept { return (pt.x >= left) && (pt.x <= right) && (pt.y >= top) && (pt.y <= bottom); } - bool Contains(PRectangle rc) { + constexpr bool ContainsWholePixel(Point pt) const noexcept { + // Does the rectangle contain all of the pixel to left/below the point + return (pt.x >= left) && ((pt.x+1) <= right) && + (pt.y >= top) && ((pt.y+1) <= bottom); + } + constexpr bool Contains(PRectangle rc) const noexcept { return (rc.left >= left) && (rc.right <= right) && (rc.top >= top) && (rc.bottom <= bottom); } - bool Intersects(PRectangle other) { + constexpr bool Intersects(PRectangle other) const noexcept { return (right > other.left) && (left < other.right) && (bottom > other.top) && (top < other.bottom); } - void Move(int xDelta, int yDelta) { + void Move(XYPOSITION xDelta, XYPOSITION yDelta) noexcept { left += xDelta; top += yDelta; right += xDelta; bottom += yDelta; } - int Width() { return right - left; } - int Height() { return bottom - top; } - bool Empty() { + constexpr XYPOSITION Width() const noexcept { return right - left; } + constexpr XYPOSITION Height() const noexcept { return bottom - top; } + constexpr bool Empty() const noexcept { return (Height() <= 0) || (Width() <= 0); } }; /** - * In some circumstances, including Win32 in paletted mode and GTK+, each colour - * must be allocated before use. The desired colours are held in the ColourDesired class, - * and after allocation the allocation entry is stored in the ColourAllocated class. In other - * circumstances, such as Win32 in true colour mode, the allocation process just copies - * the RGB values from the desired to the allocated class. - * As each desired colour requires allocation before it can be used, the ColourPair class - * holds both a ColourDesired and a ColourAllocated - * The Palette class is responsible for managing the palette of colours which contains a - * list of ColourPair objects and performs the allocation. - */ - -/** - * Holds a desired RGB colour. + * Holds an RGB colour with 8 bits for each component. */ +constexpr const float componentMaximum = 255.0f; class ColourDesired { - long co; + int co; public: - ColourDesired(long lcol=0) { - co = lcol; + constexpr explicit ColourDesired(int co_=0) noexcept : co(co_) { } - ColourDesired(unsigned int red, unsigned int green, unsigned int blue) { - Set(red, green, blue); + constexpr ColourDesired(unsigned int red, unsigned int green, unsigned int blue) noexcept : + co(red | (green << 8) | (blue << 16)) { } - bool operator==(const ColourDesired &other) const { + constexpr bool operator==(const ColourDesired &other) const noexcept { return co == other.co; } - void Set(long lcol) { - co = lcol; + constexpr int AsInteger() const noexcept { + return co; } - void Set(unsigned int red, unsigned int green, unsigned int blue) { - co = red | (green << 8) | (blue << 16); + // Red, green and blue values as bytes 0..255 + constexpr unsigned char GetRed() const noexcept { + return co & 0xff; } - - static inline unsigned int ValueOfHex(const char ch) { - if (ch >= '0' && ch <= '9') - return ch - '0'; - else if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 10; - else if (ch >= 'a' && ch <= 'f') - return ch - 'a' + 10; - else - return 0; + constexpr unsigned char GetGreen() const noexcept { + return (co >> 8) & 0xff; } - - void Set(const char *val) { - if (*val == '#') { - val++; - } - unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]); - unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]); - unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]); - Set(r, g, b); + constexpr unsigned char GetBlue() const noexcept { + return (co >> 16) & 0xff; } - long AsLong() const { - return co; + // Red, green and blue values as float 0..1.0 + constexpr float GetRedComponent() const noexcept { + return GetRed() / componentMaximum; + } + constexpr float GetGreenComponent() const noexcept { + return GetGreen() / componentMaximum; + } + constexpr float GetBlueComponent() const noexcept { + return GetBlue() / componentMaximum; } +}; - unsigned int GetRed() { - return co & 0xff; +/** +* Holds an RGBA colour. +*/ +class ColourAlpha : public ColourDesired { +public: + constexpr explicit ColourAlpha(int co_ = 0) noexcept : ColourDesired(co_) { } - unsigned int GetGreen() { - return (co >> 8) & 0xff; + constexpr ColourAlpha(unsigned int red, unsigned int green, unsigned int blue) noexcept : + ColourDesired(red | (green << 8) | (blue << 16)) { } - unsigned int GetBlue() { - return (co >> 16) & 0xff; + constexpr ColourAlpha(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) noexcept : + ColourDesired(red | (green << 8) | (blue << 16) | (alpha << 24)) { } -}; -/** - * Holds an allocated RGB colour which may be an approximation to the desired colour. - */ -class ColourAllocated { - long coAllocated; + constexpr ColourAlpha(ColourDesired cd, unsigned int alpha) noexcept : + ColourDesired(cd.AsInteger() | (alpha << 24)) { + } -public: + constexpr ColourDesired GetColour() const noexcept { + return ColourDesired(AsInteger() & 0xffffff); + } - ColourAllocated(long lcol=0) { - coAllocated = lcol; + constexpr unsigned char GetAlpha() const noexcept { + return (AsInteger() >> 24) & 0xff; } - void Set(long lcol) { - coAllocated = lcol; + constexpr float GetAlphaComponent() const noexcept { + return GetAlpha() / componentMaximum; } - long AsLong() const { - return coAllocated; + constexpr ColourAlpha MixedWith(ColourAlpha other) const noexcept { + const unsigned int red = (GetRed() + other.GetRed()) / 2; + const unsigned int green = (GetGreen() + other.GetGreen()) / 2; + const unsigned int blue = (GetBlue() + other.GetBlue()) / 2; + const unsigned int alpha = (GetAlpha() + other.GetAlpha()) / 2; + return ColourAlpha(red, green, blue, alpha); } }; /** - * Colour pairs hold a desired colour and an allocated colour. - */ -struct ColourPair { - ColourDesired desired; - ColourAllocated allocated; - - ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) { - desired = desired_; - allocated.Set(desired.AsLong()); - } - void Copy() { - allocated.Set(desired.AsLong()); +* Holds an element of a gradient with an RGBA colour and a relative position. +*/ +class ColourStop { +public: + float position; + ColourAlpha colour; + ColourStop(float position_, ColourAlpha colour_) noexcept : + position(position_), colour(colour_) { } }; -class Window; // Forward declaration for Palette - /** - * Colour palette management. + * Font management. */ -class Palette { - int used; - int size; - ColourPair *entries; -#if PLAT_GTK - void *allocatedPalette; // GdkColor * - int allocatedLen; -#endif - // Private so Palette objects can not be copied - Palette(const Palette &) {} - Palette &operator=(const Palette &) { return *this; } -public: -#if PLAT_WIN - void *hpal; -#endif - bool allowRealization; - - Palette(); - ~Palette(); - - void Release(); - /** - * This method either adds a colour to the list of wanted colours (want==true) - * or retrieves the allocated colour back to the ColourPair. - * This is one method to make it easier to keep the code for wanting and retrieving in sync. - */ - void WantFind(ColourPair &cp, bool want); +struct FontParameters { + const char *faceName; + float size; + int weight; + bool italic; + int extraFontFlag; + int technology; + int characterSet; + + FontParameters( + const char *faceName_, + float size_=10, + int weight_=400, + bool italic_=false, + int extraFontFlag_=0, + int technology_=0, + int characterSet_=0) noexcept : + + faceName(faceName_), + size(size_), + weight(weight_), + italic(italic_), + extraFontFlag(extraFontFlag_), + technology(technology_), + characterSet(characterSet_) + { + } - void Allocate(Window &w); }; -/** - * Font management. - */ class Font { protected: - FontID id; -#if PLAT_WX - int ascent; -#endif - // Private so Font objects can not be copied - Font(const Font &) {} - Font &operator=(const Font &) { id=0; return *this; } + FontID fid; public: - Font(); + Font() noexcept; + // Deleted so Font objects can not be copied + Font(const Font &) = delete; + Font(Font &&) = delete; + Font &operator=(const Font &) = delete; + Font &operator=(Font &&) = delete; virtual ~Font(); - virtual void Create(const char *faceName, int characterSet, int size, - bool bold, bool italic, bool extraFontFlag=false); + virtual void Create(const FontParameters &fp); virtual void Release(); - FontID GetID() { return id; } + FontID GetID() const noexcept { return fid; } // Alias another font - caller guarantees not to Release - void SetID(FontID id_) { id = id_; } + void SetID(FontID fid_) noexcept { fid = fid_; } friend class Surface; - friend class SurfaceImpl; + friend class SurfaceImpl; +}; + +class IScreenLine { +public: + virtual std::string_view Text() const = 0; + virtual size_t Length() const = 0; + virtual size_t RepresentationCount() const = 0; + virtual XYPOSITION Width() const = 0; + virtual XYPOSITION Height() const = 0; + virtual XYPOSITION TabWidth() const = 0; + virtual XYPOSITION TabWidthMinimumPixels() const = 0; + virtual const Font *FontOfPosition(size_t position) const = 0; + virtual XYPOSITION RepresentationWidth(size_t position) const = 0; + virtual XYPOSITION TabPositionAfter(XYPOSITION xPosition) const = 0; +}; + +struct Interval { + XYPOSITION left; + XYPOSITION right; +}; + +class IScreenLineLayout { +public: + virtual ~IScreenLineLayout() = default; + virtual size_t PositionFromX(XYPOSITION xDistance, bool charPosition) = 0; + virtual XYPOSITION XFromPosition(size_t caretPosition) = 0; + virtual std::vector FindRangeIntervals(size_t start, size_t end) = 0; }; /** * A surface abstracts a place to draw. */ class Surface { -private: - // Private so Surface objects can not be copied - Surface(const Surface &) {} - Surface &operator=(const Surface &) { return *this; } public: - Surface() {}; - virtual ~Surface() {}; - static Surface *Allocate(); + Surface() noexcept = default; + Surface(const Surface &) = delete; + Surface(Surface &&) = delete; + Surface &operator=(const Surface &) = delete; + Surface &operator=(Surface &&) = delete; + virtual ~Surface() {} + static Surface *Allocate(int technology); virtual void Init(WindowID wid)=0; virtual void Init(SurfaceID sid, WindowID wid)=0; @@ -323,96 +380,79 @@ class Surface { virtual void Release()=0; virtual bool Initialised()=0; - virtual void PenColour(ColourAllocated fore)=0; + virtual void PenColour(ColourDesired fore)=0; virtual int LogPixelsY()=0; virtual int DeviceHeightFont(int points)=0; virtual void MoveTo(int x_, int y_)=0; virtual void LineTo(int x_, int y_)=0; - virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0; - virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; - virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0; + virtual void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back)=0; + virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0; + virtual void FillRectangle(PRectangle rc, ColourDesired back)=0; virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0; - virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; - virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, - ColourAllocated outline, int alphaOutline, int flags)=0; - virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; + virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0; + virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, + ColourDesired outline, int alphaOutline, int flags)=0; + enum class GradientOptions { leftToRight, topToBottom }; + virtual void GradientRectangle(PRectangle rc, const std::vector &stops, GradientOptions options)=0; + virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0; + virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0; virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0; - virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; - virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; - virtual void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore)=0; - virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0; - virtual int WidthText(Font &font_, const char *s, int len)=0; - virtual int WidthChar(Font &font_, char ch)=0; - virtual int Ascent(Font &font_)=0; - virtual int Descent(Font &font_)=0; - virtual int InternalLeading(Font &font_)=0; - virtual int ExternalLeading(Font &font_)=0; - virtual int Height(Font &font_)=0; - virtual int AverageCharWidth(Font &font_)=0; - - virtual int SetPalette(Palette *pal, bool inBackGround)=0; + virtual std::unique_ptr Layout(const IScreenLine *screenLine) = 0; + + virtual void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) = 0; + virtual void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, std::string_view text, ColourDesired fore, ColourDesired back) = 0; + virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) = 0; + virtual void MeasureWidths(Font &font_, std::string_view text, XYPOSITION *positions) = 0; + virtual XYPOSITION WidthText(Font &font_, std::string_view text) = 0; + virtual XYPOSITION Ascent(Font &font_)=0; + virtual XYPOSITION Descent(Font &font_)=0; + virtual XYPOSITION InternalLeading(Font &font_)=0; + virtual XYPOSITION Height(Font &font_)=0; + virtual XYPOSITION AverageCharWidth(Font &font_)=0; + virtual void SetClip(PRectangle rc)=0; virtual void FlushCachedState()=0; virtual void SetUnicodeMode(bool unicodeMode_)=0; virtual void SetDBCSMode(int codePage)=0; + virtual void SetBidiR2L(bool bidiR2L_)=0; }; -/** - * A simple callback action passing one piece of untyped user data. - */ -typedef void (*CallBackAction)(void*); - /** * Class to hide the details of window manipulation. * Does not own the window which will normally have a longer life than this object. */ class Window { protected: - WindowID id; -#if PLAT_MACOSX - void *windowRef; - void *control; -#endif + WindowID wid; public: - Window() : id(0), cursorLast(cursorInvalid) { -#if PLAT_MACOSX - windowRef = 0; - control = 0; -#endif + Window() noexcept : wid(nullptr), cursorLast(cursorInvalid) { } - Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) { -#if PLAT_MACOSX - windowRef = 0; - control = 0; -#endif - } - virtual ~Window(); - Window &operator=(WindowID id_) { - id = id_; + Window(const Window &source) = delete; + Window(Window &&) = delete; + Window &operator=(WindowID wid_) noexcept { + wid = wid_; + cursorLast = cursorInvalid; return *this; } - WindowID GetID() const { return id; } - bool Created() const { return id != 0; } + Window &operator=(const Window &) = delete; + Window &operator=(Window &&) = delete; + virtual ~Window(); + WindowID GetID() const noexcept { return wid; } + bool Created() const noexcept { return wid != nullptr; } void Destroy(); - bool HasFocus(); - PRectangle GetPosition(); + PRectangle GetPosition() const; void SetPosition(PRectangle rc); - void SetPositionRelative(PRectangle rc, Window relativeTo); - PRectangle GetClientPosition(); + void SetPositionRelative(PRectangle rc, const Window *relativeTo); + PRectangle GetClientPosition() const; void Show(bool show=true); void InvalidateAll(); void InvalidateRectangle(PRectangle rc); virtual void SetFont(Font &font); enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand }; void SetCursor(Cursor curs); - void SetTitle(const char *s); PRectangle GetMonitorRect(Point pt); -#if PLAT_MACOSX - void SetWindow(void *ref) { windowRef = ref; }; - void SetControl(void *_control) { control = _control; }; -#endif private: Cursor cursorLast; }; @@ -421,14 +461,27 @@ class Window { * Listbox management. */ +// ScintillaBase implements IListBoxDelegate to receive ListBoxEvents from a ListBox + +struct ListBoxEvent { + enum class EventType { selectionChange, doubleClick } event; + ListBoxEvent(EventType event_) noexcept : event(event_) { + } +}; + +class IListBoxDelegate { +public: + virtual void ListNotify(ListBoxEvent *plbe)=0; +}; + class ListBox : public Window { public: - ListBox(); - virtual ~ListBox(); + ListBox() noexcept; + ~ListBox() override; static ListBox *Allocate(); - virtual void SetFont(Font &font)=0; - virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_)=0; + void SetFont(Font &font) override =0; + virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0; virtual void SetAverageCharWidth(int width)=0; virtual void SetVisibleRows(int rows)=0; virtual int GetVisibleRows() const=0; @@ -442,8 +495,9 @@ class ListBox : public Window { virtual int Find(const char *prefix)=0; virtual void GetValue(int n, char *value, int len)=0; virtual void RegisterImage(int type, const char *xpm_data)=0; + virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) = 0; virtual void ClearRegisteredImages()=0; - virtual void SetDoubleClickAction(CallBackAction, void *)=0; + virtual void SetDelegate(IListBoxDelegate *lbDelegate)=0; virtual void SetList(const char* list, char separator, char typesep)=0; }; @@ -451,29 +505,21 @@ class ListBox : public Window { * Menu management. */ class Menu { - MenuID id; + MenuID mid; public: - Menu(); - MenuID GetID() { return id; } + Menu() noexcept; + MenuID GetID() const noexcept { return mid; } void CreatePopUp(); void Destroy(); void Show(Point pt, Window &w); }; -class ElapsedTime { - long bigBit; - long littleBit; -public: - ElapsedTime(); - double Duration(bool reset=false); -}; - /** * Dynamic Library (DLL/SO/...) loading */ class DynamicLibrary { public: - virtual ~DynamicLibrary() {}; + virtual ~DynamicLibrary() = default; /// @return Pointer to function "name", or NULL on failure. virtual Function FindFunction(const char *name) = 0; @@ -485,71 +531,49 @@ class DynamicLibrary { static DynamicLibrary *Load(const char *modulePath); }; +#if defined(__clang__) +# if __has_feature(attribute_analyzer_noreturn) +# define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) +# else +# define CLANG_ANALYZER_NORETURN +# endif +#else +# define CLANG_ANALYZER_NORETURN +#endif + /** * Platform class used to retrieve system wide parameters such as double click speed * and chrome colour. Not a creatable object, more of a module with several functions. */ class Platform { - // Private so Platform objects can not be copied - Platform(const Platform &) {} - Platform &operator=(const Platform &) { return *this; } public: - // Should be private because no new Platforms are ever created - // but gcc warns about this - Platform() {} - ~Platform() {} + Platform() = default; + Platform(const Platform &) = delete; + Platform(Platform &&) = delete; + Platform &operator=(const Platform &) = delete; + Platform &operator=(Platform &&) = delete; + ~Platform() = default; static ColourDesired Chrome(); static ColourDesired ChromeHighlight(); static const char *DefaultFont(); static int DefaultFontSize(); static unsigned int DoubleClickTime(); - static bool MouseButtonBounce(); static void DebugDisplay(const char *s); - static bool IsKeyDown(int key); - static long SendScintilla( - WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0); - static long SendScintillaPointer( - WindowID w, unsigned int msg, unsigned long wParam=0, void *lParam=0); - static bool IsDBCSLeadByte(int codePage, char ch); - static int DBCSCharLength(int codePage, const char *s); - static int DBCSCharMaxLength(); - - // These are utility functions not really tied to a platform - static int Minimum(int a, int b); - static int Maximum(int a, int b); - // Next three assume 16 bit shorts and 32 bit longs - static long LongFromTwoShorts(short a,short b) { + static constexpr long LongFromTwoShorts(short a,short b) noexcept { return (a) | ((b) << 16); } - static short HighShortFromLong(long x) { - return static_cast(x >> 16); - } - static short LowShortFromLong(long x) { - return static_cast(x & 0xffff); - } + static void DebugPrintf(const char *format, ...); static bool ShowAssertionPopUps(bool assertionPopUps_); - static void Assert(const char *c, const char *file, int line); - static int Clamp(int val, int minVal, int maxVal); + static void Assert(const char *c, const char *file, int line) CLANG_ANALYZER_NORETURN; }; #ifdef NDEBUG #define PLATFORM_ASSERT(c) ((void)0) #else -#ifdef SCI_NAMESPACE #define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__)) -#else -#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__)) -#endif #endif -#ifdef SCI_NAMESPACE } -#endif - -// Shut up annoying Visual C++ warnings: -#ifdef _MSC_VER -#pragma warning(disable: 4244 4309 4514 4710) -#endif #endif diff --git a/Pythonwin/Scintilla/include/PropSet.h b/Pythonwin/Scintilla/include/PropSet.h deleted file mode 100644 index 91bc7072b..000000000 --- a/Pythonwin/Scintilla/include/PropSet.h +++ /dev/null @@ -1,104 +0,0 @@ -// Scintilla source code edit control -/** @file PropSet.h - ** A Java style properties file module. - **/ -// Copyright 1998-2002 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef PROPSET_H -#define PROPSET_H -#include "SString.h" - -bool EqualCaseInsensitive(const char *a, const char *b); - -bool isprefix(const char *target, const char *prefix); - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -struct Property { - unsigned int hash; - char *key; - char *val; - Property *next; - Property() : hash(0), key(0), val(0), next(0) {} -}; - -/** - */ -class PropSet { -protected: - enum { hashRoots=31 }; - Property *props[hashRoots]; - Property *enumnext; - int enumhash; - static unsigned int HashString(const char *s, size_t len) { - unsigned int ret = 0; - while (len--) { - ret <<= 4; - ret ^= *s; - s++; - } - return ret; - } - -public: - PropSet *superPS; - PropSet(); - ~PropSet(); - void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1); - void Set(const char *keyVal); - void Unset(const char *key, int lenKey=-1); - void SetMultiple(const char *s); - SString Get(const char *key) const; - SString GetExpanded(const char *key) const; - SString Expand(const char *withVars, int maxExpands=100) const; - int GetInt(const char *key, int defaultValue=0) const; - void Clear(); - char *ToString() const; // Caller must delete[] the return value - -private: - // copy-value semantics not implemented - PropSet(const PropSet ©); - void operator=(const PropSet &assign); -}; - -/** - */ -class WordList { -public: - // Each word contains at least one character - a empty word acts as sentinel at the end. - char **words; - char *list; - int len; - bool onlyLineEnds; ///< Delimited by any white space or only line ends - bool sorted; - int starts[256]; - WordList(bool onlyLineEnds_ = false) : - words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), - sorted(false) - {} - ~WordList() { Clear(); } - operator bool() { return len ? true : false; } - void Clear(); - void Set(const char *s); - bool InList(const char *s); - bool InListAbbreviated(const char *s, const char marker); -}; - -inline bool IsAlphabetic(unsigned int ch) { - return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z')); -} - -#ifdef SCI_NAMESPACE -} -#endif - -#ifdef _MSC_VER -// Visual C++ doesn't like the private copy idiom for disabling -// the default copy constructor and operator=, but it's fine. -#pragma warning(disable: 4511 4512) -#endif - -#endif diff --git a/Pythonwin/Scintilla/include/SString.h b/Pythonwin/Scintilla/include/SString.h deleted file mode 100644 index b770afebe..000000000 --- a/Pythonwin/Scintilla/include/SString.h +++ /dev/null @@ -1,289 +0,0 @@ -// SciTE - Scintilla based Text Editor -/** @file SString.h - ** A simple string class. - **/ -// Copyright 1998-2004 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef SSTRING_H -#define SSTRING_H - - -// These functions are implemented because each platform calls them something different. -int CompareCaseInsensitive(const char *a, const char *b); -int CompareNCaseInsensitive(const char *a, const char *b, size_t len); -bool EqualCaseInsensitive(const char *a, const char *b); - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -// Define another string class. -// While it would be 'better' to use std::string, that doubles the executable size. -// An SString may contain embedded nul characters. - -/** - * Base class from which the two other classes (SBuffer & SString) - * are derived. - */ -class SContainer { -public: - /** Type of string lengths (sizes) and positions (indexes). */ - typedef size_t lenpos_t; - /** Out of bounds value indicating that the string argument should be measured. */ - enum { measure_length=0xffffffffU}; - -protected: - char *s; ///< The C string - lenpos_t sSize; ///< The size of the buffer, less 1: ie. the maximum size of the string - - SContainer() : s(0), sSize(0) {} - ~SContainer() { - delete []s; // Suppose it was allocated using StringAllocate - s = 0; - sSize = 0; - } - /** Size of buffer. */ - lenpos_t size() const { - if (s) { - return sSize; - } else { - return 0; - } - } -public: - /** - * Allocate uninitialized memory big enough to fit a string of the given length. - * @return the pointer to the new string - */ - static char *StringAllocate(lenpos_t len); - /** - * Duplicate a buffer/C string. - * Allocate memory of the given size, or big enough to fit the string if length isn't given; - * then copy the given string in the allocated memory. - * @return the pointer to the new string - */ - static char *StringAllocate( - const char *s, ///< The string to duplicate - lenpos_t len=measure_length); ///< The length of memory to allocate. Optional. -}; - - -/** - * @brief A string buffer class. - * - * Main use is to ask an API the length of a string it can provide, - * then to allocate a buffer of the given size, and to provide this buffer - * to the API to put the string. - * This class is intended to be shortlived, to be transformed as SString - * as soon as it holds the string, so it has little members. - * Note: we assume the buffer is filled by the API. If the length can be shorter, - * we should set sLen to strlen(sb.ptr()) in related SString constructor and assignment. - */ -class SBuffer : protected SContainer { -public: - SBuffer(lenpos_t len) { - s = StringAllocate(len); - if (s) { - *s = '\0'; - sSize = len; - } else { - sSize = 0; - } - } -private: - /// Copy constructor - // Here only to be on the safe size, user should avoid returning SBuffer values. - SBuffer(const SBuffer &source) : SContainer() { - s = StringAllocate(source.s, source.sSize); - sSize = (s) ? source.sSize : 0; - } - /// Default assignment operator - // Same here, shouldn't be used - SBuffer &operator=(const SBuffer &source) { - if (this != &source) { - delete []s; - s = StringAllocate(source.s, source.sSize); - sSize = (s) ? source.sSize : 0; - } - return *this; - } -public: - /** Provide direct read/write access to buffer. */ - char *ptr() { - return s; - } - /** Ownership of the buffer have been taken, so release it. */ - void reset() { - s = 0; - sSize = 0; - } - /** Size of buffer. */ - lenpos_t size() const { - return SContainer::size(); - } -}; - - -/** - * @brief A simple string class. - * - * Hold the length of the string for quick operations, - * can have a buffer bigger than the string to avoid too many memory allocations and copies. - * May have embedded zeroes as a result of @a substitute, but relies too heavily on C string - * functions to allow reliable manipulations of these strings, other than simple appends, etc. - */ -class SString : protected SContainer { - lenpos_t sLen; ///< The size of the string in s - lenpos_t sizeGrowth; ///< Minimum growth size when appending strings - enum { sizeGrowthDefault = 64 }; - - bool grow(lenpos_t lenNew); - SString &assign(const char *sOther, lenpos_t sSize_=measure_length); - -public: - SString() : sLen(0), sizeGrowth(sizeGrowthDefault) {} - SString(const SString &source) : SContainer(), sizeGrowth(sizeGrowthDefault) { - s = StringAllocate(source.s, source.sLen); - sSize = sLen = (s) ? source.sLen : 0; - } - SString(const char *s_) : sizeGrowth(sizeGrowthDefault) { - s = StringAllocate(s_); - sSize = sLen = (s) ? strlen(s) : 0; - } - SString(SBuffer &buf) : sizeGrowth(sizeGrowthDefault) { - s = buf.ptr(); - sSize = sLen = buf.size(); - // Consumes the given buffer! - buf.reset(); - } - SString(const char *s_, lenpos_t first, lenpos_t last) : sizeGrowth(sizeGrowthDefault) { - // note: expects the "last" argument to point one beyond the range end (a la STL iterators) - s = StringAllocate(s_ + first, last - first); - sSize = sLen = (s) ? last - first : 0; - } - SString(int i); - SString(double d, int precision); - ~SString() { - sLen = 0; - } - void clear() { - if (s) { - *s = '\0'; - } - sLen = 0; - } - /** Size of buffer. */ - lenpos_t size() const { - return SContainer::size(); - } - /** Size of string in buffer. */ - lenpos_t length() const { - return sLen; - } - /** Read access to a character of the string. */ - char operator[](lenpos_t i) const { - return (s && i < sSize) ? s[i] : '\0'; - } - SString &operator=(const char *source) { - return assign(source); - } - SString &operator=(const SString &source) { - if (this != &source) { - assign(source.s, source.sLen); - } - return *this; - } - bool operator==(const SString &sOther) const; - bool operator!=(const SString &sOther) const { - return !operator==(sOther); - } - bool operator==(const char *sOther) const; - bool operator!=(const char *sOther) const { - return !operator==(sOther); - } - bool contains(char ch) const { - return (s && *s) ? strchr(s, ch) != 0 : false; - } - void setsizegrowth(lenpos_t sizeGrowth_) { - sizeGrowth = sizeGrowth_; - } - const char *c_str() const { - return s ? s : ""; - } - /** Give ownership of buffer to caller which must use delete[] to free buffer. */ - char *detach() { - char *sRet = s; - s = 0; - sSize = 0; - sLen = 0; - return sRet; - } - SString substr(lenpos_t subPos, lenpos_t subLen=measure_length) const; - SString &lowercase(lenpos_t subPos = 0, lenpos_t subLen=measure_length); - SString &uppercase(lenpos_t subPos = 0, lenpos_t subLen=measure_length); - SString &append(const char *sOther, lenpos_t sLenOther=measure_length, char sep = '\0'); - SString &operator+=(const char *sOther) { - return append(sOther, static_cast(measure_length)); - } - SString &operator+=(const SString &sOther) { - return append(sOther.s, sOther.sLen); - } - SString &operator+=(char ch) { - return append(&ch, 1); - } - SString &appendwithseparator(const char *sOther, char sep) { - return append(sOther, strlen(sOther), sep); - } - SString &insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther=measure_length); - - /** - * Remove @a len characters from the @a pos position, included. - * Characters at pos + len and beyond replace characters at pos. - * If @a len is 0, or greater than the length of the string - * starting at @a pos, the string is just truncated at @a pos. - */ - void remove(lenpos_t pos, lenpos_t len); - - SString &change(lenpos_t pos, char ch) { - if (pos < sLen) { // character changed must be in string bounds - *(s + pos) = ch; - } - return *this; - } - /** Read an integral numeric value from the string. */ - int value() const { - return s ? atoi(s) : 0; - } - bool startswith(const char *prefix); - bool endswith(const char *suffix); - int search(const char *sFind, lenpos_t start=0) const; - bool contains(const char *sFind) const { - return search(sFind) >= 0; - } - int substitute(char chFind, char chReplace); - int substitute(const char *sFind, const char *sReplace); - int remove(const char *sFind) { - return substitute(sFind, ""); - } -}; - - -/** - * Duplicate a C string. - * Allocate memory of the given size, or big enough to fit the string if length isn't given; - * then copy the given string in the allocated memory. - * @return the pointer to the new string - */ -inline char *StringDup( - const char *s, ///< The string to duplicate - SContainer::lenpos_t len=SContainer::measure_length) ///< The length of memory to allocate. Optional. -{ - return SContainer::StringAllocate(s, len); -} - -#ifdef SCI_NAMESPACE -} -#endif - -#endif diff --git a/Pythonwin/Scintilla/include/SciLexer.h b/Pythonwin/Scintilla/include/SciLexer.h index defd72cfa..d23e18e0c 100644 --- a/Pythonwin/Scintilla/include/SciLexer.h +++ b/Pythonwin/Scintilla/include/SciLexer.h @@ -1,19 +1,19 @@ -// Scintilla source code edit control +/* Scintilla source code edit control */ /** @file SciLexer.h ** Interface to the added lexer functions in the SciLexer version of the edit control. **/ -// Copyright 1998-2002 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. +/* Copyright 1998-2002 by Neil Hodgson + * The License.txt file describes the conditions under which this software may be distributed. */ -// Most of this file is automatically generated from the Scintilla.iface interface definition -// file which contains any comments about the definitions. HFacer.py does the generation. +/* Most of this file is automatically generated from the Scintilla.iface interface definition + * file which contains any comments about the definitions. HFacer.py does the generation. */ #ifndef SCILEXER_H #define SCILEXER_H -// SciLexer features - not in standard Scintilla +/* SciLexer features - not in standard Scintilla */ -//++Autogenerated -- start of section automatically generated from Scintilla.iface +/* ++Autogenerated -- start of section automatically generated from Scintilla.iface */ #define SCLEX_CONTAINER 0 #define SCLEX_NULL 1 #define SCLEX_PYTHON 2 @@ -103,6 +103,47 @@ #define SCLEX_POWERSHELL 88 #define SCLEX_MYSQL 89 #define SCLEX_PO 90 +#define SCLEX_TAL 91 +#define SCLEX_COBOL 92 +#define SCLEX_TACL 93 +#define SCLEX_SORCUS 94 +#define SCLEX_POWERPRO 95 +#define SCLEX_NIMROD 96 +#define SCLEX_SML 97 +#define SCLEX_MARKDOWN 98 +#define SCLEX_TXT2TAGS 99 +#define SCLEX_A68K 100 +#define SCLEX_MODULA 101 +#define SCLEX_COFFEESCRIPT 102 +#define SCLEX_TCMD 103 +#define SCLEX_AVS 104 +#define SCLEX_ECL 105 +#define SCLEX_OSCRIPT 106 +#define SCLEX_VISUALPROLOG 107 +#define SCLEX_LITERATEHASKELL 108 +#define SCLEX_STTXT 109 +#define SCLEX_KVIRC 110 +#define SCLEX_RUST 111 +#define SCLEX_DMAP 112 +#define SCLEX_AS 113 +#define SCLEX_DMIS 114 +#define SCLEX_REGISTRY 115 +#define SCLEX_BIBTEX 116 +#define SCLEX_SREC 117 +#define SCLEX_IHEX 118 +#define SCLEX_TEHEX 119 +#define SCLEX_JSON 120 +#define SCLEX_EDIFACT 121 +#define SCLEX_INDENT 122 +#define SCLEX_MAXIMA 123 +#define SCLEX_STATA 124 +#define SCLEX_SAS 125 +#define SCLEX_NIM 126 +#define SCLEX_CIL 127 +#define SCLEX_X12 128 +#define SCLEX_DATAFLEX 129 +#define SCLEX_HOLLYWOOD 130 +#define SCLEX_RAKU 131 #define SCLEX_AUTOMATIC 1000 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 @@ -120,6 +161,10 @@ #define SCE_P_STRINGEOL 13 #define SCE_P_WORD2 14 #define SCE_P_DECORATOR 15 +#define SCE_P_FSTRING 16 +#define SCE_P_FCHARACTER 17 +#define SCE_P_FTRIPLE 18 +#define SCE_P_FTRIPLEDOUBLE 19 #define SCE_C_DEFAULT 0 #define SCE_C_COMMENT 1 #define SCE_C_COMMENTLINE 2 @@ -140,6 +185,14 @@ #define SCE_C_COMMENTDOCKEYWORD 17 #define SCE_C_COMMENTDOCKEYWORDERROR 18 #define SCE_C_GLOBALCLASS 19 +#define SCE_C_STRINGRAW 20 +#define SCE_C_TRIPLEVERBATIM 21 +#define SCE_C_HASHQUOTEDSTRING 22 +#define SCE_C_PREPROCESSORCOMMENT 23 +#define SCE_C_PREPROCESSORCOMMENTDOC 24 +#define SCE_C_USERLITERAL 25 +#define SCE_C_TASKMARKER 26 +#define SCE_C_ESCAPESEQUENCE 27 #define SCE_D_DEFAULT 0 #define SCE_D_COMMENT 1 #define SCE_D_COMMENTLINE 2 @@ -158,6 +211,11 @@ #define SCE_D_COMMENTLINEDOC 15 #define SCE_D_COMMENTDOCKEYWORD 16 #define SCE_D_COMMENTDOCKEYWORDERROR 17 +#define SCE_D_STRINGB 18 +#define SCE_D_STRINGR 19 +#define SCE_D_WORD5 20 +#define SCE_D_WORD6 21 +#define SCE_D_WORD7 22 #define SCE_TCL_DEFAULT 0 #define SCE_TCL_COMMENT 1 #define SCE_TCL_COMMENTLINE 2 @@ -326,6 +384,16 @@ #define SCE_PL_SUB_PROTOTYPE 40 #define SCE_PL_FORMAT_IDENT 41 #define SCE_PL_FORMAT 42 +#define SCE_PL_STRING_VAR 43 +#define SCE_PL_XLAT 44 +#define SCE_PL_REGEX_VAR 54 +#define SCE_PL_REGSUBST_VAR 55 +#define SCE_PL_BACKTICKS_VAR 57 +#define SCE_PL_HERE_QQ_VAR 61 +#define SCE_PL_HERE_QX_VAR 62 +#define SCE_PL_STRING_QQ_VAR 64 +#define SCE_PL_STRING_QX_VAR 65 +#define SCE_PL_STRING_QR_VAR 66 #define SCE_RB_DEFAULT 0 #define SCE_RB_ERROR 1 #define SCE_RB_COMMENTLINE 2 @@ -379,6 +447,10 @@ #define SCE_B_ERROR 16 #define SCE_B_HEXNUMBER 17 #define SCE_B_BINNUMBER 18 +#define SCE_B_COMMENTBLOCK 19 +#define SCE_B_DOCLINE 20 +#define SCE_B_DOCBLOCK 21 +#define SCE_B_DOCKEYWORD 22 #define SCE_PROPS_DEFAULT 0 #define SCE_PROPS_COMMENT 1 #define SCE_PROPS_SECTION 2 @@ -390,6 +462,14 @@ #define SCE_L_TAG 2 #define SCE_L_MATH 3 #define SCE_L_COMMENT 4 +#define SCE_L_TAG2 5 +#define SCE_L_MATH2 6 +#define SCE_L_COMMENT2 7 +#define SCE_L_VERBATIM 8 +#define SCE_L_SHORTCMD 9 +#define SCE_L_SPECIAL 10 +#define SCE_L_CMDOPT 11 +#define SCE_L_ERROR 12 #define SCE_LUA_DEFAULT 0 #define SCE_LUA_COMMENT 1 #define SCE_LUA_COMMENTLINE 2 @@ -410,6 +490,7 @@ #define SCE_LUA_WORD6 17 #define SCE_LUA_WORD7 18 #define SCE_LUA_WORD8 19 +#define SCE_LUA_LABEL 20 #define SCE_ERR_DEFAULT 0 #define SCE_ERR_PYTHON 1 #define SCE_ERR_GCC 2 @@ -432,6 +513,26 @@ #define SCE_ERR_TIDY 19 #define SCE_ERR_JAVA_STACK 20 #define SCE_ERR_VALUE 21 +#define SCE_ERR_GCC_INCLUDED_FROM 22 +#define SCE_ERR_ESCSEQ 23 +#define SCE_ERR_ESCSEQ_UNKNOWN 24 +#define SCE_ERR_GCC_EXCERPT 25 +#define SCE_ERR_ES_BLACK 40 +#define SCE_ERR_ES_RED 41 +#define SCE_ERR_ES_GREEN 42 +#define SCE_ERR_ES_BROWN 43 +#define SCE_ERR_ES_BLUE 44 +#define SCE_ERR_ES_MAGENTA 45 +#define SCE_ERR_ES_CYAN 46 +#define SCE_ERR_ES_GRAY 47 +#define SCE_ERR_ES_DARK_GRAY 48 +#define SCE_ERR_ES_BRIGHT_RED 49 +#define SCE_ERR_ES_BRIGHT_GREEN 50 +#define SCE_ERR_ES_YELLOW 51 +#define SCE_ERR_ES_BRIGHT_BLUE 52 +#define SCE_ERR_ES_BRIGHT_MAGENTA 53 +#define SCE_ERR_ES_BRIGHT_CYAN 54 +#define SCE_ERR_ES_WHITE 55 #define SCE_BAT_DEFAULT 0 #define SCE_BAT_COMMENT 1 #define SCE_BAT_WORD 2 @@ -440,6 +541,17 @@ #define SCE_BAT_COMMAND 5 #define SCE_BAT_IDENTIFIER 6 #define SCE_BAT_OPERATOR 7 +#define SCE_TCMD_DEFAULT 0 +#define SCE_TCMD_COMMENT 1 +#define SCE_TCMD_WORD 2 +#define SCE_TCMD_LABEL 3 +#define SCE_TCMD_HIDE 4 +#define SCE_TCMD_COMMAND 5 +#define SCE_TCMD_IDENTIFIER 6 +#define SCE_TCMD_OPERATOR 7 +#define SCE_TCMD_ENVIRONMENT 8 +#define SCE_TCMD_EXPANSION 9 +#define SCE_TCMD_CLABEL 10 #define SCE_MAKE_DEFAULT 0 #define SCE_MAKE_COMMENT 1 #define SCE_MAKE_PREPROCESSOR 2 @@ -455,6 +567,10 @@ #define SCE_DIFF_DELETED 5 #define SCE_DIFF_ADDED 6 #define SCE_DIFF_CHANGED 7 +#define SCE_DIFF_PATCH_ADD 8 +#define SCE_DIFF_PATCH_DELETE 9 +#define SCE_DIFF_REMOVED_PATCH_ADD 10 +#define SCE_DIFF_REMOVED_PATCH_DELETE 11 #define SCE_CONF_DEFAULT 0 #define SCE_CONF_COMMENT 1 #define SCE_CONF_NUMBER 2 @@ -503,6 +619,20 @@ #define SCE_BAAN_IDENTIFIER 8 #define SCE_BAAN_STRINGEOL 9 #define SCE_BAAN_WORD2 10 +#define SCE_BAAN_WORD3 11 +#define SCE_BAAN_WORD4 12 +#define SCE_BAAN_WORD5 13 +#define SCE_BAAN_WORD6 14 +#define SCE_BAAN_WORD7 15 +#define SCE_BAAN_WORD8 16 +#define SCE_BAAN_WORD9 17 +#define SCE_BAAN_TABLEDEF 18 +#define SCE_BAAN_TABLESQL 19 +#define SCE_BAAN_FUNCTION 20 +#define SCE_BAAN_DOMDEF 21 +#define SCE_BAAN_FUNCDEF 22 +#define SCE_BAAN_OBJECTDEF 23 +#define SCE_BAAN_DEFINEDEF 24 #define SCE_LISP_DEFAULT 0 #define SCE_LISP_COMMENT 1 #define SCE_LISP_NUMBER 2 @@ -556,6 +686,14 @@ #define SCE_MATLAB_OPERATOR 6 #define SCE_MATLAB_IDENTIFIER 7 #define SCE_MATLAB_DOUBLEQUOTESTRING 8 +#define SCE_MAXIMA_OPERATOR 0 +#define SCE_MAXIMA_COMMANDENDING 1 +#define SCE_MAXIMA_COMMENT 2 +#define SCE_MAXIMA_NUMBER 3 +#define SCE_MAXIMA_STRING 4 +#define SCE_MAXIMA_COMMAND 5 +#define SCE_MAXIMA_VARIABLE 6 +#define SCE_MAXIMA_UNKNOWN 7 #define SCE_SCRIPTOL_DEFAULT 0 #define SCE_SCRIPTOL_WHITE 1 #define SCE_SCRIPTOL_COMMENTLINE 2 @@ -587,6 +725,7 @@ #define SCE_ASM_CHARACTER 12 #define SCE_ASM_STRINGEOL 13 #define SCE_ASM_EXTINSTRUCTION 14 +#define SCE_ASM_COMMENTDIRECTIVE 15 #define SCE_F_DEFAULT 0 #define SCE_F_COMMENT 1 #define SCE_F_NUMBER 2 @@ -624,6 +763,8 @@ #define SCE_CSS_EXTENDED_IDENTIFIER 19 #define SCE_CSS_EXTENDED_PSEUDOCLASS 20 #define SCE_CSS_EXTENDED_PSEUDOELEMENT 21 +#define SCE_CSS_MEDIA 22 +#define SCE_CSS_VARIABLE 23 #define SCE_POV_DEFAULT 0 #define SCE_POV_COMMENT 1 #define SCE_POV_COMMENTLINE 2 @@ -776,8 +917,19 @@ #define SCE_ERLANG_CHARACTER 9 #define SCE_ERLANG_MACRO 10 #define SCE_ERLANG_RECORD 11 -#define SCE_ERLANG_SEPARATOR 12 +#define SCE_ERLANG_PREPROC 12 #define SCE_ERLANG_NODE_NAME 13 +#define SCE_ERLANG_COMMENT_FUNCTION 14 +#define SCE_ERLANG_COMMENT_MODULE 15 +#define SCE_ERLANG_COMMENT_DOC 16 +#define SCE_ERLANG_COMMENT_DOC_MACRO 17 +#define SCE_ERLANG_ATOM_QUOTED 18 +#define SCE_ERLANG_MACRO_QUOTED 19 +#define SCE_ERLANG_RECORD_QUOTED 20 +#define SCE_ERLANG_NODE_NAME_QUOTED 21 +#define SCE_ERLANG_BIFS 22 +#define SCE_ERLANG_MODULES 23 +#define SCE_ERLANG_MODULES_ATT 24 #define SCE_ERLANG_UNKNOWN 31 #define SCE_MSSQL_DEFAULT 0 #define SCE_MSSQL_COMMENT 1 @@ -810,6 +962,11 @@ #define SCE_V_IDENTIFIER 11 #define SCE_V_STRINGEOL 12 #define SCE_V_USER 19 +#define SCE_V_COMMENT_WORD 20 +#define SCE_V_INPUT 21 +#define SCE_V_OUTPUT 22 +#define SCE_V_INOUT 23 +#define SCE_V_PORT_CONNECT 24 #define SCE_KIX_DEFAULT 0 #define SCE_KIX_COMMENT 1 #define SCE_KIX_STRING1 2 @@ -820,6 +977,7 @@ #define SCE_KIX_KEYWORD 7 #define SCE_KIX_FUNCTIONS 8 #define SCE_KIX_OPERATOR 9 +#define SCE_KIX_COMMENTSTREAM 10 #define SCE_KIX_IDENTIFIER 31 #define SCE_GC_DEFAULT 0 #define SCE_GC_COMMENTLINE 1 @@ -916,6 +1074,7 @@ #define SCE_VHDL_STDPACKAGE 12 #define SCE_VHDL_STDTYPE 13 #define SCE_VHDL_USERWORD 14 +#define SCE_VHDL_BLOCK_COMMENT 15 #define SCE_CAML_DEFAULT 0 #define SCE_CAML_IDENTIFIER 1 #define SCE_CAML_TAGNAME 2 @@ -926,6 +1085,7 @@ #define SCE_CAML_OPERATOR 7 #define SCE_CAML_NUMBER 8 #define SCE_CAML_CHAR 9 +#define SCE_CAML_WHITE 10 #define SCE_CAML_STRING 11 #define SCE_CAML_COMMENT 12 #define SCE_CAML_COMMENT1 13 @@ -948,6 +1108,12 @@ #define SCE_HA_COMMENTBLOCK 14 #define SCE_HA_COMMENTBLOCK2 15 #define SCE_HA_COMMENTBLOCK3 16 +#define SCE_HA_PRAGMA 17 +#define SCE_HA_PREPROCESSOR 18 +#define SCE_HA_STRINGEOL 19 +#define SCE_HA_RESERVED_OPERATOR 20 +#define SCE_HA_LITERATE_COMMENT 21 +#define SCE_HA_LITERATE_CODEDELIM 22 #define SCE_T3_DEFAULT 0 #define SCE_T3_X_DEFAULT 1 #define SCE_T3_PREPROCESSOR 2 @@ -1020,6 +1186,7 @@ #define SCE_SQL_USER3 21 #define SCE_SQL_USER4 22 #define SCE_SQL_QUOTEDIDENTIFIER 23 +#define SCE_SQL_QOPERATOR 24 #define SCE_ST_DEFAULT 0 #define SCE_ST_STRING 1 #define SCE_ST_NUMBER 2 @@ -1056,11 +1223,19 @@ #define SCE_FS_DATE 16 #define SCE_FS_STRINGEOL 17 #define SCE_FS_CONSTANT 18 -#define SCE_FS_ASM 19 -#define SCE_FS_LABEL 20 -#define SCE_FS_ERROR 21 -#define SCE_FS_HEXNUMBER 22 -#define SCE_FS_BINNUMBER 23 +#define SCE_FS_WORDOPERATOR 19 +#define SCE_FS_DISABLEDCODE 20 +#define SCE_FS_DEFAULT_C 21 +#define SCE_FS_COMMENTDOC_C 22 +#define SCE_FS_COMMENTLINEDOC_C 23 +#define SCE_FS_KEYWORD_C 24 +#define SCE_FS_KEYWORD2_C 25 +#define SCE_FS_NUMBER_C 26 +#define SCE_FS_STRING_C 27 +#define SCE_FS_PREPROCESSOR_C 28 +#define SCE_FS_OPERATOR_C 29 +#define SCE_FS_IDENTIFIER_C 30 +#define SCE_FS_STRINGEOL_C 31 #define SCE_CSOUND_DEFAULT 0 #define SCE_CSOUND_COMMENT 1 #define SCE_CSOUND_NUMBER 2 @@ -1083,7 +1258,7 @@ #define SCE_INNO_PARAMETER 3 #define SCE_INNO_SECTION 4 #define SCE_INNO_PREPROC 5 -#define SCE_INNO_PREPROC_INLINE 6 +#define SCE_INNO_INLINE_EXPANSION 6 #define SCE_INNO_COMMENT_PASCAL 7 #define SCE_INNO_KEYWORD_PASCAL 8 #define SCE_INNO_KEYWORD_USER 9 @@ -1144,38 +1319,19 @@ #define SCE_PLM_OPERATOR 5 #define SCE_PLM_CONTROL 6 #define SCE_PLM_KEYWORD 7 -#define SCE_4GL_DEFAULT 0 -#define SCE_4GL_NUMBER 1 -#define SCE_4GL_WORD 2 -#define SCE_4GL_STRING 3 -#define SCE_4GL_CHARACTER 4 -#define SCE_4GL_PREPROCESSOR 5 -#define SCE_4GL_OPERATOR 6 -#define SCE_4GL_IDENTIFIER 7 -#define SCE_4GL_BLOCK 8 -#define SCE_4GL_END 9 -#define SCE_4GL_COMMENT1 10 -#define SCE_4GL_COMMENT2 11 -#define SCE_4GL_COMMENT3 12 -#define SCE_4GL_COMMENT4 13 -#define SCE_4GL_COMMENT5 14 -#define SCE_4GL_COMMENT6 15 -#define SCE_4GL_DEFAULT_ 16 -#define SCE_4GL_NUMBER_ 17 -#define SCE_4GL_WORD_ 18 -#define SCE_4GL_STRING_ 19 -#define SCE_4GL_CHARACTER_ 20 -#define SCE_4GL_PREPROCESSOR_ 21 -#define SCE_4GL_OPERATOR_ 22 -#define SCE_4GL_IDENTIFIER_ 23 -#define SCE_4GL_BLOCK_ 24 -#define SCE_4GL_END_ 25 -#define SCE_4GL_COMMENT1_ 26 -#define SCE_4GL_COMMENT2_ 27 -#define SCE_4GL_COMMENT3_ 28 -#define SCE_4GL_COMMENT4_ 29 -#define SCE_4GL_COMMENT5_ 30 -#define SCE_4GL_COMMENT6_ 31 +#define SCE_ABL_DEFAULT 0 +#define SCE_ABL_NUMBER 1 +#define SCE_ABL_WORD 2 +#define SCE_ABL_STRING 3 +#define SCE_ABL_CHARACTER 4 +#define SCE_ABL_PREPROCESSOR 5 +#define SCE_ABL_OPERATOR 6 +#define SCE_ABL_IDENTIFIER 7 +#define SCE_ABL_BLOCK 8 +#define SCE_ABL_END 9 +#define SCE_ABL_COMMENT 10 +#define SCE_ABL_TASKMARKER 11 +#define SCE_ABL_LINECOMMENT 12 #define SCE_ABAQUS_DEFAULT 0 #define SCE_ABAQUS_COMMENT 1 #define SCE_ABAQUS_COMMENTBLOCK 2 @@ -1241,6 +1397,12 @@ #define SCE_POWERSHELL_KEYWORD 8 #define SCE_POWERSHELL_CMDLET 9 #define SCE_POWERSHELL_ALIAS 10 +#define SCE_POWERSHELL_FUNCTION 11 +#define SCE_POWERSHELL_USER1 12 +#define SCE_POWERSHELL_COMMENTSTREAM 13 +#define SCE_POWERSHELL_HERE_STRING 14 +#define SCE_POWERSHELL_HERE_CHARACTER 15 +#define SCE_POWERSHELL_COMMENTDOCKEYWORD 16 #define SCE_MYSQL_DEFAULT 0 #define SCE_MYSQL_COMMENT 1 #define SCE_MYSQL_COMMENTLINE 2 @@ -1262,6 +1424,8 @@ #define SCE_MYSQL_USER1 18 #define SCE_MYSQL_USER2 19 #define SCE_MYSQL_USER3 20 +#define SCE_MYSQL_HIDDENCOMMAND 21 +#define SCE_MYSQL_PLACEHOLDER 22 #define SCE_PO_DEFAULT 0 #define SCE_PO_COMMENT 1 #define SCE_PO_MSGID 2 @@ -1271,8 +1435,529 @@ #define SCE_PO_MSGCTXT 6 #define SCE_PO_MSGCTXT_TEXT 7 #define SCE_PO_FUZZY 8 -#define SCLEX_ASP 29 -#define SCLEX_PHP 30 -//--Autogenerated -- end of section automatically generated from Scintilla.iface +#define SCE_PO_PROGRAMMER_COMMENT 9 +#define SCE_PO_REFERENCE 10 +#define SCE_PO_FLAGS 11 +#define SCE_PO_MSGID_TEXT_EOL 12 +#define SCE_PO_MSGSTR_TEXT_EOL 13 +#define SCE_PO_MSGCTXT_TEXT_EOL 14 +#define SCE_PO_ERROR 15 +#define SCE_PAS_DEFAULT 0 +#define SCE_PAS_IDENTIFIER 1 +#define SCE_PAS_COMMENT 2 +#define SCE_PAS_COMMENT2 3 +#define SCE_PAS_COMMENTLINE 4 +#define SCE_PAS_PREPROCESSOR 5 +#define SCE_PAS_PREPROCESSOR2 6 +#define SCE_PAS_NUMBER 7 +#define SCE_PAS_HEXNUMBER 8 +#define SCE_PAS_WORD 9 +#define SCE_PAS_STRING 10 +#define SCE_PAS_STRINGEOL 11 +#define SCE_PAS_CHARACTER 12 +#define SCE_PAS_OPERATOR 13 +#define SCE_PAS_ASM 14 +#define SCE_SORCUS_DEFAULT 0 +#define SCE_SORCUS_COMMAND 1 +#define SCE_SORCUS_PARAMETER 2 +#define SCE_SORCUS_COMMENTLINE 3 +#define SCE_SORCUS_STRING 4 +#define SCE_SORCUS_STRINGEOL 5 +#define SCE_SORCUS_IDENTIFIER 6 +#define SCE_SORCUS_OPERATOR 7 +#define SCE_SORCUS_NUMBER 8 +#define SCE_SORCUS_CONSTANT 9 +#define SCE_POWERPRO_DEFAULT 0 +#define SCE_POWERPRO_COMMENTBLOCK 1 +#define SCE_POWERPRO_COMMENTLINE 2 +#define SCE_POWERPRO_NUMBER 3 +#define SCE_POWERPRO_WORD 4 +#define SCE_POWERPRO_WORD2 5 +#define SCE_POWERPRO_WORD3 6 +#define SCE_POWERPRO_WORD4 7 +#define SCE_POWERPRO_DOUBLEQUOTEDSTRING 8 +#define SCE_POWERPRO_SINGLEQUOTEDSTRING 9 +#define SCE_POWERPRO_LINECONTINUE 10 +#define SCE_POWERPRO_OPERATOR 11 +#define SCE_POWERPRO_IDENTIFIER 12 +#define SCE_POWERPRO_STRINGEOL 13 +#define SCE_POWERPRO_VERBATIM 14 +#define SCE_POWERPRO_ALTQUOTE 15 +#define SCE_POWERPRO_FUNCTION 16 +#define SCE_SML_DEFAULT 0 +#define SCE_SML_IDENTIFIER 1 +#define SCE_SML_TAGNAME 2 +#define SCE_SML_KEYWORD 3 +#define SCE_SML_KEYWORD2 4 +#define SCE_SML_KEYWORD3 5 +#define SCE_SML_LINENUM 6 +#define SCE_SML_OPERATOR 7 +#define SCE_SML_NUMBER 8 +#define SCE_SML_CHAR 9 +#define SCE_SML_STRING 11 +#define SCE_SML_COMMENT 12 +#define SCE_SML_COMMENT1 13 +#define SCE_SML_COMMENT2 14 +#define SCE_SML_COMMENT3 15 +#define SCE_MARKDOWN_DEFAULT 0 +#define SCE_MARKDOWN_LINE_BEGIN 1 +#define SCE_MARKDOWN_STRONG1 2 +#define SCE_MARKDOWN_STRONG2 3 +#define SCE_MARKDOWN_EM1 4 +#define SCE_MARKDOWN_EM2 5 +#define SCE_MARKDOWN_HEADER1 6 +#define SCE_MARKDOWN_HEADER2 7 +#define SCE_MARKDOWN_HEADER3 8 +#define SCE_MARKDOWN_HEADER4 9 +#define SCE_MARKDOWN_HEADER5 10 +#define SCE_MARKDOWN_HEADER6 11 +#define SCE_MARKDOWN_PRECHAR 12 +#define SCE_MARKDOWN_ULIST_ITEM 13 +#define SCE_MARKDOWN_OLIST_ITEM 14 +#define SCE_MARKDOWN_BLOCKQUOTE 15 +#define SCE_MARKDOWN_STRIKEOUT 16 +#define SCE_MARKDOWN_HRULE 17 +#define SCE_MARKDOWN_LINK 18 +#define SCE_MARKDOWN_CODE 19 +#define SCE_MARKDOWN_CODE2 20 +#define SCE_MARKDOWN_CODEBK 21 +#define SCE_TXT2TAGS_DEFAULT 0 +#define SCE_TXT2TAGS_LINE_BEGIN 1 +#define SCE_TXT2TAGS_STRONG1 2 +#define SCE_TXT2TAGS_STRONG2 3 +#define SCE_TXT2TAGS_EM1 4 +#define SCE_TXT2TAGS_EM2 5 +#define SCE_TXT2TAGS_HEADER1 6 +#define SCE_TXT2TAGS_HEADER2 7 +#define SCE_TXT2TAGS_HEADER3 8 +#define SCE_TXT2TAGS_HEADER4 9 +#define SCE_TXT2TAGS_HEADER5 10 +#define SCE_TXT2TAGS_HEADER6 11 +#define SCE_TXT2TAGS_PRECHAR 12 +#define SCE_TXT2TAGS_ULIST_ITEM 13 +#define SCE_TXT2TAGS_OLIST_ITEM 14 +#define SCE_TXT2TAGS_BLOCKQUOTE 15 +#define SCE_TXT2TAGS_STRIKEOUT 16 +#define SCE_TXT2TAGS_HRULE 17 +#define SCE_TXT2TAGS_LINK 18 +#define SCE_TXT2TAGS_CODE 19 +#define SCE_TXT2TAGS_CODE2 20 +#define SCE_TXT2TAGS_CODEBK 21 +#define SCE_TXT2TAGS_COMMENT 22 +#define SCE_TXT2TAGS_OPTION 23 +#define SCE_TXT2TAGS_PREPROC 24 +#define SCE_TXT2TAGS_POSTPROC 25 +#define SCE_A68K_DEFAULT 0 +#define SCE_A68K_COMMENT 1 +#define SCE_A68K_NUMBER_DEC 2 +#define SCE_A68K_NUMBER_BIN 3 +#define SCE_A68K_NUMBER_HEX 4 +#define SCE_A68K_STRING1 5 +#define SCE_A68K_OPERATOR 6 +#define SCE_A68K_CPUINSTRUCTION 7 +#define SCE_A68K_EXTINSTRUCTION 8 +#define SCE_A68K_REGISTER 9 +#define SCE_A68K_DIRECTIVE 10 +#define SCE_A68K_MACRO_ARG 11 +#define SCE_A68K_LABEL 12 +#define SCE_A68K_STRING2 13 +#define SCE_A68K_IDENTIFIER 14 +#define SCE_A68K_MACRO_DECLARATION 15 +#define SCE_A68K_COMMENT_WORD 16 +#define SCE_A68K_COMMENT_SPECIAL 17 +#define SCE_A68K_COMMENT_DOXYGEN 18 +#define SCE_MODULA_DEFAULT 0 +#define SCE_MODULA_COMMENT 1 +#define SCE_MODULA_DOXYCOMM 2 +#define SCE_MODULA_DOXYKEY 3 +#define SCE_MODULA_KEYWORD 4 +#define SCE_MODULA_RESERVED 5 +#define SCE_MODULA_NUMBER 6 +#define SCE_MODULA_BASENUM 7 +#define SCE_MODULA_FLOAT 8 +#define SCE_MODULA_STRING 9 +#define SCE_MODULA_STRSPEC 10 +#define SCE_MODULA_CHAR 11 +#define SCE_MODULA_CHARSPEC 12 +#define SCE_MODULA_PROC 13 +#define SCE_MODULA_PRAGMA 14 +#define SCE_MODULA_PRGKEY 15 +#define SCE_MODULA_OPERATOR 16 +#define SCE_MODULA_BADSTR 17 +#define SCE_COFFEESCRIPT_DEFAULT 0 +#define SCE_COFFEESCRIPT_COMMENT 1 +#define SCE_COFFEESCRIPT_COMMENTLINE 2 +#define SCE_COFFEESCRIPT_COMMENTDOC 3 +#define SCE_COFFEESCRIPT_NUMBER 4 +#define SCE_COFFEESCRIPT_WORD 5 +#define SCE_COFFEESCRIPT_STRING 6 +#define SCE_COFFEESCRIPT_CHARACTER 7 +#define SCE_COFFEESCRIPT_UUID 8 +#define SCE_COFFEESCRIPT_PREPROCESSOR 9 +#define SCE_COFFEESCRIPT_OPERATOR 10 +#define SCE_COFFEESCRIPT_IDENTIFIER 11 +#define SCE_COFFEESCRIPT_STRINGEOL 12 +#define SCE_COFFEESCRIPT_VERBATIM 13 +#define SCE_COFFEESCRIPT_REGEX 14 +#define SCE_COFFEESCRIPT_COMMENTLINEDOC 15 +#define SCE_COFFEESCRIPT_WORD2 16 +#define SCE_COFFEESCRIPT_COMMENTDOCKEYWORD 17 +#define SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR 18 +#define SCE_COFFEESCRIPT_GLOBALCLASS 19 +#define SCE_COFFEESCRIPT_STRINGRAW 20 +#define SCE_COFFEESCRIPT_TRIPLEVERBATIM 21 +#define SCE_COFFEESCRIPT_COMMENTBLOCK 22 +#define SCE_COFFEESCRIPT_VERBOSE_REGEX 23 +#define SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT 24 +#define SCE_COFFEESCRIPT_INSTANCEPROPERTY 25 +#define SCE_AVS_DEFAULT 0 +#define SCE_AVS_COMMENTBLOCK 1 +#define SCE_AVS_COMMENTBLOCKN 2 +#define SCE_AVS_COMMENTLINE 3 +#define SCE_AVS_NUMBER 4 +#define SCE_AVS_OPERATOR 5 +#define SCE_AVS_IDENTIFIER 6 +#define SCE_AVS_STRING 7 +#define SCE_AVS_TRIPLESTRING 8 +#define SCE_AVS_KEYWORD 9 +#define SCE_AVS_FILTER 10 +#define SCE_AVS_PLUGIN 11 +#define SCE_AVS_FUNCTION 12 +#define SCE_AVS_CLIPPROP 13 +#define SCE_AVS_USERDFN 14 +#define SCE_ECL_DEFAULT 0 +#define SCE_ECL_COMMENT 1 +#define SCE_ECL_COMMENTLINE 2 +#define SCE_ECL_NUMBER 3 +#define SCE_ECL_STRING 4 +#define SCE_ECL_WORD0 5 +#define SCE_ECL_OPERATOR 6 +#define SCE_ECL_CHARACTER 7 +#define SCE_ECL_UUID 8 +#define SCE_ECL_PREPROCESSOR 9 +#define SCE_ECL_UNKNOWN 10 +#define SCE_ECL_IDENTIFIER 11 +#define SCE_ECL_STRINGEOL 12 +#define SCE_ECL_VERBATIM 13 +#define SCE_ECL_REGEX 14 +#define SCE_ECL_COMMENTLINEDOC 15 +#define SCE_ECL_WORD1 16 +#define SCE_ECL_COMMENTDOCKEYWORD 17 +#define SCE_ECL_COMMENTDOCKEYWORDERROR 18 +#define SCE_ECL_WORD2 19 +#define SCE_ECL_WORD3 20 +#define SCE_ECL_WORD4 21 +#define SCE_ECL_WORD5 22 +#define SCE_ECL_COMMENTDOC 23 +#define SCE_ECL_ADDED 24 +#define SCE_ECL_DELETED 25 +#define SCE_ECL_CHANGED 26 +#define SCE_ECL_MOVED 27 +#define SCE_OSCRIPT_DEFAULT 0 +#define SCE_OSCRIPT_LINE_COMMENT 1 +#define SCE_OSCRIPT_BLOCK_COMMENT 2 +#define SCE_OSCRIPT_DOC_COMMENT 3 +#define SCE_OSCRIPT_PREPROCESSOR 4 +#define SCE_OSCRIPT_NUMBER 5 +#define SCE_OSCRIPT_SINGLEQUOTE_STRING 6 +#define SCE_OSCRIPT_DOUBLEQUOTE_STRING 7 +#define SCE_OSCRIPT_CONSTANT 8 +#define SCE_OSCRIPT_IDENTIFIER 9 +#define SCE_OSCRIPT_GLOBAL 10 +#define SCE_OSCRIPT_KEYWORD 11 +#define SCE_OSCRIPT_OPERATOR 12 +#define SCE_OSCRIPT_LABEL 13 +#define SCE_OSCRIPT_TYPE 14 +#define SCE_OSCRIPT_FUNCTION 15 +#define SCE_OSCRIPT_OBJECT 16 +#define SCE_OSCRIPT_PROPERTY 17 +#define SCE_OSCRIPT_METHOD 18 +#define SCE_VISUALPROLOG_DEFAULT 0 +#define SCE_VISUALPROLOG_KEY_MAJOR 1 +#define SCE_VISUALPROLOG_KEY_MINOR 2 +#define SCE_VISUALPROLOG_KEY_DIRECTIVE 3 +#define SCE_VISUALPROLOG_COMMENT_BLOCK 4 +#define SCE_VISUALPROLOG_COMMENT_LINE 5 +#define SCE_VISUALPROLOG_COMMENT_KEY 6 +#define SCE_VISUALPROLOG_COMMENT_KEY_ERROR 7 +#define SCE_VISUALPROLOG_IDENTIFIER 8 +#define SCE_VISUALPROLOG_VARIABLE 9 +#define SCE_VISUALPROLOG_ANONYMOUS 10 +#define SCE_VISUALPROLOG_NUMBER 11 +#define SCE_VISUALPROLOG_OPERATOR 12 +#define SCE_VISUALPROLOG_CHARACTER 13 +#define SCE_VISUALPROLOG_CHARACTER_TOO_MANY 14 +#define SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR 15 +#define SCE_VISUALPROLOG_STRING 16 +#define SCE_VISUALPROLOG_STRING_ESCAPE 17 +#define SCE_VISUALPROLOG_STRING_ESCAPE_ERROR 18 +#define SCE_VISUALPROLOG_STRING_EOL_OPEN 19 +#define SCE_VISUALPROLOG_STRING_VERBATIM 20 +#define SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL 21 +#define SCE_VISUALPROLOG_STRING_VERBATIM_EOL 22 +#define SCE_STTXT_DEFAULT 0 +#define SCE_STTXT_COMMENT 1 +#define SCE_STTXT_COMMENTLINE 2 +#define SCE_STTXT_KEYWORD 3 +#define SCE_STTXT_TYPE 4 +#define SCE_STTXT_FUNCTION 5 +#define SCE_STTXT_FB 6 +#define SCE_STTXT_NUMBER 7 +#define SCE_STTXT_HEXNUMBER 8 +#define SCE_STTXT_PRAGMA 9 +#define SCE_STTXT_OPERATOR 10 +#define SCE_STTXT_CHARACTER 11 +#define SCE_STTXT_STRING1 12 +#define SCE_STTXT_STRING2 13 +#define SCE_STTXT_STRINGEOL 14 +#define SCE_STTXT_IDENTIFIER 15 +#define SCE_STTXT_DATETIME 16 +#define SCE_STTXT_VARS 17 +#define SCE_STTXT_PRAGMAS 18 +#define SCE_KVIRC_DEFAULT 0 +#define SCE_KVIRC_COMMENT 1 +#define SCE_KVIRC_COMMENTBLOCK 2 +#define SCE_KVIRC_STRING 3 +#define SCE_KVIRC_WORD 4 +#define SCE_KVIRC_KEYWORD 5 +#define SCE_KVIRC_FUNCTION_KEYWORD 6 +#define SCE_KVIRC_FUNCTION 7 +#define SCE_KVIRC_VARIABLE 8 +#define SCE_KVIRC_NUMBER 9 +#define SCE_KVIRC_OPERATOR 10 +#define SCE_KVIRC_STRING_FUNCTION 11 +#define SCE_KVIRC_STRING_VARIABLE 12 +#define SCE_RUST_DEFAULT 0 +#define SCE_RUST_COMMENTBLOCK 1 +#define SCE_RUST_COMMENTLINE 2 +#define SCE_RUST_COMMENTBLOCKDOC 3 +#define SCE_RUST_COMMENTLINEDOC 4 +#define SCE_RUST_NUMBER 5 +#define SCE_RUST_WORD 6 +#define SCE_RUST_WORD2 7 +#define SCE_RUST_WORD3 8 +#define SCE_RUST_WORD4 9 +#define SCE_RUST_WORD5 10 +#define SCE_RUST_WORD6 11 +#define SCE_RUST_WORD7 12 +#define SCE_RUST_STRING 13 +#define SCE_RUST_STRINGR 14 +#define SCE_RUST_CHARACTER 15 +#define SCE_RUST_OPERATOR 16 +#define SCE_RUST_IDENTIFIER 17 +#define SCE_RUST_LIFETIME 18 +#define SCE_RUST_MACRO 19 +#define SCE_RUST_LEXERROR 20 +#define SCE_RUST_BYTESTRING 21 +#define SCE_RUST_BYTESTRINGR 22 +#define SCE_RUST_BYTECHARACTER 23 +#define SCE_DMAP_DEFAULT 0 +#define SCE_DMAP_COMMENT 1 +#define SCE_DMAP_NUMBER 2 +#define SCE_DMAP_STRING1 3 +#define SCE_DMAP_STRING2 4 +#define SCE_DMAP_STRINGEOL 5 +#define SCE_DMAP_OPERATOR 6 +#define SCE_DMAP_IDENTIFIER 7 +#define SCE_DMAP_WORD 8 +#define SCE_DMAP_WORD2 9 +#define SCE_DMAP_WORD3 10 +#define SCE_DMIS_DEFAULT 0 +#define SCE_DMIS_COMMENT 1 +#define SCE_DMIS_STRING 2 +#define SCE_DMIS_NUMBER 3 +#define SCE_DMIS_KEYWORD 4 +#define SCE_DMIS_MAJORWORD 5 +#define SCE_DMIS_MINORWORD 6 +#define SCE_DMIS_UNSUPPORTED_MAJOR 7 +#define SCE_DMIS_UNSUPPORTED_MINOR 8 +#define SCE_DMIS_LABEL 9 +#define SCE_REG_DEFAULT 0 +#define SCE_REG_COMMENT 1 +#define SCE_REG_VALUENAME 2 +#define SCE_REG_STRING 3 +#define SCE_REG_HEXDIGIT 4 +#define SCE_REG_VALUETYPE 5 +#define SCE_REG_ADDEDKEY 6 +#define SCE_REG_DELETEDKEY 7 +#define SCE_REG_ESCAPED 8 +#define SCE_REG_KEYPATH_GUID 9 +#define SCE_REG_STRING_GUID 10 +#define SCE_REG_PARAMETER 11 +#define SCE_REG_OPERATOR 12 +#define SCE_BIBTEX_DEFAULT 0 +#define SCE_BIBTEX_ENTRY 1 +#define SCE_BIBTEX_UNKNOWN_ENTRY 2 +#define SCE_BIBTEX_KEY 3 +#define SCE_BIBTEX_PARAMETER 4 +#define SCE_BIBTEX_VALUE 5 +#define SCE_BIBTEX_COMMENT 6 +#define SCE_HEX_DEFAULT 0 +#define SCE_HEX_RECSTART 1 +#define SCE_HEX_RECTYPE 2 +#define SCE_HEX_RECTYPE_UNKNOWN 3 +#define SCE_HEX_BYTECOUNT 4 +#define SCE_HEX_BYTECOUNT_WRONG 5 +#define SCE_HEX_NOADDRESS 6 +#define SCE_HEX_DATAADDRESS 7 +#define SCE_HEX_RECCOUNT 8 +#define SCE_HEX_STARTADDRESS 9 +#define SCE_HEX_ADDRESSFIELD_UNKNOWN 10 +#define SCE_HEX_EXTENDEDADDRESS 11 +#define SCE_HEX_DATA_ODD 12 +#define SCE_HEX_DATA_EVEN 13 +#define SCE_HEX_DATA_UNKNOWN 14 +#define SCE_HEX_DATA_EMPTY 15 +#define SCE_HEX_CHECKSUM 16 +#define SCE_HEX_CHECKSUM_WRONG 17 +#define SCE_HEX_GARBAGE 18 +#define SCE_JSON_DEFAULT 0 +#define SCE_JSON_NUMBER 1 +#define SCE_JSON_STRING 2 +#define SCE_JSON_STRINGEOL 3 +#define SCE_JSON_PROPERTYNAME 4 +#define SCE_JSON_ESCAPESEQUENCE 5 +#define SCE_JSON_LINECOMMENT 6 +#define SCE_JSON_BLOCKCOMMENT 7 +#define SCE_JSON_OPERATOR 8 +#define SCE_JSON_URI 9 +#define SCE_JSON_COMPACTIRI 10 +#define SCE_JSON_KEYWORD 11 +#define SCE_JSON_LDKEYWORD 12 +#define SCE_JSON_ERROR 13 +#define SCE_EDI_DEFAULT 0 +#define SCE_EDI_SEGMENTSTART 1 +#define SCE_EDI_SEGMENTEND 2 +#define SCE_EDI_SEP_ELEMENT 3 +#define SCE_EDI_SEP_COMPOSITE 4 +#define SCE_EDI_SEP_RELEASE 5 +#define SCE_EDI_UNA 6 +#define SCE_EDI_UNH 7 +#define SCE_EDI_BADSEGMENT 8 +#define SCE_STATA_DEFAULT 0 +#define SCE_STATA_COMMENT 1 +#define SCE_STATA_COMMENTLINE 2 +#define SCE_STATA_COMMENTBLOCK 3 +#define SCE_STATA_NUMBER 4 +#define SCE_STATA_OPERATOR 5 +#define SCE_STATA_IDENTIFIER 6 +#define SCE_STATA_STRING 7 +#define SCE_STATA_TYPE 8 +#define SCE_STATA_WORD 9 +#define SCE_STATA_GLOBAL_MACRO 10 +#define SCE_STATA_MACRO 11 +#define SCE_SAS_DEFAULT 0 +#define SCE_SAS_COMMENT 1 +#define SCE_SAS_COMMENTLINE 2 +#define SCE_SAS_COMMENTBLOCK 3 +#define SCE_SAS_NUMBER 4 +#define SCE_SAS_OPERATOR 5 +#define SCE_SAS_IDENTIFIER 6 +#define SCE_SAS_STRING 7 +#define SCE_SAS_TYPE 8 +#define SCE_SAS_WORD 9 +#define SCE_SAS_GLOBAL_MACRO 10 +#define SCE_SAS_MACRO 11 +#define SCE_SAS_MACRO_KEYWORD 12 +#define SCE_SAS_BLOCK_KEYWORD 13 +#define SCE_SAS_MACRO_FUNCTION 14 +#define SCE_SAS_STATEMENT 15 +#define SCE_NIM_DEFAULT 0 +#define SCE_NIM_COMMENT 1 +#define SCE_NIM_COMMENTDOC 2 +#define SCE_NIM_COMMENTLINE 3 +#define SCE_NIM_COMMENTLINEDOC 4 +#define SCE_NIM_NUMBER 5 +#define SCE_NIM_STRING 6 +#define SCE_NIM_CHARACTER 7 +#define SCE_NIM_WORD 8 +#define SCE_NIM_TRIPLE 9 +#define SCE_NIM_TRIPLEDOUBLE 10 +#define SCE_NIM_BACKTICKS 11 +#define SCE_NIM_FUNCNAME 12 +#define SCE_NIM_STRINGEOL 13 +#define SCE_NIM_NUMERROR 14 +#define SCE_NIM_OPERATOR 15 +#define SCE_NIM_IDENTIFIER 16 +#define SCE_CIL_DEFAULT 0 +#define SCE_CIL_COMMENT 1 +#define SCE_CIL_COMMENTLINE 2 +#define SCE_CIL_WORD 3 +#define SCE_CIL_WORD2 4 +#define SCE_CIL_WORD3 5 +#define SCE_CIL_STRING 6 +#define SCE_CIL_LABEL 7 +#define SCE_CIL_OPERATOR 8 +#define SCE_CIL_IDENTIFIER 9 +#define SCE_CIL_STRINGEOL 10 +#define SCE_X12_DEFAULT 0 +#define SCE_X12_BAD 1 +#define SCE_X12_ENVELOPE 2 +#define SCE_X12_FUNCTIONGROUP 3 +#define SCE_X12_TRANSACTIONSET 4 +#define SCE_X12_SEGMENTHEADER 5 +#define SCE_X12_SEGMENTEND 6 +#define SCE_X12_SEP_ELEMENT 7 +#define SCE_X12_SEP_SUBELEMENT 8 +#define SCE_DF_DEFAULT 0 +#define SCE_DF_IDENTIFIER 1 +#define SCE_DF_METATAG 2 +#define SCE_DF_IMAGE 3 +#define SCE_DF_COMMENTLINE 4 +#define SCE_DF_PREPROCESSOR 5 +#define SCE_DF_PREPROCESSOR2 6 +#define SCE_DF_NUMBER 7 +#define SCE_DF_HEXNUMBER 8 +#define SCE_DF_WORD 9 +#define SCE_DF_STRING 10 +#define SCE_DF_STRINGEOL 11 +#define SCE_DF_SCOPEWORD 12 +#define SCE_DF_OPERATOR 13 +#define SCE_DF_ICODE 14 +#define SCE_HOLLYWOOD_DEFAULT 0 +#define SCE_HOLLYWOOD_COMMENT 1 +#define SCE_HOLLYWOOD_COMMENTBLOCK 2 +#define SCE_HOLLYWOOD_NUMBER 3 +#define SCE_HOLLYWOOD_KEYWORD 4 +#define SCE_HOLLYWOOD_STDAPI 5 +#define SCE_HOLLYWOOD_PLUGINAPI 6 +#define SCE_HOLLYWOOD_PLUGINMETHOD 7 +#define SCE_HOLLYWOOD_STRING 8 +#define SCE_HOLLYWOOD_STRINGBLOCK 9 +#define SCE_HOLLYWOOD_PREPROCESSOR 10 +#define SCE_HOLLYWOOD_OPERATOR 11 +#define SCE_HOLLYWOOD_IDENTIFIER 12 +#define SCE_HOLLYWOOD_CONSTANT 13 +#define SCE_HOLLYWOOD_HEXNUMBER 14 +#define SCE_RAKU_DEFAULT 0 +#define SCE_RAKU_ERROR 1 +#define SCE_RAKU_COMMENTLINE 2 +#define SCE_RAKU_COMMENTEMBED 3 +#define SCE_RAKU_POD 4 +#define SCE_RAKU_CHARACTER 5 +#define SCE_RAKU_HEREDOC_Q 6 +#define SCE_RAKU_HEREDOC_QQ 7 +#define SCE_RAKU_STRING 8 +#define SCE_RAKU_STRING_Q 9 +#define SCE_RAKU_STRING_QQ 10 +#define SCE_RAKU_STRING_Q_LANG 11 +#define SCE_RAKU_STRING_VAR 12 +#define SCE_RAKU_REGEX 13 +#define SCE_RAKU_REGEX_VAR 14 +#define SCE_RAKU_ADVERB 15 +#define SCE_RAKU_NUMBER 16 +#define SCE_RAKU_PREPROCESSOR 17 +#define SCE_RAKU_OPERATOR 18 +#define SCE_RAKU_WORD 19 +#define SCE_RAKU_FUNCTION 20 +#define SCE_RAKU_IDENTIFIER 21 +#define SCE_RAKU_TYPEDEF 22 +#define SCE_RAKU_MU 23 +#define SCE_RAKU_POSITIONAL 24 +#define SCE_RAKU_ASSOCIATIVE 25 +#define SCE_RAKU_CALLABLE 26 +#define SCE_RAKU_GRAMMAR 27 +#define SCE_RAKU_CLASS 28 +/* --Autogenerated -- end of section automatically generated from Scintilla.iface */ #endif diff --git a/Pythonwin/Scintilla/include/Sci_Position.h b/Pythonwin/Scintilla/include/Sci_Position.h new file mode 100644 index 000000000..abd0f3408 --- /dev/null +++ b/Pythonwin/Scintilla/include/Sci_Position.h @@ -0,0 +1,29 @@ +// Scintilla source code edit control +/** @file Sci_Position.h + ** Define the Sci_Position type used in Scintilla's external interfaces. + ** These need to be available to clients written in C so are not in a C++ namespace. + **/ +// Copyright 2015 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef SCI_POSITION_H +#define SCI_POSITION_H + +#include + +// Basic signed type used throughout interface +typedef ptrdiff_t Sci_Position; + +// Unsigned variant used for ILexer::Lex and ILexer::Fold +typedef size_t Sci_PositionU; + +// For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE +typedef long Sci_PositionCR; + +#ifdef _WIN32 + #define SCI_METHOD __stdcall +#else + #define SCI_METHOD +#endif + +#endif diff --git a/Pythonwin/Scintilla/include/Scintilla.h b/Pythonwin/Scintilla/include/Scintilla.h index 7dca10ae4..acde9a5f9 100644 --- a/Pythonwin/Scintilla/include/Scintilla.h +++ b/Pythonwin/Scintilla/include/Scintilla.h @@ -1,44 +1,46 @@ -// Scintilla source code edit control +/* Scintilla source code edit control */ /** @file Scintilla.h ** Interface to the edit control. **/ -// Copyright 1998-2003 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. +/* Copyright 1998-2003 by Neil Hodgson + * The License.txt file describes the conditions under which this software may be distributed. */ -// Most of this file is automatically generated from the Scintilla.iface interface definition -// file which contains any comments about the definitions. HFacer.py does the generation. +/* Most of this file is automatically generated from the Scintilla.iface interface definition + * file which contains any comments about the definitions. HFacer.py does the generation. */ #ifndef SCINTILLA_H #define SCINTILLA_H -#if LCCWIN -typedef BOOL bool; +#ifdef __cplusplus +extern "C" { #endif -#if PLAT_WIN -// Return false on failure: -bool Scintilla_RegisterClasses(void *hInstance); -bool Scintilla_ReleaseResources(); +#if defined(_WIN32) +/* Return false on failure: */ +int Scintilla_RegisterClasses(void *hInstance); +int Scintilla_ReleaseResources(void); #endif -int Scintilla_LinkLexers(); +int Scintilla_LinkLexers(void); -// Here should be placed typedefs for uptr_t, an unsigned integer type large enough to -// hold a pointer and sptr_t, a signed integer large enough to hold a pointer. -// May need to be changed for 64 bit platforms. -#if _MSC_VER >= 1300 -#include -#endif -#ifdef MAXULONG_PTR -typedef ULONG_PTR uptr_t; -typedef LONG_PTR sptr_t; -#else -typedef unsigned long uptr_t; -typedef long sptr_t; +#ifdef __cplusplus +} #endif +// Include header that defines basic numeric types. +#include + +// Define uptr_t, an unsigned integer type large enough to hold a pointer. +typedef uintptr_t uptr_t; +// Define sptr_t, a signed integer large enough to hold a pointer. +typedef intptr_t sptr_t; + +#include "Sci_Position.h" + typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam); -//++Autogenerated -- start of section automatically generated from Scintilla.iface +#ifndef SCI_DISABLE_AUTOGENERATED + +/* ++Autogenerated -- start of section automatically generated from Scintilla.iface */ #define INVALID_POSITION -1 #define SCI_START 2000 #define SCI_OPTIONAL_START 3000 @@ -46,7 +48,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_ADDTEXT 2001 #define SCI_ADDSTYLEDTEXT 2002 #define SCI_INSERTTEXT 2003 +#define SCI_CHANGEINSERTION 2672 #define SCI_CLEARALL 2004 +#define SCI_DELETERANGE 2645 #define SCI_CLEARDOCUMENTSTYLE 2005 #define SCI_GETLENGTH 2006 #define SCI_GETCHARAT 2007 @@ -61,12 +65,19 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_CANREDO 2016 #define SCI_MARKERLINEFROMHANDLE 2017 #define SCI_MARKERDELETEHANDLE 2018 +#define SCI_MARKERHANDLEFROMLINE 2732 +#define SCI_MARKERNUMBERFROMLINE 2733 #define SCI_GETUNDOCOLLECTION 2019 #define SCWS_INVISIBLE 0 #define SCWS_VISIBLEALWAYS 1 #define SCWS_VISIBLEAFTERINDENT 2 +#define SCWS_VISIBLEONLYININDENT 3 #define SCI_GETVIEWWS 2020 #define SCI_SETVIEWWS 2021 +#define SCTD_LONGARROW 0 +#define SCTD_STRIKEOUT 1 +#define SCI_GETTABDRAWMODE 2698 +#define SCI_SETTABDRAWMODE 2699 #define SCI_POSITIONFROMPOINT 2022 #define SCI_POSITIONFROMPOINTCLOSE 2023 #define SCI_GOTOLINE 2024 @@ -86,10 +97,24 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETBUFFEREDDRAW 2035 #define SCI_SETTABWIDTH 2036 #define SCI_GETTABWIDTH 2121 +#define SCI_SETTABMINIMUMWIDTH 2724 +#define SCI_GETTABMINIMUMWIDTH 2725 +#define SCI_CLEARTABSTOPS 2675 +#define SCI_ADDTABSTOP 2676 +#define SCI_GETNEXTTABSTOP 2677 #define SC_CP_UTF8 65001 -#define SC_CP_DBCS 1 #define SCI_SETCODEPAGE 2037 -#define SCI_SETUSEPALETTE 2039 +#define SC_IME_WINDOWED 0 +#define SC_IME_INLINE 1 +#define SCI_GETIMEINTERACTION 2678 +#define SCI_SETIMEINTERACTION 2679 +#define SC_ALPHA_TRANSPARENT 0 +#define SC_ALPHA_OPAQUE 255 +#define SC_ALPHA_NOALPHA 256 +#define SC_CURSORNORMAL -1 +#define SC_CURSORARROW 2 +#define SC_CURSORWAIT 4 +#define SC_CURSORREVERSEARROW 7 #define MARKER_MAX 31 #define SC_MARK_CIRCLE 0 #define SC_MARK_ROUNDRECT 1 @@ -119,6 +144,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MARK_PIXMAP 25 #define SC_MARK_FULLRECT 26 #define SC_MARK_LEFTRECT 27 +#define SC_MARK_AVAILABLE 28 +#define SC_MARK_UNDERLINE 29 +#define SC_MARK_RGBAIMAGE 30 +#define SC_MARK_BOOKMARK 31 +#define SC_MARK_VERTICALBOOKMARK 32 #define SC_MARK_CHARACTER 10000 #define SC_MARKNUM_FOLDEREND 25 #define SC_MARKNUM_FOLDEROPENMID 26 @@ -131,6 +161,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_MARKERDEFINE 2040 #define SCI_MARKERSETFORE 2041 #define SCI_MARKERSETBACK 2042 +#define SCI_MARKERSETBACKSELECTED 2292 +#define SCI_MARKERENABLEHIGHLIGHT 2293 #define SCI_MARKERADD 2043 #define SCI_MARKERDELETE 2044 #define SCI_MARKERDELETEALL 2045 @@ -140,10 +172,14 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_MARKERDEFINEPIXMAP 2049 #define SCI_MARKERADDSET 2466 #define SCI_MARKERSETALPHA 2476 +#define SC_MAX_MARGIN 4 #define SC_MARGIN_SYMBOL 0 #define SC_MARGIN_NUMBER 1 #define SC_MARGIN_BACK 2 #define SC_MARGIN_FORE 3 +#define SC_MARGIN_TEXT 4 +#define SC_MARGIN_RTEXT 5 +#define SC_MARGIN_COLOUR 6 #define SCI_SETMARGINTYPEN 2240 #define SCI_GETMARGINTYPEN 2241 #define SCI_SETMARGINWIDTHN 2242 @@ -152,6 +188,12 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETMARGINMASKN 2245 #define SCI_SETMARGINSENSITIVEN 2246 #define SCI_GETMARGINSENSITIVEN 2247 +#define SCI_SETMARGINCURSORN 2248 +#define SCI_GETMARGINCURSORN 2249 +#define SCI_SETMARGINBACKN 2250 +#define SCI_GETMARGINBACKN 2251 +#define SCI_SETMARGINS 2252 +#define SCI_GETMARGINS 2253 #define STYLE_DEFAULT 32 #define STYLE_LINENUMBER 33 #define STYLE_BRACELIGHT 34 @@ -159,6 +201,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define STYLE_CONTROLCHAR 36 #define STYLE_INDENTGUIDE 37 #define STYLE_CALLTIP 38 +#define STYLE_FOLDDISPLAYTEXT 39 #define STYLE_LASTPREDEFINED 39 #define STYLE_MAX 255 #define SC_CHARSET_ANSI 0 @@ -172,6 +215,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_CHARSET_MAC 77 #define SC_CHARSET_OEM 255 #define SC_CHARSET_RUSSIAN 204 +#define SC_CHARSET_OEM866 866 #define SC_CHARSET_CYRILLIC 1251 #define SC_CHARSET_SHIFTJIS 128 #define SC_CHARSET_SYMBOL 2 @@ -195,6 +239,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_CASE_MIXED 0 #define SC_CASE_UPPER 1 #define SC_CASE_LOWER 2 +#define SC_CASE_CAMEL 3 #define SCI_STYLEGETFORE 2481 #define SCI_STYLEGETBACK 2482 #define SCI_STYLEGETBOLD 2483 @@ -209,6 +254,14 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_STYLEGETCHANGEABLE 2492 #define SCI_STYLEGETHOTSPOT 2493 #define SCI_STYLESETCASE 2060 +#define SC_FONT_SIZE_MULTIPLIER 100 +#define SCI_STYLESETSIZEFRACTIONAL 2061 +#define SCI_STYLEGETSIZEFRACTIONAL 2062 +#define SC_WEIGHT_NORMAL 400 +#define SC_WEIGHT_SEMIBOLD 600 +#define SC_WEIGHT_BOLD 700 +#define SCI_STYLESETWEIGHT 2063 +#define SCI_STYLEGETWEIGHT 2064 #define SCI_STYLESETCHARACTERSET 2066 #define SCI_STYLESETHOTSPOT 2409 #define SCI_SETSELFORE 2067 @@ -226,6 +279,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETCARETPERIOD 2075 #define SCI_SETCARETPERIOD 2076 #define SCI_SETWORDCHARS 2077 +#define SCI_GETWORDCHARS 2646 +#define SCI_SETCHARACTERCATEGORYOPTIMIZATION 2720 +#define SCI_GETCHARACTERCATEGORYOPTIMIZATION 2721 #define SCI_BEGINUNDOACTION 2078 #define SCI_ENDUNDOACTION 2079 #define INDIC_PLAIN 0 @@ -236,22 +292,47 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDIC_HIDDEN 5 #define INDIC_BOX 6 #define INDIC_ROUNDBOX 7 -#define INDIC_MAX 31 +#define INDIC_STRAIGHTBOX 8 +#define INDIC_DASH 9 +#define INDIC_DOTS 10 +#define INDIC_SQUIGGLELOW 11 +#define INDIC_DOTBOX 12 +#define INDIC_SQUIGGLEPIXMAP 13 +#define INDIC_COMPOSITIONTHICK 14 +#define INDIC_COMPOSITIONTHIN 15 +#define INDIC_FULLBOX 16 +#define INDIC_TEXTFORE 17 +#define INDIC_POINT 18 +#define INDIC_POINTCHARACTER 19 +#define INDIC_GRADIENT 20 +#define INDIC_GRADIENTCENTRE 21 #define INDIC_CONTAINER 8 -#define INDIC0_MASK 0x20 -#define INDIC1_MASK 0x40 -#define INDIC2_MASK 0x80 -#define INDICS_MASK 0xE0 +#define INDIC_IME 32 +#define INDIC_IME_MAX 35 +#define INDIC_MAX 35 +#define INDICATOR_CONTAINER 8 +#define INDICATOR_IME 32 +#define INDICATOR_IME_MAX 35 +#define INDICATOR_MAX 35 #define SCI_INDICSETSTYLE 2080 #define SCI_INDICGETSTYLE 2081 #define SCI_INDICSETFORE 2082 #define SCI_INDICGETFORE 2083 #define SCI_INDICSETUNDER 2510 #define SCI_INDICGETUNDER 2511 +#define SCI_INDICSETHOVERSTYLE 2680 +#define SCI_INDICGETHOVERSTYLE 2681 +#define SCI_INDICSETHOVERFORE 2682 +#define SCI_INDICGETHOVERFORE 2683 +#define SC_INDICVALUEBIT 0x1000000 +#define SC_INDICVALUEMASK 0xFFFFFF +#define SC_INDICFLAG_VALUEFORE 1 +#define SCI_INDICSETFLAGS 2684 +#define SCI_INDICGETFLAGS 2685 #define SCI_SETWHITESPACEFORE 2084 #define SCI_SETWHITESPACEBACK 2085 -#define SCI_SETSTYLEBITS 2090 -#define SCI_GETSTYLEBITS 2091 +#define SCI_SETWHITESPACESIZE 2086 +#define SCI_GETWHITESPACESIZE 2087 #define SCI_SETLINESTATE 2092 #define SCI_GETLINESTATE 2093 #define SCI_GETMAXLINESTATE 2094 @@ -259,6 +340,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETCARETLINEVISIBLE 2096 #define SCI_GETCARETLINEBACK 2097 #define SCI_SETCARETLINEBACK 2098 +#define SCI_GETCARETLINEFRAME 2704 +#define SCI_SETCARETLINEFRAME 2705 #define SCI_STYLESETCHANGEABLE 2099 #define SCI_AUTOCSHOW 2100 #define SCI_AUTOCCANCEL 2101 @@ -297,6 +380,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETLINEINDENTATION 2127 #define SCI_GETLINEINDENTPOSITION 2128 #define SCI_GETCOLUMN 2129 +#define SCI_COUNTCHARACTERS 2633 +#define SCI_COUNTCODEUNITS 2715 #define SCI_SETHSCROLLBAR 2130 #define SCI_GETHSCROLLBAR 2131 #define SC_IV_NONE 0 @@ -310,13 +395,13 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETLINEENDPOSITION 2136 #define SCI_GETCODEPAGE 2137 #define SCI_GETCARETFORE 2138 -#define SCI_GETUSEPALETTE 2139 #define SCI_GETREADONLY 2140 #define SCI_SETCURRENTPOS 2141 #define SCI_SETSELECTIONSTART 2142 #define SCI_GETSELECTIONSTART 2143 #define SCI_SETSELECTIONEND 2144 #define SCI_GETSELECTIONEND 2145 +#define SCI_SETEMPTYSELECTION 2556 #define SCI_SETPRINTMAGNIFICATION 2146 #define SCI_GETPRINTMAGNIFICATION 2147 #define SC_PRINT_NORMAL 0 @@ -324,13 +409,16 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_PRINT_BLACKONWHITE 2 #define SC_PRINT_COLOURONWHITE 3 #define SC_PRINT_COLOURONWHITEDEFAULTBG 4 +#define SC_PRINT_SCREENCOLOURS 5 #define SCI_SETPRINTCOLOURMODE 2148 #define SCI_GETPRINTCOLOURMODE 2149 -#define SCFIND_WHOLEWORD 2 -#define SCFIND_MATCHCASE 4 +#define SCFIND_NONE 0x0 +#define SCFIND_WHOLEWORD 0x2 +#define SCFIND_MATCHCASE 0x4 #define SCFIND_WORDSTART 0x00100000 #define SCFIND_REGEXP 0x00200000 #define SCFIND_POSIX 0x00400000 +#define SCFIND_CXX11REGEX 0x00800000 #define SCI_FINDTEXT 2150 #define SCI_FORMATRANGE 2151 #define SCI_GETFIRSTVISIBLELINE 2152 @@ -351,6 +439,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_POSITIONFROMLINE 2167 #define SCI_LINESCROLL 2168 #define SCI_SCROLLCARET 2169 +#define SCI_SCROLLRANGE 2569 #define SCI_REPLACESEL 2170 #define SCI_SETREADONLY 2171 #define SCI_NULL 2172 @@ -373,8 +462,16 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETCARETWIDTH 2189 #define SCI_SETTARGETSTART 2190 #define SCI_GETTARGETSTART 2191 +#define SCI_SETTARGETSTARTVIRTUALSPACE 2728 +#define SCI_GETTARGETSTARTVIRTUALSPACE 2729 #define SCI_SETTARGETEND 2192 #define SCI_GETTARGETEND 2193 +#define SCI_SETTARGETENDVIRTUALSPACE 2730 +#define SCI_GETTARGETENDVIRTUALSPACE 2731 +#define SCI_SETTARGETRANGE 2686 +#define SCI_GETTARGETTEXT 2687 +#define SCI_TARGETFROMSELECTION 2287 +#define SCI_TARGETWHOLEDOCUMENT 2690 #define SCI_REPLACETARGET 2194 #define SCI_REPLACETARGETRE 2195 #define SCI_SEARCHINTARGET 2197 @@ -384,21 +481,19 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_CALLTIPCANCEL 2201 #define SCI_CALLTIPACTIVE 2202 #define SCI_CALLTIPPOSSTART 2203 +#define SCI_CALLTIPSETPOSSTART 2214 #define SCI_CALLTIPSETHLT 2204 #define SCI_CALLTIPSETBACK 2205 #define SCI_CALLTIPSETFORE 2206 #define SCI_CALLTIPSETFOREHLT 2207 #define SCI_CALLTIPUSESTYLE 2212 +#define SCI_CALLTIPSETPOSITION 2213 #define SCI_VISIBLEFROMDOCLINE 2220 #define SCI_DOCLINEFROMVISIBLE 2221 #define SCI_WRAPCOUNT 2235 #define SC_FOLDLEVELBASE 0x400 #define SC_FOLDLEVELWHITEFLAG 0x1000 #define SC_FOLDLEVELHEADERFLAG 0x2000 -#define SC_FOLDLEVELBOXHEADERFLAG 0x4000 -#define SC_FOLDLEVELBOXFOOTERFLAG 0x8000 -#define SC_FOLDLEVELCONTRACTED 0x10000 -#define SC_FOLDLEVELUNINDENT 0x20000 #define SC_FOLDLEVELNUMBERMASK 0x0FFF #define SCI_SETFOLDLEVEL 2222 #define SCI_GETFOLDLEVEL 2223 @@ -407,16 +502,37 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SHOWLINES 2226 #define SCI_HIDELINES 2227 #define SCI_GETLINEVISIBLE 2228 +#define SCI_GETALLLINESVISIBLE 2236 #define SCI_SETFOLDEXPANDED 2229 #define SCI_GETFOLDEXPANDED 2230 #define SCI_TOGGLEFOLD 2231 +#define SCI_TOGGLEFOLDSHOWTEXT 2700 +#define SC_FOLDDISPLAYTEXT_HIDDEN 0 +#define SC_FOLDDISPLAYTEXT_STANDARD 1 +#define SC_FOLDDISPLAYTEXT_BOXED 2 +#define SCI_FOLDDISPLAYTEXTSETSTYLE 2701 +#define SCI_FOLDDISPLAYTEXTGETSTYLE 2707 +#define SCI_SETDEFAULTFOLDDISPLAYTEXT 2722 +#define SCI_GETDEFAULTFOLDDISPLAYTEXT 2723 +#define SC_FOLDACTION_CONTRACT 0 +#define SC_FOLDACTION_EXPAND 1 +#define SC_FOLDACTION_TOGGLE 2 +#define SCI_FOLDLINE 2237 +#define SCI_FOLDCHILDREN 2238 +#define SCI_EXPANDCHILDREN 2239 +#define SCI_FOLDALL 2662 #define SCI_ENSUREVISIBLE 2232 +#define SC_AUTOMATICFOLD_SHOW 0x0001 +#define SC_AUTOMATICFOLD_CLICK 0x0002 +#define SC_AUTOMATICFOLD_CHANGE 0x0004 +#define SCI_SETAUTOMATICFOLD 2663 +#define SCI_GETAUTOMATICFOLD 2664 #define SC_FOLDFLAG_LINEBEFORE_EXPANDED 0x0002 #define SC_FOLDFLAG_LINEBEFORE_CONTRACTED 0x0004 #define SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008 #define SC_FOLDFLAG_LINEAFTER_CONTRACTED 0x0010 #define SC_FOLDFLAG_LEVELNUMBERS 0x0040 -#define SC_FOLDFLAG_BOX 0x0001 +#define SC_FOLDFLAG_LINESTATE 0x0080 #define SCI_SETFOLDFLAGS 2233 #define SCI_ENSUREVISIBLEENFORCEPOLICY 2234 #define SCI_SETTABINDENTS 2260 @@ -428,14 +544,23 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETMOUSEDWELLTIME 2265 #define SCI_WORDSTARTPOSITION 2266 #define SCI_WORDENDPOSITION 2267 +#define SCI_ISRANGEWORD 2691 +#define SC_IDLESTYLING_NONE 0 +#define SC_IDLESTYLING_TOVISIBLE 1 +#define SC_IDLESTYLING_AFTERVISIBLE 2 +#define SC_IDLESTYLING_ALL 3 +#define SCI_SETIDLESTYLING 2692 +#define SCI_GETIDLESTYLING 2693 #define SC_WRAP_NONE 0 #define SC_WRAP_WORD 1 #define SC_WRAP_CHAR 2 +#define SC_WRAP_WHITESPACE 3 #define SCI_SETWRAPMODE 2268 #define SCI_GETWRAPMODE 2269 #define SC_WRAPVISUALFLAG_NONE 0x0000 #define SC_WRAPVISUALFLAG_END 0x0001 #define SC_WRAPVISUALFLAG_START 0x0002 +#define SC_WRAPVISUALFLAG_MARGIN 0x0004 #define SCI_SETWRAPVISUALFLAGS 2460 #define SCI_GETWRAPVISUALFLAGS 2461 #define SC_WRAPVISUALFLAGLOC_DEFAULT 0x0000 @@ -445,6 +570,12 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETWRAPVISUALFLAGSLOCATION 2463 #define SCI_SETWRAPSTARTINDENT 2464 #define SCI_GETWRAPSTARTINDENT 2465 +#define SC_WRAPINDENT_FIXED 0 +#define SC_WRAPINDENT_SAME 1 +#define SC_WRAPINDENT_INDENT 2 +#define SC_WRAPINDENT_DEEPINDENT 3 +#define SCI_SETWRAPINDENTMODE 2472 +#define SCI_GETWRAPINDENTMODE 2473 #define SC_CACHE_NONE 0 #define SC_CACHE_CARET 1 #define SC_CACHE_PAGE 2 @@ -462,13 +593,32 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETVSCROLLBAR 2280 #define SCI_GETVSCROLLBAR 2281 #define SCI_APPENDTEXT 2282 -#define SCI_GETTWOPHASEDRAW 2283 -#define SCI_SETTWOPHASEDRAW 2284 -#define SCI_TARGETFROMSELECTION 2287 +#define SC_PHASES_ONE 0 +#define SC_PHASES_TWO 1 +#define SC_PHASES_MULTIPLE 2 +#define SCI_GETPHASESDRAW 2673 +#define SCI_SETPHASESDRAW 2674 +#define SC_EFF_QUALITY_MASK 0xF +#define SC_EFF_QUALITY_DEFAULT 0 +#define SC_EFF_QUALITY_NON_ANTIALIASED 1 +#define SC_EFF_QUALITY_ANTIALIASED 2 +#define SC_EFF_QUALITY_LCD_OPTIMIZED 3 +#define SCI_SETFONTQUALITY 2611 +#define SCI_GETFONTQUALITY 2612 +#define SCI_SETFIRSTVISIBLELINE 2613 +#define SC_MULTIPASTE_ONCE 0 +#define SC_MULTIPASTE_EACH 1 +#define SCI_SETMULTIPASTE 2614 +#define SCI_GETMULTIPASTE 2615 +#define SCI_GETTAG 2616 #define SCI_LINESJOIN 2288 #define SCI_LINESSPLIT 2289 #define SCI_SETFOLDMARGINCOLOUR 2290 #define SCI_SETFOLDMARGINHICOLOUR 2291 +#define SC_ACCESSIBILITY_DISABLED 0 +#define SC_ACCESSIBILITY_ENABLED 1 +#define SCI_SETACCESSIBILITY 2702 +#define SCI_GETACCESSIBILITY 2703 #define SCI_LINEDOWN 2300 #define SCI_LINEDOWNEXTEND 2301 #define SCI_LINEUP 2302 @@ -510,6 +660,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_LINECUT 2337 #define SCI_LINEDELETE 2338 #define SCI_LINETRANSPOSE 2339 +#define SCI_LINEREVERSE 2354 #define SCI_LINEDUPLICATE 2404 #define SCI_LOWERCASE 2340 #define SCI_UPPERCASE 2341 @@ -530,8 +681,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_MOVECARETINSIDEVIEW 2401 #define SCI_LINELENGTH 2350 #define SCI_BRACEHIGHLIGHT 2351 +#define SCI_BRACEHIGHLIGHTINDICATOR 2498 #define SCI_BRACEBADLIGHT 2352 +#define SCI_BRACEBADLIGHTINDICATOR 2499 #define SCI_BRACEMATCH 2353 +#define SCI_BRACEMATCHNEXT 2369 #define SCI_GETVIEWEOL 2355 #define SCI_SETVIEWEOL 2356 #define SCI_GETDOCPOINTER 2357 @@ -540,32 +694,50 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define EDGE_NONE 0 #define EDGE_LINE 1 #define EDGE_BACKGROUND 2 +#define EDGE_MULTILINE 3 #define SCI_GETEDGECOLUMN 2360 #define SCI_SETEDGECOLUMN 2361 #define SCI_GETEDGEMODE 2362 #define SCI_SETEDGEMODE 2363 #define SCI_GETEDGECOLOUR 2364 #define SCI_SETEDGECOLOUR 2365 +#define SCI_MULTIEDGEADDLINE 2694 +#define SCI_MULTIEDGECLEARALL 2695 +#define SCI_GETMULTIEDGECOLUMN 2749 #define SCI_SEARCHANCHOR 2366 #define SCI_SEARCHNEXT 2367 #define SCI_SEARCHPREV 2368 #define SCI_LINESONSCREEN 2370 +#define SC_POPUP_NEVER 0 +#define SC_POPUP_ALL 1 +#define SC_POPUP_TEXT 2 #define SCI_USEPOPUP 2371 #define SCI_SELECTIONISRECTANGLE 2372 #define SCI_SETZOOM 2373 #define SCI_GETZOOM 2374 +#define SC_DOCUMENTOPTION_DEFAULT 0 +#define SC_DOCUMENTOPTION_STYLES_NONE 0x1 +#define SC_DOCUMENTOPTION_TEXT_LARGE 0x100 #define SCI_CREATEDOCUMENT 2375 #define SCI_ADDREFDOCUMENT 2376 #define SCI_RELEASEDOCUMENT 2377 +#define SCI_GETDOCUMENTOPTIONS 2379 #define SCI_GETMODEVENTMASK 2378 +#define SCI_SETCOMMANDEVENTS 2717 +#define SCI_GETCOMMANDEVENTS 2718 #define SCI_SETFOCUS 2380 #define SCI_GETFOCUS 2381 +#define SC_STATUS_OK 0 +#define SC_STATUS_FAILURE 1 +#define SC_STATUS_BADALLOC 2 +#define SC_STATUS_WARN_START 1000 +#define SC_STATUS_WARN_REGEX 1001 #define SCI_SETSTATUS 2382 #define SCI_GETSTATUS 2383 #define SCI_SETMOUSEDOWNCAPTURES 2384 #define SCI_GETMOUSEDOWNCAPTURES 2385 -#define SC_CURSORNORMAL -1 -#define SC_CURSORWAIT 4 +#define SCI_SETMOUSEWHEELCAPTURES 2696 +#define SCI_GETMOUSEWHEELCAPTURES 2697 #define SCI_SETCURSOR 2386 #define SCI_GETCURSOR 2387 #define SCI_SETCONTROLCHARSYMBOL 2388 @@ -605,13 +777,17 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_PARAUPEXTEND 2416 #define SCI_POSITIONBEFORE 2417 #define SCI_POSITIONAFTER 2418 +#define SCI_POSITIONRELATIVE 2670 +#define SCI_POSITIONRELATIVECODEUNITS 2716 #define SCI_COPYRANGE 2419 #define SCI_COPYTEXT 2420 #define SC_SEL_STREAM 0 #define SC_SEL_RECTANGLE 1 #define SC_SEL_LINES 2 +#define SC_SEL_THIN 3 #define SCI_SETSELECTIONMODE 2422 #define SCI_GETSELECTIONMODE 2423 +#define SCI_GETMOVEEXTENDSSELECTION 2706 #define SCI_GETLINESELSTARTPOSITION 2424 #define SCI_GETLINESELENDPOSITION 2425 #define SCI_LINEDOWNRECTEXTEND 2426 @@ -632,27 +808,48 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_WORDRIGHTEND 2441 #define SCI_WORDRIGHTENDEXTEND 2442 #define SCI_SETWHITESPACECHARS 2443 +#define SCI_GETWHITESPACECHARS 2647 +#define SCI_SETPUNCTUATIONCHARS 2648 +#define SCI_GETPUNCTUATIONCHARS 2649 #define SCI_SETCHARSDEFAULT 2444 #define SCI_AUTOCGETCURRENT 2445 +#define SCI_AUTOCGETCURRENTTEXT 2610 +#define SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE 0 +#define SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE 1 +#define SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR 2634 +#define SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR 2635 +#define SC_MULTIAUTOC_ONCE 0 +#define SC_MULTIAUTOC_EACH 1 +#define SCI_AUTOCSETMULTI 2636 +#define SCI_AUTOCGETMULTI 2637 +#define SC_ORDER_PRESORTED 0 +#define SC_ORDER_PERFORMSORT 1 +#define SC_ORDER_CUSTOM 2 +#define SCI_AUTOCSETORDER 2660 +#define SCI_AUTOCGETORDER 2661 #define SCI_ALLOCATE 2446 #define SCI_TARGETASUTF8 2447 #define SCI_SETLENGTHFORENCODE 2448 #define SCI_ENCODEDFROMUTF8 2449 #define SCI_FINDCOLUMN 2456 +#define SC_CARETSTICKY_OFF 0 +#define SC_CARETSTICKY_ON 1 +#define SC_CARETSTICKY_WHITESPACE 2 #define SCI_GETCARETSTICKY 2457 #define SCI_SETCARETSTICKY 2458 #define SCI_TOGGLECARETSTICKY 2459 #define SCI_SETPASTECONVERTENDINGS 2467 #define SCI_GETPASTECONVERTENDINGS 2468 #define SCI_SELECTIONDUPLICATE 2469 -#define SC_ALPHA_TRANSPARENT 0 -#define SC_ALPHA_OPAQUE 255 -#define SC_ALPHA_NOALPHA 256 #define SCI_SETCARETLINEBACKALPHA 2470 #define SCI_GETCARETLINEBACKALPHA 2471 #define CARETSTYLE_INVISIBLE 0 #define CARETSTYLE_LINE 1 #define CARETSTYLE_BLOCK 2 +#define CARETSTYLE_OVERSTRIKE_BAR 0 +#define CARETSTYLE_OVERSTRIKE_BLOCK 0x10 +#define CARETSTYLE_INS_MASK 0xF +#define CARETSTYLE_BLOCK_AFTER 0x100 #define SCI_SETCARETSTYLE 2512 #define SCI_GETCARETSTYLE 2513 #define SCI_SETINDICATORCURRENT 2500 @@ -669,8 +866,159 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETPOSITIONCACHE 2515 #define SCI_COPYALLOWLINE 2519 #define SCI_GETCHARACTERPOINTER 2520 -#define SCI_SETKEYSUNICODE 2521 -#define SCI_GETKEYSUNICODE 2522 +#define SCI_GETRANGEPOINTER 2643 +#define SCI_GETGAPPOSITION 2644 +#define SCI_INDICSETALPHA 2523 +#define SCI_INDICGETALPHA 2524 +#define SCI_INDICSETOUTLINEALPHA 2558 +#define SCI_INDICGETOUTLINEALPHA 2559 +#define SCI_SETEXTRAASCENT 2525 +#define SCI_GETEXTRAASCENT 2526 +#define SCI_SETEXTRADESCENT 2527 +#define SCI_GETEXTRADESCENT 2528 +#define SCI_MARKERSYMBOLDEFINED 2529 +#define SCI_MARGINSETTEXT 2530 +#define SCI_MARGINGETTEXT 2531 +#define SCI_MARGINSETSTYLE 2532 +#define SCI_MARGINGETSTYLE 2533 +#define SCI_MARGINSETSTYLES 2534 +#define SCI_MARGINGETSTYLES 2535 +#define SCI_MARGINTEXTCLEARALL 2536 +#define SCI_MARGINSETSTYLEOFFSET 2537 +#define SCI_MARGINGETSTYLEOFFSET 2538 +#define SC_MARGINOPTION_NONE 0 +#define SC_MARGINOPTION_SUBLINESELECT 1 +#define SCI_SETMARGINOPTIONS 2539 +#define SCI_GETMARGINOPTIONS 2557 +#define SCI_ANNOTATIONSETTEXT 2540 +#define SCI_ANNOTATIONGETTEXT 2541 +#define SCI_ANNOTATIONSETSTYLE 2542 +#define SCI_ANNOTATIONGETSTYLE 2543 +#define SCI_ANNOTATIONSETSTYLES 2544 +#define SCI_ANNOTATIONGETSTYLES 2545 +#define SCI_ANNOTATIONGETLINES 2546 +#define SCI_ANNOTATIONCLEARALL 2547 +#define ANNOTATION_HIDDEN 0 +#define ANNOTATION_STANDARD 1 +#define ANNOTATION_BOXED 2 +#define ANNOTATION_INDENTED 3 +#define SCI_ANNOTATIONSETVISIBLE 2548 +#define SCI_ANNOTATIONGETVISIBLE 2549 +#define SCI_ANNOTATIONSETSTYLEOFFSET 2550 +#define SCI_ANNOTATIONGETSTYLEOFFSET 2551 +#define SCI_RELEASEALLEXTENDEDSTYLES 2552 +#define SCI_ALLOCATEEXTENDEDSTYLES 2553 +#define UNDO_NONE 0 +#define UNDO_MAY_COALESCE 1 +#define SCI_ADDUNDOACTION 2560 +#define SCI_CHARPOSITIONFROMPOINT 2561 +#define SCI_CHARPOSITIONFROMPOINTCLOSE 2562 +#define SCI_SETMOUSESELECTIONRECTANGULARSWITCH 2668 +#define SCI_GETMOUSESELECTIONRECTANGULARSWITCH 2669 +#define SCI_SETMULTIPLESELECTION 2563 +#define SCI_GETMULTIPLESELECTION 2564 +#define SCI_SETADDITIONALSELECTIONTYPING 2565 +#define SCI_GETADDITIONALSELECTIONTYPING 2566 +#define SCI_SETADDITIONALCARETSBLINK 2567 +#define SCI_GETADDITIONALCARETSBLINK 2568 +#define SCI_SETADDITIONALCARETSVISIBLE 2608 +#define SCI_GETADDITIONALCARETSVISIBLE 2609 +#define SCI_GETSELECTIONS 2570 +#define SCI_GETSELECTIONEMPTY 2650 +#define SCI_CLEARSELECTIONS 2571 +#define SCI_SETSELECTION 2572 +#define SCI_ADDSELECTION 2573 +#define SCI_DROPSELECTIONN 2671 +#define SCI_SETMAINSELECTION 2574 +#define SCI_GETMAINSELECTION 2575 +#define SCI_SETSELECTIONNCARET 2576 +#define SCI_GETSELECTIONNCARET 2577 +#define SCI_SETSELECTIONNANCHOR 2578 +#define SCI_GETSELECTIONNANCHOR 2579 +#define SCI_SETSELECTIONNCARETVIRTUALSPACE 2580 +#define SCI_GETSELECTIONNCARETVIRTUALSPACE 2581 +#define SCI_SETSELECTIONNANCHORVIRTUALSPACE 2582 +#define SCI_GETSELECTIONNANCHORVIRTUALSPACE 2583 +#define SCI_SETSELECTIONNSTART 2584 +#define SCI_GETSELECTIONNSTART 2585 +#define SCI_GETSELECTIONNSTARTVIRTUALSPACE 2726 +#define SCI_SETSELECTIONNEND 2586 +#define SCI_GETSELECTIONNENDVIRTUALSPACE 2727 +#define SCI_GETSELECTIONNEND 2587 +#define SCI_SETRECTANGULARSELECTIONCARET 2588 +#define SCI_GETRECTANGULARSELECTIONCARET 2589 +#define SCI_SETRECTANGULARSELECTIONANCHOR 2590 +#define SCI_GETRECTANGULARSELECTIONANCHOR 2591 +#define SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE 2592 +#define SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE 2593 +#define SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE 2594 +#define SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE 2595 +#define SCVS_NONE 0 +#define SCVS_RECTANGULARSELECTION 1 +#define SCVS_USERACCESSIBLE 2 +#define SCVS_NOWRAPLINESTART 4 +#define SCI_SETVIRTUALSPACEOPTIONS 2596 +#define SCI_GETVIRTUALSPACEOPTIONS 2597 +#define SCI_SETRECTANGULARSELECTIONMODIFIER 2598 +#define SCI_GETRECTANGULARSELECTIONMODIFIER 2599 +#define SCI_SETADDITIONALSELFORE 2600 +#define SCI_SETADDITIONALSELBACK 2601 +#define SCI_SETADDITIONALSELALPHA 2602 +#define SCI_GETADDITIONALSELALPHA 2603 +#define SCI_SETADDITIONALCARETFORE 2604 +#define SCI_GETADDITIONALCARETFORE 2605 +#define SCI_ROTATESELECTION 2606 +#define SCI_SWAPMAINANCHORCARET 2607 +#define SCI_MULTIPLESELECTADDNEXT 2688 +#define SCI_MULTIPLESELECTADDEACH 2689 +#define SCI_CHANGELEXERSTATE 2617 +#define SCI_CONTRACTEDFOLDNEXT 2618 +#define SCI_VERTICALCENTRECARET 2619 +#define SCI_MOVESELECTEDLINESUP 2620 +#define SCI_MOVESELECTEDLINESDOWN 2621 +#define SCI_SETIDENTIFIER 2622 +#define SCI_GETIDENTIFIER 2623 +#define SCI_RGBAIMAGESETWIDTH 2624 +#define SCI_RGBAIMAGESETHEIGHT 2625 +#define SCI_RGBAIMAGESETSCALE 2651 +#define SCI_MARKERDEFINERGBAIMAGE 2626 +#define SCI_REGISTERRGBAIMAGE 2627 +#define SCI_SCROLLTOSTART 2628 +#define SCI_SCROLLTOEND 2629 +#define SC_TECHNOLOGY_DEFAULT 0 +#define SC_TECHNOLOGY_DIRECTWRITE 1 +#define SC_TECHNOLOGY_DIRECTWRITERETAIN 2 +#define SC_TECHNOLOGY_DIRECTWRITEDC 3 +#define SCI_SETTECHNOLOGY 2630 +#define SCI_GETTECHNOLOGY 2631 +#define SCI_CREATELOADER 2632 +#define SCI_FINDINDICATORSHOW 2640 +#define SCI_FINDINDICATORFLASH 2641 +#define SCI_FINDINDICATORHIDE 2642 +#define SCI_VCHOMEDISPLAY 2652 +#define SCI_VCHOMEDISPLAYEXTEND 2653 +#define SCI_GETCARETLINEVISIBLEALWAYS 2654 +#define SCI_SETCARETLINEVISIBLEALWAYS 2655 +#define SC_LINE_END_TYPE_DEFAULT 0 +#define SC_LINE_END_TYPE_UNICODE 1 +#define SCI_SETLINEENDTYPESALLOWED 2656 +#define SCI_GETLINEENDTYPESALLOWED 2657 +#define SCI_GETLINEENDTYPESACTIVE 2658 +#define SCI_SETREPRESENTATION 2665 +#define SCI_GETREPRESENTATION 2666 +#define SCI_CLEARREPRESENTATION 2667 +#define SCI_EOLANNOTATIONSETTEXT 2740 +#define SCI_EOLANNOTATIONGETTEXT 2741 +#define SCI_EOLANNOTATIONSETSTYLE 2742 +#define SCI_EOLANNOTATIONGETSTYLE 2743 +#define SCI_EOLANNOTATIONCLEARALL 2744 +#define EOLANNOTATION_HIDDEN 0 +#define EOLANNOTATION_STANDARD 1 +#define EOLANNOTATION_BOXED 2 +#define SCI_EOLANNOTATIONSETVISIBLE 2745 +#define SCI_EOLANNOTATIONGETVISIBLE 2746 +#define SCI_EOLANNOTATIONSETSTYLEOFFSET 2747 +#define SCI_EOLANNOTATIONGETSTYLEOFFSET 2748 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 @@ -684,7 +1032,31 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETPROPERTY 4008 #define SCI_GETPROPERTYEXPANDED 4009 #define SCI_GETPROPERTYINT 4010 -#define SCI_GETSTYLEBITSNEEDED 4011 +#define SCI_GETLEXERLANGUAGE 4012 +#define SCI_PRIVATELEXERCALL 4013 +#define SCI_PROPERTYNAMES 4014 +#define SC_TYPE_BOOLEAN 0 +#define SC_TYPE_INTEGER 1 +#define SC_TYPE_STRING 2 +#define SCI_PROPERTYTYPE 4015 +#define SCI_DESCRIBEPROPERTY 4016 +#define SCI_DESCRIBEKEYWORDSETS 4017 +#define SCI_GETLINEENDTYPESSUPPORTED 4018 +#define SCI_ALLOCATESUBSTYLES 4020 +#define SCI_GETSUBSTYLESSTART 4021 +#define SCI_GETSUBSTYLESLENGTH 4022 +#define SCI_GETSTYLEFROMSUBSTYLE 4027 +#define SCI_GETPRIMARYSTYLEFROMSTYLE 4028 +#define SCI_FREESUBSTYLES 4023 +#define SCI_SETIDENTIFIERS 4024 +#define SCI_DISTANCETOSECONDARYSTYLES 4025 +#define SCI_GETSUBSTYLEBASES 4026 +#define SCI_GETNAMEDSTYLES 4029 +#define SCI_NAMEOFSTYLE 4030 +#define SCI_TAGSOFSTYLE 4031 +#define SCI_DESCRIPTIONOFSTYLE 4032 +#define SCI_SETILEXER 4033 +#define SC_MOD_NONE 0x0 #define SC_MOD_INSERTTEXT 0x1 #define SC_MOD_DELETETEXT 0x2 #define SC_MOD_CHANGESTYLE 0x4 @@ -701,7 +1073,18 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_STARTACTION 0x2000 #define SC_MOD_CHANGEINDICATOR 0x4000 #define SC_MOD_CHANGELINESTATE 0x8000 -#define SC_MODEVENTMASKALL 0xFFFF +#define SC_MOD_CHANGEMARGIN 0x10000 +#define SC_MOD_CHANGEANNOTATION 0x20000 +#define SC_MOD_CONTAINER 0x40000 +#define SC_MOD_LEXERSTATE 0x80000 +#define SC_MOD_INSERTCHECK 0x100000 +#define SC_MOD_CHANGETABSTOPS 0x200000 +#define SC_MOD_CHANGEEOLANNOTATION 0x400000 +#define SC_MODEVENTMASKALL 0x7FFFFF +#define SC_UPDATE_CONTENT 0x1 +#define SC_UPDATE_SELECTION 0x2 +#define SC_UPDATE_V_SCROLL 0x4 +#define SC_UPDATE_H_SCROLL 0x8 #define SCEN_CHANGE 768 #define SCEN_SETFOCUS 512 #define SCEN_KILLFOCUS 256 @@ -729,6 +1112,16 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCMOD_SHIFT 1 #define SCMOD_CTRL 2 #define SCMOD_ALT 4 +#define SCMOD_SUPER 8 +#define SCMOD_META 16 +#define SC_AC_FILLUP 1 +#define SC_AC_DOUBLECLICK 2 +#define SC_AC_TAB 3 +#define SC_AC_NEWLINE 4 +#define SC_AC_COMMAND 5 +#define SC_CHARACTERSOURCE_DIRECT_INPUT 0 +#define SC_CHARACTERSOURCE_TENTATIVE_INPUT 1 +#define SC_CHARACTERSOURCE_IME_RESULT 2 #define SCN_STYLENEEDED 2000 #define SCN_CHARADDED 2001 #define SCN_SAVEPOINTREACHED 2002 @@ -754,94 +1147,150 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCN_INDICATORCLICK 2023 #define SCN_INDICATORRELEASE 2024 #define SCN_AUTOCCANCELLED 2025 -//--Autogenerated -- end of section automatically generated from Scintilla.iface - -// These structures are defined to be exactly the same shape as the Win32 -// CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs. -// So older code that treats Scintilla as a RichEdit will work. +#define SCN_AUTOCCHARDELETED 2026 +#define SCN_HOTSPOTRELEASECLICK 2027 +#define SCN_FOCUSIN 2028 +#define SCN_FOCUSOUT 2029 +#define SCN_AUTOCCOMPLETED 2030 +#define SCN_MARGINRIGHTCLICK 2031 +#define SCN_AUTOCSELECTIONCHANGE 2032 +#ifndef SCI_DISABLE_PROVISIONAL +#define SC_BIDIRECTIONAL_DISABLED 0 +#define SC_BIDIRECTIONAL_L2R 1 +#define SC_BIDIRECTIONAL_R2L 2 +#define SCI_GETBIDIRECTIONAL 2708 +#define SCI_SETBIDIRECTIONAL 2709 +#define SC_LINECHARACTERINDEX_NONE 0 +#define SC_LINECHARACTERINDEX_UTF32 1 +#define SC_LINECHARACTERINDEX_UTF16 2 +#define SCI_GETLINECHARACTERINDEX 2710 +#define SCI_ALLOCATELINECHARACTERINDEX 2711 +#define SCI_RELEASELINECHARACTERINDEX 2712 +#define SCI_LINEFROMINDEXPOSITION 2713 +#define SCI_INDEXPOSITIONFROMLINE 2714 +#endif +/* --Autogenerated -- end of section automatically generated from Scintilla.iface */ -#ifdef SCI_NAMESPACE -namespace Scintilla { #endif -struct CharacterRange { - long cpMin; - long cpMax; +/* These structures are defined to be exactly the same shape as the Win32 + * CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs. + * So older code that treats Scintilla as a RichEdit will work. */ + +struct Sci_CharacterRange { + Sci_PositionCR cpMin; + Sci_PositionCR cpMax; }; -struct TextRange { - struct CharacterRange chrg; +struct Sci_TextRange { + struct Sci_CharacterRange chrg; char *lpstrText; }; -struct TextToFind { - struct CharacterRange chrg; - char *lpstrText; - struct CharacterRange chrgText; +struct Sci_TextToFind { + struct Sci_CharacterRange chrg; + const char *lpstrText; + struct Sci_CharacterRange chrgText; }; -#ifdef PLATFORM_H +typedef void *Sci_SurfaceID; + +struct Sci_Rectangle { + int left; + int top; + int right; + int bottom; +}; -// This structure is used in printing and requires some of the graphics types -// from Platform.h. Not needed by most client code. +/* This structure is used in printing and requires some of the graphics types + * from Platform.h. Not needed by most client code. */ -struct RangeToFormat { - SurfaceID hdc; - SurfaceID hdcTarget; - PRectangle rc; - PRectangle rcPage; - CharacterRange chrg; +struct Sci_RangeToFormat { + Sci_SurfaceID hdc; + Sci_SurfaceID hdcTarget; + struct Sci_Rectangle rc; + struct Sci_Rectangle rcPage; + struct Sci_CharacterRange chrg; }; +#ifndef __cplusplus +/* For the GTK+ platform, g-ir-scanner needs to have these typedefs. This + * is not required in C++ code and actually seems to break ScintillaEditPy */ +typedef struct Sci_NotifyHeader Sci_NotifyHeader; +typedef struct SCNotification SCNotification; #endif -struct NotifyHeader { - // Compatible with Windows NMHDR. - // hwndFrom is really an environment specific window handle or pointer - // but most clients of Scintilla.h do not have this type visible. +struct Sci_NotifyHeader { + /* Compatible with Windows NMHDR. + * hwndFrom is really an environment specific window handle or pointer + * but most clients of Scintilla.h do not have this type visible. */ void *hwndFrom; uptr_t idFrom; unsigned int code; }; struct SCNotification { - struct NotifyHeader nmhdr; - int position; // SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND - int ch; // SCN_CHARADDED, SCN_KEY - int modifiers; // SCN_KEY - int modificationType; // SCN_MODIFIED - const char *text; // SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION - int length; // SCN_MODIFIED - int linesAdded; // SCN_MODIFIED - int message; // SCN_MACRORECORD - uptr_t wParam; // SCN_MACRORECORD - sptr_t lParam; // SCN_MACRORECORD - int line; // SCN_MODIFIED - int foldLevelNow; // SCN_MODIFIED - int foldLevelPrev; // SCN_MODIFIED - int margin; // SCN_MARGINCLICK - int listType; // SCN_USERLISTSELECTION - int x; // SCN_DWELLSTART, SCN_DWELLEND - int y; // SCN_DWELLSTART, SCN_DWELLEND -}; + 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 */ -#ifdef SCI_NAMESPACE -} -#endif + int ch; + /* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETED, SCN_AUTOCSELECTION, */ + /* SCN_USERLISTSELECTION */ + int modifiers; + /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */ + /* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ -// Deprecation section listing all API features that are deprecated and will -// will be removed completely in a future version. -// To enable these features define INCLUDE_DEPRECATED_FEATURES + int modificationType; /* SCN_MODIFIED */ + const char *text; + /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */ + + Sci_Position length; /* SCN_MODIFIED */ + Sci_Position linesAdded; /* SCN_MODIFIED */ + int message; /* SCN_MACRORECORD */ + uptr_t wParam; /* SCN_MACRORECORD */ + sptr_t lParam; /* SCN_MACRORECORD */ + Sci_Position line; /* SCN_MODIFIED */ + int foldLevelNow; /* SCN_MODIFIED */ + int foldLevelPrev; /* SCN_MODIFIED */ + int margin; /* SCN_MARGINCLICK */ + int listType; /* SCN_USERLISTSELECTION */ + int x; /* SCN_DWELLSTART, SCN_DWELLEND */ + int y; /* SCN_DWELLSTART, SCN_DWELLEND */ + int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */ + Sci_Position annotationLinesAdded; /* SCN_MODIFIED with SC_MOD_CHANGEANNOTATION */ + int updated; /* SCN_UPDATEUI */ + int listCompletionMethod; + /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION, */ + int characterSource; /* SCN_CHARADDED */ +}; #ifdef INCLUDE_DEPRECATED_FEATURES -#define SCI_SETCARETPOLICY 2369 -#define CARET_CENTER 0x02 -#define CARET_XEVEN 0x08 -#define CARET_XJUMPS 0x10 +#define SCI_SETKEYSUNICODE 2521 +#define SCI_GETKEYSUNICODE 2522 + +#define SCI_GETTWOPHASEDRAW 2283 +#define SCI_SETTWOPHASEDRAW 2284 -#define SCN_POSCHANGED 2012 -#define SCN_CHECKBRACE 2007 +#define CharacterRange Sci_CharacterRange +#define TextRange Sci_TextRange +#define TextToFind Sci_TextToFind +#define RangeToFormat Sci_RangeToFormat +#define NotifyHeader Sci_NotifyHeader + +#define SCI_SETSTYLEBITS 2090 +#define SCI_GETSTYLEBITS 2091 +#define SCI_GETSTYLEBITSNEEDED 4011 + +#define INDIC0_MASK 0x20 +#define INDIC1_MASK 0x40 +#define INDIC2_MASK 0x80 +#define INDICS_MASK 0xE0 #endif diff --git a/Pythonwin/Scintilla/include/Scintilla.iface b/Pythonwin/Scintilla/include/Scintilla.iface new file mode 100644 index 000000000..2c044d1a8 --- /dev/null +++ b/Pythonwin/Scintilla/include/Scintilla.iface @@ -0,0 +1,5417 @@ +## First line may be used for shbang + +## This file defines the interface to Scintilla + +## Copyright 2000-2003 by Neil Hodgson +## The License.txt file describes the conditions under which this software may be distributed. + +## A line starting with ## is a pure comment and should be stripped by readers. +## A line starting with #! is for future shbang use +## A line starting with # followed by a space is a documentation comment and refers +## to the next feature definition. + +## Each feature is defined by a line starting with fun, get, set, val, evt, enu, lex, or ali. +## cat -> start a category +## fun -> a function +## get -> a property get function +## set -> a property set function +## val -> definition of a constant +## evt -> an event +## enu -> associate an enumeration with a set of vals with a prefix +## lex -> associate a lexer with the lexical classes it produces +## ali -> add an alias for a val, commonly adding '_' to separate words +## +## All other feature names should be ignored. They may be defined in the future. +## A property may have a set function, a get function or both. Each will have +## "Get" or "Set" in their names and the corresponding name will have the obvious switch. +## A property may be subscripted, in which case the first parameter is the subscript. +## fun, get, and set features have a strict syntax: +## [=,) +## where stands for white space. +## param may be empty (null value) or is [=] +## Additional white space is allowed between elements. +## The syntax for evt is [=[,]*]) +## Feature names that contain an underscore are defined by Windows, so in these +## cases, using the Windows definition is preferred where available. +## The feature numbers are stable so features will not be renumbered. +## Features may be removed but they will go through a period of deprecation +## before removal which is signalled by moving them into the Deprecated category. +## +## enu has the syntax enu=[]* where all the val +## features in this file starting with a given are considered part of the +## enumeration. +## +## lex has the syntax lex=[]* +## where name is a reasonably capitalised (Python, XML) identifier or UI name, +## lexerVal is the val used to specify the lexer, and the list of prefixes is similar +## to enu. The name may not be the same as that used within the lexer so the lexerVal +## should be used to tie these entities together. + +## Types: Never start with a capital letter +## void +## int +## bool -> integer, 1=true, 0=false +## position -> intptr_t position in a document +## line -> intptr_t line in a document +## colour -> colour integer containing red, green and blue bytes. +## string -> pointer to const character +## stringresult -> pointer to character, NULL-> return size of result +## cells -> pointer to array of cells, each cell containing a style byte and character byte +## pointer -> void* pointer that may point to a document, loader, internal text storage or similar +## textrange -> range of a min and a max position with an output string +## findtext -> searchrange, text -> foundposition +## keymod -> integer containing key in low half and modifiers in high half +## formatrange +## Enumeration types always start with a capital letter +## Types no longer used: +## findtextex -> searchrange +## charrange -> range of a min and a max position +## charrangeresult -> like charrange, but output param +## countedstring +## point -> x,y +## pointresult -> like point, but output param +## rectangle -> left,top,right,bottom +## Client code should ignore definitions containing types it does not understand, except +## for possibly #defining the constants + +## Line numbers and positions start at 0. +## String arguments may contain NUL ('\0') characters where the calls provide a length +## argument and retrieve NUL characters. APIs marked as NUL-terminated also have a +## NUL appended but client code should calculate the size that will be returned rather +## than relying upon the NUL whenever possible. Allow for the extra NUL character when +## allocating buffers. The size to allocate for a stringresult (not including NUL) can be +## determined by calling with a NULL (0) pointer. + +cat Basics + +################################################ +## For Scintilla.h +val INVALID_POSITION=-1 +# Define start of Scintilla messages to be greater than all Windows edit (EM_*) messages +# as many EM_ messages can be used although that use is deprecated. +val SCI_START=2000 +val SCI_OPTIONAL_START=3000 +val SCI_LEXER_START=4000 + +# Add text to the document at current position. +fun void AddText=2001(position length, string text) + +# Add array of cells to document. +fun void AddStyledText=2002(position length, cells c) + +# Insert string at a position. +fun void InsertText=2003(position pos, string text) + +# Change the text that is being inserted in response to SC_MOD_INSERTCHECK +fun void ChangeInsertion=2672(position length, string text) + +# Delete all text in the document. +fun void ClearAll=2004(,) + +# Delete a range of text in the document. +fun void DeleteRange=2645(position start, position lengthDelete) + +# Set all style bytes to 0, remove all folding information. +fun void ClearDocumentStyle=2005(,) + +# Returns the number of bytes in the document. +get position GetLength=2006(,) + +# Returns the character byte at the position. +get int GetCharAt=2007(position pos,) + +# Returns the position of the caret. +get position GetCurrentPos=2008(,) + +# Returns the position of the opposite end of the selection to the caret. +get position GetAnchor=2009(,) + +# Returns the style byte at the position. +get int GetStyleAt=2010(position pos,) + +# Redoes the next action on the undo history. +fun void Redo=2011(,) + +# Choose between collecting actions into the undo +# history and discarding them. +set void SetUndoCollection=2012(bool collectUndo,) + +# Select all the text in the document. +fun void SelectAll=2013(,) + +# Remember the current position in the undo history as the position +# at which the document was saved. +fun void SetSavePoint=2014(,) + +# Retrieve a buffer of cells. +# Returns the number of bytes in the buffer not including terminating NULs. +fun position GetStyledText=2015(, textrange tr) + +# Are there any redoable actions in the undo history? +fun bool CanRedo=2016(,) + +# Retrieve the line number at which a particular marker is located. +fun line MarkerLineFromHandle=2017(int markerHandle,) + +# Delete a marker. +fun void MarkerDeleteHandle=2018(int markerHandle,) + +# Retrieve marker handles of a line +fun int MarkerHandleFromLine=2732(line line, int which) + +# Retrieve marker number of a marker handle +fun int MarkerNumberFromLine=2733(line line, int which) + +# Is undo history being collected? +get bool GetUndoCollection=2019(,) + +enu WhiteSpace=SCWS_ +val SCWS_INVISIBLE=0 +val SCWS_VISIBLEALWAYS=1 +val SCWS_VISIBLEAFTERINDENT=2 +val SCWS_VISIBLEONLYININDENT=3 + +ali SCWS_VISIBLEALWAYS=VISIBLE_ALWAYS +ali SCWS_VISIBLEAFTERINDENT=VISIBLE_AFTER_INDENT +ali SCWS_VISIBLEONLYININDENT=VISIBLE_ONLY_IN_INDENT + +# Are white space characters currently visible? +# Returns one of SCWS_* constants. +get WhiteSpace GetViewWS=2020(,) + +# Make white space characters invisible, always visible or visible outside indentation. +set void SetViewWS=2021(WhiteSpace viewWS,) + +enu TabDrawMode=SCTD_ +val SCTD_LONGARROW=0 +val SCTD_STRIKEOUT=1 + +ali SCTD_LONGARROW=LONG_ARROW +ali SCTD_STRIKEOUT=STRIKE_OUT + +# Retrieve the current tab draw mode. +# Returns one of SCTD_* constants. +get TabDrawMode GetTabDrawMode=2698(,) + +# Set how tabs are drawn when visible. +set void SetTabDrawMode=2699(TabDrawMode tabDrawMode,) + +# Find the position from a point within the window. +fun position PositionFromPoint=2022(int x, int y) + +# Find the position from a point within the window but return +# INVALID_POSITION if not close to text. +fun position PositionFromPointClose=2023(int x, int y) + +# Set caret to start of a line and ensure it is visible. +fun void GotoLine=2024(line line,) + +# Set caret to a position and ensure it is visible. +fun void GotoPos=2025(position caret,) + +# Set the selection anchor to a position. The anchor is the opposite +# end of the selection from the caret. +set void SetAnchor=2026(position anchor,) + +# Retrieve the text of the line containing the caret. +# Returns the index of the caret on the line. +# Result is NUL-terminated. +fun position GetCurLine=2027(position length, stringresult text) + +# Retrieve the position of the last correctly styled character. +get position GetEndStyled=2028(,) + +enu EndOfLine=SC_EOL_ +val SC_EOL_CRLF=0 +val SC_EOL_CR=1 +val SC_EOL_LF=2 + +ali SC_EOL_CRLF=CR_LF + +# Convert all line endings in the document to one mode. +fun void ConvertEOLs=2029(EndOfLine eolMode,) + +# Retrieve the current end of line mode - one of CRLF, CR, or LF. +get EndOfLine GetEOLMode=2030(,) + +# Set the current end of line mode. +set void SetEOLMode=2031(EndOfLine eolMode,) + +# Set the current styling position to start. +# The unused parameter is no longer used and should be set to 0. +fun void StartStyling=2032(position start, int unused) + +# Change style from current styling position for length characters to a style +# and move the current styling position to after this newly styled segment. +fun void SetStyling=2033(position length, int style) + +# Is drawing done first into a buffer or direct to the screen? +get bool GetBufferedDraw=2034(,) + +# If drawing is buffered then each line of text is drawn into a bitmap buffer +# before drawing it to the screen to avoid flicker. +set void SetBufferedDraw=2035(bool buffered,) + +# Change the visible size of a tab to be a multiple of the width of a space character. +set void SetTabWidth=2036(int tabWidth,) + +# Retrieve the visible size of a tab. +get int GetTabWidth=2121(,) + +# Set the minimum visual width of a tab. +set void SetTabMinimumWidth=2724(int pixels,) + +# Get the minimum visual width of a tab. +get int GetTabMinimumWidth=2725(,) + +# Clear explicit tabstops on a line. +fun void ClearTabStops=2675(line line,) + +# Add an explicit tab stop for a line. +fun void AddTabStop=2676(line line, int x) + +# Find the next explicit tab stop position on a line after a position. +fun int GetNextTabStop=2677(line line, int x) + +# The SC_CP_UTF8 value can be used to enter Unicode mode. +# This is the same value as CP_UTF8 in Windows +val SC_CP_UTF8=65001 + +# Set the code page used to interpret the bytes of the document as characters. +# The SC_CP_UTF8 value can be used to enter Unicode mode. +set void SetCodePage=2037(int codePage,) + +enu IMEInteraction=SC_IME_ +val SC_IME_WINDOWED=0 +val SC_IME_INLINE=1 + +# Is the IME displayed in a window or inline? +get IMEInteraction GetIMEInteraction=2678(,) + +# Choose to display the IME in a window or inline. +set void SetIMEInteraction=2679(IMEInteraction imeInteraction,) + +enu Alpha=SC_ALPHA_ +val SC_ALPHA_TRANSPARENT=0 +val SC_ALPHA_OPAQUE=255 +val SC_ALPHA_NOALPHA=256 + +ali SC_ALPHA_NOALPHA=NO_ALPHA + +enu CursorShape=SC_CURSOR +val SC_CURSORNORMAL=-1 +val SC_CURSORARROW=2 +val SC_CURSORWAIT=4 +val SC_CURSORREVERSEARROW=7 + +ali SC_CURSORREVERSEARROW=REVERSE_ARROW + +enu MarkerSymbol=SC_MARK_ +val MARKER_MAX=31 +val SC_MARK_CIRCLE=0 +val SC_MARK_ROUNDRECT=1 +val SC_MARK_ARROW=2 +val SC_MARK_SMALLRECT=3 +val SC_MARK_SHORTARROW=4 +val SC_MARK_EMPTY=5 +val SC_MARK_ARROWDOWN=6 +val SC_MARK_MINUS=7 +val SC_MARK_PLUS=8 + +# Shapes used for outlining column. +val SC_MARK_VLINE=9 +val SC_MARK_LCORNER=10 +val SC_MARK_TCORNER=11 +val SC_MARK_BOXPLUS=12 +val SC_MARK_BOXPLUSCONNECTED=13 +val SC_MARK_BOXMINUS=14 +val SC_MARK_BOXMINUSCONNECTED=15 +val SC_MARK_LCORNERCURVE=16 +val SC_MARK_TCORNERCURVE=17 +val SC_MARK_CIRCLEPLUS=18 +val SC_MARK_CIRCLEPLUSCONNECTED=19 +val SC_MARK_CIRCLEMINUS=20 +val SC_MARK_CIRCLEMINUSCONNECTED=21 + +# Invisible mark that only sets the line background colour. +val SC_MARK_BACKGROUND=22 +val SC_MARK_DOTDOTDOT=23 +val SC_MARK_ARROWS=24 +val SC_MARK_PIXMAP=25 +val SC_MARK_FULLRECT=26 +val SC_MARK_LEFTRECT=27 +val SC_MARK_AVAILABLE=28 +val SC_MARK_UNDERLINE=29 +val SC_MARK_RGBAIMAGE=30 +val SC_MARK_BOOKMARK=31 +val SC_MARK_VERTICALBOOKMARK=32 + +val SC_MARK_CHARACTER=10000 + +ali SC_MARK_ROUNDRECT=ROUND_RECT +ali SC_MARK_SMALLRECT=SMALL_RECT +ali SC_MARK_SHORTARROW=SHORT_ARROW +ali SC_MARK_ARROWDOWN=ARROW_DOWN +ali SC_MARK_VLINE=V_LINE +ali SC_MARK_LCORNER=L_CORNER +ali SC_MARK_TCORNER=T_CORNER +ali SC_MARK_BOXPLUS=BOX_PLUS +ali SC_MARK_BOXPLUSCONNECTED=BOX_PLUS_CONNECTED +ali SC_MARK_BOXMINUS=BOX_MINUS +ali SC_MARK_BOXMINUSCONNECTED=BOX_MINUS_CONNECTED +ali SC_MARK_LCORNERCURVE=L_CORNER_CURVE +ali SC_MARK_TCORNERCURVE=T_CORNER_CURVE +ali SC_MARK_CIRCLEPLUS=CIRCLE_PLUS +ali SC_MARK_CIRCLEPLUSCONNECTED=CIRCLE_PLUS_CONNECTED +ali SC_MARK_CIRCLEMINUS=CIRCLE_MINUS +ali SC_MARK_CIRCLEMINUSCONNECTED=CIRCLE_MINUS_CONNECTED +ali SC_MARK_DOTDOTDOT=DOT_DOT_DOT +ali SC_MARK_FULLRECT=FULL_RECT +ali SC_MARK_LEFTRECT=LEFT_RECT +ali SC_MARK_RGBAIMAGE=RGBA_IMAGE +ali SC_MARK_VERTICALBOOKMARK=VERTICAL_BOOKMARK + +enu MarkerOutline=SC_MARKNUM_ +# Markers used for outlining column. +val SC_MARKNUM_FOLDEREND=25 +val SC_MARKNUM_FOLDEROPENMID=26 +val SC_MARKNUM_FOLDERMIDTAIL=27 +val SC_MARKNUM_FOLDERTAIL=28 +val SC_MARKNUM_FOLDERSUB=29 +val SC_MARKNUM_FOLDER=30 +val SC_MARKNUM_FOLDEROPEN=31 + +ali SC_MARKNUM_FOLDEREND=FOLDER_END +ali SC_MARKNUM_FOLDEROPENMID=FOLDER_OPEN_MID +ali SC_MARKNUM_FOLDERMIDTAIL=FOLDER_MID_TAIL +ali SC_MARKNUM_FOLDERTAIL=FOLDER_TAIL +ali SC_MARKNUM_FOLDERSUB=FOLDER_SUB +ali SC_MARKNUM_FOLDEROPEN=FOLDER_OPEN + +# SC_MASK_FOLDERS doesn't go in an enumeration as larger than max 32-bit positive integer +val SC_MASK_FOLDERS=0xFE000000 + +# Set the symbol used for a particular marker number. +fun void MarkerDefine=2040(int markerNumber, MarkerSymbol markerSymbol) + +# Set the foreground colour used for a particular marker number. +set void MarkerSetFore=2041(int markerNumber, colour fore) + +# Set the background colour used for a particular marker number. +set void MarkerSetBack=2042(int markerNumber, colour back) + +# Set the background colour used for a particular marker number when its folding block is selected. +set void MarkerSetBackSelected=2292(int markerNumber, colour back) + +# Enable/disable highlight for current folding block (smallest one that contains the caret) +fun void MarkerEnableHighlight=2293(bool enabled,) + +# Add a marker to a line, returning an ID which can be used to find or delete the marker. +fun int MarkerAdd=2043(line line, int markerNumber) + +# Delete a marker from a line. +fun void MarkerDelete=2044(line line, int markerNumber) + +# Delete all markers with a particular number from all lines. +fun void MarkerDeleteAll=2045(int markerNumber,) + +# Get a bit mask of all the markers set on a line. +fun int MarkerGet=2046(line line,) + +# Find the next line at or after lineStart that includes a marker in mask. +# Return -1 when no more lines. +fun line MarkerNext=2047(line lineStart, int markerMask) + +# Find the previous line before lineStart that includes a marker in mask. +fun line MarkerPrevious=2048(line lineStart, int markerMask) + +# Define a marker from a pixmap. +fun void MarkerDefinePixmap=2049(int markerNumber, string pixmap) + +# Add a set of markers to a line. +fun void MarkerAddSet=2466(line line, int markerSet) + +# Set the alpha used for a marker that is drawn in the text area, not the margin. +set void MarkerSetAlpha=2476(int markerNumber, Alpha alpha) + +val SC_MAX_MARGIN=4 + +enu MarginType=SC_MARGIN_ +val SC_MARGIN_SYMBOL=0 +val SC_MARGIN_NUMBER=1 +val SC_MARGIN_BACK=2 +val SC_MARGIN_FORE=3 +val SC_MARGIN_TEXT=4 +val SC_MARGIN_RTEXT=5 +val SC_MARGIN_COLOUR=6 + +ali SC_MARGIN_RTEXT=R_TEXT + +# Set a margin to be either numeric or symbolic. +set void SetMarginTypeN=2240(int margin, MarginType marginType) + +# Retrieve the type of a margin. +get MarginType GetMarginTypeN=2241(int margin,) + +# Set the width of a margin to a width expressed in pixels. +set void SetMarginWidthN=2242(int margin, int pixelWidth) + +# Retrieve the width of a margin in pixels. +get int GetMarginWidthN=2243(int margin,) + +# Set a mask that determines which markers are displayed in a margin. +set void SetMarginMaskN=2244(int margin, int mask) + +# Retrieve the marker mask of a margin. +get int GetMarginMaskN=2245(int margin,) + +# Make a margin sensitive or insensitive to mouse clicks. +set void SetMarginSensitiveN=2246(int margin, bool sensitive) + +# Retrieve the mouse click sensitivity of a margin. +get bool GetMarginSensitiveN=2247(int margin,) + +# Set the cursor shown when the mouse is inside a margin. +set void SetMarginCursorN=2248(int margin, CursorShape cursor) + +# Retrieve the cursor shown in a margin. +get CursorShape GetMarginCursorN=2249(int margin,) + +# Set the background colour of a margin. Only visible for SC_MARGIN_COLOUR. +set void SetMarginBackN=2250(int margin, colour back) + +# Retrieve the background colour of a margin +get colour GetMarginBackN=2251(int margin,) + +# Allocate a non-standard number of margins. +set void SetMargins=2252(int margins,) + +# How many margins are there?. +get int GetMargins=2253(,) + +# Styles in range 32..39 are predefined for parts of the UI and are not used as normal styles. +enu StylesCommon=STYLE_ +val STYLE_DEFAULT=32 +val STYLE_LINENUMBER=33 +val STYLE_BRACELIGHT=34 +val STYLE_BRACEBAD=35 +val STYLE_CONTROLCHAR=36 +val STYLE_INDENTGUIDE=37 +val STYLE_CALLTIP=38 +val STYLE_FOLDDISPLAYTEXT=39 +val STYLE_LASTPREDEFINED=39 +val STYLE_MAX=255 + +ali STYLE_LINENUMBER=LINE_NUMBER +ali STYLE_BRACELIGHT=BRACE_LIGHT +ali STYLE_BRACEBAD=BRACE_BAD +ali STYLE_CONTROLCHAR=CONTROL_CHAR +ali STYLE_INDENTGUIDE=INDENT_GUIDE +ali STYLE_CALLTIP=CALL_TIP +ali STYLE_FOLDDISPLAYTEXT=FOLD_DISPLAY_TEXT +ali STYLE_LASTPREDEFINED=LAST_PREDEFINED + +# Character set identifiers are used in StyleSetCharacterSet. +# The values are the same as the Windows *_CHARSET values. +enu CharacterSet=SC_CHARSET_ +val SC_CHARSET_ANSI=0 +val SC_CHARSET_DEFAULT=1 +val SC_CHARSET_BALTIC=186 +val SC_CHARSET_CHINESEBIG5=136 +val SC_CHARSET_EASTEUROPE=238 +val SC_CHARSET_GB2312=134 +val SC_CHARSET_GREEK=161 +val SC_CHARSET_HANGUL=129 +val SC_CHARSET_MAC=77 +val SC_CHARSET_OEM=255 +val SC_CHARSET_RUSSIAN=204 +val SC_CHARSET_OEM866=866 +val SC_CHARSET_CYRILLIC=1251 +val SC_CHARSET_SHIFTJIS=128 +val SC_CHARSET_SYMBOL=2 +val SC_CHARSET_TURKISH=162 +val SC_CHARSET_JOHAB=130 +val SC_CHARSET_HEBREW=177 +val SC_CHARSET_ARABIC=178 +val SC_CHARSET_VIETNAMESE=163 +val SC_CHARSET_THAI=222 +val SC_CHARSET_8859_15=1000 + +ali SC_CHARSET_CHINESEBIG5=CHINESE_BIG5 +ali SC_CHARSET_EASTEUROPE=EAST_EUROPE +ali SC_CHARSET_GB2312=G_B_2312 +ali SC_CHARSET_OEM866=OEM_866 +ali SC_CHARSET_SHIFTJIS=SHIFT_JIS +ali SC_CHARSET_8859_15=ISO_8859_15 + +# Clear all the styles and make equivalent to the global default style. +fun void StyleClearAll=2050(,) + +# Set the foreground colour of a style. +set void StyleSetFore=2051(int style, colour fore) + +# Set the background colour of a style. +set void StyleSetBack=2052(int style, colour back) + +# Set a style to be bold or not. +set void StyleSetBold=2053(int style, bool bold) + +# Set a style to be italic or not. +set void StyleSetItalic=2054(int style, bool italic) + +# Set the size of characters of a style. +set void StyleSetSize=2055(int style, int sizePoints) + +# Set the font of a style. +set void StyleSetFont=2056(int style, string fontName) + +# Set a style to have its end of line filled or not. +set void StyleSetEOLFilled=2057(int style, bool eolFilled) + +# Reset the default style to its state at startup +fun void StyleResetDefault=2058(,) + +# Set a style to be underlined or not. +set void StyleSetUnderline=2059(int style, bool underline) + +enu CaseVisible=SC_CASE_ +val SC_CASE_MIXED=0 +val SC_CASE_UPPER=1 +val SC_CASE_LOWER=2 +val SC_CASE_CAMEL=3 + +# Get the foreground colour of a style. +get colour StyleGetFore=2481(int style,) + +# Get the background colour of a style. +get colour StyleGetBack=2482(int style,) + +# Get is a style bold or not. +get bool StyleGetBold=2483(int style,) + +# Get is a style italic or not. +get bool StyleGetItalic=2484(int style,) + +# Get the size of characters of a style. +get int StyleGetSize=2485(int style,) + +# Get the font of a style. +# Returns the length of the fontName +# Result is NUL-terminated. +get int StyleGetFont=2486(int style, stringresult fontName) + +# Get is a style to have its end of line filled or not. +get bool StyleGetEOLFilled=2487(int style,) + +# Get is a style underlined or not. +get bool StyleGetUnderline=2488(int style,) + +# Get is a style mixed case, or to force upper or lower case. +get CaseVisible StyleGetCase=2489(int style,) + +# Get the character get of the font in a style. +get CharacterSet StyleGetCharacterSet=2490(int style,) + +# Get is a style visible or not. +get bool StyleGetVisible=2491(int style,) + +# Get is a style changeable or not (read only). +# Experimental feature, currently buggy. +get bool StyleGetChangeable=2492(int style,) + +# Get is a style a hotspot or not. +get bool StyleGetHotSpot=2493(int style,) + +# Set a style to be mixed case, or to force upper or lower case. +set void StyleSetCase=2060(int style, CaseVisible caseVisible) + +val SC_FONT_SIZE_MULTIPLIER=100 + +# Set the size of characters of a style. Size is in points multiplied by 100. +set void StyleSetSizeFractional=2061(int style, int sizeHundredthPoints) + +# Get the size of characters of a style in points multiplied by 100 +get int StyleGetSizeFractional=2062(int style,) + +enu FontWeight=SC_WEIGHT_ +val SC_WEIGHT_NORMAL=400 +val SC_WEIGHT_SEMIBOLD=600 +val SC_WEIGHT_BOLD=700 + +ali SC_WEIGHT_SEMIBOLD=SEMI_BOLD + +# Set the weight of characters of a style. +set void StyleSetWeight=2063(int style, FontWeight weight) + +# Get the weight of characters of a style. +get FontWeight StyleGetWeight=2064(int style,) + +# Set the character set of the font in a style. +set void StyleSetCharacterSet=2066(int style, CharacterSet characterSet) + +# Set a style to be a hotspot or not. +set void StyleSetHotSpot=2409(int style, bool hotspot) + +# Set the foreground colour of the main and additional selections and whether to use this setting. +fun void SetSelFore=2067(bool useSetting, colour fore) + +# Set the background colour of the main and additional selections and whether to use this setting. +fun void SetSelBack=2068(bool useSetting, colour back) + +# Get the alpha of the selection. +get Alpha GetSelAlpha=2477(,) + +# Set the alpha of the selection. +set void SetSelAlpha=2478(Alpha alpha,) + +# Is the selection end of line filled? +get bool GetSelEOLFilled=2479(,) + +# Set the selection to have its end of line filled or not. +set void SetSelEOLFilled=2480(bool filled,) + +# Set the foreground colour of the caret. +set void SetCaretFore=2069(colour fore,) + +# When key+modifier combination keyDefinition is pressed perform sciCommand. +fun void AssignCmdKey=2070(keymod keyDefinition, int sciCommand) + +# When key+modifier combination keyDefinition is pressed do nothing. +fun void ClearCmdKey=2071(keymod keyDefinition,) + +# Drop all key mappings. +fun void ClearAllCmdKeys=2072(,) + +# Set the styles for a segment of the document. +fun void SetStylingEx=2073(position length, string styles) + +# Set a style to be visible or not. +set void StyleSetVisible=2074(int style, bool visible) + +# Get the time in milliseconds that the caret is on and off. +get int GetCaretPeriod=2075(,) + +# Get the time in milliseconds that the caret is on and off. 0 = steady on. +set void SetCaretPeriod=2076(int periodMilliseconds,) + +# Set the set of characters making up words for when moving or selecting by word. +# First sets defaults like SetCharsDefault. +set void SetWordChars=2077(, string characters) + +# Get the set of characters making up words for when moving or selecting by word. +# Returns the number of characters +get int GetWordChars=2646(, stringresult characters) + +# Set the number of characters to have directly indexed categories +set void SetCharacterCategoryOptimization=2720(int countCharacters,) + +# Get the number of characters to have directly indexed categories +get int GetCharacterCategoryOptimization=2721(,) + +# Start a sequence of actions that is undone and redone as a unit. +# May be nested. +fun void BeginUndoAction=2078(,) + +# End a sequence of actions that is undone and redone as a unit. +fun void EndUndoAction=2079(,) + +# Indicator style enumeration and some constants +enu IndicatorStyle=INDIC_ +val INDIC_PLAIN=0 +val INDIC_SQUIGGLE=1 +val INDIC_TT=2 +val INDIC_DIAGONAL=3 +val INDIC_STRIKE=4 +val INDIC_HIDDEN=5 +val INDIC_BOX=6 +val INDIC_ROUNDBOX=7 +val INDIC_STRAIGHTBOX=8 +val INDIC_DASH=9 +val INDIC_DOTS=10 +val INDIC_SQUIGGLELOW=11 +val INDIC_DOTBOX=12 +val INDIC_SQUIGGLEPIXMAP=13 +val INDIC_COMPOSITIONTHICK=14 +val INDIC_COMPOSITIONTHIN=15 +val INDIC_FULLBOX=16 +val INDIC_TEXTFORE=17 +val INDIC_POINT=18 +val INDIC_POINTCHARACTER=19 +val INDIC_GRADIENT=20 +val INDIC_GRADIENTCENTRE=21 + +# INDIC_CONTAINER, INDIC_IME, INDIC_IME_MAX, and INDIC_MAX are indicator numbers, +# not IndicatorStyles so should not really be in the INDIC_ enumeration. +# They are redeclared in IndicatorNumbers INDICATOR_. +val INDIC_CONTAINER=8 +val INDIC_IME=32 +val INDIC_IME_MAX=35 +val INDIC_MAX=35 + +enu IndicatorNumbers=INDICATOR_ +val INDICATOR_CONTAINER=8 +val INDICATOR_IME=32 +val INDICATOR_IME_MAX=35 +val INDICATOR_MAX=35 + +ali INDIC_TT=T_T +ali INDIC_ROUNDBOX=ROUND_BOX +ali INDIC_STRAIGHTBOX=STRAIGHT_BOX +ali INDIC_SQUIGGLELOW=SQUIGGLE_LOW +ali INDIC_DOTBOX=DOT_BOX +ali INDIC_SQUIGGLEPIXMAP=SQUIGGLE_PIXMAP +ali INDIC_COMPOSITIONTHICK=COMPOSITION_THICK +ali INDIC_COMPOSITIONTHIN=COMPOSITION_THIN +ali INDIC_FULLBOX=FULL_BOX +ali INDIC_TEXTFORE=TEXT_FORE +ali INDIC_POINTCHARACTER=POINT_CHARACTER +ali INDIC_GRADIENTCENTRE=GRADIENT_CENTRE + +# Set an indicator to plain, squiggle or TT. +set void IndicSetStyle=2080(int indicator, IndicatorStyle indicatorStyle) + +# Retrieve the style of an indicator. +get IndicatorStyle IndicGetStyle=2081(int indicator,) + +# Set the foreground colour of an indicator. +set void IndicSetFore=2082(int indicator, colour fore) + +# Retrieve the foreground colour of an indicator. +get colour IndicGetFore=2083(int indicator,) + +# Set an indicator to draw under text or over(default). +set void IndicSetUnder=2510(int indicator, bool under) + +# Retrieve whether indicator drawn under or over text. +get bool IndicGetUnder=2511(int indicator,) + +# Set a hover indicator to plain, squiggle or TT. +set void IndicSetHoverStyle=2680(int indicator, IndicatorStyle indicatorStyle) + +# Retrieve the hover style of an indicator. +get IndicatorStyle IndicGetHoverStyle=2681(int indicator,) + +# Set the foreground hover colour of an indicator. +set void IndicSetHoverFore=2682(int indicator, colour fore) + +# Retrieve the foreground hover colour of an indicator. +get colour IndicGetHoverFore=2683(int indicator,) + +enu IndicValue=SC_INDICVALUE +val SC_INDICVALUEBIT=0x1000000 +val SC_INDICVALUEMASK=0xFFFFFF + +enu IndicFlag=SC_INDICFLAG_ +val SC_INDICFLAG_VALUEFORE=1 + +ali SC_INDICFLAG_VALUEFORE=VALUE_FORE + +# Set the attributes of an indicator. +set void IndicSetFlags=2684(int indicator, IndicFlag flags) + +# Retrieve the attributes of an indicator. +get IndicFlag IndicGetFlags=2685(int indicator,) + +# Set the foreground colour of all whitespace and whether to use this setting. +fun void SetWhitespaceFore=2084(bool useSetting, colour fore) + +# Set the background colour of all whitespace and whether to use this setting. +fun void SetWhitespaceBack=2085(bool useSetting, colour back) + +# Set the size of the dots used to mark space characters. +set void SetWhitespaceSize=2086(int size,) + +# Get the size of the dots used to mark space characters. +get int GetWhitespaceSize=2087(,) + +# Used to hold extra styling information for each line. +set void SetLineState=2092(line line, int state) + +# Retrieve the extra styling information for a line. +get int GetLineState=2093(line line,) + +# Retrieve the last line number that has line state. +get int GetMaxLineState=2094(,) + +# Is the background of the line containing the caret in a different colour? +get bool GetCaretLineVisible=2095(,) + +# Display the background of the line containing the caret in a different colour. +set void SetCaretLineVisible=2096(bool show,) + +# Get the colour of the background of the line containing the caret. +get colour GetCaretLineBack=2097(,) + +# Set the colour of the background of the line containing the caret. +set void SetCaretLineBack=2098(colour back,) + +# Retrieve the caret line frame width. +# Width = 0 means this option is disabled. +get int GetCaretLineFrame=2704(,) + +# Display the caret line framed. +# Set width != 0 to enable this option and width = 0 to disable it. +set void SetCaretLineFrame=2705(int width,) + +# Set a style to be changeable or not (read only). +# Experimental feature, currently buggy. +set void StyleSetChangeable=2099(int style, bool changeable) + +# Display a auto-completion list. +# The lengthEntered parameter indicates how many characters before +# the caret should be used to provide context. +fun void AutoCShow=2100(position lengthEntered, string itemList) + +# Remove the auto-completion list from the screen. +fun void AutoCCancel=2101(,) + +# Is there an auto-completion list visible? +fun bool AutoCActive=2102(,) + +# Retrieve the position of the caret when the auto-completion list was displayed. +fun position AutoCPosStart=2103(,) + +# User has selected an item so remove the list and insert the selection. +fun void AutoCComplete=2104(,) + +# Define a set of character that when typed cancel the auto-completion list. +fun void AutoCStops=2105(, string characterSet) + +# Change the separator character in the string setting up an auto-completion list. +# Default is space but can be changed if items contain space. +set void AutoCSetSeparator=2106(int separatorCharacter,) + +# Retrieve the auto-completion list separator character. +get int AutoCGetSeparator=2107(,) + +# Select the item in the auto-completion list that starts with a string. +fun void AutoCSelect=2108(, string select) + +# Should the auto-completion list be cancelled if the user backspaces to a +# position before where the box was created. +set void AutoCSetCancelAtStart=2110(bool cancel,) + +# Retrieve whether auto-completion cancelled by backspacing before start. +get bool AutoCGetCancelAtStart=2111(,) + +# Define a set of characters that when typed will cause the autocompletion to +# choose the selected item. +set void AutoCSetFillUps=2112(, string characterSet) + +# Should a single item auto-completion list automatically choose the item. +set void AutoCSetChooseSingle=2113(bool chooseSingle,) + +# Retrieve whether a single item auto-completion list automatically choose the item. +get bool AutoCGetChooseSingle=2114(,) + +# Set whether case is significant when performing auto-completion searches. +set void AutoCSetIgnoreCase=2115(bool ignoreCase,) + +# Retrieve state of ignore case flag. +get bool AutoCGetIgnoreCase=2116(,) + +# Display a list of strings and send notification when user chooses one. +fun void UserListShow=2117(int listType, string itemList) + +# Set whether or not autocompletion is hidden automatically when nothing matches. +set void AutoCSetAutoHide=2118(bool autoHide,) + +# Retrieve whether or not autocompletion is hidden automatically when nothing matches. +get bool AutoCGetAutoHide=2119(,) + +# Set whether or not autocompletion deletes any word characters +# after the inserted text upon completion. +set void AutoCSetDropRestOfWord=2270(bool dropRestOfWord,) + +# Retrieve whether or not autocompletion deletes any word characters +# after the inserted text upon completion. +get bool AutoCGetDropRestOfWord=2271(,) + +# Register an XPM image for use in autocompletion lists. +fun void RegisterImage=2405(int type, string xpmData) + +# Clear all the registered XPM images. +fun void ClearRegisteredImages=2408(,) + +# Retrieve the auto-completion list type-separator character. +get int AutoCGetTypeSeparator=2285(,) + +# Change the type-separator character in the string setting up an auto-completion list. +# Default is '?' but can be changed if items contain '?'. +set void AutoCSetTypeSeparator=2286(int separatorCharacter,) + +# Set the maximum width, in characters, of auto-completion and user lists. +# Set to 0 to autosize to fit longest item, which is the default. +set void AutoCSetMaxWidth=2208(int characterCount,) + +# Get the maximum width, in characters, of auto-completion and user lists. +get int AutoCGetMaxWidth=2209(,) + +# Set the maximum height, in rows, of auto-completion and user lists. +# The default is 5 rows. +set void AutoCSetMaxHeight=2210(int rowCount,) + +# Set the maximum height, in rows, of auto-completion and user lists. +get int AutoCGetMaxHeight=2211(,) + +# Set the number of spaces used for one level of indentation. +set void SetIndent=2122(int indentSize,) + +# Retrieve indentation size. +get int GetIndent=2123(,) + +# Indentation will only use space characters if useTabs is false, otherwise +# it will use a combination of tabs and spaces. +set void SetUseTabs=2124(bool useTabs,) + +# Retrieve whether tabs will be used in indentation. +get bool GetUseTabs=2125(,) + +# Change the indentation of a line to a number of columns. +set void SetLineIndentation=2126(line line, int indentation) + +# Retrieve the number of columns that a line is indented. +get int GetLineIndentation=2127(line line,) + +# Retrieve the position before the first non indentation character on a line. +get position GetLineIndentPosition=2128(line line,) + +# Retrieve the column number of a position, taking tab width into account. +get position GetColumn=2129(position pos,) + +# Count characters between two positions. +fun position CountCharacters=2633(position start, position end) + +# Count code units between two positions. +fun position CountCodeUnits=2715(position start, position end) + +# Show or hide the horizontal scroll bar. +set void SetHScrollBar=2130(bool visible,) +# Is the horizontal scroll bar visible? +get bool GetHScrollBar=2131(,) + +enu IndentView=SC_IV_ +val SC_IV_NONE=0 +val SC_IV_REAL=1 +val SC_IV_LOOKFORWARD=2 +val SC_IV_LOOKBOTH=3 + +ali SC_IV_LOOKFORWARD=LOOK_FORWARD +ali SC_IV_LOOKBOTH=LOOK_BOTH + +# Show or hide indentation guides. +set void SetIndentationGuides=2132(IndentView indentView,) + +# Are the indentation guides visible? +get IndentView GetIndentationGuides=2133(,) + +# Set the highlighted indentation guide column. +# 0 = no highlighted guide. +set void SetHighlightGuide=2134(position column,) + +# Get the highlighted indentation guide column. +get position GetHighlightGuide=2135(,) + +# Get the position after the last visible characters on a line. +get position GetLineEndPosition=2136(line line,) + +# Get the code page used to interpret the bytes of the document as characters. +get int GetCodePage=2137(,) + +# Get the foreground colour of the caret. +get colour GetCaretFore=2138(,) + +# In read-only mode? +get bool GetReadOnly=2140(,) + +# Sets the position of the caret. +set void SetCurrentPos=2141(position caret,) + +# Sets the position that starts the selection - this becomes the anchor. +set void SetSelectionStart=2142(position anchor,) + +# Returns the position at the start of the selection. +get position GetSelectionStart=2143(,) + +# Sets the position that ends the selection - this becomes the caret. +set void SetSelectionEnd=2144(position caret,) + +# Returns the position at the end of the selection. +get position GetSelectionEnd=2145(,) + +# Set caret to a position, while removing any existing selection. +fun void SetEmptySelection=2556(position caret,) + +# Sets the print magnification added to the point size of each style for printing. +set void SetPrintMagnification=2146(int magnification,) + +# Returns the print magnification. +get int GetPrintMagnification=2147(,) + +enu PrintOption=SC_PRINT_ +# PrintColourMode - use same colours as screen. +# with the exception of line number margins, which use a white background +val SC_PRINT_NORMAL=0 +# PrintColourMode - invert the light value of each style for printing. +val SC_PRINT_INVERTLIGHT=1 +# PrintColourMode - force black text on white background for printing. +val SC_PRINT_BLACKONWHITE=2 +# PrintColourMode - text stays coloured, but all background is forced to be white for printing. +val SC_PRINT_COLOURONWHITE=3 +# PrintColourMode - only the default-background is forced to be white for printing. +val SC_PRINT_COLOURONWHITEDEFAULTBG=4 +# PrintColourMode - use same colours as screen, including line number margins. +val SC_PRINT_SCREENCOLOURS=5 + +ali SC_PRINT_INVERTLIGHT=INVERT_LIGHT +ali SC_PRINT_BLACKONWHITE=BLACK_ON_WHITE +ali SC_PRINT_COLOURONWHITE=COLOUR_ON_WHITE +ali SC_PRINT_COLOURONWHITEDEFAULTBG=COLOUR_ON_WHITE_DEFAULT_B_G +ali SC_PRINT_SCREENCOLOURS=SCREEN_COLOURS + +# Modify colours when printing for clearer printed text. +set void SetPrintColourMode=2148(PrintOption mode,) + +# Returns the print colour mode. +get PrintOption GetPrintColourMode=2149(,) + +enu FindOption=SCFIND_ +val SCFIND_NONE=0x0 +val SCFIND_WHOLEWORD=0x2 +val SCFIND_MATCHCASE=0x4 +val SCFIND_WORDSTART=0x00100000 +val SCFIND_REGEXP=0x00200000 +val SCFIND_POSIX=0x00400000 +val SCFIND_CXX11REGEX=0x00800000 + +ali SCFIND_WHOLEWORD=WHOLE_WORD +ali SCFIND_MATCHCASE=MATCH_CASE +ali SCFIND_WORDSTART=WORD_START +ali SCFIND_REGEXP=REG_EXP +ali SCFIND_CXX11REGEX=CXX11_REG_EX + +# Find some text in the document. +fun position FindText=2150(FindOption searchFlags, findtext ft) + +# On Windows, will draw the document into a display context such as a printer. +fun position FormatRange=2151(bool draw, formatrange fr) + +# Retrieve the display line at the top of the display. +get line GetFirstVisibleLine=2152(,) + +# Retrieve the contents of a line. +# Returns the length of the line. +fun position GetLine=2153(line line, stringresult text) + +# Returns the number of lines in the document. There is always at least one. +get line GetLineCount=2154(,) + +# Sets the size in pixels of the left margin. +set void SetMarginLeft=2155(, int pixelWidth) + +# Returns the size in pixels of the left margin. +get int GetMarginLeft=2156(,) + +# Sets the size in pixels of the right margin. +set void SetMarginRight=2157(, int pixelWidth) + +# Returns the size in pixels of the right margin. +get int GetMarginRight=2158(,) + +# Is the document different from when it was last saved? +get bool GetModify=2159(,) + +# Select a range of text. +fun void SetSel=2160(position anchor, position caret) + +# Retrieve the selected text. +# Return the length of the text. +# Result is NUL-terminated. +fun position GetSelText=2161(, stringresult text) + +# Retrieve a range of text. +# Return the length of the text. +fun position GetTextRange=2162(, textrange tr) + +# Draw the selection either highlighted or in normal (non-highlighted) style. +fun void HideSelection=2163(bool hide,) + +# Retrieve the x value of the point in the window where a position is displayed. +fun int PointXFromPosition=2164(, position pos) + +# Retrieve the y value of the point in the window where a position is displayed. +fun int PointYFromPosition=2165(, position pos) + +# Retrieve the line containing a position. +fun line LineFromPosition=2166(position pos,) + +# Retrieve the position at the start of a line. +fun position PositionFromLine=2167(line line,) + +# Scroll horizontally and vertically. +fun void LineScroll=2168(position columns, line lines) + +# Ensure the caret is visible. +fun void ScrollCaret=2169(,) + +# Scroll the argument positions and the range between them into view giving +# priority to the primary position then the secondary position. +# This may be used to make a search match visible. +fun void ScrollRange=2569(position secondary, position primary) + +# Replace the selected text with the argument text. +fun void ReplaceSel=2170(, string text) + +# Set to read only or read write. +set void SetReadOnly=2171(bool readOnly,) + +# Null operation. +fun void Null=2172(,) + +# Will a paste succeed? +fun bool CanPaste=2173(,) + +# Are there any undoable actions in the undo history? +fun bool CanUndo=2174(,) + +# Delete the undo history. +fun void EmptyUndoBuffer=2175(,) + +# Undo one action in the undo history. +fun void Undo=2176(,) + +# Cut the selection to the clipboard. +fun void Cut=2177(,) + +# Copy the selection to the clipboard. +fun void Copy=2178(,) + +# Paste the contents of the clipboard into the document replacing the selection. +fun void Paste=2179(,) + +# Clear the selection. +fun void Clear=2180(,) + +# Replace the contents of the document with the argument text. +fun void SetText=2181(, string text) + +# Retrieve all the text in the document. +# Returns number of characters retrieved. +# Result is NUL-terminated. +fun position GetText=2182(position length, stringresult text) + +# Retrieve the number of characters in the document. +get position GetTextLength=2183(,) + +# Retrieve a pointer to a function that processes messages for this Scintilla. +get pointer GetDirectFunction=2184(,) + +# Retrieve a pointer value to use as the first argument when calling +# the function returned by GetDirectFunction. +get pointer GetDirectPointer=2185(,) + +# Set to overtype (true) or insert mode. +set void SetOvertype=2186(bool overType,) + +# Returns true if overtype mode is active otherwise false is returned. +get bool GetOvertype=2187(,) + +# Set the width of the insert mode caret. +set void SetCaretWidth=2188(int pixelWidth,) + +# Returns the width of the insert mode caret. +get int GetCaretWidth=2189(,) + +# Sets the position that starts the target which is used for updating the +# document without affecting the scroll position. +set void SetTargetStart=2190(position start,) + +# Get the position that starts the target. +get position GetTargetStart=2191(,) + +# Sets the virtual space of the target start +set void SetTargetStartVirtualSpace=2728(position space,) + +# Get the virtual space of the target start +get position GetTargetStartVirtualSpace=2729(,) + +# Sets the position that ends the target which is used for updating the +# document without affecting the scroll position. +set void SetTargetEnd=2192(position end,) + +# Get the position that ends the target. +get position GetTargetEnd=2193(,) + +# Sets the virtual space of the target end +set void SetTargetEndVirtualSpace=2730(position space,) + +# Get the virtual space of the target end +get position GetTargetEndVirtualSpace=2731(,) + +# Sets both the start and end of the target in one call. +fun void SetTargetRange=2686(position start, position end) + +# Retrieve the text in the target. +get position GetTargetText=2687(, stringresult text) + +# Make the target range start and end be the same as the selection range start and end. +fun void TargetFromSelection=2287(,) + +# Sets the target to the whole document. +fun void TargetWholeDocument=2690(,) + +# Replace the target text with the argument text. +# Text is counted so it can contain NULs. +# Returns the length of the replacement text. +fun position ReplaceTarget=2194(position length, string text) + +# Replace the target text with the argument text after \d processing. +# Text is counted so it can contain NULs. +# Looks for \d where d is between 1 and 9 and replaces these with the strings +# matched in the last search operation which were surrounded by \( and \). +# Returns the length of the replacement text including any change +# caused by processing the \d patterns. +fun position ReplaceTargetRE=2195(position length, string text) + +# Search for a counted string in the target and set the target to the found +# range. Text is counted so it can contain NULs. +# Returns start of found range or -1 for failure in which case target is not moved. +fun position SearchInTarget=2197(position length, string text) + +# Set the search flags used by SearchInTarget. +set void SetSearchFlags=2198(FindOption searchFlags,) + +# Get the search flags used by SearchInTarget. +get FindOption GetSearchFlags=2199(,) + +# Show a call tip containing a definition near position pos. +fun void CallTipShow=2200(position pos, string definition) + +# Remove the call tip from the screen. +fun void CallTipCancel=2201(,) + +# Is there an active call tip? +fun bool CallTipActive=2202(,) + +# Retrieve the position where the caret was before displaying the call tip. +fun position CallTipPosStart=2203(,) + +# Set the start position in order to change when backspacing removes the calltip. +set void CallTipSetPosStart=2214(position posStart,) + +# Highlight a segment of the definition. +fun void CallTipSetHlt=2204(position highlightStart, position highlightEnd) + +# Set the background colour for the call tip. +set void CallTipSetBack=2205(colour back,) + +# Set the foreground colour for the call tip. +set void CallTipSetFore=2206(colour fore,) + +# Set the foreground colour for the highlighted part of the call tip. +set void CallTipSetForeHlt=2207(colour fore,) + +# Enable use of STYLE_CALLTIP and set call tip tab size in pixels. +set void CallTipUseStyle=2212(int tabSize,) + +# Set position of calltip, above or below text. +set void CallTipSetPosition=2213(bool above,) + +# Find the display line of a document line taking hidden lines into account. +fun line VisibleFromDocLine=2220(line docLine,) + +# Find the document line of a display line taking hidden lines into account. +fun line DocLineFromVisible=2221(line displayLine,) + +# The number of display lines needed to wrap a document line +fun line WrapCount=2235(line docLine,) + +enu FoldLevel=SC_FOLDLEVEL +val SC_FOLDLEVELBASE=0x400 +val SC_FOLDLEVELWHITEFLAG=0x1000 +val SC_FOLDLEVELHEADERFLAG=0x2000 +val SC_FOLDLEVELNUMBERMASK=0x0FFF + +ali SC_FOLDLEVELWHITEFLAG=WHITE_FLAG +ali SC_FOLDLEVELHEADERFLAG=HEADER_FLAG +ali SC_FOLDLEVELNUMBERMASK=NUMBER_MASK + +# Set the fold level of a line. +# This encodes an integer level along with flags indicating whether the +# line is a header and whether it is effectively white space. +set void SetFoldLevel=2222(line line, FoldLevel level) + +# Retrieve the fold level of a line. +get FoldLevel GetFoldLevel=2223(line line,) + +# Find the last child line of a header line. +get line GetLastChild=2224(line line, FoldLevel level) + +# Find the parent line of a child line. +get line GetFoldParent=2225(line line,) + +# Make a range of lines visible. +fun void ShowLines=2226(line lineStart, line lineEnd) + +# Make a range of lines invisible. +fun void HideLines=2227(line lineStart, line lineEnd) + +# Is a line visible? +get bool GetLineVisible=2228(line line,) + +# Are all lines visible? +get bool GetAllLinesVisible=2236(,) + +# Show the children of a header line. +set void SetFoldExpanded=2229(line line, bool expanded) + +# Is a header line expanded? +get bool GetFoldExpanded=2230(line line,) + +# Switch a header line between expanded and contracted. +fun void ToggleFold=2231(line line,) + +# Switch a header line between expanded and contracted and show some text after the line. +fun void ToggleFoldShowText=2700(line line, string text) + +enu FoldDisplayTextStyle=SC_FOLDDISPLAYTEXT_ +val SC_FOLDDISPLAYTEXT_HIDDEN=0 +val SC_FOLDDISPLAYTEXT_STANDARD=1 +val SC_FOLDDISPLAYTEXT_BOXED=2 + +# Set the style of fold display text. +set void FoldDisplayTextSetStyle=2701(FoldDisplayTextStyle style,) + +# Get the style of fold display text. +get FoldDisplayTextStyle FoldDisplayTextGetStyle=2707(,) + +# Set the default fold display text. +fun void SetDefaultFoldDisplayText=2722(, string text) + +# Get the default fold display text. +fun int GetDefaultFoldDisplayText=2723(, stringresult text) + +enu FoldAction=SC_FOLDACTION_ +val SC_FOLDACTION_CONTRACT=0 +val SC_FOLDACTION_EXPAND=1 +val SC_FOLDACTION_TOGGLE=2 + +# Expand or contract a fold header. +fun void FoldLine=2237(line line, FoldAction action) + +# Expand or contract a fold header and its children. +fun void FoldChildren=2238(line line, FoldAction action) + +# Expand a fold header and all children. Use the level argument instead of the line's current level. +fun void ExpandChildren=2239(line line, FoldLevel level) + +# Expand or contract all fold headers. +fun void FoldAll=2662(FoldAction action,) + +# Ensure a particular line is visible by expanding any header line hiding it. +fun void EnsureVisible=2232(line line,) + +enu AutomaticFold=SC_AUTOMATICFOLD_ +val SC_AUTOMATICFOLD_SHOW=0x0001 +val SC_AUTOMATICFOLD_CLICK=0x0002 +val SC_AUTOMATICFOLD_CHANGE=0x0004 + +# Set automatic folding behaviours. +set void SetAutomaticFold=2663(AutomaticFold automaticFold,) + +# Get automatic folding behaviours. +get AutomaticFold GetAutomaticFold=2664(,) + +enu FoldFlag=SC_FOLDFLAG_ +val SC_FOLDFLAG_LINEBEFORE_EXPANDED=0x0002 +val SC_FOLDFLAG_LINEBEFORE_CONTRACTED=0x0004 +val SC_FOLDFLAG_LINEAFTER_EXPANDED=0x0008 +val SC_FOLDFLAG_LINEAFTER_CONTRACTED=0x0010 +val SC_FOLDFLAG_LEVELNUMBERS=0x0040 +val SC_FOLDFLAG_LINESTATE=0x0080 + +ali SC_FOLDFLAG_LINEBEFORE_EXPANDED=LINE_BEFORE_EXPANDED +ali SC_FOLDFLAG_LINEBEFORE_CONTRACTED=LINE_BEFORE_CONTRACTED +ali SC_FOLDFLAG_LINEAFTER_EXPANDED=LINE_AFTER_EXPANDED +ali SC_FOLDFLAG_LINEAFTER_CONTRACTED=LINE_AFTER_CONTRACTED +ali SC_FOLDFLAG_LEVELNUMBERS=LEVEL_NUMBERS +ali SC_FOLDFLAG_LINESTATE=LINE_STATE + +# Set some style options for folding. +set void SetFoldFlags=2233(FoldFlag flags,) + +# Ensure a particular line is visible by expanding any header line hiding it. +# Use the currently set visibility policy to determine which range to display. +fun void EnsureVisibleEnforcePolicy=2234(line line,) + +# Sets whether a tab pressed when caret is within indentation indents. +set void SetTabIndents=2260(bool tabIndents,) + +# Does a tab pressed when caret is within indentation indent? +get bool GetTabIndents=2261(,) + +# Sets whether a backspace pressed when caret is within indentation unindents. +set void SetBackSpaceUnIndents=2262(bool bsUnIndents,) + +# Does a backspace pressed when caret is within indentation unindent? +get bool GetBackSpaceUnIndents=2263(,) + +val SC_TIME_FOREVER=10000000 + +# Sets the time the mouse must sit still to generate a mouse dwell event. +set void SetMouseDwellTime=2264(int periodMilliseconds,) + +# Retrieve the time the mouse must sit still to generate a mouse dwell event. +get int GetMouseDwellTime=2265(,) + +# Get position of start of word. +fun position WordStartPosition=2266(position pos, bool onlyWordCharacters) + +# Get position of end of word. +fun position WordEndPosition=2267(position pos, bool onlyWordCharacters) + +# Is the range start..end considered a word? +fun bool IsRangeWord=2691(position start, position end) + +enu IdleStyling=SC_IDLESTYLING_ +val SC_IDLESTYLING_NONE=0 +val SC_IDLESTYLING_TOVISIBLE=1 +val SC_IDLESTYLING_AFTERVISIBLE=2 +val SC_IDLESTYLING_ALL=3 + +ali SC_IDLESTYLING_TOVISIBLE=TO_VISIBLE +ali SC_IDLESTYLING_AFTERVISIBLE=AFTER_VISIBLE + +# Sets limits to idle styling. +set void SetIdleStyling=2692(IdleStyling idleStyling,) + +# Retrieve the limits to idle styling. +get IdleStyling GetIdleStyling=2693(,) + +enu Wrap=SC_WRAP_ +val SC_WRAP_NONE=0 +val SC_WRAP_WORD=1 +val SC_WRAP_CHAR=2 +val SC_WRAP_WHITESPACE=3 + +ali SC_WRAP_WHITESPACE=WHITE_SPACE + +# Sets whether text is word wrapped. +set void SetWrapMode=2268(Wrap wrapMode,) + +# Retrieve whether text is word wrapped. +get Wrap GetWrapMode=2269(,) + +enu WrapVisualFlag=SC_WRAPVISUALFLAG_ +val SC_WRAPVISUALFLAG_NONE=0x0000 +val SC_WRAPVISUALFLAG_END=0x0001 +val SC_WRAPVISUALFLAG_START=0x0002 +val SC_WRAPVISUALFLAG_MARGIN=0x0004 + +# Set the display mode of visual flags for wrapped lines. +set void SetWrapVisualFlags=2460(WrapVisualFlag wrapVisualFlags,) + +# Retrive the display mode of visual flags for wrapped lines. +get WrapVisualFlag GetWrapVisualFlags=2461(,) + +enu WrapVisualLocation=SC_WRAPVISUALFLAGLOC_ +val SC_WRAPVISUALFLAGLOC_DEFAULT=0x0000 +val SC_WRAPVISUALFLAGLOC_END_BY_TEXT=0x0001 +val SC_WRAPVISUALFLAGLOC_START_BY_TEXT=0x0002 + +# Set the location of visual flags for wrapped lines. +set void SetWrapVisualFlagsLocation=2462(WrapVisualLocation wrapVisualFlagsLocation,) + +# Retrive the location of visual flags for wrapped lines. +get WrapVisualLocation GetWrapVisualFlagsLocation=2463(,) + +# Set the start indent for wrapped lines. +set void SetWrapStartIndent=2464(int indent,) + +# Retrive the start indent for wrapped lines. +get int GetWrapStartIndent=2465(,) + +enu WrapIndentMode=SC_WRAPINDENT_ +val SC_WRAPINDENT_FIXED=0 +val SC_WRAPINDENT_SAME=1 +val SC_WRAPINDENT_INDENT=2 +val SC_WRAPINDENT_DEEPINDENT=3 + +ali SC_WRAPINDENT_DEEPINDENT=DEEP_INDENT + +# Sets how wrapped sublines are placed. Default is fixed. +set void SetWrapIndentMode=2472(WrapIndentMode wrapIndentMode,) + +# Retrieve how wrapped sublines are placed. Default is fixed. +get WrapIndentMode GetWrapIndentMode=2473(,) + +enu LineCache=SC_CACHE_ +val SC_CACHE_NONE=0 +val SC_CACHE_CARET=1 +val SC_CACHE_PAGE=2 +val SC_CACHE_DOCUMENT=3 + +# Sets the degree of caching of layout information. +set void SetLayoutCache=2272(LineCache cacheMode,) + +# Retrieve the degree of caching of layout information. +get LineCache GetLayoutCache=2273(,) + +# Sets the document width assumed for scrolling. +set void SetScrollWidth=2274(int pixelWidth,) + +# Retrieve the document width assumed for scrolling. +get int GetScrollWidth=2275(,) + +# Sets whether the maximum width line displayed is used to set scroll width. +set void SetScrollWidthTracking=2516(bool tracking,) + +# Retrieve whether the scroll width tracks wide lines. +get bool GetScrollWidthTracking=2517(,) + +# Measure the pixel width of some text in a particular style. +# NUL terminated text argument. +# Does not handle tab or control characters. +fun int TextWidth=2276(int style, string text) + +# 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. +set void SetEndAtLastLine=2277(bool endAtLastLine,) + +# Retrieve whether the maximum scroll position has the last +# line at the bottom of the view. +get bool GetEndAtLastLine=2278(,) + +# Retrieve the height of a particular line of text in pixels. +fun int TextHeight=2279(line line,) + +# Show or hide the vertical scroll bar. +set void SetVScrollBar=2280(bool visible,) + +# Is the vertical scroll bar visible? +get bool GetVScrollBar=2281(,) + +# Append a string to the end of the document without changing the selection. +fun void AppendText=2282(position length, string text) + +enu PhasesDraw=SC_PHASES_ +val SC_PHASES_ONE=0 +val SC_PHASES_TWO=1 +val SC_PHASES_MULTIPLE=2 + +# How many phases is drawing done in? +get PhasesDraw GetPhasesDraw=2673(,) + +# In one phase draw, text is drawn in a series of rectangular blocks with no overlap. +# In two phase draw, text is drawn in a series of lines allowing runs to overlap horizontally. +# In multiple phase draw, each element is drawn over the whole drawing area, allowing text +# to overlap from one line to the next. +set void SetPhasesDraw=2674(PhasesDraw phases,) + +# Control font anti-aliasing. + +enu FontQuality=SC_EFF_ +val SC_EFF_QUALITY_MASK=0xF +val SC_EFF_QUALITY_DEFAULT=0 +val SC_EFF_QUALITY_NON_ANTIALIASED=1 +val SC_EFF_QUALITY_ANTIALIASED=2 +val SC_EFF_QUALITY_LCD_OPTIMIZED=3 + +# Choose the quality level for text from the FontQuality enumeration. +set void SetFontQuality=2611(FontQuality fontQuality,) + +# Retrieve the quality level for text. +get FontQuality GetFontQuality=2612(,) + +# Scroll so that a display line is at the top of the display. +set void SetFirstVisibleLine=2613(line displayLine,) + +enu MultiPaste=SC_MULTIPASTE_ +val SC_MULTIPASTE_ONCE=0 +val SC_MULTIPASTE_EACH=1 + +# Change the effect of pasting when there are multiple selections. +set void SetMultiPaste=2614(MultiPaste multiPaste,) + +# Retrieve the effect of pasting when there are multiple selections. +get MultiPaste GetMultiPaste=2615(,) + +# Retrieve the value of a tag from a regular expression search. +# Result is NUL-terminated. +get int GetTag=2616(int tagNumber, stringresult tagValue) + +# Join the lines in the target. +fun void LinesJoin=2288(,) + +# Split the lines in the target into lines that are less wide than pixelWidth +# where possible. +fun void LinesSplit=2289(int pixelWidth,) + +# Set one of the colours used as a chequerboard pattern in the fold margin +fun void SetFoldMarginColour=2290(bool useSetting, colour back) +# Set the other colour used as a chequerboard pattern in the fold margin +fun void SetFoldMarginHiColour=2291(bool useSetting, colour fore) + +enu Accessibility=SC_ACCESSIBILITY_ +val SC_ACCESSIBILITY_DISABLED=0 +val SC_ACCESSIBILITY_ENABLED=1 + +# Enable or disable accessibility. +set void SetAccessibility=2702(Accessibility accessibility,) + +# Report accessibility status. +get Accessibility GetAccessibility=2703(,) + +## New messages go here + +## Start of key messages +# Move caret down one line. +fun void LineDown=2300(,) + +# Move caret down one line extending selection to new caret position. +fun void LineDownExtend=2301(,) + +# Move caret up one line. +fun void LineUp=2302(,) + +# Move caret up one line extending selection to new caret position. +fun void LineUpExtend=2303(,) + +# Move caret left one character. +fun void CharLeft=2304(,) + +# Move caret left one character extending selection to new caret position. +fun void CharLeftExtend=2305(,) + +# Move caret right one character. +fun void CharRight=2306(,) + +# Move caret right one character extending selection to new caret position. +fun void CharRightExtend=2307(,) + +# Move caret left one word. +fun void WordLeft=2308(,) + +# Move caret left one word extending selection to new caret position. +fun void WordLeftExtend=2309(,) + +# Move caret right one word. +fun void WordRight=2310(,) + +# Move caret right one word extending selection to new caret position. +fun void WordRightExtend=2311(,) + +# Move caret to first position on line. +fun void Home=2312(,) + +# Move caret to first position on line extending selection to new caret position. +fun void HomeExtend=2313(,) + +# Move caret to last position on line. +fun void LineEnd=2314(,) + +# Move caret to last position on line extending selection to new caret position. +fun void LineEndExtend=2315(,) + +# Move caret to first position in document. +fun void DocumentStart=2316(,) + +# Move caret to first position in document extending selection to new caret position. +fun void DocumentStartExtend=2317(,) + +# Move caret to last position in document. +fun void DocumentEnd=2318(,) + +# Move caret to last position in document extending selection to new caret position. +fun void DocumentEndExtend=2319(,) + +# Move caret one page up. +fun void PageUp=2320(,) + +# Move caret one page up extending selection to new caret position. +fun void PageUpExtend=2321(,) + +# Move caret one page down. +fun void PageDown=2322(,) + +# Move caret one page down extending selection to new caret position. +fun void PageDownExtend=2323(,) + +# Switch from insert to overtype mode or the reverse. +fun void EditToggleOvertype=2324(,) + +# Cancel any modes such as call tip or auto-completion list display. +fun void Cancel=2325(,) + +# Delete the selection or if no selection, the character before the caret. +fun void DeleteBack=2326(,) + +# If selection is empty or all on one line replace the selection with a tab character. +# If more than one line selected, indent the lines. +fun void Tab=2327(,) + +# Dedent the selected lines. +fun void BackTab=2328(,) + +# Insert a new line, may use a CRLF, CR or LF depending on EOL mode. +fun void NewLine=2329(,) + +# Insert a Form Feed character. +fun void FormFeed=2330(,) + +# Move caret to before first visible character on line. +# If already there move to first character on line. +fun void VCHome=2331(,) + +# Like VCHome but extending selection to new caret position. +fun void VCHomeExtend=2332(,) + +# Magnify the displayed text by increasing the sizes by 1 point. +fun void ZoomIn=2333(,) + +# Make the displayed text smaller by decreasing the sizes by 1 point. +fun void ZoomOut=2334(,) + +# Delete the word to the left of the caret. +fun void DelWordLeft=2335(,) + +# Delete the word to the right of the caret. +fun void DelWordRight=2336(,) + +# Delete the word to the right of the caret, but not the trailing non-word characters. +fun void DelWordRightEnd=2518(,) + +# Cut the line containing the caret. +fun void LineCut=2337(,) + +# Delete the line containing the caret. +fun void LineDelete=2338(,) + +# Switch the current line with the previous. +fun void LineTranspose=2339(,) + +# Reverse order of selected lines. +fun void LineReverse=2354(,) + +# Duplicate the current line. +fun void LineDuplicate=2404(,) + +# Transform the selection to lower case. +fun void LowerCase=2340(,) + +# Transform the selection to upper case. +fun void UpperCase=2341(,) + +# Scroll the document down, keeping the caret visible. +fun void LineScrollDown=2342(,) + +# Scroll the document up, keeping the caret visible. +fun void LineScrollUp=2343(,) + +# Delete the selection or if no selection, the character before the caret. +# Will not delete the character before at the start of a line. +fun void DeleteBackNotLine=2344(,) + +# Move caret to first position on display line. +fun void HomeDisplay=2345(,) + +# Move caret to first position on display line extending selection to +# new caret position. +fun void HomeDisplayExtend=2346(,) + +# Move caret to last position on display line. +fun void LineEndDisplay=2347(,) + +# Move caret to last position on display line extending selection to new +# caret position. +fun void LineEndDisplayExtend=2348(,) + +# Like Home but when word-wrap is enabled goes first to start of display line +# HomeDisplay, then to start of document line Home. +fun void HomeWrap=2349(,) + +# Like HomeExtend but when word-wrap is enabled extends first to start of display line +# HomeDisplayExtend, then to start of document line HomeExtend. +fun void HomeWrapExtend=2450(,) + +# Like LineEnd but when word-wrap is enabled goes first to end of display line +# LineEndDisplay, then to start of document line LineEnd. +fun void LineEndWrap=2451(,) + +# Like LineEndExtend but when word-wrap is enabled extends first to end of display line +# LineEndDisplayExtend, then to start of document line LineEndExtend. +fun void LineEndWrapExtend=2452(,) + +# Like VCHome but when word-wrap is enabled goes first to start of display line +# VCHomeDisplay, then behaves like VCHome. +fun void VCHomeWrap=2453(,) + +# Like VCHomeExtend but when word-wrap is enabled extends first to start of display line +# VCHomeDisplayExtend, then behaves like VCHomeExtend. +fun void VCHomeWrapExtend=2454(,) + +# Copy the line containing the caret. +fun void LineCopy=2455(,) + +# Move the caret inside current view if it's not there already. +fun void MoveCaretInsideView=2401(,) + +# How many characters are on a line, including end of line characters? +fun position LineLength=2350(line line,) + +# Highlight the characters at two positions. +fun void BraceHighlight=2351(position posA, position posB) + +# Use specified indicator to highlight matching braces instead of changing their style. +fun void BraceHighlightIndicator=2498(bool useSetting, int indicator) + +# Highlight the character at a position indicating there is no matching brace. +fun void BraceBadLight=2352(position pos,) + +# Use specified indicator to highlight non matching brace instead of changing its style. +fun void BraceBadLightIndicator=2499(bool useSetting, int indicator) + +# Find the position of a matching brace or INVALID_POSITION if no match. +# The maxReStyle must be 0 for now. It may be defined in a future release. +fun position BraceMatch=2353(position pos, int maxReStyle) + +# Similar to BraceMatch, but matching starts at the explicit start position. +fun position BraceMatchNext=2369(position pos, position startPos) + +# Are the end of line characters visible? +get bool GetViewEOL=2355(,) + +# Make the end of line characters visible or invisible. +set void SetViewEOL=2356(bool visible,) + +# Retrieve a pointer to the document object. +get pointer GetDocPointer=2357(,) + +# Change the document object used. +set void SetDocPointer=2358(, pointer doc) + +# Set which document modification events are sent to the container. +set void SetModEventMask=2359(ModificationFlags eventMask,) + +enu EdgeVisualStyle=EDGE_ +val EDGE_NONE=0 +val EDGE_LINE=1 +val EDGE_BACKGROUND=2 +val EDGE_MULTILINE=3 + +ali EDGE_MULTILINE=MULTI_LINE + +# Retrieve the column number which text should be kept within. +get position GetEdgeColumn=2360(,) + +# Set the column number of the edge. +# If text goes past the edge then it is highlighted. +set void SetEdgeColumn=2361(position column,) + +# Retrieve the edge highlight mode. +get EdgeVisualStyle GetEdgeMode=2362(,) + +# The edge may be displayed by a line (EDGE_LINE/EDGE_MULTILINE) or by highlighting text that +# goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE). +set void SetEdgeMode=2363(EdgeVisualStyle edgeMode,) + +# Retrieve the colour used in edge indication. +get colour GetEdgeColour=2364(,) + +# Change the colour used in edge indication. +set void SetEdgeColour=2365(colour edgeColour,) + +# Add a new vertical edge to the view. +fun void MultiEdgeAddLine=2694(position column, colour edgeColour) + +# Clear all vertical edges. +fun void MultiEdgeClearAll=2695(,) + +# Get multi edge positions. +get position GetMultiEdgeColumn=2749(int which,) + +# Sets the current caret position to be the search anchor. +fun void SearchAnchor=2366(,) + +# Find some text starting at the search anchor. +# Does not ensure the selection is visible. +fun position SearchNext=2367(FindOption searchFlags, string text) + +# Find some text starting at the search anchor and moving backwards. +# Does not ensure the selection is visible. +fun position SearchPrev=2368(FindOption searchFlags, string text) + +# Retrieves the number of lines completely visible. +get line LinesOnScreen=2370(,) + +enu PopUp=SC_POPUP_ +val SC_POPUP_NEVER=0 +val SC_POPUP_ALL=1 +val SC_POPUP_TEXT=2 + +# Set whether a pop up menu is displayed automatically when the user presses +# the wrong mouse button on certain areas. +fun void UsePopUp=2371(PopUp popUpMode,) + +# Is the selection rectangular? The alternative is the more common stream selection. +get bool SelectionIsRectangle=2372(,) + +# Set the zoom level. This number of points is added to the size of all fonts. +# It may be positive to magnify or negative to reduce. +set void SetZoom=2373(int zoomInPoints,) +# Retrieve the zoom level. +get int GetZoom=2374(,) + +enu DocumentOption=SC_DOCUMENTOPTION_ +val SC_DOCUMENTOPTION_DEFAULT=0 +val SC_DOCUMENTOPTION_STYLES_NONE=0x1 +val SC_DOCUMENTOPTION_TEXT_LARGE=0x100 + +# Create a new document object. +# Starts with reference count of 1 and not selected into editor. +fun pointer CreateDocument=2375(position bytes, DocumentOption documentOptions) +# Extend life of document. +fun void AddRefDocument=2376(, pointer doc) +# Release a reference to the document, deleting document if it fades to black. +fun void ReleaseDocument=2377(, pointer doc) + +# Get which document options are set. +get DocumentOption GetDocumentOptions=2379(,) + +# Get which document modification events are sent to the container. +get ModificationFlags GetModEventMask=2378(,) + +# Set whether command events are sent to the container. +set void SetCommandEvents=2717(bool commandEvents,) + +# Get whether command events are sent to the container. +get bool GetCommandEvents=2718(,) + +# Change internal focus flag. +set void SetFocus=2380(bool focus,) +# Get internal focus flag. +get bool GetFocus=2381(,) + +enu Status=SC_STATUS_ +val SC_STATUS_OK=0 +val SC_STATUS_FAILURE=1 +val SC_STATUS_BADALLOC=2 +val SC_STATUS_WARN_START=1000 +val SC_STATUS_WARN_REGEX=1001 + +ali SC_STATUS_BADALLOC=BAD_ALLOC +ali SC_STATUS_WARN_REGEX=REG_EX + +# Change error status - 0 = OK. +set void SetStatus=2382(Status status,) +# Get error status. +get Status GetStatus=2383(,) + +# Set whether the mouse is captured when its button is pressed. +set void SetMouseDownCaptures=2384(bool captures,) +# Get whether mouse gets captured. +get bool GetMouseDownCaptures=2385(,) + +# Set whether the mouse wheel can be active outside the window. +set void SetMouseWheelCaptures=2696(bool captures,) +# Get whether mouse wheel can be active outside the window. +get bool GetMouseWheelCaptures=2697(,) + +# Sets the cursor to one of the SC_CURSOR* values. +set void SetCursor=2386(CursorShape cursorType,) +# Get cursor type. +get CursorShape GetCursor=2387(,) + +# Change the way control characters are displayed: +# If symbol is < 32, keep the drawn way, else, use the given character. +set void SetControlCharSymbol=2388(int symbol,) +# Get the way control characters are displayed. +get int GetControlCharSymbol=2389(,) + +# Move to the previous change in capitalisation. +fun void WordPartLeft=2390(,) +# Move to the previous change in capitalisation extending selection +# to new caret position. +fun void WordPartLeftExtend=2391(,) +# Move to the change next in capitalisation. +fun void WordPartRight=2392(,) +# Move to the next change in capitalisation extending selection +# to new caret position. +fun void WordPartRightExtend=2393(,) + +# Constants for use with SetVisiblePolicy, similar to SetCaretPolicy. +enu VisiblePolicy=VISIBLE_ +val VISIBLE_SLOP=0x01 +val VISIBLE_STRICT=0x04 + +# Set the way the display area is determined when a particular line +# is to be moved to by Find, FindNext, GotoLine, etc. +fun void SetVisiblePolicy=2394(VisiblePolicy visiblePolicy, int visibleSlop) + +# Delete back from the current position to the start of the line. +fun void DelLineLeft=2395(,) + +# Delete forwards from the current position to the end of the line. +fun void DelLineRight=2396(,) + +# Set the xOffset (ie, horizontal scroll position). +set void SetXOffset=2397(int xOffset,) + +# Get the xOffset (ie, horizontal scroll position). +get int GetXOffset=2398(,) + +# Set the last x chosen value to be the caret x position. +fun void ChooseCaretX=2399(,) + +# Set the focus to this Scintilla widget. +fun void GrabFocus=2400(,) + +enu CaretPolicy=CARET_ +# Caret policy, used by SetXCaretPolicy and SetYCaretPolicy. +# If CARET_SLOP is set, we can define a slop value: caretSlop. +# This value defines an unwanted zone (UZ) where the caret is... unwanted. +# 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, +# so it is likely that the identifier that the caret is on can be completely seen, +# and that the current line is seen with some of the lines following it which are +# often dependent on that line. +val CARET_SLOP=0x01 +# If CARET_STRICT is set, the policy is enforced... strictly. +# The caret is centred on the display if slop is not set, +# and cannot go in the UZ if slop is set. +val CARET_STRICT=0x04 +# If CARET_JUMPS is set, the display is moved more energetically +# so the caret can move in the same direction longer before the policy is applied again. +val CARET_JUMPS=0x10 +# If CARET_EVEN is not set, instead of having symmetrical UZs, +# the left and bottom UZs are extended up to right and top UZs respectively. +# This way, we favour the displaying of useful information: the beginning of lines, +# where most code reside, and the lines after the caret, eg. the body of a function. +val CARET_EVEN=0x08 + +# Set the way the caret is kept visible when going sideways. +# The exclusion zone is given in pixels. +fun void SetXCaretPolicy=2402(CaretPolicy caretPolicy, int caretSlop) + +# Set the way the line the caret is on is kept visible. +# The exclusion zone is given in lines. +fun void SetYCaretPolicy=2403(CaretPolicy caretPolicy, int caretSlop) + +# Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE). +set void SetPrintWrapMode=2406(Wrap wrapMode,) + +# Is printing line wrapped? +get Wrap GetPrintWrapMode=2407(,) + +# Set a fore colour for active hotspots. +set void SetHotspotActiveFore=2410(bool useSetting, colour fore) + +# Get the fore colour for active hotspots. +get colour GetHotspotActiveFore=2494(,) + +# Set a back colour for active hotspots. +set void SetHotspotActiveBack=2411(bool useSetting, colour back) + +# Get the back colour for active hotspots. +get colour GetHotspotActiveBack=2495(,) + +# Enable / Disable underlining active hotspots. +set void SetHotspotActiveUnderline=2412(bool underline,) + +# Get whether underlining for active hotspots. +get bool GetHotspotActiveUnderline=2496(,) + +# Limit hotspots to single line so hotspots on two lines don't merge. +set void SetHotspotSingleLine=2421(bool singleLine,) + +# Get the HotspotSingleLine property +get bool GetHotspotSingleLine=2497(,) + +# Move caret down one paragraph (delimited by empty lines). +fun void ParaDown=2413(,) + +# Extend selection down one paragraph (delimited by empty lines). +fun void ParaDownExtend=2414(,) + +# Move caret up one paragraph (delimited by empty lines). +fun void ParaUp=2415(,) + +# Extend selection up one paragraph (delimited by empty lines). +fun void ParaUpExtend=2416(,) + +# Given a valid document position, return the previous position taking code +# page into account. Returns 0 if passed 0. +fun position PositionBefore=2417(position pos,) + +# Given a valid document position, return the next position taking code +# page into account. Maximum value returned is the last position in the document. +fun position PositionAfter=2418(position pos,) + +# Given a valid document position, return a position that differs in a number +# of characters. Returned value is always between 0 and last position in document. +fun position PositionRelative=2670(position pos, position relative) + +# Given a valid document position, return a position that differs in a number +# of UTF-16 code units. Returned value is always between 0 and last position in document. +# The result may point half way (2 bytes) inside a non-BMP character. +fun position PositionRelativeCodeUnits=2716(position pos, position relative) + +# Copy a range of text to the clipboard. Positions are clipped into the document. +fun void CopyRange=2419(position start, position end) + +# Copy argument text to the clipboard. +fun void CopyText=2420(position length, string text) + +enu SelectionMode=SC_SEL_ +val SC_SEL_STREAM=0 +val SC_SEL_RECTANGLE=1 +val SC_SEL_LINES=2 +val SC_SEL_THIN=3 + +# Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or +# by lines (SC_SEL_LINES). +set void SetSelectionMode=2422(SelectionMode selectionMode,) + +# Get the mode of the current selection. +get SelectionMode GetSelectionMode=2423(,) + +# Get whether or not regular caret moves will extend or reduce the selection. +get bool GetMoveExtendsSelection=2706(,) + +# Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). +fun position GetLineSelStartPosition=2424(line line,) + +# Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). +fun position GetLineSelEndPosition=2425(line line,) + +## RectExtended rectangular selection moves +# Move caret down one line, extending rectangular selection to new caret position. +fun void LineDownRectExtend=2426(,) + +# Move caret up one line, extending rectangular selection to new caret position. +fun void LineUpRectExtend=2427(,) + +# Move caret left one character, extending rectangular selection to new caret position. +fun void CharLeftRectExtend=2428(,) + +# Move caret right one character, extending rectangular selection to new caret position. +fun void CharRightRectExtend=2429(,) + +# Move caret to first position on line, extending rectangular selection to new caret position. +fun void HomeRectExtend=2430(,) + +# Move caret to before first visible character on line. +# If already there move to first character on line. +# In either case, extend rectangular selection to new caret position. +fun void VCHomeRectExtend=2431(,) + +# Move caret to last position on line, extending rectangular selection to new caret position. +fun void LineEndRectExtend=2432(,) + +# Move caret one page up, extending rectangular selection to new caret position. +fun void PageUpRectExtend=2433(,) + +# Move caret one page down, extending rectangular selection to new caret position. +fun void PageDownRectExtend=2434(,) + + +# Move caret to top of page, or one page up if already at top of page. +fun void StutteredPageUp=2435(,) + +# Move caret to top of page, or one page up if already at top of page, extending selection to new caret position. +fun void StutteredPageUpExtend=2436(,) + +# Move caret to bottom of page, or one page down if already at bottom of page. +fun void StutteredPageDown=2437(,) + +# Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position. +fun void StutteredPageDownExtend=2438(,) + + +# Move caret left one word, position cursor at end of word. +fun void WordLeftEnd=2439(,) + +# Move caret left one word, position cursor at end of word, extending selection to new caret position. +fun void WordLeftEndExtend=2440(,) + +# Move caret right one word, position cursor at end of word. +fun void WordRightEnd=2441(,) + +# Move caret right one word, position cursor at end of word, extending selection to new caret position. +fun void WordRightEndExtend=2442(,) + +# Set the set of characters making up whitespace for when moving or selecting by word. +# Should be called after SetWordChars. +set void SetWhitespaceChars=2443(, string characters) + +# Get the set of characters making up whitespace for when moving or selecting by word. +get int GetWhitespaceChars=2647(, stringresult characters) + +# Set the set of characters making up punctuation characters +# Should be called after SetWordChars. +set void SetPunctuationChars=2648(, string characters) + +# Get the set of characters making up punctuation characters +get int GetPunctuationChars=2649(, stringresult characters) + +# Reset the set of characters for whitespace and word characters to the defaults. +fun void SetCharsDefault=2444(,) + +# Get currently selected item position in the auto-completion list +get int AutoCGetCurrent=2445(,) + +# Get currently selected item text in the auto-completion list +# Returns the length of the item text +# Result is NUL-terminated. +get int AutoCGetCurrentText=2610(, stringresult text) + +enu CaseInsensitiveBehaviour=SC_CASEINSENSITIVEBEHAVIOUR_ +val SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE=0 +val SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE=1 + +ali SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE=RESPECT_CASE +ali SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE=IGNORE_CASE + +# Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference. +set void AutoCSetCaseInsensitiveBehaviour=2634(CaseInsensitiveBehaviour behaviour,) + +# Get auto-completion case insensitive behaviour. +get CaseInsensitiveBehaviour AutoCGetCaseInsensitiveBehaviour=2635(,) + +enu MultiAutoComplete=SC_MULTIAUTOC_ +val SC_MULTIAUTOC_ONCE=0 +val SC_MULTIAUTOC_EACH=1 + +# Change the effect of autocompleting when there are multiple selections. +set void AutoCSetMulti=2636(MultiAutoComplete multi,) + +# Retrieve the effect of autocompleting when there are multiple selections. +get MultiAutoComplete AutoCGetMulti=2637(,) + +enu Ordering=SC_ORDER_ +val SC_ORDER_PRESORTED=0 +val SC_ORDER_PERFORMSORT=1 +val SC_ORDER_CUSTOM=2 + +ali SC_ORDER_PRESORTED=PRE_SORTED +ali SC_ORDER_PERFORMSORT=PERFORM_SORT + +# Set the way autocompletion lists are ordered. +set void AutoCSetOrder=2660(Ordering order,) + +# Get the way autocompletion lists are ordered. +get Ordering AutoCGetOrder=2661(,) + +# Enlarge the document to a particular size of text bytes. +fun void Allocate=2446(position bytes,) + +# Returns the target converted to UTF8. +# Return the length in bytes. +fun position TargetAsUTF8=2447(, stringresult s) + +# Set the length of the utf8 argument for calling EncodedFromUTF8. +# Set to -1 and the string will be measured to the first nul. +fun void SetLengthForEncode=2448(position bytes,) + +# Translates a UTF8 string into the document encoding. +# Return the length of the result in bytes. +# On error return 0. +fun position EncodedFromUTF8=2449(string utf8, stringresult encoded) + +# Find the position of a column on a line taking into account tabs and +# multi-byte characters. If beyond end of line, return line end position. +fun position FindColumn=2456(line line, position column) + +enu CaretSticky=SC_CARETSTICKY_ +val SC_CARETSTICKY_OFF=0 +val SC_CARETSTICKY_ON=1 +val SC_CARETSTICKY_WHITESPACE=2 + +ali SC_CARETSTICKY_WHITESPACE=WHITE_SPACE + +# Can the caret preferred x position only be changed by explicit movement commands? +get CaretSticky GetCaretSticky=2457(,) + +# Stop the caret preferred x position changing when the user types. +set void SetCaretSticky=2458(CaretSticky useCaretStickyBehaviour,) + +# Switch between sticky and non-sticky: meant to be bound to a key. +fun void ToggleCaretSticky=2459(,) + +# Enable/Disable convert-on-paste for line endings +set void SetPasteConvertEndings=2467(bool convert,) + +# Get convert-on-paste setting +get bool GetPasteConvertEndings=2468(,) + +# Duplicate the selection. If selection empty duplicate the line containing the caret. +fun void SelectionDuplicate=2469(,) + +# Set background alpha of the caret line. +set void SetCaretLineBackAlpha=2470(Alpha alpha,) + +# Get the background alpha of the caret line. +get Alpha GetCaretLineBackAlpha=2471(,) + +enu CaretStyle=CARETSTYLE_ +val CARETSTYLE_INVISIBLE=0 +val CARETSTYLE_LINE=1 +val CARETSTYLE_BLOCK=2 +val CARETSTYLE_OVERSTRIKE_BAR=0 +val CARETSTYLE_OVERSTRIKE_BLOCK=0x10 +val CARETSTYLE_INS_MASK=0xF +val CARETSTYLE_BLOCK_AFTER=0x100 + +# Set the style of the caret to be drawn. +set void SetCaretStyle=2512(CaretStyle caretStyle,) + +# Returns the current style of the caret. +get CaretStyle GetCaretStyle=2513(,) + +# Set the indicator used for IndicatorFillRange and IndicatorClearRange +set void SetIndicatorCurrent=2500(int indicator,) + +# Get the current indicator +get int GetIndicatorCurrent=2501(,) + +# Set the value used for IndicatorFillRange +set void SetIndicatorValue=2502(int value,) + +# Get the current indicator value +get int GetIndicatorValue=2503(,) + +# Turn a indicator on over a range. +fun void IndicatorFillRange=2504(position start, position lengthFill) + +# Turn a indicator off over a range. +fun void IndicatorClearRange=2505(position start, position lengthClear) + +# Are any indicators present at pos? +fun int IndicatorAllOnFor=2506(position pos,) + +# What value does a particular indicator have at a position? +fun int IndicatorValueAt=2507(int indicator, position pos) + +# Where does a particular indicator start? +fun position IndicatorStart=2508(int indicator, position pos) + +# Where does a particular indicator end? +fun position IndicatorEnd=2509(int indicator, position pos) + +# Set number of entries in position cache +set void SetPositionCache=2514(int size,) + +# How many entries are allocated to the position cache? +get int GetPositionCache=2515(,) + +# Copy the selection, if selection empty copy the line with the caret +fun void CopyAllowLine=2519(,) + +# Compact the document buffer and return a read-only pointer to the +# characters in the document. +get pointer GetCharacterPointer=2520(,) + +# Return a read-only pointer to a range of characters in the document. +# May move the gap so that the range is contiguous, but will only move up +# to lengthRange bytes. +get pointer GetRangePointer=2643(position start, position lengthRange) + +# Return a position which, to avoid performance costs, should not be within +# the range of a call to GetRangePointer. +get position GetGapPosition=2644(,) + +# Set the alpha fill colour of the given indicator. +set void IndicSetAlpha=2523(int indicator, Alpha alpha) + +# Get the alpha fill colour of the given indicator. +get Alpha IndicGetAlpha=2524(int indicator,) + +# Set the alpha outline colour of the given indicator. +set void IndicSetOutlineAlpha=2558(int indicator, Alpha alpha) + +# Get the alpha outline colour of the given indicator. +get Alpha IndicGetOutlineAlpha=2559(int indicator,) + +# Set extra ascent for each line +set void SetExtraAscent=2525(int extraAscent,) + +# Get extra ascent for each line +get int GetExtraAscent=2526(,) + +# Set extra descent for each line +set void SetExtraDescent=2527(int extraDescent,) + +# Get extra descent for each line +get int GetExtraDescent=2528(,) + +# Which symbol was defined for markerNumber with MarkerDefine +fun int MarkerSymbolDefined=2529(int markerNumber,) + +# Set the text in the text margin for a line +set void MarginSetText=2530(line line, string text) + +# Get the text in the text margin for a line +get int MarginGetText=2531(line line, stringresult text) + +# Set the style number for the text margin for a line +set void MarginSetStyle=2532(line line, int style) + +# Get the style number for the text margin for a line +get int MarginGetStyle=2533(line line,) + +# Set the style in the text margin for a line +set void MarginSetStyles=2534(line line, string styles) + +# Get the styles in the text margin for a line +get int MarginGetStyles=2535(line line, stringresult styles) + +# Clear the margin text on all lines +fun void MarginTextClearAll=2536(,) + +# Get the start of the range of style numbers used for margin text +set void MarginSetStyleOffset=2537(int style,) + +# Get the start of the range of style numbers used for margin text +get int MarginGetStyleOffset=2538(,) + +enu MarginOption=SC_MARGINOPTION_ +val SC_MARGINOPTION_NONE=0 +val SC_MARGINOPTION_SUBLINESELECT=1 + +ali SC_MARGINOPTION_SUBLINESELECT=SUB_LINE_SELECT + +# Set the margin options. +set void SetMarginOptions=2539(MarginOption marginOptions,) + +# Get the margin options. +get MarginOption GetMarginOptions=2557(,) + +# Set the annotation text for a line +set void AnnotationSetText=2540(line line, string text) + +# Get the annotation text for a line +get int AnnotationGetText=2541(line line, stringresult text) + +# Set the style number for the annotations for a line +set void AnnotationSetStyle=2542(line line, int style) + +# Get the style number for the annotations for a line +get int AnnotationGetStyle=2543(line line,) + +# Set the annotation styles for a line +set void AnnotationSetStyles=2544(line line, string styles) + +# Get the annotation styles for a line +get int AnnotationGetStyles=2545(line line, stringresult styles) + +# Get the number of annotation lines for a line +get int AnnotationGetLines=2546(line line,) + +# Clear the annotations from all lines +fun void AnnotationClearAll=2547(,) + +enu AnnotationVisible=ANNOTATION_ +val ANNOTATION_HIDDEN=0 +val ANNOTATION_STANDARD=1 +val ANNOTATION_BOXED=2 +val ANNOTATION_INDENTED=3 + +# Set the visibility for the annotations for a view +set void AnnotationSetVisible=2548(AnnotationVisible visible,) + +# Get the visibility for the annotations for a view +get AnnotationVisible AnnotationGetVisible=2549(,) + +# Get the start of the range of style numbers used for annotations +set void AnnotationSetStyleOffset=2550(int style,) + +# Get the start of the range of style numbers used for annotations +get int AnnotationGetStyleOffset=2551(,) + +# Release all extended (>255) style numbers +fun void ReleaseAllExtendedStyles=2552(,) + +# Allocate some extended (>255) style numbers and return the start of the range +fun int AllocateExtendedStyles=2553(int numberStyles,) + +enu UndoFlags=UNDO_ +val UNDO_NONE=0 +val UNDO_MAY_COALESCE=1 + +# Add a container action to the undo stack +fun void AddUndoAction=2560(int token, UndoFlags flags) + +# Find the position of a character from a point within the window. +fun position CharPositionFromPoint=2561(int x, int y) + +# Find the position of a character from a point within the window. +# Return INVALID_POSITION if not close to text. +fun position CharPositionFromPointClose=2562(int x, int y) + +# Set whether switching to rectangular mode while selecting with the mouse is allowed. +set void SetMouseSelectionRectangularSwitch=2668(bool mouseSelectionRectangularSwitch,) + +# Whether switching to rectangular mode while selecting with the mouse is allowed. +get bool GetMouseSelectionRectangularSwitch=2669(,) + +# Set whether multiple selections can be made +set void SetMultipleSelection=2563(bool multipleSelection,) + +# Whether multiple selections can be made +get bool GetMultipleSelection=2564(,) + +# Set whether typing can be performed into multiple selections +set void SetAdditionalSelectionTyping=2565(bool additionalSelectionTyping,) + +# Whether typing can be performed into multiple selections +get bool GetAdditionalSelectionTyping=2566(,) + +# Set whether additional carets will blink +set void SetAdditionalCaretsBlink=2567(bool additionalCaretsBlink,) + +# Whether additional carets will blink +get bool GetAdditionalCaretsBlink=2568(,) + +# Set whether additional carets are visible +set void SetAdditionalCaretsVisible=2608(bool additionalCaretsVisible,) + +# Whether additional carets are visible +get bool GetAdditionalCaretsVisible=2609(,) + +# How many selections are there? +get int GetSelections=2570(,) + +# Is every selected range empty? +get bool GetSelectionEmpty=2650(,) + +# Clear selections to a single empty stream selection +fun void ClearSelections=2571(,) + +# Set a simple selection +fun void SetSelection=2572(position caret, position anchor) + +# Add a selection +fun void AddSelection=2573(position caret, position anchor) + +# Drop one selection +fun void DropSelectionN=2671(int selection,) + +# Set the main selection +set void SetMainSelection=2574(int selection,) + +# Which selection is the main selection +get int GetMainSelection=2575(,) + +# Set the caret position of the nth selection. +set void SetSelectionNCaret=2576(int selection, position caret) + +# Return the caret position of the nth selection. +get position GetSelectionNCaret=2577(int selection,) + +# Set the anchor position of the nth selection. +set void SetSelectionNAnchor=2578(int selection, position anchor) + +# Return the anchor position of the nth selection. +get position GetSelectionNAnchor=2579(int selection,) + +# Set the virtual space of the caret of the nth selection. +set void SetSelectionNCaretVirtualSpace=2580(int selection, position space) + +# Return the virtual space of the caret of the nth selection. +get position GetSelectionNCaretVirtualSpace=2581(int selection,) + +# Set the virtual space of the anchor of the nth selection. +set void SetSelectionNAnchorVirtualSpace=2582(int selection, position space) + +# Return the virtual space of the anchor of the nth selection. +get position GetSelectionNAnchorVirtualSpace=2583(int selection,) + +# Sets the position that starts the selection - this becomes the anchor. +set void SetSelectionNStart=2584(int selection, position anchor) + +# Returns the position at the start of the selection. +get position GetSelectionNStart=2585(int selection,) + +# Returns the virtual space at the start of the selection. +get position GetSelectionNStartVirtualSpace=2726(int selection,) + +# Sets the position that ends the selection - this becomes the currentPosition. +set void SetSelectionNEnd=2586(int selection, position caret) + +# Returns the virtual space at the end of the selection. +get position GetSelectionNEndVirtualSpace=2727(int selection,) + +# Returns the position at the end of the selection. +get position GetSelectionNEnd=2587(int selection,) + +# Set the caret position of the rectangular selection. +set void SetRectangularSelectionCaret=2588(position caret,) + +# Return the caret position of the rectangular selection. +get position GetRectangularSelectionCaret=2589(,) + +# Set the anchor position of the rectangular selection. +set void SetRectangularSelectionAnchor=2590(position anchor,) + +# Return the anchor position of the rectangular selection. +get position GetRectangularSelectionAnchor=2591(,) + +# Set the virtual space of the caret of the rectangular selection. +set void SetRectangularSelectionCaretVirtualSpace=2592(position space,) + +# Return the virtual space of the caret of the rectangular selection. +get position GetRectangularSelectionCaretVirtualSpace=2593(,) + +# Set the virtual space of the anchor of the rectangular selection. +set void SetRectangularSelectionAnchorVirtualSpace=2594(position space,) + +# Return the virtual space of the anchor of the rectangular selection. +get position GetRectangularSelectionAnchorVirtualSpace=2595(,) + +enu VirtualSpace=SCVS_ +val SCVS_NONE=0 +val SCVS_RECTANGULARSELECTION=1 +val SCVS_USERACCESSIBLE=2 +val SCVS_NOWRAPLINESTART=4 + +ali SCVS_RECTANGULARSELECTION=RECTANGULAR_SELECTION +ali SCVS_USERACCESSIBLE=USER_ACCESSIBLE +ali SCVS_NOWRAPLINESTART=NO_WRAP_LINE_START + +# Set options for virtual space behaviour. +set void SetVirtualSpaceOptions=2596(VirtualSpace virtualSpaceOptions,) + +# Return options for virtual space behaviour. +get VirtualSpace GetVirtualSpaceOptions=2597(,) + +# On GTK, allow selecting the modifier key to use for mouse-based +# rectangular selection. Often the window manager requires Alt+Mouse Drag +# for moving windows. +# Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER. + +set void SetRectangularSelectionModifier=2598(int modifier,) + +# Get the modifier key used for rectangular selection. +get int GetRectangularSelectionModifier=2599(,) + +# Set the foreground colour of additional selections. +# Must have previously called SetSelFore with non-zero first argument for this to have an effect. +set void SetAdditionalSelFore=2600(colour fore,) + +# Set the background colour of additional selections. +# Must have previously called SetSelBack with non-zero first argument for this to have an effect. +set void SetAdditionalSelBack=2601(colour back,) + +# Set the alpha of the selection. +set void SetAdditionalSelAlpha=2602(Alpha alpha,) + +# Get the alpha of the selection. +get Alpha GetAdditionalSelAlpha=2603(,) + +# Set the foreground colour of additional carets. +set void SetAdditionalCaretFore=2604(colour fore,) + +# Get the foreground colour of additional carets. +get colour GetAdditionalCaretFore=2605(,) + +# Set the main selection to the next selection. +fun void RotateSelection=2606(,) + +# Swap that caret and anchor of the main selection. +fun void SwapMainAnchorCaret=2607(,) + +# Add the next occurrence of the main selection to the set of selections as main. +# If the current selection is empty then select word around caret. +fun void MultipleSelectAddNext=2688(,) + +# Add each occurrence of the main selection in the target to the set of selections. +# If the current selection is empty then select word around caret. +fun void MultipleSelectAddEach=2689(,) + +# Indicate that the internal state of a lexer has changed over a range and therefore +# there may be a need to redraw. +fun int ChangeLexerState=2617(position start, position end) + +# Find the next line at or after lineStart that is a contracted fold header line. +# Return -1 when no more lines. +fun line ContractedFoldNext=2618(line lineStart,) + +# Centre current line in window. +fun void VerticalCentreCaret=2619(,) + +# Move the selected lines up one line, shifting the line above after the selection +fun void MoveSelectedLinesUp=2620(,) + +# Move the selected lines down one line, shifting the line below before the selection +fun void MoveSelectedLinesDown=2621(,) + +# Set the identifier reported as idFrom in notification messages. +set void SetIdentifier=2622(int identifier,) + +# Get the identifier. +get int GetIdentifier=2623(,) + +# Set the width for future RGBA image data. +set void RGBAImageSetWidth=2624(int width,) + +# Set the height for future RGBA image data. +set void RGBAImageSetHeight=2625(int height,) + +# Set the scale factor in percent for future RGBA image data. +set void RGBAImageSetScale=2651(int scalePercent,) + +# Define a marker from RGBA data. +# It has the width and height from RGBAImageSetWidth/Height +fun void MarkerDefineRGBAImage=2626(int markerNumber, string pixels) + +# Register an RGBA image for use in autocompletion lists. +# It has the width and height from RGBAImageSetWidth/Height +fun void RegisterRGBAImage=2627(int type, string pixels) + +# Scroll to start of document. +fun void ScrollToStart=2628(,) + +# Scroll to end of document. +fun void ScrollToEnd=2629(,) + +enu Technology=SC_TECHNOLOGY_ +val SC_TECHNOLOGY_DEFAULT=0 +val SC_TECHNOLOGY_DIRECTWRITE=1 +val SC_TECHNOLOGY_DIRECTWRITERETAIN=2 +val SC_TECHNOLOGY_DIRECTWRITEDC=3 + +ali SC_TECHNOLOGY_DIRECTWRITE=DIRECT_WRITE +ali SC_TECHNOLOGY_DIRECTWRITERETAIN=DIRECT_WRITE_RETAIN +ali SC_TECHNOLOGY_DIRECTWRITEDC=DIRECT_WRITE_D_C + +# Set the technology used. +set void SetTechnology=2630(Technology technology,) + +# Get the tech. +get Technology GetTechnology=2631(,) + +# Create an ILoader*. +fun pointer CreateLoader=2632(position bytes, DocumentOption documentOptions) + +# On OS X, show a find indicator. +fun void FindIndicatorShow=2640(position start, position end) + +# On OS X, flash a find indicator, then fade out. +fun void FindIndicatorFlash=2641(position start, position end) + +# On OS X, hide the find indicator. +fun void FindIndicatorHide=2642(,) + +# Move caret to before first visible character on display line. +# If already there move to first character on display line. +fun void VCHomeDisplay=2652(,) + +# Like VCHomeDisplay but extending selection to new caret position. +fun void VCHomeDisplayExtend=2653(,) + +# Is the caret line always visible? +get bool GetCaretLineVisibleAlways=2654(,) + +# Sets the caret line to always visible. +set void SetCaretLineVisibleAlways=2655(bool alwaysVisible,) + +# Line end types which may be used in addition to LF, CR, and CRLF +# SC_LINE_END_TYPE_UNICODE includes U+2028 Line Separator, +# U+2029 Paragraph Separator, and U+0085 Next Line +enu LineEndType=SC_LINE_END_TYPE_ +val SC_LINE_END_TYPE_DEFAULT=0 +val SC_LINE_END_TYPE_UNICODE=1 + +# Set the line end types that the application wants to use. May not be used if incompatible with lexer or encoding. +set void SetLineEndTypesAllowed=2656(LineEndType lineEndBitSet,) + +# Get the line end types currently allowed. +get LineEndType GetLineEndTypesAllowed=2657(,) + +# Get the line end types currently recognised. May be a subset of the allowed types due to lexer limitation. +get LineEndType GetLineEndTypesActive=2658(,) + +# Set the way a character is drawn. +set void SetRepresentation=2665(string encodedCharacter, string representation) + +# Set the way a character is drawn. +# Result is NUL-terminated. +get int GetRepresentation=2666(string encodedCharacter, stringresult representation) + +# Remove a character representation. +fun void ClearRepresentation=2667(string encodedCharacter,) + +# Set the end of line annotation text for a line +set void EOLAnnotationSetText=2740(line line, string text) + +# Get the end of line annotation text for a line +get int EOLAnnotationGetText=2741(line line, stringresult text) + +# Set the style number for the end of line annotations for a line +set void EOLAnnotationSetStyle=2742(line line, int style) + +# Get the style number for the end of line annotations for a line +get int EOLAnnotationGetStyle=2743(line line,) + +# Clear the end of annotations from all lines +fun void EOLAnnotationClearAll=2744(,) + +enu EOLAnnotationVisible=EOLANNOTATION_ +val EOLANNOTATION_HIDDEN=0 +val EOLANNOTATION_STANDARD=1 +val EOLANNOTATION_BOXED=2 + +# Set the visibility for the end of line annotations for a view +set void EOLAnnotationSetVisible=2745(EOLAnnotationVisible visible,) + +# Get the visibility for the end of line annotations for a view +get EOLAnnotationVisible EOLAnnotationGetVisible=2746(,) + +# Get the start of the range of style numbers used for end of line annotations +set void EOLAnnotationSetStyleOffset=2747(int style,) + +# Get the start of the range of style numbers used for end of line annotations +get int EOLAnnotationGetStyleOffset=2748(,) + +# Start notifying the container of all key presses and commands. +fun void StartRecord=3001(,) + +# Stop notifying the container of all key presses and commands. +fun void StopRecord=3002(,) + +# Set the lexing language of the document. +set void SetLexer=4001(int lexer,) + +# Retrieve the lexing language of the document. +get int GetLexer=4002(,) + +# Colourise a segment of the document using the current lexing language. +fun void Colourise=4003(position start, position end) + +# Set up a value that may be used by a lexer for some optional feature. +set void SetProperty=4004(string key, string value) + +# Maximum value of keywordSet parameter of SetKeyWords. +val KEYWORDSET_MAX=8 + +# Set up the key words used by the lexer. +set void SetKeyWords=4005(int keyWordSet, string keyWords) + +# Set the lexing language of the document based on string name. +set void SetLexerLanguage=4006(, string language) + +# Load a lexer library (dll / so). +fun void LoadLexerLibrary=4007(, string path) + +# Retrieve a "property" value previously set with SetProperty. +# Result is NUL-terminated. +get int GetProperty=4008(string key, stringresult value) + +# Retrieve a "property" value previously set with SetProperty, +# with "$()" variable replacement on returned buffer. +# Result is NUL-terminated. +get int GetPropertyExpanded=4009(string key, stringresult value) + +# Retrieve a "property" value previously set with SetProperty, +# interpreted as an int AFTER any "$()" variable replacement. +get int GetPropertyInt=4010(string key, int defaultValue) + +# Retrieve the name of the lexer. +# Return the length of the text. +# Result is NUL-terminated. +get int GetLexerLanguage=4012(, stringresult language) + +# For private communication between an application and a known lexer. +fun pointer PrivateLexerCall=4013(int operation, pointer pointer) + +# Retrieve a '\n' separated list of properties understood by the current lexer. +# Result is NUL-terminated. +fun int PropertyNames=4014(, stringresult names) + +enu TypeProperty=SC_TYPE_ +val SC_TYPE_BOOLEAN=0 +val SC_TYPE_INTEGER=1 +val SC_TYPE_STRING=2 + +# Retrieve the type of a property. +fun TypeProperty PropertyType=4015(string name,) + +# Describe a property. +# Result is NUL-terminated. +fun int DescribeProperty=4016(string name, stringresult description) + +# Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer. +# Result is NUL-terminated. +fun int DescribeKeyWordSets=4017(, stringresult descriptions) + +# Bit set of LineEndType enumertion for which line ends beyond the standard +# LF, CR, and CRLF are supported by the lexer. +get int GetLineEndTypesSupported=4018(,) + +# Allocate a set of sub styles for a particular base style, returning start of range +fun int AllocateSubStyles=4020(int styleBase, int numberStyles) + +# The starting style number for the sub styles associated with a base style +get int GetSubStylesStart=4021(int styleBase,) + +# The number of sub styles associated with a base style +get int GetSubStylesLength=4022(int styleBase,) + +# For a sub style, return the base style, else return the argument. +get int GetStyleFromSubStyle=4027(int subStyle,) + +# For a secondary style, return the primary style, else return the argument. +get int GetPrimaryStyleFromStyle=4028(int style,) + +# Free allocated sub styles +fun void FreeSubStyles=4023(,) + +# Set the identifiers that are shown in a particular style +set void SetIdentifiers=4024(int style, string identifiers) + +# Where styles are duplicated by a feature such as active/inactive code +# return the distance between the two types. +get int DistanceToSecondaryStyles=4025(,) + +# Get the set of base styles that can be extended with sub styles +# Result is NUL-terminated. +get int GetSubStyleBases=4026(, stringresult styles) + +# Retrieve the number of named styles for the lexer. +get int GetNamedStyles=4029(,) + +# Retrieve the name of a style. +# Result is NUL-terminated. +fun int NameOfStyle=4030(int style, stringresult name) + +# Retrieve a ' ' separated list of style tags like "literal quoted string". +# Result is NUL-terminated. +fun int TagsOfStyle=4031(int style, stringresult tags) + +# Retrieve a description of a style. +# Result is NUL-terminated. +fun int DescriptionOfStyle=4032(int style, stringresult description) + +# Set the lexer from an ILexer*. +set void SetILexer=4033(, pointer ilexer) + +# Notifications +# Type of modification and the action which caused the modification. +# These are defined as a bit mask to make it easy to specify which notifications are wanted. +# One bit is set from each of SC_MOD_* and SC_PERFORMED_*. +enu ModificationFlags=SC_MOD_ SC_PERFORMED_ SC_MULTISTEPUNDOREDO SC_LASTSTEPINUNDOREDO SC_MULTILINEUNDOREDO SC_STARTACTION SC_MODEVENTMASKALL +val SC_MOD_NONE=0x0 +val SC_MOD_INSERTTEXT=0x1 +val SC_MOD_DELETETEXT=0x2 +val SC_MOD_CHANGESTYLE=0x4 +val SC_MOD_CHANGEFOLD=0x8 +val SC_PERFORMED_USER=0x10 +val SC_PERFORMED_UNDO=0x20 +val SC_PERFORMED_REDO=0x40 +val SC_MULTISTEPUNDOREDO=0x80 +val SC_LASTSTEPINUNDOREDO=0x100 +val SC_MOD_CHANGEMARKER=0x200 +val SC_MOD_BEFOREINSERT=0x400 +val SC_MOD_BEFOREDELETE=0x800 +val SC_MULTILINEUNDOREDO=0x1000 +val SC_STARTACTION=0x2000 +val SC_MOD_CHANGEINDICATOR=0x4000 +val SC_MOD_CHANGELINESTATE=0x8000 +val SC_MOD_CHANGEMARGIN=0x10000 +val SC_MOD_CHANGEANNOTATION=0x20000 +val SC_MOD_CONTAINER=0x40000 +val SC_MOD_LEXERSTATE=0x80000 +val SC_MOD_INSERTCHECK=0x100000 +val SC_MOD_CHANGETABSTOPS=0x200000 +val SC_MOD_CHANGEEOLANNOTATION=0x400000 +val SC_MODEVENTMASKALL=0x7FFFFF + +ali SC_MOD_INSERTTEXT=INSERT_TEXT +ali SC_MOD_DELETETEXT=DELETE_TEXT +ali SC_MOD_CHANGESTYLE=CHANGE_STYLE +ali SC_MOD_CHANGEFOLD=CHANGE_FOLD +ali SC_MULTISTEPUNDOREDO=MULTI_STEP_UNDO_REDO +ali SC_LASTSTEPINUNDOREDO=LAST_STEP_IN_UNDO_REDO +ali SC_MOD_CHANGEMARKER=CHANGE_MARKER +ali SC_MOD_BEFOREINSERT=BEFORE_INSERT +ali SC_MOD_BEFOREDELETE=BEFORE_DELETE +ali SC_MULTILINEUNDOREDO=MULTILINE_UNDO_REDO +ali SC_STARTACTION=START_ACTION +ali SC_MOD_CHANGEINDICATOR=CHANGE_INDICATOR +ali SC_MOD_CHANGELINESTATE=CHANGE_LINE_STATE +ali SC_MOD_CHANGEMARGIN=CHANGE_MARGIN +ali SC_MOD_CHANGEANNOTATION=CHANGE_ANNOTATION +ali SC_MOD_LEXERSTATE=LEXER_STATE +ali SC_MOD_INSERTCHECK=INSERT_CHECK +ali SC_MOD_CHANGETABSTOPS=CHANGE_TAB_STOPS +ali SC_MOD_CHANGEEOLANNOTATION=CHANGE_E_O_L_ANNOTATION +ali SC_MODEVENTMASKALL=EVENT_MASK_ALL + +enu Update=SC_UPDATE_ +val SC_UPDATE_CONTENT=0x1 +val SC_UPDATE_SELECTION=0x2 +val SC_UPDATE_V_SCROLL=0x4 +val SC_UPDATE_H_SCROLL=0x8 + +# For compatibility, these go through the COMMAND notification rather than NOTIFY +# and should have had exactly the same values as the EN_* constants. +# Unfortunately the SETFOCUS and KILLFOCUS are flipped over from EN_* +# As clients depend on these constants, this will not be changed. +val SCEN_CHANGE=768 +val SCEN_SETFOCUS=512 +val SCEN_KILLFOCUS=256 + +# Symbolic key codes and modifier flags. +# ASCII and other printable characters below 256. +# Extended keys above 300. + +enu Keys=SCK_ +val SCK_DOWN=300 +val SCK_UP=301 +val SCK_LEFT=302 +val SCK_RIGHT=303 +val SCK_HOME=304 +val SCK_END=305 +val SCK_PRIOR=306 +val SCK_NEXT=307 +val SCK_DELETE=308 +val SCK_INSERT=309 +val SCK_ESCAPE=7 +val SCK_BACK=8 +val SCK_TAB=9 +val SCK_RETURN=13 +val SCK_ADD=310 +val SCK_SUBTRACT=311 +val SCK_DIVIDE=312 +val SCK_WIN=313 +val SCK_RWIN=314 +val SCK_MENU=315 + +ali SCK_RWIN=R_WIN + +enu KeyMod=SCMOD_ +val SCMOD_NORM=0 +val SCMOD_SHIFT=1 +val SCMOD_CTRL=2 +val SCMOD_ALT=4 +val SCMOD_SUPER=8 +val SCMOD_META=16 + +enu CompletionMethods=SC_AC_ +val SC_AC_FILLUP=1 +val SC_AC_DOUBLECLICK=2 +val SC_AC_TAB=3 +val SC_AC_NEWLINE=4 +val SC_AC_COMMAND=5 + +ali SC_AC_FILLUP=FILL_UP +ali SC_AC_DOUBLECLICK=DOUBLE_CLICK + +# characterSource for SCN_CHARADDED +enu CharacterSource=SC_CHARACTERSOURCE_ +# Direct input characters. +val SC_CHARACTERSOURCE_DIRECT_INPUT=0 +# IME (inline mode) or dead key tentative input characters. +val SC_CHARACTERSOURCE_TENTATIVE_INPUT=1 +# IME (either inline or windowed mode) full composited string. +val SC_CHARACTERSOURCE_IME_RESULT=2 + +################################################ +# For SciLexer.h +enu Lexer=SCLEX_ +val SCLEX_CONTAINER=0 +val SCLEX_NULL=1 +val SCLEX_PYTHON=2 +val SCLEX_CPP=3 +val SCLEX_HTML=4 +val SCLEX_XML=5 +val SCLEX_PERL=6 +val SCLEX_SQL=7 +val SCLEX_VB=8 +val SCLEX_PROPERTIES=9 +val SCLEX_ERRORLIST=10 +val SCLEX_MAKEFILE=11 +val SCLEX_BATCH=12 +val SCLEX_XCODE=13 +val SCLEX_LATEX=14 +val SCLEX_LUA=15 +val SCLEX_DIFF=16 +val SCLEX_CONF=17 +val SCLEX_PASCAL=18 +val SCLEX_AVE=19 +val SCLEX_ADA=20 +val SCLEX_LISP=21 +val SCLEX_RUBY=22 +val SCLEX_EIFFEL=23 +val SCLEX_EIFFELKW=24 +val SCLEX_TCL=25 +val SCLEX_NNCRONTAB=26 +val SCLEX_BULLANT=27 +val SCLEX_VBSCRIPT=28 +val SCLEX_BAAN=31 +val SCLEX_MATLAB=32 +val SCLEX_SCRIPTOL=33 +val SCLEX_ASM=34 +val SCLEX_CPPNOCASE=35 +val SCLEX_FORTRAN=36 +val SCLEX_F77=37 +val SCLEX_CSS=38 +val SCLEX_POV=39 +val SCLEX_LOUT=40 +val SCLEX_ESCRIPT=41 +val SCLEX_PS=42 +val SCLEX_NSIS=43 +val SCLEX_MMIXAL=44 +val SCLEX_CLW=45 +val SCLEX_CLWNOCASE=46 +val SCLEX_LOT=47 +val SCLEX_YAML=48 +val SCLEX_TEX=49 +val SCLEX_METAPOST=50 +val SCLEX_POWERBASIC=51 +val SCLEX_FORTH=52 +val SCLEX_ERLANG=53 +val SCLEX_OCTAVE=54 +val SCLEX_MSSQL=55 +val SCLEX_VERILOG=56 +val SCLEX_KIX=57 +val SCLEX_GUI4CLI=58 +val SCLEX_SPECMAN=59 +val SCLEX_AU3=60 +val SCLEX_APDL=61 +val SCLEX_BASH=62 +val SCLEX_ASN1=63 +val SCLEX_VHDL=64 +val SCLEX_CAML=65 +val SCLEX_BLITZBASIC=66 +val SCLEX_PUREBASIC=67 +val SCLEX_HASKELL=68 +val SCLEX_PHPSCRIPT=69 +val SCLEX_TADS3=70 +val SCLEX_REBOL=71 +val SCLEX_SMALLTALK=72 +val SCLEX_FLAGSHIP=73 +val SCLEX_CSOUND=74 +val SCLEX_FREEBASIC=75 +val SCLEX_INNOSETUP=76 +val SCLEX_OPAL=77 +val SCLEX_SPICE=78 +val SCLEX_D=79 +val SCLEX_CMAKE=80 +val SCLEX_GAP=81 +val SCLEX_PLM=82 +val SCLEX_PROGRESS=83 +val SCLEX_ABAQUS=84 +val SCLEX_ASYMPTOTE=85 +val SCLEX_R=86 +val SCLEX_MAGIK=87 +val SCLEX_POWERSHELL=88 +val SCLEX_MYSQL=89 +val SCLEX_PO=90 +val SCLEX_TAL=91 +val SCLEX_COBOL=92 +val SCLEX_TACL=93 +val SCLEX_SORCUS=94 +val SCLEX_POWERPRO=95 +val SCLEX_NIMROD=96 +val SCLEX_SML=97 +val SCLEX_MARKDOWN=98 +val SCLEX_TXT2TAGS=99 +val SCLEX_A68K=100 +val SCLEX_MODULA=101 +val SCLEX_COFFEESCRIPT=102 +val SCLEX_TCMD=103 +val SCLEX_AVS=104 +val SCLEX_ECL=105 +val SCLEX_OSCRIPT=106 +val SCLEX_VISUALPROLOG=107 +val SCLEX_LITERATEHASKELL=108 +val SCLEX_STTXT=109 +val SCLEX_KVIRC=110 +val SCLEX_RUST=111 +val SCLEX_DMAP=112 +val SCLEX_AS=113 +val SCLEX_DMIS=114 +val SCLEX_REGISTRY=115 +val SCLEX_BIBTEX=116 +val SCLEX_SREC=117 +val SCLEX_IHEX=118 +val SCLEX_TEHEX=119 +val SCLEX_JSON=120 +val SCLEX_EDIFACT=121 +val SCLEX_INDENT=122 +val SCLEX_MAXIMA=123 +val SCLEX_STATA=124 +val SCLEX_SAS=125 +val SCLEX_NIM=126 +val SCLEX_CIL=127 +val SCLEX_X12=128 +val SCLEX_DATAFLEX=129 +val SCLEX_HOLLYWOOD=130 +val SCLEX_RAKU=131 + +# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a +# value assigned in sequence from SCLEX_AUTOMATIC+1. +val SCLEX_AUTOMATIC=1000 +# Lexical states for SCLEX_PYTHON +lex Python=SCLEX_PYTHON SCE_P_ +lex Nimrod=SCLEX_NIMROD SCE_P_ +val SCE_P_DEFAULT=0 +val SCE_P_COMMENTLINE=1 +val SCE_P_NUMBER=2 +val SCE_P_STRING=3 +val SCE_P_CHARACTER=4 +val SCE_P_WORD=5 +val SCE_P_TRIPLE=6 +val SCE_P_TRIPLEDOUBLE=7 +val SCE_P_CLASSNAME=8 +val SCE_P_DEFNAME=9 +val SCE_P_OPERATOR=10 +val SCE_P_IDENTIFIER=11 +val SCE_P_COMMENTBLOCK=12 +val SCE_P_STRINGEOL=13 +val SCE_P_WORD2=14 +val SCE_P_DECORATOR=15 +val SCE_P_FSTRING=16 +val SCE_P_FCHARACTER=17 +val SCE_P_FTRIPLE=18 +val SCE_P_FTRIPLEDOUBLE=19 +# Lexical states for SCLEX_CPP +# Lexical states for SCLEX_BULLANT +# Lexical states for SCLEX_COBOL +# Lexical states for SCLEX_TACL +# Lexical states for SCLEX_TAL +lex Cpp=SCLEX_CPP SCE_C_ +lex BullAnt=SCLEX_BULLANT SCE_C_ +lex COBOL=SCLEX_COBOL SCE_C_ +lex TACL=SCLEX_TACL SCE_C_ +lex TAL=SCLEX_TAL SCE_C_ +val SCE_C_DEFAULT=0 +val SCE_C_COMMENT=1 +val SCE_C_COMMENTLINE=2 +val SCE_C_COMMENTDOC=3 +val SCE_C_NUMBER=4 +val SCE_C_WORD=5 +val SCE_C_STRING=6 +val SCE_C_CHARACTER=7 +val SCE_C_UUID=8 +val SCE_C_PREPROCESSOR=9 +val SCE_C_OPERATOR=10 +val SCE_C_IDENTIFIER=11 +val SCE_C_STRINGEOL=12 +val SCE_C_VERBATIM=13 +val SCE_C_REGEX=14 +val SCE_C_COMMENTLINEDOC=15 +val SCE_C_WORD2=16 +val SCE_C_COMMENTDOCKEYWORD=17 +val SCE_C_COMMENTDOCKEYWORDERROR=18 +val SCE_C_GLOBALCLASS=19 +val SCE_C_STRINGRAW=20 +val SCE_C_TRIPLEVERBATIM=21 +val SCE_C_HASHQUOTEDSTRING=22 +val SCE_C_PREPROCESSORCOMMENT=23 +val SCE_C_PREPROCESSORCOMMENTDOC=24 +val SCE_C_USERLITERAL=25 +val SCE_C_TASKMARKER=26 +val SCE_C_ESCAPESEQUENCE=27 +# Lexical states for SCLEX_D +lex D=SCLEX_D SCE_D_ +val SCE_D_DEFAULT=0 +val SCE_D_COMMENT=1 +val SCE_D_COMMENTLINE=2 +val SCE_D_COMMENTDOC=3 +val SCE_D_COMMENTNESTED=4 +val SCE_D_NUMBER=5 +val SCE_D_WORD=6 +val SCE_D_WORD2=7 +val SCE_D_WORD3=8 +val SCE_D_TYPEDEF=9 +val SCE_D_STRING=10 +val SCE_D_STRINGEOL=11 +val SCE_D_CHARACTER=12 +val SCE_D_OPERATOR=13 +val SCE_D_IDENTIFIER=14 +val SCE_D_COMMENTLINEDOC=15 +val SCE_D_COMMENTDOCKEYWORD=16 +val SCE_D_COMMENTDOCKEYWORDERROR=17 +val SCE_D_STRINGB=18 +val SCE_D_STRINGR=19 +val SCE_D_WORD5=20 +val SCE_D_WORD6=21 +val SCE_D_WORD7=22 +# Lexical states for SCLEX_TCL +lex TCL=SCLEX_TCL SCE_TCL_ +val SCE_TCL_DEFAULT=0 +val SCE_TCL_COMMENT=1 +val SCE_TCL_COMMENTLINE=2 +val SCE_TCL_NUMBER=3 +val SCE_TCL_WORD_IN_QUOTE=4 +val SCE_TCL_IN_QUOTE=5 +val SCE_TCL_OPERATOR=6 +val SCE_TCL_IDENTIFIER=7 +val SCE_TCL_SUBSTITUTION=8 +val SCE_TCL_SUB_BRACE=9 +val SCE_TCL_MODIFIER=10 +val SCE_TCL_EXPAND=11 +val SCE_TCL_WORD=12 +val SCE_TCL_WORD2=13 +val SCE_TCL_WORD3=14 +val SCE_TCL_WORD4=15 +val SCE_TCL_WORD5=16 +val SCE_TCL_WORD6=17 +val SCE_TCL_WORD7=18 +val SCE_TCL_WORD8=19 +val SCE_TCL_COMMENT_BOX=20 +val SCE_TCL_BLOCK_COMMENT=21 +# Lexical states for SCLEX_HTML, SCLEX_XML +lex HTML=SCLEX_HTML SCE_H_ SCE_HJ_ SCE_HJA_ SCE_HB_ SCE_HBA_ SCE_HP_ SCE_HPHP_ SCE_HPA_ +lex XML=SCLEX_XML SCE_H_ SCE_HJ_ SCE_HJA_ SCE_HB_ SCE_HBA_ SCE_HP_ SCE_HPHP_ SCE_HPA_ +val SCE_H_DEFAULT=0 +val SCE_H_TAG=1 +val SCE_H_TAGUNKNOWN=2 +val SCE_H_ATTRIBUTE=3 +val SCE_H_ATTRIBUTEUNKNOWN=4 +val SCE_H_NUMBER=5 +val SCE_H_DOUBLESTRING=6 +val SCE_H_SINGLESTRING=7 +val SCE_H_OTHER=8 +val SCE_H_COMMENT=9 +val SCE_H_ENTITY=10 +# XML and ASP +val SCE_H_TAGEND=11 +val SCE_H_XMLSTART=12 +val SCE_H_XMLEND=13 +val SCE_H_SCRIPT=14 +val SCE_H_ASP=15 +val SCE_H_ASPAT=16 +val SCE_H_CDATA=17 +val SCE_H_QUESTION=18 +# More HTML +val SCE_H_VALUE=19 +# X-Code +val SCE_H_XCCOMMENT=20 +# SGML +val SCE_H_SGML_DEFAULT=21 +val SCE_H_SGML_COMMAND=22 +val SCE_H_SGML_1ST_PARAM=23 +val SCE_H_SGML_DOUBLESTRING=24 +val SCE_H_SGML_SIMPLESTRING=25 +val SCE_H_SGML_ERROR=26 +val SCE_H_SGML_SPECIAL=27 +val SCE_H_SGML_ENTITY=28 +val SCE_H_SGML_COMMENT=29 +val SCE_H_SGML_1ST_PARAM_COMMENT=30 +val SCE_H_SGML_BLOCK_DEFAULT=31 +# Embedded Javascript +val SCE_HJ_START=40 +val SCE_HJ_DEFAULT=41 +val SCE_HJ_COMMENT=42 +val SCE_HJ_COMMENTLINE=43 +val SCE_HJ_COMMENTDOC=44 +val SCE_HJ_NUMBER=45 +val SCE_HJ_WORD=46 +val SCE_HJ_KEYWORD=47 +val SCE_HJ_DOUBLESTRING=48 +val SCE_HJ_SINGLESTRING=49 +val SCE_HJ_SYMBOLS=50 +val SCE_HJ_STRINGEOL=51 +val SCE_HJ_REGEX=52 +# ASP Javascript +val SCE_HJA_START=55 +val SCE_HJA_DEFAULT=56 +val SCE_HJA_COMMENT=57 +val SCE_HJA_COMMENTLINE=58 +val SCE_HJA_COMMENTDOC=59 +val SCE_HJA_NUMBER=60 +val SCE_HJA_WORD=61 +val SCE_HJA_KEYWORD=62 +val SCE_HJA_DOUBLESTRING=63 +val SCE_HJA_SINGLESTRING=64 +val SCE_HJA_SYMBOLS=65 +val SCE_HJA_STRINGEOL=66 +val SCE_HJA_REGEX=67 +# Embedded VBScript +val SCE_HB_START=70 +val SCE_HB_DEFAULT=71 +val SCE_HB_COMMENTLINE=72 +val SCE_HB_NUMBER=73 +val SCE_HB_WORD=74 +val SCE_HB_STRING=75 +val SCE_HB_IDENTIFIER=76 +val SCE_HB_STRINGEOL=77 +# ASP VBScript +val SCE_HBA_START=80 +val SCE_HBA_DEFAULT=81 +val SCE_HBA_COMMENTLINE=82 +val SCE_HBA_NUMBER=83 +val SCE_HBA_WORD=84 +val SCE_HBA_STRING=85 +val SCE_HBA_IDENTIFIER=86 +val SCE_HBA_STRINGEOL=87 +# Embedded Python +val SCE_HP_START=90 +val SCE_HP_DEFAULT=91 +val SCE_HP_COMMENTLINE=92 +val SCE_HP_NUMBER=93 +val SCE_HP_STRING=94 +val SCE_HP_CHARACTER=95 +val SCE_HP_WORD=96 +val SCE_HP_TRIPLE=97 +val SCE_HP_TRIPLEDOUBLE=98 +val SCE_HP_CLASSNAME=99 +val SCE_HP_DEFNAME=100 +val SCE_HP_OPERATOR=101 +val SCE_HP_IDENTIFIER=102 +# PHP +val SCE_HPHP_COMPLEX_VARIABLE=104 +# ASP Python +val SCE_HPA_START=105 +val SCE_HPA_DEFAULT=106 +val SCE_HPA_COMMENTLINE=107 +val SCE_HPA_NUMBER=108 +val SCE_HPA_STRING=109 +val SCE_HPA_CHARACTER=110 +val SCE_HPA_WORD=111 +val SCE_HPA_TRIPLE=112 +val SCE_HPA_TRIPLEDOUBLE=113 +val SCE_HPA_CLASSNAME=114 +val SCE_HPA_DEFNAME=115 +val SCE_HPA_OPERATOR=116 +val SCE_HPA_IDENTIFIER=117 +# PHP +val SCE_HPHP_DEFAULT=118 +val SCE_HPHP_HSTRING=119 +val SCE_HPHP_SIMPLESTRING=120 +val SCE_HPHP_WORD=121 +val SCE_HPHP_NUMBER=122 +val SCE_HPHP_VARIABLE=123 +val SCE_HPHP_COMMENT=124 +val SCE_HPHP_COMMENTLINE=125 +val SCE_HPHP_HSTRING_VARIABLE=126 +val SCE_HPHP_OPERATOR=127 +# Lexical states for SCLEX_PERL +lex Perl=SCLEX_PERL SCE_PL_ +val SCE_PL_DEFAULT=0 +val SCE_PL_ERROR=1 +val SCE_PL_COMMENTLINE=2 +val SCE_PL_POD=3 +val SCE_PL_NUMBER=4 +val SCE_PL_WORD=5 +val SCE_PL_STRING=6 +val SCE_PL_CHARACTER=7 +val SCE_PL_PUNCTUATION=8 +val SCE_PL_PREPROCESSOR=9 +val SCE_PL_OPERATOR=10 +val SCE_PL_IDENTIFIER=11 +val SCE_PL_SCALAR=12 +val SCE_PL_ARRAY=13 +val SCE_PL_HASH=14 +val SCE_PL_SYMBOLTABLE=15 +val SCE_PL_VARIABLE_INDEXER=16 +val SCE_PL_REGEX=17 +val SCE_PL_REGSUBST=18 +val SCE_PL_LONGQUOTE=19 +val SCE_PL_BACKTICKS=20 +val SCE_PL_DATASECTION=21 +val SCE_PL_HERE_DELIM=22 +val SCE_PL_HERE_Q=23 +val SCE_PL_HERE_QQ=24 +val SCE_PL_HERE_QX=25 +val SCE_PL_STRING_Q=26 +val SCE_PL_STRING_QQ=27 +val SCE_PL_STRING_QX=28 +val SCE_PL_STRING_QR=29 +val SCE_PL_STRING_QW=30 +val SCE_PL_POD_VERB=31 +val SCE_PL_SUB_PROTOTYPE=40 +val SCE_PL_FORMAT_IDENT=41 +val SCE_PL_FORMAT=42 +val SCE_PL_STRING_VAR=43 +val SCE_PL_XLAT=44 +val SCE_PL_REGEX_VAR=54 +val SCE_PL_REGSUBST_VAR=55 +val SCE_PL_BACKTICKS_VAR=57 +val SCE_PL_HERE_QQ_VAR=61 +val SCE_PL_HERE_QX_VAR=62 +val SCE_PL_STRING_QQ_VAR=64 +val SCE_PL_STRING_QX_VAR=65 +val SCE_PL_STRING_QR_VAR=66 +# Lexical states for SCLEX_RUBY +lex Ruby=SCLEX_RUBY SCE_RB_ +val SCE_RB_DEFAULT=0 +val SCE_RB_ERROR=1 +val SCE_RB_COMMENTLINE=2 +val SCE_RB_POD=3 +val SCE_RB_NUMBER=4 +val SCE_RB_WORD=5 +val SCE_RB_STRING=6 +val SCE_RB_CHARACTER=7 +val SCE_RB_CLASSNAME=8 +val SCE_RB_DEFNAME=9 +val SCE_RB_OPERATOR=10 +val SCE_RB_IDENTIFIER=11 +val SCE_RB_REGEX=12 +val SCE_RB_GLOBAL=13 +val SCE_RB_SYMBOL=14 +val SCE_RB_MODULE_NAME=15 +val SCE_RB_INSTANCE_VAR=16 +val SCE_RB_CLASS_VAR=17 +val SCE_RB_BACKTICKS=18 +val SCE_RB_DATASECTION=19 +val SCE_RB_HERE_DELIM=20 +val SCE_RB_HERE_Q=21 +val SCE_RB_HERE_QQ=22 +val SCE_RB_HERE_QX=23 +val SCE_RB_STRING_Q=24 +val SCE_RB_STRING_QQ=25 +val SCE_RB_STRING_QX=26 +val SCE_RB_STRING_QR=27 +val SCE_RB_STRING_QW=28 +val SCE_RB_WORD_DEMOTED=29 +val SCE_RB_STDIN=30 +val SCE_RB_STDOUT=31 +val SCE_RB_STDERR=40 +val SCE_RB_UPPER_BOUND=41 +# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC, SCLEX_BLITZBASIC, SCLEX_PUREBASIC, SCLEX_FREEBASIC +lex VB=SCLEX_VB SCE_B_ +lex VBScript=SCLEX_VBSCRIPT SCE_B_ +lex PowerBasic=SCLEX_POWERBASIC SCE_B_ +lex BlitzBasic=SCLEX_BLITZBASIC SCE_B_ +lex PureBasic=SCLEX_PUREBASIC SCE_B_ +lex FreeBasic=SCLEX_FREEBASIC SCE_B_ +val SCE_B_DEFAULT=0 +val SCE_B_COMMENT=1 +val SCE_B_NUMBER=2 +val SCE_B_KEYWORD=3 +val SCE_B_STRING=4 +val SCE_B_PREPROCESSOR=5 +val SCE_B_OPERATOR=6 +val SCE_B_IDENTIFIER=7 +val SCE_B_DATE=8 +val SCE_B_STRINGEOL=9 +val SCE_B_KEYWORD2=10 +val SCE_B_KEYWORD3=11 +val SCE_B_KEYWORD4=12 +val SCE_B_CONSTANT=13 +val SCE_B_ASM=14 +val SCE_B_LABEL=15 +val SCE_B_ERROR=16 +val SCE_B_HEXNUMBER=17 +val SCE_B_BINNUMBER=18 +val SCE_B_COMMENTBLOCK=19 +val SCE_B_DOCLINE=20 +val SCE_B_DOCBLOCK=21 +val SCE_B_DOCKEYWORD=22 +# Lexical states for SCLEX_PROPERTIES +lex Properties=SCLEX_PROPERTIES SCE_PROPS_ +val SCE_PROPS_DEFAULT=0 +val SCE_PROPS_COMMENT=1 +val SCE_PROPS_SECTION=2 +val SCE_PROPS_ASSIGNMENT=3 +val SCE_PROPS_DEFVAL=4 +val SCE_PROPS_KEY=5 +# Lexical states for SCLEX_LATEX +lex LaTeX=SCLEX_LATEX SCE_L_ +val SCE_L_DEFAULT=0 +val SCE_L_COMMAND=1 +val SCE_L_TAG=2 +val SCE_L_MATH=3 +val SCE_L_COMMENT=4 +val SCE_L_TAG2=5 +val SCE_L_MATH2=6 +val SCE_L_COMMENT2=7 +val SCE_L_VERBATIM=8 +val SCE_L_SHORTCMD=9 +val SCE_L_SPECIAL=10 +val SCE_L_CMDOPT=11 +val SCE_L_ERROR=12 +# Lexical states for SCLEX_LUA +lex Lua=SCLEX_LUA SCE_LUA_ +val SCE_LUA_DEFAULT=0 +val SCE_LUA_COMMENT=1 +val SCE_LUA_COMMENTLINE=2 +val SCE_LUA_COMMENTDOC=3 +val SCE_LUA_NUMBER=4 +val SCE_LUA_WORD=5 +val SCE_LUA_STRING=6 +val SCE_LUA_CHARACTER=7 +val SCE_LUA_LITERALSTRING=8 +val SCE_LUA_PREPROCESSOR=9 +val SCE_LUA_OPERATOR=10 +val SCE_LUA_IDENTIFIER=11 +val SCE_LUA_STRINGEOL=12 +val SCE_LUA_WORD2=13 +val SCE_LUA_WORD3=14 +val SCE_LUA_WORD4=15 +val SCE_LUA_WORD5=16 +val SCE_LUA_WORD6=17 +val SCE_LUA_WORD7=18 +val SCE_LUA_WORD8=19 +val SCE_LUA_LABEL=20 +# Lexical states for SCLEX_ERRORLIST +lex ErrorList=SCLEX_ERRORLIST SCE_ERR_ +val SCE_ERR_DEFAULT=0 +val SCE_ERR_PYTHON=1 +val SCE_ERR_GCC=2 +val SCE_ERR_MS=3 +val SCE_ERR_CMD=4 +val SCE_ERR_BORLAND=5 +val SCE_ERR_PERL=6 +val SCE_ERR_NET=7 +val SCE_ERR_LUA=8 +val SCE_ERR_CTAG=9 +val SCE_ERR_DIFF_CHANGED=10 +val SCE_ERR_DIFF_ADDITION=11 +val SCE_ERR_DIFF_DELETION=12 +val SCE_ERR_DIFF_MESSAGE=13 +val SCE_ERR_PHP=14 +val SCE_ERR_ELF=15 +val SCE_ERR_IFC=16 +val SCE_ERR_IFORT=17 +val SCE_ERR_ABSF=18 +val SCE_ERR_TIDY=19 +val SCE_ERR_JAVA_STACK=20 +val SCE_ERR_VALUE=21 +val SCE_ERR_GCC_INCLUDED_FROM=22 +val SCE_ERR_ESCSEQ=23 +val SCE_ERR_ESCSEQ_UNKNOWN=24 +val SCE_ERR_GCC_EXCERPT=25 +val SCE_ERR_ES_BLACK=40 +val SCE_ERR_ES_RED=41 +val SCE_ERR_ES_GREEN=42 +val SCE_ERR_ES_BROWN=43 +val SCE_ERR_ES_BLUE=44 +val SCE_ERR_ES_MAGENTA=45 +val SCE_ERR_ES_CYAN=46 +val SCE_ERR_ES_GRAY=47 +val SCE_ERR_ES_DARK_GRAY=48 +val SCE_ERR_ES_BRIGHT_RED=49 +val SCE_ERR_ES_BRIGHT_GREEN=50 +val SCE_ERR_ES_YELLOW=51 +val SCE_ERR_ES_BRIGHT_BLUE=52 +val SCE_ERR_ES_BRIGHT_MAGENTA=53 +val SCE_ERR_ES_BRIGHT_CYAN=54 +val SCE_ERR_ES_WHITE=55 +# Lexical states for SCLEX_BATCH +lex Batch=SCLEX_BATCH SCE_BAT_ +val SCE_BAT_DEFAULT=0 +val SCE_BAT_COMMENT=1 +val SCE_BAT_WORD=2 +val SCE_BAT_LABEL=3 +val SCE_BAT_HIDE=4 +val SCE_BAT_COMMAND=5 +val SCE_BAT_IDENTIFIER=6 +val SCE_BAT_OPERATOR=7 +# Lexical states for SCLEX_TCMD +lex TCMD=SCLEX_TCMD SCE_TCMD_ +val SCE_TCMD_DEFAULT=0 +val SCE_TCMD_COMMENT=1 +val SCE_TCMD_WORD=2 +val SCE_TCMD_LABEL=3 +val SCE_TCMD_HIDE=4 +val SCE_TCMD_COMMAND=5 +val SCE_TCMD_IDENTIFIER=6 +val SCE_TCMD_OPERATOR=7 +val SCE_TCMD_ENVIRONMENT=8 +val SCE_TCMD_EXPANSION=9 +val SCE_TCMD_CLABEL=10 +# Lexical states for SCLEX_MAKEFILE +lex MakeFile=SCLEX_MAKEFILE SCE_MAKE_ +val SCE_MAKE_DEFAULT=0 +val SCE_MAKE_COMMENT=1 +val SCE_MAKE_PREPROCESSOR=2 +val SCE_MAKE_IDENTIFIER=3 +val SCE_MAKE_OPERATOR=4 +val SCE_MAKE_TARGET=5 +val SCE_MAKE_IDEOL=9 +# Lexical states for SCLEX_DIFF +lex Diff=SCLEX_DIFF SCE_DIFF_ +val SCE_DIFF_DEFAULT=0 +val SCE_DIFF_COMMENT=1 +val SCE_DIFF_COMMAND=2 +val SCE_DIFF_HEADER=3 +val SCE_DIFF_POSITION=4 +val SCE_DIFF_DELETED=5 +val SCE_DIFF_ADDED=6 +val SCE_DIFF_CHANGED=7 +val SCE_DIFF_PATCH_ADD=8 +val SCE_DIFF_PATCH_DELETE=9 +val SCE_DIFF_REMOVED_PATCH_ADD=10 +val SCE_DIFF_REMOVED_PATCH_DELETE=11 +# Lexical states for SCLEX_CONF (Apache Configuration Files Lexer) +lex Conf=SCLEX_CONF SCE_CONF_ +val SCE_CONF_DEFAULT=0 +val SCE_CONF_COMMENT=1 +val SCE_CONF_NUMBER=2 +val SCE_CONF_IDENTIFIER=3 +val SCE_CONF_EXTENSION=4 +val SCE_CONF_PARAMETER=5 +val SCE_CONF_STRING=6 +val SCE_CONF_OPERATOR=7 +val SCE_CONF_IP=8 +val SCE_CONF_DIRECTIVE=9 +# Lexical states for SCLEX_AVE, Avenue +lex Avenue=SCLEX_AVE SCE_AVE_ +val SCE_AVE_DEFAULT=0 +val SCE_AVE_COMMENT=1 +val SCE_AVE_NUMBER=2 +val SCE_AVE_WORD=3 +val SCE_AVE_STRING=6 +val SCE_AVE_ENUM=7 +val SCE_AVE_STRINGEOL=8 +val SCE_AVE_IDENTIFIER=9 +val SCE_AVE_OPERATOR=10 +val SCE_AVE_WORD1=11 +val SCE_AVE_WORD2=12 +val SCE_AVE_WORD3=13 +val SCE_AVE_WORD4=14 +val SCE_AVE_WORD5=15 +val SCE_AVE_WORD6=16 +# Lexical states for SCLEX_ADA +lex Ada=SCLEX_ADA SCE_ADA_ +val SCE_ADA_DEFAULT=0 +val SCE_ADA_WORD=1 +val SCE_ADA_IDENTIFIER=2 +val SCE_ADA_NUMBER=3 +val SCE_ADA_DELIMITER=4 +val SCE_ADA_CHARACTER=5 +val SCE_ADA_CHARACTEREOL=6 +val SCE_ADA_STRING=7 +val SCE_ADA_STRINGEOL=8 +val SCE_ADA_LABEL=9 +val SCE_ADA_COMMENTLINE=10 +val SCE_ADA_ILLEGAL=11 +# Lexical states for SCLEX_BAAN +lex Baan=SCLEX_BAAN SCE_BAAN_ +val SCE_BAAN_DEFAULT=0 +val SCE_BAAN_COMMENT=1 +val SCE_BAAN_COMMENTDOC=2 +val SCE_BAAN_NUMBER=3 +val SCE_BAAN_WORD=4 +val SCE_BAAN_STRING=5 +val SCE_BAAN_PREPROCESSOR=6 +val SCE_BAAN_OPERATOR=7 +val SCE_BAAN_IDENTIFIER=8 +val SCE_BAAN_STRINGEOL=9 +val SCE_BAAN_WORD2=10 +val SCE_BAAN_WORD3=11 +val SCE_BAAN_WORD4=12 +val SCE_BAAN_WORD5=13 +val SCE_BAAN_WORD6=14 +val SCE_BAAN_WORD7=15 +val SCE_BAAN_WORD8=16 +val SCE_BAAN_WORD9=17 +val SCE_BAAN_TABLEDEF=18 +val SCE_BAAN_TABLESQL=19 +val SCE_BAAN_FUNCTION=20 +val SCE_BAAN_DOMDEF=21 +val SCE_BAAN_FUNCDEF=22 +val SCE_BAAN_OBJECTDEF=23 +val SCE_BAAN_DEFINEDEF=24 +# Lexical states for SCLEX_LISP +lex Lisp=SCLEX_LISP SCE_LISP_ +val SCE_LISP_DEFAULT=0 +val SCE_LISP_COMMENT=1 +val SCE_LISP_NUMBER=2 +val SCE_LISP_KEYWORD=3 +val SCE_LISP_KEYWORD_KW=4 +val SCE_LISP_SYMBOL=5 +val SCE_LISP_STRING=6 +val SCE_LISP_STRINGEOL=8 +val SCE_LISP_IDENTIFIER=9 +val SCE_LISP_OPERATOR=10 +val SCE_LISP_SPECIAL=11 +val SCE_LISP_MULTI_COMMENT=12 +# Lexical states for SCLEX_EIFFEL and SCLEX_EIFFELKW +lex Eiffel=SCLEX_EIFFEL SCE_EIFFEL_ +lex EiffelKW=SCLEX_EIFFELKW SCE_EIFFEL_ +val SCE_EIFFEL_DEFAULT=0 +val SCE_EIFFEL_COMMENTLINE=1 +val SCE_EIFFEL_NUMBER=2 +val SCE_EIFFEL_WORD=3 +val SCE_EIFFEL_STRING=4 +val SCE_EIFFEL_CHARACTER=5 +val SCE_EIFFEL_OPERATOR=6 +val SCE_EIFFEL_IDENTIFIER=7 +val SCE_EIFFEL_STRINGEOL=8 +# Lexical states for SCLEX_NNCRONTAB (nnCron crontab Lexer) +lex NNCronTab=SCLEX_NNCRONTAB SCE_NNCRONTAB_ +val SCE_NNCRONTAB_DEFAULT=0 +val SCE_NNCRONTAB_COMMENT=1 +val SCE_NNCRONTAB_TASK=2 +val SCE_NNCRONTAB_SECTION=3 +val SCE_NNCRONTAB_KEYWORD=4 +val SCE_NNCRONTAB_MODIFIER=5 +val SCE_NNCRONTAB_ASTERISK=6 +val SCE_NNCRONTAB_NUMBER=7 +val SCE_NNCRONTAB_STRING=8 +val SCE_NNCRONTAB_ENVIRONMENT=9 +val SCE_NNCRONTAB_IDENTIFIER=10 +# Lexical states for SCLEX_FORTH (Forth Lexer) +lex Forth=SCLEX_FORTH SCE_FORTH_ +val SCE_FORTH_DEFAULT=0 +val SCE_FORTH_COMMENT=1 +val SCE_FORTH_COMMENT_ML=2 +val SCE_FORTH_IDENTIFIER=3 +val SCE_FORTH_CONTROL=4 +val SCE_FORTH_KEYWORD=5 +val SCE_FORTH_DEFWORD=6 +val SCE_FORTH_PREWORD1=7 +val SCE_FORTH_PREWORD2=8 +val SCE_FORTH_NUMBER=9 +val SCE_FORTH_STRING=10 +val SCE_FORTH_LOCALE=11 +# Lexical states for SCLEX_MATLAB +lex MatLab=SCLEX_MATLAB SCE_MATLAB_ +val SCE_MATLAB_DEFAULT=0 +val SCE_MATLAB_COMMENT=1 +val SCE_MATLAB_COMMAND=2 +val SCE_MATLAB_NUMBER=3 +val SCE_MATLAB_KEYWORD=4 +# single quoted string +val SCE_MATLAB_STRING=5 +val SCE_MATLAB_OPERATOR=6 +val SCE_MATLAB_IDENTIFIER=7 +val SCE_MATLAB_DOUBLEQUOTESTRING=8 +# Lexical states for SCLEX_MAXIMA +lex Maxima=SCLEX_MAXIMA SCE_MAXIMA_ +val SCE_MAXIMA_OPERATOR=0 +val SCE_MAXIMA_COMMANDENDING=1 +val SCE_MAXIMA_COMMENT=2 +val SCE_MAXIMA_NUMBER=3 +val SCE_MAXIMA_STRING=4 +val SCE_MAXIMA_COMMAND=5 +val SCE_MAXIMA_VARIABLE=6 +val SCE_MAXIMA_UNKNOWN=7 +# Lexical states for SCLEX_SCRIPTOL +lex Sol=SCLEX_SCRIPTOL SCE_SCRIPTOL_ +val SCE_SCRIPTOL_DEFAULT=0 +val SCE_SCRIPTOL_WHITE=1 +val SCE_SCRIPTOL_COMMENTLINE=2 +val SCE_SCRIPTOL_PERSISTENT=3 +val SCE_SCRIPTOL_CSTYLE=4 +val SCE_SCRIPTOL_COMMENTBLOCK=5 +val SCE_SCRIPTOL_NUMBER=6 +val SCE_SCRIPTOL_STRING=7 +val SCE_SCRIPTOL_CHARACTER=8 +val SCE_SCRIPTOL_STRINGEOL=9 +val SCE_SCRIPTOL_KEYWORD=10 +val SCE_SCRIPTOL_OPERATOR=11 +val SCE_SCRIPTOL_IDENTIFIER=12 +val SCE_SCRIPTOL_TRIPLE=13 +val SCE_SCRIPTOL_CLASSNAME=14 +val SCE_SCRIPTOL_PREPROCESSOR=15 +# Lexical states for SCLEX_ASM, SCLEX_AS +lex Asm=SCLEX_ASM SCE_ASM_ +lex As=SCLEX_AS SCE_ASM_ +val SCE_ASM_DEFAULT=0 +val SCE_ASM_COMMENT=1 +val SCE_ASM_NUMBER=2 +val SCE_ASM_STRING=3 +val SCE_ASM_OPERATOR=4 +val SCE_ASM_IDENTIFIER=5 +val SCE_ASM_CPUINSTRUCTION=6 +val SCE_ASM_MATHINSTRUCTION=7 +val SCE_ASM_REGISTER=8 +val SCE_ASM_DIRECTIVE=9 +val SCE_ASM_DIRECTIVEOPERAND=10 +val SCE_ASM_COMMENTBLOCK=11 +val SCE_ASM_CHARACTER=12 +val SCE_ASM_STRINGEOL=13 +val SCE_ASM_EXTINSTRUCTION=14 +val SCE_ASM_COMMENTDIRECTIVE=15 +# Lexical states for SCLEX_FORTRAN +lex Fortran=SCLEX_FORTRAN SCE_F_ +lex F77=SCLEX_F77 SCE_F_ +val SCE_F_DEFAULT=0 +val SCE_F_COMMENT=1 +val SCE_F_NUMBER=2 +val SCE_F_STRING1=3 +val SCE_F_STRING2=4 +val SCE_F_STRINGEOL=5 +val SCE_F_OPERATOR=6 +val SCE_F_IDENTIFIER=7 +val SCE_F_WORD=8 +val SCE_F_WORD2=9 +val SCE_F_WORD3=10 +val SCE_F_PREPROCESSOR=11 +val SCE_F_OPERATOR2=12 +val SCE_F_LABEL=13 +val SCE_F_CONTINUATION=14 +# Lexical states for SCLEX_CSS +lex CSS=SCLEX_CSS SCE_CSS_ +val SCE_CSS_DEFAULT=0 +val SCE_CSS_TAG=1 +val SCE_CSS_CLASS=2 +val SCE_CSS_PSEUDOCLASS=3 +val SCE_CSS_UNKNOWN_PSEUDOCLASS=4 +val SCE_CSS_OPERATOR=5 +val SCE_CSS_IDENTIFIER=6 +val SCE_CSS_UNKNOWN_IDENTIFIER=7 +val SCE_CSS_VALUE=8 +val SCE_CSS_COMMENT=9 +val SCE_CSS_ID=10 +val SCE_CSS_IMPORTANT=11 +val SCE_CSS_DIRECTIVE=12 +val SCE_CSS_DOUBLESTRING=13 +val SCE_CSS_SINGLESTRING=14 +val SCE_CSS_IDENTIFIER2=15 +val SCE_CSS_ATTRIBUTE=16 +val SCE_CSS_IDENTIFIER3=17 +val SCE_CSS_PSEUDOELEMENT=18 +val SCE_CSS_EXTENDED_IDENTIFIER=19 +val SCE_CSS_EXTENDED_PSEUDOCLASS=20 +val SCE_CSS_EXTENDED_PSEUDOELEMENT=21 +val SCE_CSS_MEDIA=22 +val SCE_CSS_VARIABLE=23 +# Lexical states for SCLEX_POV +lex POV=SCLEX_POV SCE_POV_ +val SCE_POV_DEFAULT=0 +val SCE_POV_COMMENT=1 +val SCE_POV_COMMENTLINE=2 +val SCE_POV_NUMBER=3 +val SCE_POV_OPERATOR=4 +val SCE_POV_IDENTIFIER=5 +val SCE_POV_STRING=6 +val SCE_POV_STRINGEOL=7 +val SCE_POV_DIRECTIVE=8 +val SCE_POV_BADDIRECTIVE=9 +val SCE_POV_WORD2=10 +val SCE_POV_WORD3=11 +val SCE_POV_WORD4=12 +val SCE_POV_WORD5=13 +val SCE_POV_WORD6=14 +val SCE_POV_WORD7=15 +val SCE_POV_WORD8=16 +# Lexical states for SCLEX_LOUT +lex LOUT=SCLEX_LOUT SCE_LOUT_ +val SCE_LOUT_DEFAULT=0 +val SCE_LOUT_COMMENT=1 +val SCE_LOUT_NUMBER=2 +val SCE_LOUT_WORD=3 +val SCE_LOUT_WORD2=4 +val SCE_LOUT_WORD3=5 +val SCE_LOUT_WORD4=6 +val SCE_LOUT_STRING=7 +val SCE_LOUT_OPERATOR=8 +val SCE_LOUT_IDENTIFIER=9 +val SCE_LOUT_STRINGEOL=10 +# Lexical states for SCLEX_ESCRIPT +lex ESCRIPT=SCLEX_ESCRIPT SCE_ESCRIPT_ +val SCE_ESCRIPT_DEFAULT=0 +val SCE_ESCRIPT_COMMENT=1 +val SCE_ESCRIPT_COMMENTLINE=2 +val SCE_ESCRIPT_COMMENTDOC=3 +val SCE_ESCRIPT_NUMBER=4 +val SCE_ESCRIPT_WORD=5 +val SCE_ESCRIPT_STRING=6 +val SCE_ESCRIPT_OPERATOR=7 +val SCE_ESCRIPT_IDENTIFIER=8 +val SCE_ESCRIPT_BRACE=9 +val SCE_ESCRIPT_WORD2=10 +val SCE_ESCRIPT_WORD3=11 +# Lexical states for SCLEX_PS +lex PS=SCLEX_PS SCE_PS_ +val SCE_PS_DEFAULT=0 +val SCE_PS_COMMENT=1 +val SCE_PS_DSC_COMMENT=2 +val SCE_PS_DSC_VALUE=3 +val SCE_PS_NUMBER=4 +val SCE_PS_NAME=5 +val SCE_PS_KEYWORD=6 +val SCE_PS_LITERAL=7 +val SCE_PS_IMMEVAL=8 +val SCE_PS_PAREN_ARRAY=9 +val SCE_PS_PAREN_DICT=10 +val SCE_PS_PAREN_PROC=11 +val SCE_PS_TEXT=12 +val SCE_PS_HEXSTRING=13 +val SCE_PS_BASE85STRING=14 +val SCE_PS_BADSTRINGCHAR=15 +# Lexical states for SCLEX_NSIS +lex NSIS=SCLEX_NSIS SCE_NSIS_ +val SCE_NSIS_DEFAULT=0 +val SCE_NSIS_COMMENT=1 +val SCE_NSIS_STRINGDQ=2 +val SCE_NSIS_STRINGLQ=3 +val SCE_NSIS_STRINGRQ=4 +val SCE_NSIS_FUNCTION=5 +val SCE_NSIS_VARIABLE=6 +val SCE_NSIS_LABEL=7 +val SCE_NSIS_USERDEFINED=8 +val SCE_NSIS_SECTIONDEF=9 +val SCE_NSIS_SUBSECTIONDEF=10 +val SCE_NSIS_IFDEFINEDEF=11 +val SCE_NSIS_MACRODEF=12 +val SCE_NSIS_STRINGVAR=13 +val SCE_NSIS_NUMBER=14 +val SCE_NSIS_SECTIONGROUP=15 +val SCE_NSIS_PAGEEX=16 +val SCE_NSIS_FUNCTIONDEF=17 +val SCE_NSIS_COMMENTBOX=18 +# Lexical states for SCLEX_MMIXAL +lex MMIXAL=SCLEX_MMIXAL SCE_MMIXAL_ +val SCE_MMIXAL_LEADWS=0 +val SCE_MMIXAL_COMMENT=1 +val SCE_MMIXAL_LABEL=2 +val SCE_MMIXAL_OPCODE=3 +val SCE_MMIXAL_OPCODE_PRE=4 +val SCE_MMIXAL_OPCODE_VALID=5 +val SCE_MMIXAL_OPCODE_UNKNOWN=6 +val SCE_MMIXAL_OPCODE_POST=7 +val SCE_MMIXAL_OPERANDS=8 +val SCE_MMIXAL_NUMBER=9 +val SCE_MMIXAL_REF=10 +val SCE_MMIXAL_CHAR=11 +val SCE_MMIXAL_STRING=12 +val SCE_MMIXAL_REGISTER=13 +val SCE_MMIXAL_HEX=14 +val SCE_MMIXAL_OPERATOR=15 +val SCE_MMIXAL_SYMBOL=16 +val SCE_MMIXAL_INCLUDE=17 +# Lexical states for SCLEX_CLW +lex Clarion=SCLEX_CLW SCE_CLW_ +val SCE_CLW_DEFAULT=0 +val SCE_CLW_LABEL=1 +val SCE_CLW_COMMENT=2 +val SCE_CLW_STRING=3 +val SCE_CLW_USER_IDENTIFIER=4 +val SCE_CLW_INTEGER_CONSTANT=5 +val SCE_CLW_REAL_CONSTANT=6 +val SCE_CLW_PICTURE_STRING=7 +val SCE_CLW_KEYWORD=8 +val SCE_CLW_COMPILER_DIRECTIVE=9 +val SCE_CLW_RUNTIME_EXPRESSIONS=10 +val SCE_CLW_BUILTIN_PROCEDURES_FUNCTION=11 +val SCE_CLW_STRUCTURE_DATA_TYPE=12 +val SCE_CLW_ATTRIBUTE=13 +val SCE_CLW_STANDARD_EQUATE=14 +val SCE_CLW_ERROR=15 +val SCE_CLW_DEPRECATED=16 +# Lexical states for SCLEX_LOT +lex LOT=SCLEX_LOT SCE_LOT_ +val SCE_LOT_DEFAULT=0 +val SCE_LOT_HEADER=1 +val SCE_LOT_BREAK=2 +val SCE_LOT_SET=3 +val SCE_LOT_PASS=4 +val SCE_LOT_FAIL=5 +val SCE_LOT_ABORT=6 +# Lexical states for SCLEX_YAML +lex YAML=SCLEX_YAML SCE_YAML_ +val SCE_YAML_DEFAULT=0 +val SCE_YAML_COMMENT=1 +val SCE_YAML_IDENTIFIER=2 +val SCE_YAML_KEYWORD=3 +val SCE_YAML_NUMBER=4 +val SCE_YAML_REFERENCE=5 +val SCE_YAML_DOCUMENT=6 +val SCE_YAML_TEXT=7 +val SCE_YAML_ERROR=8 +val SCE_YAML_OPERATOR=9 +# Lexical states for SCLEX_TEX +lex TeX=SCLEX_TEX SCE_TEX_ +val SCE_TEX_DEFAULT=0 +val SCE_TEX_SPECIAL=1 +val SCE_TEX_GROUP=2 +val SCE_TEX_SYMBOL=3 +val SCE_TEX_COMMAND=4 +val SCE_TEX_TEXT=5 +lex Metapost=SCLEX_METAPOST SCE_METAPOST_ +val SCE_METAPOST_DEFAULT=0 +val SCE_METAPOST_SPECIAL=1 +val SCE_METAPOST_GROUP=2 +val SCE_METAPOST_SYMBOL=3 +val SCE_METAPOST_COMMAND=4 +val SCE_METAPOST_TEXT=5 +val SCE_METAPOST_EXTRA=6 +# Lexical states for SCLEX_ERLANG +lex Erlang=SCLEX_ERLANG SCE_ERLANG_ +val SCE_ERLANG_DEFAULT=0 +val SCE_ERLANG_COMMENT=1 +val SCE_ERLANG_VARIABLE=2 +val SCE_ERLANG_NUMBER=3 +val SCE_ERLANG_KEYWORD=4 +val SCE_ERLANG_STRING=5 +val SCE_ERLANG_OPERATOR=6 +val SCE_ERLANG_ATOM=7 +val SCE_ERLANG_FUNCTION_NAME=8 +val SCE_ERLANG_CHARACTER=9 +val SCE_ERLANG_MACRO=10 +val SCE_ERLANG_RECORD=11 +val SCE_ERLANG_PREPROC=12 +val SCE_ERLANG_NODE_NAME=13 +val SCE_ERLANG_COMMENT_FUNCTION=14 +val SCE_ERLANG_COMMENT_MODULE=15 +val SCE_ERLANG_COMMENT_DOC=16 +val SCE_ERLANG_COMMENT_DOC_MACRO=17 +val SCE_ERLANG_ATOM_QUOTED=18 +val SCE_ERLANG_MACRO_QUOTED=19 +val SCE_ERLANG_RECORD_QUOTED=20 +val SCE_ERLANG_NODE_NAME_QUOTED=21 +val SCE_ERLANG_BIFS=22 +val SCE_ERLANG_MODULES=23 +val SCE_ERLANG_MODULES_ATT=24 +val SCE_ERLANG_UNKNOWN=31 +# Lexical states for SCLEX_OCTAVE are identical to MatLab +lex Octave=SCLEX_OCTAVE SCE_MATLAB_ +# Lexical states for SCLEX_MSSQL +lex MSSQL=SCLEX_MSSQL SCE_MSSQL_ +val SCE_MSSQL_DEFAULT=0 +val SCE_MSSQL_COMMENT=1 +val SCE_MSSQL_LINE_COMMENT=2 +val SCE_MSSQL_NUMBER=3 +val SCE_MSSQL_STRING=4 +val SCE_MSSQL_OPERATOR=5 +val SCE_MSSQL_IDENTIFIER=6 +val SCE_MSSQL_VARIABLE=7 +val SCE_MSSQL_COLUMN_NAME=8 +val SCE_MSSQL_STATEMENT=9 +val SCE_MSSQL_DATATYPE=10 +val SCE_MSSQL_SYSTABLE=11 +val SCE_MSSQL_GLOBAL_VARIABLE=12 +val SCE_MSSQL_FUNCTION=13 +val SCE_MSSQL_STORED_PROCEDURE=14 +val SCE_MSSQL_DEFAULT_PREF_DATATYPE=15 +val SCE_MSSQL_COLUMN_NAME_2=16 +# Lexical states for SCLEX_VERILOG +lex Verilog=SCLEX_VERILOG SCE_V_ +val SCE_V_DEFAULT=0 +val SCE_V_COMMENT=1 +val SCE_V_COMMENTLINE=2 +val SCE_V_COMMENTLINEBANG=3 +val SCE_V_NUMBER=4 +val SCE_V_WORD=5 +val SCE_V_STRING=6 +val SCE_V_WORD2=7 +val SCE_V_WORD3=8 +val SCE_V_PREPROCESSOR=9 +val SCE_V_OPERATOR=10 +val SCE_V_IDENTIFIER=11 +val SCE_V_STRINGEOL=12 +val SCE_V_USER=19 +val SCE_V_COMMENT_WORD=20 +val SCE_V_INPUT=21 +val SCE_V_OUTPUT=22 +val SCE_V_INOUT=23 +val SCE_V_PORT_CONNECT=24 +# Lexical states for SCLEX_KIX +lex Kix=SCLEX_KIX SCE_KIX_ +val SCE_KIX_DEFAULT=0 +val SCE_KIX_COMMENT=1 +val SCE_KIX_STRING1=2 +val SCE_KIX_STRING2=3 +val SCE_KIX_NUMBER=4 +val SCE_KIX_VAR=5 +val SCE_KIX_MACRO=6 +val SCE_KIX_KEYWORD=7 +val SCE_KIX_FUNCTIONS=8 +val SCE_KIX_OPERATOR=9 +val SCE_KIX_COMMENTSTREAM=10 +val SCE_KIX_IDENTIFIER=31 +# Lexical states for SCLEX_GUI4CLI +lex Gui4Cli=SCLEX_GUI4CLI SCE_GC_ +val SCE_GC_DEFAULT=0 +val SCE_GC_COMMENTLINE=1 +val SCE_GC_COMMENTBLOCK=2 +val SCE_GC_GLOBAL=3 +val SCE_GC_EVENT=4 +val SCE_GC_ATTRIBUTE=5 +val SCE_GC_CONTROL=6 +val SCE_GC_COMMAND=7 +val SCE_GC_STRING=8 +val SCE_GC_OPERATOR=9 +# Lexical states for SCLEX_SPECMAN +lex Specman=SCLEX_SPECMAN SCE_SN_ +val SCE_SN_DEFAULT=0 +val SCE_SN_CODE=1 +val SCE_SN_COMMENTLINE=2 +val SCE_SN_COMMENTLINEBANG=3 +val SCE_SN_NUMBER=4 +val SCE_SN_WORD=5 +val SCE_SN_STRING=6 +val SCE_SN_WORD2=7 +val SCE_SN_WORD3=8 +val SCE_SN_PREPROCESSOR=9 +val SCE_SN_OPERATOR=10 +val SCE_SN_IDENTIFIER=11 +val SCE_SN_STRINGEOL=12 +val SCE_SN_REGEXTAG=13 +val SCE_SN_SIGNAL=14 +val SCE_SN_USER=19 +# Lexical states for SCLEX_AU3 +lex Au3=SCLEX_AU3 SCE_AU3_ +val SCE_AU3_DEFAULT=0 +val SCE_AU3_COMMENT=1 +val SCE_AU3_COMMENTBLOCK=2 +val SCE_AU3_NUMBER=3 +val SCE_AU3_FUNCTION=4 +val SCE_AU3_KEYWORD=5 +val SCE_AU3_MACRO=6 +val SCE_AU3_STRING=7 +val SCE_AU3_OPERATOR=8 +val SCE_AU3_VARIABLE=9 +val SCE_AU3_SENT=10 +val SCE_AU3_PREPROCESSOR=11 +val SCE_AU3_SPECIAL=12 +val SCE_AU3_EXPAND=13 +val SCE_AU3_COMOBJ=14 +val SCE_AU3_UDF=15 +# Lexical states for SCLEX_APDL +lex APDL=SCLEX_APDL SCE_APDL_ +val SCE_APDL_DEFAULT=0 +val SCE_APDL_COMMENT=1 +val SCE_APDL_COMMENTBLOCK=2 +val SCE_APDL_NUMBER=3 +val SCE_APDL_STRING=4 +val SCE_APDL_OPERATOR=5 +val SCE_APDL_WORD=6 +val SCE_APDL_PROCESSOR=7 +val SCE_APDL_COMMAND=8 +val SCE_APDL_SLASHCOMMAND=9 +val SCE_APDL_STARCOMMAND=10 +val SCE_APDL_ARGUMENT=11 +val SCE_APDL_FUNCTION=12 +# Lexical states for SCLEX_BASH +lex Bash=SCLEX_BASH SCE_SH_ +val SCE_SH_DEFAULT=0 +val SCE_SH_ERROR=1 +val SCE_SH_COMMENTLINE=2 +val SCE_SH_NUMBER=3 +val SCE_SH_WORD=4 +val SCE_SH_STRING=5 +val SCE_SH_CHARACTER=6 +val SCE_SH_OPERATOR=7 +val SCE_SH_IDENTIFIER=8 +val SCE_SH_SCALAR=9 +val SCE_SH_PARAM=10 +val SCE_SH_BACKTICKS=11 +val SCE_SH_HERE_DELIM=12 +val SCE_SH_HERE_Q=13 +# Lexical states for SCLEX_ASN1 +lex Asn1=SCLEX_ASN1 SCE_ASN1_ +val SCE_ASN1_DEFAULT=0 +val SCE_ASN1_COMMENT=1 +val SCE_ASN1_IDENTIFIER=2 +val SCE_ASN1_STRING=3 +val SCE_ASN1_OID=4 +val SCE_ASN1_SCALAR=5 +val SCE_ASN1_KEYWORD=6 +val SCE_ASN1_ATTRIBUTE=7 +val SCE_ASN1_DESCRIPTOR=8 +val SCE_ASN1_TYPE=9 +val SCE_ASN1_OPERATOR=10 +# Lexical states for SCLEX_VHDL +lex VHDL=SCLEX_VHDL SCE_VHDL_ +val SCE_VHDL_DEFAULT=0 +val SCE_VHDL_COMMENT=1 +val SCE_VHDL_COMMENTLINEBANG=2 +val SCE_VHDL_NUMBER=3 +val SCE_VHDL_STRING=4 +val SCE_VHDL_OPERATOR=5 +val SCE_VHDL_IDENTIFIER=6 +val SCE_VHDL_STRINGEOL=7 +val SCE_VHDL_KEYWORD=8 +val SCE_VHDL_STDOPERATOR=9 +val SCE_VHDL_ATTRIBUTE=10 +val SCE_VHDL_STDFUNCTION=11 +val SCE_VHDL_STDPACKAGE=12 +val SCE_VHDL_STDTYPE=13 +val SCE_VHDL_USERWORD=14 +val SCE_VHDL_BLOCK_COMMENT=15 +# Lexical states for SCLEX_CAML +lex Caml=SCLEX_CAML SCE_CAML_ +val SCE_CAML_DEFAULT=0 +val SCE_CAML_IDENTIFIER=1 +val SCE_CAML_TAGNAME=2 +val SCE_CAML_KEYWORD=3 +val SCE_CAML_KEYWORD2=4 +val SCE_CAML_KEYWORD3=5 +val SCE_CAML_LINENUM=6 +val SCE_CAML_OPERATOR=7 +val SCE_CAML_NUMBER=8 +val SCE_CAML_CHAR=9 +val SCE_CAML_WHITE=10 +val SCE_CAML_STRING=11 +val SCE_CAML_COMMENT=12 +val SCE_CAML_COMMENT1=13 +val SCE_CAML_COMMENT2=14 +val SCE_CAML_COMMENT3=15 +# Lexical states for SCLEX_HASKELL +lex Haskell=SCLEX_HASKELL SCE_HA_ +val SCE_HA_DEFAULT=0 +val SCE_HA_IDENTIFIER=1 +val SCE_HA_KEYWORD=2 +val SCE_HA_NUMBER=3 +val SCE_HA_STRING=4 +val SCE_HA_CHARACTER=5 +val SCE_HA_CLASS=6 +val SCE_HA_MODULE=7 +val SCE_HA_CAPITAL=8 +val SCE_HA_DATA=9 +val SCE_HA_IMPORT=10 +val SCE_HA_OPERATOR=11 +val SCE_HA_INSTANCE=12 +val SCE_HA_COMMENTLINE=13 +val SCE_HA_COMMENTBLOCK=14 +val SCE_HA_COMMENTBLOCK2=15 +val SCE_HA_COMMENTBLOCK3=16 +val SCE_HA_PRAGMA=17 +val SCE_HA_PREPROCESSOR=18 +val SCE_HA_STRINGEOL=19 +val SCE_HA_RESERVED_OPERATOR=20 +val SCE_HA_LITERATE_COMMENT=21 +val SCE_HA_LITERATE_CODEDELIM=22 +# Lexical states of SCLEX_TADS3 +lex TADS3=SCLEX_TADS3 SCE_T3_ +val SCE_T3_DEFAULT=0 +val SCE_T3_X_DEFAULT=1 +val SCE_T3_PREPROCESSOR=2 +val SCE_T3_BLOCK_COMMENT=3 +val SCE_T3_LINE_COMMENT=4 +val SCE_T3_OPERATOR=5 +val SCE_T3_KEYWORD=6 +val SCE_T3_NUMBER=7 +val SCE_T3_IDENTIFIER=8 +val SCE_T3_S_STRING=9 +val SCE_T3_D_STRING=10 +val SCE_T3_X_STRING=11 +val SCE_T3_LIB_DIRECTIVE=12 +val SCE_T3_MSG_PARAM=13 +val SCE_T3_HTML_TAG=14 +val SCE_T3_HTML_DEFAULT=15 +val SCE_T3_HTML_STRING=16 +val SCE_T3_USER1=17 +val SCE_T3_USER2=18 +val SCE_T3_USER3=19 +val SCE_T3_BRACE=20 +# Lexical states for SCLEX_REBOL +lex Rebol=SCLEX_REBOL SCE_REBOL_ +val SCE_REBOL_DEFAULT=0 +val SCE_REBOL_COMMENTLINE=1 +val SCE_REBOL_COMMENTBLOCK=2 +val SCE_REBOL_PREFACE=3 +val SCE_REBOL_OPERATOR=4 +val SCE_REBOL_CHARACTER=5 +val SCE_REBOL_QUOTEDSTRING=6 +val SCE_REBOL_BRACEDSTRING=7 +val SCE_REBOL_NUMBER=8 +val SCE_REBOL_PAIR=9 +val SCE_REBOL_TUPLE=10 +val SCE_REBOL_BINARY=11 +val SCE_REBOL_MONEY=12 +val SCE_REBOL_ISSUE=13 +val SCE_REBOL_TAG=14 +val SCE_REBOL_FILE=15 +val SCE_REBOL_EMAIL=16 +val SCE_REBOL_URL=17 +val SCE_REBOL_DATE=18 +val SCE_REBOL_TIME=19 +val SCE_REBOL_IDENTIFIER=20 +val SCE_REBOL_WORD=21 +val SCE_REBOL_WORD2=22 +val SCE_REBOL_WORD3=23 +val SCE_REBOL_WORD4=24 +val SCE_REBOL_WORD5=25 +val SCE_REBOL_WORD6=26 +val SCE_REBOL_WORD7=27 +val SCE_REBOL_WORD8=28 +# Lexical states for SCLEX_SQL +lex SQL=SCLEX_SQL SCE_SQL_ +val SCE_SQL_DEFAULT=0 +val SCE_SQL_COMMENT=1 +val SCE_SQL_COMMENTLINE=2 +val SCE_SQL_COMMENTDOC=3 +val SCE_SQL_NUMBER=4 +val SCE_SQL_WORD=5 +val SCE_SQL_STRING=6 +val SCE_SQL_CHARACTER=7 +val SCE_SQL_SQLPLUS=8 +val SCE_SQL_SQLPLUS_PROMPT=9 +val SCE_SQL_OPERATOR=10 +val SCE_SQL_IDENTIFIER=11 +val SCE_SQL_SQLPLUS_COMMENT=13 +val SCE_SQL_COMMENTLINEDOC=15 +val SCE_SQL_WORD2=16 +val SCE_SQL_COMMENTDOCKEYWORD=17 +val SCE_SQL_COMMENTDOCKEYWORDERROR=18 +val SCE_SQL_USER1=19 +val SCE_SQL_USER2=20 +val SCE_SQL_USER3=21 +val SCE_SQL_USER4=22 +val SCE_SQL_QUOTEDIDENTIFIER=23 +val SCE_SQL_QOPERATOR=24 +# Lexical states for SCLEX_SMALLTALK +lex Smalltalk=SCLEX_SMALLTALK SCE_ST_ +val SCE_ST_DEFAULT=0 +val SCE_ST_STRING=1 +val SCE_ST_NUMBER=2 +val SCE_ST_COMMENT=3 +val SCE_ST_SYMBOL=4 +val SCE_ST_BINARY=5 +val SCE_ST_BOOL=6 +val SCE_ST_SELF=7 +val SCE_ST_SUPER=8 +val SCE_ST_NIL=9 +val SCE_ST_GLOBAL=10 +val SCE_ST_RETURN=11 +val SCE_ST_SPECIAL=12 +val SCE_ST_KWSEND=13 +val SCE_ST_ASSIGN=14 +val SCE_ST_CHARACTER=15 +val SCE_ST_SPEC_SEL=16 +# Lexical states for SCLEX_FLAGSHIP (clipper) +lex FlagShip=SCLEX_FLAGSHIP SCE_FS_ +val SCE_FS_DEFAULT=0 +val SCE_FS_COMMENT=1 +val SCE_FS_COMMENTLINE=2 +val SCE_FS_COMMENTDOC=3 +val SCE_FS_COMMENTLINEDOC=4 +val SCE_FS_COMMENTDOCKEYWORD=5 +val SCE_FS_COMMENTDOCKEYWORDERROR=6 +val SCE_FS_KEYWORD=7 +val SCE_FS_KEYWORD2=8 +val SCE_FS_KEYWORD3=9 +val SCE_FS_KEYWORD4=10 +val SCE_FS_NUMBER=11 +val SCE_FS_STRING=12 +val SCE_FS_PREPROCESSOR=13 +val SCE_FS_OPERATOR=14 +val SCE_FS_IDENTIFIER=15 +val SCE_FS_DATE=16 +val SCE_FS_STRINGEOL=17 +val SCE_FS_CONSTANT=18 +val SCE_FS_WORDOPERATOR=19 +val SCE_FS_DISABLEDCODE=20 +val SCE_FS_DEFAULT_C=21 +val SCE_FS_COMMENTDOC_C=22 +val SCE_FS_COMMENTLINEDOC_C=23 +val SCE_FS_KEYWORD_C=24 +val SCE_FS_KEYWORD2_C=25 +val SCE_FS_NUMBER_C=26 +val SCE_FS_STRING_C=27 +val SCE_FS_PREPROCESSOR_C=28 +val SCE_FS_OPERATOR_C=29 +val SCE_FS_IDENTIFIER_C=30 +val SCE_FS_STRINGEOL_C=31 +# Lexical states for SCLEX_CSOUND +lex Csound=SCLEX_CSOUND SCE_CSOUND_ +val SCE_CSOUND_DEFAULT=0 +val SCE_CSOUND_COMMENT=1 +val SCE_CSOUND_NUMBER=2 +val SCE_CSOUND_OPERATOR=3 +val SCE_CSOUND_INSTR=4 +val SCE_CSOUND_IDENTIFIER=5 +val SCE_CSOUND_OPCODE=6 +val SCE_CSOUND_HEADERSTMT=7 +val SCE_CSOUND_USERKEYWORD=8 +val SCE_CSOUND_COMMENTBLOCK=9 +val SCE_CSOUND_PARAM=10 +val SCE_CSOUND_ARATE_VAR=11 +val SCE_CSOUND_KRATE_VAR=12 +val SCE_CSOUND_IRATE_VAR=13 +val SCE_CSOUND_GLOBAL_VAR=14 +val SCE_CSOUND_STRINGEOL=15 +# Lexical states for SCLEX_INNOSETUP +lex Inno=SCLEX_INNOSETUP SCE_INNO_ +val SCE_INNO_DEFAULT=0 +val SCE_INNO_COMMENT=1 +val SCE_INNO_KEYWORD=2 +val SCE_INNO_PARAMETER=3 +val SCE_INNO_SECTION=4 +val SCE_INNO_PREPROC=5 +val SCE_INNO_INLINE_EXPANSION=6 +val SCE_INNO_COMMENT_PASCAL=7 +val SCE_INNO_KEYWORD_PASCAL=8 +val SCE_INNO_KEYWORD_USER=9 +val SCE_INNO_STRING_DOUBLE=10 +val SCE_INNO_STRING_SINGLE=11 +val SCE_INNO_IDENTIFIER=12 +# Lexical states for SCLEX_OPAL +lex Opal=SCLEX_OPAL SCE_OPAL_ +val SCE_OPAL_SPACE=0 +val SCE_OPAL_COMMENT_BLOCK=1 +val SCE_OPAL_COMMENT_LINE=2 +val SCE_OPAL_INTEGER=3 +val SCE_OPAL_KEYWORD=4 +val SCE_OPAL_SORT=5 +val SCE_OPAL_STRING=6 +val SCE_OPAL_PAR=7 +val SCE_OPAL_BOOL_CONST=8 +val SCE_OPAL_DEFAULT=32 +# Lexical states for SCLEX_SPICE +lex Spice=SCLEX_SPICE SCE_SPICE_ +val SCE_SPICE_DEFAULT=0 +val SCE_SPICE_IDENTIFIER=1 +val SCE_SPICE_KEYWORD=2 +val SCE_SPICE_KEYWORD2=3 +val SCE_SPICE_KEYWORD3=4 +val SCE_SPICE_NUMBER=5 +val SCE_SPICE_DELIMITER=6 +val SCE_SPICE_VALUE=7 +val SCE_SPICE_COMMENTLINE=8 +# Lexical states for SCLEX_CMAKE +lex CMAKE=SCLEX_CMAKE SCE_CMAKE_ +val SCE_CMAKE_DEFAULT=0 +val SCE_CMAKE_COMMENT=1 +val SCE_CMAKE_STRINGDQ=2 +val SCE_CMAKE_STRINGLQ=3 +val SCE_CMAKE_STRINGRQ=4 +val SCE_CMAKE_COMMANDS=5 +val SCE_CMAKE_PARAMETERS=6 +val SCE_CMAKE_VARIABLE=7 +val SCE_CMAKE_USERDEFINED=8 +val SCE_CMAKE_WHILEDEF=9 +val SCE_CMAKE_FOREACHDEF=10 +val SCE_CMAKE_IFDEFINEDEF=11 +val SCE_CMAKE_MACRODEF=12 +val SCE_CMAKE_STRINGVAR=13 +val SCE_CMAKE_NUMBER=14 +# Lexical states for SCLEX_GAP +lex Gap=SCLEX_GAP SCE_GAP_ +val SCE_GAP_DEFAULT=0 +val SCE_GAP_IDENTIFIER=1 +val SCE_GAP_KEYWORD=2 +val SCE_GAP_KEYWORD2=3 +val SCE_GAP_KEYWORD3=4 +val SCE_GAP_KEYWORD4=5 +val SCE_GAP_STRING=6 +val SCE_GAP_CHAR=7 +val SCE_GAP_OPERATOR=8 +val SCE_GAP_COMMENT=9 +val SCE_GAP_NUMBER=10 +val SCE_GAP_STRINGEOL=11 +# Lexical state for SCLEX_PLM +lex PLM=SCLEX_PLM SCE_PLM_ +val SCE_PLM_DEFAULT=0 +val SCE_PLM_COMMENT=1 +val SCE_PLM_STRING=2 +val SCE_PLM_NUMBER=3 +val SCE_PLM_IDENTIFIER=4 +val SCE_PLM_OPERATOR=5 +val SCE_PLM_CONTROL=6 +val SCE_PLM_KEYWORD=7 +# Lexical state for SCLEX_PROGRESS +lex Progress=SCLEX_PROGRESS SCE_ABL_ +val SCE_ABL_DEFAULT=0 +val SCE_ABL_NUMBER=1 +val SCE_ABL_WORD=2 +val SCE_ABL_STRING=3 +val SCE_ABL_CHARACTER=4 +val SCE_ABL_PREPROCESSOR=5 +val SCE_ABL_OPERATOR=6 +val SCE_ABL_IDENTIFIER=7 +val SCE_ABL_BLOCK=8 +val SCE_ABL_END=9 +val SCE_ABL_COMMENT=10 +val SCE_ABL_TASKMARKER=11 +val SCE_ABL_LINECOMMENT=12 +# Lexical states for SCLEX_ABAQUS +lex ABAQUS=SCLEX_ABAQUS SCE_ABAQUS_ +val SCE_ABAQUS_DEFAULT=0 +val SCE_ABAQUS_COMMENT=1 +val SCE_ABAQUS_COMMENTBLOCK=2 +val SCE_ABAQUS_NUMBER=3 +val SCE_ABAQUS_STRING=4 +val SCE_ABAQUS_OPERATOR=5 +val SCE_ABAQUS_WORD=6 +val SCE_ABAQUS_PROCESSOR=7 +val SCE_ABAQUS_COMMAND=8 +val SCE_ABAQUS_SLASHCOMMAND=9 +val SCE_ABAQUS_STARCOMMAND=10 +val SCE_ABAQUS_ARGUMENT=11 +val SCE_ABAQUS_FUNCTION=12 +# Lexical states for SCLEX_ASYMPTOTE +lex Asymptote=SCLEX_ASYMPTOTE SCE_ASY_ +val SCE_ASY_DEFAULT=0 +val SCE_ASY_COMMENT=1 +val SCE_ASY_COMMENTLINE=2 +val SCE_ASY_NUMBER=3 +val SCE_ASY_WORD=4 +val SCE_ASY_STRING=5 +val SCE_ASY_CHARACTER=6 +val SCE_ASY_OPERATOR=7 +val SCE_ASY_IDENTIFIER=8 +val SCE_ASY_STRINGEOL=9 +val SCE_ASY_COMMENTLINEDOC=10 +val SCE_ASY_WORD2=11 +# Lexical states for SCLEX_R +lex R=SCLEX_R SCE_R_ +val SCE_R_DEFAULT=0 +val SCE_R_COMMENT=1 +val SCE_R_KWORD=2 +val SCE_R_BASEKWORD=3 +val SCE_R_OTHERKWORD=4 +val SCE_R_NUMBER=5 +val SCE_R_STRING=6 +val SCE_R_STRING2=7 +val SCE_R_OPERATOR=8 +val SCE_R_IDENTIFIER=9 +val SCE_R_INFIX=10 +val SCE_R_INFIXEOL=11 +# Lexical state for SCLEX_MAGIK +lex MagikSF=SCLEX_MAGIK SCE_MAGIK_ +val SCE_MAGIK_DEFAULT=0 +val SCE_MAGIK_COMMENT=1 +val SCE_MAGIK_HYPER_COMMENT=16 +val SCE_MAGIK_STRING=2 +val SCE_MAGIK_CHARACTER=3 +val SCE_MAGIK_NUMBER=4 +val SCE_MAGIK_IDENTIFIER=5 +val SCE_MAGIK_OPERATOR=6 +val SCE_MAGIK_FLOW=7 +val SCE_MAGIK_CONTAINER=8 +val SCE_MAGIK_BRACKET_BLOCK=9 +val SCE_MAGIK_BRACE_BLOCK=10 +val SCE_MAGIK_SQBRACKET_BLOCK=11 +val SCE_MAGIK_UNKNOWN_KEYWORD=12 +val SCE_MAGIK_KEYWORD=13 +val SCE_MAGIK_PRAGMA=14 +val SCE_MAGIK_SYMBOL=15 +# Lexical state for SCLEX_POWERSHELL +lex PowerShell=SCLEX_POWERSHELL SCE_POWERSHELL_ +val SCE_POWERSHELL_DEFAULT=0 +val SCE_POWERSHELL_COMMENT=1 +val SCE_POWERSHELL_STRING=2 +val SCE_POWERSHELL_CHARACTER=3 +val SCE_POWERSHELL_NUMBER=4 +val SCE_POWERSHELL_VARIABLE=5 +val SCE_POWERSHELL_OPERATOR=6 +val SCE_POWERSHELL_IDENTIFIER=7 +val SCE_POWERSHELL_KEYWORD=8 +val SCE_POWERSHELL_CMDLET=9 +val SCE_POWERSHELL_ALIAS=10 +val SCE_POWERSHELL_FUNCTION=11 +val SCE_POWERSHELL_USER1=12 +val SCE_POWERSHELL_COMMENTSTREAM=13 +val SCE_POWERSHELL_HERE_STRING=14 +val SCE_POWERSHELL_HERE_CHARACTER=15 +val SCE_POWERSHELL_COMMENTDOCKEYWORD=16 +# Lexical state for SCLEX_MYSQL +lex MySQL=SCLEX_MYSQL SCE_MYSQL_ +val SCE_MYSQL_DEFAULT=0 +val SCE_MYSQL_COMMENT=1 +val SCE_MYSQL_COMMENTLINE=2 +val SCE_MYSQL_VARIABLE=3 +val SCE_MYSQL_SYSTEMVARIABLE=4 +val SCE_MYSQL_KNOWNSYSTEMVARIABLE=5 +val SCE_MYSQL_NUMBER=6 +val SCE_MYSQL_MAJORKEYWORD=7 +val SCE_MYSQL_KEYWORD=8 +val SCE_MYSQL_DATABASEOBJECT=9 +val SCE_MYSQL_PROCEDUREKEYWORD=10 +val SCE_MYSQL_STRING=11 +val SCE_MYSQL_SQSTRING=12 +val SCE_MYSQL_DQSTRING=13 +val SCE_MYSQL_OPERATOR=14 +val SCE_MYSQL_FUNCTION=15 +val SCE_MYSQL_IDENTIFIER=16 +val SCE_MYSQL_QUOTEDIDENTIFIER=17 +val SCE_MYSQL_USER1=18 +val SCE_MYSQL_USER2=19 +val SCE_MYSQL_USER3=20 +val SCE_MYSQL_HIDDENCOMMAND=21 +val SCE_MYSQL_PLACEHOLDER=22 +# Lexical state for SCLEX_PO +lex Po=SCLEX_PO SCE_PO_ +val SCE_PO_DEFAULT=0 +val SCE_PO_COMMENT=1 +val SCE_PO_MSGID=2 +val SCE_PO_MSGID_TEXT=3 +val SCE_PO_MSGSTR=4 +val SCE_PO_MSGSTR_TEXT=5 +val SCE_PO_MSGCTXT=6 +val SCE_PO_MSGCTXT_TEXT=7 +val SCE_PO_FUZZY=8 +val SCE_PO_PROGRAMMER_COMMENT=9 +val SCE_PO_REFERENCE=10 +val SCE_PO_FLAGS=11 +val SCE_PO_MSGID_TEXT_EOL=12 +val SCE_PO_MSGSTR_TEXT_EOL=13 +val SCE_PO_MSGCTXT_TEXT_EOL=14 +val SCE_PO_ERROR=15 +# Lexical states for SCLEX_PASCAL +lex Pascal=SCLEX_PASCAL SCE_PAS_ +val SCE_PAS_DEFAULT=0 +val SCE_PAS_IDENTIFIER=1 +val SCE_PAS_COMMENT=2 +val SCE_PAS_COMMENT2=3 +val SCE_PAS_COMMENTLINE=4 +val SCE_PAS_PREPROCESSOR=5 +val SCE_PAS_PREPROCESSOR2=6 +val SCE_PAS_NUMBER=7 +val SCE_PAS_HEXNUMBER=8 +val SCE_PAS_WORD=9 +val SCE_PAS_STRING=10 +val SCE_PAS_STRINGEOL=11 +val SCE_PAS_CHARACTER=12 +val SCE_PAS_OPERATOR=13 +val SCE_PAS_ASM=14 +# Lexical state for SCLEX_SORCUS +lex SORCUS=SCLEX_SORCUS SCE_SORCUS_ +val SCE_SORCUS_DEFAULT=0 +val SCE_SORCUS_COMMAND=1 +val SCE_SORCUS_PARAMETER=2 +val SCE_SORCUS_COMMENTLINE=3 +val SCE_SORCUS_STRING=4 +val SCE_SORCUS_STRINGEOL=5 +val SCE_SORCUS_IDENTIFIER=6 +val SCE_SORCUS_OPERATOR=7 +val SCE_SORCUS_NUMBER=8 +val SCE_SORCUS_CONSTANT=9 +# Lexical state for SCLEX_POWERPRO +lex PowerPro=SCLEX_POWERPRO SCE_POWERPRO_ +val SCE_POWERPRO_DEFAULT=0 +val SCE_POWERPRO_COMMENTBLOCK=1 +val SCE_POWERPRO_COMMENTLINE=2 +val SCE_POWERPRO_NUMBER=3 +val SCE_POWERPRO_WORD=4 +val SCE_POWERPRO_WORD2=5 +val SCE_POWERPRO_WORD3=6 +val SCE_POWERPRO_WORD4=7 +val SCE_POWERPRO_DOUBLEQUOTEDSTRING=8 +val SCE_POWERPRO_SINGLEQUOTEDSTRING=9 +val SCE_POWERPRO_LINECONTINUE=10 +val SCE_POWERPRO_OPERATOR=11 +val SCE_POWERPRO_IDENTIFIER=12 +val SCE_POWERPRO_STRINGEOL=13 +val SCE_POWERPRO_VERBATIM=14 +val SCE_POWERPRO_ALTQUOTE=15 +val SCE_POWERPRO_FUNCTION=16 +# Lexical states for SCLEX_SML +lex SML=SCLEX_SML SCE_SML_ +val SCE_SML_DEFAULT=0 +val SCE_SML_IDENTIFIER=1 +val SCE_SML_TAGNAME=2 +val SCE_SML_KEYWORD=3 +val SCE_SML_KEYWORD2=4 +val SCE_SML_KEYWORD3=5 +val SCE_SML_LINENUM=6 +val SCE_SML_OPERATOR=7 +val SCE_SML_NUMBER=8 +val SCE_SML_CHAR=9 +val SCE_SML_STRING=11 +val SCE_SML_COMMENT=12 +val SCE_SML_COMMENT1=13 +val SCE_SML_COMMENT2=14 +val SCE_SML_COMMENT3=15 +# Lexical state for SCLEX_MARKDOWN +lex Markdown=SCLEX_MARKDOWN SCE_MARKDOWN_ +val SCE_MARKDOWN_DEFAULT=0 +val SCE_MARKDOWN_LINE_BEGIN=1 +val SCE_MARKDOWN_STRONG1=2 +val SCE_MARKDOWN_STRONG2=3 +val SCE_MARKDOWN_EM1=4 +val SCE_MARKDOWN_EM2=5 +val SCE_MARKDOWN_HEADER1=6 +val SCE_MARKDOWN_HEADER2=7 +val SCE_MARKDOWN_HEADER3=8 +val SCE_MARKDOWN_HEADER4=9 +val SCE_MARKDOWN_HEADER5=10 +val SCE_MARKDOWN_HEADER6=11 +val SCE_MARKDOWN_PRECHAR=12 +val SCE_MARKDOWN_ULIST_ITEM=13 +val SCE_MARKDOWN_OLIST_ITEM=14 +val SCE_MARKDOWN_BLOCKQUOTE=15 +val SCE_MARKDOWN_STRIKEOUT=16 +val SCE_MARKDOWN_HRULE=17 +val SCE_MARKDOWN_LINK=18 +val SCE_MARKDOWN_CODE=19 +val SCE_MARKDOWN_CODE2=20 +val SCE_MARKDOWN_CODEBK=21 +# Lexical state for SCLEX_TXT2TAGS +lex Txt2tags=SCLEX_TXT2TAGS SCE_TXT2TAGS_ +val SCE_TXT2TAGS_DEFAULT=0 +val SCE_TXT2TAGS_LINE_BEGIN=1 +val SCE_TXT2TAGS_STRONG1=2 +val SCE_TXT2TAGS_STRONG2=3 +val SCE_TXT2TAGS_EM1=4 +val SCE_TXT2TAGS_EM2=5 +val SCE_TXT2TAGS_HEADER1=6 +val SCE_TXT2TAGS_HEADER2=7 +val SCE_TXT2TAGS_HEADER3=8 +val SCE_TXT2TAGS_HEADER4=9 +val SCE_TXT2TAGS_HEADER5=10 +val SCE_TXT2TAGS_HEADER6=11 +val SCE_TXT2TAGS_PRECHAR=12 +val SCE_TXT2TAGS_ULIST_ITEM=13 +val SCE_TXT2TAGS_OLIST_ITEM=14 +val SCE_TXT2TAGS_BLOCKQUOTE=15 +val SCE_TXT2TAGS_STRIKEOUT=16 +val SCE_TXT2TAGS_HRULE=17 +val SCE_TXT2TAGS_LINK=18 +val SCE_TXT2TAGS_CODE=19 +val SCE_TXT2TAGS_CODE2=20 +val SCE_TXT2TAGS_CODEBK=21 +val SCE_TXT2TAGS_COMMENT=22 +val SCE_TXT2TAGS_OPTION=23 +val SCE_TXT2TAGS_PREPROC=24 +val SCE_TXT2TAGS_POSTPROC=25 +# Lexical states for SCLEX_A68K +lex A68k=SCLEX_A68K SCE_A68K_ +val SCE_A68K_DEFAULT=0 +val SCE_A68K_COMMENT=1 +val SCE_A68K_NUMBER_DEC=2 +val SCE_A68K_NUMBER_BIN=3 +val SCE_A68K_NUMBER_HEX=4 +val SCE_A68K_STRING1=5 +val SCE_A68K_OPERATOR=6 +val SCE_A68K_CPUINSTRUCTION=7 +val SCE_A68K_EXTINSTRUCTION=8 +val SCE_A68K_REGISTER=9 +val SCE_A68K_DIRECTIVE=10 +val SCE_A68K_MACRO_ARG=11 +val SCE_A68K_LABEL=12 +val SCE_A68K_STRING2=13 +val SCE_A68K_IDENTIFIER=14 +val SCE_A68K_MACRO_DECLARATION=15 +val SCE_A68K_COMMENT_WORD=16 +val SCE_A68K_COMMENT_SPECIAL=17 +val SCE_A68K_COMMENT_DOXYGEN=18 +# Lexical states for SCLEX_MODULA +lex Modula=SCLEX_MODULA SCE_MODULA_ +val SCE_MODULA_DEFAULT=0 +val SCE_MODULA_COMMENT=1 +val SCE_MODULA_DOXYCOMM=2 +val SCE_MODULA_DOXYKEY=3 +val SCE_MODULA_KEYWORD=4 +val SCE_MODULA_RESERVED=5 +val SCE_MODULA_NUMBER=6 +val SCE_MODULA_BASENUM=7 +val SCE_MODULA_FLOAT=8 +val SCE_MODULA_STRING=9 +val SCE_MODULA_STRSPEC=10 +val SCE_MODULA_CHAR=11 +val SCE_MODULA_CHARSPEC=12 +val SCE_MODULA_PROC=13 +val SCE_MODULA_PRAGMA=14 +val SCE_MODULA_PRGKEY=15 +val SCE_MODULA_OPERATOR=16 +val SCE_MODULA_BADSTR=17 +# Lexical states for SCLEX_COFFEESCRIPT +lex CoffeeScript=SCLEX_COFFEESCRIPT SCE_COFFEESCRIPT_ +val SCE_COFFEESCRIPT_DEFAULT=0 +val SCE_COFFEESCRIPT_COMMENT=1 +val SCE_COFFEESCRIPT_COMMENTLINE=2 +val SCE_COFFEESCRIPT_COMMENTDOC=3 +val SCE_COFFEESCRIPT_NUMBER=4 +val SCE_COFFEESCRIPT_WORD=5 +val SCE_COFFEESCRIPT_STRING=6 +val SCE_COFFEESCRIPT_CHARACTER=7 +val SCE_COFFEESCRIPT_UUID=8 +val SCE_COFFEESCRIPT_PREPROCESSOR=9 +val SCE_COFFEESCRIPT_OPERATOR=10 +val SCE_COFFEESCRIPT_IDENTIFIER=11 +val SCE_COFFEESCRIPT_STRINGEOL=12 +val SCE_COFFEESCRIPT_VERBATIM=13 +val SCE_COFFEESCRIPT_REGEX=14 +val SCE_COFFEESCRIPT_COMMENTLINEDOC=15 +val SCE_COFFEESCRIPT_WORD2=16 +val SCE_COFFEESCRIPT_COMMENTDOCKEYWORD=17 +val SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR=18 +val SCE_COFFEESCRIPT_GLOBALCLASS=19 +val SCE_COFFEESCRIPT_STRINGRAW=20 +val SCE_COFFEESCRIPT_TRIPLEVERBATIM=21 +val SCE_COFFEESCRIPT_COMMENTBLOCK=22 +val SCE_COFFEESCRIPT_VERBOSE_REGEX=23 +val SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT=24 +val SCE_COFFEESCRIPT_INSTANCEPROPERTY=25 +# Lexical states for SCLEX_AVS +lex AVS=SCLEX_AVS SCE_AVS_ +val SCE_AVS_DEFAULT=0 +val SCE_AVS_COMMENTBLOCK=1 +val SCE_AVS_COMMENTBLOCKN=2 +val SCE_AVS_COMMENTLINE=3 +val SCE_AVS_NUMBER=4 +val SCE_AVS_OPERATOR=5 +val SCE_AVS_IDENTIFIER=6 +val SCE_AVS_STRING=7 +val SCE_AVS_TRIPLESTRING=8 +val SCE_AVS_KEYWORD=9 +val SCE_AVS_FILTER=10 +val SCE_AVS_PLUGIN=11 +val SCE_AVS_FUNCTION=12 +val SCE_AVS_CLIPPROP=13 +val SCE_AVS_USERDFN=14 +# Lexical states for SCLEX_ECL +lex ECL=SCLEX_ECL SCE_ECL_ +val SCE_ECL_DEFAULT=0 +val SCE_ECL_COMMENT=1 +val SCE_ECL_COMMENTLINE=2 +val SCE_ECL_NUMBER=3 +val SCE_ECL_STRING=4 +val SCE_ECL_WORD0=5 +val SCE_ECL_OPERATOR=6 +val SCE_ECL_CHARACTER=7 +val SCE_ECL_UUID=8 +val SCE_ECL_PREPROCESSOR=9 +val SCE_ECL_UNKNOWN=10 +val SCE_ECL_IDENTIFIER=11 +val SCE_ECL_STRINGEOL=12 +val SCE_ECL_VERBATIM=13 +val SCE_ECL_REGEX=14 +val SCE_ECL_COMMENTLINEDOC=15 +val SCE_ECL_WORD1=16 +val SCE_ECL_COMMENTDOCKEYWORD=17 +val SCE_ECL_COMMENTDOCKEYWORDERROR=18 +val SCE_ECL_WORD2=19 +val SCE_ECL_WORD3=20 +val SCE_ECL_WORD4=21 +val SCE_ECL_WORD5=22 +val SCE_ECL_COMMENTDOC=23 +val SCE_ECL_ADDED=24 +val SCE_ECL_DELETED=25 +val SCE_ECL_CHANGED=26 +val SCE_ECL_MOVED=27 +# Lexical states for SCLEX_OSCRIPT +lex OScript=SCLEX_OSCRIPT SCE_OSCRIPT_ +val SCE_OSCRIPT_DEFAULT=0 +val SCE_OSCRIPT_LINE_COMMENT=1 +val SCE_OSCRIPT_BLOCK_COMMENT=2 +val SCE_OSCRIPT_DOC_COMMENT=3 +val SCE_OSCRIPT_PREPROCESSOR=4 +val SCE_OSCRIPT_NUMBER=5 +val SCE_OSCRIPT_SINGLEQUOTE_STRING=6 +val SCE_OSCRIPT_DOUBLEQUOTE_STRING=7 +val SCE_OSCRIPT_CONSTANT=8 +val SCE_OSCRIPT_IDENTIFIER=9 +val SCE_OSCRIPT_GLOBAL=10 +val SCE_OSCRIPT_KEYWORD=11 +val SCE_OSCRIPT_OPERATOR=12 +val SCE_OSCRIPT_LABEL=13 +val SCE_OSCRIPT_TYPE=14 +val SCE_OSCRIPT_FUNCTION=15 +val SCE_OSCRIPT_OBJECT=16 +val SCE_OSCRIPT_PROPERTY=17 +val SCE_OSCRIPT_METHOD=18 +# Lexical states for SCLEX_VISUALPROLOG +lex VisualProlog=SCLEX_VISUALPROLOG SCE_VISUALPROLOG_ +val SCE_VISUALPROLOG_DEFAULT=0 +val SCE_VISUALPROLOG_KEY_MAJOR=1 +val SCE_VISUALPROLOG_KEY_MINOR=2 +val SCE_VISUALPROLOG_KEY_DIRECTIVE=3 +val SCE_VISUALPROLOG_COMMENT_BLOCK=4 +val SCE_VISUALPROLOG_COMMENT_LINE=5 +val SCE_VISUALPROLOG_COMMENT_KEY=6 +val SCE_VISUALPROLOG_COMMENT_KEY_ERROR=7 +val SCE_VISUALPROLOG_IDENTIFIER=8 +val SCE_VISUALPROLOG_VARIABLE=9 +val SCE_VISUALPROLOG_ANONYMOUS=10 +val SCE_VISUALPROLOG_NUMBER=11 +val SCE_VISUALPROLOG_OPERATOR=12 +val SCE_VISUALPROLOG_CHARACTER=13 +val SCE_VISUALPROLOG_CHARACTER_TOO_MANY=14 +val SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR=15 +val SCE_VISUALPROLOG_STRING=16 +val SCE_VISUALPROLOG_STRING_ESCAPE=17 +val SCE_VISUALPROLOG_STRING_ESCAPE_ERROR=18 +val SCE_VISUALPROLOG_STRING_EOL_OPEN=19 +val SCE_VISUALPROLOG_STRING_VERBATIM=20 +val SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL=21 +val SCE_VISUALPROLOG_STRING_VERBATIM_EOL=22 +# Lexical states for SCLEX_STTXT +lex StructuredText=SCLEX_STTXT SCE_STTXT_ +val SCE_STTXT_DEFAULT=0 +val SCE_STTXT_COMMENT=1 +val SCE_STTXT_COMMENTLINE=2 +val SCE_STTXT_KEYWORD=3 +val SCE_STTXT_TYPE=4 +val SCE_STTXT_FUNCTION=5 +val SCE_STTXT_FB=6 +val SCE_STTXT_NUMBER=7 +val SCE_STTXT_HEXNUMBER=8 +val SCE_STTXT_PRAGMA=9 +val SCE_STTXT_OPERATOR=10 +val SCE_STTXT_CHARACTER=11 +val SCE_STTXT_STRING1=12 +val SCE_STTXT_STRING2=13 +val SCE_STTXT_STRINGEOL=14 +val SCE_STTXT_IDENTIFIER=15 +val SCE_STTXT_DATETIME=16 +val SCE_STTXT_VARS=17 +val SCE_STTXT_PRAGMAS=18 +# Lexical states for SCLEX_KVIRC +lex KVIrc=SCLEX_KVIRC SCE_KVIRC_ +val SCE_KVIRC_DEFAULT=0 +val SCE_KVIRC_COMMENT=1 +val SCE_KVIRC_COMMENTBLOCK=2 +val SCE_KVIRC_STRING=3 +val SCE_KVIRC_WORD=4 +val SCE_KVIRC_KEYWORD=5 +val SCE_KVIRC_FUNCTION_KEYWORD=6 +val SCE_KVIRC_FUNCTION=7 +val SCE_KVIRC_VARIABLE=8 +val SCE_KVIRC_NUMBER=9 +val SCE_KVIRC_OPERATOR=10 +val SCE_KVIRC_STRING_FUNCTION=11 +val SCE_KVIRC_STRING_VARIABLE=12 +# Lexical states for SCLEX_RUST +lex Rust=SCLEX_RUST SCE_RUST_ +val SCE_RUST_DEFAULT=0 +val SCE_RUST_COMMENTBLOCK=1 +val SCE_RUST_COMMENTLINE=2 +val SCE_RUST_COMMENTBLOCKDOC=3 +val SCE_RUST_COMMENTLINEDOC=4 +val SCE_RUST_NUMBER=5 +val SCE_RUST_WORD=6 +val SCE_RUST_WORD2=7 +val SCE_RUST_WORD3=8 +val SCE_RUST_WORD4=9 +val SCE_RUST_WORD5=10 +val SCE_RUST_WORD6=11 +val SCE_RUST_WORD7=12 +val SCE_RUST_STRING=13 +val SCE_RUST_STRINGR=14 +val SCE_RUST_CHARACTER=15 +val SCE_RUST_OPERATOR=16 +val SCE_RUST_IDENTIFIER=17 +val SCE_RUST_LIFETIME=18 +val SCE_RUST_MACRO=19 +val SCE_RUST_LEXERROR=20 +val SCE_RUST_BYTESTRING=21 +val SCE_RUST_BYTESTRINGR=22 +val SCE_RUST_BYTECHARACTER=23 +# Lexical states for SCLEX_DMAP +lex DMAP=SCLEX_DMAP SCE_DMAP_ +val SCE_DMAP_DEFAULT=0 +val SCE_DMAP_COMMENT=1 +val SCE_DMAP_NUMBER=2 +val SCE_DMAP_STRING1=3 +val SCE_DMAP_STRING2=4 +val SCE_DMAP_STRINGEOL=5 +val SCE_DMAP_OPERATOR=6 +val SCE_DMAP_IDENTIFIER=7 +val SCE_DMAP_WORD=8 +val SCE_DMAP_WORD2=9 +val SCE_DMAP_WORD3=10 +# Lexical states for SCLEX_DMIS +lex DMIS=SCLEX_DMIS SCE_DMIS_ +val SCE_DMIS_DEFAULT=0 +val SCE_DMIS_COMMENT=1 +val SCE_DMIS_STRING=2 +val SCE_DMIS_NUMBER=3 +val SCE_DMIS_KEYWORD=4 +val SCE_DMIS_MAJORWORD=5 +val SCE_DMIS_MINORWORD=6 +val SCE_DMIS_UNSUPPORTED_MAJOR=7 +val SCE_DMIS_UNSUPPORTED_MINOR=8 +val SCE_DMIS_LABEL=9 +# Lexical states for SCLEX_REGISTRY +lex REG=SCLEX_REGISTRY SCE_REG_ +val SCE_REG_DEFAULT=0 +val SCE_REG_COMMENT=1 +val SCE_REG_VALUENAME=2 +val SCE_REG_STRING=3 +val SCE_REG_HEXDIGIT=4 +val SCE_REG_VALUETYPE=5 +val SCE_REG_ADDEDKEY=6 +val SCE_REG_DELETEDKEY=7 +val SCE_REG_ESCAPED=8 +val SCE_REG_KEYPATH_GUID=9 +val SCE_REG_STRING_GUID=10 +val SCE_REG_PARAMETER=11 +val SCE_REG_OPERATOR=12 +# Lexical state for SCLEX_BIBTEX +lex BibTeX=SCLEX_BIBTEX SCE_BIBTEX_ +val SCE_BIBTEX_DEFAULT=0 +val SCE_BIBTEX_ENTRY=1 +val SCE_BIBTEX_UNKNOWN_ENTRY=2 +val SCE_BIBTEX_KEY=3 +val SCE_BIBTEX_PARAMETER=4 +val SCE_BIBTEX_VALUE=5 +val SCE_BIBTEX_COMMENT=6 +# Lexical state for SCLEX_SREC +lex Srec=SCLEX_SREC SCE_HEX_ +val SCE_HEX_DEFAULT=0 +val SCE_HEX_RECSTART=1 +val SCE_HEX_RECTYPE=2 +val SCE_HEX_RECTYPE_UNKNOWN=3 +val SCE_HEX_BYTECOUNT=4 +val SCE_HEX_BYTECOUNT_WRONG=5 +val SCE_HEX_NOADDRESS=6 +val SCE_HEX_DATAADDRESS=7 +val SCE_HEX_RECCOUNT=8 +val SCE_HEX_STARTADDRESS=9 +val SCE_HEX_ADDRESSFIELD_UNKNOWN=10 +val SCE_HEX_EXTENDEDADDRESS=11 +val SCE_HEX_DATA_ODD=12 +val SCE_HEX_DATA_EVEN=13 +val SCE_HEX_DATA_UNKNOWN=14 +val SCE_HEX_DATA_EMPTY=15 +val SCE_HEX_CHECKSUM=16 +val SCE_HEX_CHECKSUM_WRONG=17 +val SCE_HEX_GARBAGE=18 +# Lexical state for SCLEX_IHEX (shared with Srec) +lex IHex=SCLEX_IHEX SCE_HEX_ +# Lexical state for SCLEX_TEHEX (shared with Srec) +lex TEHex=SCLEX_TEHEX SCE_HEX_ +# Lexical states for SCLEX_JSON +lex JSON=SCLEX_JSON SCE_JSON_ +val SCE_JSON_DEFAULT=0 +val SCE_JSON_NUMBER=1 +val SCE_JSON_STRING=2 +val SCE_JSON_STRINGEOL=3 +val SCE_JSON_PROPERTYNAME=4 +val SCE_JSON_ESCAPESEQUENCE=5 +val SCE_JSON_LINECOMMENT=6 +val SCE_JSON_BLOCKCOMMENT=7 +val SCE_JSON_OPERATOR=8 +val SCE_JSON_URI=9 +val SCE_JSON_COMPACTIRI=10 +val SCE_JSON_KEYWORD=11 +val SCE_JSON_LDKEYWORD=12 +val SCE_JSON_ERROR=13 +lex EDIFACT=SCLEX_EDIFACT SCE_EDI_ +val SCE_EDI_DEFAULT=0 +val SCE_EDI_SEGMENTSTART=1 +val SCE_EDI_SEGMENTEND=2 +val SCE_EDI_SEP_ELEMENT=3 +val SCE_EDI_SEP_COMPOSITE=4 +val SCE_EDI_SEP_RELEASE=5 +val SCE_EDI_UNA=6 +val SCE_EDI_UNH=7 +val SCE_EDI_BADSEGMENT=8 +# Lexical states for SCLEX_STATA +lex STATA=SCLEX_STATA SCE_STATA_ +val SCE_STATA_DEFAULT=0 +val SCE_STATA_COMMENT=1 +val SCE_STATA_COMMENTLINE=2 +val SCE_STATA_COMMENTBLOCK=3 +val SCE_STATA_NUMBER=4 +val SCE_STATA_OPERATOR=5 +val SCE_STATA_IDENTIFIER=6 +val SCE_STATA_STRING=7 +val SCE_STATA_TYPE=8 +val SCE_STATA_WORD=9 +val SCE_STATA_GLOBAL_MACRO=10 +val SCE_STATA_MACRO=11 +# Lexical states for SCLEX_SAS +lex SAS=SCLEX_SAS SCE_SAS_ +val SCE_SAS_DEFAULT=0 +val SCE_SAS_COMMENT=1 +val SCE_SAS_COMMENTLINE=2 +val SCE_SAS_COMMENTBLOCK=3 +val SCE_SAS_NUMBER=4 +val SCE_SAS_OPERATOR=5 +val SCE_SAS_IDENTIFIER=6 +val SCE_SAS_STRING=7 +val SCE_SAS_TYPE=8 +val SCE_SAS_WORD=9 +val SCE_SAS_GLOBAL_MACRO=10 +val SCE_SAS_MACRO=11 +val SCE_SAS_MACRO_KEYWORD=12 +val SCE_SAS_BLOCK_KEYWORD=13 +val SCE_SAS_MACRO_FUNCTION=14 +val SCE_SAS_STATEMENT=15 +# Lexical states for SCLEX_NIM +lex Nim=SCLEX_NIM SCE_NIM_ +val SCE_NIM_DEFAULT=0 +val SCE_NIM_COMMENT=1 +val SCE_NIM_COMMENTDOC=2 +val SCE_NIM_COMMENTLINE=3 +val SCE_NIM_COMMENTLINEDOC=4 +val SCE_NIM_NUMBER=5 +val SCE_NIM_STRING=6 +val SCE_NIM_CHARACTER=7 +val SCE_NIM_WORD=8 +val SCE_NIM_TRIPLE=9 +val SCE_NIM_TRIPLEDOUBLE=10 +val SCE_NIM_BACKTICKS=11 +val SCE_NIM_FUNCNAME=12 +val SCE_NIM_STRINGEOL=13 +val SCE_NIM_NUMERROR=14 +val SCE_NIM_OPERATOR=15 +val SCE_NIM_IDENTIFIER=16 +# Lexical states for SCLEX_CIL +lex CIL=SCLEX_CIL SCE_CIL_ +val SCE_CIL_DEFAULT=0 +val SCE_CIL_COMMENT=1 +val SCE_CIL_COMMENTLINE=2 +val SCE_CIL_WORD=3 +val SCE_CIL_WORD2=4 +val SCE_CIL_WORD3=5 +val SCE_CIL_STRING=6 +val SCE_CIL_LABEL=7 +val SCE_CIL_OPERATOR=8 +val SCE_CIL_IDENTIFIER=9 +val SCE_CIL_STRINGEOL=10 +# Lexical states for SCLEX_X12 +lex X12=SCLEX_X12 SCE_X12_ +val SCE_X12_DEFAULT=0 +val SCE_X12_BAD=1 +val SCE_X12_ENVELOPE=2 +val SCE_X12_FUNCTIONGROUP=3 +val SCE_X12_TRANSACTIONSET=4 +val SCE_X12_SEGMENTHEADER=5 +val SCE_X12_SEGMENTEND=6 +val SCE_X12_SEP_ELEMENT=7 +val SCE_X12_SEP_SUBELEMENT=8 +# Lexical states for SCLEX_DATAFLEX +lex Dataflex=SCLEX_DATAFLEX SCE_DF_ +val SCE_DF_DEFAULT=0 +val SCE_DF_IDENTIFIER=1 +val SCE_DF_METATAG=2 +val SCE_DF_IMAGE=3 +val SCE_DF_COMMENTLINE=4 +val SCE_DF_PREPROCESSOR=5 +val SCE_DF_PREPROCESSOR2=6 +val SCE_DF_NUMBER=7 +val SCE_DF_HEXNUMBER=8 +val SCE_DF_WORD=9 +val SCE_DF_STRING=10 +val SCE_DF_STRINGEOL=11 +val SCE_DF_SCOPEWORD=12 +val SCE_DF_OPERATOR=13 +val SCE_DF_ICODE=14 +# Lexical states for SCLEX_HOLLYWOOD +lex Hollywood=SCLEX_HOLLYWOOD SCE_HOLLYWOOD_ +val SCE_HOLLYWOOD_DEFAULT=0 +val SCE_HOLLYWOOD_COMMENT=1 +val SCE_HOLLYWOOD_COMMENTBLOCK=2 +val SCE_HOLLYWOOD_NUMBER=3 +val SCE_HOLLYWOOD_KEYWORD=4 +val SCE_HOLLYWOOD_STDAPI=5 +val SCE_HOLLYWOOD_PLUGINAPI=6 +val SCE_HOLLYWOOD_PLUGINMETHOD=7 +val SCE_HOLLYWOOD_STRING=8 +val SCE_HOLLYWOOD_STRINGBLOCK=9 +val SCE_HOLLYWOOD_PREPROCESSOR=10 +val SCE_HOLLYWOOD_OPERATOR=11 +val SCE_HOLLYWOOD_IDENTIFIER=12 +val SCE_HOLLYWOOD_CONSTANT=13 +val SCE_HOLLYWOOD_HEXNUMBER=14 +# Lexical states for SCLEX_RAKU +lex Raku=SCLEX_RAKU SCE_RAKU_ +val SCE_RAKU_DEFAULT=0 +val SCE_RAKU_ERROR=1 +val SCE_RAKU_COMMENTLINE=2 +val SCE_RAKU_COMMENTEMBED=3 +val SCE_RAKU_POD=4 +val SCE_RAKU_CHARACTER=5 +val SCE_RAKU_HEREDOC_Q=6 +val SCE_RAKU_HEREDOC_QQ=7 +val SCE_RAKU_STRING=8 +val SCE_RAKU_STRING_Q=9 +val SCE_RAKU_STRING_QQ=10 +val SCE_RAKU_STRING_Q_LANG=11 +val SCE_RAKU_STRING_VAR=12 +val SCE_RAKU_REGEX=13 +val SCE_RAKU_REGEX_VAR=14 +val SCE_RAKU_ADVERB=15 +val SCE_RAKU_NUMBER=16 +val SCE_RAKU_PREPROCESSOR=17 +val SCE_RAKU_OPERATOR=18 +val SCE_RAKU_WORD=19 +val SCE_RAKU_FUNCTION=20 +val SCE_RAKU_IDENTIFIER=21 +val SCE_RAKU_TYPEDEF=22 +val SCE_RAKU_MU=23 +val SCE_RAKU_POSITIONAL=24 +val SCE_RAKU_ASSOCIATIVE=25 +val SCE_RAKU_CALLABLE=26 +val SCE_RAKU_GRAMMAR=27 +val SCE_RAKU_CLASS=28 + +# Events + +evt void StyleNeeded=2000(int position) +evt void CharAdded=2001(int ch, int characterSource) +evt void SavePointReached=2002(void) +evt void SavePointLeft=2003(void) +evt void ModifyAttemptRO=2004(void) +# GTK Specific to work around focus and accelerator problems: +evt void Key=2005(int ch, int modifiers) +evt void DoubleClick=2006(int modifiers, int position, int line) +evt void UpdateUI=2007(int updated) +evt void Modified=2008(int position, int modificationType, string text, int length, int linesAdded, int line, int foldLevelNow, int foldLevelPrev, int token, int annotationLinesAdded) +evt void MacroRecord=2009(int message, int wParam, int lParam) +evt void MarginClick=2010(int modifiers, int position, int margin) +evt void NeedShown=2011(int position, int length) +evt void Painted=2013(void) +evt void UserListSelection=2014(int listType, string text, int position, int ch, CompletionMethods listCompletionMethod) +evt void URIDropped=2015(string text) +evt void DwellStart=2016(int position, int x, int y) +evt void DwellEnd=2017(int position, int x, int y) +evt void Zoom=2018(void) +evt void HotSpotClick=2019(int modifiers, int position) +evt void HotSpotDoubleClick=2020(int modifiers, int position) +evt void CallTipClick=2021(int position) +evt void AutoCSelection=2022(string text, int position, int ch, CompletionMethods listCompletionMethod) +evt void IndicatorClick=2023(int modifiers, int position) +evt void IndicatorRelease=2024(int modifiers, int position) +evt void AutoCCancelled=2025(void) +evt void AutoCCharDeleted=2026(void) +evt void HotSpotReleaseClick=2027(int modifiers, int position) +evt void FocusIn=2028(void) +evt void FocusOut=2029(void) +evt void AutoCCompleted=2030(string text, int position, int ch, CompletionMethods listCompletionMethod) +evt void MarginRightClick=2031(int modifiers, int position, int margin) +evt void AutoCSelectionChange=2032(int listType, string text, int position) + +cat Provisional + +enu Bidirectional=SC_BIDIRECTIONAL_ +val SC_BIDIRECTIONAL_DISABLED=0 +val SC_BIDIRECTIONAL_L2R=1 +val SC_BIDIRECTIONAL_R2L=2 + +# Retrieve bidirectional text display state. +get Bidirectional GetBidirectional=2708(,) + +# Set bidirectional text display state. +set void SetBidirectional=2709(Bidirectional bidirectional,) + +enu LineCharacterIndexType=SC_LINECHARACTERINDEX_ +val SC_LINECHARACTERINDEX_NONE=0 +val SC_LINECHARACTERINDEX_UTF32=1 +val SC_LINECHARACTERINDEX_UTF16=2 + +# Retrieve line character index state. +get LineCharacterIndexType GetLineCharacterIndex=2710(,) + +# Request line character index be created or its use count increased. +fun void AllocateLineCharacterIndex=2711(LineCharacterIndexType lineCharacterIndex,) + +# Decrease use count of line character index and remove if 0. +fun void ReleaseLineCharacterIndex=2712(LineCharacterIndexType lineCharacterIndex,) + +# Retrieve the document line containing a position measured in index units. +fun line LineFromIndexPosition=2713(position pos, LineCharacterIndexType lineCharacterIndex) + +# Retrieve the position measured in index units at the start of a document line. +fun position IndexPositionFromLine=2714(line line, LineCharacterIndexType lineCharacterIndex) + +cat Deprecated + +# 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. +set void SetStyleBits=2090(int bits,) + +# Retrieve number of bits in style bytes used to hold the lexical state. +get int GetStyleBits=2091(,) + +# Retrieve the number of bits the current lexer needs for styling. +get int GetStyleBitsNeeded=4011(,) + +# Deprecated in 3.5.5 + +# Always interpret keyboard input as Unicode +set void SetKeysUnicode=2521(bool keysUnicode,) + +# Are keys always interpreted as Unicode? +get bool GetKeysUnicode=2522(,) + +# Is drawing done in two phases with backgrounds drawn before foregrounds? +get bool GetTwoPhaseDraw=2283(,) + +# In twoPhaseDraw mode, drawing is performed in two phases, first the background +# and then the foreground. This avoids chopping off characters that overlap the next run. +set void SetTwoPhaseDraw=2284(bool twoPhase,) + +val INDIC0_MASK=0x20 +val INDIC1_MASK=0x40 +val INDIC2_MASK=0x80 +val INDICS_MASK=0xE0 diff --git a/Pythonwin/Scintilla/include/ScintillaWidget.h b/Pythonwin/Scintilla/include/ScintillaWidget.h new file mode 100644 index 000000000..1721f65d9 --- /dev/null +++ b/Pythonwin/Scintilla/include/ScintillaWidget.h @@ -0,0 +1,72 @@ +/* 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. + * This comment is not a doc-comment as that causes warnings from g-ir-scanner. + */ +/* 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 ()) + +#define SCINTILLA_TYPE_OBJECT (scintilla_object_get_type()) +#define SCINTILLA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SCINTILLA_TYPE_OBJECT, ScintillaObject)) +#define SCINTILLA_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCINTILLA_TYPE_OBJECT)) +#define SCINTILLA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SCINTILLA_TYPE_OBJECT, ScintillaObjectClass)) +#define SCINTILLA_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SCINTILLA_TYPE_OBJECT)) +#define SCINTILLA_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), SCINTILLA_TYPE_OBJECT, ScintillaObjectClass)) + +typedef struct _ScintillaObject ScintillaObject; +typedef struct _ScintillaClass ScintillaObjectClass; + +struct _ScintillaObject { + GtkContainer cont; + void *pscin; +}; + +struct _ScintillaClass { + GtkContainerClass parent_class; + + void (* command) (ScintillaObject *sci, int cmd, GtkWidget *window); + void (* notify) (ScintillaObject *sci, int id, SCNotification *scn); +}; + +GType scintilla_object_get_type (void); +GtkWidget* scintilla_object_new (void); +gintptr scintilla_object_send_message (ScintillaObject *sci, unsigned int iMessage, guintptr wParam, gintptr lParam); + + +GType scnotification_get_type (void); +#define SCINTILLA_TYPE_NOTIFICATION (scnotification_get_type()) + +#ifndef G_IR_SCANNING +/* The legacy names confuse the g-ir-scanner program */ +typedef struct _ScintillaClass ScintillaClass; + +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); +#endif + +#define SCINTILLA_NOTIFY "sci-notify" + +#ifdef __cplusplus +} +#endif + +#endif + +#endif diff --git a/Pythonwin/Scintilla/include/WinDefs.h b/Pythonwin/Scintilla/include/WinDefs.h deleted file mode 100644 index bab41662e..000000000 --- a/Pythonwin/Scintilla/include/WinDefs.h +++ /dev/null @@ -1,185 +0,0 @@ -// Scintilla source code edit control -/** @file WinDefs.h - ** The subset of definitions from Windows needed by Scintilla for GTK+. - **/ -// Copyright 1998-2001 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef WINDEFS_H -#define WINDEFS_H - -#define WORD short -#define WPARAM unsigned long -#define LPARAM long -#define LRESULT long -#define DWORD long - -#define UINT unsigned int -#define LPSTR char * -#define LONG long - -//#if 0 -/* RTF control */ -#define EM_CANPASTE (1074) -#define EM_CANUNDO (198) -#define EM_CHARFROMPOS (215) -#define EM_EMPTYUNDOBUFFER (205) -#define EM_EXGETSEL (1076) -#define EM_EXLINEFROMCHAR (1078) -#define EM_EXSETSEL (1079) -#define EM_FINDTEXT (1080) -#define EM_FINDTEXTEX (1103) -#define EM_FORMATRANGE (1081) -#define EM_GETFIRSTVISIBLELINE (206) -#define EM_GETLINE (196) -#define EM_GETLINECOUNT (186) -#define EM_GETMARGINS (212) -#define EM_GETMODIFY (184) -#define EM_GETRECT (178) -#define EM_GETSEL (176) -#define EM_GETSELTEXT (1086) -#define EM_GETTEXTRANGE (1099) -#define EM_HIDESELECTION (1087) -#define EM_LINEFROMCHAR (201) -#define EM_LINEINDEX (187) -#define EM_LINELENGTH (193) -#define EM_LINESCROLL (182) -#define EM_POSFROMCHAR (214) -#define EM_REPLACESEL (194) -#define EM_SCROLLCARET (183) -#define EM_SELECTIONTYPE (1090) -#define EM_SETMARGINS (211) -#define EM_SETREADONLY (207) -#define EM_SETSEL (177) -#define EM_UNDO (199) - -#define WM_NULL (0) -#define WM_CLEAR (771) -#define WM_COPY (769) -#define WM_CUT (768) -#define WM_GETTEXT (13) -#define WM_GETTEXTLENGTH (14) -#define WM_PASTE (770) -#define WM_SETTEXT (12) -#define WM_UNDO (772) - -#define EN_CHANGE (768) -#define EN_KILLFOCUS (512) -#define EN_SETFOCUS (256) - -#define EC_LEFTMARGIN 1 -#define EC_RIGHTMARGIN 2 -#define EC_USEFONTINFO 0xffff - -//#endif - -#if 0 -#if PLAT_GTK -#define VK_DOWN GDK_Down -#define VK_UP GDK_Up -#define VK_LEFT GDK_Left -#define VK_RIGHT GDK_Right -#define VK_HOME GDK_Home -#define VK_END GDK_End -#define VK_PRIOR GDK_Page_Up -#define VK_NEXT GDK_Page_Down -#define VK_DELETE GDK_Delete -#define VK_INSERT GDK_Insert -#define VK_ESCAPE GDK_Escape -#define VK_BACK GDK_BackSpace -#define VK_TAB GDK_Tab -#define VK_RETURN GDK_Return -#define VK_ADD GDK_KP_Add -#define VK_SUBTRACT GDK_KP_Subtract -#define VK_DIVIDE GDK_KP_Divide -#endif - -#if PLAT_WX -#define VK_DOWN WXK_DOWN -#define VK_UP WXK_UP -#define VK_LEFT WXK_LEFT -#define VK_RIGHT WXK_RIGHT -#define VK_HOME WXK_HOME -#define VK_END WXK_END -#define VK_PRIOR WXK_PRIOR -#define VK_NEXT WXK_NEXT -#define VK_DELETE WXK_DELETE -#define VK_INSERT WXK_INSERT -#define VK_ESCAPE WXK_ESCAPE -#define VK_BACK WXK_BACK -#define VK_TAB WXK_TAB -#define VK_RETURN WXK_RETURN -#define VK_ADD WXK_ADD -#define VK_SUBTRACT WXK_SUBTRACT -//TODO: -#define VK_DIVIDE WXK_DIVIDE -#endif - -#define SHIFT_PRESSED 1 -#define LEFT_CTRL_PRESSED 2 -#define LEFT_ALT_PRESSED 4 - -// Are these needed any more -#define LPSTR char * -#define LONG long -#define LPDWORD (long *) - -/* SELCHANGE structure */ -#define SEL_EMPTY (0) -#define SEL_TEXT (1) -#define SEL_OBJECT (2) -#define SEL_MULTICHAR (4) -#define SEL_MULTIOBJECT (8) - -struct RECT { - LONG left; - LONG top; - LONG right; - LONG bottom; -}; - -/* FINDREPLACE structure */ - -#define FR_MATCHCASE (0x4) -#define FR_WHOLEWORD (0x2) -#define FR_DOWN (0x1) - -#endif - -#if 0 -struct CHARRANGE { - LONG cpMin; - LONG cpMax; -}; - -struct TEXTRANGE { - CHARRANGE chrg; - LPSTR lpstrText; -}; - -struct FINDTEXTEX { - CHARRANGE chrg; - LPSTR lpstrText; - CHARRANGE chrgText; -}; - -struct NMHDR { - WindowID hwndFrom; - UINT idFrom; - UINT code; -}; - -struct FORMATRANGE { - SurfaceID hdc; - SurfaceID hdcTarget; - RECT rc; - RECT rcPage; - CHARRANGE chrg; -}; -#endif - -//#define MAKELONG(a, b) ((a) | ((b) << 16)) -//#define LOWORD(x) (x & 0xffff) -//#define HIWORD(x) (x >> 16) - -#endif diff --git a/Pythonwin/Scintilla/include/WindowAccessor.h b/Pythonwin/Scintilla/include/WindowAccessor.h deleted file mode 100644 index e107a0659..000000000 --- a/Pythonwin/Scintilla/include/WindowAccessor.h +++ /dev/null @@ -1,66 +0,0 @@ -// Scintilla source code edit control -/** @file WindowAccessor.h - ** Implementation of BufferAccess and StylingAccess on a Scintilla - ** rapid easy access to contents of a Scintilla. - **/ -// Copyright 1998-2001 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -/** - */ -class WindowAccessor : public Accessor { - // Private so WindowAccessor objects can not be copied - WindowAccessor(const WindowAccessor &source) : Accessor(), props(source.props) {} - WindowAccessor &operator=(const WindowAccessor &) { return *this; } -protected: - WindowID id; - PropSet &props; - int lenDoc; - - char styleBuf[bufferSize]; - int validLen; - char chFlags; - char chWhile; - unsigned int startSeg; - - bool InternalIsLeadByte(char ch); - void Fill(int position); -public: - WindowAccessor(WindowID id_, PropSet &props_) : - Accessor(), id(id_), props(props_), - lenDoc(-1), validLen(0), chFlags(0), chWhile(0) { - } - ~WindowAccessor(); - bool Match(int pos, const char *s); - char StyleAt(int position); - int GetLine(int position); - int LineStart(int line); - int LevelAt(int line); - int Length(); - void Flush(); - int GetLineState(int line); - int SetLineState(int line, int state); - int GetPropertyInt(const char *key, int defaultValue=0) { - return props.GetInt(key, defaultValue); - } - char *GetProperties() { - return props.ToString(); - } - - void StartAt(unsigned int start, char chMask=31); - void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; - unsigned int GetStartSegment() { return startSeg; } - void StartSegment(unsigned int pos); - void ColourTo(unsigned int pos, int chAttr); - void SetLevel(int line, int level); - int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0); - void IndicatorFill(int start, int end, int indicator, int value); -}; - -#ifdef SCI_NAMESPACE -} -#endif diff --git a/Pythonwin/Scintilla/lexers/LexA68k.cxx b/Pythonwin/Scintilla/lexers/LexA68k.cxx new file mode 100644 index 000000000..1475ad078 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexA68k.cxx @@ -0,0 +1,345 @@ +// Scintilla source code edit control +/** @file LexA68k.cxx + ** Lexer for Assembler, just for the MASM syntax + ** Written by Martial Demolins AKA Folco + **/ +// Copyright 2010 Martial Demolins +// 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" + +using namespace Scintilla; + + +// Return values for GetOperatorType +#define NO_OPERATOR 0 +#define OPERATOR_1CHAR 1 +#define OPERATOR_2CHAR 2 + + +/** + * IsIdentifierStart + * + * Return true if the given char is a valid identifier first char + */ + +static inline bool IsIdentifierStart (const int ch) +{ + return (isalpha(ch) || (ch == '_') || (ch == '\\')); +} + + +/** + * IsIdentifierChar + * + * Return true if the given char is a valid identifier char + */ + +static inline bool IsIdentifierChar (const int ch) +{ + return (isalnum(ch) || (ch == '_') || (ch == '@') || (ch == ':') || (ch == '.')); +} + + +/** + * GetOperatorType + * + * Return: + * NO_OPERATOR if char is not an operator + * OPERATOR_1CHAR if the operator is one char long + * OPERATOR_2CHAR if the operator is two chars long + */ + +static inline int GetOperatorType (const int ch1, const int ch2) +{ + int OpType = NO_OPERATOR; + + if ((ch1 == '+') || (ch1 == '-') || (ch1 == '*') || (ch1 == '/') || (ch1 == '#') || + (ch1 == '(') || (ch1 == ')') || (ch1 == '~') || (ch1 == '&') || (ch1 == '|') || (ch1 == ',')) + OpType = OPERATOR_1CHAR; + + else if ((ch1 == ch2) && (ch1 == '<' || ch1 == '>')) + OpType = OPERATOR_2CHAR; + + return OpType; +} + + +/** + * IsBin + * + * Return true if the given char is 0 or 1 + */ + +static inline bool IsBin (const int ch) +{ + return (ch == '0') || (ch == '1'); +} + + +/** + * IsDoxygenChar + * + * Return true if the char may be part of a Doxygen keyword + */ + +static inline bool IsDoxygenChar (const int ch) +{ + return isalpha(ch) || (ch == '$') || (ch == '[') || (ch == ']') || (ch == '{') || (ch == '}'); +} + + +/** + * ColouriseA68kDoc + * + * Main function, which colourises a 68k source + */ + +static void ColouriseA68kDoc (Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) +{ + // Used to buffer a string, to be able to compare it using built-in functions + char Buffer[100]; + + + // Used to know the length of an operator + int OpType; + + + // Get references to keywords lists + WordList &cpuInstruction = *keywordlists[0]; + WordList ®isters = *keywordlists[1]; + WordList &directive = *keywordlists[2]; + WordList &extInstruction = *keywordlists[3]; + WordList &alert = *keywordlists[4]; + WordList &doxygenKeyword = *keywordlists[5]; + + + // Instanciate a context for our source + StyleContext sc(startPos, length, initStyle, styler); + + + /************************************************************ + * + * Parse the source + * + ************************************************************/ + + for ( ; sc.More(); sc.Forward()) + { + /************************************************************ + * + * A style always terminates at the end of a line, even for + * comments (no multi-lines comments) + * + ************************************************************/ + if (sc.atLineStart) { + sc.SetState(SCE_A68K_DEFAULT); + } + + + /************************************************************ + * + * If we are not in "default style", check if the style continues + * In this case, we just have to loop + * + ************************************************************/ + + if (sc.state != SCE_A68K_DEFAULT) + { + if ( ((sc.state == SCE_A68K_NUMBER_DEC) && isdigit(sc.ch)) // Decimal number + || ((sc.state == SCE_A68K_NUMBER_BIN) && IsBin(sc.ch)) // Binary number + || ((sc.state == SCE_A68K_NUMBER_HEX) && isxdigit(sc.ch)) // Hexa number + || ((sc.state == SCE_A68K_MACRO_ARG) && isdigit(sc.ch)) // Macro argument + || ((sc.state == SCE_A68K_STRING1) && (sc.ch != '\'')) // String single-quoted + || ((sc.state == SCE_A68K_STRING2) && (sc.ch != '\"')) // String double-quoted + || ((sc.state == SCE_A68K_MACRO_DECLARATION) && IsIdentifierChar(sc.ch)) // Macro declaration (or global label, we don't know at this point) + || ((sc.state == SCE_A68K_IDENTIFIER) && IsIdentifierChar(sc.ch)) // Identifier + || ((sc.state == SCE_A68K_LABEL) && IsIdentifierChar(sc.ch)) // Label (local) + || ((sc.state == SCE_A68K_COMMENT_DOXYGEN) && IsDoxygenChar(sc.ch)) // Doxygen keyword + || ((sc.state == SCE_A68K_COMMENT_SPECIAL) && isalpha(sc.ch)) // Alert + || ((sc.state == SCE_A68K_COMMENT) && !isalpha(sc.ch) && (sc.ch != '\\'))) // Normal comment + { + continue; + } + + /************************************************************ + * + * Check if current state terminates + * + ************************************************************/ + + // Strings: include terminal ' or " in the current string by skipping it + if ((sc.state == SCE_A68K_STRING1) || (sc.state == SCE_A68K_STRING2)) { + sc.Forward(); + } + + + // If a macro declaration was terminated with ':', it was a label + else if ((sc.state == SCE_A68K_MACRO_DECLARATION) && (sc.chPrev == ':')) { + sc.ChangeState(SCE_A68K_LABEL); + } + + + // If it wasn't a Doxygen keyword, change it to normal comment + else if (sc.state == SCE_A68K_COMMENT_DOXYGEN) { + sc.GetCurrent(Buffer, sizeof(Buffer)); + if (!doxygenKeyword.InList(Buffer)) { + sc.ChangeState(SCE_A68K_COMMENT); + } + sc.SetState(SCE_A68K_COMMENT); + continue; + } + + + // If it wasn't an Alert, change it to normal comment + else if (sc.state == SCE_A68K_COMMENT_SPECIAL) { + sc.GetCurrent(Buffer, sizeof(Buffer)); + if (!alert.InList(Buffer)) { + sc.ChangeState(SCE_A68K_COMMENT); + } + // Reset style to normal comment, or to Doxygen keyword if it begins with '\' + if (sc.ch == '\\') { + sc.SetState(SCE_A68K_COMMENT_DOXYGEN); + } + else { + sc.SetState(SCE_A68K_COMMENT); + } + continue; + } + + + // If we are in a comment, it's a Doxygen keyword or an Alert + else if (sc.state == SCE_A68K_COMMENT) { + if (sc.ch == '\\') { + sc.SetState(SCE_A68K_COMMENT_DOXYGEN); + } + else { + sc.SetState(SCE_A68K_COMMENT_SPECIAL); + } + continue; + } + + + // Check if we are at the end of an identifier + // In this case, colourise it if was a keyword. + else if ((sc.state == SCE_A68K_IDENTIFIER) && !IsIdentifierChar(sc.ch)) { + sc.GetCurrentLowered(Buffer, sizeof(Buffer)); // Buffer the string of the current context + if (cpuInstruction.InList(Buffer)) { // And check if it belongs to a keyword list + sc.ChangeState(SCE_A68K_CPUINSTRUCTION); + } + else if (extInstruction.InList(Buffer)) { + sc.ChangeState(SCE_A68K_EXTINSTRUCTION); + } + else if (registers.InList(Buffer)) { + sc.ChangeState(SCE_A68K_REGISTER); + } + else if (directive.InList(Buffer)) { + sc.ChangeState(SCE_A68K_DIRECTIVE); + } + } + + // All special contexts are now handled.Come back to default style + sc.SetState(SCE_A68K_DEFAULT); + } + + + /************************************************************ + * + * Check if we must enter a new state + * + ************************************************************/ + + // Something which begins at the beginning of a line, and with + // - '\' + an identifier start char, or + // - '\\@' + an identifier start char + // is a local label (second case is used for macro local labels). We set it already as a label, it can't be a macro/equ declaration + if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.chNext) && (sc.ch == '\\')) { + sc.SetState(SCE_A68K_LABEL); + } + + if (sc.atLineStart && (sc.ch < 0x80) && (sc.ch == '\\') && (sc.chNext == '\\')) { + sc.Forward(2); + if ((sc.ch == '@') && IsIdentifierStart(sc.chNext)) { + sc.ChangeState(SCE_A68K_LABEL); + sc.SetState(SCE_A68K_LABEL); + } + } + + // Label and macro identifiers start at the beginning of a line + // We set both as a macro id, but if it wasn't one (':' at the end), + // it will be changed as a label. + if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.ch)) { + sc.SetState(SCE_A68K_MACRO_DECLARATION); + } + else if ((sc.ch < 0x80) && (sc.ch == ';')) { // Default: alert in a comment. If it doesn't match + sc.SetState(SCE_A68K_COMMENT); // with an alert, it will be toggle to a normal comment + } + else if ((sc.ch < 0x80) && isdigit(sc.ch)) { // Decimal numbers haven't prefix + sc.SetState(SCE_A68K_NUMBER_DEC); + } + else if ((sc.ch < 0x80) && (sc.ch == '%')) { // Binary numbers are prefixed with '%' + sc.SetState(SCE_A68K_NUMBER_BIN); + } + else if ((sc.ch < 0x80) && (sc.ch == '$')) { // Hexadecimal numbers are prefixed with '$' + sc.SetState(SCE_A68K_NUMBER_HEX); + } + else if ((sc.ch < 0x80) && (sc.ch == '\'')) { // String (single-quoted) + sc.SetState(SCE_A68K_STRING1); + } + else if ((sc.ch < 0x80) && (sc.ch == '\"')) { // String (double-quoted) + sc.SetState(SCE_A68K_STRING2); + } + else if ((sc.ch < 0x80) && (sc.ch == '\\') && (isdigit(sc.chNext))) { // Replacement symbols in macro are prefixed with '\' + sc.SetState(SCE_A68K_MACRO_ARG); + } + else if ((sc.ch < 0x80) && IsIdentifierStart(sc.ch)) { // An identifier: constant, label, etc... + sc.SetState(SCE_A68K_IDENTIFIER); + } + else { + if (sc.ch < 0x80) { + OpType = GetOperatorType(sc.ch, sc.chNext); // Check if current char is an operator + if (OpType != NO_OPERATOR) { + sc.SetState(SCE_A68K_OPERATOR); + if (OpType == OPERATOR_2CHAR) { // Check if the operator is 2 bytes long + sc.ForwardSetState(SCE_A68K_OPERATOR); // (>> or <<) + } + } + } + } + } // End of for() + sc.Complete(); +} + + +// Names of the keyword lists + +static const char * const a68kWordListDesc[] = +{ + "CPU instructions", + "Registers", + "Directives", + "Extended instructions", + "Comment special words", + "Doxygen keywords", + 0 +}; + +LexerModule lmA68k(SCLEX_A68K, ColouriseA68kDoc, "a68k", 0, a68kWordListDesc); diff --git a/Pythonwin/Scintilla/src/LexAPDL.cxx b/Pythonwin/Scintilla/lexers/LexAPDL.cxx similarity index 94% rename from Pythonwin/Scintilla/src/LexAPDL.cxx rename to Pythonwin/Scintilla/lexers/LexAPDL.cxx index 7bf597b42..447e40d58 100644 --- a/Pythonwin/Scintilla/src/LexAPDL.cxx +++ b/Pythonwin/Scintilla/lexers/LexAPDL.cxx @@ -8,22 +8,23 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.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 == '_')); @@ -40,7 +41,7 @@ static inline bool IsAnOperator(char ch) { return false; } -static void ColouriseAPDLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseAPDLDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { int stringStart = ' '; @@ -181,16 +182,16 @@ static int CheckAPDLFoldPoint(char const *token, int &level) { return 0; } -static void FoldAPDLDoc(unsigned int startPos, int length, int, +static void FoldAPDLDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - int line = styler.GetLine(startPos); + Sci_Position line = styler.GetLine(startPos); int level = styler.LevelAt(line); int go = 0, done = 0; - int endPos = startPos + length; + Sci_Position endPos = startPos + length; char word[256]; int wordlen = 0; - int i; + Sci_Position i; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; // Scan for tokens at the start of the line (they may include // whitespace, for tokens like "End Function" diff --git a/Pythonwin/Scintilla/src/LexASY.cxx b/Pythonwin/Scintilla/lexers/LexASY.cxx similarity index 89% rename from Pythonwin/Scintilla/src/LexASY.cxx rename to Pythonwin/Scintilla/lexers/LexASY.cxx index 5bf979fd3..612d24b40 100644 --- a/Pythonwin/Scintilla/src/LexASY.cxx +++ b/Pythonwin/Scintilla/lexers/LexASY.cxx @@ -1,28 +1,28 @@ // Scintilla source code edit control +// @file LexASY.cxx //Author: instanton (email: soft_share126com) // The License.txt file describes the conditions under which this software may be distributed. #include #include -#include #include #include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" #include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif -static void ColouriseAsyDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseAsyDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -118,7 +118,7 @@ static void ColouriseAsyDoc(unsigned int startPos, int length, int initStyle, sc.SetState(SCE_ASY_IDENTIFIER); } else if (sc.Match('/', '*')) { sc.SetState(SCE_ASY_COMMENT); - sc.Forward(); // + sc.Forward(); // } else if (sc.Match('/', '/')) { sc.SetState(SCE_ASY_COMMENTLINE); } else if (sc.ch == '\"') { @@ -151,7 +151,7 @@ static inline bool isASYidentifier(int ch) { ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) ; } -static int ParseASYWord(unsigned int pos, Accessor &styler, char *word) +static int ParseASYWord(Sci_PositionU pos, Accessor &styler, char *word) { int length=0; char ch=styler.SafeGetCharAt(pos); @@ -162,15 +162,15 @@ static int ParseASYWord(unsigned int pos, Accessor &styler, char *word) length++; ch=styler.SafeGetCharAt(pos+length); } - word[length]=0; + word[length]=0; return length; } -static bool IsASYDrawingLine(int line, Accessor &styler) { - int pos = styler.LineStart(line); - int eol_pos = styler.LineStart(line + 1) - 1; - - int startpos = pos; +static bool IsASYDrawingLine(Sci_Position line, Accessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + + Sci_Position startpos = pos; char buffer[100]=""; while (startpos 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; @@ -201,7 +201,7 @@ static void FoldAsyDoc(unsigned int startPos, int length, int initStyle, char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; @@ -236,7 +236,7 @@ static void FoldAsyDoc(unsigned int startPos, int length, int initStyle, else if (lineCurrent!=0 && IsASYDrawingLine(lineCurrent - 1, styler) && !IsASYDrawingLine(lineCurrent+1, styler)) levelNext--; - } + } if (atEOL) { int levelUse = levelCurrent; diff --git a/Pythonwin/Scintilla/src/LexAU3.cxx b/Pythonwin/Scintilla/lexers/LexAU3.cxx similarity index 89% rename from Pythonwin/Scintilla/src/LexAU3.cxx rename to Pythonwin/Scintilla/lexers/LexAU3.cxx index cedf261f5..417c832e0 100644 --- a/Pythonwin/Scintilla/src/LexAU3.cxx +++ b/Pythonwin/Scintilla/lexers/LexAU3.cxx @@ -1,15 +1,15 @@ // Scintilla source code edit control // @file LexAU3.cxx -// Lexer for AutoIt3 http://www.hiddensoft.com/autoit3 -// by Jos van der Zande, jvdzande@yahoo.com +// Lexer for AutoIt3 https://www.autoitscript.com/site/ +// by Jos van der Zande, jvdzande@yahoo.com // // Changes: // March 28, 2004 - Added the standard Folding code // April 21, 2004 - Added Preprosessor Table + Syntax Highlighting // Fixed Number highlighting // Changed default isoperator to IsAOperator to have a better match to AutoIt3 -// Fixed "#comments_start" -> "#comments-start" -// Fixed "#comments_end" -> "#comments-end" +// Fixed "#comments_start" -> "#comments-start" +// Fixed "#comments_end" -> "#comments-end" // Fixed Sendkeys in Strings when not terminated with } // Added support for Sendkey strings that have second parameter e.g. {UP 5} or {a down} // April 26, 2004 - Fixed # pre-processor statement inside of comment block would invalidly change the color. @@ -25,9 +25,9 @@ // Added fold.compact support set with fold.compact=1 // Changed folding inside of #cs-#ce. Default is no keyword folding inside comment blocks when fold.comment=1 // it will now only happen when fold.comment=2. -// Sep 5, 2004 - Added logic to handle colourizing words on the last line. +// Sep 5, 2004 - Added logic to handle colourizing words on the last line. // Typed Characters now show as "default" till they match any table. -// Oct 10, 2004 - Added logic to show Comments in "Special" directives. +// Oct 10, 2004 - Added logic to show Comments in "Special" directives. // Nov 1, 2004 - Added better testing for Numbers supporting x and e notation. // Nov 28, 2004 - Added logic to handle continuation lines for syntax highlighting. // Jan 10, 2005 - Added Abbreviations Keyword used for expansion @@ -52,22 +52,23 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif static inline bool IsTypeCharacter(const int ch) { @@ -84,7 +85,7 @@ static inline bool IsAWordStart(const int ch) } static inline bool IsAOperator(char ch) { - if (isascii(ch) && isalnum(ch)) + if (IsASCII(ch) && isalnum(ch)) return false; if (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '&' || ch == '^' || ch == '=' || ch == '<' || ch == '>' || @@ -127,7 +128,7 @@ static int GetSendKey(const char *szLine, char *szKey) } else if (cTemp == ' ') { - // skip other spaces + // skip other spaces } else if (nFlag == 0) { @@ -139,7 +140,7 @@ static int GetSendKey(const char *szLine, char *szKey) // Save second portion into var... szSpecial[nSpecPos++] = cTemp; // check if Second portion is all numbers for repeat fuction - if (isdigit(cTemp) == false) {nSpecNum = 0;} + if (isdigit(cTemp) == false) {nSpecNum = 0;} } } nPos++; // skip to next char @@ -151,7 +152,7 @@ static int GetSendKey(const char *szLine, char *szKey) szKey[nKeyPos] = '\0'; szSpecial[nSpecPos] = '\0'; if (strcmp(szSpecial,"down")== 0 || strcmp(szSpecial,"up")== 0 || - strcmp(szSpecial,"on")== 0 || strcmp(szSpecial,"off")== 0 || + strcmp(szSpecial,"on")== 0 || strcmp(szSpecial,"off")== 0 || strcmp(szSpecial,"toggle")== 0 || nSpecNum == 1 ) { nFlag = 0; @@ -160,17 +161,17 @@ static int GetSendKey(const char *szLine, char *szKey) { nFlag = 1; } - return nFlag; // 1 is bad, 0 is good + return nFlag; // 1 is bad, 0 is good -} // GetSendKey() +} // GetSendKey() // // Routine to check the last "none comment" character on a line to see if its a continuation -// -static bool IsContinuationLine(unsigned int szLine, Accessor &styler) +// +static bool IsContinuationLine(Sci_PositionU szLine, Accessor &styler) { - int nsPos = styler.LineStart(szLine); - int nePos = styler.LineStart(szLine+1) - 2; + Sci_Position nsPos = styler.LineStart(szLine); + Sci_Position nePos = styler.LineStart(szLine+1) - 2; //int stylech = styler.StyleAt(nsPos); while (nsPos < nePos) { @@ -192,8 +193,8 @@ static bool IsContinuationLine(unsigned int szLine, Accessor &styler) // // syntax highlighting logic -static void ColouriseAU3Doc(unsigned int startPos, - int length, int initStyle, +static void ColouriseAU3Doc(Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -206,27 +207,27 @@ static void ColouriseAU3Doc(unsigned int startPos, WordList &keywords7 = *keywordlists[6]; WordList &keywords8 = *keywordlists[7]; // find the first previous line without continuation character at the end - int lineCurrent = styler.GetLine(startPos); - int s_startPos = startPos; + Sci_Position lineCurrent = styler.GetLine(startPos); + Sci_Position s_startPos = startPos; // When not inside a Block comment: find First line without _ if (!(initStyle==SCE_AU3_COMMENTBLOCK)) { while ((lineCurrent > 0 && IsContinuationLine(lineCurrent,styler)) || (lineCurrent > 1 && IsContinuationLine(lineCurrent-1,styler))) { lineCurrent--; startPos = styler.LineStart(lineCurrent); // get start position - initStyle = 0; // reset the start style to 0 + initStyle = 0; // reset the start style to 0 } } // Set the new length to include it from the start and set the start position length = length + s_startPos - startPos; // correct the total length to process styler.StartAt(startPos); - + StyleContext sc(startPos, length, initStyle, styler); char si; // string indicator "=1 '=2 char ni; // Numeric indicator error=9 normal=0 normal+dec=1 hex=2 Enot=3 - char ci; // comment indicator 0=not linecomment(;) - char s_save[100]; - si=0; + char ci; // comment indicator 0=not linecomment(;) + char s_save[100] = ""; + si=0; ni=0; ci=0; //$$$ @@ -234,11 +235,11 @@ static void ColouriseAU3Doc(unsigned int startPos, char s[100]; sc.GetCurrentLowered(s, sizeof(s)); // ********************************************** - // save the total current word for eof processing - if (IsAWordChar(sc.ch) || sc.ch == '}') + // save the total current word for eof processing + if (IsAWordChar(sc.ch) || sc.ch == '}') { strcpy(s_save,s); - int tp = strlen(s_save); + int tp = static_cast(strlen(s_save)); if (tp < 99) { s_save[tp] = static_cast(tolower(sc.ch)); s_save[tp+1] = '\0'; @@ -253,11 +254,12 @@ static void ColouriseAU3Doc(unsigned int startPos, //Reset at line end if (sc.atLineEnd) { ci=0; - if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0)) - if (sc.atLineEnd) + if (strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0) { + if (sc.atLineEnd) sc.SetState(SCE_AU3_DEFAULT); - else + else sc.SetState(SCE_AU3_COMMENTBLOCK); + } break; } //skip rest of line when a ; is encountered @@ -266,9 +268,9 @@ static void ColouriseAU3Doc(unsigned int startPos, sc.SetState(SCE_AU3_COMMENTBLOCK); } // skip rest of the line - if (ci==2) + if (ci==2) break; - // check when first character is detected on the line + // check when first character is detected on the line if (ci==0) { if (IsAWordStart(static_cast(sc.ch)) || IsAOperator(static_cast(sc.ch))) { ci=1; @@ -291,10 +293,10 @@ static void ColouriseAU3Doc(unsigned int startPos, } case SCE_AU3_OPERATOR: { - // check if its a COMobject + // check if its a COMobject if (sc.chPrev == '.' && IsAWordChar(sc.ch)) { sc.SetState(SCE_AU3_COMOBJ); - } + } else { sc.SetState(SCE_AU3_DEFAULT); } @@ -359,7 +361,7 @@ static void ColouriseAU3Doc(unsigned int startPos, sc.SetState(SCE_AU3_DEFAULT); } } - } + } if (sc.atLineEnd) { sc.SetState(SCE_AU3_DEFAULT);} break; @@ -432,7 +434,7 @@ static void ColouriseAU3Doc(unsigned int startPos, case SCE_AU3_STRING: { // check for " to end a double qouted string or - // check for ' to end a single qouted string + // check for ' to end a single qouted string if ((si == 1 && sc.ch == '\"') || (si == 2 && sc.ch == '\'') || (si == 3 && sc.ch == '>')) { sc.ForwardSetState(SCE_AU3_DEFAULT); @@ -443,8 +445,8 @@ static void ColouriseAU3Doc(unsigned int startPos, { si=0; // at line end and not found a continuation char then reset to default - int lineCurrent = styler.GetLine(sc.currentPos); - if (!IsContinuationLine(lineCurrent,styler)) + Sci_Position lineCurrent = styler.GetLine(sc.currentPos); + if (!IsContinuationLine(lineCurrent,styler)) { sc.SetState(SCE_AU3_DEFAULT); break; @@ -455,27 +457,27 @@ static void ColouriseAU3Doc(unsigned int startPos, sc.SetState(SCE_AU3_SENT);} break; } - + case SCE_AU3_SENT: { - // Send key string ended - if (sc.chPrev == '}' && sc.ch != '}') + // Send key string ended + if (sc.chPrev == '}' && sc.ch != '}') { // set color to SENDKEY when valid sendkey .. else set back to regular string char sk[100]; // split {111 222} and return {111} and check if 222 is valid. // if return code = 1 then invalid 222 so must be string - if (GetSendKey(s,sk)) + if (GetSendKey(s,sk)) { sc.ChangeState(SCE_AU3_STRING); } // if single char between {?} then its ok as sendkey for a single character - else if (strlen(sk) == 3) + else if (strlen(sk) == 3) { sc.ChangeState(SCE_AU3_SENT); } // if sendkey {111} is in table then ok as sendkey - else if (keywords4.InList(sk)) + else if (keywords4.InList(sk)) { sc.ChangeState(SCE_AU3_SENT); } @@ -488,12 +490,12 @@ static void ColouriseAU3Doc(unsigned int startPos, else { // check if the start is a valid SendKey start - int nPos = 0; + Sci_Position nPos = 0; int nState = 1; char cTemp; - while (!(nState == 2) && ((cTemp = s[nPos]) != '\0')) + while (!(nState == 2) && ((cTemp = s[nPos]) != '\0')) { - if (cTemp == '{' && nState == 1) + if (cTemp == '{' && nState == 1) { nState = 2; } @@ -508,14 +510,14 @@ static void ColouriseAU3Doc(unsigned int startPos, sc.ChangeState(SCE_AU3_STRING); sc.SetState(SCE_AU3_STRING); } - // If invalid character found then assume its a regular string + // If invalid character found then assume its a regular string if (nState == 0) { sc.ChangeState(SCE_AU3_STRING); sc.SetState(SCE_AU3_STRING); } } // check if next portion is again a sendkey - if (sc.atLineEnd) + if (sc.atLineEnd) { sc.ChangeState(SCE_AU3_STRING); sc.SetState(SCE_AU3_DEFAULT); @@ -546,14 +548,14 @@ static void ColouriseAU3Doc(unsigned int startPos, else if (sc.ch == '.' && !IsADigit(sc.chNext)) {sc.SetState(SCE_AU3_OPERATOR);} else if (sc.ch == '@') {sc.SetState(SCE_AU3_KEYWORD);} //else if (sc.ch == '_') {sc.SetState(SCE_AU3_KEYWORD);} - else if (sc.ch == '<' && si==3) {sc.SetState(SCE_AU3_STRING);} // string after #include + else if (sc.ch == '<' && si==3) {sc.SetState(SCE_AU3_STRING);} // string after #include else if (sc.ch == '\"') { sc.SetState(SCE_AU3_STRING); si = 1; } else if (sc.ch == '\'') { sc.SetState(SCE_AU3_STRING); si = 2; } - else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) + else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_AU3_NUMBER); ni = 0; @@ -565,7 +567,7 @@ static void ColouriseAU3Doc(unsigned int startPos, } //for (; sc.More(); sc.Forward()) //************************************* - // Colourize the last word correctly + // Colourize the last word correctly //************************************* if (sc.state == SCE_AU3_KEYWORD) { @@ -609,24 +611,24 @@ static void ColouriseAU3Doc(unsigned int startPos, } if (sc.state == SCE_AU3_SENT) { - // Send key string ended - if (sc.chPrev == '}' && sc.ch != '}') + // Send key string ended + if (sc.chPrev == '}' && sc.ch != '}') { // set color to SENDKEY when valid sendkey .. else set back to regular string char sk[100]; // split {111 222} and return {111} and check if 222 is valid. // if return code = 1 then invalid 222 so must be string - if (GetSendKey(s_save,sk)) + if (GetSendKey(s_save,sk)) { sc.ChangeState(SCE_AU3_STRING); } // if single char between {?} then its ok as sendkey for a single character - else if (strlen(sk) == 3) + else if (strlen(sk) == 3) { sc.ChangeState(SCE_AU3_SENT); } // if sendkey {111} is in table then ok as sendkey - else if (keywords4.InList(sk)) + else if (keywords4.InList(sk)) { sc.ChangeState(SCE_AU3_SENT); } @@ -637,7 +639,7 @@ static void ColouriseAU3Doc(unsigned int startPos, sc.SetState(SCE_AU3_STRING); } // check if next portion is again a sendkey - if (sc.atLineEnd) + if (sc.atLineEnd) { sc.ChangeState(SCE_AU3_STRING); sc.SetState(SCE_AU3_DEFAULT); @@ -654,11 +656,11 @@ static bool IsStreamCommentStyle(int style) { // // Routine to find first none space on the current line and return its Style -// needed for comment lines not starting on pos 1 -static int GetStyleFirstWord(unsigned int szLine, Accessor &styler) +// needed for comment lines not starting on pos 1 +static int GetStyleFirstWord(Sci_PositionU szLine, Accessor &styler) { - int nsPos = styler.LineStart(szLine); - int nePos = styler.LineStart(szLine+1) - 1; + Sci_Position nsPos = styler.LineStart(szLine); + Sci_Position nePos = styler.LineStart(szLine+1) - 1; while (isspacechar(styler.SafeGetCharAt(nsPos)) && nsPos < nePos) { nsPos++; // skip to next char @@ -670,23 +672,23 @@ static int GetStyleFirstWord(unsigned int szLine, Accessor &styler) // -static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) +static void FoldAU3Doc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - int endPos = startPos + length; + Sci_Position endPos = startPos + length; // get settings from the config files for folding comments and preprocessor lines bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldInComment = styler.GetPropertyInt("fold.comment") == 2; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldpreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; // Backtrack to previous line in case need to fix its fold status - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); if (startPos > 0) { if (lineCurrent > 0) { lineCurrent--; startPos = styler.LineStart(lineCurrent); } } - // vars for style of previous/current/next lines + // vars for style of previous/current/next lines int style = GetStyleFirstWord(lineCurrent,styler); int stylePrev = 0; // find the first previous line without continuation character at the end @@ -711,12 +713,12 @@ static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Acc if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelNext = levelCurrent; - // + // int visibleChars = 0; char chNext = styler.SafeGetCharAt(startPos); char chPrev = ' '; // - for (int i = startPos; i < endPos; i++) { + for (Sci_Position i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if (IsAWordChar(ch)) { @@ -736,7 +738,7 @@ static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Acc } } } - // start the capture of the first word + // start the capture of the first word if (!(FirstWordStart)) { if (IsAWordChar(ch) || IsAWordStart(ch) || ch == ';') { FirstWordStart = true; @@ -748,7 +750,7 @@ static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Acc if (ThenFoundLast) { if (IsAWordChar(ch)) { ThenFoundLast = false; - } + } } // find out if the word "then" is the last on a "if" line if (FirstWordEnd && strcmp(szKeyword,"if") == 0) { @@ -769,21 +771,21 @@ static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Acc } } } - // End of Line found so process the information + // End of Line found so process the information if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos)) { // ************************** // Folding logic for Keywords // ************************** // if a keyword is found on the current line and the line doesn't end with _ (continuation) // and we are not inside a commentblock. - if (szKeywordlen > 0 && (!(chPrev == '_')) && + if (szKeywordlen > 0 && (!(chPrev == '_')) && ((!(IsStreamCommentStyle(style)) || foldInComment)) ) { szKeyword[szKeywordlen] = '\0'; // only fold "if" last keyword is "then" (else its a one line if) if (strcmp(szKeyword,"if") == 0 && ThenFoundLast) { levelNext++; } - // create new fold for these words + // create new fold for these words if (strcmp(szKeyword,"do") == 0 || strcmp(szKeyword,"for") == 0 || strcmp(szKeyword,"func") == 0 || strcmp(szKeyword,"while") == 0|| strcmp(szKeyword,"with") == 0 || strcmp(szKeyword,"#region") == 0 ) { @@ -796,12 +798,12 @@ static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Acc } // end the fold for these words before the current line if (strcmp(szKeyword,"endfunc") == 0 || strcmp(szKeyword,"endif") == 0 || - strcmp(szKeyword,"next") == 0 || strcmp(szKeyword,"until") == 0 || + strcmp(szKeyword,"next") == 0 || strcmp(szKeyword,"until") == 0 || strcmp(szKeyword,"endwith") == 0 ||strcmp(szKeyword,"wend") == 0){ levelNext--; levelCurrent--; } - // end the fold for these words before the current line and Start new fold + // end the fold for these words before the current line and Start new fold if (strcmp(szKeyword,"case") == 0 || strcmp(szKeyword,"else") == 0 || strcmp(szKeyword,"elseif") == 0 ) { levelCurrent--; @@ -840,16 +842,16 @@ static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Acc // Start of a comment block if (!(stylePrev==style) && IsStreamCommentStyle(styleNext) && styleNext==style) { levelNext++; - } + } // fold till the last line for normal comment lines - else if (IsStreamCommentStyle(stylePrev) + else if (IsStreamCommentStyle(stylePrev) && !(styleNext == SCE_AU3_COMMENT) - && stylePrev == SCE_AU3_COMMENT + && stylePrev == SCE_AU3_COMMENT && style == SCE_AU3_COMMENT) { levelNext--; } // fold till the one but last line for Blockcomment lines - else if (IsStreamCommentStyle(stylePrev) + else if (IsStreamCommentStyle(stylePrev) && !(styleNext == SCE_AU3_COMMENTBLOCK) && style == SCE_AU3_COMMENTBLOCK) { levelNext--; diff --git a/Pythonwin/Scintilla/src/LexAVE.cxx b/Pythonwin/Scintilla/lexers/LexAVE.cxx similarity index 91% rename from Pythonwin/Scintilla/src/LexAVE.cxx rename to Pythonwin/Scintilla/lexers/LexAVE.cxx index 2b7029b1a..b976734ae 100644 --- a/Pythonwin/Scintilla/src/LexAVE.cxx +++ b/Pythonwin/Scintilla/lexers/LexAVE.cxx @@ -9,22 +9,23 @@ #include #include -#include -#include #include +#include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif static inline bool IsAWordChar(const int ch) { @@ -42,7 +43,7 @@ inline bool IsAWordStart(const int ch) { } inline bool isAveOperator(char ch) { - if (isalnum(ch)) + if (IsASCII(ch) && isalnum(ch)) return false; // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || @@ -56,8 +57,8 @@ inline bool isAveOperator(char ch) { } static void ColouriseAveDoc( - unsigned int startPos, - int length, + Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -79,7 +80,7 @@ static void ColouriseAveDoc( for (; sc.More(); sc.Forward()) { if (sc.atLineEnd) { // Update the line state, so it can be seen by next line - int currentLine = styler.GetLine(sc.currentPos); + Sci_Position currentLine = styler.GetLine(sc.currentPos); styler.SetLineState(currentLine, 0); } if (sc.atLineStart && (sc.state == SCE_AVE_STRING)) { @@ -154,19 +155,19 @@ static void ColouriseAveDoc( sc.Complete(); } -static void FoldAveDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[], +static void FoldAveDoc(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = static_cast(tolower(styler[startPos])); bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; int styleNext = styler.StyleAt(startPos); - char s[10]; + char s[10] = ""; - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = static_cast(tolower(chNext)); chNext = static_cast(tolower(styler.SafeGetCharAt(i + 1))); int style = styleNext; diff --git a/Pythonwin/Scintilla/lexers/LexAVS.cxx b/Pythonwin/Scintilla/lexers/LexAVS.cxx new file mode 100644 index 000000000..df5223f8d --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexAVS.cxx @@ -0,0 +1,291 @@ +// Scintilla source code edit control +/** @file LexAVS.cxx + ** Lexer for AviSynth. + **/ +// Copyright 2012 by Bruno Barbieri +// Heavily based on LexPOV by Neil Hodgson +// 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" + +using namespace Scintilla; + +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '_'); +} + +static inline bool IsAWordStart(int ch) { + return isalpha(ch) || (ch != ' ' && ch != '\n' && ch != '(' && ch != '.' && ch != ','); +} + +static inline bool IsANumberChar(int ch) { + // Not exactly following number definition (several dots are seen as OK, etc.) + // but probably enough in most cases. + return (ch < 0x80) && + (isdigit(ch) || ch == '.' || ch == '-' || ch == '+'); +} + +static void ColouriseAvsDoc( + Sci_PositionU startPos, + Sci_Position length, + int initStyle, + WordList *keywordlists[], + Accessor &styler) { + + WordList &keywords = *keywordlists[0]; + WordList &filters = *keywordlists[1]; + WordList &plugins = *keywordlists[2]; + WordList &functions = *keywordlists[3]; + WordList &clipProperties = *keywordlists[4]; + WordList &userDefined = *keywordlists[5]; + + Sci_Position currentLine = styler.GetLine(startPos); + // Initialize the block comment nesting level, if we are inside such a comment. + int blockCommentLevel = 0; + if (initStyle == SCE_AVS_COMMENTBLOCK || initStyle == SCE_AVS_COMMENTBLOCKN) { + blockCommentLevel = styler.GetLineState(currentLine - 1); + } + + // Do not leak onto next line + if (initStyle == SCE_AVS_COMMENTLINE) { + initStyle = SCE_AVS_DEFAULT; + } + + StyleContext sc(startPos, length, initStyle, styler); + + for (; sc.More(); sc.Forward()) { + if (sc.atLineEnd) { + // Update the line state, so it can be seen by next line + currentLine = styler.GetLine(sc.currentPos); + if (sc.state == SCE_AVS_COMMENTBLOCK || sc.state == SCE_AVS_COMMENTBLOCKN) { + // Inside a block comment, we set the line state + styler.SetLineState(currentLine, blockCommentLevel); + } else { + // Reset the line state + styler.SetLineState(currentLine, 0); + } + } + + // Determine if the current state should terminate. + if (sc.state == SCE_AVS_OPERATOR) { + sc.SetState(SCE_AVS_DEFAULT); + } else if (sc.state == SCE_AVS_NUMBER) { + // We stop the number definition on non-numerical non-dot non-sign char + if (!IsANumberChar(sc.ch)) { + sc.SetState(SCE_AVS_DEFAULT); + } + } else if (sc.state == SCE_AVS_IDENTIFIER) { + if (!IsAWordChar(sc.ch)) { + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + + if (keywords.InList(s)) { + sc.ChangeState(SCE_AVS_KEYWORD); + } else if (filters.InList(s)) { + sc.ChangeState(SCE_AVS_FILTER); + } else if (plugins.InList(s)) { + sc.ChangeState(SCE_AVS_PLUGIN); + } else if (functions.InList(s)) { + sc.ChangeState(SCE_AVS_FUNCTION); + } else if (clipProperties.InList(s)) { + sc.ChangeState(SCE_AVS_CLIPPROP); + } else if (userDefined.InList(s)) { + sc.ChangeState(SCE_AVS_USERDFN); + } + sc.SetState(SCE_AVS_DEFAULT); + } + } else if (sc.state == SCE_AVS_COMMENTBLOCK) { + if (sc.Match('/', '*')) { + blockCommentLevel++; + sc.Forward(); + } else if (sc.Match('*', '/') && blockCommentLevel > 0) { + blockCommentLevel--; + sc.Forward(); + if (blockCommentLevel == 0) { + sc.ForwardSetState(SCE_AVS_DEFAULT); + } + } + } else if (sc.state == SCE_AVS_COMMENTBLOCKN) { + if (sc.Match('[', '*')) { + blockCommentLevel++; + sc.Forward(); + } else if (sc.Match('*', ']') && blockCommentLevel > 0) { + blockCommentLevel--; + sc.Forward(); + if (blockCommentLevel == 0) { + sc.ForwardSetState(SCE_AVS_DEFAULT); + } + } + } else if (sc.state == SCE_AVS_COMMENTLINE) { + if (sc.atLineEnd) { + sc.ForwardSetState(SCE_AVS_DEFAULT); + } + } else if (sc.state == SCE_AVS_STRING) { + if (sc.ch == '\"') { + sc.ForwardSetState(SCE_AVS_DEFAULT); + } + } else if (sc.state == SCE_AVS_TRIPLESTRING) { + if (sc.Match("\"\"\"")) { + sc.Forward(); + sc.Forward(); + sc.ForwardSetState(SCE_AVS_DEFAULT); + } + } + + // Determine if a new state should be entered. + if (sc.state == SCE_AVS_DEFAULT) { + if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { + sc.SetState(SCE_AVS_NUMBER); + } else if (IsADigit(sc.ch) || (sc.ch == ',' && IsADigit(sc.chNext))) { + sc.Forward(); + sc.SetState(SCE_AVS_NUMBER); + } else if (sc.Match('/', '*')) { + blockCommentLevel = 1; + sc.SetState(SCE_AVS_COMMENTBLOCK); + sc.Forward(); // Eat the * so it isn't used for the end of the comment + } else if (sc.Match('[', '*')) { + blockCommentLevel = 1; + sc.SetState(SCE_AVS_COMMENTBLOCKN); + sc.Forward(); // Eat the * so it isn't used for the end of the comment + } else if (sc.ch == '#') { + sc.SetState(SCE_AVS_COMMENTLINE); + } else if (sc.ch == '\"') { + if (sc.Match("\"\"\"")) { + sc.SetState(SCE_AVS_TRIPLESTRING); + } else { + sc.SetState(SCE_AVS_STRING); + } + } else if (isoperator(static_cast(sc.ch))) { + sc.SetState(SCE_AVS_OPERATOR); + } else if (IsAWordStart(sc.ch)) { + sc.SetState(SCE_AVS_IDENTIFIER); + } + } + } + + // End of file: complete any pending changeState + if (sc.state == SCE_AVS_IDENTIFIER) { + if (!IsAWordChar(sc.ch)) { + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + + if (keywords.InList(s)) { + sc.ChangeState(SCE_AVS_KEYWORD); + } else if (filters.InList(s)) { + sc.ChangeState(SCE_AVS_FILTER); + } else if (plugins.InList(s)) { + sc.ChangeState(SCE_AVS_PLUGIN); + } else if (functions.InList(s)) { + sc.ChangeState(SCE_AVS_FUNCTION); + } else if (clipProperties.InList(s)) { + sc.ChangeState(SCE_AVS_CLIPPROP); + } else if (userDefined.InList(s)) { + sc.ChangeState(SCE_AVS_USERDFN); + } + sc.SetState(SCE_AVS_DEFAULT); + } + } + + sc.Complete(); +} + +static void FoldAvsDoc( + 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_AVS_COMMENTBLOCK) { + if (stylePrev != SCE_AVS_COMMENTBLOCK) { + levelCurrent++; + } else if ((styleNext != SCE_AVS_COMMENTBLOCK) && !atEOL) { + // Comments don't end at end of line and the next character may be unstyled. + levelCurrent--; + } + } + + if (foldComment && style == SCE_AVS_COMMENTBLOCKN) { + if (stylePrev != SCE_AVS_COMMENTBLOCKN) { + levelCurrent++; + } else if ((styleNext != SCE_AVS_COMMENTBLOCKN) && !atEOL) { + // Comments don't end at end of line and the next character may be unstyled. + levelCurrent--; + } + } + + if (style == SCE_AVS_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); +} + +static const char * const avsWordLists[] = { + "Keywords", + "Filters", + "Plugins", + "Functions", + "Clip properties", + "User defined functions", + 0, +}; + +LexerModule lmAVS(SCLEX_AVS, ColouriseAvsDoc, "avs", FoldAvsDoc, avsWordLists); diff --git a/Pythonwin/Scintilla/src/LexAbaqus.cxx b/Pythonwin/Scintilla/lexers/LexAbaqus.cxx similarity index 89% rename from Pythonwin/Scintilla/src/LexAbaqus.cxx rename to Pythonwin/Scintilla/lexers/LexAbaqus.cxx index 10e8b76b1..0b9bfb62a 100644 --- a/Pythonwin/Scintilla/src/LexAbaqus.cxx +++ b/Pythonwin/Scintilla/lexers/LexAbaqus.cxx @@ -1,5 +1,5 @@ // Scintilla source code edit control -/** @file LexABAQUS.cxx +/** @file LexAbaqus.cxx ** Lexer for ABAQUS. Based on the lexer for APDL by Hadar Raz. ** By Sergio Lucato. ** Sort of completely rewritten by Gertjan Kloosterman @@ -10,26 +10,23 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.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 == '_'))); -} static inline bool IsAKeywordChar(const int ch) { return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == ' '))); @@ -39,18 +36,7 @@ static inline bool IsASetChar(const int ch) { return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == '.') || (ch == '-'))); } -static inline bool IsAnOperator(char ch) { - // '.' left out as it is used to make up numbers - if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || - ch == '(' || ch == ')' || ch == '=' || ch == '^' || - ch == '[' || ch == ']' || ch == '<' || ch == '&' || - ch == '>' || ch == ',' || ch == '|' || ch == '~' || - ch == '$' || ch == ':' || ch == '%') - return true; - return false; -} - -static void ColouriseABAQUSDoc(unsigned int startPos, int length, int initStyle, WordList*[] /* *keywordlists[] */, +static void ColouriseABAQUSDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList*[] /* *keywordlists[] */, Accessor &styler) { enum localState { KW_LINE_KW, KW_LINE_COMMA, KW_LINE_PAR, KW_LINE_EQ, KW_LINE_VAL, \ DAT_LINE_VAL, DAT_LINE_COMMA,\ @@ -313,10 +299,10 @@ static int LowerCase(int c) return c; } -static int LineEnd(int line, Accessor &styler) +static Sci_Position LineEnd(Sci_Position line, Accessor &styler) { - const int docLines = styler.GetLine(styler.Length() - 1); // Available last line - int eol_pos ; + const Sci_Position docLines = styler.GetLine(styler.Length() - 1); // Available last line + Sci_Position eol_pos ; // if the line is the last line, the eol_pos is styler.Length() // eol will contain a new line, or a virtual new line if ( docLines == line ) @@ -326,7 +312,7 @@ static int LineEnd(int line, Accessor &styler) return eol_pos ; } -static int LineStart(int line, Accessor &styler) +static Sci_Position LineStart(Sci_Position line, Accessor &styler) { return styler.LineStart(line) ; } @@ -342,14 +328,14 @@ static int LineStart(int line, Accessor &styler) // 6 : block close keyword line // 7 : keyword line in error // 8 : comment line -static int LineType(int line, Accessor &styler) { - int pos = LineStart(line, styler) ; - int eol_pos = LineEnd(line, styler) ; +static int LineType(Sci_Position line, Accessor &styler) { + Sci_Position pos = LineStart(line, styler) ; + Sci_Position eol_pos = LineEnd(line, styler) ; int c ; char ch = ' '; - int i = pos ; + Sci_Position i = pos ; while ( i < eol_pos ) { c = styler.SafeGetCharAt(i); ch = static_cast(LowerCase(c)); @@ -430,7 +416,7 @@ static int LineType(int line, Accessor &styler) { return 4 ; } -static void SafeSetLevel(int line, int level, Accessor &styler) +static void SafeSetLevel(Sci_Position line, int level, Accessor &styler) { if ( line < 0 ) return ; @@ -444,20 +430,20 @@ static void SafeSetLevel(int line, int level, Accessor &styler) styler.SetLevel(line, level) ; } -static void FoldABAQUSDoc(unsigned int startPos, int length, int, +static void FoldABAQUSDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - int startLine = styler.GetLine(startPos) ; - int endLine = styler.GetLine(startPos+length-1) ; + Sci_Position startLine = styler.GetLine(startPos) ; + Sci_Position endLine = styler.GetLine(startPos+length-1) ; // bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; // We want to deal with all the cases // To know the correct indentlevel, we need to look back to the // previous command line indentation level // order of formatting keyline datalines commentlines - int beginData = -1 ; - int beginComment = -1 ; - int prvKeyLine = startLine ; - int prvKeyLineTp = 0 ; + Sci_Position beginData = -1 ; + Sci_Position beginComment = -1 ; + Sci_Position prvKeyLine = startLine ; + Sci_Position prvKeyLineTp = 0 ; // Scan until we find the previous keyword line // this will give us the level reference that we need @@ -479,7 +465,7 @@ WordList *[], Accessor &styler) { prvKeyLine = -1 ; // Now start scanning over the lines. - for ( int line = startLine; line <= endLine; line++ ) { + for ( Sci_Position line = startLine; line <= endLine; line++ ) { int lineType = LineType(line, styler) ; // Check for comment line @@ -528,7 +514,7 @@ WordList *[], Accessor &styler) { datLevel = level ; } - for ( int ll = beginData; ll < beginComment; ll++ ) + for ( Sci_Position ll = beginData; ll < beginComment; ll++ ) SafeSetLevel(ll, datLevel, styler) ; // The keyword we just found is going to be written at another level @@ -544,7 +530,7 @@ WordList *[], Accessor &styler) { } } - for ( int lll = beginComment; lll < line; lll++ ) + for ( Sci_Position lll = beginComment; lll < line; lll++ ) SafeSetLevel(lll, level, styler) ; // wrap and reset @@ -561,10 +547,10 @@ WordList *[], Accessor &styler) { } else { // We need to find out whether this comment block is followed by // a data line or a keyword line - const int docLines = styler.GetLine(styler.Length() - 1); + const Sci_Position docLines = styler.GetLine(styler.Length() - 1); - for ( int line = endLine + 1; line <= docLines; line++ ) { - int lineType = LineType(line, styler) ; + for ( Sci_Position line = endLine + 1; line <= docLines; line++ ) { + Sci_Position lineType = LineType(line, styler) ; if ( lineType != 8 ) { if ( !(lineType & 4) ) { @@ -590,17 +576,17 @@ WordList *[], Accessor &styler) { datLevel = level ; } - for ( int ll = beginData; ll < beginComment; ll++ ) + for ( Sci_Position ll = beginData; ll < beginComment; ll++ ) SafeSetLevel(ll, datLevel, styler) ; - if ( prvKeyLineTp == 5 ) { - level += 1 ; - } + if ( prvKeyLineTp == 5 ) { + level += 1 ; + } - if ( prvKeyLineTp == 6 ) { - level -= 1 ; - } - for ( int m = beginComment; m <= endLine; m++ ) + if ( prvKeyLineTp == 6 ) { + level -= 1 ; + } + for ( Sci_Position m = beginComment; m <= endLine; m++ ) SafeSetLevel(m, level, styler) ; } diff --git a/Pythonwin/Scintilla/src/LexAda.cxx b/Pythonwin/Scintilla/lexers/LexAda.cxx similarity index 91% rename from Pythonwin/Scintilla/src/LexAda.cxx rename to Pythonwin/Scintilla/lexers/LexAda.cxx index f6c9e7ee7..9d7f5d0f7 100644 --- a/Pythonwin/Scintilla/src/LexAda.cxx +++ b/Pythonwin/Scintilla/lexers/LexAda.cxx @@ -6,30 +6,34 @@ // 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 +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "PropSet.h" -#include "KeyWords.h" -#include "SciLexer.h" -#include "SString.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif /* * Interface */ static void ColouriseDocument( - unsigned int startPos, - int length, + Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler); @@ -59,11 +63,9 @@ static void ColouriseWhiteSpace(StyleContext& sc, bool& apostropheStartsAttribut static void ColouriseWord(StyleContext& sc, WordList& keywords, bool& apostropheStartsAttribute); static inline bool IsDelimiterCharacter(int ch); -static inline bool IsNumberStartCharacter(int ch); -static inline bool IsNumberCharacter(int ch); static inline bool IsSeparatorOrDelimiterCharacter(int ch); -static bool IsValidIdentifier(const SString& identifier); -static bool IsValidNumber(const SString& number); +static bool IsValidIdentifier(const std::string& identifier); +static bool IsValidNumber(const std::string& number); static inline bool IsWordStartCharacter(int ch); static inline bool IsWordCharacter(int ch); @@ -117,7 +119,7 @@ static void ColouriseLabel(StyleContext& sc, WordList& keywords, bool& apostroph sc.Forward(); sc.Forward(); - SString identifier; + std::string identifier; while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) { identifier += static_cast(tolower(sc.ch)); @@ -144,7 +146,7 @@ static void ColouriseLabel(StyleContext& sc, WordList& keywords, bool& apostroph static void ColouriseNumber(StyleContext& sc, bool& apostropheStartsAttribute) { apostropheStartsAttribute = true; - SString number; + std::string number; sc.SetState(SCE_ADA_NUMBER); // Get all characters up to a delimiter or a separator, including points, but excluding @@ -192,7 +194,7 @@ static void ColouriseWord(StyleContext& sc, WordList& keywords, bool& apostrophe apostropheStartsAttribute = true; sc.SetState(SCE_ADA_IDENTIFIER); - SString word; + std::string word; while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) { word += static_cast(tolower(sc.ch)); @@ -218,8 +220,8 @@ static void ColouriseWord(StyleContext& sc, WordList& keywords, bool& apostrophe // static void ColouriseDocument( - unsigned int startPos, - int length, + Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -227,7 +229,7 @@ static void ColouriseDocument( StyleContext sc(startPos, length, initStyle, styler); - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); bool apostropheStartsAttribute = (styler.GetLineState(lineCurrent) & 1) != 0; while (sc.More()) { @@ -304,24 +306,11 @@ static inline bool IsDelimiterCharacter(int ch) { } } -static inline bool IsNumberCharacter(int ch) { - return IsNumberStartCharacter(ch) || - ch == '_' || - ch == '.' || - ch == '#' || - (ch >= 'a' && ch <= 'f') || - (ch >= 'A' && ch <= 'F'); -} - -static inline bool IsNumberStartCharacter(int ch) { - return IsADigit(ch); -} - static inline bool IsSeparatorOrDelimiterCharacter(int ch) { return IsASpace(ch) || IsDelimiterCharacter(ch); } -static bool IsValidIdentifier(const SString& identifier) { +static bool IsValidIdentifier(const std::string& identifier) { // First character can't be '_', so initialize the flag to true bool lastWasUnderscore = true; @@ -355,8 +344,8 @@ static bool IsValidIdentifier(const SString& identifier) { return true; } -static bool IsValidNumber(const SString& number) { - int hashPos = number.search("#"); +static bool IsValidNumber(const std::string& number) { + size_t hashPos = number.find("#"); bool seenDot = false; size_t i = 0; @@ -366,7 +355,7 @@ static bool IsValidNumber(const SString& number) { return false; // Just in case // Decimal number - if (hashPos == -1) { + if (hashPos == std::string::npos) { bool canBeSpecial = false; for (; i < length; i++) { @@ -520,5 +509,5 @@ static inline bool IsWordCharacter(int ch) { } static inline bool IsWordStartCharacter(int ch) { - return (isascii(ch) && isalpha(ch)) || ch == '_'; + return (IsASCII(ch) && isalpha(ch)) || ch == '_'; } diff --git a/Pythonwin/Scintilla/lexers/LexAsm.cxx b/Pythonwin/Scintilla/lexers/LexAsm.cxx new file mode 100644 index 000000000..4560f9751 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexAsm.cxx @@ -0,0 +1,477 @@ +// Scintilla source code edit control +/** @file LexAsm.cxx + ** Lexer for Assembler, just for the MASM syntax + ** Written by The Black Horus + ** Enhancements and NASM stuff by Kein-Hong Man, 2003-10 + ** SCE_ASM_COMMENTBLOCK and SCE_ASM_CHARACTER are for future GNU as colouring + ** Converted to lexer object and added further folding features/properties by "Udo Lechner" + **/ +// 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 "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" +#include "DefaultLexer.h" + +using namespace Scintilla; + +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '.' || + ch == '_' || ch == '?'); +} + +static inline bool IsAWordStart(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.' || + ch == '%' || ch == '@' || ch == '$' || ch == '?'); +} + +static inline bool IsAsmOperator(const int ch) { + if ((ch < 0x80) && (isalnum(ch))) + return false; + // '.' left out as it is used to make up numbers + if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || + ch == '(' || ch == ')' || ch == '=' || ch == '^' || + ch == '[' || ch == ']' || ch == '<' || ch == '&' || + ch == '>' || ch == ',' || ch == '|' || ch == '~' || + ch == '%' || ch == ':') + return true; + return false; +} + +static bool IsStreamCommentStyle(int style) { + return style == SCE_ASM_COMMENTDIRECTIVE || style == SCE_ASM_COMMENTBLOCK; +} + +static inline int LowerCase(int c) { + if (c >= 'A' && c <= 'Z') + return 'a' + c - 'A'; + return c; +} + +// An individual named option for use in an OptionSet + +// Options used for LexerAsm +struct OptionsAsm { + std::string delimiter; + bool fold; + bool foldSyntaxBased; + bool foldCommentMultiline; + bool foldCommentExplicit; + std::string foldExplicitStart; + std::string foldExplicitEnd; + bool foldExplicitAnywhere; + bool foldCompact; + std::string commentChar; + OptionsAsm() { + delimiter = ""; + fold = false; + foldSyntaxBased = true; + foldCommentMultiline = false; + foldCommentExplicit = false; + foldExplicitStart = ""; + foldExplicitEnd = ""; + foldExplicitAnywhere = false; + foldCompact = true; + commentChar = ""; + } +}; + +static const char * const asmWordListDesc[] = { + "CPU instructions", + "FPU instructions", + "Registers", + "Directives", + "Directive operands", + "Extended instructions", + "Directives4Foldstart", + "Directives4Foldend", + 0 +}; + +struct OptionSetAsm : public OptionSet { + OptionSetAsm() { + DefineProperty("lexer.asm.comment.delimiter", &OptionsAsm::delimiter, + "Character used for COMMENT directive's delimiter, replacing the standard \"~\"."); + + DefineProperty("fold", &OptionsAsm::fold); + + DefineProperty("fold.asm.syntax.based", &OptionsAsm::foldSyntaxBased, + "Set this property to 0 to disable syntax based folding."); + + DefineProperty("fold.asm.comment.multiline", &OptionsAsm::foldCommentMultiline, + "Set this property to 1 to enable folding multi-line comments."); + + DefineProperty("fold.asm.comment.explicit", &OptionsAsm::foldCommentExplicit, + "This option enables folding explicit fold points when using the Asm lexer. " + "Explicit fold points allows adding extra folding by placing a ;{ comment at the start and a ;} " + "at the end of a section that should fold."); + + DefineProperty("fold.asm.explicit.start", &OptionsAsm::foldExplicitStart, + "The string to use for explicit fold start points, replacing the standard ;{."); + + DefineProperty("fold.asm.explicit.end", &OptionsAsm::foldExplicitEnd, + "The string to use for explicit fold end points, replacing the standard ;}."); + + DefineProperty("fold.asm.explicit.anywhere", &OptionsAsm::foldExplicitAnywhere, + "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); + + DefineProperty("fold.compact", &OptionsAsm::foldCompact); + + DefineProperty("lexer.as.comment.character", &OptionsAsm::commentChar, + "Overrides the default comment character (which is ';' for asm and '#' for as)."); + + DefineWordListSets(asmWordListDesc); + } +}; + +class LexerAsm : public DefaultLexer { + WordList cpuInstruction; + WordList mathInstruction; + WordList registers; + WordList directive; + WordList directiveOperand; + WordList extInstruction; + WordList directives4foldstart; + WordList directives4foldend; + OptionsAsm options; + OptionSetAsm osAsm; + int commentChar; +public: + LexerAsm(const char *languageName_, int language_, int commentChar_) : DefaultLexer(languageName_, language_) { + commentChar = commentChar_; + } + virtual ~LexerAsm() { + } + void SCI_METHOD Release() override { + delete this; + } + int SCI_METHOD Version() const override { + return lvRelease5; + } + const char * SCI_METHOD PropertyNames() override { + return osAsm.PropertyNames(); + } + int SCI_METHOD PropertyType(const char *name) override { + return osAsm.PropertyType(name); + } + const char * SCI_METHOD DescribeProperty(const char *name) override { + return osAsm.DescribeProperty(name); + } + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override; + const char * SCI_METHOD PropertyGet(const char *key) override { + return osAsm.PropertyGet(key); + } + const char * SCI_METHOD DescribeWordListSets() override { + return osAsm.DescribeWordListSets(); + } + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override; + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + + void * SCI_METHOD PrivateCall(int, void *) override { + return 0; + } + + static ILexer5 *LexerFactoryAsm() { + return new LexerAsm("asm", SCLEX_ASM, ';'); + } + + static ILexer5 *LexerFactoryAs() { + return new LexerAsm("as", SCLEX_AS, '#'); + } +}; + +Sci_Position SCI_METHOD LexerAsm::PropertySet(const char *key, const char *val) { + if (osAsm.PropertySet(&options, key, val)) { + return 0; + } + return -1; +} + +Sci_Position SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) { + WordList *wordListN = 0; + switch (n) { + case 0: + wordListN = &cpuInstruction; + break; + case 1: + wordListN = &mathInstruction; + break; + case 2: + wordListN = ®isters; + break; + case 3: + wordListN = &directive; + break; + case 4: + wordListN = &directiveOperand; + break; + case 5: + wordListN = &extInstruction; + break; + case 6: + wordListN = &directives4foldstart; + break; + case 7: + wordListN = &directives4foldend; + break; + } + Sci_Position firstModification = -1; + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + return firstModification; +} + +void SCI_METHOD LexerAsm::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + LexAccessor styler(pAccess); + + const char commentCharacter = options.commentChar.empty() ? + commentChar : options.commentChar.front(); + + // Do not leak onto next line + if (initStyle == SCE_ASM_STRINGEOL) + initStyle = SCE_ASM_DEFAULT; + + StyleContext sc(startPos, length, initStyle, styler); + + for (; sc.More(); sc.Forward()) + { + + // Prevent SCE_ASM_STRINGEOL from leaking back to previous line + if (sc.atLineStart && (sc.state == SCE_ASM_STRING)) { + sc.SetState(SCE_ASM_STRING); + } else if (sc.atLineStart && (sc.state == SCE_ASM_CHARACTER)) { + sc.SetState(SCE_ASM_CHARACTER); + } + + // Handle line continuation generically. + if (sc.ch == '\\') { + if (sc.chNext == '\n' || sc.chNext == '\r') { + sc.Forward(); + if (sc.ch == '\r' && sc.chNext == '\n') { + sc.Forward(); + } + continue; + } + } + + // Determine if the current state should terminate. + if (sc.state == SCE_ASM_OPERATOR) { + if (!IsAsmOperator(sc.ch)) { + sc.SetState(SCE_ASM_DEFAULT); + } + } else if (sc.state == SCE_ASM_NUMBER) { + if (!IsAWordChar(sc.ch)) { + sc.SetState(SCE_ASM_DEFAULT); + } + } else if (sc.state == SCE_ASM_IDENTIFIER) { + if (!IsAWordChar(sc.ch) ) { + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + bool IsDirective = false; + + if (cpuInstruction.InList(s)) { + sc.ChangeState(SCE_ASM_CPUINSTRUCTION); + } else if (mathInstruction.InList(s)) { + sc.ChangeState(SCE_ASM_MATHINSTRUCTION); + } else if (registers.InList(s)) { + sc.ChangeState(SCE_ASM_REGISTER); + } else if (directive.InList(s)) { + sc.ChangeState(SCE_ASM_DIRECTIVE); + IsDirective = true; + } else if (directiveOperand.InList(s)) { + sc.ChangeState(SCE_ASM_DIRECTIVEOPERAND); + } else if (extInstruction.InList(s)) { + sc.ChangeState(SCE_ASM_EXTINSTRUCTION); + } + sc.SetState(SCE_ASM_DEFAULT); + if (IsDirective && !strcmp(s, "comment")) { + char delimiter = options.delimiter.empty() ? '~' : options.delimiter.c_str()[0]; + while (IsASpaceOrTab(sc.ch) && !sc.atLineEnd) { + sc.ForwardSetState(SCE_ASM_DEFAULT); + } + if (sc.ch == delimiter) { + sc.SetState(SCE_ASM_COMMENTDIRECTIVE); + } + } + } + } else if (sc.state == SCE_ASM_COMMENTDIRECTIVE) { + char delimiter = options.delimiter.empty() ? '~' : options.delimiter.c_str()[0]; + if (sc.ch == delimiter) { + while (!sc.atLineEnd) { + sc.Forward(); + } + sc.SetState(SCE_ASM_DEFAULT); + } + } else if (sc.state == SCE_ASM_COMMENT ) { + if (sc.atLineEnd) { + sc.SetState(SCE_ASM_DEFAULT); + } + } else if (sc.state == SCE_ASM_STRING) { + if (sc.ch == '\\') { + if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\"') { + sc.ForwardSetState(SCE_ASM_DEFAULT); + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_ASM_STRINGEOL); + sc.ForwardSetState(SCE_ASM_DEFAULT); + } + } else if (sc.state == SCE_ASM_CHARACTER) { + if (sc.ch == '\\') { + if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\'') { + sc.ForwardSetState(SCE_ASM_DEFAULT); + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_ASM_STRINGEOL); + sc.ForwardSetState(SCE_ASM_DEFAULT); + } + } + + // Determine if a new state should be entered. + if (sc.state == SCE_ASM_DEFAULT) { + if (sc.ch == commentCharacter) { + sc.SetState(SCE_ASM_COMMENT); + } else if (IsASCII(sc.ch) && (isdigit(sc.ch) || (sc.ch == '.' && IsASCII(sc.chNext) && isdigit(sc.chNext)))) { + sc.SetState(SCE_ASM_NUMBER); + } else if (IsAWordStart(sc.ch)) { + sc.SetState(SCE_ASM_IDENTIFIER); + } else if (sc.ch == '\"') { + sc.SetState(SCE_ASM_STRING); + } else if (sc.ch == '\'') { + sc.SetState(SCE_ASM_CHARACTER); + } else if (IsAsmOperator(sc.ch)) { + sc.SetState(SCE_ASM_OPERATOR); + } + } + + } + sc.Complete(); +} + +// Store both the current line's fold level and the next lines in the +// level store to make it easy to pick up with each increment +// and to make it possible to fiddle the current level for "else". + +void SCI_METHOD LexerAsm::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + + if (!options.fold) + return; + + LexAccessor styler(pAccess); + + 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 levelNext = levelCurrent; + char chNext = styler[startPos]; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + char word[100]; + int wordlen = 0; + const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); + for (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 (options.foldCommentMultiline && IsStreamCommentStyle(style)) { + if (!IsStreamCommentStyle(stylePrev)) { + levelNext++; + } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { + // Comments don't end at end of line and the next character may be unstyled. + levelNext--; + } + } + if (options.foldCommentExplicit && ((style == SCE_ASM_COMMENT) || options.foldExplicitAnywhere)) { + if (userDefinedFoldMarkers) { + if (styler.Match(i, options.foldExplicitStart.c_str())) { + levelNext++; + } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { + levelNext--; + } + } else { + if (ch == ';') { + if (chNext == '{') { + levelNext++; + } else if (chNext == '}') { + levelNext--; + } + } + } + } + if (options.foldSyntaxBased && (style == SCE_ASM_DIRECTIVE)) { + word[wordlen++] = static_cast(LowerCase(ch)); + if (wordlen == 100) { // prevent overflow + word[0] = '\0'; + wordlen = 1; + } + if (styleNext != SCE_ASM_DIRECTIVE) { // reading directive ready + word[wordlen] = '\0'; + wordlen = 0; + if (directives4foldstart.InList(word)) { + levelNext++; + } else if (directives4foldend.InList(word)){ + levelNext--; + } + } + } + if (!IsASpace(ch)) + visibleChars++; + if (atEOL || (i == endPos-1)) { + int levelUse = levelCurrent; + int lev = levelUse | levelNext << 16; + if (visibleChars == 0 && options.foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if (levelUse < levelNext) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + levelCurrent = levelNext; + if (atEOL && (i == static_cast(styler.Length() - 1))) { + // There is an empty line at end of file so give it same level and empty + styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); + } + visibleChars = 0; + } + } +} + +LexerModule lmAsm(SCLEX_ASM, LexerAsm::LexerFactoryAsm, "asm", asmWordListDesc); +LexerModule lmAs(SCLEX_AS, LexerAsm::LexerFactoryAs, "as", asmWordListDesc); + diff --git a/Pythonwin/Scintilla/src/LexAsn1.cxx b/Pythonwin/Scintilla/lexers/LexAsn1.cxx similarity index 91% rename from Pythonwin/Scintilla/src/LexAsn1.cxx rename to Pythonwin/Scintilla/lexers/LexAsn1.cxx index 36f1d5dc2..0ec2a0636 100644 --- a/Pythonwin/Scintilla/src/LexAsn1.cxx +++ b/Pythonwin/Scintilla/lexers/LexAsn1.cxx @@ -5,24 +5,25 @@ // Copyright 2004 by Herr Pfarrer rpfarrer yahoo de // Last Updated: 20/07/2004 // The License.txt file describes the conditions under which this software may be distributed. + #include #include -#include #include #include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif // Some char test functions static bool isAsn1Number(int ch) @@ -44,7 +45,7 @@ static bool isAsn1Char(int ch) // Function determining the color of a given code portion // Based on a "state" // -static void ColouriseAsn1Doc(unsigned int startPos, int length, int initStyle, WordList *keywordLists[], Accessor &styler) +static void ColouriseAsn1Doc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordLists[], Accessor &styler) { // The keywords WordList &Keywords = *keywordLists[0]; @@ -165,7 +166,7 @@ static void ColouriseAsn1Doc(unsigned int startPos, int length, int initStyle, W sc.Complete(); } -static void FoldAsn1Doc(unsigned int, int, int, WordList *[], Accessor &styler) +static void FoldAsn1Doc(Sci_PositionU, Sci_Position, int, WordList *[], Accessor &styler) { // No folding enabled, no reason to continue... if( styler.GetPropertyInt("fold") == 0 ) @@ -182,4 +183,4 @@ static const char * const asn1WordLists[] = { 0, }; -LexerModule lmAns1(SCLEX_ASN1, ColouriseAsn1Doc, "asn1", FoldAsn1Doc, asn1WordLists); +LexerModule lmAsn1(SCLEX_ASN1, ColouriseAsn1Doc, "asn1", FoldAsn1Doc, asn1WordLists); diff --git a/Pythonwin/Scintilla/lexers/LexBaan.cxx b/Pythonwin/Scintilla/lexers/LexBaan.cxx new file mode 100644 index 000000000..80b4f40ab --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexBaan.cxx @@ -0,0 +1,992 @@ +// Scintilla source code edit control +/** @file LexBaan.cxx +** Lexer for Baan. +** Based heavily on LexCPP.cxx +**/ +// Copyright 2001- by Vamsi Potluru & Praveen Ambekar +// Maintainer Email: oirfeodent@yahoo.co.in +// The License.txt file describes the conditions under which this software may be distributed. + +// C standard library +#include +#include + +// C++ wrappers of C standard library +#include + +// C++ standard library +#include +#include + +// Scintilla headers + +// Non-platform-specific headers + +// include +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +// lexlib +#include "WordList.h" +#include "LexAccessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" +#include "DefaultLexer.h" + +using namespace Scintilla; + +namespace { +// Use an unnamed namespace to protect the functions and classes from name conflicts + +// Options used for LexerBaan +struct OptionsBaan { + bool fold; + bool foldComment; + bool foldPreprocessor; + bool foldCompact; + bool baanFoldSyntaxBased; + bool baanFoldKeywordsBased; + bool baanFoldSections; + bool baanFoldInnerLevel; + bool baanStylingWithinPreprocessor; + OptionsBaan() { + fold = false; + foldComment = false; + foldPreprocessor = false; + foldCompact = false; + baanFoldSyntaxBased = false; + baanFoldKeywordsBased = false; + baanFoldSections = false; + baanFoldInnerLevel = false; + baanStylingWithinPreprocessor = false; + } +}; + +const char *const baanWordLists[] = { + "Baan & BaanSQL Reserved Keywords ", + "Baan Standard functions", + "Baan Functions Abridged", + "Baan Main Sections ", + "Baan Sub Sections", + "PreDefined Variables", + "PreDefined Attributes", + "Enumerates", + 0, +}; + +struct OptionSetBaan : public OptionSet { + OptionSetBaan() { + DefineProperty("fold", &OptionsBaan::fold); + + DefineProperty("fold.comment", &OptionsBaan::foldComment); + + DefineProperty("fold.preprocessor", &OptionsBaan::foldPreprocessor); + + DefineProperty("fold.compact", &OptionsBaan::foldCompact); + + DefineProperty("fold.baan.syntax.based", &OptionsBaan::baanFoldSyntaxBased, + "Set this property to 0 to disable syntax based folding, which is folding based on '{' & '('."); + + DefineProperty("fold.baan.keywords.based", &OptionsBaan::baanFoldKeywordsBased, + "Set this property to 0 to disable keywords based folding, which is folding based on " + " for, if, on (case), repeat, select, while and fold ends based on endfor, endif, endcase, until, endselect, endwhile respectively." + "Also folds declarations which are grouped together."); + + DefineProperty("fold.baan.sections", &OptionsBaan::baanFoldSections, + "Set this property to 0 to disable folding of Main Sections as well as Sub Sections."); + + DefineProperty("fold.baan.inner.level", &OptionsBaan::baanFoldInnerLevel, + "Set this property to 1 to enable folding of inner levels of select statements." + "Disabled by default. case and if statements are also eligible" ); + + DefineProperty("lexer.baan.styling.within.preprocessor", &OptionsBaan::baanStylingWithinPreprocessor, + "For Baan code, determines whether all preprocessor code is styled in the " + "preprocessor style (0, the default) or only from the initial # to the end " + "of the command word(1)."); + + DefineWordListSets(baanWordLists); + } +}; + +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '$'); +} + +static inline bool IsAnOperator(int ch) { + if (IsAlphaNumeric(ch)) + return false; + if (ch == '#' || ch == '^' || ch == '&' || ch == '*' || + ch == '(' || ch == ')' || ch == '-' || ch == '+' || + ch == '=' || ch == '|' || ch == '{' || ch == '}' || + ch == '[' || ch == ']' || ch == ':' || ch == ';' || + ch == '<' || ch == '>' || ch == ',' || ch == '/' || + ch == '?' || ch == '!' || ch == '"' || ch == '~' || + ch == '\\') + return true; + return false; +} + +static inline int IsAnyOtherIdentifier(char *s, Sci_Position sLength) { + + /* IsAnyOtherIdentifier uses standard templates used in baan. + The matching template is shown as comments just above the return condition. + ^ - refers to any character [a-z]. + # - refers to any number [0-9]. + Other characters shown are compared as is. + Tried implementing with Regex... it was too complicated for me. + Any other implementation suggestion welcome. + */ + switch (sLength) { + case 8: + if (isalpha(s[0]) && isalpha(s[1]) && isalpha(s[2]) && isalpha(s[3]) && isalpha(s[4]) && IsADigit(s[5]) && IsADigit(s[6]) && IsADigit(s[7])) { + //^^^^^### + return(SCE_BAAN_TABLEDEF); + } + break; + case 9: + if (s[0] == 't' && isalpha(s[1]) && isalpha(s[2]) && isalpha(s[3]) && isalpha(s[4]) && isalpha(s[5]) && IsADigit(s[6]) && IsADigit(s[7]) && IsADigit(s[8])) { + //t^^^^^### + return(SCE_BAAN_TABLEDEF); + } + else if (s[8] == '.' && isalpha(s[0]) && isalpha(s[1]) && isalpha(s[2]) && isalpha(s[3]) && isalpha(s[4]) && IsADigit(s[5]) && IsADigit(s[6]) && IsADigit(s[7])) { + //^^^^^###. + return(SCE_BAAN_TABLESQL); + } + break; + case 13: + if (s[8] == '.' && isalpha(s[0]) && isalpha(s[1]) && isalpha(s[2]) && isalpha(s[3]) && isalpha(s[4]) && IsADigit(s[5]) && IsADigit(s[6]) && IsADigit(s[7])) { + //^^^^^###.**** + return(SCE_BAAN_TABLESQL); + } + else if (s[0] == 'r' && s[1] == 'c' && s[2] == 'd' && s[3] == '.' && s[4] == 't' && isalpha(s[5]) && isalpha(s[6]) && isalpha(s[7]) && isalpha(s[8]) && isalpha(s[9]) && IsADigit(s[10]) && IsADigit(s[11]) && IsADigit(s[12])) { + //rcd.t^^^^^### + return(SCE_BAAN_TABLEDEF); + } + break; + case 14: + case 15: + if (s[8] == '.' && isalpha(s[0]) && isalpha(s[1]) && isalpha(s[2]) && isalpha(s[3]) && isalpha(s[4]) && IsADigit(s[5]) && IsADigit(s[6]) && IsADigit(s[7])) { + if (s[13] != ':') { + //^^^^^###.****** + return(SCE_BAAN_TABLESQL); + } + } + break; + case 16: + case 17: + if (s[8] == '.' && s[9] == '_' && s[10] == 'i' && s[11] == 'n' && s[12] == 'd' && s[13] == 'e' && s[14] == 'x' && IsADigit(s[15]) && isalpha(s[0]) && isalpha(s[1]) && isalpha(s[2]) && isalpha(s[3]) && isalpha(s[4]) && IsADigit(s[5]) && IsADigit(s[6]) && IsADigit(s[7])) { + //^^^^^###._index## + return(SCE_BAAN_TABLEDEF); + } + else if (s[8] == '.' && s[9] == '_' && s[10] == 'c' && s[11] == 'o' && s[12] == 'm' && s[13] == 'p' && s[14] == 'n' && s[15] == 'r' && isalpha(s[0]) && isalpha(s[1]) && isalpha(s[2]) && isalpha(s[3]) && isalpha(s[4]) && IsADigit(s[5]) && IsADigit(s[6]) && IsADigit(s[7])) { + //^^^^^###._compnr + return(SCE_BAAN_TABLEDEF); + } + break; + default: + break; + } + if (sLength > 14 && s[5] == '.' && s[6] == 'd' && s[7] == 'l' && s[8] == 'l' && s[13] == '.' && isalpha(s[0]) && isalpha(s[1]) && isalpha(s[2]) && isalpha(s[3]) && isalpha(s[4]) && IsADigit(s[9]) && IsADigit(s[10]) && IsADigit(s[11]) && IsADigit(s[12])) { + //^^^^^.dll####. + return(SCE_BAAN_FUNCTION); + } + else if (sLength > 15 && s[2] == 'i' && s[3] == 'n' && s[4] == 't' && s[5] == '.' && s[6] == 'd' && s[7] == 'l' && s[8] == 'l' && isalpha(s[0]) && isalpha(s[1]) && isalpha(s[9]) && isalpha(s[10]) && isalpha(s[11]) && isalpha(s[12]) && isalpha(s[13])) { + //^^int.dll^^^^^. + return(SCE_BAAN_FUNCTION); + } + else if (sLength > 11 && s[0] == 'i' && s[10] == '.' && isalpha(s[1]) && isalpha(s[2]) && isalpha(s[3]) && isalpha(s[4]) && isalpha(s[5]) && IsADigit(s[6]) && IsADigit(s[7]) && IsADigit(s[8]) && IsADigit(s[9])) { + //i^^^^^####. + return(SCE_BAAN_FUNCTION); + } + + return(SCE_BAAN_DEFAULT); +} + +static bool IsCommentLine(Sci_Position line, LexAccessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + int style = styler.StyleAt(i); + if (ch == '|' && style == SCE_BAAN_COMMENT) + return true; + else if (!IsASpaceOrTab(ch)) + return false; + } + return false; +} + +static bool IsPreProcLine(Sci_Position line, LexAccessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + int style = styler.StyleAt(i); + if (ch == '#' && style == SCE_BAAN_PREPROCESSOR) { + if (styler.Match(i, "#elif") || styler.Match(i, "#else") || styler.Match(i, "#endif") + || styler.Match(i, "#if") || styler.Match(i, "#ifdef") || styler.Match(i, "#ifndef")) + // Above PreProcessors has a seperate fold mechanism. + return false; + else + return true; + } + else if (ch == '^') + return true; + else if (!IsASpaceOrTab(ch)) + return false; + } + return false; +} + +static int mainOrSubSectionLine(Sci_Position line, LexAccessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + int style = styler.StyleAt(i); + if (style == SCE_BAAN_WORD5 || style == SCE_BAAN_WORD4) + return style; + else if (IsASpaceOrTab(ch)) + continue; + else + break; + } + return 0; +} + +static bool priorSectionIsSubSection(Sci_Position line, LexAccessor &styler){ + while (line > 0) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + int style = styler.StyleAt(i); + if (style == SCE_BAAN_WORD4) + return true; + else if (style == SCE_BAAN_WORD5) + return false; + else if (IsASpaceOrTab(ch)) + continue; + else + break; + } + line--; + } + return false; +} + +static bool nextSectionIsSubSection(Sci_Position line, LexAccessor &styler) { + while (line > 0) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + int style = styler.StyleAt(i); + if (style == SCE_BAAN_WORD4) + return true; + else if (style == SCE_BAAN_WORD5) + return false; + else if (IsASpaceOrTab(ch)) + continue; + else + break; + } + line++; + } + return false; +} + +static bool IsDeclarationLine(Sci_Position line, LexAccessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + int style = styler.StyleAt(i); + if (style == SCE_BAAN_WORD) { + if (styler.Match(i, "table") || styler.Match(i, "extern") || styler.Match(i, "long") + || styler.Match(i, "double") || styler.Match(i, "boolean") || styler.Match(i, "string") + || styler.Match(i, "domain")) { + for (Sci_Position j = eol_pos; j > pos; j--) { + int styleFromEnd = styler.StyleAt(j); + if (styleFromEnd == SCE_BAAN_COMMENT) + continue; + else if (IsASpace(styler[j])) + continue; + else if (styler[j] != ',') + //Above conditions ensures, Declaration is not part of any function parameters. + return true; + else + return false; + } + } + else + return false; + } + else if (!IsASpaceOrTab(ch)) + return false; + } + return false; +} + +static bool IsInnerLevelFold(Sci_Position line, LexAccessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + int style = styler.StyleAt(i); + if (style == SCE_BAAN_WORD && (styler.Match(i, "else" ) || styler.Match(i, "case") + || styler.Match(i, "default") || styler.Match(i, "selectdo") || styler.Match(i, "selecteos") + || styler.Match(i, "selectempty") || styler.Match(i, "selecterror"))) + return true; + else if (IsASpaceOrTab(ch)) + continue; + else + return false; + } + return false; +} + +static inline bool wordInArray(const std::string& value, std::string *array, int length) +{ + for (int i = 0; i < length; i++) + { + if (value == array[i]) + { + return true; + } + } + + return false; +} + +class WordListAbridged : public WordList { +public: + WordListAbridged() { + kwAbridged = false; + kwHasSection = false; + }; + ~WordListAbridged() { + Clear(); + }; + bool kwAbridged; + bool kwHasSection; + bool Contains(const char *s) { + return kwAbridged ? InListAbridged(s, '~') : InList(s); + }; +}; + +} + +class LexerBaan : public DefaultLexer { + WordListAbridged keywords; + WordListAbridged keywords2; + WordListAbridged keywords3; + WordListAbridged keywords4; + WordListAbridged keywords5; + WordListAbridged keywords6; + WordListAbridged keywords7; + WordListAbridged keywords8; + WordListAbridged keywords9; + OptionsBaan options; + OptionSetBaan osBaan; +public: + LexerBaan() : DefaultLexer("baan", SCLEX_BAAN) { + } + + virtual ~LexerBaan() { + } + + int SCI_METHOD Version() const override { + return lvRelease5; + } + + void SCI_METHOD Release() override { + delete this; + } + + const char * SCI_METHOD PropertyNames() override { + return osBaan.PropertyNames(); + } + + int SCI_METHOD PropertyType(const char * name) override { + return osBaan.PropertyType(name); + } + + const char * SCI_METHOD DescribeProperty(const char * name) override { + return osBaan.DescribeProperty(name); + } + + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override; + + const char * SCI_METHOD PropertyGet(const char *key) override { + return osBaan.PropertyGet(key); + } + + const char * SCI_METHOD DescribeWordListSets() override { + return osBaan.DescribeWordListSets(); + } + + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override; + + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + + void * SCI_METHOD PrivateCall(int, void *) override { + return NULL; + } + + static ILexer5 * LexerFactoryBaan() { + return new LexerBaan(); + } +}; + +Sci_Position SCI_METHOD LexerBaan::PropertySet(const char *key, const char *val) { + if (osBaan.PropertySet(&options, key, val)) { + return 0; + } + return -1; +} + +Sci_Position SCI_METHOD LexerBaan::WordListSet(int n, const char *wl) { + WordListAbridged *WordListAbridgedN = 0; + switch (n) { + case 0: + WordListAbridgedN = &keywords; + break; + case 1: + WordListAbridgedN = &keywords2; + break; + case 2: + WordListAbridgedN = &keywords3; + break; + case 3: + WordListAbridgedN = &keywords4; + break; + case 4: + WordListAbridgedN = &keywords5; + break; + case 5: + WordListAbridgedN = &keywords6; + break; + case 6: + WordListAbridgedN = &keywords7; + break; + case 7: + WordListAbridgedN = &keywords8; + break; + case 8: + WordListAbridgedN = &keywords9; + break; + } + Sci_Position firstModification = -1; + if (WordListAbridgedN) { + WordListAbridged wlNew; + wlNew.Set(wl); + if (*WordListAbridgedN != wlNew) { + WordListAbridgedN->Set(wl); + WordListAbridgedN->kwAbridged = strchr(wl, '~') != NULL; + WordListAbridgedN->kwHasSection = strchr(wl, ':') != NULL; + + firstModification = 0; + } + } + return firstModification; +} + +void SCI_METHOD LexerBaan::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + + if (initStyle == SCE_BAAN_STRINGEOL) // Does not leak onto next line + initStyle = SCE_BAAN_DEFAULT; + + int visibleChars = 0; + bool lineHasDomain = false; + bool lineHasFunction = false; + bool lineHasPreProc = false; + bool lineIgnoreString = false; + bool lineHasDefines = false; + bool numberIsHex = false; + char word[1000]; + int wordlen = 0; + + std::string preProcessorTags[13] = { "#context_off", "#context_on", + "#define", "#elif", "#else", "#endif", + "#ident", "#if", "#ifdef", "#ifndef", + "#include", "#pragma", "#undef" }; + LexAccessor styler(pAccess); + StyleContext sc(startPos, length, initStyle, styler); + + for (; sc.More(); sc.Forward()) { + + // Determine if the current state should terminate. + switch (sc.state) { + case SCE_BAAN_OPERATOR: + sc.SetState(SCE_BAAN_DEFAULT); + break; + case SCE_BAAN_NUMBER: + if (IsASpaceOrTab(sc.ch) || sc.ch == '\r' || sc.ch == '\n' || IsAnOperator(sc.ch)) { + sc.SetState(SCE_BAAN_DEFAULT); + } + else if ((numberIsHex && !(MakeLowerCase(sc.ch) == 'x' || MakeLowerCase(sc.ch) == 'e' || + IsADigit(sc.ch, 16) || sc.ch == '.' || sc.ch == '-' || sc.ch == '+')) || + (!numberIsHex && !(MakeLowerCase(sc.ch) == 'e' || IsADigit(sc.ch) + || sc.ch == '.' || sc.ch == '-' || sc.ch == '+'))) { + // check '-' for possible -10e-5. Add '+' as well. + numberIsHex = false; + sc.ChangeState(SCE_BAAN_IDENTIFIER); + sc.SetState(SCE_BAAN_DEFAULT); + } + break; + case SCE_BAAN_IDENTIFIER: + if (!IsAWordChar(sc.ch)) { + char s[1000]; + char s1[1000]; + sc.GetCurrentLowered(s, sizeof(s)); + if (sc.ch == ':') { + memcpy(s1, s, sizeof(s)); + s1[sc.LengthCurrent()] = sc.ch; + s1[sc.LengthCurrent() + 1] = '\0'; + } + if ((keywords.kwHasSection && (sc.ch == ':')) ? keywords.Contains(s1) : keywords.Contains(s)) { + sc.ChangeState(SCE_BAAN_WORD); + if (0 == strcmp(s, "domain")) { + lineHasDomain = true; + } + else if (0 == strcmp(s, "function")) { + lineHasFunction = true; + } + } + else if (lineHasDomain) { + sc.ChangeState(SCE_BAAN_DOMDEF); + lineHasDomain = false; + } + else if (lineHasFunction) { + sc.ChangeState(SCE_BAAN_FUNCDEF); + lineHasFunction = false; + } + else if ((keywords2.kwHasSection && (sc.ch == ':')) ? keywords2.Contains(s1) : keywords2.Contains(s)) { + sc.ChangeState(SCE_BAAN_WORD2); + } + else if ((keywords3.kwHasSection && (sc.ch == ':')) ? keywords3.Contains(s1) : keywords3.Contains(s)) { + if (sc.ch == '(') + sc.ChangeState(SCE_BAAN_WORD3); + else + sc.ChangeState(SCE_BAAN_IDENTIFIER); + } + else if ((keywords4.kwHasSection && (sc.ch == ':')) ? keywords4.Contains(s1) : keywords4.Contains(s)) { + sc.ChangeState(SCE_BAAN_WORD4); + } + else if ((keywords5.kwHasSection && (sc.ch == ':')) ? keywords5.Contains(s1) : keywords5.Contains(s)) { + sc.ChangeState(SCE_BAAN_WORD5); + } + else if ((keywords6.kwHasSection && (sc.ch == ':')) ? keywords6.Contains(s1) : keywords6.Contains(s)) { + sc.ChangeState(SCE_BAAN_WORD6); + } + else if ((keywords7.kwHasSection && (sc.ch == ':')) ? keywords7.Contains(s1) : keywords7.Contains(s)) { + sc.ChangeState(SCE_BAAN_WORD7); + } + else if ((keywords8.kwHasSection && (sc.ch == ':')) ? keywords8.Contains(s1) : keywords8.Contains(s)) { + sc.ChangeState(SCE_BAAN_WORD8); + } + else if ((keywords9.kwHasSection && (sc.ch == ':')) ? keywords9.Contains(s1) : keywords9.Contains(s)) { + sc.ChangeState(SCE_BAAN_WORD9); + } + else if (lineHasPreProc) { + sc.ChangeState(SCE_BAAN_OBJECTDEF); + lineHasPreProc = false; + } + else if (lineHasDefines) { + sc.ChangeState(SCE_BAAN_DEFINEDEF); + lineHasDefines = false; + } + else { + int state = IsAnyOtherIdentifier(s, sc.LengthCurrent()); + if (state > 0) { + sc.ChangeState(state); + } + } + sc.SetState(SCE_BAAN_DEFAULT); + } + break; + case SCE_BAAN_PREPROCESSOR: + if (options.baanStylingWithinPreprocessor) { + if (IsASpace(sc.ch) || IsAnOperator(sc.ch)) { + sc.SetState(SCE_BAAN_DEFAULT); + } + } + else { + if (sc.atLineEnd && (sc.chNext != '^')) { + sc.SetState(SCE_BAAN_DEFAULT); + } + } + break; + case SCE_BAAN_COMMENT: + if (sc.ch == '\r' || sc.ch == '\n') { + sc.SetState(SCE_BAAN_DEFAULT); + } + break; + case 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.MatchIgnoreCase("endfunctionusage")) { + for (unsigned int i = 0; i < 15; i++) { + sc.Forward(); + } + sc.ForwardSetState(SCE_BAAN_DEFAULT); + } + break; + case 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_BAAN_DEFAULT); + visibleChars = 0; + } + break; + } + + // Determine if a new state should be entered. + if (sc.state == SCE_BAAN_DEFAULT) { + if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext)) + || ((sc.ch == '-' || sc.ch == '+') && (IsADigit(sc.chNext) || sc.chNext == '.')) + || (MakeLowerCase(sc.ch) == 'e' && (IsADigit(sc.chNext) || sc.chNext == '+' || sc.chNext == '-'))) { + if ((sc.ch == '0' && MakeLowerCase(sc.chNext) == 'x') || + ((sc.ch == '-' || sc.ch == '+') && sc.chNext == '0' && MakeLowerCase(sc.GetRelativeCharacter(2)) == 'x')){ + numberIsHex = true; + } + sc.SetState(SCE_BAAN_NUMBER); + } + else if (sc.MatchIgnoreCase("dllusage") || sc.MatchIgnoreCase("functionusage")) { + sc.SetState(SCE_BAAN_COMMENTDOC); + do { + sc.Forward(); + } while ((!sc.atLineEnd) && sc.More()); + } + else if (iswordstart(sc.ch)) { + sc.SetState(SCE_BAAN_IDENTIFIER); + } + else if (sc.Match('|')) { + sc.SetState(SCE_BAAN_COMMENT); + } + else if (sc.ch == '\"' && !(lineIgnoreString)) { + sc.SetState(SCE_BAAN_STRING); + } + else if (sc.ch == '#' && visibleChars == 0) { + // Preprocessor commands are alone on their line + sc.SetState(SCE_BAAN_PREPROCESSOR); + word[0] = '\0'; + wordlen = 0; + while (sc.More() && !(IsASpace(sc.chNext) || IsAnOperator(sc.chNext))) { + sc.Forward(); + wordlen++; + } + sc.GetCurrentLowered(word, sizeof(word)); + if (!sc.atLineEnd) { + word[wordlen++] = sc.ch; + word[wordlen++] = '\0'; + } + if (!wordInArray(word, preProcessorTags, 13)) + // Colorise only preprocessor built in Baan. + sc.ChangeState(SCE_BAAN_IDENTIFIER); + if (strcmp(word, "#pragma") == 0 || strcmp(word, "#include") == 0) { + lineHasPreProc = true; + lineIgnoreString = true; + } + else if (strcmp(word, "#define") == 0 || strcmp(word, "#undef") == 0 || + strcmp(word, "#ifdef") == 0 || strcmp(word, "#if") == 0 || strcmp(word, "#ifndef") == 0) { + lineHasDefines = true; + lineIgnoreString = false; + } + } + else if (IsAnOperator(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; + lineHasDomain = false; + lineHasFunction = false; + lineHasPreProc = false; + lineIgnoreString = false; + lineHasDefines = false; + numberIsHex = false; + } + if (!IsASpace(sc.ch)) { + visibleChars++; + } + } + sc.Complete(); +} + +void SCI_METHOD LexerBaan::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + if (!options.fold) + return; + + char word[100]; + int wordlen = 0; + bool foldStart = true; + bool foldNextSelect = true; + bool afterFunctionSection = false; + bool beforeDeclarationSection = false; + int currLineStyle = 0; + int nextLineStyle = 0; + + std::string startTags[6] = { "for", "if", "on", "repeat", "select", "while" }; + std::string endTags[6] = { "endcase", "endfor", "endif", "endselect", "endwhile", "until" }; + std::string selectCloseTags[5] = { "selectdo", "selecteos", "selectempty", "selecterror", "endselect" }; + + LexAccessor styler(pAccess); + Sci_PositionU endPos = startPos + length; + int visibleChars = 0; + Sci_Position lineCurrent = styler.GetLine(startPos); + + // Backtrack to previous line in case need to fix its fold status + if (startPos > 0) { + if (lineCurrent > 0) { + lineCurrent--; + startPos = styler.LineStart(lineCurrent); + } + } + + int levelPrev = SC_FOLDLEVELBASE; + if (lineCurrent > 0) + levelPrev = styler.LevelAt(lineCurrent - 1) >> 16; + int levelCurrent = levelPrev; + char chNext = styler[startPos]; + int style = initStyle; + int styleNext = styler.StyleAt(startPos); + + for (Sci_PositionU i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + style = styleNext; + styleNext = styler.StyleAt(i + 1); + int stylePrev = (i) ? styler.StyleAt(i - 1) : SCE_BAAN_DEFAULT; + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + + // Comment folding + if (options.foldComment && style == SCE_BAAN_COMMENTDOC) { + if (style != stylePrev) { + levelCurrent++; + } + else if (style != styleNext) { + levelCurrent--; + } + } + if (options.foldComment && atEOL && IsCommentLine(lineCurrent, styler)) { + if (!IsCommentLine(lineCurrent - 1, styler) + && IsCommentLine(lineCurrent + 1, styler)) + levelCurrent++; + else if (IsCommentLine(lineCurrent - 1, styler) + && !IsCommentLine(lineCurrent + 1, styler)) + levelCurrent--; + } + // PreProcessor Folding + if (options.foldPreprocessor) { + if (atEOL && IsPreProcLine(lineCurrent, styler)) { + if (!IsPreProcLine(lineCurrent - 1, styler) + && IsPreProcLine(lineCurrent + 1, styler)) + levelCurrent++; + else if (IsPreProcLine(lineCurrent - 1, styler) + && !IsPreProcLine(lineCurrent + 1, styler)) + levelCurrent--; + } + else if (style == SCE_BAAN_PREPROCESSOR) { + // folds #ifdef/#if/#ifndef - they are not part of the IsPreProcLine folding. + if (ch == '#') { + if (styler.Match(i, "#ifdef") || styler.Match(i, "#if") || styler.Match(i, "#ifndef") + || styler.Match(i, "#context_on")) + levelCurrent++; + else if (styler.Match(i, "#endif") || styler.Match(i, "#context_off")) + levelCurrent--; + } + } + } + //Syntax Folding + if (options.baanFoldSyntaxBased && (style == SCE_BAAN_OPERATOR)) { + if (ch == '{' || ch == '(') { + levelCurrent++; + } + else if (ch == '}' || ch == ')') { + levelCurrent--; + } + } + //Keywords Folding + if (options.baanFoldKeywordsBased) { + if (atEOL && IsDeclarationLine(lineCurrent, styler)) { + if (!IsDeclarationLine(lineCurrent - 1, styler) + && IsDeclarationLine(lineCurrent + 1, styler)) + levelCurrent++; + else if (IsDeclarationLine(lineCurrent - 1, styler) + && !IsDeclarationLine(lineCurrent + 1, styler)) + levelCurrent--; + } + else if (style == SCE_BAAN_WORD) { + word[wordlen++] = static_cast(MakeLowerCase(ch)); + if (wordlen == 100) { // prevent overflow + word[0] = '\0'; + wordlen = 1; + } + if (styleNext != SCE_BAAN_WORD) { + word[wordlen] = '\0'; + wordlen = 0; + if (strcmp(word, "for") == 0) { + Sci_PositionU j = i + 1; + while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { + j++; + } + if (styler.Match(j, "update")) { + // Means this is a "for update" used by Select which is already folded. + foldStart = false; + } + } + else if (strcmp(word, "on") == 0) { + Sci_PositionU j = i + 1; + while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { + j++; + } + if (!styler.Match(j, "case")) { + // Means this is not a "on Case" statement... could be "on" used by index. + foldStart = false; + } + } + else if (strcmp(word, "select") == 0) { + if (foldNextSelect) { + // Next Selects are sub-clause till reach of selectCloseTags[] array. + foldNextSelect = false; + foldStart = true; + } + else { + foldNextSelect = false; + foldStart = false; + } + } + else if (wordInArray(word, selectCloseTags, 5)) { + // select clause ends, next select clause can be folded. + foldNextSelect = true; + foldStart = true; + } + else { + foldStart = true; + } + if (foldStart) { + if (wordInArray(word, startTags, 6)) { + levelCurrent++; + } + else if (wordInArray(word, endTags, 6)) { + levelCurrent--; + } + } + } + } + } + // Fold inner level of if/select/case statements + if (options.baanFoldInnerLevel && atEOL) { + bool currLineInnerLevel = IsInnerLevelFold(lineCurrent, styler); + bool nextLineInnerLevel = IsInnerLevelFold(lineCurrent + 1, styler); + if (currLineInnerLevel && currLineInnerLevel != nextLineInnerLevel) { + levelCurrent++; + } + else if (nextLineInnerLevel && nextLineInnerLevel != currLineInnerLevel) { + levelCurrent--; + } + } + // Section Foldings. + // One way of implementing Section Foldings, as there is no END markings of sections. + // first section ends on the previous line of next section. + // Re-written whole folding to accomodate this. + if (options.baanFoldSections && atEOL) { + currLineStyle = mainOrSubSectionLine(lineCurrent, styler); + nextLineStyle = mainOrSubSectionLine(lineCurrent + 1, styler); + if (currLineStyle != 0 && currLineStyle != nextLineStyle) { + if (levelCurrent < levelPrev) + --levelPrev; + for (Sci_Position j = styler.LineStart(lineCurrent); j < styler.LineStart(lineCurrent + 1) - 1; j++) { + if (IsASpaceOrTab(styler[j])) + continue; + else if (styler.StyleAt(j) == SCE_BAAN_WORD5) { + if (styler.Match(j, "functions:")) { + // Means functions: is the end of MainSections. + // Nothing to fold after this. + afterFunctionSection = true; + break; + } + else { + afterFunctionSection = false; + break; + } + } + else { + afterFunctionSection = false; + break; + } + } + if (!afterFunctionSection) + levelCurrent++; + } + else if (nextLineStyle != 0 && currLineStyle != nextLineStyle + && (priorSectionIsSubSection(lineCurrent -1 ,styler) + || !nextSectionIsSubSection(lineCurrent + 1, styler))) { + for (Sci_Position j = styler.LineStart(lineCurrent + 1); j < styler.LineStart(lineCurrent + 1 + 1) - 1; j++) { + if (IsASpaceOrTab(styler[j])) + continue; + else if (styler.StyleAt(j) == SCE_BAAN_WORD5) { + if (styler.Match(j, "declaration:")) { + // Means declaration: is the start of MainSections. + // Nothing to fold before this. + beforeDeclarationSection = true; + break; + } + else { + beforeDeclarationSection = false; + break; + } + } + else { + beforeDeclarationSection = false; + break; + } + } + if (!beforeDeclarationSection) { + levelCurrent--; + if (nextLineStyle == SCE_BAAN_WORD5 && priorSectionIsSubSection(lineCurrent-1, styler)) + // next levelCurrent--; is to unfold previous subsection fold. + // On reaching the next main section, the previous main as well sub section ends. + levelCurrent--; + } + } + } + if (atEOL) { + int lev = levelPrev; + lev |= levelCurrent << 16; + if (visibleChars == 0 && options.foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if ((levelCurrent > levelPrev) && (visibleChars > 0)) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + levelPrev = levelCurrent; + visibleChars = 0; + } + if (!isspacechar(ch)) + visibleChars++; + } + int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; + styler.SetLevel(lineCurrent, levelPrev | flagsNext); +} + +LexerModule lmBaan(SCLEX_BAAN, LexerBaan::LexerFactoryBaan, "baan", baanWordLists); diff --git a/Pythonwin/Scintilla/lexers/LexBash.cxx b/Pythonwin/Scintilla/lexers/LexBash.cxx new file mode 100644 index 000000000..07dc6c1ce --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexBash.cxx @@ -0,0 +1,1086 @@ +// Scintilla source code edit control +/** @file LexBash.cxx + ** Lexer for Bash. + **/ +// Copyright 2004-2012 by Neil Hodgson +// Adapted from LexPerl by Kein-Hong Man 2004 +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "StringCopy.h" +#include "WordList.h" +#include "LexAccessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" +#include "SubStyles.h" +#include "DefaultLexer.h" + +using namespace Scintilla; + +#define HERE_DELIM_MAX 256 + +// define this if you want 'invalid octals' to be marked as errors +// usually, this is not a good idea, permissive lexing is better +#undef PEDANTIC_OCTAL + +#define BASH_BASE_ERROR 65 +#define BASH_BASE_DECIMAL 66 +#define BASH_BASE_HEX 67 +#ifdef PEDANTIC_OCTAL +#define BASH_BASE_OCTAL 68 +#define BASH_BASE_OCTAL_ERROR 69 +#endif + +// state constants for parts of a bash command segment +#define BASH_CMD_BODY 0 +#define BASH_CMD_START 1 +#define BASH_CMD_WORD 2 +#define BASH_CMD_TEST 3 +#define BASH_CMD_ARITH 4 +#define BASH_CMD_DELIM 5 + +// state constants for nested delimiter pairs, used by +// SCE_SH_STRING and SCE_SH_BACKTICKS processing +#define BASH_DELIM_LITERAL 0 +#define BASH_DELIM_STRING 1 +#define BASH_DELIM_CSTRING 2 +#define BASH_DELIM_LSTRING 3 +#define BASH_DELIM_COMMAND 4 +#define BASH_DELIM_BACKTICK 5 + +#define BASH_DELIM_STACK_MAX 7 + +namespace { + +inline int translateBashDigit(int ch) { + if (ch >= '0' && ch <= '9') { + return ch - '0'; + } else if (ch >= 'a' && ch <= 'z') { + return ch - 'a' + 10; + } else if (ch >= 'A' && ch <= 'Z') { + return ch - 'A' + 36; + } else if (ch == '@') { + return 62; + } else if (ch == '_') { + return 63; + } + return BASH_BASE_ERROR; +} + +inline int getBashNumberBase(char *s) { + int i = 0; + int base = 0; + while (*s) { + base = base * 10 + (*s++ - '0'); + i++; + } + if (base > 64 || i > 2) { + return BASH_BASE_ERROR; + } + return base; +} + +int opposite(int ch) { + if (ch == '(') return ')'; + if (ch == '[') return ']'; + if (ch == '{') return '}'; + if (ch == '<') return '>'; + return ch; +} + +int GlobScan(StyleContext &sc) { + // forward scan for zsh globs, disambiguate versus bash arrays + // complex expressions may still fail, e.g. unbalanced () '' "" etc + int c, sLen = 0; + int pCount = 0; + int hash = 0; + while ((c = sc.GetRelativeCharacter(++sLen)) != 0) { + if (IsASpace(c)) { + return 0; + } else if (c == '\'' || c == '\"') { + if (hash != 2) return 0; + } else if (c == '#' && hash == 0) { + hash = (sLen == 1) ? 2:1; + } else if (c == '(') { + pCount++; + } else if (c == ')') { + if (pCount == 0) { + if (hash) return sLen; + return 0; + } + pCount--; + } + } + return 0; +} + +bool IsCommentLine(Sci_Position line, LexAccessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + if (ch == '#') + return true; + else if (ch != ' ' && ch != '\t') + return false; + } + return false; +} + +struct OptionsBash { + bool fold; + bool foldComment; + bool foldCompact; + + OptionsBash() { + fold = false; + foldComment = false; + foldCompact = true; + } +}; + +const char * const bashWordListDesc[] = { + "Keywords", + 0 +}; + +struct OptionSetBash : public OptionSet { + OptionSetBash() { + DefineProperty("fold", &OptionsBash::fold); + + DefineProperty("fold.comment", &OptionsBash::foldComment); + + DefineProperty("fold.compact", &OptionsBash::foldCompact); + + DefineWordListSets(bashWordListDesc); + } +}; + +const char styleSubable[] = { SCE_SH_IDENTIFIER, SCE_SH_SCALAR, 0 }; + +LexicalClass lexicalClasses[] = { + // Lexer Bash SCLEX_BASH SCE_SH_: + 0, "SCE_SH_DEFAULT", "default", "White space", + 1, "SCE_SH_ERROR", "error", "Error", + 2, "SCE_SH_COMMENTLINE", "comment line", "Line comment: #", + 3, "SCE_SH_NUMBER", "literal numeric", "Number", + 4, "SCE_SH_WORD", "keyword", "Keyword", + 5, "SCE_SH_STRING", "literal string", "String", + 6, "SCE_SH_CHARACTER", "literal string", "Single quoted string", + 7, "SCE_SH_OPERATOR", "operator", "Operators", + 8, "SCE_SH_IDENTIFIER", "identifier", "Identifiers", + 9, "SCE_SH_SCALAR", "identifier", "Scalar variable", + 10, "SCE_SH_PARAM", "identifier", "Parameter", + 11, "SCE_SH_BACKTICKS", "literal string", "Backtick quoted command", + 12, "SCE_SH_HERE_DELIM", "operator", "Heredoc delimiter", + 13, "SCE_SH_HERE_Q", "literal string", "Heredoc quoted string", +}; + +} + +class LexerBash : public DefaultLexer { + WordList keywords; + OptionsBash options; + OptionSetBash osBash; + enum { ssIdentifier, ssScalar }; + SubStyles subStyles; +public: + LexerBash() : + DefaultLexer("bash", SCLEX_BASH, lexicalClasses, ELEMENTS(lexicalClasses)), + subStyles(styleSubable, 0x80, 0x40, 0) { + } + virtual ~LexerBash() { + } + void SCI_METHOD Release() override { + delete this; + } + int SCI_METHOD Version() const override { + return lvRelease5; + } + const char * SCI_METHOD PropertyNames() override { + return osBash.PropertyNames(); + } + int SCI_METHOD PropertyType(const char* name) override { + return osBash.PropertyType(name); + } + const char * SCI_METHOD DescribeProperty(const char *name) override { + return osBash.DescribeProperty(name); + } + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override; + const char * SCI_METHOD PropertyGet(const char* key) override { + return osBash.PropertyGet(key); + } + const char * SCI_METHOD DescribeWordListSets() override { + return osBash.DescribeWordListSets(); + } + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override; + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + + void * SCI_METHOD PrivateCall(int, void *) override { + return 0; + } + + int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override { + return subStyles.Allocate(styleBase, numberStyles); + } + int SCI_METHOD SubStylesStart(int styleBase) override { + return subStyles.Start(styleBase); + } + int SCI_METHOD SubStylesLength(int styleBase) override { + return subStyles.Length(styleBase); + } + int SCI_METHOD StyleFromSubStyle(int subStyle) override { + const int styleBase = subStyles.BaseStyle(subStyle); + return styleBase; + } + int SCI_METHOD PrimaryStyleFromStyle(int style) override { + return style; + } + void SCI_METHOD FreeSubStyles() override { + subStyles.Free(); + } + void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override { + subStyles.SetIdentifiers(style, identifiers); + } + int SCI_METHOD DistanceToSecondaryStyles() override { + return 0; + } + const char *SCI_METHOD GetSubStyleBases() override { + return styleSubable; + } + + static ILexer5 *LexerFactoryBash() { + return new LexerBash(); + } +}; + +Sci_Position SCI_METHOD LexerBash::PropertySet(const char *key, const char *val) { + if (osBash.PropertySet(&options, key, val)) { + return 0; + } + return -1; +} + +Sci_Position SCI_METHOD LexerBash::WordListSet(int n, const char *wl) { + WordList *wordListN = 0; + switch (n) { + case 0: + wordListN = &keywords; + break; + } + Sci_Position firstModification = -1; + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + return firstModification; +} + +void SCI_METHOD LexerBash::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + WordList cmdDelimiter, bashStruct, bashStruct_in; + cmdDelimiter.Set("| || |& & && ; ;; ( ) { }"); + bashStruct.Set("if elif fi while until else then do done esac eval"); + bashStruct_in.Set("for case select"); + + CharacterSet setWordStart(CharacterSet::setAlpha, "_"); + // note that [+-] are often parts of identifiers in shell scripts + CharacterSet setWord(CharacterSet::setAlphaNum, "._+-"); + CharacterSet setMetaCharacter(CharacterSet::setNone, "|&;()<> \t\r\n"); + setMetaCharacter.Add(0); + CharacterSet setBashOperator(CharacterSet::setNone, "^&%()-+=|{}[]:;>,*/(ch); + Delimiter[DelimiterLength] = '\0'; + } + ~HereDocCls() { + } + }; + HereDocCls HereDoc; + + class QuoteCls { // Class to manage quote pairs (simplified vs LexPerl) + public: + int Count; + int Up, Down; + QuoteCls() { + Count = 0; + Up = '\0'; + Down = '\0'; + } + void Open(int u) { + Count++; + Up = u; + Down = opposite(Up); + } + void Start(int u) { + Count = 0; + Open(u); + } + }; + QuoteCls Quote; + + class QuoteStackCls { // Class to manage quote pairs that nest + public: + int Count; + int Up, Down; + int Style; + int Depth; // levels pushed + int CountStack[BASH_DELIM_STACK_MAX]; + int UpStack [BASH_DELIM_STACK_MAX]; + int StyleStack[BASH_DELIM_STACK_MAX]; + QuoteStackCls() { + Count = 0; + Up = '\0'; + Down = '\0'; + Style = 0; + Depth = 0; + } + void Start(int u, int s) { + Count = 1; + Up = u; + Down = opposite(Up); + Style = s; + } + void Push(int u, int s) { + if (Depth >= BASH_DELIM_STACK_MAX) + return; + CountStack[Depth] = Count; + UpStack [Depth] = Up; + StyleStack[Depth] = Style; + Depth++; + Count = 1; + Up = u; + Down = opposite(Up); + Style = s; + } + void Pop(void) { + if (Depth <= 0) + return; + Depth--; + Count = CountStack[Depth]; + Up = UpStack [Depth]; + Style = StyleStack[Depth]; + Down = opposite(Up); + } + ~QuoteStackCls() { + } + }; + QuoteStackCls QuoteStack; + + const WordClassifier &classifierIdentifiers = subStyles.Classifier(SCE_SH_IDENTIFIER); + const WordClassifier &classifierScalars = subStyles.Classifier(SCE_SH_SCALAR); + + int numBase = 0; + int digit; + Sci_PositionU endPos = startPos + length; + int cmdState = BASH_CMD_START; + int testExprType = 0; + LexAccessor styler(pAccess); + + // Always backtracks to the start of a line that is not a continuation + // of the previous line (i.e. start of a bash command segment) + Sci_Position ln = styler.GetLine(startPos); + if (ln > 0 && startPos == static_cast(styler.LineStart(ln))) + ln--; + for (;;) { + startPos = styler.LineStart(ln); + if (ln == 0 || styler.GetLineState(ln) == BASH_CMD_START) + break; + ln--; + } + initStyle = SCE_SH_DEFAULT; + + StyleContext sc(startPos, endPos - startPos, initStyle, styler); + + for (; sc.More(); sc.Forward()) { + + // handle line continuation, updates per-line stored state + if (sc.atLineStart) { + ln = styler.GetLine(sc.currentPos); + if (sc.state == SCE_SH_STRING + || sc.state == SCE_SH_BACKTICKS + || sc.state == SCE_SH_CHARACTER + || sc.state == SCE_SH_HERE_Q + || sc.state == SCE_SH_COMMENTLINE + || sc.state == SCE_SH_PARAM) { + // force backtrack while retaining cmdState + styler.SetLineState(ln, BASH_CMD_BODY); + } else { + if (ln > 0) { + if ((sc.GetRelative(-3) == '\\' && sc.GetRelative(-2) == '\r' && sc.chPrev == '\n') + || sc.GetRelative(-2) == '\\') { // handle '\' line continuation + // retain last line's state + } else + cmdState = BASH_CMD_START; + } + styler.SetLineState(ln, cmdState); + } + } + + // controls change of cmdState at the end of a non-whitespace element + // states BODY|TEST|ARITH persist until the end of a command segment + // state WORD persist, but ends with 'in' or 'do' construct keywords + int cmdStateNew = BASH_CMD_BODY; + if (cmdState == BASH_CMD_TEST || cmdState == BASH_CMD_ARITH || cmdState == BASH_CMD_WORD) + cmdStateNew = cmdState; + int stylePrev = sc.state; + + // Determine if the current state should terminate. + switch (sc.state) { + case SCE_SH_OPERATOR: + sc.SetState(SCE_SH_DEFAULT); + if (cmdState == BASH_CMD_DELIM) // if command delimiter, start new command + cmdStateNew = BASH_CMD_START; + else if (sc.chPrev == '\\') // propagate command state if line continued + cmdStateNew = cmdState; + break; + case SCE_SH_WORD: + // "." never used in Bash variable names but used in file names + if (!setWord.Contains(sc.ch)) { + char s[500]; + char s2[10]; + sc.GetCurrent(s, sizeof(s)); + int identifierStyle = SCE_SH_IDENTIFIER; + int subStyle = classifierIdentifiers.ValueFor(s); + if (subStyle >= 0) { + identifierStyle = subStyle; + } + // allow keywords ending in a whitespace or command delimiter + s2[0] = static_cast(sc.ch); + s2[1] = '\0'; + bool keywordEnds = IsASpace(sc.ch) || cmdDelimiter.InList(s2); + // 'in' or 'do' may be construct keywords + if (cmdState == BASH_CMD_WORD) { + if (strcmp(s, "in") == 0 && keywordEnds) + cmdStateNew = BASH_CMD_BODY; + else if (strcmp(s, "do") == 0 && keywordEnds) + cmdStateNew = BASH_CMD_START; + else + sc.ChangeState(identifierStyle); + sc.SetState(SCE_SH_DEFAULT); + break; + } + // a 'test' keyword starts a test expression + if (strcmp(s, "test") == 0) { + if (cmdState == BASH_CMD_START && keywordEnds) { + cmdStateNew = BASH_CMD_TEST; + testExprType = 0; + } else + sc.ChangeState(identifierStyle); + } + // detect bash construct keywords + else if (bashStruct.InList(s)) { + if (cmdState == BASH_CMD_START && keywordEnds) + cmdStateNew = BASH_CMD_START; + else + sc.ChangeState(identifierStyle); + } + // 'for'|'case'|'select' needs 'in'|'do' to be highlighted later + else if (bashStruct_in.InList(s)) { + if (cmdState == BASH_CMD_START && keywordEnds) + cmdStateNew = BASH_CMD_WORD; + else + sc.ChangeState(identifierStyle); + } + // disambiguate option items and file test operators + else if (s[0] == '-') { + if (cmdState != BASH_CMD_TEST) + sc.ChangeState(identifierStyle); + } + // disambiguate keywords and identifiers + else if (cmdState != BASH_CMD_START + || !(keywords.InList(s) && keywordEnds)) { + sc.ChangeState(identifierStyle); + } + sc.SetState(SCE_SH_DEFAULT); + } + break; + case SCE_SH_IDENTIFIER: + if (sc.chPrev == '\\' || !setWord.Contains(sc.ch) || + (cmdState == BASH_CMD_ARITH && !setWordStart.Contains(sc.ch))) { + char s[500]; + sc.GetCurrent(s, sizeof(s)); + int subStyle = classifierIdentifiers.ValueFor(s); + if (subStyle >= 0) { + sc.ChangeState(subStyle); + } + if (sc.chPrev == '\\') { // for escaped chars + sc.ForwardSetState(SCE_SH_DEFAULT); + } else { + sc.SetState(SCE_SH_DEFAULT); + } + } + break; + case SCE_SH_NUMBER: + digit = translateBashDigit(sc.ch); + if (numBase == BASH_BASE_DECIMAL) { + if (sc.ch == '#') { + char s[10]; + sc.GetCurrent(s, sizeof(s)); + numBase = getBashNumberBase(s); + if (numBase != BASH_BASE_ERROR) + break; + } else if (IsADigit(sc.ch)) + break; + } else if (numBase == BASH_BASE_HEX) { + if (IsADigit(sc.ch, 16)) + break; +#ifdef PEDANTIC_OCTAL + } else if (numBase == BASH_BASE_OCTAL || + numBase == BASH_BASE_OCTAL_ERROR) { + if (digit <= 7) + break; + if (digit <= 9) { + numBase = BASH_BASE_OCTAL_ERROR; + break; + } +#endif + } else if (numBase == BASH_BASE_ERROR) { + if (digit <= 9) + break; + } else { // DD#DDDD number style handling + if (digit != BASH_BASE_ERROR) { + if (numBase <= 36) { + // case-insensitive if base<=36 + if (digit >= 36) digit -= 26; + } + if (digit < numBase) + break; + if (digit <= 9) { + numBase = BASH_BASE_ERROR; + break; + } + } + } + // fallthrough when number is at an end or error + if (numBase == BASH_BASE_ERROR +#ifdef PEDANTIC_OCTAL + || numBase == BASH_BASE_OCTAL_ERROR +#endif + ) { + sc.ChangeState(SCE_SH_ERROR); + } + sc.SetState(SCE_SH_DEFAULT); + break; + case SCE_SH_COMMENTLINE: + if (sc.atLineEnd && sc.chPrev != '\\') { + sc.SetState(SCE_SH_DEFAULT); + } + break; + case SCE_SH_HERE_DELIM: + // From Bash info: + // --------------- + // Specifier format is: <<[-]WORD + // Optional '-' is for removal of leading tabs from here-doc. + // Whitespace acceptable after <<[-] operator + // + if (HereDoc.State == 0) { // '<<' encountered + HereDoc.Quote = sc.chNext; + HereDoc.Quoted = false; + HereDoc.DelimiterLength = 0; + HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0'; + if (sc.chNext == '\'' || sc.chNext == '\"') { // a quoted here-doc delimiter (' or ") + sc.Forward(); + HereDoc.Quoted = true; + HereDoc.State = 1; + } else if (setHereDoc.Contains(sc.chNext) || + (sc.chNext == '=' && cmdState != BASH_CMD_ARITH)) { + // an unquoted here-doc delimiter, no special handling + HereDoc.State = 1; + } else if (sc.chNext == '<') { // HERE string <<< + sc.Forward(); + sc.ForwardSetState(SCE_SH_DEFAULT); + } else if (IsASpace(sc.chNext)) { + // eat whitespace + } else if (setLeftShift.Contains(sc.chNext) || + (sc.chNext == '=' && cmdState == BASH_CMD_ARITH)) { + // left shift <<$var or <<= cases + sc.ChangeState(SCE_SH_OPERATOR); + sc.ForwardSetState(SCE_SH_DEFAULT); + } else { + // symbols terminates; deprecated zero-length delimiter + HereDoc.State = 1; + } + } else if (HereDoc.State == 1) { // collect the delimiter + // * if single quoted, there's no escape + // * if double quoted, there are \\ and \" escapes + if ((HereDoc.Quote == '\'' && sc.ch != HereDoc.Quote) || + (HereDoc.Quoted && sc.ch != HereDoc.Quote && sc.ch != '\\') || + (HereDoc.Quote != '\'' && sc.chPrev == '\\') || + (setHereDoc2.Contains(sc.ch))) { + HereDoc.Append(sc.ch); + } else if (HereDoc.Quoted && sc.ch == HereDoc.Quote) { // closing quote => end of delimiter + sc.ForwardSetState(SCE_SH_DEFAULT); + } else if (sc.ch == '\\') { + if (HereDoc.Quoted && sc.chNext != HereDoc.Quote && sc.chNext != '\\') { + // in quoted prefixes only \ and the quote eat the escape + HereDoc.Append(sc.ch); + } else { + // skip escape prefix + } + } else if (!HereDoc.Quoted) { + sc.SetState(SCE_SH_DEFAULT); + } + if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup + sc.SetState(SCE_SH_ERROR); + HereDoc.State = 0; + } + } + break; + case SCE_SH_HERE_Q: + // HereDoc.State == 2 + if (sc.atLineStart) { + sc.SetState(SCE_SH_HERE_Q); + int prefixws = 0; + while (sc.ch == '\t' && !sc.atLineEnd) { // tabulation prefix + sc.Forward(); + prefixws++; + } + if (prefixws > 0) + sc.SetState(SCE_SH_HERE_Q); + while (!sc.atLineEnd) { + sc.Forward(); + } + char s[HERE_DELIM_MAX]; + sc.GetCurrent(s, sizeof(s)); + if (sc.LengthCurrent() == 0) { // '' or "" delimiters + if ((prefixws == 0 || HereDoc.Indent) && + HereDoc.Quoted && HereDoc.DelimiterLength == 0) + sc.SetState(SCE_SH_DEFAULT); + break; + } + if (s[strlen(s) - 1] == '\r') + s[strlen(s) - 1] = '\0'; + if (strcmp(HereDoc.Delimiter, s) == 0) { + if ((prefixws == 0) || // indentation rule + (prefixws > 0 && HereDoc.Indent)) { + sc.SetState(SCE_SH_DEFAULT); + break; + } + } + } + break; + case SCE_SH_SCALAR: // variable names + if (!setParam.Contains(sc.ch)) { + char s[500]; + sc.GetCurrent(s, sizeof(s)); + int subStyle = classifierScalars.ValueFor(&s[1]); // skip the $ + if (subStyle >= 0) { + sc.ChangeState(subStyle); + } + if (sc.LengthCurrent() == 1) { + // Special variable: $(, $_ etc. + sc.ForwardSetState(SCE_SH_DEFAULT); + } else { + sc.SetState(SCE_SH_DEFAULT); + } + } + break; + case SCE_SH_STRING: // delimited styles, can nest + case SCE_SH_BACKTICKS: + if (sc.ch == '\\' && QuoteStack.Up != '\\') { + if (QuoteStack.Style != BASH_DELIM_LITERAL) + sc.Forward(); + } else if (sc.ch == QuoteStack.Down) { + QuoteStack.Count--; + if (QuoteStack.Count == 0) { + if (QuoteStack.Depth > 0) { + QuoteStack.Pop(); + } else + sc.ForwardSetState(SCE_SH_DEFAULT); + } + } else if (sc.ch == QuoteStack.Up) { + QuoteStack.Count++; + } else { + if (QuoteStack.Style == BASH_DELIM_STRING || + QuoteStack.Style == BASH_DELIM_LSTRING + ) { // do nesting for "string", $"locale-string" + if (sc.ch == '`') { + QuoteStack.Push(sc.ch, BASH_DELIM_BACKTICK); + } else if (sc.ch == '$' && sc.chNext == '(') { + sc.Forward(); + QuoteStack.Push(sc.ch, BASH_DELIM_COMMAND); + } + } else if (QuoteStack.Style == BASH_DELIM_COMMAND || + QuoteStack.Style == BASH_DELIM_BACKTICK + ) { // do nesting for $(command), `command` + if (sc.ch == '\'') { + QuoteStack.Push(sc.ch, BASH_DELIM_LITERAL); + } else if (sc.ch == '\"') { + QuoteStack.Push(sc.ch, BASH_DELIM_STRING); + } else if (sc.ch == '`') { + QuoteStack.Push(sc.ch, BASH_DELIM_BACKTICK); + } else if (sc.ch == '$') { + if (sc.chNext == '\'') { + sc.Forward(); + QuoteStack.Push(sc.ch, BASH_DELIM_CSTRING); + } else if (sc.chNext == '\"') { + sc.Forward(); + QuoteStack.Push(sc.ch, BASH_DELIM_LSTRING); + } else if (sc.chNext == '(') { + sc.Forward(); + QuoteStack.Push(sc.ch, BASH_DELIM_COMMAND); + } + } + } + } + break; + case SCE_SH_PARAM: // ${parameter} + if (sc.ch == '\\' && Quote.Up != '\\') { + sc.Forward(); + } else if (sc.ch == Quote.Down) { + Quote.Count--; + if (Quote.Count == 0) { + sc.ForwardSetState(SCE_SH_DEFAULT); + } + } else if (sc.ch == Quote.Up) { + Quote.Count++; + } + break; + case SCE_SH_CHARACTER: // singly-quoted strings + if (sc.ch == Quote.Down) { + Quote.Count--; + if (Quote.Count == 0) { + sc.ForwardSetState(SCE_SH_DEFAULT); + } + } + break; + } + + // Must check end of HereDoc state 1 before default state is handled + if (HereDoc.State == 1 && sc.atLineEnd) { + // Begin of here-doc (the line after the here-doc delimiter): + // Lexically, the here-doc starts from the next line after the >>, but the + // first line of here-doc seem to follow the style of the last EOL sequence + HereDoc.State = 2; + if (HereDoc.Quoted) { + if (sc.state == SCE_SH_HERE_DELIM) { + // Missing quote at end of string! Syntax error in bash 4.3 + // Mark this bit as an error, do not colour any here-doc + sc.ChangeState(SCE_SH_ERROR); + sc.SetState(SCE_SH_DEFAULT); + } else { + // HereDoc.Quote always == '\'' + sc.SetState(SCE_SH_HERE_Q); + } + } else if (HereDoc.DelimiterLength == 0) { + // no delimiter, illegal (but '' and "" are legal) + sc.ChangeState(SCE_SH_ERROR); + sc.SetState(SCE_SH_DEFAULT); + } else { + sc.SetState(SCE_SH_HERE_Q); + } + } + + // update cmdState about the current command segment + if (stylePrev != SCE_SH_DEFAULT && sc.state == SCE_SH_DEFAULT) { + cmdState = cmdStateNew; + } + // Determine if a new state should be entered. + if (sc.state == SCE_SH_DEFAULT) { + if (sc.ch == '\\') { + // Bash can escape any non-newline as a literal + sc.SetState(SCE_SH_IDENTIFIER); + if (sc.chNext == '\r' || sc.chNext == '\n') + sc.SetState(SCE_SH_OPERATOR); + } else if (IsADigit(sc.ch)) { + sc.SetState(SCE_SH_NUMBER); + numBase = BASH_BASE_DECIMAL; + if (sc.ch == '0') { // hex,octal + if (sc.chNext == 'x' || sc.chNext == 'X') { + numBase = BASH_BASE_HEX; + sc.Forward(); + } else if (IsADigit(sc.chNext)) { +#ifdef PEDANTIC_OCTAL + numBase = BASH_BASE_OCTAL; +#else + numBase = BASH_BASE_HEX; +#endif + } + } + } else if (setWordStart.Contains(sc.ch)) { + sc.SetState(SCE_SH_WORD); + } else if (sc.ch == '#') { + if (stylePrev != SCE_SH_WORD && stylePrev != SCE_SH_IDENTIFIER && + (sc.currentPos == 0 || setMetaCharacter.Contains(sc.chPrev))) { + sc.SetState(SCE_SH_COMMENTLINE); + } else { + sc.SetState(SCE_SH_WORD); + } + // handle some zsh features within arithmetic expressions only + if (cmdState == BASH_CMD_ARITH) { + if (sc.chPrev == '[') { // [#8] [##8] output digit setting + sc.SetState(SCE_SH_WORD); + if (sc.chNext == '#') { + sc.Forward(); + } + } else if (sc.Match("##^") && IsUpperCase(sc.GetRelative(3))) { // ##^A + sc.SetState(SCE_SH_IDENTIFIER); + sc.Forward(3); + } else if (sc.chNext == '#' && !IsASpace(sc.GetRelative(2))) { // ##a + sc.SetState(SCE_SH_IDENTIFIER); + sc.Forward(2); + } else if (setWordStart.Contains(sc.chNext)) { // #name + sc.SetState(SCE_SH_IDENTIFIER); + } + } + } else if (sc.ch == '\"') { + sc.SetState(SCE_SH_STRING); + QuoteStack.Start(sc.ch, BASH_DELIM_STRING); + } else if (sc.ch == '\'') { + sc.SetState(SCE_SH_CHARACTER); + Quote.Start(sc.ch); + } else if (sc.ch == '`') { + sc.SetState(SCE_SH_BACKTICKS); + QuoteStack.Start(sc.ch, BASH_DELIM_BACKTICK); + } else if (sc.ch == '$') { + if (sc.Match("$((")) { + sc.SetState(SCE_SH_OPERATOR); // handle '((' later + continue; + } + sc.SetState(SCE_SH_SCALAR); + sc.Forward(); + if (sc.ch == '{') { + sc.ChangeState(SCE_SH_PARAM); + Quote.Start(sc.ch); + } else if (sc.ch == '\'') { + sc.ChangeState(SCE_SH_STRING); + QuoteStack.Start(sc.ch, BASH_DELIM_CSTRING); + } else if (sc.ch == '"') { + sc.ChangeState(SCE_SH_STRING); + QuoteStack.Start(sc.ch, BASH_DELIM_LSTRING); + } else if (sc.ch == '(') { + sc.ChangeState(SCE_SH_BACKTICKS); + QuoteStack.Start(sc.ch, BASH_DELIM_COMMAND); + } else if (sc.ch == '`') { // $` seen in a configure script, valid? + sc.ChangeState(SCE_SH_BACKTICKS); + QuoteStack.Start(sc.ch, BASH_DELIM_BACKTICK); + } else { + continue; // scalar has no delimiter pair + } + } else if (sc.Match('<', '<')) { + sc.SetState(SCE_SH_HERE_DELIM); + HereDoc.State = 0; + if (sc.GetRelative(2) == '-') { // <<- indent case + HereDoc.Indent = true; + sc.Forward(); + } else { + HereDoc.Indent = false; + } + } else if (sc.ch == '-' && // one-char file test operators + setSingleCharOp.Contains(sc.chNext) && + !setWord.Contains(sc.GetRelative(2)) && + IsASpace(sc.chPrev)) { + sc.SetState(SCE_SH_WORD); + sc.Forward(); + } else if (setBashOperator.Contains(sc.ch)) { + char s[10]; + bool isCmdDelim = false; + sc.SetState(SCE_SH_OPERATOR); + // globs have no whitespace, do not appear in arithmetic expressions + if (cmdState != BASH_CMD_ARITH && sc.ch == '(' && sc.chNext != '(') { + int i = GlobScan(sc); + if (i > 1) { + sc.SetState(SCE_SH_IDENTIFIER); + sc.Forward(i); + continue; + } + } + // handle opening delimiters for test/arithmetic expressions - ((,[[,[ + if (cmdState == BASH_CMD_START + || cmdState == BASH_CMD_BODY) { + if (sc.Match('(', '(')) { + cmdState = BASH_CMD_ARITH; + sc.Forward(); + } else if (sc.Match('[', '[') && IsASpace(sc.GetRelative(2))) { + cmdState = BASH_CMD_TEST; + testExprType = 1; + sc.Forward(); + } else if (sc.ch == '[' && IsASpace(sc.chNext)) { + cmdState = BASH_CMD_TEST; + testExprType = 2; + } + } + // special state -- for ((x;y;z)) in ... looping + if (cmdState == BASH_CMD_WORD && sc.Match('(', '(')) { + cmdState = BASH_CMD_ARITH; + sc.Forward(); + continue; + } + // handle command delimiters in command START|BODY|WORD state, also TEST if 'test' + if (cmdState == BASH_CMD_START + || cmdState == BASH_CMD_BODY + || cmdState == BASH_CMD_WORD + || (cmdState == BASH_CMD_TEST && testExprType == 0)) { + s[0] = static_cast(sc.ch); + if (setBashOperator.Contains(sc.chNext)) { + s[1] = static_cast(sc.chNext); + s[2] = '\0'; + isCmdDelim = cmdDelimiter.InList(s); + if (isCmdDelim) + sc.Forward(); + } + if (!isCmdDelim) { + s[1] = '\0'; + isCmdDelim = cmdDelimiter.InList(s); + } + if (isCmdDelim) { + cmdState = BASH_CMD_DELIM; + continue; + } + } + // handle closing delimiters for test/arithmetic expressions - )),]],] + if (cmdState == BASH_CMD_ARITH && sc.Match(')', ')')) { + cmdState = BASH_CMD_BODY; + sc.Forward(); + } else if (cmdState == BASH_CMD_TEST && IsASpace(sc.chPrev)) { + if (sc.Match(']', ']') && testExprType == 1) { + sc.Forward(); + cmdState = BASH_CMD_BODY; + } else if (sc.ch == ']' && testExprType == 2) { + cmdState = BASH_CMD_BODY; + } + } + } + }// sc.state + } + sc.Complete(); + if (sc.state == SCE_SH_HERE_Q) { + styler.ChangeLexerState(sc.currentPos, styler.Length()); + } + sc.Complete(); +} + +void SCI_METHOD LexerBash::Fold(Sci_PositionU startPos, Sci_Position length, int, IDocument *pAccess) { + if(!options.fold) + return; + + LexAccessor styler(pAccess); + + Sci_PositionU endPos = startPos + length; + int visibleChars = 0; + int skipHereCh = 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); + char word[8] = { '\0' }; // we're not interested in long words anyway + unsigned int wordlen = 0; + for (Sci_PositionU i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + int style = styleNext; + styleNext = styler.StyleAt(i + 1); + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + // Comment folding + if (options.foldComment && atEOL && IsCommentLine(lineCurrent, styler)) + { + if (!IsCommentLine(lineCurrent - 1, styler) + && IsCommentLine(lineCurrent + 1, styler)) + levelCurrent++; + else if (IsCommentLine(lineCurrent - 1, styler) + && !IsCommentLine(lineCurrent + 1, styler)) + levelCurrent--; + } + if (style == SCE_SH_WORD) { + if ((wordlen + 1) < sizeof(word)) + word[wordlen++] = ch; + if (styleNext != style) { + word[wordlen] = '\0'; + wordlen = 0; + if (strcmp(word, "if") == 0 || strcmp(word, "case") == 0 || strcmp(word, "do") == 0) { + levelCurrent++; + } else if (strcmp(word, "fi") == 0 || strcmp(word, "esac") == 0 || strcmp(word, "done") == 0) { + levelCurrent--; + } + } + } + if (style == SCE_SH_OPERATOR) { + if (ch == '{') { + levelCurrent++; + } else if (ch == '}') { + levelCurrent--; + } + } + // Here Document folding + if (style == SCE_SH_HERE_DELIM) { + if (ch == '<' && chNext == '<') { + if (styler.SafeGetCharAt(i + 2) == '<') { + skipHereCh = 1; + } else { + if (skipHereCh == 0) { + levelCurrent++; + } else { + skipHereCh = 0; + } + } + } + } else if (style == SCE_SH_HERE_Q && styler.StyleAt(i+1) == SCE_SH_DEFAULT) { + levelCurrent--; + } + if (atEOL) { + int lev = levelPrev; + if (visibleChars == 0 && options.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 lmBash(SCLEX_BASH, LexerBash::LexerFactoryBash, "bash", bashWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexBasic.cxx b/Pythonwin/Scintilla/lexers/LexBasic.cxx new file mode 100644 index 000000000..e9004b1a1 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexBasic.cxx @@ -0,0 +1,570 @@ +// Scintilla source code edit control +/** @file LexBasic.cxx + ** Lexer for BlitzBasic and PureBasic. + ** Converted to lexer object and added further folding features/properties by "Udo Lechner" + **/ +// Copyright 1998-2003 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +// This tries to be a unified Lexer/Folder for all the BlitzBasic/BlitzMax/PurBasic basics +// and derivatives. Once they diverge enough, might want to split it into multiple +// lexers for more code clearity. +// +// Mail me (elias users sf net) for any bugs. + +// Folding only works for simple things like functions or types. + +// You may want to have a look at my ctags lexer as well, if you additionally to coloring +// and folding need to extract things like label tags in your editor. + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" +#include "DefaultLexer.h" + +using namespace Scintilla; + +/* Bits: + * 1 - whitespace + * 2 - operator + * 4 - identifier + * 8 - decimal digit + * 16 - hex digit + * 32 - bin digit + * 64 - letter + */ +static int character_classification[128] = +{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10, 2, + 60, 60, 28, 28, 28, 28, 28, 28, 28, 28, 2, 2, 2, 2, 2, 2, + 2, 84, 84, 84, 84, 84, 84, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 2, 2, 2, 2, 68, + 2, 84, 84, 84, 84, 84, 84, 68, 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 2, 2, 2, 2, 0 +}; + +static bool IsSpace(int c) { + return c < 128 && (character_classification[c] & 1); +} + +static bool IsOperator(int c) { + return c < 128 && (character_classification[c] & 2); +} + +static bool IsIdentifier(int c) { + return c < 128 && (character_classification[c] & 4); +} + +static bool IsDigit(int c) { + return c < 128 && (character_classification[c] & 8); +} + +static bool IsHexDigit(int c) { + return c < 128 && (character_classification[c] & 16); +} + +static bool IsBinDigit(int c) { + return c < 128 && (character_classification[c] & 32); +} + +static bool IsLetter(int c) { + return c < 128 && (character_classification[c] & 64); +} + +static int LowerCase(int c) +{ + if (c >= 'A' && c <= 'Z') + return 'a' + c - 'A'; + return c; +} + +static int CheckBlitzFoldPoint(char const *token, int &level) { + if (!strcmp(token, "function") || + !strcmp(token, "type")) { + level |= SC_FOLDLEVELHEADERFLAG; + return 1; + } + if (!strcmp(token, "end function") || + !strcmp(token, "end type")) { + return -1; + } + return 0; +} + +static int CheckPureFoldPoint(char const *token, int &level) { + if (!strcmp(token, "procedure") || + !strcmp(token, "enumeration") || + !strcmp(token, "interface") || + !strcmp(token, "structure")) { + level |= SC_FOLDLEVELHEADERFLAG; + return 1; + } + if (!strcmp(token, "endprocedure") || + !strcmp(token, "endenumeration") || + !strcmp(token, "endinterface") || + !strcmp(token, "endstructure")) { + return -1; + } + return 0; +} + +static int CheckFreeFoldPoint(char const *token, int &level) { + if (!strcmp(token, "function") || + !strcmp(token, "sub") || + !strcmp(token, "enum") || + !strcmp(token, "type") || + !strcmp(token, "union") || + !strcmp(token, "property") || + !strcmp(token, "destructor") || + !strcmp(token, "constructor")) { + level |= SC_FOLDLEVELHEADERFLAG; + return 1; + } + if (!strcmp(token, "end function") || + !strcmp(token, "end sub") || + !strcmp(token, "end enum") || + !strcmp(token, "end type") || + !strcmp(token, "end union") || + !strcmp(token, "end property") || + !strcmp(token, "end destructor") || + !strcmp(token, "end constructor")) { + return -1; + } + return 0; +} + +// An individual named option for use in an OptionSet + +// Options used for LexerBasic +struct OptionsBasic { + bool fold; + bool foldSyntaxBased; + bool foldCommentExplicit; + std::string foldExplicitStart; + std::string foldExplicitEnd; + bool foldExplicitAnywhere; + bool foldCompact; + OptionsBasic() { + fold = false; + foldSyntaxBased = true; + foldCommentExplicit = false; + foldExplicitStart = ""; + foldExplicitEnd = ""; + foldExplicitAnywhere = false; + foldCompact = true; + } +}; + +static const char * const blitzbasicWordListDesc[] = { + "BlitzBasic Keywords", + "user1", + "user2", + "user3", + 0 +}; + +static const char * const purebasicWordListDesc[] = { + "PureBasic Keywords", + "PureBasic PreProcessor Keywords", + "user defined 1", + "user defined 2", + 0 +}; + +static const char * const freebasicWordListDesc[] = { + "FreeBasic Keywords", + "FreeBasic PreProcessor Keywords", + "user defined 1", + "user defined 2", + 0 +}; + +struct OptionSetBasic : public OptionSet { + OptionSetBasic(const char * const wordListDescriptions[]) { + DefineProperty("fold", &OptionsBasic::fold); + + DefineProperty("fold.basic.syntax.based", &OptionsBasic::foldSyntaxBased, + "Set this property to 0 to disable syntax based folding."); + + DefineProperty("fold.basic.comment.explicit", &OptionsBasic::foldCommentExplicit, + "This option enables folding explicit fold points when using the Basic lexer. " + "Explicit fold points allows adding extra folding by placing a ;{ (BB/PB) or '{ (FB) comment at the start " + "and a ;} (BB/PB) or '} (FB) at the end of a section that should be folded."); + + DefineProperty("fold.basic.explicit.start", &OptionsBasic::foldExplicitStart, + "The string to use for explicit fold start points, replacing the standard ;{ (BB/PB) or '{ (FB)."); + + DefineProperty("fold.basic.explicit.end", &OptionsBasic::foldExplicitEnd, + "The string to use for explicit fold end points, replacing the standard ;} (BB/PB) or '} (FB)."); + + DefineProperty("fold.basic.explicit.anywhere", &OptionsBasic::foldExplicitAnywhere, + "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); + + DefineProperty("fold.compact", &OptionsBasic::foldCompact); + + DefineWordListSets(wordListDescriptions); + } +}; + +class LexerBasic : public DefaultLexer { + char comment_char; + int (*CheckFoldPoint)(char const *, int &); + WordList keywordlists[4]; + OptionsBasic options; + OptionSetBasic osBasic; +public: + LexerBasic(const char *languageName_, int language_, char comment_char_, + int (*CheckFoldPoint_)(char const *, int &), const char * const wordListDescriptions[]) : + DefaultLexer(languageName_, language_), + comment_char(comment_char_), + CheckFoldPoint(CheckFoldPoint_), + osBasic(wordListDescriptions) { + } + virtual ~LexerBasic() { + } + void SCI_METHOD Release() override { + delete this; + } + int SCI_METHOD Version() const override { + return lvRelease5; + } + const char * SCI_METHOD PropertyNames() override { + return osBasic.PropertyNames(); + } + int SCI_METHOD PropertyType(const char *name) override { + return osBasic.PropertyType(name); + } + const char * SCI_METHOD DescribeProperty(const char *name) override { + return osBasic.DescribeProperty(name); + } + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override; + const char * SCI_METHOD PropertyGet(const char *key) override { + return osBasic.PropertyGet(key); + } + const char * SCI_METHOD DescribeWordListSets() override { + return osBasic.DescribeWordListSets(); + } + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override; + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + + void * SCI_METHOD PrivateCall(int, void *) override { + return 0; + } + static ILexer5 *LexerFactoryBlitzBasic() { + return new LexerBasic("blitzbasic", SCLEX_BLITZBASIC, ';', CheckBlitzFoldPoint, blitzbasicWordListDesc); + } + static ILexer5 *LexerFactoryPureBasic() { + return new LexerBasic("purebasic", SCLEX_PUREBASIC, ';', CheckPureFoldPoint, purebasicWordListDesc); + } + static ILexer5 *LexerFactoryFreeBasic() { + return new LexerBasic("freebasic", SCLEX_FREEBASIC, '\'', CheckFreeFoldPoint, freebasicWordListDesc ); + } +}; + +Sci_Position SCI_METHOD LexerBasic::PropertySet(const char *key, const char *val) { + if (osBasic.PropertySet(&options, key, val)) { + return 0; + } + return -1; +} + +Sci_Position SCI_METHOD LexerBasic::WordListSet(int n, const char *wl) { + WordList *wordListN = 0; + switch (n) { + case 0: + wordListN = &keywordlists[0]; + break; + case 1: + wordListN = &keywordlists[1]; + break; + case 2: + wordListN = &keywordlists[2]; + break; + case 3: + wordListN = &keywordlists[3]; + break; + } + Sci_Position firstModification = -1; + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + return firstModification; +} + +void SCI_METHOD LexerBasic::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + LexAccessor styler(pAccess); + + bool wasfirst = true, isfirst = true; // true if first token in a line + styler.StartAt(startPos); + int styleBeforeKeyword = SCE_B_DEFAULT; + + StyleContext sc(startPos, length, initStyle, styler); + + // Can't use sc.More() here else we miss the last character + for (; ; sc.Forward()) { + if (sc.state == SCE_B_IDENTIFIER) { + if (!IsIdentifier(sc.ch)) { + // Labels + if (wasfirst && sc.Match(':')) { + sc.ChangeState(SCE_B_LABEL); + sc.ForwardSetState(SCE_B_DEFAULT); + } else { + char s[100]; + int kstates[4] = { + SCE_B_KEYWORD, + SCE_B_KEYWORD2, + SCE_B_KEYWORD3, + SCE_B_KEYWORD4, + }; + sc.GetCurrentLowered(s, sizeof(s)); + for (int i = 0; i < 4; i++) { + if (keywordlists[i].InList(s)) { + sc.ChangeState(kstates[i]); + } + } + // Types, must set them as operator else they will be + // matched as number/constant + if (sc.Match('.') || sc.Match('$') || sc.Match('%') || + sc.Match('#')) { + sc.SetState(SCE_B_OPERATOR); + } else { + sc.SetState(SCE_B_DEFAULT); + } + } + } + } else if (sc.state == SCE_B_OPERATOR) { + if (!IsOperator(sc.ch) || sc.Match('#')) + sc.SetState(SCE_B_DEFAULT); + } else if (sc.state == SCE_B_LABEL) { + if (!IsIdentifier(sc.ch)) + sc.SetState(SCE_B_DEFAULT); + } else if (sc.state == SCE_B_CONSTANT) { + if (!IsIdentifier(sc.ch)) + sc.SetState(SCE_B_DEFAULT); + } else if (sc.state == SCE_B_NUMBER) { + if (!IsDigit(sc.ch)) + sc.SetState(SCE_B_DEFAULT); + } else if (sc.state == SCE_B_HEXNUMBER) { + if (!IsHexDigit(sc.ch)) + sc.SetState(SCE_B_DEFAULT); + } else if (sc.state == SCE_B_BINNUMBER) { + if (!IsBinDigit(sc.ch)) + sc.SetState(SCE_B_DEFAULT); + } else if (sc.state == SCE_B_STRING) { + if (sc.ch == '"') { + sc.ForwardSetState(SCE_B_DEFAULT); + } + if (sc.atLineEnd) { + sc.ChangeState(SCE_B_ERROR); + sc.SetState(SCE_B_DEFAULT); + } + } else if (sc.state == SCE_B_COMMENT || sc.state == SCE_B_PREPROCESSOR) { + if (sc.atLineEnd) { + sc.SetState(SCE_B_DEFAULT); + } + } else if (sc.state == SCE_B_DOCLINE) { + if (sc.atLineEnd) { + sc.SetState(SCE_B_DEFAULT); + } else if (sc.ch == '\\' || sc.ch == '@') { + if (IsLetter(sc.chNext) && sc.chPrev != '\\') { + styleBeforeKeyword = sc.state; + sc.SetState(SCE_B_DOCKEYWORD); + }; + } + } else if (sc.state == SCE_B_DOCKEYWORD) { + if (IsSpace(sc.ch)) { + sc.SetState(styleBeforeKeyword); + } else if (sc.atLineEnd && styleBeforeKeyword == SCE_B_DOCLINE) { + sc.SetState(SCE_B_DEFAULT); + } + } else if (sc.state == SCE_B_COMMENTBLOCK) { + if (sc.Match("\'/")) { + sc.Forward(); + sc.ForwardSetState(SCE_B_DEFAULT); + } + } else if (sc.state == SCE_B_DOCBLOCK) { + if (sc.Match("\'/")) { + sc.Forward(); + sc.ForwardSetState(SCE_B_DEFAULT); + } else if (sc.ch == '\\' || sc.ch == '@') { + if (IsLetter(sc.chNext) && sc.chPrev != '\\') { + styleBeforeKeyword = sc.state; + sc.SetState(SCE_B_DOCKEYWORD); + }; + } + } + + if (sc.atLineStart) + isfirst = true; + + if (sc.state == SCE_B_DEFAULT || sc.state == SCE_B_ERROR) { + if (isfirst && sc.Match('.') && comment_char != '\'') { + sc.SetState(SCE_B_LABEL); + } else if (isfirst && sc.Match('#')) { + wasfirst = isfirst; + sc.SetState(SCE_B_IDENTIFIER); + } else if (sc.Match(comment_char)) { + // Hack to make deprecated QBASIC '$Include show + // up in freebasic with SCE_B_PREPROCESSOR. + if (comment_char == '\'' && sc.Match(comment_char, '$')) + sc.SetState(SCE_B_PREPROCESSOR); + else if (sc.Match("\'*") || sc.Match("\'!")) { + sc.SetState(SCE_B_DOCLINE); + } else { + sc.SetState(SCE_B_COMMENT); + } + } else if (sc.Match("/\'")) { + if (sc.Match("/\'*") || sc.Match("/\'!")) { // Support of gtk-doc/Doxygen doc. style + sc.SetState(SCE_B_DOCBLOCK); + } else { + sc.SetState(SCE_B_COMMENTBLOCK); + } + sc.Forward(); // Eat the ' so it isn't used for the end of the comment + } else if (sc.Match('"')) { + sc.SetState(SCE_B_STRING); + } else if (IsDigit(sc.ch)) { + sc.SetState(SCE_B_NUMBER); + } else if (sc.Match('$') || sc.Match("&h") || sc.Match("&H") || sc.Match("&o") || sc.Match("&O")) { + sc.SetState(SCE_B_HEXNUMBER); + } else if (sc.Match('%') || sc.Match("&b") || sc.Match("&B")) { + sc.SetState(SCE_B_BINNUMBER); + } else if (sc.Match('#')) { + sc.SetState(SCE_B_CONSTANT); + } else if (IsOperator(sc.ch)) { + sc.SetState(SCE_B_OPERATOR); + } else if (IsIdentifier(sc.ch)) { + wasfirst = isfirst; + sc.SetState(SCE_B_IDENTIFIER); + } else if (!IsSpace(sc.ch)) { + sc.SetState(SCE_B_ERROR); + } + } + + if (!IsSpace(sc.ch)) + isfirst = false; + + if (!sc.More()) + break; + } + sc.Complete(); +} + + +void SCI_METHOD LexerBasic::Fold(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, IDocument *pAccess) { + + if (!options.fold) + return; + + LexAccessor styler(pAccess); + + Sci_Position line = styler.GetLine(startPos); + int level = styler.LevelAt(line); + int go = 0, done = 0; + Sci_Position endPos = startPos + length; + char word[256]; + int wordlen = 0; + const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); + int cNext = styler[startPos]; + + // Scan for tokens at the start of the line (they may include + // whitespace, for tokens like "End Function" + for (Sci_Position i = startPos; i < endPos; i++) { + int c = cNext; + cNext = styler.SafeGetCharAt(i + 1); + bool atEOL = (c == '\r' && cNext != '\n') || (c == '\n'); + if (options.foldSyntaxBased && !done && !go) { + if (wordlen) { // are we scanning a token already? + word[wordlen] = static_cast(LowerCase(c)); + if (!IsIdentifier(c)) { // done with token + word[wordlen] = '\0'; + go = CheckFoldPoint(word, level); + if (!go) { + // Treat any whitespace as single blank, for + // things like "End Function". + if (IsSpace(c) && IsIdentifier(word[wordlen - 1])) { + word[wordlen] = ' '; + if (wordlen < 255) + wordlen++; + } + else // done with this line + done = 1; + } + } else if (wordlen < 255) { + wordlen++; + } + } else { // start scanning at first non-whitespace character + if (!IsSpace(c)) { + if (IsIdentifier(c)) { + word[0] = static_cast(LowerCase(c)); + wordlen = 1; + } else // done with this line + done = 1; + } + } + } + if (options.foldCommentExplicit && ((styler.StyleAt(i) == SCE_B_COMMENT) || options.foldExplicitAnywhere)) { + if (userDefinedFoldMarkers) { + if (styler.Match(i, options.foldExplicitStart.c_str())) { + level |= SC_FOLDLEVELHEADERFLAG; + go = 1; + } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { + go = -1; + } + } else { + if (c == comment_char) { + if (cNext == '{') { + level |= SC_FOLDLEVELHEADERFLAG; + go = 1; + } else if (cNext == '}') { + go = -1; + } + } + } + } + if (atEOL) { // line end + if (!done && wordlen == 0 && options.foldCompact) // line was only space + level |= SC_FOLDLEVELWHITEFLAG; + if (level != styler.LevelAt(line)) + styler.SetLevel(line, level); + level += go; + line++; + // reset state + wordlen = 0; + level &= ~SC_FOLDLEVELHEADERFLAG; + level &= ~SC_FOLDLEVELWHITEFLAG; + go = 0; + done = 0; + } + } +} + +LexerModule lmBlitzBasic(SCLEX_BLITZBASIC, LexerBasic::LexerFactoryBlitzBasic, "blitzbasic", blitzbasicWordListDesc); + +LexerModule lmPureBasic(SCLEX_PUREBASIC, LexerBasic::LexerFactoryPureBasic, "purebasic", purebasicWordListDesc); + +LexerModule lmFreeBasic(SCLEX_FREEBASIC, LexerBasic::LexerFactoryFreeBasic, "freebasic", freebasicWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexBatch.cxx b/Pythonwin/Scintilla/lexers/LexBatch.cxx new file mode 100644 index 000000000..857b60ce6 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexBatch.cxx @@ -0,0 +1,576 @@ +// Scintilla source code edit control +/** @file LexBatch.cxx + ** Lexer for batch files. + **/ +// 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 "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" + +using namespace Scintilla; + +static bool Is0To9(char ch) { + return (ch >= '0') && (ch <= '9'); +} + +static bool IsAlphabetic(int ch) { + return IsASCII(ch) && isalpha(ch); +} + +static inline bool AtEOL(Accessor &styler, Sci_PositionU i) { + return (styler[i] == '\n') || + ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')); +} + +// Tests for BATCH Operators +static bool IsBOperator(char ch) { + return (ch == '=') || (ch == '+') || (ch == '>') || (ch == '<') || + (ch == '|') || (ch == '?') || (ch == '*')|| + (ch == '&') || (ch == '(') || (ch == ')'); +} + +// Tests for BATCH Separators +static bool IsBSeparator(char ch) { + return (ch == '\\') || (ch == '.') || (ch == ';') || + (ch == '\"') || (ch == '\'') || (ch == '/'); +} + +// Tests for escape character +static bool IsEscaped(char* wordStr, Sci_PositionU pos) { + bool isQoted=false; + while (pos>0){ + pos--; + if (wordStr[pos]=='^') + isQoted=!isQoted; + else + break; + } + return isQoted; +} + +// Tests for quote character +static bool textQuoted(char *lineBuffer, Sci_PositionU endPos) { + char strBuffer[1024]; + strncpy(strBuffer, lineBuffer, endPos); + strBuffer[endPos] = '\0'; + char *pQuote; + pQuote = strchr(strBuffer, '"'); + bool CurrentStatus = false; + while (pQuote != NULL) + { + if (!IsEscaped(strBuffer, pQuote - strBuffer)) { + CurrentStatus = !CurrentStatus; + } + pQuote = strchr(pQuote + 1, '"'); + } + return CurrentStatus; +} + +static void ColouriseBatchDoc( + Sci_PositionU startPos, + Sci_Position length, + int /*initStyle*/, + WordList *keywordlists[], + Accessor &styler) { + // Always backtracks to the start of a line that is not a continuation + // of the previous line + if (startPos > 0) { + Sci_Position ln = styler.GetLine(startPos); // Current line number + while (startPos > 0) { + ln--; + if ((styler.SafeGetCharAt(startPos-3) == '^' && styler.SafeGetCharAt(startPos-2) == '\r' && styler.SafeGetCharAt(startPos-1) == '\n') + || styler.SafeGetCharAt(startPos-2) == '^') { // handle '^' line continuation + // When the line continuation is found, + // set the Start Position to the Start of the previous line + length+=startPos-styler.LineStart(ln); + startPos=styler.LineStart(ln); + } + else + break; + } + } + + char lineBuffer[1024]; + + styler.StartAt(startPos); + styler.StartSegment(startPos); + Sci_PositionU linePos = 0; + Sci_PositionU startLine = startPos; + bool continueProcessing = true; // Used to toggle Regular Keyword Checking + bool isNotAssigned=false; // Used to flag Assignment in Set operation + + for (Sci_PositionU i = startPos; i < startPos + length; i++) { + lineBuffer[linePos++] = styler[i]; + if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1) || (i==startPos + length-1)) { + // End of line (or of line buffer) (or End of Last Line) met, colourise it + lineBuffer[linePos] = '\0'; + Sci_PositionU lengthLine=linePos; + Sci_PositionU endPos=i; + Sci_PositionU offset = 0; // Line Buffer Offset + Sci_PositionU cmdLoc; // External Command / Program Location + char wordBuffer[81]; // Word Buffer - large to catch long paths + Sci_PositionU wbl; // Word Buffer Length + Sci_PositionU wbo; // Word Buffer Offset - also Special Keyword Buffer Length + WordList &keywords = *keywordlists[0]; // Internal Commands + WordList &keywords2 = *keywordlists[1]; // External Commands (optional) + + // CHOICE, ECHO, GOTO, PROMPT and SET have Default Text that may contain Regular Keywords + // Toggling Regular Keyword Checking off improves readability + // Other Regular Keywords and External Commands / Programs might also benefit from toggling + // Need a more robust algorithm to properly toggle Regular Keyword Checking + bool stopLineProcessing=false; // Used to stop line processing if Comment or Drive Change found + // Special Keywords are those that allow certain characters without whitespace after the command + // Examples are: cd. cd\ md. rd. dir| dir> echo: echo. path= + // Special Keyword Buffer used to determine if the first n characters is a Keyword + char sKeywordBuffer[10]; // Special Keyword Buffer + bool sKeywordFound; // Exit Special Keyword for-loop if found + + // Skip initial spaces + while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) { + offset++; + } + // Colorize Default Text + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + // Set External Command / Program Location + cmdLoc = offset; + + // Check for Fake Label (Comment) or Real Label - return if found + if (lineBuffer[offset] == ':') { + if (lineBuffer[offset + 1] == ':') { + // Colorize Fake Label (Comment) - :: is similar to REM, see http://content.techweb.com/winmag/columns/explorer/2000/21.htm + styler.ColourTo(endPos, SCE_BAT_COMMENT); + } else { + // Colorize Real Label + styler.ColourTo(endPos, SCE_BAT_LABEL); + } + stopLineProcessing=true; + // Check for Drive Change (Drive Change is internal command) - return if found + } else if ((IsAlphabetic(lineBuffer[offset])) && + (lineBuffer[offset + 1] == ':') && + ((isspacechar(lineBuffer[offset + 2])) || + (((lineBuffer[offset + 2] == '\\')) && + (isspacechar(lineBuffer[offset + 3]))))) { + // Colorize Regular Keyword + styler.ColourTo(endPos, SCE_BAT_WORD); + stopLineProcessing=true; + } + + // Check for Hide Command (@ECHO OFF/ON) + if (lineBuffer[offset] == '@') { + styler.ColourTo(startLine + offset, SCE_BAT_HIDE); + offset++; + } + // Skip next spaces + while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) { + offset++; + } + + // Read remainder of line word-at-a-time or remainder-of-word-at-a-time + while (offset < lengthLine && !stopLineProcessing) { + if (offset > startLine) { + // Colorize Default Text + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + } + // Copy word from Line Buffer into Word Buffer + wbl = 0; + for (; offset < lengthLine && wbl < 80 && + !isspacechar(lineBuffer[offset]); wbl++, offset++) { + wordBuffer[wbl] = static_cast(tolower(lineBuffer[offset])); + } + wordBuffer[wbl] = '\0'; + wbo = 0; + + // Check for Comment - return if found + if ((CompareCaseInsensitive(wordBuffer, "rem") == 0) && continueProcessing) { + styler.ColourTo(endPos, SCE_BAT_COMMENT); + break; + } + // Check for Separator + if (IsBSeparator(wordBuffer[0])) { + // Check for External Command / Program + if ((cmdLoc == offset - wbl) && + ((wordBuffer[0] == ':') || + (wordBuffer[0] == '\\') || + (wordBuffer[0] == '.'))) { + // Reset Offset to re-process remainder of word + offset -= (wbl - 1); + // Colorize External Command / Program + if (!keywords2) { + styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); + } else if (keywords2.InList(wordBuffer)) { + styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); + } else { + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + } + // Reset External Command / Program Location + cmdLoc = offset; + } else { + // Reset Offset to re-process remainder of word + offset -= (wbl - 1); + // Colorize Default Text + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + } + // Check for Regular Keyword in list + } else if ((keywords.InList(wordBuffer)) && + (continueProcessing)) { + // ECHO, GOTO, PROMPT and SET require no further Regular Keyword Checking + if ((CompareCaseInsensitive(wordBuffer, "echo") == 0) || + (CompareCaseInsensitive(wordBuffer, "goto") == 0) || + (CompareCaseInsensitive(wordBuffer, "prompt") == 0)) { + continueProcessing = false; + } + // SET requires additional processing for the assignment operator + if (CompareCaseInsensitive(wordBuffer, "set") == 0) { + continueProcessing = false; + isNotAssigned=true; + } + // Identify External Command / Program Location for ERRORLEVEL, and EXIST + if ((CompareCaseInsensitive(wordBuffer, "errorlevel") == 0) || + (CompareCaseInsensitive(wordBuffer, "exist") == 0)) { + // Reset External Command / Program Location + cmdLoc = offset; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Skip comparison + while ((cmdLoc < lengthLine) && + (!isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Identify External Command / Program Location for CALL, DO, LOADHIGH and LH + } else if ((CompareCaseInsensitive(wordBuffer, "call") == 0) || + (CompareCaseInsensitive(wordBuffer, "do") == 0) || + (CompareCaseInsensitive(wordBuffer, "loadhigh") == 0) || + (CompareCaseInsensitive(wordBuffer, "lh") == 0)) { + // Reset External Command / Program Location + cmdLoc = offset; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + } + // Colorize Regular keyword + styler.ColourTo(startLine + offset - 1, SCE_BAT_WORD); + // No need to Reset Offset + // Check for Special Keyword in list, External Command / Program, or Default Text + } else if ((wordBuffer[0] != '%') && + (wordBuffer[0] != '!') && + (!IsBOperator(wordBuffer[0])) && + (continueProcessing)) { + // Check for Special Keyword + // Affected Commands are in Length range 2-6 + // Good that ERRORLEVEL, EXIST, CALL, DO, LOADHIGH, and LH are unaffected + sKeywordFound = false; + for (Sci_PositionU keywordLength = 2; keywordLength < wbl && keywordLength < 7 && !sKeywordFound; keywordLength++) { + wbo = 0; + // Copy Keyword Length from Word Buffer into Special Keyword Buffer + for (; wbo < keywordLength; wbo++) { + sKeywordBuffer[wbo] = static_cast(wordBuffer[wbo]); + } + sKeywordBuffer[wbo] = '\0'; + // Check for Special Keyword in list + if ((keywords.InList(sKeywordBuffer)) && + ((IsBOperator(wordBuffer[wbo])) || + (IsBSeparator(wordBuffer[wbo])))) { + sKeywordFound = true; + // ECHO requires no further Regular Keyword Checking + if (CompareCaseInsensitive(sKeywordBuffer, "echo") == 0) { + continueProcessing = false; + } + // Colorize Special Keyword as Regular Keyword + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_WORD); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + } + } + // Check for External Command / Program or Default Text + if (!sKeywordFound) { + wbo = 0; + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + // Read up to %, Operator or Separator + while ((wbo < wbl) && + (((wordBuffer[wbo] != '%') && + (wordBuffer[wbo] != '!') && + (!IsBOperator(wordBuffer[wbo])) && + (!IsBSeparator(wordBuffer[wbo]))))) { + wbo++; + } + // Reset External Command / Program Location + cmdLoc = offset - (wbl - wbo); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + // CHOICE requires no further Regular Keyword Checking + if (CompareCaseInsensitive(wordBuffer, "choice") == 0) { + continueProcessing = false; + } + // Check for START (and its switches) - What follows is External Command \ Program + if (CompareCaseInsensitive(wordBuffer, "start") == 0) { + // Reset External Command / Program Location + cmdLoc = offset; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Reset External Command / Program Location if command switch detected + if (lineBuffer[cmdLoc] == '/') { + // Skip command switch + while ((cmdLoc < lengthLine) && + (!isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + } + } + // Colorize External Command / Program + if (!keywords2) { + styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); + } else if (keywords2.InList(wordBuffer)) { + styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); + } else { + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + } + // No need to Reset Offset + // Check for Default Text + } else { + // Read up to %, Operator or Separator + while ((wbo < wbl) && + (((wordBuffer[wbo] != '%') && + (wordBuffer[wbo] != '!') && + (!IsBOperator(wordBuffer[wbo])) && + (!IsBSeparator(wordBuffer[wbo]))))) { + wbo++; + } + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_DEFAULT); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + } + } + // Check for Argument (%n), Environment Variable (%x...%) or Local Variable (%%a) + } else if (wordBuffer[0] == '%') { + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT); + wbo++; + // Search to end of word for second % (can be a long path) + while ((wbo < wbl) && + (wordBuffer[wbo] != '%')) { + wbo++; + } + // Check for Argument (%n) or (%*) + if (((Is0To9(wordBuffer[1])) || (wordBuffer[1] == '*')) && + (wordBuffer[wbo] != '%')) { + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - 2); + } + // Colorize Argument + styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - 2); + // Check for Expanded Argument (%~...) / Variable (%%~...) + } else if (((wbl > 1) && (wordBuffer[1] == '~')) || + ((wbl > 2) && (wordBuffer[1] == '%') && (wordBuffer[2] == '~'))) { + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - wbo); + } + // Colorize Expanded Argument / Variable + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + // Check for Environment Variable (%x...%) + } else if ((wordBuffer[1] != '%') && + (wordBuffer[wbo] == '%')) { + wbo++; + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - wbo); + } + // Colorize Environment Variable + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + // Check for Local Variable (%%a) + } else if ( + (wbl > 2) && + (wordBuffer[1] == '%') && + (wordBuffer[2] != '%') && + (!IsBOperator(wordBuffer[2])) && + (!IsBSeparator(wordBuffer[2]))) { + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - 3); + } + // Colorize Local Variable + styler.ColourTo(startLine + offset - 1 - (wbl - 3), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - 3); + } + // Check for Environment Variable (!x...!) + } else if (wordBuffer[0] == '!') { + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT); + wbo++; + // Search to end of word for second ! (can be a long path) + while ((wbo < wbl) && + (wordBuffer[wbo] != '!')) { + wbo++; + } + if (wordBuffer[wbo] == '!') { + wbo++; + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - wbo); + } + // Colorize Environment Variable + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + } + // Check for Operator + } else if (IsBOperator(wordBuffer[0])) { + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT); + // Check for Comparison Operator + if ((wordBuffer[0] == '=') && (wordBuffer[1] == '=')) { + // Identify External Command / Program Location for IF + cmdLoc = offset; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Colorize Comparison Operator + if (continueProcessing) + styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_BAT_OPERATOR); + else + styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_BAT_DEFAULT); + // Reset Offset to re-process remainder of word + offset -= (wbl - 2); + // Check for Pipe Operator + } else if ((wordBuffer[0] == '|') && + !(IsEscaped(lineBuffer,offset - wbl + wbo) || textQuoted(lineBuffer, offset - wbl) )) { + // Reset External Command / Program Location + cmdLoc = offset - wbl + 1; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Colorize Pipe Operator + styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_BAT_OPERATOR); + // Reset Offset to re-process remainder of word + offset -= (wbl - 1); + continueProcessing = true; + // Check for Other Operator + } else { + // Check for Operators: >, |, & + if (((wordBuffer[0] == '>')|| + (wordBuffer[0] == ')')|| + (wordBuffer[0] == '(')|| + (wordBuffer[0] == '&' )) && + !(!continueProcessing && (IsEscaped(lineBuffer,offset - wbl + wbo) + || textQuoted(lineBuffer, offset - wbl) ))){ + // Turn Keyword and External Command / Program checking back on + continueProcessing = true; + isNotAssigned=false; + } + // Colorize Other Operators + // Do not Colorize Paranthesis, quoted text and escaped operators + if (((wordBuffer[0] != ')') && (wordBuffer[0] != '(') + && !textQuoted(lineBuffer, offset - wbl) && !IsEscaped(lineBuffer,offset - wbl + wbo)) + && !((wordBuffer[0] == '=') && !isNotAssigned )) + styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_BAT_OPERATOR); + else + styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_BAT_DEFAULT); + // Reset Offset to re-process remainder of word + offset -= (wbl - 1); + + if ((wordBuffer[0] == '=') && isNotAssigned ){ + isNotAssigned=false; + } + } + // Check for Default Text + } else { + // Read up to %, Operator or Separator + while ((wbo < wbl) && + ((wordBuffer[wbo] != '%') && + (wordBuffer[wbo] != '!') && + (!IsBOperator(wordBuffer[wbo])) && + (!IsBSeparator(wordBuffer[wbo])))) { + wbo++; + } + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_DEFAULT); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + } + // Skip next spaces - nothing happens if Offset was Reset + while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) { + offset++; + } + } + // Colorize Default Text for remainder of line - currently not lexed + styler.ColourTo(endPos, SCE_BAT_DEFAULT); + + // handle line continuation for SET and ECHO commands except the last line + if (!continueProcessing && (i2) && lineBuffer[linePos-2]=='\r') // Windows EOL + lineContinuationPos=linePos-3; + else + lineContinuationPos=linePos-2; // Unix or Mac EOL + // Reset continueProcessing if line continuation was not found + if ((lineBuffer[lineContinuationPos]!='^') + || IsEscaped(lineBuffer, lineContinuationPos) + || textQuoted(lineBuffer, lineContinuationPos)) + continueProcessing=true; + } + } + + linePos = 0; + startLine = i + 1; + } + } +} + +static const char *const batchWordListDesc[] = { + "Internal Commands", + "External Commands", + 0 +}; + +LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexBibTeX.cxx b/Pythonwin/Scintilla/lexers/LexBibTeX.cxx new file mode 100644 index 000000000..7e4cb9fc1 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexBibTeX.cxx @@ -0,0 +1,308 @@ +// Copyright 2008-2010 Sergiu Dotenco. The License.txt file describes the +// conditions under which this software may be distributed. + +/** + * @file LexBibTeX.cxx + * @brief General BibTeX coloring scheme. + * @author Sergiu Dotenco + * @date April 18, 2009 + */ + +#include +#include + +#include +#include + +#include +#include +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "PropSetSimple.h" +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + +using namespace Scintilla; + +namespace { + bool IsAlphabetic(unsigned int ch) + { + return IsASCII(ch) && std::isalpha(ch) != 0; + } + bool IsAlphaNumeric(char ch) + { + return IsASCII(ch) && std::isalnum(ch); + } + + bool EqualCaseInsensitive(const char* a, const char* b) + { + return CompareCaseInsensitive(a, b) == 0; + } + + bool EntryWithoutKey(const char* name) + { + return EqualCaseInsensitive(name,"string"); + } + + char GetClosingBrace(char openbrace) + { + char result = openbrace; + + switch (openbrace) { + case '(': result = ')'; break; + case '{': result = '}'; break; + } + + return result; + } + + bool IsEntryStart(char prev, char ch) + { + return prev != '\\' && ch == '@'; + } + + bool IsEntryStart(const StyleContext& sc) + { + return IsEntryStart(sc.chPrev, sc.ch); + } + + void ColorizeBibTeX(Sci_PositionU start_pos, Sci_Position length, int /*init_style*/, WordList* keywordlists[], Accessor& styler) + { + WordList &EntryNames = *keywordlists[0]; + bool fold_compact = styler.GetPropertyInt("fold.compact", 1) != 0; + + std::string buffer; + buffer.reserve(25); + + // We always colorize a section from the beginning, so let's + // search for the @ character which isn't escaped, i.e. \@ + while (start_pos > 0 && !IsEntryStart(styler.SafeGetCharAt(start_pos - 1), + styler.SafeGetCharAt(start_pos))) { + --start_pos; ++length; + } + + styler.StartAt(start_pos); + styler.StartSegment(start_pos); + + Sci_Position current_line = styler.GetLine(start_pos); + int prev_level = styler.LevelAt(current_line) & SC_FOLDLEVELNUMBERMASK; + int current_level = prev_level; + int visible_chars = 0; + + bool in_comment = false ; + StyleContext sc(start_pos, length, SCE_BIBTEX_DEFAULT, styler); + + bool going = sc.More(); // needed because of a fuzzy end of file state + char closing_brace = 0; + bool collect_entry_name = false; + + for (; going; sc.Forward()) { + if (!sc.More()) + going = false; // we need to go one behind the end of text + + if (in_comment) { + if (sc.atLineEnd) { + sc.SetState(SCE_BIBTEX_DEFAULT); + in_comment = false; + } + } + else { + // Found @entry + if (IsEntryStart(sc)) { + sc.SetState(SCE_BIBTEX_UNKNOWN_ENTRY); + sc.Forward(); + ++current_level; + + buffer.clear(); + collect_entry_name = true; + } + else if ((sc.state == SCE_BIBTEX_ENTRY || sc.state == SCE_BIBTEX_UNKNOWN_ENTRY) + && (sc.ch == '{' || sc.ch == '(')) { + // Entry name colorization done + // Found either a { or a ( after entry's name, e.g. @entry(...) @entry{...} + // Closing counterpart needs to be stored. + closing_brace = GetClosingBrace(sc.ch); + + sc.SetState(SCE_BIBTEX_DEFAULT); // Don't colorize { ( + + // @string doesn't have any key + if (EntryWithoutKey(buffer.c_str())) + sc.ForwardSetState(SCE_BIBTEX_PARAMETER); + else + sc.ForwardSetState(SCE_BIBTEX_KEY); // Key/label colorization + } + + // Need to handle the case where entry's key is empty + // e.g. @book{,...} + if (sc.state == SCE_BIBTEX_KEY && sc.ch == ',') { + // Key/label colorization done + sc.SetState(SCE_BIBTEX_DEFAULT); // Don't colorize the , + sc.ForwardSetState(SCE_BIBTEX_PARAMETER); // Parameter colorization + } + else if (sc.state == SCE_BIBTEX_PARAMETER && sc.ch == '=') { + sc.SetState(SCE_BIBTEX_DEFAULT); // Don't colorize the = + sc.ForwardSetState(SCE_BIBTEX_VALUE); // Parameter value colorization + + Sci_Position start = sc.currentPos; + + // We need to handle multiple situations: + // 1. name"one two {three}" + // 2. name={one {one two {two}} three} + // 3. year=2005 + + // Skip ", { until we encounter the first alphanumerical character + while (sc.More() && !(IsAlphaNumeric(sc.ch) || sc.ch == '"' || sc.ch == '{')) + sc.Forward(); + + if (sc.More()) { + // Store " or { + char ch = sc.ch; + + // Not interested in alphanumerical characters + if (IsAlphaNumeric(ch)) + ch = 0; + + int skipped = 0; + + if (ch) { + // Skip preceding " or { such as in name={{test}}. + // Remember how many characters have been skipped + // Make sure that empty values, i.e. "" are also handled correctly + while (sc.More() && (sc.ch == ch && (ch != '"' || skipped < 1))) { + sc.Forward(); + ++skipped; + } + } + + // Closing counterpart for " is the same character + if (ch == '{') + ch = '}'; + + // We have reached the parameter value + // In case the open character was a alnum char, skip until , is found + // otherwise until skipped == 0 + while (sc.More() && (skipped > 0 || (!ch && !(sc.ch == ',' || sc.ch == closing_brace)))) { + // Make sure the character isn't escaped + if (sc.chPrev != '\\') { + // Parameter value contains a { which is the 2nd case described above + if (sc.ch == '{') + ++skipped; // Remember it + else if (sc.ch == '}') + --skipped; + else if (skipped == 1 && sc.ch == ch && ch == '"') // Don't ignore cases like {"o} + skipped = 0; + } + + sc.Forward(); + } + } + + // Don't colorize the , + sc.SetState(SCE_BIBTEX_DEFAULT); + + // Skip until the , or entry's closing closing_brace is found + // since this parameter might be the last one + while (sc.More() && !(sc.ch == ',' || sc.ch == closing_brace)) + sc.Forward(); + + int state = SCE_BIBTEX_PARAMETER; // The might be more parameters + + // We've reached the closing closing_brace for the bib entry + // in case no " or {} has been used to enclose the value, + // as in 3rd case described above + if (sc.ch == closing_brace) { + --current_level; + // Make sure the text between entries is not colored + // using parameter's style + state = SCE_BIBTEX_DEFAULT; + } + + Sci_Position end = sc.currentPos; + current_line = styler.GetLine(end); + + // We have possibly skipped some lines, so the folding levels + // have to be adjusted separately + for (Sci_Position i = styler.GetLine(start); i <= styler.GetLine(end); ++i) + styler.SetLevel(i, prev_level); + + sc.ForwardSetState(state); + } + + if (sc.state == SCE_BIBTEX_PARAMETER && sc.ch == closing_brace) { + sc.SetState(SCE_BIBTEX_DEFAULT); + --current_level; + } + + // Non escaped % found which represents a comment until the end of the line + if (sc.chPrev != '\\' && sc.ch == '%') { + in_comment = true; + sc.SetState(SCE_BIBTEX_COMMENT); + } + } + + if (sc.state == SCE_BIBTEX_UNKNOWN_ENTRY || sc.state == SCE_BIBTEX_ENTRY) { + if (!IsAlphabetic(sc.ch) && collect_entry_name) + collect_entry_name = false; + + if (collect_entry_name) { + buffer += static_cast(tolower(sc.ch)); + if (EntryNames.InList(buffer.c_str())) + sc.ChangeState(SCE_BIBTEX_ENTRY); + else + sc.ChangeState(SCE_BIBTEX_UNKNOWN_ENTRY); + } + } + + if (sc.atLineEnd) { + int level = prev_level; + + if (visible_chars == 0 && fold_compact) + level |= SC_FOLDLEVELWHITEFLAG; + + if ((current_level > prev_level)) + level |= SC_FOLDLEVELHEADERFLAG; + // else if (current_level < prev_level) + // level |= SC_FOLDLEVELBOXFOOTERFLAG; // Deprecated + + if (level != styler.LevelAt(current_line)) { + styler.SetLevel(current_line, level); + } + + ++current_line; + prev_level = current_level; + visible_chars = 0; + } + + if (!isspacechar(sc.ch)) + ++visible_chars; + } + + sc.Complete(); + + // Fill in the real level of the next line, keeping the current flags as they will be filled in later + int flagsNext = styler.LevelAt(current_line) & ~SC_FOLDLEVELNUMBERMASK; + styler.SetLevel(current_line, prev_level | flagsNext); + } +} +static const char * const BibTeXWordLists[] = { + "Entry Names", + 0, +}; + + +LexerModule lmBibTeX(SCLEX_BIBTEX, ColorizeBibTeX, "bib", 0, BibTeXWordLists); + +// Entry Names +// article, book, booklet, conference, inbook, +// incollection, inproceedings, manual, mastersthesis, +// misc, phdthesis, proceedings, techreport, unpublished, +// string, url + diff --git a/Pythonwin/Scintilla/src/LexBullant.cxx b/Pythonwin/Scintilla/lexers/LexBullant.cxx similarity index 89% rename from Pythonwin/Scintilla/src/LexBullant.cxx rename to Pythonwin/Scintilla/lexers/LexBullant.cxx index cc60cd2fc..2386d2252 100644 --- a/Pythonwin/Scintilla/src/LexBullant.cxx +++ b/Pythonwin/Scintilla/lexers/LexBullant.cxx @@ -3,25 +3,28 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" - -#include "PropSet.h" -#include "Accessor.h" -#include "KeyWords.h" +#include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" -#ifdef SCI_NAMESPACE +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + using namespace Scintilla; -#endif -static int classifyWordBullant(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { +static int classifyWordBullant(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler) { char s[100]; - for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { + s[0] = '\0'; + for (Sci_PositionU i = 0; i < end - start + 1 && i < 30; i++) { s[i] = static_cast(tolower(styler[start + i])); s[i + 1] = '\0'; } @@ -53,14 +56,14 @@ static int classifyWordBullant(unsigned int start, unsigned int end, WordList &k return lev; } -static void ColouriseBullantDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseBullantDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; styler.StartAt(startPos); bool fold = styler.GetPropertyInt("fold") != 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; @@ -69,11 +72,11 @@ static void ColouriseBullantDoc(unsigned int startPos, int length, int initStyle state = SCE_C_DEFAULT; char chPrev = ' '; char chNext = styler[startPos]; - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; styler.StartSegment(startPos); int endFoundThisLine = 0; - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -111,7 +114,7 @@ static void ColouriseBullantDoc(unsigned int startPos, int length, int initStyle } blockChange=0; */ } - if (!isspace(ch)) + if (!(IsASCII(ch) && isspace(ch))) visibleChars++; if (styler.IsLeadByte(ch)) { diff --git a/Pythonwin/Scintilla/lexers/LexCIL.cxx b/Pythonwin/Scintilla/lexers/LexCIL.cxx new file mode 100644 index 000000000..4e0fdb696 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexCIL.cxx @@ -0,0 +1,407 @@ +// Scintilla source code edit control +/** @file LexCIL.cxx + ** Lexer for Common Intermediate Language + ** Written by Jad Altahan (github.com/xv) + ** CIL manual: https://www.ecma-international.org/publications/standards/Ecma-335.htm + **/ +// 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 "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "StringCopy.h" +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" +#include "DefaultLexer.h" + +using namespace Scintilla; + +namespace { + // Use an unnamed namespace to protect the functions and classes from name conflicts + +bool IsAWordChar(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); +} + +bool IsOperator(const int ch) { + if ((ch < 0x80) && (isalnum(ch))) + return false; + + if (strchr("!%&*+-/<=>@^|~()[]{}", ch)) { + return true; + } + + return false; +} + +constexpr bool IsStreamCommentStyle(const int style) noexcept { + return style == SCE_CIL_COMMENT; +} + +struct OptionsCIL { + bool fold; + bool foldComment; + bool foldCommentMultiline; + bool foldCompact; + + OptionsCIL() { + fold = true; + foldComment = false; + foldCommentMultiline = true; + foldCompact = true; + } +}; + +static const char *const cilWordListDesc[] = { + "Primary CIL keywords", + "Metadata", + "Opcode instructions", + 0 +}; + +struct OptionSetCIL : public OptionSet { + OptionSetCIL() { + DefineProperty("fold", &OptionsCIL::fold); + DefineProperty("fold.comment", &OptionsCIL::foldComment); + + DefineProperty("fold.cil.comment.multiline", &OptionsCIL::foldCommentMultiline, + "Set this property to 0 to disable folding multi-line comments when fold.comment=1."); + + DefineProperty("fold.compact", &OptionsCIL::foldCompact); + + DefineWordListSets(cilWordListDesc); + } +}; + +LexicalClass lexicalClasses[] = { + // Lexer CIL SCLEX_CIL SCE_CIL_: + 0, "SCE_CIL_DEFAULT", "default", "White space", + 1, "SCE_CIL_COMMENT", "comment", "Multi-line comment", + 2, "SCE_CIL_COMMENTLINE", "comment line", "Line comment", + 3, "SCE_CIL_WORD", "keyword", "Keyword 1", + 4, "SCE_CIL_WORD2", "keyword", "Keyword 2", + 5, "SCE_CIL_WORD3", "keyword", "Keyword 3", + 6, "SCE_CIL_STRING", "literal string", "Double quoted string", + 7, "SCE_CIL_LABEL", "label", "Code label", + 8, "SCE_CIL_OPERATOR", "operator", "Operators", + 9, "SCE_CIL_STRINGEOL", "error literal string", "String is not closed", + 10, "SCE_CIL_IDENTIFIER", "identifier", "Identifiers", +}; + +} + +class LexerCIL : public DefaultLexer { + WordList keywords, keywords2, keywords3; + OptionsCIL options; + OptionSetCIL osCIL; + +public: + LexerCIL() : DefaultLexer("cil", SCLEX_CIL, lexicalClasses, ELEMENTS(lexicalClasses)) { } + + virtual ~LexerCIL() { } + + void SCI_METHOD Release() override { + delete this; + } + + int SCI_METHOD Version() const override { + return lvRelease5; + } + + const char * SCI_METHOD PropertyNames() override { + return osCIL.PropertyNames(); + } + + int SCI_METHOD PropertyType(const char *name) override { + return osCIL.PropertyType(name); + } + + const char * SCI_METHOD DescribeProperty(const char *name) override { + return osCIL.DescribeProperty(name); + } + + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override; + + const char * SCI_METHOD PropertyGet(const char* key) override { + return osCIL.PropertyGet(key); + } + + const char * SCI_METHOD DescribeWordListSets() override { + return osCIL.DescribeWordListSets(); + } + + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override; + + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + + void * SCI_METHOD PrivateCall(int, void *) override { + return 0; + } + + int SCI_METHOD LineEndTypesSupported() override { + return SC_LINE_END_TYPE_UNICODE; + } + + int SCI_METHOD PrimaryStyleFromStyle(int style) override { + return style; + } + + static ILexer5 *LexerFactoryCIL() { + return new LexerCIL(); + } +}; + +Sci_Position SCI_METHOD LexerCIL::PropertySet(const char *key, const char *val) { + if (osCIL.PropertySet(&options, key, val)) { + return 0; + } + + return -1; +} + +Sci_Position SCI_METHOD LexerCIL::WordListSet(int n, const char *wl) { + WordList *wordListN = 0; + + switch (n) { + case 0: + wordListN = &keywords; + break; + case 1: + wordListN = &keywords2; + break; + case 2: + wordListN = &keywords3; + break; + } + + Sci_Position firstModification = -1; + + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + + return firstModification; +} + +void SCI_METHOD LexerCIL::Lex(Sci_PositionU startPos, Sci_Position length, + int initStyle, IDocument *pAccess) { + if (initStyle == SCE_CIL_STRINGEOL) { + initStyle = SCE_CIL_DEFAULT; + } + + Accessor styler(pAccess, NULL); + StyleContext sc(startPos, length, initStyle, styler); + + bool identAtLineStart = false, // Checks if an identifier is at line start (ignoring spaces) + canStyleLabels = false; // Checks if conditions are met to style SCE_CIL_LABEL + + for (; sc.More(); sc.Forward()) { + if (sc.atLineStart) { + if (sc.state == SCE_CIL_STRING) { + sc.SetState(SCE_CIL_STRING); + } + + identAtLineStart = true; + } + + // Handle string line continuation + if (sc.ch == '\\' && (sc.chNext == '\n' || sc.chNext == '\r') && + (sc.state == SCE_CIL_STRING)) { + sc.Forward(); + + if (sc.ch == '\r' && sc.chNext == '\n') { + sc.Forward(); + } + + continue; + } + + switch (sc.state) { + case SCE_CIL_OPERATOR: + sc.SetState(SCE_CIL_DEFAULT); + break; + case SCE_CIL_IDENTIFIER: + if (!IsAWordChar(sc.ch)) { + if (canStyleLabels && (sc.ch == ':' && sc.chNext != ':')) { + sc.ChangeState(SCE_CIL_LABEL); + sc.ForwardSetState(SCE_CIL_DEFAULT); + } else { + char kwSize[100]; + sc.GetCurrent(kwSize, sizeof(kwSize)); + int style = SCE_CIL_IDENTIFIER; + + if (keywords.InList(kwSize)) { + style = SCE_CIL_WORD; + } else if (keywords2.InList(kwSize)) { + style = SCE_CIL_WORD2; + } else if (keywords3.InList(kwSize)) { + style = SCE_CIL_WORD3; + } + + sc.ChangeState(style); + sc.SetState(SCE_CIL_DEFAULT); + } + } + break; + case SCE_CIL_COMMENT: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_CIL_DEFAULT); + } + break; + case SCE_CIL_COMMENTLINE: + if (sc.atLineStart) { + sc.SetState(SCE_CIL_DEFAULT); + } + break; + case SCE_CIL_STRING: + if (sc.ch == '\\') { + if (sc.chNext == '"' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '"') { + sc.ForwardSetState(SCE_CIL_DEFAULT); + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_CIL_STRINGEOL); + sc.ForwardSetState(SCE_CIL_DEFAULT); + } + break; + } + + if (sc.state == SCE_CIL_DEFAULT) { + // String + if (sc.ch == '"') { + sc.SetState(SCE_CIL_STRING); + } + // Keyword + else if (IsAWordChar(sc.ch)) { + // Allow setting SCE_CIL_LABEL style only if the label is the + // first token in the line and does not start with a dot or a digit + canStyleLabels = identAtLineStart && !(sc.ch == '.' || IsADigit(sc.ch)); + sc.SetState(SCE_CIL_IDENTIFIER); + } + // Multi-line comment + else if (sc.Match('/', '*')) { + sc.SetState(SCE_CIL_COMMENT); + sc.Forward(); + } + // Line comment + else if (sc.Match('/', '/')) { + sc.SetState(SCE_CIL_COMMENTLINE); + } + // Operators + else if (IsOperator(sc.ch)) { + sc.SetState(SCE_CIL_OPERATOR); + } + } + + if (!IsASpace(sc.ch)) { + identAtLineStart = false; + } + } + + sc.Complete(); +} + +void SCI_METHOD LexerCIL::Fold(Sci_PositionU startPos, Sci_Position length, + int initStyle, IDocument *pAccess) { + if (!options.fold) { + return; + } + + LexAccessor styler(pAccess); + + const Sci_PositionU endPos = startPos + length; + Sci_Position lineCurrent = styler.GetLine(startPos); + + int levelCurrent = SC_FOLDLEVELBASE; + if (lineCurrent > 0) + levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16; + + int style = initStyle; + int styleNext = styler.StyleAt(startPos); + int levelNext = levelCurrent; + int visibleChars = 0; + + char chNext = styler[startPos]; + + for (Sci_PositionU i = startPos; i < endPos; i++) { + const char ch = chNext; + int stylePrev = style; + + chNext = styler.SafeGetCharAt(i + 1); + style = styleNext; + styleNext = styler.StyleAt(i + 1); + + const bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + + if (options.foldComment && + options.foldCommentMultiline && IsStreamCommentStyle(style)) { + if (!IsStreamCommentStyle(stylePrev)) { + levelNext++; + } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { + levelNext--; + } + } + + if (style == SCE_CIL_OPERATOR) { + if (ch == '{') { + levelNext++; + } else if (ch == '}') { + levelNext--; + } + } + + if (!IsASpace(ch)) { + visibleChars++; + } + + if (atEOL || (i == endPos - 1)) { + int lev = levelCurrent | levelNext << 16; + if (visibleChars == 0 && options.foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if (levelCurrent < levelNext) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + + lineCurrent++; + levelCurrent = levelNext; + + if (options.foldCompact && + i == static_cast(styler.Length() - 1)) { + styler.SetLevel(lineCurrent, lev | SC_FOLDLEVELWHITEFLAG); + } + + visibleChars = 0; + } + } +} + +LexerModule lmCIL(SCLEX_CIL, LexerCIL::LexerFactoryCIL, "cil", cilWordListDesc); \ No newline at end of file diff --git a/Pythonwin/Scintilla/src/LexCLW.cxx b/Pythonwin/Scintilla/lexers/LexCLW.cxx similarity index 92% rename from Pythonwin/Scintilla/src/LexCLW.cxx rename to Pythonwin/Scintilla/lexers/LexCLW.cxx index 624ef0f2b..fbc86e6c0 100644 --- a/Pythonwin/Scintilla/src/LexCLW.cxx +++ b/Pythonwin/Scintilla/lexers/LexCLW.cxx @@ -1,5 +1,5 @@ // Scintilla source code edit control -/** @file LexClw.cxx +/** @file LexCLW.cxx ** Lexer for Clarion. ** 2004/12/17 Updated Lexer **/ @@ -10,20 +10,21 @@ #include #include #include +#include #include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif // Is an end of line character inline bool IsEOL(const int ch) { @@ -60,10 +61,10 @@ inline bool IsALabelStart(const int iChar) { // Is a label character inline bool IsALabelCharacter(const int iChar) { - return(isalnum(iChar) || iChar == '_' || iChar == ':'); + return(isalnum(iChar) || iChar == '_' || iChar == ':'); } -// Is the character is a ! and the the next character is not a ! +// Is the character is a ! and the the next character is not a ! inline bool IsACommentStart(const int iChar) { return(iChar == '!'); @@ -126,7 +127,7 @@ inline bool SetNumericConstantState(StyleContext &scDoc) { break; default : break; - } + } } // If points found (can be more than one for improper formatted number if (iPoints > 0) { @@ -139,12 +140,12 @@ inline bool SetNumericConstantState(StyleContext &scDoc) { } // Get the next word in uppercase from the current position (keyword lookahead) -inline bool GetNextWordUpper(Accessor &styler, unsigned int uiStartPos, int iLength, char *cWord) { +inline bool GetNextWordUpper(Accessor &styler, Sci_PositionU uiStartPos, Sci_Position iLength, char *cWord) { - unsigned int iIndex = 0; // Buffer Index + Sci_PositionU iIndex = 0; // Buffer Index // Loop through the remaining string from the current position - for (int iOffset = uiStartPos; iOffset < iLength; iOffset++) { + for (Sci_Position iOffset = uiStartPos; iOffset < iLength; iOffset++) { // Get the character from the buffer using the offset char cCharacter = styler[iOffset]; if (IsEOL(cCharacter)) { @@ -171,7 +172,7 @@ inline bool GetNextWordUpper(Accessor &styler, unsigned int uiStartPos, int iLen } // Clarion Language Colouring Procedure -static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) { +static void ColouriseClarionDoc(Sci_PositionU uiStartPos, Sci_Position iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) { int iParenthesesLevel = 0; // Parenthese Level int iColumn1Label = false; // Label starts in Column 1 @@ -186,12 +187,12 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS WordList &wlLabelReservedWords = *wlKeywords[7]; // Clarion Reserved Keywords (Labels) WordList &wlProcLabelReservedWords = *wlKeywords[8]; // Clarion Reserved Keywords (Procedure Labels) - const char wlProcReservedKeywordList[] = + const char wlProcReservedKeywordList[] = "PROCEDURE FUNCTION"; WordList wlProcReservedKeywords; wlProcReservedKeywords.Set(wlProcReservedKeywordList); - const char wlCompilerKeywordList[] = + const char wlCompilerKeywordList[] = "COMPILE OMIT"; WordList wlCompilerKeywords; wlCompilerKeywords.Set(wlCompilerKeywordList); @@ -243,7 +244,7 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS // change the label to error state scDoc.ChangeState(SCE_CLW_ERROR); } - // Else if UPPERCASE label string is + // Else if UPPERCASE label string is else if (wlProcLabelReservedWords.InList(cLabel) && iColumn1Label) { char cWord[512]; // Word buffer // Get the next word from the current position @@ -368,13 +369,13 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS // Increment the parenthese level iParenthesesLevel++; } - // Else if the character is a ) (close parenthese) + // Else if the character is a ) (close parenthese) else if (scDoc.ch == ')') { // If the parenthese level is set to zero // parentheses matched if (!iParenthesesLevel) { scDoc.SetState(SCE_CLW_DEFAULT); - } + } // Else parenthese level is greater than zero // still looking for matching parentheses else { @@ -399,7 +400,7 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS || IsAHexCharacter(scDoc.ch, bCaseSensitive) || scDoc.ch == '.' || IsANumericBaseCharacter(scDoc.ch, bCaseSensitive))) { - // If the number was a real + // If the number was a real if (SetNumericConstantState(scDoc)) { // Colour the matched string to the real constant state scDoc.ChangeState(SCE_CLW_REAL_CONSTANT); @@ -461,7 +462,7 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS } // Default Handling else { - // If in default state + // If in default state if (scDoc.state == SCE_CLW_DEFAULT) { // If is a letter could be a possible statement if (isalpha(scDoc.ch)) { @@ -477,10 +478,10 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS else if (IsACommentStart(scDoc.ch) || scDoc.ch == '|') { // then set the state to comment. scDoc.SetState(SCE_CLW_COMMENT); - } + } // else if the character is a ' (single quote) else if (scDoc.ch == '\'') { - // If the character is also a ' (single quote) + // If the character is also a ' (single quote) // Embedded Apostrophe if (scDoc.chNext == '\'') { // Move forward colouring it as default state @@ -490,7 +491,7 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS // move to the next character and then set the state to comment. scDoc.ForwardSetState(SCE_CLW_STRING); } - } + } // else the character is an @ (ampersand) else if (scDoc.ch == '@') { // Case insensitive. @@ -509,7 +510,7 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS scDoc.SetState(SCE_CLW_PICTURE_STRING); } } - } + } } } } @@ -518,22 +519,22 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS } // Clarion Language Case Sensitive Colouring Procedure -static void ColouriseClarionDocSensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { +static void ColouriseClarionDocSensitive(Sci_PositionU uiStartPos, Sci_Position iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { ColouriseClarionDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, true); } // Clarion Language Case Insensitive Colouring Procedure -static void ColouriseClarionDocInsensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { +static void ColouriseClarionDocInsensitive(Sci_PositionU uiStartPos, Sci_Position iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { ColouriseClarionDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, false); } // Fill Buffer -static void FillBuffer(unsigned int uiStart, unsigned int uiEnd, Accessor &accStyler, char *szBuffer, unsigned int uiLength) { +static void FillBuffer(Sci_PositionU uiStart, Sci_PositionU uiEnd, Accessor &accStyler, char *szBuffer, Sci_PositionU uiLength) { - unsigned int uiPos = 0; + Sci_PositionU uiPos = 0; while ((uiPos < uiEnd - uiStart + 1) && (uiPos < uiLength-1)) { szBuffer[uiPos] = static_cast(toupper(accStyler[uiStart + uiPos])); @@ -596,19 +597,19 @@ static int ClassifyClarionFoldPoint(int iLevel, const char* szString) { } // Clarion Language Folding Procedure -static void FoldClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *[], Accessor &accStyler) { +static void FoldClarionDoc(Sci_PositionU uiStartPos, Sci_Position iLength, int iInitStyle, WordList *[], Accessor &accStyler) { - unsigned int uiEndPos = uiStartPos + iLength; - int iLineCurrent = accStyler.GetLine(uiStartPos); + Sci_PositionU uiEndPos = uiStartPos + iLength; + Sci_Position iLineCurrent = accStyler.GetLine(uiStartPos); int iLevelPrev = accStyler.LevelAt(iLineCurrent) & SC_FOLDLEVELNUMBERMASK; int iLevelCurrent = iLevelPrev; char chNext = accStyler[uiStartPos]; int iStyle = iInitStyle; int iStyleNext = accStyler.StyleAt(uiStartPos); int iVisibleChars = 0; - int iLastStart = 0; + Sci_Position iLastStart = 0; - for (unsigned int uiPos = uiStartPos; uiPos < uiEndPos; uiPos++) { + for (Sci_PositionU uiPos = uiStartPos; uiPos < uiEndPos; uiPos++) { char chChar = chNext; chNext = accStyler.SafeGetCharAt(uiPos + 1); @@ -616,7 +617,7 @@ static void FoldClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, iStyle = iStyleNext; iStyleNext = accStyler.StyleAt(uiPos + 1); bool bEOL = (chChar == '\r' && chNext != '\n') || (chChar == '\n'); - + if (iStylePrev == SCE_CLW_DEFAULT) { if (iStyle == SCE_CLW_KEYWORD || iStyle == SCE_CLW_STRUCTURE_DATA_TYPE) { // Store last word start point. @@ -647,7 +648,7 @@ static void FoldClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, iLevelPrev = iLevelCurrent; iVisibleChars = 0; } - + if (!isspacechar(chChar)) iVisibleChars++; } diff --git a/Pythonwin/Scintilla/lexers/LexCOBOL.cxx b/Pythonwin/Scintilla/lexers/LexCOBOL.cxx new file mode 100644 index 000000000..f0374824f --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexCOBOL.cxx @@ -0,0 +1,379 @@ +// Scintilla source code edit control +/** @file LexCOBOL.cxx + ** Lexer for COBOL + ** Based on LexPascal.cxx + ** Written by Laurent le Tynevez + ** Updated by Simon Steele September 2002 + ** Updated by Mathias Rauen May 2003 (Delphi adjustments) + ** Updated by Rod Falck, Aug 2006 Converted to COBOL + **/ + +#include +#include +#include +#include +#include +#include + +#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" + +using namespace Scintilla; + +#define IN_DIVISION 0x01 +#define IN_DECLARATIVES 0x02 +#define IN_SECTION 0x04 +#define IN_PARAGRAPH 0x08 +#define IN_FLAGS 0xF +#define NOT_HEADER 0x10 + +inline bool isCOBOLoperator(char ch) + { + return isoperator(ch); + } + +inline bool isCOBOLwordchar(char ch) + { + return IsASCII(ch) && (isalnum(ch) || ch == '-'); + + } + +inline bool isCOBOLwordstart(char ch) + { + return IsASCII(ch) && isalnum(ch); + } + +static int CountBits(int nBits) + { + int count = 0; + for (int i = 0; i < 32; ++i) + { + count += nBits & 1; + nBits >>= 1; + } + return count; + } + +static void getRange(Sci_PositionU start, + Sci_PositionU end, + Accessor &styler, + char *s, + Sci_PositionU len) { + Sci_PositionU i = 0; + while ((i < end - start + 1) && (i < len-1)) { + s[i] = static_cast(tolower(styler[start + i])); + i++; + } + s[i] = '\0'; +} + +static void ColourTo(Accessor &styler, Sci_PositionU end, unsigned int attr) { + styler.ColourTo(end, attr); +} + + +static int classifyWordCOBOL(Sci_PositionU start, Sci_PositionU end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, int nContainment, bool *bAarea) { + int ret = 0; + + WordList& a_keywords = *keywordlists[0]; + WordList& b_keywords = *keywordlists[1]; + WordList& c_keywords = *keywordlists[2]; + + char s[100]; + s[0] = '\0'; + s[1] = '\0'; + getRange(start, end, styler, s, sizeof(s)); + + char chAttr = SCE_C_IDENTIFIER; + if (isdigit(s[0]) || (s[0] == '.') || (s[0] == 'v')) { + chAttr = SCE_C_NUMBER; + char *p = s + 1; + while (*p) { + if ((!isdigit(*p) && (*p) != 'v') && isCOBOLwordchar(*p)) { + chAttr = SCE_C_IDENTIFIER; + break; + } + ++p; + } + } + else { + if (a_keywords.InList(s)) { + chAttr = SCE_C_WORD; + } + else if (b_keywords.InList(s)) { + chAttr = SCE_C_WORD2; + } + else if (c_keywords.InList(s)) { + chAttr = SCE_C_UUID; + } + } + if (*bAarea) { + if (strcmp(s, "division") == 0) { + ret = IN_DIVISION; + // we've determined the containment, anything else is just ignored for those purposes + *bAarea = false; + } else if (strcmp(s, "declaratives") == 0) { + ret = IN_DIVISION | IN_DECLARATIVES; + if (nContainment & IN_DECLARATIVES) + ret |= NOT_HEADER | IN_SECTION; + // we've determined the containment, anything else is just ignored for those purposes + *bAarea = false; + } else if (strcmp(s, "section") == 0) { + ret = (nContainment &~ IN_PARAGRAPH) | IN_SECTION; + // we've determined the containment, anything else is just ignored for those purposes + *bAarea = false; + } else if (strcmp(s, "end") == 0 && (nContainment & IN_DECLARATIVES)) { + ret = IN_DIVISION | IN_DECLARATIVES | IN_SECTION | NOT_HEADER; + } else { + ret = nContainment | IN_PARAGRAPH; + } + } + ColourTo(styler, end, chAttr); + return ret; +} + +static void ColouriseCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], + Accessor &styler) { + + styler.StartAt(startPos); + + int state = initStyle; + if (state == SCE_C_CHARACTER) // Does not leak onto next line + state = SCE_C_DEFAULT; + char chPrev = ' '; + char chNext = styler[startPos]; + Sci_PositionU lengthDoc = startPos + length; + + int nContainment; + + Sci_Position currentLine = styler.GetLine(startPos); + if (currentLine > 0) { + styler.SetLineState(currentLine, styler.GetLineState(currentLine-1)); + nContainment = styler.GetLineState(currentLine); + nContainment &= ~NOT_HEADER; + } else { + styler.SetLineState(currentLine, 0); + nContainment = 0; + } + + styler.StartSegment(startPos); + bool bNewLine = true; + bool bAarea = !isspacechar(chNext); + int column = 0; + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { + char ch = chNext; + + chNext = styler.SafeGetCharAt(i + 1); + + ++column; + + if (bNewLine) { + column = 0; + } + if (column <= 1 && !bAarea) { + bAarea = !isspacechar(ch); + } + bool bSetNewLine = false; + if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { + // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) + // Avoid triggering two times on Dos/Win + // End of line + if (state == SCE_C_CHARACTER) { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + styler.SetLineState(currentLine, nContainment); + currentLine++; + bSetNewLine = true; + if (nContainment & NOT_HEADER) + nContainment &= ~(NOT_HEADER | IN_DECLARATIVES | IN_SECTION); + } + + if (styler.IsLeadByte(ch)) { + chNext = styler.SafeGetCharAt(i + 2); + chPrev = ' '; + i += 1; + continue; + } + + if (state == SCE_C_DEFAULT) { + if (isCOBOLwordstart(ch) || (ch == '$' && IsASCII(chNext) && isalpha(chNext))) { + ColourTo(styler, i-1, state); + state = SCE_C_IDENTIFIER; + } else if (column == 6 && ch == '*') { + // Cobol comment line: asterisk in column 7. + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTLINE; + } else if (ch == '*' && chNext == '>') { + // Cobol inline comment: asterisk, followed by greater than. + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTLINE; + } else if (column == 0 && ch == '*' && chNext != '*') { + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTLINE; + } else if (column == 0 && ch == '/' && chNext != '*') { + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTLINE; + } else if (column == 0 && ch == '*' && chNext == '*') { + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTDOC; + } else if (column == 0 && ch == '/' && chNext == '*') { + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTDOC; + } else if (ch == '"') { + ColourTo(styler, i-1, state); + state = SCE_C_STRING; + } else if (ch == '\'') { + ColourTo(styler, i-1, state); + state = SCE_C_CHARACTER; + } else if (ch == '?' && column == 0) { + ColourTo(styler, i-1, state); + state = SCE_C_PREPROCESSOR; + } else if (isCOBOLoperator(ch)) { + ColourTo(styler, i-1, state); + ColourTo(styler, i, SCE_C_OPERATOR); + } + } else if (state == SCE_C_IDENTIFIER) { + if (!isCOBOLwordchar(ch)) { + int lStateChange = classifyWordCOBOL(styler.GetStartSegment(), i - 1, keywordlists, styler, nContainment, &bAarea); + + if(lStateChange != 0) { + styler.SetLineState(currentLine, lStateChange); + nContainment = lStateChange; + } + + state = SCE_C_DEFAULT; + chNext = styler.SafeGetCharAt(i + 1); + if (ch == '"') { + state = SCE_C_STRING; + } else if (ch == '\'') { + state = SCE_C_CHARACTER; + } else if (isCOBOLoperator(ch)) { + ColourTo(styler, i, SCE_C_OPERATOR); + } + } + } else { + if (state == SCE_C_PREPROCESSOR) { + if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) { + ColourTo(styler, i-1, state); + state = SCE_C_DEFAULT; + } + } else if (state == SCE_C_COMMENT) { + if (ch == '\r' || ch == '\n') { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + } else if (state == SCE_C_COMMENTDOC) { + if (ch == '\r' || ch == '\n') { + if (((i > styler.GetStartSegment() + 2) || ( + (initStyle == SCE_C_COMMENTDOC) && + (styler.GetStartSegment() == static_cast(startPos))))) { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + } + } else if (state == SCE_C_COMMENTLINE) { + if (ch == '\r' || ch == '\n') { + ColourTo(styler, i-1, state); + state = SCE_C_DEFAULT; + } + } else if (state == SCE_C_STRING) { + if (ch == '"') { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + } else if (state == SCE_C_CHARACTER) { + if (ch == '\'') { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + } + } + chPrev = ch; + bNewLine = bSetNewLine; + if (bNewLine) + { + bAarea = false; + } + } + ColourTo(styler, lengthDoc - 1, state); +} + +static void FoldCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], + Accessor &styler) { + bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; + Sci_PositionU endPos = startPos + length; + int visibleChars = 0; + Sci_Position lineCurrent = styler.GetLine(startPos); + int levelPrev = lineCurrent > 0 ? styler.LevelAt(lineCurrent - 1) & SC_FOLDLEVELNUMBERMASK : 0xFFF; + char chNext = styler[startPos]; + + bool bNewLine = true; + bool bAarea = !isspacechar(chNext); + int column = 0; + bool bComment = false; + for (Sci_PositionU i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + ++column; + + if (bNewLine) { + column = 0; + bComment = (ch == '*' || ch == '/' || ch == '?'); + } + if (column <= 1 && !bAarea) { + bAarea = !isspacechar(ch); + } + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + if (atEOL) { + int nContainment = styler.GetLineState(lineCurrent); + int lev = CountBits(nContainment & IN_FLAGS) | SC_FOLDLEVELBASE; + if (bAarea && !bComment) + --lev; + if (visibleChars == 0 && foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if ((bAarea) && (visibleChars > 0) && !(nContainment & NOT_HEADER) && !bComment) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + if ((lev & SC_FOLDLEVELNUMBERMASK) <= (levelPrev & SC_FOLDLEVELNUMBERMASK)) { + // this level is at the same level or less than the previous line + // therefore these is nothing for the previous header to collapse, so remove the header + styler.SetLevel(lineCurrent - 1, levelPrev & ~SC_FOLDLEVELHEADERFLAG); + } + levelPrev = lev; + visibleChars = 0; + bAarea = false; + bNewLine = true; + lineCurrent++; + } else { + bNewLine = false; + } + + + if (!isspacechar(ch)) + visibleChars++; + } + + // Fill in the real level of the next line, keeping the current flags as they will be filled in later + int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; + styler.SetLevel(lineCurrent, levelPrev | flagsNext); +} + +static const char * const COBOLWordListDesc[] = { + "A Keywords", + "B Keywords", + "Extended Keywords", + 0 +}; + +LexerModule lmCOBOL(SCLEX_COBOL, ColouriseCOBOLDoc, "COBOL", FoldCOBOLDoc, COBOLWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexCPP.cxx b/Pythonwin/Scintilla/lexers/LexCPP.cxx new file mode 100644 index 000000000..8ef4a1bfa --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexCPP.cxx @@ -0,0 +1,1785 @@ +// Scintilla source code edit control +/** @file LexCPP.cxx + ** Lexer for C++, C, Java, and JavaScript. + ** Further folding features and configuration properties added by "Udo Lechner" + **/ +// Copyright 1998-2005 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 "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "StringCopy.h" +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" +#include "SparseState.h" +#include "SubStyles.h" + +using namespace Scintilla; + +namespace { + // Use an unnamed namespace to protect the functions and classes from name conflicts + +constexpr bool IsSpaceEquiv(int state) noexcept { + return (state <= SCE_C_COMMENTDOC) || + // including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE + (state == SCE_C_COMMENTLINEDOC) || (state == SCE_C_COMMENTDOCKEYWORD) || + (state == SCE_C_COMMENTDOCKEYWORDERROR); +} + +// Preconditions: sc.currentPos points to a character after '+' or '-'. +// The test for pos reaching 0 should be redundant, +// and is in only for safety measures. +// Limitation: this code will give the incorrect answer for code like +// a = b+++/ptn/... +// Putting a space between the '++' post-inc operator and the '+' binary op +// fixes this, and is highly recommended for readability anyway. +bool FollowsPostfixOperator(const StyleContext &sc, LexAccessor &styler) { + Sci_Position pos = sc.currentPos; + while (--pos > 0) { + const char ch = styler[pos]; + if (ch == '+' || ch == '-') { + return styler[pos - 1] == ch; + } + } + return false; +} + +bool followsReturnKeyword(const StyleContext &sc, LexAccessor &styler) { + // Don't look at styles, so no need to flush. + Sci_Position pos = sc.currentPos; + const Sci_Position currentLine = styler.GetLine(pos); + const Sci_Position lineStartPos = styler.LineStart(currentLine); + while (--pos > lineStartPos) { + const char ch = styler.SafeGetCharAt(pos); + if (ch != ' ' && ch != '\t') { + break; + } + } + const char *retBack = "nruter"; + const char *s = retBack; + while (*s + && pos >= lineStartPos + && styler.SafeGetCharAt(pos) == *s) { + s++; + pos--; + } + return !*s; +} + +constexpr bool IsSpaceOrTab(int ch) noexcept { + return ch == ' ' || ch == '\t'; +} + +bool OnlySpaceOrTab(const std::string &s) noexcept { + for (const char ch : s) { + if (!IsSpaceOrTab(ch)) + return false; + } + return true; +} + +std::vector StringSplit(const std::string &text, int separator) { + std::vector vs(text.empty() ? 0 : 1); + for (const char ch : text) { + if (ch == separator) { + vs.emplace_back(); + } else { + vs.back() += ch; + } + } + return vs; +} + +struct BracketPair { + std::vector::iterator itBracket; + std::vector::iterator itEndBracket; +}; + +BracketPair FindBracketPair(std::vector &tokens) { + BracketPair bp; + std::vector::iterator itTok = std::find(tokens.begin(), tokens.end(), "("); + bp.itBracket = tokens.end(); + bp.itEndBracket = tokens.end(); + if (itTok != tokens.end()) { + bp.itBracket = itTok; + size_t nest = 0; + while (itTok != tokens.end()) { + if (*itTok == "(") { + nest++; + } else if (*itTok == ")") { + nest--; + if (nest == 0) { + bp.itEndBracket = itTok; + return bp; + } + } + ++itTok; + } + } + bp.itBracket = tokens.end(); + return bp; +} + +void highlightTaskMarker(StyleContext &sc, LexAccessor &styler, + int activity, const WordList &markerList, bool caseSensitive){ + if ((isoperator(sc.chPrev) || IsASpace(sc.chPrev)) && markerList.Length()) { + constexpr Sci_PositionU lengthMarker = 50; + char marker[lengthMarker+1] = ""; + const Sci_PositionU currPos = sc.currentPos; + Sci_PositionU i = 0; + while (i < lengthMarker) { + const char ch = styler.SafeGetCharAt(currPos + i); + if (IsASpace(ch) || isoperator(ch)) { + break; + } + if (caseSensitive) + marker[i] = ch; + else + marker[i] = MakeLowerCase(ch); + i++; + } + marker[i] = '\0'; + if (markerList.InList(marker)) { + sc.SetState(SCE_C_TASKMARKER|activity); + } + } +} + +class EscapeSequence { + const CharacterSet setHexDigits = CharacterSet(CharacterSet::setDigits, "ABCDEFabcdef"); + const CharacterSet setOctDigits = CharacterSet(CharacterSet::setNone, "01234567"); + const CharacterSet setNoneNumeric; + const CharacterSet *escapeSetValid = nullptr; + int digitsLeft = 0; +public: + EscapeSequence() = default; + void resetEscapeState(int nextChar) { + digitsLeft = 0; + escapeSetValid = &setNoneNumeric; + if (nextChar == 'U') { + digitsLeft = 9; + escapeSetValid = &setHexDigits; + } else if (nextChar == 'u') { + digitsLeft = 5; + escapeSetValid = &setHexDigits; + } else if (nextChar == 'x') { + digitsLeft = 5; + escapeSetValid = &setHexDigits; + } else if (setOctDigits.Contains(nextChar)) { + digitsLeft = 3; + escapeSetValid = &setOctDigits; + } + } + bool atEscapeEnd(int currChar) const { + return (digitsLeft <= 0) || !escapeSetValid->Contains(currChar); + } + void consumeDigit() noexcept { + digitsLeft--; + } +}; + +std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpace) { + std::string restOfLine; + Sci_Position line = styler.GetLine(start); + Sci_Position pos = start; + Sci_Position endLine = styler.LineEnd(line); + char ch = styler.SafeGetCharAt(start, '\n'); + while (pos < endLine) { + if (ch == '\\' && ((pos + 1) == endLine)) { + // Continuation line + line++; + pos = styler.LineStart(line); + endLine = styler.LineEnd(line); + ch = styler.SafeGetCharAt(pos, '\n'); + } else { + const char chNext = styler.SafeGetCharAt(pos + 1, '\n'); + if (ch == '/' && (chNext == '/' || chNext == '*')) + break; + if (allowSpace || (ch != ' ')) { + restOfLine += ch; + } + pos++; + ch = chNext; + } + } + return restOfLine; +} + +constexpr bool IsStreamCommentStyle(int style) noexcept { + return style == SCE_C_COMMENT || + style == SCE_C_COMMENTDOC || + style == SCE_C_COMMENTDOCKEYWORD || + style == SCE_C_COMMENTDOCKEYWORDERROR; +} + +struct PPDefinition { + Sci_Position line; + std::string key; + std::string value; + bool isUndef; + std::string arguments; + PPDefinition(Sci_Position line_, const std::string &key_, const std::string &value_, bool isUndef_ = false, const std::string &arguments_="") : + line(line_), key(key_), value(value_), isUndef(isUndef_), arguments(arguments_) { + } +}; + +constexpr int inactiveFlag = 0x40; + +class LinePPState { + // Track the state of preprocessor conditionals to allow showing active and inactive + // code in different styles. + // Only works up to 31 levels of conditional nesting. + + // state is a bit mask with 1 bit per level + // bit is 1 for level if section inactive, so any bits set = inactive style + int state = 0; + // ifTaken is a bit mask with 1 bit per level + // bit is 1 for level if some branch at this level has been taken + int ifTaken = 0; + // level is the nesting level of #if constructs + int level = -1; + static const int maximumNestingLevel = 31; + bool ValidLevel() const noexcept { + return level >= 0 && level < maximumNestingLevel; + } + int maskLevel() const noexcept { + if (level >= 0) { + return 1 << level; + } else { + return 1; + } + } +public: + LinePPState() noexcept { + } + bool IsActive() const noexcept { + return state == 0; + } + bool IsInactive() const noexcept { + return state != 0; + } + int ActiveState() const noexcept { + return state ? inactiveFlag : 0; + } + bool CurrentIfTaken() const noexcept { + return (ifTaken & maskLevel()) != 0; + } + void StartSection(bool on) noexcept { + level++; + if (ValidLevel()) { + if (on) { + state &= ~maskLevel(); + ifTaken |= maskLevel(); + } else { + state |= maskLevel(); + ifTaken &= ~maskLevel(); + } + } + } + void EndSection() noexcept { + if (ValidLevel()) { + state &= ~maskLevel(); + ifTaken &= ~maskLevel(); + } + level--; + } + void InvertCurrentLevel() noexcept { + if (ValidLevel()) { + state ^= maskLevel(); + ifTaken |= maskLevel(); + } + } +}; + +// Hold the preprocessor state for each line seen. +// Currently one entry per line but could become sparse with just one entry per preprocessor line. +class PPStates { + std::vector vlls; +public: + LinePPState ForLine(Sci_Position line) const noexcept { + if ((line > 0) && (vlls.size() > static_cast(line))) { + return vlls[line]; + } else { + return LinePPState(); + } + } + void Add(Sci_Position line, LinePPState lls) { + vlls.resize(line+1); + vlls[line] = lls; + } +}; + +// An individual named option for use in an OptionSet + +// Options used for LexerCPP +struct OptionsCPP { + bool stylingWithinPreprocessor; + bool identifiersAllowDollars; + bool trackPreprocessor; + bool updatePreprocessor; + bool verbatimStringsAllowEscapes; + bool triplequotedStrings; + bool hashquotedStrings; + bool backQuotedStrings; + bool escapeSequence; + bool fold; + bool foldSyntaxBased; + bool foldComment; + bool foldCommentMultiline; + bool foldCommentExplicit; + std::string foldExplicitStart; + std::string foldExplicitEnd; + bool foldExplicitAnywhere; + bool foldPreprocessor; + bool foldPreprocessorAtElse; + bool foldCompact; + bool foldAtElse; + OptionsCPP() { + stylingWithinPreprocessor = false; + identifiersAllowDollars = true; + trackPreprocessor = true; + updatePreprocessor = true; + verbatimStringsAllowEscapes = false; + triplequotedStrings = false; + hashquotedStrings = false; + backQuotedStrings = false; + escapeSequence = false; + fold = false; + foldSyntaxBased = true; + foldComment = false; + foldCommentMultiline = true; + foldCommentExplicit = true; + foldExplicitStart = ""; + foldExplicitEnd = ""; + foldExplicitAnywhere = false; + foldPreprocessor = false; + foldPreprocessorAtElse = false; + foldCompact = false; + foldAtElse = false; + } +}; + +const char *const cppWordLists[] = { + "Primary keywords and identifiers", + "Secondary keywords and identifiers", + "Documentation comment keywords", + "Global classes and typedefs", + "Preprocessor definitions", + "Task marker and error marker keywords", + nullptr, +}; + +struct OptionSetCPP : public OptionSet { + OptionSetCPP() { + DefineProperty("styling.within.preprocessor", &OptionsCPP::stylingWithinPreprocessor, + "For C++ code, determines whether all preprocessor code is styled in the " + "preprocessor style (0, the default) or only from the initial # to the end " + "of the command word(1)."); + + DefineProperty("lexer.cpp.allow.dollars", &OptionsCPP::identifiersAllowDollars, + "Set to 0 to disallow the '$' character in identifiers with the cpp lexer."); + + DefineProperty("lexer.cpp.track.preprocessor", &OptionsCPP::trackPreprocessor, + "Set to 1 to interpret #if/#else/#endif to grey out code that is not active."); + + DefineProperty("lexer.cpp.update.preprocessor", &OptionsCPP::updatePreprocessor, + "Set to 1 to update preprocessor definitions when #define found."); + + DefineProperty("lexer.cpp.verbatim.strings.allow.escapes", &OptionsCPP::verbatimStringsAllowEscapes, + "Set to 1 to allow verbatim strings to contain escape sequences."); + + DefineProperty("lexer.cpp.triplequoted.strings", &OptionsCPP::triplequotedStrings, + "Set to 1 to enable highlighting of triple-quoted strings."); + + DefineProperty("lexer.cpp.hashquoted.strings", &OptionsCPP::hashquotedStrings, + "Set to 1 to enable highlighting of hash-quoted strings."); + + DefineProperty("lexer.cpp.backquoted.strings", &OptionsCPP::backQuotedStrings, + "Set to 1 to enable highlighting of back-quoted raw strings ."); + + DefineProperty("lexer.cpp.escape.sequence", &OptionsCPP::escapeSequence, + "Set to 1 to enable highlighting of escape sequences in strings"); + + DefineProperty("fold", &OptionsCPP::fold); + + DefineProperty("fold.cpp.syntax.based", &OptionsCPP::foldSyntaxBased, + "Set this property to 0 to disable syntax based folding."); + + DefineProperty("fold.comment", &OptionsCPP::foldComment, + "This option enables folding multi-line comments and explicit fold points when using the C++ lexer. " + "Explicit fold points allows adding extra folding by placing a //{ comment at the start and a //} " + "at the end of a section that should fold."); + + DefineProperty("fold.cpp.comment.multiline", &OptionsCPP::foldCommentMultiline, + "Set this property to 0 to disable folding multi-line comments when fold.comment=1."); + + DefineProperty("fold.cpp.comment.explicit", &OptionsCPP::foldCommentExplicit, + "Set this property to 0 to disable folding explicit fold points when fold.comment=1."); + + DefineProperty("fold.cpp.explicit.start", &OptionsCPP::foldExplicitStart, + "The string to use for explicit fold start points, replacing the standard //{."); + + DefineProperty("fold.cpp.explicit.end", &OptionsCPP::foldExplicitEnd, + "The string to use for explicit fold end points, replacing the standard //}."); + + DefineProperty("fold.cpp.explicit.anywhere", &OptionsCPP::foldExplicitAnywhere, + "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); + + DefineProperty("fold.cpp.preprocessor.at.else", &OptionsCPP::foldPreprocessorAtElse, + "This option enables folding on a preprocessor #else or #endif line of an #if statement."); + + DefineProperty("fold.preprocessor", &OptionsCPP::foldPreprocessor, + "This option enables folding preprocessor directives when using the C++ lexer. " + "Includes C#'s explicit #region and #endregion folding directives."); + + DefineProperty("fold.compact", &OptionsCPP::foldCompact); + + DefineProperty("fold.at.else", &OptionsCPP::foldAtElse, + "This option enables C++ folding on a \"} else {\" line of an if statement."); + + DefineWordListSets(cppWordLists); + } +}; + +const char styleSubable[] = {SCE_C_IDENTIFIER, SCE_C_COMMENTDOCKEYWORD, 0}; + +LexicalClass lexicalClasses[] = { + // Lexer Cpp SCLEX_CPP SCE_C_: + 0, "SCE_C_DEFAULT", "default", "White space", + 1, "SCE_C_COMMENT", "comment", "Comment: /* */.", + 2, "SCE_C_COMMENTLINE", "comment line", "Line Comment: //.", + 3, "SCE_C_COMMENTDOC", "comment documentation", "Doc comment: block comments beginning with /** or /*!", + 4, "SCE_C_NUMBER", "literal numeric", "Number", + 5, "SCE_C_WORD", "keyword", "Keyword", + 6, "SCE_C_STRING", "literal string", "Double quoted string", + 7, "SCE_C_CHARACTER", "literal string character", "Single quoted string", + 8, "SCE_C_UUID", "literal uuid", "UUIDs (only in IDL)", + 9, "SCE_C_PREPROCESSOR", "preprocessor", "Preprocessor", + 10, "SCE_C_OPERATOR", "operator", "Operators", + 11, "SCE_C_IDENTIFIER", "identifier", "Identifiers", + 12, "SCE_C_STRINGEOL", "error literal string", "End of line where string is not closed", + 13, "SCE_C_VERBATIM", "literal string multiline raw", "Verbatim strings for C#", + 14, "SCE_C_REGEX", "literal regex", "Regular expressions for JavaScript", + 15, "SCE_C_COMMENTLINEDOC", "comment documentation line", "Doc Comment Line: line comments beginning with /// or //!.", + 16, "SCE_C_WORD2", "identifier", "Keywords2", + 17, "SCE_C_COMMENTDOCKEYWORD", "comment documentation keyword", "Comment keyword", + 18, "SCE_C_COMMENTDOCKEYWORDERROR", "error comment documentation keyword", "Comment keyword error", + 19, "SCE_C_GLOBALCLASS", "identifier", "Global class", + 20, "SCE_C_STRINGRAW", "literal string multiline raw", "Raw strings for C++0x", + 21, "SCE_C_TRIPLEVERBATIM", "literal string multiline raw", "Triple-quoted strings for Vala", + 22, "SCE_C_HASHQUOTEDSTRING", "literal string", "Hash-quoted strings for Pike", + 23, "SCE_C_PREPROCESSORCOMMENT", "comment preprocessor", "Preprocessor stream comment", + 24, "SCE_C_PREPROCESSORCOMMENTDOC", "comment preprocessor documentation", "Preprocessor stream doc comment", + 25, "SCE_C_USERLITERAL", "literal", "User defined literals", + 26, "SCE_C_TASKMARKER", "comment taskmarker", "Task Marker", + 27, "SCE_C_ESCAPESEQUENCE", "literal string escapesequence", "Escape sequence", +}; + +const int sizeLexicalClasses = static_cast(std::size(lexicalClasses)); + +} + +class LexerCPP : public ILexer5 { + bool caseSensitive; + CharacterSet setWord; + CharacterSet setNegationOp; + CharacterSet setAddOp; + CharacterSet setMultOp; + CharacterSet setRelOp; + CharacterSet setLogicalOp; + CharacterSet setWordStart; + PPStates vlls; + std::vector ppDefineHistory; + WordList keywords; + WordList keywords2; + WordList keywords3; + WordList keywords4; + WordList ppDefinitions; + WordList markerList; + struct SymbolValue { + std::string value; + std::string arguments; + SymbolValue() noexcept = default; + SymbolValue(const std::string &value_, const std::string &arguments_) : value(value_), arguments(arguments_) { + } + SymbolValue &operator = (const std::string &value_) { + value = value_; + arguments.clear(); + return *this; + } + bool IsMacro() const noexcept { + return !arguments.empty(); + } + }; + typedef std::map SymbolTable; + SymbolTable preprocessorDefinitionsStart; + OptionsCPP options; + OptionSetCPP osCPP; + EscapeSequence escapeSeq; + SparseState rawStringTerminators; + enum { ssIdentifier, ssDocKeyword }; + SubStyles subStyles; + std::string returnBuffer; +public: + explicit LexerCPP(bool caseSensitive_) : + caseSensitive(caseSensitive_), + setWord(CharacterSet::setAlphaNum, "._", 0x80, true), + setNegationOp(CharacterSet::setNone, "!"), + setAddOp(CharacterSet::setNone, "+-"), + setMultOp(CharacterSet::setNone, "*/%"), + setRelOp(CharacterSet::setNone, "=!<>"), + setLogicalOp(CharacterSet::setNone, "|&"), + subStyles(styleSubable, 0x80, 0x40, inactiveFlag) { + } + // Deleted so LexerCPP objects can not be copied. + LexerCPP(const LexerCPP &) = delete; + LexerCPP(LexerCPP &&) = delete; + void operator=(const LexerCPP &) = delete; + void operator=(LexerCPP &&) = delete; + virtual ~LexerCPP() { + } + void SCI_METHOD Release() noexcept override { + delete this; + } + int SCI_METHOD Version() const noexcept override { + return lvRelease5; + } + const char * SCI_METHOD PropertyNames() override { + return osCPP.PropertyNames(); + } + int SCI_METHOD PropertyType(const char *name) override { + return osCPP.PropertyType(name); + } + const char * SCI_METHOD DescribeProperty(const char *name) override { + return osCPP.DescribeProperty(name); + } + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override; + const char * SCI_METHOD DescribeWordListSets() override { + return osCPP.DescribeWordListSets(); + } + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override; + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + + void * SCI_METHOD PrivateCall(int, void *) noexcept override { + return nullptr; + } + + int SCI_METHOD LineEndTypesSupported() noexcept override { + return SC_LINE_END_TYPE_UNICODE; + } + + int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override { + return subStyles.Allocate(styleBase, numberStyles); + } + int SCI_METHOD SubStylesStart(int styleBase) override { + return subStyles.Start(styleBase); + } + int SCI_METHOD SubStylesLength(int styleBase) override { + return subStyles.Length(styleBase); + } + int SCI_METHOD StyleFromSubStyle(int subStyle) override { + const int styleBase = subStyles.BaseStyle(MaskActive(subStyle)); + const int inactive = subStyle & inactiveFlag; + return styleBase | inactive; + } + int SCI_METHOD PrimaryStyleFromStyle(int style) noexcept override { + return MaskActive(style); + } + void SCI_METHOD FreeSubStyles() override { + subStyles.Free(); + } + void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override { + subStyles.SetIdentifiers(style, identifiers); + } + int SCI_METHOD DistanceToSecondaryStyles() noexcept override { + return inactiveFlag; + } + const char * SCI_METHOD GetSubStyleBases() noexcept override { + return styleSubable; + } + int SCI_METHOD NamedStyles() override { + return std::max(subStyles.LastAllocated() + 1, + sizeLexicalClasses) + + inactiveFlag; + } + const char * SCI_METHOD NameOfStyle(int style) override { + if (style >= NamedStyles()) + return ""; + if (style < sizeLexicalClasses) + return lexicalClasses[style].name; + // TODO: inactive and substyles + return ""; + } + const char * SCI_METHOD TagsOfStyle(int style) override { + if (style >= NamedStyles()) + return "Excess"; + returnBuffer.clear(); + const int firstSubStyle = subStyles.FirstAllocated(); + if (firstSubStyle >= 0) { + const int lastSubStyle = subStyles.LastAllocated(); + if (((style >= firstSubStyle) && (style <= (lastSubStyle))) || + ((style >= firstSubStyle + inactiveFlag) && (style <= (lastSubStyle + inactiveFlag)))) { + int styleActive = style; + if (style > lastSubStyle) { + returnBuffer = "inactive "; + styleActive -= inactiveFlag; + } + const int styleMain = StyleFromSubStyle(styleActive); + returnBuffer += lexicalClasses[styleMain].tags; + return returnBuffer.c_str(); + } + } + if (style < sizeLexicalClasses) + return lexicalClasses[style].tags; + if (style >= inactiveFlag) { + returnBuffer = "inactive "; + const int styleActive = style - inactiveFlag; + if (styleActive < sizeLexicalClasses) + returnBuffer += lexicalClasses[styleActive].tags; + else + returnBuffer = ""; + return returnBuffer.c_str(); + } + return ""; + } + const char * SCI_METHOD DescriptionOfStyle(int style) override { + if (style >= NamedStyles()) + return ""; + if (style < sizeLexicalClasses) + return lexicalClasses[style].description; + // TODO: inactive and substyles + return ""; + } + + // ILexer5 methods + const char * SCI_METHOD GetName() override { + return caseSensitive ? "cpp" : "cppnocase"; + } + int SCI_METHOD GetIdentifier() override { + return caseSensitive ? SCLEX_CPP : SCLEX_CPPNOCASE; + } + const char * SCI_METHOD PropertyGet(const char *key) override; + + static ILexer5 *LexerFactoryCPP() { + return new LexerCPP(true); + } + static ILexer5 *LexerFactoryCPPInsensitive() { + return new LexerCPP(false); + } + constexpr static int MaskActive(int style) noexcept { + return style & ~inactiveFlag; + } + void EvaluateTokens(std::vector &tokens, const SymbolTable &preprocessorDefinitions); + std::vector Tokenize(const std::string &expr) const; + bool EvaluateExpression(const std::string &expr, const SymbolTable &preprocessorDefinitions); +}; + +Sci_Position SCI_METHOD LexerCPP::PropertySet(const char *key, const char *val) { + if (osCPP.PropertySet(&options, key, val)) { + if (strcmp(key, "lexer.cpp.allow.dollars") == 0) { + setWord = CharacterSet(CharacterSet::setAlphaNum, "._", 0x80, true); + if (options.identifiersAllowDollars) { + setWord.Add('$'); + } + } + return 0; + } + return -1; +} + +const char * SCI_METHOD LexerCPP::PropertyGet(const char *key) { + return osCPP.PropertyGet(key); +} + +Sci_Position SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) { + WordList *wordListN = nullptr; + switch (n) { + case 0: + wordListN = &keywords; + break; + case 1: + wordListN = &keywords2; + break; + case 2: + wordListN = &keywords3; + break; + case 3: + wordListN = &keywords4; + break; + case 4: + wordListN = &ppDefinitions; + break; + case 5: + wordListN = &markerList; + break; + } + Sci_Position firstModification = -1; + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + if (n == 4) { + // Rebuild preprocessorDefinitions + preprocessorDefinitionsStart.clear(); + for (int nDefinition = 0; nDefinition < ppDefinitions.Length(); nDefinition++) { + const char *cpDefinition = ppDefinitions.WordAt(nDefinition); + const char *cpEquals = strchr(cpDefinition, '='); + if (cpEquals) { + std::string name(cpDefinition, cpEquals - cpDefinition); + std::string val(cpEquals+1); + const size_t bracket = name.find('('); + const size_t bracketEnd = name.find(')'); + if ((bracket != std::string::npos) && (bracketEnd != std::string::npos)) { + // Macro + std::string args = name.substr(bracket + 1, bracketEnd - bracket - 1); + name = name.substr(0, bracket); + preprocessorDefinitionsStart[name] = SymbolValue(val, args); + } else { + preprocessorDefinitionsStart[name] = val; + } + } else { + std::string name(cpDefinition); + std::string val("1"); + preprocessorDefinitionsStart[name] = val; + } + } + } + } + } + return firstModification; +} + +void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + LexAccessor styler(pAccess); + + CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-"); + CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-"); + + CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]"); + + setWordStart = CharacterSet(CharacterSet::setAlpha, "_", 0x80, true); + + CharacterSet setInvalidRawFirst(CharacterSet::setNone, " )\\\t\v\f\n"); + + if (options.identifiersAllowDollars) { + setWordStart.Add('$'); + } + + int chPrevNonWhite = ' '; + int visibleChars = 0; + bool lastWordWasUUID = false; + int styleBeforeDCKeyword = SCE_C_DEFAULT; + int styleBeforeTaskMarker = SCE_C_DEFAULT; + bool continuationLine = false; + bool isIncludePreprocessor = false; + bool isStringInPreprocessor = false; + bool inRERange = false; + bool seenDocKeyBrace = false; + + Sci_Position lineCurrent = styler.GetLine(startPos); + if ((MaskActive(initStyle) == SCE_C_PREPROCESSOR) || + (MaskActive(initStyle) == SCE_C_COMMENTLINE) || + (MaskActive(initStyle) == SCE_C_COMMENTLINEDOC)) { + // Set continuationLine if last character of previous line is '\' + if (lineCurrent > 0) { + const Sci_Position endLinePrevious = styler.LineEnd(lineCurrent - 1); + if (endLinePrevious > 0) { + continuationLine = styler.SafeGetCharAt(endLinePrevious-1) == '\\'; + } + } + } + + // look back to set chPrevNonWhite properly for better regex colouring + if (startPos > 0) { + Sci_Position back = startPos; + while (--back && IsSpaceEquiv(MaskActive(styler.StyleAt(back)))) + ; + if (MaskActive(styler.StyleAt(back)) == SCE_C_OPERATOR) { + chPrevNonWhite = styler.SafeGetCharAt(back); + } + } + + StyleContext sc(startPos, length, initStyle, styler); + LinePPState preproc = vlls.ForLine(lineCurrent); + + bool definitionsChanged = false; + + // Truncate ppDefineHistory before current line + + if (!options.updatePreprocessor) + ppDefineHistory.clear(); + + std::vector::iterator itInvalid = std::find_if(ppDefineHistory.begin(), ppDefineHistory.end(), + [lineCurrent](const PPDefinition &p) noexcept { return p.line >= lineCurrent; }); + if (itInvalid != ppDefineHistory.end()) { + ppDefineHistory.erase(itInvalid, ppDefineHistory.end()); + definitionsChanged = true; + } + + SymbolTable preprocessorDefinitions = preprocessorDefinitionsStart; + for (const PPDefinition &ppDef : ppDefineHistory) { + if (ppDef.isUndef) + preprocessorDefinitions.erase(ppDef.key); + else + preprocessorDefinitions[ppDef.key] = SymbolValue(ppDef.value, ppDef.arguments); + } + + std::string rawStringTerminator = rawStringTerminators.ValueAt(lineCurrent-1); + SparseState rawSTNew(lineCurrent); + + int activitySet = preproc.ActiveState(); + + const WordClassifier &classifierIdentifiers = subStyles.Classifier(SCE_C_IDENTIFIER); + const WordClassifier &classifierDocKeyWords = subStyles.Classifier(SCE_C_COMMENTDOCKEYWORD); + + Sci_PositionU lineEndNext = styler.LineEnd(lineCurrent); + + for (; sc.More();) { + + if (sc.atLineStart) { + // Using MaskActive() is not needed in the following statement. + // Inside inactive preprocessor declaration, state will be reset anyway at the end of this block. + if ((sc.state == SCE_C_STRING) || (sc.state == SCE_C_CHARACTER)) { + // Prevent SCE_C_STRINGEOL from leaking back to previous line which + // ends with a line continuation by locking in the state up to this position. + sc.SetState(sc.state); + } + if ((MaskActive(sc.state) == SCE_C_PREPROCESSOR) && (!continuationLine)) { + sc.SetState(SCE_C_DEFAULT|activitySet); + } + // Reset states to beginning of colourise so no surprises + // if different sets of lines lexed. + visibleChars = 0; + lastWordWasUUID = false; + isIncludePreprocessor = false; + inRERange = false; + if (preproc.IsInactive()) { + activitySet = inactiveFlag; + sc.SetState(sc.state | activitySet); + } + } + + if (sc.atLineEnd) { + lineCurrent++; + lineEndNext = styler.LineEnd(lineCurrent); + vlls.Add(lineCurrent, preproc); + if (rawStringTerminator != "") { + rawSTNew.Set(lineCurrent-1, rawStringTerminator); + } + } + + // Handle line continuation generically. + if (sc.ch == '\\') { + if ((sc.currentPos+1) >= lineEndNext) { + lineCurrent++; + lineEndNext = styler.LineEnd(lineCurrent); + vlls.Add(lineCurrent, preproc); + if (rawStringTerminator != "") { + rawSTNew.Set(lineCurrent-1, rawStringTerminator); + } + sc.Forward(); + if (sc.ch == '\r' && sc.chNext == '\n') { + // Even in UTF-8, \r and \n are separate + sc.Forward(); + } + continuationLine = true; + sc.Forward(); + continue; + } + } + + const bool atLineEndBeforeSwitch = sc.atLineEnd; + + // Determine if the current state should terminate. + switch (MaskActive(sc.state)) { + case SCE_C_OPERATOR: + sc.SetState(SCE_C_DEFAULT|activitySet); + break; + case SCE_C_NUMBER: + // We accept almost anything because of hex. and number suffixes + if (sc.ch == '_') { + sc.ChangeState(SCE_C_USERLITERAL|activitySet); + } else if (!(setWord.Contains(sc.ch) + || (sc.ch == '\'') + || ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E' || + sc.chPrev == 'p' || sc.chPrev == 'P')))) { + sc.SetState(SCE_C_DEFAULT|activitySet); + } + break; + case SCE_C_USERLITERAL: + if (!(setWord.Contains(sc.ch))) + sc.SetState(SCE_C_DEFAULT|activitySet); + break; + case SCE_C_IDENTIFIER: + if (sc.atLineStart || sc.atLineEnd || !setWord.Contains(sc.ch) || (sc.ch == '.')) { + char s[1000]; + if (caseSensitive) { + sc.GetCurrent(s, sizeof(s)); + } else { + sc.GetCurrentLowered(s, sizeof(s)); + } + if (keywords.InList(s)) { + lastWordWasUUID = strcmp(s, "uuid") == 0; + sc.ChangeState(SCE_C_WORD|activitySet); + } else if (keywords2.InList(s)) { + sc.ChangeState(SCE_C_WORD2|activitySet); + } else if (keywords4.InList(s)) { + sc.ChangeState(SCE_C_GLOBALCLASS|activitySet); + } else { + int subStyle = classifierIdentifiers.ValueFor(s); + if (subStyle >= 0) { + sc.ChangeState(subStyle|activitySet); + } + } + const bool literalString = sc.ch == '\"'; + if (literalString || sc.ch == '\'') { + size_t lenS = strlen(s); + const bool raw = literalString && sc.chPrev == 'R' && !setInvalidRawFirst.Contains(sc.chNext); + if (raw) + s[lenS--] = '\0'; + const bool valid = + (lenS == 0) || + ((lenS == 1) && ((s[0] == 'L') || (s[0] == 'u') || (s[0] == 'U'))) || + ((lenS == 2) && literalString && (s[0] == 'u') && (s[1] == '8')); + if (valid) { + if (literalString) { + if (raw) { + // Set the style of the string prefix to SCE_C_STRINGRAW but then change to + // SCE_C_DEFAULT as that allows the raw string start code to run. + sc.ChangeState(SCE_C_STRINGRAW|activitySet); + sc.SetState(SCE_C_DEFAULT|activitySet); + } else { + sc.ChangeState(SCE_C_STRING|activitySet); + } + } else { + sc.ChangeState(SCE_C_CHARACTER|activitySet); + } + } else { + sc.SetState(SCE_C_DEFAULT | activitySet); + } + } else { + sc.SetState(SCE_C_DEFAULT|activitySet); + } + } + break; + case SCE_C_PREPROCESSOR: + if (options.stylingWithinPreprocessor) { + if (IsASpace(sc.ch) || (sc.ch == '(')) { + sc.SetState(SCE_C_DEFAULT|activitySet); + } + } else if (isStringInPreprocessor && (sc.Match('>') || sc.Match('\"') || sc.atLineEnd)) { + isStringInPreprocessor = false; + } else if (!isStringInPreprocessor) { + if ((isIncludePreprocessor && sc.Match('<')) || sc.Match('\"')) { + isStringInPreprocessor = true; + } else if (sc.Match('/', '*')) { + if (sc.Match("/**") || sc.Match("/*!")) { + sc.SetState(SCE_C_PREPROCESSORCOMMENTDOC|activitySet); + } else { + sc.SetState(SCE_C_PREPROCESSORCOMMENT|activitySet); + } + sc.Forward(); // Eat the * + } else if (sc.Match('/', '/')) { + sc.SetState(SCE_C_DEFAULT|activitySet); + } + } + break; + case SCE_C_PREPROCESSORCOMMENT: + case SCE_C_PREPROCESSORCOMMENTDOC: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_C_PREPROCESSOR|activitySet); + continue; // Without advancing in case of '\'. + } + break; + case SCE_C_COMMENT: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_C_DEFAULT|activitySet); + } else { + styleBeforeTaskMarker = SCE_C_COMMENT; + highlightTaskMarker(sc, styler, activitySet, markerList, caseSensitive); + } + break; + case SCE_C_COMMENTDOC: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_C_DEFAULT|activitySet); + } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = SCE_C_COMMENTDOC; + sc.SetState(SCE_C_COMMENTDOCKEYWORD|activitySet); + } + } + break; + case SCE_C_COMMENTLINE: + if (sc.atLineStart && !continuationLine) { + sc.SetState(SCE_C_DEFAULT|activitySet); + } else { + styleBeforeTaskMarker = SCE_C_COMMENTLINE; + highlightTaskMarker(sc, styler, activitySet, markerList, caseSensitive); + } + break; + case SCE_C_COMMENTLINEDOC: + if (sc.atLineStart && !continuationLine) { + sc.SetState(SCE_C_DEFAULT|activitySet); + } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = SCE_C_COMMENTLINEDOC; + sc.SetState(SCE_C_COMMENTDOCKEYWORD|activitySet); + } + } + break; + case SCE_C_COMMENTDOCKEYWORD: + if ((styleBeforeDCKeyword == SCE_C_COMMENTDOC) && sc.Match('*', '/')) { + sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR); + sc.Forward(); + sc.ForwardSetState(SCE_C_DEFAULT|activitySet); + seenDocKeyBrace = false; + } else if (sc.ch == '[' || sc.ch == '{') { + seenDocKeyBrace = true; + } else if (!setDoxygen.Contains(sc.ch) + && !(seenDocKeyBrace && (sc.ch == ',' || sc.ch == '.'))) { + char s[100]; + if (caseSensitive) { + sc.GetCurrent(s, sizeof(s)); + } else { + sc.GetCurrentLowered(s, sizeof(s)); + } + if (!(IsASpace(sc.ch) || (sc.ch == 0))) { + sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR|activitySet); + } else if (!keywords3.InList(s + 1)) { + int subStyleCDKW = classifierDocKeyWords.ValueFor(s+1); + if (subStyleCDKW >= 0) { + sc.ChangeState(subStyleCDKW|activitySet); + } else { + sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR|activitySet); + } + } + sc.SetState(styleBeforeDCKeyword|activitySet); + seenDocKeyBrace = false; + } + break; + case SCE_C_STRING: + if (sc.atLineEnd) { + sc.ChangeState(SCE_C_STRINGEOL|activitySet); + } else if (isIncludePreprocessor) { + if (sc.ch == '>') { + sc.ForwardSetState(SCE_C_DEFAULT|activitySet); + isIncludePreprocessor = false; + } + } else if (sc.ch == '\\') { + if (options.escapeSequence) { + sc.SetState(SCE_C_ESCAPESEQUENCE|activitySet); + escapeSeq.resetEscapeState(sc.chNext); + } + sc.Forward(); // Skip all characters after the backslash + } else if (sc.ch == '\"') { + if (sc.chNext == '_') { + sc.ChangeState(SCE_C_USERLITERAL|activitySet); + } else { + sc.ForwardSetState(SCE_C_DEFAULT|activitySet); + } + } + break; + case SCE_C_ESCAPESEQUENCE: + escapeSeq.consumeDigit(); + if (!escapeSeq.atEscapeEnd(sc.ch)) { + break; + } + if (sc.ch == '"') { + sc.SetState(SCE_C_STRING|activitySet); + sc.ForwardSetState(SCE_C_DEFAULT|activitySet); + } else if (sc.ch == '\\') { + escapeSeq.resetEscapeState(sc.chNext); + sc.Forward(); + } else { + sc.SetState(SCE_C_STRING|activitySet); + if (sc.atLineEnd) { + sc.ChangeState(SCE_C_STRINGEOL|activitySet); + } + } + break; + case SCE_C_HASHQUOTEDSTRING: + if (sc.ch == '\\') { + if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\"') { + sc.ForwardSetState(SCE_C_DEFAULT|activitySet); + } + break; + case SCE_C_STRINGRAW: + if (sc.Match(rawStringTerminator.c_str())) { + for (size_t termPos=rawStringTerminator.size(); termPos; termPos--) + sc.Forward(); + sc.SetState(SCE_C_DEFAULT|activitySet); + rawStringTerminator = ""; + } + break; + case SCE_C_CHARACTER: + if (sc.atLineEnd) { + sc.ChangeState(SCE_C_STRINGEOL|activitySet); + } else if (sc.ch == '\\') { + if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\'') { + if (sc.chNext == '_') { + sc.ChangeState(SCE_C_USERLITERAL|activitySet); + } else { + sc.ForwardSetState(SCE_C_DEFAULT|activitySet); + } + } + break; + case SCE_C_REGEX: + if (sc.atLineStart) { + sc.SetState(SCE_C_DEFAULT|activitySet); + } else if (!inRERange && sc.ch == '/') { + sc.Forward(); + while (IsLowerCase(sc.ch)) + sc.Forward(); // gobble regex flags + sc.SetState(SCE_C_DEFAULT|activitySet); + } else if (sc.ch == '\\' && ((sc.currentPos+1) < lineEndNext)) { + // Gobble up the escaped character + sc.Forward(); + } else if (sc.ch == '[') { + inRERange = true; + } else if (sc.ch == ']') { + inRERange = false; + } + break; + case SCE_C_STRINGEOL: + if (sc.atLineStart) { + sc.SetState(SCE_C_DEFAULT|activitySet); + } + break; + case SCE_C_VERBATIM: + if (options.verbatimStringsAllowEscapes && (sc.ch == '\\')) { + sc.Forward(); // Skip all characters after the backslash + } else if (sc.ch == '\"') { + if (sc.chNext == '\"') { + sc.Forward(); + } else { + sc.ForwardSetState(SCE_C_DEFAULT|activitySet); + } + } + break; + case SCE_C_TRIPLEVERBATIM: + if (sc.Match(R"(""")")) { + while (sc.Match('"')) { + sc.Forward(); + } + sc.SetState(SCE_C_DEFAULT|activitySet); + } + break; + case SCE_C_UUID: + if (sc.atLineEnd || sc.ch == ')') { + sc.SetState(SCE_C_DEFAULT|activitySet); + } + break; + case SCE_C_TASKMARKER: + if (isoperator(sc.ch) || IsASpace(sc.ch)) { + sc.SetState(styleBeforeTaskMarker|activitySet); + styleBeforeTaskMarker = SCE_C_DEFAULT; + } + } + + if (sc.atLineEnd && !atLineEndBeforeSwitch) { + // State exit processing consumed characters up to end of line. + lineCurrent++; + lineEndNext = styler.LineEnd(lineCurrent); + vlls.Add(lineCurrent, preproc); + } + + // Determine if a new state should be entered. + if (MaskActive(sc.state) == SCE_C_DEFAULT) { + if (sc.Match('@', '\"')) { + sc.SetState(SCE_C_VERBATIM|activitySet); + sc.Forward(); + } else if (options.triplequotedStrings && sc.Match(R"(""")")) { + sc.SetState(SCE_C_TRIPLEVERBATIM|activitySet); + sc.Forward(2); + } else if (options.hashquotedStrings && sc.Match('#', '\"')) { + sc.SetState(SCE_C_HASHQUOTEDSTRING|activitySet); + sc.Forward(); + } else if (options.backQuotedStrings && sc.Match('`')) { + sc.SetState(SCE_C_STRINGRAW|activitySet); + rawStringTerminator = "`"; + } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { + if (lastWordWasUUID) { + sc.SetState(SCE_C_UUID|activitySet); + lastWordWasUUID = false; + } else { + sc.SetState(SCE_C_NUMBER|activitySet); + } + } else if (!sc.atLineEnd && (setWordStart.Contains(sc.ch) || (sc.ch == '@'))) { + if (lastWordWasUUID) { + sc.SetState(SCE_C_UUID|activitySet); + lastWordWasUUID = false; + } else { + sc.SetState(SCE_C_IDENTIFIER|activitySet); + } + } else if (sc.Match('/', '*')) { + if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style + sc.SetState(SCE_C_COMMENTDOC|activitySet); + } else { + sc.SetState(SCE_C_COMMENT|activitySet); + } + sc.Forward(); // Eat the * so it isn't used for the end of the comment + } else if (sc.Match('/', '/')) { + if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!")) + // Support of Qt/Doxygen doc. style + sc.SetState(SCE_C_COMMENTLINEDOC|activitySet); + else + sc.SetState(SCE_C_COMMENTLINE|activitySet); + } else if (sc.ch == '/' + && (setOKBeforeRE.Contains(chPrevNonWhite) + || followsReturnKeyword(sc, styler)) + && (!setCouldBePostOp.Contains(chPrevNonWhite) + || !FollowsPostfixOperator(sc, styler))) { + sc.SetState(SCE_C_REGEX|activitySet); // JavaScript's RegEx + inRERange = false; + } else if (sc.ch == '\"') { + if (sc.chPrev == 'R') { + styler.Flush(); + if (MaskActive(styler.StyleAt(sc.currentPos - 1)) == SCE_C_STRINGRAW) { + sc.SetState(SCE_C_STRINGRAW|activitySet); + rawStringTerminator = ")"; + for (Sci_Position termPos = sc.currentPos + 1;; termPos++) { + const char chTerminator = styler.SafeGetCharAt(termPos, '('); + if (chTerminator == '(') + break; + rawStringTerminator += chTerminator; + } + rawStringTerminator += '\"'; + } else { + sc.SetState(SCE_C_STRING|activitySet); + } + } else { + sc.SetState(SCE_C_STRING|activitySet); + } + isIncludePreprocessor = false; // ensure that '>' won't end the string + } else if (isIncludePreprocessor && sc.ch == '<') { + sc.SetState(SCE_C_STRING|activitySet); + } else if (sc.ch == '\'') { + sc.SetState(SCE_C_CHARACTER|activitySet); + } else if (sc.ch == '#' && visibleChars == 0) { + // Preprocessor commands are alone on their line + sc.SetState(SCE_C_PREPROCESSOR|activitySet); + // Skip whitespace between # and preprocessor word + do { + sc.Forward(); + } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More()); + if (sc.atLineEnd) { + sc.SetState(SCE_C_DEFAULT|activitySet); + } else if (sc.Match("include")) { + isIncludePreprocessor = true; + } else { + if (options.trackPreprocessor) { + // If #if is nested too deeply (>31 levels) the active/inactive appearance + // will stop reflecting the code. + if (sc.Match("ifdef") || sc.Match("ifndef")) { + const bool isIfDef = sc.Match("ifdef"); + const int startRest = isIfDef ? 5 : 6; + std::string restOfLine = GetRestOfLine(styler, sc.currentPos + startRest + 1, false); + bool foundDef = preprocessorDefinitions.find(restOfLine) != preprocessorDefinitions.end(); + preproc.StartSection(isIfDef == foundDef); + } else if (sc.Match("if")) { + std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 2, true); + const bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions); + preproc.StartSection(ifGood); + } else if (sc.Match("else")) { + // #else is shown as active if either preceding or following section is active + // as that means that it contributed to the result. + if (!preproc.CurrentIfTaken()) { + // Inactive, may become active if parent scope active + assert(sc.state == (SCE_C_PREPROCESSOR|inactiveFlag)); + preproc.InvertCurrentLevel(); + activitySet = preproc.ActiveState(); + // If following is active then show "else" as active + if (!activitySet) + sc.ChangeState(SCE_C_PREPROCESSOR); + } else if (preproc.IsActive()) { + // Active -> inactive + assert(sc.state == SCE_C_PREPROCESSOR); + preproc.InvertCurrentLevel(); + activitySet = preproc.ActiveState(); + // Continue to show "else" as active as it ends active section. + } + } else if (sc.Match("elif")) { + // Ensure only one chosen out of #if .. #elif .. #elif .. #else .. #endif + // #elif is shown as active if either preceding or following section is active + // as that means that it contributed to the result. + if (!preproc.CurrentIfTaken()) { + // Inactive, if expression true then may become active if parent scope active + assert(sc.state == (SCE_C_PREPROCESSOR|inactiveFlag)); + // Similar to #if + std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 4, true); + const bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions); + if (ifGood) { + preproc.InvertCurrentLevel(); + activitySet = preproc.ActiveState(); + if (!activitySet) + sc.ChangeState(SCE_C_PREPROCESSOR); + } + } else if (preproc.IsActive()) { + // Active -> inactive + assert(sc.state == SCE_C_PREPROCESSOR); + preproc.InvertCurrentLevel(); + activitySet = preproc.ActiveState(); + // Continue to show "elif" as active as it ends active section. + } + } else if (sc.Match("endif")) { + preproc.EndSection(); + activitySet = preproc.ActiveState(); + sc.ChangeState(SCE_C_PREPROCESSOR|activitySet); + } else if (sc.Match("define")) { + if (options.updatePreprocessor && preproc.IsActive()) { + std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 6, true); + size_t startName = 0; + while ((startName < restOfLine.length()) && IsSpaceOrTab(restOfLine[startName])) + startName++; + size_t endName = startName; + while ((endName < restOfLine.length()) && setWord.Contains(restOfLine[endName])) + endName++; + std::string key = restOfLine.substr(startName, endName-startName); + if ((endName < restOfLine.length()) && (restOfLine.at(endName) == '(')) { + // Macro + size_t endArgs = endName; + while ((endArgs < restOfLine.length()) && (restOfLine[endArgs] != ')')) + endArgs++; + std::string args = restOfLine.substr(endName + 1, endArgs - endName - 1); + size_t startValue = endArgs+1; + while ((startValue < restOfLine.length()) && IsSpaceOrTab(restOfLine[startValue])) + startValue++; + std::string value; + if (startValue < restOfLine.length()) + value = restOfLine.substr(startValue); + preprocessorDefinitions[key] = SymbolValue(value, args); + ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value, false, args)); + definitionsChanged = true; + } else { + // Value + size_t startValue = endName; + while ((startValue < restOfLine.length()) && IsSpaceOrTab(restOfLine[startValue])) + startValue++; + std::string value = restOfLine.substr(startValue); + if (OnlySpaceOrTab(value)) + value = "1"; // No value defaults to 1 + preprocessorDefinitions[key] = value; + ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value)); + definitionsChanged = true; + } + } + } else if (sc.Match("undef")) { + if (options.updatePreprocessor && preproc.IsActive()) { + const std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 5, false); + std::vector tokens = Tokenize(restOfLine); + if (tokens.size() >= 1) { + const std::string key = tokens[0]; + preprocessorDefinitions.erase(key); + ppDefineHistory.push_back(PPDefinition(lineCurrent, key, "", true)); + definitionsChanged = true; + } + } + } + } + } + } else if (isoperator(sc.ch)) { + sc.SetState(SCE_C_OPERATOR|activitySet); + } + } + + if (!IsASpace(sc.ch) && !IsSpaceEquiv(MaskActive(sc.state))) { + chPrevNonWhite = sc.ch; + visibleChars++; + } + continuationLine = false; + sc.Forward(); + } + const bool rawStringsChanged = rawStringTerminators.Merge(rawSTNew, lineCurrent); + if (definitionsChanged || rawStringsChanged) + styler.ChangeLexerState(startPos, startPos + length); + sc.Complete(); +} + +// Store both the current line's fold level and the next lines in the +// level store to make it easy to pick up with each increment +// and to make it possible to fiddle the current level for "} else {". + +void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + + if (!options.fold) + return; + + LexAccessor styler(pAccess); + + const Sci_PositionU endPos = startPos + length; + int visibleChars = 0; + bool inLineComment = false; + Sci_Position lineCurrent = styler.GetLine(startPos); + int levelCurrent = SC_FOLDLEVELBASE; + if (lineCurrent > 0) + levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; + Sci_PositionU lineStartNext = styler.LineStart(lineCurrent+1); + int levelMinCurrent = levelCurrent; + int levelNext = levelCurrent; + char chNext = styler[startPos]; + int styleNext = MaskActive(styler.StyleAt(startPos)); + int style = MaskActive(initStyle); + const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); + for (Sci_PositionU i = startPos; i < endPos; i++) { + const char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + const int stylePrev = style; + style = styleNext; + styleNext = MaskActive(styler.StyleAt(i + 1)); + const bool atEOL = i == (lineStartNext-1); + if ((style == SCE_C_COMMENTLINE) || (style == SCE_C_COMMENTLINEDOC)) + inLineComment = true; + if (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style) && !inLineComment) { + if (!IsStreamCommentStyle(stylePrev)) { + levelNext++; + } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { + // Comments don't end at end of line and the next character may be unstyled. + levelNext--; + } + } + if (options.foldComment && options.foldCommentExplicit && ((style == SCE_C_COMMENTLINE) || options.foldExplicitAnywhere)) { + if (userDefinedFoldMarkers) { + if (styler.Match(i, options.foldExplicitStart.c_str())) { + levelNext++; + } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { + levelNext--; + } + } else { + if ((ch == '/') && (chNext == '/')) { + const char chNext2 = styler.SafeGetCharAt(i + 2); + if (chNext2 == '{') { + levelNext++; + } else if (chNext2 == '}') { + levelNext--; + } + } + } + } + if (options.foldPreprocessor && (style == SCE_C_PREPROCESSOR)) { + if (ch == '#') { + Sci_PositionU j = i + 1; + while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { + j++; + } + if (styler.Match(j, "region") || styler.Match(j, "if")) { + levelNext++; + } else if (styler.Match(j, "end")) { + levelNext--; + } + + if (options.foldPreprocessorAtElse && (styler.Match(j, "else") || styler.Match(j, "elif"))) { + levelMinCurrent--; + } + } + } + if (options.foldSyntaxBased && (style == SCE_C_OPERATOR)) { + if (ch == '{' || ch == '[' || ch == '(') { + // Measure the minimum before a '{' to allow + // folding on "} else {" + if (options.foldAtElse && levelMinCurrent > levelNext) { + levelMinCurrent = levelNext; + } + levelNext++; + } else if (ch == '}' || ch == ']' || ch == ')') { + levelNext--; + } + } + if (!IsASpace(ch)) + visibleChars++; + if (atEOL || (i == endPos-1)) { + int levelUse = levelCurrent; + if ((options.foldSyntaxBased && options.foldAtElse) || + (options.foldPreprocessor && options.foldPreprocessorAtElse) + ) { + levelUse = levelMinCurrent; + } + int lev = levelUse | levelNext << 16; + if (visibleChars == 0 && options.foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if (levelUse < levelNext) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + lineStartNext = styler.LineStart(lineCurrent+1); + levelCurrent = levelNext; + levelMinCurrent = levelCurrent; + if (atEOL && (i == static_cast(styler.Length()-1))) { + // There is an empty line at end of file so give it same level and empty + styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); + } + visibleChars = 0; + inLineComment = false; + } + } +} + +void LexerCPP::EvaluateTokens(std::vector &tokens, const SymbolTable &preprocessorDefinitions) { + + // Remove whitespace tokens + tokens.erase(std::remove_if(tokens.begin(), tokens.end(), OnlySpaceOrTab), tokens.end()); + + // Evaluate defined statements to either 0 or 1 + for (size_t i=0; (i+1)) + SymbolTable::const_iterator it = preprocessorDefinitions.find(tokens[i+2]); + if (it != preprocessorDefinitions.end()) { + val = "1"; + } + tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 4); + } else { + // Spurious '(' so erase as more likely to result in false + tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 2); + } + } else { + // defined + SymbolTable::const_iterator it = preprocessorDefinitions.find(tokens[i+1]); + if (it != preprocessorDefinitions.end()) { + val = "1"; + } + tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 2); + } + tokens[i] = val; + } else { + i++; + } + } + + // Evaluate identifiers + constexpr size_t maxIterations = 100; + size_t iterations = 0; // Limit number of iterations in case there is a recursive macro. + for (size_t i = 0; (i macroTokens = Tokenize(it->second.value); + if (it->second.IsMacro()) { + if ((i + 1 < tokens.size()) && (tokens.at(i + 1) == "(")) { + // Create map of argument name to value + std::vector argumentNames = StringSplit(it->second.arguments, ','); + std::map arguments; + size_t arg = 0; + size_t tok = i+2; + while ((tok < tokens.size()) && (arg < argumentNames.size()) && (tokens.at(tok) != ")")) { + if (tokens.at(tok) != ",") { + arguments[argumentNames.at(arg)] = tokens.at(tok); + arg++; + } + tok++; + } + + // Remove invocation + tokens.erase(tokens.begin() + i, tokens.begin() + tok + 1); + + // Substitute values into macro + macroTokens.erase(std::remove_if(macroTokens.begin(), macroTokens.end(), OnlySpaceOrTab), macroTokens.end()); + + for (size_t iMacro = 0; iMacro < macroTokens.size();) { + if (setWordStart.Contains(macroTokens[iMacro][0])) { + std::map::const_iterator itFind = arguments.find(macroTokens[iMacro]); + if (itFind != arguments.end()) { + // TODO: Possible that value will be expression so should insert tokenized form + macroTokens[iMacro] = itFind->second; + } + } + iMacro++; + } + + // Insert results back into tokens + tokens.insert(tokens.begin() + i, macroTokens.begin(), macroTokens.end()); + + } else { + i++; + } + } else { + // Remove invocation + tokens.erase(tokens.begin() + i); + // Insert results back into tokens + tokens.insert(tokens.begin() + i, macroTokens.begin(), macroTokens.end()); + } + } else { + // Identifier not found and value defaults to zero + tokens[i] = "0"; + } + } else { + i++; + } + } + + // Find bracketed subexpressions and recurse on them + BracketPair bracketPair = FindBracketPair(tokens); + while (bracketPair.itBracket != tokens.end()) { + std::vector inBracket(bracketPair.itBracket + 1, bracketPair.itEndBracket); + EvaluateTokens(inBracket, preprocessorDefinitions); + + // The insertion is done before the removal because there were failures with the opposite approach + tokens.insert(bracketPair.itBracket, inBracket.begin(), inBracket.end()); + + bracketPair = FindBracketPair(tokens); + tokens.erase(bracketPair.itBracket, bracketPair.itEndBracket + 1); + + bracketPair = FindBracketPair(tokens); + } + + // Evaluate logical negations + for (size_t j=0; (j+1)::iterator itInsert = + tokens.erase(tokens.begin() + j, tokens.begin() + j + 2); + tokens.insert(itInsert, isTrue ? "1" : "0"); + } else { + j++; + } + } + + // Evaluate expressions in precedence order + enum precedence { precMult, precAdd, precRelative + , precLogical, /* end marker */ precLast }; + for (int prec = precMult; prec < precLast; prec++) { + // Looking at 3 tokens at a time so end at 2 before end + for (size_t k=0; (k+2)") + result = valA > valB; + else if (tokens[k+1] == ">=") + result = valA >= valB; + else if (tokens[k+1] == "==") + result = valA == valB; + else if (tokens[k+1] == "!=") + result = valA != valB; + else if (tokens[k+1] == "||") + result = valA || valB; + else if (tokens[k+1] == "&&") + result = valA && valB; + std::vector::iterator itInsert = + tokens.erase(tokens.begin() + k, tokens.begin() + k + 3); + tokens.insert(itInsert, std::to_string(result)); + } else { + k++; + } + } + } +} + +std::vector LexerCPP::Tokenize(const std::string &expr) const { + // Break into tokens + std::vector tokens; + const char *cp = expr.c_str(); + while (*cp) { + std::string word; + if (setWord.Contains(*cp)) { + // Identifiers and numbers + while (setWord.Contains(*cp)) { + word += *cp; + cp++; + } + } else if (IsSpaceOrTab(*cp)) { + while (IsSpaceOrTab(*cp)) { + word += *cp; + cp++; + } + } else if (setRelOp.Contains(*cp)) { + word += *cp; + cp++; + if (setRelOp.Contains(*cp)) { + word += *cp; + cp++; + } + } else if (setLogicalOp.Contains(*cp)) { + word += *cp; + cp++; + if (setLogicalOp.Contains(*cp)) { + word += *cp; + cp++; + } + } else { + // Should handle strings, characters, and comments here + word += *cp; + cp++; + } + tokens.push_back(word); + } + return tokens; +} + +bool LexerCPP::EvaluateExpression(const std::string &expr, const SymbolTable &preprocessorDefinitions) { + std::vector tokens = Tokenize(expr); + + EvaluateTokens(tokens, preprocessorDefinitions); + + // "0" or "" -> false else true + const bool isFalse = tokens.empty() || + ((tokens.size() == 1) && ((tokens[0] == "") || tokens[0] == "0")); + return !isFalse; +} + +LexerModule lmCPP(SCLEX_CPP, LexerCPP::LexerFactoryCPP, "cpp", cppWordLists); +LexerModule lmCPPNoCase(SCLEX_CPPNOCASE, LexerCPP::LexerFactoryCPPInsensitive, "cppnocase", cppWordLists); diff --git a/Pythonwin/Scintilla/src/LexCSS.cxx b/Pythonwin/Scintilla/lexers/LexCSS.cxx similarity index 58% rename from Pythonwin/Scintilla/src/LexCSS.cxx rename to Pythonwin/Scintilla/lexers/LexCSS.cxx index 3b139cdcd..c1a86f537 100644 --- a/Pythonwin/Scintilla/src/LexCSS.cxx +++ b/Pythonwin/Scintilla/lexers/LexCSS.cxx @@ -1,30 +1,38 @@ // Scintilla source code edit control +// Encoding: UTF-8 /** @file LexCSS.cxx ** Lexer for Cascading Style Sheets - ** Written by Jakub Vrána + ** Written by Jakub Vrána ** Improved by Philippe Lhoste (CSS2) + ** Improved by Ross McKay (SCSS mode; see http://sass-lang.com/ ) **/ // Copyright 1998-2002 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. +// TODO: handle SCSS nested properties like font: { weight: bold; size: 1em; } +// TODO: handle SCSS interpolation: #{} +// TODO: add features for Less if somebody feels like contributing; http://lesscss.org/ +// TODO: refactor this monster so that the next poor slob can read it! + #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif static inline bool IsAWordChar(const unsigned int ch) { @@ -48,7 +56,23 @@ inline bool IsCssOperator(const int ch) { return false; } -static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { +// look behind (from start of document to our start position) to determine current nesting level +inline int NestingLevelLookBehind(Sci_PositionU startPos, Accessor &styler) { + int ch; + int nestingLevel = 0; + + for (Sci_PositionU i = 0; i < startPos; i++) { + ch = styler.SafeGetCharAt(i); + if (ch == '{') + nestingLevel++; + else if (ch == '}') + nestingLevel--; + } + + return nestingLevel; +} + +static void ColouriseCssDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &css1Props = *keywordlists[0]; WordList &pseudoClasses = *keywordlists[1]; WordList &css2Props = *keywordlists[2]; @@ -62,15 +86,51 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo int lastState = -1; // before operator int lastStateC = -1; // before comment + int lastStateS = -1; // before single-quoted/double-quoted string + int lastStateVar = -1; // before variable (SCSS) + int lastStateVal = -1; // before value (SCSS) int op = ' '; // last operator int opPrev = ' '; // last operator + bool insideParentheses = false; // true if currently in a CSS url() or similar construct + + // property lexer.css.scss.language + // Set to 1 for Sassy CSS (.scss) + bool isScssDocument = styler.GetPropertyInt("lexer.css.scss.language") != 0; + + // property lexer.css.less.language + // Set to 1 for Less CSS (.less) + bool isLessDocument = styler.GetPropertyInt("lexer.css.less.language") != 0; + + // property lexer.css.hss.language + // Set to 1 for HSS (.hss) + bool isHssDocument = styler.GetPropertyInt("lexer.css.hss.language") != 0; + + // SCSS/LESS/HSS have the concept of variable + bool hasVariables = isScssDocument || isLessDocument || isHssDocument; + char varPrefix = 0; + if (hasVariables) + varPrefix = isLessDocument ? '@' : '$'; + + // SCSS/LESS/HSS support single-line comments + typedef enum _CommentModes { eCommentBlock = 0, eCommentLine = 1} CommentMode; + CommentMode comment_mode = eCommentBlock; + bool hasSingleLineComments = isScssDocument || isLessDocument || isHssDocument; + + // must keep track of nesting level in document types that support it (SCSS/LESS/HSS) + bool hasNesting = false; + int nestingLevel = 0; + if (isScssDocument || isLessDocument || isHssDocument) { + hasNesting = true; + nestingLevel = NestingLevelLookBehind(startPos, styler); + } + // "the loop" for (; sc.More(); sc.Forward()) { - if (sc.state == SCE_CSS_COMMENT && sc.Match('*', '/')) { + if (sc.state == SCE_CSS_COMMENT && ((comment_mode == eCommentBlock && sc.Match('*', '/')) || (comment_mode == eCommentLine && sc.atLineEnd))) { if (lastStateC == -1) { // backtrack to get last state: // comments are like whitespace, so we must return to the previous state - unsigned int i = startPos; + Sci_PositionU i = startPos; for (; i > 0; i--) { if ((lastStateC = styler.StyleAt(i-1)) != SCE_CSS_COMMENT) { if (lastStateC == SCE_CSS_OPERATOR) { @@ -90,8 +150,12 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (i == 0) lastStateC = SCE_CSS_DEFAULT; } - sc.Forward(); - sc.ForwardSetState(lastStateC); + if (comment_mode == eCommentBlock) { + sc.Forward(); + sc.ForwardSetState(lastStateC); + } else /* eCommentLine */ { + sc.SetState(lastStateC); + } } if (sc.state == SCE_CSS_COMMENT) @@ -100,17 +164,17 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (sc.state == SCE_CSS_DOUBLESTRING || sc.state == SCE_CSS_SINGLESTRING) { if (sc.ch != (sc.state == SCE_CSS_DOUBLESTRING ? '\"' : '\'')) continue; - unsigned int i = sc.currentPos; + Sci_PositionU i = sc.currentPos; while (i && styler[i-1] == '\\') i--; if ((sc.currentPos - i) % 2 == 1) continue; - sc.ForwardSetState(SCE_CSS_VALUE); + sc.ForwardSetState(lastStateS); } if (sc.state == SCE_CSS_OPERATOR) { if (op == ' ') { - unsigned int i = startPos; + Sci_PositionU i = startPos; op = styler.SafeGetCharAt(i-1); opPrev = styler.SafeGetCharAt(i-2); while (--i) { @@ -121,7 +185,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo } switch (op) { case '@': - if (lastState == SCE_CSS_DEFAULT) + if (lastState == SCE_CSS_DEFAULT || hasNesting) sc.SetState(SCE_CSS_DIRECTIVE); break; case '>': @@ -140,15 +204,33 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo sc.SetState(SCE_CSS_TAG); break; case '{': - if (lastState == SCE_CSS_DIRECTIVE) + nestingLevel++; + switch (lastState) { + case SCE_CSS_MEDIA: sc.SetState(SCE_CSS_DEFAULT); - else if (lastState == SCE_CSS_TAG) + break; + case SCE_CSS_TAG: + case SCE_CSS_DIRECTIVE: sc.SetState(SCE_CSS_IDENTIFIER); + break; + } break; case '}': - if (lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT || - lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 || lastState == SCE_CSS_IDENTIFIER3) - sc.SetState(SCE_CSS_DEFAULT); + if (--nestingLevel < 0) + nestingLevel = 0; + switch (lastState) { + case SCE_CSS_DEFAULT: + case SCE_CSS_VALUE: + case SCE_CSS_IMPORTANT: + case SCE_CSS_IDENTIFIER: + case SCE_CSS_IDENTIFIER2: + case SCE_CSS_IDENTIFIER3: + if (hasNesting) + sc.SetState(nestingLevel > 0 ? SCE_CSS_IDENTIFIER : SCE_CSS_DEFAULT); + else + sc.SetState(SCE_CSS_DEFAULT); + break; + } break; case '(': if (lastState == SCE_CSS_PSEUDOCLASS) @@ -163,14 +245,28 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo sc.SetState(SCE_CSS_TAG); break; case ':': - if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || - lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS || - lastState == SCE_CSS_PSEUDOELEMENT || lastState == SCE_CSS_EXTENDED_PSEUDOELEMENT) + switch (lastState) { + case SCE_CSS_TAG: + case SCE_CSS_DEFAULT: + case SCE_CSS_CLASS: + case SCE_CSS_ID: + case SCE_CSS_PSEUDOCLASS: + case SCE_CSS_EXTENDED_PSEUDOCLASS: + case SCE_CSS_UNKNOWN_PSEUDOCLASS: + case SCE_CSS_PSEUDOELEMENT: + case SCE_CSS_EXTENDED_PSEUDOELEMENT: sc.SetState(SCE_CSS_PSEUDOCLASS); - else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 || - lastState == SCE_CSS_IDENTIFIER3 || lastState == SCE_CSS_EXTENDED_IDENTIFIER || - lastState == SCE_CSS_UNKNOWN_IDENTIFIER) + break; + case SCE_CSS_IDENTIFIER: + case SCE_CSS_IDENTIFIER2: + case SCE_CSS_IDENTIFIER3: + case SCE_CSS_EXTENDED_IDENTIFIER: + case SCE_CSS_UNKNOWN_IDENTIFIER: + case SCE_CSS_VARIABLE: sc.SetState(SCE_CSS_VALUE); + lastStateVal = lastState; + break; + } break; case '.': if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || @@ -189,10 +285,40 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo sc.SetState(SCE_CSS_DEFAULT); break; case ';': - if (lastState == SCE_CSS_DIRECTIVE) - sc.SetState(SCE_CSS_DEFAULT); - else if (lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT) - sc.SetState(SCE_CSS_IDENTIFIER); + switch (lastState) { + case SCE_CSS_DIRECTIVE: + if (hasNesting) { + sc.SetState(nestingLevel > 0 ? SCE_CSS_IDENTIFIER : SCE_CSS_DEFAULT); + } else { + sc.SetState(SCE_CSS_DEFAULT); + } + break; + case SCE_CSS_VALUE: + case SCE_CSS_IMPORTANT: + // data URLs can have semicolons; simplistically check for wrapping parentheses and move along + if (insideParentheses) { + sc.SetState(lastState); + } else { + if (lastStateVal == SCE_CSS_VARIABLE) { + sc.SetState(SCE_CSS_DEFAULT); + } else { + sc.SetState(SCE_CSS_IDENTIFIER); + } + } + break; + case SCE_CSS_VARIABLE: + if (lastStateVar == SCE_CSS_VALUE) { + // data URLs can have semicolons; simplistically check for wrapping parentheses and move along + if (insideParentheses) { + sc.SetState(SCE_CSS_VALUE); + } else { + sc.SetState(SCE_CSS_IDENTIFIER); + } + } else { + sc.SetState(SCE_CSS_DEFAULT); + } + break; + } break; case '!': if (lastState == SCE_CSS_VALUE) @@ -201,14 +327,78 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo } } - if (IsAWordChar(sc.ch)) { - if (sc.state == SCE_CSS_DEFAULT) - sc.SetState(SCE_CSS_TAG); + if (sc.ch == '*' && sc.state == SCE_CSS_DEFAULT) { + sc.SetState(SCE_CSS_TAG); continue; } - if (sc.ch == '*' && sc.state == SCE_CSS_DEFAULT) { - sc.SetState(SCE_CSS_TAG); + // check for inside parentheses (whether part of an "operator" or not) + if (sc.ch == '(') + insideParentheses = true; + else if (sc.ch == ')') + insideParentheses = false; + + // SCSS special modes + if (hasVariables) { + // variable name + if (sc.ch == varPrefix) { + switch (sc.state) { + case SCE_CSS_DEFAULT: + if (isLessDocument) // give priority to pseudo elements + break; + // Falls through. + case SCE_CSS_VALUE: + lastStateVar = sc.state; + sc.SetState(SCE_CSS_VARIABLE); + continue; + } + } + if (sc.state == SCE_CSS_VARIABLE) { + if (IsAWordChar(sc.ch)) { + // still looking at the variable name + continue; + } + if (lastStateVar == SCE_CSS_VALUE) { + // not looking at the variable name any more, and it was part of a value + sc.SetState(SCE_CSS_VALUE); + } + } + + // nested rule parent selector + if (sc.ch == '&') { + switch (sc.state) { + case SCE_CSS_DEFAULT: + case SCE_CSS_IDENTIFIER: + sc.SetState(SCE_CSS_TAG); + continue; + } + } + } + + // nesting rules that apply to SCSS and Less + if (hasNesting) { + // check for nested rule selector + if (sc.state == SCE_CSS_IDENTIFIER && (IsAWordChar(sc.ch) || sc.ch == ':' || sc.ch == '.' || sc.ch == '#')) { + // look ahead to see whether { comes before next ; and } + Sci_PositionU endPos = startPos + length; + int ch; + + for (Sci_PositionU i = sc.currentPos; i < endPos; i++) { + ch = styler.SafeGetCharAt(i); + if (ch == ';' || ch == '}') + break; + if (ch == '{') { + sc.SetState(SCE_CSS_DEFAULT); + continue; + } + } + } + + } + + if (IsAWordChar(sc.ch)) { + if (sc.state == SCE_CSS_DEFAULT) + sc.SetState(SCE_CSS_TAG); continue; } @@ -219,7 +409,8 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_PSEUDOELEMENT || sc.state == SCE_CSS_EXTENDED_PSEUDOCLASS || sc.state == SCE_CSS_EXTENDED_PSEUDOELEMENT || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || - sc.state == SCE_CSS_IMPORTANT + sc.state == SCE_CSS_IMPORTANT || + sc.state == SCE_CSS_DIRECTIVE )) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); @@ -263,6 +454,10 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (strcmp(s2, "important") != 0) sc.ChangeState(SCE_CSS_VALUE); break; + case SCE_CSS_DIRECTIVE: + if (op == '@' && strcmp(s2, "media") == 0) + sc.ChangeState(SCE_CSS_MEDIA); + break; } } @@ -278,14 +473,23 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (sc.Match('/', '*')) { lastStateC = sc.state; + comment_mode = eCommentBlock; + sc.SetState(SCE_CSS_COMMENT); + sc.Forward(); + } else if (hasSingleLineComments && sc.Match('/', '/') && !insideParentheses) { + // note that we've had to treat ([...]// as the start of a URL not a comment, e.g. url(http://example.com), url(//example.com) + lastStateC = sc.state; + comment_mode = eCommentLine; sc.SetState(SCE_CSS_COMMENT); sc.Forward(); - } else if (sc.state == SCE_CSS_VALUE && (sc.ch == '\"' || sc.ch == '\'')) { + } else if ((sc.state == SCE_CSS_VALUE || sc.state == SCE_CSS_ATTRIBUTE) + && (sc.ch == '\"' || sc.ch == '\'')) { + lastStateS = sc.state; sc.SetState((sc.ch == '\"' ? SCE_CSS_DOUBLESTRING : SCE_CSS_SINGLESTRING)); } else if (IsCssOperator(sc.ch) && (sc.state != SCE_CSS_ATTRIBUTE || sc.ch == ']') && (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!') - && (sc.state != SCE_CSS_DIRECTIVE || sc.ch == ';' || sc.ch == '{') + && ((sc.state != SCE_CSS_DIRECTIVE && sc.state != SCE_CSS_MEDIA) || sc.ch == ';' || sc.ch == '{') ) { if (sc.state != SCE_CSS_OPERATOR) lastState = sc.state; @@ -298,17 +502,17 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo sc.Complete(); } -static void FoldCSSDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { +static void FoldCSSDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; bool inComment = (styler.StyleAt(startPos-1) == SCE_CSS_COMMENT); - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styler.StyleAt(i); diff --git a/Pythonwin/Scintilla/src/LexCaml.cxx b/Pythonwin/Scintilla/lexers/LexCaml.cxx similarity index 63% rename from Pythonwin/Scintilla/src/LexCaml.cxx rename to Pythonwin/Scintilla/lexers/LexCaml.cxx index 539eee0de..1339b5dcc 100644 --- a/Pythonwin/Scintilla/src/LexCaml.cxx +++ b/Pythonwin/Scintilla/lexers/LexCaml.cxx @@ -2,7 +2,7 @@ /** @file LexCaml.cxx ** Lexer for Objective Caml. **/ -// Copyright 2005 by Robert Roessler +// Copyright 2005-2009 by Robert Roessler // The License.txt file describes the conditions under which this software may be distributed. /* Release History 20050204 Initial release. @@ -15,61 +15,71 @@ 20051125 Added 2nd "optional" keywords class. 20051129 Support "magic" (read-only) comments for RCaml. 20051204 Swtich to using StyleContext infrastructure. + 20090629 Add full Standard ML '97 support. */ #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "PropSetSimple.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" + +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wcomma" +#endif // Since the Microsoft __iscsym[f] funcs are not ANSI... inline int iscaml(int c) {return isalnum(c) || c == '_';} inline int iscamlf(int c) {return isalpha(c) || c == '_';} -inline int iscamld(int c) {return isdigit(c) || c == '_';} static const int baseT[24] = { 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A - L */ 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,16 /* M - X */ }; -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif #ifdef BUILD_AS_EXTERNAL_LEXER /* (actually seems to work!) */ +#include #include "WindowAccessor.h" #include "ExternalLexer.h" +#undef EXT_LEXER_DECL +#define EXT_LEXER_DECL __declspec( dllexport ) __stdcall + #if PLAT_WIN #include #endif static void ColouriseCamlDoc( - unsigned int startPos, int length, + Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler); static void FoldCamlDoc( - unsigned int startPos, int length, + Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler); -static void InternalLexOrFold(int lexOrFold, unsigned int startPos, int length, +static void InternalLexOrFold(int lexOrFold, Sci_PositionU startPos, Sci_Position length, int initStyle, char *words[], WindowID window, char *props); static const char* LexerName = "caml"; @@ -101,7 +111,7 @@ long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long reinterpret_cast(lParam)); } -void EXT_LEXER_DECL Fold(unsigned int lexer, unsigned int startPos, int length, +void EXT_LEXER_DECL Fold(unsigned int lexer, Sci_PositionU startPos, Sci_Position length, int initStyle, char *words[], WindowID window, char *props) { // below useless evaluation(s) to supress "not used" warnings @@ -130,7 +140,7 @@ void EXT_LEXER_DECL GetLexerName(unsigned int Index, char *name, int buflength) } } -void EXT_LEXER_DECL Lex(unsigned int lexer, unsigned int startPos, int length, +void EXT_LEXER_DECL Lex(unsigned int lexer, Sci_PositionU startPos, Sci_Position length, int initStyle, char *words[], WindowID window, char *props) { // below useless evaluation(s) to supress "not used" warnings @@ -139,11 +149,11 @@ void EXT_LEXER_DECL Lex(unsigned int lexer, unsigned int startPos, int length, InternalLexOrFold(0, startPos, length, initStyle, words, window, props); } -static void InternalLexOrFold(int foldOrLex, unsigned int startPos, int length, +static void InternalLexOrFold(int foldOrLex, Sci_PositionU startPos, Sci_Position length, int initStyle, char *words[], WindowID window, char *props) { // create and initialize a WindowAccessor (including contained PropSet) - PropSet ps; + PropSetSimple ps; ps.SetMultiple(props); WindowAccessor wa(window, ps); // create and initialize WordList(s) @@ -172,32 +182,35 @@ static #endif /* BUILD_AS_EXTERNAL_LEXER */ void ColouriseCamlDoc( - unsigned int startPos, int length, + Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { // initialize styler StyleContext sc(startPos, length, initStyle, styler); - // set up [initial] state info (terminating states that shouldn't "bleed") - int nesting = 0; - if (sc.state < SCE_CAML_STRING) - sc.state = SCE_CAML_DEFAULT; - if (sc.state >= SCE_CAML_COMMENT) - nesting = (sc.state & 0x0f) - SCE_CAML_COMMENT; - int chBase = 0, chToken = 0, chLit = 0; + Sci_PositionU chToken = 0; + int chBase = 0, chLit = 0; WordList& keywords = *keywordlists[0]; WordList& keywords2 = *keywordlists[1]; WordList& keywords3 = *keywordlists[2]; + const bool isSML = keywords.InList("andalso"); const int useMagic = styler.GetPropertyInt("lexer.caml.magic", 0); + // set up [initial] state info (terminating states that shouldn't "bleed") + const int state_ = sc.state & 0x0f; + if (state_ <= SCE_CAML_CHAR + || (isSML && state_ == SCE_CAML_STRING)) + sc.state = SCE_CAML_DEFAULT; + int nesting = (state_ >= SCE_CAML_COMMENT)? (state_ - SCE_CAML_COMMENT): 0; + // foreach char in range... while (sc.More()) { // set up [per-char] state info - int state2 = -1; // (ASSUME no state change) - int chColor = sc.currentPos - 1;// (ASSUME standard coloring range) - bool advance = true; // (ASSUME scanner "eats" 1 char) + int state2 = -1; // (ASSUME no state change) + Sci_Position chColor = sc.currentPos - 1;// (ASSUME standard coloring range) + bool advance = true; // (ASSUME scanner "eats" 1 char) // step state machine switch (sc.state & 0x0f) { @@ -206,36 +219,49 @@ void ColouriseCamlDoc( // it's wide open; what do we have? if (iscamlf(sc.ch)) state2 = SCE_CAML_IDENTIFIER; - else if (sc.Match('`') && iscamlf(sc.chNext)) + else if (!isSML && sc.Match('`') && iscamlf(sc.chNext)) state2 = SCE_CAML_TAGNAME; - else if (sc.Match('#') && isdigit(sc.chNext)) + else if (!isSML && sc.Match('#') && isdigit(sc.chNext)) state2 = SCE_CAML_LINENUM; else if (isdigit(sc.ch)) { + // it's a number, assume base 10 state2 = SCE_CAML_NUMBER, chBase = 10; - if (sc.Match('0') && strchr("bBoOxX", sc.chNext)) - chBase = baseT[tolower(sc.chNext) - 'a'], sc.Forward(); - } else if (sc.Match('\'')) /* (char literal?) */ + if (sc.Match('0')) { + // there MAY be a base specified... + const char* baseC = "bBoOxX"; + if (isSML) { + if (sc.chNext == 'w') + sc.Forward(); // (consume SML "word" indicator) + baseC = "x"; + } + // ... change to specified base AS REQUIRED + if (strchr(baseC, sc.chNext)) + chBase = baseT[tolower(sc.chNext) - 'a'], sc.Forward(); + } + } else if (!isSML && sc.Match('\'')) // (Caml char literal?) state2 = SCE_CAML_CHAR, chLit = 0; - else if (sc.Match('\"')) + else if (isSML && sc.Match('#', '"')) // (SML char literal?) + state2 = SCE_CAML_CHAR, sc.Forward(); + else if (sc.Match('"')) state2 = SCE_CAML_STRING; else if (sc.Match('(', '*')) - state2 = SCE_CAML_COMMENT, - sc.ch = ' ', // (make SURE "(*)" isn't seen as a closed comment) - sc.Forward(); - else if (strchr("!?~" /* Caml "prefix-symbol" */ - "=<>@^|&+-*/$%" /* Caml "infix-symbol" */ - "()[]{};,:.#", sc.ch)) /* Caml "bracket" or ;,:.# */ + state2 = SCE_CAML_COMMENT, sc.Forward(), sc.ch = ' '; // (*)... + else if (strchr("!?~" /* Caml "prefix-symbol" */ + "=<>@^|&+-*/$%" /* Caml "infix-symbol" */ + "()[]{};,:.#", sc.ch) // Caml "bracket" or ;,:.# + // SML "extra" ident chars + || (isSML && (sc.Match('\\') || sc.Match('`')))) state2 = SCE_CAML_OPERATOR; break; case SCE_CAML_IDENTIFIER: // [try to] interpret as [additional] identifier char if (!(iscaml(sc.ch) || sc.Match('\''))) { - const int n = sc.currentPos - chToken; + const Sci_Position n = sc.currentPos - chToken; if (n < 24) { // length is believable as keyword, [re-]construct token char t[24]; - for (int i = -n; i < 0; i++) + for (Sci_Position i = -n; i < 0; i++) t[n + i] = static_cast(sc.GetRelative(i)); t[n] = '\0'; // special-case "_" token as KEYWORD @@ -273,9 +299,12 @@ void ColouriseCamlDoc( case SCE_CAML_OPERATOR: { // [try to] interpret as [additional] operator char const char* o = 0; - if (iscaml(sc.ch) || isspace(sc.ch) /* ident or whitespace */ - || (o = strchr(")]};,\'\"`#", sc.ch),o)/* "termination" chars */ - || !strchr("!$%&*+-./:<=>?@^|~", sc.ch)/* "operator" chars */) { + if (iscaml(sc.ch) || isspace(sc.ch) // ident or whitespace + || (o = strchr(")]};,\'\"#", sc.ch),o) // "termination" chars + || (!isSML && sc.Match('`')) // Caml extra term char + || (!strchr("!$%&*+-./:<=>?@^|~", sc.ch)// "operator" chars + // SML extra ident chars + && !(isSML && (sc.Match('\\') || sc.Match('`'))))) { // check for INCLUSIVE termination if (o && strchr(")]};,", sc.ch)) { if ((sc.Match(')') && sc.chPrev == '(') @@ -292,24 +321,27 @@ void ColouriseCamlDoc( case SCE_CAML_NUMBER: // [try to] interpret as [additional] numeric literal char - // N.B. - improperly accepts "extra" digits in base 2 or 8 literals - if (iscamld(sc.ch) || IsADigit(sc.ch, chBase)) + if ((!isSML && sc.Match('_')) || IsADigit(sc.ch, chBase)) break; // how about an integer suffix? - if ((sc.Match('l') || sc.Match('L') || sc.Match('n')) - && (iscamld(sc.chPrev) || IsADigit(sc.chPrev, chBase))) + if (!isSML && (sc.Match('l') || sc.Match('L') || sc.Match('n')) + && (sc.chPrev == '_' || IsADigit(sc.chPrev, chBase))) break; // or a floating-point literal? if (chBase == 10) { // with a decimal point? - if (sc.Match('.') && iscamld(sc.chPrev)) + if (sc.Match('.') + && ((!isSML && sc.chPrev == '_') + || IsADigit(sc.chPrev, chBase))) break; // with an exponent? (I) if ((sc.Match('e') || sc.Match('E')) - && (iscamld(sc.chPrev) || sc.chPrev == '.')) + && ((!isSML && (sc.chPrev == '.' || sc.chPrev == '_')) + || IsADigit(sc.chPrev, chBase))) break; // with an exponent? (II) - if ((sc.Match('+') || sc.Match('-')) + if (((!isSML && (sc.Match('+') || sc.Match('-'))) + || (isSML && sc.Match('~'))) && (sc.chPrev == 'e' || sc.chPrev == 'E')) break; } @@ -318,29 +350,57 @@ void ColouriseCamlDoc( break; case SCE_CAML_CHAR: - // [try to] interpret as [additional] char literal char - if (sc.Match('\\')) { - chLit = 1; // (definitely IS a char literal) - if (sc.chPrev == '\\') - sc.ch = ' '; // (so termination test isn't fooled) + if (!isSML) { + // [try to] interpret as [additional] char literal char + if (sc.Match('\\')) { + chLit = 1; // (definitely IS a char literal) + if (sc.chPrev == '\\') + sc.ch = ' '; // (...\\') + // should we be terminating - one way or another? + } else if ((sc.Match('\'') && sc.chPrev != '\\') + || sc.atLineEnd) { + state2 = SCE_CAML_DEFAULT; + if (sc.Match('\'')) + chColor++; + else + sc.ChangeState(SCE_CAML_IDENTIFIER); + // ... maybe a char literal, maybe not + } else if (chLit < 1 && sc.currentPos - chToken >= 2) + sc.ChangeState(SCE_CAML_IDENTIFIER), advance = false; + break; + }/* else + // fall through for SML char literal (handle like string) */ + // Falls through. + + case SCE_CAML_STRING: + // [try to] interpret as [additional] [SML char/] string literal char + if (isSML && sc.Match('\\') && sc.chPrev != '\\' && isspace(sc.chNext)) + state2 = SCE_CAML_WHITE; + else if (sc.Match('\\') && sc.chPrev == '\\') + sc.ch = ' '; // (...\\") // should we be terminating - one way or another? - } else if ((sc.Match('\'') && sc.chPrev != '\\') || sc.atLineEnd) { + else if ((sc.Match('"') && sc.chPrev != '\\') + || (isSML && sc.atLineEnd)) { state2 = SCE_CAML_DEFAULT; - if (sc.Match('\'')) + if (sc.Match('"')) chColor++; - else - sc.ChangeState(SCE_CAML_IDENTIFIER); - // ... maybe a char literal, maybe not - } else if (chLit < 1 && sc.currentPos - chToken >= 2) - sc.ChangeState(SCE_CAML_IDENTIFIER), advance = false; + } break; - case SCE_CAML_STRING: - // [try to] interpret as [additional] string literal char - if (sc.Match('\\') && sc.chPrev == '\\') - sc.ch = ' '; // (so '\\' doesn't cause us trouble) - else if (sc.Match('\"') && sc.chPrev != '\\') - state2 = SCE_CAML_DEFAULT, chColor++; + case SCE_CAML_WHITE: + // [try to] interpret as [additional] SML embedded whitespace char + if (sc.Match('\\')) { + // style this puppy NOW... + state2 = SCE_CAML_STRING, sc.ch = ' ' /* (...\") */, chColor++, + styler.ColourTo(chColor, SCE_CAML_WHITE), styler.Flush(); + // ... then backtrack to determine original SML literal type + Sci_Position p = chColor - 2; + for (; p >= 0 && styler.StyleAt(p) == SCE_CAML_WHITE; p--) ; + if (p >= 0) + state2 = static_cast(styler.StyleAt(p)); + // take care of state change NOW + sc.ChangeState(state2), state2 = -1; + } break; case SCE_CAML_COMMENT: @@ -350,8 +410,7 @@ void ColouriseCamlDoc( // we're IN a comment - does this start a NESTED comment? if (sc.Match('(', '*')) state2 = sc.state + 1, chToken = sc.currentPos, - sc.ch = ' ', // (make SURE "(*)" isn't seen as a closed comment) - sc.Forward(), nesting++; + sc.Forward(), sc.ch = ' ' /* (*)... */, nesting++; // [try to] interpret as [additional] comment char else if (sc.Match(')') && sc.chPrev == '*') { if (nesting) @@ -366,7 +425,7 @@ void ColouriseCamlDoc( break; } - // handle state change and char coloring as required + // handle state change and char coloring AS REQUIRED if (state2 >= 0) styler.ColourTo(chColor, sc.state), sc.ChangeState(state2); // move to next char UNLESS re-scanning current char @@ -382,13 +441,11 @@ void ColouriseCamlDoc( static #endif /* BUILD_AS_EXTERNAL_LEXER */ void FoldCamlDoc( - unsigned int startPos, int length, - int initStyle, - WordList *keywordlists[], - Accessor &styler) + Sci_PositionU, Sci_Position, + int, + WordList *[], + Accessor &) { - // below useless evaluation(s) to supress "not used" warnings - startPos || length || initStyle || keywordlists[0] || styler.Length(); } static const char * const camlWordListDesc[] = { diff --git a/Pythonwin/Scintilla/src/LexCmake.cxx b/Pythonwin/Scintilla/lexers/LexCmake.cxx similarity index 88% rename from Pythonwin/Scintilla/src/LexCmake.cxx rename to Pythonwin/Scintilla/lexers/LexCmake.cxx index f63eb399f..e3835c5c3 100644 --- a/Pythonwin/Scintilla/src/LexCmake.cxx +++ b/Pythonwin/Scintilla/lexers/LexCmake.cxx @@ -5,23 +5,26 @@ // Copyright 2007 by Cristian Adam // based on the NSIS lexer // 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 "PropSet.h" -#include "Accessor.h" -#include "KeyWords.h" +#include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" -#ifdef SCI_NAMESPACE +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + using namespace Scintilla; -#endif static bool isCmakeNumber(char ch) { @@ -38,10 +41,10 @@ static bool isCmakeLetter(char ch) return(ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); } -static bool CmakeNextLineHasElse(unsigned int start, unsigned int end, Accessor &styler) +static bool CmakeNextLineHasElse(Sci_PositionU start, Sci_PositionU end, Accessor &styler) { - int nNextLine = -1; - for ( unsigned int i = start; i < end; i++ ) { + Sci_Position nNextLine = -1; + for ( Sci_PositionU i = start; i < end; i++ ) { char cNext = styler.SafeGetCharAt( i ); if ( cNext == '\n' ) { nNextLine = i+1; @@ -52,7 +55,7 @@ static bool CmakeNextLineHasElse(unsigned int start, unsigned int end, Accessor if ( nNextLine == -1 ) // We never foudn the next line... return false; - for ( unsigned int firstChar = nNextLine; firstChar < end; firstChar++ ) { + for ( Sci_PositionU firstChar = nNextLine; firstChar < end; firstChar++ ) { char cNext = styler.SafeGetCharAt( firstChar ); if ( cNext == ' ' ) continue; @@ -66,7 +69,7 @@ static bool CmakeNextLineHasElse(unsigned int start, unsigned int end, Accessor return false; } -static int calculateFoldCmake(unsigned int start, unsigned int end, int foldlevel, Accessor &styler, bool bElse) +static int calculateFoldCmake(Sci_PositionU start, Sci_PositionU end, int foldlevel, Accessor &styler, bool bElse) { // If the word is too long, it is not what we are looking for if ( end - start > 20 ) @@ -82,10 +85,11 @@ static int calculateFoldCmake(unsigned int start, unsigned int end, int foldleve if ( CompareCaseInsensitive(s, "IF") == 0 || CompareCaseInsensitive(s, "WHILE") == 0 || CompareCaseInsensitive(s, "MACRO") == 0 || CompareCaseInsensitive(s, "FOREACH") == 0 - || CompareCaseInsensitive(s, "ELSEIF") == 0 ) + || CompareCaseInsensitive(s, "FUNCTION") == 0 || CompareCaseInsensitive(s, "ELSEIF") == 0) newFoldlevel++; else if ( CompareCaseInsensitive(s, "ENDIF") == 0 || CompareCaseInsensitive(s, "ENDWHILE") == 0 - || CompareCaseInsensitive(s, "ENDMACRO") == 0 || CompareCaseInsensitive(s, "ENDFOREACH") == 0) + || CompareCaseInsensitive(s, "ENDMACRO") == 0 || CompareCaseInsensitive(s, "ENDFOREACH") == 0 + || CompareCaseInsensitive(s, "ENDFUNCTION") == 0) newFoldlevel--; else if ( bElse && CompareCaseInsensitive(s, "ELSEIF") == 0 ) newFoldlevel++; @@ -95,7 +99,7 @@ static int calculateFoldCmake(unsigned int start, unsigned int end, int foldleve return newFoldlevel; } -static int classifyWordCmake(unsigned int start, unsigned int end, WordList *keywordLists[], Accessor &styler ) +static int classifyWordCmake(Sci_PositionU start, Sci_PositionU end, WordList *keywordLists[], Accessor &styler ) { char word[100] = {0}; char lowercaseWord[100] = {0}; @@ -104,7 +108,7 @@ static int classifyWordCmake(unsigned int start, unsigned int end, WordList *key WordList &Parameters = *keywordLists[1]; WordList &UserDefined = *keywordLists[2]; - for (unsigned int i = 0; i < end - start + 1 && i < 99; i++) { + for (Sci_PositionU i = 0; i < end - start + 1 && i < 99; i++) { word[i] = static_cast( styler[ start + i ] ); lowercaseWord[i] = static_cast(tolower(word[i])); } @@ -157,7 +161,7 @@ static int classifyWordCmake(unsigned int start, unsigned int end, WordList *key return SCE_CMAKE_DEFAULT; } -static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) +static void ColouriseCmakeDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_CMAKE_DEFAULT; if ( startPos > 0 ) @@ -166,14 +170,14 @@ static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList * styler.StartAt( startPos ); styler.GetLine( startPos ); - unsigned int nLengthDoc = startPos + length; + Sci_PositionU nLengthDoc = startPos + length; styler.StartSegment( startPos ); char cCurrChar; bool bVarInString = false; bool bClassicVarInString = false; - unsigned int i; + Sci_PositionU i; for ( i = startPos; i < nLengthDoc; i++ ) { cCurrChar = styler.SafeGetCharAt( i ); char cNextChar = styler.SafeGetCharAt(i+1); @@ -221,14 +225,13 @@ static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList * break; case SCE_CMAKE_COMMENT: - if ( cNextChar == '\n' || cNextChar == '\r' ) { - // Special case: - if ( cCurrChar == '\\' ) { + if ( cCurrChar == '\n' || cCurrChar == '\r' ) { + if ( styler.SafeGetCharAt(i-1) == '\\' ) { styler.ColourTo(i-2,state); - styler.ColourTo(i,SCE_CMAKE_DEFAULT); + styler.ColourTo(i-1,SCE_CMAKE_DEFAULT); } else { - styler.ColourTo(i,state); + styler.ColourTo(i-1,state); state = SCE_CMAKE_DEFAULT; } } @@ -259,8 +262,8 @@ static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList * } if ( cNextChar == '\r' || cNextChar == '\n' ) { - int nCurLine = styler.GetLine(i+1); - int nBack = i; + Sci_Position nCurLine = styler.GetLine(i+1); + Sci_Position nBack = i; // We need to check if the previous line has a \ in it... bool bNextLine = false; @@ -330,10 +333,7 @@ static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList * break; } - if ( state == SCE_CMAKE_COMMENT) { - styler.ColourTo(i,state); - } - else if ( state == SCE_CMAKE_STRINGDQ || state == SCE_CMAKE_STRINGLQ || state == SCE_CMAKE_STRINGRQ ) { + if ( state == SCE_CMAKE_STRINGDQ || state == SCE_CMAKE_STRINGLQ || state == SCE_CMAKE_STRINGRQ ) { bool bIngoreNextDollarSign = false; if ( bVarInString && cCurrChar == '$' ) { @@ -376,7 +376,7 @@ static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList * styler.ColourTo(nLengthDoc-1,state); } -static void FoldCmakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) +static void FoldCmakeDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { // No folding enabled, no reason to continue... if ( styler.GetPropertyInt("fold") == 0 ) @@ -384,18 +384,18 @@ static void FoldCmakeDoc(unsigned int startPos, int length, int, WordList *[], A bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) == 1; - int lineCurrent = styler.GetLine(startPos); - unsigned int safeStartPos = styler.LineStart( lineCurrent ); + Sci_Position lineCurrent = styler.GetLine(startPos); + Sci_PositionU safeStartPos = styler.LineStart( lineCurrent ); bool bArg1 = true; - int nWordStart = -1; + Sci_Position nWordStart = -1; int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelNext = levelCurrent; - for (unsigned int i = safeStartPos; i < startPos + length; i++) { + for (Sci_PositionU i = safeStartPos; i < startPos + length; i++) { char chCurr = styler.SafeGetCharAt(i); if ( bArg1 ) { diff --git a/Pythonwin/Scintilla/lexers/LexCoffeeScript.cxx b/Pythonwin/Scintilla/lexers/LexCoffeeScript.cxx new file mode 100644 index 000000000..a00162335 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexCoffeeScript.cxx @@ -0,0 +1,483 @@ +// Scintilla source code edit control +/** @file LexCoffeeScript.cxx + ** Lexer for CoffeeScript. + **/ +// Copyright 1998-2011 by Neil Hodgson +// Based on the Scintilla C++ Lexer +// Written by Eric Promislow in 2011 for the Komodo IDE +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#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" + +using namespace Scintilla; + +static bool IsSpaceEquiv(int state) { + return (state == SCE_COFFEESCRIPT_DEFAULT + || state == SCE_COFFEESCRIPT_COMMENTLINE + || state == SCE_COFFEESCRIPT_COMMENTBLOCK + || state == SCE_COFFEESCRIPT_VERBOSE_REGEX + || state == SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT + || state == SCE_COFFEESCRIPT_WORD + || state == SCE_COFFEESCRIPT_REGEX); +} + +// Store the current lexer state and brace count prior to starting a new +// `#{}` interpolation level. +// Based on LexRuby.cxx. +static void enterInnerExpression(int *p_inner_string_types, + int *p_inner_expn_brace_counts, + int& inner_string_count, + int state, + int& brace_counts + ) { + p_inner_string_types[inner_string_count] = state; + p_inner_expn_brace_counts[inner_string_count] = brace_counts; + brace_counts = 0; + ++inner_string_count; +} + +// Restore the lexer state and brace count for the previous `#{}` interpolation +// level upon returning to it. +// Note the previous lexer state is the return value and needs to be restored +// manually by the StyleContext. +// Based on LexRuby.cxx. +static int exitInnerExpression(int *p_inner_string_types, + int *p_inner_expn_brace_counts, + int& inner_string_count, + int& brace_counts + ) { + --inner_string_count; + brace_counts = p_inner_expn_brace_counts[inner_string_count]; + return p_inner_string_types[inner_string_count]; +} + +// Preconditions: sc.currentPos points to a character after '+' or '-'. +// The test for pos reaching 0 should be redundant, +// and is in only for safety measures. +// Limitation: this code will give the incorrect answer for code like +// a = b+++/ptn/... +// Putting a space between the '++' post-inc operator and the '+' binary op +// fixes this, and is highly recommended for readability anyway. +static bool FollowsPostfixOperator(StyleContext &sc, Accessor &styler) { + Sci_Position pos = (Sci_Position) sc.currentPos; + while (--pos > 0) { + char ch = styler[pos]; + if (ch == '+' || ch == '-') { + return styler[pos - 1] == ch; + } + } + return false; +} + +static bool followsKeyword(StyleContext &sc, Accessor &styler) { + Sci_Position pos = (Sci_Position) sc.currentPos; + Sci_Position currentLine = styler.GetLine(pos); + Sci_Position lineStartPos = styler.LineStart(currentLine); + while (--pos > lineStartPos) { + char ch = styler.SafeGetCharAt(pos); + if (ch != ' ' && ch != '\t') { + break; + } + } + styler.Flush(); + return styler.StyleAt(pos) == SCE_COFFEESCRIPT_WORD; +} + +static void ColouriseCoffeeScriptDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], + Accessor &styler) { + + WordList &keywords = *keywordlists[0]; + WordList &keywords2 = *keywordlists[1]; + WordList &keywords4 = *keywordlists[3]; + + CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-"); + CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-"); + + CharacterSet setWordStart(CharacterSet::setAlpha, "_$@", 0x80, true); + CharacterSet setWord(CharacterSet::setAlphaNum, "._$", 0x80, true); + + int chPrevNonWhite = ' '; + int visibleChars = 0; + + // String/Regex interpolation variables, based on LexRuby.cxx. + // In most cases a value of 2 should be ample for the code the user is + // likely to enter. For example, + // "Filling the #{container} with #{liquid}..." + // from the CoffeeScript homepage nests to a level of 2 + // If the user actually hits a 6th occurrence of '#{' in a double-quoted + // string (including regexes), it will stay as a string. The problem with + // this is that quotes might flip, a 7th '#{' will look like a comment, + // and code-folding might be wrong. +#define INNER_STRINGS_MAX_COUNT 5 + // These vars track our instances of "...#{,,,'..#{,,,}...',,,}..." + int inner_string_types[INNER_STRINGS_MAX_COUNT]; + // Track # braces when we push a new #{ thing + int inner_expn_brace_counts[INNER_STRINGS_MAX_COUNT]; + int inner_string_count = 0; + int brace_counts = 0; // Number of #{ ... } things within an expression + for (int i = 0; i < INNER_STRINGS_MAX_COUNT; i++) { + inner_string_types[i] = 0; + inner_expn_brace_counts[i] = 0; + } + + // look back to set chPrevNonWhite properly for better regex colouring + Sci_Position endPos = startPos + length; + if (startPos > 0 && IsSpaceEquiv(initStyle)) { + Sci_PositionU back = startPos; + styler.Flush(); + while (back > 0 && IsSpaceEquiv(styler.StyleAt(--back))) + ; + if (styler.StyleAt(back) == SCE_COFFEESCRIPT_OPERATOR) { + chPrevNonWhite = styler.SafeGetCharAt(back); + } + if (startPos != back) { + initStyle = styler.StyleAt(back); + if (IsSpaceEquiv(initStyle)) { + initStyle = SCE_COFFEESCRIPT_DEFAULT; + } + } + startPos = back; + } + + StyleContext sc(startPos, endPos - startPos, initStyle, styler); + + for (; sc.More();) { + + if (sc.atLineStart) { + // Reset states to beginning of colourise so no surprises + // if different sets of lines lexed. + visibleChars = 0; + } + + // Determine if the current state should terminate. + switch (sc.state) { + case SCE_COFFEESCRIPT_OPERATOR: + sc.SetState(SCE_COFFEESCRIPT_DEFAULT); + break; + case SCE_COFFEESCRIPT_NUMBER: + // We accept almost anything because of hex. and number suffixes + if (!setWord.Contains(sc.ch) || sc.Match('.', '.')) { + sc.SetState(SCE_COFFEESCRIPT_DEFAULT); + } + break; + case SCE_COFFEESCRIPT_IDENTIFIER: + if (!setWord.Contains(sc.ch) || (sc.ch == '.') || (sc.ch == '$')) { + char s[1000]; + sc.GetCurrent(s, sizeof(s)); + if (keywords.InList(s)) { + sc.ChangeState(SCE_COFFEESCRIPT_WORD); + } else if (keywords2.InList(s)) { + sc.ChangeState(SCE_COFFEESCRIPT_WORD2); + } else if (keywords4.InList(s)) { + sc.ChangeState(SCE_COFFEESCRIPT_GLOBALCLASS); + } else if (sc.LengthCurrent() > 0 && s[0] == '@') { + sc.ChangeState(SCE_COFFEESCRIPT_INSTANCEPROPERTY); + } + sc.SetState(SCE_COFFEESCRIPT_DEFAULT); + } + break; + case SCE_COFFEESCRIPT_WORD: + case SCE_COFFEESCRIPT_WORD2: + case SCE_COFFEESCRIPT_GLOBALCLASS: + case SCE_COFFEESCRIPT_INSTANCEPROPERTY: + if (!setWord.Contains(sc.ch)) { + sc.SetState(SCE_COFFEESCRIPT_DEFAULT); + } + break; + case SCE_COFFEESCRIPT_COMMENTLINE: + if (sc.atLineStart) { + sc.SetState(SCE_COFFEESCRIPT_DEFAULT); + } + break; + case SCE_COFFEESCRIPT_STRING: + if (sc.ch == '\\') { + if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\"') { + sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); + } else if (sc.ch == '#' && sc.chNext == '{' && inner_string_count < INNER_STRINGS_MAX_COUNT) { + // process interpolated code #{ ... } + enterInnerExpression(inner_string_types, + inner_expn_brace_counts, + inner_string_count, + sc.state, + brace_counts); + sc.SetState(SCE_COFFEESCRIPT_OPERATOR); + sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); + } + break; + case SCE_COFFEESCRIPT_CHARACTER: + if (sc.ch == '\\') { + if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\'') { + sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); + } + break; + case SCE_COFFEESCRIPT_REGEX: + if (sc.atLineStart) { + sc.SetState(SCE_COFFEESCRIPT_DEFAULT); + } else if (sc.ch == '/') { + sc.Forward(); + while ((sc.ch < 0x80) && islower(sc.ch)) + sc.Forward(); // gobble regex flags + sc.SetState(SCE_COFFEESCRIPT_DEFAULT); + } else if (sc.ch == '\\') { + // Gobble up the quoted character + if (sc.chNext == '\\' || sc.chNext == '/') { + sc.Forward(); + } + } + break; + case SCE_COFFEESCRIPT_STRINGEOL: + if (sc.atLineStart) { + sc.SetState(SCE_COFFEESCRIPT_DEFAULT); + } + break; + case SCE_COFFEESCRIPT_COMMENTBLOCK: + if (sc.Match("###")) { + sc.Forward(); + sc.Forward(); + sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); + } else if (sc.ch == '\\') { + sc.Forward(); + } + break; + case SCE_COFFEESCRIPT_VERBOSE_REGEX: + if (sc.Match("///")) { + sc.Forward(); + sc.Forward(); + sc.ForwardSetState(SCE_COFFEESCRIPT_DEFAULT); + } else if (sc.Match('#')) { + sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT); + } else if (sc.ch == '\\') { + sc.Forward(); + } + break; + case SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT: + if (sc.atLineStart) { + sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX); + } + break; + } + + // Determine if a new state should be entered. + if (sc.state == SCE_COFFEESCRIPT_DEFAULT) { + if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { + sc.SetState(SCE_COFFEESCRIPT_NUMBER); + } else if (setWordStart.Contains(sc.ch)) { + sc.SetState(SCE_COFFEESCRIPT_IDENTIFIER); + } else if (sc.Match("///")) { + sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX); + sc.Forward(); + sc.Forward(); + } else if (sc.ch == '/' + && (setOKBeforeRE.Contains(chPrevNonWhite) + || followsKeyword(sc, styler)) + && (!setCouldBePostOp.Contains(chPrevNonWhite) + || !FollowsPostfixOperator(sc, styler))) { + sc.SetState(SCE_COFFEESCRIPT_REGEX); // JavaScript's RegEx + } else if (sc.ch == '\"') { + sc.SetState(SCE_COFFEESCRIPT_STRING); + } else if (sc.ch == '\'') { + sc.SetState(SCE_COFFEESCRIPT_CHARACTER); + } else if (sc.ch == '#') { + if (sc.Match("###")) { + sc.SetState(SCE_COFFEESCRIPT_COMMENTBLOCK); + sc.Forward(); + sc.Forward(); + } else { + sc.SetState(SCE_COFFEESCRIPT_COMMENTLINE); + } + } else if (isoperator(static_cast(sc.ch))) { + sc.SetState(SCE_COFFEESCRIPT_OPERATOR); + // Handle '..' and '...' operators correctly. + if (sc.ch == '.') { + for (int i = 0; i < 2 && sc.chNext == '.'; i++, sc.Forward()) ; + } else if (sc.ch == '{') { + ++brace_counts; + } else if (sc.ch == '}' && --brace_counts <= 0 && inner_string_count > 0) { + // Return to previous state before #{ ... } + sc.ForwardSetState(exitInnerExpression(inner_string_types, + inner_expn_brace_counts, + inner_string_count, + brace_counts)); + continue; // skip sc.Forward() at loop end + } + } + } + + if (!IsASpace(sc.ch) && !IsSpaceEquiv(sc.state)) { + chPrevNonWhite = sc.ch; + visibleChars++; + } + sc.Forward(); + } + sc.Complete(); +} + +static bool IsCommentLine(Sci_Position line, Accessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + if (ch == '#') + return true; + else if (ch != ' ' && ch != '\t') + return false; + } + return false; +} + +static void FoldCoffeeScriptDoc(Sci_PositionU startPos, Sci_Position length, int, + WordList *[], Accessor &styler) { + // A simplified version of FoldPyDoc + const Sci_Position maxPos = startPos + length; + const Sci_Position maxLines = styler.GetLine(maxPos - 1); // Requested last line + const Sci_Position docLines = styler.GetLine(styler.Length() - 1); // Available last line + + // property fold.coffeescript.comment + const bool foldComment = styler.GetPropertyInt("fold.coffeescript.comment") != 0; + + const bool foldCompact = styler.GetPropertyInt("fold.compact") != 0; + + // Backtrack to previous non-blank line so we can determine indent level + // for any white space lines + // and so we can fix any preceding fold level (which is why we go back + // at least one line in all cases) + int spaceFlags = 0; + Sci_Position lineCurrent = styler.GetLine(startPos); + int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); + while (lineCurrent > 0) { + lineCurrent--; + indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); + if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) + && !IsCommentLine(lineCurrent, styler)) + break; + } + int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; + + // Set up initial loop state + int prevComment = 0; + if (lineCurrent >= 1) + prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler); + + // Process all characters to end of requested range + // or comment that hangs over the end of the range. Cap processing in all cases + // to end of document (in case of comment at end). + while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevComment)) { + + // Gather info + int lev = indentCurrent; + Sci_Position lineNext = lineCurrent + 1; + int indentNext = indentCurrent; + if (lineNext <= docLines) { + // Information about next line is only available if not at end of document + indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); + } + const int comment = foldComment && IsCommentLine(lineCurrent, styler); + const int comment_start = (comment && !prevComment && (lineNext <= docLines) && + IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE)); + const int comment_continue = (comment && prevComment); + if (!comment) + indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; + if (indentNext & SC_FOLDLEVELWHITEFLAG) + indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel; + + if (comment_start) { + // Place fold point at start of a block of comments + lev |= SC_FOLDLEVELHEADERFLAG; + } else if (comment_continue) { + // Add level to rest of lines in the block + lev = lev + 1; + } + + // Skip past any blank lines for next indent level info; we skip also + // comments (all comments, not just those starting in column 0) + // which effectively folds them into surrounding code rather + // than screwing up folding. + + while ((lineNext < docLines) && + ((indentNext & SC_FOLDLEVELWHITEFLAG) || + (lineNext <= docLines && IsCommentLine(lineNext, styler)))) { + + lineNext++; + indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); + } + + const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK; + const int levelBeforeComments = std::max(indentCurrentLevel,levelAfterComments); + + // Now set all the indent levels on the lines we skipped + // Do this from end to start. Once we encounter one line + // which is indented more than the line after the end of + // the comment-block, use the level of the block before + + Sci_Position skipLine = lineNext; + int skipLevel = levelAfterComments; + + while (--skipLine > lineCurrent) { + int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL); + + if (foldCompact) { + if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments) + skipLevel = levelBeforeComments; + + int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG; + + styler.SetLevel(skipLine, skipLevel | whiteFlag); + } else { + if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments && + !(skipLineIndent & SC_FOLDLEVELWHITEFLAG) && + !IsCommentLine(skipLine, styler)) + skipLevel = levelBeforeComments; + + styler.SetLevel(skipLine, skipLevel); + } + } + + // Set fold header on non-comment line + if (!comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { + if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) + lev |= SC_FOLDLEVELHEADERFLAG; + } + + // Keep track of block comment state of previous line + prevComment = comment_start || comment_continue; + + // Set fold level for this line and move to next line + styler.SetLevel(lineCurrent, lev); + indentCurrent = indentNext; + lineCurrent = lineNext; + } +} + +static const char *const csWordLists[] = { + "Keywords", + "Secondary keywords", + "Unused", + "Global classes", + 0, +}; + +LexerModule lmCoffeeScript(SCLEX_COFFEESCRIPT, ColouriseCoffeeScriptDoc, "coffeescript", FoldCoffeeScriptDoc, csWordLists); diff --git a/Pythonwin/Scintilla/src/LexConf.cxx b/Pythonwin/Scintilla/lexers/LexConf.cxx similarity index 83% rename from Pythonwin/Scintilla/src/LexConf.cxx rename to Pythonwin/Scintilla/lexers/LexConf.cxx index 969275f92..73fbe46ef 100644 --- a/Pythonwin/Scintilla/src/LexConf.cxx +++ b/Pythonwin/Scintilla/lexers/LexConf.cxx @@ -2,7 +2,7 @@ /** @file LexConf.cxx ** Lexer for Apache Configuration Files. ** - ** First working version contributed by Ahmad Zawawi on October 28, 2000. + ** First working version contributed by Ahmad Zawawi on October 28, 2000. ** i created this lexer because i needed something pretty when dealing ** when Apache Configuration files... **/ @@ -11,30 +11,32 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" - -#include "PropSet.h" -#include "Accessor.h" -#include "KeyWords.h" +#include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" -#ifdef SCI_NAMESPACE +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + using namespace Scintilla; -#endif -static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) +static void ColouriseConfDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_CONF_DEFAULT; char chNext = styler[startPos]; - int lengthDoc = startPos + length; + Sci_Position lengthDoc = startPos + length; // create a buffer large enough to take the largest chunk... - char *buffer = new char[length]; - int bufferCount = 0; + char *buffer = new char[length+1]; + Sci_Position bufferCount = 0; // this assumes that we have 2 keyword list in conf.properties WordList &directives = *keywordLists[0]; @@ -44,7 +46,7 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k // using the hand-written state machine shown below styler.StartAt(startPos); styler.StartSegment(startPos); - for (int i = startPos; i < lengthDoc; i++) { + for (Sci_Position i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -70,17 +72,17 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k } else if( ch == '"') { state = SCE_CONF_STRING; styler.ColourTo(i,SCE_CONF_STRING); - } else if( ispunct(ch) ) { + } else if( IsASCII(ch) && ispunct(ch) ) { // signals an operator... // no state jump necessary for this // simple case... styler.ColourTo(i,SCE_CONF_OPERATOR); - } else if( isalpha(ch) ) { + } else if( IsASCII(ch) && isalpha(ch) ) { // signals the start of an identifier bufferCount = 0; buffer[bufferCount++] = static_cast(tolower(ch)); state = SCE_CONF_IDENTIFIER; - } else if( isdigit(ch) ) { + } else if( IsASCII(ch) && isdigit(ch) ) { // signals the start of a number bufferCount = 0; buffer[bufferCount++] = ch; @@ -107,7 +109,7 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k // if we find a non-alphanumeric char, // we simply go to default state // else we're still dealing with an extension... - if( isalnum(ch) || (ch == '_') || + if( (IsASCII(ch) && isalnum(ch)) || (ch == '_') || (ch == '-') || (ch == '$') || (ch == '/') || (ch == '.') || (ch == '*') ) { @@ -129,7 +131,7 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k case SCE_CONF_IDENTIFIER: // stay in CONF_IDENTIFIER state until we find a non-alphanumeric - if( isalnum(ch) || (ch == '_') || (ch == '-') || (ch == '/') || (ch == '$') || (ch == '.') || (ch == '*')) { + if( (IsASCII(ch) && isalnum(ch)) || (ch == '_') || (ch == '-') || (ch == '/') || (ch == '$') || (ch == '.') || (ch == '*')) { buffer[bufferCount++] = static_cast(tolower(ch)); } else { state = SCE_CONF_DEFAULT; @@ -154,7 +156,7 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k case SCE_CONF_NUMBER: // stay in CONF_NUMBER state until we find a non-numeric - if( isdigit(ch) || ch == '.') { + if( (IsASCII(ch) && isdigit(ch)) || ch == '.') { buffer[bufferCount++] = ch; } else { state = SCE_CONF_DEFAULT; diff --git a/Pythonwin/Scintilla/src/LexCrontab.cxx b/Pythonwin/Scintilla/lexers/LexCrontab.cxx similarity index 90% rename from Pythonwin/Scintilla/src/LexCrontab.cxx rename to Pythonwin/Scintilla/lexers/LexCrontab.cxx index 62044c370..7f6d5fb0c 100644 --- a/Pythonwin/Scintilla/src/LexCrontab.cxx +++ b/Pythonwin/Scintilla/lexers/LexCrontab.cxx @@ -9,31 +9,33 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" - -#include "PropSet.h" -#include "Accessor.h" -#include "KeyWords.h" +#include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" -#ifdef SCI_NAMESPACE +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + using namespace Scintilla; -#endif -static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordList +static void ColouriseNncrontabDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_NNCRONTAB_DEFAULT; char chNext = styler[startPos]; - int lengthDoc = startPos + length; + Sci_Position lengthDoc = startPos + length; // create a buffer large enough to take the largest chunk... - char *buffer = new char[length]; - int bufferCount = 0; + char *buffer = new char[length+1]; + Sci_Position bufferCount = 0; // used when highliting environment variables inside quoted string: bool insideString = false; @@ -46,7 +48,7 @@ static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordLi // using the hand-written state machine shown below styler.StartAt(startPos); styler.StartSegment(startPos); - for (int i = startPos; i < lengthDoc; i++) { + for (Sci_Position i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -94,12 +96,12 @@ static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordLi // signals an asterisk // no state jump necessary for this simple case... styler.ColourTo(i,SCE_NNCRONTAB_ASTERISK); - } else if( isalpha(ch) || ch == '<' ) { + } else if( (IsASCII(ch) && isalpha(ch)) || ch == '<' ) { // signals the start of an identifier bufferCount = 0; buffer[bufferCount++] = ch; state = SCE_NNCRONTAB_IDENTIFIER; - } else if( isdigit(ch) ) { + } else if( IsASCII(ch) && isdigit(ch) ) { // signals the start of a number bufferCount = 0; buffer[bufferCount++] = ch; @@ -167,7 +169,7 @@ static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordLi case SCE_NNCRONTAB_IDENTIFIER: // stay in CONF_IDENTIFIER state until we find a non-alphanumeric - if( isalnum(ch) || (ch == '_') || (ch == '-') || (ch == '/') || + if( (IsASCII(ch) && isalnum(ch)) || (ch == '_') || (ch == '-') || (ch == '/') || (ch == '$') || (ch == '.') || (ch == '<') || (ch == '>') || (ch == '@') ) { buffer[bufferCount++] = ch; @@ -196,7 +198,7 @@ static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordLi case SCE_NNCRONTAB_NUMBER: // stay in CONF_NUMBER state until we find a non-numeric - if( isdigit(ch) /* || ch == '.' */ ) { + if( IsASCII(ch) && isdigit(ch) /* || ch == '.' */ ) { buffer[bufferCount++] = ch; } else { state = SCE_NNCRONTAB_DEFAULT; diff --git a/Pythonwin/Scintilla/src/LexCsound.cxx b/Pythonwin/Scintilla/lexers/LexCsound.cxx similarity index 91% rename from Pythonwin/Scintilla/src/LexCsound.cxx rename to Pythonwin/Scintilla/lexers/LexCsound.cxx index 4162c9b3a..24603801e 100644 --- a/Pythonwin/Scintilla/src/LexCsound.cxx +++ b/Pythonwin/Scintilla/lexers/LexCsound.cxx @@ -8,21 +8,23 @@ #include #include -#include #include #include -#include "Platform.h" +#include +#include -#include "PropSet.h" -#include "Accessor.h" -#include "StyleContext.h" -#include "KeyWords.h" +#include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" -#ifdef SCI_NAMESPACE +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + using namespace Scintilla; -#endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || @@ -35,7 +37,7 @@ static inline bool IsAWordStart(const int ch) { } static inline bool IsCsoundOperator(char ch) { - if (isalnum(ch)) + if (IsASCII(ch) && isalnum(ch)) return false; // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || @@ -47,7 +49,7 @@ static inline bool IsCsoundOperator(char ch) { return false; } -static void ColouriseCsoundDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseCsoundDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &opcode = *keywordlists[0]; @@ -72,7 +74,7 @@ static void ColouriseCsoundDoc(unsigned int startPos, int length, int initStyle, continue; } } - + // Determine if the current state should terminate. if (sc.state == SCE_CSOUND_OPERATOR) { if (!IsCsoundOperator(static_cast(sc.ch))) { @@ -119,7 +121,7 @@ static void ColouriseCsoundDoc(unsigned int startPos, int length, int initStyle, sc.SetState(SCE_CSOUND_DEFAULT); } } - + // Determine if a new state should be entered. if (sc.state == SCE_CSOUND_DEFAULT) { if (sc.ch == ';'){ @@ -146,17 +148,17 @@ static void ColouriseCsoundDoc(unsigned int startPos, int length, int initStyle, sc.Complete(); } -static void FoldCsoundInstruments(unsigned int startPos, int length, int /* initStyle */, WordList *[], +static void FoldCsoundInstruments(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int stylePrev = 0; int styleNext = styler.StyleAt(startPos); - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; diff --git a/Pythonwin/Scintilla/lexers/LexD.cxx b/Pythonwin/Scintilla/lexers/LexD.cxx new file mode 100644 index 000000000..9381a0d07 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexD.cxx @@ -0,0 +1,571 @@ +/** @file LexD.cxx + ** Lexer for D. + ** + ** Copyright (c) 2006 by Waldemar Augustyn + ** Converted to lexer object and added further folding features/properties by "Udo Lechner" + **/ +// Copyright 1998-2005 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 "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" +#include "DefaultLexer.h" + +using namespace Scintilla; + +/* Nested comments require keeping the value of the nesting level for every + position in the document. But since scintilla always styles line by line, + we only need to store one value per line. The non-negative number indicates + nesting level at the end of the line. +*/ + +// Underscore, letter, digit and universal alphas from C99 Appendix D. + +static bool IsWordStart(int ch) { + return (IsASCII(ch) && (isalpha(ch) || ch == '_')) || !IsASCII(ch); +} + +static bool IsWord(int ch) { + return (IsASCII(ch) && (isalnum(ch) || ch == '_')) || !IsASCII(ch); +} + +static bool IsDoxygen(int ch) { + if (IsASCII(ch) && islower(ch)) + return true; + if (ch == '$' || ch == '@' || ch == '\\' || + ch == '&' || ch == '#' || ch == '<' || ch == '>' || + ch == '{' || ch == '}' || ch == '[' || ch == ']') + return true; + return false; +} + +static bool IsStringSuffix(int ch) { + return ch == 'c' || ch == 'w' || ch == 'd'; +} + +static bool IsStreamCommentStyle(int style) { + return style == SCE_D_COMMENT || + style == SCE_D_COMMENTDOC || + style == SCE_D_COMMENTDOCKEYWORD || + style == SCE_D_COMMENTDOCKEYWORDERROR; +} + +// An individual named option for use in an OptionSet + +// Options used for LexerD +struct OptionsD { + bool fold; + bool foldSyntaxBased; + bool foldComment; + bool foldCommentMultiline; + bool foldCommentExplicit; + std::string foldExplicitStart; + std::string foldExplicitEnd; + bool foldExplicitAnywhere; + bool foldCompact; + int foldAtElseInt; + bool foldAtElse; + OptionsD() { + fold = false; + foldSyntaxBased = true; + foldComment = false; + foldCommentMultiline = true; + foldCommentExplicit = true; + foldExplicitStart = ""; + foldExplicitEnd = ""; + foldExplicitAnywhere = false; + foldCompact = true; + foldAtElseInt = -1; + foldAtElse = false; + } +}; + +static const char * const dWordLists[] = { + "Primary keywords and identifiers", + "Secondary keywords and identifiers", + "Documentation comment keywords", + "Type definitions and aliases", + "Keywords 5", + "Keywords 6", + "Keywords 7", + 0, + }; + +struct OptionSetD : public OptionSet { + OptionSetD() { + DefineProperty("fold", &OptionsD::fold); + + DefineProperty("fold.d.syntax.based", &OptionsD::foldSyntaxBased, + "Set this property to 0 to disable syntax based folding."); + + DefineProperty("fold.comment", &OptionsD::foldComment); + + DefineProperty("fold.d.comment.multiline", &OptionsD::foldCommentMultiline, + "Set this property to 0 to disable folding multi-line comments when fold.comment=1."); + + DefineProperty("fold.d.comment.explicit", &OptionsD::foldCommentExplicit, + "Set this property to 0 to disable folding explicit fold points when fold.comment=1."); + + DefineProperty("fold.d.explicit.start", &OptionsD::foldExplicitStart, + "The string to use for explicit fold start points, replacing the standard //{."); + + DefineProperty("fold.d.explicit.end", &OptionsD::foldExplicitEnd, + "The string to use for explicit fold end points, replacing the standard //}."); + + DefineProperty("fold.d.explicit.anywhere", &OptionsD::foldExplicitAnywhere, + "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); + + DefineProperty("fold.compact", &OptionsD::foldCompact); + + DefineProperty("lexer.d.fold.at.else", &OptionsD::foldAtElseInt, + "This option enables D folding on a \"} else {\" line of an if statement."); + + DefineProperty("fold.at.else", &OptionsD::foldAtElse); + + DefineWordListSets(dWordLists); + } +}; + +class LexerD : public DefaultLexer { + bool caseSensitive; + WordList keywords; + WordList keywords2; + WordList keywords3; + WordList keywords4; + WordList keywords5; + WordList keywords6; + WordList keywords7; + OptionsD options; + OptionSetD osD; +public: + LexerD(bool caseSensitive_) : + DefaultLexer("D", SCLEX_D), + caseSensitive(caseSensitive_) { + } + virtual ~LexerD() { + } + void SCI_METHOD Release() override { + delete this; + } + int SCI_METHOD Version() const override { + return lvRelease5; + } + const char * SCI_METHOD PropertyNames() override { + return osD.PropertyNames(); + } + int SCI_METHOD PropertyType(const char *name) override { + return osD.PropertyType(name); + } + const char * SCI_METHOD DescribeProperty(const char *name) override { + return osD.DescribeProperty(name); + } + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override; + const char * SCI_METHOD PropertyGet(const char *key) override { + return osD.PropertyGet(key); + } + const char * SCI_METHOD DescribeWordListSets() override { + return osD.DescribeWordListSets(); + } + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override; + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + + void * SCI_METHOD PrivateCall(int, void *) override { + return 0; + } + + static ILexer5 *LexerFactoryD() { + return new LexerD(true); + } + static ILexer5 *LexerFactoryDInsensitive() { + return new LexerD(false); + } +}; + +Sci_Position SCI_METHOD LexerD::PropertySet(const char *key, const char *val) { + if (osD.PropertySet(&options, key, val)) { + return 0; + } + return -1; +} + +Sci_Position SCI_METHOD LexerD::WordListSet(int n, const char *wl) { + WordList *wordListN = 0; + switch (n) { + case 0: + wordListN = &keywords; + break; + case 1: + wordListN = &keywords2; + break; + case 2: + wordListN = &keywords3; + break; + case 3: + wordListN = &keywords4; + break; + case 4: + wordListN = &keywords5; + break; + case 5: + wordListN = &keywords6; + break; + case 6: + wordListN = &keywords7; + break; + } + Sci_Position firstModification = -1; + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + return firstModification; +} + +void SCI_METHOD LexerD::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + LexAccessor styler(pAccess); + + int styleBeforeDCKeyword = SCE_D_DEFAULT; + + StyleContext sc(startPos, length, initStyle, styler); + + Sci_Position curLine = styler.GetLine(startPos); + int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0; + bool numFloat = false; // Float literals have '+' and '-' signs + bool numHex = false; + + for (; sc.More(); sc.Forward()) { + + if (sc.atLineStart) { + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + } + + // Determine if the current state should terminate. + switch (sc.state) { + case SCE_D_OPERATOR: + sc.SetState(SCE_D_DEFAULT); + break; + case SCE_D_NUMBER: + // We accept almost anything because of hex. and number suffixes + if (IsASCII(sc.ch) && (isalnum(sc.ch) || sc.ch == '_')) { + continue; + } else if (sc.ch == '.' && sc.chNext != '.' && !numFloat) { + // Don't parse 0..2 as number. + numFloat=true; + continue; + } else if ( ( sc.ch == '-' || sc.ch == '+' ) && ( /*sign and*/ + ( !numHex && ( sc.chPrev == 'e' || sc.chPrev == 'E' ) ) || /*decimal or*/ + ( sc.chPrev == 'p' || sc.chPrev == 'P' ) ) ) { /*hex*/ + // Parse exponent sign in float literals: 2e+10 0x2e+10 + continue; + } else { + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_IDENTIFIER: + if (!IsWord(sc.ch)) { + char s[1000]; + if (caseSensitive) { + sc.GetCurrent(s, sizeof(s)); + } else { + sc.GetCurrentLowered(s, sizeof(s)); + } + if (keywords.InList(s)) { + sc.ChangeState(SCE_D_WORD); + } else if (keywords2.InList(s)) { + sc.ChangeState(SCE_D_WORD2); + } else if (keywords4.InList(s)) { + sc.ChangeState(SCE_D_TYPEDEF); + } else if (keywords5.InList(s)) { + sc.ChangeState(SCE_D_WORD5); + } else if (keywords6.InList(s)) { + sc.ChangeState(SCE_D_WORD6); + } else if (keywords7.InList(s)) { + sc.ChangeState(SCE_D_WORD7); + } + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_COMMENT: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_COMMENTDOC: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = SCE_D_COMMENTDOC; + sc.SetState(SCE_D_COMMENTDOCKEYWORD); + } + } + break; + case SCE_D_COMMENTLINE: + if (sc.atLineStart) { + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_COMMENTLINEDOC: + if (sc.atLineStart) { + sc.SetState(SCE_D_DEFAULT); + } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = SCE_D_COMMENTLINEDOC; + sc.SetState(SCE_D_COMMENTDOCKEYWORD); + } + } + break; + case SCE_D_COMMENTDOCKEYWORD: + if ((styleBeforeDCKeyword == SCE_D_COMMENTDOC) && sc.Match('*', '/')) { + sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } else if (!IsDoxygen(sc.ch)) { + char s[100]; + if (caseSensitive) { + sc.GetCurrent(s, sizeof(s)); + } else { + sc.GetCurrentLowered(s, sizeof(s)); + } + if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) { + sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); + } + sc.SetState(styleBeforeDCKeyword); + } + break; + case SCE_D_COMMENTNESTED: + if (sc.Match('+', '/')) { + if (curNcLevel > 0) + curNcLevel -= 1; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + sc.Forward(); + if (curNcLevel == 0) { + sc.ForwardSetState(SCE_D_DEFAULT); + } + } else if (sc.Match('/','+')) { + curNcLevel += 1; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + sc.Forward(); + } + break; + case SCE_D_STRING: + if (sc.ch == '\\') { + if (sc.chNext == '"' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '"') { + if(IsStringSuffix(sc.chNext)) + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_CHARACTER: + if (sc.atLineEnd) { + sc.ChangeState(SCE_D_STRINGEOL); + } else if (sc.ch == '\\') { + if (sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\'') { + // Char has no suffixes + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_STRINGEOL: + if (sc.atLineStart) { + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_STRINGB: + if (sc.ch == '`') { + if(IsStringSuffix(sc.chNext)) + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_STRINGR: + if (sc.ch == '"') { + if(IsStringSuffix(sc.chNext)) + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + } + + // Determine if a new state should be entered. + if (sc.state == SCE_D_DEFAULT) { + if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { + sc.SetState(SCE_D_NUMBER); + numFloat = sc.ch == '.'; + // Remember hex literal + numHex = sc.ch == '0' && ( sc.chNext == 'x' || sc.chNext == 'X' ); + } else if ( (sc.ch == 'r' || sc.ch == 'x' || sc.ch == 'q') + && sc.chNext == '"' ) { + // Limited support for hex and delimited strings: parse as r"" + sc.SetState(SCE_D_STRINGR); + sc.Forward(); + } else if (IsWordStart(sc.ch) || sc.ch == '$') { + sc.SetState(SCE_D_IDENTIFIER); + } else if (sc.Match('/','+')) { + curNcLevel += 1; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + sc.SetState(SCE_D_COMMENTNESTED); + sc.Forward(); + } else if (sc.Match('/', '*')) { + if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style + sc.SetState(SCE_D_COMMENTDOC); + } else { + sc.SetState(SCE_D_COMMENT); + } + sc.Forward(); // Eat the * so it isn't used for the end of the comment + } else if (sc.Match('/', '/')) { + if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!")) + // Support of Qt/Doxygen doc. style + sc.SetState(SCE_D_COMMENTLINEDOC); + else + sc.SetState(SCE_D_COMMENTLINE); + } else if (sc.ch == '"') { + sc.SetState(SCE_D_STRING); + } else if (sc.ch == '\'') { + sc.SetState(SCE_D_CHARACTER); + } else if (sc.ch == '`') { + sc.SetState(SCE_D_STRINGB); + } else if (isoperator(static_cast(sc.ch))) { + sc.SetState(SCE_D_OPERATOR); + if (sc.ch == '.' && sc.chNext == '.') sc.Forward(); // Range operator + } + } + } + sc.Complete(); +} + +// 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 {". + +void SCI_METHOD LexerD::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + + if (!options.fold) + return; + + LexAccessor styler(pAccess); + + 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 = styler[startPos]; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + bool foldAtElse = options.foldAtElseInt >= 0 ? options.foldAtElseInt != 0 : options.foldAtElse; + const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); + for (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 (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style)) { + if (!IsStreamCommentStyle(stylePrev)) { + levelNext++; + } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { + // Comments don't end at end of line and the next character may be unstyled. + levelNext--; + } + } + if (options.foldComment && options.foldCommentExplicit && ((style == SCE_D_COMMENTLINE) || options.foldExplicitAnywhere)) { + if (userDefinedFoldMarkers) { + if (styler.Match(i, options.foldExplicitStart.c_str())) { + levelNext++; + } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { + levelNext--; + } + } else { + if ((ch == '/') && (chNext == '/')) { + char chNext2 = styler.SafeGetCharAt(i + 2); + if (chNext2 == '{') { + levelNext++; + } else if (chNext2 == '}') { + levelNext--; + } + } + } + } + if (options.foldSyntaxBased && (style == SCE_D_OPERATOR)) { + if (ch == '{') { + // Measure the minimum before a '{' to allow + // folding on "} else {" + if (levelMinCurrent > levelNext) { + levelMinCurrent = levelNext; + } + levelNext++; + } else if (ch == '}') { + levelNext--; + } + } + if (atEOL || (i == endPos-1)) { + if (options.foldComment && options.foldCommentMultiline) { // Handle nested comments + int nc; + nc = styler.GetLineState(lineCurrent); + nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0; + levelNext += nc; + } + int levelUse = levelCurrent; + if (options.foldSyntaxBased && foldAtElse) { + levelUse = levelMinCurrent; + } + int lev = levelUse | levelNext << 16; + if (visibleChars == 0 && options.foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if (levelUse < levelNext) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + levelCurrent = levelNext; + levelMinCurrent = levelCurrent; + visibleChars = 0; + } + if (!IsASpace(ch)) + visibleChars++; + } +} + +LexerModule lmD(SCLEX_D, LexerD::LexerFactoryD, "d", dWordLists); diff --git a/Pythonwin/Scintilla/lexers/LexDMAP.cxx b/Pythonwin/Scintilla/lexers/LexDMAP.cxx new file mode 100644 index 000000000..91b10c29b --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexDMAP.cxx @@ -0,0 +1,226 @@ +// Scintilla source code edit control +/** @file LexDMAP.cxx + ** Lexer for MSC Nastran DMAP. + ** Written by Mark Robinson, based on the Fortran lexer by Chuan-jian Shen, Last changed Aug. 2013 + **/ +// 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 "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" +/***************************************/ + +using namespace Scintilla; + +/***********************************************/ +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '%'); +} +/**********************************************/ +static inline bool IsAWordStart(const int ch) { + return (ch < 0x80) && (isalnum(ch)); +} +/***************************************/ +static void ColouriseDMAPDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + WordList &keywords = *keywordlists[0]; + WordList &keywords2 = *keywordlists[1]; + WordList &keywords3 = *keywordlists[2]; + /***************************************/ + Sci_Position posLineStart = 0, numNonBlank = 0; + Sci_Position endPos = startPos + length; + /***************************************/ + // backtrack to the nearest keyword + while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_DMAP_WORD)) { + startPos--; + } + startPos = styler.LineStart(styler.GetLine(startPos)); + initStyle = styler.StyleAt(startPos - 1); + StyleContext sc(startPos, endPos-startPos, initStyle, styler); + /***************************************/ + for (; sc.More(); sc.Forward()) { + // remember the start position of the line + if (sc.atLineStart) { + posLineStart = sc.currentPos; + numNonBlank = 0; + sc.SetState(SCE_DMAP_DEFAULT); + } + if (!IsASpaceOrTab(sc.ch)) numNonBlank ++; + /***********************************************/ + // Handle data appearing after column 72; it is ignored + Sci_Position toLineStart = sc.currentPos - posLineStart; + if (toLineStart >= 72 || sc.ch == '$') { + sc.SetState(SCE_DMAP_COMMENT); + while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end + continue; + } + /***************************************/ + // Determine if the current state should terminate. + if (sc.state == SCE_DMAP_OPERATOR) { + sc.SetState(SCE_DMAP_DEFAULT); + } else if (sc.state == SCE_DMAP_NUMBER) { + if (!(IsAWordChar(sc.ch) || sc.ch=='\'' || sc.ch=='\"' || sc.ch=='.')) { + sc.SetState(SCE_DMAP_DEFAULT); + } + } else if (sc.state == SCE_DMAP_IDENTIFIER) { + if (!IsAWordChar(sc.ch) || (sc.ch == '%')) { + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + if (keywords.InList(s)) { + sc.ChangeState(SCE_DMAP_WORD); + } else if (keywords2.InList(s)) { + sc.ChangeState(SCE_DMAP_WORD2); + } else if (keywords3.InList(s)) { + sc.ChangeState(SCE_DMAP_WORD3); + } + sc.SetState(SCE_DMAP_DEFAULT); + } + } else if (sc.state == SCE_DMAP_COMMENT) { + if (sc.ch == '\r' || sc.ch == '\n') { + sc.SetState(SCE_DMAP_DEFAULT); + } + } else if (sc.state == SCE_DMAP_STRING1) { + if (sc.ch == '\'') { + if (sc.chNext == '\'') { + sc.Forward(); + } else { + sc.ForwardSetState(SCE_DMAP_DEFAULT); + } + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_DMAP_STRINGEOL); + sc.ForwardSetState(SCE_DMAP_DEFAULT); + } + } else if (sc.state == SCE_DMAP_STRING2) { + if (sc.atLineEnd) { + sc.ChangeState(SCE_DMAP_STRINGEOL); + sc.ForwardSetState(SCE_DMAP_DEFAULT); + } else if (sc.ch == '\"') { + if (sc.chNext == '\"') { + sc.Forward(); + } else { + sc.ForwardSetState(SCE_DMAP_DEFAULT); + } + } + } + /***************************************/ + // Determine if a new state should be entered. + if (sc.state == SCE_DMAP_DEFAULT) { + if (sc.ch == '$') { + sc.SetState(SCE_DMAP_COMMENT); + } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext)) || (sc.ch == '-' && IsADigit(sc.chNext))) { + sc.SetState(SCE_F_NUMBER); + } else if (IsAWordStart(sc.ch)) { + sc.SetState(SCE_DMAP_IDENTIFIER); + } else if (sc.ch == '\"') { + sc.SetState(SCE_DMAP_STRING2); + } else if (sc.ch == '\'') { + sc.SetState(SCE_DMAP_STRING1); + } else if (isoperator(static_cast(sc.ch))) { + sc.SetState(SCE_DMAP_OPERATOR); + } + } + } + sc.Complete(); +} +/***************************************/ +// To determine the folding level depending on keywords +static int classifyFoldPointDMAP(const char* s, const char* prevWord) { + int lev = 0; + if ((strcmp(prevWord, "else") == 0 && strcmp(s, "if") == 0) || strcmp(s, "enddo") == 0 || strcmp(s, "endif") == 0) { + lev = -1; + } else if ((strcmp(prevWord, "do") == 0 && strcmp(s, "while") == 0) || strcmp(s, "then") == 0) { + lev = 1; + } + return lev; +} +// Folding the code +static void FoldDMAPDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, + WordList *[], Accessor &styler) { + // + // bool foldComment = styler.GetPropertyInt("fold.comment") != 0; + // Do not know how to fold the comment at the moment. + // + 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; + /***************************************/ + Sci_Position lastStart = 0; + char prevWord[32] = ""; + /***************************************/ + 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 ((stylePrev == SCE_DMAP_DEFAULT || stylePrev == SCE_DMAP_OPERATOR || stylePrev == SCE_DMAP_COMMENT) && (style == SCE_DMAP_WORD)) { + // Store last word and label start point. + lastStart = i; + } + /***************************************/ + if (style == SCE_DMAP_WORD) { + if(iswordchar(ch) && !iswordchar(chNext)) { + char s[32]; + Sci_PositionU k; + for(k=0; (k<31 ) && (k(tolower(styler[lastStart+k])); + } + s[k] = '\0'; + levelCurrent += classifyFoldPointDMAP(s, prevWord); + strcpy(prevWord, s); + } + } + 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; + strcpy(prevWord, ""); + } + /***************************************/ + if (!isspacechar(ch)) visibleChars++; + } + /***************************************/ + // Fill in the real level of the next line, keeping the current flags as they will be filled in later + int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; + styler.SetLevel(lineCurrent, levelPrev | flagsNext); +} +/***************************************/ +static const char * const DMAPWordLists[] = { + "Primary keywords and identifiers", + "Intrinsic functions", + "Extended and user defined functions", + 0, +}; +/***************************************/ +LexerModule lmDMAP(SCLEX_DMAP, ColouriseDMAPDoc, "DMAP", FoldDMAPDoc, DMAPWordLists); diff --git a/Pythonwin/Scintilla/lexers/LexDMIS.cxx b/Pythonwin/Scintilla/lexers/LexDMIS.cxx new file mode 100644 index 000000000..3c8da6081 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexDMIS.cxx @@ -0,0 +1,358 @@ +// Scintilla source code edit control +/** @file LexDMIS.cxx + ** Lexer for DMIS. + **/ +// Copyright 1998-2005 by Neil Hodgson +// Copyright 2013-2014 by Andreas Tscharner +// The License.txt file describes the conditions under which this software may be distributed. + + +#include +#include +#include +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "DefaultLexer.h" + +using namespace Scintilla; + + +static const char *const DMISWordListDesc[] = { + "DMIS Major Words", + "DMIS Minor Words", + "Unsupported DMIS Major Words", + "Unsupported DMIS Minor Words", + "Keywords for code folding start", + "Corresponding keywords for code folding end", + 0 +}; + + +class LexerDMIS : public DefaultLexer +{ + private: + char *m_wordListSets; + WordList m_majorWords; + WordList m_minorWords; + WordList m_unsupportedMajor; + WordList m_unsupportedMinor; + WordList m_codeFoldingStart; + WordList m_codeFoldingEnd; + + char * SCI_METHOD UpperCase(char *item); + void SCI_METHOD InitWordListSets(void); + + public: + LexerDMIS(void); + virtual ~LexerDMIS(void); + + int SCI_METHOD Version() const override { + return lvRelease5; + } + + void SCI_METHOD Release() override { + delete this; + } + + const char * SCI_METHOD PropertyNames() override { + return NULL; + } + + int SCI_METHOD PropertyType(const char *) override { + return -1; + } + + const char * SCI_METHOD DescribeProperty(const char *) override { + return NULL; + } + + Sci_Position SCI_METHOD PropertySet(const char *, const char *) override { + return -1; + } + + const char * SCI_METHOD PropertyGet(const char *) override { + return NULL; + } + + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override; + + void * SCI_METHOD PrivateCall(int, void *) override { + return NULL; + } + + static ILexer5 *LexerFactoryDMIS() { + return new LexerDMIS; + } + + const char * SCI_METHOD DescribeWordListSets() override; + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override; +}; + + +char * SCI_METHOD LexerDMIS::UpperCase(char *item) +{ + char *itemStart; + + + itemStart = item; + while (item && *item) { + *item = toupper(*item); + item++; + }; + return itemStart; +} + +void SCI_METHOD LexerDMIS::InitWordListSets(void) +{ + size_t totalLen = 0; + + + for (int i=0; DMISWordListDesc[i]; i++) { + totalLen += strlen(DMISWordListDesc[i]); + totalLen++; + }; + + totalLen++; + this->m_wordListSets = new char[totalLen]; + memset(this->m_wordListSets, 0, totalLen); + + for (int i=0; DMISWordListDesc[i]; i++) { + strcat(this->m_wordListSets, DMISWordListDesc[i]); + strcat(this->m_wordListSets, "\n"); + }; +} + + +LexerDMIS::LexerDMIS(void) : DefaultLexer("DMIS", SCLEX_DMIS) { + this->InitWordListSets(); + + this->m_majorWords.Clear(); + this->m_minorWords.Clear(); + this->m_unsupportedMajor.Clear(); + this->m_unsupportedMinor.Clear(); + this->m_codeFoldingStart.Clear(); + this->m_codeFoldingEnd.Clear(); +} + +LexerDMIS::~LexerDMIS(void) { + delete[] this->m_wordListSets; +} + +Sci_Position SCI_METHOD LexerDMIS::WordListSet(int n, const char *wl) +{ + switch (n) { + case 0: + this->m_majorWords.Clear(); + this->m_majorWords.Set(wl); + break; + case 1: + this->m_minorWords.Clear(); + this->m_minorWords.Set(wl); + break; + case 2: + this->m_unsupportedMajor.Clear(); + this->m_unsupportedMajor.Set(wl); + break; + case 3: + this->m_unsupportedMinor.Clear(); + this->m_unsupportedMinor.Set(wl); + break; + case 4: + this->m_codeFoldingStart.Clear(); + this->m_codeFoldingStart.Set(wl); + break; + case 5: + this->m_codeFoldingEnd.Clear(); + this->m_codeFoldingEnd.Set(wl); + break; + default: + return -1; + break; + } + + return 0; +} + +const char * SCI_METHOD LexerDMIS::DescribeWordListSets() +{ + return this->m_wordListSets; +} + +void SCI_METHOD LexerDMIS::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) +{ + const Sci_PositionU MAX_STR_LEN = 100; + + LexAccessor styler(pAccess); + StyleContext scCTX(startPos, lengthDoc, initStyle, styler); + CharacterSet setDMISNumber(CharacterSet::setDigits, ".-+eE"); + CharacterSet setDMISWordStart(CharacterSet::setAlpha, "-234", 0x80, true); + CharacterSet setDMISWord(CharacterSet::setAlpha); + + + bool isIFLine = false; + + for (; scCTX.More(); scCTX.Forward()) { + if (scCTX.atLineEnd) { + isIFLine = false; + }; + + switch (scCTX.state) { + case SCE_DMIS_DEFAULT: + if (scCTX.Match('$', '$')) { + scCTX.SetState(SCE_DMIS_COMMENT); + scCTX.Forward(); + }; + if (scCTX.Match('\'')) { + scCTX.SetState(SCE_DMIS_STRING); + }; + if (IsADigit(scCTX.ch) || ((scCTX.Match('-') || scCTX.Match('+')) && IsADigit(scCTX.chNext))) { + scCTX.SetState(SCE_DMIS_NUMBER); + break; + }; + if (setDMISWordStart.Contains(scCTX.ch)) { + scCTX.SetState(SCE_DMIS_KEYWORD); + }; + if (scCTX.Match('(') && (!isIFLine)) { + scCTX.SetState(SCE_DMIS_LABEL); + }; + break; + + case SCE_DMIS_COMMENT: + if (scCTX.atLineEnd) { + scCTX.SetState(SCE_DMIS_DEFAULT); + }; + break; + + case SCE_DMIS_STRING: + if (scCTX.Match('\'')) { + scCTX.SetState(SCE_DMIS_DEFAULT); + }; + break; + + case SCE_DMIS_NUMBER: + if (!setDMISNumber.Contains(scCTX.ch)) { + scCTX.SetState(SCE_DMIS_DEFAULT); + }; + break; + + case SCE_DMIS_KEYWORD: + if (!setDMISWord.Contains(scCTX.ch)) { + char tmpStr[MAX_STR_LEN]; + memset(tmpStr, 0, MAX_STR_LEN*sizeof(char)); + scCTX.GetCurrent(tmpStr, (MAX_STR_LEN-1)); + strncpy(tmpStr, this->UpperCase(tmpStr), (MAX_STR_LEN-1)); + + if (this->m_minorWords.InList(tmpStr)) { + scCTX.ChangeState(SCE_DMIS_MINORWORD); + }; + if (this->m_majorWords.InList(tmpStr)) { + isIFLine = (strcmp(tmpStr, "IF") == 0); + scCTX.ChangeState(SCE_DMIS_MAJORWORD); + }; + if (this->m_unsupportedMajor.InList(tmpStr)) { + scCTX.ChangeState(SCE_DMIS_UNSUPPORTED_MAJOR); + }; + if (this->m_unsupportedMinor.InList(tmpStr)) { + scCTX.ChangeState(SCE_DMIS_UNSUPPORTED_MINOR); + }; + + if (scCTX.Match('(') && (!isIFLine)) { + scCTX.SetState(SCE_DMIS_LABEL); + } else { + scCTX.SetState(SCE_DMIS_DEFAULT); + }; + }; + break; + + case SCE_DMIS_LABEL: + if (scCTX.Match(')')) { + scCTX.SetState(SCE_DMIS_DEFAULT); + }; + break; + }; + }; + scCTX.Complete(); +} + +void SCI_METHOD LexerDMIS::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int, IDocument *pAccess) +{ + const int MAX_STR_LEN = 100; + + LexAccessor styler(pAccess); + Sci_PositionU endPos = startPos + lengthDoc; + char chNext = styler[startPos]; + Sci_Position lineCurrent = styler.GetLine(startPos); + int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; + int levelCurrent = levelPrev; + int strPos = 0; + bool foldWordPossible = false; + CharacterSet setDMISFoldWord(CharacterSet::setAlpha); + char *tmpStr; + + + tmpStr = new char[MAX_STR_LEN]; + memset(tmpStr, 0, MAX_STR_LEN*sizeof(char)); + + for (Sci_PositionU i=startPos; i= (MAX_STR_LEN-1)) { + strPos = MAX_STR_LEN-1; + }; + + int style = styler.StyleAt(i); + bool noFoldPos = ((style == SCE_DMIS_COMMENT) || (style == SCE_DMIS_STRING)); + + if (foldWordPossible) { + if (setDMISFoldWord.Contains(ch)) { + tmpStr[strPos++] = ch; + } else { + tmpStr = this->UpperCase(tmpStr); + if (this->m_codeFoldingStart.InList(tmpStr) && (!noFoldPos)) { + levelCurrent++; + }; + if (this->m_codeFoldingEnd.InList(tmpStr) && (!noFoldPos)) { + levelCurrent--; + }; + memset(tmpStr, 0, MAX_STR_LEN*sizeof(char)); + strPos = 0; + foldWordPossible = false; + }; + } else { + if (setDMISFoldWord.Contains(ch)) { + tmpStr[strPos++] = ch; + foldWordPossible = true; + }; + }; + + if (atEOL || (i == (endPos-1))) { + int lev = levelPrev; + + if (levelCurrent > levelPrev) { + lev |= SC_FOLDLEVELHEADERFLAG; + }; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + }; + lineCurrent++; + levelPrev = levelCurrent; + }; + }; + delete[] tmpStr; +} + + +LexerModule lmDMIS(SCLEX_DMIS, LexerDMIS::LexerFactoryDMIS, "DMIS", DMISWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexDataflex.cxx b/Pythonwin/Scintilla/lexers/LexDataflex.cxx new file mode 100644 index 000000000..42bd39b6b --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexDataflex.cxx @@ -0,0 +1,608 @@ +// Scintilla source code edit control +/** @file LexDataflex.cxx + ** Lexer for DataFlex. + ** Based on LexPascal.cxx + ** Written by Wil van Antwerpen, June 2019 + **/ + +/* +// The License.txt file describes the conditions under which this software may be distributed. + +A few words about features of LexDataflex... + +Generally speaking LexDataflex tries to support all available DataFlex features (up +to DataFlex 19.1 at this time). + +~ FOLDING: + +Folding is supported in the following cases: + +- Folding of stream-like comments +- Folding of groups of consecutive line comments +- Folding of preprocessor blocks (the following preprocessor blocks are +supported: #IFDEF, #IFNDEF, #ENDIF and #HEADER / #ENDHEADER +blocks), +- Folding of code blocks on appropriate keywords (the following code blocks are +supported: "begin, struct, type, case / end" blocks, class & object +declarations and interface declarations) + +Remarks: + +- We pass 4 arrays to the lexer: +1. The DataFlex keyword list, these are normal DataFlex keywords +2. The Scope Open list, for example, begin / procedure / while +3. The Scope Close list, for example, end / end_procedure / loop +4. Operator list, for ex. + / - / * / Lt / iand +These lists are all mutually exclusive, scope open words should not be in the keyword list and vice versa + +- Folding of code blocks tries to handle all special cases in which folding +should not occur. + +~ KEYWORDS: + +The list of keywords that can be used in dataflex.properties file (up to DataFlex +19.1): + +- Keywords: .. snipped .. see dataflex.properties file. + +*/ + +#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" + +using namespace Scintilla; + + +static void GetRangeLowered(Sci_PositionU start, + Sci_PositionU end, + Accessor &styler, + char *s, + Sci_PositionU len) { + Sci_PositionU i = 0; + while ((i < end - start + 1) && (i < len-1)) { + s[i] = static_cast(tolower(styler[start + i])); + i++; + } + s[i] = '\0'; +} + +static void GetForwardRangeLowered(Sci_PositionU start, + CharacterSet &charSet, + Accessor &styler, + char *s, + Sci_PositionU len) { + Sci_PositionU i = 0; + while ((i < len-1) && charSet.Contains(styler.SafeGetCharAt(start + i))) { + s[i] = static_cast(tolower(styler.SafeGetCharAt(start + i))); + i++; + } + s[i] = '\0'; + +} + +enum { + stateInICode = 0x1000, + stateSingleQuoteOpen = 0x2000, + stateDoubleQuoteOpen = 0x4000, + stateFoldInPreprocessor = 0x0100, + stateFoldInCaseStatement = 0x0200, + stateFoldInPreprocessorLevelMask = 0x00FF, + stateFoldMaskAll = 0x0FFF +}; + + +static bool IsFirstDataFlexWord(Sci_Position pos, Accessor &styler) { + Sci_Position line = styler.GetLine(pos); + Sci_Position start_pos = styler.LineStart(line); + for (Sci_Position i = start_pos; i < pos; i++) { + char ch = styler.SafeGetCharAt(i); + if (!(ch == ' ' || ch == '\t')) + return false; + } + return true; +} + + +inline bool IsADataFlexField(int ch) { + return (ch == '.'); +} + + +static void ClassifyDataFlexWord(WordList *keywordlists[], StyleContext &sc, Accessor &styler) { + WordList& keywords = *keywordlists[0]; + WordList& scopeOpen = *keywordlists[1]; + WordList& scopeClosed = *keywordlists[2]; + WordList& operators = *keywordlists[3]; + + char s[100]; + int oldState; + int newState; + size_t tokenlen; + + oldState = sc.state; + newState = oldState; + sc.GetCurrentLowered(s, sizeof(s)); + tokenlen = strnlen(s,sizeof(s)); + if (keywords.InList(s)) { + // keywords in DataFlex can be used as table column names (file.field) and as such they + // should not be characterized as a keyword. So test for that. + // for ex. somebody using date as field name. + if (!IsADataFlexField(sc.GetRelative(-static_cast(tokenlen+1)))) { + newState = SCE_DF_WORD; + } + } + if (oldState == newState) { + if ((scopeOpen.InList(s) || scopeClosed.InList(s)) && (strcmp(s, "for") != 0) && (strcmp(s, "repeat") != 0)) { + // scope words in DataFlex can be used as table column names (file.field) and as such they + // should not be characterized as a scope word. So test for that. + // for ex. somebody using procedure for field name. + if (!IsADataFlexField(sc.GetRelative(-static_cast(tokenlen+1)))) { + newState = SCE_DF_SCOPEWORD; + } + } + // no code folding on the next words, but just want to paint them like keywords (as they are) (??? doesn't the code to the opposite?) + if (strcmp(s, "if") == 0 || + strcmp(s, "ifnot") == 0 || + strcmp(s, "case") == 0 || + strcmp(s, "else") == 0 ) { + newState = SCE_DF_SCOPEWORD; + } + } + if (oldState != newState && newState == SCE_DF_WORD) { + // a for loop must have for at the start of the line, for is also used in "define abc for 123" + if ( (strcmp(s, "for") == 0) && (IsFirstDataFlexWord(sc.currentPos-3, styler)) ) { + newState = SCE_DF_SCOPEWORD; + } + } + if (oldState != newState && newState == SCE_DF_WORD) { + // a repeat loop must have repeat at the start of the line, repeat is also used in 'move (repeat("d",5)) to sFoo' + if ( (strcmp(s, "repeat") == 0) && (IsFirstDataFlexWord(sc.currentPos-6, styler)) ) { + newState = SCE_DF_SCOPEWORD; + } + } + if (oldState == newState) { + if (operators.InList(s)) { + newState = SCE_DF_OPERATOR; + } + } + + if (oldState != newState) { + sc.ChangeState(newState); + } + sc.SetState(SCE_DF_DEFAULT); +} + +static void ColouriseDataFlexDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], + Accessor &styler) { +// bool bSmartHighlighting = styler.GetPropertyInt("lexer.dataflex.smart.highlighting", 1) != 0; + + CharacterSet setWordStart(CharacterSet::setAlpha, "_$#@", 0x80, true); + CharacterSet setWord(CharacterSet::setAlphaNum, "_$#@", 0x80, true); + CharacterSet setNumber(CharacterSet::setDigits, ".-+eE"); + CharacterSet setHexNumber(CharacterSet::setDigits, "abcdefABCDEF"); + CharacterSet setOperator(CharacterSet::setNone, "*+-/<=>^"); + + Sci_Position curLine = styler.GetLine(startPos); + int curLineState = curLine > 0 ? styler.GetLineState(curLine - 1) : 0; + + StyleContext sc(startPos, length, initStyle, styler); + + for (; sc.More(); sc.Forward()) { + if (sc.atLineEnd) { + // Update the line state, so it can be seen by next line + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curLineState); + } + + // Determine if the current state should terminate. + switch (sc.state) { + case SCE_DF_NUMBER: + if (!setNumber.Contains(sc.ch) || (sc.ch == '.' && sc.chNext == '.')) { + sc.SetState(SCE_DF_DEFAULT); + } else if (sc.ch == '-' || sc.ch == '+') { + if (sc.chPrev != 'E' && sc.chPrev != 'e') { + sc.SetState(SCE_DF_DEFAULT); + } + } + break; + case SCE_DF_IDENTIFIER: + if (!setWord.Contains(sc.ch)) { + ClassifyDataFlexWord(keywordlists, sc, styler); + } + break; + case SCE_DF_HEXNUMBER: + if (!(setHexNumber.Contains(sc.ch) || sc.ch == 'I') ) { // in |CI$22a we also want to color the "I" + sc.SetState(SCE_DF_DEFAULT); + } + break; + case SCE_DF_METATAG: + if (sc.atLineStart || sc.chPrev == '}') { + sc.SetState(SCE_DF_DEFAULT); + } + break; + case SCE_DF_PREPROCESSOR: + if (sc.atLineStart || IsASpaceOrTab(sc.ch)) { + sc.SetState(SCE_DF_DEFAULT); + } + break; + case SCE_DF_IMAGE: + if (sc.atLineStart && sc.Match("/*")) { + sc.Forward(); // these characters are still part of the DF Image + sc.ForwardSetState(SCE_DF_DEFAULT); + } + break; + case SCE_DF_PREPROCESSOR2: + // we don't have inline comments or preprocessor2 commands + //if (sc.Match('*', ')')) { + // sc.Forward(); + // sc.ForwardSetState(SCE_DF_DEFAULT); + //} + break; + case SCE_DF_COMMENTLINE: + if (sc.atLineStart) { + sc.SetState(SCE_DF_DEFAULT); + } + break; + case SCE_DF_STRING: + if (sc.atLineEnd) { + sc.ChangeState(SCE_DF_STRINGEOL); + } else if (sc.ch == '\'' && sc.chNext == '\'') { + sc.Forward(); + } else if (sc.ch == '\"' && sc.chNext == '\"') { + sc.Forward(); + } else if (sc.ch == '\'' || sc.ch == '\"') { + if (sc.ch == '\'' && (curLineState & stateSingleQuoteOpen) ) { + curLineState &= ~(stateSingleQuoteOpen); + sc.ForwardSetState(SCE_DF_DEFAULT); + } + else if (sc.ch == '\"' && (curLineState & stateDoubleQuoteOpen) ) { + curLineState &= ~(stateDoubleQuoteOpen); + sc.ForwardSetState(SCE_DF_DEFAULT); + } + } + break; + case SCE_DF_STRINGEOL: + if (sc.atLineStart) { + sc.SetState(SCE_DF_DEFAULT); + } + break; + case SCE_DF_SCOPEWORD: + //if (!setHexNumber.Contains(sc.ch) && sc.ch != '$') { + // sc.SetState(SCE_DF_DEFAULT); + //} + break; + case SCE_DF_OPERATOR: +// if (bSmartHighlighting && sc.chPrev == ';') { +// curLineState &= ~(stateInProperty | stateInExport); +// } + sc.SetState(SCE_DF_DEFAULT); + break; + case SCE_DF_ICODE: + if (sc.atLineStart || IsASpace(sc.ch) || isoperator(sc.ch)) { + sc.SetState(SCE_DF_DEFAULT); + } + break; + } + + // Determine if a new state should be entered. + if (sc.state == SCE_DF_DEFAULT) { + if (IsADigit(sc.ch)) { + sc.SetState(SCE_DF_NUMBER); + } else if (sc.Match('/', '/') || sc.Match("#REM")) { + sc.SetState(SCE_DF_COMMENTLINE); + } else if ((sc.ch == '#' && !sc.Match("#REM")) && IsFirstDataFlexWord(sc.currentPos, styler)) { + sc.SetState(SCE_DF_PREPROCESSOR); + // || (sc.ch == '|' && sc.chNext == 'C' && sc.GetRelativeCharacter(2) == 'I' && sc.GetRelativeCharacter(3) == '$') ) { + } else if ((sc.ch == '$' && ((!setWord.Contains(sc.chPrev)) || sc.chPrev == 'I' ) ) || (sc.Match("|CI$")) ) { + sc.SetState(SCE_DF_HEXNUMBER); // start with $ and previous character not in a..zA..Z0..9 excluding "I" OR start with |CI$ + } else if (setWordStart.Contains(sc.ch)) { + sc.SetState(SCE_DF_IDENTIFIER); + } else if (sc.ch == '{') { + sc.SetState(SCE_DF_METATAG); + //} else if (sc.Match("(*$")) { + // sc.SetState(SCE_DF_PREPROCESSOR2); + } else if (sc.ch == '/' && setWord.Contains(sc.chNext) && sc.atLineStart) { + sc.SetState(SCE_DF_IMAGE); + // sc.Forward(); // Eat the * so it isn't used for the end of the comment + } else if (sc.ch == '\'' || sc.ch == '\"') { + if (sc.ch == '\'' && !(curLineState & stateDoubleQuoteOpen)) { + curLineState |= stateSingleQuoteOpen; + } else if (sc.ch == '\"' && !(curLineState & stateSingleQuoteOpen)) { + curLineState |= stateDoubleQuoteOpen; + } + sc.SetState(SCE_DF_STRING); + } else if (setOperator.Contains(sc.ch)) { + sc.SetState(SCE_DF_OPERATOR); +// } else if (curLineState & stateInICode) { + // ICode start ! in a string followed by close string mark is not icode + } else if ((sc.ch == '!') && !(sc.ch == '!' && ((sc.chNext == '\"') || (sc.ch == '\'')) )) { + sc.SetState(SCE_DF_ICODE); + } + } + } + + if (sc.state == SCE_DF_IDENTIFIER && setWord.Contains(sc.chPrev)) { + ClassifyDataFlexWord(keywordlists, sc, styler); + } + + sc.Complete(); +} + +static bool IsStreamCommentStyle(int style) { + return style == SCE_DF_IMAGE; +} + +static bool IsCommentLine(Sci_Position line, Accessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eolPos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eolPos; i++) { + char ch = styler[i]; + char chNext = styler.SafeGetCharAt(i + 1); + int style = styler.StyleAt(i); + if (ch == '/' && chNext == '/' && style == SCE_DF_COMMENTLINE) { + return true; + } else if (!IsASpaceOrTab(ch)) { + return false; + } + } + return false; +} + + + +static unsigned int GetFoldInPreprocessorLevelFlag(int lineFoldStateCurrent) { + return lineFoldStateCurrent & stateFoldInPreprocessorLevelMask; +} + +static void SetFoldInPreprocessorLevelFlag(int &lineFoldStateCurrent, unsigned int nestLevel) { + lineFoldStateCurrent &= ~stateFoldInPreprocessorLevelMask; + lineFoldStateCurrent |= nestLevel & stateFoldInPreprocessorLevelMask; +} + +static int ClassifyDataFlexPreprocessorFoldPoint(int &levelCurrent, int &lineFoldStateCurrent, + Sci_PositionU startPos, Accessor &styler) { + CharacterSet setWord(CharacterSet::setAlpha); + + char s[100]; // Size of the longest possible keyword + one additional character + null + GetForwardRangeLowered(startPos, setWord, styler, s, sizeof(s)); + size_t iLen = strnlen(s,sizeof(s)); + size_t iWordSize = 0; + + unsigned int nestLevel = GetFoldInPreprocessorLevelFlag(lineFoldStateCurrent); + + if (strcmp(s, "command") == 0 || + // The #if/#ifdef etcetera commands are not currently foldable as it is easy to write code that + // breaks the collaps logic, so we keep things simple and not include that for now. + strcmp(s, "header") == 0) { + nestLevel++; + SetFoldInPreprocessorLevelFlag(lineFoldStateCurrent, nestLevel); + lineFoldStateCurrent |= stateFoldInPreprocessor; + levelCurrent++; + iWordSize = iLen; + } else if (strcmp(s, "endcommand") == 0 || + strcmp(s, "endheader") == 0) { + nestLevel--; + SetFoldInPreprocessorLevelFlag(lineFoldStateCurrent, nestLevel); + if (nestLevel == 0) { + lineFoldStateCurrent &= ~stateFoldInPreprocessor; + } + levelCurrent--; + iWordSize = iLen; + if (levelCurrent < SC_FOLDLEVELBASE) { + levelCurrent = SC_FOLDLEVELBASE; + } + } + return static_cast(iWordSize); +} + + +static void ClassifyDataFlexWordFoldPoint(int &levelCurrent, int &lineFoldStateCurrent, + Sci_PositionU lastStart, Sci_PositionU currentPos, WordList *[], Accessor &styler) { + char s[100]; + + // property fold.dataflex.compilerlist + // Set to 1 for enabling the code folding feature in *.prn files + bool foldPRN = styler.GetPropertyInt("fold.dataflex.compilerlist",0) != 0; + + GetRangeLowered(lastStart, currentPos, styler, s, sizeof(s)); + + if (strcmp(s, "case") == 0) { + lineFoldStateCurrent |= stateFoldInCaseStatement; + } else if (strcmp(s, "begin") == 0) { + levelCurrent++; + } else if (strcmp(s, "for") == 0 || + strcmp(s, "while") == 0 || + strcmp(s, "repeat") == 0 || + strcmp(s, "for_all") == 0 || + strcmp(s, "struct") == 0 || + strcmp(s, "type") == 0 || + strcmp(s, "begin_row") == 0 || + strcmp(s, "item_list") == 0 || + strcmp(s, "begin_constraints") == 0 || + strcmp(s, "begin_transaction") == 0 || + strcmp(s, "enum_list") == 0 || + strcmp(s, "class") == 0 || + strcmp(s, "object") == 0 || + strcmp(s, "cd_popup_object") == 0 || + strcmp(s, "procedure") == 0 || + strcmp(s, "procedure_section") == 0 || + strcmp(s, "function") == 0 ) { + if ((IsFirstDataFlexWord(lastStart, styler )) || foldPRN) { + levelCurrent++; + } + } else if (strcmp(s, "end") == 0) { // end is not always the first keyword, for example "case end" + levelCurrent--; + if (levelCurrent < SC_FOLDLEVELBASE) { + levelCurrent = SC_FOLDLEVELBASE; + } + } else if (strcmp(s, "loop") == 0 || + strcmp(s, "until") == 0 || + strcmp(s, "end_class") == 0 || + strcmp(s, "end_object") == 0 || + strcmp(s, "cd_end_object") == 0 || + strcmp(s, "end_procedure") == 0 || + strcmp(s, "end_function") == 0 || + strcmp(s, "end_for_all") == 0 || + strcmp(s, "end_struct") == 0 || + strcmp(s, "end_type") == 0 || + strcmp(s, "end_row") == 0 || + strcmp(s, "end_item_list") == 0 || + strcmp(s, "end_constraints") == 0 || + strcmp(s, "end_transaction") == 0 || + strcmp(s, "end_enum_list") == 0 ) { + // lineFoldStateCurrent &= ~stateFoldInRecord; + if ((IsFirstDataFlexWord(lastStart, styler )) || foldPRN) { + levelCurrent--; + if (levelCurrent < SC_FOLDLEVELBASE) { + levelCurrent = SC_FOLDLEVELBASE; + } + } + } + +} + + +static void ClassifyDataFlexMetaDataFoldPoint(int &levelCurrent, + Sci_PositionU lastStart, Sci_PositionU currentPos, WordList *[], Accessor &styler) { + char s[100]; + + GetRangeLowered(lastStart, currentPos, styler, s, sizeof(s)); + + if (strcmp(s, "#beginsection") == 0) { + levelCurrent++; + } else if (strcmp(s, "#endsection") == 0) { + levelCurrent--; + if (levelCurrent < SC_FOLDLEVELBASE) { + levelCurrent = SC_FOLDLEVELBASE; + } + } + +} + +static void FoldDataFlexDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], + Accessor &styler) { + bool foldComment = styler.GetPropertyInt("fold.comment") != 0; + bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 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; + int lineFoldStateCurrent = lineCurrent > 0 ? styler.GetLineState(lineCurrent - 1) & stateFoldMaskAll : 0; + char chNext = styler[startPos]; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + int iWordSize; + + Sci_Position lastStart = 0; + CharacterSet setWord(CharacterSet::setAlphaNum, "_$#@", 0x80, true); + + 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 && IsStreamCommentStyle(style)) { + if (!IsStreamCommentStyle(stylePrev)) { + levelCurrent++; + } else if (!IsStreamCommentStyle(styleNext)) { + levelCurrent--; + } + } + if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) + { + if (!IsCommentLine(lineCurrent - 1, styler) + && IsCommentLine(lineCurrent + 1, styler)) + levelCurrent++; + else if (IsCommentLine(lineCurrent - 1, styler) + && !IsCommentLine(lineCurrent+1, styler)) + levelCurrent--; + } + if (foldPreprocessor) { + if (style == SCE_DF_PREPROCESSOR) { + iWordSize = ClassifyDataFlexPreprocessorFoldPoint(levelCurrent, lineFoldStateCurrent, i + 1, styler); + //} else if (style == SCE_DF_PREPROCESSOR2 && ch == '(' && chNext == '*' + // && styler.SafeGetCharAt(i + 2) == '$') { + // ClassifyDataFlexPreprocessorFoldPoint(levelCurrent, lineFoldStateCurrent, i + 3, styler); + i = i + iWordSize; + } + } + + if (stylePrev != SCE_DF_SCOPEWORD && style == SCE_DF_SCOPEWORD) + { + // Store last word start point. + lastStart = i; + } + if (stylePrev == SCE_DF_SCOPEWORD) { + if(setWord.Contains(ch) && !setWord.Contains(chNext)) { + ClassifyDataFlexWordFoldPoint(levelCurrent, lineFoldStateCurrent, lastStart, i, keywordlists, styler); + } + } + + if (stylePrev == SCE_DF_METATAG && ch == '#') + { + // Store last word start point. + lastStart = i; + } + if (stylePrev == SCE_DF_METATAG) { + if(setWord.Contains(ch) && !setWord.Contains(chNext)) { + ClassifyDataFlexMetaDataFoldPoint(levelCurrent, lastStart, i, keywordlists, styler); + } + } + + if (!IsASpace(ch)) + visibleChars++; + + 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); + } + int newLineState = (styler.GetLineState(lineCurrent) & ~stateFoldMaskAll) | lineFoldStateCurrent; + styler.SetLineState(lineCurrent, newLineState); + lineCurrent++; + levelPrev = levelCurrent; + visibleChars = 0; + } + } + + // If we didn't reach the EOL in previous loop, store line level and whitespace information. + // The rest will be filled in later... + int lev = levelPrev; + if (visibleChars == 0 && foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + styler.SetLevel(lineCurrent, lev); +} + +static const char * const dataflexWordListDesc[] = { + "Keywords", + "Scope open", + "Scope close", + "Operators", + 0 +}; + +LexerModule lmDataflex(SCLEX_DATAFLEX, ColouriseDataFlexDoc, "dataflex", FoldDataFlexDoc, dataflexWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexDiff.cxx b/Pythonwin/Scintilla/lexers/LexDiff.cxx new file mode 100644 index 000000000..dd008c5cb --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexDiff.cxx @@ -0,0 +1,161 @@ +// Scintilla source code edit control +/** @file LexDiff.cxx + ** Lexer for diff results. + **/ +// 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 "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" + +using namespace Scintilla; + +static inline bool AtEOL(Accessor &styler, Sci_PositionU i) { + return (styler[i] == '\n') || + ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')); +} + +#define DIFF_BUFFER_START_SIZE 16 +// Note that ColouriseDiffLine analyzes only the first DIFF_BUFFER_START_SIZE +// characters of each line to classify the line. + +static void ColouriseDiffLine(char *lineBuffer, Sci_Position endLine, Accessor &styler) { + // It is needed to remember the current state to recognize starting + // comment lines before the first "diff " or "--- ". If a real + // difference starts then each line starting with ' ' is a whitespace + // otherwise it is considered a comment (Only in..., Binary file...) + if (0 == strncmp(lineBuffer, "diff ", 5)) { + styler.ColourTo(endLine, SCE_DIFF_COMMAND); + } else if (0 == strncmp(lineBuffer, "Index: ", 7)) { // For subversion's diff + styler.ColourTo(endLine, SCE_DIFF_COMMAND); + } else if (0 == strncmp(lineBuffer, "---", 3) && lineBuffer[3] != '-') { + // In a context diff, --- appears in both the header and the position markers + if (lineBuffer[3] == ' ' && atoi(lineBuffer + 4) && !strchr(lineBuffer, '/')) + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else if (lineBuffer[3] == '\r' || lineBuffer[3] == '\n') + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else if (lineBuffer[3] == ' ') + styler.ColourTo(endLine, SCE_DIFF_HEADER); + else + styler.ColourTo(endLine, SCE_DIFF_DELETED); + } else if (0 == strncmp(lineBuffer, "+++ ", 4)) { + // I don't know of any diff where "+++ " is a position marker, but for + // consistency, do the same as with "--- " and "*** ". + if (atoi(lineBuffer+4) && !strchr(lineBuffer, '/')) + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else + styler.ColourTo(endLine, SCE_DIFF_HEADER); + } else if (0 == strncmp(lineBuffer, "====", 4)) { // For p4's diff + styler.ColourTo(endLine, SCE_DIFF_HEADER); + } else if (0 == strncmp(lineBuffer, "***", 3)) { + // In a context diff, *** appears in both the header and the position markers. + // Also ******** is a chunk header, but here it's treated as part of the + // position marker since there is no separate style for a chunk header. + if (lineBuffer[3] == ' ' && atoi(lineBuffer+4) && !strchr(lineBuffer, '/')) + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else if (lineBuffer[3] == '*') + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else + styler.ColourTo(endLine, SCE_DIFF_HEADER); + } else if (0 == strncmp(lineBuffer, "? ", 2)) { // For difflib + styler.ColourTo(endLine, SCE_DIFF_HEADER); + } else if (lineBuffer[0] == '@') { + styler.ColourTo(endLine, SCE_DIFF_POSITION); + } else if (lineBuffer[0] >= '0' && lineBuffer[0] <= '9') { + styler.ColourTo(endLine, SCE_DIFF_POSITION); + } else if (0 == strncmp(lineBuffer, "++", 2)) { + styler.ColourTo(endLine, SCE_DIFF_PATCH_ADD); + } else if (0 == strncmp(lineBuffer, "+-", 2)) { + styler.ColourTo(endLine, SCE_DIFF_PATCH_DELETE); + } else if (0 == strncmp(lineBuffer, "-+", 2)) { + styler.ColourTo(endLine, SCE_DIFF_REMOVED_PATCH_ADD); + } else if (0 == strncmp(lineBuffer, "--", 2)) { + styler.ColourTo(endLine, SCE_DIFF_REMOVED_PATCH_DELETE); + } else if (lineBuffer[0] == '-' || lineBuffer[0] == '<') { + styler.ColourTo(endLine, SCE_DIFF_DELETED); + } else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') { + styler.ColourTo(endLine, SCE_DIFF_ADDED); + } else if (lineBuffer[0] == '!') { + styler.ColourTo(endLine, SCE_DIFF_CHANGED); + } else if (lineBuffer[0] != ' ') { + styler.ColourTo(endLine, SCE_DIFF_COMMENT); + } else { + styler.ColourTo(endLine, SCE_DIFF_DEFAULT); + } +} + +static void ColouriseDiffDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { + char lineBuffer[DIFF_BUFFER_START_SIZE] = ""; + styler.StartAt(startPos); + styler.StartSegment(startPos); + Sci_PositionU linePos = 0; + for (Sci_PositionU i = startPos; i < startPos + length; i++) { + if (AtEOL(styler, i)) { + if (linePos < DIFF_BUFFER_START_SIZE) { + lineBuffer[linePos] = 0; + } + ColouriseDiffLine(lineBuffer, i, styler); + linePos = 0; + } else if (linePos < DIFF_BUFFER_START_SIZE - 1) { + lineBuffer[linePos++] = styler[i]; + } else if (linePos == DIFF_BUFFER_START_SIZE - 1) { + lineBuffer[linePos++] = 0; + } + } + if (linePos > 0) { // Last line does not have ending characters + if (linePos < DIFF_BUFFER_START_SIZE) { + lineBuffer[linePos] = 0; + } + ColouriseDiffLine(lineBuffer, startPos + length - 1, styler); + } +} + +static void FoldDiffDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { + Sci_Position curLine = styler.GetLine(startPos); + Sci_Position curLineStart = styler.LineStart(curLine); + int prevLevel = curLine > 0 ? styler.LevelAt(curLine - 1) : SC_FOLDLEVELBASE; + int nextLevel; + + do { + const int lineType = styler.StyleAt(curLineStart); + if (lineType == SCE_DIFF_COMMAND) + nextLevel = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + else if (lineType == SCE_DIFF_HEADER) + nextLevel = (SC_FOLDLEVELBASE + 1) | SC_FOLDLEVELHEADERFLAG; + else if (lineType == SCE_DIFF_POSITION && styler[curLineStart] != '-') + nextLevel = (SC_FOLDLEVELBASE + 2) | SC_FOLDLEVELHEADERFLAG; + else if (prevLevel & SC_FOLDLEVELHEADERFLAG) + nextLevel = (prevLevel & SC_FOLDLEVELNUMBERMASK) + 1; + else + nextLevel = prevLevel; + + if ((nextLevel & SC_FOLDLEVELHEADERFLAG) && (nextLevel == prevLevel)) + styler.SetLevel(curLine-1, prevLevel & ~SC_FOLDLEVELHEADERFLAG); + + styler.SetLevel(curLine, nextLevel); + prevLevel = nextLevel; + + curLineStart = styler.LineStart(++curLine); + } while (static_cast(startPos)+length > curLineStart); +} + +static const char *const emptyWordListDesc[] = { + 0 +}; + +LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", FoldDiffDoc, emptyWordListDesc); diff --git a/Pythonwin/Scintilla/src/LexCPP.cxx b/Pythonwin/Scintilla/lexers/LexECL.cxx similarity index 50% rename from Pythonwin/Scintilla/src/LexCPP.cxx rename to Pythonwin/Scintilla/lexers/LexECL.cxx index c2933f41d..6c916bce4 100644 --- a/Pythonwin/Scintilla/src/LexCPP.cxx +++ b/Pythonwin/Scintilla/lexers/LexECL.cxx @@ -1,86 +1,94 @@ // Scintilla source code edit control -/** @file LexCPP.cxx - ** Lexer for C++, C, Java, and JavaScript. +/** @file LexECL.cxx + ** Lexer for ECL. **/ -// Copyright 1998-2005 by Neil Hodgson +// 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 "Platform.h" +#ifdef _MSC_VER +#pragma warning(disable: 4786) +#endif +#ifdef __BORLANDC__ +// Borland C++ displays warnings in vector header without this +#pragma option -w-ccc -w-rch +#endif -#include "PropSet.h" -#include "Accessor.h" -#include "StyleContext.h" -#include "KeyWords.h" +#include +#include +#include +#include + +#include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h" + +#include "PropSetSimple.h" +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" #include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" + +#define SET_LOWER "abcdefghijklmnopqrstuvwxyz" +#define SET_UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +#define SET_DIGITS "0123456789" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif static bool IsSpaceEquiv(int state) { - return (state <= SCE_C_COMMENTDOC) || - // including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE - (state == SCE_C_COMMENTLINEDOC) || (state == SCE_C_COMMENTDOCKEYWORD) || - (state == SCE_C_COMMENTDOCKEYWORDERROR); -} + switch (state) { + case SCE_ECL_DEFAULT: + case SCE_ECL_COMMENT: + case SCE_ECL_COMMENTLINE: + case SCE_ECL_COMMENTLINEDOC: + case SCE_ECL_COMMENTDOCKEYWORD: + case SCE_ECL_COMMENTDOCKEYWORDERROR: + case SCE_ECL_COMMENTDOC: + return true; -// Preconditions: sc.currentPos points to a character after '+' or '-'. -// The test for pos reaching 0 should be redundant, -// and is in only for safety measures. -// Limitation: this code will give the incorrect answer for code like -// a = b+++/ptn/... -// Putting a space between the '++' post-inc operator and the '+' binary op -// fixes this, and is highly recommended for readability anyway. -static bool FollowsPostfixOperator(StyleContext &sc, Accessor &styler) { - int pos = (int) sc.currentPos; - while (--pos > 0) { - char ch = styler[pos]; - if (ch == '+' || ch == '-') { - return styler[pos - 1] == ch; - } + default: + return false; } - return false; } -static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler, bool caseSensitive) { - - WordList &keywords = *keywordlists[0]; - WordList &keywords2 = *keywordlists[1]; - WordList &keywords3 = *keywordlists[2]; - WordList &keywords4 = *keywordlists[3]; +static void ColouriseEclDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], + Accessor &styler) { + WordList &keywords0 = *keywordlists[0]; + WordList &keywords1 = *keywordlists[1]; + WordList &keywords2 = *keywordlists[2]; + WordList &keywords3 = *keywordlists[3]; //Value Types + WordList &keywords4 = *keywordlists[4]; + WordList &keywords5 = *keywordlists[5]; + WordList &keywords6 = *keywordlists[6]; //Javadoc Tags + WordList cplusplus; + cplusplus.Set("beginc endc"); - bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0; - - CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-"); - CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-"); - - CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]"); + bool stylingWithinPreprocessor = false; + CharacterSet setOKBeforeRE(CharacterSet::setNone, "(=,"); + CharacterSet setDoxygen(CharacterSet::setLower, "$@\\&<>#{}[]"); CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true); - if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) { - setWordStart.Add('$'); - setWord.Add('$'); - } + CharacterSet setQualified(CharacterSet::setNone, "uUxX"); int chPrevNonWhite = ' '; int visibleChars = 0; bool lastWordWasUUID = false; - int styleBeforeDCKeyword = SCE_C_DEFAULT; + int styleBeforeDCKeyword = SCE_ECL_DEFAULT; bool continuationLine = false; - if (initStyle == SCE_C_PREPROCESSOR) { + if (initStyle == SCE_ECL_PREPROCESSOR) { // Set continuationLine if last character of previous line is '\' - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); if (lineCurrent > 0) { int chBack = styler.SafeGetCharAt(startPos-1, 0); int chBack2 = styler.SafeGetCharAt(startPos-2, 0); @@ -96,10 +104,10 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo // look back to set chPrevNonWhite properly for better regex colouring if (startPos > 0) { - int back = startPos; + Sci_Position back = startPos; while (--back && IsSpaceEquiv(styler.StyleAt(back))) ; - if (styler.StyleAt(back) == SCE_C_OPERATOR) { + if (styler.StyleAt(back) == SCE_ECL_OPERATOR) { chPrevNonWhite = styler.SafeGetCharAt(back); } } @@ -107,12 +115,11 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo StyleContext sc(startPos, length, initStyle, styler); for (; sc.More(); sc.Forward()) { - if (sc.atLineStart) { - if (sc.state == SCE_C_STRING) { - // Prevent SCE_C_STRINGEOL from leaking back to previous line which + if (sc.state == SCE_ECL_STRING) { + // Prevent SCE_ECL_STRINGEOL from leaking back to previous line which // ends with a line continuation by locking in the state upto this position. - sc.SetState(SCE_C_STRING); + sc.SetState(SCE_ECL_STRING); } // Reset states to begining of colourise so no surprises // if different sets of lines lexed. @@ -134,129 +141,145 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo // Determine if the current state should terminate. switch (sc.state) { - case SCE_C_OPERATOR: - sc.SetState(SCE_C_DEFAULT); + case SCE_ECL_ADDED: + case SCE_ECL_DELETED: + case SCE_ECL_CHANGED: + case SCE_ECL_MOVED: + if (sc.atLineStart) + sc.SetState(SCE_ECL_DEFAULT); + break; + case SCE_ECL_OPERATOR: + sc.SetState(SCE_ECL_DEFAULT); break; - case SCE_C_NUMBER: + case SCE_ECL_NUMBER: // We accept almost anything because of hex. and number suffixes if (!setWord.Contains(sc.ch)) { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } break; - case SCE_C_IDENTIFIER: + case SCE_ECL_IDENTIFIER: if (!setWord.Contains(sc.ch) || (sc.ch == '.')) { char s[1000]; - if (caseSensitive) { - sc.GetCurrent(s, sizeof(s)); - } else { - sc.GetCurrentLowered(s, sizeof(s)); - } - if (keywords.InList(s)) { + sc.GetCurrentLowered(s, sizeof(s)); + if (keywords0.InList(s)) { lastWordWasUUID = strcmp(s, "uuid") == 0; - sc.ChangeState(SCE_C_WORD); + sc.ChangeState(SCE_ECL_WORD0); + } else if (keywords1.InList(s)) { + sc.ChangeState(SCE_ECL_WORD1); } else if (keywords2.InList(s)) { - sc.ChangeState(SCE_C_WORD2); + sc.ChangeState(SCE_ECL_WORD2); } else if (keywords4.InList(s)) { - sc.ChangeState(SCE_C_GLOBALCLASS); + sc.ChangeState(SCE_ECL_WORD4); + } else if (keywords5.InList(s)) { + sc.ChangeState(SCE_ECL_WORD5); + } + else //Data types are of from KEYWORD## + { + int i = static_cast(strlen(s)) - 1; + while(i >= 0 && (isdigit(s[i]) || s[i] == '_')) + --i; + + char s2[1000]; + strncpy(s2, s, i + 1); + s2[i + 1] = 0; + if (keywords3.InList(s2)) { + sc.ChangeState(SCE_ECL_WORD3); + } } - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } break; - case SCE_C_PREPROCESSOR: + case SCE_ECL_PREPROCESSOR: if (sc.atLineStart && !continuationLine) { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } else if (stylingWithinPreprocessor) { if (IsASpace(sc.ch)) { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } } else { if (sc.Match('/', '*') || sc.Match('/', '/')) { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } } break; - case SCE_C_COMMENT: + case SCE_ECL_COMMENT: if (sc.Match('*', '/')) { sc.Forward(); - sc.ForwardSetState(SCE_C_DEFAULT); + sc.ForwardSetState(SCE_ECL_DEFAULT); } break; - case SCE_C_COMMENTDOC: + case SCE_ECL_COMMENTDOC: if (sc.Match('*', '/')) { sc.Forward(); - sc.ForwardSetState(SCE_C_DEFAULT); + sc.ForwardSetState(SCE_ECL_DEFAULT); } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support // Verify that we have the conditions to mark a comment-doc-keyword if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { - styleBeforeDCKeyword = SCE_C_COMMENTDOC; - sc.SetState(SCE_C_COMMENTDOCKEYWORD); + styleBeforeDCKeyword = SCE_ECL_COMMENTDOC; + sc.SetState(SCE_ECL_COMMENTDOCKEYWORD); } } break; - case SCE_C_COMMENTLINE: + case SCE_ECL_COMMENTLINE: if (sc.atLineStart) { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } break; - case SCE_C_COMMENTLINEDOC: + case SCE_ECL_COMMENTLINEDOC: if (sc.atLineStart) { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support // Verify that we have the conditions to mark a comment-doc-keyword if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { - styleBeforeDCKeyword = SCE_C_COMMENTLINEDOC; - sc.SetState(SCE_C_COMMENTDOCKEYWORD); + styleBeforeDCKeyword = SCE_ECL_COMMENTLINEDOC; + sc.SetState(SCE_ECL_COMMENTDOCKEYWORD); } } break; - case SCE_C_COMMENTDOCKEYWORD: - if ((styleBeforeDCKeyword == SCE_C_COMMENTDOC) && sc.Match('*', '/')) { - sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR); + case SCE_ECL_COMMENTDOCKEYWORD: + if ((styleBeforeDCKeyword == SCE_ECL_COMMENTDOC) && sc.Match('*', '/')) { + sc.ChangeState(SCE_ECL_COMMENTDOCKEYWORDERROR); sc.Forward(); - sc.ForwardSetState(SCE_C_DEFAULT); + sc.ForwardSetState(SCE_ECL_DEFAULT); } else if (!setDoxygen.Contains(sc.ch)) { - char s[100]; - if (caseSensitive) { - sc.GetCurrent(s, sizeof(s)); - } else { - sc.GetCurrentLowered(s, sizeof(s)); - } - if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) { - sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR); + char s[1000]; + sc.GetCurrentLowered(s, sizeof(s)); + if (!IsASpace(sc.ch) || !keywords6.InList(s+1)) { + sc.ChangeState(SCE_ECL_COMMENTDOCKEYWORDERROR); } sc.SetState(styleBeforeDCKeyword); } break; - case SCE_C_STRING: + case SCE_ECL_STRING: if (sc.atLineEnd) { - sc.ChangeState(SCE_C_STRINGEOL); + sc.ChangeState(SCE_ECL_STRINGEOL); } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\"') { - sc.ForwardSetState(SCE_C_DEFAULT); + sc.ForwardSetState(SCE_ECL_DEFAULT); } break; - case SCE_C_CHARACTER: + case SCE_ECL_CHARACTER: if (sc.atLineEnd) { - sc.ChangeState(SCE_C_STRINGEOL); + sc.ChangeState(SCE_ECL_STRINGEOL); } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); } } else if (sc.ch == '\'') { - sc.ForwardSetState(SCE_C_DEFAULT); + sc.ForwardSetState(SCE_ECL_DEFAULT); } break; - case SCE_C_REGEX: + case SCE_ECL_REGEX: if (sc.atLineStart) { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } else if (sc.ch == '/') { sc.Forward(); while ((sc.ch < 0x80) && islower(sc.ch)) sc.Forward(); // gobble regex flags - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } else if (sc.ch == '\\') { // Gobble up the quoted character if (sc.chNext == '\\' || sc.chNext == '/') { @@ -264,77 +287,85 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo } } break; - case SCE_C_STRINGEOL: + case SCE_ECL_STRINGEOL: if (sc.atLineStart) { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } break; - case SCE_C_VERBATIM: + case SCE_ECL_VERBATIM: if (sc.ch == '\"') { if (sc.chNext == '\"') { sc.Forward(); } else { - sc.ForwardSetState(SCE_C_DEFAULT); + sc.ForwardSetState(SCE_ECL_DEFAULT); } } break; - case SCE_C_UUID: + case SCE_ECL_UUID: if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } + break; } // Determine if a new state should be entered. - if (sc.state == SCE_C_DEFAULT) { - if (sc.Match('@', '\"')) { - sc.SetState(SCE_C_VERBATIM); + Sci_Position lineCurrent = styler.GetLine(sc.currentPos); + int lineState = styler.GetLineState(lineCurrent); + if (sc.state == SCE_ECL_DEFAULT) { + if (lineState) { + sc.SetState(lineState); + } + else if (sc.Match('@', '\"')) { + sc.SetState(SCE_ECL_VERBATIM); + sc.Forward(); + } else if (setQualified.Contains(sc.ch) && sc.chNext == '\'') { + sc.SetState(SCE_ECL_CHARACTER); sc.Forward(); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { if (lastWordWasUUID) { - sc.SetState(SCE_C_UUID); + sc.SetState(SCE_ECL_UUID); lastWordWasUUID = false; } else { - sc.SetState(SCE_C_NUMBER); + sc.SetState(SCE_ECL_NUMBER); } } else if (setWordStart.Contains(sc.ch) || (sc.ch == '@')) { if (lastWordWasUUID) { - sc.SetState(SCE_C_UUID); + sc.SetState(SCE_ECL_UUID); lastWordWasUUID = false; } else { - sc.SetState(SCE_C_IDENTIFIER); + sc.SetState(SCE_ECL_IDENTIFIER); } } else if (sc.Match('/', '*')) { if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style - sc.SetState(SCE_C_COMMENTDOC); + sc.SetState(SCE_ECL_COMMENTDOC); } else { - sc.SetState(SCE_C_COMMENT); + sc.SetState(SCE_ECL_COMMENT); } sc.Forward(); // Eat the * so it isn't used for the end of the comment } else if (sc.Match('/', '/')) { if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!")) // Support of Qt/Doxygen doc. style - sc.SetState(SCE_C_COMMENTLINEDOC); + sc.SetState(SCE_ECL_COMMENTLINEDOC); else - sc.SetState(SCE_C_COMMENTLINE); - } else if (sc.ch == '/' && setOKBeforeRE.Contains(chPrevNonWhite) && - (!setCouldBePostOp.Contains(chPrevNonWhite) || !FollowsPostfixOperator(sc, styler))) { - sc.SetState(SCE_C_REGEX); // JavaScript's RegEx - } else if (sc.ch == '\"') { - sc.SetState(SCE_C_STRING); + sc.SetState(SCE_ECL_COMMENTLINE); + } else if (sc.ch == '/' && setOKBeforeRE.Contains(chPrevNonWhite)) { + sc.SetState(SCE_ECL_REGEX); // JavaScript's RegEx +// } else if (sc.ch == '\"') { +// sc.SetState(SCE_ECL_STRING); } else if (sc.ch == '\'') { - sc.SetState(SCE_C_CHARACTER); + sc.SetState(SCE_ECL_CHARACTER); } else if (sc.ch == '#' && visibleChars == 0) { // Preprocessor commands are alone on their line - sc.SetState(SCE_C_PREPROCESSOR); + sc.SetState(SCE_ECL_PREPROCESSOR); // Skip whitespace between # and preprocessor word do { sc.Forward(); } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More()); if (sc.atLineEnd) { - sc.SetState(SCE_C_DEFAULT); + sc.SetState(SCE_ECL_DEFAULT); } } else if (isoperator(static_cast(sc.ch))) { - sc.SetState(SCE_C_OPERATOR); + sc.SetState(SCE_ECL_OPERATOR); } } @@ -345,27 +376,42 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo continuationLine = false; } sc.Complete(); + } static bool IsStreamCommentStyle(int style) { - return style == SCE_C_COMMENT || - style == SCE_C_COMMENTDOC || - style == SCE_C_COMMENTDOCKEYWORD || - style == SCE_C_COMMENTDOCKEYWORDERROR; + return style == SCE_ECL_COMMENT || + style == SCE_ECL_COMMENTDOC || + style == SCE_ECL_COMMENTDOCKEYWORD || + style == SCE_ECL_COMMENTDOCKEYWORDERROR; +} + +static bool MatchNoCase(Accessor & styler, Sci_PositionU & pos, const char *s) { + Sci_Position i=0; + for (; *s; i++) { + char compare_char = tolower(*s); + char styler_char = tolower(styler.SafeGetCharAt(pos+i)); + if (compare_char != styler_char) + return false; + s++; + } + pos+=i-1; + return true; } + // 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 FoldCppDoc(unsigned int startPos, int length, int initStyle, +static void FoldEclDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { - bool foldComment = styler.GetPropertyInt("fold.comment") != 0; - bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; - bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0; - unsigned int endPos = startPos + length; + bool foldComment = true; + bool foldPreprocessor = true; + bool foldCompact = true; + bool foldAtElse = true; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; @@ -374,7 +420,7 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; @@ -382,14 +428,14 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (foldComment && IsStreamCommentStyle(style)) { - if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_C_COMMENTLINEDOC)) { + if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_ECL_COMMENTLINEDOC)) { levelNext++; - } else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_C_COMMENTLINEDOC) && !atEOL) { + } else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_ECL_COMMENTLINEDOC) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelNext--; } } - if (foldComment && (style == SCE_C_COMMENTLINE)) { + if (foldComment && (style == SCE_ECL_COMMENTLINE)) { if ((ch == '/') && (chNext == '/')) { char chNext2 = styler.SafeGetCharAt(i + 2); if (chNext2 == '{') { @@ -399,20 +445,20 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, } } } - if (foldPreprocessor && (style == SCE_C_PREPROCESSOR)) { + if (foldPreprocessor && (style == SCE_ECL_PREPROCESSOR)) { if (ch == '#') { - unsigned int j = i + 1; + Sci_PositionU j = i + 1; while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { j++; } - if (styler.Match(j, "region") || styler.Match(j, "if")) { + if (MatchNoCase(styler, j, "region") || MatchNoCase(styler, j, "if")) { levelNext++; - } else if (styler.Match(j, "end")) { + } else if (MatchNoCase(styler, j, "endregion") || MatchNoCase(styler, j, "end")) { levelNext--; } } } - if (style == SCE_C_OPERATOR) { + if (style == SCE_ECL_OPERATOR) { if (ch == '{') { // Measure the minimum before a '{' to allow // folding on "} else {" @@ -424,8 +470,15 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, levelNext--; } } - if (!IsASpace(ch)) - visibleChars++; + if (style == SCE_ECL_WORD2) { + if (MatchNoCase(styler, i, "record") || MatchNoCase(styler, i, "transform") || MatchNoCase(styler, i, "type") || MatchNoCase(styler, i, "function") || + MatchNoCase(styler, i, "module") || MatchNoCase(styler, i, "service") || MatchNoCase(styler, i, "interface") || MatchNoCase(styler, i, "ifblock") || + MatchNoCase(styler, i, "macro") || MatchNoCase(styler, i, "beginc++")) { + levelNext++; + } else if (MatchNoCase(styler, i, "endmacro") || MatchNoCase(styler, i, "endc++") || MatchNoCase(styler, i, "end")) { + levelNext--; + } + } if (atEOL || (i == endPos-1)) { int levelUse = levelCurrent; if (foldAtElse) { @@ -442,29 +495,25 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; + if (atEOL && (i == static_cast(styler.Length()-1))) { + // There is an empty line at end of file so give it same level and empty + styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); + } visibleChars = 0; } + if (!IsASpace(ch)) + visibleChars++; } } -static const char * const cppWordLists[] = { - "Primary keywords and identifiers", - "Secondary keywords and identifiers", - "Documentation comment keywords", - "Unused", - "Global classes and typedefs", - 0, - }; - -static void ColouriseCppDocSensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler) { - ColouriseCppDoc(startPos, length, initStyle, keywordlists, styler, true); -} - -static void ColouriseCppDocInsensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler) { - ColouriseCppDoc(startPos, length, initStyle, keywordlists, styler, false); -} +static const char * const EclWordListDesc[] = { + "Keywords", + 0 +}; -LexerModule lmCPP(SCLEX_CPP, ColouriseCppDocSensitive, "cpp", FoldCppDoc, cppWordLists); -LexerModule lmCPPNoCase(SCLEX_CPPNOCASE, ColouriseCppDocInsensitive, "cppnocase", FoldCppDoc, cppWordLists); +LexerModule lmECL( + SCLEX_ECL, + ColouriseEclDoc, + "ecl", + FoldEclDoc, + EclWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexEDIFACT.cxx b/Pythonwin/Scintilla/lexers/LexEDIFACT.cxx new file mode 100644 index 000000000..3623807a4 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexEDIFACT.cxx @@ -0,0 +1,403 @@ +// Scintilla Lexer for EDIFACT +// @file LexEDIFACT.cxx +// Written by Iain Clarke, IMCSoft & Inobiz AB. +// EDIFACT documented here: https://www.unece.org/cefact/edifact/welcome.html +// and more readably here: https://en.wikipedia.org/wiki/EDIFACT +// This code is subject to the same license terms as the rest of the scintilla project: +// The License.txt file describes the conditions under which this software may be distributed. +// + +// Header order must match order in scripts/HeaderOrder.txt +#include +#include +#include +#include + +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "LexAccessor.h" +#include "LexerModule.h" +#include "DefaultLexer.h" + +using namespace Scintilla; + +class LexerEDIFACT : public DefaultLexer +{ +public: + LexerEDIFACT(); + virtual ~LexerEDIFACT() {} // virtual destructor, as we inherit from ILexer + + static ILexer5 *Factory() { + return new LexerEDIFACT; + } + + int SCI_METHOD Version() const override + { + return lvRelease5; + } + void SCI_METHOD Release() override + { + delete this; + } + + const char * SCI_METHOD PropertyNames() override + { + return "fold\nlexer.edifact.highlight.un.all"; + } + int SCI_METHOD PropertyType(const char *) override + { + return SC_TYPE_BOOLEAN; // Only one property! + } + const char * SCI_METHOD DescribeProperty(const char *name) override + { + if (!strcmp(name, "fold")) + return "Whether to apply folding to document or not"; + if (!strcmp(name, "lexer.edifact.highlight.un.all")) + return "Whether to apply UN* highlighting to all UN segments, or just to UNH"; + return NULL; + } + + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override + { + if (!strcmp(key, "fold")) + { + m_bFold = strcmp(val, "0") ? true : false; + return 0; + } + if (!strcmp(key, "lexer.edifact.highlight.un.all")) // GetProperty + { + m_bHighlightAllUN = strcmp(val, "0") ? true : false; + return 0; + } + return -1; + } + + const char * SCI_METHOD PropertyGet(const char *key) override + { + m_lastPropertyValue = ""; + if (!strcmp(key, "fold")) + { + m_lastPropertyValue = m_bFold ? "1" : "0"; + } + if (!strcmp(key, "lexer.edifact.highlight.un.all")) // GetProperty + { + m_lastPropertyValue = m_bHighlightAllUN ? "1" : "0"; + } + return m_lastPropertyValue.c_str(); + } + + const char * SCI_METHOD DescribeWordListSets() override + { + return NULL; + } + Sci_Position SCI_METHOD WordListSet(int, const char *) override + { + return -1; + } + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + void * SCI_METHOD PrivateCall(int, void *) override + { + return NULL; + } + +protected: + Sci_Position InitialiseFromUNA(IDocument *pAccess, Sci_PositionU MaxLength); + Sci_Position FindPreviousEnd(IDocument *pAccess, Sci_Position startPos) const; + Sci_Position ForwardPastWhitespace(IDocument *pAccess, Sci_Position startPos, Sci_Position MaxLength) const; + int DetectSegmentHeader(char SegmentHeader[3]) const; + + bool m_bFold; + + // property lexer.edifact.highlight.un.all + // Set to 0 to highlight only UNA segments, or 1 to highlight all UNx segments. + bool m_bHighlightAllUN; + + char m_chComponent; + char m_chData; + char m_chDecimal; + char m_chRelease; + char m_chSegment; + + std::string m_lastPropertyValue; +}; + +LexerModule lmEDIFACT(SCLEX_EDIFACT, LexerEDIFACT::Factory, "edifact"); + +/////////////////////////////////////////////////////////////////////////////// + + + +/////////////////////////////////////////////////////////////////////////////// + +LexerEDIFACT::LexerEDIFACT() : DefaultLexer("edifact", SCLEX_EDIFACT) +{ + m_bFold = false; + m_bHighlightAllUN = false; + m_chComponent = ':'; + m_chData = '+'; + m_chDecimal = '.'; + m_chRelease = '?'; + m_chSegment = '\''; +} + +void LexerEDIFACT::Lex(Sci_PositionU startPos, Sci_Position length, int, IDocument *pAccess) +{ + Sci_PositionU posFinish = startPos + length; + InitialiseFromUNA(pAccess, posFinish); + + // Look backwards for a ' or a document beginning + Sci_PositionU posCurrent = FindPreviousEnd(pAccess, startPos); + // And jump past the ' if this was not the beginning of the document + if (posCurrent != 0) + posCurrent++; + + // Style buffer, so we're not issuing loads of notifications + LexAccessor styler (pAccess); + pAccess->StartStyling(posCurrent); + styler.StartSegment(posCurrent); + Sci_Position posSegmentStart = -1; + + while ((posCurrent < posFinish) && (posSegmentStart == -1)) + { + posCurrent = ForwardPastWhitespace(pAccess, posCurrent, posFinish); + // Mark whitespace as default + styler.ColourTo(posCurrent - 1, SCE_EDI_DEFAULT); + if (posCurrent >= posFinish) + break; + + // Does is start with 3 charaters? ie, UNH + char SegmentHeader[4] = { 0 }; + pAccess->GetCharRange(SegmentHeader, posCurrent, 3); + + int SegmentStyle = DetectSegmentHeader(SegmentHeader); + if (SegmentStyle == SCE_EDI_BADSEGMENT) + break; + if (SegmentStyle == SCE_EDI_UNA) + { + posCurrent += 9; + styler.ColourTo(posCurrent - 1, SCE_EDI_UNA); // UNA + continue; + } + posSegmentStart = posCurrent; + posCurrent += 3; + + styler.ColourTo(posCurrent - 1, SegmentStyle); // UNH etc + + // Colour in the rest of the segment + for (char c; posCurrent < posFinish; posCurrent++) + { + pAccess->GetCharRange(&c, posCurrent, 1); + + if (c == m_chRelease) // ? escape character, check first, in case of ?' + posCurrent++; + else if (c == m_chSegment) // ' + { + // Make sure the whole segment is on one line. styler won't let us go back in time, so we'll settle for marking the ' as bad. + Sci_Position lineSegmentStart = pAccess->LineFromPosition(posSegmentStart); + Sci_Position lineSegmentEnd = pAccess->LineFromPosition(posCurrent); + if (lineSegmentStart == lineSegmentEnd) + styler.ColourTo(posCurrent, SCE_EDI_SEGMENTEND); + else + styler.ColourTo(posCurrent, SCE_EDI_BADSEGMENT); + posSegmentStart = -1; + posCurrent++; + break; + } + else if (c == m_chComponent) // : + styler.ColourTo(posCurrent, SCE_EDI_SEP_COMPOSITE); + else if (c == m_chData) // + + styler.ColourTo(posCurrent, SCE_EDI_SEP_ELEMENT); + else + styler.ColourTo(posCurrent, SCE_EDI_DEFAULT); + } + } + styler.Flush(); + + if (posSegmentStart == -1) + return; + + pAccess->StartStyling(posSegmentStart); + pAccess->SetStyleFor(posFinish - posSegmentStart, SCE_EDI_BADSEGMENT); +} + +void LexerEDIFACT::Fold(Sci_PositionU startPos, Sci_Position length, int, IDocument *pAccess) +{ + if (!m_bFold) + return; + + Sci_PositionU endPos = startPos + length; + startPos = FindPreviousEnd(pAccess, startPos); + char c; + char SegmentHeader[4] = { 0 }; + + bool AwaitingSegment = true; + Sci_PositionU currLine = pAccess->LineFromPosition(startPos); + int levelCurrentStyle = SC_FOLDLEVELBASE; + if (currLine > 0) + levelCurrentStyle = pAccess->GetLevel(currLine - 1); // bottom 12 bits are level + int indentCurrent = levelCurrentStyle & SC_FOLDLEVELNUMBERMASK; + int indentNext = indentCurrent; + + while (startPos < endPos) + { + pAccess->GetCharRange(&c, startPos, 1); + switch (c) + { + case '\t': + case '\r': + case ' ': + startPos++; + continue; + case '\n': + currLine = pAccess->LineFromPosition(startPos); + pAccess->SetLevel(currLine, levelCurrentStyle | indentCurrent); + startPos++; + levelCurrentStyle = SC_FOLDLEVELBASE; + indentCurrent = indentNext; + continue; + } + if (c == m_chRelease) + { + startPos += 2; + continue; + } + if (c == m_chSegment) + { + AwaitingSegment = true; + startPos++; + continue; + } + + if (!AwaitingSegment) + { + startPos++; + continue; + } + + // Segment! + pAccess->GetCharRange(SegmentHeader, startPos, 3); + if (SegmentHeader[0] != 'U' || SegmentHeader[1] != 'N') + { + startPos++; + continue; + } + + AwaitingSegment = false; + switch (SegmentHeader[2]) + { + case 'H': + case 'G': + indentNext++; + levelCurrentStyle = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + break; + + case 'T': + case 'E': + if (indentNext > 0) + indentNext--; + break; + } + + startPos += 3; + } +} + +Sci_Position LexerEDIFACT::InitialiseFromUNA(IDocument *pAccess, Sci_PositionU MaxLength) +{ + MaxLength -= 9; // drop 9 chars, to give us room for UNA:+.? ' + + Sci_PositionU startPos = 0; + startPos += ForwardPastWhitespace(pAccess, 0, MaxLength); + if (startPos < MaxLength) + { + char bufUNA[9]; + pAccess->GetCharRange(bufUNA, startPos, 9); + + // Check it's UNA segment + if (!memcmp(bufUNA, "UNA", 3)) + { + m_chComponent = bufUNA[3]; + m_chData = bufUNA[4]; + m_chDecimal = bufUNA[5]; + m_chRelease = bufUNA[6]; + // bufUNA [7] should be space - reserved. + m_chSegment = bufUNA[8]; + + return 0; // success! + } + } + + // We failed to find a UNA, so drop to defaults + m_chComponent = ':'; + m_chData = '+'; + m_chDecimal = '.'; + m_chRelease = '?'; + m_chSegment = '\''; + + return -1; +} + +Sci_Position LexerEDIFACT::ForwardPastWhitespace(IDocument *pAccess, Sci_Position startPos, Sci_Position MaxLength) const +{ + char c; + + while (startPos < MaxLength) + { + pAccess->GetCharRange(&c, startPos, 1); + switch (c) + { + case '\t': + case '\r': + case '\n': + case ' ': + break; + default: + return startPos; + } + + startPos++; + } + + return MaxLength; +} + +int LexerEDIFACT::DetectSegmentHeader(char SegmentHeader[3]) const +{ + if ( + SegmentHeader[0] < 'A' || SegmentHeader[0] > 'Z' || + SegmentHeader[1] < 'A' || SegmentHeader[1] > 'Z' || + SegmentHeader[2] < 'A' || SegmentHeader[2] > 'Z') + return SCE_EDI_BADSEGMENT; + + if (!memcmp(SegmentHeader, "UNA", 3)) + return SCE_EDI_UNA; + + if (m_bHighlightAllUN && !memcmp(SegmentHeader, "UN", 2)) + return SCE_EDI_UNH; + else if (!memcmp(SegmentHeader, "UNH", 3)) + return SCE_EDI_UNH; + else if (!memcmp(SegmentHeader, "UNG", 3)) + return SCE_EDI_UNH; + + return SCE_EDI_SEGMENTSTART; +} + +// Look backwards for a ' or a document beginning +Sci_Position LexerEDIFACT::FindPreviousEnd(IDocument *pAccess, Sci_Position startPos) const +{ + for (char c; startPos > 0; startPos--) + { + pAccess->GetCharRange(&c, startPos, 1); + if (c == m_chSegment) + return startPos; + } + // We didn't find a ', so just go with the beginning + return 0; +} + + diff --git a/Pythonwin/Scintilla/src/LexEScript.cxx b/Pythonwin/Scintilla/lexers/LexEScript.cxx similarity index 92% rename from Pythonwin/Scintilla/src/LexEScript.cxx rename to Pythonwin/Scintilla/lexers/LexEScript.cxx index 295aaec53..79f99aedd 100644 --- a/Pythonwin/Scintilla/src/LexEScript.cxx +++ b/Pythonwin/Scintilla/lexers/LexEScript.cxx @@ -1,27 +1,28 @@ // Scintilla source code edit control -/** @file LexESCRIPT.cxx +/** @file LexEScript.cxx ** Lexer for ESCRIPT **/ // Copyright 2003 by Patrizio Bekerle (patrizio@bekerle.com) #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif static inline bool IsAWordChar(const int ch) { @@ -34,7 +35,7 @@ static inline bool IsAWordStart(const int ch) { -static void ColouriseESCRIPTDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseESCRIPTDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -173,24 +174,24 @@ static bool IsStreamCommentStyle(int style) { style == SCE_ESCRIPT_COMMENTLINE; } -static void FoldESCRIPTDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { +static void FoldESCRIPTDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { //~ bool foldComment = styler.GetPropertyInt("fold.comment") != 0; // Do not know how to fold the comment at the moment. bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldComment = true; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + 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; - int lastStart = 0; + Sci_Position lastStart = 0; char prevWord[32] = ""; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; @@ -198,7 +199,7 @@ static void FoldESCRIPTDoc(unsigned int startPos, int length, int initStyle, Wor styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); - + if (foldComment && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev)) { levelCurrent++; @@ -228,7 +229,7 @@ static void FoldESCRIPTDoc(unsigned int startPos, int length, int initStyle, Wor if (style == SCE_ESCRIPT_WORD3) { if(iswordchar(ch) && !iswordchar(chNext)) { char s[32]; - unsigned int j; + Sci_PositionU j; for(j = 0; ( j < 31 ) && ( j < i-lastStart+1 ); j++) { s[j] = static_cast(tolower(styler[lastStart + j])); } diff --git a/Pythonwin/Scintilla/src/LexEiffel.cxx b/Pythonwin/Scintilla/lexers/LexEiffel.cxx similarity index 88% rename from Pythonwin/Scintilla/src/LexEiffel.cxx rename to Pythonwin/Scintilla/lexers/LexEiffel.cxx index 03dea5e73..d1d42a960 100644 --- a/Pythonwin/Scintilla/src/LexEiffel.cxx +++ b/Pythonwin/Scintilla/lexers/LexEiffel.cxx @@ -7,22 +7,23 @@ #include #include -#include -#include #include +#include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif static inline bool isEiffelOperator(unsigned int ch) { // '.' left out as it is used to make up numbers @@ -43,8 +44,8 @@ static inline bool IsAWordStart(unsigned int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } -static void ColouriseEiffelDoc(unsigned int startPos, - int length, +static void ColouriseEiffelDoc(Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -115,16 +116,16 @@ static void ColouriseEiffelDoc(unsigned int startPos, sc.Complete(); } -static bool IsEiffelComment(Accessor &styler, int pos, int len) { +static bool IsEiffelComment(Accessor &styler, Sci_Position pos, Sci_Position len) { return len>1 && styler[pos]=='-' && styler[pos+1]=='-'; } -static void FoldEiffelDocIndent(unsigned int startPos, int length, int, +static void FoldEiffelDocIndent(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - int lengthDoc = startPos + length; + Sci_Position lengthDoc = startPos + length; // Backtrack to previous line in case need to fix its fold status - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); if (startPos > 0) { if (lineCurrent > 0) { lineCurrent--; @@ -134,7 +135,7 @@ static void FoldEiffelDocIndent(unsigned int startPos, int length, int, int spaceFlags = 0; int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsEiffelComment); char chNext = styler[startPos]; - for (int i = startPos; i < lengthDoc; i++) { + for (Sci_Position i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -161,11 +162,11 @@ static void FoldEiffelDocIndent(unsigned int startPos, int length, int, } } -static void FoldEiffelDocKeyWords(unsigned int startPos, int length, int /* initStyle */, WordList *[], +static void FoldEiffelDocKeyWords(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; @@ -174,7 +175,7 @@ static void FoldEiffelDocKeyWords(unsigned int startPos, int length, int /* init // lastDeferred should be determined by looking back to last keyword in case // the "deferred" is on a line before "class" bool lastDeferred = false; - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; @@ -182,7 +183,7 @@ static void FoldEiffelDocKeyWords(unsigned int startPos, int length, int /* init bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if ((stylePrev != SCE_EIFFEL_WORD) && (style == SCE_EIFFEL_WORD)) { char s[20]; - unsigned int j = 0; + Sci_PositionU j = 0; while ((j < (sizeof(s) - 1)) && (iswordchar(styler[i + j]))) { s[j] = styler[i + j]; j++; diff --git a/Pythonwin/Scintilla/lexers/LexErlang.cxx b/Pythonwin/Scintilla/lexers/LexErlang.cxx new file mode 100644 index 000000000..4ca5962c3 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexErlang.cxx @@ -0,0 +1,624 @@ +// Scintilla source code edit control +// Encoding: UTF-8 +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. +/** @file LexErlang.cxx + ** Lexer for Erlang. + ** Enhanced by Etienne 'Lenain' Girondel (lenaing@gmail.com) + ** Originally wrote by Peter-Henry Mander, + ** based on Matlab lexer by José Fonseca. + **/ + +#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" + +using namespace Scintilla; + +static int is_radix(int radix, int ch) { + int digit; + + if (36 < radix || 2 > radix) + return 0; + + if (isdigit(ch)) { + digit = ch - '0'; + } else if (isalnum(ch)) { + digit = toupper(ch) - 'A' + 10; + } else { + return 0; + } + + return (digit < radix); +} + +typedef enum { + STATE_NULL, + COMMENT, + COMMENT_FUNCTION, + COMMENT_MODULE, + COMMENT_DOC, + COMMENT_DOC_MACRO, + ATOM_UNQUOTED, + ATOM_QUOTED, + NODE_NAME_UNQUOTED, + NODE_NAME_QUOTED, + MACRO_START, + MACRO_UNQUOTED, + MACRO_QUOTED, + RECORD_START, + RECORD_UNQUOTED, + RECORD_QUOTED, + NUMERAL_START, + NUMERAL_BASE_VALUE, + NUMERAL_FLOAT, + NUMERAL_EXPONENT, + PREPROCESSOR +} atom_parse_state_t; + +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (ch != ' ') && (isalnum(ch) || ch == '_'); +} + +static void ColouriseErlangDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + + StyleContext sc(startPos, length, initStyle, styler); + WordList &reservedWords = *keywordlists[0]; + WordList &erlangBIFs = *keywordlists[1]; + WordList &erlangPreproc = *keywordlists[2]; + WordList &erlangModulesAtt = *keywordlists[3]; + WordList &erlangDoc = *keywordlists[4]; + WordList &erlangDocMacro = *keywordlists[5]; + int radix_digits = 0; + int exponent_digits = 0; + atom_parse_state_t parse_state = STATE_NULL; + atom_parse_state_t old_parse_state = STATE_NULL; + bool to_late_to_comment = false; + char cur[100]; + int old_style = SCE_ERLANG_DEFAULT; + + styler.StartAt(startPos); + + for (; sc.More(); sc.Forward()) { + int style = SCE_ERLANG_DEFAULT; + if (STATE_NULL != parse_state) { + + switch (parse_state) { + + case STATE_NULL : sc.SetState(SCE_ERLANG_DEFAULT); break; + + /* COMMENTS ------------------------------------------------------*/ + case COMMENT : { + if (sc.ch != '%') { + to_late_to_comment = true; + } else if (!to_late_to_comment && sc.ch == '%') { + // Switch to comment level 2 (Function) + sc.ChangeState(SCE_ERLANG_COMMENT_FUNCTION); + old_style = SCE_ERLANG_COMMENT_FUNCTION; + parse_state = COMMENT_FUNCTION; + sc.Forward(); + } + } + // V--- Falling through! + // Falls through. + case COMMENT_FUNCTION : { + if (sc.ch != '%') { + to_late_to_comment = true; + } else if (!to_late_to_comment && sc.ch == '%') { + // Switch to comment level 3 (Module) + sc.ChangeState(SCE_ERLANG_COMMENT_MODULE); + old_style = SCE_ERLANG_COMMENT_MODULE; + parse_state = COMMENT_MODULE; + sc.Forward(); + } + } + // V--- Falling through! + // Falls through. + case COMMENT_MODULE : { + if (parse_state != COMMENT) { + // Search for comment documentation + if (sc.chNext == '@') { + old_parse_state = parse_state; + parse_state = ('{' == sc.ch) + ? COMMENT_DOC_MACRO + : COMMENT_DOC; + sc.ForwardSetState(sc.state); + } + } + + // All comments types fall here. + if (sc.atLineEnd) { + to_late_to_comment = false; + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case COMMENT_DOC : + // V--- Falling through! + case COMMENT_DOC_MACRO : { + + if (!isalnum(sc.ch)) { + // Try to match documentation comment + sc.GetCurrent(cur, sizeof(cur)); + + if (parse_state == COMMENT_DOC_MACRO + && erlangDocMacro.InList(cur)) { + sc.ChangeState(SCE_ERLANG_COMMENT_DOC_MACRO); + while (sc.ch != '}' && !sc.atLineEnd) + sc.Forward(); + } else if (erlangDoc.InList(cur)) { + sc.ChangeState(SCE_ERLANG_COMMENT_DOC); + } else { + sc.ChangeState(old_style); + } + + // Switch back to old state + sc.SetState(old_style); + parse_state = old_parse_state; + } + + if (sc.atLineEnd) { + to_late_to_comment = false; + sc.ChangeState(old_style); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Atoms ---------------------------------------------------------*/ + case ATOM_UNQUOTED : { + if ('@' == sc.ch){ + parse_state = NODE_NAME_UNQUOTED; + } else if (sc.ch == ':') { + // Searching for module name + if (sc.chNext == ' ') { + // error + sc.ChangeState(SCE_ERLANG_UNKNOWN); + parse_state = STATE_NULL; + } else { + sc.Forward(); + if (isalnum(sc.ch)) { + sc.GetCurrent(cur, sizeof(cur)); + sc.ChangeState(SCE_ERLANG_MODULES); + sc.SetState(SCE_ERLANG_MODULES); + } + } + } else if (!IsAWordChar(sc.ch)) { + + sc.GetCurrent(cur, sizeof(cur)); + if (reservedWords.InList(cur)) { + style = SCE_ERLANG_KEYWORD; + } else if (erlangBIFs.InList(cur) + && strcmp(cur,"erlang:")){ + style = SCE_ERLANG_BIFS; + } else if (sc.ch == '(' || '/' == sc.ch){ + style = SCE_ERLANG_FUNCTION_NAME; + } else { + style = SCE_ERLANG_ATOM; + } + + sc.ChangeState(style); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + + } break; + + case ATOM_QUOTED : { + if ( '@' == sc.ch ){ + parse_state = NODE_NAME_QUOTED; + } else if ('\'' == sc.ch && '\\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_ATOM); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Node names ----------------------------------------------------*/ + case NODE_NAME_UNQUOTED : { + if ('@' == sc.ch) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if (!IsAWordChar(sc.ch)) { + sc.ChangeState(SCE_ERLANG_NODE_NAME); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case NODE_NAME_QUOTED : { + if ('@' == sc.ch) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if ('\'' == sc.ch && '\\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_NODE_NAME_QUOTED); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Records -------------------------------------------------------*/ + case RECORD_START : { + if ('\'' == sc.ch) { + parse_state = RECORD_QUOTED; + } else if (isalpha(sc.ch) && islower(sc.ch)) { + parse_state = RECORD_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case RECORD_UNQUOTED : { + if (!IsAWordChar(sc.ch)) { + sc.ChangeState(SCE_ERLANG_RECORD); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case RECORD_QUOTED : { + if ('\'' == sc.ch && '\\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_RECORD_QUOTED); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Macros --------------------------------------------------------*/ + case MACRO_START : { + if ('\'' == sc.ch) { + parse_state = MACRO_QUOTED; + } else if (isalpha(sc.ch)) { + parse_state = MACRO_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case MACRO_UNQUOTED : { + if (!IsAWordChar(sc.ch)) { + sc.ChangeState(SCE_ERLANG_MACRO); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case MACRO_QUOTED : { + if ('\'' == sc.ch && '\\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_MACRO_QUOTED); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Numerics ------------------------------------------------------*/ + /* Simple integer */ + case NUMERAL_START : { + if (isdigit(sc.ch)) { + radix_digits *= 10; + radix_digits += sc.ch - '0'; // Assuming ASCII here! + } else if ('#' == sc.ch) { + if (2 > radix_digits || 36 < radix_digits) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + parse_state = NUMERAL_BASE_VALUE; + } + } else if ('.' == sc.ch && isdigit(sc.chNext)) { + radix_digits = 0; + parse_state = NUMERAL_FLOAT; + } else if ('e' == sc.ch || 'E' == sc.ch) { + exponent_digits = 0; + parse_state = NUMERAL_EXPONENT; + } else { + radix_digits = 0; + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* Integer in other base than 10 (x#yyy) */ + case NUMERAL_BASE_VALUE : { + if (!is_radix(radix_digits,sc.ch)) { + radix_digits = 0; + + if (!isalnum(sc.ch)) + sc.ChangeState(SCE_ERLANG_NUMBER); + + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* Float (x.yyy) */ + case NUMERAL_FLOAT : { + if ('e' == sc.ch || 'E' == sc.ch) { + exponent_digits = 0; + parse_state = NUMERAL_EXPONENT; + } else if (!isdigit(sc.ch)) { + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* Exponent, either integer or float (xEyy, x.yyEzzz) */ + case NUMERAL_EXPONENT : { + if (('-' == sc.ch || '+' == sc.ch) + && (isdigit(sc.chNext))) { + sc.Forward(); + } else if (!isdigit(sc.ch)) { + if (0 < exponent_digits) + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + ++exponent_digits; + } + } break; + + /* -------------------------------------------------------------- */ + /* Preprocessor --------------------------------------------------*/ + case PREPROCESSOR : { + if (!IsAWordChar(sc.ch)) { + + sc.GetCurrent(cur, sizeof(cur)); + if (erlangPreproc.InList(cur)) { + style = SCE_ERLANG_PREPROC; + } else if (erlangModulesAtt.InList(cur)) { + style = SCE_ERLANG_MODULES_ATT; + } + + sc.ChangeState(style); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + } + + } /* End of : STATE_NULL != parse_state */ + else + { + switch (sc.state) { + case SCE_ERLANG_VARIABLE : { + if (!IsAWordChar(sc.ch)) + sc.SetState(SCE_ERLANG_DEFAULT); + } break; + case SCE_ERLANG_STRING : { + if (sc.ch == '\"' && sc.chPrev != '\\') + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } break; + case SCE_ERLANG_COMMENT : { + if (sc.atLineEnd) + sc.SetState(SCE_ERLANG_DEFAULT); + } break; + case SCE_ERLANG_CHARACTER : { + if (sc.chPrev == '\\') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if (sc.ch != '\\') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } + } break; + case SCE_ERLANG_OPERATOR : { + if (sc.chPrev == '.') { + if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' + || sc.ch == '^') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if (sc.ch == '\'') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } break; + } + } + + if (sc.state == SCE_ERLANG_DEFAULT) { + bool no_new_state = false; + + switch (sc.ch) { + case '\"' : sc.SetState(SCE_ERLANG_STRING); break; + case '$' : sc.SetState(SCE_ERLANG_CHARACTER); break; + case '%' : { + parse_state = COMMENT; + sc.SetState(SCE_ERLANG_COMMENT); + } break; + case '#' : { + parse_state = RECORD_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } break; + case '?' : { + parse_state = MACRO_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } break; + case '\'' : { + parse_state = ATOM_QUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } break; + case '+' : + case '-' : { + if (IsADigit(sc.chNext)) { + parse_state = NUMERAL_START; + radix_digits = 0; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (sc.ch != '+') { + parse_state = PREPROCESSOR; + sc.SetState(SCE_ERLANG_UNKNOWN); + } + } break; + default : no_new_state = true; + } + + if (no_new_state) { + if (isdigit(sc.ch)) { + parse_state = NUMERAL_START; + radix_digits = sc.ch - '0'; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isupper(sc.ch) || '_' == sc.ch) { + sc.SetState(SCE_ERLANG_VARIABLE); + } else if (isalpha(sc.ch)) { + parse_state = ATOM_UNQUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isoperator(static_cast(sc.ch)) + || sc.ch == '\\') { + sc.SetState(SCE_ERLANG_OPERATOR); + } + } + } + + } + sc.Complete(); +} + +static int ClassifyErlangFoldPoint( + Accessor &styler, + int styleNext, + Sci_Position keyword_start +) { + int lev = 0; + if (styler.Match(keyword_start,"case") + || ( + styler.Match(keyword_start,"fun") + && (SCE_ERLANG_FUNCTION_NAME != styleNext) + ) + || styler.Match(keyword_start,"if") + || styler.Match(keyword_start,"query") + || styler.Match(keyword_start,"receive") + ) { + ++lev; + } else if (styler.Match(keyword_start,"end")) { + --lev; + } + + return lev; +} + +static void FoldErlangDoc( + Sci_PositionU startPos, Sci_Position length, int initStyle, + WordList** /*keywordlists*/, Accessor &styler +) { + Sci_PositionU endPos = startPos + length; + Sci_Position currentLine = styler.GetLine(startPos); + int lev; + int previousLevel = styler.LevelAt(currentLine) & SC_FOLDLEVELNUMBERMASK; + int currentLevel = previousLevel; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + int stylePrev; + Sci_Position keyword_start = 0; + char ch; + char chNext = styler.SafeGetCharAt(startPos); + bool atEOL; + + for (Sci_PositionU i = startPos; i < endPos; i++) { + ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + + // Get styles + stylePrev = style; + style = styleNext; + styleNext = styler.StyleAt(i + 1); + atEOL = ((ch == '\r') && (chNext != '\n')) || (ch == '\n'); + + if (stylePrev != SCE_ERLANG_KEYWORD + && style == SCE_ERLANG_KEYWORD) { + keyword_start = i; + } + + // Fold on keywords + if (stylePrev == SCE_ERLANG_KEYWORD + && style != SCE_ERLANG_KEYWORD + && style != SCE_ERLANG_ATOM + ) { + currentLevel += ClassifyErlangFoldPoint(styler, + styleNext, + keyword_start); + } + + // Fold on comments + if (style == SCE_ERLANG_COMMENT + || style == SCE_ERLANG_COMMENT_MODULE + || style == SCE_ERLANG_COMMENT_FUNCTION) { + + if (ch == '%' && chNext == '{') { + currentLevel++; + } else if (ch == '%' && chNext == '}') { + currentLevel--; + } + } + + // Fold on braces + if (style == SCE_ERLANG_OPERATOR) { + if (ch == '{' || ch == '(' || ch == '[') { + currentLevel++; + } else if (ch == '}' || ch == ')' || ch == ']') { + currentLevel--; + } + } + + + if (atEOL) { + lev = previousLevel; + + if (currentLevel > previousLevel) + lev |= SC_FOLDLEVELHEADERFLAG; + + if (lev != styler.LevelAt(currentLine)) + styler.SetLevel(currentLine, lev); + + currentLine++; + previousLevel = currentLevel; + } + + } + + // Fill in the real level of the next line, keeping the current flags as they will be filled in later + styler.SetLevel(currentLine, + previousLevel + | (styler.LevelAt(currentLine) & ~SC_FOLDLEVELNUMBERMASK)); +} + +static const char * const erlangWordListDesc[] = { + "Erlang Reserved words", + "Erlang BIFs", + "Erlang Preprocessor", + "Erlang Module Attributes", + "Erlang Documentation", + "Erlang Documentation Macro", + 0 +}; + +LexerModule lmErlang( + SCLEX_ERLANG, + ColouriseErlangDoc, + "erlang", + FoldErlangDoc, + erlangWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexErrorList.cxx b/Pythonwin/Scintilla/lexers/LexErrorList.cxx new file mode 100644 index 000000000..0fc389646 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexErrorList.cxx @@ -0,0 +1,409 @@ +// Scintilla source code edit control +/** @file LexErrorList.cxx + ** Lexer for error lists. Used for the output pane in SciTE. + **/ +// 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 "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" + +using namespace Scintilla; + +namespace { + +bool strstart(const char *haystack, const char *needle) noexcept { + return strncmp(haystack, needle, strlen(needle)) == 0; +} + +constexpr bool Is0To9(char ch) noexcept { + return (ch >= '0') && (ch <= '9'); +} + +constexpr bool Is1To9(char ch) noexcept { + return (ch >= '1') && (ch <= '9'); +} + +bool IsAlphabetic(int ch) { + return IsASCII(ch) && isalpha(ch); +} + +inline bool AtEOL(Accessor &styler, Sci_PositionU i) { + return (styler[i] == '\n') || + ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')); +} + +bool IsGccExcerpt(const char *s) noexcept { + while (*s) { + if (s[0] == ' ' && s[1] == '|' && (s[2] == ' ' || s[2] == '+')) { + return true; + } + if (!(s[0] == ' ' || s[0] == '+' || Is0To9(s[0]))) { + return false; + } + s++; + } + return true; +} + +int RecogniseErrorListLine(const char *lineBuffer, Sci_PositionU lengthLine, Sci_Position &startValue) { + if (lineBuffer[0] == '>') { + // Command or return status + return SCE_ERR_CMD; + } else if (lineBuffer[0] == '<') { + // Diff removal. + return SCE_ERR_DIFF_DELETION; + } else if (lineBuffer[0] == '!') { + return SCE_ERR_DIFF_CHANGED; + } else if (lineBuffer[0] == '+') { + if (strstart(lineBuffer, "+++ ")) { + return SCE_ERR_DIFF_MESSAGE; + } else { + return SCE_ERR_DIFF_ADDITION; + } + } else if (lineBuffer[0] == '-') { + if (strstart(lineBuffer, "--- ")) { + return SCE_ERR_DIFF_MESSAGE; + } else { + return SCE_ERR_DIFF_DELETION; + } + } else if (strstart(lineBuffer, "cf90-")) { + // Absoft Pro Fortran 90/95 v8.2 error and/or warning message + return SCE_ERR_ABSF; + } else if (strstart(lineBuffer, "fortcom:")) { + // Intel Fortran Compiler v8.0 error/warning message + return SCE_ERR_IFORT; + } else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) { + return SCE_ERR_PYTHON; + } else if (strstr(lineBuffer, " in ") && strstr(lineBuffer, " on line ")) { + return SCE_ERR_PHP; + } else if ((strstart(lineBuffer, "Error ") || + strstart(lineBuffer, "Warning ")) && + strstr(lineBuffer, " at (") && + strstr(lineBuffer, ") : ") && + (strstr(lineBuffer, " at (") < strstr(lineBuffer, ") : "))) { + // Intel Fortran Compiler error/warning message + return SCE_ERR_IFC; + } else if (strstart(lineBuffer, "Error ")) { + // Borland error message + return SCE_ERR_BORLAND; + } else if (strstart(lineBuffer, "Warning ")) { + // Borland warning message + return SCE_ERR_BORLAND; + } else if (strstr(lineBuffer, "at line ") && + (strstr(lineBuffer, "at line ") < (lineBuffer + lengthLine)) && + strstr(lineBuffer, "file ") && + (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) { + // Lua 4 error message + return SCE_ERR_LUA; + } else if (strstr(lineBuffer, " at ") && + (strstr(lineBuffer, " at ") < (lineBuffer + lengthLine)) && + strstr(lineBuffer, " line ") && + (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine)) && + (strstr(lineBuffer, " at ") + 4 < (strstr(lineBuffer, " line ")))) { + // perl error message: + // at line + return SCE_ERR_PERL; + } else if ((lengthLine >= 6) && + (memcmp(lineBuffer, " at ", 6) == 0) && + strstr(lineBuffer, ":line ")) { + // A .NET traceback + return SCE_ERR_NET; + } else if (strstart(lineBuffer, "Line ") && + strstr(lineBuffer, ", file ")) { + // Essential Lahey Fortran error message + return SCE_ERR_ELF; + } else if (strstart(lineBuffer, "line ") && + strstr(lineBuffer, " column ")) { + // HTML tidy style: line 42 column 1 + return SCE_ERR_TIDY; + } else if (strstart(lineBuffer, "\tat ") && + strstr(lineBuffer, "(") && + strstr(lineBuffer, ".java:")) { + // Java stack back trace + return SCE_ERR_JAVA_STACK; + } else if (strstart(lineBuffer, "In file included from ") || + strstart(lineBuffer, " from ")) { + // GCC showing include path to following error + return SCE_ERR_GCC_INCLUDED_FROM; + } else if (strstr(lineBuffer, "warning LNK")) { + // Microsoft linker warning: + // { : } warning LNK9999 + return SCE_ERR_MS; + } else if (IsGccExcerpt(lineBuffer)) { + // GCC code excerpt and pointer to issue + // 73 | GTimeVal last_popdown; + // | ^~~~~~~~~~~~ + return SCE_ERR_GCC_EXCERPT; + } else { + // Look for one of the following formats: + // GCC: :: + // Microsoft: () : + // Common: (): warning|error|note|remark|catastrophic|fatal + // Common: () warning|error|note|remark|catastrophic|fatal + // Microsoft: (,) + // CTags: \t\t + // Lua 5 traceback: \t:: + // Lua 5.1: : :: + const bool initialTab = (lineBuffer[0] == '\t'); + bool initialColonPart = false; + bool canBeCtags = !initialTab; // For ctags must have an identifier with no spaces then a tab + enum { stInitial, + stGccStart, stGccDigit, stGccColumn, stGcc, + stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet, + stCtagsStart, stCtagsFile, stCtagsStartString, stCtagsStringDollar, stCtags, + stUnrecognized + } state = stInitial; + for (Sci_PositionU i = 0; i < lengthLine; i++) { + const char ch = lineBuffer[i]; + char chNext = ' '; + if ((i + 1) < lengthLine) + chNext = lineBuffer[i + 1]; + if (state == stInitial) { + if (ch == ':') { + // May be GCC, or might be Lua 5 (Lua traceback same but with tab prefix) + if ((chNext != '\\') && (chNext != '/') && (chNext != ' ')) { + // This check is not completely accurate as may be on + // GTK+ with a file name that includes ':'. + state = stGccStart; + } else if (chNext == ' ') { // indicates a Lua 5.1 error message + initialColonPart = true; + } + } else if ((ch == '(') && Is1To9(chNext) && (!initialTab)) { + // May be Microsoft + // Check against '0' often removes phone numbers + state = stMsStart; + } else if ((ch == '\t') && canBeCtags) { + // May be CTags + state = stCtagsStart; + } else if (ch == ' ') { + canBeCtags = false; + } + } else if (state == stGccStart) { // : + state = ((ch == '-') || Is0To9(ch)) ? stGccDigit : stUnrecognized; + } else if (state == stGccDigit) { // : + if (ch == ':') { + state = stGccColumn; // :9.*: is GCC + startValue = i + 1; + } else if (!Is0To9(ch)) { + state = stUnrecognized; + } + } else if (state == stGccColumn) { // :: + if (!Is0To9(ch)) { + state = stGcc; + if (ch == ':') + startValue = i + 1; + break; + } + } else if (state == stMsStart) { // ( + state = Is0To9(ch) ? stMsDigit : stUnrecognized; + } else if (state == stMsDigit) { // ( + if (ch == ',') { + state = stMsDigitComma; + } else if (ch == ')') { + state = stMsBracket; + } else if ((ch != ' ') && !Is0To9(ch)) { + state = stUnrecognized; + } + } else if (state == stMsBracket) { // () + if ((ch == ' ') && (chNext == ':')) { + state = stMsVc; + } else if ((ch == ':' && chNext == ' ') || (ch == ' ')) { + // Possibly Delphi.. don't test against chNext as it's one of the strings below. + char word[512]; + unsigned numstep; + if (ch == ' ') + numstep = 1; // ch was ' ', handle as if it's a delphi errorline, only add 1 to i. + else + numstep = 2; // otherwise add 2. + Sci_PositionU chPos = 0; + for (Sci_PositionU j = i + numstep; j < lengthLine && IsAlphabetic(lineBuffer[j]) && chPos < sizeof(word) - 1; j++) + word[chPos++] = lineBuffer[j]; + word[chPos] = 0; + if (!CompareCaseInsensitive(word, "error") || !CompareCaseInsensitive(word, "warning") || + !CompareCaseInsensitive(word, "fatal") || !CompareCaseInsensitive(word, "catastrophic") || + !CompareCaseInsensitive(word, "note") || !CompareCaseInsensitive(word, "remark")) { + state = stMsVc; + } else { + state = stUnrecognized; + } + } else { + state = stUnrecognized; + } + } else if (state == stMsDigitComma) { // (, + if (ch == ')') { + state = stMsDotNet; + break; + } else if ((ch != ' ') && !Is0To9(ch)) { + state = stUnrecognized; + } + } else if (state == stCtagsStart) { + if (ch == '\t') { + state = stCtagsFile; + } + } else if (state == stCtagsFile) { + if ((lineBuffer[i - 1] == '\t') && + ((ch == '/' && chNext == '^') || Is0To9(ch))) { + state = stCtags; + break; + } else if ((ch == '/') && (chNext == '^')) { + state = stCtagsStartString; + } + } else if ((state == stCtagsStartString) && ((lineBuffer[i] == '$') && (lineBuffer[i + 1] == '/'))) { + state = stCtagsStringDollar; + break; + } + } + if (state == stGcc) { + return initialColonPart ? SCE_ERR_LUA : SCE_ERR_GCC; + } else if ((state == stMsVc) || (state == stMsDotNet)) { + return SCE_ERR_MS; + } else if ((state == stCtagsStringDollar) || (state == stCtags)) { + return SCE_ERR_CTAG; + } else if (initialColonPart && strstr(lineBuffer, ": warning C")) { + // Microsoft warning without line number + // : warning C9999 + return SCE_ERR_MS; + } else { + return SCE_ERR_DEFAULT; + } + } +} + +#define CSI "\033[" + +constexpr bool SequenceEnd(int ch) noexcept { + return (ch == 0) || ((ch >= '@') && (ch <= '~')); +} + +int StyleFromSequence(const char *seq) noexcept { + int bold = 0; + int colour = 0; + while (!SequenceEnd(*seq)) { + if (Is0To9(*seq)) { + int base = *seq - '0'; + if (Is0To9(seq[1])) { + base = base * 10; + base += seq[1] - '0'; + seq++; + } + if (base == 0) { + colour = 0; + bold = 0; + } + else if (base == 1) { + bold = 1; + } + else if (base >= 30 && base <= 37) { + colour = base - 30; + } + } + seq++; + } + return SCE_ERR_ES_BLACK + bold * 8 + colour; +} + +void ColouriseErrorListLine( + const std::string &lineBuffer, + Sci_PositionU endPos, + Accessor &styler, + bool valueSeparate, + bool escapeSequences) { + Sci_Position startValue = -1; + const Sci_PositionU lengthLine = lineBuffer.length(); + const int style = RecogniseErrorListLine(lineBuffer.c_str(), lengthLine, startValue); + if (escapeSequences && strstr(lineBuffer.c_str(), CSI)) { + const Sci_Position startPos = endPos - lengthLine; + const char *linePortion = lineBuffer.c_str(); + Sci_Position startPortion = startPos; + int portionStyle = style; + while (const char *startSeq = strstr(linePortion, CSI)) { + if (startSeq > linePortion) { + styler.ColourTo(startPortion + static_cast(startSeq - linePortion), portionStyle); + } + const char *endSeq = startSeq + 2; + while (!SequenceEnd(*endSeq)) + endSeq++; + const Sci_Position endSeqPosition = startPortion + static_cast(endSeq - linePortion) + 1; + switch (*endSeq) { + case 0: + styler.ColourTo(endPos, SCE_ERR_ESCSEQ_UNKNOWN); + return; + case 'm': // Colour command + styler.ColourTo(endSeqPosition, SCE_ERR_ESCSEQ); + portionStyle = StyleFromSequence(startSeq+2); + break; + case 'K': // Erase to end of line -> ignore + styler.ColourTo(endSeqPosition, SCE_ERR_ESCSEQ); + break; + default: + styler.ColourTo(endSeqPosition, SCE_ERR_ESCSEQ_UNKNOWN); + portionStyle = style; + } + startPortion = endSeqPosition; + linePortion = endSeq + 1; + } + styler.ColourTo(endPos, portionStyle); + } else { + if (valueSeparate && (startValue >= 0)) { + styler.ColourTo(endPos - (lengthLine - startValue), style); + styler.ColourTo(endPos, SCE_ERR_VALUE); + } else { + styler.ColourTo(endPos, style); + } + } +} + +void ColouriseErrorListDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { + std::string lineBuffer; + styler.StartAt(startPos); + styler.StartSegment(startPos); + + // property lexer.errorlist.value.separate + // For lines in the output pane that are matches from Find in Files or GCC-style + // diagnostics, style the path and line number separately from the rest of the + // line with style 21 used for the rest of the line. + // This allows matched text to be more easily distinguished from its location. + const bool valueSeparate = styler.GetPropertyInt("lexer.errorlist.value.separate", 0) != 0; + + // property lexer.errorlist.escape.sequences + // Set to 1 to interpret escape sequences. + const bool escapeSequences = styler.GetPropertyInt("lexer.errorlist.escape.sequences") != 0; + + for (Sci_PositionU i = startPos; i < startPos + length; i++) { + lineBuffer.push_back(styler[i]); + if (AtEOL(styler, i)) { + // End of line met, colourise it + ColouriseErrorListLine(lineBuffer, i, styler, valueSeparate, escapeSequences); + lineBuffer.clear(); + } + } + if (!lineBuffer.empty()) { // Last line does not have ending characters + ColouriseErrorListLine(lineBuffer, startPos + length - 1, styler, valueSeparate, escapeSequences); + } +} + +const char *const emptyWordListDesc[] = { + nullptr +}; + +} + +LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexFlagship.cxx b/Pythonwin/Scintilla/lexers/LexFlagship.cxx new file mode 100644 index 000000000..2dfb687aa --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexFlagship.cxx @@ -0,0 +1,352 @@ +// Scintilla source code edit control +/** @file LexFlagship.cxx + ** Lexer for Harbour and FlagShip. + ** (Syntactically compatible to other xBase dialects, like Clipper, dBase, Clip, FoxPro etc.) + **/ +// Copyright 2005 by Randy Butler +// Copyright 2010 by Xavi (Harbour) +// 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 "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" + +using namespace Scintilla; + +// Extended to accept accented characters +static inline bool IsAWordChar(int ch) +{ + return ch >= 0x80 || + (isalnum(ch) || ch == '_'); +} + +static void ColouriseFlagShipDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, + WordList *keywordlists[], Accessor &styler) +{ + + WordList &keywords = *keywordlists[0]; + WordList &keywords2 = *keywordlists[1]; + WordList &keywords3 = *keywordlists[2]; + WordList &keywords4 = *keywordlists[3]; + WordList &keywords5 = *keywordlists[4]; + + // property lexer.flagship.styling.within.preprocessor + // For Harbour code, determines whether all preprocessor code is styled in the preprocessor style (0) or only from the + // initial # to the end of the command word(1, the default). It also determines how to present text, dump, and disabled code. + bool stylingWithinPreprocessor = styler.GetPropertyInt("lexer.flagship.styling.within.preprocessor", 1) != 0; + + CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]"); + + int visibleChars = 0; + int closeStringChar = 0; + int styleBeforeDCKeyword = SCE_FS_DEFAULT; + bool bEnableCode = initStyle < SCE_FS_DISABLEDCODE; + + StyleContext sc(startPos, length, initStyle, styler); + + for (; sc.More(); sc.Forward()) { + + // Determine if the current state should terminate. + switch (sc.state) { + case SCE_FS_OPERATOR: + case SCE_FS_OPERATOR_C: + case SCE_FS_WORDOPERATOR: + sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + break; + case SCE_FS_IDENTIFIER: + case SCE_FS_IDENTIFIER_C: + if (!IsAWordChar(sc.ch)) { + char s[64]; + sc.GetCurrentLowered(s, sizeof(s)); + if (keywords.InList(s)) { + sc.ChangeState(bEnableCode ? SCE_FS_KEYWORD : SCE_FS_KEYWORD_C); + } else if (keywords2.InList(s)) { + sc.ChangeState(bEnableCode ? SCE_FS_KEYWORD2 : SCE_FS_KEYWORD2_C); + } else if (bEnableCode && keywords3.InList(s)) { + sc.ChangeState(SCE_FS_KEYWORD3); + } else if (bEnableCode && keywords4.InList(s)) { + sc.ChangeState(SCE_FS_KEYWORD4); + }// Else, it is really an identifier... + sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } + break; + case SCE_FS_NUMBER: + if (!IsAWordChar(sc.ch) && !(sc.ch == '.' && IsADigit(sc.chNext))) { + sc.SetState(SCE_FS_DEFAULT); + } + break; + case SCE_FS_NUMBER_C: + if (!IsAWordChar(sc.ch) && sc.ch != '.') { + sc.SetState(SCE_FS_DEFAULT_C); + } + break; + case SCE_FS_CONSTANT: + if (!IsAWordChar(sc.ch)) { + sc.SetState(SCE_FS_DEFAULT); + } + break; + case SCE_FS_STRING: + case SCE_FS_STRING_C: + if (sc.ch == closeStringChar) { + sc.ForwardSetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } else if (sc.atLineEnd) { + sc.ChangeState(bEnableCode ? SCE_FS_STRINGEOL : SCE_FS_STRINGEOL_C); + } + break; + case SCE_FS_STRINGEOL: + case SCE_FS_STRINGEOL_C: + if (sc.atLineStart) { + sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } + break; + case SCE_FS_COMMENTDOC: + case SCE_FS_COMMENTDOC_C: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = bEnableCode ? SCE_FS_COMMENTDOC : SCE_FS_COMMENTDOC_C; + sc.SetState(SCE_FS_COMMENTDOCKEYWORD); + } + } + break; + case SCE_FS_COMMENT: + case SCE_FS_COMMENTLINE: + if (sc.atLineStart) { + sc.SetState(SCE_FS_DEFAULT); + } + break; + case SCE_FS_COMMENTLINEDOC: + case SCE_FS_COMMENTLINEDOC_C: + if (sc.atLineStart) { + sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = bEnableCode ? SCE_FS_COMMENTLINEDOC : SCE_FS_COMMENTLINEDOC_C; + sc.SetState(SCE_FS_COMMENTDOCKEYWORD); + } + } + break; + case SCE_FS_COMMENTDOCKEYWORD: + if ((styleBeforeDCKeyword == SCE_FS_COMMENTDOC || styleBeforeDCKeyword == SCE_FS_COMMENTDOC_C) && + sc.Match('*', '/')) { + sc.ChangeState(SCE_FS_COMMENTDOCKEYWORDERROR); + sc.Forward(); + sc.ForwardSetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } else if (!setDoxygen.Contains(sc.ch)) { + char s[64]; + sc.GetCurrentLowered(s, sizeof(s)); + if (!IsASpace(sc.ch) || !keywords5.InList(s + 1)) { + sc.ChangeState(SCE_FS_COMMENTDOCKEYWORDERROR); + } + sc.SetState(styleBeforeDCKeyword); + } + break; + case SCE_FS_PREPROCESSOR: + case SCE_FS_PREPROCESSOR_C: + if (sc.atLineEnd) { + if (!(sc.chPrev == ';' || sc.GetRelative(-2) == ';')) { + sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } + } else if (stylingWithinPreprocessor) { + if (IsASpaceOrTab(sc.ch)) { + sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } + } else if (sc.Match('/', '*') || sc.Match('/', '/') || sc.Match('&', '&')) { + sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } + break; + case SCE_FS_DISABLEDCODE: + if (sc.ch == '#' && visibleChars == 0) { + sc.SetState(bEnableCode ? SCE_FS_PREPROCESSOR : SCE_FS_PREPROCESSOR_C); + do { // Skip whitespace between # and preprocessor word + sc.Forward(); + } while (IsASpaceOrTab(sc.ch) && sc.More()); + if (sc.MatchIgnoreCase("pragma")) { + sc.Forward(6); + do { // Skip more whitespace until keyword + sc.Forward(); + } while (IsASpaceOrTab(sc.ch) && sc.More()); + if (sc.MatchIgnoreCase("enddump") || sc.MatchIgnoreCase("__endtext")) { + bEnableCode = true; + sc.SetState(SCE_FS_DISABLEDCODE); + sc.Forward(sc.ch == '_' ? 8 : 6); + sc.ForwardSetState(SCE_FS_DEFAULT); + } else { + sc.ChangeState(SCE_FS_DISABLEDCODE); + } + } else { + sc.ChangeState(SCE_FS_DISABLEDCODE); + } + } + break; + case SCE_FS_DATE: + if (sc.ch == '}') { + sc.ForwardSetState(SCE_FS_DEFAULT); + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_FS_STRINGEOL); + } + } + + // Determine if a new state should be entered. + if (sc.state == SCE_FS_DEFAULT || sc.state == SCE_FS_DEFAULT_C) { + if (bEnableCode && + (sc.MatchIgnoreCase(".and.") || sc.MatchIgnoreCase(".not."))) { + sc.SetState(SCE_FS_WORDOPERATOR); + sc.Forward(4); + } else if (bEnableCode && sc.MatchIgnoreCase(".or.")) { + sc.SetState(SCE_FS_WORDOPERATOR); + sc.Forward(3); + } else if (bEnableCode && + (sc.MatchIgnoreCase(".t.") || sc.MatchIgnoreCase(".f.") || + (!IsAWordChar(sc.GetRelative(3)) && sc.MatchIgnoreCase("nil")))) { + sc.SetState(SCE_FS_CONSTANT); + sc.Forward(2); + } else if (sc.Match('/', '*')) { + sc.SetState(bEnableCode ? SCE_FS_COMMENTDOC : SCE_FS_COMMENTDOC_C); + sc.Forward(); + } else if (bEnableCode && sc.Match('&', '&')) { + sc.SetState(SCE_FS_COMMENTLINE); + sc.Forward(); + } else if (sc.Match('/', '/')) { + sc.SetState(bEnableCode ? SCE_FS_COMMENTLINEDOC : SCE_FS_COMMENTLINEDOC_C); + sc.Forward(); + } else if (bEnableCode && sc.ch == '*' && visibleChars == 0) { + sc.SetState(SCE_FS_COMMENT); + } else if (sc.ch == '\"' || sc.ch == '\'') { + sc.SetState(bEnableCode ? SCE_FS_STRING : SCE_FS_STRING_C); + closeStringChar = sc.ch; + } else if (closeStringChar == '>' && sc.ch == '<') { + sc.SetState(bEnableCode ? SCE_FS_STRING : SCE_FS_STRING_C); + } else if (sc.ch == '#' && visibleChars == 0) { + sc.SetState(bEnableCode ? SCE_FS_PREPROCESSOR : SCE_FS_PREPROCESSOR_C); + do { // Skip whitespace between # and preprocessor word + sc.Forward(); + } while (IsASpaceOrTab(sc.ch) && sc.More()); + if (sc.atLineEnd) { + sc.SetState(bEnableCode ? SCE_FS_DEFAULT : SCE_FS_DEFAULT_C); + } else if (sc.MatchIgnoreCase("include")) { + if (stylingWithinPreprocessor) { + closeStringChar = '>'; + } + } else if (sc.MatchIgnoreCase("pragma")) { + sc.Forward(6); + do { // Skip more whitespace until keyword + sc.Forward(); + } while (IsASpaceOrTab(sc.ch) && sc.More()); + if (sc.MatchIgnoreCase("begindump") || sc.MatchIgnoreCase("__cstream")) { + bEnableCode = false; + if (stylingWithinPreprocessor) { + sc.SetState(SCE_FS_DISABLEDCODE); + sc.Forward(8); + sc.ForwardSetState(SCE_FS_DEFAULT_C); + } else { + sc.SetState(SCE_FS_DISABLEDCODE); + } + } else if (sc.MatchIgnoreCase("enddump") || sc.MatchIgnoreCase("__endtext")) { + bEnableCode = true; + sc.SetState(SCE_FS_DISABLEDCODE); + sc.Forward(sc.ch == '_' ? 8 : 6); + sc.ForwardSetState(SCE_FS_DEFAULT); + } + } + } else if (bEnableCode && sc.ch == '{') { + Sci_Position p = 0; + int chSeek; + Sci_PositionU endPos(startPos + length); + do { // Skip whitespace + chSeek = sc.GetRelative(++p); + } while (IsASpaceOrTab(chSeek) && (sc.currentPos + p < endPos)); + if (chSeek == '^') { + sc.SetState(SCE_FS_DATE); + } else { + sc.SetState(SCE_FS_OPERATOR); + } + } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { + sc.SetState(bEnableCode ? SCE_FS_NUMBER : SCE_FS_NUMBER_C); + } else if (IsAWordChar(sc.ch)) { + sc.SetState(bEnableCode ? SCE_FS_IDENTIFIER : SCE_FS_IDENTIFIER_C); + } else if (isoperator(static_cast(sc.ch)) || (bEnableCode && sc.ch == '@')) { + sc.SetState(bEnableCode ? SCE_FS_OPERATOR : SCE_FS_OPERATOR_C); + } + } + + if (sc.atLineEnd) { + visibleChars = 0; + closeStringChar = 0; + } + if (!IsASpace(sc.ch)) { + visibleChars++; + } + } + sc.Complete(); +} + +static void FoldFlagShipDoc(Sci_PositionU startPos, Sci_Position length, int, + WordList *[], Accessor &styler) +{ + + Sci_Position endPos = startPos + length; + + // Backtrack to previous line in case need to fix its fold status + Sci_Position lineCurrent = styler.GetLine(startPos); + if (startPos > 0 && lineCurrent > 0) { + lineCurrent--; + startPos = styler.LineStart(lineCurrent); + } + int spaceFlags = 0; + int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags); + char chNext = styler[startPos]; + for (Sci_Position i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + + if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == endPos-1)) { + int lev = indentCurrent; + int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags); + if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { + if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) { + lev |= SC_FOLDLEVELHEADERFLAG; + } else if (indentNext & SC_FOLDLEVELWHITEFLAG) { + int spaceFlags2 = 0; + int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2); + if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) { + lev |= SC_FOLDLEVELHEADERFLAG; + } + } + } + indentCurrent = indentNext; + styler.SetLevel(lineCurrent, lev); + lineCurrent++; + } + } +} + +static const char * const FSWordListDesc[] = { + "Keywords Commands", + "Std Library Functions", + "Procedure, return, exit", + "Class (oop)", + "Doxygen keywords", + 0 +}; + +LexerModule lmFlagShip(SCLEX_FLAGSHIP, ColouriseFlagShipDoc, "flagship", FoldFlagShipDoc, FSWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexForth.cxx b/Pythonwin/Scintilla/lexers/LexForth.cxx new file mode 100644 index 000000000..80842097d --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexForth.cxx @@ -0,0 +1,168 @@ +// Scintilla source code edit control +/** @file LexForth.cxx + ** Lexer for FORTH + **/ +// 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 "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" + +using namespace Scintilla; + +static inline bool IsAWordStart(int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); +} + +static inline bool IsANumChar(int ch) { + return (ch < 0x80) && (isxdigit(ch) || ch == '.' || ch == 'e' || ch == 'E' ); +} + +static inline bool IsASpaceChar(int ch) { + return (ch < 0x80) && isspace(ch); +} + +static void ColouriseForthDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordLists[], + Accessor &styler) { + + WordList &control = *keywordLists[0]; + WordList &keyword = *keywordLists[1]; + WordList &defword = *keywordLists[2]; + WordList &preword1 = *keywordLists[3]; + WordList &preword2 = *keywordLists[4]; + WordList &strings = *keywordLists[5]; + + StyleContext sc(startPos, length, initStyle, styler); + + for (; sc.More(); sc.Forward()) + { + // Determine if the current state should terminate. + if (sc.state == SCE_FORTH_COMMENT) { + if (sc.atLineEnd) { + sc.SetState(SCE_FORTH_DEFAULT); + } + }else if (sc.state == SCE_FORTH_COMMENT_ML) { + if (sc.ch == ')') { + sc.ForwardSetState(SCE_FORTH_DEFAULT); + } + }else if (sc.state == SCE_FORTH_IDENTIFIER || sc.state == SCE_FORTH_NUMBER) { + // handle numbers here too, because what we thought was a number might + // turn out to be a keyword e.g. 2DUP + if (IsASpaceChar(sc.ch) ) { + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + int newState = sc.state == SCE_FORTH_NUMBER ? SCE_FORTH_NUMBER : SCE_FORTH_DEFAULT; + if (control.InList(s)) { + sc.ChangeState(SCE_FORTH_CONTROL); + } else if (keyword.InList(s)) { + sc.ChangeState(SCE_FORTH_KEYWORD); + } else if (defword.InList(s)) { + sc.ChangeState(SCE_FORTH_DEFWORD); + } else if (preword1.InList(s)) { + sc.ChangeState(SCE_FORTH_PREWORD1); + } else if (preword2.InList(s)) { + sc.ChangeState(SCE_FORTH_PREWORD2); + } else if (strings.InList(s)) { + sc.ChangeState(SCE_FORTH_STRING); + newState = SCE_FORTH_STRING; + } + sc.SetState(newState); + } + if (sc.state == SCE_FORTH_NUMBER) { + if (IsASpaceChar(sc.ch)) { + sc.SetState(SCE_FORTH_DEFAULT); + } else if (!IsANumChar(sc.ch)) { + sc.ChangeState(SCE_FORTH_IDENTIFIER); + } + } + }else if (sc.state == SCE_FORTH_STRING) { + if (sc.ch == '\"') { + sc.ForwardSetState(SCE_FORTH_DEFAULT); + } + }else if (sc.state == SCE_FORTH_LOCALE) { + if (sc.ch == '}') { + sc.ForwardSetState(SCE_FORTH_DEFAULT); + } + }else if (sc.state == SCE_FORTH_DEFWORD) { + if (IsASpaceChar(sc.ch)) { + sc.SetState(SCE_FORTH_DEFAULT); + } + } + + // Determine if a new state should be entered. + if (sc.state == SCE_FORTH_DEFAULT) { + if (sc.ch == '\\'){ + sc.SetState(SCE_FORTH_COMMENT); + } else if (sc.ch == '(' && + (sc.atLineStart || IsASpaceChar(sc.chPrev)) && + (sc.atLineEnd || IsASpaceChar(sc.chNext))) { + sc.SetState(SCE_FORTH_COMMENT_ML); + } else if ( (sc.ch == '$' && (IsASCII(sc.chNext) && isxdigit(sc.chNext))) ) { + // number starting with $ is a hex number + sc.SetState(SCE_FORTH_NUMBER); + while(sc.More() && IsASCII(sc.chNext) && isxdigit(sc.chNext)) + sc.Forward(); + } else if ( (sc.ch == '%' && (IsASCII(sc.chNext) && (sc.chNext == '0' || sc.chNext == '1'))) ) { + // number starting with % is binary + sc.SetState(SCE_FORTH_NUMBER); + while(sc.More() && IsASCII(sc.chNext) && (sc.chNext == '0' || sc.chNext == '1')) + sc.Forward(); + } else if ( IsASCII(sc.ch) && + (isxdigit(sc.ch) || ((sc.ch == '.' || sc.ch == '-') && IsASCII(sc.chNext) && isxdigit(sc.chNext)) ) + ){ + sc.SetState(SCE_FORTH_NUMBER); + } else if (IsAWordStart(sc.ch)) { + sc.SetState(SCE_FORTH_IDENTIFIER); + } else if (sc.ch == '{') { + sc.SetState(SCE_FORTH_LOCALE); + } else if (sc.ch == ':' && IsASCII(sc.chNext) && isspace(sc.chNext)) { + // highlight word definitions e.g. : GCD ( n n -- n ) ..... ; + // ^ ^^^ + sc.SetState(SCE_FORTH_DEFWORD); + while(sc.More() && IsASCII(sc.chNext) && isspace(sc.chNext)) + sc.Forward(); + } else if (sc.ch == ';' && + (sc.atLineStart || IsASpaceChar(sc.chPrev)) && + (sc.atLineEnd || IsASpaceChar(sc.chNext)) ) { + // mark the ';' that ends a word + sc.SetState(SCE_FORTH_DEFWORD); + sc.ForwardSetState(SCE_FORTH_DEFAULT); + } + } + + } + sc.Complete(); +} + +static void FoldForthDoc(Sci_PositionU, Sci_Position, int, WordList *[], + Accessor &) { +} + +static const char * const forthWordLists[] = { + "control keywords", + "keywords", + "definition words", + "prewords with one argument", + "prewords with two arguments", + "string definition keywords", + 0, + }; + +LexerModule lmForth(SCLEX_FORTH, ColouriseForthDoc, "forth", FoldForthDoc, forthWordLists); + + diff --git a/Pythonwin/Scintilla/lexers/LexFortran.cxx b/Pythonwin/Scintilla/lexers/LexFortran.cxx new file mode 100644 index 000000000..28298b3ed --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexFortran.cxx @@ -0,0 +1,721 @@ +// Scintilla source code edit control +/** @file LexFortran.cxx + ** Lexer for Fortran. + ** Written by Chuan-jian Shen, Last changed Sep. 2003 + **/ +// 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 "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" +/***************************************/ + +using namespace Scintilla; + +/***********************************************/ +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '%'); +} +/**********************************************/ +static inline bool IsAWordStart(const int ch) { + return (ch < 0x80) && (isalnum(ch)); +} +/***************************************/ +static inline bool IsABlank(unsigned int ch) { + return (ch == ' ') || (ch == 0x09) || (ch == 0x0b) ; +} +/***************************************/ +static inline bool IsALineEnd(char ch) { + return ((ch == '\n') || (ch == '\r')) ; +} +/***************************************/ +static Sci_PositionU GetContinuedPos(Sci_PositionU pos, Accessor &styler) { + while (!IsALineEnd(styler.SafeGetCharAt(pos++))) continue; + if (styler.SafeGetCharAt(pos) == '\n') pos++; + while (IsABlank(styler.SafeGetCharAt(pos++))) continue; + char chCur = styler.SafeGetCharAt(pos); + if (chCur == '&') { + while (IsABlank(styler.SafeGetCharAt(++pos))) continue; + return pos; + } else { + return pos; + } +} +/***************************************/ +static void ColouriseFortranDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, + WordList *keywordlists[], Accessor &styler, bool isFixFormat) { + WordList &keywords = *keywordlists[0]; + WordList &keywords2 = *keywordlists[1]; + WordList &keywords3 = *keywordlists[2]; + /***************************************/ + Sci_Position posLineStart = 0; + int numNonBlank = 0, prevState = 0; + Sci_Position endPos = startPos + length; + /***************************************/ + // backtrack to the nearest keyword + while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_F_WORD)) { + startPos--; + } + startPos = styler.LineStart(styler.GetLine(startPos)); + initStyle = styler.StyleAt(startPos - 1); + StyleContext sc(startPos, endPos-startPos, initStyle, styler); + /***************************************/ + for (; sc.More(); sc.Forward()) { + // remember the start position of the line + if (sc.atLineStart) { + posLineStart = sc.currentPos; + numNonBlank = 0; + sc.SetState(SCE_F_DEFAULT); + } + if (!IsASpaceOrTab(sc.ch)) numNonBlank ++; + /***********************************************/ + // Handle the fix format generically + Sci_Position toLineStart = sc.currentPos - posLineStart; + if (isFixFormat && (toLineStart < 6 || toLineStart >= 72)) { + if ((toLineStart == 0 && (tolower(sc.ch) == 'c' || sc.ch == '*')) || sc.ch == '!') { + if (sc.MatchIgnoreCase("cdec$") || sc.MatchIgnoreCase("*dec$") || sc.MatchIgnoreCase("!dec$") || + sc.MatchIgnoreCase("cdir$") || sc.MatchIgnoreCase("*dir$") || sc.MatchIgnoreCase("!dir$") || + sc.MatchIgnoreCase("cms$") || sc.MatchIgnoreCase("*ms$") || sc.MatchIgnoreCase("!ms$") || + sc.chNext == '$') { + sc.SetState(SCE_F_PREPROCESSOR); + } else { + sc.SetState(SCE_F_COMMENT); + } + + while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end + } else if (toLineStart >= 72) { + sc.SetState(SCE_F_COMMENT); + while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end + } else if (toLineStart < 5) { + if (IsADigit(sc.ch)) + sc.SetState(SCE_F_LABEL); + else + sc.SetState(SCE_F_DEFAULT); + } else if (toLineStart == 5) { + //if (!IsASpace(sc.ch) && sc.ch != '0') { + if (sc.ch != '\r' && sc.ch != '\n') { + sc.SetState(SCE_F_CONTINUATION); + if (!IsASpace(sc.ch) && sc.ch != '0') + sc.ForwardSetState(prevState); + } else + sc.SetState(SCE_F_DEFAULT); + } + continue; + } + /***************************************/ + // Handle line continuation generically. + if (!isFixFormat && sc.ch == '&' && sc.state != SCE_F_COMMENT) { + char chTemp = ' '; + Sci_Position j = 1; + while (IsABlank(chTemp) && j<132) { + chTemp = static_cast(sc.GetRelative(j)); + j++; + } + if (chTemp == '!') { + sc.SetState(SCE_F_CONTINUATION); + if (sc.chNext == '!') sc.ForwardSetState(SCE_F_COMMENT); + } else if (chTemp == '\r' || chTemp == '\n') { + int currentState = sc.state; + sc.SetState(SCE_F_CONTINUATION); + sc.ForwardSetState(SCE_F_DEFAULT); + while (IsASpace(sc.ch) && sc.More()) { + sc.Forward(); + if (sc.atLineStart) numNonBlank = 0; + if (!IsASpaceOrTab(sc.ch)) numNonBlank ++; + } + if (sc.ch == '&') { + sc.SetState(SCE_F_CONTINUATION); + sc.Forward(); + } + sc.SetState(currentState); + } + } + /***************************************/ + // Hanndle preprocessor directives + if (sc.ch == '#' && numNonBlank == 1) + { + sc.SetState(SCE_F_PREPROCESSOR); + while (!sc.atLineEnd && sc.More()) + sc.Forward(); // Until line end + } + /***************************************/ + // Determine if the current state should terminate. + if (sc.state == SCE_F_OPERATOR) { + sc.SetState(SCE_F_DEFAULT); + } else if (sc.state == SCE_F_NUMBER) { + if (!(IsAWordChar(sc.ch) || sc.ch=='\'' || sc.ch=='\"' || sc.ch=='.')) { + sc.SetState(SCE_F_DEFAULT); + } + } else if (sc.state == SCE_F_IDENTIFIER) { + if (!IsAWordChar(sc.ch) || (sc.ch == '%')) { + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + if (keywords.InList(s)) { + sc.ChangeState(SCE_F_WORD); + } else if (keywords2.InList(s)) { + sc.ChangeState(SCE_F_WORD2); + } else if (keywords3.InList(s)) { + sc.ChangeState(SCE_F_WORD3); + } + sc.SetState(SCE_F_DEFAULT); + } + } else if (sc.state == SCE_F_COMMENT || sc.state == SCE_F_PREPROCESSOR) { + if (sc.ch == '\r' || sc.ch == '\n') { + sc.SetState(SCE_F_DEFAULT); + } + } else if (sc.state == SCE_F_STRING1) { + prevState = sc.state; + if (sc.ch == '\'') { + if (sc.chNext == '\'') { + sc.Forward(); + } else { + sc.ForwardSetState(SCE_F_DEFAULT); + prevState = SCE_F_DEFAULT; + } + } else if (sc.atLineEnd) { + sc.ChangeState(SCE_F_STRINGEOL); + sc.ForwardSetState(SCE_F_DEFAULT); + } + } else if (sc.state == SCE_F_STRING2) { + prevState = sc.state; + if (sc.atLineEnd) { + sc.ChangeState(SCE_F_STRINGEOL); + sc.ForwardSetState(SCE_F_DEFAULT); + } else if (sc.ch == '\"') { + if (sc.chNext == '\"') { + sc.Forward(); + } else { + sc.ForwardSetState(SCE_F_DEFAULT); + prevState = SCE_F_DEFAULT; + } + } + } else if (sc.state == SCE_F_OPERATOR2) { + if (sc.ch == '.') { + sc.ForwardSetState(SCE_F_DEFAULT); + } + } else if (sc.state == SCE_F_CONTINUATION) { + sc.SetState(SCE_F_DEFAULT); + } else if (sc.state == SCE_F_LABEL) { + if (!IsADigit(sc.ch)) { + sc.SetState(SCE_F_DEFAULT); + } else { + if (isFixFormat && sc.currentPos-posLineStart > 4) + sc.SetState(SCE_F_DEFAULT); + else if (numNonBlank > 5) + sc.SetState(SCE_F_DEFAULT); + } + } + /***************************************/ + // Determine if a new state should be entered. + if (sc.state == SCE_F_DEFAULT) { + if (sc.ch == '!') { + if (sc.MatchIgnoreCase("!dec$") || sc.MatchIgnoreCase("!dir$") || + sc.MatchIgnoreCase("!ms$") || sc.chNext == '$') { + sc.SetState(SCE_F_PREPROCESSOR); + } else { + sc.SetState(SCE_F_COMMENT); + } + } else if ((!isFixFormat) && IsADigit(sc.ch) && numNonBlank == 1) { + sc.SetState(SCE_F_LABEL); + } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { + sc.SetState(SCE_F_NUMBER); + } else if ((tolower(sc.ch) == 'b' || tolower(sc.ch) == 'o' || + tolower(sc.ch) == 'z') && (sc.chNext == '\"' || sc.chNext == '\'')) { + sc.SetState(SCE_F_NUMBER); + sc.Forward(); + } else if (sc.ch == '.' && isalpha(sc.chNext)) { + sc.SetState(SCE_F_OPERATOR2); + } else if (IsAWordStart(sc.ch)) { + sc.SetState(SCE_F_IDENTIFIER); + } else if (sc.ch == '\"') { + sc.SetState(SCE_F_STRING2); + } else if (sc.ch == '\'') { + sc.SetState(SCE_F_STRING1); + } else if (isoperator(static_cast(sc.ch))) { + sc.SetState(SCE_F_OPERATOR); + } + } + } + sc.Complete(); +} +/***************************************/ +static void CheckLevelCommentLine(const unsigned int nComL, + Sci_Position nComColB[], Sci_Position nComColF[], Sci_Position &nComCur, + bool comLineB[], bool comLineF[], bool &comLineCur, + int &levelDeltaNext) { + levelDeltaNext = 0; + if (!comLineCur) { + return; + } + + if (!comLineF[0] || nComColF[0] != nComCur) { + unsigned int i=0; + for (; i= nLineTotal) { + return; + } + + for (int i=nComL-2; i>=0; i--) { + nComColB[i+1] = nComColB[i]; + comLineB[i+1] = comLineB[i]; + } + nComColB[0] = nComCur; + comLineB[0] = comLineCur; + nComCur = nComColF[0]; + comLineCur = comLineF[0]; + for (unsigned int i=0; i+1 0) { + lineCurrent--; + startPos = styler.LineStart(lineCurrent); + isPrevLine = true; + } else { + isPrevLine = false; + } + char chNext = styler[startPos]; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + int levelDeltaNext = 0; + + const unsigned int nComL = 3; // defines how many comment lines should be before they are folded + Sci_Position nComColB[nComL] = {}; + Sci_Position nComColF[nComL] = {}; + Sci_Position nComCur = 0; + bool comLineB[nComL] = {}; + bool comLineF[nComL] = {}; + bool comLineCur; + Sci_Position nLineTotal = styler.GetLine(styler.Length()-1) + 1; + if (foldComment) { + for (unsigned int i=0; i= nLineTotal) { + comLineF[i] = false; + break; + } + GetIfLineComment(styler, isFixFormat, chL, comLineF[i], nComColF[i]); + } + GetIfLineComment(styler, isFixFormat, lineCurrent, comLineCur, nComCur); + CheckBackComLines(styler, isFixFormat, lineCurrent, nComL, nComColB, nComColF, nComCur, + comLineB, comLineF, comLineCur); + } + int levelCurrent = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; + + /***************************************/ + Sci_Position lastStart = 0; + char prevWord[32] = ""; + /***************************************/ + for (Sci_PositionU i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + char chNextNonBlank = chNext; + bool nextEOL = false; + if (IsALineEnd(chNextNonBlank)) { + nextEOL = true; + } + Sci_PositionU j=i+1; + while(IsABlank(chNextNonBlank) && j(tolower(styler[lastStart+k])); + } + s[k] = '\0'; + // Handle the forall and where statement and structure. + if (strcmp(s, "forall") == 0 || (strcmp(s, "where") == 0 && strcmp(prevWord, "else") != 0)) { + if (strcmp(prevWord, "end") != 0) { + j = i + 1; + char chBrace = '(', chSeek = ')', ch1 = styler.SafeGetCharAt(j); + // Find the position of the first ( + while (ch1 != chBrace && j 0) && (visibleChars > 0)) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) + styler.SetLevel(lineCurrent, lev); + + lineCurrent++; + levelCurrent += levelDeltaNext; + levelDeltaNext = 0; + visibleChars = 0; + strcpy(prevWord, ""); + isPrevLine = false; + + if (foldComment) { + StepCommentLine(styler, isFixFormat, lineCurrent, nComL, nComColB, nComColF, nComCur, + comLineB, comLineF, comLineCur); + } + } + /***************************************/ + if (!isspacechar(ch)) visibleChars++; + } + /***************************************/ +} +/***************************************/ +static const char * const FortranWordLists[] = { + "Primary keywords and identifiers", + "Intrinsic functions", + "Extended and user defined functions", + 0, +}; +/***************************************/ +static void ColouriseFortranDocFreeFormat(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], + Accessor &styler) { + ColouriseFortranDoc(startPos, length, initStyle, keywordlists, styler, false); +} +/***************************************/ +static void ColouriseFortranDocFixFormat(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], + Accessor &styler) { + ColouriseFortranDoc(startPos, length, initStyle, keywordlists, styler, true); +} +/***************************************/ +static void FoldFortranDocFreeFormat(Sci_PositionU startPos, Sci_Position length, int initStyle, + WordList *[], Accessor &styler) { + FoldFortranDoc(startPos, length, initStyle,styler, false); +} +/***************************************/ +static void FoldFortranDocFixFormat(Sci_PositionU startPos, Sci_Position length, int initStyle, + WordList *[], Accessor &styler) { + FoldFortranDoc(startPos, length, initStyle,styler, true); +} +/***************************************/ +LexerModule lmFortran(SCLEX_FORTRAN, ColouriseFortranDocFreeFormat, "fortran", FoldFortranDocFreeFormat, FortranWordLists); +LexerModule lmF77(SCLEX_F77, ColouriseFortranDocFixFormat, "f77", FoldFortranDocFixFormat, FortranWordLists); diff --git a/Pythonwin/Scintilla/src/LexGAP.cxx b/Pythonwin/Scintilla/lexers/LexGAP.cxx similarity index 89% rename from Pythonwin/Scintilla/src/LexGAP.cxx rename to Pythonwin/Scintilla/lexers/LexGAP.cxx index 25bd33b90..a2eca95ab 100644 --- a/Pythonwin/Scintilla/src/LexGAP.cxx +++ b/Pythonwin/Scintilla/lexers/LexGAP.cxx @@ -8,25 +8,26 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif static inline bool IsGAPOperator(char ch) { - if (isalnum(ch)) return false; + if (IsASCII(ch) && isalnum(ch)) return false; if (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '^' || ch == ',' || ch == '!' || ch == '.' || ch == '=' || ch == '<' || ch == '>' || ch == '(' || @@ -36,8 +37,8 @@ static inline bool IsGAPOperator(char ch) { return false; } -static void GetRange(unsigned int start, unsigned int end, Accessor &styler, char *s, unsigned int len) { - unsigned int i = 0; +static void GetRange(Sci_PositionU start, Sci_PositionU end, Accessor &styler, char *s, Sci_PositionU len) { + Sci_PositionU i = 0; while ((i < end - start + 1) && (i < len-1)) { s[i] = static_cast(styler[start + i]); i++; @@ -45,7 +46,7 @@ static void GetRange(unsigned int start, unsigned int end, Accessor &styler, cha s[i] = '\0'; } -static void ColouriseGAPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { +static void ColouriseGAPDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords1 = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; @@ -194,19 +195,19 @@ static int ClassifyFoldPointGAP(const char* s) { return level; } -static void FoldGAPDoc( unsigned int startPos, int length, int initStyle, WordList** , Accessor &styler) { - unsigned int endPos = startPos + length; +static void FoldGAPDoc( Sci_PositionU startPos, Sci_Position length, int initStyle, WordList** , Accessor &styler) { + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + 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; - int lastStart = 0; + Sci_Position lastStart = 0; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; diff --git a/Pythonwin/Scintilla/src/LexGui4Cli.cxx b/Pythonwin/Scintilla/lexers/LexGui4Cli.cxx similarity index 91% rename from Pythonwin/Scintilla/src/LexGui4Cli.cxx rename to Pythonwin/Scintilla/lexers/LexGui4Cli.cxx index 1c92de72e..664fa4f2f 100644 --- a/Pythonwin/Scintilla/src/LexGui4Cli.cxx +++ b/Pythonwin/Scintilla/lexers/LexGui4Cli.cxx @@ -1,13 +1,14 @@ // Scintilla source code edit control // Copyright 1998-2002 by Neil Hodgson +// @file LexGui4Cli.cxx /* This is the Lexer for Gui4Cli, included in SciLexer.dll - by d. Keletsekis, 2/10/2003 To add to SciLexer.dll: 1. Add the values below to INCLUDE\Scintilla.iface -2. Run the include/HFacer.py script -3. Run the src/lexGen.py script +2. Run the scripts/HFacer.py script +3. Run the scripts/LexGen.py script val SCE_GC_DEFAULT=0 val SCE_GC_COMMENTLINE=1 @@ -23,22 +24,23 @@ val SCE_GC_OPERATOR=9 #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif #define debug Platform::DebugPrintf @@ -46,10 +48,6 @@ static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch =='\\'); } -static inline bool IsAWordStart(const int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); -} - inline bool isGCOperator(int ch) { if (isalnum(ch)) return false; @@ -69,9 +67,9 @@ inline bool isGCOperator(int ch) #define isFoldPoint(x) ((styler.LevelAt(x) & SC_FOLDLEVELNUMBERMASK) == 1024) static void colorFirstWord(WordList *keywordlists[], Accessor &styler, - StyleContext *sc, char *buff, int length, int) + StyleContext *sc, char *buff, Sci_Position length, Sci_Position) { - int c = 0; + Sci_Position c = 0; while (sc->More() && isSpaceOrNL(sc->ch)) { sc->Forward(); } @@ -120,12 +118,13 @@ static void colorFirstWord(WordList *keywordlists[], Accessor &styler, // Main colorizing function called by Scintilla static void -ColouriseGui4CliDoc(unsigned int startPos, int length, int initStyle, +ColouriseGui4CliDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { styler.StartAt(startPos); - int quotestart = 0, oldstate, currentline = styler.GetLine(startPos); + Sci_Position currentline = styler.GetLine(startPos); + int quotestart = 0, oldstate; styler.StartSegment(startPos); bool noforward; char buff[BUFFSIZE+1]; // buffer for command name @@ -244,20 +243,20 @@ ColouriseGui4CliDoc(unsigned int startPos, int length, int initStyle, } // Main folding function called by Scintilla - (based on props (.ini) files function) -static void FoldGui4Cli(unsigned int startPos, int length, int, +static void FoldGui4Cli(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); bool headerPoint = false; - for (unsigned int i = startPos; i < endPos; i++) + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler[i+1]; diff --git a/Pythonwin/Scintilla/src/LexHTML.cxx b/Pythonwin/Scintilla/lexers/LexHTML.cxx similarity index 57% rename from Pythonwin/Scintilla/src/LexHTML.cxx rename to Pythonwin/Scintilla/lexers/LexHTML.cxx index 6d16c53f9..c6042f2b6 100644 --- a/Pythonwin/Scintilla/src/LexHTML.cxx +++ b/Pythonwin/Scintilla/lexers/LexHTML.cxx @@ -7,23 +7,29 @@ #include #include -#include #include #include +#include +#include +#include +#include +#include -#include "Platform.h" - -#include "PropSet.h" -#include "Accessor.h" -#include "StyleContext.h" -#include "KeyWords.h" +#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" +#include "OptionSet.h" +#include "DefaultLexer.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif + +namespace { #define SCE_HA_JS (SCE_HJA_START - SCE_HJ_START) #define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START) @@ -32,16 +38,16 @@ using namespace Scintilla; enum script_type { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock, eScriptComment }; enum script_mode { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc }; -static inline bool IsAWordChar(const int ch) { +inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); } -static inline bool IsAWordStart(const int ch) { +inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } inline bool IsOperator(int ch) { - if (isascii(ch) && isalnum(ch)) + if (IsASCII(ch) && isalnum(ch)) return false; // '.' left out as it is used to make up numbers if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || @@ -54,22 +60,38 @@ inline bool IsOperator(int ch) { return false; } -static inline int MakeLowerCase(int ch) { - if (ch < 'A' || ch > 'Z') - return ch; - else - return ch - 'A' + 'a'; -} - -static void GetTextSegment(Accessor &styler, unsigned int start, unsigned int end, char *s, size_t len) { - size_t i = 0; +void GetTextSegment(Accessor &styler, Sci_PositionU start, Sci_PositionU end, char *s, size_t len) { + Sci_PositionU i = 0; for (; (i < end - start + 1) && (i < len-1); i++) { - s[i] = static_cast(MakeLowerCase(styler[start + i])); + s[i] = MakeLowerCase(styler[start + i]); } s[i] = '\0'; } -static script_type segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, script_type prevValue) { +std::string GetStringSegment(Accessor &styler, Sci_PositionU start, Sci_PositionU end) { + std::string s; + Sci_PositionU i = 0; + for (; (i < end - start + 1); i++) { + s.push_back(MakeLowerCase(styler[start + i])); + } + return s; +} + +std::string GetNextWord(Accessor &styler, Sci_PositionU start) { + std::string ret; + Sci_PositionU i = 0; + for (; i < 200; i++) { // Put an upper limit to bound time taken for unexpected text. + const char ch = styler.SafeGetCharAt(start + i); + if ((i == 0) && !IsAWordStart(ch)) + break; + if ((i > 0) && !IsAWordChar(ch)) + break; + ret.push_back(ch); + } + return ret; +} + +script_type segIsScriptingIndicator(Accessor &styler, Sci_PositionU start, Sci_PositionU end, script_type prevValue) { char s[100]; GetTextSegment(styler, start, end, s, sizeof(s)); //Platform::DebugPrintf("Scripting indicator [%s]\n", s); @@ -98,18 +120,16 @@ static script_type segIsScriptingIndicator(Accessor &styler, unsigned int start, return prevValue; } -static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, unsigned int end) { +int PrintScriptingIndicatorOffset(Accessor &styler, Sci_PositionU start, Sci_PositionU end) { int iResult = 0; - char s[100]; - GetTextSegment(styler, start, end, s, sizeof(s)); - if (0 == strncmp(s, "php", 3)) { + std::string s = GetStringSegment(styler, start, end); + if (0 == strncmp(s.c_str(), "php", 3)) { iResult = 3; } - return iResult; } -static script_type ScriptOfState(int state) { +script_type ScriptOfState(int state) { if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) { return eScriptPython; } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) { @@ -127,7 +147,7 @@ static script_type ScriptOfState(int state) { } } -static int statePrintForState(int state, script_mode inScriptType) { +int statePrintForState(int state, script_mode inScriptType) { int StateToPrint = state; if (state >= SCE_HJ_START) { @@ -143,7 +163,7 @@ static int statePrintForState(int state, script_mode inScriptType) { return StateToPrint; } -static int stateForPrintState(int StateToPrint) { +int stateForPrintState(int StateToPrint) { int state; if ((StateToPrint >= SCE_HPA_START) && (StateToPrint <= SCE_HPA_IDENTIFIER)) { @@ -159,12 +179,12 @@ static int stateForPrintState(int StateToPrint) { return state; } -static inline bool IsNumber(unsigned int start, Accessor &styler) { +inline bool IsNumber(Sci_PositionU start, Accessor &styler) { return IsADigit(styler[start]) || (styler[start] == '.') || (styler[start] == '-') || (styler[start] == '#'); } -static inline bool isStringState(int state) { +inline bool isStringState(int state) { bool bResult; switch (state) { @@ -195,7 +215,7 @@ static inline bool isStringState(int state) { return bResult; } -static inline bool stateAllowsTermination(int state) { +inline bool stateAllowsTermination(int state) { bool allowTermination = !isStringState(state); if (allowTermination) { switch (state) { @@ -210,7 +230,7 @@ static inline bool stateAllowsTermination(int state) { } // not really well done, since it's only comments that should lex the %> and <% -static inline bool isCommentASPState(int state) { +inline bool isCommentASPState(int state) { bool bResult; switch (state) { @@ -230,15 +250,14 @@ static inline bool isCommentASPState(int state) { return bResult; } -static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { - bool wordIsNumber = IsNumber(start, styler); +void classifyAttribHTML(Sci_PositionU start, Sci_PositionU end, const WordList &keywords, Accessor &styler) { + const bool wordIsNumber = IsNumber(start, styler); char chAttr = SCE_H_ATTRIBUTEUNKNOWN; if (wordIsNumber) { chAttr = SCE_H_NUMBER; } else { - char s[100]; - GetTextSegment(styler, start, end, s, sizeof(s)); - if (keywords.InList(s)) + std::string s = GetStringSegment(styler, start, end); + if (keywords.InList(s.c_str())) chAttr = SCE_H_ATTRIBUTE; } if ((chAttr == SCE_H_ATTRIBUTEUNKNOWN) && !keywords) @@ -247,81 +266,103 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k styler.ColourTo(end, chAttr); } -static int classifyTagHTML(unsigned int start, unsigned int end, - WordList &keywords, Accessor &styler, bool &tagDontFold, - bool caseSensitive, bool isXml, bool allowScripts) { - char s[30 + 2]; - // Copy after the '<' - unsigned int i = 0; - for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) { - char ch = styler[cPos]; +// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-core-concepts +bool isHTMLCustomElement(const std::string &tag) { + // check valid HTML custom element name: starts with an ASCII lower alpha and contains hyphen. + // IsUpperOrLowerCase() is used for `html.tags.case.sensitive=1`. + if (tag.length() < 2 || !IsUpperOrLowerCase(tag[0])) { + return false; + } + if (tag.find('-') == std::string::npos) { + return false; + } + return true; +} + +int classifyTagHTML(Sci_PositionU start, Sci_PositionU end, + const WordList &keywords, Accessor &styler, bool &tagDontFold, + bool caseSensitive, bool isXml, bool allowScripts, + const std::set &nonFoldingTags) { + std::string tag; + // Copy after the '<' and stop before ' ' + for (Sci_PositionU cPos = start; cPos <= end; cPos++) { + const char ch = styler[cPos]; + if (IsASpace(ch)) { + break; + } if ((ch != '<') && (ch != '/')) { - s[i++] = caseSensitive ? ch : static_cast(MakeLowerCase(ch)); + tag.push_back(caseSensitive ? ch : MakeLowerCase(ch)); } } - - //The following is only a quick hack, to see if this whole thing would work - //we first need the tagname with a trailing space... - s[i] = ' '; - s[i+1] = '\0'; - // if the current language is XML, I can fold any tag // if the current language is HTML, I don't want to fold certain tags (input, meta, etc.) //...to find it in the list of no-container-tags - tagDontFold = (!isXml) && (NULL != strstr("meta link img area br hr input ", s)); - - //now we can remove the trailing space - s[i] = '\0'; - + tagDontFold = (!isXml) && (nonFoldingTags.count(tag) > 0); // No keywords -> all are known - // Name of a closing tag starts at s + 1 char chAttr = SCE_H_TAGUNKNOWN; - if (s[0] == '!') { + if (!tag.empty() && (tag[0] == '!')) { chAttr = SCE_H_SGML_DEFAULT; - } else if (!keywords || keywords.InList(s[0] == '/' ? s + 1 : s)) { + } else if (!keywords || keywords.InList(tag.c_str())) { + chAttr = SCE_H_TAG; + } else if (!isXml && isHTMLCustomElement(tag)) { chAttr = SCE_H_TAG; } - styler.ColourTo(end, chAttr); + if (chAttr != SCE_H_TAGUNKNOWN) { + styler.ColourTo(end, chAttr); + } if (chAttr == SCE_H_TAG) { - if (allowScripts && 0 == strcmp(s, "script")) { - chAttr = SCE_H_SCRIPT; - } else if (!isXml && 0 == strcmp(s, "comment")) { + if (allowScripts && (tag == "script")) { + // check to see if this is a self-closing tag by sniffing ahead + bool isSelfClose = false; + for (Sci_PositionU cPos = end; cPos <= end + 200; cPos++) { + const char ch = styler.SafeGetCharAt(cPos, '\0'); + if (ch == '\0' || ch == '>') + break; + else if (ch == '/' && styler.SafeGetCharAt(cPos + 1, '\0') == '>') { + isSelfClose = true; + break; + } + } + + // do not enter a script state if the tag self-closed + if (!isSelfClose) + chAttr = SCE_H_SCRIPT; + } else if (!isXml && (tag == "comment")) { chAttr = SCE_H_COMMENT; } } return chAttr; } -static void classifyWordHTJS(unsigned int start, unsigned int end, - WordList &keywords, Accessor &styler, script_mode inScriptType) { +void classifyWordHTJS(Sci_PositionU start, Sci_PositionU end, + const WordList &keywords, Accessor &styler, script_mode inScriptType) { + char s[30 + 1]; + Sci_PositionU i = 0; + for (; i < end - start + 1 && i < 30; i++) { + s[i] = styler[start + i]; + } + s[i] = '\0'; + char chAttr = SCE_HJ_WORD; - bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.'); - if (wordIsNumber) + const bool wordIsNumber = IsADigit(s[0]) || ((s[0] == '.') && IsADigit(s[1])); + if (wordIsNumber) { chAttr = SCE_HJ_NUMBER; - else { - char s[30 + 1]; - unsigned int i = 0; - for (; i < end - start + 1 && i < 30; i++) { - s[i] = styler[start + i]; - } - s[i] = '\0'; - if (keywords.InList(s)) - chAttr = SCE_HJ_KEYWORD; + } else if (keywords.InList(s)) { + chAttr = SCE_HJ_KEYWORD; } styler.ColourTo(end, statePrintForState(chAttr, inScriptType)); } -static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, script_mode inScriptType) { +int classifyWordHTVB(Sci_PositionU start, Sci_PositionU end, const WordList &keywords, Accessor &styler, script_mode inScriptType) { char chAttr = SCE_HB_IDENTIFIER; - bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.'); - if (wordIsNumber) + const bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.'); + if (wordIsNumber) { chAttr = SCE_HB_NUMBER; - else { - char s[100]; - GetTextSegment(styler, start, end, s, sizeof(s)); - if (keywords.InList(s)) { + } else { + std::string s = GetStringSegment(styler, start, end); + if (keywords.InList(s.c_str())) { chAttr = SCE_HB_WORD; - if (strcmp(s, "rem") == 0) + if (s == "rem") chAttr = SCE_HB_COMMENTLINE; } } @@ -332,65 +373,60 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw return SCE_HB_DEFAULT; } -static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType) { - bool wordIsNumber = IsADigit(styler[start]); - char s[30 + 1]; - unsigned int i = 0; - for (; i < end - start + 1 && i < 30; i++) { - s[i] = styler[start + i]; +void classifyWordHTPy(Sci_PositionU start, Sci_PositionU end, const WordList &keywords, Accessor &styler, std::string &prevWord, script_mode inScriptType, bool isMako) { + const bool wordIsNumber = IsADigit(styler[start]); + std::string s; + for (Sci_PositionU i = 0; i < end - start + 1 && i < 30; i++) { + s.push_back(styler[start + i]); } - s[i] = '\0'; char chAttr = SCE_HP_IDENTIFIER; - if (0 == strcmp(prevWord, "class")) + if (prevWord == "class") chAttr = SCE_HP_CLASSNAME; - else if (0 == strcmp(prevWord, "def")) + else if (prevWord == "def") chAttr = SCE_HP_DEFNAME; else if (wordIsNumber) chAttr = SCE_HP_NUMBER; - else if (keywords.InList(s)) + else if (keywords.InList(s.c_str())) + chAttr = SCE_HP_WORD; + else if (isMako && (s == "block")) chAttr = SCE_HP_WORD; styler.ColourTo(end, statePrintForState(chAttr, inScriptType)); - strcpy(prevWord, s); + prevWord = s; } // Update the word colour to default or keyword // Called when in a PHP word -static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { +void classifyWordHTPHP(Sci_PositionU start, Sci_PositionU end, const WordList &keywords, Accessor &styler) { char chAttr = SCE_HPHP_DEFAULT; - bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.' && start+1 <= end && IsADigit(styler[start+1])); - if (wordIsNumber) + const bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.' && start+1 <= end && IsADigit(styler[start+1])); + if (wordIsNumber) { chAttr = SCE_HPHP_NUMBER; - else { - char s[100]; - GetTextSegment(styler, start, end, s, sizeof(s)); - if (keywords.InList(s)) + } else { + std::string s = GetStringSegment(styler, start, end); + if (keywords.InList(s.c_str())) chAttr = SCE_HPHP_WORD; } styler.ColourTo(end, chAttr); } -static bool isWordHSGML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { - char s[30 + 1]; - unsigned int i = 0; - for (; i < end - start + 1 && i < 30; i++) { - s[i] = styler[start + i]; +bool isWordHSGML(Sci_PositionU start, Sci_PositionU end, const WordList &keywords, Accessor &styler) { + std::string s; + for (Sci_PositionU i = 0; i < end - start + 1 && i < 30; i++) { + s.push_back(styler[start + i]); } - s[i] = '\0'; - return keywords.InList(s); + return keywords.InList(s.c_str()); } -static bool isWordCdata(unsigned int start, unsigned int end, Accessor &styler) { - char s[30 + 1]; - unsigned int i = 0; - for (; i < end - start + 1 && i < 30; i++) { - s[i] = styler[start + i]; +bool isWordCdata(Sci_PositionU start, Sci_PositionU end, Accessor &styler) { + std::string s; + for (Sci_PositionU i = 0; i < end - start + 1 && i < 30; i++) { + s.push_back(styler[start + i]); } - s[i] = '\0'; - return (0 == strcmp(s, "[CDATA[")); + return s == "[CDATA["; } // Return the first state to reach when entering a scripting language -static int StateForScript(script_type scriptLanguage) { +int StateForScript(script_type scriptLanguage) { int Result; switch (scriptLanguage) { case eScriptVBS: @@ -418,25 +454,20 @@ static int StateForScript(script_type scriptLanguage) { return Result; } -static inline bool ishtmlwordchar(int ch) { - return !isascii(ch) || - (isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#'); -} - -static inline bool issgmlwordchar(int ch) { - return !isascii(ch) || +inline bool issgmlwordchar(int ch) { + return !IsASCII(ch) || (isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '['); } -static inline bool IsPhpWordStart(int ch) { - return (isascii(ch) && (isalpha(ch) || (ch == '_'))) || (ch >= 0x7f); +inline bool IsPhpWordStart(int ch) { + return (IsASCII(ch) && (isalpha(ch) || (ch == '_'))) || (ch >= 0x7f); } -static inline bool IsPhpWordChar(int ch) { +inline bool IsPhpWordChar(int ch) { return IsADigit(ch) || IsPhpWordStart(ch); } -static bool InTagState(int state) { +bool InTagState(int state) { return state == SCE_H_TAG || state == SCE_H_TAGUNKNOWN || state == SCE_H_SCRIPT || state == SCE_H_ATTRIBUTE || state == SCE_H_ATTRIBUTEUNKNOWN || @@ -444,24 +475,52 @@ static bool InTagState(int state) { state == SCE_H_DOUBLESTRING || state == SCE_H_SINGLESTRING; } -static bool IsCommentState(const int state) { +bool IsCommentState(const int state) { return state == SCE_H_COMMENT || state == SCE_H_SGML_COMMENT; } -static bool IsScriptCommentState(const int state) { +bool IsScriptCommentState(const int state) { return state == SCE_HJ_COMMENT || state == SCE_HJ_COMMENTLINE || state == SCE_HJA_COMMENT || state == SCE_HJA_COMMENTLINE || state == SCE_HB_COMMENTLINE || state == SCE_HBA_COMMENTLINE; } -static bool isLineEnd(int ch) { +bool isLineEnd(int ch) { return ch == '\r' || ch == '\n'; } -static bool isOKBeforeRE(int ch) { - return (ch == '(') || (ch == '=') || (ch == ','); +bool isMakoBlockEnd(const int ch, const int chNext, const std::string &blockType) { + if (blockType.empty()) { + return ((ch == '%') && (chNext == '>')); + } else if ((blockType == "inherit") || + (blockType == "namespace") || + (blockType == "include") || + (blockType == "page")) { + return ((ch == '/') && (chNext == '>')); + } else if (blockType == "%") { + if (ch == '/' && isLineEnd(chNext)) + return true; + else + return isLineEnd(ch); + } else if (blockType == "{") { + return ch == '}'; + } else { + return (ch == '>'); + } +} + +bool isDjangoBlockEnd(const int ch, const int chNext, const std::string &blockType) { + if (blockType.empty()) { + return false; + } else if (blockType == "%") { + return ((ch == '%') && (chNext == '}')); + } else if (blockType == "{") { + return ((ch == '}') && (chNext == '}')); + } else { + return false; + } } -static bool isPHPStringState(int state) { +bool isPHPStringState(int state) { return (state == SCE_HPHP_HSTRING) || (state == SCE_HPHP_SIMPLESTRING) || @@ -469,29 +528,27 @@ static bool isPHPStringState(int state) { (state == SCE_HPHP_COMPLEX_VARIABLE); } -static int FindPhpStringDelimiter(char *phpStringDelimiter, const int phpStringDelimiterSize, int i, const int lengthDoc, Accessor &styler, bool &isSimpleString) { - int j; - const int beginning = i - 1; +Sci_Position FindPhpStringDelimiter(std::string &phpStringDelimiter, Sci_Position i, const Sci_Position lengthDoc, Accessor &styler, bool &isSimpleString) { + Sci_Position j; + const Sci_Position beginning = i - 1; bool isValidSimpleString = false; while (i < lengthDoc && (styler[i] == ' ' || styler[i] == '\t')) i++; - char ch = styler.SafeGetCharAt(i); const char chNext = styler.SafeGetCharAt(i + 1); + phpStringDelimiter.clear(); if (!IsPhpWordStart(ch)) { if (ch == '\'' && IsPhpWordStart(chNext)) { i++; ch = chNext; isSimpleString = true; } else { - phpStringDelimiter[0] = '\0'; return beginning; } } - phpStringDelimiter[0] = ch; + phpStringDelimiter.push_back(ch); i++; - for (j = i; j < lengthDoc && !isLineEnd(styler[j]); j++) { if (!IsPhpWordChar(styler[j])) { if (isSimpleString && (styler[j] == '\'') && isLineEnd(styler.SafeGetCharAt(j + 1))) { @@ -499,46 +556,417 @@ static int FindPhpStringDelimiter(char *phpStringDelimiter, const int phpStringD j++; break; } else { - phpStringDelimiter[0] = '\0'; + phpStringDelimiter.clear(); return beginning; } } - if (j - i < phpStringDelimiterSize - 2) - phpStringDelimiter[j-i+1] = styler[j]; - else - i++; + phpStringDelimiter.push_back(styler[j]); } if (isSimpleString && !isValidSimpleString) { - phpStringDelimiter[0] = '\0'; + phpStringDelimiter.clear(); return beginning; } - phpStringDelimiter[j-i+1 - (isSimpleString ? 1 : 0)] = '\0'; return j - 1; } -static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler, bool isXml) { - WordList &keywords = *keywordlists[0]; - WordList &keywords2 = *keywordlists[1]; - WordList &keywords3 = *keywordlists[2]; - WordList &keywords4 = *keywordlists[3]; - WordList &keywords5 = *keywordlists[4]; - WordList &keywords6 = *keywordlists[5]; // SGML (DTD) keywords - - // Lexer for HTML requires more lexical states (8 bits worth) than most lexers - styler.StartAt(startPos, static_cast(STYLE_MAX)); - char prevWord[200]; - prevWord[0] = '\0'; - char phpStringDelimiter[200]; // PHP is not limited in length, we are - phpStringDelimiter[0] = '\0'; +// Options used for LexerHTML +struct OptionsHTML { + int aspDefaultLanguage = eScriptJS; + bool caseSensitive = false; + bool allowScripts = true; + bool isMako = false; + bool isDjango = false; + bool fold = false; + bool foldHTML = false; + bool foldHTMLPreprocessor = true; + bool foldCompact = true; + bool foldComment = false; + bool foldHeredoc = false; + bool foldXmlAtTagOpen = false; + OptionsHTML() noexcept { + } +}; + +const char * const htmlWordListDesc[] = { + "HTML elements and attributes", + "JavaScript keywords", + "VBScript keywords", + "Python keywords", + "PHP keywords", + "SGML and DTD keywords", + 0, +}; + +const char * const phpscriptWordListDesc[] = { + "", //Unused + "", //Unused + "", //Unused + "", //Unused + "PHP keywords", + "", //Unused + 0, +}; + +struct OptionSetHTML : public OptionSet { + OptionSetHTML(bool isPHPScript_) { + + DefineProperty("asp.default.language", &OptionsHTML::aspDefaultLanguage, + "Script in ASP code is initially assumed to be in JavaScript. " + "To change this to VBScript set asp.default.language to 2. Python is 3."); + + DefineProperty("html.tags.case.sensitive", &OptionsHTML::caseSensitive, + "For XML and HTML, setting this property to 1 will make tags match in a case " + "sensitive way which is the expected behaviour for XML and XHTML."); + + DefineProperty("lexer.xml.allow.scripts", &OptionsHTML::allowScripts, + "Set to 0 to disable scripts in XML."); + + DefineProperty("lexer.html.mako", &OptionsHTML::isMako, + "Set to 1 to enable the mako template language."); + + DefineProperty("lexer.html.django", &OptionsHTML::isDjango, + "Set to 1 to enable the django template language."); + + DefineProperty("fold", &OptionsHTML::fold); + + DefineProperty("fold.html", &OptionsHTML::foldHTML, + "Folding is turned on or off for HTML and XML files with this option. " + "The fold option must also be on for folding to occur."); + + DefineProperty("fold.html.preprocessor", &OptionsHTML::foldHTMLPreprocessor, + "Folding is turned on or off for scripts embedded in HTML files with this option. " + "The default is on."); + + DefineProperty("fold.compact", &OptionsHTML::foldCompact); + + DefineProperty("fold.hypertext.comment", &OptionsHTML::foldComment, + "Allow folding for comments in scripts embedded in HTML. " + "The default is off."); + + DefineProperty("fold.hypertext.heredoc", &OptionsHTML::foldHeredoc, + "Allow folding for heredocs in scripts embedded in HTML. " + "The default is off."); + + DefineProperty("fold.xml.at.tag.open", &OptionsHTML::foldXmlAtTagOpen, + "Enable folding for XML at the start of open tag. " + "The default is off."); + + DefineWordListSets(isPHPScript_ ? phpscriptWordListDesc : htmlWordListDesc); + } +}; + +LexicalClass lexicalClassesHTML[] = { + // Lexer HTML SCLEX_HTML SCE_H_ SCE_HJ_ SCE_HJA_ SCE_HB_ SCE_HBA_ SCE_HP_ SCE_HPHP_ SCE_HPA_: + 0, "SCE_H_DEFAULT", "default", "Text", + 1, "SCE_H_TAG", "tag", "Tags", + 2, "SCE_H_ERRORTAGUNKNOWN", "error tag", "Unknown Tags", + 3, "SCE_H_ATTRIBUTE", "attribute", "Attributes", + 4, "SCE_H_ATTRIBUTEUNKNOWN", "error attribute", "Unknown Attributes", + 5, "SCE_H_NUMBER", "literal numeric", "Numbers", + 6, "SCE_H_DOUBLESTRING", "literal string", "Double quoted strings", + 7, "SCE_H_SINGLESTRING", "literal string", "Single quoted strings", + 8, "SCE_H_OTHER", "tag operator", "Other inside tag, including space and '='", + 9, "SCE_H_COMMENT", "comment", "Comment", + 10, "SCE_H_ENTITY", "literal", "Entities", + 11, "SCE_H_TAGEND", "tag", "XML style tag ends '/>'", + 12, "SCE_H_XMLSTART", "identifier", "XML identifier start ''", + 14, "SCE_H_SCRIPT", "error", "Internal state which should never be visible", + 15, "SCE_H_ASP", "preprocessor", "ASP <% ... %>", + 16, "SCE_H_ASPAT", "preprocessor", "ASP <% ... %>", + 17, "SCE_H_CDATA", "literal", "CDATA", + 18, "SCE_H_QUESTION", "preprocessor", "PHP", + 19, "SCE_H_VALUE", "literal string", "Unquoted values", + 20, "SCE_H_XCCOMMENT", "comment", "JSP Comment <%-- ... --%>", + 21, "SCE_H_SGML_DEFAULT", "default", "SGML tags ", + 22, "SCE_H_SGML_COMMAND", "preprocessor", "SGML command", + 23, "SCE_H_SGML_1ST_PARAM", "preprocessor", "SGML 1st param", + 24, "SCE_H_SGML_DOUBLESTRING", "literal string", "SGML double string", + 25, "SCE_H_SGML_SIMPLESTRING", "literal string", "SGML single string", + 26, "SCE_H_SGML_ERROR", "error", "SGML error", + 27, "SCE_H_SGML_SPECIAL", "literal", "SGML special (#XXXX type)", + 28, "SCE_H_SGML_ENTITY", "literal", "SGML entity", + 29, "SCE_H_SGML_COMMENT", "comment", "SGML comment", + 30, "SCE_H_SGML_1ST_PARAM_COMMENT", "error comment", "SGML first parameter - lexer internal. It is an error if any text is in this style.", + 31, "SCE_H_SGML_BLOCK_DEFAULT", "default", "SGML block", + 32, "", "predefined", "", + 33, "", "predefined", "", + 34, "", "predefined", "", + 35, "", "predefined", "", + 36, "", "predefined", "", + 37, "", "predefined", "", + 38, "", "predefined", "", + 39, "", "predefined", "", + 40, "SCE_HJ_START", "client javascript default", "JS Start - allows eol filled background to not start on same line as SCRIPT tag", + 41, "SCE_HJ_DEFAULT", "client javascript default", "JS Default", + 42, "SCE_HJ_COMMENT", "client javascript comment", "JS Comment", + 43, "SCE_HJ_COMMENTLINE", "client javascript comment line", "JS Line Comment", + 44, "SCE_HJ_COMMENTDOC", "client javascript comment documentation", "JS Doc comment", + 45, "SCE_HJ_NUMBER", "client javascript literal numeric", "JS Number", + 46, "SCE_HJ_WORD", "client javascript identifier", "JS Word", + 47, "SCE_HJ_KEYWORD", "client javascript keyword", "JS Keyword", + 48, "SCE_HJ_DOUBLESTRING", "client javascript literal string", "JS Double quoted string", + 49, "SCE_HJ_SINGLESTRING", "client javascript literal string", "JS Single quoted string", + 50, "SCE_HJ_SYMBOLS", "client javascript operator", "JS Symbols", + 51, "SCE_HJ_STRINGEOL", "client javascript error literal string", "JavaScript EOL", + 52, "SCE_HJ_REGEX", "client javascript literal regex", "JavaScript RegEx", + 53, "", "unused", "", + 54, "", "unused", "", + 55, "SCE_HJA_START", "server javascript default", "JS Start - allows eol filled background to not start on same line as SCRIPT tag", + 56, "SCE_HJA_DEFAULT", "server javascript default", "JS Default", + 57, "SCE_HJA_COMMENT", "server javascript comment", "JS Comment", + 58, "SCE_HJA_COMMENTLINE", "server javascript comment line", "JS Line Comment", + 59, "SCE_HJA_COMMENTDOC", "server javascript comment documentation", "JS Doc comment", + 60, "SCE_HJA_NUMBER", "server javascript literal numeric", "JS Number", + 61, "SCE_HJA_WORD", "server javascript identifier", "JS Word", + 62, "SCE_HJA_KEYWORD", "server javascript keyword", "JS Keyword", + 63, "SCE_HJA_DOUBLESTRING", "server javascript literal string", "JS Double quoted string", + 64, "SCE_HJA_SINGLESTRING", "server javascript literal string", "JS Single quoted string", + 65, "SCE_HJA_SYMBOLS", "server javascript operator", "JS Symbols", + 66, "SCE_HJA_STRINGEOL", "server javascript error literal string", "JavaScript EOL", + 67, "SCE_HJA_REGEX", "server javascript literal regex", "JavaScript RegEx", + 68, "", "unused", "", + 69, "", "unused", "", + 70, "SCE_HB_START", "client basic default", "Start", + 71, "SCE_HB_DEFAULT", "client basic default", "Default", + 72, "SCE_HB_COMMENTLINE", "client basic comment line", "Comment", + 73, "SCE_HB_NUMBER", "client basic literal numeric", "Number", + 74, "SCE_HB_WORD", "client basic keyword", "KeyWord", + 75, "SCE_HB_STRING", "client basic literal string", "String", + 76, "SCE_HB_IDENTIFIER", "client basic identifier", "Identifier", + 77, "SCE_HB_STRINGEOL", "client basic literal string", "Unterminated string", + 78, "", "unused", "", + 79, "", "unused", "", + 80, "SCE_HBA_START", "server basic default", "Start", + 81, "SCE_HBA_DEFAULT", "server basic default", "Default", + 82, "SCE_HBA_COMMENTLINE", "server basic comment line", "Comment", + 83, "SCE_HBA_NUMBER", "server basic literal numeric", "Number", + 84, "SCE_HBA_WORD", "server basic keyword", "KeyWord", + 85, "SCE_HBA_STRING", "server basic literal string", "String", + 86, "SCE_HBA_IDENTIFIER", "server basic identifier", "Identifier", + 87, "SCE_HBA_STRINGEOL", "server basic literal string", "Unterminated string", + 88, "", "unused", "", + 89, "", "unused", "", + 90, "SCE_HP_START", "client python default", "Embedded Python", + 91, "SCE_HP_DEFAULT", "client python default", "Embedded Python", + 92, "SCE_HP_COMMENTLINE", "client python comment line", "Comment", + 93, "SCE_HP_NUMBER", "client python literal numeric", "Number", + 94, "SCE_HP_STRING", "client python literal string", "String", + 95, "SCE_HP_CHARACTER", "client python literal string character", "Single quoted string", + 96, "SCE_HP_WORD", "client python keyword", "Keyword", + 97, "SCE_HP_TRIPLE", "client python literal string", "Triple quotes", + 98, "SCE_HP_TRIPLEDOUBLE", "client python literal string", "Triple double quotes", + 99, "SCE_HP_CLASSNAME", "client python identifier", "Class name definition", + 100, "SCE_HP_DEFNAME", "client python identifier", "Function or method name definition", + 101, "SCE_HP_OPERATOR", "client python operator", "Operators", + 102, "SCE_HP_IDENTIFIER", "client python identifier", "Identifiers", + 103, "", "unused", "", + 104, "SCE_HPHP_COMPLEX_VARIABLE", "server php identifier", "PHP complex variable", + 105, "SCE_HPA_START", "server python default", "ASP Python", + 106, "SCE_HPA_DEFAULT", "server python default", "ASP Python", + 107, "SCE_HPA_COMMENTLINE", "server python comment line", "Comment", + 108, "SCE_HPA_NUMBER", "server python literal numeric", "Number", + 109, "SCE_HPA_STRING", "server python literal string", "String", + 110, "SCE_HPA_CHARACTER", "server python literal string character", "Single quoted string", + 111, "SCE_HPA_WORD", "server python keyword", "Keyword", + 112, "SCE_HPA_TRIPLE", "server python literal string", "Triple quotes", + 113, "SCE_HPA_TRIPLEDOUBLE", "server python literal string", "Triple double quotes", + 114, "SCE_HPA_CLASSNAME", "server python identifier", "Class name definition", + 115, "SCE_HPA_DEFNAME", "server python identifier", "Function or method name definition", + 116, "SCE_HPA_OPERATOR", "server python operator", "Operators", + 117, "SCE_HPA_IDENTIFIER", "server python identifier", "Identifiers", + 118, "SCE_HPHP_DEFAULT", "server php default", "Default", + 119, "SCE_HPHP_HSTRING", "server php literal string", "Double quoted String", + 120, "SCE_HPHP_SIMPLESTRING", "server php literal string", "Single quoted string", + 121, "SCE_HPHP_WORD", "server php keyword", "Keyword", + 122, "SCE_HPHP_NUMBER", "server php literal numeric", "Number", + 123, "SCE_HPHP_VARIABLE", "server php identifier", "Variable", + 124, "SCE_HPHP_COMMENT", "server php comment", "Comment", + 125, "SCE_HPHP_COMMENTLINE", "server php comment line", "One line comment", + 126, "SCE_HPHP_HSTRING_VARIABLE", "server php literal string identifier", "PHP variable in double quoted string", + 127, "SCE_HPHP_OPERATOR", "server php operator", "PHP operator", +}; + +LexicalClass lexicalClassesXML[] = { + // Lexer.Secondary XML SCLEX_XML SCE_H_: + 0, "SCE_H_DEFAULT", "default", "Default", + 1, "SCE_H_TAG", "tag", "Tags", + 2, "SCE_H_TAGUNKNOWN", "error tag", "Unknown Tags", + 3, "SCE_H_ATTRIBUTE", "attribute", "Attributes", + 4, "SCE_H_ERRORATTRIBUTEUNKNOWN", "error attribute", "Unknown Attributes", + 5, "SCE_H_NUMBER", "literal numeric", "Numbers", + 6, "SCE_H_DOUBLESTRING", "literal string", "Double quoted strings", + 7, "SCE_H_SINGLESTRING", "literal string", "Single quoted strings", + 8, "SCE_H_OTHER", "tag operator", "Other inside tag, including space and '='", + 9, "SCE_H_COMMENT", "comment", "Comment", + 10, "SCE_H_ENTITY", "literal", "Entities", + 11, "SCE_H_TAGEND", "tag", "XML style tag ends '/>'", + 12, "SCE_H_XMLSTART", "identifier", "XML identifier start ''", + 14, "", "unused", "", + 15, "", "unused", "", + 16, "", "unused", "", + 17, "SCE_H_CDATA", "literal", "CDATA", + 18, "SCE_H_QUESTION", "preprocessor", "Question", + 19, "SCE_H_VALUE", "literal string", "Unquoted Value", + 20, "", "unused", "", + 21, "SCE_H_SGML_DEFAULT", "default", "SGML tags ", + 22, "SCE_H_SGML_COMMAND", "preprocessor", "SGML command", + 23, "SCE_H_SGML_1ST_PARAM", "preprocessor", "SGML 1st param", + 24, "SCE_H_SGML_DOUBLESTRING", "literal string", "SGML double string", + 25, "SCE_H_SGML_SIMPLESTRING", "literal string", "SGML single string", + 26, "SCE_H_SGML_ERROR", "error", "SGML error", + 27, "SCE_H_SGML_SPECIAL", "literal", "SGML special (#XXXX type)", + 28, "SCE_H_SGML_ENTITY", "literal", "SGML entity", + 29, "SCE_H_SGML_COMMENT", "comment", "SGML comment", + 30, "", "unused", "", + 31, "SCE_H_SGML_BLOCK_DEFAULT", "default", "SGML block", +}; + +const char *tagsThatDoNotFold[] = { + "area", + "base", + "basefont", + "br", + "col", + "command", + "embed", + "frame", + "hr", + "img", + "input", + "isindex", + "keygen", + "link", + "meta", + "param", + "source", + "track", + "wbr" +}; + +} + +class LexerHTML : public DefaultLexer { + bool isXml; + bool isPHPScript; + WordList keywords; + WordList keywords2; + WordList keywords3; + WordList keywords4; + WordList keywords5; + WordList keywords6; // SGML (DTD) keywords + OptionsHTML options; + OptionSetHTML osHTML; + std::set nonFoldingTags; +public: + explicit LexerHTML(bool isXml_, bool isPHPScript_) : + DefaultLexer( + isXml_ ? "xml" : (isPHPScript_ ? "phpscript" : "hypertext"), + isXml_ ? SCLEX_XML : (isPHPScript_ ? SCLEX_PHPSCRIPT : SCLEX_HTML), + isXml_ ? lexicalClassesHTML : lexicalClassesXML, + isXml_ ? std::size(lexicalClassesHTML) : std::size(lexicalClassesXML)), + isXml(isXml_), + isPHPScript(isPHPScript_), + osHTML(isPHPScript_), + nonFoldingTags(std::begin(tagsThatDoNotFold), std::end(tagsThatDoNotFold)) { + } + ~LexerHTML() override { + } + void SCI_METHOD Release() override { + delete this; + } + const char *SCI_METHOD PropertyNames() override { + return osHTML.PropertyNames(); + } + int SCI_METHOD PropertyType(const char *name) override { + return osHTML.PropertyType(name); + } + const char *SCI_METHOD DescribeProperty(const char *name) override { + return osHTML.DescribeProperty(name); + } + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override; + const char * SCI_METHOD PropertyGet(const char *key) override { + return osHTML.PropertyGet(key); + } + const char *SCI_METHOD DescribeWordListSets() override { + return osHTML.DescribeWordListSets(); + } + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override; + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + // No Fold as all folding performs in Lex. + + static ILexer5 *LexerFactoryHTML() { + return new LexerHTML(false, false); + } + static ILexer5 *LexerFactoryXML() { + return new LexerHTML(true, false); + } + static ILexer5 *LexerFactoryPHPScript() { + return new LexerHTML(false, true); + } +}; + +Sci_Position SCI_METHOD LexerHTML::PropertySet(const char *key, const char *val) { + if (osHTML.PropertySet(&options, key, val)) { + return 0; + } + return -1; +} + +Sci_Position SCI_METHOD LexerHTML::WordListSet(int n, const char *wl) { + WordList *wordListN = 0; + switch (n) { + case 0: + wordListN = &keywords; + break; + case 1: + wordListN = &keywords2; + break; + case 2: + wordListN = &keywords3; + break; + case 3: + wordListN = &keywords4; + break; + case 4: + wordListN = &keywords5; + break; + case 5: + wordListN = &keywords6; + break; + } + Sci_Position firstModification = -1; + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + return firstModification; +} + +void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + Accessor styler(pAccess, nullptr); + if (isPHPScript && (startPos == 0)) { + initStyle = SCE_HPHP_DEFAULT; + } + styler.StartAt(startPos); + std::string prevWord; + std::string phpStringDelimiter; int StateToPrint = initStyle; int state = stateForPrintState(StateToPrint); - - // If inside a tag, it may be a script tag, so reread from the start to ensure any language tags are seen + std::string makoBlockType; + int makoComment = 0; + std::string djangoBlockType; + // If inside a tag, it may be a script tag, so reread from the start of line starting tag to ensure any language tags are seen if (InTagState(state)) { while ((startPos > 0) && (InTagState(styler.StyleAt(startPos - 1)))) { - startPos--; - length++; + const Sci_Position backLineStart = styler.LineStart(styler.GetLine(startPos-1)); + length += startPos - backLineStart; + startPos = backLineStart; } state = SCE_H_DEFAULT; } @@ -552,23 +980,35 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (startPos == 0) state = SCE_H_DEFAULT; } - styler.StartAt(startPos, static_cast(STYLE_MAX)); + styler.StartAt(startPos); - int lineCurrent = styler.GetLine(startPos); + /* Nothing handles getting out of these, so we need not start in any of them. + * As we're at line start and they can't span lines, we'll re-detect them anyway */ + switch (state) { + case SCE_H_QUESTION: + case SCE_H_XMLSTART: + case SCE_H_XMLEND: + case SCE_H_ASP: + state = SCE_H_DEFAULT; + break; + } + + Sci_Position lineCurrent = styler.GetLine(startPos); int lineState; if (lineCurrent > 0) { - lineState = styler.GetLineState(lineCurrent); + lineState = styler.GetLineState(lineCurrent-1); } else { // Default client and ASP scripting language is JavaScript lineState = eScriptJS << 8; - lineState |= styler.GetPropertyInt("asp.default.language", eScriptJS) << 4; + lineState |= options.aspDefaultLanguage << 4; } - script_mode inScriptType = script_mode((lineState >> 0) & 0x03); // 2 bits of scripting mode + script_mode inScriptType = static_cast((lineState >> 0) & 0x03); // 2 bits of scripting mode + bool tagOpened = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag bool tagClosing = (lineState >> 3) & 0x01; // 1 bit to know if we are in a closing tag bool tagDontFold = false; //some HTML tags should not be folded - script_type aspScript = script_type((lineState >> 4) & 0x0F); // 4 bits of script name - script_type clientScript = script_type((lineState >> 8) & 0x0F); // 4 bits of script name + script_type aspScript = static_cast((lineState >> 4) & 0x0F); // 4 bits of script name + script_type clientScript = static_cast((lineState >> 8) & 0x0F); // 4 bits of script name int beforePreProc = (lineState >> 12) & 0xFF; // 8 bits of state script_type scriptLanguage = ScriptOfState(state); @@ -576,30 +1016,35 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (inScriptType == eNonHtmlScript && state == SCE_H_COMMENT) { scriptLanguage = eScriptComment; } - - const bool foldHTML = styler.GetPropertyInt("fold.html", 0) != 0; - const bool fold = foldHTML && styler.GetPropertyInt("fold", 0); - const bool foldHTMLPreprocessor = foldHTML && styler.GetPropertyInt("fold.html.preprocessor", 1); - const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - const bool foldComment = fold && styler.GetPropertyInt("fold.hypertext.comment", 0) != 0; - const bool foldHeredoc = fold && styler.GetPropertyInt("fold.hypertext.heredoc", 0) != 0; - const bool caseSensitive = styler.GetPropertyInt("html.tags.case.sensitive", 0) != 0; - const bool allowScripts = styler.GetPropertyInt("lexer.xml.allow.scripts", 1) != 0; - + script_type beforeLanguage = ScriptOfState(beforePreProc); + const bool foldHTML = options.foldHTML; + const bool fold = foldHTML && options.fold; + const bool foldHTMLPreprocessor = foldHTML && options.foldHTMLPreprocessor; + const bool foldCompact = options.foldCompact; + const bool foldComment = fold && options.foldComment; + const bool foldHeredoc = fold && options.foldHeredoc; + const bool foldXmlAtTagOpen = isXml && fold && options.foldXmlAtTagOpen; + const bool caseSensitive = options.caseSensitive; + const bool allowScripts = options.allowScripts; + const bool isMako = options.isMako; + const bool isDjango = options.isDjango; const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true); const CharacterSet setTagContinue(CharacterSet::setAlphaNum, ".-_:!#[", 0x80, true); const CharacterSet setAttributeContinue(CharacterSet::setAlphaNum, ".-_:!#/", 0x80, true); + // TODO: also handle + and - (except if they're part of ++ or --) and return keywords + const CharacterSet setOKBeforeJSRE(CharacterSet::setNone, "([{=,:;!%^&*|?~"); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; int visibleChars = 0; + int lineStartVisibleChars = 0; int chPrev = ' '; int ch = ' '; int chPrevNonWhite = ' '; // look back to set chPrevNonWhite properly for better regex colouring if (scriptLanguage == eScriptJS && startPos > 0) { - int back = startPos; + Sci_Position back = startPos; int style = 0; while (--back) { style = styler.StyleAt(back); @@ -613,8 +1058,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } styler.StartSegment(startPos); - const int lengthDoc = startPos + length; - for (int i = startPos; i < lengthDoc; i++) { + const Sci_Position lengthDoc = startPos + length; + for (Sci_Position i = startPos; i < lengthDoc; i++) { const int chPrev2 = chPrev; chPrev = ch; if (!IsASpace(ch) && state != SCE_HJ_COMMENT && @@ -633,6 +1078,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if ((!IsASpace(ch) || !foldCompact) && fold) visibleChars++; + if (!IsASpace(ch)) + lineStartVisibleChars++; // decide what is the current state to print (depending of the script tag) StateToPrint = statePrintForState(state, inScriptType); @@ -647,22 +1094,32 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if ((state != SCE_HPHP_COMMENT) && (state != SCE_HPHP_COMMENTLINE) && (state != SCE_HJ_COMMENT) && (state != SCE_HJ_COMMENTLINE) && (state != SCE_HJ_COMMENTDOC) && (!isStringState(state))) { //Platform::DebugPrintf("state=%d, StateToPrint=%d, initStyle=%d\n", state, StateToPrint, initStyle); //if ((state == SCE_HPHP_OPERATOR) || (state == SCE_HPHP_DEFAULT) || (state == SCE_HJ_SYMBOLS) || (state == SCE_HJ_START) || (state == SCE_HJ_DEFAULT)) { - if ((ch == '{') || (ch == '}') || (foldComment && (ch == '/') && (chNext == '*'))) { - levelCurrent += ((ch == '{') || (ch == '/')) ? 1 : -1; + if (ch == '#') { + Sci_Position j = i + 1; + while ((j < lengthDoc) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { + j++; + } + if (styler.Match(j, "region") || styler.Match(j, "if")) { + levelCurrent++; + } else if (styler.Match(j, "end")) { + levelCurrent--; + } + } else if ((ch == '{') || (ch == '}') || (foldComment && (ch == '/') && (chNext == '*'))) { + levelCurrent += (((ch == '{') || (ch == '/')) ? 1 : -1); } } else if (((state == SCE_HPHP_COMMENT) || (state == SCE_HJ_COMMENT)) && foldComment && (ch == '*') && (chNext == '/')) { levelCurrent--; } break; case eScriptPython: - if (state != SCE_HP_COMMENTLINE) { + if (state != SCE_HP_COMMENTLINE && !isMako) { if ((ch == ':') && ((chNext == '\n') || (chNext == '\r' && chNext2 == '\n'))) { levelCurrent++; } else if ((ch == '\n') && !((chNext == '\r') && (chNext2 == '\n')) && (chNext != '\n')) { // check if the number of tabs is lower than the level int Findlevel = (levelCurrent & ~SC_FOLDLEVELBASE) * 8; - for (int j = 0; Findlevel > 0; j++) { - char chTmp = styler.SafeGetCharAt(i + j + 1); + for (Sci_Position j = 0; Findlevel > 0; j++) { + const char chTmp = styler.SafeGetCharAt(i + j + 1); if (chTmp == '\t') { Findlevel -= 8; } else if (chTmp == ' ') { @@ -700,14 +1157,39 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty visibleChars = 0; levelPrev = levelCurrent; } - lineCurrent++; styler.SetLineState(lineCurrent, ((inScriptType & 0x03) << 0) | - ((tagOpened & 0x01) << 2) | - ((tagClosing & 0x01) << 3) | + ((tagOpened ? 1 : 0) << 2) | + ((tagClosing ? 1 : 0) << 3) | ((aspScript & 0x0F) << 4) | ((clientScript & 0x0F) << 8) | ((beforePreProc & 0xFF) << 12)); + lineCurrent++; + lineStartVisibleChars = 0; + } + + // handle start of Mako comment line + if (isMako && ch == '#' && chNext == '#') { + makoComment = 1; + state = SCE_HP_COMMENTLINE; + } + + // handle end of Mako comment line + else if (isMako && makoComment && (ch == '\r' || ch == '\n')) { + makoComment = 0; + styler.ColourTo(i - 1, StateToPrint); + if (scriptLanguage == eScriptPython) { + state = SCE_HP_DEFAULT; + } else { + state = SCE_H_DEFAULT; + } + } + // Allow falling through to mako handling code if newline is going to end a block + if (((ch == '\r' && chNext != '\n') || (ch == '\n')) && + (!isMako || (makoBlockType != "%"))) { + } + // Ignore everything in mako comment until the line ends + else if (isMako && makoComment) { } // generic end of script processing @@ -741,7 +1223,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (const char *tag = state == SCE_HJ_COMMENTLINE || isXml ? "script" : state == SCE_H_COMMENT ? "comment" : 0) { - int j = i + 2; + Sci_Position j = i + 2; int chr; do { chr = static_cast(*tag++); @@ -757,6 +1239,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty i += 2; visibleChars += 2; tagClosing = true; + if (foldXmlAtTagOpen) { + levelCurrent--; + } continue; } } @@ -764,13 +1249,15 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty ///////////////////////////////////// // handle the start of PHP pre-processor = Non-HTML else if ((state != SCE_H_ASPAT) && - !isPHPStringState(state) && + !isStringState(state) && (state != SCE_HPHP_COMMENT) && + (state != SCE_HPHP_COMMENTLINE) && (ch == '<') && (chNext == '?') && - !IsScriptCommentState(state) ) { - scriptLanguage = segIsScriptingIndicator(styler, i + 2, i + 6, eScriptPHP); - if (scriptLanguage != eScriptPHP && isStringState(state)) continue; + !IsScriptCommentState(state)) { + beforeLanguage = scriptLanguage; + scriptLanguage = segIsScriptingIndicator(styler, i + 2, i + 6, isXml ? eScriptXML : eScriptPHP); + if ((scriptLanguage != eScriptPHP) && (isStringState(state) || (state==SCE_H_COMMENT))) continue; styler.ColourTo(i - 1, StateToPrint); beforePreProc = state; i++; @@ -794,8 +1281,106 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty continue; } + // handle the start Mako template Python code + else if (isMako && scriptLanguage == eScriptNone && ((ch == '<' && chNext == '%') || + (lineStartVisibleChars == 1 && ch == '%') || + (lineStartVisibleChars == 1 && ch == '/' && chNext == '%') || + (ch == '$' && chNext == '{') || + (ch == '<' && chNext == '/' && chNext2 == '%'))) { + if (ch == '%' || ch == '/') + makoBlockType = "%"; + else if (ch == '$') + makoBlockType = "{"; + else if (chNext == '/') + makoBlockType = GetNextWord(styler, i+3); + else + makoBlockType = GetNextWord(styler, i+2); + styler.ColourTo(i - 1, StateToPrint); + beforePreProc = state; + if (inScriptType == eNonHtmlScript) + inScriptType = eNonHtmlScriptPreProc; + else + inScriptType = eNonHtmlPreProc; + + if (chNext == '/') { + i += 2; + visibleChars += 2; + } else if (ch != '%') { + i++; + visibleChars++; + } + state = SCE_HP_START; + scriptLanguage = eScriptPython; + styler.ColourTo(i, SCE_H_ASP); + if (ch != '%' && ch != '$' && ch != '/') { + i += makoBlockType.length(); + visibleChars += static_cast(makoBlockType.length()); + if (keywords4.InList(makoBlockType.c_str())) + styler.ColourTo(i, SCE_HP_WORD); + else + styler.ColourTo(i, SCE_H_TAGUNKNOWN); + } + + ch = static_cast(styler.SafeGetCharAt(i)); + continue; + } + + // handle the start/end of Django comment + else if (isDjango && state != SCE_H_COMMENT && (ch == '{' && chNext == '#')) { + styler.ColourTo(i - 1, StateToPrint); + beforePreProc = state; + beforeLanguage = scriptLanguage; + if (inScriptType == eNonHtmlScript) + inScriptType = eNonHtmlScriptPreProc; + else + inScriptType = eNonHtmlPreProc; + i += 1; + visibleChars += 1; + scriptLanguage = eScriptComment; + state = SCE_H_COMMENT; + styler.ColourTo(i, SCE_H_ASP); + ch = static_cast(styler.SafeGetCharAt(i)); + continue; + } else if (isDjango && state == SCE_H_COMMENT && (ch == '#' && chNext == '}')) { + styler.ColourTo(i - 1, StateToPrint); + i += 1; + visibleChars += 1; + styler.ColourTo(i, SCE_H_ASP); + state = beforePreProc; + if (inScriptType == eNonHtmlScriptPreProc) + inScriptType = eNonHtmlScript; + else + inScriptType = eHtml; + scriptLanguage = beforeLanguage; + continue; + } + + // handle the start Django template code + else if (isDjango && scriptLanguage != eScriptPython && scriptLanguage != eScriptComment && (ch == '{' && (chNext == '%' || chNext == '{'))) { + if (chNext == '%') + djangoBlockType = "%"; + else + djangoBlockType = "{"; + styler.ColourTo(i - 1, StateToPrint); + beforePreProc = state; + if (inScriptType == eNonHtmlScript) + inScriptType = eNonHtmlScriptPreProc; + else + inScriptType = eNonHtmlPreProc; + + i += 1; + visibleChars += 1; + state = SCE_HP_START; + beforeLanguage = scriptLanguage; + scriptLanguage = eScriptPython; + styler.ColourTo(i, SCE_H_ASP); + + ch = static_cast(styler.SafeGetCharAt(i)); + continue; + } + // handle the start of ASP pre-processor = Non-HTML - else if (!isCommentASPState(state) && (ch == '<') && (chNext == '%') && !isPHPStringState(state)) { + else if (!isMako && !isDjango && !isCommentASPState(state) && (ch == '<') && (chNext == '%') && !isPHPStringState(state)) { styler.ColourTo(i - 1, StateToPrint); beforePreProc = state; if (inScriptType == eNonHtmlScript) @@ -840,7 +1425,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty (ch == '!') && (StateToPrint != SCE_H_CDATA) && (!IsCommentState(StateToPrint)) && - (!IsScriptCommentState(StateToPrint)) ) { + (!IsScriptCommentState(StateToPrint))) { beforePreProc = state; styler.ColourTo(i - 2, StateToPrint); if ((chNext == '-') && (chNext2 == '-')) { @@ -855,17 +1440,75 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_H_SGML_COMMAND; // wait for a pending command } // fold whole tag (-- when closing the tag) - if (foldHTMLPreprocessor) + if (foldHTMLPreprocessor || state == SCE_H_COMMENT || state == SCE_H_CDATA) levelCurrent++; continue; } + // handle the end of Mako Python code + else if (isMako && + ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && + (scriptLanguage != eScriptNone) && stateAllowsTermination(state) && + isMakoBlockEnd(ch, chNext, makoBlockType)) { + if (state == SCE_H_ASPAT) { + aspScript = segIsScriptingIndicator(styler, + styler.GetStartSegment(), i - 1, aspScript); + } + if (state == SCE_HP_WORD) { + classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako); + } else { + styler.ColourTo(i - 1, StateToPrint); + } + if ((makoBlockType != "%") && (makoBlockType != "{") && ch != '>') { + i++; + visibleChars++; + } + else if ((makoBlockType == "%") && ch == '/') { + i++; + visibleChars++; + } + if ((makoBlockType != "%") || ch == '/') { + styler.ColourTo(i, SCE_H_ASP); + } + state = beforePreProc; + if (inScriptType == eNonHtmlScriptPreProc) + inScriptType = eNonHtmlScript; + else + inScriptType = eHtml; + scriptLanguage = eScriptNone; + continue; + } + + // handle the end of Django template code + else if (isDjango && + ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && + (scriptLanguage != eScriptNone) && stateAllowsTermination(state) && + isDjangoBlockEnd(ch, chNext, djangoBlockType)) { + if (state == SCE_H_ASPAT) { + aspScript = segIsScriptingIndicator(styler, + styler.GetStartSegment(), i - 1, aspScript); + } + if (state == SCE_HP_WORD) { + classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako); + } else { + styler.ColourTo(i - 1, StateToPrint); + } + i += 1; + visibleChars += 1; + styler.ColourTo(i, SCE_H_ASP); + state = beforePreProc; + if (inScriptType == eNonHtmlScriptPreProc) + inScriptType = eNonHtmlScript; + else + inScriptType = eHtml; + scriptLanguage = beforeLanguage; + continue; + } + // handle the end of a pre-processor = Non-HTML - else if (( - ((inScriptType == eNonHtmlPreProc) - || (inScriptType == eNonHtmlScriptPreProc)) && ( - ((scriptLanguage != eScriptNone) && stateAllowsTermination(state) && ((ch == '%') || (ch == '?'))) - ) && (chNext == '>')) || + else if ((!isMako && !isDjango && ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && + (((scriptLanguage != eScriptNone) && stateAllowsTermination(state))) && + (((ch == '%') || (ch == '?')) && (chNext == '>'))) || ((scriptLanguage == eScriptSGML) && (ch == '>') && (state != SCE_H_SGML_COMMENT))) { if (state == SCE_H_ASPAT) { aspScript = segIsScriptingIndicator(styler, @@ -880,7 +1523,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty classifyWordHTVB(styler.GetStartSegment(), i - 1, keywords3, styler, inScriptType); break; case SCE_HP_WORD: - classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType); + classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako); break; case SCE_HPHP_WORD: classifyWordHTPHP(styler.GetStartSegment(), i - 1, keywords5, styler); @@ -913,7 +1556,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (foldHTMLPreprocessor && (scriptLanguage != eScriptXML)) { levelCurrent--; } - scriptLanguage = eScriptNone; + scriptLanguage = beforeLanguage; continue; } ///////////////////////////////////// @@ -924,6 +1567,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty // in HTML, fold on tag open and unfold on tag close tagOpened = true; tagClosing = (chNext == '/'); + if (foldXmlAtTagOpen && !(chNext == '/' || chNext == '?' || chNext == '!' || chNext == '-' || chNext == '%')) { + levelCurrent++; + } + if (foldXmlAtTagOpen && chNext == '/') { + levelCurrent--; + } styler.ColourTo(i - 1, StateToPrint); if (chNext != '!') state = SCE_H_TAGUNKNOWN; @@ -944,11 +1593,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.ColourTo(i - 1, StateToPrint); state = SCE_H_SGML_SIMPLESTRING; } else if ((ch == '-') && (chPrev == '-')) { - if (static_cast(styler.GetStartSegment()) <= (i - 2)) { + if (static_cast(styler.GetStartSegment()) <= (i - 2)) { styler.ColourTo(i - 2, StateToPrint); } state = SCE_H_SGML_COMMENT; - } else if (isascii(ch) && isalpha(ch) && (chPrev == '%')) { + } else if (IsASCII(ch) && isalpha(ch) && (chPrev == '%')) { styler.ColourTo(i - 2, StateToPrint); state = SCE_H_SGML_ENTITY; } else if (ch == '#') { @@ -1027,6 +1676,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.ColourTo(i - 2, StateToPrint); state = SCE_H_SGML_COMMENT; } + break; case SCE_H_SGML_DOUBLESTRING: if (ch == '\"') { styler.ColourTo(i, StateToPrint); @@ -1066,7 +1716,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } break; case SCE_H_SGML_SPECIAL: - if (!(isascii(ch) && isupper(ch))) { + if (!(IsASCII(ch) && isupper(ch))) { styler.ColourTo(i - 1, StateToPrint); if (isalnum(ch)) { state = SCE_H_SGML_ERROR; @@ -1079,7 +1729,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (ch == ';') { styler.ColourTo(i, StateToPrint); state = SCE_H_SGML_DEFAULT; - } else if (!(isascii(ch) && isalnum(ch)) && ch != '-' && ch != '.') { + } else if (!(IsASCII(ch) && isalnum(ch)) && ch != '-' && ch != '.') { styler.ColourTo(i, SCE_H_SGML_ERROR); state = SCE_H_SGML_DEFAULT; } @@ -1089,16 +1739,19 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.ColourTo(i, StateToPrint); state = SCE_H_DEFAULT; } - if (ch != '#' && !(isascii(ch) && isalnum(ch)) // Should check that '#' follows '&', but it is unlikely anyway... + if (ch != '#' && !(IsASCII(ch) && isalnum(ch)) // Should check that '#' follows '&', but it is unlikely anyway... && ch != '.' && ch != '-' && ch != '_' && ch != ':') { // valid in XML - styler.ColourTo(i, SCE_H_TAGUNKNOWN); + if (!IsASCII(ch)) // Possibly start of a multibyte character so don't allow this byte to be in entity style + styler.ColourTo(i-1, SCE_H_TAGUNKNOWN); + else + styler.ColourTo(i, SCE_H_TAGUNKNOWN); state = SCE_H_DEFAULT; } break; case SCE_H_TAGUNKNOWN: if (!setTagContinue.Contains(ch) && !((ch == '/') && (chPrev == '<'))) { int eClass = classifyTagHTML(styler.GetStartSegment(), - i - 1, keywords, styler, tagDontFold, caseSensitive, isXml, allowScripts); + i - 1, keywords, styler, tagDontFold, caseSensitive, isXml, allowScripts, nonFoldingTags); if (eClass == SCE_H_SCRIPT || eClass == SCE_H_COMMENT) { if (!tagClosing) { inScriptType = eNonHtmlScript; @@ -1116,7 +1769,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_H_DEFAULT; } tagOpened = false; - if (!tagDontFold) { + if (!(foldXmlAtTagOpen || tagDontFold)) { if (tagClosing) { levelCurrent--; } else { @@ -1135,6 +1788,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty ch = chNext; state = SCE_H_DEFAULT; tagOpened = false; + if (foldXmlAtTagOpen) { + levelCurrent--; + } } else { if (eClass != SCE_H_TAGUNKNOWN) { if (eClass == SCE_H_SGML_DEFAULT) { @@ -1149,7 +1805,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty case SCE_H_ATTRIBUTE: if (!setAttributeContinue.Contains(ch)) { if (inScriptType == eNonHtmlScript) { - int scriptLanguagePrev = scriptLanguage; + const int scriptLanguagePrev = scriptLanguage; clientScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage); scriptLanguage = clientScript; if ((scriptLanguagePrev != scriptLanguage) && (scriptLanguage == eScriptNone)) @@ -1164,7 +1820,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_H_DEFAULT; } tagOpened = false; - if (!tagDontFold) { + if (!(foldXmlAtTagOpen || tagDontFold)) { if (tagClosing) { levelCurrent--; } else { @@ -1190,7 +1846,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_H_DEFAULT; } tagOpened = false; - if (!tagDontFold) { + if (!(foldXmlAtTagOpen || tagDontFold)) { if (tagClosing) { levelCurrent--; } else { @@ -1214,6 +1870,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty ch = chNext; state = SCE_H_DEFAULT; tagOpened = false; + if (foldXmlAtTagOpen) { + levelCurrent--; + } } else if (ch == '?' && chNext == '>') { styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i + 1, SCE_H_XMLEND); @@ -1290,10 +1949,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_HJ_COMMENTDOC; else state = SCE_HJ_COMMENT; + if (chNext2 == '/') { + // Eat the * so it isn't used for the end of the comment + i++; + } } else if (ch == '/' && chNext == '/') { styler.ColourTo(i - 1, StateToPrint); state = SCE_HJ_COMMENTLINE; - } else if (ch == '/' && isOKBeforeRE(chPrevNonWhite)) { + } else if (ch == '/' && setOKBeforeJSRE.Contains(chPrevNonWhite)) { styler.ColourTo(i - 1, StateToPrint); state = SCE_HJ_REGEX; } else if (ch == '\"') { @@ -1393,7 +2056,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty i += 2; } else if (isLineEnd(ch)) { styler.ColourTo(i - 1, StateToPrint); - state = SCE_HJ_STRINGEOL; + if (chPrev != '\\' && (chPrev2 != '\\' || chPrev != '\r' || ch != '\n')) { + state = SCE_HJ_STRINGEOL; + } } break; case SCE_HJ_STRINGEOL: @@ -1408,7 +2073,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty case SCE_HJ_REGEX: if (ch == '\r' || ch == '\n' || ch == '/') { if (ch == '/') { - while (isascii(chNext) && islower(chNext)) { // gobble regex flags + while (IsASCII(chNext) && islower(chNext)) { // gobble regex flags i++; ch = chNext; chNext = static_cast(styler.SafeGetCharAt(i + 1)); @@ -1537,7 +2202,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty break; case SCE_HP_WORD: if (!IsAWordChar(ch)) { - classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType); + classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako); state = SCE_HP_DEFAULT; if (ch == '#') { state = SCE_HP_COMMENTLINE; @@ -1622,17 +2287,17 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_HPHP_COMMENTLINE; } else if (ch == '\"') { state = SCE_HPHP_HSTRING; - strcpy(phpStringDelimiter, "\""); + phpStringDelimiter = "\""; } else if (styler.Match(i, "<<<")) { bool isSimpleString = false; - i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler, isSimpleString); - if (strlen(phpStringDelimiter)) { + i = FindPhpStringDelimiter(phpStringDelimiter, i + 3, lengthDoc, styler, isSimpleString); + if (!phpStringDelimiter.empty()) { state = (isSimpleString ? SCE_HPHP_SIMPLESTRING : SCE_HPHP_HSTRING); if (foldHeredoc) levelCurrent++; } } else if (ch == '\'') { state = SCE_HPHP_SIMPLESTRING; - strcpy(phpStringDelimiter, "\'"); + phpStringDelimiter = "\'"; } else if (ch == '$' && IsPhpWordStart(chNext)) { state = SCE_HPHP_VARIABLE; } else if (IsOperator(ch)) { @@ -1673,7 +2338,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } break; case SCE_HPHP_HSTRING: - if (ch == '\\' && (phpStringDelimiter[0] == '\"' || chNext == '$' || chNext == '{')) { + if (ch == '\\' && ((phpStringDelimiter == "\"") || chNext == '$' || chNext == '{')) { // skip the next char i++; } else if (((ch == '{' && chNext == '$') || (ch == '$' && chNext == '{')) @@ -1683,12 +2348,12 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } else if (ch == '$' && IsPhpWordStart(chNext)) { styler.ColourTo(i - 1, StateToPrint); state = SCE_HPHP_HSTRING_VARIABLE; - } else if (styler.Match(i, phpStringDelimiter)) { - if (phpStringDelimiter[0] == '\"') { + } else if (styler.Match(i, phpStringDelimiter.c_str())) { + if (phpStringDelimiter == "\"") { styler.ColourTo(i, StateToPrint); state = SCE_HPHP_DEFAULT; } else if (isLineEnd(chPrev)) { - const int psdLength = strlen(phpStringDelimiter); + const int psdLength = static_cast(phpStringDelimiter.length()); const char chAfterPsd = styler.SafeGetCharAt(i + psdLength); const char chAfterPsd2 = styler.SafeGetCharAt(i + psdLength + 1); if (isLineEnd(chAfterPsd) || @@ -1702,7 +2367,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } break; case SCE_HPHP_SIMPLESTRING: - if (phpStringDelimiter[0] == '\'') { + if (phpStringDelimiter == "\'") { if (ch == '\\') { // skip the next char i++; @@ -1710,8 +2375,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.ColourTo(i, StateToPrint); state = SCE_HPHP_DEFAULT; } - } else if (isLineEnd(chPrev) && styler.Match(i, phpStringDelimiter)) { - const int psdLength = strlen(phpStringDelimiter); + } else if (isLineEnd(chPrev) && styler.Match(i, phpStringDelimiter.c_str())) { + const int psdLength = static_cast(phpStringDelimiter.length()); const char chAfterPsd = styler.SafeGetCharAt(i + psdLength); const char chAfterPsd2 = styler.SafeGetCharAt(i + psdLength + 1); if (isLineEnd(chAfterPsd) || @@ -1752,17 +2417,17 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_HPHP_COMMENTLINE; } else if (ch == '\"') { state = SCE_HPHP_HSTRING; - strcpy(phpStringDelimiter, "\""); + phpStringDelimiter = "\""; } else if (styler.Match(i, "<<<")) { bool isSimpleString = false; - i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler, isSimpleString); - if (strlen(phpStringDelimiter)) { + i = FindPhpStringDelimiter(phpStringDelimiter, i + 3, lengthDoc, styler, isSimpleString); + if (!phpStringDelimiter.empty()) { state = (isSimpleString ? SCE_HPHP_SIMPLESTRING : SCE_HPHP_HSTRING); if (foldHeredoc) levelCurrent++; } } else if (ch == '\'') { state = SCE_HPHP_SIMPLESTRING; - strcpy(phpStringDelimiter, "\'"); + phpStringDelimiter = "\'"; } else if (ch == '$' && IsPhpWordStart(chNext)) { state = SCE_HPHP_VARIABLE; } else if (IsOperator(ch)) { @@ -1777,7 +2442,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty // Some of the above terminated their lexeme but since the same character starts // the same class again, only reenter if non empty segment. - bool nonEmptySegment = i >= static_cast(styler.GetStartSegment()); + const bool nonEmptySegment = i >= static_cast(styler.GetStartSegment()); if (state == SCE_HB_DEFAULT) { // One of the above succeeded if ((ch == '\"') && (nonEmptySegment)) { state = SCE_HB_STRING; @@ -1826,359 +2491,26 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty classifyWordHTVB(styler.GetStartSegment(), lengthDoc - 1, keywords3, styler, inScriptType); break; case SCE_HP_WORD: - classifyWordHTPy(styler.GetStartSegment(), lengthDoc - 1, keywords4, styler, prevWord, inScriptType); + classifyWordHTPy(styler.GetStartSegment(), lengthDoc - 1, keywords4, styler, prevWord, inScriptType, isMako); break; case SCE_HPHP_WORD: classifyWordHTPHP(styler.GetStartSegment(), lengthDoc - 1, keywords5, styler); break; default: StateToPrint = statePrintForState(state, inScriptType); - styler.ColourTo(lengthDoc - 1, StateToPrint); + if (static_cast(styler.GetStartSegment()) < lengthDoc) + styler.ColourTo(lengthDoc - 1, StateToPrint); break; } // Fill in the real level of the next line, keeping the current flags as they will be filled in later if (fold) { - int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; + const int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, levelPrev | flagsNext); } + styler.Flush(); } -static void ColouriseXMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler) { - // Passing in true because we're lexing XML - ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists, styler, true); -} - -static void ColouriseHTMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler) { - // Passing in false because we're notlexing XML - ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists, styler, false); -} - -static bool isASPScript(int state) { - return - (state >= SCE_HJA_START && state <= SCE_HJA_REGEX) || - (state >= SCE_HBA_START && state <= SCE_HBA_STRINGEOL) || - (state >= SCE_HPA_DEFAULT && state <= SCE_HPA_IDENTIFIER); -} - -static void ColouriseHBAPiece(StyleContext &sc, WordList *keywordlists[]) { - WordList &keywordsVBS = *keywordlists[2]; - if (sc.state == SCE_HBA_WORD) { - if (!IsAWordChar(sc.ch)) { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (keywordsVBS.InList(s)) { - if (strcmp(s, "rem") == 0) { - sc.ChangeState(SCE_HBA_COMMENTLINE); - if (sc.atLineEnd) { - sc.SetState(SCE_HBA_DEFAULT); - } - } else { - sc.SetState(SCE_HBA_DEFAULT); - } - } else { - sc.ChangeState(SCE_HBA_IDENTIFIER); - sc.SetState(SCE_HBA_DEFAULT); - } - } - } else if (sc.state == SCE_HBA_NUMBER) { - if (!IsAWordChar(sc.ch)) { - sc.SetState(SCE_HBA_DEFAULT); - } - } else if (sc.state == SCE_HBA_STRING) { - if (sc.ch == '\"') { - sc.ForwardSetState(SCE_HBA_DEFAULT); - } else if (sc.ch == '\r' || sc.ch == '\n') { - sc.ChangeState(SCE_HBA_STRINGEOL); - sc.ForwardSetState(SCE_HBA_DEFAULT); - } - } else if (sc.state == SCE_HBA_COMMENTLINE) { - if (sc.ch == '\r' || sc.ch == '\n') { - sc.SetState(SCE_HBA_DEFAULT); - } - } - - if (sc.state == SCE_HBA_DEFAULT) { - if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { - sc.SetState(SCE_HBA_NUMBER); - } else if (IsAWordStart(sc.ch)) { - sc.SetState(SCE_HBA_WORD); - } else if (sc.ch == '\'') { - sc.SetState(SCE_HBA_COMMENTLINE); - } else if (sc.ch == '\"') { - sc.SetState(SCE_HBA_STRING); - } - } -} - -static void ColouriseHTMLPiece(StyleContext &sc, WordList *keywordlists[]) { - WordList &keywordsTags = *keywordlists[0]; - if (sc.state == SCE_H_COMMENT) { - if (sc.Match("-->")) { - sc.Forward(); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } - } else if (sc.state == SCE_H_ENTITY) { - if (sc.ch == ';') { - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.ch != '#' && (sc.ch < 0x80) && !isalnum(sc.ch) // Should check that '#' follows '&', but it is unlikely anyway... - && sc.ch != '.' && sc.ch != '-' && sc.ch != '_' && sc.ch != ':') { // valid in XML - sc.ChangeState(SCE_H_TAGUNKNOWN); - sc.SetState(SCE_H_DEFAULT); - } - } else if (sc.state == SCE_H_TAGUNKNOWN) { - if (!ishtmlwordchar(sc.ch) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (s[1] == '/') { - if (keywordsTags.InList(s + 2)) { - sc.ChangeState(SCE_H_TAG); - } - } else { - if (keywordsTags.InList(s + 1)) { - sc.ChangeState(SCE_H_TAG); - } - } - if (sc.ch == '>') { - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.Match('/', '>')) { - sc.SetState(SCE_H_TAGEND); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } else { - sc.SetState(SCE_H_OTHER); - } - } - } else if (sc.state == SCE_H_ATTRIBUTE) { - if (!ishtmlwordchar(sc.ch)) { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (!keywordsTags.InList(s)) { - sc.ChangeState(SCE_H_ATTRIBUTEUNKNOWN); - } - sc.SetState(SCE_H_OTHER); - } - } else if (sc.state == SCE_H_OTHER) { - if (sc.ch == '>') { - sc.SetState(SCE_H_TAG); - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.Match('/', '>')) { - sc.SetState(SCE_H_TAG); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.chPrev == '=') { - sc.SetState(SCE_H_VALUE); - } - } else if (sc.state == SCE_H_DOUBLESTRING) { - if (sc.ch == '\"') { - sc.ForwardSetState(SCE_H_OTHER); - } - } else if (sc.state == SCE_H_SINGLESTRING) { - if (sc.ch == '\'') { - sc.ForwardSetState(SCE_H_OTHER); - } - } else if (sc.state == SCE_H_NUMBER) { - if (!IsADigit(sc.ch)) { - sc.SetState(SCE_H_OTHER); - } - } - - if (sc.state == SCE_H_DEFAULT) { - if (sc.ch == '<') { - if (sc.Match(" "+/*" would be recognized as a sequence of operators + + // if (!IsOperator(sc.ch)) sc.SetState(SCE_HOLLYWOOD_DEFAULT); + sc.SetState(SCE_HOLLYWOOD_DEFAULT); + + } else if (sc.state == SCE_HOLLYWOOD_PREPROCESSOR) { + if (!IsIdentifier(sc.ch)) + sc.SetState(SCE_HOLLYWOOD_DEFAULT); + } else if (sc.state == SCE_HOLLYWOOD_CONSTANT) { + if (!IsIdentifier(sc.ch)) + sc.SetState(SCE_HOLLYWOOD_DEFAULT); + } else if (sc.state == SCE_HOLLYWOOD_NUMBER) { + if (!IsDigit(sc.ch) && sc.ch != '.') + sc.SetState(SCE_HOLLYWOOD_DEFAULT); + } else if (sc.state == SCE_HOLLYWOOD_HEXNUMBER) { + if (!IsHexDigit(sc.ch)) + sc.SetState(SCE_HOLLYWOOD_DEFAULT); + } else if (sc.state == SCE_HOLLYWOOD_STRING) { + if (sc.ch == '"') { + sc.ForwardSetState(SCE_HOLLYWOOD_DEFAULT); + } + if (sc.atLineEnd) { + sc.SetState(SCE_HOLLYWOOD_DEFAULT); + } + } else if (sc.state == SCE_HOLLYWOOD_COMMENT) { + if (sc.atLineEnd) { + sc.SetState(SCE_HOLLYWOOD_DEFAULT); + } + } else if (sc.state == SCE_HOLLYWOOD_COMMENTBLOCK) { + if (sc.Match("*/") && !inString) { + sc.Forward(); + sc.ForwardSetState(SCE_HOLLYWOOD_DEFAULT); + } + } else if (sc.state == SCE_HOLLYWOOD_STRINGBLOCK) { + if (sc.Match("]]") && !inString) { + sc.Forward(); + sc.ForwardSetState(SCE_HOLLYWOOD_DEFAULT); + } + } + + if (sc.state == SCE_HOLLYWOOD_DEFAULT) { + if (sc.Match(';')) { + sc.SetState(SCE_HOLLYWOOD_COMMENT); + } else if (sc.Match("/*")) { + sc.SetState(SCE_HOLLYWOOD_COMMENTBLOCK); + sc.Forward(); + } else if (sc.Match("[[")) { + sc.SetState(SCE_HOLLYWOOD_STRINGBLOCK); + sc.Forward(); + } else if (sc.Match('"')) { + sc.SetState(SCE_HOLLYWOOD_STRING); + } else if (sc.Match('$')) { + sc.SetState(SCE_HOLLYWOOD_HEXNUMBER); + } else if (sc.Match("0x") || sc.Match("0X")) { // must be before IsDigit() because of 0x + sc.SetState(SCE_HOLLYWOOD_HEXNUMBER); + sc.Forward(); + } else if (sc.ch == '.' && (sc.chNext >= '0' && sc.chNext <= '9')) { // ".1234" style numbers + sc.SetState(SCE_HOLLYWOOD_NUMBER); + sc.Forward(); + } else if (IsDigit(sc.ch)) { + sc.SetState(SCE_HOLLYWOOD_NUMBER); + } else if (sc.Match('#')) { + sc.SetState(SCE_HOLLYWOOD_CONSTANT); + } else if (sc.Match('@')) { + sc.SetState(SCE_HOLLYWOOD_PREPROCESSOR); + } else if (IsOperator(sc.ch)) { + sc.SetState(SCE_HOLLYWOOD_OPERATOR); + } else if (IsIdentifier(sc.ch)) { + sc.SetState(SCE_HOLLYWOOD_IDENTIFIER); + } + } + + if (!sc.More()) + break; + } + sc.Complete(); +} + +void SCI_METHOD LexerHollywood::Fold(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, IDocument *pAccess) { + + if (!options.fold) + return; + + LexAccessor styler(pAccess); + + Sci_PositionU lengthDoc = 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 done = 0; + char word[256]; + int wordlen = 0; + + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + int style = styleNext; + styleNext = styler.StyleAt(i + 1); + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + if (!done) { + if (wordlen) { // are we scanning a token already? + word[wordlen] = static_cast(LowerCase(ch)); + if (!IsIdentifier(ch)) { // done with token + word[wordlen] = '\0'; + levelCurrent += CheckFoldPoint(word); + done = 1; + } else if (wordlen < 255) { + wordlen++; + } + } else { // start scanning at first non-whitespace character + if (!IsSpace(ch)) { + if (style != SCE_HOLLYWOOD_COMMENTBLOCK && IsIdentifier(ch)) { + word[0] = static_cast(LowerCase(ch)); + wordlen = 1; + } else // done with this line + done = 1; + } + } + } + + if (atEOL) { + int lev = levelPrev; + if (visibleChars == 0 && options.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; + done = 0; + wordlen = 0; + } + if (!IsSpace(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 lmHollywood(SCLEX_HOLLYWOOD, LexerHollywood::LexerFactoryHollywood, "hollywood", hollywoodWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexIndent.cxx b/Pythonwin/Scintilla/lexers/LexIndent.cxx new file mode 100644 index 000000000..053bdd928 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexIndent.cxx @@ -0,0 +1,71 @@ +// Scintilla source code edit control +/** @file LexIndent.cxx + ** Lexer for no language. Used for indentation-based folding of files. + **/ +// 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" + +using namespace Scintilla; + +static void ColouriseIndentDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], + Accessor &styler) { + // Indent language means all style bytes are 0 so just mark the end - no need to fill in. + if (length > 0) { + styler.StartAt(startPos + length - 1); + styler.StartSegment(startPos + length - 1); + styler.ColourTo(startPos + length - 1, 0); + } +} + +static void FoldIndentDoc(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { + int visibleCharsCurrent, visibleCharsNext; + int levelCurrent, levelNext; + Sci_PositionU i, lineEnd; + Sci_PositionU lengthDoc = startPos + length; + Sci_Position lineCurrent = styler.GetLine(startPos); + + i = styler.LineStart(lineCurrent ); + lineEnd = styler.LineStart(lineCurrent+1)-1; + if(lineEnd>=lengthDoc) lineEnd = lengthDoc-1; + while(styler[lineEnd]=='\n' || styler[lineEnd]=='\r') lineEnd--; + for(visibleCharsCurrent=0, levelCurrent=SC_FOLDLEVELBASE; !visibleCharsCurrent && i<=lineEnd; i++){ + if(isspacechar(styler[i])) levelCurrent++; + else visibleCharsCurrent=1; + } + + for(; i=lengthDoc) lineEnd = lengthDoc-1; + while(styler[lineEnd]=='\n' || styler[lineEnd]=='\r') lineEnd--; + for(visibleCharsNext=0, levelNext=SC_FOLDLEVELBASE; !visibleCharsNext && i<=lineEnd; i++){ + if(isspacechar(styler[i])) levelNext++; + else visibleCharsNext=1; + } + int lev = levelCurrent; + if(!visibleCharsCurrent) lev |= SC_FOLDLEVELWHITEFLAG; + else if(levelNext > levelCurrent) lev |= SC_FOLDLEVELHEADERFLAG; + styler.SetLevel(lineCurrent, lev); + levelCurrent = levelNext; + visibleCharsCurrent = visibleCharsNext; + } +} + +LexerModule lmIndent(SCLEX_INDENT, ColouriseIndentDoc, "indent", FoldIndentDoc); diff --git a/Pythonwin/Scintilla/src/LexInno.cxx b/Pythonwin/Scintilla/lexers/LexInno.cxx similarity index 69% rename from Pythonwin/Scintilla/src/LexInno.cxx rename to Pythonwin/Scintilla/lexers/LexInno.cxx index 3af9b2f1d..5d01c0588 100644 --- a/Pythonwin/Scintilla/src/LexInno.cxx +++ b/Pythonwin/Scintilla/lexers/LexInno.cxx @@ -7,32 +7,34 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif -static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) { +static void ColouriseInnoDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_INNO_DEFAULT; char chPrev; char ch = 0; char chNext = styler[startPos]; - int lengthDoc = startPos + length; - char *buffer = new char[length]; - int bufferCount = 0; + Sci_Position lengthDoc = startPos + length; + char *buffer = new char[length+1]; + Sci_Position bufferCount = 0; bool isBOL, isEOL, isWS, isBOLWS = 0; + bool isCStyleComment = false; WordList §ionKeywords = *keywordLists[0]; WordList &standardKeywords = *keywordLists[1]; @@ -41,11 +43,15 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k WordList &pascalKeywords = *keywordLists[4]; WordList &userKeywords = *keywordLists[5]; + Sci_Position curLine = styler.GetLine(startPos); + int curLineState = curLine > 0 ? styler.GetLineState(curLine - 1) : 0; + bool isCode = (curLineState == 1); + // Go through all provided text segment // using the hand-written state machine shown below styler.StartAt(startPos); styler.StartSegment(startPos); - for (int i = startPos; i < lengthDoc; i++) { + for (Sci_Position i = startPos; i < lengthDoc; i++) { chPrev = ch; ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -61,9 +67,15 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k isEOL = (ch == '\n' || ch == '\r'); isWS = (ch == ' ' || ch == '\t'); + if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { + // Remember the line state for future incremental lexing + curLine = styler.GetLine(i); + styler.SetLineState(curLine, (isCode ? 1 : 0)); + } + switch(state) { case SCE_INNO_DEFAULT: - if (ch == ';' && isBOLWS) { + if (!isCode && ch == ';' && isBOLWS) { // Start of a comment state = SCE_INNO_COMMENT; } else if (ch == '[' && isBOLWS) { @@ -73,20 +85,24 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k } else if (ch == '#' && isBOLWS) { // Start of a preprocessor directive state = SCE_INNO_PREPROC; - } else if (ch == '{' && chNext == '#') { - // Start of a preprocessor inline directive - state = SCE_INNO_PREPROC_INLINE; - } else if ((ch == '{' && (chNext == ' ' || chNext == '\t')) - || (ch == '(' && chNext == '*')) { + } else if (!isCode && ch == '{' && chNext != '{' && chPrev != '{') { + // Start of an inline expansion + state = SCE_INNO_INLINE_EXPANSION; + } else if (isCode && (ch == '{' || (ch == '(' && chNext == '*'))) { // Start of a Pascal comment state = SCE_INNO_COMMENT_PASCAL; + isCStyleComment = false; + } else if (isCode && ch == '/' && chNext == '/') { + // Apparently, C-style comments are legal, too + state = SCE_INNO_COMMENT_PASCAL; + isCStyleComment = true; } else if (ch == '"') { // Start of a double-quote string state = SCE_INNO_STRING_DOUBLE; } else if (ch == '\'') { // Start of a single-quote string state = SCE_INNO_STRING_SINGLE; - } else if (isascii(ch) && (isalpha(ch) || (ch == '_'))) { + } else if (IsASCII(ch) && (isalpha(ch) || (ch == '_'))) { // Start of an identifier bufferCount = 0; buffer[bufferCount++] = static_cast(tolower(ch)); @@ -105,20 +121,20 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k break; case SCE_INNO_IDENTIFIER: - if (isascii(ch) && (isalnum(ch) || (ch == '_'))) { + if (IsASCII(ch) && (isalnum(ch) || (ch == '_'))) { buffer[bufferCount++] = static_cast(tolower(ch)); } else { state = SCE_INNO_DEFAULT; buffer[bufferCount] = '\0'; // Check if the buffer contains a keyword - if (standardKeywords.InList(buffer)) { + if (!isCode && standardKeywords.InList(buffer)) { styler.ColourTo(i-1,SCE_INNO_KEYWORD); - } else if (parameterKeywords.InList(buffer)) { + } else if (!isCode && parameterKeywords.InList(buffer)) { styler.ColourTo(i-1,SCE_INNO_PARAMETER); - } else if (pascalKeywords.InList(buffer)) { + } else if (isCode && pascalKeywords.InList(buffer)) { styler.ColourTo(i-1,SCE_INNO_KEYWORD_PASCAL); - } else if (userKeywords.InList(buffer)) { + } else if (!isCode && userKeywords.InList(buffer)) { styler.ColourTo(i-1,SCE_INNO_KEYWORD_USER); } else { styler.ColourTo(i-1,SCE_INNO_DEFAULT); @@ -138,10 +154,11 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k // Check if the buffer contains a section name if (sectionKeywords.InList(buffer)) { styler.ColourTo(i,SCE_INNO_SECTION); + isCode = !CompareCaseInsensitive(buffer, "code"); } else { styler.ColourTo(i,SCE_INNO_DEFAULT); } - } else if (isascii(ch) && (isalnum(ch) || (ch == '_'))) { + } else if (IsASCII(ch) && (isalnum(ch) || (ch == '_'))) { buffer[bufferCount++] = static_cast(tolower(ch)); } else { state = SCE_INNO_DEFAULT; @@ -151,7 +168,7 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k case SCE_INNO_PREPROC: if (isWS || isEOL) { - if (isascii(chPrev) && isalpha(chPrev)) { + if (IsASCII(chPrev) && isalpha(chPrev)) { state = SCE_INNO_DEFAULT; buffer[bufferCount] = '\0'; @@ -166,7 +183,7 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k chNext = styler[i--]; ch = chPrev; } - } else if (isascii(ch) && isalpha(ch)) { + } else if (IsASCII(ch) && isalpha(ch)) { if (chPrev == '#' || chPrev == ' ' || chPrev == '\t') bufferCount = 0; buffer[bufferCount++] = static_cast(tolower(ch)); @@ -187,10 +204,10 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k } break; - case SCE_INNO_PREPROC_INLINE: + case SCE_INNO_INLINE_EXPANSION: if (ch == '}') { state = SCE_INNO_DEFAULT; - styler.ColourTo(i,SCE_INNO_PREPROC_INLINE); + styler.ColourTo(i,SCE_INNO_INLINE_EXPANSION); } else if (isEOL) { state = SCE_INNO_DEFAULT; styler.ColourTo(i,SCE_INNO_DEFAULT); @@ -198,12 +215,19 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k break; case SCE_INNO_COMMENT_PASCAL: - if (ch == '}' || (ch == ')' && chPrev == '*')) { - state = SCE_INNO_DEFAULT; - styler.ColourTo(i,SCE_INNO_COMMENT_PASCAL); - } else if (isEOL) { - state = SCE_INNO_DEFAULT; - styler.ColourTo(i,SCE_INNO_DEFAULT); + if (isCStyleComment) { + if (isEOL) { + state = SCE_INNO_DEFAULT; + styler.ColourTo(i,SCE_INNO_COMMENT_PASCAL); + } + } else { + if (ch == '}' || (ch == ')' && chPrev == '*')) { + state = SCE_INNO_DEFAULT; + styler.ColourTo(i,SCE_INNO_COMMENT_PASCAL); + } else if (isEOL) { + state = SCE_INNO_DEFAULT; + styler.ColourTo(i,SCE_INNO_DEFAULT); + } } break; @@ -222,17 +246,17 @@ static const char * const innoWordListDesc[] = { 0 }; -static void FoldInnoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { - unsigned int endPos = startPos + length; +static void FoldInnoDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { + Sci_PositionU endPos = startPos + length; char chNext = styler[startPos]; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); bool sectionFlag = false; int levelPrev = lineCurrent > 0 ? styler.LevelAt(lineCurrent - 1) : SC_FOLDLEVELBASE; int level; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler[i+1]; bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); diff --git a/Pythonwin/Scintilla/lexers/LexJSON.cxx b/Pythonwin/Scintilla/lexers/LexJSON.cxx new file mode 100644 index 000000000..3712e931f --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexJSON.cxx @@ -0,0 +1,502 @@ +// Scintilla source code edit control +/** + * @file LexJSON.cxx + * @date February 19, 2016 + * @brief Lexer for JSON and JSON-LD formats + * @author nkmathew + * + * The License.txt file describes the conditions under which this software may + * be distributed. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" +#include "WordList.h" +#include "LexAccessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "OptionSet.h" +#include "DefaultLexer.h" + +using namespace Scintilla; + +static const char *const JSONWordListDesc[] = { + "JSON Keywords", + "JSON-LD Keywords", + 0 +}; + +/** + * Used to detect compact IRI/URLs in JSON-LD without first looking ahead for the + * colon separating the prefix and suffix + * + * https://www.w3.org/TR/json-ld/#dfn-compact-iri + */ +struct CompactIRI { + int colonCount; + bool foundInvalidChar; + CharacterSet setCompactIRI; + CompactIRI() { + colonCount = 0; + foundInvalidChar = false; + setCompactIRI = CharacterSet(CharacterSet::setAlpha, "$_-"); + } + void resetState() { + colonCount = 0; + foundInvalidChar = false; + } + void checkChar(int ch) { + if (ch == ':') { + colonCount++; + } else { + foundInvalidChar |= !setCompactIRI.Contains(ch); + } + } + bool shouldHighlight() const { + return !foundInvalidChar && colonCount == 1; + } +}; + +/** + * Keeps track of escaped characters in strings as per: + * + * https://tools.ietf.org/html/rfc7159#section-7 + */ +struct EscapeSequence { + int digitsLeft; + CharacterSet setHexDigits; + CharacterSet setEscapeChars; + EscapeSequence() { + digitsLeft = 0; + setHexDigits = CharacterSet(CharacterSet::setDigits, "ABCDEFabcdef"); + setEscapeChars = CharacterSet(CharacterSet::setNone, "\\\"tnbfru/"); + } + // Returns true if the following character is a valid escaped character + bool newSequence(int nextChar) { + digitsLeft = 0; + if (nextChar == 'u') { + digitsLeft = 5; + } else if (!setEscapeChars.Contains(nextChar)) { + return false; + } + return true; + } + bool atEscapeEnd() const { + return digitsLeft <= 0; + } + bool isInvalidChar(int currChar) const { + return !setHexDigits.Contains(currChar); + } +}; + +struct OptionsJSON { + bool foldCompact; + bool fold; + bool allowComments; + bool escapeSequence; + OptionsJSON() { + foldCompact = false; + fold = false; + allowComments = false; + escapeSequence = false; + } +}; + +struct OptionSetJSON : public OptionSet { + OptionSetJSON() { + DefineProperty("lexer.json.escape.sequence", &OptionsJSON::escapeSequence, + "Set to 1 to enable highlighting of escape sequences in strings"); + + DefineProperty("lexer.json.allow.comments", &OptionsJSON::allowComments, + "Set to 1 to enable highlighting of line/block comments in JSON"); + + DefineProperty("fold.compact", &OptionsJSON::foldCompact); + DefineProperty("fold", &OptionsJSON::fold); + DefineWordListSets(JSONWordListDesc); + } +}; + +class LexerJSON : public DefaultLexer { + OptionsJSON options; + OptionSetJSON optSetJSON; + EscapeSequence escapeSeq; + WordList keywordsJSON; + WordList keywordsJSONLD; + CharacterSet setOperators; + CharacterSet setURL; + CharacterSet setKeywordJSONLD; + CharacterSet setKeywordJSON; + CompactIRI compactIRI; + + static bool IsNextNonWhitespace(LexAccessor &styler, Sci_Position start, char ch) { + Sci_Position i = 0; + while (i < 50) { + i++; + char curr = styler.SafeGetCharAt(start+i, '\0'); + char next = styler.SafeGetCharAt(start+i+1, '\0'); + bool atEOL = (curr == '\r' && next != '\n') || (curr == '\n'); + if (curr == ch) { + return true; + } else if (!isspacechar(curr) || atEOL) { + return false; + } + } + return false; + } + + /** + * Looks for the colon following the end quote + * + * Assumes property names of lengths no longer than a 100 characters. + * The colon is also expected to be less than 50 spaces after the end + * quote for the string to be considered a property name + */ + static bool AtPropertyName(LexAccessor &styler, Sci_Position start) { + Sci_Position i = 0; + bool escaped = false; + while (i < 100) { + i++; + char curr = styler.SafeGetCharAt(start+i, '\0'); + if (escaped) { + escaped = false; + continue; + } + escaped = curr == '\\'; + if (curr == '"') { + return IsNextNonWhitespace(styler, start+i, ':'); + } else if (!curr) { + return false; + } + } + return false; + } + + static bool IsNextWordInList(WordList &keywordList, CharacterSet wordSet, + StyleContext &context, LexAccessor &styler) { + char word[51]; + Sci_Position currPos = (Sci_Position) context.currentPos; + int i = 0; + while (i < 50) { + char ch = styler.SafeGetCharAt(currPos + i); + if (!wordSet.Contains(ch)) { + break; + } + word[i] = ch; + i++; + } + word[i] = '\0'; + return keywordList.InList(word); + } + + public: + LexerJSON() : + DefaultLexer("json", SCLEX_JSON), + setOperators(CharacterSet::setNone, "[{}]:,"), + setURL(CharacterSet::setAlphaNum, "-._~:/?#[]@!$&'()*+,),="), + setKeywordJSONLD(CharacterSet::setAlpha, ":@"), + setKeywordJSON(CharacterSet::setAlpha, "$_") { + } + virtual ~LexerJSON() {} + int SCI_METHOD Version() const override { + return lvRelease5; + } + void SCI_METHOD Release() override { + delete this; + } + const char *SCI_METHOD PropertyNames() override { + return optSetJSON.PropertyNames(); + } + int SCI_METHOD PropertyType(const char *name) override { + return optSetJSON.PropertyType(name); + } + const char *SCI_METHOD DescribeProperty(const char *name) override { + return optSetJSON.DescribeProperty(name); + } + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override { + if (optSetJSON.PropertySet(&options, key, val)) { + return 0; + } + return -1; + } + const char * SCI_METHOD PropertyGet(const char *key) override { + return optSetJSON.PropertyGet(key); + } + Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override { + WordList *wordListN = 0; + switch (n) { + case 0: + wordListN = &keywordsJSON; + break; + case 1: + wordListN = &keywordsJSONLD; + break; + } + Sci_Position firstModification = -1; + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + return firstModification; + } + void *SCI_METHOD PrivateCall(int, void *) override { + return 0; + } + static ILexer5 *LexerFactoryJSON() { + return new LexerJSON; + } + const char *SCI_METHOD DescribeWordListSets() override { + return optSetJSON.DescribeWordListSets(); + } + void SCI_METHOD Lex(Sci_PositionU startPos, + Sci_Position length, + int initStyle, + IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, + Sci_Position length, + int initStyle, + IDocument *pAccess) override; +}; + +void SCI_METHOD LexerJSON::Lex(Sci_PositionU startPos, + Sci_Position length, + int initStyle, + IDocument *pAccess) { + LexAccessor styler(pAccess); + StyleContext context(startPos, length, initStyle, styler); + int stringStyleBefore = SCE_JSON_STRING; + while (context.More()) { + switch (context.state) { + case SCE_JSON_BLOCKCOMMENT: + if (context.Match("*/")) { + context.Forward(); + context.ForwardSetState(SCE_JSON_DEFAULT); + } + break; + case SCE_JSON_LINECOMMENT: + if (context.atLineEnd) { + context.SetState(SCE_JSON_DEFAULT); + } + break; + case SCE_JSON_STRINGEOL: + if (context.atLineStart) { + context.SetState(SCE_JSON_DEFAULT); + } + break; + case SCE_JSON_ESCAPESEQUENCE: + escapeSeq.digitsLeft--; + if (!escapeSeq.atEscapeEnd()) { + if (escapeSeq.isInvalidChar(context.ch)) { + context.SetState(SCE_JSON_ERROR); + } + break; + } + if (context.ch == '"') { + context.SetState(stringStyleBefore); + context.ForwardSetState(SCE_C_DEFAULT); + } else if (context.ch == '\\') { + if (!escapeSeq.newSequence(context.chNext)) { + context.SetState(SCE_JSON_ERROR); + } + context.Forward(); + } else { + context.SetState(stringStyleBefore); + if (context.atLineEnd) { + context.ChangeState(SCE_JSON_STRINGEOL); + } + } + break; + case SCE_JSON_PROPERTYNAME: + case SCE_JSON_STRING: + if (context.ch == '"') { + if (compactIRI.shouldHighlight()) { + context.ChangeState(SCE_JSON_COMPACTIRI); + context.ForwardSetState(SCE_JSON_DEFAULT); + compactIRI.resetState(); + } else { + context.ForwardSetState(SCE_JSON_DEFAULT); + } + } else if (context.atLineEnd) { + context.ChangeState(SCE_JSON_STRINGEOL); + } else if (context.ch == '\\') { + stringStyleBefore = context.state; + if (options.escapeSequence) { + context.SetState(SCE_JSON_ESCAPESEQUENCE); + if (!escapeSeq.newSequence(context.chNext)) { + context.SetState(SCE_JSON_ERROR); + } + } + context.Forward(); + } else if (context.Match("https://") || + context.Match("http://") || + context.Match("ssh://") || + context.Match("git://") || + context.Match("svn://") || + context.Match("ftp://") || + context.Match("mailto:")) { + // Handle most common URI schemes only + stringStyleBefore = context.state; + context.SetState(SCE_JSON_URI); + } else if (context.ch == '@') { + // https://www.w3.org/TR/json-ld/#dfn-keyword + if (IsNextWordInList(keywordsJSONLD, setKeywordJSONLD, context, styler)) { + stringStyleBefore = context.state; + context.SetState(SCE_JSON_LDKEYWORD); + } + } else { + compactIRI.checkChar(context.ch); + } + break; + case SCE_JSON_LDKEYWORD: + case SCE_JSON_URI: + if ((!setKeywordJSONLD.Contains(context.ch) && + (context.state == SCE_JSON_LDKEYWORD)) || + (!setURL.Contains(context.ch))) { + context.SetState(stringStyleBefore); + } + if (context.ch == '"') { + context.ForwardSetState(SCE_JSON_DEFAULT); + } else if (context.atLineEnd) { + context.ChangeState(SCE_JSON_STRINGEOL); + } + break; + case SCE_JSON_OPERATOR: + case SCE_JSON_NUMBER: + context.SetState(SCE_JSON_DEFAULT); + break; + case SCE_JSON_ERROR: + if (context.atLineEnd) { + context.SetState(SCE_JSON_DEFAULT); + } + break; + case SCE_JSON_KEYWORD: + if (!setKeywordJSON.Contains(context.ch)) { + context.SetState(SCE_JSON_DEFAULT); + } + break; + } + if (context.state == SCE_JSON_DEFAULT) { + if (context.ch == '"') { + compactIRI.resetState(); + context.SetState(SCE_JSON_STRING); + Sci_Position currPos = static_cast(context.currentPos); + if (AtPropertyName(styler, currPos)) { + context.SetState(SCE_JSON_PROPERTYNAME); + } + } else if (setOperators.Contains(context.ch)) { + context.SetState(SCE_JSON_OPERATOR); + } else if (options.allowComments && context.Match("/*")) { + context.SetState(SCE_JSON_BLOCKCOMMENT); + context.Forward(); + } else if (options.allowComments && context.Match("//")) { + context.SetState(SCE_JSON_LINECOMMENT); + } else if (setKeywordJSON.Contains(context.ch)) { + if (IsNextWordInList(keywordsJSON, setKeywordJSON, context, styler)) { + context.SetState(SCE_JSON_KEYWORD); + } + } + bool numberStart = + IsADigit(context.ch) && (context.chPrev == '+'|| + context.chPrev == '-' || + context.atLineStart || + IsASpace(context.chPrev) || + setOperators.Contains(context.chPrev)); + bool exponentPart = + tolower(context.ch) == 'e' && + IsADigit(context.chPrev) && + (IsADigit(context.chNext) || + context.chNext == '+' || + context.chNext == '-'); + bool signPart = + (context.ch == '-' || context.ch == '+') && + ((tolower(context.chPrev) == 'e' && IsADigit(context.chNext)) || + ((IsASpace(context.chPrev) || setOperators.Contains(context.chPrev)) + && IsADigit(context.chNext))); + bool adjacentDigit = + IsADigit(context.ch) && IsADigit(context.chPrev); + bool afterExponent = IsADigit(context.ch) && tolower(context.chPrev) == 'e'; + bool dotPart = context.ch == '.' && + IsADigit(context.chPrev) && + IsADigit(context.chNext); + bool afterDot = IsADigit(context.ch) && context.chPrev == '.'; + if (numberStart || + exponentPart || + signPart || + adjacentDigit || + dotPart || + afterExponent || + afterDot) { + context.SetState(SCE_JSON_NUMBER); + } else if (context.state == SCE_JSON_DEFAULT && !IsASpace(context.ch)) { + context.SetState(SCE_JSON_ERROR); + } + } + context.Forward(); + } + context.Complete(); +} + +void SCI_METHOD LexerJSON::Fold(Sci_PositionU startPos, + Sci_Position length, + int, + IDocument *pAccess) { + if (!options.fold) { + return; + } + LexAccessor styler(pAccess); + Sci_PositionU currLine = styler.GetLine(startPos); + Sci_PositionU endPos = startPos + length; + int currLevel = SC_FOLDLEVELBASE; + if (currLine > 0) + currLevel = styler.LevelAt(currLine - 1) >> 16; + int nextLevel = currLevel; + int visibleChars = 0; + for (Sci_PositionU i = startPos; i < endPos; i++) { + char curr = styler.SafeGetCharAt(i); + char next = styler.SafeGetCharAt(i+1); + bool atEOL = (curr == '\r' && next != '\n') || (curr == '\n'); + if (styler.StyleAt(i) == SCE_JSON_OPERATOR) { + if (curr == '{' || curr == '[') { + nextLevel++; + } else if (curr == '}' || curr == ']') { + nextLevel--; + } + } + if (atEOL || i == (endPos-1)) { + int level = currLevel | nextLevel << 16; + if (!visibleChars && options.foldCompact) { + level |= SC_FOLDLEVELWHITEFLAG; + } else if (nextLevel > currLevel) { + level |= SC_FOLDLEVELHEADERFLAG; + } + if (level != styler.LevelAt(currLine)) { + styler.SetLevel(currLine, level); + } + currLine++; + currLevel = nextLevel; + visibleChars = 0; + } + if (!isspacechar(curr)) { + visibleChars++; + } + } +} + +LexerModule lmJSON(SCLEX_JSON, + LexerJSON::LexerFactoryJSON, + "json", + JSONWordListDesc); diff --git a/Pythonwin/Scintilla/lexers/LexKVIrc.cxx b/Pythonwin/Scintilla/lexers/LexKVIrc.cxx new file mode 100644 index 000000000..0cae2a234 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexKVIrc.cxx @@ -0,0 +1,471 @@ +// Scintilla source code edit control +/** @file LexKVIrc.cxx + ** Lexer for KVIrc script. + **/ +// Copyright 2013 by OmegaPhil , based in +// part from LexPython Copyright 1998-2002 by Neil Hodgson +// and LexCmake Copyright 2007 by Cristian Adam + +// 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" + +using namespace Scintilla; + + +/* KVIrc Script syntactic rules: http://www.kvirc.net/doc/doc_syntactic_rules.html */ + +/* Utility functions */ +static inline bool IsAWordChar(int ch) { + + /* Keyword list includes modules, i.e. words including '.', and + * alias namespaces include ':' */ + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.' + || ch == ':'); +} +static inline bool IsAWordStart(int ch) { + + /* Functions (start with '$') are treated separately to keywords */ + return (ch < 0x80) && (isalnum(ch) || ch == '_' ); +} + +/* Interface function called by Scintilla to request some text to be + syntax highlighted */ +static void ColouriseKVIrcDoc(Sci_PositionU startPos, Sci_Position length, + int initStyle, WordList *keywordlists[], + Accessor &styler) +{ + /* Fetching style context */ + StyleContext sc(startPos, length, initStyle, styler); + + /* Accessing keywords and function-marking keywords */ + WordList &keywords = *keywordlists[0]; + WordList &functionKeywords = *keywordlists[1]; + + /* Looping for all characters - only automatically moving forward + * when asked for (transitions leaving strings and keywords do this + * already) */ + bool next = true; + for( ; sc.More(); next ? sc.Forward() : (void)0 ) + { + /* Resetting next */ + next = true; + + /* Dealing with different states */ + switch (sc.state) + { + case SCE_KVIRC_DEFAULT: + + /* Detecting single-line comments + * Unfortunately KVIrc script allows raw '#' to be used, and appending # to an array returns + * its length... + * Going for a compromise where single line comments not + * starting on a newline are allowed in all cases except + * when they are preceeded with an opening bracket or comma + * (this will probably be the most common style a valid + * string-less channel name will be used with), with the + * array length case included + */ + if ( + (sc.ch == '#' && sc.atLineStart) || + (sc.ch == '#' && ( + sc.chPrev != '(' && sc.chPrev != ',' && + sc.chPrev != ']') + ) + ) + { + sc.SetState(SCE_KVIRC_COMMENT); + break; + } + + /* Detecting multi-line comments */ + if (sc.Match('/', '*')) + { + sc.SetState(SCE_KVIRC_COMMENTBLOCK); + break; + } + + /* Detecting strings */ + if (sc.ch == '"') + { + sc.SetState(SCE_KVIRC_STRING); + break; + } + + /* Detecting functions */ + if (sc.ch == '$') + { + sc.SetState(SCE_KVIRC_FUNCTION); + break; + } + + /* Detecting variables */ + if (sc.ch == '%') + { + sc.SetState(SCE_KVIRC_VARIABLE); + break; + } + + /* Detecting numbers - isdigit is unsafe as it does not + * validate, use CharacterSet.h functions */ + if (IsADigit(sc.ch)) + { + sc.SetState(SCE_KVIRC_NUMBER); + break; + } + + /* Detecting words */ + if (IsAWordStart(sc.ch) && IsAWordChar(sc.chNext)) + { + sc.SetState(SCE_KVIRC_WORD); + sc.Forward(); + break; + } + + /* Detecting operators */ + if (isoperator(sc.ch)) + { + sc.SetState(SCE_KVIRC_OPERATOR); + break; + } + + break; + + case SCE_KVIRC_COMMENT: + + /* Breaking out of single line comment when a newline + * is introduced */ + if (sc.ch == '\r' || sc.ch == '\n') + { + sc.SetState(SCE_KVIRC_DEFAULT); + break; + } + + break; + + case SCE_KVIRC_COMMENTBLOCK: + + /* Detecting end of multi-line comment */ + if (sc.Match('*', '/')) + { + // Moving the current position forward two characters + // so that '*/' is included in the comment + sc.Forward(2); + sc.SetState(SCE_KVIRC_DEFAULT); + + /* Comment has been exited and the current position + * moved forward, yet the new current character + * has yet to be defined - loop without moving + * forward again */ + next = false; + break; + } + + break; + + case SCE_KVIRC_STRING: + + /* Detecting end of string - closing speechmarks */ + if (sc.ch == '"') + { + /* Allowing escaped speechmarks to pass */ + if (sc.chPrev == '\\') + break; + + /* Moving the current position forward to capture the + * terminating speechmarks, and ending string */ + sc.ForwardSetState(SCE_KVIRC_DEFAULT); + + /* String has been exited and the current position + * moved forward, yet the new current character + * has yet to be defined - loop without moving + * forward again */ + next = false; + break; + } + + /* Functions and variables are now highlighted in strings + * Detecting functions */ + if (sc.ch == '$') + { + /* Allowing escaped functions to pass */ + if (sc.chPrev == '\\') + break; + + sc.SetState(SCE_KVIRC_STRING_FUNCTION); + break; + } + + /* Detecting variables */ + if (sc.ch == '%') + { + /* Allowing escaped variables to pass */ + if (sc.chPrev == '\\') + break; + + sc.SetState(SCE_KVIRC_STRING_VARIABLE); + break; + } + + /* Breaking out of a string when a newline is introduced */ + if (sc.ch == '\r' || sc.ch == '\n') + { + /* Allowing escaped newlines */ + if (sc.chPrev == '\\') + break; + + sc.SetState(SCE_KVIRC_DEFAULT); + break; + } + + break; + + case SCE_KVIRC_FUNCTION: + case SCE_KVIRC_VARIABLE: + + /* Detecting the end of a function/variable (word) */ + if (!IsAWordChar(sc.ch)) + { + sc.SetState(SCE_KVIRC_DEFAULT); + + /* Word has been exited yet the current character + * has yet to be defined - loop without moving + * forward again */ + next = false; + break; + } + + break; + + case SCE_KVIRC_STRING_FUNCTION: + case SCE_KVIRC_STRING_VARIABLE: + + /* A function or variable in a string + * Detecting the end of a function/variable (word) */ + if (!IsAWordChar(sc.ch)) + { + sc.SetState(SCE_KVIRC_STRING); + + /* Word has been exited yet the current character + * has yet to be defined - loop without moving + * forward again */ + next = false; + break; + } + + break; + + case SCE_KVIRC_NUMBER: + + /* Detecting the end of a number */ + if (!IsADigit(sc.ch)) + { + sc.SetState(SCE_KVIRC_DEFAULT); + + /* Number has been exited yet the current character + * has yet to be defined - loop without moving + * forward */ + next = false; + break; + } + + break; + + case SCE_KVIRC_OPERATOR: + + /* Because '%' is an operator but is also the marker for + * a variable, I need to always treat operators as single + * character strings and therefore redo their detection + * after every character */ + sc.SetState(SCE_KVIRC_DEFAULT); + + /* Operator has been exited yet the current character + * has yet to be defined - loop without moving + * forward */ + next = false; + break; + + case SCE_KVIRC_WORD: + + /* Detecting the end of a word */ + if (!IsAWordChar(sc.ch)) + { + /* Checking if the word was actually a keyword - + * fetching the current word, NULL-terminated like + * the keyword list */ + char s[100]; + Sci_Position wordLen = sc.currentPos - styler.GetStartSegment(); + if (wordLen > 99) + wordLen = 99; /* Include '\0' in buffer */ + Sci_Position i; + for( i = 0; i < wordLen; ++i ) + { + s[i] = styler.SafeGetCharAt( styler.GetStartSegment() + i ); + } + s[wordLen] = '\0'; + + /* Actually detecting keywords and fixing the state */ + if (keywords.InList(s)) + { + /* The SetState call actually commits the + * previous keyword state */ + sc.ChangeState(SCE_KVIRC_KEYWORD); + } + else if (functionKeywords.InList(s)) + { + // Detecting function keywords and fixing the state + sc.ChangeState(SCE_KVIRC_FUNCTION_KEYWORD); + } + + /* Transitioning to default and committing the previous + * word state */ + sc.SetState(SCE_KVIRC_DEFAULT); + + /* Word has been exited yet the current character + * has yet to be defined - loop without moving + * forward again */ + next = false; + break; + } + + break; + } + } + + /* Indicating processing is complete */ + sc.Complete(); +} + +static void FoldKVIrcDoc(Sci_PositionU startPos, Sci_Position length, int /*initStyle - unused*/, + WordList *[], Accessor &styler) +{ + /* Based on CMake's folder */ + + /* Exiting if folding isnt enabled */ + if ( styler.GetPropertyInt("fold") == 0 ) + return; + + /* Obtaining current line number*/ + Sci_Position currentLine = styler.GetLine(startPos); + + /* Obtaining starting character - indentation is done on a line basis, + * not character */ + Sci_PositionU safeStartPos = styler.LineStart( currentLine ); + + /* Initialising current level - this is defined as indentation level + * in the low 12 bits, with flag bits in the upper four bits. + * It looks like two indentation states are maintained in the returned + * 32bit value - 'nextLevel' in the most-significant bits, 'currentLevel' + * in the least-significant bits. Since the next level is the most + * up to date, this must refer to the current state of indentation. + * So the code bitshifts the old current level out of existence to + * get at the actual current state of indentation + * Based on the LexerCPP.cxx line 958 comment */ + int currentLevel = SC_FOLDLEVELBASE; + if (currentLine > 0) + currentLevel = styler.LevelAt(currentLine - 1) >> 16; + int nextLevel = currentLevel; + + // Looping for characters in range + for (Sci_PositionU i = safeStartPos; i < startPos + length; ++i) + { + /* Folding occurs after syntax highlighting, meaning Scintilla + * already knows where the comments are + * Fetching the current state */ + int state = styler.StyleAt(i) & 31; + + switch( styler.SafeGetCharAt(i) ) + { + case '{': + + /* Indenting only when the braces are not contained in + * a comment */ + if (state != SCE_KVIRC_COMMENT && + state != SCE_KVIRC_COMMENTBLOCK) + ++nextLevel; + break; + + case '}': + + /* Outdenting only when the braces are not contained in + * a comment */ + if (state != SCE_KVIRC_COMMENT && + state != SCE_KVIRC_COMMENTBLOCK) + --nextLevel; + break; + + case '\n': + case '\r': + + /* Preparing indentation information to return - combining + * current and next level data */ + int lev = currentLevel | nextLevel << 16; + + /* If the next level increases the indent level, mark the + * current line as a fold point - current level data is + * in the least significant bits */ + if (nextLevel > currentLevel ) + lev |= SC_FOLDLEVELHEADERFLAG; + + /* Updating indentation level if needed */ + if (lev != styler.LevelAt(currentLine)) + styler.SetLevel(currentLine, lev); + + /* Updating variables */ + ++currentLine; + currentLevel = nextLevel; + + /* Dealing with problematic Windows newlines - + * incrementing to avoid the extra newline breaking the + * fold point */ + if (styler.SafeGetCharAt(i) == '\r' && + styler.SafeGetCharAt(i + 1) == '\n') + ++i; + break; + } + } + + /* At this point the data has ended, so presumably the end of the line? + * Preparing indentation information to return - combining current + * and next level data */ + int lev = currentLevel | nextLevel << 16; + + /* If the next level increases the indent level, mark the current + * line as a fold point - current level data is in the least + * significant bits */ + if (nextLevel > currentLevel ) + lev |= SC_FOLDLEVELHEADERFLAG; + + /* Updating indentation level if needed */ + if (lev != styler.LevelAt(currentLine)) + styler.SetLevel(currentLine, lev); +} + +/* Registering wordlists */ +static const char *const kvircWordListDesc[] = { + "primary", + "function_keywords", + 0 +}; + + +/* Registering functions and wordlists */ +LexerModule lmKVIrc(SCLEX_KVIRC, ColouriseKVIrcDoc, "kvirc", FoldKVIrcDoc, + kvircWordListDesc); diff --git a/Pythonwin/Scintilla/src/LexKix.cxx b/Pythonwin/Scintilla/lexers/LexKix.cxx similarity index 85% rename from Pythonwin/Scintilla/src/LexKix.cxx rename to Pythonwin/Scintilla/lexers/LexKix.cxx index 06e7c1791..bcd68137e 100644 --- a/Pythonwin/Scintilla/src/LexKix.cxx +++ b/Pythonwin/Scintilla/lexers/LexKix.cxx @@ -4,25 +4,27 @@ **/ // Copyright 2004 by Manfred Becker // The License.txt file describes the conditions under which this software may be distributed. +// Edited by Lee Wilmott (24-Jun-2014) added support for block comments #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif // Extended to accept accented characters static inline bool IsAWordChar(int ch) { @@ -33,7 +35,7 @@ static inline bool IsOperator(const int ch) { return (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '&' || ch == '|' || ch == '<' || ch == '>' || ch == '='); } -static void ColouriseKixDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseKixDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -51,6 +53,10 @@ static void ColouriseKixDoc(unsigned int startPos, int length, int initStyle, if (sc.atLineEnd) { sc.SetState(SCE_KIX_DEFAULT); } + } else if (sc.state == SCE_KIX_COMMENTSTREAM) { + if (sc.ch == '/' && sc.chPrev == '*') { + sc.ForwardSetState(SCE_KIX_DEFAULT); + } } else if (sc.state == SCE_KIX_STRING1) { // This is a doubles quotes string if (sc.ch == '\"') { @@ -101,6 +107,8 @@ static void ColouriseKixDoc(unsigned int startPos, int length, int initStyle, if (sc.state == SCE_KIX_DEFAULT) { if (sc.ch == ';') { sc.SetState(SCE_KIX_COMMENT); + } else if (sc.ch == '/' && sc.chNext == '*') { + sc.SetState(SCE_KIX_COMMENTSTREAM); } else if (sc.ch == '\"') { sc.SetState(SCE_KIX_STRING1); } else if (sc.ch == '\'') { diff --git a/Pythonwin/Scintilla/lexers/LexLaTeX.cxx b/Pythonwin/Scintilla/lexers/LexLaTeX.cxx new file mode 100644 index 000000000..6376bd7d6 --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexLaTeX.cxx @@ -0,0 +1,559 @@ +// Scintilla source code edit control +/** @file LexLaTeX.cxx + ** Lexer for LaTeX2e. + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +// Modified by G. HU in 2013. Added folding, syntax highting inside math environments, and changed some minor behaviors. + +#include +#include +#include +#include +#include +#include +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "PropSetSimple.h" +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" +#include "DefaultLexer.h" +#include "LexerBase.h" + +using namespace Scintilla; + +using namespace std; + +struct latexFoldSave { + latexFoldSave() : structLev(0) { + for (int i = 0; i < 8; ++i) openBegins[i] = 0; + } + latexFoldSave(const latexFoldSave &save) : structLev(save.structLev) { + for (int i = 0; i < 8; ++i) openBegins[i] = save.openBegins[i]; + } + latexFoldSave &operator=(const latexFoldSave &save) { + if (this != &save) { + structLev = save.structLev; + for (int i = 0; i < 8; ++i) openBegins[i] = save.openBegins[i]; + } + return *this; + } + int openBegins[8]; + Sci_Position structLev; +}; + +class LexerLaTeX : public LexerBase { +private: + vector modes; + void setMode(Sci_Position line, int mode) { + if (line >= static_cast(modes.size())) modes.resize(line + 1, 0); + modes[line] = mode; + } + int getMode(Sci_Position line) { + if (line >= 0 && line < static_cast(modes.size())) return modes[line]; + return 0; + } + void truncModes(Sci_Position numLines) { + if (static_cast(modes.size()) > numLines * 2 + 256) + modes.resize(numLines + 128); + } + + vector saves; + void setSave(Sci_Position line, const latexFoldSave &save) { + if (line >= static_cast(saves.size())) saves.resize(line + 1); + saves[line] = save; + } + void getSave(Sci_Position line, latexFoldSave &save) { + if (line >= 0 && line < static_cast(saves.size())) save = saves[line]; + else { + save.structLev = 0; + for (int i = 0; i < 8; ++i) save.openBegins[i] = 0; + } + } + void truncSaves(Sci_Position numLines) { + if (static_cast(saves.size()) > numLines * 2 + 256) + saves.resize(numLines + 128); + } +public: + static ILexer5 *LexerFactoryLaTeX() { + return new LexerLaTeX(); + } + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override; + + // ILexer5 methods + const char * SCI_METHOD GetName() override { + return "latex"; + } + int SCI_METHOD GetIdentifier() override { + return SCLEX_LATEX; + } +}; + +static bool latexIsSpecial(int ch) { + return (ch == '#') || (ch == '$') || (ch == '%') || (ch == '&') || (ch == '_') || + (ch == '{') || (ch == '}') || (ch == ' '); +} + +static bool latexIsBlank(int ch) { + return (ch == ' ') || (ch == '\t'); +} + +static bool latexIsBlankAndNL(int ch) { + return (ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n'); +} + +static bool latexIsLetter(int ch) { + return IsASCII(ch) && isalpha(ch); +} + +static bool latexIsTagValid(Sci_Position &i, Sci_Position l, Accessor &styler) { + while (i < l) { + if (styler.SafeGetCharAt(i) == '{') { + while (i < l) { + i++; + if (styler.SafeGetCharAt(i) == '}') { + return true; + } else if (!latexIsLetter(styler.SafeGetCharAt(i)) && + styler.SafeGetCharAt(i)!='*') { + return false; + } + } + } else if (!latexIsBlank(styler.SafeGetCharAt(i))) { + return false; + } + i++; + } + return false; +} + +static bool latexNextNotBlankIs(Sci_Position i, Accessor &styler, char needle) { + char ch; + while (i < styler.Length()) { + ch = styler.SafeGetCharAt(i); + if (!latexIsBlankAndNL(ch) && ch != '*') { + if (ch == needle) + return true; + else + return false; + } + i++; + } + return false; +} + +static bool latexLastWordIs(Sci_Position start, Accessor &styler, const char *needle) { + Sci_PositionU i = 0; + Sci_PositionU l = static_cast(strlen(needle)); + Sci_Position ini = start-l+1; + char s[32]; + + while (i < l && i < 31) { + s[i] = styler.SafeGetCharAt(ini + i); + i++; + } + s[i] = '\0'; + + return (strcmp(s, needle) == 0); +} + +static bool latexLastWordIsMathEnv(Sci_Position pos, Accessor &styler) { + Sci_Position i, j; + char s[32]; + const char *mathEnvs[] = { "align", "alignat", "flalign", "gather", + "multiline", "displaymath", "eqnarray", "equation" }; + if (styler.SafeGetCharAt(pos) != '}') return false; + for (i = pos - 1; i >= 0; --i) { + if (styler.SafeGetCharAt(i) == '{') break; + if (pos - i >= 20) return false; + } + if (i < 0 || i == pos - 1) return false; + ++i; + for (j = 0; i + j < pos; ++j) + s[j] = styler.SafeGetCharAt(i + j); + s[j] = '\0'; + if (j == 0) return false; + if (s[j - 1] == '*') s[--j] = '\0'; + for (i = 0; i < static_cast(sizeof(mathEnvs) / sizeof(const char *)); ++i) + if (strcmp(s, mathEnvs[i]) == 0) return true; + return false; +} + +static inline void latexStateReset(int &mode, int &state) { + switch (mode) { + case 1: state = SCE_L_MATH; break; + case 2: state = SCE_L_MATH2; break; + default: state = SCE_L_DEFAULT; break; + } +} + +// There are cases not handled correctly, like $abcd\textrm{what is $x+y$}z+w$. +// But I think it's already good enough. +void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { + // startPos is assumed to be the first character of a line + Accessor styler(pAccess, &props); + styler.StartAt(startPos); + int mode = getMode(styler.GetLine(startPos) - 1); + int state = initStyle; + if (state == SCE_L_ERROR || state == SCE_L_SHORTCMD || state == SCE_L_SPECIAL) // should not happen + latexStateReset(mode, state); + + char chNext = styler.SafeGetCharAt(startPos); + char chVerbatimDelim = '\0'; + styler.StartSegment(startPos); + Sci_Position lengthDoc = startPos + length; + + for (Sci_Position i = startPos; i < lengthDoc; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + + if (styler.IsLeadByte(ch)) { + i++; + chNext = styler.SafeGetCharAt(i + 1); + continue; + } + + if (ch == '\r' || ch == '\n') + setMode(styler.GetLine(i), mode); + + switch (state) { + case SCE_L_DEFAULT : + switch (ch) { + case '\\' : + styler.ColourTo(i - 1, state); + if (latexIsLetter(chNext)) { + state = SCE_L_COMMAND; + } else if (latexIsSpecial(chNext)) { + styler.ColourTo(i + 1, SCE_L_SPECIAL); + i++; + chNext = styler.SafeGetCharAt(i + 1); + } else if (chNext == '\r' || chNext == '\n') { + styler.ColourTo(i, SCE_L_ERROR); + } else if (IsASCII(chNext)) { + styler.ColourTo(i + 1, SCE_L_SHORTCMD); + if (chNext == '(') { + mode = 1; + state = SCE_L_MATH; + } else if (chNext == '[') { + mode = 2; + state = SCE_L_MATH2; + } + i++; + chNext = styler.SafeGetCharAt(i + 1); + } + break; + case '$' : + styler.ColourTo(i - 1, state); + if (chNext == '$') { + styler.ColourTo(i + 1, SCE_L_SHORTCMD); + mode = 2; + state = SCE_L_MATH2; + i++; + chNext = styler.SafeGetCharAt(i + 1); + } else { + styler.ColourTo(i, SCE_L_SHORTCMD); + mode = 1; + state = SCE_L_MATH; + } + break; + case '%' : + styler.ColourTo(i - 1, state); + state = SCE_L_COMMENT; + break; + } + break; + // These 3 will never be reached. + case SCE_L_ERROR: + case SCE_L_SPECIAL: + case SCE_L_SHORTCMD: + break; + case SCE_L_COMMAND : + if (!latexIsLetter(chNext)) { + styler.ColourTo(i, state); + if (latexNextNotBlankIs(i + 1, styler, '[' )) { + state = SCE_L_CMDOPT; + } else if (latexLastWordIs(i, styler, "\\begin")) { + state = SCE_L_TAG; + } else if (latexLastWordIs(i, styler, "\\end")) { + state = SCE_L_TAG2; + } else if (latexLastWordIs(i, styler, "\\verb") && chNext != '*' && chNext != ' ') { + chVerbatimDelim = chNext; + state = SCE_L_VERBATIM; + } else { + latexStateReset(mode, state); + } + } + break; + case SCE_L_CMDOPT : + if (ch == ']') { + styler.ColourTo(i, state); + latexStateReset(mode, state); + } + break; + case SCE_L_TAG : + if (latexIsTagValid(i, lengthDoc, styler)) { + styler.ColourTo(i, state); + latexStateReset(mode, state); + if (latexLastWordIs(i, styler, "{verbatim}")) { + state = SCE_L_VERBATIM; + } else if (latexLastWordIs(i, styler, "{lstlisting}")) { + state = SCE_L_VERBATIM; + } else if (latexLastWordIs(i, styler, "{comment}")) { + state = SCE_L_COMMENT2; + } else if (latexLastWordIs(i, styler, "{math}") && mode == 0) { + mode = 1; + state = SCE_L_MATH; + } else if (latexLastWordIsMathEnv(i, styler) && mode == 0) { + mode = 2; + state = SCE_L_MATH2; + } + } else { + styler.ColourTo(i, SCE_L_ERROR); + latexStateReset(mode, state); + ch = styler.SafeGetCharAt(i); + if (ch == '\r' || ch == '\n') setMode(styler.GetLine(i), mode); + } + chNext = styler.SafeGetCharAt(i+1); + break; + case SCE_L_TAG2 : + if (latexIsTagValid(i, lengthDoc, styler)) { + styler.ColourTo(i, state); + latexStateReset(mode, state); + } else { + styler.ColourTo(i, SCE_L_ERROR); + latexStateReset(mode, state); + ch = styler.SafeGetCharAt(i); + if (ch == '\r' || ch == '\n') setMode(styler.GetLine(i), mode); + } + chNext = styler.SafeGetCharAt(i+1); + break; + case SCE_L_MATH : + switch (ch) { + case '\\' : + styler.ColourTo(i - 1, state); + if (latexIsLetter(chNext)) { + Sci_Position match = i + 3; + if (latexLastWordIs(match, styler, "\\end")) { + match++; + if (latexIsTagValid(match, lengthDoc, styler)) { + if (latexLastWordIs(match, styler, "{math}")) + mode = 0; + } + } + state = SCE_L_COMMAND; + } else if (latexIsSpecial(chNext)) { + styler.ColourTo(i + 1, SCE_L_SPECIAL); + i++; + chNext = styler.SafeGetCharAt(i + 1); + } else if (chNext == '\r' || chNext == '\n') { + styler.ColourTo(i, SCE_L_ERROR); + } else if (IsASCII(chNext)) { + if (chNext == ')') { + mode = 0; + state = SCE_L_DEFAULT; + } + styler.ColourTo(i + 1, SCE_L_SHORTCMD); + i++; + chNext = styler.SafeGetCharAt(i + 1); + } + break; + case '$' : + styler.ColourTo(i - 1, state); + styler.ColourTo(i, SCE_L_SHORTCMD); + mode = 0; + state = SCE_L_DEFAULT; + break; + case '%' : + styler.ColourTo(i - 1, state); + state = SCE_L_COMMENT; + break; + } + break; + case SCE_L_MATH2 : + switch (ch) { + case '\\' : + styler.ColourTo(i - 1, state); + if (latexIsLetter(chNext)) { + Sci_Position match = i + 3; + if (latexLastWordIs(match, styler, "\\end")) { + match++; + if (latexIsTagValid(match, lengthDoc, styler)) { + if (latexLastWordIsMathEnv(match, styler)) + mode = 0; + } + } + state = SCE_L_COMMAND; + } else if (latexIsSpecial(chNext)) { + styler.ColourTo(i + 1, SCE_L_SPECIAL); + i++; + chNext = styler.SafeGetCharAt(i + 1); + } else if (chNext == '\r' || chNext == '\n') { + styler.ColourTo(i, SCE_L_ERROR); + } else if (IsASCII(chNext)) { + if (chNext == ']') { + mode = 0; + state = SCE_L_DEFAULT; + } + styler.ColourTo(i + 1, SCE_L_SHORTCMD); + i++; + chNext = styler.SafeGetCharAt(i + 1); + } + break; + case '$' : + styler.ColourTo(i - 1, state); + if (chNext == '$') { + styler.ColourTo(i + 1, SCE_L_SHORTCMD); + i++; + chNext = styler.SafeGetCharAt(i + 1); + mode = 0; + state = SCE_L_DEFAULT; + } else { // This may not be an error, e.g. \begin{equation}\text{$a$}\end{equation} + styler.ColourTo(i, SCE_L_SHORTCMD); + } + break; + case '%' : + styler.ColourTo(i - 1, state); + state = SCE_L_COMMENT; + break; + } + break; + case SCE_L_COMMENT : + if (ch == '\r' || ch == '\n') { + styler.ColourTo(i - 1, state); + latexStateReset(mode, state); + } + break; + case SCE_L_COMMENT2 : + if (ch == '\\') { + Sci_Position match = i + 3; + if (latexLastWordIs(match, styler, "\\end")) { + match++; + if (latexIsTagValid(match, lengthDoc, styler)) { + if (latexLastWordIs(match, styler, "{comment}")) { + styler.ColourTo(i - 1, state); + state = SCE_L_COMMAND; + } + } + } + } + break; + case SCE_L_VERBATIM : + if (ch == '\\') { + Sci_Position match = i + 3; + if (latexLastWordIs(match, styler, "\\end")) { + match++; + if (latexIsTagValid(match, lengthDoc, styler)) { + if (latexLastWordIs(match, styler, "{verbatim}")) { + styler.ColourTo(i - 1, state); + state = SCE_L_COMMAND; + } else if (latexLastWordIs(match, styler, "{lstlisting}")) { + styler.ColourTo(i - 1, state); + state = SCE_L_COMMAND; + } + } + } + } else if (chNext == chVerbatimDelim) { + styler.ColourTo(i + 1, state); + latexStateReset(mode, state); + chVerbatimDelim = '\0'; + i++; + chNext = styler.SafeGetCharAt(i + 1); + } else if (chVerbatimDelim != '\0' && (ch == '\n' || ch == '\r')) { + styler.ColourTo(i, SCE_L_ERROR); + latexStateReset(mode, state); + chVerbatimDelim = '\0'; + } + break; + } + } + if (lengthDoc == styler.Length()) truncModes(styler.GetLine(lengthDoc - 1)); + styler.ColourTo(lengthDoc - 1, state); + styler.Flush(); +} + +static int latexFoldSaveToInt(const latexFoldSave &save) { + int sum = 0; + for (int i = 0; i <= save.structLev; ++i) + sum += save.openBegins[i]; + return ((sum + save.structLev + SC_FOLDLEVELBASE) & SC_FOLDLEVELNUMBERMASK); +} + +// Change folding state while processing a line +// Return the level before the first relevant command +void SCI_METHOD LexerLaTeX::Fold(Sci_PositionU startPos, Sci_Position length, int, IDocument *pAccess) { + const char *structWords[7] = {"part", "chapter", "section", "subsection", + "subsubsection", "paragraph", "subparagraph"}; + Accessor styler(pAccess, &props); + Sci_PositionU endPos = startPos + length; + Sci_Position curLine = styler.GetLine(startPos); + latexFoldSave save; + getSave(curLine - 1, save); + do { + char ch, buf[16]; + Sci_Position i, j; + int lev = -1; + bool needFold = false; + for (i = static_cast(startPos); i < static_cast(endPos); ++i) { + ch = styler.SafeGetCharAt(i); + if (ch == '\r' || ch == '\n') break; + if (ch != '\\' || styler.StyleAt(i) != SCE_L_COMMAND) continue; + for (j = 0; j < 15 && i + 1 < static_cast(endPos); ++j, ++i) { + buf[j] = styler.SafeGetCharAt(i + 1); + if (!latexIsLetter(buf[j])) break; + } + buf[j] = '\0'; + if (strcmp(buf, "begin") == 0) { + if (lev < 0) lev = latexFoldSaveToInt(save); + ++save.openBegins[save.structLev]; + needFold = true; + } + else if (strcmp(buf, "end") == 0) { + while (save.structLev > 0 && save.openBegins[save.structLev] == 0) + --save.structLev; + if (lev < 0) lev = latexFoldSaveToInt(save); + if (save.openBegins[save.structLev] > 0) --save.openBegins[save.structLev]; + } + else { + for (j = 0; j < 7; ++j) + if (strcmp(buf, structWords[j]) == 0) break; + if (j >= 7) continue; + save.structLev = j; // level before the command + for (j = save.structLev + 1; j < 8; ++j) { + save.openBegins[save.structLev] += save.openBegins[j]; + save.openBegins[j] = 0; + } + if (lev < 0) lev = latexFoldSaveToInt(save); + ++save.structLev; // level after the command + needFold = true; + } + } + if (lev < 0) lev = latexFoldSaveToInt(save); + if (needFold) lev |= SC_FOLDLEVELHEADERFLAG; + styler.SetLevel(curLine, lev); + setSave(curLine, save); + ++curLine; + startPos = styler.LineStart(curLine); + if (static_cast(startPos) == styler.Length()) { + lev = latexFoldSaveToInt(save); + styler.SetLevel(curLine, lev); + setSave(curLine, save); + truncSaves(curLine); + } + } while (startPos < endPos); + styler.Flush(); +} + +static const char *const emptyWordListDesc[] = { + 0 +}; + +LexerModule lmLatex(SCLEX_LATEX, LexerLaTeX::LexerFactoryLaTeX, "latex", emptyWordListDesc); diff --git a/Pythonwin/Scintilla/src/LexLisp.cxx b/Pythonwin/Scintilla/lexers/LexLisp.cxx similarity index 84% rename from Pythonwin/Scintilla/src/LexLisp.cxx rename to Pythonwin/Scintilla/lexers/LexLisp.cxx index 1072e13a3..8e7586355 100644 --- a/Pythonwin/Scintilla/src/LexLisp.cxx +++ b/Pythonwin/Scintilla/lexers/LexLisp.cxx @@ -8,45 +8,46 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" - -#include "PropSet.h" -#include "Accessor.h" -#include "KeyWords.h" +#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 #define SCE_LISP_CHARACTER 29 #define SCE_LISP_MACRO 30 #define SCE_LISP_MACRO_DISPATCH 31 static inline bool isLispoperator(char ch) { - if (isascii(ch) && isalnum(ch)) + if (IsASCII(ch) && isalnum(ch)) return false; - if (ch == '\'' || ch == '`' || ch == '(' || ch == ')' ) + if (ch == '\'' || ch == '`' || ch == '(' || ch == ')' || ch == '[' || ch == ']' || ch == '{' || ch == '}') return true; return false; } static inline bool isLispwordstart(char ch) { - return isascii(ch) && ch != ';' && !isspacechar(ch) && !isLispoperator(ch) && + return IsASCII(ch) && ch != ';' && !isspacechar(ch) && !isLispoperator(ch) && ch != '\n' && ch != '\r' && ch != '\"'; } -static void classifyWordLisp(unsigned int start, unsigned int end, WordList &keywords, WordList &keywords_kw, Accessor &styler) { - PLATFORM_ASSERT(end >= start); +static void classifyWordLisp(Sci_PositionU start, Sci_PositionU end, WordList &keywords, WordList &keywords_kw, Accessor &styler) { + assert(end >= start); char s[100]; - unsigned int i; + Sci_PositionU i; bool digit_flag = true; for (i = 0; (i < end - start + 1) && (i < 99); i++) { s[i] = styler[start + i]; @@ -71,7 +72,7 @@ static void classifyWordLisp(unsigned int start, unsigned int end, WordList &key } -static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseLispDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -81,9 +82,9 @@ static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, W int state = initStyle, radix = -1; char chNext = styler[startPos]; - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; styler.StartSegment(startPos); - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -100,6 +101,9 @@ static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, W styler.ColourTo(i - 1, state); radix = -1; state = SCE_LISP_MACRO_DISPATCH; + } else if (ch == ':' && isLispwordstart(chNext)) { + styler.ColourTo(i - 1, state); + state = SCE_LISP_SYMBOL; } else if (isLispwordstart(ch)) { styler.ColourTo(i - 1, state); state = SCE_LISP_IDENTIFIER; @@ -136,7 +140,7 @@ static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, W } } } else if (state == SCE_LISP_MACRO_DISPATCH) { - if (!isdigit(ch)) { + if (!(IsASCII(ch) && isdigit(ch))) { if (ch != 'r' && ch != 'R' && (i - styler.GetStartSegment()) > 1) { state = SCE_LISP_DEFAULT; } else { @@ -227,25 +231,25 @@ static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, W styler.ColourTo(lengthDoc - 1, state); } -static void FoldLispDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[], +static void FoldLispDoc(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + 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); - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (style == SCE_LISP_OPERATOR) { - if (ch == '(') { + if (ch == '(' || ch == '[' || ch == '{') { levelCurrent++; - } else if (ch == ')') { + } else if (ch == ')' || ch == ']' || ch == '}') { levelCurrent--; } } diff --git a/Pythonwin/Scintilla/src/LexLout.cxx b/Pythonwin/Scintilla/lexers/LexLout.cxx similarity index 91% rename from Pythonwin/Scintilla/src/LexLout.cxx rename to Pythonwin/Scintilla/lexers/LexLout.cxx index 492e4ed6d..abba91ad1 100644 --- a/Pythonwin/Scintilla/src/LexLout.cxx +++ b/Pythonwin/Scintilla/lexers/LexLout.cxx @@ -7,22 +7,23 @@ #include #include -#include #include #include +#include +#include -#include "Platform.h" +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" -#include "PropSet.h" +#include "WordList.h" +#include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" -#include "KeyWords.h" -#include "Scintilla.h" -#include "SciLexer.h" +#include "CharacterSet.h" +#include "LexerModule.h" -#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalpha(ch) || ch == '@' || ch == '_'); @@ -37,7 +38,7 @@ static inline bool IsAnOther(const int ch) { ch == ']' || ch == '^' || ch == '`' || ch == '|' || ch == '~'); } -static void ColouriseLoutDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseLoutDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -137,20 +138,20 @@ static void ColouriseLoutDoc(unsigned int startPos, int length, int initStyle, sc.Complete(); } -static void FoldLoutDoc(unsigned int startPos, int length, int, WordList *[], +static void FoldLoutDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; int styleNext = styler.StyleAt(startPos); - char s[10]; + char s[10] = ""; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; @@ -159,7 +160,7 @@ static void FoldLoutDoc(unsigned int startPos, int length, int, WordList *[], if (style == SCE_LOUT_WORD) { if (ch == '@') { - for (unsigned int j = 0; j < 8; j++) { + for (Sci_PositionU j = 0; j < 8; j++) { if (!IsAWordChar(styler[i + j])) { break; } diff --git a/Pythonwin/Scintilla/lexers/LexLua.cxx b/Pythonwin/Scintilla/lexers/LexLua.cxx new file mode 100644 index 000000000..9e6e8a70c --- /dev/null +++ b/Pythonwin/Scintilla/lexers/LexLua.cxx @@ -0,0 +1,502 @@ +// Scintilla source code edit control +/** @file LexLua.cxx + ** Lexer for Lua language. + ** + ** Written by Paul Winwood. + ** Folder by Alexey Yutkin. + ** Modified by Marcos E. Wurzius & Philippe Lhoste + **/ + +#include +#include +#include +#include +#include +#include + +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "StringCopy.h" +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + +using namespace Scintilla; + +// Test for [=[ ... ]=] delimiters, returns 0 if it's only a [ or ], +// return 1 for [[ or ]], returns >=2 for [=[ or ]=] and so on. +// The maximum number of '=' characters allowed is 254. +static int LongDelimCheck(StyleContext &sc) { + int sep = 1; + while (sc.GetRelative(sep) == '=' && sep < 0xFF) + sep++; + if (sc.GetRelative(sep) == sc.ch) + return sep; + return 0; +} + +static void ColouriseLuaDoc( + Sci_PositionU startPos, + Sci_Position length, + int initStyle, + WordList *keywordlists[], + Accessor &styler) { + + const WordList &keywords = *keywordlists[0]; + const WordList &keywords2 = *keywordlists[1]; + const WordList &keywords3 = *keywordlists[2]; + const WordList &keywords4 = *keywordlists[3]; + const WordList &keywords5 = *keywordlists[4]; + const WordList &keywords6 = *keywordlists[5]; + const WordList &keywords7 = *keywordlists[6]; + const WordList &keywords8 = *keywordlists[7]; + + // Accepts accented characters + CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); + CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true); + // Not exactly following number definition (several dots are seen as OK, etc.) + // but probably enough in most cases. [pP] is for hex floats. + CharacterSet setNumber(CharacterSet::setDigits, ".-+abcdefpABCDEFP"); + CharacterSet setExponent(CharacterSet::setNone, "eEpP"); + CharacterSet setLuaOperator(CharacterSet::setNone, "*/-+()={}~[];<>,.^%:#&|"); + CharacterSet setEscapeSkip(CharacterSet::setNone, "\"'\\"); + + Sci_Position currentLine = styler.GetLine(startPos); + // Initialize long string [[ ... ]] or block comment --[[ ... ]] nesting level, + // if we are inside such a string. Block comment was introduced in Lua 5.0, + // blocks with separators [=[ ... ]=] in Lua 5.1. + // Continuation of a string (\z whitespace escaping) is controlled by stringWs. + int nestLevel = 0; + int sepCount = 0; + int stringWs = 0; + if (initStyle == SCE_LUA_LITERALSTRING || initStyle == SCE_LUA_COMMENT || + initStyle == SCE_LUA_STRING || initStyle == SCE_LUA_CHARACTER) { + const int lineState = styler.GetLineState(currentLine - 1); + nestLevel = lineState >> 9; + sepCount = lineState & 0xFF; + stringWs = lineState & 0x100; + } + + // results of identifier/keyword matching + Sci_Position idenPos = 0; + Sci_Position idenWordPos = 0; + int idenStyle = SCE_LUA_IDENTIFIER; + bool foundGoto = false; + + // Do not leak onto next line + if (initStyle == SCE_LUA_STRINGEOL || initStyle == SCE_LUA_COMMENTLINE || initStyle == SCE_LUA_PREPROCESSOR) { + initStyle = SCE_LUA_DEFAULT; + } + + StyleContext sc(startPos, length, initStyle, styler); + if (startPos == 0 && sc.ch == '#' && sc.chNext == '!') { + // shbang line: "#!" is a comment only if located at the start of the script + sc.SetState(SCE_LUA_COMMENTLINE); + } + for (; sc.More(); sc.Forward()) { + if (sc.atLineEnd) { + // Update the line state, so it can be seen by next line + currentLine = styler.GetLine(sc.currentPos); + switch (sc.state) { + case SCE_LUA_LITERALSTRING: + case SCE_LUA_COMMENT: + case SCE_LUA_STRING: + case SCE_LUA_CHARACTER: + // Inside a literal string, block comment or string, we set the line state + styler.SetLineState(currentLine, (nestLevel << 9) | stringWs | sepCount); + break; + default: + // Reset the line state + styler.SetLineState(currentLine, 0); + break; + } + } + if (sc.atLineStart && (sc.state == SCE_LUA_STRING)) { + // Prevent SCE_LUA_STRINGEOL from leaking back to previous line + sc.SetState(SCE_LUA_STRING); + } + + // Handle string line continuation + if ((sc.state == SCE_LUA_STRING || sc.state == SCE_LUA_CHARACTER) && + sc.ch == '\\') { + if (sc.chNext == '\n' || sc.chNext == '\r') { + sc.Forward(); + if (sc.ch == '\r' && sc.chNext == '\n') { + sc.Forward(); + } + continue; + } + } + + // Determine if the current state should terminate. + if (sc.state == SCE_LUA_OPERATOR) { + if (sc.ch == ':' && sc.chPrev == ':') { // ::