2016-05-10 00:46:56 +03:00
|
|
|
/* $NetBSD: emacs.c,v 1.36 2016/05/09 21:46:56 christos Exp $ */
|
1997-01-11 09:47:47 +03:00
|
|
|
|
1994-05-06 10:01:42 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Christos Zoulas of Cornell University.
|
|
|
|
*
|
|
|
|
* 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.
|
2003-08-07 20:42:00 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-06 10:01:42 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
|
|
|
*/
|
|
|
|
|
2002-03-18 19:00:50 +03:00
|
|
|
#include "config.h"
|
1994-05-06 10:01:42 +04:00
|
|
|
#if !defined(lint) && !defined(SCCSID)
|
1997-01-11 09:47:47 +03:00
|
|
|
#if 0
|
1994-05-06 10:01:42 +04:00
|
|
|
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
|
1997-01-11 09:47:47 +03:00
|
|
|
#else
|
2016-05-10 00:46:56 +03:00
|
|
|
__RCSID("$NetBSD: emacs.c,v 1.36 2016/05/09 21:46:56 christos Exp $");
|
1997-01-11 09:47:47 +03:00
|
|
|
#endif
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif /* not lint && not SCCSID */
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/*
|
1994-05-06 10:01:42 +04:00
|
|
|
* emacs.c: Emacs functions
|
|
|
|
*/
|
2016-02-17 01:53:14 +03:00
|
|
|
#include <ctype.h>
|
|
|
|
|
1994-05-06 10:01:42 +04:00
|
|
|
#include "el.h"
|
2016-02-16 22:08:41 +03:00
|
|
|
#include "emacs.h"
|
From Ingo Schwarze:
* Replace fcns.c by a shorter and simpler func.h
and include it only in the one file needing it, map.c.
* Combine help.h and help.c into a simplified help.h
and include it only in the one file needing it, map.c.
* Check the very simple, static files editline.c, historyn.c, and
tokenizern.c into CVS rather than needlessly generating them.
* So we no longer autogenerate any C files. :-)
* Shorten and simplify makelist by deleting the options -n, -e, -bc,
and -m; the latter was unused and useless in the first place.
* Move the declaration of el_func_t from fcns.h to the header
actually needing it, map.h. Since that header is already
included by el.h for unrelated reasons, that makes el_func_t
just as globally available as before.
* No longer include the simplified fcns.h into el.h,
include it directly into the *.c files needing it.
2016-04-18 20:01:19 +03:00
|
|
|
#include "fcns.h"
|
1994-05-06 10:01:42 +04:00
|
|
|
|
|
|
|
/* em_delete_or_list():
|
|
|
|
* Delete character under cursor or list completions if at end of line
|
|
|
|
* [^D]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_delete_or_list(EditLine *el, wint_t c)
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (el->el_line.cursor == el->el_line.lastchar) {
|
|
|
|
/* if I'm at the end */
|
|
|
|
if (el->el_line.cursor == el->el_line.buffer) {
|
|
|
|
/* and the beginning */
|
2011-07-28 05:05:20 +04:00
|
|
|
terminal_writec(el, c); /* then do an EOF */
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_EOF;
|
2000-09-05 02:06:28 +04:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Here we could list completions, but it is an
|
|
|
|
* error right now
|
|
|
|
*/
|
2011-07-28 05:05:20 +04:00
|
|
|
terminal_beep(el);
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
|
|
|
} else {
|
2004-08-13 16:10:38 +04:00
|
|
|
if (el->el_state.doingarg)
|
|
|
|
c_delafter(el, el->el_state.argument);
|
|
|
|
else
|
|
|
|
c_delafter1(el);
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor > el->el_line.lastchar)
|
|
|
|
el->el_line.cursor = el->el_line.lastchar;
|
|
|
|
/* bounds check */
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_delete_next_word():
|
|
|
|
* Cut from cursor to end of current word
|
|
|
|
* [M-d]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_delete_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *cp, *p, *kp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor == el->el_line.lastchar)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
cp = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
|
|
|
el->el_state.argument, ce__isword);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
for (p = el->el_line.cursor, kp = el->el_chared.c_kill.buf; p < cp; p++)
|
|
|
|
/* save the text */
|
|
|
|
*kp++ = *p;
|
|
|
|
el->el_chared.c_kill.last = kp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2009-02-16 00:55:23 +03:00
|
|
|
c_delafter(el, (int)(cp - el->el_line.cursor)); /* delete after dot */
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor > el->el_line.lastchar)
|
|
|
|
el->el_line.cursor = el->el_line.lastchar;
|
|
|
|
/* bounds check */
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_yank():
|
|
|
|
* Paste cut buffer at cursor position
|
|
|
|
* [^Y]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_yank(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *kp, *cp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2003-11-02 23:07:58 +03:00
|
|
|
if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.lastchar +
|
|
|
|
(el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >=
|
|
|
|
el->el_line.limit)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_chared.c_kill.mark = el->el_line.cursor;
|
|
|
|
cp = el->el_line.cursor;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
/* open the space, */
|
2009-02-16 00:55:23 +03:00
|
|
|
c_insert(el,
|
|
|
|
(int)(el->el_chared.c_kill.last - el->el_chared.c_kill.buf));
|
2000-09-05 02:06:28 +04:00
|
|
|
/* copy the chars */
|
|
|
|
for (kp = el->el_chared.c_kill.buf; kp < el->el_chared.c_kill.last; kp++)
|
|
|
|
*cp++ = *kp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
/* if an arg, cursor at beginning else cursor at end */
|
|
|
|
if (el->el_state.argument == 1)
|
|
|
|
el->el_line.cursor = cp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_kill_line():
|
|
|
|
* Cut the entire line and save in cut buffer
|
|
|
|
* [^U]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *kp, *cp;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
cp = el->el_line.buffer;
|
|
|
|
kp = el->el_chared.c_kill.buf;
|
|
|
|
while (cp < el->el_line.lastchar)
|
|
|
|
*kp++ = *cp++; /* copy it */
|
|
|
|
el->el_chared.c_kill.last = kp;
|
|
|
|
/* zap! -- delete all of it */
|
|
|
|
el->el_line.lastchar = el->el_line.buffer;
|
|
|
|
el->el_line.cursor = el->el_line.buffer;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_kill_region():
|
|
|
|
* Cut area between mark and cursor and save in cut buffer
|
|
|
|
* [^W]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_kill_region(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *kp, *cp;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (!el->el_chared.c_kill.mark)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (el->el_chared.c_kill.mark > el->el_line.cursor) {
|
|
|
|
cp = el->el_line.cursor;
|
|
|
|
kp = el->el_chared.c_kill.buf;
|
|
|
|
while (cp < el->el_chared.c_kill.mark)
|
|
|
|
*kp++ = *cp++; /* copy it */
|
|
|
|
el->el_chared.c_kill.last = kp;
|
2009-02-16 00:55:23 +03:00
|
|
|
c_delafter(el, (int)(cp - el->el_line.cursor));
|
2000-09-05 02:06:28 +04:00
|
|
|
} else { /* mark is before cursor */
|
|
|
|
cp = el->el_chared.c_kill.mark;
|
|
|
|
kp = el->el_chared.c_kill.buf;
|
|
|
|
while (cp < el->el_line.cursor)
|
|
|
|
*kp++ = *cp++; /* copy it */
|
|
|
|
el->el_chared.c_kill.last = kp;
|
2009-02-16 00:55:23 +03:00
|
|
|
c_delbefore(el, (int)(cp - el->el_chared.c_kill.mark));
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor = el->el_chared.c_kill.mark;
|
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_copy_region():
|
|
|
|
* Copy area between mark and cursor to cut buffer
|
|
|
|
* [M-W]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_copy_region(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *kp, *cp;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2002-10-28 00:41:50 +03:00
|
|
|
if (!el->el_chared.c_kill.mark)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (el->el_chared.c_kill.mark > el->el_line.cursor) {
|
|
|
|
cp = el->el_line.cursor;
|
|
|
|
kp = el->el_chared.c_kill.buf;
|
|
|
|
while (cp < el->el_chared.c_kill.mark)
|
|
|
|
*kp++ = *cp++; /* copy it */
|
|
|
|
el->el_chared.c_kill.last = kp;
|
|
|
|
} else {
|
|
|
|
cp = el->el_chared.c_kill.mark;
|
|
|
|
kp = el->el_chared.c_kill.buf;
|
|
|
|
while (cp < el->el_line.cursor)
|
|
|
|
*kp++ = *cp++; /* copy it */
|
|
|
|
el->el_chared.c_kill.last = kp;
|
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-31 20:52:42 +04:00
|
|
|
/* em_gosmacs_transpose():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Exchange the two characters before the cursor
|
|
|
|
* Gosling emacs transpose chars [^T]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_gosmacs_transpose(EditLine *el, wint_t c)
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor > &el->el_line.buffer[1]) {
|
|
|
|
/* must have at least two chars entered */
|
|
|
|
c = el->el_line.cursor[-2];
|
|
|
|
el->el_line.cursor[-2] = el->el_line.cursor[-1];
|
2016-04-11 03:50:13 +03:00
|
|
|
el->el_line.cursor[-1] = c;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
2000-09-05 02:06:28 +04:00
|
|
|
} else
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_next_word():
|
|
|
|
* Move next to end of current word
|
|
|
|
* [M-f]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor == el->el_line.lastchar)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
el->el_line.cursor = c__next_word(el->el_line.cursor,
|
|
|
|
el->el_line.lastchar,
|
|
|
|
el->el_state.argument,
|
|
|
|
ce__isword);
|
|
|
|
|
|
|
|
if (el->el_map.type == MAP_VI)
|
2002-11-15 17:32:32 +03:00
|
|
|
if (el->el_chared.c_vcmd.action != NOP) {
|
2000-09-05 02:06:28 +04:00
|
|
|
cv_delfini(el);
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_CURSOR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
|
1994-05-06 10:01:42 +04:00
|
|
|
/* em_upper_case():
|
|
|
|
* Uppercase the characters from cursor to end of current word
|
|
|
|
* [M-u]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_upper_case(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *cp, *ep;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
|
|
|
el->el_state.argument, ce__isword);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
for (cp = el->el_line.cursor; cp < ep; cp++)
|
2016-04-09 21:43:17 +03:00
|
|
|
if (iswlower(*cp))
|
|
|
|
*cp = towupper(*cp);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor = ep;
|
|
|
|
if (el->el_line.cursor > el->el_line.lastchar)
|
|
|
|
el->el_line.cursor = el->el_line.lastchar;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_capitol_case():
|
|
|
|
* Capitalize the characters from cursor to end of current word
|
|
|
|
* [M-c]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_capitol_case(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *cp, *ep;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
|
|
|
el->el_state.argument, ce__isword);
|
|
|
|
|
|
|
|
for (cp = el->el_line.cursor; cp < ep; cp++) {
|
2016-04-09 21:43:17 +03:00
|
|
|
if (iswalpha(*cp)) {
|
|
|
|
if (iswlower(*cp))
|
|
|
|
*cp = towupper(*cp);
|
2000-09-05 02:06:28 +04:00
|
|
|
cp++;
|
|
|
|
break;
|
|
|
|
}
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
2000-09-05 02:06:28 +04:00
|
|
|
for (; cp < ep; cp++)
|
2016-04-09 21:43:17 +03:00
|
|
|
if (iswupper(*cp))
|
|
|
|
*cp = towlower(*cp);
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
el->el_line.cursor = ep;
|
|
|
|
if (el->el_line.cursor > el->el_line.lastchar)
|
|
|
|
el->el_line.cursor = el->el_line.lastchar;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
|
1994-05-06 10:01:42 +04:00
|
|
|
/* em_lower_case():
|
|
|
|
* Lowercase the characters from cursor to end of current word
|
|
|
|
* [M-l]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_lower_case(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *cp, *ep;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
|
|
|
el->el_state.argument, ce__isword);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
for (cp = el->el_line.cursor; cp < ep; cp++)
|
2016-04-09 21:43:17 +03:00
|
|
|
if (iswupper(*cp))
|
|
|
|
*cp = towlower(*cp);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor = ep;
|
|
|
|
if (el->el_line.cursor > el->el_line.lastchar)
|
|
|
|
el->el_line.cursor = el->el_line.lastchar;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_set_mark():
|
|
|
|
* Set the mark at cursor
|
|
|
|
* [^@]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_set_mark(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
el->el_chared.c_kill.mark = el->el_line.cursor;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_exchange_mark():
|
1999-07-02 19:14:07 +04:00
|
|
|
* Exchange the cursor and mark
|
1994-05-06 10:01:42 +04:00
|
|
|
* [^X^X]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_exchange_mark(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *cp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
cp = el->el_line.cursor;
|
|
|
|
el->el_line.cursor = el->el_chared.c_kill.mark;
|
|
|
|
el->el_chared.c_kill.mark = cp;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_CURSOR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
|
1994-05-06 10:01:42 +04:00
|
|
|
/* em_universal_argument():
|
|
|
|
* Universal argument (argument times 4)
|
|
|
|
* [^U]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_universal_argument(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{ /* multiply current argument by 4 */
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (el->el_state.argument > 1000000)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_state.doingarg = 1;
|
|
|
|
el->el_state.argument *= 4;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ARGHACK;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
|
1994-05-06 10:01:42 +04:00
|
|
|
/* em_meta_next():
|
|
|
|
* Add 8th bit to next character typed
|
|
|
|
* [<ESC>]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_meta_next(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
el->el_state.metanext = 1;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ARGHACK;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_toggle_overwrite():
|
|
|
|
* Switch from insert to overwrite mode or vice versa
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_toggle_overwrite(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
|
|
|
|
MODE_REPLACE : MODE_INSERT;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_copy_prev_word():
|
|
|
|
* Copy current word to cursor
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2016-04-11 03:50:13 +03:00
|
|
|
wchar_t *cp, *oldc, *dp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor == el->el_line.buffer)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
oldc = el->el_line.cursor;
|
|
|
|
/* does a bounds check */
|
|
|
|
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
|
|
|
|
el->el_state.argument, ce__isword);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2009-02-16 00:55:23 +03:00
|
|
|
c_insert(el, (int)(oldc - cp));
|
2000-09-05 02:06:28 +04:00
|
|
|
for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
|
|
|
|
*dp++ = *cp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor = dp;/* put cursor at end */
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_inc_search_next():
|
|
|
|
* Emacs incremental next search
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_inc_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
el->el_search.patlen = 0;
|
2011-07-29 19:16:33 +04:00
|
|
|
return ce_inc_search(el, ED_SEARCH_NEXT_HISTORY);
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* em_inc_search_prev():
|
|
|
|
* Emacs incremental reverse search
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
1994-05-06 10:01:42 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_inc_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
el->el_search.patlen = 0;
|
2011-07-29 19:16:33 +04:00
|
|
|
return ce_inc_search(el, ED_SEARCH_PREV_HISTORY);
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
2004-08-13 16:10:38 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* em_delete_prev_char():
|
|
|
|
* Delete the character to the left of the cursor
|
|
|
|
* [^?]
|
|
|
|
*/
|
2016-05-10 00:46:56 +03:00
|
|
|
libedit_private el_action_t
|
2004-08-13 16:10:38 +04:00
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
em_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
2004-08-13 16:10:38 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
if (el->el_line.cursor <= el->el_line.buffer)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2004-08-13 16:10:38 +04:00
|
|
|
|
|
|
|
if (el->el_state.doingarg)
|
|
|
|
c_delbefore(el, el->el_state.argument);
|
|
|
|
else
|
|
|
|
c_delbefore1(el);
|
|
|
|
el->el_line.cursor -= el->el_state.argument;
|
|
|
|
if (el->el_line.cursor < el->el_line.buffer)
|
|
|
|
el->el_line.cursor = el->el_line.buffer;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
2004-08-13 16:10:38 +04:00
|
|
|
}
|