Skip to main content

Documentation Index

Fetch the complete documentation index at: https://developers.remeinium.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

The SinglishIME class provides a stateful engine for handling real-time input, such as typing in a text area. It manages a buffer of pending keystrokes to correctly handle multi-character sequences (e.g., k -> ka, k -> kra).

Class: SinglishIME

import { SinglishIME } from '@siyabasa/singlish';

const ime = new SinglishIME();

Methods

processKey

Processes a single key press and updates the internal buffer. Returns the result of the processing.
processKey(key: string): ResolveResult
  • Parameters: key (string) - The key pressed (e.g., ‘a’, ‘k’).
  • Returns: ResolveResult - The committed text and remaining buffer.

backspace

Removes the last character from the internal buffer.
backspace(): boolean
  • Returns: boolean - true if a character was removed from the buffer, false if the buffer was empty.

getSpeculativeDisplay

Returns the current “speculative” conversion of the pending buffer. This is what you show to the user while they are typing a partial sequence.
getSpeculativeDisplay(): string
  • Returns: string - The Sinhala representation of the current buffer.

flush

Forces the current buffer to be committed as Sinhala text.
flush(): string
  • Returns: string - The converted text.

reset

Clears the internal buffer and resets the state.
reset(): void

Types

ResolveResult

interface ResolveResult {
  /** Sinhala text to commit (may be empty if nothing is committable yet) */
  toCommit: string;
  /** Remaining Roman buffer (ambiguous tail that could extend further) */
  remaining: string;
}