fancy_irb 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ == 0.6.5
2
+ * Windows support
3
+
4
+ == < 0.6.5
5
+ See https://github.com/janlelis/fancy_irb/commits/0.6.4
data/README.rdoc CHANGED
@@ -70,6 +70,10 @@ You can modify how to get and display the input. The <tt>result_proc</tt> is a p
70
70
  end
71
71
  }
72
72
 
73
+ == FancyIrb on Windows?
74
+
75
+ You need ansicon[https://github.com/adoxa/ansicon] and everything will be fine :D
76
+
73
77
  == Example configurations
74
78
 
75
79
  === Default
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.4
1
+ 0.6.5
data/fancy_irb.gemspec CHANGED
@@ -14,13 +14,15 @@ Gem::Specification.new do |s|
14
14
  #s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
15
15
  s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
16
16
  s.license = 'MIT'
17
- s.add_dependency('wirb', '>= 0')
18
- s.add_dependency('unicode-display_width', ">= 0")
17
+ s.requirements = ['On Windows, you need ansicon: https://github.com/adoxa/ansicon']
18
+ s.add_dependency('wirb', '>= 0.2.4')
19
+ s.add_dependency('unicode-display_width', ">= 0.1.1")
19
20
  s.files = [
20
21
  "LICENSE",
21
22
  "README.rdoc",
22
23
  "Rakefile",
23
24
  "VERSION",
25
+ "CHANGELOG.rdoc",
24
26
  "fancy_irb.gemspec",
25
27
  "lib/fancy_irb.rb",
26
28
  "lib/fancy_irb/irb_ext.rb"
@@ -8,12 +8,21 @@ end
8
8
 
9
9
  module IRB
10
10
  class Irb
11
- TPUT = {
12
- :sc => `tput sc`,
13
- :rc => `tput rc`,
14
- :cuu1 => `tput cuu1`,
15
- :cuf1 => `tput cuf1`,
16
- }
11
+ if FancyIrb.win?
12
+ TPUT = {
13
+ :sc => "\e[s",
14
+ :rc => "\e[u",
15
+ :cuu1 => "\e[1A",
16
+ :cuf1 => "\e[1C",
17
+ }
18
+ else
19
+ TPUT = {
20
+ :sc => `tput sc`,
21
+ :rc => `tput rc`,
22
+ :cuu1 => `tput cuu1`,
23
+ :cuf1 => `tput cuf1`,
24
+ }
25
+ end
17
26
 
18
27
  def colorize(string, color)
19
28
  if defined?(::Wirb) && color
@@ -49,8 +58,8 @@ module IRB
49
58
  last_input = @scanner.instance_variable_get( :@line )
50
59
  last_line_without_prompt = last_input.split("\n").last
51
60
  offset = last_line_without_prompt.display_size + FancyIrb.real_lengths[:input_prompt] + 1
52
- screen_length = `tput cols`.to_i
53
- screen_lines = `tput lines`.to_i
61
+ screen_length = FancyIrb.current_length
62
+ screen_lines = FancyIrb.current_lines
54
63
  output_length = FancyIrb.real_lengths[:output]
55
64
  rocket_length = FancyIrb[:rocket_prompt].size
56
65
  stdout_lines = FancyIrb.get_height
@@ -181,9 +190,6 @@ class << $stdin
181
190
  }
182
191
  end
183
192
 
184
- # reset everything (e.g. colors) when exiting
185
- END{
186
- print `tput sgr0`
187
- }
193
+ END{ print "\e[0;0m" } # reset colors when exiting
188
194
 
189
195
  # J-_-L
data/lib/fancy_irb.rb CHANGED
@@ -107,7 +107,7 @@ class << FancyIrb
107
107
  def track_height(data)
108
108
  lines = data.to_s.count("\n")
109
109
  long_lines = data.to_s.split("\n").inject(0){ |sum, line|
110
- sum + (line.display_size / `tput cols`.to_i)
110
+ sum + (line.display_size / current_length)
111
111
  }
112
112
  @height_counter << lines + long_lines
113
113
  end
@@ -125,4 +125,27 @@ class << FancyIrb
125
125
  end
126
126
  )
127
127
  end
128
+
129
+ def win?
130
+ RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
131
+ end
132
+
133
+ if FancyIrb.win?
134
+ raise LoadError, 'FancyIrb needs ansicon on windows, see https://github.com/adoxa/ansicon' unless ENV['ANSICON']
135
+ def current_length
136
+ ENV['ANSICON'][/\((.*)x/, 1].to_i
137
+ end
138
+
139
+ def current_lines
140
+ ENV['ANSICON'][/\(.*x(.*)\)/, 1].to_i
141
+ end
142
+ else
143
+ def current_length
144
+ `tput cols`.to_i
145
+ end
146
+
147
+ def current_lines
148
+ `tput lines`.to_i
149
+ end
150
+ end
128
151
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancy_irb
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 6
8
- - 4
9
- version: 0.6.4
4
+ prerelease:
5
+ version: 0.6.5
10
6
  platform: ruby
11
7
  authors:
12
8
  - Jan Lelis
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-01-27 00:00:00 +01:00
13
+ date: 2011-02-24 00:00:00 +01:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,9 +21,7 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
24
+ version: 0.2.4
31
25
  type: :runtime
32
26
  version_requirements: *id001
33
27
  - !ruby/object:Gem::Dependency
@@ -38,9 +32,7 @@ dependencies:
38
32
  requirements:
39
33
  - - ">="
40
34
  - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
35
+ version: 0.1.1
44
36
  type: :runtime
45
37
  version_requirements: *id002
46
38
  description: "FancyIrb patches your IRB to create a smooth output experience. You can colorize the prompts, irb errors, stderr and stdout. Results can be putted as #=> (rocket). Furthermore, it's possible to apply filter procs to your output value."
@@ -57,6 +49,7 @@ files:
57
49
  - README.rdoc
58
50
  - Rakefile
59
51
  - VERSION
52
+ - CHANGELOG.rdoc
60
53
  - fancy_irb.gemspec
61
54
  - lib/fancy_irb.rb
62
55
  - lib/fancy_irb/irb_ext.rb
@@ -74,25 +67,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
67
  requirements:
75
68
  - - ">="
76
69
  - !ruby/object:Gem::Version
77
- segments:
78
- - 1
79
- - 8
80
- - 7
81
70
  version: 1.8.7
82
71
  required_rubygems_version: !ruby/object:Gem::Requirement
83
72
  none: false
84
73
  requirements:
85
74
  - - ">="
86
75
  - !ruby/object:Gem::Version
87
- segments:
88
- - 1
89
- - 3
90
- - 6
91
76
  version: 1.3.6
92
- requirements: []
93
-
77
+ requirements:
78
+ - "On Windows, you need ansicon: https://github.com/adoxa/ansicon"
94
79
  rubyforge_project:
95
- rubygems_version: 1.3.7
80
+ rubygems_version: 1.5.2
96
81
  signing_key:
97
82
  specification_version: 3
98
83
  summary: FancyIrb patches your IRB to create a smooth output experience.