[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] highlight text output



>Anyone know how to highlight text that is written to the screen?  I am
>trying to find text in a file and have the file displayed with the matches
>highlighted.

Is it possible? Yes and No.

The 'yes' part is that it is possible with TextEdit.pm to display a file
and select some text. Essentially you have to find the number of characters
in the file up to the beginning of the match and the number of characters
up to the end of the match. Then TESetSelect(STARTSEL, ENDSEL, HTE) will
highlight the match.

You can CUT, COPY, & PASTE the selection with TECut() etc.

The 'no' part is that you really have to do quite a lot of work to make the
thing useable. For instance if the file is bigger than the window (which it
probably will be?) you will need to put in working scroll-bars and that is
not a trivial undertaking.

Unless you prevent resizing of the window you will need to do write a
'layout' procedure which repositions and resizes the scroll bars,
rearranges the text and reselects the selected text. All this is possible
but involves quite a bit of work. It is the better part of a text editor,
really.

Attached is the bare bones of a script which matches and selects a word,
which I hope you might find helpful, or at least start some thoughts.

Alan Fry



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch