Wildcard Colours

Posted by Zalethon on Thu 26 Apr 2007 07:54 PM — 4 posts, 19,741 views.

USA #0
I know there's a way to match colours. Is there a way to detect the colour of a wildcard for use in a script? In this case I want to put a line of text from the MUD into the info bar, to alert me if I'm in another window, but I want it to keep its colours..
Australia Forum Administrator #1
See: http://mushclient.com/faq - items 23 and 33.
Amended on Thu 26 Apr 2007 08:23 PM by Nick Gammon
USA #2
Is there any way to do it without Lua?
Australia Forum Administrator #3
Yes you can, see below, however I should point out that you can make a plugin in Lua that does this particular function, even if the rest of your scripts are in some other language.

To get the colours in other languages, you need a couple of function calls:



Armed with all that you can redisplay it, send to another window, send to the Info bar, or whatever you want.

Bear in mind that triggers fire on a newline, however a large line might wrap, taking up one or more physical lines. GetLineInfo returns a physical line, not a logical line. You can tell from GetLineInfo (line_number, 3) if the line you are looking at has a newline at the end of it. If not, you can "walk backwards" (ie. subtracting 1 from the line number each time) until you find a line with a newline. The one after that is the start of the current logical line.

Example:


Line 101: The Cathedral Altar (newline)
Line 102: You are before the cathedral's altar.  Those of ill luck or poor faith often
Line 103: come here to pray to their God for guidance, or chance.  An aisle leads back
Line 104: south through the cathedral, while a large public board lies to the west. (newline)


Now in this example, if this was one big paragraph starting at "You are before the cathedral's altar ..." then the trigger will fire at line 104 (but not on receiving lines 102 or 103).

Thus, calling GetLinesInBufferCount will return 104. I would then "work backwards" (subtracting 1 each time), until I got a newline (by calling GetLineInfo). In this case, line 101.

I now know that lines 102 onwards (the one after the newline) comprise this paragraph.

For each of those lines you can pull out the colour information using GetStyleInfo. The call to GetLineInfo tells you how many styles there are in the line, so you know how many times to call GetStyleInfo.