! DIRECTORY.TPU - EVE commands to do a directory and get the file ! whose name is under the cursor ! ! Edit History ! ! Which When Who What ! ! X00-01 26-Dec-84 JLB Created from MYSECINI.TPU ! X00-02 2-Jan-85 JLB Make the directory buffer no_write ! eve$... => eveplus_... ! X00-03 27-Mar-85 JLB Fix bug in prompting ! X00-04 1-May-85 JLB Make it EXECUTable ! X00-05 25-Jun-85 JLB fix word separators ! X00-06 28-Jun-85 JLB And add one (@) ! X00-07 18-Jul-85 JLB Fix locals per MarkG ! ! Variant version of EVE's eve$this_word which selects ONLY the word ! and not the separators surrounding it. ! procedure eveplus_this_word_exact(rendition) ! Select the current word LOCAL select_word_range , temp_string , start_select_word , end_select_word ; if (current_character = 0) then return(0); endif; ! If current character is a word separator, we're not on a word. temp_string := current_character; if index (eve$x_word_separators, temp_string) <> 0 then return(0); endif; ! Go to end of word first - eve$start_of_word goes back a word ! when current cursor is at the start of a word. eve$end_of_word; loop move_horizontal (-1); exitif (index(eve$x_word_separators, current_character) = 0); endloop; end_select_word := mark (none); move_horizontal (1); eve$start_of_word; start_select_word := mark (none); select_word_range := create_range (start_select_word, end_select_word, rendition); update(current_window); return(select_word_range); endprocedure; ! ! Routine to test if a file actually exists ! procedure eveplus_file_exists(file_spec) ! See if a file exists LOCAL temp, file_name; on_error return(0); endon_error; temp := file_search(''); ! Make sure nobody affects us file_name := file_parse(file_spec); if (file_search(file_name) <> '') then temp := file_search(''); ! Make sure we affect nobody return (1); else return (0); endif; endprocedure; ! ! The DIRECTORY command itself - uses FILE_SEARCH not SPAWN, so all ! we get is the file spec. ! procedure eve_directory (file_arg) ! Do a directory LOCAL full_spec, ! Fully specified file spec file_spec, ! Writable version of the arg file_name, ! Each file in turn file_count, ! Loop counter my_key; ! The key that invoked us !GLOBAL eveplus_directory_spec, ! Used to remember the file name ! directory_buffer; ! Pointer to the directory buffer file_spec := file_arg; ! Get a read/write copy my_key := last_key; ! How were we invoked? if (my_key = RET_KEY) then ! Was it DIRECTORY ? my_key := DO; endif; if (file_spec = "") then ! Prompt if no file on command line file_spec := read_line("Directory of: "); if (file_spec = "") then if (last_key = my_key) then ! Use as "DIR again" file_spec := eveplus_directory_spec; else message("No file specified"); return; endif; endif; endif; eveplus_directory_spec := file_spec; eve_buffer("DIRECTORY BUFFER"); if (get_info(directory_buffer, "type") = unspecified) then directory_buffer := current_buffer; set(no_write, directory_buffer); endif; erase(current_buffer); full_spec := file_parse(eveplus_directory_spec, '*.*;'); eveplus_insert_text(" Directory listing of: " + full_spec); split_line; file_count := 0; loop file_name := file_search(full_spec); exitif (file_name = ''); split_line; eveplus_insert_text(' ' + file_name); file_count := file_count + 1; endloop; if (file_count = 0) then split_line; eveplus_insert_text(' -- No such files --'); endif; eve_top; update(current_window); move_vertical(2); ! Position to the first file name move_horizontal(2); ! so that THIS FILE will work endprocedure ! ! THIS FILE - command to get the file whose name is pointed to ! by the cursor. ! procedure eve_this_file ! Get the file under the cursor LOCAL the_word, ! The pointed to word the_string, ! as a string. old_separators; ! Saved word separators ! ! Change the separators used by EVE's word routines ! old_separators := eve$x_word_separators; ! Save EVE's separators eve$x_word_separators := ascii(9) + " !""#&'()+,-/=?@\^`{|}~"; ! ^ ! | ! Note that this means that you can't use UICs --------+ the_word := eveplus_this_word_exact(BOLD); eve$x_word_separators := old_separators; ! Restore original separators if (the_word = 0) then message("You are not pointing to a word"); return; endif; the_string := substr(the_word, 1, length(the_word)); ! Convert it to a string if (eveplus_file_exists(the_string)) then eve_fetch_file (the_string); else message("Can't find file: " + the_string); endif; delete(the_word); endprocedure; procedure tpu$local_init ! Package initialization eve$arg1_directory := 'string'; endprocedure; tpu$local_init;