From ffccd5b2b05243e7976db80f90f453dccfae9886 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:22:03 +0200 Subject: Adding upstream version 3:4.8.30. Signed-off-by: Daniel Baumann --- lib/skin/Makefile.am | 12 + lib/skin/Makefile.in | 760 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/skin/colors-old.c | 203 ++++++++++++++ lib/skin/colors.c | 422 ++++++++++++++++++++++++++++ lib/skin/common.c | 209 ++++++++++++++ lib/skin/hc-skins.c | 146 ++++++++++ lib/skin/ini-file.c | 210 ++++++++++++++ lib/skin/internal.h | 40 +++ lib/skin/lines.c | 100 +++++++ 9 files changed, 2102 insertions(+) create mode 100644 lib/skin/Makefile.am create mode 100644 lib/skin/Makefile.in create mode 100644 lib/skin/colors-old.c create mode 100644 lib/skin/colors.c create mode 100644 lib/skin/common.c create mode 100644 lib/skin/hc-skins.c create mode 100644 lib/skin/ini-file.c create mode 100644 lib/skin/internal.h create mode 100644 lib/skin/lines.c (limited to 'lib/skin') diff --git a/lib/skin/Makefile.am b/lib/skin/Makefile.am new file mode 100644 index 0000000..04f12ed --- /dev/null +++ b/lib/skin/Makefile.am @@ -0,0 +1,12 @@ +noinst_LTLIBRARIES = libmcskin.la + +libmcskin_la_SOURCES = \ + colors.c \ + colors-old.c \ + common.c \ + hc-skins.c \ + ini-file.c \ + lines.c \ + internal.h + +AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) diff --git a/lib/skin/Makefile.in b/lib/skin/Makefile.in new file mode 100644 index 0000000..62f642b --- /dev/null +++ b/lib/skin/Makefile.in @@ -0,0 +1,760 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = lib/skin +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/m4.include/gnulib/mode_t.m4 \ + $(top_srcdir)/m4.include/gnulib/stat-size.m4 \ + $(top_srcdir)/m4.include/gnulib/fstypename.m4 \ + $(top_srcdir)/m4.include/gnulib/fsusage.m4 \ + $(top_srcdir)/m4.include/gnulib/mountlist.m4 \ + $(top_srcdir)/m4.include/gnulib/windows-stat-inodes.m4 \ + $(top_srcdir)/m4.include/gnulib/sys_types_h.m4 \ + $(top_srcdir)/m4.include/ax_path_lib_pcre.m4 \ + $(top_srcdir)/m4.include/ax_check_pcre2.m4 \ + $(top_srcdir)/m4.include/dx_doxygen.m4 \ + $(top_srcdir)/m4.include/ax_require_defined.m4 \ + $(top_srcdir)/m4.include/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4.include/ax_append_flag.m4 \ + $(top_srcdir)/m4.include/ax_append_compile_flags.m4 \ + $(top_srcdir)/m4.include/mc-cflags.m4 \ + $(top_srcdir)/m4.include/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4.include/mc-check-search-type.m4 \ + $(top_srcdir)/m4.include/mc-get-fs-info.m4 \ + $(top_srcdir)/m4.include/mc-with-x.m4 \ + $(top_srcdir)/m4.include/mc-use-termcap.m4 \ + $(top_srcdir)/m4.include/mc-with-screen.m4 \ + $(top_srcdir)/m4.include/mc-with-screen-ncurses.m4 \ + $(top_srcdir)/m4.include/mc-with-screen-slang.m4 \ + $(top_srcdir)/m4.include/mc-with-internal-edit.m4 \ + $(top_srcdir)/m4.include/mc-subshell.m4 \ + $(top_srcdir)/m4.include/mc-background.m4 \ + $(top_srcdir)/m4.include/mc-ext2fs-attr.m4 \ + $(top_srcdir)/m4.include/mc-glib.m4 \ + $(top_srcdir)/m4.include/mc-vfs.m4 \ + $(top_srcdir)/m4.include/vfs/rpc.m4 \ + $(top_srcdir)/m4.include/vfs/socket.m4 \ + $(top_srcdir)/m4.include/vfs/mc-vfs-extfs.m4 \ + $(top_srcdir)/m4.include/vfs/mc-vfs-sfs.m4 \ + $(top_srcdir)/m4.include/vfs/mc-vfs-ftp.m4 \ + $(top_srcdir)/m4.include/vfs/mc-vfs-sftp.m4 \ + $(top_srcdir)/m4.include/vfs/mc-vfs-fish.m4 \ + $(top_srcdir)/m4.include/vfs/mc-vfs-undelfs.m4 \ + $(top_srcdir)/m4.include/vfs/mc-vfs-tarfs.m4 \ + $(top_srcdir)/m4.include/vfs/mc-vfs-cpiofs.m4 \ + $(top_srcdir)/m4.include/mc-version.m4 \ + $(top_srcdir)/m4.include/mc-tests.m4 \ + $(top_srcdir)/m4.include/mc-i18n.m4 \ + $(top_srcdir)/m4.include/mc-assert.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libmcskin_la_LIBADD = +am_libmcskin_la_OBJECTS = colors.lo colors-old.lo common.lo \ + hc-skins.lo ini-file.lo lines.lo +libmcskin_la_OBJECTS = $(am_libmcskin_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/colors-old.Plo \ + ./$(DEPDIR)/colors.Plo ./$(DEPDIR)/common.Plo \ + ./$(DEPDIR)/hc-skins.Plo ./$(DEPDIR)/ini-file.Plo \ + ./$(DEPDIR)/lines.Plo +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libmcskin_la_SOURCES) +DIST_SOURCES = $(libmcskin_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +COM_ERR_CFLAGS = @COM_ERR_CFLAGS@ +COM_ERR_LIBS = @COM_ERR_LIBS@ +CP1251 = @CP1251@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOC_LINGUAS = @DOC_LINGUAS@ +DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DX_CONFIG = @DX_CONFIG@ +DX_DOCDIR = @DX_DOCDIR@ +DX_DOT = @DX_DOT@ +DX_DOXYGEN = @DX_DOXYGEN@ +DX_DVIPS = @DX_DVIPS@ +DX_EGREP = @DX_EGREP@ +DX_ENV = @DX_ENV@ +DX_FLAG_chi = @DX_FLAG_chi@ +DX_FLAG_chm = @DX_FLAG_chm@ +DX_FLAG_doc = @DX_FLAG_doc@ +DX_FLAG_dot = @DX_FLAG_dot@ +DX_FLAG_html = @DX_FLAG_html@ +DX_FLAG_man = @DX_FLAG_man@ +DX_FLAG_pdf = @DX_FLAG_pdf@ +DX_FLAG_ps = @DX_FLAG_ps@ +DX_FLAG_rtf = @DX_FLAG_rtf@ +DX_FLAG_xml = @DX_FLAG_xml@ +DX_HHC = @DX_HHC@ +DX_LATEX = @DX_LATEX@ +DX_MAKEINDEX = @DX_MAKEINDEX@ +DX_PDFLATEX = @DX_PDFLATEX@ +DX_PERL = @DX_PERL@ +DX_PROJECT = @DX_PROJECT@ +E2P_CFLAGS = @E2P_CFLAGS@ +E2P_LIBS = @E2P_LIBS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +EXT2FS_CFLAGS = @EXT2FS_CFLAGS@ +EXT2FS_LIBS = @EXT2FS_LIBS@ +EXTHELPERSDIR = @EXTHELPERSDIR@ +FGREP = @FGREP@ +FILECMD = @FILECMD@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_LIBS = @GLIB_LIBS@ +GMODULE_CFLAGS = @GMODULE_CFLAGS@ +GMODULE_LIBS = @GMODULE_LIBS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +HAVE_FILECMD = @HAVE_FILECMD@ +HAVE_ZIPINFO = @HAVE_ZIPINFO@ +HAVE_nroff = @HAVE_nroff@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBMC_RELEASE = @LIBMC_RELEASE@ +LIBMC_VERSION = @LIBMC_VERSION@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSSH_CFLAGS = @LIBSSH_CFLAGS@ +LIBSSH_LIBS = @LIBSSH_LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANDOC = @MANDOC@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MAN_DATE = @MAN_DATE@ +MAN_FLAGS = @MAN_FLAGS@ +MAN_VERSION = @MAN_VERSION@ +MCLIBS = @MCLIBS@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCRE_CFLAGS = @PCRE_CFLAGS@ +PCRE_LIBS = @PCRE_LIBS@ +PERL = @PERL@ +PERL_FOR_BUILD = @PERL_FOR_BUILD@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POSUB = @POSUB@ +PYTHON = @PYTHON@ +RANLIB = @RANLIB@ +RUBY = @RUBY@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SLANG_CFLAGS = @SLANG_CFLAGS@ +SLANG_LIBS = @SLANG_LIBS@ +STRIP = @STRIP@ +TESTS_LDFLAGS = @TESTS_LDFLAGS@ +UNZIP = @UNZIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +X11_WWW = @X11_WWW@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ZIP = @ZIP@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LTLIBRARIES = libmcskin.la +libmcskin_la_SOURCES = \ + colors.c \ + colors-old.c \ + common.c \ + hc-skins.c \ + ini-file.c \ + lines.c \ + internal.h + +AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/skin/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu lib/skin/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libmcskin.la: $(libmcskin_la_OBJECTS) $(libmcskin_la_DEPENDENCIES) $(EXTRA_libmcskin_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libmcskin_la_OBJECTS) $(libmcskin_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/colors-old.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/colors.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hc-skins.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ini-file.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lines.Plo@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/colors-old.Plo + -rm -f ./$(DEPDIR)/colors.Plo + -rm -f ./$(DEPDIR)/common.Plo + -rm -f ./$(DEPDIR)/hc-skins.Plo + -rm -f ./$(DEPDIR)/ini-file.Plo + -rm -f ./$(DEPDIR)/lines.Plo + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/colors-old.Plo + -rm -f ./$(DEPDIR)/colors.Plo + -rm -f ./$(DEPDIR)/common.Plo + -rm -f ./$(DEPDIR)/hc-skins.Plo + -rm -f ./$(DEPDIR)/ini-file.Plo + -rm -f ./$(DEPDIR)/lines.Plo + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libtool clean-noinstLTLIBRARIES \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/lib/skin/colors-old.c b/lib/skin/colors-old.c new file mode 100644 index 0000000..628b2aa --- /dev/null +++ b/lib/skin/colors-old.c @@ -0,0 +1,203 @@ +/* + Skins engine. + Work with colors - backward compatibility + + Copyright (C) 2009-2023 + Free Software Foundation, Inc. + + Written by: + Slava Zanko , 2009 + Egmont Koblinger , 2010 + Andrew Borodin , 2012 + + This file is part of the Midnight Commander. + + The Midnight Commander is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + The Midnight Commander is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include +#include +#include /* strcmp() */ +#include /* size_t */ + +#include "internal.h" + +#include "lib/tty/color.h" + +/*** global variables ****************************************************************************/ + +/*** file scope macro definitions ****************************************************************/ + +/*** forward declarations (file scope functions) *************************************************/ + +/*** file scope type declarations ****************************************************************/ + +typedef struct mc_skin_colors_old_struct +{ + const char *old_color; + const char *group; + const char *key; +} mc_skin_colors_old_t; + +/*** file scope variables ************************************************************************/ + +/* keep this table alphabetically sorted */ +static const mc_skin_colors_old_t old_colors[] = { + {"bbarbutton", "buttonbar", "button"}, + {"bbarhotkey", "buttonbar", "hotkey"}, + {"commandlinemark", "core", "commandlinemark"}, + {"dfocus", "dialog", "dfocus"}, + {"dhotfocus", "dialog", "dhotfocus"}, + {"dhotnormal", "dialog", "dhotnormal"}, + {"disabled", "core", "disabled"}, + {"dnormal", "dialog", "_default_"}, + {"editbg", "editor", "editbg"}, + {"editbold", "editor", "editbold"}, + {"editframe", "editor", "editframe"}, + {"editframeactive", "editor", "editframeactive"}, + {"editframedrag", "editor", "editframedrag"}, + {"editlinestate", "editor", "editlinestate"}, + {"editmarked", "editor", "editmarked"}, + {"editnormal", "editor", "_default_"}, + {"editwhitespace", "editor", "editwhitespace"}, + {"errdhotfocus", "error", "errdhotfocus"}, + {"errdhotnormal", "error", "errdhotnormal"}, + {"errors", "error", "_default_"}, + {"gauge", "core", "gauge"}, + {"header", "core", "header"}, + {"helpbold", "help", "helpbold"}, + {"helpitalic", "help", "helpitalic"}, + {"helplink", "help", "helplink"}, + {"helpnormal", "help", "_default_"}, + {"helpslink", "help", "helpslink"}, + {"input", "core", "input"}, + {"inputmark", "core", "inputmark"}, + {"inputunchanged", "core", "inputunchanged"}, + {"marked", "core", "marked"}, + {"markselect", "core", "markselect"}, + {"menuhot", "menu", "menuhot"}, + {"menuhotsel", "menu", "menuhotsel"}, + {"menuinactive", "menu", "menuinactive"}, + {"menunormal", "menu", "_default_"}, + {"menusel", "menu", "menusel"}, + {"normal", "core", "_default_"}, + {"pmenunormal", "popupmenu", "_default_"}, + {"pmenusel", "popupmenu", "menusel"}, + {"pmenutitle", "popupmenu", "menutitle"}, + {"reverse", "core", "reverse"}, + {"selected", "core", "selected"}, + {"statusbar", "statusbar", "_default_"}, + {"viewbold", "viewer", "viewbold"}, + {"viewnormal", "viewer", "_default_"}, + {"viewselected", "viewer", "viewselected"}, + {"viewunderline", "viewer", "viewunderline"} +}; + +static const size_t num_old_colors = G_N_ELEMENTS (old_colors); + +/* --------------------------------------------------------------------------------------------- */ +/*** file scope functions ************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +static int +old_color_comparator (const void *p1, const void *p2) +{ + const mc_skin_colors_old_t *m1 = (const mc_skin_colors_old_t *) p1; + const mc_skin_colors_old_t *m2 = (const mc_skin_colors_old_t *) p2; + + return strcmp (m1->old_color, m2->old_color); +} + +/* --------------------------------------------------------------------------------------------- */ + +static gboolean +mc_skin_colors_old_transform (const char *old_color, const char **group, const char **key) +{ + const mc_skin_colors_old_t oc = { old_color, NULL, NULL }; + mc_skin_colors_old_t *res; + + if (old_color == NULL) + return FALSE; + + res = (mc_skin_colors_old_t *) bsearch (&oc, old_colors, num_old_colors, + sizeof (old_colors[0]), old_color_comparator); + + if (res == NULL) + return FALSE; + + if (group != NULL) + *group = res->group; + if (key != NULL) + *key = res->key; + return TRUE; +} + +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_string) +{ + gchar **colors, **orig_colors; + + if (the_color_string == NULL) + return; + + orig_colors = g_strsplit (the_color_string, ":", -1); + if (orig_colors == NULL) + return; + + for (colors = orig_colors; *colors != NULL; colors++) + { + gchar **key_val; + const gchar *skin_group, *skin_key; + + key_val = g_strsplit_set (*colors, "=,", 4); + + if (key_val == NULL) + continue; + + if (key_val[1] != NULL && mc_skin_colors_old_transform (key_val[0], &skin_group, &skin_key)) + { + gchar *skin_val; + + if (key_val[2] == NULL) + skin_val = g_strdup_printf ("%s;", key_val[1]); + else if (key_val[3] == NULL) + skin_val = g_strdup_printf ("%s;%s", key_val[1], key_val[2]); + else + skin_val = g_strdup_printf ("%s;%s;%s", key_val[1], key_val[2], key_val[3]); + + mc_config_set_string (mc_skin->config, skin_group, skin_key, skin_val); + g_free (skin_val); + } + + g_strfreev (key_val); + } + g_strfreev (orig_colors); +} + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +void +mc_skin_colors_old_configure (mc_skin_t * mc_skin) +{ + mc_skin_colors_old_configure_one (mc_skin, mc_global.tty.setup_color_string); + mc_skin_colors_old_configure_one (mc_skin, mc_global.tty.term_color_string); + mc_skin_colors_old_configure_one (mc_skin, getenv ("MC_COLOR_TABLE")); + mc_skin_colors_old_configure_one (mc_skin, mc_global.tty.command_line_colors); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/skin/colors.c b/lib/skin/colors.c new file mode 100644 index 0000000..87e9442 --- /dev/null +++ b/lib/skin/colors.c @@ -0,0 +1,422 @@ +/* + Skins engine. + Work with colors + + Copyright (C) 2009-2023 + Free Software Foundation, Inc. + + Written by: + Slava Zanko , 2009 + Egmont Koblinger , 2010 + Andrew Borodin , 2012 + + This file is part of the Midnight Commander. + + The Midnight Commander is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + The Midnight Commander is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include +#include + +#include "internal.h" + +#include "lib/tty/color.h" + +/*** global variables ****************************************************************************/ + +int mc_skin_color__cache[MC_SKIN_COLOR_CACHE_COUNT]; + +/*** file scope macro definitions ****************************************************************/ + +/*** file scope type declarations ****************************************************************/ + +/*** forward declarations (file scope functions) *************************************************/ + +/*** file scope variables ************************************************************************/ + +/* --------------------------------------------------------------------------------------------- */ +/*** file scope functions ************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +static mc_skin_color_t * +mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key) +{ + gchar kname[BUF_TINY]; + mc_skin_color_t *mc_skin_color; + + if (group == NULL || key == NULL) + return NULL; + + if (mc_skin == NULL) + mc_skin = &mc_skin__default; + + g_snprintf (kname, sizeof (kname), "%s.%s", group, key); + mc_skin_color = (mc_skin_color_t *) g_hash_table_lookup (mc_skin->colors, (gpointer) kname); + + return mc_skin_color; +} + +/* --------------------------------------------------------------------------------------------- */ + +#if 0 +static void +mc_skin_color_remove_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key) +{ + gchar kname[BUF_TINY]; + if (group == NULL || key == NULL) + return; + + if (mc_skin == NULL) + mc_skin = &mc_skin__default; + + g_snprintf (kname, sizeof (kname), "%s.%s", group, key); + g_hash_table_remove (mc_skin->colors, (gpointer) kname); +} +#endif + +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_skin_color_add_to_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key, + mc_skin_color_t * mc_skin_color) +{ + gchar *kname; + + kname = g_strdup_printf ("%s.%s", group, key); + if (kname != NULL) + { + if (g_hash_table_lookup (mc_skin->colors, (gpointer) kname) != NULL) + g_hash_table_remove (mc_skin->colors, (gpointer) kname); + + g_hash_table_insert (mc_skin->colors, (gpointer) kname, (gpointer) mc_skin_color); + } +} + +/* --------------------------------------------------------------------------------------------- */ + +static mc_skin_color_t * +mc_skin_color_get_with_defaults (const gchar * group, const gchar * name) +{ + mc_skin_color_t *mc_skin_color; + + mc_skin_color = mc_skin_color_get_from_hash (NULL, group, name); + if (mc_skin_color != NULL) + return mc_skin_color; + + mc_skin_color = mc_skin_color_get_from_hash (NULL, group, "_default_"); + if (mc_skin_color != NULL) + return mc_skin_color; + + mc_skin_color = mc_skin_color_get_from_hash (NULL, "core", "_default_"); + return mc_skin_color; +} + +/* --------------------------------------------------------------------------------------------- */ + +/* If an alias is found, alloc a new string for the resolved value and free the input parameter. + Otherwise it's a no-op returning the original string. */ +static gchar * +mc_skin_color_look_up_alias (mc_skin_t * mc_skin, gchar * str) +{ + gchar *orig, *str2; + int hop = 0; + + orig = g_strdup (str); + str2 = g_strdup (str); + + while (TRUE) + { + gchar **values; + gsize items_count; + + values = mc_config_get_string_list (mc_skin->config, "aliases", str, &items_count); + if (items_count != 1) + { + /* No such alias declaration found, that is, we've got the resolved value. */ + g_strfreev (values); + g_free (str2); + g_free (orig); + return str; + } + + g_free (str); + str = g_strdup (values[0]); + g_strfreev (values); + + /* str2 resolves at half speed than str. This is used for loop detection. */ + if (hop++ % 2 != 0) + { + values = mc_config_get_string_list (mc_skin->config, "aliases", str2, &items_count); + g_assert (items_count == 1); + g_free (str2); + str2 = g_strdup (values[0]); + g_strfreev (values); + + if (strcmp (str, str2) == 0) + { + /* Loop detected. */ + fprintf (stderr, + "Loop detected while trying to resolve alias \"%s\" in skin \"%s\"\n", + orig, mc_skin->name); + g_free (str); + g_free (str2); + return orig; + } + } + } +} + +/* --------------------------------------------------------------------------------------------- */ + +static mc_skin_color_t * +mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const gchar * key) +{ + gsize items_count; + gchar **values; + mc_skin_color_t *mc_skin_color, *tmp; + + values = mc_config_get_string_list (mc_skin->config, group, key, &items_count); + if (values == NULL || values[0] == NULL) + { + g_strfreev (values); + return NULL; + } + + mc_skin_color = g_try_new0 (mc_skin_color_t, 1); + if (mc_skin_color == NULL) + { + g_strfreev (values); + return NULL; + } + + tmp = mc_skin_color_get_with_defaults (group, "_default_"); + mc_skin_color->fgcolor = (items_count > 0 && values[0][0]) ? + mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[0]))) : + (tmp != NULL) ? g_strdup (tmp->fgcolor) : NULL; + mc_skin_color->bgcolor = (items_count > 1 && values[1][0]) ? + mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[1]))) : + (tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL; + mc_skin_color->attrs = (items_count > 2 && values[2][0]) ? + mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[2]))) : + (tmp != NULL) ? g_strdup (tmp->attrs) : NULL; + + g_strfreev (values); + + mc_skin_color->pair_index = + tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, + mc_skin_color->attrs, FALSE); + + return mc_skin_color; +} + +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_skin_color_set_default_for_terminal (mc_skin_t * mc_skin) +{ + mc_skin_color_t *mc_skin_color; + mc_skin_color = g_try_new0 (mc_skin_color_t, 1); + if (mc_skin_color != NULL) + { + mc_skin_color->fgcolor = g_strdup ("default"); + mc_skin_color->bgcolor = g_strdup ("default"); + mc_skin_color->attrs = NULL; + mc_skin_color->pair_index = + tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, + mc_skin_color->attrs, FALSE); + mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color); + } +} + +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_skin_color_cache_init (void) +{ + DEFAULT_COLOR = mc_skin_color_get ("skin", "terminal_default_color"); + NORMAL_COLOR = mc_skin_color_get ("core", "_default_"); + MARKED_COLOR = mc_skin_color_get ("core", "marked"); + SELECTED_COLOR = mc_skin_color_get ("core", "selected"); + MARKED_SELECTED_COLOR = mc_skin_color_get ("core", "markselect"); + DISABLED_COLOR = mc_skin_color_get ("core", "disabled"); + REVERSE_COLOR = mc_skin_color_get ("core", "reverse"); + HEADER_COLOR = mc_skin_color_get ("core", "header"); + COMMAND_MARK_COLOR = mc_skin_color_get ("core", "commandlinemark"); + SHADOW_COLOR = mc_skin_color_get ("core", "shadow"); + + COLOR_NORMAL = mc_skin_color_get ("dialog", "_default_"); + COLOR_FOCUS = mc_skin_color_get ("dialog", "dfocus"); + COLOR_HOT_NORMAL = mc_skin_color_get ("dialog", "dhotnormal"); + COLOR_HOT_FOCUS = mc_skin_color_get ("dialog", "dhotfocus"); + COLOR_TITLE = mc_skin_color_get ("dialog", "dtitle"); + + ERROR_COLOR = mc_skin_color_get ("error", "_default_"); + ERROR_FOCUS = mc_skin_color_get ("error", "errdfocus"); + ERROR_HOT_NORMAL = mc_skin_color_get ("error", "errdhotnormal"); + ERROR_HOT_FOCUS = mc_skin_color_get ("error", "errdhotfocus"); + ERROR_TITLE = mc_skin_color_get ("error", "errdtitle"); + + MENU_ENTRY_COLOR = mc_skin_color_get ("menu", "_default_"); + MENU_SELECTED_COLOR = mc_skin_color_get ("menu", "menusel"); + MENU_HOT_COLOR = mc_skin_color_get ("menu", "menuhot"); + MENU_HOTSEL_COLOR = mc_skin_color_get ("menu", "menuhotsel"); + MENU_INACTIVE_COLOR = mc_skin_color_get ("menu", "menuinactive"); + + PMENU_ENTRY_COLOR = mc_skin_color_get ("popupmenu", "_default_"); + PMENU_SELECTED_COLOR = mc_skin_color_get ("popupmenu", "menusel"); + PMENU_TITLE_COLOR = mc_skin_color_get ("popupmenu", "menutitle"); + + BUTTONBAR_HOTKEY_COLOR = mc_skin_color_get ("buttonbar", "hotkey"); + BUTTONBAR_BUTTON_COLOR = mc_skin_color_get ("buttonbar", "button"); + + STATUSBAR_COLOR = mc_skin_color_get ("statusbar", "_default_"); + + GAUGE_COLOR = mc_skin_color_get ("core", "gauge"); + INPUT_COLOR = mc_skin_color_get ("core", "input"); + INPUT_HISTORY_COLOR = mc_skin_color_get ("core", "inputhistory"); + COMMAND_HISTORY_COLOR = mc_skin_color_get ("core", "commandhistory"); + INPUT_MARK_COLOR = mc_skin_color_get ("core", "inputmark"); + INPUT_UNCHANGED_COLOR = mc_skin_color_get ("core", "inputunchanged"); + + HELP_NORMAL_COLOR = mc_skin_color_get ("help", "_default_"); + HELP_ITALIC_COLOR = mc_skin_color_get ("help", "helpitalic"); + HELP_BOLD_COLOR = mc_skin_color_get ("help", "helpbold"); + HELP_LINK_COLOR = mc_skin_color_get ("help", "helplink"); + HELP_SLINK_COLOR = mc_skin_color_get ("help", "helpslink"); + HELP_TITLE_COLOR = mc_skin_color_get ("help", "helptitle"); + + VIEW_NORMAL_COLOR = mc_skin_color_get ("viewer", "_default_"); + VIEW_BOLD_COLOR = mc_skin_color_get ("viewer", "viewbold"); + VIEW_UNDERLINED_COLOR = mc_skin_color_get ("viewer", "viewunderline"); + VIEW_SELECTED_COLOR = mc_skin_color_get ("viewer", "viewselected"); + + EDITOR_NORMAL_COLOR = mc_skin_color_get ("editor", "_default_"); + EDITOR_BOLD_COLOR = mc_skin_color_get ("editor", "editbold"); + EDITOR_MARKED_COLOR = mc_skin_color_get ("editor", "editmarked"); + EDITOR_WHITESPACE_COLOR = mc_skin_color_get ("editor", "editwhitespace"); + EDITOR_RIGHT_MARGIN_COLOR = mc_skin_color_get ("editor", "editrightmargin"); + LINE_STATE_COLOR = mc_skin_color_get ("editor", "editlinestate"); + EDITOR_BACKGROUND = mc_skin_color_get ("editor", "editbg"); + EDITOR_FRAME = mc_skin_color_get ("editor", "editframe"); + EDITOR_FRAME_ACTIVE = mc_skin_color_get ("editor", "editframeactive"); + EDITOR_FRAME_DRAG = mc_skin_color_get ("editor", "editframedrag"); + + BOOK_MARK_COLOR = mc_skin_color_get ("editor", "bookmark"); + BOOK_MARK_FOUND_COLOR = mc_skin_color_get ("editor", "bookmarkfound"); + + DFF_ADD_COLOR = mc_skin_color_get ("diffviewer", "added"); + DFF_CHG_COLOR = mc_skin_color_get ("diffviewer", "changedline"); + DFF_CHH_COLOR = mc_skin_color_get ("diffviewer", "changednew"); + DFF_CHD_COLOR = mc_skin_color_get ("diffviewer", "changed"); + DFF_DEL_COLOR = mc_skin_color_get ("diffviewer", "removed"); + DFF_ERROR_COLOR = mc_skin_color_get ("diffviewer", "error"); +} + +/* --------------------------------------------------------------------------------------------- */ + +static gboolean +mc_skin_color_check_inisection (const gchar * group) +{ + return !((strcasecmp ("skin", group) == 0) || (strcasecmp ("aliases", group) == 0) + || (strcasecmp ("lines", group) == 0) || (strncasecmp ("widget-", group, 7) == 0)); +} + +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_skin_color_check_bw_mode (mc_skin_t * mc_skin) +{ + gchar **groups, **orig_groups; + + if (tty_use_colors () && !mc_global.tty.disable_colors) + return; + + orig_groups = mc_config_get_groups (mc_skin->config, NULL); + + for (groups = orig_groups; *groups != NULL; groups++) + if (mc_skin_color_check_inisection (*groups)) + mc_config_del_group (mc_skin->config, *groups); + + g_strfreev (orig_groups); + + mc_skin_hardcoded_blackwhite_colors (mc_skin); +} + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +gboolean +mc_skin_color_parse_ini_file (mc_skin_t * mc_skin) +{ + gboolean ret = FALSE; + gsize items_count; + gchar **groups, **orig_groups; + mc_skin_color_t *mc_skin_color; + + mc_skin_color_check_bw_mode (mc_skin); + + orig_groups = mc_config_get_groups (mc_skin->config, &items_count); + if (*orig_groups == NULL) + goto ret; + + /* as first, need to set up default colors */ + mc_skin_color_set_default_for_terminal (mc_skin); + mc_skin_color = mc_skin_color_get_from_ini_file (mc_skin, "core", "_default_"); + if (mc_skin_color == NULL) + goto ret; + + tty_color_set_defaults (mc_skin_color->fgcolor, mc_skin_color->bgcolor, mc_skin_color->attrs); + mc_skin_color_add_to_hash (mc_skin, "core", "_default_", mc_skin_color); + + for (groups = orig_groups; *groups != NULL; groups++) + { + gchar **keys, **orig_keys; + + if (!mc_skin_color_check_inisection (*groups)) + continue; + + orig_keys = mc_config_get_keys (mc_skin->config, *groups, NULL); + + for (keys = orig_keys; *keys != NULL; keys++) + { + mc_skin_color = mc_skin_color_get_from_ini_file (mc_skin, *groups, *keys); + if (mc_skin_color != NULL) + mc_skin_color_add_to_hash (mc_skin, *groups, *keys, mc_skin_color); + } + g_strfreev (orig_keys); + } + + mc_skin_color_cache_init (); + + ret = TRUE; + + ret: + g_strfreev (orig_groups); + return ret; +} + +/* --------------------------------------------------------------------------------------------- */ + +int +mc_skin_color_get (const gchar * group, const gchar * name) +{ + mc_skin_color_t *mc_skin_color; + + mc_skin_color = mc_skin_color_get_with_defaults (group, name); + + return (mc_skin_color != NULL) ? mc_skin_color->pair_index : 0; +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/skin/common.c b/lib/skin/common.c new file mode 100644 index 0000000..85790f2 --- /dev/null +++ b/lib/skin/common.c @@ -0,0 +1,209 @@ +/* + Skins engine. + Interface functions + + Copyright (C) 2009-2023 + Free Software Foundation, Inc. + + Written by: + Slava Zanko , 2009 + Egmont Koblinger , 2010 + + This file is part of the Midnight Commander. + + The Midnight Commander is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + The Midnight Commander is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include +#include + +#include "internal.h" +#include "lib/util.h" + +#include "lib/tty/color.h" /* tty_use_256colors(); */ + +/*** global variables ****************************************************************************/ + +mc_skin_t mc_skin__default; + +/*** file scope macro definitions ****************************************************************/ + +/*** file scope type declarations ****************************************************************/ + +/*** forward declarations (file scope functions) *************************************************/ + +/*** file scope variables ************************************************************************/ + +static gboolean mc_skin_is_init = FALSE; + +/* --------------------------------------------------------------------------------------------- */ +/*** file scope functions ************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_skin_hash_destroy_value (gpointer data) +{ + mc_skin_color_t *mc_skin_color = (mc_skin_color_t *) data; + g_free (mc_skin_color->fgcolor); + g_free (mc_skin_color->bgcolor); + g_free (mc_skin_color->attrs); + g_free (mc_skin_color); +} + +/* --------------------------------------------------------------------------------------------- */ + +static char * +mc_skin_get_default_name (void) +{ + char *tmp_str; + + /* from command line */ + if (mc_global.tty.skin != NULL) + return g_strdup (mc_global.tty.skin); + + /* from envirovement variable */ + tmp_str = getenv ("MC_SKIN"); + if (tmp_str != NULL) + return g_strdup (tmp_str); + + /* from config. Or 'default' if no present in config */ + return mc_config_get_string (mc_global.main_config, CONFIG_APP_SECTION, "skin", "default"); +} + +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_skin_reinit (void) +{ + mc_skin_deinit (); + mc_skin__default.name = mc_skin_get_default_name (); + mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, mc_skin_hash_destroy_value); +} + +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_skin_try_to_load_default (void) +{ + mc_skin_reinit (); + g_free (mc_skin__default.name); + mc_skin__default.name = g_strdup ("default"); + if (!mc_skin_ini_file_load (&mc_skin__default)) + { + mc_skin_reinit (); + mc_skin_set_hardcoded_skin (&mc_skin__default); + } +} + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +gboolean +mc_skin_init (const gchar * skin_override, GError ** mcerror) +{ + gboolean is_good_init = TRUE; + GError *error = NULL; + + mc_return_val_if_error (mcerror, FALSE); + + mc_skin__default.have_256_colors = FALSE; + mc_skin__default.have_true_colors = FALSE; + + mc_skin__default.name = + skin_override != NULL ? g_strdup (skin_override) : mc_skin_get_default_name (); + + mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, mc_skin_hash_destroy_value); + if (!mc_skin_ini_file_load (&mc_skin__default)) + { + mc_propagate_error (mcerror, 0, + _("Unable to load '%s' skin.\nDefault skin has been loaded"), + mc_skin__default.name); + mc_skin_try_to_load_default (); + is_good_init = FALSE; + } + mc_skin_colors_old_configure (&mc_skin__default); + + if (!mc_skin_ini_file_parse (&mc_skin__default)) + { + mc_propagate_error (mcerror, 0, + _("Unable to parse '%s' skin.\nDefault skin has been loaded"), + mc_skin__default.name); + + mc_skin_try_to_load_default (); + mc_skin_colors_old_configure (&mc_skin__default); + (void) mc_skin_ini_file_parse (&mc_skin__default); + is_good_init = FALSE; + } + if (is_good_init && mc_skin__default.have_true_colors && !tty_use_truecolors (&error)) + { + mc_propagate_error (mcerror, 0, + _ + ("Unable to use '%s' skin with true colors support:\n%s\nDefault skin has been loaded"), + mc_skin__default.name, error->message); + g_error_free (error); + mc_skin_try_to_load_default (); + mc_skin_colors_old_configure (&mc_skin__default); + (void) mc_skin_ini_file_parse (&mc_skin__default); + is_good_init = FALSE; + } + if (is_good_init && mc_skin__default.have_256_colors && !tty_use_256colors (&error)) + { + mc_propagate_error (mcerror, 0, + _ + ("Unable to use '%s' skin with 256 colors support\non non-256 colors terminal.\nDefault skin has been loaded"), + mc_skin__default.name); + mc_skin_try_to_load_default (); + mc_skin_colors_old_configure (&mc_skin__default); + (void) mc_skin_ini_file_parse (&mc_skin__default); + is_good_init = FALSE; + } + mc_skin_is_init = TRUE; + return is_good_init; +} + +/* --------------------------------------------------------------------------------------------- */ + +void +mc_skin_deinit (void) +{ + tty_color_free_all_tmp (); + tty_color_free_all_non_tmp (); + + MC_PTR_FREE (mc_skin__default.name); + g_hash_table_destroy (mc_skin__default.colors); + mc_skin__default.colors = NULL; + + MC_PTR_FREE (mc_skin__default.description); + + mc_config_deinit (mc_skin__default.config); + mc_skin__default.config = NULL; + + mc_skin_is_init = FALSE; +} + +/* --------------------------------------------------------------------------------------------- */ + +gchar * +mc_skin_get (const gchar * group, const gchar * key, const gchar * default_value) +{ + if (mc_global.tty.ugly_line_drawing) + return g_strdup (default_value); + + return mc_config_get_string (mc_skin__default.config, group, key, default_value); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/skin/hc-skins.c b/lib/skin/hc-skins.c new file mode 100644 index 0000000..95ac73d --- /dev/null +++ b/lib/skin/hc-skins.c @@ -0,0 +1,146 @@ +/* + Skins engine. + Set of hardcoded skins + + Copyright (C) 2009-2023 + Free Software Foundation, Inc. + + Written by: + Slava Zanko , 2009 + Andrew Borodin , 2012 + + This file is part of the Midnight Commander. + + The Midnight Commander is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + The Midnight Commander is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include + +#include "internal.h" + +/*** global variables ****************************************************************************/ + +/*** file scope macro definitions ****************************************************************/ + +#define set_lines(x,y) mc_config_set_string(mc_skin->config, "Lines", x, y) + +/*** file scope type declarations ****************************************************************/ + +/*** file scope variables ************************************************************************/ + +/*** file scope functions ************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +void +mc_skin_hardcoded_blackwhite_colors (mc_skin_t * mc_skin) +{ + mc_config_set_string (mc_skin->config, "core", "_default_", "default;default"); + mc_config_set_string (mc_skin->config, "core", "selected", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "core", "marked", "A_BOLD"); + mc_config_set_string (mc_skin->config, "core", "markselect", "A_BOLD_REVERSE"); + mc_config_set_string (mc_skin->config, "core", "disabled", "default"); + mc_config_set_string (mc_skin->config, "core", "reverse", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "dialog", "_default_", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "dialog", "dfocus", "A_BOLD"); + mc_config_set_string (mc_skin->config, "dialog", "dhotnormal", "A_UNDERLINE"); + mc_config_set_string (mc_skin->config, "dialog", "dhotfocus", "A_UNDERLINE"); + mc_config_set_string (mc_skin->config, "error", "_default_", "A_BOLD"); + mc_config_set_string (mc_skin->config, "menu", "_default_", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "menu", "menuhot", "A_BOLD"); + mc_config_set_string (mc_skin->config, "menu", "menusel", "default"); + mc_config_set_string (mc_skin->config, "menu", "menuhotsel", "A_UNDERLINE"); + mc_config_set_string (mc_skin->config, "menu", "menuinactive", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "popupmenu", "_default_", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "popupmenu", "menusel", "default"); + mc_config_set_string (mc_skin->config, "popupmenu", "menutitle", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "statusbar", "_default_", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "help", "_default_", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "help", "helpitalic", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "help", "helpbold", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "help", "helpslink", "A_BOLD"); + mc_config_set_string (mc_skin->config, "viewer", "viewunderline", "A_UNDERLINE"); + mc_config_set_string (mc_skin->config, "editor", "editbold", "A_BOLD"); + mc_config_set_string (mc_skin->config, "editor", "editmarked", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "editor", "editframeactive", "A_BOLD"); + mc_config_set_string (mc_skin->config, "editor", "editframedrag", "A_REVERSE"); + mc_config_set_string (mc_skin->config, "buttonbar", "hotkey", "default"); + mc_config_set_string (mc_skin->config, "buttonbar", "button", "A_REVERSE"); +} + +/* --------------------------------------------------------------------------------------------- */ + +void +mc_skin_hardcoded_space_lines (mc_skin_t * mc_skin) +{ + /* single lines */ + set_lines ("vert", " "); + set_lines ("horiz", " "); + set_lines ("lefttop", " "); + set_lines ("righttop", " "); + set_lines ("leftbottom", " "); + set_lines ("rightbottom", " "); + set_lines ("topmiddle", " "); + set_lines ("bottommiddle", " "); + set_lines ("leftmiddle", " "); + set_lines ("rightmiddle", " "); + set_lines ("cross", " "); + + set_lines ("dvert", " "); + set_lines ("dhoriz", " "); + set_lines ("dlefttop", " "); + set_lines ("drighttop", " "); + set_lines ("dleftbottom", " "); + set_lines ("drightbottom", " "); + set_lines ("dtopmiddle", " "); + set_lines ("dbottommiddle", " "); + set_lines ("dleftmiddle", " "); + set_lines ("drightmiddle", " "); +} + +/* --------------------------------------------------------------------------------------------- */ + +void +mc_skin_hardcoded_ugly_lines (mc_skin_t * mc_skin) +{ + /* single lines */ + set_lines ("vert", "|"); + set_lines ("horiz", "-"); + set_lines ("lefttop", "+"); + set_lines ("righttop", "+"); + set_lines ("leftbottom", "+"); + set_lines ("rightbottom", "+"); + set_lines ("topmiddle", "-"); + set_lines ("bottommiddle", "-"); + set_lines ("leftmiddle", "|"); + set_lines ("rightmiddle", "|"); + set_lines ("cross", "+"); + + /* double lines */ + set_lines ("dvert", "|"); + set_lines ("dhoriz", "-"); + set_lines ("dlefttop", "+"); + set_lines ("drighttop", "+"); + set_lines ("dleftbottom", "+"); + set_lines ("drightbottom", "+"); + set_lines ("dtopmiddle", "-"); + set_lines ("dbottommiddle", "-"); + set_lines ("dleftmiddle", "|"); + set_lines ("drightmiddle", "|"); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/skin/ini-file.c b/lib/skin/ini-file.c new file mode 100644 index 0000000..6d92435 --- /dev/null +++ b/lib/skin/ini-file.c @@ -0,0 +1,210 @@ +/* + Skins engine. + Reading and parse ini-files + + Copyright (C) 2009-2023 + Free Software Foundation, Inc. + + Written by: + Slava Zanko , 2009. + + This file is part of the Midnight Commander. + + The Midnight Commander is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + The Midnight Commander is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include + +#include + +#include "lib/global.h" /* */ + +#include "internal.h" +#include "lib/fileloc.h" +#include "lib/util.h" /* exist_file() */ + +/*** global variables ****************************************************************************/ + +/*** file scope macro definitions ****************************************************************/ + +/*** file scope type declarations ****************************************************************/ + +/*** forward declarations (file scope functions) *************************************************/ + +/*** file scope variables ************************************************************************/ + +/* --------------------------------------------------------------------------------------------- */ +/*** file scope functions ************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +static void +mc_skin_get_list_from_dir (const gchar * base_dir, GPtrArray * list) +{ + gchar *name; + GDir *dir; + + name = g_build_filename (base_dir, MC_SKINS_DIR, (char *) NULL); + dir = g_dir_open (name, 0, NULL); + g_free (name); + + if (dir != NULL) + { + const gchar *cname; + + while ((cname = g_dir_read_name (dir)) != NULL) + { + gchar *sname; + size_t slen; + unsigned int i; + + slen = strlen (cname); + sname = g_strndup (cname, slen); + + if (slen > 4 && strcmp (sname + slen - 4, ".ini") == 0) + sname[slen - 4] = '\0'; + + for (i = 0; i < list->len; i++) + if (strcmp (sname, g_ptr_array_index (list, i)) == 0) + break; + + if (i < list->len) + g_free (sname); + else + g_ptr_array_add (list, sname); + } + + g_dir_close (dir); + } +} + +/* --------------------------------------------------------------------------------------------- */ + +static int +string_array_comparator (gconstpointer a, gconstpointer b) +{ + return strcmp (*(char *const *) a, *(char *const *) b); +} + +/* --------------------------------------------------------------------------------------------- */ + +static gboolean +mc_skin_ini_file_load_search_in_dir (mc_skin_t * mc_skin, const gchar * base_dir) +{ + char *file_name, *file_name2; + + file_name = g_build_filename (base_dir, MC_SKINS_DIR, mc_skin->name, (char *) NULL); + if (exist_file (file_name)) + { + mc_skin->config = mc_config_init (file_name, TRUE); + g_free (file_name); + return (mc_skin->config != NULL); + } + g_free (file_name); + + file_name2 = g_strdup_printf ("%s.ini", mc_skin->name); + file_name = g_build_filename (base_dir, MC_SKINS_DIR, file_name2, (char *) NULL); + g_free (file_name2); + + if (exist_file (file_name)) + { + mc_skin->config = mc_config_init (file_name, TRUE); + g_free (file_name); + return (mc_skin->config != NULL); + } + g_free (file_name); + return FALSE; +} + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +GPtrArray * +mc_skin_list (void) +{ + GPtrArray *list; + + list = g_ptr_array_new_with_free_func (g_free); + mc_skin_get_list_from_dir (mc_config_get_data_path (), list); + mc_skin_get_list_from_dir (mc_global.sysconfig_dir, list); + mc_skin_get_list_from_dir (mc_global.share_data_dir, list); + g_ptr_array_sort (list, (GCompareFunc) string_array_comparator); + + return list; +} + +/* --------------------------------------------------------------------------------------------- */ + +gboolean +mc_skin_ini_file_load (mc_skin_t * mc_skin) +{ + char *file_name; + + file_name = g_path_get_basename (mc_skin->name); + if (file_name == NULL) + return FALSE; + + if (strcmp (file_name, mc_skin->name) != 0) + { + g_free (file_name); + if (!g_path_is_absolute (mc_skin->name)) + return FALSE; + mc_skin->config = mc_config_init (mc_skin->name, TRUE); + return (mc_skin->config != NULL); + } + g_free (file_name); + + /* ${XDG_DATA_HOME}/mc/skins/ */ + if (mc_skin_ini_file_load_search_in_dir (mc_skin, mc_config_get_data_path ())) + return TRUE; + + /* /etc/mc/skins/ */ + if (mc_skin_ini_file_load_search_in_dir (mc_skin, mc_global.sysconfig_dir)) + return TRUE; + + /* /usr/share/mc/skins/ */ + return mc_skin_ini_file_load_search_in_dir (mc_skin, mc_global.share_data_dir); +} + +/* --------------------------------------------------------------------------------------------- */ + +gboolean +mc_skin_ini_file_parse (mc_skin_t * mc_skin) +{ + mc_skin->description = + mc_config_get_string (mc_skin->config, "skin", "description", "- no description -"); + if (!mc_skin_color_parse_ini_file (mc_skin)) + return FALSE; + + mc_skin_lines_parse_ini_file (mc_skin); + mc_skin->have_256_colors = mc_config_get_bool (mc_skin->config, "skin", "256colors", FALSE); + mc_skin->have_true_colors = mc_config_get_bool (mc_skin->config, "skin", "truecolors", FALSE); + + return TRUE; +} + +/* --------------------------------------------------------------------------------------------- */ + +void +mc_skin_set_hardcoded_skin (mc_skin_t * mc_skin) +{ + mc_skin->config = mc_config_init (NULL, TRUE); + + mc_config_set_string (mc_skin->config, "skin", "description", "hardcoded skin"); + + mc_skin_hardcoded_ugly_lines (mc_skin); + mc_skin_hardcoded_blackwhite_colors (mc_skin); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/skin/internal.h b/lib/skin/internal.h new file mode 100644 index 0000000..8b468db --- /dev/null +++ b/lib/skin/internal.h @@ -0,0 +1,40 @@ +#ifndef MC__SKIN_INTERNAL_H +#define MC__SKIN_INTERNAL_H + +#include "lib/global.h" +#include "lib/skin.h" + +/*** typedefs(not structures) and defined constants **********************************************/ + +/*** enums ***************************************************************************************/ + +/*** structures declarations (and typedefs of structures)*****************************************/ + +typedef struct mc_skin_color_struct +{ + gchar *fgcolor; + gchar *bgcolor; + gchar *attrs; + int pair_index; +} mc_skin_color_t; + +/*** global variables defined in .c file *********************************************************/ + +/*** declarations of public functions ************************************************************/ + +gboolean mc_skin_ini_file_load (mc_skin_t * mc_skin); +gboolean mc_skin_ini_file_parse (mc_skin_t * mc_skin); +void mc_skin_set_hardcoded_skin (mc_skin_t * mc_skin); + +gboolean mc_skin_ini_file_parse_colors (mc_skin_t * mc_skin); +gboolean mc_skin_color_parse_ini_file (mc_skin_t * mc_skin); + +void mc_skin_hardcoded_ugly_lines (mc_skin_t * mc_skin); +void mc_skin_hardcoded_space_lines (mc_skin_t * mc_skin); +void mc_skin_hardcoded_blackwhite_colors (mc_skin_t * mc_skin); + +void mc_skin_colors_old_configure (mc_skin_t * mc_skin); + +/*** inline functions ****************************************************************************/ + +#endif /* MC__SKIN_INTERNAL_H */ diff --git a/lib/skin/lines.c b/lib/skin/lines.c new file mode 100644 index 0000000..90cc028 --- /dev/null +++ b/lib/skin/lines.c @@ -0,0 +1,100 @@ +/* + Skins engine. + Work with line draving chars. + + Copyright (C) 2009-2023 + Free Software Foundation, Inc. + + Written by: + Slava Zanko , 2009. + + This file is part of the Midnight Commander. + + The Midnight Commander is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. + + The Midnight Commander is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include +#include + +#include "internal.h" +#include "lib/tty/tty.h" + +/*** global variables ****************************************************************************/ + +/*** file scope macro definitions ****************************************************************/ + +/*** file scope type declarations ****************************************************************/ + +/*** forward declarations (file scope functions) *************************************************/ + +/*** file scope variables ************************************************************************/ + +/* --------------------------------------------------------------------------------------------- */ +/*** file scope functions ************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +static int +mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name) +{ + int ret; + char *frm_val; + + frm_val = mc_config_get_string_raw (mc_skin->config, "Lines", name, " "); + ret = mc_tty_normalize_lines_char (frm_val); + g_free (frm_val); + + return ret; +} + +/* --------------------------------------------------------------------------------------------- */ +/*** public functions ****************************************************************************/ +/* --------------------------------------------------------------------------------------------- */ + +void +mc_skin_lines_parse_ini_file (mc_skin_t * mc_skin) +{ + if (mc_global.tty.slow_terminal) + mc_skin_hardcoded_space_lines (mc_skin); + else if (mc_global.tty.ugly_line_drawing) + mc_skin_hardcoded_ugly_lines (mc_skin); + else + { + /* single lines */ + mc_tty_frm[MC_TTY_FRM_VERT] = mc_skin_lines_load_frm (mc_skin, "vert"); + mc_tty_frm[MC_TTY_FRM_HORIZ] = mc_skin_lines_load_frm (mc_skin, "horiz"); + mc_tty_frm[MC_TTY_FRM_LEFTTOP] = mc_skin_lines_load_frm (mc_skin, "lefttop"); + mc_tty_frm[MC_TTY_FRM_RIGHTTOP] = mc_skin_lines_load_frm (mc_skin, "righttop"); + mc_tty_frm[MC_TTY_FRM_LEFTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "leftbottom"); + mc_tty_frm[MC_TTY_FRM_RIGHTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "rightbottom"); + mc_tty_frm[MC_TTY_FRM_TOPMIDDLE] = mc_skin_lines_load_frm (mc_skin, "topmiddle"); + mc_tty_frm[MC_TTY_FRM_BOTTOMMIDDLE] = mc_skin_lines_load_frm (mc_skin, "bottommiddle"); + mc_tty_frm[MC_TTY_FRM_LEFTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "leftmiddle"); + mc_tty_frm[MC_TTY_FRM_RIGHTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "rightmiddle"); + mc_tty_frm[MC_TTY_FRM_CROSS] = mc_skin_lines_load_frm (mc_skin, "cross"); + + /* double lines */ + mc_tty_frm[MC_TTY_FRM_DVERT] = mc_skin_lines_load_frm (mc_skin, "dvert"); + mc_tty_frm[MC_TTY_FRM_DHORIZ] = mc_skin_lines_load_frm (mc_skin, "dhoriz"); + mc_tty_frm[MC_TTY_FRM_DLEFTTOP] = mc_skin_lines_load_frm (mc_skin, "dlefttop"); + mc_tty_frm[MC_TTY_FRM_DRIGHTTOP] = mc_skin_lines_load_frm (mc_skin, "drighttop"); + mc_tty_frm[MC_TTY_FRM_DLEFTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "dleftbottom"); + mc_tty_frm[MC_TTY_FRM_DRIGHTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "drightbottom"); + mc_tty_frm[MC_TTY_FRM_DTOPMIDDLE] = mc_skin_lines_load_frm (mc_skin, "dtopmiddle"); + mc_tty_frm[MC_TTY_FRM_DBOTTOMMIDDLE] = mc_skin_lines_load_frm (mc_skin, "dbottommiddle"); + mc_tty_frm[MC_TTY_FRM_DLEFTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "dleftmiddle"); + mc_tty_frm[MC_TTY_FRM_DRIGHTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "drightmiddle"); + } +} + +/* --------------------------------------------------------------------------------------------- */ -- cgit v1.2.3