diff options
author | 2016-09-19 08:25:10 -0400 | |
---|---|---|
committer | 2016-09-19 08:25:10 -0400 | |
commit | 1a017c93023f489772d53221cda2248f930636ce (patch) | |
tree | ea7f48c10c4950abbd8f6aa4a3510daacb878ce0 /src/frontend/mame/ui/selector.cpp | |
parent | ea15eb91112bff6dc9976d192bf2527b1fe8c37a (diff) |
Consolidated code that inputs characters into buffers
Diffstat (limited to 'src/frontend/mame/ui/selector.cpp')
-rw-r--r-- | src/frontend/mame/ui/selector.cpp | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp index e614bb587e7..8f32c5530dc 100644 --- a/src/frontend/mame/ui/selector.cpp +++ b/src/frontend/mame/ui/selector.cpp @@ -99,28 +99,14 @@ void menu_selector::handle() } else if (menu_event->iptkey == IPT_SPECIAL) { - auto const buflen = strlen(m_search); - if ((menu_event->unichar == 8) || (menu_event->unichar == 0x7f)) - { - // if it's a backspace and we can handle it, do so - if (0 < buflen) - { - *const_cast<char *>(utf8_previous_char(&m_search[buflen])) = 0; - reset(reset_options::SELECT_FIRST); - } - } - else if (menu_event->is_char_printable()) - { - // if it's any other key and we're not maxed out, update - if (menu_event->append_char(m_search, buflen)) - reset(reset_options::SELECT_FIRST); - } + if (input_character(m_search, menu_event->unichar, uchar_is_printable)) + reset(reset_options::SELECT_FIRST); } // escape pressed with non-empty text clears the text else if (menu_event->iptkey == IPT_UI_CANCEL && m_search[0] != 0) { - m_search[0] = '\0'; + m_search.clear(); reset(reset_options::SELECT_FIRST); } } @@ -132,9 +118,9 @@ void menu_selector::handle() void menu_selector::populate() { - if (m_search[0] != 0) + if (!m_search.empty()) { - find_matches(m_search); + find_matches(m_search.c_str()); for (int curitem = 0; m_searchlist[curitem]; ++curitem) item_append(*m_searchlist[curitem], "", 0, (void *)m_searchlist[curitem]); |