mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Some code improvements
* Some assignments simplified by using assignment operators * Rewrite switch statement with only one case as if. * Rewrite if-else chain as a switch statement. * go fmt `modules/todoist/project.go` file.
This commit is contained in:
@@ -35,9 +35,9 @@ func (widget *Widget) display() {
|
||||
title = widget.buildTitle(cityData)
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
content = widget.settings.common.SigilStr(len(widget.Data), widget.Idx, width) + "\n"
|
||||
content = content + widget.description(cityData) + "\n\n"
|
||||
content = content + widget.temperatures(cityData) + "\n"
|
||||
content = content + widget.sunInfo(cityData)
|
||||
content += widget.description(cityData) + "\n\n"
|
||||
content += widget.temperatures(cityData) + "\n"
|
||||
content += widget.sunInfo(cityData)
|
||||
}
|
||||
|
||||
widget.Redraw(title, content, setWrap)
|
||||
@@ -63,7 +63,7 @@ func (widget *Widget) sunInfo(cityData *owm.CurrentWeatherData) string {
|
||||
func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string {
|
||||
str := fmt.Sprintf("%8s: %4.1f° %s\n", "High", cityData.Main.TempMax, widget.settings.tempUnit)
|
||||
|
||||
str = str + fmt.Sprintf(
|
||||
str += fmt.Sprintf(
|
||||
"%8s: [%s]%4.1f° %s[white]\n",
|
||||
"Current",
|
||||
widget.settings.colors.current,
|
||||
@@ -71,7 +71,7 @@ func (widget *Widget) temperatures(cityData *owm.CurrentWeatherData) string {
|
||||
widget.settings.tempUnit,
|
||||
)
|
||||
|
||||
str = str + fmt.Sprintf("%8s: %4.1f° %s\n", "Low", cityData.Main.TempMin, widget.settings.tempUnit)
|
||||
str += fmt.Sprintf("%8s: %4.1f° %s\n", "Low", cityData.Main.TempMin, widget.settings.tempUnit)
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (widget *Widget) Refresh() {
|
||||
// Next displays data for the next city data in the list. If the current city is the last
|
||||
// city, it wraps to the first city.
|
||||
func (widget *Widget) Next() {
|
||||
widget.Idx = widget.Idx + 1
|
||||
widget.Idx++
|
||||
if widget.Idx == len(widget.Data) {
|
||||
widget.Idx = 0
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func (widget *Widget) Next() {
|
||||
// Prev displays data for the previous city in the list. If the previous city is the first
|
||||
// city, it wraps to the last city.
|
||||
func (widget *Widget) Prev() {
|
||||
widget.Idx = widget.Idx - 1
|
||||
widget.Idx--
|
||||
if widget.Idx < 0 {
|
||||
widget.Idx = len(widget.Data) - 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user