Re: [code] [textadept] changing text color in message buffer

From: Jay Young <jyng7.att.hotmail.com>
Date: Fri, 11 Mar 2016 06:22:14 +0000

Hi Mitchell,

Please don't feel obligated to reply to my thoughts below, since I don't know what I'm doing and I'm using this code in my init.lua which might be a problem (I like my working buffer always active):

textadept.run.RUN_IN_BACKGROUND = true

I was thinking I could loop through the buffers and try to find the message buffer in order to work with it. But my lack of knowledge with Lua is bringing this to a halt. I'm not quite sure how to use:

buffer:start_styling(pos, buffer.STYLE_MAX)
buffer:set_styling(length, style)

The 'pos' and 'length' parameters make sense, but I'm not sure what to enter for 'buffer.STYLE_MAX' and 'style'. And I'm wondering if I need to use the following somewhere as well, in order to add the color to the characters, but not sure what to enter for the style and color:

buffer.style_fore[style], color

The code I've been testing looks like so, although it doesn't store the message buffer correctly. If you have some quick thoughts, I'd love to hear them, but again don't feel obligated and please don't waste too much time on this.

events.connect(events.RUN_OUTPUT, function(lexer, output)
    for i, buffer in ipairs(_BUFFERS) do
        if buffer._type == _L['[Message Buffer]'] then
            local buffer = buffer
            break
        end
    end

    ui.print(buffer.filename)
    ui.print(buffer.style_at[0])

    --buffer:start_styling(0, 0xff)
    --buffer:set_styling(5, 5)
end, 1)

Thank you.

Jay

________________________________________
From: Mitchell <m.att.foicica.com>
Sent: Wednesday, March 9, 2016 9:43 PM
To: code.att.foicica.com
Subject: Re: [code] [textadept] changing text color in message buffer

Hi Jay,

On Wed, 9 Mar 2016, Jay Young wrote:

> I'm curious if it's possible to change the color of the result text in the message buffer?
> I don't want to change the color of the lines that start with the greater than sign, but just the results in-between those.
>
>> sh "test.sh"
> result... <-- Only change this color
>> exit status: 0

It's certainly not straightforward, but you can:

1. Connect to `events.RUN_OUTPUT` with an index of 1 (in order to override
the default functionality).
2. `ui.print()` the output given.
3. Define the style you want to use via `buffer.style_*[]`.
4. Determine what was printed and then do the styling via
`buffer:start_styling()` and `buffer:set_styling()`.

If you have the Textadept Quick Reference, the section "Manually Style
Text" will be of help.

Cheers,
Mitchell

--
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Fri 11 Mar 2016 - 01:22:14 EST

This archive was generated by hypermail 2.2.0 : Fri 11 Mar 2016 - 06:43:19 EST