Method: RubyCurses::TextView#edit_external
- Defined in:
- lib/rbcurse/core/widgets/rtextview.rb
#edit_external ⇒ Object
edit content of textview in EDITOR and bring back NOTE: does not maintain content_type, so if you edit ansi text, it will come back in as normal text
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
# File 'lib/rbcurse/core/widgets/rtextview.rb', line 712 def edit_external require 'rbcurse/core/include/appmethods' require 'tempfile' f = Tempfile.new("rbcurse") l = self.text l.each { |line| f.puts line } fp = f.path f.flush editor = ENV['EDITOR'] || 'vi' vimp = %x[which #{editor}].chomp ret = shell_out "#{vimp} #{fp}" if ret lines = File.open(f,'r').readlines set_content(lines, :content_type => @old_content_type) end end |