Notepad++ should work now.

This commit is contained in:
Storm Dragon committed 2026-10-10 22:39:24 -04:00
1 parent cbce83581a
commit df7879acb5
12 files changed
+523 -18

No files matched your search

+46 -4
View File
@@ -7,6 +7,7 @@ import argparse
import os
from pathlib import Path
import subprocess
import shutil
import sys
import tempfile
import time
@@ -16,20 +17,24 @@ from gi.repository import Gio, GLib
parser = argparse.ArgumentParser()
parser.add_argument("--build-dir", default="build")
parser.add_argument("--session", action="store_true")
parser.add_argument("--fixture", choices=("menu", "edit", "notepad", "list", "winforms", "controls"), default="menu")
parser.add_argument("--fixture", choices=("menu", "edit", "notepad", "list", "winforms", "controls", "scintilla"), default="menu")
parser.add_argument("--notepadpp-exe", type=Path)
parser.add_argument("--32-bit", dest="is32Bit", action="store_true")
parser.add_argument("--late-helper", action="store_true")
parser.add_argument("--restart-helper", action="store_true")
args = parser.parse_args()
if args.is32Bit and args.fixture not in ("list", "controls"):
parser.error("32-bit checks currently require --fixture list or controls")
if (args.late_helper or args.restart_helper) and args.fixture not in ("edit", "winforms"):
parser.error("helper lifecycle checks require --fixture edit or --fixture winforms")
if (args.late_helper or args.restart_helper) and args.fixture not in ("edit", "winforms", "scintilla"):
parser.error("helper lifecycle checks require --fixture edit, winforms or scintilla")
if args.fixture == "scintilla" and (not args.notepadpp_exe or not args.notepadpp_exe.is_file()):
parser.error("--fixture scintilla requires --notepadpp-exe pointing to a 64-bit Notepad++ executable")
build = Path(args.build_dir).resolve()
if not args.session:
sys.exit(subprocess.call(["dbus-run-session", "--", sys.executable,
__file__, "--session", "--build-dir", str(build),
"--fixture", args.fixture,
*(["--notepadpp-exe", str(args.notepadpp_exe.resolve())] if args.notepadpp_exe else []),
*(["--32-bit"] if args.is32Bit else []),
*(["--late-helper"] if args.late_helper else []),
*(["--restart-helper"] if args.restart_helper else [])]))
@@ -59,6 +64,21 @@ with tempfile.TemporaryDirectory(prefix="wine-access-menus-") as temporary:
WINEDLLOVERRIDES="mscoree,mshtml=", CTHULHU_WINE_ACCESS_MANAGED="1")
ready = Path(temporary) / "ready"
env["WINE_ACCESS_FIXTURE_READY"] = "Z:" + str(ready).replace("/", "\\")
if args.fixture == "scintilla":
# Copy the application to isolate its configuration as well as its
# document. Never open or edit files in the user's running instance.
appDir = Path(temporary) / "notepadpp"
appDir.mkdir()
for name in (args.notepadpp_exe.name, "langs.model.xml", "stylers.model.xml"):
source = args.notepadpp_exe.parent / name
if source.is_file():
shutil.copy2(source, appDir / name)
(appDir / "doLocalConf.xml").touch()
document = Path(temporary) / "editor.txt"
document.write_bytes(("hello beta\r\nScintilla second line\r\ncafé 😀 tail\r\n" +
"x" * 1100000 + "\r\n" + "x" * 1022 + "😀tail").encode("utf-8"))
env["WINE_ACCESS_NOTEPADPP_EXE"] = "Z:" + str(appDir / args.notepadpp_exe.name).replace("/", "\\")
env["WINE_ACCESS_SCINTILLA_DOCUMENT"] = "Z:" + str(document).replace("/", "\\")
fixture = Path(temporary) / "menu-fixture.exe"
compiler = "i686-w64-mingw32-gcc" if args.is32Bit else "x86_64-w64-mingw32-gcc"
sourceName = "edit" if args.fixture == "winforms" else args.fixture
@@ -72,7 +92,7 @@ with tempfile.TemporaryDirectory(prefix="wine-access-menus-") as temporary:
subprocess.run(["wineboot", "-u"], env=env, check=True, timeout=45)
if args.late_helper:
app = subprocess.Popen(["wine", str(fixture)], env=env)
deadline = time.monotonic() + 5
deadline = time.monotonic() + 10
while not ready.exists() and app.poll() is None and time.monotonic() < deadline:
time.sleep(0.01)
assert ready.exists(), "editor did not become ready before helper attachment"
@@ -173,6 +193,28 @@ with tempfile.TemporaryDirectory(prefix="wine-access-menus-") as temporary:
assert any(e[3] == "edit" and e[4] == "otepad second line" for e in text_events), "Notepad menu return missing"
print("PASS: actual Wine Notepad keyboard characters, words, lines, selection, deletion, and menu return")
sys.exit(0)
if args.fixture == "scintilla":
textEvents = [e for e in events if e[0].endswith(":text")]
for event in textEvents:
print(event[1:7])
spoken = [e[2] for e in textEvents if e[1] == "text"]
for expected in ("e", "l", "beta", "hello ", "Scintilla second line", "hello beta", "S selected",
"c selected", "c unselected", "S unselected", "S deleted", "c",
"Scintilla selected", "Scintilla deleted", "café 😀 tail", "é", "😀",
"😀 selected", "😀 unselected", "😀 deleted"):
assert expected in spoken, f"missing Scintilla feedback: {expected!r}; {textEvents!r}"
assert spoken.count("l") == 2, "Scintilla lost repeated characters"
assert any(e[1] == "focus" and e[4] == "intilla second line" for e in textEvents), "menu return lost Scintilla caret line"
assert any(e[3] == "read only edit" for e in textEvents), "Scintilla read-only role missing"
assert any(e[2] == "c" and "kind=7" in e[5] for e in textEvents), "Scintilla Backspace suffix wrong"
assert any(e[2] == "😀" and "kind=7" in e[5] for e in textEvents), "multibyte Backspace missing"
assert any(e[2] == "x" * 1022 for e in textEvents), "Scintilla truncation split a surrogate pair"
assert any(e[2] == "x" * 1023 for e in textEvents), "large Scintilla document line missing"
focusEvents = [e for e in textEvents if e[1] == "focus"]
assert [e[4] for e in focusEvents[-2:]] == ["hello beta", "hello beta"], "single-byte Scintilla charset reading failed"
assert all("offset_unit=byte" in e[5] for e in textEvents if e[1] == "text"), "Scintilla offsets mislabeled"
print("PASS: actual Notepad++ arrows, words, Unicode, selection, deletion, undo, menu return and read-only document")
sys.exit(0)
if args.fixture in ("edit", "winforms"):
text_events = [e for e in events if e[0].endswith(":text")]
for event in text_events: