Code Monkey home page Code Monkey logo

fancy_irb's People

Contributors

janlelis avatar melborne avatar rjshade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fancy_irb's Issues

Colorize of input prompt cause strange issue

The default options of FancyIrb has:

:colorize => {
        :input_prompt  => :nothing,
        :input         => :nothing,
       },

Which will cause a strange issue on Linux:

  1. Execute a very long line code like
p "It's a very long long long long long long long long long long long long line"
  1. Press ESC k (or Ctrl+P if using default emacs mode) to get last line.
  2. Press 0 (or Ctrl+A if using default emacs mode) to try move cursor to the beginning of current line.
  3. Now the cursor stay around the first "very" word, not the beginning of current line, and you can't move cursor left anymore.

Turn of input prompt colorize like this can avoid the issue.

Irbtools.replace_library_callback :fancy_irb do
  FancyIrb.start :colorize => {:input_prompt => nil, :input => nil}
end

Unable to clear all line when hitting delete or backspace under windows CMD/Powershell

Hello, whenever you try to correct something misspelled in irb with fancy_irb active under Windows CMD/PowerShell the delete goes to a point where it stops before the prompt itself. The characters are all deleted, however the output is wrong and it is unclear what characters are actually deleted since the cursor falls back for 2-3 characters instead following properly the string.

IRB history (up arrow key) prepends a few characters to the command

irb(main):001:0> p "first command"
irb(main):002:0> p "second command"

Now if I press up twice to remember first command, I get this

irb(main):003:0> p "second command" first
______________________________________^
And I can only delete to here
I then have to control-C to goto a new empty line

In my .irbrc:
require 'fancy_irb'
FancyIrb.start({:colorize => {:input_prompt => [:white]}})

`#=>` expression result overwrites `Kernel#system` output

I am running stock irbtools. My ~/.irbrc: https://gist.github.com/3087362. I am using the bash shell in Terminal on Mac OS X.

FancyIrb works fine most of the time. But the #=> is output in the wrong place when a system command prints output. This is the problem output:

>> system 'pwd'
/Users/roryokane#=> truets/code/prepare-to-edit-Git-repo

And when irbtools is disabled:

irb(main):008:0> system 'pwd'
/Users/roryokane/Documents/code/prepare-to-edit-Git-repo

I can work around it by padding my statement with spaces at the end. It seems that the expression result is just moved one line below where it should be.

>> system 'pwd'                                    # padded
/Users/roryokane/Documents/code/prepare-to-edit-Git-repo    #=> true

More test cases:

>> system 'echo'
                 #=> true
>> system 'echo "line one\nline two"'
line one
line two                              #=> true
>> puts "line one\nline two" #=> nil
line one
line two

Assignment statements causing exception

This is strange ... I'm working on venus a 2011 MacMini running MacOS 10.13.6 It has no Xcode installed.

15:50:03 3.2.2  venus:~ $ irb
irb(main):001> x = 1
/Users/dewayne/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/fancy_irb-2.1.0/lib/fancy_irb/irb_ext.rb:3:in `output_value': wrong number of arguments (given 1, expected 0) (ArgumentError)
	from /Users/dewayne/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/fancy_irb-2.1.0/lib/fancy_irb/irb_ext.rb:9:in `signal_status'
	from /Users/dewayne/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.8.3/exe/irb:9:in `<top (required)>'
	from /Users/dewayne/.rbenv/versions/3.2.2/bin/irb:25:in `load'
	from /Users/dewayne/.rbenv/versions/3.2.2/bin/irb:25:in `<main>'
irb(main):002> exit
15:50:50 3.2.2  venus:~ $ ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin17]
15:50:57 3.2.2  venus:~ $ irb --version
irb 1.8.3 (2023-10-14)
15:51:03 3.2.2  venus:~ $ gem list fancy_irb

*** LOCAL GEMS ***

fancy_irb (2.1.0)
15:51:12 3.2.2  venus:~ $

longlines rocket bug

when printing a longline string, rocket prompt go wrong position.
i found one mistake on track_height, but still remain the problem...

def track_height(data)
    lines      = data.to_s.count("\n")
    long_lines = data.to_s.split("\n").inject(0){ |sum, line| sum + (line.size / `tput cols`.to_i) }

NoMethodError: undefined method `[]' for FancyIrb:Module

Hello!

On Ruby 2.2.2 I get this error:

