npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pi-char-thai

v0.3.0

Published

Thai input fixes for pi's editor: vertical cursor drift and combining-mark Backspace (custom editor subclass, no core patch)

Readme

pi-char-thai

pi-char-thai fixes Thai text input in Pi's editor: vertical cursor drift on wrapped lines and Backspace that deletes combining marks ( Sara Am, tone marks, above/below vowels ) one at a time instead of swallowing the whole base character. It installs a custom editor subclass through Pi's official extension API — no core patch.

Install

pi install npm:pi-char-thai

That is the only required step. Pi loads the TypeScript extension directly; there is no build step and no Pi core patch.

Try this first

Open Pi and type Thai text with combining characters:

ทดสอบภาษาไทย กํา น้ำ ที่

Then:

  1. Wrap a long Thai line and move the cursor up/down — the cursor lands on the same visual column instead of drifting.
  2. Press Backspace on กํา or น้ำ — the combining marks peel off one step at a time and ำ (dot plus า) vanishes in a single press (กํา → ก, น้ำ → น้), the base character stays until the next press.

How it works

Pi's native editor measures lines and deletes by code unit assumptions that break on Thai grapheme clusters. This extension keeps Pi core untouched and changes behavior at the extension boundary:

  • A ThaiEditor subclass of CustomEditor is registered via setEditorComponent on session_start.
  • Vertical movement uses a grapheme-aware visual line map, so up/down across wrapped Thai lines keeps the visual column.
  • Backspace peels Thai combining marks off the cluster before deleting the base character, using Intl.Segmenter grapheme segmentation. Sara Am (ำ) is one peel step: composed U+0E33 deletes whole, and a decomposed ํ+า pair (either order) deletes together, so the dot never lingers.
  • Fail-closed: headless sessions, or any Pi whose editor no longer exposes the methods the overrides adapt, keep the stock editor with one warning and never a throw.

At every other input path, Pi's native editing behavior stays unchanged.

Implementation map

| File | Responsibility | | ----------- | ------------------------------------------------------------------------------------------------------------------------------------- | | index.ts | Extension entry point. Registers the custom editor via setEditorComponent; guards headless sessions and incompatible editor shapes. | | editor.ts | ThaiEditor; grapheme-aware visual line map, vertical move column computation, Thai combining-mark Backspace, required-method probe. |

Test

Tests live in the parent pi-extensions repo:

bun test tests/pi-char-thai.test.ts   # unit
bun run test:integration              # headless Pi

Manual check: open Pi, type กําน้ำ, press Backspace — one press removes all of ำ, further presses peel the tone mark and then the base character.

Compatibility and risks

The editor overrides TypeScript-private methods. A Pi upgrade can break them — the extension detects the mismatch at startup and falls back to the stock editor instead of throwing.

Confirmed against:

  • Pi 0.85.1 Homebrew runtime
  • Pi 0.84.3 pinned types

Fallback: patch Pi core TUI editor.js to segment graphemes for vertical movement and Backspace.

Repository

https://github.com/th-dev-git/pi-char-thai