feat(desktop): built-in Han/Eng layout auto-switching, terminal/Vim support, and Unicode input

This commit is contained in:
Yun Chan 2026-10-27 10:48:07 +09:00
parent 1da04b9e46
commit a3ac44da2b
109 changed files with 8234 additions and 242 deletions

View file

@ -132,8 +132,8 @@ def _read_text(auto: Any, control: Any) -> tuple[str, str, Optional[Any]]:
if value_pattern is not None:
try:
text = value_pattern.Value or ""
return (str(text)[:MAX_TEXT_CHARS], "value", value_pattern)
text = str(value_pattern.Value or "")
return (text[-MAX_TEXT_CHARS:], "value", value_pattern)
except Exception:
pass
@ -143,8 +143,20 @@ def _read_text(auto: Any, control: Any) -> tuple[str, str, Optional[Any]]:
text_pattern = None
if text_pattern is not None:
try:
text = text_pattern.DocumentRange.GetText(-1) or ""
return (str(text)[:MAX_TEXT_CHARS], "text", value_pattern)
raw_text = str(text_pattern.DocumentRange.GetText(-1) or "")
trimmed = raw_text.rstrip("\r\n ")
if len(trimmed) > MAX_TEXT_CHARS:
try:
visible = text_pattern.GetVisibleRanges()
if visible:
vis_text = "\n".join(
str(r.GetText(-1) or "").rstrip("\r\n ") for r in visible
).rstrip("\r\n ")
if vis_text:
return (vis_text[-MAX_TEXT_CHARS:], "text", value_pattern)
except Exception:
pass
return ((trimmed or raw_text)[-MAX_TEXT_CHARS:], "text", value_pattern)
except Exception:
# Chromium/CEF 입력창에서 COMError 가 나는 사례가 보고돼 있다 (issue #135/#138).
pass
@ -152,8 +164,8 @@ def _read_text(auto: Any, control: Any) -> tuple[str, str, Optional[Any]]:
try:
legacy = control.GetLegacyIAccessiblePattern()
if legacy is not None:
text = legacy.Value or ""
return (str(text)[:MAX_TEXT_CHARS], "legacy", value_pattern)
text = str(legacy.Value or "")
return (text[-MAX_TEXT_CHARS:], "legacy", value_pattern)
except Exception:
pass
@ -205,7 +217,7 @@ def _caret_rect_and_offset(auto: Any, control: Any) -> tuple[Optional[dict], Opt
# 문자 단위로 확장한 뒤 다시 시도한다 (Windows Terminal 레시피).
try:
expanded = caret_range.Clone()
expanded.ExpandToEnclosingUnit(auto.TextUnit.Character)
expanded.ExpandToEnclosingUnit(auto.TextUnit.Character, waitTime=0)
caret_rect = _first_rect(expanded.GetBoundingRectangles())
except Exception:
caret_rect = None