Skip to content
Browse files

FancyIrb now uses unicode-display_size to position the rocket better

  • Loading branch information...
1 parent 7593afc commit 651eb3dfcd2613e11ab5ca8cb516ac9e6d920257 @janlelis committed Jan 2, 2011
Showing with 7 additions and 6 deletions.
  1. +1 −1 LICENSE
  2. +1 −1 README.rdoc
  3. +2 −1 Rakefile
  4. +2 −2 lib/fancy_irb.rb
  5. +1 −1 lib/fancy_irb/irb_ext.rb
View
2 LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2010 Jan Lelis
+Copyright (c) 2010-2011 Jan Lelis
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
2 README.rdoc
@@ -108,6 +108,6 @@ Feel free to fix a bug or implement a todo ;)
Inspired by the irb_rocket gem from genki.
-Copyright (c) 2010 Jan Lelis, http://rbjl.net, released under the MIT license.
+Copyright (c) 2010-2011 Jan Lelis, http://rbjl.net, released under the MIT license.
J-_-L
View
3 Rakefile
@@ -7,13 +7,14 @@ begin
gem.name = "fancy_irb"
gem.summary = %q{FancyIrb patches your IRB to create a smooth output experience.}
gem.description = %q{FancyIrb patches your IRB to create a smooth output experience.
-* Use fancy colors! You can colorize the prompts, irb errors, +stderr+ and +stdout+
+* Use fancy colors! You can colorize the prompts, irb errors, stderr and stdout
* Output results as Ruby comment #=> (rocket)
* Enhance your output value, using procs}
gem.email = "mail@janlelis.de"
gem.homepage = "http://github.com/janlelis/fancy_irb"
gem.authors = ["Jan Lelis"]
gem.add_dependency 'wirble'
+ gem.add_dependency 'unicode-display_width'
end
Jeweler::GemcutterTasks.new
rescue LoadError
View
4 lib/fancy_irb.rb
@@ -1,5 +1,6 @@
require 'stringio'
require 'wirble'
+require 'unicode/display_width'
module FancyIrb
VERSION = ( File.read File.expand_path( '../VERSION', File.dirname(__FILE__)) ).chomp
@@ -106,8 +107,7 @@ def reset_height
def track_height(data)
lines = data.to_s.count("\n")
long_lines = data.to_s.split("\n").inject(0){ |sum, line|
- line_size = (RUBY_VERSION[2] == ?8) ? line.unpack('U*').size : line.size
- sum + (line_size / `tput cols`.to_i)
+ sum + (line.display_size / `tput cols`.to_i)
}
@height_counter << lines + long_lines
end
View
2 lib/fancy_irb/irb_ext.rb
@@ -33,7 +33,7 @@ def output_value
# get lengths
last_input = @scanner.instance_variable_get( :@line )
last_line_without_prompt = last_input.split("\n").last
- offset = last_line_without_prompt.size + FancyIrb.real_lengths[:input_prompt] + 1
+ offset = last_line_without_prompt.display_size + FancyIrb.real_lengths[:input_prompt] + 1
screen_length = `tput cols`.to_i
screen_lines = `tput lines`.to_i
output_length = FancyIrb.real_lengths[:output]

0 comments on commit 651eb3d

Please sign in to comment.
Something went wrong with that request. Please try again.