MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / updateTextboxAndCursorPos

Function updateTextboxAndCursorPos

src/AndroidJNICalls.cpp:213–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211 }
212
213 void updateTextboxAndCursorPos(CustomEvents::InputTextBoxID tId, const std::shared_ptr<RichText::TextBox>& newTextbox, const std::shared_ptr<RichText::TextBox::Cursor>& newCursor) {
214 std::scoped_lock a{textboxMutex};
215
216 if(tId == textboxID) {
217 *cursor = *newCursor;
218 textBox->set_rich_text_data(newTextbox->get_rich_text_data());
219
220 JNIEnv* env = static_cast<JNIEnv*>(SDL_GetAndroidJNIEnv());
221 jni_local_frame(env, 16, [&] {
222 jobject activity = (jobject) SDL_GetAndroidActivity();
223 jclass clazz = env->GetObjectClass(activity);
224 jmethodID method_id = env->GetStaticMethodID(clazz, "updateCursorPos",
225 "(II)V");
226 env->CallStaticVoidMethod(clazz, method_id,
227 get_android_text_pos_from_cursor_pos(textBox, std::min(
228 cursor->selectionBeginPos,
229 cursor->selectionEndPos)),
230 get_android_text_pos_from_cursor_pos(textBox, std::max(
231 cursor->selectionBeginPos,
232 cursor->selectionEndPos)));
233 });
234 }
235 }
236
237 std::pair<bool, bool> getChangesToCommit(CustomEvents::InputTextBoxID tId) {
238 std::scoped_lock a{textboxMutex};

Calls 4

jni_local_frameFunction · 0.85
set_rich_text_dataMethod · 0.80
get_rich_text_dataMethod · 0.80

Tested by

no test coverage detected