Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcsri!utegc!utai!garfield!john13 From: john13@garfield.UUCP Newsgroups: comp.sys.amiga Subject: ADD (customize keyboard shortcuts) Message-ID: <3577@garfield.UUCP> Date: Sun, 5-Apr-87 16:28:15 EST Article-I.D.: garfield.3577 Posted: Sun Apr 5 16:28:15 1987 Date-Received: Tue, 7-Apr-87 00:01:04 EST Organization: CS Dept., Memorial U. of Newfoundland, St. John's Lines: 379 Keywords: source + executable + doc [] What follows is a little program I wrote to make my life easier. Not that I *hate* menus, you understand, I kinda like them; but if I'm using the mouse for other things, I don't want to have to keep moving it up to the top over and over and over again. Now Intuition allows you to avoid this using keyboard equivalents...but only if the guy writing the program thought to include them, and used the same ones *you* would have. Anyway, it's in my c: directory now. John -----Cut Here-----Cut Here-----Cut Here-----Cut Here----- #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # add.doc # add.c # add.uue echo shar: extracting add.doc sed 's/^X//' << 'END_OF_FILE' > add.doc X XADD - create keyboard shortcuts where no keyboard shortcuts have gone before. X XCopyright ((c)) 1987, John Russell X X This is a small Intuition hack, which I'm surprised not to have seen Xanywhere before. It lets you take other people's menus, and customize them X(at least with regards to keyboard equivalents, ie right-Amiga + Xcombinations). The idea was brought into my consciousness when I saw how XMWB let you circumvent the assumptions made by other programmers in a Xtransparent way, although it had probably been fermenting back there for a Xwhile :-). X XSyntax: Xadd [ ] X XWindowname is the name of the window (no matter what screen it is on) to Xwhich the menu you want to alter is attached. I ran into hassles with Xlong window titles and those with spaces, so you only need specify the Xfirst word (eg VT100 instead of VT100 (2.4 861214... etc). Note that names X*are* case sensitive. X XAll numbers are from 1 upwards, so "add window 1 1 X" is the upper-left-hand Xposition in the menu list. X XIf you have 5 parameters it assumes the 4th is the position of a sub-item, Xnot the shortcut itself. Otherwise, the 2nd and 3rd supply the position info Xand the 4th is the key to use. X XThe shortcut can be specified as upper or lower case; they are treated the Xsame. Note that there is nothing to prevent you from creating duplicate Xshortcuts. Since I didn't want to get over-fancy, the size of the menu Xhitbox is unaltered and this may cause some (non-harmful) overlapping. X-------------- X XSample uses - X XInstall this file as s:loadwb (instead of "loadwb", "execute loadwb") X Xaddbuffers df0: 15 Xloadwb Xwait 4 ;wait for disk activity to finish Xadd Workbench 1 1 O Xadd Workbench 1 2 C Xadd Workbench 1 3 D Xadd Workbench 1 4 R Xadd Workbench 1 5 I Xadd Workbench 1 6 K ;for kill Xadd Workbench 2 1 E Xadd Workbench 2 2 F ;for format Xadd Workbench 3 4 S Xadd Workbench 3 5 V X XIf you use VT100 and don't have a compiler, you might want to install Xs:vt100 ("run vt100", then "execute vt100") X Xaddbuffers df0: 15 ;if none added before Xadd VT100 1 1 C Xadd VT100 1 2 A Xadd VT100 2 1 1 L ;I only use 3/1200 baud Xadd VT100 2 1 2 H Xadd VT100 2 1 3 \ ;to avoid duplicates X X-------------- XBugs/problems: X XUsing 0 or negative numbers for menu positions is *not* recommended. XBefore I added the checks for end-of-menu, I would experience strange Xscreen displays trying to access menu # 1000, etc. even though it was just Xde-referencing the pointers. Anyone know why? X XPrograms with a space as the first character in the window title (eg XPageSetter) need to be filezapped (change the space to, say, a _). X XPrograms that re-use parts of the menu structure (eg Ahost); well, it doesn't Xhurt, but you can only specify 1 shortcut which shows up several times. X XPrograms that disable menu operations at various times (eg DPaint and XWorkbench) need to be taken case-by-case. I was disappointed about DPaint, Xalthough menu operations *are* allowed once the mouse is above the drawing Xarea. For Workbench, just allow disk activity to cease before using add. X XThis was originally interactive, and I just hacked it into "expert" mode Xat someone's request. If I ever get more than 10 minutes at a time with it, XI'll combine the two, and hopefully get to use some of the neato features Xlike ItemAddress and the MenuNumber macro. Be warned, I fully intend to steal Xmenus away from programs and let you select them in *mine*! X XI can't accept responsibility for any damages that may occur as a result Xof using this program (although I highly doubt any will happen). X-------------- XThis program is made available as shareware. Anyone may give it to anyone, Xbut not impose any conditions in doing so. If you feel that this program Xhas been worth $5 or so to you, you might want to send a small donation to: X XJohn Russell X5 Alderdice Place XSt. John's, NF, Canada XA1B 2P8 X XIf I get favourable response, I may expand the idea into a general screen/ Xwindow/menu management program, allowing you to customize the Intuition-based Xfeatures of other people's programs. Hmmm, I wonder what kind of Xcopyright conundrums *that* might create? "But officer, the spreadsheet I Xwrote has *none* of these filthy messages in it..." X END_OF_FILE echo shar: extracting add.c sed 's/^X//' << 'END_OF_FILE' > add.c X/* X * ADD (add keyboard shortcuts to menus) X * X * Copyright ((c)) 1987, John Russell X * This program is freely redistributable. Nobody may impose extra X * limitations on its distribution. X * X * Please distribute at least documentation with the executable. The X * source is straightforward, but could be informative for those who get X * blurred vision from reading those structure definitions in intuition.h. X * X * This program is shareware, and if you feel that it is useful to you X * (I *know* it is to me :-) a small contribution would be appreciated X * (see documentation). X */ X X/* Manx users compile with "+l" just in case */ X X#include X#include X X/* include standard stuff for _intuition_ */ X Xstruct NewWindow dummy = { X 0,0,1,1,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,0,0,WBENCHSCREEN X}; /* only to get address of the Workbench screen */ X Xstruct IntuitionBase *IntuitionBase; X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X struct Screen *screen; X struct Window *window; X struct MenuItem *item; X struct Menu *menu,*main_menu; X int x,cut; X X cut = argc-1; /* *argv[cut] == key to assign */ X X if ((IntuitionBase=(struct IntuitionBase *) X OpenLibrary("intuition.library",0L))==NULL) { X printf("Where is Intuition gone???\n"); X exit(0); X } X X if ((window=(struct Window *) X OpenWindow(&dummy))==NULL) { X printf("Can't open even a teeny-weeny window!\n"); X goto quit; /* background in basic shows through! */ X } X X screen = window->WScreen; /* address of Workbench screen structure */ X CloseWindow(window); /* no longer necessary */ X X while (screen != NULL) { /* do all screens */ X window = screen->FirstWindow; X while (window != NULL) { /* do all windows */ X if (compare(argv[1],window->Title)==0) { /* search for name */ X x=atoi(argv[2]); /* menu # */ X menu = window->MenuStrip; X main_menu = menu; /* main menu of window for SetMenuStrip */ X X while (--x > 0) { /* scan menu list */ X if ((menu = menu->NextMenu) == NULL) X goto quit; X } X x = atoi(argv[3]); /* item # */ X item = menu->FirstItem; Xsubmenu: X while (--x > 0) { /* scan item list */ X if ((item = item->NextItem) == NULL) X goto quit; X } X if (argc==6) { /* descend into sub-menu? */ X argc=0; X item=item->SubItem; X x=atoi(argv[4]); /* sub-item # */ X goto submenu; X } X ClearMenuStrip(window); /* disable menu structure */ X item->Flags |= COMMSEQ; /* add shortcut flag */ X item->Command = *argv[cut]; /* which key */ X printf("Added shortcut: %c.\n",*argv[cut]); X SetMenuStrip(window,main_menu); /* give it back */ X } X window = window->NextWindow; X } X screen = screen->NextScreen; X } X X quit: X X CloseLibrary(IntuitionBase); X X} X Xcompare(string1,string2) /* if spaces in windowname, only check first word */ Xchar *string1,*string2; X{ X while ((*string1 != '\0') && (*string1 != ' ')) { X if (*string1 != *string2) /* space and null both end conditions */ X return(1); X string1++; X string2++; X } X return(0); /* return weird values like strcmp() */ X} X END_OF_FILE echo shar: extracting add.uue sed 's/^X//' << 'END_OF_FILE' > add.uue Xbegin 600 add XM #\P # ( 3U V /I $]4ZY # XM)DY5_^(F+0 (4X,K0__B0J=(>@&T3KH33%!/*4""RDJ 9A)(>@&T3KH#/EA/ XM0J=.N@WL6$](;( "3KH3>EA/*T#_^$J 9@Y(>@&L3KH#&EA/8 !9BQM__@K XM;@ N__PO+?_X3KH31%A/2JW__&< 4HL;?_\*VX !/_X2JW_^&< 2PL;?_X XM+RX ("QM PO+@ $3KH!G%!/2H!F $$+&T #"\N A.N@'86$\K0/_F+&W_ XM^"MN !S_\"MM__#_[%.M_^8,K0 #_YF\2+&W_\"M6__!*K?_P9P W&#@ XM+&T #"\N Q.N@&66$\K0/_F+&W_\"MN !+_]%.M_^8,K0 #_YF\2+&W_ XM]"M6__1*K?_T9P H&#@#*T & AF(D*M @L;?_T*VX '/_T+&T #"\N XM !!.N@%"6$\K0/_F8+0O+?_X3KH23EA/+&W_] !N 0 #"QM__0F+?_BY8,B XM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