chars.c), move_left() (renamed move_mbleft() and moved to
chars.c), move_right() (renamed move_mbright() and moved to
chars.c), do_home(), do_verbatim_input(), do_delete(),
- do_tab(), do_next_word(), do_prev_word(), do_input(),
- do_output(), strstrwrapper(), get_buffer(), unget_input(),
- unget_kbinput(), get_input(), parse_kbinput(),
- unparse_kbinput(), parse_verbatim_kbinput(),
+ do_tab(), do_enter(), indent_length(), do_next_word(),
+ do_prev_word(), do_input(), do_output(), strstrwrapper(),
+ get_buffer(), unget_input(), unget_kbinput(), get_input(),
+ parse_kbinput(), unparse_kbinput(), parse_verbatim_kbinput(),
do_statusbar_input(), do_statusbar_home(),
do_statusbar_verbatim_kbinput(), do_statusbar_output(), and
display_string(); removal of buffer_to_keys() and
#ifndef NANO_SMALL
if (ISSET(SMART_HOME)) {
size_t current_x_save = current_x;
- char *blank_mb = charalloc(mb_cur_max());
- int blank_mb_len;
- current_x = 0;
-
- while (current->data[current_x] != '\0') {
- blank_mb_len = parse_mbchar(current->data + current_x,
- blank_mb
-#ifdef NANO_WIDE
- , NULL
-#endif
- , NULL);
-
- if (!is_blank_mbchar(blank_mb))
- break;
-
- current_x += blank_mb_len;
- }
-
- free(blank_mb);
+ current_x = indent_length(current->data);
if (current_x == current_x_save ||
current->data[current_x] == '\0')
{
size_t pww_save = placewewant;
const filestruct *current_save = current;
- char *char_mb = charalloc(mb_cur_max());
+ char *char_mb;
int char_mb_len;
assert(current != NULL && current->data != NULL);
+ char_mb = charalloc(mb_cur_max());
+
/* Move forward until we find the character after the last letter of
* the current word. */
while (current->data[current_x] != '\0') {
{
size_t pww_save = placewewant;
const filestruct *current_save = current;
- char *char_mb = charalloc(mb_cur_max());
+ char *char_mb;
int char_mb_len;
bool begin_line = FALSE;
assert(current != NULL && current->data != NULL);
+ char_mb = charalloc(mb_cur_max());
+
/* Move backward until we find the character before the first letter
* of the current word. */
while (!begin_line) {
if (ISSET(AUTOINDENT)) {
/* Indentation comes from the next line if wrapping, else from
* this line. */
- indentation = (wrapping ? wrap_line : inptr->data);
+ indentation = wrapping ? wrap_line : inptr->data;
indent_len = indent_length(indentation);
if (wrapping)
/* The wrap_line text should not duplicate indentation.
}
#endif /* !DISABLE_SPELLER */
-#if !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
+#ifndef NANO_SMALL
/* The "indentation" of a line is the whitespace between the quote part
* and the non-whitespace of the line. */
size_t indent_length(const char *line)
{
size_t len = 0;
+ char *blank_mb;
+ int blank_mb_len;
assert(line != NULL);
- while (is_blank_char(*line)) {
- line++;
- len++;
+
+ blank_mb = charalloc(mb_cur_max());
+
+ while (*line != '\0') {
+ blank_mb_len = parse_mbchar(line, blank_mb
+#ifdef NANO_WIDE
+ , NULL
+#endif
+ , NULL);
+
+ if (!is_blank_mbchar(blank_mb))
+ break;
+
+ line += blank_mb_len;
+ len += blank_mb_len;
}
+
+ free(blank_mb);
+
return len;
}
-#endif /* !NANO_SMALL || !DISABLE_JUSTIFY */
+#endif /* !NANO_SMALL */
#ifndef DISABLE_JUSTIFY
/* justify_format() replaces Tab by Space and multiple spaces by 1
#ifndef NANO_SMALL
if (ISSET(SMART_HOME)) {
size_t statusbar_x_save = statusbar_x;
- char *blank_mb = charalloc(mb_cur_max());
- int blank_mb_len;
- statusbar_x = 0;
-
- while (statusbar_x < statusbar_xend) {
- blank_mb_len = parse_mbchar(answer + statusbar_x,
- blank_mb
-#ifdef NANO_WIDE
- , NULL
-#endif
- , NULL);
-
- if (!is_blank_mbchar(blank_mb))
- break;
-
- statusbar_x += blank_mb_len;
- }
-
- free(blank_mb);
+ statusbar_x = indent_length(answer);
if (statusbar_x == statusbar_x_save ||
statusbar_x == statusbar_xend)
#ifndef NANO_SMALL
void do_statusbar_next_word(void)
{
- char *char_mb = charalloc(mb_cur_max());
+ char *char_mb;
int char_mb_len;
assert(answer != NULL);
+ char_mb = charalloc(mb_cur_max());
+
/* Move forward until we find the character after the last letter of
* the current word. */
while (statusbar_x < statusbar_xend) {
void do_statusbar_prev_word(void)
{
- char *char_mb = charalloc(mb_cur_max());
+ char *char_mb;
int char_mb_len;
bool begin_line = FALSE;
assert(answer != NULL);
+ char_mb = charalloc(mb_cur_max());
+
/* Move backward until we find the character before the first letter
* of the current word. */
while (!begin_line) {