mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	move checked todos to bottom
This commit is contained in:
		
							parent
							
								
									b73c7aa21b
								
							
						
					
					
						commit
						30428ec3a4
					
				| @ -14,14 +14,28 @@ func (widget *Widget) display() { | ||||
| 	maxLen := widget.longestLineLen(widget.list.Items) | ||||
| 
 | ||||
| 	str := "" | ||||
| 	checked := []*Item{} | ||||
| 	uncheckedLen := 0 | ||||
| 	var selected *Item | ||||
| 	var newList List | ||||
| 	for idx, item := range widget.list.Items { | ||||
| 		foreColor, backColor := "white", "black" | ||||
| 
 | ||||
| 		if item.Checked { | ||||
| 			foreColor = Config.UString("wtf.mods.todo.colors.checked", "white") | ||||
| 		// save the selected one | ||||
| 		if idx == widget.list.selected { | ||||
| 			selected = item | ||||
| 		} | ||||
| 
 | ||||
| 		if widget.View.HasFocus() && idx == widget.list.selected { | ||||
| 		if item.Checked { | ||||
| 			checked = append(checked, item) | ||||
| 			continue | ||||
| 		} | ||||
| 
 | ||||
| 		uncheckedLen++ | ||||
| 
 | ||||
| 		if widget.View.HasFocus() && item == selected { | ||||
| 			// set selected item index | ||||
| 			newList.selected = idx | ||||
| 			foreColor = Config.UString("wtf.mods.todo.colors.highlight.fore", "black") | ||||
| 			backColor = Config.UString("wtf.mods.todo.colors.highlight.back", "white") | ||||
| 		} | ||||
| @ -35,7 +49,32 @@ func (widget *Widget) display() { | ||||
| 		) | ||||
| 
 | ||||
| 		str = str + wtf.PadRow((4+len(item.Text)), (4+maxLen)) + "\n" | ||||
| 
 | ||||
| 		newList.Items = append(newList.Items, item) | ||||
| 	} | ||||
| 	for idx, item := range checked { | ||||
| 		foreColor, backColor := Config.UString("wtf.mods.todo.colors.checked", "white"), "black" | ||||
| 
 | ||||
| 		if widget.View.HasFocus() && item == selected { | ||||
| 			newList.selected = idx + uncheckedLen | ||||
| 			foreColor = Config.UString("wtf.mods.todo.colors.highlight.fore", "black") | ||||
| 			backColor = Config.UString("wtf.mods.todo.colors.highlight.back", "white") | ||||
| 		} | ||||
| 		str = str + fmt.Sprintf( | ||||
| 			"[%s:%s]|%s| %s[white]", | ||||
| 			foreColor, | ||||
| 			backColor, | ||||
| 			item.CheckMark(), | ||||
| 			item.Text, | ||||
| 		) | ||||
| 
 | ||||
| 		str = str + wtf.PadRow((4+len(item.Text)), (4+maxLen)) + "\n" | ||||
| 
 | ||||
| 		newList.Items = append(newList.Items, item) | ||||
| 	} | ||||
| 
 | ||||
| 	// update list with new Items and selected item index | ||||
| 	widget.list = &newList | ||||
| 
 | ||||
| 	fmt.Fprintf(widget.View, "%s", str) | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user