Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement text range selection in TextView #30

Open
uxmal opened this issue Aug 21, 2015 · 9 comments
Open

Implement text range selection in TextView #30

uxmal opened this issue Aug 21, 2015 · 9 comments
Assignees
Labels
enhancement This is a feature request

Comments

@uxmal
Copy link
Owner

uxmal commented Aug 21, 2015

Recall that the RichEdit Control was unsuitable for reko, and Windows Forms has no other way of displaying rich text. TextView is a poor man's version of GtkTextView which seems to serve adequately. The problem is that there is no way for users to mark a text selection. This precludes copying snippets of code, which is a fairly reasonable expectation. Today reko cheeses out by providing a "Copy All" verb, but it certainly could be better.

To implement this, TextView needs the usual assortment of Selection range plumbing: where the selection starts (the anchor), where it ends. A TextSpan must be able to perform hit-detection based on an X-coordinate and return the index position within the span that was selected. TextView needs a CurrentSelection that returns a TextSelection object consisting of all the TextSpans, both partially and fully selected. TextSpans, when rendering, must know what portion of them is selected and what is not so that they render colors correctly.

@nemerle
Copy link
Collaborator

nemerle commented Aug 21, 2015

Yup, I think we'll need to spice that control up pretty heavily in the future:

  1. adding tooltips on registers/instructions
  2. visualizing additional data ( points where something was 'assumed' by the user etc. )
  3. Identifying various bit's and pieces of the current shown data

When i was doing my boomerang/exetoc assembly view experiments i did it like this:

  • for each visible assembly instruction/label - produce a simple tree-like structure, embedding various parts in proper tags ( , , , ... )
  • Render the pre-processed tree into colored Qt rich text document and using it's services to identify elements under mouse cursor, so i could show relevant tooltips, context menu's etc.

@uxmal
Copy link
Owner Author

uxmal commented Aug 21, 2015

thats the same approach I'm taking with reko. The drawback is I don't want to add a dependecy on Qt or Gtk. It strikes me, however, that adding tooltips for registers and instructions shouldn't be that bad, it's just that there is no selection visible. Let me mull on this for a while

I'll create a separate issue to track the notion of annotations in the TextView.

@nemerle
Copy link
Collaborator

nemerle commented Aug 21, 2015

Agreed, no need to pull in gtk or qt
As for selection handling, one way of doing it would be to disable selection handling on control itself but add mouse handling by-hand ( handling clicks and mouse moves ), and mark areas as selected programmaticly, although i guess it would be a bit of PITA 😄

@uxmal
Copy link
Owner Author

uxmal commented Aug 21, 2015

Better to make TextView text-selection aware. However, all annotatable things, like registers, instructions, and identifiers, can indicate their annotatedness very easily. The class Reko.Gui.Windows.DisassemblyFormatter could tell TextView about being annotatable. This could be done relatively quickly, I think.

@uxmal uxmal self-assigned this Aug 21, 2015
@nemerle
Copy link
Collaborator

nemerle commented Aug 21, 2015

Yes, I can see that having a proper per-character selection would be helpful when getting assembly out of reko.
I think we'll still need some kind of

List<object> GetObjectsFromCurrentSelection();

that would return the 'root' objects in current selection

@uxmal
Copy link
Owner Author

uxmal commented Aug 21, 2015

Each TextSpan the TextView can be associated with a Tag: an arbitrary object. This tag could be what gets returned from GetSelectedObjects()

@uxmal
Copy link
Owner Author

uxmal commented Sep 10, 2015

I just checked into master the new TextView which allows arbitrary selection of text. Basically, I've implemented a simple rich text editor.... (what this has to do with decompiling is an exercise left to the reader!)

Next step is to provide an API to select the objects embedded in the selected text, so that relevant tool tips and context menus can be displayed.

@xor2003
Copy link
Contributor

xor2003 commented Jul 23, 2016

Maybe you can use http:https://www.scintilla.org/Steps.html as edit control. It is used for example in Notepad++

@uxmal
Copy link
Owner Author

uxmal commented Jul 23, 2016

@xor2003: thanks for the suggestion! However, a fullblown text editor with undo, at this time, is a bit overkill for Reko's needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is a feature request
Projects
None yet
Development

No branches or pull requests

3 participants