-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 changed file
with
10 additions
and
10 deletions.
There are no files selected for viewing
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,5 +1,5 @@ | ||
/* | ||
Copyright © 2022 NAME HERE <EMAIL ADDRESS> | ||
Copyright © 2022 Eoin Barr <[email protected]> | ||
*/ | ||
package cmd | ||
|
||
|
@@ -214,24 +214,24 @@ func uniqueCities(cities types.CityDetails) types.CityDetails { | |
// Give the user a chance to select the correct city. | ||
func renderList(cities types.CityDetails) int { | ||
if err := ui.Init(); err != nil { | ||
fmt.Println(err) | ||
fmt.Println(err) | ||
} | ||
defer ui.Close() | ||
|
||
l := widgets.NewList() | ||
l.Title = "There are multiple cities with the same name." | ||
l.Border = false | ||
l.Border = false | ||
for i, c := range cities { | ||
l.Rows = append(l.Rows, fmt.Sprintf("%d: %s, %s", i, c.Name, c.Country)) | ||
} | ||
|
||
l.WrapText = false | ||
l.SetRect(0, 0, 100, 100) | ||
l.SelectedRowStyle.Fg = ui.ColorGreen | ||
l.SelectedRowStyle.Fg = ui.ColorGreen | ||
ui.Render(l) | ||
uiEvents := ui.PollEvents() | ||
var index int | ||
selected := false | ||
selected := false | ||
for { | ||
e := <-uiEvents | ||
|
||
|
@@ -253,12 +253,12 @@ func renderList(cities types.CityDetails) int { | |
os.Exit(0) | ||
case "<Enter>": | ||
index = l.SelectedRow | ||
selected = true | ||
selected = true | ||
} | ||
|
||
if selected { | ||
return index | ||
} | ||
|
||
if(selected){ | ||
return index | ||
} | ||
ui.Render(l) | ||
} | ||
} | ||
|