1package vt
2
3// decSpecialGraphics maps 0x5f..0x7e to the DEC Special Graphics set
4// (designated by ESC ( 0 or ESC ) 0), used by ncurses for line drawing.
5var decSpecialGraphics = [...]rune{
6 ' ', '◆', '▒', '␉', '␌', '␍', '␊', '°', '±', '', '␋', '┘', '┐', '┌', '└', '┼',
7 '⎺', '⎻', '─', '⎼', '⎽', '├', '┤', '┴', '┬', '│', '≤', '≥', 'π', '≠', '£', '·',
8}
9
10// maxRepeat bounds REP to one full screen: repeating further only rewrites
11// cells and scrolls, so a hostile count cannot stall the parser.
12func maxRepeat(width, height int) int {
13 return max(width*height, 1)
14}
15
16// translateCharset maps r through the character set currently invoked into GL.
17func (s *Screen) translateCharset(r rune) rune {
18 g := 0
19 if s.shiftOut {
20 g = 1
21 }
22 if s.charsets[g] == '0' && r >= 0x5f && r <= 0x7e {
23 return decSpecialGraphics[r-0x5f]
24 }
25 return r
26}