Christian Grasser dcc7e600c7 Updated to Scintilla 5.4.1 & Lexilla 5.3.0
Scintilla 5.4.1
https://www.scintilla.org/scintilla541.zip
Released 27 December 2023.

1.  Add IDocumentEditable interface to allow efficient interaction with document objects which may not be visible in a Scintilla instance. This feature is provisonal and may change before being declared stable. For better type-safety, the ScintillaCall C++ API uses IDocumentEditable* where void* was used before which may require changes to client code that uses document pointer APIs DocPointer, SetDocPointer, CreateDocument, AddRefDocument, and ReleaseDocument.
2.  Ctrl-click on a selection deselects it in multiple selection mode.
3.  Add SCI_SELECTIONFROMPOINT for modifying multiple selections.
4.  Add SCI_SETMOVEEXTENDSSELECTION and SCI_CHANGESELECTIONMODE to simplify selection mode manipulation.
5.  Improve performance of global replace by reducing cache invalidation overhead. [Feature #1502](https://sourceforge.net/p/scintilla/feature-requests/1502/).
6.  Fix regular expression search for "\<" matching beginning of search when not beginning of word and for "\>" not matching line end. [Bug #2157](https://sourceforge.net/p/scintilla/bugs/2157/).
7.  Fix regular expression search failure when search for "\<" followed by search for "\>". [Bug #2413](https://sourceforge.net/p/scintilla/bugs/2413/).
8.  Fix regular expression assertion (^, $, \b. \B) failures when using SCFIND_CXX11REGEX. [Bug #2405](https://sourceforge.net/p/scintilla/bugs/2405/).
9.  Fix regular expression bug in reverse direction where shortened match returned. [Bug #2405](https://sourceforge.net/p/scintilla/bugs/2405/).
10. Avoid character fragments in regular expression search results. [Bug #2405](https://sourceforge.net/p/scintilla/bugs/2405/).
11. With a document that does not have the SC_DOCUMENTOPTION_TEXT_LARGE option set, allocating more than 2G (calling SCI_ALLOCATE or similar) will now fail with SC_STATUS_FAILURE.
12. Protect SCI_REPLACETARGET, SCI_REPLACETARGETMINIMAL, and SCI_REPLACETARGETRE from application changing target in notification handlers. [Bug #2289](https://sourceforge.net/p/scintilla/bugs/2289/).

Lexilla 5.3.0
https://www.scintilla.org/lexilla530.zip
Released 27 December 2023.

1. Fix calling AddStaticLexerModule by defining as C++ instead of C which matches header. [Bug #2421](https://sourceforge.net/p/scintilla/bugs/2421/).
2. Bash: Fix shift operator << incorrectly recognized as here-doc. [Issue #215](https://github.com/ScintillaOrg/lexilla/issues/215).
3. Bash: Fix termination of '${' with first unquoted '}' instead of nesting. [Issue #216](https://github.com/ScintillaOrg/lexilla/issues/216).
4. HTML: JavaScript double-quoted strings may escape line end with '\'. [Issue #214](https://github.com/ScintillaOrg/lexilla/issues/214).
5. Lua: recognize --- doc comments. Defined by [LDoc](https://github.com/lunarmodules/ldoc). Does not recognize --[[-- doc comments which seem less common.

Close #14375
2023-12-26 23:17:53 +01:00

176 lines
4.9 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Requires Python 2.7 or later
# These are tests that run only on Win32 as they use Win32 SendMessage call
# to send WM_* messages to Scintilla that are not implemented on other platforms.
# These help Scintilla behave like a Win32 text control and can help screen readers,
# for example.
from __future__ import with_statement
from __future__ import unicode_literals
import ctypes, unittest
from MessageNumbers import msgs
user32 = ctypes.windll.user32
import XiteWin as Xite
class TestWins(unittest.TestCase):
def setUp(self):
self.xite = Xite.xiteFrame
self.ed = self.xite.ed
self.sciHwnd = self.xite.sciHwnd
self.ed.ClearAll()
self.ed.EmptyUndoBuffer()
self.ed.SetCodePage(0)
self.ed.SetStatus(0)
# Helper methods
def Send(self, msg, wp, lp):
return user32.SendMessageW(self.sciHwnd, msgs[msg], wp, lp)
def GetTextLength(self):
return self.Send("WM_GETTEXTLENGTH", 0, 0)
def GetText(self, n, s):
# n = The maximum number of characters to be copied, including the terminating null character.
# returns the number of characters copied, not including the terminating null character
return self.Send("WM_GETTEXT", n, s)
def TextValue(self):
self.assertEqual(self.ed.GetStatus(), 0)
lenValue = self.GetTextLength()
lenValueWithNUL = lenValue + 1
value = ctypes.create_unicode_buffer(lenValueWithNUL)
lenData = self.GetText(lenValueWithNUL, value)
self.assertEqual(self.ed.GetStatus(), 0)
self.assertEqual(lenData, lenValue)
return value.value
def SetText(self, s):
return self.Send("WM_SETTEXT", 0, s)
# Tests
def testSetText(self):
self.SetText(b"ab")
self.assertEqual(self.ed.Length, 2)
def testGetTextLength(self):
self.SetText(b"ab")
self.assertEqual(self.GetTextLength(), 2)
def testGetText(self):
self.SetText(b"ab")
data = ctypes.create_unicode_buffer(100)
lenData = self.GetText(100, data)
self.assertEqual(lenData, 2)
self.assertEqual(len(data.value), 2)
self.assertEqual(data.value, "ab")
def testGetUTF8Text(self):
self.ed.SetCodePage(65001)
t = "å"
tu8 = t.encode("UTF-8")
self.SetText(tu8)
value = self.TextValue()
self.assertEqual(value, t)
def testGetBadUTF8Text(self):
self.ed.SetCodePage(65001)
tu8 = b't\xc2'
t = "t\xc2"
self.SetText(tu8)
value = self.TextValue()
self.assertEqual(len(value), 2)
self.assertEqual(value, t)
def testGetJISText(self):
self.ed.SetCodePage(932)
t = "\N{HIRAGANA LETTER KA}"
tu8 = t.encode("shift-jis")
self.SetText(tu8)
value = self.TextValue()
self.assertEqual(len(value), 1)
self.assertEqual(value, t)
def testGetBadJISText(self):
self.ed.SetCodePage(932)
# This is invalid Shift-JIS, surrounded by []
tu8 = b'[\x85\xff]'
# Win32 uses Katakana Middle Dot to indicate some invalid Shift-JIS text
# At other times \uF8F3 is used which is a private use area character
# See https://unicodebook.readthedocs.io/operating_systems.html
katakanaMiddleDot = '[\N{KATAKANA MIDDLE DOT}]'
privateBad = '[\uf8f3]'
self.SetText(tu8)
value = self.TextValue()
self.assertEqual(len(value), 3)
self.assertEqual(value, katakanaMiddleDot)
# This is even less valid Shift-JIS
tu8 = b'[\xff]'
self.SetText(tu8)
value = self.TextValue()
self.assertEqual(len(value), 3)
self.assertEqual(value, privateBad)
def testGetTextLong(self):
self.assertEqual(self.ed.GetStatus(), 0)
self.SetText(b"ab")
data = ctypes.create_unicode_buffer(100)
lenData = self.GetText(4, data)
self.assertEqual(self.ed.GetStatus(), 0)
self.assertEqual(lenData, 2)
self.assertEqual(data.value, "ab")
def testGetTextLongNonASCII(self):
# With 1 multibyte character in document ask for 4 and ensure 1 character
# returned correctly.
self.ed.SetCodePage(65001)
t = "å"
tu8 = t.encode("UTF-8")
self.SetText(tu8)
data = ctypes.create_unicode_buffer(100)
lenData = self.GetText(4, data)
self.assertEqual(self.ed.GetStatus(), 0)
self.assertEqual(lenData, 1)
self.assertEqual(data.value, t)
def testGetTextShort(self):
self.assertEqual(self.ed.GetStatus(), 0)
self.SetText(b"ab")
data = ctypes.create_unicode_buffer(100)
lenData = self.GetText(2, data)
self.assertEqual(self.ed.GetStatus(), 0)
self.assertEqual(lenData, 1)
self.assertEqual(data.value, "a")
def testGetTextJustNUL(self):
self.assertEqual(self.ed.GetStatus(), 0)
self.SetText(b"ab")
data = ctypes.create_unicode_buffer(100)
lenData = self.GetText(1, data)
self.assertEqual(self.ed.GetStatus(), 0)
#~ print(data)
self.assertEqual(lenData, 0)
self.assertEqual(data.value, "")
def testGetTextZeroLength(self):
self.assertEqual(self.ed.GetStatus(), 0)
self.SetText(b"ab")
data = ctypes.create_unicode_buffer(100)
lenData = self.GetText(0, data)
self.assertEqual(self.ed.GetStatus(), 0)
#~ print(data)
self.assertEqual(lenData, 0)
self.assertEqual(data.value, "")
if __name__ == '__main__':
uu = Xite.main("win32Tests")