home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / DOpus4-GPL / Program / doidcmp.c < prev    next >
C/C++ Source or Header  |  2000-01-27  |  26KB  |  796 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 "DOpus.h"
  32.  
  33. extern struct IntuiMessage *getintuimsg();
  34.  
  35. void doidcmp()
  36. {
  37.     int x,y,a,function,wmes,stringgd=0,waitbits,b,x1,y1,c,win,dir,num;
  38.     ULONG class;
  39.     USHORT code,gadgetid,menunum,itemnum,qual;
  40.     UBYTE old_change_state;
  41.     char buf[80],buf2[30],ch;
  42.     struct dopusgadgetbanks *bank,*bank1;
  43.     struct AppMessage *apmsg;
  44.     struct dopushotkey *hotkey;
  45.     struct dopusfuncpar par;
  46.     struct Gadget *gad;
  47.     struct MenuItem *item;
  48.  
  49. foreverloop:
  50.     FOREVER {
  51.         waitbits=1<<Window->UserPort->mp_SigBit|1<<count_port->mp_SigBit|rexx_signalbit|INPUTSIG_HOTKEY;
  52.         if (system_version2 && WorkbenchBase && dopus_appwindow)
  53.             waitbits|=1<<appmsg_port->mp_SigBit;
  54.         if ((wmes=Wait(waitbits))&INPUTSIG_HOTKEY) {
  55.             if (dopus_globalhotkey==(struct dopushotkey *)-1) {
  56.                 function=FUNC_QUIT; dopus_globalhotkey=NULL;
  57.                 goto foobarbaz;
  58.             }
  59.             else if (dopus_globalhotkey==(struct dopushotkey *)-2) {
  60.                 function=FUNC_ICONIFY; dopus_globalhotkey=NULL;
  61.                 goto foobarbaz;
  62.             }
  63.             else if (!dopus_globalhotkey) continue;
  64.             hotkey=dopus_globalhotkey; dopus_globalhotkey=NULL;
  65.             CopyMem((char *)&hotkey->func.which,(char *)&par,sizeof(struct dopusfuncpar));
  66.             par.which&=FLAG_OUTWIND|FLAG_NOQUOTE|FLAG_SHELLUP|FLAG_DOPUSUP;
  67.             par.which|=FLAG_ASYNC;
  68.             if (par.which&FLAG_OUTWIND) par.which|=FLAG_WB2F;
  69.             status_flags|=STATUS_FROMHOTKEY;
  70.             dofunctionstring(hotkey->func.function,hotkey->name,NULL,&par);
  71.             status_flags&=~STATUS_FROMHOTKEY;
  72.             continue;
  73.         }
  74.         if (wmes&rexx_signalbit) {
  75.             rexx_dispatch(1);
  76.             if (func_global_function)
  77.                 internal_function(func_global_function,rexx_global_flag,NULL,NULL);
  78.             status_haveaborted=0;
  79.             continue;
  80.         }
  81.         if (WorkbenchBase && dopus_appwindow &&
  82.             (wmes&(1<<appmsg_port->mp_SigBit))) {
  83.             ActivateWindow(Window);
  84.             while ((apmsg=(struct AppMessage *)GetMsg(appmsg_port))) {
  85.                 if (apmsg->am_Type==MTYPE_APPWINDOW && apmsg->am_ID==APPWINID) {
  86.                     for (a=0;a<apmsg->am_NumArgs;a++) {
  87.                         if (apmsg->am_ArgList[a].wa_Lock) {
  88.                             if ((b=isinwindow(apmsg->am_MouseX,apmsg->am_MouseY))!=-1) {
  89.                                 if (!(*apmsg->am_ArgList[a].wa_Name)) {
  90.                                     PathName(apmsg->am_ArgList[a].wa_Lock,str_pathbuffer[b],256);
  91.                                     checkdir(str_pathbuffer[b],&path_strgadget[b]);
  92.                                     startgetdir(b,SGDFLAGS_CANMOVEEMPTY);
  93.                                     break;
  94.                                 }
  95.                                 else {
  96.                                     c=data_active_window;
  97.                                     makeactive(b,0);
  98.                                     PathName(apmsg->am_ArgList[a].wa_Lock,func_external_file,256);
  99.                                     TackOn(func_external_file,apmsg->am_ArgList[a].wa_Name,256);
  100.                                     dofunctionstring("*copy",NULL,NULL,NULL);
  101.                                     makeactive(c,0);
  102.                                 }
  103.                             }
  104.                             else if (dopus_curgadbank &&
  105.                                 (b=gadgetfrompos(apmsg->am_MouseX,apmsg->am_MouseY))!=-1) {
  106.                                 b+=(data_gadgetrow_offset*7);
  107.                                 if (isvalidgad(&dopus_curgadbank->gadgets[b])) {
  108.                                     PathName(apmsg->am_ArgList[a].wa_Lock,func_external_file,256);
  109.                                     if (func_external_file[0] &&
  110.                                         func_external_file[(strlen(func_external_file)-1)]==':' &&
  111.                                         !apmsg->am_ArgList[a].wa_Name[0])
  112.                                         TackOn(func_external_file,"Disk.info",256);
  113.                                     else TackOn(func_external_file,apmsg->am_ArgList[a].wa_Name,256);
  114.                                     if (!(CheckExist(func_external_file,NULL)))
  115.                                         StrConcat(func_external_file,".info",256);
  116.                                     dofunctionstring(dopus_curgadbank->gadgets[b].function,
  117.                                         dopus_curgadbank->gadgets[b].name,
  118.                                         NULL,(struct dopusfuncpar *)&dopus_curgadbank->gadgets[b].which);
  119.                                 }
  120.                             }
  121.                             else if (apmsg->am_MouseY<scrdata_yoffset+scrdata_status_height) {
  122.                                 if (apmsg->am_ArgList[a].wa_Name[0]) {
  123.                                     char pathbuf[256];
  124.  
  125.                                     PathName(apmsg->am_ArgList[a].wa_Lock,pathbuf,256);
  126.                                     strcpy(func_external_file,pathbuf);
  127.                                     TackOn(func_external_file,apmsg->am_ArgList[a].wa_Name,256);
  128.                                     ftype_doubleclick(pathbuf,apmsg->am_ArgList[a].wa_Name,0);
  129.                                     unbusy();
  130.                                 }
  131.                             }
  132.                         }
  133.                     }
  134.                     func_external_file[0]=0;
  135.                 }
  136.                 ReplyMsg((struct Message *)apmsg);
  137.             }
  138.         }
  139.         if (wmes&(1<<count_port->mp_SigBit)) {
  140.             struct NotifyMessage *note;
  141.             int got=0;
  142.  
  143.             while ((note=(struct NotifyMessage *)GetMsg(count_port))) {
  144.                 if (system_version2 && config->dynamicflags&UPDATE_NOTIFY) {
  145.                     a=note->nm_NReq->nr_UserData;
  146.                     ReplyMsg((struct Message *)note);
  147.                     if (!(got&(1<<a))) {
  148.                         got|=1<<a;
  149.  
  150.                         if (a==0 || a==1) {
  151.                             if (!(config->dirflags&DIRFLAGS_REREADOLD) ||
  152.                                 IntuitionBase->ActiveWindow==Window) {
  153.                                 struct DirWindowPars notifypars;
  154.  
  155.                                 notifypars.reselection_list=NULL;
  156.                                 makereselect(¬ifypars,a);
  157.                                 startgetdir(a,SGDFLAGS_CANMOVEEMPTY);
  158.                                 doreselect(¬ifypars,0);
  159.                                 makereselect(¬ifypars,-1);
  160.                             }
  161.                         }
  162.                     }
  163.                 }
  164.                 else ReplyMsg((struct Message *)note);
  165.             }
  166.         }
  167.         while (getintuimsg()) {
  168.             x=IMsg->MouseX;
  169.             y=IMsg->MouseY;
  170.             time_current_sec=IMsg->Seconds;
  171.             time_current_micro=IMsg->Micros;
  172.             class=IMsg->Class;
  173.             code=IMsg->Code;
  174.             qual=IMsg->Qualifier;
  175.             if (class==IDCMP_GADGETUP || class==IDCMP_GADGETDOWN) {
  176.                 gad=(struct Gadget *) IMsg->IAddress;
  177.                 gadgetid=gad->GadgetID;
  178.             }
  179.             ReplyMsg((struct Message *) IMsg);
  180.             if (Window->FirstRequest) continue;
  181.  
  182.             function=status_haveaborted=0;
  183.             switch (class) {
  184.                 case IDCMP_ACTIVEWINDOW:
  185.                     for (a=0;a<2;a++) check_old_buffer(a);
  186.                     break;
  187.  
  188.                 case IDCMP_NEWSIZE:
  189.                     config->scr_winw=Window->Width;
  190.                     config->scr_winh=Window->Height;
  191.                     if (!MainScreen) {
  192.                         config->scrw=config->scr_winw;
  193.                         config->scrh=config->scr_winh;
  194.                     }
  195.                     config->screenflags&=~(SCRFLAGS_DEFWIDTH|SCRFLAGS_DEFHEIGHT);
  196.                     remclock();
  197.                     SetUp(0);
  198.                     dostatustext(str_last_statustext);
  199.                     break;
  200.  
  201.                 case IDCMP_CLOSEWINDOW:
  202.                     busy();
  203.                     if ((a=simplerequest(globstring[STR_REALLY_QUIT],
  204.                         globstring[STR_QUIT],str_cancelstring,globstring[STR_ICONIFY],NULL))) {
  205.                         if (a==2) function=FUNC_ICONIFY;
  206.                         else {
  207.                             function=FUNC_QUIT;
  208.                             rexx_argcount=1;
  209.                             strcpy(rexx_args[0],"force");
  210.                         }
  211.                     }
  212.                     unbusy();
  213.                     break;
  214.  
  215.                 case IDCMP_DISKREMOVED:
  216.                     setupchangestate();
  217.                     break;
  218.  
  219.                 case IDCMP_DISKINSERTED:
  220.                     old_change_state=disk_change_state;
  221.                     setupchangestate();
  222.                     if (config->dirflags&DIRFLAGS_AUTODISKC) {
  223.                         if (IntuitionBase->ActiveWindow==Window || !(status_flags&STATUS_IANSCRAP)) {
  224.                             c=0;
  225.                             for (a=0;a<4;a++) {
  226.                                 if ((old_change_state&(1<<a))!=(disk_change_state&(1<<a))) {
  227.                                     lsprintf(buf,"DF%ld:",a);
  228.                                     lsprintf(buf2,"PC%ld:",a);
  229.                                     for (b=0;b<2;b++) {
  230.                                         if ((LStrCmpI(dopus_curwin[b]->realdevice,buf)==0) ||
  231.                                             (LStrCmpI(dopus_curwin[b]->realdevice,buf2)==0)) {
  232.                                             identify_and_load(b,a);
  233.                                             c=1;
  234.                                         }
  235.                                     }
  236.                                 }
  237.                                 if (c) break;
  238.                             }
  239.                             if (c) break;
  240.                         }
  241.                     }
  242.                     if (IntuitionBase->ActiveWindow==Window) {
  243.                         if (config->dirflags&DIRFLAGS_AUTODISKL) {
  244.                             for (a=0;a<4;a++) {
  245.                                 if ((old_change_state&(1<<a))!=(disk_change_state&(1<<a)) &&
  246.                                     identify_and_load(-1,a)) {
  247.                                     lsprintf(buf,globstring[STR_NEW_DISK_INSERTED],a);
  248.                                     if ((b=simplerequest(buf,globstring[STR_LEFT_WINDOW],
  249.                                         str_cancelstring,globstring[STR_RIGHT_WINDOW],NULL))) {
  250.                                         identify_and_load(b-1,a);
  251.                                     }
  252.                                 }
  253.                             }
  254.                         }
  255.                     }
  256.                     break;
  257.  
  258.                 case IDCMP_RAWKEY:
  259.                     code&=0x7f;
  260.                     readkeys(var_key_matrix);
  261.                     a=code/8; b=code-(a*8);
  262.                     if (!(var_key_matrix[a]&(1<<b))) {
  263.                         flushidcmp();
  264.                         break;
  265.                     }
  266.                     qual&=VALID_QUALIFIERS;
  267.                     bank=dopus_firstgadbank;
  268.                     while (bank) {
  269.                         for (a=0;a<GADCOUNT;a++) {
  270.                             if (check_key_press((struct dopusfunction *)&bank->gadgets[a],code,qual)) {
  271.                                 dofunctionstring(bank->gadgets[a].function,bank->gadgets[a].name,
  272.                                     NULL,(struct dopusfuncpar *)&bank->gadgets[a].which);
  273.                                 goto foobarbaz;
  274.                             }
  275.                         }
  276.                         bank=bank->next;
  277.                     }
  278.                     for (a=0;a<MENUCOUNT;a++) {
  279.                         if (check_key_press((struct dopusfunction *)&config->menu[a],code,qual)) {
  280.                             dofunctionstring(config->menu[a].function,config->menu[a].name,
  281.                                 NULL,(struct dopusfuncpar *)&config->menu[a].which);
  282.                             goto foobarbaz;
  283.                         }
  284.                     }
  285.                     for (a=0;a<USEDRIVECOUNT;a++) {
  286.                         if (check_key_press(&config->drive[a],code,qual)) {
  287.                             strcpy(str_pathbuffer[data_active_window],config->drive[a].function);
  288.                             startgetdir(data_active_window,SGDFLAGS_CANMOVEEMPTY);
  289.                             goto foobarbaz;
  290.                         }
  291.                     }
  292.                     if (qual&(IEQUALIFIER_RCOMMAND|IEQUALIFIER_LCOMMAND)) {
  293.                         switch (code) {
  294.                             case 0x13: function=FUNC_RESELECT; break;
  295.                             case 0x20: function=FUNC_AREXX; break;
  296.                             case 0x21: function=FUNC_SELECT; break;
  297.                             case 0x35: function=FUNC_BUFFERLIST; break;
  298.                             case 0x40:
  299.                                 if (qual&IEQUALIFIER_LCOMMAND) findfirstsel(data_active_window,ENTRY_FILE);
  300.                                 else findfirstsel(data_active_window,ENTRY_DIRECTORY);
  301.                                 break;
  302.                         }
  303.                     }
  304.                     else {
  305.                         switch (code) {
  306.                             case CURSOR_UP:
  307.                                 if (dopus_curwin[data_active_window]->total<scrdata_dispwin_lines) break;
  308.                                 if (qual&(IEQUALIFIER_CONTROL|IEQUALIFIER_ANYSHIFT)) {
  309.                                     if (qual&IEQUALIFIER_CONTROL) dopus_curwin[data_active_window]->offset=0;
  310.                                     else {
  311.                                         dopus_curwin[data_active_window]->offset-=scrdata_dispwin_lines;
  312.                                         if (dopus_curwin[data_active_window]->offset<0)
  313.                                             dopus_curwin[data_active_window]->offset=0;
  314.                                     }
  315.                                     fixvertprop(data_active_window);
  316.                                     displaydir(data_active_window);
  317.                                     break;
  318.                                 }
  319.                                 verticalscroll(data_active_window,-1);
  320.                                 break;
  321.                             case CURSOR_DOWN:
  322.                                 if (dopus_curwin[data_active_window]->total<scrdata_dispwin_lines) break;
  323.                                 if (qual&(IEQUALIFIER_CONTROL|IEQUALIFIER_ANYSHIFT)) {
  324.                                     if (qual&IEQUALIFIER_CONTROL)
  325.                                         dopus_curwin[data_active_window]->offset=dopus_curwin[data_active_window]->total-scrdata_dispwin_lines;
  326.                                     else {
  327.                                         dopus_curwin[data_active_window]->offset+=scrdata_dispwin_lines;
  328.                                         if (dopus_curwin[data_active_window]->offset>dopus_curwin[data_active_window]->total-scrdata_dispwin_lines)
  329.                                             dopus_curwin[data_active_window]->offset=dopus_curwin[data_active_window]->total-scrdata_dispwin_lines;
  330.                                     }
  331.                                     fixvertprop(data_active_window);
  332.                                     displaydir(data_active_window);
  333.                                     break;
  334.                                 }
  335.                                 verticalscroll(data_active_window,1);
  336.                                 break;
  337.                             case CURSOR_LEFT:
  338.                                 if (qual&(IEQUALIFIER_LALT|IEQUALIFIER_RALT)) {
  339.                                     incrementbuf(data_active_window,-1,1);
  340.                                     break;
  341.                                 }
  342.                                 if (dopus_curwin[data_active_window]->total==0) break;
  343.                                 if (qual&(IEQUALIFIER_CONTROL|IEQUALIFIER_ANYSHIFT)) {
  344.                                     if (qual&IEQUALIFIER_CONTROL) dopus_curwin[data_active_window]->hoffset=0;
  345.                                     else {
  346.                                         dopus_curwin[data_active_window]->hoffset-=scrdata_dispwin_nchars[data_active_window];
  347.                                         if (dopus_curwin[data_active_window]->hoffset<0) dopus_curwin[data_active_window]->hoffset=0;
  348.                                     }
  349.                                     refreshwindow(data_active_window,1);
  350.                                     break;
  351.                                 }
  352.                                 horizontalscroll(data_active_window,-1);
  353.                                 break;
  354.                             case CURSOR_RIGHT:
  355.                                 if (qual&(IEQUALIFIER_LALT|IEQUALIFIER_RALT)) {
  356.                                     incrementbuf(data_active_window,1,1);
  357.                                     break;
  358.                                 }
  359.                                 if (dopus_curwin[data_active_window]->total==0) break;
  360.                                 if (qual&(IEQUALIFIER_CONTROL|IEQUALIFIER_ANYSHIFT)) {
  361.                                     if (qual&IEQUALIFIER_CONTROL) {
  362.                                         dopus_curwin[data_active_window]->hoffset=dopus_curwin[data_active_window]->hlen-scrdata_dispwin_nchars[data_active_window];
  363.                                         if (dopus_curwin[data_active_window]->hoffset<0) dopus_curwin[data_active_window]->hoffset=0;
  364.                                     }
  365.                                     else {
  366.                                         dopus_curwin[data_active_window]->hoffset+=scrdata_dispwin_nchars[data_active_window];
  367.                                         if (dopus_curwin[data_active_window]->hoffset>=(dopus_curwin[data_active_window]->hlen-scrdata_dispwin_nchars[data_active_window]))
  368.                                             dopus_curwin[data_active_window]->hoffset=dopus_curwin[data_active_window]->hlen-scrdata_dispwin_nchars[data_active_window];
  369.                                     }
  370.                                     refreshwindow(data_active_window,1);
  371.                                     break;
  372.                                 }
  373.                                 horizontalscroll(data_active_window,1);
  374.                                 break;
  375.                         }
  376.                         switch (code) {
  377.                             case 0x5f:
  378.                                 function=FUNC_HELP;
  379.                                 break;
  380.                             case 0x40:
  381.                             case 0x42:
  382.                                 makeactive(1-data_active_window,1);
  383.                                 break;
  384.                             case 0x44:
  385.                                 if (qual&IEQUALIFIER_ANYSHIFT) function=FUNC_BUFFERLIST;
  386.                                 else if (qual&(IEQUALIFIER_LALT|IEQUALIFIER_RALT)) function=FUNC_DEVICELIST;
  387.                                 else ActivateStrGad(&path_strgadget[data_active_window],Window);
  388.                                 break;
  389.                             case 0x0b:
  390.                                 dosizedirwindows(-60000);
  391.                                 break;
  392.                             case 0x0c:
  393.                                 dosizedirwindows(0);
  394.                                 break;
  395.                             case 0x0d:
  396.                                 dosizedirwindows(60000);
  397.                                 break;
  398.                             case 0x1a:
  399.                                 goto prevgadgetbank;
  400.                                 break;
  401.                             case 0x1b:
  402.                                 goto nextgadgetbank;
  403.                                 break;
  404.                             default:
  405.                                 if (code<0x40 && !(qual&IEQUALIFIER_CONTROL)) {
  406.                                     RawkeyToStr(code,qual,NULL,buf,0);
  407.                                     ch=buf[0];
  408.                                     if (isprint(ch)) findfirstchar(data_active_window,ch);
  409.                                 }
  410.                               break;
  411.                       }
  412.                     }
  413.                     unbusy();
  414. foobarbaz:
  415.                     break;
  416.  
  417.                 case IDCMP_MENUPICK:
  418.                     Window->Flags|=RMBTRAP;
  419.                     if (!Window->MenuStrip) break;
  420.                     if (stringgd) {
  421.                         checkstringgads(stringgd);
  422.                         stringgd=0;
  423.                     }
  424.                     if (code==MENUNULL) break;
  425.                     menunum=menu_real_number[MENUNUM(code)];
  426.                     num=ITEMNUM(code);
  427.                     item=menu_menus[menunum].FirstItem;
  428.                     for (a=0,itemnum=0;a<num && item;a++) {
  429.                         if (item->Flags&ITEMTEXT) ++itemnum;
  430.                         item=item->NextItem;
  431.                     }
  432.                     if (item) {
  433.                         a=(menunum*20)+itemnum;
  434.                         if (!isvalidgad(&config->menu[a])) break;
  435.                         dofunctionstring(config->menu[a].function,config->menu[a].name,
  436.                             NULL,(struct dopusfuncpar *)&config->menu[a].which);
  437.                     }
  438.                     break;
  439.                 case IDCMP_GADGETDOWN:
  440.                     if (stringgd) {
  441.                         checkstringgads(stringgd);
  442.                         stringgd=0;
  443.                     }
  444.                     switch (gadgetid) {
  445.                         case SCRGAD_MOVEUP1:
  446.                         case SCRGAD_MOVEDOWN1:
  447.                         case SCRGAD_MOVEUP2:
  448.                         case SCRGAD_MOVEDOWN2:
  449.                             if (gadgetid==SCRGAD_MOVEUP1 || gadgetid==SCRGAD_MOVEUP2) dir=-1;
  450.                             else dir=1;
  451.                             if (gadgetid==SCRGAD_MOVEUP1 || gadgetid==SCRGAD_MOVEDOWN1) win=0;
  452.                             else win=1;
  453.                             if (config->generalflags&GENERAL_ACTIVATE) makeactive(win,0);
  454.                             verticalscroll(win,dir);
  455.                             Delay(5);
  456.                             while (!getintuimsg())
  457.                                 if (gad->Flags&SELECTED) verticalscroll(win,dir);
  458.                             ReplyMsg((struct Message *) IMsg);
  459.                             break;
  460.  
  461.                         case SCRGAD_MOVELEFT1:
  462.                         case SCRGAD_MOVERIGHT1:
  463.                         case SCRGAD_MOVELEFT2:
  464.                         case SCRGAD_MOVERIGHT2:
  465.                             if (gadgetid==SCRGAD_MOVELEFT1 || gadgetid==SCRGAD_MOVELEFT2) dir=-1;
  466.                             else dir=1;
  467.                             if (gadgetid==SCRGAD_MOVELEFT1 || gadgetid==SCRGAD_MOVERIGHT1) win=0;
  468.                             else win=1;
  469.                             if (config->generalflags&GENERAL_ACTIVATE) makeactive(win,0);
  470.                             horizontalscroll(win,dir);
  471.                             Delay(5);
  472.                             while (!getintuimsg())
  473.                                 if (gad->Flags&SELECTED) horizontalscroll(win,dir);
  474.                             ReplyMsg((struct Message *) IMsg);
  475.                             break;
  476.  
  477.                         case SCRGAD_LEFTPROP:
  478.                         case SCRGAD_RIGHTPROP:
  479.                             if (gadgetid==SCRGAD_LEFTPROP) a=0;
  480.                             else a=1;
  481.                             if (config->generalflags&GENERAL_ACTIVATE) makeactive(a,0);
  482.                             doposprop(a);
  483.                             FOREVER {
  484.                                 Wait(1<<Window->UserPort->mp_SigBit);
  485.                                 class=0;
  486.                                 while (getintuimsg()) {
  487.                                     class=IMsg->Class;
  488.                                     ReplyMsg((struct Message *) IMsg);
  489.                                     if (class==IDCMP_MOUSEMOVE) doposprop(a);
  490.                                     else if (class==IDCMP_GADGETUP) break;
  491.                                 }
  492.                                 if (class==IDCMP_GADGETUP) break;
  493.                             }
  494.                             dopus_curwin[a]->offset=-1;
  495.                             doposprop(a);
  496.                             break;
  497.  
  498.                         case SCRGAD_LEFTHPROP:
  499.                         case SCRGAD_RIGHTHPROP:
  500.                             if (gadgetid==SCRGAD_LEFTHPROP) a=0;
  501.                             else a=1;
  502.                             if (config->generalflags&GENERAL_ACTIVATE) makeactive(a,0);
  503.                             doposhprop(a);
  504.                             FOREVER {
  505.                                 Wait(1<<Window->UserPort->mp_SigBit);
  506.                                 class=0;
  507.                                 while (getintuimsg()) {
  508.                                     class=IMsg->Class;
  509.                                     ReplyMsg((struct Message *) IMsg);
  510.                                     if (class==IDCMP_MOUSEMOVE) doposhprop(a);
  511.                                     else if (class==IDCMP_GADGETUP) break;
  512.                                 }
  513.                                 if (class==IDCMP_GADGETUP) break;
  514.                             }
  515.                             dopus_curwin[a]->hoffset=-1;
  516.                             doposhprop(a);
  517.                             break;
  518.  
  519.                         case SCRGAD_DRIVEPROP:
  520.                             if (config->generalscreenflags&SCR_GENERAL_GADSLIDERS) {
  521.                                 doposdriveprop();
  522.                                 FOREVER {
  523.                                     Wait(1<<Window->UserPort->mp_SigBit);
  524.                                     class=0;
  525.                                     while (getintuimsg()) {
  526.                                         class=IMsg->Class;
  527.                                         ReplyMsg((struct Message *) IMsg);
  528.                                         if (class==IDCMP_MOUSEMOVE) doposdriveprop();
  529.                                         else if (class==IDCMP_GADGETUP) break;
  530.                                     }
  531.                                     if (class==IDCMP_GADGETUP) break;
  532.                                 }
  533.                                 doposdriveprop();
  534.                             }
  535.                             break;
  536.  
  537.                         case SCRGAD_GADGETPROP:
  538.                             if (config->generalscreenflags&SCR_GENERAL_GADSLIDERS) {
  539.                                 FOREVER {
  540.                                     doposgadgetprop(0);
  541.                                     if (getintuimsg()) {
  542.                                         class=IMsg->Class;
  543.                                         ReplyMsg((struct Message *) IMsg);
  544.                                         if (class==IDCMP_MOUSEMOVE) continue;
  545.                                         else if (class==IDCMP_GADGETUP) break;
  546.                                     }
  547.                                     Wait(1<<Window->UserPort->mp_SigBit);
  548.                                 }
  549.                                 doposgadgetprop(1);
  550.                             }
  551.                             break;
  552.  
  553.                         case SCRGAD_LEFTSTRING:
  554.                         case SCRGAD_RIGHTSTRING:
  555.                             stringgd=gadgetid+1;
  556.                             break;
  557.                     }
  558.                     break;
  559.  
  560.                 case IDCMP_GADGETUP:
  561.                     if (stringgd) {
  562.                         if (gadgetid!=SCRGAD_LEFTSTRING && gadgetid!=SCRGAD_RIGHTSTRING)
  563.                             checkstringgads(stringgd);
  564.                         stringgd=0;
  565.                     }
  566.                     if (gadgetid>=MAIN_GAD_BASE && gadgetid<MAIN_GAD_BASE+GADCOUNT) {
  567.                         a=(gadgetid-MAIN_GAD_BASE)+(data_gadgetrow_offset*7);
  568.                         if (!dopus_curgadbank || !(isvalidgad(&dopus_curgadbank->gadgets[a]))) break;
  569.                         dofunctionstring(dopus_curgadbank->gadgets[a].function,
  570.                             dopus_curgadbank->gadgets[a].name,
  571.                             NULL,(struct dopusfuncpar *)&dopus_curgadbank->gadgets[a].which);
  572.                         break;
  573.                     }
  574.                     switch (gadgetid) {
  575.                         case SCRGAD_LEFTSTRING:
  576.                         case SCRGAD_RIGHTSTRING:
  577.                             if (code==0x5f) do_path_completion(gadgetid,qual);
  578.                             else if (code!=0x9) {
  579.                                 makeactive(gadgetid,0);
  580.                                 startgetdir(gadgetid,SGDFLAGS_CANMOVEEMPTY);
  581.                             }
  582.                             break;
  583.  
  584.                         case SCRGAD_BUFFERLEFT1:
  585.                             incrementbuf(0,-1,1);
  586.                             break;
  587.  
  588.                         case SCRGAD_BUFFERRIGHT1:
  589.                             incrementbuf(0,1,1);
  590.                             break;
  591.  
  592.                         case SCRGAD_BUFFERLEFT2:
  593.                             incrementbuf(1,-1,1);
  594.                             break;
  595.  
  596.                         case SCRGAD_BUFFERRIGHT2:
  597.                             incrementbuf(1,1,1);
  598.                             break;
  599.  
  600.                         case FUNC_PARENT1:
  601.                             makeactive(0,0);
  602.                             function=FUNC_PARENT;
  603.                             break;
  604.  
  605.                         case FUNC_PARENT2:
  606.                             makeactive(1,0);
  607.                             function=FUNC_PARENT;
  608.                             break;
  609.  
  610.                         case SCRGAD_TINYFILTER:
  611.                             if (status_flags&STATUS_HELP) {
  612.                                 dohelp(NULL,"*Filter",0,0,NULL);
  613.                                 screen_gadgets[SCRGAD_TINYFILTER].Flags^=GFLG_SELECTED;
  614.                                 dolittlegads(&screen_gadgets[SCRGAD_TINYFILTER],&globstring[STR_TINY_BUTTONS][6],1);
  615.                             }
  616.                             else if (screen_gadgets[SCRGAD_TINYFILTER].Flags&GFLG_SELECTED) {
  617.                                 busy();
  618.                                 if (!(whatsit(globstring[STR_ENTER_FILTER],40,str_filter,NULL)) ||
  619.                                     !str_filter[0]) {
  620.                                     screen_gadgets[SCRGAD_TINYFILTER].Flags&=~GFLG_SELECTED;
  621.                                     dolittlegads(&screen_gadgets[SCRGAD_TINYFILTER],&globstring[STR_TINY_BUTTONS][6],1);
  622.                                     str_filter_parsed[0]=0;
  623.                                 }
  624.                                 else LParsePatternI(str_filter,str_filter_parsed);
  625.                                 unbusy();
  626.                             }
  627.                             else str_filter_parsed[0]=0;
  628.                             break;
  629.  
  630.                         default:
  631.                             function=gadgetid;
  632.                             if (function==FUNC_QUIT && status_flags&STATUS_IANSCRAP) {
  633.                                 rexx_argcount=1;
  634.                                 strcpy(rexx_args[0],"force");
  635.                             }
  636.                             break;
  637.                     }
  638.                     break;
  639.  
  640.                 case IDCMP_MOUSEBUTTONS:
  641.                     if (stringgd) {
  642.                         checkstringgads(stringgd);
  643.                         stringgd=0;
  644.                     }
  645.                     if (code==SELECTDOWN) {
  646.                         if (y>=scrdata_diskname_ypos && y<scrdata_diskname_ypos+scrdata_diskname_height) {
  647.                             a=(x<scrdata_dispwin_center)?0:1;
  648.                             if (data_active_window==1-a) {
  649.                                 if (DoubleClick(time_previous_sec,time_previous_micro,
  650.                                     time_current_sec,time_current_micro)) {
  651.                                     copydirwin(dopus_curwin[1-a],dopus_curwin[a],a);
  652.                                 }
  653.                                 makeactive(a,1);
  654.                             }
  655.                             else {
  656.                                 if (DoubleClick(time_previous_sec,time_previous_micro,
  657.                                     time_current_sec,time_current_micro)) {
  658.                                     busy();
  659.                                     if (str_pathbuffer[data_active_window][0] &&
  660.                                         do_parent_multi(str_pathbuffer[data_active_window]))
  661.                                         startgetdir(data_active_window,SGDFLAGS_CANMOVEEMPTY|SGDFLAGS_CANCHECKBUFS);
  662.                                     unbusy();
  663.                                 }
  664.                                 time_previous_sec=time_current_sec;
  665.                                 time_previous_micro=time_current_micro;
  666.                             }
  667.                             checksize(a);
  668.                             break;
  669.                         }
  670.                         else if (x>scrdata_dispwin_center-3 && x<scrdata_dispwin_center+2 &&
  671.                             y>=scrdata_dispwin_ypos && y<scrdata_dispwin_height+scrdata_dispwin_ypos) {
  672.                             dosizedirwindows(65536);
  673.                         }
  674.                         else if ((a=isinwindow(x,y))!=-1) doselection(a,TRUE);
  675.                         else if (x>=scrdata_xoffset && x<scrdata_xoffset+scrdata_clock_width &&
  676.                             y>scrdata_clock_ypos-3) {
  677. nextgadgetbank:
  678.                             if ((data_gadgetrow_offset+=scr_gadget_rows)>=6) {
  679.                                 data_gadgetrow_offset=0;
  680.                                 bank=dopus_curgadbank;
  681.                                 if (dopus_curgadbank && dopus_curgadbank->next)
  682.                                     dopus_curgadbank=dopus_curgadbank->next;
  683.                                 else dopus_curgadbank=dopus_firstgadbank;
  684.                                 if (bank!=dopus_curgadbank || scr_gadget_rows<6) drawgadgets(0,0);
  685.                             }
  686.                             else drawgadgets(0,0);
  687.                             fixgadgetprop();
  688.                         }
  689.                     }
  690.                     else if (code==MENUDOWN) {
  691.                         if ((a=DoRMBGadget(mainrmbgads,Window))>-1) {
  692.                             if (a==FUNC_ROOT) {
  693.                                 if (x<scrdata_xoffset+3) makeactive(0,0);
  694.                                 else makeactive(1,0);
  695.                             }
  696.                             function=a;
  697.                         }
  698.                         else if (y<scrdata_diskname_ypos ||
  699.                             y>scrdata_yoffset+scrdata_height ||
  700.                             x<scrdata_xoffset ||
  701.                             x>scrdata_xoffset+scrdata_width)
  702.                             quickfixmenus();
  703.  
  704.                         else if (y>=scrdata_diskname_ypos && y<=scrdata_dispwin_ypos) {
  705.                             if (x<scrdata_dispwin_center) a=1;
  706.                             else a=0;
  707.                             if (data_active_window==a) {
  708.                                 if (DoubleClick(time_previous_sec,time_previous_micro,
  709.                                     time_current_sec,time_current_micro)) {
  710.                                     swapdirwin();
  711.                                     time_previous_sec=0;
  712.                                 }
  713.                                 makeactive(1-a,1);
  714.                             }
  715.                             else {
  716.                                 time_previous_sec=time_current_sec;
  717.                                 time_previous_micro=time_current_micro;
  718.                             }
  719.                             checksize(1-a);
  720.                         }
  721.                         else if (x>=scrdata_xoffset && x<scrdata_xoffset+scrdata_clock_width &&
  722.                             y>scrdata_clock_ypos-3) {
  723.                             if (qual&IEQUALIFIER_ANYSHIFT) {
  724.                                 drawgadgets(0,GADCOUNT/2);
  725.                                 FOREVER {
  726.                                     while (getintuimsg()) {
  727.                                         class=IMsg->Class; code=IMsg->Code;
  728.                                         ReplyMsg((struct Message *) IMsg);
  729.                                         if (class==MOUSEBUTTONS && code==MENUUP) break;
  730.                                     }
  731.                                     if (class==MOUSEBUTTONS && code==MENUUP) break;
  732.                                     Wait(1<<Window->UserPort->mp_SigBit);
  733.                                 }
  734.                                 drawgadgets(0,0);
  735.                             }
  736.                             else {
  737. prevgadgetbank:
  738.                                 if ((data_gadgetrow_offset-=scr_gadget_rows)<0) {
  739.                                     data_gadgetrow_offset=6-scr_gadget_rows;
  740.                                     bank1=dopus_curgadbank;
  741.                                     bank=dopus_firstgadbank;
  742.                                     while (bank && bank->next && bank->next!=dopus_curgadbank) bank=bank->next;
  743.                                     if (!bank) dopus_curgadbank=dopus_firstgadbank;
  744.                                     else dopus_curgadbank=bank;
  745.                                     if (bank1!=dopus_curgadbank || scr_gadget_rows<6) drawgadgets(0,0);
  746.                                 }
  747.                                 else drawgadgets(0,0);
  748.                                 fixgadgetprop();
  749.                             }
  750.                         }
  751.                         else if (y>scrdata_dispwin_ypos+1 &&
  752.                             y<scrdata_dispwin_height+scrdata_dispwin_ypos+2) {
  753.                             if (x>1 && x<scrdata_dispwin_center-13) {
  754.                                 doselinfo(0);
  755.                                 dormbscroll(0);
  756.                             }
  757.                             else if (x>scrdata_dispwin_center+12 &&
  758.                                 x<screen_gadgets[SCRGAD_RIGHTPARENT].LeftEdge) {
  759.                                 doselinfo(1);
  760.                                 dormbscroll(1);
  761.                             }
  762.                         }
  763.                         else if (x>=scrdata_gadget_xpos && y>=scrdata_gadget_ypos &&
  764.                             y<scrdata_gadget_ypos+(scr_gadget_rows*scrdata_gadget_height)+1 &&
  765.                             dopus_curgadbank) {
  766.  
  767.                             if ((c=gadgetfrompos(x,y))>-1) {
  768.                                 a=c+(GADCOUNT/2)+(data_gadgetrow_offset*7);
  769.                                 if (isvalidgad(&dopus_curgadbank->gadgets[a])) {
  770.                                     x1=scrdata_gadget_xpos+((c%7)*scrdata_gadget_width);
  771.                                     y1=scrdata_gadget_ypos+((c/7)*scrdata_gadget_height)-1;
  772.                                     if (!(dormbgadget(x1,y1,
  773.                                         &dopus_curgadbank->gadgets[c+(data_gadgetrow_offset*7)],
  774.                                         &dopus_curgadbank->gadgets[a]))) {
  775.                                         dofunctionstring(dopus_curgadbank->gadgets[a].function,
  776.                                             dopus_curgadbank->gadgets[a].name,NULL,
  777.                                             (struct dopusfuncpar *)&dopus_curgadbank->gadgets[a].which);
  778.                                     }
  779.                                 }
  780.                             }
  781.                         }
  782.                     }
  783.                     break;
  784.             }
  785.             if (function) internal_function(function,0,NULL,NULL);
  786.             status_haveaborted=0;
  787.         }
  788.     }
  789.     goto foreverloop;
  790. }
  791.  
  792. struct IntuiMessage *getintuimsg()
  793. {
  794.     return((IMsg=(struct IntuiMessage *)GetMsg(Window->UserPort)));
  795. }
  796.