xkk6663/mcu_text_paging

0.1.0

Latest
uploaded 6 hours ago
UTF-8 text paging helpers for Chinese chat bubbles, subtitles, and long-text readers

Readme

# mcu_text_paging

## 安装

```powershell
idf.py add-dependency "xkk6663/mcu_text_paging^0.1.0"
```

UTF-8 文本分页纯函数,适合中文聊天气泡、字幕、长文阅读器。

## 特性

- 只依赖 `stdbool.h` / `stdint.h` / `string.h`
- 以“半字单位”计量:ASCII 1、非 ASCII 2;默认 56 单位/页
- 优先在句末切,其次在停顿切,最后才硬切
- 只在 UTF-8 字符边界切,不会出现半个汉字

## 拖入别的工程

复制 `components/mcu_text_paging/`,把 `include/` 加入头文件路径即可(header-only,无需编译源文件)。

```c
#include "text_paging.h"

int pos = 0;
while (s[pos]) {
    int end = text_paging_split(s, pos);
    render_page(s + pos, end - pos);
    pos = end;
}
```

如果字号/气泡宽度不同,编译时覆盖 `TEXT_PAGE_UNITS`:

```cmake
target_compile_definitions(your_target PRIVATE TEXT_PAGE_UNITS=40)
```

## 测试

`test/test_text_paging.c` 覆盖短句、纯中文、纯 ASCII、逗号断点、句号尾、长多句六类边界。根工程 host 测试会直接编译该文件。

Links

Supports all targets

To add this component to your project, run:

idf.py add-dependency "xkk6663/mcu_text_paging^0.1.0"

download archive

Stats

  • Archive size
    Archive size ~ 5.63 KB
  • Downloaded in total
    Downloaded in total 0 times
  • Downloaded this version
    This version: 0 times

Badge

xkk6663/mcu_text_paging version: 0.1.0
|