From 8ce2413feb3108278e9dc33b7ad0bb916a4a2da6 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Mon, 30 Apr 2001 11:28:46 +0000 Subject: [PATCH] Add color changes, undocumented and ugly, but hey maybe people want to see what chap I wrote so far git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@624 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- Makefile.am | 3 +- Makefile.in | 6 +- acconfig.h | 3 + config.h.in | 3 + configure | 219 ++++++++++++++++++++++++++++++--------------------- configure.in | 1 + files.c | 16 +++- global.c | 4 + nano.c | 7 ++ nano.h | 21 +++++ proto.h | 8 ++ winio.c | 164 +++++++++++++++++++++++++++++++++++--- 12 files changed, 350 insertions(+), 105 deletions(-) diff --git a/Makefile.am b/Makefile.am index e67dd348..97d92903 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,7 @@ ## $Id$ bin_PROGRAMS = nano -nano_SOURCES = cut.c \ +nano_SOURCES = color.c \ + cut.c \ files.c \ global.c \ move.c \ diff --git a/Makefile.in b/Makefile.in index 6651ece8..3ab80dd9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -86,7 +86,7 @@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ bin_PROGRAMS = nano -nano_SOURCES = cut.c files.c global.c move.c nano.c nano.h proto.h rcfile.c search.c utils.c winio.c +nano_SOURCES = color.c cut.c files.c global.c move.c nano.c nano.h proto.h rcfile.c search.c utils.c winio.c man_MANS = nano.1 @@ -113,8 +113,8 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -nano_OBJECTS = cut.o files.o global.o move.o nano.o rcfile.o search.o \ -utils.o winio.o +nano_OBJECTS = color.o cut.o files.o global.o move.o nano.o rcfile.o \ +search.o utils.o winio.o nano_DEPENDENCIES = nano_LDFLAGS = CFLAGS = @CFLAGS@ diff --git a/acconfig.h b/acconfig.h index 205ff2cd..be307ea3 100644 --- a/acconfig.h +++ b/acconfig.h @@ -57,6 +57,9 @@ /* Define this to use the .nanorc file */ #undef ENABLE_NANORC +/* Define this if your curses library has the use_default_colors command */ +#undef HAVE_USE_DEFAULT_COLORS + /* Define this to have syntax hilighting, requires ENABLE_NANORC too! */ #undef ENABLE_COLOR diff --git a/config.h.in b/config.h.in index edf9ca29..a49aeb29 100644 --- a/config.h.in +++ b/config.h.in @@ -91,6 +91,9 @@ /* Define this to use the .nanorc file */ #undef ENABLE_NANORC +/* Define this if your curses library has the use_default_colors command */ +#undef HAVE_USE_DEFAULT_COLORS + /* Define this to have syntax hilighting, requires ENABLE_NANORC too! */ #undef ENABLE_COLOR diff --git a/configure b/configure index d7e2f34b..7e96ca26 100755 --- a/configure +++ b/configure @@ -813,7 +813,7 @@ fi -ALL_LINGUAS="es de fr it id fi hu ca cs" +ALL_LINGUAS="es de fr it id fi hu ca cs gl" # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 @@ -2462,9 +2462,52 @@ else fi +echo $ac_n "checking for use_default_colors in -l$CURSES_LIB_NAME""... $ac_c" 1>&6 +echo "configure:2467: checking for use_default_colors in -l$CURSES_LIB_NAME" >&5 +ac_lib_var=`echo $CURSES_LIB_NAME'_'use_default_colors | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-l$CURSES_LIB_NAME $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_USE_DEFAULT_COLORS 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + if test x$slang_support != xyes; then echo $ac_n "checking for wresize in -l$CURSES_LIB_NAME""... $ac_c" 1>&6 -echo "configure:2468: checking for wresize in -l$CURSES_LIB_NAME" >&5 +echo "configure:2511: checking for wresize in -l$CURSES_LIB_NAME" >&5 ac_lib_var=`echo $CURSES_LIB_NAME'_'wresize | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2472,7 +2515,7 @@ else ac_save_LIBS="$LIBS" LIBS="-l$CURSES_LIB_NAME $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2530: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2507,7 +2550,7 @@ else fi echo $ac_n "checking for resizeterm in -l$CURSES_LIB_NAME""... $ac_c" 1>&6 -echo "configure:2511: checking for resizeterm in -l$CURSES_LIB_NAME" >&5 +echo "configure:2554: checking for resizeterm in -l$CURSES_LIB_NAME" >&5 ac_lib_var=`echo $CURSES_LIB_NAME'_'resizeterm | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2515,7 +2558,7 @@ else ac_save_LIBS="$LIBS" LIBS="-l$CURSES_LIB_NAME $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2552,12 +2595,12 @@ fi # Taken from aumix (can't tell form the variable name?) echo $ac_n "checking for private member _use_keypad in WINDOW""... $ac_c" 1>&6 -echo "configure:2556: checking for private member _use_keypad in WINDOW" >&5 +echo "configure:2599: checking for private member _use_keypad in WINDOW" >&5 if eval "test \"`echo '$''{'aumix_cv_struct_window_usekeypad'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -2568,7 +2611,7 @@ int main() { WINDOW w; w._use_keypad; ; return 0; } EOF -if { (eval echo configure:2572: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* aumix_cv_struct_window_usekeypad=yes else @@ -2618,7 +2661,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:2622: checking host system type" >&5 +echo "configure:2665: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -2641,7 +2684,7 @@ echo "$ac_t""$host" 1>&6 # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2645: checking for $ac_word" >&5 +echo "configure:2688: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2669,12 +2712,12 @@ else fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:2673: checking for working const" >&5 +echo "configure:2716: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2770: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -2744,21 +2787,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:2748: checking for inline" >&5 +echo "configure:2791: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2805: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -2784,12 +2827,12 @@ EOF esac echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:2788: checking for off_t" >&5 +echo "configure:2831: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2817,12 +2860,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:2821: checking for size_t" >&5 +echo "configure:2864: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2852,19 +2895,19 @@ fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:2856: checking for working alloca.h" >&5 +echo "configure:2899: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:2868: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -2885,12 +2928,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:2889: checking for alloca" >&5 +echo "configure:2932: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -2950,12 +2993,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:2954: checking whether alloca needs Cray hooks" >&5 +echo "configure:2997: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2984: checking for $ac_func" >&5 +echo "configure:3027: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3035,7 +3078,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:3039: checking stack direction for C alloca" >&5 +echo "configure:3082: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3043,7 +3086,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3109: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -3087,17 +3130,17 @@ for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3091: checking for $ac_hdr" >&5 +echo "configure:3134: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3101: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3144: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3126,12 +3169,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3130: checking for $ac_func" >&5 +echo "configure:3173: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3201: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3179,7 +3222,7 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:3183: checking for working mmap" >&5 +echo "configure:3226: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3187,7 +3230,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3374: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes else @@ -3355,17 +3398,17 @@ stdlib.h string.h unistd.h sys/param.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3359: checking for $ac_hdr" >&5 +echo "configure:3402: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3369: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3412: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3396,12 +3439,12 @@ setenv setlocale stpcpy strchr strcasecmp strdup tsearch \ __argz_count __argz_stringify __argz_next do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3400: checking for $ac_func" >&5 +echo "configure:3443: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3451,7 +3494,7 @@ done echo $ac_n "checking for iconv""... $ac_c" 1>&6 -echo "configure:3455: checking for iconv" >&5 +echo "configure:3498: checking for iconv" >&5 if eval "test \"`echo '$''{'am_cv_func_iconv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3459,7 +3502,7 @@ else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no cat > conftest.$ac_ext < #include @@ -3469,7 +3512,7 @@ iconv_t cd = iconv_open("",""); iconv_close(cd); ; return 0; } EOF -if { (eval echo configure:3473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_func_iconv=yes else @@ -3481,7 +3524,7 @@ rm -f conftest* am_save_LIBS="$LIBS" LIBS="$LIBS -liconv" cat > conftest.$ac_ext < #include @@ -3491,7 +3534,7 @@ iconv_t cd = iconv_open("",""); iconv_close(cd); ; return 0; } EOF -if { (eval echo configure:3495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3538: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_lib_iconv=yes am_cv_func_iconv=yes @@ -3512,13 +3555,13 @@ echo "$ac_t""$am_cv_func_iconv" 1>&6 EOF echo $ac_n "checking for iconv declaration""... $ac_c" 1>&6 -echo "configure:3516: checking for iconv declaration" >&5 +echo "configure:3559: checking for iconv declaration" >&5 if eval "test \"`echo '$''{'am_cv_proto_iconv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -3537,7 +3580,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:3541: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3584: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* am_cv_proto_iconv_arg1="" else @@ -3566,19 +3609,19 @@ EOF echo $ac_n "checking for nl_langinfo and CODESET""... $ac_c" 1>&6 -echo "configure:3570: checking for nl_langinfo and CODESET" >&5 +echo "configure:3613: checking for nl_langinfo and CODESET" >&5 if eval "test \"`echo '$''{'am_cv_langinfo_codeset'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char* cs = nl_langinfo(CODESET); ; return 0; } EOF -if { (eval echo configure:3582: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_langinfo_codeset=yes else @@ -3601,19 +3644,19 @@ EOF if test $ac_cv_header_locale_h = yes; then echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6 -echo "configure:3605: checking for LC_MESSAGES" >&5 +echo "configure:3648: checking for LC_MESSAGES" >&5 if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return LC_MESSAGES ; return 0; } EOF -if { (eval echo configure:3617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_val_LC_MESSAGES=yes else @@ -3634,7 +3677,7 @@ EOF fi fi echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6 -echo "configure:3638: checking whether NLS is requested" >&5 +echo "configure:3681: checking whether NLS is requested" >&5 # Check whether --enable-nls or --disable-nls was given. if test "${enable_nls+set}" = set; then enableval="$enable_nls" @@ -3655,7 +3698,7 @@ fi EOF echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6 -echo "configure:3659: checking whether included gettext is requested" >&5 +echo "configure:3702: checking whether included gettext is requested" >&5 # Check whether --with-included-gettext or --without-included-gettext was given. if test "${with_included_gettext+set}" = set; then withval="$with_included_gettext" @@ -3675,17 +3718,17 @@ fi ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for libintl.h""... $ac_c" 1>&6 -echo "configure:3679: checking for libintl.h" >&5 +echo "configure:3722: checking for libintl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3689: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3732: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3702,12 +3745,12 @@ fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for GNU gettext in libc""... $ac_c" 1>&6 -echo "configure:3706: checking for GNU gettext in libc" >&5 +echo "configure:3749: checking for GNU gettext in libc" >&5 if eval "test \"`echo '$''{'gt_cv_func_gnugettext1_libc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < extern int _nl_msg_cat_cntr; @@ -3716,7 +3759,7 @@ bindtextdomain ("", ""); return (int) gettext ("") + _nl_msg_cat_cntr ; return 0; } EOF -if { (eval echo configure:3720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3763: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gt_cv_func_gnugettext1_libc=yes else @@ -3732,14 +3775,14 @@ echo "$ac_t""$gt_cv_func_gnugettext1_libc" 1>&6 if test "$gt_cv_func_gnugettext1_libc" != "yes"; then echo $ac_n "checking for GNU gettext in libintl""... $ac_c" 1>&6 -echo "configure:3736: checking for GNU gettext in libintl" >&5 +echo "configure:3779: checking for GNU gettext in libintl" >&5 if eval "test \"`echo '$''{'gt_cv_func_gnugettext1_libintl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else gt_save_LIBS="$LIBS" LIBS="$LIBS -lintl" cat > conftest.$ac_ext < extern int _nl_msg_cat_cntr; @@ -3748,7 +3791,7 @@ bindtextdomain ("", ""); return (int) gettext ("") + _nl_msg_cat_cntr ; return 0; } EOF -if { (eval echo configure:3752: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3795: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gt_cv_func_gnugettext1_libintl=yes else @@ -3773,12 +3816,12 @@ EOF for ac_func in dcgettext do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3777: checking for $ac_func" >&5 +echo "configure:3820: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3848: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3828,7 +3871,7 @@ done # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3832: checking for $ac_word" >&5 +echo "configure:3875: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3862,7 +3905,7 @@ fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3866: checking for $ac_word" >&5 +echo "configure:3909: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3899,7 +3942,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3903: checking for $ac_word" >&5 +echo "configure:3946: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3951,7 +3994,7 @@ fi # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3955: checking for $ac_word" >&5 +echo "configure:3998: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3985,7 +4028,7 @@ fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3989: checking for $ac_word" >&5 +echo "configure:4032: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4021,7 +4064,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4025: checking for $ac_word" >&5 +echo "configure:4068: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4087,7 +4130,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4091: checking for $ac_word" >&5 +echo "configure:4134: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_INTLBISON'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4120,7 +4163,7 @@ done ac_verc_fail=yes else echo $ac_n "checking version of bison""... $ac_c" 1>&6 -echo "configure:4124: checking version of bison" >&5 +echo "configure:4167: checking version of bison" >&5 ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison .* \([0-9]*\.[0-9.]*\).*$/\1/p'` case $ac_prog_version in '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; @@ -4161,7 +4204,7 @@ echo "configure:4124: checking version of bison" >&5 LINGUAS= else echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6 -echo "configure:4165: checking for catalogs to be installed" >&5 +echo "configure:4208: checking for catalogs to be installed" >&5 NEW_LINGUAS= for presentlang in $ALL_LINGUAS; do useit=no diff --git a/configure.in b/configure.in index 80026b0a..7311284b 100644 --- a/configure.in +++ b/configure.in @@ -237,6 +237,7 @@ else fi +AC_CHECK_LIB([$CURSES_LIB_NAME], use_default_colors, [AC_DEFINE(HAVE_USE_DEFAULT_COLORS)]) if test x$slang_support != xyes; then AC_CHECK_LIB([$CURSES_LIB_NAME], wresize, [AC_DEFINE(HAVE_WRESIZE)]) AC_CHECK_LIB([$CURSES_LIB_NAME], resizeterm, [AC_DEFINE(HAVE_RESIZETERM)]) diff --git a/files.c b/files.c index 878e784b..350ae625 100644 --- a/files.c +++ b/files.c @@ -1322,6 +1322,7 @@ char *do_browser(char *inpath) return do_browser(path); /* Stuff we want to abort the browser */ + case NANO_CONTROL_C: case 'q': case 'Q': case 'e': /* Pico compatibility, yeech */ @@ -1380,11 +1381,22 @@ char *do_browser(char *inpath) } /* Hilight the currently selected file/dir */ - if (j == selected) + if (j == selected) { +#ifdef ENABLE_COLOR + color_on(edit, COLOR_STATUSBAR); +#else wattron(edit, A_REVERSE); + +#endif + } waddnstr(edit, foo, strlen(foo)); - if (j == selected) + if (j == selected) { +#ifdef ENABLE_COLOR + color_off(edit, COLOR_STATUSBAR); +#else wattroff(edit, A_REVERSE); +#endif + } /* And add some space between the cols */ waddstr(edit, " "); diff --git a/global.c b/global.c index 80ac83a5..f56f96be 100644 --- a/global.c +++ b/global.c @@ -88,6 +88,10 @@ shortcut spell_list[SPELL_LIST_LEN]; shortcut browser_list[BROWSER_LIST_LEN]; #endif +#ifdef ENABLE_COLOR + colorstruct colors[NUM_NCOLORS]; +#endif + shortcut *currshortcut = main_list; /* Current shortcut list we're using */ int currslen = MAIN_VISIBLE; /* Length of current shortcut list */ diff --git a/nano.c b/nano.c index 86d8c40a..f1874814 100644 --- a/nano.c +++ b/nano.c @@ -453,6 +453,9 @@ void version(void) #ifdef ENABLE_NANORC printf(" --enable-nanorc"); #endif +#ifdef ENABLE_COLOR + printf(" --enable-color"); +#endif #ifdef NANO_SMALL printf(" --enable-tiny"); @@ -2402,6 +2405,10 @@ int main(int argc, char *argv[]) fprintf(stderr, _("Main: set up windows\n")); #endif +#ifdef ENABLE_COLOR + do_colorinit(); +#endif /* ENABLE_COLOR */ + window_init(); mouse_init(); diff --git a/nano.h b/nano.h index f8f013ac..0b36be8e 100644 --- a/nano.h +++ b/nano.h @@ -285,4 +285,25 @@ know what you're doing */ /* Minimum fill length (space available for text before wrapping occurs) */ #define MIN_FILL_LENGTH 10 +/* Color specific defines */ +#ifdef ENABLE_COLOR +typedef struct colorstruct { + int fg; + int bg; + int bold; + int set; +} colorstruct; + +#define FIRST_COLORNUM 16 + +#define COLOR_TITLEBAR 16 +#define COLOR_BOTTOMBARS 17 +#define COLOR_STATUSBAR 18 +#define COLOR_TEXT 19 +#define COLOR_MARKER 20 + +#define NUM_NCOLORS 5 + +#endif /* ENABLE_COLOR */ + #endif /* ifndef NANO_H */ diff --git a/proto.h b/proto.h index 45baaee5..3b26ef38 100644 --- a/proto.h +++ b/proto.h @@ -174,6 +174,14 @@ struct stat filestat(const char *path); char *do_browse_from(char *inpath); #endif +#ifdef ENABLE_COLOR +int do_colorinit(void); +void color_on(WINDOW *win, int whatever); +void color_off(WINDOW *win, int whatever); + +extern colorstruct colors[NUM_NCOLORS]; +#endif /* ENABLE_COLOR */ + RETSIGTYPE main_loop (int junk); filestruct *copy_node(filestruct * src); diff --git a/winio.c b/winio.c index 0ca40bee..70128ddc 100644 --- a/winio.c +++ b/winio.c @@ -227,7 +227,11 @@ void nanoget_repaint(char *buf, char *inputbuf, int x) int len = strlen(buf); int wid = COLS - len; +#ifdef ENABLE_COLOR + color_on(bottomwin, COLOR_STATUSBAR); +#endif blank_statusbar(); + if (x <= COLS - 1) { /* Black magic */ buf[len - 1] = ' '; @@ -244,6 +248,10 @@ void nanoget_repaint(char *buf, char *inputbuf, int x) waddnstr(bottomwin, &inputbuf[wid * ((x - len) / (wid))], wid); wmove(bottomwin, 0, ((x - len) % wid) + len); } + +#ifdef ENABLE_COLOR + color_off(bottomwin, COLOR_STATUSBAR); +#endif } /* Get the input from the kb, this should only be called from statusq */ @@ -492,8 +500,15 @@ void titlebar(char *path) if (path == NULL) what = filename; +#ifdef ENABLE_COLOR + color_on(topwin, COLOR_TITLEBAR); + mvwaddstr(topwin, 0, 0, hblank); +#else horizbar(topwin, 0); wattron(topwin, A_REVERSE); +#endif + + mvwaddstr(topwin, 0, 3, VERMSG); space = COLS - strlen(VERMSG) - strlen(VERSION) - 21; @@ -519,7 +534,14 @@ void titlebar(char *path) } if (ISSET(MODIFIED)) mvwaddstr(topwin, 0, COLS - 10, _("Modified")); + + +#ifdef ENABLE_COLOR + color_off(topwin, COLOR_TITLEBAR); +#else wattroff(topwin, A_REVERSE); +#endif + wrefresh(topwin); reset_cursor(); } @@ -552,6 +574,10 @@ void bottombars(shortcut s[], int slen) if (ISSET(NO_HELP)) return; +#ifdef ENABLE_COLOR + color_on(bottomwin, COLOR_BOTTOMBARS); +#endif + /* Determine how many extra spaces are needed to fill the bottom of the screen */ k = COLS / 6 - 13; @@ -574,6 +600,10 @@ void bottombars(shortcut s[], int slen) waddch(bottomwin, ' '); } +#ifdef ENABLE_COLOR + color_off(bottomwin, COLOR_BOTTOMBARS); +#endif + wrefresh(bottomwin); } @@ -671,10 +701,22 @@ void add_marked_sameline(int begin, int end, filestruct * fileptr, int y, /* Paint this line! */ mvwaddnstr(edit, y, 0, &fileptr->data[this_page_start], pre_data_len); + +#ifdef ENABLE_COLOR + color_on(edit, COLOR_MARKER); +#else wattron(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + mvwaddnstr(edit, y, begin - this_page_start, &fileptr->data[begin], sel_data_len); + +#ifdef ENABLE_COLOR + color_off(edit, COLOR_MARKER); +#else wattroff(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + mvwaddnstr(edit, y, end - this_page_start, &fileptr->data[end], post_data_len); } @@ -702,9 +744,20 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, if (fileptr != mark_beginbuf && fileptr != current) { /* We are on a completely marked line, paint it all * inverse */ +#ifdef ENABLE_COLOR + color_on(edit, COLOR_MARKER); +#else wattron(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + mvwaddnstr(edit, yval, 0, fileptr->data, COLS); + +#ifdef ENABLE_COLOR + color_off(edit, COLOR_MARKER); +#else wattroff(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + } else if (fileptr == mark_beginbuf && fileptr == current) { /* Special case, we're still on the same line we started * marking -- so we call our helper function */ @@ -730,8 +783,13 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, */ int target; - if (mark_beginbuf->lineno > current->lineno) + if (mark_beginbuf->lineno > current->lineno) { +#ifdef ENABLE_COLOR + color_on(edit, COLOR_MARKER); +#else wattron(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + } target = (virt_mark_beginx < @@ -739,10 +797,23 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, mvwaddnstr(edit, yval, 0, fileptr->data, target); - if (mark_beginbuf->lineno < current->lineno) + if (mark_beginbuf->lineno < current->lineno) { + +#ifdef ENABLE_COLOR + color_on(edit, COLOR_MARKER); +#else wattron(edit, A_REVERSE); - else +#endif /* ENABLE_COLOR */ + + } else { + +#ifdef ENABLE_COLOR + color_off(edit, COLOR_MARKER); +#else wattroff(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + + } target = (COLS - 1) - virt_mark_beginx; if (target < 0) @@ -751,8 +822,15 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, mvwaddnstr(edit, yval, virt_mark_beginx, &fileptr->data[virt_mark_beginx], target); - if (mark_beginbuf->lineno < current->lineno) + if (mark_beginbuf->lineno < current->lineno) { + +#ifdef ENABLE_COLOR + color_off(edit, COLOR_MARKER); +#else wattroff(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + + } } else if (fileptr == current) { /* we're on the cursor's line, but it's not the first @@ -760,8 +838,15 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, int this_page_start = get_page_start_virtual(this_page), this_page_end = get_page_end_virtual(this_page); - if (mark_beginbuf->lineno < current->lineno) + if (mark_beginbuf->lineno < current->lineno) { + +#ifdef ENABLE_COLOR + color_on(edit, COLOR_MARKER); +#else wattron(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + + } if (virt_cur_x > COLS - 2) { mvwaddnstr(edit, yval, 0, @@ -771,10 +856,23 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, mvwaddnstr(edit, yval, 0, fileptr->data, virt_cur_x); } - if (mark_beginbuf->lineno > current->lineno) + if (mark_beginbuf->lineno > current->lineno) { + +#ifdef ENABLE_COLOR + color_on(edit, COLOR_MARKER); +#else wattron(edit, A_REVERSE); - else +#endif /* ENABLE_COLOR */ + + } else { + +#ifdef ENABLE_COLOR + color_off(edit, COLOR_MARKER); +#else wattroff(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + + } if (virt_cur_x > COLS - 2) mvwaddnstr(edit, yval, virt_cur_x - this_page_start, @@ -784,8 +882,15 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, mvwaddnstr(edit, yval, virt_cur_x, &fileptr->data[virt_cur_x], COLS - virt_cur_x); - if (mark_beginbuf->lineno > current->lineno) + if (mark_beginbuf->lineno > current->lineno) { + +#ifdef ENABLE_COLOR + color_off(edit, COLOR_MARKER); +#else wattroff(edit, A_REVERSE); +#endif /* ENABLE_COLOR */ + + } } } else @@ -1007,9 +1112,21 @@ int statusq(int tabs, shortcut s[], int slen, char *def, char *msg, ...) va_end(ap); strncat(foo, ": ", 132); +#ifdef ENABLE_COLOR + color_on(bottomwin, COLOR_STATUSBAR); +#else wattron(bottomwin, A_REVERSE); +#endif + + ret = nanogetstr(tabs, foo, def, s, slen, (strlen(foo) + 3)); + +#ifdef ENABLE_COLOR + color_off(bottomwin, COLOR_STATUSBAR); +#else wattroff(bottomwin, A_REVERSE); +#endif + switch (ret) { @@ -1061,9 +1178,10 @@ int do_yesno(int all, int leavecursor, char *msg, ...) /* Write the bottom of the screen */ clear_bottomwin(); - wattron(bottomwin, A_REVERSE); - blank_statusbar_refresh(); - wattroff(bottomwin, A_REVERSE); + +#ifdef ENABLE_COLOR + color_on(bottomwin, COLOR_BOTTOMBARS); +#endif /* Remove gettext call for keybindings until we clear the thing up */ if (!ISSET(NO_HELP)) { @@ -1086,9 +1204,23 @@ int do_yesno(int all, int leavecursor, char *msg, ...) va_start(ap, msg); vsnprintf(foo, 132, msg, ap); va_end(ap); + +#ifdef ENABLE_COLOR + color_off(bottomwin, COLOR_BOTTOMBARS); + color_on(bottomwin, COLOR_STATUSBAR); +#else wattron(bottomwin, A_REVERSE); +#endif /* ENABLE_COLOR */ + + blank_statusbar(); mvwaddstr(bottomwin, 0, 0, foo); + +#ifdef ENABLE_COLOR + color_off(bottomwin, COLOR_STATUSBAR); +#else wattroff(bottomwin, A_REVERSE); +#endif + wrefresh(bottomwin); if (leavecursor == 1) @@ -1188,12 +1320,22 @@ void statusbar(char *msg, ...) wmove(bottomwin, 0, start_x); +#ifdef ENABLE_COLOR + color_on(bottomwin, COLOR_STATUSBAR); +#else wattron(bottomwin, A_REVERSE); +#endif waddstr(bottomwin, "[ "); waddstr(bottomwin, foo); waddstr(bottomwin, " ]"); + +#ifdef ENABLE_COLOR + color_off(bottomwin, COLOR_STATUSBAR); +#else wattroff(bottomwin, A_REVERSE); +#endif + wrefresh(bottomwin); if (ISSET(CONSTUPDATE))