mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-09 20:20:32 +00:00
Implement the old dialog backslash behaviour.
I'm not sure whether the old backslash behaviour is really a good idea but now we keep backwards compatibility. Also added a test case.
This commit is contained in:
parent
8bc2434b5b
commit
de9c3ea240
@ -440,7 +440,8 @@ Xu , Xu , Qxu , Qxu , Ql , Ql
|
||||
[/option]
|
||||
[option]
|
||||
# Should have an empty first column.
|
||||
message=" =A nice and black\nToo dark too see?=Take a sip and pass the bottle along"
|
||||
# Should show \/\/ell a nice and black drink. Too dark too see?.
|
||||
message=" =\\/\\/ell a \nice and black drink. Too dark too see?=Take a sip and pass the bottle along"
|
||||
[/option]
|
||||
[/message]
|
||||
[/event]
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
#define WRN_CF LOG_STREAM(warn, config)
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
tcontrol::tcontrol(const unsigned canvas_count)
|
||||
@ -407,8 +409,13 @@ std::string colour_prefix(const SDL_Color& colour)
|
||||
return result.str();
|
||||
}
|
||||
|
||||
/** escapes a string to be used in a pango formatted string. */
|
||||
std::string escape_string(const std::string& str)
|
||||
/**
|
||||
* Escapes a string to be used in a pango formatted string.
|
||||
*
|
||||
* This function also changes every "\x" to "x" thus also "\\" to "\". This
|
||||
* is used to mimic the old dialog behaviour.
|
||||
*/
|
||||
std::string escape_string(std::string str)
|
||||
{
|
||||
struct tconverter
|
||||
{
|
||||
@ -425,6 +432,13 @@ std::string escape_string(const std::string& str)
|
||||
gchar* str;
|
||||
};
|
||||
|
||||
size_t offset = str.find('\\', 0);
|
||||
while (offset != std::string::npos) {
|
||||
str.erase(offset, 1);
|
||||
++offset;
|
||||
offset = str.find('\\', offset);
|
||||
}
|
||||
|
||||
tconverter converter(str);
|
||||
return std::string(converter.str);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user