This is an archive of the discontinued LLVM Phabricator instance.

[lldb/IOHandlerCursesGUI] Make the menu bar clickable
AbandonedPublic

Authored by JDevlieghere on Jun 25 2020, 12:02 AM.

Details

Summary

Add mouse support to the IOHandlerCursesGUI and make it possible to select items in the top menu bar by clicking on them. This patch only makes the top level items clickable and does not (yet) make it possible to click on items in the submenu.

This patch is mostly me being curious about the IOHandlerCursesGUI and trying to understand how it works.

Diff Detail

Event Timeline

JDevlieghere created this revision.Jun 25 2020, 12:02 AM

Being curious is nice, but it would be even nicer if we figured out a way to test all of this stuff. Currently we have some very basic pexpect tests for this, but it's not clear how that will scale to more complex interactions (such as mouse clicking).

My idea for a test strategy (which is looking for someone to implement it) is to write (or resuse an existing -- pyte looks interesting) a simple "terminal emulator" in python. The idea is that this would process the raw escape sequences and produce an in-memory view of what the resulting screen should look like. Then we just connect the pexpect output to this terminal emulator.

This would allow us to write assertions based on that the virtual terminal view, so that we check *what* actually gets printed on the screen, and ignore the exact details about *how* it gets printed. (e.g. self.assertIn("Process (F3)", screen[0])...

(All this assumes that we're able to inject mouse clicks via pexpect, which I haven't checked whether it's possible, but I presume pexpect is low-level enough to be able to do something like that.)

I wrote all this, so feel free to contact me directly with questions! It would be nice to pass the events along to the window or object for the mouse coordinates. See inlined comment and let me know what you think.

lldb/source/Core/IOHandlerCursesGUI.cpp
1085

It might be nice for this to be a bit more generic and be GetWindowForPosition(...). If we are going to enable mouse support, it would be nice to pass the mouse clicks to the windows and let them handle the clicks. Something like:

auto window = GetWindowForPosition(event.x, event.y);
if (window)
  result = window->HandleMouseButtonPressed(event);

The HandleMouseButton will return eKeyHandled if it handled the press. We might also allow other button presses to be passed along for right click and center clicks.
Then menu bars can handle the clicking. We might also want to pass

JDevlieghere abandoned this revision.Aug 4 2020, 4:19 PM