Add function wrappedText
This commit is contained in:
		
							parent
							
								
									593900c788
								
							
						
					
					
						commit
						357757e479
					
				
					 1 changed files with 17 additions and 0 deletions
				
			
		
							
								
								
									
										17
									
								
								Main.go
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								Main.go
									
										
									
									
									
								
							|  | @ -67,6 +67,23 @@ func centeredText(s string, x, y, width int, scr tcell.Screen, style tcell.Style | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| func wrappedText(s string, scr tcell.Screen, style tcell.Style) { | ||||
| 	x := 0 | ||||
| 	y := 0 | ||||
| 	w, h := scr.Size() | ||||
| 	for _, char := range s { | ||||
| 		if x >= w { | ||||
| 			if y >= h { | ||||
| 				break; | ||||
| 			} | ||||
| 			x = 0 | ||||
| 			y++ | ||||
| 		} | ||||
| 		scr.SetContent(x, y, char, nil, style) | ||||
| 		x++ | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func drawMonth(m time.Month, x, y int) { | ||||
| 	centeredText(months[m], x, y, monthWidth, wall, defStyle) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Petar Kapriš
						Petar Kapriš