Skip to content

Conversation

@rickycodes
Copy link
Contributor

@rickycodes rickycodes commented Jul 13, 2017

closes: #265

First stab at creating a right-click context menu...

right-click-copy

/cc @leo

@timothyis timothyis added the 👩‍🔬 Status: In Progress Issue or PR is currently active and work is in progress label Jul 13, 2017
@rickycodes rickycodes changed the title Add context menu (WIP) Add context menu Jul 14, 2017
@timothyis timothyis removed the 👩‍🔬 Status: In Progress Issue or PR is currently active and work is in progress label Jul 14, 2017
@timothyis timothyis requested a review from chabou July 14, 2017 17:52
@rickycodes
Copy link
Contributor Author

rickycodes commented Jul 15, 2017

Looking at the original issue, I saw #265 (comment) and decided to add two items to the context menu:

  • 'Open Selection as URL'
  • 'Search the Web for Selection'

selectionMenu

/cc @codetheory

@rickycodes rickycodes force-pushed the issue-265 branch 2 times, most recently from c91943e to 34b4738 Compare July 15, 2017 14:18
@timothyis timothyis requested a review from matheuss July 15, 2017 15:10
@timothyis
Copy link
Contributor

This is incredible! Can't wait to have this in! 🎉
cc @matheuss @rauchg @chabou @ppot

@rickycodes
Copy link
Contributor Author

rickycodes commented Jul 15, 2017

I ended up just using .concat to add the two new items to the end of the menu since splice is problematic (modifies the original) 😓

screenshot for context:
screen shot 2017-07-15 at 12 43 00 pm

@Stanzilla
Copy link
Contributor

This does and will clash with

// if true, on right click selected text will be copied or pasted if no
    // selection is present (true by default on Windows)
    quickEdit: true,

so I guess having it enabled should disable the menu or the other way round

@Stanzilla
Copy link
Contributor

Stanzilla commented Jul 16, 2017

Same with

    // set to `true` (without backticks) if you're using a Linux setup that doesn't show native menus
    // default: `false` on Linux, `true` on Windows (ignored on macOS)
    showHamburgerMenu: '',

in the case of Windows or true the right click menu should probably adjust itself to not duplicate items with the hamburger menu

clear buffer command works but is still bugged on Windows (#1808 (comment))
cut undo select all and redo do not work. nothing happens.

@rickycodes
Copy link
Contributor Author

cut undo select all and redo do not work. nothing happens.

do these items behave as expected or differently when using the main menus? (I haven't really been able to get them to work in either case), they should perform the same as the other menus (since they're just duplicated from there)

re: windows settings, I will tweak what I have to make sure there's no conflicts (and test a bit in windows) to see what makes the most sense.

/cc @Stanzilla

@Stanzilla
Copy link
Contributor

Yeah, they don't work from the main menu either. Do they work on any OS?

enabled: !isCollapsed
},
{
label: 'Search the Web for Selection',
Copy link
Contributor

Choose a reason for hiding this comment

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

Search with Google is more specific and consistent with other context menus ✌️

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there anyway to open a link with the users default search engine? That would be awesome.
Default search engine probably would come from the default browser > default search engine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could leave it as Google by default and make it configurable via .hyper.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

both terminal and iTerm2 have Search with Google

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I'd like that. I know a few people who'd like not to use Google.

Copy link
Contributor

Choose a reason for hiding this comment

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

With Mac OS services you should be able to search with default browser and engine but most likely unusable since Hyper also supports other operative systems ✌️

Copy link
Contributor Author

@rickycodes rickycodes Jul 17, 2017

Choose a reason for hiding this comment

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

in b3a9d30 I've made this configurable via exposing a new key/value (searchEngineUrl) from config so this can be customized via .hyper.js

defaults to google, but can be anything the user desires.

this would likely need to be addressed in app/config/config-default.js as well (similar to bellSoundURL)

I left the wording as is.

/cc @henrikdahl @codetheory

@rickycodes
Copy link
Contributor Author

rickycodes commented Jul 16, 2017

Yeah, they don't work from the main menu either. Do they work on any OS?

this is a good question, I'm not sure under what circumstances they are designed to work... the main thing is that this is not a regression on my part 😉

@rickycodes rickycodes force-pushed the issue-265 branch 2 times, most recently from b3a9d30 to 70f4aec Compare July 18, 2017 18:53
@rickycodes
Copy link
Contributor Author

I nixed the url/google functionality (as I think that should be handled in a different PR, or possibly a plugin?)

@Stanzilla this should account for the items you mentioned quickEdit and showHamburgerMenu. let me know if this makes sense

/cc @codetheory

@Stanzilla
Copy link
Contributor

showHamburgerMenu is a bit problematic, the default is '' which is sort of auto, that means it is actually true on Windows even if it is not set to true in the config. That is a problem because a Windows user can't set it to falsewhen he would prefer using your context menu over the hamburger and also makes you checking for it kinda useless since it will never be false on Windows.

My concern was to not duplicate menu entries when both hamburger and context are enabled but since you removed the URL/Google option it's 100% the same anyway, no?

@rickycodes
Copy link
Contributor Author

rickycodes commented Jul 22, 2017

@Stanzilla what do you think makes the most sense in your opinion? should I just drop the showHamburgerMenu check? I'm not entirely sure what makes the most sense for this as I am not a windows user

maybe I'll fire up a windows VM and see 👁️

@Stanzilla
Copy link
Contributor

I'd drop the check, yeah. Makes the most sense to me.

@rickycodes
Copy link
Contributor Author

@Stanzilla I dropped that showHamburgerMenu

lmk if this makes sense

@ppot
Copy link
Contributor

ppot commented Aug 2, 2017

@rickycodes Are you binding the menu context with keymaps?

@rickycodes
Copy link
Contributor Author

rickycodes commented Aug 2, 2017

@ppot I'm just building the context menu from what already exists (combining edit + shell .submenu's here: https://github.com/zeit/hyper/pull/2001/files#diff-ac33cd5e16269e3f364363f9865b9ff5R24)

so yea, they have the same role/accelerator properties, if that's what you mean?

@rickycodes
Copy link
Contributor Author

rickycodes commented Oct 13, 2017

@chabou this has now been rebased over zeit:canary and is now targeting it

I had to make a couple adjustments to accommodate the new changes

lmk what you think

const contextMenuTemplate = createWindow => {
return editMenu(commands).submenu.concat({type: 'separator'}, shellMenu(commands, createWindow).submenu);
};

Copy link
Contributor Author

@rickycodes rickycodes Oct 14, 2017

Choose a reason for hiding this comment

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

maybe an alternative to this:

const contextMenuTemplate = createWindow => {
  const shell = shellMenu(commands, createWindow).submenu
  const edit = editMenu(commands).submenu
  return edit.concat({type: 'separator'}, shell);
};

@rickycodes
Copy link
Contributor Author

rickycodes commented Oct 20, 2017

@chabou have you had a chance to look at this? I've actually made some refinements, and have an example where the menu changes/updates based on selection... in this version I've made it so cut and copy are only available if text is selected... text selection also expands two new options: Open Selection as URL and Search the Web for Selection:

hyper

you can compare the changes here: rickycodes/hyper@rickycodes:issue-265...add-context-menu

lmk what you think!

Copy link
Contributor

@chabou chabou left a comment

Choose a reason for hiding this comment

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

Please remove all right click mentions

}

