1
0
Fork 0

video: Provide a signal when a new console line is started

When we start a new line (due to the user pressing return), signal this to
the driver so that it can flush its buffer of character positions.

Signed-off-by: Simon Glass <sjg@chromium.org>
utp
Simon Glass 2016-01-14 18:10:40 -07:00 committed by Anatolij Gustschin
parent c5b77d01d1
commit 58c733a70f
2 changed files with 28 additions and 0 deletions

View File

@ -47,6 +47,15 @@ int vidconsole_set_row(struct udevice *dev, uint row, int clr)
return ops->set_row(dev, row, clr); return ops->set_row(dev, row, clr);
} }
static int vidconsole_entry_start(struct udevice *dev)
{
struct vidconsole_ops *ops = vidconsole_get_ops(dev);
if (!ops->entry_start)
return -ENOSYS;
return ops->entry_start(dev);
}
/* Move backwards one space */ /* Move backwards one space */
static void vidconsole_back(struct udevice *dev) static void vidconsole_back(struct udevice *dev)
{ {
@ -82,6 +91,8 @@ static void vidconsole_newline(struct udevice *dev)
vid_priv->colour_bg); vid_priv->colour_bg);
priv->ycur -= rows * priv->y_charsize; priv->ycur -= rows * priv->y_charsize;
} }
priv->last_ch = 0;
video_sync(dev->parent); video_sync(dev->parent);
} }
@ -99,6 +110,7 @@ int vidconsole_put_char(struct udevice *dev, char ch)
break; break;
case '\n': case '\n':
vidconsole_newline(dev); vidconsole_newline(dev);
vidconsole_entry_start(dev);
break; break;
case '\t': /* Tab (8 chars alignment) */ case '\t': /* Tab (8 chars alignment) */
priv->xcur_frac = ((priv->xcur_frac / priv->tab_width_frac) priv->xcur_frac = ((priv->xcur_frac / priv->tab_width_frac)
@ -109,6 +121,7 @@ int vidconsole_put_char(struct udevice *dev, char ch)
break; break;
case '\b': case '\b':
vidconsole_back(dev); vidconsole_back(dev);
priv->last_ch = 0;
break; break;
default: default:
/* /*
@ -125,6 +138,7 @@ int vidconsole_put_char(struct udevice *dev, char ch)
if (ret < 0) if (ret < 0)
return ret; return ret;
priv->xcur_frac += ret; priv->xcur_frac += ret;
priv->last_ch = ch;
if (priv->xcur_frac >= priv->xsize_frac) if (priv->xcur_frac >= priv->xsize_frac)
vidconsole_newline(dev); vidconsole_newline(dev);
break; break;

View File

@ -28,6 +28,7 @@
* @tab_width_frac: Tab width in fractional units * @tab_width_frac: Tab width in fractional units
* @xsize_frac: Width of the display in fractional units * @xsize_frac: Width of the display in fractional units
* @xstart_frac: Left margin for the text console in fractional units * @xstart_frac: Left margin for the text console in fractional units
* @last_ch: Last character written to the text console on this line
*/ */
struct vidconsole_priv { struct vidconsole_priv {
struct stdio_dev sdev; struct stdio_dev sdev;
@ -40,6 +41,7 @@ struct vidconsole_priv {
int tab_width_frac; int tab_width_frac;
int xsize_frac; int xsize_frac;
int xstart_frac; int xstart_frac;
int last_ch;
}; };
/** /**
@ -87,6 +89,18 @@ struct vidconsole_ops {
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
int (*set_row)(struct udevice *dev, uint row, int clr); int (*set_row)(struct udevice *dev, uint row, int clr);
/**
* entry_start() - Indicate that text entry is starting afresh
*
* Consoles which use proportional fonts need to track the position of
* each character output so that backspace will return to the correct
* place. This method signals to the console driver that a new entry
* line is being start (e.g. the user pressed return to start a new
* command). The driver can use this signal to empty its list of
* positions.
*/
int (*entry_start)(struct udevice *dev);
}; };
/* Get a pointer to the driver operations for a video console device */ /* Get a pointer to the driver operations for a video console device */