degesch: stub word completion
This commit is contained in:
		
							parent
							
								
									99526126e4
								
							
						
					
					
						commit
						06ec2a1388
					
				
							
								
								
									
										34
									
								
								degesch.c
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								degesch.c
									
									
									
									
									
								
							| @ -215,6 +215,7 @@ input_erase (struct input *self) | ||||
| 
 | ||||
| static int app_readline_init (void); | ||||
| static void on_readline_input (char *line); | ||||
| static char **app_readline_completion (const char *text, int start, int end); | ||||
| 
 | ||||
| static void | ||||
| input_start (struct input *self, const char *program_name) | ||||
| @ -225,9 +226,11 @@ input_start (struct input *self, const char *program_name) | ||||
| 	// This can cause memory leaks, or maybe even a segfault.  Funny, eh?
 | ||||
| 	stifle_history (HISTORY_LIMIT); | ||||
| 
 | ||||
| 	rl_readline_name = PROGRAM_NAME; | ||||
| 	rl_startup_hook = app_readline_init; | ||||
| 	rl_catch_sigwinch = false; | ||||
| 	rl_callback_handler_install (self->prompt, on_readline_input); | ||||
| 	rl_attempted_completion_function = app_readline_completion; | ||||
| 	self->prompt_shown = 1; | ||||
| 	self->active = true; | ||||
| } | ||||
| @ -5113,6 +5116,18 @@ app_readline_bind_meta (char key, rl_command_func_t cb) | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| static char ** | ||||
| app_readline_completion (const char *text, int start, int end) | ||||
| { | ||||
| 	(void) text; | ||||
| 	(void) start; | ||||
| 	(void) end; | ||||
| 
 | ||||
| 	// Don't iterate over filenames and stuff
 | ||||
| 	rl_attempted_completion_over = true; | ||||
| 	return NULL; | ||||
| } | ||||
| 
 | ||||
| static int | ||||
| app_readline_init (void) | ||||
| { | ||||
| @ -5134,6 +5149,12 @@ app_readline_init (void) | ||||
| 
 | ||||
| 	// We need to hide the prompt first
 | ||||
| 	rl_bind_key (RETURN, on_readline_return); | ||||
| 
 | ||||
| 	// Completion
 | ||||
| 	rl_variable_bind ("completion-ignore-case", "on"); | ||||
| 	rl_bind_key (TAB, rl_named_function ("menu-complete")); | ||||
| 	if (key_btab) | ||||
| 		rl_bind_keyseq (key_btab, rl_named_function ("menu-complete-backward")); | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| @ -5187,6 +5208,15 @@ on_editline_next_buffer (EditLine *editline, int key) | ||||
| 	return CC_NORM; | ||||
| } | ||||
| 
 | ||||
| static unsigned char | ||||
| on_editline_complete (EditLine *editline, int key) | ||||
| { | ||||
| 	(void) key; | ||||
| 	(void) editline; | ||||
| 
 | ||||
| 	return CC_ERROR; | ||||
| } | ||||
| 
 | ||||
| static unsigned char | ||||
| on_editline_return (EditLine *editline, int key) | ||||
| { | ||||
| @ -5252,6 +5282,10 @@ app_editline_init (struct input *self) | ||||
| 	el_set (self->editline, EL_ADDFN, "send-line", | ||||
| 		"Send line", on_editline_return); | ||||
| 	el_set (self->editline, EL_BIND, "\n", "send-line", NULL); | ||||
| 
 | ||||
| 	el_set (self->editline, EL_ADDFN, "complete", | ||||
| 		"Complete word", on_editline_complete); | ||||
| 	el_set (self->editline, EL_BIND, "^I", "complete", NULL); | ||||
| } | ||||
| 
 | ||||
| #endif // HAVE_EDITLINE
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user