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 C6278C05027 for ; Mon, 23 Jan 2023 15:43:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1FBCA85763; Mon, 23 Jan 2023 16:42:18 +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="FG6NO2ix"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB1C98571C; Mon, 23 Jan 2023 16:07:17 +0100 (CET) Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (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 0ED628571F for ; Mon, 23 Jan 2023 16:07:05 +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-ej1-x629.google.com with SMTP id hw16so31207519ejc.10 for ; Mon, 23 Jan 2023 07:07:05 -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=rBJodTc5haZ1WBxqoIjCx/xenSlWkNkn3dRqZAu9CuQ=; b=FG6NO2ixnk3jTi3noT73fl2X9ezXtHkPy45IAvWohUz+fz+STlzDIk8kE6KPs/vRnW VJxwjOd+TnM8jhDcPIrlyXRWYV2xZC4aJASb8+S0Ae2JmRfe2Ge0VmE6IQ0NA950TIBP y57n3IvXUY1X9QtqIJiVFEEHFm2el5CfM7UAUwtciJN/L3v7pdaI7o+ev5XvlBK0MDik mRm9Gzr4QXCv0S+PZqzdTIu/NTrOJ+DRk+er68DBpL5i2KBKbihYjivJdbnBrQEhIdRK HlZY7kDeWXyngxojl/66U/P5d0kjo0BkTsAS92SOWrUPdlA3oyxRqU15vqwbYyZagtYo S0/Q== 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=rBJodTc5haZ1WBxqoIjCx/xenSlWkNkn3dRqZAu9CuQ=; b=KvnolDxs3xXrfomzs4kITzjsK+AYEfwZ+uQzLBuVp9Le8Z7hPc+DxzR1tY+OI2qlQ+ pa3Hv+EiRP61beHWV/IRvosPcBFQlckbILHnz1m277fAoAlTqIglzvMEPVhqAwICnUsa BEXBFyPsi8b5p/RMViZAH8BnreGwXHoXnhQ1WrPaxt+sM8B29l6fMbkKOoTYV8wZbJkX ii+QM+L4yVZYp8TqJ1BLJ2lrHYiRw4g257jJE9JBN8XfJRrGAv76RqK1dkUeksmW46NJ HHg83iScwPGU4xY7TRwBszD9khmDp/TCtXy2fLO6WD3Q1uqIwBEtQcTIHlhdXINboFcG /SOA== X-Gm-Message-State: AFqh2krGAKT7VuRrvz00FqmOOYpDDzhzLPiJDebajzFaWuyjpTLgwCfh A7Eo5wCPWUddlji+cH9NLno8tg== X-Google-Smtp-Source: AMrXdXvs5RzcLgYcSqDsLsFWv9/XngxcS7cpQjcjQkCpdFDAHS226I7lq1qfwlBsWPsGS7lPdxdodQ== X-Received: by 2002:a17:906:5e09:b0:7c1:727c:5f70 with SMTP id n9-20020a1709065e0900b007c1727c5f70mr25621688eju.46.1674486424628; Mon, 23 Jan 2023 07:07:04 -0800 (PST) Received: from hera (ppp079167090036.access.hol.gr. [79.167.90.36]) by smtp.gmail.com with ESMTPSA id la16-20020a170907781000b0084d494b24dcsm19427815ejc.161.2023.01.23.07.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 07:07:04 -0800 (PST) Date: Mon, 23 Jan 2023 17:07:02 +0200 From: Ilias Apalodimas To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: Re: [PATCH v4 3/4] eficonfig: add vertical scroll support Message-ID: References: <20230120084358.5919-1-masahisa.kojima@linaro.org> <20230120084358.5919-4-masahisa.kojima@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230120084358.5919-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 On Fri, Jan 20, 2023 at 05:43:57PM +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 v3 > > Changes in v3: > - modify "reverse" local variable type to bool > > Changes in v2: > - add comment when the user key press is not valid > - add const qualifier to eficonfig_change_boot_order_desc > > 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 01bd1b05bc..5692b332c7 100644 > --- a/cmd/eficonfig.c > +++ b/cmd/eficonfig.c > @@ -30,8 +30,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 > @@ -157,18 +162,16 @@ void eficonfig_print_entry(void *data) > struct eficonfig_entry *entry = data; > bool 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); > @@ -191,8 +194,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); > } > > /** > @@ -216,13 +219,23 @@ char *eficonfig_choice_entry(void *data) > > switch (key) { > case BKEY_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--; > + } For all the sequences of this do: void efi_menu_adjust(struct efimenu *menu, bool add) { if (add && efi_menu->end < efi_menu->active) { menu->start++; menu->end++; } else if (!add && efi_menu->start > efi_menu->active) menu->start--; menu->end--; } } #define efi_menu_up(_a) efi_menu_adjust(_a, true) #define efi_menu_down(_a) efi_menu_adjust(_a, false) I think this would look a bit more readable > + } > /* no menu key selected, regenerate menu */ > return NULL; > case BKEY_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++; [...] Regards /Ilias