1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/examples/terminal_control.v
bpryer 3f7970db52
term: add get_cursor_position and set_terminal_title (#6279)
* added functions

added:
  - get_cursor_position()
  - set_terminal_title(title string)

* implement term.get_cursor_position and term.set_terminal_title on unix

* Cleanup

* make x,y fields of term.Coord mutable

* fix vrepl compilation

* use more descriptive var names in term_test.v

* do not change the current terminal title in dumb terminals; do not test term.set_terminal_title outside of CI

* unix: in term.set_terminal_title, return true even for dumb terminals

Co-authored-by: Brent Pryer <brent@pryermachine.com>
Co-authored-by: Delyan Angelov <delian66@gmail.com>
2020-09-08 22:00:10 +03:00

31 lines
552 B
V

import term
fn main() {
term.erase_clear()
sleeping_line(5,5,5,'*')
standing_line(5,5,5,'*')
sleeping_line(5,10,5,'*')
standing_line(9,5,5,'*')
term.cursor_down(5)
print('\n')
println(term.bold(term.red('It Worked!')))
}
fn sleeping_line(x,y,size int, ch string) {
mut i := 0
for i < size {
term.set_cursor_position(x: x+i, y: y)
print(term.bold(term.yellow(ch)))
i++
}
}
fn standing_line(x,y,size int, ch string) {
mut i := 0
for i < size {
term.set_cursor_position(x: x, y: y+i)
print(term.bold(term.yellow(ch)))
i++
}
}