boxchars

Crates.ioboxchars
lib.rsboxchars
version0.1.4
created_at2025-08-29 21:15:17.213736+00
updated_at2025-08-29 22:42:27.275351+00
descriptionThis library allows to manipulate Box Drawing Chars
homepagehttps://gitverse.ru/k25v/boxchars
repository
max_upload_size
id1816908
size28,397
(ivaska)

documentation

README

Box Drawing Chars manipulation library

Created by KNB (initials) as mindkeeper pet in 2024-2025. First version written in c++ to help draw frames in CLI application. Box Drawing chars are Unicode chars starting with number 0x2500. There are 128 chars for draw borders in CLI application. Each char has name similar to "Box Drawing Heavy Vertical" which is '┃'. It's possible to retrieve some useful information about char from name. For example what kind of char is, it's style and direction.

I found that exists 4 ways: Up, Right, Down, Left and each char can be described as end styles in that directions and end's styles can be retrieved directly from name of chars. Knowing styles lets you classify chars by categories, such as lines, corners, T connectors and crosses, lines can be vertical, horizontal, diagonal and so on. That information let you build automated drawers for borders, mazes, trees and so on in cli application. I present all retrieved information in few HashMaps coded in only 256 bytes for all the 128 chars, 2 bytes for each char.

For example: Char '┝' named as "Box Drawing Light Vertical And Right Heavy", coded as [100,128] and these 2 bytes holds info about ends and that this is T typed char.

Theoretically possible to compress data. I do not follow this task. It's possible to use only byte that holds only end styles, so data size will be decreased to 1 byte for each char.

I found that it's possible to build 82 different simplest borders by rules from chars such as

╭─╮
│C│\ ╰─╯

or 752 simplets similar to
╭╼┓
╽C╿
┗╾╯

I limit connections char to char only with the same end style, dashed lines excluded.

What is Box Drawing char

Box drawing chars are used to draw borders in cli applications, examples are midnight commander, older programms such as Dos Navigator and so on.

What for this library is

This library is not peace of best coding, but can help you find some ideas how to build TUI for your cli application. Or you can solve some combinatoric task and find all possible borders sized as 3x3 chars or any another size.

Examples

Commit count: 0

cargo fmt