diff options
-rw-r--r-- | code/directory.rb | 2 | ||||
-rw-r--r-- | code/draw.rb | 8 | ||||
-rw-r--r-- | code/entry.rb | 4 | ||||
-rw-r--r-- | code/extensions/basic.rb | 8 | ||||
-rwxr-xr-x | ranger.rb | 1 |
5 files changed, 18 insertions, 5 deletions
diff --git a/code/directory.rb b/code/directory.rb index c738b995..646a15df 100644 --- a/code/directory.rb +++ b/code/directory.rb @@ -142,7 +142,7 @@ class Directory @width = 0 @files[pos, lines-2].each_with_index do |fn, ix| ix += pos - sz = fn.basename.size + fn.infostring.size + 2 + sz = fn.displayname.size + fn.infostring.size + 2 @width = sz + 3 if @width < sz end # @width = @files[pos,lines-2].map{|x| File.basename(x).size}.max diff --git a/code/draw.rb b/code/draw.rb index aaca6253..84e0e9b4 100644 --- a/code/draw.rb +++ b/code/draw.rb @@ -102,7 +102,7 @@ module Fm :file end - fn = f.basename + fn = f.displayname fn = "* #{fn}" if f.marked? @@ -229,8 +229,8 @@ module Fm end s1 = "#{Socket.gethostname}:" - s2 = "#{@path.last.path}#{"/" unless @path.size == 1}" - s3 = "#{cf ? cf.basename : ''}" + s2 = "#{@path.last.path.ascii_only_if(Option.ascii_only)}#{"/" unless @path.size == 1}" + s3 = "#{cf ? cf.displayname : ''}" if s0 puti 0, (s1 + s2 + s3).ljust(cols-s0.size) @@ -291,7 +291,7 @@ module Fm puti btm, "#@buffer #{@pwd.file_size.bytes(false)}, #{@pwd.free_space.bytes(false)} free, #{@pwd.size}, #{@pwd.pos+1} ".rjust(cols) more = '' if cf.symlink? - more = "#{cf.readlink}" + more = "#{cf.readlink.ascii_only_if(Option.ascii_only)}" end attr_set(Color.date) diff --git a/code/entry.rb b/code/entry.rb index 9f0cb7b9..af1faa83 100644 --- a/code/entry.rb +++ b/code/entry.rb @@ -70,6 +70,10 @@ class Directory::Entry alias movie? video? alias sound? audio? + def displayname() + @displayname ||= @basename.ascii_only_if(Option.ascii_only) + end + def handler() ## get_handler has to be defined in another file @handler ||= catch(:use) do diff --git a/code/extensions/basic.rb b/code/extensions/basic.rb index dd2f0fd0..728af9c3 100644 --- a/code/extensions/basic.rb +++ b/code/extensions/basic.rb @@ -33,6 +33,14 @@ class String end end + def ascii_only() + gsub(/[^!-~\s]/, '*') + end + + def ascii_only_if(bool) + bool ? ascii_only : dup + end + def from_first(str) self.include?(str) ? self [ self.index(str) + str.size .. -1 ] : nil end diff --git a/ranger.rb b/ranger.rb index 3bfdf17b..7fbe4824 100755 --- a/ranger.rb +++ b/ranger.rb @@ -36,6 +36,7 @@ opt = { :sort_reverse => false, :cd => ARGV.include?('--cd'), :colorscheme => true, + :ascii_only => true, :wide_bar => true, :file_preview => true, :preview => true, |