Recent

Author Topic: Copy (clipboard) an Watches/Locals (e.g. for printing)  (Read 551 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9865
  • Debugger - SynEdit - and more
    • wiki
Copy (clipboard) an Watches/Locals (e.g. for printing)
« on: April 17, 2023, 02:29:22 pm »
I had a quick conversation during a recent meeting on the topic. Unfortunately I don't have the contact details. Maybe the person will read this here. Also this may be of interest for others.

The background was that (since the Watches Window does not have "print") values (selected or all) could be copied to clipboard. And then be processed and printed.

Generally a good idea. (and upcoming).
Only there are many ways this can be done. And I don't use it myself in the described manner, so I may not pick the most practical solution(s).

Watches (values displayed) can be formatted in many ways.
- Single line vs multi line (e.g. structures and arrays)
- quoted (pascal), or raw for strings (the latter can be multiline)

Further more, if entire entries are copied (rather than a single value), then you need to put "Name", "Data-Address" (other future metadata), "Value" into some format.
E.g.
Code: Text  [Select][+][-]
  1. a=1
  2. b=2
  3. c='foo'

Which works only for single line data. But Single line data is harder to read.

For human consumption, you could do above, with line breaks (and maybe indent), and then leave it to the reader to figure out start/stop and indent vs value.
E.g. Indenting a structure gives a clear indication what is a continuation line. But indenting the 2nd line of a multi line string can be more tricky, as you need to check the exact amount of spaces to distinguish indent from leading space (for a non-quoted string).

And an "=" as separator, is not sufficient if "Data-Address" (etc) is added to the line(s).


Another idea is to embed the copied data into simple html. Thus the table structure would be preserved.

I know I might be overthinking this. And I will start with something simple (and feedback received here, may then be added at some time sooner or later / or some may not be added).
But getting some different views and opinions might uncover some common needs.


Also, there is room for interpretation what  "copy all" could mean, if you have an array and expanded the view (the + tree button).

You have the entry for the entire array => wich will have either the entire array (but if entries are structures, then at lower detail level), or even only have the first n entries, if the array has thousands of entries (the default is only the first 512 / and then more can be viewed using the expanded view).
Then there are the entries in the expanded views. But that is paged, so those are limited in count. The IDE caches a few pages, but if you went through too many then some aren't in the cache. And then you may not want to copy 10k+ lines?

So  "copy all" would likely have the "main entry" with up to 512 low detail values. And the current visible page (if expanded) with by default 10 entries.

This default is all, but not very smart. But as I said, without use case of my own, and without knowing more details of other peoples use cases => it is tricky to decide what really is smart.





On the idea of printing => This would be simply an extension of having a formatted export (I.e. an html to clipboard could likely also be sent to a printer).

That is, if that is really needed.
For that, I would need to be certain of the reasons that there may be to want a print out.

I would expect this to be temporary (since the goal is to fix a bug, and once fixed....). So likely a print out would be, If you need to continue later. Or if you want to send a snapshot to a co-worker?

And here there may be a better - however unknown - solution.

The IDE keeps a history of watches/locals/stacks/threads taken at each step/breakpoint. By default last 30 entries, but using the history window, and the "add snapshot button, entries of interest can be kept longer (until the debug session ends, and the next is started).

Those snapshot can be saved/exported. So a co-worker would get entire callstacks with all the data you saw. And they could navigate to the source.

« Last Edit: April 17, 2023, 02:40:36 pm by Martin_fr »

 

TinyPortal © 2005-2018