🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.sources.d
Article #1492

Pick/ Gram's Commander

#1492
From: Graham Wheeler
Date: Tue, 17 Nov 1992 11:31
72 lines
3825 bytes
Hi all

I have recently finished pick v2.1, which includes, amongst other things, the
ability to read a list of arguments from standard input and write them to
standard output; that is, you can now use pick as an interactive filter!

Also, pick inspired me to write Gram's Commander. I did this last weekend;
it is a lot like the Norton Commander, and works great. This weekend
I wrote version 2, which is completely user-configurable. You can create 
your own commands, and assign them to whichever key you like. A couple
of examples:

KEY ^M 40 41 42 43 44 45 46 47 48 49 	"Do file dependent action on current file"
MKEY D 0 51 17 18 	"Delete the selected files/directories"
KEY d 17 18 	"Delete the current file or directory"
KEY \F 50 	"Find files matching pattern"

17	: o	: d	::	@QDeleting@ : rmdir @f : @i(read) : @i(paint)
18	: 	: rxl	::	@QDeleting@ : @U@ : @i(read) : @i(paint)
42	: 	: rl	:[Mm]akefile:	make -f @f @cMake what? @:@i(wait): @i(read) : @i(paint)
50	: 	: 	::		find . -name '@cPattern? @' -print| @EPAGER@/bin/pg@ : rm @t : @i(clr) :@i(paint)
51	: 	: 	::		@i(read) :@i(paint)

These come from the default setup. The first four lines specify that the ENTER
key is associated with commands 40 through 49, the d key with commands 17
and 18, and the F key (escaped to distinguish it from F1, F2, etc) is 
associated with command 50. The text strings are the help that will be shown
when the help command is executed.

MKEY D specifies that D is a multi-key; that is, the action associated with
this key is:

	execute command 0 (no command)
	loop through each selected file, setting @f to be the file name,
		and execute either command 17 or command 18
	execute command 51

The entries beginning with numbers are the actual commands. Looking at 17 and
18, the `d' and `rxl' implies that command 18 can be applied to regular,
executable and link files, while 17 can be applied to directories only.
In the former case, the internal @U@ action is used (an unlink (2)), while
in the latter case a `sh rmdir' is used. In each case, the directory is
reread and the screen is repainted (actually these commands are disabled 
while in the body of an MKEY loop), and finally action 51 is done (which
*does* read the directory and repaint the screen). The reason 17 and 18 
include a reread and repaint is that they are also used with key `d' to
remove individual files.

It is quite ugly, and in version 3 it will be a lot cleaner and more 
powerful, but it is still quite useable. I will post it soon, but I would
like to port it to some more platforms first. So, some questions:

* does anyone have a program that will take ANSI C and convert the
	prototypes to #ifdef ANSI C (original) #else (KI&R style) #endif
	constructs (the ansi2knr that comes with Ghostscript seems to
	do nothing at all)

* is anyone out there interested in testing/porting this to their (preferably
	SVR3 or BSD) platform, and letting me know what changes were needed?

Note that the program currently runs on SVR4/386 and SCO SVR3.2.

Please reply soon, as I would like to get this done by next week.

Cheers
Graham

-- 
Graham Wheeler                     | "That which is weak conquers the strong,
Network Systems Programmer         | that which is soft conquers the hard."
Aztec Information Management       | 		Lao Tzu - Tao Te Ching Ch. 78
gram@aim1.aztec.co.za              | There's no justice, there's just us
Technical Details
Message-ID: <gram.721999904@aim1>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!spool.mu.edu!olivea!charnel!psgrain!hippo!ucthpx!aim1!aim1!gram

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!spool.mu.edu!olivea!charnel!psgrain!hippo!ucthpx!aim1!aim1!gram
From: gram@aim1.aztec.co.za (Graham Wheeler)
Newsgroups: alt.sources.d
Subject: Pick/ Gram's Commander
Message-ID: <gram.721999904@aim1>
Date: 17 Nov 92 11:31:44 GMT
Organization: Aztec Information Management
Lines: 72