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

  1. /***********************************************************************/
  2. /* COMM2.C - Commands D-J                                              */
  3. /* This file contains all commands that can be assigned to function    */
  4. /* keys or typed on the command line.                                  */
  5. /***********************************************************************/
  6. /*
  7.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  8.  * Copyright (C) 1991-1997 Mark Hessling
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 2 of
  13.  * the License, or any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to:
  22.  *
  23.  *    The Free Software Foundation, Inc.
  24.  *    675 Mass Ave,
  25.  *    Cambridge, MA 02139 USA.
  26.  *
  27.  *
  28.  * If you make modifications to this software that you feel increases
  29.  * it usefulness for the rest of the community, please email the
  30.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  31.  * This software is going to be maintained and enhanced as deemed
  32.  * necessary by the community.
  33.  *
  34.  * Mark Hessling                 Email:             M.Hessling@qut.edu.au
  35.  * PO Box 203                    Phone:                    +617 3802 0800
  36.  * Bellara                       http://www.gu.edu.au/gext/the/markh.html
  37.  * QLD 4507                      **** Maintainer PDCurses & REXX/SQL ****
  38.  * Australia                     ************* Author of THE ************
  39.  */
  40.  
  41. /*
  42. $Id: comm2.c 2.1 1995/06/24 16:28:49 MH Rel MH $
  43. */
  44.  
  45. #include <the.h>
  46. #include <proto.h>
  47.  
  48. /*#define DEBUG 1*/
  49.  
  50. /*man-start*********************************************************************
  51. COMMAND
  52.      define - assign one or many commands to a key or mouse event
  53.  
  54. SYNTAX
  55.      DEFine key-name [REXX] [command [args] [[#command [args]...]]]
  56.      DEFine mouse-key-definition IN window [REXX] [command [args] [[#command [args]...]]]
  57.  
  58. DESCRIPTION
  59.      The DEFINE command allows the user to assign one or many 
  60.      commands and optional parameter(s) to a key or a mouse button
  61.      specification.
  62.  
  63.      Commands may be abbreviated.
  64.  
  65.      If multiple commands are assigned, then the LINEND setting
  66.      must be ON and the LINEND character must match the character
  67.      that delimits the commands at the time that the DEFINE command
  68.      is executed. LINEND can be OFF at the time the key is pressed.
  69.  
  70.      With no arguments, any existing definition for that key is
  71.      removed and the key reverts back to its default assignation (if
  72.      it had any).
  73.  
  74.      'key-name' corresponds to the key name shown with the <SHOWKEY> command.
  75.  
  76.      If the optional keyword; 'REXX', is supplied, the remainder of the
  77.      command line is treated as a REXX macro and is passed onto the
  78.      REXX interpreter (if you have one) for execution.
  79.  
  80. COMPATIBILITY
  81.      XEDIT: N/A
  82.      KEDIT: Compatible.
  83.             KEDIT does not allow multiple commands except as KEXX
  84.             macros.
  85.  
  86. SEE ALSO
  87.      <SHOWKEY>, <SET LINEND>
  88.  
  89. STATUS
  90.      Complete.
  91. **man-end**********************************************************************/
  92. #ifdef HAVE_PROTO
  93. short Define(CHARTYPE *params)
  94. #else
  95. short Define(params)
  96. CHARTYPE *params;
  97. #endif
  98. /***********************************************************************/
  99. {
  100. /*------------------------- external data -----------------------------*/
  101.  extern DEFINE *first_define;
  102.  extern DEFINE *last_define;
  103.  extern DEFINE *first_mouse_define;
  104.  extern DEFINE *last_mouse_define;
  105. /*--------------------------- local data ------------------------------*/
  106. #define DEF_PARAMS  2
  107. #define DEF_MOUSE_PARAMS  4
  108.  CHARTYPE *word[DEF_MOUSE_PARAMS+1];
  109.  CHARTYPE strip[DEF_MOUSE_PARAMS];
  110.  CHARTYPE *ptr=NULL;
  111.  unsigned short num_params=0;
  112.  int key_value=0;
  113.  short rc=RC_OK;
  114. /*--------------------------- processing ------------------------------*/
  115. #ifdef TRACE
  116.  trace_function("comm2.c:   Define");
  117. #endif
  118.  strip[0] = STRIP_BOTH;
  119.  strip[1] = STRIP_LEADING;
  120.  num_params = param_split(params,word,DEF_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  121.  if (num_params == 0)
  122.    {
  123.     display_error(3,(CHARTYPE *)"",FALSE);
  124. #ifdef TRACE
  125.     trace_return();
  126. #endif
  127.     return(RC_INVALID_OPERAND);
  128.    }
  129. /*---------------------------------------------------------------------*/
  130. /* The first parameter is the key name mnemonic , the next is one or   */
  131. /* more commands and/or parameters.                                    */
  132. /* First check the mnemonic for decimal string value. ie begins with \ */
  133. /*---------------------------------------------------------------------*/
  134.  if (word[0][0] == '\\')
  135.    {
  136.     if ((key_value = atoi((DEFCHAR *)word[0]+1)) == 0)
  137.        rc = RC_INVALID_OPERAND;
  138.    }
  139.  else
  140.    {
  141.     if ((key_value = find_key_value(word[0])) == (-1))
  142.        rc = RC_INVALID_OPERAND;
  143.    }
  144.  if (rc == RC_OK)
  145.    {
  146. /*---------------------------------------------------------------------*/
  147. /* Determine if the first word of the supplied command is REXX (either */
  148. /* case)...                                                            */
  149. /*---------------------------------------------------------------------*/
  150.     if (memcmpi(word[1],(CHARTYPE *)"REXX ",5) == 0)
  151.       {
  152.        ptr = word[1];
  153.        rc = add_define(&first_define,&last_define,key_value,ptr+5,TRUE);
  154.       }
  155.     else
  156.        rc = add_define(&first_define,&last_define,key_value,word[1],FALSE);
  157.     /*
  158.      * Return after processing a KEY definition...
  159.      */
  160. #ifdef TRACE
  161.     trace_return();
  162. #endif
  163.     return(rc);
  164.    }
  165. /*---------------------------------------------------------------------*/
  166. /* To get here, either it is an invalid KEY definition, or it is a     */
  167. /* MOUSE key definition waiting to be validated.                       */
  168. /*---------------------------------------------------------------------*/
  169.  strip[0] = STRIP_BOTH;
  170.  strip[1] = STRIP_BOTH;
  171.  strip[2] = STRIP_BOTH;
  172.  strip[3] = STRIP_NONE;
  173.  num_params = param_split(params,word,DEF_MOUSE_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  174.  if (num_params < 3)
  175.    {
  176.     display_error(3,(CHARTYPE *)"",FALSE);
  177. #ifdef TRACE
  178.     trace_return();
  179. #endif
  180.     return(RC_INVALID_OPERAND);
  181.    }
  182.  if (!equal((CHARTYPE *)"IN",word[1],2))
  183.    {
  184.     display_error(1,word[1],FALSE);
  185. #ifdef TRACE
  186.     trace_return();
  187. #endif
  188.     return(RC_INVALID_OPERAND);
  189.    }
  190.  if ((key_value = find_mouse_key_value(word[0],word[2])) == (-1))
  191.    {
  192. #ifdef TRACE
  193.     trace_return();
  194. #endif
  195.     return(RC_INVALID_OPERAND);
  196.    }
  197. /*---------------------------------------------------------------------*/
  198. /* Determine if the first word of the supplied command is REXX (either */
  199. /* case)...                                                            */
  200. /*---------------------------------------------------------------------*/
  201.  if (memcmpi(word[3],(CHARTYPE *)"REXX ",5) == 0)
  202.    {
  203.     ptr = word[3];
  204.     rc = add_define(&first_mouse_define,&last_mouse_define,key_value,ptr+5,TRUE);
  205.    }
  206.  else
  207.     rc = add_define(&first_mouse_define,&last_mouse_define,key_value,word[3],FALSE);
  208. #ifdef TRACE
  209.  trace_return();
  210. #endif
  211.  return(rc);
  212. }
  213. /*man-start*********************************************************************
  214. COMMAND
  215.      delete - delete lines from a file
  216.  
  217. SYNTAX
  218.      DELete [target]
  219.  
  220. DESCRIPTION
  221.      The DELETE command removes lines from the current file.
  222.      The number of lines removed depends on the <'target'> specified.
  223.      Lines are removed starting with the <focus line>.
  224.  
  225. COMPATIBILITY
  226.      XEDIT: Compatible.
  227.      KEDIT: Compatible.
  228.  
  229. DEFAULT
  230.      1
  231.  
  232. SEE ALSO
  233.      <SOS DELLINE>
  234.  
  235. STATUS
  236.      Complete.
  237. **man-end**********************************************************************/
  238. #ifdef HAVE_PROTO
  239. short DeleteLine(CHARTYPE *params)
  240. #else
  241. short DeleteLine(params)
  242. CHARTYPE *params;
  243. #endif
  244. /***********************************************************************/
  245. {
  246. /*-------------------------- external data ----------------------------*/
  247.  extern VIEW_DETAILS *vd_mark;
  248. /*--------------------------- local data ------------------------------*/
  249.  LINETYPE start_line=0L,end_line=0L,dest_line=0L,lines_affected=0L;
  250.  short rc=RC_OK;
  251.  CHARTYPE *args=NULL;
  252.  TARGET target;
  253.  short target_type=TARGET_NORMAL|TARGET_ALL|TARGET_BLOCK_CURRENT;
  254.  bool lines_based_on_scope=FALSE;
  255. /*--------------------------- processing ------------------------------*/
  256. #ifdef TRACE
  257.  trace_function("comm2.c:   DeleteLine");
  258. #endif
  259. /*---------------------------------------------------------------------*/
  260. /* If no parameter is supplied, 1 is assumed.                          */
  261. /*---------------------------------------------------------------------*/
  262.  if (blank_field(params))
  263.     args = (CHARTYPE *)"1";
  264.  else
  265.     args = params;
  266.  initialise_target(&target);
  267.  if ((rc = validate_target(args,&target,target_type,get_true_line(TRUE),TRUE,TRUE)) != RC_OK)
  268.    {
  269.     free_target(&target);
  270. #ifdef TRACE
  271.     trace_return();
  272. #endif
  273.     return(rc);
  274.    }
  275. /*---------------------------------------------------------------------*/
  276. /* If the target is BLOCK and the marked block is a box block, call    */
  277. /* box_operations(), otherwise delete specified lines.                 */
  278. /*---------------------------------------------------------------------*/
  279.  if (target.rt[0].target_type == TARGET_BLOCK_CURRENT)
  280.    {
  281. /*---------------------------------------------------------------------*/
  282. /* For box blocks, call the appropriate function...                    */
  283. /*---------------------------------------------------------------------*/
  284.     if (MARK_VIEW->mark_type != M_LINE)
  285.       {
  286.        free_target(&target);
  287.        box_operations(BOX_D,SOURCE_BLOCK_RESET,FALSE,' ');
  288. #ifdef TRACE
  289.        trace_return();
  290. #endif
  291.        return(RC_OK);
  292.       }
  293.     start_line = MARK_VIEW->mark_start_line;
  294.     end_line = MARK_VIEW->mark_end_line;
  295.     dest_line = MARK_VIEW->mark_start_line;
  296.     lines_based_on_scope = FALSE;
  297.    }
  298.  else
  299.    {
  300.     start_line = target.true_line;
  301.     if (target.num_lines < 0L)
  302.       {
  303.        end_line = (target.true_line + target.num_lines) + 1L;
  304.        dest_line = end_line;
  305.       }
  306.     else
  307.       {
  308.        end_line = (target.true_line + target.num_lines) - 1L;
  309.        dest_line = start_line;
  310.       }
  311.     lines_based_on_scope = TRUE;
  312.    }
  313.  free_target(&target);
  314.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  315.  if (target.num_lines != 0L)
  316.     rc = rearrange_line_blocks(COMMAND_DELETE,SOURCE_COMMAND,start_line,
  317.                                end_line,dest_line,1,CURRENT_VIEW,CURRENT_VIEW,
  318.                                lines_based_on_scope,&lines_affected);
  319.  CURRENT_VIEW->current_line = find_next_in_scope(CURRENT_VIEW,NULL,CURRENT_VIEW->current_line,DIRECTION_FORWARD);
  320.  start_line = find_next_in_scope(CURRENT_VIEW,NULL,CURRENT_VIEW->focus_line,DIRECTION_FORWARD);
  321.  if (CURRENT_VIEW->focus_line != start_line)
  322.    {
  323.     CURRENT_VIEW->focus_line = start_line;
  324.     pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  325.    }
  326.  if (rc == RC_OK)
  327.    {
  328.     if (CURRENT_BOF || CURRENT_TOF)
  329.        rc = RC_TOF_EOF_REACHED;
  330.    }
  331. #ifdef TRACE
  332.  trace_return();
  333. #endif
  334.  return(rc);
  335. }
  336. /*man-start*********************************************************************
  337. COMMAND
  338.      directory - list the specified directory as an editable file
  339.  
  340. SYNTAX
  341.      DIRectory [file specification]
  342.  
  343. DESCRIPTION
  344.      The DIRECTORY command displays all files matching the specified 
  345.      'file specification'.
  346.  
  347.      When no parameter is supplied, all files in the current directory 
  348.      are displayed subject to any <SET DIRINCLUDE> restrictions.
  349.  
  350. COMPATIBILITY
  351.      XEDIT: N/A
  352.      KEDIT: Compatible.
  353.  
  354. SEE ALSO
  355.      <LS>, <SET DIRINCLUDE>
  356.  
  357. STATUS
  358.      Complete.
  359. **man-end**********************************************************************/
  360. #ifdef HAVE_PROTO
  361. short Directory(CHARTYPE *params)
  362. #else
  363. short Directory(params)
  364. CHARTYPE *params;
  365. #endif
  366. /***********************************************************************/
  367. {
  368. /*-------------------------- external data ----------------------------*/
  369.  extern CHARTYPE *temp_cmd;
  370. #if !defined(MULTIPLE_PSEUDO_FILES)
  371.  extern CHARTYPE dir_filename[10];
  372.  extern CHARTYPE dir_pathname[MAX_FILE_NAME+1];
  373. #endif
  374.  extern CHARTYPE dir_path[MAX_FILE_NAME+1];
  375.  extern CHARTYPE dir_files[MAX_FILE_NAME+1];
  376.  extern CHARTYPE sp_fname[MAX_FILE_NAME+1];
  377. /*--------------------------- local data ------------------------------*/
  378. #define DIR_PARAMS  1
  379.  CHARTYPE *word[DIR_PARAMS+1];
  380.  CHARTYPE strip[DIR_PARAMS];
  381.  unsigned short num_params=0;
  382.  short rc=RC_OK;
  383. /*--------------------------- processing ------------------------------*/
  384. #ifdef TRACE
  385.  trace_function("comm2.c:   Directory");
  386. #endif
  387. /*---------------------------------------------------------------------*/
  388. /* Validate the parameters that have been supplied. The one and only   */
  389. /* parameter should be the directory to display.                       */
  390. /*---------------------------------------------------------------------*/
  391.  strip[0] = STRIP_BOTH;
  392.  num_params = param_split(params,word,DIR_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  393.  if (num_params > 1)
  394.    {
  395.     display_error(1,(CHARTYPE *)word[1],FALSE);
  396. #ifdef TRACE
  397.     trace_return();
  398. #endif
  399.     return(RC_INVALID_OPERAND);
  400.    }
  401. /*---------------------------------------------------------------------*/
  402. /* Validate that the supplied directory is valid.                      */
  403. /*---------------------------------------------------------------------*/
  404.  if ((rc = splitpath(strrmdup(strtrans(word[0],OSLASH,ISLASH),ISLASH))) != RC_OK)
  405.    {
  406.     display_error(10,(CHARTYPE *)word[0],FALSE);
  407. #ifdef TRACE
  408.     trace_return();
  409. #endif
  410.     return(rc);
  411.    }
  412.  if ((rc = read_directory()) != RC_OK)
  413.    {
  414.     if (strcmp((DEFCHAR *)sp_fname,"") == 0)
  415.        display_error(10,(CHARTYPE *)word[0],FALSE);
  416.     else
  417.        display_error(9,(CHARTYPE *)word[0],FALSE);
  418. #ifdef TRACE
  419.     trace_return();
  420. #endif
  421.     return(rc);
  422.    }
  423. #if 0
  424.  if (CURRENT_VIEW != NULL)
  425.     pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  426. #endif
  427.  
  428. #if defined(MULTIPLE_PSEUDO_FILES)
  429.  strcpy((DEFCHAR *)temp_cmd,(DEFCHAR *)dir_path);
  430.  strcat((DEFCHAR *)temp_cmd,(DEFCHAR *)dir_files);
  431. #else
  432.  strcpy((DEFCHAR *)temp_cmd,(DEFCHAR *)dir_pathname);
  433.  strcat((DEFCHAR *)temp_cmd,(DEFCHAR *)dir_filename);
  434. #endif
  435.  Xedit(temp_cmd);
  436.  
  437. #ifdef TRACE
  438.  trace_return();
  439. #endif
  440.  return(RC_OK);
  441. }
  442. /*man-start*********************************************************************
  443. COMMAND
  444.      dos - execute an operating system command
  445.  
  446. SYNTAX
  447.      DOS [command]
  448.  
  449. DESCRIPTION
  450.      The DOS command executes the supplied operating system 'command'
  451.      or runs an interactive shell if no 'command' is supplied.
  452.  
  453. COMPATIBILITY
  454.      XEDIT: N/A
  455.      KEDIT: Compatible.
  456.  
  457. SEE ALSO
  458.      <OS>, <!>
  459.  
  460. STATUS
  461.      Complete.
  462. **man-end**********************************************************************/
  463.  
  464. /*man-start*********************************************************************
  465. COMMAND
  466.      dosnowait - execute an operating system command - no prompt
  467.  
  468. SYNTAX
  469.      DOSNowait command
  470.  
  471. DESCRIPTION
  472.      The DOSNOWAIT command executes the supplied operating system 
  473.      command not waiting for the user to be prompted once the
  474.      command has completed.
  475.  
  476. COMPATIBILITY
  477.      XEDIT: N/A
  478.      KEDIT: Compatible.
  479.  
  480. SEE ALSO
  481.      <OSNOWAIT>
  482.  
  483. STATUS
  484.      Complete.
  485. **man-end**********************************************************************/
  486.  
  487. /*man-start*********************************************************************
  488. COMMAND
  489.      dosquiet - execute an operating system command quietly
  490.  
  491. SYNTAX
  492.      DOSQuiet command
  493.  
  494. DESCRIPTION
  495.      The DOSQUIET command executes the supplied operating system 'command'
  496.      as quietly as possible.
  497.  
  498. COMPATIBILITY
  499.      XEDIT: N/A
  500.      KEDIT: Compatible.
  501.  
  502. SEE ALSO
  503.      <OSQUIET>
  504.  
  505. STATUS
  506.      Complete.
  507. **man-end**********************************************************************/
  508.  
  509. /*man-start*********************************************************************
  510. COMMAND
  511.      down - move forward in the file a number of lines
  512.  
  513. SYNTAX
  514.      Down [relative target]
  515.  
  516. DESCRIPTION
  517.      The DOWN command moves the <current line> forwards the number of
  518.      lines specified by the <'relative target'>. This <'relative target'> 
  519.      can only be a positive integer or the character "*". 
  520.  
  521. COMPATIBILITY
  522.      XEDIT: Compatible.
  523.      KEDIT: Compatible.
  524.  
  525. DEFAULT
  526.      1
  527.  
  528. SEE ALSO
  529.      <NEXT>, <UP>
  530.  
  531. STATUS
  532.      Complete.
  533. **man-end**********************************************************************/
  534.  
  535. /*man-start*********************************************************************
  536. COMMAND
  537.      duplicate - duplicate lines
  538.  
  539. SYNTAX
  540.      DUPlicate [n [target|BLOCK]]
  541.  
  542. DESCRIPTION
  543.      The DUPLICATE command copies the number of lines extrapolated from
  544.      <'target'> or the marked 'BLOCK', 'n' times.
  545.  
  546. COMPATIBILITY
  547.      XEDIT: Equivalent of DUPLICAT command.
  548.      KEDIT: Compatible.
  549.  
  550. STATUS
  551.      Complete.
  552. **man-end**********************************************************************/
  553. #ifdef HAVE_PROTO
  554. short Duplicate(CHARTYPE *params)
  555. #else
  556. short Duplicate(params)
  557. CHARTYPE *params;
  558. #endif
  559. /***********************************************************************/
  560. {
  561. /*------------------------- external data -----------------------------*/
  562.  extern VIEW_DETAILS *vd_mark;
  563. /*--------------------------- local data ------------------------------*/
  564. #define DUP_PARAMS  2
  565.  CHARTYPE *word[DUP_PARAMS+1];
  566.  CHARTYPE strip[DUP_PARAMS];
  567.  unsigned short num_params=0;
  568.  short rc=RC_OK,num_occ=0;
  569.  LINETYPE start_line=0L,end_line=0L,dest_line=0L,lines_affected=0L;
  570.  CHARTYPE command_source=0;
  571.  TARGET target;
  572.  short target_type=TARGET_NORMAL|TARGET_BLOCK_CURRENT|TARGET_ALL;
  573.  bool lines_based_on_scope=FALSE;
  574. /*--------------------------- processing ------------------------------*/
  575. #ifdef TRACE
  576.  trace_function("comm2.c:   Duplicate");
  577. #endif
  578.  strip[0]=STRIP_BOTH;
  579.  strip[1]=STRIP_LEADING;
  580.  num_params = param_split(params,word,DUP_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  581. /*---------------------------------------------------------------------*/
  582. /* If no parameters, default to 1 1                                    */
  583. /*---------------------------------------------------------------------*/
  584.  if (num_params == 0)
  585.    {
  586.     word[0] = (CHARTYPE *)"1";
  587.     word[1] = (CHARTYPE *)"1";
  588.    }
  589. /*---------------------------------------------------------------------*/
  590. /* If 1 parameter, default 2nd parameter to 1                          */
  591. /*---------------------------------------------------------------------*/
  592.  if (num_params == 1)
  593.     word[1] = (CHARTYPE *)"1";
  594. /*---------------------------------------------------------------------*/
  595. /* If first parameter is not an integer, error.                        */
  596. /*---------------------------------------------------------------------*/
  597.  if (!valid_integer(word[0]))
  598.    {
  599.     display_error(4,word[0],FALSE);
  600. #ifdef TRACE
  601.     trace_return();
  602. #endif
  603.     return(RC_INVALID_OPERAND);
  604.    }
  605.  num_occ = atoi((DEFCHAR *)word[0]);
  606. /*---------------------------------------------------------------------*/
  607. /* Validate second parameter is a valid target...                      */
  608. /*---------------------------------------------------------------------*/
  609.  initialise_target(&target);
  610.  if ((rc = validate_target(word[1],&target,target_type,get_true_line(TRUE),TRUE,TRUE)) != RC_OK)
  611.    {
  612.     free_target(&target);
  613. #ifdef TRACE
  614.     trace_return();
  615. #endif
  616.     return(rc);
  617.    }
  618. /*---------------------------------------------------------------------*/
  619. /* Duplicate lines depending on target type...                         */
  620. /*---------------------------------------------------------------------*/
  621.  switch(target.rt[0].target_type)
  622.    {
  623.     case TARGET_BLOCK_CURRENT:
  624. /*---------------------------------------------------------------------*/
  625. /* This function not valid for box  blocks.                            */
  626. /*---------------------------------------------------------------------*/
  627.          if (MARK_VIEW->mark_type == M_BOX)
  628.            {
  629.             display_error(48,(CHARTYPE *)"",FALSE);
  630. #ifdef TRACE
  631.             trace_return();
  632. #endif
  633.             return(RC_INVALID_ENVIRON);
  634.            }
  635.          command_source = SOURCE_BLOCK;
  636.          start_line = MARK_VIEW->mark_start_line;
  637.          end_line = dest_line = MARK_VIEW->mark_end_line;
  638.          lines_based_on_scope = FALSE;
  639.          break;
  640.     default:
  641.          command_source = SOURCE_COMMAND;
  642.          if (target.num_lines < 0L)
  643.            {
  644.             start_line = target.true_line + target.num_lines + 1L;
  645.             end_line = dest_line = target.true_line;
  646.            }
  647.          else
  648.            {
  649.             start_line = target.true_line;
  650.             end_line = dest_line = (target.true_line + target.num_lines) - 1L;
  651.            }
  652.          lines_based_on_scope = TRUE;
  653.          break;
  654.    }
  655.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  656.  rc = rearrange_line_blocks(COMMAND_DUPLICATE,command_source,
  657.                             start_line,end_line,dest_line,num_occ,
  658.                             CURRENT_VIEW,CURRENT_VIEW,lines_based_on_scope,
  659.                             &lines_affected);
  660.  free_target(&target);
  661. #ifdef TRACE
  662.  trace_return();
  663. #endif
  664.  return(rc);
  665. }
  666.  
  667. /*man-start*********************************************************************
  668. COMMAND
  669.      edit - edit another file or switch to next file
  670.  
  671. SYNTAX
  672.      Edit [file]
  673.  
  674. DESCRIPTION
  675.      The EDIT command allows the user to edit another 'file'. The new file
  676.      is placed in the file <ring>. The previous file being edited remains
  677.      in memory and can be returned to by issuing an EDIT command without
  678.      any parameters. Several files can be edited at once, and all files
  679.      are arranged in a ring, with subsequent EDIT commands moving through
  680.      the ring, one file at a time.
  681.  
  682. COMPATIBILITY
  683.      XEDIT: Does not provide options switches.
  684.      KEDIT: Does not provide options switches.
  685.  
  686. SEE ALSO
  687.      <THE>, <XEDIT>
  688.  
  689. STATUS
  690.      Complete.
  691. **man-end**********************************************************************/
  692.  
  693. /*man-start*********************************************************************
  694. COMMAND
  695.      editv - set and retrieve persistent macro variables
  696.  
  697. SYNTAX
  698.      EDITV GET|PUT|GETF|PUTF var1 [var2 ...]
  699.      EDITV SET|SETF var1 value1 [var2 value2 ...]
  700.      EDITV SETL|SETLF|SETFL var1 value1
  701.      EDITV LIST|LISTF [var1 ...]
  702.  
  703. DESCRIPTION
  704.      The EDITV command manipulates variables for the lifetime of the
  705.      edit session or the file, depending on the subcommand used.
  706.  
  707.      Edit variables are useful for maintaining variable values from 
  708.      one execution of a macro to another.
  709.  
  710.      EDITV GET, PUT, GETF and PUTF are only valid from within a macro
  711.      as they reference Rexx variables.  All other subcommands are valid
  712.      from within a macro or from the command line.
  713.  
  714.      EDITV GET sets a Rexx macro variable, with the same name as the
  715.      edit variable, to the value of the edit variable.
  716.  
  717.      EDITV PUT stores the value of a Rexx macro variable as an edit
  718.      variable.
  719.  
  720.      EDITV SET stores an edit variable with a value.
  721.  
  722.      EDITV SET can only work with variable values comprising a single
  723.      space-seperated word.  To specify a variable value that contains
  724.      spaces, use EDITV SETL.
  725.  
  726.      EDITV LIST displays the values of the specified edit variables, or
  727.      all variables if no edit variables are specified.
  728.  
  729.      EDITV GETF, PUTF, SETF, SETLF, SETFL, and LISTF all work the same
  730.      way as their counterparts without the F, but the variables are
  731.      only available while the particular file is the current file.  This
  732.      enables you to use the same edit variable name but with different
  733.      values for different files.
  734.  
  735. COMPATIBILITY
  736.      XEDIT: N/A
  737.      KEDIT: Compatible
  738.  
  739. STATUS
  740.      Complete.
  741. **man-end**********************************************************************/
  742. #ifdef HAVE_PROTO
  743. short THEEditv(CHARTYPE *params)
  744. #else
  745. short THEEditv(params)
  746. CHARTYPE *params;
  747. #endif
  748. /***********************************************************************/
  749. {
  750. /*-------------------------- external data ----------------------------*/
  751.  extern bool in_macro;
  752. /*--------------------------- local data ------------------------------*/
  753. #define EDITV_PARAMS  2
  754.  CHARTYPE *word[EDITV_PARAMS+1];
  755.  CHARTYPE strip[EDITV_PARAMS];
  756.  unsigned short num_params=0;
  757.  short editv_type=0;
  758.  short rc=RC_OK;
  759.  bool editv_file = FALSE;
  760. /*--------------------------- processing ------------------------------*/
  761. #ifdef TRACE
  762.  trace_function("comm2.c:   THEEditv");
  763. #endif
  764.  strip[0] = STRIP_BOTH;
  765.  strip[1] = STRIP_LEADING;
  766.  num_params = param_split(params,word,EDITV_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  767.  if (num_params == 0)
  768.    {
  769.     display_error(3,(CHARTYPE *)"",FALSE);
  770. #ifdef TRACE
  771.     trace_return();
  772. #endif
  773.     return(RC_INVALID_OPERAND);
  774.    }
  775. /*---------------------------------------------------------------------*/
  776. /* Determine the subcommand...                                         */
  777. /*---------------------------------------------------------------------*/
  778.  if (equal((CHARTYPE *)"GET",word[0],3))
  779.    {
  780.     editv_type = EDITV_GET;
  781.    }
  782.  else if (equal((CHARTYPE *)"PUT",word[0],3))
  783.    {
  784.     editv_type = EDITV_PUT;
  785.    }
  786.  else if (equal((CHARTYPE *)"SET",word[0],3))
  787.    {
  788.     editv_type = EDITV_SET;
  789.    }
  790.  else if (equal((CHARTYPE *)"SETL",word[0],4))
  791.    {
  792.     editv_type = EDITV_SETL;
  793.    }
  794.  else if (equal((CHARTYPE *)"LIST",word[0],4))
  795.    {
  796.     editv_type = EDITV_LIST;
  797.    }
  798.  else if (equal((CHARTYPE *)"GETF",word[0],4))
  799.    {
  800.     editv_type = EDITV_GET;
  801.     editv_file = TRUE;
  802.    }
  803.  else if (equal((CHARTYPE *)"PUTF",word[0],4))
  804.    {
  805.     editv_type = EDITV_PUT;
  806.     editv_file = TRUE;
  807.    }
  808.  else if (equal((CHARTYPE *)"SETF",word[0],4))
  809.    {
  810.     editv_type = EDITV_SET;
  811.     editv_file = TRUE;
  812.    }
  813.  else if (equal((CHARTYPE *)"SETLF",word[0],5))
  814.    {
  815.     editv_type = EDITV_SETL;
  816.     editv_file = TRUE;
  817.    }
  818.  else if (equal((CHARTYPE *)"SETFL",word[0],5))
  819.    {
  820.     editv_type = EDITV_SETL;
  821.     editv_file = TRUE;
  822.    }
  823.  else if (equal((CHARTYPE *)"LISTF",word[0],5))
  824.    {
  825.     editv_type = EDITV_LIST;
  826.     editv_file = TRUE;
  827.    }
  828.  else
  829.    {
  830.     display_error(1,word[0],FALSE);
  831. #ifdef TRACE
  832.     trace_return();
  833. #endif
  834.     return(RC_INVALID_OPERAND);
  835.    }
  836. /*---------------------------------------------------------------------*/
  837. /* Only LIST and LISTF are allowed no parameters...                    */
  838. /*---------------------------------------------------------------------*/
  839.  if (editv_type != EDITV_LIST
  840.  &&  num_params == 1)
  841.    {
  842.     display_error(3,(CHARTYPE *)"",FALSE);
  843. #ifdef TRACE
  844.     trace_return();
  845. #endif
  846.     return(RC_INVALID_OPERAND);
  847.    }
  848. /*---------------------------------------------------------------------*/
  849. /* GET, PUT, GETF and PUTF only allowed in a macro...                  */
  850. /*---------------------------------------------------------------------*/
  851.  if (editv_type == EDITV_GET
  852.  ||  editv_type == EDITV_PUT)
  853.    {
  854.     if (!in_macro)
  855.       {
  856.        display_error(53,(CHARTYPE *)"",FALSE);
  857. #ifdef TRACE
  858.        trace_return();
  859. #endif
  860.        return(RC_INVALID_ENVIRON);
  861.       }
  862.    }
  863.  rc = execute_editv(editv_type,editv_file,word[1]);
  864. #ifdef TRACE
  865.  trace_return();
  866. #endif
  867.  return(RC_OK);
  868. }
  869.  
  870. /*man-start*********************************************************************
  871. COMMAND
  872.      emsg - display message
  873.  
  874. SYNTAX
  875.      EMSG [message]
  876.  
  877. DESCRIPTION
  878.      The EMSG command displays an 'message' on the <message line>.
  879.      This command is usually issued from a macro file.
  880.  
  881. COMPATIBILITY
  882.      XEDIT: Does not support [mmmnnns text] option
  883.      KEDIT: Compatible
  884.  
  885. SEE ALSO
  886.      <CMSG>, <MSG>
  887.  
  888. STATUS
  889.      Complete.
  890. **man-end**********************************************************************/
  891. #ifdef HAVE_PROTO
  892. short Emsg(CHARTYPE *params)
  893. #else
  894. short Emsg(params)
  895. CHARTYPE *params;
  896. #endif
  897. /***********************************************************************/
  898. {
  899. /*-------------------------- external data ----------------------------*/
  900. /*--------------------------- local data ------------------------------*/
  901. /*--------------------------- processing ------------------------------*/
  902. #ifdef TRACE
  903.  trace_function("comm2.c:   Emsg");
  904. #endif
  905.  display_error(0,params,FALSE);
  906. #ifdef TRACE
  907.  trace_return();
  908. #endif
  909.  return(RC_OK);
  910. }
  911. /*man-start*********************************************************************
  912. COMMAND
  913.      enter - execute a command
  914.  
  915. SYNTAX
  916.      enter
  917.  
  918. DESCRIPTION
  919.      The ENTER command executes the command currently displayed on the
  920.      command line, if the cursor is currently displayed there.
  921.      If the key associated with ENTER is pressed while in the <filearea>,
  922.      then the cursor will move to the first column of the
  923.      next line. If the cursor is in the <prefix area>, any pending
  924.      prefix commands will be executed. If the mode is currently in 
  925.      'insert', then a new line is added and the cursor placed on the
  926.      next line depending on the value of <SET NEWLINES>.
  927.  
  928.      This command can only be used by assigning it to a function key
  929.      with the <DEFINE> command.
  930.  
  931.      This command will be removed in a future version.
  932.  
  933. COMPATIBILITY
  934.      XEDIT: N/A
  935.      KEDIT: N/A
  936.  
  937. SEE ALSO
  938.      <SOS EXECUTE>
  939.  
  940. STATUS
  941.      Complete.
  942. **man-end**********************************************************************/
  943. #ifdef HAVE_PROTO
  944. short Enter(CHARTYPE *params)
  945. #else
  946. short Enter(params)
  947. CHARTYPE *params;
  948. #endif
  949. /***********************************************************************/
  950. {
  951. /*------------------------- external data -----------------------------*/
  952.  extern bool readonly;
  953. /*--------------------------- local data ------------------------------*/
  954.  unsigned short x=0,y=0;
  955.  short rc=RC_OK;
  956. /*--------------------------- processing ------------------------------*/
  957. #ifdef TRACE
  958.  trace_function("comm2.c:   Enter");
  959. #endif
  960.  switch(CURRENT_VIEW->current_window)
  961.    {
  962.     case WINDOW_COMMAND:
  963.          rc = Sos_execute((CHARTYPE *)"");
  964.          break;
  965.     case WINDOW_PREFIX:
  966.          post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  967.          if (CURRENT_FILE->first_ppc == NULL)/* no pending prefix cmds */
  968.            {
  969.             cursor_down(TRUE);
  970.             rc = Sos_firstcol((CHARTYPE *)"");
  971.            }
  972.          else
  973.             Sos_doprefix((CHARTYPE *)"");
  974.          break;
  975.     case WINDOW_FILEAREA:
  976. /*---------------------------------------------------------------------*/
  977. /* If in readonly mode, ignore new line addition...                    */
  978. /*---------------------------------------------------------------------*/
  979.          if (!readonly)
  980.            {
  981.             if (CURRENT_VIEW->inputmode == INPUTMODE_LINE)
  982.               {
  983.                post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  984.                insert_new_line((CHARTYPE *)"",0,1,get_true_line(FALSE),FALSE,FALSE,TRUE,CURRENT_VIEW->display_low,TRUE,TRUE);
  985.                break;
  986.               }
  987.            }
  988.          cursor_down(TRUE);
  989.          getyx(CURRENT_WINDOW,y,x);
  990.          wmove(CURRENT_WINDOW,y,0);
  991.          break;
  992.    }
  993. #ifdef TRACE
  994.  trace_return();
  995. #endif
  996.  return(rc);
  997. }
  998. /*man-start*********************************************************************
  999. COMMAND
  1000.      expand - expand tab characters to spaces
  1001.  
  1002. SYNTAX
  1003.      EXPand [target]
  1004.  
  1005. DESCRIPTION
  1006.      The EXPAND command converts all tab characters to spaces in the
  1007.      <'target'> depending on the size of a tab determined by the 
  1008.      <SET TABS> command.
  1009.  
  1010. COMPATIBILITY
  1011.      XEDIT: Compatible.
  1012.      KEDIT: Compatible.
  1013.  
  1014. SEE ALSO
  1015.      <COMPRESS>, <SET TABS>
  1016.  
  1017. STATUS
  1018.      Complete.
  1019. **man-end**********************************************************************/
  1020. #ifdef HAVE_PROTO
  1021. short Expand(CHARTYPE *params)
  1022. #else
  1023. short Expand(params)
  1024. CHARTYPE *params;
  1025. #endif
  1026. /***********************************************************************/
  1027. {
  1028. /*-------------------------- external data ----------------------------*/
  1029. /*--------------------------- local data ------------------------------*/
  1030.  short rc=RC_OK;
  1031. /*--------------------------- processing ------------------------------*/
  1032. #ifdef TRACE
  1033.  trace_function("comm2.c:   Expand");
  1034. #endif
  1035.  rc = execute_expand_compress(params,TRUE,TRUE,TRUE,TRUE);
  1036. #ifdef TRACE
  1037.  trace_return();
  1038. #endif
  1039.  return(rc);
  1040. }
  1041. /*man-start*********************************************************************
  1042. COMMAND
  1043.      extract - obtain various internal information about THE
  1044.  
  1045. SYNTAX
  1046.      EXTract /item/[...]
  1047.  
  1048. DESCRIPTION
  1049.      The EXTRACT command is used to relay information about settings
  1050.      within THE from within a REXX macro. EXTRACT is only valid within
  1051.      a REXX macro.
  1052.  
  1053.      For a complete list of 'item's that can be extracted, see the section;
  1054.      <QUERY, EXTRACT and STATUS>.
  1055.  
  1056. COMPATIBILITY
  1057.      XEDIT: Only allows '/' as delimiter.
  1058.      KEDIT: Only allows '/' as delimiter.
  1059.  
  1060. STATUS
  1061.      Complete.
  1062. **man-end**********************************************************************/
  1063. #ifdef HAVE_PROTO
  1064. short Extract(CHARTYPE *params)
  1065. #else
  1066. short Extract(params)
  1067. CHARTYPE *params;
  1068. #endif
  1069. /***********************************************************************/
  1070. {
  1071. /*-------------------------- external data ----------------------------*/
  1072.  extern bool in_macro;
  1073.  extern bool rexx_support;
  1074. /*--------------------------- local data ------------------------------*/
  1075.  register short i=0;
  1076.  short rc=RC_OK,itemno=0,num_items=0,len=0,num_values=0;
  1077.  short pos=0,arglen=0;
  1078.  CHARTYPE *args=NULL;
  1079.  bool invalid_item=FALSE;
  1080. /*--------------------------- processing ------------------------------*/
  1081. #ifdef TRACE
  1082.  trace_function("comm2.c:   Extract");
  1083. #endif
  1084.  if (!in_macro
  1085.  ||  !rexx_support)
  1086.    {
  1087.     display_error(53,(CHARTYPE *)"",FALSE);
  1088. #ifdef TRACE
  1089.     trace_return();
  1090. #endif
  1091.     return(RC_INVALID_ENVIRON);
  1092.    }
  1093. /*---------------------------------------------------------------------*/
  1094. /* Check that the first character of parameters is /.                  */
  1095. /*---------------------------------------------------------------------*/
  1096.  if (*(params) != '/')
  1097.    {
  1098.     display_error(1,params,FALSE);
  1099. #ifdef TRACE
  1100.     trace_return();
  1101. #endif
  1102.     return(RC_INVALID_OPERAND);
  1103.    }
  1104.  params++;                               /* throw away first delimiter */
  1105.  strtrunc(params);
  1106.  len = strlen((DEFCHAR *)params);
  1107. /*---------------------------------------------------------------------*/
  1108. /* Check that we have an item to extract...                            */
  1109. /*---------------------------------------------------------------------*/
  1110.  if (len == 0)
  1111.     invalid_item = TRUE;
  1112.  else
  1113.     if (len == 1 && (*(params) == '/'))
  1114.        invalid_item = TRUE;
  1115.  if (invalid_item)
  1116.    {
  1117.     display_error(1,params,FALSE);
  1118. #ifdef TRACE
  1119.     trace_return();
  1120. #endif
  1121.     return(RC_INVALID_OPERAND);
  1122.    }
  1123. /*---------------------------------------------------------------------*/
  1124. /* Allow for no trailing '/'...                                        */
  1125. /*---------------------------------------------------------------------*/
  1126.  if ((*(params+len-1) == '/'))
  1127.     num_items = 0;
  1128.  else
  1129.     num_items = 1;
  1130. /*---------------------------------------------------------------------*/
  1131. /* Replace all / with nul character to give us seperate strings.       */
  1132. /*---------------------------------------------------------------------*/
  1133.  for (i=0;i<len;i++)
  1134.    {
  1135.     if (*(params+i) == '/')
  1136.       {
  1137.        *(params+i) = '\0';
  1138.        num_items++;
  1139.       }
  1140.    }
  1141. /*---------------------------------------------------------------------*/
  1142. /* For each item, extract its variables...                             */
  1143. /*---------------------------------------------------------------------*/
  1144.  for (i=0;i<num_items;i++)
  1145.    {
  1146. /*---------------------------------------------------------------------*/
  1147. /* First check if the item has any arguments with it.                  */
  1148. /*---------------------------------------------------------------------*/
  1149.     arglen = strlen((DEFCHAR *)params);
  1150.     pos = strzeq(params,' ');
  1151.     if (pos == (-1))
  1152.        args = (CHARTYPE *)"";
  1153.     else
  1154.       {
  1155.        *(params+pos) = '\0';
  1156.        args = strtrunc(params+pos+1);
  1157.       }
  1158. /*---------------------------------------------------------------------*/
  1159. /* Find the item in the list of valid extract options...               */
  1160. /*---------------------------------------------------------------------*/
  1161.     if ((itemno = find_item(params,QUERY_EXTRACT)) == (-1))
  1162.        {
  1163.         display_error(1,params,FALSE);
  1164. #ifdef TRACE
  1165.         trace_return();
  1166. #endif
  1167.         return(RC_INVALID_OPERAND);
  1168.        }
  1169. /*---------------------------------------------------------------------*/
  1170. /* Get the current settings for the valid item...                      */
  1171. /*---------------------------------------------------------------------*/
  1172.     num_values = get_item_values(itemno,args,QUERY_EXTRACT,0L,NULL,0L);
  1173. /*---------------------------------------------------------------------*/
  1174. /* If the arguments to the item are invalid, return with an error.     */
  1175. /*---------------------------------------------------------------------*/
  1176.     if (num_values == EXTRACT_ARG_ERROR)
  1177.        {
  1178. #ifdef TRACE
  1179.         trace_return();
  1180. #endif
  1181.         return(RC_INVALID_OPERAND);
  1182.        }
  1183. /*---------------------------------------------------------------------*/
  1184. /* If the REXX variables have already been set, don't try to set them. */
  1185. /*---------------------------------------------------------------------*/
  1186.     if (num_values != EXTRACT_VARIABLES_SET)
  1187.       {
  1188.        rc = set_extract_variables(itemno);
  1189.        if (rc == RC_SYSTEM_ERROR)
  1190.           break;
  1191.       }
  1192.     params += arglen+1;
  1193.    }
  1194.  
  1195. #ifdef TRACE
  1196.  trace_return();
  1197. #endif
  1198.  return(rc);
  1199. }
  1200. /*man-start*********************************************************************
  1201. COMMAND
  1202.      ffile - force a FILE of the current file to disk
  1203.  
  1204. SYNTAX
  1205.      FFile  [filename]
  1206.  
  1207. DESCRIPTION
  1208.      The FFILE command writes the current file to disk to the current
  1209.      file name or to the supplied 'filename'.
  1210.      Unlike the <FILE> command, if the optional 'filename' exists, this
  1211.      command will overwrite the file.
  1212.  
  1213. COMPATIBILITY
  1214.      XEDIT: N/A
  1215.      KEDIT: Compatible.
  1216.  
  1217. DEFAULT
  1218.      With no parameters, the current file is written.
  1219.  
  1220. SEE ALSO
  1221.      <FILE>, <SAVE>, <SSAVE>
  1222.  
  1223. STATUS
  1224.      Complete
  1225. **man-end**********************************************************************/
  1226. #ifdef HAVE_PROTO
  1227. short Ffile(CHARTYPE *params)
  1228. #else
  1229. short Ffile(params)
  1230. CHARTYPE *params;
  1231. #endif
  1232. /***********************************************************************/
  1233. {
  1234. /*-------------------------- external data ----------------------------*/
  1235. /*--------------------------- local data ------------------------------*/
  1236.  short rc=RC_OK;
  1237. /*--------------------------- processing ------------------------------*/
  1238. #ifdef TRACE
  1239.  trace_function("comm2.c:   Ffile");
  1240. #endif
  1241.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1242.  if ((rc = save_file(CURRENT_FILE,params,TRUE,CURRENT_FILE->number_lines,1L,NULL,FALSE,0,max_line_length,TRUE,FALSE)) != RC_OK)
  1243.    {
  1244. #ifdef TRACE
  1245.     trace_return();
  1246. #endif
  1247.     return(rc);
  1248.    }
  1249. /*---------------------------------------------------------------------*/
  1250. /* If autosave is on at the time of FFiling, remove the .aus file...   */
  1251. /*---------------------------------------------------------------------*/
  1252.  if (CURRENT_FILE->autosave > 0)
  1253.     rc = remove_aus_file(CURRENT_FILE);
  1254.  free_view_memory(TRUE,TRUE);
  1255. #ifdef TRACE
  1256.  trace_return();
  1257. #endif
  1258.  return(rc);
  1259. }
  1260. /*man-start*********************************************************************
  1261. COMMAND
  1262.      file - write the current file to disk and remove from ring
  1263.  
  1264. SYNTAX
  1265.      FILE  [filename]
  1266.  
  1267. DESCRIPTION
  1268.      The FILE command writes the current file to disk to the current
  1269.      file name or to the supplied 'filename'.
  1270.      Unlike the <FFILE> command, if the optional 'filename' exists, this
  1271.      command will not overwrite the file.
  1272.  
  1273. COMPATIBILITY
  1274.      XEDIT: Compatible.
  1275.      KEDIT: Compatible.
  1276.  
  1277. DEFAULT
  1278.      With no parameters, the current file is written.
  1279.  
  1280. SEE ALSO
  1281.      <FFILE>, <SAVE>, <SSAVE>
  1282.  
  1283. STATUS
  1284.      Complete
  1285. **man-end**********************************************************************/
  1286. #ifdef HAVE_PROTO
  1287. short File(CHARTYPE *params)
  1288. #else
  1289. short File(params)
  1290. CHARTYPE *params;
  1291. #endif
  1292. /***********************************************************************/
  1293. {
  1294. /*-------------------------- external data ----------------------------*/
  1295. /*--------------------------- local data ------------------------------*/
  1296.  short rc=RC_OK;
  1297. /*--------------------------- processing ------------------------------*/
  1298. #ifdef TRACE
  1299.  trace_function("comm2.c:   File");
  1300. #endif
  1301.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1302. /*---------------------------------------------------------------------*/
  1303. /* If we are filing the current file with the same name AND the number */
  1304. /* of alterations is zero, then quit the file.                         */
  1305. /* Removed to be consistant with XEDIT/KEDIT.                          */
  1306. /*---------------------------------------------------------------------*/
  1307. /*
  1308.  if (CURRENT_FILE->save_alt == 0 && strcmp(params,"") == 0)
  1309.     Quit((CHARTYPE *)"");
  1310.  else
  1311. */
  1312.    {
  1313.     if ((rc = save_file(CURRENT_FILE,params,FALSE,CURRENT_FILE->number_lines,1L,NULL,FALSE,0,max_line_length,TRUE,FALSE)) != RC_OK)
  1314.       {
  1315. #ifdef TRACE
  1316.        trace_return();
  1317. #endif
  1318.        return(rc);
  1319.       }
  1320. /*---------------------------------------------------------------------*/
  1321. /* If autosave is on at the time of Filing, remove the .aus file...    */
  1322. /*---------------------------------------------------------------------*/
  1323.     if (CURRENT_FILE->autosave > 0)
  1324.        rc = remove_aus_file(CURRENT_FILE);
  1325.     free_view_memory(TRUE,TRUE);
  1326.    }
  1327. #ifdef TRACE
  1328.  trace_return();
  1329. #endif
  1330.  return(rc);
  1331. }
  1332. /*man-start*********************************************************************
  1333. COMMAND
  1334.      fillbox - fill the marked box block with a character
  1335.  
  1336. SYNTAX
  1337.      FILLbox [c]
  1338.  
  1339. DESCRIPTION
  1340.      The FILLBOX command fills the marked block with the specified
  1341.      character, 'c'. If no parameters are supplied and the command is run
  1342.      from the command line, then the box will be filled with spaces.
  1343.      If the command is not run from the command line, the user is
  1344.      prompted for a character to fill the box.
  1345.  
  1346. COMPATIBILITY
  1347.      XEDIT: N/A
  1348.      KEDIT: Compatible.
  1349.  
  1350. STATUS
  1351.      Complete
  1352. **man-end**********************************************************************/
  1353. #ifdef HAVE_PROTO
  1354. short Fillbox(CHARTYPE *params)
  1355. #else
  1356. short Fillbox(params)
  1357. CHARTYPE *params;
  1358. #endif
  1359. /***********************************************************************/
  1360. {
  1361. /*-------------------------- external data ----------------------------*/
  1362.  extern VIEW_DETAILS *vd_mark;
  1363. /*--------------------------- local data ------------------------------*/
  1364.  CHARTYPE chr=0;
  1365.  short len_params=0;
  1366.  short y=0,x=0;
  1367. /*--------------------------- processing ------------------------------*/
  1368. #ifdef TRACE
  1369.  trace_function("comm2.c:   Fillbox");
  1370. #endif
  1371.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1372. /*---------------------------------------------------------------------*/
  1373. /* Validate the marked block.                                          */
  1374. /*---------------------------------------------------------------------*/
  1375.  if (marked_block(TRUE) != RC_OK)
  1376.    {
  1377. #ifdef TRACE
  1378.     trace_return();
  1379. #endif
  1380.     return(RC_INVALID_ENVIRON);
  1381.    }
  1382. /*---------------------------------------------------------------------*/
  1383. /* This function not valid for line blocks.                            */
  1384. /*---------------------------------------------------------------------*/
  1385.  if (MARK_VIEW->mark_type == M_LINE)
  1386.    {
  1387.     display_error(47,(CHARTYPE *)"",FALSE);
  1388. #ifdef TRACE
  1389.     trace_return();
  1390. #endif
  1391.     return(RC_INVALID_ENVIRON);
  1392.    }
  1393. /*---------------------------------------------------------------------*/
  1394. /* Check if hex on in effect and translate hex char if required...     */
  1395. /*---------------------------------------------------------------------*/
  1396.  if (CURRENT_VIEW->hex)
  1397.    {
  1398.     if ((len_params = convert_hex_strings(params)) == (-1))
  1399.       {
  1400.        display_error(32,params,FALSE);
  1401. #ifdef TRACE
  1402.        trace_return();
  1403. #endif
  1404.        return(RC_INVALID_OPERAND);
  1405.       }
  1406.    }
  1407.  else
  1408.    len_params = strlen((DEFCHAR *)params);
  1409. /*---------------------------------------------------------------------*/
  1410. /* Whew, now do something...                                           */
  1411. /*---------------------------------------------------------------------*/
  1412.  if (len_params > 1)
  1413.    {
  1414.     display_error(1,params,FALSE);
  1415. #ifdef TRACE
  1416.     trace_return();
  1417. #endif
  1418.     return(RC_INVALID_OPERAND);
  1419.    }
  1420.  if (len_params == 0)
  1421.     chr = ' ';
  1422.  else
  1423.     chr = *(params);
  1424.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND
  1425.  && len_params != 1) 
  1426.    {
  1427.     getyx(CURRENT_WINDOW,y,x);
  1428.     display_prompt((CHARTYPE *)"Enter fill character...");
  1429.     wmove(CURRENT_WINDOW_FILEAREA,y,x);
  1430.     wrefresh(CURRENT_WINDOW_FILEAREA);
  1431.     chr = (CHARTYPE)my_getch(stdscr);
  1432.     clear_msgline();
  1433.    }
  1434.  box_operations(BOX_F,SOURCE_BLOCK,TRUE,chr);
  1435. #ifdef TRACE
  1436.  trace_return();
  1437. #endif
  1438.  return(RC_OK);
  1439. }
  1440. /*man-start*********************************************************************
  1441. COMMAND
  1442.      find - locate forwards the line which begins with the supplied string
  1443.  
  1444. SYNTAX
  1445.      Find string
  1446.  
  1447. DESCRIPTION
  1448.      The FIND command attempts to locate a line towards the end of
  1449.      the file that begins with 'string'.
  1450.  
  1451.      'string' can contain two special characters:
  1452.  
  1453.           space - this will match any single character in the target line
  1454.           underscore - this will match any single space in the target line
  1455.  
  1456. COMPATIBILITY
  1457.      XEDIT: Compatible.
  1458.      KEDIT: Compatible.
  1459.  
  1460. SEE ALSO
  1461.      <FINDUP>, <NFIND>, <NFINDUP>
  1462.  
  1463. STATUS
  1464.      Complete
  1465. **man-end**********************************************************************/
  1466. #ifdef HAVE_PROTO
  1467. short Find(CHARTYPE *params)
  1468. #else
  1469. short Find(params)
  1470. CHARTYPE *params;
  1471. #endif
  1472. /***********************************************************************/
  1473. {
  1474. /*-------------------------- external data ----------------------------*/
  1475. /*--------------------------- local data ------------------------------*/
  1476.  short rc=RC_OK;
  1477. /*--------------------------- processing ------------------------------*/
  1478. #ifdef TRACE
  1479.  trace_function("comm2.c:   Find");
  1480. #endif
  1481.  rc = execute_find_command(params,TARGET_FIND);
  1482. #ifdef TRACE
  1483.  trace_return();
  1484. #endif
  1485.  return(rc);
  1486. }
  1487. /*man-start*********************************************************************
  1488. COMMAND
  1489.      findup - locate backwards the line which begins with the supplied string
  1490.  
  1491. SYNTAX
  1492.      FINDUp string
  1493.      FUp string
  1494.  
  1495. DESCRIPTION
  1496.      The FINDUP command attempts to locate a line towards the start of
  1497.      the file that begins with 'string'.
  1498.  
  1499.      'string' can contain two special characters:
  1500.  
  1501.           space - this will match any single character in the target line
  1502.           underscore - this will match any single space in the target line
  1503.  
  1504. COMPATIBILITY
  1505.      XEDIT: Compatible.
  1506.      KEDIT: Compatible.
  1507.  
  1508. SEE ALSO
  1509.      <FIND>, <NFIND>, <NFINDUP>
  1510.  
  1511. STATUS
  1512.      Complete
  1513. **man-end**********************************************************************/
  1514. #ifdef HAVE_PROTO
  1515. short Findup(CHARTYPE *params)
  1516. #else
  1517. short Findup(params)
  1518. CHARTYPE *params;
  1519. #endif
  1520. /***********************************************************************/
  1521. {
  1522. /*-------------------------- external data ----------------------------*/
  1523. /*--------------------------- local data ------------------------------*/
  1524.  short rc=RC_OK;
  1525. /*--------------------------- processing ------------------------------*/
  1526. #ifdef TRACE
  1527.  trace_function("comm2.c:   Findup");
  1528. #endif
  1529.  rc = execute_find_command(params,TARGET_FINDUP);
  1530. #ifdef TRACE
  1531.  trace_return();
  1532. #endif
  1533.  return(rc);
  1534. }
  1535. /*man-start*********************************************************************
  1536. COMMAND
  1537.      forward - scroll forwards [n] screens
  1538.  
  1539. SYNTAX
  1540.      FOrward [n]
  1541.  
  1542. DESCRIPTION
  1543.      The FORWARD command scrolls the file contents forwards 'n' screens.
  1544.  
  1545.      If 0 is specified as the number of screens to scroll, the 
  1546.      <Top-of-File line> becomes the <current line>.
  1547.  
  1548.      If the FORWARD command is issued while the <current line> is the
  1549.      <Bottom-of-File line>, the <Top-of-File line> becomes the
  1550.      <current line>.
  1551.  
  1552. COMPATIBILITY
  1553.      XEDIT: Compatible.
  1554.      KEDIT: Does not support HALF or Lines options.
  1555.  
  1556. DEFAULT
  1557.      1
  1558.  
  1559. SEE ALSO
  1560.      <BACKWARD>, <TOP>
  1561.  
  1562. STATUS
  1563.      Complete
  1564. **man-end**********************************************************************/
  1565. #ifdef HAVE_PROTO
  1566. short Forward(CHARTYPE *params)
  1567. #else
  1568. short Forward(params)
  1569. CHARTYPE *params;
  1570. #endif
  1571. /***********************************************************************/
  1572. {
  1573. /*-------------------------- external data ----------------------------*/
  1574. /*--------------------------- local data ------------------------------*/
  1575. #define FOR_PARAMS  1
  1576.  CHARTYPE *word[FOR_PARAMS+1];
  1577.  CHARTYPE strip[FOR_PARAMS];
  1578.  unsigned short num_params=0;
  1579.  LINETYPE num_pages=0L;
  1580.  short rc=RC_OK;
  1581. /*--------------------------- processing ------------------------------*/
  1582. #ifdef TRACE
  1583.  trace_function("comm2.c:   Forward");
  1584. #endif
  1585. /*---------------------------------------------------------------------*/
  1586. /* Validate parameters...                                              */
  1587. /*---------------------------------------------------------------------*/
  1588.  strip[0]=STRIP_BOTH;
  1589.  num_params = param_split(params,word,FOR_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  1590.  if (num_params == 0)
  1591.     {
  1592.      num_params = 1;
  1593.      word[0] = (CHARTYPE *)"1";
  1594.     }
  1595.  if (num_params != 1)
  1596.     {
  1597.      display_error(1,(CHARTYPE *)word[1],FALSE);
  1598. #ifdef TRACE
  1599.     trace_return();
  1600. #endif
  1601.      return(RC_INVALID_OPERAND);
  1602.     }
  1603. /*---------------------------------------------------------------------*/
  1604. /* If parameter is '*', set current line equal to last line in file... */
  1605. /*---------------------------------------------------------------------*/
  1606.  if (strcmp((DEFCHAR *)word[0],"*") == 0)
  1607.    {
  1608.     rc = Bottom((CHARTYPE *)"");
  1609. #ifdef TRACE
  1610.     trace_return();
  1611. #endif
  1612.     return(rc);
  1613.    }
  1614. /*---------------------------------------------------------------------*/
  1615. /* If the parameter is not a valid integer, error.                     */
  1616. /*---------------------------------------------------------------------*/
  1617.  if (!valid_integer(word[0]))
  1618.    {
  1619.     display_error(1,(CHARTYPE *)word[0],FALSE);
  1620. #ifdef TRACE
  1621.     trace_return();
  1622. #endif
  1623.     return(RC_INVALID_OPERAND);
  1624.    }
  1625. /*---------------------------------------------------------------------*/
  1626. /* Number of screens to scroll is set here.                            */
  1627. /*---------------------------------------------------------------------*/
  1628.  num_pages = atol((DEFCHAR *)word[0]);
  1629. /*---------------------------------------------------------------------*/
  1630. /* If the number specified is < 0, error...                            */
  1631. /*---------------------------------------------------------------------*/
  1632.  if (num_pages < 0L)
  1633.    {
  1634.     display_error(5,(CHARTYPE *)word[0],FALSE);
  1635. #ifdef TRACE
  1636.     trace_return();
  1637. #endif
  1638.     return(RC_INVALID_OPERAND);
  1639.    }
  1640. /*---------------------------------------------------------------------*/
  1641. /* If the current line is already on "Bottom of File" or the parameter */
  1642. /* is 0, go to the top of the file.                                    */
  1643. /*---------------------------------------------------------------------*/
  1644.  if (num_pages == 0
  1645.  || CURRENT_BOF)
  1646.    {
  1647.     rc = Top((CHARTYPE *)"");
  1648. #ifdef TRACE
  1649.     trace_return();
  1650. #endif
  1651.     return(rc);
  1652.    }
  1653. /*---------------------------------------------------------------------*/
  1654. /* Scroll the screen num_pages...                                      */
  1655. /*---------------------------------------------------------------------*/
  1656.  rc = scroll_page(DIRECTION_FORWARD,num_pages,FALSE);
  1657. #ifdef TRACE
  1658.  trace_return();
  1659. #endif
  1660.  return(rc);
  1661. }
  1662. /*man-start*********************************************************************
  1663. COMMAND
  1664.      get - insert into file the contents of specified file
  1665.  
  1666. SYNTAX
  1667.      GET [filename] [fromline] [numlines]
  1668.  
  1669. DESCRIPTION
  1670.      The GET command reads a file into the current file, inserting
  1671.      lines after the current line.
  1672.  
  1673.      When no 'filename' is supplied the temporary file generated by the
  1674.      last <PUT> or <PUTD> command is used.
  1675.  
  1676.      When 'fromline' is specified, reading of the file begins at the
  1677.      line number specified.
  1678.      If 'fromline' is not specifed, reading begins at line 1.
  1679.  
  1680.      When 'numlines' is specified, reading of the file ends when the
  1681.      specified number of lines has been read.
  1682.      If 'numlines' is not specified, or 'numlines' is specified as '*',
  1683.      all files from the 'fromline' to the end of file are read.
  1684.  
  1685. COMPATIBILITY
  1686.      XEDIT: Compatible.
  1687.      KEDIT: Compatible.
  1688.  
  1689. SEE ALSO
  1690.      <PUT>, <PUTD>
  1691.  
  1692. STATUS
  1693.      Complete
  1694. **man-end**********************************************************************/
  1695. #ifdef HAVE_PROTO
  1696. short Get(CHARTYPE *params)
  1697. #else
  1698. short Get(params)
  1699. CHARTYPE *params;
  1700. #endif
  1701. /***********************************************************************/
  1702. {
  1703. /*-------------------------- external data ----------------------------*/
  1704.  extern CHARTYPE *tempfilename;
  1705.  extern CHARTYPE *temp_cmd;
  1706.  extern CHARTYPE sp_path[MAX_FILE_NAME+1] ;
  1707.  extern CHARTYPE sp_fname[MAX_FILE_NAME+1] ;
  1708. /*--------------------------- local data ------------------------------*/
  1709. #define GET_PARAMS  3
  1710.  CHARTYPE *word[GET_PARAMS+1];
  1711.  CHARTYPE strip[GET_PARAMS];
  1712.  unsigned short num_params=0;
  1713.  CHARTYPE *filename=NULL;
  1714.  FILE *fp=NULL;
  1715.  LINE *curr=NULL;
  1716.  LINE *save_curr=NULL;
  1717.  LINE *save_next=NULL;
  1718.  LINETYPE old_number_lines=0L,true_line=0L;
  1719.  short rc=RC_OK;
  1720.  LINETYPE fromline=1L,numlines=0L;
  1721. /*--------------------------- processing ------------------------------*/
  1722. #ifdef TRACE
  1723.  trace_function("comm2.c:   Get");
  1724. #endif
  1725. /*---------------------------------------------------------------------*/
  1726. /* Validate the parameters that have been supplied.                    */
  1727. /*---------------------------------------------------------------------*/
  1728.  strip[0]=STRIP_BOTH;
  1729.  strip[1]=STRIP_BOTH;
  1730.  strip[2]=STRIP_BOTH;
  1731.  num_params = param_split(params,word,GET_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  1732.  if (num_params > 3)
  1733.    {
  1734.     display_error(2,(CHARTYPE *)"",FALSE);
  1735. #ifdef TRACE
  1736.     trace_return();
  1737. #endif
  1738.     return(RC_INVALID_ENVIRON);
  1739.    }
  1740.  if (num_params == 0)
  1741.     filename = tempfilename;
  1742.  else
  1743.    {
  1744.     if ((rc = splitpath(strrmdup(strtrans(word[0],OSLASH,ISLASH),ISLASH))) != RC_OK)
  1745.       {
  1746.        display_error(10,word[0],FALSE);
  1747. #ifdef TRACE
  1748.        trace_return();
  1749. #endif
  1750.        return(rc);
  1751.       }
  1752.     strcpy((DEFCHAR *)temp_cmd,(DEFCHAR *)sp_path);
  1753.     strcat((DEFCHAR *)temp_cmd,(DEFCHAR *)sp_fname);
  1754.     filename = temp_cmd;
  1755.     if (num_params == 2
  1756.     ||  num_params == 3)
  1757.       {
  1758.        if (!valid_positive_integer(word[1]))
  1759.          {
  1760.           display_error(4,word[1],FALSE);
  1761. #ifdef TRACE
  1762.           trace_return();
  1763. #endif
  1764.           return(RC_INVALID_OPERAND);
  1765.          }
  1766.        fromline = atol((DEFCHAR *)word[1]);
  1767.        if (fromline == 0L)
  1768.          {
  1769.           display_error(4,word[1],FALSE);
  1770. #ifdef TRACE
  1771.           trace_return();
  1772. #endif
  1773.           return(RC_INVALID_OPERAND);
  1774.          }
  1775.       }
  1776.     if (num_params == 3)
  1777.       {
  1778.        if (strcmp((DEFCHAR *)word[2],"*") == 0)
  1779.           numlines = 0L;
  1780.        else
  1781.          {
  1782.           if (!valid_positive_integer(word[2]))
  1783.             {
  1784.              display_error(4,word[2],FALSE);
  1785. #ifdef TRACE
  1786.              trace_return();
  1787. #endif
  1788.              return(RC_INVALID_OPERAND);
  1789.             }
  1790.           else
  1791.              numlines = atol((DEFCHAR *)word[2]);
  1792.          }
  1793.       }
  1794.    }
  1795.  
  1796.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1797.  
  1798.  if (!file_readable(filename))
  1799.    {
  1800.     display_error(8,filename,FALSE);
  1801. #ifdef TRACE
  1802.     trace_return();
  1803. #endif
  1804.     return(RC_ACCESS_DENIED);
  1805.    }
  1806.  
  1807.  if ((fp = fopen((DEFCHAR *)filename,"r")) == NULL)
  1808.    {
  1809.     display_error(9,params,FALSE);
  1810. #ifdef TRACE
  1811.     trace_return();
  1812. #endif
  1813.     return(RC_ACCESS_DENIED);
  1814.    }
  1815.  true_line = get_true_line(TRUE);
  1816.  curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,true_line,CURRENT_FILE->number_lines);
  1817.  if (curr->next == NULL)   /* on bottom of file */
  1818.     curr = curr->prev;
  1819.  old_number_lines = CURRENT_FILE->number_lines;
  1820.  save_curr = curr;
  1821.  save_next = curr->next;
  1822.  if ((curr = read_file(fp,curr,filename,fromline,numlines,TRUE)) == NULL)
  1823.    {
  1824.     for (curr=save_curr;curr!=save_next;)
  1825.       {
  1826.        if (curr != save_curr)
  1827.           curr = lll_del(&CURRENT_FILE->first_line,&CURRENT_FILE->last_line,curr,DIRECTION_FORWARD);
  1828.        else
  1829.           curr = curr->next;
  1830.       }
  1831.     pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1832.     fclose(fp);
  1833. #ifdef TRACE
  1834.     trace_return();
  1835. #endif
  1836.     return(RC_ACCESS_DENIED);
  1837.    }
  1838.  
  1839.  fclose(fp);
  1840.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1841. /*---------------------------------------------------------------------*/
  1842. /* Fix the positioning of the marked block (if there is one and it is  */
  1843. /* in the current view).                                               */
  1844. /*---------------------------------------------------------------------*/
  1845.  adjust_marked_lines(TRUE,true_line,CURRENT_FILE->number_lines - old_number_lines);
  1846.  adjust_pending_prefix(CURRENT_VIEW,TRUE,true_line,CURRENT_FILE->number_lines - old_number_lines);
  1847. /*---------------------------------------------------------------------*/
  1848. /* Increment the number of lines counter for the current file and the  */
  1849. /* number of alterations.                                              */
  1850. /*---------------------------------------------------------------------*/
  1851.  increment_alt(CURRENT_FILE);
  1852.  
  1853.  build_screen(current_screen); 
  1854.  display_screen(current_screen);
  1855. #ifdef TRACE
  1856.  trace_return();
  1857. #endif
  1858.  return(RC_OK);
  1859. }
  1860. /*man-start*********************************************************************
  1861. COMMAND
  1862.      help - edit help file for THE
  1863.  
  1864. SYNTAX
  1865.      HELP
  1866.  
  1867. DESCRIPTION
  1868.      The HELP command displays help for the editor.
  1869.      Uses THE_HELP_FILE environment variable to point to the help file.
  1870.      See Appendix 1 for details on this and other environemnt variables.
  1871.  
  1872. COMPATIBILITY
  1873.      XEDIT: Similar in concept.
  1874.      KEDIT: Similar in concept.
  1875.  
  1876. STATUS
  1877.      Complete.
  1878. **man-end**********************************************************************/
  1879. #ifdef HAVE_PROTO
  1880. short Help(CHARTYPE *params)
  1881. #else
  1882. short Help(params)
  1883. CHARTYPE *params;
  1884. #endif
  1885. /***********************************************************************/
  1886. {
  1887. /*------------------------- external data -----------------------------*/
  1888.  extern CHARTYPE the_help_file[MAX_FILE_NAME+1];
  1889. /*--------------------------- local data ------------------------------*/
  1890. /*--------------------------- processing ------------------------------*/
  1891. #ifdef TRACE
  1892.  trace_function("comm2.c:   Help");
  1893. #endif
  1894. /*---------------------------------------------------------------------*/
  1895. /* No arguments are allowed; error if any are present.                 */
  1896. /*---------------------------------------------------------------------*/
  1897.  if (strcmp((DEFCHAR *)params,"") != 0)
  1898.    {
  1899.     display_error(1,(CHARTYPE *)params,FALSE);
  1900. #ifdef TRACE
  1901.     trace_return();
  1902. #endif
  1903.     return(RC_INVALID_OPERAND);
  1904.    }
  1905.  if (!file_exists(the_help_file))
  1906.    {
  1907.     display_error(23,(CHARTYPE *)the_help_file,FALSE);
  1908. #ifdef TRACE
  1909.     trace_return();
  1910. #endif
  1911.     return(RC_FILE_NOT_FOUND);
  1912.    }
  1913.  Xedit(the_help_file);
  1914. #ifdef TRACE
  1915.  trace_return();
  1916. #endif
  1917.  return(RC_OK);
  1918. }
  1919. /*man-start*********************************************************************
  1920. COMMAND
  1921.      hit - simulate hitting of the named key
  1922.  
  1923. SYNTAX
  1924.      HIT key
  1925.  
  1926. DESCRIPTION
  1927.      The HIT command enables the simulation of hitting the named 'key'.
  1928.      This is most useful from within a macro.
  1929.  
  1930.      Be very careful when using the HIT command with the <DEFINE> command.
  1931.      If you assign the HIT command to a key, DO NOT use the same key
  1932.      name. eg. DEFINE F1 HIT F1
  1933.      This will result in an infinite processing loop.
  1934.  
  1935. COMPATIBILITY
  1936.      XEDIT: N/A
  1937.      KEDIT: Similar, but more like the <MACRO> command.
  1938.  
  1939. STATUS
  1940.      Complete.
  1941. **man-end**********************************************************************/
  1942. #ifdef HAVE_PROTO
  1943. short Hit(CHARTYPE *params)
  1944. #else
  1945. short Hit(params)
  1946. CHARTYPE *params;
  1947. #endif
  1948. /***********************************************************************/
  1949. {
  1950. /*------------------------- external data -----------------------------*/
  1951.  extern bool in_macro;
  1952.  extern CHARTYPE number_of_files;
  1953. /*--------------------------- local data ------------------------------*/
  1954.  int key=0;
  1955.  short rc=RC_OK;
  1956.  bool save_in_macro=in_macro;
  1957. /*--------------------------- processing ------------------------------*/
  1958. #ifdef TRACE
  1959.  trace_function("comm2.c:   Hit");
  1960. #endif
  1961. /*---------------------------------------------------------------------*/
  1962. /* Only argument is the name of a valid key.                           */
  1963. /*---------------------------------------------------------------------*/
  1964.  key = find_key_name(params);
  1965.  if (key == (-1))
  1966.    {
  1967.     display_error(13,params,FALSE);
  1968. #ifdef TRACE
  1969.     trace_return();
  1970. #endif
  1971.     return(RC_INVALID_OPERAND);
  1972.    }
  1973.  in_macro = FALSE;
  1974.  rc = process_key(key);
  1975.  in_macro = save_in_macro;
  1976.  if (number_of_files == 0)
  1977.     rc = RC_INVALID_ENVIRON;
  1978.  /* how to exit ???? */
  1979. #ifdef TRACE
  1980.  trace_return();
  1981. #endif
  1982.  return(rc);
  1983. }
  1984. /*man-start*********************************************************************
  1985. COMMAND
  1986.      input - insert the command line contents into the file
  1987.  
  1988. SYNTAX
  1989.      Input [string]
  1990.  
  1991. DESCRIPTION
  1992.      The INPUT command inserts the 'string' specified on the <command line>
  1993.      into the current file after the <current line>.
  1994.  
  1995.      If <SET INPUTMODE> FULL is in effect, and the INPUT command is
  1996.      entered on the command line with no arguments, THE is put into
  1997.      full input mode.  If the <prefix area> is on, it is turned off,
  1998.      the cursor moved to the <filearea> and blank lines inserted
  1999.      into the file from the <current line> to the end of the screen.
  2000.  
  2001.      To get out of full input mode, press the key assigned to the 
  2002.      <CURSOR> HOME [SAVE] command.
  2003.  
  2004. COMPATIBILITY
  2005.      XEDIT: Does not provide full input mode option.
  2006.      KEDIT: Does not provide full input mode option.
  2007.  
  2008. STATUS
  2009.      Complete. Except for full input mode capability.
  2010. **man-end**********************************************************************/
  2011. #ifdef HAVE_PROTO
  2012. short Input(CHARTYPE *params)
  2013. #else
  2014. short Input(params)
  2015. CHARTYPE *params;
  2016. #endif
  2017. /***********************************************************************/
  2018. {
  2019. /*-------------------------- external data ----------------------------*/
  2020. /*--------------------------- local data ------------------------------*/
  2021.  LINETYPE len_params=0;
  2022. /*--------------------------- processing ------------------------------*/
  2023. #ifdef TRACE
  2024.  trace_function("comm2.c:   Input");
  2025. #endif
  2026.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  2027.  if (CURRENT_VIEW->hex)
  2028.    {
  2029.     if ((len_params = (LINETYPE)convert_hex_strings(params)) == (-1))
  2030.       {
  2031.        display_error(32,params,FALSE);
  2032. #ifdef TRACE
  2033.        trace_return();
  2034. #endif
  2035.        return(RC_INVALID_OPERAND);
  2036.       }
  2037.    }
  2038.  else
  2039.    len_params = (LINETYPE)strlen((DEFCHAR *)params);
  2040.  if (len_params > (LINETYPE)max_line_length)
  2041.    {
  2042.     display_error(0,(CHARTYPE *)"Truncated",FALSE);
  2043.     len_params = (LINETYPE)max_line_length;
  2044.    }
  2045.  insert_new_line(params,(unsigned short)len_params,1L,get_true_line(TRUE),TRUE,TRUE,TRUE,CURRENT_VIEW->display_low,TRUE,FALSE);
  2046. #ifdef TRACE
  2047.  trace_return();
  2048. #endif
  2049.  return(RC_OK);
  2050. }
  2051. /*man-start*********************************************************************
  2052. COMMAND
  2053.      join - join a line with the line following
  2054.  
  2055. SYNTAX
  2056.      Join [ALigned] [Column|CURSOR]
  2057.  
  2058. DESCRIPTION
  2059.      The JOIN command makes one line out of the focus line and the
  2060.      line following.
  2061.  
  2062.      If 'Aligned' is specified, any leading spaces in the following line
  2063.      are ignored. If 'Aligned' is not specified, all characters, including
  2064.      spaces are added.
  2065.  
  2066.      If 'Column' (the default) is specified, the current line is joined
  2067.      at the current column location.
  2068.  
  2069.      If 'CURSOR' is specified, the focus line is joined at the cursor
  2070.      position.
  2071.  
  2072. COMPATIBILITY
  2073.      XEDIT: Compatible.
  2074.             Does not support Colno option
  2075.      KEDIT: Compatible.
  2076.  
  2077. SEE ALSO
  2078.      <SPLIT>, <SPLTJOIN>
  2079.  
  2080. STATUS
  2081.      Complete.
  2082. **man-end**********************************************************************/
  2083. #ifdef HAVE_PROTO
  2084. short Join(CHARTYPE *params)
  2085. #else
  2086. short Join(params)
  2087. CHARTYPE *params;
  2088. #endif
  2089. /***********************************************************************/
  2090. {
  2091. /*-------------------------- external data ----------------------------*/
  2092.  extern bool curses_started;
  2093. /*--------------------------- local data ------------------------------*/
  2094. #define JOI_PARAMS  2
  2095.  CHARTYPE *word[JOI_PARAMS+1];
  2096.  CHARTYPE strip[JOI_PARAMS];
  2097.  unsigned short num_params=0;
  2098.  short rc=RC_OK;
  2099.  bool aligned=FALSE;
  2100.  bool cursorarg=FALSE;
  2101. /*--------------------------- processing ------------------------------*/
  2102. #ifdef TRACE
  2103.  trace_function("comm2.c:   Join");
  2104. #endif
  2105. /*---------------------------------------------------------------------*/
  2106. /* Split parameters up...                                              */
  2107. /*---------------------------------------------------------------------*/
  2108.  strip[0]=STRIP_BOTH;
  2109.  strip[1]=STRIP_BOTH;
  2110.  num_params = param_split(params,word,JOI_PARAMS,WORD_DELIMS,TEMP_PARAM,strip,FALSE);
  2111.  if (num_params == 0)
  2112.    {
  2113.     aligned = FALSE;
  2114.     cursorarg = FALSE;
  2115.    }
  2116.  else
  2117.    {
  2118.     if (equal((CHARTYPE *)"aligned",word[0],2))
  2119.       {
  2120.        aligned = TRUE;
  2121.        if (equal((CHARTYPE *)"cursor",word[1],6))
  2122.          {
  2123.           cursorarg = TRUE;
  2124.          }
  2125.        else
  2126.          {
  2127.           if (equal((CHARTYPE *)"column",word[1],1))
  2128.             {
  2129.              cursorarg = FALSE;
  2130.             }
  2131.           else
  2132.             {
  2133.              display_error(1,(CHARTYPE *)word[1],FALSE);
  2134. #ifdef TRACE
  2135.              trace_return();
  2136. #endif
  2137.              return(RC_INVALID_ENVIRON);
  2138.             }
  2139.          }
  2140.       }
  2141.     else
  2142.       {
  2143.        if (equal((CHARTYPE *)"cursor",word[0],6))
  2144.          {
  2145.           aligned = FALSE;
  2146.           cursorarg = TRUE;
  2147.          }
  2148.        else
  2149.          {
  2150.           if (equal((CHARTYPE *)"column",word[0],1))
  2151.             {
  2152.              aligned = FALSE;
  2153.              cursorarg = FALSE;
  2154.             }
  2155.           else
  2156.             {
  2157.              display_error(1,(CHARTYPE *)word[0],FALSE);
  2158. #ifdef TRACE
  2159.              trace_return();
  2160. #endif
  2161.              return(RC_INVALID_ENVIRON);
  2162.             }
  2163.          }
  2164.       }
  2165.    }
  2166.  rc = execute_split_join(SPLTJOIN_JOIN,aligned,cursorarg);
  2167. #ifdef TRACE
  2168.  trace_return();
  2169. #endif
  2170.  return(rc);
  2171. }
  2172.