ved_sourcefile 
Author Message
 ved_sourcefile

This is a multi-part message in MIME format.

--------------3886454A67D7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi Poppers

Here is a new version of ved_sourcefile which works with xved.
The only difference is when more than one file is returned by
popindex. If poplog_ui_enabled is true or vved_sourefile_use_pui
is true then it creates a scrolling list for the user to select
a file otherwise it uses a ved working buffer to display the files
10 at a time.

Enjoy.

--
Anthony Worrall
The University of Reading,
Department of Computer Science,
Whiteknights, PO Box 225
Reading,
Berkshire, UK
RG6 6AY
Tel:   +44 (0)1734 318610
Fax:   +44 (0)1734 751994

--------------3886454A67D7
Content-Type: text/plain; charset=us-ascii; name="ved_sourcefile.p"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="ved_sourcefile.p"

/* --- Copyright University of Sussex 1992.  All rights reserved. ---------
 > File:           C.all/lib/ved/ved_sourcefile.p
 > Purpose:        examine source of procedures in source and libraries
 > Author:         Chris Slymon, June 1983 (see revisions)
 > Documentation:  HELP * SOURCEFILE, * POPINDEX
 > Related Files:  LIB * POPINDEX, * POPWHERE
 */

section;

define global vars vedsrcfiledefaults();
    lvars dir;
    vedhelpdefaults();
    false -> vednotabs;
    uppertolower(sys_fname(vedpathname, 3)) -> dir;
    if issubstring('lib', dir) then
        "lib"
    else
        "src"
    endif -> vedfileprops
enddefine;

define lconstant Get_index_file(string, num,quit);
    ;;; string is a line from index file, obtained by -popindex-
    lvars string, num, name, start, l=datalength(string);
    dlocal vedediting;

    ;;; extract file name and get source file into VED
    locchar_back(` `,l,string) -> start;
    sysfileok(substring(start + 1, l - start, string)) -> vedargument;
    false -> vedediting;
    if quit then
        vedqget(vededit(%[^vedargument src], vedsrcfiledefaults%));
    else
        vededit([^vedargument src], vedsrcfiledefaults);
    endif;
    ;;; extract procedure name
    locchar(` `,1,string) -> start;
    ;;; changed to use consword for exact match A.S. 6 April 1986
    consword(substring(1, start - 1, string)) -> name;

    ;;; if exact match fails, try inexact match!
    vedfindpdheader(name, true) or vedfindpdheader(name, false) -> l;
    if l then vedjumpto(l,1) endif;
    if vvedbuffersize > vedstartwindow then
        vedline - 1 -> vedlineoffset;
    endif;
    chain(if num == 1 then vedrefresh else vedrestorewindows endif);
enddefine;

define lconstant tty_select_file(entry_list,l) -> entry_num;
    lvars entry_list,l,entry_num;
    pr('\n\nChoose one of the following:\n\n');
    for entry_num from 1 to l  do
        pr(tab); pr(entry_num);
        pr(tab); pr(entry_list(entry_num));
        pr(newline);
        if entry_num > vedscreenlength - 5 then
            pr(l >< ' altogether ...'); quitloop()
        endif;
    endfor;
    true -> popnewline;
    repeat
        sys_clear_input(pop_charin_device);
        pr('\nType number <return> to access file');
        incharitem(charin)()-> entry_num;
        if entry_num = newline then
            false -> vedprintingdone; chain(vedrefresh)
        elseif entry_num.isinteger and entry_num > 0 and entry_num <= l
        then
            return();
        endif;
    endrepeat;
enddefine;

lvars box,sheet;
define constant pui_select_file(entry_list);
    lvars entry_list;

    propsheet_new_box('Select Source File', false, false, [Apply Dismiss]) -> box;
    propsheet_new('Select Source File',box, [
            [ Files listof 10 ^entry_list
                ( applier = %procedure(sheet,field,value);
                    if value then
                        external_defer_apply(Get_index_file(%value,2,false%));
                    endif;
                endprocedure% )
            ]
        ]) -> sheet;
    propsheet_show(sheet);
    propsheet_show(box);
enddefine;

define lconstant xved_select_file(entry_list,l) -> entry_num;
lvars index = 1, entry_list,l,entry_num;

    vededit('Select Source File');
    repeat
        ved_clear();
        vedinsertstring('\n\nChoose one of the following:\n\n');
        for entry_num from index to min(l,index+9)  do
            vedinsertstring(tab); vedcharinsert(entry_num + `0` - index);
            vedinsertstring(tab); vedinsertstring(entry_list(entry_num));
            vedinsertstring(newline);
        endfor;

        repeat
            vedinsertstring('\nType number to access file');
            if l-index >= 10 then
                vedinsertstring(', N for next 10 files');
            endif;
            if index > 10 then
                vedinsertstring(', P for previous 10 files');
            endif;
            wved_get_one_input() -> entry_num;
            if entry_num(1) = `A` then
                entry_num(2) -> entry_num;

                if entry_num = `n` or entry_num = `N` then
                    if l - index > 10 then
                        index + 10 -> index;
                    endif;
                    quitloop();
                endif;

                if entry_num = `p` or entry_num = `P` then
                    if index > 10 then
                        index - 10 -> index;
                    endif;
                    quitloop();
                endif;

                if entry_num >=  `0`
                and entry_num <= `0` + l - index
                then
                    entry_num - `0` + index -> entry_num;
                    return();
                endif;
            endif;
        endrepeat;
    endrepeat;
