-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix text selection from the panes #53
base: main
Are you sure you want to change the base?
Fix text selection from the panes #53
Conversation
src/idd/ui/scrollable_area.py
Outdated
} | ||
""" | ||
|
||
# Terminal-specific selection tips | ||
SELECTION_TIPS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we detect which app we are running and display the relevant tip?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is what is done currently(?)
For the "default" which is the Mac terminal, I haven't figured out the command and I don't think it's possible just with a command, that's why I put a general message for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, sounds good. Do we need to enumerate the shortcuts by hand -- isn't there some api that we can use? I bet there is some way to configure these on the user end...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I unfortunately couldn't find any api... I will definitely keep it in mind for later though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. I have left some comments, please have a look.
src/idd/ui/scrollable_area.py
Outdated
"Terminal.app": "Option(⌥)+Click to select text", | ||
"iTerm2": "Cmd(⌘)+Shift+C: Copy mode | Option(⌥)+Click: Selection", | ||
"Warp": "Shift+Click to select text", | ||
"default": "Use terminal's selection mechanism to copy text" #default mac terminal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"default": "Use terminal's selection mechanism to copy text" #default mac terminal | |
"default": "Use terminal's selection mechanism to copy text (Maybe Shift+Click)" #default mac terminal |
Does this sound better?
src/idd/ui/scrollable_area.py
Outdated
|
||
def on_mouse_up(self, event: events.MouseUp) -> None: | ||
"""Reset click state when mouse button is released.""" | ||
if hasattr(self, '_clicked'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize self._clicked
in __init__
. And remove the hasattr
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
src/idd/ui/scrollable_area.py
Outdated
if hasattr(self, '_clicked'): | ||
self._clicked = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
src/idd/ui/scrollable_area.py
Outdated
terminal = self._get_terminal_type() | ||
tip = self.SELECTION_TIPS.get(terminal, self.SELECTION_TIPS["default"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be part of __init__
. Why recompute this again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks!
src/idd/ui/scrollable_area.py
Outdated
# Only show tip if we've been clicked and haven't shown a tip yet | ||
if hasattr(self, '_clicked') and self._clicked and not self.tip_shown: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's show the tip multiple times. I will need it, I can't remember anything 😄.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vipul-Cariappa I have tried this by setting tip_shown to false again in on_mouse_up function. The other issue I have is about the tip showing multiple times (depending on the pane I scroll+click). So I get multiple tips(one on top of the other) all showing at the same time. This comes from the fact that each pane initialises its own TextScrollView in DiffDebug. How would you go about this ? I have tried using global variables but it still seems to be attached to each instance of TextScrollView. I thought about maybe moving the tip_shown variable to DiffDebug ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not realise you were modifying TextScrollView
. I believe you will have to move all these changes to DiffDebug
. It belongs there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks!
I have even more basic question. Why standard copy and paste does not work? Why they are required to different shortcuts? |
Replying to self: https://textual.textualize.io/FAQ/ apparently the terminal enters in some mode… not sure why that is not the case when you run standard lldb/gdb… |
@vgvassilev Indeed, it seems adding a tip message is the best way right now. The good news is I found how to do it in the Mac terminal. I'll add it too. |
@vgvassilev @Vipul-Cariappa The changes you suggested are implemented. I also display the tip multiple times now. I added the changes to DiffDebug and I added specific commands for vs code and Mac terminals. Vs code config was also about changing the user settings json with this: "terminal.integrated.macOptionClickForcesSelection": true. Not sure if I should add this in the tip ? Afterwards it just works with Opt+click. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice Work!
This PR introduces tips/advice for users when they try selecting text from the panes. Every time a user makes the action of "selection" by clicking and scrolling on text from the panels, a temporary message displays.
The commands for the "selection" action is specific to terminals and this implementation checks for the terminal type to show the appropriate tip.
Addresses issue #44