With a growing amount of Kernel configuration, it's
getting ever more difficult to find anything on
menuconfig. Because of that, implement mergesort for
kconfig to make it a little easier for anybody
building kernels.
Signed-off-by: Felipe Balbi <[email protected]>
---
scripts/kconfig/lxdialog/menubox.c | 18 +++++----
scripts/kconfig/mconf.c | 83 +++++++++++++++++++++++++++++++++++---
2 files changed, 89 insertions(+), 12 deletions(-)
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index 11ae9ad7ac7b..d6cc04db6e60 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -162,6 +162,7 @@ static void print_buttons(WINDOW * win, int height, int width, int selected)
print_button(win, gettext(" Help "), y, x + 24, selected == 2);
print_button(win, gettext(" Save "), y, x + 36, selected == 3);
print_button(win, gettext(" Load "), y, x + 48, selected == 4);
+ print_button(win, gettext(" Sort "), y, x + 60, selected == 5);
wmove(win, y, x + 1 + 12 * selected);
wrefresh(win);
@@ -375,7 +376,7 @@ int dialog_menu(const char *title, const char *prompt,
case TAB:
case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0)
- ? 4 : (button > 4 ? 0 : button);
+ ? 5 : (button > 5 ? 0 : button);
print_buttons(dialog, height, width, button);
wrefresh(menu);
@@ -390,6 +391,7 @@ int dialog_menu(const char *title, const char *prompt,
case '?':
case 'z':
case '\n':
+ case '.':
/* save scroll info */
*s_scroll = scroll;
delwin(menu);
@@ -400,19 +402,21 @@ int dialog_menu(const char *title, const char *prompt,
case 'h':
case '?':
return 2;
+ case '.':
+ return 5;
case 's':
case 'y':
- return 5;
- case 'n':
return 6;
- case 'm':
+ case 'n':
return 7;
- case ' ':
+ case 'm':
return 8;
- case '/':
+ case ' ':
return 9;
- case 'z':
+ case '/':
return 10;
+ case 'z':
+ return 11;
case '\n':
return button;
}
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 315ce2c7cb9d..c4a2eb561be4 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -642,6 +642,75 @@ static void build_conf(struct menu *menu)
indent -= doint;
}
+static int less(struct menu *a, struct menu *b)
+{
+ const char *s1 = _(menu_get_prompt(a));
+ const char *s2 = _(menu_get_prompt(b));
+
+ if (!s1)
+ return 1;
+
+ if (!s2)
+ return 0;
+
+ return strcmp(s1, s2) < 0;
+}
+
+static struct menu *merge(struct menu *a, struct menu *b)
+{
+ struct menu head;
+ struct menu *c = &head;
+
+ while (a && b) {
+ if (less(a, b)) {
+ c->next = a;
+ c = a;
+ a = a->next;
+ } else {
+ c->next = b;
+ c = b;
+ b = b->next;
+ }
+ }
+
+ c->next = a ? a : b;
+
+ return head.next;
+}
+
+static struct menu *mergesort(struct menu *c)
+{
+ struct menu *a;
+ struct menu *b;
+
+ if (!c)
+ return c;
+
+ if (c->list)
+ c->list = mergesort(c->list);
+
+ if (!c->next)
+ return c;
+
+ a = c;
+ b = c->next;
+
+ while (b && b->next) {
+ c = c->next;
+ b = b->next->next;
+ }
+
+ b = c->next;
+ c->next = NULL;
+
+ return merge(mergesort(a), mergesort(b));
+}
+
+static struct menu *sort_conf(void)
+{
+ return mergesort(&rootmenu);
+}
+
static void conf(struct menu *menu, struct menu *active_menu)
{
struct menu *submenu;
@@ -668,6 +737,7 @@ static void conf(struct menu *menu, struct menu *active_menu)
res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
_(menu_instructions),
active_menu, &s_scroll);
+
if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
break;
if (item_count() != 0) {
@@ -720,6 +790,9 @@ static void conf(struct menu *menu, struct menu *active_menu)
conf_load();
break;
case 5:
+ sort_conf();
+ break;
+ case 6:
if (item_is_tag('t')) {
if (sym_set_tristate_value(sym, yes))
break;
@@ -727,24 +800,24 @@ static void conf(struct menu *menu, struct menu *active_menu)
show_textbox(NULL, setmod_text, 6, 74);
}
break;
- case 6:
+ case 7:
if (item_is_tag('t'))
sym_set_tristate_value(sym, no);
break;
- case 7:
+ case 8:
if (item_is_tag('t'))
sym_set_tristate_value(sym, mod);
break;
- case 8:
+ case 9:
if (item_is_tag('t'))
sym_toggle_tristate_value(sym);
else if (item_is_tag('m'))
conf(submenu, NULL);
break;
- case 9:
+ case 10:
search_conf();
break;
- case 10:
+ case 11:
show_all_options = !show_all_options;
break;
}
--
2.11.0.295.gd7dffce1ce
On 04/11/17 04:12, Felipe Balbi wrote:
> With a growing amount of Kernel configuration, it's
> getting ever more difficult to find anything on
> menuconfig. Because of that, implement mergesort for
> kconfig to make it a little easier for anybody
> building kernels.
Search works for me, but I don't mind Sort either.
Why only menuconfig? Is it the one that you use mostly?
Any Help text for Sort? or is it obvious what it does? (no)
In an 80x25 terminal (window), the < Sort > option wraps around
past column 80.
I haven't looked at the source code (lately), but I think that it
would OK to not have the (extra) spaces inside the <...> brackets.
I.e., instead of
│ <Select> < Exit > < Help > < Save > < Load > < Sort
>
just have
│ <Select> <Exit> <Help> <Save> <Load> <Sort>
Or the <Select> does not need to be indented as much as it is.
And BTW, Yann made kconfig an orphan today. :(
> Signed-off-by: Felipe Balbi <[email protected]>
> ---
> scripts/kconfig/lxdialog/menubox.c | 18 +++++----
> scripts/kconfig/mconf.c | 83 +++++++++++++++++++++++++++++++++++---
> 2 files changed, 89 insertions(+), 12 deletions(-)
--
~Randy
Hi,
Randy Dunlap <[email protected]> writes:
> On 04/11/17 04:12, Felipe Balbi wrote:
>> With a growing amount of Kernel configuration, it's
>> getting ever more difficult to find anything on
>> menuconfig. Because of that, implement mergesort for
>> kconfig to make it a little easier for anybody
>> building kernels.
>
> Search works for me, but I don't mind Sort either.
yes, it works. It does a different thing, though. Here's what happens
when I want to find DWC3:
/ DWC3 RET
| Symbol: USB_DWC3 [=m] │
│ Type : tristate │
│ Prompt: DesignWare USB3 DRD Core Support │
│ Location: │
│ -> Device Drivers │
│ (1) -> USB support (USB_SUPPORT [=y]) │
│ Defined at drivers/usb/dwc3/Kconfig:1 │
│ Depends on: USB_SUPPORT [=y] && (USB [=y] || USB_GADGET [=y]) && HAS_DMA │
│ Selects: USB_XHCI_PLATFORM [=m] │
│ │
│ │
│ Symbol: USB_DWC3_DUAL_ROLE [=n] │
│ Type : boolean │
│ Prompt: Dual Role mode │
│ Location: │
│ -> Device Drivers │
│ -> USB support (USB_SUPPORT [=y]) │
│ -> DesignWare USB3 DRD Core Support (USB_DWC3 [=m]) │
│ (2) -> DWC3 Mode Selection (<choice> [=y]) │
│ Defined at drivers/usb/dwc3/Kconfig:41 │
│ Depends on: <choice> && (USB [=y]=y || USB [=y]=USB_DWC3 [=m]) && (USB_G │
│ │
│ │
│ Symbol: USB_DWC3_EXYNOS [=n] │
│ Type : tristate │
│ Prompt: Samsung Exynos Platform │
│ Location: │
│ -> Device Drivers │
│ -> USB support (USB_SUPPORT [=y]) │
│ (3) -> DesignWare USB3 DRD Core Support (USB_DWC3 [=m]) │
│ Defined at drivers/usb/dwc3/Kconfig:63 │
│ Depends on: USB_SUPPORT [=y] && USB_DWC3 [=m] && (ARCH_EXYNOS || COMPILE │
│ │
│ │
│ Symbol: USB_DWC3_GADGET [=y] │
│ Type : boolean │
│ Prompt: Gadget only mode │
│ Location: │
│ -> Device Drivers │
│ -> USB support (USB_SUPPORT [=y]) │
│ -> DesignWare USB3 DRD Core Support (USB_DWC3 [=m]) │
│ (4) -> DWC3 Mode Selection (<choice> [=y]) │
│ Defined at drivers/usb/dwc3/Kconfig:34 │
│ Depends on: <choice> && (USB_GADGET [=y]=y || USB_GAD
Now I know where DWC3 is defined, so I navigate to Device Driver, USB
Support and search for DesignWare USB3 DRD Core Support:
│ │ <M> USB Test and Measurement Class support │ │
│ │ *** NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may ***│ │
│ │ *** also be needed; see USB_STORAGE Help for more info *** │ │
│ │ <M> USB Mass Storage support │ │
│ │ [ ] USB Mass Storage verbose debug │ │
│ │ <M> Realtek Card Reader support │ │
│ │ [*] Realtek Card Reader autosuspend support │ │
│ │ <M> Datafab Compact Flash Reader support │ │
│ │ <M> Freecom USB/ATAPI Bridge support │ │
│ │ <M> ISD-200 USB/ATA Bridge support │ │
│ │ <M> USBAT/USBAT02-based storage support │ │
│ │ <M> SanDisk SDDR-09 (and other SmartMedia, including DPCM) sup│ │
│ │ <M> SanDisk SDDR-55 SmartMedia support │ │
│ │ <M> Lexar Jumpshot Compact Flash Reader │ │
│ │ <M> Olympus MAUSB-10/Fuji DPC-R1 support │ │
│ │ <M> Support OneTouch Button on Maxtor Hard Drives │ │
│ │ <M> Support for Rio Karma music player │ │
│ │ <M> SAT emulation on Cypress USB/ATA Bridge with ATACB │ │
│ │ <M> USB ENE card reader support │ │
│ │ <M> USB Attached SCSI │ │
│ │ *** USB Imaging devices *** │ │
│ │ < > USB Mustek MDC800 Digital Camera support │ │
│ │ < > Microtek X6USB scanner support │ │
│ │ < > USB/IP support │ │
│ │ < > Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...) │ │
│ │ < > DesignWare USB3 DRD Core Support │ │
│ │ < > DesignWare USB2 DRD Core Support │ │
│ │ < > ChipIdea Highspeed Dual Role Controller │ │
│ │ < > NXP ISP 1760/1761 support │ │
│ │ *** USB port drivers *** │ │
│ │ <M> USB Serial Converter support ---> │ │
│ │ *** USB Miscellaneous drivers *** │ │
│ │ < > EMI 6|2m USB Audio interface support │ │
│ │ < > EMI 2|6 USB Audio interface support │ │
│ │ < > ADU devices from Ontrak Control Systems │ │
│ │ < > USB 7-Segment LED Display │ │
│ │ < > USB Diamond Rio500 support │ │
│ │ < > USB Lego Infrared Tower support │ │
│ │ < > USB LCD driver support │ │
Compare that to the sorted view of this same entry:
│ │ --- USB support │ │
│ │ < > ADU devices from Ontrak Control Systems │ │
│ │ < > Apple Cinema Display support │ │
│ │ < > ChaosKey random number generator driver support │ │
│ │ < > ChipIdea Highspeed Dual Role Controller │ │
│ │ < > Cypress CY7C63xxx USB driver support │ │
│ │ < > Cypress USB thermometer driver support │ │
│ │ < > DesignWare USB2 DRD Core Support │ │
│ │ < > DesignWare USB3 DRD Core Support │ │
│ │ < > EMI 2|6 USB Audio interface support │ │
│ │ < > EMI 6|2m USB Audio interface support │ │
│ │ < > Elan PCMCIA CardBus Adapter USB Client │ │
│ │ {M} Functions for loading firmware on EZUSB chips │ │
│ │ < > IO Warrior driver support │ │
│ │ < > Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...) │ │
│ │ < > NXP ISP 1760/1761 support │ │
│ │ < > PlayStation 2 Trance Vibrator driver support │ │
│ │ < > Siemens ID USB Mouse Fingerprint sensor support │ │
│ │ <*> Support for Host-side USB │ │
│ │ < > BCMA usb host driver │ │
│ │ < > Cypress C67x00 HCD support │ │
│ │ [*] Dynamic USB minor allocation │ │
│ │ < > EHCI HCD (USB 2.0) support │ │
│ │ [*] Enable USB persist by default │ │
│ │ < > FOTG210 HCD support │ │
│ │ [ ] HCD test mode support │ │
│ │ < > ISP116X HCD support │ │
│ │ < > ISP1362 HCD support │ │
│ │ < > Microtek X6USB scanner support │ │
│ │ *** Miscellaneous USB options *** │ │
│ │ *** NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may ***│ │
│ │ < > OHCI HCD (USB 1.1) support │ │
│ │ [ ] OTG support │ │
│ │ < > OXU210HP HCD support │ │
│ │ < > R8A66597 HCD support │ │
│ │ [ ] Rely on OTG and EH Targeted Peripherals List │ │
│ │ < > SL811HS HCD support │ │
│ │ < > SSB usb host driver │ │
│ │ < > Support WUSB Cable Based Association (CBA) │ │
much easier to find, don't you think?
> Why only menuconfig? Is it the one that you use mostly?
shouldn't be difficult to port to nconfig.
> Any Help text for Sort? or is it obvious what it does? (no)
wait, it's not obvious what "Sort" means?
> In an 80x25 terminal (window), the < Sort > option wraps around
> past column 80.
not what I see here [1]
> I haven't looked at the source code (lately), but I think that it
> would OK to not have the (extra) spaces inside the <...> brackets.
> I.e., instead of
> │ <Select> < Exit > < Help > < Save > < Load > < Sort
> >
> just have
> │ <Select> <Exit> <Help> <Save> <Load> <Sort>
>
> Or the <Select> does not need to be indented as much as it is.
I changed that for this very reason
> And BTW, Yann made kconfig an orphan today. :(
oh well
[1] https://imgur.com/a/qyvG6
--
balbi
Felipe, All,
On 2017-04-12 10:49 +0300, Felipe Balbi spake thusly:
>
> Randy Dunlap <[email protected]> writes:
> > On 04/11/17 04:12, Felipe Balbi wrote:
> >> With a growing amount of Kernel configuration, it's
> >> getting ever more difficult to find anything on
> >> menuconfig. Because of that, implement mergesort for
> >> kconfig to make it a little easier for anybody
> >> building kernels.
> >
> > Search works for me, but I don't mind Sort either.
>
> yes, it works. It does a different thing, though. Here's what happens
> when I want to find DWC3:
>
> / DWC3 RET
>
> | Symbol: USB_DWC3 [=m] │
> │ Type : tristate │
> │ Prompt: DesignWare USB3 DRD Core Support │
> │ Location: │
> │ -> Device Drivers │
> │ (1) -> USB support (USB_SUPPORT [=y]) │
> │ Defined at drivers/usb/dwc3/Kconfig:1 │
> │ Depends on: USB_SUPPORT [=y] && (USB [=y] || USB_GADGET [=y]) && HAS_DMA │
> │ Selects: USB_XHCI_PLATFORM [=m] │
> │ │
> │ │
> │ Symbol: USB_DWC3_DUAL_ROLE [=n] │
> │ Type : boolean │
> │ Prompt: Dual Role mode │
> │ Location: │
> │ -> Device Drivers │
> │ -> USB support (USB_SUPPORT [=y]) │
> │ -> DesignWare USB3 DRD Core Support (USB_DWC3 [=m]) │
> │ (2) -> DWC3 Mode Selection (<choice> [=y]) │
> │ Defined at drivers/usb/dwc3/Kconfig:41 │
> │ Depends on: <choice> && (USB [=y]=y || USB [=y]=USB_DWC3 [=m]) && (USB_G │
> │ │
> │ │
> │ Symbol: USB_DWC3_EXYNOS [=n] │
> │ Type : tristate │
> │ Prompt: Samsung Exynos Platform │
> │ Location: │
> │ -> Device Drivers │
> │ -> USB support (USB_SUPPORT [=y]) │
> │ (3) -> DesignWare USB3 DRD Core Support (USB_DWC3 [=m]) │
> │ Defined at drivers/usb/dwc3/Kconfig:63 │
> │ Depends on: USB_SUPPORT [=y] && USB_DWC3 [=m] && (ARCH_EXYNOS || COMPILE │
> │ │
> │ │
> │ Symbol: USB_DWC3_GADGET [=y] │
> │ Type : boolean │
> │ Prompt: Gadget only mode │
> │ Location: │
> │ -> Device Drivers │
> │ -> USB support (USB_SUPPORT [=y]) │
> │ -> DesignWare USB3 DRD Core Support (USB_DWC3 [=m]) │
> │ (4) -> DWC3 Mode Selection (<choice> [=y]) │
> │ Defined at drivers/usb/dwc3/Kconfig:34 │
> │ Depends on: <choice> && (USB_GADGET [=y]=y || USB_GAD
>
> Now I know where DWC3 is defined, so I navigate to Device Driver, USB
> Support and search for DesignWare USB3 DRD Core Support:
Or you just press '3' (the number between parenthesis), and that will
take you directly there.
When you then exit, you're back top the search results.
> │ │ <M> USB Test and Measurement Class support │ │
[--SNIP unsorted menu--]
> │ │ < > USB LCD driver support │ │
>
> Compare that to the sorted view of this same entry:
>
> │ │ --- USB support │ │
[--SNIP sorted menu--]
> │ │ < > Support WUSB Cable Based Association (CBA) │ │
>
> much easier to find, don't you think?
Arguably, the order may also make sense, for example to "group" related
items. So, <Sort> should be a toggle, so that it is possible to go back
to the unsorted, original order, IMHO...
> > Any Help text for Sort? or is it obvious what it does? (no)
> wait, it's not obvious what "Sort" means?
I guess that what Randy said was that in this context, it is not more
obvious than Load or Save, and they are documented in the help (but it
is not obvious how to get the help).
For example, go on the "General setup" entry, but do not enter the menu.
Now, select Help: you'll get a bit of help on how to use menuconfig.
There, Load and Save are documented, in Alternate Configuration Files.
> > In an 80x25 terminal (window), the < Sort > option wraps around
> > past column 80.
> not what I see here [1]
I see the same as Randy here:
$ stty size
25 80
https://imgur.com/a/ku0sG
> > I haven't looked at the source code (lately), but I think that it
> > would OK to not have the (extra) spaces inside the <...> brackets.
> > I.e., instead of
> > │ <Select> < Exit > < Help > < Save > < Load > < Sort
> > >
> > just have
> > │ <Select> <Exit> <Help> <Save> <Load> <Sort>
> >
> > Or the <Select> does not need to be indented as much as it is.
> I changed that for this very reason
Or just always left-align the line, rather than center it?
> > And BTW, Yann made kconfig an orphan today. :(
Yes, I did a very bad job at being the maintainer over the past years,
so I could not really keep it any longer...
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
On 04/12/17 09:06, Yann E. MORIN wrote:
> Felipe, All,
>
> On 2017-04-12 10:49 +0300, Felipe Balbi spake thusly:
>>
>> Randy Dunlap <[email protected]> writes:
>>> On 04/11/17 04:12, Felipe Balbi wrote:
>>>> With a growing amount of Kernel configuration, it's
>>>> getting ever more difficult to find anything on
>>>> menuconfig. Because of that, implement mergesort for
>>>> kconfig to make it a little easier for anybody
>>>> building kernels.
>>>
>>> Search works for me, but I don't mind Sort either.
>>
[snip]
>
> Arguably, the order may also make sense, for example to "group" related
> items. So, <Sort> should be a toggle, so that it is possible to go back
> to the unsorted, original order, IMHO...
>
>>> Any Help text for Sort? or is it obvious what it does? (no)
>> wait, it's not obvious what "Sort" means?
>
> I guess that what Randy said was that in this context, it is not more
> obvious than Load or Save, and they are documented in the help (but it
> is not obvious how to get the help).
Correct. and true (about how to get to the Help text).
> For example, go on the "General setup" entry, but do not enter the menu.
> Now, select Help: you'll get a bit of help on how to use menuconfig.
>
> There, Load and Save are documented, in Alternate Configuration Files.
>
>>> In an 80x25 terminal (window), the < Sort > option wraps around
>>> past column 80.
>> not what I see here [1]
>
> I see the same as Randy here:
>
> $ stty size
> 25 80
>
> https://imgur.com/a/ku0sG
For some reason, Felipe's <Select> starts further to the left than mine
or Yann's does.
>>> I haven't looked at the source code (lately), but I think that it
>>> would OK to not have the (extra) spaces inside the <...> brackets.
>>> I.e., instead of
>>> │ <Select> < Exit > < Help > < Save > < Load > < Sort
>>> >
>>> just have
>>> │ <Select> <Exit> <Help> <Save> <Load> <Sort>
>>>
>>> Or the <Select> does not need to be indented as much as it is.
>> I changed that for this very reason
I don't see that. Is that part of the patch missing?
> Or just always left-align the line, rather than center it?
OK.
--
~Randy