mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Add overload of wcstringutil::trim that automatically trims whitespace
This commit is contained in:
parent
d7cbf3581d
commit
a9845dc026
2 changed files with 5 additions and 0 deletions
|
@ -46,6 +46,10 @@ wcstring truncate(const wcstring &input, int max_len, ellipsis_type etype) {
|
|||
return output;
|
||||
}
|
||||
|
||||
wcstring trim(const wcstring &input) {
|
||||
return trim(input, whitespace.c_str());
|
||||
}
|
||||
|
||||
wcstring trim(const wcstring &input, const wchar_t *any_of) {
|
||||
auto begin_offset = input.find_first_not_of(any_of);
|
||||
if (begin_offset == wcstring::npos) {
|
||||
|
|
|
@ -64,6 +64,7 @@ enum class ellipsis_type {
|
|||
};
|
||||
|
||||
wcstring truncate(const wcstring &input, int max_len, ellipsis_type etype = ellipsis_type::Prettiest);
|
||||
wcstring trim(const wcstring &input);
|
||||
wcstring trim(const wcstring &input, const wchar_t *any_of);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue