diff options
Diffstat (limited to 'term/init.lua')
-rw-r--r-- | term/init.lua | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/term/init.lua b/term/init.lua index 07be081..8e59ce6 100644 --- a/term/init.lua +++ b/term/init.lua | |||
@@ -18,7 +18,33 @@ | |||
18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
19 | -- THE SOFTWARE. | 19 | -- THE SOFTWARE. |
20 | 20 | ||
21 | local term = require 'term.core' | 21 | local term = require 'term.core' |
22 | local sformat = string.format | ||
23 | local iotype = io.type | ||
24 | local stdout = io.stdout | ||
25 | |||
26 | function term.maketermfunc(sequence_fmt) | ||
27 | sequence_fmt = '\027[' .. sequence_fmt | ||
28 | |||
29 | local func | ||
30 | |||
31 | func = function(handle, ...) | ||
32 | if iotype(handle) ~= 'file' then | ||
33 | return func(stdout, handle, ...) | ||
34 | end | ||
35 | |||
36 | return handle:write(sformat(sequence_fmt, ...)) | ||
37 | end | ||
38 | |||
39 | return func | ||
40 | end | ||
41 | |||
22 | term.colors = require 'term.colors' | 42 | term.colors = require 'term.colors' |
43 | term.cursor = require 'term.cursor' | ||
44 | |||
45 | term.clear = term.maketermfunc '2J' | ||
46 | term.cleareol = term.maketermfunc 'K' | ||
47 | |||
48 | term.maketermfunc = nil | ||
23 | 49 | ||
24 | return term | 50 | return term |