| Message |
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.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|