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:
patacongo 2012-03-27 16:59:15 +00:00
parent e8c12b7433
commit ac6fcaa5e3
3 changed files with 64 additions and 32 deletions

View File

@ -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,16 +180,10 @@ static ssize_t nxcon_write(FAR struct file *filep, FAR const char *buffer,
nxcon_scroll(priv, lineheight);
}
/* Ignore carriage returns */
ch = *buffer++;
if (ch != '\r')
{
/* Finally, we can output the character */
nxcon_putc(priv, (uint8_t)ch);
}
}
return buflen;
}

View File

@ -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)
}