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

term: optimized move function

This commit is contained in:
archanpatkar 2019-07-07 00:12:05 +05:30 committed by Alexander Medvednikov
parent ccf733ac95
commit f767218107

View File

@ -26,24 +26,24 @@ pub fn set_cursor_position(x int,y int) {
// direction: B is down / South // direction: B is down / South
// direction: C is forward / East // direction: C is forward / East
// direction: D is backward / West // direction: D is backward / West
pub fn move(n int,direction string) string { pub fn move(n int,direction string) {
return '\x1b[$n$direction' print('\x1b[$n$direction')
} }
pub fn cursor_up(n int) { pub fn cursor_up(n int) {
print(move(n,'A')) move(n,'A')
} }
pub fn cursor_down(n int) { pub fn cursor_down(n int) {
print(move(n,'B')) move(n,'B')
} }
pub fn cursor_forward(n int) { pub fn cursor_forward(n int) {
print(move(n,'C')) move(n,'C')
} }
pub fn cursor_back(n int) { pub fn cursor_back(n int) {
print(move(n,'D')) move(n,'D')
} }
// type: 0 -> current cursor postion to end of the screen // type: 0 -> current cursor postion to end of the screen