mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
graphics/nxterm and configs/open1788: Various fixes to get the NxTerm example working in PROTECTED mode with the Open1788 knxterm configuration. Basically works until the screen becomes full and it starts scrolling. Then characters are missing from the display. Needs more debug and test.
This commit is contained in:
@@ -184,6 +184,5 @@ static int nxterm_bitmap(FAR struct nxterm_state_s *priv,
|
||||
|
||||
NXTERM nx_register(NXWINDOW hwnd, FAR struct nxterm_window_s *wndo, int minor)
|
||||
{
|
||||
return nxterm_register((NXTERM)hwnd, wndo, &g_nxops, minor);
|
||||
return nxterm_register((NXTERM)hwnd, wndo, &wndo->wsize, &g_nxops, minor);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ struct nxterm_state_s
|
||||
FAR const struct nxterm_operations_s *ops; /* Window operations */
|
||||
FAR void *handle; /* The window handle */
|
||||
FAR struct nxterm_window_s wndo; /* Describes the window and font */
|
||||
struct nxgl_size_s wsize; /* NXTK main window size */
|
||||
sem_t exclsem; /* Forces mutually exclusive access */
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
pid_t holder; /* Deadlock avoidance */
|
||||
@@ -202,8 +203,8 @@ int nxterm_sempost(FAR struct nxterm_state_s *priv);
|
||||
/* Common device registration/un-registration */
|
||||
|
||||
FAR struct nxterm_state_s *nxterm_register(NXTERM handle,
|
||||
FAR struct nxterm_window_s *wndo, FAR const struct nxterm_operations_s *ops,
|
||||
int minor);
|
||||
FAR struct nxterm_window_s *wndo, FAR struct nxgl_size_s *wsize,
|
||||
FAR const struct nxterm_operations_s *ops, int minor);
|
||||
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||
void nxterm_unregister(FAR struct nxterm_state_s *priv);
|
||||
#endif
|
||||
|
||||
@@ -82,6 +82,59 @@ static int nxterm_fontsize(FAR struct nxterm_state_s *priv, uint8_t ch,
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxterm_fillspace
|
||||
****************************************************************************/
|
||||
|
||||
static void nxterm_fillspace(FAR struct nxterm_state_s *priv,
|
||||
FAR const struct nxgl_rect_s *rect,
|
||||
FAR const struct nxterm_bitmap_s *bm)
|
||||
{
|
||||
#if 0 /* Not necessary */
|
||||
struct nxgl_rect_s bounds;
|
||||
struct nxgl_rect_s intersection;
|
||||
int ret;
|
||||
|
||||
/* Construct a bounding box for the glyph */
|
||||
|
||||
bounds.pt1.x = bm->pos.x;
|
||||
bounds.pt1.y = bm->pos.y;
|
||||
bounds.pt2.x = bm->pos.x + priv->spwidth - 1;
|
||||
bounds.pt2.y = bm->pos.y + priv->fheight - 1;
|
||||
|
||||
# /* Should this also be clipped to a region in the window? */
|
||||
|
||||
if (rect != NULL)
|
||||
{
|
||||
/* Get the intersection of the redraw region and the character bitmap */
|
||||
|
||||
nxgl_rectintersect(&intersection, rect, &bounds);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The intersection is the whole glyph */
|
||||
|
||||
nxgl_rectcopy(&intersection, &bounds);
|
||||
}
|
||||
|
||||
/* Check for empty intersections */
|
||||
|
||||
if (!nxgl_nullrect(&intersection))
|
||||
{
|
||||
/* Fill the bitmap region with the background color, erasing the
|
||||
* character from the display. NOTE: This region might actually
|
||||
* be obscured... NX will handle that case.
|
||||
*/
|
||||
|
||||
ret = priv->ops->fill(priv, &intersection, priv->wndo.wcolor);
|
||||
if (ret < 0)
|
||||
{
|
||||
gerr("ERROR: fill() method failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -150,7 +203,7 @@ nxterm_addchar(FAR struct nxterm_state_s *priv, uint8_t ch)
|
||||
****************************************************************************/
|
||||
|
||||
int nxterm_hidechar(FAR struct nxterm_state_s *priv,
|
||||
FAR const struct nxterm_bitmap_s *bm)
|
||||
FAR const struct nxterm_bitmap_s *bm)
|
||||
{
|
||||
struct nxgl_rect_s bounds;
|
||||
struct nxgl_size_s fsize;
|
||||
@@ -285,6 +338,7 @@ void nxterm_fillchar(FAR struct nxterm_state_s *priv,
|
||||
|
||||
if (BM_ISSPACE(bm))
|
||||
{
|
||||
nxterm_fillspace(priv, rect, bm);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -311,7 +365,7 @@ void nxterm_fillchar(FAR struct nxterm_state_s *priv,
|
||||
|
||||
/* Should this also be clipped to a region in the window? */
|
||||
|
||||
if (rect)
|
||||
if (rect != NULL)
|
||||
{
|
||||
/* Get the intersection of the redraw region and the character bitmap */
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxterm_putc
|
||||
*
|
||||
@@ -77,7 +81,7 @@ void nxterm_putc(FAR struct nxterm_state_s *priv, uint8_t ch)
|
||||
|
||||
/* Will another character fit on this line? */
|
||||
|
||||
if (priv->fpos.x + priv->fwidth > priv->wndo.wsize.w)
|
||||
if (priv->fpos.x + priv->fwidth > priv->wsize.w)
|
||||
{
|
||||
#ifndef CONFIG_NXTERM_NOWRAP
|
||||
/* No.. move to the next line */
|
||||
@@ -113,7 +117,7 @@ void nxterm_putc(FAR struct nxterm_state_s *priv, uint8_t ch)
|
||||
/* Check if we need to scroll up */
|
||||
|
||||
lineheight = (priv->fheight + CONFIG_NXTERM_LINESEPARATION);
|
||||
while (priv->fpos.y >= priv->wndo.wsize.h - lineheight)
|
||||
while (priv->fpos.y >= priv->wsize.h - lineheight)
|
||||
{
|
||||
nxterm_scroll(priv, lineheight);
|
||||
}
|
||||
@@ -143,7 +147,7 @@ void nxterm_showcursor(FAR struct nxterm_state_s *priv)
|
||||
|
||||
/* Will another character fit on this line? */
|
||||
|
||||
if (priv->fpos.x + priv->fwidth > priv->wndo.wsize.w)
|
||||
if (priv->fpos.x + priv->fwidth > priv->wsize.w)
|
||||
{
|
||||
#ifndef CONFIG_NXTERM_NOWRAP
|
||||
/* No.. move to the next line */
|
||||
@@ -157,7 +161,7 @@ void nxterm_showcursor(FAR struct nxterm_state_s *priv)
|
||||
/* Check if we need to scroll up */
|
||||
|
||||
lineheight = (priv->fheight + CONFIG_NXTERM_LINESEPARATION);
|
||||
while (priv->fpos.y >= priv->wndo.wsize.h - lineheight)
|
||||
while (priv->fpos.y >= priv->wsize.h - lineheight)
|
||||
{
|
||||
nxterm_scroll(priv, lineheight);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@
|
||||
|
||||
FAR struct nxterm_state_s *
|
||||
nxterm_register(NXTERM handle, FAR struct nxterm_window_s *wndo,
|
||||
FAR const struct nxterm_operations_s *ops, int minor)
|
||||
FAR struct nxgl_size_s *wsize,
|
||||
FAR const struct nxterm_operations_s *ops, int minor)
|
||||
{
|
||||
FAR struct nxterm_state_s *priv;
|
||||
FAR const struct nx_font_s *fontset;
|
||||
@@ -87,7 +88,9 @@ FAR struct nxterm_state_s *
|
||||
priv->ops = ops;
|
||||
priv->handle = handle;
|
||||
priv->minor = minor;
|
||||
|
||||
memcpy(&priv->wndo, wndo, sizeof(struct nxterm_window_s));
|
||||
memcpy(&priv->wsize, wsize, sizeof(struct nxgl_size_s));
|
||||
|
||||
nxsem_init(&priv->exclsem, 0, 1);
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
|
||||
@@ -85,7 +85,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
|
||||
*/
|
||||
|
||||
rect.pt1.x = 0;
|
||||
rect.pt2.x = priv->wndo.wsize.w - 1;
|
||||
rect.pt2.x = priv->wsize.w - 1;
|
||||
|
||||
for (row = CONFIG_NXTERM_LINESEPARATION; row < bottom; row += scrollheight)
|
||||
{
|
||||
@@ -107,7 +107,8 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
|
||||
for (i = 0; i < priv->nchars; i++)
|
||||
{
|
||||
bm = &priv->bm[i];
|
||||
if (bm->pos.y <= rect.pt2.y && bm->pos.y + priv->fheight >= rect.pt1.y)
|
||||
if (bm->pos.y <= rect.pt2.y &&
|
||||
bm->pos.y + priv->fheight >= rect.pt1.y)
|
||||
{
|
||||
nxterm_fillchar(priv, &rect, bm);
|
||||
}
|
||||
@@ -117,7 +118,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
|
||||
/* Finally, clear the vacated part of the display */
|
||||
|
||||
rect.pt1.y = bottom;
|
||||
rect.pt2.y = priv->wndo.wsize.h - 1;
|
||||
rect.pt2.y = priv->wsize.h - 1;
|
||||
|
||||
ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
|
||||
if (ret < 0)
|
||||
@@ -145,8 +146,8 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
|
||||
|
||||
rect.pt1.x = 0;
|
||||
rect.pt1.y = scrollheight;
|
||||
rect.pt2.x = priv->wndo.wsize.w - 1;
|
||||
rect.pt2.y = priv->wndo.wsize.h - 1;
|
||||
rect.pt2.x = priv->wsize.w - 1;
|
||||
rect.pt2.y = priv->wsize.h - 1;
|
||||
|
||||
/* The offset that determines how far to move the source rectangle */
|
||||
|
||||
@@ -163,7 +164,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
|
||||
|
||||
/* Finally, clear the vacated bottom part of the display */
|
||||
|
||||
rect.pt1.y = priv->wndo.wsize.h - scrollheight;
|
||||
rect.pt1.y = priv->wsize.h - scrollheight;
|
||||
|
||||
ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
|
||||
if (ret < 0)
|
||||
@@ -198,9 +199,9 @@ void nxterm_scroll(FAR struct nxterm_state_s *priv, int scrollheight)
|
||||
{
|
||||
/* Yes... Delete the character by moving all of the data */
|
||||
|
||||
for (j = i; j < priv->nchars-1; j++)
|
||||
for (j = i; j < priv->nchars - 1; j++)
|
||||
{
|
||||
memcpy(&priv->bm[j], &priv->bm[j+1],
|
||||
memcpy(&priv->bm[j], &priv->bm[j + 1],
|
||||
sizeof(struct nxterm_bitmap_s));
|
||||
}
|
||||
|
||||
@@ -209,6 +210,8 @@ void nxterm_scroll(FAR struct nxterm_state_s *priv, int scrollheight)
|
||||
*/
|
||||
|
||||
priv->nchars--;
|
||||
priv->bm[priv->nchars].code = ' ';
|
||||
priv->bm[priv->nchars].flags = BMFLAGS_NOGLYPH;
|
||||
}
|
||||
|
||||
/* No.. just decrement its vertical position (moving it "up" the
|
||||
|
||||
@@ -160,6 +160,22 @@ static int nxtkcon_bitmap(FAR struct nxterm_state_s *priv,
|
||||
return nxtk_bitmapwindow((NXTKWINDOW)priv->handle, dest, src, origin, stride);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxterm_tbheight
|
||||
*
|
||||
* Description:
|
||||
* Get the current height of the toolbar.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static nxgl_coord_t nxterm_tbheight(NXTKWINDOW hfwnd)
|
||||
{
|
||||
FAR struct nxgl_rect_s bounds;
|
||||
|
||||
(void)nxtk_toolbarbounds(hfwnd, &bounds);
|
||||
return bounds.pt2.y - bounds.pt1.y + 1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -182,7 +198,16 @@ static int nxtkcon_bitmap(FAR struct nxterm_state_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
NXTERM nxtk_register(NXTKWINDOW hfwnd, FAR struct nxterm_window_s *wndo, int minor)
|
||||
NXTERM nxtk_register(NXTKWINDOW hfwnd, FAR struct nxterm_window_s *wndo,
|
||||
int minor)
|
||||
{
|
||||
return nxterm_register((NXTERM)hfwnd, wndo, &g_nxtkops, minor);
|
||||
struct nxgl_size_s wsize;
|
||||
|
||||
/* REVISIT: What if the window or toolbar size changes? */
|
||||
|
||||
wsize.w = wndo->wsize.w - 2 * CONFIG_NXTK_BORDERWIDTH;
|
||||
wsize.h = wndo->wsize.h - nxterm_tbheight(hfwnd) -
|
||||
2 * CONFIG_NXTK_BORDERWIDTH;
|
||||
|
||||
return nxterm_register((NXTERM)hfwnd, wndo, &wsize, &g_nxtkops, minor);
|
||||
}
|
||||
|
||||
@@ -160,6 +160,24 @@ static int nxtool_bitmap(FAR struct nxterm_state_s *priv,
|
||||
return nxtk_bitmaptoolbar((NXTKWINDOW)priv->handle, dest, src, origin, stride);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxterm_toolbar_size
|
||||
*
|
||||
* Description:
|
||||
* Get the current size of the toolbar.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void nxterm_toolbar_size(NXTKWINDOW hfwnd,
|
||||
FAR struct nxgl_size_s *size)
|
||||
{
|
||||
FAR struct nxgl_rect_s bounds;
|
||||
|
||||
(void)nxtk_toolbarbounds(hfwnd, &bounds);
|
||||
size->w = bounds.pt2.x - bounds.pt1.x + 1;
|
||||
size->h = bounds.pt2.y - bounds.pt1.y + 1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -186,6 +204,9 @@ static int nxtool_bitmap(FAR struct nxterm_state_s *priv,
|
||||
|
||||
NXTERM nxtool_register(NXTKWINDOW hfwnd, FAR struct nxterm_window_s *wndo, int minor)
|
||||
{
|
||||
return nxterm_register((NXTERM)hfwnd, wndo, &g_nxtoolops, minor);
|
||||
FAR struct nxgl_size_s tbsize;
|
||||
|
||||
nxterm_toolbar_size(hfwnd, &tbsize);
|
||||
return nxterm_register((NXTERM)hfwnd, wndo, &tbsize, &g_nxtoolops, minor);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user