aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/XiteWin.py
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-11-07 14:08:31 +1100
committerNeil <nyamatongwe@gmail.com>2020-11-07 14:08:31 +1100
commit50be9c6b7cd609600f103e108c80c473c986a427 (patch)
treee550c8c1d9c2f3753b19e42481acebbb9ce0caa6 /test/XiteWin.py
parent4c687a95b0afcfcb60bdb916ca460cc9cf9d18f5 (diff)
downloadscintilla-mirror-50be9c6b7cd609600f103e108c80c473c986a427.tar.gz
Try to load Lexilla for tests that need a lexer but skip the tests when Lexilla
not found. Unicode line ends only tested with Lexilla as they require a lexer that supports Unicode line ends.
Diffstat (limited to 'test/XiteWin.py')
-rw-r--r--test/XiteWin.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/test/XiteWin.py b/test/XiteWin.py
index 158a2a83e..4d4179818 100644
--- a/test/XiteWin.py
+++ b/test/XiteWin.py
@@ -19,6 +19,10 @@ from MessageNumbers import msgs, sgsm
import ScintillaCallable
import XiteMenu
+scintillaIncludesLexers = False
+# Lexilla may optionally be tested it is built and can be loaded
+lexillaAvailable = False
+
scintillaDirectory = ".."
scintillaIncludeDirectory = os.path.join(scintillaDirectory, "include")
scintillaScriptsDirectory = os.path.join(scintillaDirectory, "scripts")
@@ -27,6 +31,19 @@ import Face
scintillaBinDirectory = os.path.join(scintillaDirectory, "bin")
+lexillaBinDirectory = os.path.join(scintillaDirectory, "..", "lexilla", "bin")
+lexName = "Lexilla.DLL"
+try:
+ lexillaDLLPath = os.path.join(lexillaBinDirectory, lexName)
+ lexillaLibrary = ctypes.cdll.LoadLibrary(lexillaDLLPath)
+ createLexer = lexillaLibrary.CreateLexer
+ createLexer.restype = ctypes.c_void_p
+ lexillaAvailable = True
+ print("Found Lexilla")
+except OSError:
+ print("Can't find " + lexName)
+ print("Python is built for " + " ".join(platform.architecture()))
+
WFUNC = ctypes.WINFUNCTYPE(c_int, HWND, c_uint, WPARAM, LPARAM)
WS_CHILD = 0x40000000
@@ -182,11 +199,15 @@ class XiteWin():
def OnCreate(self, hwnd):
self.win = hwnd
+ if scintillaIncludesLexers:
+ sciName = "SciLexer.DLL"
+ else:
+ sciName = "Scintilla.DLL"
try:
- scintillaDLLPath = os.path.join(scintillaBinDirectory, "SciLexer.DLL")
+ scintillaDLLPath = os.path.join(scintillaBinDirectory, sciName)
ctypes.cdll.LoadLibrary(scintillaDLLPath)
except OSError:
- print("Can't find SciLexer.DLL")
+ print("Can't find " + sciName)
print("Python is built for " + " ".join(platform.architecture()))
sys.exit()
self.sciHwnd = user32.CreateWindowExW(0,
@@ -206,6 +227,14 @@ class XiteWin():
self.FocusOnEditor()
+ def ChooseLexer(self, lexer):
+ if scintillaIncludesLexers:
+ self.ed.LexerLanguage = lexer
+ elif lexillaAvailable:
+ pLexilla = createLexer(lexer)
+ self.ed.SetILexer(0, pLexilla)
+ else: # No lexers available
+ pass
def Invalidate(self):
user32.InvalidateRect(self.win, 0, 0)