-
Notifications
You must be signed in to change notification settings - Fork 42
/
DrawIt.vim
2921 lines (2657 loc) · 91.9 KB
/
DrawIt.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" DrawIt.vim: a simple way to draw things in Vim
"
" Maintainer: Charles E. Campbell
" Authors: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz> - NOSPAM
" Sylvain Viart (molo@multimania.com)
" Version: 13
" Date: Nov 25, 2013
"
" Quick Setup: {{{1
" tar -oxvf DrawIt.tar
" Should put DrawItPlugin.vim in your .vim/plugin directory,
" put DrawIt.vim in your .vim/autoload directory
" put DrawIt.txt in your .vim/doc directory.
" Then, use \di to start DrawIt,
" \ds to stop Drawit, and
" draw by simply moving about using the cursor keys.
"
" You may also use visual-block mode to select endpoints and
" draw lines, arrows, and ellipses.
"
" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" DrawIt.vim is provided *as is* and comes with no warranty
" of any kind, either expressed or implied. By using this
" plugin, you agree that in no event will the copyright
" holder be liable for any damages resulting from the use
" of this software.
"
" Required: THIS SCRIPT REQUIRES VIM 7.0 (or later) {{{1
" GetLatestVimScripts: 40 1 :AutoInstall: DrawIt.vim
" GetLatestVimScripts: 1066 1 cecutil.vim
"
" Woe to her who is rebellious and polluted, the oppressing {{{1
" city! She didn't obey the voice. She didn't receive correction.
" She didn't trust in Yahweh. She didn't draw near to her God. (Zeph 3:1,2 WEB)
" ---------------------------------------------------------------------
" Load Once: {{{1
if &cp || exists("g:loaded_DrawIt")
finish
endif
let g:loaded_DrawIt= "v13"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of DrawIt needs vim 7.0"
echohl Normal
finish
endif
let s:keepcpo= &cpo
set cpo&vim
scriptencoding utf-8
" ---------------------------------------------------------------------
" Script Variables: {{{1
if !exists("g:drawit_xstrlen")
if exists("g:Align_xstrlen")
let g:drawit_xstrlen= g:Align_xstrlen
elseif exists("g:netrw_xstrlen")
let g:drawit_xstrlen= g:netrw_xstrlen
elseif &enc == "latin1" || !has("multi_byte")
let g:drawit_xstrlen= 0
else
let g:drawit_xstrlen= 1
endif
endif
if !exists("g:drawit_mode")
let g:drawit_mode= 'N' " other options: =S (single-line utf-*,cp437) or =D (double-line utf-*,cp437)
endif
if !exists("s:saveposn_count")
let s:saveposn_count= 0
endif
"DechoTabOn
" =====================================================================
" DrawIt Functions: (by Charles E. Campbell) {{{1
" =====================================================================
" ---------------------------------------------------------------------
" DrawIt#DrawItStart: this function maps the cursor keys, sets up default {{{2
" drawing characters, and makes some settings
fun! DrawIt#DrawItStart(...)
" call Dfunc("DrawItStart()")
if a:0 > 0
if exists("b:di_gfxchr") && b:di_gfxchr && (a:1 == 'S' || a:1 == 's')
DIsngl
elseif exists("b:di_gfxchr") && b:di_gfxchr && (a:1 == 'D' || a:1 == 'd')
DIdbl
elseif !exists("g:drawit_mode")
let g:drawit_mode= 'N'
endif
endif
" DrawItStart: report on [DrawIt] mode {{{3
if exists("b:dodrawit") && b:dodrawit == 1
" already in DrawIt mode
echo "[DrawIt] (already on, use ".((exists("mapleader") && mapleader != "")? mapleader : '\')."ds to stop)"
" call Dret("DrawItStart")
return
endif
let b:dodrawit= 1
" indicate in DrawIt mode
echo "[DrawIt]"
" DrawItStart: turn on mouse {{{3
if !exists("b:drawit_keep_mouse")
let b:drawit_keep_mouse= &mouse
endif
setl mouse=a
" DrawItStart: set up DrawIt commands {{{3
com! -nargs=1 -range SetBrush <line1>,<line2>call DrawIt#SetBrush(<q-args>)
com! -count Canvas call s:Spacer(line("."),line(".") + <count> - 1,0)
" DrawItStart: set up default drawing characters {{{3
if !exists("b:di_vert") |let b:di_vert = "|" |endif
if !exists("b:di_horiz") |let b:di_horiz = "-" |endif
if !exists("b:di_plus") |let b:di_plus = "+" |endif
if !exists("b:di_upright")|let b:di_upright = "/" |endif " same as downleft
if !exists("b:di_upleft") |let b:di_upleft = "\\"|endif " same as downright
if !exists("b:di_cross") |let b:di_cross = "X" |endif
if !exists("b:di_ellipse")|let b:di_ellipse = '*' |endif
let b:di_gfxchr= 1
if &enc == 'utf-8' || &enc == 'utf-16' || &enc == "ucs-4"
" Box drawing characters using unicode
" │ ─ ┌ ┐ └ ┘ ┬ ┴ ├ ┤ ┼ ╱ ╲ ╳
" ║ ═ ╔ ╗ ╚ ╝ ╦ ╩ ╠ ╣ ╬
" call Decho("box drawing characters using unicode")
if !exists("b:di_Svert") |let b:di_Svert = '│' |endif
if !exists("b:di_Dvert") |let b:di_Dvert = '║' |endif
if !exists("b:di_Shoriz") |let b:di_Shoriz = '─' |endif
if !exists("b:di_Dhoriz") |let b:di_Dhoriz = '═' |endif
if !exists("b:di_Sulcorn") |let b:di_Sulcorn = '┌' |endif
if !exists("b:di_Dulcorn") |let b:di_Dulcorn = '╔' |endif
if !exists("b:di_Surcorn") |let b:di_Surcorn = '┐' |endif
if !exists("b:di_Durcorn") |let b:di_Durcorn = '╗' |endif
if !exists("b:di_Sllcorn") |let b:di_Sllcorn = '└' |endif
if !exists("b:di_Dllcorn") |let b:di_Dllcorn = '╚' |endif
if !exists("b:di_Slrcorn") |let b:di_Slrcorn = '┘' |endif
if !exists("b:di_Dlrcorn") |let b:di_Dlrcorn = '╝' |endif
if !exists("b:di_Splus") |let b:di_Splus = '┼' |endif
if !exists("b:di_Dplus") |let b:di_Dplus = '╬' |endif
if !exists("b:di_Sdnplus") |let b:di_Sdnplus = '┬' |endif
if !exists("b:di_Ddnplus") |let b:di_Ddnplus = '╦' |endif
if !exists("b:di_Supplus") |let b:di_Supplus = '┴' |endif
if !exists("b:di_Dupplus") |let b:di_Dupplus = '╩' |endif
if !exists("b:di_Slplus") |let b:di_Slplus = '┤' |endif
if !exists("b:di_Dlplus") |let b:di_Dlplus = '╣' |endif
if !exists("b:di_Srplus") |let b:di_Srplus = '├' |endif
if !exists("b:di_Drplus") |let b:di_Drplus = '╠' |endif
if !exists("b:di_Supright")|let b:di_Supright= "╱" |endif " same as Sdownleft
if !exists("b:di_Supleft") |let b:di_Supleft = "╲" |endif " same as Sdownright
if !exists("b:di_Scross") |let b:di_Scross = "╳" |endif
" Mixed Single-Double unicode box drawing characters
" ╞ ╟ ╡ ╢ ╤ ╥ ╧ ╪ ╫
if !exists("b:di_DhSd") |let b:di_DhSd = '╤' |endif
if !exists("b:di_DhSu") |let b:di_DhSu = '╧' |endif
if !exists("b:di_DuSl") |let b:di_DuSl = '╢' |endif
if !exists("b:di_DuSlr") |let b:di_DuSlr= '╫' |endif
if !exists("b:di_DuSr") |let b:di_DuSr = '╟' |endif
if !exists("b:di_ShDd") |let b:di_ShDd = '╥' |endif
if !exists("b:di_ShDu") |let b:di_ShDu = '╨' |endif
if !exists("b:di_SuDl") |let b:di_SuDl = '╡' |endif
if !exists("b:di_SuDlr") |let b:di_SuDlr= '╪' |endif
if !exists("b:di_SdDh") |let b:di_SdDh = '╤' |endif
if !exists("b:di_SuDh") |let b:di_SuDh = '╧' |endif
if !exists("b:di_SuDr") |let b:di_SuDr = '╞' |endif
" Mixed Single-Double unicode box drawing corner characters
" ╒ ╓ ╕ ╖ ╘ ╙ ╛ ╜
if !exists("b:di_cSdDr")| let b:di_cSdDr= '╒'| endif
if !exists("b:di_cDdSr")| let b:di_cDdSr= '╓'| endif
if !exists("b:di_cDlSd")| let b:di_cDlSd= '╕'| endif
if !exists("b:di_cSlDd")| let b:di_cSlDd= '╖'| endif
if !exists("b:di_cDrSu")| let b:di_cDrSu= '╘'| endif
if !exists("b:di_cSrDu")| let b:di_cSrDu= '╙'| endif
if !exists("b:di_cDlSu")| let b:di_cDlSu= '╛'| endif
if !exists("b:di_cSlDu")| let b:di_cSlDu= '╜'| endif
elseif &enc == 'cp437'
" Box drawing characters using cp437 (dos)
" call Decho("box drawing characters using cp437")
if !exists("b:di_Svert") |let b:di_Svert = nr2char(179) |endif " │
if !exists("b:di_Dvert") |let b:di_Dvert = nr2char(186) |endif " ║
if !exists("b:di_Shoriz") |let b:di_Shoriz = nr2char(196) |endif " ─
if !exists("b:di_Dhoriz") |let b:di_Dhoriz = nr2char(205) |endif " ═
if !exists("b:di_Sulcorn") |let b:di_Sulcorn = nr2char(218) |endif " ┌
if !exists("b:di_Dulcorn") |let b:di_Dulcorn = nr2char(201) |endif " ╔
if !exists("b:di_Surcorn") |let b:di_Surcorn = nr2char(191) |endif " ┐
if !exists("b:di_Durcorn") |let b:di_Durcorn = nr2char(187) |endif " ╗
if !exists("b:di_Sllcorn") |let b:di_Sllcorn = nr2char(192) |endif " └
if !exists("b:di_Dllcorn") |let b:di_Dllcorn = nr2char(200) |endif " ╚
if !exists("b:di_Slrcorn") |let b:di_Slrcorn = nr2char(217) |endif " ┘
if !exists("b:di_Dlrcorn") |let b:di_Dlrcorn = nr2char(188) |endif " ╝
if !exists("b:di_Splus") |let b:di_Splus = nr2char(197) |endif " ┼
if !exists("b:di_Dplus") |let b:di_Dplus = nr2char(206) |endif " ╬
if !exists("b:di_Sdnplus") |let b:di_Sdnplus = nr2char(194) |endif " ┬
if !exists("b:di_Ddnplus") |let b:di_Ddnplus = nr2char(203) |endif " ╦
if !exists("b:di_Supplus") |let b:di_Supplus = nr2char(193) |endif " ┴
if !exists("b:di_Dupplus") |let b:di_Dupplus = nr2char(202) |endif " ╩
if !exists("b:di_Slplus") |let b:di_Slplus = nr2char(180) |endif " ┤
if !exists("b:di_Dlplus") |let b:di_Dlplus = nr2char(185) |endif " ╣
if !exists("b:di_Srplus") |let b:di_Srplus = nr2char(195) |endif " ├
if !exists("b:di_Drplus") |let b:di_Drplus = nr2char(204) |endif " ╠
if !exists("b:di_Supright")|let b:di_Supright= '/' |endif " ╱
if !exists("b:di_Supleft") |let b:di_Supleft = '\' |endif " ╲
if !exists("b:di_Scross") |let b:di_Scross = 'X' |endif " ╳
" Mixed Single-Double cp437 box drawing characters
if !exists("b:di_DhSd") |let b:di_DhSd = nr2char(209)|endif " ╤
if !exists("b:di_DhSu") |let b:di_DhSu = nr2char(207)|endif " ╧
if !exists("b:di_DuSl") |let b:di_DuSl = nr2char(182)|endif " ╢
if !exists("b:di_DuSlr") |let b:di_DuSlr= nr2char(215)|endif " ╫
if !exists("b:di_DuSr") |let b:di_DuSr = nr2char(199)|endif " ╟
if !exists("b:di_ShDd") |let b:di_ShDd = nr2char(210)|endif " ╥
if !exists("b:di_ShDu") |let b:di_ShDu = nr2char(208)|endif " ╨
if !exists("b:di_SuDl") |let b:di_SuDl = nr2char(181)|endif " ╡
if !exists("b:di_SuDlr") |let b:di_SuDlr= nr2char(216)|endif " ╪
if !exists("b:di_SdDh") |let b:di_SdDh = nr2char(209)|endif " ╤
if !exists("b:di_SuDh") |let b:di_SuDh = nr2char(207)|endif " ╧
if !exists("b:di_SuDr") |let b:di_SuDr = nr2char(198)|endif " ╞
" Mixed Single-Double cp437 box drawing corner characters
if !exists("b:di_cSdDr")| let b:di_cSdDr= nr2char(213)| endif " ╒
if !exists("b:di_cDdSr")| let b:di_cDdSr= nr2char(214)| endif " ╓
if !exists("b:di_cDlSd")| let b:di_cDlSd= nr2char(184)| endif " ╕
if !exists("b:di_cSlDd")| let b:di_cSlDd= nr2char(183)| endif " ╖
if !exists("b:di_cDrSu")| let b:di_cDrSu= nr2char(212)| endif " ╘
if !exists("b:di_cSrDu")| let b:di_cSrDu= nr2char(211)| endif " ╙
if !exists("b:di_cDlSu")| let b:di_cDlSu= nr2char(190)| endif " ╛
if !exists("b:di_cSlDu")| let b:di_cSlDu= nr2char(189)| endif " ╜
else
" call Decho("regular box drawing characters only")
let b:di_gfxchr = 0
endif
" set up initial DrawIt behavior (as opposed to erase behavior)
let b:di_erase = 0
call s:DrawItSaveUserSettings()
" DrawItStart: save and unmap user maps {{{3
let b:lastdir = 1
if exists("mapleader")
let usermaplead = mapleader
else
let usermaplead = "\\"
endif
call SaveUserMaps("bn","","><^v","DrawIt")
call SaveUserMaps("bv",usermaplead,"abceflsy","DrawIt")
call SaveUserMaps("bn","","<c-v>","DrawIt")
call SaveUserMaps("bn",usermaplead,"h><v^","DrawIt")
call SaveUserMaps("bn","","<left>","DrawIt")
call SaveUserMaps("bn","","<right>","DrawIt")
call SaveUserMaps("bn","","<up>","DrawIt")
call SaveUserMaps("bn","","<down>","DrawIt")
call SaveUserMaps("bn","","<left>","DrawIt")
call SaveUserMaps("bn","","<s-right>","DrawIt")
call SaveUserMaps("bn","","<s-up>","DrawIt")
call SaveUserMaps("bn","","<s-down>","DrawIt")
call SaveUserMaps("bn","","<space>","DrawIt")
call SaveUserMaps("bn","","<home>","DrawIt")
call SaveUserMaps("bn","","<end>","DrawIt")
call SaveUserMaps("bn","","<pageup>","DrawIt")
call SaveUserMaps("bn","","<pagedown>","DrawIt")
call SaveUserMaps("bn","","<c-leftdrag>","DrawIt")
call SaveUserMaps("bn","","<c-leftmouse>","DrawIt")
call SaveUserMaps("bn","","<c-leftrelease>","DrawIt")
call SaveUserMaps("bn","","<leftdrag>","DrawIt")
call SaveUserMaps("bn","","<leftmouse>","DrawIt")
call SaveUserMaps("bn","","<middlemouse>","DrawIt")
call SaveUserMaps("bn","","<rightmouse>","DrawIt")
call SaveUserMaps("bn","","<s-leftdrag>","DrawIt")
call SaveUserMaps("bn","","<s-leftmouse>","DrawIt")
call SaveUserMaps("bn","","<s-leftrelease>","DrawIt")
call SaveUserMaps("bv","","<c-leftmouse>","DrawIt")
call SaveUserMaps("bv","","<leftmouse>","DrawIt")
call SaveUserMaps("bv","","<middlemouse>","DrawIt")
call SaveUserMaps("bv","","<rightmouse>","DrawIt")
call SaveUserMaps("bv","","<s-leftmouse>","DrawIt")
call SaveUserMaps("bn",usermaplead,":pa","DrawIt")
call SaveUserMaps("bn",usermaplead,":pb","DrawIt")
call SaveUserMaps("bn",usermaplead,":pc","DrawIt")
call SaveUserMaps("bn",usermaplead,":pd","DrawIt")
call SaveUserMaps("bn",usermaplead,":pe","DrawIt")
call SaveUserMaps("bn",usermaplead,":pf","DrawIt")
call SaveUserMaps("bn",usermaplead,":pg","DrawIt")
call SaveUserMaps("bn",usermaplead,":ph","DrawIt")
call SaveUserMaps("bn",usermaplead,":pi","DrawIt")
call SaveUserMaps("bn",usermaplead,":pj","DrawIt")
call SaveUserMaps("bn",usermaplead,":pk","DrawIt")
call SaveUserMaps("bn",usermaplead,":pl","DrawIt")
call SaveUserMaps("bn",usermaplead,":pm","DrawIt")
call SaveUserMaps("bn",usermaplead,":pn","DrawIt")
call SaveUserMaps("bn",usermaplead,":po","DrawIt")
call SaveUserMaps("bn",usermaplead,":pp","DrawIt")
call SaveUserMaps("bn",usermaplead,":pq","DrawIt")
call SaveUserMaps("bn",usermaplead,":pr","DrawIt")
call SaveUserMaps("bn",usermaplead,":ps","DrawIt")
call SaveUserMaps("bn",usermaplead,":pt","DrawIt")
call SaveUserMaps("bn",usermaplead,":pu","DrawIt")
call SaveUserMaps("bn",usermaplead,":pv","DrawIt")
call SaveUserMaps("bn",usermaplead,":pw","DrawIt")
call SaveUserMaps("bn",usermaplead,":px","DrawIt")
call SaveUserMaps("bn",usermaplead,":py","DrawIt")
call SaveUserMaps("bn",usermaplead,":pz","DrawIt")
call SaveUserMaps("bn",usermaplead,":ra","DrawIt")
call SaveUserMaps("bn",usermaplead,":rb","DrawIt")
call SaveUserMaps("bn",usermaplead,":rc","DrawIt")
call SaveUserMaps("bn",usermaplead,":rd","DrawIt")
call SaveUserMaps("bn",usermaplead,":re","DrawIt")
call SaveUserMaps("bn",usermaplead,":rf","DrawIt")
call SaveUserMaps("bn",usermaplead,":rg","DrawIt")
call SaveUserMaps("bn",usermaplead,":rh","DrawIt")
call SaveUserMaps("bn",usermaplead,":ri","DrawIt")
call SaveUserMaps("bn",usermaplead,":rj","DrawIt")
call SaveUserMaps("bn",usermaplead,":rk","DrawIt")
call SaveUserMaps("bn",usermaplead,":rl","DrawIt")
call SaveUserMaps("bn",usermaplead,":rm","DrawIt")
call SaveUserMaps("bn",usermaplead,":rn","DrawIt")
call SaveUserMaps("bn",usermaplead,":ro","DrawIt")
call SaveUserMaps("bn",usermaplead,":rp","DrawIt")
call SaveUserMaps("bn",usermaplead,":rq","DrawIt")
call SaveUserMaps("bn",usermaplead,":rr","DrawIt")
call SaveUserMaps("bn",usermaplead,":rs","DrawIt")
call SaveUserMaps("bn",usermaplead,":rt","DrawIt")
call SaveUserMaps("bn",usermaplead,":ru","DrawIt")
call SaveUserMaps("bn",usermaplead,":rv","DrawIt")
call SaveUserMaps("bn",usermaplead,":rw","DrawIt")
call SaveUserMaps("bn",usermaplead,":rx","DrawIt")
call SaveUserMaps("bn",usermaplead,":ry","DrawIt")
call SaveUserMaps("bn",usermaplead,":rz","DrawIt")
if exists("g:drawit_insertmode") && g:drawit_insertmode
call SaveUserMaps("bi","","<left>","DrawIt")
call SaveUserMaps("bi","","<right>","DrawIt")
call SaveUserMaps("bi","","<up>","DrawIt")
call SaveUserMaps("bi","","<down>","DrawIt")
call SaveUserMaps("bi","","<left>","DrawIt")
call SaveUserMaps("bi","","<s-right>","DrawIt")
call SaveUserMaps("bi","","<s-up>","DrawIt")
call SaveUserMaps("bi","","<s-down>","DrawIt")
call SaveUserMaps("bi","","<home>","DrawIt")
call SaveUserMaps("bi","","<end>","DrawIt")
call SaveUserMaps("bi","","<pageup>","DrawIt")
call SaveUserMaps("bi","","<pagedown>","DrawIt")
call SaveUserMaps("bi","","<leftmouse>","DrawIt")
endif
call SaveUserMaps("bn","",":\<c-v>","DrawIt")
" DrawItStart: DrawIt maps (Charles Campbell) {{{3
nmap <silent> <buffer> <script> <left> :set lz<CR>:silent! call <SID>DrawLeft()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <right> :set lz<CR>:silent! call <SID>DrawRight()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <up> :set lz<CR>:silent! call <SID>DrawUp()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <down> :set lz<CR>:silent! call <SID>DrawDown()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <s-left> :set lz<CR>:silent! call <SID>MoveLeft()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <s-right> :set lz<CR>:silent! call <SID>MoveRight()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <s-up> :set lz<CR>:silent! call <SID>MoveUp()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <s-down> :set lz<CR>:silent! call <SID>MoveDown()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <space> :set lz<CR>:silent! call <SID>DrawErase()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> > :set lz<CR>:silent! call <SID>DrawSpace('>',1)<CR>:set nolz<CR>
nmap <silent> <buffer> <script> < :set lz<CR>:silent! call <SID>DrawSpace('<',2)<CR>:set nolz<CR>
nmap <silent> <buffer> <script> ^ :set lz<CR>:silent! call <SID>DrawSpace('^',3)<CR>:set nolz<CR>
nmap <silent> <buffer> <script> v :set lz<CR>:silent! call <SID>DrawSpace('v',4)<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <home> :set lz<CR>:silent! call <SID>DrawSlantUpLeft()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <end> :set lz<CR>:silent! call <SID>DrawSlantDownLeft()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <pageup> :set lz<CR>:silent! call <SID>DrawSlantUpRight()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <pagedown> :set lz<CR>:silent! call <SID>DrawSlantDownRight()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <Leader>> :set lz<CR>:silent! call <SID>DrawFatRArrow()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <Leader>< :set lz<CR>:silent! call <SID>DrawFatLArrow()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <Leader>^ :set lz<CR>:silent! call <SID>DrawFatUArrow()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <Leader>v :set lz<CR>:silent! call <SID>DrawFatDArrow()<CR>:set nolz<CR>
nmap <silent> <buffer> <script> <Leader>f :call <SID>Flood()<cr>
" DrawItStart: Set up insertmode maps {{{3
if exists("g:drawit_insertmode") && g:drawit_insertmode
imap <silent> <buffer> <script> <left> <Esc><left>a
imap <silent> <buffer> <script> <right> <Esc><right>a
imap <silent> <buffer> <script> <up> <Esc><up>a
imap <silent> <buffer> <script> <down> <Esc><down>a
imap <silent> <buffer> <script> <left> <Esc><left>a
imap <silent> <buffer> <script> <s-right> <Esc><s-right>a
imap <silent> <buffer> <script> <s-up> <Esc><s-up>a
imap <silent> <buffer> <script> <s-down> <Esc><s-down>a
imap <silent> <buffer> <script> <home> <Esc><home>a
imap <silent> <buffer> <script> <end> <Esc><end>a
imap <silent> <buffer> <script> <pageup> <Esc><pageup>a
imap <silent> <buffer> <script> <pagedown> <Esc><pagedown>a
endif
" DrawItStart: set up drawing mode mappings (Sylvain Viart) {{{3
nnoremap <silent> <buffer> <script> <c-v> :call <SID>LeftStart()<CR><c-v>
vmap <silent> <buffer> <script> <Leader>a :<c-u>call <SID>CallBox('Arrow')<CR>
vmap <silent> <buffer> <script> <Leader>b :<c-u>call <SID>CallBox('DrawBox')<cr>
nmap <buffer> <script> <Leader>c :call <SID>Canvas()<cr>
vmap <silent> <buffer> <script> <Leader>l :<c-u>call <SID>CallBox('DrawPlainLine')<CR>
vmap <silent> <buffer> <script> <Leader>s :<c-u>call <SID>Spacer(line("'<"), line("'>"),0)<cr>
" DrawItStart: set up drawing mode mappings (Charles Campbell) {{{3
" \pa ... \pz : blanks are transparent
" \ra ... \rz : blanks copy over
vmap <buffer> <silent> <Leader>e :<c-u>call <SID>CallBox('DrawEllipse')<CR>
let allreg= "abcdefghijklmnopqrstuvwxyz"
while strlen(allreg) > 0
let ireg= strpart(allreg,0,1)
exe "nmap <silent> <buffer> <Leader>p".ireg.' :<c-u>set lz<cr>:silent! call <SID>PutBlock("'.ireg.'",0)<cr>:set nolz<cr>'
exe "nmap <silent> <buffer> <Leader>r".ireg.' :<c-u>set lz<cr>:silent! call <SID>PutBlock("'.ireg.'",1)<cr>:set nolz<cr>'
let allreg= strpart(allreg,1)
endwhile
" DrawItStart: mouse maps (Sylvain Viart) {{{3
" start visual-block with leftmouse
nnoremap <silent> <buffer> <script> <leftmouse> <leftmouse>:call <SID>LeftStart()<CR><c-v>
vnoremap <silent> <buffer> <script> <rightmouse> <leftmouse>:<c-u>call <SID>RightStart(1)<cr>
vnoremap <silent> <buffer> <script> <middlemouse> <leftmouse>:<c-u>call <SID>RightStart(0)<cr>
vnoremap <silent> <buffer> <script> <c-leftmouse> <leftmouse>:<c-u>call <SID>CLeftStart()<cr>
" DrawItStart: mouse maps (Charles Campbell) {{{3
" Draw with current brush
nnoremap <silent> <buffer> <script> <s-leftmouse> <leftmouse>:call <SID>SLeftStart()<CR><c-v>
nnoremap <silent> <buffer> <script> <c-leftmouse> <leftmouse>:call <SID>CLeftStart()<CR><c-v>
" DrawItStart: Menu support {{{3
if has("gui_running") && has("menu") && &go =~# 'm'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Stop\ \ DrawIt<tab>\\ds <Leader>ds'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Toggle\ Erase\ Mode<tab><space> <space>'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Arrow<tab>\\a <Leader>a'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Box<tab>\\b <Leader>b'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Make\ Blank\ Zone<tab>\\c <Leader>c'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Ellipse<tab>\\e <Leader>e'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Flood<tab>\\e <Leader>f'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Line<tab>\\l <Leader>l'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Append\ Blanks<tab>\\s <Leader>s'
exe 'silent! unmenu '.g:DrChipTopLvlMenu.'DrawIt.Start\ DrawIt'
endif
" call Dret("DrawItStart")
endfun
" ---------------------------------------------------------------------
" DrawIt#DrawItStop: this function unmaps the cursor keys and restores settings {{{2
fun! DrawIt#DrawItStop()
" call Dfunc("DrawItStop()")
" DrawItStop: report on [DrawIt off] mode {{{3
if !exists("b:dodrawit")
echo "[DrawIt off]"
" call Dret("DrawItStop")
return
endif
" DrawItStop: restore mouse {{{3
if exists("b:drawit_keep_mouse")
let &mouse= b:drawit_keep_mouse
unlet b:drawit_keep_mouse
endif
unlet b:dodrawit
echo "[DrawIt off]"
if exists("b:drawit_canvas_used")
" DrawItStop: clean up trailing white space {{{3
call s:SavePosn()
silent! %s/\s\+$//e
unlet b:drawit_canvas_used
call s:RestorePosn()
endif
" DrawItStop: remove drawit commands {{{3
delc SetBrush
" DrawItStop: insure that erase mode is off {{{3
" (thanks go to Gary Johnson for this)
if b:di_erase == 1
call s:DrawErase()
endif
" DrawItStop: restore user map(s), if any {{{3
call RestoreUserMaps("DrawIt")
call s:DrawItRestoreUserSettings()
" DrawItStop: DrChip menu support: {{{3
if has("gui_running") && has("menu") && &go =~# 'm'
exe 'menu '.g:DrChipTopLvlMenu.'DrawIt.Start\ DrawIt<tab>\\di <Leader>di'
exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Stop\ \ DrawIt'
exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Toggle\ Erase\ Mode'
exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Arrow'
exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Box'
exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Ellipse'
exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Flood'
exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Draw\ Line'
exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Make\ Blank\ Zone'
exe 'unmenu '.g:DrChipTopLvlMenu.'DrawIt.Append\ Blanks'
endif
" call Dret("DrawItStop")
endfun
" ---------------------------------------------------------------------
" s:DrawItSaveUserSettings: saves user settings, changes them to be safe for DrawIt {{{2
" Use s:DrawItRestoreUserSettings() to restore.
fun! s:DrawItSaveUserSettings()
" call Dfunc("s:DrawItSaveUserSettings()")
" save user settings
let b:di_aikeep = &l:ai
let b:di_cedit = &cedit
let b:di_cinkeep = &l:cin
let b:di_cpokeep = &l:cpo
let b:di_etkeep = &l:et
let b:di_fokeep = &l:fo
let b:di_gdkeep = &l:gd
let b:di_gokeep = &l:go
let b:di_magickeep = &l:magic
let b:di_remapkeep = &l:remap
let b:di_repkeep = &l:report
let b:di_sikeep = &l:si
let b:di_stakeep = &l:sta
let b:di_vekeep = &l:ve
" change user settings to something safe for DrawIt
setl cpo&vim
setl nocin noai nosi nogd sta et ve=all report=10000
setl go-=aA
setl fo-=a
setl remap magic
set cedit&
" call Dret("s:DrawItSaveUserSettings")
endfun
" ---------------------------------------------------------------------
" s:DrawItRestoreUserSettings: restore user settings {{{2
fun! s:DrawItRestoreUserSettings()
" call Dfunc("s:DrawItRestoreUserSettings()")
" restore user's settings
let &l:ai = b:di_aikeep
let &l:cin = b:di_cinkeep
let &l:cpo = b:di_cpokeep
let &l:et = b:di_etkeep
let &l:fo = b:di_fokeep
let &l:gd = b:di_gdkeep
let &l:go = b:di_gokeep
let &l:magic = b:di_magickeep
let &l:remap = b:di_remapkeep
let &l:report = b:di_repkeep
let &l:si = b:di_sikeep
let &l:sta = b:di_stakeep
let &l:ve = b:di_vekeep
unlet b:di_aikeep
unlet b:di_cinkeep
unlet b:di_cpokeep
unlet b:di_etkeep
unlet b:di_fokeep
unlet b:di_gdkeep
unlet b:di_gokeep
unlet b:di_magickeep
unlet b:di_remapkeep
unlet b:di_repkeep
unlet b:di_sikeep
unlet b:di_stakeep
unlet b:di_vekeep
" call Dret("s:DrawItRestoreUserSettings")
endfun
" ---------------------------------------------------------------------
" DrawIt#SetMode: sets normal, single, double drawing mode, and ensures that DrawIt mode is on {{{2
fun! DrawIt#SetMode(mode)
" call Dfunc("DrawIt#SetMode(mode=".a:mode.")")
if &enc == 'utf-8' || &enc == 'cp437' || &enc == 'utf-16' || &enc == 'ucs-4'
let b:di_gfxchr= 1
else
let b:di_gfxchr= 0
endif
if b:di_gfxchr == 0
let g:drawit_mode= 'N'
elseif &enc != 'utf-8' && &enc != 'cp437' && &enc != 'utf-16' && &enc != 'ucs-4'
let g:drawit_mode = 'N'
let b:di_gfxchr = 0
elseif a:mode =~ '^[sS]$'
let g:drawit_mode= 'S'
elseif a:mode =~ '^[dD]$'
let g:drawit_mode= 'D'
else
let g:drawit_mode = 'N'
let b:di_gfxchr = 0
endif
if !exists("b:dodrawit") || b:dodrawit == 0
call DrawIt#DrawItStart()
endif
" call Dret("DrawIt#SetMode")
endfun
" ---------------------------------------------------------------------
" SetDrawIt: this function allows one to change the drawing characters {{{2
fun! SetDrawIt(di_vert,di_horiz,di_plus,di_upleft,di_upright,di_cross,di_ellipse)
" call Dfunc("SetDrawIt(vert<".a:di_vert."> horiz<".a:di_horiz."> plus<".a:di_plus."> upleft<".a:di_upleft."> upright<".a:di_upright."> cross<".a:di_cross."> ellipse<".a:di_ellipse.">)")
let b:di_vert = a:di_vert
let b:di_horiz = a:di_horiz
let b:di_plus = a:di_plus
let b:di_upleft = a:di_upleft
let b:di_upright = a:di_upright
let b:di_cross = a:di_cross
let b:di_ellipse = a:di_ellipse
" call Dret("SetDrawIt")
endfun
" =====================================================================
" s:DrawLeft: {{{2
fun! s:DrawLeft()
" call Dfunc("s:DrawLeft()")
let curline = getline(".")
let curcol = virtcol(".")
let b:lastdir = 2
let keepatat = @@
" call Decho("curcol#".curcol." curline<".curline.">")
if curcol > 0
norm! vy
let curchar= @@
" call Decho("curchar<".curchar.">")
" let curchar = strpart(curline,curcol-1,1)
" step1: Replace
" step2: Move and Replace
let step= 1
while step <= 2
" call Decho("step#".step)
if step == 2
if curcol < 2
break
endif
" call Decho("move and replace: curchar<".curchar."> mode<".g:drawit_mode.">")
call s:MoveLeft()
norm! vy
let curchar= @@
" call Decho("curchar<".curchar.">")
else
" call Decho("replace: curchar<".curchar."> mode<".g:drawit_mode.">")
endif
if s:IsDrawItH(curchar)
if g:drawit_mode == 'S'
exe "norm! r".b:di_Splus
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dplus
else
exe "norm! r".b:di_plus
endif
else
if g:drawit_mode == 'S'
exe "norm! r".b:di_Shoriz
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dhoriz
else
exe "norm! r".b:di_horiz
endif
endif
let step= step + 1
endwhile
norm! l
call s:DrawCorner()
norm! h
call s:DrawCorner()
endif
let @@= keepatat
" call Dret("s:DrawLeft")
endfun
" ---------------------------------------------------------------------
" s:DrawRight: {{{2
fun! s:DrawRight()
" call Dfunc("s:DrawRight()")
let curline = getline(".")
let curcol = virtcol(".")
let b:lastdir = 1
let keepatat = @@
norm! vy
let curchar= @@
" call Decho("curchar<".curchar.">")
" replace
if curcol == virtcol("$")
if g:drawit_mode == 'S'
exe "norm! a".b:di_Shoriz."\<Esc>"
elseif g:drawit_mode == 'D'
exe "norm! a".b:di_Dhoriz."\<Esc>"
else
exe "norm! a".b:di_horiz."\<Esc>"
endif
else
if s:IsDrawItH(curchar)
if g:drawit_mode == 'S'
exe "norm! r".b:di_Splus
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dplus
else
exe "norm! r".b:di_plus
endif
else
if g:drawit_mode == 'S'
exe "norm! r".b:di_Shoriz
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dhoriz
else
exe "norm! r".b:di_horiz
endif
endif
endif
" move and replace
call s:MoveRight()
if curcol == virtcol("$")
if g:drawit_mode == 'S'
exe "norm! i".b:di_Shoriz."\<Esc>"
elseif g:drawit_mode == 'D'
exe "norm! i".b:di_Dhoriz."\<Esc>"
else
exe "norm! i".b:di_horiz."\<Esc>"
endif
else
norm! vy
let curchar= @@
" call Decho("curchar<".curchar.">")
if s:IsDrawItH(curchar)
if g:drawit_mode == 'S'
exe "norm! r".b:di_Splus
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dplus
else
exe "norm! r".b:di_plus
endif
else
if g:drawit_mode == 'S'
exe "norm! r".b:di_Shoriz
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dhoriz
else
exe "norm! r".b:di_horiz
endif
endif
endif
norm! h
call s:DrawCorner()
norm! l
call s:DrawCorner()
let @@= keepatat
" call Dret("s:DrawRight")
endfun
" ---------------------------------------------------------------------
" s:DrawUp: {{{2
fun! s:DrawUp()
" call Dfunc("s:DrawUp()")
let curline = getline(".")
let curcol = virtcol(".")
let b:lastdir = 3
let keepatat = @@
norm! vy
let curchar = @@
" call Decho("curchar<".curchar.">")
" replace
if curcol == 1 && virtcol("$") == 1
" call Decho("case curcol#".curcol."==virtcol($): insert")
if g:drawit_mode == 'S'
exe "norm! i".b:di_Svert."\<Esc>"
elseif g:drawit_mode == 'D'
exe "norm! i".b:di_Dvert."\<Esc>"
else
exe "norm! i".b:di_vert."\<Esc>"
endif
else
" call Decho("case curcol#".curcol."!=virtcol($) curchar<".curchar.">: replace")
if s:IsDrawItV(curchar)
if g:drawit_mode == 'S'
exe "norm! r".b:di_Splus
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dplus
else
exe "norm! r".b:di_plus
endif
else
if g:drawit_mode == 'S'
exe "norm! r".b:di_Svert
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dvert
else
exe "norm! r".b:di_vert
endif
endif
endif
" move and replace/insert
call s:MoveUp()
let curline= getline(".")
" let curchar= strpart(curline,curcol-1,1)
norm! vy
let curchar= @@
if curcol == 1 && virtcol("$") == 1
if g:drawit_mode == 'S'
exe "norm! i".b:di_Svert."\<Esc>"
elseif g:drawit_mode == 'D'
exe "norm! i".b:di_Dvert."\<Esc>"
else
exe "norm! i".b:di_vert."\<Esc>"
endif
elseif s:IsDrawItV(curchar)
if g:drawit_mode == 'S'
exe "norm! r".b:di_Splus
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dplus
else
exe "norm! r".b:di_plus
endif
else
if g:drawit_mode == 'S'
exe "norm! r".b:di_Svert
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dvert
else
exe "norm! r".b:di_vert
endif
endif
norm! j
call s:DrawCorner()
norm! k
call s:DrawCorner()
let @@= keepatat
" call Dret("s:DrawUp")
endfun
" ---------------------------------------------------------------------
" s:DrawDown: {{{2
fun! s:DrawDown()
" call Dfunc("s:DrawDown()")
let curline = getline(".")
let curcol = virtcol(".")
let keepatat = @@
norm! vy
let curchar = @@
" call Decho("curchar<".curchar.">")
let b:lastdir = 4
" replace
if curcol == 1 && virtcol("$") == 1
" call Decho("curcol=".curcol." $=1"
if g:drawit_mode == 'S'
exe "norm! i".b:di_Svert."\<Esc>"
elseif g:drawit_mode == 'D'
exe "norm! i".b:di_Dvert."\<Esc>"
else
exe "norm! i".b:di_vert."\<Esc>"
endif
else
norm! vy
let curchar= @@
" call Decho("curchar<".curchar.">")
if s:IsDrawItV(curchar)
if g:drawit_mode == 'S'
exe "norm! r".b:di_Splus
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dplus
else
exe "norm! r".b:di_plus
endif
else
if g:drawit_mode == 'S'
exe "norm! r".b:di_Svert
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dvert
else
exe "norm! r".b:di_vert
endif
endif
endif
" move and replace/insert
call s:MoveDown()
let curline= getline(".")
norm! vy
let curchar= @@
" call Decho("curchar<".curchar.">")
if curcol == 1 && virtcol("$") == 1
if g:drawit_mode == 'S'
exe "norm! i".b:di_Svert."\<Esc>"
elseif g:drawit_mode == 'D'
exe "norm! i".b:di_Dvert."\<Esc>"
else
exe "norm! i".b:di_vert."\<Esc>"
endif
elseif s:IsDrawItV(curchar)
if g:drawit_mode == 'S'
exe "norm! r".b:di_Splus
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dplus
else
exe "norm! r".b:di_plus
endif
else
if g:drawit_mode == 'S'
exe "norm! r".b:di_Svert
elseif g:drawit_mode == 'D'
exe "norm! r".b:di_Dvert
else
exe "norm! r".b:di_vert
endif
endif
norm! k
call s:DrawCorner()
norm! j
call s:DrawCorner()
let @@= keepatat
" call Dret("s:DrawDown")
endfun
" ---------------------------------------------------------------------
" s:DrawCorner: change a ┼ or a ╬ into an appropriate corner {{{2
fun! s:DrawCorner()
" call Dfunc("s:DrawCorner()")
let keepatat= @@
norm! vy
let ctr= @@
if ctr != b:di_Splus && ctr != b:di_Dplus
let @@= keepatat
" call Dret("s:DrawCorner : ctr<".ctr."> (quick return)")
return
endif
" cleft: Grab a copy of the character to the left of the cursor
if virtcol(".") > 1
norm! hvyl
let cleft= @@
else
let cleft= " "
endif
" cright: Grab a copy of the character to the right of the cursor
if virtcol(".") < virtcol("$")
norm! lvyh
let cright= @@
else
let cright= " "
endif
" cup: Grab a copy of the character above the cursor
if line(".") > 1
norm! kvyj
let cup= @@
else
let cup= " "
endif
" cdown: Grab a copy of the character below the cursor
if line(".") < line("$")
norm! jvyk
let cdown= @@
else
let cdown= " "
endif
" call Decho("ctr<".ctr."> cup<".cup."> cright<".cright."> cdown<".cdown."> cleft<".cleft.">")
" - MIXED SINGLE-DOUBLE CORNERS ----------------------------------------
" ┼═ ╬═ ╒═
" │ │ │
if !s:IsDnS(cup)
\ && s:IsLeftD(cright)
\ && s:IsUpS(cdown)
\ && !s:IsRightD(cleft)
exe "norm! r".b:di_cSdDr
" ┼─ ╬─ ╓─
" ║ ║ ║
elseif !s:IsDnD(cup)
\ && s:IsLeftS(cright)
\ && s:IsUpD(cdown)
\ && !s:IsRightS(cleft)
exe "norm! r".b:di_cDdSr
" ═┼ ═╬ ═╕
" │ │ │
elseif !s:IsDnS(cup)
\ && !s:IsLeftD(cright)
\ && s:IsUpS(cdown)