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 git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3758 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
7f80174373
commit
aee00d4d14
|
@ -14,6 +14,14 @@ CVS code -
|
||||||
actually blanked. Changes to do_help(), do_continue(),
|
actually blanked. Changes to do_help(), do_continue(),
|
||||||
handle_sigwinch(), and update_statusbar_line(). (DLR)
|
handle_sigwinch(), and update_statusbar_line(). (DLR)
|
||||||
(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:
|
- browser.c:
|
||||||
do_browser()
|
do_browser()
|
||||||
- Refactor the mouse support, modeling it after do_mouse() for
|
- Refactor the mouse support, modeling it after do_mouse() for
|
||||||
|
|
12
src/global.c
12
src/global.c
|
@ -349,8 +349,8 @@ void shortcut_init(bool unjustify)
|
||||||
const char *nano_whereis_next_msg = N_("Repeat last search");
|
const char *nano_whereis_next_msg = N_("Repeat last search");
|
||||||
const char *nano_copy_msg =
|
const char *nano_copy_msg =
|
||||||
N_("Copy the current line and store it in the cutbuffer");
|
N_("Copy the current line and store it in the cutbuffer");
|
||||||
const char *nano_indentmarked_msg = N_("Indent marked text");
|
const char *nano_indent_msg = N_("Indent the current line");
|
||||||
const char *nano_unindentmarked_msg = N_("Unindent marked text");
|
const char *nano_unindent_msg = N_("Unindent the current line");
|
||||||
#endif
|
#endif
|
||||||
const char *nano_forward_msg = N_("Move forward one character");
|
const char *nano_forward_msg = N_("Move forward one character");
|
||||||
const char *nano_back_msg = N_("Move back one character");
|
const char *nano_back_msg = N_("Move back one character");
|
||||||
|
@ -588,12 +588,12 @@ void shortcut_init(bool unjustify)
|
||||||
NANO_COPY_ALTKEY, NOVIEW, do_copy_text);
|
NANO_COPY_ALTKEY, NOVIEW, do_copy_text);
|
||||||
|
|
||||||
sc_init_one(&main_list, NANO_NO_KEY, N_("Indent Text"),
|
sc_init_one(&main_list, NANO_NO_KEY, N_("Indent Text"),
|
||||||
IFHELP(nano_indentmarked_msg, FALSE), NANO_INDENTMARKED_KEY,
|
IFHELP(nano_indent_msg, FALSE), NANO_INDENT_KEY, NANO_NO_KEY,
|
||||||
NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_indent_marked_void);
|
NANO_NO_KEY, NOVIEW, do_indent_void);
|
||||||
|
|
||||||
sc_init_one(&main_list, NANO_NO_KEY, N_("Unindent Text"),
|
sc_init_one(&main_list, NANO_NO_KEY, N_("Unindent Text"),
|
||||||
IFHELP(nano_unindentmarked_msg, TRUE), NANO_UNINDENTMARKED_KEY,
|
IFHELP(nano_unindent_msg, TRUE), NANO_UNINDENT_KEY, NANO_NO_KEY,
|
||||||
NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_unindent_marked_void);
|
NANO_NO_KEY, NOVIEW, do_unindent);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
|
sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
|
||||||
|
|
|
@ -547,8 +547,8 @@ typedef struct rcoption {
|
||||||
#define NANO_DELETE_KEY NANO_CONTROL_D
|
#define NANO_DELETE_KEY NANO_CONTROL_D
|
||||||
#define NANO_BACKSPACE_KEY NANO_CONTROL_H
|
#define NANO_BACKSPACE_KEY NANO_CONTROL_H
|
||||||
#define NANO_TAB_KEY NANO_CONTROL_I
|
#define NANO_TAB_KEY NANO_CONTROL_I
|
||||||
#define NANO_INDENTMARKED_KEY NANO_ALT_RCURLYBRACKET
|
#define NANO_INDENT_KEY NANO_ALT_RCURLYBRACKET
|
||||||
#define NANO_UNINDENTMARKED_KEY NANO_ALT_LCURLYBRACKET
|
#define NANO_UNINDENT_KEY NANO_ALT_LCURLYBRACKET
|
||||||
#define NANO_SUSPEND_KEY NANO_CONTROL_Z
|
#define NANO_SUSPEND_KEY NANO_CONTROL_Z
|
||||||
#define NANO_ENTER_KEY NANO_CONTROL_M
|
#define NANO_ENTER_KEY NANO_CONTROL_M
|
||||||
#define NANO_TOFILES_KEY NANO_CONTROL_T
|
#define NANO_TOFILES_KEY NANO_CONTROL_T
|
||||||
|
|
|
@ -613,9 +613,9 @@ void do_delete(void);
|
||||||
void do_backspace(void);
|
void do_backspace(void);
|
||||||
void do_tab(void);
|
void do_tab(void);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
void do_indent_marked(ssize_t cols);
|
void do_indent(ssize_t cols);
|
||||||
void do_indent_marked_void(void);
|
void do_indent_void(void);
|
||||||
void do_unindent_marked_void(void);
|
void do_unindent(void);
|
||||||
#endif
|
#endif
|
||||||
void do_enter(void);
|
void do_enter(void);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
|
49
src/text.c
49
src/text.c
|
@ -191,12 +191,12 @@ void do_tab(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* Indent or unindent all lines covered by the mark len columns,
|
/* Indent or unindent the current line (or all lines covered by the mark
|
||||||
* depending on whether len is positive or negative. If the
|
* if the mark is on) len columns, depending on whether len is positive
|
||||||
* TABS_TO_SPACES flag is set, indent/unindent by len spaces.
|
* or negative. If the TABS_TO_SPACES flag is set, indent/unindent by
|
||||||
* Otherwise, indent/unindent by (len / tabsize) tabs and (len %
|
* len spaces. Otherwise, indent/unindent by (len / tabsize) tabs and
|
||||||
* tabsize) spaces. */
|
* (len % tabsize) spaces. */
|
||||||
void do_indent_marked(ssize_t cols)
|
void do_indent(ssize_t cols)
|
||||||
{
|
{
|
||||||
bool indent_changed = FALSE;
|
bool indent_changed = FALSE;
|
||||||
/* Whether any indenting or unindenting was done. */
|
/* Whether any indenting or unindenting was done. */
|
||||||
|
@ -212,13 +212,6 @@ void do_indent_marked(ssize_t cols)
|
||||||
|
|
||||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
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 is zero, get out. */
|
||||||
if (cols == 0)
|
if (cols == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -233,9 +226,15 @@ void do_indent_marked(ssize_t cols)
|
||||||
} else
|
} else
|
||||||
indent_changed = TRUE;
|
indent_changed = TRUE;
|
||||||
|
|
||||||
/* Get the coordinates of the marked text. */
|
/* If the mark is on, use all lines covered by the mark. */
|
||||||
|
if (openfile->mark_set)
|
||||||
mark_order((const filestruct **)&top, &top_x,
|
mark_order((const filestruct **)&top, &top_x,
|
||||||
(const filestruct **)&bot, &bot_x, NULL);
|
(const filestruct **)&bot, &bot_x, NULL);
|
||||||
|
/* Otherwise, use the current line. */
|
||||||
|
else {
|
||||||
|
top = openfile->current;
|
||||||
|
bot = top;
|
||||||
|
}
|
||||||
|
|
||||||
if (!unindent) {
|
if (!unindent) {
|
||||||
/* Set up the text we'll be using as indentation. */
|
/* Set up the text we'll be using as indentation. */
|
||||||
|
@ -260,7 +259,7 @@ void do_indent_marked(ssize_t cols)
|
||||||
line_indent[line_indent_len] = '\0';
|
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) {
|
for (f = top; f != bot->next; f = f->next) {
|
||||||
size_t line_len = strlen(f->data);
|
size_t line_len = strlen(f->data);
|
||||||
size_t indent_len = indent_length(f->data);
|
size_t indent_len = indent_length(f->data);
|
||||||
|
@ -276,8 +275,8 @@ void do_indent_marked(ssize_t cols)
|
||||||
openfile->totsize += line_indent_len;
|
openfile->totsize += line_indent_len;
|
||||||
|
|
||||||
/* Keep track of the change in the current line. */
|
/* Keep track of the change in the current line. */
|
||||||
if (f == openfile->mark_begin && openfile->mark_begin_x >=
|
if (openfile->mark_set && f == openfile->mark_begin &&
|
||||||
indent_len)
|
openfile->mark_begin_x >= indent_len)
|
||||||
openfile->mark_begin_x += line_indent_len;
|
openfile->mark_begin_x += line_indent_len;
|
||||||
|
|
||||||
if (f == openfile->current && openfile->current_x >=
|
if (f == openfile->current && openfile->current_x >=
|
||||||
|
@ -311,7 +310,7 @@ void do_indent_marked(ssize_t cols)
|
||||||
openfile->totsize -= indent_shift;
|
openfile->totsize -= indent_shift;
|
||||||
|
|
||||||
/* Keep track of the change in the current line. */
|
/* 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) {
|
openfile->mark_begin_x > indent_new) {
|
||||||
if (openfile->mark_begin_x <= indent_len)
|
if (openfile->mark_begin_x <= indent_len)
|
||||||
openfile->mark_begin_x = indent_new;
|
openfile->mark_begin_x = indent_new;
|
||||||
|
@ -347,16 +346,18 @@ void do_indent_marked(ssize_t cols)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Indent all lines covered by the mark tabsize columns. */
|
/* Indent the current line, or all lines covered by the mark if the mark
|
||||||
void do_indent_marked_void(void)
|
* 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. */
|
/* Unindent the current line, or all lines covered by the mark if the
|
||||||
void do_unindent_marked_void(void)
|
* mark is on, tabsize columns. */
|
||||||
|
void do_unindent(void)
|
||||||
{
|
{
|
||||||
do_indent_marked(-tabsize);
|
do_indent(-tabsize);
|
||||||
}
|
}
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue