Skip to main content

Crate boxchars

Crate boxchars 

Source
Expand description

ebbe is u8 number which represents boxchar’s info about ends, 2 bits for each end, starting from Up clockwise elle is [char;4] array of chars, each char represents boxchar’s info about ends, starting from Up clockwise, like ebbe E means Empty, L means Light, H means Heavy, D means Double EELH is a corner where Up and Right ends are empty, down is Light and left is Heavy ELLE is a corner where right and down ends are Light Here Single style equals Light style, see names of chars So you can connect chars with Double and Single styled ends to Light ends Why EBBE? Because it’s lightweight and fast to use, one byte is enough to store all directions and end styles. Why ELLE? Text coding can be easier than byte coding

§Examples

let ebbe = 0b10000000;
//           10 Up is Heavy, so it's Heavy styled short line directed to up side
let elle = ['H', 'E', 'E', 'E']; // for that char
let elle = ['H', 'E', 'L', 'L']; // what is it?
// Box Drawing char '┌' is Left Top corner, with ebbe 0b00010100
// and elle ['E', 'L', 'L', 'E']

// '┍' is Left Top corner, with ebbe 0b00011000
// and elle ['E', 'H', 'L', 'E']

// look closely to boxchars, each char can has 4 ends in 4 directions with 4 styles,
// including empty style, or no-end
// ╄
//        Up
//        |
//  Left - - Right
//        |
//        Down

Char can be rotated simply by changing order of chars in elle array or by changing ebbe bits;

What for boxbyte is? It’s impossible to recognize char only from ebbe, so you need to know what char is, for example Arc corners have the same ebbe byte, and this is why find_char_by_ebbe() returns vector diagonal lines and diagonal cross have ebbe equal to zero, so should be coded to boxbyte too merged u16 [ebbe, boxbyte] is unique identifier of char so 2 tables presented Vector to improve library

  • implement better extrude function which can be useful in editors
  • implement frame struct to draw borders
  • implement framelet as simplest border made of boxdrawing chars 2x2 framelet, 3x3 framelet, 4x4 framelet, 5x5 framelet and so on
  • implement coloring in terminal, inflate framelet to content
  • implement framelet to border route
  • application: editor, maps, drawing, etc Simplet or Framelet, it’s the same

Cascadia mono font will have more pleasant look

Library is not finished yet, not deeply tested, but it’s working

Structs§

Data
Box Drawing Chars data

Enums§

CharType
Types of char as enum
CornerStyle
Corner styles as enum
CornerType
Corner types as enum
CrossType
Cross types as enum
Diagonals
Diagonal LeftBottom to RightTop or LeftTop to RightBottom
End
Ends as enum
EndStyles
End point styles as enum
LineStyle
Line styles as enum
LineType
Line types as enum

Constants§

DIR_DOWN
DIR_LEFT
DIR_RIGHT
DIR_UP
ES_DOUBLE
ES_EMPTY
ES_HEAVY
ES_LIGHT

Functions§

build_ebbe
build ebbe from end styles as enum
chartype_to_bits
convert chartype enum to bits
chartype_to_enum
convert chartype bits to enum
corner_info
retrieve corner info from boxbyte type is place, style is arc or square
end_to_endstyle
endstyle_to_byte
convert endstyle to byte
get_char_type_bits
get chartype bits from boxbyte
get_chartype_from_ebbe
retrieve chartype from ebbe
get_cross_type
get cross type from boxbyte
get_diagonals
get diagonals from boxbyte or return error message
get_ebbe
convert elle to ebbe
get_elle
convert ebbe to elle
get_end_style
get end style from ebbe
get_end_styles
get end styles enum from ebbe
get_ext_bits
get ext bits from boxbyte
get_info_bits
get info bits from boxbyte
line_info
retrieve line info from boxbyte
opposite_end
get opposite end
rotate_ccw
rotate_cw
set_char_type_bits
set chartype bits in boxbyte
set_ext_bits
set ext bits in boxbyte
set_info_bits
set info bits in boxbyte