Re: Syntax-Highlighter questions
On Thu, Aug 20, 2020 at 8:21 PM Kåre Särs wrote: > > So the thing is that the text document does not get notified that it needs a > redraw... how is just adding a 'onDefinitionNameChanged: textArea.append("")' > > I tried it and it works, but is that too ugly? > Hi Kåre, thanks for your response. It was an inspiring suggestion: OK I was looking for something that the library does for all consumers. So I looked into QTextDocument but I found nothing that looked suitable for a forced redraw. So I remembered: My code does nothing with the document but passing it to SyntaxHighlighter on creation. That lead me to the (brute force) solution: Every time a new definition or theme is set, the highlighter is destroyed and a new one is created [1]. Maybe ugly from performance point of view but works fine. [1] https://github.com/schnitzeltony/ksyntax-highlighting-wrapper/commit/d556eece45dc65aada51d7c7925a13866188ba22 Thanks again, Andreas
Re: Syntax-Highlighter questions
Hi, On torsdag 20 augusti 2020 kl. 01:02:36 EEST Andreas Müller wrote: > Hi, > > a while back I needed syntax-highlighting in a QML based application. > Since I could not find some QML support for syntax-highlighter, I > wrote a wrapper library [1]. That worked perfectly fine but now that I > wrote an example (screenshot in [1]) unexpected behaviour pops up. The > example is different because it can set highlighter's definition and > theme during runtime which were set once statically in the initial > application. > > Now my issue/question: > Highlight definition: Although SyntaxHighlighter::setDefinition calls > rehighlight(), the content of the text field remains unchanged. By > changing the size of the window, the new highlighting is drawn. Do you > have any suggestions what can be done to fix that? > > Hoping for cure :) and thanks in advance, So the thing is that the text document does not get notified that it needs a redraw... how is just adding a 'onDefinitionNameChanged: textArea.append("")' I tried it and it works, but is that too ugly? Nice wrapper tho... :) /Kåre > > Andreas > > > [1] https://github.com/schnitzeltony/ksyntax-highlighting-wrapper
Syntax-Highlighter questions
Hi, a while back I needed syntax-highlighting in a QML based application. Since I could not find some QML support for syntax-highlighter, I wrote a wrapper library [1]. That worked perfectly fine but now that I wrote an example (screenshot in [1]) unexpected behaviour pops up. The example is different because it can set highlighter's definition and theme during runtime which were set once statically in the initial application. Now my issue/question: Highlight definition: Although SyntaxHighlighter::setDefinition calls rehighlight(), the content of the text field remains unchanged. By changing the size of the window, the new highlighting is drawn. Do you have any suggestions what can be done to fix that? Hoping for cure :) and thanks in advance, Andreas [1] https://github.com/schnitzeltony/ksyntax-highlighting-wrapper