add location autocomplete
This commit is contained in:
parent
4da8c423c0
commit
132021fe73
@ -13,7 +13,7 @@ func (view *Introduction) Event(state *ui.State, event vaxis.Event) (processed b
|
|||||||
case "Ctrl+c", "Ctrl+d":
|
case "Ctrl+c", "Ctrl+d":
|
||||||
close(ui.Quit)
|
close(ui.Quit)
|
||||||
case "Enter":
|
case "Enter":
|
||||||
ui.ViewChange <- &Settings{}
|
ui.ViewChange <- NewSettings()
|
||||||
}
|
}
|
||||||
processed = true
|
processed = true
|
||||||
}
|
}
|
||||||
|
637
app/settings.go
637
app/settings.go
@ -7,13 +7,19 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.sr.ht/~rockorager/vaxis"
|
"git.sr.ht/~rockorager/vaxis"
|
||||||
"git.sr.ht/~rockorager/vaxis/widgets/textinput"
|
|
||||||
"git.tilde.town/nbsp/welcome/ui"
|
"git.tilde.town/nbsp/welcome/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
index int
|
index int
|
||||||
inputs [3]textinput.Model
|
inputs [3]ui.Input
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSettings() *Settings {
|
||||||
|
s := &Settings{}
|
||||||
|
s.inputs[2].Placeholder = "e.g. America/New_York"
|
||||||
|
s.inputs[2].AutoComplete = TIMEZONES
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (view *Settings) Event(state *ui.State, event vaxis.Event) (processed bool) {
|
func (view *Settings) Event(state *ui.State, event vaxis.Event) (processed bool) {
|
||||||
@ -82,19 +88,7 @@ func (view *Settings) Event(state *ui.State, event vaxis.Event) (processed bool)
|
|||||||
|
|
||||||
_, q3 := win.New(0, q1+q2, 80, state.Window().Height).Wrap(vaxis.Segment{Text: `
|
_, q3 := win.New(0, q1+q2, 80, state.Window().Height).Wrap(vaxis.Segment{Text: `
|
||||||
|
|
||||||
3. `}, vaxis.Segment{Text: "what's your timezone?", Style: vaxis.Style{Foreground: vaxis.IndexColor(1)}}, vaxis.Segment{Text: ` this will change all times you view in town to your local timezone, so you don't have to convert from utc in your head. the format for timezones can be found here:
|
3. `}, vaxis.Segment{Text: "what's your timezone?", Style: vaxis.Style{Foreground: vaxis.IndexColor(1)}}, vaxis.Segment{Text: ` this will change all times you view in town to your local timezone, so you don't have to convert from utc in your head. just start typing your continent and a big city in your area.
|
||||||
|
|
||||||
`},
|
|
||||||
vaxis.Segment{
|
|
||||||
Text: "https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List",
|
|
||||||
Style: vaxis.Style{
|
|
||||||
Foreground: vaxis.IndexColor(4),
|
|
||||||
UnderlineStyle: vaxis.UnderlineSingle,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
vaxis.Segment{Text: `
|
|
||||||
|
|
||||||
it should look something like America/New_York.
|
|
||||||
|
|
||||||
>
|
>
|
||||||
|
|
||||||
@ -133,19 +127,7 @@ it should look something like America/New_York.
|
|||||||
view.inputs[1].Draw(vaxis.Window{win.Vx, &win, 5, h, int(math.Min(73.0, float64(win.Width)-7)), 1})
|
view.inputs[1].Draw(vaxis.Window{win.Vx, &win, 5, h, int(math.Min(73.0, float64(win.Width)-7)), 1})
|
||||||
win.SetStyle(3, h, vaxis.Style{Attribute: vaxis.AttrReverse})
|
win.SetStyle(3, h, vaxis.Style{Attribute: vaxis.AttrReverse})
|
||||||
case 3:
|
case 3:
|
||||||
_, h := win.Wrap(vaxis.Segment{Text: `3. `}, vaxis.Segment{Text: "what's your timezone?", Style: vaxis.Style{Foreground: vaxis.IndexColor(1)}}, vaxis.Segment{Text: ` this will change all times you view in town to your local timezone, so you don't have to convert from utc in your head. the format for timezones can be found here:
|
_, h := win.Wrap(vaxis.Segment{Text: `3. `}, vaxis.Segment{Text: "what's your timezone?", Style: vaxis.Style{Foreground: vaxis.IndexColor(1)}}, vaxis.Segment{Text: ` this will change all times you view in town to your local timezone, so you don't have to convert from utc in your head. just start typing your continent and a big city in your area.
|
||||||
|
|
||||||
`},
|
|
||||||
vaxis.Segment{
|
|
||||||
Text: "https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List",
|
|
||||||
Style: vaxis.Style{
|
|
||||||
Foreground: vaxis.IndexColor(4),
|
|
||||||
UnderlineStyle: vaxis.UnderlineSingle,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
vaxis.Segment{Text: `
|
|
||||||
|
|
||||||
it should look something like America/New_York.
|
|
||||||
|
|
||||||
>`})
|
>`})
|
||||||
view.inputs[2].Draw(vaxis.Window{win.Vx, &win, 5, h, int(math.Min(73.0, float64(win.Width)-7)), 1})
|
view.inputs[2].Draw(vaxis.Window{win.Vx, &win, 5, h, int(math.Min(73.0, float64(win.Width)-7)), 1})
|
||||||
@ -158,3 +140,602 @@ it should look something like America/New_York.
|
|||||||
state.HideCursor()
|
state.HideCursor()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var TIMEZONES = []string{
|
||||||
|
"Africa/Abidjan",
|
||||||
|
"Africa/Accra",
|
||||||
|
"Africa/Bamako",
|
||||||
|
"Africa/Banjul",
|
||||||
|
"Africa/Conakry",
|
||||||
|
"Africa/Dakar",
|
||||||
|
"Africa/Freetown",
|
||||||
|
"Africa/Lome",
|
||||||
|
"Africa/Nouakchott",
|
||||||
|
"Africa/Ouagadougou",
|
||||||
|
"Africa/Timbuktu",
|
||||||
|
"Atlantic/Reykjavik",
|
||||||
|
"Atlantic/St_Helena",
|
||||||
|
"Iceland",
|
||||||
|
"Africa/Algiers",
|
||||||
|
"Africa/Bissau",
|
||||||
|
"Africa/Cairo",
|
||||||
|
"Egypt",
|
||||||
|
"Africa/Casablanca",
|
||||||
|
"Africa/Ceuta",
|
||||||
|
"Africa/El_Aaiun",
|
||||||
|
"Africa/Johannesburg",
|
||||||
|
"Africa/Maseru",
|
||||||
|
"Africa/Mbabane",
|
||||||
|
"Africa/Juba",
|
||||||
|
"Africa/Khartoum",
|
||||||
|
"Africa/Lagos",
|
||||||
|
"Africa/Bangui",
|
||||||
|
"Africa/Brazzaville",
|
||||||
|
"Africa/Douala",
|
||||||
|
"Africa/Kinshasa",
|
||||||
|
"Africa/Libreville",
|
||||||
|
"Africa/Luanda",
|
||||||
|
"Africa/Malabo",
|
||||||
|
"Africa/Niamey",
|
||||||
|
"Africa/Porto-Novo",
|
||||||
|
"Africa/Maputo",
|
||||||
|
"Africa/Blantyre",
|
||||||
|
"Africa/Bujumbura",
|
||||||
|
"Africa/Gaborone",
|
||||||
|
"Africa/Harare",
|
||||||
|
"Africa/Kigali",
|
||||||
|
"Africa/Lubumbashi",
|
||||||
|
"Africa/Lusaka",
|
||||||
|
"Africa/Monrovia",
|
||||||
|
"Africa/Nairobi",
|
||||||
|
"Africa/Addis_Ababa",
|
||||||
|
"Africa/Asmara",
|
||||||
|
"Africa/Asmera",
|
||||||
|
"Africa/Dar_es_Salaam",
|
||||||
|
"Africa/Djibouti",
|
||||||
|
"Africa/Kampala",
|
||||||
|
"Africa/Mogadishu",
|
||||||
|
"Indian/Antananarivo",
|
||||||
|
"Indian/Comoro",
|
||||||
|
"Indian/Mayotte",
|
||||||
|
"Africa/Ndjamena",
|
||||||
|
"Africa/Sao_Tome",
|
||||||
|
"Africa/Tripoli",
|
||||||
|
"Libya",
|
||||||
|
"Africa/Tunis",
|
||||||
|
"Africa/Windhoek",
|
||||||
|
"America/Adak",
|
||||||
|
"America/Atka",
|
||||||
|
"US/Aleutian",
|
||||||
|
"America/Anchorage",
|
||||||
|
"US/Alaska",
|
||||||
|
"America/Araguaina",
|
||||||
|
"America/Argentina/Buenos_Aires",
|
||||||
|
"America/Buenos_Aires",
|
||||||
|
"America/Argentina/Catamarca",
|
||||||
|
"America/Argentina/ComodRivadavia",
|
||||||
|
"America/Catamarca",
|
||||||
|
"America/Argentina/Cordoba",
|
||||||
|
"America/Cordoba",
|
||||||
|
"America/Rosario",
|
||||||
|
"America/Argentina/Jujuy",
|
||||||
|
"America/Jujuy",
|
||||||
|
"America/Argentina/La_Rioja",
|
||||||
|
"America/Argentina/Mendoza",
|
||||||
|
"America/Mendoza",
|
||||||
|
"America/Argentina/Rio_Gallegos",
|
||||||
|
"America/Argentina/Salta",
|
||||||
|
"America/Argentina/San_Juan",
|
||||||
|
"America/Argentina/San_Luis",
|
||||||
|
"America/Argentina/Tucuman",
|
||||||
|
"America/Argentina/Ushuaia",
|
||||||
|
"America/Asuncion",
|
||||||
|
"America/Bahia",
|
||||||
|
"America/Bahia_Banderas",
|
||||||
|
"America/Barbados",
|
||||||
|
"America/Belem",
|
||||||
|
"America/Belize",
|
||||||
|
"America/Boa_Vista",
|
||||||
|
"America/Bogota",
|
||||||
|
"America/Boise",
|
||||||
|
"America/Cambridge_Bay",
|
||||||
|
"America/Campo_Grande",
|
||||||
|
"America/Cancun",
|
||||||
|
"America/Caracas",
|
||||||
|
"America/Cayenne",
|
||||||
|
"America/Chicago",
|
||||||
|
"CST6CDT",
|
||||||
|
"US/Central",
|
||||||
|
"America/Chihuahua",
|
||||||
|
"America/Ciudad_Juarez",
|
||||||
|
"America/Costa_Rica",
|
||||||
|
"America/Cuiaba",
|
||||||
|
"America/Danmarkshavn",
|
||||||
|
"America/Dawson",
|
||||||
|
"America/Dawson_Creek",
|
||||||
|
"America/Denver",
|
||||||
|
"America/Shiprock",
|
||||||
|
"MST7MDT",
|
||||||
|
"Navajo",
|
||||||
|
"US/Mountain",
|
||||||
|
"America/Detroit",
|
||||||
|
"US/Michigan",
|
||||||
|
"America/Edmonton",
|
||||||
|
"America/Yellowknife",
|
||||||
|
"Canada/Mountain",
|
||||||
|
"America/Eirunepe",
|
||||||
|
"America/El_Salvador",
|
||||||
|
"America/Fort_Nelson",
|
||||||
|
"America/Fortaleza",
|
||||||
|
"America/Glace_Bay",
|
||||||
|
"America/Goose_Bay",
|
||||||
|
"America/Grand_Turk",
|
||||||
|
"America/Guatemala",
|
||||||
|
"America/Guayaquil",
|
||||||
|
"America/Guyana",
|
||||||
|
"America/Halifax",
|
||||||
|
"Canada/Atlantic",
|
||||||
|
"America/Havana",
|
||||||
|
"Cuba",
|
||||||
|
"America/Hermosillo",
|
||||||
|
"America/Indiana/Indianapolis",
|
||||||
|
"America/Fort_Wayne",
|
||||||
|
"America/Indianapolis",
|
||||||
|
"US/East-Indiana",
|
||||||
|
"America/Indiana/Knox",
|
||||||
|
"America/Knox_IN",
|
||||||
|
"US/Indiana-Starke",
|
||||||
|
"America/Indiana/Marengo",
|
||||||
|
"America/Indiana/Petersburg",
|
||||||
|
"America/Indiana/Tell_City",
|
||||||
|
"America/Indiana/Vevay",
|
||||||
|
"America/Indiana/Vincennes",
|
||||||
|
"America/Indiana/Winamac",
|
||||||
|
"America/Inuvik",
|
||||||
|
"America/Iqaluit",
|
||||||
|
"America/Pangnirtung",
|
||||||
|
"America/Jamaica",
|
||||||
|
"Jamaica",
|
||||||
|
"America/Juneau",
|
||||||
|
"America/Kentucky/Louisville",
|
||||||
|
"America/Louisville",
|
||||||
|
"America/Kentucky/Monticello",
|
||||||
|
"America/La_Paz",
|
||||||
|
"America/Lima",
|
||||||
|
"America/Los_Angeles",
|
||||||
|
"PST8PDT",
|
||||||
|
"US/Pacific",
|
||||||
|
"America/Maceio",
|
||||||
|
"America/Managua",
|
||||||
|
"America/Manaus",
|
||||||
|
"Brazil/West",
|
||||||
|
"America/Martinique",
|
||||||
|
"America/Matamoros",
|
||||||
|
"America/Mazatlan",
|
||||||
|
"Mexico/BajaSur",
|
||||||
|
"America/Menominee",
|
||||||
|
"America/Merida",
|
||||||
|
"America/Metlakatla",
|
||||||
|
"America/Mexico_City",
|
||||||
|
"Mexico/General",
|
||||||
|
"America/Miquelon",
|
||||||
|
"America/Moncton",
|
||||||
|
"America/Monterrey",
|
||||||
|
"America/Montevideo",
|
||||||
|
"America/New_York",
|
||||||
|
"EST5EDT",
|
||||||
|
"US/Eastern",
|
||||||
|
"America/Nome",
|
||||||
|
"America/Noronha",
|
||||||
|
"Brazil/DeNoronha",
|
||||||
|
"America/North_Dakota/Beulah",
|
||||||
|
"America/North_Dakota/Center",
|
||||||
|
"America/North_Dakota/New_Salem",
|
||||||
|
"America/Nuuk",
|
||||||
|
"America/Godthab",
|
||||||
|
"America/Ojinaga",
|
||||||
|
"America/Panama",
|
||||||
|
"America/Atikokan",
|
||||||
|
"America/Cayman",
|
||||||
|
"America/Coral_Harbour",
|
||||||
|
"EST",
|
||||||
|
"America/Paramaribo",
|
||||||
|
"America/Phoenix",
|
||||||
|
"America/Creston",
|
||||||
|
"MST",
|
||||||
|
"US/Arizona",
|
||||||
|
"America/Port-au-Prince",
|
||||||
|
"America/Porto_Velho",
|
||||||
|
"America/Puerto_Rico",
|
||||||
|
"America/Anguilla",
|
||||||
|
"America/Antigua",
|
||||||
|
"America/Aruba",
|
||||||
|
"America/Blanc-Sablon",
|
||||||
|
"America/Curacao",
|
||||||
|
"America/Dominica",
|
||||||
|
"America/Grenada",
|
||||||
|
"America/Guadeloupe",
|
||||||
|
"America/Kralendijk",
|
||||||
|
"America/Lower_Princes",
|
||||||
|
"America/Marigot",
|
||||||
|
"America/Montserrat",
|
||||||
|
"America/Port_of_Spain",
|
||||||
|
"America/St_Barthelemy",
|
||||||
|
"America/St_Kitts",
|
||||||
|
"America/St_Lucia",
|
||||||
|
"America/St_Thomas",
|
||||||
|
"America/St_Vincent",
|
||||||
|
"America/Tortola",
|
||||||
|
"America/Virgin",
|
||||||
|
"America/Punta_Arenas",
|
||||||
|
"America/Rankin_Inlet",
|
||||||
|
"America/Recife",
|
||||||
|
"America/Regina",
|
||||||
|
"Canada/Saskatchewan",
|
||||||
|
"America/Resolute",
|
||||||
|
"America/Rio_Branco",
|
||||||
|
"America/Porto_Acre",
|
||||||
|
"Brazil/Acre",
|
||||||
|
"America/Santarem",
|
||||||
|
"America/Santiago",
|
||||||
|
"Chile/Continental",
|
||||||
|
"America/Santo_Domingo",
|
||||||
|
"America/Sao_Paulo",
|
||||||
|
"Brazil/East",
|
||||||
|
"America/Scoresbysund",
|
||||||
|
"America/Sitka",
|
||||||
|
"America/St_Johns",
|
||||||
|
"Canada/Newfoundland",
|
||||||
|
"America/Swift_Current",
|
||||||
|
"America/Tegucigalpa",
|
||||||
|
"America/Thule",
|
||||||
|
"America/Tijuana",
|
||||||
|
"America/Ensenada",
|
||||||
|
"America/Santa_Isabel",
|
||||||
|
"Mexico/BajaNorte",
|
||||||
|
"America/Toronto",
|
||||||
|
"America/Montreal",
|
||||||
|
"America/Nassau",
|
||||||
|
"America/Nipigon",
|
||||||
|
"America/Thunder_Bay",
|
||||||
|
"Canada/Eastern",
|
||||||
|
"America/Vancouver",
|
||||||
|
"Canada/Pacific",
|
||||||
|
"America/Whitehorse",
|
||||||
|
"Canada/Yukon",
|
||||||
|
"America/Winnipeg",
|
||||||
|
"America/Rainy_River",
|
||||||
|
"Canada/Central",
|
||||||
|
"America/Yakutat",
|
||||||
|
"Antarctica/Casey",
|
||||||
|
"Antarctica/Davis",
|
||||||
|
"Antarctica/Macquarie",
|
||||||
|
"Antarctica/Mawson",
|
||||||
|
"Antarctica/Palmer",
|
||||||
|
"Antarctica/Rothera",
|
||||||
|
"Antarctica/Troll",
|
||||||
|
"Antarctica/Vostok",
|
||||||
|
"Asia/Almaty",
|
||||||
|
"Asia/Amman",
|
||||||
|
"Asia/Anadyr",
|
||||||
|
"Asia/Aqtau",
|
||||||
|
"Asia/Aqtobe",
|
||||||
|
"Asia/Ashgabat",
|
||||||
|
"Asia/Ashkhabad",
|
||||||
|
"Asia/Atyrau",
|
||||||
|
"Asia/Baghdad",
|
||||||
|
"Asia/Baku",
|
||||||
|
"Asia/Bangkok",
|
||||||
|
"Asia/Phnom_Penh",
|
||||||
|
"Asia/Vientiane",
|
||||||
|
"Indian/Christmas",
|
||||||
|
"Asia/Barnaul",
|
||||||
|
"Asia/Beirut",
|
||||||
|
"Asia/Bishkek",
|
||||||
|
"Asia/Chita",
|
||||||
|
"Asia/Colombo",
|
||||||
|
"Asia/Damascus",
|
||||||
|
"Asia/Dhaka",
|
||||||
|
"Asia/Dacca",
|
||||||
|
"Asia/Dili",
|
||||||
|
"Asia/Dubai",
|
||||||
|
"Asia/Muscat",
|
||||||
|
"Indian/Mahe",
|
||||||
|
"Indian/Reunion",
|
||||||
|
"Asia/Dushanbe",
|
||||||
|
"Asia/Famagusta",
|
||||||
|
"Asia/Gaza",
|
||||||
|
"Asia/Hebron",
|
||||||
|
"Asia/Ho_Chi_Minh",
|
||||||
|
"Asia/Saigon",
|
||||||
|
"Asia/Hong_Kong",
|
||||||
|
"Hongkong",
|
||||||
|
"Asia/Hovd",
|
||||||
|
"Asia/Irkutsk",
|
||||||
|
"Asia/Jakarta",
|
||||||
|
"Asia/Jayapura",
|
||||||
|
"Asia/Jerusalem",
|
||||||
|
"Asia/Tel_Aviv",
|
||||||
|
"Israel",
|
||||||
|
"Asia/Kabul",
|
||||||
|
"Asia/Kamchatka",
|
||||||
|
"Asia/Karachi",
|
||||||
|
"Asia/Kathmandu",
|
||||||
|
"Asia/Katmandu",
|
||||||
|
"Asia/Khandyga",
|
||||||
|
"Asia/Kolkata",
|
||||||
|
"Asia/Calcutta",
|
||||||
|
"Asia/Krasnoyarsk",
|
||||||
|
"Asia/Kuching",
|
||||||
|
"Asia/Brunei",
|
||||||
|
"Asia/Macau",
|
||||||
|
"Asia/Macao",
|
||||||
|
"Asia/Magadan",
|
||||||
|
"Asia/Makassar",
|
||||||
|
"Asia/Ujung_Pandang",
|
||||||
|
"Asia/Manila",
|
||||||
|
"Asia/Nicosia",
|
||||||
|
"Europe/Nicosia",
|
||||||
|
"Asia/Novokuznetsk",
|
||||||
|
"Asia/Novosibirsk",
|
||||||
|
"Asia/Omsk",
|
||||||
|
"Asia/Oral",
|
||||||
|
"Asia/Pontianak",
|
||||||
|
"Asia/Pyongyang",
|
||||||
|
"Asia/Qatar",
|
||||||
|
"Asia/Bahrain",
|
||||||
|
"Asia/Qostanay",
|
||||||
|
"Asia/Qyzylorda",
|
||||||
|
"Asia/Riyadh",
|
||||||
|
"Antarctica/Syowa",
|
||||||
|
"Asia/Aden",
|
||||||
|
"Asia/Kuwait",
|
||||||
|
"Asia/Sakhalin",
|
||||||
|
"Asia/Samarkand",
|
||||||
|
"Asia/Seoul",
|
||||||
|
"ROK",
|
||||||
|
"Asia/Shanghai",
|
||||||
|
"Asia/Chongqing",
|
||||||
|
"Asia/Chungking",
|
||||||
|
"Asia/Harbin",
|
||||||
|
"PRC",
|
||||||
|
"Asia/Singapore",
|
||||||
|
"Asia/Kuala_Lumpur",
|
||||||
|
"Singapore",
|
||||||
|
"Asia/Srednekolymsk",
|
||||||
|
"Asia/Taipei",
|
||||||
|
"ROC",
|
||||||
|
"Asia/Tashkent",
|
||||||
|
"Asia/Tbilisi",
|
||||||
|
"Asia/Tehran",
|
||||||
|
"Iran",
|
||||||
|
"Asia/Thimphu",
|
||||||
|
"Asia/Thimbu",
|
||||||
|
"Asia/Tokyo",
|
||||||
|
"Japan",
|
||||||
|
"Asia/Tomsk",
|
||||||
|
"Asia/Ulaanbaatar",
|
||||||
|
"Asia/Choibalsan",
|
||||||
|
"Asia/Ulan_Bator",
|
||||||
|
"Asia/Urumqi",
|
||||||
|
"Asia/Kashgar",
|
||||||
|
"Asia/Ust-Nera",
|
||||||
|
"Asia/Vladivostok",
|
||||||
|
"Asia/Yakutsk",
|
||||||
|
"Asia/Yangon",
|
||||||
|
"Asia/Rangoon",
|
||||||
|
"Indian/Cocos",
|
||||||
|
"Asia/Yekaterinburg",
|
||||||
|
"Asia/Yerevan",
|
||||||
|
"Atlantic/Azores",
|
||||||
|
"Atlantic/Bermuda",
|
||||||
|
"Atlantic/Canary",
|
||||||
|
"Atlantic/Cape_Verde",
|
||||||
|
"Atlantic/Faroe",
|
||||||
|
"Atlantic/Faeroe",
|
||||||
|
"Atlantic/Madeira",
|
||||||
|
"Atlantic/South_Georgia",
|
||||||
|
"Atlantic/Stanley",
|
||||||
|
"Australia/Adelaide",
|
||||||
|
"Australia/South",
|
||||||
|
"Australia/Brisbane",
|
||||||
|
"Australia/Queensland",
|
||||||
|
"Australia/Broken_Hill",
|
||||||
|
"Australia/Yancowinna",
|
||||||
|
"Australia/Darwin",
|
||||||
|
"Australia/North",
|
||||||
|
"Australia/Eucla",
|
||||||
|
"Australia/Hobart",
|
||||||
|
"Australia/Currie",
|
||||||
|
"Australia/Tasmania",
|
||||||
|
"Australia/Lindeman",
|
||||||
|
"Australia/Lord_Howe",
|
||||||
|
"Australia/LHI",
|
||||||
|
"Australia/Melbourne",
|
||||||
|
"Australia/Victoria",
|
||||||
|
"Australia/Perth",
|
||||||
|
"Australia/West",
|
||||||
|
"Australia/Sydney",
|
||||||
|
"Australia/ACT",
|
||||||
|
"Australia/Canberra",
|
||||||
|
"Australia/NSW",
|
||||||
|
"Etc/GMT",
|
||||||
|
"Etc/GMT+0",
|
||||||
|
"Etc/GMT-0",
|
||||||
|
"Etc/GMT0",
|
||||||
|
"Etc/Greenwich",
|
||||||
|
"GMT",
|
||||||
|
"GMT+0",
|
||||||
|
"GMT-0",
|
||||||
|
"GMT0",
|
||||||
|
"Greenwich",
|
||||||
|
"Etc/GMT-1",
|
||||||
|
"Etc/GMT-10",
|
||||||
|
"Etc/GMT-11",
|
||||||
|
"Etc/GMT-12",
|
||||||
|
"Etc/GMT-13",
|
||||||
|
"Etc/GMT-14",
|
||||||
|
"Etc/GMT-2",
|
||||||
|
"Etc/GMT-3",
|
||||||
|
"Etc/GMT-4",
|
||||||
|
"Etc/GMT-5",
|
||||||
|
"Etc/GMT-6",
|
||||||
|
"Etc/GMT-7",
|
||||||
|
"Etc/GMT-8",
|
||||||
|
"Etc/GMT-9",
|
||||||
|
"Etc/GMT+1",
|
||||||
|
"Etc/GMT+10",
|
||||||
|
"Etc/GMT+11",
|
||||||
|
"Etc/GMT+12",
|
||||||
|
"Etc/GMT+2",
|
||||||
|
"Etc/GMT+3",
|
||||||
|
"Etc/GMT+4",
|
||||||
|
"Etc/GMT+5",
|
||||||
|
"Etc/GMT+6",
|
||||||
|
"Etc/GMT+7",
|
||||||
|
"Etc/GMT+8",
|
||||||
|
"Etc/GMT+9",
|
||||||
|
"Etc/UTC",
|
||||||
|
"Etc/UCT",
|
||||||
|
"Etc/Universal",
|
||||||
|
"Etc/Zulu",
|
||||||
|
"UCT",
|
||||||
|
"UTC",
|
||||||
|
"Universal",
|
||||||
|
"Zulu",
|
||||||
|
"Europe/Andorra",
|
||||||
|
"Europe/Astrakhan",
|
||||||
|
"Europe/Athens",
|
||||||
|
"EET",
|
||||||
|
"Europe/Belgrade",
|
||||||
|
"Europe/Ljubljana",
|
||||||
|
"Europe/Podgorica",
|
||||||
|
"Europe/Sarajevo",
|
||||||
|
"Europe/Skopje",
|
||||||
|
"Europe/Zagreb",
|
||||||
|
"Europe/Berlin",
|
||||||
|
"Arctic/Longyearbyen",
|
||||||
|
"Atlantic/Jan_Mayen",
|
||||||
|
"Europe/Copenhagen",
|
||||||
|
"Europe/Oslo",
|
||||||
|
"Europe/Stockholm",
|
||||||
|
"Europe/Brussels",
|
||||||
|
"CET",
|
||||||
|
"Europe/Amsterdam",
|
||||||
|
"Europe/Luxembourg",
|
||||||
|
"MET",
|
||||||
|
"Europe/Bucharest",
|
||||||
|
"Europe/Budapest",
|
||||||
|
"Europe/Chisinau",
|
||||||
|
"Europe/Tiraspol",
|
||||||
|
"Europe/Dublin",
|
||||||
|
"Eire",
|
||||||
|
"Europe/Gibraltar",
|
||||||
|
"Europe/Helsinki",
|
||||||
|
"Europe/Mariehamn",
|
||||||
|
"Europe/Istanbul",
|
||||||
|
"Asia/Istanbul",
|
||||||
|
"Turkey",
|
||||||
|
"Europe/Kaliningrad",
|
||||||
|
"Europe/Kirov",
|
||||||
|
"Europe/Kyiv",
|
||||||
|
"Europe/Kiev",
|
||||||
|
"Europe/Uzhgorod",
|
||||||
|
"Europe/Zaporozhye",
|
||||||
|
"Europe/Lisbon",
|
||||||
|
"Portugal",
|
||||||
|
"WET",
|
||||||
|
"Europe/London",
|
||||||
|
"Europe/Belfast",
|
||||||
|
"Europe/Guernsey",
|
||||||
|
"Europe/Isle_of_Man",
|
||||||
|
"Europe/Jersey",
|
||||||
|
"GB",
|
||||||
|
"GB-Eire",
|
||||||
|
"Europe/Madrid",
|
||||||
|
"Europe/Malta",
|
||||||
|
"Europe/Minsk",
|
||||||
|
"Europe/Moscow",
|
||||||
|
"W-SU",
|
||||||
|
"Europe/Paris",
|
||||||
|
"Europe/Monaco",
|
||||||
|
"Europe/Prague",
|
||||||
|
"Europe/Bratislava",
|
||||||
|
"Europe/Riga",
|
||||||
|
"Europe/Rome",
|
||||||
|
"Europe/San_Marino",
|
||||||
|
"Europe/Vatican",
|
||||||
|
"Europe/Samara",
|
||||||
|
"Europe/Saratov",
|
||||||
|
"Europe/Simferopol",
|
||||||
|
"Europe/Sofia",
|
||||||
|
"Europe/Tallinn",
|
||||||
|
"Europe/Tirane",
|
||||||
|
"Europe/Ulyanovsk",
|
||||||
|
"Europe/Vienna",
|
||||||
|
"Europe/Vilnius",
|
||||||
|
"Europe/Volgograd",
|
||||||
|
"Europe/Warsaw",
|
||||||
|
"Poland",
|
||||||
|
"Europe/Zurich",
|
||||||
|
"Europe/Busingen",
|
||||||
|
"Europe/Vaduz",
|
||||||
|
"Indian/Chagos",
|
||||||
|
"Indian/Maldives",
|
||||||
|
"Indian/Kerguelen",
|
||||||
|
"Indian/Mauritius",
|
||||||
|
"Pacific/Apia",
|
||||||
|
"Pacific/Auckland",
|
||||||
|
"Antarctica/McMurdo",
|
||||||
|
"Antarctica/South_Pole",
|
||||||
|
"NZ",
|
||||||
|
"Pacific/Bougainville",
|
||||||
|
"Pacific/Chatham",
|
||||||
|
"NZ-CHAT",
|
||||||
|
"Pacific/Easter",
|
||||||
|
"Chile/EasterIsland",
|
||||||
|
"Pacific/Efate",
|
||||||
|
"Pacific/Fakaofo",
|
||||||
|
"Pacific/Fiji",
|
||||||
|
"Pacific/Galapagos",
|
||||||
|
"Pacific/Gambier",
|
||||||
|
"Pacific/Guadalcanal",
|
||||||
|
"Pacific/Pohnpei",
|
||||||
|
"Pacific/Ponape",
|
||||||
|
"Pacific/Guam",
|
||||||
|
"Pacific/Saipan",
|
||||||
|
"Pacific/Honolulu",
|
||||||
|
"HST",
|
||||||
|
"Pacific/Johnston",
|
||||||
|
"US/Hawaii",
|
||||||
|
"Pacific/Kanton",
|
||||||
|
"Pacific/Enderbury",
|
||||||
|
"Pacific/Kiritimati",
|
||||||
|
"Pacific/Kosrae",
|
||||||
|
"Pacific/Kwajalein",
|
||||||
|
"Kwajalein",
|
||||||
|
"Pacific/Marquesas",
|
||||||
|
"Pacific/Nauru",
|
||||||
|
"Pacific/Niue",
|
||||||
|
"Pacific/Norfolk",
|
||||||
|
"Pacific/Noumea",
|
||||||
|
"Pacific/Pago_Pago",
|
||||||
|
"Pacific/Midway",
|
||||||
|
"Pacific/Samoa",
|
||||||
|
"US/Samoa",
|
||||||
|
"Pacific/Palau",
|
||||||
|
"Pacific/Pitcairn",
|
||||||
|
"Pacific/Port_Moresby",
|
||||||
|
"Antarctica/DumontDUrville",
|
||||||
|
"Pacific/Chuuk",
|
||||||
|
"Pacific/Truk",
|
||||||
|
"Pacific/Yap",
|
||||||
|
"Pacific/Rarotonga",
|
||||||
|
"Pacific/Tahiti",
|
||||||
|
"Pacific/Tarawa",
|
||||||
|
"Pacific/Funafuti",
|
||||||
|
"Pacific/Majuro",
|
||||||
|
"Pacific/Wake",
|
||||||
|
"Pacific/Wallis",
|
||||||
|
"Pacific/Tongatapu",
|
||||||
|
}
|
||||||
|
39
ui/autocomplete.go
Normal file
39
ui/autocomplete.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package ui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"git.sr.ht/~rockorager/vaxis"
|
||||||
|
"git.sr.ht/~rockorager/vaxis/widgets/textinput"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Input struct {
|
||||||
|
model textinput.Model
|
||||||
|
AutoComplete []string
|
||||||
|
Placeholder string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Input) Draw(win vaxis.Window) {
|
||||||
|
// figure out which thing to complete
|
||||||
|
rest := ""
|
||||||
|
if m.model.String() != "" {
|
||||||
|
for _, comp := range m.AutoComplete {
|
||||||
|
if strings.HasPrefix(comp, m.model.String()) {
|
||||||
|
rest = comp[len(m.model.String()):]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rest = m.Placeholder
|
||||||
|
}
|
||||||
|
m.model.Draw(win)
|
||||||
|
win.New(len(m.model.String()), 0, win.Width, win.Height).Print(vaxis.Segment{Text: rest, Style: vaxis.Style{Foreground: vaxis.IndexColor(8)}})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Input) Update(event vaxis.Event) {
|
||||||
|
m.model.Update(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Input) String() string {
|
||||||
|
return m.model.String()
|
||||||
|
}
|
105
ui/list.go
105
ui/list.go
@ -1,105 +0,0 @@
|
|||||||
/**
|
|
||||||
* vaxis/widget/list, edited to support wraparounds and number seeking
|
|
||||||
* soon to support confirmations, once i get around to that
|
|
||||||
*/
|
|
||||||
package ui
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"git.sr.ht/~rockorager/vaxis"
|
|
||||||
)
|
|
||||||
|
|
||||||
type List struct {
|
|
||||||
index int
|
|
||||||
items []string
|
|
||||||
offset int
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewList(items []string, index int) List {
|
|
||||||
return List{
|
|
||||||
items: items,
|
|
||||||
index: index,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) Draw(win vaxis.Window) {
|
|
||||||
_, height := win.Size()
|
|
||||||
if m.index >= m.offset+height {
|
|
||||||
m.offset = m.index - height + 1
|
|
||||||
} else if m.index < m.offset {
|
|
||||||
m.offset = m.index
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultStyle := vaxis.Style{}
|
|
||||||
selectedStyle := vaxis.Style{Attribute: vaxis.AttrReverse}
|
|
||||||
|
|
||||||
index := m.index - m.offset
|
|
||||||
for i, subject := range m.items[m.offset:] {
|
|
||||||
var style vaxis.Style
|
|
||||||
if i == index {
|
|
||||||
style = selectedStyle
|
|
||||||
} else {
|
|
||||||
style = defaultStyle
|
|
||||||
}
|
|
||||||
win.Println(i, vaxis.Segment{Text: fmt.Sprintf(" %-"+strconv.Itoa(win.Width-2)+"s", subject), Style: style})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) Down() {
|
|
||||||
if m.index == len(m.items)-1 {
|
|
||||||
m.index = 0
|
|
||||||
} else {
|
|
||||||
m.index++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) Up() {
|
|
||||||
if m.index == 0 {
|
|
||||||
m.index = len(m.items) - 1
|
|
||||||
} else {
|
|
||||||
m.index--
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) Home() {
|
|
||||||
m.index = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) End() {
|
|
||||||
m.index = len(m.items) - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) PageDown(win vaxis.Window) {
|
|
||||||
_, height := win.Size()
|
|
||||||
m.index = min(len(m.items)-1, m.index+height)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) PageUp(win vaxis.Window) {
|
|
||||||
_, height := win.Size()
|
|
||||||
m.index = max(0, m.index-height)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) Items() []string {
|
|
||||||
return m.items
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) SetItems(items []string) {
|
|
||||||
m.items = items
|
|
||||||
m.index = min(len(items)-1, m.index)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) SetItem(index int, item string) {
|
|
||||||
m.items[index] = item
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the index of the currently selected item.
|
|
||||||
func (m *List) Index() int {
|
|
||||||
return m.index
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *List) SetIndex(index int) {
|
|
||||||
m.index = index
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user