home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / DOpus4-GPL / Config / main4.c < prev    next >
C/C++ Source or Header  |  2000-01-27  |  16KB  |  566 lines

  1. /*
  2.  
  3. Directory Opus 4
  4. Original GPL release version 4.12
  5. Copyright 1993-2000 Jonathan Potter
  6.  
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. All users of Directory Opus 4 (including versions distributed
  22. under the GPL) are entitled to upgrade to the latest version of
  23. Directory Opus version 5 at a reduced price. Please see
  24. http://www.gpsoft.com.au for more information.
  25.  
  26. The release of Directory Opus 4 under the GPL in NO WAY affects
  27. the existing commercial status of Directory Opus 5.
  28.  
  29. */
  30.  
  31. #include "config.h"
  32.  
  33. static struct dopusfunction *seldrive;
  34.  
  35. dodriveconfig()
  36. {
  37.     ULONG class;
  38.     USHORT code,gadgetid,qual;
  39.     struct ConfigUndo *undo;
  40.     struct DOpusRemember *gadkey;
  41.     struct dopusfunction *seconddrive;
  42.     struct Gadget *gad;
  43.     struct Border *unselborder,*selborder;
  44.     int a,b,x,y,mode=-1,editon=0,dnum=-1,odnum;
  45.     char buf[256];
  46.  
  47.     gadkey=NULL;
  48.     if (!(drivegads=(struct Gadget *)LAllocRemember(&gadkey,sizeof(struct Gadget)*USEDRIVECOUNT,
  49.         MEMF_CLEAR))) return(0);
  50.  
  51.     CreateGadgetBorders(&gadkey,
  52.         80,10,
  53.         &selborder,&unselborder,
  54.         0,
  55.         screen_pens[config->gadgettopcol].pen,screen_pens[config->gadgetbotcol].pen);
  56.  
  57.     seldrive=NULL; seligad=NULL;
  58.  
  59.     x=x_off+76;
  60.     y=y_off+2;
  61.     for (a=0;a<USEDRIVECOUNT;a++) {
  62.         drivegads[a].NextGadget=(a<USEDRIVECOUNT-1)?&drivegads[a+1]:NULL;
  63.         drivegads[a].LeftEdge=x;
  64.         drivegads[a].TopEdge=y;
  65.         drivegads[a].Width=80;
  66.         drivegads[a].Height=10;
  67.         drivegads[a].Flags=(selborder)?GFLG_GADGHIMAGE:GFLG_GADGHCOMP;
  68.         drivegads[a].Activation=GACT_RELVERIFY;
  69.         drivegads[a].GadgetType=GTYP_BOOLGADGET;
  70.         drivegads[a].GadgetID=a+100;
  71.         drivegads[a].GadgetRender=unselborder;
  72.         drivegads[a].SelectRender=selborder;
  73.         if ((y+=10)>=y_off+62) {
  74.             y=y_off+2;
  75.             x+=100;
  76.         }
  77.     }
  78.  
  79.     namesinfo.MaxChars=16;
  80.     showconfigscreen(CFG_DRIVE);
  81.  
  82.     paint_state=0;
  83.     ClearMenuStrip(Window);
  84.     projectmenu.NextMenu=&neatstuffmenu;
  85.     neatstuffitem.Flags&=~CHECKED;
  86.     neatstuffmenu.LeftEdge=140;
  87.     FSSetMenuStrip(Window,&projectmenu);
  88.     undo=makeundo(UNDO_DRIVE);
  89.  
  90.     showdrives();
  91.  
  92.     FOREVER {
  93.         Wait(1<<Window->UserPort->mp_SigBit);
  94.         while (IMsg=getintuimsg()) {
  95.             class=IMsg->Class; code=IMsg->Code; x=IMsg->MouseX; y=IMsg->MouseY;
  96.             qual=IMsg->Qualifier;
  97.             if (class==GADGETUP || class==GADGETDOWN) {
  98.                 gad=(struct Gadget *)IMsg->IAddress;
  99.                 gadgetid=gad->GadgetID;
  100.             }
  101.             ReplyMsg((struct Message *)IMsg);
  102.             switch (class) {
  103.                 case IDCMP_MENUPICK:
  104.                     if (code==MENUNULL) break;
  105.                     if (seldrive) {
  106.                         select_gadget(seligad,0);
  107.                         seligad=NULL; seldrive=NULL;
  108.                     }
  109.                     if (editon) {
  110.                         driveeditoff();
  111.                         editon=0;
  112.                     }
  113.                     if (mode>-1) {
  114.                         select_gadget(&maingad[mode],0);
  115.                         mode=-1;
  116.                     }
  117.                     dogadgetinfo(NULL);
  118.                     switch (MENUNUM(code)) {
  119.                         case 0:
  120.                             switch ((a=ITEMNUM(code))) {
  121.                                 case 0:
  122.                                 case 1:
  123.                                     if (doload(CFG_DRIVE,a)) {
  124.                                         showdrives();
  125.                                         if (a) dogadgetinfo(cfg_string[STR_NEW_DRIVE_BANKS_LOADED]);
  126.                                         else dogadgetinfo(cfg_string[STR_DEFAULT_DRIVE_BANKS_RESET]);
  127.                                     }
  128.                                     break;
  129.                             }
  130.                             break;
  131.                         case 1:
  132.                             if (ITEMNUM(code)==0) {
  133.                                 if (neatstuffitem.Flags&CHECKED) {
  134.                                     if (!(paint_state=get_paint_colours(&paint_fg,&paint_bg,CFG_GADGET))) {
  135.                                         ClearMenuStrip(Window);
  136.                                         neatstuffitem.Flags&=~CHECKED;
  137.                                         FSSetMenuStrip(Window,&projectmenu);
  138.                                     }
  139.                                 }
  140.                                 else paint_state=0;
  141.                                 do_menuscreen_title(STR_DRIVE_SCREEN);
  142.                             }
  143.                             break;
  144.                     }
  145.                     break;
  146.  
  147.                 case IDCMP_RAWKEY:
  148.                     if (!seldrive || !editon || (code>=0x60 && code<=0x67) || code&0x80)
  149.                         break;
  150.                     if (editdrivegadgets[1].Flags&SELECTED) {
  151.                         qual&=IEQUALIFIER_LCOMMAND|IEQUALIFIER_RCOMMAND|
  152.                             IEQUALIFIER_CONTROL|IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT|
  153.                             IEQUALIFIER_LALT|IEQUALIFIER_RALT;
  154.                         seldrive->key=code; seldrive->qual=qual;
  155.                         showkey(seldrive->key,seldrive->qual,x_off+150,y_off+129,331,10);
  156.                         break;
  157.                     }
  158.                     buf[0]=0;
  159.                     RawkeyToStr(code,qual,NULL,buf,10);
  160.                     switch (LToUpper(buf[0])) {
  161.                         case 'N':
  162.                             ActivateStrGad(&editdrivegadgets[0],Window);
  163.                             break;
  164.                         case 'K':
  165.                             fixrmbimage(&sampleclearrmb,NULL,0,-1,-1);
  166.                             editdrivegadgets[1].Flags|=SELECTED;
  167.                             select_gadget(&editdrivegadgets[1],1);
  168.                             fixrmbimage(&sampleclearrmb,NULL,1,-1,-1);
  169.                             break;
  170.                         case 'P':
  171.                             ActivateStrGad(&editdrivegadgets[3],Window);
  172.                             break;
  173.                     }
  174.                     break;
  175.  
  176.                 case IDCMP_MOUSEBUTTONS:
  177.                     if (code==SELECTDOWN) {
  178.                         if (seldrive && editon) {
  179.                             a=seldrive->fpen; b=seldrive->bpen;
  180.                             if (docolourgad(rp,x_off+150,y_off+76,x,y,seldrive->name,&a,&b,CFG_DRIVE)) {
  181.                                 seldrive->fpen=a; seldrive->bpen=b;
  182.                                 showdrivename(seldrive,seligad);
  183.                             }
  184.                         }
  185.                     }
  186.                     else if (code==MENUDOWN) {
  187.                         if (!seldrive || !editon) break;
  188.                         if (fixrmbimage(&sampleclearrmb,NULL,0,x,y)) {
  189.                             a=DoRMBGadget(&sampleclearrmb,Window);
  190.                             fixrmbimage(&sampleclearrmb,NULL,1,-1,-1);
  191.                             if (a==0) {
  192.                                 seldrive->key=0xff;
  193.                                 seldrive->qual=0;
  194.                                 showkey(0,0,x_off+150,y_off+129,331,10);
  195.                             }
  196.                             editdrivegadgets[1].Flags&=~SELECTED;
  197.                             help_ok=1;
  198.                         }
  199.                     }
  200.                     break;
  201.  
  202.                 case IDCMP_GADGETUP:
  203.                     if (gadgetid<DRIVE_OKAY) {
  204.                         if (seldrive) {
  205.                             select_gadget(seligad,0);
  206.                             seligad=NULL; seldrive=NULL;
  207.                         }
  208.                         if (editon) {
  209.                             driveeditoff();
  210.                             editon=0;
  211.                         }
  212.                         if (mode==gadgetid) {
  213.                             mode=-1;
  214.                             dogadgetinfo(NULL);
  215.                             break;
  216.                         }
  217.                         if (mode>-1) {
  218.                             select_gadget(&maingad[mode],0);
  219.                             mode=-1;
  220.                         }
  221.                     }
  222.                     else if (gadgetid>=100) {
  223.                         a=gadgetid-100;
  224.                         odnum=dnum; dnum=a/6;
  225.                         if (mode>-1) {
  226.                             if (mode==DRIVE_DELETEDRIVE) {
  227.                                 deletedrive(&config->drive[a]);
  228.                                 seldrive=NULL;
  229.                                 dogadgetinfo(cfg_string[STR_DRIVE_GADGET_DELETED]);
  230.                                 showdrivename(seldrive,gad);
  231.                             }
  232.                             else if (!seldrive) {
  233.                                 seldrive=&config->drive[a];
  234.                                 seligad=gad;
  235.                                 select_gadget(gad,1);
  236.                                 switch (mode) {
  237.                                     case DRIVE_COPYDRIVE:
  238.                                         dogadgetinfo(cfg_string[STR_SELECT_DRIVE_TO_COPY_TO]);
  239.                                         break;
  240.                                     case DRIVE_SWAPDRIVE:
  241.                                         dogadgetinfo(cfg_string[STR_SELECT_DRIVE_TO_SWAP_WITH_FIRST]);
  242.                                         break;
  243.                                     case DRIVE_COPYBANK:
  244.                                         dogadgetinfo(cfg_string[STR_SELECT_DRIVE_BANK_TO_COPY_TO]);
  245.                                         break;
  246.                                     case DRIVE_SWAPBANK:
  247.                                         dogadgetinfo(cfg_string[STR_SELECT_DRIVE_BANK_TO_SWAP_WITH_FIRST]);
  248.                                         break;
  249.                                     case DRIVE_DELETEBANK:
  250.                                         if (request(cfg_string[STR_REALLY_DELETE_DRIVE_BANK])) {
  251.                                             x=dnum*6; b=x+6;
  252.                                             for (a=x;a<b;a++) deletedrive(&config->drive[a]);
  253.                                         }
  254.                                         seldrive=NULL;
  255.                                         showdrives();
  256.                                         doinitdrivetext(mode);
  257.                                         break;
  258.                                     case DRIVE_SORTBANK:
  259.                                         sortdrivebank(dnum);
  260.                                         seldrive=NULL;
  261.                                         showdrives();
  262.                                         doinitdrivetext(mode);
  263.                                         break;
  264.                                 }
  265.                             }
  266.                             else {
  267.                                 seconddrive=&config->drive[a];
  268.                                 if (seldrive==seconddrive) select_gadget(gad,0);
  269.                                 else {
  270.                                     switch (mode) {
  271.                                         case DRIVE_COPYDRIVE:
  272.                                             CopyMem((char *)seldrive,(char *)seconddrive,sizeof(struct dopusfunction));
  273.                                             seconddrive->function=getcopy(seldrive->function,-1,NULL);
  274.                                             break;
  275.                                         case DRIVE_SWAPDRIVE:
  276.                                             SwapMem((char *)seldrive,(char *)seconddrive,sizeof(struct dopusfunction));
  277.                                             break;
  278.                                         case DRIVE_COPYBANK:
  279.                                             if (dnum!=odnum) {
  280.                                                 for (a=0;a<6;a++) {
  281.                                                     CopyMem((char *)&config->drive[(odnum*6)+a],
  282.                                                         (char *)&config->drive[(dnum*6)+a],sizeof(struct dopusfunction));
  283.                                                     config->drive[(dnum*6)+a].function=getcopy(config->drive[(odnum*6)+a].function,-1,NULL);
  284.                                                 }
  285.                                             }
  286.                                             break;
  287.                                         case DRIVE_SWAPBANK:
  288.                                             if (dnum!=odnum)
  289.                                                 SwapMem((char *)&config->drive[odnum*6],
  290.                                                     (char *)&config->drive[dnum*6],sizeof(struct dopusfunction)*6);
  291.                                             break;
  292.                                     }
  293.                                     seldrive=NULL;
  294.                                     showdrives();
  295.                                 }
  296.                                 seldrive=NULL; seligad=NULL;
  297.                                 doinitdrivetext(mode);
  298.                             }
  299.                         }
  300.                         else {
  301.                             if (paint_state) {
  302.                                 config->drive[a].fpen=paint_fg;
  303.                                 config->drive[a].bpen=paint_bg;
  304.                                 showdrivename(&config->drive[a],gad);
  305.                             }
  306.                             else {
  307.                                 if (seldrive && editon) select_gadget(seligad,0);
  308.                                 if (seldrive==&config->drive[a]) {
  309.                                     driveeditoff();
  310.                                     editon=0;
  311.                                     break;
  312.                                 }
  313.                                 seligad=gad; seldrive=&config->drive[a];
  314.                                 showdrivename(seldrive,gad);
  315.                                 setupcolourbox(rp,x_off+150,y_off+76,seldrive->fpen,seldrive->bpen);
  316.                                 strcpy(edit_namebuf,seldrive->name);
  317.                                 if (seldrive->function) strcpy(edit_pathbuf,seldrive->function);
  318.                                 else edit_pathbuf[0]=0;
  319.                                 SetAPen(rp,screen_pens[1].pen);
  320.                                 if (!editon) {
  321.                                     do_gad_label(cfg_string[STR_SHORTCUT_KEY],x_off+139,y_off+136);
  322.                                     do_gad_label(cfg_string[STR_PATH],x_off+139,y_off+122);
  323.                                     editdrivegadgets[1].Flags&=~SELECTED;
  324.                                     AddGadgets(Window,
  325.                                         editdrivegadgets,
  326.                                         drivegadgets2,
  327.                                         4,
  328.                                         screen_pens[config->gadgettopcol].pen,screen_pens[config->gadgetbotcol].pen,1);
  329.                                     fixrmbimage(&sampleclearrmb,&editdrivegadgets[1],2,-1,-1);
  330.                                     doglassimage(&editdrivegadgets[2]);
  331.                                 }
  332.                                 else {
  333.                                     RefreshStrGad(&editdrivegadgets[0],Window);
  334.                                     RefreshStrGad(&editdrivegadgets[3],Window);
  335.                                 }
  336.                                 if (editdrivegadgets[1].Flags&SELECTED) {
  337.                                     fixrmbimage(&sampleclearrmb,NULL,0,-1,-1);
  338.                                     editdrivegadgets[1].Flags&=~SELECTED;
  339.                                     select_gadget(&editdrivegadgets[1],0);
  340.                                     fixrmbimage(&sampleclearrmb,NULL,1,-1,-1);
  341.                                 }
  342.                                 showfuncob(rp,seldrive->name,seldrive->fpen,seldrive->bpen,CFG_DRIVE,x_off+244,y_off+66);
  343.                                 showkey(seldrive->key,seldrive->qual,x_off+150,y_off+129,331,10);
  344.                                 editon=1;
  345.                             }
  346.                         }
  347.                         break;
  348.                     }
  349.                     switch (gadgetid) {
  350.                         case DRIVE_GETDRIVES:
  351.                             {
  352.                                 char fpen_back[USEDRIVECOUNT],bpen_back[USEDRIVECOUNT];
  353.                                 int a;
  354.  
  355.                                 for (a=0;a<USEDRIVECOUNT;a++) {
  356.                                     fpen_back[a]=config->drive[a].fpen;
  357.                                     bpen_back[a]=config->drive[a].bpen;
  358.                                 }
  359.                                 fixcstuff(&cstuff);
  360.                                 GetDevices(&cstuff);
  361.                                 seldrive=NULL;
  362.                                 for (a=0;a<USEDRIVECOUNT;a++) {
  363.                                     config->drive[a].fpen=fpen_back[a];
  364.                                     config->drive[a].bpen=bpen_back[a];
  365.                                 }
  366.                                 showdrives();
  367.                                 dogadgetinfo(cfg_string[STR_SYSTEM_DEVICES_LISTED]);
  368.                             }
  369.                             break;
  370.  
  371.                         case DRIVE_EDITNAME:
  372.                             strcpy(seldrive->name,edit_namebuf);
  373.                             showfuncob(rp,seldrive->name,seldrive->fpen,seldrive->bpen,CFG_DRIVE,x_off+244,y_off+66);
  374.                             showdrivename(seldrive,seligad);
  375.                             if (code!=0x9) getnextgadget(gad);
  376.                             break;
  377.  
  378.                         case DRIVE_EDITPATH:
  379.                             freestring(seldrive->function);
  380.                             seldrive->function=getcopy(edit_pathbuf,-1,NULL);
  381.                             if (code!=0x9) getnextgadget(gad);
  382.                             break;
  383.  
  384.                         case DRIVE_EDITREQ:
  385.                             strcpy(dirbuf,edit_pathbuf);
  386.                             if (funcrequester(FREQ_PATHREQ,buf,NULL)) {
  387.                                 LStrnCpy(edit_pathbuf,buf,32); edit_pathbuf[32]=0;
  388.                                 b=strlen(edit_pathbuf);
  389.                                 for (a=b;a>=0;a--) {
  390.                                     if (edit_pathbuf[a]=='/' || edit_pathbuf[a]==':') {
  391.                                         edit_pathbuf[a+1]=0;
  392.                                         break;
  393.                                     }
  394.                                 }
  395.                                 freestring(seldrive->function);
  396.                                 seldrive->function=getcopy(edit_pathbuf,-1,NULL);
  397.                                 RefreshStrGad(&editdrivegadgets[3],Window);
  398.                             }
  399.                             break;
  400.  
  401.                         case DRIVE_EDITSAMPLE:
  402.                             help_ok=(editdrivegadgets[1].Flags&SELECTED)?0:1;
  403.                             break;
  404.  
  405.                         case DRIVE_CANCEL:
  406.                             doundo(undo,UNDO_DRIVE);
  407.                         case DRIVE_OKAY:
  408.                             doundo(undo,0);
  409.                             RemoveGList(Window,drivegads,USEDRIVECOUNT);
  410.                             LFreeRemember(&gadkey); drivegads=NULL;
  411.                             ClearMenuStrip(Window); projectmenu.NextMenu=NULL;
  412.                             FSSetMenuStrip(Window,&projectmenu);
  413.                             help_ok=1;
  414.                             paint_state=0;
  415.                             return((gadgetid==DRIVE_OKAY));
  416.                     }
  417.                     mode=doinitdrivetext(gadgetid);
  418.                     break;
  419.             }
  420.         }
  421.     }
  422. }
  423.  
  424. void showdrives()
  425. {
  426.     int a;
  427.  
  428.     for (a=0;a<USEDRIVECOUNT;a++)
  429.         showdrivename(&config->drive[a],&drivegads[a]);
  430. }
  431.  
  432. void showdrivename(drive,gadget)
  433. struct dopusfunction *drive;
  434. struct Gadget *gadget;
  435. {
  436.     int a,x,y;
  437.     char showname[16];
  438.  
  439.     x=gadget->LeftEdge;
  440.     y=gadget->TopEdge;
  441.     if (drive) SetAPen(rp,screen_pens[drive->bpen].pen);
  442.     else SetAPen(rp,screen_pens[0].pen);
  443.     RectFill(rp,x+2,y+1,x+77,y+8);
  444.     do3dbox(x+2,y+1,76,8);
  445.     if (drive) {
  446.         SetAPen(rp,screen_pens[drive->fpen].pen);
  447.         SetBPen(rp,screen_pens[drive->bpen].pen);
  448.         strcpy(showname,drive->name); showname[9]=0;
  449.         UScoreText(rp,showname,x+((80-((a=strlen(showname))*8))/2),y+7,-1);
  450.         SetBPen(rp,screen_pens[0].pen);
  451.         if (seldrive==drive) select_gadget(seligad,1);
  452.     }
  453. }
  454.  
  455. doinitdrivetext(id)
  456. int id;
  457. {
  458.     int mode=-1;
  459.  
  460.     switch (id) {
  461.         case DRIVE_COPYBANK:
  462.             mode=DRIVE_COPYBANK;
  463.             dogadgetinfo(cfg_string[STR_SELECT_DRIVE_BANK_TO_COPY]);
  464.             break;
  465.         case DRIVE_SWAPBANK:
  466.             mode=DRIVE_SWAPBANK;
  467.             dogadgetinfo(cfg_string[STR_SELECT_DRIVE_BANK_TO_SWAP]);
  468.             break;
  469.         case DRIVE_DELETEBANK:
  470.             mode=DRIVE_DELETEBANK;
  471.             dogadgetinfo(cfg_string[STR_SELECT_DRIVE_BANK_TO_DELETE]);
  472.             break;
  473.         case DRIVE_SORTBANK:
  474.             mode=DRIVE_SORTBANK;
  475.             dogadgetinfo(cfg_string[STR_SELECT_DRIVE_BANK_TO_SORT]);
  476.             break;
  477.         case DRIVE_COPYDRIVE:
  478.             mode=DRIVE_COPYDRIVE;
  479.             dogadgetinfo(cfg_string[STR_SELECT_DRIVE_GADGET_TO_COPY]);
  480.             break;
  481.         case DRIVE_SWAPDRIVE:
  482.             mode=DRIVE_SWAPDRIVE;
  483.             dogadgetinfo(cfg_string[STR_SELECT_DRIVE_GADGET_TO_SWAP]);
  484.             break;
  485.         case DRIVE_DELETEDRIVE:
  486.             mode=DRIVE_DELETEDRIVE;
  487.             dogadgetinfo(cfg_string[STR_SELECT_DRIVE_GADGET_TO_DELETE]);
  488.             break;
  489.     }
  490.     return(mode);
  491. }
  492.  
  493. docolourgad(r,x,y,mx,my,name,fp,bp,type)
  494. struct RastPort *r;
  495. int x,y,mx,my;
  496. char *name;
  497. int *fp,*bp,type;
  498. {
  499.     int num,box;
  500.  
  501.     if (my>y && my<y+21) {
  502.         for (box=0;box<2;box++) {
  503.             for (num=0;num<colour_box_num;num++) {
  504.                 if (mx>=colour_box_xy[box][num][0] && mx<=colour_box_xy[box][num][2] &&
  505.                     my>=colour_box_xy[box][num][1] && my<=colour_box_xy[box][num][3]) {
  506.                     if ((box==0 && *fp!=num) || (box==1 && *bp!=num)) {
  507.                         docoloursel(r,x+(box*248),y,(box==0)?*fp:*bp);
  508.                         docoloursel(r,x+(box*248),y,num);
  509.                         if (box==0) *fp=num;
  510.                         else *bp=num;
  511.                         if (name) showfuncob(r,name,*fp,*bp,type,x+94,y-10);
  512.                         return(1);
  513.                     }
  514.                     return(0);
  515.                 }
  516.             }
  517.         }
  518.     }
  519.     return(0);
  520. }
  521.  
  522. void driveeditoff()
  523. {
  524.     seldrive=NULL; seligad=NULL;
  525.     SetAPen(rp,screen_pens[0].pen);
  526.     RectFill(rp,
  527.         x_off+2,y_off+65,
  528.         x_bot,y_off+140);
  529.     RemoveGList(Window,editdrivegadgets,4);
  530. }
  531.  
  532. void deletedrive(drive)
  533. struct dopusfunction *drive;
  534. {
  535.     drive->name[0]=0;
  536.     freestring(drive->function); drive->function=NULL;
  537.     drive->key=drive->qual=0;
  538.     if (paint_state) {
  539.         drive->fpen=paint_fg;
  540.         drive->bpen=paint_bg;
  541.     }
  542.     else {
  543.         drive->fpen=1;
  544.         drive->bpen=0;
  545.     }
  546. }
  547.  
  548. void sortdrivebank(m)
  549. int m;
  550. {
  551.     int gap,i,j,k;
  552.     char *ptr1,*ptr2,*zstr="\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f";
  553.  
  554.     m*=6;
  555.     for (gap=3;gap>0;gap/=2)
  556.         for (i=gap;i<6;i++)
  557.             for (j=i-gap;j>=0;j-=gap) {
  558.                 k=j+gap;
  559.                 ptr1=(config->drive[j+m].name[0])?config->drive[j+m].name:zstr;
  560.                 ptr2=(config->drive[k+m].name[0])?config->drive[k+m].name:zstr;
  561.                 if (LStrCmpI(ptr1,ptr2)<=0) break;
  562.                 SwapMem((char *)&config->drive[j+m],(char *)&config->drive[k+m],
  563.                     sizeof(struct dopusfunction));
  564.             }
  565. }
  566.