Re: [code] Highlighting questions

From: Mitchell <m.att.foicica.com>
Date: Wed, 6 May 2020 09:08:30 -0400 (EDT)

Hi Christian,

On Wed, 6 May 2020, Christian Gelinek wrote:

> On 2/5/20 4:22 am, Mitchell wrote:
>
>> On Fri, 1 May 2020, Christian Gelinek wrote:
>>> 2. Can we have multiple simultaneous highlights with different colours
>>>   for different (parts of) words?
>>
>> You'd have to code this up on your own, but it's possible.
>> *modules/textadept/editing.lua*'s `textadept.editing.highlight_word()` is a
>> starting point of how you might go about doing this.
>
> Thanks for the pointer, if I find time to work this out, I'll be sure to
> share it here.
>
>
>>> 3. Can other occurrences of the currently selected word be (slightly)
>>>   highlighted?
>>
>> `textadept.editing.highlight_word()` does the highlighting of selected
>> words; you'd just have to change the color to be more "slightly
>> highlighted". `textadept.editing.INDIC_HIGHLIGHT` is the indicator you'd
>> want to change the color of.
>
> Hmm, there already appears to be some configuration present:
>
> buffer.indic_fore[textadept.editing.INDIC_HIGHLIGHT] = 56575
> buffer.indic_alpha[textadept.editing.INDIC_HIGHLIGHT] = 255
> buffer.indic_style[textadept.editing.INDIC_HIGHLIGHT] = 7
>
> I interpret this as colour 0x00dcff (a bright cyan), fully opaque
> <https://foicica.com/textadept/api.html#buffer.indic_fore>, INDIC_ROUNDBOX
> <https://foicica.com/textadept/api.html#buffer.indic_style> style, but I must
> be missing something as I can't see any such highlights on words that equal
> the selected one.
>
> Here is a screenshot with the word "editing" on line 2 selected:

Textadept does not highlight words automatically when you select them. You have to call `textadept.editing.highlight_word()` manually, e.g. via Edit > Highlight Word or the equivalent key binding. You can connect to `events.UPDATE_UI` to automatically do this with possible performance issues. Something like this in your *~/.textadept/init.lua*:

   events.connect(events.UPDATE_UI, function(update)
     if update & buffer.UPDATE_SELECTION > 0 and
        not buffer.selection_empty then
       textadept.editing.highlight_word()
     end
   end)

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.
Received on Wed 06 May 2020 - 09:08:30 EDT

This archive was generated by hypermail 2.2.0 : Thu 07 May 2020 - 06:27:24 EDT