mirror of
				https://github.com/troglobit/editline.git
				synced 2025-10-31 16:28:15 +08:00 
			
		
		
		
	Add support for el_no_hist to disable access to and auto-save of history.
This commit adds a new global variable 'el_no_hist' which can be used to disable auto-save of history as well as access to history using prev and next keybindings (up/down arrows). Signed-off-by: Mattias Walström <lazzer@gmail.com> Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
		 Mattias Walström
					Mattias Walström
				
			
				
					committed by
					
						 Joachim Nilsson
						Joachim Nilsson
					
				
			
			
				
	
			
			
			 Joachim Nilsson
						Joachim Nilsson
					
				
			
						parent
						
							f7432fbfbd
						
					
				
				
					commit
					7cd7fc4b61
				
			| @@ -72,7 +72,8 @@ extern char       *rl_line_buffer; | ||||
| extern const char *rl_readline_name; | ||||
| extern FILE       *rl_instream;  /* The stdio stream from which input is read. Defaults to stdin if NULL - Not supported yet! */ | ||||
| extern FILE       *rl_outstream; /* The stdio stream to which output is flushed. Defaults to stdout if NULL - Not supported yet! */ | ||||
| extern int         el_no_echo;   /* e.g under emacs, don't echo except prompt */ | ||||
| extern int         el_no_echo;   /* E.g under emacs, don't echo except prompt */ | ||||
| extern int         el_no_hist;   /* Disable auto-save of and access to history -- e.g. for password prompts or wizards */ | ||||
| extern int         el_hist_size; /* size of history scrollback buffer, default: 15 */ | ||||
|  | ||||
| extern void rl_initialize(void); | ||||
|   | ||||
| @@ -107,6 +107,7 @@ static int        tty_cols = SCREEN_COLS; | ||||
| static int        tty_rows = SCREEN_ROWS; | ||||
|  | ||||
| int               el_no_echo = 0; /* e.g., under Emacs */ | ||||
| int               el_no_hist = 0; | ||||
| int               rl_point; | ||||
| int               rl_mark; | ||||
| int               rl_end; | ||||
| @@ -547,11 +548,17 @@ static el_status_t do_hist(const char *(*move)(void)) | ||||
|  | ||||
| static el_status_t h_next(void) | ||||
| { | ||||
|     if (el_no_hist) | ||||
| 	return CSstay; | ||||
|  | ||||
|     return do_hist(next_hist); | ||||
| } | ||||
|  | ||||
| static el_status_t h_prev(void) | ||||
| { | ||||
|     if (el_no_hist) | ||||
| 	return CSstay; | ||||
|  | ||||
|     return do_hist(prev_hist); | ||||
| } | ||||
|  | ||||
| @@ -1210,8 +1217,8 @@ char *readline(const char *prompt) | ||||
|     free(Screen); | ||||
|     free(H.Lines[--H.Size]); | ||||
|  | ||||
|     /* Add to history, unless no-echo mode ... */ | ||||
|     if (!el_no_echo) { | ||||
|     /* Add to history, unless no-echo or no-history mode ... */ | ||||
|     if (!el_no_echo && !el_no_hist) { | ||||
| 	if (line != NULL && *line != '\0') | ||||
| 	    hist_add(line); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user