在curses应用程序中闪烁字符串

时间:2013-10-12 22:14:15

标签: ruby curses

在ruby curses的微薄文档中,我找到了这个方法

A_BLINK
Blinking

See ::attrset

但是,我不知道如何利用它。

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

请不要怪我,谷歌对诅咒毫无帮助。老实说,至少不是红宝石。

1 个答案:

答案 0 :(得分:2)

您可以使用Curses::Window#attrset设置属性。这是一个例子:

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
相关问题