1*088b4f5fSWarner Losh-- 2*088b4f5fSWarner Losh-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 3*088b4f5fSWarner Losh-- All rights reserved. 4*088b4f5fSWarner Losh-- 5*088b4f5fSWarner Losh-- Redistribution and use in source and binary forms, with or without 6*088b4f5fSWarner Losh-- modification, are permitted provided that the following conditions 7*088b4f5fSWarner Losh-- are met: 8*088b4f5fSWarner Losh-- 1. Redistributions of source code must retain the above copyright 9*088b4f5fSWarner Losh-- notice, this list of conditions and the following disclaimer. 10*088b4f5fSWarner Losh-- 2. Redistributions in binary form must reproduce the above copyright 11*088b4f5fSWarner Losh-- notice, this list of conditions and the following disclaimer in the 12*088b4f5fSWarner Losh-- documentation and/or other materials provided with the distribution. 13*088b4f5fSWarner Losh-- 14*088b4f5fSWarner Losh-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*088b4f5fSWarner Losh-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*088b4f5fSWarner Losh-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*088b4f5fSWarner Losh-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*088b4f5fSWarner Losh-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*088b4f5fSWarner Losh-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*088b4f5fSWarner Losh-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*088b4f5fSWarner Losh-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*088b4f5fSWarner Losh-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*088b4f5fSWarner Losh-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*088b4f5fSWarner Losh-- SUCH DAMAGE. 25*088b4f5fSWarner Losh-- 26*088b4f5fSWarner Losh-- $FreeBSD$ 27*088b4f5fSWarner Losh-- 28*088b4f5fSWarner Losh 29*088b4f5fSWarner Loshlocal screen = {}; 30*088b4f5fSWarner Losh 31*088b4f5fSWarner Loshlocal color = require("color"); 32*088b4f5fSWarner Loshlocal core = require("core"); 33*088b4f5fSWarner Losh 34*088b4f5fSWarner Loshfunction screen.clear() 35*088b4f5fSWarner Losh if core.bootserial() then 36*088b4f5fSWarner Losh return; 37*088b4f5fSWarner Losh end 38*088b4f5fSWarner Losh loader.printc("\027[H\027[J"); 39*088b4f5fSWarner Loshend 40*088b4f5fSWarner Losh 41*088b4f5fSWarner Loshfunction screen.setcursor(x, y) 42*088b4f5fSWarner Losh if core.bootserial() then 43*088b4f5fSWarner Losh return; 44*088b4f5fSWarner Losh end 45*088b4f5fSWarner Losh loader.printc("\027["..y..";"..x.."H"); 46*088b4f5fSWarner Loshend 47*088b4f5fSWarner Losh 48*088b4f5fSWarner Loshfunction screen.setforeground(c) 49*088b4f5fSWarner Losh if color.disabled then 50*088b4f5fSWarner Losh return c; 51*088b4f5fSWarner Losh end 52*088b4f5fSWarner Losh loader.printc("\027[3"..c.."m"); 53*088b4f5fSWarner Loshend 54*088b4f5fSWarner Losh 55*088b4f5fSWarner Loshfunction screen.setbackground(c) 56*088b4f5fSWarner Losh if color.disabled then 57*088b4f5fSWarner Losh return c; 58*088b4f5fSWarner Losh end 59*088b4f5fSWarner Losh loader.printc("\027[4"..c.."m"); 60*088b4f5fSWarner Loshend 61*088b4f5fSWarner Losh 62*088b4f5fSWarner Loshfunction screen.defcolor() 63*088b4f5fSWarner Losh loader.printc(color.default()); 64*088b4f5fSWarner Loshend 65*088b4f5fSWarner Losh 66*088b4f5fSWarner Loshfunction screen.defcursor() 67*088b4f5fSWarner Losh if core.bootserial() then 68*088b4f5fSWarner Losh return; 69*088b4f5fSWarner Losh end 70*088b4f5fSWarner Losh loader.printc("\027[25;0H"); 71*088b4f5fSWarner Loshend 72*088b4f5fSWarner Losh 73*088b4f5fSWarner Loshreturn screen 74