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