rawline 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +42 -30
- data/examples/rawline_irb.rb +27 -0
- data/examples/rawline_rush.rb +27 -0
- data/examples/rawline_shell.rb +26 -26
- data/examples/readline_emulation.rb +17 -17
- data/lib/rawline/editor.rb +705 -704
- data/lib/rawline/history_buffer.rb +134 -134
- data/lib/rawline/line.rb +169 -168
- data/lib/rawline.rb +109 -119
- data/spec/editor_spec.rb +167 -167
- metadata +4 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,30 +1,42 @@
|
|
1
|
-
== Version 0.3.
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
* Fixed #
|
8
|
-
* Fixed #
|
9
|
-
*
|
10
|
-
*
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
*
|
16
|
-
*
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
*
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
1
|
+
== Version 0.3.1
|
2
|
+
|
3
|
+
* Renamed completion_append_char to complation_append_character (Readline compatibility).
|
4
|
+
* Fixed minor bugs in HistoryBuffer (push and << methods are now redefined properly).
|
5
|
+
* The string returned by Editor#read (and Rawline#readline) does not contain a trailing newline character anymore (Readline compatibility)
|
6
|
+
* It is now possible to set Line#word_separator to an empty string or nil (Readline compatibility).
|
7
|
+
* Fixed #6 (Fixnum#ord not defined on Ruby 1.8.6)
|
8
|
+
* Fixed #7 (Win32Console gem not required)
|
9
|
+
* Fixed #8 (Rawline.version not defined)
|
10
|
+
* Fixed #9 (Readline compatibility issues)
|
11
|
+
|
12
|
+
|
13
|
+
== Version 0.3.0
|
14
|
+
|
15
|
+
* Fixed linux-specific bugs.
|
16
|
+
* Added RawLine::Line#words method, which returns the words typed in the current line.
|
17
|
+
* undo and redo action now bound to C-u and C-r instead of C-z and C-y to avoid conflicts on Linux.
|
18
|
+
* test file and directory renaming.
|
19
|
+
* Fixed #1 [#21300] bad requirement because sensitive case error.
|
20
|
+
* Fixed #2 [#21301] unitialized constant when no WIN32CONSOLE.
|
21
|
+
* Added Ruby 1.9.1 support.
|
22
|
+
* Editor#read now takes an optional parameter (default: false) to enable or disable history.
|
23
|
+
* Line is no longer added to history when calling Editor#history_back.
|
24
|
+
* Added Editor#filename_completion_proc.
|
25
|
+
* Editor#completion_proc defaults to Editor#filename_completion_proc.
|
26
|
+
* RawLine is now a drop-in replacement for Readline.
|
27
|
+
* Added examples/readline_emulation.rb.
|
28
|
+
* Moved repository to GitHub.
|
29
|
+
|
30
|
+
== Version 0.2.0
|
31
|
+
|
32
|
+
* Added /examples and /test directory to gem.
|
33
|
+
* Escape codes can now be used in prompt.
|
34
|
+
* It is now possible to use bind(key, &block) with a String as key, even if the corresponding escape sequence is not defined.
|
35
|
+
* Added Editor#write_line(string) to print a any string (and "hit return").
|
36
|
+
* 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).
|
37
|
+
* Provided alternative implementation for left and right arrows if terminal
|
38
|
+
supports escape sequences (on Windows, it requires the Win32Console gem).
|
39
|
+
|
40
|
+
== Version 0.1.0
|
41
|
+
|
42
|
+
First preview release of InLine, implementing some of the functionality provided by the ReadLine library such as basic line editing, history and word completion.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'irb'
|
4
|
+
require 'irb/completion'
|
5
|
+
require File.dirname(File.expand_path(__FILE__))+'/../lib/rawline'
|
6
|
+
|
7
|
+
Rawline.basic_word_break_characters= " \t\n\"\\'`><;|&{("
|
8
|
+
Rawline.completion_append_character = nil
|
9
|
+
Rawline.completion_proc = IRB::InputCompletor::CompletionProc
|
10
|
+
|
11
|
+
class RawlineInputMethod < IRB::ReadlineInputMethod
|
12
|
+
include Rawline
|
13
|
+
def gets
|
14
|
+
if l = readline(@prompt, false)
|
15
|
+
HISTORY.push(l) if !l.empty?
|
16
|
+
@line[@line_no += 1] = l + "\n"
|
17
|
+
else
|
18
|
+
@eof = true
|
19
|
+
l
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module IRB
|
25
|
+
@CONF[:SCRIPT] = RawlineInputMethod.new
|
26
|
+
end
|
27
|
+
IRB.start
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rush'
|
5
|
+
require File.dirname(File.expand_path(__FILE__))+'/../lib/rawline'
|
6
|
+
|
7
|
+
class RawlineRush < Rush::Shell
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
Rawline.basic_word_break_characters = ""
|
11
|
+
Rawline.completion_proc = completion_proc
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
loop do
|
17
|
+
cmd = Rawline.readline('rawline_rush> ')
|
18
|
+
finish if cmd.nil? or cmd == 'exit'
|
19
|
+
next if cmd == ""
|
20
|
+
Rawline::HISTORY.push(cmd)
|
21
|
+
execute(cmd)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
shell = RawlineRush.new.run
|
27
|
+
|
data/examples/rawline_shell.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
#!usr/bin/env ruby
|
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+G 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_g) { 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("=> ", true)
|
26
|
-
end
|
1
|
+
#!usr/bin/env ruby
|
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+G 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_g) { 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("=> ", true)}]"
|
26
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
#!usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.dirname(File.expand_path(__FILE__))+'/../lib/rawline'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
puts "
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
loop do
|
16
|
-
puts "You typed: [#{readline("=> ", true)
|
17
|
-
end
|
1
|
+
#!usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(File.expand_path(__FILE__))+'/../lib/rawline'
|
4
|
+
|
5
|
+
puts "*** Readline emulation Test Shell ***"
|
6
|
+
puts " * Press CTRL+X to exit"
|
7
|
+
puts " * Press <TAB> for file completion"
|
8
|
+
|
9
|
+
Rawline.editor.bind(:ctrl_x) { puts; puts "Exiting..."; exit }
|
10
|
+
|
11
|
+
Dir.chdir '..'
|
12
|
+
|
13
|
+
include Rawline
|
14
|
+
|
15
|
+
loop do
|
16
|
+
puts "You typed: [#{readline("=> ", true)}]"
|
17
|
+
end
|