view src/luan/modules/swing/Text_area.luan @ 1722:7d2ab44f7a59 default tip

remove String regex fns
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 29 Jul 2022 14:12:01 -0600
parents 915cb538e2a3
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local set_metatable = Luan.set_metatable or error()
local type = Luan.type or error()
local Font = require "luan:swing/Font.luan"
require "java"
local JTextArea = require "java:javax.swing.JTextArea"


local Text_area = {}

local mt = {}

function mt.__index(text_area,key)
	if key == "line_wrap" then
		return text_area.java.getLineWrap()
	end
	if key == "wrap_style_word" then
		return text_area.java.getWrapStyleWord()
	end
	if key == "tab_size" then
		return text_area.java.getTabSize()
	end
	error("'"..key.."' not defined")
end

function mt.__new_index(text_area,key,value)
	if key == "line_wrap" then
		text_area.java.setLineWrap(value)
		return
	end
	if key == "wrap_style_word" then
		text_area.java.setWrapStyleWord(value)
		return
	end
	if key == "tab_size" then
		text_area.java.setTabSize(value)
		return
	end
	if key == "font" then
		if type(value) == "table" then
			value = Font.get(value)
		end
		text_area.java.setFont(value)
		return
	end
	error("'"..key.."' not defined")
end

function Text_area.new(rows,columns)
	local jtext_area = JTextArea.new(rows,columns)
	local text_area = { java = jtext_area }
	set_metatable(text_area,mt)
	return text_area
end

return Text_area