aboutsummaryrefslogtreecommitdiff
path: root/lib/libedit/prompt.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-01-09 07:40:56 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-01-09 07:40:56 +0000
commitc1a66a97f95d2f4366348b75e2c7676d11048666 (patch)
treed33ef1b987208879e7fa795c6b8d9fb885b151a9 /lib/libedit/prompt.c
parentec680ff8a8ad7b7018eaf69ad934178e6464e61e (diff)
downloadsrc-c1a66a97f95d2f4366348b75e2c7676d11048666.tar.gz
src-c1a66a97f95d2f4366348b75e2c7676d11048666.zip
Notes
Diffstat (limited to 'lib/libedit/prompt.c')
-rw-r--r--lib/libedit/prompt.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/lib/libedit/prompt.c b/lib/libedit/prompt.c
index 2d37b67154d0..3696d0c2c440 100644
--- a/lib/libedit/prompt.c
+++ b/lib/libedit/prompt.c
@@ -1,3 +1,5 @@
+/* $NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $ */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -28,12 +30,15 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $NetBSD: prompt.c,v 1.14 2009/03/31 17:38:27 christos Exp $
*/
+#include "config.h"
#if !defined(lint) && !defined(SCCSID)
+#if 0
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $");
+#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -41,50 +46,46 @@ __FBSDID("$FreeBSD$");
/*
* prompt.c: Prompt printing functions
*/
-#include "sys.h"
#include <stdio.h>
#include "el.h"
-private char *prompt_default(EditLine *);
-private char *prompt_default_r(EditLine *);
+private Char *prompt_default(EditLine *);
+private Char *prompt_default_r(EditLine *);
/* prompt_default():
* Just a default prompt, in case the user did not provide one
*/
-private char *
+private Char *
/*ARGSUSED*/
-prompt_default(EditLine *el __unused)
+prompt_default(EditLine *el __attribute__((__unused__)))
{
- static char a[3] = {'?', ' ', '\0'};
+ static Char a[3] = {'?', ' ', '\0'};
- return (a);
+ return a;
}
/* prompt_default_r():
* Just a default rprompt, in case the user did not provide one
*/
-private char *
+private Char *
/*ARGSUSED*/
-prompt_default_r(EditLine *el __unused)
+prompt_default_r(EditLine *el __attribute__((__unused__)))
{
- static char a[1] = {'\0'};
+ static Char a[1] = {'\0'};
- return (a);
+ return a;
}
/* prompt_print():
* Print the prompt and update the prompt position.
- * We use an array of integers in case we want to pass
- * literal escape sequences in the prompt and we want a
- * bit to flag them
*/
protected void
prompt_print(EditLine *el, int op)
{
el_prompt_t *elp;
- char *p;
+ Char *p;
int ignore = 0;
if (op == EL_PROMPT)
@@ -92,13 +93,19 @@ prompt_print(EditLine *el, int op)
else
elp = &el->el_rprompt;
- for (p = (*elp->p_func)(el); *p; p++) {
+ if (elp->p_wide)
+ p = (*elp->p_func)(el);
+ else
+ p = ct_decode_string((char *)(void *)(*elp->p_func)(el),
+ &el->el_scratch);
+
+ for (; *p; p++) {
if (elp->p_ignore == *p) {
ignore = !ignore;
continue;
}
if (ignore)
- term__putc(el, *p);
+ terminal__putc(el, *p);
else
re_putc(el, *p, 1);
}
@@ -132,7 +139,7 @@ prompt_init(EditLine *el)
*/
protected void
/*ARGSUSED*/
-prompt_end(EditLine *el __unused)
+prompt_end(EditLine *el __attribute__((__unused__)))
{
}
@@ -141,7 +148,7 @@ prompt_end(EditLine *el __unused)
* Install a prompt printing function
*/
protected int
-prompt_set(EditLine *el, el_pfunc_t prf, char c, int op)
+prompt_set(EditLine *el, el_pfunc_t prf, Char c, int op, int wide)
{
el_prompt_t *p;
@@ -155,13 +162,15 @@ prompt_set(EditLine *el, el_pfunc_t prf, char c, int op)
p->p_func = prompt_default;
else
p->p_func = prompt_default_r;
- } else
+ } else {
p->p_func = prf;
+ }
p->p_ignore = c;
p->p_pos.v = 0;
p->p_pos.h = 0;
+ p->p_wide = wide;
return 0;
}
@@ -171,7 +180,7 @@ prompt_set(EditLine *el, el_pfunc_t prf, char c, int op)
* Retrieve the prompt printing function
*/
protected int
-prompt_get(EditLine *el, el_pfunc_t *prf, char *c, int op)
+prompt_get(EditLine *el, el_pfunc_t *prf, Char *c, int op)
{
el_prompt_t *p;
@@ -183,8 +192,8 @@ prompt_get(EditLine *el, el_pfunc_t *prf, char *c, int op)
else
p = &el->el_rprompt;
- *prf = el->el_rprompt.p_func;
-
+ if (prf)
+ *prf = p->p_func;
if (c)
*c = p->p_ignore;