Open farzadmf opened 2 years ago
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 :(
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:
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! đ
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.
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:
draw
and it takes a "screenshot" of existing output, allowing to draw on top of thatDescribe alternatives you've considered None