1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 02:57:44 +00:00

Everywhere: "indexes" => "indices"

I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
This commit is contained in:
Andreas Kling 2021-04-29 22:23:52 +02:00
parent 7ae7170d61
commit 3d4afe7614
29 changed files with 139 additions and 139 deletions

View file

@ -618,15 +618,15 @@ void Menu::set_visible(bool visible)
void Menu::add_item(NonnullOwnPtr<MenuItem> item)
{
if (auto alt_shortcut = find_ampersand_shortcut_character(item->text())) {
m_alt_shortcut_character_to_item_indexes.ensure(tolower(alt_shortcut)).append(m_items.size());
m_alt_shortcut_character_to_item_indices.ensure(tolower(alt_shortcut)).append(m_items.size());
}
m_items.append(move(item));
}
const Vector<size_t>* Menu::items_with_alt_shortcut(u32 alt_shortcut) const
{
auto it = m_alt_shortcut_character_to_item_indexes.find(tolower(alt_shortcut));
if (it == m_alt_shortcut_character_to_item_indexes.end())
auto it = m_alt_shortcut_character_to_item_indices.find(tolower(alt_shortcut));
if (it == m_alt_shortcut_character_to_item_indices.end())
return nullptr;
return &it->value;
}

View file

@ -154,7 +154,7 @@ private:
int m_scroll_offset { 0 };
int m_max_scroll_offset { 0 };
HashMap<u32, Vector<size_t>> m_alt_shortcut_character_to_item_indexes;
HashMap<u32, Vector<size_t>> m_alt_shortcut_character_to_item_indices;
};
u32 find_ampersand_shortcut_character(const StringView&);

View file

@ -70,11 +70,11 @@ void MenuManager::event(Core::Event& event)
&& ((key_event.key() >= Key_A && key_event.key() <= Key_Z)
|| (key_event.key() >= Key_0 && key_event.key() <= Key_9))) {
if (auto* shortcut_item_indexes = m_current_menu->items_with_alt_shortcut(key_event.code_point())) {
VERIFY(!shortcut_item_indexes->is_empty());
if (auto* shortcut_item_indices = m_current_menu->items_with_alt_shortcut(key_event.code_point())) {
VERIFY(!shortcut_item_indices->is_empty());
// FIXME: If there are multiple items with the same Alt shortcut, we should cycle through them
// with each keypress instead of activating immediately.
auto index = shortcut_item_indexes->at(0);
auto index = shortcut_item_indices->at(0);
auto& item = m_current_menu->item(index);
m_current_menu->set_hovered_index(index);
if (item.is_submenu())