/* This file is http://www.cs.bham.ac.uk/research/poplog/winpop/init.p Posted to pop-forum by Roger Evans 6 Apr 2001. Installed at free poplog site by A.Sloman. Date: Fri, 06 Apr 2001 09:59:23 +0100 From: Roger Evans Subject: global init.p file for windows users Michael Worsley's recent windows-related enquiry (the first such for a good while on pop-forum) prompts me to offer to the community the attached global init.p file for windows poplog systems. (Aaron: is there a sensible archive place it could be saved in for posterity etc if appropriate?). The attached file sets up 'reasonable' defaults for pop_filename_case (ok, so unix users don't even know what this is!) and $poplocal, but most signficantly provides some code to allow winpop11 to be used as a filetype action - so that you can double click on a pop11 file and open ved on it (and if you wish, open ved-in-prolog on a prolog file). If you look at the code you will see this was slightly non-trivial to achieve (in terms of beating the innards of winpop11 startup into submission), so I hope it may be useful to some people. The file contains the code uncommented first, and then at the end a more heavily commented version which should explain how to use it etc. */ /* Some useful system-wide initialisations for windows poplog Roger.Evans@itri.brighton.ac.uk 4th June 2000 Install as pop\pop\init.p for system-wide effect or %HOME%\init.p for personal use. For detail see commented version of code at end of file. */ "undef" -> pop_filename_case; systranslate('usepop') -> systranslate('poplocal'); sysfileok('$poplocal/local/auto') -> systranslate('poplocalauto'); define macro winvededit; readstringline() -> ; [] -> ved_char_in_stream; vedscreenlength div 2 -> vedstartwindow; vededit(hd(poparglist)); vedsetwindow(); enddefine; if ispair(poparglist0) then lvars basename = sys_fname_nam(fast_front(poparglist0)), arglist = false, arg; if basename = 'winpop11' then fast_back(poparglist0) -> arglist; ;;; skip saved image startup args while ispair(arglist) do fast_front(arglist) -> arg; quitunless(datalength(arg) > 0 and fast_subscrs(1,arg) == `+`); fast_back(arglist) -> arglist; endwhile; ;;; save rest as poparglist arglist -> poparglist; procedure(old); lvars old; vedinput(sys_process_poparg1(%pop11_compile, trycompile, '.p'%)); old -> vedprocesstrap; old(); endprocedure(%vedprocesstrap%) -> vedprocesstrap; endif; endif; #_TERMIN_IF true; ;;; compilation ends here - commented version of code below ;;; ---------------------------------------------------------------------------- ;;; /* Some useful system-wide initialisations for windows poplog ;;; Roger.Evans@itri.brighton.ac.uk ;;; 4th June 2000 ;;; ;;; Install as pop\pop\init.p for system-wide effect or %HOME%\init.p for ;;; personal use. ;;; ;;; */ ;;; ;;; /* preserve case in filenames - especially if you are working with Java, which ;;; cares about filename case more than most windows applications ;;; */ ;;; "undef" -> pop_filename_case; ;;; ;;; /* winpop11 doesn't handle command line arguments nicely - it just starts up ;;; an immediate mode VED window ignoring any arguments apart from saved image ;;; specifiers. ;;; The code below makes winpop11 behave better, by collecting up all args ;;; *after* the saved image args and invoking sys_process_poparg1 on them. ;;; (This turns out to be harder than you might think). ;;; Even this doesn't support invoking VED directly, but the following macro helps ;;; make this less painful ;;; */ ;;; ;;; ;;; /* This macro can be used to make winpop11 start up ved on a named file, instead of ;;; an immediate mode window. It uses the sepcail satrtup code further down the file. ;;; Invoke it like this: ;;; ;;; winpop11 +startup ':winvededit' ;;; ;;; You can use it like this in the file types specification for .p (etc) files to make ;;; double-clicking a file open it in ved: ;;; ;;; D:\Poplog\15.5\pop\pop\winpop11 +startup ':winvededit' '%1' ;;; ;;; IMPORTANT: VED *hates* spaces in path names, and misbehaves badly. So if the full ;;; pathname of a file you edit like this has a space, it will not work properly. ;;; */ ;;; define macro winvededit; ;;; readstringline() -> ; ;;; clear (unparseable) pathname from input stream ;;; [] -> ved_char_in_stream; ;;; clear ved actions to start up immediate mode buffer ;;; vededit(hd(poparglist)); ;;; get path name from poparglist and edit it ;;; enddefine; ;;; ;;; /* This code makes winpop11 recognise command line arguments. ;;; It rebuilds poparglist from poparglist0 and then uses vedprocesstrap to ;;; intercept execution before just the immediate mode buffer is started ;;; and run sys_process_poparg1 on the new poparglist. ;;; */ ;;; if ispair(poparglist0) then ;;; lvars basename = sys_fname_nam(fast_front(poparglist0)), ;;; arglist = false, ;;; arg; ;;; if basename = 'winpop11' then ;;; fast_back(poparglist0) -> arglist; ;;; ;;; skip saved image startup args ;;; while ispair(arglist) do ;;; fast_front(arglist) -> arg; ;;; quitunless(datalength(arg) > 0 and fast_subscrs(1,arg) == `+`); ;;; fast_back(arglist) -> arglist; ;;; endwhile; ;;; ;;; save rest as poparglist ;;; arglist -> poparglist; ;;; ;;; create a one-off wrapper for vedprocesstrap to process poparglist ;;; ;;; use vedinput to ensure user code is run from VED's top level loop context ;;; procedure(old); ;;; lvars old; ;;; vedinput(sys_process_poparg1(%pop11_compile, trycompile, '.p'%)); ;;; old -> vedprocesstrap; ;;; old(); ;;; endprocedure(%vedprocesstrap%) -> vedprocesstrap; ;;; endif; ;;; endif;