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

  1. /***********************************************************************/
  2. /* COMMSOS.C - sos commands.                                           */
  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: commsos.c 2.1 1995/06/24 16:29:14 MH Rel MH $
  43. */
  44.  
  45. #include <the.h>
  46. #include <proto.h>
  47.  
  48. /*#define DEBUG 1*/
  49.  
  50. /*man-start*********************************************************************
  51.  
  52.  
  53. ========================================================================
  54. SOS COMMAND REFERENCE
  55. ========================================================================
  56. **man-end**********************************************************************/
  57.  
  58. /*man-start*********************************************************************
  59. COMMAND
  60.      sos addline - add blank line after focus line
  61.  
  62. SYNTAX
  63.      SOS ADDline
  64.  
  65. DESCRIPTION
  66.      The SOS ADDLINE command inserts a blank line in the file following
  67.      the focus line. The cursor is placed in the column under the first
  68.      non-blank in the focus line.
  69.  
  70. COMPATIBILITY
  71.      XEDIT: Compatible.
  72.      KEDIT: Compatible.
  73.  
  74. SEE ALSO
  75.      <SOS LINEADD>, <SOS DELLINE>
  76.  
  77. STATUS
  78.      Complete
  79. **man-end**********************************************************************/
  80. #ifdef HAVE_PROTO
  81. short Sos_addline(CHARTYPE *params)
  82. #else
  83. short Sos_addline(params)
  84. CHARTYPE *params;
  85. #endif
  86. /***********************************************************************/
  87. {
  88. /*-------------------------- external data ----------------------------*/
  89.  extern bool curses_started;
  90.  extern short compatible_feel;
  91. /*--------------------------- local data ------------------------------*/
  92.  short rc=RC_OK;
  93. /*--------------------------- processing ------------------------------*/
  94. #ifdef TRACE
  95.  trace_function("commsos.c: Sos_addline");
  96. #endif
  97.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  98.  insert_new_line((CHARTYPE *)"",0,1,get_true_line(FALSE),FALSE,FALSE,TRUE,CURRENT_VIEW->display_low,TRUE,TRUE);
  99.  if (compatible_feel == COMPAT_XEDIT)
  100.     advance_current_line(1L);
  101.  if (curses_started
  102.  && CURRENT_VIEW->current_window == WINDOW_COMMAND)
  103.    {
  104.     cursor_home(FALSE);
  105.     rc = Sos_firstcol((CHARTYPE *)"");
  106.    }
  107. #ifdef TRACE
  108.  trace_return();
  109. #endif
  110.  return(rc);
  111. }
  112. /*man-start*********************************************************************
  113. COMMAND
  114.      sos blockend - move cursor to end of marked block
  115.  
  116. SYNTAX
  117.      SOS BLOCKEnd
  118.  
  119. DESCRIPTION
  120.      The SOS BLOCKEND command moves the cursor to the ending line
  121.      and column of the marked block.  If the cursor is on the command 
  122.      line, the last line of the marked block becomes the current line.
  123.  
  124.      If no marked block is in the current file, an error is displayed.
  125.  
  126. COMPATIBILITY
  127.      XEDIT: N/A
  128.      KEDIT: Compatible.
  129.  
  130. SEE ALSO
  131.      <SOS BLOCKSTART>
  132.  
  133. STATUS
  134.      Complete.
  135. **man-end**********************************************************************/
  136. #ifdef HAVE_PROTO
  137. short Sos_blockend(CHARTYPE *params)
  138. #else
  139. short Sos_blockend(params)
  140. CHARTYPE *params;
  141. #endif
  142. /***********************************************************************/
  143. {
  144. /*-------------------------- external data ----------------------------*/
  145.  extern short compatible_feel;
  146.  extern VIEW_DETAILS *vd_mark;
  147. /*--------------------------- local data ------------------------------*/
  148.  unsigned short x=0,y=0;
  149.  short rc=RC_OK;
  150.  LINE *curr=NULL;
  151.  LENGTHTYPE col=0;
  152.  LINETYPE line=0L;
  153.  short save_compat=0;
  154.  CHARTYPE cmd[20];
  155. /*--------------------------- processing ------------------------------*/
  156. #ifdef TRACE
  157.  trace_function("commsos.c: Sos_blockend");
  158. #endif
  159.  if (MARK_VIEW != CURRENT_VIEW)
  160.    {
  161.     display_error(45,(CHARTYPE *)"",FALSE);
  162. #ifdef TRACE
  163.     trace_return();
  164. #endif
  165.     return(RC_INVALID_ENVIRON);
  166.    }
  167.  switch(MARK_VIEW->mark_type)
  168.    {
  169.     case M_COLUMN:
  170.          col = MARK_VIEW->mark_end_col;
  171.          line = CURRENT_FILE->number_lines;
  172.          break;
  173.     case M_LINE:
  174.          line = MARK_VIEW->mark_end_line;
  175.          break;
  176.     default:
  177.          col = MARK_VIEW->mark_end_col;
  178.          line = MARK_VIEW->mark_end_line;
  179.          break;
  180.    }
  181.  /* work out if block boundary is not excluded */
  182.  curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,line,CURRENT_FILE->number_lines);
  183.  if (!in_scope(CURRENT_VIEW,curr))
  184.    {
  185.     display_error(46,(CHARTYPE *)"",FALSE);
  186. #ifdef TRACE
  187.     trace_return();
  188. #endif
  189.     return(RC_INVALID_ENVIRON);
  190.    }
  191.  if (CURRENT_VIEW->current_window == WINDOW_PREFIX)
  192.     Sos_leftedge((CHARTYPE *)"");
  193.  getyx(CURRENT_WINDOW,y,x);
  194.  /*
  195.   * Move to the line
  196.   */
  197.  save_compat = compatible_feel;
  198.  compatible_feel = COMPAT_THE;
  199.  sprintf((DEFCHAR*)cmd,":%d",line);
  200.  rc = command_line(cmd,COMMAND_ONLY_FALSE);
  201.  compatible_feel = save_compat;;
  202.  /*
  203.   * Move to the column, except if the block is a LINE block or
  204.   * we are on command line.
  205.   */
  206.  if (MARK_VIEW->mark_type != M_LINE
  207.  &&  CURRENT_VIEW->current_window != WINDOW_COMMAND)
  208.     execute_move_cursor(col-1);
  209. #ifdef TRACE
  210.  trace_return();
  211. #endif
  212.  return(rc);
  213. }
  214. /*man-start*********************************************************************
  215. COMMAND
  216.      sos blockstart - move cursor to start of marked block
  217.  
  218. SYNTAX
  219.      SOS BLOCKStart
  220.  
  221. DESCRIPTION
  222.      The SOS BLOCKSTART command moves the cursor to the starting line
  223.      and column of the marked block.  If the cursor is on the command 
  224.      line, the first line of the marked block becomes the current line.
  225.  
  226.      If no marked block is in the current file, an error is displayed.
  227.  
  228. COMPATIBILITY
  229.      XEDIT: N/A
  230.      KEDIT: Compatible.
  231.  
  232. SEE ALSO
  233.      <SOS BLOCKEND>
  234.  
  235. STATUS
  236.      Complete.
  237. **man-end**********************************************************************/
  238. #ifdef HAVE_PROTO
  239. short Sos_blockstart(CHARTYPE *params)
  240. #else
  241. short Sos_blockstart(params)
  242. CHARTYPE *params;
  243. #endif
  244. /***********************************************************************/
  245. {
  246. /*-------------------------- external data ----------------------------*/
  247.  extern short compatible_feel;
  248.  extern VIEW_DETAILS *vd_mark;
  249. /*--------------------------- local data ------------------------------*/
  250.  unsigned short x=0,y=0;
  251.  short rc=RC_OK;
  252.  LINE *curr=NULL;
  253.  LENGTHTYPE col=0;
  254.  LINETYPE line=0L;
  255.  short save_compat=0;
  256.  CHARTYPE cmd[20];
  257. /*--------------------------- processing ------------------------------*/
  258. #ifdef TRACE
  259.  trace_function("commsos.c: Sos_blockstart");
  260. #endif
  261.  if (MARK_VIEW != CURRENT_VIEW)
  262.    {
  263.     display_error(45,(CHARTYPE *)"",FALSE);
  264. #ifdef TRACE
  265.     trace_return();
  266. #endif
  267.     return(RC_INVALID_ENVIRON);
  268.    }
  269.  switch(MARK_VIEW->mark_type)
  270.    {
  271.     case M_COLUMN:
  272.          col = MARK_VIEW->mark_start_col;
  273.          line = 1;
  274.          break;
  275.     case M_LINE:
  276.          line = MARK_VIEW->mark_start_line;
  277.          break;
  278.     default:
  279.          col = MARK_VIEW->mark_start_col;
  280.          line = MARK_VIEW->mark_start_line;
  281.          break;
  282.    }
  283.  /* work out if block boundary is not excluded */
  284.  curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,line,CURRENT_FILE->number_lines);
  285.  if (!in_scope(CURRENT_VIEW,curr))
  286.    {
  287.     display_error(46,(CHARTYPE *)"",FALSE);
  288. #ifdef TRACE
  289.     trace_return();
  290. #endif
  291.     return(RC_INVALID_ENVIRON);
  292.    }
  293.  if (CURRENT_VIEW->current_window == WINDOW_PREFIX)
  294.     Sos_leftedge((CHARTYPE *)"");
  295.  getyx(CURRENT_WINDOW,y,x);
  296.  /*
  297.   * Move to the line first
  298.   */
  299.  save_compat = compatible_feel;
  300.  compatible_feel = COMPAT_THE;
  301.  sprintf((DEFCHAR*)cmd,":%d",line);
  302.  rc = command_line(cmd,COMMAND_ONLY_FALSE);
  303.  compatible_feel = save_compat;;
  304.  /*
  305.   * Move to the column, except if the block is a LINE block or
  306.   * we are on command line.
  307.   */
  308.  if (MARK_VIEW->mark_type != M_LINE
  309.  &&  CURRENT_VIEW->current_window != WINDOW_COMMAND)
  310.     execute_move_cursor(col-1);
  311. #ifdef TRACE
  312.  trace_return();
  313. #endif
  314.  return(rc);
  315. }
  316. /*man-start*********************************************************************
  317. COMMAND
  318.      sos bottomedge - move cursor to bottom edge of FILEAREA
  319.  
  320. SYNTAX
  321.      SOS BOTTOMEdge
  322.  
  323. DESCRIPTION
  324.      The SOS BOTTOMEDGE command moves the cursor to the last 
  325.      enterable line in the <filearea> or <prefix> area. If the cursor
  326.      is on the command line, the cursor moves to the first 
  327.      enterable line of the <filearea>.
  328.  
  329. COMPATIBILITY
  330.      XEDIT: N/A
  331.      KEDIT: Comaptible.
  332.  
  333. SEE ALSO
  334.      <SOS TOPEDGE>
  335.  
  336. STATUS
  337.      Complete.
  338. **man-end**********************************************************************/
  339. #ifdef HAVE_PROTO
  340. short Sos_bottomedge(CHARTYPE *params)
  341. #else
  342. short Sos_bottomedge(params)
  343. CHARTYPE *params;
  344. #endif
  345. /***********************************************************************/
  346. {
  347. /*-------------------------- external data ----------------------------*/
  348. /*--------------------------- local data ------------------------------*/
  349.  short rc=RC_OK;
  350.  unsigned short y=0,x=0,row=0;
  351. /*--------------------------- processing ------------------------------*/
  352. #ifdef TRACE
  353.  trace_function("commsos.c: Sos_bottomedge");
  354. #endif
  355.  getyx(CURRENT_WINDOW,y,x);
  356. /*---------------------------------------------------------------------*/
  357. /* Get the last enterable row. If an error, stay where we are...       */
  358. /*---------------------------------------------------------------------*/
  359.  if (find_last_focus_line(&row) != RC_OK)
  360.    {
  361. #ifdef TRACE
  362.     trace_return();
  363. #endif
  364.     return(rc);
  365.    }
  366. /*---------------------------------------------------------------------*/
  367. /* For each window determine what needs to be done...                  */
  368. /*---------------------------------------------------------------------*/
  369.  switch(CURRENT_VIEW->current_window)
  370.    {
  371.     case WINDOW_COMMAND:
  372.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) != PREFIX_LEFT)
  373.             x += CURRENT_VIEW->prefix_width;
  374.          CURRENT_VIEW->focus_line = CURRENT_SCREEN.sl[row].line_number;
  375.          pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  376.          CURRENT_VIEW->current_window = WINDOW_FILEAREA;
  377.          wmove(CURRENT_WINDOW,row,x);
  378.          break;
  379.     case WINDOW_FILEAREA:
  380.     case WINDOW_PREFIX:
  381.             if (row != y)                            /* different rows */
  382.               {
  383.                post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  384.                CURRENT_VIEW->focus_line = CURRENT_SCREEN.sl[row].line_number;
  385.                pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  386.                wmove(CURRENT_WINDOW,row,x);
  387.               }
  388.             break;
  389.    }
  390. #ifdef TRACE
  391.  trace_return();
  392. #endif
  393.  return(rc);
  394. }
  395. /*man-start*********************************************************************
  396. COMMAND
  397.      sos current - move cursor to current line
  398.  
  399. SYNTAX
  400.      SOS CURRent
  401.  
  402. DESCRIPTION
  403.      The SOS CURRENT command moves the cursor to the current column
  404.      of the cursor line from any window.
  405.  
  406. COMPATIBILITY
  407.      XEDIT: N/A
  408.      KEDIT: Compatible.
  409.  
  410. STATUS
  411.      Complete
  412. **man-end**********************************************************************/
  413. #ifdef HAVE_PROTO
  414. short Sos_current(CHARTYPE *params)
  415. #else
  416. short Sos_current(params)
  417. CHARTYPE *params;
  418. #endif
  419. /***********************************************************************/
  420. {
  421. /*-------------------------- external data ----------------------------*/
  422. /*--------------------------- local data ------------------------------*/
  423.  short rc=RC_OK;
  424.  unsigned short x=0,y=0;
  425.  bool same_line=TRUE;
  426. /*--------------------------- processing ------------------------------*/
  427. #ifdef TRACE
  428.  trace_function("commsos.c: Sos_current");
  429. #endif
  430.  getyx(CURRENT_WINDOW_FILEAREA,y,x);
  431.  switch (CURRENT_VIEW->current_window)
  432.    {
  433.     case WINDOW_FILEAREA:
  434.          if (CURRENT_VIEW->focus_line != CURRENT_VIEW->current_line)
  435.            {
  436.             post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  437.             CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
  438.             same_line = FALSE;
  439.            }
  440.          y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,
  441.                                     CURRENT_VIEW->current_row);
  442.          wmove(CURRENT_WINDOW_FILEAREA,y,x);
  443.          if (!same_line)
  444.             pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  445.          break;
  446.     case WINDOW_PREFIX:
  447.     case WINDOW_COMMAND:
  448.          CURRENT_VIEW->focus_line = CURRENT_VIEW->current_line;
  449.          y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,
  450.                                     CURRENT_VIEW->current_row);
  451.          CURRENT_VIEW->current_window = WINDOW_FILEAREA;
  452.          wmove(CURRENT_WINDOW_FILEAREA,y,x);
  453.          pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  454.          break;
  455.     default:
  456.          break;
  457.    }
  458. #ifdef TRACE
  459.  trace_return();
  460. #endif
  461.  return(rc);
  462. }
  463. /*man-start*********************************************************************
  464. COMMAND
  465.      sos cursoradj - move first non-blank character to cursor
  466.  
  467. SYNTAX
  468.      SOS CURSORAdj
  469.  
  470. DESCRIPTION
  471.      The SOS CURSORADJ command moves text in the <focus line> so that
  472.      the first non-blank character appears under the cursor position.
  473.  
  474. COMPATIBILITY
  475.      XEDIT: N/A
  476.      KEDIT: Compatible.
  477.  
  478. STATUS
  479.      Complete
  480. **man-end**********************************************************************/
  481. #ifdef HAVE_PROTO
  482. short Sos_cursoradj(CHARTYPE *params)
  483. #else
  484. short Sos_cursoradj(params)
  485. CHARTYPE *params;
  486. #endif
  487. /***********************************************************************/
  488. {
  489. /*-------------------------- external data ----------------------------*/
  490.  extern CHARTYPE *rec;
  491. /*--------------------------- local data ------------------------------*/
  492.  short num_cols=0,first_non_blank_col=0,col=0,rc=RC_OK;
  493.  unsigned short x=0,y=0;
  494. /*--------------------------- processing ------------------------------*/
  495. #ifdef TRACE
  496.  trace_function("commsos.c: Sos_cursoradj");
  497. #endif
  498.  getyx(CURRENT_WINDOW,y,x);
  499.  switch (CURRENT_VIEW->current_window)
  500.    {
  501.     case WINDOW_FILEAREA:
  502.          if (FOCUS_TOF || FOCUS_BOF)
  503.            {
  504.             display_error(38,(CHARTYPE *)"",FALSE);
  505. #ifdef TRACE
  506.             trace_return();
  507. #endif
  508.             return(RC_INVALID_ENVIRON);
  509.            }
  510.          col = x + CURRENT_VIEW->verify_col - 1;
  511.          first_non_blank_col = strzne(rec,' ');
  512.          if (first_non_blank_col == (-1))
  513.             first_non_blank_col = 0;
  514.          num_cols = first_non_blank_col - col;
  515.          if (num_cols < 0)
  516.             rc = execute_shift_command(FALSE,-num_cols,CURRENT_VIEW->focus_line,1,FALSE,TARGET_UNFOUND,TRUE);
  517.          else
  518.             if (num_cols > 0)
  519.                rc = execute_shift_command(TRUE,num_cols,CURRENT_VIEW->focus_line,1,FALSE,TARGET_UNFOUND,TRUE);
  520.          break;
  521.     default:
  522.          break;
  523.    }
  524. #ifdef TRACE
  525.  trace_return();
  526. #endif
  527.  return(rc);
  528. }
  529. /*man-start*********************************************************************
  530. COMMAND
  531.      sos delback - delete the character to the left of the cursor
  532.  
  533. SYNTAX
  534.      SOS DELBAck
  535.  
  536. DESCRIPTION
  537.      The SOS DELBACK command moves the cursor one character to the left
  538.      and deletes the character now under the cursor.
  539.  
  540. COMPATIBILITY
  541.      XEDIT: N/A
  542.      KEDIT: Compatible.
  543.  
  544. SEE ALSO
  545.      <SOS DELCHAR>
  546.  
  547. STATUS
  548.      Complete
  549. **man-end**********************************************************************/
  550. #ifdef HAVE_PROTO
  551. short Sos_delback(CHARTYPE *params)
  552. #else
  553. short Sos_delback(params)
  554. CHARTYPE *params;
  555. #endif
  556. /***********************************************************************/
  557. {
  558. /*------------------------- external data -----------------------------*/
  559.  extern CHARTYPE *rec;
  560.  extern LENGTHTYPE rec_len;
  561.  extern CHARTYPE *cmd_rec;
  562.  extern unsigned short cmd_rec_len;
  563.  extern CHARTYPE *pre_rec;
  564.  extern unsigned short pre_rec_len;
  565.  extern bool prefix_changed;
  566.  extern bool readonly;
  567.  extern VIEW_DETAILS *vd_mark;
  568. /*--------------------------- local data ------------------------------*/
  569.  unsigned short x=0,y=0;
  570.  LENGTHTYPE off=0;
  571. /*--------------------------- processing ------------------------------*/
  572. #ifdef TRACE
  573.  trace_function("commsos.c: Sos_delback");
  574. #endif
  575.  getyx(CURRENT_WINDOW,y,x);
  576.  switch (CURRENT_VIEW->current_window)
  577.    {
  578.     case WINDOW_FILEAREA:
  579. /*---------------------------------------------------------------------*/
  580. /* If running in read-only mode and an attempt is made to execute this */
  581. /* command in the MAIN window, then error...                           */
  582. /*---------------------------------------------------------------------*/
  583.          if (readonly)
  584.            {
  585.             display_error(56,(CHARTYPE *)"",FALSE);
  586. #ifdef TRACE
  587.             trace_return();
  588. #endif
  589.             return(RC_INVALID_ENVIRON);
  590.            }
  591.          if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  592.            {
  593.             display_error(38,(CHARTYPE *)"",FALSE);
  594. #ifdef TRACE
  595.             trace_return();
  596. #endif
  597.             return(RC_INVALID_ENVIRON);
  598.            }
  599.          break;
  600.     case WINDOW_COMMAND:
  601.          if (x == 0)
  602.            {
  603. #ifdef TRACE
  604.             trace_return();
  605. #endif
  606.             return(RC_OK);
  607.            }
  608.          wmove(CURRENT_WINDOW,y,x-1);
  609.          my_wdelch(CURRENT_WINDOW);
  610.          if (x <= cmd_rec_len)
  611.            {
  612.             memdeln(cmd_rec,x-1,cmd_rec_len,1);
  613.             cmd_rec_len--;
  614.            }
  615. #ifdef TRACE
  616.          trace_return();
  617. #endif
  618.          return(RC_OK);
  619.          break;
  620.     case WINDOW_PREFIX:
  621. #if 0
  622.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT)
  623.             off = CURRENT_VIEW->prefix_gap;
  624.          else
  625.             off = 0;
  626. #endif
  627.          if (x == 0)
  628.            {
  629. #ifdef TRACE
  630.             trace_return();
  631. #endif
  632.             return(RC_OK);
  633.            }
  634.          prefix_changed = TRUE;
  635.          wmove(CURRENT_WINDOW,y,x-1);
  636.          my_wdelch(CURRENT_WINDOW);
  637.          if ((x) <= pre_rec_len)
  638.            {
  639.             memdeln(pre_rec,x-1,pre_rec_len,1);
  640.             pre_rec_len --;
  641.            }
  642. #ifdef TRACE
  643.          trace_return();
  644. #endif
  645.          return(RC_OK);
  646.          break;
  647.     default:
  648.          break;
  649.    }
  650. /*---------------------------------------------------------------------*/
  651. /* Remainder of processing is only for WINDOW_FILEAREA.                */
  652. /*---------------------------------------------------------------------*/
  653.  if (x == 0 && CURRENT_VIEW->verify_start == CURRENT_VIEW->verify_col)
  654.    {
  655. #ifdef TRACE
  656.     trace_return();
  657. #endif
  658.     return(RC_OK);
  659.    }
  660.  cursor_left(TRUE,FALSE);
  661. /*---------------------------------------------------------------------*/
  662. /* If we are after the last character of the line, exit.               */
  663. /*---------------------------------------------------------------------*/
  664.  if (x+CURRENT_VIEW->verify_col-1 > rec_len)
  665.    {
  666. #ifdef TRACE
  667.     trace_return();
  668. #endif
  669.     return(RC_OK);
  670.    }
  671.  
  672.  getyx(CURRENT_WINDOW,y,x);
  673.  my_wdelch(CURRENT_WINDOW);
  674.  
  675.  memdeln(rec,CURRENT_VIEW->verify_col-1+x,rec_len,1);
  676.  rec_len--;
  677. /*---------------------------------------------------------------------*/
  678. /* If there is a character off the right edge of the screen, display it*/
  679. /* in the last character of the main window.                           */
  680. /*---------------------------------------------------------------------*/
  681.  if (CURRENT_VIEW->verify_col-1+CURRENT_SCREEN.cols[WINDOW_FILEAREA]-1 < rec_len)
  682.    {
  683.     wmove(CURRENT_WINDOW,y,CURRENT_SCREEN.cols[WINDOW_FILEAREA]-1);
  684.     put_char(CURRENT_WINDOW,rec[CURRENT_VIEW->verify_col-1+CURRENT_SCREEN.cols[WINDOW_FILEAREA]-1],ADDCHAR);
  685.     wmove(CURRENT_WINDOW,y,x);
  686.    }
  687. /*---------------------------------------------------------------------*/
  688. /* If the character being deleted is on a line which is in the marked  */
  689. /* block, redisplay the window.                                        */
  690. /*---------------------------------------------------------------------*/
  691.  if (CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  692.    {
  693.     if ((CURRENT_VIEW == MARK_VIEW
  694.       &&  CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line
  695.       &&  CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  696.     || CURRENT_SCREEN.sl[y].highlight)
  697.       {
  698.        build_screen(current_screen);
  699.        display_screen(current_screen);
  700.       }
  701.    }
  702. #ifdef TRACE
  703.  trace_return();
  704. #endif
  705.  return(RC_OK);
  706. }
  707. /*man-start*********************************************************************
  708. COMMAND
  709.      sos delchar - delete character under cursor
  710.  
  711. SYNTAX
  712.      SOS DELChar
  713.  
  714. DESCRIPTION
  715.      The SOS DELCHAR command deletes the character under the cursor.
  716.      Text to the right is shifted to the left.
  717.  
  718. COMPATIBILITY
  719.      XEDIT: N/A
  720.      KEDIT: Compatible.
  721.  
  722. SEE ALSO
  723.      <SOS DELBACK>
  724.  
  725. STATUS
  726.      Complete
  727. **man-end**********************************************************************/
  728. #ifdef HAVE_PROTO
  729. short Sos_delchar(CHARTYPE *params)
  730. #else
  731. short Sos_delchar(params)
  732. CHARTYPE *params;
  733. #endif
  734. /***********************************************************************/
  735. {
  736. /*------------------------- external data -----------------------------*/
  737.  extern CHARTYPE *rec;
  738.  extern LENGTHTYPE rec_len;
  739.  extern CHARTYPE *cmd_rec;
  740.  extern unsigned short cmd_rec_len;
  741.  extern CHARTYPE *pre_rec;
  742.  extern unsigned short pre_rec_len;
  743.  extern bool prefix_changed;
  744.  extern bool readonly;
  745.  extern VIEW_DETAILS *vd_mark;
  746. /*--------------------------- local data ------------------------------*/
  747.  unsigned short x=0,y=0;
  748.  LENGTHTYPE off=0;
  749. /*--------------------------- processing ------------------------------*/
  750. #ifdef TRACE
  751.  trace_function("commsos.c: Sos_delchar");
  752. #endif
  753. /*---------------------------------------------------------------------*/
  754. /* If running in read-only mode and an attempt is made to execute this */
  755. /* command in the MAIN window, then error...                           */
  756. /*---------------------------------------------------------------------*/
  757.  if (readonly && CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  758.    {
  759.     display_error(56,(CHARTYPE *)"",FALSE);
  760. #ifdef TRACE
  761.     trace_return();
  762. #endif
  763.     return(RC_INVALID_ENVIRON);
  764.    }
  765.  getyx(CURRENT_WINDOW,y,x);
  766.  switch (CURRENT_VIEW->current_window)
  767.    {
  768.     case WINDOW_COMMAND:
  769.          my_wdelch(CURRENT_WINDOW);
  770.          if (x < cmd_rec_len)
  771.            {
  772.             memdeln(cmd_rec,x,cmd_rec_len,1);
  773.             cmd_rec_len--;
  774.            }
  775. #ifdef TRACE
  776.          trace_return();
  777. #endif
  778.          return(RC_OK);
  779.          break;
  780.     case WINDOW_PREFIX:
  781. #if 0
  782.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT)
  783.             off = CURRENT_VIEW->prefix_gap;
  784.          else
  785.             off = 0;
  786. #endif
  787.          my_wdelch(CURRENT_WINDOW);
  788.          if (x < pre_rec_len)
  789.            {
  790.             prefix_changed = TRUE;
  791.             memdeln(pre_rec,x,pre_rec_len,1);
  792.             pre_rec_len--;
  793.            }
  794. #ifdef TRACE
  795.          trace_return();
  796. #endif
  797.          return(RC_OK);
  798.          break;
  799.     case WINDOW_FILEAREA:
  800. /*---------------------------------------------------------------------*/
  801. /* Do not allow this command on the top or bottom of file lines or on  */
  802. /* shadow lines.                                                       */
  803. /*---------------------------------------------------------------------*/
  804.          if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  805.            {
  806.             display_error(38,(CHARTYPE *)"",FALSE);
  807. #ifdef TRACE
  808.             trace_return();
  809. #endif
  810.             return(RC_INVALID_ENVIRON);
  811.            }
  812.          my_wdelch(CURRENT_WINDOW);
  813.          break;
  814.     default:
  815.          break;
  816.    }
  817. /*---------------------------------------------------------------------*/
  818. /* If we are not after the last character of the line...               */
  819. /*---------------------------------------------------------------------*/
  820.  if (x+CURRENT_VIEW->verify_col <= rec_len)
  821.    {
  822.     memdeln(rec,CURRENT_VIEW->verify_col-1+x,rec_len,1);
  823.     rec_len--;
  824. /*---------------------------------------------------------------------*/
  825. /* If there is a character off the right edge of the screen, display it*/
  826. /* in the last character of the main window.                           */
  827. /*---------------------------------------------------------------------*/
  828.     if (CURRENT_VIEW->verify_col-1+CURRENT_SCREEN.cols[WINDOW_FILEAREA]-1 < rec_len)
  829.       {
  830.        wmove(CURRENT_WINDOW,y,CURRENT_SCREEN.cols[WINDOW_FILEAREA]-1);
  831.        put_char(CURRENT_WINDOW,rec[CURRENT_VIEW->verify_col-1+CURRENT_SCREEN.cols[WINDOW_FILEAREA]-1],ADDCHAR);
  832.        wmove(CURRENT_WINDOW,y,x);
  833.       }
  834.    }
  835. /*---------------------------------------------------------------------*/
  836. /* If the character being deleted is on a line which is in the marked  */
  837. /* block, and we are in the FILEAREA, redisplay the screen.            */
  838. /*---------------------------------------------------------------------*/
  839.  if (CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  840.    {
  841.     if ((CURRENT_VIEW == MARK_VIEW
  842.       &&  CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line
  843.       &&  CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  844.     || CURRENT_SCREEN.sl[y].highlight)
  845.       {
  846.        build_screen(current_screen);
  847.        display_screen(current_screen);
  848.       }
  849.    }
  850. #ifdef TRACE
  851.  trace_return();
  852. #endif
  853.  return(RC_OK);
  854. }
  855. /*man-start*********************************************************************
  856. COMMAND
  857.      sos delend - delete to end of line
  858.  
  859. SYNTAX
  860.      SOS DELEnd
  861.  
  862. DESCRIPTION
  863.      The SOS DELEND command deletes all characters from the current
  864.      column to the end of line.
  865.  
  866. COMPATIBILITY
  867.      XEDIT: N/A
  868.      KEDIT: Compatible.
  869.  
  870. STATUS
  871.      Complete.
  872. **man-end**********************************************************************/
  873. #ifdef HAVE_PROTO
  874. short Sos_delend(CHARTYPE *params)
  875. #else
  876. short Sos_delend(params)
  877. CHARTYPE *params;
  878. #endif
  879. /***********************************************************************/
  880. {
  881. /*-------------------------- external data ----------------------------*/
  882.  extern CHARTYPE *rec;
  883.  extern LENGTHTYPE rec_len;
  884.  extern CHARTYPE *cmd_rec;
  885.  extern unsigned short cmd_rec_len;
  886.  extern CHARTYPE *pre_rec;
  887.  extern unsigned short pre_rec_len;
  888.  extern bool prefix_changed;
  889.  extern bool readonly;
  890.  extern VIEW_DETAILS *vd_mark;
  891. /*--------------------------- local data ------------------------------*/
  892.  register short i=0;
  893.  unsigned short col=0,x=0,y=0;
  894.  LENGTHTYPE off=0;
  895. /*--------------------------- processing ------------------------------*/
  896. #ifdef TRACE
  897.  trace_function("commsos.c: Sos_delend");
  898. #endif
  899.  getyx(CURRENT_WINDOW,y,x);
  900.  switch (CURRENT_VIEW->current_window)
  901.    {
  902.     case WINDOW_FILEAREA:
  903. /*---------------------------------------------------------------------*/
  904. /* If running in read-only mode and an attempt is made to execute this */
  905. /* command in the MAIN window, then error...                           */
  906. /*---------------------------------------------------------------------*/
  907.          if (readonly)
  908.            {
  909.             display_error(56,(CHARTYPE *)"",FALSE);
  910. #ifdef TRACE
  911.             trace_return();
  912. #endif
  913.             return(RC_INVALID_ENVIRON);
  914.            }
  915.          if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  916.            {
  917.             display_error(38,(CHARTYPE *)"",FALSE);
  918. #ifdef TRACE
  919.             trace_return();
  920. #endif
  921.             return(RC_INVALID_ENVIRON);
  922.            }
  923.          col = x + CURRENT_VIEW->verify_col - 1;
  924.          for (i=col;i<max_line_length;i++)
  925.              rec[i] = ' ';
  926.          if (rec_len > col)
  927.             rec_len = col;
  928.          my_wclrtoeol(CURRENT_WINDOW);
  929.          break;
  930.     case WINDOW_COMMAND:
  931.          for (i=x;i<COLS;i++)
  932.              cmd_rec[i] = ' ';
  933.          if (cmd_rec_len > x)
  934.             cmd_rec_len = x;
  935.          my_wclrtoeol(CURRENT_WINDOW);
  936.          break;
  937.     case WINDOW_PREFIX:
  938. #if 0
  939.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT)
  940.             off = CURRENT_VIEW->prefix_gap;
  941.          else
  942.             off = 0;
  943. #endif
  944.          prefix_changed = TRUE;
  945.          for (i=x;i<CURRENT_VIEW->prefix_width-CURRENT_VIEW->prefix_gap;i++)
  946.              pre_rec[i] = ' ';
  947.          if (pre_rec_len > x)
  948.             pre_rec_len = x;
  949.          my_wclrtoeol(CURRENT_WINDOW);
  950.          break;
  951.     default:
  952.          break;
  953.    }
  954. /*---------------------------------------------------------------------*/
  955. /* If the character being deleted is on a line which is in the marked  */
  956. /* block, and we are in the filearea, redisplay the screen.            */
  957. /*---------------------------------------------------------------------*/
  958.  if (CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  959.    {
  960.     if ((CURRENT_VIEW == MARK_VIEW
  961.       &&  CURRENT_VIEW->focus_line >= MARK_VIEW->mark_start_line
  962.       &&  CURRENT_VIEW->focus_line <= MARK_VIEW->mark_end_line)
  963.     || CURRENT_SCREEN.sl[y].highlight)
  964.       {
  965.        build_screen(current_screen);
  966.        display_screen(current_screen);
  967.       }
  968.    }
  969. #ifdef TRACE
  970.  trace_return();
  971. #endif
  972.  return(RC_OK);
  973. }
  974. /*man-start*********************************************************************
  975. COMMAND
  976.      sos delline - delete focus line
  977.  
  978. SYNTAX
  979.      SOS DELLine
  980.  
  981. DESCRIPTION
  982.      The SOS DELLINE command deletes the <focus line>.
  983.  
  984. COMPATIBILITY
  985.      XEDIT: Compatible.
  986.      KEDIT: Compatible.
  987.  
  988. SEE ALSO
  989.      <SOS LINEDEL>, <SOS ADDLINE>
  990.  
  991. STATUS
  992.      Complete
  993. **man-end**********************************************************************/
  994. #ifdef HAVE_PROTO
  995. short Sos_delline(CHARTYPE *params)
  996. #else
  997. short Sos_delline(params)
  998. CHARTYPE *params;
  999. #endif
  1000. /***********************************************************************/
  1001. {
  1002. /*-------------------------- external data ----------------------------*/
  1003.  extern bool curses_started;
  1004. /*--------------------------- local data ------------------------------*/
  1005.  short rc=RC_OK;
  1006.  unsigned short x=0,y=0;
  1007.  LINETYPE true_line=0L,lines_affected=0L;
  1008. /*--------------------------- processing ------------------------------*/
  1009. #ifdef TRACE
  1010.  trace_function("commsos.c: Sos_delline");
  1011. #endif
  1012.  if (CURRENT_VIEW->current_window == WINDOW_FILEAREA
  1013.  ||  CURRENT_VIEW->current_window == WINDOW_PREFIX)
  1014.    {
  1015.     getyx(CURRENT_WINDOW,y,x);
  1016.     if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE
  1017.     &&  !CURRENT_VIEW->scope_all)
  1018.       {
  1019.        display_error(38,(CHARTYPE *)"",FALSE);
  1020. #ifdef TRACE
  1021.        trace_return();
  1022. #endif
  1023.        return(RC_INVALID_ENVIRON);
  1024.       }
  1025.    }
  1026.  true_line = get_true_line(FALSE);
  1027.  rc = rearrange_line_blocks(COMMAND_DELETE,SOURCE_COMMAND,true_line,
  1028.                             true_line,true_line,1,CURRENT_VIEW,CURRENT_VIEW,FALSE,
  1029.                             &lines_affected);
  1030. #if 0
  1031.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1032.    {
  1033.     if (curses_started)
  1034.        getyx(CURRENT_WINDOW,y,x);
  1035.     CURRENT_VIEW->focus_line = get_focus_line_in_view(current_screen,CURRENT_VIEW->focus_line,y);
  1036.     y = get_row_for_focus_line(current_screen,CURRENT_VIEW->focus_line,CURRENT_VIEW->current_row);
  1037.     if (curses_started)
  1038.        wmove(CURRENT_WINDOW,y,x);
  1039.     pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1040.    }
  1041. #endif
  1042. #ifdef TRACE
  1043.  trace_return();
  1044. #endif
  1045.  return(rc);
  1046. }
  1047. /*man-start*********************************************************************
  1048. COMMAND
  1049.      sos delword - delete word at or right of cursor
  1050.  
  1051. SYNTAX
  1052.      SOS DELWord
  1053.  
  1054. DESCRIPTION
  1055.      The SOS DELWORD command deletes the word at or to the right
  1056.      of the current cursor position and any spaces following the 
  1057.      word.
  1058.  
  1059. COMPATIBILITY
  1060.      XEDIT: N/A
  1061.      KEDIT: Compatible.
  1062.  
  1063. STATUS
  1064.      Complete
  1065. **man-end**********************************************************************/
  1066. #ifdef HAVE_PROTO
  1067. short Sos_delword(CHARTYPE *params)
  1068. #else
  1069. short Sos_delword(params)
  1070. CHARTYPE *params;
  1071. #endif
  1072. /***********************************************************************/
  1073. {
  1074. /*-------------------------- external data ----------------------------*/
  1075.  extern CHARTYPE *rec;
  1076.  extern LENGTHTYPE rec_len;
  1077.  extern CHARTYPE *cmd_rec;
  1078.  extern unsigned short cmd_rec_len;
  1079.  extern bool readonly;
  1080. /*--------------------------- local data ------------------------------*/
  1081.  register short i=0;
  1082.  short rc=RC_OK;
  1083.  LENGTHTYPE first_col=0,last_col=0;
  1084.  unsigned short x=0,y=0,temp_rec_len=0;
  1085.  short num_cols=0,left_col=0;
  1086.  CHARTYPE *temp_rec=NULL;
  1087. /*--------------------------- processing ------------------------------*/
  1088. #ifdef TRACE
  1089.  trace_function("commsos.c: Sos_delword");
  1090. #endif
  1091. /*---------------------------------------------------------------------*/
  1092. /* This function is not applicable to the PREFIX window.               */
  1093. /*---------------------------------------------------------------------*/
  1094.  getyx(CURRENT_WINDOW,y,x);
  1095.  switch(CURRENT_VIEW->current_window)
  1096.    {
  1097.     case WINDOW_PREFIX:
  1098.          display_error(38,(CHARTYPE *)"",FALSE);
  1099. #ifdef TRACE
  1100.          trace_return();
  1101. #endif
  1102.          return(RC_INVALID_ENVIRON);
  1103.          break;
  1104.     case WINDOW_FILEAREA:
  1105. /*---------------------------------------------------------------------*/
  1106. /* If running in read-only mode and an attempt is made to execute this */
  1107. /* command in the MAIN window, then error...                           */
  1108. /*---------------------------------------------------------------------*/
  1109.          if (readonly)
  1110.            {
  1111.             display_error(56,(CHARTYPE *)"",FALSE);
  1112. #ifdef TRACE
  1113.             trace_return();
  1114. #endif
  1115.             return(RC_INVALID_ENVIRON);
  1116.            }
  1117.          if (CURRENT_SCREEN.sl[y].line_type != LINE_LINE)
  1118.            {
  1119.             display_error(38,(CHARTYPE *)"",FALSE);
  1120. #ifdef TRACE
  1121.             trace_return();
  1122. #endif
  1123.             return(RC_INVALID_ENVIRON);
  1124.            }
  1125.          temp_rec = rec;
  1126.          temp_rec_len = rec_len;
  1127.          left_col = CURRENT_VIEW->verify_col-1;
  1128.          break;
  1129.     case WINDOW_COMMAND:
  1130.          temp_rec = (CHARTYPE *)cmd_rec;
  1131.          temp_rec_len = cmd_rec_len;
  1132.          left_col = 0;
  1133.          break;
  1134.    }
  1135.  if (get_word(temp_rec,temp_rec_len,x+left_col,&first_col,&last_col) == 0)
  1136.    {
  1137. #ifdef TRACE
  1138.     trace_return();
  1139. #endif
  1140.     return(0);
  1141.    }
  1142. /*---------------------------------------------------------------------*/
  1143. /* Delete from the field the number of columns calculated above        */
  1144. /* and adjust the appropriate record length.                           */
  1145. /*---------------------------------------------------------------------*/
  1146.  num_cols = last_col-first_col+1;
  1147.  memdeln(temp_rec,first_col,temp_rec_len,num_cols);
  1148.  switch(CURRENT_VIEW->current_window)
  1149.    {
  1150.     case WINDOW_FILEAREA:
  1151.          rec_len -= num_cols;
  1152.          rc = execute_move_cursor(first_col);
  1153.          build_screen(current_screen); 
  1154.          display_screen(current_screen);
  1155.          break;
  1156.     case WINDOW_COMMAND:
  1157.          cmd_rec_len -= num_cols;
  1158.          wmove(CURRENT_WINDOW,y,first_col);
  1159.          for (i=0;i<num_cols;i++)
  1160.             my_wdelch(CURRENT_WINDOW);
  1161.          break;
  1162.    }
  1163. #ifdef TRACE
  1164.  trace_return();
  1165. #endif
  1166.  return(rc);
  1167. }
  1168. /*man-start*********************************************************************
  1169. COMMAND
  1170.      sos doprefix - execute any pending prefix commands
  1171.  
  1172. SYNTAX
  1173.      SOS DOPREfix
  1174.  
  1175. DESCRIPTION
  1176.      The SOS DOPREFIX command executes any pending prefix commands.
  1177.  
  1178. COMPATIBILITY
  1179.      XEDIT: N/A
  1180.      KEDIT: Compatible.
  1181.  
  1182. STATUS
  1183.      Complete
  1184. **man-end**********************************************************************/
  1185. #ifdef HAVE_PROTO
  1186. short Sos_doprefix(CHARTYPE *params)
  1187. #else
  1188. short Sos_doprefix(params)
  1189. CHARTYPE *params;
  1190. #endif
  1191. /***********************************************************************/
  1192. {
  1193. /*------------------------- external data -----------------------------*/
  1194. /*--------------------------- local data ------------------------------*/
  1195.  short rc=RC_OK;
  1196. /*--------------------------- processing ------------------------------*/
  1197. #ifdef TRACE
  1198.  trace_function("commsos.c: Sos_doprefix");
  1199. #endif
  1200. /*---------------------------------------------------------------------*/
  1201. /*                                                                     */
  1202. /*---------------------------------------------------------------------*/
  1203.  rc = execute_prefix_commands();
  1204. #ifdef TRACE
  1205.  trace_return();
  1206. #endif
  1207.  return(rc);
  1208. }
  1209. /*man-start*********************************************************************
  1210. COMMAND
  1211.      sos edit - edit a file from directory list
  1212.  
  1213. SYNTAX
  1214.      SOS EDIT
  1215.  
  1216. DESCRIPTION
  1217.      The SOS EDIT command allows the user to edit a file, chosen from
  1218.      a directory list (the file DIR.DIR).
  1219.  
  1220. COMPATIBILITY
  1221.      XEDIT: N/A
  1222.      KEDIT: Compatible with default definition for Alt-X key.
  1223.  
  1224. STATUS
  1225.      Complete.
  1226. **man-end**********************************************************************/
  1227. #ifdef HAVE_PROTO
  1228. short Sos_edit(CHARTYPE *params)
  1229. #else
  1230. short Sos_edit(params)
  1231. CHARTYPE *params;
  1232. #endif
  1233. /***********************************************************************/
  1234. {
  1235. /*-------------------------- external data ----------------------------*/
  1236.  extern CHARTYPE sp_path[MAX_FILE_NAME+1];
  1237.  extern CHARTYPE sp_fname[MAX_FILE_NAME+1];
  1238.  extern CHARTYPE dir_path[MAX_FILE_NAME+1];
  1239.  extern LENGTHTYPE rec_len;
  1240.  extern unsigned short file_start;
  1241. /*--------------------------- local data ------------------------------*/
  1242.  LINE *curr=NULL;
  1243.  CHARTYPE edit_fname[MAX_FILE_NAME];
  1244.  unsigned short y=0,x=0;
  1245.  short rc=RC_OK;
  1246.  LINETYPE true_line=0L;
  1247.  CHARTYPE *lname=NULL,*fname=NULL;
  1248. /*--------------------------- processing ------------------------------*/
  1249. #ifdef TRACE
  1250.  trace_function("commsos.c: Sos_edit");
  1251. #endif
  1252. /*---------------------------------------------------------------------*/
  1253. /* If the current file is not the special DIR.DIR file exit.           */
  1254. /*---------------------------------------------------------------------*/
  1255.  if (CURRENT_FILE->pseudo_file != PSEUDO_DIR)
  1256.    {
  1257. #ifdef TRACE
  1258.     trace_return();
  1259. #endif
  1260.     return(RC_INVALID_ENVIRON);
  1261.    }
  1262. /*---------------------------------------------------------------------*/
  1263. /* Determine which line contains a vaild file to edit. TOF and EOF are */
  1264. /* invalid positions.                                                  */
  1265. /*---------------------------------------------------------------------*/
  1266.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND)
  1267.    {
  1268.     if (CURRENT_TOF || CURRENT_BOF)
  1269.       {
  1270. #ifdef TRACE
  1271.        trace_return();
  1272. #endif
  1273.        return(RC_INVALID_ENVIRON);
  1274.       }
  1275.     true_line = CURRENT_VIEW->current_line;
  1276.    }
  1277.  else
  1278.    {
  1279.     getyx(CURRENT_WINDOW,y,x);
  1280.     if (FOCUS_TOF || FOCUS_BOF)
  1281.       {
  1282. #ifdef TRACE
  1283.        trace_return();
  1284. #endif
  1285.        return(RC_INVALID_ENVIRON);
  1286.       }
  1287.     true_line = CURRENT_VIEW->focus_line;
  1288.    }
  1289. /*---------------------------------------------------------------------*/
  1290. /* Find the current LINE pointer for the focus_line.                   */
  1291. /*---------------------------------------------------------------------*/
  1292.  curr = lll_find(CURRENT_FILE->first_line,CURRENT_FILE->last_line,true_line,CURRENT_FILE->number_lines);
  1293. /*---------------------------------------------------------------------*/
  1294. /* Ensure that the line is long enough to have a filename on it...     */
  1295. /*---------------------------------------------------------------------*/
  1296.  if (rec_len <= file_start)
  1297.    {
  1298. #ifdef TRACE
  1299.     trace_return();
  1300. #endif
  1301.     return(RC_INVALID_ENVIRON);
  1302.    }
  1303. /*---------------------------------------------------------------------*/
  1304.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  1305. /*---------------------------------------------------------------------*/
  1306. /* Validate that the supplied file is valid.                           */
  1307. /*---------------------------------------------------------------------*/
  1308. #if defined(MULTIPLE_PSEUDO_FILES)
  1309.  strcpy((DEFCHAR *)edit_fname,(DEFCHAR *)CURRENT_FILE->fpath);
  1310.  strcat((DEFCHAR *)edit_fname,(DEFCHAR *)curr->line+file_start);
  1311. # ifdef FILENAME_LENGTH
  1312.  edit_fname[(strlen((DEFCHAR *)CURRENT_FILE->fpath)+curr->filename_length)-1] = '\0';
  1313. # else
  1314.  edit_fname[(strlen((DEFCHAR *)CURRENT_FILE->fpath)+curr->length)-1] = '\0';
  1315. # endif
  1316. #else
  1317.  strcpy((DEFCHAR *)edit_fname,(DEFCHAR *)dir_path);
  1318.  fname = curr->line+file_start;
  1319.  if (*(curr->line) == 'l')
  1320.    {
  1321.     /*
  1322.      * We have a symbolic link.  Get the "real" file if there is one
  1323.      * ie. the string AFTER "->" is the "real" file name.
  1324.      */
  1325.     lname = strstr((DEFCHAR*)fname," -> ");
  1326.     if (lname != NULL)
  1327.       {
  1328.        if (strlen(lname) > 4)
  1329.           fname = lname + 4*sizeof(CHARTYPE);
  1330.       }
  1331.    }
  1332.  strcat((DEFCHAR *)edit_fname,(DEFCHAR *)fname);
  1333. #endif
  1334.  
  1335. #if !defined(MULTIPLE_PSEUDO_FILES)
  1336.  if ((rc = splitpath(edit_fname)) != RC_OK)
  1337.    {
  1338.     display_error(10,edit_fname,FALSE);
  1339. #ifdef TRACE
  1340.     trace_return();
  1341. #endif
  1342.     return(rc);
  1343.    }
  1344.  strcpy((DEFCHAR *)edit_fname,(DEFCHAR *)sp_path);
  1345.  strcat((DEFCHAR *)edit_fname,(DEFCHAR *)sp_fname);
  1346. #endif
  1347. /*---------------------------------------------------------------------*/
  1348. /* Edit the file.                                                      */
  1349. /*---------------------------------------------------------------------*/
  1350.  rc = Xedit(edit_fname);
  1351.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  1352. #ifdef TRACE
  1353.  trace_return();
  1354. #endif
  1355.  return(rc);
  1356. }
  1357. /*man-start*********************************************************************
  1358. COMMAND
  1359.      sos endchar - move cursor to end of focus line
  1360.  
  1361. SYNTAX
  1362.      SOS ENDChar
  1363.  
  1364. DESCRIPTION
  1365.      The SOS ENDCHAR command moves the cursor to the position after
  1366.      the last character displayed in the current window.
  1367.  
  1368. COMPATIBILITY
  1369.      XEDIT: N/A
  1370.      KEDIT: Compatible.
  1371.  
  1372. SEE ALSO
  1373.      <SOS STARTENDCHAR>
  1374.  
  1375. STATUS
  1376.      Complete.
  1377. **man-end**********************************************************************/
  1378. #ifdef HAVE_PROTO
  1379. short Sos_endchar(CHARTYPE *params)
  1380. #else
  1381. short Sos_endchar(params)
  1382. CHARTYPE *params;
  1383. #endif
  1384. /***********************************************************************/
  1385. {
  1386. /*-------------------------- external data ----------------------------*/
  1387.  extern LENGTHTYPE rec_len;
  1388.  extern LENGTHTYPE cmd_rec_len;
  1389.  extern unsigned short pre_rec_len;
  1390. /*--------------------------- local data ------------------------------*/
  1391.  short rc=RC_OK;
  1392.  unsigned short x=0,y=0;
  1393. /*--------------------------- processing ------------------------------*/
  1394. #ifdef TRACE
  1395.  trace_function("commsos.c: Sos_endchar");
  1396. #endif
  1397.  getyx(CURRENT_WINDOW,y,x);
  1398.  switch(CURRENT_VIEW->current_window)
  1399.    {
  1400.     case WINDOW_PREFIX:
  1401. #if 0
  1402.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT)
  1403.             wmove(CURRENT_WINDOW,y,CURRENT_VIEW->prefix_gap+min(pre_rec_len,CURRENT_VIEW->prefix_width-CURRENT_VIEW->prefix_gap-1));
  1404.          else
  1405. #endif
  1406.          wmove(CURRENT_WINDOW,y,min(pre_rec_len,CURRENT_VIEW->prefix_width-CURRENT_VIEW->prefix_gap-1));
  1407.          rc = RC_OK;
  1408.          break;
  1409.     case WINDOW_COMMAND:
  1410.          wmove(CURRENT_WINDOW,y,cmd_rec_len);
  1411.          rc = RC_OK;
  1412.          break;
  1413.     case WINDOW_FILEAREA:
  1414.          rc = execute_move_cursor(rec_len);
  1415.          break;
  1416.    }
  1417. #ifdef TRACE
  1418.  trace_return();
  1419. #endif
  1420.  return(rc);
  1421. }
  1422. /*man-start*********************************************************************
  1423. COMMAND
  1424.      sos execute - move cursor to command line and execute command
  1425.  
  1426. SYNTAX
  1427.      SOS EXecute
  1428.  
  1429. DESCRIPTION
  1430.      The SOS EXECUTE command moves the cursor to the <command line>
  1431.      and executes any command that is displayed there.
  1432.  
  1433. COMPATIBILITY
  1434.      XEDIT: N/A
  1435.      KEDIT: Compatible
  1436.  
  1437. STATUS
  1438.      Complete. 
  1439. **man-end**********************************************************************/
  1440. #ifdef HAVE_PROTO
  1441. short Sos_execute(CHARTYPE *params)
  1442. #else
  1443. short Sos_execute(params)
  1444. CHARTYPE *params;
  1445. #endif
  1446. /***********************************************************************/
  1447. {
  1448. /*-------------------------- external data ----------------------------*/
  1449.  extern CHARTYPE *cmd_rec;
  1450.  extern unsigned short cmd_rec_len;
  1451.  extern CHARTYPE *temp_cmd;
  1452. /*--------------------------- local data ------------------------------*/
  1453.  register short i=0;
  1454.  short rc=RC_OK;
  1455. /*--------------------------- processing ------------------------------*/
  1456. #ifdef TRACE
  1457.  trace_function("commsos.c: Sos_execute");
  1458. #endif
  1459.  
  1460.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1461.     rc = cursor_cmdline(1);
  1462.  if (rc == RC_OK)
  1463.    {
  1464.     for (i=0;i<cmd_rec_len;i++)
  1465.        temp_cmd[i] = cmd_rec[i];
  1466.     temp_cmd[cmd_rec_len] = '\0';
  1467.     MyStrip(temp_cmd,'L',' ');
  1468.     add_command(temp_cmd);
  1469.     rc = command_line(temp_cmd,COMMAND_ONLY_FALSE);
  1470.    }
  1471. #ifdef TRACE
  1472.  trace_return();
  1473. #endif
  1474.  return(rc);
  1475. }
  1476. /*man-start*********************************************************************
  1477. COMMAND
  1478.      sos firstchar - move cursor to first non-blank of field
  1479.  
  1480. SYNTAX
  1481.      SOS FIRSTCHar
  1482.  
  1483. DESCRIPTION
  1484.      The SOS FIRSTCHAR command moves the cursor to the first
  1485.      non-blank character of the cursor field
  1486.  
  1487. COMPATIBILITY
  1488.      XEDIT: N/A
  1489.      KEDIT: Compatible
  1490.  
  1491. SEE ALSO
  1492.      <SOS FIRSTCOL>
  1493.  
  1494. STATUS
  1495.      Complete.
  1496. **man-end**********************************************************************/
  1497. #ifdef HAVE_PROTO
  1498. short Sos_firstchar(CHARTYPE *params)
  1499. #else
  1500. short Sos_firstchar(params)
  1501. CHARTYPE *params;
  1502. #endif
  1503. /***********************************************************************/
  1504. {
  1505. /*-------------------------- external data ----------------------------*/
  1506. /*--------------------------- local data ------------------------------*/
  1507.  short rc=RC_OK,new_col=0;
  1508.  unsigned short y=0,x=0;
  1509.  LINE *curr=NULL;
  1510. /*--------------------------- processing ------------------------------*/
  1511. #ifdef TRACE
  1512.  trace_function("commsos.c: Sos_firstchar");
  1513. #endif
  1514. /*---------------------------------------------------------------------*/
  1515. /* For the command line and prefix area, just go to the first column...*/
  1516. /*---------------------------------------------------------------------*/
  1517.  getyx(CURRENT_WINDOW,y,x);
  1518.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  1519.  ||  CURRENT_VIEW->current_window == WINDOW_PREFIX)
  1520.    {
  1521.     wmove(CURRENT_WINDOW,y,0);
  1522. #ifdef TRACE
  1523.     trace_return();
  1524. #endif
  1525.     return(rc);
  1526.    }
  1527. /*---------------------------------------------------------------------*/
  1528. /* For the filearea, we have to do a bit more...                       */
  1529. /*---------------------------------------------------------------------*/
  1530.  curr = CURRENT_SCREEN.sl[y].current;
  1531.  new_col = memne(curr->line,' ',curr->length);
  1532.  if (new_col == (-1))
  1533.     new_col = 0;
  1534.  rc = execute_move_cursor(new_col);
  1535. #ifdef TRACE
  1536.  trace_return();
  1537. #endif
  1538.  return(rc);
  1539. }
  1540. /*man-start*********************************************************************
  1541. COMMAND
  1542.      sos firstcol - move cursor to first column of field
  1543.  
  1544. SYNTAX
  1545.      SOS FIRSTCOl
  1546.  
  1547. DESCRIPTION
  1548.      The SOS FIRSTCOL command moves the cursor to the first
  1549.      column of the <cursor field>.
  1550.  
  1551. COMPATIBILITY
  1552.      XEDIT: N/A
  1553.      KEDIT: Compatible
  1554.  
  1555. SEE ALSO
  1556.      <SOS FIRSTCHAR>, <SOS LASTCOL>
  1557.  
  1558. STATUS
  1559.      Complete.
  1560. **man-end**********************************************************************/
  1561. #ifdef HAVE_PROTO
  1562. short Sos_firstcol(CHARTYPE *params)
  1563. #else
  1564. short Sos_firstcol(params)
  1565. CHARTYPE *params;
  1566. #endif
  1567. /***********************************************************************/
  1568. {
  1569. /*-------------------------- external data ----------------------------*/
  1570. /*--------------------------- local data ------------------------------*/
  1571.  short rc=RC_OK;
  1572.  unsigned short y=0,x=0;
  1573. /*--------------------------- processing ------------------------------*/
  1574. #ifdef TRACE
  1575.  trace_function("commsos.c: Sos_firstcol");
  1576. #endif
  1577.  getyx(CURRENT_WINDOW,y,x);
  1578. /*---------------------------------------------------------------------*/
  1579. /* For the command line, just go to the first column...                */
  1580. /*---------------------------------------------------------------------*/
  1581.  switch(CURRENT_VIEW->current_window)
  1582.    {
  1583.     case WINDOW_COMMAND:
  1584.     case WINDOW_PREFIX:
  1585.          wmove(CURRENT_WINDOW,y,0);
  1586.          break;
  1587.     case WINDOW_FILEAREA:
  1588.          if (CURRENT_VIEW->verify_col != 1)
  1589.             rc = execute_move_cursor(0);
  1590.          wmove(CURRENT_WINDOW,y,0);
  1591.          break;
  1592.    }
  1593. #ifdef TRACE
  1594.  trace_return();
  1595. #endif
  1596.  return(rc);
  1597. }
  1598. /*man-start*********************************************************************
  1599. COMMAND
  1600.      sos instab - shift text to next tab column
  1601.  
  1602. SYNTAX
  1603.      SOS INSTAB
  1604.  
  1605. DESCRIPTION
  1606.      The SOS INSTAB command shifts all text from the current cursor
  1607.      position in the <filearea> to the next tab column.
  1608.  
  1609. COMPATIBILITY
  1610.      XEDIT: N/A
  1611.      KEDIT: Compatible.
  1612.  
  1613. SEE ALSO
  1614.      <SET TABS>
  1615.  
  1616. STATUS
  1617.      Complete.
  1618. **man-end**********************************************************************/
  1619. #ifdef HAVE_PROTO
  1620. short Sos_instab(CHARTYPE *params)
  1621. #else
  1622. short Sos_instab(params)
  1623. CHARTYPE *params;
  1624. #endif
  1625. /***********************************************************************/
  1626. {
  1627. /*-------------------------- external data ----------------------------*/
  1628.  extern LENGTHTYPE rec_len;
  1629.  extern CHARTYPE *rec;
  1630. /*--------------------------- local data ------------------------------*/
  1631.  unsigned short x=0,y=0;
  1632.  short rc=RC_OK;
  1633.  LENGTHTYPE col=0,tabcol=0;
  1634.  register int i=0;
  1635. /*--------------------------- processing ------------------------------*/
  1636. #ifdef TRACE
  1637.  trace_function("commsos.c: Sos_instab");
  1638. #endif
  1639.  if (CURRENT_VIEW->current_window != WINDOW_FILEAREA)
  1640.    {
  1641. #ifdef TRACE
  1642.     trace_return();
  1643. #endif
  1644.     return(rc);
  1645.    }
  1646.  getyx(CURRENT_WINDOW,y,x);
  1647.  col = x + CURRENT_VIEW->verify_col;
  1648.  for (i=0;i<CURRENT_VIEW->numtabs;i++)
  1649.    {
  1650.     if (col < CURRENT_VIEW->tabs[i])
  1651.       {
  1652.        tabcol = CURRENT_VIEW->tabs[i];
  1653.        break;
  1654.       }
  1655.    }
  1656.  if (tabcol == 0) /* after last tab column or on a tab column */
  1657.    {
  1658. #ifdef TRACE
  1659.     trace_return();
  1660. #endif
  1661.     return(rc);
  1662.    }
  1663.  for (i=0;i<tabcol-col;i++)
  1664.     meminschr(rec,' ',col-1,max_line_length,rec_len++);
  1665. #if 1
  1666.  rec_len = min(max_line_length,rec_len);
  1667. #endif
  1668.  
  1669.  Sos_tabf((CHARTYPE *)"nochar");
  1670.  build_screen(current_screen);
  1671.  display_screen(current_screen);
  1672. #ifdef TRACE
  1673.  trace_return();
  1674. #endif
  1675.  return(rc);
  1676. }
  1677. /*man-start*********************************************************************
  1678. COMMAND
  1679.      sos lastcol - move cursor to last column of field
  1680.  
  1681. SYNTAX
  1682.      SOS LASTCOl
  1683.  
  1684. DESCRIPTION
  1685.      The SOS LASTCOL command moves the cursor to the last column
  1686.      of the <cursor field>.
  1687.  
  1688. COMPATIBILITY
  1689.      XEDIT: N/A
  1690.      KEDIT: N/A
  1691.  
  1692. SEE ALSO
  1693.      <SOS FIRSTCOL>
  1694.  
  1695. STATUS
  1696.      Complete.
  1697. **man-end**********************************************************************/
  1698. #ifdef HAVE_PROTO
  1699. short Sos_lastcol(CHARTYPE *params)
  1700. #else
  1701. short Sos_lastcol(params)
  1702. CHARTYPE *params;
  1703. #endif
  1704. /***********************************************************************/
  1705. {
  1706. /*-------------------------- external data ----------------------------*/
  1707. /*--------------------------- local data ------------------------------*/
  1708.  short rc=RC_OK;
  1709.  unsigned short y=0,x=0;
  1710. /*--------------------------- processing ------------------------------*/
  1711. #ifdef TRACE
  1712.  trace_function("commsos.c: Sos_lastcol");
  1713. #endif
  1714. #if 0
  1715. /*---------------------------------------------------------------------*/
  1716. /* For the command line and filearea, just go to the last column...    */
  1717. /*---------------------------------------------------------------------*/
  1718.  getyx(CURRENT_WINDOW,y,x);
  1719.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  1720.  ||  CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  1721.    {
  1722.     x = getmaxx(CURRENT_WINDOW)-1;
  1723.     wmove(CURRENT_WINDOW,y,x);
  1724. #ifdef TRACE
  1725.     trace_return();
  1726. #endif
  1727.     return(rc);
  1728.    }
  1729. /*---------------------------------------------------------------------*/
  1730. /* For the prefix area we have to do a bit more...                     */
  1731. /*---------------------------------------------------------------------*/
  1732.  if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT)
  1733.      x = CURRENT_VIEW->prefix_width - 1;
  1734.  else
  1735.      x = CURRENT_VIEW->prefix_width - CURRENT_VIEW->prefix_gap - 1;
  1736.  wmove(CURRENT_WINDOW,y,x);
  1737. #else
  1738.  
  1739.  getyx(CURRENT_WINDOW,y,x);
  1740.  x = getmaxx(CURRENT_WINDOW)-1;
  1741.  wmove(CURRENT_WINDOW,y,x);
  1742. #endif
  1743.  
  1744. #ifdef TRACE
  1745.  trace_return();
  1746. #endif
  1747.  return(rc);
  1748. }
  1749. /*man-start*********************************************************************
  1750. COMMAND
  1751.      sos leftedge - move cursor to left edge of window
  1752.  
  1753. SYNTAX
  1754.      SOS LEFTEdge
  1755.  
  1756. DESCRIPTION
  1757.      The SOS LEFTEDGE command moves the cursor to the leftmost edge
  1758.      of the <filearea> if not on the command line or to the leftmost
  1759.      edge of the command line if on the <command line>.
  1760.  
  1761. COMPATIBILITY
  1762.      XEDIT: N/A
  1763.      KEDIT: Compatible
  1764.  
  1765. SEE ALSO
  1766.      <SOS RIGHTEDGE>, <SOS PREFIX>
  1767.  
  1768. STATUS
  1769.      Complete.
  1770. **man-end**********************************************************************/
  1771. #ifdef HAVE_PROTO
  1772. short Sos_leftedge(CHARTYPE *params)
  1773. #else
  1774. short Sos_leftedge(params)
  1775. CHARTYPE *params;
  1776. #endif
  1777. /***********************************************************************/
  1778. {
  1779. /*-------------------------- external data ----------------------------*/
  1780. /*--------------------------- local data ------------------------------*/
  1781.  unsigned short y=0,x=0;
  1782. /*--------------------------- processing ------------------------------*/
  1783. #ifdef TRACE
  1784.  trace_function("commsos.c: Sos_leftedge");
  1785. #endif
  1786.  getyx(CURRENT_WINDOW,y,x);
  1787.  if (CURRENT_VIEW->current_window == WINDOW_PREFIX)
  1788.     CURRENT_VIEW->current_window = WINDOW_FILEAREA;
  1789.  wmove(CURRENT_WINDOW,y,0);
  1790. #ifdef TRACE
  1791.  trace_return();
  1792. #endif
  1793.  return(RC_OK);
  1794. }
  1795. /*man-start*********************************************************************
  1796. COMMAND
  1797.      sos lineadd - add blank line after focus line
  1798.  
  1799. SYNTAX
  1800.      SOS LINEAdd
  1801.  
  1802. DESCRIPTION
  1803.      The SOS LINEADD command inserts a blank line in the file following
  1804.      the <focus line>. The cursor is placed in the column under the first
  1805.      non-blank in the <focus line>.
  1806.  
  1807. COMPATIBILITY
  1808.      XEDIT: Compatible.
  1809.      KEDIT: Compatible.
  1810.  
  1811. SEE ALSO
  1812.      <SOS ADDLINE>, <SOS LINEDEL>
  1813.  
  1814. STATUS
  1815.      Complete
  1816. **man-end**********************************************************************/
  1817.  
  1818. /*man-start*********************************************************************
  1819. COMMAND
  1820.      sos linedel - delete focus line
  1821.  
  1822. SYNTAX
  1823.      SOS LINEDel
  1824.  
  1825. DESCRIPTION
  1826.      The SOS LINEDEL command deletes the <focus line>.
  1827.  
  1828. COMPATIBILITY
  1829.      XEDIT: Compatible.
  1830.      KEDIT: Compatible.
  1831.  
  1832. SEE ALSO
  1833.      <SOS DELLINE>, <SOS LINEADD>        
  1834.  
  1835. STATUS
  1836.      Complete
  1837. **man-end**********************************************************************/
  1838.  
  1839. /*man-start*********************************************************************
  1840. COMMAND
  1841.      sos makecurr - make focus line the current line
  1842.  
  1843. SYNTAX
  1844.      SOS MAKECURR
  1845.  
  1846. DESCRIPTION
  1847.      The SOS MAKECURR command set the <current line> to the <focus line>.
  1848.  
  1849. COMPATIBILITY
  1850.      XEDIT: N/A
  1851.      KEDIT: Compatible.
  1852.  
  1853. STATUS
  1854.      Complete
  1855. **man-end**********************************************************************/
  1856. #ifdef HAVE_PROTO
  1857. short Sos_makecurr(CHARTYPE *params)
  1858. #else
  1859. short Sos_makecurr(params)
  1860. CHARTYPE *params;
  1861. #endif
  1862. /***********************************************************************/
  1863. {
  1864. /*-------------------------- external data ----------------------------*/
  1865. /*--------------------------- local data ------------------------------*/
  1866.  short rc=RC_OK;
  1867. /*--------------------------- processing ------------------------------*/
  1868. #ifdef TRACE
  1869.  trace_function("commsos.c: Sos_makecurr");
  1870. #endif
  1871.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  1872.     rc = execute_makecurr(CURRENT_VIEW->focus_line);
  1873. #ifdef TRACE
  1874.  trace_return();
  1875. #endif
  1876.  return(rc);
  1877. }
  1878. /*man-start*********************************************************************
  1879. COMMAND
  1880.      sos marginl - move cursor to the left margin column
  1881.  
  1882. SYNTAX
  1883.      SOS MARGINL
  1884.  
  1885. DESCRIPTION
  1886.      The SOS MARGINL command moves the cursor to the left margin
  1887.      column.
  1888.  
  1889. COMPATIBILITY
  1890.      XEDIT: N/A
  1891.      KEDIT: Compatible.
  1892.             Although, when issued from the command line, nothing
  1893.             happens.
  1894.  
  1895. SEE ALSO
  1896.      <SOS MARGINR>
  1897.  
  1898. STATUS
  1899.      Complete
  1900. **man-end**********************************************************************/
  1901. #ifdef HAVE_PROTO
  1902. short Sos_marginl(CHARTYPE *params)
  1903. #else
  1904. short Sos_marginl(params)
  1905. CHARTYPE *params;
  1906. #endif
  1907. /***********************************************************************/
  1908. {
  1909. /*-------------------------- external data ----------------------------*/
  1910. /*--------------------------- local data ------------------------------*/
  1911.  short rc=RC_OK;
  1912. /*--------------------------- processing ------------------------------*/
  1913. #ifdef TRACE
  1914.  trace_function("commsos.c: Sos_marginl");
  1915. #endif
  1916.  if (Sos_leftedge((CHARTYPE *)"") == RC_OK)
  1917.     rc = execute_move_cursor(CURRENT_VIEW->margin_left-1);
  1918. #ifdef TRACE
  1919.  trace_return();
  1920. #endif
  1921.  return(rc);
  1922. }
  1923. /*man-start*********************************************************************
  1924. COMMAND
  1925.      sos marginr - move cursor to the right margin column
  1926.  
  1927. SYNTAX
  1928.      SOS MARGINR
  1929.  
  1930. DESCRIPTION
  1931.      The SOS MARGINR command moves the cursor to the right margin
  1932.      column.
  1933.  
  1934. COMPATIBILITY
  1935.      XEDIT: N/A
  1936.      KEDIT: Compatible.
  1937.             Although, when issued from the command line, nothing
  1938.             happens.
  1939.  
  1940. SEE ALSO
  1941.      <SOS MARGINL>
  1942.  
  1943. STATUS
  1944.      Complete
  1945. **man-end**********************************************************************/
  1946. #ifdef HAVE_PROTO
  1947. short Sos_marginr(CHARTYPE *params)
  1948. #else
  1949. short Sos_marginr(params)
  1950. CHARTYPE *params;
  1951. #endif
  1952. /***********************************************************************/
  1953. {
  1954. /*-------------------------- external data ----------------------------*/
  1955. /*--------------------------- local data ------------------------------*/
  1956.  short rc=RC_OK;
  1957. /*--------------------------- processing ------------------------------*/
  1958. #ifdef TRACE
  1959.  trace_function("commsos.c: Sos_marginr");
  1960. #endif
  1961.  if (Sos_leftedge((CHARTYPE *)"") == RC_OK)
  1962.     rc = execute_move_cursor(CURRENT_VIEW->margin_right-1);
  1963. #ifdef TRACE
  1964.  trace_return();
  1965. #endif
  1966.  return(rc);
  1967. }
  1968. /*man-start*********************************************************************
  1969. COMMAND
  1970.      sos parindent - move cursor to the paragraph indent column
  1971.  
  1972. SYNTAX
  1973.      SOS PARINDent
  1974.  
  1975. DESCRIPTION
  1976.      The SOS PARINDENT command moves the cursor to the paragraph
  1977.      indent column.
  1978.  
  1979. COMPATIBILITY
  1980.      XEDIT: N/A
  1981.      KEDIT: Compatible.
  1982.             Although, when issued from the command line, nothing
  1983.             happens.
  1984.  
  1985. STATUS
  1986.      Complete
  1987. **man-end**********************************************************************/
  1988. #ifdef HAVE_PROTO
  1989. short Sos_parindent(CHARTYPE *params)
  1990. #else
  1991. short Sos_parindent(params)
  1992. CHARTYPE *params;
  1993. #endif
  1994. /***********************************************************************/
  1995. {
  1996. /*-------------------------- external data ----------------------------*/
  1997. /*--------------------------- local data ------------------------------*/
  1998.  short rc=RC_OK;
  1999.  COLTYPE parindent=0;
  2000. /*--------------------------- processing ------------------------------*/
  2001. #ifdef TRACE
  2002.  trace_function("commsos.c: Sos_parindent");
  2003. #endif
  2004.  if (CURRENT_VIEW->margin_indent_offset_status)
  2005.     parindent = CURRENT_VIEW->margin_left + CURRENT_VIEW->margin_indent - 1;
  2006.  else
  2007.     parindent = CURRENT_VIEW->margin_indent - 1;
  2008.  if (Sos_leftedge((CHARTYPE *)"") == RC_OK)
  2009.     rc = execute_move_cursor(parindent);
  2010. #ifdef TRACE
  2011.  trace_return();
  2012. #endif
  2013.  return(rc);
  2014. }
  2015. /*man-start*********************************************************************
  2016. COMMAND
  2017.      sos pastecmdline - copy contents of marked block to command line
  2018.  
  2019. SYNTAX
  2020.      SOS PASTECMDline
  2021.  
  2022. DESCRIPTION
  2023.      The SOS PASTECMDLINE command copies the contents of the marked
  2024.      block to the command line at the current cursor location.
  2025.  
  2026.      Marked blocks that span one line only are allowed to be pasted.
  2027.  
  2028. COMPATIBILITY
  2029.      XEDIT: N/A
  2030.      KEDIT: N/A
  2031.  
  2032. STATUS
  2033.      Complete
  2034. **man-end**********************************************************************/
  2035. #ifdef HAVE_PROTO
  2036. short Sos_pastecmdline(CHARTYPE *params)
  2037. #else
  2038. short Sos_pastecmdline(params)
  2039. CHARTYPE *params;
  2040. #endif
  2041. /***********************************************************************/
  2042. {
  2043. /*-------------------------- external data ----------------------------*/
  2044.  extern VIEW_DETAILS *vd_mark;
  2045.  extern CHARTYPE *cmd_rec;
  2046.  extern unsigned short cmd_rec_len;
  2047.  extern bool clear_command;
  2048.  extern bool curses_started;
  2049.  extern bool INSERTMODEx;
  2050. /*--------------------------- local data ------------------------------*/
  2051.  short rc=RC_OK;
  2052.  unsigned short x=0,y=0;
  2053.  LINE *curr=NULL;
  2054.  LENGTHTYPE start_col=0,end_col=0;
  2055. /*--------------------------- processing ------------------------------*/
  2056. #ifdef TRACE
  2057.  trace_function("commsos.c: Sos_pastecmdline");
  2058. #endif
  2059.  if (CURRENT_VIEW->current_window != WINDOW_COMMAND)
  2060.    {
  2061.     display_error(38,(CHARTYPE *)"",FALSE);
  2062. #ifdef TRACE
  2063.     trace_return();
  2064. #endif
  2065.     return(RC_INVALID_ENVIRON);
  2066.    }
  2067.  if (MARK_VIEW == NULL)
  2068.    {
  2069.     display_error(44,(CHARTYPE *)"",FALSE);
  2070. #ifdef TRACE
  2071.     trace_return();
  2072. #endif
  2073.     return(RC_INVALID_ENVIRON);
  2074.    }
  2075.  if (MARK_VIEW->mark_start_line != MARK_VIEW->mark_end_line)
  2076.    {
  2077.     display_error(81,(CHARTYPE *)"",FALSE);
  2078. #ifdef TRACE
  2079.     trace_return();
  2080. #endif
  2081.     return(RC_INVALID_ENVIRON);
  2082.    }
  2083.  curr = lll_find(MARK_FILE->first_line,MARK_FILE->last_line,MARK_VIEW->mark_start_line,MARK_FILE->number_lines);
  2084.  if (MARK_VIEW->mark_type == M_LINE)
  2085.    {
  2086.     start_col = 0;
  2087.     end_col = curr->length-1;
  2088.    }
  2089.  else
  2090.    {
  2091.     start_col = MARK_VIEW->mark_start_col-1;
  2092.     end_col = MARK_VIEW->mark_end_col-1;
  2093.    }
  2094.  getyx(CURRENT_WINDOW,y,x);
  2095.  if (INSERTMODEx)
  2096.    {
  2097.     meminsmem(cmd_rec,curr->line+start_col,end_col-start_col+1,x,max_line_length,cmd_rec_len);
  2098.     cmd_rec_len = max(cmd_rec_len,x)+end_col-start_col+1;
  2099.    }
  2100.  else
  2101.    {
  2102.     memcpy(cmd_rec+x,curr->line+start_col,end_col-start_col+1);
  2103.     cmd_rec_len = max(x+end_col-start_col+1,cmd_rec_len);
  2104.    }
  2105.  
  2106.  if (curses_started
  2107.  &&  CURRENT_WINDOW_COMMAND != (WINDOW *)NULL)
  2108.    {
  2109.     wmove(CURRENT_WINDOW_COMMAND,0,0);
  2110.     my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  2111.     put_string(CURRENT_WINDOW_COMMAND,0,0,cmd_rec,cmd_rec_len);
  2112.     wmove(CURRENT_WINDOW,y,x+end_col-start_col+1);
  2113.     clear_command = FALSE;
  2114.    }
  2115. #ifdef TRACE
  2116.  trace_return();
  2117. #endif
  2118.  return(rc);
  2119. }
  2120. /*man-start*********************************************************************
  2121. COMMAND
  2122.      sos prefix - move cursor to leftmost edge of prefix area
  2123.  
  2124. SYNTAX
  2125.      SOS PREfix
  2126.  
  2127. DESCRIPTION
  2128.      The SOS PREFIX command moves the cursor to the rightmost edge
  2129.      of the <prefix area>.
  2130.  
  2131. COMPATIBILITY
  2132.      XEDIT: N/A
  2133.      KEDIT: Compatible
  2134.  
  2135. SEE ALSO
  2136.      <SOS LEFTEDGE>, <SOS RIGHTEDGE>
  2137.  
  2138. STATUS
  2139.      Complete.
  2140. **man-end**********************************************************************/
  2141. #ifdef HAVE_PROTO
  2142. short Sos_prefix(CHARTYPE *params)
  2143. #else
  2144. short Sos_prefix(params)
  2145. CHARTYPE *params;
  2146. #endif
  2147. /***********************************************************************/
  2148. {
  2149. /*-------------------------- external data ----------------------------*/
  2150. /*--------------------------- local data ------------------------------*/
  2151.  short rc=RC_OK;
  2152.  unsigned short y=0,x=0;
  2153. /*--------------------------- processing ------------------------------*/
  2154. #ifdef TRACE
  2155.  trace_function("commsos.c: Sos_prefix");
  2156. #endif
  2157. /*---------------------------------------------------------------------*/
  2158. /* If the cursor is in the command line or there is no prefix on, exit.*/
  2159. /*---------------------------------------------------------------------*/
  2160.  if (CURRENT_VIEW->current_window == WINDOW_COMMAND
  2161.  ||  !CURRENT_VIEW->prefix)
  2162.    {
  2163. #ifdef TRACE
  2164.     trace_return();
  2165. #endif
  2166.     return(RC_OK);
  2167.    }
  2168.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  2169.  getyx(CURRENT_WINDOW,y,x);
  2170.  if (CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  2171.     CURRENT_VIEW->current_window = WINDOW_PREFIX;
  2172. #if 0
  2173.  if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT)
  2174.     x = CURRENT_VIEW->prefix_gap;
  2175.  else
  2176. #endif
  2177.     x = 0;
  2178.  wmove(CURRENT_WINDOW,y,x);
  2179. #ifdef TRACE
  2180.  trace_return();
  2181. #endif
  2182.  return(rc);
  2183. }
  2184. /*man-start*********************************************************************
  2185. COMMAND
  2186.      sos qcmnd - move cursor to command line and clear
  2187.  
  2188. SYNTAX
  2189.      SOS QCmnd
  2190.  
  2191. DESCRIPTION
  2192.      The SOS QCMND command moves the cursor to the first column of
  2193.      the <command line> and clears it.
  2194.  
  2195. COMPATIBILITY
  2196.      XEDIT: N/A
  2197.      KEDIT: Compatible
  2198.  
  2199. SEE ALSO
  2200.      <SOS EXECUTE>
  2201.  
  2202. STATUS
  2203.      Complete.
  2204. **man-end**********************************************************************/
  2205. #ifdef HAVE_PROTO
  2206. short Sos_qcmnd(CHARTYPE *params)
  2207. #else
  2208. short Sos_qcmnd(params)
  2209. CHARTYPE *params;
  2210. #endif
  2211. /***********************************************************************/
  2212. {
  2213. /*-------------------------- external data ----------------------------*/
  2214.  extern CHARTYPE *cmd_rec;
  2215.  extern unsigned short cmd_rec_len;
  2216. /*--------------------------- local data ------------------------------*/
  2217.  short rc=RC_OK;
  2218. /*--------------------------- processing ------------------------------*/
  2219. #ifdef TRACE
  2220.  trace_function("commsos.c: Sos_qcmnd");
  2221. #endif
  2222.  if ((rc = cursor_cmdline(1)) == RC_OK)
  2223.    {
  2224.     if (CURRENT_WINDOW_COMMAND != (WINDOW *)NULL)
  2225.       {
  2226.        wmove(CURRENT_WINDOW_COMMAND,0,0);
  2227.        my_wclrtoeol(CURRENT_WINDOW_COMMAND);
  2228.       }
  2229.     memset(cmd_rec,' ',max_line_length);
  2230.     cmd_rec_len = 0;
  2231.   }
  2232. #ifdef TRACE
  2233.  trace_return();
  2234. #endif
  2235.  return(rc);
  2236. }
  2237. /*man-start*********************************************************************
  2238. COMMAND
  2239.      sos rightedge - move cursor to right edge of window
  2240.  
  2241. SYNTAX
  2242.      SOS RIGHTEdge
  2243.  
  2244. DESCRIPTION
  2245.      The SOS RIGHTEDGE command moves the cursor to the rightmost edge
  2246.      of the <filearea> if not on the command line or to the rightmost
  2247.      edge of the command line if on the <command line>.
  2248.  
  2249. COMPATIBILITY
  2250.      XEDIT: N/A
  2251.      KEDIT: Compatible
  2252.  
  2253. SEE ALSO
  2254.      <SOS LEFTEDGE>, <SOS PREFIX>
  2255.  
  2256. STATUS
  2257.      Complete.
  2258. **man-end**********************************************************************/
  2259. #ifdef HAVE_PROTO
  2260. short Sos_rightedge(CHARTYPE *params)
  2261. #else
  2262. short Sos_rightedge(params)
  2263. CHARTYPE *params;
  2264. #endif
  2265. /***********************************************************************/
  2266. {
  2267. /*-------------------------- external data ----------------------------*/
  2268. /*--------------------------- local data ------------------------------*/
  2269.  short rc=RC_OK;
  2270.  unsigned short y=0,x=0;
  2271. /*--------------------------- processing ------------------------------*/
  2272. #ifdef TRACE
  2273.  trace_function("commsos.c: Sos_rightedge");
  2274. #endif
  2275.  getyx(CURRENT_WINDOW,y,x);
  2276.  if (CURRENT_VIEW->current_window == WINDOW_PREFIX)
  2277.     CURRENT_VIEW->current_window = WINDOW_FILEAREA;
  2278.  x = getmaxx(CURRENT_WINDOW)-1;
  2279.  wmove(CURRENT_WINDOW,y,x);
  2280. #ifdef TRACE
  2281.  trace_return();
  2282. #endif
  2283.  return(rc);
  2284. }
  2285. /*man-start*********************************************************************
  2286. COMMAND
  2287.      sos settab - set a tab column at the cursor position
  2288.  
  2289. SYNTAX
  2290.      SOS SETTAB
  2291.  
  2292. DESCRIPTION
  2293.      The SOS SETTAB command sets a tab column at the position of the
  2294.      cursor in the <filearea>.  This command is ignored if issued 
  2295.      elsewhere.
  2296.      If a tab column is already set at the cursor position, the tab 
  2297.      column is cleared.
  2298.  
  2299. COMPATIBILITY
  2300.      XEDIT: N/A
  2301.      KEDIT: Kedit does not toggle the tab column, but only sets it.
  2302.  
  2303. SEE ALSO
  2304.      <SET TABS>
  2305.  
  2306. STATUS
  2307.      Complete.
  2308. **man-end**********************************************************************/
  2309. #ifdef HAVE_PROTO
  2310. short Sos_settab(CHARTYPE *params)
  2311. #else
  2312. short Sos_settab(params)
  2313. CHARTYPE *params;
  2314. #endif
  2315. /***********************************************************************/
  2316. {
  2317. #define SETTAB_INSERT 0
  2318. #define SETTAB_APPEND 1
  2319. #define SETTAB_REMOVE 2
  2320. /*-------------------------- external data ----------------------------*/
  2321.  extern LENGTHTYPE rec_len;
  2322.  extern unsigned short cmd_rec_len;
  2323.  extern unsigned short pre_rec_len;
  2324. /*--------------------------- local data ------------------------------*/
  2325.  unsigned short x=0,y=0;
  2326.  short rc=RC_OK;
  2327.  LENGTHTYPE col=0;
  2328.  LENGTHTYPE max_tab_col=0;
  2329.  int action=SETTAB_INSERT;
  2330.  int i=0,j=0;
  2331. /*--------------------------- processing ------------------------------*/
  2332. #ifdef TRACE
  2333.  trace_function("commsos.c: Sos_settab");
  2334. #endif
  2335.  if (CURRENT_VIEW->current_window != WINDOW_FILEAREA)
  2336.    {
  2337. #ifdef TRACE
  2338.     trace_return();
  2339. #endif
  2340.     return(rc);
  2341.    }
  2342.  getyx(CURRENT_WINDOW,y,x);
  2343.  col = x + CURRENT_VIEW->verify_col;
  2344.  for (i=0;i<CURRENT_VIEW->numtabs;i++)
  2345.    {
  2346.     if (CURRENT_VIEW->tabs[i] == col)
  2347.       {
  2348.        action = SETTAB_REMOVE;
  2349.        break;
  2350.       }
  2351.     if (max_tab_col < CURRENT_VIEW->tabs[i])
  2352.        max_tab_col = CURRENT_VIEW->tabs[i];
  2353.    }
  2354.  if (action != SETTAB_REMOVE
  2355.  &&  col > max_tab_col)
  2356.     action = SETTAB_APPEND;
  2357.  
  2358.  switch(action)
  2359.    {
  2360.     case SETTAB_REMOVE:
  2361.          for (i=0,j=0;i<CURRENT_VIEW->numtabs;i++,j++)
  2362.            {
  2363.             if (CURRENT_VIEW->tabs[i] == col)
  2364.                j++;
  2365.             if (j < CURRENT_VIEW->numtabs)
  2366.                CURRENT_VIEW->tabs[i] = CURRENT_VIEW->tabs[j];
  2367.            }
  2368.          CURRENT_VIEW->numtabs--;
  2369.          CURRENT_VIEW->tabsinc = 0;
  2370.          break;
  2371.     case SETTAB_APPEND:
  2372.          if (CURRENT_VIEW->numtabs < MAX_NUMTABS)
  2373.            {
  2374.             CURRENT_VIEW->tabs[CURRENT_VIEW->numtabs] = col;
  2375.             CURRENT_VIEW->numtabs++;
  2376.             CURRENT_VIEW->tabsinc = 0;
  2377.            }
  2378.          else
  2379.            {
  2380.             display_error(79,(CHARTYPE *)"",FALSE);
  2381.             rc = RC_INVALID_ENVIRON;
  2382.            }
  2383.          break;
  2384.     default:
  2385.          if (CURRENT_VIEW->numtabs < MAX_NUMTABS)
  2386.            {
  2387.             for (i=0;i<CURRENT_VIEW->numtabs;i++)
  2388.               {
  2389.                if (col < CURRENT_VIEW->tabs[i])
  2390.                  {
  2391.                   for (j=CURRENT_VIEW->numtabs-1;j>i;j--)
  2392.                      CURRENT_VIEW->tabs[j] = CURRENT_VIEW->tabs[j-1];
  2393.                   CURRENT_VIEW->tabs[i] = col;
  2394.                   break;
  2395.                  }
  2396.               }
  2397.             CURRENT_VIEW->numtabs++;
  2398.             CURRENT_VIEW->tabsinc = 0;
  2399.            }
  2400.          else
  2401.            {
  2402.             display_error(79,(CHARTYPE *)"",FALSE);
  2403.             rc = RC_INVALID_ENVIRON;
  2404.            }
  2405.           break;
  2406.    }
  2407.  build_screen(current_screen);
  2408.  display_screen(current_screen);
  2409. #ifdef TRACE
  2410.  trace_return();
  2411. #endif
  2412.  return(rc);
  2413. }
  2414. /*man-start*********************************************************************
  2415. COMMAND
  2416.      sos startendchar - move cursor to end/start of focus line
  2417.  
  2418. SYNTAX
  2419.      SOS STARTENDChar
  2420.  
  2421. DESCRIPTION
  2422.      The SOS STARTENDCHAR command moves the cursor to the first character
  2423.      displayed in the <cursor field>, if the cursor is after the last
  2424.      character displayed in the <cursor field>, or to the position after
  2425.      the last character displayed in the <cursor field>, if the cursor is
  2426.      anywhere else.
  2427.  
  2428. COMPATIBILITY
  2429.      XEDIT: N/A
  2430.      KEDIT: N/A
  2431.  
  2432. SEE ALSO
  2433.      <SOS ENDCHAR>
  2434.  
  2435. STATUS
  2436.      Complete.
  2437. **man-end**********************************************************************/
  2438. #ifdef HAVE_PROTO
  2439. short Sos_startendchar(CHARTYPE *params)
  2440. #else
  2441. short Sos_startendchar(params)
  2442. CHARTYPE *params;
  2443. #endif
  2444. /***********************************************************************/
  2445. {
  2446. /*-------------------------- external data ----------------------------*/
  2447.  extern LENGTHTYPE rec_len;
  2448.  extern unsigned short cmd_rec_len;
  2449.  extern unsigned short pre_rec_len;
  2450. /*--------------------------- local data ------------------------------*/
  2451.  unsigned short x=0,y=0;
  2452.  short rc=RC_OK;
  2453.  short offl=0;
  2454. /*--------------------------- processing ------------------------------*/
  2455. #ifdef TRACE
  2456.  trace_function("commsos.c: Sos_startendchar");
  2457. #endif
  2458.  getyx(CURRENT_WINDOW,y,x);
  2459.  switch(CURRENT_VIEW->current_window)
  2460.    {
  2461.     case WINDOW_PREFIX:
  2462.          if (x >= pre_rec_len)
  2463.             wmove(CURRENT_WINDOW,y,0);
  2464.          else
  2465.             wmove(CURRENT_WINDOW,y,pre_rec_len);
  2466.          break;
  2467.     case WINDOW_COMMAND:
  2468.          if (x >= cmd_rec_len)
  2469.             wmove(CURRENT_WINDOW,y,0);
  2470.          else
  2471.             wmove(CURRENT_WINDOW,y,cmd_rec_len);
  2472.          break;
  2473.     case WINDOW_FILEAREA:
  2474.          if (x + CURRENT_VIEW->verify_col > min(rec_len,CURRENT_VIEW->verify_end))
  2475.             rc = Sos_firstcol((CHARTYPE *)"");
  2476.          else
  2477.             rc = Sos_endchar((CHARTYPE *)"");
  2478.          break;
  2479.    }
  2480. #ifdef TRACE
  2481.  trace_return();
  2482. #endif
  2483.  return(rc);
  2484. }
  2485. /*man-start*********************************************************************
  2486. COMMAND
  2487.      sos tabb - move cursor to previous tab stop
  2488.  
  2489. SYNTAX
  2490.      SOS TABB
  2491.  
  2492. DESCRIPTION
  2493.      The SOS TABB command causes the cursor to move to the previous tab
  2494.      column as set by the <SET TABS> command.
  2495.      If the resulting column is beyond the left hand edge of the main
  2496.      window, the window will scroll half a window.
  2497.  
  2498. COMPATIBILITY
  2499.      XEDIT: Does not allow arguments.
  2500.      KEDIT: Compatible. See below.
  2501.      Does not line tab to next line if before the left hand tab column.
  2502.  
  2503. SEE ALSO
  2504.      <SET TABS>, <SOS TABF>
  2505.  
  2506. STATUS
  2507.      Complete.
  2508. **man-end**********************************************************************/
  2509. #ifdef HAVE_PROTO
  2510. short Sos_tabb(CHARTYPE *params)
  2511. #else
  2512. short Sos_tabb(params)
  2513. CHARTYPE *params;
  2514. #endif
  2515. /***********************************************************************/
  2516. {
  2517. /*-------------------------- external data ----------------------------*/
  2518. /*--------------------------- local data ------------------------------*/
  2519.  unsigned short x=0,y=0;
  2520.  LENGTHTYPE prev_tab_col=0,current_col=0;
  2521.  COLTYPE new_screen_col=0;
  2522.  LENGTHTYPE new_verify_col=0;
  2523.  short rc=RC_OK;
  2524. /*--------------------------- processing ------------------------------*/
  2525. #ifdef TRACE
  2526.  trace_function("commsos.c: Sos_tabb");
  2527. #endif
  2528.  getyx(CURRENT_WINDOW,y,x);
  2529. /*---------------------------------------------------------------------*/
  2530. /* Determine action depending on current window...                     */
  2531. /*---------------------------------------------------------------------*/
  2532.  switch(CURRENT_VIEW->current_window)
  2533.    {
  2534.     case WINDOW_PREFIX:
  2535. #ifdef TRACE
  2536.          trace_return();
  2537. #endif
  2538.          return(RC_OK);
  2539.          break;
  2540.     case WINDOW_FILEAREA:
  2541.          current_col = x+CURRENT_VIEW->verify_col;
  2542.          break;
  2543.     case WINDOW_COMMAND:
  2544.          current_col = x+1;
  2545.          break;
  2546.    }
  2547. /*---------------------------------------------------------------------*/
  2548. /* First determine the next tab stop column...                         */
  2549. /*---------------------------------------------------------------------*/
  2550.  prev_tab_col = find_prev_tab_col(current_col);
  2551. /*---------------------------------------------------------------------*/
  2552. /* If no prev tab column, stay where we are and return...              */
  2553. /*---------------------------------------------------------------------*/
  2554.  if (prev_tab_col == 0)
  2555.    {
  2556. #ifdef TRACE
  2557.     trace_return();
  2558. #endif
  2559.     return(RC_OK);
  2560.    }
  2561. /*---------------------------------------------------------------------*/
  2562. /* For all windows, if the new cursor position does not exceed the     */
  2563. /* right edge, move there.                                             */
  2564. /*---------------------------------------------------------------------*/
  2565.  prev_tab_col--;                               /* zero base the column */
  2566.  
  2567. #ifdef VERSHIFT
  2568.  rc = execute_move_cursor(prev_tab_col);
  2569. #else
  2570.  calculate_new_column(x,CURRENT_VIEW->verify_col,prev_tab_col,&new_screen_col,&new_verify_col);
  2571.  if (CURRENT_VIEW->verify_col != new_verify_col
  2572.  &&  CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  2573.    {
  2574.     CURRENT_VIEW->verify_col = new_verify_col;
  2575.     build_screen(current_screen); 
  2576.     display_screen(current_screen);
  2577.    }
  2578.  wmove(CURRENT_WINDOW,y,new_screen_col);
  2579. #endif
  2580.  
  2581. #ifdef TRACE
  2582.  trace_return();
  2583. #endif
  2584.  return(rc);
  2585. }
  2586. /*man-start*********************************************************************
  2587. COMMAND
  2588.      sos tabf - move cursor to next tab stop
  2589.  
  2590. SYNTAX
  2591.      SOS TABf
  2592.  
  2593. DESCRIPTION
  2594.      The SOS TABF command causes the cursor to move to the next tab column
  2595.      as set by the <SET TABS> command.
  2596.      If the resulting column is beyond the right hand edge of the main
  2597.      window, the window will scroll half a window.
  2598.  
  2599. COMPATIBILITY
  2600.      XEDIT: Does not allow arguments.
  2601.      KEDIT: Compatible. See below.
  2602.      Does not line tab to next line if after the right hand tab column.
  2603.  
  2604. SEE ALSO
  2605.      <SET TABS>, <SOS TABB>
  2606.  
  2607. STATUS
  2608.      Complete.
  2609. **man-end**********************************************************************/
  2610. #ifdef HAVE_PROTO
  2611. short Sos_tabf(CHARTYPE *params)
  2612. #else
  2613. short Sos_tabf(params)
  2614. CHARTYPE *params;
  2615. #endif
  2616. /***********************************************************************/
  2617. {
  2618. /*-------------------------- external data ----------------------------*/
  2619.  extern bool INSERTMODEx;
  2620.  extern CHARTYPE tabkey_insert,tabkey_overwrite;
  2621. /*--------------------------- local data ------------------------------*/
  2622.  unsigned short x=0,y=0;
  2623.  LENGTHTYPE next_tab_col=0,current_col=0;
  2624.  COLTYPE new_screen_col=0;
  2625.  LENGTHTYPE new_verify_col=0;
  2626.  short rc=RC_OK;
  2627. /*--------------------------- processing ------------------------------*/
  2628. #ifdef TRACE
  2629.  trace_function("commsos.c: Sos_tabf");
  2630. #endif
  2631. /*---------------------------------------------------------------------*/
  2632. /* If the actual tab character is to be display then exit so that      */
  2633. /* editor() can process it as a raw key.                               */
  2634. /* Ignore this test if the parameter 'nochar' is passed.  The command  */
  2635. /* SOS INSTAB is the only way that 'nochar' can be passed.             */
  2636. /*---------------------------------------------------------------------*/
  2637.  if (strcmp((DEFCHAR*)params,"nochar") != 0)
  2638.    {
  2639.     if (INSERTMODEx && tabkey_insert == 'C')
  2640.       {
  2641. #ifdef TRACE
  2642.        trace_return();
  2643. #endif
  2644.        return(RAW_KEY);
  2645.       }
  2646.     if (!INSERTMODEx && tabkey_overwrite == 'C')
  2647.       {
  2648. #ifdef TRACE
  2649.        trace_return();
  2650. #endif
  2651.        return(RAW_KEY);
  2652.       }
  2653.    }
  2654.  getyx(CURRENT_WINDOW,y,x);
  2655. /*---------------------------------------------------------------------*/
  2656. /* Determine action depending on current window...                     */
  2657. /*---------------------------------------------------------------------*/
  2658.  switch(CURRENT_VIEW->current_window)
  2659.    {
  2660.     case WINDOW_PREFIX:
  2661. #ifdef TRACE
  2662.          trace_return();
  2663. #endif
  2664.          return(RC_OK);
  2665.          break;
  2666.     case WINDOW_FILEAREA:
  2667.          current_col = x+CURRENT_VIEW->verify_col;
  2668.          break;
  2669.     case WINDOW_COMMAND:
  2670.          current_col = x+1;
  2671.          break;
  2672.    }
  2673. /*---------------------------------------------------------------------*/
  2674. /* First determine the next tab stop column...                         */
  2675. /*---------------------------------------------------------------------*/
  2676.  next_tab_col = find_next_tab_col(current_col);
  2677. /*---------------------------------------------------------------------*/
  2678. /* If no next tab column, stay where we are and return...              */
  2679. /*---------------------------------------------------------------------*/
  2680.  if (next_tab_col == 0)
  2681.    {
  2682. #ifdef TRACE
  2683.     trace_return();
  2684. #endif
  2685.     return(RC_OK);
  2686.    }
  2687. /*---------------------------------------------------------------------*/
  2688. /* Check for going past end of line - max_line_length                  */
  2689. /*---------------------------------------------------------------------*/
  2690.  if (next_tab_col > max_line_length)
  2691.    {
  2692. #ifdef TRACE
  2693.     trace_return();
  2694. #endif
  2695.     return(RC_TRUNCATED);
  2696.    }
  2697. /*---------------------------------------------------------------------*/
  2698. /* For all windows, if the new cursor position does not exceed the     */
  2699. /* right edge, move there.                                             */
  2700. /*---------------------------------------------------------------------*/
  2701.  next_tab_col--;                               /* zero base the column */
  2702.  
  2703. #ifdef VERSHIFT
  2704.  rc = execute_move_cursor(next_tab_col);
  2705. #else
  2706.  calculate_new_column(x,CURRENT_VIEW->verify_col,next_tab_col,&new_screen_col,&new_verify_col);
  2707.  if (CURRENT_VIEW->verify_col != new_verify_col
  2708.  &&  CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  2709.    {
  2710.     CURRENT_VIEW->verify_col = new_verify_col;
  2711.     build_screen(current_screen); 
  2712.     display_screen(current_screen);
  2713.    }
  2714.  wmove(CURRENT_WINDOW,y,new_screen_col);
  2715. #endif
  2716.  
  2717. #ifdef TRACE
  2718.  trace_return();
  2719. #endif
  2720.  return(rc);
  2721. }
  2722. /*man-start*********************************************************************
  2723. COMMAND
  2724.      sos tabfieldb - move cursor to previous enterable field
  2725.  
  2726. SYNTAX
  2727.      SOS TABFIELDB
  2728.  
  2729. DESCRIPTION
  2730.      The SOS TABFIELDB command causes the cursor to move to the first
  2731.      column of the current enterable field. If the cursor is already
  2732.      in the first column of the current field the cursor moves to the
  2733.      first column of the previous enterable field on the screen. 
  2734.      This command is intended to mimic the behaviour of the SHIFT-TAB 
  2735.      key on a 3270 terminal.
  2736.  
  2737. COMPATIBILITY
  2738.      XEDIT: N/A
  2739.      KEDIT: Compatible.
  2740.  
  2741. SEE ALSO
  2742.      <SOS TABFIELDF>
  2743.  
  2744. STATUS
  2745.      Complete.
  2746. **man-end**********************************************************************/
  2747. #ifdef HAVE_PROTO
  2748. short Sos_tabfieldb(CHARTYPE *params)
  2749. #else
  2750. short Sos_tabfieldb(params)
  2751. CHARTYPE *params;
  2752. #endif
  2753. /***********************************************************************/
  2754. {
  2755. /*-------------------------- external data ----------------------------*/
  2756. /*--------------------------- local data ------------------------------*/
  2757.  short rc=RC_OK;
  2758.  long save_where=0L,where=0L,what_current=0L,what_other=0L;
  2759.  unsigned short y=0,x=0,left_col=0;
  2760.  bool stay_in_current_field=FALSE;
  2761. /*--------------------------- processing ------------------------------*/
  2762. #ifdef TRACE
  2763.  trace_function("commsos.c: Sos_tabfieldb");
  2764. #endif
  2765. /*---------------------------------------------------------------------*/
  2766. /* Determine if the cursor is in the left-most column of the current   */
  2767. /* field...                                                            */
  2768. /*---------------------------------------------------------------------*/
  2769.  getyx(CURRENT_WINDOW,y,x);
  2770. #if 0
  2771.  switch(CURRENT_VIEW->current_window)
  2772.    {
  2773.     case WINDOW_FILEAREA:
  2774.     case WINDOW_COMMAND:
  2775.          if (x != left_col)
  2776.             stay_in_current_field = TRUE;
  2777.          break;
  2778.     case WINDOW_PREFIX:
  2779.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) == PREFIX_RIGHT)
  2780.             left_col = CURRENT_VIEW->prefix_gap;
  2781.          else
  2782.             left_col = 0;
  2783.          if (x != left_col)
  2784.             stay_in_current_field = TRUE;
  2785.          break;
  2786.    }
  2787. #else
  2788.  if (x != left_col)
  2789.     stay_in_current_field = TRUE;
  2790. #endif
  2791. /*---------------------------------------------------------------------*/
  2792. /* If the cursor was not in the left-most column of the current field, */
  2793. /* move it there now...                                                */
  2794. /*---------------------------------------------------------------------*/
  2795.  if (stay_in_current_field)
  2796.    {
  2797.     wmove(CURRENT_WINDOW,y,left_col);
  2798. #ifdef TRACE
  2799.     trace_return();
  2800. #endif
  2801.     return(rc);
  2802.    }
  2803. /*---------------------------------------------------------------------*/
  2804. /* ... otherwise determine which is the previous enterable filed and   */
  2805. /* move the cursor there.                                              */
  2806. /*---------------------------------------------------------------------*/
  2807.  save_where = where = where_now();
  2808.  what_current = what_current_now();
  2809.  what_other = what_other_now();
  2810.  while(1)
  2811.    {
  2812.     where = where_before(where,what_current,what_other);
  2813.     if (where == save_where)
  2814.        break;
  2815.     if (enterable_field(where))
  2816.        break;
  2817.    }
  2818. /*---------------------------------------------------------------------*/
  2819. /* If we can't go anywhere, stay where we are...                       */
  2820. /*---------------------------------------------------------------------*/
  2821.  if (where == save_where)
  2822.    {
  2823. #ifdef TRACE
  2824.     trace_return();
  2825. #endif
  2826.     return(rc);
  2827.    }
  2828.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  2829.  rc = go_to_new_field(save_where,where);
  2830.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  2831. #ifdef TRACE
  2832.  trace_return();
  2833. #endif
  2834.  return(rc);
  2835. }
  2836. /*man-start*********************************************************************
  2837. COMMAND
  2838.      sos tabfieldf - move cursor to next enterable field
  2839.  
  2840. SYNTAX
  2841.      SOS TABFIELDf
  2842.  
  2843. DESCRIPTION
  2844.      The SOS TABFIELDF command causes the cursor to move to the next 
  2845.      enterable field on the screen. This command is intended to
  2846.      mimic the behaviour of the TAB key on a 3270 terminal.
  2847.  
  2848. COMPATIBILITY
  2849.      XEDIT: N/A
  2850.      KEDIT: Compatible.
  2851.  
  2852. SEE ALSO
  2853.      <SOS TABFIELDB>
  2854.  
  2855. STATUS
  2856.      Complete.
  2857. **man-end**********************************************************************/
  2858. #ifdef HAVE_PROTO
  2859. short Sos_tabfieldf(CHARTYPE *params)
  2860. #else
  2861. short Sos_tabfieldf(params)
  2862. CHARTYPE *params;
  2863. #endif
  2864. /***********************************************************************/
  2865. {
  2866. /*-------------------------- external data ----------------------------*/
  2867. /*--------------------------- local data ------------------------------*/
  2868.  short rc=RC_OK;
  2869.  long save_where=0L,where=0L,what_current=0L,what_other=0L;
  2870. /*--------------------------- processing ------------------------------*/
  2871. #ifdef TRACE
  2872.  trace_function("commsos.c: Sos_tabfieldf");
  2873. #endif
  2874.  save_where = where = where_now();
  2875.  what_current = what_current_now();
  2876.  what_other = what_other_now();
  2877.  while(1)
  2878.    {
  2879.     where = where_next(where,what_current,what_other);
  2880.     if (where == save_where)
  2881.        break;
  2882.     if (enterable_field(where))
  2883.        break;
  2884.    }
  2885. /*---------------------------------------------------------------------*/
  2886. /* If we can't go anywhere, stay where we are...                       */
  2887. /*---------------------------------------------------------------------*/
  2888.  if (where == save_where)
  2889.    {
  2890. #ifdef TRACE
  2891.     trace_return();
  2892. #endif
  2893.     return(rc);
  2894.    }
  2895.  post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  2896.  rc = go_to_new_field(save_where,where);
  2897.  pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  2898. #ifdef TRACE
  2899.  trace_return();
  2900. #endif
  2901.  return(rc);
  2902. }
  2903. /*man-start*********************************************************************
  2904. COMMAND
  2905.      sos tabwordb - move cursor to beginning of previous word
  2906.  
  2907. SYNTAX
  2908.      SOS TABWORDB
  2909.  
  2910. DESCRIPTION
  2911.      The SOS TABWORDB command causes the cursor to move to the first 
  2912.      character of the word to the left or to the start of the line if 
  2913.      no more words precede.
  2914.      If the resulting column is beyond the left hand edge of the 
  2915.      <filearea>, the window will scroll half a window.
  2916.  
  2917. COMPATIBILITY
  2918.      XEDIT: N/A
  2919.      KEDIT: Compatible.
  2920.  
  2921. SEE ALSO
  2922.      <SOS TABWORDF>
  2923.  
  2924. STATUS
  2925.      Complete.
  2926. **man-end**********************************************************************/
  2927. #ifdef HAVE_PROTO
  2928. short Sos_tabwordb(CHARTYPE *params)
  2929. #else
  2930. short Sos_tabwordb(params)
  2931. CHARTYPE *params;
  2932. #endif
  2933. /***********************************************************************/
  2934. {
  2935. /*-------------------------- external data ----------------------------*/
  2936.  extern CHARTYPE *rec;
  2937.  extern CHARTYPE *cmd_rec;
  2938. /*--------------------------- local data ------------------------------*/
  2939.  unsigned short x=0,y=0;
  2940.  short start_word_col=0;
  2941.  unsigned short word_break=0;
  2942.  CHARTYPE *temp_rec=NULL;
  2943.  register short i=0;
  2944.  short left_col=0;
  2945.  COLTYPE new_screen_col=0;
  2946.  LENGTHTYPE new_verify_col=0;
  2947.  short rc=RC_OK;
  2948. /*--------------------------- processing ------------------------------*/
  2949. #ifdef TRACE
  2950.  trace_function("commsos.c: Sos_tabwordb");
  2951. #endif
  2952. /*---------------------------------------------------------------------*/
  2953. /* This function is not applicable to the PREFIX window.               */
  2954. /*---------------------------------------------------------------------*/
  2955.  getyx(CURRENT_WINDOW,y,x);
  2956.  switch(CURRENT_VIEW->current_window)
  2957.    {
  2958.     case WINDOW_PREFIX:
  2959.          display_error(38,(CHARTYPE *)"",FALSE);
  2960. #ifdef TRACE
  2961.          trace_return();
  2962. #endif
  2963.          return(RC_INVALID_ENVIRON);
  2964.          break;
  2965.     case WINDOW_FILEAREA:
  2966.          temp_rec = rec;
  2967.          left_col = CURRENT_VIEW->verify_col-1;
  2968.          break;
  2969.     case WINDOW_COMMAND:
  2970.          temp_rec = (CHARTYPE *)cmd_rec;
  2971.          left_col = 0;
  2972.          break;
  2973.    }
  2974. /*---------------------------------------------------------------------*/
  2975. /* Determine the start of the prior word, or go to the start of the    */
  2976. /* line if already at or before beginning of prior word.               */
  2977. /*---------------------------------------------------------------------*/
  2978.  word_break = 0;
  2979.  start_word_col = (-1);
  2980.  for (i=left_col+x;i>(-1);i--)
  2981.    {
  2982.     switch(word_break)
  2983.       {
  2984.        case 0:  /* still in current word */
  2985.             if (*(temp_rec+i) == ' ')
  2986.                word_break++;
  2987.             break;
  2988.        case 1:  /* in first blank space */
  2989.             if (*(temp_rec+i) != ' ')
  2990.                word_break++;
  2991.             break;
  2992.        case 2:  /* in previous word */
  2993.             if (*(temp_rec+i) == ' ')
  2994.               {
  2995.                start_word_col = i+1;
  2996.                word_break++;
  2997.               }
  2998.             break;
  2999.        default: /* should not get here */
  3000.             break;
  3001.       }
  3002.     if (word_break == 3)
  3003.        break;
  3004.    }
  3005.  if (start_word_col == (-1))
  3006.     start_word_col = 0;
  3007.  
  3008. #ifdef VERSHIFT
  3009.  rc = execute_move_cursor(start_word_col);
  3010. #else
  3011.  calculate_new_column(x,CURRENT_VIEW->verify_col,start_word_col,&new_screen_col,&new_verify_col);
  3012.  if (CURRENT_VIEW->verify_col != new_verify_col
  3013.  &&  CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  3014.    {
  3015.     CURRENT_VIEW->verify_col = new_verify_col;
  3016.     build_screen(current_screen); 
  3017.     display_screen(current_screen);
  3018.    }
  3019.  wmove(CURRENT_WINDOW,y,new_screen_col);
  3020. #endif
  3021.  
  3022. #ifdef TRACE
  3023.  trace_return();
  3024. #endif
  3025.  return(rc);
  3026. }
  3027. /*man-start*********************************************************************
  3028. COMMAND
  3029.      sos tabwordf - move cursor to start of next word
  3030.  
  3031. SYNTAX
  3032.      SOS TABWORDf
  3033.  
  3034. DESCRIPTION
  3035.      The SOS TABWORDF command causes the cursor to move to the first 
  3036.      character of the next word to the right or to the end of the line 
  3037.      if no more words follow.
  3038.      If the resulting column is beyond the right hand edge of the
  3039.      <filearea>, the window will scroll half a window.
  3040.  
  3041. COMPATIBILITY
  3042.      XEDIT: N/A
  3043.      KEDIT: Compatible.
  3044.  
  3045. SEE ALSO
  3046.      <SOS TABWORDB>
  3047.  
  3048. STATUS
  3049.      Complete.
  3050. **man-end**********************************************************************/
  3051. #ifdef HAVE_PROTO
  3052. short Sos_tabwordf(CHARTYPE *params)
  3053. #else
  3054. short Sos_tabwordf(params)
  3055. CHARTYPE *params;
  3056. #endif
  3057. /***********************************************************************/
  3058. {
  3059. /*-------------------------- external data ----------------------------*/
  3060.  extern CHARTYPE *rec;
  3061.  extern LENGTHTYPE rec_len;
  3062.  extern CHARTYPE *cmd_rec;
  3063.  extern unsigned short cmd_rec_len;
  3064. /*--------------------------- local data ------------------------------*/
  3065.  unsigned short x=0,y=0,temp_rec_len=0;
  3066.  short start_word_col=0,left_col=0;
  3067.  bool word_break=FALSE;
  3068.  CHARTYPE *temp_rec=NULL;
  3069.  register short i=0;
  3070.  COLTYPE new_screen_col=0;
  3071.  LENGTHTYPE new_verify_col=0;
  3072.  short rc=RC_OK;
  3073. /*--------------------------- processing ------------------------------*/
  3074. #ifdef TRACE
  3075.  trace_function("commsos.c: Sos_tabwordf");
  3076. #endif
  3077. /*---------------------------------------------------------------------*/
  3078. /* This function is not applicable to the PREFIX window.               */
  3079. /*---------------------------------------------------------------------*/
  3080.  getyx(CURRENT_WINDOW,y,x);
  3081.  switch(CURRENT_VIEW->current_window)
  3082.    {
  3083.     case WINDOW_PREFIX:
  3084.          display_error(38,(CHARTYPE *)"",FALSE);
  3085. #ifdef TRACE
  3086.          trace_return();
  3087. #endif
  3088.          return(RC_INVALID_ENVIRON);
  3089.          break;
  3090.     case WINDOW_FILEAREA:
  3091.          temp_rec = rec;
  3092.          temp_rec_len = rec_len;
  3093.          left_col = CURRENT_VIEW->verify_col-1;
  3094.          break;
  3095.     case WINDOW_COMMAND:
  3096.          temp_rec = (CHARTYPE *)cmd_rec;
  3097.          temp_rec_len = cmd_rec_len;
  3098.          left_col = 0;
  3099.          break;
  3100.    }
  3101. /*---------------------------------------------------------------------*/
  3102. /* If we are after the last column of the line, then just ignore the   */
  3103. /* command and leave the cursor where it is.                           */
  3104. /*---------------------------------------------------------------------*/
  3105.  if ((x + left_col) > temp_rec_len)
  3106.    {
  3107. #ifdef TRACE
  3108.     trace_return();
  3109. #endif
  3110.     return(RC_OK);
  3111.    }
  3112. /*---------------------------------------------------------------------*/
  3113. /* Determine the start of the next word, or go to the end of the line  */
  3114. /* if already at or past beginning of last word.                       */
  3115. /*---------------------------------------------------------------------*/
  3116.  word_break = FALSE;
  3117.  start_word_col = (-1);
  3118.  for (i=left_col+x;i<temp_rec_len;i++)
  3119.    {
  3120.     if (*(temp_rec+i) == ' ')
  3121.        word_break = TRUE;
  3122.     else
  3123.       {
  3124.        if (word_break)
  3125.          {
  3126.           start_word_col = i;
  3127.           break;
  3128.          }
  3129.       }
  3130.    }
  3131.  if (start_word_col == (-1))
  3132.     start_word_col = temp_rec_len;
  3133.  
  3134. #ifdef VERSHIFT
  3135.  rc = execute_move_cursor(start_word_col);
  3136. #else
  3137.  calculate_new_column(x,CURRENT_VIEW->verify_col,start_word_col,&new_screen_col,&new_verify_col);
  3138.  if (CURRENT_VIEW->verify_col != new_verify_col
  3139.  &&  CURRENT_VIEW->current_window == WINDOW_FILEAREA)
  3140.    {
  3141.     CURRENT_VIEW->verify_col = new_verify_col;
  3142.     build_screen(current_screen); 
  3143.     display_screen(current_screen);
  3144.    }
  3145.  wmove(CURRENT_WINDOW,y,new_screen_col);
  3146. #endif
  3147.  
  3148. #ifdef TRACE
  3149.  trace_return();
  3150. #endif
  3151.  return(rc);
  3152. }
  3153. /*man-start*********************************************************************
  3154. COMMAND
  3155.      sos topedge - move cursor to top edge of filearea
  3156.  
  3157. SYNTAX
  3158.      SOS TOPEdge
  3159.  
  3160. DESCRIPTION
  3161.      The SOS TOPEDGE command moves the cursor to the first enterable
  3162.      line in the <filearea> or <prefix area>. If the cursor is on the 
  3163.      <command line>, the cursor moves to the first enterable line of 
  3164.      the <filearea>.
  3165.  
  3166. COMPATIBILITY
  3167.      XEDIT: N/A
  3168.      KEDIT: Comaptible.
  3169.  
  3170. SEE ALSO
  3171.      <SOS BOTTOMEDGE>
  3172.  
  3173. STATUS
  3174.      Complete.
  3175. **man-end**********************************************************************/
  3176. #ifdef HAVE_PROTO
  3177. short Sos_topedge(CHARTYPE *params)
  3178. #else
  3179. short Sos_topedge(params)
  3180. CHARTYPE *params;
  3181. #endif
  3182. /***********************************************************************/
  3183. {
  3184. /*-------------------------- external data ----------------------------*/
  3185. /*--------------------------- local data ------------------------------*/
  3186.  short rc=RC_OK;
  3187.  unsigned short y=0,x=0,row=0;
  3188. /*--------------------------- processing ------------------------------*/
  3189. #ifdef TRACE
  3190.  trace_function("commsos.c: Sos_topedge");
  3191. #endif
  3192.  getyx(CURRENT_WINDOW,y,x);
  3193. /*---------------------------------------------------------------------*/
  3194. /* Get the last enterable row. If an error, stay where we are...       */
  3195. /*---------------------------------------------------------------------*/
  3196.  if (find_first_focus_line(&row) != RC_OK)
  3197.    {
  3198. #ifdef TRACE
  3199.     trace_return();
  3200. #endif
  3201.     return(rc);
  3202.    }
  3203. /*---------------------------------------------------------------------*/
  3204. /* For each window determine what needs to be done...                  */
  3205. /*---------------------------------------------------------------------*/
  3206.  switch(CURRENT_VIEW->current_window)
  3207.    {
  3208.     case WINDOW_COMMAND:
  3209.          if ((CURRENT_VIEW->prefix&PREFIX_LOCATION_MASK) != PREFIX_LEFT)
  3210.             x += CURRENT_VIEW->prefix_width;
  3211.          CURRENT_VIEW->focus_line = CURRENT_SCREEN.sl[row].line_number;
  3212.          pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  3213.          CURRENT_VIEW->current_window = WINDOW_FILEAREA;
  3214.          wmove(CURRENT_WINDOW,row,x);
  3215.          break;
  3216.     case WINDOW_FILEAREA:
  3217.     case WINDOW_PREFIX:
  3218.             if (row != y)                            /* different rows */
  3219.               {
  3220.                post_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL,TRUE);
  3221.                CURRENT_VIEW->focus_line = CURRENT_SCREEN.sl[row].line_number;
  3222.                pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  3223.                wmove(CURRENT_WINDOW,row,x);
  3224.               }
  3225.             break;
  3226.    }
  3227. #ifdef TRACE
  3228.  trace_return();
  3229. #endif
  3230.  return(rc);
  3231. }
  3232. /*man-start*********************************************************************
  3233. COMMAND
  3234.      sos undo - undo changes to the current line
  3235.  
  3236. SYNTAX
  3237.      SOS UNDO
  3238.  
  3239. DESCRIPTION
  3240.      The SOS UNDO command causes the contents of the <focus line> (or the
  3241.      <command line>) to be reset to the contents before the cursor was
  3242.      positioned there.
  3243.  
  3244. COMPATIBILITY
  3245.      XEDIT: N/A
  3246.      KEDIT: Compatible. 
  3247.  
  3248. STATUS
  3249.      Complete.
  3250. **man-end**********************************************************************/
  3251. #ifdef HAVE_PROTO
  3252. short Sos_undo(CHARTYPE *params)
  3253. #else
  3254. short Sos_undo(params)
  3255. CHARTYPE *params;
  3256. #endif
  3257. /***********************************************************************/
  3258. {
  3259. /*-------------------------- external data ----------------------------*/
  3260.  extern CHARTYPE *cmd_rec;
  3261.  extern unsigned short cmd_rec_len;
  3262.  extern CHARTYPE *pre_rec;
  3263.  extern unsigned short pre_rec_len;
  3264.  extern bool prefix_changed;
  3265. /*--------------------------- local data ------------------------------*/
  3266.  unsigned short x=0,y=0;
  3267. /*--------------------------- processing ------------------------------*/
  3268. #ifdef TRACE
  3269.  trace_function("commsos.c: Sos_undo");
  3270. #endif
  3271. /*---------------------------------------------------------------------*/
  3272. /* No arguments are allowed; error if any are present.                 */
  3273. /*---------------------------------------------------------------------*/
  3274.  if (strcmp((DEFCHAR *)params,"") != 0)
  3275.    {
  3276.     display_error(1,(CHARTYPE *)params,FALSE);
  3277. #ifdef TRACE
  3278.     trace_return();
  3279. #endif
  3280.     return(RC_INVALID_OPERAND);
  3281.    }
  3282.  switch (CURRENT_VIEW->current_window)
  3283.    {
  3284.     case WINDOW_FILEAREA:
  3285.          pre_process_line(CURRENT_VIEW,CURRENT_VIEW->focus_line,(LINE *)NULL);
  3286.          build_screen(current_screen); 
  3287.          display_screen(current_screen);
  3288.          break;
  3289.     case WINDOW_COMMAND:
  3290.          memset(cmd_rec,' ',max_line_length);
  3291.          cmd_rec_len = 0;
  3292.          wmove(CURRENT_WINDOW,0,0);
  3293.          my_wclrtoeol(CURRENT_WINDOW);
  3294.          break;
  3295.     case WINDOW_PREFIX:
  3296.          prefix_changed = TRUE;
  3297.          memset(pre_rec,' ',MAX_PREFIX_WIDTH);
  3298.          pre_rec_len = 0;
  3299.          getyx(CURRENT_WINDOW,y,x);
  3300.          wmove(CURRENT_WINDOW,y,0);
  3301.          my_wclrtoeol(CURRENT_WINDOW);
  3302.          break;
  3303.     default:
  3304.          break;
  3305.    }
  3306. #ifdef TRACE
  3307.  trace_return();
  3308. #endif
  3309.  return(RC_OK);
  3310. }
  3311.