Rbcurse errors

OSX 10.6.8

$ rvm list
rvm rubies

jruby-1.7.12 [ x86_64 ]
ruby-1.8.7-p370 [ i686 ]
ruby-1.8.7-p374 [ i686 ]
ruby-1.9.3-p194 [ x86_64 ]
ruby-1.9.3-p545 [ x86_64 ]
=> ruby-1.9.3-p547 [ x86_64 ]
ruby-2.0.0-p0 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
ruby-2.0.0-p481 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]

  • ruby-2.1.2 [ x86_64 ]

$ gem install rbcurse-core
Fetching: ffi-1.9.3.gem (100%)
Building native extensions. This could take a while…
Successfully installed ffi-1.9.3
Fetching: ffi-locale-1.0.1.gem (100%)
Successfully installed ffi-locale-1.0.1
Fetching: ffi-ncurses-0.4.0.gem (100%)
Successfully installed ffi-ncurses-0.4.0
Fetching: rbcurse-core-0.0.14.gem (100%)
Successfully installed rbcurse-core-0.0.14
4 gems installed

$ gem list
*** LOCAL GEMS ***

activemodel (4.1.2)
activerecord (4.1.2)
activesupport (4.1.2)
arel (5.0.1.20140414130214)
bigdecimal (1.1.0)
builder (3.2.2)
bundler (1.6.2)
bundler-unload (1.0.2)
chronic (0.10.2)
coderay (1.1.0)
executable-hooks (1.3.1)
ffi (1.9.3)
ffi-locale (1.0.1)
ffi-ncurses (0.4.0)
gem-wrappers (1.2.4)
glib2 (2.2.0)
highline (1.6.21)
i18n (0.6.9)
io-console (0.3)
json (1.8.1, 1.5.5)
kamelopard (0.0.15, 0.0.14)
libxml-ruby (2.7.0)
method_source (0.8.2)
minitest (5.3.5, 2.5.1)
mysql2 (0.3.16)
pg (0.17.1)
pkg-config (1.1.5)
pry (0.10.0)
pry-doc (0.6.0)
rake (0.9.2.2)
rbcurse-core (0.0.14)
rdoc (4.1.1, 3.9.5)
rdoc-data (4.0.1)
rubygems-bundler (1.4.3)
rvm (1.11.3.9)
sequel (4.11.0)
slop (3.5.0)
sqlite3 (1.3.9)
sqlite3-ruby (1.3.3)
thread_safe (0.3.4)
tzinfo (1.2.1)
yard (0.8.7.4)

An example from the docs (where I filled in some missing parts!):

require ‘rbcurse’

@window = VER::Window.root_window
@form = Form.new @window
f3 = Field.new @form

r = 1
fc = 10

f3.name(“mobile”).display_length(20).bgcolor(:white).color(:black).
text(“”).label(’ Mobile: ').
row(r).col(fc).
type(:integer)

–output:–
r 1.rb
/Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/window.rb:66:
[BUG] Segmentation fault
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin10.8.0]

– Control frame information

c:0008 p:---- s:0031 b:0031 l:000030 d:000030 CFUNC :newwin
c:0007 p:0262 s:0024 b:0024 l:000023 d:000023 METHOD
/Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/window.rb:66
c:0006 p:---- s:0019 b:0019 l:000018 d:000018 FINISH
c:0005 p:---- s:0017 b:0017 l:000016 d:000016 CFUNC :new
c:0004 p:0047 s:0013 b:0013 l:000012 d:000012 METHOD
/Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/window.rb:98
c:0003 p:0029 s:0009 b:0009 l:002638 d:0022d0 EVAL 1.rb:3
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:002638 d:002638 TOP

– Ruby level backtrace information

