1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

term: add format_esc/1 (#16574)

This commit is contained in:
RGBCube 2022-12-03 15:01:39 +03:00 committed by GitHub
parent bf0c8a0d96
commit 5acd855525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,14 @@
// that can be found in the LICENSE file.
module term
// format_esc produces an ANSI escape code, for selecting the graphics rendition of the following
// text. Each of the attributes that can be passed in `code`, separated by `;`, will be in effect,
// until the terminal encounters another SGR ANSI escape code. For more details about the different
// codes, and their meaning, see: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
pub fn format_esc(code string) string {
return '\x1b[${code}m'
}
pub fn format(msg string, open string, close string) string {
return '\x1b[${open}m${msg}\x1b[${close}m'
}