Add a test for the NX console device
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4528 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
e8c12b7433
commit
ac6fcaa5e3
@ -138,21 +138,37 @@ static ssize_t nxcon_write(FAR struct file *filep, FAR const char *buffer,
|
||||
|
||||
while (buflen-- > 0)
|
||||
{
|
||||
/* Ignore carriage returns */
|
||||
|
||||
ch = *buffer++;
|
||||
if (ch == '\r')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Will another character fit on this line? */
|
||||
|
||||
if (priv->fpos.x + priv->fwidth > priv->wndo.wsize.w)
|
||||
{
|
||||
#ifndef CONFIG_NXCONSOLE_NOWRAP
|
||||
/* No.. move to the next line */
|
||||
|
||||
nxcon_newline(priv);
|
||||
|
||||
/* If we were about to output a newline character, then don't */
|
||||
|
||||
if (*buffer == '\n')
|
||||
if (ch == '\n')
|
||||
{
|
||||
buffer++;
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
/* No.. Ignore all further characters until a newline is encountered */
|
||||
|
||||
if (ch != '\n')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check if we need to scroll up (handling a corner case where
|
||||
@ -164,15 +180,9 @@ static ssize_t nxcon_write(FAR struct file *filep, FAR const char *buffer,
|
||||
nxcon_scroll(priv, lineheight);
|
||||
}
|
||||
|
||||
/* Ignore carriage returns */
|
||||
/* Finally, we can output the character */
|
||||
|
||||
ch = *buffer++;
|
||||
if (ch != '\r')
|
||||
{
|
||||
/* Finally, we can output the character */
|
||||
|
||||
nxcon_putc(priv, (uint8_t)ch);
|
||||
}
|
||||
nxcon_putc(priv, (uint8_t)ch);
|
||||
}
|
||||
|
||||
return buflen;
|
||||
|
@ -407,37 +407,37 @@ nxcon_addchar(NXHANDLE hfont, FAR struct nxcon_state_s *priv, uint8_t ch)
|
||||
|
||||
if (priv->nchars < priv->maxchars)
|
||||
{
|
||||
/* Yes, setup the bitmap information */
|
||||
/* Yes, setup the bitmap information */
|
||||
|
||||
bm = &priv->bm[priv->nchars];
|
||||
bm->code = ch;
|
||||
bm->flags = 0;
|
||||
bm->pos.x = priv->fpos.x;
|
||||
bm->pos.y = priv->fpos.y;
|
||||
bm = &priv->bm[priv->nchars];
|
||||
bm->code = ch;
|
||||
bm->flags = 0;
|
||||
bm->pos.x = priv->fpos.x;
|
||||
bm->pos.y = priv->fpos.y;
|
||||
|
||||
/* Find (or create) the matching glyph */
|
||||
/* Find (or create) the matching glyph */
|
||||
|
||||
glyph = nxcon_getglyph(hfont, priv, ch);
|
||||
if (!glyph)
|
||||
{
|
||||
/* No, there is no font for this code. Just mark this as a space. */
|
||||
glyph = nxcon_getglyph(hfont, priv, ch);
|
||||
if (!glyph)
|
||||
{
|
||||
/* No, there is no font for this code. Just mark this as a space. */
|
||||
|
||||
bm->flags |= BMFLAGS_NOGLYPH;
|
||||
bm->flags |= BMFLAGS_NOGLYPH;
|
||||
|
||||
/* Set up the next character position */
|
||||
/* Set up the next character position */
|
||||
|
||||
priv->fpos.x += priv->spwidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set up the next character position */
|
||||
priv->fpos.x += priv->spwidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set up the next character position */
|
||||
|
||||
priv->fpos.x += glyph->width;
|
||||
}
|
||||
priv->fpos.x += glyph->width;
|
||||
}
|
||||
|
||||
/* Success.. increment nchars to retain this character */
|
||||
/* Success.. increment nchars to retain this character */
|
||||
|
||||
priv->nchars++;
|
||||
priv->nchars++;
|
||||
}
|
||||
|
||||
return bm;
|
||||
|
@ -171,6 +171,28 @@ EXTERN NXCONSOLE nxtool_register(NXTKWINDOW hfwnd,
|
||||
|
||||
EXTERN void nxcon_unregister(NXCONSOLE handle);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxcon_redraw
|
||||
*
|
||||
* Description:
|
||||
* Re-draw a portion of the NX console. This function should be called
|
||||
* from the appropriate window callback logic.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - A handle previously returned by nx_register, nxtk_register, or
|
||||
* nxtool_register.
|
||||
* rect - The rectangle that needs to be re-drawn (in window relative
|
||||
* coordinates)
|
||||
* more - true: More re-draw requests will follow
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect,
|
||||
bool more);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user