-
Notifications
You must be signed in to change notification settings - Fork 2
/
comm4.c
2871 lines (2580 loc) · 79 KB
/
comm4.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
/***********************************************************************/
/* COMM4.C - Commands P-S */
/* 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>
/*man-start*********************************************************************
COMMAND
popup - display popup menu
SYNTAX
POPUP [MOUSE|TEXT|CENTER|CENTRE|BELOW|ABOVE] [INITIAL n] [ESCAPE keyname] [KEYS keyname,keyname,...] /item1[/item2/...]
DESCRIPTION
The POPUP command allows the user to create and display a popup
menu containing a list of selectable options.
The location of the popup menu is specified by the first parameter.
'MOUSE' specifies that the top left corner of the popup menu is to
be displayed where the mouse cursor currently is displayed. This option
is only valid if the popup window is initiated from a macro assigned to
a mouse event.
'TEXT' specifies that the top left corner of the popup menu is to
be displayed where the text cursor is displayed. If the text starts with
a dash, then a divider line is inserted.
'ABOVE' specifies that the bottom row of the popup window is to be displayed
above the line where the text cursor is displayed. The popup window will use at
most from the line above the text cursor to the top of the screen.
'BELOW' specifies that the top row of the popup window is to be displayed
below the line where the text cursor is displayed. The popup window will use at
most from the line below the text cursor to the bottom of the screen.
'CENTRE' or 'CENTER' specifies that the popup window is centred in the
middle of the screen. This option will use all of the screen to display the
popup window if necessary.
If the location is not specified, then the default is 'CENTRE'
'INITIAL' specifies the item to be highlighted when the popup window
is first displayed. This value must be within the bounds of the items
specified.
'ESCAPE' specifies the keyname that can be used to quit from the popup
window without making a selection. By default 'q' will quit. Only keynames
that are valid with the <DEFINE> command are allowed.
'KEYS' specifies a list of keynames that can be used to exit from the popup
with a selection. Only keynames that are valid with the <DEFINE> command are allowed.
A maximum of 20 keynames can be specified.
On return from the popup menu, the following Rexx variables are set:
popup.0 = 4
popup.1 = Item selected or empty string if no item selected.
popup.2 = Item number selected or zero if no item selected.
popup.3 = Item number on which the cursor was last positioned.
popup.4 = The index into the list of 'KEYS' that terminated the popup or 0 if ENTER used.
If mouse support is available, an item is selectable by clicking
the first mouse button on the item. To quit from the popup window
without making a selection, click the mouse outside the popup
window, or on the border of the window.
Keyboard keys that take effect in the POPUP command are CURU, CURD,
CURL, CURR, PGUP, PGDN and ENTER.
The colours used for the popup are:
Border - <SET COLOR> POPUPBORDER
Non-current line - <SET COLOR> POPUP
Current line - <SET COLOR> POPUPCURLINE
Divider line - <SET COLOR> POPUPDIVIDER
COMPATIBILITY
XEDIT: N/A
KEDIT: KEDIT does not support INITIAL, ESCAPE, KEYS, ABOVE or BELOW options.
SEE ALSO
<DIALOG>, <ALERT>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Popup(CHARTYPE *params)
#else
short Popup(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
TRACE_FUNCTION("comm4.c: Popup");
rc = prepare_popup( params );
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
preserve - save various editor settings
SYNTAX
PREServe
DESCRIPTION
The PRESERVE command saves various editing settings at the time
the command is issued. These settings can then be restored by
using the <RESTORE> command.
The following view level settings are saved:
ARBCHAR
ARROW
CASE
CMDLINE
CURLINE
DISPLAY
HEX
HEXSHOW
HIGHLIGHT
IDLINE
IMPMACRO
IMPOS
INPUTMODE
LINEND
MACRO
MARGINS
MSGLINE
MSGMODE
NEWLINES
NUMBER
POSITION
PREFIX
SCALE
SCOPE
SHADOW
STAY
SYNONYM
TABLINE
TABS
THIGHLIGHT
TOFEOF
VERIFY
VERSHIFT
WORD
WORDWRAP
WRAP
ZONE
The following file level settings are saved:
AUTOSAVE
BACKUP
COLOUR/COLOR
COLOURING/COLORING
ECOLOUR/ECOLOR
EOLOUT
TABSOUT
TRAILING
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<RESTORE>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Preserve(CHARTYPE *params)
#else
short Preserve(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
TRACE_FUNCTION( "comm4.c: Preserve" );
/*
* Don't allow any parameters
*/
if ( !blank_field(params) )
{
display_error( 1, params, FALSE );
TRACE_RETURN();
return( RC_INVALID_OPERAND );
}
rc = execute_preserve( CURRENT_VIEW, &CURRENT_VIEW->preserved_view_details, CURRENT_FILE, &CURRENT_FILE->preserved_file_details );
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
prevwindow - switch focus of editing session to another file
SYNTAX
PREVWindow
DESCRIPTION
The PREVWINDOW command moves the focus of the editing session to
the other screen (if <SET SCREEN> 2 is in effect) or to the previous
file in the <ring>.
COMPATIBILITY
XEDIT: N/A
KEDIT: N/A
SEE ALSO
<NEXTWINDOW>, <EDIT>, <SET SCREEN>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Prevwindow(CHARTYPE *params)
#else
short Prevwindow(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
/*
* must use local variable, NOT a constant as we MyStrip() this later on
* and some compilers give seg fault trying to change a constant
*/
CHARTYPE tmp[2] = { '-', '\0' };
TRACE_FUNCTION("comm4.c: Prevwindow");
if (strcmp((DEFCHAR *)params,"") != 0)
{
display_error(1,params,FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
if (display_screens == 1)
{
rc = Xedit((CHARTYPE *)tmp);
TRACE_RETURN();
return(rc);
}
post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
current_screen = (current_screen == 0) ? 1 : 0;
CURRENT_VIEW = CURRENT_SCREEN.screen_view;
if (curses_started)
{
if (CURRENT_WINDOW_COMMAND != (WINDOW *)NULL)
{
wattrset(CURRENT_WINDOW_COMMAND,set_colour(CURRENT_FILE->attr+ATTR_CMDLINE));
touchwin(CURRENT_WINDOW_COMMAND);
wnoutrefresh(CURRENT_WINDOW_COMMAND);
}
if (CURRENT_WINDOW_ARROW != (WINDOW *)NULL)
{
wattrset(CURRENT_WINDOW_ARROW,set_colour(CURRENT_FILE->attr+ATTR_ARROW));
redraw_window(CURRENT_WINDOW_ARROW);
wnoutrefresh(CURRENT_WINDOW_ARROW);
}
if (statarea != (WINDOW *)NULL)
{
wattrset(statarea,set_colour(CURRENT_FILE->attr+ATTR_STATAREA));
redraw_window(statarea);
}
if (CURRENT_WINDOW_IDLINE != (WINDOW *)NULL)
{
wattrset(CURRENT_WINDOW_IDLINE,set_colour(CURRENT_FILE->attr+ATTR_IDLINE));
redraw_window(CURRENT_WINDOW_IDLINE);
}
if (display_screens > 1
&& !horizontal)
{
wattrset(divider,set_colour(CURRENT_FILE->attr+ATTR_DIVIDER));
draw_divider();
wnoutrefresh(divider);
}
}
pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
build_screen(current_screen);
if (!line_in_view(current_screen,CURRENT_VIEW->focus_line))
{
CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
build_screen(current_screen);
}
display_screen(current_screen);
TRACE_RETURN();
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
print - send text to default printer or print spooler
SYNTAX
PRint [target] [n]
PRint LINE [text]
PRint STRING [text]
PRint FORMfeed
PRint CLOSE
DESCRIPTION
The PRINT command writes a portion of the current file to the default
printer or print spooler, or text entered on the command line.
PRINT [<'target'>] ['n']
Sends text from the file contents up to the <'target'> to the printer
followed by a CR/LF (DOS) or LF(UNIX) after each line.
When ['n'] is specified, this sends a formfeed after ['n'] successive
lines of text.
PRINT 'LINE' ['text']
Sends the remainder of the 'text' on the command line to the printer
followed by a LF(UNIX), CR(MAC) or CR/LF (DOS).
PRINT 'STRING' ['text']
Sends the remainder of the 'text' on the command line to the printer
without any trailing line terminator.
PRINT 'FORMfeed'
Sends a formfeed (^L) character to the printer.
PRINT 'CLOSE'
Closes the printer spooler.
COMPATIBILITY
XEDIT: N/A
KEDIT: Compatible.
SEE ALSO
<SET PRINTER>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Print(CHARTYPE *params)
#else
short Print(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
#define PRT_PARAMS 2
CHARTYPE *word[PRT_PARAMS+1];
CHARTYPE strip[PRT_PARAMS];
unsigned short num_params=0;
short page_break=0;
short rc=RC_OK;
long target_type=TARGET_NORMAL|TARGET_ALL|TARGET_BLOCK_CURRENT|TARGET_SPARE;
TARGET target;
#if defined(UNIX)
CHARTYPE *line_term = (CHARTYPE *)"\n";
#else
CHARTYPE *line_term = (CHARTYPE *)"\n\r";
#endif
TRACE_FUNCTION("comm4.c: Print");
/*
* Under Win32, startup the printing system, the first time this
* command is called. This makes startup of THE faster.
*/
#if defined(WIN32) && !defined(__CYGWIN32__)
if (!StartedPrinter)
{
StartTextPrnt();
StartedPrinter = TRUE;
}
#endif
/*
* Split parameters up...
*/
strip[0]=STRIP_BOTH;
strip[1]=STRIP_NONE;
num_params = param_split(params,word,PRT_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
if (num_params == 0)
{
num_params = 1;
word[0] = (CHARTYPE *)"1";
}
/*
* If first argument is LINE...
*/
if (equal((CHARTYPE *)"line",word[0],4))
{
print_line(FALSE,0L,0L,0,(CHARTYPE *)word[1],line_term,0);
TRACE_RETURN();
return(RC_OK);
}
/*
* If first argument is STRING...
*/
if (equal((CHARTYPE *)"string",word[0],5))
{
print_line(FALSE,0L,0L,0,(CHARTYPE *)word[1],(CHARTYPE *)"",0);
TRACE_RETURN();
return(RC_OK);
}
/*
* If first argument is FORMFEED...
*/
if (equal((CHARTYPE *)"formfeed",word[0],4))
{
if (num_params > 1)
{
display_error(1,word[1],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
print_line(FALSE,0L,0L,0,(CHARTYPE *)"",(CHARTYPE *)"\f",0);
TRACE_RETURN();
return(RC_OK);
}
/*
* If first argument is CLOSE...
*/
if (equal((CHARTYPE *)"close",word[0],5))
{
if (num_params > 1)
{
display_error(1,word[1],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
print_line(TRUE,0L,0L,0,(CHARTYPE *)"",(CHARTYPE *)"",0);
TRACE_RETURN();
return(RC_OK);
}
/*
* ...treat all other options as targets...
*/
initialise_target(&target);
if ((rc = validate_target(params,&target,target_type,get_true_line(TRUE),TRUE,TRUE)) != RC_OK)
{
free_target(&target);
TRACE_RETURN();
return(rc);
}
if (target.spare == (-1))
page_break = 0;
else
{
if (!valid_positive_integer(strtrunc(target.rt[target.spare].string)))
{
display_error(4,word[0],FALSE);
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
page_break = atoi((DEFCHAR *)strtrunc(target.rt[target.spare].string));
}
print_line(FALSE,target.true_line,target.num_lines,page_break,
(CHARTYPE *)"",line_term,target.rt[0].target_type);
free_target(&target);
TRACE_RETURN();
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
put - write part of a file to another
SYNTAX
PUT [target] [filename]
DESCRIPTION
The PUT command writes a portion of the current file, defined by
<'target'> to another file, either explicit or temporary.
When no 'filename' is supplied the temporary file used for <PUT>
and <GET> commands is overwritten.
When a 'filename' is supplied the portion of the file written out
is appended to the specified file.
If 'CLIP:' is used in place of 'filename', the portion of the file
specified by <'target'> is written to the clipboard.
This option only available for X11, OS/2 and Win32 ports of THE.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<PUTD>, <GET>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Put(CHARTYPE *params)
#else
short Put(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
TRACE_FUNCTION( "comm4.c: Put" );
rc = execute_put( params, FALSE );
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
putd - write part of a file to another and delete
SYNTAX
PUTD [target] [filename]
DESCRIPTION
The PUTD command writes a portion of the current file, defined by
<'target'> to another file, either explicit or temporary, and then
deletes the lines written.
When no 'filename' is supplied the temporary file used for <PUT>
and <GET> commands is overwritten.
When a 'filename' is supplied the portion of the file written out
is appended to the specified file.
If 'CLIP:' is used in place of 'filename', the portion of the file
specified by <'target'> is written to the clipboard.
This option only available for X11, OS/2 and Win32 ports of THE.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<PUT>, <GET>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Putd(CHARTYPE *params)
#else
short Putd(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
short rc=RC_OK;
TRACE_FUNCTION( "comm4.c: Putd" );
rc = execute_put( params, TRUE );
TRACE_RETURN();
return(rc);
}
/*man-start*********************************************************************
COMMAND
qquit - exit from the current file without saving changes
SYNTAX
QQuit
DESCRIPTION
The QQUIT command exits the user from the current file, whether
changes made to the file have been saved or not.
The previous file in the <ring> then becomes the current file.
If the current file is the only file in the <ring>, THE terminates.
COMPATIBILITY
XEDIT: Compatible.
KEDIT: Compatible.
SEE ALSO
<QUIT>
STATUS
Complete
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Qquit(CHARTYPE *params)
#else
short Qquit(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
TRACE_FUNCTION( "comm4.c: Qquit" );
/*
* 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 );
free_view_memory( TRUE, TRUE );
TRACE_RETURN();
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
query - display various option settings
SYNTAX
Query item
DESCRIPTION
The QUERY command displays the various settings for options set
by THE.
For a complete list of 'item's that can be extracted, see the section;
<QUERY, EXTRACT and STATUS>.
Results of the QUERY command are displayed at the top of the
display window, and ignore the setting of <SET MSGLINE>.
COMPATIBILITY
XEDIT: Compatible functionality, but not all options.
KEDIT: Compatible functionality, but not all options.
SEE ALSO
<STATUS>, <MODIFY>
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Query(CHARTYPE *params)
#else
short Query(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
#define QUE_PARAMS 2
CHARTYPE *word[QUE_PARAMS+1];
CHARTYPE strip[QUE_PARAMS];
unsigned short num_params=0;
register short i=0;
short itemno=0;
bool save_msgmode_status = CURRENT_VIEW->msgmode_status;
CHARTYPE item_type=0;
TRACE_FUNCTION( "comm4.c: Query" );
strip[0]=STRIP_BOTH;
strip[1]=STRIP_NONE;
num_params = param_split( params, word, QUE_PARAMS, WORD_DELIMS, TEMP_PARAM, strip, FALSE );
if ( ( itemno = find_query_item( word[0], strlen( (DEFCHAR *)word[0] ), &item_type ) ) == (-1)
|| !( item_type & QUERY_QUERY ) )
{
display_error( 1, params, FALSE );
TRACE_RETURN();
return(RC_INVALID_OPERAND);
}
/*
* Note that multi-line outputs like PARSER or COLOR will be displayed as part
* of get_item_values()
*/
itemno = get_item_values( 1, itemno, (CHARTYPE *)word[1], QUERY_QUERY, 0L, NULL, 0L );
/*
* Save the current position and size of the message line so we can
* restore it. Do it after we have queried the status, otherwise
* the status of msgline will be stuffed!
*/
CURRENT_VIEW->msgmode_status = TRUE;
/*
* We display output from QUERY here only for single line queries.
* Multi-line displays will have set itemno = EXTRACT_VARIABLES_SET
*/
if ( itemno != EXTRACT_ARG_ERROR
&& itemno != EXTRACT_VARIABLES_SET )
{
strcpy( (DEFCHAR *)temp_cmd, "" );
for ( i = 0; i < itemno + 1; i++ )
{
strcat( (DEFCHAR *)temp_cmd, (DEFCHAR *)item_values[i].value );
strcat( (DEFCHAR *)temp_cmd, " " );
}
display_error( 0, temp_cmd, TRUE );
}
CURRENT_VIEW->msgmode_status = save_msgmode_status;
TRACE_RETURN();
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
quit - exit from the current file if no changes made
SYNTAX
QUIT
DESCRIPTION
The QUIT command exits the user from the current file, provided
that any changes made to the file have been saved, otherwise an
error message is displayed.
The previous file in the <ring> then becomes the current file.
If the current file is the only file in the <ring>, THE terminates.
COMPATIBILITY
XEDIT: Does not support return code option.
KEDIT: Compatible.
SEE ALSO
<QQUIT>
STATUS
Complete
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Quit(CHARTYPE *params)
#else
short Quit(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
TRACE_FUNCTION("comm4.c: Quit");
/*
* 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 (CURRENT_FILE->save_alt > 0)
{
display_error(22,(CHARTYPE *)"",FALSE);
TRACE_RETURN();
return(RC_FILE_CHANGED);
}
free_view_memory(TRUE,TRUE);
TRACE_RETURN();
return(RC_OK);
}
/*man-start*********************************************************************
COMMAND
readv - read keystrokes and pass to macro
SYNTAX
READV Cmdline [initial text]
READV KEY
DESCRIPTION
The READV command allows a Rexx macro to interact with the user
by accepting either individual keystrokes ('KEY') or a complete
line of text ('Cmdline').
The READV 'Cmdline' can take optional 'initial text' to be
displayed on the command line.
The 'macro' obtains the entered information by setting Rexx
variables. These are set as follows.
'KEY' option:
readv.0 = 4
readv.1 = name of key (empty if unknown)
readv.2 = ASCII value of key (null if not an ASCII code)
readv.3 = curses key value (or ASCII code if an ASCII code)
readv.4 = shift status (see below)
'CMDLINE' option:
readv.0 = 1
readv.1 = contents of command line
While editing the command in READV 'Cmdline', any key redefinitions
you have made will be in effect. Therefore you can use your
"normal" editing keys to edit the line. THE will allow the
following commands to be executed while in READV 'Cmdline':
<CURSOR> LEFT, <CURSOR> RIGHT, <CURSOR> DOWN, <CURSOR> UP,
<SOS FIRSTCHAR>, <SOS ENDCHAR>, <SOS STARTENDCHAR>,
<SOS DELEND>, <SOS DELCHAR>, <SOS DELCHAR>,
<SOS TABB>, <SOS TABF>, <SOS TABWORDB>, <SOS TABWORDF>,
<SOS UNDO>, <SOS DELWORD>, <SET INSERTMODE>, <TEXT>
Either of the keys, TAB, ENTER, RETURN and NUMENTER will terminate
READV 'Cmdline', irrespective of what THE commands have been
assigned.
The shift status of the key is an eight character string of
0 or 1; each position represented by the following.
Position
1 1 if INSERTMODE is ON
2 always 0
3 always 0
4 always 0
5 1 if ALT key pressed
6 1 if CTRL key pressed
7 1 if SHIFT key pressed
8 same as position 7
COMPATIBILITY
XEDIT: Similar to READ CMDLINE option.
KEDIT: Compatible.
STATUS
Complete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short Readv(CHARTYPE *params)
#else
short Readv(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
#define REA_PARAMS 2
CHARTYPE *word[REA_PARAMS+1];
CHARTYPE strip[REA_PARAMS];
unsigned short num_params=0;
short rc=RC_OK,itemno=0,num_values=0;
unsigned short y=0,x=0;
CHARTYPE item_type=0;
bool cursor_on_cmdline=FALSE;
TRACE_FUNCTION( "comm4.c: Readv" );
if ( !in_macro
|| !rexx_support )
{
display_error( 53, (CHARTYPE *)"", FALSE );
TRACE_RETURN();
return( RC_INVALID_ENVIRON );
}
strip[0]=STRIP_BOTH;
strip[1]=STRIP_NONE;
num_params = param_split( params, word, REA_PARAMS, WORD_DELIMS, TEMP_PARAM, strip, FALSE );
if ( num_params == 0 )
{
display_error( 1, params, FALSE );
TRACE_RETURN();
return( RC_INVALID_OPERAND );
}
getyx( CURRENT_WINDOW, y, x );
(void)THERefresh( (CHARTYPE *)"" );
#if defined(USE_EXTCURSES)
getyx( CURRENT_WINDOW, y, x );
wmove( CURRENT_WINDOW, y, x );
wrefresh( CURRENT_WINDOW );
#endif
if ( equal( (CHARTYPE *)"key", word[0], 3) )
{
/*
* Move the cursor to the current location - Bug #3370863.
*/
wmove( CURRENT_WINDOW, y, x );
/*
* Find the item in the list of valid extract options...
*/
if ( ( itemno = find_query_item( (CHARTYPE *)"READV", 5, &item_type ) ) == (-1) )
{
display_error( 1, params, FALSE );
TRACE_RETURN();
return( RC_INVALID_OPERAND );
}
/*
* Get the current settings for the valid item...
*/
num_values = get_item_values( 1, itemno, NULL, QUERY_READV, 0L, NULL, 0L );
/*
* If the arguments to the item are invalid, return with an error.
*/
if ( num_values == EXTRACT_ARG_ERROR )
{
TRACE_RETURN();
return( RC_INVALID_OPERAND );
}
/*
* If the Rexx variables have already been set, don't try to set them.
*/
if ( num_values != EXTRACT_VARIABLES_SET )
rc = set_extract_variables( itemno );
if ( error_on_screen )
clear_msgline( -1 );
}
else
{
if ( equal( (CHARTYPE *)"cmdline", word[0], 1 ) )
{
if ( CURRENT_VIEW->current_window == WINDOW_COMMAND )
cursor_on_cmdline = TRUE;
rc = readv_cmdline( word[1], NULL, -1 );
set_rexx_variable( (CHARTYPE *)"READV", cmd_rec, cmd_rec_len, 1 );
set_rexx_variable( (CHARTYPE *)"READV", (CHARTYPE *)"1", 1, 0 );
wmove(CURRENT_WINDOW_COMMAND,0,0);
my_wclrtoeol(CURRENT_WINDOW_COMMAND);
memset(cmd_rec,' ',max_line_length);
cmd_rec_len = 0;
wmove(CURRENT_WINDOW_COMMAND,0,0);
if ( !cursor_on_cmdline )
THEcursor_home( current_screen, CURRENT_VIEW, TRUE );
}
else
{
display_error( 1, word[0], FALSE );
TRACE_RETURN();
return( RC_INVALID_OPERAND );
}
}
initial = FALSE;
TRACE_RETURN();
return( rc );
}
/*man-start*********************************************************************
COMMAND
record - records all keystrokes into a macro file
SYNTAX
RECORD stop_key filename
DESCRIPTION
The RECORD command allows the user to record all keystrokes
from the time that RECORD is executed until the first time
that the specified 'stop_key' is hit. All commands associated
with each keystroke are stored into the specified 'filename'
as THE commands. This 'filename' can then be run with the
<MACRO> command.
COMPATIBILITY
XEDIT: N/A
KEDIT: N/A
SEE ALSO
<MACRO>
STATUS
InComplete.
**man-end**********************************************************************/
#ifdef HAVE_PROTO
short THERecord(CHARTYPE *params)
#else
short THERecord(params)
CHARTYPE *params;
#endif
/***********************************************************************/
{
#define RECD_PARAMS 2
CHARTYPE strip[RECD_PARAMS];
CHARTYPE quoted[RECD_PARAMS];
CHARTYPE *word[RECD_PARAMS+1];
unsigned short num_params=0;
short rc=RC_OK;
char ctime_buf[26];
time_t now;
TRACE_FUNCTION( "comm4.c: THERecord" );
/*
* If we are already recording, display error...
*/
if ( record_fp )
{
display_error( 148, (CHARTYPE *)"", FALSE );
TRACE_RETURN();
return( RC_INVALID_OPERAND );
}
/*
* Validate the parameters that have been supplied.