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

potential ascii diagram design #27

Open
8 tasks
matu3ba opened this issue Aug 30, 2023 · 9 comments
Open
8 tasks

potential ascii diagram design #27

matu3ba opened this issue Aug 30, 2023 · 9 comments
Assignees

Comments

@matu3ba
Copy link
Collaborator

matu3ba commented Aug 30, 2023

Also briefly mentioned in anuvyklack/hydra.nvim#94. Besides overlapping logic for 1, overwrites, 2. + on intersections and arrow logic I suspect the selection logic can probably (hydra has many bugs) be done within hydra.

The idea description, hopefully dense enough.

-- symbols (-,|,^,<,>,/,\)
local venn_hint_ascii   = [[
 - and | moves^^   Confirmation moves^^^^
 ^ ^ _K_ ^ ^ ^ ^   _<C-h>_: ◄, _<C-j>_: ▼
 _H_ ^ ^ _L_ ^ ^   ^     ^       ^   ^  ^
 ^ ^ _J_ ^ ^ ^ ^   _<C-k>_: ▲, _<C-l>_: ►
 ◄ + ▲ = \ ^ ^ ^   ◄ + ◄ / ► + ► = - / -
 ► + ▲ = / ^ ^ ^   ▲ + ▲ / ▼ + ▼ = | / |
 ◄ + ▼ = \ ^ ^ ^   other followup symbol
 ► + ▼ = / ^ ^ ^   + ◄▼▲► = <v^> and ▼ = nop
 _F_: surround^^   _f_: surround     ^^ ^
 + corners ^  ^^   overwritten corners
                              _<C-c>_
]]

Capital letters overwrite intersections via +, so going 1 up from

------
      ^<- cursor
      |

yields

------+<- cursor
      |
      |

and likewise the boxing with F.
C-hjkl are to indicate a direction for overwriting with necessary repeated pressing.
The idea is that hk can be pressed very fast, so there is marginal slowdown and things like >>>>>> can be pressed much faster via > and dot-repeat anyway except for ^, which I think is acceptable with C-v5kr^ stored within a macro taking the count from another register (to be provided).

TODOs

  • implement box mode
  • example graphics for overlapping writes
  • implement 2 intersections modes (+ one and overwriting one)
  • more intuitive way other than clock and anti-clock movement
  • diagonal drawing via box mode + key

general improvements

  • dot-repitition for commands (steal from nvim-surround)
  • interpolations
  • document high quality external tooling for drawing?
@matu3ba
Copy link
Collaborator Author

matu3ba commented Sep 1, 2023

Maybe this one is more elaborative:

  -- * ascii mode
  --   + hjkl <v^>
  --   + hj as ◄▼ /
  --   + kl as ▲► /
  --   + kh as ◄▲ \
  --   + jl as ▼► \
  --   + boxes as
  --     +-----+
  --     |     |
  --     |     |
  --     +-----+

@matu3ba
Copy link
Collaborator Author

matu3ba commented Oct 23, 2023

I did my part:

      +---------------------------+
       \                         /  +---+
        \                       /   |   |
         \                     /    |   |
          \                   /     |   |
           \                 /      +---+
            \               /
             \             /        +---+    |\           /|
              \           /         |   |    | \         / |
               \         /          |   |    |  \       /  |
                \       /           |   |    |   \     /   |
                 \     /            |   |    |    \   /    |
                  \   /             |   |    |     \ /     |
                   \ /              |   |    |      +      |
                    +               +---+    ---------------
-- simplified ascii art with hydra
-- symbols (-,|,^,<,>,/,\)
-- capital letters => -| movements
-- C-letters => <v^>
-- leader right clockwise (time running): \/ including movements
-- leader left clockwise (enough time): \/ without movements
local venn_hint_ascii   = [[
 - and | moves^^   Confirmation select^^^
 ^ ^ _K_ ^ ^ ^ ^   _<C-h>_: <, _<C-j>_: v
 _H_ ^ ^ _L_ ^ ^   ^     ^       ^   ^  ^
 ^ ^ _J_ ^ ^ ^ ^   _<C-k>_: ^, _<C-l>_: >
 ◄ + ▲ = \ ^ ^ ^   ◄ + ◄ / ► + ► = <- / ->
 ► + ▲ = / ^ ^ ^   ▲ + ▲ / ▼ + ▼ = | / |
 ◄ + ▼ = \ ^ ^ ^   other followup symbol
 ► + ▼ = / ^ ^ ^   + ◄▲► = <^> and ▼ = nop
                              _<C-c>_
]]
-- _F_: surround^^   _f_: surround     ^^ ^
-- + corners ^  ^^   overwritten corners

