Skip to content

Ascii drawing plugin: lines, ellipses, arrows, fills, and more!

Notifications You must be signed in to change notification settings

joshzcold/DrawIt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Drawit (joshzcold tweaks)

DrawIt is a plugin which allows one to draw lines left, right, up, down, and along both slants. Optionally one may "cap" the lines with arrowheads. One may change the horizontal, vertical, slant, and crossing characters to whichever characters one wishes. Peek 2021-07-18 09-20

Its easy to start and stop DrawIt: use

\di to start DrawIt and \ds to stop DrawIt.

When DrawIt has been started you may use the number pad to leave a trail of dashes, vertical bars, etc. The lines will be expanded as needed to accomodate your drawing. DrawIt can also draw boxes and ellipses on a blank-filled area (DrawIt can produce these) which can be useful for drawing boxes around comments.

DrawIt incorporates an "erase" mode, toggled by the key, that will leave a trail of blanks behind and under the cursor as it is moved by the number pad. Using the shift-arrow keys, DrawIt will move the cursor, expanding lines and inserting spaces as needed, without changing underlying text.

DrawIt records many user options that affect DrawIt and all maps that starting DrawIt creates. When DrawIt is terminated it restores the user's maps and options. DrawIt's number pad maps will expand the file as necessary to accomodate the drawing, automatically.

Supported Features

left move and draw left
right move and draw right, inserting lines/space as needed
up move and draw up, inserting lines/space as needed
down move and draw down, inserting lines/space as needed
s-left move left
s-right move right, inserting lines/space as needed
s-up move up, inserting lines/space as needed
s-down move down, inserting lines/space as needed
\z toggle into and out of erase mode
> draw -> arrow
< draw <- arrow
^ draw ^ arrow
v draw v arrow
pgdn replace with a , move down and right, and insert a |
end replace with a /, move down and left, and insert a /
pgup replace with a /, move up and right, and insert a /
home replace with a , move up and left, and insert a |
> draw fat -> arrow
< draw fat <- arrow
^ draw fat ^ arrow
\v draw fat v arrow
\a draw arrow based on corners of visual-block
\b draw box using visual-block selected region
\e draw an ellipse inside visual-block
\f fill a figure with some character
\h create a canvas for \a \b \e \l
\l draw line based on corners of visual block
\s adds spaces to canvas
leftmouse select visual block
s-leftmouse drag and draw with current brush (register)
\ra ... \rz replace text with given brush/register
\pa ... like \ra ... \rz, except that blanks are considered

Mapping drawing functions

Lua:

-- Start DrawIt
function()
   vim.cmd[[call DrawIt#DrawItStart()]]
   vim.cmd[[set timeoutlen=100]]
   vim.api.nvim_buf_set_keymap(0, "n", "J", ":call DrawIt#DrawDown()<cr>", {noremap = true})
   vim.api.nvim_buf_set_keymap(0, "n", "K", ":call DrawIt#DrawUp()<cr>", {noremap = true})
   vim.api.nvim_buf_set_keymap(0, "n", "L", ":call DrawIt#DrawRight()<cr>", {noremap = true})
   vim.api.nvim_buf_set_keymap(0, "n", "H", ":call DrawIt#DrawLeft()<cr>", {noremap = true})
   vim.api.nvim_buf_set_keymap(0, "n", "JL", ":call DrawIt#DrawSlantDownRight()<cr>", {noremap = true})
   vim.api.nvim_buf_set_keymap(0, "n", "JH", ":call DrawIt#DrawSlantDownLeft()<cr>", {noremap = true})
   vim.api.nvim_buf_set_keymap(0, "n", "KL", ":call DrawIt#DrawSlantUpRight()<cr>", {noremap = true})
   vim.api.nvim_buf_set_keymap(0, "n", "KH", ":call DrawIt#DrawSlantUpLeft()<cr>", {noremap = true})
end

-- End DrawIt
function()
vim.cmd[[call DrawIt#DrawItStop()]]
vim.cmd[[mapclear <buffer>]]
vim.cmd[[set timeoutlen=400]]
end

About

Ascii drawing plugin: lines, ellipses, arrows, fills, and more!

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Vim Script 100.0%