1088b4f5fSWarner Losh-- 272e39d71SKyle Evans-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD 372e39d71SKyle Evans-- 4088b4f5fSWarner Losh-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 5088b4f5fSWarner Losh-- All rights reserved. 6088b4f5fSWarner Losh-- 7088b4f5fSWarner Losh-- Redistribution and use in source and binary forms, with or without 8088b4f5fSWarner Losh-- modification, are permitted provided that the following conditions 9088b4f5fSWarner Losh-- are met: 10088b4f5fSWarner Losh-- 1. Redistributions of source code must retain the above copyright 11088b4f5fSWarner Losh-- notice, this list of conditions and the following disclaimer. 12088b4f5fSWarner Losh-- 2. Redistributions in binary form must reproduce the above copyright 13088b4f5fSWarner Losh-- notice, this list of conditions and the following disclaimer in the 14088b4f5fSWarner Losh-- documentation and/or other materials provided with the distribution. 15088b4f5fSWarner Losh-- 16088b4f5fSWarner Losh-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17088b4f5fSWarner Losh-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18088b4f5fSWarner Losh-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19088b4f5fSWarner Losh-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20088b4f5fSWarner Losh-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21088b4f5fSWarner Losh-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22088b4f5fSWarner Losh-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23088b4f5fSWarner Losh-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24088b4f5fSWarner Losh-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25088b4f5fSWarner Losh-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26088b4f5fSWarner Losh-- SUCH DAMAGE. 27088b4f5fSWarner Losh-- 28088b4f5fSWarner Losh-- $FreeBSD$ 29088b4f5fSWarner Losh-- 30088b4f5fSWarner Losh 31aedd6be5SKyle Evanslocal color = require("color") 32aedd6be5SKyle Evanslocal core = require("core") 33088b4f5fSWarner Losh 34aedd6be5SKyle Evanslocal screen = {} 351f5696c7SKyle Evans 36b5746545SKyle Evans-- Module exports 37ed1d0954SKyle Evansscreen.default_x = 0 38ed1d0954SKyle Evansscreen.default_y = 25 39ed1d0954SKyle Evans 40088b4f5fSWarner Loshfunction screen.clear() 419f71d421SKyle Evans if core.isSerialBoot() then 42aedd6be5SKyle Evans return 43088b4f5fSWarner Losh end 44223e9874SKyle Evans printc(core.KEYSTR_CSI .. "H" .. core.KEYSTR_CSI .. "J") 45088b4f5fSWarner Loshend 46088b4f5fSWarner Losh 47088b4f5fSWarner Loshfunction screen.setcursor(x, y) 489f71d421SKyle Evans if core.isSerialBoot() then 49aedd6be5SKyle Evans return 50088b4f5fSWarner Losh end 51901d96e3SKyle Evans 52223e9874SKyle Evans printc(core.KEYSTR_CSI .. y .. ";" .. x .. "H") 53088b4f5fSWarner Loshend 54088b4f5fSWarner Losh 555495d73cSKyle Evansfunction screen.setforeground(color_value) 569f71d421SKyle Evans if color.disabled then 575495d73cSKyle Evans return color_value 58088b4f5fSWarner Losh end 59*8ce1744fSKyle Evans printc(color.escapefg(color_value)) 60088b4f5fSWarner Loshend 61088b4f5fSWarner Losh 625495d73cSKyle Evansfunction screen.setbackground(color_value) 639f71d421SKyle Evans if color.disabled then 645495d73cSKyle Evans return color_value 65088b4f5fSWarner Losh end 66*8ce1744fSKyle Evans printc(color.escapebg(color_value)) 67088b4f5fSWarner Loshend 68088b4f5fSWarner Losh 69088b4f5fSWarner Loshfunction screen.defcolor() 70223e9874SKyle Evans printc(color.default()) 71088b4f5fSWarner Loshend 72088b4f5fSWarner Losh 73088b4f5fSWarner Loshfunction screen.defcursor() 749f71d421SKyle Evans if core.isSerialBoot() then 75aedd6be5SKyle Evans return 76088b4f5fSWarner Losh end 77ed1d0954SKyle Evans screen.setcursor(screen.default_x, screen.default_y) 78088b4f5fSWarner Loshend 79088b4f5fSWarner Losh 80aedd6be5SKyle Evansreturn screen 81