Code Monkey home page Code Monkey logo

coolline's Introduction

Coolline

Coolline is a simple readline-like library that allows you to change the way the input is displayed while theuser is typing. This is meant to allow the implementation of live syntax highlighting:

require 'coolline'
require 'coderay'
require 'pp'

cool = Coolline.new do |c|
  c.transform_proc = proc do
    CodeRay.scan(c.line, :ruby).term
  end

  c.completion_proc = proc do
    word = c.completed_word
    Object.constants.map(&:to_s).select { |w| w.start_with? word }
  end
end

loop do
  line = cool.readline

  obj  = eval(line)

  print "=> "
  pp obj
end

Configuration

Coolline automatically loads a config file before starting, which allows adding new key bindings to it. The file is just a chunk of arbitrary ruby code located at $XDG_CONFIG_HOME/coolline/coolline.rb.

 Coolline.bind "\C-z" do |cool|
   puts "Testing key binding with #{cool}!"
 end

Installation

gem install coolline

Notice this needs io-console (which is part of Ruby 1.9.3).

coolline's People

Contributors

mon-ouie avatar swarley avatar seydar avatar kyrylo avatar conradirwin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.