grosser / ruco

Desktop-style, Intuitive, Commandline Editor in Ruby. "Better than nano, simpler than vim."
MIT License
130 stars 10 forks source link

Simple, extendable, test-driven commandline editor written in ruby, for Linux/Mac/Windows.

Features

ruco with railscasts theme

Install

gem install ruco

Usage

ruco file.rb
rvmsudo ruco /etc/hosts

Customize

# ~/.ruco.rb
Ruco.configure do
  # set options
  options.window_line_scroll_offset = 5 # default 1
  options.history_entries = 10          # default 100
  options.editor_remove_trailing_whitespace_on_save = true  # default false
  options.editor_blank_line_before_eof_on_save = true       # default false
  options.editor_line_numbers = true                        # default false

  # Use any Textmate theme e.g. from http://wiki.macromates.com/Themes/UserSubmittedThemes
  # use a url that points directly to the theme, e.g. github 'raw' urls
  options.color_theme = "https://raw.github.com/deplorableword/textmate-solarized/master/Solarized%20%28dark%29.tmTheme"
  ...

  # bind a key
  # - you can use Integers and Symbols
  # - use "ruco --debug-keys foo" to see which keys are possible
  # - have a look at [keyboard.rb](https://github.com/grosser/dispel/blob/master/lib/dispel/keyboard.rb)
  bind(:"Ctrl+e") do
    ask('foo') do |response|
      if response == 'bar'
        editor.insert('baz')
      else
        editor.move(:to, 0,0)
        editor.delete(99999)
        editor.insert('FAIL!')
      end
    end
  end

  # bind an existing action
  puts @actions.keys

  bind :"Ctrl+x", :quit
  bind :"Ctrl+o", :save
  bind :"Ctrl+k", :delete_line
  bind :"Ctrl+a", :move_to_bol

  # create reusable actions
  action(:first_line){ editor.move(:to_column, 0) }
  bind :"Ctrl+u", :first_line
end

TIPS

Architecture

Ruco is basically a lot of String manipulation separated in HTML style elements. The only component dealing with the commandline interface are Screen and Keyboard. Therefore everything is very simple to build and test since it returns a string or a e.g. cursor position.

Writing/reading is done in a TextArea or a TextField (a TextArea with 1 line) which are placed in Form`s.

The Application consists of a StatusBar, Editor, CommandBar and delegates actions to the currently active element.

To build the commandline output Editor/CommandBar return:

TODO

Authors

Contributors

Michael Grosser
grosser.michael@gmail.com
License: MIT