summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/macro.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-15 15:26:57 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-15 15:26:57 +0000
commitcc137f4b229d1763c3ad71fe56605b8611a1067c (patch)
tree601f5b148db6c1d94d593d89a11208ae3fa925ad /crawl-ref/source/macro.cc
parent8b6107e382417e437cc541dfad85c20234ca3d7c (diff)
downloadcrawl-ref-cc137f4b229d1763c3ad71fe56605b8611a1067c.tar.gz
crawl-ref-cc137f4b229d1763c3ad71fe56605b8611a1067c.zip
Another code cleanup.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4244 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/macro.cc')
-rw-r--r--crawl-ref/source/macro.cc49
1 files changed, 29 insertions, 20 deletions
diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc
index f834623bd0..74e294c4d7 100644
--- a/crawl-ref/source/macro.cc
+++ b/crawl-ref/source/macro.cc
@@ -342,7 +342,8 @@ static std::string vtostr( const keyseq &seq )
for (keyseq::const_iterator i = v->begin(); i != v->end(); i++)
{
- if (*i <= 32 || *i > 127) {
+ if (*i <= 32 || *i > 127)
+ {
if (*i == KEY_MACRO_MORE_PROTECT)
s << "\\{!more}";
else
@@ -351,11 +352,11 @@ static std::string vtostr( const keyseq &seq )
snprintf( buff, sizeof(buff), "\\{%d}", *i );
s << buff;
}
- } else if (*i == '\\') {
+ }
+ else if (*i == '\\')
s << "\\\\";
- } else {
+ else
s << static_cast<char>(*i);
- }
}
return (s.str());
@@ -462,13 +463,15 @@ static void macro_buf_add_long( keyseq actions,
tmp.pop_back();
}
- if (tmp.size() == 0) {
+ if (tmp.size() == 0)
+ {
// Didn't find a macro. Add the first keypress of the sequence
// into the buffer, remove it from the sequence, and try again.
macro_buf_add( actions.front() );
actions.pop_front();
-
- } else {
+ }
+ else
+ {
// Found a macro, which has already been added above. Now just
// remove the macroed keys from the sequence.
for (unsigned int i = 0; i < tmp.size(); i++)
@@ -572,7 +575,8 @@ void macro_save( void )
f << "# WARNING: This file is entirely auto-generated." << std::endl
<< std::endl << "# Key Mappings:" << std::endl;
- for (int mc = KC_DEFAULT; mc < KC_CONTEXT_COUNT; ++mc) {
+ for (int mc = KC_DEFAULT; mc < KC_CONTEXT_COUNT; ++mc)
+ {
char keybuf[30] = "K:";
if (mc)
snprintf(keybuf, sizeof keybuf, "K%d:", mc);
@@ -610,7 +614,8 @@ static keyseq getch_mul( int (*rgetch)() = NULL )
// The a == 0 test is legacy code that I don't dare to remove. I
// have a vague recollection of it being a kludge for conio support.
- while ((kbhit() || a == 0)) {
+ while (kbhit() || a == 0)
+ {
keys.push_back( a = rgetch() );
}
@@ -826,26 +831,30 @@ static void _read_macros_from(const char* filename)
{
trim_string(s); // remove white space from ends
- if (s[0] == '#') {
- continue; // skip comments
-
- } else if (s.substr(0, 2) == "K:") {
+ if (s[0] == '#')
+ continue; // skip comments
+ else if (s.substr(0, 2) == "K:")
+ {
key = parse_keyseq(s.substr(2));
keymap = true;
keymc = KC_DEFAULT;
-
- } else if (s.length() >= 3 && s[0] == 'K' && s[2] == ':') {
+ }
+ else if (s.length() >= 3 && s[0] == 'K' && s[2] == ':')
+ {
keymc = KeymapContext( KC_DEFAULT + s[1] - '0' );
- if (keymc >= KC_DEFAULT && keymc < KC_CONTEXT_COUNT) {
+ if (keymc >= KC_DEFAULT && keymc < KC_CONTEXT_COUNT)
+ {
key = parse_keyseq(s.substr(3));
keymap = true;
}
-
- } else if (s.substr(0, 2) == "M:") {
+ }
+ else if (s.substr(0, 2) == "M:")
+ {
key = parse_keyseq(s.substr(2));
keymap = false;
-
- } else if (s.substr(0, 2) == "A:") {
+ }
+ else if (s.substr(0, 2) == "A:")
+ {
action = parse_keyseq(s.substr(2));
macro_add( (keymap ? Keymaps[keymc] : Macros), key, action );
}