jroimartin / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
9.91k stars 608 forks source link

Should Gui.SetKeybinding accept a slice of viewnames? #12

Closed jroimartin closed 9 years ago

jroimartin commented 10 years ago

Then you could transform this kind of code:

if err := g.SetKeybinding("side", gocui.KeyCtrlSpace, 0, nextView); err != nil {
    return err
}
if err := g.SetKeybinding("main", gocui.KeyCtrlSpace, 0, nextView); err != nil {
    return err
}

Into something like this:

if err := g.SetKeybinding([]string{"main","side"}, gocui.KeyCtrlSpace, 0, nextView); err != nil {
    return err
}
hazbo commented 10 years ago

I think this would be a good idea, there's been times I've needed to do something like this and I've either gone with the duplicate code or just gone with the empty string, so a slice would be pretty sweet.

jroimartin commented 10 years ago

So do I (+1)

jroimartin commented 9 years ago

Finally, after trying it, I decided to discard this change. It adds complexity to the API and breaks with the conventions followed by the rest of functions. Also, it can be easily replaced by a for loop or so.