4

I'm using Ubuntu 14.04, gcc 4.8.2 and Ncurses 5.9.20140118; whenever I run any code like

attron(A_BLINK);
printw("Hi");
refresh();

the text that gets printed to the terminal doesn't blinks (or do hoola-hoops)- it's just regular text that would have been printed by

printw("Hi");
refresh();

I have tested it on xterm, default ubuntu terminal, gnome terminal and Guake with the same result. Do I need some special fonts with "Blink Support" or something for it?

  • 2
    You don't need special fonts. You do need terminals that have support for blinking. However, checking the terminfo for xterm, at least, reveals that it does support blinking text. Are you using something like tmux or screen that would override your terminfo? Are you manually overriding $TERM in your shell? You can test your terminal for support by running the following in your shell: echo "\x1b[5mtest". If "test" blinks, then you know your terminal supports blinking. – HalosGhost Aug 23 '14 at 0:10
3

I think your issue has to do with which terminal emulator you're using and what value the $TERM variable is set to. I was able to use some sample code I find that works with those 2 conditions were met, but it wouldn't work in same gnome-terminal or terminator.

Sample code

#include <ncurses.h>

int main(void)
{
    initscr();

    attron(A_BOLD);
    addstr("Twinkle, twinkle little star\n");
    attron(A_BLINK);
    addstr("How I wonder what you are.\n");
    attroff(A_BOLD);
    addstr("Up above the world so high,\n");
    addstr("Like a diamond in the sky.\n");
    attrset(A_NORMAL);
    addstr("Twinkle, twinkle little star\n");
    addstr("How I wonder what you are.\n");
    refresh();

    endwin();

    return 0;
}

I compiled it like so:

$ gcc -o blink blink.c -lncurses

You can see that it's working by piping its output to hexdump:

$ ./blink | hexdump -C
00000000  1b 5b 3f 31 30 34 39 68  1b 5b 31 3b 33 31 72 1b  |.[?1049h.[1;31r.|
00000010  28 42 1b 5b 6d 1b 5b 34  6c 1b 5b 3f 37 68 1b 5b  |(B.[m.[4l.[?7h.[|
00000020  48 1b 5b 32 4a 1b 28 42  1b 5b 30 3b 31 6d 54 77  |H.[2J.(B.[0;1mTw|
00000030  69 6e 6b 6c 65 2c 20 74  77 69 6e 6b 6c 65 20 6c  |inkle, twinkle l|
00000040  69 74 74 6c 65 20 73 74  61 72 0d 0a 1b 28 42 1b  |ittle star...(B.|
00000050  5b 30 3b 31 3b 35 6d 48  6f 77 20 49 20 77 6f 6e  |[0;1;5mHow I won|
00000060  64 65 72 20 77 68 61 74  20 79 6f 75 20 61 72 65  |der what you are|
00000070  2e 0d 0a 1b 28 42 1b 5b  30 3b 35 6d 55 70 20 61  |....(B.[0;5mUp a|
00000080  62 6f 76 65 20 74 68 65  20 77 6f 72 6c 64 20 73  |bove the world s|
00000090  6f 20 68 69 67 68 2c 0d  0a 4c 69 6b 65 20 61 20  |o high,..Like a |
000000a0  64 69 61 6d 6f 6e 64 20  69 6e 20 74 68 65 20 73  |diamond in the s|
000000b0  6b 79 2e 0d 0a 1b 28 42  1b 5b 6d 54 77 69 6e 6b  |ky....(B.[mTwink|
000000c0  6c 65 2c 20 74 77 69 6e  6b 6c 65 20 6c 69 74 74  |le, twinkle litt|
000000d0  6c 65 20 73 74 61 72 0d  0a 48 6f 77 20 49 20 77  |le star..How I w|
000000e0  6f 6e 64 65 72 20 77 68  61 74 20 79 6f 75 20 61  |onder what you a|
000000f0  72 65 2e 0d 0a 1b 5b 33  31 3b 31 48 1b 5b 3f 31  |re....[31;1H.[?1|
00000100  30 34 39 6c 0d 1b 5b 3f  31 6c 1b 3e              |049l..[?1l.>|
0000010c

Switching to xterm with $TERM set to vt100. Here's a screenshot of the terminal.

                 ss#1

                 ss#2

  • @HalosGhost - thanks for the catch, I always do, I missed this one however 8-). – slm Aug 23 '14 at 1:37
  • No one is perfect. :) – HalosGhost Aug 23 '14 at 1:40
  • Modifying $TERM indeed made it work in xterm, it also worked in Konsole which makes me think I should switch to KDE. Thanks. – strNOcat Aug 23 '14 at 2:28
  • For the record, setting $TERM is not a solution. It's a workaround. Something is probably setting your $TERM incorrectly (overriding the terminfo). Fixing that is the actual solution. – HalosGhost Aug 23 '14 at 2:42
  • @slm @HalosGhost Sorry to ping you guys on a very old post. I'm trying to resolve the same problem on MacOS with the default terminal, which has $TERM set to xterm-256color which I believe should support blinking. Like the OP, however, A_BLINK doesn't seem to do anything. Any ideas on what I could be missing? – mnoronha Mar 23 '17 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.