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ZDDXZTJFQJXY6PWKBDJXAOLY3FZAD6WHTUTQC
TOOHYAX73C5KPSWGHPCBWCUN62WMMO3BI5CWEEMGV3WBFZ5RIH5AC
5Z6ZTK37C3X2YBHO2HX3ULMCHKQXDUDMX4TUIRCBTTP2IQ57BVQAC
L4UCVNVRFTHENDKDOY6X75LXIE2B7XIMSKGVKHBOXNID7RDTBQRAC
2N5AKUYV6EUUT254C47WSHZKD7FGN65JKJ3RCKSDP74XJIHIFMDQC
SJP5BHX6MFWF3OSQPEF4WUWZWPUGMOVURTT2CUVT6H3A66LETXUAC
GTPAKUU3R5AS3LQNCCZIP3BWV473RM4EB2AIS4FXAJRXHEOVH2PAC
WCK6TM2ZD56WSOK6SMMKBYAYGG4OUCTILLMVVLMB4QO5I5S2IVNAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
BW3XFNOS6LDAQLHOZ6RXARCMKCY5JVLVDSXDSSAX4DSYM3FANQBAC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
SVY2PTCLXR3KNPQAWXVXTTGCC5DR334HOAKHYO3VDDRWM2BWMALAC
ID2OZJTHFXL74RVUCS3JCMDQEUHAXCQFZU7235VU6IEVAAUWD2FAC
EOMCPVNQLX3IMLC46EAO67DPBH5KEG2FQTPBLGU62HIRWA3UQ7XQC
4XGOVPFCU6KZIYHKWCHUTZY6G5S326DKBG3UREPR34Q4TSDD3TAAC
"one and the same. To search for one turn, press <w>s<magenta>, "
"<w>.<magenta>, <w>delete<magenta> or <w>keypad-5<magenta>. "
"Pressing <w>5<magenta> or <w>shift-and-keypad-5<magenta> will "
"one and the same. To search for one turn, press <w>s</w>, "
"<w>.</w>, <w>delete</w> or <w>keypad-5</w>. "
"Pressing <w>5</w> or <w>shift-and-keypad-5</w> will "
"<w>?:<magenta> to read it. You can enter notes manually with "
"the <w>:<magenta> command. Once your character perishes, two "
"morgue files are left in the <w>/morgue<magenta> directory. "
"<w>?:</w> to read it. You can enter notes manually with "
"the <w>:</w> command. Once your character perishes, two "
"morgue files are left in the <w>/morgue</w> directory. "
"explained in the file <w>crawl_options.txt<magenta> which "
"can be found in the <w>docs<magenta> directory. The "
"options themselves are set in <w>init.txt<magenta> or "
"<w>.crawlrc<magenta>. Crawl will complain if it can't "
"explained in the file <w>crawl_options.txt</w> which "
"can be found in the <w>docs</w> directory. The "
"options themselves are set in <w>init.txt</w> or "
"<w>.crawlrc</w>. Crawl will complain if it can't "
text += "If you don't want to eat it, consider <w>D<magenta>issecting "
"this corpse under <w>p<magenta>rayer as a sacrifice to ";
text += "If you don't want to eat it, consider <w>D</w>issecting "
"this corpse under <w>p</w>rayer as a sacrifice to ";
static std::string colour_to_tag(int col, bool closed = false)
// As safely as possible, colourize the passed glyph.
// Handles quoting "<", MBCS-ing unicode, and
// making DEC characters safe if not properly printable.
static std::string colourize_glyph(int col, unsigned glyph)
std::string tag = "<";
if (closed)
tag += "/";
tag += colour_to_str(col);
tag += ">";
return tag;
std::string colour_str = colour_to_str(col);
std::ostringstream text;
text << "<" << colour_str << ">";
text << stringize_glyph(glyph);
if (glyph == '<') text << '<';
text << "</" << colour_str << ">";
return text.str();
text += colour_to_tag(col);
text += ch;
text += "<magenta> is a monster, usually depicted by a letter. Some typical "
"early monsters look like <brown>r<magenta>, <lightgray>g<magenta>, "
"<darkgray>b<magenta> or <brown>K<magenta>. "
text += colourize_glyph(col, ch);
text += " is a monster, usually depicted by a letter. Some typical "
"early monsters look like <brown>r</brown>, <lightgray>g</lightgray>, "
"<darkgray>b</darkgray> or <brown>K</brown>. "
"bow. If you have a look at your bow with <w>v<magenta>, you'll "
"find an explanation of how to do this. First <w>w<magenta>ield "
"bow. If you have a look at your bow with <w>v</w>, you'll "
"find an explanation of how to do this. First <w>w</w>ield "
text += " is an item. If you move there and press <w>g<magenta> or "
"<w>,<magenta> you will pick it up. "
text += " is an item. If you move there and press <w>g</w> or "
"<w>,</w> you will pick it up. "
"you've picked up. Use <w>W<magenta> to wear it and "
"<w>T<magenta> to take it off again. You can view its "
"properties with <w>v<magenta>.";
"you've picked up. Use <w>W</w> to wear it and "
"<w>T</w> to take it off again. You can view its "
"properties with <w>v</w>.";
"level by following them down (<w>><magenta>). To get back to "
"this level again, press <w><<<magenta> while standing on the "
"level by following them down (<w>></w>). To get back to "
"this level again, press <w><<</w> while standing on the "
"<w>t<magenta>, choose a throwing weapon, e.g. one of your "
"spears, use <w>+<magenta> to select a monster and press "
"<w>.<magenta>, <w>f<magenta> or <w>Enter<magenta>. The closest "
"<w>t</w>, choose a throwing weapon, e.g. one of your "
"spears, use <w>+</w> to select a monster and press "
"<w>.</w>, <w>f</w> or <w>Enter</w>. The closest "
ostr << "You can wield this weapon with <w>w<magenta>, or use "
"<w>'<magenta> to switch between the weapons in slot "
"a and b. (Use <w>=<magenta> to adjust item slots.)";
ostr << "You can wield this weapon with <w>w</w>, or use "
"<w>'</w> to switch between the weapons in slot "
"a and b. (Use <w>=</w> to adjust item slots.)";
ostr << "\n\nTo do magic, type <w>Z<magenta> and "
"choose a spell, e.g. <w>a<magenta> (check "
"with <w>?<magenta>). For attack spells "
ostr << "\n\nTo do magic, type <w>Z</w> and "
"choose a spell, e.g. <w>a</w> (check "
"with <w>?</w>). For attack spells "
"these up (<w><<<magenta>). To get back to this level "
"again, press <w>><magenta> while standing on the "
"these up (<w><<</w>). To get back to this level "
"again, press <w>></w> while standing on the "
"here you can do this by <w>d<magenta>ropping them, "
"then <w>p<magenta>raying. As a follower, pressing "
"<w>^<magenta> allows you to check "
"here you can do this by <w>d</w>ropping them, "
"then <w>p</w>raying. As a follower, pressing "
"<w>^</w> allows you to check "
// output given string as formatted message, but check patterns
// for string stripped of tags and store original tagged string
// for message history
void formatted_message_history(const std::string &st, msg_channel_type channel,
int param)
// output given string as formatted message(s), but check patterns
// for string stripped of tags and store the original tagged string
// for message history. Newlines break the string into multiple
// messages.
//
// If wrap_col > 0, text is wrapped at that column.
//
void formatted_message_history(const std::string &st_nocolor, msg_channel_type channel,
int param, int wrap_col)
// Apply channel color explicitly, so "foo <w>bar</w> baz"
// renders "baz" correctly
std::string st;
{
std::ostringstream text;
const std::string colour_str = colour_to_str(colour);
text << "<" << colour_str << ">"
<< st_nocolor
<< "</" << colour_str << ">";
text.str().swap(st);
}
bool eol_ends_format,
bool eot_ends_format,
bool (*process)(const std::string &tag))
{
// Safe assumption, that incoming color is LIGHTGREY
std::vector<int> colour_stack;
colour_stack.push_back(LIGHTGREY);
formatted_string fs;
parse_string1(s, fs, colour_stack, process);
if (eot_ends_format)
{
if (colour_stack.back() != colour_stack.front())
fs.textcolor(colour_stack.front());
}
return fs;
}
// Parses a formatted string in much the same way as parse_string, but
// handles EOL by creating a new formatted_string.
void formatted_string::parse_string_to_multiple(
const std::string &s,
std::vector<formatted_string> &out)
{
std::vector<int> colour_stack;
colour_stack.push_back(LIGHTGREY);
std::vector<std::string> lines = split_string("\n", s, false, true);
for (int i = 0, size = lines.size(); i < size; ++i)
{
out.push_back(formatted_string());
formatted_string& fs = out.back();
fs.textcolor(colour_stack.back());
parse_string1(lines[i], fs, colour_stack, NULL);
if (colour_stack.back() != colour_stack.front())
fs.textcolor(colour_stack.front());
}
}
// Helper for the other parse_ methods
void formatted_string::parse_string1(
const std::string &s,
formatted_string &fs,
std::vector<int> &colour_stack,
fs.textcolor( curr_colour = new_colour );
if (revert_colour)
{
colour_stack.pop_back();
if (colour_stack.size() < 1)
{
ASSERT(false);
colour_stack.push_back(LIGHTRED);
}
}
else
{
colour_stack.push_back(get_colour(tagtext));
}
// fs.cprintf("%d%d", colour_stack.size(), colour_stack.back());
fs.textcolor(colour_stack.back());
}
std::string formatted_string::to_colour_string() const
{
std::string st;
const int size = ops.size();
for (int i = 0; i < size; ++i)
{
if (ops[i] == FSOP_TEXT) {
// gotta double up those '<' chars ...
uint start = st.size();
st += ops[i].text;
while (true) {
const uint left_angle = st.find('<', start);
if (left_angle == std::string::npos) break;
st.insert(left_angle, "<");
start = left_angle + 2;
}
} else if (ops[i] == FSOP_COLOUR) {
st += "<";
st += colour_to_str(ops[i].x);
st += ">";
}
}
return st;