2024-05-17 05:59:08 +03:00
|
|
|
/* $NetBSD: eln.c,v 1.38 2024/05/17 02:59:08 christos Exp $ */
|
2009-12-31 01:37:40 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT 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.
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#if !defined(lint) && !defined(SCCSID)
|
2024-05-17 05:59:08 +03:00
|
|
|
__RCSID("$NetBSD: eln.c,v 1.38 2024/05/17 02:59:08 christos Exp $");
|
2009-12-31 01:37:40 +03:00
|
|
|
#endif /* not lint && not SCCSID */
|
|
|
|
|
From Ingo Schwarze:
el_getc() for the WIDECHAR case, that is, the version in eln.c.
For a UTF-8 locale, it is broken in four ways:
1. If the character read is outside the ASCII range, the function
does an undefined cast from wchar_t to char. Even if wchar_t
is internally represented as UCS-4, that is wrong and dangerous
because characters beyond codepoint U+0255 get their high bits
truncated, meaning that perfectly valid printable Unicode
characters get mapped to arbitrary bytes, even the ASCII escape
character for some Unicode characters. But wchar_t need not
be implemented in terms of UCS-4, so the outcome of this function
is undefined for any and all input.
2. If insufficient space is available for the result, the function
fails to detect failure and returns garbage rather than -1 as
specified in the documentation.
3. The documentation says that errno will be set on failure, but
that doesn't happen either in the above case.
4. Even for ASCII characters, the results may be wrong if wchar_t
is not using UCS-4.
2016-02-14 20:06:24 +03:00
|
|
|
#include <errno.h>
|
2009-12-31 01:37:40 +03:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
2009-12-31 02:54:52 +03:00
|
|
|
#include <stdlib.h>
|
2009-12-31 01:37:40 +03:00
|
|
|
|
2016-02-16 18:53:48 +03:00
|
|
|
#include "el.h"
|
|
|
|
|
2016-04-11 21:56:31 +03:00
|
|
|
int
|
2009-12-31 01:37:40 +03:00
|
|
|
el_getc(EditLine *el, char *cp)
|
|
|
|
{
|
|
|
|
int num_read;
|
|
|
|
wchar_t wc = 0;
|
|
|
|
|
From Ingo Schwarze:
el_getc() for the WIDECHAR case, that is, the version in eln.c.
For a UTF-8 locale, it is broken in four ways:
1. If the character read is outside the ASCII range, the function
does an undefined cast from wchar_t to char. Even if wchar_t
is internally represented as UCS-4, that is wrong and dangerous
because characters beyond codepoint U+0255 get their high bits
truncated, meaning that perfectly valid printable Unicode
characters get mapped to arbitrary bytes, even the ASCII escape
character for some Unicode characters. But wchar_t need not
be implemented in terms of UCS-4, so the outcome of this function
is undefined for any and all input.
2. If insufficient space is available for the result, the function
fails to detect failure and returns garbage rather than -1 as
specified in the documentation.
3. The documentation says that errno will be set on failure, but
that doesn't happen either in the above case.
4. Even for ASCII characters, the results may be wrong if wchar_t
is not using UCS-4.
2016-02-14 20:06:24 +03:00
|
|
|
num_read = el_wgetc(el, &wc);
|
|
|
|
*cp = '\0';
|
|
|
|
if (num_read <= 0)
|
|
|
|
return num_read;
|
2016-04-09 21:43:17 +03:00
|
|
|
num_read = wctob(wc);
|
From Ingo Schwarze:
el_getc() for the WIDECHAR case, that is, the version in eln.c.
For a UTF-8 locale, it is broken in four ways:
1. If the character read is outside the ASCII range, the function
does an undefined cast from wchar_t to char. Even if wchar_t
is internally represented as UCS-4, that is wrong and dangerous
because characters beyond codepoint U+0255 get their high bits
truncated, meaning that perfectly valid printable Unicode
characters get mapped to arbitrary bytes, even the ASCII escape
character for some Unicode characters. But wchar_t need not
be implemented in terms of UCS-4, so the outcome of this function
is undefined for any and all input.
2. If insufficient space is available for the result, the function
fails to detect failure and returns garbage rather than -1 as
specified in the documentation.
3. The documentation says that errno will be set on failure, but
that doesn't happen either in the above case.
4. Even for ASCII characters, the results may be wrong if wchar_t
is not using UCS-4.
2016-02-14 20:06:24 +03:00
|
|
|
if (num_read == EOF) {
|
|
|
|
errno = ERANGE;
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
*cp = (char)num_read;
|
|
|
|
return 1;
|
|
|
|
}
|
2009-12-31 01:37:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-11 21:56:31 +03:00
|
|
|
void
|
2009-12-31 01:37:40 +03:00
|
|
|
el_push(EditLine *el, const char *str)
|
|
|
|
{
|
|
|
|
/* Using multibyte->wide string decoding works fine under single-byte
|
|
|
|
* character sets too, and Does The Right Thing. */
|
|
|
|
el_wpush(el, ct_decode_string(str, &el->el_lgcyconv));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-11 21:56:31 +03:00
|
|
|
const char *
|
2009-12-31 01:37:40 +03:00
|
|
|
el_gets(EditLine *el, int *nread)
|
|
|
|
{
|
2010-01-20 04:15:52 +03:00
|
|
|
const wchar_t *tmp;
|
|
|
|
|
|
|
|
tmp = el_wgets(el, nread);
|
2015-05-18 18:07:04 +03:00
|
|
|
if (tmp != NULL) {
|
2016-02-12 20:23:21 +03:00
|
|
|
int i;
|
2015-05-18 18:07:04 +03:00
|
|
|
size_t nwread = 0;
|
2016-02-12 20:23:21 +03:00
|
|
|
|
|
|
|
for (i = 0; i < *nread; i++)
|
2015-05-18 18:07:04 +03:00
|
|
|
nwread += ct_enc_width(tmp[i]);
|
|
|
|
*nread = (int)nwread;
|
|
|
|
}
|
2010-01-20 04:15:52 +03:00
|
|
|
return ct_encode_string(tmp, &el->el_lgcyconv);
|
2009-12-31 01:37:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-11 21:56:31 +03:00
|
|
|
int
|
2009-12-31 01:37:40 +03:00
|
|
|
el_parse(EditLine *el, int argc, const char *argv[])
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
const wchar_t **wargv;
|
|
|
|
|
2016-05-10 00:37:34 +03:00
|
|
|
wargv = (void *)ct_decode_argv(argc, argv, &el->el_lgcyconv);
|
2009-12-31 01:37:40 +03:00
|
|
|
if (!wargv)
|
|
|
|
return -1;
|
|
|
|
ret = el_wparse(el, argc, wargv);
|
2016-04-09 21:43:17 +03:00
|
|
|
el_free(wargv);
|
2009-12-31 01:37:40 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-11 21:56:31 +03:00
|
|
|
int
|
2009-12-31 01:37:40 +03:00
|
|
|
el_set(EditLine *el, int op, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!el)
|
|
|
|
return -1;
|
|
|
|
va_start(ap, op);
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case EL_PROMPT: /* el_pfunc_t */
|
|
|
|
case EL_RPROMPT: {
|
|
|
|
el_pfunc_t p = va_arg(ap, el_pfunc_t);
|
|
|
|
ret = prompt_set(el, p, 0, op, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-08-28 19:44:59 +04:00
|
|
|
case EL_RESIZE: {
|
|
|
|
el_zfunc_t p = va_arg(ap, el_zfunc_t);
|
|
|
|
void *arg = va_arg(ap, void *);
|
|
|
|
ret = ch_resizefun(el, p, arg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-06-18 22:12:28 +04:00
|
|
|
case EL_ALIAS_TEXT: {
|
|
|
|
el_afunc_t p = va_arg(ap, el_afunc_t);
|
|
|
|
void *arg = va_arg(ap, void *);
|
|
|
|
ret = ch_aliasfun(el, p, arg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-26 17:50:29 +04:00
|
|
|
case EL_PROMPT_ESC:
|
|
|
|
case EL_RPROMPT_ESC: {
|
|
|
|
el_pfunc_t p = va_arg(ap, el_pfunc_t);
|
|
|
|
int c = va_arg(ap, int);
|
|
|
|
|
|
|
|
ret = prompt_set(el, p, c, op, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
case EL_TERMINAL: /* const char * */
|
|
|
|
ret = el_wset(el, op, va_arg(ap, char *));
|
|
|
|
break;
|
|
|
|
|
2010-01-20 01:38:08 +03:00
|
|
|
case EL_EDITOR: /* const wchar_t * */
|
|
|
|
ret = el_wset(el, op, ct_decode_string(va_arg(ap, char *),
|
|
|
|
&el->el_lgcyconv));
|
|
|
|
break;
|
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
case EL_SIGNAL: /* int */
|
|
|
|
case EL_EDITMODE:
|
2021-08-15 13:08:41 +03:00
|
|
|
case EL_SAFEREAD:
|
2009-12-31 01:37:40 +03:00
|
|
|
case EL_UNBUFFERED:
|
|
|
|
case EL_PREP_TERM:
|
|
|
|
ret = el_wset(el, op, va_arg(ap, int));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EL_BIND: /* const char * list -> const wchar_t * list */
|
|
|
|
case EL_TELLTC:
|
|
|
|
case EL_SETTC:
|
|
|
|
case EL_ECHOTC:
|
|
|
|
case EL_SETTY: {
|
|
|
|
const char *argv[20];
|
|
|
|
int i;
|
|
|
|
const wchar_t **wargv;
|
2014-05-20 19:05:08 +04:00
|
|
|
for (i = 1; i < (int)__arraycount(argv) - 1; ++i)
|
|
|
|
if ((argv[i] = va_arg(ap, const char *)) == NULL)
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
2014-05-20 19:05:08 +04:00
|
|
|
argv[0] = argv[i] = NULL;
|
2016-05-10 00:37:34 +03:00
|
|
|
wargv = (void *)ct_decode_argv(i + 1, argv, &el->el_lgcyconv);
|
2009-12-31 01:37:40 +03:00
|
|
|
if (!wargv) {
|
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* AFAIK we can't portably pass through our new wargv to
|
|
|
|
* el_wset(), so we have to reimplement the body of
|
|
|
|
* el_wset() for these ops.
|
|
|
|
*/
|
|
|
|
switch (op) {
|
|
|
|
case EL_BIND:
|
2016-04-11 03:22:48 +03:00
|
|
|
wargv[0] = L"bind";
|
2009-12-31 01:37:40 +03:00
|
|
|
ret = map_bind(el, i, wargv);
|
|
|
|
break;
|
|
|
|
case EL_TELLTC:
|
2016-04-11 03:22:48 +03:00
|
|
|
wargv[0] = L"telltc";
|
2011-07-28 05:05:20 +04:00
|
|
|
ret = terminal_telltc(el, i, wargv);
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
|
|
|
case EL_SETTC:
|
2016-04-11 03:22:48 +03:00
|
|
|
wargv[0] = L"settc";
|
2011-07-28 05:05:20 +04:00
|
|
|
ret = terminal_settc(el, i, wargv);
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
|
|
|
case EL_ECHOTC:
|
2016-04-11 03:22:48 +03:00
|
|
|
wargv[0] = L"echotc";
|
2011-07-28 05:05:20 +04:00
|
|
|
ret = terminal_echotc(el, i, wargv);
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
|
|
|
case EL_SETTY:
|
2016-04-11 03:22:48 +03:00
|
|
|
wargv[0] = L"setty";
|
2009-12-31 01:37:40 +03:00
|
|
|
ret = tty_stty(el, i, wargv);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -1;
|
|
|
|
}
|
2016-04-09 21:43:17 +03:00
|
|
|
el_free(wargv);
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: do we need to change el_func_t too? */
|
|
|
|
case EL_ADDFN: { /* const char *, const char *, el_func_t */
|
|
|
|
const char *args[2];
|
|
|
|
el_func_t func;
|
|
|
|
wchar_t **wargv;
|
|
|
|
|
|
|
|
args[0] = va_arg(ap, const char *);
|
|
|
|
args[1] = va_arg(ap, const char *);
|
|
|
|
func = va_arg(ap, el_func_t);
|
|
|
|
|
|
|
|
wargv = ct_decode_argv(2, args, &el->el_lgcyconv);
|
|
|
|
if (!wargv) {
|
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
2016-02-16 00:56:35 +03:00
|
|
|
/* XXX: The two strdup's leak */
|
2016-04-11 03:22:48 +03:00
|
|
|
ret = map_addfunc(el, wcsdup(wargv[0]), wcsdup(wargv[1]),
|
2010-01-12 22:40:50 +03:00
|
|
|
func);
|
2016-04-09 21:43:17 +03:00
|
|
|
el_free(wargv);
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EL_HIST: { /* hist_fun_t, const char * */
|
|
|
|
hist_fun_t fun = va_arg(ap, hist_fun_t);
|
2011-07-29 00:50:55 +04:00
|
|
|
void *ptr = va_arg(ap, void *);
|
2009-12-31 02:54:52 +03:00
|
|
|
ret = hist_set(el, fun, ptr);
|
2010-11-04 16:53:12 +03:00
|
|
|
el->el_flags |= NARROW_HISTORY;
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
|
|
|
}
|
2014-02-26 17:50:29 +04:00
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
case EL_GETCFN: /* el_rfunc_t */
|
|
|
|
ret = el_wset(el, op, va_arg(ap, el_rfunc_t));
|
|
|
|
break;
|
2014-02-26 17:50:29 +04:00
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
case EL_CLIENTDATA: /* void * */
|
|
|
|
ret = el_wset(el, op, va_arg(ap, void *));
|
|
|
|
break;
|
2014-02-26 17:50:29 +04:00
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
case EL_SETFP: { /* int, FILE * */
|
|
|
|
int what = va_arg(ap, int);
|
|
|
|
FILE *fp = va_arg(ap, FILE *);
|
|
|
|
ret = el_wset(el, op, what, fp);
|
|
|
|
break;
|
|
|
|
}
|
2014-02-26 17:50:29 +04:00
|
|
|
|
|
|
|
case EL_REFRESH:
|
|
|
|
re_clear_display(el);
|
|
|
|
re_refresh(el);
|
|
|
|
terminal__flush(el);
|
|
|
|
ret = 0;
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
2014-02-26 17:50:29 +04:00
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
default:
|
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
va_end(ap);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-11 21:56:31 +03:00
|
|
|
int
|
2009-12-31 01:37:40 +03:00
|
|
|
el_get(EditLine *el, int op, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!el)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
va_start(ap, op);
|
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case EL_PROMPT: /* el_pfunc_t * */
|
|
|
|
case EL_RPROMPT: {
|
|
|
|
el_pfunc_t *p = va_arg(ap, el_pfunc_t *);
|
2009-12-31 02:54:52 +03:00
|
|
|
ret = prompt_get(el, p, 0, op);
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case EL_PROMPT_ESC: /* el_pfunc_t *, char **/
|
|
|
|
case EL_RPROMPT_ESC: {
|
|
|
|
el_pfunc_t *p = va_arg(ap, el_pfunc_t *);
|
|
|
|
char *c = va_arg(ap, char *);
|
2011-06-20 13:11:16 +04:00
|
|
|
wchar_t wc = 0;
|
2009-12-31 02:54:52 +03:00
|
|
|
ret = prompt_get(el, p, &wc, op);
|
2011-08-16 20:25:15 +04:00
|
|
|
*c = (char)wc;
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case EL_EDITOR: {
|
|
|
|
const char **p = va_arg(ap, const char **);
|
|
|
|
const wchar_t *pw;
|
|
|
|
ret = el_wget(el, op, &pw);
|
|
|
|
*p = ct_encode_string(pw, &el->el_lgcyconv);
|
|
|
|
if (!el->el_lgcyconv.csize)
|
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case EL_TERMINAL: /* const char ** */
|
|
|
|
ret = el_wget(el, op, va_arg(ap, const char **));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EL_SIGNAL: /* int * */
|
|
|
|
case EL_EDITMODE:
|
2021-08-15 13:08:41 +03:00
|
|
|
case EL_SAFEREAD:
|
2009-12-31 01:37:40 +03:00
|
|
|
case EL_UNBUFFERED:
|
|
|
|
case EL_PREP_TERM:
|
|
|
|
ret = el_wget(el, op, va_arg(ap, int *));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EL_GETTC: {
|
2019-04-26 19:56:57 +03:00
|
|
|
char *argv[3];
|
2009-12-31 01:37:40 +03:00
|
|
|
static char gettc[] = "gettc";
|
|
|
|
argv[0] = gettc;
|
2019-04-26 19:56:57 +03:00
|
|
|
argv[1] = va_arg(ap, char *);
|
|
|
|
argv[2] = va_arg(ap, void *);
|
|
|
|
ret = terminal_gettc(el, 3, argv);
|
2009-12-31 01:37:40 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case EL_GETCFN: /* el_rfunc_t */
|
|
|
|
ret = el_wget(el, op, va_arg(ap, el_rfunc_t *));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EL_CLIENTDATA: /* void ** */
|
|
|
|
ret = el_wget(el, op, va_arg(ap, void **));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EL_GETFP: { /* int, FILE ** */
|
|
|
|
int what = va_arg(ap, int);
|
|
|
|
FILE **fpp = va_arg(ap, FILE **);
|
|
|
|
ret = el_wget(el, op, what, fpp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
va_end(ap);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const LineInfo *
|
|
|
|
el_line(EditLine *el)
|
|
|
|
{
|
|
|
|
const LineInfoW *winfo = el_wline(el);
|
|
|
|
LineInfo *info = &el->el_lgcylinfo;
|
2010-04-15 04:52:48 +04:00
|
|
|
size_t offset;
|
2016-04-11 03:50:13 +03:00
|
|
|
const wchar_t *p;
|
2009-12-31 01:37:40 +03:00
|
|
|
|
2024-05-17 05:59:08 +03:00
|
|
|
if (el->el_flags & FROM_ELLINE)
|
|
|
|
return info;
|
|
|
|
|
|
|
|
el->el_flags |= FROM_ELLINE;
|
2009-12-31 01:37:40 +03:00
|
|
|
info->buffer = ct_encode_string(winfo->buffer, &el->el_lgcyconv);
|
2010-04-15 04:52:48 +04:00
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
for (p = winfo->buffer; p < winfo->cursor; p++)
|
|
|
|
offset += ct_enc_width(*p);
|
|
|
|
info->cursor = info->buffer + offset;
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
for (p = winfo->buffer; p < winfo->lastchar; p++)
|
|
|
|
offset += ct_enc_width(*p);
|
|
|
|
info->lastchar = info->buffer + offset;
|
|
|
|
|
2024-05-17 05:59:08 +03:00
|
|
|
if (el->el_chared.c_resizefun)
|
|
|
|
(*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg);
|
|
|
|
el->el_flags &= ~FROM_ELLINE;
|
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
el_insertstr(EditLine *el, const char *str)
|
|
|
|
{
|
|
|
|
return el_winsertstr(el, ct_decode_string(str, &el->el_lgcyconv));
|
|
|
|
}
|
2022-01-11 21:30:15 +03:00
|
|
|
|
|
|
|
int
|
|
|
|
el_replacestr(EditLine *el, const char *str)
|
|
|
|
{
|
|
|
|
return el_wreplacestr(el, ct_decode_string(str, &el->el_lgcyconv));
|
|
|
|
}
|