Changes in v1.7.0 (English)
- Introduced a new interface for syntax highlighting.
- Pattern specifies the range to which the highlight is applied. A
regexp.Regexp
is acceptable, but any type is sufficient as long as it has FindAllStringIndex(string, int) [][]int
.
Sequence
specifies the escape sequence to apply to the Pattern
parts.
DefaultColor
specifies the sequence used for parts where no highlight is applied.
ResetColor
specifies the sequence used when completing the output of the input text.
- The existing syntax highlighting interface,
Coloring
, is planned to be deprecated.
Changes in v1.7.0 (Japanese)
- シンタックスハイライトの新しいインターフェイスを用意した。
Pattern
はハイライトを適用する範囲を指定する。regexp.Regexp
でよいが、FindAllStringIndex(string, int) [][]int
を持つ型なら何でもよい
Sequence
は Pattern
の部分に適用するエスケープシーケンスを指定する
DefaultColor
はハイライトが適用されていない部分に使うシーケンスを指定する
ResetColor
は入力テキスト出力を終える時に使うシーケンスを指定する
- 従来のシンタックスハイライトのインターフェイス:
Coloring
は廃止予定です
editor := &readline.Editor{
// :
Highlight: []readline.Highlight{
{Pattern: regexp.MustCompile("&"), Sequence: "\x1B[33;49;22m"},
{Pattern: regexp.MustCompile(`"[^"]*"`), Sequence: "\x1B[35;49;22m"},
{Pattern: regexp.MustCompile(`%[^%]*%`), Sequence: "\x1B[36;49;1m"},
{Pattern: regexp.MustCompile("\u3000"), Sequence: "\x1B[37;41;22m"},
},
ResetColor: "\x1B[0m",
DefaultColor: "\x1B[33;49;1m",
}