-
Notifications
You must be signed in to change notification settings - Fork 2
/
comm1.c
2684 lines (2496 loc) · 78.5 KB
/
comm1.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
/***********************************************************************/
/* COMM1.C - Commands A-C */
/* This file contains all commands that can be assigned to function */
/* keys or typed on the command line. */
/***********************************************************************/
/*
* THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
* Copyright (C) 1991-2013 Mark Hessling
*
* 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 of
* the License, or 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, Inc.
* 675 Mass Ave,
* Cambridge, MA 02139 USA.
*
*
* If you make modifications to this software that you feel increases
* it usefulness for the rest of the community, please email the
* changes, enhancements, bug fixes as well as any and all ideas to me.
* This software is going to be maintained and enhanced as deemed
* necessary by the community.
*
* Mark Hessling, [email protected] http://www.rexx.org/
*/
#include <the.h>
#include <proto.h>
/*#define DEBUG 1*/
/*man-start*********************************************************************
========================================================================
COMMAND REFERENCE
========================================================================
**man-end**********************************************************************/
/*man-start*********************************************************************
COMMAND
add - add blank line
SYNTAX
Add [n]
DESCRIPTION
The ADD command inserts 'n' blank lines after the <current line>,
if issued from the <command line> or after the <focus line>,
if issued from the <filearea> or <prefix area>.
If <SET NEWLINES> is set to ALIGNED, the cursor is positioned in
the column corresponding to the first column not containing a
space in the line above.
If <SET NEWLINES> is set to LEFT, the cursor is positioned in the
first column.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
DEFAULT
1
SEE ALSO
<SOS ADDLINE>
STATUS
Complete
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Add(CHARTYPE *params)
#else
short Add(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
#define ADD_PARAMS 1
CHARTYPE *word[ADD_PARAMS+1];
CHARTYPE strip[ADD_PARAMS];
unsigned short num_params=0;
LINETYPE num_lines=0L;
TRACE_FUNCTION("comm1.c: Add");
/*
* Validate the parameters that have been supplied. The one and only
* parameter should be a positive integer greater than zero.
* If no parameter is supplied, 1 is assumed.
*/
strip[0]=STRIP_BOTH;
num_params = param_split(params,word,ADD_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
if (num_params == 0)
{
num_params = 1;
word[0] = (CHARTYPE *)"1";
}
if (num_params != 1)
{
display_error(1,word[1],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
if (!valid_positive_integer(word[0]))
{
display_error(4,word[0],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
num_lines = atol((DEFCHAR *)word[0]);
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
insert_new_line( current_screen, CURRENT_VIEW, (CHARTYPE *)"", 0, num_lines, get_true_line(TRUE), FALSE, FALSE, TRUE, CURRENT_VIEW->display_low, TRUE, FALSE );
if (curses_started
&& CURRENT_VIEW->current_window == WINDOW_COMMAND)
THEcursor_home( current_screen, CURRENT_VIEW, TRUE );
TRACE_RETURN();
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
alert - display a user configurable dialog box with notification
SYNTAX
ALERT /prompt/ [EDITfield [/val/]] [TITLE /title/] [OK|OKCANCEL|YESNO|YESNOCANCEL] [DEFBUTTON n]
DESCRIPTION
The ALERT command is identical to the <DIALOG> command except that
if <SET BEEP> is on, a beep is played.
On exit from the ALERT command, the following Rexx variables are set:
ALERT.0 - 2
ALERT.1 - value of 'EDITfield'
ALERT.2 - button selected as specified in the call to the command.
The colours for the alert box are the same as for a dialog box, except
the prompt area which uses the colour set by <SET COLOR> ALERT.
COMPATIBILITY
XEDIT: N/A
KEDIT: Compatible. Does not support bitmap icons or font options.
SEE ALSO
<POPUP>, <DIALOG>, <READV>, <SET COLOR>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Alert(CHARTYPE *params)
#else
short Alert(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
TRACE_FUNCTION("comm2.c: Alert");
/*
* If we have a beep() functiond and its ON, ring it..
*/
#ifdef HAVE_BEEP
if ( BEEPx )
beep();
#endif
rc = prepare_dialog( params, TRUE, (CHARTYPE *)"ALERT" );
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
all - select and display restricted set of lines
SYNTAX
ALL [rtarget]
DESCRIPTION
The ALL command allows for the selective display, and editing
(subject to <SET SCOPE>) of lines that match the specified target.
This target consists of any number of individual targets
separated by '&' (logical and) or '|' (logical or).
For example, to display all lines in a file that contain the
strings 'ball' and 'cat' on the same line or the named lines
.fred or .bill, use the following command
ALL /ball/ & /cat/ | .fred | .bill
Logical operators act left to right, with no precedence for &.
<rtarget> can also be specified as a regular expression. The syntax of
this is "Regexp /re/". eg ALL R /[0-9].*$/
ALL without any arguments, is the equivalent of setting the
selection level of all lines in your file to 0 and running
<SET DISPLAY> 0 0.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<SET SCOPE>, <SET DISPLAY>, <SET SELECT>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short All(CHARTYPE *params)
#else
short All(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
LINE *curr=NULL;
bool target_found=FALSE;
short status=RC_OK;
long target_type=TARGET_NORMAL|TARGET_REGEXP;
TARGET target;
LINETYPE line_number=0L;
unsigned short x=0,y=0;
bool save_scope=FALSE;
LINETYPE num_lines=0L;
TRACE_FUNCTION( "comm1.c: All" );
if ( strlen( (DEFCHAR *)params ) == 0 )
{
if ( CURRENT_FILE->number_lines == 0L )
{
TRACE_RETURN();
return(rc);
}
post_process_line( CURRENT_VIEW, CURRENT_VIEW->focus_line, (LINE *)NULL, TRUE );
curr = CURRENT_FILE->first_line->next;
while( 1 )
{
curr->select = 0;
curr = curr->next;
if ( curr->next == NULL )
break;
}
CURRENT_VIEW->display_low = 0;
CURRENT_VIEW->display_high = 0;
build_screen( current_screen );
display_screen( current_screen );
TRACE_RETURN();
return(rc);
}
if ( CURRENT_FILE->number_lines == 0L )
{
display_error( 17, params, FALSE );
TRACE_RETURN();
return(RC_TARGET_NOT_FOUND);
}
/*
* Validate the parameters as valid targets...
*/
initialise_target( &target );
rc = parse_target( params, get_true_line( TRUE ), &target, target_type, TRUE, TRUE, FALSE );
if ( rc != RC_OK )
{
free_target( &target );
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*
* Save the select levels for all lines in case no target is found.
*/
curr = CURRENT_FILE->first_line->next;
while( 1 )
{
curr->save_select = curr->select;
curr = curr->next;
if ( curr->next == NULL )
break;
}
/*
* Find all lines for the supplied target...
*/
curr = CURRENT_FILE->first_line;
status = FALSE;
save_scope = CURRENT_VIEW->scope_all;
CURRENT_VIEW->scope_all = TRUE;
/*
* Tell the target finding stuff we are the TAG command...
*/
target.all_tag_command = TRUE;
for ( line_number = 0L; curr->next != NULL; line_number++ )
{
status = find_rtarget_target( curr, &target, 0L, line_number, &num_lines );
if ( status == RC_OK ) /* target found */
{
target_found = TRUE;
curr->select = 1;
}
else if ( status == RC_TARGET_NOT_FOUND ) /* target not found */
{
curr->select = 0;
}
else /* error */
break;
curr = curr->next;
}
/*
* If at least one line matches the target, set DISPLAY to 1 1,
* otherwise reset the select levels as they were before the command.
*/
if ( target_found )
{
post_process_line( CURRENT_VIEW, CURRENT_VIEW->focus_line, (LINE *)NULL, TRUE );
CURRENT_VIEW->display_low = 1;
CURRENT_VIEW->display_high = 1;
CURRENT_VIEW->scope_all = FALSE;
CURRENT_VIEW->current_line = find_next_in_scope( CURRENT_VIEW, CURRENT_FILE->first_line->next, 1L, DIRECTION_FORWARD );
build_screen( current_screen );
display_screen( current_screen );
CURRENT_VIEW->focus_line = calculate_focus_line( CURRENT_VIEW->focus_line, CURRENT_VIEW->current_line );
pre_process_line( CURRENT_VIEW, CURRENT_VIEW->focus_line, (LINE *)NULL );
if ( CURRENT_VIEW->current_window != WINDOW_COMMAND )
{
getyx( CURRENT_WINDOW, y, x );
y = get_row_for_focus_line( current_screen, CURRENT_VIEW->focus_line, CURRENT_VIEW->current_row );
wmove( CURRENT_WINDOW, y, x );
}
/*
* If the same file is in the other screen, refresh it
*/
adjust_other_screen_shadow_lines();
}
else
{
CURRENT_VIEW->scope_all = save_scope;
curr = CURRENT_FILE->first_line->next;
while( 1 )
{
curr->select = curr->save_select;
curr = curr->next;
if ( curr->next == NULL )
break;
}
if ( status == RC_TARGET_NOT_FOUND )
{
display_error( 17, params, FALSE );
rc = RC_TARGET_NOT_FOUND;
}
else
rc = status;
}
free_target( &target );
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
backward - scroll backward by number of screens or lines
SYNTAX
BAckward [n|*|HALF] [Lines]
DESCRIPTION
The BACKWARD command scrolls the file contents backwards 'n' screens
or 'n' lines if the optional 'Lines' argument is specified.
If '*' is specified, the <Top-File line> becomes the <current line>.
If 'HALF' is specified, the file contents are scrolled one half of a screen.
If 0 is specified as the number of lines or screens to scroll, the last
line of the file becomes the <current line>.
If the BACKWARD command is issued while the current line is the
<Top-of-File line> and <SET PAGEWRAP> is ON, the last line of the file becomes
the <current line>.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible
DEFAULT
1
SEE ALSO
<FORWARD>, <TOP>, <SET PAGEWRAP>
STATUS
Complete
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Backward(CHARTYPE *params)
#else
short Backward(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
#define BAC_PARAMS 2
CHARTYPE *word[BAC_PARAMS+1];
CHARTYPE strip[BAC_PARAMS];
unsigned short num_params=0;
LINETYPE num_pages=0L;
short scroll_by_page = 1; /* by default we scroll pages */
short rc=RC_OK;
TRACE_FUNCTION("comm1.c: Backward");
/*
* Validate parameters...
*/
strip[0]=STRIP_BOTH;
strip[1]=STRIP_BOTH;
num_params = param_split(params,word,BAC_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
switch( num_params )
{
case 0:
num_pages = 1;
break;
case 1:
/*
* If parameter is '*', set current line equal to "Top of File".
*/
if (strcmp((DEFCHAR *)word[0],"*") == 0)
{
rc = Top((CHARTYPE *)"");
TRACE_RETURN();
return(rc);
}
/*
* If parameter is 'HALF', advance half a page
*/
else if (equal((CHARTYPE *)"HALF",word[0],4))
{
scroll_by_page = 0;
num_pages = CURRENT_SCREEN.rows[WINDOW_FILEAREA] / 2;
}
/*
* If the parameter is not a valid positive integer, error.
*/
else if (!valid_positive_integer(word[0]))
{
display_error(1,(CHARTYPE *)word[0],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
else
{
/*
* Number of screens to scroll is set here.
*/
num_pages = atol((DEFCHAR *)word[0]);
}
break;
case 2:
if (equal((CHARTYPE *)"Lines",word[1],1))
{
scroll_by_page = 0;
if (!valid_positive_integer(word[0]))
{
display_error(1,(CHARTYPE *)word[0],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
}
else
{
display_error(1,(CHARTYPE *)word[1],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
num_pages = atol((DEFCHAR *)word[0]);
break;
default:
display_error(2,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
break;
}
/*
* If the current line is already on "Top of File" or the parameter is
* 0, go to the bottom of the file.
*/
if ( num_pages == 0
|| ( CURRENT_TOF && PAGEWRAPx ) )
{
rc = Bottom((CHARTYPE *)"");
TRACE_RETURN();
return(rc);
}
/*
* Scroll the screen num_pages...
*/
if ( scroll_by_page )
{
rc = scroll_page(DIRECTION_BACKWARD,num_pages,FALSE);
}
else
{
rc = advance_current_line(-num_pages);
}
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
bottom - move to the bottom of the file
SYNTAX
Bottom
DESCRIPTION
The BOTTOM command moves to the very end of the current file.
The last line of the file is set to the <current line>.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<FORWARD>, <TOP>
STATUS
Complete
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Bottom(CHARTYPE *params)
#else
short Bottom(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
unsigned short x=0,y=0;
TRACE_FUNCTION("comm1.c: Bottom");
/*
* No arguments are allowed; error if any are present.
*/
if (strcmp((DEFCHAR *)params,"") != 0)
{
display_error(1,(CHARTYPE *)params,FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
if (CURRENT_VIEW->scope_all)
CURRENT_VIEW->current_line = CURRENT_FILE->number_lines;
else
CURRENT_VIEW->current_line = find_next_in_scope(CURRENT_VIEW,CURRENT_FILE->last_line->prev,CURRENT_FILE->number_lines,DIRECTION_BACKWARD);
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
build_screen(current_screen);
if (!line_in_view(current_screen,CURRENT_VIEW->focus_line))
CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
if (curses_started)
{
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
getyx(CURRENT_PREV_WINDOW,y,x);
else
getyx(CURRENT_WINDOW,y,x);
display_screen(current_screen);
y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,
CURRENT_VIEW->current_row);
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
wmove(CURRENT_PREV_WINDOW,y,x);
else
wmove(CURRENT_WINDOW,y,x);
}
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
cancel - quit from all unaltered files in the ring
SYNTAX
CANcel
DESCRIPTION
The CANCEL command exits from THE quickly by executing a <QQUIT>
command for every file in the ring that does not have any
outstanding alterations.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<CCANCEL>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cancel(CHARTYPE *params)
#else
short Cancel(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
VIEW_DETAILS *save_current_view=(VIEW_DETAILS *)NULL;
LINETYPE save_number_of_files=number_of_files;
VIEW_DETAILS **save_view;
register int i=0;
TRACE_FUNCTION( "comm1.c: Cancel" );
/*
* No arguments are allowed; error if any are present.
*/
if ( strcmp( (DEFCHAR *)params, "" ) != 0 )
{
display_error( 1, (CHARTYPE *)params, FALSE );
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
post_process_line( CURRENT_VIEW, CURRENT_VIEW->focus_line, (LINE *)NULL, TRUE );
if ( ( save_view = (VIEW_DETAILS **)(*the_malloc)( (save_number_of_files) * sizeof(VIEW_DETAILS *) ) ) == NULL )
{
display_error( 30, (CHARTYPE *)"", FALSE );
TRACE_RETURN();
return(RC_OUT_OF_MEMORY);
}
/*
* Setthe numbr o screens to 1; stops crashes when there are multiple
* screens. A hack yes.
*/
THEScreen( (CHARTYPE *)"1" );
CURRENT_VIEW = vd_first;
for ( i = 0; i < save_number_of_files; i++ )
{
save_view[i] = CURRENT_VIEW;
CURRENT_VIEW = CURRENT_VIEW->next;
}
CURRENT_VIEW = vd_first;
for ( i = 0; i < save_number_of_files; i++ )
{
CURRENT_VIEW = save_view[i];
if ( CURRENT_FILE->save_alt == 0 )
free_view_memory( TRUE, FALSE );
}
save_current_view = CURRENT_VIEW = vd_first;
(*the_free)( save_view );
if ( save_current_view != (VIEW_DETAILS *)NULL )
{
CURRENT_VIEW = save_current_view;
CURRENT_SCREEN.screen_view = CURRENT_VIEW;
pre_process_line( CURRENT_VIEW, CURRENT_VIEW->focus_line, (LINE *)NULL );
build_screen( current_screen );
display_screen( current_screen );
if ( curses_started )
{
if ( CURRENT_WINDOW_PREFIX != NULL )
touchwin( CURRENT_WINDOW_PREFIX );
if ( CURRENT_WINDOW_COMMAND != NULL )
touchwin( CURRENT_WINDOW_COMMAND );
touchwin( CURRENT_WINDOW_FILEAREA );
touchwin( CURRENT_WINDOW );
}
}
if ( number_of_files > 0 )
{
sprintf( (DEFCHAR *)temp_cmd, "%ld file(s) remain with outstanding changes", number_of_files );
display_error( 0, (CHARTYPE *)temp_cmd, TRUE );
}
TRACE_RETURN();
return(QUIT);
}
/*man-start*********************************************************************
COMMAND
cappend - append text after column pointer
SYNTAX
CAppend [text]
DESCRIPTION
The CAPPEND command moves the column pointer to the end of the
focus line and appends the specified 'text'.
If no 'text' is specified, the column pointer moves to the first
trailing space.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<CLAST>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cappend(CHARTYPE *params)
#else
short Cappend(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
TRACE_FUNCTION("comm1.c: Cappend");
rc = column_command(params,COLUMN_CAPPEND);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
ccancel - qquit from all files in the ring
SYNTAX
CCancel
DESCRIPTION
The CCANCEL command exits from THE quickly by executing the <QQUIT>
command for every file in the ring. Any changes made to any of
the files since the last <SAVE> will be lost.
COMPATIBILITY
XEDIT: N/A
KEDIT: N/A
SEE ALSO
<CANCEL>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Ccancel(CHARTYPE *params)
#else
short Ccancel(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
TRACE_FUNCTION("comm1.c: Ccancel");
/*
* No arguments are allowed; error if any are present.
*/
if ( strcmp( (DEFCHAR *)params, "" ) != 0 )
{
display_error( 1, (CHARTYPE *)params, FALSE );
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
CURRENT_VIEW = vd_first;
while ( CURRENT_VIEW != (VIEW_DETAILS *)NULL )
{
free_view_memory( TRUE, FALSE );
}
TRACE_RETURN();
return(QUIT);
}
/*man-start*********************************************************************
COMMAND
cdelete - delete text starting at column pointer
SYNTAX
CDelete [column target]
DESCRIPTION
The CDELETE command deletes characters starting from the current
column pointer for the specified <'column target'>.
If no <'column target'> is specified, the character at the column
pointer is deleted.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cdelete(CHARTYPE *params)
#else
short Cdelete(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
short target_type=TARGET_ABSOLUTE|TARGET_RELATIVE|TARGET_STRING|TARGET_BLANK;
TARGET target;
LENGTHTYPE start_col=0,del_start=0;
unsigned int y=0,x=0;
TRACE_FUNCTION("comm1.c: Cdelete");
/*
* Validate the cursor position...
*/
if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
{
getyx(CURRENT_WINDOW,y,x);
rc = processable_line(CURRENT_VIEW,CURRENT_SCREEN.sl[y].line_number,CURRENT_SCREEN.sl[y].current);
switch(rc)
{
case LINE_SHADOW:
display_error(87,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
break;
/* case LINE_TOF_EOF: MH12 */
case LINE_TOF:
case LINE_EOF:
display_error(36,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
break;
default:
break;
}
}
/*
* Determine at which column to start the search...
*/
switch (CURRENT_VIEW->current_window)
{
case WINDOW_FILEAREA:
start_col = (CURRENT_VIEW->verify_col) + x;
if (start_col > CURRENT_VIEW->zone_end)
start_col = min(max_line_length,CURRENT_VIEW->zone_end+1);
if (start_col < CURRENT_VIEW->zone_start)
start_col = max(1,CURRENT_VIEW->zone_start-1);
break;
case WINDOW_PREFIX:
start_col = max(CURRENT_VIEW->current_column,max(1,CURRENT_VIEW->zone_start));
break;
case WINDOW_COMMAND:
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->current_line,(LINE *)NULL);
start_col = CURRENT_VIEW->current_column;
break;
}
/*
* Validate the parameters as valid targets...
*/
initialise_target(&target);
rc = parse_target(params,(LINETYPE)start_col,&target,target_type,TRUE,TRUE,TRUE);
if (rc != RC_OK)
{
free_target(&target);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*
* Find the valid column target. If found process the command...
*/
if ((find_column_target(rec,rec_len,&target,start_col,TRUE,TRUE)) == RC_OK)
{
CURRENT_VIEW->current_column = start_col;
if (target.num_lines < 0)
{
if (start_col > CURRENT_VIEW->zone_end)
{
start_col--;
target.num_lines++;
}
del_start = start_col+target.num_lines;
(void)memdeln(rec,del_start,rec_len,-target.num_lines);
rec_len = calculate_rec_len( ADJUST_DELETE,rec, rec_len, del_start, -target.num_lines, CURRENT_FILE->trailing );
}
else
{
if (start_col < CURRENT_VIEW->zone_start)
{
start_col++;
target.num_lines--;
}
del_start = start_col-1;
(void)memdeln(rec,del_start,rec_len,target.num_lines);
rec_len = calculate_rec_len( ADJUST_DELETE, rec, rec_len, del_start, target.num_lines, CURRENT_FILE->trailing );
}
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
{
post_process_line(CURRENT_VIEW,CURRENT_VIEW->current_line,(LINE *)NULL,TRUE);
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
}
else
{
rc = THEcursor_column();
}
build_screen(current_screen);
display_screen(current_screen);
}
else
{
if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
{
post_process_line(CURRENT_VIEW,CURRENT_VIEW->current_line,(LINE *)NULL,TRUE);
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
}
}
free_target(&target);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
cfirst - move column pointer to beginning of zone
SYNTAX
CFirst
DESCRIPTION
The CFIRST command moves the column pointer to the beginning of
the zone.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<SET ZONE>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Cfirst(CHARTYPE *params)
#else
short Cfirst(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
bool need_to_redisplay=FALSE;
TRACE_FUNCTION("comm1.c: Cfirst");
/*
* No arguments are allowed; error if any are present.
*/
if (strcmp((DEFCHAR *)params,"") != 0)
{
display_error(1,(CHARTYPE *)params,FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
if (column_in_view(current_screen,CURRENT_VIEW->current_column-1))
need_to_redisplay = TRUE;
CURRENT_VIEW->current_column = CURRENT_VIEW->zone_start;
if (column_in_view(current_screen,CURRENT_VIEW->current_column-1))
need_to_redisplay = TRUE;
if (need_to_redisplay)
display_screen(current_screen);
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
change - change one string to another
SYNTAX
Change [/string1/string2/ [target] [n] [m]]
DESCRIPTION
The CHANGE command changes one string of text to another.
The first parameter to the change command is the old and new
string values, separated by delimiters.
The first non alphabetic character after the 'change' command
is the delimiter.
<'target'> specifies how many lines are to be searched for
occurrences of 'string1' to be changed.
'n' determines how many occurrences of 'string1' are to be
changed to 'string2' on each line. 'n' may be specified as
'*' which will result in all occurrences of 'string1' will
be changed. '*' is equivalent to the current WIDTH of the
line.
'm' determines from which occurrence of 'string1' on the line
changes are to commence.
If no arguments are supplied to the CHANGE command, the last
change command, if any, is re-executed.
COMPATIBILITY
XEDIT: Compatible. ARBCHAR not supported however.
KEDIT: Compatible. ARBCHAR not supported however.
DEFAULT