mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 10:47:41 +00:00
LibGUI: Implement case inversion in Vim emulation
When in visual mode with text selected, on Key_Tilde press, uppercase characters convert to lowercase and lowercase ones to uppercase.
This commit is contained in:
parent
8ffa860bc3
commit
2cfbb9a0e8
2 changed files with 9 additions and 1 deletions
|
@ -1149,6 +1149,10 @@ bool VimEditingEngine::on_key_in_visual_mode(KeyEvent const& event)
|
||||||
casefold_selection(Casing::Uppercase);
|
casefold_selection(Casing::Uppercase);
|
||||||
switch_to_normal_mode();
|
switch_to_normal_mode();
|
||||||
return true;
|
return true;
|
||||||
|
case (KeyCode::Key_Tilde):
|
||||||
|
casefold_selection(Casing::Invertcase);
|
||||||
|
switch_to_normal_mode();
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1428,6 +1432,9 @@ void VimEditingEngine::casefold_selection(Casing casing)
|
||||||
case Casing::Lowercase:
|
case Casing::Lowercase:
|
||||||
m_editor->insert_at_cursor_or_replace_selection(m_editor->selected_text().to_lowercase());
|
m_editor->insert_at_cursor_or_replace_selection(m_editor->selected_text().to_lowercase());
|
||||||
return;
|
return;
|
||||||
|
case Casing::Invertcase:
|
||||||
|
m_editor->insert_at_cursor_or_replace_selection(m_editor->selected_text().invert_case());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,8 @@ private:
|
||||||
|
|
||||||
enum class Casing {
|
enum class Casing {
|
||||||
Uppercase,
|
Uppercase,
|
||||||
Lowercase
|
Lowercase,
|
||||||
|
Invertcase
|
||||||
};
|
};
|
||||||
|
|
||||||
VimMode m_vim_mode { VimMode::Normal };
|
VimMode m_vim_mode { VimMode::Normal };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue