1 /* GNU Mailutils -- a suite of utilities for electronic mail 2 Copyright (C) 2010-2021 Free Software Foundation, Inc. 3 4 GNU Mailutils is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 3, or (at your option) 7 any later version. 8 9 GNU Mailutils is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ 16 17 /* MH prompter - readline support */ 18 19 #include <mh.h> 20 #include "prompter.h" 21 #include <readline/readline.h> 22 23 void prompter_init()24prompter_init () 25 { 26 } 27 28 void prompter_done()29prompter_done () 30 { 31 } 32 33 void prompter_set_erase(const char * keyseq)34prompter_set_erase (const char *keyseq) 35 { 36 rl_bind_keyseq (keyseq, rl_delete); 37 } 38 39 void prompter_set_kill(const char * keyseq)40prompter_set_kill (const char *keyseq) 41 { 42 rl_bind_keyseq (keyseq, rl_kill_full_line); 43 } 44 45 char * prompter_get_value(const char * name)46prompter_get_value (const char *name) 47 { 48 char *prompt = NULL; 49 char *val; 50 51 if (name) 52 { 53 prompt = mu_alloc (strlen (name) + 3); 54 strcpy (prompt, name); 55 strcat (prompt, ": "); 56 } 57 val = readline (prompt); 58 free (prompt); 59 return val; 60 } 61 62 char * prompter_get_line()63prompter_get_line () 64 { 65 return doteof_filter (readline (NULL)); 66 } 67 68 69