[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&#39;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 &lt;<a \
href="mailto:christoph@cullmann.io">christoph@cullmann.io</a>&gt; 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> &gt; On Freitag, 11. Dezember 2020 16:52:25 CET Sven Brauch wrote:<br>
&gt;&gt; Hi,<br>
&gt;&gt; <br>
&gt;&gt; &gt; PS: How would one even use KSyntaxHighlighting for rendering into a<br>
&gt;&gt; &gt; QAbstractItemView? That also sounds somewhat nasty hmmm<br>
&gt;&gt; <br>
&gt;&gt; That doesn&#39;t sound too complicated, or maybe I&#39;m mistaken? For one \
of <br> &gt;&gt; my<br>
&gt;&gt; applications, I needed HTML rendering once, which I implemented by <br>
&gt;&gt; creating<br>
&gt;&gt; a delegate holding a QTextDocument. The delegate just sets the text on <br>
&gt;&gt; the<br>
&gt;&gt; document and then draws its contents. The same should work when you <br>
&gt;&gt; set a<br>
&gt;&gt; highlighter. Like this (sorry, not the cleanest code, it&#39;s already a \
<br> &gt;&gt; few<br>
&gt;&gt; years old): <a href="http://pastie.org/p/6yTw8HZl47KcgvrjSBaDG8" \
rel="noreferrer noreferrer" \
target="_blank">http://pastie.org/p/6yTw8HZl47KcgvrjSBaDG8</a><br> &gt; <br>
&gt; Yes, that&#39;s obviously an easy approach to take, and for the amount of <br>
&gt; data I&#39;m<br>
&gt; expecting should probably work out fine. But note that this approach <br>
&gt; requires<br>
&gt; a re-layouting for every paint. A better approach would store the <br>
&gt; layout (i.e.<br>
&gt; the text document) per item somehow. Maybe I can just put that into the <br>
&gt; model<br>
&gt; itself, next to the highlighting...<br>
&gt; <br>
&gt; Anyhow, probably premature optimization, and a KISS approach should <br>
&gt; work out<br>
&gt; fine for now.<br>
&gt; <br>
&gt;&gt; Otherwise, I&#39;m not sure either. I personally think it will be easier \
<br> &gt;&gt; if you<br>
&gt;&gt; just use a QTableView, unless you need column-wise text selection. I <br>
&gt;&gt; think<br>
&gt;&gt; you could hook everything you need into KTextEditor as well (by e.g.<br>
&gt;&gt; setting custom context menus depending on the column that was clicked <br>
&gt;&gt; etc)<br>
&gt;&gt; but it will require more lines of hacks than you would otherwise need <br>
&gt;&gt; to<br>
&gt;&gt; re-create the needed functionality yourself ;) Some applications use <br>
&gt;&gt; the<br>
&gt;&gt; text editor for a lot of stuff, maybe that can serve you as <br>
&gt;&gt; inspiration --<br>
&gt;&gt; e.g. sublime text comes to mind, which presents its search results <br>
&gt;&gt; (and<br>
&gt;&gt; probably other things) as an interactive text document.<br>
&gt; <br>
&gt; Right, that could work. But it would let the disassembly view stand out <br>
&gt; a lot<br>
&gt; from the other hotspot views.<br>
&gt; <br>
&gt; Thank you, unless someone else chimes in with an awesome idea, I really <br>
&gt; think<br>
&gt; that we&#39;ll have to try the KSyntaxHighlighter + custom delegate <br>
&gt; 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