Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25008932rwd; Sun, 2 Jul 2023 08:36:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlGAQX0U0FYnIKmyhjDJOaw7ODxmNPgkDFy/FKS5pvgDpdXW8bQsnfxoCOm1GfKVTaqGEsV/ X-Received: by 2002:a05:6a20:7f9d:b0:12e:7bd4:78f5 with SMTP id d29-20020a056a207f9d00b0012e7bd478f5mr1543769pzj.50.1688312210002; Sun, 02 Jul 2023 08:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688312209; cv=none; d=google.com; s=arc-20160816; b=iONOEp3ArCRDjP7M4agMPZqxvrB8JRjDFo4rVTikyiSQ0XPwgMkgXQRTegsb2Rd6i6 hZvf4NmOBmAwI7zA1pNM82WXX1PVaA8HNSHqLSwUYCh56WqAQ+9gAIzfZ0fryJL8kJpp +bRNc8BOq7BdjpsUoisgQHqu4hbMyPXeKnBtgIdvymJaTYueEMyXu8M5tIi9RwHxiljc hJpAPz7SoK2rau4a66dwjVSqmANZdhlLXxmwqUxty1RyhD4GqC3aykQRge/9XCFegeVz GoAm94RYD3Kw5XgI+/M7B4jj17J+AGsqF8PP869wDgkVYBB0mu3vLGc4MqQRFefeC1bu X8LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=BKRcVjhv9qOuqFU5huXi5cspgHb6yZVSr+TK7u2sjxk=; fh=cFxMzn3iIeK1Me+fNTdMQg/oqntDXBXaHIGc5R5lw/Q=; b=kzUSrgV8D+IRZ5ur6dCtqhSQr4sUR2zRbsE8ahUbE+mgkE+oqkeaZ2o+xXfrmnWL1I cCDp5r1qD1CM1Jtrl5wxGlTDVzcF0GrpCJNv9yYQ9ncE317oRTa1YSXxu4RHvTKAnfW9 ++wMBFsV5h8kvhg/kAb/nJY3qEDlXuiT8zQrP6m9h4LbkKGA0kzG3yebX+DIDvEcqDnx YbtFLuykzjCH6M4cdCd3NCh74Gc9qbcro7pxnMhIFYGjF13b2G7MpJ/41w7SvcW9ms5a Zbaz4fJ9bndjogyWBrK0oh+p8lGHekryHLrZ1g9wJYg1bQJopW+uQoUoRGlE99kQaZvk X6Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="k/E3kpP3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020aa7848e000000b0066e96a581c8si14733865pfn.261.2023.07.02.08.36.33; Sun, 02 Jul 2023 08:36:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="k/E3kpP3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbjGBPJp (ORCPT + 99 others); Sun, 2 Jul 2023 11:09:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbjGBPJo (ORCPT ); Sun, 2 Jul 2023 11:09:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B01C3E67; Sun, 2 Jul 2023 08:09:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1D66A60C23; Sun, 2 Jul 2023 15:09:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D361C433C8; Sun, 2 Jul 2023 15:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688310582; bh=qYxj8FKfyA8BqS7gNXhxOkvG6rseYZjPp8at5kUg6i8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=k/E3kpP3brDnwOLzcQB/glehVf910J9kZBduzkziouCApRzWe8sIVg9Jzr2Pn9o6v 5DIHykwGgSgW3odLVCt0CBx1W7GecvRkzpHFEHGHIjuWVfOFVpyBcUFFT11w/hp//J zN5p3dgGPW/Joq2VI9/wpvEaD9NEGYKLXBPrOl3O1XmTHNwCfphubQzYFy+qn8wSYV Jm0M8KgOBLM4XnHjwIgvJW2jCtlxhPYmLIy+TIjfdcCTejkgmHPLoSpjF1U2o5TZME CRdXv7SHclHEiuG7Zjs4oZH0g2OaSO7eSagu0D1aRSnw+xucXGnehisxHx4GbSgq6f nzg7O7cGyZ3fg== Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-558a79941c6so2188969eaf.3; Sun, 02 Jul 2023 08:09:42 -0700 (PDT) X-Gm-Message-State: AC+VfDz3NSpfcKy20qGsRQEMm+maK4QZCpzx2hy3fjBmOvZSDkdZlBgu 7QmoFfH/Lm49ipHbDNgXQK262n6aPAeJ2Q8vxeU= X-Received: by 2002:a4a:3307:0:b0:565:afcf:fd9c with SMTP id q7-20020a4a3307000000b00565afcffd9cmr5842787ooq.3.1688310581745; Sun, 02 Jul 2023 08:09:41 -0700 (PDT) MIME-Version: 1.0 References: <20230629160351.2996541-1-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Mon, 3 Jul 2023 00:09:05 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] kconfig: menuconfig: simplify global jump key assignment To: Jesse T Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 1, 2023 at 12:58=E2=80=AFPM Jesse T w= rote: > > On Thu, Jun 29, 2023 at 12:03=E2=80=AFPM Masahiro Yamada wrote: > > > > Commit 95ac9b3b585d ("menuconfig: Assign jump keys per-page instead > > of globally") injects a lot of hacks to the bottom of the textbox > > infrastructure. > > > > I reverted many of them without changing the behavior. (almost) > > Now, the key markers are inserted when constructing the search result > > instead of updating the text buffer on-the-fly. > > > > The buffer passed to the textbox got back to a constant string. > > The ugly casts from (const char *) to (char *) went away. > > > > A disadvantage is that the same key numbers might be diplayed multiple > > times in the dialog if you use a huge window (but I believe it is > > unlikely to happen). > > > > Signed-off-by: Masahiro Yamada > > --- > > > > scripts/kconfig/lkc.h | 1 + > > scripts/kconfig/lxdialog/dialog.h | 10 ++-- > > scripts/kconfig/lxdialog/textbox.c | 68 +++++++++-------------- > > scripts/kconfig/mconf.c | 86 +++++++++++++++++------------- > > scripts/kconfig/menu.c | 22 ++++++-- > > 5 files changed, 97 insertions(+), 90 deletions(-) > > > > diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h > > index e7118d62a45f..d5c27180ce91 100644 > > --- a/scripts/kconfig/lkc.h > > +++ b/scripts/kconfig/lkc.h > > @@ -101,6 +101,7 @@ const char *menu_get_prompt(struct menu *menu); > > struct menu *menu_get_parent_menu(struct menu *menu); > > bool menu_has_help(struct menu *menu); > > const char *menu_get_help(struct menu *menu); > > +int get_jump_key(void); > > struct gstr get_relations_str(struct symbol **sym_arr, struct list_hea= d *head); > > void menu_get_ext_help(struct menu *menu, struct gstr *help); > > > > diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdial= og/dialog.h > > index 347daf25fdc8..cd1b59c24b21 100644 > > --- a/scripts/kconfig/lxdialog/dialog.h > > +++ b/scripts/kconfig/lxdialog/dialog.h > > @@ -196,13 +196,9 @@ int first_alpha(const char *string, const char *ex= empt); > > int dialog_yesno(const char *title, const char *prompt, int height, in= t width); > > int dialog_msgbox(const char *title, const char *prompt, int height, > > int width, int pause); > > - > > - > > -typedef void (*update_text_fn)(char *buf, size_t start, size_t end, vo= id > > - *_data); > > -int dialog_textbox(const char *title, char *tbuf, int initial_height, > > - int initial_width, int *keys, int *_vscroll, int *_h= scroll, > > - update_text_fn update_text, void *data); > > +int dialog_textbox(const char *title, const char *tbuf, int initial_he= ight, > > + int initial_width, int *_vscroll, int *_hscroll, > > + int (*extra_key_cb)(int, int, int, void *), void *da= ta); > > int dialog_menu(const char *title, const char *prompt, > > const void *selected, int *s_scroll); > > int dialog_checklist(const char *title, const char *prompt, int height= , > > diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdia= log/textbox.c > > index bc4d4fb1dc75..e6cd7bb83746 100644 > > --- a/scripts/kconfig/lxdialog/textbox.c > > +++ b/scripts/kconfig/lxdialog/textbox.c > > @@ -10,8 +10,8 @@ > > > > static int hscroll; > > static int begin_reached, end_reached, page_length; > > -static char *buf; > > -static char *page; > > +static const char *buf, *page; > > +static int start, end; > > > > /* > > * Go back 'n' lines in text. Called by dialog_textbox(). > > @@ -98,21 +98,10 @@ static void print_line(WINDOW *win, int row, int wi= dth) > > /* > > * Print a new page of text. > > */ > > -static void print_page(WINDOW *win, int height, int width, update_text= _fn > > - update_text, void *data) > > +static void print_page(WINDOW *win, int height, int width) > > { > > int i, passed_end =3D 0; > > > > - if (update_text) { > > - char *end; > > - > > - for (i =3D 0; i < height; i++) > > - get_line(); > > - end =3D page; > > - back_lines(height); > > - update_text(buf, page - buf, end - buf, data); > > - } > > - > > page_length =3D 0; > > for (i =3D 0; i < height; i++) { > > print_line(win, i, width); > > @@ -142,24 +131,26 @@ static void print_position(WINDOW *win) > > * refresh window content > > */ > > static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, in= t boxw, > > - int cur_y, int cur_x, update_text_fn updat= e_text, > > - void *data) > > + int cur_y, int cur_x) > > The change for refresh_text_box is very large. > Is there an easy way to split the change of `refresh_text_box` and > everything else > while still maintaining bisectability? I do not think the change is large or complicated. It just stopped passing down 'update_text' and 'data'. The same pattern. The point is this is revert of 95ac9b3b585d The revert should not be split. > > @@ -351,11 +333,9 @@ int dialog_textbox(const char *title, char *tbuf, = int initial_height, > > on_key_resize(); > > goto do_resize; > > default: > > - for (i =3D 0; keys[i]; i++) { > > - if (key =3D=3D keys[i]) { > > - done =3D true; > > - break; > > - } > > + if (extra_key_cb(key, start, end, data)) { > > `extra_key_cb` is null when not used, on the help page this will segfault= . Thanks. I will fix it. > > diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c > > index b90fff833588..5578b8bc8a23 100644 > > --- a/scripts/kconfig/menu.c > > +++ b/scripts/kconfig/menu.c > > @@ -701,6 +701,11 @@ static void get_dep_str(struct gstr *r, struct exp= r *expr, const char *prefix) > > } > > } > > > > +int __attribute__((weak)) get_jump_key(void) > > This seems like a non-optimal solution, otherwise fine. Do you have a better idea? --=20 Best Regards Masahiro Yamada