Skip to content

Commit 5d9d97f

Browse files
Charles Campbellvim-scripts
authored andcommitted
Version 02242003
The latest DrawIt now provides a fill function. \f will ask for a character to fill the figure surrounding the current cursor location. Plus I suggest reading :he drawit-tip for those whose home/pageup/pagedown/end keys aren't all working properly with DrawIt.
0 parents  commit 5d9d97f

File tree

3 files changed

+1617
-0
lines changed

3 files changed

+1617
-0
lines changed

README

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
This is a mirror of http://www.vim.org/scripts/script.php?script_id=40
2+
3+
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.
4+
5+
Its easy to start and stop DrawIt: use
6+
7+
\di to start DrawIt and
8+
\ds to stop DrawIt.
9+
10+
The alpha/beta version is available at http://mysite.verizon.net/astronaut/vim/index.html#DRAWIT.
11+
12+
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.
13+
14+
Viart's <drawing.vim> has been merged with the original DrawIt (vimscript#11) (by permission). Use visual-block selection to specify starting and ending positions and a Bresenham line drawing algorithm will be used to connect the two. DrC has written an ellipse-drawing Bresenham-style procedure: again, use the visual block selection to specify a box to contain the ellipse and \e to trigger the ellipse drawing.
15+
16+
DrawIt incorporates an "erase" mode, toggled by the <space> 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.
17+
18+
DrawIt is now in the vimball format, which is understood by the new Vim 7.0 release. After decompressing the DrawIt.vba.gz file, edit it with Vim, and then source it (:so %). The components of DrawIt will then be placed where they belong, based on your Vim's runtimepath.
19+
20+
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.
21+
22+
Supported Features
23+
<left> move and draw left
24+
<right> move and draw right, inserting lines/space as needed
25+
<up> move and draw up, inserting lines/space as needed
26+
<down> move and draw down, inserting lines/space as needed
27+
<s-left> move left
28+
<s-right> move right, inserting lines/space as needed
29+
<s-up> move up, inserting lines/space as needed
30+
<s-down> move down, inserting lines/space as needed
31+
<space> toggle into and out of erase mode
32+
> draw -> arrow
33+
< draw <- arrow
34+
^ draw ^ arrow
35+
v draw v arrow
36+
<pgdn> replace with a \, move down and right, and insert a \
37+
<end> replace with a /, move down and left, and insert a /
38+
<pgup> replace with a /, move up and right, and insert a /
39+
<home> replace with a \, move up and left, and insert a \
40+
\> draw fat -> arrow
41+
\< draw fat <- arrow
42+
\^ draw fat ^ arrow
43+
\v draw fat v arrow
44+
\a draw arrow based on corners of visual-block
45+
\b draw box using visual-block selected region
46+
\e draw an ellipse inside visual-block
47+
\f fill a figure with some character
48+
\h create a canvas for \a \b \e \l
49+
\l draw line based on corners of visual block
50+
\s adds spaces to canvas
51+
<leftmouse> select visual block
52+
<s-leftmouse> drag and draw with current brush (register)
53+
\ra ... \rz replace text with given brush/register
54+
\pa ... like \ra ... \rz, except that blanks are considered
55+
to be transparent
56+
57+
Thank you for ranking DrawIt!
58+