componentDidMount() {
window.addEventListener('contextmenu', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know/see there was this event.
In this case, please remove any mention of right click notion. We should only speak about context menu.

@chabou
Copy link
Contributor

chabou commented Oct 29, 2017

I love the idea to pass selection in redux action.
Please make it happen 🙏

@rickycodes
Copy link
Contributor Author

@chabou I've made the requested changes

@chabou
Copy link
Contributor

chabou commented Oct 30, 2017

I have a problem with selection with your PR.
When I right click to show contextMenu at a point "P", when I discard contextMenu, xterm is on SelectionMode starting on this point "P" (but I haven't any mouse button pressed).
See:
contextmenu

@chabou
Copy link
Contributor

chabou commented Oct 30, 2017

Can you remove "Open Selection as URL" and "Search the webfor Selection"? I don't think it should be a core feature. But it is perfect to filter Copy/Cut in contextMenu depending on selection presence.

@rickycodes
Copy link
Contributor Author

@chabou I've removed the extended menu with the additional options. I noticed canary has the ability to click on URLs anyway, so maybe Open Selection as URL isn't so useful now

we can discuss creating plugins to accomplish those items once this lands/how to expand on this so plugin authors can modify the context menu

@Stanzilla
Copy link
Contributor

The CircleCI failure looks unrelated.

@rickycodes
Copy link
Contributor Author

@Stanzilla yea i noticed that, but it seems unrelated (the build was passing earlier and I haven't made any adjustments that would have changed that)

@chabou
Copy link
Contributor

chabou commented Nov 3, 2017

I can't reproduce #2001 (comment) anymore 🤔

Let's merge this. We'll fix bugs if needed: not a big deal.

@chabou
Copy link
Contributor

chabou commented Nov 3, 2017

@rickycodes I can't push to your branch. Did you allow maintainers to modify your branch?
I resolved conflicts (in GitHub interface) and Github doesn't see my last commit 😞.
Can you push a empty commit to trigger it ?

@rauchg
Copy link
Member

rauchg commented Nov 3, 2017

This feature is 🔥

@chabou chabou merged commit 62e29ef into vercel:canary Nov 3, 2017
@chabou
Copy link
Contributor

chabou commented Nov 3, 2017

Thank you so much for your help and your awesome work 🙏
Really sorry for the multiple delays along this PR.

@rickycodes rickycodes deleted the issue-265 branch January 20, 2018 06:23
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.

Add context menu

9 participants