ComputerCraft Archive

Text

computer utility kepler155c github

Description

ComputerCraft OS

Installation

Copy one of these commands into your ComputerCraft terminal:

wget:wget https://raw.githubusercontent.com/kepler155c/opus/develop-1.8/sys/modules/opus/ui/components/Text.lua text
Archive:wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-modules-opus-ui-components-text text
Quick Install: wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-modules-opus-ui-components-text Text

Usage

Run: Text

Tags

none

Source

View Original Source

Code Preview

local class = require('opus.class')
local UI    = require('opus.ui')
local Util  = require('opus.util')

UI.Text = class(UI.Window)
UI.Text.defaults = {
	UIElement = 'Text',
	value = '',
	height = 1,
}
function UI.Text:layout()
	if not self.width and not self.ex then
		self.width = #tostring(self.value)
	end
	UI.Window.layout(self)
end

function UI.Text:draw()
	self:write(1, 1, Util.widthify(self.value, self.width, self.align))
end