Module: Vedeu::EscapeSequences::Borders

Extended by:
Borders
Included in:
Vedeu::Esc, Borders
Defined in:
lib/vedeu/esc/borders.rb

Overview

Note:

Refer to UTF-8 U+2500 to U+257F for border characters. More details can be found at:

en.wikipedia.org/wiki/Box-drawing_character

Using the ‘uXXXX’ variant produces gaps in the border, whilst the ‘xXX’ renders ‘nicely’.

Provides border/box related escape sequences.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.border_offString



28
29
30
# File 'lib/vedeu/esc/borders.rb', line 28

def border_off
  "\e(B"
end

.border_onString



23
24
25
# File 'lib/vedeu/esc/borders.rb', line 23

def border_on
  "\e(0"
end

.charactersHash<Symbol => String>

Provides all the semigraphic characters.

# 0 1 2 3 4 5 6 7 8 9 A B C D E F 6 ┘ ┐ ┌ └ ┼7 ─ ├ ┤ ┴ ┬ │



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vedeu/esc/borders.rb', line 39

def characters
  {
    bottom_right:      "\x6A", # ┘ # \u2518
    top_right:         "\x6B", # ┐ # \u2510
    top_left:          "\x6C", # ┌ # \u250C
    bottom_left:       "\x6D", # └ # \u2514
    horizontal:        "\x71", # ─ # \u2500
    vertical_left:     "\x74", # ├ # \u251C
    vertical_right:    "\x75", # ┤ # \u2524
    horizontal_bottom: "\x76", # ┴ # \u2534
    horizontal_top:    "\x77", # ┬ # \u252C
    vertical:          "\x78", # │ # \u2502
  }
end

.define_borders!void (private)



62
63
64
# File 'lib/vedeu/esc/borders.rb', line 62

def define_borders!
  characters.each { |key, code| define_method(key) { code } }
end

.setup!void



55
56
57
# File 'lib/vedeu/esc/borders.rb', line 55

def setup!
  define_borders!
end

Instance Method Details

#border_offString



28
29
30
# File 'lib/vedeu/esc/borders.rb', line 28

def border_off
  "\e(B"
end

#border_onString



23
24
25
# File 'lib/vedeu/esc/borders.rb', line 23

def border_on
  "\e(0"
end

#charactersHash<Symbol => String>

Provides all the semigraphic characters.

# 0 1 2 3 4 5 6 7 8 9 A B C D E F 6 ┘ ┐ ┌ └ ┼7 ─ ├ ┤ ┴ ┬ │



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vedeu/esc/borders.rb', line 39

def characters
  {
    bottom_right:      "\x6A", # ┘ # \u2518
    top_right:         "\x6B", # ┐ # \u2510
    top_left:          "\x6C", # ┌ # \u250C
    bottom_left:       "\x6D", # └ # \u2514
    horizontal:        "\x71", # ─ # \u2500
    vertical_left:     "\x74", # ├ # \u251C
    vertical_right:    "\x75", # ┤ # \u2524
    horizontal_bottom: "\x76", # ┴ # \u2534
    horizontal_top:    "\x77", # ┬ # \u252C
    vertical:          "\x78", # │ # \u2502
  }
end

#define_borders!void (private)



62
63
64
# File 'lib/vedeu/esc/borders.rb', line 62

def define_borders!
  characters.each { |key, code| define_method(key) { code } }
end

#setup!void



55
56
57
# File 'lib/vedeu/esc/borders.rb', line 55

def setup!
  define_borders!
end