mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-18 17:29:28 +03:00
Merge branch '3119_format_paragraph'
* 3119_format_paragraph: Add editor_stop_format_chars ini option. (format_paragraph): fix wrong refactoring. Ticket #3119: fix format paragrap formatting.
This commit is contained in:
commit
bc2f24b0e5
@ -598,6 +598,12 @@ Use
|
||||
.B spell_language = NONE
|
||||
to disable aspell support. Default value is 'en'. Option must located
|
||||
in the [Misc] section.
|
||||
.TP
|
||||
.I editor_stop_format_chars
|
||||
Set of characters to stop paragraph formatting. If one of those characters
|
||||
is found in the begin of line, that line and all following lines of paragraph
|
||||
will be untouched. Default value is
|
||||
"\fB-\fR\fB+\fR\fB*\fR\fB\\\fR\fB,\fR\fB.\fR\fB;\fR\fB:\fR\fB&\fR\fB>\fR".
|
||||
.SH MISCELLANEOUS
|
||||
You can use scanf search and replace to search and replace a C format
|
||||
string. First take a look at the
|
||||
|
@ -49,6 +49,7 @@ extern int option_syntax_highlighting;
|
||||
extern int option_group_undo;
|
||||
extern char *option_backup_ext;
|
||||
extern char *option_filesize_threshold;
|
||||
extern char *option_stop_format_chars;
|
||||
|
||||
extern int edit_confirm_save;
|
||||
|
||||
|
@ -57,11 +57,12 @@
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
char *option_stop_format_chars = NULL;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
#define tab_width option_tab_spacing
|
||||
|
||||
#define NO_FORMAT_CHARS_START "-+*\\,.;:&>"
|
||||
#define FONT_MEAN_WIDTH 1
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
@ -112,7 +113,7 @@ bad_line_start (const edit_buffer_t * buf, off_t p)
|
||||
&& edit_buffer_get_byte (buf, p + 2) == '-');
|
||||
}
|
||||
|
||||
return (strchr (NO_FORMAT_CHARS_START, c) != NULL);
|
||||
return (option_stop_format_chars != NULL && strchr (option_stop_format_chars, c) != NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -316,7 +317,6 @@ word_start (unsigned char *t, off_t q, off_t size)
|
||||
return (-1);
|
||||
if (c == ' ' || c == '\t')
|
||||
return i;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,15 +498,29 @@ format_paragraph (WEdit * edit, gboolean force)
|
||||
if (!force)
|
||||
{
|
||||
off_t i;
|
||||
char *stop_format_chars;
|
||||
|
||||
if (strchr (NO_FORMAT_CHARS_START, t->str[0]) == NULL)
|
||||
for (i = 0; i < size - 1; i++)
|
||||
if (t->str[i] == '\n'
|
||||
&& strchr (NO_FORMAT_CHARS_START "\t ", t->str[i + 1]) != NULL)
|
||||
break;
|
||||
if (option_stop_format_chars != NULL
|
||||
&& strchr (option_stop_format_chars, t->str[0]) != NULL)
|
||||
{
|
||||
g_string_free (t, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_free (t, TRUE);
|
||||
return;
|
||||
if (option_stop_format_chars == NULL || *option_stop_format_chars == '\0')
|
||||
stop_format_chars = g_strdup ("\t");
|
||||
else
|
||||
stop_format_chars = g_strconcat (option_stop_format_chars, "\t", (char *) NULL);
|
||||
|
||||
for (i = 0; i < size - 1; i++)
|
||||
if (t->str[i] == '\n' && strchr (stop_format_chars, t->str[i + 1]) != NULL)
|
||||
{
|
||||
g_free (stop_format_chars);
|
||||
g_string_free (t, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
g_free (stop_format_chars);
|
||||
}
|
||||
|
||||
t2 = (unsigned char *) g_string_free (t, FALSE);
|
||||
|
@ -376,6 +376,7 @@ static const struct
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
{ "editor_backup_extension", &option_backup_ext, "~" },
|
||||
{ "editor_filesize_threshold", &option_filesize_threshold, "64M" },
|
||||
{ "editor_stop_format_chars", &option_stop_format_chars, "-+*\\,.;:&>" },
|
||||
#endif
|
||||
{ "mcview_eof", &mcview_show_eof, "" },
|
||||
{ NULL, NULL, NULL }
|
||||
|
Loading…
Reference in New Issue
Block a user