Lines Matching defs:edit_state
3043 ImGuiInputTextState* edit_state = &g.InputTextState;
3044 IM_ASSERT(edit_state->ID != 0 && g.ActiveId == edit_state->ID);
3045 IM_ASSERT(Buf == edit_state->TempBuffer.Data);
3047 edit_state->TempBuffer.reserve(new_buf_size + 1);
3048 Buf = edit_state->TempBuffer.Data;
3049 BufSize = edit_state->BufCapacityA = new_buf_size;
3204 // NB: we are only allowed to access 'edit_state' if we are the active widget.
3205 ImGuiInputTextState& edit_state = g.InputTextState;
3212 const bool user_scrolled = is_multiline && g.ActiveId == 0 && edit_state.ID == id && g.ActiveIdPreviousFrame == draw_window->GetIDNoKeepAlive("#SCROLLY");
3225 const int prev_len_w = edit_state.CurLenW;
3227 edit_state.TextW.resize(buf_size+1); // wchar count <= UTF-8 count. we use +1 to make sure that .Data isn't NULL so it doesn't crash.
3228 edit_state.InitialText.resize(init_buf_len + 1); // UTF-8. we use +1 to make sure that .Data isn't NULL so it doesn't crash.
3229 memcpy(edit_state.InitialText.Data, buf, init_buf_len + 1);
3231 edit_state.CurLenW = ImTextStrFromUtf8(edit_state.TextW.Data, buf_size, buf, NULL, &buf_end);
3232 edit_state.CurLenA = (int)(buf_end - buf); // We can't get the result from ImStrncpy() above because it is not UTF-8 aware. Here we'll cut off malformed UTF-8.
3233 edit_state.CursorAnimReset();
3236 // FIXME: We should probably compare the whole buffer to be on the safety side. Comparing buf (utf8) and edit_state.Text (wchar).
3237 const bool recycle_state = (edit_state.ID == id) && (prev_len_w == edit_state.CurLenW);
3242 edit_state.CursorClamp();
3246 edit_state.ID = id;
3247 edit_state.ScrollX = 0.0f;
3248 stb_textedit_initialize_state(&edit_state.StbState, !is_multiline);
3253 edit_state.StbState.insert_mode = 1;
3279 edit_state.TextW.resize(buf_size+1);
3281 edit_state.CurLenW = ImTextStrFromUtf8(edit_state.TextW.Data, edit_state.TextW.Size, buf, NULL, &buf_end);
3282 edit_state.CurLenA = (int)(buf_end - buf);
3283 edit_state.CursorClamp();
3286 backup_current_text_length = edit_state.CurLenA;
3287 edit_state.BufCapacityA = buf_size;
3288 edit_state.UserFlags = flags;
3289 edit_state.UserCallback = callback;
3290 edit_state.UserCallbackData = callback_user_data;
3298 const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + edit_state.ScrollX;
3304 edit_state.SelectAll();
3305 edit_state.SelectedAllMouseLock = true;
3310 edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT);
3311 edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT);
3313 else if (io.MouseClicked[0] && !edit_state.SelectedAllMouseLock)
3317 stb_textedit_click(&edit_state, &edit_state.StbState, mouse_x, mouse_y);
3318 edit_state.CursorAnimReset();
3321 else if (io.MouseDown[0] && !edit_state.SelectedAllMouseLock && (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f))
3323 stb_textedit_drag(&edit_state, &edit_state.StbState, mouse_x, mouse_y);
3324 edit_state.CursorAnimReset();
3325 edit_state.CursorFollow = true;
3327 if (edit_state.SelectedAllMouseLock && !io.MouseDown[0])
3328 edit_state.SelectedAllMouseLock = false;
3341 edit_state.OnKeyPressed((int)c);
3362 const bool is_cut = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && is_editable && !is_password && (!is_multiline || edit_state.HasSelection());
3363 const bool is_copy = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || edit_state.HasSelection());
3368 if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); }
3369 else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); }
3370 else if (IsKeyPressedMap(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetWindowScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); }
3371 else if (IsKeyPressedMap(ImGuiKey_DownArrow) && is_multiline) { if (io.KeyCtrl) SetWindowScrollY(draw_window, ImMin(draw_window->Scroll.y + g.FontSize, GetScrollMaxY())); else edit_state.OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTEND : STB_TEXTEDIT_K_DOWN) | k_mask); }
3372 else if (IsKeyPressedMap(ImGuiKey_Home)) { edit_state.OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); }
3373 else if (IsKeyPressedMap(ImGuiKey_End)) { edit_state.OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); }
3374 else if (IsKeyPressedMap(ImGuiKey_Delete) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); }
3377 if (!edit_state.HasSelection())
3379 if (is_wordmove_key_down) edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT|STB_TEXTEDIT_K_SHIFT);
3380 else if (is_osx && io.KeySuper && !io.KeyAlt && !io.KeyCtrl) edit_state.OnKeyPressed(STB_TEXTEDIT_K_LINESTART|STB_TEXTEDIT_K_SHIFT);
3382 edit_state.OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
3395 edit_state.OnKeyPressed((int)c);
3402 edit_state.OnKeyPressed((int)c);
3410 edit_state.OnKeyPressed(is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO);
3411 edit_state.ClearSelection();
3415 edit_state.SelectAll();
3416 edit_state.CursorFollow = true;
3423 const int ib = edit_state.HasSelection() ? ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end) : 0;
3424 const int ie = edit_state.HasSelection() ? ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end) : edit_state.CurLenW;
3425 edit_state.TempBuffer.resize((ie-ib) * 4 + 1);
3426 ImTextStrToUtf8(edit_state.TempBuffer.Data, edit_state.TempBuffer.Size, edit_state.TextW.Data+ib, edit_state.TextW.Data+ie);
3427 SetClipboardText(edit_state.TempBuffer.Data);
3431 if (!edit_state.HasSelection())
3432 edit_state.SelectAll();
3433 edit_state.CursorFollow = true;
3434 stb_textedit_cut(&edit_state, &edit_state.StbState);
3458 stb_textedit_paste(&edit_state, &edit_state.StbState, clipboard_filtered, clipboard_filtered_len);
3459 edit_state.CursorFollow = true;
3473 if (is_editable && strcmp(buf, edit_state.InitialText.Data) != 0)
3475 apply_new_text = edit_state.InitialText.Data;
3476 apply_new_text_length = edit_state.InitialText.Size - 1;
3491 edit_state.TempBuffer.resize(edit_state.TextW.Size * 4 + 1);
3492 ImTextStrToUtf8(edit_state.TempBuffer.Data, edit_state.TempBuffer.Size, edit_state.TextW.Data, NULL);
3530 callback_data.Buf = edit_state.TempBuffer.Data;
3531 callback_data.BufTextLen = edit_state.CurLenA;
3532 callback_data.BufSize = edit_state.BufCapacityA;
3536 ImWchar* text = edit_state.TextW.Data;
3537 const int utf8_cursor_pos = callback_data.CursorPos = ImTextCountUtf8BytesFromStr(text, text + edit_state.StbState.cursor);
3538 const int utf8_selection_start = callback_data.SelectionStart = ImTextCountUtf8BytesFromStr(text, text + edit_state.StbState.select_start);
3539 const int utf8_selection_end = callback_data.SelectionEnd = ImTextCountUtf8BytesFromStr(text, text + edit_state.StbState.select_end);
3545 IM_ASSERT(callback_data.Buf == edit_state.TempBuffer.Data); // Invalid to modify those fields
3546 IM_ASSERT(callback_data.BufSize == edit_state.BufCapacityA);
3548 if (callback_data.CursorPos != utf8_cursor_pos) { edit_state.StbState.cursor = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.CursorPos); edit_state.CursorFollow = true; }
3549 if (callback_data.SelectionStart != utf8_selection_start) { edit_state.StbState.select_start = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionStart); }
3550 if (callback_data.SelectionEnd != utf8_selection_end) { edit_state.StbState.select_end = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionEnd); }
3555 edit_state.TextW.resize(edit_state.TextW.Size + (callback_data.BufTextLen - backup_current_text_length));
3556 edit_state.CurLenW = ImTextStrFromUtf8(edit_state.TextW.Data, edit_state.TextW.Size, callback_data.Buf, NULL);
3557 edit_state.CurLenA = callback_data.BufTextLen; // Assume correct length and valid UTF-8 from user, saves us an extra strlen()
3558 edit_state.CursorAnimReset();
3564 if (is_editable && strcmp(edit_state.TempBuffer.Data, buf) != 0)
3566 apply_new_text = edit_state.TempBuffer.Data;
3567 apply_new_text_length = edit_state.CurLenA;
3597 edit_state.UserFlags = 0;
3598 edit_state.UserCallback = NULL;
3599 edit_state.UserCallbackData = NULL;
3608 const char* buf_display = (g.ActiveId == id && is_editable) ? edit_state.TempBuffer.Data : buf; buf = NULL;
3624 const bool is_currently_scrolling = (edit_state.ID == id && is_multiline && g.ActiveId == draw_window->GetIDNoKeepAlive("#SCROLLY"));
3627 edit_state.CursorAnim += io.DeltaTime;
3635 const ImWchar* text_begin = edit_state.TextW.Data;
3641 searches_input_ptr[0] = text_begin + edit_state.StbState.cursor;
3645 if (edit_state.StbState.select_start != edit_state.StbState.select_end)
3647 searches_input_ptr[1] = text_begin + ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end);
3683 if (edit_state.CursorFollow)
3689 if (cursor_offset.x < edit_state.ScrollX)
3690 edit_state.ScrollX = (float)(int)ImMax(0.0f, cursor_offset.x - scroll_increment_x);
3691 else if (cursor_offset.x - size.x >= edit_state.ScrollX)
3692 edit_state.ScrollX = (float)(int)(cursor_offset.x - size.x + scroll_increment_x);
3696 edit_state.ScrollX = 0.0f;
3712 edit_state.CursorFollow = false;
3713 const ImVec2 render_scroll = ImVec2(edit_state.ScrollX, 0.0f);
3716 if (edit_state.StbState.select_start != edit_state.StbState.select_end)
3718 const ImWchar* text_selected_begin = text_begin + ImMin(edit_state.StbState.select_start, edit_state.StbState.select_end);
3719 const ImWchar* text_selected_end = text_begin + ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end);
3751 const int buf_display_len = edit_state.CurLenA;