$ irb
Welcome to IRB. You are using ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]. Have fun ;)
>> "ciao"
NoMethodError: undefined method `[]' for FancyIrb:Module
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/irb-benchmark-0.1.2/lib/irb_benchmark.rb:12:in `print'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/irb-benchmark-0.1.2/lib/irb_benchmark/irb_ext.rb:11:in `evaluate'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/fancy_irb-1.0.0/lib/fancy_irb/irb_ext.rb:31:in `evaluate'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:489:in `block (2 levels) in eval_input'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:623:in `signal_status'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/fancy_irb-1.0.0/lib/fancy_irb/irb_ext.rb:19:in `signal_status'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:486:in `block in eval_input'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb/ruby-lex.rb:245:in `block (2 levels) in each_top_level_statement'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `loop'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `block in each_top_level_statement'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `catch'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `each_top_level_statement'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:485:in `eval_input'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:395:in `block in start'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:394:in `catch'
  from /home/user/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:394:in `start'
  from /home/user/.rbenv/versions/2.2.2/bin/irb:11:in `<main>'Maybe IRB bug!

This is my .irbrc:

begin
  require 'irbtools/configure'
  require 'irb-benchmark'
  require 'bond'

  Irbtools.remove_library 'boson/console' if RUBY_VERSION >= '2.2.0'
  Irbtools.start
  Bond.start
rescue LoadError
end

Not supported in Linux Alpine

When used in Linux alpine, RbConfig::CONFIG['host_os'] is equal to "linux-musl"

When the constant TPUT is getting set the RbConfig::CONFIG['host_os'] =~ /linux/ condition passes, attempting to run the script command, which is not installed on alpine by default.

begin
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
TPUT = {
:sc => "\e[s",
:rc => "\e[u",
:cuu1 => "\e[1A",
:cuf1 => "\e[1C",
}
elsif RbConfig::CONFIG['host_os'] =~ /linux/
TPUT = {
:sc => `script -q -e -t /dev/null -c 'tput sc'`,
:rc => `script -q -e -t /dev/null -c 'tput rc'`,
:cuu1 => `script -q -e -t /dev/null -c 'tput cuu1'`,
:cuf1 => `script -q -e -t /dev/null -c 'tput cuf1'`,
}
else
TPUT = {
:sc => `tput sc`,
:rc => `tput rc`,
:cuu1 => `tput cuu1`,
:cuf1 => `tput cuf1`,
}
end
rescue Errno::ENOTTY
TPUT = {
:sc => "\e7",
:rc => "\e8",
:cuu1 => "\e[A",
:cuf1 => "\e[C",
}
end

This leaves us with an ugly error and a non-colored console, however the console still works fine.

docker-container:~/app$ bundle exec rails c
sh: script: not found
sh: script: not found
sh: script: not found
sh: script: not found
application(production)>

To install script on alpine, you must install the util-linux package, which is very large, and we are trying to keep our docker containers sizes to a minimum.

If the following block of code is run instead when RbConfig::CONFIG['host_os'] == "linux-musl", it will fix this issue.

TPUT = {
:sc => `tput sc`,
:rc => `tput rc`,
:cuu1 => `tput cuu1`,
:cuf1 => `tput cuf1`,
}

gem rdoc aborts

When running gem rdoc fancy_irb RDoc complains with:
RDoc failure in lib/fancy_irb.rb at or around line 89 column 31

v1.3.0+ prints numbers to screen on boot

$ rails c
Loading development environment (Rails 6.0.3.3)
0.307376 2
          0.315706 2
                    0.321084 3
                              0.325803 3
                                        Welcome to RAILS. You are using ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]. Have fun ;)
>>

From what I can tell, this is the commit that did it. c569a24

OS is Ubuntu

No windows support

Is there any possibility this gem will be supported on Windows versions of ruby? I ask only because I'm stuck on Windows for work and am trying to bring Ruby in.

Specifically, in lib/fancy_irb/irb_ext.rb, I got some errors when trying to FancyIrb.start:

>> FancyIrb.start
#<Class:0x323c790>: No such file or directory - tput sc
        from C:/Ruby187/lib/ruby/gems/1.8/gems/fancy_irb-0.6.4/lib/fancy_irb/irb_ext.rb:12:in ``'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/fancy_irb-0.6.4/lib/fancy_irb/irb_ext.rb:12
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/Ruby187/lib/ruby/gems/1.8/gems/fancy_irb-0.6.4/lib/fancy_irb.rb:89:in `start'
        from (irb):2:in `irb_binding'
        from C:/Ruby187/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'
        from C:/Ruby187/lib/ruby/1.8/irb/workspace.rb:52
Maybe IRB bug!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.