null+****@clear*****
null+****@clear*****
Wed Jul 18 13:09:50 JST 2012
SUZUKI Miho 2012-07-18 13:09:50 +0900 (Wed, 18 Jul 2012) New Revision: f9a52db6f637d391d30905e07bbd69727f316888 https://github.com/logaling/logaling-command/commit/f9a52db6f637d391d30905e07bbd69727f316888 Log: Calculate print size for terminal output Modified files: lib/logaling/command/application.rb Modified: lib/logaling/command/application.rb (+6 -2) =================================================================== --- lib/logaling/command/application.rb 2012-07-12 11:31:32 +0900 (7e2f1e1) +++ lib/logaling/command/application.rb 2012-07-18 13:09:50 +0900 (92f34f2) @@ -262,7 +262,7 @@ module Logaling::Command end terms =****@repos*****(source_term, glossary, options["dictionary"]) unless terms.empty? - max_str_size = terms.map{|term| term[:source_term].size}.sort.last + max_str_size = terms.map{|term| term_print_size(term[:source_term])}.sort.last run_pager terms.each_with_index do |term, i| case options["output"] @@ -311,7 +311,7 @@ module Logaling::Command terms = glossary.terms unless terms.empty? run_pager - max_str_size = terms.map{|term| term[:source_term].size}.sort.last + max_str_size = terms.map{|term| term_print_size(term[:source_term])}.sort.last terms.each do |term| target_string = "#{term[:target_term]}" target_string << "\t# #{term[:note]}" unless term[:note].empty? @@ -379,5 +379,9 @@ module Logaling::Command @repository.register(@dotfile_path, @config.glossary) @repository.index end + + def term_print_size(string) + string.each_char.map{|char| char.bytesize == 1 ? 1 : 2}.inject(0, &:+) + end end end -------------- next part -------------- An HTML attachment was scrubbed...Télécharger