venn.nvim icon indicating copy to clipboard operation
venn.nvim copied to clipboard

diagonal lines, inserting up and down arrow and other possible extensions

Open matu3ba opened this issue 4 years ago • 4 comments
trafficstars

example why this is cool

Only providing diagonal lines and have a way to insert up and down arrow should be sufficient for most cases.

However having the optional + in several cases could also simplify drawing.

The ultra interface would be of course a curve plotting from a selection via commands and interpolation of results, but thats quite some complexity.

matu3ba avatar Nov 11 '21 22:11 matu3ba

That's cool indeed. There are some impressive ascii art in there.

One difference with them is that venn.nvim is using the special box-drawing characters instead of standard ASCII. I guess if you prefer this style DrawIt or one of its fork could be an option.

I see now that they are also diagonal characters , , . We could integrate them in venn.nvim somehow. I'm currently not sure how the drawing process would look like.

Plots would be cool indeed. I think it would have to be a separate plugin though.

jbyuki avatar Nov 15 '21 18:11 jbyuki

It would also be nice to be able to use a dashed ascii line instead of just a solid one.

JonathanLorimer avatar Apr 24 '22 00:04 JonathanLorimer

I see now that they are also diagonal characters ╱, ╲, ╳. We could integrate them in venn.nvim somehow. I'm currently not sure how the drawing process would look like.

There are typically 2 modes for lines in inkscape: 1. accurate and 2. interpolated

As I understand it, the main implementation problem for both approaches is to get useful information for the console/terminal font to decide, if the non-accurate line interpolates

1.
  x
 /  
x
2.
x
|
x
3.
x
 \
  x

One needs to figure out the prescaling factor of the terminal font to know the diagonal offset (in this case / and \ need 2 character's right- and leftwards, but this might become arbitrary complex with utf8 symbol width.

Not sure, if the character width can be queried in a simple way from utf8. Otherwise offering an "ascii mode" with "ascii character detection" would be most failure-safe. The ascii check could be written in C, ie ported from my code: https://github.com/matu3ba/chepa

matu3ba avatar Apr 24 '22 11:04 matu3ba

It would also be nice to be able to use a dashed ascii line instead of just a solid one.

This is a good idea and might be a recurring request. I have added two functions set_line and set_arrow to customize the style of lines and arrow for each direction. We might have a style parameter in the future.

For example to get the standard ascii style, you would set:

require"venn".set_line({ "s", "s" , " ", " " }, '|')
require"venn".set_line({ " ", "s" , " ", "s" }, '+')
require"venn".set_line({ "s", " " , " ", "s" }, '+')
require"venn".set_line({ " ", "s" , "s", " " }, '+')
require"venn".set_line({ "s", " " , "s", " " }, '+')
require"venn".set_line({ " ", "s" , "s", "s" }, '+')
require"venn".set_line({ "s", " " , "s", "s" }, '+')
require"venn".set_line({ "s", "s" , " ", "s" }, '+')
require"venn".set_line({ "s", "s" , "s", " " }, '+')
require"venn".set_line({ " ", " " , "s", "s" }, '-')
require"venn".set_arrow("up", '^')
require"venn".set_arrow("down", 'v')
require"venn".set_arrow("left", '<')
require"venn".set_arrow("right", '>')

Not sure, if the character width can be queried in a simple way from utf8.

The box-drawing characters are actually already multi-byte character so I needed to compute the width. There is one function in neovim, I don't recall the name anymore to get the displayed width of any string.

The main issue was more about how to keep a logical user interface for vim while allowing the drawing of diagonal characters. Draw a rectangle in Visual + VBox, to draw a rectangle. Draw a rectangle of width/height 1 to draw an arrow. I'm not sure where to fit diagonal lines.

jbyuki avatar Apr 24 '22 13:04 jbyuki