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

Ability to draw on top of an "existing" terminal output #2

Open
farzadmf opened this issue Apr 16, 2022 · 3 comments
Open

Ability to draw on top of an "existing" terminal output #2

farzadmf opened this issue Apr 16, 2022 · 3 comments

Comments

@farzadmf
Copy link

Describe the solution you'd like
I think it would be nice to have the ability to draw on an existing output in the terminal.

An example use case:

  • You're running some commands and have some output
  • You want to "highlight" or draw attention to a particular portion
  • You call draw and it takes a "screenshot" of existing output, allowing to draw on top of that

Describe alternatives you've considered
None

@maaslalani
Copy link
Owner

maaslalani commented Apr 16, 2022

I think it would be really great if you could pass input to annotate over stdin so that way you can pipe to draw to start annotating output.

ls -lah | draw

One problem I can see though is that some programs will strip unicode characters when piped which means we'd lose color that way :(

@caproven
Copy link

Another potential factor is double-width (wide) characters. This may not be a concern for current user input, but wide chars could very well be piped into draw from other commands. Should there be handling for them?

Here's an example of using a wide char with the current version. I wrote out the text and then attempted to draw a single box around it:
image

I bring this up because various CLIs have begun incorporating emojis in their output. Take for example the output of kind:

❯ kind create cluster
Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.21.1) 🖼
 ✓ Preparing nodes 📦
 ✓ Writing configuration 📜
 ✓ Starting control-plane 🕹️
 ✓ Installing CNI 🔌
 ✓ Installing StorageClass 💾
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Thanks for using kind! 😊

@maaslalani
Copy link
Owner

Yes, there definitely should be handling for double-width characters:
I think I have an idea on how to implement support but might be tricky.

Thinking out loud: my thinking is that we can reserve a special character to insert after (to the right of) any character that is > 2 character width in the grid and display that character as blank when View() is called. We can then ensure a box border doesn't lie on any of those special characters and if it does, move it to the right/left until it doesn't.

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

3 participants