Uninitialized constant STDSCR
kmort89 opened this issue · comments
Hi,
in this minimal example I'm getting uninitialized constant error.
require 'rubytext'
require 'byebug'
byebug
win = RubyText.window(8, 39, r: 4, c: 9, fg: Black, bg: Blue)
win.puts "If your text is longer than " +
"the width of the window, by default it will " +
"wrap around."
Ruby is 2.7.2 and rubytext is 0.1.23
$ ruby --verbose text.rb
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/rubytext.rb:63: warning: `*' interpreted as argument prefix
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/output.rb:9: warning: assigned but unused variable - c
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/output.rb:55: warning: `*' interpreted as argument prefix
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/output.rb:60: warning: `*' interpreted as argument prefix
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/output.rb:86: warning: assigned but unused variable - c
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/output.rb:240: warning: assigned but unused variable - num
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/menu.rb:19: warning: assigned but unused variable - hash_flag
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/menu.rb:80: warning: assigned but unused variable - hash_flag
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/menu.rb:194: warning: assigned but unused variable - str
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/menu.rb:208: warning: assigned but unused variable - hash_flag
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/window.rb:156: warning: `*' interpreted as argument prefix
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/window.rb:91: warning: method redefined; discarding old scrolling
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/window.rb:165: warning: method redefined; discarding old fg=
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/window.rb:169: warning: method redefined; discarding old bg=
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/color.rb:79: warning: method redefined; discarding old fg=
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/window.rb:165: warning: previous definition of fg= was here
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/color.rb:85: warning: method redefined; discarding old bg=
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/window.rb:169: warning: previous definition of bg= was here
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/navigation.rb:48: warning: `*' interpreted as argument prefix
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/navigation.rb:83: warning: assigned but unused variable - r
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/navigation.rb:90: warning: assigned but unused variable - r
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/navigation.rb:110: warning: assigned but unused variable - c
/home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/navigation.rb:117: warning: assigned but unused variable - c
[1, 10] in /vagrant/text.rb
1: require 'rubytext'
2: require 'byebug'
3:
4: byebug
5:
=> 6: win = RubyText.window(8, 39, r: 4, c: 9, fg: Black, bg: Blue)
7:
8: win.puts "If your text is longer than " +
9: "the width of the window, by default it will " +
10: "wrap around."
(byebug) step
[1, 10] in /home/vagrant/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubytext-0.1.23/lib/window.rb
1:
2: module RubyText
3: def self.window(high, wide, r: nil, c: nil, border: true,
4: fg: White, bg: Blue, scroll: false, title: nil)
=> 5: r ||= (STDSCR.rows - high)/2
6: c ||= (STDSCR.cols - wide)/2
7: win = RubyText::Window.new(high, wide, r, c, border, fg, bg, scroll)
8: win.add_title(title) if title
9: 0.upto(high) {|row| 0.upto(wide) {|col| win[row, col] = " " } }
10: win
(byebug) print STDSCR
*** NameError Exception: uninitialized constant RubyText::STDSCR
Did you mean? STDERR
nil
(byebug) quit
Really quit? (y/n) y
Further notes:
Adding require 'curses' and
RubyText::STDSCR = Curses.stdscr
Before the RubyText.window call fixes it in one way.
Adding
RubyText.start
before that call fixes it in another way (seems better), but neither of these are documented into the examples.
Ah apparently those examples where from slides where the initialization is done outside the script file.
User error then. 👍
Or arguably a documentation error. :)
Sorry, I didn't see this until you had already closed it.
Honestly didn't know anyone was actually interested in this. It has many flaws and
limitations. If you are interested, we can discuss these things. I do hope to make
more improvements later.
I actually couldn't get the examples to work properly even after that. I suspect those deprecation warnings are what's messing it up.
I'll try a different library first (Remedy) for my needs and if that also fails, I'll just go with writing raw curses. I just had hoped to use minimal effort on the curses part here. But yes, better documentation and getting rid of those warnings might be good for this project.