Lisp HUG Maillist Archive

colouring a region of text in editor

I'm digging through the docs and editor sources, but maybe someone can save me 
a bit of time.

Does anybody know how to colour a region of text within the editor (under 
program control, given two points)?

I've been trying it with set-region-face and font-lock-apply-highlight using 
editor::*font-lock-keyword-face*, but haven't had any success yet...

thanks
pt


Re: colouring a region of text in editor

Unable to parse email body. Email id is 2288

Re: colouring a region of text in editor

On Wed, 5 May 2004 10:53:50 -0400, tarvydas <tarvydas@allstream.net> wrote:

> I'm digging through the docs and editor sources, but maybe someone
> can save me a bit of time.
>
> Does anybody know how to colour a region of text within the editor
> (under program control, given two points)?
>
> I've been trying it with set-region-face and
> font-lock-apply-highlight using editor::*font-lock-keyword-face*,
> but haven't had any success yet...

This is how it's done in the "Regex Coach"[1]:

  (defun x-highlight-with-face (pane start-index end-index face)
    (let ((buffer (capi:editor-pane-buffer pane)))
      (editor::buffer-save-excursion (buffer)
       (editor:with-point ((start (editor:buffers-start buffer))
                           (end (editor:buffers-start buffer))
                           (point (editor:current-point)))
         (editor:increment-point start start-index)
         (editor:increment-point end end-index)
         (cond (face
                (editor::push-region-face face start end))
               (t
                (editor:remove-text-properties start end
                                               (list 'editor::face t))))))))

Cheers,
Edi.

[1] <http://weitz.de/regex-coach/>


Updated at: 2020-12-10 08:56 UTC