diff --git a/src/global.c b/src/global.c index 46633e3..d5326ea 100644 --- a/src/global.c +++ b/src/global.c @@ -1078,7 +1078,7 @@ void shortcut_init(void) add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0); add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0); add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0); - add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0); + //add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0); add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search, 0); add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search, 0); add_to_sclist(MMAIN, "^\\", 0, do_replace, 0); @@ -1131,6 +1131,7 @@ void shortcut_init(void) add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0); add_to_sclist(MMAIN, "M-}", 0, do_indent, 0); add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0); + add_to_sclist(MMAIN, "Ins", 0, do_overwrite, 0); add_to_sclist(MMAIN, "M-U", 0, do_undo, 0); add_to_sclist(MMAIN, "M-E", 0, do_redo, 0); #endif diff --git a/src/nano.c b/src/nano.c index 412b17e..810dae3 100644 --- a/src/nano.c +++ b/src/nano.c @@ -39,6 +39,8 @@ #endif #include +static bool overwrite_mode = FALSE; + #ifdef ENABLE_MOUSE static int oldinterval = -1; /* Used to store the user's original mouse click interval. */ @@ -1563,6 +1565,15 @@ void unbound_key(int code) statusline(ALERT, _("Unbound key: %c"), code); } +/* Toggles overwrite mode */ +void do_overwrite(void) +{ + overwrite_mode = !overwrite_mode; + if (overwrite_mode) + statusbar(_("Overwrite mode enabled")); + else + statusbar(_("Overwrite mode disabled")); +} /* Read in a keystroke. Act on the keystroke if it is a shortcut or a toggle; * otherwise, insert it into the edit buffer. If allow_funcs is FALSE, don't * do anything with the keystroke -- just return it. */ @@ -1629,6 +1640,10 @@ int do_input(bool allow_funcs) /* Store the byte, and leave room for a terminating zero. */ puddle = charealloc(puddle, depth + 2); puddle[depth++] = (char)input; + if(overwrite_mode && + openfile->current->data[openfile->current_x] != '\0' && + input != '\n') + do_delete(); } #ifndef NANO_TINY if (openfile->mark_set && openfile->kind_of_mark == SOFTMARK) { diff --git a/src/proto.h b/src/proto.h index 71c12d4..721ae2d 100644 --- a/src/proto.h +++ b/src/proto.h @@ -449,6 +449,7 @@ void disable_flow_control(void); void enable_flow_control(void); void terminal_init(void); void unbound_key(int code); +void do_overwrite(void); int do_input(bool allow_funcs); #ifdef ENABLE_MOUSE int do_mouse(void);