• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/gnulib-lib/
1/* Output stream for attributed text, producing ANSI escape sequences.
2   Copyright (C) 2006 Free Software Foundation, Inc.
3   Written by Bruno Haible <bruno@clisp.org>, 2006.
4
5   This program is free software: you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 3 of the License, or
8   (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18#ifndef _TERM_OSTREAM_H
19#define _TERM_OSTREAM_H
20
21#include "ostream.h"
22
23
24/* Querying and setting of text attributes.
25   The stream has a notion of the current text attributes; they apply
26   implicitly to all following output.  The attributes are automatically
27   reset when the stream is closed.
28   Note: Not all terminal types can actually render all attributes adequately.
29   For example, xterm cannot render POSTURE_ITALIC nor the combination of
30   WEIGHT_BOLD and UNDERLINE_ON.  */
31
32/* Colors are represented by indices >= 0 in a stream dependent format.  */
33typedef int term_color_t;
34/* The value -1 denotes the default (foreground or background) color.  */
35enum
36{
37  COLOR_DEFAULT = -1  /* unknown */
38};
39
40typedef enum
41{
42  WEIGHT_NORMAL = 0,
43  WEIGHT_BOLD,
44  WEIGHT_DEFAULT = WEIGHT_NORMAL
45} term_weight_t;
46
47typedef enum
48{
49  POSTURE_NORMAL = 0,
50  POSTURE_ITALIC, /* same as oblique */
51  POSTURE_DEFAULT = POSTURE_NORMAL
52} term_posture_t;
53
54typedef enum
55{
56  UNDERLINE_OFF = 0,
57  UNDERLINE_ON,
58  UNDERLINE_DEFAULT = UNDERLINE_OFF
59} term_underline_t;
60
61struct term_ostream : struct ostream
62{
63methods:
64
65  /* Convert an RGB value (red, green, blue in [0..255]) to a color, valid
66     for this stream only.  */
67  term_color_t rgb_to_color (term_ostream_t stream,
68			     int red, int green, int blue);
69
70  /* Get/set the text color.  */
71  term_color_t get_color (term_ostream_t stream);
72  void         set_color (term_ostream_t stream, term_color_t color);
73
74  /* Get/set the background color.  */
75  term_color_t get_bgcolor (term_ostream_t stream);
76  void         set_bgcolor (term_ostream_t stream, term_color_t color);
77
78  /* Get/set the font weight.  */
79  term_weight_t get_weight (term_ostream_t stream);
80  void          set_weight (term_ostream_t stream, term_weight_t weight);
81
82  /* Get/set the font posture.  */
83  term_posture_t get_posture (term_ostream_t stream);
84  void           set_posture (term_ostream_t stream, term_posture_t posture);
85
86  /* Get/set the text underline decoration.  */
87  term_underline_t get_underline (term_ostream_t stream);
88  void             set_underline (term_ostream_t stream,
89				  term_underline_t underline);
90};
91
92
93#ifdef __cplusplus
94extern "C" {
95#endif
96
97
98/* Create an output stream referring to the file descriptor FD.
99   FILENAME is used only for error messages.
100   The resulting stream will be line-buffered.
101   Note that the resulting stream must be closed before FD can be closed.  */
102extern term_ostream_t term_ostream_create (int fd, const char *filename);
103
104
105#ifdef __cplusplus
106}
107#endif
108
109#endif /* _TERM_OSTREAM_H */
110