M.ascii_hydra = Hydra {
  name = 'Draw Ascii Diagram',
  hint = venn_hint_ascii,
  config = {
    color = 'pink',
    invoke_on_body = true,
    hint = {
      border = 'rounded',
    },
    on_enter = function() vim.wo.virtualedit = 'all' end,
  },
  mode = 'n',
  body = '<leader>va',
  heads = {
    { '<C-h>', 'r<' },
    { '<C-j>', 'rv' },
    { '<C-k>', 'r^' },
    { '<C-l>', 'r>' },
    { 'H', 'r-h' },
    { 'J', 'r|j' },
    { 'K', 'r|k' },
    { 'L', 'r-l' },
    { '<leader>hj', 'r/hj' },
    { '<leader>jh', 'r/' },
    { '<leader>hk', 'r\\hk' },
    { '<leader>kh', 'r\\' },
    { '<leader>lj', 'r\\jl' },
    { '<leader>jl', 'r\\' },
    { '<leader>kl', 'r/kl' },
    { '<leader>lk', 'r/' },
    { '<leader>n', 'r+' },
    { '<leader>h', 'r-hr<' },
    { '<leader>j', 'r|jrv' },
    { '<leader>k', 'r|kr^' },
    { '<leader>l', 'r-lr>' },
    { '<C-c>', nil, { exit = true } },
  },
}

If you give me some brief pointers, then I can implement myself.

@matu3ba
Copy link
Collaborator Author

matu3ba commented Oct 23, 2023

Not sure if the left+right turn thing to distinguish /\ with and without movement is intuitive or another binding is better.

@matu3ba
Copy link
Collaborator Author

matu3ba commented Oct 23, 2023

I guess this one has nicer hints, but I really hate that hydra does automatically include the bindings at the bottom line, if not specified in the hint.

-- simplified ascii art with hydra
-- symbols (-,|,^,<,>,/,\)
-- capital letters => -| movements
-- C-letters => <v^>
-- leader right clockwise (time running): \/ including movements
-- leader left clockwise (enough time): \/ without movements
local venn_hint_ascii   = [[
 -| moves: _H_ _J_ _K_ _L_
 <v^> arrow: _<C-h>_ _<C-j>_ _<C-k>_ _<C-l>_
 diagnoal + move: leader + clockwise like ◄ ▲
 _<leader>jh_ _<leader>hk_ _<leader>lj_ _<leader>kl_
 diagnoal + nomove: anticlockwise like ▲ + ◄
 _<leader>hj_ _<leader>kh_ _<leader>jl_ _<leader>lk_
 set +: _<leader>n_
 rectangle move + arrow, ie ► with ->
 _<leader>h_ _<leader>j_ _<leader>k_ _<leader>l_
                              _<C-c>_
]]
-- _F_: surround^^   _f_: surround     ^^ ^
-- + corners ^  ^^   overwritten corners

M.ascii_hydra = Hydra {
  name = 'Draw Ascii Diagram',
  hint = venn_hint_ascii,
  config = {
    color = 'pink',
    invoke_on_body = true,
    hint = {
      border = 'rounded',
    },
    on_enter = function() vim.wo.virtualedit = 'all' end,
  },
  mode = 'n',
  body = '<leader>va',
  heads = {
    { '<C-h>', 'r<' },
    { '<C-j>', 'rv' },
    { '<C-k>', 'r^' },
    { '<C-l>', 'r>' },
    { 'H', 'r-h' },
    { 'J', 'r|j' },
    { 'K', 'r|k' },
    { 'L', 'r-l' },
    { '<leader>jh', 'r/hj' },
    { '<leader>hj', 'r/' },
    { '<leader>hk', 'r\\hk' },
    { '<leader>kh', 'r\\' },
    { '<leader>lj', 'r\\jl' },
    { '<leader>jl', 'r\\' },
    { '<leader>kl', 'r/kl' },
    { '<leader>lk', 'r/' },
    { '<leader>n', 'r+' },
    { '<leader>h', 'r-hr<' },
    { '<leader>j', 'r|jrv' },
    { '<leader>k', 'r|kr^' },
    { '<leader>l', 'r-lr>' },

    { '<C-c>', nil, { exit = true } },
  },
}

@jbyuki
Copy link
Owner

jbyuki commented Nov 5, 2023

If you give me some brief pointers, then I can implement myself.

In hydra or in venn? Or as a new wiki in this project page?

@matu3ba
Copy link
Collaborator Author

matu3ba commented Nov 5, 2023

In hydra or in venn? Or as a new wiki in this project page?

in venn, for example in this issue.

@jbyuki
Copy link
Owner

jbyuki commented Nov 5, 2023

I've sent you a write access request. This should allow to edit the wiki page freely and go for it. A link in the readme to this wiki would be nice once something is there.

@jbyuki
Copy link
Owner

jbyuki commented Nov 5, 2023

Or I can pin the issue if you prefer. And link it in the readme.

@matu3ba
Copy link
Collaborator Author

matu3ba commented Nov 5, 2023

Or I can pin the issue if you prefer. And link it in the readme.

pinning issue sounds better until a more final solution exists.

@jbyuki jbyuki pinned this issue Nov 5, 2023
@matu3ba matu3ba self-assigned this Apr 23, 2024
@jbyuki jbyuki mentioned this issue May 8, 2024
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

2 participants