-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathte.c
1257 lines (974 loc) · 20.5 KB
/
te.c
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
/* te.c
Text editor.
Main module.
Copyright (c) 2015-2021 Miguel Garcia / FloppySoftware
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Notes:
Change TE_VERSION in 'te.h' as required, before compilation.
Changes:
29 Apr 2015 : Start working.
02 May 2015 : Added Amstrad PCW version (te_pcw.c).
03 May 2015 : Added K. Murakami's CP/M emulator for Win32 version (te_em1.c).
04 May 2015 : Added te.h file. Added forced entry. Nice ruler with tab stops.
07 May 2015 : While porting it to Pelles C & Windows 32 bit, it was discovered
collateral efects in 3 pieces of code. Recoded and marked below.
Solved bug in ReadFile() - characters > 0x7F caused 'bad
character' errors.
Added checking for filenames too long in command line.
08 May 2015 : v1.00 : Added BackupFile().
12 May 2015 : v1.01 : Now K_CUT copies the line to the clipboard before deleting it.
14 May 2015 : v1.02 : Added support for word left & word right cursor movement.
You must define K_LWORD and K_RWORD in your CRT_FILE
to activate them.
15 May 2015 : v1.03 : Modified getch & putch to getchr & putchr.
31 Aug 2015 : v1.04 : Minor changes in comments and ReadLine().
02 Jun 2016 : v1.05 : Minor changes.
10 Jun 2016 : v1.06 : Screen optimizations in Menu(). Removed BOX_COL.
Removed lp_max, box_cols, ps_fname, ps_lin_cur, ps_lin_now, ps_lin_max,
ps_col_cur, ps_col_now, ps_col_max.
14 Jun 2016 : v1.07 : Hack for SamaruX.
05 Jul 2017 : v1.08 : Optimizations in NULL comparisons. Include CC_FGETS.
24 Jan 2018 : v1.09 : Added find string and find next string commands.
20 Feb 2018 : v1.10 : Added command to execute macro from file. Split te.c in modules. Added go to line #.
Disable code for macros from strings, for now.
22 Feb 2018 : v1.11 : Ask for confirmation only if changes were not saved.
06 Jan 2019 : Included te_lines module and modified related functions. Added LoopCut(), LoopPaste().
13 Jan 2019 : Included te_misc module. Minor changes.
15 Jan 2019 : Added LoopBlkStart(), LoopBlkEnd(), LoopBlkUnset(), LoopCopy().
18 Jan 2019 : Added K_DELETE, LoopDelete().
19 Jan 2019 : Added LoopUp(), LoopDown().
22 Jan 2019 : Added te_keys module. Added support for key bindings.
27 Jan 2019 : Added support for macros.
29 Jan 2019 : Added K_CLRCLP. Show clipboard status.
30 Jan 2019 : Removed support for SamaruX.
14 Feb 2019 : Added help items layout.
24 Dec 2019 : Added support for line numbers.
26 Dec 2019 : Now K_INTRO is K_CR, LoopIntro() is LoopCr().
01 Mar 2020 : Added fe_forced.
02 Mar 2020 : Added automatic indentation.
08 Mar 2020 : Support for CRT_LONG.
22 Dec 2020 : Add default filetype to macro filenames.
30 Dec 2020 : Solved bug in LoopCr() - bad column position after line break.
Solved bug in LoopDelete() - did nothing if no selection, must delete current line.
Added LoopBlkEx(), LoopDeleteEx().
Added automatic list.
04 Jan 2021 : Use configuration variables.
22 Feb 2021 : Removed CRT_ROWS, CRT_COLS.
04 Apr 2021 : Move key bindings to configuration. Remove customized key names.
30 Jun 2021 : Get CP/M version. Adjust auto rows and columns configuration values.
01 Jul 2021 : Check if macro is running to avoid auto-indentation and lists side effects.
06 Jul 2021 : Optimize LoopCr(), LoopLeftDel(), LoopRightDel() a bit.
25 Sep 2021 : Add editln variable. Use SysLineEdit() when editing.
01 Nov 2021 : Added macro raw mode.
18 Nov 2021 : Added mac_indent, mac_list for AutoIndent, AutoList macros.
20 Nov 2021 : Added mac_sym for macros.
Notes:
See FIX-ME notes.
*/
/* Libraries
---------
*/
#define CC_FGETS
#define CC_FPUTS
#include <mescc.h>
#include <string.h>
#include <ctype.h>
#include <fileio.h>
#include <sprintf.h>
/* TE definitions
--------------
*/
#include "te.h"
#include "te_keys.h"
/* Operating system
----------------
*/
int cpm_ver; /* CP/M version */
/* Array of text lines
-------------------
*/
WORD *lp_arr; /* Text lines pointers array */
int lp_now; /* How many lines are in the array */
int lp_cur; /* Current line */
int lp_chg; /* 0 if no changes are made */
/* Current line
------------
*/
char *ln_dat; /* Data buffer */
int ln_max; /* Max. # of characters */
/* Clipboard & block selection
---------------------------
*/
#if OPT_BLOCK
int blk_start; /* Start line # */
int blk_end; /* End line # */
int blk_count; /* # of lines */
WORD *clp_arr; /* Multi-line */
int clp_count; /* # of lines */
#else
char *clp_line; /* Just one line */
#endif
/* Filename
--------
*/
char file_name[FILENAME_MAX];
/* Editor box
----------
*/
int box_rows; /* Height in lines */
int box_shr; /* Vertical position of cursor in the box (0..box_rows - 1) */
int box_shc; /* Horizontal position of cursor in the box (0..cf_cols - 1) */
/* Keyboard forced entry
---------------------
*/
int *fe_dat; /* Data buffer */
int fe_now; /* How many characters are now in the buffer */
int fe_set; /* Set position */
int fe_get; /* Get position */
int fe_forced; /* Flag: true if forced character on input */
/* System line
-----------
*/
int sysln; /* NZ when written - for Loop() */
/* Edit line
---------
*/
int editln; /* NZ when editing line - for ErrLine() */
#if OPT_FIND
/* Find string
-----------
*/
char find_str[FIND_MAX];
#endif
#if OPT_MACRO
/* Macros
------
*/
FILE *mac_fp; /* FP for a file macro, or NULL */
/*char *mac_str;*/ /* Address for a string macro, or NULL */
int mac_raw; /* NZ for raw mode */
unsigned char mac_indent; /* Value of cf_indent */
unsigned char mac_list; /* Value of cf_list */
char mac_sym[MAC_SYM_SIZ]; /* Macro symbol */
#endif
/* Help items layout
-----------------
*/
int help_items[] = {
K_UP, K_DOWN, K_TAB,
K_LEFT, K_RIGHT, K_CR,
K_BEGIN, K_END, K_ESC,
K_TOP, K_BOTTOM, K_MACRO,
K_PGUP, K_PGDOWN, 0,
K_LWORD, K_RWORD, 0,
K_LDEL, K_RDEL, 0,
K_BLK_START, K_BLK_END, K_BLK_UNSET,
K_CUT, K_COPY, K_PASTE,
K_DELETE, K_CLRCLP, 0,
K_FIND, K_NEXT, K_GOTO,
-1
};
/* TE modules
----------
*/
#include "te_conf.c"
#include "te_ui.c"
#include "te_file.c"
#include "te_keys.c"
#include "te_edit.c"
#include "te_lines.c"
#include "te_misc.c"
#include "te_error.c"
#if OPT_MACRO
#include "te_macro.c"
#endif
/* Program entry
-------------
*/
main(argc, argv)
int argc, argv[];
{
int i;
/* Get CP/M version */
cpm_ver = bdos_a(0x0C, 0x0000);
/* Adjust auto rows and columns configuration values */
cf_rows = GetScrConf(0, cf_rows, CRT_DEF_ROWS);
cf_cols = GetScrConf(1, cf_cols, CRT_DEF_COLS);
/* Setup CRT */
CrtSetup();
/* Setup some globals */
#if CRT_LONG
box_rows = cf_rows - 4;
#else
box_rows = cf_rows - 2;
#endif
/* Max. width of lines */
ln_max = cf_cols - cf_num - 1;
/* Print layout */
Layout();
/* Allocate buffers -- FIXME -- use AllocMem() ?? */
ln_dat = malloc(ln_max + 2);
fe_dat = malloc(FORCED_MAX * SIZEOF_INT);
lp_arr = malloc(cf_mx_lines * SIZEOF_PTR);
i = 1;
if(ln_dat && fe_dat && lp_arr) {
#if OPT_BLOCK
#else
if((clp_line = malloc(ln_max + 1))) {
#endif
i = 0;
#if OPT_BLOCK
#else
}
#endif
}
if(i)
{
ErrLineMem(); CrtReset(); return 1;
}
/* Setup clipboard */
#if OPT_BLOCK
clp_arr = NULL;
clp_count = 0;
#else
*clp_line = '\0';
#endif
/* Setup lines */
for(i = 0; i < cf_mx_lines; ++i) {
lp_arr[i] = NULL;
}
/* Check command line */
if(argc == 1)
{
NewFile();
}
else if(argc == 2)
{
if(strlen(argv[1]) > FILENAME_MAX - 1)
{
ErrLine("Filename too long");
NewFile();
}
else if(ReadFile(argv[1]))
NewFile();
else
strcpy(file_name, argv[1]);
}
else
{
ErrLine("Bad command line. Use: te [filename]");
NewFile();
}
/* Main loop */
Loop();
/* Clear & reset CRT */
CrtClear();
CrtReset();
/* Exit */
return 0;
}
/* Get # of rows / columns on auto configuration value
---------------------------------------------------
*/
GetScrConf(n, val, def_val)
int n, val, def_val;
{
unsigned char scb_pb[2];
if(val == 0) {
val = def_val;
if(cpm_ver >= 0x30) {
scb_pb[0] = (n == 0 ? 0x1C : 0x1A);
scb_pb[1] = 0;
val = bdos_a(0x31, scb_pb) + 1;
}
}
return val;
}
/* Main loop
---------
*/
Loop()
{
int run, ch;
/* Setup forced entry */
fe_now = fe_get = fe_set = 0;
/* Setup more things */
run = sysln = 1;
/* Print filename */
ShowFilename();
/* Refresh editor box */
RefreshAll();
/* Loop */
while(run)
{
/* Refresh system line message if it changed */
if(sysln)
{
SysLineEdit();
sysln = 0;
}
/* Print clipboard status */
CrtLocate(PS_ROW, PS_CLP);
#if OPT_BLOCK
putstr(clp_count ? "CLP" : "---");
#else
putstr(*clp_line ? "CLP" : "---");
#endif
/* Print current line number, etc. */
CrtLocate(PS_ROW, PS_LIN_CUR); putint("%04d", lp_cur + 1);
CrtLocate(PS_ROW, PS_LIN_NOW); putint("%04d", lp_now);
/* Edit the line */
ch = BfEdit();
/* Note: BfEdit() does previous checks for following
actions, to not waste time when an action is not
possible */
/* Check returned control character */
switch(ch)
{
case K_UP : /* Up one line --------------------- */
LoopUp();
break;
case K_DOWN : /* Down one line ------------------- */
LoopDown();
break;
case K_CR : /* Insert CR ----------------------- */
LoopCr();
break;
case K_LDEL : /* Delete CR on the left ----------- */
LoopLeftDel();
break;
case K_RDEL : /* Delete CR on the right ---------- */
LoopRightDel();
break;
case K_PGUP : /* Page up ------------------------- */
LoopPgUp();
break;
case K_PGDOWN :/* Page down ----------------------- */
LoopPgDown();
break;
case K_TOP : /* Top of document ----------------- */
LoopTop();
break;
case K_BOTTOM :/* Bottom of document -------------- */
LoopBottom();
break;
case K_COPY : /* Copy line or block ------------- */
LoopCopy();
break;
case K_CUT : /* Copy and delete line or block -- */
LoopCut();
break;
case K_PASTE : /* Paste line or block ------------ */
LoopPaste();
break;
case K_DELETE : /* Delete line or block ----------- */
LoopDelete();
break;
case K_CLRCLP : /* Clear the clipboard ------------ */
LoopClrClp();
break;
#if OPT_BLOCK
case K_BLK_START : /* Set block start ------------- */
LoopBlkStart();
break;
case K_BLK_END : /* Set block end --------------- */
LoopBlkEnd();
break;
case K_BLK_UNSET : /* Unset block ----------------- */
LoopBlkUnset();
break;
#endif
#if OPT_FIND
case K_FIND : /* Find string --------------------- */
LoopFindFirst();
break;
case K_NEXT : /* Find next string ---------------- */
LoopFindNext();
break;
#endif
#if OPT_GOTO
case K_GOTO : /* Go to line # -------------------- */
LoopGoLine();
break;
#endif
#if OPT_MACRO
case K_MACRO : /* Execute macro from file --------- */
LoopMacro();
break;
#endif
case K_ESC : /* Show the menu ------------------- */
if(Menu()) {
run = 0;
}
else {
ShowFilename(); /* Refresh filename */
RefreshAll(); /* Refresh editor box */
}
break;
}
}
}
/* Go one line up
--------------
*/
LoopUp()
{
--lp_cur; // FIXME -- check if we are on the 1st line?
if(box_shr)
--box_shr;
else
Refresh(0, lp_cur);
}
/* Go one line down
----------------
*/
LoopDown()
{
++lp_cur; // FIXME -- check if we are on the last line?
if(box_shr < box_rows - 1)
++box_shr;
else
Refresh(0, lp_cur - box_rows + 1);
}
/* Go to document top
------------------
*/
LoopTop()
{
int first;
first = GetFirstLine();
lp_cur = box_shr = box_shc = 0;
if(first > 0) {
RefreshAll();
}
}
/* Go to document bottom
---------------------
*/
LoopBottom()
{
int first, last;
first = GetFirstLine();
last = GetLastLine();
lp_cur = lp_now - 1;
box_shc = 999;
if(last < lp_now - 1) {
box_shr = box_rows - 1;
RefreshAll();
}
else {
box_shr = last - first;
}
}
/* Page up
-------
*/
LoopPgUp()
{
int first, to;
first = GetFirstLine();
if(first)
{
if((to = first - box_rows) < 0) /* max(to, 0) */
to = 0;
lp_cur = to; box_shr = box_shc = 0;
RefreshAll();
}
else
LoopTop();
}
/* Page down
---------
*/
LoopPgDown()
{
int to;
if(GetLastLine() < lp_now - 1)
{
to = GetFirstLine() + box_rows;
if(to >= lp_now)
to = lp_now - 1;
lp_cur = to; box_shr = box_shc = 0;
RefreshAll();
}
else
LoopBottom();
}
/* Insert CR
---------
*/
LoopCr()
{
int ok;
int i, k;
if(box_shc) {
if(ln_dat[box_shc]) {
/* Cursor is in the middle of the line */
if((ok = SplitLine(lp_cur, box_shc))) {
CrtClearEol();
}
}
else {
/* Cursor is at the end of the line */
ok = AppendLine(lp_cur, NULL);
}
}
else {
/* Cursor is in first column */
if((ok = InsertLine(lp_cur, NULL))) {
if(ln_dat[0]) {
/* Line is not empty */
CrtClearEol();
}
/* else { */
/* Line is empty */
/* } */
}
}
if(ok) {
++lp_cur;
k = 0;
if(box_shc) {
i = 0;
if(cf_indent) {
while(ln_dat[i] == ' ') {
++i;
}
}
if(cf_list) {
if(strchr(cf_list_chr, ln_dat[i]) && ln_dat[i + 1] == ' ') {
i += 2;
}
}
if(i) {
k = i;
strcpy(ln_dat + i, lp_arr[lp_cur]);
ModifyLine(lp_cur, ln_dat);
}
}
if(box_shr < box_rows - 1) {
++box_shr;
Refresh(box_shr, lp_cur);
}
else {
Refresh(0, lp_cur - box_rows + 1);
}
box_shc = k;
lp_chg = 1;
}
}
#if OPT_BLOCK
/* Set block start
---------------
*/
LoopBlkStart()
{
if(blk_start != -1 || (blk_end != -1 && lp_cur > blk_end)) {
LoopBlkUnset();
}
blk_start = lp_cur;
if(blk_end != -1) {
RefreshBlock(box_shr, 1);
blk_count = blk_end - blk_start + 1;
}
}
/* Set block end
-------------
*/
LoopBlkEnd()
{
if(blk_end != -1 || (blk_start != -1 && lp_cur < blk_start) ) {
LoopBlkUnset();
}
blk_end = lp_cur;
if(blk_start != -1) {
RefreshBlock(0, 1); // FIXME -- optimize
blk_count = blk_end - blk_start + 1;
}
}
/* Unset block
-----------
*/
LoopBlkUnset()
{
if(blk_count) {
if(blk_start <= GetLastLine() && blk_end >= GetFirstLine()) {
RefreshBlock(0, 0); // FIXME -- optimize
}
}
blk_start = blk_end = -1;
blk_count = 0;
}
LoopBlkEx()
{
if(!blk_count) {
blk_start = blk_end = lp_cur;
blk_count = 1;
}
}
#endif
/* Copy line
---------
*/
LoopCopy()
{
#if OPT_BLOCK
LoopBlkEx();
if(LoopCopyEx()) {
LoopBlkUnset();
}
#else
strcpy(clp_line, ln_dat);
#endif
}
#if OPT_BLOCK
LoopCopyEx()
{
int i;
LoopClrClp();
if((clp_arr = AllocMem(blk_count * SIZEOF_PTR))) {
for(i = 0; i < blk_count; ++i) {
if((clp_arr[i] = AllocMem(strlen(lp_arr[blk_start + i]) + 1))) {
strcpy(clp_arr[i], lp_arr[blk_start + i]);
}
else {
FreeArray(clp_arr, i, 1);
return 0;
}
}
clp_count = blk_count;
return 1;
}
return 0;
}
#endif
/* Delete line
-----------
*/
LoopDelete()
{
#if OPT_BLOCK
LoopBlkEx();
LoopDeleteEx();
#else
if(lp_cur != lp_now - 1) {
DeleteLine(lp_cur);
}
else {
ClearLine(lp_cur);
}
Refresh(box_shr, lp_cur);
box_shc = 0;
lp_chg = 1;
#endif
}
#if OPT_BLOCK
LoopDeleteEx()
{
//if(blk_count) {
LoopGo(blk_start);
while(blk_count--) {
if(blk_start != lp_now - 1) {
DeleteLine(blk_start);
}
else {
ClearLine(blk_start);
}
--blk_end;
Refresh(box_shr, lp_cur);
}
blk_start = blk_end = -1;
blk_count = 0;
box_shc = 0;
lp_chg = 1;
//}
}
#endif
/* Copy and delete line
--------------------
*/
LoopCut()
{
#if OPT_BLOCK
LoopBlkEx();
if(LoopCopyEx()) {
LoopDeleteEx();
}
#else
strcpy(clp_line, ln_dat);
LoopDelete();
#endif
}
/* Paste line
----------
*/
LoopPaste()
{
#if OPT_BLOCK
int i;
if(clp_count) {
for(i = 0; i < clp_count; ++i) {
if(InsertLine(lp_cur, clp_arr[i])) {
Refresh(box_shr, lp_cur);
LoopDown();
}
else {
break;
}
}
box_shc = 0;
lp_chg = 1;
}
#else
if((InsertLine(lp_cur, clp_line))) {
Refresh(box_shr, lp_cur);
LoopDown();
box_shc = 0;
lp_chg = 1;
}
#endif
}
/* Clear the clipboard
-------------------
*/
LoopClrClp()
{
#if OPT_BLOCK
if(clp_count) {
FreeArray(clp_arr, clp_count, 1);
clp_count = 0;
}
#else
*clp_line = '\0';
#endif
}
/* Delete CR on the left
---------------------
*/
LoopLeftDel()
{
char *p;
int ok, rs, pos;
if(ln_dat[0]) {
/* Line is not empty */
p = lp_arr[lp_cur - 1];
if(*p) {
/* Previous line is not empty */
pos = strlen(p);
if((ok = JoinLines(lp_cur - 1))) {
rs = 0;
}
}
else {
/* Previous line is empty */
if((ok = DeleteLine(lp_cur - 1))) {