You are here: PSPad forum > English discussion forum > Re: How can I change the (background) color for single words via VBScript?

Re: How can I change the (background) color for single words via VBScript?

#1 How can I change the (background) color for single words via VBScript?

Posted by: Professor Bernd | Date: 2019-10-06 15:22 | IP: IP Logged

I would like to implement the highlighting function for identical words via VBScript. Therefore I could use "selText" to find the marked word and search for further occurrences. But how can I highlight the words?

See feature requests

forum.pspad.com
forum.pspad.com
forum.pspad.com
forum.pspad.com

Options: Reply | Quote | Up ^


#2 Re: How can I change the (background) color for single words via VBScript?

Posted by: pspad | Date: 2019-10-06 15:50 | IP: IP Logged

Set curso to the start of the word and call SelStart() foolowed by SelLength(length_of_the_word)

or

Set cursor to start of the word and call editorCommand(ecSelWord)

Options: Reply | Quote | Up ^


#3 Re: How can I change the (background) color for single words via VBScript?

Posted by: vbr | Date: 2019-10-06 18:24 | IP: IP Logged

Professor Bernd:
I would like to implement the highlighting function for identical words via VBScript. Therefore I could use "selText" to find the marked word and search for further occurrences. But how can I highlight the words?

See feature requests
[...]

Hi,
I think, this functionality is currently not supported - the mentioned script commands perform a selection - e.g. for copying text etc. - only one selection at a time is possible, multiple selected text portions are not supported with the current editor component.

Other kinds of marking string occurrences, such as font or background color cannot be set individually in this manner either, as far as I know. (only e.g. for syntax highlighters etc.)

vbr

Options: Reply | Quote | Up ^


#4 Re: How can I change the (background) color for single words via VBScript?

Posted by: Professor Bernd | Date: 2019-10-07 20:15 | IP: IP Logged

What I meant was what vbr wrote: One word is marked and the other occurrences are highlighted. Here is a screenshot.

image
.

I'm working on an PSPad extension (VBScript) to use the highlighter for this purpose. In the highlighter (AutoIt3.ini) in the unused section "Key words 3" I set a font and background color. With VBScript I check if a word has been marked and write it temporarily into the section "Key words 3" of AutoIt3.ini. Then (almost) all occurrences of the word are highlighted.

If the word is unmarked, the entry in AutoIt3.ini is also deleted => all highlights are removed.

This might work, but there are some problems, e.g. that occurrences in comments are not highlighted. (see screenshot)

image

Is there a way to highlight words using VBScript?

@Jan

Many thanks for the tip about the EditorCommands! I searched a little and found a good hint here. I searched the PSPad directory for a rtf and found the Scripting.rtf. Is there more information about EditorCommands? Is there a command to set the background color for identical words?

Bernd.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2019 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR