Make fish pager use non-universal variables as well for getting it's colors

darcs-hash:20060811145528-ac50b-26be05f363f353d87ebceccf73385cd1af1c88f2.gz
This commit is contained in:
axel 2006-08-12 00:55:28 +10:00
parent 21de293a44
commit 72ad4e0d3b
3 changed files with 42 additions and 3 deletions

View file

@ -138,14 +138,21 @@ typedef struct
static int get_color( int highlight ) static int get_color( int highlight )
{ {
wchar_t *val;
if( highlight < 0 ) if( highlight < 0 )
return FISH_COLOR_NORMAL; return FISH_COLOR_NORMAL;
if( highlight >= (4) ) if( highlight >= (4) )
return FISH_COLOR_NORMAL; return FISH_COLOR_NORMAL;
wchar_t *val = env_universal_get( hightlight_var[highlight]); val = wgetenv( hightlight_var[highlight]);
if( val == 0 ) if( !val )
{
val = env_universal_get( hightlight_var[highlight]);
}
if( !val )
{ {
return FISH_COLOR_NORMAL; return FISH_COLOR_NORMAL;
} }

28
wutil.c
View file

@ -53,12 +53,14 @@
the \c wutil_wcs2str() function. the \c wutil_wcs2str() function.
*/ */
static char *tmp=0; static char *tmp=0;
/** /**
Buffer for converting narrow results to wide ones, used by the \c Buffer for converting narrow results to wide ones, used by the \c
wutil_str2wcs() function. Avoid usign this without thinking about wutil_str2wcs() function. Avoid usign this without thinking about
it, since sebseuent calls will overwrite previous values. it, since subsequent calls will overwrite previous values.
*/ */
static wchar_t *tmp2; static wchar_t *tmp2;
/** /**
Length of the \c tmp buffer. Length of the \c tmp buffer.
*/ */
@ -518,3 +520,27 @@ const wchar_t *wgettext( const wchar_t *in )
return wres; return wres;
} }
wchar_t *wgetenv( const wchar_t *name )
{
char *name_narrow =wutil_wcs2str(name);
char *res_narrow = getenv( name_narrow );
static string_buffer_t *out = 0;
if( !res_narrow )
return 0;
if( !out )
{
out = sb_halloc( global_context );
}
else
{
sb_clear( out );
}
sb_printf( out, L"%s", res_narrow );
return (wchar_t *)out->buff;
}

View file

@ -128,4 +128,10 @@ wchar_t *wbasename( const wchar_t *path );
*/ */
const wchar_t *wgettext( const wchar_t *in ); const wchar_t *wgettext( const wchar_t *in );
/**
Wide character version of getenv
*/
wchar_t *wgetenv( const wchar_t *name );
#endif #endif