Change the styling of a text

Help
2011-11-25
2015-06-24
  • Viczian Istvan
    Viczian Istvan
    2011-11-25

    The setStyling doesn't work for me. I open a new editor and the console. I type some text into the editor. Then I type the following into the console:
    editor.styleSetFore(9, (0,0,255))
    editor.startStyling(0, 0xff)
    editor.setStyling(6, 9)

    But nothings happen. The editor.getStyledText returns 0 for styles.

    The following code works fine:

    editor.addStyledText(Cell("Hello in blue\n", ))

     
  • Viczian Istvan
    Viczian Istvan
    2011-11-25

    How can I change the styling of a text?

     
  • You need to set the lexer to the container, otherwise scintilla will ignore the calls for startStyling and so on.

    editor.setLexer(LEXER.CONTAINER)
    

    Cheers,
    Dave.

     
  • Viczian Istvan
    Viczian Istvan
    2011-11-26

    Dear Dave,

    Thank you for your incredible quick answer, it works! This plugin is awesome!

    Istvan

     
  • Sasumner
    Sasumner
    2015-06-24

    I'm definitely new to this Scintilla thing, but I'm wondering if someone knowledgeable can give me a short course on how to do what I want to do, which is basically to programmatically (pythonscript) be able to set (and clear) highlighting sort of like the N++ Search -> "Mark..." or "Mark All" features do.

    I can affect text by following the hints earlier in this thread, but I notice if I switch the active file and then come back to the file that I attempted to change the style on, my styling disappears. I'd like it to persist until I turn it off. There are other oddities I see, but this is the biggest.

    Perhaps general guidance would be best! Thanks for any help in this regard!