exe/helpline in helpline-0.1.14 vs exe/helpline in helpline-0.1.15

- old
+ new

@@ -96,24 +96,26 @@ def disp(list,sel) Curses.move(0,0) lines = list.length lines = LINES if lines > LINES (0...lines).each { |i| - Curses.move(i,0) - s = "* #{list[i][0]}" + Curses.move(i*2,0) + s = "#{list[i][0]}" if i == sel Curses.print_inverse s else - Curses.print s + Curses.print_bold s end + Curses.move(i*2+1,0) + Curses.print " % " + list[i][1] } - Curses.move(sel,0) + Curses.move(sel*2,0) # Curses.down # Curses.tol end - def helpline + def helpline(options) data = JSON.parse(File.read(datafile)) unless data['pages'] # データ型式変換があったので getdata data = JSON.parse(File.read(datafile)) end @@ -128,29 +130,35 @@ g = ExpandRuby::Generator.new # re_expandのジェネレータ # # HelpLineエントリ # + + # File.open("/tmp/defs","w"){ |f| # ログを残す場合 + entries = [] data['defs'].each { |line| if line =~ /^\s*\$\s*(.*)$/ # $.... entries << $1 elsif line =~ /^\s*\%\s*(.*)$/ # %.... cmd = $1 entries.each { |l| desc = eval('"' + l + '"') + # f.puts "desc #{desc}" g.add desc.force_encoding('utf-8'), cmd.force_encoding('utf-8') } entries = [] end } + # } res = g.generate " #{ARGV.join(' ').sub(/\[/,'').sub(/\]/,'')} " File.open("/tmp/helpline.cmd","w"){ |f| f.puts ARGV.join(' ') } + if res[0].length == 0 puts "ヘルプがみつかりません" exit end @@ -169,10 +177,15 @@ listed[a[1]] = true end end } + if options['t'] then + puts list + exit + end + # # HelpLineメニュー表示し、カーソル移動で選択 # help_number = {} list.each_with_index { |entry,ind| @@ -224,17 +237,18 @@ end desc = list[sel.to_i][0] cmd = list[sel][1] - Curses.move(lines,0) + Curses.move(lines*2,0) Curses.tol #Curses.move(0,0) ##Curses.down - Curses.print_inverse("「#{desc}」を実行") - puts " (ソース: http://scrapbox.io/HelpLine/#{data['pages'][help_number[desc]]})" + + # Curses.print_inverse("「#{desc}」を実行") + # puts " (ソース: http://scrapbox.io/HelpLine/#{data['pages'][help_number[desc]]})" File.open("/tmp/helpline.cmd","w"){ |f| f.puts cmd } end end @@ -243,19 +257,19 @@ # unless is_repository # STDERR.puts "Gitレポジトリで実行して下さい" # exit # end -options = ARGV.getopts('u') +options = ARGV.getopts('ut') helpline = HelpLine.new if !File.exist?(helpline.datafile) && !options['u'] puts "#{helpline.datafile}を作成します..." helpline.getdata end - + if options['u'] then helpline.getdata -else - helpline.helpline +else + helpline.helpline(options) end