class TermImages::Image::W3MImageDisplayer
Public Class Methods
new()
click to toggle source
# File lib/term-images.rb, line 44 def initialize @w3mimgdisplay = "/usr/lib/w3m/w3mimgdisplay" end
Public Instance Methods
run(path)
click to toggle source
# File lib/term-images.rb, line 50 def run path fonth=12 fontw=8 columns=`tput cols`.chomp.to_i lines=`tput lines`.chomp.to_i arr = `echo -e "5;#{path}" | #{@w3mimgdisplay}`.chomp.split(" ") width = arr[0].to_i height = arr[1].to_i max_width=fontw * columns max_height=fonth * (lines - 2) # substract one line for prompt if width > max_width height=(height * max_width / width) width=max_width end if height > max_height width=(width * max_height / height) height=max_height end c = Cursor.pos (height / fonth).to_i.times do puts end w3m_command="0;1;#{c[:column] * fontw};#{c[:row] * fonth};#{width};#{height};;;;;#{path}\\n4;\\n3;" `tput cup #{height/fonth} 0` `echo -e "#{w3m_command}"|#{@w3mimgdisplay}` end
supported?()
click to toggle source
# File lib/term-images.rb, line 47 def supported? File.exists? @w3mimgdisplay end