2018-10-07 20:52:13 +02:00
|
|
|
/* undo.c - manage list of changes to lines, offering opportunity to undo them */
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2019-08-12 18:24:03 +02:00
|
|
|
/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
This file is part of the GNU Readline Library (Readline), a library
|
|
|
|
for reading lines of text with interactive input and history editing.
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
Readline is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
1999-04-16 03:34:55 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
Readline is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
1999-04-16 03:34:55 +02:00
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
#define READLINE_LIBRARY
|
|
|
|
|
|
|
|
#if defined (HAVE_CONFIG_H)
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#if defined (HAVE_UNISTD_H)
|
|
|
|
# include <unistd.h> /* for _POSIX_VERSION */
|
|
|
|
#endif /* HAVE_UNISTD_H */
|
|
|
|
|
|
|
|
#if defined (HAVE_STDLIB_H)
|
|
|
|
# include <stdlib.h>
|
|
|
|
#else
|
|
|
|
# include "ansi_stdlib.h"
|
|
|
|
#endif /* HAVE_STDLIB_H */
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
/* System-specific feature definitions and include files. */
|
|
|
|
#include "rldefs.h"
|
|
|
|
|
|
|
|
/* Some standard library routines. */
|
|
|
|
#include "readline.h"
|
|
|
|
#include "history.h"
|
|
|
|
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
#include "rlprivate.h"
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
#include "xmalloc.h"
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
extern void _hs_replace_history_data PARAMS((int, histdata_t *, histdata_t *));
|
2011-05-12 01:38:44 +02:00
|
|
|
|
2019-08-12 18:24:03 +02:00
|
|
|
extern HIST_ENTRY *_rl_saved_line_for_history;
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
/* Non-zero tells rl_delete_text and rl_insert_text to not add to
|
|
|
|
the undo list. */
|
|
|
|
int _rl_doing_an_undo = 0;
|
|
|
|
|
|
|
|
/* How many unclosed undo groups we currently have. */
|
|
|
|
int _rl_undo_group_level = 0;
|
|
|
|
|
|
|
|
/* The current undo list for THE_LINE. */
|
|
|
|
UNDO_LIST *rl_undo_list = (UNDO_LIST *)NULL;
|
|
|
|
|
|
|
|
/* **************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* Undo, and Undoing */
|
|
|
|
/* */
|
|
|
|
/* **************************************************************** */
|
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
static UNDO_LIST *
|
2019-08-12 18:24:03 +02:00
|
|
|
alloc_undo_entry (enum undo_code what, int start, int end, char *text)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2011-05-12 01:38:44 +02:00
|
|
|
UNDO_LIST *temp;
|
|
|
|
|
|
|
|
temp = (UNDO_LIST *)xmalloc (sizeof (UNDO_LIST));
|
1999-04-16 03:34:55 +02:00
|
|
|
temp->what = what;
|
|
|
|
temp->start = start;
|
|
|
|
temp->end = end;
|
|
|
|
temp->text = text;
|
2011-05-12 01:38:44 +02:00
|
|
|
|
|
|
|
temp->next = (UNDO_LIST *)NULL;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remember how to undo something. Concatenate some undos if that
|
|
|
|
seems right. */
|
|
|
|
void
|
2019-08-12 18:24:03 +02:00
|
|
|
rl_add_undo (enum undo_code what, int start, int end, char *text)
|
2011-05-12 01:38:44 +02:00
|
|
|
{
|
|
|
|
UNDO_LIST *temp;
|
|
|
|
|
|
|
|
temp = alloc_undo_entry (what, start, end, text);
|
1999-04-16 03:34:55 +02:00
|
|
|
temp->next = rl_undo_list;
|
|
|
|
rl_undo_list = temp;
|
|
|
|
}
|
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
/* Free an UNDO_LIST */
|
1999-04-16 03:34:55 +02:00
|
|
|
void
|
2019-08-12 18:24:03 +02:00
|
|
|
_rl_free_undo_list (UNDO_LIST *ul)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2018-10-07 20:52:13 +02:00
|
|
|
UNDO_LIST *release;
|
2011-05-12 01:38:44 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
while (ul)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2018-10-07 20:52:13 +02:00
|
|
|
release = ul;
|
|
|
|
ul = ul->next;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
if (release->what == UNDO_DELETE)
|
2011-05-12 01:38:44 +02:00
|
|
|
xfree (release->text);
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
xfree (release);
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
2018-10-07 20:52:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the existing undo list. */
|
|
|
|
void
|
2019-08-12 18:24:03 +02:00
|
|
|
rl_free_undo_list (void)
|
2018-10-07 20:52:13 +02:00
|
|
|
{
|
|
|
|
UNDO_LIST *release, *orig_list;
|
|
|
|
|
|
|
|
orig_list = rl_undo_list;
|
|
|
|
_rl_free_undo_list (rl_undo_list);
|
1999-04-16 03:34:55 +02:00
|
|
|
rl_undo_list = (UNDO_LIST *)NULL;
|
2018-10-07 20:52:13 +02:00
|
|
|
_hs_replace_history_data (-1, (histdata_t *)orig_list, (histdata_t *)NULL);
|
2011-05-12 01:38:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UNDO_LIST *
|
2019-08-12 18:24:03 +02:00
|
|
|
_rl_copy_undo_entry (UNDO_LIST *entry)
|
2011-05-12 01:38:44 +02:00
|
|
|
{
|
|
|
|
UNDO_LIST *new;
|
|
|
|
|
|
|
|
new = alloc_undo_entry (entry->what, entry->start, entry->end, (char *)NULL);
|
|
|
|
new->text = entry->text ? savestring (entry->text) : 0;
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
|
|
|
UNDO_LIST *
|
2019-08-12 18:24:03 +02:00
|
|
|
_rl_copy_undo_list (UNDO_LIST *head)
|
2011-05-12 01:38:44 +02:00
|
|
|
{
|
|
|
|
UNDO_LIST *list, *new, *roving, *c;
|
|
|
|
|
|
|
|
if (head == 0)
|
|
|
|
return head;
|
|
|
|
|
|
|
|
list = head;
|
|
|
|
new = 0;
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
c = _rl_copy_undo_entry (list);
|
|
|
|
if (new == 0)
|
|
|
|
roving = new = c;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
roving->next = c;
|
|
|
|
roving = roving->next;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
roving->next = 0;
|
|
|
|
return new;
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Undo the next thing in the list. Return 0 if there
|
|
|
|
is nothing to undo, or non-zero if there was. */
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
rl_do_undo (void)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2019-08-12 18:24:03 +02:00
|
|
|
UNDO_LIST *release, *search;
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
int waiting_for_begin, start, end;
|
2018-10-07 20:52:13 +02:00
|
|
|
HIST_ENTRY *cur, *temp;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
#define TRANS(i) ((i) == -1 ? rl_point : ((i) == -2 ? rl_end : (i)))
|
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
start = end = waiting_for_begin = 0;
|
1999-04-16 03:34:55 +02:00
|
|
|
do
|
|
|
|
{
|
2011-05-12 01:38:44 +02:00
|
|
|
if (rl_undo_list == 0)
|
1999-04-16 03:34:55 +02:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
_rl_doing_an_undo = 1;
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
RL_SETSTATE(RL_STATE_UNDOING);
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
/* To better support vi-mode, a start or end value of -1 means
|
|
|
|
rl_point, and a value of -2 means rl_end. */
|
|
|
|
if (rl_undo_list->what == UNDO_DELETE || rl_undo_list->what == UNDO_INSERT)
|
|
|
|
{
|
|
|
|
start = TRANS (rl_undo_list->start);
|
|
|
|
end = TRANS (rl_undo_list->end);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (rl_undo_list->what)
|
|
|
|
{
|
|
|
|
/* Undoing deletes means inserting some text. */
|
|
|
|
case UNDO_DELETE:
|
|
|
|
rl_point = start;
|
|
|
|
rl_insert_text (rl_undo_list->text);
|
2011-05-12 01:38:44 +02:00
|
|
|
xfree (rl_undo_list->text);
|
1999-04-16 03:34:55 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Undoing inserts means deleting some text. */
|
|
|
|
case UNDO_INSERT:
|
|
|
|
rl_delete_text (start, end);
|
|
|
|
rl_point = start;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Undoing an END means undoing everything 'til we get to a BEGIN. */
|
|
|
|
case UNDO_END:
|
|
|
|
waiting_for_begin++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Undoing a BEGIN means that we are done with this group. */
|
|
|
|
case UNDO_BEGIN:
|
|
|
|
if (waiting_for_begin)
|
|
|
|
waiting_for_begin--;
|
|
|
|
else
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
rl_ding ();
|
1999-04-16 03:34:55 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
_rl_doing_an_undo = 0;
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
RL_UNSETSTATE(RL_STATE_UNDOING);
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
release = rl_undo_list;
|
|
|
|
rl_undo_list = rl_undo_list->next;
|
2019-08-12 18:24:03 +02:00
|
|
|
release->next = 0; /* XXX */
|
2018-10-07 20:52:13 +02:00
|
|
|
|
|
|
|
/* If we are editing a history entry, make sure the change is replicated
|
|
|
|
in the history entry's line */
|
|
|
|
cur = current_history ();
|
|
|
|
if (cur && cur->data && (UNDO_LIST *)cur->data == release)
|
|
|
|
{
|
|
|
|
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
|
|
|
|
xfree (temp->line);
|
|
|
|
FREE (temp->timestamp);
|
|
|
|
xfree (temp);
|
|
|
|
}
|
|
|
|
|
2019-08-12 18:24:03 +02:00
|
|
|
/* Make sure there aren't any history entries with that undo list */
|
2018-10-07 20:52:13 +02:00
|
|
|
_hs_replace_history_data (-1, (histdata_t *)release, (histdata_t *)rl_undo_list);
|
2011-05-12 01:38:44 +02:00
|
|
|
|
2019-08-12 18:24:03 +02:00
|
|
|
/* And make sure this list isn't anywhere in the saved line for history */
|
|
|
|
if (_rl_saved_line_for_history && _rl_saved_line_for_history->data)
|
|
|
|
{
|
|
|
|
/* Brute force; no finesse here */
|
|
|
|
search = (UNDO_LIST *)_rl_saved_line_for_history->data;
|
|
|
|
if (search == release)
|
|
|
|
_rl_saved_line_for_history->data = rl_undo_list;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (search->next)
|
|
|
|
{
|
|
|
|
if (search->next == release)
|
|
|
|
{
|
|
|
|
search->next = rl_undo_list;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
search = search->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
xfree (release);
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
|
|
|
while (waiting_for_begin);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
#undef TRANS
|
|
|
|
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
_rl_fix_last_undo_of_type (int type, int start, int end)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
UNDO_LIST *rl;
|
|
|
|
|
|
|
|
for (rl = rl_undo_list; rl; rl = rl->next)
|
|
|
|
{
|
|
|
|
if (rl->what == type)
|
|
|
|
{
|
|
|
|
rl->start = start;
|
|
|
|
rl->end = end;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Begin a group. Subsequent undos are undone as an atomic operation. */
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
rl_begin_undo_group (void)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
rl_add_undo (UNDO_BEGIN, 0, 0, 0);
|
|
|
|
_rl_undo_group_level++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* End an undo group started with rl_begin_undo_group (). */
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
rl_end_undo_group (void)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
rl_add_undo (UNDO_END, 0, 0, 0);
|
|
|
|
_rl_undo_group_level--;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save an undo entry for the text from START to END. */
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
rl_modifying (int start, int end)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
if (start > end)
|
|
|
|
{
|
|
|
|
SWAP (start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start != end)
|
|
|
|
{
|
|
|
|
char *temp = rl_copy_text (start, end);
|
|
|
|
rl_begin_undo_group ();
|
|
|
|
rl_add_undo (UNDO_DELETE, start, end, temp);
|
|
|
|
rl_add_undo (UNDO_INSERT, start, end, (char *)NULL);
|
|
|
|
rl_end_undo_group ();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Revert the current line to its previous state. */
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
rl_revert_line (int count, int key)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2011-05-12 01:38:44 +02:00
|
|
|
if (rl_undo_list == 0)
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
rl_ding ();
|
1999-04-16 03:34:55 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
while (rl_undo_list)
|
|
|
|
rl_do_undo ();
|
2006-05-05 20:26:14 +02:00
|
|
|
#if defined (VI_MODE)
|
|
|
|
if (rl_editing_mode == vi_mode)
|
|
|
|
rl_point = rl_mark = 0; /* rl_end should be set correctly */
|
|
|
|
#endif
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
2006-05-05 20:26:14 +02:00
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do some undoing of things that were done. */
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
rl_undo_command (int count, int key)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
if (count < 0)
|
|
|
|
return 0; /* Nothing to do. */
|
|
|
|
|
|
|
|
while (count)
|
|
|
|
{
|
|
|
|
if (rl_do_undo ())
|
|
|
|
count--;
|
|
|
|
else
|
|
|
|
{
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
rl_ding ();
|
1999-04-16 03:34:55 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|