mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 15:01:28 +12:00
cellImeJp: fix character deletion after change to cursor
This commit is contained in:
parent
675ed82c0b
commit
86bab5b7c3
2 changed files with 39 additions and 20 deletions
|
@ -92,34 +92,52 @@ bool ime_jp_manager::addString(vm::cptr<u16> str)
|
||||||
|
|
||||||
bool ime_jp_manager::backspaceWord()
|
bool ime_jp_manager::backspaceWord()
|
||||||
{
|
{
|
||||||
if (!focus_begin || focus_begin > CELL_IMEJP_STRING_MAXLENGTH || focus_begin > input_string.length())
|
return remove_character(false);
|
||||||
return false;
|
|
||||||
|
|
||||||
// Delete the character in front of the cursor
|
|
||||||
input_string.erase(focus_begin, 1);
|
|
||||||
|
|
||||||
// Move cursors
|
|
||||||
move_focus(-1);
|
|
||||||
|
|
||||||
if (input_string.empty())
|
|
||||||
input_state = CELL_IMEJP_BEFORE_INPUT;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ime_jp_manager::deleteWord()
|
bool ime_jp_manager::deleteWord()
|
||||||
{
|
{
|
||||||
if (focus_begin >= (CELL_IMEJP_STRING_MAXLENGTH - 1ULL) || focus_begin > (input_string.length() - 1))
|
return remove_character(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ime_jp_manager::remove_character(bool forward)
|
||||||
|
{
|
||||||
|
if (!forward && !cursor)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the character at the cursor
|
const usz pos = forward ? cursor : (cursor - 1);
|
||||||
input_string.erase(focus_begin, 1);
|
|
||||||
|
|
||||||
// Sanitize cursors
|
if (pos >= (CELL_IMEJP_STRING_MAXLENGTH - 1ULL) || pos >= input_string.length())
|
||||||
move_focus(0);
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the character at the position
|
||||||
|
input_string.erase(pos, 1);
|
||||||
|
|
||||||
|
// Move cursor and focus
|
||||||
|
const bool deleted_part_of_focus = pos > focus_begin && pos <= (focus_begin + focus_length);
|
||||||
|
|
||||||
|
if (!forward)
|
||||||
|
{
|
||||||
|
move_cursor(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deleted_part_of_focus)
|
||||||
|
{
|
||||||
|
move_focus_end(-1, false);
|
||||||
|
}
|
||||||
|
else if (focus_begin > pos)
|
||||||
|
{
|
||||||
|
move_focus(-1);
|
||||||
|
}
|
||||||
|
|
||||||
if (input_string.empty())
|
if (input_string.empty())
|
||||||
|
{
|
||||||
input_state = CELL_IMEJP_BEFORE_INPUT;
|
input_state = CELL_IMEJP_BEFORE_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -781,7 +799,7 @@ static error_code cellImeJpExtendConvertArea(CellImeJpHandle hImeJpHandle)
|
||||||
return CELL_IMEJP_ERROR_ERR;
|
return CELL_IMEJP_ERROR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move end of cursor by one. Wrap around if the cursor end is already at the end of the input string.
|
// Move end of the focus by one. Wrap around if the focus end is already at the end of the input string.
|
||||||
manager.move_focus_end(1, true);
|
manager.move_focus_end(1, true);
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
|
@ -804,7 +822,7 @@ static error_code cellImeJpShortenConvertArea(CellImeJpHandle hImeJpHandle)
|
||||||
return CELL_IMEJP_ERROR_ERR;
|
return CELL_IMEJP_ERROR_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move end of cursor by one. Wrap around if the cursor end is already at the beginning of the input string.
|
// Move end of focus by one. Wrap around if the focus end is already at the beginning of the input string.
|
||||||
manager.move_focus_end(-1, true);
|
manager.move_focus_end(-1, true);
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
|
|
|
@ -132,6 +132,7 @@ struct ime_jp_manager
|
||||||
bool addString(vm::cptr<u16> str);
|
bool addString(vm::cptr<u16> str);
|
||||||
bool backspaceWord();
|
bool backspaceWord();
|
||||||
bool deleteWord();
|
bool deleteWord();
|
||||||
|
bool remove_character(bool forward);
|
||||||
void clear_input();
|
void clear_input();
|
||||||
void move_cursor(s8 amount); // s8 because CELL_IMEJP_STRING_MAXLENGTH is 128
|
void move_cursor(s8 amount); // s8 because CELL_IMEJP_STRING_MAXLENGTH is 128
|
||||||
void move_focus(s8 amount); // s8 because CELL_IMEJP_STRING_MAXLENGTH is 128
|
void move_focus(s8 amount); // s8 because CELL_IMEJP_STRING_MAXLENGTH is 128
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue