@@ -1670,11 +1670,10 @@ static int scene_obj_open(struct scene *scn, struct scene_obj *obj)
case SCENEOBJT_MENU:
case SCENEOBJT_TEXT:
case SCENEOBJT_BOX:
- case SCENEOBJT_TEXTEDIT:
break;
case SCENEOBJT_TEXTLINE:
- ret = scene_textline_open(scn,
- (struct scene_obj_textline *)obj);
+ case SCENEOBJT_TEXTEDIT:
+ ret = scene_txtin_open(scn, obj, scene_obj_txtin(obj));
if (ret)
return log_msg_ret("op", ret);
break;
@@ -569,15 +569,17 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj,
int scene_obj_calc_bbox(struct scene_obj *obj, struct vidconsole_bbox *bbox);
/**
- * scene_textline_open() - Open a textline object
+ * scene_txtin_open() - Open a text-input object
*
* Set up the text editor ready for use
*
- * @scn: Scene containing the textline
- * @tline: textline object
+ * @scn: Scene containing the object
+ * @obj: Object to open
+ * @tin: Text-input info
* Return: 0 if OK, -ve on error
*/
-int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline);
+int scene_txtin_open(struct scene *scn, struct scene_obj *obj,
+ struct scene_txtin *tin);
/**
* scene_textline_close() - Close a textline object
@@ -152,48 +152,3 @@ bool scene_textline_within(const struct scene *scn,
return scene_within(scn, tline->tin.edit_id, x, y);
}
-/**
- * scene_textline_putch() - Output a character to the vidconsole
- *
- * This is used as the putch callback for CLI line editing, so that characters
- * are sent to the correct vidconsole.
- *
- * @cls: CLI line state
- * @ch: Character to output
- */
-static void scene_textline_putch(struct cli_line_state *cls, int ch)
-{
- struct scene *scn = container_of(cls, struct scene, cls);
-
- vidconsole_put_char(scn->expo->cons, ch);
-}
-
-int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline)
-{
- struct udevice *cons = scn->expo->cons;
- struct scene_obj_txt *txt;
- int ret;
-
- /* Copy the text into the scene buffer in case the edit is cancelled */
- memcpy(abuf_data(&scn->buf), abuf_data(&tline->tin.buf),
- abuf_size(&scn->buf));
-
- /* get the position of the editable */
- txt = scene_obj_find(scn, tline->tin.edit_id, SCENEOBJT_NONE);
- if (!txt)
- return log_msg_ret("cur", -ENOENT);
-
- vidconsole_set_cursor_pos(cons, txt->obj.bbox.x0, txt->obj.bbox.y0);
- vidconsole_entry_start(cons);
- cli_cread_init(&scn->cls, abuf_data(&tline->tin.buf), tline->tin.line_chars);
- scn->cls.insert = true;
- scn->cls.putch = scene_textline_putch;
- ret = vidconsole_entry_save(cons, &scn->entry_save);
- if (ret)
- return log_msg_ret("sav", ret);
-
- /* make sure the cursor is visible */
- vidconsole_readline_start(true);
-
- return 0;
-}
@@ -10,8 +10,10 @@
#include <expo.h>
#include <log.h>
+#include <menu.h>
#include <video_console.h>
#include <linux/errno.h>
+#include <linux/string.h>
#include "scene_internal.h"
int scene_txtin_init(struct scene_txtin *tin, uint size, uint line_chars)
@@ -86,6 +88,53 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj,
return 0;
}
+/**
+ * scene_txtin_putch() - Output a character to the vidconsole
+ *
+ * This is used as the putch callback for CLI line editing, so that characters
+ * are sent to the correct vidconsole.
+ *
+ * @cls: CLI line state
+ * @ch: Character to output
+ */
+static void scene_txtin_putch(struct cli_line_state *cls, int ch)
+{
+ struct scene *scn = container_of(cls, struct scene, cls);
+
+ vidconsole_put_char(scn->expo->cons, ch);
+}
+
+int scene_txtin_open(struct scene *scn, struct scene_obj *obj,
+ struct scene_txtin *tin)
+{
+ struct udevice *cons = scn->expo->cons;
+ struct scene_obj_txt *txt;
+ int ret;
+
+ /* Copy the text into the scene buffer in case the edit is cancelled */
+ memcpy(abuf_data(&scn->buf), abuf_data(&tin->buf),
+ abuf_size(&scn->buf));
+
+ /* get the position of the editable */
+ txt = scene_obj_find(scn, tin->edit_id, SCENEOBJT_NONE);
+ if (!txt)
+ return log_msg_ret("cur", -ENOENT);
+
+ vidconsole_set_cursor_pos(cons, txt->obj.bbox.x0, txt->obj.bbox.y0);
+ vidconsole_entry_start(cons);
+ cli_cread_init(&scn->cls, abuf_data(&tin->buf), tin->line_chars);
+ scn->cls.insert = true;
+ scn->cls.putch = scene_txtin_putch;
+ ret = vidconsole_entry_save(cons, &scn->entry_save);
+ if (ret)
+ return log_msg_ret("sav", ret);
+
+ /* make sure the cursor is visible */
+ vidconsole_readline_start(true);
+
+ return 0;
+}
+
void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin,
struct vidconsole_bbox *bbox,
struct vidconsole_bbox *edit_bbox)