mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
term: make the second example in the README.md compilable as well
This commit is contained in:
parent
be3a5362c2
commit
3c88926fdb
1 changed files with 9 additions and 8 deletions
|
@ -41,13 +41,14 @@ This simple program covers many of the principal aspects of the `term ` module.
|
|||
|
||||
## API
|
||||
|
||||
Here are some functions you should be aware of in the `term `module:
|
||||
Here are some of the main functions of the `term `module:
|
||||
|
||||
```v oksyntax
|
||||
```v
|
||||
import term
|
||||
|
||||
// returns the height and the width of the terminal
|
||||
width, height := term.get_terminal_size()
|
||||
println('width: ${width}, height: ${height}')
|
||||
// returns the string as green text to be printed on stdout
|
||||
term.ok_message('cool')
|
||||
// returns the string as red text to be printed on stdout
|
||||
|
@ -77,15 +78,15 @@ term.bg_green('field')
|
|||
// sets the position of the cursor at a given place in the terminal
|
||||
term.set_cursor_position(x: 5, y: 10)
|
||||
// moves the cursor up
|
||||
term.cursor_up()
|
||||
term.cursor_up(1)
|
||||
// moves the cursor down
|
||||
term.cursor_down()
|
||||
term.cursor_down(1)
|
||||
// moves the cursor to the right
|
||||
term.cursor_forward()
|
||||
term.cursor_forward(2)
|
||||
// moves the cursor to the left
|
||||
term.cursor_back()
|
||||
// shows the cursor
|
||||
term.show_cursor()
|
||||
term.cursor_back(2)
|
||||
// hides the cursor
|
||||
term.hide_cursor()
|
||||
// shows the cursor
|
||||
term.show_cursor()
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue