It is currently Fri May 24, 2013 4:50 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: IDE Select & Highlight
PostPosted: Wed May 16, 2012 12:52 am 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 13, 2007 12:42 pm
Posts: 1307
Location: Manchester, UK
One of the things that I use in Scintilla based programs (either Scite or Notepad++) is the ability to highlight the same word - highly useful when coming to refactoring your variable names.

In Scite, I uncomment:
Code:
highlight.current.word=1
highlight.current.word.by.style=1
highlight.current.word.colour=#00D040


Could this be added to the IDE? Or is it available and I've missed it?


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Wed May 16, 2012 2:56 am 
Offline
Addict
Addict
User avatar

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 2704
+1

I love this feature in Notepad++.

_________________
Image


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Wed May 16, 2012 7:02 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 578
Location: germany
+1

http://www.purebasic.fr/english/viewtopic.php?f=3&t=48193

Kukulkan

_________________
When somebody says "Expect the unexpected" slap them in the face and say" You didn’t expect that, did you?"


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Wed May 16, 2012 11:27 am 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 13, 2007 12:42 pm
Posts: 1307
Location: Manchester, UK
My apologies for creating a new thread - I had done a search, but I hadn't searched hard enough. :oops:


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Wed May 16, 2012 5:23 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 794
...and my request predates the previous link by about a year:
http://www.purebasic.fr/english/viewtop ... ht#p340278


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 12:27 am 
Offline
User
User

Joined: Wed Jun 21, 2006 11:09 am
Posts: 16
Count my vote for this too!
Never understood why so many useful features of Scintilla have been disabled in Purebasic IDE.


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 12:44 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 794
ssb wrote:
Count my vote for this too!
Never understood why so many useful features of Scintilla have been disabled in Purebasic IDE.


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.


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 1:14 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Jul 09, 2011 7:57 am
Posts: 276
from scite

Code:

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 != -&& 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());
    }
}
 

_________________
http://www.mediafire.com/pbstuff


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 5:26 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 794
I have seen that in the source, but can't for the life of me find the setting to turn it on! (I like NP++ and PN enough that I don't really use Scite.)

I have seen other very similar routines, and when you have a large file open, they are very laggy since it updates the entire document each time. As it is, using Gosci, it is already more than four times as slow as Notepad++, and I have slimmed Gosci down quite a bit, too. I don't know if it is the better compiler optimization, or just the lighter weight "generic" lexer, but with the PB compiled version taking so much longer I wouldn't want to run that search & style through with every highlight on large files.

For reference, I duplicated a file until it was just over 200k lines. Notepad++ styled it in under 5 seconds (the entire doc) and using PB and Gosci (compiled to exe), it took over 25. Sure, that is a very long file, but 10,000 lines is very normal, and that is still about 1.5 seconds, compared to less than 1/2 second for NP++.


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 2:58 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Jul 09, 2011 7:57 am
Posts: 276
notepad++ only do the highlighting on the visible part of the text.

http://notepad-plus.svn.sourceforge.net ... iew=markup

line 78

_________________
http://www.mediafire.com/pbstuff


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 3:10 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 2401
Location: Utah, USA
Tenaja wrote:
...and my request predates the previous link by about a year:
viewtopic.php?f=3&t=44489&p=340278&hilit=highlight#p340278

And yours is predated by this one by eight months. :mrgreen:

_________________
Image


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 4:04 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 794
Demivec wrote:
Tenaja wrote:
...and my request predates the previous link by about a year:
http://www.purebasic.fr/english/viewtop ... ht#p340278

And yours is predated by this one by eight months. :mrgreen:

Wow, so oft requested...


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 4:05 pm 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1566
Location: Germany
I can't +1 this feature request enough as it's very useful! +1


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 4:31 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 794
xorc1zt wrote:
from scite

Code:

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 != -&& 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());
    }
}
 


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:
change:
#highlight.current.word=1
to:
highlight.current.word=1

So apparently Scite's biggest drawback is the lack of dialog boxes for changing properties. You also have to edit properties files to save the "recent file" list, and a whole bunch of other features people would expect. I haven't figure out how to get the PB syntax to work, though, even adding it to the list and all the other stuff that would seem necessary.


Top
 Profile  
 
 Post subject: Re: IDE Select & Highlight
PostPosted: Thu May 17, 2012 5:52 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Jul 09, 2011 7:57 am
Posts: 276
did you read the first post ? :D

_________________
http://www.mediafire.com/pbstuff


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye