mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	feat: add hilbish.cancel hook (closes #213)
This commit is contained in:
		
							parent
							
								
									ef3e7d92bc
								
							
						
					
					
						commit
						ff4609e432
					
				@ -76,6 +76,7 @@ disables commands being added to history.
 | 
				
			|||||||
random errors introduced with the new Lua runtime (see [#197])
 | 
					random errors introduced with the new Lua runtime (see [#197])
 | 
				
			||||||
- `bait.release(name, catcher)` removes `handler` for the named `event`
 | 
					- `bait.release(name, catcher)` removes `handler` for the named `event`
 | 
				
			||||||
- `exec`, `clear` and `cat` builtin commands
 | 
					- `exec`, `clear` and `cat` builtin commands
 | 
				
			||||||
 | 
					- `hilbish.cancel` hook
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[#197]: https://github.com/Rosettea/Hilbish/issues/197
 | 
					[#197]: https://github.com/Rosettea/Hilbish/issues/197
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -5,3 +5,5 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
+ `hilbish.vimAction` -> actionName, args > Sent when the user does a "vim action," being something
 | 
					+ `hilbish.vimAction` -> actionName, args > Sent when the user does a "vim action," being something
 | 
				
			||||||
like yanking or pasting text. See `doc vim-mode actions` for more info.
 | 
					like yanking or pasting text. See `doc vim-mode actions` for more info.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					+ `hilbish.cancel` > Sent when the user cancels their input with Ctrl-C.
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.go
									
									
									
									
									
								
							@ -181,11 +181,14 @@ input:
 | 
				
			|||||||
			break
 | 
								break
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			if err != readline.CtrlC {
 | 
								if err == readline.CtrlC {
 | 
				
			||||||
 | 
									fmt.Println("^C")
 | 
				
			||||||
 | 
									hooks.Emit("hilbish.cancel")
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
				// If we get a completely random error, print
 | 
									// If we get a completely random error, print
 | 
				
			||||||
				fmt.Fprintln(os.Stderr, err)
 | 
									fmt.Fprintln(os.Stderr, err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			fmt.Println("^C")
 | 
								// TODO: Halt if any other error occurs
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		var priv bool
 | 
							var priv bool
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user