beep.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* PDCurses */
  2. #include <curspriv.h>
  3. /*man-start**************************************************************
  4. beep
  5. ----
  6. ### Synopsis
  7. int beep(void);
  8. int flash(void);
  9. ### Description
  10. beep() sounds the audible bell on the terminal, if possible; if not,
  11. it calls flash().
  12. flash() "flashes" the screen, by inverting the foreground and
  13. background of every cell, pausing, and then restoring the original
  14. attributes.
  15. ### Return Value
  16. These functions return ERR if called before initscr(), otherwise OK.
  17. ### Portability
  18. X/Open ncurses NetBSD
  19. beep Y Y Y
  20. flash Y Y Y
  21. **man-end****************************************************************/
  22. int beep(void)
  23. {
  24. PDC_LOG(("beep() - called\n"));
  25. if (!SP)
  26. return ERR;
  27. if (SP->audible)
  28. PDC_beep();
  29. else
  30. flash();
  31. return OK;
  32. }
  33. int flash(void)
  34. {
  35. int z, y, x;
  36. PDC_LOG(("flash() - called\n"));
  37. if (!curscr)
  38. return ERR;
  39. /* Reverse each cell; wait; restore the screen */
  40. for (z = 0; z < 2; z++)
  41. {
  42. for (y = 0; y < LINES; y++)
  43. for (x = 0; x < COLS; x++)
  44. curscr->_y[y][x] ^= A_REVERSE;
  45. wrefresh(curscr);
  46. if (!z)
  47. napms(50);
  48. }
  49. return OK;
  50. }