diff options
author | hut <hut@lavabit.com> | 2009-06-18 01:56:01 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-06-18 01:56:01 +0200 |
commit | 9097b81b515f05c5e0e3eb76b6c51f2f374dc23a (patch) | |
tree | 0d1495c516544dc4f2a55024fc557b5e862d9fb9 /data | |
parent | c747b1f7d103018291d83a03eec29a9ad3e54ed6 (diff) | |
download | ranger-9097b81b515f05c5e0e3eb76b6c51f2f374dc23a.tar.gz |
more comments
Diffstat (limited to 'data')
-rw-r--r-- | data/apps.rb | 45 | ||||
-rw-r--r-- | data/types.rb | 19 |
2 files changed, 51 insertions, 13 deletions
diff --git a/data/apps.rb b/data/apps.rb index 9c300f56..18856262 100644 --- a/data/apps.rb +++ b/data/apps.rb @@ -1,4 +1,42 @@ +## This file defines programs, and HOW those +## programs are run. +## +## Look at the definition of "totem" for a +## fully documented example. + + module Application + + ## def totem(files) starts the definition of totem + def totem(files) + ## this is the `case' statement. + ## it looks up the mode and does different + ## things depending on the mode. + case files.mode + + ## if the mode is 0 (default) + when 0 + ## start totem in fullscreen + "totem --fullscreen #{files}" + + ## if the mode is 1 + when 1 + ## start totem normally + "totem #{files}" + end + + ## the mode is a number which you type in + ## between two r's. for example, press: + ## r1r + ## to run the file in mode 1. + ## there are shortcuts: the key l runs in mode 0, + ## and L in mode 1. + + ## the variable `files' is of a type RunContext, + ## see ranger/code/runcontext.rb for details. + end + + def aunpack(files) case files.mode when 0; "aunpack #{files}" @@ -10,13 +48,6 @@ module Application "gedit #{files}" end - def totem(files) - case files.mode - when 0; "totem --fullscreen #{files}" - when 1; "totem #{files}" - end - end - def mplayer(files) case files.mode when 0; "mplayer -fs -sid 0 #{files}" diff --git a/data/types.rb b/data/types.rb index f1e3d24e..97648ec0 100644 --- a/data/types.rb +++ b/data/types.rb @@ -1,3 +1,10 @@ +## This file specifies WHAT program is run, +## depending on the file. +## +## as soon as a "use.myprogram" is reached, +## this programm will be used an the function +## is finished. + class Directory::Entry def get_handler ## directories or sockets don't have any handler @@ -28,7 +35,7 @@ class Directory::Entry when /^image/ use.feh - when /^(text|application)\/x-(#{INTERPRETED_LANGUAGES.join('|')})$/ + when /^(text|application)\/x-(#{INTR})$/ use.interpreted_language when 'text/x-java' @@ -53,14 +60,14 @@ class Directory::Entry ## is it executable? - if executable? - use.vi_or_run - end + use.vi_or_run if executable? - ## otherwise use vi + ## if there is nothing found, use a default application, + ## for example a text- or hex-editor. use.vi end - INTERPRETED_LANGUAGES = %w[haskell perl python ruby sh] + ## interpreted languages + INTR = %w[haskell perl python ruby sh].join('|') end |