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.
32 #define NO_INLINE_STDARG
34 #define NO_PPCINLINE_STDARG
38 sbName
=DISPLAY_NAME
+1, sbSize
, sbProt
, sbDate
, sbComment
, sbType
, sbOwner
, sbGroup
, sbNetprot
, sbExt
,
40 sbMix
=0x00010000,sbDirF
=0x00020000,sbFileF
=0x00030000,
41 sbSortA
=0x01000000,sbSortD
=0x02000000,sbSortH
=0x03000000,
42 sbReverse
=0x40000000 // So we can put in the same LONG, as a flag...
45 /* based on code by Henrik Isaksson */
48 ULONG
MenuHandlerFunc(void);
50 struct EmulLibEntry GATE_MenuHandlerFunc
= { TRAP_LIB
, 0, (void (*)(void))MenuHandlerFunc
};
52 ULONG
MenuHandlerFunc(void)
54 struct Hook
*hook
= (struct Hook
*)REG_A0
;
55 struct PopupMenu
*pm
= (struct PopupMenu
*)REG_A2
;
56 // APTR msg = (APTR)REG_A1;
58 __saveds ULONG
MenuHandlerFunc(register struct Hook
*hook
__asm("a0"),\
59 register struct PopupMenu
*pm
__asm("a2"),\
60 register APTR msg
__asm("a1"))
66 PM_GetItemAttrs(pm
,PM_ID
,&id
,PM_Checked
,&on
,TAG_END
);
67 //D(bug("&sortorder: %lx\tID: %ld\tFlags: %lx\n",hook->h_Data,id,on));
72 *((ULONG
*)hook
->h_Data
) |= sbReverse
; // Set flag
76 *((ULONG
*)hook
->h_Data
) &= ~sbReverse
; // Clear flag
79 else if(id
>=sbName
&& id
<sbKMG
)
83 *((ULONG
*)hook
->h_Data
) &= 0xFFFF0000; // We don't need all bits so we
84 *((ULONG
*)hook
->h_Data
) |= id
; // preserve the high ones for flags.
87 else if(((id
>>16)&0xF)>0)
91 *((ULONG
*)hook
->h_Data
) &= 0xFFF0FFFF;
92 *((ULONG
*)hook
->h_Data
) |= id
;
95 else if(((id
>>24)&0xF)>0)
99 *((ULONG
*)hook
->h_Data
) &= 0xF0FFFFFF;
100 *((ULONG
*)hook
->h_Data
) |= id
;
108 void handlelistermenu(int a
)
110 struct Hook MenuHandler
;
111 ULONG sortorder
; // Holds the current sort order
113 BOOL changed
= FALSE
;
114 char oldsort
,newsort
,sortbit
;
117 !dopus_curwin
[a
]->firstentry
||
118 (ENTRYTYPE(dopus_curwin
[a
]->firstentry
->type
) == ENTRY_CUSTOM
) ||
119 (ENTRYTYPE(dopus_curwin
[a
]->firstentry
->type
) == ENTRY_DEVICE
))
122 sortbit
= a
?SORT_RREVERSE
:SORT_LREVERSE
;
123 oldsort
= config
->sortflags
& sortbit
;
125 MenuHandler
.h_Entry
= (HOOKFUNC
) &GATE_MenuHandlerFunc
;
127 MenuHandler
.h_Entry
= (HOOKFUNC
) MenuHandlerFunc
;
129 MenuHandler
.h_Data
= &sortorder
;
131 for (r
= DISPLAY_NAME
; r
<= DISPLAY_LAST
; r
++)
132 PM_SetItemAttrs(PM_FindItem(sortmenu
,1+r
),
133 PM_Checked
,config
->sortmethod
[a
] == r
,
136 PM_SetItemAttrs(PM_FindItem(sortmenu
,sbReverse
),PM_Checked
,oldsort
,TAG_END
);
138 for (r
= 0; r
< 3; r
++)
139 PM_SetItemAttrs(PM_FindItem(sortmenu
,(r
+1)*0x00010000),
140 PM_Checked
,config
->separatemethod
[a
] == r
,
143 for (r
= 0; r
< 3; r
++)
144 PM_SetItemAttrs(PM_FindItem(sortmenu
,(r
+1)*0x01000000),
145 PM_Checked
, SORT_NAMEMODE(config
->sortflags
)==r
,
148 PM_SetItemAttrs(PM_FindItem(sortmenu
,sbKMG
),
149 PM_Checked
,(config
->listerdisplayflags
[a
] & SIZE_KMG
) == SIZE_KMG
,
152 sortorder
= (config
->sortmethod
[a
] + 1) + (oldsort
? sbReverse
: 0) + (config
->separatemethod
[a
]+1)*0x00010000 + (SORT_NAMEMODE(config
->sortflags
)+1)*0x01000000;
154 PM_OpenPopupMenu(Window
, PM_Menu
, sortmenu
,
155 PM_MenuHandler
, &MenuHandler
,
156 PM_ForceFont
, scr_font
[FONT_MENUS
],
158 D(bug("sortorder=%lx\n",sortorder
));
159 r
= (sortorder
&0xFFFF) - 1;
160 if (config
->sortmethod
[a
] != r
)
162 config
->sortmethod
[a
] = r
;
165 r
= ((sortorder
>>16)&0xF) - 1;
166 if (config
->separatemethod
[a
] != r
)
168 config
->separatemethod
[a
] = r
;
171 r
= ((sortorder
>>24)&0xF) - 1;
172 if (SORT_NAMEMODE(config
->sortflags
) != r
)
174 config
->sortflags
&=~SORT_NAMEMASK
;
175 config
->sortflags
|= r
<<SORT_BITPOS
;
178 r
= (sortorder
& sbReverse
) ? ~0 : 0;
179 newsort
= r
& sortbit
;
180 //D(bug("newsort = %lx\n",newsort));
181 if (oldsort
!= newsort
)
183 if (newsort
) config
->sortflags
|= sortbit
;
184 else config
->sortflags
&= ~sortbit
;
188 r
= PM_ItemChecked(sortmenu
,sbKMG
) ? SIZE_KMG
: 0;
189 if ( ( config
->listerdisplayflags
[a
] & SIZE_KMG
) != r
)
191 if ( r
& SIZE_KMG
) config
->listerdisplayflags
[a
] |= SIZE_KMG
;
192 else config
->listerdisplayflags
[a
] &= ~SIZE_KMG
;
194 setsizedisplen(&dir_rp
[a
]);
197 if (! changed
) refreshwindow(a
,1);
202 sortdir(dopus_curwin
[a
],a
);
207 void initlistermenu(void)
211 BOOL userinfo
= AccountsBase
|| muBase
;
213 sortmenu
= PMMenu(globstring
[STR_LISTER_MENU
]),
214 PMInfo(globstring
[STR_SORTBY
]),
217 PMCheckItem(globstring
[STR_FILE_NAME
],sbName
),
218 PM_Exclude
, PM_ExLst(sbSize
,sbProt
,sbDate
,sbComment
,sbType
,sbOwner
,sbGroup
,sbNetprot
,sbExt
,0),
220 PMCheckItem(globstring
[STR_FILE_EXTENSION
],sbExt
),
221 PM_Exclude
, PM_ExLst(sbName
,sbSize
,sbProt
,sbDate
,sbComment
,sbType
,sbOwner
,sbGroup
,sbNetprot
,0),
223 PMCheckItem(globstring
[STR_FILE_SIZE
],sbSize
),
224 PM_Exclude
, PM_ExLst(sbName
,sbProt
,sbDate
,sbComment
,sbType
,sbOwner
,sbGroup
,sbNetprot
,sbExt
,0),
226 PMCheckItem(globstring
[STR_PROTECTION_BITS
],sbProt
),
227 PM_Exclude
, PM_ExLst(sbName
,sbSize
,sbDate
,sbComment
,sbType
,sbOwner
,sbGroup
,sbNetprot
,sbExt
,0),
229 PMCheckItem(globstring
[STR_CREATION_DATE
],sbDate
),
230 PM_Exclude
, PM_ExLst(sbName
,sbSize
,sbProt
,sbComment
,sbType
,sbOwner
,sbGroup
,sbNetprot
,sbExt
,0),
232 PMCheckItem(globstring
[STR_FILE_COMMENT
],sbComment
),
233 PM_Exclude
, PM_ExLst(sbName
,sbSize
,sbProt
,sbDate
,sbType
,sbOwner
,sbGroup
,sbNetprot
,sbExt
,0),
235 PMCheckItem(globstring
[STR_FILE_TYPE
],sbType
),
236 PM_Exclude
, PM_ExLst(sbName
,sbSize
,sbProt
,sbDate
,sbComment
,sbOwner
,sbGroup
,sbNetprot
,sbExt
,0),
238 PMCheckItem(globstring
[STR_OWNER
],sbOwner
),
239 PM_Exclude
, PM_ExLst(sbName
,sbSize
,sbProt
,sbDate
,sbComment
,sbType
,sbGroup
,sbNetprot
,sbExt
,0),
240 PM_Hidden
, ! userinfo
,
242 PMCheckItem(globstring
[STR_GROUP
],sbGroup
),
243 PM_Exclude
, PM_ExLst(sbName
,sbSize
,sbProt
,sbDate
,sbComment
,sbType
,sbOwner
,sbNetprot
,sbExt
,0),
244 PM_Hidden
, ! userinfo
,
246 PMCheckItem(globstring
[STR_NET_PROTECTION_BITS
],sbNetprot
),
247 PM_Exclude
, PM_ExLst(sbName
,sbSize
,sbProt
,sbDate
,sbComment
,sbType
,sbOwner
,sbGroup
,sbExt
,0),
248 PM_Hidden
, ! userinfo
,
252 PMCheckItem(globstring
[STR_REVERSE_ORDER
],sbReverse
),
256 PMCheckItem(globstring
[STR_MIXDIRSFILES
],sbMix
),
257 PM_Exclude
, PM_ExLst(sbDirF
,sbFileF
,0),
259 PMCheckItem(globstring
[STR_DIRSFIRST
],sbDirF
),
260 PM_Exclude
, PM_ExLst(sbMix
,sbFileF
,0),
262 PMCheckItem(globstring
[STR_FILESFIRST
],sbFileF
),
263 PM_Exclude
, PM_ExLst(sbMix
,sbDirF
,0),
267 PMInfo(globstring
[STR_NAMESORT_MENU
]),
270 PMCheckItem(globstring
[STR_SORTALPHA
],sbSortA
),
271 PM_Exclude
, PM_ExLst(sbSortD
,sbSortH
,0),
273 PMCheckItem(globstring
[STR_SORTDEC
],sbSortD
),
274 PM_Exclude
, PM_ExLst(sbSortA
,sbSortH
,0),
276 PMCheckItem(globstring
[STR_SORTHEX
],sbSortH
),
277 PM_Exclude
, PM_ExLst(sbSortA
,sbSortD
,0),
281 PMCheckItem(globstring
[STR_SIZE_AS_KMG
],sbKMG
),