In Files

  • ruby-3.1.2/lib/reline/terminfo.rb

Files

Class/Module Index [+]

Quicksearch

Reline::Terminfo

Public Class Methods

curses_dl() click to toggle source
 
               # File ruby-3.1.2/lib/reline/terminfo.rb, line 6
def self.curses_dl
  false
end
            
curses_dl_files() click to toggle source
 
               # File ruby-3.1.2/lib/reline/terminfo.rb, line 17
def self.curses_dl_files
  case RUBY_PLATFORM
  when /mingw/, /mswin/
    # aren't supported
    []
  when /cygwin/
    %w[cygncursesw-10.dll cygncurses-10.dll]
  when /darwin/
    %w[libncursesw.dylib libcursesw.dylib libncurses.dylib libcurses.dylib]
  else
    %w[libncursesw.so libcursesw.so libncurses.so libcurses.so]
  end
end
            
enabled?() click to toggle source
 
               # File ruby-3.1.2/lib/reline/terminfo.rb, line 125
def self.enabled?
  true
end
            
setupterm(term, fildes) click to toggle source

TODO: add int tigetflag(char *capname) and int tigetnum(char *capname)

 
               # File ruby-3.1.2/lib/reline/terminfo.rb, line 79
def self.setupterm(term, fildes)
  errret_int = String.new("\x00" * 8, encoding: 'ASCII-8BIT')
  ret = @setupterm.(term, fildes, errret_int)
  errret = errret_int.unpack1('i')
  case ret
  when 0 # OK
    0
  when -1 # ERR
    case errret
    when 1
      raise TerminfoError.new('The terminal is hardcopy, cannot be used for curses applications.')
    when 0
      raise TerminfoError.new('The terminal could not be found, or that it is a generic type, having too little information for curses applications to run.')
    when -1
      raise TerminfoError.new('The terminfo database could not be found.')
    else # unknown
      -1
    end
  else # unknown
    -2
  end
end
            
tigetstr(capname) click to toggle source
 
               # File ruby-3.1.2/lib/reline/terminfo.rb, line 108
def self.tigetstr(capname)
  capability = @tigetstr.(capname)
  case capability.to_i
  when 0, -1
    raise TerminfoError, "can't find capability: #{capname}"
  end
  StringWithTiparm.new(capability.to_s)
end
            
tiparm(str, *args) click to toggle source
 
               # File ruby-3.1.2/lib/reline/terminfo.rb, line 117
def self.tiparm(str, *args)
  new_args = []
  args.each do |a|
    new_args << Fiddle::TYPE_INT << a
  end
  @tiparm.(str, *new_args).to_s
end