I use insertText() a lot, as I like to use right-aligned system echos.
I have my own function for doing this:
function posecho( mess, pos, col, line_offset, writeover)
-- Determine the line to print to
local linenum = getLineCount()
if line_offset ~= nil then
linenum = linenum + line_offset
end
moveCursor("main", pos, linenum)
-- Replace existing, or add to end?
if writeover ~= nil then
local endpos = 1
endpos = string.len( mess)
endpos = pos + endpos
selectString( mess, 1)
replace("")
end
-- Colour the text?
fg(col) bg("black")
insertText(mess)
resetFormat()
moveCursorEnd("main")
end
I'd like to use cecho() for this, to make prettier system echos - my function only allows a single colour.
Do you think it is possible? If so, any suggestions on how I can rewrite my function to use cecho() rather than insertText()?