add the ability to copy text into the cutbuffer without cutting it, via
Meta-^ (Meta-6); note that this is disabled when NANO_TINY is defined git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3429 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
bc80cb1ba7
commit
c87e0c0965
|
@ -55,6 +55,11 @@ CVS code -
|
|||
browser. New function parse_help_input(); changes to
|
||||
parse_browser_input() and do_help(). (DLR, suggested by Benno
|
||||
Schulenberg)
|
||||
- Add the ability to copy text into the cutbuffer without
|
||||
cutting it, via Meta-^ (Meta-6). Note that this is disabled
|
||||
when NANO_TINY is defined. New functions do_cut_text_void()
|
||||
and do_copy_text(); changes to do_cut_text(), shortcut_init(),
|
||||
and do_input(). (DLR, suggested by Ken Tyler)
|
||||
- files.c:
|
||||
open_file()
|
||||
- Remove redundant wording in the error message when we try to
|
||||
|
|
68
src/cut.c
68
src/cut.c
|
@ -99,9 +99,24 @@ void cut_to_eol(void)
|
|||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Move text from the current filestruct into the cutbuffer. */
|
||||
void do_cut_text(void)
|
||||
/* Move text from the current filestruct into the cutbuffer. If
|
||||
* copy_text is TRUE, copy the text back into the filestruct
|
||||
* afterward. */
|
||||
void do_cut_text(
|
||||
#ifndef NANO_TINY
|
||||
bool copy_text
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
filestruct *cb_save = NULL;
|
||||
/* The current end of the cutbuffer, before we add text to
|
||||
* it. */
|
||||
bool old_mark_set = openfile->mark_set;
|
||||
#endif
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
check_statusblank();
|
||||
|
@ -116,6 +131,15 @@ void do_cut_text(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (cutbuffer != NULL) {
|
||||
/* If the cutbuffer isn't empty, save where it currently ends.
|
||||
* This is where the new text will be added. */
|
||||
cb_save = cutbottom;
|
||||
cb_save->data += strlen(cb_save->data);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set keep_cutbuffer to TRUE, so that the text we're going to move
|
||||
* into the cutbuffer will be added to the text already in the
|
||||
* cutbuffer instead of replacing it. */
|
||||
|
@ -123,7 +147,7 @@ void do_cut_text(void)
|
|||
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->mark_set) {
|
||||
/* If the mark is on, move the marked text to the cutbuffer and
|
||||
/* If the mark is on, move the marked text to the cutbuffer, and
|
||||
* turn the mark off. */
|
||||
cut_marked();
|
||||
openfile->mark_set = FALSE;
|
||||
|
@ -136,15 +160,45 @@ void do_cut_text(void)
|
|||
/* Otherwise, move the entire line into the cutbuffer. */
|
||||
cut_line();
|
||||
|
||||
edit_refresh();
|
||||
#ifndef NANO_TINY
|
||||
if (copy_text)
|
||||
/* Copy the text in the cutbuffer, starting at its saved end if
|
||||
* there is one, back into the filestruct. This effectively
|
||||
* uncuts the text we just cut without marking the file as
|
||||
* modified. */
|
||||
copy_from_filestruct((cb_save != NULL) ? cb_save : cutbuffer,
|
||||
cutbottom);
|
||||
else
|
||||
#endif
|
||||
/* Leave the text in the cutbuffer, and mark the file as
|
||||
* modified. */
|
||||
set_modified();
|
||||
|
||||
/* Update the screen. */
|
||||
#ifndef NANO_TINY
|
||||
if (!copy_text || old_mark_set)
|
||||
#endif
|
||||
edit_refresh();
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(cutbuffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Move text from the current filestruct into the cutbuffer. */
|
||||
void do_cut_text_void(void)
|
||||
{
|
||||
do_cut_text(FALSE);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Move text from the current filestruct into the cutbuffer, and copy it
|
||||
* back into the filestruct afterward. */
|
||||
void do_copy_text(void)
|
||||
{
|
||||
do_cut_text(TRUE);
|
||||
}
|
||||
|
||||
/* Cut from the current cursor position to the end of the file. */
|
||||
void do_cut_till_end(void)
|
||||
{
|
||||
|
@ -156,9 +210,13 @@ void do_cut_till_end(void)
|
|||
openfile->current_x, openfile->filebot,
|
||||
strlen(openfile->filebot->data));
|
||||
|
||||
edit_refresh();
|
||||
/* Leave the text in the cutbuffer, and mark the file as
|
||||
* modified. */
|
||||
set_modified();
|
||||
|
||||
/* Update the screen. */
|
||||
edit_refresh();
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(cutbuffer);
|
||||
#endif
|
||||
|
|
|
@ -392,6 +392,8 @@ void shortcut_init(bool unjustify)
|
|||
#ifndef NANO_TINY
|
||||
const char *nano_wordcount_msg =
|
||||
N_("Count the number of words, lines, and characters");
|
||||
const char *nano_copy_msg =
|
||||
N_("Copy the current line and store it in the cutbuffer");
|
||||
#endif
|
||||
const char *nano_refresh_msg =
|
||||
N_("Refresh (redraw) the current screen");
|
||||
|
@ -512,7 +514,7 @@ void shortcut_init(bool unjustify)
|
|||
/* TRANSLATORS: Try to keep this at most 10 characters. */
|
||||
sc_init_one(&main_list, NANO_CUT_KEY, N_("Cut Text"),
|
||||
IFHELP(nano_cut_msg, FALSE), NANO_NO_KEY, NANO_CUT_FKEY,
|
||||
NANO_NO_KEY, NOVIEW, do_cut_text);
|
||||
NANO_NO_KEY, NOVIEW, do_cut_text_void);
|
||||
|
||||
if (unjustify)
|
||||
/* TRANSLATORS: Try to keep this at most 10 characters. */
|
||||
|
@ -680,6 +682,10 @@ void shortcut_init(bool unjustify)
|
|||
sc_init_one(&main_list, NANO_NO_KEY, N_("Word Count"),
|
||||
IFHELP(nano_wordcount_msg, FALSE), NANO_WORDCOUNT_KEY,
|
||||
NANO_NO_KEY, NANO_NO_KEY, VIEW, do_wordlinechar_count);
|
||||
|
||||
sc_init_one(&main_list, NANO_NO_KEY, N_("Copy Text"),
|
||||
IFHELP(nano_copy_msg, FALSE), NANO_COPY_KEY, NANO_NO_KEY,
|
||||
NANO_COPY_ALTKEY, NOVIEW, do_copy_text);
|
||||
#endif
|
||||
|
||||
sc_init_one(&main_list, NANO_REFRESH_KEY, refresh_msg
|
||||
|
|
12
src/nano.c
12
src/nano.c
|
@ -1381,8 +1381,12 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
|||
* associated functions. */
|
||||
default:
|
||||
/* Blow away the text in the cutbuffer if we aren't
|
||||
* cutting text. */
|
||||
if (s->func != do_cut_text)
|
||||
* cutting or copying text. */
|
||||
if (s->func != do_cut_text_void
|
||||
#ifndef NANO_TINY
|
||||
&& s->func != do_copy_text
|
||||
#endif
|
||||
)
|
||||
cutbuffer_reset();
|
||||
|
||||
if (s->func != NULL) {
|
||||
|
@ -1399,7 +1403,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
|||
#ifndef NANO_TINY
|
||||
else if (have_toggle) {
|
||||
/* Blow away the text in the cutbuffer, since we aren't
|
||||
* cutting text. */
|
||||
* cutting or copying text. */
|
||||
cutbuffer_reset();
|
||||
/* Toggle the flag associated with this shortcut. */
|
||||
if (allow_funcs)
|
||||
|
@ -1408,7 +1412,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
|||
#endif
|
||||
else
|
||||
/* Blow away the text in the cutbuffer, since we aren't
|
||||
* cutting text. */
|
||||
* cutting or copying text. */
|
||||
cutbuffer_reset();
|
||||
}
|
||||
|
||||
|
|
12
src/nano.h
12
src/nano.h
|
@ -421,13 +421,15 @@ typedef struct rcoption {
|
|||
#define NANO_ALT_PERIOD '.'
|
||||
#define NANO_ALT_SLASH '/'
|
||||
#define NANO_ALT_0 '0'
|
||||
#define NANO_ALT_6 '6'
|
||||
#define NANO_ALT_9 '9'
|
||||
#define NANO_ALT_LCARAT '<'
|
||||
#define NANO_ALT_LCARET '<'
|
||||
#define NANO_ALT_EQUALS '='
|
||||
#define NANO_ALT_RCARAT '>'
|
||||
#define NANO_ALT_RCARET '>'
|
||||
#define NANO_ALT_QUESTION '?'
|
||||
#define NANO_ALT_BACKSLASH '\\'
|
||||
#define NANO_ALT_RBRACKET ']'
|
||||
#define NANO_ALT_CARET '^'
|
||||
#define NANO_ALT_UNDERSCORE '_'
|
||||
#define NANO_ALT_A 'a'
|
||||
#define NANO_ALT_B 'b'
|
||||
|
@ -496,6 +498,8 @@ typedef struct rcoption {
|
|||
#define NANO_NEXTPAGE_FKEY KEY_F(8)
|
||||
#define NANO_CUT_KEY NANO_CONTROL_K
|
||||
#define NANO_CUT_FKEY KEY_F(9)
|
||||
#define NANO_COPY_KEY NANO_ALT_CARET
|
||||
#define NANO_COPY_ALTKEY NANO_ALT_6
|
||||
#define NANO_UNCUT_KEY NANO_CONTROL_U
|
||||
#define NANO_UNCUT_FKEY KEY_F(10)
|
||||
#define NANO_CURSORPOS_KEY NANO_CONTROL_C
|
||||
|
@ -540,8 +544,8 @@ typedef struct rcoption {
|
|||
#define NANO_TOFILES_KEY NANO_CONTROL_T
|
||||
#define NANO_APPEND_KEY NANO_ALT_A
|
||||
#define NANO_PREPEND_KEY NANO_ALT_P
|
||||
#define NANO_PREVFILE_KEY NANO_ALT_LCARAT
|
||||
#define NANO_NEXTFILE_KEY NANO_ALT_RCARAT
|
||||
#define NANO_PREVFILE_KEY NANO_ALT_LCARET
|
||||
#define NANO_NEXTFILE_KEY NANO_ALT_RCARET
|
||||
#define NANO_PREVFILE_ALTKEY NANO_ALT_COMMA
|
||||
#define NANO_NEXTFILE_ALTKEY NANO_ALT_PERIOD
|
||||
#define NANO_BRACKET_KEY NANO_ALT_RBRACKET
|
||||
|
|
10
src/proto.h
10
src/proto.h
|
@ -250,8 +250,16 @@ void cut_line(void);
|
|||
void cut_marked(void);
|
||||
void cut_to_eol(void);
|
||||
#endif
|
||||
void do_cut_text(void);
|
||||
void do_cut_text(
|
||||
#ifndef NANO_TINY
|
||||
bool copy_text
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
);
|
||||
void do_cut_text_void(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_copy_text(void);
|
||||
void do_cut_till_end(void);
|
||||
#endif
|
||||
void do_uncut_text(void);
|
||||
|
|
Loading…
Reference in New Issue