[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: Re: using ktexteditor as a base for a disassembly viewer
From: Dominik Haumann <dhaumann () kde ! org>
Date: 2020-12-11 21:26:40
Message-ID: CALi_srBUN9cqh4JynPYBEt_QQuVwisJOMWvBZmf2KU0j3YxQLQ () mail ! gmail ! com
[Download RAW message or body]
I also believe that using KSyntaxHighlighting directly is the best approach
with custom delegate. This way you'll also get the Background colors you
want etc.
Best regards
Dominik
Christoph Cullmann <christoph@cullmann.io> schrieb am Fr., 11. Dez. 2020,
20:25:
> On 2020-12-11 20:19, Milian Wolff wrote:
> > On Freitag, 11. Dezember 2020 16:52:25 CET Sven Brauch wrote:
> >> Hi,
> >>
> >> > PS: How would one even use KSyntaxHighlighting for rendering into a
> >> > QAbstractItemView? That also sounds somewhat nasty hmmm
> >>
> >> That doesn't sound too complicated, or maybe I'm mistaken? For one of
> >> my
> >> applications, I needed HTML rendering once, which I implemented by
> >> creating
> >> a delegate holding a QTextDocument. The delegate just sets the text on
> >> the
> >> document and then draws its contents. The same should work when you
> >> set a
> >> highlighter. Like this (sorry, not the cleanest code, it's already a
> >> few
> >> years old): http://pastie.org/p/6yTw8HZl47KcgvrjSBaDG8
> >
> > Yes, that's obviously an easy approach to take, and for the amount of
> > data I'm
> > expecting should probably work out fine. But note that this approach
> > requires
> > a re-layouting for every paint. A better approach would store the
> > layout (i.e.
> > the text document) per item somehow. Maybe I can just put that into the
> > model
> > itself, next to the highlighting...
> >
> > Anyhow, probably premature optimization, and a KISS approach should
> > work out
> > fine for now.
> >
> >> Otherwise, I'm not sure either. I personally think it will be easier
> >> if you
> >> just use a QTableView, unless you need column-wise text selection. I
> >> think
> >> you could hook everything you need into KTextEditor as well (by e.g.
> >> setting custom context menus depending on the column that was clicked
> >> etc)
> >> but it will require more lines of hacks than you would otherwise need
> >> to
> >> re-create the needed functionality yourself ;) Some applications use
> >> the
> >> text editor for a lot of stuff, maybe that can serve you as
> >> inspiration --
> >> e.g. sublime text comes to mind, which presents its search results
> >> (and
> >> probably other things) as an interactive text document.
> >
> > Right, that could work. But it would let the disassembly view stand out
> > a lot
> > from the other hotspot views.
> >
> > Thank you, unless someone else chimes in with an awesome idea, I really
> > think
> > that we'll have to try the KSyntaxHighlighter + custom delegate
> > approach.
>
> I guess that is the most pragmatic way to go.
>
> Greetings
> Christoph
>
> --
> Ignorance is bliss...
> https://cullmann.io | https://kate-editor.org
>
[Attachment #3 (text/html)]
<div dir="auto"><div>I also believe that using KSyntaxHighlighting directly is the \
best approach with custom delegate. This way you'll also get the Background \
colors you want etc.</div><div dir="auto"><br></div><div dir="auto">Best \
regards</div><div dir="auto">Dominik<br><br><div class="gmail_quote" dir="auto"><div \
dir="ltr" class="gmail_attr">Christoph Cullmann <<a \
href="mailto:christoph@cullmann.io">christoph@cullmann.io</a>> schrieb am Fr., 11. \
Dez. 2020, 20:25:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">On 2020-12-11 20:19, Milian Wolff \
wrote:<br> > On Freitag, 11. Dezember 2020 16:52:25 CET Sven Brauch wrote:<br>
>> Hi,<br>
>> <br>
>> > PS: How would one even use KSyntaxHighlighting for rendering into a<br>
>> > QAbstractItemView? That also sounds somewhat nasty hmmm<br>
>> <br>
>> That doesn't sound too complicated, or maybe I'm mistaken? For one \
of <br> >> my<br>
>> applications, I needed HTML rendering once, which I implemented by <br>
>> creating<br>
>> a delegate holding a QTextDocument. The delegate just sets the text on <br>
>> the<br>
>> document and then draws its contents. The same should work when you <br>
>> set a<br>
>> highlighter. Like this (sorry, not the cleanest code, it's already a \
<br> >> few<br>
>> years old): <a href="http://pastie.org/p/6yTw8HZl47KcgvrjSBaDG8" \
rel="noreferrer noreferrer" \
target="_blank">http://pastie.org/p/6yTw8HZl47KcgvrjSBaDG8</a><br> > <br>
> Yes, that's obviously an easy approach to take, and for the amount of <br>
> data I'm<br>
> expecting should probably work out fine. But note that this approach <br>
> requires<br>
> a re-layouting for every paint. A better approach would store the <br>
> layout (i.e.<br>
> the text document) per item somehow. Maybe I can just put that into the <br>
> model<br>
> itself, next to the highlighting...<br>
> <br>
> Anyhow, probably premature optimization, and a KISS approach should <br>
> work out<br>
> fine for now.<br>
> <br>
>> Otherwise, I'm not sure either. I personally think it will be easier \
<br> >> if you<br>
>> just use a QTableView, unless you need column-wise text selection. I <br>
>> think<br>
>> you could hook everything you need into KTextEditor as well (by e.g.<br>
>> setting custom context menus depending on the column that was clicked <br>
>> etc)<br>
>> but it will require more lines of hacks than you would otherwise need <br>
>> to<br>
>> re-create the needed functionality yourself ;) Some applications use <br>
>> the<br>
>> text editor for a lot of stuff, maybe that can serve you as <br>
>> inspiration --<br>
>> e.g. sublime text comes to mind, which presents its search results <br>
>> (and<br>
>> probably other things) as an interactive text document.<br>
> <br>
> Right, that could work. But it would let the disassembly view stand out <br>
> a lot<br>
> from the other hotspot views.<br>
> <br>
> Thank you, unless someone else chimes in with an awesome idea, I really <br>
> think<br>
> that we'll have to try the KSyntaxHighlighter + custom delegate <br>
> approach.<br>
<br>
I guess that is the most pragmatic way to go.<br>
<br>
Greetings<br>
Christoph<br>
<br>
-- <br>
Ignorance is bliss...<br>
<a href="https://cullmann.io" rel="noreferrer noreferrer" \
target="_blank">https://cullmann.io</a> | <a href="https://kate-editor.org" \
rel="noreferrer noreferrer" target="_blank">https://kate-editor.org</a><br> \
</blockquote></div></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic