mirror of
				https://github.com/taigrr/gopher-os
				synced 2025-01-18 04:43:13 -08:00 
			
		
		
		
	Revise console interface
This commit is contained in:
		
							parent
							
								
									425ad7319b
								
							
						
					
					
						commit
						b72725742a
					
				
							
								
								
									
										45
									
								
								src/gopheros/device/video/console/device.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/gopheros/device/video/console/device.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | |||||||
|  | package console | ||||||
|  | 
 | ||||||
|  | import "image/color" | ||||||
|  | 
 | ||||||
|  | // ScrollDir defines a scroll direction. | ||||||
|  | type ScrollDir uint8 | ||||||
|  | 
 | ||||||
|  | // The supported list of scroll directions for the console Scroll() calls. | ||||||
|  | const ( | ||||||
|  | 	Up ScrollDir = iota | ||||||
|  | 	Down | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | // The Device interface is implemented by objects that can function as system | ||||||
|  | // consoles. | ||||||
|  | type Device interface { | ||||||
|  | 	// Dimensions returns the width and height of the console in characters. | ||||||
|  | 	Dimensions() (uint16, uint16) | ||||||
|  | 
 | ||||||
|  | 	// DefaultColors returns the default foreground and background colors | ||||||
|  | 	// used by this console. | ||||||
|  | 	DefaultColors() (fg, bg uint8) | ||||||
|  | 
 | ||||||
|  | 	// Fill sets the contents of the specified rectangular region to the | ||||||
|  | 	// requested color. Both x and y coordinates are 1-based (top-left | ||||||
|  | 	// corner has coordinates 1,1). | ||||||
|  | 	Fill(x, y, width, height uint16, fg, bg uint8) | ||||||
|  | 
 | ||||||
|  | 	// Scroll the console contents to the specified direction. The caller | ||||||
|  | 	// is responsible for updating (e.g. clear or replace) the contents of | ||||||
|  | 	// the region that was scrolled. | ||||||
|  | 	Scroll(dir ScrollDir, lines uint16) | ||||||
|  | 
 | ||||||
|  | 	// Write a char to the specified location. Both x and y coordinates are | ||||||
|  | 	// 1-based (top-left corner has coordinates 1,1). | ||||||
|  | 	Write(ch byte, fg, bg uint8, x, y uint16) | ||||||
|  | 
 | ||||||
|  | 	// Palette returns the active color palette for this console. | ||||||
|  | 	Palette() color.Palette | ||||||
|  | 
 | ||||||
|  | 	// SetPaletteColor updates the color definition for the specified | ||||||
|  | 	// palette index. Passing a color index greated than the number of | ||||||
|  | 	// supported colors should be a no-op. | ||||||
|  | 	SetPaletteColor(uint8, color.RGBA) | ||||||
|  | } | ||||||
| @ -1,48 +0,0 @@ | |||||||
| package console |  | ||||||
| 
 |  | ||||||
| // Attr defines a color attribute. |  | ||||||
| type Attr uint16 |  | ||||||
| 
 |  | ||||||
| // The set of attributes that can be passed to Write(). |  | ||||||
| const ( |  | ||||||
| 	Black Attr = iota |  | ||||||
| 	Blue |  | ||||||
| 	Green |  | ||||||
| 	Cyan |  | ||||||
| 	Red |  | ||||||
| 	Magenta |  | ||||||
| 	Brown |  | ||||||
| 	LightGrey |  | ||||||
| 	Grey |  | ||||||
| 	LightBlue |  | ||||||
| 	LightGreen |  | ||||||
| 	LightCyan |  | ||||||
| 	LightRed |  | ||||||
| 	LightMagenta |  | ||||||
| 	LightBrown |  | ||||||
| 	White |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| // ScrollDir defines a scroll direction. |  | ||||||
| type ScrollDir uint8 |  | ||||||
| 
 |  | ||||||
| // The supported list of scroll directions for the console Scroll() calls. |  | ||||||
| const ( |  | ||||||
| 	Up ScrollDir = iota |  | ||||||
| 	Down |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| // The Console interface is implemented by objects that can function as physical consoles. |  | ||||||
| type Console interface { |  | ||||||
| 	// Dimensions returns the width and height of the console in characters. |  | ||||||
| 	Dimensions() (uint16, uint16) |  | ||||||
| 
 |  | ||||||
| 	// Clear clears the specified rectangular region |  | ||||||
| 	Clear(x, y, width, height uint16) |  | ||||||
| 
 |  | ||||||
| 	// Scroll a particular number of lines to the specified direction. |  | ||||||
| 	Scroll(dir ScrollDir, lines uint16) |  | ||||||
| 
 |  | ||||||
| 	// Write a char to the specified location. |  | ||||||
| 	Write(ch byte, attr Attr, x, y uint16) |  | ||||||
| } |  | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user