[PR #3] Add emoji-aware wide character detection; replace ▶ with ❯ in demos #4

Open
opened 2026-03-07 13:55:28 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ahmadawais/terminui/pull/3
Author: @Copilot
Created: 3/4/2026
Status: 🔄 Open

Base: mainHead: copilot/change-highlight-symbol-in-demo


📝 Commits (4)

  • 44b3746 Initial plan
  • 3fbb46c fix: replace ▶ with ❯ in demo highlightSymbol for consistent width
  • b470311 feat: add emoji-aware wide character detection to library
  • 58b166b chore: remove accidental package-lock.json, add inline comments for key symbols

📊 Changes

8 files changed (+124 additions, -42 deletions)

View changed files

📝 README.md (+2 -2)
📝 examples/jsx-dashboard.tsx (+1 -1)
📝 examples/kitchen-sink.ts (+1 -1)
📝 examples/primary-screen.ts (+1 -1)
📝 src/__tests__/core.test.ts (+31 -0)
📝 src/core/buffer.ts (+3 -17)
src/core/charwidth.ts (+84 -0)
📝 src/core/text.ts (+1 -20)

📄 Description

(U+25B6) renders as 2 cells wide in many terminal fonts, but isWideChar returned false for it — causing layout corruption. The library's width detection only covered CJK/Hangul/Fullwidth ranges, missing emoji presentation characters entirely.

Library: emoji-aware isWideChar

  • New src/core/charwidth.ts — shared module with comprehensive wide character detection covering:
    • All existing CJK/Hangul/Fullwidth ranges (unchanged)
    • BMP characters with Emoji_Presentation=Yes (❤ etc.)
    • Commonly wide symbols: (U+25B6), (U+25C0)
    • SMP emoji blocks (U+1F000–U+1FAFF)
  • text.ts / buffer.ts now import from the shared module, eliminating the duplicated range definitions
isWideChar(0x25b6) // ▶ → true  (was false)
isWideChar(0x276f) // ❯ → false (correct, consistently 1-wide)
isWideChar(0x1f600) // 😀 → true (was false)

Demos & README

  • Replaced highlightSymbol: '▶ ''❯ ' across all examples and README
Original prompt

This section details on the original issue you should resolve

<issue_title>Change highlightSymbol of List in demo</issue_title>
<issue_description> is not 1-char wide in some fonts. isWideChar('▶') is a false-negative and is better.

Image</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ahmadawais/terminui/pull/3 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 3/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `copilot/change-highlight-symbol-in-demo` --- ### 📝 Commits (4) - [`44b3746`](https://github.com/ahmadawais/terminui/commit/44b37460fd92db0c9580a74ee7ee3783d7a06cdd) Initial plan - [`3fbb46c`](https://github.com/ahmadawais/terminui/commit/3fbb46cc104bdd0e14d95dd3e62962727040c04b) fix: replace ▶ with ❯ in demo highlightSymbol for consistent width - [`b470311`](https://github.com/ahmadawais/terminui/commit/b4703113c74cad7a1ceca96ad90eeab880cfb80f) feat: add emoji-aware wide character detection to library - [`58b166b`](https://github.com/ahmadawais/terminui/commit/58b166b242e7caef7983eb65d0e87cc7dd80a593) chore: remove accidental package-lock.json, add inline comments for key symbols ### 📊 Changes **8 files changed** (+124 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+2 -2) 📝 `examples/jsx-dashboard.tsx` (+1 -1) 📝 `examples/kitchen-sink.ts` (+1 -1) 📝 `examples/primary-screen.ts` (+1 -1) 📝 `src/__tests__/core.test.ts` (+31 -0) 📝 `src/core/buffer.ts` (+3 -17) ➕ `src/core/charwidth.ts` (+84 -0) 📝 `src/core/text.ts` (+1 -20) </details> ### 📄 Description `▶` (U+25B6) renders as 2 cells wide in many terminal fonts, but `isWideChar` returned `false` for it — causing layout corruption. The library's width detection only covered CJK/Hangul/Fullwidth ranges, missing emoji presentation characters entirely. ### Library: emoji-aware `isWideChar` - **New `src/core/charwidth.ts`** — shared module with comprehensive wide character detection covering: - All existing CJK/Hangul/Fullwidth ranges (unchanged) - BMP characters with `Emoji_Presentation=Yes` (⌚☔✅✨❤ etc.) - Commonly wide symbols: `▶` (U+25B6), `◀` (U+25C0) - SMP emoji blocks (U+1F000–U+1FAFF) - **`text.ts` / `buffer.ts`** now import from the shared module, eliminating the duplicated range definitions ```ts isWideChar(0x25b6) // ▶ → true (was false) isWideChar(0x276f) // ❯ → false (correct, consistently 1-wide) isWideChar(0x1f600) // 😀 → true (was false) ``` ### Demos & README - Replaced `highlightSymbol: '▶ '` → `'❯ '` across all examples and README <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Change `highlightSymbol` of `List` in demo</issue_title> > <issue_description>`▶` is not 1-char wide in some fonts. `isWideChar('▶')` is a false-negative and `❯` is better. > > <img width="503" height="173" alt="Image" src="https://github.com/user-attachments/assets/5d80e1f9-388c-499b-bd18-b4cfd1ea6e7b" /></issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes ahmadawais/terminui#2 <!-- START COPILOT CODING AGENT TIPS --> --- 🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/terminui#4
No description provided.