cecho() and insertText()

Post Reply
Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

cecho() and insertText()

Post by Caled »

I use insertText() a lot, as I like to use right-aligned system echos.
I have my own function for doing this:
Code: [show] | [select all] lua
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()?

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: cecho() and insertText()

Post by Caled »

Er, after rereading the manual, I want to ask my question differently:

Why does this, in an alias, not work? It echos the value of matches[2] in red, to the start of the next line. It's as though the cecho function resets the cursor to the end of the next/current line rather than letting me choose where to put it. I've tried using 'false' as the boolean just in case false meant insertText rather than echo, but the same result.
Code: [show] | [select all] lua
	local linenum = getLineCount()
	linenum = linenum -1 
	moveCursor("main", 85, linenum)

	cecho("<red>" .. matches[2], nil, nil, true, "main")

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: cecho() and insertText()

Post by Vadi »

I believe it's been changed to cecho("main", "<red>" .. matches[2]) in the latest and cinsertecho was added (or something similar).

Denarii
Posts: 111
Joined: Thu Dec 03, 2009 10:54 pm

Re: cecho() and insertText()

Post by Denarii »

cinserttext(), but it's currently broken and I haven't had time to fix it.

Post Reply