summary refs log tree commit diff stats
path: root/doc/pydoc/ranger.container.keybuffer.html
blob: 5ebc033a9fdef3d5cc6e9c370f6c17a103efded0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module ranger.container.keybuffer</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="ranger.html"><font color="#ffffff">ranger</font></a>.<a href="ranger.container.html"><font color="#ffffff">container</font></a>.keybuffer</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/ranger/ranger/container/keybuffer.py">/home/hut/ranger/ranger/container/keybuffer.py</a></font></td></tr></table>
    <p><tt>#&nbsp;Copyright&nbsp;(C)&nbsp;2009,&nbsp;2010&nbsp;&nbsp;Roman&nbsp;Zimbelmann&nbsp;&lt;romanz@lavabit.com&gt;<br>
#<br>
#&nbsp;This&nbsp;program&nbsp;is&nbsp;free&nbsp;software:&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or&nbsp;modify<br>
#&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;as&nbsp;published&nbsp;by<br>
#&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation,&nbsp;either&nbsp;version&nbsp;3&nbsp;of&nbsp;the&nbsp;License,&nbsp;or<br>
#&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version.<br>
#<br>
#&nbsp;This&nbsp;program&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,<br>
#&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of<br>
#&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the<br>
#&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.<br>
#<br>
#&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License<br>
#&nbsp;along&nbsp;with&nbsp;this&nbsp;program.&nbsp;&nbsp;If&nbsp;not,&nbsp;see&nbsp;&lt;<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>&gt;.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.container.keybuffer.html#KeyBuffer">KeyBuffer</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="KeyBuffer">class <strong>KeyBuffer</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="KeyBuffer-__init__"><strong>__init__</strong></a>(self)</dt></dl>

<dl><dt><a name="KeyBuffer-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>returns&nbsp;a&nbsp;concatenation&nbsp;of&nbsp;all&nbsp;characters</tt></dd></dl>

<dl><dt><a name="KeyBuffer-append"><strong>append</strong></a>(self, key)</dt><dd><tt>Append&nbsp;a&nbsp;key&nbsp;to&nbsp;the&nbsp;keybuffer,&nbsp;or&nbsp;initial&nbsp;numbers&nbsp;to<br>
the&nbsp;number&nbsp;attribute.</tt></dd></dl>

<dl><dt><a name="KeyBuffer-clear"><strong>clear</strong></a>(self)</dt><dd><tt>Clear&nbsp;the&nbsp;keybuffer&nbsp;and&nbsp;restore&nbsp;the&nbsp;initial&nbsp;state</tt></dd></dl>

<dl><dt><a name="KeyBuffer-tuple_with_numbers"><strong>tuple_with_numbers</strong></a>(self)</dt><dd><tt>Get&nbsp;a&nbsp;tuple&nbsp;of&nbsp;ascii&nbsp;codes.</tt></dd></dl>

