Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
ImStb Namespace Reference

Functions

static int STB_TEXTEDIT_STRINGLEN (const ImGuiInputTextState *obj)
 
static ImWchar STB_TEXTEDIT_GETCHAR (const ImGuiInputTextState *obj, int idx)
 
static float STB_TEXTEDIT_GETWIDTH (ImGuiInputTextState *obj, int line_start_idx, int char_idx)
 
static int STB_TEXTEDIT_KEYTOTEXT (int key)
 
static void STB_TEXTEDIT_LAYOUTROW (StbTexteditRow *r, ImGuiInputTextState *obj, int line_start_idx)
 
static bool is_separator (unsigned int c)
 
static int is_word_boundary_from_right (ImGuiInputTextState *obj, int idx)
 
static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL (ImGuiInputTextState *obj, int idx)
 
static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL (ImGuiInputTextState *obj, int idx)
 
static void STB_TEXTEDIT_DELETECHARS (ImGuiInputTextState *obj, int pos, int n)
 
static bool STB_TEXTEDIT_INSERTCHARS (ImGuiInputTextState *obj, int pos, const ImWchar *new_text, int new_text_len)
 
static void stb_textedit_replace (ImGuiInputTextState *str, STB_TexteditState *state, const STB_TEXTEDIT_CHARTYPE *text, int text_len)
 

Variables

static ImWchar STB_TEXTEDIT_NEWLINE = '\n'
 

Function Documentation

◆ is_separator()

