| 1 | package displaywidth |
| 2 | |
| 3 | // Options allows you to specify the treatment of ambiguous East Asian |
| 4 | // characters and ANSI escape sequences. |
| 5 | type Options struct { |
| 6 | // EastAsianWidth specifies whether to treat ambiguous East Asian characters |
| 7 | // as width 1 or 2. When false (default), ambiguous East Asian characters |
| 8 | // are treated as width 1. When true, they are width 2. |
| 9 | EastAsianWidth bool |
| 10 | |
| 11 | // ControlSequences specifies whether to ignore 7-bit ECMA-48 escape sequences |
| 12 | // when calculating the display width. When false (default), ANSI escape |
| 13 | // sequences are treated as just a series of characters. When true, they are |
| 14 | // treated as a single zero-width unit. |
| 15 | ControlSequences bool |
| 16 | // ControlSequences8Bit specifies whether to ignore 8-bit ECMA-48 escape sequences |
| 17 | // when calculating the display width. When false (default), these are treated |
| 18 | // as just a series of characters. When true, they are treated as a single |
| 19 | // zero-width unit. |
| 20 | ControlSequences8Bit bool |
| 21 | } |
| 22 | |
| 23 | // DefaultOptions is the default options for the display width |
| 24 | // calculation, which is EastAsianWidth false, ControlSequences false, and |
| 25 | // ControlSequences8Bit false. |
| 26 | var DefaultOptions = Options{ |
| 27 | EastAsianWidth: false, |
| 28 | ControlSequences: false, |
| 29 | ControlSequences8Bit: false, |
| 30 | } |