Re: using ktexteditor as a base for a disassembly viewer

Milian Wolff <[email protected]>
Newsgroups gmane.comp.kde.devel.kwrite
Message-ID <3379160.5nVr8omUUM@milian-workstation>
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.

Cheers

> On 12/11/20 3:46 PM, Milian Wolff wrote:
> > Hey all,
> > 
> > I'm wondering what to use for hotspot to show a disassembly view.
> > Basically
> > this view consists of multiple columns:
> > 
> > - address
> > - instructions
> > - costs (cycles, instructions, branch misses, whatever...)
> > 
> > Initially I thought: Let's use a read-only ktexteditor part for this, as
> > it
> > will get us highlighting and copy'n'paste features for free. But we'd have
> > to put the costs into ktexteditor annotations then, I guess?
> > 
> > So I'm not so sure whether that's a good fit after all: While we get some
> > features for free, we lose others, such as reordering of columns and
> > selection of more.
> > 
> > What would you use to build something like this:
> > https://docs.wasmtime.dev/assets/perf-annotate-fib.png
> > 
> > Ideally, we would even eventually get the ability to show the source code
> > too, like here:
> > https://chrisdietri.ch/img/perf-report-annotate2.png
> > 
> > But I have to say that instead of the mixed view above, I much prefer
> > godbolt's view: https://danlarkorg.files.wordpress.com/
> > 2020/10/2020-10-04-223128_947x626_scrot.png?w=947
> > 
> > So, any input and suggestions would be welcome on how to tackle this.


-- 
Milian Wolff
[email protected]
http://milianw.de
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEezawi1aUvUGg3A1+8zYW/HGdOX8FAl/Txl8ACgkQ8zYW/HGd
OX+oMhAAw1bf4pSfKEK7DIx/CKpGIWLCc++2heeM3VnwzjwT07M2j1QeJ67Q682n
yIzh9Amm0/Mu/f+rm5y387bpo64REg9jSY8XJuZxcX2KNW80j1CRxYqWWRt70RRA
cKB/98BeF/Kry2jaD+gM+bi6lu+xBApwdCIejz+CbwbysZcFNNN0A1Brb7hqnf0m
sYu64QKYwLxAICL3awR72xRB6dUzXEpSCngfUUSmooJqRF9T1356GByD9ukqhC6W
LqvTsa2tNU+p7HG6OhQvB6AhpAGGtAyoZ2tw+nEMnFc6VYUPJpVlrDFAdIywQvEl
+XSYqLTFhq0KwRWOU3eNZkRxDWg38rtpdIzNDR99Dhq70XgLKZua5YUN7SmWQG42
EJb4absNi1OJuPIprapSMu2FpAbIpo+YH0UqRRrBLOdm3QTsCnwxAoP9SEaftEkC
wBBevL9JMCkj6T4dOislNBkZMg2V/NnFoQqlnqtUoWFTBlzTwjsF9tesi1n8ny5e
q3V/pmXS6qnSan1beeFQxGNA1llTUOcLyAMmAcelCerSMZ8tinubPMUyI0aVUu4j
c7PAX7XF+S788vtFndFjeaA2z+t+gWaDwXfvRPLqSPiPL5NhR+8sBsSBjyxg6PBT
kHoF4gVa/yKWnUKVUEBqvw+gmFe0I3aGBBs66HNpO4mt3tL6s7g=
=H72G
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.