home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / thesrc15.zip / commset1.c < prev    next >
C/C++ Source or Header  |  1993-11-17  |  71KB  |  2,501 lines

  1. /***********************************************************************/
  2. /* COMMSET1.C - SET commands A-N                                       */
  3. /***********************************************************************/
  4. /*
  5.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  6.  * Copyright (C) 1991-1993 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@gu.edu.au
  33.  * 36 David Road                     Phone: +61 7 849 7731
  34.  * Holland Park                      Fax:   +61 7 875 5314
  35.  * QLD 4121
  36.  * Australia
  37.  */
  38.  
  39. /*
  40. $Header: C:\THE\RCS\commset1.c 1.4 1993/09/01 16:25:50 MH Interim MH $
  41. */
  42.  
  43. #include <stdio.h>
  44.  
  45. #include "the.h"
  46. #include "proto.h"
  47.  
  48. /*#define DEBUG 1*/
  49. /*man-start*********************************************************************
  50.  
  51.  
  52.  
  53. ========================================================================
  54. SET COMMAND REFERENCE
  55. ========================================================================
  56. **man-end**********************************************************************/
  57.  
  58. /*-------------------------- external data ----------------------------*/
  59. extern VIEW_DETAILS *vd_current;
  60. extern char in_profile;    /* indicates if processing profile */
  61. extern char mode_insert;        /* defines insert mode toggle */
  62. extern char current_screen;
  63. extern SCREEN_DETAILS screen[MAX_SCREENS];        /* screen structures */
  64. extern WINDOW *foot,*error_window,*divider;
  65. /*man-start*********************************************************************
  66. COMMAND
  67.      arbchar - set arbitrary character for change commands
  68.  
  69. SYNTAX
  70.      [SET] ARBchar ON|OFF [char]
  71.  
  72. DESCRIPTION
  73.      Set the character to use as an 'arbitrary character' when using
  74.      change commands. When on the character specified no longer matches
  75.      itself in locating a character to change but matches all characters.
  76.  
  77. COMPATIBILITY
  78.      XEDIT: See below
  79.      KEDIT: See below
  80.      Only allows for single character matching, not multiple strings.
  81.  
  82. DEFAULT
  83.      OFF ?
  84.  
  85. SEE ALSO
  86.      Change,Schange and Locate
  87.  
  88. STATUS
  89.      Complete.
  90. **man-end**********************************************************************/
  91. #ifdef PROTO
  92. int Arbchar(char *params)
  93. #else
  94. int Arbchar(params)
  95. char *params;
  96. #endif
  97. /***********************************************************************/
  98. {
  99. /*------------------------- external data -----------------------------*/
  100. /*--------------------------- local data ------------------------------*/
  101. #define ARB_PARAMS  3
  102.  char *word[ARB_PARAMS+1];
  103.  unsigned short num_params;
  104.  int rc = RC_INVALID_OPERAND;
  105.  char arbsts=CURRENT_VIEW->arbchar_status;
  106.  char arbchr=CURRENT_VIEW->arbchar_char;
  107. /*--------------------------- processing ------------------------------*/
  108. #ifdef TRACE
  109.  trace_function("commset1.c:Arbchar");
  110. #endif
  111. /*---------------------------------------------------------------------*/
  112. /* Validate the parameters that have been supplied.                    */
  113. /*---------------------------------------------------------------------*/
  114.  num_params = param_split(params,word,ARB_PARAMS,WORD_DELIMS,TEMP_PARAM);
  115.  switch(num_params)
  116.    {
  117. /*---------------------------------------------------------------------*/
  118. /* No parameters, error.                                               */
  119. /*---------------------------------------------------------------------*/
  120.     case 0: 
  121.          display_error(3,(char *)""); 
  122.          break;
  123. /*---------------------------------------------------------------------*/
  124. /* 1 or 2 parameters, validate them...                                 */
  125. /*---------------------------------------------------------------------*/
  126.     case 1: 
  127.     case 2: 
  128.          if (equal((char *)"on",word[0],2))
  129.            {
  130.             arbsts = ON;
  131.             rc = RC_OK;
  132.            }
  133.          if (equal((char *)"off",word[0],3))
  134.            {
  135.             arbsts = OFF;
  136.             rc = RC_OK;
  137.            }
  138. /*---------------------------------------------------------------------*/
  139. /* If not a valid first parameter, display an error and exit.          */
  140. /*---------------------------------------------------------------------*/
  141.          if (rc != RC_OK)
  142.            {
  143.             display_error(1,word[0]);
  144.             break;
  145.            }
  146. /*---------------------------------------------------------------------*/
  147. /* For 1 parameter, don't check any more.                              */
  148. /*---------------------------------------------------------------------*/
  149.          if (num_params == 1)
  150.             break;
  151.          rc = RC_INVALID_OPERAND;
  152. /*---------------------------------------------------------------------*/
  153. /* For 2 parameters, check that a single character has been supplied...*/
  154. /*---------------------------------------------------------------------*/
  155.          if (strlen(word[1]) != 1)
  156.            {
  157.             display_error(1,word[1]);
  158.             break;
  159.            }
  160.          arbchr = word[1][0];
  161.          rc = RC_OK;
  162.          break;
  163. /*---------------------------------------------------------------------*/
  164. /* Too many parameters...                                              */
  165. /*---------------------------------------------------------------------*/
  166.     default:
  167.          display_error(2,(char *)""); 
  168.          break;
  169.    }
  170. /*---------------------------------------------------------------------*/
  171. /* If valid parameters, change the settings...                         */
  172. /*---------------------------------------------------------------------*/
  173.  if (rc == RC_OK)
  174.    {
  175.     CURRENT_VIEW->arbchar_char = arbchr;
  176.     CURRENT_VIEW->arbchar_status = arbsts;
  177.    }
  178. #ifdef TRACE
  179.  trace_return();
  180. #endif
  181.  return(rc);
  182. }
  183. /*man-start*********************************************************************
  184. COMMAND
  185.      autosave - set autosave period
  186.  
  187. SYNTAX
  188.      [SET] AUtosave n|OFF
  189.  
  190. DESCRIPTION
  191.      The AUTOSAVE command sets the interval between automatic saves
  192.      of the file, or turns it off altogether.
  193.  
  194. COMPATIBILITY
  195.      XEDIT: Does not support [mode] option.
  196.      KEDIT: Compatible.
  197.  
  198. STATUS
  199.      Complete.
  200. **man-end**********************************************************************/
  201. #ifdef PROTO
  202. int Autosave(char *params)
  203. #else
  204. int Autosave(params)
  205. char *params;
  206. #endif
  207. /***********************************************************************/
  208. {
  209. /*--------------------------- extern data -----------------------------*/
  210. extern char AUSx;
  211. /*--------------------------- local data ------------------------------*/
  212. #define AUS_PARAMS  1
  213.  char *word[AUS_PARAMS+1];
  214.  register int i;
  215.  unsigned short num_params;
  216.  long num_pages,num_lines;
  217.  unsigned short x,y;
  218. /*--------------------------- processing ------------------------------*/
  219. #ifdef TRACE
  220.  trace_function("commset1.c:Autosave");
  221. #endif
  222.  num_params = param_split(params,word,AUS_PARAMS,WORD_DELIMS,TEMP_PARAM);
  223.  if (num_params == 0)
  224.    {
  225.     display_error(3,(char *)"");
  226. #ifdef TRACE
  227.     trace_return();
  228. #endif
  229.     return(RC_INVALID_OPERAND);
  230.    }
  231.  if (num_params != 1)
  232.    {
  233.     display_error(2,(char *)"");
  234. #ifdef TRACE
  235.     trace_return();
  236. #endif
  237.     return(RC_INVALID_OPERAND);
  238.    }
  239.  if (equal((char *)"off",word[0],3))
  240.    {
  241.     CURRENT_FILE->autosave = 0;
  242. #ifdef TRACE
  243.     trace_return();
  244. #endif
  245.     return(RC_OK);
  246.    }
  247.  if (!valid_positive_integer(word[0]))
  248.    {
  249.     display_error(4,(char *)word[0]);
  250. #ifdef TRACE
  251.     trace_return();
  252. #endif
  253.     return(RC_INVALID_OPERAND);
  254.    }
  255.  CURRENT_FILE->autosave = AUSx =  (char)atoi(word[0]);
  256.  return(RC_OK);
  257. }
  258. /*man-start*********************************************************************
  259. COMMAND
  260.      backup - indicate if a backup copy of the file is to be kept
  261.  
  262. SYNTAX
  263.      [SET] BACKup ON|OFF
  264.  
  265. DESCRIPTION
  266.      The BACKUP command allows the user to determine if a backup copy
  267.      of the original file is to be kept when the file being edited is
  268.      saved or filed.
  269.  
  270. COMPATIBILITY
  271.      XEDIT: N/A
  272.      KEDIT: Does not support TEMP or KEEP options.
  273.  
  274. DEFAULT
  275.      ON - a backup file is kept
  276.  
  277. SEE ALSO
  278.      file,ffile,save,ssave
  279.  
  280. STATUS
  281.      Complete.
  282. **man-end**********************************************************************/
  283. #ifdef PROTO
  284. int Backup(char *params)
  285. #else
  286. int Backup(params)
  287. char *params;
  288. #endif
  289. /***********************************************************************/
  290. {
  291. /*-------------------------- external data ----------------------------*/
  292.  extern bool BACKUPx;
  293. /*--------------------------- local data ------------------------------*/
  294. /*--------------------------- processing ------------------------------*/
  295. #ifdef TRACE
  296.  trace_function("commset1.c:Backup");
  297. #endif
  298.  if (equal((char *)"off",params,3))
  299.     BACKUPx = FALSE;
  300.  else
  301.     if (equal((char *)"on",params,2))
  302.        BACKUPx = TRUE;
  303.     else
  304.       {
  305.        display_error(1,(char *)params);
  306. #ifdef TRACE
  307.        trace_return();
  308. #endif
  309.        return(RC_INVALID_OPERAND);
  310.       }
  311.  CURRENT_FILE->backup = BACKUPx;
  312. #ifdef TRACE
  313.  trace_return();
  314. #endif
  315.  return(RC_OK);
  316. }
  317. /*man-start*********************************************************************
  318. COMMAND
  319.      beep - turn on or off the audible alarm when displaying errors
  320.  
  321. SYNTAX
  322.      [SET] BEEP ON|OFF
  323.  
  324. DESCRIPTION
  325.      The BEEP command allows the user to determine if an audible alarm
  326.      is sounded when an error is displayed.
  327.  
  328. COMPATIBILITY
  329.      XEDIT: N/A
  330.      KEDIT: Compatible.
  331.  
  332. DEFAULT
  333.      OFF
  334.  
  335. STATUS
  336.      Complete.
  337. **man-end**********************************************************************/
  338. #ifdef PROTO
  339. int BeepSound(char *params)
  340. #else
  341. int BeepSound(params)
  342. char *params;
  343. #endif
  344. /***********************************************************************/
  345. {
  346. /*-------------------------- external data ----------------------------*/
  347.  extern bool BEEPx;
  348. /*--------------------------- local data ------------------------------*/
  349. /*--------------------------- processing ------------------------------*/
  350. #ifdef TRACE
  351.  trace_function("commset1.c:BeepSound");
  352. #endif
  353.  if (equal((char *)"off",params,3))
  354.     BEEPx = FALSE;
  355.  else
  356.     if (equal((char *)"on",params,2))
  357.        BEEPx = TRUE;
  358.     else
  359.       {
  360.        display_error(1,(char *)params);
  361. #ifdef TRACE
  362.        trace_return();
  363. #endif
  364.        return(RC_INVALID_OPERAND);
  365.       }
  366. #ifdef TRACE
  367.  trace_return();
  368. #endif
  369.  return(RC_OK);
  370. }
  371. /*man-start*********************************************************************
  372. COMMAND
  373.      case - set case sensitivity parameters
  374.  
  375. SYNTAX
  376.      [SET] CASE Mixed|Lower|Upper [Respect|Ignore] [Respect|Ignore]
  377.                                   [Respect|Ignore]
  378.  
  379. DESCRIPTION
  380.      The CASE command sets the editor's handling of the case of text.
  381.  
  382.      The first option (which is mandatory) controls how text is entered
  383.      by the user. When LOWER or UPPER are in effect, the shift or caps
  384.      lock keys have no effect on the text being entered. When MIXED is
  385.      in effect, text is entered in the case set by the use of the shift
  386.      and caps lock keys.
  387.  
  388.      The second option determines how the editor determines if a string
  389.      target matches text in the file when the target is used in a LOCATE
  390.      command.  With IGNORE in effect, a match is
  391.      found irrespective of the case of the target or the found text.
  392.      The following strings are treated as equivalent: the THE The ThE...
  393.      With RESPECT in effect, the target and text must be the same case.
  394.      Therefore a target of 'The' only matches text containing 'The', not
  395.      'THE' or 'ThE' etc.
  396.  
  397.      The third option determines how the editor determines if a string
  398.      target matches text in the file when the target is used in a CHANGE
  399.      command.  With IGNORE in effect, a match is
  400.      found irrespective of the case of the target or the found text.
  401.      The following strings are treated as equivalent: the THE The ThE...
  402.      With RESPECT in effect, the target and text must be the same case.
  403.      Therefore a target of 'The' only matches text containing 'The', not
  404.      'THE' or 'ThE' etc.
  405.  
  406.      The fourth option determines how the editor determines the sort 
  407.      order of upper and lower case with the SORT command.
  408.      With IGNORE in effect, upper and lower case letters are treated as
  409.      equivalent.
  410.      With RESPECT in effect, upper and lower case letters are treated as
  411.      different values and uppercase characters will sort before lowercase
  412.      characters.
  413.  
  414. COMPATIBILITY
  415.      XEDIT: Adds support for case significance in CHANGE commands.
  416.      KEDIT: Adds support for LOWER option.
  417.      Both:  Adds support for case significance in SORT command.
  418.  
  419. DEFAULT
  420.      MIXED IGNORE RESPECT RESPECT
  421.  
  422. STATUS
  423.      Complete
  424. **man-end**********************************************************************/
  425. #ifdef PROTO
  426. int Case(char *params)
  427. #else
  428. int Case(params)
  429. char *params;
  430. #endif
  431. /***********************************************************************/
  432. {
  433. /*--------------------------- extern data -----------------------------*/
  434. /*--------------------------- local data ------------------------------*/
  435. #define CAS_PARAMS  4
  436.  char parm[CAS_PARAMS];
  437.  char *word[CAS_PARAMS+1];
  438.  register int i;
  439.  unsigned short num_params;
  440. /*--------------------------- processing ------------------------------*/
  441. #ifdef TRACE
  442.  trace_function("commset1.c:Case");
  443. #endif
  444.  num_params = param_split(params,word,CAS_PARAMS,WORD_DELIMS,TEMP_PARAM);
  445. /*---------------------------------------------------------------------*/
  446. /* Validate the first parameter: must be Mixed, Upper or Lower         */
  447. /*---------------------------------------------------------------------*/
  448.  parm[0] = (char)UNDEFINED_OPERAND;
  449.  if (equal((char *)"mixed",word[0],1))
  450.     parm[0] = CASE_MIXED;
  451.  if (equal((char *)"upper",word[0],1))
  452.     parm[0] = CASE_UPPER;
  453.  if (equal((char *)"lower",word[0],1))
  454.     parm[0] = CASE_LOWER;
  455.  if (parm[0] == (char)UNDEFINED_OPERAND)
  456.     {
  457.      display_error(1,(char *)word[0]);
  458. #ifdef TRACE
  459.      trace_return();
  460. #endif
  461.      return(RC_INVALID_OPERAND);
  462.     }
  463. /*---------------------------------------------------------------------*/
  464. /* Save the current values of each remaining case setting.             */
  465. /*---------------------------------------------------------------------*/
  466.  parm[1] = CURRENT_VIEW->case_locate;
  467.  parm[2] = CURRENT_VIEW->case_change;
  468.  parm[3] = CURRENT_VIEW->case_sort;
  469. /*---------------------------------------------------------------------*/
  470. /* Validate the remainder of the arguments.                            */
  471. /* Each must be Respect or Ignore, if present.                         */
  472. /*---------------------------------------------------------------------*/
  473.  for (i=1;i<num_params;i++)
  474.    {
  475.     if (strcmp(word[1],"") != 0)
  476.       {
  477.        if (equal((char *)"respect",word[i],1))
  478.           parm[i] = CASE_RESPECT;
  479.        else
  480.           if (equal((char *)"ignore",word[i],1))
  481.              parm[i] = CASE_IGNORE;
  482.           else
  483.             {
  484.              display_error(1,(char *)word[i]);
  485. #ifdef TRACE
  486.              trace_return();
  487. #endif
  488.              return(RC_INVALID_OPERAND);
  489.             }
  490.       }
  491.    }
  492. /*---------------------------------------------------------------------*/
  493. /* Set the new values of case settings for the view.                   */
  494. /*---------------------------------------------------------------------*/
  495.  CURRENT_VIEW->case_enter  = parm[0];
  496.  CURRENT_VIEW->case_locate = parm[1];
  497.  CURRENT_VIEW->case_change = parm[2];
  498.  CURRENT_VIEW->case_sort   = parm[3];
  499.  
  500. #ifdef TRACE
  501.  trace_return();
  502. #endif
  503.  return(RC_OK);
  504. }
  505. /*man-start*********************************************************************
  506. COMMAND
  507.      clearscreen - indicate if the screen is to be cleared on exit
  508.  
  509. SYNTAX
  510.      [SET] CLEARScreen ON|OFF
  511.  
  512. DESCRIPTION
  513.      The CLEARSCREEN command allows the user to request that the screen be
  514.      cleared on exit from THE.
  515.  
  516. COMPATIBILITY
  517.      XEDIT: N/A
  518.      KEDIT: N/A
  519.  
  520. DEFAULT
  521.      OFF - a clear screen does not occur.
  522.  
  523. STATUS
  524.      Complete
  525. **man-end**********************************************************************/
  526. #ifdef PROTO
  527. int Clearscreen(char *params)
  528. #else
  529. int Clearscreen(params)
  530. char *params;
  531. #endif
  532. /***********************************************************************/
  533. {
  534. /*--------------------------- local data ------------------------------*/
  535.  extern bool CLEARSCREENx;
  536. /*--------------------------- processing ------------------------------*/
  537. #ifdef TRACE
  538.  trace_function("commset1.c:Clearscreen");
  539. #endif
  540.  if (equal((char *)"off",params,3))
  541.     CLEARSCREENx = FALSE;
  542.  else
  543.     if (equal((char *)"on",params,2))
  544.        CLEARSCREENx = TRUE;
  545.     else
  546.       {
  547.        display_error(1,(char *)params);
  548. #ifdef TRACE
  549.        trace_return();
  550. #endif
  551.        return(RC_INVALID_OPERAND);
  552.       }
  553. #ifdef TRACE
  554.  trace_return();
  555. #endif
  556.  return(RC_OK);
  557. }
  558. /*man-start*********************************************************************
  559. COMMAND
  560.      clock - turn on or display of time on status line
  561.  
  562. SYNTAX
  563.      [SET] CLOCK ON|OFF
  564.  
  565. DESCRIPTION
  566.      The CLOCK command turns on or off the display of the time on the
  567.      status line.
  568.  
  569. COMPATIBILITY
  570.      XEDIT: N/A
  571.      KEDIT: Compatible.
  572.  
  573. DEFAULT
  574.      ON - the time is displayed.
  575.  
  576. STATUS
  577.      Complete
  578. **man-end**********************************************************************/
  579. #ifdef PROTO
  580. int Clock(char *params)
  581. #else
  582. int Clock(params)
  583. char *params;
  584. #endif
  585. /***********************************************************************/
  586. {
  587. /*--------------------------- local data ------------------------------*/
  588.  extern bool CLOCKx;
  589. /*--------------------------- processing ------------------------------*/
  590. #ifdef TRACE
  591.  trace_function("commset1.c:Clock");
  592. #endif
  593.  if (equal((char *)"off",params,3))
  594.     CLOCKx = FALSE;
  595.  else
  596.     if (equal((char *)"on",params,2))
  597.        CLOCKx = TRUE;
  598.     else
  599.       {
  600.        display_error(1,(char *)params);
  601. #ifdef TRACE
  602.        trace_return();
  603. #endif
  604.        return(RC_INVALID_OPERAND);
  605.       }
  606.  clear_footing();
  607. #ifdef TRACE
  608.  trace_return();
  609. #endif
  610.  return(RC_OK);
  611. }
  612. /*man-start*********************************************************************
  613. COMMAND
  614.      cmdarrows - sets the functionality of the arrows keys
  615.  
  616. SYNTAX
  617.      [SET] CMDArrows Retrieve|Tab Scroll|Tab Scroll|Tab
  618.  
  619. DESCRIPTION
  620.      The CMDARROWS command determines the action that occurs when the
  621.      arrows keys are hit.
  622.  
  623.      CMDARROWS RETRIEVE SCROLL SCROLL (the default) will set the up and 
  624.      down arrows to retrieve the last or next command entered on the command 
  625.      line and to scroll the screen when at the top or bottom of the main
  626.      text window. The left and right arrows will cause the main text window 
  627.      to scroll if appropriate.
  628.  
  629.      CMDARROWS TAB TAB TAB will set the up and down arrows to move to the
  630.      last or first line respectively of the main window and to return to 
  631.      the command line when the top or bottom of the main text window is 
  632.      reached. The left and right arrows will wrap around the window if on
  633.      the command line or no prefix is on or to move between the prefix area.
  634.      This behaviour is more like XEDIT.
  635.  
  636. DEFAULT
  637.      RETRIEVE SCROLL SCROLL
  638.  
  639. COMPATIBILITY
  640.      XEDIT: N/A
  641.      KEDIT: N/A
  642.  
  643. STATUS
  644.      Complete.
  645. **man-end**********************************************************************/
  646. #ifdef PROTO
  647. int Cmdarrows(char *params)
  648. #else
  649. int Cmdarrows(params)
  650. char *params;
  651. #endif
  652. /***********************************************************************/
  653. {
  654. /*------------------------- external data -----------------------------*/
  655. extern char CMDARROWSTABCMDx;
  656. extern char CMDARROWSTABTXTx;
  657. extern char CMDARROWSTABLRx;
  658. /*--------------------------- local data ------------------------------*/
  659. #define CMD_PARAMS  3
  660.  char *word[CMD_PARAMS+1];
  661.  char parm[CMD_PARAMS];
  662.  int num_params;
  663. /*--------------------------- processing ------------------------------*/
  664. #ifdef TRACE
  665.  trace_function("commset1.c:Cmdarrows");
  666. #endif
  667.  parm[0] = (char)UNDEFINED_OPERAND;
  668.  parm[1] = (char)UNDEFINED_OPERAND;
  669. /*---------------------------------------------------------------------*/
  670. /* Validate the parameters that have been supplied.                    */
  671. /* 2 Parameters are mandatory.                                         */
  672. /*---------------------------------------------------------------------*/
  673.  num_params = param_split(params,word,CMD_PARAMS,WORD_DELIMS,TEMP_PARAM);
  674.  if (num_params < 3)
  675.    {
  676.     display_error(3,(char *)"");
  677. #ifdef TRACE
  678.     trace_return();
  679. #endif
  680.     return(RC_INVALID_OPERAND);
  681.    }
  682.  if (num_params > 3)
  683.    {
  684.     display_error(2,(char *)"");
  685. #ifdef TRACE
  686.     trace_return();
  687. #endif
  688.     return(RC_INVALID_OPERAND);
  689.    }
  690. /*---------------------------------------------------------------------*/
  691. /* Determine values for first parameter; command line behaviour        */
  692. /*---------------------------------------------------------------------*/
  693.  if (equal((char *)"tab",word[0],1))
  694.    {
  695.     CMDARROWSTABCMDx = TRUE;
  696.     parm[0] = TRUE;
  697.    }
  698.  if (equal((char *)"retrieve",word[0],1))
  699.    {
  700.     CMDARROWSTABCMDx = FALSE;
  701.     parm[0] = TRUE;
  702.    }
  703.  if (parm[0] == (char)UNDEFINED_OPERAND)
  704.    {
  705.     display_error(1,word[0]);
  706. #ifdef TRACE
  707.     trace_return();
  708. #endif
  709.     return(RC_INVALID_OPERAND);
  710.    }
  711. /*---------------------------------------------------------------------*/
  712. /* Determine values for second parameter; main text window behaviour   */
  713. /*---------------------------------------------------------------------*/
  714.  if (equal((char *)"tab",word[1],1))
  715.    {
  716.     CMDARROWSTABTXTx = TRUE;
  717.     parm[1] = TRUE;
  718.    }
  719.  if (equal((char *)"scroll",word[1],1))
  720.    {
  721.     CMDARROWSTABTXTx = FALSE;
  722.     parm[1] = TRUE;
  723.    }
  724.  if (parm[1] == (char)UNDEFINED_OPERAND)
  725.    {
  726.     display_error(1,word[1]);
  727. #ifdef TRACE
  728.     trace_return();
  729. #endif
  730.     return(RC_INVALID_OPERAND);
  731.    }
  732. /*---------------------------------------------------------------------*/
  733. /* Determine values for third parameter; left/right arrow keys         */
  734. /*---------------------------------------------------------------------*/
  735.  if (equal((char *)"tab",word[2],1))
  736.    {
  737.     CMDARROWSTABLRx = TRUE;
  738.     parm[2] = TRUE;
  739.    }
  740.  if (equal((char *)"scroll",word[2],1))
  741.    {
  742.     CMDARROWSTABLRx = FALSE;
  743.     parm[2] = TRUE;
  744.    }
  745.  if (parm[2] == (char)UNDEFINED_OPERAND)
  746.    {
  747.     display_error(1,word[2]);
  748. #ifdef TRACE
  749.     trace_return();
  750. #endif
  751.     return(RC_INVALID_OPERAND);
  752.    }
  753.  
  754. #ifdef TRACE
  755.  trace_return();
  756. #endif
  757.  return(RC_OK);
  758. }
  759. /*man-start*********************************************************************
  760. COMMAND
  761.      cmdline - sets the position of the command line.
  762.  
  763. SYNTAX
  764.      [SET] CMDline Top|Bottom
  765.  
  766. DESCRIPTION
  767.      The CMDLINE command sets the position of the command line, either
  768.      at the top of the screen or at the bottom of the screen.
  769.  
  770. COMPATIBILITY
  771.      XEDIT: Does not allow CMDLINE to be turned OFF.
  772.      KEDIT: Compatible.
  773.  
  774. STATUS
  775.      Complete.
  776. **man-end**********************************************************************/
  777. #ifdef PROTO
  778. int Cmdline(char *params)
  779. #else
  780. int Cmdline(params)
  781. char *params;
  782. #endif
  783. /***********************************************************************/
  784. {
  785. /*------------------------- external data -----------------------------*/
  786. extern char CMD_LINEx;
  787. /*--------------------------- local data ------------------------------*/
  788.  char cmd_place='?';
  789.  int off;
  790.  unsigned short y,x;
  791. /*--------------------------- processing ------------------------------*/
  792. #ifdef TRACE
  793.  trace_function("commset1.c:Cmdline");
  794. #endif
  795.  if (equal((char *)"top",params,1))
  796.    {
  797.     cmd_place='T';
  798.     off = 1;
  799.    }
  800.  if (equal((char *)"bottom",params,1))
  801.    {
  802.     cmd_place='B';
  803.     off = (-1);
  804.    }
  805.  if (cmd_place=='?')
  806.    {
  807.     display_error(1,(char *)params);
  808. #ifdef TRACE
  809.     trace_return();
  810. #endif
  811.     return(RC_INVALID_OPERAND);
  812.    }
  813. /*---------------------------------------------------------------------*/
  814. /* If the setting supplied is the same as the current setting, just    */
  815. /* return without doing anything.                                      */
  816. /*---------------------------------------------------------------------*/
  817.  if (cmd_place == CURRENT_VIEW->cmd_line)
  818.    {
  819. #ifdef TRACE
  820.     trace_return();
  821. #endif
  822.     return(RC_OK);
  823.    }
  824. /*---------------------------------------------------------------------*/
  825. /* Now we need to move the windows around.                             */
  826. /*---------------------------------------------------------------------*/
  827.  CURRENT_VIEW->cmd_line = cmd_place;
  828.  if (cmd_place == 'T')
  829.     CURRENT_VIEW->command_row = CURRENT_SCREEN.origin_y+1;
  830.  else
  831.     CURRENT_VIEW->command_row = CURRENT_SCREEN.origin_y+CURRENT_SCREEN.screen_rows-1;
  832. /*---------------------------------------------------------------------*/
  833. /* If we are in the profile, exit here.                                */
  834. /*---------------------------------------------------------------------*/
  835.  if (in_profile)
  836.    {
  837. #ifdef TRACE
  838.     trace_return();
  839. #endif
  840.     return(RC_OK);
  841.    }
  842.  
  843.  getbegyx(CURRENT_WINDOW_MAIN,y,x);
  844.  mvwin(CURRENT_WINDOW_MAIN,y+off,x);
  845.  if (CURRENT_VIEW->prefix)
  846.    {
  847.     getbegyx(CURRENT_WINDOW_PREFIX,y,x);
  848.     mvwin(CURRENT_WINDOW_PREFIX,y+off,x);
  849.    }
  850.  getbegyx(CURRENT_WINDOW_COMMAND,y,x);
  851.  mvwin(CURRENT_WINDOW_COMMAND,CURRENT_VIEW->command_row,x);
  852.  getbegyx(CURRENT_WINDOW_ARROW,y,x);
  853.  mvwin(CURRENT_WINDOW_ARROW,CURRENT_VIEW->command_row,x);
  854.  touchwin(CURRENT_WINDOW_ARROW);
  855.  wnoutrefresh(CURRENT_WINDOW_ARROW);
  856. #ifdef TRACE
  857.  trace_return();
  858. #endif
  859.  return(RC_OK);
  860. }
  861. /*man-start*********************************************************************
  862. COMMAND
  863.      colour - set colours for display
  864.  
  865. SYNTAX
  866.      [SET] COLOUR|COLOR area [modifier] [foreground background]
  867.  
  868. DESCRIPTION
  869.      The COLOUR command changes the colours or display attributes of
  870.      various display areas in THE.
  871.  
  872.      Valid values for 'area':
  873.        filearea - area containing file lines
  874.        curline  - the current line
  875.        block    - marked block
  876.        cblock   - current line if in marked block
  877.        cmdline  - command line
  878.        idline   - line containing file specific info
  879.        msgline  - error messages
  880.        arrow    - command line prompt
  881.        prefix   - prefix area
  882.        pending  - pending commands in prefix
  883.        scale    - line showing scale line (N/A)
  884.        tofeof   - *** Top of File *** and *** Bottom of File *** lines
  885.        ctofeof  - as above if the same as current line
  886.        tabline  - line showing tab positions (N/A)
  887.        shadow   - hidden line marker lines (N/A)
  888.        statarea - line showing status of editing session
  889.        divider  - dividing line between vertical split screens (N/A)
  890.        reserved - any reserved lines
  891.  
  892.      Valid values for 'foreground' and 'background':
  893.        black,blue,green,cyan,red,magenta,yellow,white
  894.  
  895.      Valid values for 'modifier':
  896.        normal,blink,bold,bright,high,reverse,underline
  897.  
  898.      It is an error to attempt to set a colour on a mono display.
  899.  
  900. COMPATIBILITY
  901.      XEDIT: Functionally compatible. See below.
  902.      KEDIT: Functionally compatible. See below.
  903.      Does not implement all modifiers.
  904.  
  905. STATUS  
  906.      Complete.
  907. **man-end**********************************************************************/
  908. #ifdef PROTO
  909. int Colour(char *params)
  910. #else
  911. int Colour(params)
  912. char *params;
  913. #endif
  914.  
  915. /***********************************************************************/
  916. {
  917. /*--------------------------- local data ------------------------------*/
  918.  struct areas
  919.  {
  920.   char *area;
  921.   short area_min_len;
  922.   short area_window;
  923.  };
  924.  typedef struct areas AREAS;
  925.  static AREAS valid_areas[ATTR_MAX]=
  926.  {
  927.   {(char *)"filearea",1,WINDOW_MAIN},
  928.   {(char *)"curline",2,WINDOW_MAIN},
  929.   {(char *)"block",1,WINDOW_MAIN},
  930.   {(char *)"cblock",2,WINDOW_MAIN},
  931.   {(char *)"cmdline",1,WINDOW_COMMAND},
  932.   {(char *)"idline",1,WINDOW_IDLINE},
  933.   {(char *)"msgline",1,WINDOW_ERROR},
  934.   {(char *)"arrow",1,WINDOW_ARROW},
  935.   {(char *)"prefix",2,WINDOW_PREFIX},
  936.   {(char *)"pending",1,WINDOW_PREFIX},
  937.   {(char *)"scale",1,WINDOW_MAIN},
  938.   {(char *)"tofeof",2,WINDOW_MAIN},
  939.   {(char *)"ctofeof",2,WINDOW_MAIN},
  940.   {(char *)"tabline",1,WINDOW_MAIN},
  941.   {(char *)"shadow",2,WINDOW_MAIN},
  942.   {(char *)"statarea",2,WINDOW_FOOTING},
  943.   {(char *)"divider",1,WINDOW_DIVIDER},
  944.   {(char *)"reserved",1,WINDOW_RESERVED}
  945.  };
  946. #define COL_PARAMS 2
  947.  char *word[COL_PARAMS+1];
  948.  char parm[COL_PARAMS];
  949.  register int i;
  950.  unsigned short num_params;
  951.  int area;
  952.  chtype fg,bg,mod;
  953. /*--------------------------- processing ------------------------------*/
  954. #ifdef TRACE
  955.  trace_function("commset1.c:Colour");
  956. #endif
  957.  num_params = param_split(params,word,COL_PARAMS,WORD_DELIMS,TEMP_PARAM);
  958.  if (num_params < 2 )
  959.     {
  960.      display_error(3,(char *)"");
  961. #ifdef TRACE
  962.      trace_return();
  963. #endif
  964.      return(RC_INVALID_OPERAND);
  965.     }
  966. /*---------------------------------------------------------------------*/
  967. /* Check that the supplied area matches one of the values in the area  */
  968. /* array and that the length is at least as long as the minimum.       */
  969. /*---------------------------------------------------------------------*/
  970.  parm[0] = FALSE;
  971.  for (i=0;i<ATTR_MAX;i++)
  972.     {
  973.      if (equal(valid_areas[i].area,word[0],valid_areas[i].area_min_len))
  974.        {
  975.         parm[0] = TRUE;
  976.         area = i;
  977.         break;
  978.        }
  979.     }
  980.  if (parm[0] == FALSE)
  981.     {
  982.      display_error(1,(char *)word[0]);
  983. #ifdef TRACE
  984.      trace_return();
  985. #endif
  986.      return(RC_INVALID_OPERAND);
  987.     }
  988. /*---------------------------------------------------------------------*/
  989. /* Determine colours and modifiers.                                    */
  990. /*---------------------------------------------------------------------*/
  991.  
  992.  if (parse_colours(word[1],&fg,&bg,&mod) != RC_OK)
  993.    {
  994. #ifdef TRACE
  995.     trace_return();
  996. #endif
  997.     return(RC_INVALID_OPERAND);
  998.    }
  999. /*---------------------------------------------------------------------*/
  1000. /* If we are still in the profile, save the colour setup for later...  */
  1001. /*---------------------------------------------------------------------*/
  1002.  
  1003.  if (in_profile)
  1004.    {
  1005.     colour[area] = (chtype)1;
  1006.     save_fg[area] = fg;
  1007.     save_bg[area] = bg;
  1008.     save_mod[area] = mod;
  1009. #ifdef TRACE
  1010.     trace_return();
  1011. #endif
  1012.     return(RC_OK);
  1013.    }
  1014. /*---------------------------------------------------------------------*/
  1015. /* Set the colours.                                                    */
  1016. /*---------------------------------------------------------------------*/
  1017.  
  1018.  set_colour(area,fg,bg,mod);
  1019.  
  1020. /*---------------------------------------------------------------------*/
  1021. /* Update the appropriate window with the new colour combination.      */
  1022. /*---------------------------------------------------------------------*/
  1023.  
  1024.  switch (valid_areas[area].area_window)
  1025.    {
  1026.     case WINDOW_MAIN:
  1027.                         if (area == ATTR_FILEAREA)
  1028.                            wattrset(CURRENT_WINDOW_MAIN,colour[area]);
  1029.                         redraw_window(CURRENT_WINDOW_MAIN);
  1030.                         show_page();
  1031.                         touchwin(CURRENT_WINDOW_MAIN);
  1032.                         wnoutrefresh(CURRENT_WINDOW_MAIN);
  1033.                         break;
  1034.     case WINDOW_PREFIX:
  1035.                         if (CURRENT_VIEW->prefix)
  1036.                           {
  1037.                            wattrset(CURRENT_WINDOW_PREFIX,colour[area]);
  1038.                            redraw_window(CURRENT_WINDOW_PREFIX);
  1039.                            touchwin(CURRENT_WINDOW_PREFIX);
  1040.                            wnoutrefresh(CURRENT_WINDOW_PREFIX);
  1041.                           }
  1042.                         break;
  1043.     case WINDOW_COMMAND:
  1044.                         wattrset(CURRENT_WINDOW_COMMAND,colour[area]);
  1045.                         redraw_window(CURRENT_WINDOW_COMMAND);
  1046.                         touchwin(CURRENT_WINDOW_COMMAND);
  1047.                         wnoutrefresh(CURRENT_WINDOW_COMMAND);
  1048.                         break;
  1049.     case WINDOW_ARROW:
  1050.                         wattrset(CURRENT_WINDOW_ARROW,colour[area]);
  1051.                         redraw_window(CURRENT_WINDOW_ARROW);
  1052.                         touchwin(CURRENT_WINDOW_ARROW);
  1053.                         wnoutrefresh(CURRENT_WINDOW_ARROW);
  1054.                         break;
  1055.     case WINDOW_IDLINE:
  1056.                         wattrset(CURRENT_WINDOW_IDLINE,colour[area]);
  1057.                         redraw_window(CURRENT_WINDOW_IDLINE);
  1058.                         touchwin(CURRENT_WINDOW_IDLINE);
  1059.                         wnoutrefresh(CURRENT_WINDOW_IDLINE);
  1060.                         break;
  1061.     case WINDOW_FOOTING:
  1062.                         wattrset(foot,colour[area]);
  1063.                         redraw_window(foot);
  1064.                         touchwin(foot);
  1065.                         wnoutrefresh(foot);
  1066.                         break;
  1067.     case WINDOW_ERROR:
  1068.                         wattrset(error_window,colour[area]);
  1069.                         break;
  1070.     case WINDOW_DIVIDER:
  1071.                         wattrset(divider,colour[area]);
  1072.                         break;
  1073.     case WINDOW_RESERVED:
  1074.                         wattrset(stdscr,colour[area]);
  1075.                         break;
  1076.     default:
  1077.                         break;
  1078.    }
  1079. #ifdef TRACE
  1080.  trace_return();
  1081. #endif
  1082.  return(RC_OK);
  1083. }
  1084. /*man-start*********************************************************************
  1085. COMMAND
  1086.      curline - set position of current line on screen
  1087.  
  1088. SYNTAX
  1089.      [SET] CURLine M[+n|-n] | [+|-]n
  1090.  
  1091. DESCRIPTION
  1092.      The CURLINE command sets the position of the current line to
  1093.      the physical screen line specified by supplied arguments.
  1094.  
  1095.      The two forms of parameters are:
  1096.      M[+n|-n] - this sets the current line to be relative to the
  1097.                 middle of the screen. A positvie value adds to the
  1098.                 middle line number, a negative subtracts from it.
  1099.                 eg. M+3 on a 24 line screen will be line 15
  1100.                     M-5 on a 24 line screen will be line 7
  1101.  
  1102.      [+|-]n   - this sets the current line to be relative to the
  1103.                 top of the screen (if positive or no sign) or
  1104.                 relative to the bottom of the screen if negative.
  1105.                 eg. +3 or 3 will set current line to line 3
  1106.                     -3 on a 24 line screen will be line 21
  1107.  
  1108.      If the resulting line is outside the bounds of the screen
  1109.      the position of the current line will become the middle line
  1110.      on the screen.
  1111.  
  1112. COMPATIBILITY
  1113.      XEDIT: Compatible.
  1114.      KEDIT: Compatible.
  1115.  
  1116. STATUS
  1117.      Complete.
  1118. **man-end**********************************************************************/
  1119. #ifdef PROTO
  1120. int Curline(char *params)
  1121. #else
  1122. int Curline(params)
  1123. char *params;
  1124. #endif
  1125. /***********************************************************************/
  1126. {
  1127. /*--------------------------- local data ------------------------------*/
  1128. #define CUR_PARAMS  1
  1129.  char *word[CUR_PARAMS+1];
  1130.  int num_params;
  1131.  int rc;
  1132.  int base,off;
  1133. /*--------------------------- processing ------------------------------*/
  1134. #ifdef TRACE
  1135.  trace_function("commset1.c:Curline");
  1136. #endif
  1137.  num_params = param_split(params,word,CUR_PARAMS,WORD_DELIMS,TEMP_PARAM);
  1138.  if (num_params < 1)
  1139.    {
  1140.     display_error(3,(char *)"");
  1141. #ifdef TRACE
  1142.     trace_return();
  1143. #endif
  1144.     return(RC_INVALID_OPERAND);
  1145.    }
  1146.  if (num_params > 1)
  1147.    {
  1148.     display_error(2,(char *)"");
  1149. #ifdef TRACE
  1150.     trace_return();
  1151. #endif
  1152.     return(RC_INVALID_OPERAND);
  1153.    }
  1154. /*---------------------------------------------------------------------*/
  1155. /* Parse the parameter...                                              */
  1156. /*---------------------------------------------------------------------*/
  1157.  if (*params == 'M'
  1158.  ||  *params == 'm')
  1159.    {
  1160.     base = CURLINE_MIDDLE;
  1161.     params++;
  1162.     if (blank_field(params))
  1163.        off = 0;
  1164.     else
  1165.       {
  1166.        if ((*params != '-'
  1167.        &&  *params != '+')
  1168.        || ((off = atoi(params)) == 0))
  1169.          {
  1170.           display_error(1,params);
  1171. #ifdef TRACE
  1172.           trace_return();
  1173. #endif
  1174.           return(RC_INVALID_OPERAND);
  1175.          }
  1176.       }
  1177.    }
  1178.  else
  1179.    {
  1180.     if ((off = atoi(params)) == 0)
  1181.       {
  1182.        display_error(1,params);
  1183. #ifdef TRACE
  1184.        trace_return();
  1185. #endif
  1186.        return(RC_INVALID_OPERAND);
  1187.       }
  1188.     base = (off > 0) ? CURLINE_TOP : CURLINE_BOTTOM;
  1189.    }
  1190.  CURRENT_VIEW->current_base = (char)base;
  1191.  CURRENT_VIEW->current_off = (char)off;
  1192.  if (!in_profile)
  1193.    {
  1194.     post_process_line(CURRENT_VIEW->focus_line);
  1195.     CURRENT_VIEW->current_row = calculate_current_row(CURRENT_VIEW->current_base,
  1196.                                                       CURRENT_VIEW->current_off,
  1197.                                                       CURRENT_SCREEN.rows);
  1198.     show_page();
  1199.    }
  1200.  
  1201. #ifdef TRACE
  1202.  trace_return();
  1203. #endif
  1204.  return(RC_OK);
  1205. }
  1206. /*man-start*********************************************************************
  1207. COMMAND
  1208.      dirinclude - set the file mask for directory command
  1209.  
  1210. SYNTAX
  1211.      [SET] DIRInclude * 
  1212.      [SET] DIRInclude [Normal] [Readonly] [System] [Hidden] [Directory]
  1213.  
  1214. DESCRIPTION
  1215.      The DIRINCLUDE command sets the file mask for files that will be
  1216.      displayed on subsequent DIRECTORY commands.
  1217.      * will set the mask to all files, the other options will set the
  1218.      mask to include those options specified together with "normal"
  1219.      files eg.
  1220.  
  1221.       DIRINCLUDE R S
  1222.  
  1223.      will display readonly and system files together with "normal" files
  1224.      the next time the DIRECTORY command is issued.
  1225.  
  1226.      The effects of DIRINCLUDE are ignored in the Unix version.
  1227.  
  1228. COMPATIBILITY
  1229.      XEDIT: N/A
  1230.      KEDIT: N/A
  1231.  
  1232. SEE ALSO
  1233.      directory
  1234.  
  1235. STATUS
  1236.      Complete.
  1237. **man-end**********************************************************************/
  1238. #ifdef PROTO
  1239. int Dirinclude(char *params)
  1240. #else
  1241. int Dirinclude(params)
  1242. char *params;
  1243. #endif
  1244. /***********************************************************************/
  1245. {
  1246. /*--------------------------- local data ------------------------------*/
  1247.  int rc;
  1248. /*--------------------------- processing ------------------------------*/
  1249. #ifdef TRACE
  1250.  trace_function("commset1.c:Dirinclude");
  1251. #endif
  1252.  rc = set_dirtype(params);
  1253. #ifdef TRACE
  1254.  trace_return();
  1255. #endif
  1256.  return(rc);
  1257. }
  1258. /*man-start*********************************************************************
  1259. COMMAND
  1260.      display - specify which level of lines to display
  1261.  
  1262. SYNTAX
  1263.      [SET] DISPlay n [m|*]
  1264.  
  1265. DESCRIPTION
  1266.      The DISPLAY command sets the selection level for lines to be
  1267.      displayed on the screen.
  1268.  
  1269. COMPATIBILITY
  1270.      XEDIT: Compatible.
  1271.      KEDIT: Compatible.
  1272.  
  1273. SEE ALSO
  1274.      SET SCOPE, SET SELECT, ALL
  1275.  
  1276. STATUS
  1277.      Not started.
  1278. **man-end**********************************************************************/
  1279. #ifdef PROTO
  1280. int Display(char *params)
  1281. #else
  1282. int Display(params)
  1283. char *params;
  1284. #endif
  1285. /***********************************************************************/
  1286. {
  1287.  extern char file_read; /* indicates if we have read the file */
  1288.  extern char DISPLAY_LOWx;
  1289.  extern char DISPLAY_HIGHx;
  1290. /*--------------------------- local data ------------------------------*/
  1291.  int rc=RC_OK;
  1292. #define DIS_PARAMS  2
  1293.  char *word[DIS_PARAMS+1];
  1294.  unsigned short num_params;
  1295.  long col1,col2;
  1296.  unsigned short x,y;
  1297. /*--------------------------- processing ------------------------------*/
  1298. #ifdef TRACE
  1299.  trace_function("commset1.c:Display");
  1300. #endif
  1301.  display_error(0,(char *)"This function has not yet been implemented");
  1302.  
  1303. #ifdef TO_BE_IMPLEMENTED
  1304.  
  1305. /*---------------------------------------------------------------------*/
  1306. /* Validate the parameters that have been supplied. One only           */
  1307. /* parameter MUST be supplied. The first parameter MUST be a positive  */
  1308. /* integer. The second can be a positive integer or '*'. If no second  */
  1309. /* parameter is supplied, defaults to p1. The second parameter MUST be */
  1310. /* >= first parameter. '*' is regarded as the biggest number and is    */
  1311. /* literally 255.                                                      */
  1312. /*---------------------------------------------------------------------*/
  1313.  num_params = param_split(params,word,DIS_PARAMS,WORD_DELIMS,TEMP_PARAM);
  1314.  if (num_params < 1)
  1315.    {
  1316.     display_error(3,"");
  1317. #ifdef TRACE
  1318.     trace_return();
  1319. #endif
  1320.     return(RC_INVALID_OPERAND);
  1321.    }
  1322.  if (num_params > 2)
  1323.    {
  1324.     display_error(2,"");
  1325. #ifdef TRACE
  1326.     trace_return();
  1327. #endif
  1328.     return(RC_INVALID_OPERAND);
  1329.    }
  1330.  if (!valid_positive_integer(word[0]))
  1331.    {
  1332.     display_error(4,word[0]);
  1333. #ifdef TRACE
  1334.     trace_return();
  1335. #endif
  1336.     return(RC_INVALID_OPERAND);
  1337.    }
  1338.  col1 = atoi(word[0]);
  1339.  if (strcmp(word[1],"*") == 0)
  1340.     col2 = 255;
  1341.  else
  1342.     if (num_params == 1)      /* no second parameter, default to first */
  1343.        col2 = col1;
  1344.     else
  1345.        if (!valid_positive_integer(word[1]))
  1346.          {
  1347.           display_error(4,word[1]);
  1348. #ifdef TRACE
  1349.           trace_return();
  1350. #endif
  1351.           return(RC_INVALID_OPERAND);
  1352.          }
  1353.        else
  1354.           col2 = atoi(word[1]);
  1355.  
  1356.  if (col2 > 255)
  1357.     col2 = 255;
  1358.  if (col1 > col2)
  1359.    {
  1360.     display_error(6,word[0]);
  1361. #ifdef TRACE
  1362.     trace_return();
  1363. #endif
  1364.     return(RC_INVALID_OPERAND);
  1365.    }
  1366.  if (file_read)
  1367.    {
  1368.     CURRENT_VIEW->display_low = col1;
  1369.     CURRENT_VIEW->display_high   = col2;
  1370.     getyx(CURRENT_WINDOW,y,x);
  1371.     show_page();
  1372.     if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1373.        wmove(CURRENT_WINDOW,y,x);
  1374.    }
  1375.  else
  1376.    {
  1377.     DISPLAY_LOWx = col1;
  1378.     DISPLAY_HIGHx = col2;
  1379.    }
  1380.  
  1381. #endif
  1382.  
  1383. #ifdef TRACE
  1384.  trace_return();
  1385. #endif
  1386.  return(rc);
  1387. }
  1388. /*man-start*********************************************************************
  1389. COMMAND
  1390.      eolout - set end of line terminator
  1391.  
  1392. SYNTAX
  1393.      [SET] EOLout CRLF|LF
  1394.  
  1395. DESCRIPTION
  1396.      The EOLOUT command allows the user to specify the combination of
  1397.      characters that terminate a line. Lines of text in U*ix files are
  1398.      usually terminated with a LF, whereas in DOS they usually end with
  1399.      a CR and LF combination.
  1400.  
  1401. COMPATIBILITY
  1402.      XEDIT: N/A
  1403.      KEDIT: N/A
  1404.  
  1405. STATUS
  1406.      Complete.
  1407. **man-end**********************************************************************/
  1408. #ifdef PROTO
  1409. int Eolout(char *params)
  1410. #else
  1411. int Eolout(params)
  1412. char *params;
  1413. #endif
  1414. /***********************************************************************/
  1415. {
  1416. /*--------------------------- extern data -----------------------------*/
  1417. extern char EOLx;
  1418. /*--------------------------- local data ------------------------------*/
  1419. #define EOLOUT_PARAMS  1
  1420.  char *word[EOLOUT_PARAMS+1];
  1421.  unsigned short num_params;
  1422.  char eolchar;
  1423. /*--------------------------- processing ------------------------------*/
  1424. #ifdef TRACE
  1425.  trace_function("commset1.c:Eolout");
  1426. #endif
  1427.  num_params = param_split(params,word,EOLOUT_PARAMS,WORD_DELIMS,TEMP_PARAM);
  1428.  if (equal((char *)"lf",word[0],2))
  1429.     eolchar = EOLOUT_LF;
  1430.  else
  1431.     if (equal((char *)"crlf",word[0],4))
  1432.        eolchar = EOLOUT_CRLF;
  1433.     else
  1434.       {
  1435.        display_error(1,(char *)word[0]);
  1436. #ifdef TRACE
  1437.        trace_return();
  1438. #endif
  1439.        return(RC_INVALID_OPERAND);
  1440.       }
  1441.  EOLx = CURRENT_FILE->eolout = eolchar;
  1442. #ifdef TRACE
  1443.  trace_return();
  1444. #endif
  1445.  return(RC_OK);
  1446. }
  1447. /*man-start*********************************************************************
  1448. COMMAND
  1449.      etmode - indicate if extended display mode is possible
  1450.  
  1451. SYNTAX
  1452.      [SET] ETMODE ON|OFF
  1453.  
  1454. DESCRIPTION
  1455.      The ETMODE command allows the user to specify if extended ASCII
  1456.      codes ( > 127) are to be displayed or should be displayed as
  1457.      the NONDISP character.
  1458.  
  1459. COMPATIBILITY
  1460.      XEDIT: Similar function but deals with Double-Byte characters
  1461.      KEDIT: N/A
  1462.  
  1463. DEFAULT
  1464.      ON  - for DOS and OS/2 platforms
  1465.      OFF - for other platforms
  1466.  
  1467. SEE ALSO
  1468.      [SET] NONDisp
  1469.  
  1470. STATUS
  1471.      Complete.
  1472. **man-end**********************************************************************/
  1473. #ifdef PROTO
  1474. int Etmode(char *params)
  1475. #else
  1476. int Etmode(params)
  1477. char *params;
  1478. #endif
  1479. /***********************************************************************/
  1480. {
  1481. /*-------------------------- external data ----------------------------*/
  1482.  extern bool extended_display_mode;
  1483. /*--------------------------- local data ------------------------------*/
  1484. /*--------------------------- processing ------------------------------*/
  1485. #ifdef TRACE
  1486.  trace_function("commset1.c:Etmode");
  1487. #endif
  1488.  if (equal((char *)"off",params,3))
  1489.     extended_display_mode = FALSE;
  1490.  else
  1491.     if (equal((char *)"on",params,2))
  1492.        extended_display_mode= TRUE;
  1493.     else
  1494.       {
  1495.        display_error(1,(char *)params);
  1496. #ifdef TRACE
  1497.        trace_return();
  1498. #endif
  1499.        return(RC_INVALID_OPERAND);
  1500.       }
  1501.  if (!in_profile)
  1502.     show_page();
  1503. #ifdef TRACE
  1504.  trace_return();
  1505. #endif
  1506.  return(RC_OK);
  1507. }
  1508. /*man-start*********************************************************************
  1509. COMMAND
  1510.      hex - set how hexidecimal strings are treated in string operands
  1511.  
  1512. SYNTAX
  1513.      [SET] HEX ON|OFF
  1514.  
  1515. DESCRIPTION
  1516.      The HEX set command determines whether hexidecimal strings are
  1517.      treated as such in string operands.
  1518.      With HEX ON, any string operand of the form
  1519.         /x'31 32 33'/ or
  1520.         /d'49 50 51'/
  1521.      will be converted to /123/ before the command is executed.
  1522.      With HEX OFF, no conversion is done.
  1523.  
  1524.      This conversion should work wherever a string operand is used
  1525.      in any command.
  1526.  
  1527. COMPATIBILITY
  1528.      XEDIT: Adds support for decimal representation. See below.
  1529.      KEDIT: Compatible. See below.
  1530.      Spaces must seperate each character representation.
  1531.  
  1532. DEFAULT
  1533.      HEX OFF
  1534.  
  1535. STATUS
  1536.      Complete.
  1537. **man-end**********************************************************************/
  1538. #ifdef PROTO
  1539. int Hex(char *params)
  1540. #else
  1541. int Hex(params)
  1542. char *params;
  1543. #endif
  1544. /***********************************************************************/
  1545. {
  1546. /*--------------------------- extern data -----------------------------*/
  1547. extern char HEXx;
  1548. /*--------------------------- local data ------------------------------*/
  1549. #define HEX_PARAMS  1
  1550.  char parm[HEX_PARAMS];
  1551.  char *word[HEX_PARAMS+1];
  1552.  register int i;
  1553.  unsigned short num_params;
  1554. /*--------------------------- processing ------------------------------*/
  1555. #ifdef TRACE
  1556.  trace_function("commset1.c:Hex");
  1557. #endif
  1558.  num_params = param_split(params,word,HEX_PARAMS,WORD_DELIMS,TEMP_PARAM);
  1559.  
  1560.  parm[0] = (char)UNDEFINED_OPERAND;
  1561.  if (equal((char *)"on",word[0],2))
  1562.     parm[0] = ON;
  1563.  if (equal((char *)"off",word[0],3))
  1564.     parm[0] = OFF;
  1565.  if (parm[0] == (char)UNDEFINED_OPERAND)
  1566.    {
  1567.     display_error(1,word[0]);
  1568. #ifdef TRACE
  1569.     trace_return();
  1570. #endif
  1571.     return(RC_INVALID_OPERAND);
  1572.    }
  1573.  HEXx = CURRENT_VIEW->hex = parm[0];
  1574. #ifdef TRACE
  1575.  trace_return();
  1576. #endif
  1577.  return(RC_OK);
  1578. }
  1579. /*man-start*********************************************************************
  1580. COMMAND
  1581.      hexdisplay - turn on or display of character under cursor
  1582.  
  1583. SYNTAX
  1584.      [SET] HEXDISPlay ON|OFF
  1585.  
  1586. DESCRIPTION
  1587.      The HEXDISPLAY command turns on or off the display of the character under
  1588.      the cursor on the status line.
  1589.  
  1590. COMPATIBILITY
  1591.      XEDIT: N/A
  1592.      KEDIT: Compatible.
  1593.  
  1594. DEFAULT
  1595.      ON - the current character is displayed.
  1596.  
  1597. STATUS
  1598.      Complete
  1599. **man-end**********************************************************************/
  1600. #ifdef PROTO
  1601. int Hexdisplay(char *params)
  1602. #else
  1603. int Hexdisplay(params)
  1604. char *params;
  1605. #endif
  1606. /***********************************************************************/
  1607. {
  1608. /*--------------------------- local data ------------------------------*/
  1609.  extern bool HEXDISPLAYx;
  1610. /*--------------------------- processing ------------------------------*/
  1611. #ifdef TRACE
  1612.  trace_function("commset1.c:Hexdisplay");
  1613. #endif
  1614.  if (equal((char *)"off",params,3))
  1615.     HEXDISPLAYx = FALSE;
  1616.  else
  1617.     if (equal((char *)"on",params,2))
  1618.        HEXDISPLAYx = TRUE;
  1619.     else
  1620.       {
  1621.        display_error(1,(char *)params);
  1622. #ifdef TRACE
  1623.        trace_return();
  1624. #endif
  1625.        return(RC_INVALID_OPERAND);
  1626.       }
  1627.  clear_footing();
  1628. #ifdef TRACE
  1629.  trace_return();
  1630. #endif
  1631.  return(RC_OK);
  1632. }
  1633. /*man-start*********************************************************************
  1634. COMMAND
  1635.      impmacro - set implied macro command processing
  1636.  
  1637. SYNTAX
  1638.      [SET] IMPMACro ON|OFF
  1639.  
  1640. DESCRIPTION
  1641.      The IMPMACRO command is used to toggle implied macro processing
  1642.      from the command line. By turning this feature on you can then
  1643.      issue a macro command without the need to prefix the macro name
  1644.      with the MACRO command.
  1645.  
  1646. COMPATIBILITY
  1647.      XEDIT: N/A
  1648.      KEDIT: Compatible.
  1649.  
  1650. DEFAULT
  1651.      ON
  1652.  
  1653. SEE ALSO
  1654.      Macro,Macropath
  1655.  
  1656. STATUS
  1657.      Complete.
  1658. **man-end**********************************************************************/
  1659. #ifdef PROTO
  1660. int Impmacro(char *params)
  1661. #else
  1662. int Impmacro(params)
  1663. char *params;
  1664. #endif
  1665. /***********************************************************************/
  1666. {
  1667. /*-------------------------- external data ----------------------------*/
  1668.  extern bool IMPMACROx;
  1669. /*--------------------------- local data ------------------------------*/
  1670. /*--------------------------- processing ------------------------------*/
  1671. #ifdef TRACE
  1672.  trace_function("commset1.c:Impmacro");
  1673. #endif
  1674.  if (equal((char *)"off",params,3))
  1675.     IMPMACROx = FALSE;
  1676.  else
  1677.     if (equal((char *)"on",params,2))
  1678.        IMPMACROx = TRUE;
  1679.     else
  1680.       {
  1681.        display_error(1,(char *)params);
  1682. #ifdef TRACE
  1683.        trace_return();
  1684. #endif
  1685.        return(RC_INVALID_OPERAND);
  1686.       }
  1687.  CURRENT_VIEW->imp_macro = IMPMACROx;
  1688. #ifdef TRACE
  1689.  trace_return();
  1690. #endif
  1691.  return(RC_OK);
  1692. }
  1693. /*man-start*********************************************************************
  1694. COMMAND
  1695.      impos - set implied operating system command processing
  1696.  
  1697. SYNTAX
  1698.      [SET] IMPOS ON|OFF
  1699.      [SET] IMPcmscp ON|OFF
  1700.  
  1701. DESCRIPTION
  1702.      The IMPMOS command is used to toggle implied operating system
  1703.      command processing from the command line. By turning this feature 
  1704.      on you can then issue an operating system command without the need 
  1705.      to prefix the operating system command with the OS command.
  1706.  
  1707. COMPATIBILITY
  1708.      XEDIT: Compatible.
  1709.      KEDIT: N/A
  1710.  
  1711. DEFAULT
  1712.      ON
  1713.  
  1714. STATUS
  1715.      Complete.
  1716. **man-end**********************************************************************/
  1717. #ifdef PROTO
  1718. int Impos(char *params)
  1719. #else
  1720. int Impos(params)
  1721. char *params;
  1722. #endif
  1723. /***********************************************************************/
  1724. {
  1725. /*-------------------------- external data ----------------------------*/
  1726.  extern bool IMPOSx;
  1727. /*--------------------------- local data ------------------------------*/
  1728. /*--------------------------- processing ------------------------------*/
  1729. #ifdef TRACE
  1730.  trace_function("commset1.c:Impos");
  1731. #endif
  1732.  if (equal((char *)"off",params,3))
  1733.     IMPOSx = FALSE;
  1734.  else
  1735.     if (equal((char *)"on",params,2))
  1736.        IMPOSx = TRUE;
  1737.     else
  1738.       {
  1739.        display_error(1,(char *)params);
  1740. #ifdef TRACE
  1741.        trace_return();
  1742. #endif
  1743.        return(RC_INVALID_OPERAND);
  1744.       }
  1745.  CURRENT_VIEW->imp_os = IMPOSx;
  1746. #ifdef TRACE
  1747.  trace_return();
  1748. #endif
  1749.  return(RC_OK);
  1750. }
  1751. /*man-start*********************************************************************
  1752. COMMAND
  1753.      insertmode - put editor into insert mode
  1754.  
  1755. SYNTAX
  1756.      [SET] INSERTMode ON|OFF|TOGGLE
  1757.  
  1758. DESCRIPTION
  1759.      The INSERTMODE command toggles the insert mode within THE.
  1760.  
  1761. COMPATIBILITY
  1762.      XEDIT: N/A
  1763.      KEDIT: Compatible.
  1764.  
  1765. DEFAULT
  1766.      TOGGLE
  1767.  
  1768. STATUS
  1769.      Complete.
  1770. **man-end**********************************************************************/
  1771. #ifdef PROTO
  1772. int Insertmode(char *params)
  1773. #else
  1774. int Insertmode(params)
  1775. char *params;
  1776. #endif
  1777. /***********************************************************************/
  1778. {
  1779. /*--------------------------- local data ------------------------------*/
  1780. /*--------------------------- processing ------------------------------*/
  1781. #ifdef TRACE
  1782.  trace_function("commset1.c:Insertmode");
  1783. #endif
  1784.  if (equal((char *)"off",params,3))
  1785.     mode_insert = NO;
  1786.  else
  1787.     if (equal((char *)"on",params,2))
  1788.        mode_insert = YES;
  1789.     else
  1790.        if (equal((char *)"toggle",params,6))
  1791.           mode_insert = (mode_insert) ? NO : YES;
  1792.        else
  1793.          {
  1794.           display_error(1,(char *)params);
  1795. #ifdef TRACE
  1796.           trace_return();
  1797. #endif
  1798.           return(RC_INVALID_OPERAND);
  1799.          }
  1800.  if (!in_profile)
  1801.     draw_cursor(ON);
  1802. #ifdef TRACE
  1803.  trace_return();
  1804. #endif
  1805.  return(RC_OK);
  1806. }
  1807. /*man-start*********************************************************************
  1808. COMMAND
  1809.      linend - allow/disallow multiple commands on command line
  1810.  
  1811. SYNTAX
  1812.      [SET] LINENd ON|OFF [char]
  1813.  
  1814. DESCRIPTION
  1815.      The LINEND command allows or disallows the execution of multiple
  1816.      commands on the command line. When setting LINEND ON, a character
  1817.      is specified as the LINEND character which delimits each command.
  1818.  
  1819. COMPATIBILITY
  1820.      XEDIT: N/A
  1821.      KEDIT: Compatible.
  1822.  
  1823. DEFAULT
  1824.      OFF #
  1825.  
  1826. STATUS
  1827.      Complete.
  1828. **man-end**********************************************************************/
  1829. #ifdef PROTO
  1830. int Linend(char *params)
  1831. #else
  1832. int Linend(params)
  1833. char *params;
  1834. #endif
  1835. /***********************************************************************/
  1836. {
  1837. /*--------------------------- local data ------------------------------*/
  1838. #define LE_PARAMS  2
  1839.  char *word[LE_PARAMS+1];
  1840.  unsigned short num_params;
  1841.  bool le_status=CURRENT_VIEW->linend_status;
  1842.  char le_value=CURRENT_VIEW->linend_value;
  1843.  int rc=RC_OK;
  1844. /*--------------------------- processing ------------------------------*/
  1845. #ifdef TRACE
  1846.  trace_function("commset1.c:Linend");
  1847. #endif
  1848.  num_params = param_split(params,word,LE_PARAMS,WORD_DELIMS,TEMP_PARAM);
  1849.  switch(num_params)
  1850.    {
  1851.     case 1:
  1852.     case 2:
  1853.            if (equal((char *)"off",word[0],3))
  1854.               le_status = FALSE;
  1855.            else
  1856.               if (equal((char *)"on",word[0],2))
  1857.                  le_status = TRUE;
  1858.               else
  1859.                 {
  1860.                  display_error(1,word[0]);
  1861.                  rc = RC_INVALID_OPERAND;
  1862.                  break;
  1863.                 }
  1864.            if (num_params == 1)
  1865.               break;
  1866.            if (strlen(word[1]) > 1)
  1867.              {
  1868.               display_error(1,word[1]);
  1869.               break;
  1870.              }
  1871.            le_value = word[1][0];
  1872.            break;
  1873.     case 0:
  1874.            display_error(3,"");
  1875.            rc = RC_INVALID_OPERAND;
  1876.            break;
  1877.     default:
  1878.            display_error(2,"");
  1879.            rc = RC_INVALID_OPERAND;
  1880.            break;
  1881.    }
  1882.  if (rc == RC_OK)
  1883.    {
  1884.     CURRENT_VIEW->linend_status = le_status;
  1885.     CURRENT_VIEW->linend_value = le_value;
  1886.    }
  1887. #ifdef TRACE
  1888.  trace_return();
  1889. #endif
  1890.  return(rc);
  1891. }
  1892. /*man-start*********************************************************************
  1893. COMMAND
  1894.      macroext - set default macro extension value
  1895.  
  1896. SYNTAX
  1897.      [SET] MACROExt [ext]
  1898.  
  1899. DESCRIPTION
  1900.      The MACROEXT command sets the value of the file extension to be
  1901.      used for macro files. When a macro file name is specified on the
  1902.      command line, a fullstop '.' then this value will be appended.
  1903.      If no value is specified for ext, then THE assumes that the
  1904.      supplied macro file name is the fully specified name for a macro.
  1905.  
  1906.      The length of ext must be 10 characters or less.
  1907.  
  1908.      The macro extension is only appended to a file if that file does
  1909.      not include any path specifiers.
  1910.  
  1911. COMPATIBILITY
  1912.      XEDIT: N/A
  1913.      KEDIT: N/A
  1914.  
  1915. DEFAULT
  1916.      the
  1917.  
  1918. STATUS
  1919.      Complete.
  1920. **man-end**********************************************************************/
  1921. #ifdef PROTO
  1922. int Macroext(char *params)
  1923. #else
  1924. int Macroext(params)
  1925. char *params;
  1926. #endif
  1927. /***********************************************************************/
  1928. {
  1929. /*-------------------------- external data ----------------------------*/
  1930.  extern char macro_suffix[12];
  1931. /*--------------------------- local data ------------------------------*/
  1932. /*--------------------------- processing ------------------------------*/
  1933. #ifdef TRACE
  1934.  trace_function("commset1.c:Macroext");
  1935. #endif
  1936. /*---------------------------------------------------------------------*/
  1937. /* If no value is specified for ext, set the value of macro_suffix to  */
  1938. /* "", otherwise set it to the supplied value, prefixed with '.'       */
  1939. /*---------------------------------------------------------------------*/
  1940.  if (strlen(params) == 0)
  1941.     strcpy(macro_suffix,"");
  1942.  else
  1943.    {
  1944.     if (strlen(params) > 10)
  1945.       {
  1946.        display_error(7,(char *)params);
  1947. #ifdef TRACE
  1948.        trace_return();
  1949. #endif
  1950.        return(RC_INVALID_OPERAND);
  1951.       }
  1952.     strcpy(macro_suffix,".");
  1953.     strcat(macro_suffix,params);
  1954.    }
  1955. #ifdef TRACE
  1956.  trace_return();
  1957. #endif
  1958.  return(RC_OK);
  1959. }
  1960. /*man-start*********************************************************************
  1961. COMMAND
  1962.      macropath - set up default path for macro commands
  1963.  
  1964. SYNTAX
  1965.      [SET] MACROPath path[s]
  1966.  
  1967. DESCRIPTION
  1968.      The MACROPATH command sets up the search path from which macro
  1969.      command files are executed. Each directory is seperated by a
  1970.      colon (Unix) or semi-colon (DOS & OS/2).
  1971.      No check is done at this stage to validate the supplied path.
  1972.  
  1973. COMPATIBILITY
  1974.      XEDIT: N/A
  1975.      KEDIT: Incompatible.
  1976.  
  1977. DEFAULT
  1978.      Path specified by env variable THE_MACRO_PATH or directory
  1979.      specified in THE_HOME_DIR followed by the current directory
  1980.      if THE_MACRO_PATH not defined.
  1981.  
  1982. SEE ALSO
  1983.      Macro,Impmacro.
  1984.  
  1985. STATUS
  1986.      Complete.
  1987. **man-end**********************************************************************/
  1988. #ifdef PROTO
  1989. int Macropath(char *params)
  1990. #else
  1991. int Macropath(params)
  1992. char *params;
  1993. #endif
  1994. /***********************************************************************/
  1995. {
  1996. /*-------------------------- external data ----------------------------*/
  1997.  extern char the_macro_path[MAX_FILE_NAME+1];
  1998.  extern char sp_path[MAX_FILE_NAME+1] ;
  1999.  extern char sp_fname[MAX_FILE_NAME+1] ;
  2000. /*--------------------------- local data ------------------------------*/
  2001. /*--------------------------- processing ------------------------------*/
  2002. #ifdef TRACE
  2003.  trace_function("commset1.c:Macropath");
  2004. #endif
  2005. /*---------------------------------------------------------------------*/
  2006. /* No checking is done on macro path supplied other than it contains a */
  2007. /* value. Path delimiters are translated if necessary.                 */
  2008. /*---------------------------------------------------------------------*/
  2009.  if (strlen(params) == 0)
  2010.    {
  2011.     display_error(3,(char *)"");
  2012. #ifdef TRACE
  2013.     trace_return();
  2014. #endif
  2015.     return(RC_INVALID_OPERAND);
  2016.    }
  2017.  strcpy(the_macro_path,params);
  2018.  (void *)strtrans(the_macro_path,OSLASH,ISLASH);
  2019. #ifdef TRACE
  2020.  trace_return();
  2021. #endif
  2022.  return(RC_OK);
  2023. }
  2024. /*man-start*********************************************************************
  2025. COMMAND
  2026.      margins - set left and right margins
  2027.  
  2028. SYNTAX
  2029.      [SET] MARgins left right [[+|-]indent]
  2030.  
  2031. DESCRIPTION
  2032.      The MARGINS command sets the left and right margins and the
  2033.      number of columns to indent a paragraph.
  2034.      These values are used with the WORDWRAP option.
  2035.  
  2036. COMPATIBILITY
  2037.      XEDIT: N/A
  2038.      KEDIT: Compatible.
  2039.  
  2040. DEFAULT
  2041.      1 72 0
  2042.  
  2043. SEE ALSO
  2044.      [SET] WORDWRAP.
  2045.  
  2046. STATUS
  2047.      Complete.
  2048. **man-end**********************************************************************/
  2049. #ifdef PROTO
  2050. int Margins(char *params)
  2051. #else
  2052. int Margins(params)
  2053. char *params;
  2054. #endif
  2055. /***********************************************************************/
  2056. {
  2057. /*-------------------------- external data ----------------------------*/
  2058.  extern char *temp_cmd;
  2059. /*--------------------------- local data ------------------------------*/
  2060. #define MAR_PARAMS  3
  2061.  char *word[MAR_PARAMS+1];
  2062.  int num_params;
  2063.  int rc;
  2064.  unsigned short left,right;
  2065.  short indent;
  2066.  bool offset,consistancy_error;
  2067. /*--------------------------- processing ------------------------------*/
  2068. #ifdef TRACE
  2069.  trace_function("commset1.c:Margins");
  2070. #endif
  2071. /*---------------------------------------------------------------------*/
  2072. /* Two parameters are mandatory, the third is optional.                */
  2073. /*---------------------------------------------------------------------*/
  2074.  num_params = param_split(params,word,MAR_PARAMS,WORD_DELIMS,TEMP_PARAM);
  2075.  if (num_params < 2)
  2076.    {
  2077.     display_error(3,(char *)"");
  2078. #ifdef TRACE
  2079.     trace_return();
  2080. #endif
  2081.     return(RC_INVALID_OPERAND);
  2082.    }
  2083.  if (num_params > 3)
  2084.    {
  2085.     display_error(2,(char *)"");
  2086. #ifdef TRACE
  2087.     trace_return();
  2088. #endif
  2089.     return(RC_INVALID_OPERAND);
  2090.    }
  2091. /*---------------------------------------------------------------------*/
  2092. /* Parse the parameters...                                             */
  2093. /*---------------------------------------------------------------------*/
  2094.  if ((left = atoi(word[0])) == 0)
  2095.    {
  2096.     display_error(1,word[0]);
  2097. #ifdef TRACE
  2098.     trace_return();
  2099. #endif
  2100.     return(RC_INVALID_OPERAND);
  2101.    }
  2102. /*---------------------------------------------------------------------*/
  2103. /* Right margin value can be *, set to maximum line length.            */
  2104. /*---------------------------------------------------------------------*/
  2105.  if (*(word[1]+1) == '*')
  2106.    {
  2107.     right = max_line_length;
  2108.    }
  2109.  else
  2110.    {
  2111.     if ((right = atoi(word[1])) == 0)
  2112.       {
  2113.        display_error(1,word[1]);
  2114. #ifdef TRACE
  2115.        trace_return();
  2116. #endif
  2117.        return(RC_INVALID_OPERAND);
  2118.       }
  2119.    }
  2120. /*---------------------------------------------------------------------*/
  2121. /* Left margin must be less than right margin.                         */
  2122. /*---------------------------------------------------------------------*/
  2123.  if (right < left)
  2124.    {
  2125.     display_error(5,word[1]);
  2126. #ifdef TRACE
  2127.     trace_return();
  2128. #endif
  2129.     return(RC_INVALID_OPERAND);
  2130.    }
  2131. /*---------------------------------------------------------------------*/
  2132. /* Obtain current values for indent, in case they aren't changed by    */
  2133. /* the current command. (ie. no third parameter)                       */
  2134. /*---------------------------------------------------------------------*/
  2135.  indent = CURRENT_VIEW->margin_indent;
  2136.  offset = CURRENT_VIEW->margin_indent_offset;
  2137. /*---------------------------------------------------------------------*/
  2138. /* Determine the type of offset for the indent value. If a sign is     */
  2139. /* specified, then the number supplied is relative to the left margin  */
  2140. /* otherwise it is an absolute column value.                           */
  2141. /*---------------------------------------------------------------------*/
  2142.  if (num_params == 3)
  2143.    {
  2144.     if (*(word[2]) == '-'
  2145.     ||  *(word[2]) == '+')
  2146.       {
  2147.        offset = TRUE;
  2148.        if ((indent = atoi(word[2])) == 0)
  2149.          {
  2150.           if (strcmp(word[2],"+0") != 0)
  2151.             {
  2152.              display_error(1,word[2]);
  2153. #ifdef TRACE
  2154.              trace_return();
  2155. #endif
  2156.              return(RC_INVALID_OPERAND);
  2157.             }
  2158.          }
  2159.       }
  2160.     else
  2161.       {
  2162.        offset = FALSE;
  2163. /*---------------------------------------------------------------------*/
  2164. /* Absolute indent cannot be negative.                                 */
  2165. /*---------------------------------------------------------------------*/
  2166.        if ((indent = atoi(word[2])) < 0)
  2167.          {
  2168.           display_error(1,word[2]);
  2169. #ifdef TRACE
  2170.           trace_return();
  2171. #endif
  2172.           return(RC_INVALID_OPERAND);
  2173.          }
  2174.       }
  2175.    }
  2176. /*---------------------------------------------------------------------*/
  2177. /* Once all values are determined, validate the relationship between   */
  2178. /* the margins and the indent values.                                  */
  2179. /* Rules:                                                              */
  2180. /*       o If indent is a negative offset, the resultant column value  */
  2181. /*         cannot be negative.                                         */
  2182. /*       o If indent is a positive offset, the resultant column value  */
  2183. /*         cannot be > max_line_length or right margin                 */
  2184. /*       o If indent is an absolute value, it cannot be > right margin */
  2185. /*---------------------------------------------------------------------*/
  2186.  consistancy_error = FALSE;
  2187.  if (offset
  2188.  && indent < 0
  2189.  && indent + left < 0)
  2190.     consistancy_error = TRUE;
  2191.  if (offset
  2192.  && indent > 0
  2193.  && indent + left > right)
  2194.     consistancy_error = TRUE;
  2195.  if (offset
  2196.  && indent > 0
  2197.  && indent + left > max_line_length)
  2198.     consistancy_error = TRUE;
  2199.  if (!offset
  2200.  && indent > right)
  2201.     consistancy_error = TRUE;
  2202.  if (consistancy_error)
  2203.    {
  2204.     if (offset)
  2205.        sprintf(temp_cmd,"%d %d %+d",left,right,indent);
  2206.     else
  2207.        sprintf(temp_cmd,"%d %d %d",left,right,indent);
  2208.     display_error(12,temp_cmd);
  2209. #ifdef TRACE
  2210.     trace_return();
  2211. #endif
  2212.     return(RC_INVALID_OPERAND);
  2213.    }
  2214. /*---------------------------------------------------------------------*/
  2215. /* All OK, so save the values...                                       */
  2216. /*---------------------------------------------------------------------*/
  2217.  CURRENT_VIEW->margin_left = left;
  2218.  CURRENT_VIEW->margin_right = right;
  2219.  CURRENT_VIEW->margin_indent = indent;
  2220.  CURRENT_VIEW->margin_indent_offset = offset;
  2221. #ifdef TRACE
  2222.  trace_return();
  2223. #endif
  2224.  return(RC_OK);
  2225. }
  2226. /*man-start*********************************************************************
  2227. COMMAND
  2228.      msgmode - set display of messages on or off
  2229.  
  2230. SYNTAX
  2231.      [SET] MSGMode ON|OFF
  2232.  
  2233. DESCRIPTION
  2234.      The MSGMODE set command determines whether error messages will be 
  2235.      displayed or suppressed.
  2236.  
  2237. COMPATIBILITY
  2238.      XEDIT: Does not support [Short|Long] options.
  2239.      KEDIT: Compatible
  2240.  
  2241. DEFAULT
  2242.      ON
  2243.  
  2244. STATUS
  2245.      Complete
  2246. **man-end**********************************************************************/
  2247. #ifdef PROTO
  2248. int Msgmode(char *params)
  2249. #else
  2250. int Msgmode(params)
  2251. char *params;
  2252. #endif
  2253. /***********************************************************************/
  2254. {
  2255. /*--------------------------- extern data -----------------------------*/
  2256. extern char MSGMx;
  2257. /*--------------------------- local data ------------------------------*/
  2258. #define MSG_PARAMS  1
  2259.  char parm[MSG_PARAMS];
  2260.  char *word[MSG_PARAMS+1];
  2261.  unsigned short num_params;
  2262. /*--------------------------- processing ------------------------------*/
  2263. #ifdef TRACE
  2264.  trace_function("commset1.c:Msgmode");
  2265. #endif
  2266.  num_params = param_split(params,word,MSG_PARAMS,WORD_DELIMS,TEMP_PARAM);
  2267.  if (num_params > 1)
  2268.    {
  2269.     display_error(2,(char *)"");
  2270. #ifdef TRACE
  2271.     trace_return();
  2272. #endif
  2273.     return(RC_INVALID_OPERAND);
  2274.    }
  2275.  if (num_params < 1)
  2276.    {
  2277.     display_error(3,(char *)"");
  2278. #ifdef TRACE
  2279.     trace_return();
  2280. #endif
  2281.     return(RC_INVALID_OPERAND);
  2282.    }
  2283.  parm[0] = (char)UNDEFINED_OPERAND;
  2284.  if (equal((char *)"on",word[0],2))
  2285.     parm[0] = TRUE;
  2286.  if (equal((char *)"off",word[0],3))
  2287.     parm[0] = FALSE;
  2288.  if (parm[0] == (char)UNDEFINED_OPERAND)
  2289.    {
  2290.     display_error(1,word[0]);
  2291. #ifdef TRACE
  2292.     trace_return();
  2293. #endif
  2294.     return(RC_INVALID_OPERAND);
  2295.    }
  2296.  if (in_profile)
  2297.     MSGMx = parm[0];
  2298.  CURRENT_VIEW->message_mode = parm[0];
  2299. #ifdef TRACE
  2300.  trace_return();
  2301. #endif
  2302.  return(RC_OK);
  2303. }
  2304. /*man-start*********************************************************************
  2305. COMMAND
  2306.      newlines - set behaviour of adding new lines
  2307.  
  2308. SYNTAX
  2309.      [SET] NEWLines Aligned|Left
  2310.  
  2311. DESCRIPTION
  2312.      The NEWLINES set command determines where the cursor displays after
  2313.      a new line is added to the file.
  2314.      With ALIGNED, the cursor will display in the column of the new line
  2315.      immediately underneath the first non-blank character in the line
  2316.      above.
  2317.      With LEFT, the cursor will display in the first column of the new line.
  2318.  
  2319. COMPATIBILITY
  2320.      XEDIT: N/A
  2321.      KEDIT: Same command, different functionality.
  2322.  
  2323. DEFAULT
  2324.      NEWLINES ALIGNED
  2325.  
  2326. STATUS
  2327.      Complete
  2328. **man-end**********************************************************************/
  2329. #ifdef PROTO
  2330. int Newlines(char *params)
  2331. #else
  2332. int Newlines(params)
  2333. char *params;
  2334. #endif
  2335. /***********************************************************************/
  2336. {
  2337. /*--------------------------- extern data -----------------------------*/
  2338. extern char NEWLx;
  2339. /*--------------------------- local data ------------------------------*/
  2340. #define NEW_PARAMS  1
  2341.  char parm[NEW_PARAMS];
  2342.  char *word[NEW_PARAMS+1];
  2343.  unsigned short num_params;
  2344. /*--------------------------- processing ------------------------------*/
  2345. #ifdef TRACE
  2346.  trace_function("commset1.c:Newlines");
  2347. #endif
  2348.  num_params = param_split(params,word,NEW_PARAMS,WORD_DELIMS,TEMP_PARAM);
  2349.  if (num_params > 1)
  2350.    {
  2351.     display_error(2,(char *)"");
  2352. #ifdef TRACE
  2353.     trace_return();
  2354. #endif
  2355.     return(RC_INVALID_OPERAND);
  2356.    }
  2357.  if (num_params < 1)
  2358.    {
  2359.     display_error(3,(char *)"");
  2360. #ifdef TRACE
  2361.     trace_return();
  2362. #endif
  2363.     return(RC_INVALID_OPERAND);
  2364.    }
  2365.  
  2366.  parm[0] = (char)UNDEFINED_OPERAND;
  2367.  if (equal((char *)"aligned",word[0],1))
  2368.     parm[0] = TRUE;
  2369.  if (equal((char *)"left",word[0],1))
  2370.     parm[0] = FALSE;
  2371.  if (parm[0] == (char)UNDEFINED_OPERAND)
  2372.    {
  2373.     display_error(1,word[0]);
  2374. #ifdef TRACE
  2375.     trace_return();
  2376. #endif
  2377.     return(RC_INVALID_OPERAND);
  2378.    }
  2379.  NEWLx = CURRENT_VIEW->newline_aligned = parm[0];
  2380. #ifdef TRACE
  2381.  trace_return();
  2382. #endif
  2383.  return(RC_OK);
  2384. }
  2385. /*man-start*********************************************************************
  2386. COMMAND
  2387.      nodisp - set the character that displays for non-displaying characters
  2388.  
  2389. SYNTAX
  2390.      [SET] NONDisp char
  2391.  
  2392. DESCRIPTION
  2393.      The NONDISP command allows the user to change the character that 
  2394.      is displayed for non-displaying commands when [SET] ETMODE is OFF.
  2395.  
  2396. COMPATIBILITY
  2397.      XEDIT: Compatible.
  2398.      KEDIT: N/A
  2399.  
  2400. DEFAULT
  2401.      #
  2402.  
  2403. SEE ALSO
  2404.      [SET] ETMODE
  2405.  
  2406. STATUS
  2407.      Complete.
  2408. **man-end**********************************************************************/
  2409. #ifdef PROTO
  2410. int Nondisp(char *params)
  2411. #else
  2412. int Nondisp(params)
  2413. char *params;
  2414. #endif
  2415. /***********************************************************************/
  2416. {
  2417. /*-------------------------- external data ----------------------------*/
  2418.  extern bool NONDISPx;
  2419. /*--------------------------- local data ------------------------------*/
  2420. /*--------------------------- processing ------------------------------*/
  2421. #ifdef TRACE
  2422.  trace_function("commset1.c:Nondisp");
  2423. #endif
  2424.  if (strlen(params) != 1)
  2425.    {
  2426.     display_error(1,params);
  2427. #ifdef TRACE
  2428.     trace_return();
  2429. #endif
  2430.     return(RC_INVALID_OPERAND);
  2431.    }
  2432.  NONDISPx = *params;
  2433.  if (!in_profile)
  2434.     show_page();
  2435. #ifdef TRACE
  2436.  trace_return();
  2437. #endif
  2438.  return(RC_OK);
  2439. }
  2440. /*man-start*********************************************************************
  2441. COMMAND
  2442.      number - turn prefix numbers on or off
  2443.  
  2444. SYNTAX
  2445.      [SET] NUMber ON|OFF
  2446.  
  2447. DESCRIPTION
  2448.      The NUMBER command allows the user to toggle the display of numbers
  2449.      in the prefix area.
  2450.  
  2451. COMPATIBILITY
  2452.      XEDIT: Compatible.
  2453.      KEDIT: Compatible.
  2454.  
  2455. DEFAULT
  2456.      ON
  2457.  
  2458. SEE ALSO
  2459.      Prefix
  2460.  
  2461. STATUS
  2462.      Complete.
  2463. **man-end**********************************************************************/
  2464. #ifdef PROTO
  2465. int Number(char *params)
  2466. #else
  2467. int Number(params)
  2468. char *params;
  2469. #endif
  2470. /***********************************************************************/
  2471. {
  2472. /*-------------------------- external data ----------------------------*/
  2473.  extern bool NUMBERx;
  2474. /*--------------------------- local data ------------------------------*/
  2475. /*--------------------------- processing ------------------------------*/
  2476. #ifdef TRACE
  2477.  trace_function("commset1.c:Number");
  2478. #endif
  2479.  if (equal((char *)"off",params,3))
  2480.     NUMBERx = FALSE;
  2481.  else
  2482.     if (equal((char *)"on",params,2))
  2483.        NUMBERx = TRUE;
  2484.     else
  2485.       {
  2486.        display_error(1,(char *)params);
  2487. #ifdef TRACE
  2488.        trace_return();
  2489. #endif
  2490.        return(RC_INVALID_OPERAND);
  2491.       }
  2492.  CURRENT_VIEW->number = NUMBERx;
  2493.  if (!in_profile)
  2494.     show_page();
  2495.  
  2496. #ifdef TRACE
  2497.  trace_return();
  2498. #endif
  2499.  return(RC_OK);
  2500. }
  2501.