static bool ImStb::is_separator ( unsigned int  c)
static
3605{ return ImCharIsBlankW(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; }
static bool ImCharIsBlankW(unsigned int c)
Definition imgui_internal.h:322

References ImCharIsBlankW().

Referenced by is_word_boundary_from_right().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_word_boundary_from_right()

static int ImStb::is_word_boundary_from_right ( ImGuiInputTextState obj,
int  idx 
)
static
3606{ if (obj->Flags & ImGuiInputTextFlags_Password) return 0; return idx > 0 ? (is_separator(obj->TextW[idx - 1]) && !is_separator(obj->TextW[idx]) ) : 1; }
@ ImGuiInputTextFlags_Password
Definition imgui.h:971
static bool is_separator(unsigned int c)
Definition imgui_widgets.cpp:3605
ImGuiInputTextFlags Flags
Definition imgui_internal.h:1032
ImVector< ImWchar > TextW
Definition imgui_internal.h:1021

References ImGuiInputTextState::Flags, ImGuiInputTextFlags_Password, is_separator(), and ImGuiInputTextState::TextW.

Referenced by STB_TEXTEDIT_MOVEWORDLEFT_IMPL(), and STB_TEXTEDIT_MOVEWORDRIGHT_IMPL().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ STB_TEXTEDIT_DELETECHARS()

static void ImStb::STB_TEXTEDIT_DELETECHARS ( ImGuiInputTextState obj,
int  pos,
int  n 
)
static
3618{
3619 ImWchar* dst = obj->TextW.Data + pos;
3620
3621 // We maintain our buffer length in both UTF-8 and wchar formats
3622 obj->Edited = true;
3623 obj->CurLenA -= ImTextCountUtf8BytesFromStr(dst, dst + n);
3624 obj->CurLenW -= n;
3625
3626 // Offset remaining text (FIXME-OPT: Use memmove)
3627 const ImWchar* src = obj->TextW.Data + pos + n;
3628 while (ImWchar c = *src++)
3629 *dst++ = c;
3630 *dst = '\0';
3631}
int ImTextCountUtf8BytesFromStr(const ImWchar *in_text, const ImWchar *in_text_end)
Definition imgui.cpp:1771
ImWchar16 ImWchar
Definition imgui.h:220
int CurLenW
Definition imgui_internal.h:1020
int CurLenA
Definition imgui_internal.h:1020
bool Edited
Definition imgui_internal.h:1031
T * Data
Definition imgui.h:1657

References ImGuiInputTextState::CurLenA, ImGuiInputTextState::CurLenW, ImVector< T >::Data, ImGuiInputTextState::Edited, ImTextCountUtf8BytesFromStr(), and ImGuiInputTextState::TextW.

Referenced by stb_textedit_replace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ STB_TEXTEDIT_GETCHAR()

static ImWchar ImStb::STB_TEXTEDIT_GETCHAR ( const ImGuiInputTextState obj,
int  idx 
)
static
3587{ return obj->TextW[idx]; }

References ImGuiInputTextState::TextW.

◆ STB_TEXTEDIT_GETWIDTH()

static float ImStb::STB_TEXTEDIT_GETWIDTH ( ImGuiInputTextState obj,
int  line_start_idx,
int  char_idx 
)
static
3588{ ImWchar c = obj->TextW[line_start_idx + char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *GImGui; return g.Font->GetCharAdvance(c) * (g.FontSize / g.Font->FontSize); }
ImGuiContext * GImGui
Definition imgui.cpp:960
#define STB_TEXTEDIT_GETWIDTH_NEWLINE
Definition imgui_internal.h:177
float FontSize
Definition imgui.h:2694
float GetCharAdvance(ImWchar c) const
Definition imgui.h:2718
Definition imgui_internal.h:1351
ImFont * Font
Definition imgui_internal.h:1356
float FontSize
Definition imgui_internal.h:1357

References ImGuiContext::Font, ImFont::FontSize, ImGuiContext::FontSize, ImFont::GetCharAdvance(), GImGui, STB_TEXTEDIT_GETWIDTH_NEWLINE, and ImGuiInputTextState::TextW.

+ Here is the call graph for this function:

◆ STB_TEXTEDIT_INSERTCHARS()

static bool ImStb::STB_TEXTEDIT_INSERTCHARS ( ImGuiInputTextState obj,
int  pos,
const ImWchar new_text,
int  new_text_len 
)
static
3634{
3635 const bool is_resizable = (obj->Flags & ImGuiInputTextFlags_CallbackResize) != 0;
3636 const int text_len = obj->CurLenW;
3637 IM_ASSERT(pos <= text_len);
3638
3639 const int new_text_len_utf8 = ImTextCountUtf8BytesFromStr(new_text, new_text + new_text_len);
3640 if (!is_resizable && (new_text_len_utf8 + obj->CurLenA + 1 > obj->BufCapacityA))
3641 return false;
3642
3643 // Grow internal buffer if needed
3644 if (new_text_len + text_len + 1 > obj->TextW.Size)
3645 {
3646 if (!is_resizable)
3647 return false;
3648 IM_ASSERT(text_len < obj->TextW.Size);
3649 obj->TextW.resize(text_len + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1);
3650 }
3651
3652 ImWchar* text = obj->TextW.Data;
3653 if (pos != text_len)
3654 memmove(text + pos + new_text_len, text + pos, (size_t)(text_len - pos) * sizeof(ImWchar));
3655 memcpy(text + pos, new_text, (size_t)new_text_len * sizeof(ImWchar));
3656
3657 obj->Edited = true;
3658 obj->CurLenW += new_text_len;
3659 obj->CurLenA += new_text_len_utf8;
3660 obj->TextW[obj->CurLenW] = '\0';
3661
3662 return true;
3663}
@ ImGuiInputTextFlags_CallbackResize
Definition imgui.h:974
#define IM_ASSERT(_EXPR)
Definition imgui.h:81
static T ImClamp(T v, T mn, T mx)
Definition imgui_internal.h:411
static T ImMax(T lhs, T rhs)
Definition imgui_internal.h:410
int BufCapacityA
Definition imgui_internal.h:1025
int Size
Definition imgui.h:1655
void resize(int new_size)
Definition imgui.h:1690

References ImGuiInputTextState::BufCapacityA, ImGuiInputTextState::CurLenA, ImGuiInputTextState::CurLenW, ImVector< T >::Data, ImGuiInputTextState::Edited, ImGuiInputTextState::Flags, IM_ASSERT, ImClamp(), ImGuiInputTextFlags_CallbackResize, ImMax(), ImTextCountUtf8BytesFromStr(), ImVector< T >::resize(), ImVector< T >::Size, and ImGuiInputTextState::TextW.

Referenced by stb_textedit_replace().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ STB_TEXTEDIT_KEYTOTEXT()

static int ImStb::STB_TEXTEDIT_KEYTOTEXT ( int  key)
static
3589{ return key >= 0x200000 ? 0 : key; }

◆ STB_TEXTEDIT_LAYOUTROW()

static void ImStb::STB_TEXTEDIT_LAYOUTROW ( StbTexteditRow r,
ImGuiInputTextState obj,
int  line_start_idx 
)
static
3592{
3593 const ImWchar* text = obj->TextW.Data;
3594 const ImWchar* text_remaining = NULL;
3595 const ImVec2 size = InputTextCalcTextSizeW(text + line_start_idx, text + obj->CurLenW, &text_remaining, NULL, true);
3596 r->x0 = 0.0f;
3597 r->x1 = size.x;
3598 r->baseline_y_delta = size.y;
3599 r->ymin = 0.0f;
3600 r->ymax = size.y;
3601 r->num_chars = (int)(text_remaining - (text + line_start_idx));
3602}
static ImVec2 InputTextCalcTextSizeW(const ImWchar *text_begin, const ImWchar *text_end, const ImWchar **remaining=NULL, ImVec2 *out_offset=NULL, bool stop_on_new_line=false)
Definition imgui_widgets.cpp:3537
int num_chars
Definition imstb_textedit.h:369
float x1
Definition imstb_textedit.h:366
float ymin
Definition imstb_textedit.h:368
float ymax
Definition imstb_textedit.h:368
float baseline_y_delta
Definition imstb_textedit.h:367
float x0
Definition imstb_textedit.h:366
Definition imgui.h:245

References StbTexteditRow::baseline_y_delta, ImGuiInputTextState::CurLenW, ImVector< T >::Data, InputTextCalcTextSizeW(), StbTexteditRow::num_chars, ImGuiInputTextState::TextW, StbTexteditRow::x0, StbTexteditRow::x1, StbTexteditRow::ymax, and StbTexteditRow::ymin.

+ Here is the call graph for this function:

◆ STB_TEXTEDIT_MOVEWORDLEFT_IMPL()

static int ImStb::STB_TEXTEDIT_MOVEWORDLEFT_IMPL ( ImGuiInputTextState obj,
int  idx 
)
static
3607{ idx--; while (idx >= 0 && !is_word_boundary_from_right(obj, idx)) idx--; return idx < 0 ? 0 : idx; }
static int is_word_boundary_from_right(ImGuiInputTextState *obj, int idx)
Definition imgui_widgets.cpp:3606

References is_word_boundary_from_right().

+ Here is the call graph for this function:

◆ STB_TEXTEDIT_MOVEWORDRIGHT_IMPL()

static int ImStb::STB_TEXTEDIT_MOVEWORDRIGHT_IMPL ( ImGuiInputTextState obj,
int  idx 
)
static
3612{ idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_right(obj, idx)) idx++; return idx > len ? len : idx; }

References ImGuiInputTextState::CurLenW, and is_word_boundary_from_right().

+ Here is the call graph for this function:

◆ stb_textedit_replace()

static void ImStb::stb_textedit_replace ( ImGuiInputTextState str,
STB_TexteditState state,
const STB_TEXTEDIT_CHARTYPE text,
int  text_len 
)
static
3690{
3691 stb_text_makeundo_replace(str, state, 0, str->CurLenW, text_len);
3693 if (text_len <= 0)
3694 return;
3695 if (ImStb::STB_TEXTEDIT_INSERTCHARS(str, 0, text, text_len))
3696 {
3697 state->cursor = text_len;
3698 state->has_preferred_x = 0;
3699 return;
3700 }
3701 IM_ASSERT(0); // Failed to insert character, normally shouldn't happen because of how we currently use stb_textedit_replace()
3702}
int cursor
Definition imstb_textedit.h:324
unsigned char has_preferred_x
Definition imstb_textedit.h:348
static void STB_TEXTEDIT_DELETECHARS(ImGuiInputTextState *obj, int pos, int n)
Definition imgui_widgets.cpp:3617
static bool STB_TEXTEDIT_INSERTCHARS(ImGuiInputTextState *obj, int pos, const ImWchar *new_text, int new_text_len)
Definition imgui_widgets.cpp:3633

References ImGuiInputTextState::CurLenW, STB_TexteditState::cursor, STB_TexteditState::has_preferred_x, IM_ASSERT, STB_TEXTEDIT_DELETECHARS(), and STB_TEXTEDIT_INSERTCHARS().

+ Here is the call graph for this function:

◆ STB_TEXTEDIT_STRINGLEN()

static int ImStb::STB_TEXTEDIT_STRINGLEN ( const ImGuiInputTextState obj)
static
3586{ return obj->CurLenW; }

References ImGuiInputTextState::CurLenW.

Variable Documentation

◆ STB_TEXTEDIT_NEWLINE

ImWchar ImStb::STB_TEXTEDIT_NEWLINE = '\n'
static