In Scite, I uncomment:
Code: Select all
highlight.current.word=1
highlight.current.word.by.style=1
highlight.current.word.colour=#00D040
Code: Select all
highlight.current.word=1
highlight.current.word.by.style=1
highlight.current.word.colour=#00D040
This is not actually a "feature of scintilla." It is a feature that is commonly implemented in editors that use scintilla, but it is manually coded in each. It is not like the "goto line #" feature that is a single function call. With Smart Highlighting, you have to manually grab the highlighted text, then manually search for each occurrence and then manually shade them. All the while tracking when views and selections change to add and remove highlighting, etc. There are some simple examples online, but they are always lacking features.ssb wrote:Count my vote for this too!
Never understood why so many useful features of Scintilla have been disabled in Purebasic IDE.
Code: Select all
void SciTEBase::HighlightCurrentWord(bool highlight) {
if (!currentWordHighlight.isEnabled)
return;
GUI::ScintillaWindow &wCurrent = wOutput.HasFocus() ? wOutput : wEditor;
// Remove old indicators if any exist.
wCurrent.Call(SCI_SETINDICATORCURRENT, indicatorHightlightCurrentWord);
int lenDoc = wCurrent.Call(SCI_GETLENGTH);
wCurrent.Call(SCI_INDICATORCLEARRANGE, 0, lenDoc);
if (!highlight)
return;
// Get start & end selection.
int selStart = wCurrent.Call(SCI_GETSELECTIONSTART);
int selEnd = wCurrent.Call(SCI_GETSELECTIONEND);
bool noUserSelection = selStart == selEnd;
SString wordToFind = RangeExtendAndGrab(wCurrent, selStart, selEnd,
&SciTEBase::islexerwordcharforsel);
if (wordToFind.length() == 0 || wordToFind.contains('\n') || wordToFind.contains('\r'))
return; // No highlight when no selection or multi-lines selection.
if (noUserSelection && currentWordHighlight.statesOfDelay == currentWordHighlight.noDelay) {
// Manage delay before highlight when no user selection but there is word at the caret.
currentWordHighlight.statesOfDelay = currentWordHighlight.delay;
// Reset timer
currentWordHighlight.elapsedTimes.Duration(true);
return;
}
// Get style of the current word to highlight only word with same style.
int selectedStyle = wCurrent.Call(SCI_GETSTYLEAT, selStart);
// Manage word with DBCS.
wordToFind = EncodeString(wordToFind);
// Case sensitive & whole word only.
wCurrent.Call(SCI_SETSEARCHFLAGS, SCFIND_MATCHCASE | SCFIND_WHOLEWORD);
wCurrent.Call(SCI_SETTARGETSTART, 0);
wCurrent.Call(SCI_SETTARGETEND, lenDoc);
// Find the first occurrence of word.
int indexOf = wCurrent.CallString(SCI_SEARCHINTARGET,
wordToFind.length(), wordToFind.c_str());
while (indexOf != -1 && indexOf < lenDoc) {
if (!currentWordHighlight.isOnlyWithSameStyle || selectedStyle ==
wCurrent.Call(SCI_GETSTYLEAT, indexOf)) {
wCurrent.Call(SCI_INDICATORFILLRANGE, indexOf, wordToFind.length());
}
// Try to find next occurrence of word.
wCurrent.Call(SCI_SETTARGETSTART, indexOf + wordToFind.length() + 1);
wCurrent.Call(SCI_SETTARGETEND, lenDoc);
indexOf = wCurrent.CallString(SCI_SEARCHINTARGET, wordToFind.length(),
wordToFind.c_str());
}
}
And yours is predated by this one by eight months.Tenaja wrote:...and my request predates the previous link by about a year:
http://www.purebasic.fr/english/viewtop ... ht#p340278
Wow, so oft requested...Demivec wrote:And yours is predated by this one by eight months.Tenaja wrote:...and my request predates the previous link by about a year:
http://www.purebasic.fr/english/viewtop ... ht#p340278
I found how to activate this. You must edit the SciTEGlobal.properties file, and uncoment (remove the # character) from the line that has the setting:xorc1zt wrote:from scite
Code: Select all
void SciTEBase::HighlightCurrentWord(bool highlight) { if (!currentWordHighlight.isEnabled) return; GUI::ScintillaWindow &wCurrent = wOutput.HasFocus() ? wOutput : wEditor; // Remove old indicators if any exist. wCurrent.Call(SCI_SETINDICATORCURRENT, indicatorHightlightCurrentWord); int lenDoc = wCurrent.Call(SCI_GETLENGTH); wCurrent.Call(SCI_INDICATORCLEARRANGE, 0, lenDoc); if (!highlight) return; // Get start & end selection. int selStart = wCurrent.Call(SCI_GETSELECTIONSTART); int selEnd = wCurrent.Call(SCI_GETSELECTIONEND); bool noUserSelection = selStart == selEnd; SString wordToFind = RangeExtendAndGrab(wCurrent, selStart, selEnd, &SciTEBase::islexerwordcharforsel); if (wordToFind.length() == 0 || wordToFind.contains('\n') || wordToFind.contains('\r')) return; // No highlight when no selection or multi-lines selection. if (noUserSelection && currentWordHighlight.statesOfDelay == currentWordHighlight.noDelay) { // Manage delay before highlight when no user selection but there is word at the caret. currentWordHighlight.statesOfDelay = currentWordHighlight.delay; // Reset timer currentWordHighlight.elapsedTimes.Duration(true); return; } // Get style of the current word to highlight only word with same style. int selectedStyle = wCurrent.Call(SCI_GETSTYLEAT, selStart); // Manage word with DBCS. wordToFind = EncodeString(wordToFind); // Case sensitive & whole word only. wCurrent.Call(SCI_SETSEARCHFLAGS, SCFIND_MATCHCASE | SCFIND_WHOLEWORD); wCurrent.Call(SCI_SETTARGETSTART, 0); wCurrent.Call(SCI_SETTARGETEND, lenDoc); // Find the first occurrence of word. int indexOf = wCurrent.CallString(SCI_SEARCHINTARGET, wordToFind.length(), wordToFind.c_str()); while (indexOf != -1 && indexOf < lenDoc) { if (!currentWordHighlight.isOnlyWithSameStyle || selectedStyle == wCurrent.Call(SCI_GETSTYLEAT, indexOf)) { wCurrent.Call(SCI_INDICATORFILLRANGE, indexOf, wordToFind.length()); } // Try to find next occurrence of word. wCurrent.Call(SCI_SETTARGETSTART, indexOf + wordToFind.length() + 1); wCurrent.Call(SCI_SETTARGETEND, lenDoc); indexOf = wCurrent.CallString(SCI_SEARCHINTARGET, wordToFind.length(), wordToFind.c_str()); } }