redo-event-system #1
@ -18,13 +18,13 @@ func (application *Application) SetTitle (title string) {
 | 
				
			|||||||
	application.backend.SetTitle(title)
 | 
						application.backend.SetTitle(title)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Run initializes the application, and then calls callback. Operations inside
 | 
					// Run initializes the application, starts it, and then returns a channel that
 | 
				
			||||||
// of callback are allowed to interact with the application. Depending on the
 | 
					// broadcasts events. If no suitable backend can be found, an error is returned.
 | 
				
			||||||
// backend used, this function may bind to the main thread.
 | 
					 | 
				
			||||||
func (application *Application) Run (
 | 
					func (application *Application) Run (
 | 
				
			||||||
	callback func (application *Application),
 | 
						callback func (application *Application),
 | 
				
			||||||
) (
 | 
					) (
 | 
				
			||||||
	err error,
 | 
						channel chan(Event),
 | 
				
			||||||
 | 
						err     error,
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
	// default values for certain parameters
 | 
						// default values for certain parameters
 | 
				
			||||||
	width, height := application.Size()
 | 
						width, height := application.Size()
 | 
				
			||||||
@ -44,7 +44,7 @@ func (application *Application) Run (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	application.backend, err = instantiateBackend(application)
 | 
						application.backend, err = instantiateBackend(application)
 | 
				
			||||||
	if err != nil { return }
 | 
						if err != nil { return }
 | 
				
			||||||
	application.backend.Run(callback)
 | 
						channel = application.backend.Run()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,11 +1,10 @@
 | 
				
			|||||||
package stone
 | 
					package stone
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "time"
 | 
					 | 
				
			||||||
import "image"
 | 
					import "image"
 | 
				
			||||||
import "errors"
 | 
					import "errors"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Backend interface {
 | 
					type Backend interface {
 | 
				
			||||||
	Run      () (chan(Event))
 | 
						Run      () (channel chan(Event))
 | 
				
			||||||
	SetTitle (title string)
 | 
						SetTitle (title string)
 | 
				
			||||||
	SetIcon  (icons []image.Image)
 | 
						SetIcon  (icons []image.Image)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								event.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								event.go
									
									
									
									
									
								
							@ -1,7 +1,8 @@
 | 
				
			|||||||
package application
 | 
					package stone
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Event interface { }
 | 
					type Event interface { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type EventQuit      struct { }
 | 
				
			||||||
type EventPress     Button
 | 
					type EventPress     Button
 | 
				
			||||||
type EventRelease   Button
 | 
					type EventRelease   Button
 | 
				
			||||||
type EventResize    struct { }
 | 
					type EventResize    struct { }
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@ package main
 | 
				
			|||||||
import "fmt"
 | 
					import "fmt"
 | 
				
			||||||
import "time"
 | 
					import "time"
 | 
				
			||||||
import "git.tebibyte.media/sashakoshka/stone"
 | 
					import "git.tebibyte.media/sashakoshka/stone"
 | 
				
			||||||
import _ "git.tebibyte.media/sashakoshka/stone/backends/pixel"
 | 
					// import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func main () {
 | 
					func main () {
 | 
				
			||||||
	application := stone.Application { }
 | 
						application := stone.Application { }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user