mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
term.ui: allow setting the terminal title (#6809)
This commit is contained in:
@ -9,12 +9,17 @@ pub fn init(cfg Config) &Context {
|
||||
cfg: cfg,
|
||||
read_buf: []byte{ cap: cfg.buffer_size }
|
||||
}
|
||||
ctx.save_title()
|
||||
|
||||
if cfg.hide_cursor {
|
||||
s := '\x1b[?25l'
|
||||
C.write(C.STDOUT_FILENO, s.str, s.len)
|
||||
print('\x1b[?25l')
|
||||
}
|
||||
|
||||
if cfg.window_title != '' {
|
||||
print('\x1b]0;$cfg.window_title\x07')
|
||||
}
|
||||
|
||||
// lmao
|
||||
unsafe {
|
||||
x := &ctx_ptr
|
||||
*x = ctx
|
||||
@ -23,6 +28,15 @@ pub fn init(cfg Config) &Context {
|
||||
return ctx
|
||||
}
|
||||
|
||||
pub fn (mut ctx Context) save_title() {
|
||||
// restore the previously saved terminal title
|
||||
print('\x1b[22;0t')
|
||||
}
|
||||
pub fn (mut ctx Context) load_title() {
|
||||
// restore the previously saved terminal title
|
||||
print('\x1b[23;0t')
|
||||
}
|
||||
|
||||
pub fn (mut ctx Context) run() {
|
||||
if ctx.cfg.use_x11 {
|
||||
ctx.fail('error: x11 backend not implemented yet')
|
||||
|
Reference in New Issue
Block a user