improved some mode.dir method names
--HG-- branch : pmacs2
This commit is contained in:
parent
a4475951e7
commit
4718ba3003
37
mode/dir.py
37
mode/dir.py
|
@ -59,13 +59,13 @@ class SortName(FsSettingBase):
|
||||||
msg = "Sorting files by name, type"
|
msg = "Sorting files by name, type"
|
||||||
def _doit(self, w, **vargs): w.buffer.settings['type-sort'] = False
|
def _doit(self, w, **vargs): w.buffer.settings['type-sort'] = False
|
||||||
|
|
||||||
class RefreshView(Method):
|
class DirRefresh(Method):
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
t = dirutil.resolve_token(w)
|
t = dirutil.resolve_token(w)
|
||||||
s = t.string
|
s = t.string
|
||||||
w.buffer.reload()
|
w.buffer.reload()
|
||||||
dirutil.find_name(w, s)
|
dirutil.find_name(w, s)
|
||||||
class OpenPath(Method):
|
class DirOpen(Method):
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
path = dirutil.resolve_path(w)
|
path = dirutil.resolve_path(w)
|
||||||
w.set_error("opening %r" % path)
|
w.set_error("opening %r" % path)
|
||||||
|
@ -104,7 +104,7 @@ class DirCmd(Method):
|
||||||
w.set_error("%s failed (exit %d)" % (self.name, status))
|
w.set_error("%s failed (exit %d)" % (self.name, status))
|
||||||
dirutil.find_name(w, basename)
|
dirutil.find_name(w, basename)
|
||||||
|
|
||||||
class Chmod(DirCmd):
|
class DirChmod(DirCmd):
|
||||||
args = [Argument('mode', type=type(''), prompt="New Mode: ")]
|
args = [Argument('mode', type=type(''), prompt="New Mode: ")]
|
||||||
octal_re = re.compile('^[0-7]{1,4}$')
|
octal_re = re.compile('^[0-7]{1,4}$')
|
||||||
symbolic_re = re.compile('(?:[ugoa]*(?:[-+=](?:[rwxXst]*|[ugo]))+ *,?)+')
|
symbolic_re = re.compile('(?:[ugoa]*(?:[-+=](?:[rwxXst]*|[ugo]))+ *,?)+')
|
||||||
|
@ -118,7 +118,7 @@ class Chmod(DirCmd):
|
||||||
else:
|
else:
|
||||||
w.set_error("Not a valid mode: %r" % vargs['mode'])
|
w.set_error("Not a valid mode: %r" % vargs['mode'])
|
||||||
self._run(w, **vargs)
|
self._run(w, **vargs)
|
||||||
class Chown(DirCmd):
|
class DirChown(DirCmd):
|
||||||
args = [Argument('owner', type=type(''), prompt="New Owner: ")]
|
args = [Argument('owner', type=type(''), prompt="New Owner: ")]
|
||||||
def _make_cmd(self, w, path, **vargs):
|
def _make_cmd(self, w, path, **vargs):
|
||||||
return 'chown %r %r' % (vargs['owner'], path)
|
return 'chown %r %r' % (vargs['owner'], path)
|
||||||
|
@ -138,7 +138,7 @@ class Chown(DirCmd):
|
||||||
w.set_error('Group %r does not exist' % group)
|
w.set_error('Group %r does not exist' % group)
|
||||||
return
|
return
|
||||||
self._run(w, **vargs)
|
self._run(w, **vargs)
|
||||||
class Chgrp(DirCmd):
|
class DirChgrp(DirCmd):
|
||||||
args = [Argument('group', type=type(''), prompt="New Group: ")]
|
args = [Argument('group', type=type(''), prompt="New Group: ")]
|
||||||
def _make_cmd(self, w, path, **vargs):
|
def _make_cmd(self, w, path, **vargs):
|
||||||
return 'chgrp %r %r' % (vargs['group'], path)
|
return 'chgrp %r %r' % (vargs['group'], path)
|
||||||
|
@ -148,17 +148,17 @@ class Chgrp(DirCmd):
|
||||||
return
|
return
|
||||||
self._run(w, **vargs)
|
self._run(w, **vargs)
|
||||||
|
|
||||||
class TouchPath(Method):
|
class DirTouch(Method):
|
||||||
args = [Argument('filename', datatype="path", prompt="Touch File: ")]
|
args = [Argument('filename', datatype="path", prompt="Touch File: ")]
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
basename = vargs['filename']
|
basename = vargs['filename']
|
||||||
path = os.path.join(w.buffer.path, basename)
|
path = os.path.join(w.buffer.path, basename)
|
||||||
retval = os.system('touch %r' % path)
|
retval = os.system('touch %r' % path)
|
||||||
w.application.methods['refresh-view'].execute(w, filename=path)
|
w.application.methods['dir-refresh'].execute(w, filename=path)
|
||||||
dirutil.find_name(w, basename)
|
dirutil.find_name(w, basename)
|
||||||
if retval != 0:
|
if retval != 0:
|
||||||
w.set_error("touch %r failed (exit %d)" % (path, retval))
|
w.set_error("touch %r failed (exit %d)" % (path, retval))
|
||||||
class RemovePath(Method):
|
class DirRemove(Method):
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
self._old_window = w
|
self._old_window = w
|
||||||
self._old_path = dirutil.resolve_path(w)
|
self._old_path = dirutil.resolve_path(w)
|
||||||
|
@ -183,7 +183,7 @@ class RemovePath(Method):
|
||||||
w.application.methods['previous-line'].execute(w)
|
w.application.methods['previous-line'].execute(w)
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
w.set_error("deleted %r " % path)
|
w.set_error("deleted %r " % path)
|
||||||
w.application.methods['refresh-view'].execute(w, filename=path)
|
w.application.methods['dir-refresh'].execute(w, filename=path)
|
||||||
except:
|
except:
|
||||||
w.set_error("failed to delete %r" % path)
|
w.set_error("failed to delete %r" % path)
|
||||||
|
|
||||||
|
@ -217,17 +217,18 @@ class Dir(mode.Fundamental):
|
||||||
'dir_size': ('yellow', 'default', 'bold'),
|
'dir_size': ('yellow', 'default', 'bold'),
|
||||||
'dir_mtime': ('green', 'default', 'bold'),
|
'dir_mtime': ('green', 'default', 'bold'),
|
||||||
}
|
}
|
||||||
actions = [RefreshView, OpenPath, DirGrep, Chmod, Chown, Chgrp, TouchPath,
|
actions = [DirRefresh, DirOpen, DirGrep, DirChmod, DirChown, DirChgrp,
|
||||||
RemovePath, HideDotFiles, ShowDotFiles, SortName, SortType]
|
DirTouch, DirRemove, HideDotFiles, ShowDotFiles, SortName,
|
||||||
|
SortType]
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
self.add_bindings('refresh-view', ('C-c r',))
|
self.add_bindings('dir-refresh', ('C-c r',))
|
||||||
self.add_bindings('open-path', ('RETURN',))
|
self.add_bindings('dir-open', ('RETURN',))
|
||||||
self.add_bindings('dir-grep', ('C-c G',))
|
self.add_bindings('dir-grep', ('C-c G',))
|
||||||
self.add_bindings('chmod', ('C-c m',))
|
self.add_bindings('dir-chmod', ('C-c m',))
|
||||||
self.add_bindings('chown', ('C-c o',))
|
self.add_bindings('dir-chown', ('C-c o',))
|
||||||
self.add_bindings('chgrp', ('C-c g',))
|
self.add_bindings('dir-chgrp', ('C-c g',))
|
||||||
self.add_bindings('touch-path', ('C-c t',))
|
self.add_bindings('dir-touch', ('C-c t',))
|
||||||
self.add_bindings('remove-path', ('DELETE', 'BACKSPACE', 'C-d'))
|
self.add_bindings('dir-remove', ('DELETE', 'BACKSPACE', 'C-d'))
|
||||||
|
|
||||||
install = Dir.install
|
install = Dir.install
|
||||||
|
|
Loading…
Reference in New Issue