1 /* Public Domain Curses */
2 
3 #include "pdcwin.h"
4 #include "pdccolor.h"
5 
6 /*man-start**************************************************************
7 
8 pdcsetsc
9 --------
10 
11 ### Synopsis
12 
13     int PDC_set_blink(bool blinkon);
14     int PDC_set_bold(bool boldon);
15     void PDC_set_title(const char *title);
16 
17 ### Description
18 
19    PDC_set_blink() toggles whether the A_BLINK attribute sets an actual
20    blink mode (TRUE), or sets the background color to high intensity
21    (FALSE). The default is platform-dependent (FALSE in most cases). It
22    returns OK if it could set the state to match the given parameter,
23    ERR otherwise.
24 
25    PDC_set_bold() toggles whether the A_BOLD attribute selects an actual
26    bold font (TRUE), or sets the foreground color to high intensity
27    (FALSE). It returns OK if it could set the state to match the given
28    parameter, ERR otherwise.
29 
30    PDC_set_title() sets the title of the window in which the curses
31    program is running. This function may not do anything on some
32    platforms.
33 
34 ### Portability
35                              X/Open  ncurses  NetBSD
36     PDC_set_blink               -       -       -
37     PDC_set_bold                -       -       -
38     PDC_set_title               -       -       -
39 
40 **man-end****************************************************************/
41 
42                 /* Note that the following is a line-for-line   */
43                 /* copy of the SDL version of this function.    */
PDC_curs_set(int visibility)44 int PDC_curs_set(int visibility)
45 {
46     int ret_vis;
47 
48     PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
49 
50     ret_vis = SP->visibility;
51 
52     SP->visibility = visibility;
53 
54     PDC_gotoyx(SP->cursrow, SP->curscol);
55 
56     return ret_vis;
57 }
58 
PDC_set_title(const char * title)59 void PDC_set_title(const char *title)
60 {
61     extern HWND PDC_hWnd;
62 #ifdef PDC_WIDE
63     wchar_t wtitle[512];
64 #endif
65     PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
66 
67 #ifdef PDC_WIDE
68     PDC_mbstowcs(wtitle, title, 511);
69     SetWindowTextW( PDC_hWnd, wtitle);
70 #else
71     SetWindowTextA( PDC_hWnd, title);
72 #endif
73 }
74 
75         /* If SP->termattrs & A_BLINK is on, then text with the A_BLINK  */
76         /* attribute will actually blink.  Otherwise,  such text will    */
77         /* be shown with higher color intensity (the R, G, and B values  */
78         /* are averaged with pure white).  See pdcdisp.c for details of  */
79         /* how this is done.                                             */
80         /*     Unlike on other PDCurses platforms,  this doesn't require */
81         /* decreasing the number of colors by half.  Also,  the choice   */
82         /* indicated by 'blinkon' will actually be respected,  so OK is  */
83         /* always returned (most platforms don't actually support        */
84         /* blinking).                                                    */
85         /*      The default behavior is to not show A_BLINK text as      */
86         /* blinking,  i.e., SP->termattrs & A_BLINK = 0.  Blinking text  */
87         /* can be pretty annoying to some people.  You should probably   */
88         /* call PDC_set_blink( TRUE) only if there is something to which */
89         /* the user _must_ pay attention;  say,  "the nuclear reactor    */
90         /* is about to melt down".  Otherwise,  the bolder,  brighter    */
91         /* text should be attention-getting enough.                      */
92 
reset_attr(const attr_t attr,const bool attron)93 static int reset_attr( const attr_t attr, const bool attron)
94 {
95     if (!SP)
96         return ERR;
97     if( attron)
98         SP->termattrs |= attr;
99     else
100         SP->termattrs &= ~attr;
101     return OK;
102 }
103 
PDC_set_blink(bool blinkon)104 int PDC_set_blink(bool blinkon)
105 {
106    return( reset_attr( A_BLINK, blinkon));
107 }
108 
PDC_set_bold(bool boldon)109 int PDC_set_bold(bool boldon)
110 {
111    return( reset_attr( A_BOLD, boldon));
112 }
113