InputHandler: Handle C-c as Escape

This commit is contained in:
Maxime Coste 2012-11-08 14:05:00 +01:00
parent 68cc07022c
commit 0887e1364e

View File

@ -161,7 +161,7 @@ public:
callback(selected, context);
return;
}
else if (key == Key::Escape)
else if (key == Key::Escape or key == Key{ Key::Modifiers::Control, 'c' })
{
if (m_edit_filter)
{
@ -267,7 +267,7 @@ public:
callback(result, context);
return;
}
else if (key == Key::Escape)
else if (key == Key::Escape or key == Key { Key::Modifiers::Control, 'c' })
{
context.ui().print_status("");
context.ui().menu_hide();
@ -494,31 +494,23 @@ public:
return;
}
bool reset_completer = true;
switch (key.modifiers)
if (key == Key::Escape or key == Key{ Key::Modifiers::Control, 'c' })
{
case Key::Modifiers::None:
switch (key.key)
{
case Key::Escape:
m_completer.reset(context);
reset_normal_mode();
return;
case Key::Backspace:
}
else if (key == Key::Backspace)
m_inserter.erase();
break;
case Key::Left:
else if (key == Key::Left)
m_inserter.move_cursors({0, -1});
break;
case Key::Right:
else if (key == Key::Right)
m_inserter.move_cursors({0, 1});
break;
case Key::Up:
else if (key == Key::Up)
m_inserter.move_cursors({-1, 0});
break;
case Key::Down:
else if (key == Key::Down)
m_inserter.move_cursors({ 1, 0});
break;
default:
else if (key.modifiers == Key::Modifiers::None)
{
m_inserter.insert(codepoint_to_str(key.key));
if (m_inserter.editor().selections().size() == 1 and
is_word(key.key))
@ -528,32 +520,23 @@ public:
m_completer.select(context, 0);
}
}
break;
case Key::Modifiers::Control:
switch (key.key)
{
case 'r':
else if (key == Key{ Key::Modifiers::Control, 'r' })
m_insert_reg = true;
break;
case 'm':
else if ( key == Key{ Key::Modifiers::Control, 'm' })
m_inserter.insert(String() + '\n');
break;
case 'i':
else if ( key == Key{ Key::Modifiers::Control, 'i' })
m_inserter.insert(String() + '\t');
break;
case 'n':
else if ( key == Key{ Key::Modifiers::Control, 'n' })
{
m_completer.select(context, 1);
reset_completer = false;
break;
case 'p':
}
else if ( key == Key{ Key::Modifiers::Control, 'p' })
{
m_completer.select(context, -1);
reset_completer = false;
break;
}
break;
default:
break;
}
if (reset_completer)
m_completer.reset(context);
}