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

vfmt: change all '$expr' to '${expr}' (#16428)

This commit is contained in:
yuyi
2022-11-15 21:53:13 +08:00
committed by GitHub
parent 56239b4a23
commit 017ace6ea7
859 changed files with 7156 additions and 7135 deletions

View File

@ -4,11 +4,11 @@
module term
pub fn format(msg string, open string, close string) string {
return '\x1b[${open}m$msg\x1b[${close}m'
return '\x1b[${open}m${msg}\x1b[${close}m'
}
pub fn format_rgb(r int, g int, b int, msg string, open string, close string) string {
return '\x1b[$open;2;$r;$g;${b}m$msg\x1b[${close}m'
return '\x1b[${open};2;${r};${g};${b}m${msg}\x1b[${close}m'
}
pub fn rgb(r int, g int, b int, msg string) string {
@ -194,5 +194,5 @@ pub fn bright_bg_white(msg string) string {
// highlight_command highlights the command with an on-brand background
// to make CLI commands immediately recognizable.
pub fn highlight_command(command string) string {
return bright_white(bg_cyan(' $command '))
return bright_white(bg_cyan(' ${command} '))
}

View File

@ -15,7 +15,7 @@ module term
// x is the x coordinate
// y is the y coordinate
pub fn set_cursor_position(c Coord) {
print('\x1b[$c.y;$c.x' + 'H')
print('\x1b[${c.y};${c.x}' + 'H')
flush_stdout()
}
@ -25,7 +25,7 @@ pub fn set_cursor_position(c Coord) {
// direction: C is forward / East
// direction: D is backward / West
pub fn move(n int, direction string) {
print('\x1b[$n$direction')
print('\x1b[${n}${direction}')
flush_stdout()
}

View File

@ -40,7 +40,7 @@ pub fn failed(s string) string {
// If colors are not allowed, returns a given string.
pub fn ok_message(s string) string {
if can_show_color_on_stdout() {
return green(' $s ')
return green(' ${s} ')
}
return s
}
@ -48,14 +48,14 @@ pub fn ok_message(s string) string {
// fail_message returns a colored string with red color.
// If colors are not allowed, returns a given string.
pub fn fail_message(s string) string {
return failed(' $s ')
return failed(' ${s} ')
}
// warn_message returns a colored string with yellow color.
// If colors are not allowed, returns a given string.
pub fn warn_message(s string) string {
if can_show_color_on_stdout() {
return bright_yellow(' $s ')
return bright_yellow(' ${s} ')
}
return s
}
@ -148,7 +148,7 @@ pub fn header_left(text string, divider string) string {
hstart := relement.repeat(4)[0..4]
remaining_cols := imax(0, (cols - (hstart.len + 1 + plain_text.len + 1)))
hend := relement.repeat((remaining_cols + 1) / relement.len)[0..remaining_cols]
return '$hstart $text $hend'
return '${hstart} ${text} ${hend}'
}
// header returns a horizontal divider line with a centered text in the middle.

View File

@ -76,9 +76,9 @@ fn test_get_cursor_position() {
cursor_position_3 := term.get_cursor_position()!
//
term.set_cursor_position(original_position)
eprintln('original_position: $original_position')
eprintln('cursor_position_2: $cursor_position_2')
eprintln('cursor_position_3: $cursor_position_3')
eprintln('original_position: ${original_position}')
eprintln('cursor_position_2: ${cursor_position_2}')
eprintln('cursor_position_3: ${cursor_position_3}')
// 0,0 is returned on dumb terminals
if cursor_position_2.x == 0 && cursor_position_2.y == 0 {
return

View File

@ -75,7 +75,7 @@ pub fn init(cfg Config) &Context {
}
if ctx.cfg.window_title != '' {
print('\x1b]0;$ctx.cfg.window_title\x07')
print('\x1b]0;${ctx.cfg.window_title}\x07')
flush_stdout()
}
@ -293,7 +293,7 @@ fn (mut ctx Context) parse_events() {
}
w := sb.srWindow.Right - sb.srWindow.Left + 1
h := sb.srWindow.Bottom - sb.srWindow.Top + 1
utf8 := '($ctx.window_width, $ctx.window_height) -> ($w, $h)'
utf8 := '(${ctx.window_width}, ${ctx.window_height}) -> (${w}, ${h})'
if w != ctx.window_width || h != ctx.window_height {
ctx.window_width, ctx.window_height = w, h
mut event := &Event{

View File

@ -78,7 +78,7 @@ fn (mut ctx Context) termios_setup() ! {
}
if ctx.cfg.window_title != '' {
print('\x1b]0;$ctx.cfg.window_title\x07')
print('\x1b]0;${ctx.cfg.window_title}\x07')
flush_stdout()
}
@ -90,7 +90,7 @@ fn (mut ctx Context) termios_setup() ! {
C.tcsetattr(C.STDIN_FILENO, C.TCSAFLUSH, &termios)
// feature-test the SU spec
sx, sy := get_cursor_position()
print('$bsu$esu')
print('${bsu}${esu}')
flush_stdout()
ex, ey := get_cursor_position()
if sx == ex && sy == ey {

View File

@ -13,7 +13,7 @@ pub:
}
pub fn (c Color) hex() string {
return '#$c.r.hex()$c.g.hex()$c.b.hex()'
return '#${c.r.hex()}${c.g.hex()}${c.b.hex()}'
}
// Synchronized Updates spec, designed to avoid tearing during renders
@ -54,7 +54,7 @@ pub fn (mut ctx Context) bold() {
// set_cursor_position positions the cusor at the given coordinates `x`,`y`.
[inline]
pub fn (mut ctx Context) set_cursor_position(x int, y int) {
ctx.write('\x1b[$y;${x}H')
ctx.write('\x1b[${y};${x}H')
}
// show_cursor will make the cursor appear if it is not already visible
@ -115,7 +115,7 @@ pub fn (mut ctx Context) clear() {
// set_window_title sets the string `s` as the window title.
[inline]
pub fn (mut ctx Context) set_window_title(s string) {
print('\x1b]0;$s\x07')
print('\x1b]0;${s}\x07')
flush_stdout()
}