mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	Compare commits
	
		
			No commits in common. "c55bf4a73688990286d71ae2c692f5c8cbe6b17c" and "e364897b8801c3f3d13ccec0ab1c5c69a395976b" have entirely different histories.
		
	
	
		
			c55bf4a736
			...
			e364897b88
		
	
		
@ -70,11 +70,6 @@ set `hilbish.opts.motd` to false.
 | 
				
			|||||||
disables commands being added to history.
 | 
					disables commands being added to history.
 | 
				
			||||||
- `hilbish.rawInput` hook for input from the readline library
 | 
					- `hilbish.rawInput` hook for input from the readline library
 | 
				
			||||||
- Completion of files in quotes
 | 
					- Completion of files in quotes
 | 
				
			||||||
- A new and "safer" event emitter has been added. This causes a performance deficit, but avoids a lot of
 | 
					 | 
				
			||||||
random errors introduced with the new Lua runtime (see [#197])
 | 
					 | 
				
			||||||
- `bait.release(name, catcher)` removes `handler` for the named `event`
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[#197]: https://github.com/Rosettea/Hilbish/issues/197
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Changed
 | 
					### Changed
 | 
				
			||||||
- **Breaking Change:** Upgraded to Lua 5.4.
 | 
					- **Breaking Change:** Upgraded to Lua 5.4.
 | 
				
			||||||
 | 
				
			|||||||
@ -13,10 +13,8 @@ const (
 | 
				
			|||||||
	luaListener
 | 
						luaListener
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Recoverer is a function which is called when a panic occurs in an event.
 | 
					 | 
				
			||||||
type Recoverer func(event string, handler *Listener, err interface{})
 | 
					type Recoverer func(event string, handler *Listener, err interface{})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Listener is a struct that holds the handler for an event.
 | 
					 | 
				
			||||||
type Listener struct{
 | 
					type Listener struct{
 | 
				
			||||||
	typ listenerType
 | 
						typ listenerType
 | 
				
			||||||
	once bool
 | 
						once bool
 | 
				
			||||||
@ -31,7 +29,6 @@ type Bait struct{
 | 
				
			|||||||
	rtm *rt.Runtime
 | 
						rtm *rt.Runtime
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// New creates a new Bait instance.
 | 
					 | 
				
			||||||
func New(rtm *rt.Runtime) *Bait {
 | 
					func New(rtm *rt.Runtime) *Bait {
 | 
				
			||||||
	b := &Bait{
 | 
						b := &Bait{
 | 
				
			||||||
		handlers: make(map[string][]*Listener),
 | 
							handlers: make(map[string][]*Listener),
 | 
				
			||||||
@ -45,7 +42,6 @@ func New(rtm *rt.Runtime) *Bait {
 | 
				
			|||||||
	return b
 | 
						return b
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Emit throws an event.
 | 
					 | 
				
			||||||
func (b *Bait) Emit(event string, args ...interface{}) {
 | 
					func (b *Bait) Emit(event string, args ...interface{}) {
 | 
				
			||||||
	handles := b.handlers[event]
 | 
						handles := b.handlers[event]
 | 
				
			||||||
	if handles == nil {
 | 
						if handles == nil {
 | 
				
			||||||
@ -86,7 +82,6 @@ func (b *Bait) Emit(event string, args ...interface{}) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// On adds a Go function handler for an event.
 | 
					 | 
				
			||||||
func (b *Bait) On(event string, handler func(...interface{})) *Listener {
 | 
					func (b *Bait) On(event string, handler func(...interface{})) *Listener {
 | 
				
			||||||
	listener := &Listener{
 | 
						listener := &Listener{
 | 
				
			||||||
		typ: goListener,
 | 
							typ: goListener,
 | 
				
			||||||
@ -97,7 +92,6 @@ func (b *Bait) On(event string, handler func(...interface{})) *Listener {
 | 
				
			|||||||
	return listener
 | 
						return listener
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// OnLua adds a Lua function handler for an event.
 | 
					 | 
				
			||||||
func (b *Bait) OnLua(event string, handler *rt.Closure) *Listener {
 | 
					func (b *Bait) OnLua(event string, handler *rt.Closure) *Listener {
 | 
				
			||||||
	listener :=&Listener{
 | 
						listener :=&Listener{
 | 
				
			||||||
		typ: luaListener,
 | 
							typ: luaListener,
 | 
				
			||||||
@ -108,7 +102,6 @@ func (b *Bait) OnLua(event string, handler *rt.Closure) *Listener {
 | 
				
			|||||||
	return listener
 | 
						return listener
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Off removes a Go function handler for an event.
 | 
					 | 
				
			||||||
func (b *Bait) Off(event string, listener *Listener) {
 | 
					func (b *Bait) Off(event string, listener *Listener) {
 | 
				
			||||||
	handles := b.handlers[event]
 | 
						handles := b.handlers[event]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -119,7 +112,6 @@ func (b *Bait) Off(event string, listener *Listener) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// OffLua removes a Lua function handler for an event.
 | 
					 | 
				
			||||||
func (b *Bait) OffLua(event string, handler *rt.Closure) {
 | 
					func (b *Bait) OffLua(event string, handler *rt.Closure) {
 | 
				
			||||||
	handles := b.handlers[event]
 | 
						handles := b.handlers[event]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -130,7 +122,6 @@ func (b *Bait) OffLua(event string, handler *rt.Closure) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Once adds a Go function listener for an event that only runs once.
 | 
					 | 
				
			||||||
func (b *Bait) Once(event string, handler func(...interface{})) *Listener {
 | 
					func (b *Bait) Once(event string, handler func(...interface{})) *Listener {
 | 
				
			||||||
	listener := &Listener{
 | 
						listener := &Listener{
 | 
				
			||||||
		typ: goListener,
 | 
							typ: goListener,
 | 
				
			||||||
@ -142,7 +133,6 @@ func (b *Bait) Once(event string, handler func(...interface{})) *Listener {
 | 
				
			|||||||
	return listener
 | 
						return listener
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// OnceLua adds a Lua function listener for an event that only runs once.
 | 
					 | 
				
			||||||
func (b *Bait) OnceLua(event string, handler *rt.Closure) *Listener {
 | 
					func (b *Bait) OnceLua(event string, handler *rt.Closure) *Listener {
 | 
				
			||||||
	listener := &Listener{
 | 
						listener := &Listener{
 | 
				
			||||||
		typ: luaListener,
 | 
							typ: luaListener,
 | 
				
			||||||
@ -154,7 +144,6 @@ func (b *Bait) OnceLua(event string, handler *rt.Closure) *Listener {
 | 
				
			|||||||
	return listener
 | 
						return listener
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SetRecoverer sets the function to be executed when a panic occurs in an event.
 | 
					 | 
				
			||||||
func (b *Bait) SetRecoverer(recoverer Recoverer) {
 | 
					func (b *Bait) SetRecoverer(recoverer Recoverer) {
 | 
				
			||||||
	b.recoverer = recoverer
 | 
						b.recoverer = recoverer
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -275,10 +264,6 @@ func (b *Bait) bcatchOnce(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
 | 
				
			|||||||
	return c.Next(), nil
 | 
						return c.Next(), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// release(name, catcher)
 | 
					 | 
				
			||||||
// Removes the `catcher` for the event with `name`
 | 
					 | 
				
			||||||
// For this to work, `catcher` has to be the same function used to catch
 | 
					 | 
				
			||||||
// an event, like one saved to a variable.
 | 
					 | 
				
			||||||
func (b *Bait) brelease(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
 | 
					func (b *Bait) brelease(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
 | 
				
			||||||
	name, catcher, err := util.HandleStrCallback(t, c)
 | 
						name, catcher, err := util.HandleStrCallback(t, c)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user