more update
This commit is contained in:
parent
b6a8a15536
commit
b75f69d7a0
2 changed files with 63 additions and 59 deletions
|
@ -70,11 +70,69 @@ typedef struct GConsoleObject_t {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font);
|
/**
|
||||||
BaseSequentialStream *gwinGetConsoleStream(GHandle gh);
|
* @brief Create a console window.
|
||||||
void gwinPutChar(GHandle gh, char c);
|
* @details A console window allows text to be written using chprintf() (and the console functions defined here).
|
||||||
void gwinPutString(GHandle gh, const char *str);
|
* @brief Text in a console window supports newlines and will wrap text as required.
|
||||||
void gwinPutCharArray(GHandle gh, const char *str, size_t n);
|
* @return NULL if there is no resultant drawing area, otherwise a window handle.
|
||||||
|
*
|
||||||
|
* @param[in] gc The GConsoleObject structure to initialise. If this is NULL the structure is dynamically allocated.
|
||||||
|
* @param[in] x,y The screen co-ordinates for the bottom left corner of the window
|
||||||
|
* @param[in] width The width of the window
|
||||||
|
* @param[in] height The height of the window
|
||||||
|
* @param[in] font The font to use
|
||||||
|
* @note The console is not automatically cleared on creation. You must do that by calling gwinClear() (possibly after changing your background color)
|
||||||
|
* @note If the dispay does not support scrolling, the window will be cleared when the bottom line is reached.
|
||||||
|
* @note The default drawing color gets set to White and the background drawing color to Black.
|
||||||
|
* @note The dimensions and position may be changed to fit on the real screen.
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a stream from a console window suitable for use with chprintf().
|
||||||
|
* @return The stream handle or NULL if this is not a console window.
|
||||||
|
*
|
||||||
|
* @param[in] gh The window handle (must be a console window)
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
BaseSequentialStream *gwinGetConsoleStream(GHandle gh);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put a character at the cursor position in the window.
|
||||||
|
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
|
||||||
|
*
|
||||||
|
* @param[in] gh The window handle (must be a console window)
|
||||||
|
* @param[in] c The character to draw
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
void gwinPutChar(GHandle gh, char c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put a string at the cursor position in the window. It will wrap lines as required.
|
||||||
|
* @note Uses the current foreground color to draw the string and fills the background using the background drawing color
|
||||||
|
*
|
||||||
|
* @param[in] gh The window handle (must be a console window)
|
||||||
|
* @param[in] str The string to draw
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
void gwinPutString(GHandle gh, const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Put the character array at the cursor position in the window. It will wrap lines as required.
|
||||||
|
* @note Uses the current foreground color to draw the string and fills the background using the background drawing color
|
||||||
|
*
|
||||||
|
* @param[in] gh The window handle (must be a console window)
|
||||||
|
* @param[in] str The string to draw
|
||||||
|
* @param[in] n The number of characters to draw
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
void gwinPutCharArray(GHandle gh, const char *str, size_t n);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,24 +70,6 @@ static const struct GConsoleWindowVMT_t GWindowConsoleVMT = {
|
||||||
GWinStreamReadTimed
|
GWinStreamReadTimed
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Create a console window.
|
|
||||||
* @details A console window allows text to be written using chprintf() (and the console functions defined here).
|
|
||||||
* @brief Text in a console window supports newlines and will wrap text as required.
|
|
||||||
* @return NULL if there is no resultant drawing area, otherwise a window handle.
|
|
||||||
*
|
|
||||||
* @param[in] gc The GConsoleObject structure to initialise. If this is NULL the structure is dynamically allocated.
|
|
||||||
* @param[in] x,y The screen co-ordinates for the bottom left corner of the window
|
|
||||||
* @param[in] width The width of the window
|
|
||||||
* @param[in] height The height of the window
|
|
||||||
* @param[in] font The font to use
|
|
||||||
* @note The console is not automatically cleared on creation. You must do that by calling gwinClear() (possibly after changing your background color)
|
|
||||||
* @note If the dispay does not support scrolling, the window will be cleared when the bottom line is reached.
|
|
||||||
* @note The default drawing color gets set to White and the background drawing color to Black.
|
|
||||||
* @note The dimensions and position may be changed to fit on the real screen.
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font) {
|
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font) {
|
||||||
if (!(gc = (GConsoleObject *)_gwinInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject))))
|
if (!(gc = (GConsoleObject *)_gwinInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject))))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -99,29 +81,12 @@ GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t widt
|
||||||
return (GHandle)gc;
|
return (GHandle)gc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get a stream from a console window suitable for use with chprintf().
|
|
||||||
* @return The stream handle or NULL if this is not a console window.
|
|
||||||
*
|
|
||||||
* @param[in] gh The window handle (must be a console window)
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
BaseSequentialStream *gwinGetConsoleStream(GHandle gh) {
|
BaseSequentialStream *gwinGetConsoleStream(GHandle gh) {
|
||||||
if (gh->type != GW_CONSOLE)
|
if (gh->type != GW_CONSOLE)
|
||||||
return 0;
|
return 0;
|
||||||
return (BaseSequentialStream *)&(((GConsoleObject *)(gh))->stream);
|
return (BaseSequentialStream *)&(((GConsoleObject *)(gh))->stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Put a character at the cursor position in the window.
|
|
||||||
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
|
|
||||||
*
|
|
||||||
* @param[in] gh The window handle (must be a console window)
|
|
||||||
* @param[in] c The character to draw
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
void gwinPutChar(GHandle gh, char c) {
|
void gwinPutChar(GHandle gh, char c) {
|
||||||
uint8_t width;
|
uint8_t width;
|
||||||
#define gcw ((GConsoleObject *)gh)
|
#define gcw ((GConsoleObject *)gh)
|
||||||
|
@ -178,30 +143,11 @@ void gwinPutChar(GHandle gh, char c) {
|
||||||
#undef gcw
|
#undef gcw
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Put a string at the cursor position in the window. It will wrap lines as required.
|
|
||||||
* @note Uses the current foreground color to draw the string and fills the background using the background drawing color
|
|
||||||
*
|
|
||||||
* @param[in] gh The window handle (must be a console window)
|
|
||||||
* @param[in] str The string to draw
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
void gwinPutString(GHandle gh, const char *str) {
|
void gwinPutString(GHandle gh, const char *str) {
|
||||||
while(*str)
|
while(*str)
|
||||||
gwinPutChar(gh, *str++);
|
gwinPutChar(gh, *str++);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Put the character array at the cursor position in the window. It will wrap lines as required.
|
|
||||||
* @note Uses the current foreground color to draw the string and fills the background using the background drawing color
|
|
||||||
*
|
|
||||||
* @param[in] gh The window handle (must be a console window)
|
|
||||||
* @param[in] str The string to draw
|
|
||||||
* @param[in] n The number of characters to draw
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
void gwinPutCharArray(GHandle gh, const char *str, size_t n) {
|
void gwinPutCharArray(GHandle gh, const char *str, size_t n) {
|
||||||
while(n--)
|
while(n--)
|
||||||
gwinPutChar(gh, *str++);
|
gwinPutChar(gh, *str++);
|
||||||
|
|
Loading…
Add table
Reference in a new issue