Compiler warnings about misleading indentation removed.
[AROS-Contrib.git] / dopus / Program / doidcmp.c
blob769cfa9648e24d45e599cbef95de2d5d211fa5c7
1 /*
3 Directory Opus 4
4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
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.
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.
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.
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.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
31 #ifndef __AROS__
32 #include <devices/newmouse.h>
33 #else
34 #include <devices/rawkeycodes.h>
35 #endif
36 #include "dopus.h"
37 #ifndef __AROS__
38 #include <libraries/screennotify.h>
39 #endif
41 void doidcmp()
43 int x,y,a,function,wmes,stringgd=0,waitbits,b,x1,y1,c,win,dir,num;
44 ULONG class;
45 UWORD code,gadgetid,menunum,itemnum,qual;
46 UBYTE old_change_state;
47 char buf[80],buf2[30],ch;
48 struct dopusgadgetbanks *bank,*bank1;
49 struct AppMessage *apmsg;
50 struct dopushotkey *hotkey;
51 struct dopusfuncpar par;
52 struct Gadget *gad;
53 struct MenuItem *item;
55 //foreverloop:
56 FOREVER {
57 waitbits=1<<Window->UserPort->mp_SigBit|1<<count_port->mp_SigBit|rexx_signalbit|INPUTSIG_HOTKEY|1<<snm_port->mp_SigBit;
58 if (/*system_version2 &&*/ WorkbenchBase && dopus_appwindow)
59 waitbits|=1<<appmsg_port->mp_SigBit;
60 if ((wmes=Wait(waitbits))&INPUTSIG_HOTKEY) {
61 if (dopus_globalhotkey==(struct dopushotkey *)-1) {
62 function=FUNC_QUIT; dopus_globalhotkey=NULL;
63 goto foobarbaz;
65 else if (dopus_globalhotkey==(struct dopushotkey *)-2) {
66 function=FUNC_ICONIFY; dopus_globalhotkey=NULL;
67 goto foobarbaz;
69 else if (!dopus_globalhotkey) continue;
70 hotkey=dopus_globalhotkey; dopus_globalhotkey=NULL;
71 CopyMem((char *)&hotkey->func.which,(char *)&par,sizeof(struct dopusfuncpar));
72 par.which&=FLAG_OUTWIND|FLAG_NOQUOTE|FLAG_SHELLUP|FLAG_DOPUSUP;
73 par.which|=FLAG_ASYNC;
74 if (par.which&FLAG_OUTWIND) par.which|=FLAG_WB2F;
75 status_flags|=STATUS_FROMHOTKEY;
76 dofunctionstring(hotkey->func.function,hotkey->name,NULL,&par);
77 status_flags&=~STATUS_FROMHOTKEY;
78 continue;
80 if (wmes&rexx_signalbit) {
81 rexx_dispatch(1);
82 if (func_global_function)
83 internal_function(func_global_function,rexx_global_flag,NULL,NULL);
84 status_haveaborted=0;
85 continue;
87 /// "AppMessage"
88 if (WorkbenchBase && dopus_appwindow &&
89 (wmes&(1<<appmsg_port->mp_SigBit))) {
90 ActivateWindow(Window);
91 while ((apmsg=(struct AppMessage *)GetMsg(appmsg_port))) {
92 if (apmsg->am_Type==AMTYPE_APPWINDOW && apmsg->am_ID==APPWINID) {
93 for (a=0;a<apmsg->am_NumArgs;a++) {
94 if (apmsg->am_ArgList[a].wa_Lock) {
95 if ((b=isinwindow(apmsg->am_MouseX,apmsg->am_MouseY))!=-1) { // lister area
96 if (!(*apmsg->am_ArgList[a].wa_Name)) {
97 PathName(apmsg->am_ArgList[a].wa_Lock,str_pathbuffer[b],256);
98 checkdir(str_pathbuffer[b],&path_strgadget[b]);
99 startgetdir(b,SGDFLAGS_CANMOVEEMPTY);
100 break;
102 else {
103 c=data_active_window;
104 makeactive(b,0);
105 PathName(apmsg->am_ArgList[a].wa_Lock,func_external_file,256);
106 TackOn(func_external_file,apmsg->am_ArgList[a].wa_Name,256);
107 dofunctionstring("*copy",NULL,NULL,NULL);
108 makeactive(c,0);
111 else if (dopus_curgadbank &&
112 (b=gadgetfrompos(apmsg->am_MouseX,apmsg->am_MouseY))!=-1) { // gadget bank area
113 b+=(data_gadgetrow_offset*7);
114 if (isvalidgad(&dopus_curgadbank->gadgets[b])) {
115 PathName(apmsg->am_ArgList[a].wa_Lock,func_external_file,256);
116 if (func_external_file[0] &&
117 func_external_file[(strlen(func_external_file)-1)]==':' &&
118 !apmsg->am_ArgList[a].wa_Name[0])
119 TackOn(func_external_file,"Disk.info",256);
120 else TackOn(func_external_file,apmsg->am_ArgList[a].wa_Name,256);
121 if (!(CheckExist(func_external_file,NULL)))
122 StrConcat(func_external_file,".info",256);
123 dofunctionstring(dopus_curgadbank->gadgets[b].function,
124 dopus_curgadbank->gadgets[b].name,
125 NULL,(struct dopusfuncpar *)&dopus_curgadbank->gadgets[b].which);
128 else if (apmsg->am_MouseY<scrdata_yoffset+scrdata_status_height) {
129 if (apmsg->am_ArgList[a].wa_Name[0]) {
130 char pathbuf[256];
132 PathName(apmsg->am_ArgList[a].wa_Lock,pathbuf,256);
133 strcpy(func_external_file,pathbuf);
134 TackOn(func_external_file,apmsg->am_ArgList[a].wa_Name,256);
135 ftype_doubleclick(pathbuf,apmsg->am_ArgList[a].wa_Name,0);
136 unbusy();
141 func_external_file[0]=0;
143 ReplyMsg((struct Message *)apmsg);
147 /// "DOS notify"
148 if (wmes&(1<<count_port->mp_SigBit)) {
149 struct NotifyMessage *note;
150 int got=0;
152 while ((note=(struct NotifyMessage *)GetMsg(count_port))) {
153 D(bug("DOS notification message\n"));
154 if (/*system_version2 &&*/ config->dynamicflags&UPDATE_NOTIFY) {
155 a=note->nm_NReq->nr_UserData;
156 ReplyMsg((struct Message *)note);
157 if (!(got&(1<<a))) {
158 got|=1<<a;
160 if (a==0 || a==1) {
161 if (!(config->dirflags&DIRFLAGS_REREADOLD) ||
162 IntuitionBase->ActiveWindow==Window) {
163 struct DirWindowPars notifypars;
165 notifypars.reselection_list=NULL;
166 makereselect(&notifypars,a);
167 startgetdir(a,SGDFLAGS_CANMOVEEMPTY);
168 doreselect(&notifypars,0);
169 makereselect(&notifypars,-1);
174 else ReplyMsg((struct Message *)note);
177 #ifndef __AROS__
179 /// "Screen notify"
180 if (wmes & (1 << snm_port->mp_SigBit))
182 BOOL do_iconify;
184 while ((snm = (struct ScreenNotifyMessage *) GetMsg(snm_port)))
186 do_iconify = FALSE;
187 if (snm->snm_Type == SCREENNOTIFY_TYPE_WORKBENCH)
189 if (snm->snm_Value == FALSE) /* Workbench close notification */
191 if (! status_iconified) if (config->screenmode == MODE_WORKBENCHUSE) do_iconify = TRUE;
194 if (do_iconify) internal_function(FUNC_SCREENNOTIFY,0,NULL,NULL);
195 else ReplyMsg((struct Message *) snm);
198 #endif
200 while (getintuimsg()) {
201 x=IMsg->MouseX;
202 y=IMsg->MouseY;
203 time_current_sec=IMsg->Seconds;
204 time_current_micro=IMsg->Micros;
205 class=IMsg->Class;
206 code=IMsg->Code;
207 qual=IMsg->Qualifier;
208 if (class==IDCMP_GADGETUP || class==IDCMP_GADGETDOWN) {
209 gad=(struct Gadget *) IMsg->IAddress;
210 gadgetid=gad->GadgetID;
212 ReplyMsg((struct Message *) IMsg);
213 if (Window->FirstRequest) continue;
215 function=status_haveaborted=0;
216 switch (class) {
217 /// "IDCMP_ACTIVEWINDOW"
218 case IDCMP_ACTIVEWINDOW:
219 for (a=0;a<2;a++) check_old_buffer(a);
220 break;
223 /// "IDCMP_NEWSIZE"
224 case IDCMP_NEWSIZE:
225 config->scr_winw=Window->Width;
226 config->scr_winh=Window->Height;
227 if (!MainScreen) {
228 config->scrw=config->scr_winw;
229 config->scrh=config->scr_winh;
231 config->screenflags&=~(SCRFLAGS_DEFWIDTH|SCRFLAGS_DEFHEIGHT);
232 remclock();
233 SetUp(0);
234 dostatustext(str_last_statustext);
235 break;
238 /// "IDCMP_CLOSEWINDOW"
239 case IDCMP_CLOSEWINDOW:
240 busy();
241 if (!(config->generalflags&GENERAL_FORCEQUIT)) a=simplerequest(globstring[STR_REALLY_QUIT],globstring[STR_QUIT],str_cancelstring,globstring[STR_ICONIFY],NULL);
242 else a = 1;
244 if (a==2) function=FUNC_ICONIFY;
245 else if (a==1)
247 function=FUNC_QUIT;
248 rexx_argcount=1;
249 strcpy(rexx_args[0],"force");
251 unbusy();
252 break;
255 /// "IDCMP_DISKREMOVED"
256 case IDCMP_DISKREMOVED:
257 setupchangestate();
258 break;
261 /// "IDCMP_DISKINSERTED"
262 case IDCMP_DISKINSERTED:
263 old_change_state=disk_change_state;
264 setupchangestate();
265 if (config->dirflags&DIRFLAGS_AUTODISKC) {
266 if (IntuitionBase->ActiveWindow==Window
267 #ifdef _USE_SMALL_Q
268 || !(status_flags&STATUS_IANSCRAP)
269 #endif
271 c=0;
272 for (a=0;a<4;a++) {
273 if ((old_change_state&(1<<a))!=(disk_change_state&(1<<a))) {
274 lsprintf(buf,"DF%ld:",(long int)a);
275 lsprintf(buf2,"PC%ld:",(long int)a);
276 for (b=0;b<2;b++) {
277 if ((Stricmp(dopus_curwin[b]->realdevice,buf)==0) ||
278 (Stricmp(dopus_curwin[b]->realdevice,buf2)==0)) {
279 identify_and_load(b,a);
280 c=1;
284 if (c) break;
286 if (c) break;
289 if (IntuitionBase->ActiveWindow==Window) {
290 if (config->dirflags&DIRFLAGS_AUTODISKL) {
291 for (a=0;a<4;a++) {
292 if ((old_change_state&(1<<a))!=(disk_change_state&(1<<a)) &&
293 identify_and_load(-1,a)) {
294 lsprintf(buf,globstring[STR_NEW_DISK_INSERTED],a);
295 if ((b=simplerequest(buf,globstring[STR_LEFT_WINDOW],
296 str_cancelstring,globstring[STR_RIGHT_WINDOW],NULL))) {
297 identify_and_load(b-1,a);
303 break;
306 /// "IDCMP_MENUPICK"
307 case IDCMP_MENUPICK:
308 Window->Flags|=RMBTRAP;
309 if (!Window->MenuStrip) break;
310 if (stringgd) {
311 checkstringgads(stringgd);
312 stringgd=0;
314 if (code==MENUNULL) break;
315 menunum=menu_real_number[MENUNUM(code)];
316 num=ITEMNUM(code);
317 item=menu_menus[menunum].FirstItem;
318 for (a=0,itemnum=0;a<num && item;a++) {
319 if (item->Flags&ITEMTEXT) ++itemnum;
320 item=item->NextItem;
322 if (item) {
323 a=(menunum*20)+itemnum;
324 if (!isvalidgad(&config->menu[a])) break;
325 dofunctionstring(config->menu[a].function,config->menu[a].name,
326 NULL,(struct dopusfuncpar *)&config->menu[a].which);
328 break;
330 /// "IDCMP_GADGETDOWN"
331 case IDCMP_GADGETDOWN:
332 if (stringgd) {
333 checkstringgads(stringgd);
334 stringgd=0;
336 switch (gadgetid) {
337 case SCRGAD_MOVEUP1:
338 case SCRGAD_MOVEDOWN1:
339 case SCRGAD_MOVEUP2:
340 case SCRGAD_MOVEDOWN2:
341 if (gadgetid==SCRGAD_MOVEUP1 || gadgetid==SCRGAD_MOVEUP2) dir=-1;
342 else dir=1;
343 if (gadgetid==SCRGAD_MOVEUP1 || gadgetid==SCRGAD_MOVEDOWN1) win=0;
344 else win=1;
345 if (config->generalflags&GENERAL_ACTIVATE) makeactive(win,0);
346 verticalscroll(win,dir);
347 // Delay(5);
348 while (!getintuimsg())
349 if (gad->Flags&SELECTED) verticalscroll(win,dir);
350 ReplyMsg((struct Message *) IMsg);
351 break;
353 case SCRGAD_MOVELEFT1:
354 case SCRGAD_MOVERIGHT1:
355 case SCRGAD_MOVELEFT2:
356 case SCRGAD_MOVERIGHT2:
357 if (gadgetid==SCRGAD_MOVELEFT1 || gadgetid==SCRGAD_MOVELEFT2) dir=-1;
358 else dir=1;
359 if (gadgetid==SCRGAD_MOVELEFT1 || gadgetid==SCRGAD_MOVERIGHT1) win=0;
360 else win=1;
361 if (config->generalflags&GENERAL_ACTIVATE) makeactive(win,0);
362 horizontalscroll(win,dir);
363 // Delay(5);
364 while (!getintuimsg())
365 if (gad->Flags&SELECTED) horizontalscroll(win,dir);
366 ReplyMsg((struct Message *) IMsg);
367 break;
369 case SCRGAD_LEFTPROP:
370 case SCRGAD_RIGHTPROP:
371 if (gadgetid==SCRGAD_LEFTPROP) a=0;
372 else a=1;
373 if (config->generalflags&GENERAL_ACTIVATE) makeactive(a,0);
374 doposprop(a);
375 FOREVER {
376 Wait(1<<Window->UserPort->mp_SigBit);
377 class=0;
378 while (getintuimsg()) {
379 class=IMsg->Class;
380 ReplyMsg((struct Message *) IMsg);
381 if (class==IDCMP_MOUSEMOVE) doposprop(a);
382 else if (class==IDCMP_GADGETUP) break;
384 if (class==IDCMP_GADGETUP) break;
386 dopus_curwin[a]->offset=-1;
387 doposprop(a);
388 break;
390 case SCRGAD_LEFTHPROP:
391 case SCRGAD_RIGHTHPROP:
392 if (gadgetid==SCRGAD_LEFTHPROP) a=0;
393 else a=1;
394 if (config->generalflags&GENERAL_ACTIVATE) makeactive(a,0);
395 doposhprop(a);
396 FOREVER {
397 Wait(1<<Window->UserPort->mp_SigBit);
398 class=0;
399 while (getintuimsg()) {
400 class=IMsg->Class;
401 ReplyMsg((struct Message *) IMsg);
402 if (class==IDCMP_MOUSEMOVE) doposhprop(a);
403 else if (class==IDCMP_GADGETUP) break;
405 if (class==IDCMP_GADGETUP) break;
407 dopus_curwin[a]->hoffset=-1;
408 doposhprop(a);
409 break;
411 case SCRGAD_DRIVEPROP:
412 if (config->generalscreenflags&SCR_GENERAL_GADSLIDERS) {
413 doposdriveprop();
414 FOREVER {
415 Wait(1<<Window->UserPort->mp_SigBit);
416 class=0;
417 while (getintuimsg()) {
418 class=IMsg->Class;
419 ReplyMsg((struct Message *) IMsg);
420 if (class==IDCMP_MOUSEMOVE) doposdriveprop();
421 else if (class==IDCMP_GADGETUP) break;
423 if (class==IDCMP_GADGETUP) break;
425 doposdriveprop();
427 break;
429 case SCRGAD_GADGETPROP:
430 if (config->generalscreenflags&SCR_GENERAL_GADSLIDERS) {
431 FOREVER {
432 doposgadgetprop(0);
433 if (getintuimsg()) {
434 class=IMsg->Class;
435 ReplyMsg((struct Message *) IMsg);
436 if (class==IDCMP_MOUSEMOVE) continue;
437 else if (class==IDCMP_GADGETUP) break;
439 Wait(1<<Window->UserPort->mp_SigBit);
441 doposgadgetprop(1);
443 break;
445 case SCRGAD_LEFTSTRING:
446 case SCRGAD_RIGHTSTRING:
447 stringgd=gadgetid+1;
448 break;
450 break;
453 /// "IDCMP_GADGETUP"
454 case IDCMP_GADGETUP:
455 if (stringgd) {
456 if (gadgetid!=SCRGAD_LEFTSTRING && gadgetid!=SCRGAD_RIGHTSTRING)
457 checkstringgads(stringgd);
458 stringgd=0;
460 if (gadgetid>=MAIN_GAD_BASE && gadgetid<MAIN_GAD_BASE+GADCOUNT) {
461 a=(gadgetid-MAIN_GAD_BASE)+(data_gadgetrow_offset*7);
462 #ifndef __AROS__
463 D(bug("doidcmp: a = %ld\n",a);KDump(&dopus_curgadbank->gadgets[a],sizeof(struct newdopusfunction)));
464 #endif
465 if (!dopus_curgadbank || !(isvalidgad(&dopus_curgadbank->gadgets[a]))) break;
466 dofunctionstring(dopus_curgadbank->gadgets[a].function,
467 dopus_curgadbank->gadgets[a].name,
468 NULL,(struct dopusfuncpar *)&dopus_curgadbank->gadgets[a].which);
469 break;
471 switch (gadgetid) {
472 case SCRGAD_LEFTSTRING:
473 case SCRGAD_RIGHTSTRING:
474 if (code==0x5f) do_path_completion(gadgetid,qual);
475 else if (code!=0x9) {
476 makeactive(gadgetid,0);
477 startgetdir(gadgetid,SGDFLAGS_CANMOVEEMPTY);
479 break;
481 case SCRGAD_BUFFERLEFT1:
482 incrementbuf(0,-1,1);
483 break;
485 case SCRGAD_BUFFERRIGHT1:
486 incrementbuf(0,1,1);
487 break;
489 case SCRGAD_BUFFERLEFT2:
490 incrementbuf(1,-1,1);
491 break;
493 case SCRGAD_BUFFERRIGHT2:
494 incrementbuf(1,1,1);
495 break;
497 case FUNC_PARENT1:
498 makeactive(0,0);
499 function=FUNC_PARENT;
500 break;
502 case FUNC_PARENT2:
503 makeactive(1,0);
504 function=FUNC_PARENT;
505 break;
507 case SCRGAD_TINYFILTER:
508 if (status_flags&STATUS_HELP) {
509 dohelp(NULL,"*Filter",0,0,NULL);
510 screen_gadgets[SCRGAD_TINYFILTER].Flags^=GFLG_SELECTED;
511 dolittlegads(&screen_gadgets[SCRGAD_TINYFILTER],&globstring[STR_TINY_BUTTONS][6],1);
513 else if (screen_gadgets[SCRGAD_TINYFILTER].Flags&GFLG_SELECTED) {
514 busy();
515 if (!(whatsit(globstring[STR_ENTER_FILTER],40,str_filter,NULL)) ||
516 !str_filter[0]) {
517 screen_gadgets[SCRGAD_TINYFILTER].Flags&=~GFLG_SELECTED;
518 dolittlegads(&screen_gadgets[SCRGAD_TINYFILTER],&globstring[STR_TINY_BUTTONS][6],1);
519 str_filter_parsed[0]=0;
521 else LParsePatternI(str_filter,str_filter_parsed);
522 unbusy();
524 else str_filter_parsed[0]=0;
525 break;
527 default:
528 function=gadgetid;
529 #ifdef _USE_SMALL_Q
530 if (function==FUNC_QUIT && status_flags&STATUS_IANSCRAP) {
531 rexx_argcount=1;
532 strcpy(rexx_args[0],"force");
534 #endif
535 break;
537 break;
540 /// "IDCMP_RAWKEY"
541 case IDCMP_RAWKEY:
543 code&=0x7f;
544 readkeys(var_key_matrix);
545 a=code/8; b=code%8;
546 if (!(var_key_matrix[a]&(1<<b)))
548 if (code & IECODE_UP_PREFIX)
550 flushidcmp();
551 break;
553 qual&=VALID_QUALIFIERS;
554 bank=dopus_firstgadbank;
555 while (bank) {
556 for (a=0;a<GADCOUNT;a++) {
557 if (check_key_press((struct dopusfunction *)&bank->gadgets[a],code,qual)) {
558 dofunctionstring(bank->gadgets[a].function,bank->gadgets[a].name,
559 NULL,(struct dopusfuncpar *)&bank->gadgets[a].which);
560 goto foobarbaz;
563 bank=bank->next;
565 for (a=0;a<MENUCOUNT;a++) {
566 if (check_key_press((struct dopusfunction *)&config->menu[a],code,qual)) {
567 dofunctionstring(config->menu[a].function,config->menu[a].name,
568 NULL,(struct dopusfuncpar *)&config->menu[a].which);
569 goto foobarbaz;
572 for (a=0;a<USEDRIVECOUNT;a++) {
573 if (check_key_press(&config->drive[a],code,qual)) {
574 strcpy(str_pathbuffer[data_active_window],config->drive[a].function);
575 startgetdir(data_active_window,SGDFLAGS_CANMOVEEMPTY);
576 goto foobarbaz;
579 if (qual&(IEQUALIFIER_RCOMMAND|IEQUALIFIER_LCOMMAND)) {
580 RawkeyToStr(code,qual,NULL,buf,0);
581 switch (ToUpper(buf[0])) {
582 case 'R': function=FUNC_RESELECT; break;
583 case 'A': function=FUNC_AREXX; break;
584 case 'S': function=FUNC_SELECT; break;
585 case 'B': function=FUNC_BUFFERLIST; break;
586 case ' ':
587 if (qual&IEQUALIFIER_LCOMMAND) findfirstsel(data_active_window,ENTRY_FILE);
588 else findfirstsel(data_active_window,ENTRY_DIRECTORY);
589 break;
591 switch (code) {
592 case 0x13: function=FUNC_RESELECT; break; // R
593 case 0x20: function=FUNC_AREXX; break; // A
594 case 0x21: function=FUNC_SELECT; break; // S
595 case 0x35: function=FUNC_BUFFERLIST; break;// B
596 case 0x40: // SPACE
597 if (qual&IEQUALIFIER_LCOMMAND) findfirstsel(data_active_window,ENTRY_FILE);
598 else findfirstsel(data_active_window,ENTRY_DIRECTORY);
599 break;
603 else {
604 win = -1;
605 switch (code) {
606 case RAWKEY_NM_WHEEL_UP:
607 if ((y>=scrdata_gadget_ypos) && (y<=scrdata_gadget_ypos+(scr_gadget_rows*scrdata_gadget_height))) // gadget bank area
609 if ((x>=scrdata_gadget_offset) && (x<scrdata_gadget_xpos) && scr_gadget_rows) //drive bank
611 if (scrdata_drive_width)
613 data_drive_offset--;
614 if (data_drive_offset < 0) data_drive_offset = 0;
615 if (config->generalscreenflags&SCR_GENERAL_GADSLIDERS) {
616 FixSliderPot(Window,&drive_propgad,data_drive_offset,
617 USEDRIVECOUNT,scr_gadget_rows,!status_iconified);
619 if (!status_iconified) fixdrivegadgets();
622 else // button bank
624 int max = (getgadbankcount()*6)/scr_gadget_rows,
625 pos = GetSliderPos(&gadget_propgad,max,1);
627 if (--pos < 0) pos = 0;
628 else
630 FixSliderPot(Window,&gadget_propgad,pos,max,1,0);
631 doposgadgetprop(0);
634 break;
636 else
637 win = isinwindow(x,y); // lister area
639 if (win == -1) break;
640 case CURSOR_UP:
641 if (win == -1) win = data_active_window;
642 if (dopus_curwin[win]->total<scrdata_dispwin_lines) break;
643 if (qual&(IEQUALIFIER_CONTROL|IEQUALIFIER_ANYSHIFT)) {
644 if (qual&IEQUALIFIER_CONTROL) dopus_curwin[win]->offset=0;
645 else {
646 dopus_curwin[win]->offset-=scrdata_dispwin_lines;
647 if (dopus_curwin[win]->offset<0)
648 dopus_curwin[win]->offset=0;
650 fixvertprop(win);
651 displaydir(win);
652 break;
654 verticalscroll(win,-1);
655 break;
656 case RAWKEY_NM_WHEEL_DOWN:
657 if ((y>=scrdata_gadget_ypos) && (y<=scrdata_gadget_ypos+(scr_gadget_rows*scrdata_gadget_height))) // gadget bank area
659 if ((x>=scrdata_gadget_offset) && (x<scrdata_gadget_xpos) && scr_gadget_rows) //drive bank
661 if (scrdata_drive_width)
663 data_drive_offset++;
664 if (data_drive_offset > (USEDRIVECOUNT-scr_gadget_rows)) data_drive_offset = USEDRIVECOUNT - scr_gadget_rows;
665 if (config->generalscreenflags&SCR_GENERAL_GADSLIDERS) {
666 FixSliderPot(Window,&drive_propgad,data_drive_offset,
667 USEDRIVECOUNT,scr_gadget_rows,!status_iconified);
669 if (!status_iconified) fixdrivegadgets();
672 else // button bank
674 int max = (getgadbankcount()*6)/scr_gadget_rows,
675 pos = GetSliderPos(&gadget_propgad,max,1);
677 if (++pos == max) pos = max-1;
678 else
680 FixSliderPot(Window,&gadget_propgad,pos,max,1,0);
681 doposgadgetprop(0);
684 break;
686 else
687 win = isinwindow(x,y); // lister area
689 if (win == -1) break;
690 case CURSOR_DOWN:
691 if (win == -1) win = data_active_window;
692 if (dopus_curwin[win]->total<scrdata_dispwin_lines) break;
693 if (qual&(IEQUALIFIER_CONTROL|IEQUALIFIER_ANYSHIFT)) {
694 if (qual&IEQUALIFIER_CONTROL)
695 dopus_curwin[win]->offset=dopus_curwin[win]->total-scrdata_dispwin_lines;
696 else {
697 dopus_curwin[win]->offset+=scrdata_dispwin_lines;
698 if (dopus_curwin[win]->offset>dopus_curwin[win]->total-scrdata_dispwin_lines)
699 dopus_curwin[win]->offset=dopus_curwin[win]->total-scrdata_dispwin_lines;
701 fixvertprop(win);
702 displaydir(win);
703 break;
705 verticalscroll(win,1);
706 break;
707 case CURSOR_LEFT:
708 if (qual&(IEQUALIFIER_LALT|IEQUALIFIER_RALT)) {
709 incrementbuf(data_active_window,-1,1);
710 break;
712 case RAWKEY_NM_WHEEL_LEFT:
713 if (code == RAWKEY_NM_WHEEL_LEFT)
715 win = isinwindow(x,y); // lister area
716 if (win == -1) break;
718 if (win == -1) win = data_active_window;
719 if (dopus_curwin[win]->total==0) break;
720 if (qual&(IEQUALIFIER_CONTROL|IEQUALIFIER_ANYSHIFT)) {
721 if (qual&IEQUALIFIER_CONTROL) dopus_curwin[win]->hoffset=0;
722 else {
723 dopus_curwin[win]->hoffset-=scrdata_dispwin_nchars[win];
724 if (dopus_curwin[win]->hoffset<0) dopus_curwin[win]->hoffset=0;
726 refreshwindow(win,1);
727 break;
729 horizontalscroll(win,-1);
730 break;
731 case CURSOR_RIGHT:
732 if (qual&(IEQUALIFIER_LALT|IEQUALIFIER_RALT)) {
733 incrementbuf(data_active_window,1,1);
734 break;
736 case RAWKEY_NM_WHEEL_RIGHT:
737 if (code == RAWKEY_NM_WHEEL_RIGHT)
739 win = isinwindow(x,y); // lister area
740 if (win == -1) break;
742 if (win == -1) win = data_active_window;
743 if (dopus_curwin[win]->total==0) break;
744 if (qual&(IEQUALIFIER_CONTROL|IEQUALIFIER_ANYSHIFT)) {
745 if (qual&IEQUALIFIER_CONTROL) {
746 dopus_curwin[win]->hoffset=dopus_curwin[win]->hlen-scrdata_dispwin_nchars[win];
747 if (dopus_curwin[win]->hoffset<0) dopus_curwin[win]->hoffset=0;
749 else {
750 dopus_curwin[win]->hoffset+=scrdata_dispwin_nchars[win];
751 if (dopus_curwin[win]->hoffset>=(dopus_curwin[win]->hlen-scrdata_dispwin_nchars[win]))
752 dopus_curwin[win]->hoffset=dopus_curwin[win]->hlen-scrdata_dispwin_nchars[win];
754 refreshwindow(win,1);
755 break;
757 horizontalscroll(win,1);
758 break;
760 switch (code) {
761 case 0x5f: // HELP
762 function=FUNC_HELP;
763 break;
764 case 0x40: // SPACE
765 case 0x42: // TAB
766 makeactive(1-data_active_window,1);
767 break;
768 case 0x44: // RETURN
769 if (qual&IEQUALIFIER_ANYSHIFT) function=FUNC_BUFFERLIST;
770 else if (qual&(IEQUALIFIER_LALT|IEQUALIFIER_RALT)) function=FUNC_DEVICELIST;
771 else ActivateStrGad(&path_strgadget[data_active_window],Window);
772 break;
773 case 0x0b: // - _
774 dosizedirwindows(-60000);
775 break;
776 case 0x0c: // = +
777 dosizedirwindows(0);
778 break;
779 case 0x0d: // \ |
780 dosizedirwindows(60000);
781 break;
782 case 0x1a: // [ {
783 goto prevgadgetbank;
784 break;
785 case 0x1b: // ] }
786 goto nextgadgetbank;
787 break;
788 default:
789 if (code<0x40 && !(qual&IEQUALIFIER_CONTROL)) { // a digit or char
790 RawkeyToStr(code,qual,NULL,buf,0);
791 ch=buf[0];
792 if (_isprint(ch)) findfirstchar(data_active_window,ch);
794 break;
797 unbusy();
798 break;
801 /// "IDCMP_MOUSEBUTTONS"
802 case IDCMP_MOUSEBUTTONS:
803 if (stringgd) {
804 checkstringgads(stringgd);
805 stringgd=0;
807 if (code==SELECTDOWN) {
808 if (y>=scrdata_diskname_ypos && y<scrdata_diskname_ypos+scrdata_diskname_height) { // disk name bar
809 a=(x<scrdata_dispwin_center)?0:1;
810 if (data_active_window==1-a) {
811 if (DoubleClick(time_previous_sec,time_previous_micro,
812 time_current_sec,time_current_micro)) {
813 copydirwin(dopus_curwin[1-a],dopus_curwin[a],a);
815 makeactive(a,1);
817 else {
818 if (DoubleClick(time_previous_sec,time_previous_micro,
819 time_current_sec,time_current_micro)) {
820 busy();
821 if (str_pathbuffer[data_active_window][0] &&
822 do_parent_multi(str_pathbuffer[data_active_window]))
823 startgetdir(data_active_window,SGDFLAGS_CANMOVEEMPTY|SGDFLAGS_CANCHECKBUFS);
824 unbusy();
826 time_previous_sec=time_current_sec;
827 time_previous_micro=time_current_micro;
829 checksize(a);
830 break;
832 else if (x>scrdata_dispwin_center-3 && x<scrdata_dispwin_center+2 &&
833 y>=scrdata_dispwin_ypos && y<scrdata_dispwin_height+scrdata_dispwin_ypos) { // lister inner edge
834 dosizedirwindows(65536);
836 else if ((a=isinwindow(x,y))!=-1) doselection(a,TRUE); // lister area
837 else if (x>=scrdata_xoffset && x<scrdata_xoffset+scrdata_clock_width && // button bank area
838 y>scrdata_clock_ypos-3) {
839 nextgadgetbank:
840 if ((data_gadgetrow_offset+=scr_gadget_rows)>=6) {
841 data_gadgetrow_offset=0;
842 bank=dopus_curgadbank;
843 if (dopus_curgadbank && dopus_curgadbank->next)
844 dopus_curgadbank=dopus_curgadbank->next;
845 else dopus_curgadbank=dopus_firstgadbank;
846 if (bank!=dopus_curgadbank || scr_gadget_rows<6) drawgadgets(0,0);
848 else drawgadgets(0,0);
849 fixgadgetprop();
852 else if (code==MENUDOWN) {
853 if ((a=DoRMBGadget(mainrmbgads,Window))>-1) { // check buttons reacting on RMB click
854 if (a==FUNC_ROOT) {
855 char buf[256];
856 int w;
858 if (x<scrdata_xoffset+3) w = 0;
859 else w=1;
860 makeactive(w,0);
862 if (!(dopus_curwin[w]->flags & DWF_ARCHIVE))
864 strcpy(buf,dopus_curwin[w]->directory);
865 if (!(doroot(buf)))
867 function = FUNC_DEVICELIST;
868 break;
872 function=a;
874 else if (y<scrdata_diskname_ypos ||
875 y>scrdata_yoffset+scrdata_height ||
876 x<scrdata_xoffset ||
877 x>scrdata_xoffset+scrdata_width) // window frame
878 quickfixmenus();
880 else if (y>=scrdata_diskname_ypos && y<=scrdata_dispwin_ypos) { /* diskname bar */
881 if (x<scrdata_dispwin_center) a=1;
882 else a=0;
883 if (data_active_window==a) {
884 if (DoubleClick(time_previous_sec,time_previous_micro,
885 time_current_sec,time_current_micro)) {
886 swapdirwin();
887 time_previous_sec=0;
889 makeactive(1-a,1);
891 else {
892 time_previous_sec=time_current_sec;
893 time_previous_micro=time_current_micro;
895 #ifndef __AROS__
896 handlelistermenu(1-a);
897 #endif
899 checksize(1-a);
901 else if (x>=scrdata_xoffset && x<scrdata_xoffset+scrdata_clock_width &&
902 y>scrdata_clock_ypos-3) { // clock bar
903 if (qual&IEQUALIFIER_ANYSHIFT) {
904 drawgadgets(0,GADCOUNT/2);
905 FOREVER {
906 while (getintuimsg()) {
907 class=IMsg->Class; code=IMsg->Code;
908 ReplyMsg((struct Message *) IMsg);
909 if (class==MOUSEBUTTONS && code==MENUUP) break;
911 if (class==MOUSEBUTTONS && code==MENUUP) break;
912 Wait(1<<Window->UserPort->mp_SigBit);
914 drawgadgets(0,0);
916 else {
917 prevgadgetbank:
918 if ((data_gadgetrow_offset-=scr_gadget_rows)<0) {
919 data_gadgetrow_offset=6-scr_gadget_rows;
920 bank1=dopus_curgadbank;
921 bank=dopus_firstgadbank;
922 while (bank && bank->next && bank->next!=dopus_curgadbank) bank=bank->next;
923 if (!bank) dopus_curgadbank=dopus_firstgadbank;
924 else dopus_curgadbank=bank;
925 if (bank1!=dopus_curgadbank || scr_gadget_rows<6) drawgadgets(0,0);
927 else drawgadgets(0,0);
928 fixgadgetprop();
931 else if (y>scrdata_dispwin_ypos+1 &&
932 y<scrdata_dispwin_height+scrdata_dispwin_ypos+2) { // lister area
933 if (x>1 && x<scrdata_dispwin_center-13) {
934 if (config->generalflags & GENERAL_FMPARENT) function = FUNC_PARENT;
935 else {
936 dormbscroll(0);
937 doselinfo(0);
940 else if (x>scrdata_dispwin_center+12 &&
941 x<screen_gadgets[SCRGAD_RIGHTPARENT].LeftEdge) {
942 if (config->generalflags & GENERAL_FMPARENT) function = FUNC_PARENT;
943 else {
944 doselinfo(1);
945 dormbscroll(1);
949 else if (x>=scrdata_gadget_xpos && y>=scrdata_gadget_ypos && // gadget bank area
950 y<scrdata_gadget_ypos+(scr_gadget_rows*scrdata_gadget_height)+1 &&
951 dopus_curgadbank) {
953 if ((c=gadgetfrompos(x,y))>-1) {
954 a=c+(GADCOUNT/2)+(data_gadgetrow_offset*7);
955 if (isvalidgad(&dopus_curgadbank->gadgets[a])) {
956 x1=scrdata_gadget_xpos+((c%7)*scrdata_gadget_width);
957 y1=scrdata_gadget_ypos+((c/7)*scrdata_gadget_height)-1;
958 if (!(dormbgadget(x1,y1,
959 &dopus_curgadbank->gadgets[c+(data_gadgetrow_offset*7)],
960 &dopus_curgadbank->gadgets[a]))) {
961 dofunctionstring(dopus_curgadbank->gadgets[a].function,
962 dopus_curgadbank->gadgets[a].name,NULL,
963 (struct dopusfuncpar *)&dopus_curgadbank->gadgets[a].which);
969 else if (code == MIDDLEUP)
971 int win;
973 if (config->hotkeyflags & HOTKEY_USEMMB) break;
975 if ((win=isinwindow(x,y))!=-1) // lister area
977 if (DoubleClick(time_previous_sec,time_previous_micro,time_current_sec,time_current_micro))
979 int a, owin;
980 owin = data_active_window;
981 data_active_window = win;
982 a = (y - scrdata_dirwin_ypos[win]) / scrdata_font_ysize;
983 a += dopus_curwin[win]->offset;
984 if (a < dopus_curwin[win]->total)
986 char buf[256];
987 struct dopusfiletype *type;
988 struct Directory *file;
990 select(win,a - dopus_curwin[win]->offset);
991 for (file = dopus_curwin[win]->firstentry; a--; file=file->next);
992 strcpy(buf,str_pathbuffer[win]);
993 TackOn(buf,file->name,256);
994 D(bug("MMB double click on \"%s\"\n",buf));
996 if ((type=checkfiletype(buf,FTFUNC_MMBCLICK,0)))
998 struct dopusfuncpar par;
1000 D(bug("filetype %s matched\n",type->type));
1001 par.which=type->which[FTFUNC_MMBCLICK];
1002 par.stack=type->stack[FTFUNC_MMBCLICK];
1003 par.pri=type->pri[FTFUNC_MMBCLICK];
1004 par.delay=type->delay[FTFUNC_MMBCLICK];
1005 par.key=par.qual=0; par.type=3;
1007 if (type->actionstring[FTFUNC_MMBCLICK][0]) {
1008 do_title_string(type->actionstring[FTFUNC_MMBCLICK],buf,0,file->name);
1009 dostatustext(buf);
1011 else buf[0]=0;
1012 strcpy(func_single_file,file->name);
1013 dofunctionstring(type->function[FTFUNC_MMBCLICK],file->name,buf,&par);
1014 func_single_file[0]=0;
1016 unselect(win,file);
1018 data_active_window = owin;
1019 time_previous_sec=0;
1021 else
1023 if (config->generalflags & GENERAL_MMBSELECTS) makeactive(win,0);
1024 time_previous_sec=time_current_sec;
1025 time_previous_micro=time_current_micro;
1029 break;
1032 foobarbaz:
1033 if (function) internal_function(function,0,NULL,NULL);
1034 status_haveaborted=0;
1037 // goto foreverloop; // JRZ: Just in case???
1040 struct IntuiMessage *getintuimsg(void)
1042 return((IMsg=(struct IntuiMessage *)GetMsg(Window->UserPort)));
1045 void flushidcmp()
1047 while (getintuimsg()) ReplyMsg((struct Message *)IMsg);
1050 int isinwindow(x,y)
1051 int x,y;
1053 int win;
1055 for (win=0;win<2;win++) {
1056 if (x>=scrdata_dirwin_xpos[win] && x<scrdata_dirwin_xpos[win]+scrdata_dirwin_width[win] &&
1057 y>=scrdata_dirwin_ypos[win] && y<scrdata_dirwin_ypos[win]+scrdata_dirwin_height) return(win);
1059 return(-1);