Overview
Text operation IPC methods handle inserting, replacing, and managing text in external applications. These methods communicate with the text handler service to send text to the last active window.Methods
replaceText
Replaces the selected text in the target application with the provided text.The text to insert into the target application
void (one-way message)
Implementation: frontend/electron/src/ipc/text-handlers.ts:6
Behavior
- Hides the main menu window
- Waits 100ms for window transition
- Sends text to the last active window using the configured output mode
- Updates clipboard state tracking
Output Modes
The text insertion method depends on the currenttextOutputMode setting:
- paste - Uses clipboard paste (Ctrl+V)
- typewriter - Simulates human typing with realistic delays
- typewriter-leetcode - Typing mode optimized for code editors with auto-indent handling
setTextOutputMode().
acceptSuggestion
Accepts an inline suggestion and inserts it into the target application.The suggestion text to accept and insert
void (one-way message)
Implementation: frontend/electron/src/ipc/text-handlers.ts:24
Behavior
- Hides the suggestion window
- Waits 100ms for window transition
- Sends text to the last active window
- Updates clipboard state tracking
dismissSuggestion
Dismisses the current suggestion without inserting any text. Parameters: None Returns:void (one-way message)
Implementation: frontend/electron/src/ipc/text-handlers.ts:42
Behavior
Simply hides the suggestion window without any text manipulation.Text Output Modes
getTextOutputMode
Retrieves the current text output mode. Parameters: None Returns:Promise<"paste" | "typewriter" | "typewriter-leetcode">
Implementation: frontend/electron/src/ipc/settings-handlers.ts:27
setTextOutputMode
Sets the text output mode for text insertion operations.The text output mode to use
paste- Fast clipboard-based insertiontypewriter- Human-like typing with realistic delays and occasional typostypewriter-leetcode- Code editor optimized typing with auto-indent handling
void (one-way message)
Implementation: frontend/electron/src/ipc/settings-handlers.ts:29
Typewriter Mode Details
The typewriter modes simulate human typing behavior to avoid detection by anti-cheating systems.Features
- Realistic delays - Variable delay between keystrokes (20-100ms)
- Typos - 3% chance of typing a neighboring key, then correcting it
- Punctuation pauses - Longer delays after punctuation marks (150-400ms)
- Word boundaries - Slight pause after spaces (30-100ms)
Simple Typewriter
Used for basic text editors like Notepad:frontend/electron/src/services/text-handler.ts:153
LeetCode Typewriter
Optimized for code editors with auto-indent:- Types each line separately
- Clears auto-indented whitespace before typing
- Preserves exact indentation from source code
frontend/electron/src/services/text-handler.ts:218
Event Listeners
onShowMenu
Called when the main menu should be displayed with selected text.Function to call when the menu is shown
text- The currently selected text in the target application
() => void - Cleanup function to remove the listener
Implementation: frontend/electron/src/preload.ts:4
onShowSuggestion
Called when an inline suggestion should be displayed.Function to call when a suggestion is available
data.context- The context text around the cursor position
() => void - Cleanup function to remove the listener
Implementation: frontend/electron/src/preload.ts:17
Related APIs
- Window Management - Control window visibility and position
- Settings - Configure suggestion and output modes