Question

In the meagre documentation for ruby curses I found this method

A_BLINK
Blinking

See ::attrset

However, I don't know how to utilize it.

win1 = Window.new
win1.addstr.a_blink "Blinking" #=> error

Please don't blame me, there is literally no help on google regarding curses. Honestly, at least not for ruby.

Was it helpful?

Solution

You can set attributes with Curses::Window#attrset. Here's an example:

require "curses"
include Curses

init_screen
begin
  attrs = {
    A_NORMAL =>     'Normal display (no highlight)',
    A_STANDOUT =>   'Best highlighting mode of the terminal.',
    A_UNDERLINE =>  'Underlining',
    A_REVERSE =>    'Reverse video',
    A_BLINK =>      'Blinking',
    A_DIM =>        'Half bright',
    A_BOLD =>       'Extra bright or bold',
    A_PROTECT =>    'Protected mode',
    A_INVIS =>      'Invisible or blank mode',
    A_ALTCHARSET => 'Alternate character set',
  }
  attrs.each { |a, s|
    attrset(a)
    addstr("#{s}\n")
  }
  refresh
  getch
ensure
  close_screen
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top