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
}
#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();
#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. */
#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;
/* Otherwise, move the entire line into the cutbuffer. */
cut_line();
- edit_refresh();
- set_modified();
+#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)
{
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
#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");
/* 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. */
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
* 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) {
#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)
#endif
else
/* Blow away the text in the cutbuffer, since we aren't
- * cutting text. */
+ * cutting or copying text. */
cutbuffer_reset();
}
#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'
#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
#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
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);