home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8710 / vms-vi / 12 < prev    next >
Encoding:
Internet Message Format  |  1990-07-13  |  35.3 KB

  1. Path: uunet!husc6!necntc!ncoast!allbery
  2. From: gregg@a.cs.okstate.edu@mandrill.CWRU.Edu (Gregg Wonderly)
  3. Newsgroups: comp.sources.misc
  4. Subject: VI in TPU part 12/13
  5. Message-ID: <4861@ncoast.UUCP>
  6. Date: 13 Oct 87 02:56:04 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Organization: Oklahoma State Univ., Stillwater
  9. Lines: 1331
  10. Approved: allbery@ncoast.UUCP
  11. X-Archive: comp.sources.misc/8710/vms-vi/12
  12.  
  13. $ WRITE SYS$OUTPUT "Creating ""VI.11"""
  14. $ CREATE VI.11
  15. $ DECK/DOLLARS=$$EOD$$
  16.     file_cnt := loop_cnt;
  17.  
  18.     LOOP
  19.  
  20.         POSITION (obuf);
  21.  
  22.         ! See if we already have a buffer by that name
  23.  
  24.         IF temp_file_name = 0 THEN
  25.             temp_buffer_name :=
  26.                 FILE_PARSE (get_file_name, "", "", NAME) +
  27.                 FILE_PARSE (get_file_name, "", "", TYPE);
  28.         ELSE
  29.             temp_buffer_name :=
  30.                 FILE_PARSE (temp_file_name, "", "", NAME) +
  31.                 FILE_PARSE (temp_file_name, "", "", TYPE);
  32.         ENDIF;
  33.  
  34.         IF get_file_parm <> 0 THEN
  35.  
  36.             !  Trim the trailing dot off.
  37.  
  38.             EDIT (get_file_parm, UPPER, COLLAPSE);
  39.  
  40.             IF (SUBSTR (get_file_parm, LENGTH(get_file_parm), 1)
  41.                                                                 <> '.') THEN
  42.                 IF (SUBSTR (temp_buffer_name,
  43.                                 LENGTH(temp_buffer_name), 1) = '.') THEN
  44.  
  45.                     temp_buffer_name :=
  46.                         SUBSTR (temp_buffer_name, 1,
  47.                                                 LENGTH(temp_buffer_name)-1);
  48.                 ENDIF;
  49.             ENDIF;
  50.         ENDIF;
  51.  
  52.         loop_buffer := GET_INFO (BUFFERS, "FIRST");
  53.         found_a_buffer := 0;
  54.  
  55.         LOOP
  56.             EXITIF loop_buffer = 0;
  57.             IF temp_buffer_name = GET_INFO (loop_buffer, "NAME") THEN
  58.                 found_a_buffer := 1;
  59.                 EXITIF 1;
  60.             ENDIF;
  61.             loop_buffer := GET_INFO (BUFFERS, "NEXT");
  62.         ENDLOOP;
  63.  
  64.         ! If there is a buffer by that name, is it the same file?
  65.         ! We ignore version numbers to keep our sanity
  66.  
  67.         IF found_a_buffer THEN      ! Have a buffer with the same name
  68.             IF temp_file_name = 0 THEN  ! No file on disk
  69.                 IF get_file_name = GET_INFO (loop_buffer, "OUTPUT_FILE") THEN
  70.                     want_new_buffer := 0;
  71.                 ELSE
  72.  
  73.                     !   If the buffer is empty, then throw it
  74.                     !   away.
  75.  
  76.                     IF (GET_INFO (loop_buffer, "RECORD_COUNT") > 0) THEN
  77.                         want_new_buffer := 0;
  78.                     ELSE
  79.                         IF (temp_file_name <> 0) and (temp_file_name <> "") THE
  80. N
  81.                             vi$message ("Buffer empty, reading file");
  82.                             POSITION (loop_buffer);
  83.                             vi$message (FAO ('Reading "!AS"', temp_file_name));
  84.                             file_read := READ_FILE (temp_file_name);
  85.  
  86.                             IF file_read <> "" THEN
  87.                                 SET (OUTPUT_FILE, loop_buffer, file_read);
  88.                                 vi$status_lines (loop_buffer);
  89.                             ENDIF;
  90.                         ENDIF;
  91.  
  92.                         want_new_buffer := 2;
  93.                         POSITION (BEGINNING_OF (loop_buffer));
  94.                         MAP (CURRENT_WINDOW, loop_buffer);
  95.                     ENDIF;
  96.                 ENDIF;
  97.             ELSE
  98.  
  99.                 ! Check to see if the same file
  100.  
  101.                 outfile := GET_INFO (loop_buffer, "OUTPUT_FILE");
  102.                 filename := GET_INFO (loop_buffer, "FILE_NAME");
  103.  
  104.                 !  Trim version numbers off all of the names.
  105.  
  106.                 IF (outfile <> 0) THEN
  107.                     outfile := FILE_PARSE (outfile, "", "", DEVICE) +
  108.                                 FILE_PARSE (outfile, "", "", DIRECTORY) +
  109.                                 FILE_PARSE (outfile, "", "", NAME) +
  110.                                 FILE_PARSE (outfile, "", "", TYPE);
  111.                 ENDIF;
  112.  
  113.                 IF (filename <> 0) THEN
  114.                     filename := FILE_PARSE (filename, "", "", DEVICE) +
  115.                                 FILE_PARSE (filename, "", "", DIRECTORY) +
  116.                                 FILE_PARSE (filename, "", "", NAME) +
  117.                                 FILE_PARSE (filename, "", "", TYPE);
  118.                 ENDIF;
  119.  
  120.                 temp_file_name := FILE_PARSE (temp_file_name, "", "", DEVICE) +
  121.                                 FILE_PARSE (temp_file_name, "", "", DIRECTORY) 
  122. +
  123.                                 FILE_PARSE (temp_file_name, "", "", NAME) +
  124.                                 FILE_PARSE (temp_file_name, "", "", TYPE);
  125.  
  126.                 !   If the buffer is empty, then throw it away.
  127.  
  128.                 IF (GET_INFO (loop_buffer, "RECORD_COUNT") > 0) THEN
  129.                     IF (outfile = temp_file_name) OR
  130.                                             (filename = temp_file_name) THEN
  131.                         want_new_buffer := 0;
  132.                     ELSE
  133.                         want_new_buffer := 1;
  134.                     ENDIF;
  135.                 ELSE
  136.                     IF temp_file_name <> 0 THEN
  137.                         vi$message ("Buffer empty, reading file");
  138.                         POSITION (loop_buffer);
  139.                         vi$message (FAO ('Reading "!AS"', temp_file_name));
  140.                         file_read := READ_FILE (temp_file_name);
  141.                         IF (file_read <> "") THEN
  142.                             SET (OUTPUT_FILE, loop_buffer, file_read);
  143.                             vi$status_lines (loop_buffer);
  144.                         ENDIF;
  145.                     ENDIF;
  146.  
  147.                     want_new_buffer := 2;
  148.                     POSITION (BEGINNING_OF (loop_buffer));
  149.                     MAP (CURRENT_WINDOW, loop_buffer);
  150.                 ENDIF;
  151.             ENDIF;
  152.  
  153.             IF want_new_buffer = 1 THEN
  154.  
  155.                 vi$message (FAO (
  156.                             "Buffer name !AS is in use", temp_buffer_name));
  157.  
  158.                 temp_buffer_name :=
  159.                     vi$read_line (
  160.                         "Type new buffer name or press Return to cancel: ");
  161.  
  162.                 IF temp_buffer_name = "" THEN
  163.                     vi$message ("No new buffer created");
  164.                 ELSE
  165.                     new_buffer := vi$_create_buffer (temp_buffer_name,
  166.                                                 get_file_name, temp_file_name);
  167.                 ENDIF;
  168.             ELSE
  169.                 IF (want_new_buffer = 0) and (CURRENT_BUFFER = loop_buffer) THE
  170. N
  171.                     vi$message (FAO (
  172.                                 "Already editing file !AS", get_file_name));
  173.                 ELSE
  174.                     IF (want_new_buffer = 0) THEN
  175.                         vi$check_auto_write;
  176.                         MAP (CURRENT_WINDOW, loop_buffer);
  177.                     ENDIF;
  178.                 ENDIF;
  179.             ENDIF;
  180.         ELSE            ! No buffer with the same name, so create a new buffer
  181.             new_buffer := vi$_create_buffer (temp_buffer_name, get_file_name,
  182.                                                                 temp_file_name)
  183. ;
  184.         ENDIF;
  185.  
  186.         IF new_buffer <> 0 THEN
  187.             SET (EOB_TEXT, new_buffer, "[EOB]");
  188.             SET (TAB_STOPS, new_buffer, vi$tab_amount);
  189.         ENDIF;
  190.  
  191.         loop_cnt := loop_cnt - 1;
  192.  
  193.         EXITIF loop_cnt <= 0;
  194.  
  195.         POSITION (BEGINNING_OF (choice_buffer));
  196.         temp_file_name := vi$current_line;
  197.         ERASE_LINE;
  198.     ENDLOOP;
  199.  
  200.     IF (file_cnt > 1) THEN
  201.         vi$_first_file;
  202.     ENDIF;
  203.  
  204.     vi$set_status_line (CURRENT_WINDOW);
  205.     RETURN (file_cnt);
  206. ENDPROCEDURE;
  207.  
  208. !
  209. !  This procedure collects the names of all buffers that are leading
  210. !  derivatives of "buffer_name".  The function value is the boolean
  211. !  value telling whether or not the name matched exactly.  The other
  212. !  parameters are return values.
  213. !
  214. PROCEDURE vi$choose_buffer (buffer_name, how_many_buffers,
  215.                              possible_buffer, possible_buffer_name, loop_buffer
  216. )
  217.  
  218.     LOCAL
  219.         this_buffer,            ! Current buffer
  220.         loop_buffer_name,       ! String containing name of loop_buffer
  221.         found_a_buffer,         ! True if buffer found with same exact name
  222.         how_many_buffers;       ! Number of buffers listed in possible_names
  223.  
  224.     found_a_buffer := 0;
  225.     EDIT (buffer_name, COLLAPSE);
  226.     possible_buffer := 0;
  227.     possible_buffer_name := 0;
  228.     how_many_buffers := 0;
  229.  
  230.     ! See if we already have a buffer by that name
  231.  
  232.     this_buffer := CURRENT_BUFFER;
  233.     loop_buffer := GET_INFO (BUFFERS, "FIRST");
  234.     CHANGE_CASE (buffer_name, UPPER);   ! buffer names are uppercase
  235.     ERASE (choice_buffer);
  236.  
  237.     LOOP
  238.         EXITIF loop_buffer = 0;
  239.         loop_buffer_name := GET_INFO (loop_buffer, "NAME");
  240.  
  241.         IF buffer_name = loop_buffer_name THEN
  242.             found_a_buffer := 1;
  243.             how_many_buffers := 1;
  244.             EXITIF 1;
  245.         ELSE
  246.             IF buffer_name = SUBSTR (loop_buffer_name, 1,
  247.                                                     LENGTH (buffer_name)) THEN
  248.                 vi$add_choice (loop_buffer_name);
  249.                 possible_buffer := loop_buffer;
  250.                 possible_buffer_name := loop_buffer_name;
  251.                 how_many_buffers := how_many_buffers + 1;
  252.             ENDIF;
  253.         ENDIF;
  254.  
  255.         loop_buffer := GET_INFO (BUFFERS, "NEXT");
  256.     ENDLOOP;
  257.  
  258.     RETURN (found_a_buffer);
  259. ENDPROCEDURE;
  260.  
  261. !
  262. !   Return current line or empty string if at EOB
  263. !
  264. PROCEDURE vi$current_line
  265.     IF (MARK (NONE) = END_OF (CURRENT_BUFFER)) THEN
  266.         RETURN ("");
  267.     ELSE
  268.         RETURN (CURRENT_LINE);
  269.     ENDIF;
  270. ENDPROCEDURE;
  271.  
  272. !
  273. !   If autowrite is active, then write the current buffer out.
  274. !
  275. PROCEDURE vi$check_auto_write
  276.     vi$last_mapped := CURRENT_BUFFER;
  277.  
  278.     IF GET_INFO (CURRENT_BUFFER, "MODIFIED") AND vi$auto_write AND
  279.                         NOT GET_INFO (CURRENT_BUFFER, "SYSTEM") AND
  280.                                 NOT GET_INFO (CURRENT_BUFFER, "NO_WRITE") THEN
  281.         vi$message ("Writing out """+GET_INFO (CURRENT_BUFFER, "NAME")+"""");
  282.         WRITE_FILE (CURRENT_BUFFER);
  283.     ENDIF;
  284. ENDPROCEDURE;
  285.  
  286. !
  287. !   Only perform an update if there is not a keyboard macro in progress.
  288. !
  289. PROCEDURE vi$update (win)
  290.     IF (vi$key_buf = 0) AND (vi$playing_back = 0) THEN
  291.         UPDATE (win);
  292.     ENDIF;
  293. ENDPROCEDURE;
  294.  
  295. !
  296. !   This procedure should be envoked after a GET FILE command.  It will allow
  297. !   a list of files that have been created due to a wildcard filespec to be
  298. !   processed sequentially.
  299. !
  300. PROCEDURE vi$_next_file
  301.     LOCAL
  302.         win,
  303.         fn,
  304.         pos,
  305.         found_one,
  306.         btype,
  307.         bn,
  308.         how_many_buffers,
  309.         possible_buffer,
  310.         possible_buffer_name,
  311.         loop_buffer,
  312.         line;
  313.  
  314.     ON_ERROR
  315.         ! Ignore errors
  316.     ENDON_ERROR;
  317.  
  318.     vi$check_auto_write;
  319.     pos := MARK (NONE);
  320.     win := CURRENT_WINDOW;
  321.  
  322.     POSITION (vi$file_names);
  323.     IF (MARK (NONE) <> END_OF (CURRENT_BUFFER)) THEN
  324.         MOVE_VERTICAL (1);
  325.         IF (MARK (NONE) = END_OF (CURRENT_BUFFER)) THEN
  326.             vi$message ("No more files!");
  327.             MOVE_VERTICAL (-1);
  328.             POSITION (win);
  329.             RETURN (1);
  330.         ENDIF;
  331.     ELSE
  332.         vi$message ("No more files!");
  333.         POSITION (win);
  334.         RETURN (1);
  335.     ENDIF;
  336.  
  337.     fn := vi$current_line;
  338.  
  339.     bn := FILE_PARSE (fn, "", "", NAME);
  340.     btype := FILE_PARSE (fn, "", "", TYPE);
  341.  
  342.     IF btype = "" THEN
  343.         btype := ".";
  344.     ENDIF;
  345.     bn := bn + btype;
  346.  
  347.     found_one := vi$choose_buffer (bn, how_many_buffers,
  348.                             possible_buffer, possible_buffer_name, loop_buffer)
  349. ;
  350.  
  351.     IF (found_one) THEN
  352.         POSITION (pos);
  353.         IF (CURRENT_BUFFER = loop_buffer) THEN
  354.             vi$message ("Already positioned in that buffer");
  355.         ELSE
  356.             vi$check_auto_write;
  357.             UNMAP (win);
  358.             MAP (win, loop_buffer);
  359.             vi$set_status_line (CURRENT_WINDOW);
  360.         ENDIF;
  361.     ELSE
  362.         vi$message (FAO (
  363.             "No such buffer ""!AS"", buffer has been deleted!", bn));
  364.         POSITION (vi$file_names);
  365.         MOVE_VERTICAL (1);
  366.     ENDIF;
  367.  
  368.     POSITION (win);
  369.     vi$kill_undo;
  370.     vi$undo_end := 0;
  371.     RETURN (1);
  372. ENDPROCEDURE
  373.  
  374. !
  375. !   This procedure should be envoked after a GET FILE command.  It will allow
  376. !   a list of files that have been created due to a wildcard filespec to be
  377. !   processed sequentially.
  378. !
  379. PROCEDURE vi$_previous_file
  380.     LOCAL
  381.         win,
  382.         fn,
  383.         pos,
  384.         found_one,
  385.         btype,
  386.         bn,
  387.         how_many_buffers,
  388.         possible_buffer,
  389.         possible_buffer_name,
  390.         loop_buffer,
  391.         line;
  392.  
  393.     ON_ERROR
  394.         ! Ignore errors
  395.     ENDON_ERROR;
  396.  
  397.     vi$check_auto_write;
  398.     pos := MARK (NONE);
  399.     win := CURRENT_WINDOW;
  400.  
  401.     fn := GET_INFO (CURRENT_BUFFER, "OUTPUT_FILE");
  402.  
  403.     POSITION (vi$file_names);
  404.     IF (MARK (NONE) <> BEGINNING_OF (CURRENT_BUFFER)) THEN
  405.         IF (MARK (NONE) = END_OF (CURRENT_BUFFER)) THEN
  406.             MOVE_VERTICAL (-1);
  407.         ENDIF;
  408.         MOVE_VERTICAL (-1);
  409.     ELSE
  410.         vi$message ("No previous file!");
  411.         POSITION (pos);
  412.         RETURN (1);
  413.     ENDIF;
  414.  
  415.     fn := vi$current_line;
  416.  
  417.     bn := FILE_PARSE (fn, "", "", NAME);
  418.     btype := FILE_PARSE (fn, "", "", TYPE);
  419.  
  420.     IF btype = "" THEN
  421.         btype := ".";
  422.     ENDIF;
  423.     bn := bn + btype;
  424.  
  425.     found_one := vi$choose_buffer (bn, how_many_buffers,
  426.                             possible_buffer, possible_buffer_name, loop_buffer)
  427. ;
  428.  
  429.     IF (found_one) THEN
  430.         POSITION (pos);
  431.         IF (CURRENT_BUFFER = loop_buffer) THEN
  432.             vi$message ("Already positioned in that buffer");
  433.         ELSE
  434.             vi$check_auto_write;
  435.             UNMAP (win);
  436.             MAP (win, loop_buffer);
  437.             vi$set_status_line (CURRENT_WINDOW);
  438.         ENDIF;
  439.     ELSE
  440.         vi$message ("No previous file!");
  441.     ENDIF;
  442.  
  443.     vi$kill_undo;
  444.     vi$undo_end := 0;
  445.     POSITION (win);
  446.     RETURN (1);
  447. ENDPROCEDURE
  448.  
  449. !
  450. !   Map first file in file list to the current window, providing it make
  451. !   sense to do so (eg. no mapping should be done to the command window.
  452. !
  453. PROCEDURE vi$_first_file
  454.     LOCAL
  455.         win,
  456.         fn,
  457.         pos,
  458.         found_one,
  459.         btype,
  460.         bn,
  461.         how_many_buffers,
  462.         possible_buffer,
  463.         possible_buffer_name,
  464.         loop_buffer,
  465.         line;
  466.  
  467.     ON_ERROR
  468.         ! Ignore errors
  469.     ENDON_ERROR;
  470.  
  471.     vi$check_auto_write;
  472.     pos := MARK (NONE);
  473.     win := CURRENT_WINDOW;
  474.  
  475.     POSITION (BEGINNING_OF (vi$file_names));
  476.     IF (MARK (NONE) = END_OF (vi$file_names)) THEN
  477.         vi$message ("No filename list!");
  478.         POSITION (pos);
  479.         RETURN (1);
  480.     ENDIF;
  481.  
  482.     fn := vi$current_line;
  483.  
  484.     bn := FILE_PARSE (fn, "", "", NAME);
  485.     btype := FILE_PARSE (fn, "", "", TYPE);
  486.  
  487.     IF btype = "" THEN
  488.         btype := ".";
  489.     ENDIF;
  490.  
  491.     bn := bn + btype;
  492.  
  493.     found_one := vi$choose_buffer (bn, how_many_buffers,
  494.                             possible_buffer, possible_buffer_name, loop_buffer)
  495. ;
  496.  
  497.     IF (found_one) THEN
  498.         POSITION (pos);
  499.         IF (CURRENT_BUFFER = loop_buffer) THEN
  500.             vi$message ("Already positioned in that buffer");
  501.         ELSE
  502.             vi$check_auto_write;
  503.             UNMAP (win);
  504.             MAP (win, loop_buffer);
  505.             vi$set_status_line (CURRENT_WINDOW);
  506.         ENDIF;
  507.     ELSE
  508.         vi$message ("Buffer not found: " + bn + "!");
  509.     ENDIF;
  510.  
  511.     vi$kill_undo;
  512.     vi$undo_end := 0;
  513.     POSITION (win);
  514.     RETURN (1);
  515. ENDPROCEDURE;
  516.  
  517. !
  518. !   Show the contents of the tags buffer
  519. !
  520. PROCEDURE vi$_show_tags
  521.     vi$show_list (vi$tag_buf,
  522.         "Current tags from the files: "+vi$tag_files, info_window)
  523. ENDPROCEDURE;
  524.  
  525. !
  526. !   Show the list of filenames currently being used by the NEXT FILE, FIRST
  527. !   FILE, and PREVIOUS FILE commands.
  528. !
  529. PROCEDURE vi$_show_files
  530.     vi$show_list (vi$file_names,
  531. "  File names currently active for PREVIOUS, FIRST and NEXT line mode commands"
  532. ,
  533.         info_window)
  534.  
  535. ENDPROCEDURE;
  536.  
  537. !
  538. !   Show a buffer, dbuf, in a window, dwin, with the status line set to 'stat'.
  539. !   Allow scrolling around, but no editing.  <ENTER> gets you out.
  540. !
  541. PROCEDURE vi$show_list (dbuf, stat, dwin)
  542.  
  543.     LOCAL
  544.         this_key,
  545.         win,
  546.         pos;
  547.  
  548.     win := CURRENT_WINDOW;
  549.     pos := MARK (NONE);
  550.  
  551.     MAP (dwin, dbuf);
  552.     SET (STATUS_LINE, dwin, NONE, "");
  553.     SET (STATUS_LINE, dwin, REVERSE, stat);
  554.     POSITION (dwin);
  555.     SET (EOB_TEXT, dbuf,
  556. "[Press RETURN to continue editing]                        ");
  557.     UPDATE (dwin);
  558.  
  559.     LOOP
  560.         this_key := vi$read_a_key;
  561.         EXITIF (this_key = RET_KEY);
  562.  
  563.         IF (this_key = CTRL_D_KEY) OR
  564.            (this_key = CTRL_U_KEY) OR
  565.            (this_key = CTRL_F_KEY) OR
  566.            (this_key = CTRL_B_KEY) OR
  567.            (this_key = KEY_NAME ('h')) OR
  568.            (this_key = KEY_NAME ('j')) OR
  569.            (this_key = KEY_NAME ('k')) OR
  570.            (this_key = KEY_NAME ('l')) THEN
  571.  
  572.             EXECUTE (LOOKUP_KEY (this_key, PROGRAM, vi$cmd_keys));
  573.             UPDATE (CURRENT_WINDOW);
  574.         ENDIF;
  575.     ENDLOOP;
  576.  
  577.     UNMAP (dwin);
  578.     SET (STATUS_LINE, dwin, NONE, "");
  579.     SET (EOB_TEXT, dbuf, "");
  580.     POSITION (win);
  581.     POSITION (pos);
  582.     vi$message ("");
  583. ENDPROCEDURE;
  584.  
  585. !
  586. !   This procedure creates a new buffer with the named file in it.
  587. !   Checking is done to see if the input file exists, and CREATE was on
  588. !   the command line, etc...
  589. !
  590. PROCEDURE vi$_create_buffer (buffer_name, req_name, actual_file_name)
  591.  
  592.     LOCAL
  593.         info,
  594.         succ,
  595.         outf,
  596.         new_buffer;     ! Buffer created
  597.  
  598.     ON_ERROR
  599.         IF ERROR = TPU$_DUPBUFNAME THEN
  600.             vi$message (FAO ("Buffer !AS already exists", buffer_name));
  601.             RETURN (0);
  602.         ENDIF;
  603.     ENDON_ERROR;
  604.  
  605.     IF (actual_file_name = 0) OR (actual_file_name = "") THEN
  606.         new_buffer := CREATE_BUFFER (buffer_name);
  607.  
  608.         IF (req_name <> 0) THEN
  609.             outf := FILE_PARSE (req_name);
  610.             MESSAGE (outf);
  611.             vi$message (FAO ("New file ""!AS""", outf));
  612.             SET (OUTPUT_FILE, new_buffer, outf);
  613.         ENDIF;
  614.     ELSE
  615.         vi$message ("Reading file """+actual_file_name+"""");
  616.         new_buffer := CREATE_BUFFER (buffer_name, actual_file_name);
  617.  
  618.         vi$message (FAO ("""!AS"", !UL lines", actual_file_name,
  619.             GET_INFO (new_buffer, "RECORD_COUNT")));
  620.  
  621.         IF (vi$starting_up) THEN
  622.             IF GET_INFO (COMMAND_LINE, "OUTPUT") THEN
  623.                 SET (OUTPUT_FILE, new_buffer, FILE_PARSE (
  624.                     GET_INFO (COMMAND_LINE, "OUTPUT_FILE"),
  625.                     actual_file_name));
  626.  
  627.                 !  Set the buffer to be modified so that the file will
  628.                 !  be written on exit.
  629.  
  630.                 SPLIT_LINE;
  631.                 APPEND_LINE;
  632.             ENDIF;
  633.         ELSE
  634.             SET (OUTPUT_FILE, new_buffer, actual_file_name);
  635.         ENDIF;
  636.     ENDIF;
  637.  
  638.     vi$check_auto_write;
  639.     MAP (CURRENT_WINDOW, new_buffer);
  640.     vi$status_lines (new_buffer);
  641.  
  642.     IF GET_INFO (COMMAND_LINE, "READ_ONLY") THEN
  643.         SET (NO_WRITE, new_buffer);
  644.     ENDIF;
  645.  
  646.     SET (TAB_STOPS, new_buffer, vi$tab_amount);
  647.  
  648.     RETURN (new_buffer);
  649. ENDPROCEDURE;
  650.  
  651. !
  652. !   Add a string to the end of the choice buffer
  653. !
  654. PROCEDURE vi$add_choice (choice_string)
  655.  
  656.     LOCAL
  657.         pos;        ! Current position in the buffer
  658.  
  659.     pos := MARK (NONE);
  660.     POSITION (END_OF (choice_buffer));
  661.     COPY_TEXT (choice_string);
  662.     POSITION (pos);
  663. ENDPROCEDURE;
  664.  
  665. !
  666. !   Put a message into the message window, and make sure that it is visible.
  667. !   There appears to be problems with mapping the command_window over the
  668. !   top of the message window that makes this kludge necessary.
  669. !
  670. PROCEDURE vi$message (mess)
  671.     MESSAGE (mess);
  672.     vi$update (message_window);
  673. ENDPROCEDURE;
  674.  
  675. !
  676. !   Print the system error message corresponding to the error code passed.
  677. !
  678. PROCEDURE vi$system_message (errno)
  679.     MESSAGE (CALL_USER (vi$cu_getmsg, STR(errno)));
  680. ENDPROCEDURE;
  681.  
  682. !
  683. !  Below are the window manipulation routines.  They take care of
  684. !  spliting and deleting windows.  The vi$prev_win and vi$next_win are
  685. !  very VERY dependent on there not being any occusion of the windows
  686. !  that they consider.  If a window is occluded, the results are
  687. !  unpredictable.
  688. !
  689. !  Split the current window exactly where it is at
  690. !
  691. PROCEDURE vi$split_here
  692.  
  693.     LOCAL
  694.         curwin,
  695.         nextwin,
  696.         curtop,
  697.         curbuf,
  698.         len,
  699.         line,
  700.         row,
  701.         errno,
  702.         newwin,
  703.         newlen,
  704.         newtop,
  705.         top;
  706.  
  707.     ON_ERROR
  708.         errno := ERROR;
  709.         line := ERROR_LINE;
  710.         MESSAGE ("ERROR at line: "+ STR (line));
  711.         vi$system_message (errno);
  712.         RETURN(1);
  713.     ENDON_ERROR
  714.  
  715.     IF (vi$in_occlusion) THEN
  716.         MESSAGE ("Can't split while MAKE FULL SCREEN is active");
  717.         RETURN (1);
  718.     ENDIF;
  719.  
  720.     curwin  :=  CURRENT_WINDOW;
  721.     row     :=  GET_INFO (SCREEN, "CURRENT_ROW");
  722.     top     :=  GET_INFO (curwin, "VISIBLE_TOP");
  723.     len     :=  GET_INFO (curwin, "VISIBLE_LENGTH");
  724.  
  725.     IF (row - top < 1) OR (top + len - row < 3) THEN
  726.  
  727.         ! Check to see if the cursor can not be placed in the middle because
  728.         ! the buffer does not have enough lines.
  729.  
  730.         IF ((GET_INFO (CURRENT_BUFFER, "RECORD_COUNT") >= len/2) AND
  731.                 (MARK (NONE) <> BEGINNING_OF (CURRENT_BUFFER)) AND
  732.                                 (MARK (NONE) <> END_OF (CURRENT_BUFFER))) THEN
  733.             vi$pos_in_middle (MARK(NONE));
  734.             UPDATE (CURRENT_WINDOW);
  735.             row := GET_INFO (SCREEN, "CURRENT_ROW");
  736.         ELSE
  737.             ! Not enough lines, so estimate the middle.
  738.             row := top+(len/2)-1;
  739.         ENDIF;
  740.  
  741.         ! Check limits again.
  742.  
  743.         IF (row - top < 1) OR (top + len - row < 3) THEN
  744.             MESSAGE ("Can't split window");
  745.             RETURN(1);
  746.         ENDIF;
  747.     ENDIF;
  748.  
  749.     curbuf := GET_INFO (curwin, "BUFFER");
  750.     newlen := row - top + 1;
  751.     newwin := CREATE_WINDOW (top, newlen, ON);
  752.     newtop := row + 1;
  753.     MAP (newwin, curbuf);
  754.     vi$set_status_line (newwin);
  755.  
  756.     newwin := CREATE_WINDOW (newtop, len - (newtop - top), ON);
  757.     MAP (newwin, curbuf);
  758.     vi$set_status_line (newwin);
  759.  
  760.     UNMAP (curwin);
  761.     DELETE (curwin);
  762.  
  763.     POSITION (newwin);
  764.     vi$pos_in_middle (MARK(NONE));
  765.     vi$previous_window;
  766.     vi$pos_in_middle (MARK(NONE));
  767.  
  768.     vi$this_window := CURRENT_WINDOW;
  769.  
  770.     RETURN (0);
  771. ENDPROCEDURE;
  772.  
  773. !
  774. !   This procedure is used to initialize some things that are necessarily
  775. !   changed when the editing environment changes because of window or other
  776. !   operations.
  777. !
  778. PROCEDURE vi$new_env
  779.     vi$how_much_scroll := GET_INFO (CURRENT_WINDOW, "VISIBLE_LENGTH") / 2;
  780.     vi$new_offset := 1;
  781. ENDPROCEDURE;
  782.  
  783. !
  784. !  Delete the current window
  785. !
  786. PROCEDURE vi$delete_window
  787.     LOCAL
  788.         curwin;
  789.  
  790.     MESSAGE ("");
  791.     IF (vi$in_occlusion) THEN
  792.         IF (CURRENT_WINDOW <> vi$occluding_win) THEN
  793.             MESSAGE ("Can't delete this window.");
  794.             RETURN;
  795.         ENDIF;
  796.  
  797.         UNMAP (vi$old_occ_win);
  798.         MAP (vi$old_occ_win, CURRENT_BUFFER);
  799.         DELETE (vi$occluding_win);
  800.         vi$in_occlusion := 0;
  801.         vi$set_status_line (CURRENT_WINDOW);
  802.         vi$new_env;
  803.     ELSE
  804.         curwin  := GET_INFO (WINDOWS, "CURRENT");
  805.         vi$del_win (curwin);
  806.     ENDIF;
  807. ENDPROCEDURE;
  808.  
  809. !
  810. !   Do the actual work of deleting a window
  811. !
  812. PROCEDURE vi$del_win (curwin)
  813.  
  814.     LOCAL
  815.         max_len,        ! Maximum length of screen minus the
  816.                         ! command window and message window
  817.         prevwin,        ! Window before the current
  818.         nextwin,        ! Window below the current
  819.         prevtop,        ! Top line of previous window
  820.         nexttop,        ! Top line of next window
  821.         curtop,         ! Top line of current window
  822.         prevbuf,        ! Buffer mapped to previous window
  823.         prevlen,        ! Length of previous window
  824.         curlen,         ! Length of current window
  825.         nextbuf,        ! Buffer mapped to next window
  826.         nextend,        ! Last line of next window
  827.         newwin,
  828.         nextlen;        ! Length of next window
  829.  
  830.     max_len := vi$scr_length - 2;
  831.     prevwin := vi$prev_win (curwin);
  832.     nextwin := vi$next_win (curwin);
  833.     curlen  := GET_INFO (curwin, "VISIBLE_LENGTH");
  834.     curtop  := GET_INFO (curwin, "VISIBLE_TOP");
  835.  
  836.     IF (nextwin <> 0) THEN
  837.         nextend := GET_INFO (nextwin, "VISIBLE_BOTTOM");
  838.     ELSE
  839.         nextend := max_len+1;  ! Something greater than the max_len used below
  840.     ENDIF;
  841.  
  842.     IF (nextwin <> 0) AND (nextend <= max_len) THEN
  843.         nextlen := GET_INFO (nextwin, "VISIBLE_LENGTH");
  844.         nextbuf := GET_INFO (nextwin, "BUFFER");
  845.         newwin := CREATE_WINDOW (curtop, curlen+nextlen, ON);
  846.         UNMAP (curwin);
  847.         UNMAP (nextwin);
  848.         MAP (newwin, nextbuf);
  849.         vi$set_status_line (newwin);
  850.         DELETE (curwin);
  851.         DELETE (nextwin);
  852.     ELSE
  853.         IF (prevwin <> 0) THEN
  854.             prevlen := GET_INFO (prevwin, "VISIBLE_LENGTH");
  855.             prevbuf := GET_INFO (prevwin, "BUFFER");
  856.             prevtop := GET_INFO (prevwin, "VISIBLE_TOP");
  857.             newwin := CREATE_WINDOW (prevtop, curlen+prevlen, ON);
  858.             UNMAP (curwin);
  859.             UNMAP (prevwin);
  860.             MAP (newwin, prevbuf);
  861.             vi$set_status_line (newwin);
  862.             DELETE (curwin);
  863.             DELETE (prevwin);
  864.         ELSE
  865.             MESSAGE ("Can't delete this window");
  866.             RETURN;
  867.         ENDIF;
  868.     ENDIF;
  869.  
  870.     IF (vi$prev_win (CURRENT_WINDOW) = 0) THEN
  871.         IF (vi$next_win (CURRENT_WINDOW) = 0) THEN
  872.             SET (STATUS_LINE, CURRENT_WINDOW, NONE, "");
  873.             REFRESH;
  874.         ENDIF;
  875.     ENDIF;
  876.     vi$this_window := CURRENT_WINDOW;
  877.     vi$pos_in_middle (MARK (NONE));
  878.     vi$new_env;
  879.  
  880. ENDPROCEDURE;
  881.  
  882. !
  883. !   Take the current buffer (if there is more than one window displayed on the
  884. !   screen), and remap it to a new window that occludes all others and is
  885. !   the size of the screen.
  886. !
  887. PROCEDURE vi$make_full_screen
  888.  
  889.     LOCAL
  890.         win,
  891.         buf;
  892.  
  893.     IF (vi$in_occlusion) THEN
  894.         MESSAGE ("Already in full screen");
  895.         RETURN;
  896.     ENDIF;
  897.  
  898.     IF (vi$next_win (CURRENT_WINDOW) = 0) THEN
  899.         IF (vi$prev_win (CURRENT_WINDOW) = 0) THEN
  900.             MESSAGE ("Current window is only window");
  901.             RETURN;
  902.         ENDIF;
  903.     ENDIF;
  904.  
  905.     vi$old_occ_win := CURRENT_WINDOW;
  906.  
  907.     buf := CURRENT_BUFFER;
  908.     win := CREATE_WINDOW (1, vi$scr_length - 1, ON);
  909.     vi$occluding_win := win;
  910.  
  911.     IF (win <> 0) THEN
  912.         vi$in_occlusion := 1;
  913.         SET (STATUS_LINE, win, NONE, "");
  914.         MAP (win, buf);
  915.         vi$pos_in_middle (MARK (NONE));
  916.         vi$new_env;
  917.     ELSE
  918.         MESSAGE ("Error creating window, command aborted!");
  919.     ENDIF;
  920.  
  921. ENDPROCEDURE;
  922.  
  923. !
  924. !  Move to next window going down the screen
  925. !
  926. PROCEDURE vi$next_window
  927.  
  928.     LOCAL
  929.         nextwin,
  930.         curwin;
  931.  
  932.     IF (vi$in_occlusion) THEN
  933.         RETURN;
  934.     ENDIF;
  935.  
  936.     curwin := CURRENT_WINDOW;
  937.     nextwin := vi$next_win (curwin);
  938.  
  939.     IF (nextwin <> 0) THEN
  940.         UPDATE (curwin);
  941.         POSITION (nextwin);
  942.         vi$set_status_line (nextwin);
  943.         vi$new_env;
  944.     ENDIF;
  945.  
  946. ENDPROCEDURE;
  947.  
  948. !
  949. !  Move to previous window going up the screen
  950. !
  951. PROCEDURE vi$previous_window
  952.  
  953.     LOCAL
  954.         prevwin,
  955.         curwin;
  956.  
  957.     IF (vi$in_occlusion) THEN
  958.         RETURN;
  959.     ENDIF;
  960.  
  961.     curwin := CURRENT_WINDOW;
  962.     prevwin := vi$prev_win (curwin);
  963.  
  964.     IF (prevwin <> 0) THEN
  965.         UPDATE (curwin);
  966.         POSITION (prevwin);
  967.         vi$set_status_line (prevwin);
  968.         vi$new_env;
  969.     ENDIF;
  970.  
  971. ENDPROCEDURE;
  972.  
  973. !
  974. !   Return the window that is below the current one, or ZERO if there is
  975. !   none.  Note the special case that occurs while MAKE_FULL_SCREEN is active.
  976. !
  977. PROCEDURE vi$next_win (win)
  978.  
  979.     LOCAL
  980.         winbot,
  981.         nexttop,
  982.         nextwin;
  983.  
  984.     IF (vi$in_occlusion) THEN
  985.         RETURN (0);
  986.     ENDIF;
  987.  
  988.     nextwin := GET_INFO (WINDOWS, "FIRST");
  989.     winbot := GET_INFO (win, "VISIBLE_BOTTOM");
  990.  
  991.     IF (winbot >= (vi$scr_length - 3)) THEN
  992.         RETURN (0);
  993.     ENDIF;
  994.  
  995.     LOOP
  996.  
  997.         EXITIF nextwin = 0;
  998.  
  999.         IF (GET_INFO (nextwin, "BUFFER") <> 0) THEN
  1000.             nexttop := GET_INFO (nextwin, "VISIBLE_TOP");
  1001.  
  1002.             IF (winbot + 2 = nexttop) THEN
  1003.                 RETURN (nextwin);
  1004.             ENDIF;
  1005.         ENDIF;
  1006.  
  1007.         nextwin := GET_INFO (nextwin, "NEXT");
  1008.     ENDLOOP;
  1009.  
  1010.     RETURN (0);
  1011.  
  1012. ENDPROCEDURE;
  1013.  
  1014. !
  1015. !   Return the window that is above the current one, or ZERO if there is
  1016. !   none.  Note the special case that occurs while MAKE_FULL_SCREEN is active.
  1017. !
  1018. PROCEDURE vi$prev_win (win)
  1019.  
  1020.     LOCAL
  1021.         max_len,    ! Maximum length of screen minus the
  1022.                     ! command window, and message window.
  1023.         wintop,
  1024.         prevbot,
  1025.         prevwin;
  1026.  
  1027.     IF (vi$in_occlusion) THEN
  1028.         RETURN(0);
  1029.     ENDIF;
  1030.  
  1031.     max_len := vi$scr_length - 1;
  1032.     prevwin := GET_INFO (WINDOWS, "FIRST");
  1033.     wintop := GET_INFO (win, "VISIBLE_TOP");
  1034.  
  1035.     IF (max_len <= wintop) THEN
  1036.         RETURN (0);
  1037.     ENDIF;
  1038.  
  1039.     IF (max_len - 1 = GET_INFO (win, "VISIBLE_BOTTOM")) AND (wintop = 1) THEN
  1040.         RETURN (0);
  1041.     ENDIF;
  1042.  
  1043.     LOOP
  1044.         EXITIF prevwin = 0;
  1045.  
  1046.         IF (GET_INFO (prevwin, "BUFFER") <> 0) THEN
  1047.             prevbot := GET_INFO (prevwin, "VISIBLE_BOTTOM");
  1048.  
  1049.             IF (prevbot + 2 = wintop) THEN
  1050.                 RETURN (prevwin);
  1051.             ENDIF;
  1052.         ENDIF;
  1053.  
  1054.         prevwin := GET_INFO (prevwin, "NEXT");
  1055.     ENDLOOP;
  1056.  
  1057.     RETURN (0);
  1058.  
  1059. ENDPROCEDURE;
  1060.  
  1061. !
  1062. !   Shrink the current window, lengthing the lower window if possible first.
  1063. !   If there is no window below, then try above.  If can't do that either,
  1064. !   then give up with a message
  1065. !
  1066. PROCEDURE vi$shrink_window (shrinkparm)
  1067.  
  1068.     LOCAL
  1069.         curwin,
  1070.         currow,
  1071.         prevwin,
  1072.         nextwin,
  1073.         newshrink;
  1074.  
  1075.     IF (vi$in_occlusion) THEN
  1076.         RETURN;
  1077.     ENDIF;
  1078.  
  1079.     newshrink := shrinkparm;
  1080.  
  1081.     curwin := GET_INFO (WINDOWS, "CURRENT");
  1082.     currow := GET_INFO (curwin, "VISIBLE_LENGTH");
  1083.  
  1084.     IF (currow < 3) THEN
  1085.         MESSAGE ("Can't shrink this window");
  1086.         RETURN;
  1087.     ENDIF;
  1088.  
  1089.     IF newshrink > currow - 2 THEN
  1090.         newshrink := currow - 2;
  1091.     ENDIF;
  1092.  
  1093.     IF newshrink <= 0 THEN
  1094.         MESSAGE ("Can't shrink this window");
  1095.         RETURN;
  1096.     ENDIF;
  1097.  
  1098.     nextwin := vi$next_win (curwin);
  1099.     prevwin := vi$prev_win (curwin);
  1100.  
  1101.     IF (nextwin <> 0) THEN
  1102.         ADJUST_WINDOW (curwin, 0, -newshrink);
  1103.         ADJUST_WINDOW (nextwin, -newshrink, 0);
  1104.     ELSE
  1105.         IF (prevwin <> 0) THEN
  1106.             ADJUST_WINDOW (curwin, newshrink, 0);
  1107.             ADJUST_WINDOW (prevwin, 0, newshrink);
  1108.         ELSE
  1109.             MESSAGE ("Can't shrink this window");
  1110.             RETURN;
  1111.         ENDIF;
  1112.     ENDIF;
  1113.     POSITION (curwin);
  1114.     vi$pos_in_middle (MARK(NONE));
  1115. ENDPROCEDURE;
  1116.  
  1117. !
  1118. !   Enlarge the current window if possible.  Try moving the bottom down.
  1119. !   If that doesn't work, then try moving the top up.
  1120. !
  1121. PROCEDURE vi$enlarge_window (enlargeparm)
  1122.  
  1123.     LOCAL
  1124.         curwin,
  1125.         prevwin,
  1126.         nextwin,
  1127.         nextrow,
  1128.         newenlarge,
  1129.         prevrow;
  1130.  
  1131.     IF (vi$in_occlusion) THEN
  1132.         RETURN;
  1133.     ENDIF;
  1134.  
  1135.     newenlarge := enlargeparm;
  1136.  
  1137.     curwin := GET_INFO (WINDOWS, "CURRENT");
  1138.  
  1139.     nextwin := vi$next_win (curwin);
  1140.     prevwin := vi$prev_win (curwin);
  1141.  
  1142.     IF (nextwin <> 0) THEN
  1143.         nextrow := GET_INFO (nextwin, "VISIBLE_LENGTH");
  1144.  
  1145.         IF (nextrow > 2) then
  1146.             IF (newenlarge + 2 > nextrow) THEN
  1147.                 newenlarge := nextrow - 2;
  1148.             ENDIF;
  1149.  
  1150.             IF newenlarge <= 0 THEN
  1151.                 MESSAGE ("Can't enlarge this window");
  1152.                 RETURN;
  1153.             ENDIF;
  1154.  
  1155.             ADJUST_WINDOW (nextwin, newenlarge, 0);
  1156.             ADJUST_WINDOW (curwin, 0, newenlarge);
  1157.         ELSE
  1158.             MESSAGE ("Can't shrink next window");
  1159.             RETURN;
  1160.         ENDIF;
  1161.     ELSE
  1162.         IF (prevwin <> 0) THEN
  1163.  
  1164.             prevrow := GET_INFO (prevwin, "VISIBLE_LENGTH");
  1165.  
  1166.             IF (prevrow < 3) THEN
  1167.                 MESSAGE ("Can't shrink previous window");
  1168.                 RETURN;
  1169.             ENDIF;
  1170.  
  1171.             IF (newenlarge + 2 > prevrow) THEN
  1172.                 newenlarge := prevrow - 2;
  1173.             ENDIF;
  1174.  
  1175.             IF newenlarge = 0 THEN
  1176.                 MESSAGE ("Can't enlarge this window");
  1177.                 RETURN;
  1178.             ENDIF;
  1179.  
  1180.             ADJUST_WINDOW (prevwin, 0, -newenlarge);
  1181.             ADJUST_WINDOW (curwin, -newenlarge, 0);
  1182.         ELSE
  1183.             MESSAGE ("Can't enlarge this window");
  1184.             RETURN;
  1185.         ENDIF;
  1186.     ENDIF;
  1187.  
  1188.     POSITION (curwin);
  1189.     vi$pos_in_middle (MARK(NONE));
  1190. ENDPROCEDURE;
  1191.  
  1192. !
  1193. !   Set the status line for the window passed
  1194. !
  1195. PROCEDURE vi$set_status_line (win)
  1196.     LOCAL
  1197.         nowr,
  1198.         buf,
  1199.         fmtstr,
  1200.         fn;
  1201.  
  1202.     IF (GET_INFO (win, "STATUS_VIDEO") <> REVERSE) THEN
  1203.         RETURN;
  1204.     ENDIF;
  1205.  
  1206.     buf := GET_INFO (win, "BUFFER");
  1207.     nowr := " ";
  1208.     IF (GET_INFO (buf, "NO_WRITE")) THEN
  1209.         nowr := "*";
  1210.     ENDIF;
  1211.     fn := GET_INFO (buf, "NAME");
  1212.     SET (STATUS_LINE, win, NONE, "");
  1213.     fmtstr := "!" + STR (GET_INFO (win, "WIDTH"));
  1214.     SET (STATUS_LINE, win, REVERSE,
  1215.             FAO (fmtstr+"<!ASBuffer: !AS!>", nowr, fn));
  1216. ENDPROCEDURE;
  1217.  
  1218. !
  1219. !   Position the location passed into the middle of the current window.
  1220. !
  1221. PROCEDURE vi$pos_in_middle (pos)
  1222.     LOCAL
  1223.         scroll_top,
  1224.         scroll_bottom,
  1225.         cur_window,
  1226.         scroll_amount,
  1227.         scrl_value;
  1228.  
  1229.     ON_ERROR
  1230.     ENDON_ERROR;
  1231.  
  1232.     cur_window    := CURRENT_WINDOW;
  1233.     scrl_value    := (GET_INFO (cur_window, "VISIBLE_LENGTH") / 2);
  1234.  
  1235.     POSITION (pos);
  1236.     MOVE_VERTICAL (-scrl_value);
  1237.     vi$update (cur_window);
  1238.     POSITION (pos);
  1239. ENDPROCEDURE;
  1240.  
  1241. !
  1242. !   Update the status lines for windows with the buffer passed mapped to them
  1243. !
  1244. PROCEDURE vi$status_lines (buf)
  1245.     LOCAL
  1246.         win;
  1247.  
  1248.     win := GET_INFO (WINDOWS, "FIRST");
  1249.     LOOP
  1250.         EXITIF (win = 0);
  1251.         IF (GET_INFO (win, "BUFFER") = buf) THEN
  1252.             vi$set_status_line (win);
  1253.         ENDIF;
  1254.         win := GET_INFO (WINDOWS, "NEXT");
  1255.     ENDLOOP;
  1256. ENDPROCEDURE;
  1257.  
  1258. !
  1259. !   Send the string passed to a DCL process.  All the necessary stuff is
  1260. !   done to move to the DCL buffer, and start the DCL process, and all
  1261. !   of the other junk.
  1262. !
  1263. PROCEDURE vi$send_to_dcl (dcl_string)
  1264.  
  1265.     ON_ERROR
  1266.         IF ERROR = TPU$_CREATEFAIL THEN
  1267.             MESSAGE ("DCL subprocess could not be created");
  1268.             RETURN (1);
  1269.         ENDIF;
  1270.     ENDON_ERROR;
  1271.  
  1272.     IF CURRENT_BUFFER <> vi$dcl_buf THEN
  1273.  
  1274.         IF (GET_INFO (vi$dcl_buf, "MAP_COUNT") > 0) AND
  1275.                 (vi$in_occlusion = 0) THEN
  1276.             POSITION (vi$dcl_buf);
  1277.         ELSE
  1278.  
  1279.             ! Attempt to split the screen at the cursor position
  1280.  
  1281.             IF (vi$split_here = 1) THEN
  1282.                 IF (vi$in_occlusion = 0) THEN
  1283.                     MESSAGE ("Move cursor to middle of current window");
  1284.                 ENDIF;
  1285.                 RETURN (1);
  1286.             ENDIF;
  1287.  
  1288.             MAP (CURRENT_WINDOW, vi$dcl_buf);
  1289.         ENDIF;
  1290.     ENDIF;
  1291.  
  1292.     POSITION (END_OF (vi$dcl_buf));
  1293.     vi$status_lines (CURRENT_BUFFER);
  1294.     UPDATE (CURRENT_WINDOW);
  1295.  
  1296.     IF (GET_INFO (vi$dcl_process, "TYPE") = UNSPECIFIED) OR
  1297.                                                (vi$dcl_process = 0) THEN
  1298.         MESSAGE ("Creating DCL subprocess...");
  1299.         vi$dcl_process := CREATE_PROCESS (vi$dcl_buf);
  1300.         IF (vi$dcl_process = 0) THEN
  1301.             RETURN;
  1302.         ENDIF;
  1303.         MESSAGE ("Process was created");
  1304.     ENDIF;
  1305.  
  1306.     SPLIT_LINE;
  1307.     COPY_TEXT (dcl_string);
  1308.     UPDATE (CURRENT_WINDOW);
  1309.     SEND (dcl_string, vi$dcl_process);
  1310.     POSITION (END_OF (vi$dcl_buf));
  1311.     UPDATE (CURRENT_WINDOW);
  1312.  
  1313.     RETURN (0);
  1314. ENDPROCEDURE;
  1315.  
  1316. !
  1317. !
  1318. !
  1319. PROCEDURE vi$mess_select (mode)
  1320.     LOCAL
  1321.         pos;
  1322.  
  1323.     pos := MARK (NONE);
  1324.     vi$message_select := 0;
  1325.     POSITION (END_OF (message_buffer));
  1326.     vi$message_select := SELECT (mode);
  1327.     POSITION (pos);
  1328. ENDPROCEDURE;
  1329.  
  1330. !
  1331. !  Allow local modifications to be done here.
  1332. !
  1333. PROCEDURE tpu$local_init
  1334. ENDPROCEDURE;
  1335.  
  1336. !
  1337. !   Create a section file, and terminate.
  1338. !
  1339. vi$init_keys;
  1340. COMPILE ("PROCEDURE vi$init_keys ENDPROCEDURE;");
  1341. SAVE ("SYS$DISK:[]VI.GBL");
  1342. QUIT;
  1343. $$EOD$$
  1344.