diff options
author | hut <hut@lavabit.com> | 2009-12-10 01:37:14 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-12-10 01:37:14 +0100 |
commit | 871c502d58055c7611f0763eaa71a7fafad7efdc (patch) | |
tree | 0f0080aac9f8bdbee5a7d6ca9bf6bb0d4866ffb7 /ranger | |
parent | aea67778ad2366b4e4171008af7b0dcd5d91f93b (diff) | |
download | ranger-871c502d58055c7611f0763eaa71a7fafad7efdc.tar.gz |
Restructuration
Diffstat (limited to 'ranger')
35 files changed, 2812 insertions, 199 deletions
diff --git a/ranger/__init__.py b/ranger/__init__.py index d2716895..f5a1c480 100644 --- a/ranger/__init__.py +++ b/ranger/__init__.py @@ -6,3 +6,25 @@ rangerdir = os.path.dirname(__file__) sys.path.append(confdir) + +def relpath(*args): + return os.path.join(rangerdir, *args) + +LOGFILE = '/tmp/errorlog' + +def log(txt): + f = open(LOGFILE, 'a') + f.write("r1: ") + f.write(str(txt)) + f.write("\n") + f.close() + +# used to get all colorschemes in ~/.ranger/colorschemes +# and ranger/colorschemes +def get_all(dirname): + import os + result = [] + for filename in os.listdir(dirname): + if filename.endswith('.py') and not filename.startswith('_'): + result.append(filename[0:filename.index('.')]) + return result diff --git a/ranger/applications.py b/ranger/applications.py index fd977c43..ca934920 100644 --- a/ranger/applications.py +++ b/ranger/applications.py @@ -13,3 +13,43 @@ class Applications(object): def all(self): return [x for x in self.__dict__ if x.startswith('app_')] +import os +null = open(os.devnull, 'a') + +def run(*args, **kw): + from subprocess import Popen + from subprocess import PIPE + from ranger.ext import waitpid_no_intr + + flags, fm = kw['flags'], kw['fm'] + for flag in flags: + if ord(flag) <= 90: + bad = flag + flag.lower() + flags = ''.join(c for c in flags if c not in bad) + + args = map(str, args) + popen_kw = {} + + if kw['stdin'] is not None: + popen_kw['stdin'] = kw['stdin'] + + if 's' in flags or 'd' in flags: + popen_kw['stdout'] = popen_kw['stderr'] = popen_kw['stdin'] = null + + if 'p' in flags: + popen_kw['stdout'] = PIPE + process1 = Popen(args, **popen_kw) + kw['stdin'] = process1.stdout + kw['files'] = () + kw['flags'] = ''.join(f for f in kw['flags'] if f in 'd') + process2 = kw['apps'].app_pager(**kw) + return process2 + if 'd' in flags: + process = Popen(args, **popen_kw) + return process + else: + fm.ui.exit() + p = Popen(args, **popen_kw) + waitpid_no_intr(p.pid) + fm.ui.initialize() + return p diff --git a/ranger/colorschemes/__init__.py b/ranger/colorschemes/__init__.py index 6319fa96..2318ba27 100644 --- a/ranger/colorschemes/__init__.py +++ b/ranger/colorschemes/__init__.py @@ -1,4 +1,4 @@ -from ranger.helper import get_all, log +from ranger import get_all, log from os.path import expanduser, dirname, exists, join __all__ = get_all(dirname(__file__)) @@ -9,8 +9,8 @@ confpath = expanduser('~/.ranger') if exists(join(confpath, 'colorschemes')): initpy = join(confpath, 'colorschemes/__init__.py') if not exists(initpy): - open(initpy, 'w').write("""import ranger.helper, os.path -__all__ = ranger.helper.get_all( os.path.dirname( __file__ ) ) + open(initpy, 'w').write("""import ranger, os.path +__all__ = ranger.get_all( os.path.dirname( __file__ ) ) """) try: diff --git a/ranger/colorschemes/jungle.py b/ranger/colorschemes/jungle.py index 5f575238..eb70e5aa 100644 --- a/ranger/colorschemes/jungle.py +++ b/ranger/colorschemes/jungle.py @@ -47,4 +47,8 @@ class Default(ColorScheme): elif context.link: fg = cyan + elif context.keybuffer: + fg = yellow + attr = normal + return fg, bg, attr diff --git a/ranger/container/__init__.py b/ranger/container/__init__.py new file mode 100644 index 00000000..fe8228e9 --- /dev/null +++ b/ranger/container/__init__.py @@ -0,0 +1,4 @@ +from ranger.container.history import History +from ranger.container.keybuffer import KeyBuffer +from .commandlist import CommandList +from .bookmarks import Bookmarks diff --git a/ranger/bookmark.py b/ranger/container/bookmarks.py index da54e8eb..da54e8eb 100644 --- a/ranger/bookmark.py +++ b/ranger/container/bookmarks.py diff --git a/ranger/command.py b/ranger/container/commandlist.py index a252fea2..a252fea2 100644 --- a/ranger/command.py +++ b/ranger/container/commandlist.py diff --git a/ranger/history.py b/ranger/container/history.py index bd9a575f..bd9a575f 100644 --- a/ranger/history.py +++ b/ranger/container/history.py diff --git a/ranger/container/keybuffer.py b/ranger/container/keybuffer.py new file mode 100644 index 00000000..1f6471d8 --- /dev/null +++ b/ranger/container/keybuffer.py @@ -0,0 +1,9 @@ +class KeyBuffer(tuple): + def __str__(self): + return "".join( map( to_string, self ) ) + +def to_string(i): + try: + return chr(i) + except ValueError: + return '?' diff --git a/ranger/data/generate.py b/ranger/data/generate.py new file mode 100755 index 00000000..61309259 --- /dev/null +++ b/ranger/data/generate.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 +# coding=utf-8 + +protocol = 0 + +import sys, pickle + +table = {} +for line in open(len(sys.argv) > 1 and sys.argv[1] or "mime.types"): + if len(line) > 3 and line[0] != '#' and '\t' in line: + name, *extensions = line.split() + for ext in extensions: + table[ext] = name + +pickle.dump(table, open('mime.dat', 'wb'), protocol) + diff --git a/ranger/data/mime.dat b/ranger/data/mime.dat new file mode 100644 index 00000000..ddfca976 --- /dev/null +++ b/ranger/data/mime.dat @@ -0,0 +1,1752 @@ +(dp0 +Valc +p1 +Vchemical/x-alchemy +p2 +sVgf +p3 +Vapplication/x-tex-gf +p4 +sVmp4 +p5 +Vvideo/mp4 +p6 +sVmp2 +p7 +Vaudio/mpeg +p8 +sVmp3 +p9 +g8 +sVnwc +p10 +Vapplication/x-nwc +p11 +sVsct +p12 +Vtext/scriptlet +p13 +sVros +p14 +Vchemical/x-rosdal +p15 +sVmng +p16 +Vvideo/x-mng +p17 +sVwmz +p18 +Vapplication/x-ms-wmz +p19 +sVwmx +p20 +Vvideo/x-ms-wmx +p21 +sVgcd +p22 +Vtext/x-pcs-gcd +p23 +sVtr +p24 +Vapplication/x-troff +p25 +sVts +p26 +Vtext/texmacs +p27 +sVtm +p28 +g27 +sVtk +p29 +Vtext/x-tcl +p30 +sVwml +p31 +Vtext/vnd.wap.wml +p32 +sVwma +p33 +Vaudio/x-ms-wma +p34 +sVfchk +p35 +Vchemical/x-gaussian-checkpoint +p36 +sVwmd +p37 +Vapplication/x-ms-wmd +p38 +sVmpg +p39 +Vvideo/mpeg +p40 +sVcascii +p41 +Vchemical/x-cactvs-binary +p42 +sVmpe +p43 +g40 +sVsmi +p44 +Vapplication/smil +p45 +sVmpv +p46 +Vvideo/x-matroska +p47 +sVwsc +p48 +g13 +sVcml +p49 +Vchemical/x-cml +p50 +sVdif +p51 +Vvideo/dv +p52 +sVp +p53 +Vtext/x-pascal +p54 +sVpbm +p55 +Vimage/x-portable-bitmap +p56 +sVdir +p57 +Vapplication/x-director +p58 +sVhtc +p59 +Vtext/x-component +p60 +sVhta +p61 +Vapplication/hta +p62 +sVodp +p63 +Vapplication/vnd.oasis.opendocument.presentation +p64 +sVhtm +p65 +Vtext/html +p66 +sVnbp +p67 +Vapplication/mathematica +p68 +sVodt +p69 +Vapplication/vnd.oasis.opendocument.text +p70 +sVtex +p71 +Vtext/x-tex +p72 +sVodi +p73 +Vapplication/vnd.oasis.opendocument.image +p74 +sVodm +p75 +Vapplication/vnd.oasis.opendocument.text-master +p76 +sVoda +p77 +Vapplication/oda +p78 +sVodb +p79 +Vapplication/vnd.oasis.opendocument.database +p80 +sVodc +p81 +Vapplication/vnd.oasis.opendocument.chart +p82 +sVodf +p83 +Vapplication/vnd.oasis.opendocument.formula +p84 +sVodg +p85 +Vapplication/vnd.oasis.opendocument.graphics +p86 +sVgl +p87 +Vvideo/gl +p88 +sVrtx +p89 +Vtext/richtext +p90 +sVabw +p91 +Vapplication/x-abiword +p92 +sVoza +p93 +Vapplication/x-oz-application +p94 +sVasc +p95 +Vtext/plain +p96 +sVm3u +p97 +Vaudio/x-mpegurl +p98 +sVctx +p99 +Vchemical/x-ctx +p100 +sVcbin +p101 +g42 +sVrdf +p102 +Vapplication/rdf+xml +p103 +sVboo +p104 +Vtext/x-boo +p105 +sVm3g +p106 +Vapplication/m3g +p107 +sVmaker +p108 +Vapplication/x-maker +p109 +sVwmv +p110 +Vvideo/x-ms-wmv +p111 +sVsgl +p112 +Vapplication/vnd.stardivision.writer-global +p113 +sVbrf +p114 +g96 +sVtxt +p115 +g96 +sVwbmp +p116 +Vimage/vnd.wap.wbmp +p117 +sVsgf +p118 +Vapplication/x-go-sgf +p119 +sVzip +p120 +Vapplication/zip +p121 +sVepsf +p122 +Vapplication/postscript +p123 +sVchm +p124 +Vchemical/x-chemdraw +p125 +sVmsi +p126 +Vapplication/x-msi +p127 +sVmsh +p128 +Vmodel/mesh +p129 +sVjmz +p130 +Vapplication/x-jmol +p131 +sVwvx +p132 +Vvideo/x-ms-wvx +p133 +sVpfb +p134 +Vapplication/x-font +p135 +sVflv +p136 +Vvideo/x-flv +p137 +sVflac +p138 +Vaudio/flac +p139 +sVwbxml +p140 +Vapplication/vnd.wap.wbxml +p141 +sViii +p142 +Vapplication/x-iphone +p143 +sVme +p144 +Vapplication/x-troff-me +p145 +sVmm +p146 +Vapplication/x-freemind +p147 +sVuls +p148 +Vtext/iuls +p149 +sVcap +p150 +Vapplication/cap +p151 +sVcat +p152 +Vapplication/vnd.ms-pki.seccat +p153 +sVfli +p154 +Vvideo/fli +p155 +sVjdx +p156 +Vchemical/x-jcamp-dx +p157 +sVms +p158 +Vapplication/x-troff-ms +p159 +sVxht +p160 +Vapplication/xhtml+xml +p161 +sVcac +p162 +Vchemical/x-cache +p163 +sVcab +p164 +Vapplication/x-cab +p165 +sVdeb +p166 +Vapplication/x-debian-package +p167 +sVeps2 +p168 +g123 +sVeps3 +p169 +g123 +sVspx +p170 +Vaudio/ogg +p171 +sVltx +p172 +g72 +sVxcf +p173 +Vapplication/x-xcf +p174 +sVtar +p175 +Vapplication/x-tar +p176 +sVdxr +p177 +g58 +sVtaz +p178 +Vapplication/x-gtar +p179 +sVspl +p180 +Vapplication/x-futuresplash +p181 +sVspc +p182 +Vchemical/x-galactic-spc +p183 +sVmpc +p184 +Vchemical/x-mopac-input +p185 +sVcsm +p186 +Vchemical/x-csml +p187 +sVchrt +p188 +Vapplication/x-kchart +p189 +sVcsh +p190 +Vtext/x-csh +p191 +sVgcg +p192 +Vchemical/x-gcg8-sequence +p193 +sVsit +p194 +Vapplication/x-stuffit +p195 +sVcsf +p196 +Vchemical/x-cache-csf +p197 +sVent +p198 +Vchemical/x-pdb +p199 +sVsid +p200 +Vaudio/prs.sid +p201 +sVsik +p202 +Vapplication/x-trash +p203 +sVxhtml +p204 +g161 +sVcsv +p205 +Vtext/csv +p206 +sVcss +p207 +Vtext/css +p208 +sVsis +p209 +Vapplication/vnd.symbian.install +p210 +sVsnd +p211 +Vaudio/basic +p212 +sVmpega +p213 +g8 +sVfb +p214 +g109 +sVmesh +p215 +g129 +sVfm +p216 +g109 +sVman +p217 +Vapplication/x-troff-man +p218 +sVlha +p219 +Vapplication/x-lha +p220 +sVgcf +p221 +Vapplication/x-graphing-calculator +p222 +sVsw +p223 +Vchemical/x-swissprot +p224 +sVsh +p225 +Vtext/x-sh +p226 +sVlhs +p227 +Vtext/x-literate-haskell +p228 +sVsd +p229 +Vchemical/x-mdl-sdfile +p230 +sVlsf +p231 +Vvideo/x-la-asf +p232 +sVvmd +p233 +Vchemical/x-vmd +p234 +sVjpeg +p235 +Vimage/jpeg +p236 +sVjng +p237 +Vimage/x-jng +p238 +sVvms +p239 +Vchemical/x-vamas-iso14976 +p240 +sVlsx +p241 +g232 +sVpcx +p242 +Vimage/pcx +p243 +sVdjv +p244 +Vimage/vnd.djvu +p245 +sVwrl +p246 +Vx-world/x-vrml +p247 +sVqgs +p248 +Vapplication/x-qgis +p249 +sVhtml +p250 +g66 +sVfig +p251 +Vapplication/x-xfig +p252 +sVtsv +p253 +Vtext/tab-separated-values +p254 +sVpcf +p255 +g135 +sVtsp +p256 +Vapplication/dsptype +p257 +sVcls +p258 +g72 +sVlzx +p259 +Vapplication/x-lzx +p260 +sVmxu +p261 +Vvideo/vnd.mpegurl +p262 +sVdat +p263 +Vapplication/x-ns-proxy-autoconfig +p264 +sVlzh +p265 +Vapplication/x-lzh +p266 +sVcer +p267 +Vchemical/x-cerius +p268 +sVhqx +p269 +Vapplication/mac-binhex40 +p270 +sVkpr +p271 +Vapplication/x-kpresenter +p272 +sVkpt +p273 +g272 +sVxlb +p274 +Vapplication/vnd.ms-excel +p275 +sVh +p276 +Vtext/x-chdr +p277 +sVxlt +p278 +g275 +sVxls +p279 +g275 +sVatomcat +p280 +Vapplication/atomcat+xml +p281 +sVmdb +p282 +Vapplication/msaccess +p283 +sVgtar +p284 +g179 +sVez +p285 +Vapplication/andrew-inset +p286 +sVes +p287 +Vapplication/ecmascript +p288 +sVvcd +p289 +Vapplication/x-cdlink +p290 +sVvcf +p291 +Vtext/x-vcard +p292 +sVrd +p293 +Vchemical/x-mdl-rdfile +p294 +sVvcs +p295 +Vtext/x-vcalendar +p296 +sVra +p297 +Vaudio/x-realaudio +p298 +sVrb +p299 +Vapplication/x-ruby +p300 +sVrm +p301 +Vaudio/x-pn-realaudio +p302 +sVasx +p303 +Vvideo/x-ms-asf +p304 +sVgnumeric +p305 +Vapplication/x-gnumeric +p306 +sVmml +p307 +Vtext/mathml +p308 +sVasf +p309 +g304 +sVmmd +p310 +Vchemical/x-macromodel-input +p311 +sVmmf +p312 +Vapplication/vnd.smaf +p313 +sVaso +p314 +Vchemical/x-ncbi-asn1-binary +p315 +sVasn +p316 +Vchemical/x-ncbi-asn1-spec +p317 +sVcxx +p318 +Vtext/x-c++src +p319 +sVxpm +p320 +Vimage/x-xpixmap +p321 +sVmidi +p322 +Vaudio/midi +p323 +sVc3d +p324 +Vchemical/x-chem3d +p325 +sVisp +p326 +Vapplication/x-internet-signup +p327 +sVswfl +p328 +Vapplication/x-shockwave-flash +p329 +sVist +p330 +Vchemical/x-isostar +p331 +sVmvb +p332 +Vchemical/x-mopac-vib +p333 +sViso +p334 +Vapplication/x-iso9660-image +p335 +sVxul +p336 +Vapplication/vnd.mozilla.xul+xml +p337 +sVpgn +p338 +Vapplication/x-chess-pgn +p339 +sVpgm +p340 +Vimage/x-portable-graymap +p341 +sVpgp +p342 +Vapplication/pgp-signature +p343 +sVmkv +p344 +Vvideo/mkv +p345 +sVgpt +p346 +Vchemical/x-mopac-graph +p347 +sVphtml +p348 +Vapplication/x-httpd-php +p349 +sVods +p350 +Vapplication/vnd.oasis.opendocument.spreadsheet +p351 +sVogx +p352 +Vapplication/ogg +p353 +sVwax +p354 +Vaudio/x-ms-wax +p355 +sVpnm +p356 +Vimage/x-portable-anymap +p357 +sVcmdf +p358 +Vchemical/x-cmdf +p359 +sVoga +p360 +g171 +sVpng +p361 +Vimage/png +p362 +sVrss +p363 +Vapplication/rss+xml +p364 +sVstd +p365 +Vapplication/vnd.sun.xml.draw.template +p366 +sVb +p367 +Vchemical/x-molconn-Z +p368 +sVstc +p369 +Vapplication/vnd.sun.xml.calc.template +p370 +sVstl +p371 +Vapplication/vnd.ms-pki.stl +p372 +sVogg +p373 +g171 +sVmcif +p374 +Vchemical/x-mmcif +p375 +sVstw +p376 +Vapplication/vnd.sun.xml.writer.template +p377 +sVtorrent +p378 +Vapplication/x-bittorrent +p379 +sVprf +p380 +Vapplication/pics-rules +p381 +sVphp3p +p382 +Vapplication/x-httpd-php3-preprocessed +p383 +sVram +p384 +g302 +sVprt +p385 +Vchemical/x-ncbi-asn1-ascii +p386 +sVrar +p387 +Vapplication/rar +p388 +sVras +p389 +Vimage/x-cmu-raster +p390 +sVanx +p391 +Vapplication/annodex +p392 +sV7z +p393 +Vapplication/x-7z-compressed +p394 +sVshtml +p395 +g66 +sVlin +p396 +Vapplication/bbolin +p397 +sVmid +p398 +g323 +sVmif +p399 +Vapplication/x-mif +p400 +sV323 +p401 +Vtext/h323 +p402 +sVistr +p403 +g331 +sVcsml +p404 +g187 +sVogv +p405 +Vvideo/ogg +p406 +sVzmt +p407 +g185 +sVkar +p408 +g323 +sVmpeg +p409 +g40 +sVsisx +p410 +Vx-epoc/x-sisx-app +p411 +sVpyo +p412 +Vapplication/x-python-code +p413 +sVfch +p414 +g36 +sVpyc +p415 +g413 +sVawb +p416 +Vaudio/amr-wb +p417 +sVcc +p418 +g319 +sVfbdoc +p419 +g109 +sVlatex +p420 +Vapplication/x-latex +p421 +sVexe +p422 +Vapplication/x-msdos-program +p423 +sVaxv +p424 +Vvideo/annodex +p425 +sVdoc +p426 +Vapplication/msword +p427 +sVwmlsc +p428 +Vapplication/vnd.wap.wmlscriptc +p429 +sVhh +p430 +Vtext/x-c++hdr +p431 +sVaxa +p432 +Vaudio/annodex +p433 +sVdot +p434 +g427 +sVcdf +p435 +Vapplication/x-cdf +p436 +sVrtf +p437 +Vapplication/rtf +p438 +sVctab +p439 +g42 +sVcda +p440 +g436 +sVtext +p441 +g96 +sVsdc +p442 +Vapplication/vnd.stardivision.calc +p443 +sVcdt +p444 +Vimage/x-coreldrawtemplate +p445 +sVtexi +p446 +Vapplication/x-texinfo +p447 +sVcdr +p448 +Vimage/x-coreldraw +p449 +sVcdx +p450 +Vchemical/x-cdx +p451 +sVcdy +p452 +Vapplication/vnd.cinderella +p453 +sVxml +p454 +Vapplication/xml +p455 +sVksp +p456 +Vapplication/x-kspread +p457 +sVcache +p458 +g163 +sVjar +p459 +Vapplication/java-archive +p460 +sVjam +p461 +Vapplication/x-jam +p462 +sVjad +p463 +Vtext/vnd.sun.j2me.app-descriptor +p464 +sVief +p465 +Vimage/ief +p466 +sVdl +p467 +Vvideo/dl +p468 +sVcpio +p469 +Vapplication/x-cpio +p470 +sVdx +p471 +g157 +sVdv +p472 +g52 +sVgen +p473 +Vchemical/x-genbank +p474 +sVhin +p475 +Vchemical/x-hin +p476 +sVsilo +p477 +g129 +sVshp +p478 +g249 +sVbat +p479 +g423 +sVqt +p480 +Vvideo/quicktime +p481 +sVcrt +p482 +Vapplication/x-x509-ca-cert +p483 +sVemb +p484 +Vchemical/x-embl-dl-nucleotide +p485 +sVshx +p486 +g249 +sVeml +p487 +Vmessage/rfc822 +p488 +sVc++ +p489 +g319 +sVpatch +p490 +Vtext/x-diff +p491 +sVbak +p492 +g203 +sVcrl +p493 +Vapplication/x-pkcs7-crl +p494 +sVespi +p495 +g123 +sVart +p496 +Vimage/x-jg +p497 +sVser +p498 +Vapplication/java-serialized-object +p499 +sVframe +p500 +g109 +sVsti +p501 +Vapplication/vnd.sun.xml.impress.template +p502 +sVqtl +p503 +Vapplication/x-quicktimeplayer +p504 +sVmovie +p505 +Vvideo/x-sgi-movie +p506 +sVdll +p507 +g423 +sVwm +p508 +Vvideo/x-ms-wm +p509 +sVwk +p510 +Vapplication/x-123 +p511 +sVjs +p512 +Vapplication/javascript +p513 +sVkey +p514 +Vapplication/pgp-keys +p515 +sVsv4crc +p516 +Vapplication/x-sv4crc +p517 +sVpcap +p518 +g151 +sVwz +p519 +Vapplication/x-wingz +p520 +sVvrm +p521 +g247 +sVc +p522 +Vtext/x-csrc +p523 +sVetx +p524 +Vtext/x-setext +p525 +sVsty +p526 +g72 +sVcod +p527 +Vapplication/vnd.rim.cod +p528 +sVpdf +p529 +Vapplication/pdf +p530 +sVcom +p531 +g423 +sVpdb +p532 +g199 +sVxspf +p533 +Vapplication/xspf+xml +p534 +sVroff +p535 +g25 +sVtgz +p536 +g179 +sVpot +p537 +g96 +sVtgf +p538 +Vchemical/x-mdl-tgf +p539 +sVkwt +p540 +Vapplication/x-kword +p541 +sVcxf +p542 +Vchemical/x-cxf +p543 +sVsxd +p544 +Vapplication/vnd.sun.xml.draw +p545 +sVrpm +p546 +Vapplication/x-redhat-package-manager +p547 +sVcu +p548 +Vapplication/cu-seeme +p549 +sVjnlp +p550 +Vapplication/x-java-jnlp-file +p551 +sVps +p552 +g123 +sVmpga +p553 +g8 +sViges +p554 +Vmodel/iges +p555 +sVpy +p556 +Vtext/x-python +p557 +sVfrm +p558 +g109 +sVswf +p559 +g329 +sVpk +p560 +Vapplication/x-tex-pk +p561 +sVpl +p562 +Vtext/x-perl +p563 +sVpm +p564 +g563 +sVoth +p565 +Vapplication/vnd.oasis.opendocument.text-web +p566 +sVmcm +p567 +Vchemical/x-macmolecule +p568 +sVlyx +p569 +Vapplication/x-lyx +p570 +sVgau +p571 +Vchemical/x-gaussian-input +p572 +sVotg +p573 +Vapplication/vnd.oasis.opendocument.graphics-template +p574 +sVgam +p575 +Vchemical/x-gamess-input +p576 +sVgal +p577 +Vchemical/x-gaussian-log +p578 +sVotp +p579 +Vapplication/vnd.oasis.opendocument.presentation-template +p580 +sVots +p581 +Vapplication/vnd.oasis.opendocument.spreadsheet-template +p582 +sVott +p583 +Vapplication/vnd.oasis.opendocument.text-template +p584 +sVmopcrt +p585 +g185 +sVhdf +p586 +Vapplication/x-hdf +p587 +sVatomsrv +p588 +Vapplication/atomserv+xml +p589 +sVaif +p590 +Vaudio/x-aiff +p591 +sV~ +p592 +g203 +sVsvgz +p593 +Vimage/svg+xml +p594 +sVcef +p595 +g543 +sVwp5 +p596 +Vapplication/vnd.wordperfect5.1 +p597 +sVjpe +p598 +g236 +sVjpg +p599 +g236 +sVsitx +p600 +g195 +sVavi +p601 +Vvideo/x-msvideo +p602 +sVtexinfo +p603 +g447 +sVshar +p604 +Vapplication/x-shar +p605 +sVpas +p606 +g54 +sVpat +p607 +Vimage/x-coreldrawpattern +p608 +sVpac +p609 +g264 +sVhxx +p610 +g431 +sV3gp +p611 +Vvideo/3gpp +p612 +sVkin +p613 +Vchemical/x-kinemage +p614 +sVkil +p615 +Vapplication/x-killustrator +p616 +sVwpd +p617 +Vapplication/vnd.wordperfect +p618 +sVigs +p619 +g555 +sVphp +p620 +g349 +sVpht +p621 +g349 +sVgamin +p622 +g576 +sVwmls +p623 +Vtext/vnd.wap.wmlscript +p624 +sVeps +p625 +g123 +sVgsf +p626 +g135 +sVwmlc +p627 +Vapplication/vnd.wap.wmlc +p628 +sVgsm +p629 +Vaudio/x-gsm +p630 +sVhpp +p631 +g431 +sVaiff +p632 +g591 +sVdavmount +p633 +Vapplication/davmount+xml +p634 +sVaifc +p635 +g591 +sVtcl +p636 +g30 +sVbcpio +p637 +Vapplication/x-bcpio +p638 +sVkwd +p639 +g541 +sVskt +p640 +Vapplication/x-koan +p641 +sVskp +p642 +g641 +sVskd +p643 +g641 +sVrgb +p644 +Vimage/x-rgb +p645 +sVcub +p646 +Vchemical/x-gaussian-cube +p647 +sVskm +p648 +g641 +sVm4a +p649 +g8 +sVbin +p650 +Vapplication/octet-stream +p651 +sVembl +p652 +g485 +sVmop +p653 +g185 +sVbib +p654 +Vtext/x-bibtex +p655 +sVmov +p656 +g481 +sVpsd +p657 +Vimage/x-photoshop +p658 +sVmoo +p659 +Vchemical/x-mopac-out +p660 +sVmol +p661 +Vchemical/x-mdl-molfile +p662 +sVmoc +p663 +Vtext/x-moc +p664 +sVamr +p665 +Vaudio/amr +p666 +sVustar +p667 +Vapplication/x-ustar +p668 +sVd +p669 +Vtext/x-dsrc +p670 +sVt +p671 +g25 +sVxsd +p672 +g455 +sVgjf +p673 +g572 +sVvrml +p674 +g247 +sVgjc +p675 +g572 +sVxsl +p676 +g455 +sVold +p677 +g203 +sVvsd +p678 +Vapplication/vnd.visio +p679 +sVdiff +p680 +g491 +sVudeb +p681 +g167 +sVico +p682 +Vimage/x-icon +p683 +sVscala +p684 +Vtext/x-scala +p685 +sVica +p686 +Vapplication/x-ica +p687 +sVkml +p688 +Vapplication/vnd.google-earth.kml+xml +p689 +sVice +p690 +Vx-conference/x-cooltalk +p691 +sVicz +p692 +Vtext/calendar +p693 +sVics +p694 +g693 +sVxtel +p695 +Vchemical/x-xtel +p696 +sVkmz +p697 +Vapplication/vnd.google-earth.kmz +p698 +sVpls +p699 +Vaudio/x-scpls +p700 +sVmmod +p701 +g311 +sVjava +p702 +Vtext/x-java +p703 +sVdcr +p704 +g58 +sVsrc +p705 +Vapplication/x-wais-source +p706 +sVo +p707 +Vapplication/x-object +p708 +sVsd2 +p709 +Vaudio/x-sd2 +p710 +sVtiff +p711 +Vimage/tiff +p712 +sVxyz +p713 +Vchemical/x-xyz +p714 +sVppm +p715 +Vimage/x-portable-pixmap +p716 +sVpps +p717 +Vapplication/vnd.ms-powerpoint +p718 +sVbsd +p719 +Vchemical/x-crossfire +p720 +sVppt +p721 +g718 +sVdjvu +p722 +g245 +sVxpi +p723 +Vapplication/x-xpinstall +p724 +sVval +p725 +g315 +sVwad +p726 +Vapplication/x-doom +p727 +sVclass +p728 +Vapplication/java-vm +p729 +sVgif +p730 +Vimage/gif +p731 +sVsmil +p732 +g45 +sVwav +p733 +Vaudio/x-wav +p734 +sVrhtml +p735 +Vapplication/x-httpd-eruby +p736 +sVsdw +p737 +Vapplication/vnd.stardivision.writer +p738 +sVsds +p739 +Vapplication/vnd.stardivision.chart +p740 +sVhs +p741 +Vtext/x-haskell +p742 +sVsdd +p743 +Vapplication/vnd.stardivision.impress +p744 +sVsdf +p745 +g230 +sVsda +p746 +Vapplication/vnd.stardivision.draw +p747 +sVatom +p748 +Vapplication/atom+xml +p749 +sVsv4cpio +p750 +Vapplication/x-sv4cpio +p751 +sVinfo +p752 +Vapplication/x-info +p753 +sVcif +p754 +Vchemical/x-cif +p755 +sVdmg +p756 +Vapplication/x-apple-diskimage +p757 +sVdms +p758 +Vapplication/x-dms +p759 +sVsvg +p760 +g594 +sVxwd +p761 +Vimage/x-xwindowdump +p762 +sVpfa +p763 +g135 +sVsxc +p764 +Vapplication/vnd.sun.xml.calc +p765 +sVp7r +p766 +Vapplication/x-pkcs7-certreqresp +p767 +sVsxg +p768 +Vapplication/vnd.sun.xml.writer.global +p769 +sVai +p770 +g123 +sVsxi +p771 +Vapplication/vnd.sun.xml.impress +p772 +sVinp +p773 +g576 +sVsxm +p774 +Vapplication/vnd.sun.xml.math +p775 +sVins +p776 +g327 +sVcbr +p777 +Vapplication/x-cbr +p778 +sVau +p779 +g212 +sVsxw +p780 +Vapplication/vnd.sun.xml.writer +p781 +sVcbz +p782 +Vapplication/x-cbz +p783 +sV% +p784 +g203 +sVnb +p785 +g68 +sVnc +p786 +Vapplication/x-netcdf +p787 +sVbook +p788 +g109 +sVphp4 +p789 +Vapplication/x-httpd-php4 +p790 +sVtif +p791 +g712 +sVphp3 +p792 +Vapplication/x-httpd-php3 +p793 +sVmol2 +p794 +Vchemical/x-mol2 +p795 +sVh++ +p796 +g431 +sVdvi +p797 +Vapplication/x-dvi +p798 +sVpcf.Z +p799 +g135 +sVrxn +p800 +Vchemical/x-mdl-rxnfile +p801 +sVcpa +p802 +Vchemical/x-compass +p803 +sVbmp +p804 +Vimage/x-ms-bmp +p805 +sVxbm +p806 +Vimage/x-xbitmap +p807 +sVcpp +p808 +g319 +sVcpt +p809 +Vimage/x-corelphotopaint +p810 +sVphps +p811 +Vapplication/x-httpd-php-source +p812 +s. \ No newline at end of file diff --git a/ranger/data/mime.types b/ranger/data/mime.types new file mode 100644 index 00000000..866db2c2 --- /dev/null +++ b/ranger/data/mime.types @@ -0,0 +1,769 @@ +############################################################################### +# +# MIME-TYPES and the extensions that represent them +# +# This file is part of the "mime-support" package. Please send email (not a +# bug report) to mime-support@packages.debian.org if you would like new types +# and/or extensions to be added. +# +# The reason that all types are managed by the mime-support package instead +# allowing individual packages to install types in much the same way as they +# add entries in to the mailcap file is so these types can be referenced by +# other programs (such as a web server) even if the specific support package +# for that type is not installed. +# +# Users can add their own types if they wish by creating a ".mime.types" +# file in their home directory. Definitions included there will take +# precedence over those listed here. +# +# Note: Compression schemes like "gzip", "bzip", and "compress" are not +# actually "mime-types". They are "encodings" and hence must _not_ have +# entries in this file to map their extensions. The "mime-type" of an +# encoded file refers to the type of data that has been encoded, not the +# type of encoding. +# +############################################################################### + + +application/activemessage +application/andrew-inset ez +application/annodex anx +application/applefile +application/atom+xml atom +application/atomcat+xml atomcat +application/atomserv+xml atomsrv +application/atomicmail +application/batch-SMTP +application/beep+xml +application/bbolin lin +application/cals-1840 +application/cap cap pcap +application/commonground +application/cu-seeme cu +application/cybercash +application/davmount+xml davmount +application/dca-rft +application/dec-dx +application/docbook+xml +application/dsptype tsp +application/dvcs +application/ecmascript es +application/edi-consent +application/edi-x12 +application/edifact +application/eshop +application/font-tdpfr +application/futuresplash spl +application/ghostview +application/hta hta +application/http +application/hyperstudio +application/iges +application/index +application/index.cmd +application/index.obj +application/index.response +application/index.vnd +application/iotp +application/ipp +application/isup +application/java-archive jar +application/java-serialized-object ser +application/java-vm class +application/javascript js +application/m3g m3g +application/mac-binhex40 hqx +application/mac-compactpro cpt +application/macwriteii +application/marc +application/mathematica nb nbp +application/ms-tnef +application/msaccess mdb +application/msword doc dot +application/news-message-id +application/news-transmission +application/ocsp-request +application/ocsp-response +application/octet-stream bin +application/oda oda +application/ogg ogx +application/parityfec +application/pdf pdf +application/pgp-encrypted +application/pgp-keys key +application/pgp-signature pgp +application/pics-rules prf +application/pkcs10 +application/pkcs7-mime +application/pkcs7-signature +application/pkix-cert +application/pkix-crl +application/pkixcmp +application/postscript ps ai eps espi epsf eps2 eps3 +application/prs.alvestrand.titrax-sheet +application/prs.cww +application/prs.nprend +application/qsig +application/rar rar +application/rdf+xml rdf +application/remote-printing +application/riscos +application/rss+xml rss +application/rtf rtf +application/sdp +application/set-payment +application/set-payment-initiation +application/set-registration +application/set-registration-initiation +application/sgml +application/sgml-open-catalog +application/sieve +application/slate +application/smil smi smil +application/timestamp-query +application/timestamp-reply +application/vemmi +application/whoispp-query +application/whoispp-response +application/wita +application/x400-bp +application/xhtml+xml xhtml xht +application/xml xml xsl xsd +application/xml-dtd +application/xml-external-parsed-entity +application/xspf+xml xspf +application/zip zip +application/vnd.3M.Post-it-Notes +application/vnd.accpac.simply.aso +application/vnd.accpac.simply.imp +application/vnd.acucobol +application/vnd.aether.imp +application/vnd.anser-web-certificate-issue-initiation +application/vnd.anser-web-funds-transfer-initiation +application/vnd.audiograph +application/vnd.bmi +application/vnd.businessobjects +application/vnd.canon-cpdl +application/vnd.canon-lips +application/vnd.cinderella cdy +application/vnd.claymore +application/vnd.commerce-battelle +application/vnd.commonspace +application/vnd.comsocaller +application/vnd.contact.cmsg +application/vnd.cosmocaller +application/vnd.ctc-posml +application/vnd.cups-postscript +application/vnd.cups-raster +application/vnd.cups-raw +application/vnd.cybank +application/vnd.dna +application/vnd.dpgraph +application/vnd.dxr +application/vnd.ecdis-update +application/vnd.ecowin.chart +application/vnd.ecowin.filerequest +application/vnd.ecowin.fileupdate +application/vnd.ecowin.series +application/vnd.ecowin.seriesrequest +application/vnd.ecowin.seriesupdate +application/vnd.enliven +application/vnd.epson.esf +application/vnd.epson.msf +application/vnd.epson.quickanime +application/vnd.epson.salt +application/vnd.epson.ssf +application/vnd.ericsson.quickcall +application/vnd.eudora.data +application/vnd.fdf +application/vnd.ffsns +application/vnd.flographit +application/vnd.framemaker +application/vnd.fsc.weblaunch +application/vnd.fujitsu.oasys +application/vnd.fujitsu.oasys2 +application/vnd.fujitsu.oasys3 +application/vnd.fujitsu.oasysgp +application/vnd.fujitsu.oasysprs +application/vnd.fujixerox.ddd +application/vnd.fujixerox.docuworks +application/vnd.fujixerox.docuworks.binder +application/vnd.fut-misnet +application/vnd.google-earth.kml+xml kml +application/vnd.google-earth.kmz kmz +application/vnd.grafeq +application/vnd.groove-account +application/vnd.groove-identity-message +application/vnd.groove-injector +application/vnd.groove-tool-message +application/vnd.groove-tool-template +application/vnd.groove-vcard +application/vnd.hhe.lesson-player +application/vnd.hp-HPGL +application/vnd.hp-PCL +application/vnd.hp-PCLXL +application/vnd.hp-hpid +application/vnd.hp-hps +application/vnd.httphone +application/vnd.hzn-3d-crossword +application/vnd.ibm.MiniPay +application/vnd.ibm.afplinedata +application/vnd.ibm.modcap +application/vnd.informix-visionary +application/vnd.intercon.formnet +application/vnd.intertrust.digibox +application/vnd.intertrust.nncp +application/vnd.intu.qbo +application/vnd.intu.qfx +application/vnd.irepository.package+xml +application/vnd.is-xpr +application/vnd.japannet-directory-service +application/vnd.japannet-jpnstore-wakeup +application/vnd.japannet-payment-wakeup +application/vnd.japannet-registration +application/vnd.japannet-registration-wakeup +application/vnd.japannet-setstore-wakeup +application/vnd.japannet-verification +application/vnd.japannet-verification-wakeup +application/vnd.koan +application/vnd.lotus-1-2-3 +application/vnd.lotus-approach +application/vnd.lotus-freelance +application/vnd.lotus-notes +application/vnd.lotus-organizer +application/vnd.lotus-screencam +application/vnd.lotus-wordpro +application/vnd.mcd +application/vnd.mediastation.cdkey +application/vnd.meridian-slingshot +application/vnd.mif +application/vnd.minisoft-hp3000-save +application/vnd.mitsubishi.misty-guard.trustweb +application/vnd.mobius.daf +application/vnd.mobius.dis +application/vnd.mobius.msl +application/vnd.mobius.plc +application/vnd.mobius.txf +application/vnd.motorola.flexsuite +application/vnd.motorola.flexsuite.adsi +application/vnd.motorola.flexsuite.fis +application/vnd.motorola.flexsuite.gotap +application/vnd.motorola.flexsuite.kmr +application/vnd.motorola.flexsuite.ttc +application/vnd.motorola.flexsuite.wem +application/vnd.mozilla.xul+xml xul +application/vnd.ms-artgalry +application/vnd.ms-asf +application/vnd.ms-excel xls xlb xlt +application/vnd.ms-lrm +application/vnd.ms-pki.seccat cat +application/vnd.ms-pki.stl stl +application/vnd.ms-powerpoint ppt pps +application/vnd.ms-project +application/vnd.ms-tnef +application/vnd.ms-works +application/vnd.mseq +application/vnd.msign +application/vnd.music-niff +application/vnd.musician +application/vnd.netfpx +application/vnd.noblenet-directory +application/vnd.noblenet-sealer +application/vnd.noblenet-web +application/vnd.novadigm.EDM +application/vnd.novadigm.EDX +application/vnd.novadigm.EXT +application/vnd.oasis.opendocument.chart odc +application/vnd.oasis.opendocument.database odb +application/vnd.oasis.opendocument.formula odf +application/vnd.oasis.opendocument.graphics odg +application/vnd.oasis.opendocument.graphics-template otg +application/vnd.oasis.opendocument.image odi +application/vnd.oasis.opendocument.presentation odp +application/vnd.oasis.opendocument.presentation-template otp +application/vnd.oasis.opendocument.spreadsheet ods +application/vnd.oasis.opendocument.spreadsheet-template ots +application/vnd.oasis.opendocument.text odt +application/vnd.oasis.opendocument.text-master odm +application/vnd.oasis.opendocument.text-template ott +application/vnd.oasis.opendocument.text-web oth +application/vnd.osa.netdeploy +application/vnd.palm +application/vnd.pg.format +application/vnd.pg.osasli +application/vnd.powerbuilder6 +application/vnd.powerbuilder6-s +application/vnd.powerbuilder7 +application/vnd.powerbuilder7-s +application/vnd.powerbuilder75 +application/vnd.powerbuilder75-s +application/vnd.previewsystems.box +application/vnd.publishare-delta-tree +application/vnd.pvi.ptid1 +application/vnd.pwg-xhtml-print+xml +application/vnd.rapid +application/vnd.rim.cod cod +application/vnd.s3sms +application/vnd.seemail +application/vnd.shana.informed.formdata +application/vnd.shana.informed.formtemplate +application/vnd.shana.informed.interchange +application/vnd.shana.informed.package +application/vnd.smaf mmf +application/vnd.sss-cod +application/vnd.sss-dtf +application/vnd.sss-ntf +application/vnd.stardivision.calc sdc +application/vnd.stardivision.chart sds +application/vnd.stardivision.draw sda +application/vnd.stardivision.impress sdd +application/vnd.stardivision.math sdf +application/vnd.stardivision.writer sdw +application/vnd.stardivision.writer-global sgl +application/vnd.street-stream +application/vnd.sun.xml.calc sxc +application/vnd.sun.xml.calc.template stc +application/vnd.sun.xml.draw sxd +application/vnd.sun.xml.draw.template std +application/vnd.sun.xml.impress sxi +application/vnd.sun.xml.impress.template sti +application/vnd.sun.xml.math sxm +application/vnd.sun.xml.writer sxw +application/vnd.sun.xml.writer.global sxg +application/vnd.sun.xml.writer.template stw +application/vnd.svd +application/vnd.swiftview-ics +application/vnd.symbian.install sis +application/vnd.triscape.mxs +application/vnd.trueapp +application/vnd.truedoc +application/vnd.tve-trigger +application/vnd.ufdl +application/vnd.uplanet.alert +application/vnd.uplanet.alert-wbxml +application/vnd.uplanet.bearer-choice +application/vnd.uplanet.bearer-choice-wbxml +application/vnd.uplanet.cacheop +application/vnd.uplanet.cacheop-wbxml +application/vnd.uplanet.channel +application/vnd.uplanet.channel-wbxml +application/vnd.uplanet.list +application/vnd.uplanet.list-wbxml +application/vnd.uplanet.listcmd +application/vnd.uplanet.listcmd-wbxml +application/vnd.uplanet.signal +application/vnd.vcx +application/vnd.vectorworks +application/vnd.vidsoft.vidconference +application/vnd.visio vsd +application/vnd.vividence.scriptfile +application/vnd.wap.sic +application/vnd.wap.slc +application/vnd.wap.wbxml wbxml +application/vnd.wap.wmlc wmlc +application/vnd.wap.wmlscriptc wmlsc +application/vnd.webturbo +application/vnd.wordperfect wpd +application/vnd.wordperfect5.1 wp5 +application/vnd.wrq-hp3000-labelled +application/vnd.wt.stf +application/vnd.xara +application/vnd.xfdl +application/vnd.yellowriver-custom-menu +application/x-123 wk +application/x-7z-compressed 7z +application/x-abiword abw +application/x-apple-diskimage dmg +application/x-bcpio bcpio +application/x-bittorrent torrent +application/x-cab cab +application/x-cbr cbr +application/x-cbz cbz +application/x-cdf cdf cda +application/x-cdlink vcd +application/x-chess-pgn pgn +application/x-core +application/x-cpio cpio +application/x-csh csh +application/x-debian-package deb udeb +application/x-director dcr dir dxr +application/x-dms dms +application/x-doom wad +application/x-dvi dvi +application/x-httpd-eruby rhtml +application/x-executable +application/x-font pfa pfb gsf pcf pcf.Z +application/x-freemind mm +application/x-futuresplash spl +application/x-gnumeric gnumeric +application/x-go-sgf sgf +application/x-graphing-calculator gcf +application/x-gtar gtar tgz taz +application/x-hdf hdf +application/x-httpd-php phtml pht php +application/x-httpd-php-source phps +application/x-httpd-php3 php3 +application/x-httpd-php3-preprocessed php3p +application/x-httpd-php4 php4 +application/x-ica ica +application/x-info info +application/x-internet-signup ins isp +application/x-iphone iii +application/x-iso9660-image iso +application/x-jam jam +application/x-java-applet +application/x-java-bean +application/x-java-jnlp-file jnlp +application/x-jmol jmz +application/x-kchart chrt +application/x-kdelnk +application/x-killustrator kil +application/x-koan skp skd skt skm +application/x-kpresenter kpr kpt +application/x-kspread ksp +application/x-kword kwd kwt +application/x-latex latex +application/x-lha lha +application/x-lyx lyx +application/x-lzh lzh +application/x-lzx lzx +application/x-maker frm maker frame fm fb book fbdoc +application/x-mif mif +application/x-ms-wmd wmd +application/x-ms-wmz wmz +application/x-msdos-program com exe bat dll +application/x-msi msi +application/x-netcdf nc +application/x-ns-proxy-autoconfig pac dat +application/x-nwc nwc +application/x-object o +application/x-oz-application oza +application/x-pkcs7-certreqresp p7r +application/x-pkcs7-crl crl +application/x-python-code pyc pyo +application/x-qgis qgs shp shx +application/x-quicktimeplayer qtl +application/x-redhat-package-manager rpm +application/x-ruby rb +application/x-rx +application/x-sh sh +application/x-shar shar +application/x-shellscript +application/x-shockwave-flash swf swfl +application/x-stuffit sit sitx +application/x-sv4cpio sv4cpio +application/x-sv4crc sv4crc +application/x-tar tar +application/x-tcl tcl +application/x-tex-gf gf +application/x-tex-pk pk +application/x-texinfo texinfo texi +application/x-trash ~ % bak old sik +application/x-troff t tr roff +application/x-troff-man man +application/x-troff-me me +application/x-troff-ms ms +application/x-ustar ustar +application/x-videolan +application/x-wais-source src +application/x-wingz wz +application/x-x509-ca-cert crt +application/x-xcf xcf +application/x-xfig fig +application/x-xpinstall xpi + +audio/32kadpcm +audio/3gpp +audio/amr amr +audio/amr-wb awb +audio/amr amr +audio/amr-wb awb +audio/annodex axa +audio/basic au snd +audio/flac flac +audio/g.722.1 +audio/l16 +audio/midi mid midi kar +audio/mp4a-latm +audio/mpa-robust +audio/mpeg mpga mpega mp2 mp3 m4a +audio/mpegurl m3u +audio/ogg oga ogg spx +audio/parityfec +audio/prs.sid sid +audio/telephone-event +audio/tone +audio/vnd.cisco.nse +audio/vnd.cns.anp1 +audio/vnd.cns.inf1 +audio/vnd.digital-winds +audio/vnd.everad.plj +audio/vnd.lucent.voice +audio/vnd.nortel.vbk +audio/vnd.nuera.ecelp4800 +audio/vnd.nuera.ecelp7470 +audio/vnd.nuera.ecelp9600 +audio/vnd.octel.sbc +audio/vnd.qcelp +audio/vnd.rhetorex.32kadpcm +audio/vnd.vmx.cvsd +audio/x-aiff aif aiff aifc +audio/x-gsm gsm +audio/x-mpegurl m3u +audio/x-ms-wma wma +audio/x-ms-wax wax +audio/x-pn-realaudio-plugin +audio/x-pn-realaudio ra rm ram +audio/x-realaudio ra +audio/x-scpls pls +audio/x-sd2 sd2 +audio/x-wav wav + +chemical/x-alchemy alc +chemical/x-cache cac cache +chemical/x-cache-csf csf +chemical/x-cactvs-binary cbin cascii ctab +chemical/x-cdx cdx +chemical/x-cerius cer +chemical/x-chem3d c3d +chemical/x-chemdraw chm +chemical/x-cif cif +chemical/x-cmdf cmdf +chemical/x-cml cml +chemical/x-compass cpa +chemical/x-crossfire bsd +chemical/x-csml csml csm +chemical/x-ctx ctx +chemical/x-cxf cxf cef +#chemical/x-daylight-smiles smi +chemical/x-embl-dl-nucleotide emb embl +chemical/x-galactic-spc spc +chemical/x-gamess-input inp gam gamin +chemical/x-gaussian-checkpoint fch fchk +chemical/x-gaussian-cube cub +chemical/x-gaussian-input gau gjc gjf +chemical/x-gaussian-log gal +chemical/x-gcg8-sequence gcg +chemical/x-genbank gen +chemical/x-hin hin +chemical/x-isostar istr ist +chemical/x-jcamp-dx jdx dx +chemical/x-kinemage kin +chemical/x-macmolecule mcm +chemical/x-macromodel-input mmd mmod +chemical/x-mdl-molfile mol +chemical/x-mdl-rdfile rd +chemical/x-mdl-rxnfile rxn +chemical/x-mdl-sdfile sd sdf +chemical/x-mdl-tgf tgf +#chemical/x-mif mif +chemical/x-mmcif mcif +chemical/x-mol2 mol2 +chemical/x-molconn-Z b +chemical/x-mopac-graph gpt +chemical/x-mopac-input mop mopcrt mpc zmt +chemical/x-mopac-out moo +chemical/x-mopac-vib mvb +chemical/x-ncbi-asn1 asn +chemical/x-ncbi-asn1-ascii prt ent +chemical/x-ncbi-asn1-binary val aso +chemical/x-ncbi-asn1-spec asn +chemical/x-pdb pdb ent +chemical/x-rosdal ros +chemical/x-swissprot sw +chemical/x-vamas-iso14976 vms +chemical/x-vmd vmd +chemical/x-xtel xtel +chemical/x-xyz xyz + +image/cgm +image/g3fax +image/gif gif +image/ief ief +image/jpeg jpeg jpg jpe +image/naplps +image/pcx pcx +image/png png +image/prs.btif +image/prs.pti +image/svg+xml svg svgz +image/tiff tiff tif +image/vnd.cns.inf2 +image/vnd.djvu djvu djv +image/vnd.dwg +image/vnd.dxf +image/vnd.fastbidsheet +image/vnd.fpx +image/vnd.fst +image/vnd.fujixerox.edmics-mmr +image/vnd.fujixerox.edmics-rlc +image/vnd.mix +image/vnd.net-fpx +image/vnd.svf +image/vnd.wap.wbmp wbmp +image/vnd.xiff +image/x-cmu-raster ras +image/x-coreldraw cdr +image/x-coreldrawpattern pat +image/x-coreldrawtemplate cdt +image/x-corelphotopaint cpt +image/x-icon ico +image/x-jg art +image/x-jng jng +image/x-ms-bmp bmp +image/x-photoshop psd +image/x-portable-anymap pnm +image/x-portable-bitmap pbm +image/x-portable-graymap pgm +image/x-portable-pixmap ppm +image/x-rgb rgb +image/x-xbitmap xbm +image/x-xpixmap xpm +image/x-xwindowdump xwd + +inode/chardevice +inode/blockdevice +inode/directory-locked +inode/directory +inode/fifo +inode/socket + +message/delivery-status +message/disposition-notification +message/external-body +message/http +message/s-http +message/news +message/partial +message/rfc822 eml + +model/iges igs iges +model/mesh msh mesh silo +model/vnd.dwf +model/vnd.flatland.3dml +model/vnd.gdl +model/vnd.gs-gdl +model/vnd.gtw +model/vnd.mts +model/vnd.vtu +model/vrml wrl vrml + +multipart/alternative +multipart/appledouble +multipart/byteranges +multipart/digest +multipart/encrypted +multipart/form-data +multipart/header-set +multipart/mixed +multipart/parallel +multipart/related +multipart/report +multipart/signed +multipart/voice-message + +text/calendar ics icz +text/css css +text/csv csv +text/directory +text/english +text/enriched +text/h323 323 +text/html html htm shtml +text/iuls uls +text/mathml mml +text/parityfec +text/plain asc txt text pot brf +text/prs.lines.tag +text/rfc822-headers +text/richtext rtx +text/rtf +text/scriptlet sct wsc +text/t140 +text/texmacs tm ts +text/tab-separated-values tsv +text/uri-list +text/vnd.abc +text/vnd.curl +text/vnd.DMClientScript +text/vnd.flatland.3dml +text/vnd.fly +text/vnd.fmi.flexstor +text/vnd.in3d.3dml +text/vnd.in3d.spot +text/vnd.IPTC.NewsML +text/vnd.IPTC.NITF +text/vnd.latex-z +text/vnd.motorola.reflex +text/vnd.ms-mediapackage +text/vnd.sun.j2me.app-descriptor jad +text/vnd.wap.si +text/vnd.wap.sl +text/vnd.wap.wml wml +text/vnd.wap.wmlscript wmls +text/x-bibtex bib +text/x-boo boo +text/x-c++hdr h++ hpp hxx hh +text/x-c++src c++ cpp cxx cc +text/x-chdr h +text/x-component htc +text/x-crontab +text/x-csh csh +text/x-csrc c +text/x-dsrc d +text/x-diff diff patch +text/x-haskell hs +text/x-java java +text/x-literate-haskell lhs +text/x-makefile +text/x-moc moc +text/x-pascal p pas +text/x-pcs-gcd gcd +text/x-perl pl pm +text/x-python py +text/x-scala scala +text/x-server-parsed-html +text/x-setext etx +text/x-sh sh +text/x-tcl tcl tk +text/x-tex tex ltx sty cls +text/x-vcalendar vcs +text/x-vcard vcf + +video/3gpp 3gp +video/annodex axv +video/dl dl +video/dv dif dv +video/fli fli +video/gl gl +video/mpeg mpeg mpg mpe +video/mkv mkv +video/mp4 mp4 +video/quicktime qt mov +video/mp4v-es +video/ogg ogv +video/parityfec +video/pointer +video/vnd.fvt +video/vnd.motorola.video +video/vnd.motorola.videop +video/vnd.mpegurl mxu +video/vnd.mts +video/vnd.nokia.interleaved-multimedia +video/vnd.vivo +video/x-flv flv +video/x-la-asf lsf lsx +video/x-mng mng +video/x-ms-asf asf asx +video/x-ms-wm wm +video/x-ms-wmv wmv +video/x-ms-wmx wmx +video/x-ms-wvx wvx +video/x-msvideo avi +video/x-sgi-movie movie +video/x-matroska mpv + +x-conference/x-cooltalk ice + +x-epoc/x-sisx-app sisx +x-world/x-vrml vrm vrml wrl diff --git a/ranger/defaults/apps.py b/ranger/defaults/apps.py index 23b95537..b2dc36c6 100644 --- a/ranger/defaults/apps.py +++ b/ranger/defaults/apps.py @@ -1,7 +1,6 @@ -from ranger.applications import Applications as SuperClass -from ranger.helper import popen as run +from ranger.applications import Applications, run -class CustomApplications(SuperClass): +class CustomApplications(Applications): # How to determine the default application? {{{ def app_default(self, **kw): f = kw['mainfile'] @@ -43,6 +42,11 @@ class CustomApplications(SuperClass): '-lavdopts', 'lowres=1:fast:skiploopfilter=all:threads=8', *kw['files'], **kw) + elif kw['mode'] == 3: + return run('mplayer', + '-mixer', 'software', + *kw['files'], **kw) + else: return run('mplayer', '-fs', *kw['files'], **kw) diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index dc7362cf..de58681a 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -1,7 +1,7 @@ def initialize_commands(cl): from ranger.fm import FM from curses.ascii import ctrl - from ranger.bookmark import ALLOWED_KEYS as ALLOWED_BOOKMARK_KEYS + from ranger.container.bookmarks import ALLOWED_KEYS as ALLOWED_BOOKMARK_KEYS import curses # syntax for binding keys: cl.bind(fnc, *keys) diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py index d3eeef84..f78d0a81 100644 --- a/ranger/defaults/options.py +++ b/ranger/defaults/options.py @@ -1,3 +1,4 @@ +from ranger.defaults import apps, keys from ranger import colorschemes colorscheme = colorschemes.default diff --git a/ranger/directory.py b/ranger/directory.py index 6a619537..258266c0 100644 --- a/ranger/directory.py +++ b/ranger/directory.py @@ -4,7 +4,7 @@ from ranger.file import File from ranger.fsobject import BAD_INFO from ranger.fsobject import FileSystemObject as SuperClass -from ranger.conf import SettingsAware +from ranger.shared import SettingsAware def sort_by_basename(path): return path.basename @@ -37,7 +37,7 @@ class Directory(SuperClass, SettingsAware): # to find out if something has changed: self.old_show_hidden = self.settings.show_hidden self.old_directories_first = self.settings.directories_first - + def load_content(self): from os.path import join, isdir, basename from os import listdir @@ -211,3 +211,8 @@ class Directory(SuperClass, SettingsAware): if not self.accessible: raise ranger.fsobject.NotLoadedYet() return self.files[key] + def __eq__(self, other): + return isinstance(other, Directory) and self.path == other.path + + def __neq__(self, other): + return not self.__eq__(other) diff --git a/ranger/environment.py b/ranger/environment.py index a5e54414..8e45516b 100644 --- a/ranger/environment.py +++ b/ranger/environment.py @@ -1,28 +1,31 @@ from os.path import abspath, normpath, join, expanduser from ranger.directory import Directory, NoDirectoryGiven -from ranger.conf import SettingsAware +from ranger.container import KeyBuffer, History +from ranger.shared import SettingsAware class Environment(SettingsAware): # A collection of data which is relevant for more than # one class. def __init__(self, path): - from ranger.history import History self.path = abspath(expanduser(path)) self.pathway = () self.last_search = None self.directories = {} self.pwd = None # current directory self.cf = None # current file - self.keybuffer = () + self.keybuffer = KeyBuffer() self.copy = None self.termsize = (24, 80) self.history = History(self.settings.max_history_size) + from ranger.shared import EnvironmentAware + EnvironmentAware.env = self + def key_append(self, key): - self.keybuffer += (key, ) + self.keybuffer = KeyBuffer(self.keybuffer + (key, )) def key_clear(self): - self.keybuffer = () + self.keybuffer = KeyBuffer() def at_level(self, level): if level <= 0: @@ -37,6 +40,14 @@ class Environment(SettingsAware): return None except KeyError: return self.cf + + def garbage_collect(self): + from ranger.fsobject import FileSystemObject + for key in tuple(self.directories.keys()): + value = self.directories[key] + if isinstance(value, FileSystemObject): + if value.is_older_than(1): + del self.directories[key] def get_directory(self, path): path = abspath(path) @@ -59,7 +70,8 @@ class Environment(SettingsAware): def history_go(self, relative): if self.history: - self.enter_dir(self.history.move(relative)) +# self.enter_dir(self.history.move(relative)) + self.history.move(relative).go() def enter_dir(self, path, history = True): if path is None: return @@ -98,7 +110,7 @@ class Environment(SettingsAware): self.cf = self.pwd.pointed_file if history: - self.history.add(path) + self.history.add(new_pwd) return True diff --git a/ranger/ext/__init__.py b/ranger/ext/__init__.py new file mode 100644 index 00000000..f09324b7 --- /dev/null +++ b/ranger/ext/__init__.py @@ -0,0 +1,3 @@ +from .openstruct import OpenStruct +from .human_readable import human_readable +from .waitpid_no_intr import waitpid_no_intr diff --git a/ranger/ext/human_readable.py b/ranger/ext/human_readable.py new file mode 100644 index 00000000..4afa03cb --- /dev/null +++ b/ranger/ext/human_readable.py @@ -0,0 +1,21 @@ +ONE_KB = 1024 +UNITS = 'BKMGTP' +MAX_EXPONENT = len(UNITS) - 1 + +def human_readable(byte): + import math + + if not byte: + return '0 B' + + exponent = int(math.log(byte, 2) / 10) + flt = float(byte) / (1 << (10 * exponent)) + + if exponent > MAX_EXPONENT: + return '>9000' # off scale + + if int(flt) == flt: + return '%.0f %s' % (flt, UNITS[exponent]) + + else: + return '%.2f %s' % (flt, UNITS[exponent]) diff --git a/ranger/ext/openstruct.py b/ranger/ext/openstruct.py new file mode 100644 index 00000000..0a899de6 --- /dev/null +++ b/ranger/ext/openstruct.py @@ -0,0 +1,16 @@ +class OpenStruct(object): + def __init__(self, __dictionary=None, **__keywords): + if __dictionary: + self.__dict__.update(__dictionary) + if __keywords: + self.__dict__.update(__keywords) + + def __getitem__(self, key): + return self.__dict__[key] + + def __setitem__(self, key, value): + self.__dict__[key] = value + return value + + def __contains__(self, key): + return key in self.__dict__ diff --git a/ranger/ext/waitpid_no_intr.py b/ranger/ext/waitpid_no_intr.py new file mode 100644 index 00000000..38df44ee --- /dev/null +++ b/ranger/ext/waitpid_no_intr.py @@ -0,0 +1,12 @@ +def waitpid_no_intr(pid): + """ catch interrupts which occur while using os.waitpid """ + import os, errno + + while True: + try: + return os.waitpid(pid, 0) + except OSError as e: + if e.errno == errno.EINTR: + continue + else: + raise diff --git a/ranger/fm.py b/ranger/fm.py index 3fcfb92f..2bfecffb 100644 --- a/ranger/fm.py +++ b/ranger/fm.py @@ -1,29 +1,34 @@ -from os import devnull -#from ranger.conf.apps import CustomApplications as Applications -from ranger.conf import apps -null = open(devnull, 'a') - -class FM(object): - def __init__(self, environment, ui, bookmarks): - self.env = environment +from ranger.shared import EnvironmentAware + +class FM(EnvironmentAware): + def __init__(self, ui, bookmarks): self.ui = ui - self.apps = apps.CustomApplications() + self.apps = self.env.settings.apps.CustomApplications() self.bookmarks = bookmarks self.bookmarks.enter_dir_function = self.enter_dir - def run(self): + from ranger.shared import FileManagerAware + FileManagerAware.fm = self + + def loop(self): self.env.enter_dir(self.env.path) + gc_tick = 0 + while True: try: self.bookmarks.reload_if_outdated() self.ui.draw() key = self.ui.get_next_key() self.ui.press(key, self) + + gc_tick += 1 + if gc_tick > 10: + gc_tick = 0 + self.env.garbage_collect() + except KeyboardInterrupt: self.ui.press(3, self) - except: - raise def interrupt(self): import time @@ -53,7 +58,7 @@ class FM(object): self.env.enter_dir(path) def enter_bookmark(self, key): - from ranger.bookmark import NonexistantBookmark + from ranger.container.bookmarks import NonexistantBookmark try: destination = self.bookmarks[key] current_path = self.env.pwd.path diff --git a/ranger/fsobject.py b/ranger/fsobject.py index 35a6465a..35d0d5b3 100644 --- a/ranger/fsobject.py +++ b/ranger/fsobject.py @@ -12,9 +12,11 @@ CONTAINER_EXTENSIONS = 'rar zip tar gz bz bz2 tgz 7z iso cab'.split() DOCUMENT_EXTENSIONS = 'pdf doc ppt odt'.split() DOCUMENT_BASENAMES = 'README TODO LICENSE'.split() -class FileSystemObject(object): +from ranger.shared import MimeTypeAware, FileManagerAware +class FileSystemObject(MimeTypeAware, FileManagerAware): def __init__(self, path): + MimeTypeAware.__init__(self) if type(self) == FileSystemObject: raise TypeError("FileSystemObject is an abstract class and cannot be initialized.") @@ -42,14 +44,22 @@ class FileSystemObject(object): self.type = T_UNKNOWN self.set_mimetype() + self.use() def __str__(self): return str(self.path) + def use(self): + import time + self.last_used = time.time() + + def is_older_than(self, seconds): + import time + return self.last_used + seconds < time.time() + def set_mimetype(self): - import ranger.mimetype as mimetype try: - self.mimetype = mimetype.get() [self.extension] + self.mimetype = self.mimetypes[self.extension] except KeyError: self.mimetype = '' @@ -70,7 +80,7 @@ class FileSystemObject(object): # and caches it in instance attributes. def load(self): import os - from ranger.helper import human_readable + from ranger.ext import human_readable self.loaded = True @@ -113,6 +123,9 @@ class FileSystemObject(object): return True return False + def go(self): + self.fm.enter_dir(self.path) + def load_if_outdated(self): if self.load_once(): return True diff --git a/ranger/gui/colorscheme.py b/ranger/gui/colorscheme.py index 6f3ef01f..281396a5 100644 --- a/ranger/gui/colorscheme.py +++ b/ranger/gui/colorscheme.py @@ -3,7 +3,8 @@ CONTEXT_KEYS = [ 'reset', 'error', 'directory', 'file', 'hostname', 'executable', 'media', 'link', 'video', 'audio', 'image', 'media', 'document', 'container', - 'broken', 'selected', 'empty', 'maindisplay'] + 'broken', 'selected', 'empty', 'maindisplay', + 'keybuffer'] # colorscheme specification: # @@ -27,7 +28,7 @@ CONTEXT_KEYS = [ 'reset', 'error', # If your colorscheme-file contains more than one colorscheme, specify it with: # colorscheme = colorschemes.filename.classname -from ranger.helper import OpenStruct +from ranger.ext import OpenStruct class ColorScheme(object): def __init__(self): diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index b5ae78dc..beedea09 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -17,14 +17,15 @@ class MouseEvent(object): except: return False -class UI(object): - def __init__(self, env, commandlist, colorscheme): +from ranger.shared import EnvironmentAware + +class UI(EnvironmentAware): + def __init__(self, commandlist): import os os.environ['ESCDELAY'] = '25' # don't know a cleaner way - self.env = env self.commandlist = commandlist - self.colorscheme = colorscheme + self.colorscheme = self.env.settings.colorscheme self.is_set_up = False self.win = curses.initscr() @@ -52,7 +53,7 @@ class UI(object): self.resize() def exit(self): - from ranger.helper import log + from ranger import log log("exiting ui!") self.win.keypad(0) curses.nocbreak() @@ -108,7 +109,7 @@ class UI(object): return try: - cmd = self.commandlist.paths[self.env.keybuffer] + cmd = self.commandlist.paths[tuple(self.env.keybuffer)] except KeyError: self.env.key_clear() return diff --git a/ranger/gui/wconsole.py b/ranger/gui/wconsole.py index a0322c42..581745b4 100644 --- a/ranger/gui/wconsole.py +++ b/ranger/gui/wconsole.py @@ -6,13 +6,12 @@ CONSOLE_MODES_DICTIONARY = { '@': 'open with: ' } class WConsole(SuperClass): def __init__(self, win, colorscheme): - from ranger.command import CommandList - from ranger.conf import keys + from ranger.container import CommandList SuperClass.__init__(self, win, colorscheme) self.mode = None self.visible = False self.commandlist = CommandList() - keys.initialize_console_commands(self.commandlist) + self.settings.keys.initialize_console_commands(self.commandlist) self.last_cursor_mode = 1 self.clear() self.prompt = None diff --git a/ranger/gui/wdisplay.py b/ranger/gui/wdisplay.py index fd4f7dec..5e5e80d6 100644 --- a/ranger/gui/wdisplay.py +++ b/ranger/gui/wdisplay.py @@ -70,6 +70,7 @@ class WDisplay(SuperClass): import curses import stat + self.target.use() self.target.load_content_if_outdated() self.target.sort_if_outdated() diff --git a/ranger/gui/widget.py b/ranger/gui/widget.py index 071b88bc..093eee14 100644 --- a/ranger/gui/widget.py +++ b/ranger/gui/widget.py @@ -8,12 +8,12 @@ def combine(keylist, keys): else: return tuple((keylist, ) + keys) -from ranger.conf import SettingsAware +from ranger.shared import SettingsAware class Widget(SettingsAware): - def __init__(self, win, colorscheme): + def __init__(self, win, _): self.win = win self.focused = False - self.colorscheme = colorscheme + self.colorscheme = self.settings.colorscheme self.visible = True self.setdim(0, 0, 0, 0) diff --git a/ranger/gui/wtitlebar.py b/ranger/gui/wtitlebar.py index af8ab0d7..65ed2e33 100644 --- a/ranger/gui/wtitlebar.py +++ b/ranger/gui/wtitlebar.py @@ -4,6 +4,7 @@ class WTitleBar(SuperClass): def feed_env(self, env): self.pathway = env.pathway self.cf = env.cf + self.keybuffer = env.keybuffer def draw(self): import curses, socket, os @@ -30,5 +31,15 @@ class WTitleBar(SuperClass): currentx = self.win.getyx()[1] self.color('in_titlebar', 'file') self.win.addnstr(self.cf.basename, max(self.wid - currentx, 0)) + + self.color('in_titlebar', 'keybuffer') + + kb = str(self.keybuffer) + if self.wid + self.x - currentx > len(kb): + self.win.addstr( + self.y, + self.x + self.wid - len(kb) - 2, + kb) + self.color_reset() diff --git a/ranger/helper.py b/ranger/helper.py deleted file mode 100644 index d9f6270d..00000000 --- a/ranger/helper.py +++ /dev/null @@ -1,111 +0,0 @@ - -LOGFILE = '/tmp/errorlog' - -def log(txt): - f = open(LOGFILE, 'a') - f.write("r1: ") - f.write(str(txt)) - f.write("\n") - f.close() - -class OpenStruct(object): - def __init__(self, __dictionary=None, **__keywords): - if __dictionary: - self.__dict__.update(__dictionary) - if __keywords: - self.__dict__.update(__keywords) - - def __getitem__(self, key): - return self.__dict__[key] - - def __setitem__(self, key, value): - self.__dict__[key] = value - return value - - def __contains__(self, key): - return key in self.__dict__ - -# used to get all colorschemes in ~/.ranger/colorschemes and ranger/colorschemes -def get_all(dirname): - import os - result = [] - for filename in os.listdir(dirname): - if filename.endswith('.py') and not filename.startswith('_'): - result.append(filename[0:filename.index('.')]) - return result - - -ONE_KB = 1024 -UNITS = 'BKMGTP' -MAX_EXPONENT = len(UNITS) - 1 - -def human_readable(byte): - import math - - if not byte: - return '0 B' - - exponent = int(math.log(byte, 2) / 10) - flt = float(byte) / (1 << (10 * exponent)) - - if exponent > MAX_EXPONENT: - return '>9000' # off scale - - if int(flt) == flt: - return '%.0f %s' % (flt, UNITS[exponent]) - - else: - return '%.2f %s' % (flt, UNITS[exponent]) - -def waitpid_no_intr(pid): - """ catch interrupts which occur while using os.waitpid """ - import os, errno - - while True: - try: - return os.waitpid(pid, 0) - except OSError as e: - if e.errno == errno.EINTR: - continue - else: - raise - -import os -null = open(os.devnull, 'a') - -def popen(*args, **kw): - from subprocess import Popen - from subprocess import PIPE - - flags, fm = kw['flags'], kw['fm'] - for flag in flags: - if ord(flag) <= 90: - bad = flag + flag.lower() - flags = ''.join(c for c in flags if c not in bad) - - args = map(str, args) - popen_kw = {} - - if kw['stdin'] is not None: - popen_kw['stdin'] = kw['stdin'] - - if 's' in flags or 'd' in flags: - popen_kw['stdout'] = popen_kw['stderr'] = popen_kw['stdin'] = null - - if 'p' in flags: - popen_kw['stdout'] = PIPE - process1 = Popen(args, **popen_kw) - kw['stdin'] = process1.stdout - kw['files'] = () - kw['flags'] = ''.join(f for f in kw['flags'] if f in 'd') - process2 = kw['apps'].app_pager(**kw) - return process2 - if 'd' in flags: - process = Popen(args, **popen_kw) - return process - else: - fm.ui.exit() - p = Popen(args, **popen_kw) - waitpid_no_intr(p.pid) - fm.ui.initialize() - return p diff --git a/ranger/main.py b/ranger/main.py index 9faf069f..f5453187 100644 --- a/ranger/main.py +++ b/ranger/main.py @@ -4,12 +4,11 @@ from locale import setlocale, LC_ALL from optparse import OptionParser, SUPPRESS_HELP from ranger.fm import FM +from ranger.container import CommandList, Bookmarks from ranger.environment import Environment -from ranger.command import CommandList -from ranger.bookmark import Bookmarks -from ranger.conf import keys, options +from ranger.shared import SettingsAware, EnvironmentAware, FileManagerAware from ranger.gui.defaultui import DefaultUI as UI -from ranger.gui.colorscheme import ColorScheme +from ranger.file import File VERSION = '1.0.0' @@ -53,7 +52,8 @@ def main(): print("File or directory doesn't exist: %s" % target) sys.exit(1) elif os.path.isfile(target): - FM.execute_file(FM(0, 0), target) + thefile = File(target) + FM(0, 0, sys).execute_file(thefile) sys.exit(0) else: path = target @@ -61,23 +61,26 @@ def main(): else: path = '.' - env = Environment(path) + Environment(path) commandlist = CommandList() - keys.initialize_commands(commandlist) + SettingsAware.settings.keys.initialize_commands(commandlist) bookmarks = Bookmarks() bookmarks.load() - my_ui = UI(env, commandlist, options.colorscheme()) - my_fm = FM(env, my_ui, bookmarks) + my_ui = None try: + my_ui = UI(commandlist) + my_fm = FM(my_ui, bookmarks) + # Run the file manager my_ui.initialize() - my_fm.run() + my_fm.loop() finally: # Finish, clean up - my_ui.exit() + if my_ui: + my_ui.exit() if args.cd_after_exit: try: sys.__stderr__.write(env.pwd.path) diff --git a/ranger/mimetype.py b/ranger/mimetype.py deleted file mode 100644 index 5e70f2e7..00000000 --- a/ranger/mimetype.py +++ /dev/null @@ -1,14 +0,0 @@ -types = {'not loaded': True} - -def load(): - import sys, os, pickle - types.clear() - - f = open(os.path.join(os.path.dirname(__file__), '../data/mime.dat'), 'rb') - types.update(pickle.load(f)) - f.close() - -def get(): - if 'not loaded' in types: - load() - return types diff --git a/ranger/shared/__init__.py b/ranger/shared/__init__.py new file mode 100644 index 00000000..eed206d6 --- /dev/null +++ b/ranger/shared/__init__.py @@ -0,0 +1,11 @@ +class Awareness(object): + pass + +from .mimetype import MimeTypeAware +from .settings import SettingsAware + +class EnvironmentAware(Awareness): + env = None + +class FileManagerAware(Awareness): + fm = None diff --git a/ranger/shared/mimetype.py b/ranger/shared/mimetype.py new file mode 100644 index 00000000..ac4ff629 --- /dev/null +++ b/ranger/shared/mimetype.py @@ -0,0 +1,13 @@ +from ranger import relpath +class MimeTypeAware(object): + mimetypes = {} + __initialized = False + def __init__(self): + if not MimeTypeAware.__initialized: + MimeTypeAware.__initialized = True + import os, sys, pickle + MimeTypeAware.mimetypes.clear() + + f = open(relpath('data/mime.dat'), 'rb') + MimeTypeAware.mimetypes.update(pickle.load(f)) + f.close() diff --git a/ranger/conf/__init__.py b/ranger/shared/settings.py index 626fe98e..def09c4e 100644 --- a/ranger/conf/__init__.py +++ b/ranger/shared/settings.py @@ -1,24 +1,13 @@ from inspect import isclass, ismodule -from ranger.helper import OpenStruct +from ranger.ext.openstruct import OpenStruct from ranger.gui.colorscheme import ColorScheme ALLOWED_SETTINGS = """ show_hidden scroll_offset directories_first preview_files max_history_size colorscheme +apps keys """.split() -# -- import the options -- -# either use the custom file or the default file -try: - import keys -except ImportError: - from ranger.defaults import keys - -try: - import apps -except ImportError: - from ranger.defaults import apps - # overwrite single default options with custom options from ranger.defaults import options try: @@ -34,14 +23,15 @@ except ImportError: # If a module is specified as the colorscheme, replace it with one # valid colorscheme inside that module. -if isclass(options.colorscheme) and issubclass(options.colorscheme, ColorScheme): - pass # everything ok +if isclass(options.colorscheme) and \ + issubclass(options.colorscheme, ColorScheme): + options.colorscheme = options.colorscheme() elif ismodule(options.colorscheme): for var_name in dir(options.colorscheme): var = getattr(options.colorscheme, var_name) if var != ColorScheme and isclass(var) and issubclass(var, ColorScheme): - options.colorscheme = var + options.colorscheme = var() break else: raise Exception("The given colorscheme module contains no valid colorscheme!") |