From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79302C4332F for ; Tue, 27 Dec 2022 14:55:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C9EC852F0; Tue, 27 Dec 2022 15:55:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eI6Ys/a1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 24310852F8; Tue, 27 Dec 2022 15:55:53 +0100 (CET) Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C18DB852A2 for ; Tue, 27 Dec 2022 15:55:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x535.google.com with SMTP id z11so3425077ede.1 for ; Tue, 27 Dec 2022 06:55:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=x/7d+DDXcZ4/rw3iIV7yozJQPXbibG9wfbUEumYRdnY=; b=eI6Ys/a1IVO9Er08H4mjJ/Qn/3rP1MYXJ5UoHlSkj0ffEOSS7SXZIYccdEsAoekmQE /Gs4cXsNgkdFECyu8+7TALDsYdu8q1ig+Pl6dGIYgJ9syn1VstV9MXA5gaM2lco8rpNB /XcHsF1dP7wtaWNd1qZfBvXpl1MLHSCJDHk20UH55MX42KPRFCK6tradD36EEFYhYnzq EGFqY41XvBk6g3vRreXVxlfj0EJk/PaUPVAFtLTqKACUMWC/c4eIvbqw4NdA5DPLM1A6 w7nnqkwhNpdTLGIFWsD/yKHFh6Ofz2+x9PydynLDtiFizKS0hDpLf7vRkIX5HUgKSSr5 r2Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=x/7d+DDXcZ4/rw3iIV7yozJQPXbibG9wfbUEumYRdnY=; b=iA21QKe68BNMOEH3J97H3Kx4K7M3DiJjnawK0gaUQffps2ERjhsgmvc980RyKoXOC4 TIfzboOOq9o7+h4vTsxPT9vekA/ijt7f5EejAP3jzW36c2vzmk7fOczIMd1IYG1XyEsQ m2jijnK4RiYaQS8Sa9UFIQ6LZJhrAEUej7z1jIAQeEmWewFVJ2JsYtH0zp13goy6XTXE HULdb2OhZTFehzFmjSI+fW1dT9rCHBmCGk8irQw3/oUjq+aUCO18oMUukSmg5k6FJF1r KBeFkFfUfIR5+65NYSK2uvwrpVjYE+Y+AvKjgfnhfdUfkhGtMXmltcM52lkN5zkxGZvN N0Zw== X-Gm-Message-State: AFqh2krKeJmxZ769kzx+l7wwTjJ2/UHE/oB63nPoZFoA4gNkPmWBe7W2 6v/lHj9PCh0fH0zZGomsH+jbHg== X-Google-Smtp-Source: AMrXdXuZTXsN6NpqedPzuANN+wR2VBkWe6w9KAdP9+kGo2yOwJ3cVChseACMWvHcmROeFOHYihhTBQ== X-Received: by 2002:a05:6402:1458:b0:47d:a733:c051 with SMTP id d24-20020a056402145800b0047da733c051mr19683343edx.15.1672152950384; Tue, 27 Dec 2022 06:55:50 -0800 (PST) Received: from hera (ppp079167090036.access.hol.gr. [79.167.90.36]) by smtp.gmail.com with ESMTPSA id v18-20020a170906293200b007adf2e4c6f7sm6161380ejd.195.2022.12.27.06.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 06:55:49 -0800 (PST) Date: Tue, 27 Dec 2022 16:55:47 +0200 From: Ilias Apalodimas To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: Re: [PATCH v2 3/3] eficonfig: add vertical scroll support Message-ID: References: <20221223225745.16985-1-masahisa.kojima@linaro.org> <20221223225745.16985-4-masahisa.kojima@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221223225745.16985-4-masahisa.kojima@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This looks correct to me. Heinrich can you check if that solves your scrolling issues? On Sat, Dec 24, 2022 at 07:57:44AM +0900, Masahisa Kojima wrote: > The current eficonfig menu does not support vertical scroll, > so it can not display the menu entries greater than > the console row size. > > This commit add the vertial scroll support. > The console size is retrieved by > SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode() service, then > calculates the row size for menu entry by subtracting > menu header and description row size from the console row size. > "start" and "end" are added in the efimenu structure. > "start" keeps the menu entry index at the top, "end" keeps > the bottom menu entry index. item_data_print() menu function > only draws the menu entry between "start" and "end". > > Signed-off-by: Masahisa Kojima > --- > No update since v1 > > cmd/eficonfig.c | 79 ++++++++++++++++++++++++++++++++++++-------- > include/efi_config.h | 4 +++ > include/efi_loader.h | 1 + > 3 files changed, 70 insertions(+), 14 deletions(-) > > diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c > index 13929cb003..e289d95589 100644 > --- a/cmd/eficonfig.c > +++ b/cmd/eficonfig.c > @@ -29,8 +29,13 @@ static const char *eficonfig_change_boot_order_desc = > " Press SPACE to activate or deactivate the entry\n" > " Select [Save] to complete, ESC/CTRL+C to quit"; > > +static struct efi_simple_text_output_protocol *cout; > +static int avail_row; > + > #define EFICONFIG_DESCRIPTION_MAX 32 > #define EFICONFIG_OPTIONAL_DATA_MAX 64 > +#define EFICONFIG_MENU_HEADER_ROW_NUM 3 > +#define EFICONFIG_MENU_DESC_ROW_NUM 5 > > /** > * struct eficonfig_filepath_info - structure to be used to store file path > @@ -156,18 +161,16 @@ void eficonfig_print_entry(void *data) > struct eficonfig_entry *entry = data; > int reverse = (entry->efi_menu->active == entry->num); > > - /* TODO: support scroll or page for many entries */ > + if (entry->efi_menu->start > entry->num || entry->efi_menu->end < entry->num) > + return; > > - /* > - * Move cursor to line where the entry will be drawn (entry->num) > - * First 3 lines(menu header) + 1 empty line > - */ > - printf(ANSI_CURSOR_POSITION, entry->num + 4, 7); > + printf(ANSI_CURSOR_POSITION, (entry->num - entry->efi_menu->start) + > + EFICONFIG_MENU_HEADER_ROW_NUM + 1, 7); > > if (reverse) > puts(ANSI_COLOR_REVERSE); > > - printf("%s", entry->title); > + printf(ANSI_CLEAR_LINE "%s", entry->title); > > if (reverse) > puts(ANSI_COLOR_RESET); > @@ -190,8 +193,8 @@ void eficonfig_display_statusline(struct menu *m) > ANSI_CURSOR_POSITION ANSI_CLEAR_LINE ANSI_CURSOR_POSITION > "%s" > ANSI_CLEAR_LINE_TO_END, > - 1, 1, entry->efi_menu->menu_header, entry->efi_menu->count + 5, 1, > - entry->efi_menu->count + 6, 1, entry->efi_menu->menu_desc); > + 1, 1, entry->efi_menu->menu_header, avail_row + 4, 1, > + avail_row + 5, 1, entry->efi_menu->menu_desc); > } > > /** > @@ -213,13 +216,23 @@ char *eficonfig_choice_entry(void *data) > > switch (key) { > case KEY_UP: > - if (efi_menu->active > 0) > + if (efi_menu->active > 0) { > --efi_menu->active; > + if (efi_menu->start > efi_menu->active) { > + efi_menu->start--; > + efi_menu->end--; > + } > + } > /* no menu key selected, regenerate menu */ > return NULL; > case KEY_DOWN: > - if (efi_menu->active < efi_menu->count - 1) > + if (efi_menu->active < efi_menu->count - 1) { > ++efi_menu->active; > + if (efi_menu->end < efi_menu->active) { > + efi_menu->start++; > + efi_menu->end++; > + } > + } > /* no menu key selected, regenerate menu */ > return NULL; > case KEY_SELECT: > @@ -399,6 +412,8 @@ efi_status_t eficonfig_process_common(struct efimenu *efi_menu, > > efi_menu->delay = -1; > efi_menu->active = 0; > + efi_menu->start = 0; > + efi_menu->end = avail_row - 1; > > if (menu_header) { > efi_menu->menu_header = strdup(menu_header); > @@ -1865,7 +1880,11 @@ static void eficonfig_print_change_boot_order_entry(void *data) > struct eficonfig_entry *entry = data; > int reverse = (entry->efi_menu->active == entry->num); > > - printf(ANSI_CURSOR_POSITION, entry->num + 4, 7); > + if (entry->efi_menu->start > entry->num || entry->efi_menu->end < entry->num) > + return; > + > + printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, > + (entry->num - entry->efi_menu->start) + EFICONFIG_MENU_HEADER_ROW_NUM + 1, 7); > > if (reverse) > puts(ANSI_COLOR_REVERSE); > @@ -1916,8 +1935,13 @@ char *eficonfig_choice_change_boot_order(void *data) > } > fallthrough; > case KEY_UP: > - if (efi_menu->active > 0) > + if (efi_menu->active > 0) { > --efi_menu->active; > + if (efi_menu->start > efi_menu->active) { > + efi_menu->start--; > + efi_menu->end--; > + } > + } > return NULL; > case KEY_MINUS: > if (efi_menu->active < efi_menu->count - 3) { > @@ -1933,11 +1957,20 @@ char *eficonfig_choice_change_boot_order(void *data) > list_add(&entry->list, &tmp->list); > > ++efi_menu->active; > + if (efi_menu->end < efi_menu->active) { > + efi_menu->start++; > + efi_menu->end++; > + } > } > return NULL; > case KEY_DOWN: > - if (efi_menu->active < efi_menu->count - 1) > + if (efi_menu->active < efi_menu->count - 1) { > ++efi_menu->active; > + if (efi_menu->end < efi_menu->active) { > + efi_menu->start++; > + efi_menu->end++; > + } > + } > return NULL; > case KEY_SELECT: > /* "Save" */ > @@ -2585,6 +2618,7 @@ static efi_status_t eficonfig_init(void) > efi_status_t ret = EFI_SUCCESS; > static bool init; > struct efi_handler *handler; > + unsigned long columns, rows; > > if (!init) { > ret = efi_search_protocol(efi_root, &efi_guid_text_input_protocol, &handler); > @@ -2595,6 +2629,23 @@ static efi_status_t eficonfig_init(void) > EFI_OPEN_PROTOCOL_GET_PROTOCOL); > if (ret != EFI_SUCCESS) > return ret; > + ret = efi_search_protocol(efi_root, &efi_guid_text_output_protocol, &handler); > + if (ret != EFI_SUCCESS) > + return ret; > + > + ret = efi_protocol_open(handler, (void **)&cout, efi_root, NULL, > + EFI_OPEN_PROTOCOL_GET_PROTOCOL); Shouldn't we be closing the protocol if eficonfig terminates? > + if (ret != EFI_SUCCESS) > + return ret; > + > + cout->query_mode(cout, cout->mode->mode, &columns, &rows); [...] Regards /Ilias