home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / the25.zip / thesrc251.zip / commset2.c < prev    next >
C/C++ Source or Header  |  1998-07-28  |  117KB  |  3,790 lines

  1. /***********************************************************************/
  2. /* COMMSET2.C - SET commands O-Z                                       */
  3. /***********************************************************************/
  4. /*
  5.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  6.  * Copyright (C) 1991-1997 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                 Email:             M.Hessling@qut.edu.au
  33.  * PO Box 203                    Phone:                    +617 3802 0800
  34.  * Bellara                       http://www.gu.edu.au/gext/the/markh.html
  35.  * QLD 4507                      **** Maintainer PDCurses & REXX/SQL ****
  36.  * Australia                     ************* Author of THE ************
  37.  */
  38.  
  39. /*
  40. $Id: commset2.c 2.1 1995/06/24 16:29:10 MH Rel MH $
  41. */
  42.  
  43. #include <the.h>
  44. #include <proto.h>
  45.  
  46. /*#define DEBUG 1*/
  47.  
  48. /*--------------------------- global data -----------------------------*/
  49. bool rexx_output=FALSE;
  50.  
  51. /*man-start*********************************************************************
  52. COMMAND
  53.      set pending - set status of pending prefix commands
  54.  
  55. SYNTAX
  56.      [SET] PENDing ON string
  57.      [SET] PENDing OFF
  58.      [SET] PENDing BLOCK string
  59.  
  60. DESCRIPTION
  61.      The SET PENDING command allows the user to insert or remove commands
  62.      from the pending prefix list.
  63.  
  64.      ON string, simulates the user typing 'string' in the <prefix area>
  65.      of the <focus line>.
  66.  
  67.      OFF, removes any pending prefix command from the focus line.
  68.  
  69.      BLOCK string, simulates the user typing 'string' in the PREFIX
  70.      area of the focus line and identifies the prefix command to be 
  71.      a BLOCK command.
  72.  
  73. COMPATIBILITY
  74.      XEDIT: Does not support ERROR option.
  75.      KEDIT: N/A
  76.  
  77. STATUS
  78.      Complete.
  79. **man-end**********************************************************************/
  80. #ifdef HAVE_PROTO
  81. short Pending(CHARTYPE *params)
  82. #else
  83. short Pending(params)
  84. CHARTYPE *params;
  85. #endif
  86. /***********************************************************************/
  87. {
  88. #define PEND_ON    1
  89. #define PEND_OFF   2
  90. #define PEND_BLOCK 3
  91. /*------------------------- external data -----------------------------*/
  92.  extern CHARTYPE *pre_rec;
  93.  extern unsigned short pre_rec_len;
  94. /*--------------------------- local data ------------------------------*/
  95. #define PEN_PARAMS  3
  96.  CHARTYPE *word[PEN_PARAMS+1];
  97.  CHARTYPE strip[PEN_PARAMS];
  98.  unsigned short num_params=0;
  99.  short rc=RC_OK;
  100.  LINE *curr=NULL;
  101.  LINETYPE true_line=0L;
  102.  short command=0;
  103. /*--------------------------- processing ------------------------------*/
  104. #ifdef TRACE
  105.  trace_function("commset2.c:Pending");
  106. #endif
  107. /*---------------------------------------------------------------------*/
  108. /* Validate parameters.                                                */
  109. /*---------------------------------------------------------------------*/
  110.  strip[0]=STRIP_BOTH;
  111.  strip[1]=STRIP_BOTH;
  112.  strip[2]=STRIP_BOTH;
  113.  num_params = param_split(params,word,PEN_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  114. /*---------------------------------------------------------------------*/
  115. /* If no arguments, error.                                             */
  116. /*---------------------------------------------------------------------*/
  117.  if (num_params == 0)
  118.    {
  119.     display_error(3,(CHARTYPE *)"",FALSE);
  120. #ifdef TRACE
  121.     trace_return();
  122. #endif
  123.     return(RC_INVALID_OPERAND);
  124.    }
  125. /*---------------------------------------------------------------------*/
  126. /* If more than 2 arguments, error.                                    */
  127. /*---------------------------------------------------------------------*/
  128.  if (num_params > 2)
  129.    {
  130.     display_error(2,(CHARTYPE *)"",FALSE);
  131. #ifdef TRACE
  132.     trace_return();
  133. #endif
  134.     return(RC_INVALID_OPERAND);
  135.    }
  136. /*---------------------------------------------------------------------*/
  137. /* Validate first parameter...                                         */
  138. /*---------------------------------------------------------------------*/
  139.  if (equal((CHARTYPE *)"off",word[0],3))
  140.     command = PEND_OFF;
  141.  else
  142.     if (equal((CHARTYPE *)"on",word[0],2))
  143.        command = PEND_ON;
  144.     else
  145.        if (equal((CHARTYPE *)"block",word[0],5))
  146.           command = PEND_BLOCK;
  147.        else
  148.          {
  149.           display_error(1,word[0],FALSE);
  150. #ifdef TRACE
  151.           trace_return();
  152. #endif
  153.           return(RC_INVALID_OPERAND);
  154.          }
  155.  true_line = get_true_line(TRUE);
  156.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  157.  switch(command)
  158.    {
  159. /*---------------------------------------------------------------------*/
  160. /* PENDING ON and PENDING BLOCK...                                     */
  161. /*---------------------------------------------------------------------*/
  162.     case PEND_ON:
  163.     case PEND_BLOCK:
  164. /*---------------------------------------------------------------------*/
  165. /* The second argument must be present and <= PREFIX_WIDTH.            */
  166. /*---------------------------------------------------------------------*/
  167.          if (num_params != 2)
  168.            {
  169.             display_error(3,(CHARTYPE *)"",FALSE);
  170.             rc = RC_INVALID_OPERAND;
  171.             break;
  172.            }
  173.          if (strlen((DEFCHAR *)word[1]) > CURRENT_VIEW->prefix_width)
  174.            {
  175.             display_error(1,word[1],FALSE); /* different error ?? */
  176.             rc = RC_INVALID_OPERAND;
  177.             break;
  178.            }
  179. /*---------------------------------------------------------------------*/
  180. /* Copy the string into pre_rec and set its length.                    */
  181. /*---------------------------------------------------------------------*/
  182.          memset(pre_rec,' ',MAX_PREFIX_WIDTH);
  183.          strcpy((DEFCHAR *)pre_rec,(DEFCHAR *)word[1]);
  184.          pre_rec_len = strlen((DEFCHAR *)word[1]);
  185.          pre_rec[pre_rec_len] = ' ';
  186.          pre_rec[CURRENT_VIEW->prefix_width] = '\0';
  187.          curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,true_line,CURRENT_FILE->number_lines);
  188.          if (command == PEND_BLOCK)
  189.             add_prefix_command(curr,true_line,TRUE);
  190.          else
  191.             add_prefix_command(curr,true_line,FALSE);
  192.          break;
  193. /*---------------------------------------------------------------------*/
  194. /* PENDING OFF...                                                      */
  195. /*---------------------------------------------------------------------*/
  196.     case PEND_OFF:
  197.          if (num_params != 1)
  198.            {
  199.             display_error(2,(CHARTYPE *)"",FALSE);
  200.             rc = RC_INVALID_OPERAND;
  201.             break;
  202.            }
  203.          curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,true_line,CURRENT_FILE->number_lines);
  204.          (void)delete_pending_prefix_command(curr->pre,CURRENT_FILE,curr);
  205.          memset(pre_rec,' ',MAX_PREFIX_WIDTH);
  206.          pre_rec_len = 0;
  207.          break;
  208.    }
  209.  if (rc == RC_OK)
  210.    {
  211.     build_screen(current_screen);
  212.     display_screen(current_screen);
  213.    }
  214. #ifdef TRACE
  215.  trace_return();
  216. #endif
  217.  return(rc);
  218. }
  219. /*man-start*********************************************************************
  220. COMMAND
  221.      set point - assign a name to the current line
  222.  
  223. SYNTAX
  224.      [SET] Point .name [OFF]
  225.  
  226. DESCRIPTION
  227.      The SET POINT command assignes the specified name to the 
  228.      <focus line>, or removes the name from the line with the specified 
  229.      name.
  230.      A valid line name must start with a '.' followed by alphanumeric
  231.      characters. eg. .a .fred and .3AB are valid names.
  232.  
  233.      When a line is moved within the same file, its line name stays
  234.      with the line.
  235.  
  236. COMPATIBILITY
  237.      XEDIT: Compatible. See below.
  238.      KEDIT: Compatible. See below.
  239.      Does not allow for multiple names for the same line.
  240.  
  241. STATUS
  242.      Complete.
  243. **man-end**********************************************************************/
  244. #ifdef HAVE_PROTO
  245. short Point(CHARTYPE *params)
  246. #else
  247. short Point(params)
  248. CHARTYPE *params;
  249. #endif
  250. /***********************************************************************/
  251. {
  252. /*------------------------- external date -----------------------------*/
  253. /*--------------------------- local data ------------------------------*/
  254. #define POI_PARAMS  2
  255.  CHARTYPE *word[POI_PARAMS+1];
  256.  CHARTYPE strip[POI_PARAMS];
  257.  unsigned short num_params=0;
  258.  short rc=RC_OK;
  259. /*--------------------------- processing ------------------------------*/
  260. #ifdef TRACE
  261.  trace_function("commset2.c:Point");
  262. #endif
  263. /*---------------------------------------------------------------------*/
  264. /* Validate parameters.                                                */
  265. /*---------------------------------------------------------------------*/
  266.  strip[0]=STRIP_BOTH;
  267.  strip[1]=STRIP_BOTH;
  268.  num_params = param_split(params,word,POI_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  269.  if (num_params < 1)
  270.    {
  271.     display_error(3,(CHARTYPE *)"",FALSE);
  272. #ifdef TRACE
  273.     trace_return();
  274. #endif
  275.     return(RC_INVALID_OPERAND);
  276.    }
  277. /*---------------------------------------------------------------------*/
  278. /* Turning on line name...                                             */
  279. /*---------------------------------------------------------------------*/
  280.  if (num_params == 1)
  281.    {
  282.     if (word[0][0] != '.'
  283.     ||  !isalnum(word[0][1]))
  284.       {
  285.        display_error(18,word[0],FALSE);
  286. #ifdef TRACE
  287.        trace_return();
  288. #endif
  289.        return(RC_INVALID_OPERAND);
  290.       }
  291.     if ((rc = execute_set_point(word[0],get_true_line(TRUE),TRUE)) != RC_OK)
  292.       {
  293. #ifdef TRACE
  294.        trace_return();
  295. #endif
  296.        return(rc);
  297.       }
  298.    }
  299. /*---------------------------------------------------------------------*/
  300. /* Turning off line name...                                            */
  301. /*---------------------------------------------------------------------*/
  302.  else
  303.    {
  304.     if (!equal((CHARTYPE *)"off",word[1],3))
  305.       {
  306.        display_error(1,word[1],FALSE);
  307. #ifdef TRACE
  308.        trace_return();
  309. #endif
  310.        return(RC_INVALID_OPERAND);
  311.       }
  312.     if ((rc = execute_set_point(word[0],get_true_line(TRUE),FALSE)) != RC_OK)
  313.       {
  314. #ifdef TRACE
  315.        trace_return();
  316. #endif
  317.        return(rc);
  318.       }
  319.    }
  320. #ifdef TRACE
  321.  trace_return();
  322. #endif
  323.  return(RC_OK);
  324. }
  325. /*man-start*********************************************************************
  326. COMMAND
  327.      set position - determine if LINE/COL is displayed on idline
  328.  
  329. SYNTAX
  330.      [SET] POSition ON|OFF
  331.  
  332. DESCRIPTION
  333.      The SET POSITION command allows the user to turn on or off the
  334.      display of LINE/COL on the <idline>.
  335.  
  336. COMPATIBILITY
  337.      XEDIT: N/A
  338.      KEDIT: N/A
  339.  
  340. DEFAULT
  341.      ON
  342.  
  343. STATUS
  344.      Complete.
  345. **man-end**********************************************************************/
  346. #ifdef HAVE_PROTO
  347. short Position(CHARTYPE *params)
  348. #else
  349. short Position(params)
  350. CHARTYPE *params;
  351. #endif
  352. /***********************************************************************/
  353. {
  354. /*------------------------- external date -----------------------------*/
  355. /*--------------------------- local data ------------------------------*/
  356.  short rc=RC_OK;
  357. /*--------------------------- processing ------------------------------*/
  358. #ifdef TRACE
  359.  trace_function("commset2.c:Position");
  360. #endif
  361.  rc = execute_set_on_off(params,&CURRENT_VIEW->position_status);
  362. #ifdef TRACE
  363.  trace_return();
  364. #endif
  365.  return(rc);
  366. }
  367. /*man-start*********************************************************************
  368. COMMAND
  369.      set prefix - set prefix area attributes
  370.  
  371. SYNTAX
  372.      [SET] PREfix ON [Left|Right] [n [m]]
  373.      [SET] PREfix Nulls [Left|Right] [n [m]]
  374.      [SET] PREfix OFF
  375.      [SET] PREfix Synonym newname oldname
  376.  
  377. DESCRIPTION
  378.      The first form of the SET PREFIX command allows the user to display
  379.      the <prefix area> and optionally to select the position were the 
  380.      prefix should be displayed. 
  381.  
  382.      The second form of the SET PREFIX command is functionally the same
  383.      as the first form. The difference is that when the prefix area
  384.      is displayed with <SET NUMBER> ON, numbers are displyed with leading
  385.      spaces rather than zeros; with <SET NUMBER> OFF, blanks are displayed
  386.      instead of equal signs.
  387.  
  388.      The third form, turns the display of the prefix area off.
  389.      Executed from within the profile, the only effect is that the
  390.      defaults for all files is changed.
  391.      Executed from the command line, the SET PREFIX command changes the
  392.      current window displays to reflect the required options.
  393.  
  394.      The fourth form of the SET PREFIX command allows the user to specify
  395.      a synonym for a prefix command or REXX prefix macro. The 'newname'
  396.      is the command entered in the prefix area and 'oldname' corresponds
  397.      to an existing prefix command or a REXX macro file in the MACROPATH
  398.      ending in .the or whatever the value of <SET MACROEXT> is at the time the
  399.      prefix command is executed. The 'oldname' can also be the fully
  400.      qualified filename of a REXX macro.
  401.  
  402.      The first and second forms of the SET PREFIX command allows the user 
  403.      to specify the width of the prefix area and optionally a gap between 
  404.      the prefix area and the filearea.
  405.      'm' can be specified as an unsigned number between 2 and 20 inclusive.
  406.      'n' can be specified as an unsigned number between 0 and 18, but less
  407.      than the number specified in 'm'.
  408.  
  409. COMPATIBILITY
  410.      XEDIT: Compatible.
  411.      KEDIT: Compatible.
  412.      Specification of prefix width is a THE-only option.
  413.  
  414. DEFAULT
  415.      ON Left 6 0
  416.  
  417. STATUS
  418.      Complete.
  419. **man-end**********************************************************************/
  420. #ifdef HAVE_PROTO
  421. short Prefix(CHARTYPE *params)
  422. #else
  423. short Prefix(params)
  424. CHARTYPE *params;
  425. #endif
  426. /***********************************************************************/
  427. {
  428. /*-------------------------- external data ----------------------------*/
  429. /*--------------------------- local data ------------------------------*/
  430. #define PRE_PARAMS  5
  431.  CHARTYPE *word[PRE_PARAMS+1];
  432.  CHARTYPE strip[PRE_PARAMS];
  433.  CHARTYPE prefix=PREFIX_OFF;
  434.  CHARTYPE previous_prefix=CURRENT_VIEW->prefix;
  435.  unsigned short num_params=0;
  436.  short my_prefix_width=0,my_prefix_gap=0;
  437.  short previous_prefix_width=0;
  438.  short previous_prefix_gap=0;
  439.  short rc=RC_OK;
  440. /*--------------------------- processing ------------------------------*/
  441. #ifdef TRACE
  442.  trace_function("commset2.c:Prefix");
  443. #endif
  444. /*---------------------------------------------------------------------*/
  445. /* Set the default values for the prefix width and gap...              */
  446. /*---------------------------------------------------------------------*/
  447.  if (CURRENT_VIEW)
  448.    {
  449.     previous_prefix_width = CURRENT_VIEW->prefix_width;
  450.     previous_prefix_gap = CURRENT_VIEW->prefix_gap;
  451.    }
  452.  else
  453.    {
  454.     previous_prefix_width = DEFAULT_PREFIX_WIDTH;
  455.     previous_prefix_gap = DEFAULT_PREFIX_GAP;
  456.    }
  457. /*---------------------------------------------------------------------*/
  458. /* Parse the parameters...                                             */
  459. /*---------------------------------------------------------------------*/
  460.  strip[0]=STRIP_BOTH;
  461.  strip[1]=STRIP_BOTH;
  462.  strip[2]=STRIP_BOTH;
  463.  strip[3]=STRIP_BOTH;
  464.  num_params = param_split(params,word,PRE_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  465.  if (equal((CHARTYPE *)"on",word[0],2)
  466.  ||  equal((CHARTYPE *)"nulls",word[0],1))
  467.    {
  468.     if (num_params > 4)
  469.       {
  470.        display_error(2,(CHARTYPE *)"",FALSE);
  471. #ifdef TRACE
  472.        trace_return();
  473. #endif
  474.        return(RC_INVALID_OPERAND);
  475.       }
  476.     if (equal((CHARTYPE *)"left",word[1],1))
  477.        prefix = PREFIX_LEFT;
  478.     else
  479.        if (equal((CHARTYPE *)"right",word[1],1))
  480.           prefix = PREFIX_RIGHT;
  481.        else
  482.           if (num_params == 1)       /* no left/right, default to left */
  483.              prefix = PREFIX_LEFT;
  484.           else
  485.             {
  486.              display_error(1,word[1],FALSE);
  487. #ifdef TRACE
  488.              trace_return();
  489. #endif
  490.              return(RC_INVALID_OPERAND);
  491.             }
  492.     if (equal((CHARTYPE *)"on",word[0],2))
  493.        CURRENT_VIEW->prefix = prefix | PREFIX_ON;
  494.     else
  495.        CURRENT_VIEW->prefix = prefix | PREFIX_NULLS;
  496.     if (num_params > 2)
  497.       {
  498.        if (!valid_positive_integer(word[2]))
  499.          {
  500.           display_error(1,word[2],FALSE);
  501. #ifdef TRACE
  502.           trace_return();
  503. #endif
  504.           return(RC_INVALID_OPERAND);
  505.          }
  506.        my_prefix_width = atoi((DEFCHAR *)word[2]);
  507.        if (my_prefix_width > 20)
  508.          {
  509.           display_error(6,word[2],FALSE);
  510. #ifdef TRACE
  511.           trace_return();
  512. #endif
  513.           return(RC_INVALID_OPERAND);
  514.          }
  515.        if (my_prefix_width < 2)
  516.          {
  517.           display_error(5,word[2],FALSE);
  518. #ifdef TRACE
  519.           trace_return();
  520. #endif
  521.           return(RC_INVALID_OPERAND);
  522.          }
  523.        if (num_params == 3)
  524.            my_prefix_gap = 0;
  525.        else
  526.          {
  527.           if (!valid_positive_integer(word[3]))
  528.             {
  529.              display_error(1,word[3],FALSE);
  530. #ifdef TRACE
  531.              trace_return();
  532. #endif
  533.              return(RC_INVALID_OPERAND);
  534.             }
  535.           my_prefix_gap = atoi((DEFCHAR *)word[3]);
  536.           if (my_prefix_gap >= my_prefix_width)
  537.             {
  538.              display_error(6,word[3],FALSE);
  539. #ifdef TRACE
  540.              trace_return();
  541. #endif
  542.              return(RC_INVALID_OPERAND);
  543.             }
  544.          }
  545.        CURRENT_VIEW->prefix_width = my_prefix_width;
  546.        CURRENT_VIEW->prefix_gap = my_prefix_gap;
  547.       }
  548.    }
  549.  else
  550.    {
  551.     if (equal((CHARTYPE *)"off",word[0],3))
  552.       {
  553.        if (num_params > 1)
  554.          {
  555.           display_error(2,(CHARTYPE *)"",FALSE);
  556. #ifdef TRACE
  557.           trace_return();
  558. #endif
  559.           return(RC_INVALID_OPERAND);
  560.          }
  561.        if (strcmp((DEFCHAR *)word[1],"") == 0)
  562.          {
  563.           CURRENT_VIEW->prefix = PREFIX_OFF;
  564.           switch(CURRENT_VIEW->current_window)
  565.             {
  566.              case WINDOW_FILEAREA:
  567.                   break;
  568.              case WINDOW_PREFIX:
  569.                   CURRENT_VIEW->current_window = WINDOW_FILEAREA;
  570.                   break;
  571.              case WINDOW_COMMAND:
  572.                   CURRENT_VIEW->previous_window = WINDOW_FILEAREA;
  573.                   break;
  574.             }
  575.          }
  576.        else
  577.          {
  578.           display_error(2,word[1],FALSE);
  579. #ifdef TRACE
  580.           trace_return();
  581. #endif
  582.           return(RC_INVALID_OPERAND);
  583.          }
  584.       }
  585.     else
  586.        if (equal((CHARTYPE *)"synonym",word[0],1))
  587.          {
  588.           if (num_params < 3)
  589.             {
  590.              display_error(3,(CHARTYPE *)"",FALSE);
  591. #ifdef TRACE
  592.              trace_return();
  593. #endif
  594.              return(RC_INVALID_OPERAND);
  595.             }
  596.           if (num_params > 3)
  597.             {
  598.              display_error(2,(CHARTYPE *)"",FALSE);
  599. #ifdef TRACE
  600.              trace_return();
  601. #endif
  602.              return(RC_INVALID_OPERAND);
  603.             }
  604.           if (strlen((DEFCHAR *)word[1]) > MAX_PREFIX_WIDTH)
  605.             {
  606.              display_error(37,word[1],FALSE);
  607. #ifdef TRACE
  608.              trace_return();
  609. #endif
  610.              return(RC_INVALID_OPERAND);
  611.             }
  612.           rc = add_prefix_synonym(word[1],word[2]);
  613. #ifdef TRACE
  614.           trace_return();
  615. #endif
  616.           return(rc);
  617.          }
  618.        else
  619.             {
  620.              display_error(1,word[0],FALSE);
  621. #ifdef TRACE
  622.              trace_return();
  623. #endif
  624.              return(RC_INVALID_OPERAND);
  625.             }
  626.    }
  627. /*---------------------------------------------------------------------*/
  628. /* If the new setting for PREFIX is identical with the previous values */
  629. /* don't do anything more.                                             */
  630. /*---------------------------------------------------------------------*/
  631.  if (previous_prefix == CURRENT_VIEW->prefix
  632.  &&  previous_prefix_width == CURRENT_VIEW->prefix_width
  633.  &&  previous_prefix_gap == CURRENT_VIEW->prefix_gap)
  634.    {
  635. #ifdef TRACE
  636.     trace_return();
  637. #endif
  638.     return(RC_OK);
  639.    }
  640. /*---------------------------------------------------------------------*/
  641. /* To get here something has changed, so rebuild the windows and       */
  642. /* display the screen.                                                 */
  643. /*---------------------------------------------------------------------*/
  644.  set_screen_defaults();
  645.  if (set_up_windows(current_screen) != RC_OK)
  646.    {
  647. #ifdef TRACE
  648.     trace_return();
  649. #endif
  650.     return(RC_OK);
  651.    }
  652.  build_screen(current_screen);
  653.  display_screen(current_screen);
  654. #ifdef TRACE
  655.  trace_return();
  656. #endif
  657.  return(RC_OK);
  658. }
  659. /*man-start*********************************************************************
  660. COMMAND
  661.      set printer - define printer spooler name
  662.  
  663. SYNTAX
  664.      [SET] PRINTER spooler
  665.  
  666. DESCRIPTION
  667.      The SET PRINTER command sets up the print spooler name to determine
  668.      where output from the <PRINT> command goes.
  669.  
  670. COMPATIBILITY
  671.      XEDIT: N/A
  672.      KEDIT: Compatible.
  673.  
  674. DEFAULT
  675.      LPT1 - DOS/OS2, lpr - Unix
  676.  
  677. SEE ALSO
  678.      <PRINT>
  679.  
  680. STATUS
  681.      Complete. 
  682. **man-end**********************************************************************/
  683. #ifdef HAVE_PROTO
  684. short THEPrinter(CHARTYPE *params)
  685. #else
  686. short THEPrinter(params)
  687. CHARTYPE *params;
  688. #endif
  689. /***********************************************************************/
  690. {
  691. /*------------------------- external date -----------------------------*/
  692. #if defined(UNIX) || defined(OS2) || defined(EMX)
  693.  extern CHARTYPE *spooler_name;
  694. /*--------------------------- processing ------------------------------*/
  695. #ifdef TRACE
  696.  trace_function("commset2.c:THEPrinter");
  697. #endif
  698.  if ((spooler_name = (CHARTYPE *)(*the_realloc)(spooler_name,strlen((DEFCHAR *)params)+1)) == NULL)
  699.    {
  700.     display_error(30,(CHARTYPE *)"",FALSE);
  701. #ifdef TRACE
  702.     trace_return();
  703. #endif
  704.     return(RC_OUT_OF_MEMORY);
  705.    }
  706.  strcpy((DEFCHAR *)spooler_name,(DEFCHAR *)params);
  707. #endif
  708. #ifdef TRACE
  709.  trace_return();
  710. #endif
  711.  return(RC_OK);
  712. }
  713. /*man-start*********************************************************************
  714. COMMAND
  715.      set pscreen - set physical size of screen
  716.  
  717. SYNTAX
  718.      [SET] PSCReen height [width] [RESET|PRESET]
  719.  
  720. DESCRIPTION
  721.      The SET PSCREEN command allows the user to adjust the size of the
  722.      physical screen to the size specified by 'height' and 'width'.
  723.      
  724.      This command only works in an OS/2 window.
  725.  
  726.      The optional argument [RESET|PRESET] are ignored; they are there
  727.      for Kedit compatibility.
  728.  
  729. COMPATIBILITY
  730.      XEDIT: N/A
  731.      KEDIT: Compatible. Ignores RESET|PRESET argument
  732.  
  733. DEFAULT
  734.      System Dependent
  735.  
  736. STATUS
  737.      Incomplete.
  738. **man-end**********************************************************************/
  739. #ifdef HAVE_PROTO
  740. short Pscreen(CHARTYPE *params)
  741. #else
  742. short Pscreen(params)
  743. CHARTYPE *params;
  744. #endif
  745. /***********************************************************************/
  746. {
  747. /*------------------------- external date -----------------------------*/
  748. /*--------------------------- local data ------------------------------*/
  749. #define PSC_PARAMS  3
  750.  CHARTYPE *word[PSC_PARAMS+1];
  751.  CHARTYPE strip[PSC_PARAMS];
  752.  unsigned short num_params=0;
  753.  int current_cols=COLS,current_lines=LINES;
  754.  short rc=RC_OK;
  755. /*--------------------------- processing ------------------------------*/
  756. #ifdef TRACE
  757.  trace_function("commset2.c:Pscreen");
  758. #endif
  759. /*---------------------------------------------------------------------*/
  760. /* Validate parameters.                                                */
  761. /*---------------------------------------------------------------------*/
  762.  strip[0]=STRIP_BOTH;
  763.  strip[1]=STRIP_BOTH;
  764.  num_params = param_split(params,word,PSC_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  765.  if (num_params < 1)
  766.    {
  767.     display_error(3,(CHARTYPE *)"",FALSE);
  768. #ifdef TRACE
  769.     trace_return();
  770. #endif
  771.     return(RC_INVALID_OPERAND);
  772.    }
  773. /*---------------------------------------------------------------------*/
  774. /* Validate height parameter...                                        */
  775. /*---------------------------------------------------------------------*/
  776.  if ((current_lines = atoi((DEFCHAR *)word[0])) == 0)
  777.    {
  778.     display_error(4,word[0],FALSE);
  779. #ifdef TRACE
  780.     trace_return();
  781. #endif
  782.     return(RC_INVALID_OPERAND);
  783.    }
  784. /*---------------------------------------------------------------------*/
  785. /* Validate width parameter...                                         */
  786. /*---------------------------------------------------------------------*/
  787.  if (num_params > 1)
  788.    {
  789.     if ((current_cols = atoi((DEFCHAR *)word[1])) == 0)
  790.       {
  791.        display_error(4,word[1],FALSE);
  792. #ifdef TRACE
  793.        trace_return();
  794. #endif
  795.        return(RC_INVALID_OPERAND);
  796.       }
  797.    }
  798. #if defined(OS2) || defined(WIN32)
  799.  (void)THE_Resize(current_lines,current_cols);
  800.  (void)THERefresh((CHARTYPE *)"");
  801.  draw_cursor(TRUE);
  802. #endif
  803. #ifdef TRACE
  804.  trace_return();
  805. #endif
  806.  return(rc);
  807. }
  808. /*man-start*********************************************************************
  809. COMMAND
  810.      set reprofile - indicate if profile file to be executed for all files
  811.  
  812. SYNTAX
  813.      [SET] REPROFile ON|OFF
  814.  
  815. DESCRIPTION
  816.      The SET REPROFILE command allows the user to determine if the 
  817.      <profile> file is to reexecuted for files subsequenlty edited.
  818.  
  819. COMPATIBILITY
  820.      XEDIT: N/A
  821.      KEDIT: Compatible.
  822.  
  823. DEFAULT
  824.      OFF
  825.  
  826. SEE ALSO
  827.      <XEDIT>, <EDIT>, <THE>
  828.  
  829. STATUS
  830.      Complete
  831. **man-end**********************************************************************/
  832. #ifdef HAVE_PROTO
  833. short Reprofile(CHARTYPE *params)
  834. #else
  835. short Reprofile(params)
  836. CHARTYPE *params;
  837. #endif
  838. /***********************************************************************/
  839. {
  840. /*-------------------------- external data ----------------------------*/
  841.  extern bool REPROFILEx;
  842. /*--------------------------- local data ------------------------------*/
  843.  short rc=RC_OK;
  844. /*--------------------------- processing ------------------------------*/
  845. #ifdef TRACE
  846.  trace_function("commset2.c:Reprofile");
  847. #endif
  848.  rc = execute_set_on_off(params,&REPROFILEx);
  849. #ifdef TRACE
  850.  trace_return();
  851. #endif
  852.  return(rc);
  853. }
  854. /*man-start*********************************************************************
  855. COMMAND
  856.      set reserved - display a reserved line
  857.  
  858. SYNTAX
  859.      [SET] RESERved *|+|-n [colour] [text|OFF]
  860.  
  861. DESCRIPTION
  862.      The SET RESERVED command reseves a line for the display of arbitrary
  863.      text by the user. The position is determined by +|-n.
  864.      This number, if positive, specifies the line relative from the
  865.      top of the display. A negative number is relative from the
  866.      bottom of the display.
  867.  
  868.      By specifying a line, say +3, then the third line from the top will
  869.      be reserved, with the supplied text being displayed in that line.
  870.  
  871.      The <idline> of a file will always be displayed after any reserved
  872.      lines.
  873.  
  874.      The <status line> is not considered part of the displayable area,
  875.      so any positioning specifications ignore that line.
  876.  
  877.      A <reserved line> can only be turned off by identifying it in the
  878.      same way that it was defined.  If a <reserved line> was added with
  879.      the position specification of -1, it cannot be turned off with
  880.      a position specification of 23, even though both position 
  881.      specifiers result in the same display line.
  882.  
  883.      All reserved lines may be turned of by specifying * as the number
  884.      of lines.
  885.  
  886.      The colour option specifies the colours to use to display the
  887.      reserved line. The format of this colour specifier is the same 
  888.      as for <SET COLOUR>. If no colour is specified, the colour of the
  889.      reserved line will be the colour set by any <SET COLOUR> RESERVED
  890.      command for the view or white on black by default.
  891.  
  892.      It is an error to try to reserve a line which is the same line as
  893.      <SET CURLINE>.
  894.  
  895. COMPATIBILITY
  896.      XEDIT: Compatible.
  897.      KEDIT: Compatible.
  898.  
  899. SEE ALSO
  900.      <SET COLOUR>
  901.  
  902. STATUS
  903.      Complete.
  904. **man-end**********************************************************************/
  905. #ifdef HAVE_PROTO
  906. short Reserved(CHARTYPE *params)
  907. #else
  908. short Reserved(params)
  909. CHARTYPE *params;
  910. #endif
  911. /***********************************************************************/
  912. {
  913. /*------------------------- external data -----------------------------*/
  914.  extern bool curses_started;
  915. /*--------------------------- local data ------------------------------*/
  916. #define RSR_PARAMS  2
  917.  CHARTYPE *word[RSR_PARAMS+1];
  918.  CHARTYPE strip[RSR_PARAMS];
  919.  unsigned short num_params=0;
  920.  short base=0,off=0;
  921.  COLOUR_ATTR attr,save_attr;              /* initialisation done below */
  922.  CHARTYPE *string=NULL;
  923.  short rc=RC_OK;
  924.  unsigned short x=0,y=0;
  925.  LINETYPE new_focus_line=0L;
  926.  bool any_colours=FALSE;
  927. /*--------------------------- processing ------------------------------*/
  928. #ifdef TRACE
  929.  trace_function("commset2.c:Reserved");
  930. #endif
  931. /*---------------------------------------------------------------------*/
  932. /* Initialise attr and save_sttr...                                    */
  933. /*---------------------------------------------------------------------*/
  934.  memset((char *)&attr,0,sizeof(COLOUR_ATTR));
  935.  memset((char *)&save_attr,0,sizeof(COLOUR_ATTR));
  936.  strip[0]=STRIP_BOTH;
  937.  strip[1]=STRIP_NONE;
  938.  num_params = param_split(params,word,RSR_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  939.  if (num_params < 1)
  940.     {
  941.      display_error(3,(CHARTYPE *)"",FALSE);
  942. #ifdef TRACE
  943.      trace_return();
  944. #endif
  945.      return(RC_INVALID_OPERAND);
  946.     }
  947. /*---------------------------------------------------------------------*/
  948. /* First check for the special case of * OFF...                        */
  949. /*---------------------------------------------------------------------*/
  950.  if (strcmp((DEFCHAR *)word[0],"*") == 0
  951.  &&  equal((CHARTYPE *)"OFF",word[1],3))
  952.     CURRENT_FILE->first_reserved = rll_free(CURRENT_FILE->first_reserved);
  953.  else
  954.    {
  955. /*---------------------------------------------------------------------*/
  956. /* Parse the position parameter...                                     */
  957. /*---------------------------------------------------------------------*/
  958.     rc = execute_set_row_position(word[0],&base,&off);
  959.     if (rc != RC_OK)
  960.       {
  961. #ifdef TRACE
  962.        trace_return();
  963. #endif
  964.        return(rc);
  965.       }
  966.     if (equal((CHARTYPE *)"OFF",word[1],3))
  967.        rc = delete_reserved_line(base,off);
  968.     else
  969.       {
  970. /*---------------------------------------------------------------------*/
  971. /* Parse the colour arguments (if any)...                              */
  972. /*---------------------------------------------------------------------*/
  973.        if ((rc = parse_colours(word[1],&attr,&string,TRUE,&any_colours)) != RC_OK)
  974.          {
  975. #ifdef TRACE
  976.           trace_return();
  977. #endif
  978.           return(rc);
  979.          }
  980.        if (!any_colours)
  981.           memcpy(&attr,CURRENT_FILE->attr+ATTR_RESERVED,sizeof(COLOUR_ATTR));
  982. /*---------------------------------------------------------------------*/
  983. /* If the reserved row is the same row as CURLINE, return ERROR.       */
  984. /*---------------------------------------------------------------------*/
  985.        if (calculate_actual_row(CURRENT_VIEW->current_base,
  986.                                 CURRENT_VIEW->current_off,
  987.                                 CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE) ==
  988.            calculate_actual_row(base,off,CURRENT_SCREEN.rows[WINDOW_FILEAREA],FALSE))
  989.          {
  990.           display_error(64,(CHARTYPE *)"- same line as CURLINE",FALSE);
  991. #ifdef TRACE
  992.           trace_return();
  993. #endif
  994.           return(RC_INVALID_ENVIRON);
  995.          }
  996. /*---------------------------------------------------------------------*/
  997. /* If no colours were specified, use the default colour as set by any  */
  998. /* SET COLOUR RESERVED... command.                                     */
  999. /*---------------------------------------------------------------------*/
  1000.        if (memcmp(&attr,&save_attr,sizeof(COLOUR_ATTR)) == 0)
  1001.           rc = add_reserved_line(word[0],string,base,off,CURRENT_FILE->attr+ATTR_RESERVED);
  1002.        else
  1003.           rc = add_reserved_line(word[0],string,base,off,&attr);
  1004.       }
  1005.    }
  1006.  build_screen(current_screen);
  1007.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1008.    {
  1009.     if (curses_started)
  1010.        getyx(CURRENT_WINDOW,y,x);
  1011.     new_focus_line = get_focus_line_in_view(current_screen,CURRENT_VIEW->focus_line,y);
  1012.     if (new_focus_line != CURRENT_VIEW->focus_line)
  1013.       {
  1014.        post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1015.        CURRENT_VIEW->focus_line = new_focus_line;
  1016.        y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,CURRENT_VIEW->current_row);
  1017.        if (curses_started)
  1018.           wmove(CURRENT_WINDOW,y,x);
  1019.        pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1020.       }
  1021.    }
  1022.  display_screen(current_screen);
  1023. #ifdef TRACE
  1024.  trace_return();
  1025. #endif
  1026.  return(rc);
  1027. }
  1028. /*man-start*********************************************************************
  1029. COMMAND
  1030.      set rexxoutput - indicate where REXX output is to go
  1031.  
  1032. SYNTAX
  1033.      [SET] REXXOUTput File|Display n
  1034.  
  1035. DESCRIPTION
  1036.      The SET REXXOUTPUT command indicates where output from the REXX
  1037.      interpreter is to go; either captured to a file in the ring
  1038.      or displayed in a scrolling fashion on the screen.
  1039.  
  1040.      Also specified is the maximum number of lines from the REXX
  1041.      interpreter that are to be displayed or captured. This is
  1042.      particularly useful when a REXX <macro> gets into an infinite
  1043.      loop.
  1044.  
  1045. COMPATIBILITY
  1046.      XEDIT: N/A
  1047.      KEDIT: N/A
  1048.  
  1049. DEFAULT
  1050.      Display 1000
  1051.  
  1052. STATUS
  1053.      Complete.
  1054. **man-end**********************************************************************/
  1055. #ifdef HAVE_PROTO
  1056. short Rexxoutput(CHARTYPE *params)
  1057. #else
  1058. short Rexxoutput(params)
  1059. CHARTYPE *params;
  1060. #endif
  1061. /***********************************************************************/
  1062. {
  1063. /*-------------------------- external data ----------------------------*/
  1064.  extern LINETYPE CAPREXXMAXx;
  1065.  extern bool CAPREXXOUTx;
  1066.  extern bool rexx_output;
  1067. /*--------------------------- local data ------------------------------*/
  1068. #define REX_PARAMS  2
  1069.  CHARTYPE *word[REX_PARAMS+1];
  1070.  CHARTYPE strip[REX_PARAMS];
  1071.  unsigned short num_params=0;
  1072. /*--------------------------- processing ------------------------------*/
  1073. #ifdef TRACE
  1074.  trace_function("commset2.c:Rexxoutput");
  1075. #endif
  1076.  if (rexx_output)
  1077.    {
  1078.     display_error(0,(CHARTYPE *)"Error: Unable to alter REXXOUTPUT settings",FALSE);
  1079. #ifdef TRACE
  1080.     trace_return();
  1081. #endif
  1082.     return(RC_INVALID_OPERAND);
  1083.    }
  1084.  strip[0]=STRIP_BOTH;
  1085.  strip[1]=STRIP_BOTH;
  1086.  num_params = param_split(params,word,REX_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  1087.  if (num_params < 2)
  1088.    {
  1089.     display_error(3,(CHARTYPE *)"",FALSE);
  1090. #ifdef TRACE
  1091.     trace_return();
  1092. #endif
  1093.     return(RC_INVALID_OPERAND);
  1094.    }
  1095.  if (equal((CHARTYPE *)"file",word[0],1))
  1096.     CAPREXXOUTx = TRUE;
  1097.  else
  1098.     if (equal((CHARTYPE *)"display",word[0],1))
  1099.        CAPREXXOUTx = FALSE;
  1100.     else
  1101.       {
  1102.        display_error(1,(CHARTYPE *)word[0],FALSE);
  1103. #ifdef TRACE
  1104.        trace_return();
  1105. #endif
  1106.        return(RC_INVALID_OPERAND);
  1107.       }
  1108.  if (!valid_positive_integer(word[1]))
  1109.    {
  1110.     display_error(4,(CHARTYPE *)word[1],FALSE);
  1111. #ifdef TRACE
  1112.     trace_return();
  1113. #endif
  1114.     return(RC_INVALID_OPERAND);
  1115.    }
  1116.  CAPREXXMAXx =  atol((DEFCHAR *)word[1]);
  1117.  return(RC_OK);
  1118. }
  1119. /*man-start*********************************************************************
  1120. COMMAND
  1121.      set scale - set position and status of scale line on screen
  1122.  
  1123. SYNTAX
  1124.      [SET] SCALe ON|OFF [M[+n|-n]|[+|-]n]
  1125.  
  1126. DESCRIPTION
  1127.      The SET SCALE command sets the position and status of the scale line
  1128.      for the current view.
  1129.  
  1130.      The first form of parameters is:
  1131.  
  1132.      M[+n|-n] 
  1133.      this sets the <scale line> to be relative to the middle of
  1134.      the screen. A positive value adds to the middle line number, 
  1135.      a negative subtracts from it.
  1136.      eg. M+3 on a 24 line screen will be line 15
  1137.          M-5 on a 24 line screen will be line 7
  1138.  
  1139.      The second form of parameters is:
  1140.  
  1141.      [+|-]n
  1142.      this sets the <scale line> to be relative to the top of the
  1143.      screen (if positive or no sign) or relative to the bottom 
  1144.      of the screen if negative.
  1145.      eg. +3 or 3 will set current line to line 3
  1146.          -3 on a 24 line screen will be line 21
  1147.  
  1148.      If the resulting line is outside the bounds of the screen
  1149.      the position of the current line will become the middle line
  1150.      on the screen.
  1151.  
  1152.      It is an error to try to position the SCALE line on the same 
  1153.      line as <SET CURLINE>.
  1154.  
  1155. COMPATIBILITY
  1156.      XEDIT: Compatible.
  1157.      KEDIT: Compatible.
  1158.  
  1159. DEFAULT
  1160.      OFF M+1
  1161.  
  1162. STATUS
  1163.      Complete.
  1164. **man-end**********************************************************************/
  1165. #ifdef HAVE_PROTO
  1166. short Scale(CHARTYPE *params)
  1167. #else
  1168. short Scale(params)
  1169. CHARTYPE *params;
  1170. #endif
  1171. /***********************************************************************/
  1172. {
  1173. /*-------------------------- external data ----------------------------*/
  1174.  extern bool curses_started;
  1175. /*--------------------------- local data ------------------------------*/
  1176. #define SCA_PARAMS  2
  1177.  CHARTYPE *word[SCA_PARAMS+1];
  1178.  CHARTYPE strip[SCA_PARAMS];
  1179.  short num_params=0;
  1180.  short rc=RC_OK;
  1181.  short base=(short)CURRENT_VIEW->scale_base;
  1182.  short off=CURRENT_VIEW->scale_off;
  1183.  bool scalests=FALSE;
  1184.  unsigned short x=0,y=0;
  1185. /*--------------------------- processing ------------------------------*/
  1186. #ifdef TRACE
  1187.  trace_function("commset2.c:Scale");
  1188. #endif
  1189.  strip[0]=STRIP_BOTH;
  1190.  strip[1]=STRIP_BOTH;
  1191.  num_params = param_split(params,word,SCA_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  1192.  if (num_params < 1)
  1193.    {
  1194.     display_error(3,(CHARTYPE *)"",FALSE);
  1195. #ifdef TRACE
  1196.     trace_return();
  1197. #endif
  1198.     return(RC_INVALID_OPERAND);
  1199.    }
  1200. /*---------------------------------------------------------------------*/
  1201. /* Parse the status parameter...                                       */
  1202. /*---------------------------------------------------------------------*/
  1203.  rc = execute_set_on_off(word[0],&scalests);
  1204.  if (rc != RC_OK)
  1205.    {
  1206. #ifdef TRACE
  1207.     trace_return();
  1208. #endif
  1209.     return(rc);
  1210.    }
  1211. /*---------------------------------------------------------------------*/
  1212. /* Parse the position parameter...                                     */
  1213. /*---------------------------------------------------------------------*/
  1214.  if (num_params > 1)
  1215.    {
  1216.     rc = execute_set_row_position(word[1],&base,&off);
  1217.     if (rc != RC_OK)
  1218.       {
  1219. #ifdef TRACE
  1220.        trace_return();
  1221. #endif
  1222.        return(rc);
  1223.       }
  1224.    }
  1225. /*---------------------------------------------------------------------*/
  1226. /* If the SCALE row is the same row as CURLINE and it is being turned  */
  1227. /* on, return ERROR.                                                   */
  1228. /*---------------------------------------------------------------------*/
  1229.  if (calculate_actual_row(CURRENT_VIEW->current_base,
  1230.                           CURRENT_VIEW->current_off,
  1231.                           CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE) ==
  1232.      calculate_actual_row(base,off,CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE)
  1233.  && scalests)
  1234.    {
  1235.     display_error(64,(CHARTYPE *)"- same line as CURLINE",FALSE);
  1236. #ifdef TRACE
  1237.     trace_return();
  1238. #endif
  1239.     return(RC_INVALID_ENVIRON);
  1240.    }
  1241.  CURRENT_VIEW->scale_base = (CHARTYPE)base;
  1242.  CURRENT_VIEW->scale_off = off;
  1243.  CURRENT_VIEW->scale_on = scalests;
  1244.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1245.  build_screen(current_screen);
  1246.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1247.    {
  1248.     if (curses_started)
  1249.        getyx(CURRENT_WINDOW,y,x);
  1250.     CURRENT_VIEW->focus_line = get_focus_line_in_view(current_screen,CURRENT_VIEW->focus_line,y);
  1251.     y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,CURRENT_VIEW->current_row);
  1252.     if (curses_started)
  1253.        wmove(CURRENT_WINDOW,y,x);
  1254.     pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1255.    }
  1256.  display_screen(current_screen);
  1257. #ifdef TRACE
  1258.  trace_return();
  1259. #endif
  1260.  return(RC_OK);
  1261. }
  1262. /*man-start*********************************************************************
  1263. COMMAND
  1264.      set scope - sets which lines are to be excluded from commands
  1265.  
  1266. SYNTAX
  1267.      [SET] SCOPE All|Display
  1268.  
  1269. DESCRIPTION
  1270.      The SET SCOPE command indicates whether lines not displayed as
  1271.      the result of a <SET DISPLAY> or <ALL> command are included in
  1272.      the scope of lines to be acted upon by other THE commands.
  1273.  
  1274. COMPATIBILITY
  1275.      XEDIT: Compatible.
  1276.      KEDIT: Compatible.
  1277.  
  1278. DEFAULT
  1279.      Display
  1280.  
  1281. SEE ALSO
  1282.      <SET DISPLAY>, <SET SELECT>, <ALL>
  1283.  
  1284. STATUS
  1285.      Completed.
  1286. **man-end**********************************************************************/
  1287. #ifdef HAVE_PROTO
  1288. short Scope(CHARTYPE *params)
  1289. #else
  1290. short Scope(params)
  1291. CHARTYPE *params;
  1292. #endif
  1293. /***********************************************************************/
  1294. {
  1295. /*-------------------------- external data ----------------------------*/
  1296. /*--------------------------- local data ------------------------------*/
  1297.  short rc=RC_OK;
  1298. /*--------------------------- processing ------------------------------*/
  1299. #ifdef TRACE
  1300.  trace_function("commset2.c:Scope");
  1301. #endif
  1302.  if (equal((CHARTYPE *)"all",params,1))
  1303.     CURRENT_VIEW->scope_all = TRUE;
  1304.  else
  1305.     if (equal((CHARTYPE *)"display",params,1))
  1306.        CURRENT_VIEW->scope_all = FALSE;
  1307.     else
  1308.       {
  1309.        display_error(1,params,FALSE);
  1310. #ifdef TRACE
  1311.        trace_return();
  1312. #endif
  1313.        return(RC_INVALID_OPERAND);
  1314.       }
  1315. #ifdef TRACE
  1316.  trace_return();
  1317. #endif
  1318.  return(rc);
  1319. }
  1320. /*man-start*********************************************************************
  1321. COMMAND
  1322.      set screen - specify number of screens displayed
  1323.  
  1324. SYNTAX
  1325.      [SET] SCReen n [Horizontal|Vertical]
  1326.  
  1327. DESCRIPTION
  1328.      The SET SCREEN command specifies the number of views of file(s) to
  1329.      display on screen at once. If the number of views specified is 2
  1330.      and only one file is currently in the <ring>, two views of the
  1331.      same file are displayed.
  1332.  
  1333. COMPATIBILITY
  1334.      XEDIT: Does not support Size,Width or Define options.
  1335.      KEDIT: Does not support Size option.
  1336.      Only 2 screens are supported.
  1337.  
  1338. DEFAULT
  1339.      1
  1340.  
  1341. STATUS
  1342.      Complete.
  1343. **man-end**********************************************************************/
  1344. #ifdef HAVE_PROTO
  1345. short THEScreen(CHARTYPE *params)
  1346. #else
  1347. short THEScreen(params)
  1348. CHARTYPE *params;
  1349. #endif
  1350. /***********************************************************************/
  1351. {
  1352. /*-------------------------- external data ----------------------------*/
  1353.  extern WINDOW *divider;
  1354.  extern VIEW_DETAILS *vd_first;
  1355.  extern CHARTYPE number_of_views;
  1356.  extern CHARTYPE display_screens;
  1357.  extern bool horizontal;
  1358.  extern bool curses_started;
  1359. /*--------------------------- local data ------------------------------*/
  1360. #define SCR_PARAMS  2
  1361.  CHARTYPE *word[SCR_PARAMS+1];
  1362.  CHARTYPE strip[SCR_PARAMS];
  1363.  register short i=0;
  1364.  unsigned short num_params=0,num_views=0;
  1365.  CHARTYPE save_display_screens=0;
  1366.  bool save_horizontal=FALSE;
  1367.  int horiz=(-1);
  1368.  VIEW_DETAILS *save_current_view=NULL;
  1369.  CHARTYPE save_current_screen=0;
  1370.  short rc=RC_OK;
  1371. /*--------------------------- processing ------------------------------*/
  1372. #ifdef TRACE
  1373.  trace_function("commset2.c:THEScreen");
  1374. #endif
  1375.  strip[0]=STRIP_BOTH;
  1376.  strip[1]=STRIP_BOTH;
  1377.  num_params = param_split(params,word,SCR_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  1378.  if (num_params == 0)
  1379.    {
  1380.     display_error(3,(CHARTYPE *)"",FALSE);
  1381. #ifdef TRACE
  1382.     trace_return();
  1383. #endif
  1384.     return(RC_INVALID_OPERAND);
  1385.    }
  1386.  if (!valid_positive_integer(word[0]))
  1387.    {
  1388.     display_error(1,word[0],FALSE);
  1389. #ifdef TRACE
  1390.     trace_return();
  1391. #endif
  1392.     return(RC_INVALID_OPERAND);
  1393.    }
  1394.  if ((num_views = atoi((DEFCHAR *)word[0])) > MAX_SCREENS)
  1395.    {
  1396.     display_error(6,word[0],FALSE);
  1397. #ifdef TRACE
  1398.     trace_return();
  1399. #endif
  1400.     return(RC_INVALID_OPERAND);
  1401.    }
  1402.  if (num_views == 1)
  1403.     horiz = TRUE;
  1404.  else
  1405.    {
  1406.     if (equal((CHARTYPE *)"horizontal",word[1],1)
  1407.     || strcmp((DEFCHAR *)word[1],"") == 0)
  1408.        horiz = TRUE;
  1409.     if (equal((CHARTYPE *)"vertical",word[1],1))
  1410.        horiz = FALSE;
  1411.     if (horiz == (-1))
  1412.       {
  1413.        display_error(1,word[1],FALSE);
  1414. #ifdef TRACE
  1415.        trace_return();
  1416. #endif
  1417.        return(RC_INVALID_OPERAND);
  1418.       }
  1419.    }
  1420. /*---------------------------------------------------------------------*/
  1421. /* Set the global variable display_screens to indicate the number of   */
  1422. /* screens currently displayed and the orientation of those screens    */
  1423. /* Save the old values first so we know how the screens were oriented. */
  1424. /*---------------------------------------------------------------------*/
  1425.  save_display_screens = display_screens;
  1426.  save_horizontal = horizontal;
  1427.  
  1428.  display_screens = (CHARTYPE)num_views;
  1429.  horizontal=(bool)horiz;
  1430. /*---------------------------------------------------------------------*/
  1431. /* If there is no change to the screens, exit.                         */
  1432. /*---------------------------------------------------------------------*/
  1433.  if (display_screens == save_display_screens
  1434.  &&  horizontal == save_horizontal)
  1435.    {
  1436. #ifdef TRACE
  1437.     trace_return();
  1438. #endif
  1439.     return(RC_OK);
  1440.    }
  1441.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1442. /*---------------------------------------------------------------------*/
  1443. /* Save the screen coordinates for later retrieval.                    */
  1444. /*---------------------------------------------------------------------*/
  1445.  if (curses_started)
  1446.    {
  1447.     getyx(CURRENT_WINDOW_FILEAREA,CURRENT_VIEW->y[WINDOW_FILEAREA],CURRENT_VIEW->x[WINDOW_FILEAREA]);
  1448.     if (CURRENT_WINDOW_PREFIX != NULL)
  1449.        getyx(CURRENT_WINDOW_PREFIX,CURRENT_VIEW->y[WINDOW_PREFIX],CURRENT_VIEW->x[WINDOW_PREFIX]);
  1450.    }
  1451. /*---------------------------------------------------------------------*/
  1452. /* Set up the screen views correctly so that when we create the new    */
  1453. /* window for each screen, the screens have a view to point to...      */
  1454. /*---------------------------------------------------------------------*/
  1455.  switch(display_screens)
  1456.    {
  1457.     case 1:                         /* now have only 1 screen (from 2) */
  1458.            save_current_view = CURRENT_VIEW;
  1459.            if (CURRENT_SCREEN.screen_view->file_for_view == OTHER_SCREEN.screen_view->file_for_view)
  1460.              {
  1461.               CURRENT_VIEW = OTHER_SCREEN.screen_view;
  1462.               CURRENT_FILE->file_views--;
  1463.               free_a_view();
  1464.               CURRENT_VIEW = save_current_view;
  1465.              }
  1466.            if (divider != (WINDOW *)NULL)
  1467.              {
  1468.               delwin(divider);
  1469.               divider = NULL;
  1470.              }
  1471.            current_screen = 0;
  1472.            CURRENT_SCREEN.screen_view = CURRENT_VIEW = save_current_view;
  1473.            OTHER_SCREEN.screen_view = NULL;
  1474.            break;
  1475.     case 2:                             /* now have 2 screens (from 1) */
  1476.            save_current_view = CURRENT_VIEW;
  1477.            save_current_screen = current_screen;
  1478.            current_screen = other_screen;     /* make other screen current */
  1479.            if (number_of_views == 1)
  1480.              {
  1481.               if ((rc = defaults_for_other_files(PREVIOUS_VIEW)) != RC_OK)
  1482.                 {
  1483. #ifdef TRACE
  1484.                  trace_return();
  1485. #endif
  1486.                  return(rc);
  1487.                 }
  1488.               CURRENT_FILE = save_current_view->file_for_view;
  1489.               CURRENT_FILE->file_views++;
  1490.              }
  1491.            else
  1492.              {
  1493.               if (NEXT_VIEW == (VIEW_DETAILS *)NULL)
  1494.                  CURRENT_VIEW = vd_first;
  1495.               else
  1496.                  CURRENT_VIEW = NEXT_VIEW;
  1497.              }
  1498.            CURRENT_SCREEN.screen_view = CURRENT_VIEW;
  1499.            CURRENT_VIEW = save_current_view;
  1500.            current_screen = save_current_screen;
  1501.            break;
  1502.    }
  1503.  
  1504.  set_screen_defaults();
  1505.  if (curses_started)
  1506.    {
  1507.     for (i=0;i<display_screens;i++)
  1508.       {
  1509.        if ((rc = set_up_windows(i)) != RC_OK)
  1510.          {
  1511. #ifdef TRACE
  1512.           trace_return();
  1513. #endif
  1514.           return(rc);
  1515.          }
  1516.        if (screen[i].screen_view->prefix)
  1517.           wmove(screen[i].win[WINDOW_PREFIX],
  1518.                 screen[i].screen_view->y[WINDOW_PREFIX],screen[i].screen_view->x[WINDOW_PREFIX]);
  1519.        wmove(screen[i].win[WINDOW_FILEAREA],
  1520.              screen[i].screen_view->y[WINDOW_FILEAREA],screen[i].screen_view->x[WINDOW_FILEAREA]);
  1521.       }
  1522.    }
  1523.  
  1524.  if (!horizontal
  1525.  && display_screens > 1
  1526.  && curses_started)
  1527.    {
  1528. /*    redraw_window(divider);*/
  1529.     touchwin(divider);
  1530.     wnoutrefresh(divider);
  1531.    }
  1532.  
  1533.  if (display_screens > 1)
  1534.    {
  1535.     pre_process_line(OTHER_VIEW,OTHER_VIEW->focus_line,(LINE *)NULL);
  1536.     (void)prepare_view(other_screen);
  1537.     display_screen(other_screen);
  1538.     show_heading(other_screen);
  1539.    }
  1540.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1541.  (void)prepare_view(current_screen);
  1542.  display_screen(current_screen);
  1543.  
  1544. #ifdef TRACE
  1545.  trace_return();
  1546. #endif
  1547.  return(RC_OK);
  1548. }
  1549. /*man-start*********************************************************************
  1550. COMMAND
  1551.      set select - sets the selection level for the specified lines
  1552.  
  1553. SYNTAX
  1554.      [SET] SELect [+|-]n [target]
  1555.  
  1556. DESCRIPTION
  1557.      The SET SELECT command sets the selection level for the indicated
  1558.      lines equal to 'n' (if no signs are specified) or adds or subtracts
  1559.      n from the selection level currently set for the lines in the
  1560.      target.
  1561.  
  1562. COMPATIBILITY
  1563.      XEDIT: Compatible.
  1564.      KEDIT: Compatible.
  1565.  
  1566. DEFAULT
  1567.      0
  1568.  
  1569. SEE ALSO
  1570.      <SET SCOPE>, <SET DISPLAY>, <ALL>
  1571.  
  1572. STATUS
  1573.      Complete.
  1574. **man-end**********************************************************************/
  1575. #ifdef HAVE_PROTO
  1576. short Select(CHARTYPE *params)
  1577. #else
  1578. short Select(params)
  1579. CHARTYPE *params;
  1580. #endif
  1581. /***********************************************************************/
  1582. {
  1583. /*-------------------------- external data ----------------------------*/
  1584. /*--------------------------- local data ------------------------------*/
  1585.  short rc=RC_OK;
  1586. #define SEL_PARAMS  2
  1587.  CHARTYPE *word[SEL_PARAMS+1];
  1588.  CHARTYPE strip[SEL_PARAMS];
  1589.  LINETYPE true_line=0L;
  1590.  short num_params=0;
  1591.  bool relative=FALSE;
  1592.  short off=0;
  1593. /*--------------------------- processing ------------------------------*/
  1594. #ifdef TRACE
  1595.  trace_function("commset2.c:Select");
  1596. #endif
  1597.  strip[0]=STRIP_BOTH;
  1598.  strip[1]=STRIP_BOTH;
  1599.  num_params = param_split(params,word,SEL_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  1600.  if (num_params < 1)
  1601.    {
  1602.     display_error(3,(CHARTYPE *)"",FALSE);
  1603. #ifdef TRACE
  1604.     trace_return();
  1605. #endif
  1606.     return(RC_INVALID_OPERAND);
  1607.    }
  1608. /*---------------------------------------------------------------------*/
  1609. /* Parse the first parameter...                                        */
  1610. /*---------------------------------------------------------------------*/
  1611. /* Determine if the selection level is relative to the existing value  */
  1612. /* or is an absolute value.                                            */
  1613. /*---------------------------------------------------------------------*/
  1614.  if (*(word[0]) == '-'
  1615.  ||  *(word[0]) == '+')
  1616.     relative = TRUE;
  1617.  else
  1618.     relative = FALSE;
  1619. /*---------------------------------------------------------------------*/
  1620. /* Get the value, positive or negative.                                */
  1621. /*---------------------------------------------------------------------*/
  1622.  if (!valid_integer(word[0]))
  1623.    {
  1624.     display_error(1,word[0],FALSE);
  1625. #ifdef TRACE
  1626.     trace_return();
  1627. #endif
  1628.     return(RC_INVALID_OPERAND);
  1629.    }
  1630.  off = atoi((DEFCHAR *)word[0]);
  1631. /*---------------------------------------------------------------------*/
  1632. /* Parse the next parameter...                                         */
  1633. /*---------------------------------------------------------------------*/
  1634.  true_line = get_true_line(TRUE);
  1635. /*---------------------------------------------------------------------*/
  1636. /* If no target specified, just apply to the current line...           */
  1637. /*---------------------------------------------------------------------*/
  1638.  if (num_params == 1)
  1639.     word[1] = (CHARTYPE *)"1";
  1640. #if 0
  1641.  initialise_target(&target);
  1642.  if ((rc = validate_target(word[1],&target,target_type,get_true_line(TRUE),TRUE,TRUE)) != RC_OK)
  1643.    {
  1644.     free_target(&target);
  1645. #ifdef TRACE
  1646.     trace_return();
  1647. #endif
  1648.     return(rc);
  1649.    }
  1650.  num_lines = target.num_lines;
  1651.  true_line = target.true_line;
  1652.  direction = (target.num_lines<0) ? DIRECTION_BACKWARD : DIRECTION_FORWARD;
  1653.  free_target(&target);
  1654.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1655. /*---------------------------------------------------------------------*/
  1656. /* Get the current line from which to begin changing the select level. */
  1657. /*---------------------------------------------------------------------*/
  1658.  curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,true_line,CURRENT_FILE->number_lines);
  1659. /*---------------------------------------------------------------------*/
  1660. /* For the number of lines affected, change the select level if the    */
  1661. /* line is in scope.                                                   */
  1662. /*---------------------------------------------------------------------*/
  1663.  for (i=0;i<num_lines;i++)
  1664.    {
  1665.     if (in_scope(CURRENT_VIEW,curr) || CURRENT_VIEW->scope_all)
  1666.       {
  1667.        if (relative)
  1668.          {
  1669.           if (((short)curr->select + off) > 255)
  1670.              curr->select = 255;
  1671.           else
  1672.              if (((short)curr->select + off) < 0)
  1673.                 curr->select = 0;
  1674.              else
  1675.                 curr->select += off;
  1676.          }
  1677.        else
  1678.           curr->select = off;
  1679.       }
  1680.     if (direction == DIRECTION_FORWARD)
  1681.        curr = curr->next;
  1682.     else
  1683.        curr = curr->prev;
  1684.    }
  1685. #else
  1686.  rc = execute_select(word[1],relative,off);
  1687. #endif
  1688. /*---------------------------------------------------------------------*/
  1689. /* If we are on the command line and the result of this statement means*/
  1690. /* that the current line is no longer in scope, we need to make the    */
  1691. /* current line and possibly the focus line the next line in scope.    */
  1692. /*---------------------------------------------------------------------*/
  1693.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  1694.    {
  1695.     CURRENT_VIEW->current_line = find_next_in_scope(CURRENT_VIEW,NULL,true_line,DIRECTION_FORWARD);
  1696.     build_screen(current_screen);
  1697.     if (!line_in_view(current_screen,CURRENT_VIEW->focus_line))
  1698.       {
  1699.        CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
  1700.        pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1701.       }
  1702.    }
  1703.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1704.  build_screen(current_screen);
  1705.  display_screen(current_screen);
  1706.  
  1707. #ifdef TRACE
  1708.  trace_return();
  1709. #endif
  1710.  return(rc);
  1711. }
  1712. /*man-start*********************************************************************
  1713. COMMAND
  1714.      set shadow - determines if shadow lines are displayed or not
  1715.  
  1716. SYNTAX
  1717.      [SET] SHADOW ON|OFF
  1718.  
  1719. DESCRIPTION
  1720.      The SET SHADOW command indicates whether <shadow line>s are to be
  1721.      displayed.
  1722.  
  1723. COMPATIBILITY
  1724.      XEDIT: Compatible.
  1725.      KEDIT: Compatible.
  1726.  
  1727. DEFAULT
  1728.      ON
  1729.  
  1730. SEE ALSO
  1731.      <SET DISPLAY>, <SET SELECT>, <ALL>
  1732.  
  1733. STATUS
  1734.      Completed.
  1735. **man-end**********************************************************************/
  1736. #ifdef HAVE_PROTO
  1737. short Shadow(CHARTYPE *params)
  1738. #else
  1739. short Shadow(params)
  1740. CHARTYPE *params;
  1741. #endif
  1742. /***********************************************************************/
  1743. {
  1744. /*-------------------------- external data ----------------------------*/
  1745. /*--------------------------- local data ------------------------------*/
  1746.  short rc=RC_OK;
  1747. /*--------------------------- processing ------------------------------*/
  1748. #ifdef TRACE
  1749.  trace_function("commset2.c:Shadow");
  1750. #endif
  1751.  rc = execute_set_on_off(params,&CURRENT_VIEW->shadow);
  1752.  if (rc == RC_OK)
  1753.    {
  1754.     build_screen(current_screen);
  1755.     display_screen(current_screen);
  1756.    }
  1757. #ifdef TRACE
  1758.  trace_return();
  1759. #endif
  1760.  return(rc);
  1761. }
  1762. /*man-start*********************************************************************
  1763. COMMAND
  1764.      set slk - set Soft Label Key definitions
  1765.  
  1766. SYNTAX
  1767.      [SET] SLK n|OFF [text]
  1768.  
  1769. DESCRIPTION
  1770.      The SET SLK command allows the user to specify a short text
  1771.      description to be displayed on the bottom of the screen, using
  1772.      the terminal's built-in Soft Label Keys, or the last line of
  1773.      the screen.
  1774.  
  1775.      The 'n' argument of the command represents the label
  1776.      number from left to right, with the first label numbered 1.
  1777.  
  1778.      'OFF' turns off display of the Soft Label Keys. This is the same as
  1779.      executing [SET] SLK n with no optional text for each label
  1780.      displayed.
  1781.  
  1782.      The main use for this command is to describe the function assigned
  1783.      to a function key, in place of a <reserved line>.
  1784.  
  1785.      On those platforms that support a pointing device, clicking the
  1786.      left mouse button on the Soft Label Key, is equivalent to pressing
  1787.      the associated function key.
  1788.  
  1789.      The number of Soft Label Keys displayed is dependent on which
  1790.      curses library THE is using.  PDCurses can display 10 keys with
  1791.      the length of the 'text' argument 7 characters on a screen that
  1792.      is 80 columns wide.  The number of characters that can be 
  1793.      displayed increases with the width of the screen.
  1794.      Other curses implementations, limit the number of Soft Label Keys
  1795.      to 8, with a text width of 8 characters.  Some curses 
  1796.      implementations do not support Soft Label Keys.
  1797.  
  1798. COMPATIBILITY
  1799.      XEDIT: N/A
  1800.      KEDIT: N/A
  1801.  
  1802. DEFAULT
  1803.      OFF
  1804.  
  1805. SEE ALSO
  1806.      <SET COLOR>
  1807.  
  1808. STATUS
  1809.      Complete.
  1810. **man-end**********************************************************************/
  1811. #ifdef HAVE_PROTO
  1812. short Slk(CHARTYPE *params)
  1813. #else
  1814. short Slk(params)
  1815. CHARTYPE *params;
  1816. #endif
  1817. /***********************************************************************/
  1818. {
  1819. /*-------------------------- external data ----------------------------*/
  1820. extern bool SLKx;
  1821. /*--------------------------- local data ------------------------------*/
  1822. #define SLK_PARAMS  2
  1823.  CHARTYPE *word[SEL_PARAMS+1];
  1824.  CHARTYPE strip[SEL_PARAMS];
  1825.  short num_params=0;
  1826.  short rc=RC_OK;
  1827.  short key=0;
  1828. /*--------------------------- processing ------------------------------*/
  1829. #ifdef TRACE
  1830.  trace_function("commset2.c:Slk");
  1831. #endif
  1832. #if defined(HAVE_SLK_INIT)
  1833.  if (SLKx)
  1834.    {
  1835.     strip[0]=STRIP_BOTH;
  1836.     strip[1]=STRIP_NONE;
  1837.     num_params = param_split(params,word,SLK_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  1838.     if (num_params < 1)
  1839.       {
  1840.        display_error(3,(CHARTYPE *)"",FALSE);
  1841. #ifdef TRACE
  1842.        trace_return();
  1843. #endif
  1844.        return(RC_INVALID_OPERAND);
  1845.       }
  1846.     key = atoi((DEFCHAR*)word[0]);
  1847.     if (key == 0)
  1848.       {
  1849.        display_error(1,word[0],FALSE);
  1850. #ifdef TRACE
  1851.        trace_return();
  1852. #endif
  1853.        return(RC_INVALID_OPERAND);
  1854.       }
  1855.     if (key > MAX_SLK)
  1856.       {
  1857.        display_error(2,word[0],FALSE);
  1858. #ifdef TRACE
  1859.        trace_return();
  1860. #endif
  1861.        return(RC_INVALID_OPERAND);
  1862.       }
  1863.     slk_set(key,(DEFCHAR*)word[1],1);
  1864.     slk_noutrefresh();
  1865.    }
  1866.  else
  1867.    {
  1868.     display_error(82,(CHARTYPE*)"- use -k command line switch",FALSE);
  1869.     rc = RC_INVALID_OPERAND;
  1870.    }
  1871. #else
  1872.  display_error(82,(CHARTYPE*)"",FALSE);
  1873.  rc = RC_INVALID_OPERAND;
  1874. #endif
  1875. #ifdef TRACE
  1876.  trace_return();
  1877. #endif
  1878.  return(rc);
  1879. }
  1880. /*man-start*********************************************************************
  1881. COMMAND
  1882.      set span - specify if a string target can span multiple lines
  1883.  
  1884. SYNTAX
  1885.      [SET] SPAN ON|OFF [Blank|Noblank [n|*]]
  1886.  
  1887. DESCRIPTION
  1888.      The SET SPAN set command determines if a character string that is
  1889.      the subject of a target search can span more than one line of the
  1890.      file.
  1891.  
  1892. COMPATIBILITY
  1893.      XEDIT: Compatible.
  1894.      KEDIT: N/A
  1895.  
  1896. DEFAULT
  1897.      OFF Blank 2
  1898.  
  1899. STATUS
  1900.      Incomplete.
  1901. **man-end**********************************************************************/
  1902. #ifdef HAVE_PROTO
  1903. short Span(CHARTYPE *params)
  1904. #else
  1905. short Span(params)
  1906. CHARTYPE *params;
  1907. #endif
  1908. /***********************************************************************/
  1909. {
  1910. /*-------------------------- external data ----------------------------*/
  1911. /*--------------------------- local data ------------------------------*/
  1912.  short rc=RC_OK;
  1913. /*--------------------------- processing ------------------------------*/
  1914. #ifdef TRACE
  1915.  trace_function("commset2.c:Span");
  1916. #endif
  1917.  display_error(0,(CHARTYPE *)"This command not yet implemented",FALSE);
  1918. #ifdef TRACE
  1919.  trace_return();
  1920. #endif
  1921.  return(rc);
  1922. }
  1923. /*man-start*********************************************************************
  1924. COMMAND
  1925.      set spill - specify if a string target can span multiple lines
  1926.  
  1927. SYNTAX
  1928.      [SET] SPILL ON|OFF|WORD
  1929.  
  1930. DESCRIPTION
  1931.      The SET SPILL set command determines how characters are spilt
  1932.      off the end of a line when the length of the line exceeds the
  1933.      truncation column.
  1934.  
  1935. COMPATIBILITY
  1936.      XEDIT: Compatible.
  1937.      KEDIT: N/A
  1938.  
  1939. DEFAULT
  1940.      OFF
  1941.  
  1942. STATUS
  1943.      Incomplete.
  1944. **man-end**********************************************************************/
  1945. #ifdef HAVE_PROTO
  1946. short Spill(CHARTYPE *params)
  1947. #else
  1948. short Spill(params)
  1949. CHARTYPE *params;
  1950. #endif
  1951. /***********************************************************************/
  1952. {
  1953. /*-------------------------- external data ----------------------------*/
  1954. /*--------------------------- local data ------------------------------*/
  1955.  short rc=RC_OK;
  1956. /*--------------------------- processing ------------------------------*/
  1957. #ifdef TRACE
  1958.  trace_function("commset2.c:Spill");
  1959. #endif
  1960.  display_error(0,(CHARTYPE *)"This command not yet implemented",FALSE);
  1961. #ifdef TRACE
  1962.  trace_return();
  1963. #endif
  1964.  return(rc);
  1965. }
  1966. /*man-start*********************************************************************
  1967. COMMAND
  1968.      set statusline - set position of status line
  1969.  
  1970. SYNTAX
  1971.      [SET] STATUSLine Top|Bottom|Off|GUI
  1972.  
  1973. DESCRIPTION
  1974.  
  1975.      The SET STATUSLINE command determines the position of the 
  1976.      <status line> for the editing session. TOP will place the status 
  1977.      line on the first line of the screen; BOTTOM will place the status 
  1978.      line on the last line of the screen; OFF turns off the display of
  1979.      the status line.
  1980.  
  1981.      The GUI option is only meaningful for those platforms that support
  1982.      a separate status line window. If specified for non-GUI ports, the
  1983.      GUI option is equivalent to OFF.
  1984.  
  1985. COMPATIBILITY
  1986.      XEDIT: N/A
  1987.      KEDIT: Compatible.
  1988.             Added GUI option for THEdit port.
  1989.  
  1990. DEFAULT
  1991.      Bottom
  1992.  
  1993. STATUS
  1994.      Complete
  1995. **man-end**********************************************************************/
  1996. #ifdef HAVE_PROTO
  1997. short Statusline(CHARTYPE *params)
  1998. #else
  1999. short Statusline(params)
  2000. CHARTYPE *params;
  2001. #endif
  2002. /***********************************************************************/
  2003. {
  2004. /*-------------------------- external data ----------------------------*/
  2005.  extern ROWTYPE STATUSLINEx;
  2006.  extern CHARTYPE display_screens;
  2007.  extern bool curses_started;
  2008.  extern bool horizontal;
  2009.  extern WINDOW *divider;
  2010. /*--------------------------- local data ------------------------------*/
  2011.  CHARTYPE stat_place='?';
  2012.  short rc=RC_OK;
  2013. /*--------------------------- processing ------------------------------*/
  2014. #ifdef TRACE
  2015.  trace_function("commset2.c:Statusline");
  2016. #endif
  2017.  if (equal((CHARTYPE *)"top",params,1))
  2018.     stat_place='T';
  2019.  if (equal((CHARTYPE *)"bottom",params,1))
  2020.     stat_place='B';
  2021.  if (equal((CHARTYPE *)"off",params,2))
  2022.     stat_place='O';
  2023.  if (equal((CHARTYPE *)"gui",params,3))
  2024.    {
  2025.     stat_place='G';
  2026. #ifdef MSWIN
  2027.     SetStatusBar(1);
  2028. #endif
  2029.    }
  2030. #ifdef MSWIN
  2031.  else
  2032.    {
  2033.     SetStatusBar(0);
  2034.    }
  2035. #endif
  2036.  if (stat_place=='?')
  2037.    {
  2038.     display_error(1,(CHARTYPE *)params,FALSE);
  2039. #ifdef TRACE
  2040.     trace_return();
  2041. #endif
  2042.     return(RC_INVALID_OPERAND);
  2043.    }
  2044. /*---------------------------------------------------------------------*/
  2045. /* If the setting supplied is the same as the current setting, just    */
  2046. /* return without doing anything.                                      */
  2047. /*---------------------------------------------------------------------*/
  2048.  if (stat_place == STATUSLINEx)
  2049.    {
  2050. #ifdef TRACE
  2051.     trace_return();
  2052. #endif
  2053.     return(RC_OK);
  2054.    }
  2055. /*---------------------------------------------------------------------*/
  2056. /* Now we need to move the windows around.                             */
  2057. /*---------------------------------------------------------------------*/
  2058.  STATUSLINEx = stat_place;
  2059. /*---------------------------------------------------------------------*/
  2060. /* Redefine the screen sizes and recreate statusline window...         */
  2061. /*---------------------------------------------------------------------*/
  2062.  set_screen_defaults();
  2063.  if (curses_started)
  2064.    {
  2065.     if (create_statusline_window() != RC_OK)
  2066.       {
  2067. #ifdef TRACE
  2068.        trace_return();
  2069. #endif
  2070.        return(rc);
  2071.       }
  2072.    }
  2073. /*---------------------------------------------------------------------*/
  2074. /* Recreate windows for other screen (if there is one)...              */
  2075. /*---------------------------------------------------------------------*/
  2076.  if (display_screens > 1)
  2077.    {
  2078.     if (curses_started)
  2079.       {
  2080.        if (set_up_windows((current_screen==0) ? 1 : 0) != RC_OK)
  2081.          {
  2082. #ifdef TRACE
  2083.           trace_return();
  2084. #endif
  2085.           return(rc);
  2086.          }
  2087.        if (!horizontal)
  2088.          {
  2089. /*          redraw_window(divider); */
  2090.           touchwin(divider);
  2091.           wnoutrefresh(divider);
  2092.          }
  2093.       }
  2094.     build_screen(other_screen);
  2095.     display_screen(other_screen);
  2096.    }
  2097. /*---------------------------------------------------------------------*/
  2098. /* Recreate windows for the current screen...                          */
  2099. /*---------------------------------------------------------------------*/
  2100.  if (curses_started)
  2101.    {
  2102.     if (set_up_windows(current_screen) != RC_OK)
  2103.       {
  2104. #ifdef TRACE
  2105.        trace_return();
  2106. #endif
  2107.        return(rc);
  2108.       }
  2109.    }
  2110.  build_screen(current_screen);
  2111.  display_screen(current_screen);
  2112. #ifdef TRACE
  2113.  trace_return();
  2114. #endif
  2115.  return(rc);
  2116. }
  2117. /*man-start*********************************************************************
  2118. COMMAND
  2119.      set stay - set condition of cursor position after CHANGE/LOCATE commands
  2120.  
  2121. SYNTAX
  2122.      [SET] STAY ON|OFF
  2123.  
  2124. DESCRIPTION
  2125.      The SET STAY set command determines what line is displayed as the 
  2126.      current line after an unsuccessful <LOCATE> or successful <CHANGE>
  2127.      command.
  2128.  
  2129.      With STAY ON, the <current line> remains where it currently is. 
  2130.  
  2131.      With STAY OFF, after an unsuccessful <LOCATE>, the <current line>
  2132.      becomes the <Bottom-of-File line> (or <Top-of-File line> if direction 
  2133.      is backwards).
  2134.  
  2135.      After a successful <CHANGE>, the <current line> is the last
  2136.      line affected by the <CHANGE> command.
  2137.  
  2138. COMPATIBILITY
  2139.      XEDIT: Compatible.
  2140.      KEDIT: Compatible.
  2141.  
  2142. DEFAULT
  2143.      ON
  2144.  
  2145. STATUS
  2146.      Complete
  2147. **man-end**********************************************************************/
  2148. #ifdef HAVE_PROTO
  2149. short Stay(CHARTYPE *params)
  2150. #else
  2151. short Stay(params)
  2152. CHARTYPE *params;
  2153. #endif
  2154. /***********************************************************************/
  2155. {
  2156. /*-------------------------- external data ----------------------------*/
  2157. /*--------------------------- local data ------------------------------*/
  2158.  short rc=RC_OK;
  2159. /*--------------------------- processing ------------------------------*/
  2160. #ifdef TRACE
  2161.  trace_function("commset2.c:Stay");
  2162. #endif
  2163.  rc = execute_set_on_off(params,&CURRENT_VIEW->stay);
  2164. #ifdef TRACE
  2165.  trace_return();
  2166. #endif
  2167.  return(rc);
  2168. }
  2169. /*man-start*********************************************************************
  2170. COMMAND
  2171.      set synonym - define synonyms for commands
  2172.  
  2173. SYNTAX
  2174.      [SET] SYNonym ON|OFF
  2175.      [SET] SYNonym [LINEND char] newname [n] definition
  2176.  
  2177. DESCRIPTION
  2178.      The SET SYNONYM command allows the user to define synonyms for 
  2179.      commands or macros.
  2180.  
  2181.      The first format indicates if synonym processing is to be performed.
  2182.  
  2183.      The second format defines a command synonym.
  2184.  
  2185.      The synonym is 'newname', which effectively adds a new THE
  2186.      command with the definition specified by 'definition'.  The 'n'
  2187.      parameter defines the minimum length of the abbreviation for
  2188.      the new command
  2189.      An optional LINEND character can be specified prior to 'newname' 
  2190.      if the 'definition' contains multiple commands.
  2191.  
  2192.      'definition' can be of the form:
  2193.      [REXX] command [args] [#command [args] [...]]
  2194.      (where # represents the LINEND character specified prior to
  2195.      'newname')
  2196.  
  2197.      If the optional keyword; 'REXX', is supplied, the remainder of the
  2198.      command line is treated as a REXX macro and is passed onto the
  2199.      REXX interpreter (if you have one) for execution.
  2200.  
  2201.      Only 1 level of synonym processing is carried out; therefore
  2202.      a synonym cannot be specified in the 'definition'.
  2203.  
  2204. COMPATIBILITY
  2205.      XEDIT: Compatible.
  2206.      KEDIT: Compatible.
  2207.  
  2208. DEFAULT
  2209.      OFF
  2210.  
  2211. STATUS
  2212.      Not started.
  2213. **man-end**********************************************************************/
  2214. #ifdef HAVE_PROTO
  2215. short Synonym(CHARTYPE *params)
  2216. #else
  2217. short Synonym(params)
  2218. CHARTYPE *params;
  2219. #endif
  2220. /***********************************************************************/
  2221. {
  2222. /*--------------------------- local data ------------------------------*/
  2223.  short rc=RC_OK;
  2224. /*--------------------------- processing ------------------------------*/
  2225. #ifdef TRACE
  2226.  trace_function("commset2.c:Synonym");
  2227. #endif
  2228.  display_error(0,(CHARTYPE *)"This command not yet implemented",FALSE);
  2229. /*---------------------------------------------------------------------*/
  2230. /* Do not allow the command COMMAND to be synonymed.                   */
  2231. /*---------------------------------------------------------------------*/
  2232. #ifdef TRACE
  2233.  trace_return();
  2234. #endif
  2235.  return(rc);
  2236. }
  2237. /*man-start*********************************************************************
  2238. COMMAND
  2239.      set tabkey - set characteristics of the SOS TABF command
  2240.  
  2241. SYNTAX
  2242.      [SET] TABKey Tab|Character Tab|Character
  2243.  
  2244. DESCRIPTION
  2245.      The SET TABKEY sets the action to be taken when the <SOS TABF> 
  2246.      command is executed. Depending on the insert mode, the <SOS TABF>
  2247.      command will either display a raw tab character or will move to 
  2248.      the next tab column.
  2249.  
  2250.      The first operand refers to the behaviour of the <SOS TABF> command
  2251.      when <SET INSERTMODE> is OFF.
  2252.  
  2253.      The second operand specifies the behaviour when the <SOS TABF> 
  2254.      command is executed when <SET INSERTMODE> is ON.
  2255.  
  2256. COMPATIBILITY
  2257.      XEDIT: N/A
  2258.      KEDIT: N/A
  2259.  
  2260. DEFAULT
  2261.      Tab Character
  2262.  
  2263. STATUS
  2264.      Complete
  2265. **man-end**********************************************************************/
  2266. #ifdef HAVE_PROTO
  2267. short Tabkey(CHARTYPE *params)
  2268. #else
  2269. short Tabkey(params)
  2270. CHARTYPE *params;
  2271. #endif
  2272. /***********************************************************************/
  2273. {
  2274. /*-------------------------- external data ----------------------------*/
  2275.  extern CHARTYPE tabkey_insert,tabkey_overwrite;
  2276. /*--------------------------- local data ------------------------------*/
  2277. #define TKY_PARAMS  3
  2278.  CHARTYPE *word[TKY_PARAMS+1];
  2279.  CHARTYPE strip[TKY_PARAMS];
  2280.  unsigned short num_params=0;
  2281.  CHARTYPE tabo=tabkey_overwrite;
  2282.  CHARTYPE tabi=tabkey_insert;
  2283.  short rc=RC_INVALID_OPERAND;
  2284. /*--------------------------- processing ------------------------------*/
  2285. #ifdef TRACE
  2286.  trace_function("commset2.c:Tabkey");
  2287. #endif
  2288. /*---------------------------------------------------------------------*/
  2289. /* Validate the parameters that have been supplied.                    */
  2290. /*---------------------------------------------------------------------*/
  2291.  strip[0]=STRIP_BOTH;
  2292.  strip[1]=STRIP_BOTH;
  2293.  strip[2]=STRIP_BOTH;
  2294.  num_params = param_split(params,word,TKY_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  2295.  switch(num_params)
  2296.    {
  2297. /*---------------------------------------------------------------------*/
  2298. /* Too few parameters, error.                                          */
  2299. /*---------------------------------------------------------------------*/
  2300.     case 0:
  2301.     case 1:
  2302.          display_error(3,(CHARTYPE *)"",FALSE);
  2303.          break;
  2304. /*---------------------------------------------------------------------*/
  2305. /* 2 parameters, validate them...                                      */
  2306. /*---------------------------------------------------------------------*/
  2307.     case 2:
  2308. /*---------------------------------------------------------------------*/
  2309. /* Validate first parameter; overwrite mode setting...                 */
  2310. /*---------------------------------------------------------------------*/
  2311.          if (equal((CHARTYPE *)"character",word[0],1))
  2312.            {
  2313.             tabo = 'C';
  2314.             rc = RC_OK;
  2315.            }
  2316.          if (equal((CHARTYPE *)"tab",word[0],1))
  2317.            {
  2318.             tabo = 'T';
  2319.             rc = RC_OK;
  2320.            }
  2321. /*---------------------------------------------------------------------*/
  2322. /* If not a valid first parameter, display an error and exit.          */
  2323. /*---------------------------------------------------------------------*/
  2324.          if (rc != RC_OK)
  2325.            {
  2326.             display_error(1,word[0],FALSE);
  2327.             break;
  2328.            }
  2329.          rc = RC_INVALID_OPERAND;
  2330. /*---------------------------------------------------------------------*/
  2331. /* Validate second parameter; insert mode setting...                   */
  2332. /*---------------------------------------------------------------------*/
  2333.          if (equal((CHARTYPE *)"character",word[1],1))
  2334.            {
  2335.             tabi = 'C';
  2336.             rc = RC_OK;
  2337.            }
  2338. /*---------------------------------------------------------------------*/
  2339. /* Validate second parameter; insert mode setting...                   */
  2340. /*---------------------------------------------------------------------*/
  2341.          if (equal((CHARTYPE *)"tab",word[1],1))
  2342.            {
  2343.             tabi = 'T';
  2344.             rc = RC_OK;
  2345.            }
  2346. /*---------------------------------------------------------------------*/
  2347. /* If not a valid second parameter, display an error and exit.         */
  2348. /*---------------------------------------------------------------------*/
  2349.          if (rc != RC_OK)
  2350.            {
  2351.             display_error(1,word[1],FALSE);
  2352.             break;
  2353.            }
  2354.          rc = RC_OK;
  2355.          break;
  2356. /*---------------------------------------------------------------------*/
  2357. /* Too many parameters...                                              */
  2358. /*---------------------------------------------------------------------*/
  2359.     default:
  2360.          display_error(2,(CHARTYPE *)"",FALSE);
  2361.          break;
  2362.    }
  2363. /*---------------------------------------------------------------------*/
  2364. /* If valid parameters, change the settings...                         */
  2365. /*---------------------------------------------------------------------*/
  2366.  if (rc == RC_OK)
  2367.    {
  2368.     tabkey_insert = tabi;
  2369.     tabkey_overwrite = tabo;
  2370.    }
  2371. #ifdef TRACE
  2372.  trace_return();
  2373. #endif
  2374.  return(RC_OK);
  2375. }
  2376. /*man-start*********************************************************************
  2377. COMMAND
  2378.      set tabline - set position and status of tab line on screen
  2379.  
  2380. SYNTAX
  2381.      [SET] TABLine ON|OFF [M[+n|-n]|[+|-]n]
  2382.  
  2383. DESCRIPTION
  2384.      The SET TABLINE command sets the position and status of the <tab line>
  2385.      for the current view.
  2386.  
  2387.      The first form of parameters is:
  2388.  
  2389.      M[+n|-n] 
  2390.      this sets the <tab line> to be relative to the middle of
  2391.      the screen. A positive value adds to the middle line number, 
  2392.      a negative subtracts from it.
  2393.      eg. M+3 on a 24 line screen will be line 15
  2394.          M-5 on a 24 line screen will be line 7
  2395.  
  2396.      The second form of parameters is:
  2397.  
  2398.      [+|-]n
  2399.      this sets the <tab line> to be relative to the top of the
  2400.      screen (if positive or no sign) or relative to the bottom 
  2401.      of the screen if negative.
  2402.      eg. +3 or 3 will set current line to line 3
  2403.          -3 on a 24 line screen will be line 21
  2404.  
  2405.      If the resulting line is outside the bounds of the screen
  2406.      the position of the current line will become the middle line
  2407.      on the screen.
  2408.  
  2409.      It is an error to try to position the TABL line on the same
  2410.      line as <SET CURLINE>.
  2411.  
  2412. COMPATIBILITY
  2413.      XEDIT: Compatible.
  2414.      KEDIT: Compatible.
  2415.  
  2416. DEFAULT
  2417.      OFF -3
  2418.  
  2419. STATUS
  2420.      Complete.
  2421. **man-end**********************************************************************/
  2422. #ifdef HAVE_PROTO
  2423. short Tabline(CHARTYPE *params)
  2424. #else
  2425. short Tabline(params)
  2426. CHARTYPE *params;
  2427. #endif
  2428. /***********************************************************************/
  2429. {
  2430. /*------------------------- external data -----------------------------*/
  2431.  extern bool curses_started;
  2432. /*--------------------------- local data ------------------------------*/
  2433. #define TBL_PARAMS  2
  2434.  CHARTYPE *word[TBL_PARAMS+1];
  2435.  CHARTYPE strip[TBL_PARAMS];
  2436.  short num_params=0;
  2437.  short rc=RC_OK;
  2438.  short base=(short)CURRENT_VIEW->tab_base;
  2439.  short off=CURRENT_VIEW->tab_off;
  2440.  bool tabsts=FALSE;
  2441.  unsigned short x=0,y=0;
  2442. /*--------------------------- processing ------------------------------*/
  2443. #ifdef TRACE
  2444.  trace_function("commset2.c:Tabline");
  2445. #endif
  2446.  strip[0]=STRIP_BOTH;
  2447.  strip[1]=STRIP_BOTH;
  2448.  num_params = param_split(params,word,TBL_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  2449.  if (num_params < 1)
  2450.    {
  2451.     display_error(3,(CHARTYPE *)"",FALSE);
  2452. #ifdef TRACE
  2453.     trace_return();
  2454. #endif
  2455.     return(RC_INVALID_OPERAND);
  2456.    }
  2457. /*---------------------------------------------------------------------*/
  2458. /* Parse the status parameter...                                       */
  2459. /*---------------------------------------------------------------------*/
  2460.  rc = execute_set_on_off(word[0],&tabsts);
  2461.  if (rc != RC_OK)
  2462.    {
  2463. #ifdef TRACE
  2464.     trace_return();
  2465. #endif
  2466.     return(rc);
  2467.    }
  2468. /*---------------------------------------------------------------------*/
  2469. /* Parse the position parameter...                                     */
  2470. /*---------------------------------------------------------------------*/
  2471.  if (num_params > 1)
  2472.    {
  2473.     rc = execute_set_row_position(word[1],&base,&off);
  2474.     if (rc != RC_OK)
  2475.       {
  2476. #ifdef TRACE
  2477.        trace_return();
  2478. #endif
  2479.        return(rc);
  2480.       }
  2481.    }
  2482. /*---------------------------------------------------------------------*/
  2483. /* If the TABL  row is the same row as CURLINE and it is being turned  */
  2484. /* on, return ERROR.                                                   */
  2485. /*---------------------------------------------------------------------*/
  2486.  if (calculate_actual_row(CURRENT_VIEW->current_base,
  2487.                           CURRENT_VIEW->current_off,
  2488.                           CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE) ==
  2489.      calculate_actual_row(base,off,CURRENT_SCREEN.rows[WINDOW_FILEAREA],TRUE)
  2490.  && tabsts)
  2491.    {
  2492.     display_error(64,(CHARTYPE *)"- same line as CURLINE",FALSE);
  2493. #ifdef TRACE
  2494.     trace_return();
  2495. #endif
  2496.     return(RC_INVALID_ENVIRON);
  2497.    }
  2498.  CURRENT_VIEW->tab_base = (CHARTYPE)base;
  2499.  CURRENT_VIEW->tab_off = off;
  2500.  CURRENT_VIEW->tab_on = tabsts;
  2501.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  2502.  build_screen(current_screen);
  2503.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  2504.    {
  2505.     if (curses_started)
  2506.        getyx(CURRENT_WINDOW,y,x);
  2507.     CURRENT_VIEW->focus_line = get_focus_line_in_view(current_screen,CURRENT_VIEW->focus_line,y);
  2508.     y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,CURRENT_VIEW->current_row);
  2509.     if (curses_started)
  2510.        wmove(CURRENT_WINDOW,y,x);
  2511.     pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  2512.    }
  2513.  display_screen(current_screen);
  2514. #ifdef TRACE
  2515.  trace_return();
  2516. #endif
  2517.  return(RC_OK);
  2518. }
  2519. /*man-start*********************************************************************
  2520. COMMAND
  2521.      set tabs - set tab columns or tab length
  2522.  
  2523. SYNTAX
  2524.      [SET] TABS n1 [n2 ... n32]
  2525.      [SET] TABS INCR n
  2526.      [SET] TABS OFF
  2527.  
  2528. DESCRIPTION
  2529.      The SET TABS command determines the position of tab columns in THE.
  2530.  
  2531.      The first format of SET TABS, specifies individual tab columns. Each
  2532.      column must be greater than the column to its left.
  2533.  
  2534.      The second format specifies the tab increment to use. ie each tab
  2535.      column will be set at each 'n' columns.
  2536.  
  2537.      The third format specifies that no tab columns are to be set.
  2538.  
  2539.      Tab columns are used by <SOS TABF>, <SOS TABB> and <SOS SETTAB> 
  2540.      commands to position the cursor and also by the <COMPRESS> and 
  2541.      <EXPAND> commands.
  2542.  
  2543. COMPATIBILITY
  2544.      XEDIT: Compatible. Does not support OFF option.
  2545.      KEDIT: Compatible. Does not support OFF option.
  2546.  
  2547. DEFAULT
  2548.      INCR 8
  2549.  
  2550. STATUS
  2551.      Complete.
  2552. **man-end**********************************************************************/
  2553. #ifdef HAVE_PROTO
  2554. short Tabs(CHARTYPE *params)
  2555. #else
  2556. short Tabs(params)
  2557. CHARTYPE *params;
  2558. #endif
  2559. /***********************************************************************/
  2560. {
  2561. /*-------------------------- external data ----------------------------*/
  2562. /*--------------------------- local data ------------------------------*/
  2563. #define TABS_PARAMS  MAX_NUMTABS
  2564.  CHARTYPE *word[TABS_PARAMS+1];
  2565.  CHARTYPE strip[TABS_PARAMS];
  2566.  LENGTHTYPE stops[TABS_PARAMS];
  2567.  register short i=0;
  2568.  unsigned short num_params=0;
  2569.  LENGTHTYPE tabinc=0;
  2570. /*--------------------------- processing ------------------------------*/
  2571. #ifdef TRACE
  2572.  trace_function("commset2.c:Tabs");
  2573. #endif
  2574.  for (i=0;i<TABS_PARAMS;i++)
  2575.     strip[i] = STRIP_BOTH;
  2576.  num_params = param_split(params,word,TABS_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  2577. /*---------------------------------------------------------------------*/
  2578. /* If the INCR option is specified...                                  */
  2579. /*---------------------------------------------------------------------*/
  2580.  if (equal((CHARTYPE *)"incr",word[0],2))
  2581.    {
  2582.     if (num_params != 2)
  2583.       {
  2584.        display_error(2,(CHARTYPE *)"",FALSE);
  2585. #ifdef TRACE
  2586.        trace_return();
  2587. #endif
  2588.        return(RC_INVALID_OPERAND);
  2589.       }
  2590.     if (!valid_positive_integer(word[1]))
  2591.       {
  2592.        display_error(4,word[1],FALSE);
  2593. #ifdef TRACE
  2594.        trace_return();
  2595. #endif
  2596.        return(RC_INVALID_OPERAND);
  2597.       }
  2598.     tabinc = (LENGTHTYPE)atoi((DEFCHAR *)word[1]);
  2599.     if (tabinc < 1)
  2600.       {
  2601.        display_error(5,word[1],FALSE);
  2602. #ifdef TRACE
  2603.        trace_return();
  2604. #endif
  2605.        return(RC_INVALID_OPERAND);
  2606.       }
  2607.     if (tabinc > 32)
  2608.       {
  2609.        display_error(6,word[1],FALSE);
  2610. #ifdef TRACE
  2611.        trace_return();
  2612. #endif
  2613.        return(RC_INVALID_OPERAND);
  2614.       }
  2615.     for (i=0;i<MAX_NUMTABS;i++)
  2616.        CURRENT_VIEW->tabs[i] = 1 + (tabinc*i);
  2617.     CURRENT_VIEW->numtabs = MAX_NUMTABS;
  2618.     CURRENT_VIEW->tabsinc = tabinc;
  2619.    }
  2620.  else if (equal((CHARTYPE *)"off",word[0],3))
  2621. /*---------------------------------------------------------------------*/
  2622. /* If the OFF option is specified...                                   */
  2623. /*---------------------------------------------------------------------*/
  2624.    {
  2625.     if (num_params != 1)
  2626.       {
  2627.        display_error(2,(CHARTYPE *)"",FALSE);
  2628. #ifdef TRACE
  2629.        trace_return();
  2630. #endif
  2631.        return(RC_INVALID_OPERAND);
  2632.       }
  2633.     for (i=0;i<MAX_NUMTABS;i++)
  2634.        CURRENT_VIEW->tabs[i] = 0;
  2635.     CURRENT_VIEW->numtabs = 0;
  2636.     CURRENT_VIEW->tabsinc = 0;
  2637.    }
  2638.  else
  2639. /*---------------------------------------------------------------------*/
  2640. /* ... individual TAB stop settings.                                   */
  2641. /*---------------------------------------------------------------------*/
  2642.    {
  2643.     if (num_params > MAX_NUMTABS)
  2644.       {
  2645.        display_error(2,(CHARTYPE *)"",FALSE);
  2646. #ifdef TRACE
  2647.        trace_return();
  2648. #endif
  2649.        return(RC_INVALID_OPERAND);
  2650.       }
  2651.     if (num_params == 0)
  2652.       {
  2653.        display_error(3,(CHARTYPE *)"",FALSE);
  2654. #ifdef TRACE
  2655.        trace_return();
  2656. #endif
  2657.        return(RC_INVALID_OPERAND);
  2658.       }
  2659.     for (i=0;i<num_params;i++)
  2660.       {
  2661.        if (!valid_positive_integer(word[i]))
  2662.          {
  2663.           display_error(4,word[i],FALSE);
  2664. #ifdef TRACE
  2665.           trace_return();
  2666. #endif
  2667.           return(RC_INVALID_OPERAND);
  2668.          }
  2669.        tabinc = (LENGTHTYPE)atoi((DEFCHAR *)word[i]);
  2670.        if (i > 0)
  2671.          {
  2672.           if (stops[i-1] >= tabinc)
  2673.             {
  2674.              display_error(5,word[i],FALSE);
  2675. #ifdef TRACE
  2676.              trace_return();
  2677. #endif
  2678.              return(RC_INVALID_OPERAND);
  2679.             }
  2680.          }
  2681.        stops[i] = tabinc;
  2682.       }
  2683.     CURRENT_VIEW->numtabs = num_params;
  2684.     for (i=0;i<num_params;i++)
  2685.       {
  2686.        CURRENT_VIEW->tabs[i] = stops[i];
  2687.       }
  2688.     CURRENT_VIEW->tabsinc = 0;
  2689.    }
  2690.  build_screen(current_screen);
  2691.  display_screen(current_screen);
  2692. #ifdef TRACE
  2693.  trace_return();
  2694. #endif
  2695.  return(RC_OK);
  2696. }
  2697. /*man-start*********************************************************************
  2698. COMMAND
  2699.      set tabsin - set tab processing on file input
  2700.  
  2701. SYNTAX
  2702.      [SET] TABSIn ON|OFF [n]
  2703.  
  2704. DESCRIPTION
  2705.      The SET TABSIN command determines if tabs read from a file are to be
  2706.      expanded to spaces and if so how many spaces.
  2707.  
  2708. COMPATIBILITY
  2709.      XEDIT: N/A
  2710.      KEDIT: Does not support TABQUOTE option.
  2711.  
  2712. DEFAULT
  2713.      OFF 8
  2714.  
  2715. SEE ALSO
  2716.      <SET TABSOUT>
  2717.  
  2718. STATUS
  2719.      Complete.
  2720. **man-end**********************************************************************/
  2721. #ifdef HAVE_PROTO
  2722. short Tabsin(CHARTYPE *params)
  2723. #else
  2724. short Tabsin(params)
  2725. CHARTYPE *params;
  2726. #endif
  2727. /***********************************************************************/
  2728. {
  2729. /*---------------------------------------------------------------------*/
  2730. /* The settings for TABSIN is a global value, despite it supposedly    */
  2731. /* being a file level value.                                           */
  2732. /*---------------------------------------------------------------------*/
  2733. /*-------------------------- external data ----------------------------*/
  2734.  extern bool in_profile;
  2735.  extern CHARTYPE TABI_ONx;
  2736.  extern CHARTYPE TABI_Nx;
  2737. /*--------------------------- local data ------------------------------*/
  2738. #define TABI_PARAMS  3
  2739.  CHARTYPE *word[TABI_PARAMS+1];
  2740.  CHARTYPE strip[TABI_PARAMS];
  2741.  unsigned short num_params=0;
  2742.  short rc=RC_INVALID_OPERAND;
  2743.  CHARTYPE tabsts=TABI_ONx;
  2744.  CHARTYPE tabn  =TABI_Nx;
  2745.  bool save_scope=FALSE;
  2746.  bool save_stay=FALSE;
  2747. /*--------------------------- processing ------------------------------*/
  2748. #ifdef TRACE
  2749.  trace_function("commset2.c:Tabsin");
  2750. #endif
  2751. /*---------------------------------------------------------------------*/
  2752. /* Validate the parameters that have been supplied.                    */
  2753. /*---------------------------------------------------------------------*/
  2754.  strip[0]=STRIP_BOTH;
  2755.  strip[1]=STRIP_BOTH;
  2756.  strip[2]=STRIP_BOTH;
  2757.  num_params = param_split(params,word,TABI_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  2758.  switch(num_params)
  2759.    {
  2760. /*---------------------------------------------------------------------*/
  2761. /* Too few parameters, error.                                          */
  2762. /*---------------------------------------------------------------------*/
  2763.     case 0:
  2764.          display_error(3,(CHARTYPE *)"",FALSE);
  2765.          break;
  2766. /*---------------------------------------------------------------------*/
  2767. /* 1 or 2 parameters, validate them...                                 */
  2768. /*---------------------------------------------------------------------*/
  2769.     case 1:
  2770.     case 2:
  2771. /*---------------------------------------------------------------------*/
  2772. /* Validate first parameter; on or off...                              */
  2773. /*---------------------------------------------------------------------*/
  2774.          if (equal((CHARTYPE *)"on",word[0],2))
  2775.            {
  2776.             tabsts = TRUE;
  2777.             rc = RC_OK;
  2778.            }
  2779.          if (equal((CHARTYPE *)"off",word[0],3))
  2780.            {
  2781.             tabsts = FALSE;
  2782.             rc = RC_OK;
  2783.            }
  2784. /*---------------------------------------------------------------------*/
  2785. /* If not a valid first parameter, display an error and exit.          */
  2786. /*---------------------------------------------------------------------*/
  2787.          if (rc != RC_OK)
  2788.            {
  2789.             display_error(1,word[0],FALSE);
  2790.             break;
  2791.            }
  2792. /*---------------------------------------------------------------------*/
  2793. /* For 1 parameter, don't check any more.                              */
  2794. /*---------------------------------------------------------------------*/
  2795.          if (num_params == 1)
  2796.             break;
  2797. /*---------------------------------------------------------------------*/
  2798. /* Validate second parameter; number of spaces for a TAB...            */
  2799. /*---------------------------------------------------------------------*/
  2800.          if (!valid_positive_integer(word[1]))
  2801.            {
  2802.             display_error(4,word[1],FALSE);
  2803.             break;
  2804.            }
  2805.          tabn = (CHARTYPE)atoi((DEFCHAR *)word[1]);
  2806. /*---------------------------------------------------------------------*/
  2807. /* tabn must be between 1 and 32...                                    */
  2808. /*---------------------------------------------------------------------*/
  2809.          if (tabn < 1)
  2810.            {
  2811.             display_error(5,word[1],FALSE);
  2812.             break;
  2813.            }
  2814.          if (tabn > 32)
  2815.            {
  2816.             display_error(6,word[1],FALSE);
  2817.             break;
  2818.            }
  2819.          rc = RC_OK;
  2820.          break;
  2821. /*---------------------------------------------------------------------*/
  2822. /* Too many parameters...                                              */
  2823. /*---------------------------------------------------------------------*/
  2824.     default:
  2825.          display_error(2,(CHARTYPE *)"",FALSE);
  2826.          break;
  2827.    }
  2828. /*---------------------------------------------------------------------*/
  2829. /* If valid parameters, change the settings...                         */
  2830. /*---------------------------------------------------------------------*/
  2831.  if (rc == RC_OK)
  2832.    {
  2833.     TABI_ONx = tabsts;
  2834.     TABI_Nx = tabn;
  2835. /*---------------------------------------------------------------------*/
  2836. /* If this command is issued from the profile file, we need to run     */
  2837. /* EXPAND ALL on it, as we have already read in the file.              */
  2838. /* We need to save the current setting of scope so that it can be      */
  2839. /* changed to ALL so that every line will be expanded.                 */
  2840. /* Of course if TABSIN OFF was set we DON'T run EXPAND ALL :-)         */
  2841. /*---------------------------------------------------------------------*/
  2842.     if (in_profile && tabsts)
  2843.       {
  2844.        save_stay = CURRENT_VIEW->stay;
  2845.        CURRENT_VIEW->stay = TRUE;
  2846.        save_scope = CURRENT_VIEW->scope_all;
  2847.        rc = execute_expand_compress((CHARTYPE *)"ALL",TRUE,FALSE,FALSE,FALSE);
  2848.        CURRENT_VIEW->scope_all = save_scope;
  2849.        CURRENT_VIEW->stay = save_stay;
  2850.       }
  2851.    }
  2852. #ifdef TRACE
  2853.  trace_return();
  2854. #endif
  2855.  return(rc);
  2856. }
  2857. /*man-start*********************************************************************
  2858. COMMAND
  2859.      set tabsout - set tab processing on file output
  2860.  
  2861. SYNTAX
  2862.      [SET] TABSOut ON|OFF [n]
  2863.  
  2864. DESCRIPTION
  2865.      The SET TABSOUT command determines if spaces written to a file are to
  2866.      be compressed to tabs and if so how many spaces.
  2867.  
  2868. COMPATIBILITY
  2869.      XEDIT: N/A
  2870.      KEDIT: Compatible.
  2871.  
  2872. DEFAULT
  2873.      OFF 8
  2874.  
  2875. SEE ALSO
  2876.      <SET TABSIN>
  2877.  
  2878. STATUS
  2879.      Complete.
  2880. **man-end**********************************************************************/
  2881. #ifdef HAVE_PROTO
  2882. short Tabsout(CHARTYPE *params)
  2883. #else
  2884. short Tabsout(params)
  2885. CHARTYPE *params;
  2886. #endif
  2887. /***********************************************************************/
  2888. {
  2889. /*-------------------------- external data ----------------------------*/
  2890. /*--------------------------- local data ------------------------------*/
  2891. #define TABO_PARAMS  3
  2892.  CHARTYPE *word[TABO_PARAMS+1];
  2893.  CHARTYPE strip[TABO_PARAMS];
  2894.  unsigned short num_params=0;
  2895.  short rc=RC_INVALID_OPERAND;
  2896.  bool tabsts=CURRENT_FILE->tabsout_on;
  2897.  CHARTYPE tabn=CURRENT_FILE->tabsout_num;
  2898. /*--------------------------- processing ------------------------------*/
  2899. #ifdef TRACE
  2900.  trace_function("commset2.c:Tabsout");
  2901. #endif
  2902. /*---------------------------------------------------------------------*/
  2903. /* Validate the parameters that have been supplied.                    */
  2904. /*---------------------------------------------------------------------*/
  2905.  strip[0]=STRIP_BOTH;
  2906.  strip[1]=STRIP_BOTH;
  2907.  strip[2]=STRIP_BOTH;
  2908.  num_params = param_split(params,word,TABO_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  2909.  switch(num_params)
  2910.    {
  2911. /*---------------------------------------------------------------------*/
  2912. /* Too few parameters, error.                                          */
  2913. /*---------------------------------------------------------------------*/
  2914.     case 0:
  2915.          display_error(3,(CHARTYPE *)"",FALSE);
  2916.          break;
  2917. /*---------------------------------------------------------------------*/
  2918. /* 1 or 2 parameters, validate them...                                 */
  2919. /*---------------------------------------------------------------------*/
  2920.     case 1:
  2921.     case 2:
  2922. /*---------------------------------------------------------------------*/
  2923. /* Validate first parameter; on or off...                              */
  2924. /*---------------------------------------------------------------------*/
  2925.          if (equal((CHARTYPE *)"on",word[0],2))
  2926.            {
  2927.             tabsts = TRUE;
  2928.             rc = RC_OK;
  2929.            }
  2930.          if (equal((CHARTYPE *)"off",word[0],3))
  2931.            {
  2932.             tabsts = FALSE;
  2933.             rc = RC_OK;
  2934.            }
  2935. /*---------------------------------------------------------------------*/
  2936. /* If not a valid first parameter, display an error and exit.          */
  2937. /*---------------------------------------------------------------------*/
  2938.          if (rc != RC_OK)
  2939.            {
  2940.             display_error(1,word[0],FALSE);
  2941.             break;
  2942.            }
  2943. /*---------------------------------------------------------------------*/
  2944. /* For 1 parameter, don't check any more.                              */
  2945. /*---------------------------------------------------------------------*/
  2946.          if (num_params == 1)
  2947.             break;
  2948. /*---------------------------------------------------------------------*/
  2949. /* Validate second parameter; number of spaces for a TAB...            */
  2950. /*---------------------------------------------------------------------*/
  2951.          if (!valid_positive_integer(word[1]))
  2952.            {
  2953.             display_error(4,word[1],FALSE);
  2954.             break;
  2955.            }
  2956.          tabn = (CHARTYPE)atoi((DEFCHAR *)word[1]);
  2957. /*---------------------------------------------------------------------*/
  2958. /* tabn must be between 1 and 32...                                    */
  2959. /*---------------------------------------------------------------------*/
  2960.          if (tabn < 1)
  2961.            {
  2962.             display_error(5,word[1],FALSE);
  2963.             break;
  2964.            }
  2965.          if (tabn > 32)
  2966.            {
  2967.             display_error(6,word[1],FALSE);
  2968.             break;
  2969.            }
  2970.          rc = RC_OK;
  2971.          break;
  2972. /*---------------------------------------------------------------------*/
  2973. /* Too many parameters...                                              */
  2974. /*---------------------------------------------------------------------*/
  2975.     default:
  2976.          display_error(2,(CHARTYPE *)"",FALSE);
  2977.          break;
  2978.    }
  2979. /*---------------------------------------------------------------------*/
  2980. /* If valid parameters, change the settings...                         */
  2981. /*---------------------------------------------------------------------*/
  2982.  if (rc == RC_OK)
  2983.    {
  2984.     CURRENT_FILE->tabsout_on = tabsts;
  2985.     CURRENT_FILE->tabsout_num = tabn;
  2986.    }
  2987. #ifdef TRACE
  2988.  trace_return();
  2989. #endif
  2990.  return(RC_OK);
  2991. }
  2992. /*man-start*********************************************************************
  2993. COMMAND
  2994.      set trunc - specify the truncation column
  2995.  
  2996. SYNTAX
  2997.      [SET] TRunc n|*
  2998.  
  2999. DESCRIPTION
  3000.      The SET TRUNC set command determines the truncation column.  This
  3001.      is the rightmost column of text upon which THE commands are 
  3002.      effective.
  3003.  
  3004. COMPATIBILITY
  3005.      XEDIT: Compatible.
  3006.      KEDIT: Compatible.
  3007.  
  3008. DEFAULT
  3009.      *
  3010.  
  3011. STATUS
  3012.      Incomplete.
  3013. **man-end**********************************************************************/
  3014. #ifdef HAVE_PROTO
  3015. short Trunc(CHARTYPE *params)
  3016. #else
  3017. short Trunc(params)
  3018. CHARTYPE *params;
  3019. #endif
  3020. /***********************************************************************/
  3021. {
  3022. /*-------------------------- external data ----------------------------*/
  3023. /*--------------------------- local data ------------------------------*/
  3024.  short rc=RC_OK;
  3025. /*--------------------------- processing ------------------------------*/
  3026. #ifdef TRACE
  3027.  trace_function("commset2.c:Trunc");
  3028. #endif
  3029.  
  3030. #ifdef TRACE
  3031.  trace_return();
  3032. #endif
  3033.  return(rc);
  3034. }
  3035. /*man-start*********************************************************************
  3036. COMMAND
  3037.      set typeahead - set behaviour of screen redraw
  3038.  
  3039. SYNTAX
  3040.      [SET] TYPEAhead ON|OFF
  3041.  
  3042. DESCRIPTION
  3043.      The SET TYPEAHEAD set command determines whether or not THE uses the
  3044.      curses screen display optimization techniques.
  3045.  
  3046.      With TYPEAHEAD ON, curses will abort screen display if a keystroke
  3047.      is pending.
  3048.  
  3049.      With TYPEAHEAD OFF, curses will not abort screen display if a
  3050.      keystroke is pending.
  3051.  
  3052.      For BSD based curses, this function has no effect.
  3053.  
  3054. COMPATIBILITY
  3055.      XEDIT: N/A
  3056.      KEDIT: N/A
  3057.  
  3058. DEFAULT
  3059.      OFF
  3060.  
  3061. STATUS
  3062.      Complete.
  3063. **man-end**********************************************************************/
  3064. #ifdef HAVE_PROTO
  3065. short THETypeahead(CHARTYPE *params)
  3066. #else
  3067. short THETypeahead(params)
  3068. CHARTYPE *params;
  3069. #endif
  3070. /***********************************************************************/
  3071. {
  3072. /*-------------------------- external data ----------------------------*/
  3073.  extern bool curses_started;
  3074.  extern bool TYPEAHEADx;
  3075. /*--------------------------- local data ------------------------------*/
  3076.  short rc=RC_OK;
  3077.  bool setting=FALSE;
  3078. /*--------------------------- processing ------------------------------*/
  3079. #ifdef TRACE
  3080.  trace_function("commset2.c:THETypeahead");
  3081. #endif
  3082.  
  3083. #ifdef HAVE_TYPEAHEAD
  3084.  if (curses_started)
  3085.    {
  3086.     rc = execute_set_on_off(params,&setting);
  3087.     if (rc == RC_OK)
  3088.       {
  3089.        if (setting)
  3090.          {
  3091.           typeahead(fileno(stdin));
  3092.           TYPEAHEADx = TRUE;
  3093.          }
  3094.        else
  3095.          {
  3096.           typeahead(-1);
  3097.           TYPEAHEADx = FALSE;
  3098.          }
  3099.       }
  3100.    }
  3101. #endif
  3102.  
  3103. #ifdef TRACE
  3104.  trace_return();
  3105. #endif
  3106.  return(rc);
  3107. }
  3108. /*man-start*********************************************************************
  3109. COMMAND
  3110.      set undoing - turn on or off undo facility for the current file
  3111.  
  3112. SYNTAX
  3113.      [SET] UNDOING ON|OFF
  3114.  
  3115. DESCRIPTION
  3116.      The SET UNDOING command allows the user to turn on or off the
  3117.      undo facility for the current file.
  3118.  
  3119.      At this stage in the development of THE, setting UNDOING to OFF
  3120.      stops THE from saving changes made to lines in a file, and
  3121.      prevents those lines from being able to be RECOVERed.
  3122.  
  3123.      Setting UNDOING to OFF will increase the speed at which THE can
  3124.      execute CHANGE and DELETE commands.
  3125.  
  3126. COMPATIBILITY
  3127.      XEDIT: N/A
  3128.      KEDIT: Does not support optional arguments.
  3129.  
  3130. DEFAULT
  3131.      ON
  3132.  
  3133. STATUS
  3134.      Complete.
  3135. **man-end**********************************************************************/
  3136. #ifdef HAVE_PROTO
  3137. short Undoing(CHARTYPE *params)
  3138. #else
  3139. short Undoing(params)
  3140. CHARTYPE *params;
  3141. #endif
  3142. /***********************************************************************/
  3143. {
  3144. /*------------------------- external date -----------------------------*/
  3145. /*--------------------------- local data ------------------------------*/
  3146.  short rc=RC_OK;
  3147. /*--------------------------- processing ------------------------------*/
  3148. #ifdef TRACE
  3149.  trace_function("commset2.c:Undoing");
  3150. #endif
  3151.  rc = execute_set_on_off(params,&CURRENT_FILE->undoing);
  3152. #ifdef TRACE
  3153.  trace_return();
  3154. #endif
  3155.  return(rc);
  3156. }
  3157. /*man-start*********************************************************************
  3158. COMMAND
  3159.      set untaa - specifies if "Unsigned Numerical Targets Are Absolute"
  3160.  
  3161. SYNTAX
  3162.      [SET] UNTAA ON|OFF
  3163.  
  3164. DESCRIPTION
  3165.      The SET UNTAA command allows the user to turn on or off the
  3166.      behaviour of unsigned numerical targets.
  3167.  
  3168.      Numerical targets have the form [:|;|+|-]nn. By default, if the
  3169.      optional portion of the target is not supplied, then a '+' is
  3170.      assumed.  WIth SET UNTAA set to ON, if the optional portion of the
  3171.      target is not supplied, then a ':' is assumed.
  3172.  
  3173.      Caution:  This SET command affects all numerical targets, not
  3174.      just targets in the LOCATE command.
  3175.  
  3176. COMPATIBILITY
  3177.      XEDIT: N/A
  3178.      KEDIT: N/A
  3179.  
  3180. DEFAULT
  3181.      OFF
  3182.  
  3183. STATUS
  3184.      Complete.
  3185. **man-end**********************************************************************/
  3186. #ifdef HAVE_PROTO
  3187. short Untaa(CHARTYPE *params)
  3188. #else
  3189. short Untaa(params)
  3190. CHARTYPE *params;
  3191. #endif
  3192. /***********************************************************************/
  3193. {
  3194. /*------------------------- external date -----------------------------*/
  3195. extern bool UNTAAx;
  3196. /*--------------------------- local data ------------------------------*/
  3197.  short rc=RC_OK;
  3198. /*--------------------------- processing ------------------------------*/
  3199. #ifdef TRACE
  3200.  trace_function("commset2.c:Untaa");
  3201. #endif
  3202.  rc = execute_set_on_off(params,&UNTAAx);
  3203. #ifdef TRACE
  3204.  trace_return();
  3205. #endif
  3206.  return(rc);
  3207. }
  3208. /*man-start*********************************************************************
  3209. COMMAND
  3210.      set verify - set column display limits
  3211.  
  3212. SYNTAX
  3213.      [SET] Verify first [last]
  3214.  
  3215. DESCRIPTION
  3216.      The SET VERIFY command sets the column limits for the display of the
  3217.      current file. 'first' specifies the first column to be displayed
  3218.      and 'last' specifies the last column to be displayed.
  3219.  
  3220.      If no 'last' option is specified '*' is assumed.
  3221.  
  3222. COMPATIBILITY
  3223.      XEDIT: Does not implement HEX display nor multiple column pairs.
  3224.      KEDIT: Does not implement HEX display nor multiple column pairs.
  3225.  
  3226. DEFAULT
  3227.      1 *
  3228.  
  3229. SEE ALSO
  3230.      <SET ZONE>
  3231.  
  3232. STATUS
  3233.      Complete.
  3234. **man-end**********************************************************************/
  3235. #ifdef HAVE_PROTO
  3236. short Verify(CHARTYPE *params)
  3237. #else
  3238. short Verify(params)
  3239. CHARTYPE *params;
  3240. #endif
  3241. /***********************************************************************/
  3242. {
  3243. /*-------------------------- external data ----------------------------*/
  3244. /*--------------------------- local data ------------------------------*/
  3245. #define VER_PARAMS  2
  3246.  CHARTYPE *word[VER_PARAMS+1];
  3247.  CHARTYPE strip[VER_PARAMS];
  3248.  unsigned short num_params=0;
  3249.  LINETYPE col1=0L,col2=0L;
  3250. /*--------------------------- processing ------------------------------*/
  3251. #ifdef TRACE
  3252.  trace_function("commset2.c:Verify");
  3253. #endif
  3254. /*---------------------------------------------------------------------*/
  3255. /* Validate the parameters that have been supplied. One or two         */
  3256. /* parameters can be supplied. The first parameter MUST be a positive  */
  3257. /* integer. The second can be a positive integer or '*'. If no second  */
  3258. /* parameter is supplied, '*' is assumed. The second parameter MUST be */
  3259. /* >= first parameter. '*' is regarded as the biggest number and is    */
  3260. /* literally max_line_length.                                          */
  3261. /*---------------------------------------------------------------------*/
  3262.  strip[0]=STRIP_BOTH;
  3263.  strip[1]=STRIP_BOTH;
  3264.  num_params = param_split(params,word,VER_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  3265.  if (num_params == 0)
  3266.    {
  3267.     display_error(3,(CHARTYPE *)"",FALSE);
  3268. #ifdef TRACE
  3269.     trace_return();
  3270. #endif
  3271.     return(RC_INVALID_OPERAND);
  3272.    }
  3273.  if (num_params > 2)
  3274.    {
  3275.     display_error(2,(CHARTYPE *)"",FALSE);
  3276. #ifdef TRACE
  3277.     trace_return();
  3278. #endif
  3279.     return(RC_INVALID_OPERAND);
  3280.    }
  3281.  if (!valid_positive_integer(word[0]))
  3282.    {
  3283.     display_error(4,word[0],FALSE);
  3284. #ifdef TRACE
  3285.     trace_return();
  3286. #endif
  3287.     return(RC_INVALID_OPERAND);
  3288.    }
  3289.  col1 = atol((DEFCHAR *)word[0]);
  3290.  if (num_params == 1)
  3291.      col2 = max_line_length;
  3292.  else
  3293.      if (strcmp((DEFCHAR *)word[1],"*") == 0)
  3294.         col2 = max_line_length;
  3295.      else
  3296.         if (!valid_positive_integer(word[1]))
  3297.           {
  3298.            display_error(4,word[1],FALSE);
  3299. #ifdef TRACE
  3300.            trace_return();
  3301. #endif
  3302.            return(RC_INVALID_OPERAND);
  3303.           }
  3304.         else
  3305.            col2 = atol((DEFCHAR *)word[1]);
  3306.  
  3307.  if (col2 > max_line_length)
  3308.     col2 = max_line_length;
  3309.  if (col1 > col2)
  3310.    {
  3311.     display_error(6,word[0],FALSE);
  3312. #ifdef TRACE
  3313.     trace_return();
  3314. #endif
  3315.     return(RC_INVALID_OPERAND);
  3316.    }
  3317.  CURRENT_VIEW->verify_start = (LENGTHTYPE)col1;
  3318.  CURRENT_VIEW->verify_col = (LENGTHTYPE)col1;
  3319.  CURRENT_VIEW->verify_end = (LENGTHTYPE)col2;
  3320.  
  3321. #ifdef MSWIN
  3322.  Win31HScroll(CURRENT_VIEW->verify_col);
  3323. #endif
  3324.  
  3325.  build_screen(current_screen);
  3326.  display_screen(current_screen);
  3327.  
  3328. #ifdef TRACE
  3329.  trace_return();
  3330. #endif
  3331.  return(RC_OK);
  3332. }
  3333. /*man-start*********************************************************************
  3334. COMMAND
  3335.      set width - set width of maximum line that THE can edit
  3336.  
  3337. SYNTAX
  3338.      [SET] WIDTH n
  3339.  
  3340. DESCRIPTION
  3341.      The SET WIDTH command specifies the maximum length that a line
  3342.      can be within the edit session. This command is effectively the
  3343.      same as the -w command line switch.
  3344.  
  3345.      The value 'n' MUST be >= 10 or <= 32700.
  3346.  
  3347. COMPATIBILITY
  3348.      XEDIT: N/A
  3349.      KEDIT: N/A
  3350.  
  3351. DEFAULT
  3352.      512
  3353.  
  3354. STATUS
  3355.      Complete.
  3356. **man-end**********************************************************************/
  3357. #ifdef HAVE_PROTO
  3358. short Width(CHARTYPE *params)
  3359. #else
  3360. short Width(params)
  3361. CHARTYPE *params;
  3362. #endif
  3363. /***********************************************************************/
  3364. {
  3365. /*-------------------------- external data ----------------------------*/
  3366. extern LENGTHTYPE display_length;
  3367. /*--------------------------- local data ------------------------------*/
  3368.  unsigned short width=0;
  3369. /*--------------------------- processing ------------------------------*/
  3370. #ifdef TRACE
  3371.  trace_function("commset2.c:Width");
  3372. #endif
  3373.  width = (unsigned short)atoi((DEFCHAR*)params);
  3374.  if (width < 10)
  3375.    {
  3376.     display_error(5,(CHARTYPE *)"- width MUST be >= 10",FALSE);
  3377. #ifdef TRACE
  3378.     trace_return();
  3379. #endif
  3380.     return(RC_INVALID_OPERAND);
  3381.    }
  3382.  if (width > 32700)
  3383.    {
  3384.     display_error(6,(CHARTYPE *)"- width MUST be <= 32700",FALSE);
  3385. #ifdef TRACE
  3386.     trace_return();
  3387. #endif
  3388.     return(RC_INVALID_OPERAND);
  3389.    }
  3390.  if (display_length > 0
  3391.  &&  display_length > width)
  3392.    {
  3393.     display_error(6,(CHARTYPE *)"- width MUST be >= display length",FALSE);
  3394. #ifdef TRACE
  3395.     trace_return();
  3396. #endif
  3397.     return(RC_INVALID_OPERAND);
  3398.    }
  3399.  max_line_length = width;
  3400.  if (allocate_working_memory() != 0)
  3401.    {
  3402. #ifdef TRACE
  3403.     trace_return();
  3404. #endif
  3405.     return(RC_INVALID_OPERAND);
  3406.    }
  3407.  show_statarea();
  3408. #ifdef TRACE
  3409.  trace_return();
  3410. #endif
  3411.  return(RC_OK);
  3412. }
  3413. /*man-start*********************************************************************
  3414. COMMAND
  3415.      set word - controls what THE considers a word to be
  3416.  
  3417. SYNTAX
  3418.      [SET] WORD NONBlank|ALPHAnum
  3419.  
  3420. DESCRIPTION
  3421.      The SET WORD set command determines what sequence of characters THE
  3422.      cponsiders a word to be. This is used in command such as <SOS DELWORD>
  3423.      and <SOS TABWORDF> to specify the boundaries of the word.
  3424.  
  3425.      The default setting for SET WORD is 'NONBlank'. THE treats all
  3426.      sequences of characters seperated by a blank (ASCII 32) as words.
  3427.  
  3428.      With 'ALPHAnum' THE treats a group of consecutive alphanumeric
  3429.      characters as a word.  THE also includes the underscore character
  3430.      and characters with an ASCII value > 128 as alphanumeric.
  3431.  
  3432. COMPATIBILITY
  3433.      XEDIT: N/A
  3434.      KEDIT: Compatible.
  3435.  
  3436. DEFAULT
  3437.      NONBlank
  3438.  
  3439. STATUS
  3440.      Complete.
  3441. **man-end**********************************************************************/
  3442. #ifdef HAVE_PROTO
  3443. short Word(CHARTYPE *params)
  3444. #else
  3445. short Word(params)
  3446. CHARTYPE *params;
  3447. #endif
  3448. /***********************************************************************/
  3449. {
  3450. /*-------------------------- external data ----------------------------*/
  3451. /*--------------------------- local data ------------------------------*/
  3452.  CHARTYPE word=CURRENT_VIEW->word;
  3453.  short rc=RC_OK;
  3454. /*--------------------------- processing ------------------------------*/
  3455. #ifdef TRACE
  3456.  trace_function("commset2.c:Word");
  3457. #endif
  3458. /*---------------------------------------------------------------------*/
  3459. /* Validate the the only parameter is 'NONBlank' or 'ALPHAnum'.        */
  3460. /*---------------------------------------------------------------------*/
  3461.  if (equal((CHARTYPE *)"nonblank",params,4))
  3462.     word = 'N';
  3463.  else
  3464.    {
  3465.     if (equal((CHARTYPE *)"alphanum",params,5))
  3466.        word = 'A';
  3467.     else
  3468.       {
  3469.        display_error(1,params,FALSE);
  3470. #ifdef TRACE
  3471.        trace_return();
  3472. #endif
  3473.        return(RC_INVALID_OPERAND);
  3474.       }
  3475.    }
  3476.  CURRENT_VIEW->word = word;
  3477. #ifdef TRACE
  3478.  trace_return();
  3479. #endif
  3480.  return(rc);
  3481. }
  3482. /*man-start*********************************************************************
  3483. COMMAND
  3484.      set wordwrap - set wordwrap feature on or off
  3485.  
  3486. SYNTAX
  3487.      [SET] WORDWrap ON|OFF
  3488.  
  3489. DESCRIPTION
  3490.      The SET WORDWRAP set command determines whether wordwrap occurs when
  3491.      the cursor moves past the right margin (as set by the <SET MARGINS>
  3492.      command).
  3493.  
  3494.      With WORDWRAP ON, the line, from the beginning of the word that
  3495.      exceeds the right margin, is wrapped onto the next line. The cursor
  3496.      position stays in the same position relative to the current word.
  3497.  
  3498.      With WORDWRAP OFF, no word wrap occurs.
  3499.  
  3500. COMPATIBILITY
  3501.      XEDIT: N/A
  3502.      KEDIT: Compatible.
  3503.  
  3504. DEFAULT
  3505.      OFF
  3506.  
  3507. SEE ALSO
  3508.      <SET MARGINS>
  3509.  
  3510. STATUS
  3511.      Complete.
  3512. **man-end**********************************************************************/
  3513. #ifdef HAVE_PROTO
  3514. short Wordwrap(CHARTYPE *params)
  3515. #else
  3516. short Wordwrap(params)
  3517. CHARTYPE *params;
  3518. #endif
  3519. /***********************************************************************/
  3520. {
  3521. /*-------------------------- external data ----------------------------*/
  3522. /*--------------------------- local data ------------------------------*/
  3523.  short rc=RC_OK;
  3524. /*--------------------------- processing ------------------------------*/
  3525. #ifdef TRACE
  3526.  trace_function("commset2.c:Wordwrap");
  3527. #endif
  3528.  rc = execute_set_on_off(params,&CURRENT_VIEW->wordwrap);
  3529. #ifdef TRACE
  3530.  trace_return();
  3531. #endif
  3532.  return(rc);
  3533. }
  3534. /*man-start*********************************************************************
  3535. COMMAND
  3536.      set wrap - enable/disable string locates around the end of the file
  3537.  
  3538. SYNTAX
  3539.      [SET] WRap ON|OFF
  3540.  
  3541. DESCRIPTION
  3542.      The SET WRAP set command determines whether THE will look for a
  3543.      string target off the ends of the file.
  3544.  
  3545.      With WRAP OFF, THE will attempt to locate a string target from the
  3546.      current line to the end of file (or top of file if the locate is
  3547.      a backwards search).
  3548.  
  3549.      With WRAP ON, THE will attempt to locate a string target from the
  3550.      current line to the end of file (or top of file if the locate is 
  3551.      a backwars search) and wrap around the end of the file and continue
  3552.      searching until the current line is reached.
  3553.  
  3554.      If the string target is located after wrapping around the end of
  3555.      the file, the message 'Wrapped...' is displayed.
  3556.  
  3557.      Commands affected by SET WRAP are; <LOCATE>, <FIND>, <NFIND>,
  3558.      <FINDUP> and <NFINDUP>.
  3559.  
  3560. COMPATIBILITY
  3561.      XEDIT: N/A
  3562.      KEDIT: Compatible.
  3563.  
  3564. DEFAULT
  3565.      OFF
  3566.  
  3567. SEE ALSO
  3568.      <LOCATE>, <FIND>, <NFIND>, <FINDUP>, <NFINDUP>
  3569.  
  3570. STATUS
  3571.      Complete.
  3572. **man-end**********************************************************************/
  3573. #ifdef HAVE_PROTO
  3574. short Wrap(CHARTYPE *params)
  3575. #else
  3576. short Wrap(params)
  3577. CHARTYPE *params;
  3578. #endif
  3579. /***********************************************************************/
  3580. {
  3581. /*-------------------------- external data ----------------------------*/
  3582. /*--------------------------- local data ------------------------------*/
  3583.  short rc=RC_OK;
  3584. /*--------------------------- processing ------------------------------*/
  3585. #ifdef TRACE
  3586.  trace_function("commset2.c:Wrap");
  3587. #endif
  3588.  rc = execute_set_on_off(params,&CURRENT_VIEW->wrap);
  3589. #ifdef TRACE
  3590.  trace_return();
  3591. #endif
  3592.  return(rc);
  3593. }
  3594. /*man-start*********************************************************************
  3595. COMMAND
  3596.      set xterminal - set X terminal to execute under X
  3597.  
  3598. SYNTAX
  3599.      [SET] XTERMinal program
  3600.  
  3601. DESCRIPTION
  3602.      The SET XTERMINAL set command allows the user to specify the full
  3603.      quallified file name of the program to run when the <OS>, <DOS> or <!>
  3604.      command is entered without parameters when running the X version
  3605.      of THE.
  3606.  
  3607. COMPATIBILITY
  3608.      XEDIT: N/A
  3609.      KEDIT: N/A
  3610.  
  3611. DEFAULT
  3612.      System dependent but usually one of:
  3613.  
  3614.           /usr/bin/X11/xterm
  3615.           /usr/openwin/bin/xterm
  3616.  
  3617.      The default value is set by the configure script.
  3618.  
  3619. STATUS
  3620.      Complete.
  3621. **man-end**********************************************************************/
  3622. #ifdef HAVE_PROTO
  3623. short Xterminal(CHARTYPE *params)
  3624. #else
  3625. short Xterminal(params)
  3626. CHARTYPE *params;
  3627. #endif
  3628. /***********************************************************************/
  3629. {
  3630. /*-------------------------- external data ----------------------------*/
  3631.  extern CHARTYPE xterm_program[MAX_FILE_NAME+1];
  3632. /*--------------------------- local data ------------------------------*/
  3633. /*--------------------------- processing ------------------------------*/
  3634. #ifdef TRACE
  3635.  trace_function("commset2.c:Xterminal");
  3636. #endif
  3637.  if (strcmp((DEFCHAR *)params,"") == 0)
  3638.    {
  3639.     display_error(1,params,FALSE);
  3640. #ifdef TRACE
  3641.     trace_return();
  3642. #endif
  3643.     return(RC_INVALID_OPERAND);
  3644.    }
  3645.  if (strlen((DEFCHAR *)params) > MAX_FILE_NAME)
  3646.    {
  3647.     display_error(37,params,FALSE);
  3648. #ifdef TRACE
  3649.     trace_return();
  3650. #endif
  3651.     return(RC_INVALID_OPERAND);
  3652.    }
  3653.  strcpy((DEFCHAR *)xterm_program,(DEFCHAR *)params);
  3654. #ifdef TRACE
  3655.  trace_return();
  3656. #endif
  3657.  return(RC_OK);
  3658. }
  3659. /*man-start*********************************************************************
  3660. COMMAND
  3661.      set zone - set column limits for editing
  3662.  
  3663. SYNTAX
  3664.      [SET] Zone first [last]
  3665.  
  3666. DESCRIPTION
  3667.      The SET ZONE command sets the column limits for various other editor
  3668.      commands, such as <LOCATE> and <CHANGE>. It effectively restricts
  3669.      to the specified columns those parts of the file which can be
  3670.      acted upon.
  3671.  
  3672.      If no 'last' option is specified '*' is assumed.
  3673.  
  3674. COMPATIBILITY
  3675.      XEDIT: Compatible.
  3676.      KEDIT: Compatible.
  3677.  
  3678. DEFAULT
  3679.      1 *
  3680.  
  3681. SEE ALSO
  3682.      <SET VERIFY>
  3683.  
  3684. STATUS
  3685.      Complete.
  3686. **man-end**********************************************************************/
  3687. #ifdef HAVE_PROTO
  3688. short Zone(CHARTYPE *params)
  3689. #else
  3690. short Zone(params)
  3691. CHARTYPE *params;
  3692. #endif
  3693. /***********************************************************************/
  3694. {
  3695. /*-------------------------- external data ----------------------------*/
  3696. /*--------------------------- local data ------------------------------*/
  3697. #define ZON_PARAMS  2
  3698.  CHARTYPE *word[ZON_PARAMS+1];
  3699.  CHARTYPE strip[ZON_PARAMS];
  3700.  unsigned short num_params=0;
  3701.  LINETYPE col1=0L,col2=0L;
  3702. /*--------------------------- processing ------------------------------*/
  3703. #ifdef TRACE
  3704.  trace_function("commset2.c:Zone");
  3705. #endif
  3706. /*---------------------------------------------------------------------*/
  3707. /* Validate the parameters that have been supplied. One only           */
  3708. /* parameter MUST be supplied. The first parameter MUST be a positive  */
  3709. /* integer. The second can be a positive integer or '*'. If no second  */
  3710. /* parameter is supplied, ERROR.          The second parameter MUST be */
  3711. /* >= first parameter. '*' is regarded as the biggest number and is    */
  3712. /* literally max_line_length.                                          */
  3713. /*---------------------------------------------------------------------*/
  3714.  strip[0]=STRIP_BOTH;
  3715.  strip[1]=STRIP_BOTH;
  3716.  num_params = param_split(params,word,ZON_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  3717.  if (num_params < 2)
  3718.    {
  3719.     display_error(3,(CHARTYPE *)"",FALSE);
  3720. #ifdef TRACE
  3721.     trace_return();
  3722. #endif
  3723.     return(RC_INVALID_OPERAND);
  3724.    }
  3725.  if (num_params > 2)
  3726.    {
  3727.     display_error(2,(CHARTYPE *)"",FALSE);
  3728. #ifdef TRACE
  3729.     trace_return();
  3730. #endif
  3731.     return(RC_INVALID_OPERAND);
  3732.    }
  3733.  if (!valid_positive_integer(word[0]))
  3734.    {
  3735.     display_error(4,word[0],FALSE);
  3736. #ifdef TRACE
  3737.     trace_return();
  3738. #endif
  3739.     return(RC_INVALID_OPERAND);
  3740.    }
  3741.  col1 = atol((DEFCHAR *)word[0]);
  3742.  if (strcmp((DEFCHAR *)word[1],"*") == 0)
  3743.     col2 = max_line_length;
  3744.  else
  3745.     if (!valid_positive_integer(word[1]))
  3746.       {
  3747.        display_error(4,word[1],FALSE);
  3748. #ifdef TRACE
  3749.        trace_return();
  3750. #endif
  3751.        return(RC_INVALID_OPERAND);
  3752.       }
  3753.     else
  3754.        col2 = atol((DEFCHAR *)word[1]);
  3755.  
  3756.  if (col2 > max_line_length)
  3757.     col2 = max_line_length;
  3758.  if (col1 > col2)
  3759.    {
  3760.     display_error(6,word[0],FALSE);
  3761. #ifdef TRACE
  3762.     trace_return();
  3763. #endif
  3764.     return(RC_INVALID_OPERAND);
  3765.    }
  3766.  CURRENT_VIEW->zone_start = (LENGTHTYPE)col1;
  3767.  CURRENT_VIEW->zone_end   = (LENGTHTYPE)col2;
  3768. /*---------------------------------------------------------------------*/
  3769. /* Change the current column pointer if it is outside the new zone     */
  3770. /* settings...                                                         */
  3771. /*---------------------------------------------------------------------*/
  3772.  if (CURRENT_VIEW->current_column < CURRENT_VIEW->zone_start)
  3773.     CURRENT_VIEW->current_column = max(1,CURRENT_VIEW->zone_start-1);
  3774.  if (CURRENT_VIEW->current_column > CURRENT_VIEW->zone_end)
  3775.     CURRENT_VIEW->current_column = min(max_line_length,CURRENT_VIEW->zone_end+1);
  3776. /*---------------------------------------------------------------------*/
  3777. /* If the SCALE line is currently displayed, display the page so that  */
  3778. /* any changes are reflected in the SCALE line.                        */
  3779. /*---------------------------------------------------------------------*/
  3780.  if (CURRENT_VIEW->scale_on)
  3781.    {
  3782.     build_screen(current_screen);
  3783.     display_screen(current_screen);
  3784.    }
  3785. #ifdef TRACE
  3786.  trace_return();
  3787. #endif
  3788.  return(RC_OK);
  3789. }
  3790.