pdcsetsc.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* PDCurses */
  2. #include "pdcwin.h"
  3. /*man-start**************************************************************
  4. pdcsetsc
  5. --------
  6. ### Synopsis
  7. int PDC_set_blink(bool blinkon);
  8. int PDC_set_bold(bool boldon);
  9. void PDC_set_title(const char *title);
  10. ### Description
  11. PDC_set_blink() toggles whether the A_BLINK attribute sets an actual
  12. blink mode (TRUE), or sets the background color to high intensity
  13. (FALSE). The default is platform-dependent (FALSE in most cases). It
  14. returns OK if it could set the state to match the given parameter,
  15. ERR otherwise.
  16. PDC_set_bold() toggles whether the A_BOLD attribute selects an actual
  17. bold font (TRUE), or sets the foreground color to high intensity
  18. (FALSE). It returns OK if it could set the state to match the given
  19. parameter, ERR otherwise.
  20. PDC_set_title() sets the title of the window in which the curses
  21. program is running. This function may not do anything on some
  22. platforms.
  23. ### Portability
  24. X/Open ncurses NetBSD
  25. PDC_set_blink - - -
  26. PDC_set_title - - -
  27. **man-end****************************************************************/
  28. int PDC_curs_set(int visibility)
  29. {
  30. CONSOLE_CURSOR_INFO cci;
  31. int ret_vis;
  32. PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
  33. ret_vis = SP->visibility;
  34. if (GetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
  35. return ERR;
  36. switch(visibility)
  37. {
  38. case 0: /* invisible */
  39. cci.bVisible = FALSE;
  40. break;
  41. case 2: /* highly visible */
  42. cci.bVisible = TRUE;
  43. cci.dwSize = 95;
  44. break;
  45. default: /* normal visibility */
  46. cci.bVisible = TRUE;
  47. cci.dwSize = SP->orig_cursor;
  48. break;
  49. }
  50. if (SetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
  51. return ERR;
  52. SP->visibility = visibility;
  53. return ret_vis;
  54. }
  55. void PDC_set_title(const char *title)
  56. {
  57. #ifdef PDC_WIDE
  58. wchar_t wtitle[512];
  59. #endif
  60. PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
  61. #ifdef PDC_WIDE
  62. PDC_mbstowcs(wtitle, title, 511);
  63. SetConsoleTitleW(wtitle);
  64. #else
  65. SetConsoleTitleA(title);
  66. #endif
  67. }
  68. int PDC_set_blink(bool blinkon)
  69. {
  70. if (!SP)
  71. return ERR;
  72. if (SP->color_started)
  73. {
  74. COLORS = 16;
  75. if (PDC_can_change_color()) /* is_nt */
  76. {
  77. if (pdc_conemu || SetConsoleMode(pdc_con_out, 0x0004)) /* VT */
  78. COLORS = PDC_MAXCOL;
  79. if (!pdc_conemu)
  80. SetConsoleMode(pdc_con_out, 0x0010); /* LVB */
  81. }
  82. }
  83. if (blinkon)
  84. {
  85. if (!(SP->termattrs & A_BLINK))
  86. {
  87. SP->termattrs |= A_BLINK;
  88. pdc_last_blink = GetTickCount();
  89. }
  90. }
  91. else
  92. {
  93. if (SP->termattrs & A_BLINK)
  94. {
  95. SP->termattrs &= ~A_BLINK;
  96. PDC_blink_text();
  97. }
  98. }
  99. return OK;
  100. }
  101. int PDC_set_bold(bool boldon)
  102. {
  103. return boldon ? ERR : OK;
  104. }