enddefine;

global vars vved_sourcefile_use_pui;
if vved_sourcefile_use_pui.isundef then
    false -> vved_sourcefile_use_pui;
endif;

define global ved_sourcefile();
    lvars entry_list, entry_num, n, l, string;
    dlocal popnewline, vedargument, pop_pr_quotes=false;

    if vedargument = nullstring then
        vednextitem() sys_>< nullstring -> vedargument;
        vedcommand sys_>< vedspacestring sys_>< vedargument -> string;
        ;;; put enlarged command on status line, before current command
        true -> ved_on_status;
        unless vedline > 1 and string = vedbuffer(vedline - 1) then
        ;;; put a copy of translated command in command line buffer
            vedlineabove();
            string -> vedthisline();
            vednextline();
        endunless;
        false -> ved_on_status;
    endif;

    popindex(vedargument) -> entry_list;
    listlength(entry_list) -> l;
    if l == 0 then
        vedputmessage('No matches found in index');
    elseif l == 1 then
        ;;; ensure status line of current file gets set if needed
        ;;; only need this because of vedediting off in Get_index_file
        if vedediting and not(vedusewindows)
        and vedstartwindow < vedscreenlength
        and vedwindowlength > vedstartwindow
        then vedsetwindow()
        endif;
        Get_index_file(hd(entry_list), l,false)
    else
#_IF vedusewindows == "x"
        if poplog_ui_enabled or vved_sourcefile_use_pui then
            pui_select_file(entry_list);
            return();
        else
            xved_select_file(entry_list,l) -> entry_num;
        endif;
#_ELSE
        tty_select_file(entry_list,l) -> entry_num;
#_ENDIF
        if vedusewindows then
            vedrefresh()
        elseif vedediting and vedstartwindow < vedscreenlength then
            false -> vedediting;
            if vedwindowlength > vedstartwindow then vedsetwindow() endif;
            true-> vedediting;
            ;;;vedrefresh();
        endif;
        false -> vedprintingdone;
        Get_index_file(entry_list(entry_num), l, vedusewindows);
    endif;
enddefine;

endsection;

/*  --- Revision History ---------------------------------------------------
--- Adrian Howard, Aug 26 1992
        Set -pop_pr_quotes- to -false- to stop the profusion of ugly quote marks.
--- John Williams, Jul 29 1992
        Now sets -vedfileprops- correctly (c.f. BR pop.4)
--- John Gibson, Oct 29 1991
        Added wved_raise_window(pop_charout_device) for XVed
--- John Gibson, Jun 11 1991
        Replaced popdevin with pop_charin_device
--- Jonathan Meyer, Jun  3 1991
        Changed vedusepwmwindows to vedusewindows
--- Aaron Sloman, May 21 1990
    fixed to behave better after menu. Removed unnecessary section by
    making Get_index_file lconstant.

--- Aaron Sloman, Sep 27 1988
    If given no argument, now uses word to right of cursor, and inserts
    command in status buffer.
--- Aled Morris, Jan  6 1988
        added "vedfileprops" argument to call of -ved*getfile- to set file

--- John Gibson, Nov 11 1987
        Replaced -sys_purge_terminal- with -sys_clear_input-
--- Aaron Sloman, Apr 12 1986
    Inserted call of consword, so exact match can be tried first. Speeds
    it up also, if exact match works.
--- Ben Rubinstein, Apr 11 1986 - altered to clean up window it was called
                from if used in pwm.
--- Mark Rubinstein, Jan 22 1986 - altered to sysfileok the file name (index
    now stores name using the $usepop environment variable) and set -vednotabs-
    to be false.  Removed the modifications of March 1985 and May 22 1985 which
    are no longer necessary.
--- Mark Rubinstein, May 24 1985 - altered to use sys_><
--- Mark Rubinstein, May 22 1985 - altered to use SYS_OS_TYPE
--- Mark Rubinstein, March 1985 - Minor mod of adding disk name if run from
    VMS
--- Jonathan Laventhol, Jan 29 1985 - bug fixed : status line of current file
    got lost sometimes; added fix in ved_sourcefile.
--- Aaron Sloman, Jan 1985 - Almost completely re-written
 */

--------------3886454A67D7--



Fri, 03 Dec 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 
 

 
Powered by phpBB® Forum Software