module Dmenu
Public Class Methods
alignr(lhs, r, w)
click to toggle source
# File lib/dmenu.rb, line 86 def self.alignr(lhs, r, w) x = r str = lhs + x while str.width < w x = '.' + x str = lhs + x end str end
scrunch(str, size, dots='...')
click to toggle source
# File lib/dmenu.rb, line 95 def self.scrunch(str, size, dots='...') if str.nil? nil elsif str.width < size str else middle = str.length / 2 # Not centered; intentional lhs = str[0..middle] rhs = str[-middle..-1] lr = false while str.width > size if lr lhs = lhs[0..-2] else rhs = rhs[1..-1] end lr = !lr str = lhs + dots + rhs end str end end