-
-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
191 additions
and
170 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package comps | ||
|
||
import ( | ||
"src.elv.sh/pkg/cli/term" | ||
"src.elv.sh/pkg/etk" | ||
) | ||
|
||
func ComboBox(c etk.Context) (etk.View, etk.React) { | ||
filterView, filterReact := c.Subcomp("filter", TextArea) | ||
filterBufferVar := etk.BindState(c, "filter/buffer", TextBuffer{}) | ||
listView, listReact := c.Subcomp("list", ListBox) | ||
listItemsVar := etk.BindState(c, "list/items", ListItems(nil)) | ||
listSelectedVar := etk.BindState(c, "list/selected", 0) | ||
|
||
genListVar := etk.State(c, "gen-list", func(string) (ListItems, int) { | ||
return nil, -1 | ||
}) | ||
lastFilterContentVar := etk.State(c, "-last-filter-content", "") | ||
|
||
return etk.VBoxView(0, filterView, listView), | ||
c.WithBinding(func(ev term.Event) etk.Reaction { | ||
if reaction := filterReact(ev); reaction != etk.Unused { | ||
filterContent := filterBufferVar.Get().Content | ||
if filterContent != lastFilterContentVar.Get() { | ||
lastFilterContentVar.Set(filterContent) | ||
items, selected := genListVar.Get()(filterContent) | ||
listItemsVar.Set(items) | ||
listSelectedVar.Set(selected) | ||
} | ||
return reaction | ||
} else { | ||
return listReact(ev) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package etk | ||
package comps | ||
|
||
import ( | ||
"regexp" | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package etk | ||
package comps | ||
|
||
import ( | ||
"src.elv.sh/pkg/cli/term" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.