From 295d172f2d4cb7f687819fbf69eba452e314de4b Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sat, 1 Jan 2005 07:43:32 +0000 Subject: [PATCH] implement cutting from the current position to the end of the file, using Ctrl-X from the search prompt and Meta-T from the edit window; also update the copyright years of more modified files git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2211 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 6 ++++++ src/cut.c | 22 +++++++++++++++++++++- src/global.c | 19 +++++++++++++++++++ src/nano.h | 4 +++- src/proto.h | 3 +++ 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a9d139e..2fe31e63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -77,6 +77,12 @@ CVS code - do_statusbar_right(), do_statusbar_left(), do_statusbar_backspace(), and do_statusbar_delete(). (David Benbennick and DLR) + - Implement cutting from the current position to the end of the + file, using Ctrl-X from the search prompt and Meta-T from the + edit window. New function do_cut_till_end(). Note that this + is disabled when NANO_SMALL is defined. (DLR, based on ideas + from a patch for Pico by Eduardo Chappa, suggested by Ryan + Dlugosz and Paul Adams) - cut.c: do_cut_text() - If keep_cutbuffer is FALSE, only blow away the text in the diff --git a/src/cut.c b/src/cut.c index 1d4cac6c..b90e52fd 100644 --- a/src/cut.c +++ b/src/cut.c @@ -2,7 +2,7 @@ /************************************************************************** * cut.c * * * - * Copyright (C) 1999-2004 Chris Allegretta * + * Copyright (C) 1999-2005 Chris Allegretta * * 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 * * the Free Software Foundation; either version 2, or (at your option) * @@ -140,6 +140,26 @@ void do_cut_text(void) #endif } +#ifndef NANO_SMALL +/* Cut from the current cursor position to the end of the file. */ +void do_cut_till_end(void) +{ + assert(current != NULL && current->data != NULL); + + check_statusblank(); + + move_to_filestruct(&cutbuffer, &cutbottom, current, current_x, + filebot, 0); + + edit_refresh(); + set_modified(); + +#ifdef DEBUG + dump_buffer(cutbuffer); +#endif +} +#endif + /* Copy text from the cutbuffer into the current filestruct. */ void do_uncut_text(void) { diff --git a/src/global.c b/src/global.c index 0db515ee..3dac30a7 100644 --- a/src/global.c +++ b/src/global.c @@ -239,6 +239,9 @@ void shortcut_init(bool unjustify) const char *cancel_msg = N_("Cancel"); const char *first_line_msg = N_("First Line"); const char *last_line_msg = N_("Last Line"); +#ifndef NANO_SMALL + const char *cut_till_end_msg = N_("CutTillEnd"); +#endif #ifndef DISABLE_JUSTIFY const char *beg_of_par_msg = N_("Beg of Par"); const char *end_of_par_msg = N_("End of Par"); @@ -316,6 +319,10 @@ void shortcut_init(bool unjustify) const char *nano_opennext_msg = N_("Switch to the next file buffer"); #endif const char *nano_verbatim_msg = N_("Insert character(s) verbatim"); +#ifndef NANO_SMALL + const char *nano_cut_till_end_msg = + N_("Cut from the cursor position to the end of the file"); +#endif #ifndef DISABLE_JUSTIFY const char *nano_fulljustify_msg = N_("Justify the entire file"); #endif @@ -569,6 +576,13 @@ void shortcut_init(bool unjustify) IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_verbatim_input); +#ifndef NANO_SMALL + /* Translators: try to keep this string under 10 characters long */ + sc_init_one(&main_list, NANO_NO_KEY, cut_till_end_msg, + IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY), + NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end); +#endif + #ifndef DISABLE_JUSTIFY /* Translators: try to keep this string under 10 characters long */ sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg, @@ -653,6 +667,11 @@ void shortcut_init(bool unjustify) sc_init_one(&whereis_list, NANO_HISTORY_KEY, history_msg, IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY, VIEW, 0); + + /* Translators: try to keep this string under 10 characters long */ + sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg, + IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY), + NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end); #endif /* !NANO_SMALL */ #ifndef DISABLE_JUSTIFY diff --git a/src/nano.h b/src/nano.h index 482dd703..ca9d37ba 100644 --- a/src/nano.h +++ b/src/nano.h @@ -2,7 +2,7 @@ /************************************************************************** * nano.h * * * - * Copyright (C) 1999-2004 Chris Allegretta * + * Copyright (C) 1999-2005 Chris Allegretta * * 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 * * the Free Software Foundation; either version 2, or (at your option) * @@ -478,6 +478,8 @@ typedef struct historyheadtype { #define NANO_BRACKET_KEY NANO_ALT_RBRACKET #define NANO_NEXTWORD_KEY NANO_CONTROL_SPACE #define NANO_PREVWORD_KEY NANO_ALT_SPACE +#define NANO_CUTTILLEND_KEY NANO_CONTROL_X +#define NANO_CUTTILLEND_ALTKEY NANO_ALT_T #define NANO_PARABEGIN_KEY NANO_CONTROL_W #define NANO_PARABEGIN_ALTKEY1 NANO_ALT_LPAREN #define NANO_PARABEGIN_ALTKEY2 NANO_ALT_9 diff --git a/src/proto.h b/src/proto.h index 24419324..7c632343 100644 --- a/src/proto.h +++ b/src/proto.h @@ -165,6 +165,9 @@ void cut_marked(void); #endif void cut_to_eol(void); void do_cut_text(void); +#ifndef NANO_SMALL +void do_cut_till_end(void); +#endif void do_uncut_text(void); /* Public functions in files.c. */ -- 2.39.5