Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip %+ and %# format flags for scanning #6259

Closed
wants to merge 1 commit into from

Conversation

idbrii
Copy link
Contributor

@idbrii idbrii commented Mar 20, 2023

Fix typed in values are ignored when SliderInt's format specifier includes the + flag:

+: the sign of signed conversions is always prepended to the result of
the conversion (by default the result is preceded by minus only when it
is negative)

Also skip the # flag since it seems valid to use (esp. for octal and hex):

# : alternative form of the conversion is performed. See the table
below for exact effects otherwise the behavior is undefined.

There are two additional unhandled flags that only affect padding:

  • and space. Formatting flags don't make sense in a SliderInt's format string, so I've omitted them.

Test

In this example, editing the value by dragging it to +80º works but when Ctrl-clicking and typing in 10 it reverts to the previous value after hitting Enter:

	if (ImGui::Begin("Hello"))
	{
		static int val = 0;
		ImGui::SliderInt("Slider", &val, 0, 100, "%+dº");
		ImGui::End();
	}

Fix typed in values are ignored when SliderInt's format specifier
includes the + flag:

> +: the sign of signed conversions is always prepended to the result of
> the conversion (by default the result is preceded by minus only when it
> is negative)

Also skip the # flag since it seems valid to use (esp. for octal and hex):

> # : alternative form of the conversion is performed. See the table
> below for exact effects otherwise the behavior is undefined.

There are two additional unhandled flags that only affect padding:
- and space. Formatting flags don't make sense in a SliderInt's format
string, so I've omitted them.

Test
In this example, editing the value by dragging it to +80º works but when
Ctrl-clicking and typing in 10 it reverts to the previous value after
hitting Enter:
	if (ImGui::Begin("Hello"))
	{
		static int val = 0;
		ImGui::SliderInt("Slider", &val, 0, 100, "%+dº");
		ImGui::End();
	}
ocornut pushed a commit that referenced this pull request Mar 21, 2023
(There are two additional unhandled flags that only affect padding: '-' and ' '. Formatting flags don't make sense in a SliderInt's format string, so I've omitted them)
@ocornut
Copy link
Owner

ocornut commented Mar 21, 2023

Merged as cac76b2, thank you very much !

@ocornut ocornut closed this Mar 21, 2023
@idbrii idbrii deleted the signed-sscanf branch March 21, 2023 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants