Git Product home page Git Product logo

Comments (6)

jacobslusser avatar jacobslusser commented on August 28, 2024

I agree this is a bit unusual. I opened a ticket with the native Scintilla team. You can follow the progress here: https://sourceforge.net/p/scintilla/bugs/1736/.

from scintillanet.

dspwhite avatar dspwhite commented on August 28, 2024

Thanks. It's strange that Notepad++ doesn't have the same problem...

from scintillanet.

jacobslusser avatar jacobslusser commented on August 28, 2024

I don't know why this didn't occur to me earlier, but your comment about Notepad++ caused me to realize I was answering the question you asked, but not the question you meant to ask. You're assuming Notepad++ doesn't have this problem and I would guess that you came to that conclusion because you've used the Find dialog in Notepad++ to highlight a word or words like your application does and don't see the same behavior. You may not know, however, that when Notepad++ highlights a word it isn't using Styles to do that, it's using Indicators. If the goal of your program is to highlight regex matches it should also be using Indicators to do that.

A brief explanation of Indicators can be found in the wiki article Find and Highlight Words but I threw together a quick sample for you below as well.

scintilla.Text = "\"The quick brown fox jumps over a lazy dog\" is an English-language pangram—a phrase that contains all of the letters of the alphabet. It is commonly used for touch-typing practice. It is also used to test typewriters and computer keyboards, show fonts, and other applications involving all of the letters in the English alphabet. Owing to its brevity and coherence, it has become widely known.\r\n";
scintilla.WrapMode = WrapMode.Word;

scintilla.Indicators[8].Under = true;
scintilla.Indicators[8].Style = IndicatorStyle.StraightBox;
scintilla.Indicators[8].ForeColor = Color.LightGreen;
scintilla.Indicators[8].OutlineAlpha = 255;
scintilla.Indicators[8].Alpha = 255;

scintilla.IndicatorCurrent = 8;
foreach (var line in scintilla.Lines)
{
    var text = line.Text;
    var pos = line.Position;

    foreach (Match match in Regex.Matches(text, @"known\.\r\n"))
        scintilla.IndicatorFillRange(pos + match.Index, match.Length);
}

Using this approach there is no issue with wrapped lines.

from scintillanet.

dspwhite avatar dspwhite commented on August 28, 2024

Great. I've converted the program to use indicators instead. I don't think it's faster now, though it fixes the reason behind this thread.

I initially tried indicators days ago, though missed the useful Under property which means the highlighting isn't partially obscuring the text it's trying to highlight. Perhaps you could put scintilla.Indicators[NUM].Under = true; into the example at: https://github.com/jacobslusser/ScintillaNET/wiki/Find-and-Highlight-Words

Thanks again for the help!

from scintillanet.

jacobslusser avatar jacobslusser commented on August 28, 2024

BTW, the native Scintilla team responded to my bug ticket by essentially saying, "yes this is probably not the desired behavior, but the priority on fixing it is low".

Since you got Indicators working, and I think they're a better solution, and the native Scintilla team doesn't seem in a hurry to fix this, I'm going to close this issue.

from scintillanet.

dspwhite avatar dspwhite commented on August 28, 2024

Thanks. Let me know if they ever fix it. One advantage over Indicators is that a small bit at the start of new lines are highlighted, which is nice if you're trying to search for newlines. No hurry though.

from scintillanet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.