#!/usr/bin/env ruby # encoding: UTF-8 require 'rubygems' gem 'clipboard' require 'curses' require 'optparse' $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) def parse_options options = {} parser = OptionParser.new do |opts| opts.banner = < test if it works) def activate_256_colors require 'ruco/file_store' ( # not windows RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ and # possible to open xterm-256color ['xterm', 'xterm-256color'].include?(ENV['TERM']) and Ruco::FileStore.new('~/.ruco/cache').cache('color_possible'){ system(%{TERM=xterm-256color ruby -r curses -e 'Curses.noecho' > /dev/null 2>&1}) } # finally switch terminal, so curses knows we want colors ) and ENV['TERM'] = 'xterm-256color' end options = parse_options $ruco_colors = if options[:no_colors] false elsif options[:colors] true else activate_256_colors end require 'ruco' # draw app and redraw after each keystroke (or paste) Ruco::Screen.open(options) do |screen| app = Ruco::Application.new(ARGV[0], :convert_tabs => options[:convert_tabs], :undo_stack_size => options[:undo_stack_size], :lines => screen.lines, :columns => screen.columns ) screen.draw *app.display_info Keyboard.input do Curses.getch end Keyboard.output do |key| screen.debug_key(key) if options[:debug_keys] if key == :resize app.resize(screen.lines, screen.columns) screen.clear_cache else result = app.key key break if result == :quit end screen.draw *app.display_info end end