✨ Add simple yes/no interface
This commit is contained in:
		
					parent
					
						
							
								2a19f3c8e9
							
						
					
				
			
			
				commit
				
					
						433f49e9e0
					
				
			
		
					 5 changed files with 75 additions and 6 deletions
				
			
		
							
								
								
									
										23
									
								
								input/boolean/boolean.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								input/boolean/boolean.go
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | |||
| package boolean | ||||
| 
 | ||||
| import "github.com/rivo/tview" | ||||
| 
 | ||||
| func Choose(title string) bool { | ||||
| 	choice := false | ||||
| 	app := tview.NewApplication() | ||||
| 	list := tview.NewList(). | ||||
| 		AddItem("Yes", "", 'y', func() { | ||||
| 			choice = true | ||||
| 			app.Stop() | ||||
| 		}). | ||||
| 		AddItem("No", "", 'n', func() { | ||||
| 			choice = false | ||||
| 			app.Stop() | ||||
| 		}) | ||||
| 	list.Box.SetBorder(true).SetTitle(title) | ||||
| 	if err := app.SetRoot(list, false).EnableMouse(true).Run(); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 
 | ||||
| 	return choice | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue