home *** CD-ROM | disk | FTP | other *** search
- :::: 4sight.btm 1.3 ::::
- :::: type 4sight.btm /? for help ::::
-
- @setdos /v0
- setlocal
- unalias *
-
- iff "%temp4dos" != "" then
- set temp=%temp4dos
- elseiff "%temp" != "" .and. "%@substr[%temp,0,-1]" != "\" then
- set temp=%temp\
- endiff
- if not exist %temp%nul unset temp
- set junk=%temp%nul
-
- set test=%@unique[%temp]
- keystack 0 >&! %test
- iff "%@index[%@line[%test,0],KSTACK.COM]" == "0" then
- type %test
- del /q %test
- unset test
- quit
- else
- del /q %test
- endiff
-
- if "%@index[%@upper[%&],/X]" != "-1" unset exclude
- iff %# == 0 .or. %1 == /? then
- goto help
- elseiff "%@index[%@upper[%&],/W]" != "-1" then
- set _mode=w-fnc
- gosub fnc
- elseiff "%@index[%@upper[%&],/T]" != "-1" then
- set _mode=t-fnc
- gosub fnc
- elseiff "%@index[%@upper[%&],/V]" != "-1" then
- set _mode=view
- gosub view
- else
- goto help
- endiff
- gosub clean_up
- quit
-
- :::: subroutine help ::::
- :help
- text | list /s
- 4sight.btm ver. 1.3
- 4dos file name completion and file viewer utility
-
- copyright Bob Larson blarson@uiuc.edu 3 March 93
-
- This btm file must be called by an key alias which first uses ^K to
- save the current command line onto the history stack:
- example alias @f8=^K@4sight /w /x^Xr
-
- Syntax: 4sight [/t /w /v /?] [/x]
-
- Switches:
- /t tcsh type file name completion
- /w pop-up window type file name completion
- /v file viewer
- /? display help
- /x disable exclude files
-
- Exclude files:
- -------------
- You may designate files to be excluded using the %exclude environment
- variable, which contains 1 or more file specifications (wildcards
- permitted) separated by semi-colons or blanks. Example:
-
- set exclude=*.bak;*.tmp;
-
- will cause 4sight to ignore all *.bak and *.tmp files, unless 4sight
- is invoked with the /x switch.
- endtext
- quit
- :::: end subroutine help ::::
-
- :::: subroutine view ::::
- :view
- gosub get_hist
- gosub build_arg
- rem gosub exclude
- iff "%part_file%" EQ "" .or. not exist %part_file then
- beep
- return
- endiff
- (except (%exclude) dir /b /a-h-d %part_file | set lines=%@lines[con]) >&> %junk
- iff "%lines" == "-1" then
- beep
- return
- elseiff "%lines" == "0" then
- (except (%exclude) list %part_file) >&> %junk
- else
- (except (%exclude) select /a:-h-d list (%part_file)) >&> %junk
- endiff
- return
- :::: end subroutine view ::::
-
- :::: subroutine fnc ::::
- :fnc
- set s_path=%_cwds
- gosub get_hist
- gosub build_arg
- :redo
- set foo2=%@unique[%temp]
- iff "%_mode" == "w-fnc" then
- del /q %foo2
- (except ( %exclude ) dir /km %part_file >! %foo2) >&> %junk
- else
- (except (%exclude) dir /b %part_file >! %foo2) >&> %junk
- endiff
- set lines=%@lines[%foo2]
- iff %lines == -1 then
- gosub new_cmd
- elseiff %lines == 0 then
- set n_file=%@word[0,%@line[%foo2,0]]
- set temp_dir=%@path[%part_file]
- iff "%@substr[%temp_dir,0,-1]" NE "\" then
- set temp_dir=%temp_dir%\
- endiff
- set n_file=%@full[%temp_dir%%n_file]
- gosub new_cmd
- elseiff "%_mode" == "t-fnc" then
- (except (%exclude) dir /wkm /o-n %part_file) >&> %junk
- gosub get_new
- gosub new_cmd
- elseiff "%_mode" == "w-fnc" then
- set lines=%@eval[4+%lines]
- if %lines GT %_rows set lines=%_rows
- set n_file=%@word[0,%@select[%foo2,1,1,%lines,%_columns,%part_file]]
- del /q %foo2
- iff "%n_file" == "" then
- gosub new_cmd
- elseiff "%n_file" == "." then
- set n_file=%@path[%part_file]
- set newfile=%@substr[%newfile,0,%@eval[%@len[%n_file]-1]]
- gosub new_cmd
- else
- set temp_dir=%@path[%part_file]
- iff "%@substr[%temp_dir,0,-1]" NE "\" then
- set temp_dir=%temp_dir%\
- endiff
- set n_file=%@full[%temp_dir%%n_file]
- iff isdir %n_file then
- iff "%@substr[%n_file,0,-1]" != "\" then
- set n_file=%n_file%\
- endiff
- set part_file=%n_file%*.*
- cd %n_file
- goto redo
- else
- gosub new_cmd
- endiff
- endiff
- endiff
- :::: end subroutine fnc ::::
-
- :::: subroutine clean_up ::::
- :clean_up
- endlocal
- keystack 5
- quit
- :::: end main ::::
-
- :::: subroutine get_new ::::
-
- :get_new
- set file1=%@line[%foo2,0]
- set file2=%@line[%foo2,%lines]
- del /q %foo2
- set pos=0
- :new_loop
- set char1=%@substr[%file1,%pos,1]
- set char2=%@substr[%file2,%pos,1]
- iff "%char1%" == "" .or. "%char2%" == "" then
- goto breakout
- elseiff "%char1%" NE "%char2%" then
- goto breakout
- else
- set pos=%@eval[%pos+1]
- goto new_loop
- endiff
- :breakout
- iff "%pos" == "0" then
- set n_file=%orig
- return
- endiff
- set n_file=%@substr[%file1,0,%pos]
- set temp_dir=%@path[%part_file]
- iff "%@substr[%temp_dir,0,-1]" NE "\" then
- set temp_dir=%temp_dir%\
- endiff
- set n_file=%@full[%temp_dir%%n_file]
- return
- :::: end get_new ::::
-
-
- :::: subroutine get_hist ::::
- :get_hist
- set foo1=%@unique[%temp%]
- history >! %foo1
- set b=%@eval[%@lines[%foo1]]
- set hist_entry=%@line[%foo1,%b]
- del /q %foo1
- set pos=%@eval[%@len[%hist_entry]-1]
- iff "%@word[1,%hist_entry]" == "" then
- set just1=y
- set part_file=%hist_entry
- set old_cmd=` `
- else
- set just1=n
- set part_file=%@word[-0,%hist_entry]
- set pos=%@eval[%@len[%hist_entry]-%@len[%part_file]]
- set old_cmd=%@substr[%hist_entry,0,%pos]
- set orig=%part_file
- endiff
- return
- :::: end get_hist ::::
-
- :::: subroutine build_arg ::::
- :build_arg
- iff "%@substr[%part_file,0,-1]" == "\" then
- set part_file=%part_file*.*
- return
- endiff
- set part_file=%@full[%part_file]
- set path_part=%@path[%part_file]
- set prefix=%@name[%part_file]
- set exten=%@ext[%part_file]
- iff "%prefix" == "" then
- set prefix=*
- elseiff "%@substr[%prefix,0,-1]" NE "*" then
- set prefix=%prefix%*
- endiff
- iff "%exten" == "" then
- set exten=*
- elseiff "%@substr[%exten,0,-1]" NE "*" then
- set exten=%exten%*
- endiff
- iff "%@path[%part_file]" == "%_cwds" .and. "%just1" == "y" then
- set tempn=%@search[%prefix]
- iff "%tempn" != "" then
- set prefix=%@name[%tempn]
- set path_part=%@path[%tempn]
- endiff
- endiff
-
- set part_file=%path_part%%prefix%.%exten%
- unset prefix exten path_part max_chars >& %junk
- return
- :::: end build_arg ::::
-
-
- :::: subroutine new_cmd ::::
- :new_cmd
- iff "%n_file" == "" then
- set new_cmd=%hist_entry
- gosub bad_name
- gosub push_new_cmd
- return
- endiff
- iff "%@substr[%n_file,0,-1]" != "\" then
- iff isdir %n_file .and. "%lines" == "0" then
- if "%@substr[%n_file,0,-1]" != "\" set n_file=%n_file\
- else
- set t_file=%n_file
- unset n_file
-
- iff "%s_path" != "%@path[%@full[%t_file]]" then
- set n_file=%@path[%@full[%t_file]]
- endiff
- iff "%@ext[%t_file]" == "" then
- set n_file=%@substr[%n_file,0]%@name[%t_file]
- else
- set n_file=%@substr[%n_file,0]%@name[%t_file].%@ext[%t_file]
- endiff
- endiff
- endiff
- iff "%just1" == "y" then
- set new_cmd=%n_file
- else
- set new_cmd=%old_cmd% %n_file%
- endiff
- gosub push_new_cmd
- return
-
- :::: subroutine bad_name ::::
- :bad_name
- set new_cmd=%hist_entry
- if "%lines" == "-1" beep
- return
- :::: end bad_name ::::
-
- :::: subroutine push_new_cmd ::::
- :push_new_cmd
- history /a %new_cmd
- return
- :::: end push_new_cmd ::::