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

[DRAFT] Add rectangle select #963

Closed

Conversation

vancluever
Copy link
Collaborator

@vancluever vancluever commented Nov 28, 2023

This adds rectangle select mode; when dragging with ctrl+alt (or super+alt on MacOS), this allows you to select a rectangular region of the terminal instead of the full start-end points of the buffer.

2023-11-28.11-12-13.mp4

@vancluever
Copy link
Collaborator Author

vancluever commented Nov 28, 2023

This is a draft right now but I thought I'd get it in as a proposal 🙂

Things that would need adding still:

  • Tests
  • Reviewing the memory allocation for selectionString (held until new iteration)
  • Changing ctrl to ctrlOrSuper for MacOS support(?)

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea!

Okay the big one is selectionString. I actually have significant changes to this function in my hyperlinks branch ("urls"). My new implementation is a lot simpler and I think will get rid of some of your headaches, I wonder how we should reconcile that.... maybe I should cherry pick it over somehow or make a partial PR before I finish up the hyperlink work.

@vancluever
Copy link
Collaborator Author

I like the idea!

Okay the big one is selectionString. I actually have significant changes to this function in my hyperlinks branch ("urls"). My new implementation is a lot simpler and I think will get rid of some of your headaches, I wonder how we should reconcile that.... maybe I should cherry pick it over somehow or make a partial PR before I finish up the hyperlink work.

Works for me! I'll keep an eye out for that and work on the rest of the feedback in the meantime 🙂

@vancluever vancluever force-pushed the vancluever-rectangle-select branch 8 times, most recently from 800d06e to c9052bf Compare November 29, 2023 06:53
@vancluever
Copy link
Collaborator Author

All done now, will keep in draft until we have that updated selectionString and then I'll port the needed changes here. 🙂

@mitchellh
Copy link
Contributor

I just realized that this doesn't require any renderer changes does it, because we use contains? That's... kind of amazing. Yes I'm hard at work in the urls branch on the hyperlink stuff so hopefully I can have something for you to rebase onto as soon as possible...

@vancluever
Copy link
Collaborator Author

vancluever commented Nov 29, 2023

I just realized that this doesn't require any renderer changes does it, because we use contains? That's... kind of amazing.

That's correct! No changes to the renderer... I almost thought some might be needed cuz when I was doing it initially we were bleeding selection in the upper right/bottom left but that was just due to the fact I forgot some related bounds checks in the contains. 🙂

It's pretty awesome that it worked out to be this straightforward! 🎉

@mitchellh
Copy link
Contributor

Hyperlink PR is #968. Its still quite raw, but that has the selectionString changes.

This adds rectangle select mode; when dragging with ctrl+alt (or
super+alt on MacOS), this allows you to select a rectangular region of
the terminal instead of the full start-end points of the buffer.
@vancluever vancluever force-pushed the vancluever-rectangle-select branch from c9052bf to 7f6db38 Compare November 30, 2023 18:18
@vancluever vancluever changed the base branch from main to urls November 30, 2023 18:18
@vancluever
Copy link
Collaborator Author

vancluever commented Nov 30, 2023

Rebased and things still pass with the same implementation 🙂 I'd imagine the one thing that would have definitely improved now is the fact that we don't have to worry about the memory management of rectangle versus regular since that's calculated after the selection text is fully finalized.

PS: Once urls is in I'll change the base back, just wanted to keep the noise down in the PR.

@mitchellh mitchellh deleted the branch ghostty-org:urls November 30, 2023 20:15
@mitchellh mitchellh closed this Nov 30, 2023
@mitchellh
Copy link
Contributor

Oh lol this closed because the original branch deleted sorry. Can you rebase on main and reopen... however GitHub lets you do that. I can't seem to be able to do it from here.

@vancluever
Copy link
Collaborator Author

Oh lol this closed because the original branch deleted sorry. Can you rebase on main and reopen... however GitHub lets you do that. I can't seem to be able to do it from here.

Weird, surprised the base didn't change! I can't edit the base branch anymore either... will reopen shortly!

@vancluever vancluever mentioned this pull request Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants