mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-31 01:34:58 +02:00
update to Scinitlla Release 5.3.5 (https://www.scintilla.org/scintilla535.zip) Released 31 May 2023. On Win32, implement IME context sensitivity with IMR_DOCUMENTFEED. Feature #1310. On Win32 remove dependence on MSIMG32.DLL by replacing AlphaBlend by GdiAlphaBlend. Bug #1923. On Qt, stop movement of IME candidate box. On Qt, report correct caret position within paragraph for IME retrieve surrounding text. On Qt for Cocoa, fix crash in entry of multi-character strings with IME. and Lexilla Release 5.2.5 (https://www.scintilla.org/lexilla525.zip) Released 31 May 2023. Add CharacterSetArray constructor without setBase initial argument for common case where this is setNone and the initialSet argument completely defines the characters. This shortens and clarifies use of CharacterSetArray. Bash: implement highlighting inside quoted elements and here-docs. Controlled with properties lexer.bash.styling.inside.string, lexer.bash.styling.inside.backticks, lexer.bash.styling.inside.parameter, and lexer.bash.styling.inside.heredoc. Issue #154, Issue #153, Feature #1033. Bash: add property lexer.bash.command.substitution to choose how to style command substitutions. 0 → SCE_SH_BACKTICKS; 1 → surrounding "$(" and ")" as operators and contents styled as bash code; 2 → use distinct styles (base style + 64) for contents. Choice (2) is a provisional feature and details may change before it is finalized. Issue #153. Bash: fix nesting of parameters (SCE_SH_PARAM) like ${var/$sub/"${rep}}"}. Issue #154. Bash: fix single character special parameters like $? by limiting style. Issue #154. Bash: treat "$$" as special parameter and end scalars before "$". Issue #154. Bash: treat "<<" in arithmetic contexts as left bitwise shift operator instead of here-doc. Issue #137. Batch: style SCE_BAT_AFTER_LABEL used for rest of line after label which is not executed. Issue #148. F#: Lex interpolated verbatim strings as verbatim. Issue #156. VB: allow multiline strings when lexer.vb.strings.multiline set. Issue #151. Close #13729
176 lines
4.9 KiB
Python
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.assertEquals(self.ed.GetStatus(), 0)
|
|
lenValue = self.GetTextLength()
|
|
lenValueWithNUL = lenValue + 1
|
|
value = ctypes.create_unicode_buffer(lenValueWithNUL)
|
|
lenData = self.GetText(lenValueWithNUL, value)
|
|
self.assertEquals(self.ed.GetStatus(), 0)
|
|
self.assertEquals(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.assertEquals(self.ed.Length, 2)
|
|
|
|
def testGetTextLength(self):
|
|
self.SetText(b"ab")
|
|
self.assertEquals(self.GetTextLength(), 2)
|
|
|
|
def testGetText(self):
|
|
self.SetText(b"ab")
|
|
data = ctypes.create_unicode_buffer(100)
|
|
lenData = self.GetText(100, data)
|
|
self.assertEquals(lenData, 2)
|
|
self.assertEquals(len(data.value), 2)
|
|
self.assertEquals(data.value, "ab")
|
|
|
|
def testGetUTF8Text(self):
|
|
self.ed.SetCodePage(65001)
|
|
t = "å"
|
|
tu8 = t.encode("UTF-8")
|
|
self.SetText(tu8)
|
|
value = self.TextValue()
|
|
self.assertEquals(value, t)
|
|
|
|
def testGetBadUTF8Text(self):
|
|
self.ed.SetCodePage(65001)
|
|
tu8 = b't\xc2'
|
|
t = "t\xc2"
|
|
self.SetText(tu8)
|
|
value = self.TextValue()
|
|
self.assertEquals(len(value), 2)
|
|
self.assertEquals(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.assertEquals(len(value), 1)
|
|
self.assertEquals(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.assertEquals(len(value), 3)
|
|
self.assertEquals(value, katakanaMiddleDot)
|
|
|
|
# This is even less valid Shift-JIS
|
|
tu8 = b'[\xff]'
|
|
self.SetText(tu8)
|
|
value = self.TextValue()
|
|
self.assertEquals(len(value), 3)
|
|
self.assertEquals(value, privateBad)
|
|
|
|
def testGetTextLong(self):
|
|
self.assertEquals(self.ed.GetStatus(), 0)
|
|
self.SetText(b"ab")
|
|
data = ctypes.create_unicode_buffer(100)
|
|
lenData = self.GetText(4, data)
|
|
self.assertEquals(self.ed.GetStatus(), 0)
|
|
self.assertEquals(lenData, 2)
|
|
self.assertEquals(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.assertEquals(self.ed.GetStatus(), 0)
|
|
self.assertEquals(lenData, 1)
|
|
self.assertEquals(data.value, t)
|
|
|
|
def testGetTextShort(self):
|
|
self.assertEquals(self.ed.GetStatus(), 0)
|
|
self.SetText(b"ab")
|
|
data = ctypes.create_unicode_buffer(100)
|
|
lenData = self.GetText(2, data)
|
|
self.assertEquals(self.ed.GetStatus(), 0)
|
|
self.assertEquals(lenData, 1)
|
|
self.assertEquals(data.value, "a")
|
|
|
|
def testGetTextJustNUL(self):
|
|
self.assertEquals(self.ed.GetStatus(), 0)
|
|
self.SetText(b"ab")
|
|
data = ctypes.create_unicode_buffer(100)
|
|
lenData = self.GetText(1, data)
|
|
self.assertEquals(self.ed.GetStatus(), 0)
|
|
#~ print(data)
|
|
self.assertEquals(lenData, 0)
|
|
self.assertEquals(data.value, "")
|
|
|
|
def testGetTextZeroLength(self):
|
|
self.assertEquals(self.ed.GetStatus(), 0)
|
|
self.SetText(b"ab")
|
|
data = ctypes.create_unicode_buffer(100)
|
|
lenData = self.GetText(0, data)
|
|
self.assertEquals(self.ed.GetStatus(), 0)
|
|
#~ print(data)
|
|
self.assertEquals(lenData, 0)
|
|
self.assertEquals(data.value, "")
|
|
|
|
if __name__ == '__main__':
|
|
uu = Xite.main("win32Tests")
|