1 /***********************************************************************/
2 /* PREFIX.C - Prefix commands.                                         */
3 /***********************************************************************/
4 /*
5  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
6  * Copyright (C) 1991-2013 Mark Hessling
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to:
20  *
21  *    The Free Software Foundation, Inc.
22  *    675 Mass Ave,
23  *    Cambridge, MA 02139 USA.
24  *
25  *
26  * If you make modifications to this software that you feel increases
27  * it usefulness for the rest of the community, please email the
28  * changes, enhancements, bug fixes as well as any and all ideas to me.
29  * This software is going to be maintained and enhanced as deemed
30  * necessary by the community.
31  *
32  * Mark Hessling, mark@rexx.org  http://www.rexx.org/
33  */
34 
35 
36 #include <the.h>
37 #include <proto.h>
38 
39 /*-------------------------- declarations -----------------------------*/
40 static short parse_prefix_command Args((THE_PPC *));
41 static short invalidate_prefix Args((THE_PPC *, char *));
42 static short prefix_makecurr Args((THE_PPC *,short,LINETYPE));
43 static short prefix_add Args((THE_PPC *,short,LINETYPE));
44 static short prefix_duplicate Args((THE_PPC *,short,LINETYPE));
45 static short prefix_copy Args((THE_PPC *,short,LINETYPE));
46 static short prefix_move Args((THE_PPC *,short,LINETYPE));
47 static short prefix_overlay Args((THE_PPC *,short,LINETYPE));
48 static short prefix_lowercase Args((THE_PPC *,short,LINETYPE));
49 static short prefix_uppercase Args((THE_PPC *,short,LINETYPE));
50 static short prefix_delete Args((THE_PPC *,short,LINETYPE));
51 static short prefix_point Args((THE_PPC *,short,LINETYPE));
52 static short prefix_shift_left Args((THE_PPC *,short,LENGTHTYPE));
53 static short prefix_shift_right Args((THE_PPC *,short,LENGTHTYPE));
54 static short prefix_bounds_shift_left Args((THE_PPC *,short,LENGTHTYPE));
55 static short prefix_bounds_shift_right Args((THE_PPC *,short,LENGTHTYPE));
56 static short prefix_tabline Args((THE_PPC *,short,LINETYPE));
57 static short prefix_scale Args((THE_PPC *,short,LINETYPE));
58 static short prefix_show Args((THE_PPC *,short,LINETYPE));
59 static short prefix_exclude Args((THE_PPC *,short,LINETYPE));
60 static short prefix_block_duplicate Args((THE_PPC *,short,LINETYPE));
61 static short prefix_block_copy Args((THE_PPC *,short,LINETYPE));
62 static short prefix_block_move Args((THE_PPC *,short,LINETYPE));
63 static short prefix_block_overlay Args((THE_PPC *,short,LINETYPE));
64 static short prefix_block_lowercase Args((THE_PPC *,short,LINETYPE));
65 static short prefix_block_uppercase Args((THE_PPC *,short,LINETYPE));
66 static short prefix_block_delete Args((THE_PPC *,short,LINETYPE));
67 static short prefix_block_shift_left Args((THE_PPC *,short,LENGTHTYPE));
68 static short prefix_block_shift_right Args((THE_PPC *,short,LENGTHTYPE));
69 static short prefix_block_bounds_shift_left Args((THE_PPC *,short,LENGTHTYPE));
70 static short prefix_block_bounds_shift_right Args((THE_PPC *,short,LENGTHTYPE));
71 static short prefix_block_exclude Args((THE_PPC *,short,LINETYPE));
72 static THE_PPC *find_top_ppc Args((THE_PPC *,short));
73 static THE_PPC *find_target_ppc Args((void));
74 static THE_PPC *calculate_target_line Args((void));
75 static short try_rexx_prefix_macro Args((THE_PPC *));
76 static void split_prefix_command Args(( CHARTYPE *, THE_PPC * ));
77 static short post_prefix_add Args((THE_PPC *,short,LINETYPE));
78 /*
79  * The following two are to specify the first and last items in the
80  * linked list for prefix synonyms.
81  */
82 LINE *first_prefix_synonym=NULL;
83 LINE *last_prefix_synonym=NULL;
84 /*
85  * The view in which the pending list is being executed.
86  */
87 static VIEW_DETAILS *vd_pending;
88 static CHARTYPE pending_screen;
89 #define PENDING_VIEW                (vd_pending)
90 #define PENDING_FILE                (vd_pending->file_for_view)
91 #define PENDING_SCREEN              screen[pending_screen]
92 #define PENDING_WINDOW              (PENDING_SCREEN.win[vd_pending->current_window])
93 
94 #define THE_PPC_NO_TARGET        (-1)
95 #define THE_PPC_NO_COMMAND       (-2)
96 
97 #define THE_PPC_TARGET_PREVIOUS  3
98 #define THE_PPC_TARGET_FOLLOWING 4
99 /* the above two defines correspond to the position in the pc[] array  */
100 /* and should be changed if the position in pc[] array changes.        */
101 
102 #define NUMBER_PREFIX_COMMANDS 33
103    static PREFIX_COMMAND _THE_FAR pc[2][NUMBER_PREFIX_COMMANDS] =
104    {
105       {
106          /* THE, XEDIT, KEDIT, KEDITW compatibility mode prefix commands */
107          /* environment commands... */
108          {(CHARTYPE *)"tabl",  4,PC_IS_ACTION, PC_NO_MULTIPLES,PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_VALID_BOF,  PC_VALID_RO,  prefix_tabline,                  1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,0, NULL,FALSE,FALSE},
109          {(CHARTYPE *)"scale", 5,PC_IS_ACTION, PC_NO_MULTIPLES,PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_VALID_BOF,  PC_VALID_RO,  prefix_scale,                    1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,0, NULL,FALSE,FALSE},
110          {(CHARTYPE *)"/",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_VALID_BOF,  PC_VALID_RO,  prefix_makecurr,                 1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,50,NULL,FALSE,TRUE },
111          /* targets... */
112 /* 3 */  {(CHARTYPE *)"p",     1,PC_NOT_ACTION,PC_NO_MULTIPLES,PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_VALID_BOF,  PC_INVALID_RO,NULL,                            1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,0, NULL,FALSE,TRUE },
113 /* 4 */  {(CHARTYPE *)"f",     1,PC_NOT_ACTION,PC_NO_MULTIPLES,PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_INVALID_BOF,PC_INVALID_RO,NULL,                            1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,0, NULL,FALSE,TRUE },
114          /* block commands... */
115          {(CHARTYPE *)"lcc",   3,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_lowercase,          1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
116          {(CHARTYPE *)"ucc",   3,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_uppercase,          1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
117          {(CHARTYPE *)"\"\"",  2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_duplicate,          1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,40,NULL,FALSE,FALSE},
118          {(CHARTYPE *)"cc",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_copy,               1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
119          {(CHARTYPE *)"mm",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_move,               1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
120          {(CHARTYPE *)"oo",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_overlay,            1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
121          {(CHARTYPE *)"dd",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_delete,             1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,10,NULL,FALSE,FALSE},
122          {(CHARTYPE *)"xx",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_VALID_RO,  prefix_block_exclude,            1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
123          {(CHARTYPE *)"<<",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_shift_left,         1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
124          {(CHARTYPE *)">>",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_shift_right,        1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
125          {(CHARTYPE *)"((",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_bounds_shift_left,  1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
126          {(CHARTYPE *)"))",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_bounds_shift_right, 1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
127          /* line commands - no targets... */
128          {(CHARTYPE *)"lc",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_lowercase,                1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
129          {(CHARTYPE *)"uc",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_uppercase,                1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
130          /* line commands with targets... */
131          {(CHARTYPE *)"c",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_copy,                     1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
132          {(CHARTYPE *)"m",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_move,                     1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
133          {(CHARTYPE *)"o",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_overlay,                  1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
134          {(CHARTYPE *)"d",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_delete,                   1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,10,NULL,FALSE,FALSE},
135          /* line commands - no targets... */
136          {(CHARTYPE *)".",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_VALID_BOF,  PC_VALID_RO,  prefix_point,                    1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,40,NULL,TRUE ,FALSE},
137          {(CHARTYPE *)"\"",    1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_duplicate,                1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,40,NULL,FALSE,FALSE},
138          {(CHARTYPE *)"s",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_VALID_RO,  prefix_show,                     MAX_LONG,PC_IGNORE_SCOPE, PC_USE_LAST_IN_SCOPE,   30,NULL,FALSE,TRUE },
139          {(CHARTYPE *)"x",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_VALID_RO,  prefix_exclude,                  1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
140          {(CHARTYPE *)"<",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_shift_left,               1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
141          {(CHARTYPE *)">",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_shift_right,              1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
142          {(CHARTYPE *)"(",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_bounds_shift_left,        1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
143          {(CHARTYPE *)")",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_bounds_shift_right,       1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
144          {(CHARTYPE *)"i",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_INVALID_BOF,PC_INVALID_RO,prefix_add,                      1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,60,post_prefix_add,FALSE,FALSE},
145          {(CHARTYPE *)"a",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_INVALID_BOF,PC_INVALID_RO,prefix_add,                      1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,60,post_prefix_add,FALSE,FALSE},
146       },
147       {
148          /* ISPF compatibility mode prefix commands */
149          /* environment commands... */
150          {(CHARTYPE *)"tabs",  4,PC_IS_ACTION, PC_NO_MULTIPLES,PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_VALID_BOF,  PC_VALID_RO,  prefix_tabline,                  1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,0, NULL,FALSE,FALSE},
151          {(CHARTYPE *)"cols",  4,PC_IS_ACTION, PC_NO_MULTIPLES,PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_VALID_BOF,  PC_VALID_RO,  prefix_scale,                    1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,0, NULL,FALSE,FALSE},
152          {(CHARTYPE *)"bounds",6,PC_IS_ACTION, PC_NO_MULTIPLES,PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_VALID_BOF,  PC_VALID_RO,  prefix_scale,                    1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,0, NULL,FALSE,FALSE},
153          /* targets... */
154 /* 3 */  {(CHARTYPE *)"b",     1,PC_NOT_ACTION,PC_NO_MULTIPLES,PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_VALID_BOF,  PC_INVALID_RO,NULL,                            1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,0, NULL,FALSE,TRUE },
155 /* 4 */  {(CHARTYPE *)"a",     1,PC_NOT_ACTION,PC_NO_MULTIPLES,PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_INVALID_BOF,PC_INVALID_RO,NULL,                            1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,0, NULL,FALSE,TRUE },
156          /* block commands... */
157          {(CHARTYPE *)"lcc",   3,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_lowercase,          1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
158          {(CHARTYPE *)"ucc",   3,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_uppercase,          1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
159          {(CHARTYPE *)"rr",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_duplicate,          1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,40,NULL,FALSE,FALSE},
160          {(CHARTYPE *)"cc",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_copy,               1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
161          {(CHARTYPE *)"mm",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_move,               1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
162          {(CHARTYPE *)"oo",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_overlay,            1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
163          {(CHARTYPE *)"dd",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_delete,             1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,10,NULL,FALSE,FALSE},
164          {(CHARTYPE *)"xx",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_VALID_RO,  prefix_block_exclude,            1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
165          {(CHARTYPE *)"<<",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_shift_left,         1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
166          {(CHARTYPE *)">>",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_shift_right,        1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
167          {(CHARTYPE *)"((",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_bounds_shift_left,  1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
168          {(CHARTYPE *)"))",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_IS_BLOCK, PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_block_bounds_shift_right, 1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
169          /* line commands - no targets... */
170          {(CHARTYPE *)"lc",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_lowercase,                1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
171          {(CHARTYPE *)"uc",    2,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_uppercase,                1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
172          /* line commands with targets... */
173          {(CHARTYPE *)"c",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_copy,                     1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
174          {(CHARTYPE *)"m",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_move,                     1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
175          {(CHARTYPE *)"o",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_REQD,    PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_overlay,                  1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
176          {(CHARTYPE *)"d",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_delete,                   1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,10,NULL,FALSE,FALSE},
177          /* line commands - no targets... */
178          {(CHARTYPE *)".",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_VALID_BOF,  PC_VALID_RO,  prefix_point,                    1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,40,NULL,TRUE ,FALSE},
179          {(CHARTYPE *)"r",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_duplicate,                1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,40,NULL,FALSE,FALSE},
180          {(CHARTYPE *)"s",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_VALID_RO,  prefix_show,                     MAX_LONG,PC_IGNORE_SCOPE, PC_USE_LAST_IN_SCOPE,   30,NULL,FALSE,TRUE },
181          {(CHARTYPE *)"x",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_FULL_TARGET,   PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_VALID_RO,  prefix_exclude,                  1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
182          {(CHARTYPE *)"<",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_shift_left,               1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
183          {(CHARTYPE *)">",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_shift_right,              1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
184          {(CHARTYPE *)"(",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_bounds_shift_left,        1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
185          {(CHARTYPE *)")",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_INVALID_TOF,PC_INVALID_BOF,PC_INVALID_RO,prefix_bounds_shift_right,       1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,30,NULL,FALSE,FALSE},
186          {(CHARTYPE *)"i",     1,PC_IS_ACTION, PC_MULTIPLES,   PC_NO_FULL_TARGET,PC_NOT_BLOCK,PC_TARGET_NOT_REQD,PC_VALID_TOF,  PC_INVALID_BOF,PC_INVALID_RO,prefix_add,                      1L,      PC_RESPECT_SCOPE,PC_NO_USE_LAST_IN_SCOPE,60,post_prefix_add,FALSE,FALSE},
187       }
188   };
189 
190 LINETYPE prefix_current_line;
191 bool in_prefix_macro=FALSE;     /* indicate if processing prefix macro */
192 
193 /***********************************************************************/
194 #ifdef HAVE_PROTO
execute_prefix_commands(void)195 short execute_prefix_commands(void)
196 #else
197 short execute_prefix_commands()
198 #endif
199 /***********************************************************************/
200 {
201    short ispf_idx,cmd_idx=0,rc=RC_OK;
202    CHARTYPE *mult;
203    LINETYPE long_mult=0L;
204    LINE *curr;
205    THE_PPC *curr_ppc=NULL, *top_ppc;
206    TARGET target;
207    long target_type=TARGET_NORMAL;
208    unsigned short y=0,x=0;
209    int top_priority_idx=0;
210    int save_number_of_files;
211 
212    TRACE_FUNCTION( "prefix.c:  execute_prefix_commands" );
213    /*
214     * Setup pending values for the view, file and screen to be used by all
215     * pending prefix commands.
216     */
217    pending_screen = current_screen;
218    PENDING_VIEW = CURRENT_VIEW;
219 
220    post_process_line( PENDING_VIEW, PENDING_VIEW->focus_line, (LINE *)NULL, TRUE );
221    ispf_idx = (compatible_feel==COMPAT_ISPF) ? 1 : 0;
222    /*
223     * Do a pass, determining the cmd_idx so that target commands can be matched
224     */
225    curr_ppc = PENDING_FILE->first_ppc;
226    while( curr_ppc )
227    {
228       /*
229        * If we have already processed the command ignore it
230        */
231       if ( curr_ppc->ppc_processed )
232       {
233          curr_ppc = curr_ppc->next;
234          continue;
235       }
236       /*
237        * If an invalid prefix command from last time, ignore it.
238        */
239       if ( *(curr_ppc->ppc_orig_command) == '?' )
240       {
241          curr_ppc = curr_ppc->next;
242          continue;
243       }
244       /*
245        * Parse the prefix command and ignore any errors at the moment
246        */
247       parse_prefix_command( curr_ppc );
248       curr_ppc = curr_ppc->next;
249    }
250    /*
251     * Validate and execute all pending prefix commands from top of file down
252     */
253    top_priority_idx=(-1);
254    curr_ppc = PENDING_FILE->first_ppc;
255    while( curr_ppc )
256    {
257       /*
258        * To imitate XEDIT behaviour, ignore a prefix command if the line on which the prefix command
259        * has been entered is not in scope.
260        */
261       curr = lll_find( PENDING_FILE->first_line, PENDING_FILE->last_line, curr_ppc->ppc_line_number, PENDING_FILE->number_lines );
262       if ( !( IN_SCOPE( PENDING_VIEW, curr )
263       ||   PENDING_VIEW->scope_all
264       ||   pc[ispf_idx][curr_ppc->ppc_cmd_idx].allowed_on_shadow_line == TRUE ) )
265       {
266          curr_ppc = curr_ppc->next;
267          continue;
268       }
269       /*
270        * If an invalid prefix command from last time, clear it.
271        */
272       if ( *(curr_ppc->ppc_orig_command) == '?' )
273       {
274          clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
275          curr_ppc = curr_ppc->next;
276          continue;
277       }
278       /*
279        * If we have already processed the command ignore it
280        */
281       if ( curr_ppc->ppc_processed )
282       {
283          curr_ppc = curr_ppc->next;
284          continue;
285       }
286       /*
287        * Set the pending prefix to processed before we execute as the executing
288        * prefix command is not pending at the time it is executed.
289        * For the top part of a block command, we have to "unprocess" it later
290        */
291       curr_ppc->ppc_current_command = TRUE;
292       /*
293        * To get here we have 'normal' prefix command.
294        */
295       if ( rexx_support )              /* if REXX support is in effect ... */
296       {
297          save_number_of_files = number_of_files;
298          /*
299           * first determine if the command is a prefix macro BEFORE looking for
300           * standard prefix commands.
301           */
302          rc = try_rexx_prefix_macro( curr_ppc );
303          /*
304           * If at this point there are no more files in the ring; we assume that
305           * this was caused by exitting the last file in the ring from a prefix
306           * macro, exit and ignore any more prefix commands. This is messy !!!
307           */
308          if ( number_of_files == 0 )
309          {
310             TRACE_RETURN();
311             return( RC_COMMAND_NO_FILES );
312          }
313          if ( number_of_files != save_number_of_files
314          &&   PENDING_VIEW != CURRENT_VIEW )
315          {
316             TRACE_RETURN();
317             return( RC_OK );
318          }
319          /*
320           * If it was a Rexx prefix macro, then go get the next pending command
321           */
322          if ( rc != RC_NOT_COMMAND )
323          {
324             curr_ppc->ppc_current_command = FALSE;
325             curr_ppc = curr_ppc->next;
326             continue;
327          }
328       }
329       curr_ppc->ppc_current_command = FALSE;
330       /*
331        * if no prefix macro found for the prefix command, check to see if it
332        * is a standard prefix command.
333        */
334       if ( ( cmd_idx = parse_prefix_command( curr_ppc ) ) == THE_PPC_NO_TARGET )
335       {
336          invalidate_prefix( curr_ppc, NULL );
337          curr_ppc = curr_ppc->next;
338          continue;
339       }
340       if ( cmd_idx == THE_PPC_NO_COMMAND )
341       {
342          curr_ppc = curr_ppc->next;
343          continue;
344       }
345       /*
346        * If running in read-only mode and the function selected is not valid
347        * display an error.
348        */
349       if ( ISREADONLY( PENDING_FILE )
350       &&   !pc[ispf_idx][cmd_idx].valid_in_readonly )
351       {
352          display_error( 56, (CHARTYPE *)"", FALSE );
353          invalidate_prefix( curr_ppc, NULL );
354          curr_ppc = curr_ppc->next;
355          continue;
356       }
357       /*
358        * Set the block_command flag for the current prefix command to the
359        * appropriate value for the prefix command.
360        */
361       curr_ppc->ppc_block_command = pc[ispf_idx][cmd_idx].block_prefix_command;
362       /*
363        * Ignore the first instance of a block command
364        */
365       if ( curr_ppc->ppc_block_command )
366       {
367          top_ppc = find_top_ppc( curr_ppc, curr_ppc->ppc_cmd_idx );
368          if ( top_ppc == NULL )
369          {
370             /*
371              * For the top part of a block command, we have to set it back to
372              * "unprocessed"
373             curr_ppc->ppc_processed = FALSE;
374              */
375             curr_ppc = curr_ppc->next;
376             continue;
377          }
378          /*
379           * If we have the second instance of a block command work out any arguments.
380           * This is done like:
381           * If the top instance has an arg, use that, otherwise use the argument from the second
382           * (current) instance
383           */
384          if ( top_ppc->ppc_op[0]
385          &&   strlen( (DEFCHAR *)top_ppc->ppc_op[0] ) != 0 )
386          {
387             mult = top_ppc->ppc_op[0];
388          }
389          else
390          {
391             mult = curr_ppc->ppc_op[0];
392          }
393       }
394       else
395       {
396          mult = curr_ppc->ppc_op[0];
397       }
398       /*
399        * We now have a recognised command. We have to validate its parameters
400        * and find any associated pending commands.
401        */
402       /*
403        * If the command does not allow parameters and there are parameters,
404        * error.
405        */
406       if ( !pc[ispf_idx][cmd_idx].multiples_allowed
407       &&   strcmp((DEFCHAR *)mult,"") != 0 )
408       {
409          invalidate_prefix( curr_ppc, NULL );
410          curr_ppc = curr_ppc->next;
411          continue;
412       }
413       /*
414        * If the command does allow parameters and there are no parameters,
415        * set to default...
416        */
417       rc = RC_OK;
418       if ( strcmp( (DEFCHAR *)mult, "" ) == 0 )
419          long_mult = pc[ispf_idx][cmd_idx].default_target;
420       else
421       {
422          /*
423           * ...otherwise validate the target supplied...
424           */
425          if ( pc[ispf_idx][cmd_idx].multiples_allowed )
426          {
427             if ( !pc[ispf_idx][cmd_idx].text_arg ) /* . command */
428             {
429                if ( pc[ispf_idx][cmd_idx].full_target_allowed )
430                {
431                   initialise_target( &target );
432                   target.ignore_scope = pc[ispf_idx][cmd_idx].ignore_scope;
433                   if ( pc[ispf_idx][cmd_idx].use_last_not_in_scope        /* S command */
434                   &&   mult[0] == '-' )
435                      rc = validate_target( mult, &target, target_type, find_last_not_in_scope( PENDING_VIEW, NULL, curr_ppc->ppc_line_number, DIRECTION_FORWARD ), TRUE, TRUE );
436                   else
437                      rc = validate_target( mult, &target, target_type, curr_ppc->ppc_line_number, TRUE, TRUE );
438                   if ( target.num_lines == 0L )
439                      rc = RC_INVALID_OPERAND;
440                   long_mult = target.num_lines;
441                   free_target( &target );
442                }
443                else
444                {
445                   if ( !valid_positive_integer( mult ) )
446                      rc = RC_INVALID_OPERAND;
447                   else
448                      long_mult = atol( (DEFCHAR *)mult );
449                }
450             }
451          }
452       }
453       /*
454        * If the target is invalid or not found, invalidate the command.
455        */
456       if ( rc != RC_OK )
457       {
458          invalidate_prefix( curr_ppc, NULL );
459          curr_ppc = curr_ppc->next;
460          continue;
461       }
462       curr_ppc->ppc_cmd_param = long_mult;
463       /*
464        * Execute the function associated with the prefix command...
465        */
466       if ( cmd_idx != (-1)
467       &&   cmd_idx != THE_PPC_NO_COMMAND
468       &&   pc[ispf_idx][cmd_idx].function != NULL )
469       {
470          rc = (*pc[ispf_idx][cmd_idx].function)( curr_ppc, cmd_idx, long_mult );
471          if ( rc == RC_OK )
472          {
473             curr_ppc->ppc_processed = TRUE;
474          }
475       }
476       /*
477        * Determine the prefix command with the highest priority and save it.
478        */
479       if ( cmd_idx >= 0 )
480       {
481          if ( top_priority_idx == (-1) )
482             top_priority_idx = cmd_idx;
483          else
484          {
485             if ( pc[ispf_idx][cmd_idx].priority > pc[ispf_idx][top_priority_idx].priority )
486                top_priority_idx = cmd_idx;
487          }
488       }
489       curr_ppc = curr_ppc->next;
490    }
491    /*
492     * The "cleared" pending prefix commands now need to be deleted from
493     * the linked list...
494 
495     * MH 23 May 2005. This was commented out as it appears that prefix commands are
496     * cleared automatically, and any pending block commands set by a prefix macro
497     * are incorrectly getting cleared.
498 
499     * Only clear the pending prefix command if it is NOT a builtin prefix command
500     * and it was NOT created by SET PENDING (ie it was typed into the prefix area
501     * Fixes bug 860344
502     */
503    curr_ppc = PENDING_FILE->first_ppc;
504    while( curr_ppc )
505    {
506       if ( curr_ppc->ppc_cmd_idx == (-1) /* NOT a builtin */
507       &&   !curr_ppc->ppc_set_by_pending )
508          curr_ppc = delete_pending_prefix_command( curr_ppc, PENDING_FILE, NULL );
509       else
510          curr_ppc = curr_ppc->next;
511    }
512    /*
513     * Now that we are here, display the new version of the screen.
514     */
515    if ( top_priority_idx != (-1) )
516    {
517       if ( pc[ispf_idx][top_priority_idx].post_function != NULL )
518          rc = (*pc[ispf_idx][top_priority_idx].post_function)( curr_ppc, cmd_idx, long_mult );
519    }
520 
521    if ( PENDING_VIEW == CURRENT_VIEW )
522    {
523       pre_process_line( PENDING_VIEW, PENDING_VIEW->focus_line, (LINE *)NULL );
524       build_screen( pending_screen );
525       display_screen( pending_screen );
526       if ( PENDING_VIEW->current_window != WINDOW_COMMAND )
527       {
528          if ( curses_started )
529             getyx( PENDING_WINDOW, y, x );
530          PENDING_VIEW->focus_line = get_focus_line_in_view( pending_screen, PENDING_VIEW->focus_line, y );
531          y = get_row_for_focus_line( pending_screen, PENDING_VIEW->focus_line, PENDING_VIEW->current_row );
532          if ( curses_started )
533             wmove( PENDING_WINDOW, y, x );
534          pre_process_line( PENDING_VIEW, PENDING_VIEW->focus_line, (LINE *)NULL );
535       }
536    }
537    else
538    {
539       pre_process_line( CURRENT_VIEW, CURRENT_VIEW->focus_line, (LINE *)NULL );
540       build_screen( current_screen );
541       display_screen( current_screen );
542       if ( CURRENT_VIEW->current_window != WINDOW_COMMAND )
543       {
544          if ( curses_started )
545             getyx( CURRENT_WINDOW, y, x );
546          CURRENT_VIEW->focus_line = get_focus_line_in_view( current_screen, CURRENT_VIEW->focus_line, y );
547          y = get_row_for_focus_line( current_screen, CURRENT_VIEW->focus_line, CURRENT_VIEW->current_row );
548          if ( curses_started )
549             wmove( CURRENT_WINDOW, y, x );
550          pre_process_line( CURRENT_VIEW, CURRENT_VIEW->focus_line, (LINE *)NULL );
551       }
552    }
553    TRACE_RETURN();
554    return( RC_OK );
555 }
556 
557 /***********************************************************************/
558 #ifdef HAVE_PROTO
parse_prefix_command(THE_PPC * curr_ppc)559 static short parse_prefix_command( THE_PPC *curr_ppc )
560 #else
561 static short parse_prefix_command( curr_ppc )
562 THE_PPC *curr_ppc;
563 #endif
564 /***********************************************************************/
565 {
566    register short i=0;
567    short rc=RC_OK;
568    LINE *curr=NULL;
569    int ispf_idx = (compatible_feel==COMPAT_ISPF) ? 1 : 0;
570 
571    TRACE_FUNCTION( "prefix.c:  parse_prefix_command" );
572    /*
573     * For each pending prefix command for the current view, execute the
574     * appropriate command.
575     */
576    rc = THE_PPC_NO_TARGET;
577    if ( blank_field( curr_ppc->ppc_command ) )          /* if prefix command is blank, return */
578    {
579       TRACE_RETURN();
580       return( THE_PPC_NO_COMMAND );
581    }
582    /*
583     * For each prefix synonym, determine if the supplied prefix command matches
584     * Synonyms are case sensitive
585     */
586    curr = first_prefix_synonym;
587    while( curr )
588    {
589       if ( strcmp( (DEFCHAR *)curr_ppc->ppc_command, (DEFCHAR *)curr->name ) != 0 )
590       {
591          curr = curr->next;
592          continue;
593       }
594       /*
595        * Now that a match on synonym is made, determine the original prefix
596        * command associated with that synonym...
597        */
598       for ( i = 0; i < NUMBER_PREFIX_COMMANDS; i++ )
599       {
600          if ( pc[ispf_idx][i].cmd == NULL )
601             break;
602          if ( strcmp( (DEFCHAR *)pc[ispf_idx][i].cmd, (DEFCHAR *)curr->line ) == 0 )
603          {
604             curr_ppc->ppc_cmd_idx = i;
605             TRACE_RETURN();
606             return( i );
607          }
608       }
609       /*
610        * To get here we found a prefix synonym, but no matching original
611        * command, so return an error.
612        */
613       curr_ppc->ppc_cmd_idx = (-1);
614       TRACE_RETURN();
615       return( rc );
616    }
617    /*
618     * We don't have a prefix synonym for the supplied command; look
619     * for builtin prefix commands.
620     * Builtin prefix commands are case insensitive
621     */
622    for ( i = 0; i < NUMBER_PREFIX_COMMANDS; i++ )
623    {
624       if ( pc[ispf_idx][i].cmd == NULL )
625         break;
626       if ( my_stricmp( (DEFCHAR *)curr_ppc->ppc_command, (DEFCHAR *)pc[ispf_idx][i].cmd ) == 0 )
627       {
628          /*
629           * Set a flag in ppc[] array to indicate which command is present.
630           */
631          curr_ppc->ppc_cmd_idx = i;
632          rc = i;
633          break;
634       }
635    }
636    /*
637     * If command not found, set a flag in ppc[] array to indicate command
638     * is invalid.
639     */
640    if ( rc == THE_PPC_NO_TARGET )
641       curr_ppc->ppc_cmd_idx = (-1);
642    TRACE_RETURN();
643    return( rc );
644 }
645 /***********************************************************************/
646 #ifdef HAVE_PROTO
prefix_makecurr(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)647 static short prefix_makecurr(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
648 #else
649 static short prefix_makecurr(curr_ppc,cmd_idx,number_lines)
650 THE_PPC *curr_ppc;
651 short cmd_idx;
652 LINETYPE number_lines;
653 #endif
654 /***********************************************************************/
655 {
656    LINETYPE top_line = curr_ppc->ppc_line_number;
657 
658    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
659    execute_makecurr( pending_screen, PENDING_VIEW, top_line);
660    if (number_lines != 0L)
661       PENDING_VIEW->current_column = (LENGTHTYPE)number_lines;
662    return(0);
663 }
664 /***********************************************************************/
665 #ifdef HAVE_PROTO
prefix_tabline(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)666 static short prefix_tabline(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
667 #else
668 static short prefix_tabline(curr_ppc,cmd_idx,number_lines)
669 THE_PPC *curr_ppc;
670 short cmd_idx;
671 LINETYPE number_lines;
672 #endif
673 /***********************************************************************/
674 {
675    LINETYPE top_line = curr_ppc->ppc_line_number;
676    short tab_row = 0;
677 
678    if ((tab_row = get_row_for_focus_line(pending_screen,top_line,(-1))) != (-1))
679    {
680       PENDING_VIEW->tab_base = POSITION_TOP;
681       PENDING_VIEW->tab_off = tab_row+1;
682       PENDING_VIEW->tab_on = TRUE;
683    }
684    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
685    return(0);
686 }
687 /***********************************************************************/
688 #ifdef HAVE_PROTO
prefix_scale(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)689 static short prefix_scale(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
690 #else
691 static short prefix_scale(curr_ppc,cmd_idx,number_lines)
692 THE_PPC *curr_ppc;
693 short cmd_idx;
694 LINETYPE number_lines;
695 #endif
696 /***********************************************************************/
697 {
698    LINETYPE top_line = curr_ppc->ppc_line_number;
699    short scale_row = 0;
700 
701    if ((scale_row = get_row_for_focus_line(pending_screen,top_line,(-1))) != (-1))
702    {
703       PENDING_VIEW->scale_base = POSITION_TOP;
704       PENDING_VIEW->scale_off = scale_row+1;
705       PENDING_VIEW->scale_on = TRUE;
706    }
707    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
708    return(0);
709 }
710 /***********************************************************************/
711 #ifdef HAVE_PROTO
prefix_show(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)712 static short prefix_show(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
713 #else
714 static short prefix_show(curr_ppc,cmd_idx,number_lines)
715 THE_PPC *curr_ppc;
716 short cmd_idx;
717 LINETYPE number_lines;
718 #endif
719 /***********************************************************************/
720 {
721    LINETYPE i=0;
722    short rc=RC_OK;
723    LINETYPE top_line = curr_ppc->ppc_line_number;
724    LINETYPE target_line=0L;
725    LINE *curr=NULL;
726 
727    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
728    if (TOF(top_line)
729    ||  BOF(top_line))
730       return(-1);
731    /*
732     * Find the current line from where we start showing...
733     */
734    curr = lll_find(PENDING_FILE->first_line,PENDING_FILE->last_line,top_line,PENDING_FILE->number_lines);
735    /*
736     * If the line that the show command was entered is in scope, then
737     * return with an error.
738     */
739    if (IN_SCOPE(PENDING_VIEW,curr))
740    {
741       invalidate_prefix( curr_ppc, NULL );
742       return(-1);
743    }
744    /*
745     * For a negative target, show the lines from the end of the excluded
746     * block.
747     */
748    if (number_lines < 0)
749    {
750       target_line = find_last_not_in_scope(PENDING_VIEW,curr,top_line,DIRECTION_FORWARD);
751       curr = lll_find(PENDING_FILE->first_line,PENDING_FILE->last_line,target_line,PENDING_FILE->number_lines);
752       for(i=0;i>number_lines;i--)
753       {
754          curr->select = PENDING_VIEW->display_high;
755          curr = curr->prev;
756          if (curr->prev == NULL
757          ||  IN_SCOPE(PENDING_VIEW,curr))
758             break;
759       }
760    }
761    else
762    {
763       /*
764        * For a positive target, show the lines from the start of the excluded
765        * block.
766        */
767       for(i=0;i<number_lines;i++)
768       {
769          curr->select = PENDING_VIEW->display_high;
770          curr = curr->next;
771          if (curr->next == NULL
772          ||  IN_SCOPE(PENDING_VIEW,curr))
773             break;
774       }
775    }
776    return(rc);
777 }
778 /***********************************************************************/
779 #ifdef HAVE_PROTO
prefix_exclude(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)780 static short prefix_exclude(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
781 #else
782 static short prefix_exclude(curr_ppc,cmd_idx,number_lines)
783 THE_PPC *curr_ppc;
784 short cmd_idx;
785 LINETYPE number_lines;
786 #endif
787 /***********************************************************************/
788 {
789    short rc=RC_OK;
790    LINETYPE top_line = curr_ppc->ppc_line_number;
791    LINE *curr=NULL;
792    short direction=DIRECTION_FORWARD;
793 
794    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
795    if (TOF(top_line)
796    ||  BOF(top_line))
797       return(-1);
798    /*
799     * If the high value of SET DISPLAY is 255, we can't exclude any lines
800     * so exit.
801     */
802    if (PENDING_VIEW->display_high == 255)
803       return(rc);
804    if (number_lines < 0)
805       direction = DIRECTION_BACKWARD;
806    else
807       direction = DIRECTION_FORWARD;
808    /*
809     * Find the current line from where we start excluding...
810     */
811    curr = lll_find(PENDING_FILE->first_line,PENDING_FILE->last_line,top_line,PENDING_FILE->number_lines);
812    /*
813     * For the number of lines affected, change the select level if the
814     * line is in scope.
815     */
816    while(number_lines != 0)
817    {
818       if (IN_SCOPE(PENDING_VIEW,curr))
819          curr->select = (short)PENDING_VIEW->display_high + 1;
820       if (direction == DIRECTION_FORWARD)
821          curr = curr->next;
822       else
823          curr = curr->prev;
824       number_lines -= direction;
825    }
826    /*
827     * Determine if current line is now not in scope...
828     */
829    curr = lll_find(PENDING_FILE->first_line,PENDING_FILE->last_line,PENDING_VIEW->current_line,PENDING_FILE->number_lines);
830    if (!IN_SCOPE(PENDING_VIEW,curr))
831       PENDING_VIEW->current_line = find_next_in_scope(PENDING_VIEW,curr,PENDING_VIEW->current_line,DIRECTION_FORWARD);
832    return(rc);
833 }
834 /***********************************************************************/
835 #ifdef HAVE_PROTO
prefix_add(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)836 static short prefix_add(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
837 #else
838 static short prefix_add(curr_ppc,cmd_idx,number_lines)
839 THE_PPC *curr_ppc;
840 short cmd_idx;
841 LINETYPE number_lines;
842 #endif
843 /***********************************************************************/
844 {
845    short rc=(-1);
846    LINETYPE top_line = curr_ppc->ppc_line_number;
847 
848    if (top_line == PENDING_FILE->number_lines+1)
849       top_line--;
850    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
851    rc = insert_new_line( pending_screen, PENDING_VIEW, (CHARTYPE *)"", 0, number_lines, top_line, FALSE, FALSE, TRUE, PENDING_VIEW->display_low, FALSE, FALSE );
852    return(rc);
853 }
854 /***********************************************************************/
855 #ifdef HAVE_PROTO
prefix_duplicate(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_occ)856 static short prefix_duplicate(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_occ)
857 #else
858 static short prefix_duplicate(curr_ppc,cmd_idx,number_occ)
859 THE_PPC *curr_ppc;
860 short cmd_idx;
861 LINETYPE number_occ;
862 #endif
863 /***********************************************************************/
864 {
865    short rc=(-1);
866    LINETYPE top_line = curr_ppc->ppc_line_number;
867    LINETYPE lines_affected=0L;
868 
869    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
870    if (top_line != 0L
871    &&  top_line != PENDING_FILE->number_lines+1)
872    {
873       rc = rearrange_line_blocks( COMMAND_DUPLICATE, SOURCE_PREFIX, top_line, top_line, top_line, number_occ, PENDING_VIEW, PENDING_VIEW, TRUE, &lines_affected );
874    }
875    return(rc);
876 }
877 /***********************************************************************/
878 #ifdef HAVE_PROTO
prefix_copy(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)879 static short prefix_copy(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
880 #else
881 static short prefix_copy(curr_ppc,cmd_idx,number_lines)
882 THE_PPC *curr_ppc;
883 short cmd_idx;
884 LINETYPE number_lines;
885 #endif
886 /***********************************************************************/
887 {
888    LINETYPE bottom_line=0L,target_line=0L,lines_affected=0L;
889    LINETYPE top_line = curr_ppc->ppc_line_number;
890    THE_PPC *target_ppc=NULL;
891    short rc=(-1);
892 
893    if ((target_ppc = calculate_target_line()) == NULL)
894       return(rc);
895    target_line = target_ppc->ppc_line_number+target_ppc->ppc_cmd_param;
896    bottom_line = top_line + number_lines - ((number_lines < 0L) ? (-1L) : 1L);
897    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
898    if (top_line != 0L
899    &&  top_line != PENDING_FILE->number_lines+1)
900    {
901       rc = rearrange_line_blocks( COMMAND_COPY, SOURCE_PREFIX, top_line, bottom_line, target_line, 1, PENDING_VIEW, PENDING_VIEW, TRUE, &lines_affected );
902    }
903    clear_pending_prefix_command( target_ppc, PENDING_FILE, (LINE *)NULL );
904    return(rc);
905 }
906 /***********************************************************************/
907 #ifdef HAVE_PROTO
prefix_move(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)908 static short prefix_move(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
909 #else
910 static short prefix_move(curr_ppc,cmd_idx,number_lines)
911 THE_PPC *curr_ppc;
912 short cmd_idx;
913 LINETYPE number_lines;
914 #endif
915 /***********************************************************************/
916 {
917    LINETYPE bottom_line=0L,target_line=0L,lines_affected=0L;
918    LINETYPE top_line = curr_ppc->ppc_line_number;
919    THE_PPC *target_ppc=NULL;
920    short rc=(-1);
921 
922    if ((target_ppc = calculate_target_line()) == NULL)
923       return(rc);
924    target_line = target_ppc->ppc_line_number+target_ppc->ppc_cmd_param;
925    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
926    bottom_line = top_line + number_lines - ((number_lines < 0L) ? (-1L) : 1L);
927 
928    if ( top_line != 0L
929    &&   top_line != PENDING_FILE->number_lines+1 )
930    {
931       if ( ( rc = rearrange_line_blocks( COMMAND_MOVE_COPY_SAME, SOURCE_PREFIX, top_line, bottom_line, target_line, 1, PENDING_VIEW, PENDING_VIEW, TRUE, &lines_affected ) ) != RC_OK )
932          return(rc);
933       if ( target_line < top_line )
934       {
935          top_line += number_lines;
936          target_line += number_lines;
937          bottom_line += number_lines;
938       }
939       rc = rearrange_line_blocks( COMMAND_MOVE_DELETE_SAME, SOURCE_PREFIX, top_line, bottom_line, target_line, 1, PENDING_VIEW, PENDING_VIEW, TRUE, &lines_affected );
940    }
941    clear_pending_prefix_command( target_ppc, PENDING_FILE, (LINE *)NULL );
942    return(rc);
943 }
944 /***********************************************************************/
945 #ifdef HAVE_PROTO
prefix_point(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)946 static short prefix_point(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
947 #else
948 static short prefix_point(curr_ppc,cmd_idx,number_lines)
949 THE_PPC *curr_ppc;
950 short cmd_idx;
951 LINETYPE number_lines;
952 #endif
953 /***********************************************************************/
954 {
955    int rc=RC_OK;
956    CHARTYPE _THE_FAR buf[MAX_PREFIX_WIDTH+2];
957    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
958    strcpy( (DEFCHAR *)buf, "." );
959    strcat( (DEFCHAR *)buf, (DEFCHAR *)curr_ppc->ppc_op[0] );
960    if ( execute_set_point( pending_screen, PENDING_VIEW, buf, curr_ppc->ppc_line_number, TRUE ) != RC_OK )
961    {
962       invalidate_prefix( curr_ppc, NULL );
963       rc = (-1);
964    }
965    return(rc);
966 }
967 /***********************************************************************/
968 #ifdef HAVE_PROTO
prefix_delete(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)969 static short prefix_delete(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
970 #else
971 static short prefix_delete(curr_ppc,cmd_idx,number_lines)
972 THE_PPC *curr_ppc;
973 short cmd_idx;
974 LINETYPE number_lines;
975 #endif
976 /***********************************************************************/
977 {
978    short rc=(-1);
979    LINETYPE top_line = curr_ppc->ppc_line_number;
980    LINETYPE bottom_line=0L,target_line=0L,lines_affected=0L;
981 
982    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
983    if ( !VIEW_TOF( PENDING_VIEW, top_line )
984    &&   !VIEW_BOF( PENDING_VIEW, top_line ) )
985    {
986       bottom_line = top_line + number_lines - ((number_lines < 0L) ? (-1L) : 1L);
987       target_line = (number_lines < 0L) ? (bottom_line) : (top_line);
988       rc = rearrange_line_blocks( COMMAND_DELETE, SOURCE_PREFIX, top_line, bottom_line, target_line, 1, PENDING_VIEW, PENDING_VIEW, TRUE, &lines_affected );
989    }
990    return(rc);
991 }
992 /***********************************************************************/
993 #ifdef HAVE_PROTO
prefix_shift_left(THE_PPC * curr_ppc,short cmd_idx,LENGTHTYPE number_cols)994 static short prefix_shift_left(THE_PPC *curr_ppc,short cmd_idx,LENGTHTYPE number_cols)
995 #else
996 static short prefix_shift_left(curr_ppc,cmd_idx,number_cols)
997 THE_PPC *curr_ppc;
998 short cmd_idx;
999 LENGTHTYPE number_cols;
1000 #endif
1001 /***********************************************************************/
1002 {
1003    LINETYPE top_line = curr_ppc->ppc_line_number;
1004 
1005    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1006    if (top_line != 0L
1007    &&  top_line != PENDING_FILE->number_lines+1)
1008    {
1009       execute_shift_command( pending_screen, PENDING_VIEW, TRUE,number_cols,top_line,1L,TRUE,TARGET_UNFOUND,FALSE,FALSE);
1010    }
1011    return(0);
1012 }
1013 /***********************************************************************/
1014 #ifdef HAVE_PROTO
prefix_shift_right(THE_PPC * curr_ppc,short cmd_idx,LENGTHTYPE number_cols)1015 static short prefix_shift_right(THE_PPC *curr_ppc,short cmd_idx,LENGTHTYPE number_cols)
1016 #else
1017 static short prefix_shift_right(curr_ppc,cmd_idx,number_cols)
1018 THE_PPC *curr_ppc;
1019 short cmd_idx;
1020 LENGTHTYPE number_cols;
1021 #endif
1022 /***********************************************************************/
1023 {
1024    LINETYPE start_line = curr_ppc->ppc_line_number;
1025 
1026    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1027    if (start_line != 0L
1028    &&  start_line != PENDING_FILE->number_lines+1)
1029    {
1030       execute_shift_command( pending_screen, PENDING_VIEW, FALSE, number_cols, start_line, 1L, TRUE, TARGET_UNFOUND, FALSE, FALSE );
1031    }
1032    return(0);
1033 }
1034 /***********************************************************************/
1035 #ifdef HAVE_PROTO
prefix_bounds_shift_left(THE_PPC * curr_ppc,short cmd_idx,LENGTHTYPE number_cols)1036 static short prefix_bounds_shift_left(THE_PPC *curr_ppc,short cmd_idx,LENGTHTYPE number_cols)
1037 #else
1038 static short prefix_bounds_shift_left(curr_ppc,cmd_idx,number_cols)
1039 THE_PPC *curr_ppc;
1040 short cmd_idx;
1041 LENGTHTYPE number_cols;
1042 #endif
1043 /***********************************************************************/
1044 {
1045    LINETYPE top_line = curr_ppc->ppc_line_number;
1046 
1047    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1048    if (top_line != 0L
1049    &&  top_line != PENDING_FILE->number_lines+1)
1050    {
1051       execute_shift_command( pending_screen, PENDING_VIEW, TRUE, number_cols, top_line, 1L, TRUE, TARGET_UNFOUND, FALSE, TRUE );
1052    }
1053    return(0);
1054 }
1055 /***********************************************************************/
1056 #ifdef HAVE_PROTO
prefix_bounds_shift_right(THE_PPC * curr_ppc,short cmd_idx,LENGTHTYPE number_cols)1057 static short prefix_bounds_shift_right(THE_PPC *curr_ppc,short cmd_idx,LENGTHTYPE number_cols)
1058 #else
1059 static short prefix_bounds_shift_right(curr_ppc,cmd_idx,number_cols)
1060 THE_PPC *curr_ppc;
1061 short cmd_idx;
1062 LENGTHTYPE number_cols;
1063 #endif
1064 /***********************************************************************/
1065 {
1066    LINETYPE start_line = curr_ppc->ppc_line_number;
1067 
1068    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1069    if (start_line != 0L
1070    &&  start_line != PENDING_FILE->number_lines+1)
1071    {
1072       execute_shift_command( pending_screen, PENDING_VIEW, FALSE, number_cols, start_line, 1L, TRUE, TARGET_UNFOUND, FALSE, TRUE );
1073    }
1074    return(0);
1075 }
1076 /***********************************************************************/
1077 #ifdef HAVE_PROTO
prefix_lowercase(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1078 static short prefix_lowercase(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1079 #else
1080 static short prefix_lowercase(curr_ppc,cmd_idx,number_lines)
1081 THE_PPC *curr_ppc;
1082 short cmd_idx;
1083 LINETYPE number_lines;
1084 #endif
1085 /***********************************************************************/
1086 {
1087    LINETYPE start_line = curr_ppc->ppc_line_number;
1088    LENGTHTYPE start_col=PENDING_VIEW->zone_start-1;
1089    LENGTHTYPE end_col=PENDING_VIEW->zone_end-1;
1090 
1091    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1092    if (start_line != 0L
1093    &&  start_line != PENDING_FILE->number_lines+1)
1094    {
1095       do_actual_change_case(start_line,number_lines, CASE_LOWER, FALSE, DIRECTION_FORWARD, start_col, end_col );
1096    }
1097    return(0);
1098 }
1099 /***********************************************************************/
1100 #ifdef HAVE_PROTO
prefix_uppercase(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1101 static short prefix_uppercase(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1102 #else
1103 static short prefix_uppercase(curr_ppc,cmd_idx,number_lines)
1104 THE_PPC *curr_ppc;
1105 short cmd_idx;
1106 LINETYPE number_lines;
1107 #endif
1108 /***********************************************************************/
1109 {
1110    LINETYPE start_line = curr_ppc->ppc_line_number;
1111    LENGTHTYPE start_col=PENDING_VIEW->zone_start-1;
1112    LENGTHTYPE end_col=PENDING_VIEW->zone_end-1;
1113 
1114    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1115    if (start_line != 0L
1116    &&  start_line != PENDING_FILE->number_lines+1)
1117    {
1118       do_actual_change_case(start_line,number_lines, CASE_UPPER, FALSE, DIRECTION_FORWARD, start_col, end_col );
1119    }
1120    return(0);
1121 }
1122 /***********************************************************************/
1123 #ifdef HAVE_PROTO
prefix_overlay(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1124 static short prefix_overlay(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1125 #else
1126 static short prefix_overlay(curr_ppc,cmd_idx,number_lines)
1127 THE_PPC *curr_ppc;
1128 short cmd_idx;
1129 LINETYPE number_lines;
1130 #endif
1131 /***********************************************************************/
1132 {
1133    short rc=(-1);
1134 #if 0
1135    unsigned short y=0,x=0;
1136    LINETYPE true_line=0L,num_lines=0L,dest_line=0L,lines_affected=0L;
1137    VIEW_DETAILS *old_mark_view=NULL;
1138    LINE *curr=NULL;
1139    LINETYPE save_current_line=PENDING_VIEW->current_line;
1140    LINETYPE top_line=curr_ppc->ppc_line_number;
1141    LINETYPE bottom_line;
1142    THE_PPC *target_ppc=NULL;
1143 
1144    if ((target_ppc = calculate_target_line()) == NULL)
1145       return(rc);
1146    dest_line = target_ppc->ppc_line_number+target_ppc->ppc_cmd_param;
1147    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1148    bottom_line = top_line + number_lines - ((number_lines < 0L) ? (-1L) : 1L);
1149 
1150    if (top_line != 0L
1151    &&  top_line != PENDING_FILE->number_lines+1)
1152    {
1153       true_line = get_true_line(TRUE);
1154 
1155       rc = rearrange_line_blocks(COMMAND_OVERLAY_COPY,SOURCE_PREFIX,top_line,
1156                             bottom_line,dest_line,1,PENDING_VIEW,PENDING_VIEW,FALSE,
1157                             &lines_affected);
1158       if (rc == RC_OK
1159       &&  lines_affected != 0)
1160       {
1161          top_line = bottom_line = dest_line + lines_affected;
1162          curr = lll_find(PENDING_FILE->first_line,PENDING_FILE->last_line,top_line,PENDING_FILE->number_lines);
1163          for ( ; ; )
1164          {
1165             if (PENDING_VIEW->scope_all
1166             ||  IN_SCOPE(PENDING_VIEW,curr))
1167                lines_affected--;
1168             curr = curr->next;
1169             if (curr == NULL
1170             ||  lines_affected == 0L
1171             ||  bottom_line == PENDING_FILE->number_lines)
1172                break;
1173             bottom_line++;
1174          }
1175          dest_line = true_line;
1176          post_process_line(PENDING_VIEW,PENDING_VIEW->focus_line,(LINE *)NULL,TRUE);
1177          rc = rearrange_line_blocks(COMMAND_OVERLAY_DELETE,SOURCE_PREFIX,top_line,
1178                             bottom_line,dest_line,1,PENDING_VIEW,PENDING_VIEW,FALSE,
1179                             &lines_affected);
1180       }
1181    }
1182    clear_pending_prefix_command( target_ppc, PENDING_FILE, (LINE *)NULL );
1183 #endif
1184    return(rc);
1185 }
1186 /***********************************************************************/
1187 #ifdef HAVE_PROTO
prefix_block_duplicate(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_occ)1188 static short prefix_block_duplicate(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_occ)
1189 #else
1190 static short prefix_block_duplicate(curr_ppc,cmd_idx,number_occ)
1191 THE_PPC *curr_ppc;
1192 short cmd_idx;
1193 LINETYPE number_occ;
1194 #endif
1195 /***********************************************************************/
1196 {
1197    short rc=(-1);
1198    LINETYPE top_line=0L,bottom_line=0L,lines_affected=0L;
1199    THE_PPC *top_ppc=NULL;
1200 
1201    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1202       return(rc);
1203 
1204    top_line = top_ppc->ppc_line_number;
1205    bottom_line = curr_ppc->ppc_line_number;
1206    top_line = (top_line == 0L) ? 1L : top_line;
1207    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1208 
1209    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1210    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1211    rc = rearrange_line_blocks( COMMAND_DUPLICATE, SOURCE_PREFIX, top_line, bottom_line, bottom_line, number_occ, PENDING_VIEW, PENDING_VIEW, FALSE, &lines_affected );
1212    return(rc);
1213 }
1214 /***********************************************************************/
1215 #ifdef HAVE_PROTO
prefix_block_copy(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1216 static short prefix_block_copy(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1217 #else
1218 static short prefix_block_copy(curr_ppc,cmd_idx,number_lines)
1219 THE_PPC *curr_ppc;
1220 short cmd_idx;
1221 LINETYPE number_lines;
1222 #endif
1223 /***********************************************************************/
1224 {
1225    short rc=(-1);
1226    LINETYPE top_line=0L,bottom_line=0L,target_line=0L,lines_affected=0L;
1227    THE_PPC *top_ppc=NULL;
1228    THE_PPC *target_ppc=NULL;
1229 
1230    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1231       return(rc);
1232    if ( ( target_ppc = calculate_target_line() ) == NULL )
1233       return(rc);
1234 
1235    target_line = target_ppc->ppc_line_number+target_ppc->ppc_cmd_param;
1236    top_line = top_ppc->ppc_line_number;
1237    bottom_line = curr_ppc->ppc_line_number;
1238    top_line = (top_line == 0L) ? 1L : top_line;
1239    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1240 
1241    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1242    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1243    rc = rearrange_line_blocks( COMMAND_COPY, SOURCE_PREFIX, top_line, bottom_line, target_line, 1, PENDING_VIEW, PENDING_VIEW, FALSE, &lines_affected );
1244    clear_pending_prefix_command( target_ppc, PENDING_FILE, (LINE *)NULL );
1245    return(rc);
1246 }
1247 /***********************************************************************/
1248 #ifdef HAVE_PROTO
prefix_block_move(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1249 static short prefix_block_move(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1250 #else
1251 static short prefix_block_move(curr_ppc,cmd_idx,number_lines)
1252 THE_PPC *curr_ppc;
1253 short cmd_idx;
1254 LINETYPE number_lines;
1255 #endif
1256 /***********************************************************************/
1257 {
1258    short rc=(-1);
1259    LINETYPE top_line=0L,bottom_line=0L,target_line=0L,num_lines=0L,lines_affected=0L;
1260    THE_PPC *top_ppc=NULL;
1261    THE_PPC *target_ppc=NULL;
1262 
1263    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1264       return(rc);
1265    if ( ( target_ppc = calculate_target_line() ) == NULL )
1266       return(rc);
1267 
1268    target_line = target_ppc->ppc_line_number+target_ppc->ppc_cmd_param;
1269    top_line = top_ppc->ppc_line_number;
1270    bottom_line = curr_ppc->ppc_line_number;
1271    top_line = (top_line == 0L) ? 1L : top_line;
1272    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1273    /*
1274     * Quick validation of line numbers. Cannot move inside the block
1275     */
1276    if ( target_line > top_line
1277    &&   target_line < bottom_line )
1278    {
1279       invalidate_prefix( target_ppc, "Prefix \"%s\" is invalid for the line on which is was entered" );
1280       return(-1);
1281    }
1282    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1283    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1284    if ( ( rc = rearrange_line_blocks( COMMAND_MOVE_COPY_SAME, SOURCE_PREFIX, top_line, bottom_line, target_line, 1, PENDING_VIEW, PENDING_VIEW, FALSE, &lines_affected ) ) != RC_OK )
1285       return(rc);
1286    if ( target_line < top_line )
1287    {
1288       num_lines = bottom_line - top_line + 1L;
1289       top_line += num_lines;
1290       bottom_line += num_lines;
1291       target_line += num_lines;
1292    }
1293    rc = rearrange_line_blocks( COMMAND_MOVE_DELETE_SAME, SOURCE_PREFIX, top_line, bottom_line, target_line, 1, PENDING_VIEW, PENDING_VIEW, FALSE, &lines_affected );
1294    clear_pending_prefix_command( target_ppc, PENDING_FILE, (LINE *)NULL );
1295    return(rc);
1296 }
1297 /***********************************************************************/
1298 #ifdef HAVE_PROTO
prefix_block_delete(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1299 static short prefix_block_delete(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1300 #else
1301 static short prefix_block_delete(curr_ppc,cmd_idx,number_lines)
1302 THE_PPC *curr_ppc;
1303 short cmd_idx;
1304 LINETYPE number_lines;
1305 #endif
1306 /***********************************************************************/
1307 {
1308    short rc=(-1);
1309    LINETYPE top_line=0L,bottom_line=0L,lines_affected=0L;
1310    THE_PPC *top_ppc=NULL;
1311 
1312    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1313       return( rc );
1314 
1315    top_line = top_ppc->ppc_line_number;
1316    bottom_line = curr_ppc->ppc_line_number;
1317    top_line = (top_line == 0L) ? 1L : top_line;
1318    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1319 
1320    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1321    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1322    rc = rearrange_line_blocks( COMMAND_DELETE, SOURCE_PREFIX, top_line, bottom_line, bottom_line, 1, PENDING_VIEW, PENDING_VIEW, FALSE, &lines_affected );
1323    return(rc);
1324 }
1325 /***********************************************************************/
1326 #ifdef HAVE_PROTO
prefix_block_shift_left(THE_PPC * curr_ppc,short cmd_idx,LENGTHTYPE number_cols)1327 static short prefix_block_shift_left(THE_PPC *curr_ppc,short cmd_idx,LENGTHTYPE number_cols)
1328 #else
1329 static short prefix_block_shift_left(curr_ppc,cmd_idx,number_cols)
1330 THE_PPC *curr_ppc;
1331 short cmd_idx;
1332 LENGTHTYPE number_cols;
1333 #endif
1334 /***********************************************************************/
1335 {
1336    LINETYPE top_line=0L,bottom_line=0L;
1337    THE_PPC *top_ppc=NULL;
1338 
1339    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1340       return(-1);
1341 
1342    top_line = top_ppc->ppc_line_number;
1343    bottom_line = curr_ppc->ppc_line_number;
1344    top_line = (top_line == 0L) ? 1L : top_line;
1345    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1346 
1347    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1348    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1349    execute_shift_command( pending_screen, PENDING_VIEW, TRUE, number_cols, top_line, bottom_line-top_line+1L, FALSE, TARGET_UNFOUND, FALSE, FALSE );
1350    return(0);
1351 }
1352 /***********************************************************************/
1353 #ifdef HAVE_PROTO
prefix_block_shift_right(THE_PPC * curr_ppc,short cmd_idx,LENGTHTYPE number_cols)1354 static short prefix_block_shift_right(THE_PPC *curr_ppc,short cmd_idx,LENGTHTYPE number_cols)
1355 #else
1356 static short prefix_block_shift_right(curr_ppc,cmd_idx,number_cols)
1357 THE_PPC *curr_ppc;
1358 short cmd_idx;
1359 LENGTHTYPE number_cols;
1360 #endif
1361 /***********************************************************************/
1362 {
1363    LINETYPE top_line=0L,bottom_line=0L;
1364    THE_PPC *top_ppc=NULL;
1365 
1366    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1367       return(-1);
1368 
1369    top_line = top_ppc->ppc_line_number;
1370    bottom_line = curr_ppc->ppc_line_number;
1371    top_line = (top_line == 0L) ? 1L : top_line;
1372    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1373 
1374    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1375    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1376    execute_shift_command( pending_screen, PENDING_VIEW, FALSE, number_cols, top_line, bottom_line-top_line+1L, FALSE, TARGET_UNFOUND, FALSE, FALSE );
1377    return(0);
1378 }
1379 /***********************************************************************/
1380 #ifdef HAVE_PROTO
prefix_block_exclude(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1381 static short prefix_block_exclude(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1382 #else
1383 static short prefix_block_exclude(curr_ppc,cmd_idx,number_lines)
1384 THE_PPC *curr_ppc;
1385 short cmd_idx;
1386 LINETYPE number_lines;
1387 #endif
1388 /***********************************************************************/
1389 {
1390    short rc=RC_OK;
1391    LINETYPE top_line=0L,bottom_line=0L,num_lines=0L,i=0L;
1392    LINE *curr=NULL;
1393    THE_PPC *top_ppc=NULL;
1394 
1395    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1396       return(-1);
1397 
1398    top_line = top_ppc->ppc_line_number;
1399    bottom_line = curr_ppc->ppc_line_number;
1400    top_line = (top_line == 0L) ? 1L : top_line;
1401    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1402    num_lines = bottom_line-top_line+1L;
1403 
1404    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1405    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1406    /*
1407     * If the high value of SET DISPLAY is 255, we can't exclude any lines
1408     * so exit.
1409     */
1410    if ( PENDING_VIEW->display_high == 255 )
1411       return(rc);
1412    /*
1413     * Find the current line from where we start excluding...
1414     */
1415    curr = lll_find( PENDING_FILE->first_line, PENDING_FILE->last_line, top_line, PENDING_FILE->number_lines );
1416    /*
1417     * For the number of lines affected, change the select level if the
1418     * line is in scope.
1419     */
1420    for ( i = 0; i < num_lines; i++ )
1421    {
1422       if ( IN_SCOPE( PENDING_VIEW, curr ) )
1423          curr->select = (short)PENDING_VIEW->display_high + 1;
1424       curr = curr->next;
1425    }
1426    /*
1427     * Determine if current line is now not in scope...
1428     */
1429    curr = lll_find( PENDING_FILE->first_line, PENDING_FILE->last_line, PENDING_VIEW->current_line, PENDING_FILE->number_lines );
1430    if ( !IN_SCOPE( PENDING_VIEW, curr ) )
1431       PENDING_VIEW->current_line = find_next_in_scope( PENDING_VIEW, curr, PENDING_VIEW->current_line, DIRECTION_FORWARD );
1432    return(rc);
1433 }
1434 /***********************************************************************/
1435 #ifdef HAVE_PROTO
prefix_block_bounds_shift_left(THE_PPC * curr_ppc,short cmd_idx,LENGTHTYPE number_cols)1436 static short prefix_block_bounds_shift_left(THE_PPC *curr_ppc,short cmd_idx,LENGTHTYPE number_cols)
1437 #else
1438 static short prefix_block_bounds_shift_left(curr_ppc,cmd_idx,number_cols)
1439 THE_PPC *curr_ppc;
1440 short cmd_idx;
1441 LENGTHTYPE number_cols;
1442 #endif
1443 /***********************************************************************/
1444 {
1445    LINETYPE top_line=0L,bottom_line=0L;
1446    THE_PPC *top_ppc=NULL;
1447 
1448    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1449       return(-1);
1450 
1451    top_line = top_ppc->ppc_line_number;
1452    bottom_line = curr_ppc->ppc_line_number;
1453    top_line = (top_line == 0L) ? 1L : top_line;
1454    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1455 
1456    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1457    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1458    execute_shift_command( pending_screen, PENDING_VIEW, TRUE, number_cols, top_line, bottom_line-top_line+1L, FALSE, TARGET_UNFOUND, FALSE, TRUE );
1459    return(0);
1460 }
1461 /***********************************************************************/
1462 #ifdef HAVE_PROTO
prefix_block_bounds_shift_right(THE_PPC * curr_ppc,short cmd_idx,LENGTHTYPE number_cols)1463 static short prefix_block_bounds_shift_right(THE_PPC *curr_ppc,short cmd_idx,LENGTHTYPE number_cols)
1464 #else
1465 static short prefix_block_bounds_shift_right(curr_ppc,cmd_idx,number_cols)
1466 THE_PPC *curr_ppc;
1467 short cmd_idx;
1468 LENGTHTYPE number_cols;
1469 #endif
1470 /***********************************************************************/
1471 {
1472    LINETYPE top_line=0L,bottom_line=0L;
1473    THE_PPC *top_ppc=NULL;
1474 
1475    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1476       return(-1);
1477 
1478    top_line = top_ppc->ppc_line_number;
1479    bottom_line = curr_ppc->ppc_line_number;
1480    top_line = (top_line == 0L) ? 1L : top_line;
1481    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1482 
1483    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1484    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1485    execute_shift_command( pending_screen, PENDING_VIEW, FALSE, number_cols, top_line, bottom_line-top_line+1L, FALSE, TARGET_UNFOUND, FALSE, TRUE );
1486    return(0);
1487 }
1488 /***********************************************************************/
1489 #ifdef HAVE_PROTO
prefix_block_lowercase(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1490 static short prefix_block_lowercase(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1491 #else
1492 static short prefix_block_lowercase(curr_ppc,cmd_idx,number_lines)
1493 THE_PPC *curr_ppc;
1494 short cmd_idx;
1495 LINETYPE number_lines;
1496 #endif
1497 /***********************************************************************/
1498 {
1499    LENGTHTYPE start_col=PENDING_VIEW->zone_start-1;
1500    LENGTHTYPE end_col=PENDING_VIEW->zone_end-1;
1501    LINETYPE top_line=0L,bottom_line=0L;
1502    THE_PPC *top_ppc=NULL;
1503 
1504    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1505       return(-1);
1506 
1507    top_line = top_ppc->ppc_line_number;
1508    bottom_line = curr_ppc->ppc_line_number;
1509    top_line = (top_line == 0L) ? 1L : top_line;
1510    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1511 
1512    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1513    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1514    do_actual_change_case( top_line, bottom_line-top_line+1L, CASE_LOWER, FALSE, DIRECTION_FORWARD, start_col, end_col );
1515    return(0);
1516 }
1517 /***********************************************************************/
1518 #ifdef HAVE_PROTO
prefix_block_uppercase(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1519 static short prefix_block_uppercase(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1520 #else
1521 static short prefix_block_uppercase(curr_ppc,cmd_idx,number_lines)
1522 THE_PPC *curr_ppc;
1523 short cmd_idx;
1524 LINETYPE number_lines;
1525 #endif
1526 /***********************************************************************/
1527 {
1528    LENGTHTYPE start_col=PENDING_VIEW->zone_start-1;
1529    LENGTHTYPE end_col=PENDING_VIEW->zone_end-1;
1530    LINETYPE top_line=0L,bottom_line=0L;
1531    THE_PPC *top_ppc=NULL;
1532 
1533    if ( ( top_ppc = find_top_ppc( curr_ppc, cmd_idx ) ) == NULL )
1534       return(-1);
1535 
1536    top_line = top_ppc->ppc_line_number;
1537    bottom_line = curr_ppc->ppc_line_number;
1538    top_line = (top_line == 0L) ? 1L : top_line;
1539    bottom_line = (bottom_line == PENDING_FILE->number_lines+1L) ? bottom_line-1L : bottom_line;
1540 
1541    clear_pending_prefix_command( curr_ppc, PENDING_FILE, (LINE *)NULL );
1542    clear_pending_prefix_command( top_ppc, PENDING_FILE, (LINE *)NULL );
1543    do_actual_change_case( top_line, bottom_line-top_line+1L, CASE_UPPER, FALSE, DIRECTION_FORWARD, start_col, end_col );
1544    return(0);
1545 }
1546 /***********************************************************************/
1547 #ifdef HAVE_PROTO
prefix_block_overlay(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)1548 static short prefix_block_overlay(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
1549 #else
1550 static short prefix_block_overlay(curr_ppc,cmd_idx,number_lines)
1551 THE_PPC *curr_ppc;
1552 short cmd_idx;
1553 LINETYPE number_lines;
1554 #endif
1555 /***********************************************************************/
1556 {
1557    short rc=(-1);
1558 
1559    return(rc);
1560 }
1561 /***********************************************************************/
1562 #ifdef HAVE_PROTO
invalidate_prefix(THE_PPC * curr_ppc,char * template)1563 static short invalidate_prefix(THE_PPC *curr_ppc, char *template)
1564 #else
1565 static short invalidate_prefix(curr_ppc,template)
1566 THE_PPC *curr_ppc;
1567 char *template;
1568 #endif
1569 /***********************************************************************/
1570 {
1571    short len=0;
1572    CHARTYPE _THE_FAR buf[MAX_PREFIX_WIDTH+150];
1573 
1574    if ( *(curr_ppc->ppc_orig_command) != '?' )
1575    {
1576       len = strlen( (DEFCHAR *)curr_ppc->ppc_orig_command );
1577       meminschr( curr_ppc->ppc_orig_command, '?', 0, PENDING_VIEW->prefix_width, len );
1578       *(curr_ppc->ppc_orig_command+len+1) = '\0';
1579    }
1580    /*
1581     * ensure that there is no chance that a 'real' prefix command can be
1582     * executed.
1583     */
1584    curr_ppc->ppc_cmd_idx = THE_PPC_NO_COMMAND;
1585    /*
1586     * Display an error. If we supply a template use that.
1587     */
1588    if ( template == NULL )
1589    {
1590       sprintf( (DEFCHAR *)buf, "Invalid prefix subcommand: %s", curr_ppc->ppc_orig_command+1 );
1591    }
1592    else
1593    {
1594       sprintf( (DEFCHAR *)buf, template, curr_ppc->ppc_orig_command+1 );
1595    }
1596    display_error( 0, (CHARTYPE *)buf, FALSE );
1597    return(RC_OK);
1598 }
1599 /***********************************************************************/
1600 #ifdef HAVE_PROTO
clear_pending_prefix_command(THE_PPC * curr_ppc,FILE_DETAILS * curr_file,LINE * curr_line)1601 void clear_pending_prefix_command( THE_PPC *curr_ppc, FILE_DETAILS *curr_file, LINE *curr_line )
1602 #else
1603 void clear_pending_prefix_command( curr_ppc, curr_file, curr_line )
1604 THE_PPC *curr_ppc;
1605 FILE_DETAILS *curr_file;
1606 LINE *curr_line;
1607 #endif
1608 /***********************************************************************/
1609 {
1610    LINE *curr=curr_line;
1611 
1612    /*
1613     * If curr_ppc == NULL, then do nothing.
1614     */
1615    if (curr_ppc == NULL)
1616       return;
1617    if (curr == (LINE *)NULL)
1618       curr = lll_find(curr_file->first_line,curr_file->last_line,curr_ppc->ppc_line_number,curr_file->number_lines);
1619    curr->pre = NULL;
1620    curr_ppc->ppc_cmd_idx = (-1);
1621    curr_ppc->ppc_block_command = FALSE;
1622    curr_ppc->ppc_shadow_line = FALSE;
1623    curr_ppc->ppc_set_by_pending = FALSE;
1624    curr_ppc->ppc_orig_command[0] = '\0';
1625    curr_ppc->ppc_command[0] = '\0';
1626    curr_ppc->ppc_processed = TRUE;
1627    return;
1628 }
1629 /***********************************************************************/
1630 #ifdef HAVE_PROTO
delete_pending_prefix_command(THE_PPC * curr_ppc,FILE_DETAILS * curr_file,LINE * curr_line)1631 THE_PPC *delete_pending_prefix_command(THE_PPC *curr_ppc,FILE_DETAILS *curr_file,LINE *curr_line)
1632 #else
1633 THE_PPC *delete_pending_prefix_command(curr_ppc,curr_file,curr_line)
1634 THE_PPC *curr_ppc;
1635 FILE_DETAILS *curr_file;
1636 LINE *curr_line;
1637 #endif
1638 /***********************************************************************/
1639 {
1640    LINE *curr=curr_line;
1641    THE_PPC *return_ppc=NULL;
1642 
1643    /*
1644     * If curr_ppc == NULL, then do nothing.
1645     */
1646    if (curr_ppc == NULL)
1647       return(NULL);
1648    if (curr == (LINE *)NULL)
1649       curr = lll_find(curr_file->first_line,curr_file->last_line,curr_ppc->ppc_line_number,curr_file->number_lines);
1650    curr->pre = NULL;
1651    return_ppc = pll_del(&(curr_file->first_ppc),&(curr_file->last_ppc),curr_ppc,DIRECTION_FORWARD);
1652    return(return_ppc);
1653 }
1654 /***********************************************************************/
1655 #ifdef HAVE_PROTO
find_top_ppc(THE_PPC * curr_ppc,short top_cmd_idx)1656 static THE_PPC *find_top_ppc(THE_PPC *curr_ppc,short top_cmd_idx)
1657 #else
1658 static THE_PPC *find_top_ppc(curr_ppc,top_cmd_idx)
1659 THE_PPC *curr_ppc;
1660 short top_cmd_idx;
1661 #endif
1662 /***********************************************************************/
1663 {
1664    THE_PPC *top_ppc=PENDING_FILE->first_ppc;
1665 
1666    while( top_ppc != curr_ppc)
1667    {
1668       if ( top_cmd_idx == top_ppc->ppc_cmd_idx
1669       &&   top_ppc->ppc_processed == FALSE )
1670       {
1671          return(top_ppc);
1672       }
1673       top_ppc = top_ppc->next;
1674    }
1675    return(NULL);
1676 }
1677 /***********************************************************************/
1678 #ifdef HAVE_PROTO
find_target_ppc(void)1679 static THE_PPC *find_target_ppc(void)
1680 #else
1681 static THE_PPC *find_target_ppc()
1682 #endif
1683 /***********************************************************************/
1684 {
1685    THE_PPC *target_ppc=NULL;
1686 
1687    target_ppc = PENDING_FILE->first_ppc;
1688    while(target_ppc != NULL)
1689    {
1690       if ( target_ppc->ppc_processed == FALSE )
1691       {
1692          if (target_ppc->ppc_cmd_idx == THE_PPC_TARGET_PREVIOUS
1693          ||  target_ppc->ppc_cmd_idx == THE_PPC_TARGET_FOLLOWING)
1694             return(target_ppc);
1695       }
1696       target_ppc = target_ppc->next;
1697    }
1698    return(NULL);
1699 }
1700 /***********************************************************************/
1701 #ifdef HAVE_PROTO
calculate_target_line(void)1702 static THE_PPC *calculate_target_line(void)
1703 #else
1704 static THE_PPC *calculate_target_line()
1705 #endif
1706 /***********************************************************************/
1707 {
1708    THE_PPC *target_ppc=NULL;
1709 
1710    if ((target_ppc = find_target_ppc()) == NULL)
1711       return(NULL);
1712    target_ppc->ppc_cmd_param = 0L;
1713    switch( target_ppc->ppc_cmd_idx )
1714    {
1715       case THE_PPC_TARGET_PREVIOUS:
1716          /*
1717           * If the target line is NOT top of file line and the target type is
1718           * PREVIOUS, subtract 1 from the target line.
1719           */
1720          if ( !TOF(target_ppc->ppc_line_number) )
1721             target_ppc->ppc_cmd_param = (-1);
1722 #if 0
1723          else if ( 1 )
1724          {
1725             LINETYPE find_last_not_in_scope( PENDING_VIEW,LINE *in_curr,LINETYPE line_number,short direction)
1726             target->last_line = find_next_in_scope(PENDING_VIEW,curr,++line_number,DIRECTION_FORWARD);
1727             target_ppc->ppc_cmd_param = (-1);
1728          }
1729 #endif
1730          break;
1731       case THE_PPC_TARGET_FOLLOWING:
1732          /*
1733           * If the target line is the bottom of file and the target type is
1734           * FOLLOWING, subtract 1 from the target line.
1735           */
1736          if ( BOF(target_ppc->ppc_line_number) )
1737             target_ppc->ppc_cmd_param = (-1);
1738 #if 0
1739          else if ( 1 )
1740          {
1741             target->last_line = find_next_in_scope(PENDING_VIEW,curr,++line_number,DIRECTION_FORWARD);
1742             target_ppc->ppc_cmd_param = 1;
1743          }
1744 #endif
1745          break;
1746       default:
1747          break;
1748    }
1749    return(target_ppc);
1750 }
1751 /***********************************************************************/
1752 #ifdef HAVE_PROTO
try_rexx_prefix_macro(THE_PPC * curr_ppc)1753 static short try_rexx_prefix_macro( THE_PPC *curr_ppc )
1754 #else
1755 static short try_rexx_prefix_macro( curr_ppc )
1756 THE_PPC *curr_ppc;
1757 #endif
1758 /***********************************************************************/
1759 {
1760    short pmacro_rc=0, errnum = 0 ;
1761    LINETYPE line_number=0L;
1762    CHARTYPE _THE_FAR pm_parms[(MAX_PREFIX_WIDTH*4)+1];
1763    short macrorc=0;
1764    int i;
1765 
1766    TRACE_FUNCTION("prefix.c:  try_rexx_prefix_macro");
1767    /*
1768     * If the parsed command is blank, ignore it.
1769     */
1770    if ( blank_field( curr_ppc->ppc_command ) )
1771    {
1772       TRACE_RETURN();
1773       return( RC_NOT_COMMAND );
1774    }
1775    get_valid_macro_file_name( find_prefix_synonym( curr_ppc->ppc_command ), temp_cmd, macro_suffix, &errnum );
1776    if (errnum == 0)
1777    {
1778       line_number = curr_ppc->ppc_line_number;
1779       /*
1780        * If the prefix command was entered on a shadow line, pass this to
1781        * the prefix macro...
1782        */
1783       if (curr_ppc->ppc_shadow_line)
1784          sprintf( (DEFCHAR *)pm_parms, " PREFIX %s SHADOW %ld", curr_ppc->ppc_command, line_number );
1785       else
1786          sprintf( (DEFCHAR *)pm_parms, " PREFIX %s SET %ld", curr_ppc->ppc_command, line_number );
1787       for ( i = 0; i < PPC_OPERANDS; i++ )
1788       {
1789          if ( strlen( (DEFCHAR *)curr_ppc->ppc_op[i] ) != 0 )
1790          {
1791             strcat( (DEFCHAR *)pm_parms, " " );
1792             strcat( (DEFCHAR *)pm_parms, (DEFCHAR *)curr_ppc->ppc_op[i] );
1793          }
1794       }
1795       strcat( (DEFCHAR *)temp_cmd, (DEFCHAR *)pm_parms );     /* add on the parameter list */
1796       prefix_current_line = line_number;
1797       in_prefix_macro = TRUE;
1798       /*
1799        * Go and execute the prefix macro.
1800        */
1801       pmacro_rc = execute_macro( temp_cmd, TRUE, &macrorc );
1802       in_prefix_macro = FALSE;
1803    }
1804    else
1805       pmacro_rc = RC_NOT_COMMAND;
1806    TRACE_RETURN();
1807    return(pmacro_rc);
1808 }
1809 
1810 /***********************************************************************/
1811 #ifdef HAVE_PROTO
split_prefix_command(CHARTYPE * str,THE_PPC * curr_ppc)1812 static void split_prefix_command( CHARTYPE *str, THE_PPC *curr_ppc )
1813 #else
1814 static void split_prefix_command( str, curr_ppc )
1815 CHARTPE *str;
1816 THE_PPC *curr_ppc;
1817 #endif
1818 /***********************************************************************/
1819 {
1820 #define STATE_BEFORE_CMD 0
1821 #define STATE_ALPHA_CMD 1
1822 #define STATE_OTHER_CMD 2
1823 #define STATE_DIGIT_OPERAND 3
1824 #define STATE_REM_OPERAND 4
1825 
1826    int opt_idx[PPC_OPERANDS] = {0,};
1827    char cmd[MAX_PREFIX_WIDTH];
1828    int cmd_idx = 0;
1829    int i,len=strlen( (DEFCHAR *)str );
1830    char ch=' ',lastch;
1831    int state = STATE_BEFORE_CMD;
1832    int option = -1;
1833    int have_cmd = 0;
1834 
1835    for ( i = 0; i < len; i++ )
1836    {
1837       lastch = ch;
1838       ch = str[i];
1839       switch( state )
1840       {
1841          case STATE_BEFORE_CMD:
1842             /*
1843              * determine what the cmd starts with:
1844              * ALPHA - alpha cmd
1845              * DIGIT - operand
1846              * other - other cmd
1847              */
1848             if ( isalpha( ch ) )
1849             {
1850                cmd[cmd_idx] = ch;
1851                cmd_idx++;
1852                state = STATE_ALPHA_CMD;
1853                break;
1854             }
1855             else if ( isdigit( ch ) )
1856             {
1857                if ( isspace( lastch ) )
1858                {
1859                   /*
1860                    * When we get a space, increment the option number. Don't do
1861                    * this if we are processing the last option; include the spaces
1862                    * as part of the last option
1863                    */
1864                   if ( option < PPC_OPERANDS-1 )
1865                      option++;
1866                }
1867                curr_ppc->ppc_op[option][opt_idx[option]] = ch;
1868                opt_idx[option]++;
1869                state = STATE_DIGIT_OPERAND;
1870             }
1871             else if ( isspace( ch ) )
1872             {
1873                ;
1874             }
1875             else
1876             {
1877                cmd[cmd_idx] = ch;
1878                cmd_idx++;
1879                state = STATE_OTHER_CMD;
1880                break;
1881             }
1882             break;
1883          case STATE_ALPHA_CMD:
1884             if ( isalpha( ch ) )
1885             {
1886                cmd[cmd_idx] = ch;
1887                cmd_idx++;
1888                state = STATE_ALPHA_CMD;
1889                break;
1890             }
1891             else
1892             {
1893                /*
1894                 * End of ALPHA_CMD
1895                 */
1896                have_cmd = 1;
1897                if ( !isspace( ch ) )
1898                {
1899                   if ( option < PPC_OPERANDS-1 )
1900                      option++;
1901                   curr_ppc->ppc_op[option][opt_idx[option]] = ch;
1902                   opt_idx[option]++;
1903                }
1904                state = STATE_REM_OPERAND;
1905             }
1906             break;
1907          case STATE_OTHER_CMD:
1908             if ( isspace( ch ) || isalpha( ch ) || isdigit( ch ) )
1909             {
1910                /*
1911                 * End of OTHER_CMD
1912                 */
1913                have_cmd = 1;
1914                if ( !isspace( ch ) )
1915                {
1916                   if ( option < PPC_OPERANDS-1 )
1917                      option++;
1918                   curr_ppc->ppc_op[option][opt_idx[option]] = ch;
1919                   opt_idx[option]++;
1920                   state = STATE_REM_OPERAND;
1921                }
1922             }
1923             else
1924             {
1925                /* still the cmd... */
1926                cmd[cmd_idx] = ch;
1927                cmd_idx++;
1928             }
1929             break;
1930          case STATE_DIGIT_OPERAND: /* only valid BEFORE CMD */
1931             if ( isspace( ch ) )
1932             {
1933                if ( option == PPC_OPERANDS-1 )
1934                {
1935                   curr_ppc->ppc_op[option][opt_idx[option]] = ch;
1936                   opt_idx[option]++;
1937                }
1938             }
1939             else if ( isdigit( ch ) )
1940             {
1941                if ( isspace( lastch ) )
1942                {
1943                   if ( option < PPC_OPERANDS-1 )
1944                      option++;
1945                }
1946                curr_ppc->ppc_op[option][opt_idx[option]] = ch;
1947                opt_idx[option]++;
1948             }
1949             else if ( isalpha( ch ) )
1950             {
1951                cmd[cmd_idx] = ch;
1952                cmd_idx++;
1953                state = STATE_ALPHA_CMD;
1954                break;
1955             }
1956             else
1957             {
1958                cmd[cmd_idx] = ch;
1959                cmd_idx++;
1960                state = STATE_OTHER_CMD;
1961             }
1962             break;
1963          /*
1964           * Operands after the command delimited by spaces:
1965           */
1966          case STATE_REM_OPERAND: /* only valid AFTER CMD */
1967             if ( option < PPC_OPERANDS-1 )
1968             {
1969                if ( isspace( ch ) )
1970                   break;
1971                if ( isspace( lastch ) )
1972                {
1973                   if ( option < PPC_OPERANDS )
1974                      option++;
1975                }
1976             }
1977             curr_ppc->ppc_op[option][opt_idx[option]] = ch;
1978             opt_idx[option]++;
1979             break;
1980          default:
1981             break;
1982       }
1983    }
1984    /*
1985     * Nul Terminate the command
1986     */
1987    cmd[cmd_idx] = '\0';
1988    strcpy( (DEFCHAR *)curr_ppc->ppc_command, (DEFCHAR *)cmd );
1989    /*
1990     * Nul Terminate each option
1991     */
1992    for ( i = 0; i < PPC_OPERANDS; i++ )
1993    {
1994       cmd_idx = opt_idx[i];
1995       curr_ppc->ppc_op[i][cmd_idx] = '\0';
1996    }
1997 }
1998 
1999 /***********************************************************************/
2000 #ifdef HAVE_PROTO
add_prefix_command(CHARTYPE curr_screen,VIEW_DETAILS * curr_view,LINE * curr,LINETYPE line_number,bool block_command,bool set_by_pending)2001 void add_prefix_command(CHARTYPE curr_screen,VIEW_DETAILS *curr_view,LINE *curr,LINETYPE line_number,bool block_command, bool set_by_pending)
2002 #else
2003 void add_prefix_command(curr_screen,curr_view,curr,line_number,block_command,set_by_pending)
2004 CHARTYPE curr_screen;
2005 VIEW_DETAILS *curr_view;
2006 LINE *curr;
2007 LINETYPE line_number;
2008 bool block_command,set_by_pending;
2009 #endif
2010 /***********************************************************************/
2011 {
2012    register short i=0;
2013    CHARTYPE temp_prefix_array[MAX_PREFIX_WIDTH+1];
2014    THE_PPC *curr_ppc=NULL;
2015    bool redisplay_screen=FALSE;
2016 
2017    TRACE_FUNCTION( "prefix.c:  add_prefix_command" );
2018    prefix_changed = FALSE;
2019    /*
2020     * Copy the contexts of the prefix record area into a temporary area.
2021     */
2022    for ( i = 0; i < pre_rec_len; i++ )
2023       temp_prefix_array[i] = pre_rec[i];
2024    temp_prefix_array[pre_rec_len] = '\0';
2025    strtrunc( temp_prefix_array );
2026    /*
2027     * If the prefix record area is blank, clear the pending prefix area.
2028     */
2029    if ( blank_field( temp_prefix_array ) )
2030    {
2031       (void)delete_pending_prefix_command( curr->pre, curr_view->file_for_view, curr );
2032       redisplay_screen = TRUE;
2033    }
2034    else
2035    {
2036       /*
2037        * If the input line already points to an entry in the array, use the
2038        * existing entry in the array, otherwise add to the next entry.
2039        */
2040       curr_ppc = pll_find( curr_view->file_for_view->first_ppc, line_number );
2041       if ( curr_ppc == NULL )  /* not found */
2042       {
2043          curr_ppc = pll_add( &curr_view->file_for_view->first_ppc, sizeof(THE_PPC), line_number );
2044          if ( curr_ppc == NULL )
2045          {
2046             display_error( 30, (CHARTYPE *)"", FALSE );
2047             TRACE_RETURN();
2048             return;
2049          }
2050       }
2051       curr->pre = curr_ppc;
2052       /*
2053        * Parse the prefix command line into command and operands.
2054        */
2055       strcpy( (DEFCHAR *)curr_ppc->ppc_orig_command, (DEFCHAR *)temp_prefix_array );
2056       split_prefix_command( temp_prefix_array, curr_ppc );
2057       curr_ppc->ppc_line_number = line_number;
2058       curr_ppc->ppc_block_command = block_command;
2059       curr_ppc->ppc_cmd_idx = (-1);
2060       if ( IN_SCOPE( curr_view, curr ) )
2061          curr_ppc->ppc_shadow_line = FALSE;
2062       else
2063          curr_ppc->ppc_shadow_line = TRUE;
2064       /*
2065        * Set whether the prefix command was entered in the prefix are or by SET PENDING
2066        */
2067      curr_ppc->ppc_set_by_pending = set_by_pending;
2068      curr_ppc->ppc_processed = FALSE;
2069    }
2070 
2071    if ( redisplay_screen )
2072    {
2073       build_screen( curr_screen );
2074       display_screen( curr_screen );
2075    }
2076    TRACE_RETURN();
2077    return;
2078 }
2079 /***********************************************************************/
2080 #ifdef HAVE_PROTO
add_prefix_synonym(CHARTYPE * synonym,CHARTYPE * macroname)2081 short add_prefix_synonym(CHARTYPE *synonym,CHARTYPE *macroname)
2082 #else
2083 short add_prefix_synonym(synonym,macroname)
2084 CHARTYPE *synonym,*macroname;
2085 #endif
2086 /***********************************************************************/
2087 /* Parameters:                                                         */
2088 /*    synonym: synonym for prefix macro                                */
2089 /*  macroname: name of REXX macro file                                 */
2090 /***********************************************************************/
2091 {
2092    LINE *curr=NULL;
2093 
2094    TRACE_FUNCTION("prefix.c:  add_prefix_synonym");
2095    /*
2096     * First thing is to delete any definitions that may exist for the
2097     * supplied synonym.
2098     */
2099    curr = first_prefix_synonym;
2100    while(curr != NULL)
2101    {
2102       if (strcmp((DEFCHAR *)curr->name,(DEFCHAR *)synonym) == 0)
2103       {
2104          if (curr->name != NULL)
2105             (*the_free)(curr->name);
2106          if (curr->line != NULL)
2107             (*the_free)(curr->line);
2108          curr = lll_del(&first_prefix_synonym,&last_prefix_synonym,curr,DIRECTION_FORWARD);
2109       }
2110       else
2111          curr = curr->next;
2112    }
2113    /*
2114     * If synonym and macroname are the same we are deleting the synonym
2115     * (already done above); just don't add it. Bug 3313877
2116     */
2117    if ( strcmp( (DEFCHAR *)synonym, (DEFCHAR *)macroname ) != 0 )
2118    {
2119       /*
2120        * Lastly append the synonym at the end of the linked list.
2121        */
2122       curr = lll_add(first_prefix_synonym,last_prefix_synonym,sizeof(LINE));
2123       if (curr == NULL)
2124       {
2125          display_error(30,(CHARTYPE *)"",FALSE);
2126          TRACE_RETURN();
2127          return(RC_OUT_OF_MEMORY);
2128       }
2129       curr->line = (CHARTYPE *)(*the_malloc)((strlen((DEFCHAR *)macroname)+1)*sizeof(CHARTYPE));
2130       if (curr->line == NULL)
2131       {
2132          display_error(30,(CHARTYPE *)"",FALSE);
2133          TRACE_RETURN();
2134          return(RC_OUT_OF_MEMORY);
2135       }
2136       strcpy((DEFCHAR *)curr->line,(DEFCHAR *)macroname);
2137       curr->name = (CHARTYPE *)(*the_malloc)((strlen((DEFCHAR *)synonym)+1)*sizeof(CHARTYPE));
2138       if (curr->name == NULL)
2139       {
2140          display_error(30,(CHARTYPE *)"",FALSE);
2141          TRACE_RETURN();
2142          return(RC_OUT_OF_MEMORY);
2143       }
2144       strcpy((DEFCHAR *)curr->name,(DEFCHAR *)synonym);
2145       last_prefix_synonym = curr;
2146       if (first_prefix_synonym == NULL)
2147          first_prefix_synonym = last_prefix_synonym;
2148    }
2149    TRACE_RETURN();
2150    return(RC_OK);
2151 }
2152 /*man***************************************************************************
2153 NAME
2154      find_prefix_synonym
2155 
2156 SYNOPSIS
2157      CHARTYPE *find_prefix_synonym(synonym)
2158      CHARTYPE *synonym;
2159 
2160 DESCRIPTION
2161      The find_prefix_synonym function finds a synonym for 'synonym'
2162      and returns that value. If no synonym exists, the 'synonym' is
2163      returned unchanged.
2164 
2165      This function is only available if REXX support is available.
2166 
2167 RETURN VALUE
2168      Either the macroname associated with 'synonym' or 'synonym'.
2169 *******************************************************************************/
2170 #ifdef HAVE_PROTO
find_prefix_synonym(CHARTYPE * synonym)2171 CHARTYPE *find_prefix_synonym(CHARTYPE *synonym)
2172 #else
2173 CHARTYPE *find_prefix_synonym(synonym)
2174 CHARTYPE *synonym;
2175 #endif
2176 /***********************************************************************/
2177 {
2178    LINE *curr=NULL;
2179 
2180    TRACE_FUNCTION("prefix.c:  find_prefix_synonym");
2181    curr = first_prefix_synonym;
2182    while(curr != NULL)
2183    {
2184       if (strcmp((DEFCHAR *)synonym,(DEFCHAR *)curr->name) == 0)
2185       {
2186          TRACE_RETURN();
2187          return((CHARTYPE *)curr->line);
2188       }
2189       curr = curr->next;
2190    }
2191    TRACE_RETURN();
2192    return(synonym);
2193 }
2194 /*man***************************************************************************
2195 NAME
2196      find_prefix_oldname
2197 
2198 SYNOPSIS
2199      CHARTYPE *find_prefix_oldname(oldname)
2200      CHARTYPE *oldname;
2201 
2202 DESCRIPTION
2203      The find_prefix_oldname function finds the synonym for
2204      'oldname' and returns that value. If no synonym exists, the
2205      'oldname' is returned unchanged.
2206 
2207      This function is only available if REXX support is available.
2208 
2209 RETURN VALUE
2210      Either the synonym associated with 'oldname' or 'oldname'.
2211 *******************************************************************************/
2212 #ifdef HAVE_PROTO
find_prefix_oldname(CHARTYPE * oldname)2213 CHARTYPE *find_prefix_oldname(CHARTYPE *oldname)
2214 #else
2215 CHARTYPE *find_prefix_oldname(oldname)
2216 CHARTYPE *oldname;
2217 #endif
2218 /***********************************************************************/
2219 {
2220    LINE *curr=NULL;
2221 
2222    TRACE_FUNCTION("prefix.c:  find_prefix_oldname");
2223    curr = first_prefix_synonym;
2224    while(curr != NULL)
2225    {
2226       if (strcmp((DEFCHAR *)oldname,(DEFCHAR *)curr->line) == 0)
2227       {
2228          TRACE_RETURN();
2229          return(curr->name);
2230       }
2231       curr = curr->next;
2232    }
2233    TRACE_RETURN();
2234    return(oldname);
2235 }
2236 /***********************************************************************/
2237 #ifdef HAVE_PROTO
get_prefix_command(LINETYPE prefix_index)2238 CHARTYPE *get_prefix_command(LINETYPE prefix_index)
2239 #else
2240 CHARTYPE *get_prefix_command(prefix_index)
2241 LINETYPE prefix_index;
2242 #endif
2243 /***********************************************************************/
2244 {
2245    int ispf_idx = (compatible_feel==COMPAT_ISPF) ? 1 : 0;
2246 
2247    TRACE_FUNCTION("prefix.c:  get_prefix_command");
2248    /*
2249     * Just return a pointer to the prefix command associated with the
2250     * supplied index.
2251     */
2252    TRACE_RETURN();
2253    return(pc[ispf_idx][prefix_index].cmd);
2254 }
2255 /***********************************************************************/
2256 #ifdef HAVE_PROTO
post_prefix_add(THE_PPC * curr_ppc,short cmd_idx,LINETYPE number_lines)2257 static short post_prefix_add(THE_PPC *curr_ppc,short cmd_idx,LINETYPE number_lines)
2258 #else
2259 static short post_prefix_add(curr_ppc,cmd_idx,number_lines)
2260 THE_PPC *curr_ppc;
2261 short cmd_idx;
2262 LINETYPE number_lines;
2263 #endif
2264 /***********************************************************************/
2265 {
2266    short rc=RC_OK;
2267    unsigned short y=0,x=0;
2268 
2269    getyx( PENDING_WINDOW, y, x );
2270    if ( PENDING_VIEW->current_window == WINDOW_PREFIX )
2271       PENDING_VIEW->current_window = WINDOW_FILEAREA;
2272    wmove( PENDING_WINDOW, y, 0 );
2273    if ( PENDING_VIEW->current_window == WINDOW_FILEAREA )
2274    {
2275       if ( !VIEW_BOF( PENDING_VIEW, (PENDING_VIEW->focus_line)+1L ) )
2276          rc = THEcursor_down( pending_screen, PENDING_VIEW, TRUE );
2277    }
2278    return(rc);
2279 }
2280