📄 filesel.asm
字号:
;
;Check for type list DOWN button.
;
cmp eax,dFILE_TYPEDOWN
jz typedown
;
;Check for drive list UP button.
;
cmp eax,dFILE_DRIVEUP
jz driveup
;
;Check for drive list DOWN button.
;
cmp eax,dFILE_DRIVEDOWN
jz drivedown
;
;Selection was invalid for some reason so go back to waiting.
;
@@wl2_1: jmp waitloop
;
;File or directory selected so deal with it.
;
fileordir: mov esi,offset dFileSelector ;need file list y co-ord so we
mov ecx,dFILE_FILES ;can try and work out which file
call DialogGetButtonY ;is being selected.
sub eax,_FS_mousewiny ;get button relative y position.
neg eax
xor edx,edx ;use current font depth to work
div FontDepth ;out which entry it is.
add eax,_FS_FirstFile ;make sure start point is taken account of.
cmp eax,_FS_TotalFiles ;beyond the end of the list?
jnc @@fod0
mov ebx,14 ;length of each entry in the list.
mul ebx
add eax,256+4 ;move past count and path.
mov edi,eax
add edi,_FS_FileList ;offset into file list.
;
;check for selecting a directory.
;
test b[edi+13],16 ;dir attribute set?
jz @@fod1
push edi
@@fod2: call _FS_ReadInput ;wait for user to let go of the
cmp _FS_mouseb,0 ;mouse button.
jnz @@fod2
pop edi
mov esi,offset _FS_currentpath ;need to find the end of the
@@fod3: lodsb ;current path string.
or al,al
jnz @@fod3
dec esi ;check for adding to just a drive
cmp b[esi-2],":" ;spec.
jnz @@fod4
dec esi ;bodge it so \ falls in the right place.
@@fod4: mov b[esi],"\"
mov b[esi+1],0
mov esi,edi ;now add selected dir to end of
mov edi,offset _FS_currentpath ;current path.
call AppendString
test flags,2
jnz @@fod99
mov b[_FS_typedname],0
mov b[_FS_typedname+13],0
mov _FS_TypedTotal,0
mov _FS_FirstTyped,0
mov _FS_TypedFocus,0
@@fod99: mov _FS_drawstate,2+4+8192
mov _FS_FirstFile,0
jmp restartloop
;
;must be selecting a file so see what we want to do with it.
;
@@fod1: test _FS_mouseb,8 ;Double click?
jnz okexit
;
test flags,1 ;check if multiple selections
jz @@fod10 ;are allowed.
movzx eax,_FS_KeyFlags ;if shift key is down we don't
and eax,SK_SHIFTL+SK_SHIFTR ;want to clear current selections.
jz @@fod5
;
;Shift key is down so add this file.
;
mov b[_FS_typedname],0 ;can't have a typed name while
mov b[_FS_typedname+13],0 ;multiple selections are in
mov _FS_FirstTyped,0 ;action.
mov _FS_TypedFocus,0
mov _FS_TypedTotal,0
xor b[edi+13],128 ;mark selected file.
mov _FS_drawstate,4+8192
@@fod6: call _FS_ReadInput ;now wait for user to relase
cmp _FS_mouseb,0 ;the mouse button.
jnz @@fod6
jmp drawloop
;
;See if CTRL or ALT is being held down.
;
@@fod5: movzx eax,_FS_KeyFlags ;if shift key is down we don't
and eax,SK_CTRL+SK_ALT ;want to clear current selections.
jz @@fod10
mov b[_FS_typedname],0 ;can't have a typed name while
mov b[_FS_typedname+13],0 ;multiple selections are in
mov _FS_FirstTyped,0 ;action.
mov _FS_TypedFocus,0
mov _FS_TypedTotal,0
;
mov esi,_FS_FileList
add esi,4+256
@@fod12: test b[edi+13],128
jnz @@fod13
test b[edi+13],16
jnz @@fod12_0
or b[edi+13],128 ;set selected file.
@@fod12_0: sub edi,14
cmp edi,esi
jnc @@fod12
@@fod13: ;
mov _FS_drawstate,4+8192
@@fod11: call _FS_ReadInput ;now wait for user to relase
cmp _FS_mouseb,0 ;the mouse button.
jnz @@fod11
jmp drawloop
;
;No shift key so clear out previous settings.
;
@@fod10: mov esi,_FS_FileList ;point to file list.
mov ecx,[esi] ;get number of entries.
add esi,4+256 ;skip count and path.
@@fod7: and b[esi+13],63 ;clear attributes.
add esi,14
loop @@fod7
or b[edi+13],128 ;mark current selection.
mov esi,edi
mov edi,offset _FS_typedname ;make sure typed name gets a
call CopyString ;copy of this.
mov al,[esi+13]
mov b[_FS_typedname+13],al ;copy attributes.
mov esi,offset _FS_typedname
call LenString
mov _FS_TypedTotal,eax ;need to know how long it is.
mov _FS_FirstTyped,0
mov _FS_TypedFocus,0
mov _FS_drawstate,4+8192
@@fod9: call _FS_ReadInput ;wait for user to release mouse
cmp _FS_mouseb,0 ;button.
jnz @@fod9
jmp drawloop
;
;Not valid for this section so ignore it.
;
@@fod0: call _FS_ReadInput ;wait for user to release mouse
cmp _FS_mouseb,0 ;button.
jnz @@fod0
jmp waitloop
;
;TYPED name is selected so make it the focus.
;
changetyped: call _FS_ReadInput ;wait for user to let go of mouse
cmp _FS_mouseb,0 ;button.
jnz changetyped
test flags,2 ;typed name allowed?
jz waitloop
mov esi,_FS_FileList ;point to file list.
mov ecx,[esi] ;get number of entries.
add esi,4+256 ;skip count and path.
jecxz @@ct0_0
@@ct0: and b[esi+13],63 ;make sure all selections are
add esi,14 ;cleared while we're useing a
loop @@ct0 ;typed name.
@@ct0_0: ;
mov ecx,dFILE_FILES ;need typed name X co-ord so
mov esi,offset dFileSelector ;we can work out where the user
call DialogGetButtonX ;is selecting.
sub eax,_FS_mousewinx
neg eax
xor edx,edx ;use font width to work out the
div FontWidth ;character offset.
cmp eax,_FS_TypedTotal ;beyond length of typed name?
jc @@ct1
mov eax,_FS_TypedTotal ;force to end of string.
@@ct1: mov _FS_FirstTyped,eax ;store new position.
mov _FS_drawstate,8192 ;make sure we update cursor.
cmp _FS_TypedFocus,-1 ;already the focus?
jz @@ct2
or _FS_drawstate,4 ;make sure the file list gets
@@ct2: or _FS_TypedFocus,-1 ;a re-draw.
jmp drawloop
;
;Stuff being typed so add it to the typed name.
;
typedinput:
;
;See if its a normal alpha-numeric.
;
cmp _FS_KeyASCII,32+1 ;check for above space.
jc @@ti0
cmp _FS_KeyASCII,122+1 ;how about little z?
jnc @@ti0
cmp _FS_TypedTotal,12 ;too many characters typed?
jnc @@ti0
mov esi,offset _FS_typedname ;point to typed name buffer and
add esi,_FS_TypedTotal ;use current total to point to
mov edi,esi ;the end ready to copy everything
dec esi ;up a byte.
mov ecx,_FS_TypedTotal
sub ecx,_FS_FirstTyped
std
rep movsb ;move em all up.
cld
mov al,_FS_KeyASCII ;get the typed character again
stosb ;and store it in the buffer.
inc _FS_TypedTotal ;update length of name and current
inc _FS_FirstTyped ;cursor position.
mov _FS_drawstate,8192 ;make sure it gets a re-draw.
jmp drawloop
;
;See if its DEL.
;
@@ti0: cmp _FS_KeyASCII,0 ;check for an ASCII code.
jnz @@ti1
cmp _FS_KeyCode,83 ;check the hardware key code.
jnz @@ti1
mov eax,_FS_FirstTyped ;check we're not already at the
cmp eax,_FS_TypedTotal ;start of the buffer.
jz @@ti1
mov esi,offset _FS_typedname ;point to name buffer and use
add esi,_FS_FirstTyped ;current position to work out
mov edi,esi ;where we need to move everything
inc esi ;down from.
mov ecx,_FS_TypedTotal
sub ecx,_FS_FirstTyped
rep movsb ;copy it all down.
dec _FS_TypedTotal ;reduce length variable.
mov _FS_drawstate,8192 ;make sure it gets a re-draw.
jmp drawloop
;
;See if its BACKSPACE.
;
@@ti1: cmp _FS_KeyASCII,8 ;check for the right ASCII code.
jnz @@ti2
cmp _FS_FirstTyped,0 ;anything at the current position
jz @@ti2 ;to delete?
mov esi,offset _FS_typedname ;point to the buffer and use the
add esi,_FS_FirstTyped ;current cursor position to work
mov edi,esi ;out where we need to move
dec edi ;everything down from.
mov ecx,_FS_TypedTotal
sub ecx,_FS_FirstTyped
inc ecx
rep movsb ;move it all down.
dec _FS_TypedTotal ;reduce total character count and
dec _FS_FirstTyped ;cursor position.
mov _FS_drawstate,8192 ;make sure it gets a re-draw.
jmp drawloop
;
;See if its cursor left.
;
@@ti2: cmp _FS_KeyCode,75 ;cursor left key?
jnz @@ti3
cmp _FS_FirstTyped,0 ;already at left edge?
jz waitloop
dec _FS_FirstTyped ;update cursor position and make
mov _FS_drawstate,8192 ;sure it gets a re-draw.
jmp drawloop
;
;See if its cursor right.
;
@@ti3: cmp _FS_KeyCode,77 ;cursor right key?
jnz @@ti4
mov eax,_FS_FirstTyped ;check we're not already at the
cmp eax,_FS_TypedTotal ;right edge.
jnc waitloop
inc _FS_FirstTyped ;update cursor position and make
mov _FS_drawstate,8192 ;sure it gets a re-draw.
jmp drawloop
;
;Nothing we recognise.
;
@@ti4: jmp waitloop ;not a recognised key press.
;
;PATH is selected so move back a dir.
;
pathchange: call _FS_ReadInput ;wait for the user to relase
cmp _FS_mouseb,0 ;the mouse button.
jnz pathchange
mov esi,offset _FS_currentpath ;need to find the last section
@@pc0: lodsb ;of the current path string so
or al,al ;we can chop it off. Find end
jnz @@pc0 ;of the string first.
@@pc1: dec esi ;now work backwards in string and
cmp b[esi],"\" ;check for dir seperator.
jnz @@pc1
cmp b[esi-1],":" ;check for drive spec.
jnz @@pc2
inc esi
@@pc2: push esi
cmp b[esi-2],":"
jz @@pc3
inc esi
@@pc3: mov edi,offset _FS_CenterFile ;we're loseing into centering
call CopyString ;string.
pop esi
mov b[esi],0 ;lose last piece of path string.
test flags,2
jnz @@pc4
mov b[_FS_typedname],0 ;make sure typed name gets cleared
mov b[_FS_typedname+13],0 ;out and reset its variables.
mov _FS_TypedTotal,0
mov _FS_FirstTyped,0
@@pc4: mov _FS_drawstate,2+4+8192 ;make sure it gets a re-draw.
mov _FS_FirstFile,0
jmp restartloop
;
;TYPE is selected so set new type.
;
typechange: call _FS_ReadInput ;wait for the user to release
cmp _FS_mouseb,0 ;the mouse button.
jnz typechange
mov ecx,dFILE_TYPES ;need type list y co-ord so we
mov esi,offset dFileSelector ;can try and work out which entry
call DialogGetButtonY ;is being selected. Start off with
sub eax,_FS_mousewiny ;a pixel offset for now.
neg eax
xor edx,edx ;use font depth to work out the
div FontDepth ;entry number and make sure the
add eax,_FS_FirstMask ;selection isn't past the end of
cmp eax,_FS_TotalMasks ;the list.
jnc waitloop
cmp eax,_FS_CurrentMask ;same as we're already useing?
jz waitloop
mov _FS_CurrentMask,eax ;set new mask number.
mov _FS_drawstate,2+4+8+8192 ;make sure it gets a re-draw.
;
;Change typed names extension.
;
test flags,2
jz @@tc9
mov esi,offset _FS_TypedName
or edi,-1
@@tc0: mov al,[esi]
inc esi
cmp al,"."
jnz @@tc1
mov edi,esi
@@tc1: cmp al,"\"
jnz @@tc2
or edi,-1
@@tc2: or al,al
jnz @@tc0
cmp edi,-1 ;any extension?
jnz @@tc6
mov edi,esi
mov b[edi-1],"."
@@tc6: mov ecx,_FS_CurrentMask ;current top of list.
mov esi,maskptr ;the mask list.
jecxz @@tc4
@@tc3: lodsb
or al,al ;end of a mask yet?
jnz @@tc3
dec ecx ;got to the entry we want yet?
jnz @@tc3
@@tc4: lodsb
cmp al,"."
jnz @@tc4
cmp b[esi],"*" ;this an ALL job?
jz @@tc5
call CopyString
@@tc5: jmp restartloop
;
@@tc9: mov b[_FS_typedname],0 ;make sure the typed name is
mov b[_FS_typedname+13],0 ;cleared and doesn't have the
mov _FS_FirstTyped,0 ;focus anymore.
mov _FS_TypedFocus,0
mov _FS_TypedTotal,0
jmp restartloop
;
;DRIVE is selected so set new drive.
;
drivechange: call _FS_ReadInput ;wait for the user to let go
cmp _FS_mouseb,0 ;of the mouse button.
jnz drivechange
mov ecx,dFILE_DRIVES ;need drive list y co-ord so
mov esi,offset dFileSelector ;we can work out the pixel
call DialogGetButtonY ;offset into the list selected.
sub eax,_FS_mousewiny
neg eax
xor edx,edx ;use font depth to work out entry
div FontDepth ;number being selected and make
add eax,_FS_FirstDrive ;sure it's not beyonf the end of
cmp eax,_FS_TotalDrives ;the list.
jnc waitloop
cmp eax,_FS_CurrentDrive ;same as we're already useing?
jz waitloop
mov _FS_CurrentDrive,eax ;set new drive entry number
mov al,b[_FS_drivelist+eax*2]
sub al,"A"
call SetDrive ;let DOS know what we want.
mov edx,offset _FS_currentpath ;get path for selected drive.
call GetPath
mov _FS_drawstate,2+4+16+8192 ;make sure it gets a re-draw.
test flags,2
jnz @@drvc0
mov b[_FS_typedname],0
mov b[_FS_typedname+13],0 ;make sure typed file name is
mov _FS_FirstTyped,0 ;cleared and loses focus if it
mov _FS_TypedFocus,0 ;had it.
mov _FS_TypedTotal,0
@@drvc0: mov _FS_FirstFile,0
jmp restartloop
;
;Home key was pressed.
;
HomeKeyed: cmp _FS_FirstFile,0 ;check if we're already at the
jz waitloop ;top of the list.
mov _FS_FirstFile,0 ;move us to the top.
mov _FS_drawstate,4 ;and make sure it gets a re-draw.
jmp drawloop
;
;End key was pressed.
;
EndKeyed: mov eax,_FS_FirstFile ;see if we reached the end of the
add eax,10 ;file list yet.
cmp eax,_FS_TotalFiles
jnc waitloop
mov eax,_FS_TotalFiles
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -