Skip to content

Commit a82f66a

Browse files
committed
InputText: Word-Wrap: added ImGuiInputTextFlags_WordWrap support. (#3237, #952, #1062, #7363)
1 parent e422a38 commit a82f66a

3 files changed

Lines changed: 135 additions & 34 deletions

File tree

‎imgui_internal.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,15 @@ enum ImGuiHoveredFlagsPrivate_
10151015
// Extend ImGuiInputTextFlags_
10161016
enum ImGuiInputTextFlagsPrivate_
10171017
{
1018+
// [Experimental]
1019+
// Word-wrapping caveats:
1020+
// - Not well tested yet. Please report any incorrect cursor movement, selection behavior etc. bug to https://github.com/ocornut/imgui/issues/3237.
1021+
// - With our current design it is _much_ slower than a regular text field. Editing a <50K buffer will generally be ok, but editing a 1MB buffer will waste meaningful amount of CPU.
1022+
// We are likely to not make the feature public until this is fixed (which requires bigger changes to InputText will be be generally desirable for this and other features)
1023+
// - Wrapping of long words/sections (e.g. words that are larger than available width) is currently visually not pleasing.
1024+
// - Vertical scrollbar is currently always visible.
1025+
ImGuiInputTextFlags_WordWrap = 1 << 24, // InputTextMultine(): wrap lines that are too long. (Ref #3237, #952, #1062)
1026+
10181027
// [Internal]
10191028
ImGuiInputTextFlags_Multiline = 1 << 26, // For internal use by InputTextMultiline()
10201029
ImGuiInputTextFlags_MergedItem = 1 << 27, // For internal use by TempInputText(), will skip calling ItemAdd(). Require bounding-box to strictly match.
@@ -1235,11 +1244,13 @@ struct IMGUI_API ImGuiInputTextState
12351244
int BufCapacity; // end-user buffer capacity (include zero terminator)
12361245
ImVec2 Scroll; // horizontal offset (managed manually) + vertical scrolling (pulled from child window's own Scroll.y)
12371246
int LineCount; // last line count (solely for debugging)
1247+
float WrapWidth; // word-wrapping width
12381248
float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
12391249
bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
12401250
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
12411251
bool Edited; // edited this frame
12421252
bool WantReloadUserBuf; // force a reload of user buf so it may be modified externally. may be automatic in future version.
1253+
ImS8 LastMoveDirectionLR; // ImGuiDir_Left or ImGuiDir_Right. track last movement direction so when cursor cross over a word-wrapping boundaries we can display it on either line depending on last move.s
12431254
int ReloadSelectionStart;
12441255
int ReloadSelectionEnd;
12451256

0 commit comments

Comments
 (0)
⌂ 换网址