File: display.c

package info (click to toggle)
ips 4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 664 kB
  • sloc: ansic: 10,438; makefile: 25
file content (178 lines) | stat: -rw-r--r-- 2,568 bytes parent folder | download | duplicates (4)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
 * Configurable ps-like program.
 * High-level display device routines.
 * These global routines call the currently selected display routines.
 *
 * Copyright (c) 2010 David I. Bell
 * Permission is granted to use, distribute, or modify this source,
 * provided that this copyright notice remains intact.
 */

#include "ips.h"


/*
 * The current display device.
 */
static	DISPLAY *	display;


/*
 * Set the display type to use for later dpy calls.
 * A NULL or illegal type sets the display type to a dumb terminal.
 * Returns TRUE if the display type was NULL or was known.
 */
BOOL
DpySetDisplay(const char * type)
{
	if ((type == NULL) || (strcmp(type, DISPLAY_TYPE_TTY) == 0))
		display = GetTtyDisplay();
	else if (strcmp(type, DISPLAY_TYPE_CURSES) == 0)
		display = GetCursesDisplay();
#ifdef X11
	else if (strcmp(type, DISPLAY_TYPE_X11) == 0)
		display = GetX11Display();
#endif
	else
	{
		display = GetTtyDisplay();

		return FALSE;
	}

	return TRUE;
}


BOOL
DpyOpen(void)
{
	return display->open(display);
}


BOOL
DpyDefineColor(int colorId, const char * foreground, const char * background, int flags)
{
	return display->defineColor(display, colorId, foreground, background, flags);
}


void
DpyCreateWindow()
{
	display->createWindow(display);
}


void
DpyClose(void)
{
	display->close(display);
}


void
DpySetColor(int colorId)
{
	display->setColor(display, colorId);
}


void
DpyRefresh(void)
{
	display->refresh(display);
}


void
DpyBeginPage(void)
{
	display->beginPage(display);
}


void
DpyChar(int ch)
{
	display->putChar(display, ch);
}


void
DpyString(const char * str)
{
	display->putString(display, str);
}


void
DpyBuffer(const char * buffer, int length)
{
	display->putBuffer(display, buffer, length);
}


void
DpyEndPage(void)
{
	display->endPage(display);
}


/*
 * Handle any events from the display device while waiting for the
 * specified number of milliSeconds.  This call returns early if an
 * input character is available for reading or if a refresh is required.
 * Returns TRUE if a refresh is required due to a window resize.
 */
BOOL
DpyEventWait(int milliSeconds)
{
	return display->eventWait(display, milliSeconds);
}


BOOL
DpyInputReady(void)
{
	return display->inputReady(display);
}


int
DpyReadChar(void)
{
	return display->readChar(display);
}


void
DpyRingBell(void)
{
	display->ringBell(display);
}


int
DpyGetRows(void)
{
	return display->getRows(display);
}


int
DpyGetCols(void)
{
	return display->getCols(display);
}


BOOL
DpyDoesScroll(void)
{
	return display->doesScroll(display);
}

/* END CODE */