feat(input): upgrade graph personalization, english morphology detection, and atomic SendInput replacement
This commit is contained in:
parent
52eef21bab
commit
cd4a452148
21 changed files with 1098 additions and 110 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import type { Key as NutKey } from '@nut-tree-fork/nut-js'
|
||||
import { getLogger } from '../LoggerService'
|
||||
import { sendWin32UnicodeText } from '../../utils/win32-unicode-input'
|
||||
import { sendWin32UnicodeReplacement, sendWin32UnicodeText } from '../../utils/win32-unicode-input'
|
||||
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
|
||||
|
||||
const logger = getLogger('TextInsertService')
|
||||
|
|
@ -22,6 +22,15 @@ export interface KeyboardPort {
|
|||
* 글자가 아니라 낱자가 지워져(여 → ㅇ) 지울 개수가 어긋난다. 호출자는 남은 공백까지 지운다 (선택).
|
||||
*/
|
||||
commitComposition?(): Promise<void>
|
||||
/**
|
||||
* (선택적 IME 조합 확정 Space) + 커서 앞 백스페이스 + 텍스트 타이핑을 단일 원자적(atomic) 호출로 수행한다.
|
||||
* 지원하고 성공했으면 true, 폴백이 필요하면 false 를 돌려준다.
|
||||
*/
|
||||
replaceBeforeCaret?(
|
||||
deleteCount: number,
|
||||
text: string,
|
||||
options?: { commitComposition?: boolean }
|
||||
): Promise<boolean>
|
||||
/** 네이티브 키 모듈을 미리 불러 둔다 — 첫 삽입이 로딩을 기다리지 않게 (선택) */
|
||||
preload?(): Promise<void>
|
||||
}
|
||||
|
|
@ -112,6 +121,21 @@ export class NutKeyboardPort implements KeyboardPort {
|
|||
await nut.native.click(nut.Key.Space)
|
||||
}
|
||||
|
||||
async replaceBeforeCaret(
|
||||
deleteCount: number,
|
||||
text: string,
|
||||
options: { commitComposition?: boolean } = {}
|
||||
): Promise<boolean> {
|
||||
if (
|
||||
this._platform === 'win32' &&
|
||||
this._load === loadNutModule &&
|
||||
sendWin32UnicodeReplacement(deleteCount, text, options)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/** 백스페이스를 count 번 — 키마다 네이티브 keyTap 한 번이다. */
|
||||
async backspace(count: number): Promise<void> {
|
||||
if (count <= 0) return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue