Skip to content

Commit b92767a

Browse files
authored
Merge pull request premake#2253 from tritao/term-apis
Add `term.clearToEndOfLine` and `term.moveLeft` API additions.
2 parents 3f3c358 + 450d0d6 commit b92767a

File tree

5 files changed

+61
-1
lines changed

5 files changed

+61
-1
lines changed

src/base/term.lua

+8
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ function term.popColor()
4343
term.setTextColor(color)
4444
end
4545
end
46+
47+
function term.clearToEndOfLine()
48+
io.write("\027[K")
49+
end
50+
51+
function term.moveLeft(n)
52+
io.write(string.format("\027[%sD", n))
53+
end

website/docs/Lua-Library-Additions.md

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@
128128
* [term.setTextColor](term.setTextColor.md)
129129
* [term.pushColor](term.pushColor.md)
130130
* [term.popColor](term.popColor.md)
131+
* [term.clearToEndOfLine](term.clearToEndOfLine.md)
132+
* [term.moveLeft](term.moveLeft.md)
131133

132134
### Zip
133135

website/docs/term.clearToEndOfLine.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Clears the console from the cursor location to the end of the line.
2+
3+
```lua
4+
term.clearToEndOfLine()
5+
```
6+
7+
### Parameters ###
8+
None
9+
10+
### Return Value ###
11+
None
12+
13+
### Example ###
14+
``` lua
15+
term.clearToEndOfLine()
16+
```
17+
18+
### See Also ###
19+
* [term.moveLeft](term.moveLeft.md)
20+
21+
### Availability ###
22+
23+
Premake 5.0.0 beta 3 or later.
24+

website/docs/term.moveLeft.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Moves the console cursor left by a number of columns.
2+
3+
```lua
4+
term.moveLeft(columns)
5+
```
6+
7+
### Parameters ###
8+
`columns` is the number of columns to move left.
9+
10+
### Return Value ###
11+
None
12+
13+
### Example ###
14+
``` lua
15+
term.moveLeft(2)
16+
```
17+
18+
### See Also ###
19+
* [term.clearToEndOfLine](term.clearToEndOfLine.md)
20+
21+
### Availability ###
22+
23+
Premake 5.0.0 beta 3 or later.
24+

website/sidebars.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,11 @@ module.exports = {
491491
label: 'term',
492492
items: [
493493
'term.getTextColor',
494+
'term.setTextColor',
494495
'term.popColor',
495496
'term.pushColor',
496-
'term.setTextColor'
497+
'term.clearToEndOfLine',
498+
'term.moveLeft'
497499
]
498500
},
499501
{

0 commit comments

Comments
 (0)