From 72ad4e0d3b7d8038a5a911d99bb2175f15c5fd57 Mon Sep 17 00:00:00 2001 From: axel Date: Sat, 12 Aug 2006 00:55:28 +1000 Subject: [PATCH] Make fish pager use non-universal variables as well for getting it's colors darcs-hash:20060811145528-ac50b-26be05f363f353d87ebceccf73385cd1af1c88f2.gz --- fish_pager.c | 11 +++++++++-- wutil.c | 28 +++++++++++++++++++++++++++- wutil.h | 6 ++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/fish_pager.c b/fish_pager.c index cc934cffa..4052795b1 100644 --- a/fish_pager.c +++ b/fish_pager.c @@ -138,14 +138,21 @@ typedef struct static int get_color( int highlight ) { + wchar_t *val; + if( highlight < 0 ) return FISH_COLOR_NORMAL; if( highlight >= (4) ) return FISH_COLOR_NORMAL; - wchar_t *val = env_universal_get( hightlight_var[highlight]); + val = wgetenv( hightlight_var[highlight]); + + if( !val ) + { + val = env_universal_get( hightlight_var[highlight]); + } - if( val == 0 ) + if( !val ) { return FISH_COLOR_NORMAL; } diff --git a/wutil.c b/wutil.c index 6dfeb21ad..243a446f0 100644 --- a/wutil.c +++ b/wutil.c @@ -53,12 +53,14 @@ the \c wutil_wcs2str() function. */ static char *tmp=0; + /** Buffer for converting narrow results to wide ones, used by the \c 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; + /** Length of the \c tmp buffer. */ @@ -518,3 +520,27 @@ const wchar_t *wgettext( const wchar_t *in ) 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; + +} + diff --git a/wutil.h b/wutil.h index aeb581b5e..da041f528 100644 --- a/wutil.h +++ b/wutil.h @@ -128,4 +128,10 @@ wchar_t *wbasename( const wchar_t *path ); */ const wchar_t *wgettext( const wchar_t *in ); +/** + Wide character version of getenv +*/ +wchar_t *wgetenv( const wchar_t *name ); + + #endif