1 /***********************************************************************/
2 /* COMMSET1.C - SET commands A-N                                       */
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 the_header_mapping thm[] =
40 {
41    {"NUMBER",                6,  HEADER_NUMBER      },
42    {"COMMENT",               7,  HEADER_COMMENT     },
43    {"STRING",                6,  HEADER_STRING      },
44    {"KEYWORD",               7,  HEADER_KEYWORD     },
45    {"FUNCTION",              8,  HEADER_FUNCTION    },
46    {"HEADER",                6,  HEADER_HEADER      },
47    {"LABEL",                 5,  HEADER_LABEL       },
48    {"MATCH",                 5,  HEADER_MATCH       },
49    {"COLUMN",                6,  HEADER_COLUMN      },
50    {"POSTCOMPARE",          11,  HEADER_POSTCOMPARE },
51    {"MARKUP",                6,  HEADER_MARKUP      },
52    {"DIRECTORY",             3,  HEADER_DIRECTORY   },
53    {"*",                     1,  HEADER_ALL         }, /* this should be last */
54    {NULL,                    0,  0                  },
55 };
56 
57 /*#define DEBUG 1*/
58 
59 /***********************************************************************/
60 #ifdef HAVE_PROTO
set_active_colour(short area)61 static short set_active_colour( short area )
62 #else
63 static short set_active_colour( area )
64 short area;
65 #endif
66 /***********************************************************************/
67 {
68    int i;
69    COLOUR_ATTR attr;
70    chtype ch=0L,nondisp_attr=0L;
71 
72    TRACE_FUNCTION("commset1.c:set_active_colour");
73 
74    memcpy( &attr, CURRENT_FILE->attr+area, sizeof(COLOUR_ATTR) );
75    /*
76     * Special handling required for NONDISP...
77     */
78    if (area == ATTR_NONDISP )
79    {
80       nondisp_attr = set_colour( &attr );
81       for ( i = 0 ; i < 256; i++ )
82       {
83          if (etmode_flag[i])
84          {
85 #ifdef VMS
86             ch = etmode_table[i];
87 #else
88             ch = etmode_table[i] & A_CHARTEXT;
89 #endif
90             etmode_table[i] = ch | nondisp_attr;
91          }
92       }
93    }
94    /*
95     * If we haven't started curses (in profile first time) exit now...
96     */
97    if (!curses_started)
98    {
99       TRACE_RETURN();
100       return(RC_OK);
101    }
102 #if ( defined(USE_XCURSES) || defined(USE_SDLCURSES) || defined(USE_WINGUICURSES) ) && PDC_BUILD >= 2501
103    /*
104     * For the special BOUNDMARK colour, set the curses global colour
105     * to the foreground and return
106     */
107    if ( area == ATTR_BOUNDMARK)
108    {
109       PDC_set_line_color(FOREFROMPAIR(attr.pair));
110       build_screen(current_screen);
111       display_screen(current_screen);
112       TRACE_RETURN();
113       return(RC_OK);
114    }
115 #endif
116    /*
117     * Update the appropriate window with the new colour combination...
118     */
119    switch (valid_areas[area].area_window)
120    {
121       case WINDOW_FILEAREA:
122          if (area == ATTR_FILEAREA)
123             wattrset(CURRENT_WINDOW_FILEAREA,set_colour(CURRENT_FILE->attr+area));
124          build_screen(current_screen);
125          display_screen(current_screen);
126 #if ( defined(USE_XCURSES) || defined(USE_SDLCURSES) || defined(USE_WINGUICURSES) ) && PDC_BUILD >= 2501
127          if ( area == ATTR_BOUNDMARK)
128          {
129             redraw_window(CURRENT_WINDOW_FILEAREA);
130             touchwin(CURRENT_WINDOW_FILEAREA);
131             wnoutrefresh(CURRENT_WINDOW_FILEAREA);
132          }
133 #endif
134          break;
135       case WINDOW_PREFIX:
136          if (CURRENT_WINDOW_PREFIX != NULL)
137          {
138             wattrset(CURRENT_WINDOW_PREFIX,set_colour(CURRENT_FILE->attr+area));
139             build_screen(current_screen);
140             display_screen(current_screen);
141          }
142          break;
143       case WINDOW_COMMAND:
144          if (CURRENT_WINDOW_COMMAND != NULL)
145          {
146             wattrset(CURRENT_WINDOW_COMMAND,set_colour(CURRENT_FILE->attr+area));
147             redraw_window(CURRENT_WINDOW_COMMAND);
148             touchwin(CURRENT_WINDOW_COMMAND);
149             wnoutrefresh(CURRENT_WINDOW_COMMAND);
150          }
151          break;
152       case WINDOW_ARROW:
153          if (CURRENT_WINDOW_ARROW != NULL)
154          {
155             wattrset(CURRENT_WINDOW_ARROW,set_colour(CURRENT_FILE->attr+area));
156             redraw_window(CURRENT_WINDOW_ARROW);
157             touchwin(CURRENT_WINDOW_ARROW);
158             wnoutrefresh(CURRENT_WINDOW_ARROW);
159          }
160          break;
161       case WINDOW_IDLINE:
162          if (CURRENT_WINDOW_IDLINE != NULL)
163          {
164             wattrset(CURRENT_WINDOW_IDLINE,set_colour(CURRENT_FILE->attr+area));
165             redraw_window(CURRENT_WINDOW_IDLINE);
166             touchwin(CURRENT_WINDOW_IDLINE);
167             wnoutrefresh(CURRENT_WINDOW_IDLINE);
168          }
169          break;
170       case WINDOW_STATAREA:
171          if (statarea != NULL)
172          {
173             wattrset(statarea,set_colour(CURRENT_FILE->attr+area));
174             redraw_window(statarea);
175             touchwin(statarea);
176             wnoutrefresh(statarea);
177          }
178          break;
179       case WINDOW_FILETABS:
180          if (filetabs != NULL)
181          {
182             wattrset(filetabs,set_colour(CURRENT_FILE->attr+area));
183             redraw_window(filetabs);
184             touchwin(filetabs);
185             wnoutrefresh(filetabs);
186          }
187          break;
188       case WINDOW_DIVIDER:
189          if (divider != (WINDOW *)NULL)
190          {
191             wattrset(divider,set_colour(CURRENT_FILE->attr+area));
192             if (display_screens > 1
193             &&  !horizontal)
194             {
195                draw_divider();
196                touchwin(divider);
197                wnoutrefresh(divider);
198             }
199          }
200          break;
201       case WINDOW_SLK:
202 #if defined(HAVE_SLK_INIT)
203          if ( max_slk_labels )
204          {
205 #if defined(HAVE_SLK_ATTRSET)
206             slk_attrset(set_colour(CURRENT_FILE->attr+area));
207 #else
208             display_error(61,(CHARTYPE *)"slk_attrset not in curses library",FALSE);
209 #endif
210             slk_touch();
211             slk_noutrefresh();
212          }
213 #endif
214          break;
215       default:
216          break;
217    }
218    TRACE_RETURN();
219    return(RC_OK);
220 }
221 
222 /*man-start*********************************************************************
223 
224 
225 ========================================================================
226 SET COMMAND REFERENCE
227 ========================================================================
228 **man-end**********************************************************************/
229 
230 /*man-start*********************************************************************
231 COMMAND
232      set alt - change alteration counts
233 
234 SYNTAX
235      [SET] ALT [n] [m]
236 
237 DESCRIPTION
238      The SET ALT command allows the user to change the alteration counts.
239      This command is usually called from within a macro.
240 
241      The first number; 'n' sets the number of changes since the last
242      AUTOSAVE was issued.
243 
244      The second number; 'm' sets the number of changes since the last
245      SAVE or SSAVE command was issued.
246 
247      All options can be specified as the current EQUIVCHAR to retain the
248      existing value.
249 
250 COMPATIBILITY
251      XEDIT: Compatible.
252      KEDIT: Compatible.
253 
254 DEFAULT
255      OFF
256 
257 SEE ALSO
258      <SET EQUIVCHAR>
259 
260 STATUS
261      Complete.
262 **man-end**********************************************************************/
263 #ifdef HAVE_PROTO
Alt(CHARTYPE * params)264 short Alt(CHARTYPE *params)
265 #else
266 short Alt(params)
267 CHARTYPE *params;
268 #endif
269 /***********************************************************************/
270 {
271 #define ALT_PARAMS  2
272    CHARTYPE strip[ALT_PARAMS];
273    CHARTYPE *word[ALT_PARAMS+1];
274    unsigned short num_params=0;
275    unsigned short autosave_alt=CURRENT_FILE->autosave_alt;
276    unsigned short save_alt=CURRENT_FILE->save_alt;
277 
278    TRACE_FUNCTION("commset1.c:Alt");
279    strip[0]=STRIP_BOTH;
280    num_params = param_split(params,word,ALT_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
281    if (num_params == 0)
282    {
283       display_error(3,(CHARTYPE *)"",FALSE);
284       TRACE_RETURN();
285       return(RC_INVALID_OPERAND);
286    }
287    if (num_params > 2)
288    {
289       display_error(2,(CHARTYPE *)"",FALSE);
290       TRACE_RETURN();
291       return(RC_INVALID_OPERAND);
292    }
293    if ( equal( word[0], EQUIVCHARstr, 1 ) )
294       autosave_alt = CURRENT_FILE->autosave_alt;
295    else
296    {
297       if (!valid_positive_integer(word[0]))
298       {
299          display_error(1,word[0],FALSE);
300          TRACE_RETURN();
301          return(RC_INVALID_OPERAND);
302       }
303       autosave_alt = atoi((DEFCHAR *)word[0]);
304    }
305    if (num_params == 2)
306    {
307       if ( equal( word[1], EQUIVCHARstr, 1 ) )
308          save_alt = CURRENT_FILE->save_alt;
309       else
310       {
311          if (!valid_positive_integer(word[1]))
312          {
313             display_error(1,word[1],FALSE);
314             TRACE_RETURN();
315             return(RC_INVALID_OPERAND);
316          }
317          save_alt = atoi((DEFCHAR *)word[1]);
318       }
319    }
320 
321    CURRENT_FILE->autosave_alt = autosave_alt;
322    CURRENT_FILE->save_alt = save_alt;
323 
324    TRACE_RETURN();
325    return(RC_OK);
326 }
327 /*man-start*********************************************************************
328 COMMAND
329      set arbchar - set arbitrary character(s) for targets
330 
331 SYNTAX
332      [SET] ARBchar ON|OFF [char1] [char2]
333 
334 DESCRIPTION
335      Set the character to use as an 'arbitrary character' in string
336      targets. The first arbitrary character matches a group of zero
337      or more characters, the second will match exactly one character.
338 
339      All options can be specified as the current EQUIVCHAR to retain the
340      existing value.
341 
342 COMPATIBILITY
343      XEDIT: Compatible.
344             Single arbitrary character not supported.
345      KEDIT: Compatible.
346             Arbitrary character not supported in <CHANGE> or <SCHANGE> commands.
347 
348 DEFAULT
349      Off $ ?
350 
351 SEE ALSO
352      <SET EQUIVCHAR>
353 
354 STATUS
355      Complete.
356 **man-end**********************************************************************/
357 #ifdef HAVE_PROTO
Arbchar(CHARTYPE * params)358 short Arbchar(CHARTYPE *params)
359 #else
360 short Arbchar(params)
361 CHARTYPE *params;
362 #endif
363 /***********************************************************************/
364 {
365 #define ARB_PARAMS  4
366    CHARTYPE *word[ARB_PARAMS+1];
367    CHARTYPE strip[ARB_PARAMS];
368    unsigned short num_params=0;
369    short rc=RC_INVALID_OPERAND;
370    bool arbsts=CURRENT_VIEW->arbchar_status;
371    CHARTYPE arbchr_single=CURRENT_VIEW->arbchar_single;
372    CHARTYPE arbchr_multiple=CURRENT_VIEW->arbchar_multiple;
373 
374    TRACE_FUNCTION("commset1.c:Arbchar");
375    /*
376     * Validate the parameters that have been supplied.
377     */
378    strip[0]=STRIP_BOTH;
379    strip[1]=STRIP_BOTH;
380    strip[2]=STRIP_BOTH;
381    strip[3]=STRIP_BOTH;
382    num_params = param_split(params,word,ARB_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
383    switch(num_params)
384    {
385       case 0:
386          /*
387           * No parameters, error.
388           */
389          display_error(3,(CHARTYPE *)"",FALSE);
390          break;
391       case 1:
392          /*
393           * 1 or 2 parameters, validate them...
394           */
395          if ( equal( word[0], EQUIVCHARstr, 1 ) )
396             ;
397          else
398             rc = execute_set_on_off(word[0],&arbsts, TRUE );
399          break;
400       case 2:
401       case 3:
402          if ( equal( word[0], EQUIVCHARstr, 1 ) )
403             ;
404          else
405          {
406             rc = execute_set_on_off(word[0],&arbsts, TRUE );
407             if (rc != RC_OK)
408               break;
409          }
410          rc = RC_INVALID_OPERAND;
411          /*
412           * For 2 parameters, check that a single character has been supplied...
413           */
414          if ( equal( word[1], EQUIVCHARstr, 1 ) )
415             ;
416          else
417          {
418             if (strlen((DEFCHAR *)word[1]) != 1)
419             {
420                display_error(1,word[1],FALSE);
421                break;
422             }
423             arbchr_multiple = word[1][0];
424          }
425          rc = RC_OK;
426          /*
427           * For 2 parameters, don't check any more.
428           */
429          if (num_params == 2)
430             break;
431          rc = RC_INVALID_OPERAND;
432          /*
433           * For 3 parameters, check that a single character has been supplied...
434           */
435          if ( equal( word[2], EQUIVCHARstr, 1 ) )
436             ;
437          else
438          {
439             if (strlen((DEFCHAR *)word[2]) != 1)
440             {
441                display_error(1,word[2],FALSE);
442                break;
443             }
444             arbchr_single = word[2][0];
445          }
446          rc = RC_OK;
447          break;
448       default:
449          /*
450           * Too many parameters...
451           */
452          display_error(2,(CHARTYPE *)"",FALSE);
453          break;
454    }
455    /*
456     * If valid parameters, change the settings...
457     */
458    if (rc == RC_OK)
459    {
460       CURRENT_VIEW->arbchar_single = arbchr_single;
461       CURRENT_VIEW->arbchar_multiple = arbchr_multiple;
462       CURRENT_VIEW->arbchar_status = arbsts;
463    }
464    TRACE_RETURN();
465    return(rc);
466 }
467 /*man-start*********************************************************************
468 COMMAND
469      set autocolor - specifies which parser to use for syntax highlighting
470 
471 SYNTAX
472      [SET] AUTOCOLOR mask parser [MAGIC]
473 
474 DESCRIPTION
475      The SET AUTOCOLOR command allows the user to specify which syntax
476      highlighting <parser> is to be used for which file masks.
477 
478      The 'parser' argument specifies a syntax highlighting <parser> that
479      already exists, either as a default <parser>, or added by the user
480      with <SET PARSER>.  The special parser name of '*NULL' can be
481      specified; this will effectively remove the association between
482      the <parser> and the file mask.
483 
484      The 'mask' argument specifies the file mask (or <magic number>) to
485      associate with the specified parser.  The 'mask' can be any valid
486      file mask for the operating system. eg *.c fred.* joe.?
487 
488      If the 'magic' option is specified, the 'mask' argument refers to
489      the last element of the <magic number> that is specified in the
490      first line of a Unix shell script comment. eg if the first line of
491      a shell script contains:
492      #!/usr/local/bin/rexx
493      then the file mask argument would be specified as "rexx".
494 
495 COMPATIBILITY
496      XEDIT: N/A
497      KEDIT: Similar. KEDIT does not have MAGIC option.
498 
499 DEFAULT
500      See <QUERY> AUTOCOLOR
501 
502 SEE ALSO
503      <SET COLORING>, <SET ECOLOUR>, <SET PARSER>
504 
505 STATUS
506      Complete.
507 **man-end**********************************************************************/
508 /*man-start*********************************************************************
509 COMMAND
510      set autocolour - specifies which parser to use for syntax highlighting
511 
512 SYNTAX
513      [SET] AUTOCOLOUR mask parser [MAGIC]
514 
515 DESCRIPTION
516      The SET AUTOCOLOUR command is a synonym for the <SET AUTOCOLOR> command.
517 
518 COMPATIBILITY
519      XEDIT: N/A
520      KEDIT: Similar. KEDIT does not have MAGIC option.
521 
522 DEFAULT
523      See <QUERY> AUTOCOLOR
524 
525 SEE ALSO
526      <SET AUTOCOLOR>
527 
528 STATUS
529      Complete.
530 **man-end**********************************************************************/
531 #ifdef HAVE_PROTO
Autocolour(CHARTYPE * params)532 short Autocolour(CHARTYPE *params)
533 #else
534 short Autocolour(params)
535 CHARTYPE *params;
536 #endif
537 /***********************************************************************/
538 {
539 #define AUCO_PARAMS  3
540    CHARTYPE *word[AUCO_PARAMS+1];
541    CHARTYPE strip[AUCO_PARAMS];
542    unsigned short num_params=0;
543    short rc=RC_OK;
544    PARSER_DETAILS *parser=NULL;
545    PARSER_MAPPING *mapping=NULL,*curr=NULL,*tmp_mapping;
546    CHARTYPE *filemask=NULL,*magic_number=NULL;
547    VIEW_DETAILS *curr_view=vd_first;
548    bool redisplay_current=FALSE,redisplay_other=FALSE;
549    int i,change=0;
550 
551    TRACE_FUNCTION("commset1.c:Autocolour");
552    /*
553     * Validate the parameters that have been supplied.
554     */
555    strip[0]=STRIP_BOTH;
556    strip[1]=STRIP_BOTH;
557    strip[2]=STRIP_BOTH;
558    num_params = param_split(params,word,AUCO_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
559    if (num_params < 2)
560    {
561       display_error(3,(CHARTYPE *)"",FALSE);
562       TRACE_RETURN();
563       return(RC_INVALID_OPERAND);
564    }
565    filemask = word[0];
566    if (num_params == 3)
567    {
568       if (equal((CHARTYPE *)"magic",word[2],5))
569       {
570          magic_number = word[0];
571          filemask = NULL;
572       }
573       else
574       {
575          display_error(1,word[2],FALSE);
576          TRACE_RETURN();
577          return(RC_INVALID_OPERAND);
578       }
579    }
580    /*
581     * Find a parser equal to the first parameter...
582     */
583    if (!equal((CHARTYPE *)"*null",word[1],5))
584    {
585       parser = parserll_find(first_parser,word[1]);
586       if (parser == NULL)
587       {
588          display_error(199,word[1],FALSE);
589          TRACE_RETURN();
590          return(RC_INVALID_OPERAND);
591       }
592    }
593    /*
594     * Now check if we already have a mapping for the mask/magic number
595     */
596    mapping = mappingll_find(first_parser_mapping,filemask,magic_number);
597    if (mapping)
598       curr = mapping;
599    /*
600     * Add the new mapping if it is a "real" parser.
601     */
602    if (parser)
603    {
604       curr = last_parser_mapping = mappingll_add(first_parser_mapping,last_parser_mapping,sizeof(PARSER_MAPPING));
605       if (first_parser_mapping == NULL)
606          first_parser_mapping = curr;
607       if (filemask)
608       {
609          curr->filemask = (CHARTYPE *)(*the_malloc)(1+strlen((DEFCHAR *)filemask)*sizeof(CHARTYPE));
610          if (curr->filemask == NULL)
611          {
612             display_error(30,(CHARTYPE *)"",FALSE);
613             TRACE_RETURN();
614             return(RC_OUT_OF_MEMORY);
615          }
616          strcpy((DEFCHAR *)curr->filemask,(DEFCHAR *)filemask);
617       }
618       if (magic_number)
619       {
620          curr->magic_number = (CHARTYPE *)(*the_malloc)(1+strlen((DEFCHAR *)magic_number)*sizeof(CHARTYPE));
621          if (curr->magic_number == NULL)
622          {
623             display_error(30,(CHARTYPE *)"",FALSE);
624             TRACE_RETURN();
625             return(RC_OUT_OF_MEMORY);
626          }
627          strcpy((DEFCHAR *)curr->magic_number,(DEFCHAR *)magic_number);
628          curr->magic_number_length = strlen((DEFCHAR *)magic_number);
629       }
630       curr->parser = parser;
631    }
632    /*
633     * Check all files in the ring and apply the new mapping. If the current
634     * file or the file in the other screen now match the new mapping,
635     * redisplay them.
636     */
637    for (i=0;i<number_of_files;)
638    {
639       if (curr
640       &&  find_parser_mapping(curr_view->file_for_view,curr))
641       {
642          curr_view->file_for_view->parser = parser;
643          if (curr_view->file_for_view == SCREEN_FILE(current_screen))
644             redisplay_current = TRUE;
645          if (display_screens > 1
646          &&  curr_view->file_for_view == SCREEN_FILE( (CHARTYPE)(other_screen) ))
647             redisplay_other = TRUE;
648       }
649       curr_view = curr_view->next;
650       if (curr_view == NULL)
651          break;
652    }
653    /*
654     * Now delete the old mapping if we found one earlier...
655     */
656    if (mapping)
657    {
658       mappingll_del(&first_parser_mapping,&last_parser_mapping,mapping,DIRECTION_FORWARD);
659       change--;
660    }
661    if (parser)
662    {
663       change++;
664    }
665    if (rexx_support)
666    {
667       if (change > 0)
668       {
669          CHARTYPE tmp[20];
670          /*
671           * As this is a new mapping, then register another implied extract
672           * function for the number of mappings we now have.
673           */
674          for(i=0,tmp_mapping=first_parser_mapping;tmp_mapping!=NULL;tmp_mapping=tmp_mapping->next,i++);
675          sprintf((DEFCHAR *)tmp,"autocolour.%d",i);
676          MyRexxRegisterFunctionExe(tmp);
677          sprintf((DEFCHAR *)tmp,"autocolor.%d",i);
678          MyRexxRegisterFunctionExe(tmp);
679       }
680       if (change < 0)
681       {
682          CHARTYPE tmp[20];
683          /*
684           * As this is a removal of a mapping, then deregister the implied extract
685           * function for the number of mappings we had before.
686           */
687          for(i=0,tmp_mapping=first_parser_mapping;tmp_mapping!=NULL;tmp_mapping=tmp_mapping->next,i++);
688          sprintf((DEFCHAR *)tmp,"autocolour.%d",i-1);
689          MyRexxDeregisterFunction(tmp);
690          sprintf((DEFCHAR *)tmp,"autocolor.%d",i-1);
691          MyRexxDeregisterFunction(tmp);
692       }
693    }
694 
695    if (redisplay_other)
696       display_screen( (CHARTYPE)(other_screen) );
697    if (redisplay_current)
698       display_screen(current_screen);
699 
700    TRACE_RETURN();
701    return(rc);
702 }
703 /*man-start*********************************************************************
704 COMMAND
705      set autosave - set autosave period
706 
707 SYNTAX
708      [SET] AUtosave n|OFF
709 
710 DESCRIPTION
711      The SET AUTOSAVE command sets the interval between automatic saves
712      of the file, or turns it off altogether.  The interval 'n' refers
713      to the number of alterations made to the file.  Hence a value of
714      10 for 'n' would result in the file being automatically saved after
715      each 10 alterations have been made to the file.
716 
717      It is not possible to set AUTOSAVE for 'pseudo' files such as the
718      directory listing 'file', Rexx output 'file' and the key definitions
719      'file'
720 
721 COMPATIBILITY
722      XEDIT: Does not support [mode] option.
723      KEDIT: Compatible.
724 
725 DEFAULT
726      OFF
727 
728 STATUS
729      Complete.
730 **man-end**********************************************************************/
731 #ifdef HAVE_PROTO
Autosave(CHARTYPE * params)732 short Autosave(CHARTYPE *params)
733 #else
734 short Autosave(params)
735 CHARTYPE *params;
736 #endif
737 /***********************************************************************/
738 {
739 #define AUS_PARAMS  1
740    CHARTYPE strip[AUS_PARAMS];
741    CHARTYPE *word[AUS_PARAMS+1];
742    unsigned short num_params=0;
743 
744    TRACE_FUNCTION("commset1.c:Autosave");
745    strip[0]=STRIP_BOTH;
746    num_params = param_split(params,word,AUS_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
747    if (num_params == 0)
748    {
749       display_error(3,(CHARTYPE *)"",FALSE);
750       TRACE_RETURN();
751       return(RC_INVALID_OPERAND);
752    }
753    if (num_params != 1)
754    {
755       display_error(2,(CHARTYPE *)"",FALSE);
756       TRACE_RETURN();
757       return(RC_INVALID_OPERAND);
758    }
759    if (equal((CHARTYPE *)"off",word[0],3))
760    {
761       CURRENT_FILE->autosave = 0;
762       TRACE_RETURN();
763       return(RC_OK);
764    }
765    if (!valid_positive_integer(word[0]))
766    {
767       display_error(4,(CHARTYPE *)word[0],FALSE);
768       TRACE_RETURN();
769       return(RC_INVALID_OPERAND);
770    }
771    CURRENT_FILE->autosave = (CHARTYPE)atoi((DEFCHAR *)word[0]);
772    TRACE_RETURN();
773    return(RC_OK);
774 }
775 /*man-start*********************************************************************
776 COMMAND
777      set autoscroll - set rate of automatic horizontal scrolling
778 
779 SYNTAX
780      [SET] AUTOSCroll n|OFF|Half
781 
782 DESCRIPTION
783      The SET AUTOSCROLL allows the user to set the rate at which automatic
784      horizontal scrolling occurs.
785 
786      When the cursor reaches the last (or first) column of the <filearea>
787      the <filearea> can automatically scroll if AUTOSCROLL is not 'OFF' and
788      a <CURSOR> RIGHT or <CURSOR> LEFT command is issued.
789      How many columns are scrolled is determined by the setting of AUTOSCROLL.
790 
791      If AUTOSCROLL is set to 'HALF', then half the number of columns in the
792      <filearea> window are scrolled.  Any other value will result in that
793      many columns scrolled, or the full width of the <filearea> window if
794      the set number of columns is larger.
795 
796      Autoscrolling does not occur if the key pressed is assigned to
797      <CURSOR> SCREEN LEFT or RIGHT, which is the case if <SET COMPAT> XEDIT
798      key definitions are active.
799 
800 COMPATIBILITY
801      XEDIT: N/A
802      KEDIT: Compatible.
803 
804 DEFAULT
805      HALF
806 
807 STATUS
808      Complete.
809 **man-end**********************************************************************/
810 #ifdef HAVE_PROTO
Autoscroll(CHARTYPE * params)811 short Autoscroll(CHARTYPE *params)
812 #else
813 short Autoscroll(params)
814 CHARTYPE *params;
815 #endif
816 /***********************************************************************/
817 {
818 #define AUL_PARAMS  1
819    CHARTYPE strip[AUL_PARAMS];
820    CHARTYPE *word[AUL_PARAMS+1];
821    unsigned short num_params=0;
822 
823    TRACE_FUNCTION("commset1.c:Autoscroll");
824    strip[0]=STRIP_BOTH;
825    num_params = param_split(params,word,AUL_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
826    if (num_params == 0)
827    {
828       display_error(3,(CHARTYPE *)"",FALSE);
829       TRACE_RETURN();
830       return(RC_INVALID_OPERAND);
831    }
832    if (num_params != 1)
833    {
834       display_error(2,(CHARTYPE *)"",FALSE);
835       TRACE_RETURN();
836       return(RC_INVALID_OPERAND);
837    }
838    if (equal((CHARTYPE *)"off",word[0],3))
839    {
840       CURRENT_VIEW->autoscroll = 0;
841       TRACE_RETURN();
842       return(RC_OK);
843    }
844    if (equal((CHARTYPE *)"half",word[0],1))
845    {
846       CURRENT_VIEW->autoscroll = (-1);
847       TRACE_RETURN();
848       return(RC_OK);
849    }
850    if (!valid_positive_integer(word[0]))
851    {
852       display_error(4,(CHARTYPE *)word[0],FALSE);
853       TRACE_RETURN();
854       return(RC_INVALID_OPERAND);
855    }
856    CURRENT_VIEW->autoscroll = (CHARTYPE)atol((DEFCHAR *)word[0]);
857    TRACE_RETURN();
858    return(RC_OK);
859 }
860 /*man-start*********************************************************************
861 COMMAND
862      set backup - indicate if a backup copy of the file is to be kept
863 
864 SYNTAX
865      [SET] BACKup OFF|TEMP|KEEP|ON|INPLACE [suffix]
866 
867 DESCRIPTION
868      The SET BACKUP command allows the user to determine if a backup copy
869      of the original file is to be kept when the file being edited is
870      saved or filed.
871 
872      'KEEP' and 'ON' options are the same. 'ON' is
873      kept for compatibility with previous versions of THE.
874 
875      With 'OFF', the file being written to disk will replace an
876      existing file. There is a chance that you will end up with neither
877      the old version of the file or the new one if problems occur
878      while the file is being written.
879 
880      With 'TEMP' or 'KEEP' options, the file being written is first
881      renamed to the filename with a .bak extension. The file in memory
882      is then written to disk. If 'TEMP' is in effect, the backup
883      file is then deleted.
884 
885      With 'INPLACE', the file being written is first copied to a file
886      with a .bak extension. The file in memory is then written to disk
887      in place of the original.  This option ensures that all operating
888      system file attributes are retained.
889 
890      The optional 'suffix' specifies the string to append to the file name
891      of the backup copy including a period if required. The maximum length
892      of 'suffix' is 100 characters.
893      By default this is ".bak".
894 
895 COMPATIBILITY
896      XEDIT: N/A
897      KEDIT: Compatible.
898             'suffix' is a THE extension
899 
900 DEFAULT
901      KEEP
902 
903 SEE ALSO
904      <FILE>, <FFILE>, <SAVE>, <SSAVE>
905 
906 STATUS
907      Complete.
908 **man-end**********************************************************************/
909 #ifdef HAVE_PROTO
Backup(CHARTYPE * params)910 short Backup(CHARTYPE *params)
911 #else
912 short Backup(params)
913 CHARTYPE *params;
914 #endif
915 /***********************************************************************/
916 {
917    short rc=RC_OK;
918 #define BAC_PARAMS  2
919    CHARTYPE *word[BAC_PARAMS+1];
920    CHARTYPE strip[BAC_PARAMS];
921    short num_params=0;
922 
923    TRACE_FUNCTION( "commset1.c:Backup" );
924    strip[0]=STRIP_BOTH;
925    strip[1]=STRIP_BOTH;
926    num_params = param_split( params, word, BAC_PARAMS, WORD_DELIMS, TEMP_PARAM, strip, FALSE );
927    if ( num_params == 0 )
928    {
929       display_error( 3, (CHARTYPE *)"", FALSE );
930       TRACE_RETURN();
931       return(RC_INVALID_OPERAND);
932    }
933    if ( num_params > 2 )
934    {
935       display_error( 2, (CHARTYPE *)"", FALSE );
936       TRACE_RETURN();
937       return(RC_INVALID_OPERAND);
938    }
939    /*
940     * Validate the first parameter
941     */
942    if ( equal( (CHARTYPE *)"off", word[0], 3 ) )
943       CURRENT_FILE->backup = BACKUP_OFF;
944    else if ( equal( (CHARTYPE *)"on", word[0], 2 ) )
945       CURRENT_FILE->backup = BACKUP_ON;
946    else if ( equal( (CHARTYPE *)"keep", word[0], 4 ) )
947       CURRENT_FILE->backup = BACKUP_KEEP;
948    else if ( equal( (CHARTYPE *)"temp", word[0], 4 ) )
949       CURRENT_FILE->backup = BACKUP_TEMP;
950    else if ( equal( (CHARTYPE *)"inplace", word[0], 2 ) )
951       CURRENT_FILE->backup = BACKUP_INPLACE;
952    else
953    {
954       display_error( 1, word[0], FALSE );
955       rc = RC_INVALID_OPERAND;
956    }
957    if ( num_params == 2 )
958    {
959       /*
960        * Save the second arg as the backup suffix
961        */
962       if ( strlen( (DEFCHAR *)word[1] ) > 100 )
963       {
964          display_error( 37, word[1], FALSE );
965          rc = RC_INVALID_OPERAND;
966       }
967       else
968       {
969          strcpy( (DEFCHAR *)BACKUP_SUFFIXx, (DEFCHAR *)word[1] );
970       }
971    }
972    TRACE_RETURN();
973    return(rc);
974 }
975 /*man-start*********************************************************************
976 COMMAND
977      set beep - turn on or off the audible alarm when displaying errors
978 
979 SYNTAX
980      [SET] BEEP ON|OFF
981 
982 DESCRIPTION
983      The SET BEEP command allows the user to determine if an audible
984      alarm is sounded when an error is displayed.
985 
986 COMPATIBILITY
987      XEDIT: N/A
988      KEDIT: Compatible.
989 
990 DEFAULT
991      OFF
992 
993 STATUS
994      Complete.
995 **man-end**********************************************************************/
996 #ifdef HAVE_PROTO
BeepSound(CHARTYPE * params)997 short BeepSound(CHARTYPE *params)
998 #else
999 short BeepSound(params)
1000 CHARTYPE *params;
1001 #endif
1002 /***********************************************************************/
1003 {
1004    short rc=RC_OK;
1005 
1006    TRACE_FUNCTION("commset1.c:BeepSound");
1007    rc = execute_set_on_off(params,&BEEPx, TRUE );
1008    TRACE_RETURN();
1009    return(rc);
1010 }
1011 /*man-start*********************************************************************
1012 COMMAND
1013      set boundmark - set bounds marker display
1014 
1015 SYNTAX
1016      [SET] BOUNDMARK OFF|Zone|TRunc|MARgins|TABs|Verify
1017 
1018 DESCRIPTION
1019      The BOUNDMARK command indicates if boundary markers are to be
1020      displayed and if so, where. Boundary markers are vertical lines
1021      drawn before or after certain columns within the <filearea>.
1022      This command only has a visible effect on GUI platforms, currently
1023      only the X11 port.
1024 
1025      'OFF' turns off the display of boundary markers.
1026 
1027      'ZONE' turns on the display of boundary markers, before the zone
1028      start column and after the zone end column.
1029 
1030      'TRUNC' turns on the display of boundary markers, after the
1031      truncation column. Not supported.
1032 
1033      'MARGINS' turns on the display of boundary markers, before the left
1034      margin and after the right margin.
1035 
1036      'TABS' turns on the display of boundary markers, before each tab
1037      column.
1038 
1039      'VERIFY' turns on the display of boundary markers, before each verify
1040      column. Not supported.
1041 
1042 COMPATIBILITY
1043      XEDIT: N/A
1044      KEDIT: Compatible, but no support for TRUNC or VERIFY option.
1045 
1046 DEFAULT
1047      Zone
1048 
1049 STATUS
1050      Incomplete
1051 **man-end**********************************************************************/
1052 #ifdef HAVE_PROTO
Boundmark(CHARTYPE * params)1053 short Boundmark(CHARTYPE *params)
1054 #else
1055 short Boundmark(params)
1056 CHARTYPE *params;
1057 #endif
1058 /***********************************************************************/
1059 {
1060 #define BND_PARAMS  2
1061    CHARTYPE save_boundmark=CURRENT_VIEW->boundmark;
1062    CHARTYPE *word[BND_PARAMS+1];
1063    CHARTYPE strip[BND_PARAMS];
1064    short num_params=0;
1065 
1066    TRACE_FUNCTION("commset1.c:Boundmark");
1067    strip[0]=STRIP_BOTH;
1068    strip[1]=STRIP_BOTH;
1069    num_params = param_split(params,word,BND_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
1070    if ( num_params == 0 )
1071    {
1072       display_error(3,(CHARTYPE *)"",FALSE);
1073       TRACE_RETURN();
1074       return(RC_INVALID_OPERAND);
1075    }
1076    if ( num_params > 1 )
1077    {
1078       display_error(2,(CHARTYPE *)"",FALSE);
1079       TRACE_RETURN();
1080       return(RC_INVALID_OPERAND);
1081    }
1082    /*
1083     * Validate the first and only parameter
1084     */
1085    if (equal((CHARTYPE *)"zone",word[0],1))
1086       CURRENT_VIEW->boundmark = BOUNDMARK_ZONE;
1087    else if (equal((CHARTYPE *)"trunc",word[0],2))
1088       CURRENT_VIEW->boundmark = BOUNDMARK_TRUNC;
1089    else if (equal((CHARTYPE *)"margins",word[0],2))
1090       CURRENT_VIEW->boundmark = BOUNDMARK_MARGINS;
1091    else if (equal((CHARTYPE *)"tabs",word[0],3))
1092       CURRENT_VIEW->boundmark = BOUNDMARK_TABS;
1093    else if (equal((CHARTYPE *)"verify",word[0],1))
1094       CURRENT_VIEW->boundmark = BOUNDMARK_VERIFY;
1095    else if (equal((CHARTYPE *)"off",word[0],3))
1096       CURRENT_VIEW->boundmark = BOUNDMARK_OFF;
1097    else
1098    {
1099       display_error(1,(CHARTYPE *)word[0],FALSE);
1100       TRACE_RETURN();
1101       return(RC_INVALID_OPERAND);
1102    }
1103    /*
1104     * If the value has changed, display the screen
1105     */
1106    if ( CURRENT_VIEW->boundmark != save_boundmark )
1107    {
1108       build_screen(current_screen);
1109       display_screen(current_screen);
1110    }
1111 
1112    TRACE_RETURN();
1113    return(RC_OK);
1114 }
1115 /*man-start*********************************************************************
1116 COMMAND
1117      set case - set case sensitivity parameters
1118 
1119 SYNTAX
1120      [SET] CASE Mixed|Lower|Upper [Respect|Ignore] [Respect|Ignore] [Respect|Ignore] [Mixed|Lower|Upper] [Mixed|Lower|Upper]
1121 
1122 DESCRIPTION
1123      The CASE command sets the editor's handling of the case of text.
1124 
1125      The first option (which is mandatory) controls how text is entered
1126      by the user in the <filearea>. When 'LOWER' or 'UPPER' are in effect,
1127      the shift or caps lock keys have no effect on the text being entered.
1128      When 'MIXED' is in effect, text is entered in the case set by the use
1129      of the shift and caps lock keys.
1130 
1131      The second option determines how the editor determines if a string
1132      target matches text in the file when the target is used in a <LOCATE>
1133      command.  With 'IGNORE' in effect, a match is
1134      found irrespective of the case of the target or the found text.
1135      The following strings are treated as equivalent: the THE The ThE...
1136      With 'RESPECT' in effect, the target and text must be the same case.
1137      Therefore a target of 'The' only matches text containing 'The', not
1138      'THE' or 'ThE' etc.
1139 
1140      The third option determines how the editor determines if a string
1141      target matches text in the file when the target is used in a <CHANGE>
1142      command.  With 'IGNORE' in effect, a match is
1143      found irrespective of the case of the target or the found text.
1144      The following strings are treated as equivalent: the THE The ThE...
1145      With 'RESPECT' in effect, the target and text must be the same case.
1146      Therefore a target of 'The' only matches text containing 'The', not
1147      'THE' or 'ThE' etc.
1148 
1149      The fourth option determines how the editor determines the sort
1150      order of upper and lower case with the <SORT> command.
1151      With 'IGNORE' in effect, upper and lower case letters are treated as
1152      equivalent.
1153      With 'RESPECT' in effect, upper and lower case letters are treated as
1154      different values and uppercase characters will sort before lowercase
1155      characters.
1156 
1157      The fifth option controls how text is entered by the user on the
1158      <command line>. The allowed values and behaviour are the same as for
1159      the first option.
1160 
1161      The sixth option controls how text is entered by the user in the
1162      <prefix area>. The allowed values and behaviour are the same as for
1163      the first option.
1164 
1165      All options can be specified as the current EQUIVCHAR to retain the
1166      existing value.
1167 
1168 COMPATIBILITY
1169      XEDIT: Adds support for case significance in CHANGE commands.
1170      KEDIT: Adds support for LOWER option.
1171      Both:  Adds support for case significance in SORT command.
1172 
1173 DEFAULT
1174      Mixed Ignore Respect Respect
1175 
1176 SEE ALSO
1177      <SET EQUIVCHAR>
1178 
1179 STATUS
1180      Complete
1181 **man-end**********************************************************************/
1182 #ifdef HAVE_PROTO
Case(CHARTYPE * params)1183 short Case(CHARTYPE *params)
1184 #else
1185 short Case(params)
1186 CHARTYPE *params;
1187 #endif
1188 /***********************************************************************/
1189 {
1190 #define CAS_PARAMS  6
1191    CHARTYPE parm[CAS_PARAMS];
1192    CHARTYPE *word[CAS_PARAMS+1];
1193    CHARTYPE strip[CAS_PARAMS];
1194    /*
1195     * Type 0 is Mixed|Upper|Lower
1196     * Type 1 is Respect|Ignore
1197     */
1198    char arg_types[CAS_PARAMS+1] = "011100";
1199    register short i=0;
1200    short num_params=0;
1201 
1202    TRACE_FUNCTION("commset1.c:Case");
1203    strip[0]=STRIP_BOTH;
1204    strip[1]=STRIP_BOTH;
1205    strip[2]=STRIP_BOTH;
1206    strip[3]=STRIP_BOTH;
1207    strip[4]=STRIP_BOTH;
1208    strip[5]=STRIP_BOTH;
1209    num_params = param_split(params,word,CAS_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
1210    if ( num_params < 1 )
1211    {
1212       display_error( 3, (CHARTYPE *)"", FALSE );
1213       TRACE_RETURN();
1214       return( RC_INVALID_OPERAND );
1215    }
1216    /*
1217     * Save the current values of each optional case setting.
1218     */
1219    parm[1] = CURRENT_VIEW->case_locate;
1220    parm[2] = CURRENT_VIEW->case_change;
1221    parm[3] = CURRENT_VIEW->case_sort;
1222    parm[4] = CURRENT_VIEW->case_enter_cmdline;
1223    parm[5] = CURRENT_VIEW->case_enter_prefix;
1224    /*
1225     * Validate all arguments.
1226     */
1227    for ( i = 0; i < num_params; i++ )
1228    {
1229       if ( strcmp( (DEFCHAR *)word[i], "" ) != 0 )
1230       {
1231          if ( arg_types[i] == '0' )
1232          {
1233             if ( equal( (CHARTYPE *)"mixed", word[i], 1 ) )
1234                parm[i] = CASE_MIXED;
1235             else if ( equal( (CHARTYPE *)"upper", word[i], 1 ) )
1236                parm[i] = CASE_UPPER;
1237             else if ( equal( (CHARTYPE *)"lower", word[i], 1 ) )
1238                parm[i] = CASE_LOWER;
1239             else if ( equal( (CHARTYPE *)EQUIVCHARstr, word[i], 1 ) )
1240                parm[i] = CURRENT_VIEW->case_enter;
1241             else
1242             {
1243                display_error( 1, (CHARTYPE *)word[i], FALSE );
1244                TRACE_RETURN();
1245                return( RC_INVALID_OPERAND );
1246             }
1247          }
1248          else
1249          {
1250             if ( equal( (CHARTYPE *)"respect", word[i], 1 ) )
1251                parm[i] = CASE_RESPECT;
1252             else  if (equal((CHARTYPE *)"ignore",word[i],1))
1253                parm[i] = CASE_IGNORE;
1254             else  if (equal((CHARTYPE *)EQUIVCHARstr,word[i],1))
1255                parm[i] = parm[i];
1256             else
1257             {
1258                display_error(1,(CHARTYPE *)word[i],FALSE);
1259                TRACE_RETURN();
1260                return(RC_INVALID_OPERAND);
1261             }
1262          }
1263       }
1264    }
1265    /*
1266     * Set the new values of case settings for the view.
1267     */
1268    CURRENT_VIEW->case_enter         = parm[0];
1269    CURRENT_VIEW->case_locate        = parm[1];
1270    CURRENT_VIEW->case_change        = parm[2];
1271    CURRENT_VIEW->case_sort          = parm[3];
1272    CURRENT_VIEW->case_enter_cmdline = parm[4];
1273    CURRENT_VIEW->case_enter_prefix  = parm[5];
1274 
1275    TRACE_RETURN();
1276    return(RC_OK);
1277 }
1278 /*man-start*********************************************************************
1279 COMMAND
1280      set clearerrorkey - specify which key clears the message line
1281 
1282 SYNTAX
1283      [SET] CLEARErrorkey *|keyname
1284 
1285 DESCRIPTION
1286      The SET CLEARERRORKEY command allows the user to specify which
1287      key clears the message line.  By default, any key pressed will
1288      cause the message line to be cleared.  The keyname specified
1289      is the name returned via the <SHOWKEY> command.
1290 
1291      As the <QUERY> command also uses the same mechanism for displaying
1292      its results as errors, then this command affects when results from
1293      the <QUERY> command are cleared.
1294 
1295 COMPATIBILITY
1296      XEDIT: N/A
1297      KEDIT: N/A
1298 
1299 DEFAULT
1300      *
1301 
1302 STATUS
1303      Complete
1304 **man-end**********************************************************************/
1305 #ifdef HAVE_PROTO
Clearerrorkey(CHARTYPE * params)1306 short Clearerrorkey(CHARTYPE *params)
1307 #else
1308 short Clearerrorkey(params)
1309 CHARTYPE *params;
1310 #endif
1311 /***********************************************************************/
1312 {
1313    short rc=RC_OK;
1314    int key = 0;
1315 
1316    TRACE_FUNCTION("commset1.c:Clearerrorkey");
1317    if (strcmp((DEFCHAR*)params,"*") == 0)
1318    {
1319       CLEARERRORKEYx = -1;
1320    }
1321    else
1322    {
1323       key = find_key_value(params);
1324       if (key == -1)
1325       {
1326          display_error(13,params,FALSE);
1327          TRACE_RETURN();
1328          return(RC_INVALID_OPERAND);
1329       }
1330       CLEARERRORKEYx = key;
1331    }
1332    TRACE_RETURN();
1333    return(rc);
1334 }
1335 /*man-start*********************************************************************
1336 COMMAND
1337      set clearscreen - indicate if the screen is to be cleared on exit
1338 
1339 SYNTAX
1340      [SET] CLEARScreen ON|OFF
1341 
1342 DESCRIPTION
1343      The SET CLEARSCREEN command allows the user to request that the
1344      screen be cleared on exit from THE.
1345 
1346 COMPATIBILITY
1347      XEDIT: N/A
1348      KEDIT: N/A
1349 
1350 DEFAULT
1351      OFF
1352 
1353 STATUS
1354      Complete
1355 **man-end**********************************************************************/
1356 #ifdef HAVE_PROTO
Clearscreen(CHARTYPE * params)1357 short Clearscreen(CHARTYPE *params)
1358 #else
1359 short Clearscreen(params)
1360 CHARTYPE *params;
1361 #endif
1362 /***********************************************************************/
1363 {
1364    short rc=RC_OK;
1365 
1366    TRACE_FUNCTION("commset1.c:Clearscreen");
1367    rc = execute_set_on_off(params,&CLEARSCREENx, TRUE );
1368    TRACE_RETURN();
1369    return(rc);
1370 }
1371 /*man-start*********************************************************************
1372 COMMAND
1373      set clock - turn on or off display of time on status line
1374 
1375 SYNTAX
1376      [SET] CLOCK ON|OFF
1377 
1378 DESCRIPTION
1379      The SET CLOCK command turns on or off the display of the time on the
1380      <status line>.
1381 
1382 COMPATIBILITY
1383      XEDIT: N/A
1384      KEDIT: Compatible.
1385 
1386 DEFAULT
1387      ON
1388 
1389 STATUS
1390      Complete
1391 **man-end**********************************************************************/
1392 #ifdef HAVE_PROTO
Clock(CHARTYPE * params)1393 short Clock(CHARTYPE *params)
1394 #else
1395 short Clock(params)
1396 CHARTYPE *params;
1397 #endif
1398 /***********************************************************************/
1399 {
1400    short rc=RC_OK;
1401 
1402    TRACE_FUNCTION("commset1.c:Clock");
1403    rc = execute_set_on_off(params,&CLOCKx, TRUE );
1404    if (rc == RC_OK
1405    &&  curses_started)
1406       clear_statarea();
1407    TRACE_RETURN();
1408    return(rc);
1409 }
1410 /*man-start*********************************************************************
1411 COMMAND
1412      set cmdarrows - sets the behaviour of the up and down arrow keys
1413 
1414 SYNTAX
1415      [SET] CMDArrows Retrieve|Tab
1416 
1417 DESCRIPTION
1418      The SET CMDARROWS command determines the action that occurs when the
1419      up and down arrows keys are hit while on the <command line>.
1420 
1421      'RETRIEVE' will set the up and down arrows to retrieve the last or
1422      next command entered on the <command line>.
1423 
1424      'TAB' will set the up and down arrows to move to the last
1425      or first line respectively of the main window.
1426 
1427 COMPATIBILITY
1428      XEDIT: N/A
1429      KEDIT: N/A
1430 
1431 DEFAULT
1432      RETRIEVE
1433 
1434 SEE ALSO
1435      <CURSOR>, <?>
1436 
1437 STATUS
1438      Complete.
1439 **man-end**********************************************************************/
1440 #ifdef HAVE_PROTO
Cmdarrows(CHARTYPE * params)1441 short Cmdarrows(CHARTYPE *params)
1442 #else
1443 short Cmdarrows(params)
1444 CHARTYPE *params;
1445 #endif
1446 /***********************************************************************/
1447 {
1448    short rc=RC_OK;
1449 
1450    TRACE_FUNCTION("commset1.c:Cmdarrows");
1451    /*
1452     * Determine values for first parameter
1453     */
1454    params = MyStrip( params, STRIP_BOTH, ' ' );
1455    if ( equal( (CHARTYPE *)"tab", params, 1 ) )
1456       CMDARROWSTABCMDx = TRUE;
1457    else if (equal( (CHARTYPE *)"retrieve", params, 1 ) )
1458       CMDARROWSTABCMDx = FALSE;
1459    else
1460    {
1461       display_error( 1, params, FALSE );
1462       rc = RC_INVALID_OPERAND;
1463    }
1464    TRACE_RETURN();
1465    return(rc);
1466 }
1467 /*man-start*********************************************************************
1468 COMMAND
1469      set cmdline - sets the position of the command line.
1470 
1471 SYNTAX
1472      [SET] CMDline ON|OFF|Top|Bottom
1473 
1474 DESCRIPTION
1475      The SET CMDLINE command sets the position of the <command line>,
1476      either at the top of the screen, the bottom of the screen or off.
1477 
1478 COMPATIBILITY
1479      XEDIT: Compatible.
1480             CMDLINE ON is equivalent to CMDLINE Bottom
1481      KEDIT: Compatible.
1482 
1483 DEFAULT
1484      BOTTOM
1485 
1486 STATUS
1487      Complete.
1488 **man-end**********************************************************************/
1489 #ifdef HAVE_PROTO
Cmdline(CHARTYPE * params)1490 short Cmdline(CHARTYPE *params)
1491 #else
1492 short Cmdline(params)
1493 CHARTYPE *params;
1494 #endif
1495 /***********************************************************************/
1496 {
1497    CHARTYPE cmd_place = '?';
1498    short rc = RC_OK;
1499 
1500    TRACE_FUNCTION( "commset1.c:Cmdline" );
1501 
1502    params = MyStrip( params, STRIP_BOTH, ' ' );
1503    if ( equal( (CHARTYPE *)"top", params, 1 ) )
1504    {
1505       cmd_place = 'T';
1506    }
1507    else if ( equal( (CHARTYPE *)"bottom",params, 1 )
1508         ||   equal( (CHARTYPE *)"on", params, 2 ) )
1509    {
1510       cmd_place = 'B';
1511    }
1512    else if ( equal( (CHARTYPE *)"off", params, 3 ) )
1513    {
1514       cmd_place = 'O';
1515    }
1516    else
1517    {
1518       display_error( 1, (CHARTYPE *)params, FALSE );
1519       TRACE_RETURN();
1520       return(RC_INVALID_OPERAND);
1521    }
1522    /*
1523     * If the setting supplied is the same as the current setting, just
1524     * return without doing anything.
1525     */
1526    if ( cmd_place == CURRENT_VIEW->cmd_line )
1527    {
1528       TRACE_RETURN();
1529       return(RC_OK);
1530    }
1531    /*
1532     * Now we need to move the windows around.
1533     */
1534    CURRENT_VIEW->cmd_line = cmd_place;
1535    /*
1536     * Rebuild the windows and display...
1537     */
1538    set_screen_defaults();
1539    if ( curses_started )
1540    {
1541       if ( set_up_windows( current_screen ) != RC_OK )
1542       {
1543          TRACE_RETURN();
1544          return(rc);
1545       }
1546    }
1547    if (CURRENT_VIEW->cmd_line == 'O')
1548       CURRENT_VIEW->current_window = WINDOW_FILEAREA;
1549    build_screen( current_screen );
1550    if ( curses_started )
1551       display_screen( current_screen );
1552 
1553    TRACE_RETURN();
1554    return(rc);
1555 }
1556 /*man-start*********************************************************************
1557 COMMAND
1558      set color - set colors for display
1559 
1560 SYNTAX
1561      [SET] COLOR  area [modifier[...]] [foreground] [ON] [background]
1562      [SET] COLOR  area [modifier[...]] ON|OFF
1563      [SET] COLOUR color red blue green
1564 
1565 DESCRIPTION
1566      The SET COLOR command changes the colors or display attributes of
1567      various display areas in THE.
1568 
1569      Valid values for 'area':
1570 
1571           ALERT           - alert boxes; see <ALERT>
1572           Arrow           - command line prompt
1573           Block           - marked <block>
1574           BOUNDmarker     - bound markers (GUI platforms only)
1575           CBlock          - <current line> if in marked <block>
1576           CHIghlight      - highlighted line if the same as <current line>
1577           Cmdline         - <command line>
1578           CTofeof         - as for TOfeof if the same as <current line>
1579           CUrline         - the <current line>
1580           CURSORline      - the line in <filearea> that the cursor is or was on
1581           Divider         - dividing line between vertical split screens
1582           Filearea        - area containing file lines
1583           GAP             - the gap between the <prefix area> and <filearea>
1584           CGAP            - the gap between the <prefix area> and <filearea> - current
1585           HIghlight       - highlighted line
1586           Idline          - line containing file specific info
1587           Msgline         - error messages
1588           Nondisp         - Non-display characters (<SET ETMODE> OFF)
1589           Pending         - pending commands in <prefix area>
1590           PRefix          - <prefix area>
1591           CPRefix         - <prefix area> if the same as <current line>
1592           Reserved        - default for <reserved line>
1593           Scale           - line showing <scale line>
1594           SHadow          - hidden line marker lines
1595           SLK             - soft label keys
1596           STatarea        - line showing status of editing session
1597           Tabline         - line showing tab positions
1598           TOfeof          - <Top-of-File line> and <Bottom-of-File line>
1599           DIALOG          - background of a dialog box; see <DIALOG>
1600           DIALOGBORDER    - border for a dialog box
1601           DIALOGEDITFIELD - edit field of a dialog box
1602           DIALOGBUTTON    - inactive button in a dialog box
1603           DIALOGABUTTON   - active button in a dialog box
1604           POPUP           - all non-highlighted lines in a popup; see <POPUP>
1605           POPUPBORDER     - border for a popup
1606           POPUPCURLINE    - the highlighted line in a popup
1607           POPUPDIVIDER    - dividing line in a popup
1608           *               - All areas (second format only)
1609 
1610      Valid values for 'foreground', 'background' and 'color':
1611 
1612           BLAck
1613           BLUe
1614           Brown
1615           Green
1616           GRAy
1617           GREy
1618           Cyan
1619           RED
1620           Magenta
1621           Pink
1622           Turquoise
1623           Yellow
1624           White
1625 
1626      Valid values for 'modifier':
1627 
1628           NORmal
1629           BLInk
1630           BOld
1631           BRIght
1632           High
1633           REVerse
1634           Underline
1635           DARK
1636           Italic - only available on X11 port with valid Italic font and on
1637                    Windows with "GUI" PDcurses
1638 
1639      The second format of this command allows the user to turn on or off
1640      any of the valid modifiers.
1641 
1642      The third format of this command allows the user to change the intensity
1643      of specified colors on platforms that support changing the content of a
1644      color (X11, Windows GUI).  The specified color can be changed by supplying
1645      the intensity of red, green and blue. These are numeric values between 0
1646      and 1000 inclusive.  eg To change 'red' to 'blue': SET COLOR RED 0 0 1000.
1647      All characters being displayed as 'red' will be displayed with the specified
1648      intensities. Note that this behaviour is not consistent across platforms, and
1649      should be considered experimental at this stage.
1650 
1651      It is an error to attempt to set a colour on a mono display.
1652 
1653 COMPATIBILITY
1654      XEDIT: Functionally compatible. See below.
1655      KEDIT: Functionally compatible. See below.
1656      Does not implement all modifiers.
1657 
1658 DEFAULT
1659      Depends on compatibility mode setting and monitor type.
1660 
1661 SEE ALSO
1662      <SET COMPAT>, <SET COLOUR>, <SET ECOLOUR>, <DIALOG>, <POPUP>
1663 
1664 STATUS
1665      Complete.
1666 **man-end**********************************************************************/
1667 /*man-start*********************************************************************
1668 COMMAND
1669      set colour - set colours for display
1670 
1671 SYNTAX
1672      [SET] COLOUR area [modifier[...]] [foreground] [on background]
1673      [SET] COLOUR area [modifier[...]] ON|OFF
1674      [SET] COLOUR colour red blue green
1675 
1676 DESCRIPTION
1677      The SET COLOUR command is a synonym for the <SET COLOR> command.
1678 
1679 COMPATIBILITY
1680      XEDIT: Functionally compatible. See below.
1681      KEDIT: Functionally compatible. See below.
1682      Does not implement all modifiers.
1683 
1684 DEFAULT
1685      Depends on compatibility mode setting and monitor type.
1686 
1687 SEE ALSO
1688      <SET COLOR>
1689 
1690 STATUS
1691      Complete.
1692 **man-end**********************************************************************/
1693 #ifdef HAVE_PROTO
Colour(CHARTYPE * params)1694 short Colour(CHARTYPE *params)
1695 #else
1696 short Colour(params)
1697 CHARTYPE *params;
1698 #endif
1699 /***********************************************************************/
1700 {
1701 #define COL_PARAMS_DEF 2
1702 #define COL_PARAMS_COLOUR 4
1703 #define COL_MODIFIER_NO_SET  0
1704 #define COL_MODIFIER_SET_ON  1
1705 #define COL_MODIFIER_SET_OFF 2
1706    CHARTYPE *word[COL_PARAMS_COLOUR+1];
1707    CHARTYPE strip[COL_PARAMS_COLOUR];
1708    CHARTYPE parm[COL_PARAMS_COLOUR];
1709    register short i=0;
1710    unsigned short num_params=0;
1711    short area=-1;
1712    COLOUR_ATTR attr,tmp_attr;
1713    CHARTYPE *dummy=NULL;
1714    bool any_colours=FALSE;
1715    short word1_len,modifier_set=COL_MODIFIER_NO_SET;
1716    bool window_set[MAX_THE_WINDOWS];
1717    int clr;
1718    int cont[3];
1719 
1720    TRACE_FUNCTION("commset1.c:Colour");
1721    strip[0]=STRIP_BOTH;
1722    strip[1]=STRIP_BOTH;
1723    strip[2]=STRIP_BOTH;
1724    strip[3]=STRIP_BOTH;
1725    num_params = param_split(params,word,COL_PARAMS_DEF,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
1726    if (num_params < 2 )
1727    {
1728       display_error(3,(CHARTYPE *)"",FALSE);
1729       TRACE_RETURN();
1730       return(RC_INVALID_OPERAND);
1731    }
1732    /*
1733     * Check which format of this command we are running.
1734     * If the last word is ON or OFF then we are executing the
1735     * second format.
1736     * If the first word is a colour, it is format three.
1737     */
1738    word1_len = strlen( (DEFCHAR *)word[1] );
1739    clr = is_valid_colour( word[0] );
1740    if ( clr == (-1) )
1741    {
1742       if ( my_stricmp( (DEFCHAR *)word[1]+word1_len-3, " ON" ) == 0 )
1743          modifier_set = COL_MODIFIER_SET_ON;
1744       else if ( my_stricmp( (DEFCHAR *)word[1]+word1_len-4, " OFF" ) == 0 )
1745          modifier_set = COL_MODIFIER_SET_OFF;
1746       if ( modifier_set )
1747       {
1748          /*
1749           * Check that first parameter is an area or '*'
1750           */
1751          parm[0] = FALSE;
1752          if ( strcmp( (DEFCHAR *)word[0], "*" ) == 0 )
1753          {
1754             area = -1;
1755             parm[0] = TRUE;
1756          }
1757          else
1758          {
1759             for ( i = 0; i < ATTR_MAX; i++ )
1760             {
1761                if ( equal( valid_areas[i].area,word[0], valid_areas[i].area_min_len ) )
1762                {
1763                   parm[0] = TRUE;
1764                   area = i;
1765                   break;
1766                }
1767             }
1768          }
1769          if (parm[0] == FALSE)
1770          {
1771             display_error(1,(CHARTYPE *)word[0],FALSE);
1772             TRACE_RETURN();
1773             return(RC_INVALID_OPERAND);
1774          }
1775          /*
1776           * Check that each subsequent parameter (except the last) is
1777           * a modifier.
1778           */
1779          if ( parse_modifiers( word[1], &tmp_attr ) != RC_OK )
1780          {
1781             TRACE_RETURN();
1782             return(RC_INVALID_OPERAND);
1783          }
1784          /*
1785           * For each area, turn off the modifiers and redraw the affected part of
1786           * the screen
1787           */
1788          if ( area == (-1) )
1789          {
1790             for ( i = 0; i < MAX_THE_WINDOWS; i++ )
1791             {
1792                window_set[i] = FALSE;
1793             }
1794             for ( i = 0; i < ATTR_MAX; i++ )
1795             {
1796                attr = CURRENT_FILE->attr[i];
1797                if ( modifier_set == COL_MODIFIER_SET_ON )
1798                {
1799                   if ( colour_support )
1800                      attr.mod |= tmp_attr.mod;
1801                   else
1802                      attr.mono |= tmp_attr.mono;
1803                }
1804                else
1805                {
1806                   if ( colour_support )
1807                      attr.mod &= ~tmp_attr.mod;
1808                   else
1809                      attr.mono &= ~tmp_attr.mono;
1810                }
1811                CURRENT_FILE->attr[i] = attr;
1812                if ( i == ATTR_BOUNDMARK
1813                ||   i == ATTR_NONDISP
1814                ||   window_set[valid_areas[i].area_window] == FALSE )
1815                {
1816                   set_active_colour( i );
1817                   window_set[valid_areas[i].area_window] = TRUE;
1818                }
1819             }
1820          }
1821          else
1822          {
1823             attr = CURRENT_FILE->attr[area];
1824             if ( modifier_set == COL_MODIFIER_SET_ON )
1825             {
1826                if ( colour_support )
1827                   attr.mod |= tmp_attr.mod;
1828                else
1829                   attr.mono |= tmp_attr.mono;
1830             }
1831             else
1832             {
1833                if ( colour_support )
1834                   attr.mod &= ~tmp_attr.mod;
1835                else
1836                   attr.mono &= ~tmp_attr.mono;
1837             }
1838             CURRENT_FILE->attr[area] =attr;
1839             set_active_colour( area );
1840          }
1841       }
1842       else
1843       {
1844          /*
1845           * Check that the supplied area matches one of the values in the area
1846           * array and that the length is at least as long as the minimum.
1847           */
1848          parm[0] = FALSE;
1849          for (i=0;i<ATTR_MAX;i++)
1850          {
1851             if (equal(valid_areas[i].area,word[0],valid_areas[i].area_min_len))
1852             {
1853                parm[0] = TRUE;
1854                area = i;
1855                break;
1856             }
1857          }
1858          if (parm[0] == FALSE)
1859          {
1860             display_error(1,(CHARTYPE *)word[0],FALSE);
1861             TRACE_RETURN();
1862             return(RC_INVALID_OPERAND);
1863          }
1864          attr = CURRENT_FILE->attr[area];
1865          /*
1866           * Determine colours and modifiers.
1867           */
1868          if (parse_colours(word[1],&attr,&dummy,FALSE,&any_colours) != RC_OK)
1869          {
1870             TRACE_RETURN();
1871             return(RC_INVALID_OPERAND);
1872          }
1873          /*
1874           * Now we have the new colours, save them with the current file...
1875           */
1876          CURRENT_FILE->attr[area] = attr;
1877          set_active_colour( area );
1878       }
1879    }
1880    else
1881    {
1882       /* can the terminal support changing colour? */
1883       if ( !can_change_color() )
1884       {
1885          display_error( 61, (CHARTYPE *)"Changing colors unsupported.", FALSE );
1886          TRACE_RETURN();
1887          return(RC_INVALID_ENVIRON);
1888       }
1889       /* SET COLOUR colour red green blue */
1890       num_params = param_split( params, word, COL_PARAMS_COLOUR, WORD_DELIMS, TEMP_PARAM, strip, FALSE );
1891       if ( num_params != 4 )
1892       {
1893          display_error(3,(CHARTYPE *)"",FALSE);
1894          TRACE_RETURN();
1895          return(RC_INVALID_OPERAND);
1896       }
1897       /*
1898        * Validate the colour contents
1899        */
1900       for ( i = 1; i < 4; i++ )
1901       {
1902          if ( !valid_positive_integer( word[i] ) )
1903          {
1904             display_error(4, (CHARTYPE *)word[i], FALSE );
1905             TRACE_RETURN();
1906             return(RC_INVALID_OPERAND);
1907          }
1908          cont[i-1] = atoi( (DEFCHAR *)word[i] );
1909          if ( cont[i-1]  < 0 )
1910          {
1911             display_error(5, (CHARTYPE *)word[i], FALSE );
1912             TRACE_RETURN();
1913             return(RC_INVALID_OPERAND);
1914          }
1915          if ( cont[i-1]  > 1000 )
1916          {
1917             display_error(6, (CHARTYPE *)word[i], FALSE );
1918             TRACE_RETURN();
1919             return(RC_INVALID_OPERAND);
1920          }
1921       }
1922       init_color( clr, cont[0], cont[1], cont[2] );
1923    }
1924    TRACE_RETURN();
1925    return(RC_OK);
1926 }
1927 
1928 /*man-start*********************************************************************
1929 COMMAND
1930      set coloring - enable or disable syntax highlighting
1931 
1932 SYNTAX
1933      [SET] COLORING ON|OFF [AUTO|parser]
1934 
1935 DESCRIPTION
1936      The SET COLORING command allows the user to turn on or off syntax
1937      highlighting for current file.  It also allows the <parser> used to be
1938      specified explicitly, or automatically determined by the file
1939      extension or <magic number>.
1940 
1941      ON turns on syntax highlighting for the current file, OFF turns it
1942      off.
1943 
1944      AUTO determines the <parser> to use for the current file based on the
1945      file extension.  The <parser> to use is controlled by the <SET AUTOCOLOR>
1946      command.
1947 
1948 COMPATIBILITY
1949      XEDIT: N/A
1950      KEDIT: Compatible.
1951 
1952 DEFAULT
1953      ON AUTO
1954 
1955 SEE ALSO
1956      <SET COLOURING>, <SET ECOLOUR>, <SET AUTOCOLOR>, <SET PARSER>
1957 
1958 STATUS
1959      Complete.
1960 **man-end**********************************************************************/
1961 /*man-start*********************************************************************
1962 COMMAND
1963      set colouring - enable or disable syntax highlighting
1964 
1965 SYNTAX
1966      [SET] COLOURING ON|OFF [AUTO|parser]
1967 
1968 DESCRIPTION
1969      The SET COLOURING command is a synonym for the <SET COLORING> command.
1970 
1971 COMPATIBILITY
1972      XEDIT: N/A
1973      KEDIT: Compatible.
1974 
1975 DEFAULT
1976      ON AUTO
1977 
1978 SEE ALSO
1979      <SET COLORING>
1980 
1981 STATUS
1982      Complete.
1983 **man-end**********************************************************************/
1984 #ifdef HAVE_PROTO
Colouring(CHARTYPE * params)1985 short Colouring(CHARTYPE *params)
1986 #else
1987 short Colouring(params)
1988 CHARTYPE *params;
1989 #endif
1990 
1991 /***********************************************************************/
1992 {
1993 #define COLG_PARAMS  2
1994    CHARTYPE *word[COLG_PARAMS+1];
1995    CHARTYPE strip[COLG_PARAMS];
1996    short num_params=0;
1997    short rc=RC_OK;
1998    bool new_colouring=FALSE;
1999    PARSER_DETAILS *new_parser=NULL;
2000 
2001    TRACE_FUNCTION("commset1.c:Colouring");
2002    strip[0]=STRIP_BOTH;
2003    strip[1]=STRIP_BOTH;
2004    num_params = param_split(params,word,COLG_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
2005    if (num_params < 1)
2006    {
2007       display_error(3,(CHARTYPE *)"",FALSE);
2008       TRACE_RETURN();
2009       return(RC_INVALID_OPERAND);
2010    }
2011    /*
2012     * Parse the status parameter...
2013     */
2014    rc = execute_set_on_off(word[0],&new_colouring, TRUE );
2015    if (rc != RC_OK)
2016    {
2017       TRACE_RETURN();
2018       return(rc);
2019    }
2020    if (num_params == 1
2021    &&  new_colouring == TRUE)
2022    {
2023       display_error(3,(CHARTYPE *)"",FALSE);
2024       TRACE_RETURN();
2025       return(RC_INVALID_OPERAND);
2026    }
2027 
2028    if (new_colouring)
2029    {
2030       /*
2031        * This is only applicable when turning colouring ON
2032        */
2033       if (equal((CHARTYPE *)"AUTO",word[1],4))
2034       {
2035          /*
2036           * Set the parser to the parser for the file extension or
2037           * to NULL if no parser is set up for this extension.
2038           */
2039          new_parser = find_auto_parser(CURRENT_FILE);
2040          CURRENT_FILE->autocolour = TRUE;
2041       }
2042       else
2043       {
2044          /*
2045           * Look for a parser with the specified name
2046           */
2047          new_parser = parserll_find(first_parser,word[1]);
2048          if (new_parser == NULL) /* no parser by that name... */
2049          {
2050             display_error(199,word[1],FALSE);
2051             TRACE_RETURN();
2052             return RC_INVALID_OPERAND;
2053          }
2054          CURRENT_FILE->autocolour = FALSE;
2055       }
2056    }
2057    CURRENT_FILE->parser = new_parser;
2058    CURRENT_FILE->colouring = new_colouring;
2059    /*
2060     * If all is OK, redisplay the screen to get the new colouring
2061     */
2062    if (display_screens > 1
2063    &&  SCREEN_FILE(current_screen) == SCREEN_FILE( (CHARTYPE)(other_screen) ))
2064    {
2065       display_screen( (CHARTYPE)(other_screen) );
2066    }
2067    display_screen(current_screen);
2068    TRACE_RETURN();
2069    return(RC_OK);
2070 }
2071 
2072 /*man-start*********************************************************************
2073 COMMAND
2074      set compat - set compatibility mode
2075 
2076 SYNTAX
2077      [SET] COMPat The|Xedit|Kedit|KEDITW|Ispf|= [The|Xedit|Kedit|KEDITW|Ispf|=] [The|Xedit|Kedit|KEDITW|Ispf|=]
2078 
2079 DESCRIPTION
2080      The SET COMPAT command changes some settings of THE to make it
2081      more compatible with the look and/or feel of XEDIT, KEDIT,
2082      KEDIT for Windows, or ISPF.
2083 
2084      This command is most useful as the first <SET> command in a
2085      profile file. It will change the default settings of THE to
2086      initially look and behave like the chosen editor. You can then
2087      make any additional changes in THE by issuing other <SET> commands.
2088 
2089      It is recommended that this command NOT be executed from the
2090      command line, particularly if you have 2 files being displayed
2091      at the same time.  Although the command works, things may look
2092      and behave strangely :-)
2093 
2094      The first parameter affects the look of THE, the second parameter
2095      affects the feel of THE, and the third parameter determines
2096      which default function key settings you require.
2097 
2098      Any of the parameters can be specified as =, which will not
2099      change that aspect of THE's compatibility.
2100 
2101 COMPATIBILITY
2102      XEDIT: N/A
2103      KEDIT: N/A
2104 
2105 DEFAULT
2106      THE THE THE
2107 
2108 STATUS
2109      Complete.
2110 **man-end**********************************************************************/
2111 #ifdef HAVE_PROTO
Compat(CHARTYPE * params)2112 short Compat(CHARTYPE *params)
2113 #else
2114 short Compat(params)
2115 CHARTYPE *params;
2116 #endif
2117 /***********************************************************************/
2118 {
2119 #define COM_PARAMS  4
2120    CHARTYPE *word[COM_PARAMS+1];
2121    CHARTYPE strip[COM_PARAMS];
2122    short num_params=0;
2123    int rc=RC_OK;
2124    int prey=0,prex=0;
2125    short save_look=compatible_look;
2126    short save_feel=compatible_feel;
2127    short save_keys=compatible_keys;
2128    short new_look=0;
2129    short new_feel=0;
2130    short new_keys=0;
2131    unsigned short save_autosave_alt=0;
2132    unsigned short save_save_alt=0;
2133 
2134    TRACE_FUNCTION("commset1.c:Compat");
2135    /*
2136     * Parse the parameters...
2137     */
2138    strip[0]=STRIP_BOTH;
2139    strip[1]=STRIP_BOTH;
2140    strip[2]=STRIP_BOTH;
2141    strip[3]=STRIP_NONE;
2142    num_params = param_split(params,word,COM_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
2143    if (num_params < 1)
2144    {
2145       display_error(3,(CHARTYPE *)"",FALSE);
2146       TRACE_RETURN();
2147       return(RC_INVALID_OPERAND);
2148    }
2149    if (num_params > 3)
2150    {
2151       display_error(2,(CHARTYPE *)"",FALSE);
2152       TRACE_RETURN();
2153       return(RC_INVALID_OPERAND);
2154    }
2155    if (equal((CHARTYPE *)"the",word[0],1))
2156       new_look = COMPAT_THE;
2157    else  if (equal((CHARTYPE *)"xedit",word[0],1))
2158       new_look = COMPAT_XEDIT;
2159    else if (equal((CHARTYPE *)"kedit",word[0],1))
2160       new_look = COMPAT_KEDIT;
2161    else if (equal((CHARTYPE *)"keditw",word[0],6))
2162       new_look = COMPAT_KEDITW;
2163    else if (equal((CHARTYPE *)"ispf",word[0],1))
2164       new_look = COMPAT_ISPF;
2165    else if (equal((CHARTYPE *)EQUIVCHARstr,word[0],1))
2166       new_look = save_look;
2167    else
2168    {
2169       display_error(1,word[0],FALSE);
2170       TRACE_RETURN();
2171       return(RC_INVALID_OPERAND);
2172    }
2173    if (num_params == 1)
2174    {
2175       new_feel = save_feel;
2176       new_keys = save_keys;
2177    }
2178    else
2179    {
2180       if (equal((CHARTYPE *)"the",word[1],1))
2181          new_feel = COMPAT_THE;
2182       else if (equal((CHARTYPE *)"xedit",word[1],1))
2183          new_feel = COMPAT_XEDIT;
2184       else if (equal((CHARTYPE *)"kedit",word[1],1))
2185          new_feel = COMPAT_KEDIT;
2186       else if (equal((CHARTYPE *)"keditw",word[1],6))
2187          new_feel = COMPAT_KEDITW;
2188       else if (equal((CHARTYPE *)"ispf",word[1],1))
2189          new_feel = COMPAT_ISPF;
2190       else if (equal((CHARTYPE *)EQUIVCHARstr,word[1],1))
2191          new_feel = save_feel;
2192       else
2193       {
2194          display_error(1,word[1],FALSE);
2195          TRACE_RETURN();
2196          return(RC_INVALID_OPERAND);
2197       }
2198       if (num_params == 2)
2199          new_keys = save_keys;
2200       else
2201       {
2202          if (equal((CHARTYPE *)"the",word[2],1))
2203             new_keys = COMPAT_THE;
2204          else if (equal((CHARTYPE *)"xedit",word[2],1))
2205             new_keys = COMPAT_XEDIT;
2206          else if (equal((CHARTYPE *)"kedit",word[2],1))
2207             new_keys = COMPAT_KEDIT;
2208          else if (equal((CHARTYPE *)"keditw",word[2],6))
2209             new_keys = COMPAT_KEDITW;
2210          else if (equal((CHARTYPE *)"ispf",word[2],1))
2211             new_keys = COMPAT_ISPF;
2212          else if (equal((CHARTYPE *)EQUIVCHARstr,word[2],1))
2213             new_keys = save_keys;
2214          else
2215          {
2216             display_error(1,word[2],FALSE);
2217             TRACE_RETURN();
2218             return(RC_INVALID_OPERAND);
2219          }
2220       }
2221    }
2222    compatible_look = new_look;
2223    compatible_feel = new_feel;
2224    compatible_keys = new_keys;
2225    /*
2226     * If the FEEL has changed, change the default feel...
2227     */
2228    set_global_feel_defaults();
2229    /*
2230     * If the KEYS has changed, change the default key definitions...
2231     */
2232    if (save_keys != compatible_keys)
2233    {
2234       switch(compatible_keys)
2235       {
2236          case COMPAT_THE:
2237             rc = set_THE_key_defaults(prey,prex);
2238             break;
2239          case COMPAT_XEDIT:
2240             rc = set_XEDIT_key_defaults(prey,prex);
2241             break;
2242          case COMPAT_ISPF:
2243             rc = set_ISPF_key_defaults(prey,prex);
2244             break;
2245          case COMPAT_KEDIT:
2246          case COMPAT_KEDITW:
2247             rc = set_KEDIT_key_defaults(prey,prex);
2248             break;
2249       }
2250       if (rc != RC_OK)
2251       {
2252          TRACE_RETURN();
2253          return(rc);
2254       }
2255    }
2256    /*
2257     * Now we have to change the LOOK of the current view...
2258     */
2259    if (curses_started)
2260    {
2261       if (CURRENT_WINDOW_PREFIX != NULL)
2262          getyx(CURRENT_WINDOW_PREFIX,prey,prex);
2263    }
2264    post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
2265    /*
2266     * Reset common settings to defaults for THE...
2267     */
2268    set_global_look_defaults();
2269 
2270 #ifdef FOR_ALL_VIEWS
2271    /*
2272     * Change the settings for all views.
2273     */
2274    viewp = vd_first;
2275    while(viewp != NULL)
2276    {
2277       set_file_defaults(viewp->file_for_view);
2278       set_view_defaults(viewp);
2279       viewp = viewp->next;
2280    }
2281 #else
2282    save_autosave_alt = CURRENT_FILE->autosave_alt;
2283    save_save_alt = CURRENT_FILE->save_alt;
2284    set_file_defaults(CURRENT_FILE);
2285    CURRENT_FILE->autosave_alt = save_autosave_alt;
2286    CURRENT_FILE->save_alt = save_save_alt;
2287    set_view_defaults(CURRENT_VIEW);
2288 #endif
2289    /*
2290     * Determine the size of each window in each screen in case any changes
2291     * in defaults caused some settings to include/exclude some windows...
2292     */
2293    set_screen_defaults();
2294    /*
2295     * For the common windows, set their attributes to match the new values
2296     */
2297    if (curses_started
2298    &&  statarea != NULL)
2299    {
2300       wattrset(statarea,set_colour(CURRENT_FILE->attr+ATTR_STATAREA));
2301       clear_statarea();
2302    }
2303    /*
2304     * If more than one screen displayed, redisplay the 'other' screen...
2305     */
2306    if (display_screens > 1)
2307    {
2308       OTHER_SCREEN.screen_view->current_row = calculate_actual_row(OTHER_SCREEN.screen_view->current_base,
2309                                                   OTHER_SCREEN.screen_view->current_off,
2310                                                   OTHER_SCREEN.rows[WINDOW_FILEAREA],TRUE);
2311       pre_process_line(OTHER_SCREEN.screen_view,OTHER_SCREEN.screen_view->focus_line,(LINE *)NULL);
2312       if (OTHER_SCREEN.screen_view->cmd_line == 'O')
2313          OTHER_SCREEN.screen_view->current_window = WINDOW_FILEAREA;
2314       if (curses_started)
2315       {
2316          if (set_up_windows(current_screen) != RC_OK)
2317          {
2318             TRACE_RETURN();
2319             return(rc);
2320          }
2321          if (!horizontal)
2322          {
2323             wattrset(divider,set_colour(OTHER_SCREEN.screen_view->file_for_view->attr+ATTR_DIVIDER));
2324             touchwin(divider);
2325             wnoutrefresh(divider);
2326          }
2327       }
2328       redraw_screen( (CHARTYPE)((current_screen == 0)?1:0) );
2329       build_screen( (CHARTYPE)(other_screen) );
2330       display_screen( (CHARTYPE)(other_screen) );
2331    }
2332    /*
2333     * Redisplay the current screen...
2334     */
2335    CURRENT_VIEW->current_row = calculate_actual_row(CURRENT_VIEW->current_base,
2336                                                   CURRENT_VIEW->current_off,
2337                                                   CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE);
2338    pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
2339    if (CURRENT_VIEW->cmd_line == 'O')
2340       CURRENT_VIEW->current_window = WINDOW_FILEAREA;
2341    if (curses_started)
2342    {
2343       if (set_up_windows(current_screen) != RC_OK)
2344       {
2345          TRACE_RETURN();
2346          return(rc);
2347       }
2348    }
2349    redraw_screen(current_screen);
2350    build_screen(current_screen);
2351    display_screen(current_screen);
2352 
2353    TRACE_RETURN();
2354    return(rc);
2355 }
2356 /*man-start*********************************************************************
2357 COMMAND
2358      set ctlchar - define control character attributes
2359 
2360 SYNTAX
2361      [SET] CTLchar OFF
2362      [SET] CTLchar char Escape | OFF
2363      [SET] CTLchar char Protect|Noprotect [modifier[...]] fore [ON back]
2364 
2365 DESCRIPTION
2366      The SET CTLCHAR command defines control characters to be used when
2367      displaying a <reserved line>.  Control characters determine how parts
2368      of a <reserved line> are displayed.
2369 
2370      See <SET COLOUR> for valid values for 'modifier', 'fore' and 'back'.
2371 
2372      The 'Protect' and 'Noprotect' arguments are ignored.
2373 
2374 COMPATIBILITY
2375      XEDIT: Similar, but does not support all parameters.
2376      KEDIT: N/A.
2377 
2378 DEFAULT
2379      OFF
2380 
2381 SEE ALSO
2382      <SET COLOUR>, <SET RESERVED>
2383 
2384 STATUS
2385      Complete.
2386 **man-end**********************************************************************/
2387 #ifdef HAVE_PROTO
Ctlchar(CHARTYPE * params)2388 short Ctlchar(CHARTYPE *params)
2389 #else
2390 short Ctlchar(params)
2391 CHARTYPE *params;
2392 #endif
2393 /***********************************************************************/
2394 {
2395 #define CTL_PARAMS  3
2396    CHARTYPE *word[CTL_PARAMS+1];
2397    CHARTYPE strip[CTL_PARAMS];
2398    short num_params=0;
2399    COLOUR_ATTR attr;
2400    CHARTYPE *dummy=NULL;
2401    bool any_colours=FALSE,protect,found;
2402    int i;
2403    bool have_ctlchar=TRUE;
2404    RESERVED *curr;
2405 
2406    TRACE_FUNCTION("commset1.c:Ctlchar");
2407    strip[0]=STRIP_BOTH;
2408    strip[1]=STRIP_BOTH;
2409    strip[2]=STRIP_BOTH;
2410    num_params = param_split(params,word,CTL_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
2411    if (num_params < 1)
2412    {
2413       display_error(3,(CHARTYPE *)"",FALSE);
2414       TRACE_RETURN();
2415       return(RC_INVALID_OPERAND);
2416    }
2417    if (num_params > 3)
2418    {
2419       display_error(2,(CHARTYPE *)"",FALSE);
2420       TRACE_RETURN();
2421       return(RC_INVALID_OPERAND);
2422    }
2423    if (num_params == 1)
2424    {
2425       if (equal((CHARTYPE *)"off",word[0],1))
2426       {
2427          if (num_params != 1)
2428          {
2429             display_error(2,(CHARTYPE *)"",FALSE);
2430             TRACE_RETURN();
2431             return(RC_INVALID_OPERAND);
2432          }
2433          have_ctlchar = FALSE;
2434       }
2435       else
2436       {
2437          display_error(1,word[0],FALSE);
2438          TRACE_RETURN();
2439          return(RC_INVALID_OPERAND);
2440       }
2441    }
2442    else
2443    {
2444       if (strlen((DEFCHAR *)word[0]) > 1)
2445       {
2446          display_error(37,word[0],FALSE);
2447          TRACE_RETURN();
2448          return(RC_INVALID_OPERAND);
2449       }
2450       if (num_params == 2)
2451       {
2452          if (equal((CHARTYPE *)"escape",word[1],1))
2453          {
2454             /*
2455              * Sets the value in word[0] to be the escape character
2456              */
2457             ctlchar_escape = word[0][0];
2458          }
2459          else if (equal((CHARTYPE *)"off",word[1],3))
2460          {
2461             /*
2462              * Turns off the escape character in word[0]
2463              * Find the entry in
2464              */
2465             for ( i = 0; i < MAX_CTLCHARS; i++ )
2466             {
2467                if (ctlchar_char[i] == word[0][0])
2468                {
2469                   ctlchar_char[i] = 0;
2470                   break;
2471                }
2472             }
2473             /*
2474              * Find the first spare CTLCHAR spec for the supplied character
2475              * and add it.
2476              */
2477             found = FALSE;
2478             for (i=0;i<MAX_CTLCHARS;i++)
2479             {
2480                if (ctlchar_char[i] == 0)
2481                {
2482                   ctlchar_char[i] = word[0][0];
2483                   ctlchar_attr[i].pair = -1;
2484                   found = TRUE;
2485                   break;
2486                }
2487             }
2488             if (!found)
2489             {
2490                display_error(80,(CHARTYPE *)"",FALSE);
2491                TRACE_RETURN();
2492                return(RC_INVALID_OPERAND);
2493             }
2494          }
2495          else if (equal((CHARTYPE *)"protect",word[1],1))
2496          {
2497             display_error(3,(CHARTYPE *)"",FALSE);
2498             TRACE_RETURN();
2499             return(RC_INVALID_OPERAND);
2500          }
2501          else if (equal((CHARTYPE *)"noprotect",word[1],1))
2502          {
2503             display_error(3,(CHARTYPE *)"",FALSE);
2504             TRACE_RETURN();
2505             return(RC_INVALID_OPERAND);
2506          }
2507          else
2508          {
2509             display_error(1,word[1],FALSE);
2510             TRACE_RETURN();
2511             return(RC_INVALID_OPERAND);
2512          }
2513       }
2514       else
2515       {
2516          /*
2517           * Now should be parsing colours to set the ctlchar colour for
2518           * the character in word[0][0]
2519           */
2520          if (equal((CHARTYPE *)"protect",word[1],1))
2521             protect = TRUE;
2522          else if (equal((CHARTYPE *)"noprotect",word[1],1))
2523             protect = FALSE;
2524          else
2525          {
2526             display_error(1,word[1],FALSE);
2527             TRACE_RETURN();
2528             return(RC_INVALID_OPERAND);
2529          }
2530          memset(&attr,0,sizeof(COLOUR_ATTR));
2531          if (parse_colours(word[2],&attr,&dummy,FALSE,&any_colours) != RC_OK)
2532          {
2533             TRACE_RETURN();
2534             return(RC_INVALID_OPERAND);
2535          }
2536          /*
2537           * Find any existing CTLCHAR spec for the supplied character
2538           * and turn it off...
2539           */
2540          for ( i = 0; i < MAX_CTLCHARS; i++ )
2541          {
2542             if (ctlchar_char[i] == word[0][0])
2543             {
2544                ctlchar_char[i] = 0;
2545                ctlchar_protect[i] = FALSE;
2546                break;
2547             }
2548          }
2549          /*
2550           * Find the first spare CTLCHAR spec for the supplied character
2551           * and add it.
2552           */
2553          found = FALSE;
2554          for (i=0;i<MAX_CTLCHARS;i++)
2555          {
2556             if (ctlchar_char[i] == 0)
2557             {
2558                ctlchar_char[i] = word[0][0];
2559                ctlchar_attr[i] = attr;
2560                ctlchar_protect[i] = protect;
2561                found = TRUE;
2562                break;
2563             }
2564          }
2565          if (!found)
2566          {
2567             display_error(80,(CHARTYPE *)"",FALSE);
2568             TRACE_RETURN();
2569             return(RC_INVALID_OPERAND);
2570          }
2571       }
2572    }
2573    CTLCHARx = have_ctlchar;
2574    /*
2575     * For each current reserved line, reparse it to ensure the changes made
2576     * here are reflected correctly.
2577     */
2578    curr = CURRENT_FILE->first_reserved;
2579    while(curr)
2580    {
2581       parse_reserved_line(curr);
2582       curr = curr->next;
2583    }
2584    if (display_screens > 1
2585    &&  SCREEN_FILE(current_screen) == SCREEN_FILE( (CHARTYPE)(other_screen) ))
2586    {
2587       build_screen( (CHARTYPE)(other_screen) );
2588       display_screen( (CHARTYPE)(other_screen) );
2589    }
2590    build_screen(current_screen);
2591    display_screen(current_screen);
2592    TRACE_RETURN();
2593    return(RC_OK);
2594 }
2595 
2596 /*man-start*********************************************************************
2597 COMMAND
2598      set curline - set position of current line on screen
2599 
2600 SYNTAX
2601      [SET] CURLine [ON] M[+n|-n] | [+|-]n
2602 
2603 DESCRIPTION
2604      The SET CURLINE command sets the position of the <current line> to
2605      the physical screen line specified by supplied arguments.
2606 
2607      The first form of parameters is:
2608 
2609      M[+n|-n]
2610      this sets the <current line> to be relative to the middle of
2611      the screen. A positive value adds to the middle line number,
2612      a negative subtracts from it.
2613      e.g. M+3 on a 24 line screen will be line 15
2614          M-5 on a 24 line screen will be line 7
2615 
2616      The second form of parameters is:
2617 
2618      [+|-]n
2619      this sets the <current line> to be relative to the top of the
2620      screen (if positive or no sign) or relative to the bottom
2621      of the screen if negative.
2622      e.g. +3 or 3 will set current line to line 3
2623          -3 on a 24 line screen will be line 21
2624 
2625      If the resulting line is outside the bounds of the screen
2626      the position of the current line will become the middle line
2627      on the screen.
2628 
2629      It is optional to specify the ON argument.
2630 
2631      It is an error to try to position the CURLINE on the same
2632      line as a line already allocated by one of <SET HEXSHOW>,
2633      <SET RESERVED>, <SET SCALE> or <SET TABLINE>.
2634 
2635 COMPATIBILITY
2636      XEDIT: Compatible.
2637      KEDIT: Compatible.
2638 
2639 DEFAULT
2640      M
2641 
2642 STATUS
2643      Complete.
2644 **man-end**********************************************************************/
2645 #ifdef HAVE_PROTO
Curline(CHARTYPE * params)2646 short Curline(CHARTYPE *params)
2647 #else
2648 short Curline(params)
2649 CHARTYPE *params;
2650 #endif
2651 /***********************************************************************/
2652 {
2653 #define CUR_PARAMS  2
2654    CHARTYPE *word[CUR_PARAMS+1];
2655    CHARTYPE strip[CUR_PARAMS];
2656    short num_params=0;
2657    short rc=0;
2658    short base = CURRENT_VIEW->current_base;
2659    short off = CURRENT_VIEW->current_off;
2660    short hexshow_row=0,curline_row=0;
2661    bool onoff = FALSE;
2662 
2663    TRACE_FUNCTION( "commset1.c:Curline" );
2664    strip[0]=STRIP_BOTH;
2665    strip[1]=STRIP_BOTH;
2666    num_params = param_split( params, word, CUR_PARAMS, WORD_DELIMS, TEMP_PARAM, strip, FALSE );
2667    switch( num_params )
2668    {
2669       case 0:
2670          display_error( 3, (CHARTYPE *)"", FALSE );
2671          TRACE_RETURN();
2672          return( RC_INVALID_OPERAND );
2673          break;
2674       case 1:
2675          /*
2676           * Can only be a valid position
2677           */
2678          /*
2679           * Is the first argument ON ?
2680           */
2681          rc = execute_set_on_off( word[0], &onoff, FALSE );
2682          if ( rc != RC_OK )
2683          {
2684             /*
2685              * If not ON or OFF, it must be a position
2686              */
2687             rc = execute_set_row_position( word[0], &base, &off );
2688             if (rc != RC_OK)
2689             {
2690                TRACE_RETURN();
2691                return(rc);
2692             }
2693             /*
2694              * A valid position, so it must be ON
2695              */
2696             onoff = TRUE;
2697             break;
2698          }
2699          /*
2700           * If its ON, error: too few operands
2701           */
2702          if ( onoff == TRUE )
2703          {
2704             display_error( 3, (CHARTYPE *)"", FALSE );
2705             TRACE_RETURN();
2706             return( RC_INVALID_OPERAND );
2707          }
2708          else
2709          {
2710             display_error( 1, (CHARTYPE *)word[0], FALSE );
2711             TRACE_RETURN();
2712             return( RC_INVALID_OPERAND );
2713          }
2714          break;
2715       case 2:
2716          /*
2717           * First argument MUST be ON, 2nd a valid position
2718           */
2719          /*
2720           * Is the first argument ON or OFF ?
2721           */
2722          rc = execute_set_on_off( word[0], &onoff, TRUE );
2723          if ( rc != RC_OK )
2724          {
2725             TRACE_RETURN();
2726             return( RC_INVALID_OPERAND );
2727          }
2728          /*
2729           * If its OFF, error
2730           */
2731          if ( onoff == FALSE )
2732          {
2733             display_error( 1, (CHARTYPE *)word[1], FALSE );
2734             TRACE_RETURN();
2735             return( RC_INVALID_OPERAND );
2736          }
2737          /*
2738           * Is the position correct ?
2739           */
2740          rc = execute_set_row_position( word[1], &base, &off );
2741          if (rc != RC_OK)
2742          {
2743             TRACE_RETURN();
2744             return(rc);
2745          }
2746          break;
2747       default:
2748          display_error (2, (CHARTYPE *)"", FALSE );
2749          TRACE_RETURN();
2750          return( RC_INVALID_OPERAND );
2751          break;
2752    }
2753    /*
2754     * If we have set the CURLINE OFF, redisplay the current screen???
2755     */
2756    if ( onoff == FALSE )
2757    {
2758    }
2759    else
2760    {
2761       /*
2762        * If the CURLINE is the same line as HEXSHOW, SCALE, TABLE or has a
2763        * RESERVED line on it, return ERROR.
2764        */
2765       curline_row = calculate_actual_row( base, off, CURRENT_SCREEN.rows[WINDOW_FILEAREA], TRUE );
2766       if (calculate_actual_row(CURRENT_VIEW->scale_base,
2767                                CURRENT_VIEW->scale_off,
2768                                CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE) == curline_row
2769       && CURRENT_VIEW->scale_on)
2770       {
2771          display_error(64,(CHARTYPE *)"- same as SCALE",FALSE);
2772          TRACE_RETURN();
2773          return(rc);
2774       }
2775       if (calculate_actual_row(CURRENT_VIEW->tab_base,
2776                                CURRENT_VIEW->tab_off,
2777                                CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE) == curline_row
2778       && CURRENT_VIEW->tab_on)
2779       {
2780          display_error(64,(CHARTYPE *)"- same as TABLINE",FALSE);
2781          TRACE_RETURN();
2782          return(rc);
2783       }
2784       hexshow_row = calculate_actual_row(CURRENT_VIEW->hexshow_base,
2785                                          CURRENT_VIEW->hexshow_off,
2786                                          CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE);
2787       if ((hexshow_row == curline_row
2788          ||  hexshow_row + 1 == curline_row)
2789       && CURRENT_VIEW->hexshow_on)
2790       {
2791          display_error(64,(CHARTYPE *)"- same as HEXSHOW",FALSE);
2792          TRACE_RETURN();
2793          return(rc);
2794       }
2795       if (find_reserved_line(current_screen,TRUE,curline_row,0,0) != NULL)
2796       {
2797          display_error(64,(CHARTYPE *)"- same as RESERVED line",FALSE);
2798          TRACE_RETURN();
2799          return(rc);
2800       }
2801       /*
2802        * If the "real" row for CURLINE is not the same as the generated one,
2803        * set the base and offset to reflect the generated row.
2804        */
2805       if ( calculate_actual_row( base, off, CURRENT_SCREEN.rows[WINDOW_FILEAREA], FALSE ) != curline_row )
2806       {
2807          CURRENT_VIEW->current_base = POSITION_MIDDLE;
2808          CURRENT_VIEW->current_off = 0;
2809       }
2810       else
2811       {
2812          CURRENT_VIEW->current_base = base;
2813          CURRENT_VIEW->current_off = off;
2814       }
2815       post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
2816       CURRENT_VIEW->current_row = curline_row;
2817       build_screen(current_screen);
2818       display_screen(current_screen);
2819    }
2820 
2821    TRACE_RETURN();
2822    return(RC_OK);
2823 }
2824 /*man-start*********************************************************************
2825 COMMAND
2826      set cursorstay - set on or off the behaviour of the cursor on a scroll
2827 
2828 SYNTAX
2829      [SET] CURSORSTay ON|OFF
2830 
2831 DESCRIPTION
2832      The SETCURSORSTAY command allows the user to set the behaviour of
2833      the cursor when the file is scrolled with a <FORWARD> or <BACKWARD>
2834      command.
2835 
2836      Before this command was introduced, the position of the cursor
2837      after the file was scrolled depended on <SET COMPAT>; for
2838      THE, the cursor moved to the current line, for XEDIT and KEDIT
2839      modes the cursor stayed on the same screen line.
2840 
2841 COMPATIBILITY
2842      XEDIT: N/A
2843      KEDIT: N/A
2844 
2845 DEFAULT
2846      ON
2847 
2848 STATUS
2849      Complete.
2850 **man-end**********************************************************************/
2851 #ifdef HAVE_PROTO
CursorStay(CHARTYPE * params)2852 short CursorStay(CHARTYPE *params)
2853 #else
2854 short CursorStay(params)
2855 CHARTYPE *params;
2856 #endif
2857 /***********************************************************************/
2858 {
2859    short rc=RC_OK;
2860 
2861    TRACE_FUNCTION("commset1.c:CursorStay");
2862    rc = execute_set_on_off(params,&scroll_cursor_stay, TRUE );
2863    TRACE_RETURN();
2864    return(rc);
2865 }
2866 /*man-start*********************************************************************
2867 COMMAND
2868      set defsort - specify the order in which files appear in DIR.DIR
2869 
2870 SYNTAX
2871      [SET] DEFSORT OFF|DIRectory|Size|Date|Time|Name [Ascending|Descending]
2872 
2873 DESCRIPTION
2874      The SET DEFSORT command allows the user to determine the order
2875      in which files appear in a DIR.DIR file.
2876 
2877      'Directory' specifies that directories within the current directory
2878      are shown before other files.
2879 
2880      'Size' specifies that the size of the file determines the order
2881      in which files are displayed.
2882 
2883      'Date' specifies that the date of the last change to the file
2884      determines the order in which files are displayed. If the dates
2885      are the same, the time the file was last changed is used as a
2886      secondary sort key.
2887 
2888      'Time' specifies that the time of the file determines the order
2889      in which files are displayed.
2890 
2891      'Name' specifies that the name of the file determines the order in
2892      which files are displayed. This is the default.  Files are sorted
2893      by name as a secondary sort key when any of the above options are
2894      specified and two files have equal values for that sort option.
2895 
2896      'OFF' indicates that no ordering of the files in the directory
2897      is performed.  On directories with a large number of files, this
2898      option results in a displayed DIR.DIR file much quicker than any
2899      sorted display.
2900 
2901      The second parameter specifies if the sort order is ascending or
2902      descending.
2903 
2904      If this command is issued while the DIR.DIR pseudo file is the current
2905      file, the settings are applied immediately.
2906 
2907 COMPATIBILITY
2908      XEDIT: N/A
2909      KEDIT: Similar in functionality.
2910 
2911 DEFAULT
2912      NAME ASCENDING
2913 
2914 STATUS
2915      Complete.
2916 **man-end**********************************************************************/
2917 #ifdef HAVE_PROTO
Defsort(CHARTYPE * params)2918 short Defsort(CHARTYPE *params)
2919 #else
2920 short Defsort(params)
2921 CHARTYPE *params;
2922 #endif
2923 /***********************************************************************/
2924 {
2925 #define DIR_PARAMS  2
2926    CHARTYPE *word[DIR_PARAMS+1];
2927    CHARTYPE strip[DIR_PARAMS];
2928    short num_params=0;
2929    short rc=RC_OK;
2930    int defsort=0;
2931    int dirorder=DIRSORT_ASC;
2932 
2933    TRACE_FUNCTION("commset1.c:Defsort");
2934    /*
2935     * Here's a real hack! If we have REPROFILE ON and we call DEFSORT
2936     * in the profile, we go into infinite recursion, so we have to
2937     * check a special global variable; DONT_CALL_DEFSORTx, which is
2938     * only set to TRUE when EditFile() is called from this function.
2939     */
2940    if ( DONT_CALL_DEFSORTx )
2941    {
2942       TRACE_RETURN();
2943       return(RC_OK);
2944    }
2945    strip[0]=STRIP_BOTH;
2946    strip[1]=STRIP_BOTH;
2947    num_params = param_split(params,word,DIR_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
2948    if (num_params < 1)
2949    {
2950       display_error(3,(CHARTYPE *)"",FALSE);
2951       TRACE_RETURN();
2952       return(RC_INVALID_OPERAND);
2953    }
2954    if (num_params > 2)
2955    {
2956       display_error(2,(CHARTYPE *)"",FALSE);
2957       TRACE_RETURN();
2958       return(RC_INVALID_OPERAND);
2959    }
2960    if (equal((CHARTYPE *)"directory",word[0],3))
2961       defsort = DIRSORT_DIR;
2962    else if (equal((CHARTYPE *)"name",word[0],1))
2963       defsort = DIRSORT_NAME;
2964    else if (equal((CHARTYPE *)"time",word[0],1))
2965       defsort = DIRSORT_TIME;
2966    else if (equal((CHARTYPE *)"size",word[0],1))
2967       defsort = DIRSORT_SIZE;
2968    else if (equal((CHARTYPE *)"date",word[0],1))
2969       defsort = DIRSORT_DATE;
2970    else if (equal((CHARTYPE *)"off",word[0],3))
2971       defsort = DIRSORT_NONE;
2972    else
2973    {
2974       display_error(1,(CHARTYPE *)word[0],FALSE);
2975       TRACE_RETURN();
2976       return(RC_INVALID_OPERAND);
2977    }
2978    if (num_params == 2)
2979    {
2980       if (equal((CHARTYPE *)"ascending",word[1],1))
2981          dirorder = DIRSORT_ASC;
2982       else  if (equal((CHARTYPE *)"descending",word[1],1))
2983          dirorder = DIRSORT_DESC;
2984       else
2985       {
2986          display_error(1,(CHARTYPE *)word[1],FALSE);
2987          TRACE_RETURN();
2988          return(RC_INVALID_OPERAND);
2989       }
2990    }
2991    DEFSORTx = defsort;
2992    DIRORDERx = dirorder;
2993    /*
2994     * If we are in DIR.DIR, then reload the directory
2995     */
2996    if ( CURRENT_FILE->pseudo_file == PSEUDO_DIR )
2997    {
2998       DONT_CALL_DEFSORTx = TRUE;
2999       strcpy( (DEFCHAR *)temp_cmd, (DEFCHAR *)dir_path );
3000       strcat( (DEFCHAR *)temp_cmd, (DEFCHAR *)dir_files );
3001       /*
3002        * Edit the DIR.DIR file
3003        */
3004       rc = Directory( temp_cmd );
3005       DONT_CALL_DEFSORTx = FALSE;
3006    }
3007    TRACE_RETURN();
3008    return(rc);
3009 }
3010 /*man-start*********************************************************************
3011 COMMAND
3012      set dirinclude - set the file mask for directory command
3013 
3014 SYNTAX
3015      [SET] DIRInclude *
3016      [SET] DIRInclude [Normal] [Readonly] [System] [Hidden] [Directory]
3017 
3018 DESCRIPTION
3019      The DIRINCLUDE command sets the file mask for files that will be
3020      displayed on subsequent DIRECTORY commands. The operand "*" will
3021      set the mask to all files, the other options will set the
3022      mask to include those options specified together with "normal"
3023      files e.g.
3024 
3025         DIRINCLUDE R S
3026 
3027      will display readonly and system files together with "normal" files
3028      the next time the DIRECTORY command is issued.
3029 
3030      The effects of DIRINCLUDE are ignored in the Unix version.
3031 
3032 COMPATIBILITY
3033      XEDIT: N/A
3034      KEDIT: N/A
3035 
3036 DEFAULT
3037      *
3038 
3039 SEE ALSO
3040      <DIRECTORY>, <LS>
3041 
3042 STATUS
3043      Complete.
3044 **man-end**********************************************************************/
3045 #ifdef HAVE_PROTO
Dirinclude(CHARTYPE * params)3046 short Dirinclude(CHARTYPE *params)
3047 #else
3048 short Dirinclude(params)
3049 CHARTYPE *params;
3050 #endif
3051 /***********************************************************************/
3052 {
3053    short rc=RC_OK;
3054 
3055    TRACE_FUNCTION("commset1.c:Dirinclude");
3056    rc = set_dirtype(params);
3057    TRACE_RETURN();
3058    return(rc);
3059 }
3060 /*man-start*********************************************************************
3061 COMMAND
3062      set display - specify which level of lines to display
3063 
3064 SYNTAX
3065      [SET] DISPlay n [m|*]
3066 
3067 DESCRIPTION
3068      The SET DISPLAY command sets the selection level for lines to be
3069      displayed on the screen.
3070 
3071 COMPATIBILITY
3072      XEDIT: Compatible.
3073      KEDIT: Compatible.
3074 
3075 DEFAULT
3076      0 0
3077 
3078 SEE ALSO
3079      <SET SCOPE>, <SET SELECT>, <ALL>
3080 
3081 STATUS
3082      Complete.
3083 **man-end**********************************************************************/
3084 #ifdef HAVE_PROTO
Display(CHARTYPE * params)3085 short Display(CHARTYPE *params)
3086 #else
3087 short Display(params)
3088 CHARTYPE *params;
3089 #endif
3090 /***********************************************************************/
3091 {
3092    short rc=RC_OK;
3093    short col1=0,col2=0;
3094 
3095    TRACE_FUNCTION("commset1.c:Display");
3096    if ((rc = validate_n_m(params,&col1,&col2)) != RC_OK)
3097    {
3098       TRACE_RETURN();
3099       return(rc);
3100    }
3101    CURRENT_VIEW->display_low = col1;
3102    CURRENT_VIEW->display_high = col2;
3103    /*
3104     * If we are on the command line and the result of this statement means
3105     * that the current line is no longer in scope, we need to make the
3106     * current line and possibly the focus line the next line in scope.
3107     */
3108    if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
3109    {
3110       CURRENT_VIEW->current_line = find_next_in_scope(CURRENT_VIEW,NULL,get_true_line(TRUE),DIRECTION_FORWARD);
3111       build_screen(current_screen);
3112       if (!line_in_view(current_screen,CURRENT_VIEW->focus_line))
3113       {
3114          CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
3115          pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
3116       }
3117    }
3118    pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
3119    build_screen(current_screen);
3120    display_screen(current_screen);
3121    /*
3122     * If the same file is in the other screen, refresh it
3123     */
3124    adjust_other_screen_shadow_lines();
3125 
3126    TRACE_RETURN();
3127    return(rc);
3128 }
3129 /*man-start*********************************************************************
3130 COMMAND
3131      set ecolor - set colors for syntax highlighting
3132 
3133 SYNTAX
3134      [SET] ECOLOR char [modifier[...]] [foreground] [on background]
3135      [SET] ECOLOR char [modifier[...]] ON|OFF
3136 
3137 DESCRIPTION
3138      The SET ECOLOR command allows the user to specify the colors of
3139      each category of items used in syntax highlighting.
3140 
3141      'char' refers to one of the following valid values:
3142 
3143      A - comments
3144      B - strings
3145      C - numbers
3146      D - keywords
3147      E - labels
3148      F - preprocessor directives
3149      G - header lines
3150      H - extra right paren, matchable keyword (N/A)
3151      I - level 1 paren
3152      J - level 1 matchable keyword (N/A)
3153      K - level 1 matchable preprocessor keyword (N/A)
3154      L - level 2 paren, matchable keyword (N/A)
3155      M - level 3 paren, matchable keyword (N/A)
3156      N - level 4 paren, matchable keyword (N/A)
3157      O - level 5 paren, matchable keyword (N/A)
3158      P - level 6 paren, matchable keyword (N/A)
3159      Q - level 7 paren, matchable keyword (N/A)
3160      R - level 8 paren or higher, matchable keyword (N/A)
3161      S - incomplete string
3162      T - HTML markup tags
3163      U - HTML character/entity references
3164      V - Builtin functions
3165      W - not used
3166      X - not used
3167      Y - not used
3168      Z - not used
3169      1 - alternate keyword color 1
3170      2 - alternate keyword color 2
3171      3 - alternate keyword color 3
3172      4 - alternate keyword color 4
3173      5 - alternate keyword color 5
3174      6 - alternate keyword color 6
3175      7 - alternate keyword color 7
3176      8 - alternate keyword color 8
3177      9 - alternate keyword color 9
3178      N/A indicates that this capability is not yet implemented.
3179 
3180      For valid values for 'modifier', 'foreground' and 'background'
3181      see <SET COLOR>.
3182 
3183      The second format of this command allows the user to turn on or off
3184      any of the valid modifiers.
3185 
3186 COMPATIBILITY
3187      XEDIT: N/A
3188      KEDIT: Compatible.
3189 
3190 DEFAULT
3191      See <QUERY> ECOLOR
3192 
3193 SEE ALSO
3194      <SET COLORING>, <SET AUTOCOLOR>, <SET PARSER>, <SET COLOR>
3195      Appendix 4
3196 
3197 STATUS
3198      Complete.
3199 **man-end**********************************************************************/
3200 /*man-start*********************************************************************
3201 COMMAND
3202      set ecolour - set colours for syntax highlighting
3203 
3204 SYNTAX
3205      [SET] ECOLOUR char [modifier[...]] [foreground] [on background]
3206      [SET] ECOLOUR char [modifier[...]] ON|OFF
3207 
3208 DESCRIPTION
3209      The SET ECOLOUR command allows the user to specify the colours of
3210      each category of items used in syntax highlighting.
3211 
3212 COMPATIBILITY
3213      XEDIT: N/A
3214      KEDIT: Compatible.
3215 
3216 DEFAULT
3217      See <QUERY> ECOLOR
3218 
3219 SEE ALSO
3220      <SET COLOURING>, <SET AUTOCOLOUR>, <SET PARSER>, <SET COLOUR>
3221      Appendix 4
3222 
3223 STATUS
3224      Complete.
3225 **man-end**********************************************************************/
3226 #ifdef HAVE_PROTO
Ecolour(CHARTYPE * params)3227 short Ecolour(CHARTYPE *params)
3228 #else
3229 short Ecolour(params)
3230 CHARTYPE *params;
3231 #endif
3232 
3233 /***********************************************************************/
3234 {
3235 #define ECOL_PARAMS 2
3236    CHARTYPE *word[ECOL_PARAMS+1];
3237    CHARTYPE strip[ECOL_PARAMS];
3238    unsigned short num_params=0;
3239    short area=0,off;
3240    register short i=0;
3241    COLOUR_ATTR attr,tmp_attr;
3242    CHARTYPE *dummy=NULL;
3243    bool any_colours=FALSE;
3244    CHARTYPE ch;
3245    short word1_len,modifier_set=COL_MODIFIER_NO_SET;
3246 
3247    TRACE_FUNCTION("commset1.c:Ecolour");
3248    strip[0]=STRIP_BOTH;
3249    strip[1]=STRIP_BOTH;
3250    num_params = param_split(params,word,ECOL_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
3251    if (num_params < 2 )
3252    {
3253       display_error(3,(CHARTYPE *)"",FALSE);
3254       TRACE_RETURN();
3255       return(RC_INVALID_OPERAND);
3256    }
3257    /*
3258     * Check which format of this command we are running.
3259     * If the last word is ON or OFF then we are executing the
3260     * second format.
3261     */
3262    word1_len = strlen( (DEFCHAR *)word[1] );
3263    if ( my_stricmp( (DEFCHAR *)word[1]+word1_len-2, "ON" ) == 0 )
3264       modifier_set = COL_MODIFIER_SET_ON;
3265    else if ( my_stricmp( (DEFCHAR *)word[1]+word1_len-3, "OFF" ) == 0 )
3266       modifier_set = COL_MODIFIER_SET_OFF;
3267    if ( modifier_set )
3268    {
3269       /*
3270        * Check that the supplied area matches one of the values in the area
3271        * array and that the length is at least as long as the minimum.
3272        */
3273       if (strlen((DEFCHAR *)word[0]) != 1)
3274       {
3275          display_error(1,word[0],FALSE);
3276          TRACE_RETURN();
3277          return(RC_INVALID_OPERAND);
3278       }
3279       ch = word[0][0];
3280       if (ch >= 'A' && ch <= 'Z')
3281          off = 'A';
3282       else if (ch >= 'a' && ch <= 'z')
3283          off = 'a';
3284       else if (ch >= '1' && ch <= '9')
3285          off = '1' - 26; /* Beware: --x == +x */
3286       else if (ch == '*' )
3287          off = -1;
3288       else
3289       {
3290          display_error(1,word[0],FALSE);
3291          TRACE_RETURN();
3292          return(RC_INVALID_OPERAND);
3293       }
3294       /*
3295        * Check that each subsequent parameter (except the last) is
3296        * a modifier.
3297        */
3298       if ( parse_modifiers( word[1], &tmp_attr ) != RC_OK )
3299       {
3300          TRACE_RETURN();
3301          return(RC_INVALID_OPERAND);
3302       }
3303       if ( off == (-1) )
3304       {
3305          for ( i = 0; i < ECOLOUR_MAX; i++ )
3306          {
3307             attr = CURRENT_FILE->ecolour[i] ;
3308             if ( modifier_set == COL_MODIFIER_SET_ON )
3309             {
3310                if ( colour_support )
3311                   attr.mod |= tmp_attr.mod;
3312                else
3313                   attr.mono |= tmp_attr.mono;
3314             }
3315             else
3316             {
3317                if ( colour_support )
3318                   attr.mod &= ~tmp_attr.mod;
3319                else
3320                   attr.mono &= ~tmp_attr.mono;
3321             }
3322             CURRENT_FILE->ecolour[i] = attr;
3323          }
3324       }
3325       else
3326       {
3327          area = ch - off;
3328          attr = CURRENT_FILE->ecolour[area];
3329          if ( modifier_set == COL_MODIFIER_SET_ON )
3330          {
3331             if ( colour_support )
3332                attr.mod |= tmp_attr.mod;
3333             else
3334                attr.mono |= tmp_attr.mono;
3335          }
3336          else
3337          {
3338             if ( colour_support )
3339                attr.mod &= ~tmp_attr.mod;
3340             else
3341                attr.mono &= ~tmp_attr.mono;
3342          }
3343          CURRENT_FILE->ecolour[area] = attr;
3344       }
3345    }
3346    else
3347    {
3348       /*
3349        * Check that the supplied area matches one of the values in the area
3350        * array and that the length is at least as long as the minimum.
3351        */
3352       if (strlen((DEFCHAR *)word[0]) != 1)
3353       {
3354          display_error(1,word[0],FALSE);
3355          TRACE_RETURN();
3356          return(RC_INVALID_OPERAND);
3357       }
3358       ch = word[0][0];
3359       if (ch >= 'A' && ch <= 'Z')
3360          off = 'A';
3361       else if (ch >= 'a' && ch <= 'z')
3362          off = 'a';
3363       else if (ch >= '1' && ch <= '9')
3364          off = '1' - 26; /* Beware: --x == +x */
3365       else
3366       {
3367          display_error(1,word[0],FALSE);
3368          TRACE_RETURN();
3369          return(RC_INVALID_OPERAND);
3370       }
3371       area = ch - off;
3372       attr = CURRENT_FILE->ecolour[area];
3373       /*
3374        * Determine colours and modifiers.
3375        */
3376       if (parse_colours(word[1],&attr,&dummy,FALSE,&any_colours) != RC_OK)
3377       {
3378          TRACE_RETURN();
3379          return(RC_INVALID_OPERAND);
3380       }
3381       /*
3382        * Now we have the new colours, save them with the current file...
3383        */
3384       CURRENT_FILE->ecolour[area] = attr;
3385    }
3386    /*
3387     * If we haven't started curses (in profile first time) exit now...
3388     */
3389    if (!curses_started)
3390    {
3391       TRACE_RETURN();
3392       return(RC_OK);
3393    }
3394    /*
3395     * Update the appropriate window with the new colour combination...
3396     */
3397    if (display_screens > 1
3398    &&  SCREEN_FILE(current_screen) == SCREEN_FILE( (CHARTYPE)(other_screen) ))
3399    {
3400       display_screen( (CHARTYPE)(other_screen) );
3401    }
3402    display_screen(current_screen);
3403    TRACE_RETURN();
3404    return(RC_OK);
3405 }
3406 /*man-start*********************************************************************
3407 COMMAND
3408      set eolout - set end of line terminating character(s)
3409 
3410 SYNTAX
3411      [SET] EOLout CRLF|LF|CR|NONE
3412 
3413 DESCRIPTION
3414      The EOLOUT command allows the user to specify the combination of
3415      characters that terminate a line. Lines of text in Unix files are
3416      usually terminated with a 'LF', DOS file usually end with a 'CR' and
3417      'LF' combination. Files on the Apple Macintosh are usually terminated
3418      with a 'CR'.
3419 
3420      The 'NONE' option can be used to specify that no end of line
3421      character is written.
3422 
3423 COMPATIBILITY
3424      XEDIT: N/A
3425      KEDIT: N/A
3426 
3427 DEFAULT
3428      LF - UNIX
3429      CRLF - DOS/OS2/WIN32
3430      NONE - if THE started with -u option
3431 
3432 STATUS
3433      Complete.
3434 **man-end**********************************************************************/
3435 #ifdef HAVE_PROTO
Eolout(CHARTYPE * params)3436 short Eolout(CHARTYPE *params)
3437 #else
3438 short Eolout(params)
3439 CHARTYPE *params;
3440 #endif
3441 /***********************************************************************/
3442 {
3443    CHARTYPE eolchar=0;
3444 
3445    TRACE_FUNCTION("commset1.c:Eolout");
3446    params = MyStrip( params, STRIP_BOTH, ' ' );
3447    if ( equal((CHARTYPE *)"lf", params, 2 ) )
3448       eolchar = EOLOUT_LF;
3449    else if ( equal( (CHARTYPE *)"cr", params, 2 ) )
3450       eolchar = EOLOUT_CR;
3451    else if ( equal( (CHARTYPE *)"crlf", params, 4 ) )
3452       eolchar = EOLOUT_CRLF;
3453    else if ( equal( (CHARTYPE *)"none", params, 4 ) )
3454       eolchar = EOLOUT_NONE;
3455    else
3456    {
3457       display_error( 1, (CHARTYPE *)params, FALSE );
3458       TRACE_RETURN();
3459       return(RC_INVALID_OPERAND);
3460    }
3461    if ( display_length != 0
3462    &&   eolchar != EOLOUT_NONE )
3463    {
3464       display_error( 0, (CHARTYPE *)"Warning: Setting EOLOUT will result in extra characters appended to each line on SAVE/FILE!", FALSE );
3465    }
3466 
3467    EOLx = CURRENT_FILE->eolout = eolchar;
3468    TRACE_RETURN();
3469    return(RC_OK);
3470 }
3471 /*man-start*********************************************************************
3472 COMMAND
3473      set equivchar - set the equivalence character
3474 
3475 SYNTAX
3476      [SET] EQUIVChar char
3477 
3478 DESCRIPTION
3479      The SET EQUIVChar command allows the user to change the character
3480      that is used to specify equivalence in command parameters.
3481 
3482      In many THE commands, an equivalence character, usually '=', can
3483      be used as a parameter to default to values in the current file
3484      or view.
3485 
3486 COMPATIBILITY
3487      XEDIT: N/A
3488      KEDIT: N/A
3489 
3490 DEFAULT
3491      =
3492 
3493 STATUS
3494      Complete.
3495 **man-end**********************************************************************/
3496 #ifdef HAVE_PROTO
Equivchar(CHARTYPE * params)3497 short Equivchar(CHARTYPE *params)
3498 #else
3499 short Equivchar(params)
3500 CHARTYPE *params;
3501 #endif
3502 /***********************************************************************/
3503 {
3504    short rc=RC_OK;
3505 
3506    TRACE_FUNCTION("commset1.c:Equivchar");
3507    /*
3508     * Must supply a parameter...
3509     */
3510    if (blank_field(params))
3511    {
3512       display_error(3,(CHARTYPE *)"",FALSE);
3513       TRACE_RETURN();
3514       return(RC_INVALID_OPERAND);
3515    }
3516    /*
3517     * ... and it must be a single character
3518     */
3519    if (strlen( (DEFCHAR *)params ) > 1 )
3520    {
3521       display_error(37,params,FALSE);
3522       TRACE_RETURN();
3523       return(RC_INVALID_OPERAND);
3524    }
3525    /*
3526     * Save it.
3527     */
3528    EQUIVCHARstr[0] = EQUIVCHARx = *(params);
3529    TRACE_RETURN();
3530    return(rc);
3531 }
3532 /*man-start*********************************************************************
3533 COMMAND
3534      set erroroutput - indicate whether THE error messages are echoed to screen
3535 
3536 SYNTAX
3537      [SET] ERROROUTput ON|OFF
3538 
3539 DESCRIPTION
3540      With SET ERROROUTPUT OFF, THE error messages are shown in the MSGLINE.
3541      With SET ERROROUTPUT ON, THE error messages are also displayed in the window
3542      in which THE was started, provided one exists.
3543      This is particularly useful when tracing THE macros as the error message
3544      is shown afte the invocation of the command that caused the error.
3545 
3546 COMPATIBILITY
3547      XEDIT: N/A
3548      KEDIT: N/A
3549 
3550 DEFAULT
3551      OFF
3552 
3553 STATUS
3554      Complete.
3555 **man-end**********************************************************************/
3556 #ifdef HAVE_PROTO
Erroroutput(CHARTYPE * params)3557 short Erroroutput(CHARTYPE *params)
3558 #else
3559 short Erroroutput(params)
3560 CHARTYPE *params;
3561 #endif
3562 /***********************************************************************/
3563 {
3564    short rc=RC_OK;
3565 
3566    TRACE_FUNCTION("commset1.c:Erroroutput");
3567    rc = execute_set_on_off(params,&ERROROUTPUTx, TRUE );
3568    TRACE_RETURN();
3569    return(rc);
3570 }
3571 /*man-start*********************************************************************
3572 COMMAND
3573      set etmode - indicate if extended display mode is possible
3574 
3575 SYNTAX
3576      [SET] ETMODE ON|OFF [character list]
3577 
3578 DESCRIPTION
3579      The SET ETMODE command allows the user to specify which characters
3580      in a character set are to be displayed as their actual representation.
3581 
3582      Those characters not explicitly specified to be displayed as they are
3583      represented, will be displayed as the <SET NONDISP> character in the
3584      colour specified by <SET COLOUR> NONDISP. Characters below 32, will
3585      be displayed with an alphabetic character representing the "control"
3586      code.
3587 
3588      e.g.
3589      character code with a value of 7, will display as "G" in the colour
3590      specified by <SET COLOUR> NONDISP.
3591 
3592      'ON' with no optional 'character list' will display ALL
3593      characters as their actual representation.
3594 
3595      'OFF' with no optional 'character list' will display control
3596      characters below ASCII 32, as a "control" character; characters
3597      greater than ASCII 126 will be displayed as the <SET NONDISP>
3598      characters. On ASCII based machines, [SET] ETMODE OFF is
3599      equivalent  to [SET] ETMODE ON 32-126. On EBCDIC based machines
3600      [SET] ETMODE OFF is equivalent to [SET] ETMODE ON ??-??
3601 
3602      The 'character list' is a list of positive numbers between 0 and
3603      255 (inclusive).  The format of this character list can be either
3604      a single number; e.g. 124, or a range of numbers specified; e.g.
3605      32-126. (The first number must be less than or equal to the second
3606      number).
3607 
3608      As an example; ETMODE ON 32-127 160-250  would result in the
3609      characters with a decimal value between 32 and 127 inclusive
3610      and 160 and 250 inclusive being displayed as their actual
3611      representation (depending on the current font), and the
3612      characters between 0 and 31 inclusive, being displayed as
3613      an equivalent "control" character; characters between 128 and
3614      159 inclusive and 250 to 255 being displayed with the <SET NONDISP>
3615      character.
3616 
3617      Up to 20 character specifiers (single number or range) can be
3618      specified.
3619 
3620 COMPATIBILITY
3621      XEDIT: Similar function but deals with Double-Byte characters
3622      KEDIT: N/A
3623 
3624 DEFAULT
3625      ON - DOS/OS2/WIN32
3626      ON 32-255 - X11
3627      OFF - UNIX/AMIGA/QNX
3628 
3629 SEE ALSO
3630      <SET NONDISP>, <SET COLOUR>
3631 
3632 STATUS
3633      Complete.
3634 **man-end**********************************************************************/
3635 #ifdef HAVE_PROTO
Etmode(CHARTYPE * params)3636 short Etmode(CHARTYPE *params)
3637 #else
3638 short Etmode(params)
3639 CHARTYPE *params;
3640 #endif
3641 /***********************************************************************/
3642 {
3643 #define ETM_PARAMS  21
3644    CHARTYPE *word[ETM_PARAMS+1];
3645    CHARTYPE strip[ETM_PARAMS];
3646    short num_params=0;
3647    register short i=0,j=0;
3648    short rc=RC_OK;
3649    bool tmp_mode=FALSE;
3650    chtype attr=0L;
3651    COLOUR_ATTR curr_attr;
3652    bool flags[256];
3653    int num=0,num1=0;
3654    CHARTYPE *wptr=NULL,*wptr1=NULL;
3655 
3656    TRACE_FUNCTION("commset1.c:Etmode");
3657    for(i=0;i<ETM_PARAMS;i++)
3658       strip[i]=STRIP_BOTH;
3659    num_params = param_split(params,word,ETM_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
3660    if (num_params < 1)
3661    {
3662       display_error(3,(CHARTYPE *)"",FALSE);
3663       TRACE_RETURN();
3664       return(RC_INVALID_OPERAND);
3665    }
3666    rc = execute_set_on_off(word[0],&tmp_mode, TRUE );
3667    if (rc != RC_OK)
3668    {
3669       display_error(1,word[0],FALSE);
3670       TRACE_RETURN();
3671       return(RC_INVALID_OPERAND);
3672    }
3673    if (CURRENT_VIEW == NULL
3674    ||  CURRENT_FILE == NULL)
3675       set_up_default_colours((FILE_DETAILS *)NULL,&curr_attr,ATTR_NONDISP);
3676    else
3677       memcpy(&curr_attr,CURRENT_FILE->attr+ATTR_NONDISP,sizeof(COLOUR_ATTR));
3678    attr = set_colour(&curr_attr);
3679    if (num_params == 1)  /* absolute ON or OFF */
3680    {
3681       if (tmp_mode)  /* ETMODE ON */
3682       {
3683          for (i=0;i<256;i++)
3684          {
3685             etmode_table[i] = i;
3686             etmode_flag[i] = FALSE;
3687          }
3688       }
3689       else
3690       {
3691          for (i=0;i<256;i++)
3692          {
3693             if (isprint(i) )
3694             {
3695                etmode_table[i] = i;
3696                etmode_flag[i] = FALSE;
3697             }
3698             else if (iscntrl(i) )
3699             {
3700                etmode_table[i] = ('@' + i) | attr;
3701                etmode_flag[i] = (attr)?TRUE:FALSE;
3702             }
3703             else
3704             {
3705                etmode_table[i] = NONDISPx | attr;
3706                etmode_flag[i] = (attr)?TRUE:FALSE;
3707             }
3708          }
3709       }
3710       if (number_of_files != 0)
3711       {
3712          build_screen(current_screen);
3713          display_screen(current_screen);
3714       }
3715       TRACE_RETURN();
3716       return(RC_OK);
3717    }
3718    memset(flags,FALSE,sizeof(flags));
3719    for (i=1;i<num_params;i++)
3720    {
3721       if (valid_positive_integer(word[i]))
3722       {
3723          num = atoi((DEFCHAR *)word[i]);
3724          if (num > 255)
3725          {
3726             display_error(6,word[i],FALSE);
3727             TRACE_RETURN();
3728             return(RC_INVALID_OPERAND);
3729          }
3730          flags[num] = TRUE;
3731          continue;
3732       }
3733       num = strzeq(word[i],(CHARTYPE)'-');
3734       num1 = strzreveq(word[i],(CHARTYPE)'-');
3735       if (num != num1
3736       || num == (-1))
3737       {
3738          display_error(1,word[i],FALSE);
3739          TRACE_RETURN();
3740          return(RC_INVALID_OPERAND);
3741       }
3742       wptr = word[i];
3743       *(wptr+num) = '\0';
3744       wptr1 = wptr+num+1;
3745       if (!valid_positive_integer(wptr))
3746       {
3747          display_error(1,wptr,FALSE);
3748          TRACE_RETURN();
3749          return(RC_INVALID_OPERAND);
3750       }
3751       if (!valid_positive_integer(wptr))
3752       {
3753          display_error(1,wptr1,FALSE);
3754          TRACE_RETURN();
3755          return(RC_INVALID_OPERAND);
3756       }
3757       num = atoi((DEFCHAR *)wptr);
3758       num1 = atoi((DEFCHAR *)wptr1);
3759       if (num > num1)
3760       {
3761          display_error(1,word[i],FALSE);
3762          TRACE_RETURN();
3763          return(RC_INVALID_OPERAND);
3764       }
3765       if (num > 255)
3766       {
3767          display_error(6,wptr,FALSE);
3768          TRACE_RETURN();
3769          return(RC_INVALID_OPERAND);
3770       }
3771       if (num1 > 255)
3772       {
3773          display_error(6,wptr1,FALSE);
3774          TRACE_RETURN();
3775          return(RC_INVALID_OPERAND);
3776       }
3777       for (j=num;j<num1+1;j++)
3778       {
3779          flags[j] = TRUE;
3780       }
3781    }
3782    for (i=0;i<256;i++)
3783    {
3784       if (flags[i])
3785       {
3786          etmode_table[i] = i;
3787          etmode_flag[i] = FALSE;
3788       }
3789       else
3790       {
3791          if (iscntrl(i) )
3792          {
3793             etmode_table[i] = ('@' + i) | attr;
3794             etmode_flag[i] = TRUE;
3795          }
3796          else
3797          {
3798             etmode_table[i] = NONDISPx | attr;
3799             etmode_flag[i] = TRUE;
3800          }
3801       }
3802    }
3803    if (number_of_files != 0)
3804    {
3805       build_screen(current_screen);
3806       display_screen(current_screen);
3807    }
3808    TRACE_RETURN();
3809    return(rc);
3810 }
3811 /*man-start*********************************************************************
3812 COMMAND
3813      set fext - change the extension of the existing file
3814 
3815 SYNTAX
3816      [SET] FExt ext
3817      [SET] FType ext
3818 
3819 DESCRIPTION
3820      The SET FEXT command allows the user to change the extension of
3821      the file currently being edited. The extension is the characters
3822      after the last period.
3823 
3824      See <SET FILENAME> for a full explanation of THE's definitions
3825      of fpath, filename, fname, fext and fmode.
3826 
3827      It is not possible to use this command on pseudo files.
3828 
3829 COMPATIBILITY
3830      XEDIT: N/A
3831      KEDIT: N/A
3832 
3833 SEE ALSO
3834      <SET FNAME>, <SET FILENAME>, <SET FTYPE>, <SET FMODE>
3835 
3836 STATUS
3837      Complete.
3838 **man-end**********************************************************************/
3839 #ifdef HAVE_PROTO
Fext(CHARTYPE * params)3840 short Fext(CHARTYPE *params)
3841 #else
3842 short Fext(params)
3843 CHARTYPE *params;
3844 #endif
3845 /***********************************************************************/
3846 {
3847    CHARTYPE tmp_name[MAX_FILE_NAME+1];
3848    short rc=RC_OK;
3849    int last_period=0;
3850 
3851    TRACE_FUNCTION("commset1.c:Fext");
3852    /*
3853     * If a pseudo file is being changed, then error...
3854     */
3855    if (CURRENT_FILE->pseudo_file)
3856    {
3857       display_error(8,(CHARTYPE *)"",FALSE);
3858       TRACE_RETURN();
3859       return(RC_INVALID_OPERAND);
3860    }
3861    strcpy((DEFCHAR *)tmp_name,(DEFCHAR *)CURRENT_FILE->fpath);
3862    strcat((DEFCHAR*)tmp_name,(DEFCHAR*)CURRENT_FILE->fname);
3863    last_period = strzreveq(CURRENT_FILE->fname,(CHARTYPE)'.');
3864    if (last_period == (-1)) /* no period */
3865    {
3866       if (blank_field(params)) /* and no extension, return... */
3867       {
3868          TRACE_RETURN();
3869          return(RC_OK);
3870       }
3871       strcat((DEFCHAR*)tmp_name,"."); /* add a period */
3872    }
3873    else
3874    {
3875       tmp_name[strlen((DEFCHAR*)CURRENT_FILE->fpath)+last_period+1] = '\0';
3876    }
3877    strcat((DEFCHAR*)tmp_name,(DEFCHAR*)params);
3878    /*
3879     * Split the new path supplied...
3880     */
3881    if ((rc = splitpath(strrmdup(strtrans(tmp_name,OSLASH,ISLASH),ISLASH,TRUE))) != RC_OK)
3882    {
3883       display_error(10,tmp_name,FALSE);
3884       TRACE_RETURN();
3885       return(rc);
3886    }
3887    /*
3888     * If the path is NOT the same as already assigned, error...
3889     */
3890    if (strcmp((DEFCHAR *)sp_path,(DEFCHAR *)CURRENT_FILE->fpath) != 0)
3891    {
3892       display_error(1,params,FALSE);
3893       TRACE_RETURN();
3894       return(RC_OK);
3895    }
3896    /*
3897     * Check we don't already have this filename in the ring
3898     */
3899    if ( is_file_in_ring( CURRENT_FILE->fpath, sp_fname ) )
3900    {
3901       display_error( 76, tmp_name, FALSE );
3902       TRACE_RETURN();
3903       return(RC_INVALID_OPERAND);
3904    }
3905    /*
3906     * If the length of the new path is > the existing one,
3907     * free up any memory for the existing path and allocate some
3908     * more. Save the new path.
3909     */
3910    if (strlen((DEFCHAR*)sp_fname) > strlen((DEFCHAR*)CURRENT_FILE->fname))
3911    {
3912       (*the_free)(CURRENT_FILE->fname);
3913       if ((CURRENT_FILE->fname = (CHARTYPE *)(*the_malloc)(strlen((DEFCHAR *)sp_fname))) == NULL)
3914       {
3915          display_error(30,(CHARTYPE *)"",FALSE);
3916          TRACE_RETURN();
3917          return(RC_OUT_OF_MEMORY);
3918       }
3919    }
3920    strcpy((DEFCHAR *)CURRENT_FILE->fname,(DEFCHAR *)sp_fname);
3921    /*
3922     * Re-display the IDLINE
3923     */
3924    if (display_screens > 1
3925    &&  SCREEN_FILE(current_screen) == SCREEN_FILE( (CHARTYPE)(other_screen) ))
3926       show_heading( (CHARTYPE)(other_screen) );
3927    show_heading(current_screen);
3928    TRACE_RETURN();
3929    return(rc);
3930 }
3931 /*man-start*********************************************************************
3932 COMMAND
3933      set filename - change the filename of the file being edited
3934 
3935 SYNTAX
3936      [SET] FILEName filename
3937 
3938 DESCRIPTION
3939      The SET FILEName command allows the user to change the filename of
3940      the file currently being edited.
3941 
3942      In THE, a fully qualified file name consists of a file path and a
3943      file name.  THE treats all characters up to and including the
3944      last directory separator (usually / or \) as the file's path.
3945      From the first character after the end of the file's path, to
3946      the end of the fully qualified file name is the file name.
3947 
3948      A file name is further broken down into a fname and fext.
3949      The fname of a file consists of all characters from the start
3950      of the filename up to but not including the last period (if
3951      there is one).  The fext of a file consists of all characters
3952      from the end of the filename up to but not including the last
3953      period. If there is no period in the filename then the fext is
3954      empty.
3955 
3956      The fmode of a file is equivalent to the drive letter of the file's
3957      path. This is only valid under DOS, OS/2 and Windows ports.
3958 
3959      Some examples.
3960 
3961      *----------------------------------------------------------------
3962      Full File Name     File            File     Fname  Fext     Fmode
3963                         Path            Name
3964      -----------------------------------------------------------------
3965      /usr/local/bin/the /usr/local/bin/ the      the             N/A
3966      c:\tools\the.exe   c:\tools\       the.exe  the    exe      c
3967      /etc/a.b.c         /etc/           a.b.c    a.b    c        N/A
3968      *----------------------------------------------------------------
3969 
3970      A limited amount of validation of the resulting file name is
3971      carried out by this command, but some errors in the file name
3972      will not be evident until the file is saved.
3973 
3974      A leading "=" indicates that the fname portion of the current file
3975      name is be retained.  This is equivalent to the command
3976      <SET FEXT>.  A trailing "=" indicates that the fext portion of
3977      the current file name is to be retained. This is equivalent to the
3978      command <SET FNAME>.
3979 
3980      Only one "=" is allowed in the parameter.
3981 
3982      Some examples.
3983 
3984      *----------------------------------------------------------------
3985      File Name   Parameter  New File Name
3986      -----------------------------------------------------------------
3987      a.b.c       fred.c=    fred.c.c      SET FNAME fred.c
3988      a.b.c       fred.c.=   fred.c..c     SET FNAME fred.c.
3989      a.b.c       =fred      a.c.fred      SET FEXT fred
3990      a.b.c       =.fred     a.c..fred     SET FEXT .fred
3991      a           =d         a.d           SET FEXT d
3992      a.b.c       =          a.b.c         does nothing
3993      *----------------------------------------------------------------
3994 
3995      It is not possible to use this command on pseudo files.
3996 
3997 COMPATIBILITY
3998      XEDIT: N/A
3999      KEDIT: Compatible.
4000 
4001 SEE ALSO
4002      <SET FPATH>, <SET FNAME>, <SET FEXT>, <SET FMODE>, <SET EQUIVCHAR>
4003 
4004 STATUS
4005      Complete.
4006 **man-end**********************************************************************/
4007 #ifdef HAVE_PROTO
Filename(CHARTYPE * params)4008 short Filename(CHARTYPE *params)
4009 #else
4010 short Filename(params)
4011 CHARTYPE *params;
4012 #endif
4013 /***********************************************************************/
4014 {
4015    CHARTYPE tmp_name[MAX_FILE_NAME+1];
4016    short rc=RC_OK;
4017    int i=0,cnt=0,len_params=0;
4018 
4019    TRACE_FUNCTION("commset1.c:Filename");
4020   /*
4021    * Must supply a parameter...
4022    */
4023    if ( blank_field( params ) )
4024    {
4025       display_error( 3, (CHARTYPE *)"", FALSE );
4026       TRACE_RETURN();
4027       return(RC_INVALID_OPERAND);
4028    }
4029    /*
4030     * If a pseudo file is being changed, then error...
4031     */
4032    if ( CURRENT_FILE->pseudo_file )
4033    {
4034       display_error( 8, (CHARTYPE *)"", FALSE );
4035       TRACE_RETURN();
4036       return(RC_INVALID_OPERAND);
4037    }
4038    /*
4039     * If a = is specified...
4040     */
4041    if ( equal( params, EQUIVCHARstr, 1 ) )
4042    {
4043       TRACE_RETURN();
4044       return(RC_OK);
4045    }
4046    /*
4047     * Find out how many = are specified...
4048     */
4049    len_params = strlen( (DEFCHAR*)params );
4050    for ( i = 0, cnt = 0; i < len_params; i++ )
4051    {
4052       if ( params[i] == EQUIVCHARx )
4053          cnt++;
4054    }
4055    if ( cnt > 1 )
4056    {
4057       display_error( 1, params, FALSE );
4058       TRACE_RETURN();
4059       return(RC_OK);
4060    }
4061    /*
4062     * The filename can be quoted; so strip leading and trailing
4063     * double quotes
4064     */
4065    params = MyStrip( params, STRIP_BOTH, '"' );
4066    /*
4067     * If we do have a leading or trailing = then call the equivalent
4068     * SET FEXT or FNAME command...
4069     */
4070    if ( cnt == 1 )
4071    {
4072       if ( params[0] == EQUIVCHARx)
4073       {
4074          strcpy( (DEFCHAR*)tmp_name, (DEFCHAR*)params + 1 );
4075          rc = Fext( tmp_name );
4076          TRACE_RETURN();
4077          return(rc);
4078       }
4079       else
4080       {
4081          if ( params[len_params-1] == EQUIVCHARx )
4082          {
4083             strcpy( (DEFCHAR*)tmp_name, (DEFCHAR*)params );
4084             tmp_name[len_params-1] = '\0';
4085             rc = Fname( tmp_name );
4086             TRACE_RETURN();
4087             return(rc);
4088          }
4089          else
4090          {
4091             display_error( 1, params, FALSE );
4092             TRACE_RETURN();
4093             return(rc);
4094          }
4095       }
4096    }
4097    /*
4098     * To get here, no = was in the parameter...
4099     */
4100    strcpy( (DEFCHAR *)tmp_name, (DEFCHAR *)CURRENT_FILE->fpath );
4101    strcat( (DEFCHAR *)tmp_name, (DEFCHAR *)params );
4102    if ( ( rc = splitpath( strrmdup( strtrans( tmp_name, OSLASH, ISLASH ), ISLASH, TRUE ) ) ) != RC_OK )
4103    {
4104       display_error( 10, tmp_name, FALSE );
4105       TRACE_RETURN();
4106       return(rc);
4107    }
4108    /*
4109     * If the resulting path is different to the current one, error.
4110     */
4111    if ( strcmp( (DEFCHAR *)sp_path, (DEFCHAR *)CURRENT_FILE->fpath ) != 0 )
4112    {
4113       display_error( 8, params, FALSE );
4114       TRACE_RETURN();
4115       return(RC_INVALID_OPERAND);
4116    }
4117    /*
4118     * If the file name is the same as already assigned, exit...
4119     */
4120    if ( strcmp( (DEFCHAR *)sp_fname, (DEFCHAR *)CURRENT_FILE->fname ) == 0 )
4121    {
4122       TRACE_RETURN();
4123       return(RC_OK);
4124    }
4125    /*
4126     * Check we don't already have this filename in the ring
4127     */
4128    if ( is_file_in_ring( CURRENT_FILE->fpath, sp_fname ) )
4129    {
4130       display_error( 76, tmp_name, FALSE );
4131       TRACE_RETURN();
4132       return(RC_INVALID_OPERAND);
4133    }
4134    /*
4135     * If the length of the new filename is > the existing one,
4136     * free up any memory for the existing name and allocate some
4137     * more. Save the new name.
4138     */
4139    if ( strlen( (DEFCHAR*)sp_fname ) > strlen( (DEFCHAR*)CURRENT_FILE->fname ) )
4140    {
4141       (*the_free)( CURRENT_FILE->fname );
4142       if ( ( CURRENT_FILE->fname = (CHARTYPE *)(*the_malloc)( strlen( (DEFCHAR *)sp_fname ) + 1 ) ) == NULL )
4143       {
4144          display_error( 30, (CHARTYPE *)"", FALSE );
4145          TRACE_RETURN();
4146          return(RC_OUT_OF_MEMORY);
4147       }
4148    }
4149    strcpy( (DEFCHAR *)CURRENT_FILE->fname, (DEFCHAR *)sp_fname );
4150    /*
4151     * Re-display the IDLINE
4152     */
4153    if ( display_screens > 1
4154    &&   SCREEN_FILE(current_screen) == SCREEN_FILE( (CHARTYPE)(other_screen) ) )
4155       show_heading( (CHARTYPE)(other_screen) );
4156    show_heading( current_screen );
4157    TRACE_RETURN();
4158    return(rc);
4159 }
4160 /*man-start*********************************************************************
4161 COMMAND
4162      set filetabs - determine if and where where file tabs are positioned
4163 
4164 SYNTAX
4165      [SET] FILETABS ON|OFF
4166 
4167 DESCRIPTION
4168      The SET FILETABS command allows the user to determine if file tabs
4169      are to be displayed and where. FILETABS is a single line at the
4170      top of the display showing all files currently in the ring, except
4171      the current file.
4172      It provides a mechanism where the user running THE with mouse support
4173      can simply click on the filename in the FILETABS line to change focus
4174      to that file.
4175 
4176      The colour of the file tabs can be set with <SET COLOUR> FILETABS.
4177      The colour of the file dividers can be set with <SET COLOUR> FILETABSDIV.
4178 
4179 COMPATIBILITY
4180      XEDIT: N/A
4181      KEDIT: N/A
4182 
4183 SEE ALSO
4184      <SET COLOUR>, <TABFILE>
4185 
4186 STATUS
4187      Complete.
4188 **man-end**********************************************************************/
4189 #ifdef HAVE_PROTO
THEFiletabs(CHARTYPE * params)4190 short THEFiletabs(CHARTYPE *params)
4191 #else
4192 short THEFiletabs(params)
4193 CHARTYPE *params;
4194 #endif
4195 /***********************************************************************/
4196 {
4197    short rc=RC_OK;
4198    bool save_filetabs=FILETABSx;
4199 
4200    TRACE_FUNCTION("commset1.c:THEFiletabs");
4201    rc = execute_set_on_off( params, &FILETABSx , TRUE );
4202    if ( save_filetabs != FILETABSx )
4203    {
4204       if ( FILETABSx && filetabs == (WINDOW *)NULL )
4205       {
4206          create_filetabs_window();
4207       }
4208       else if ( !FILETABSx && filetabs != (WINDOW *)NULL )
4209       {
4210          delwin( filetabs );
4211          filetabs = (WINDOW *)NULL;
4212       }
4213       /*
4214        * To get here something has changed, so rebuild the windows and
4215        * display the screen.
4216        */
4217       set_screen_defaults();
4218       if ( set_up_windows( current_screen ) != RC_OK )
4219       {
4220          TRACE_RETURN();
4221          return(RC_OK);
4222       }
4223       /*
4224        * We now have CURRENT_VIEW and real screen sizes set, we can
4225        * calculate the CURLINE value.
4226        */
4227       CURRENT_VIEW->current_row = calculate_actual_row(CURRENT_VIEW->current_base,
4228                                                        CURRENT_VIEW->current_off,
4229                                                        CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE);
4230       if ( display_screens > 1
4231       &&  SCREEN_FILE(current_screen) == SCREEN_FILE( (CHARTYPE)(other_screen) ) )
4232       {
4233          build_screen( (CHARTYPE)(other_screen) );
4234          if ( curses_started )
4235             display_screen( (CHARTYPE)(other_screen) );
4236       }
4237       build_screen( current_screen );
4238       if ( curses_started )
4239          display_screen( current_screen );
4240    }
4241    TRACE_RETURN();
4242    return(rc);
4243 }
4244 /*man-start*********************************************************************
4245 COMMAND
4246      set fmode - change the drive letter of the existing file
4247 
4248 SYNTAX
4249      [SET] FMode d[:]
4250 
4251 DESCRIPTION
4252      The SET FMode command allows the user to change the drive letter
4253      of the file currently being edited.
4254 
4255      This command is only valid under the DOS, OS/2 and Windows ports.
4256 
4257      See <SET FILENAME> for a full explanation of THE's definitions
4258      of fpath, filename, fname, fext and fmode.
4259 
4260      It is not possible to use this command on pseudo files.
4261 
4262 COMPATIBILITY
4263      XEDIT: N/A
4264      KEDIT: Compatible
4265 
4266 SEE ALSO
4267      <SET FNAME>, <SET FILENAME>, <SET FEXT>, <SET FPATH>
4268 
4269 STATUS
4270      Complete.
4271 **man-end**********************************************************************/
4272 #ifdef HAVE_PROTO
Fmode(CHARTYPE * params)4273 short Fmode(CHARTYPE *params)
4274 #else
4275 short Fmode(params)
4276 CHARTYPE *params;
4277 #endif
4278 /***********************************************************************/
4279 {
4280 #ifndef UNIX
4281    CHARTYPE tmp_name[MAX_FILE_NAME+1];
4282    int len_params=0;
4283 #endif
4284    short rc=RC_OK;
4285 
4286    TRACE_FUNCTION("commset1.c:Fmode");
4287    /*
4288     * Not valid for Unix...
4289     */
4290 #ifdef UNIX
4291    display_error( 82, (CHARTYPE *)"FMODE", FALSE );
4292    rc = RC_INVALID_OPERAND;
4293 #else
4294    /*
4295     * Must supply a parameter...
4296     */
4297    if (blank_field(params))
4298    {
4299       display_error(3,(CHARTYPE *)"",FALSE);
4300       TRACE_RETURN();
4301       return(RC_INVALID_OPERAND);
4302    }
4303    /*
4304     * If a pseudo file is being changed, then error...
4305     */
4306    if (CURRENT_FILE->pseudo_file)
4307    {
4308     display_error(8,(CHARTYPE *)"",FALSE);
4309     TRACE_RETURN();
4310     return(RC_INVALID_OPERAND);
4311    }
4312    /*
4313     * The only valid parameter is an alphabetic with an optional
4314     * ':'
4315     */
4316    len_params = strlen((DEFCHAR*)params);
4317    if ( len_params > 2
4318    ||   !isalpha(*params)
4319    ||   (len_params == 2
4320       && *params != ':') )
4321    {
4322       display_error(1,params,FALSE);
4323       TRACE_RETURN();
4324       return(RC_INVALID_OPERAND);
4325    }
4326    strcpy((DEFCHAR*)tmp_name,(DEFCHAR*)CURRENT_FILE->fpath);
4327    memcpy((DEFCHAR*)tmp_name,(DEFCHAR*)params,len_params);
4328    /*
4329     * Split the new path supplied...
4330     */
4331    if ((rc = splitpath(strrmdup(strtrans(tmp_name,OSLASH,ISLASH),ISLASH,TRUE))) != RC_OK)
4332    {
4333       display_error(10,tmp_name,FALSE);
4334       TRACE_RETURN();
4335       return(rc);
4336    }
4337    /*
4338     * If a filename results, then the path name specified would conflict
4339     * with an existing file.
4340     */
4341    if (!blank_field(sp_fname))
4342    {
4343       display_error(8,params,FALSE);
4344       TRACE_RETURN();
4345       return(RC_INVALID_OPERAND);
4346    }
4347    /*
4348     * If the path is the same as already assigned, exit...
4349     */
4350    if (strcmp((DEFCHAR *)sp_path,(DEFCHAR *)CURRENT_FILE->fpath) == 0)
4351    {
4352       TRACE_RETURN();
4353       return(RC_OK);
4354    }
4355    /*
4356     * Check we don't already have this filename in the ring
4357     */
4358    if ( is_file_in_ring( sp_path, CURRENT_FILE->fname ) )
4359    {
4360       display_error( 76, tmp_name, FALSE );
4361       TRACE_RETURN();
4362       return(RC_INVALID_OPERAND);
4363    }
4364    /*
4365     * If the length of the new path is > the existing one,
4366     * free up any memory for the existing path and allocate some
4367     * more. Save the new path.
4368     */
4369    if (strlen((DEFCHAR*)sp_path) > strlen((DEFCHAR*)CURRENT_FILE->fpath))
4370    {
4371       (*the_free)(CURRENT_FILE->fpath);
4372       if ((CURRENT_FILE->fpath = (CHARTYPE *)(*the_malloc)(strlen((DEFCHAR *)sp_path))) == NULL)
4373       {
4374          display_error(30,(CHARTYPE *)"",FALSE);
4375          TRACE_RETURN();
4376          return(RC_OUT_OF_MEMORY);
4377       }
4378    }
4379    strcpy((DEFCHAR *)CURRENT_FILE->fpath,(DEFCHAR *)sp_path);
4380    /*
4381     * Re-display the IDLINE
4382     */
4383    if (display_screens > 1
4384    &&  SCREEN_FILE(current_screen) == SCREEN_FILE( (CHARTYPE)(other_screen) ))
4385       show_heading( (CHARTYPE)(other_screen) );
4386    show_heading(current_screen);
4387 #endif
4388    TRACE_RETURN();
4389    return(rc);
4390 }
4391 /*man-start*********************************************************************
4392 COMMAND
4393      set fname - change the filename of the file being edited
4394 
4395 SYNTAX
4396      [SET] FName filename
4397 
4398 DESCRIPTION
4399      The SET FNAME command allows the user to change the fname of
4400      the file currently being edited.
4401 
4402      See <SET FILENAME> for a full explanation of THE's definitions
4403      of fpath, filename, fname, fext and fmode.
4404 
4405      A limited amount of validation of the resulting file name is
4406      carried out by this command, but some errors in the file name
4407      will not be evident until the file is saved.
4408 
4409      It is not possible to use this command on pseudo files.
4410 
4411 COMPATIBILITY
4412      XEDIT: N/A
4413      KEDIT: Compatible.
4414 
4415 SEE ALSO
4416      <SET FPATH>, <SET FILENAME>, <SET FEXT>, <SET FMODE>
4417 
4418 STATUS
4419      Complete.
4420 **man-end**********************************************************************/
4421 #ifdef HAVE_PROTO
Fname(CHARTYPE * params)4422 short Fname(CHARTYPE *params)
4423 #else
4424 short Fname(params)
4425 CHARTYPE *params;
4426 #endif
4427 /***********************************************************************/
4428 {
4429    CHARTYPE tmp_name[MAX_FILE_NAME+1];
4430    short rc=RC_OK;
4431    int last_period=0;
4432 
4433    TRACE_FUNCTION( "commset1.c:Fname" );
4434    /*
4435     * Must supply a parameter...
4436     */
4437    if ( blank_field( params ) )
4438    {
4439       display_error( 3, (CHARTYPE *)"", FALSE );
4440       TRACE_RETURN();
4441       return(RC_INVALID_OPERAND);
4442    }
4443    /*
4444     * If a pseudo file is being changed, then error...
4445     */
4446    if ( CURRENT_FILE->pseudo_file )
4447    {
4448       display_error( 8, (CHARTYPE *)"", FALSE );
4449       TRACE_RETURN();
4450       return(RC_INVALID_OPERAND);
4451    }
4452    /*
4453     * The filename can be quoted; so strip leading and trailing
4454     * double quotes
4455     */
4456    params = MyStrip( params, STRIP_BOTH, '"' );
4457    strcpy( (DEFCHAR *)tmp_name, (DEFCHAR *)CURRENT_FILE->fpath );
4458    last_period = strzreveq( CURRENT_FILE->fname, (CHARTYPE)'.' );
4459    if ( last_period == (-1) ) /* no period */
4460    {
4461       strcat( (DEFCHAR*)tmp_name, (DEFCHAR*)params );
4462    }
4463    else
4464    {
4465       int len = strlen( (DEFCHAR*)CURRENT_FILE->fpath );
4466       int lenext = strlen( (DEFCHAR*)CURRENT_FILE->fname) - last_period;
4467       strcat( (DEFCHAR*)tmp_name, (DEFCHAR*)CURRENT_FILE->fname + last_period );
4468       meminsmem( tmp_name, params, strlen( (DEFCHAR*)params), len, MAX_FILE_NAME + 1, len + lenext + 1 );
4469    }
4470    /*
4471     * Split the new path supplied...
4472     */
4473    if ( ( rc = splitpath( strrmdup( strtrans( tmp_name, OSLASH, ISLASH ), ISLASH, TRUE ) ) ) != RC_OK )
4474    {
4475       display_error( 10, tmp_name, FALSE );
4476       TRACE_RETURN();
4477       return(rc);
4478    }
4479    /*
4480     * If the resulting path is different to the current one, error.
4481     */
4482    if ( strcmp( (DEFCHAR *)sp_path, (DEFCHAR *)CURRENT_FILE->fpath ) != 0 )
4483    {
4484       display_error( 8, params, FALSE );
4485       TRACE_RETURN();
4486       return(RC_INVALID_OPERAND);
4487    }
4488    /*
4489     * If the file name is the same as already assigned, exit...
4490     */
4491    if ( strcmp( (DEFCHAR *)sp_fname, (DEFCHAR *)CURRENT_FILE->fname ) == 0 )
4492    {
4493       TRACE_RETURN();
4494       return(RC_OK);
4495    }
4496    /*
4497     * Check we don't already have this filename in the ring
4498     */
4499    if ( is_file_in_ring( CURRENT_FILE->fpath, sp_fname ) )
4500    {
4501       display_error( 76, tmp_name, FALSE );
4502       TRACE_RETURN();
4503       return(RC_INVALID_OPERAND);
4504    }
4505    /*
4506     * If the length of the new path is > the existing one,
4507     * free up any memory for the existing path and allocate some
4508     * more. Save the new path.
4509     */
4510    if ( strlen( (DEFCHAR*)sp_fname ) > strlen( (DEFCHAR*)CURRENT_FILE->fname ) )
4511    {
4512       (*the_free)( CURRENT_FILE->fname );
4513       if ( ( CURRENT_FILE->fname = (CHARTYPE *)(*the_malloc)( strlen( (DEFCHAR *)sp_fname ) ) ) == NULL )
4514       {
4515          display_error( 30, (CHARTYPE *)"", FALSE );
4516          TRACE_RETURN();
4517          return(RC_OUT_OF_MEMORY);
4518       }
4519    }
4520    strcpy( (DEFCHAR *)CURRENT_FILE->fname, (DEFCHAR *)sp_fname );
4521    /*
4522     * Re-display the IDLINE
4523     */
4524     if ( display_screens > 1
4525     &&   SCREEN_FILE(current_screen) == SCREEN_FILE( (CHARTYPE)(other_screen) ) )
4526        show_heading( (CHARTYPE)(other_screen) );
4527     show_heading( current_screen );
4528     TRACE_RETURN();
4529     return(rc);
4530 }
4531 /*man-start*********************************************************************
4532 COMMAND
4533      set fpath - change the path of the existing file
4534 
4535 SYNTAX
4536      [SET] FPath path
4537 
4538 DESCRIPTION
4539      The SET FPATH command allows the user to change the path of
4540      the file currently being edited.
4541 
4542      The 'path' parameter can be specified with or without the
4543      trailing directory separator.  Under DOS, OS/2 and Windows ports,
4544      the drive letter is considered part of the file's path.
4545 
4546      See <SET FILENAME> for a full explanation of THE's definitions
4547      of fpath, filename, fname, fext and fmode.
4548 
4549      It is not possible to use this command on pseudo files.
4550 
4551 COMPATIBILITY
4552      XEDIT: N/A
4553      KEDIT: N/A
4554 
4555 SEE ALSO
4556      <SET FNAME>, <SET FILENAME>, <SET FEXT>, <SET FMODE>
4557 
4558 STATUS
4559      Complete.
4560 **man-end**********************************************************************/
4561 #ifdef HAVE_PROTO
Fpath(CHARTYPE * params)4562 short Fpath(CHARTYPE *params)
4563 #else
4564 short Fpath(params)
4565 CHARTYPE *params;
4566 #endif
4567 /***********************************************************************/
4568 {
4569    CHARTYPE tmp_name[MAX_FILE_NAME+1];
4570    short rc=RC_OK;
4571 
4572    TRACE_FUNCTION("commset1.c:Fpath");
4573    /*
4574     * Must supply a parameter...
4575     */
4576    if ( blank_field( params ) )
4577    {
4578       display_error( 3, (CHARTYPE *)"", FALSE );
4579       TRACE_RETURN();
4580       return(RC_INVALID_OPERAND);
4581    }
4582    /*
4583     * If a pseudo file is being changed, then error...
4584     */
4585    if ( CURRENT_FILE->pseudo_file )
4586    {
4587       display_error( 8, (CHARTYPE *)"", FALSE );
4588       TRACE_RETURN();
4589       return(RC_INVALID_OPERAND);
4590    }
4591    /*
4592     * The filename can be quoted; so strip leading and trailing
4593     * double quotes
4594     */
4595    params = MyStrip( params, STRIP_BOTH, '"' );
4596    /*
4597     * Split the new path supplied...
4598     */
4599    if ( ( rc = splitpath( strrmdup( strtrans( params, OSLASH, ISLASH ), ISLASH, TRUE ) ) ) != RC_OK )
4600    {
4601       display_error( 10, params, FALSE );
4602       TRACE_RETURN();
4603       return(rc);
4604    }
4605    /*
4606     * If a filename results, then the path name specified would conflict
4607     * with an existing file.
4608     */
4609    if ( !blank_field( sp_fname ) )
4610    {
4611       display_error( 8, params, FALSE );
4612       TRACE_RETURN();
4613       return(RC_INVALID_OPERAND);
4614    }
4615    /*
4616     * If the path is the same as already assigned, exit...
4617     */
4618    if ( strcmp( (DEFCHAR *)sp_path, (DEFCHAR *)CURRENT_FILE->fpath ) == 0 )
4619    {
4620       TRACE_RETURN();
4621       return(RC_OK);
4622    }
4623    /*
4624     * Check we don't already have this filename in the ring
4625     */
4626    if ( is_file_in_ring( sp_path, CURRENT_FILE->fname ) )
4627    {
4628       sprintf( (DEFCHAR *)tmp_name, "%s%s", (CHARTYPE *)sp_path, CURRENT_FILE->fname );
4629       display_error( 76, tmp_name, FALSE );
4630       TRACE_RETURN();
4631       return(RC_INVALID_OPERAND);
4632    }
4633    /*
4634     * If the length of the new path is > the existing one,
4635     * free up any memory for the existing path and allocate some
4636     * more. Save the new path.
4637     */
4638    if ( strlen( (DEFCHAR*)sp_path) > strlen( (DEFCHAR*)CURRENT_FILE->fpath ) )
4639    {
4640       (*the_free)( CURRENT_FILE->fpath );
4641       if ( ( CURRENT_FILE->fpath = (CHARTYPE *)(*the_malloc)( strlen( (DEFCHAR *)sp_path ) ) ) == NULL )
4642       {
4643          display_error( 30, (CHARTYPE *)"", FALSE );
4644          TRACE_RETURN();
4645          return(RC_OUT_OF_MEMORY);
4646       }
4647    }
4648    strcpy( (DEFCHAR *)CURRENT_FILE->fpath, (DEFCHAR *)sp_path );
4649    /*
4650     * Re-display the IDLINE
4651     */
4652    if ( display_screens > 1
4653    &&   SCREEN_FILE( current_screen ) == SCREEN_FILE( (CHARTYPE)(other_screen) ) )
4654       show_heading( (CHARTYPE)(other_screen) );
4655    show_heading( current_screen );
4656    TRACE_RETURN();
4657    return(rc);
4658 }
4659 /*man-start*********************************************************************
4660 COMMAND
4661      set ftype - change the extension of the existing file
4662 
4663 SYNTAX
4664      [SET] FType ext
4665 
4666 DESCRIPTION
4667      The SET FTYPE is a synonym for <SET FEXT>.
4668 
4669 COMPATIBILITY
4670      XEDIT: N/A
4671      KEDIT: N/A
4672 
4673 SEE ALSO
4674      <SET FNAME>, <SET FILENAME>, <SET FEXT>, <SET FMODE>
4675 
4676 STATUS
4677      Complete.
4678 **man-end**********************************************************************/
4679 
4680 /*man-start*********************************************************************
4681 COMMAND
4682      set fullfname - specify if complete filename to be displayed
4683 
4684 SYNTAX
4685      [SET] FULLFName ON|OFF
4686 
4687 DESCRIPTION
4688      The SET FULLFNAME command allows the user to determine if the
4689      fully qualified filename is displayed on the IDLINE or just the
4690      FNAME component.
4691      See <SET FILENAME> for a full explanation of THE's definitions
4692      of fpath, filename, fname, fext and fmode.
4693 
4694 COMPATIBILITY
4695      XEDIT: N/A
4696      KEDIT: N/A
4697 
4698 DEFAULT
4699      ON
4700 
4701 STATUS
4702      Complete.
4703 **man-end**********************************************************************/
4704 #ifdef HAVE_PROTO
Fullfname(CHARTYPE * params)4705 short Fullfname(CHARTYPE *params)
4706 #else
4707 short Fullfname(params)
4708 CHARTYPE *params;
4709 #endif
4710 /***********************************************************************/
4711 {
4712     short rc=RC_OK;
4713 
4714     TRACE_FUNCTION("commset1.c:Fullfname");
4715     rc = execute_set_on_off(params,&CURRENT_FILE->display_actual_filename, TRUE );
4716     if (display_screens > 1
4717     &&  SCREEN_FILE(current_screen) == SCREEN_FILE( (CHARTYPE)(other_screen) ))
4718        show_heading( (CHARTYPE)(other_screen) );
4719     show_heading(current_screen);
4720     TRACE_RETURN();
4721     return(rc);
4722 }
4723 /*man-start*********************************************************************
4724 COMMAND
4725      set header - turn on or off syntax highlighting headers
4726 
4727 SYNTAX
4728      [SET] HEADer section ON|OFF
4729 
4730 DESCRIPTION
4731      The SET HEADER command allows fine tuning of which sections of a
4732      TLD file are to be applied for the current view.
4733 
4734      'section' refers to one of the following headers that can be specified
4735      in a TLD file:
4736      NUMBER, COMMENT, STRING, KEYWORD, FUNCTION, HEADER, LABEL, MATCH,
4737      COLUMN, POSTCOMPARE, MARKUP, DIRECTORY.
4738      'section' can also be specified as '*', in which case all headers
4739      are applied or not applied.
4740 
4741 COMPATIBILITY
4742      XEDIT: N/A
4743      KEDIT: N/A
4744 
4745 DEFAULT
4746      * ON
4747 
4748 SEE ALSO
4749      <SET PARSER>, <SET COLORING>, <SET AUTOCOLOR>
4750 
4751 STATUS
4752      Complete.
4753 **man-end**********************************************************************/
4754 #ifdef HAVE_PROTO
THEHeader(CHARTYPE * params)4755 short THEHeader(CHARTYPE *params)
4756 #else
4757 short THEHeader(params)
4758 CHARTYPE *params;
4759 #endif
4760 /***********************************************************************/
4761 {
4762    short rc=RC_OK;
4763 #define HEA_PARAMS  2
4764    CHARTYPE *word[HEA_PARAMS+1];
4765    CHARTYPE strip[HEA_PARAMS];
4766    short num_params=0;
4767    LINETYPE save_syntax_headers=CURRENT_VIEW->syntax_headers,val=0;
4768    bool on_or_off;
4769    int i;
4770 
4771    TRACE_FUNCTION("commset1.c:THEHeader");
4772    strip[0]=STRIP_BOTH;
4773    strip[1]=STRIP_BOTH;
4774    num_params = param_split(params,word,HEA_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
4775    if (num_params < 1)
4776    {
4777       display_error(3,(CHARTYPE *)"",FALSE);
4778       TRACE_RETURN();
4779       return(RC_INVALID_OPERAND);
4780    }
4781    /*
4782     * Validate first parameter...
4783     */
4784    for ( i = 0; thm[i].the_header_name != NULL; i++ )
4785    {
4786       if (equal((CHARTYPE *)thm[i].the_header_name,word[0],thm[i].the_header_name_len))
4787       {
4788          val = thm[i].the_header;
4789          break;
4790       }
4791    }
4792    if ( val == 0 )
4793    {
4794       display_error(1,word[0],FALSE);
4795       TRACE_RETURN();
4796       return(RC_INVALID_OPERAND);
4797    }
4798 
4799    rc = execute_set_on_off(word[1],&on_or_off, TRUE );
4800    if ( rc != RC_OK )
4801    {
4802       TRACE_RETURN();
4803       return(rc);
4804    }
4805 
4806    /*
4807     * Have a valid header, and a valid ON|OFF...
4808     */
4809    if ( on_or_off )
4810       CURRENT_VIEW->syntax_headers |= val;
4811    else
4812       CURRENT_VIEW->syntax_headers &= ~val;
4813 
4814    if ( CURRENT_VIEW->syntax_headers != save_syntax_headers )
4815    {
4816       build_screen(current_screen);
4817       display_screen(current_screen);
4818    }
4819 
4820    TRACE_RETURN();
4821    return(rc);
4822 }
4823 /*man-start*********************************************************************
4824 COMMAND
4825      set hex - set how hexadecimal strings are treated in string operands
4826 
4827 SYNTAX
4828      [SET] HEX ON|OFF
4829 
4830 DESCRIPTION
4831      The SET HEX set command determines whether hexadecimal strings are
4832      treated as such in string operands.
4833 
4834      With the 'ON' option, any string operand of the form
4835         /x'31 32 33'/ or
4836         /d'49 50 51'/
4837      will be converted to /123/ before the command is executed.
4838 
4839      With the 'OFF' option, no conversion is done.
4840 
4841      This conversion should work wherever a string operand is used
4842      in any command.
4843 
4844 COMPATIBILITY
4845      XEDIT: Adds support for decimal representation. See below.
4846      KEDIT: Compatible. See below.
4847      Spaces must separate each character representation.
4848 
4849 DEFAULT
4850      OFF
4851 
4852 STATUS
4853      Complete.
4854 **man-end**********************************************************************/
4855 #ifdef HAVE_PROTO
Hex(CHARTYPE * params)4856 short Hex(CHARTYPE *params)
4857 #else
4858 short Hex(params)
4859 CHARTYPE *params;
4860 #endif
4861 /***********************************************************************/
4862 {
4863    short rc=RC_OK;
4864 
4865    TRACE_FUNCTION("commset1.c:Hex");
4866    rc = execute_set_on_off(params,&CURRENT_VIEW->hex, TRUE );
4867    TRACE_RETURN();
4868    return(rc);
4869 }
4870 /*man-start*********************************************************************
4871 COMMAND
4872      set hexdisplay - turn on or off display of character under cursor
4873 
4874 SYNTAX
4875      [SET] HEXDISPlay ON|OFF
4876 
4877 DESCRIPTION
4878      The SET HEXDISPLAY command turns on or off the display of the
4879      character under the cursor on the <status line>.
4880 
4881 COMPATIBILITY
4882      XEDIT: N/A
4883      KEDIT: Compatible.
4884 
4885 DEFAULT
4886      ON
4887 
4888 STATUS
4889      Complete
4890 **man-end**********************************************************************/
4891 #ifdef HAVE_PROTO
Hexdisplay(CHARTYPE * params)4892 short Hexdisplay(CHARTYPE *params)
4893 #else
4894 short Hexdisplay(params)
4895 CHARTYPE *params;
4896 #endif
4897 /***********************************************************************/
4898 {
4899    short rc=RC_OK;
4900 
4901    TRACE_FUNCTION("commset1.c:Hexdisplay");
4902    rc = execute_set_on_off(params,&HEXDISPLAYx, TRUE );
4903    if (rc == RC_OK
4904    &&  curses_started)
4905       clear_statarea();
4906    TRACE_RETURN();
4907    return(rc);
4908 }
4909 /*man-start*********************************************************************
4910 COMMAND
4911      set hexshow - turn on or off hex display of current line
4912 
4913 SYNTAX
4914      [SET] HEXShow ON|OFF [M[+n|-n]|[+|-]n]
4915 
4916 DESCRIPTION
4917      The SET HEXShow command indicates if and where a hexadecimal
4918      representation of the <current line> will be displayed.
4919 
4920      The first form of parameters is:
4921 
4922      M[+n|-n]
4923      this sets the hexshow line to be relative to the middle of
4924      the screen. A positive value adds to the middle line number,
4925      a negative subtracts from it.
4926      e.g. M+3 on a 24 line screen will be line 15
4927          M-5 on a 24 line screen will be line 7
4928 
4929      The second form of parameters is:
4930 
4931      [+|-]n
4932      this sets the hexshow line to be relative to the top of the
4933      screen (if positive or no sign) or relative to the bottom
4934      of the screen if negative.
4935      e.g. +3 or 3 will set current line to line 3
4936          -3 on a 24 line screen will be line 21
4937 
4938      If the resulting line is outside the bounds of the screen
4939      the position of the hexshow line will become the middle line
4940      on the screen.
4941 
4942      The position argument specifies the position of the first line
4943      of the hexadecimal display.
4944 
4945      It is an error to try to position the HEXSHOW lines on the same
4946      line as <SET CURLINE>.
4947 
4948 COMPATIBILITY
4949      XEDIT: N/A
4950      KEDIT: N/A
4951 
4952 DEFAULT
4953      OFF 7
4954 
4955 STATUS
4956      Complete
4957 **man-end**********************************************************************/
4958 #ifdef HAVE_PROTO
Hexshow(CHARTYPE * params)4959 short Hexshow(CHARTYPE *params)
4960 #else
4961 short Hexshow(params)
4962 CHARTYPE *params;
4963 #endif
4964 /***********************************************************************/
4965 {
4966 #define HEXS_PARAMS  2
4967    CHARTYPE *word[HEXS_PARAMS+1];
4968    CHARTYPE strip[HEXS_PARAMS];
4969    short num_params=0;
4970    short rc=RC_OK;
4971    short base=CURRENT_VIEW->hexshow_base;
4972    short off=CURRENT_VIEW->hexshow_off;
4973    bool hexshowsts=FALSE;
4974 
4975    TRACE_FUNCTION("commset1.c:Hexshow");
4976    strip[0]=STRIP_BOTH;
4977    strip[1]=STRIP_BOTH;
4978    num_params = param_split(params,word,HEXS_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
4979    if (num_params < 1)
4980    {
4981       display_error(3,(CHARTYPE *)"",FALSE);
4982       TRACE_RETURN();
4983       return(RC_INVALID_OPERAND);
4984    }
4985    /*
4986     * Parse the status parameter...
4987     */
4988    rc = execute_set_on_off(word[0],&hexshowsts, TRUE );
4989    if (rc != RC_OK)
4990    {
4991       TRACE_RETURN();
4992       return(rc);
4993    }
4994    /*
4995     * Parse the position parameter...
4996     */
4997    if (num_params > 1)
4998    {
4999       rc = execute_set_row_position(word[1],&base,&off);
5000       if (rc != RC_OK)
5001       {
5002          TRACE_RETURN();
5003          return(rc);
5004       }
5005    }
5006    /*
5007     * If the HEXSHOW row (or the next row) is the same row as CURLINE and
5008     * it is being turned on, return ERROR.
5009     */
5010    if ( ( calculate_actual_row( CURRENT_VIEW->current_base,
5011                                 CURRENT_VIEW->current_off,
5012                                 CURRENT_SCREEN.rows[WINDOW_FILEAREA], TRUE ) ==
5013           calculate_actual_row( base, off, CURRENT_SCREEN.rows[WINDOW_FILEAREA], TRUE )
5014        || calculate_actual_row( CURRENT_VIEW->current_base,
5015                                 CURRENT_VIEW->current_off,
5016                                 CURRENT_SCREEN.rows[WINDOW_FILEAREA], TRUE ) ==
5017           calculate_actual_row( base, off, CURRENT_SCREEN.rows[WINDOW_FILEAREA], TRUE ) + 1 )
5018    && hexshowsts )
5019    {
5020       display_error(64,(CHARTYPE *)"- same line as CURLINE",FALSE);
5021       TRACE_RETURN();
5022       return(RC_INVALID_ENVIRON);
5023    }
5024    CURRENT_VIEW->hexshow_base = base;
5025    CURRENT_VIEW->hexshow_off = off;
5026    CURRENT_VIEW->hexshow_on = hexshowsts;
5027    post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
5028    build_screen(current_screen);
5029    display_screen(current_screen);
5030    TRACE_RETURN();
5031    return(rc);
5032 }
5033 /*man-start*********************************************************************
5034 COMMAND
5035      set highlight - specify which lines (if any) are to be highlighted
5036 
5037 SYNTAX
5038      [SET] HIGHlight OFF|TAGged|ALTered|SELect n [m]
5039 
5040 DESCRIPTION
5041      The SET HIGHLIGHT command allows for the user to specify which
5042      lines are to be displayed in the highlighted colour.
5043 
5044      'OFF' turns all highlighting display off
5045 
5046      'TAGGED' displays all tagged lines in the highlight colour.
5047 
5048      'ALTERED' displays all lines that have been added or
5049      changed in the current session in the highlight colour.
5050 
5051      'SELECT n [m]' displays all lines with the specified selection
5052      level in highlight colour.
5053 
5054 
5055 COMPATIBILITY
5056      XEDIT: N/A
5057      KEDIT: Compatible
5058 
5059 DEFAULT
5060      OFF
5061 
5062 SEE ALSO
5063      <SET SELECT>, <TAG>, <SET LINEFLAG>
5064 
5065 STATUS
5066      Ccomplete.
5067 **man-end**********************************************************************/
5068 #ifdef HAVE_PROTO
Highlight(CHARTYPE * params)5069 short Highlight(CHARTYPE *params)
5070 #else
5071 short Highlight(params)
5072 CHARTYPE *params;
5073 #endif
5074 /***********************************************************************/
5075 {
5076 #define HIGH_PARAMS  2
5077    CHARTYPE *word[HIGH_PARAMS+1];
5078    CHARTYPE strip[HIGH_PARAMS];
5079    short num_params=0;
5080    short col1=0,col2=0;
5081    short rc=RC_OK;
5082 
5083    TRACE_FUNCTION("commset1.c:Highlight");
5084    strip[0]=STRIP_BOTH;
5085    strip[1]=STRIP_BOTH;
5086    num_params = param_split(params,word,HIGH_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
5087    if (num_params < 1)
5088    {
5089       display_error(3,(CHARTYPE *)"",FALSE);
5090       TRACE_RETURN();
5091       return(RC_INVALID_OPERAND);
5092    }
5093    switch (num_params)
5094    {
5095       case 1:
5096          if (equal((CHARTYPE *)"off",word[0],3))
5097          {
5098             CURRENT_VIEW->highlight = HIGHLIGHT_NONE;
5099             break;
5100          }
5101          if (equal((CHARTYPE *)"tagged",word[0],3))
5102          {
5103             CURRENT_VIEW->highlight = HIGHLIGHT_TAG;
5104             break;
5105          }
5106          if (equal((CHARTYPE *)"altered",word[0],3))
5107          {
5108             CURRENT_VIEW->highlight = HIGHLIGHT_ALT;
5109             break;
5110          }
5111          display_error(1,word[0],FALSE);
5112          rc = RC_INVALID_OPERAND;
5113          break;
5114       case 2:
5115       case 3:
5116          if (!equal((CHARTYPE *)"select",word[0],3))
5117          {
5118             display_error(1,word[0],FALSE);
5119             TRACE_RETURN();
5120             return(RC_INVALID_OPERAND);
5121          }
5122          if ((rc = validate_n_m(word[1],&col1,&col2)) != RC_OK)
5123          {
5124             TRACE_RETURN();
5125             return(rc);
5126          }
5127          CURRENT_VIEW->highlight = HIGHLIGHT_SELECT;
5128          CURRENT_VIEW->highlight_low = col1;
5129          CURRENT_VIEW->highlight_high = col2;
5130          break;
5131       default:
5132          display_error(1,word[0],FALSE);
5133          rc = RC_INVALID_OPERAND;
5134          break;
5135   }
5136    if (rc == RC_OK)
5137    {
5138       build_screen(current_screen);
5139       display_screen(current_screen);
5140    }
5141    TRACE_RETURN();
5142    return(rc);
5143 }
5144 /*man-start*********************************************************************
5145 COMMAND
5146      set idline - specify if IDLINE is displayed
5147 
5148 SYNTAX
5149      [SET] IDline ON|OFF
5150 
5151 DESCRIPTION
5152      The SET IDLINE set command determines if the <idline> for a file is
5153      displayed or not.
5154 
5155 COMPATIBILITY
5156      XEDIT: N/A
5157      KEDIT: Compatible.
5158 
5159 DEFAULT
5160      ON
5161 
5162 STATUS
5163      Complete
5164 **man-end**********************************************************************/
5165 #ifdef HAVE_PROTO
Idline(CHARTYPE * params)5166 short Idline(CHARTYPE *params)
5167 #else
5168 short Idline(params)
5169 CHARTYPE *params;
5170 #endif
5171 /***********************************************************************/
5172 {
5173    short rc=RC_OK;
5174    bool save_id_line=FALSE;
5175 
5176    TRACE_FUNCTION("commset1.c:Idline");
5177    save_id_line = CURRENT_VIEW->id_line;
5178    rc = execute_set_on_off(params,&CURRENT_VIEW->id_line, TRUE );
5179    if (rc != RC_OK)
5180    {
5181       TRACE_RETURN();
5182       return(rc);
5183    }
5184    /*
5185     * If the new value of id_line is the same as before, exit now.
5186     */
5187    if (save_id_line == CURRENT_VIEW->id_line)
5188    {
5189       TRACE_RETURN();
5190       return(rc);
5191    }
5192    /*
5193     * Redefine the screen sizes...
5194     */
5195    set_screen_defaults();
5196    /*
5197     * Recreate windows for the current screen...
5198     */
5199    if (curses_started)
5200    {
5201       if (set_up_windows(current_screen) != RC_OK)
5202       {
5203          TRACE_RETURN();
5204          return(rc);
5205       }
5206    }
5207    build_screen(current_screen);
5208    display_screen(current_screen);
5209    TRACE_RETURN();
5210    return(rc);
5211 }
5212 /*man-start*********************************************************************
5213 COMMAND
5214      set impcmscp - set implied operating system command processing
5215 
5216 SYNTAX
5217      [SET] IMPcmscp ON|OFF
5218 
5219 DESCRIPTION
5220      The SET IMPCMSCP command is used to set implied operating system
5221      command processing from the command line. By turning this feature
5222      on you can then issue an operating system command without the need
5223      to prefix the operating system command with the <OS> command.
5224 
5225 COMPATIBILITY
5226      XEDIT: Compatible.
5227      KEDIT: N/A
5228 
5229 DEFAULT
5230      ON
5231 
5232 SEE ALSO
5233      <SET IMPOS>
5234 
5235 STATUS
5236      Complete.
5237 **man-end**********************************************************************/
5238 
5239 /*man-start*********************************************************************
5240 COMMAND
5241      set impmacro - set implied macro command processing
5242 
5243 SYNTAX
5244      [SET] IMPMACro ON|OFF
5245 
5246 DESCRIPTION
5247      The SET IMPMACRO command is used to set implied macro processing
5248      from the command line. By turning this feature on you can then
5249      issue a <macro> command without the need to prefix the macro name
5250      with the <MACRO> command.
5251 
5252 COMPATIBILITY
5253      XEDIT: N/A
5254      KEDIT: Compatible.
5255 
5256 DEFAULT
5257      ON
5258 
5259 SEE ALSO
5260      <MACRO>, <SET MACROPATH>
5261 
5262 STATUS
5263      Complete.
5264 **man-end**********************************************************************/
5265 #ifdef HAVE_PROTO
Impmacro(CHARTYPE * params)5266 short Impmacro(CHARTYPE *params)
5267 #else
5268 short Impmacro(params)
5269 CHARTYPE *params;
5270 #endif
5271 /***********************************************************************/
5272 {
5273    short rc=RC_OK;
5274 
5275    TRACE_FUNCTION("commset1.c:Impmacro");
5276    rc = execute_set_on_off(params,&CURRENT_VIEW->imp_macro, TRUE );
5277    TRACE_RETURN();
5278    return(rc);
5279 }
5280 /*man-start*********************************************************************
5281 COMMAND
5282      set impos - set implied operating system command processing
5283 
5284 SYNTAX
5285      [SET] IMPOS ON|OFF
5286 
5287 DESCRIPTION
5288      The SET IMPOS command is used to set implied operating system
5289      command processing from the command line. By turning this feature
5290      on you can then issue an operating system command without the need
5291      to prefix the operating system command with the <OS> command.
5292 
5293 COMPATIBILITY
5294      XEDIT: Compatible.
5295      KEDIT: N/A
5296 
5297 DEFAULT
5298      ON
5299 
5300 SEE ALSO
5301      <SET IMPCMSCP>
5302 
5303 STATUS
5304      Complete.
5305 **man-end**********************************************************************/
5306 #ifdef HAVE_PROTO
Impos(CHARTYPE * params)5307 short Impos(CHARTYPE *params)
5308 #else
5309 short Impos(params)
5310 CHARTYPE *params;
5311 #endif
5312 /***********************************************************************/
5313 {
5314    short rc=RC_OK;
5315 
5316    TRACE_FUNCTION("commset1.c:Impos");
5317    rc = execute_set_on_off(params,&CURRENT_VIEW->imp_os, TRUE );
5318    TRACE_RETURN();
5319    return(rc);
5320 }
5321 /*man-start*********************************************************************
5322 COMMAND
5323      set inputmode - set input mode behaviour
5324 
5325 SYNTAX
5326      [SET] INPUTMode OFF|FUll|LIne
5327 
5328 DESCRIPTION
5329      The SET INPUTMODE command changes the way THE handles input.
5330 
5331      When INPUTMODE LINE is in effect, pressing the ENTER key while
5332      in the <filearea> will result in a new line being added.
5333 
5334      When INPUTMODE OFF is in effect, pressing the ENTER key while
5335      in the <filearea> will result in the cursor moving to the
5336      beginning of the next line; scrolling the screen if necessary.
5337 
5338      When INPUTMODE FULL is in effect, pressing the ENTER key while
5339      in the <filearea> will result in the cursor moving to the
5340      beginning of the next line; scrolling the screen if necessary.
5341 
5342 
5343 COMPATIBILITY
5344      XEDIT: N/A
5345      KEDIT: Compatible.
5346 
5347 DEFAULT
5348      LINE
5349 
5350 SEE ALSO
5351      <INPUT>
5352 
5353 STATUS
5354      Incomplete. No support for FULL option.
5355 **man-end**********************************************************************/
5356 #ifdef HAVE_PROTO
Inputmode(CHARTYPE * params)5357 short Inputmode(CHARTYPE *params)
5358 #else
5359 short Inputmode(params)
5360 CHARTYPE *params;
5361 #endif
5362 /***********************************************************************/
5363 {
5364    TRACE_FUNCTION( "commset1.c:Inputmode" );
5365    params = MyStrip( params, STRIP_BOTH, ' ' );
5366    if ( equal( (CHARTYPE *)"off", params, 3 ) )
5367       CURRENT_VIEW->inputmode = INPUTMODE_OFF;
5368    else if ( equal( (CHARTYPE *)"full", params, 2 ) )
5369       CURRENT_VIEW->inputmode = INPUTMODE_FULL;
5370    else if ( equal( (CHARTYPE *)"line", params, 2 ) )
5371       CURRENT_VIEW->inputmode = INPUTMODE_LINE;
5372    else
5373    {
5374       display_error( 1, (CHARTYPE *)params, FALSE );
5375       TRACE_RETURN();
5376       return(RC_INVALID_OPERAND);
5377    }
5378    TRACE_RETURN();
5379    return(RC_OK);
5380 }
5381 /*man-start*********************************************************************
5382 COMMAND
5383      set insertmode - put editor into or out of insert mode
5384 
5385 SYNTAX
5386      [SET] INSERTMode ON|OFF|TOGGLE
5387 
5388 DESCRIPTION
5389      The SET INSERTMODE command enable the user to set the insert mode
5390      within THE.
5391 
5392      The 'TOGGLE' option turns insert mode 'ON' if it is currently
5393      'OFF' and vice versa.
5394 
5395 COMPATIBILITY
5396      XEDIT: N/A
5397      KEDIT: Compatible.
5398 
5399 DEFAULT
5400      OFF
5401 
5402 STATUS
5403      Complete.
5404 **man-end**********************************************************************/
5405 #ifdef HAVE_PROTO
Insertmode(CHARTYPE * params)5406 short Insertmode(CHARTYPE *params)
5407 #else
5408 short Insertmode(params)
5409 CHARTYPE *params;
5410 #endif
5411 /***********************************************************************/
5412 {
5413    TRACE_FUNCTION("commset1.c:Insertmode");
5414    params = MyStrip( params, STRIP_BOTH, ' ' );
5415    if ( equal( (CHARTYPE *)"off", params, 3 ) )
5416       INSERTMODEx = FALSE;
5417    else if ( equal( (CHARTYPE *)"on", params, 2 ) )
5418       INSERTMODEx = TRUE;
5419    else if ( equal( (CHARTYPE *)"toggle", params, 6 ) )
5420       INSERTMODEx = (INSERTMODEx) ? FALSE : TRUE;
5421    else
5422    {
5423       display_error(1,(CHARTYPE *)params,FALSE);
5424       TRACE_RETURN();
5425       return(RC_INVALID_OPERAND);
5426    }
5427    if (curses_started)
5428       draw_cursor(TRUE);
5429    TRACE_RETURN();
5430    return(RC_OK);
5431 }
5432 /*man-start*********************************************************************
5433 COMMAND
5434      set interface - set overall behaviour of THE
5435 
5436 SYNTAX
5437      [SET] INTerface CLASSIC|CUA
5438 
5439 DESCRIPTION
5440      The SET INTERFACE command changes the behaviour of several operations
5441      within THE.  THE normally operates in a block-mode manner, however
5442      many applications conform to the Common User Access (CUA) standard
5443      developed by IBM.  This command specifies that CUA behaviour should
5444      occur on various actions during the edit session.
5445 
5446      The major differences between CLASSIC and CUA behaviour involve
5447      keyboard and mouse actions. Various THE commands have CUA options to
5448      allow the user to customise the behaviour individual keys or the
5449      mouse to behave in a CUA manner.
5450 
5451      Where behaviour is not related to particular key or mouse actions,
5452      this command provides the mechanism for changing the behaviour.
5453      The behaviour that SET INTERFACE affects:
5454 
5455      - entering text in the filearea with a marked CUA block will
5456        first delete the block and reposition the cursor
5457      - executing <SOS DELCHAR> or <SOS DELBACK> will delete the
5458        marked CUA block
5459      - executing any positioning command, such as <CURSOR> DOWN,
5460        <FORWARD> or <CURSOR> MOUSE, will unmark the CUA block
5461 
5462 COMPATIBILITY
5463      XEDIT: N/A
5464      KEDIT: Compatible with KEDIT for Windows.
5465 
5466 DEFAULT
5467      CLASSIC
5468 
5469 SEE ALSO
5470      <MARK> <CURSOR>
5471 
5472 STATUS
5473      Complete.
5474 **man-end**********************************************************************/
5475 #ifdef HAVE_PROTO
THEInterface(CHARTYPE * params)5476 short THEInterface(CHARTYPE *params)
5477 #else
5478 short THEInterface(params)
5479 CHARTYPE *params;
5480 #endif
5481 /***********************************************************************/
5482 {
5483    short rc=RC_OK;
5484 
5485    TRACE_FUNCTION("commset1.c:THEInterface");
5486 
5487    params = MyStrip( params, STRIP_BOTH, ' ' );
5488    if ( equal( (CHARTYPE *)"classic", params, 7 ) )
5489       INTERFACEx = INTERFACE_CLASSIC;
5490    else if ( equal( (CHARTYPE *)"cua", params, 3 ) )
5491       INTERFACEx = INTERFACE_CUA;
5492    else
5493    {
5494       display_error( 3, (CHARTYPE *)"", FALSE );
5495       rc = RC_INVALID_OPERAND;
5496    }
5497    TRACE_RETURN();
5498    return(rc);
5499 }
5500 /*man-start*********************************************************************
5501 COMMAND
5502      set lastop - set the contents of the lastop argument
5503 
5504 SYNTAX
5505      [SET] LASTOP operand text
5506 
5507 DESCRIPTION
5508      The SET LASTOP command sets the values of the specified 'operand' to the
5509      'text' supplied. This command is most useful when run from a macro, to
5510      set the string to be passed to the next invocation of the equivalent
5511      'operand' command; eg LOCATE, FIND, etc.
5512 
5513      Because THE does not save the contents of the lastop from a command when
5514      run from a macro, sometimes the macro is intended to set this value. This
5515      command allows that capability.
5516 
5517 COMPATIBILITY
5518      XEDIT: N/A
5519      KEDIT: Compatible.
5520 
5521 SEE ALSO
5522      <LOCATE>, <FIND>, <SEARCH>
5523 
5524 STATUS
5525      Complete.
5526 **man-end**********************************************************************/
5527 #ifdef HAVE_PROTO
Lastop(CHARTYPE * params)5528 short Lastop(CHARTYPE *params)
5529 #else
5530 short Lastop(params)
5531 CHARTYPE *params;
5532 #endif
5533 /***********************************************************************/
5534 {
5535 #define LOP_PARAMS  2
5536    CHARTYPE *word[LOP_PARAMS+1];
5537    CHARTYPE strip[LOP_PARAMS];
5538    unsigned short num_params=0;
5539    bool found=FALSE;
5540    CHARTYPE *ptr_lastop;
5541    int i;
5542    short rc=RC_OK;
5543 
5544    TRACE_FUNCTION( "commset1.c:Lastop" );
5545    strip[0]=STRIP_BOTH;
5546    strip[1]=STRIP_BOTH;
5547    num_params = param_split( params, word, LOP_PARAMS, WORD_DELIMS, TEMP_PARAM, strip, FALSE );
5548    if ( num_params < 2 )
5549    {
5550       display_error( 3, (CHARTYPE *)"", FALSE );
5551       TRACE_RETURN();
5552       return RC_INVALID_OPERAND;
5553    }
5554    else if ( num_params > 2 )
5555    {
5556       display_error( 2, (CHARTYPE *)"", FALSE );
5557       TRACE_RETURN();
5558       return RC_INVALID_OPERAND;
5559    }
5560    /*
5561     * Find a match for the supplied lastop operand
5562     */
5563    for ( i = 0; i < LASTOP_MAX; i++ )
5564    {
5565       if ( equal( lastop[i].command, word[0], lastop[i].min_len ) )
5566       {
5567          ptr_lastop = lastop[i].value;
5568          found = TRUE;
5569          break;
5570       }
5571    }
5572    if ( !found )
5573    {
5574       display_error(1,word[0],FALSE);
5575       rc = RC_INVALID_OPERAND;
5576    }
5577    else
5578    {
5579       rc = save_lastop( i, word[1] );
5580       if ( rc != RC_OK )
5581       {
5582          display_error( 30, (CHARTYPE *)"", FALSE );
5583          rc = RC_OUT_OF_MEMORY;
5584       }
5585    }
5586    TRACE_RETURN();
5587    return(rc);
5588 }
5589 
5590 /*man-start*********************************************************************
5591 COMMAND
5592      set lineflag - set the line characteristics of lines
5593 
5594 SYNTAX
5595      [SET] LINEFLAG CHAnge|NOCHange NEW|NONEW TAG|NOTAG [target]
5596 
5597 DESCRIPTION
5598      The SET LINEFLAGS command controls the line characteristics of lines
5599      in a file.
5600 
5601      Each line in a file has certain characteristics associated with it
5602      depending on how the line has been modified.  On reading a file from
5603      disk, all lines in the file are set to their default values.
5604 
5605      Once a line is modified, or tagged, the characteristics of the line
5606      are set appropriately.  A line that is added, is set to NEW; a line
5607      that is changed is set to CHANGE, and a line that is tagged with the
5608      <TAG> command, is set to TAG.  All three characteristics can be on
5609      at the one time.
5610 
5611 COMPATIBILITY
5612      XEDIT: N/A
5613      KEDIT: Compatible.
5614 
5615 DEFAULT
5616      NOCHANGE NONEW NOTAG
5617 
5618 SEE ALSO
5619      <TAG>, <SET HIGHLIGHT>
5620 
5621 STATUS
5622      Complete.
5623 **man-end**********************************************************************/
5624 #ifdef HAVE_PROTO
Lineflag(CHARTYPE * params)5625 short Lineflag(CHARTYPE *params)
5626 #else
5627 short Lineflag(params)
5628 CHARTYPE *params;
5629 #endif
5630 /***********************************************************************/
5631 {
5632 #define LF_PARAMS  4
5633    CHARTYPE *word[LF_PARAMS+1];
5634    CHARTYPE strip[LF_PARAMS];
5635    LINETYPE num_lines=0L,true_line=0L;
5636    CHARTYPE *save_params;
5637    short num_params=0,num_flags;
5638    short rc=RC_OK;
5639    long target_type=TARGET_NORMAL|TARGET_BLOCK_CURRENT|TARGET_ALL;
5640    long save_target_type=TARGET_UNFOUND;
5641    TARGET target;
5642    bool num_lines_based_on_scope=FALSE,no_flag=FALSE;
5643    unsigned int new_flag=2;
5644    unsigned int changed_flag=2;
5645    unsigned int tag_flag=2;
5646    int i,j;
5647 
5648    TRACE_FUNCTION("comm4.c:   Lineflag");
5649    save_params = my_strdup( params );
5650    if ( save_params == NULL )
5651    {
5652       display_error(30,(CHARTYPE *)"",FALSE);
5653       TRACE_RETURN();
5654       return(RC_OUT_OF_MEMORY);
5655    }
5656 
5657    strip[0]=STRIP_BOTH;
5658    strip[1]=STRIP_BOTH;
5659    strip[2]=STRIP_BOTH;
5660    strip[3]=STRIP_NONE;
5661    num_params = param_split(params,word,LF_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
5662    if (num_params == 0)                                     /* no params */
5663    {
5664       display_error(3,(CHARTYPE *)"",FALSE);
5665       (*the_free)( save_params );
5666       TRACE_RETURN();
5667       return(RC_INVALID_OPERAND);
5668    }
5669    for (i = 0; i < num_params; i++)
5670    {
5671       if (!equal((CHARTYPE *)"change",word[i],3)
5672       &&  !equal((CHARTYPE *)"nochange",word[i],4)
5673       &&  !equal((CHARTYPE *)"new",word[i],3)
5674       &&  !equal((CHARTYPE *)"nonew",word[i],5)
5675       &&  !equal((CHARTYPE *)"tag",word[i],3)
5676       &&  !equal((CHARTYPE *)"notag",word[i],5))
5677       {
5678          no_flag = TRUE;
5679          break;
5680       }
5681    }
5682    /*
5683     * If we broke out of the above loop the first time, then
5684     * there are no valid flags specified
5685     */
5686    if ( i == 0 )
5687    {
5688       display_error(3,(CHARTYPE *)"",FALSE);
5689       (*the_free)( save_params );
5690       TRACE_RETURN();
5691       return(RC_INVALID_OPERAND);
5692    }
5693    /*
5694     * If no_flag is set to FALSE, all parameters are flags; therefore
5695     * the target will be 1
5696     */
5697    if ( no_flag == FALSE )
5698    {
5699       num_lines = 1L;
5700       true_line = get_true_line(TRUE);
5701       num_lines_based_on_scope = TRUE;
5702       num_flags = num_params;
5703    }
5704    else
5705    {
5706       if ( i+1 != num_params )
5707       {
5708          for ( j = 0; j < i; j++ )
5709          {
5710             strip[0]=STRIP_BOTH;
5711          }
5712          strip[i]=STRIP_NONE;
5713          num_params = param_split( params, word, i + 1, WORD_DELIMS, TEMP_PARAM, strip, FALSE );
5714       }
5715       initialise_target(&target);
5716       if  ( ( rc = validate_target( word[num_params-1], &target, target_type, get_true_line(TRUE), TRUE, TRUE ) ) != RC_OK )
5717       {
5718          free_target( &target );
5719          (*the_free)( save_params );
5720          TRACE_RETURN();
5721          return(rc);
5722       }
5723       switch ( target.rt[0].target_type )
5724       {
5725          case TARGET_BLOCK_CURRENT:
5726             switch( MARK_VIEW->mark_type )
5727             {
5728                case M_STREAM:
5729                case M_WORD:
5730                case M_COLUMN:
5731                   display_error(49,(CHARTYPE*)"",FALSE);
5732                   free_target(&target);
5733                   (*the_free)( save_params );
5734                   TRACE_RETURN();
5735                   return(RC_INVALID_OPERAND);
5736                   break;
5737                case M_BOX:
5738                   display_error(48,(CHARTYPE*)"",FALSE);
5739                   free_target(&target);
5740                   (*the_free)( save_params );
5741                   TRACE_RETURN();
5742                   return(RC_INVALID_OPERAND);
5743                   break;
5744                default:
5745                   break;
5746             }
5747             break;
5748          case TARGET_BLOCK_ANY:
5749             display_error(45,(CHARTYPE*)"",FALSE);
5750             free_target(&target);
5751             (*the_free)( save_params );
5752             TRACE_RETURN();
5753             return(RC_INVALID_OPERAND);
5754             break;
5755          default:
5756             break;
5757       }
5758       num_lines = target.num_lines;
5759       true_line = target.true_line;
5760       save_target_type = target.rt[0].target_type;
5761       num_lines_based_on_scope = (save_target_type == TARGET_BLOCK_CURRENT) ? FALSE : TRUE;
5762       free_target(&target);
5763       num_flags = num_params-1;
5764    }
5765    for ( i = 0; i < num_flags; i++ )
5766    {
5767       if ( equal( (CHARTYPE *)"change", word[i], 3 ) )
5768          changed_flag = 1;
5769       else if ( equal( (CHARTYPE *)"nochange", word[i], 4 ) )
5770          changed_flag = 0;
5771       else if ( equal( (CHARTYPE *)"new", word[i], 3 ) )
5772          new_flag = 1;
5773       else if ( equal( (CHARTYPE *)"nonew", word[i], 5 ) )
5774          new_flag = 0;
5775       else if ( equal( (CHARTYPE *)"tag", word[i], 3 ) )
5776          tag_flag = 1;
5777       else if ( equal( (CHARTYPE *)"notag", word[i], 5 ) )
5778          tag_flag = 0;
5779       else
5780          ;
5781    }
5782    /*
5783     * Now we are here, everything's OK, do the actual modification...
5784     */
5785    rc = execute_set_lineflag( new_flag, changed_flag, tag_flag, true_line, num_lines, num_lines_based_on_scope, save_target_type );
5786    (*the_free)( save_params );
5787    TRACE_RETURN();
5788    return(rc);
5789 }
5790 /*man-start*********************************************************************
5791 COMMAND
5792      set linend - allow/disallow multiple commands on command line
5793 
5794 SYNTAX
5795      [SET] LINENd ON|OFF [character]
5796 
5797 DESCRIPTION
5798      The SET LINEND command allows or disallows the execution of multiple
5799      commands on the <command line>. When setting LINEND ON, a 'character'
5800      is specified as the LINEND character which delimits each command.
5801 
5802 COMPATIBILITY
5803      XEDIT: Compatible.
5804      KEDIT: Compatible.
5805 
5806 DEFAULT
5807      OFF #
5808 
5809 STATUS
5810      Complete.
5811 **man-end**********************************************************************/
5812 #ifdef HAVE_PROTO
Linend(CHARTYPE * params)5813 short Linend(CHARTYPE *params)
5814 #else
5815 short Linend(params)
5816 CHARTYPE *params;
5817 #endif
5818 /***********************************************************************/
5819 {
5820 #define LE_PARAMS  2
5821    CHARTYPE *word[LE_PARAMS+1];
5822    CHARTYPE strip[LE_PARAMS];
5823    unsigned short num_params=0;
5824    bool le_status=CURRENT_VIEW->linend_status;
5825    CHARTYPE le_value=CURRENT_VIEW->linend_value;
5826    short rc=RC_OK;
5827 
5828    TRACE_FUNCTION("commset1.c:Linend");
5829    strip[0]=STRIP_BOTH;
5830    strip[1]=STRIP_BOTH;
5831    num_params = param_split(params,word,LE_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
5832    switch(num_params)
5833    {
5834       case 1:
5835       case 2:
5836            rc = execute_set_on_off(word[0],&le_status, TRUE );
5837            if (rc != RC_OK)
5838            {
5839               display_error(1,word[0],FALSE);
5840               rc = RC_INVALID_OPERAND;
5841               break;
5842            }
5843            if (num_params == 1)
5844               break;
5845            if ((int)strlen((DEFCHAR *)word[1]) > (int)1)
5846            {
5847               display_error(1,word[1],FALSE);
5848               break;
5849            }
5850            le_value = word[1][0];
5851            break;
5852       case 0:
5853            display_error(3,(CHARTYPE *)"",FALSE);
5854            rc = RC_INVALID_OPERAND;
5855            break;
5856       default:
5857            display_error(2,(CHARTYPE *)"",FALSE);
5858            rc = RC_INVALID_OPERAND;
5859            break;
5860    }
5861    if (rc == RC_OK)
5862    {
5863       CURRENT_VIEW->linend_status = le_status;
5864       CURRENT_VIEW->linend_value = le_value;
5865    }
5866    TRACE_RETURN();
5867    return(rc);
5868 }
5869 /*man-start*********************************************************************
5870 COMMAND
5871      set macro - indicate if macros executed before commands
5872 
5873 SYNTAX
5874      SET MACRO ON|OFF
5875 
5876 DESCRIPTION
5877      The SET MACRO command allows the user to determine if macros
5878      are executed before a built-in command of the same name.
5879 
5880      This command MUST be prefixed with <SET> to distinguish it
5881      from the <MACRO> command.
5882 
5883      A macro with the same name as a built-in command will only
5884      be executed before the built-in command if <SET IMPMACRO>
5885      is ON, <SET MACRO> is ON, and the command was NOT executed
5886      with the <COMMAND> command.
5887 
5888 COMPATIBILITY
5889      XEDIT: Compatible.
5890      KEDIT: N/A
5891 
5892 DEFAULT
5893      OFF
5894 
5895 SEE ALSO
5896      <MACRO>, <SET IMPMACRO>, <COMMAND>
5897 
5898 STATUS
5899      Complete.
5900 **man-end**********************************************************************/
5901 #ifdef HAVE_PROTO
SetMacro(CHARTYPE * params)5902 short SetMacro(CHARTYPE *params)
5903 #else
5904 short SetMacro(params)
5905 CHARTYPE *params;
5906 #endif
5907 /***********************************************************************/
5908 {
5909    short rc=RC_OK;
5910 
5911    TRACE_FUNCTION("commset1.c:SetMacro");
5912    rc = execute_set_on_off(params,&CURRENT_VIEW->macro, TRUE );
5913    TRACE_RETURN();
5914    return(rc);
5915 }
5916 /*man-start*********************************************************************
5917 COMMAND
5918      set macroext - set default macro extension value
5919 
5920 SYNTAX
5921      [SET] MACROExt [ext]
5922 
5923 DESCRIPTION
5924      The SET MACROEXT command sets the value of the file extension to be
5925      used for <macro> files. When a macro file name is specified on the
5926      <command line>, a period '.', then this value will be appended.
5927      If no value is specified for 'ext', then THE assumes that the
5928      supplied macro file name is the fully specified name for a macro.
5929 
5930      The length of 'ext' must be 10 characters or less.
5931 
5932      The macro extension is only appended to a file if that file does
5933      not include any path specifiers.
5934 
5935 COMPATIBILITY
5936      XEDIT: N/A
5937      KEDIT: N/A
5938 
5939 DEFAULT
5940      the
5941 
5942 STATUS
5943      Complete.
5944 **man-end**********************************************************************/
5945 #ifdef HAVE_PROTO
Macroext(CHARTYPE * params)5946 short Macroext(CHARTYPE *params)
5947 #else
5948 short Macroext(params)
5949 CHARTYPE *params;
5950 #endif
5951 /***********************************************************************/
5952 {
5953    TRACE_FUNCTION("commset1.c:Macroext");
5954    /*
5955     * If no value is specified for ext, set the value of macro_suffix to
5956     * "", otherwise set it to the supplied value, prefixed with '.'
5957     */
5958    if (strlen((DEFCHAR *)params) == 0)
5959       strcpy((DEFCHAR *)macro_suffix,"");
5960    else
5961    {
5962       if ((int)strlen((DEFCHAR *)params) > (int)10)
5963       {
5964          display_error(85,(CHARTYPE *)params,FALSE);
5965          TRACE_RETURN();
5966          return(RC_INVALID_OPERAND);
5967       }
5968       strcpy((DEFCHAR *)macro_suffix,".");
5969       strcat((DEFCHAR *)macro_suffix,(DEFCHAR *)params);
5970    }
5971    TRACE_RETURN();
5972    return(RC_OK);
5973 }
5974 /*man-start*********************************************************************
5975 COMMAND
5976      set macropath - set default path for macro commands
5977 
5978 SYNTAX
5979      [SET] MACROPath PATH|path[s]
5980 
5981 DESCRIPTION
5982      The SET MACROPATH command sets up the search path from which macro
5983      command files are executed. Each directory is separated by a
5984      colon (Unix) or semi-colon (DOS & OS/2). Only 20 directories are
5985      allowed to be specified.
5986 
5987      When 'PATH' is specified, the search path is set to the system
5988      PATH environment variable.
5989 
5990 COMPATIBILITY
5991      XEDIT: N/A
5992      KEDIT: Incompatible.
5993 
5994 DEFAULT
5995      Path specified by env variable THE_MACRO_PATH
5996 
5997 SEE ALSO
5998      <MACRO>, <SET IMPMACRO>
5999 
6000 STATUS
6001      Complete.
6002 **man-end**********************************************************************/
6003 #ifdef HAVE_PROTO
Macropath(CHARTYPE * params)6004 short Macropath(CHARTYPE *params)
6005 #else
6006 short Macropath(params)
6007 CHARTYPE *params;
6008 #endif
6009 /***********************************************************************/
6010 {
6011 #if defined(UNIX)
6012 # define PATH_DELIM ':'
6013 #else
6014 # define PATH_DELIM ';'
6015 #endif
6016    register int len=0;
6017    int num_dirs,i;
6018    DEFCHAR *ptr=NULL;
6019    CHARTYPE *src;
6020 
6021    TRACE_FUNCTION( "commset1.c:Macropath" );
6022    /*
6023     * No checking is done on macro path supplied other than it contains a
6024     * value. Path delimiters are translated if necessary.
6025     */
6026    if ( strlen( (DEFCHAR *)params ) == 0 )
6027    {
6028       display_error( 3, (CHARTYPE *)"", FALSE );
6029       TRACE_RETURN();
6030       return(RC_INVALID_OPERAND);
6031    }
6032    if ( my_stricmp( (DEFCHAR *)params, "PATH" ) == 0 )
6033       src = (CHARTYPE *)getenv( "PATH" );
6034    else
6035       src = params;
6036    strcpy( (DEFCHAR *)the_macro_path_buf, (DEFCHAR *)src );
6037    strrmdup( strtrans( the_macro_path_buf, OSLASH, ISLASH ), ISLASH, TRUE );
6038    strrmdup( the_macro_path_buf, PATH_DELIM, FALSE );
6039    len = strlen( (DEFCHAR *)the_macro_path_buf );
6040    if ( the_macro_path_buf[len-1] == PATH_DELIM )
6041    {
6042       the_macro_path_buf[len-1] = '\0';
6043       len--;
6044    }
6045    if ( len == 0 )
6046    {
6047       display_error( 3, (CHARTYPE *)"", FALSE );
6048       TRACE_RETURN();
6049       return(RC_INVALID_OPERAND);
6050    }
6051    strcpy( (DEFCHAR *)the_macro_path, (DEFCHAR *)the_macro_path_buf );
6052    /*
6053     * Count the number of PATH_DELIM in the buffer to determine
6054     * how many pointers to allocate.
6055     */
6056    for ( num_dirs = 1, i = 0; i < len; i++ )
6057    {
6058       if ( *(the_macro_path+i) == PATH_DELIM )
6059          num_dirs++;
6060    }
6061    /*
6062     * If we have already allocated enough pointer memory
6063     * don't bother allocating more
6064     */
6065    if ( num_dirs > total_macro_dirs )
6066    {
6067       if ( the_macro_dir == NULL )
6068          the_macro_dir = (CHARTYPE **)(*the_malloc)( num_dirs * sizeof(DEFCHAR *) );
6069       else
6070          the_macro_dir = (CHARTYPE **)(*the_realloc)( the_macro_dir, num_dirs * sizeof(DEFCHAR *) );
6071       if ( the_macro_dir == NULL )
6072       {
6073          max_macro_dirs = total_macro_dirs = 0;
6074          display_error( 30, (CHARTYPE *)"",FALSE );
6075          TRACE_RETURN();
6076          return(RC_OUT_OF_MEMORY);
6077       }
6078       total_macro_dirs = num_dirs;
6079    }
6080    the_macro_dir[0] = the_macro_path_buf;
6081    max_macro_dirs = 0;
6082    for ( ptr = (DEFCHAR*)the_macro_path_buf; *ptr != '\0'; ptr++ )
6083    {
6084       if ( *ptr == PATH_DELIM )
6085       {
6086          *ptr = '\0';
6087          the_macro_dir[++max_macro_dirs] = (CHARTYPE*)++ptr;
6088       }
6089    }
6090    max_macro_dirs++;
6091    TRACE_RETURN();
6092    return(RC_OK);
6093 }
6094 /*man-start*********************************************************************
6095 COMMAND
6096      set margins - set left and right margins for wordwrap
6097 
6098 SYNTAX
6099      [SET] MARgins left right [[+|-]indent]
6100 
6101 DESCRIPTION
6102      The SET MARGINS command sets the 'left' and 'right' margins and the
6103      number of columns to 'indent' a paragraph.
6104 
6105      These values are used with the <SET WORDWRAP> option.
6106 
6107      All options can be specified as the current EQUIVCHAR to retain the
6108      existing value.
6109 
6110 COMPATIBILITY
6111      XEDIT: N/A
6112      KEDIT: Compatible.
6113 
6114 DEFAULT
6115      1 72 +0
6116 
6117 SEE ALSO
6118      <SET WORDWRAP>, <SET EQUIVCHAR>
6119 
6120 STATUS
6121      Complete.
6122 **man-end**********************************************************************/
6123 #ifdef HAVE_PROTO
Margins(CHARTYPE * params)6124 short Margins(CHARTYPE *params)
6125 #else
6126 short Margins(params)
6127 CHARTYPE *params;
6128 #endif
6129 /***********************************************************************/
6130 {
6131 #define MAR_PARAMS  3
6132    CHARTYPE *word[MAR_PARAMS+1];
6133    CHARTYPE strip[MAR_PARAMS];
6134    short num_params=0;
6135    LENGTHTYPE left=0,right=0,indent=0;
6136    bool offset=FALSE,consistancy_error=FALSE;
6137 
6138    TRACE_FUNCTION("commset1.c:Margins");
6139    /*
6140     * Two parameters are mandatory, the third is optional.
6141     */
6142    strip[0]=STRIP_BOTH;
6143    strip[1]=STRIP_BOTH;
6144    strip[2]=STRIP_BOTH;
6145    num_params = param_split(params,word,MAR_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
6146    if (num_params < 2)
6147    {
6148       display_error(3,(CHARTYPE *)"",FALSE);
6149       TRACE_RETURN();
6150       return(RC_INVALID_OPERAND);
6151    }
6152    if (num_params > 3)
6153    {
6154       display_error(2,(CHARTYPE *)"",FALSE);
6155       TRACE_RETURN();
6156       return(RC_INVALID_OPERAND);
6157    }
6158    /*
6159     * Parse the parameters...
6160     */
6161    if ( equal(EQUIVCHARstr, word[0], 1 ) )
6162    {
6163       left = CURRENT_VIEW->margin_left;
6164    }
6165    else
6166    {
6167       left = atol((DEFCHAR *)word[0]);
6168       if (left < 1)
6169       {
6170          display_error(5,word[0],FALSE);
6171          TRACE_RETURN();
6172          return(RC_INVALID_OPERAND);
6173       }
6174    }
6175    /*
6176     * Right margin value can be *, set to maximum line length.
6177     */
6178    if ( equal( EQUIVCHARstr, word[1], 1 ) )
6179    {
6180       right = CURRENT_VIEW->margin_right;
6181    }
6182    else if ( equal( (CHARTYPE *)"*", word[1], 1 ) )
6183    {
6184       right = max_line_length;
6185    }
6186    else
6187    {
6188       right = atol((DEFCHAR *)word[1]);
6189       if (right > max_line_length)
6190       {
6191          display_error(6,word[1],FALSE);
6192          TRACE_RETURN();
6193          return(RC_INVALID_OPERAND);
6194       }
6195       if (right < 1)
6196       {
6197          display_error(5,word[1],FALSE);
6198          TRACE_RETURN();
6199          return(RC_INVALID_OPERAND);
6200       }
6201    }
6202    /*
6203     * Left margin must be less than right margin.
6204     */
6205    if (right < left)
6206    {
6207       display_error(5,word[1],FALSE);
6208       TRACE_RETURN();
6209       return(RC_INVALID_OPERAND);
6210    }
6211    /*
6212     * Obtain current values for indent, in case they aren't changed by
6213     * the current command. (i.e. no third parameter)
6214     */
6215    indent = CURRENT_VIEW->margin_indent;
6216    offset = CURRENT_VIEW->margin_indent_offset_status;
6217    /*
6218     * Determine the type of offset for the indent value. If a sign is
6219     * specified, then the number supplied is relative to the left margin
6220     * otherwise it is an absolute column value.
6221     * Do the following processing only if the indent parameter is NOT
6222     * the EQUIVCHAR.
6223     */
6224    if ( num_params == 3
6225    &&   !equal( EQUIVCHARstr, word[2], 1 ) )
6226    {
6227       if (*(word[2]) == '-'
6228       ||  *(word[2]) == '+')
6229       {
6230          offset = TRUE;
6231          if ((indent = atol((DEFCHAR *)word[2])) == 0)
6232          {
6233             if (strcmp((DEFCHAR *)word[2],"+0") != 0)
6234             {
6235                display_error(1,word[2],FALSE);
6236                TRACE_RETURN();
6237                return(RC_INVALID_OPERAND);
6238             }
6239          }
6240       }
6241       else
6242       {
6243          offset = FALSE;
6244          /*
6245           * Absolute indent cannot be negative.
6246           */
6247          if ((indent = atol((DEFCHAR *)word[2])) < 0)
6248          {
6249             display_error(1,word[2],FALSE);
6250             TRACE_RETURN();
6251             return(RC_INVALID_OPERAND);
6252          }
6253       }
6254    }
6255    /*
6256     * Once all values are determined, validate the relationship between
6257     * the margins and the indent values.
6258     * Rules:
6259     *       o If indent is a negative offset, the resultant column value
6260     *         cannot be negative.
6261     *       o If indent is a positive offset, the resultant column value
6262     *         cannot be > max_line_length or right margin
6263     *       o If indent is an absolute value, it cannot be > right margin
6264     */
6265    consistancy_error = FALSE;
6266    if (offset
6267    && indent < 0
6268    && indent + left < 0)
6269       consistancy_error = TRUE;
6270    if (offset
6271    && indent > 0
6272    && indent + left > right)
6273       consistancy_error = TRUE;
6274    if (offset
6275    && indent > 0
6276    && (LENGTHTYPE)(indent + left) > max_line_length)
6277       consistancy_error = TRUE;
6278    if (!offset
6279    && indent > right)
6280       consistancy_error = TRUE;
6281    if (consistancy_error)
6282      {
6283       if (offset)
6284          sprintf((DEFCHAR *)temp_cmd,"%ld %ld %+ld",left,right,indent);
6285       else
6286          sprintf((DEFCHAR *)temp_cmd,"%ld %ld %ld",left,right,indent);
6287       display_error(12,temp_cmd,FALSE);
6288       TRACE_RETURN();
6289       return(RC_INVALID_OPERAND);
6290    }
6291    /*
6292     * All OK, so save the values...
6293     */
6294    CURRENT_VIEW->margin_left = left;
6295    CURRENT_VIEW->margin_right = right;
6296    CURRENT_VIEW->margin_indent = indent;
6297    CURRENT_VIEW->margin_indent_offset_status = offset;
6298    /*
6299     * If the SCALE line is currently displayed, display the page so that
6300     * any changes are reflected in the SCALE line. Also display page if
6301     * boundmark is not off.
6302     */
6303    if ( CURRENT_VIEW->scale_on
6304    ||   CURRENT_VIEW->boundmark != BOUNDMARK_OFF )
6305    {
6306       build_screen(current_screen);
6307       display_screen(current_screen);
6308    }
6309    TRACE_RETURN();
6310    return(RC_OK);
6311 }
6312 /*man-start*********************************************************************
6313 COMMAND
6314      set mouse - turn mouse support on or off
6315 
6316 SYNTAX
6317      [SET] MOUSE ON|OFF
6318 
6319 DESCRIPTION
6320      The SET MOUSE command allows the user to turn on or off mouse
6321      support in THE.  With mouse support, THE commands assigned to
6322      a mouse button event will be executed.  See APPENDIX 3 for
6323      details on default mouse support.
6324 
6325      If the platform does not support mouse operations, the default
6326      setting will be OFF.
6327 
6328 COMPATIBILITY
6329      XEDIT: N/A
6330      KEDIT: Compatible. Does not support all options.
6331 
6332 DEFAULT
6333      ON - if mouse supported, OFF - otherwise
6334 
6335 SEE ALSO
6336      <DEFINE>
6337 
6338 STATUS
6339      Complete.
6340 **man-end**********************************************************************/
6341 #ifdef HAVE_PROTO
Mouse(CHARTYPE * params)6342 short Mouse(CHARTYPE *params)
6343 #else
6344 short Mouse(params)
6345 CHARTYPE *params;
6346 #endif
6347 /***********************************************************************/
6348 {
6349    short rc=RC_OK;
6350 
6351    TRACE_FUNCTION("commset1.c:Mouse");
6352    rc = execute_set_on_off(params,&MOUSEx, TRUE );
6353 #if defined(PDCURSES_MOUSE_ENABLED)
6354    mouse_set((MOUSEx)?ALL_MOUSE_EVENTS:0L);
6355 #endif
6356 #if defined(NCURSES_MOUSE_VERSION)
6357    mousemask((MOUSEx)?ALL_MOUSE_EVENTS:0, (mmask_t*)NULL);
6358 #endif
6359    TRACE_RETURN();
6360    return(rc);
6361 }
6362 /*man-start*********************************************************************
6363 COMMAND
6364      set msgline - set position and size of message line
6365 
6366 SYNTAX
6367      [SET] MSGLine ON M[+n|-n]|[+|-]n [lines] [Overlay]
6368      [SET] MSGLine CLEAR
6369 
6370 DESCRIPTION
6371      The SET MSGLINE set command specifies the position of the
6372      <message line> and the size of the message line window.
6373 
6374      The first form of positional parameters is:
6375 
6376      M[+n|-n]
6377      this sets the first line to be relative to the middle of
6378      the screen. A positive value adds to the middle line number,
6379      a negative subtracts from it.
6380      e.g. M+3 on a 24 line screen will be line 15
6381          M-5 on a 24 line screen will be line 7
6382 
6383      The second form of positional parameters is:
6384 
6385      [+|-]n
6386      this sets the first line to be relative to the top of the
6387      screen (if positive or no sign) or relative to the bottom
6388      of the screen if negative.
6389      e.g. +3 or 3 will set first line to line 3
6390          -3 on a 24 line screen will set first line to line 21
6391 
6392      If the resulting line is outside the bounds of the screen
6393      the position of the message line will become the middle line
6394      on the screen.
6395 
6396      The 'lines' argument specifies the maximum number of lines of
6397      error messages to display at the one time.  If this value is
6398      specified as a whole number it must be less than or equal to the
6399      number of lines that could fit on the screen from the starting row.
6400      '*' can be specified to indicate that as many lines as possible should
6401      be displayed.
6402 
6403      All options can be specified as the current EQUIVCHAR to retain the
6404      existing value.
6405 
6406      The second format of the command clears the messages being displayed.
6407      This is useful in macros where you need to display an error message
6408      but also want to be able to clear it.
6409 
6410 COMPATIBILITY
6411      XEDIT: Compatible.
6412             The OVERLAY option is the default but ignored.
6413             The second format is not supported.
6414      KEDIT: Compatible
6415             The OVERLAY option is the default but ignored.
6416             The second format is not supported.
6417 
6418 DEFAULT
6419      ON 2 5 Overlay
6420 
6421 SEE ALSO
6422      <SET EQUIVCHAR>
6423 
6424 STATUS
6425      Complete
6426 **man-end**********************************************************************/
6427 #ifdef HAVE_PROTO
Msgline(CHARTYPE * params)6428 short Msgline(CHARTYPE *params)
6429 #else
6430 short Msgline(params)
6431 CHARTYPE *params;
6432 #endif
6433 /***********************************************************************/
6434 {
6435 #define MSG_PARAMS  5
6436    CHARTYPE *word[MSG_PARAMS+1];
6437    CHARTYPE strip[MSG_PARAMS];
6438    short num_params=0;
6439    short rc=RC_OK;
6440    short base=CURRENT_VIEW->msgline_base;
6441    short off=CURRENT_VIEW->msgline_off;
6442    int start_row;
6443    bool msgsts=FALSE;
6444    int num_lines=CURRENT_VIEW->msgline_rows;
6445 
6446    TRACE_FUNCTION( "commset1.c:Msgline" );
6447    strip[0]=STRIP_BOTH;
6448    strip[1]=STRIP_BOTH;
6449    strip[2]=STRIP_BOTH;
6450    strip[3]=STRIP_BOTH;
6451    strip[4]=STRIP_NONE;
6452    num_params = param_split( params, word, MSG_PARAMS, WORD_DELIMS, TEMP_PARAM, strip, FALSE );
6453    /*
6454     * If only 1 parameter, it must be CLEAR...
6455     */
6456    if ( num_params == 1 )
6457    {
6458       if ( equal( (CHARTYPE *)"CLEAR", word[0], 5 ) )
6459       {
6460          clear_msgline( -1 );
6461          TRACE_RETURN();
6462          return(RC_OK);
6463       }
6464    }
6465    /*
6466     * more than 1 parameter or only parameter not CLEAR
6467     */
6468    if ( num_params < 2 )
6469    {
6470       display_error(3,(CHARTYPE *)"",FALSE);
6471       TRACE_RETURN();
6472       return(RC_INVALID_OPERAND);
6473    }
6474    if (num_params > 4)
6475    {
6476       display_error(2,(CHARTYPE *)"",FALSE);
6477       TRACE_RETURN();
6478       return(RC_INVALID_OPERAND);
6479    }
6480    /*
6481     * Parse the status parameter...
6482     */
6483    if ( equal( EQUIVCHARstr, word[0], 1 ) )
6484    {
6485       msgsts = TRUE;
6486    }
6487    else
6488    {
6489       rc = execute_set_on_off( word[0], &msgsts , TRUE );
6490       if (rc != RC_OK)
6491       {
6492          TRACE_RETURN();
6493          return(rc);
6494       }
6495    }
6496    /*
6497     * ... only "ON" is allowed...
6498     */
6499    if (!msgsts)
6500    {
6501       display_error(1,word[0],FALSE);
6502       TRACE_RETURN();
6503       return(RC_INVALID_OPERAND);
6504    }
6505    /*
6506     * Parse the position parameter...
6507     */
6508    if (num_params > 1)
6509    {
6510       if ( equal( EQUIVCHARstr, word[1], 1 ) )
6511       {
6512          base = CURRENT_VIEW->msgline_base;
6513          off = CURRENT_VIEW->msgline_off;
6514       }
6515       else
6516       {
6517          rc = execute_set_row_position( word[1], &base, &off );
6518          if (rc != RC_OK)
6519          {
6520             TRACE_RETURN();
6521             return(rc);
6522          }
6523       }
6524    }
6525    /*
6526     * To get here we have either two arguments or one. If two, the first
6527     * is the number of lines, and the second MUST be Overlay.
6528     * If one argument, it is either Overlay or number of lines.
6529     */
6530    switch(num_params)
6531    {
6532       case 3:
6533          if (equal((CHARTYPE *)"overlay",word[2],1))
6534             num_lines = 1;
6535          else if ( equal( (CHARTYPE *)EQUIVCHARstr, word[2], 1 ) )
6536             num_lines = CURRENT_VIEW->msgline_rows;
6537          else if ( equal( (CHARTYPE *)"*", word[2], 1 ) )
6538             num_lines = 0;
6539          else
6540          {
6541             num_lines = atoi( (DEFCHAR *)word[2] );
6542             if (num_lines < 1)
6543             {
6544                display_error( 5, word[2], FALSE );
6545                TRACE_RETURN();
6546                return(rc);
6547             }
6548             start_row = calculate_actual_row( base, off, CURRENT_SCREEN.screen_rows, TRUE );
6549             if ( base == POSITION_BOTTOM )
6550             {
6551                if ( num_lines > start_row )
6552                   rc = RC_INVALID_OPERAND;
6553             }
6554             else
6555             {
6556                if ( start_row + num_lines > CURRENT_SCREEN.screen_rows )
6557                   rc = RC_INVALID_OPERAND;
6558             }
6559             if ( rc == RC_INVALID_OPERAND )
6560             {
6561                display_error( 6, word[2], FALSE );
6562                TRACE_RETURN();
6563                return(rc);
6564             }
6565          }
6566          break;
6567       case 4:
6568          if ( equal( (CHARTYPE *)EQUIVCHARstr, word[2], 1 ) )
6569             num_lines = CURRENT_VIEW->msgline_rows;
6570          else if ( equal( (CHARTYPE *)"*", word[2], 1 ) )
6571             num_lines = 0;
6572          else
6573          {
6574             num_lines = atoi( (DEFCHAR *)word[2] );
6575             if (num_lines < 1)
6576             {
6577                display_error( 5, word[2], FALSE );
6578                TRACE_RETURN();
6579                return(rc);
6580             }
6581             start_row = calculate_actual_row( base, off, CURRENT_SCREEN.screen_rows, TRUE );
6582             if ( base == POSITION_BOTTOM )
6583             {
6584                if ( num_lines > start_row )
6585                   rc = RC_INVALID_OPERAND;
6586             }
6587             else
6588             {
6589                if ( start_row + num_lines > CURRENT_SCREEN.screen_rows )
6590                   rc = RC_INVALID_OPERAND;
6591             }
6592             if ( rc == RC_INVALID_OPERAND )
6593             {
6594                display_error( 6, word[2], FALSE );
6595                TRACE_RETURN();
6596                return(rc);
6597             }
6598          }
6599          if ( !equal((CHARTYPE *)"overlay", word[3], 1 )
6600          &&   !equal((CHARTYPE *)EQUIVCHARstr, word[3], 1 ) )
6601          {
6602             display_error( 1, word[3], FALSE );
6603             TRACE_RETURN();
6604             return(rc);
6605          }
6606          break;
6607       default:
6608          num_lines = 1;
6609          break;
6610    }
6611    CURRENT_VIEW->msgline_base = base;
6612    CURRENT_VIEW->msgline_off = off;
6613    CURRENT_VIEW->msgline_rows = num_lines;
6614    TRACE_RETURN();
6615    return(rc);
6616 }
6617 /*man-start*********************************************************************
6618 COMMAND
6619      set msgmode - set display of messages on or off
6620 
6621 SYNTAX
6622      [SET] MSGMode ON|OFF [Short|Long]
6623 
6624 DESCRIPTION
6625      The SET MSGMODE set command determines whether error messages will
6626      be displayed or suppressed.
6627 
6628 COMPATIBILITY
6629      XEDIT: Does not implement [Short|Long] options.
6630      KEDIT: Compatible
6631 
6632 DEFAULT
6633      ON
6634 
6635 STATUS
6636      Complete
6637 **man-end**********************************************************************/
6638 #ifdef HAVE_PROTO
Msgmode(CHARTYPE * params)6639 short Msgmode(CHARTYPE *params)
6640 #else
6641 short Msgmode(params)
6642 CHARTYPE *params;
6643 #endif
6644 /***********************************************************************/
6645 {
6646 #define MSGM_PARAMS  2
6647    CHARTYPE *word[MSGM_PARAMS+1];
6648    CHARTYPE strip[MSGM_PARAMS];
6649    short num_params=0;
6650    short rc=RC_OK;
6651    bool new_msgmode=FALSE;
6652 
6653    TRACE_FUNCTION("commset1.c:Msgmode");
6654    strip[0]=STRIP_BOTH;
6655    strip[1]=STRIP_BOTH;
6656    num_params = param_split(params,word,MSGM_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
6657    if ( num_params < 1 )
6658    {
6659       display_error( 3,(CHARTYPE *)"",FALSE );
6660       TRACE_RETURN();
6661       return(RC_INVALID_OPERAND);
6662    }
6663    /*
6664     * Parse the status parameter...
6665     */
6666    rc = execute_set_on_off( word[0],&new_msgmode, TRUE );
6667    if (rc != RC_OK)
6668    {
6669       TRACE_RETURN();
6670       return(rc);
6671    }
6672    /*
6673     * If present the second argument is validated but ignored...
6674     */
6675    if ( num_params > 1 )
6676    {
6677       if ( equal( (CHARTYPE *)"SHORT", word[1], 1 ) )
6678       {
6679          /*
6680           * Ignore
6681           */
6682       }
6683       else if ( equal( (CHARTYPE *)"LONG", word[1], 1 ) )
6684       {
6685          /*
6686           * Ignore
6687           */
6688       }
6689       else
6690       {
6691          display_error( 1, word[1], FALSE );
6692          TRACE_RETURN();
6693          return(RC_INVALID_OPERAND);
6694       }
6695    }
6696    CURRENT_VIEW->msgmode_status = new_msgmode;
6697    TRACE_RETURN();
6698    return(RC_OK);
6699 }
6700 /*man-start*********************************************************************
6701 COMMAND
6702      set newlines - set position of cursor after adding blank line
6703 
6704 SYNTAX
6705      [SET] NEWLines Aligned|Left
6706 
6707 DESCRIPTION
6708      The SET NEWLINES set command determines where the cursor displays
6709      after a new line is added to the file.
6710 
6711      With 'ALIGNED', the cursor will display in the column of the new line
6712      immediately underneath the first non-blank character in the line
6713      above.
6714      With 'LEFT', the cursor will display in the first column of the new
6715      line.
6716 
6717 COMPATIBILITY
6718      XEDIT: N/A
6719      KEDIT: Same command, different functionality.
6720 
6721 DEFAULT
6722      Aligned
6723 
6724 STATUS
6725      Complete
6726 **man-end**********************************************************************/
6727 #ifdef HAVE_PROTO
Newlines(CHARTYPE * params)6728 short Newlines(CHARTYPE *params)
6729 #else
6730 short Newlines(params)
6731 CHARTYPE *params;
6732 #endif
6733 /***********************************************************************/
6734 {
6735 #define NEW_PARAMS  1
6736    CHARTYPE parm[NEW_PARAMS];
6737    CHARTYPE *word[NEW_PARAMS+1];
6738    CHARTYPE strip[NEW_PARAMS];
6739    unsigned short num_params=0;
6740 
6741    TRACE_FUNCTION("commset1.c:Newlines");
6742    strip[0]=STRIP_BOTH;
6743    num_params = param_split(params,word,NEW_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
6744    if (num_params > 1)
6745    {
6746       display_error(2,(CHARTYPE *)"",FALSE);
6747       TRACE_RETURN();
6748       return(RC_INVALID_OPERAND);
6749    }
6750    if (num_params < 1)
6751    {
6752       display_error(3,(CHARTYPE *)"",FALSE);
6753       TRACE_RETURN();
6754       return(RC_INVALID_OPERAND);
6755    }
6756 
6757    parm[0] = (CHARTYPE)UNDEFINED_OPERAND;
6758    if (equal((CHARTYPE *)"aligned",word[0],1))
6759       parm[0] = TRUE;
6760    if (equal((CHARTYPE *)"left",word[0],1))
6761       parm[0] = FALSE;
6762    if (parm[0] == (CHARTYPE)UNDEFINED_OPERAND)
6763    {
6764       display_error(1,word[0],FALSE);
6765       TRACE_RETURN();
6766       return(RC_INVALID_OPERAND);
6767    }
6768    CURRENT_VIEW->newline_aligned = parm[0];
6769    TRACE_RETURN();
6770    return(RC_OK);
6771 }
6772 /*man-start*********************************************************************
6773 COMMAND
6774      set nondisp - specify character to display for non-displaying characters
6775 
6776 SYNTAX
6777      [SET] NONDisp character
6778 
6779 DESCRIPTION
6780      The SET NONDISP command allows the user to change the 'character'
6781      that is displayed for non-displaying commands when <SET ETMODE>
6782      is OFF.
6783 
6784 COMPATIBILITY
6785      XEDIT: Compatible.
6786      KEDIT: N/A
6787 
6788 DEFAULT
6789      #
6790 
6791 SEE ALSO
6792      <SET ETMODE>
6793 
6794 STATUS
6795      Complete.
6796 **man-end**********************************************************************/
6797 #ifdef HAVE_PROTO
Nondisp(CHARTYPE * params)6798 short Nondisp(CHARTYPE *params)
6799 #else
6800 short Nondisp(params)
6801 CHARTYPE *params;
6802 #endif
6803 /***********************************************************************/
6804 {
6805    TRACE_FUNCTION("commset1.c:Nondisp");
6806    if (strlen((DEFCHAR *)params) != 1)
6807    {
6808       display_error(1,params,FALSE);
6809       TRACE_RETURN();
6810       return(RC_INVALID_OPERAND);
6811    }
6812    NONDISPx = *params;
6813    build_screen(current_screen);
6814    display_screen(current_screen);
6815    TRACE_RETURN();
6816    return(RC_OK);
6817 }
6818 /*man-start*********************************************************************
6819 COMMAND
6820      set number - turn prefix numbers on or off
6821 
6822 SYNTAX
6823      [SET] NUMber ON|OFF
6824 
6825 DESCRIPTION
6826      The SET NUMBER command allows the user to set the display of
6827      numbers in the <prefix area>.
6828 
6829 COMPATIBILITY
6830      XEDIT: Compatible.
6831      KEDIT: Compatible.
6832 
6833 DEFAULT
6834      ON
6835 
6836 SEE ALSO
6837      <SET PREFIX>
6838 
6839 STATUS
6840      Complete.
6841 **man-end**********************************************************************/
6842 #ifdef HAVE_PROTO
Number(CHARTYPE * params)6843 short Number(CHARTYPE *params)
6844 #else
6845 short Number(params)
6846 CHARTYPE *params;
6847 #endif
6848 /***********************************************************************/
6849 {
6850    short rc=RC_OK;
6851 
6852    TRACE_FUNCTION("commset1.c:Number");
6853    rc = execute_set_on_off(params,&CURRENT_VIEW->number, TRUE );
6854    if (rc == RC_OK)
6855    {
6856       build_screen(current_screen);
6857       display_screen(current_screen);
6858    }
6859    TRACE_RETURN();
6860    return(rc);
6861 }
6862