improve overwrite-mode

* accept universal argument: NO_ARG: toggle, ==0 insert, !=0 overwrite
* added insert-mode command
This commit is contained in:
Charlie Gordon 2014-01-06 10:24:26 +00:00
commit ab445e4bc1
3 changed files with 11 additions and 6 deletions

7
qe.c
View file

@ -1349,9 +1349,12 @@ void do_quote(EditState *s, int argval)
put_status(s, "Quote: ");
}
void do_insert(EditState *s)
void do_overwrite_mode(EditState *s, int argval)
{
s->insert = !s->insert;
if (argval == NO_ARG)
s->insert = !s->insert;
else
s->insert = !argval;
}
void do_tab(EditState *s, int argval)

2
qe.h
View file

@ -1668,7 +1668,7 @@ void do_scroll_up_down(EditState *s, int dir);
void perform_scroll_up_down(EditState *s, int h);
void do_center_cursor(EditState *s);
void do_quote(EditState *s, int argval);
void do_insert(EditState *s);
void do_overwrite_mode(EditState *s, int argval);
// should take argval
void do_set_mark(EditState *s);
void do_mark_whole_buffer(EditState *s);

View file

@ -2,7 +2,7 @@
* QEmacs, tiny but powerful multimode editor
*
* Copyright (c) 2000,2001 Fabrice Bellard.
* Copyright (c) 2000-2008 Charlie Gordon.
* Copyright (c) 2000-2014 Charlie Gordon.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -56,8 +56,10 @@ static CmdDef basic_commands[] = {
"beginning-of-line", do_bol)
CMD0( KEY_CTRL('e'), KEY_END,
"end-of-line", do_eol)
CMD0( KEY_INSERT, KEY_NONE,
"overwrite-mode", do_insert)
CMD2( KEY_INSERT, KEY_NONE,
"overwrite-mode", do_overwrite_mode, ESi, "ui")
CMD3( KEY_NONE, KEY_NONE,
"insert-mode", do_overwrite_mode, ESi, 0, "v")
/* deletion commands should be allowed in read only buffers,
* they should merely copy the data to the kill ring */
CMD2( KEY_CTRL('d'), KEY_DELETE,