4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
30 * Copyright 1999 Bernie Innocenti <bernie@codewiz.org>
34 * \brief Text graphic routines (interface)
36 * \author Bernie Innocenti <bernie@codewiz.org>
37 * \author Stefano Fedrigo <aleph@develer.com>
40 * $WIZ$ module_name = "text"
41 * $WIZ$ module_harvard = "pgm_memory"
42 * $WIZ% module_depends = "bitmap"
48 #include <cfg/compiler.h>
49 #include <cfg/macros.h> /* BV() */
50 #include <cpu/attr.h> /* CPU_HARVARD */
51 #include <gfx/gfx.h> /* coord_t */
60 #define STYLEF_BOLD BV(0)
61 #define STYLEF_ITALIC BV(1)
62 #define STYLEF_UNDERLINE BV(2)
63 #define STYLEF_INVERT BV(3)
64 #define STYLEF_EXPANDED BV(4)
65 #define STYLEF_CONDENSED BV(5)
66 #define STYLEF_STRIKEOUT BV(6) /*<! Not implemented */
67 #define STYLEF_TALL BV(7) /*<! Not implemented */
70 (STYLEF_BOLD | STYLEF_ITALIC | STYLEF_UNDERLINE \
71 | STYLEF_INVERT | STYLEF_EXPANDED | STYLEF_CONDENSED \
72 | STYLEF_STRIKEOUT | STYLEF_TALL)
76 * \name Formatting flags for text rendering
80 #define TEXT_NORMAL 0 /**< Normal mode */
81 #define TEXT_FILL BV(13) /**< Fill rest of line with spaces */
82 #define TEXT_CENTER BV(14) /**< Center string in line */
83 #define TEXT_RIGHT BV(15) /**< Right aligned */
86 /** Escape sequences codes */
87 #define ANSI_ESC_CLEARSCREEN 'c'
93 /* Low-level text functions (mware/text.c) */
94 void text_moveTo(struct Bitmap *bm, int row, int col);
95 void text_setCoord(struct Bitmap *bm, int x, int y);
96 int text_putchar(char c, struct Bitmap *bm);
97 uint8_t text_style(struct Bitmap *bm, uint8_t flags, uint8_t mask);
98 void text_clear(struct Bitmap *bm);
99 void text_clearLine(struct Bitmap *bm, int line);
101 /* Text formatting functions (mware/text_format.c) */
102 int text_puts(const char *str, struct Bitmap *bm);
103 int text_vprintf(struct Bitmap *bm, const char *fmt, va_list ap);
104 int text_printf(struct Bitmap *bm, const char *fmt, ...) FORMAT(__printf__, 2, 3);
105 int text_xyvprintf(struct Bitmap *bm, coord_t x, coord_t y, uint16_t mode, const char *fmt, va_list ap);
106 int text_xyprintf(struct Bitmap *bm, coord_t x, coord_t col, uint16_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
107 int text_xprintf(struct Bitmap *bm, uint8_t row, uint8_t col, uint16_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
108 int text_vwidthf(struct Bitmap *bm, const char * fmt, va_list ap);
109 int text_widthf(struct Bitmap *bm, const char * fmt, ...) FORMAT(__printf__, 2, 3);
111 /* Text formatting functions for program-memory strings (mware/text_format.c) */
114 int text_puts_P(const char * PROGMEM str, struct Bitmap *bm);
115 int text_vprintf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
116 int text_printf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...) FORMAT(__printf__, 2, 3);
117 int text_xyvprintf_P(struct Bitmap *bm, coord_t x, coord_t y, uint16_t mode, const char *fmt, va_list ap);
118 int text_xyprintf_P(struct Bitmap *bm, coord_t x, coord_t col, uint16_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
119 int text_xprintf_P(struct Bitmap *bm, uint8_t row, uint8_t col, uint16_t mode, const char * PROGMEM fmt, ...) FORMAT(__printf__, 5, 6);
120 int text_vwidthf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
121 int text_widthf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...);
122 #endif /* CPU_HARVARD */
124 #endif /* GFX_TEXT_H */