Add a few tests of cursor operation.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-to: concept
Series-cc: heinrich
Cover-letter:
video: Support a cursor more generally
At present U-Boot does not support displaying a cursor on the console,
except with expo.
It is quite useful to have a cursor, particularly when using the
command-line editor.
This series adds tracking of the cursor position for both truetype and
normal consoles. The cursor is shown when U-Boot is idle and is removed
before writing characters to the display. A save-buffer ensures that the
old display contents are provided.
Some related improvements in this series include:
- expo lineedit support with normal console
- arrow keys now render correctly when editing commands with truetype
- truetype console now also supports bitmap fonts
The cursor is not currently supported for rotated consoles.
A README for claude is provided, although so far I have not had too much
success with it.
A fix for an intermittent build is added as well, along with silencing
some build messages noticed from Rust ulib.
END
Now that the truetype console properly handles clearing text from the
display during editing, we don't need to clear the character when
processing a backspace.
This allows arrow keys to work as expected on the truetype console.
Signed-off-by: Simon Glass <sjg@chromium.org>
Within the CLI, inserting a character works by writing out the new char
and then all the ones after it.
With the truetype console this results in gibberish since the new
chars are written on top of the old. To resolve this, clear the rest of
the input when a character is inserted. Consider that the end of the
input, at least until furture characters are written.
As an optimisation, don't clear if the new character is the same as the
old.
This cleans up a dot above the 'g' of greatness which should not be
there, so update the dm_test_video_truetype() test.
It also clean up the part of the 't' of 'not be' which should not be
there, so update dm_test_video_truetype_bs() too.
Signed-off-by: Simon Glass <sjg@chromium.org>
Create a variant of fill_pixel_and_goto_next() function which returns
the old pixel value. This will make it easy to save the framebuffer
pixels as they are overwritten by drawing the cursor.
Leave the current function alone, since it increases code size about
16 bytes and may slow down blitting.
Signed-off-by: Simon Glass <sjg@chromium.org>
Drawing the cursor is a destructive operation, so we must save the
previous contents of the affected part of the framebuffer, so it can be
restored afterwards.
Add this to the cursor info and set it up when probing the console
device.
Signed-off-by: Simon Glass <sjg@chromium.org>
For expo, lineedit only supports a single line.
For the CLI, the text can extend across multiple lines. Add support for
this in the normal console, calculating the x and y offset of the cursor
position based on the display width and font size.
The truetype console already works, since it has had this tracking for a
while.
Signed-off-by: Simon Glass <sjg@chromium.org>
Now that the console tracks the CLI index, remove the unnecessary
parameters. Both the normal and truetype consoles use the information
provided by the console.
Signed-off-by: Simon Glass <sjg@chromium.org>
Provide these two methods so that we can use expo lineedits with the
normal console (i.e. no truetype). This allows the cursor to be
positioned correctly when editing the lineedit and rendering the expo.
Signed-off-by: Simon Glass <sjg@chromium.org>
The console supports keeping track of the index and the start position
of the CLI entry. Use this instead of the passed-in values.
Signed-off-by: Simon Glass <sjg@chromium.org>
There is only one user of this function. Update it to use the new
vidconsole_show_cursor() instead.
Remove the now-unused vidconsole_set_cursor_visible()
Signed-off-by: Simon Glass <sjg@chromium.org>
The cursor should only be enabled if the user is entering something.
This can be at the CLI or in an expo. Provide a flag to track it, which
we can (later) use to determine whether or not to draw the cursor.
Signed-off-by: Simon Glass <sjg@chromium.org>
Call the appropriate vidconsole functions to ensure that the cursor
will be enabled while a textline is open.
Signed-off-by: Simon Glass <sjg@chromium.org>
The Truetype driver maintains a list of x and y positions for every
character in the line being entered by the user. This allows it to
backspace reliably without having to re-measure lots of text.
For kerning, the video console maintains a last_ch variable which holds
the last character written to the console. This allows accurate kerning
between one character and the next. At present lash_ch is cleared on
backspace, since we cannot know what the character before last_ch is.
The slightly strange part is that the truetype console currently has no
knowledge about what the characters were, only their x and y positions,
with the x position being fractional. It also has no idea of the width
of each character, since it doesn't need to: the CLI will always write
out a new character in order to move forward during command-editing,
since there is no actual concept of 'move the cursor to the right'.
Part of the reason this works is that truetype implements backspace by
actually clearing the character from the display. So if you type some
text and then press the left arrow, it looks like it is doing a
backspace. This has been a known limitation for some time.
The correct way to implement left-arrow is to leave the display alone,
only clearing it if characters are later added. This is necessary since
Truetype fonts are OR'd onto the screen, which is assumed to be
initially cleared to the background colour.
We cannot do this clearing without knowing the width of the characters
we need to clear, so add a 'width' to the struct pos_info for that.
For kerning we must know the previous character to kern against, but we
cannot yet make that change, since we don't want to kern against
characters that were there before an erase. So that will be dealt with
later, in 'Clear after the current char on insert'.
Signed-off-by: Simon Glass <sjg@chromium.org>
Implement the mark_start() method for the truetype console by recording
which pos[] record corresponds to this event. We can be sure that the
user will not be able to backspace past this point.
Signed-off-by: Simon Glass <sjg@chromium.org>
Add some debugging which can be used to manually check that truetype is
kerning against the expected character. This is tested by the
image-based tests but they are sometimes hard to debug.
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a new mark_start() method for the console, which indicates that the
CLI prompt has been written to the display and any following characters
will be user input.
There are two cases to consider, tracked by an indent flag in
struct vidconsole_cursor:
- normal CLI entry where new lines start at the left of the console
- expo entry where new lines start at the same position as the previous
line (indent=true)
Record this position in the uclass info, so it is available to console
drivers.
Signed-off-by: Simon Glass <sjg@chromium.org>
Keep track of the current character index in the current CLI entry. This
corresponds to the cursor position and is numbered from zero.
Signed-off-by: Simon Glass <sjg@chromium.org>
Rather than having the truetype driver draw the cursor, make it just
return the information needed to draw the cursor. This will make it
possible for the normal console to support a cursor too.
Add a check for the cursor being entirely within the framebuffer.
Signed-off-by: Simon Glass <sjg@chromium.org>
We don't need to pass a pointer to a pointer, so just pass a normal
pointer. This is simpler to understand.
Signed-off-by: Simon Glass <sjg@chromium.org>
For now the cursor is always vertical, so part of this name is
redundant. Rename it to cursor_show(), which is what it does. We will
eventually have a cursor_hide() to match it.
Signed-off-by: Simon Glass <sjg@chromium.org>
We need to keep track of various things with the cursor, so create a
separate struct within the console. Add some
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a way to tell the console that the machine is idle. This will be
used (later) to show the cursor.
Call the video console sync after that, so that any updates are shown.
Keep the video_sync_all() for the case where CONFIG_CURSOR is not
enabled, to reduce code size.
Signed-off-by: Simon Glass <sjg@chromium.org>
There is normally a prompt which prevents the cursor ever being on the
far left. However we should check for this to avoid a potential crash.
Add a check for x being at least 0 in console_set_cursor_visible()
Signed-off-by: Simon Glass <sjg@chromium.org>
Update truetype_set_cursor_visible() to use the existing shared
draw_cursor_vertically() function instead of duplicating cursor-drawing
itself.
This corrects a problem where met is accessed for fixed-width fonts, for
which it doesn't exist.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Complete the support for this feature by dealing with rendering, the
moving to a particular row/column and scrolling.
Provide a simple test to check that things look right.
Allow omitting the font name to request the default font.
Fix an errant tab nearby.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
It is sometimes useful to use a bitmap font for the console even when
truetype fonts are available. As a starting point, pull in the
font table and provide information about font sizes. Allow selection of
a bitmap font by name, as well as listing available bitmap fonts.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Most of this function deals with uclass data, so move it into the
uclass. This will allow truetype to use it too.
Signed-off-by: Simon Glass <sjg@chromium.org>
Rename this macro in preparation for allowing truetype to use bitmap
fonts. This avoids a conflict with FONT_ENTRY() in video_font.h
Signed-off-by: Simon Glass <sjg@chromium.org>
Move fixed-font, character-rendering from console_normal.c into a shared
function in console_core.c. This will allow truetype to use the fixed
fonts as well as its own.
Co-developed-by: Claude <noreply@anthropic.com>
The video cursor is always enabled at present, but it is only used for
expo. Put it behind an option, to reduce code size for platforms which
do use video but don't want a cursor.
Move the existing set_cursor_visible() method behind this option, for
the normal console. For the truetype console, the fonts and extra
rendering dwarf the code-size saving, so include the cursor there
always.
Once the cursor is enabled for the CLI, this will produce code-size
savings.
Signed-off-by: Simon Glass <sjg@chromium.org>
Some strings in this file are quite long and it is a pain to look at
them within an 80-column editor. Split them.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
The ifeq/else/endif conditional for capsule_esl_file generation was
incorrectly placed inside the recipe, causing malformed Makefile syntax
that prevented proper dependency resolution. This resulted in build
failures when CONFIG_EFI_CAPSULE_AUTHENTICATE was enabled because the
capsule_esl_file target could not be created from the certificate file.
Move the conditional to properly wrap the rule definitions, allowing
Make to correctly parse and execute the capsule ESL generation rules.
Signed-off-by: Simon Glass <sjg@chromium.org>
Co-developed-by: Claude <noreply@anthropic.com>
All of these helper functions check the wrong member. Fix them.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 9e55d09596 ("video: Allow obtaining the nominal size of a...")
Fixes: 9899eef2cb ("video: Allow saving and restoring text-entry...")
When using a debugger it is common to single step through functions. If
one of those functions happens to be called from a cyclic function, then
a warning messages is shown. When debugging the console itself, this can
mess up the session.
Add a Kconfig to control whether the message is shown. Disable it by
default if CONFIG_CC_OPTIMIZE_FOR_DEBUG is enabled.
Signed-off-by: Simon Glass <sjg@chromium.org>
Check the behaviour of non-popup menus with a mouse.
Series-to: concept
Series-cc: heinrich
Cover-letter:
expo: Support interactions with a mouse or touchpad
So far expo only supports user interaction with a keyboard. This is the
common case, but for PC devices it is typical to have a mouse or
touchpad available as well.
Particularly for the configuration editor, these devices are often more
convenient for selecting options than moving up and down with with the
keyboard.
This series adds mouse support to expo, providing a function to process
a click similar to processing of a keypress. The core of this is a new
expo_send_click() function. Within scenes, the logic to search for
objects by and x and y position is provided.
As with keypresses, expo provides clear separation between the
processing of a click (which may or may not produce an action) and the
handling of that action. This allows expo to be used within an existing
event loop.
Expo uses a mouse by default if available.
This series also includes a few other minor improvements, including some
code tidy-ups and support for filled boxes.
END
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:34
Add a test which checks the various expected features of a cedit when
used with a mouse. This includes clicking on menu items and textlines.
For now, textedit is not supported.
Signed-off-by: Simon Glass <sjg@chromium.org>
Provide a way to click on an object and check that the expected action
resulted. Put it in a common file so it can be used by cedit and expo
tests.
Tidy up the include-order in both cedit and expo.
Signed-off-by: Simon Glass <sjg@chromium.org>
When creating a new bootflow menu or cedit, enable the mouse, so the
user can interact with the expo more easily.
Signed-off-by: Simon Glass <sjg@chromium.org>