Made centering the buffer in the window optional
It causes jitter while resizing in floating wms
This commit is contained in:
		
							parent
							
								
									81a0c60943
								
							
						
					
					
						commit
						0ee58d22f6
					
				| @ -39,13 +39,18 @@ func (backend *Backend) handleConfigureNotify ( | |||||||
| 		width, height := backend.calculateBufferSize() | 		width, height := backend.calculateBufferSize() | ||||||
| 		backend.application.SetSize(width, height) | 		backend.application.SetSize(width, height) | ||||||
| 
 | 
 | ||||||
| 		// position buffer in the center of the screen | 		if backend.config.Center() { | ||||||
| 		frameWidth  := width  * backend.metrics.cellWidth | 			// position buffer in the center of the screen | ||||||
| 		frameHeight := height * backend.metrics.cellHeight | 			frameWidth  := width  * backend.metrics.cellWidth | ||||||
| 		backend.metrics.paddingX = | 			frameHeight := height * backend.metrics.cellHeight | ||||||
| 			(backend.metrics.windowWidth - frameWidth) / 2 | 			backend.metrics.paddingX = | ||||||
| 		backend.metrics.paddingY = | 				(backend.metrics.windowWidth - frameWidth) / 2 | ||||||
| 			(backend.metrics.windowHeight - frameHeight) / 2 | 			backend.metrics.paddingY = | ||||||
|  | 				(backend.metrics.windowHeight - frameHeight) / 2 | ||||||
|  | 		} else { | ||||||
|  | 			backend.metrics.paddingX = backend.metrics.padding | ||||||
|  | 			backend.metrics.paddingY = backend.metrics.padding | ||||||
|  | 		} | ||||||
| 
 | 
 | ||||||
| 		backend.windowBoundsClean = false | 		backend.windowBoundsClean = false | ||||||
| 	} | 	} | ||||||
|  | |||||||
							
								
								
									
										16
									
								
								config.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								config.go
									
									
									
									
									
								
							| @ -12,6 +12,7 @@ import "path/filepath" | |||||||
| type Config struct { | type Config struct { | ||||||
| 	colors   [8]color.Color | 	colors   [8]color.Color | ||||||
| 	padding  int | 	padding  int | ||||||
|  | 	center   bool | ||||||
| 	fontSize int | 	fontSize int | ||||||
| 	fontName string | 	fontName string | ||||||
| } | } | ||||||
| @ -29,6 +30,13 @@ func (config *Config) Padding () (padding int) { | |||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Center returns whether the buffer should be displayed in the center of the | ||||||
|  | // window like in kitty, or aligned to one corner like in gnome-terminal. | ||||||
|  | func (config *Config) Center () (center bool) { | ||||||
|  | 	center = config.center | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // FontSize specifies how big the font should be. | // FontSize specifies how big the font should be. | ||||||
| func (config *Config) FontSize () (fontSize int) { | func (config *Config) FontSize () (fontSize int) { | ||||||
| 	fontSize = config.fontSize | 	fontSize = config.fontSize | ||||||
| @ -98,8 +106,14 @@ func (config *Config) loadFile (path string) { | |||||||
| 		} | 		} | ||||||
| 		key   = strings.TrimSpace(key) | 		key   = strings.TrimSpace(key) | ||||||
| 		value = strings.TrimSpace(value) | 		value = strings.TrimSpace(value) | ||||||
|  | 
 | ||||||
| 		var valueInt int | 		var valueInt int | ||||||
| 		var valueColor color.Color | 		var valueColor color.Color | ||||||
|  | 		var valueBoolean bool | ||||||
|  | 		 | ||||||
|  | 		if value == "true" { | ||||||
|  | 			valueBoolean = true | ||||||
|  | 		} | ||||||
| 
 | 
 | ||||||
| 		if value[0] == '#' { | 		if value[0] == '#' { | ||||||
| 			if len(value) != 7  { | 			if len(value) != 7  { | ||||||
| @ -134,6 +148,8 @@ func (config *Config) loadFile (path string) { | |||||||
| 			config.fontSize = valueInt | 			config.fontSize = valueInt | ||||||
| 		case "padding": | 		case "padding": | ||||||
| 			config.padding = valueInt | 			config.padding = valueInt | ||||||
|  | 		case "center": | ||||||
|  | 			config.center = valueBoolean | ||||||
| 		case "colorBackground": | 		case "colorBackground": | ||||||
| 			config.colors[ColorBackground] = valueColor | 			config.colors[ColorBackground] = valueColor | ||||||
| 		case "colorForeground": | 		case "colorForeground": | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user