summary refs log tree commit diff stats
path: root/doc/pydoc/ranger.ext.human_readable.html
blob: a4d71ea912ae8b63ee772c2fd5c12c3d8326706a (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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module ranger.ext.human_readable</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.ext.html"><font color="#ffffff">ext</font></a>.human_readable</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/ext/human_readable.py">/home/hut/ranger/ranger/ext/human_readable.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="#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="-human_readable"><strong>human_readable</strong></a>(byte, seperator<font color="#909090">=' '</font>)</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>MAX_EXPONENT</strong> = 5<br>
<strong>ONE_KB</strong> = 1024<br>
<strong>UNITS</strong> = 'BKMGTP'</td></tr></table>
</body></html>
>('f'), fm.move(down=1, pages=True)) map(KEY_PPAGE, ctrl('b'), fm.move(up=1, pages=True)) map(ctrl('d'), 'J', fm.move(down=0.5, pages=True)) map(ctrl('u'), 'K', fm.move(up=0.5, pages=True)) map(']', fm.traverse()) map('[', fm.history_go(-1)) # --------------------------------------------------------- history map('H', fm.history_go(-1)) map('L', fm.history_go(1)) # ----------------------------------------------- tagging / marking map('t', fm.tag_toggle()) map('T', fm.tag_remove()) map(' ', fm.mark(toggle=True)) map('v', fm.mark(all=True, toggle=True)) map('V', fm.mark(all=True, val=False)) # ------------------------------------------ file system operations map('yy', fm.copy()) map('dd', fm.cut()) map('pp', fm.paste()) map('po', fm.paste(overwrite=True)) map('pl', fm.paste_symlink()) map('p', hint='press //p// once again to confirm pasting' \ ', or //l// to create symlinks') # ---------------------------------------------------- run programs map('s', fm.execute_command(os.environ['SHELL'])) map('E', fm.edit_file()) map(',term', fm.execute_command('x-terminal-emulator', flags='d')) map('du', fm.execute_command('du --max-depth=1 -h | less')) # -------------------------------------------------- toggle options map('b', fm.notify('Warning: settings are now changed with z!', bad=True)) map('z', hint="show_//h//idden //p//review_files //d//irectories_first " \ "//c//ollapse_preview flush//i//nput ca//s//e_insensitive") map('zh', fm.toggle_boolean_option('show_hidden')) map('zp', fm.toggle_boolean_option('preview_files')) map('zP', fm.toggle_boolean_option('preview_directories')) map('zi', fm.toggle_boolean_option('flushinput')) map('zd', fm.toggle_boolean_option('sort_directories_first')) map('zc', fm.toggle_boolean_option('collapse_preview')) map('zs', fm.toggle_boolean_option('sort_case_insensitive')) # ------------------------------------------------------------ sort map('o', 'O', hint="//s//ize //b//ase//n//ame //m//time //t//ype //r//everse") sort_dict = { 's': 'size', 'b': 'basename', 'n': 'basename', 'm': 'mtime', 't': 'type', } for key, val in sort_dict.items(): for key, is_capital in ((key, False), (key.upper(), True)): # reverse if any of the two letters is capital map('o' + key, fm.sort(func=val, reverse=is_capital)) map('O' + key, fm.sort(func=val, reverse=True)) map('or', 'Or', 'oR', 'OR', lambda arg: \ arg.fm.sort(reverse=not arg.fm.settings.sort_reverse)) # ----------------------------------------------- console shortcuts @map("A") def append_to_filename(arg): command = 'rename ' + arg.fm.env.cf.basename arg.fm.open_console(cmode.COMMAND, command) map('cw', fm.open_console(cmode.COMMAND, 'rename ')) map('cd', fm.open_console(cmode.COMMAND, 'cd ')) map('f', fm.open_console(cmode.COMMAND_QUICK, 'find ')) map('tf', fm.open_console(cmode.COMMAND, 'filter ')) map('d', hint='d//u// (disk usage) d//d// (cut)') map('@', fm.open_console(cmode.OPEN, '@')) map('#', fm.open_console(cmode.OPEN, 'p!')) # --------------------------------------------- jump to directories map('gh', fm.cd('~')) map('ge', fm.cd('/etc')) map('gu', fm.cd('/usr')) map('gd', fm.cd('/dev')) map('gl', fm.cd('/lib')) map('go', fm.cd('/opt')) map('gv', fm.cd('/var')) map('gr', 'g/', fm.cd('/')) map('gm', fm.cd('/media')) map('gn', fm.cd('/mnt')) map('gt', fm.cd('/tmp')) map('gs', fm.cd('/srv')) map('gR', fm.cd(RANGERDIR)) # ------------------------------------------------------------ tabs map('gc', ctrl('W'), fm.tab_close()) map('gt', TAB, fm.tab_move(1)) map('gT', KEY_BTAB, fm.tab_move(-1)) map('gn', ctrl('N'), fm.tab_new()) for n in range(10): map('g' + str(n), fm.tab_open(n)) # ------------------------------------------------------- searching map('/', fm.open_console(cmode.SEARCH)) map('n', fm.search()) map('N', fm.search(forward=False)) map('ct', fm.search(order='tag')) map('cc', fm.search(order='ctime')) map('cm', fm.search(order='mimetype')) map('cs', fm.search(order='size')) map('c', hint='//c//time //m//imetype //s//ize //t//agged') # ------------------------------------------------------- bookmarks for key in ALLOWED_BOOKMARK_KEYS: map("`" + key, "'" + key, fm.enter_bookmark(key)) map("m" + key, fm.set_bookmark(key)) map("um" + key, fm.unset_bookmark(key)) map("`", "'", "m", "um", draw_bookmarks=True) # ---------------------------------------------------- change views map('i', fm.display_file()) map(ctrl('p'), fm.display_log()) map('?', KEY_F1, fm.display_help()) map('w', lambda arg: arg.fm.ui.open_taskview()) # ------------------------------------------------ system functions _system_functions(map) map('ZZ', 'ZQ', fm.exit()) map(ctrl('R'), fm.reset()) map('R', fm.reload_cwd()) @map(ctrl('C')) def ctrl_c(arg): try: item = arg.fm.loader.queue[0] except: arg.fm.notify("Type Q or :quit<Enter> to exit Ranger") else: arg.fm.notify("Aborting: " + item.get_description()) arg.fm.loader.remove(index=0) map(':', ';', fm.open_console(cmode.COMMAND)) map('>', fm.open_console(cmode.COMMAND_QUICK)) map('!', fm.open_console(cmode.OPEN)) map('r', fm.open_console(cmode.OPEN_QUICK)) map.rebuild_paths() def initialize_console_commands(map): """Initialize the commands for the console widget only""" _basic_movement(map) _emacs_aliases(map) # -------------------------------------------------------- movement map(KEY_UP, wdg.history_move(-1)) map(KEY_DOWN, wdg.history_move(1)) map(KEY_HOME, wdg.move(right=0, absolute=True)) map(KEY_END, wdg.move(right=-1, absolute=True)) # ----------------------------------------- deleting / pasting text map(KEY_DC, wdg.delete(0)) map(KEY_BACKSPACE, DEL, wdg.delete(-1)) map(ctrl('w'), wdg.delete_word()) map(ctrl('k'), wdg.delete_rest(1)) map(ctrl('u'), wdg.delete_rest(-1)) map(ctrl('y'), wdg.paste()) # ------------------------------------------------ system functions map(KEY_F1, lambda arg: arg.fm.display_command_help(arg.wdg)) map(ctrl('c'), ESC, wdg.close()) map(ctrl('j'), KEY_ENTER, wdg.execute()) map(TAB, wdg.tab()) map(KEY_BTAB, wdg.tab(-1)) map.rebuild_paths() def initialize_taskview_commands(map): """Initialize the commands for the TaskView widget""" _basic_movement(map) _vimlike_aliases(map) _system_functions(map) # -------------------------------------------------- (re)move tasks map('K', wdg.task_move(0)) map('J', wdg.task_move(-1)) map('dd', wdg.task_remove()) # ------------------------------------------------ system functions map('?', fm.display_help()) map('w', 'q', ESC, ctrl('d'), ctrl('c'), lambda arg: arg.fm.ui.close_taskview()) map.rebuild_paths() def initialize_pager_commands(map): _base_pager_commands(map) map('q', 'i', ESC, KEY_F1, lambda arg: arg.fm.ui.close_pager()) map.rebuild_paths() def initialize_embedded_pager_commands(map): _base_pager_commands(map) map('q', 'i', ESC, lambda arg: arg.fm.ui.close_embedded_pager()) map.rebuild_paths() def _base_pager_commands(map): _basic_movement(map) _vimlike_aliases(map) _system_functions(map) # -------------------------------------------------------- movement map(KEY_LEFT, wdg.move(left=4)) map(KEY_RIGHT, wdg.move(right=4)) map(KEY_NPAGE, ctrl('f'), wdg.move(down=1, pages=True)) map(KEY_PPAGE, ctrl('b'), wdg.move(up=1, pages=True)) map(ctrl('d'), wdg.move(down=0.5, pages=True)) map(ctrl('u'), wdg.move(up=0.5, pages=True)) map(' ', wdg.move(down=0.8, pages=True)) # ---------------------------------------------------------- others map('E', fm.edit_file()) map('?', fm.display_help()) # --------------------------------------------- less-like shortcuts map.alias(KEY_NPAGE, 'f') map.alias(KEY_PPAGE, 'b') map.alias(ctrl('d'), 'd') map.alias(ctrl('u'), 'u') def _system_functions(map): map('Q', fm.exit()) map(ctrl('L'), fm.redraw_window()) def _basic_movement(map): map(KEY_DOWN, wdg.move(down=1)) map(KEY_UP, wdg.move(up=1)) map(KEY_RIGHT, wdg.move(right=1)) map(KEY_LEFT, wdg.move(left=1)) map(KEY_HOME, wdg.move(to=0)) map(KEY_END, wdg.move(to=-1))