Skip to main content

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.
string
required
The text to insert into the target application
Returns: void (one-way message) Implementation: frontend/electron/src/ipc/text-handlers.ts:6

Behavior

  1. Hides the main menu window
  2. Waits 100ms for window transition
  3. Sends text to the last active window using the configured output mode
  4. Updates clipboard state tracking

Output Modes

The text insertion method depends on the current textOutputMode 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
Set the output mode using setTextOutputMode().

acceptSuggestion

Accepts an inline suggestion and inserts it into the target application.
string
required
The suggestion text to accept and insert
Returns: void (one-way message) Implementation: frontend/electron/src/ipc/text-handlers.ts:24

Behavior

  1. Hides the suggestion window
  2. Waits 100ms for window transition
  3. Sends text to the last active window
  4. 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.
'paste' | 'typewriter' | 'typewriter-leetcode'
required
The text output mode to use
  • paste - Fast clipboard-based insertion
  • typewriter - Human-like typing with realistic delays and occasional typos
  • typewriter-leetcode - Code editor optimized typing with auto-indent handling
Returns: 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:
Source: frontend/electron/src/services/text-handler.ts:153

LeetCode Typewriter

Optimized for code editors with auto-indent:
This mode:
  1. Types each line separately
  2. Clears auto-indented whitespace before typing
  3. Preserves exact indentation from source code
Source: frontend/electron/src/services/text-handler.ts:218

Event Listeners

onShowMenu

Called when the main menu should be displayed with selected text.
(text: string) => void
required
Function to call when the menu is shown
  • text - The currently selected text in the target application
Returns: () => void - Cleanup function to remove the listener Implementation: frontend/electron/src/preload.ts:4

onShowSuggestion

Called when an inline suggestion should be displayed.
(data: { context: string }) => void
required
Function to call when a suggestion is available
  • data.context - The context text around the cursor position
Returns: () => void - Cleanup function to remove the listener Implementation: frontend/electron/src/preload.ts:17