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.
33 static struct Directory
*selectedentry
;
35 void doselection(win
,state
)
39 a
,b
,c
,d
,e
,x
,y
,ox
,oy
,fa
,la
,juststart
,atot
,drag
,offx
,offy
,candrag
,
40 comp
=-1,oc
,gad
,multidrag
=0,type
,okrepeatdrag
=0;
44 struct Directory
*next
;
46 candrag
=drag
=(config
->generalflags
&GENERAL_DRAG
&& drag_bob_buffer
)?1:0;
47 /*a=0;*/ atot
=dopus_curwin
[win
]->total
-scrdata_dispwin_lines
;
49 if (dopus_curwin
[win
]->total
==0) return;
50 ox
=x
=Window
->MouseX
; oy
=y
=Window
->MouseY
; selectedentry
=NULL
;
52 a
=(y
-scrdata_dirwin_ypos
[data_active_window
])/scrdata_font_ysize
;
54 offx
=x
-scrdata_dirwin_xpos
[data_active_window
];
56 else if (offx
>drag_sprite
.Width
*16) offx
=drag_sprite
.Width
*16;
57 offy
=y
-(scrdata_dirwin_ypos
[data_active_window
]+(a
*scrdata_font_ysize
));
59 if ((b
=select(win
,a
))==2) {
62 if (!b
|| !selectedentry
) drag
=0;
64 Window
->Flags
|=WFLG_REPORTMOUSE
;
66 while (getintuimsg()) {
68 class=IMsg
->Class
; code
=IMsg
->Code
; qual
=IMsg
->Qualifier
;
69 ReplyMsg((struct Message
*) IMsg
);
71 x
=Window
->MouseX
; y
=Window
->MouseY
;
73 if (class==MOUSEBUTTONS
) {
74 if (code
==MENUDOWN
&& candrag
&& selectedentry
) {
75 status_haveaborted
=status_justabort
=0;
76 if (drag
!=2) goto startdragging
;
82 else if (code
==SELECTUP
) {
87 else if (class==MOUSEMOVE
) {
90 if (scr_gadget_rows
&& dopus_curgadbank
) {
91 oc
=gadgetfrompos(x
,y
); gad
=oc
+(data_gadgetrow_offset
*7);
92 if (oc
>-1 && !(isvalidgad(&dopus_curgadbank
->gadgets
[gad
]))) oc
=-1;
94 RemIBob(&drag_bob
,main_rp
,ViewPortAddress(Window
));
95 if (comp
>-1) dragcompgad(comp
,0);
96 if (oc
>-1 && isvalidgad(&dopus_curgadbank
->gadgets
[gad
])) {
101 AddBob(&drag_bob
,main_rp
);
104 drag_sprite
.X
=x
-offx
; drag_sprite
.Y
=y
-offy
;
106 DrawGList(main_rp
,ViewPortAddress(Window
));
112 fa
=(y
-scrdata_dirwin_ypos
[data_active_window
])/scrdata_font_ysize
; la
=(oy
-scrdata_dirwin_ypos
[data_active_window
])/scrdata_font_ysize
;
113 if (fa
==la
&& drag
&& selectedentry
) {
114 if (x
<scrdata_dirwin_xpos
[data_active_window
] || x
>scrdata_dirwin_xpos
[data_active_window
]+scrdata_dirwin_width
[data_active_window
]) {
117 if (qual
&IEQUALIFIER_ANYSHIFT
&& dopus_curwin
[win
]->filesel
>1) {
119 lsprintf(buf
,globstring
[STR_MULTI_DRAG
],dopus_curwin
[win
]->filesel
);
124 if (selectedentry
->type
==ENTRY_CUSTOM
) {
125 switch (selectedentry
->subtype
) {
126 case CUSTOMENTRY_BUFFERLIST
:
127 ptr
=selectedentry
->comment
;
129 case CUSTOMENTRY_DIRTREE
:
130 ptr
=selectedentry
->dispstr
;
132 case CUSTOMENTRY_USER
:
133 if (selectedentry
->size
&CUSTENTRY_CANSELECT
)
134 ptr
=selectedentry
->comment
;
138 else ptr
=selectedentry
->name
;
139 type
=selectedentry
->type
;
142 dotaskmsg(clockmsg_port
,CLOCK_ACTIVE
,0,0,NULL
,0);
143 SetAPen(&drag_bob_rastport
,
145 (type
==ENTRY_DEVICE
&&
146 (selectedentry
->size
==DLT_DEVICE
|| selectedentry
->size
==DLT_VOLUME
)))?
147 screen_pens
[config
->filesselfg
].pen
:
148 screen_pens
[config
->dirsselfg
].pen
);
149 SetRast(&drag_bob_rastport
,
151 (type
==ENTRY_DEVICE
&&
152 (selectedentry
->size
==DLT_DEVICE
|| selectedentry
->size
==DLT_VOLUME
)))?
153 screen_pens
[config
->filesselbg
].pen
:
154 screen_pens
[config
->dirsselbg
].pen
);
155 Move(&drag_bob_rastport
,0,scr_font
[FONT_DIRS
]->tf_Baseline
);
156 c
=(drag_sprite
.Width
*16)/scrdata_font_xsize
;
163 Text(&drag_bob_rastport
,&ptr
[e
],c
);
164 drag_sprite
.X
=x
-offx
; drag_sprite
.Y
=y
-offy
;
165 AddBob(&drag_bob
,main_rp
);
167 DrawGList(main_rp
,ViewPortAddress(Window
));
179 if (y
>=scrdata_dispwin_ypos
&& y
<scrdata_dispwin_height
+scrdata_dispwin_ypos
) {
181 for (d
=fa
;d
<la
;d
++) defselect(win
,d
,b
);
184 else if (y
<scrdata_dispwin_ypos
) {
187 if (la
>=scrdata_dispwin_lines
) la
=scrdata_dispwin_lines
;
189 for (d
=fa
;d
<la
;d
++) defselect(win
,d
,b
);
194 if (dopus_curwin
[win
]->offset
==0) continue;
195 verticalscroll(win
,-1);
196 if (state
) defselect(win
,0,b
);
199 else if (y
>=scrdata_dispwin_height
+scrdata_dispwin_ypos
) {
202 if (la
>=scrdata_dispwin_lines
) la
=scrdata_dispwin_lines
;
204 for (d
=fa
;d
<la
;d
++) defselect(win
,d
,b
);
205 defselect(win
,scrdata_dispwin_lines
-1,b
);
209 if (dopus_curwin
[win
]->offset
==atot
) continue;
210 verticalscroll(win
,1);
211 if (state
) defselect(win
,scrdata_dispwin_lines
-1,b
);
220 if (getintuimsg()) goto gotmsgloop
;
221 if (okrepeatdrag
) goto getcoordsloop
;
222 Wait(1<<Window
->UserPort
->mp_SigBit
);
226 RemIBob(&drag_bob
,main_rp
,ViewPortAddress(Window
));
227 if (comp
>-1) dragcompgad(comp
,0);
228 dotaskmsg(clockmsg_port
,CLOCK_ACTIVE
,1,0,NULL
,0);
229 if (x
>=scrdata_dirwin_xpos
[1-data_active_window
] &&
230 x
<=scrdata_dirwin_xpos
[1-data_active_window
]+scrdata_dirwin_width
[1-data_active_window
] &&
231 y
>=scrdata_dirwin_ypos
[1-data_active_window
] &&
232 y
<=scrdata_dirwin_ypos
[1-data_active_window
]+scrdata_dirwin_height
&& drag
==2) {
234 last_selected_entry
=dopus_curwin
[win
]->firstentry
;
235 while (last_selected_entry
) {
236 if (status_haveaborted
|| status_justabort
) {
240 next
=last_selected_entry
->next
;
241 if (last_selected_entry
->type
<=ENTRY_FILE
&& last_selected_entry
->selected
) {
242 CurrentTime(&time_previous_sec
,&time_previous_micro
);
243 time_current_sec
=time_previous_sec
;
244 time_current_micro
=time_previous_micro
;
245 makeactive(1-data_active_window
,1);
247 last_selected_entry
=next
;
251 time_previous_sec
=time_current_sec
;
252 time_previous_micro
=time_current_micro
;
253 last_selected_entry
=selectedentry
;
254 makeactive(1-data_active_window
,1);
258 gad
=comp
+(data_gadgetrow_offset
*7);
259 if (dopus_curgadbank
&& isvalidgad(&dopus_curgadbank
->gadgets
[gad
])) {
261 last_selected_entry
=NULL
;
262 func_single_file
[0]=0;
263 status_flags
|=STATUS_GLOBALFILE
;
266 last_selected_entry
=selectedentry
;
267 strcpy(func_single_file
,selectedentry
->name
);
268 if (selectedentry
->selected
) unselect(data_active_window
,selectedentry
);
270 dofunctionstring(dopus_curgadbank
->gadgets
[gad
].function
,
271 dopus_curgadbank
->gadgets
[gad
].name
,
272 NULL
,(struct dopusfuncpar
*)&dopus_curgadbank
->gadgets
[gad
].which
);
273 status_flags
&=~STATUS_GLOBALFILE
;
274 if (!multidrag
) checkselection(selectedentry
);
278 Window
->Flags
&=~WFLG_REPORTMOUSE
;
282 void dormbscroll(win
)
287 int x
,y
,d
,__unused a
,__unused ret
=0;
288 __unused
struct Directory
*temp
;
290 if (data_active_window
!=win
) {
295 if (dopus_curwin
[win
]->total
>0 && status_flags
&STATUS_IANSCRAP
) {
296 CurrentTime(&time_current_sec
,&time_current_micro
);
298 a
=(y
-scrdata_dirwin_ypos
[data_active_window
]-2)/scrdata_font_ysize
;
299 if (a
<scrdata_dispwin_lines
) {
300 a
+=dopus_curwin
[win
]->offset
;
301 if (a
<=dopus_curwin
[win
]->total
) {
302 temp
=dopus_curwin
[win
]->firstentry
;
303 while (a
--) temp
=temp
->next
;
304 if (temp
&& temp
->type
<=ENTRY_FILE
&& temp
->selected
&&
305 (DoubleClick(time_previous_sec
,time_previous_micro
,
306 time_current_sec
,time_current_micro
)) &&
307 last_selected_entry
==temp
&&
308 config
->generalflags
&GENERAL_DOUBLECLICK
) {
310 ftype_doubleclick(str_pathbuffer
[win
],temp
->name
,0);
321 while (!getintuimsg()) {
322 x
=Window
->MouseX
; y
=Window
->MouseY
;
324 if (y
<scr_scroll_borders
[win
].MinY
) {
325 verticalscroll(win
,-1);
326 if (y
>scr_scroll_borders
[win
].MinY
-(scrdata_font_ysize
*4)) d
=1;
328 else if (y
>scr_scroll_borders
[win
].MaxY
) {
329 verticalscroll(win
,1);
330 if (y
<scr_scroll_borders
[win
].MaxY
+(scrdata_font_ysize
*4)) d
=1;
332 else if (x
<scr_scroll_borders
[win
].MinX
) horizontalscroll(win
,-1);
333 else if (x
>scr_scroll_borders
[win
].MaxX
) horizontalscroll(win
,1);
336 class=IMsg
->Class
; code
=IMsg
->Code
;
337 ReplyMsg((struct Message
*) IMsg
);
338 if (class==MOUSEBUTTONS
&& code
==MENUUP
) break;
345 int a
,dbclick
/*=0*/,sel
=1,foundcount
;
346 char sbuf
[FILEBUF_SIZE
],*dir
;
347 struct Directory
*temp
,*temp2
;
349 a
=o
+dopus_curwin
[win
]->offset
;
350 if (o
>=scrdata_dispwin_lines
|| a
>=dopus_curwin
[win
]->total
) return(0);
351 temp
=dopus_curwin
[win
]->firstentry
;
352 while (a
--) temp
=temp
->next
;
354 if (temp
&& ((ENTRYTYPE(temp
->type
)!=ENTRY_CUSTOM
) ||
355 (temp
->subtype
!=CUSTOMENTRY_USER
) || (temp
->size
&CUSTENTRY_CANSELECT
))) {
357 temp
->selected
=sel
?FALSE
:TRUE
;
358 updateselectinfo(temp
,win
,1);
359 if (!status_iconified
) {
360 display_entry(temp
,win
,
361 scrdata_dirwin_xpos
[win
]-dopus_curwin
[win
]->hoffset
+1,
362 scrdata_font_baseline
+(scrdata_font_ysize
*o
)+scrdata_dirwin_ypos
[win
]);
363 if (config
->iconflags
&ICONFLAG_AUTOSELECT
) {
364 StrCombine(sbuf
,temp
->name
,".info",FILEBUF_SIZE
-1);
365 if ((temp2
=findfile(dopus_curwin
[win
],sbuf
,&foundcount
))) {
366 if (temp2
->selected
!=temp
->selected
) {
367 temp2
->selected
=temp
->selected
;
368 updateselectinfo(temp2
,win
,1);
369 if (foundcount
>=dopus_curwin
[win
]->offset
&&
370 foundcount
<dopus_curwin
[win
]->offset
+scrdata_dispwin_lines
) {
371 o
=foundcount
-dopus_curwin
[win
]->offset
;
372 display_entry(temp2
,win
,
373 scrdata_dirwin_xpos
[win
]-dopus_curwin
[win
]->hoffset
+1,
374 scrdata_font_baseline
+(scrdata_font_ysize
*o
)+scrdata_dirwin_ypos
[win
]);
382 if (last_selected_entry!=temp ||
383 !(dbclick=DoubleClick(time_previous_sec,time_previous_micro,
384 time_current_sec,time_current_micro))) {
385 last_selected_entry=temp;
387 time_previous_sec=time_current_sec;
388 time_previous_micro=time_current_micro;
392 dbclick
=DoubleClick(time_previous_sec
,time_previous_micro
,
393 time_current_sec
,time_current_micro
);
397 time_previous_sec
=time_current_sec
;
398 time_previous_micro
=time_current_micro
;
401 switch (ENTRYTYPE(temp
->type
)) {
403 case ENTRY_DIRECTORY
:
404 if (dbclick
==-1) last_selected_entry
=temp
;
405 else if (dbclick
&& last_selected_entry
==temp
) {
406 dir
=dopus_curwin
[win
]->directory
;
407 if (!(dopus_curwin
[win
]->flags
& DWF_ARCHIVE
)) advancebuf(win
,1);
408 if (temp
->type
==ENTRY_DEVICE
) strcpy(str_pathbuffer
[win
],temp
->name
);
411 if (temp
->subtype
== ST_SOFTLINK
)
413 struct FileInfoBlock __aligned fib
;
416 char linkbuf
[512],buf
[256];
421 //D(bug("SoftLink! path: %s\t name: %s\n",linkbuf,temp->name));
422 ld
= Lock(linkbuf
,ACCESS_READ
);
423 if (dp
= GetDeviceProc(linkbuf
,NULL
))
425 //D(bug("DeviceProc: %lX\n",dp));
426 if (ReadLink(dp
->dvp_Port
,ld
,temp
->name
,buf
,256))
428 AddPart(linkbuf
,buf
,512);
429 //D(bug("Resolved: %s\n",linkbuf));
430 if (lf
= Lock(linkbuf
,ACCESS_READ
))
432 //D(bug("Locked\n"));
433 NameFromLock(lf
,linkbuf
,512);
434 if (Examine(lf
,&fib
))
436 //D(bug("Examined: type: %ld, name: %s\n",fib.fib_DirEntryType,fib.fib_FileName));
437 if (fib
.fib_DirEntryType
== ST_SOFTLINK
) *PathPart(linkbuf
) = 0;
443 //D(bug("Lock() failed!\n"));
444 fib
.fib_DirEntryType
= ST_USERDIR
;
450 } while (fib
.fib_DirEntryType
== ST_SOFTLINK
);
451 strcpy(str_pathbuffer
[win
],linkbuf
);
455 strcpy(str_pathbuffer
[win
],dir
);
456 TackOn(str_pathbuffer
[win
],temp
->name
,256);
459 D(bug("Get dir: %s\n",str_pathbuffer
[win
]));
460 startgetdir(win
,SGDFLAGS_CANMOVEEMPTY
|SGDFLAGS_CANCHECKBUFS
);
467 if (dbclick
==-1) last_selected_entry
=temp
;
468 else if (dbclick
&& last_selected_entry
==temp
) {
469 if (temp
->subtype
==CUSTOMENTRY_BUFFERLIST
||
470 temp
->subtype
==CUSTOMENTRY_DIRTREE
) {
471 if (temp
->subtype
==CUSTOMENTRY_BUFFERLIST
)
472 bringinbuffer(last_selected_entry
->dispstr
,win
,1);
474 strcpy(str_pathbuffer
[win
],last_selected_entry
->dispstr
);
475 startgetdir(win
,SGDFLAGS_CANMOVEEMPTY
|SGDFLAGS_CANCHECKBUFS
);
480 else if (temp
->subtype
==CUSTOMENTRY_USER
) {
481 userentrymessage(dopus_curwin
[win
],temp
,USERENTRY_DOUBLECLICK
);
489 if (dbclick
==-1) last_selected_entry
=temp
;
490 else if (dbclick
&& last_selected_entry
==temp
) {
491 if (config
->generalflags
&GENERAL_DOUBLECLICK
) {
492 if (dopus_curwin
[win
]->flags
& DWF_ARCHIVE
)
494 char path
[256], tempname
[FILEBUF_SIZE
];
497 if (unarcfiledir(dopus_curwin
[win
],path
,tempname
,temp
->name
))
499 ftype_doubleclick(path
,tempname
,1);
500 AddPart(path
,tempname
,256);
501 removetemparcfile(path
);
504 else ftype_doubleclick(str_pathbuffer
[win
],temp
->name
,1);
516 int unselect(win
,file
)
518 struct Directory
*file
;
523 if (win
==-1 || !file
->selected
) return(0);
524 t
=dopus_curwin
[win
]->firstentry
;
525 while (t
!=file
&& t
) {
530 switch (ENTRYTYPE(file
->type
)) {
531 case ENTRY_DIRECTORY
:
533 --dopus_curwin
[win
]->dirsel
;
534 if (file
->type
>0 && file
->size
!=-1) dopus_curwin
[win
]->bytessel
-=file
->size
;
537 --dopus_curwin
[win
]->filesel
;
538 dopus_curwin
[win
]->bytessel
-=file
->size
;
541 file
->selected
=FALSE
;
542 if (a
<dopus_curwin
[win
]->offset
||
543 a
>(dopus_curwin
[win
]->offset
+scrdata_dispwin_lines
-1)) return(0);
544 a
-=dopus_curwin
[win
]->offset
;
545 if (!status_iconified
) {
547 scrdata_dirwin_xpos
[win
]-dopus_curwin
[win
]->hoffset
+1,
548 scrdata_font_baseline
+(scrdata_font_ysize
*a
)+scrdata_dirwin_ypos
[win
]);
553 void defselect(win
,o
,state
)
557 struct Directory
*temp
,*temp2
;
558 char sbuf
[FILEBUF_SIZE
];
560 if (o
<0 || o
>scrdata_dispwin_lines
-1) return;
561 a
=o
+dopus_curwin
[win
]->offset
;
562 if (a
>=dopus_curwin
[win
]->total
) return;
563 temp
=dopus_curwin
[win
]->firstentry
;
564 while (a
--) temp
=temp
->next
;
565 if (state
) selectedentry
=temp
;
566 else selectedentry
=NULL
;
567 if (temp
&& ((ENTRYTYPE(temp
->type
)!=ENTRY_CUSTOM
) ||
568 (temp
->subtype
!=CUSTOMENTRY_USER
) || (temp
->size
&CUSTENTRY_CANSELECT
))) {
569 if (temp
->selected
!=state
) {
570 temp
->selected
=state
;
571 updateselectinfo(temp
,win
,1);
572 if (!status_iconified
) {
573 display_entry(temp
,win
,
574 scrdata_dirwin_xpos
[win
]-dopus_curwin
[win
]->hoffset
+1,
575 scrdata_font_baseline
+(scrdata_font_ysize
*o
)+scrdata_dirwin_ypos
[win
]);
578 if (config
->iconflags
&ICONFLAG_AUTOSELECT
) {
579 StrCombine(sbuf
,temp
->name
,".info",FILEBUF_SIZE
-1);
580 if ((temp2
=findfile(dopus_curwin
[win
],sbuf
,&foundcount
))) {
581 if (temp2
->selected
!=temp
->selected
) {
582 temp2
->selected
=temp
->selected
;
583 updateselectinfo(temp2
,win
,1);
584 if (foundcount
>=dopus_curwin
[win
]->offset
&&
585 foundcount
<dopus_curwin
[win
]->offset
+scrdata_dispwin_lines
) {
586 if (!status_iconified
) {
587 o
=foundcount
-dopus_curwin
[win
]->offset
;
588 display_entry(temp2
,win
,
589 scrdata_dirwin_xpos
[win
]-dopus_curwin
[win
]->hoffset
+1,
590 scrdata_font_baseline
+(scrdata_font_ysize
*o
)+scrdata_dirwin_ypos
[win
]);
599 void globalselect(win
,all
)
602 struct Directory
*temp
;
604 if ((temp
=dopus_curwin
[win
]->firstentry
) && temp
->type
!=ENTRY_CUSTOM
) {
607 if (temp->type!=ENTRY_CUSTOM || temp->subtype!=CUSTOMENTRY_USER ||
608 temp->size&CUSTENTRY_CANSELECT) temp->selected=all;
614 dopus_curwin
[win
]->filesel
=dopus_curwin
[win
]->filetot
;
615 dopus_curwin
[win
]->dirsel
=dopus_curwin
[win
]->dirtot
;
616 dopus_curwin
[win
]->bytessel
=dopus_curwin
[win
]->bytestot
;
619 dopus_curwin
[win
]->filesel
=0;
620 dopus_curwin
[win
]->dirsel
=0;
621 dopus_curwin
[win
]->bytessel
=0;
627 void updateselectinfo(temp
,win
,show
)
628 struct Directory
*temp
;
631 if (temp
->selected
) {
632 switch (ENTRYTYPE(temp
->type
)) {
633 case ENTRY_DIRECTORY
:
634 if (temp
->size
!=-1) dopus_curwin
[win
]->bytessel
+=temp
->size
;
636 ++dopus_curwin
[win
]->dirsel
;
639 ++dopus_curwin
[win
]->filesel
;
640 dopus_curwin
[win
]->bytessel
+=temp
->size
;
644 if (config
->generalflags
&GENERAL_DISPLAYINFO
) doinfodisplay(temp
,TRUE
);
645 else doselinfo(data_active_window
);
649 switch (ENTRYTYPE(temp
->type
)) {
650 case ENTRY_DIRECTORY
:
651 if (temp
->size
!=-1) dopus_curwin
[win
]->bytessel
-=temp
->size
;
653 --dopus_curwin
[win
]->dirsel
;
656 --dopus_curwin
[win
]->filesel
;
657 dopus_curwin
[win
]->bytessel
-=temp
->size
;
660 if (show
) doselinfo(data_active_window
);
664 void globaltoggle(win
)
667 struct Directory
*temp
;
669 temp
=dopus_curwin
[win
]->firstentry
;
671 switch (ENTRYTYPE(temp
->type
)) {
673 if (temp
->selected
) {
674 dopus_curwin
[win
]->bytessel
-=temp
->size
;
675 --dopus_curwin
[win
]->filesel
;
679 dopus_curwin
[win
]->bytessel
+=temp
->size
;
680 ++dopus_curwin
[win
]->filesel
;
684 case ENTRY_DIRECTORY
:
685 if (temp
->selected
) {
686 if (temp
->size
>0) dopus_curwin
[win
]->bytessel
-=temp
->size
;
687 --dopus_curwin
[win
]->dirsel
;
691 if (temp
->size
>0) dopus_curwin
[win
]->bytessel
+=temp
->size
;
692 ++dopus_curwin
[win
]->dirsel
;
707 struct DateStamp ds1
,ds2
;
710 if (dopus_curwin
[data_active_window
]->total
==0 ||
711 dopus_curwin
[data_active_window
]->firstentry
->type
==ENTRY_CUSTOM
) return;
714 boobs
=getselectdata(str_select_pattern
,&selecttype
);
717 boobs
=rexx_arg_value
[0]; selecttype
=rexx_arg_value
[1];
718 strcpy(str_select_pattern
[selecttype
],rexx_args
[0]);
721 if (dopus_curwin
[data_active_window
]->total
==0) return;
722 switch (selecttype
) {
724 LParsePatternI(str_select_pattern
[0],buf
);
725 wildselect(buf
,boobs
,1,WILDSELECT_NAME
);
726 findfirstsel(data_active_window
,-2);
729 if (str_select_pattern
[1][0]==0) break;
730 getseldatestamps(str_select_pattern
[1],&ds1
,&ds2
);
731 dateselect(&ds1
,&ds2
,boobs
,1);
732 findfirstsel(data_active_window
,-2);
735 if (str_select_pattern
[2][0]==0) break;
736 getprotselvals(str_select_pattern
[2],prot
);
737 protselect(prot
[0],prot
[1],boobs
,1);
738 findfirstsel(data_active_window
,-2);
741 LParsePatternI(str_select_pattern
[3],buf
);
742 wildselect(buf
,boobs
,1,WILDSELECT_COMMENT
);
743 findfirstsel(data_active_window
,-2);
749 void getseldatestamps(buf
,ds1
,ds2
)
751 struct DateStamp
*ds1
,*ds2
;
753 char datebuf
[2][85],timebuf
[2][85],*ptr
;
756 datebuf
[0][0]=datebuf
[1][0]=timebuf
[0][0]=timebuf
[1][0]=a
/*=b*/=0;
757 ptr
=parsedatetime(buf
/*str_select_pattern[1]*/,datebuf
[0],timebuf
[0],&a
);
760 strcpy(datebuf
[1],datebuf
[0]);
761 strcpy(timebuf
[1],"23:59:59");
764 strcpy(datebuf
[1],datebuf
[0]);
765 strcpy(timebuf
[1],timebuf
[0]);
768 parsedatetime(ptr
,datebuf
[1],timebuf
[1],&a
/*&b*/);
771 D(bug("getseldatestamps(%s,%s,%s,%s)\n",datebuf
[0],timebuf
[0],datebuf
[1],timebuf
[1]));
772 strtostamp(datebuf
[0],timebuf
[0],ds1
);
773 strtostamp(datebuf
[1],timebuf
[1],ds2
);
774 ds1
->ds_Tick
=((ds1
->ds_Tick
/50)*50);
775 ds2
->ds_Tick
=((ds2
->ds_Tick
/50)*50)+49;
776 D(bug("getseldatestamp: ds1=%ld,%ld,%ld\n",ds1
->ds_Days
,ds1
->ds_Minute
,ds1
->ds_Tick
));
777 D(bug("getseldatestamp: ds2=%ld,%ld,%ld\n",ds2
->ds_Days
,ds2
->ds_Minute
,ds2
->ds_Tick
));
780 void getprotselvals(buf
,prot
)
791 if (ch
=='-') notflag
=1;
792 else if (ch
=='+') notflag
=0;
795 if (ch
==str_protbits
[c
]) {
796 prot
[notflag
]|=(1<<(7-c
));
804 void wildselect(wild
,boobs
,and,mode
)
809 struct Directory
*temp
;
811 temp
=dopus_curwin
[data_active_window
]->firstentry
;
815 dopus_curwin
[data_active_window
]->dirsel
=dopus_curwin
[data_active_window
]->filesel
= 0;
816 dopus_curwin
[data_active_window
]->bytessel
=0;
819 if (!and) dopus_curwin
[data_active_window
]->dirsel
=dopus_curwin
[data_active_window
]->filesel
=dopus_curwin
[data_active_window
]->bytessel
=0;
822 if (temp
->type
!=ENTRY_CUSTOM
|| temp
->subtype
!=CUSTOMENTRY_USER
||
823 temp
->size
&CUSTENTRY_CANSELECT
) {
824 if (!and) temp
->selected
=0;
825 if (temp
->type
==ENTRY_CUSTOM
) {
826 if (!temp
->selected
&& temp
->comment
) {
827 StrToUpper(temp
->comment
,buf
);
828 if (LMatchPatternI(wild
,buf
)) wildselectthisone(temp
,data_active_window
,boobs
);
832 if (!temp
->selected
) {
833 StrToUpper((mode
==WILDSELECT_NAME
)?temp
->name
:temp
->comment
,buf
);
834 if (LMatchPatternI(wild
,buf
)) wildselectthisone(temp
,data_active_window
,boobs
);
840 refreshwindow(data_active_window
,0);
841 doselinfo(data_active_window
);
844 void dateselect(ds1
,ds2
,boobs
,and)
845 struct DateStamp
*ds1
,*ds2
;
848 struct Directory
*temp
;
850 temp
=dopus_curwin
[data_active_window
]->firstentry
;
852 dopus_curwin
[data_active_window
]->dirsel
=
853 dopus_curwin
[data_active_window
]->filesel
=
854 dopus_curwin
[data_active_window
]->bytessel
=0;
857 if (temp
->type
!=ENTRY_CUSTOM
|| temp
->subtype
!=CUSTOMENTRY_USER
||
858 temp
->size
&CUSTENTRY_CANSELECT
) {
859 if (!and) temp
->selected
=0;
860 if (!temp
->selected
&&
861 CompareDate(&(temp
->date
),ds1
)>=0 && CompareDate(ds2
,&(temp
->date
))>=0)
862 wildselectthisone(temp
,data_active_window
,boobs
);
866 refreshwindow(data_active_window
,0);
867 doselinfo(data_active_window
);
870 void protselect(protyes
,protno
,boobs
,and)
871 int protyes
,protno
,boobs
,and;
873 struct Directory
*temp
;
876 temp
=dopus_curwin
[data_active_window
]->firstentry
;
880 dopus_curwin
[data_active_window
]->dirsel
=dopus_curwin
[data_active_window
]->filesel
=0;
881 dopus_curwin
[data_active_window
]->bytessel
=0;
884 if (!and) dopus_curwin
[data_active_window
]->dirsel
=dopus_curwin
[data_active_window
]->filesel
=dopus_curwin
[data_active_window
]->bytessel
=0;
887 if (temp
->type
!=ENTRY_CUSTOM
|| temp
->subtype
!=CUSTOMENTRY_USER
||
888 temp
->size
&CUSTENTRY_CANSELECT
) {
889 if (!and) temp
->selected
=0;
890 if (!temp
->selected
) {
891 prot
=((~temp
->protection
)&15)+(temp
->protection
&~15);
892 if ((prot
&protyes
)==protyes
&& ((prot
&~protyes
)&protno
)==0)
893 wildselectthisone(temp
,data_active_window
,boobs
);
898 refreshwindow(data_active_window
,0);
899 doselinfo(data_active_window
);
902 void wildselectthisone(temp
,win
,boobs
)
903 struct Directory
*temp
;
906 if (boobs
==1 && temp
->type
!=ENTRY_DEVICE
) temp
->selected
=1;
907 else if (boobs
==2 && temp
->type
<=ENTRY_FILE
) temp
->selected
=1;
908 else if (boobs
==3 && temp
->type
>=ENTRY_DIRECTORY
) temp
->selected
=1;
909 if (temp
->selected
) {
910 if (temp
->type
>=ENTRY_DIRECTORY
) {
911 ++dopus_curwin
[win
]->dirsel
;
912 if (temp
->size
!=-1) dopus_curwin
[win
]->bytessel
+=temp
->size
;
914 else if (temp
->type
<=ENTRY_FILE
) {
915 ++dopus_curwin
[win
]->filesel
;
916 dopus_curwin
[win
]->bytessel
+=temp
->size
;
926 if (!dopus_curwin
[win
]->firstentry
|| dopus_curwin
[win
]->firstentry
->type
!=ENTRY_CUSTOM
) {
927 buildkmgstring(b1
,/*(long long)*/dopus_curwin
[win
]->bytessel
,config
->listerdisplayflags
[win
] & SIZE_KMG
);
928 buildkmgstring(b2
,/*(long long)*/dopus_curwin
[win
]->bytestot
,config
->listerdisplayflags
[win
] & SIZE_KMG
);
929 D(bug("doselinfo(): b1 = %s, b2 = %s\n",b1
,b2
));
930 lsprintf(str_select_info
,globstring
[STR_DIRS_FILES_BYTES_COUNT
],
931 dopus_curwin
[win
]->dirsel
,dopus_curwin
[win
]->dirtot
,dopus_curwin
[win
]->filesel
,
932 dopus_curwin
[win
]->filetot
,b1
,b2
);
935 switch (dopus_curwin
[win
]->firstentry
->subtype
) {
936 case CUSTOMENTRY_DIRTREE
:
937 lsprintf(str_select_info
,globstring
[STR_ENTRIES_IN_TREE
],dopus_curwin
[win
]->total
);
939 case CUSTOMENTRY_BUFFERLIST
:
940 lsprintf(str_select_info
,globstring
[STR_DIRS_IN_BUFFERS
],dopus_curwin
[win
]->total
);
942 case CUSTOMENTRY_USER
:
943 lsprintf(str_select_info
,globstring
[STR_USER_ENTRIES
],dopus_curwin
[win
]->total
);
947 dostatustext(str_select_info
);
950 int makeactive(win
,state
)
953 if (data_active_window
!=win
) {
954 data_active_window
=win
;
955 return(doactive(state
,1));
960 int doactive(state
,showinfo
)
965 struct dopusfiletype
*type
;
966 struct dopusfuncpar par
;
967 struct Directory
*entry
;
969 if (status_iconified
) return(0);
970 if (showinfo
) doselinfo(data_active_window
);
971 if (last_selected_entry
&&
972 last_selected_entry
->type
<=ENTRY_FILE
) {
973 if (state
&& config
->generalflags
&GENERAL_DOUBLECLICK
) {
974 if (DoubleClick(time_previous_sec
,time_previous_micro
,
975 time_current_sec
,time_current_micro
)) {
976 data_active_window
=1-data_active_window
;
977 unselect(data_active_window
,last_selected_entry
);
978 entry
=last_selected_entry
;
979 dostatustext(globstring
[STR_INTERROGATING_FILE
]);
980 StrCombine(buf
,str_pathbuffer
[data_active_window
],last_selected_entry
->name
,256);
982 if ((type
=checkfiletype(buf
,FTFUNC_CLICKMCLICK
,0))) {
985 strcpy(func_single_file
,last_selected_entry
->name
);
986 par
.which
=type
->which
[FTFUNC_CLICKMCLICK
];
987 par
.stack
=type
->stack
[FTFUNC_CLICKMCLICK
];
988 par
.key
=par
.qual
=0; par
.type
=3;
989 par
.pri
=type
->pri
[FTFUNC_CLICKMCLICK
];
990 par
.delay
=type
->delay
[FTFUNC_CLICKMCLICK
];
992 if (type
->actionstring
[FTFUNC_CLICKMCLICK
][0]) {
993 do_title_string(type
->actionstring
[FTFUNC_CLICKMCLICK
],title
,0,NULL
);
998 dofunctionstring(type
->function
[FTFUNC_CLICKMCLICK
],
999 last_selected_entry
->name
,title
,&par
);
1001 checkselection(entry
);
1008 last_selected_entry
=NULL
;
1010 for (oe
=0;oe
<2;oe
++) displayname(oe
,1);
1011 if (last_selected_entry
&&
1012 last_selected_entry
->type
>=ENTRY_DEVICE
&& state
) {
1013 if (DoubleClick(time_previous_sec
,time_previous_micro
,
1014 time_current_sec
,time_current_micro
)) {
1015 if (last_selected_entry
->type
==ENTRY_CUSTOM
&&
1016 last_selected_entry
->subtype
==CUSTOMENTRY_USER
) {
1017 if (last_selected_entry
->size
&CUSTENTRY_CANSELECT
) {
1018 userentrymessage(dopus_curwin
[1-data_active_window
],last_selected_entry
,USERENTRY_CLICKMCLICK
);
1019 time_previous_sec
=0;
1023 unselect(1-data_active_window
,last_selected_entry
);
1024 advancebuf(data_active_window
,1);
1025 if (last_selected_entry
->type
==ENTRY_CUSTOM
) {
1026 if (last_selected_entry
->subtype
==CUSTOMENTRY_BUFFERLIST
) {
1027 bringinbuffer(last_selected_entry
->dispstr
,data_active_window
,1);
1028 time_previous_sec
=0;
1031 else strcpy(str_pathbuffer
[data_active_window
],last_selected_entry
->dispstr
);
1034 strcpy(str_pathbuffer
[data_active_window
],dopus_curwin
[1-data_active_window
]->directory
);
1035 TackOn(str_pathbuffer
[data_active_window
],last_selected_entry
->name
,256);
1037 startgetdir(data_active_window
,SGDFLAGS_CANMOVEEMPTY
|SGDFLAGS_CANCHECKBUFS
);
1038 time_previous_sec
=0;
1049 struct Directory
*entry
;
1051 entry
=dopus_curwin
[win
]->firstentry
;
1053 if (entry
->selected
&& ENTRYTYPE(entry
->type
)==ENTRY_DIRECTORY
&&
1055 setdirsize(entry
,-1,win
);
1057 if (entry
->next
) entry
=entry
->next
;
1060 refreshwindow(win
,0);
1061 if (win
==data_active_window
) doselinfo(win
);
1064 void checkselection(entry
)
1065 struct Directory
*entry
;
1067 struct Directory
*temp
;
1069 last_selected_entry
=NULL
; func_single_file
[0]=0;
1070 temp
=dopus_curwin
[data_active_window
]->firstentry
;
1072 if (temp
==entry
) break;
1075 if (temp
&& temp
->selected
) unselect(data_active_window
,temp
);