rawline 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,13 @@
1
+ == Version 0.2.0
2
+
3
+ * Added /examples and /test directory to gem.
4
+ * Escape codes can now be used in prompt.
5
+ * It is now possible to use bind(key, &block) with a String as key, even if the corresponding escape sequence is not defined.
6
+ * Added Editor#write_line(string) to print a any string (and "hit return").
7
+ * Library name changed to "RawLine" to avoid name collision issues (Bug 18879: http://rubyforge.org/tracker/?func=detail&aid=18879&group_id=5622&atid=21788).
8
+ * Provided alternative implementation for left and right arrows if terminal
9
+ supports escape sequences (on Windows, it requires the Win32Console gem).
10
+
11
+ == Version 0.1.0
12
+
13
+ First preview release of InLine, implementing some of the functionality provided by the ReadLine library such as basic line editing, history and word completion.
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Copyright (c) 2008, Fabio Cevasco
2
+ All rights reserved.
3
+
4
+ - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+ - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+ - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7
+ Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
8
+
9
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10
+
11
+
data/README ADDED
@@ -0,0 +1,43 @@
1
+ = RawLine
2
+
3
+ RawLine was created to provide a 100% Ruby alternative to the ReadLine library, providing some of its most popular features such as:
4
+
5
+ * Basic line editing operations
6
+ * Word completion
7
+ * History Management
8
+ * Custom key/key sequences bindings
9
+
10
+ == Installation
11
+
12
+ The simplest method to install RawLine is to install the gem:
13
+
14
+ gem install -r rawline
15
+
16
+ == Usage
17
+
18
+ Editor initialization:
19
+
20
+ require 'rawline'
21
+ editor = RawLine::Editor.new
22
+
23
+ Key binding:
24
+
25
+ editor.bind(:ctrl_z) { editor.undo }
26
+ editor.bind(:up_arrow) { editor.history_back }
27
+ editor.bind(:ctrl_x) { puts "Exiting..."; exit }
28
+
29
+ Setup word completion
30
+
31
+ editor.completion_proc = lambda do |word|
32
+ if word
33
+ ['select', 'update', 'delete', 'debug', 'destroy'].find_all { |e| e.match(/^#{Regexp.escape(word)}/) }
34
+ end
35
+ end
36
+ editor.completion_append_string = " "
37
+
38
+ Read input:
39
+
40
+ editor.read("=> ")
41
+
42
+
43
+
@@ -0,0 +1,19 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ require 'rubygems'
4
+ require 'highline/system_extensions'
5
+
6
+ include HighLine::SystemExtensions
7
+
8
+ puts "Press a key to view the corresponding ASCII code(s) (or CTRL-X to exit)."
9
+
10
+ loop do
11
+
12
+ print "=> "
13
+ char = get_character
14
+ case char
15
+ when ?\C-x: print "Exiting..."; exit;
16
+ else puts "#{char.chr} [#{char}] (hex: #{char.to_s(16)})";
17
+ end
18
+
19
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ require File.dirname(File.expand_path(__FILE__))+'/../lib/rawline'
4
+
5
+ puts "*** Rawline Editor Test Shell ***"
6
+ puts " * Press CTRL+X to exit"
7
+ puts " * Press CTRL+C to clear command history"
8
+ puts " * Press CTRL+D for line-related information"
9
+ puts " * Press CTRL+E to view command history"
10
+
11
+ editor = RawLine::Editor.new
12
+
13
+ editor.bind(:ctrl_c) { editor.clear_history }
14
+ editor.bind(:ctrl_d) { editor.debug_line }
15
+ editor.bind(:ctrl_e) { editor.show_history }
16
+ editor.bind(:ctrl_x) { puts; puts "Exiting..."; exit }
17
+
18
+ editor.completion_proc = lambda do |word|
19
+ if word
20
+ ['select', 'update', 'delete', 'debug', 'destroy'].find_all { |e| e.match(/^#{Regexp.escape(word)}/) }
21
+ end
22
+ end
23
+
24
+ loop do
25
+ puts "You typed: [#{editor.read("=> ").chomp!}]"
26
+ end