diff --git a/graphics/nxconsole/nxcon_driver.c b/graphics/nxconsole/nxcon_driver.c index 71fa2aabfd..58ad027fe6 100755 --- a/graphics/nxconsole/nxcon_driver.c +++ b/graphics/nxconsole/nxcon_driver.c @@ -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; diff --git a/graphics/nxconsole/nxcon_font.c b/graphics/nxconsole/nxcon_font.c index 2152d8cbc5..c3280046be 100644 --- a/graphics/nxconsole/nxcon_font.c +++ b/graphics/nxconsole/nxcon_font.c @@ -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; diff --git a/include/nuttx/nx/nxconsole.h b/include/nuttx/nx/nxconsole.h index ce494bc39b..3980d3a1ea 100644 --- a/include/nuttx/nx/nxconsole.h +++ b/include/nuttx/nx/nxconsole.h @@ -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) }