mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
Remove my_wcswidth() in favor of fish_wcswidth()
my_wcswidth() was just a wrapper around fish_wcswidth() already. Instead, add two convenience overrides of fish_wcswidth() to common.h that make it a drop-in replacement for my_wcswidth().
This commit is contained in:
parent
316d7004a3
commit
cd4fa518b8
5 changed files with 18 additions and 15 deletions
|
@ -160,7 +160,7 @@ static void print_all(int hard)
|
|||
|
||||
for (i=0; resource_arr[i].desc; i++)
|
||||
{
|
||||
w=maxi(w, my_wcswidth(resource_arr[i].desc));
|
||||
w=maxi(w, fish_wcswidth(resource_arr[i].desc));
|
||||
}
|
||||
|
||||
for (i=0; resource_arr[i].desc; i++)
|
||||
|
|
13
common.cpp
13
common.cpp
|
@ -513,13 +513,14 @@ bool wcsvarchr(wchar_t chr)
|
|||
return iswalnum(chr) || chr == L'_';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The glibc version of wcswidth seems to hang on some strings. fish uses this replacement.
|
||||
*/
|
||||
int my_wcswidth(const wchar_t *c)
|
||||
int fish_wcswidth(const wchar_t *str)
|
||||
{
|
||||
return fish_wcswidth(c, wcslen(c));
|
||||
return fish_wcswidth(str, wcslen(str));
|
||||
}
|
||||
|
||||
int fish_wcswidth(const wcstring& str)
|
||||
{
|
||||
return fish_wcswidth(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
wchar_t *quote_end(const wchar_t *pos)
|
||||
|
|
8
common.h
8
common.h
|
@ -713,11 +713,13 @@ const wchar_t *wcsfuncname(const wchar_t *str);
|
|||
|
||||
bool wcsvarchr(wchar_t chr);
|
||||
|
||||
|
||||
/**
|
||||
A wcswidth workalike. Fish uses this since the regular wcswidth seems flaky.
|
||||
Convenience variants on fish_wcwswidth().
|
||||
|
||||
See fallback.h for the normal definitions.
|
||||
*/
|
||||
int my_wcswidth(const wchar_t *c);
|
||||
int fish_wcswidth(const wchar_t *str);
|
||||
int fish_wcswidth(const wcstring& str);
|
||||
|
||||
/**
|
||||
This functions returns the end of the quoted substring beginning at
|
||||
|
|
|
@ -535,7 +535,7 @@ void writestr_ellipsis(const wchar_t *str, int max_width)
|
|||
|
||||
CHECK(str,);
|
||||
|
||||
tot = my_wcswidth(str);
|
||||
tot = fish_wcswidth(str);
|
||||
|
||||
if (tot <= max_width)
|
||||
{
|
||||
|
@ -575,7 +575,7 @@ int write_escaped_str(const wchar_t *str, int max_len)
|
|||
CHECK(str, 0);
|
||||
|
||||
out = escape(str, 1);
|
||||
len = my_wcswidth(out);
|
||||
len = fish_wcswidth(out);
|
||||
|
||||
if (max_len && (max_len < len))
|
||||
{
|
||||
|
|
|
@ -319,7 +319,7 @@ static comp_info_list_t process_completions_into_infos(const completion_list_t &
|
|||
|
||||
void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &prefix) const
|
||||
{
|
||||
size_t prefix_len = my_wcswidth(prefix.c_str());
|
||||
size_t prefix_len = fish_wcswidth(prefix.c_str());
|
||||
for (size_t i=0; i < infos->size(); i++)
|
||||
{
|
||||
comp_t *comp = &infos->at(i);
|
||||
|
@ -332,11 +332,11 @@ void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &
|
|||
if (j >= 1)
|
||||
comp->comp_width += 2;
|
||||
|
||||
comp->comp_width += prefix_len + my_wcswidth(comp_strings.at(j).c_str());
|
||||
comp->comp_width += prefix_len + fish_wcswidth(comp_strings.at(j).c_str());
|
||||
}
|
||||
|
||||
// Compute desc_width
|
||||
comp->desc_width = my_wcswidth(comp->desc.c_str());
|
||||
comp->desc_width = fish_wcswidth(comp->desc.c_str());
|
||||
|
||||
// Compute preferred width
|
||||
comp->pref_width = comp->comp_width + comp->desc_width + (comp->desc_width?4:0);
|
||||
|
|
Loading…
Reference in a new issue