Skip to content

Commit 8eafec4

Browse files
committed
Separator: rename property length with times
1 parent 5f9e7c7 commit 8eafec4

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

doc/json_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3687,8 +3687,8 @@
36873687
"description": "Set the color of the separator line",
36883688
"$ref": "#/$defs/outputColor"
36893689
},
3690-
"length": {
3691-
"description": "Set the length of the separator line, or 0 to auto-detect",
3690+
"times": {
3691+
"description": "Set the times of separator string to repeat, or 0 to auto-detect",
36923692
"type": "integer",
36933693
"minimum": 0,
36943694
"default": 0

src/modules/separator/option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ typedef struct FFSeparatorOptions
66
{
77
FFstrbuf string;
88
FFstrbuf outputColor;
9-
uint32_t length;
9+
uint32_t times;
1010
} FFSeparatorOptions;
1111

1212
static_assert(sizeof(FFSeparatorOptions) <= FF_OPTION_MAX_SIZE, "FFSeparatorOptions size exceeds maximum allowed size");

src/modules/separator/separator.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ bool ffPrintSeparator(FFSeparatorOptions* options)
4040
if(options->outputColor.length && !instance.config.display.pipe)
4141
ffPrintColor(&options->outputColor);
4242

43-
if (options->length > 0)
43+
if (options->times > 0)
4444
{
4545
if(__builtin_expect(options->string.length == 1, 1))
46-
ffPrintCharTimes(options->string.chars[0], options->length);
46+
ffPrintCharTimes(options->string.chars[0], options->times);
4747
else
4848
{
49-
for (uint32_t i = 0; i < options->length; i++)
49+
for (uint32_t i = 0; i < options->times; i++)
5050
{
5151
fputs(options->string.chars, stdout);
5252
}
@@ -136,9 +136,15 @@ void ffParseSeparatorJsonObject(FFSeparatorOptions* options, yyjson_val* module)
136136
continue;
137137
}
138138

139+
if (unsafe_yyjson_equals_str(key, "times"))
140+
{
141+
options->times = (uint32_t) yyjson_get_uint(val);
142+
continue;
143+
}
144+
139145
if (unsafe_yyjson_equals_str(key, "length"))
140146
{
141-
options->length = (uint32_t) yyjson_get_uint(val);
147+
ffPrintError(FF_SEPARATOR_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "The option length has been renamed to times.");
142148
continue;
143149
}
144150

@@ -150,14 +156,14 @@ void ffGenerateSeparatorJsonConfig(FFSeparatorOptions* options, yyjson_mut_doc*
150156
{
151157
yyjson_mut_obj_add_strbuf(doc, module, "string", &options->string);
152158
yyjson_mut_obj_add_strbuf(doc, module, "outputColor", &options->outputColor);
153-
yyjson_mut_obj_add_uint(doc, module, "length", options->length);
159+
yyjson_mut_obj_add_uint(doc, module, "times", options->times);
154160
}
155161

156162
void ffInitSeparatorOptions(FFSeparatorOptions* options)
157163
{
158164
ffStrbufInitStatic(&options->string, "-");
159165
ffStrbufInit(&options->outputColor);
160-
options->length = 0;
166+
options->times = 0;
161167
}
162168

163169
void ffDestroySeparatorOptions(FFSeparatorOptions* options)

0 commit comments

Comments
 (0)