doc/DrawIt.txt

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
*drawit.txt* The DrawIt Tool November 29, 2001
2+
3+
Authors: Charles E. Campbell, Jr. <[email protected]>
4+
Sylvain VIART <[email protected]>
5+
6+
(remove NOSPAM from Campbell's email first)
7+
8+
==============================================================================
9+
1. Contents *drawit-contents*
10+
11+
1. Contents......................: |drawit-contents|
12+
2. DrawIt Manual.................: |drawit|
13+
3. DrawIt Usage..................: |drawit-usage|
14+
Starting....................: |drawit-start|
15+
Stopping....................: |drawit-stopping|
16+
User Map Protection.........: |drawit-protect|
17+
Drawing.....................: |drawit-drawing|
18+
Changing Drawing Characters.: |drawit-setdrawit|
19+
Moving......................: |drawit-moving|
20+
Erasing.....................: |drawit-erase|
21+
Filling.....................: |drawit-fill|
22+
Tip.........................: |drawit-tip|
23+
Example.....................: |drawit-example|
24+
Visual Block Mode...........: |drawit-visblock|
25+
DrawIt Modes................: |drawit-modes|
26+
27+
==============================================================================
28+
29+
2. DrawIt Manual *drawit*
30+
*drawit-manual*
31+
To Enable:
32+
33+
/=============+============================================================\
34+
|| Starting & | ||
35+
|| Stopping | Explanation ||
36+
++------------+-----------------------------------------------------------++
37+
|| \di | start DrawIt ||
38+
|| \ds | stop DrawIt ||
39+
|| | ||
40+
++============+===========================================================++
41+
|| Commands | Explanation ||
42+
++------------+-----------------------------------------------------------++
43+
|| | The DrawIt routines use a replace, move, and ||
44+
|| | replace/insert strategy. The package also lets one insert||
45+
|| | spaces, draw arrows by using the following characters or ||
46+
|| | keypad characters: ||
47+
|| +-----------------------------------------------------------++
48+
|| <left> | move and draw left ||
49+
|| <right> | move and draw right, inserting lines/space as needed ||
50+
|| <up> | move and draw up, inserting lines/space as needed ||
51+
|| <down> | move and draw down, inserting lines/space as needed ||
52+
|| <s-left> | move left ||
53+
|| <s-right> | move right, inserting lines/space as needed ||
54+
|| <s-up> | move up, inserting lines/space as needed ||
55+
|| <s-down> | move down, inserting lines/space as needed ||
56+
|| <space> | toggle into and out of erase mode ||
57+
|| > | insert a > and move right (draw -> arrow) ||
58+
|| < | insert a < and move left (draw <- arrow) ||
59+
|| ^ | insert a ^ and move up (draw ^ arrow) ||
60+
|| v | insert a v and move down (draw v arrow) ||
61+
|| <pgdn> | replace with a \, move down and right, and insert a \ ||
62+
|| <end> | replace with a /, move down and left, and insert a / ||
63+
|| <pgup> | replace with a /, move up and right, and insert a / ||
64+
|| <home> | replace with a \, move up and left, and insert a \ ||
65+
|| \> | insert a fat > and move right (draw -> arrow) ||
66+
|| \< | insert a fat < and move left (draw <- arrow) ||
67+
|| \^ | insert a fat ^ and move up (draw ^ arrow) ||
68+
|| \v | insert a fat v and move down (draw v arrow) ||
69+
|| | ||
70+
|| +-----------------------------------------------------------++
71+
|| | The drawing mode routines use visual-block mode to ||
72+
|| | select endpoints for lines, arrows, and ellipses. Bresen- ||
73+
|| | ham and Bresenham-like algorithms are used for this. ||
74+
|| | ||
75+
|| | These routines need a block of spaces, and so the "holer" ||
76+
|| | routine must first be used to create such a block. The ||
77+
|| | holer routine will query the user for the number of lines ||
78+
|| | to hold |'textwidth'| spaces. ||
79+
|| +-----------------------------------------------------------++
80+
|| \a | draw arrow from corners of visual-block selected region ||
81+
|| \b | draw box on visual-block selected region ||
82+
|| \e | draw an ellipse on visual-block selected region ||
83+
|| \f | fill a figure with some character ||
84+
|| \h | the holer routine (will query user, see above) ||
85+
|| \l | draw line from corners of visual-block selected region ||
86+
|| \s | spacer: appends spaces up to the textwidth (default: 78) ||
87+
|| | ||
88+
++============+===========================================================++
89+
|| Function and Explanation ||
90+
++------------+-----------------------------------------------------------++
91+
|| :call SetDrawIt('vertical','horizontal','crossing','\','/','X') ||
92+
|| set drawing characters for motions for moving ||
93+
|| default motion ||
94+
|| | up/down, ||
95+
|| - left/right, ||
96+
|| + -| crossing, ||
97+
|| \ downright, ||
98+
|| / downleft, and ||
99+
|| X \/ crossing ||
100+
|| ||
101+
\==========================================================================/
102+
103+
==============================================================================
104+
105+
3. DrawIt Usage *drawit-usage*
106+
107+
108+
STARTING *drawit-start*
109+
\di
110+
111+
Typically one puts <drawit.vim> into the .vim/plugin directory
112+
(vimfiles\plugin for MS) where it becomes always available. It uses a minimal
113+
interface (\di: you can think of it as *D*raw*I*t or *D*rawIt *I*nitialize) to
114+
start it and (\ds: *D*rawIt *S*top) to stop it. Instead of using "\" you may
115+
specify your own preference for a map leader (see |mapleader|).
116+
117+
A message, "[DrawIt]", will appear on the message line.
118+
119+
120+
STOPPING *drawit-stopping*
121+
\ds
122+
123+
When you are done with DrawIt, use \ds to stop DrawIt mode. Stopping DrawIt
124+
will restore your usual options and remove the maps DrawIt set up.
125+
126+
A message, "[DrawIt off]", will appear on the message line.
127+
128+
129+
USER MAP PROTECTION *drawit-protect*
130+
131+
Starting DrawIt causes it to set up a number of maps which facilitate
132+
drawing. Just use the arrow keys or the keypad to cruise around your display.
133+
DrawIt will then leave appropriate lines as you move horizontally, vertically,
134+
or diagonally, and will transparently enlarge your file to accommodate your
135+
drawing as needed. DrawIt saves both maps and user options and sets them to
136+
its own needs. You may use h-j-k-l to move about your display and generally
137+
use editing commands as you wish even while in DrawIt mode.
138+
139+
140+
DRAWING *drawit-drawing*
141+
142+
After DrawIt is started, just use the number pad to move the cursor about. It
143+
will leave a trail of -s, |s, \s, /s (depending on which direction and
144+
SetDrawIt() changes), and +s and Xs where line crossing occurs.
145+
146+
147+
CHANGING DRAWING CHARACTERS *drawit-setdrawit*
148+
149+
The SetDrawIt() function is available for those who wish to change the
150+
characters that DrawIt uses. >
151+
152+
ex. :call SetDrawIt('*','*','*','*','*','*')
153+
ex. :call SetDrawIt('-','|','-','\','/','/')
154+
<
155+
The first example shows how to change all the DrawIt drawing characters to
156+
asterisks, and the second shows how to give crossing priority to - and /.
157+
158+
159+
MOVING *drawit-move* *drawit-moving*
160+
161+
DrawIt supports shifting the arrow keys to cause motion of the cursor. The
162+
motion of the cursor will not modify what's below the cursor. The cursor
163+
will move and lines and/or spaces will be inserted to support the move as
164+
required. Your terminal may not support shifted arrow keys, however, or Vim
165+
may not catch them as such. For example, on the machine I use, shift-up
166+
(<s-up>) produced <Esc>[161q, but vim didn't know that sequence was a <s-up>.
167+
I merely made a nmap:
168+
169+
nmap <Esc>[161q <s-up>
170+
171+
and vim thereafter recognized the <s-up> command.
172+
173+
174+
ERASING *drawit-erase*
175+
<space>
176+
177+
The <space> key will toggle DrawIt's erase mode/DrawIt mode. When in
178+
[DrawIt erase] mode, a message "[DrawIt erase]" will appear and the
179+
number pad will now cause spaces to be drawn instead of the usual drawing
180+
characters. The drawing characters will be restored when the <space>
181+
key toggles DrawIt back to regular DrawIt mode.
182+
183+
FILLING *drawit-fill*
184+
185+
With the cursor inside some figure, a \f will invoke a fill operation.
186+
DrawIt will ask the user to supply a character which will then be
187+
used to fill the figure. The figure is assumed to be connected only
188+
horizontally and vertically. Supplying more than one character to
189+
the prompt will result in the extra characters being also considered
190+
as boundary characters (for example, using ".*" will fill the the
191+
dot, but both dots and asterisks will be assumed to comprise boundary
192+
characters along with the usual boundary characters.
193+
194+
TIP *drawit-tip*
195+
196+
I have found that sometimes one or more of the <home>, <end>, <pageup>,
197+
and <pagedown> keys give unique sequences but are not interpreted
198+
properly by Vim. This problem impacts DrawIt as it uses those four
199+
keys to signify diagonal moves/drawing. One solution I use is to
200+
put into my <.vimrc> file mapings like:
201+
202+
map ^V... <home>
203+
204+
where the ellipsis (...) is the actual character sequence produced by
205+
hitting the key. The way to generate such maps is to type "map ",
206+
followed by three control-v presses, press the associated key, then
207+
a space followed by the proper interpretation sequence (ie. <home>).
208+
209+
EXAMPLES *drawit-example*
210+
211+
Needless to say, the bottom spirals were done with DrawIt and some
212+
block editing with Vim: >
213+
214+
+------------ -----------+ +------------ -----------+ +------------
215+
|+----------+ +---------+| |+----------+ +---------+| |+----------+
216+
||+--------+| |+-------+|| ||+--------+| |+-------+|| ||+--------+|
217+
|||-------+|| ||+------||| |||-------+|| ||+------||| |||-------+||
218+
||+-------+|| ||+------+|| ||+-------+|| ||+------+|| ||+-------+||
219+
|+---------+| |+--------+| |+---------+| |+--------+| |+---------+|
220+
+-----------+ +----------+ +-----------+ +----------+ +-----------+
221+
222+
VISUAL BLOCK MODE FOR ARROWS LINES BOXES AND ELLIPSES *drawit-visblock*
223+
\a \b \e \h \l \s
224+
225+
The DrawIt package has been merged with Sylvain Viart's drawing package
226+
which provides DrawIt with visual-block selection of starting/ending
227+
point drawing of arrows (\a), lines (\l), and boxes (\b). Addtionally
228+
I wrote an ellipse drawing function using visual block specification (\e).
229+
230+
One must have a block of spaces for these maps which the "holer" routine
231+
(\h) will help create. The holer routine will query the user for the number
232+
of lines s/he wishes to have, and will fill those lines with spaces out to the
233+
|'textwidth'| (or 78 spaces if that option hasn't been set).
234+
235+
The Sylvain Viart functions and the ellipse drawing function depend
236+
upon using visual block mode. Typical use: >
237+
238+
Example: * \h
239+
DrawIt asks: how many lines under the cursor? 10
240+
DrawIt then appends 10 lines filled with blanks
241+
out to textwidth (if defined) or 78 columns.
242+
* ctrl-v (move) \b
243+
DrawIt then draws a box
244+
<
245+
One first creates a number of blank-filled lines; the \h map (the "holer") is
246+
useful for this. Select the first endpoint with ctrl-v and then move to the
247+
other endpoint. One may then select \a for arrows, \b for boxes, \e for ellipses,
248+
or \l for lines.
249+
>
250+
Examples:
251+
252+
__ _ *************** +-------+
253+
\_ _/ **** **** | |
254+
\_ _/ ** ---------> ** | |
255+
\_ _/ **** **** | |
256+
\__/ <------- *************** +-------+
257+
258+
\l \a \e and \a \b
259+
<
260+
DRAWIT MODES *drawit-modes*
261+
262+
-[DrawIt] regular DrawIt mode
263+
-[DrawIt off] DrawIt is off
264+
-[DrawIt erase] DrawIt will erase using the number pad
265+
266+
g:DrChipTopLvlMenu: by default its "DrChip"; you may set this to whatever
267+
you like in your <.vimrc>. This variable controls where
268+
DrawIt's menu items are placed.
269+
270+
vim:tw=78:ts=8:ft=help

0 commit comments

Comments
 (0)