update self.items and self.current after file deletion

This commit is contained in:
Qingping Hou
2012-06-09 18:10:05 +08:00
parent 9b263ca23a
commit ad7a8d044c

View File

@@ -200,6 +200,7 @@ function FileChooser:choose(ypos, height)
if i <= #self.dirs then
DrawFileItem(self.dirs[i],self.margin_H,ypos+self.title_H+self.spacing*c,"folder")
elseif i <= self.items then
print("-----", self.files[i-#self.dirs])
local file_type = string.lower(string.match(self.files[i-#self.dirs], ".+%.([^.]+)") or "")
DrawFileItem(self.files[i-#self.dirs],self.margin_H,ypos+self.title_H+self.spacing*c,file_type)
end
@@ -370,6 +371,8 @@ function FileChooser:addAllCommands()
if lfs.rmdir(self.path.."/"..folder) then
self.pagedirty = true
table.remove(self.dirs, offset)
self.items = self.items - 1
self.current = self.current - 1
else
showInfoMsgWithDelay("This folder can not be deleted! ",2000,1)
end
@@ -385,6 +388,8 @@ function FileChooser:addAllCommands()
os.remove(DocToHistory(fullpath))
-- to avoid showing just deleted file
table.remove(self.files, pos)
self.items = self.items - 1
self.current = self.current - 1
self.pagedirty = true
end
end -- if folder == ".."