Dan S wrote:
Hi -

I have a project where I'd like code in vim to be coloured, with the
colours changing in real time (to reflect some audio-related data
being generated). For example, say the text "Merti()" represents an
audio object - I'd like to be able to update the colouring of that
text to reflect the current loudness of that object.

Although the incoming data is 'continuous' it'd be fine to use a
predefined palette of (say) 25 colours which I could define as 25
syntax categories.

The loudness data I can derive externally, that's no problem, but I'd
like to know if I can efficiently achieve the rapid color changes in
vim. Some questions:
* Is vim's syntax highlighting efficient enough to be run many (e.g.
10) times per second? e.g. if I dynamically tweak a syntax-
highlighting file from outside and force it to be re-read.

Not the best approach.

* Is there a more efficient approach you could suggest, such as syntax-
highlighting information coming through a pipe, or by executing
commands rather than reading a file?

You can execute the :highlight command to change the color of specific syntax groups. For example, if you have defined a syntax group for the text "Merti()" as follows...
:syn match Merti /Merti()/

...you could cause it to be highlighted blue with the following :highlight command:
:hi Merti guifg=#0000FF ctermfg=Blue

Changing the Merti() object to red is as simple as executing the following command:
:hi Merti guifg=#FF0000 ctermfg=Red

* Is there a better way that doesn't use vim's syntax highlighting
engine (e.g. directly through setting colour of text ranges)?

Not sure exactly what you mean here. Txtfmt (The Vim Highligher)...
http://www.vim.org/scripts/script.php?script_id=2208
...provides a flexible capability to change text's colors (and format attributes) by assigning different colors to different tokens (characters) in a range, but it certainly uses Vim's syntax highlighting engine. I think for the usage you've described, the second option makes the most sense.

Hope it helps...
Brett Stahlman


Thanks for any suggestions -
Dan


--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to