forked from Bill-Gray/PDCursesMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdcsetsc.c
158 lines (135 loc) · 4.62 KB
/
pdcsetsc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include <stdio.h>
#include <curspriv.h>
#include "pdcvt.h"
/*man-start**************************************************************
pdcsetsc
--------
### Synopsis
int PDC_set_blink(bool blinkon);
int PDC_set_bold(bool boldon);
void PDC_set_title(const char *title);
### Description
PDC_set_blink() toggles whether the A_BLINK attribute sets an actual
blink mode (TRUE), or sets the background color to high intensity
(FALSE). The default is platform-dependent (FALSE in most cases). It
returns OK if it could set the state to match the given parameter,
ERR otherwise.
PDC_set_bold() toggles whether the A_BOLD attribute selects an actual
bold font (TRUE), or sets the foreground color to high intensity
(FALSE). It returns OK if it could set the state to match the given
parameter, ERR otherwise.
PDC_set_title() sets the title of the window in which the curses
program is running. This function may not do anything on some
platforms.
### Portability
X/Open ncurses NetBSD
PDC_set_blink - - -
PDC_set_title - - -
**man-end****************************************************************/
/* #define BLINKING_CURSOR CSI "?12h" */
#define BLINKING_BLOCK CSI "1 q"
#define STEADY_BLOCK CSI "2 q"
#define BLINKING_UNDERLINE CSI "3 q"
#define STEADY_UNDERLINE CSI "4 q"
/* "bar" = "vertical line". xterm only. */
#define BLINKING_BAR CSI "5 q"
#define STEADY_BAR CSI "6 q"
#define CURSOR_ON CSI "?25h"
#define CURSOR_OFF CSI "?25l"
int PDC_curs_set( int visibility)
{
int ret_vis;
PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
ret_vis = SP->visibility;
#ifndef LINUX_FRAMEBUFFER_PORT
if( !SP->visibility && visibility) /* turn cursor back on */
PDC_puts_to_stdout( CURSOR_ON);
else if( SP->visibility && !visibility)
PDC_puts_to_stdout( CURSOR_OFF);
#endif
SP->visibility = visibility;
#ifdef LINUX_FRAMEBUFFER_PORT
PDC_gotoyx( SP->cursrow, SP->curscol);
#else
if( !PDC_is_ansi)
{
const int vis1 = visibility & 0xff;
const int vis2 = (visibility >> 8) & 0xff;
const char *command;
if( vis1 && vis2) /* show solid */
switch( vis1)
{
case 1: /* "normal" = underline */
case 5: /* bottom half block; we don't actually have that */
command = STEADY_UNDERLINE;
break;
case 2: /* full block */
command = STEADY_BLOCK;
break;
case 4: /* caret */
command = STEADY_BAR;
break;
default: /* since we can't do outline, cross, etc. */
command = STEADY_UNDERLINE;
break;
}
else switch( vis1 ? vis1 : vis2)
{
case 0: /* just turning it off */
command = CURSOR_OFF;
break;
case 1: /* "normal" = underline */
case 5: /* bottom half block; we don't actually have that */
command = BLINKING_UNDERLINE;
break;
case 2: /* full block */
command = BLINKING_BLOCK;
break;
case 4: /* caret */
command = BLINKING_BAR;
break;
default: /* since we can't do outline, cross, etc. */
command = BLINKING_UNDERLINE;
break;
}
PDC_puts_to_stdout( command);
}
#endif
return ret_vis;
}
static int reset_attr( const attr_t attr, const bool attron)
{
attr_t prev_termattrs;
if (!SP)
return ERR;
prev_termattrs = SP->termattrs;
if( attron)
SP->termattrs |= attr;
else
SP->termattrs &= ~attr;
if( prev_termattrs != SP->termattrs)
curscr->_clear = TRUE;
return OK;
}
int PDC_set_blink(bool blinkon)
{
return( reset_attr( A_BLINK, blinkon));
}
int PDC_set_bold(bool boldon)
{
return( reset_attr( A_BOLD, boldon));
}
void PDC_set_title( const char *title)
{
PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
#if !defined( DOS) && !defined( LINUX_FRAMEBUFFER_PORT)
if( !PDC_is_ansi)
{
PDC_puts_to_stdout( OSC "2;");
PDC_puts_to_stdout( title);
PDC_puts_to_stdout( "\a");
}
#else
INTENTIONALLY_UNUSED_PARAMETER( title);
#endif
}