1.rb:3:in <main>' /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/window.rb:98:in root_window’
/Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/window.rb:98:in
new' /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/window.rb:66:in initialize’
/Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/window.rb:66:in
`newwin’

– C level backtrace information

See Crash Report log file under ~/Library/Logs/CrashReporter or
/Library/Logs/CrashReporter, for the more detail of.

– Other runtime information

  • Loaded script: 1.rb

  • Loaded features:

    0 enumerator.so
    1
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/x86_64-darwin10.8.0/enc/encdb.bundle
    2
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/x86_64-darwin10.8.0/enc/trans/transdb.bundle
    3
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/x86_64-darwin10.8.0/rbconfig.rb
    4
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/compatibility.rb
    5
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/defaults.rb
    6
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/deprecate.rb
    7
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/errors.rb
    8
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/version.rb
    9
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb
    10
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/platform.rb
    11
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/basic_specification.rb
    12
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/stub_specification.rb
    13
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/util/stringio.rb
    14
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb
    15
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/exceptions.rb
    16
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb
    17 /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/thread.rb
    18 /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/monitor.rb
    19
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb
    20
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems.rb
    21
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/path_support.rb
    22
    /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb
    23
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-10/1.9.1/ffi-1.9.3/ffi_c.bundle
    24
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/platform.rb
    25
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/types.rb
    26
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/library.rb
    27
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/errno.rb
    28
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/pointer.rb
    29
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/memorypointer.rb
    30
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/struct_layout_builder.rb
    31
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/struct.rb
    32
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/union.rb
    33
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/managedstruct.rb
    34
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/callback.rb
    35
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/io.rb
    36
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/autopointer.rb
    37
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/variadic.rb
    38
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/enum.rb
    39
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi/ffi.rb
    40 /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-1.9.3/lib/ffi.rb
    41
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-locale-1.0.1/lib/ffi-locale.rb
    42
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/version.rb
    43
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/typedefs.rb
    44
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/functions.rb
    45
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/ord_shim.rb
    46
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/acs.rb
    47
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/winstruct.rb
    48
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/panel.rb
    49
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/darwin.rb
    50
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/bool_wrappers.rb
    51
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/keydefs.rb
    52
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses/mouse.rb
    53
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/ffi-ncurses-0.4.0/lib/ffi-ncurses.rb
    54
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/colormap.rb
    55
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/ncurses.rb
    56
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/panel.rb
    57
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/include/chunk.rb
    58
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/window.rb
    59 /Users/7stud/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/logger.rb
    60
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/include/orderedhash.rb
    61
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/include/rinputdataevent.rb
    62
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/include/io.rb
    63
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/system/keydefs.rb
    64
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/include/action.rb
    65
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/widgets/rwidget.rb
    66
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/include/bordertitle.rb
    67
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/widgets/rmessagebox.rb
    68
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse/core/util/rdialogs.rb
    69
    /Users/7stud/.rvm/gems/ruby-1.9.3-p547/gems/rbcurse-core-0.0.14/lib/rbcurse.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension
libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap

~/ruby_programs$

The same thing happens with ruby 2.0, 2.1.

Hold it. The following code (rbcurse-core/examples/app.sample):

=====
require ‘rbcurse/core/util/app’
def help_text
<<-eos
Enter as much help text
here as you want
eos
end

App.new do
## application code comes here
@form.help_manager.help_text = help_text()

@header = app_header "My App #{MyApp::VERSION}", :text_center =>

“Yet Another Email Client that sucks”, :text_right =>“Some text”, :color
=> :black, :bgcolor => :white

@status_line = status_line
@status_line.command {

}

end # app

produces this error:

========== EXCEPTION ==========
#<NameError: uninitialized constant MyApp>

But if I delete MyApp in the code:

require ‘rbcurse/core/util/app’

def help_text
<<-eos
Enter as much help text
here as you want
eos
end

App.new do
## application code comes here
@form.help_manager.help_text = help_text()

@header = app_header "My App ", :text_center => "Yet Another Email

Client that sucks", :text_right =>“Some text”, :color => :black,
:bgcolor => :white

@status_line = status_line
@status_line.command {

}

end # app

I see something in my terminal window–I don’t get any errors.

There are actually three ways to create widgets:

  1. By passing a hash containing configuration options to new(), e.g.

Label.new @form, {:text => “Hello World”, :row => 1, :col => 0, :color
=>:green, :bgcolor => :black}

  1. Using the rbcurse DSL:

Label.new(@form) do
text “Hello World”
row 1
col 0
color :green
bgcolor :black
end

  1. Calling a series of methods on the widget:

Label.new(@form).text(“Hello World”).
row(1).
col(0).
color(:green).
bgcolor(:black)

The rbcurse tutorial recommends using #3. But to my eye, the DSL in #2
is the nicest. Unfortunately, the creator wants to remove the DSL in
future versions.

I couldn’t get a basic rbcurse example(one that doesn’t use the App
object) to work when I followed the rbcurse tutorial here:

I kept getting the error:

fire_handler': undefined method debug’ for nil:NilClass
(NoMethodError)

So I took one of the rbcurse examples:

…and I stripped it down to the bare bones. Here is what I came up
with:

require ‘logger’
require ‘rbcurse’
require ‘rbcurse/core/include/appmethods.rb’

include RubyCurses
include RubyCurses::Utils

begin
#—Initialize curses: -----

#1) Initialize colors via ColorMap.setup
VER::start_ncurses

#2) Set up logger(required, even if you don’t use it!):
path = File.join(ENV[“LOGDIR”] || “./” ,“rbcurse.log”)
$log = Logger.new(path)
$log.level = Logger::DEBUG

#---------------------------

#Create the window to be associated with the form:

@window = VER::Window.root_window

#---------------------------

#Create the Form:-----------

catch(:close) do #This allows you to write throw :close inside an
event handler to
#termiante the curses program

@form = Form.new @window

#Create the form Fields:

#1) Create a Label:
title = "Hello World"
Label.new @form, {:text => title, :row => 1, :col => 0, :color =>

:green, :bgcolor => :black}

#2) Create a textfield w/ an associated Label:
field = Field.new @form do
  name "textfield1"
  row  4     #height
  col  20    #width
  display_length  30
  #set_buffer "abcd "   #Specify default text to be displayed in

textfield
set_label Label.new @form, {:text => “Enter your name:”, :color=>
:cyan,}
end

Display the form and the window:---------

@form.repaint
@window.wrefresh
Ncurses::Panel.update_panels

#The main loop to handle keypresses: ------

while((ch = @window.getchar()) != 13) # 13 => Enter/Return key. Or

could use something like: FFI::NCurses::KEY_F10
break if ch == ?\C-q.getbyte(0) #Alternative way to end loop: by
entering Ctrl+Q

  @form.handle_key(ch)
end

#-----------------------------------------

end # catch

rescue => e
#do nothing
ensure
@window.destroy if !@window.nil?
VER::stop_ncurses

if e
puts e
puts(e.backtrace.join(“\n”))
end
end

Here is the same example using the App object:

#Ctrl+Q to exit curses, or F10(some terminals don’t process function
keys)
require ‘rbcurse/core/util/app’

def help_text
<<-eos
Enter as much help text
here as you want
eos
end

user_answer = “error”

App.new do #Ctrl+Q to exit curses, or F10(some terminals don’t process
function keys)
@form.help_manager.help_text = help_text() #User can hit F1 to get
help text

#Create a Label:
title = “Hello World”
Label.new @form, {:text => title, :row => 1, :col => 0, :color =>
:green, :bgcolor => :black}

#Create a textfield:
text_field_rows = 4
text_field_columns = 10

question = “Are You Hungry?”
default_answer = “Yes”

text_field = Field.new @form

text_field.name(question).
display_length(20).
bgcolor(:white).
color(:black).
text(default_answer).
label(question).
row(text_field_rows).
col(text_field_columns)

text_field.cursor_end #Put cursor after default text

text_field.bind_key(13, ‘return’) do # 13 => Enter/Return key
user_answer = text_field.text
throw :close #Terminates curses. (Breaks out of catch() block
shown in prior example)
end
end # app

puts user_answer