<dl><dt><a name="KeyBuffer-tuple_without_numbers"><strong>tuple_without_numbers</strong></a>(self)</dt><dd><tt>Get&nbsp;a&nbsp;tuple&nbsp;of&nbsp;ascii&nbsp;codes.<br>
If&nbsp;the&nbsp;keybuffer&nbsp;starts&nbsp;with&nbsp;numbers,&nbsp;those&nbsp;will<br>
be&nbsp;left&nbsp;out.&nbsp;To&nbsp;access&nbsp;them,&nbsp;use&nbsp;keybuffer.number</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-to_string"><strong>to_string</strong></a>(i)</dt></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>NINE</strong> = 57<br>
<strong>ZERO</strong> = 48</td></tr></table>
</body></html>
d_redraw = True if self.need_redraw: self._draw_hint() return if self.old_hint and not self.hint: self.old_hint = None self.need_redraw = True if self.msg: if self.msg.is_alive(): self._draw_message() return else: self.msg = None self.need_redraw = True if self.fm.thisfile: self.fm.thisfile.load_if_outdated() try: ctime = self.fm.thisfile.stat.st_ctime except: ctime = -1 else: ctime = -1 if not self.result: self.need_redraw = True if self.old_du and not self.fm.thisdir.disk_usage: self.old_du = self.fm.thisdir.disk_usage self.need_redraw = True if self.old_thisfile != self.fm.thisfile: self.old_thisfile = self.fm.thisfile self.need_redraw = True if self.old_ctime != ctime: self.old_ctime = ctime self.need_redraw = True if self.need_redraw: self.need_redraw = False self._calc_bar() self._print_result(self.result) def _calc_bar(self): bar = Bar('in_statusbar') self._get_left_part(bar) self._get_right_part(bar) bar.shrink_by_removing(self.wid) self.result = bar.combine() def _draw_message(self): self.win.erase() self.color('in_statusbar', 'message', self.msg.bad and 'bad' or 'good') self.addnstr(0, 0, self.msg.text, self.wid) def _draw_hint(self): self.win.erase() highlight = True space_left = self.wid starting_point = self.x for string in self.hint.split('*'): highlight = not highlight if highlight: self.color('in_statusbar', 'text', 'highlight') else: self.color('in_statusbar', 'text') try: self.addnstr(0, starting_point, string, space_left) except: break space_left -= len(string) starting_point += len(string) def _get_left_part(self, bar): left = bar.left if self.column is not None and self.column.target is not None\ and self.column.target.is_directory: target = self.column.target.pointed_obj else: directory = self.fm.thistab.at_level(0) if directory: target = directory.pointed_obj else: return try: stat = target.stat except: return if stat is None: return if self.fm.mode != 'normal': perms = '--%s--' % self.fm.mode.upper() else: perms = target.get_permission_string() how = getuid() == stat.st_uid and 'good' or 'bad' left.add(perms, 'permissions', how) left.add_space() left.add(str(stat.st_nlink), 'nlink') left.add_space() left.add(self._get_owner(target), 'owner') left.add_space() left.add(self._get_group(target), 'group') if target.is_link: how = target.exists and 'good' or 'bad' try: dest = readlink(target.path) except: dest = '?' left.add(' -> ' + dest, 'link', how) else: left.add_space() if self.settings.display_size_in_status_bar and target.infostring: left.add(target.infostring.replace(" ", "")) left.add_space() left.add(strftime(self.timeformat, localtime(stat.st_mtime)), 'mtime') if target.vcs: if target.vcsbranch: vcsinfo = '(%s: %s)' % (target.vcs.vcsname, target.vcsbranch) else: vcsinfo = '(%s)' % (target.vcs.vcsname) left.add_space() left.add(vcsinfo, 'vcsinfo') if target.vcsfilestatus: left.add_space() vcsstr, vcscol = self.vcsfilestatus_symb[target.vcsfilestatus] left.add(vcsstr.strip(), 'vcsfile', *vcscol) if target.vcsremotestatus: vcsstr, vcscol = self.vcsremotestatus_symb[target.vcsremotestatus] left.add(vcsstr.strip(), 'vcsremote', *vcscol) if target.vcshead: left.add_space() left.add('%s' % target.vcshead['summary'], 'vcscommit') def _get_owner(self, target): uid = target.stat.st_uid try: return self.owners[uid] except KeyError: try: self.owners[uid] = getpwuid(uid)[0] return self.owners[uid] except KeyError: return str(uid) def _get_group(self, target): gid = target.stat.st_gid try: return self.groups[gid] except KeyError: try: self.groups[gid] = getgrgid(gid)[0] return self.groups[gid] except KeyError: return str(gid) def _get_right_part(self, bar): right = bar.right if self.column is None: return target = self.column.target if target is None \ or not target.accessible \ or (target.is_directory and target.files is None): return pos = target.scroll_begin max_pos = len(target) - self.column.hei base = 'scroll' if self.fm.thisdir.filter: right.add(" f=", base, 'filter') right.add(repr(self.fm.thisdir.filter), base, 'filter') right.add(", ", "space") if target.marked_items: if len(target.marked_items) == len(target.files): right.add(human_readable(target.disk_usage, separator='')) else: sumsize = sum(f.size for f in target.marked_items if not f.is_directory or f._cumulative_size_calculated) right.add(human_readable(sumsize, separator='')) right.add("/" + str(len(target.marked_items))) else: right.add(human_readable(target.disk_usage, separator='') + " sum") try: free = get_free_space(target.mount_path) except OSError: pass else: right.add(", ", "space") right.add(human_readable(free, separator='') + " free") right.add(" ", "space") if target.marked_items: # Indicate that there are marked files. Useful if you scroll # away and don't see them anymore. right.add('Mrk', base, 'marked') elif len(target.files): right.add(str(target.pointer + 1) + '/' + str(len(target.files)) + ' ', base) if max_pos <= 0: right.add('All', base, 'all') elif pos == 0: right.add('Top', base, 'top') elif pos >= max_pos: right.add('Bot', base, 'bot') else: right.add('{0:0>.0f}%'.format(100.0 * pos / max_pos), base, 'percentage') else: right.add('0/0 All', base, 'all') def _print_result(self, result): self.win.move(0, 0) for part in result: self.color(*part.lst) self.addstr(str(part)) if self.settings.draw_progress_bar_in_status_bar: queue = self.fm.loader.queue states = [] for item in queue: if item.progressbar_supported: states.append(item.percent) if states: state = sum(states) / len(states) barwidth = state / 100.0 * self.wid self.color_at(0, 0, int(barwidth), ("in_statusbar", "loaded")) self.color_reset() def get_free_space(path): stat = os.statvfs(path) return stat.f_bavail * stat.f_bsize class Message(object): elapse = None text = None bad = False def __init__(self, text, duration, bad): self.text = text self.bad = bad self.elapse = time() + duration def is_alive(self): return time() <= self.elapse