ruco 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +5 -3
- data/VERSION +1 -1
- data/bin/ruco +6 -1
- data/lib/ruco.rb +2 -1
- data/lib/ruco/keyboard.rb +12 -5
- data/lib/ruco/version.rb +3 -0
- data/ruco.gemspec +3 -2
- data/spec/ruco/keyboard_spec.rb +7 -0
- metadata +5 -4
data/Rakefile
CHANGED
@@ -28,11 +28,13 @@ task :key do
|
|
28
28
|
Curses.raw # give us all other keys
|
29
29
|
Curses.stdscr.nodelay = 1 # do not block -> we can use timeouts
|
30
30
|
Curses.init_screen
|
31
|
+
nothing = (2**32 - 1)
|
32
|
+
|
31
33
|
|
32
34
|
count = 0
|
33
35
|
loop do
|
34
|
-
key = Curses.getch ||
|
35
|
-
next if key
|
36
|
+
key = Curses.getch || nothing
|
37
|
+
next if key >= nothing
|
36
38
|
exit if key == 3 # Ctrl+c
|
37
39
|
count = (count + 1) % 20
|
38
40
|
Curses.setpos(count,0)
|
@@ -53,4 +55,4 @@ begin
|
|
53
55
|
Jeweler::GemcutterTasks.new
|
54
56
|
rescue LoadError
|
55
57
|
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
56
|
-
end
|
58
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.25
|
data/bin/ruco
CHANGED
@@ -21,6 +21,11 @@ Options:
|
|
21
21
|
BANNER
|
22
22
|
opts.on("--debug-cache","Show caching in action") { options[:debug_cache] = true }
|
23
23
|
opts.on("--debug-keys", "Show pressed keys") { options[:debug_keys] = true }
|
24
|
+
opts.on('-v', '--version','Show Version'){
|
25
|
+
require 'ruco/version'
|
26
|
+
puts Ruco::VERSION
|
27
|
+
exit
|
28
|
+
}
|
24
29
|
opts.on("-h", "--help","Show this.") { puts opts; exit }
|
25
30
|
end
|
26
31
|
parser.parse!
|
@@ -101,7 +106,7 @@ end
|
|
101
106
|
def debug_key(key)
|
102
107
|
@key_line ||= -1
|
103
108
|
@key_line = (@key_line + 1) % Curses.stdscr.maxy
|
104
|
-
write(@key_line, 0, "#{key}---")
|
109
|
+
write(@key_line, 0, "#{key.inspect}---")
|
105
110
|
end
|
106
111
|
|
107
112
|
def log(stuff)
|
data/lib/ruco.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ruco/version'
|
2
|
+
|
1
3
|
require 'ruco/core_ext/object'
|
2
4
|
require 'ruco/core_ext/string'
|
3
5
|
require 'ruco/core_ext/array'
|
@@ -19,7 +21,6 @@ require 'ruco/text_field'
|
|
19
21
|
module Ruco
|
20
22
|
autoload :Clipboard, 'clipboard' # can crash when loaded -> load if needed
|
21
23
|
|
22
|
-
VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
|
23
24
|
TAB_SIZE = 2
|
24
25
|
|
25
26
|
class << self
|
data/lib/ruco/keyboard.rb
CHANGED
@@ -5,7 +5,7 @@ class Keyboard
|
|
5
5
|
ENTER = 13
|
6
6
|
IS_18 = RUBY_VERSION =~ /^1\.8/
|
7
7
|
SEQUENCE_TIMEOUT = 0.01
|
8
|
-
NOTHING =
|
8
|
+
NOTHING = (2**32 - 1) # getch returns this as 'nothing' on 1.8 but nil on 1.9.2
|
9
9
|
A_TO_Z = ('a'..'z').to_a
|
10
10
|
|
11
11
|
def self.input(&block)
|
@@ -22,11 +22,18 @@ class Keyboard
|
|
22
22
|
if needs_paste_fix?(@sequence)
|
23
23
|
yield bytes_to_string(@sequence)
|
24
24
|
else
|
25
|
-
|
25
|
+
# weird stuff that happens when connected via ssh
|
26
|
+
if @sequence == [27, 91, 49, 59, 50, 65]
|
27
|
+
yield :"Shift+up"
|
28
|
+
elsif @sequence == [27, 91, 49, 59, 50, 66]
|
29
|
+
yield :"Shift+down"
|
30
|
+
else
|
31
|
+
bytes_to_key_codes(@sequence).each{|c| yield c }
|
32
|
+
end
|
26
33
|
end
|
27
34
|
@sequence = nil
|
28
35
|
end
|
29
|
-
next
|
36
|
+
next unless key
|
30
37
|
start_or_append_sequence key
|
31
38
|
end
|
32
39
|
end
|
@@ -75,8 +82,8 @@ class Keyboard
|
|
75
82
|
end
|
76
83
|
|
77
84
|
def self.fetch_user_input
|
78
|
-
key = @input.call
|
79
|
-
|
85
|
+
key = @input.call
|
86
|
+
return if key.nil? or key >= NOTHING
|
80
87
|
key = key.ord if key.is_a?(String) # ruby 1.9 fix
|
81
88
|
key
|
82
89
|
end
|
data/lib/ruco/version.rb
ADDED
data/ruco.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruco}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.25"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-25}
|
13
13
|
s.default_executable = %q{ruco}
|
14
14
|
s.email = %q{michael@grosser.it}
|
15
15
|
s.executables = ["ruco"]
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
"lib/ruco/status_bar.rb",
|
36
36
|
"lib/ruco/text_area.rb",
|
37
37
|
"lib/ruco/text_field.rb",
|
38
|
+
"lib/ruco/version.rb",
|
38
39
|
"ruco.gemspec",
|
39
40
|
"spec/ruco/application_spec.rb",
|
40
41
|
"spec/ruco/command_bar_spec.rb",
|
data/spec/ruco/keyboard_spec.rb
CHANGED
@@ -85,4 +85,11 @@ describe Keyboard do
|
|
85
85
|
type [11121, 324234]
|
86
86
|
output.should == [11121, 324234]
|
87
87
|
end
|
88
|
+
|
89
|
+
it "recognises weird key combos" do
|
90
|
+
type [27, 91, 49, 59, 50, 65]
|
91
|
+
output.should == [:"Shift+up"]
|
92
|
+
type [27, 91, 49, 59, 50, 66]
|
93
|
+
output.should == [:"Shift+down"]
|
94
|
+
end
|
88
95
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 45
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 25
|
10
|
+
version: 0.0.25
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Grosser
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-25 00:00:00 +01:00
|
19
19
|
default_executable: ruco
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/ruco/status_bar.rb
|
65
65
|
- lib/ruco/text_area.rb
|
66
66
|
- lib/ruco/text_field.rb
|
67
|
+
- lib/ruco/version.rb
|
67
68
|
- ruco.gemspec
|
68
69
|
- spec/ruco/application_spec.rb
|
69
70
|
- spec/ruco/command_bar_spec.rb
|