diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-11-18 07:09:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-11-18 07:10:51 +0300 |
commit | 0688309988e546382748b9e755d84ae8a5059192 (patch) | |
tree | e1304b73dbce9affde016b202af80434035d0f65 /source/blender/editors/interface/interface_query.c | |
parent | a352baccc399378333c4352ed83772b49f7ba852 (diff) |
Fix undo UI text containing shortcuts & newlines
- Shortcuts were being shown in the undo history.
- Multi-line tool-tips now only use the first line.
Diffstat (limited to 'source/blender/editors/interface/interface_query.c')
-rw-r--r-- | source/blender/editors/interface/interface_query.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index 4ad5d85e959..d0075ba8617 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -447,6 +447,32 @@ bool ui_but_contains_password(const uiBut *but) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Button (#uiBut) Text + * \{ */ + +size_t ui_but_drawstr_len_without_sep_char(const uiBut *but) +{ + if (but->flag & UI_BUT_HAS_SEP_CHAR) { + const char *str_sep = strrchr(but->drawstr, UI_SEP_CHAR); + if (str_sep != NULL) { + return (str_sep - but->drawstr); + } + } + return strlen(but->drawstr); +} + +size_t ui_but_tip_len_only_first_line(const uiBut *but) +{ + const char *str_sep = strchr(but->tip, '\n'); + if (str_sep != NULL) { + return (str_sep - but->tip); + } + return strlen(but->tip); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Block (#uiBlock) State * \{ */ |