actually blanked. Changes to do_help(), do_continue(),
handle_sigwinch(), and update_statusbar_line(). (DLR)
(DLR)
+ - If the mark isn't on, allow Meta-} and Meta-{ to indent and
+ unindent only the current line, just as it would if the mark
+ covered only the current line, instead of displaying a
+ statusbar message and quitting. Changes to shortcut_init(),
+ do_indent_marked() (renamed do_indent()),
+ do_indent_marked_void() (renamed do_indent_void()), and
+ do_unindent_marked_void() (renamed do_unindent()). (DLR,
+ suggested by John M. Gabriele)
- browser.c:
do_browser()
- Refactor the mouse support, modeling it after do_mouse() for
const char *nano_whereis_next_msg = N_("Repeat last search");
const char *nano_copy_msg =
N_("Copy the current line and store it in the cutbuffer");
- const char *nano_indentmarked_msg = N_("Indent marked text");
- const char *nano_unindentmarked_msg = N_("Unindent marked text");
+ const char *nano_indent_msg = N_("Indent the current line");
+ const char *nano_unindent_msg = N_("Unindent the current line");
#endif
const char *nano_forward_msg = N_("Move forward one character");
const char *nano_back_msg = N_("Move back one character");
NANO_COPY_ALTKEY, NOVIEW, do_copy_text);
sc_init_one(&main_list, NANO_NO_KEY, N_("Indent Text"),
- IFHELP(nano_indentmarked_msg, FALSE), NANO_INDENTMARKED_KEY,
- NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_indent_marked_void);
+ IFHELP(nano_indent_msg, FALSE), NANO_INDENT_KEY, NANO_NO_KEY,
+ NANO_NO_KEY, NOVIEW, do_indent_void);
sc_init_one(&main_list, NANO_NO_KEY, N_("Unindent Text"),
- IFHELP(nano_unindentmarked_msg, TRUE), NANO_UNINDENTMARKED_KEY,
- NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_unindent_marked_void);
+ IFHELP(nano_unindent_msg, TRUE), NANO_UNINDENT_KEY, NANO_NO_KEY,
+ NANO_NO_KEY, NOVIEW, do_unindent);
#endif
sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
}
#ifndef NANO_TINY
-/* Indent or unindent all lines covered by the mark len columns,
- * depending on whether len is positive or negative. If the
- * TABS_TO_SPACES flag is set, indent/unindent by len spaces.
- * Otherwise, indent/unindent by (len / tabsize) tabs and (len %
- * tabsize) spaces. */
-void do_indent_marked(ssize_t cols)
+/* Indent or unindent the current line (or all lines covered by the mark
+ * if the mark is on) len columns, depending on whether len is positive
+ * or negative. If the TABS_TO_SPACES flag is set, indent/unindent by
+ * len spaces. Otherwise, indent/unindent by (len / tabsize) tabs and
+ * (len % tabsize) spaces. */
+void do_indent(ssize_t cols)
{
bool indent_changed = FALSE;
/* Whether any indenting or unindenting was done. */
assert(openfile->current != NULL && openfile->current->data != NULL);
- /* If the mark isn't on, indicate it on the statusbar and get
- * out. */
- if (!openfile->mark_set) {
- statusbar(_("No lines selected, nothing to do!"));
- return;
- }
-
/* If cols is zero, get out. */
if (cols == 0)
return;
} else
indent_changed = TRUE;
- /* Get the coordinates of the marked text. */
- mark_order((const filestruct **)&top, &top_x,
- (const filestruct **)&bot, &bot_x, NULL);
+ /* If the mark is on, use all lines covered by the mark. */
+ if (openfile->mark_set)
+ mark_order((const filestruct **)&top, &top_x,
+ (const filestruct **)&bot, &bot_x, NULL);
+ /* Otherwise, use the current line. */
+ else {
+ top = openfile->current;
+ bot = top;
+ }
if (!unindent) {
/* Set up the text we'll be using as indentation. */
line_indent[line_indent_len] = '\0';
}
- /* Go through each line of the marked text. */
+ /* Go through each line of the text. */
for (f = top; f != bot->next; f = f->next) {
size_t line_len = strlen(f->data);
size_t indent_len = indent_length(f->data);
openfile->totsize += line_indent_len;
/* Keep track of the change in the current line. */
- if (f == openfile->mark_begin && openfile->mark_begin_x >=
- indent_len)
+ if (openfile->mark_set && f == openfile->mark_begin &&
+ openfile->mark_begin_x >= indent_len)
openfile->mark_begin_x += line_indent_len;
if (f == openfile->current && openfile->current_x >=
openfile->totsize -= indent_shift;
/* Keep track of the change in the current line. */
- if (f == openfile->mark_begin &&
+ if (openfile->mark_set && f == openfile->mark_begin &&
openfile->mark_begin_x > indent_new) {
if (openfile->mark_begin_x <= indent_len)
openfile->mark_begin_x = indent_new;
}
}
-/* Indent all lines covered by the mark tabsize columns. */
-void do_indent_marked_void(void)
+/* Indent the current line, or all lines covered by the mark if the mark
+ * is on, tabsize columns. */
+void do_indent_void(void)
{
- do_indent_marked(tabsize);
+ do_indent(tabsize);
}
-/* Unindent all lines covered by the mark tabsize columns. */
-void do_unindent_marked_void(void)
+/* Unindent the current line, or all lines covered by the mark if the
+ * mark is on, tabsize columns. */
+void do_unindent(void)
{
- do_indent_marked(-tabsize);
+ do_indent(-tabsize);
}
#endif /* !NANO_TINY */