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

Create buttons in the terminal #118

Open
Richienb opened this issue Mar 7, 2020 · 12 comments
Open

Create buttons in the terminal #118

Richienb opened this issue Mar 7, 2020 · 12 comments

Comments

@Richienb
Copy link

Richienb commented Mar 7, 2020

I'm not sure if this is possible: create clickable buttons in the terminal that act in a similar way to links except they trigger a callback.

Support information

@Richienb Richienb changed the title Create buttons in the terminal. Create buttons in the terminal Mar 7, 2020
@brandon93s
Copy link

brandon93s commented Mar 8, 2020

CLUI has decent mouse support:

@Richienb
Copy link
Author

Richienb commented Mar 8, 2020

@brandon93s That only works as a website themed as a terminal, not in an actual one.

@brandon93s
Copy link

brandon93s commented Mar 8, 2020

😅 I was duped by the demo! Wishful thinking I guess.

@sindresorhus
Copy link
Owner

@Richienb What problem are you trying to solve? Generally, I don't think people would expect to be able to use a mouse in the terminal.

@Richienb
Copy link
Author

Richienb commented Mar 8, 2020

@sindresorhus Terminal buttons can be used instead of having to use Electron for small mockups.

@ScottFreeCode
Copy link

Emacs has support for renderinq its buttons and menus in terminal mode. It also has support for responding to taps in Termux, which makes me suspect that mouse support in the terminal is possible; but I might be wrong about that, it might be something fancy and unusual that Termux is doing. (Emacs' terminal buttons are the one thing that doesn't work very well with taps in Termux, and running it in an ordinary terminal on my laptop has never allowed me any mouse interaction at all.) All this leaves me unsure whether mouse interaction with terminals is a thing. If it is a thing, it probably is only possible on certain terminal emulators, and the code to use it might differ from one to the next.

@Richienb
Copy link
Author

Richienb commented Mar 22, 2020

Windows Terminal/WSL also seems to have mouse support. (microsoft/terminal#5075)

@Richienb
Copy link
Author

Richienb commented Apr 9, 2020

Using terminal-kit, it's possible to easily receive mouse events in the terminal. The only challenge here is detecting if the coordinates of the mouse click line up with those of the button of which somehow must be detected.

@fregante
Copy link

fregante commented Aug 3, 2020

This seems to be possible on macOS/Terminal/bash: https://stackoverflow.com/a/28916388/288906

But really… if I'm in the terminal I will continue using whatever interface with my keyboard.

If you're looking to have an interactive UI in the terminal, perhaps look into https://github.com/vadimdemedes/ink

@Richienb
Copy link
Author

Richienb commented Sep 2, 2020

@fregante The end goal is to create clickable elements in the terminal. An example of how this can be used is in emoj. It currently allows using the left and right arrow keys to scroll through options:

Emoj example

Making these elements clickable is an incremental change that is definitely an improvement here.

@Richienb
Copy link
Author

Richienb commented Sep 2, 2020

I have found a way to get the current cursor position in the terminal to detect where clickable elements are located so this should now be possible.

@Richienb
Copy link
Author

Richienb commented Sep 5, 2020

Button in the terminal

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

No branches or pull requests

5 participants