mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Merge branch '2501_split_lib'
* 2501_split_lib: (25 commits) Added test for checking if library is independ to $(topsrcdir)/src Added configure parameter --enable-mclib for build own shared library update .gitignore for src/vfs/extfs/helpers/ configure.ac: Moved GLib initialization to m4.include/ac-glib.m4 Added manual for events (Russian and English). Lib: removed includes to "src" directory Added events for handle parent_call_string() and parent_call() Use events for suspend mc (by pressing on CTRL+Z) Moved mc_refresh() to lib/widget Use events for calling help window Use events for operate with clipboard (copy/paste to external clipboard, save/load to file) Use events for update panels Moved input_map, listbox_map and dialog_map variables to 'lib' subdirectory. src/background.c: added some forgotten va_end() calls Move check_for_default() function from lib/util.c to src/util.c Moved initialization of mc_global.share_data_dir and mc_global.sysconf_dir to library Move src/filemanager/complete.c to lib/widget/input_complete.c Use events to show VFS messages. Removed mc_main_error_quark() function Use events to check timestamp of panel directories ...
This commit is contained in:
commit
30bc575179
@ -6,6 +6,7 @@ m4_include([m4.include/mc-check-search-type.m4])
|
||||
m4_include([m4.include/ac-get-fs-info.m4])
|
||||
m4_include([m4.include/mc-use-termcap.m4])
|
||||
m4_include([m4.include/mc-with-screen.m4])
|
||||
m4_include([m4.include/ac-g-module-supported.m4])
|
||||
m4_include([m4.include/ac-glib.m4])
|
||||
m4_include([m4.include/mc-vfs.m4])
|
||||
m4_include([m4.include/mc-version.m4])
|
||||
m4_include([m4.include/mc-tests.m4])
|
||||
|
@ -29,7 +29,7 @@ fi
|
||||
cd "$srcdir"
|
||||
|
||||
# The autoconf cache (version after 2.52) is not reliable yet.
|
||||
rm -rf autom4te.cache lib/vfs/mc-vfs/samba/autom4te.cache
|
||||
rm -rf autom4te.cache src/vfs/smbfs/helpers/autom4te.cache
|
||||
|
||||
if test ! -d config; then
|
||||
mkdir config
|
||||
@ -72,16 +72,16 @@ $AUTOMAKE -a
|
||||
test -f Makefile.in || \
|
||||
{ echo "automake failed to generate Makefile.in" >&2; exit 1; }
|
||||
|
||||
cd lib/vfs/mc-vfs/samba
|
||||
cd src/vfs/smbfs/helpers
|
||||
date -u >include/stamp-h.in
|
||||
|
||||
$AUTOHEADER
|
||||
test -f include/config.h.in || \
|
||||
{ echo "autoheader failed to generate lib/vfs/mc-vfs/samba/include/config.h.in" >&2; exit 1; }
|
||||
{ echo "autoheader failed to generate src/vfs/smbfs/helpers/include/config.h.in" >&2; exit 1; }
|
||||
|
||||
$AUTOCONF
|
||||
test -f configure || \
|
||||
{ echo "autoconf failed to generate lib/vfs/mc-vfs/samba/configure" >&2; exit 1; }
|
||||
{ echo "autoconf failed to generate src/vfs/smbfs/helpers/configure" >&2; exit 1; }
|
||||
) || exit 1
|
||||
|
||||
$srcdir/maint/version.sh "$srcdir"
|
||||
|
158
configure.ac
158
configure.ac
@ -11,6 +11,11 @@ AC_CONFIG_AUX_DIR(config)
|
||||
MC_VERSION
|
||||
AM_INIT_AUTOMAKE(mc, ${VERSION} )
|
||||
|
||||
LIBMC_VERSION="0.0.1"
|
||||
LIBMC_RELEASE="1"
|
||||
AC_SUBST(LIBMC_VERSION)
|
||||
AC_SUBST(LIBMC_RELEASE)
|
||||
|
||||
dnl Enable silent rules by default (if yes)
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
@ -43,22 +48,25 @@ DX_INIT_DOXYGEN(mc,doxygen.cfg,devel)
|
||||
|
||||
dnl PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
|
||||
|
||||
dnl
|
||||
dnl First try glib 2.x.
|
||||
dnl Keep this check close to the beginning, so that the users
|
||||
dnl without any glib won't have their time wasted by other checks.
|
||||
dnl
|
||||
AC_CHECK_GLIB
|
||||
|
||||
AC_ARG_WITH([glib_static],
|
||||
[ --with-glib-static Link glib statically [[no]]])
|
||||
|
||||
glib_found=no
|
||||
|
||||
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.8], [glib_found=yes], [:])
|
||||
if test x"$glib_found" = xno; then
|
||||
AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.8)])
|
||||
fi
|
||||
AC_ARG_ENABLE([mclib],
|
||||
[AS_HELP_STRING([--enable-mclib],[ Compile shared library libmc.so [no]])],
|
||||
[
|
||||
if test "x$enableval" = "xno" ; then
|
||||
enable_mclib=no
|
||||
else
|
||||
if test "x$enable_shared" = "xno" ; then
|
||||
AC_MSG_WARN([Build of shared library is disabled. Specify --enable-shared first])
|
||||
enable_mclib=no
|
||||
else
|
||||
enable_mclib=yes
|
||||
fi
|
||||
fi
|
||||
],
|
||||
[enable_mclib=no])
|
||||
|
||||
AM_CONDITIONAL([ENABLE_MCLIB], [test x$enable_mclib = xyes])
|
||||
|
||||
AC_HEADER_MAJOR
|
||||
AC_C_CONST
|
||||
@ -219,43 +227,11 @@ dnl
|
||||
dnl X11 support.
|
||||
dnl Used to read keyboard modifiers when running under X11.
|
||||
AC_PATH_XTRA
|
||||
|
||||
dnl
|
||||
dnl Check if the gmodule functionality supported on this system.
|
||||
AC_G_MODULE_SUPPORTED
|
||||
|
||||
dnl
|
||||
dnl Try to find static libraries for glib and gmodule.
|
||||
dnl
|
||||
if test x$with_glib_static = xyes; then
|
||||
new_GLIB_LIBS=
|
||||
for i in $GLIB_LIBS; do
|
||||
case x$i in
|
||||
x-lglib*)
|
||||
lib=glib ;;
|
||||
x-lgmodule*)
|
||||
lib=gmodule ;;
|
||||
*)
|
||||
lib=
|
||||
add="$i" ;;
|
||||
esac
|
||||
|
||||
if test -n "$lib"; then
|
||||
lib1=`echo $i | sed 's/^-l//'`
|
||||
if test -f "$GLIB_LIBDIR/lib${lib1}.a"; then
|
||||
add="$GLIB_LIBDIR/lib${lib1}.a"
|
||||
else
|
||||
if test -f "$GLIB_LIBDIR/lib${lib}.a"; then
|
||||
add="$GLIB_LIBDIR/lib${lib}.a"
|
||||
else
|
||||
AC_MSG_ERROR([Cannot find static $lib])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
new_GLIB_LIBS="$new_GLIB_LIBS $add"
|
||||
done
|
||||
GLIB_LIBS="$new_GLIB_LIBS"
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Sequent wants getprocessstats
|
||||
dnl
|
||||
@ -489,6 +465,8 @@ if test "x$enable_werror" = xyes; then
|
||||
fi
|
||||
CFLAGS="$mc_configured_cflags $CFLAGS_OPTS $CFLAGS"
|
||||
|
||||
MC_UNIT_TESTS
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(CPPFLAGS)
|
||||
AC_SUBST(LDFLAGS)
|
||||
@ -540,42 +518,64 @@ src/viewer/Makefile
|
||||
src/diffviewer/Makefile
|
||||
src/filemanager/Makefile
|
||||
|
||||
src/vfs/Makefile
|
||||
|
||||
src/vfs/cpio/Makefile
|
||||
|
||||
src/vfs/extfs/Makefile
|
||||
src/vfs/extfs/helpers/Makefile
|
||||
src/vfs/extfs/helpers/a+
|
||||
src/vfs/extfs/helpers/apt+
|
||||
src/vfs/extfs/helpers/audio
|
||||
src/vfs/extfs/helpers/deb
|
||||
src/vfs/extfs/helpers/deba
|
||||
src/vfs/extfs/helpers/debd
|
||||
src/vfs/extfs/helpers/dpkg+
|
||||
src/vfs/extfs/helpers/iso9660
|
||||
src/vfs/extfs/helpers/hp48+
|
||||
src/vfs/extfs/helpers/lslR
|
||||
src/vfs/extfs/helpers/mailfs
|
||||
src/vfs/extfs/helpers/patchfs
|
||||
src/vfs/extfs/helpers/rpms+
|
||||
src/vfs/extfs/helpers/s3+
|
||||
src/vfs/extfs/helpers/uace
|
||||
src/vfs/extfs/helpers/ualz
|
||||
src/vfs/extfs/helpers/uar
|
||||
src/vfs/extfs/helpers/uarc
|
||||
src/vfs/extfs/helpers/uarj
|
||||
src/vfs/extfs/helpers/uc1541
|
||||
src/vfs/extfs/helpers/uha
|
||||
src/vfs/extfs/helpers/ulha
|
||||
src/vfs/extfs/helpers/urar
|
||||
src/vfs/extfs/helpers/uzip
|
||||
src/vfs/extfs/helpers/uzoo
|
||||
|
||||
src/vfs/fish/Makefile
|
||||
src/vfs/fish/helpers/Makefile
|
||||
|
||||
src/vfs/ftpfs/Makefile
|
||||
|
||||
src/vfs/local/Makefile
|
||||
|
||||
src/vfs/sfs/Makefile
|
||||
|
||||
src/vfs/smbfs/Makefile
|
||||
|
||||
src/vfs/tar/Makefile
|
||||
|
||||
src/vfs/undelfs/Makefile
|
||||
|
||||
lib/Makefile
|
||||
lib/event/Makefile
|
||||
lib/filehighlight/Makefile
|
||||
lib/mcconfig/Makefile
|
||||
lib/search/Makefile
|
||||
lib/skin/Makefile
|
||||
lib/strutil/Makefile
|
||||
lib/tty/Makefile
|
||||
|
||||
lib/vfs/Makefile
|
||||
lib/vfs/mc-vfs/Makefile
|
||||
lib/vfs/mc-vfs/extfs/Makefile
|
||||
lib/vfs/mc-vfs/extfs/a+
|
||||
lib/vfs/mc-vfs/extfs/apt+
|
||||
lib/vfs/mc-vfs/extfs/audio
|
||||
lib/vfs/mc-vfs/extfs/deb
|
||||
lib/vfs/mc-vfs/extfs/deba
|
||||
lib/vfs/mc-vfs/extfs/debd
|
||||
lib/vfs/mc-vfs/extfs/dpkg+
|
||||
lib/vfs/mc-vfs/extfs/iso9660
|
||||
lib/vfs/mc-vfs/extfs/hp48+
|
||||
lib/vfs/mc-vfs/extfs/lslR
|
||||
lib/vfs/mc-vfs/extfs/mailfs
|
||||
lib/vfs/mc-vfs/extfs/patchfs
|
||||
lib/vfs/mc-vfs/extfs/rpms+
|
||||
lib/vfs/mc-vfs/extfs/s3+
|
||||
lib/vfs/mc-vfs/extfs/uace
|
||||
lib/vfs/mc-vfs/extfs/ualz
|
||||
lib/vfs/mc-vfs/extfs/uar
|
||||
lib/vfs/mc-vfs/extfs/uarc
|
||||
lib/vfs/mc-vfs/extfs/uarj
|
||||
lib/vfs/mc-vfs/extfs/uc1541
|
||||
lib/vfs/mc-vfs/extfs/uha
|
||||
lib/vfs/mc-vfs/extfs/ulha
|
||||
lib/vfs/mc-vfs/extfs/urar
|
||||
lib/vfs/mc-vfs/extfs/uzip
|
||||
lib/vfs/mc-vfs/extfs/uzoo
|
||||
lib/vfs/mc-vfs/fish/Makefile
|
||||
|
||||
lib/widget/Makefile
|
||||
|
||||
misc/syntax/Makefile
|
||||
@ -602,6 +602,14 @@ intl/Makefile
|
||||
po/Makefile.in
|
||||
])
|
||||
|
||||
if test x$enable_tests != xno; then
|
||||
AC_CONFIG_FILES([
|
||||
lib/tests/Makefile
|
||||
])
|
||||
|
||||
fi
|
||||
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
echo "
|
||||
|
@ -1,8 +1,24 @@
|
||||
SUBDIRS = filehighlight mcconfig search skin tty vfs strutil widget
|
||||
SUBDIRS = event filehighlight mcconfig search skin tty vfs strutil widget .
|
||||
|
||||
if HAVE_TESTS
|
||||
SUBDIRS += tests
|
||||
endif
|
||||
|
||||
if ENABLE_MCLIB
|
||||
LIB_VERSION=`echo $(LIBMC_VERSION) | \
|
||||
tr '.' ' '| \
|
||||
while read v1 v2 v3; do echo $$v2':'$$v3':'$$v1; done`
|
||||
|
||||
libmc_la_LDFLAGS=-no-undefined -version-info $(LIB_VERSION) -release $(LIBMC_RELEASE)
|
||||
|
||||
lib_LTLIBRARIES = libmc.la
|
||||
else
|
||||
noinst_LTLIBRARIES = libmc.la
|
||||
endif
|
||||
|
||||
noinst_LTLIBRARIES = libmc.la
|
||||
|
||||
SUBLIB_includes = \
|
||||
event.h event-types.h \
|
||||
filehighlight.h \
|
||||
mcconfig.h \
|
||||
search.h \
|
||||
@ -12,7 +28,7 @@ SUBLIB_includes = \
|
||||
widget.h
|
||||
|
||||
SRC_mc_utils = \
|
||||
utilunix.c \
|
||||
utilunix.c utilunix.h \
|
||||
unixcompat.h \
|
||||
util.c util.h
|
||||
|
||||
@ -24,7 +40,7 @@ libmc_la_SOURCES = \
|
||||
fs.h \
|
||||
hook.c hook.h \
|
||||
glibcompat.c glibcompat.h \
|
||||
global.h \
|
||||
global.c global.h \
|
||||
keybind.c keybind.h \
|
||||
lock.c lock.h \
|
||||
timefmt.c timefmt.h
|
||||
@ -40,11 +56,23 @@ endif
|
||||
libmc_la_CFLAGS= $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)
|
||||
|
||||
libmc_la_LIBADD = \
|
||||
event/libmcevent.la \
|
||||
filehighlight/libmcfilehighlight.la \
|
||||
mcconfig/libmcconfig.la \
|
||||
search/libsearch.la \
|
||||
strutil/libmcstrutil.la \
|
||||
skin/libmcskin.la \
|
||||
tty/libmctty.la \
|
||||
vfs/mc-vfs/libvfs-mc.la \
|
||||
vfs/libmcvfs.la \
|
||||
widget/libmcwidget.la
|
||||
|
||||
libmc_la_LIBADD += $(MCLIBS) $(SLANGLIB)
|
||||
|
||||
if HAVE_GMODULE
|
||||
libmc_la_LIBADD += $(GMODULE_LIBS)
|
||||
else
|
||||
libmc_la_LIBADD += $(GLIB_LIBS)
|
||||
endif
|
||||
|
||||
libmc_la_LIBADD += $(PCRE_LIBS) $(LIBICONV) $(INTLLIBS)
|
||||
|
||||
|
@ -34,8 +34,6 @@
|
||||
#include "lib/fileloc.h"
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "src/main.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
GPtrArray *codepages = NULL;
|
||||
@ -163,7 +161,7 @@ load_codepages_list_from_file (GPtrArray ** list, const char *fname)
|
||||
|
||||
if (default_codepage != NULL)
|
||||
{
|
||||
display_codepage = get_codepage_index (default_codepage);
|
||||
mc_global.display_codepage = get_codepage_index (default_codepage);
|
||||
g_free (default_codepage);
|
||||
}
|
||||
|
||||
@ -200,12 +198,12 @@ load_codepages_list (void)
|
||||
char *fname;
|
||||
|
||||
/* 1: try load /usr/share/mc/mc.charsets */
|
||||
fname = g_build_filename (mc_share_data_dir, CHARSETS_LIST, (char *) NULL);
|
||||
fname = g_build_filename (mc_global.share_data_dir, CHARSETS_LIST, (char *) NULL);
|
||||
load_codepages_list_from_file (&codepages, fname);
|
||||
g_free (fname);
|
||||
|
||||
/* 2: try load /etc/mc/mc.charsets */
|
||||
fname = g_build_filename (mc_sysconfig_dir, CHARSETS_LIST, (char *) NULL);
|
||||
fname = g_build_filename (mc_global.sysconfig_dir, CHARSETS_LIST, (char *) NULL);
|
||||
load_codepages_list_from_file (&codepages, fname);
|
||||
g_free (fname);
|
||||
|
||||
@ -435,7 +433,7 @@ convert_from_utf_to_current (const char *str)
|
||||
if (!str)
|
||||
return '.';
|
||||
|
||||
cp_to = get_codepage_id (source_codepage);
|
||||
cp_to = get_codepage_id (mc_global.source_codepage);
|
||||
conv = str_crt_conv_to (cp_to);
|
||||
|
||||
if (conv != INVALID_CONV)
|
||||
@ -537,7 +535,7 @@ convert_from_8bit_to_utf_c2 (const char input_char)
|
||||
str[0] = (unsigned char) input_char;
|
||||
str[1] = '\0';
|
||||
|
||||
cp_from = get_codepage_id (source_codepage);
|
||||
cp_from = get_codepage_id (mc_global.source_codepage);
|
||||
conv = str_crt_conv_to (cp_from);
|
||||
|
||||
if (conv != INVALID_CONV)
|
||||
|
@ -54,14 +54,14 @@ void convert_string (unsigned char *str);
|
||||
/*
|
||||
* Converter from utf to selected codepage
|
||||
* param str, utf char
|
||||
* return char in needle codepage (by global int source_codepage)
|
||||
* return char in needle codepage (by global int mc_global.source_codepage)
|
||||
*/
|
||||
unsigned char convert_from_utf_to_current (const char *str);
|
||||
|
||||
/*
|
||||
* Converter from utf to selected codepage
|
||||
* param input_char, gunichar
|
||||
* return char in needle codepage (by global int source_codepage)
|
||||
* return char in needle codepage (by global int mc_global.source_codepage)
|
||||
*/
|
||||
unsigned char convert_from_utf_to_current_c (const int input_char, GIConv conv);
|
||||
|
||||
|
73
lib/event-types.h
Normal file
73
lib/event-types.h
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef MC__EVENT_TYPES_H
|
||||
#define MC__EVENT_TYPES_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/* Event groups for main modules */
|
||||
#define MCEVENT_GROUP_CORE "Core"
|
||||
#define MCEVENT_GROUP_DIFFVIEWER "DiffViewer"
|
||||
#define MCEVENT_GROUP_EDITOR "Editor"
|
||||
#define MCEVENT_GROUP_FILEMANAGER "FileManager"
|
||||
#define MCEVENT_GROUP_VIEWER "Viewer"
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
|
||||
/* MCEVENT_GROUP_CORE:vfs_timestamp */
|
||||
struct vfs_class;
|
||||
typedef struct
|
||||
{
|
||||
struct vfs_class *vclass;
|
||||
gpointer id;
|
||||
gboolean ret;
|
||||
} ev_vfs_stamp_create_t;
|
||||
|
||||
|
||||
/* MCEVENT_GROUP_CORE:vfs_print_message */
|
||||
typedef struct
|
||||
{
|
||||
const char *msg;
|
||||
va_list ap;
|
||||
} ev_vfs_print_message_t;
|
||||
|
||||
/* MCEVENT_GROUP_CORE:clipboard_text_from_file */
|
||||
typedef struct
|
||||
{
|
||||
char **text;
|
||||
gboolean ret;
|
||||
} ev_clipboard_text_from_file_t;
|
||||
|
||||
/* MCEVENT_GROUP_CORE:help */
|
||||
typedef struct
|
||||
{
|
||||
const char *filename;
|
||||
const char *node;
|
||||
} ev_help_t;
|
||||
|
||||
/* MCEVENT_GROUP_CORE:background_parent_call */
|
||||
/* MCEVENT_GROUP_CORE:background_parent_call_string */
|
||||
typedef struct
|
||||
{
|
||||
void *routine;
|
||||
gpointer *ctx;
|
||||
int argc;
|
||||
va_list ap;
|
||||
union
|
||||
{
|
||||
int i;
|
||||
char *s;
|
||||
} ret;
|
||||
} ev_background_parent_call_t;
|
||||
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__EVENT_TYPES_H */
|
45
lib/event.h
Normal file
45
lib/event.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef MC__EVENT_H
|
||||
#define MC__EVENT_H
|
||||
|
||||
#include "event-types.h"
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
typedef gboolean (*mc_event_callback_func_t) (const gchar *, const gchar *, gpointer, gpointer);
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *event_group_name;
|
||||
const char *event_name;
|
||||
mc_event_callback_func_t cb;
|
||||
gpointer init_data;
|
||||
} event_init_t;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/* event.c: */
|
||||
gboolean mc_event_init (GError **);
|
||||
gboolean mc_event_deinit (GError **);
|
||||
|
||||
|
||||
/* manage.c: */
|
||||
gboolean mc_event_add (const gchar *, const gchar *, mc_event_callback_func_t, gpointer, GError **);
|
||||
void mc_event_del (const gchar *, const gchar *, mc_event_callback_func_t);
|
||||
void mc_event_destroy (const gchar *, const gchar *);
|
||||
void mc_event_group_del (const gchar *);
|
||||
gboolean mc_event_present (const gchar *, const gchar *);
|
||||
gboolean mc_event_mass_add (event_init_t *, GError **);
|
||||
|
||||
/* raise.c: */
|
||||
gboolean mc_event_raise (const gchar *, const gchar *, gpointer);
|
||||
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__EVENT_H */
|
12
lib/event/Makefile.am
Normal file
12
lib/event/Makefile.am
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
noinst_LTLIBRARIES = libmcevent.la
|
||||
|
||||
libmcevent_la_SOURCES = \
|
||||
event.c \
|
||||
internal.h \
|
||||
manage.c \
|
||||
raise.c
|
||||
|
||||
libmcevent_la_CFLAGS=-I$(top_srcdir) \
|
||||
$(GLIB_CFLAGS) $(PCRE_CFLAGS) \
|
||||
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
|
129
lib/event/event-ru.txt
Normal file
129
lib/event/event-ru.txt
Normal file
@ -0,0 +1,129 @@
|
||||
= СОБЫТИЯ =
|
||||
|
||||
В mc используется система событий, основанная на технологии быстрых бинарных деревьев.
|
||||
|
||||
== Вступление ==
|
||||
|
||||
Система событий, в первую очередь, призвана отвязать на уровне исходных текстов источник события и обработчик.
|
||||
Например, в модуле VFS используется функция вывода сообщений, которая определена в исходных текстах (не в lib).
|
||||
В lib определение этой функции будет затруднительным (потому что функция делает множество вызовов на другие
|
||||
функции из src). В данном случае можно представить эту функцию как обработчик события, а сам процесс вывода
|
||||
сообщения от VFS на экран как непосредственно событие. В начале запуска mc функцию вывода сообщений необходимо
|
||||
зарегистрировать как обработчик события; в последствии при необходимости выдачи сообщений нужно просто вызвать
|
||||
событие, абсолютно не волнуясь, привязан ли обработчик к событию, а также какая именно функция сейчас является
|
||||
обработчиком события (вероятна ситуация, при которой позже загрузился плагин и переопределил этот обработчик
|
||||
событий на себя).
|
||||
|
||||
=== Использование ===
|
||||
|
||||
Не везде и не всегда применимы события. Самое трудное порой бывает решить, это должна быть простая функция или это
|
||||
должно быть событие. Наиболее правильным будет заменить все функции (или части switch(){case:}), используемые при
|
||||
обработке кейбиндингов. Все кейбиндинги описаны в lib/keybind.h
|
||||
|
||||
Вторым аргументом при выборе решения (обработчик события или функция) должна стать мысль, что функцию в обработчик
|
||||
события "превратить" легко; обратный процесс (обработчик в функцию) будет значительно сложнее - хотя бы потому,
|
||||
что на одном событии может "висеть" множество обработчиков, и каждый может зависеть от работы предыдущего.
|
||||
|
||||
Третьим аргументом при выборе в пользу обработчиков событий могут стать плагины (когда появятся). В данном случае
|
||||
события - это способ дать плагинам доступ к внутренним ресурсам приложения, не "пуская" эти плагины в низкоуровневое
|
||||
API. Всё, что нужно будет знать "плагинам" - какое событие с какой структурой надо вызвать и как именно вызвать
|
||||
(#include "lib/event.h").
|
||||
|
||||
== Структура ==
|
||||
|
||||
В общем виде подсистему событий можно представить так:
|
||||
|
||||
|
||||
------------------------------------ }
|
||||
|Группа1 Группа2 ... ГруппаN| } Группы событий (GTree)
|
||||
------------------------------------- }
|
||||
| | |
|
||||
/|\ /|\ /|\
|
||||
/ | \ / | ... ... событиеN }
|
||||
/ | \ / ... }
|
||||
/ | \ ... } События, разбитые на группы
|
||||
| | событие3 } (GTree для каждой группы)
|
||||
| событие2 }
|
||||
событие1 }
|
||||
| | | |
|
||||
f1f2...fN } список обработчиков события (GPtrArray на каждое событие)
|
||||
|
||||
|
||||
Такая схема позволяет группировать события и выполнять более одного обработчика на одно событие.
|
||||
|
||||
== Требования к обработчикам событий ==
|
||||
|
||||
Любой каллбэк должен быть вида:
|
||||
|
||||
gboolean mc_event_callback_func_t (const gchar *event_group, const gchar *event_name, gpointer init_data, gpointer event_data);
|
||||
где:
|
||||
event_group:
|
||||
название группы, в которой было инициировано событие
|
||||
|
||||
event_name:
|
||||
название события. Вместе с названием группы событий позволяют точно идентифицировать событие.
|
||||
Эти параметры могут быть полезны в случае если обработчик события привязан сразу к нескольким событиям
|
||||
и необходимо различать различные события (например, в функции логгирования)
|
||||
|
||||
init_data:
|
||||
Произвольные данные, предоставляемые обработчикам события. Эти данные указываются при добавлении обработчика
|
||||
к событию (инициализационные данные).
|
||||
event_data:
|
||||
Данные, предоставляемые обработчику событий в момент возникновения события.
|
||||
|
||||
Каллбэк должен вернуть TRUE, чтобы разрешить исполниться всем последующим за ним каллбэкам в данном событии; либо
|
||||
FALSE если необходимо немедленно прекратить дальнейшую обработку события (оставшиеся каллбэки не вызываются).
|
||||
|
||||
Если для одного и того же события будет привязано множество каллбэков, то порядок из исполнения будет следующим:
|
||||
"Последним добавился - первым выполнился". Это позволяет в последствии переопределять стандартные обработчики событий
|
||||
(например, в плагинах).
|
||||
|
||||
=== Передача параметров в обработчики событий. Возврат результатов ===
|
||||
|
||||
Из-за унификации обработчиков событий стало невозможным передать определённое количество параметров и
|
||||
получить результат выполнения. Если передачу одного параметра (или приём одного результата от обработчика события)
|
||||
можно произвести простым приведением типа на одну переменную при вызове событий, то при передаче нескольких параметров
|
||||
(или при получении нескольких результатов) такой метод неприменим.
|
||||
|
||||
Для решения этой проблемы можно передавать ранее определённые структуры по универсальному указателю event_data.
|
||||
Все структуры, используемые в обработчиках событий, должны быть определены в файле lib/event-types.h.
|
||||
|
||||
У данного метода (передача параметров указателем на структуру) есть как достоинства, так и недостатки.
|
||||
|
||||
Достоинства:
|
||||
* произвольное количество параметров и их типов;
|
||||
* произвольное количество возвращаемых значений и их типов.
|
||||
|
||||
Недостатки:
|
||||
* вероятность ошибки: вызов события с неправильной структурой. В данном случае обработчик приведёт указатель к той
|
||||
структуре, на которую он рассчитан. При этом возможны весёлые глюки с отладкой (особенно если нет сразу segfault);
|
||||
* необходимость иметь ранее определённые структуры для того, чтобы и обработчик события, и инициатор события могли бы
|
||||
без проблем "общаться" между собой.
|
||||
|
||||
== Примеры использования ==
|
||||
|
||||
=== Логгирование ===
|
||||
|
||||
Рассмотрим пример временного каллбэка, который просто логгирует порядок вызова определённых событий (например,
|
||||
для выявления зацикливаний).
|
||||
|
||||
Сам каллбэк:
|
||||
|
||||
gboolean mc_temp_event_logger (const gchar *event_group, const gchar *event_name, gpointer init_data, gpointer data)
|
||||
{
|
||||
(void) init_data;
|
||||
(void) data;
|
||||
|
||||
mc_log("Event: %s:%s",event_group,event_name);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Добавляем его в src/event_init.c в виде записей к инициализационной структуре
|
||||
перед строчкой "{NULL, NULL, NULL, NULL}":
|
||||
|
||||
{MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", mc_temp_event_logger, NULL},
|
||||
{MCEVENT_GROUP_CORE, "clipboard_file_from_ext_clip", mc_temp_event_logger, NULL},
|
||||
{MCEVENT_GROUP_CORE, "clipboard_text_to_file", mc_temp_event_logger, NULL},
|
||||
{MCEVENT_GROUP_CORE, "clipboard_text_from_file", mc_temp_event_logger, NULL},
|
||||
...(тут любые другие события, которые необходимо мониторить)...
|
||||
|
135
lib/event/event.c
Normal file
135
lib/event/event.c
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
Handle events in application.
|
||||
Interface functions: init/deinit; start/stop
|
||||
|
||||
Copyright (C) 2011 The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011.
|
||||
|
||||
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 2 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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/event.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
GTree *mc_event_grouplist = NULL;
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_event_init (GError ** mcerror)
|
||||
{
|
||||
if (mc_event_grouplist != NULL)
|
||||
{
|
||||
g_propagate_error (mcerror,
|
||||
g_error_new (MC_ERROR, 1,
|
||||
_("Event system already initialized")));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mc_event_grouplist =
|
||||
g_tree_new_full ((GCompareDataFunc) g_ascii_strcasecmp,
|
||||
NULL, (GDestroyNotify) g_free, (GDestroyNotify) g_tree_destroy);
|
||||
|
||||
if (mc_event_grouplist == NULL)
|
||||
{
|
||||
g_propagate_error (mcerror,
|
||||
g_error_new (MC_ERROR, 2,
|
||||
_("Failed to initialize event system")));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_event_deinit (GError ** mcerror)
|
||||
{
|
||||
if (mc_event_grouplist == NULL)
|
||||
{
|
||||
g_propagate_error (mcerror,
|
||||
g_error_new (MC_ERROR, 1,
|
||||
_("Event system not initialized")));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_tree_destroy (mc_event_grouplist);
|
||||
mc_event_grouplist = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_event_mass_add (event_init_t * events, GError ** mcerror)
|
||||
{
|
||||
size_t array_index;
|
||||
|
||||
for (array_index = 0; events[array_index].event_group_name != NULL; array_index++)
|
||||
{
|
||||
if (!mc_event_add (events[array_index].event_group_name,
|
||||
events[array_index].event_name,
|
||||
events[array_index].cb, events[array_index].init_data, mcerror))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_event_present (const gchar *event_group_name, const gchar *event_name)
|
||||
{
|
||||
GTree *event_group;
|
||||
GPtrArray *callbacks;
|
||||
|
||||
if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL)
|
||||
return FALSE;
|
||||
|
||||
event_group = mc_event_get_event_group_by_name (event_group_name, FALSE, NULL);
|
||||
if (event_group == NULL)
|
||||
return FALSE;
|
||||
|
||||
callbacks = mc_event_get_event_by_name (event_group, event_name, FALSE, NULL);
|
||||
if (callbacks == NULL)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
153
lib/event/event.txt
Normal file
153
lib/event/event.txt
Normal file
@ -0,0 +1,153 @@
|
||||
= EVENTS =
|
||||
|
||||
The subsystem of events used in mc is based on fast binary trees engine.
|
||||
|
||||
|
||||
== Introduction ==
|
||||
|
||||
Subsystem of events is primarily designed to detach event source and event
|
||||
handler in source code level. For example, VFS module uses function to show
|
||||
messages, which is defined in the source code (not in the lib). In the lib,
|
||||
definition of this function will be difficult (because the function does
|
||||
a lot of calls of other functions from src). In this case, the transform
|
||||
of this function to event handler is needed, and the display messages process
|
||||
can be used as an event. Function as event handler should be registered
|
||||
at early stage of mc start. Later just call the event, absolutely without
|
||||
worrying whether the handler is tied to the event, and which function
|
||||
is an event handler now (in some situation, plugin will load and reassign
|
||||
this event handler to itself).
|
||||
|
||||
|
||||
=== Usage ===
|
||||
|
||||
Events are applicable in any case. Sometimes it is hard to decide whether
|
||||
it should be a common function or it should be an event handler. The replacement
|
||||
of all functions used in keybindings process to event handler is good choice
|
||||
(or parts of the 'switch () {case:}' in keybindings handlers). All keybindings
|
||||
are described in lib/keybind.h.
|
||||
|
||||
The second argument to choose the solution (event handler or function) should be
|
||||
thought whether that transformation of function to the event handler is easy,
|
||||
the inverse process (handler to function) would be more difficult because
|
||||
one event can have multiple handlers and each handler may depend to another.
|
||||
|
||||
A third argument in the choice in favor of the event handlers can be a plug-ins
|
||||
(in future). In this case events is a way to give access to internal application
|
||||
resources without providing a low-level API. All plug-ins need is to know what and how
|
||||
call the event with proper structure type (#include "lib/event.h").
|
||||
|
||||
|
||||
== Structure ==
|
||||
|
||||
In general, the subsystem of events can be represented as following:
|
||||
|
||||
------------------------------------ }
|
||||
|Group1 Group2 ... GroupN| } Event groups (GTree)
|
||||
------------------------------------- }
|
||||
| | |
|
||||
/|\ /|\ /|\
|
||||
/ | \ / | ... ... eventN }
|
||||
/ | \ / ... }
|
||||
/ | \ ... } Events by groups
|
||||
| | event3 } (GTree for any group)
|
||||
| event2 }
|
||||
event1 }
|
||||
| | | |
|
||||
f1f2...fN } list of event handlers (GPtrArray for any event)
|
||||
|
||||
|
||||
This scheme allows to group events, and perform several handlers for one event.
|
||||
|
||||
|
||||
== Requirements for event handlers ==
|
||||
|
||||
The following function prototype is event handler:
|
||||
|
||||
gboolean mc_event_callback_func_t (
|
||||
const gchar *event_group,
|
||||
const gchar *event_name,
|
||||
gpointer init_data,
|
||||
gpointer event_data
|
||||
);
|
||||
|
||||
where:
|
||||
event_group:
|
||||
name of the group, where event was initiated
|
||||
|
||||
event_name:
|
||||
event name. event_name ans event_group uniquely identify an event.
|
||||
These parameters can be useful if event handler is tied to several events
|
||||
and the distinguish between different events (for example, function of logging)
|
||||
is required.
|
||||
|
||||
init_data:
|
||||
Arbitrary data, provided to the event handler.
|
||||
This data is provided by adding a handler to the event (the initialization data).
|
||||
|
||||
event_data:
|
||||
Data provided to the handler when the event occurred.
|
||||
|
||||
Handler should return TRUE to allow running all other handlers tied to this event;
|
||||
or FALSE if it is necessary to stop further processing of event (the remaining
|
||||
handlers are not called).
|
||||
|
||||
If one event will have multiple handlers, the order of execution is "Last added - first
|
||||
executed". This allows to override the standard event handlers (eg, in plug-ins).
|
||||
|
||||
|
||||
=== Passing parameters to event handlers. Returning rezults ==
|
||||
|
||||
Due to the unification of the event handlers, there is no possibility to pass
|
||||
a certain number of parameters and get the results of execution. Pass of a single
|
||||
parameter (or get one result of an event handler) can be made as simple type casting
|
||||
for one variable when event is called. But this way isn't applicable if pass
|
||||
of several parameters (or get multiple return values) is required.
|
||||
|
||||
To solve this problem, you can pass the previously defined structure as universal
|
||||
pointer event_data. All structures used in the event handlers should be defined
|
||||
in the lib/event-types.h.
|
||||
|
||||
This way (the pass parameters as pointer to structure) has advantages and disadvantages.
|
||||
|
||||
Advantages:
|
||||
* any number of parameters and their types;
|
||||
* any number of return values and their types.
|
||||
|
||||
Disadvantages:
|
||||
* probability of error: call the event with the wrong structure. In this case,
|
||||
the handler will cast pointer to the structure on which it was designed.
|
||||
At this point funny bugs and very long debugging process (especially if segfault
|
||||
doesn't occur immediately) are possible;
|
||||
* in order for an event handler and the initiator of the event to "communicate"
|
||||
with each other, previously defined structures is needed.
|
||||
|
||||
|
||||
== Examples ==
|
||||
|
||||
=== Logging ===
|
||||
|
||||
Consider the example of a temporary handler which simply logged the order
|
||||
of certain events (for example, to detect infinite loop).
|
||||
|
||||
Here event handler:
|
||||
|
||||
gboolean
|
||||
mc_temp_event_logger (const gchar *event_group, const gchar *event_name,
|
||||
gpointer init_data, gpointer data)
|
||||
{
|
||||
(void) init_data;
|
||||
(void) data;
|
||||
|
||||
mc_log("Event: %s:%s",event_group,event_name);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Add the following lines into src/event_init.c before "{NULL, NULL, NULL, NULL}" line
|
||||
as one record to the initialization structure.
|
||||
|
||||
{MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", mc_temp_event_logger, NULL},
|
||||
{MCEVENT_GROUP_CORE, "clipboard_file_from_ext_clip", mc_temp_event_logger, NULL},
|
||||
{MCEVENT_GROUP_CORE, "clipboard_text_to_file", mc_temp_event_logger, NULL},
|
||||
{MCEVENT_GROUP_CORE, "clipboard_text_from_file", mc_temp_event_logger, NULL},
|
||||
|
||||
...(there any other events which you want to monitor)...
|
31
lib/event/internal.h
Normal file
31
lib/event/internal.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef MC_EVENT_INTERNAL_H
|
||||
#define MC_EVENT_INTERNAL_H
|
||||
|
||||
/*** typedefs(not structures) and defined constants ********************/
|
||||
|
||||
/*** enums *************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)***************/
|
||||
|
||||
typedef struct mc_event_callback_struct
|
||||
{
|
||||
gpointer init_data;
|
||||
mc_event_callback_func_t callback;
|
||||
} mc_event_callback_t;
|
||||
|
||||
|
||||
/*** global variables defined in .c file *******************************/
|
||||
|
||||
extern GTree *mc_event_grouplist;
|
||||
|
||||
/*** declarations of public functions **********************************/
|
||||
|
||||
GTree *mc_event_get_event_group_by_name (const gchar * event_group_name, gboolean create_new,
|
||||
GError ** mcerror);
|
||||
GPtrArray *mc_event_get_event_by_name (GTree * event_group, const gchar * event_name,
|
||||
gboolean create_new, GError ** mcerror);
|
||||
mc_event_callback_t *mc_event_is_callback_in_array (GPtrArray * callbacks,
|
||||
mc_event_callback_func_t event_callback);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
#endif /* MC_EVENT_INTERNAL_H */
|
224
lib/event/manage.c
Normal file
224
lib/event/manage.c
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
Handle any events in application.
|
||||
Manage events: add, delete, destroy, search
|
||||
|
||||
Copyright (C) 2011 The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011.
|
||||
|
||||
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 2 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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/event.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
mc_event_group_destroy_value (gpointer data)
|
||||
{
|
||||
GPtrArray *callbacks;
|
||||
|
||||
callbacks = (GPtrArray *) data;
|
||||
g_ptr_array_foreach (callbacks, (GFunc) g_free, NULL);
|
||||
g_ptr_array_free (callbacks, TRUE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_event_add (const gchar * event_group_name, const gchar * event_name,
|
||||
mc_event_callback_func_t event_callback, gpointer event_init_data, GError ** mcerror)
|
||||
{
|
||||
|
||||
GTree *event_group;
|
||||
GPtrArray *callbacks;
|
||||
mc_event_callback_t *cb;
|
||||
|
||||
if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL
|
||||
|| event_callback == NULL)
|
||||
{
|
||||
g_propagate_error (mcerror,
|
||||
g_error_new (MC_ERROR, 1,
|
||||
_("Check input data! Some of parameters are NULL!")));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
event_group = mc_event_get_event_group_by_name (event_group_name, TRUE, mcerror);
|
||||
if (event_group == NULL)
|
||||
return FALSE;
|
||||
|
||||
callbacks = mc_event_get_event_by_name (event_group, event_name, TRUE, mcerror);
|
||||
if (callbacks == NULL)
|
||||
return FALSE;
|
||||
|
||||
cb = mc_event_is_callback_in_array (callbacks, event_callback);
|
||||
if (cb == NULL)
|
||||
{
|
||||
cb = g_new0 (mc_event_callback_t, 1);
|
||||
cb->callback = event_callback;
|
||||
g_ptr_array_add (callbacks, (gpointer) cb);
|
||||
}
|
||||
cb->init_data = event_init_data;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_event_del (const gchar * event_group_name, const gchar * event_name,
|
||||
mc_event_callback_func_t event_callback)
|
||||
{
|
||||
GTree *event_group;
|
||||
GPtrArray *callbacks;
|
||||
mc_event_callback_t *cb;
|
||||
|
||||
if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL
|
||||
|| event_callback == NULL)
|
||||
return;
|
||||
|
||||
event_group = mc_event_get_event_group_by_name (event_group_name, FALSE, NULL);
|
||||
if (event_group == NULL)
|
||||
return;
|
||||
|
||||
callbacks = mc_event_get_event_by_name (event_group, event_name, FALSE, NULL);
|
||||
if (callbacks == NULL)
|
||||
return;
|
||||
|
||||
cb = mc_event_is_callback_in_array (callbacks, event_callback);
|
||||
|
||||
if (cb == NULL)
|
||||
return;
|
||||
|
||||
g_ptr_array_remove (callbacks, (gpointer) cb);
|
||||
g_free ((gpointer) cb);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_event_destroy (const gchar * event_group_name, const gchar * event_name)
|
||||
{
|
||||
GTree *event_group;
|
||||
|
||||
if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL)
|
||||
return;
|
||||
|
||||
event_group = mc_event_get_event_group_by_name (event_group_name, FALSE, NULL);
|
||||
g_tree_remove (event_group, (gconstpointer) event_name);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_event_group_del (const gchar * event_group_name)
|
||||
{
|
||||
|
||||
if (mc_event_grouplist != NULL && event_group_name != NULL)
|
||||
g_tree_remove (mc_event_grouplist, (gconstpointer) event_group_name);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
GTree *
|
||||
mc_event_get_event_group_by_name (const gchar * event_group_name, gboolean create_new,
|
||||
GError ** mcerror)
|
||||
{
|
||||
GTree *event_group;
|
||||
|
||||
event_group = (GTree *) g_tree_lookup (mc_event_grouplist, (gconstpointer) event_group_name);
|
||||
if (event_group == NULL && create_new)
|
||||
{
|
||||
event_group =
|
||||
g_tree_new_full ((GCompareDataFunc) g_ascii_strcasecmp,
|
||||
NULL,
|
||||
(GDestroyNotify) g_free,
|
||||
(GDestroyNotify) mc_event_group_destroy_value);
|
||||
if (event_group == NULL)
|
||||
{
|
||||
g_propagate_error (mcerror,
|
||||
g_error_new (MC_ERROR, 1,
|
||||
_("Unable to create group '%s' for events!"),
|
||||
event_group_name));
|
||||
return NULL;
|
||||
}
|
||||
g_tree_insert (mc_event_grouplist, g_strdup (event_group_name), (gpointer) event_group);
|
||||
}
|
||||
return event_group;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
GPtrArray *
|
||||
mc_event_get_event_by_name (GTree * event_group, const gchar * event_name, gboolean create_new,
|
||||
GError ** mcerror)
|
||||
{
|
||||
GPtrArray *callbacks;
|
||||
|
||||
callbacks = (GPtrArray *) g_tree_lookup (event_group, (gconstpointer) event_name);
|
||||
if (callbacks == NULL && create_new)
|
||||
{
|
||||
callbacks = g_ptr_array_new ();
|
||||
if (callbacks == NULL)
|
||||
{
|
||||
g_propagate_error (mcerror,
|
||||
g_error_new (MC_ERROR, 1,
|
||||
_("Unable to create event '%s'!"), event_name));
|
||||
return NULL;
|
||||
}
|
||||
g_tree_insert (event_group, g_strdup (event_name), (gpointer) callbacks);
|
||||
}
|
||||
return callbacks;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
mc_event_callback_t *
|
||||
mc_event_is_callback_in_array (GPtrArray * callbacks, mc_event_callback_func_t event_callback)
|
||||
{
|
||||
guint array_index;
|
||||
|
||||
for (array_index = 0; array_index < callbacks->len; array_index++)
|
||||
{
|
||||
mc_event_callback_t *cb = g_ptr_array_index (callbacks, array_index);
|
||||
if (cb->callback == event_callback)
|
||||
return cb;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
76
lib/event/raise.c
Normal file
76
lib/event/raise.c
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
Handle any events in application.
|
||||
Raise events.
|
||||
|
||||
Copyright (C) 2011 The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011.
|
||||
|
||||
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 2 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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/event.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
mc_event_raise (const gchar * event_group_name, const gchar * event_name, gpointer event_data)
|
||||
{
|
||||
GTree *event_group;
|
||||
GPtrArray *callbacks;
|
||||
guint array_index;
|
||||
|
||||
if (mc_event_grouplist == NULL || event_group_name == NULL || event_name == NULL)
|
||||
return FALSE;
|
||||
|
||||
event_group = mc_event_get_event_group_by_name (event_group_name, FALSE, NULL);
|
||||
if (event_group == NULL)
|
||||
return FALSE;
|
||||
|
||||
callbacks = mc_event_get_event_by_name (event_group, event_name, FALSE, NULL);
|
||||
if (callbacks == NULL)
|
||||
return FALSE;
|
||||
|
||||
for (array_index = callbacks->len; array_index > 0; array_index--)
|
||||
{
|
||||
mc_event_callback_t *cb = g_ptr_array_index (callbacks, array_index - 1);
|
||||
if (!(*cb->callback) (event_group_name, event_name, cb->init_data, event_data))
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
@ -4,7 +4,7 @@
|
||||
#include "lib/mcconfig.h"
|
||||
#include "lib/search.h"
|
||||
|
||||
#include "src/filemanager/dir.h"
|
||||
#include "lib/util.h"
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
|
@ -35,8 +35,6 @@
|
||||
#include "lib/util.h" /* exist_file() */
|
||||
#include "lib/filehighlight.h"
|
||||
|
||||
#include "src/main.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
@ -209,14 +207,14 @@ mc_fhl_init_from_standard_files (mc_fhl_t * fhl)
|
||||
return TRUE;
|
||||
|
||||
/* ${sysconfdir}/mc/filehighlight.ini */
|
||||
name = g_build_filename (mc_sysconfig_dir, MC_FHL_INI_FILE, (char *) NULL);
|
||||
name = g_build_filename (mc_global.sysconfig_dir, MC_FHL_INI_FILE, (char *) NULL);
|
||||
ok = mc_fhl_read_ini_file (fhl, name);
|
||||
g_free (name);
|
||||
if (ok)
|
||||
return TRUE;
|
||||
|
||||
/* ${datadir}/mc/filehighlight.ini */
|
||||
name = g_build_filename (mc_share_data_dir, MC_FHL_INI_FILE, (char *) NULL);
|
||||
name = g_build_filename (mc_global.share_data_dir, MC_FHL_INI_FILE, (char *) NULL);
|
||||
ok = mc_fhl_read_ini_file (fhl, name);
|
||||
g_free (name);
|
||||
return ok;
|
||||
|
129
lib/global.c
Normal file
129
lib/global.c
Normal file
@ -0,0 +1,129 @@
|
||||
/* GLIB - Library of useful routines for C programming
|
||||
Copyright (C) 2009
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 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 2 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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/** \file glibcompat.c
|
||||
* \brief Source: compatibility with older versions of glib
|
||||
*
|
||||
* Following code was copied from glib to GNU Midnight Commander to
|
||||
* provide compatibility with older versions of glib.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "global.h"
|
||||
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
# ifdef SUBSHELL_OPTIONAL
|
||||
# define SUBSHELL_USE FALSE
|
||||
# else /* SUBSHELL_OPTIONAL */
|
||||
# define SUBSHELL_USE TRUE
|
||||
# endif /* SUBSHELL_OPTIONAL */
|
||||
#else /* !HAVE_SUBSHELL_SUPPORT */
|
||||
# define SUBSHELL_USE FALSE
|
||||
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
mc_global_t mc_global = {
|
||||
#ifdef WITH_BACKGROUND
|
||||
.we_are_background = 0,
|
||||
#endif /* WITH_BACKGROUND */
|
||||
|
||||
.message_visible = 1,
|
||||
.keybar_visible = 1,
|
||||
.mc_run_mode = MC_RUN_FULL,
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
.source_codepage = -1,
|
||||
.display_codepage = -1,
|
||||
#else
|
||||
.eight_bit_clean = 1,
|
||||
.full_eight_bits = 0,
|
||||
#endif /* !HAVE_CHARSET */
|
||||
|
||||
.utf8_display = 0,
|
||||
.sysconfig_dir = NULL,
|
||||
.share_data_dir = NULL,
|
||||
|
||||
.is_right = FALSE,
|
||||
|
||||
.args =
|
||||
{
|
||||
.disable_colors = FALSE,
|
||||
.skin = NULL,
|
||||
.ugly_line_drawing = FALSE,
|
||||
.slow_terminal = FALSE
|
||||
},
|
||||
|
||||
.widget =
|
||||
{
|
||||
.midnight_shutdown = FALSE,
|
||||
.confirm_history_cleanup = TRUE,
|
||||
.show_all_if_ambiguous = FALSE
|
||||
},
|
||||
|
||||
.tty =
|
||||
{
|
||||
.setup_color_string = NULL,
|
||||
.term_color_string = NULL,
|
||||
.color_terminal_string = NULL,
|
||||
#ifndef LINUX_CONS_SAVER_C
|
||||
.console_flag = '\0',
|
||||
#endif /* !LINUX_CONS_SAVER_C */
|
||||
|
||||
.use_subshell = SUBSHELL_USE,
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
.subshell_pty = 0,
|
||||
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
||||
|
||||
.winch_flag = FALSE,
|
||||
.command_line_colors = NULL,
|
||||
},
|
||||
|
||||
.vfs =
|
||||
{
|
||||
.cd_symlinks = TRUE
|
||||
}
|
||||
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#undef SUBSHELL_USE
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
123
lib/global.h
123
lib/global.h
@ -141,18 +141,137 @@
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#define MC_ERROR mc_main_error_quark ()
|
||||
#define MC_ERROR g_quark_from_static_string (PACKAGE)
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/* run mode and params */
|
||||
typedef enum
|
||||
{
|
||||
MC_RUN_FULL = 0,
|
||||
MC_RUN_EDITOR,
|
||||
MC_RUN_VIEWER,
|
||||
MC_RUN_DIFFVIEWER
|
||||
} mc_run_mode_t;
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#ifdef WITH_BACKGROUND
|
||||
/* If true, this is a background process */
|
||||
int we_are_background;
|
||||
#endif /* WITH_BACKGROUND */
|
||||
|
||||
/*
|
||||
* If utf-8 terminal utf8_display = 1
|
||||
* Display bits set UTF-8
|
||||
*/
|
||||
int utf8_display;
|
||||
|
||||
/* Set if the nice message (hint) bar is visible */
|
||||
int message_visible;
|
||||
|
||||
/* Set if the nice and useful keybar is visible */
|
||||
int keybar_visible;
|
||||
|
||||
mc_run_mode_t mc_run_mode;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
/* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
|
||||
int source_codepage;
|
||||
int display_codepage;
|
||||
#else
|
||||
/* If true, allow characters in the range 160-255 */
|
||||
int eight_bit_clean;
|
||||
/*
|
||||
* If true, also allow characters in the range 128-159.
|
||||
* This is reported to break on many terminals (xterm, qansi-m).
|
||||
*/
|
||||
int full_eight_bits;
|
||||
#endif /* !HAVE_CHARSET */
|
||||
|
||||
/* sysconfig_dir: Area for default settings from maintainers of distributuves
|
||||
default is /etc/mc or may be defined by MC_DATADIR
|
||||
*/
|
||||
char *sysconfig_dir;
|
||||
|
||||
/* share_data_dir: Area for default settings from developers */
|
||||
char *share_data_dir;
|
||||
|
||||
/* Ugly hack in order to distinguish between left and right panel in menubar */
|
||||
/* Set if the command is being run from the "Right" menu */
|
||||
gboolean is_right; /* If the selected menu was the right */
|
||||
|
||||
struct
|
||||
{
|
||||
/* Use the specified skin */
|
||||
char *skin;
|
||||
|
||||
/* Set to force black and white display at program startup */
|
||||
gboolean disable_colors;
|
||||
|
||||
/* If true use +, -, | for line drawing */
|
||||
gboolean ugly_line_drawing;
|
||||
|
||||
/* For slow terminals */
|
||||
gboolean slow_terminal;
|
||||
|
||||
} args;
|
||||
|
||||
struct
|
||||
{
|
||||
/* Used so that widgets know if they are being destroyed or shut down */
|
||||
gboolean midnight_shutdown;
|
||||
|
||||
/* Asks for confirmation before clean up of history */
|
||||
gboolean confirm_history_cleanup;
|
||||
|
||||
/* Set if you want the possible completions dialog for the first time */
|
||||
gboolean show_all_if_ambiguous;
|
||||
|
||||
} widget;
|
||||
|
||||
struct
|
||||
{
|
||||
char *setup_color_string;
|
||||
char *term_color_string;
|
||||
char *color_terminal_string;
|
||||
|
||||
/* Set if the window has changed it's size */
|
||||
gboolean winch_flag;
|
||||
|
||||
#ifndef LINUX_CONS_SAVER_C
|
||||
/* Used only in mc, not in cons.saver */
|
||||
char console_flag;
|
||||
#endif /* !LINUX_CONS_SAVER_C */
|
||||
/* If using a subshell for evaluating commands this is true */
|
||||
gboolean use_subshell;
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
/* File descriptors of the pseudoterminal used by the subshell */
|
||||
int subshell_pty;
|
||||
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
||||
|
||||
/* colors specified on the command line: they override any other setting */
|
||||
char *command_line_colors;
|
||||
|
||||
} tty;
|
||||
|
||||
struct
|
||||
{
|
||||
/* Set when cd symlink following is desirable (bash mode) */
|
||||
gboolean cd_symlinks;
|
||||
} vfs;
|
||||
|
||||
} mc_global_t;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
extern mc_global_t mc_global;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
void refresh_screen (void *);
|
||||
GQuark mc_main_error_quark (void);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
#endif
|
||||
|
@ -53,7 +53,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/util.h" /* tilde_expand() */
|
||||
#include "lib/lock.h"
|
||||
#include "lib/widget.h" /* query_dialog() */
|
||||
|
@ -9,5 +9,6 @@ libmcconfig_la_SOURCES = \
|
||||
|
||||
libmcconfig_la_CFLAGS = -I$(top_srcdir) \
|
||||
$(GLIB_CFLAGS) \
|
||||
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
|
||||
|
||||
-DDATADIR=\""$(pkgdatadir)/"\" \
|
||||
-DLOCALEDIR=\""$(localedir)"\" \
|
||||
-DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <errno.h> /* extern int errno */
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h" /* mc_stat */
|
||||
#include "lib/vfs/vfs.h" /* mc_stat */
|
||||
#include "lib/util.h"
|
||||
#include "lib/mcconfig.h"
|
||||
|
||||
@ -65,9 +65,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path,
|
||||
fd = mc_open (ini_path, O_WRONLY | O_TRUNC | O_SYNC, 0);
|
||||
if (fd == -1)
|
||||
{
|
||||
g_propagate_error (error,
|
||||
g_error_new (mc_main_error_quark (), 0, "%s",
|
||||
unix_error_string (errno)));
|
||||
g_propagate_error (error, g_error_new (MC_ERROR, 0, "%s", unix_error_string (errno)));
|
||||
g_free (data);
|
||||
return FALSE;
|
||||
}
|
||||
@ -81,9 +79,7 @@ mc_config_new_or_override_file (mc_config_t * mc_config, const gchar * ini_path,
|
||||
if (cur_written == -1)
|
||||
{
|
||||
mc_util_restore_from_backup_if_possible (ini_path, "~");
|
||||
g_propagate_error (error,
|
||||
g_error_new (mc_main_error_quark (), 0, "%s",
|
||||
unix_error_string (errno)));
|
||||
g_propagate_error (error, g_error_new (MC_ERROR, 0, "%s", unix_error_string (errno)));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
/*** global variables **************************************************/
|
||||
|
||||
extern int utf8_display;
|
||||
|
||||
/*** file scope macro definitions **************************************/
|
||||
|
||||
/*** file scope type declarations **************************************/
|
||||
@ -103,7 +101,7 @@ mc_config_get_string (mc_config_t * mc_config, const gchar * group,
|
||||
if (ret == NULL)
|
||||
ret = g_strdup (def);
|
||||
|
||||
if (utf8_display)
|
||||
if (mc_global.utf8_display)
|
||||
return ret;
|
||||
|
||||
conv = str_crt_conv_from ("UTF-8");
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/mcconfig.h"
|
||||
#include "lib/fileloc.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -206,6 +206,8 @@ mc_config_copy (const char *old_name, const char *new_name, GError ** error)
|
||||
void
|
||||
mc_config_init_config_paths (GError ** error)
|
||||
{
|
||||
const char *mc_datadir;
|
||||
|
||||
char *u_config_dir = (char *) g_get_user_config_dir ();
|
||||
char *u_data_dir = (char *) g_get_user_data_dir ();
|
||||
char *u_cache_dir = (char *) g_get_user_cache_dir ();
|
||||
@ -230,6 +232,17 @@ mc_config_init_config_paths (GError ** error)
|
||||
g_free (u_data_dir);
|
||||
g_free (u_cache_dir);
|
||||
g_free (u_config_dir);
|
||||
|
||||
/* This is the directory, where MC was installed, on Unix this is DATADIR */
|
||||
/* and can be overriden by the MC_DATADIR environment variable */
|
||||
mc_datadir = g_getenv ("MC_DATADIR");
|
||||
if (mc_datadir != NULL)
|
||||
mc_global.sysconfig_dir = g_strdup (mc_datadir);
|
||||
else
|
||||
mc_global.sysconfig_dir = g_strdup (SYSCONFDIR);
|
||||
|
||||
mc_global.share_data_dir = g_strdup (DATADIR);
|
||||
|
||||
xdg_vars_initialized = TRUE;
|
||||
}
|
||||
|
||||
@ -245,6 +258,9 @@ mc_config_deinit_config_paths (void)
|
||||
g_free (xdg_cache);
|
||||
g_free (xdg_data);
|
||||
|
||||
g_free (mc_global.share_data_dir);
|
||||
g_free (mc_global.sysconfig_dir);
|
||||
|
||||
xdg_vars_initialized = FALSE;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
/*** global variables **************************************************/
|
||||
|
||||
extern int utf8_display;
|
||||
|
||||
/*** file scope macro definitions **************************************/
|
||||
|
||||
/*** file scope type declarations **************************************/
|
||||
@ -42,7 +40,7 @@ mc_config_normalize_before_save (const gchar * value)
|
||||
GIConv conv;
|
||||
GString *buffer;
|
||||
|
||||
if (utf8_display)
|
||||
if (mc_global.utf8_display)
|
||||
return g_strdup (value);
|
||||
|
||||
conv = str_crt_conv_to ("UTF-8");
|
||||
|
@ -35,8 +35,6 @@
|
||||
|
||||
#include "lib/tty/color.h"
|
||||
|
||||
#include "src/setup.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
@ -160,8 +158,7 @@ mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_str
|
||||
if (key_val == NULL)
|
||||
continue;
|
||||
|
||||
if (key_val[1] != NULL
|
||||
&& mc_skin_colors_old_transform (key_val[0], &skin_group, &skin_key))
|
||||
if (key_val[1] != NULL && mc_skin_colors_old_transform (key_val[0], &skin_group, &skin_key))
|
||||
{
|
||||
gchar *skin_val;
|
||||
|
||||
@ -188,10 +185,10 @@ mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_str
|
||||
void
|
||||
mc_skin_colors_old_configure (mc_skin_t * mc_skin)
|
||||
{
|
||||
mc_skin_colors_old_configure_one (mc_skin, setup_color_string);
|
||||
mc_skin_colors_old_configure_one (mc_skin, term_color_string);
|
||||
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, command_line_colors);
|
||||
mc_skin_colors_old_configure_one (mc_skin, mc_global.tty.command_line_colors);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -33,8 +33,6 @@
|
||||
|
||||
#include "lib/tty/color.h"
|
||||
|
||||
#include "src/args.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
int mc_skin_color__cache[MC_SKIN_COLOR_CACHE_COUNT];
|
||||
@ -273,7 +271,7 @@ mc_skin_color_check_bw_mode (mc_skin_t * mc_skin)
|
||||
{
|
||||
gchar **groups, **orig_groups;
|
||||
|
||||
if (tty_use_colors () && !mc_args__disable_colors)
|
||||
if (tty_use_colors () && !mc_global.args.disable_colors)
|
||||
return;
|
||||
|
||||
orig_groups = groups = mc_config_get_groups (mc_skin->config, NULL);
|
||||
|
@ -33,8 +33,6 @@
|
||||
|
||||
#include "lib/tty/color.h" /* tty_use_256colors(); */
|
||||
|
||||
#include "src/args.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
mc_skin_t mc_skin__default;
|
||||
@ -69,8 +67,8 @@ mc_skin_get_default_name (void)
|
||||
char *tmp_str;
|
||||
|
||||
/* from command line */
|
||||
if (mc_args__skin != NULL)
|
||||
return g_strdup (mc_args__skin);
|
||||
if (mc_global.args.skin != NULL)
|
||||
return g_strdup (mc_global.args.skin);
|
||||
|
||||
/* from envirovement variable */
|
||||
tmp_str = getenv ("MC_SKIN");
|
||||
@ -146,7 +144,7 @@ mc_skin_init (GError ** error)
|
||||
(void) mc_skin_ini_file_parse (&mc_skin__default);
|
||||
is_good_init = FALSE;
|
||||
}
|
||||
if ( is_good_init && !tty_use_256colors () && mc_skin__default.have_256_colors )
|
||||
if (is_good_init && !tty_use_256colors () && mc_skin__default.have_256_colors)
|
||||
{
|
||||
if (*error == NULL)
|
||||
*error = g_error_new (MC_ERROR, 0,
|
||||
@ -187,7 +185,7 @@ mc_skin_deinit (void)
|
||||
gchar *
|
||||
mc_skin_get (const gchar * group, const gchar * key, const gchar * default_value)
|
||||
{
|
||||
if (mc_args__ugly_line_drawing)
|
||||
if (mc_global.args.ugly_line_drawing)
|
||||
{
|
||||
return g_strdup (default_value);
|
||||
}
|
||||
|
@ -32,8 +32,6 @@
|
||||
#include "lib/fileloc.h"
|
||||
#include "lib/util.h" /* exist_file() */
|
||||
|
||||
#include "src/main.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
@ -102,11 +100,11 @@ mc_skin_ini_file_load (mc_skin_t * mc_skin)
|
||||
return TRUE;
|
||||
|
||||
/* /etc/mc/skins/ */
|
||||
if (mc_skin_ini_file_load_search_in_dir (mc_skin, mc_sysconfig_dir))
|
||||
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_share_data_dir);
|
||||
return mc_skin_ini_file_load_search_in_dir (mc_skin, mc_global.share_data_dir);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include "internal.h"
|
||||
#include "lib/tty/tty.h"
|
||||
|
||||
#include "src/args.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
@ -98,9 +96,9 @@ mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
|
||||
void
|
||||
mc_skin_lines_parse_ini_file (mc_skin_t * mc_skin)
|
||||
{
|
||||
if (mc_args__slow_terminal)
|
||||
if (mc_global.args.slow_terminal)
|
||||
mc_skin_hardcoded_space_lines (mc_skin);
|
||||
else if (mc_args__ugly_line_drawing)
|
||||
else if (mc_global.args.ugly_line_drawing)
|
||||
mc_skin_hardcoded_ugly_lines (mc_skin);
|
||||
|
||||
/* single lines */
|
||||
|
10
lib/tests/Makefile.am
Normal file
10
lib/tests/Makefile.am
Normal file
@ -0,0 +1,10 @@
|
||||
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) @CHECK_CFLAGS@
|
||||
LIBS=@CHECK_LIBS@ $(top_builddir)/lib/libmc.la
|
||||
|
||||
TESTS = \
|
||||
library_independ
|
||||
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
library_independ_SOURCES = \
|
||||
library_independ.c
|
59
lib/tests/library_independ.c
Normal file
59
lib/tests/library_independ.c
Normal file
@ -0,0 +1,59 @@
|
||||
/* libmc - check if library is independ to $(topsrc)/src directory
|
||||
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
as published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program 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 Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "lib/library_independ"
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
START_TEST (test_library_independ)
|
||||
{
|
||||
}
|
||||
END_TEST
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int number_failed;
|
||||
|
||||
Suite *s = suite_create (TEST_SUITE_NAME);
|
||||
TCase *tc_core = tcase_create ("Core");
|
||||
SRunner *sr;
|
||||
|
||||
/* Add new tests here: *************** */
|
||||
tcase_add_test (tc_core, test_library_independ);
|
||||
/* *********************************** */
|
||||
|
||||
suite_add_tcase (s, tc_core);
|
||||
sr = srunner_create (s);
|
||||
srunner_run_all (sr, CK_NORMAL);
|
||||
number_failed = srunner_ntests_failed (sr);
|
||||
srunner_free (sr);
|
||||
return (number_failed == 0) ? 0 : 1;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
@ -37,8 +37,6 @@
|
||||
#include "color.h" /* variables */
|
||||
#include "color-internal.h"
|
||||
|
||||
#include "src/setup.h" /* color_terminal_string */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
@ -63,11 +61,11 @@ has_colors (gboolean disable, gboolean force)
|
||||
const char *terminal = getenv ("TERM");
|
||||
const size_t len = strlen (terminal);
|
||||
|
||||
char *cts = color_terminal_string;
|
||||
char *cts = mc_global.tty.color_terminal_string;
|
||||
char *s;
|
||||
size_t i;
|
||||
|
||||
/* check color_terminal_string */
|
||||
/* check mc_global.tty.color_terminal_string */
|
||||
while (*cts != '\0')
|
||||
{
|
||||
while (*cts == ' ' || *cts == '\t')
|
||||
|
@ -44,8 +44,6 @@
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
char *command_line_colors = NULL;
|
||||
|
||||
static char *tty_color_defaults__fg = NULL;
|
||||
static char *tty_color_defaults__bg = NULL;
|
||||
static char *tty_color_defaults__attrs = NULL;
|
||||
|
@ -29,9 +29,6 @@
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/* colors specified on the command line: they override any other setting */
|
||||
extern char *command_line_colors;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
void tty_init_colors (gboolean disable, gboolean force);
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h" /* str_casecmp */
|
||||
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
|
||||
#include "tty.h"
|
||||
#include "tty-internal.h" /* mouse_enabled */
|
||||
@ -48,10 +48,7 @@
|
||||
#include "key.h"
|
||||
#include "win.h" /* xterm_flag */
|
||||
|
||||
#include "src/main.h"
|
||||
#include "src/filemanager/layout.h" /* winch_flag, mc_refresh() */
|
||||
#include "src/consaver/cons.saver.h"
|
||||
|
||||
#include "lib/widget.h" /* mc_refresh() */
|
||||
|
||||
#ifdef HAVE_TEXTMODE_X11_SUPPORT
|
||||
#include "x11conn.h"
|
||||
@ -1959,7 +1956,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
|
||||
}
|
||||
}
|
||||
|
||||
if (!block || winch_flag)
|
||||
if (!block || mc_global.tty.winch_flag)
|
||||
{
|
||||
time_addr = &time_out;
|
||||
time_out.tv_sec = 0;
|
||||
@ -1979,7 +1976,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
|
||||
{
|
||||
if (redo_event)
|
||||
return EV_MOUSE;
|
||||
if (!block || winch_flag)
|
||||
if (!block || mc_global.tty.winch_flag)
|
||||
return EV_NONE;
|
||||
vfs_timeout_handler ();
|
||||
}
|
||||
@ -2106,7 +2103,7 @@ learn_key (void)
|
||||
void
|
||||
numeric_keypad_mode (void)
|
||||
{
|
||||
if (console_flag || xterm_flag)
|
||||
if (mc_global.tty.console_flag || xterm_flag)
|
||||
{
|
||||
fputs ("\033>", stdout);
|
||||
fflush (stdout);
|
||||
@ -2118,7 +2115,7 @@ numeric_keypad_mode (void)
|
||||
void
|
||||
application_keypad_mode (void)
|
||||
{
|
||||
if (console_flag || xterm_flag)
|
||||
if (mc_global.tty.console_flag || xterm_flag)
|
||||
{
|
||||
fputs ("\033=", stdout);
|
||||
fflush (stdout);
|
||||
|
@ -39,8 +39,6 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h" /* str_term_form */
|
||||
|
||||
#include "src/main.h"
|
||||
|
||||
#ifndef WANT_TERM_H
|
||||
#define WANT_TERM_H
|
||||
#endif
|
||||
@ -396,7 +394,7 @@ tty_print_anychar (int c)
|
||||
{
|
||||
unsigned char str[6 + 1];
|
||||
|
||||
if (utf8_display || c > 255)
|
||||
if (mc_global.utf8_display || c > 255)
|
||||
{
|
||||
int res = g_unichar_to_utf8 (c, (char *) str);
|
||||
if (res == 0)
|
||||
|
@ -34,12 +34,16 @@
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
|
||||
#include "tty.h"
|
||||
#include "tty-internal.h"
|
||||
|
||||
#include "win.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -204,3 +208,54 @@ mc_tty_normalize_from_utf8 (const char *str)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/** Resize given terminal using TIOCSWINSZ, return ioctl() result */
|
||||
int
|
||||
tty_resize (int fd)
|
||||
{
|
||||
#if defined TIOCSWINSZ
|
||||
struct winsize tty_size;
|
||||
|
||||
tty_size.ws_row = LINES;
|
||||
tty_size.ws_col = COLS;
|
||||
tty_size.ws_xpixel = tty_size.ws_ypixel = 0;
|
||||
|
||||
return ioctl (fd, TIOCSWINSZ, &tty_size);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
tty_low_level_change_screen_size (void)
|
||||
{
|
||||
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
|
||||
#if defined TIOCGWINSZ
|
||||
struct winsize winsz;
|
||||
|
||||
winsz.ws_col = winsz.ws_row = 0;
|
||||
/* Ioctl on the STDIN_FILENO */
|
||||
ioctl (0, TIOCGWINSZ, &winsz);
|
||||
if (winsz.ws_col && winsz.ws_row)
|
||||
{
|
||||
#if defined(NCURSES_VERSION) && defined(HAVE_RESIZETERM)
|
||||
resizeterm (winsz.ws_row, winsz.ws_col);
|
||||
clearok (stdscr, TRUE); /* sigwinch's should use a semaphore! */
|
||||
#else
|
||||
COLS = winsz.ws_col;
|
||||
LINES = winsz.ws_row;
|
||||
#endif
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (!mc_global.tty.use_subshell)
|
||||
return;
|
||||
|
||||
tty_resize (mc_global.tty.subshell_pty);
|
||||
#endif
|
||||
}
|
||||
#endif /* TIOCGWINSZ */
|
||||
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -130,8 +130,11 @@ extern void tty_draw_vline (int y, int x, int ch, int len);
|
||||
extern void tty_draw_box (int y, int x, int rows, int cols, gboolean single);
|
||||
extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
|
||||
|
||||
extern int tty_resize (int fd);
|
||||
extern void tty_refresh (void);
|
||||
extern void tty_setup_sigwinch (void (*handler) (int));
|
||||
extern void tty_low_level_change_screen_size (void);
|
||||
|
||||
|
||||
extern int mc_tty_normalize_lines_char (const char *);
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "lib/util.h" /* is_printable() */
|
||||
#include "tty.h" /* tty_gotoyx, tty_print_char */
|
||||
#include "win.h"
|
||||
#include "src/consaver/cons.saver.h" /* console_flag */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -44,8 +43,6 @@
|
||||
/* It is used by function view_other_cmd() */
|
||||
int xterm_flag = 0;
|
||||
|
||||
extern int keybar_visible;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
@ -122,8 +119,8 @@ show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
|
||||
unsigned char *k;
|
||||
int bytes, i, j, cols = 0;
|
||||
|
||||
y1 += (keybar_visible != 0); /* i don't knwo why we need this - paul */
|
||||
y2 += (keybar_visible != 0);
|
||||
y1 += (mc_global.keybar_visible != 0); /* i don't knwo why we need this - paul */
|
||||
y2 += (mc_global.keybar_visible != 0);
|
||||
while (anything_ready ())
|
||||
tty_lowlevel_getch ();
|
||||
|
||||
@ -174,7 +171,7 @@ look_for_rxvt_extensions (void)
|
||||
}
|
||||
|
||||
if (rxvt_extensions)
|
||||
console_flag = 4;
|
||||
mc_global.tty.console_flag = '\004';
|
||||
|
||||
return rxvt_extensions;
|
||||
}
|
||||
|
34
lib/util.c
34
lib/util.c
@ -44,14 +44,10 @@
|
||||
#include "lib/tty/win.h" /* xterm_flag */
|
||||
#include "lib/mcconfig.h"
|
||||
#include "lib/fileloc.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h"
|
||||
|
||||
#include "src/filemanager/filegui.h"
|
||||
#include "src/filemanager/file.h" /* copy_file_file() */
|
||||
#include "src/main.h" /* eight_bit_clean */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
@ -221,10 +217,10 @@ is_printable (int c)
|
||||
by setting the output codepage */
|
||||
return is_8bit_printable (c);
|
||||
#else
|
||||
if (!eight_bit_clean)
|
||||
if (!mc_global.eight_bit_clean)
|
||||
return is_7bit_printable (c);
|
||||
|
||||
if (full_eight_bits)
|
||||
if (mc_global.full_eight_bits)
|
||||
{
|
||||
return is_8bit_printable (c);
|
||||
}
|
||||
@ -611,30 +607,6 @@ extension (const char *filename)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
check_for_default (const char *default_file, const char *file)
|
||||
{
|
||||
if (!exist_file (file))
|
||||
{
|
||||
FileOpContext *ctx;
|
||||
FileOpTotalContext *tctx;
|
||||
|
||||
if (!exist_file (default_file))
|
||||
return -1;
|
||||
|
||||
ctx = file_op_context_new (OP_COPY);
|
||||
tctx = file_op_total_context_new ();
|
||||
file_op_context_create_ui (ctx, 0, FALSE);
|
||||
copy_file_file (tctx, ctx, default_file, file);
|
||||
file_op_total_context_destroy (tctx);
|
||||
file_op_context_destroy (ctx);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
char *
|
||||
load_mc_home_file (const char *from, const char *filename, char **allocated_filename)
|
||||
{
|
||||
|
25
lib/util.h
25
lib/util.h
@ -47,6 +47,28 @@ enum compression_type
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
/* keys are set only during sorting */
|
||||
typedef struct
|
||||
{
|
||||
/* File attributes */
|
||||
size_t fnamelen;
|
||||
char *fname;
|
||||
struct stat st;
|
||||
/* key used for comparing names */
|
||||
char *sort_key;
|
||||
/* key used for comparing extensions */
|
||||
char *second_sort_key;
|
||||
|
||||
/* Flags */
|
||||
struct
|
||||
{
|
||||
unsigned int marked:1; /* File marked in pane window */
|
||||
unsigned int link_to_dir:1; /* If this is a link, does it point to directory? */
|
||||
unsigned int stale_link:1; /* If this is a symlink and points to Charon's land */
|
||||
unsigned int dir_size_computed:1; /* Size of directory was computed with dirsizes_cmd */
|
||||
} f;
|
||||
} file_entry;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
extern struct sigaction startup_handler;
|
||||
@ -122,9 +144,6 @@ void init_uid_gid_cache (void);
|
||||
char *get_group (int);
|
||||
char *get_owner (int);
|
||||
|
||||
/* Check if the file exists. If not copy the default */
|
||||
int check_for_default (const char *default_file, const char *file);
|
||||
|
||||
/* Returns a copy of *s until a \n is found and is below top */
|
||||
const char *extract_line (const char *s, const char *top);
|
||||
|
||||
|
@ -52,16 +52,17 @@
|
||||
#include <grp.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h" /* VFS_ENCODING_PREFIX */
|
||||
#include "lib/vfs/vfs.h" /* VFS_ENCODING_PREFIX */
|
||||
#include "lib/strutil.h" /* str_move() */
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h" /* message() */
|
||||
|
||||
#include "src/execute.h"
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "charsets.h"
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "utilunix.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
struct sigaction startup_handler;
|
||||
|
25
lib/utilunix.h
Normal file
25
lib/utilunix.h
Normal file
@ -0,0 +1,25 @@
|
||||
/** \file execute.h
|
||||
* \brief Header: execution routines
|
||||
*/
|
||||
|
||||
#ifndef MC__UTILUNIX_H
|
||||
#define MC__UTILUNIX_H
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/* flags for shell_execute */
|
||||
#define EXECUTE_INTERNAL (1 << 0)
|
||||
#define EXECUTE_AS_SHELL (1 << 2)
|
||||
#define EXECUTE_HIDE (1 << 3)
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__UTILUNIX_H */
|
@ -9,7 +9,7 @@ covered by the terms of the GNU GPL.
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
@ -470,8 +470,8 @@ convey the exclusion of warranty; and each file should have at least the
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
License along with this library; if not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
@ -84,7 +84,7 @@ smbfs no yes no no
|
||||
undelfs no yes no yes
|
||||
|
||||
|
||||
"*" means that this property should change during further development.
|
||||
"*" means that this property should change during further development.
|
||||
Mapping from inode to entry prevents implementing hard links. It is
|
||||
permissible for directories, which cannot be hardlinked. Not loading
|
||||
the full tree speeds up access to large archives and conserves memory.
|
@ -1 +1,15 @@
|
||||
SUBDIRS = mc-vfs
|
||||
noinst_LTLIBRARIES = libmcvfs.la
|
||||
|
||||
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
|
||||
|
||||
libmcvfs_la_SOURCES = \
|
||||
vfs.c vfs.h \
|
||||
direntry.c xdirentry.h \
|
||||
utilvfs.c utilvfs.h \
|
||||
gc.c gc.h
|
||||
|
||||
if ENABLE_VFS_NET
|
||||
libmcvfs_la_SOURCES += netutil.c netutil.h
|
||||
endif
|
||||
|
||||
EXTRA_DIST = HACKING README
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <time.h>
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
#include <inttypes.h> /* uintmax_t */
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
@ -45,9 +46,7 @@
|
||||
#include "lib/widget.h" /* message() */
|
||||
#endif
|
||||
|
||||
#include "src/filemanager/layout.h" /* print_vfs_message */
|
||||
|
||||
#include "vfs-impl.h"
|
||||
#include "vfs.h"
|
||||
#include "utilvfs.h"
|
||||
#include "xdirentry.h"
|
||||
#include "gc.h" /* vfs_rmstamp */
|
||||
@ -279,7 +278,7 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
if (ent && (!(MEDATA->dir_uptodate) (me, ent->ino)))
|
||||
{
|
||||
#if 1
|
||||
print_vfs_message (_("Directory cache expired for %s"), path);
|
||||
vfs_print_message (_("Directory cache expired for %s"), path);
|
||||
#endif
|
||||
vfs_s_free_entry (me, ent);
|
||||
ent = NULL;
|
||||
@ -708,11 +707,11 @@ vfs_s_print_stats (const char *fs_name, const char *action,
|
||||
}
|
||||
|
||||
if (need)
|
||||
print_vfs_message (i18n_percent_transf_format, fs_name, action,
|
||||
vfs_print_message (i18n_percent_transf_format, fs_name, action,
|
||||
file_name, (int) ((double) have * 100 / need), (uintmax_t) have,
|
||||
_("bytes transferred"));
|
||||
else
|
||||
print_vfs_message (i18n_transf_format, fs_name, action, file_name, (uintmax_t) have,
|
||||
vfs_print_message (i18n_transf_format, fs_name, action, file_name, (uintmax_t) have,
|
||||
_("bytes transferred"));
|
||||
}
|
||||
|
||||
@ -1203,7 +1202,7 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode)
|
||||
{
|
||||
if (MEDATA->linear_start)
|
||||
{
|
||||
print_vfs_message (_("Starting linear transfer..."));
|
||||
vfs_print_message (_("Starting linear transfer..."));
|
||||
fh->linear = LS_LINEAR_PREOPEN;
|
||||
}
|
||||
}
|
@ -33,21 +33,14 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* For atol() */
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h> /* is_digit() */
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/event.h"
|
||||
|
||||
#include "src/filemanager/midnight.h" /* current_panel */
|
||||
#include "src/filemanager/layout.h" /* get_current_type(), get_other_type() */
|
||||
|
||||
#include "vfs-impl.h"
|
||||
#include "vfs.h"
|
||||
#include "utilvfs.h"
|
||||
|
||||
#include "gc.h"
|
||||
@ -174,58 +167,35 @@ vfs_stamp_path (const char *path)
|
||||
*/
|
||||
|
||||
void
|
||||
vfs_stamp_create (struct vfs_class *oldvfs, vfsid oldvfsid)
|
||||
vfs_stamp_create (struct vfs_class *vclass, vfsid id)
|
||||
{
|
||||
struct vfs_class *nvfs, *n2vfs, *n3vfs;
|
||||
vfsid nvfsid, n2vfsid, n3vfsid;
|
||||
struct vfs_class *nvfs;
|
||||
vfsid nvfsid;
|
||||
|
||||
ev_vfs_stamp_create_t event_data = { vclass, id, FALSE };
|
||||
|
||||
/* There are three directories we have to take care of: current_dir,
|
||||
current_panel->cwd and other_panel->cwd. Athough most of the time either
|
||||
current_dir and current_panel->cwd or current_dir and other_panel->cwd are the
|
||||
same, it's possible that all three are different -- Norbert */
|
||||
|
||||
if (current_panel == NULL)
|
||||
if (!mc_event_present (MCEVENT_GROUP_CORE, "vfs_timestamp"))
|
||||
return;
|
||||
|
||||
nvfs = vfs_get_class (vfs_get_current_dir ());
|
||||
nvfsid = vfs_getid (nvfs, vfs_get_current_dir ());
|
||||
vfs_rmstamp (nvfs, nvfsid);
|
||||
|
||||
if ((nvfs == oldvfs && nvfsid == oldvfsid) || oldvfsid == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_current_type () == view_listing)
|
||||
{
|
||||
n2vfs = vfs_get_class (current_panel->cwd);
|
||||
n2vfsid = vfs_getid (n2vfs, current_panel->cwd);
|
||||
if (n2vfs == oldvfs && n2vfsid == oldvfsid)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
n2vfs = NULL;
|
||||
n2vfsid = NULL;
|
||||
}
|
||||
|
||||
if (get_other_type () == view_listing)
|
||||
{
|
||||
n3vfs = vfs_get_class (other_panel->cwd);
|
||||
n3vfsid = vfs_getid (n3vfs, other_panel->cwd);
|
||||
if (n3vfs == oldvfs && n3vfsid == oldvfsid)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
n3vfs = NULL;
|
||||
n3vfsid = NULL;
|
||||
}
|
||||
|
||||
if (!oldvfs || !oldvfs->nothingisopen || !(*oldvfs->nothingisopen) (oldvfsid))
|
||||
if (id == NULL || (nvfs == vclass && nvfsid == id))
|
||||
return;
|
||||
|
||||
vfs_addstamp (oldvfs, oldvfsid);
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "vfs_timestamp", (gpointer) &event_data);
|
||||
|
||||
if (event_data.ret)
|
||||
return;
|
||||
|
||||
if (vclass != NULL && vclass->nothingisopen != NULL && vclass->nothingisopen (id) != 0)
|
||||
vfs_addstamp (vclass, id);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
@ -6,7 +6,7 @@
|
||||
#ifndef MC__VFS_GC_H
|
||||
#define MC__VFS_GC_H
|
||||
|
||||
#include "vfs-impl.h"
|
||||
#include "vfs.h"
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
11
lib/vfs/mc-vfs/.gitignore
vendored
11
lib/vfs/mc-vfs/.gitignore
vendored
@ -1,11 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
mcserv
|
||||
mcservx
|
||||
rar
|
||||
cpio
|
||||
zoo
|
||||
zip
|
||||
lha
|
||||
.deps
|
||||
*.sor
|
@ -1,152 +0,0 @@
|
||||
if ENABLE_VFS_SMB
|
||||
SAMBA_CFLAGS = -DCONFIGDIR=\""@smbconfigdir@"\"
|
||||
SAMBA_SUBDIRS = samba
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS = extfs fish
|
||||
|
||||
SUBDIRS = $(SAMBA_SUBDIRS)
|
||||
if ENABLE_VFS_EXTFS
|
||||
SUBDIRS += extfs
|
||||
endif
|
||||
if ENABLE_VFS_FISH
|
||||
SUBDIRS += fish
|
||||
endif
|
||||
|
||||
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(SAMBA_CFLAGS)
|
||||
|
||||
AM_CPPFLAGS = -DLIBEXECDIR=\""$(libexecdir)/@PACKAGE@/"\"
|
||||
|
||||
BASICFILES = \
|
||||
vfs.c vfs.h vfs-impl.h \
|
||||
direntry.c xdirentry.h \
|
||||
utilvfs.c utilvfs.h \
|
||||
gc.c gc.h \
|
||||
local.c local.h
|
||||
|
||||
CPIOFILES = cpio.c
|
||||
TARFILES = tar.c
|
||||
SFSFILES = sfs.c
|
||||
EXTFSFILES = extfs.c
|
||||
UNDELFILES = undelfs.c
|
||||
|
||||
NETFILES = netutil.c netutil.h
|
||||
|
||||
FTPFILES = ftpfs.c ftpfs.h
|
||||
FISHFILES = fish.c fish.h fishdef.h
|
||||
SMBFILES = smbfs.c smbfs.h
|
||||
|
||||
libvfs_mc_la_SOURCES = $(BASICFILES)
|
||||
if ENABLE_VFS_CPIO
|
||||
libvfs_mc_la_SOURCES += $(CPIOFILES)
|
||||
endif
|
||||
if ENABLE_VFS_TAR
|
||||
libvfs_mc_la_SOURCES += $(TARFILES)
|
||||
endif
|
||||
if ENABLE_VFS_SFS
|
||||
libvfs_mc_la_SOURCES += $(SFSFILES)
|
||||
endif
|
||||
if ENABLE_VFS_EXTFS
|
||||
libvfs_mc_la_SOURCES += $(EXTFSFILES)
|
||||
endif
|
||||
if ENABLE_VFS_UNDELFS
|
||||
libvfs_mc_la_SOURCES += $(UNDELFILES)
|
||||
endif
|
||||
if ENABLE_VFS_NET
|
||||
libvfs_mc_la_SOURCES += $(NETFILES)
|
||||
endif
|
||||
if ENABLE_VFS_FTP
|
||||
libvfs_mc_la_SOURCES += $(FTPFILES)
|
||||
endif
|
||||
if ENABLE_VFS_FISH
|
||||
libvfs_mc_la_SOURCES += $(FISHFILES)
|
||||
endif
|
||||
if ENABLE_VFS_SMB
|
||||
libvfs_mc_la_SOURCES += $(SMBFILES)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = HACKING README \
|
||||
$(BASICFILES) \
|
||||
$(CPIOFILES) \
|
||||
$(TARFILES) \
|
||||
$(SFSFILES) \
|
||||
$(EXTFSFILES) \
|
||||
$(UNDELFILES) \
|
||||
$(NETFILES) \
|
||||
$(FTPFILES) \
|
||||
$(FISHFILES) \
|
||||
$(SMBFILES)
|
||||
|
||||
dist-hook:
|
||||
$(mkinstalldirs) $(distdir)/samba
|
||||
$(mkinstalldirs) $(distdir)/samba/include
|
||||
$(mkinstalldirs) $(distdir)/samba/lib
|
||||
$(mkinstalldirs) $(distdir)/samba/libsmb
|
||||
$(mkinstalldirs) $(distdir)/samba/param
|
||||
for I in $(SAMBA_DIST); do \
|
||||
cp -p $(srcdir)/samba/$$I $(distdir)/samba/$$I || exit 1; \
|
||||
done
|
||||
|
||||
mostlyclean-local:
|
||||
if test -f samba/Makefile; then \
|
||||
(cd samba && $(MAKE) mostlyclean) \
|
||||
else :; fi
|
||||
|
||||
clean-local:
|
||||
if test -f samba/Makefile; then \
|
||||
(cd samba && $(MAKE) clean) \
|
||||
else :; fi
|
||||
|
||||
distclean-local:
|
||||
if test -f samba/Makefile; then \
|
||||
(cd samba && $(MAKE) distclean) \
|
||||
else :; fi
|
||||
|
||||
noinst_LTLIBRARIES = libvfs-mc.la
|
||||
|
||||
SAMBA_DIST = \
|
||||
Makefile.in \
|
||||
aclocal.m4 \
|
||||
configure.ac \
|
||||
configure \
|
||||
internals.doc \
|
||||
parsing.doc \
|
||||
include/byteorder.h \
|
||||
include/charset.h \
|
||||
include/client.h \
|
||||
include/config.h.in \
|
||||
include/includes.h \
|
||||
include/kanji.h \
|
||||
include/local.h \
|
||||
include/nameserv.h \
|
||||
include/nterr.h \
|
||||
include/proto.h \
|
||||
include/smb.h \
|
||||
include/stamp-h.in \
|
||||
include/trans2.h \
|
||||
include/version.h \
|
||||
lib/charcnv.c \
|
||||
lib/charset.c \
|
||||
lib/debug.c \
|
||||
lib/interface.c \
|
||||
lib/kanji.c \
|
||||
lib/md4.c \
|
||||
lib/netmask.c \
|
||||
lib/slprintf.c \
|
||||
lib/system.c \
|
||||
lib/time.c \
|
||||
lib/username.c \
|
||||
lib/util.c \
|
||||
lib/util_file.c \
|
||||
lib/util_sock.c \
|
||||
lib/util_str.c \
|
||||
libsmb/clientgen.c \
|
||||
libsmb/namequery.c \
|
||||
libsmb/nmblib.c \
|
||||
libsmb/nterr.c \
|
||||
libsmb/pwd_cache.c \
|
||||
libsmb/smbdes.c \
|
||||
libsmb/smbencrypt.c \
|
||||
libsmb/smberr.c \
|
||||
param/loadparm.c \
|
||||
param/params.c
|
@ -1,178 +0,0 @@
|
||||
|
||||
FIles transferred over SHell protocol (V 0.0.2)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This protocol was designed for transferring files over a remote shell
|
||||
connection (rsh and compatibles). It can be as well used for transfers over
|
||||
rsh, and there may be other uses.
|
||||
|
||||
Client sends requests of following form:
|
||||
|
||||
#FISH_COMMAND
|
||||
equivalent shell commands,
|
||||
which may be multiline
|
||||
|
||||
Only fish commands are defined here, shell equivalents are for your
|
||||
information only and will probably vary from implementation to
|
||||
implementation. Fish commands always have priority: server is
|
||||
expected to execute fish command if it understands it. If it does not,
|
||||
however, it can try the luck and execute shell command.
|
||||
|
||||
Server's reply is multiline, but always ends with
|
||||
|
||||
### 000<optional text>
|
||||
|
||||
line. ### is prefix to mark this line, 000 is return code. Return
|
||||
codes are superset to those used in ftp.
|
||||
|
||||
There are few new exit codes defined:
|
||||
|
||||
000 don't know; if there were no previous lines, this marks COMPLETE
|
||||
success, if they were, it marks failure.
|
||||
|
||||
001 don't know; if there were no previous lines, this marks
|
||||
PRELIMinary success, if they were, it marks failure
|
||||
|
||||
Connecting
|
||||
~~~~~~~~~~
|
||||
Client uses "echo FISH:;/bin/sh" as command executed on remote
|
||||
machine. This should make it possible for server to distinguish FISH
|
||||
connections from normal rsh/ssh.
|
||||
|
||||
Commands
|
||||
~~~~~~~~
|
||||
#FISH
|
||||
echo; start_fish_server; echo '### 200'
|
||||
|
||||
This command is sent at the beginning. It marks that client wishes to
|
||||
talk via FISH protocol. #VER command must follow. If server
|
||||
understands FISH protocol, it has option to put FISH server somewhere
|
||||
on system path and name it start_fish_server.
|
||||
|
||||
#VER 0.0.2 <feature1> <feature2> <...>
|
||||
echo '### 000'
|
||||
|
||||
This command is the second one. It sends client version and extensions
|
||||
to the server. Server should reply with protocol version to be used,
|
||||
and list of extensions accepted.
|
||||
|
||||
VER 0.0.0 <feature2>
|
||||
### 200
|
||||
|
||||
#PWD
|
||||
pwd; echo '### 200'
|
||||
|
||||
Server should reply with current directory (in form /abc/def/ghi)
|
||||
followed by line indicating success.
|
||||
|
||||
#LIST /directory
|
||||
ls -lLa $1 | grep '^[^cbt]' | ( while read p x u g s m d y n; do echo "P$p $u.$g
|
||||
S$s
|
||||
d$m $d $y
|
||||
:$n
|
||||
"; done )
|
||||
ls -lLa $1 | grep '^[cb]' | ( while read p x u g a i m d y n; do echo "P$p $u.$g
|
||||
E$a$i
|
||||
dD$m $d $y
|
||||
:$n
|
||||
"; done )
|
||||
echo '### 200'
|
||||
|
||||
This allows client to list directory or get status information about
|
||||
single file. Output is in following form (any line except :<filename>
|
||||
may be omitted):
|
||||
|
||||
P<unix permissions> <owner>.<group>
|
||||
S<size>
|
||||
d<3-letters month name> <day> <year or HH:MM>
|
||||
D<year> <month> <day> <hour> <minute> <second>[.1234]
|
||||
E<major-of-device>,<minor>
|
||||
:<filename>
|
||||
L<filename symlink points to>
|
||||
<blank line to separate items>
|
||||
|
||||
Unix permissions are of form X--------- where X is type of
|
||||
file. Currently, '-' means regular file, 'd' means directory, 'c', 'b'
|
||||
means character and block device, 'l' means symbolic link, 'p' means
|
||||
FIFO and 's' means socket.
|
||||
|
||||
'd' has three fields: month (one of strings Jan Feb Mar Apr May Jun
|
||||
Jul Aug Sep Oct Nov Dec), day of month, and third is either single
|
||||
number indicating year, or HH:MM field (assume current year in such
|
||||
case). As you've probably noticed, this is pretty broken; it is for
|
||||
compatibility with ls listing.
|
||||
|
||||
#RETR /some/name
|
||||
ls -l /some/name | ( read a b c d x e; echo $x ); echo '### 100'; cat /some/name; echo '### 200'
|
||||
|
||||
Server sends line with filesize on it, followed by line with ### 100
|
||||
indicating partial success, then it sends binary data (exactly
|
||||
filesize bytes) and follows them with (with no preceding newline) ###
|
||||
200.
|
||||
|
||||
Note that there's no way to abort running RETR command - except
|
||||
closing the connection.
|
||||
|
||||
#STOR <size> /file/name
|
||||
> /file/name; echo '### 001'; ( dd bs=4096 count=<size/4096>; dd bs=<size%4096> count=1 ) 2>/dev/null | ( cat > %s; cat > /dev/null ); echo '### 200'
|
||||
|
||||
This command is for storing /file/name, which is exactly size bytes
|
||||
big. You probably think I went crazy. Well, I did not: that strange
|
||||
cat > /dev/null has purpose to discard any extra data which was not
|
||||
written to disk (due to for example out of space condition).
|
||||
|
||||
[Why? Imagine uploading file with "rm -rf /" line in it.]
|
||||
|
||||
#CWD /somewhere
|
||||
cd /somewhere; echo '### 000'
|
||||
|
||||
It is specified here, but I'm not sure how wise idea is to use this
|
||||
one: it breaks stateless-ness of the protocol.
|
||||
|
||||
Following commands should be rather self-explanatory:
|
||||
|
||||
#CHMOD 1234 file
|
||||
chmod 1234 file; echo '### 000'
|
||||
|
||||
#DELE /some/path
|
||||
rm -f /some/path; echo '### 000'
|
||||
|
||||
#MKD /some/path
|
||||
mkdir /some/path; echo '### 000'
|
||||
|
||||
#RMD /some/path
|
||||
rmdir /some/path; echo '### 000'
|
||||
|
||||
#RENAME /path/a /path/b
|
||||
mv /path/a /path/b; echo '### 000'
|
||||
|
||||
#LINK /path/a /path/b
|
||||
ln /path/a /path/b; echo '### 000'
|
||||
|
||||
#SYMLINK /path/a /path/b
|
||||
ln -s /path/a /path/b; echo '### 000'
|
||||
|
||||
#CHOWN user /file/name
|
||||
chown user /file/name; echo '### 000'
|
||||
|
||||
#CHGRP group /file/name
|
||||
chgrp group /file/name; echo '### 000'
|
||||
|
||||
#READ <offset> <size> /path/and/filename
|
||||
cat /path/and/filename | ( dd bs=4096 count=<offset/4096> > /dev/null;
|
||||
dd bs=<offset%4096> count=1 > /dev/null;
|
||||
dd bs=4096 count=<offset/4096>;
|
||||
dd bs=<offset%4096> count=1; )
|
||||
|
||||
Returns ### 200 on successful exit, ### 291 on successful exit when
|
||||
reading ended at eof, ### 292 on successfull exit when reading did not
|
||||
end at eof.
|
||||
|
||||
#WRITE <offset> <size> /path/and/filename
|
||||
|
||||
Hmm, shall we define these ones if we know our client is not going to
|
||||
use them?
|
||||
|
||||
|
||||
That's all, folks!
|
||||
pavel@ucw.cz
|
@ -1,147 +0,0 @@
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief Header: VFS implemntation (?)
|
||||
*/
|
||||
|
||||
#ifndef MC__VFS_IMPL_H
|
||||
#define MC__VFS_IMPL_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <stddef.h>
|
||||
#include <utime.h>
|
||||
|
||||
#include "vfs.h"
|
||||
#include "lib/fs.h" /* MC_MAXPATHLEN */
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
typedef void *vfsid;
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
struct vfs_stamping;
|
||||
|
||||
struct vfs_class
|
||||
{
|
||||
struct vfs_class *next;
|
||||
const char *name; /* "FIles over SHell" */
|
||||
vfs_class_flags_t flags;
|
||||
const char *prefix; /* "fish:" */
|
||||
void *data; /* this is for filesystem's own use */
|
||||
int verrno; /* can't use errno because glibc2 might define errno as function */
|
||||
|
||||
int (*init) (struct vfs_class * me);
|
||||
void (*done) (struct vfs_class * me);
|
||||
|
||||
/**
|
||||
* The fill_names method shall call the callback function for every
|
||||
* filesystem name that this vfs module supports.
|
||||
*/
|
||||
void (*fill_names) (struct vfs_class * me, fill_names_f);
|
||||
|
||||
/**
|
||||
* The which() method shall return the index of the vfs subsystem
|
||||
* or -1 if this vfs cannot handle the given pathname.
|
||||
*/
|
||||
int (*which) (struct vfs_class * me, const char *path);
|
||||
|
||||
void *(*open) (struct vfs_class * me, const char *fname, int flags, mode_t mode);
|
||||
int (*close) (void *vfs_info);
|
||||
ssize_t (*read) (void *vfs_info, char *buffer, size_t count);
|
||||
ssize_t (*write) (void *vfs_info, const char *buf, size_t count);
|
||||
|
||||
void *(*opendir) (struct vfs_class * me, const char *dirname);
|
||||
void *(*readdir) (void *vfs_info);
|
||||
int (*closedir) (void *vfs_info);
|
||||
|
||||
int (*stat) (struct vfs_class * me, const char *path, struct stat * buf);
|
||||
int (*lstat) (struct vfs_class * me, const char *path, struct stat * buf);
|
||||
int (*fstat) (void *vfs_info, struct stat * buf);
|
||||
|
||||
int (*chmod) (struct vfs_class * me, const char *path, int mode);
|
||||
int (*chown) (struct vfs_class * me, const char *path, uid_t owner, gid_t group);
|
||||
int (*utime) (struct vfs_class * me, const char *path, struct utimbuf * times);
|
||||
|
||||
int (*readlink) (struct vfs_class * me, const char *path, char *buf, size_t size);
|
||||
int (*symlink) (struct vfs_class * me, const char *n1, const char *n2);
|
||||
int (*link) (struct vfs_class * me, const char *p1, const char *p2);
|
||||
int (*unlink) (struct vfs_class * me, const char *path);
|
||||
int (*rename) (struct vfs_class * me, const char *p1, const char *p2);
|
||||
int (*chdir) (struct vfs_class * me, const char *path);
|
||||
int (*ferrno) (struct vfs_class * me);
|
||||
off_t (*lseek) (void *vfs_info, off_t offset, int whence);
|
||||
int (*mknod) (struct vfs_class * me, const char *path, mode_t mode, dev_t dev);
|
||||
|
||||
vfsid (*getid) (struct vfs_class * me, const char *path);
|
||||
|
||||
int (*nothingisopen) (vfsid id);
|
||||
void (*free) (vfsid id);
|
||||
|
||||
char *(*getlocalcopy) (struct vfs_class * me, const char *filename);
|
||||
int (*ungetlocalcopy) (struct vfs_class * me, const char *filename,
|
||||
const char *local, int has_changed);
|
||||
|
||||
int (*mkdir) (struct vfs_class * me, const char *path, mode_t mode);
|
||||
int (*rmdir) (struct vfs_class * me, const char *path);
|
||||
|
||||
int (*ctl) (void *vfs_info, int ctlop, void *arg);
|
||||
int (*setctl) (struct vfs_class * me, const char *path, int ctlop, void *arg);
|
||||
};
|
||||
|
||||
/*
|
||||
* This union is used to ensure that there is enough space for the
|
||||
* filename (d_name) when the dirent structure is created.
|
||||
*/
|
||||
union vfs_dirent
|
||||
{
|
||||
struct dirent dent;
|
||||
char _extra_buffer[offsetof (struct dirent, d_name) + MC_MAXPATHLEN + 1];
|
||||
};
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
|
||||
/* Register a file system class */
|
||||
int vfs_register_class (struct vfs_class *vfs);
|
||||
|
||||
struct vfs_class *vfs_split (char *path, char **inpath, char **op);
|
||||
char *vfs_path (const char *path);
|
||||
|
||||
/* vfs/direntry.c: */
|
||||
void *vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode);
|
||||
|
||||
vfsid vfs_getid (struct vfs_class *vclass, const char *dir);
|
||||
|
||||
#ifdef ENABLE_VFS_CPIO
|
||||
void init_cpiofs (void);
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_TAR
|
||||
void init_tarfs (void);
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_SFS
|
||||
void init_sfs (void);
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_EXTFS
|
||||
void init_extfs (void);
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_UNDELFS
|
||||
void init_undelfs (void);
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_FTP
|
||||
void init_ftpfs (void);
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_FISH
|
||||
void init_fish (void);
|
||||
#endif
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
#endif /* MC_VFS_IMPL_H */
|
@ -40,9 +40,7 @@
|
||||
#include "lib/util.h" /* mc_mkstemps() */
|
||||
#include "lib/widget.h" /* message() */
|
||||
|
||||
#include "src/history.h"
|
||||
|
||||
#include "vfs-impl.h"
|
||||
#include "vfs.h"
|
||||
#include "utilvfs.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
@ -62,6 +60,8 @@
|
||||
/* Parsing code is used by ftpfs, fish and extfs */
|
||||
#define MAXCOLS 30
|
||||
|
||||
#define MC_HISTORY_VFS_PASSWORD "mc.vfs.password"
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
@ -54,28 +54,16 @@
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h" /* message() */
|
||||
#include "lib/event.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
#include "src/setup.h" /* cd_symlinks */
|
||||
|
||||
#include "vfs-impl.h"
|
||||
#include "vfs.h"
|
||||
#include "utilvfs.h"
|
||||
#include "gc.h"
|
||||
|
||||
#ifdef ENABLE_VFS_NET
|
||||
#include "netutil.h"
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_FTP
|
||||
#include "ftpfs.h"
|
||||
#endif
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
#include "smbfs.h"
|
||||
#endif
|
||||
|
||||
#include "local.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
@ -112,10 +100,9 @@ static char *current_dir;
|
||||
static GPtrArray *vfs_openfiles;
|
||||
static long vfs_free_handle_list = -1;
|
||||
|
||||
static struct vfs_class *localfs_class;
|
||||
static GString *vfs_str_buffer;
|
||||
|
||||
static struct vfs_class *vfs_list;
|
||||
static GPtrArray *vfs_list = NULL;
|
||||
|
||||
static struct dirent *mc_readdir_result = NULL;
|
||||
|
||||
@ -240,20 +227,23 @@ vfs_free_handle (int handle)
|
||||
static struct vfs_class *
|
||||
vfs_prefix_to_class (char *prefix)
|
||||
{
|
||||
struct vfs_class *vfs;
|
||||
guint i;
|
||||
|
||||
/* Avoid last class (localfs) that would accept any prefix */
|
||||
for (vfs = vfs_list; vfs->next != NULL; vfs = vfs->next)
|
||||
/* Avoid first class (localfs) that would accept any prefix */
|
||||
for (i = 1; i < vfs_list->len; i++)
|
||||
{
|
||||
struct vfs_class *vfs = (struct vfs_class *) g_ptr_array_index (vfs_list, i);
|
||||
if (vfs->which != NULL)
|
||||
{
|
||||
if ((*vfs->which) (vfs, prefix) == -1)
|
||||
if (vfs->which (vfs, prefix) == -1)
|
||||
continue;
|
||||
return vfs;
|
||||
}
|
||||
|
||||
if (vfs->prefix != NULL && strncmp (prefix, vfs->prefix, strlen (vfs->prefix)) == 0)
|
||||
return vfs;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -423,7 +413,7 @@ _vfs_get_cwd (void)
|
||||
{
|
||||
struct stat my_stat, my_stat2;
|
||||
/* Check if it is O.K. to use the current_dir */
|
||||
if (cd_symlinks
|
||||
if (mc_global.vfs.cd_symlinks
|
||||
&& mc_stat (sys_cwd, &my_stat) == 0
|
||||
&& mc_stat (current_dir, &my_stat2) == 0
|
||||
&& my_stat.st_ino == my_stat2.st_ino && my_stat.st_dev == my_stat2.st_dev)
|
||||
@ -444,20 +434,6 @@ _vfs_get_cwd (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
vfs_setup_wd (void)
|
||||
{
|
||||
current_dir = g_strdup (PATH_SEP_STR);
|
||||
_vfs_get_cwd ();
|
||||
|
||||
if (strlen (current_dir) > MC_MAXPATHLEN - 2)
|
||||
vfs_die ("Current dir too long.\n");
|
||||
|
||||
current_vfs = vfs_get_class (current_dir);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static char *
|
||||
mc_def_getlocalcopy (const char *filename)
|
||||
{
|
||||
@ -562,17 +538,16 @@ mc_def_ungetlocalcopy (struct vfs_class *vfs, const char *filename,
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
vfs_register_class (struct vfs_class *vfs)
|
||||
gboolean
|
||||
vfs_register_class (struct vfs_class * vfs)
|
||||
{
|
||||
if (vfs->init != NULL) /* vfs has own initialization function */
|
||||
if (!(*vfs->init) (vfs)) /* but it failed */
|
||||
return 0;
|
||||
if (!vfs->init (vfs)) /* but it failed */
|
||||
return FALSE;
|
||||
|
||||
vfs->next = vfs_list;
|
||||
vfs_list = vfs;
|
||||
g_ptr_array_add (vfs_list, vfs);
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -584,7 +559,7 @@ vfs_register_class (struct vfs_class *vfs)
|
||||
char *
|
||||
vfs_strip_suffix_from_filename (const char *filename)
|
||||
{
|
||||
struct vfs_class *vfs;
|
||||
guint i;
|
||||
char *semi;
|
||||
char *p;
|
||||
|
||||
@ -596,20 +571,23 @@ vfs_strip_suffix_from_filename (const char *filename)
|
||||
if (semi == NULL)
|
||||
return p;
|
||||
|
||||
/* Avoid last class (localfs) that would accept any prefix */
|
||||
for (vfs = vfs_list; vfs->next != NULL; vfs = vfs->next)
|
||||
/* Avoid first class (localfs) that would accept any prefix */
|
||||
for (i = 1; i < vfs_list->len; i++)
|
||||
{
|
||||
struct vfs_class *vfs = (struct vfs_class *) g_ptr_array_index (vfs_list, i);
|
||||
|
||||
if (vfs->which != NULL)
|
||||
{
|
||||
if ((*vfs->which) (vfs, semi + 1) == -1)
|
||||
if (vfs->which (vfs, semi + 1) == -1)
|
||||
continue;
|
||||
*semi = '\0'; /* Found valid suffix */
|
||||
return p;
|
||||
break;
|
||||
}
|
||||
|
||||
if (vfs->prefix != NULL && strncmp (semi + 1, vfs->prefix, strlen (vfs->prefix)) == 0)
|
||||
{
|
||||
*semi = '\0'; /* Found valid suffix */
|
||||
return p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
@ -678,14 +656,15 @@ vfs_split (char *path, char **inpath, char **op)
|
||||
struct vfs_class *
|
||||
vfs_get_class (const char *pathname)
|
||||
{
|
||||
char *path;
|
||||
struct vfs_class *vfs;
|
||||
char *path = g_strdup (pathname);
|
||||
|
||||
path = g_strdup (pathname);
|
||||
vfs = _vfs_get_class (path);
|
||||
g_free (path);
|
||||
|
||||
if (!vfs)
|
||||
vfs = localfs_class;
|
||||
if (vfs == NULL)
|
||||
vfs = g_ptr_array_index (vfs_list, 0); /* localfs */
|
||||
|
||||
return vfs;
|
||||
}
|
||||
@ -1440,42 +1419,28 @@ mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed)
|
||||
void
|
||||
vfs_init (void)
|
||||
{
|
||||
/* create the VFS handle arrays */
|
||||
vfs_list = g_ptr_array_new ();
|
||||
|
||||
/* create the VFS handle array */
|
||||
vfs_openfiles = g_ptr_array_new ();
|
||||
|
||||
vfs_str_buffer = g_string_new ("");
|
||||
/* localfs needs to be the first one */
|
||||
init_localfs ();
|
||||
/* fallback value for vfs_get_class() */
|
||||
localfs_class = vfs_list;
|
||||
|
||||
#ifdef ENABLE_VFS_CPIO
|
||||
init_cpiofs ();
|
||||
#endif /* ENABLE_VFS_CPIO */
|
||||
#ifdef ENABLE_VFS_TAR
|
||||
init_tarfs ();
|
||||
#endif /* ENABLE_VFS_TAR */
|
||||
#ifdef ENABLE_VFS_SFS
|
||||
init_sfs ();
|
||||
#endif /* ENABLE_VFS_SFS */
|
||||
#ifdef ENABLE_VFS_EXTFS
|
||||
init_extfs ();
|
||||
#endif /* ENABLE_VFS_EXTFS */
|
||||
#ifdef ENABLE_VFS_UNDELFS
|
||||
init_undelfs ();
|
||||
#endif /* ENABLE_VFS_UNDELFS */
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VFS_FTP
|
||||
init_ftpfs ();
|
||||
#endif /* ENABLE_VFS_FTP */
|
||||
#ifdef ENABLE_VFS_FISH
|
||||
init_fish ();
|
||||
#endif /* ENABLE_VFS_FISH */
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
init_smbfs ();
|
||||
#endif /* ENABLE_VFS_SMB */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
vfs_setup_wd ();
|
||||
void
|
||||
vfs_setup_work_dir (void)
|
||||
{
|
||||
current_dir = g_strdup (PATH_SEP_STR);
|
||||
_vfs_get_cwd ();
|
||||
|
||||
if (strlen (current_dir) > MC_MAXPATHLEN - 2)
|
||||
vfs_die ("Current dir too long.\n");
|
||||
|
||||
current_vfs = vfs_get_class (current_dir);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1483,17 +1448,22 @@ vfs_init (void)
|
||||
void
|
||||
vfs_shut (void)
|
||||
{
|
||||
struct vfs_class *vfs;
|
||||
guint i;
|
||||
|
||||
vfs_gc_done ();
|
||||
|
||||
g_free (current_dir);
|
||||
|
||||
for (vfs = vfs_list; vfs; vfs = vfs->next)
|
||||
if (vfs->done)
|
||||
(*vfs->done) (vfs);
|
||||
for (i = 0; i < vfs_list->len; i++)
|
||||
{
|
||||
struct vfs_class *vfs = (struct vfs_class *) g_ptr_array_index (vfs_list, i);
|
||||
|
||||
if (vfs->done != NULL)
|
||||
vfs->done (vfs);
|
||||
}
|
||||
|
||||
g_ptr_array_free (vfs_openfiles, TRUE);
|
||||
g_ptr_array_free (vfs_list, TRUE);
|
||||
g_string_free (vfs_str_buffer, TRUE);
|
||||
g_free (mc_readdir_result);
|
||||
}
|
||||
@ -1507,11 +1477,15 @@ vfs_shut (void)
|
||||
void
|
||||
vfs_fill_names (fill_names_f func)
|
||||
{
|
||||
struct vfs_class *vfs;
|
||||
guint i;
|
||||
|
||||
for (vfs = vfs_list; vfs; vfs = vfs->next)
|
||||
if (vfs->fill_names)
|
||||
(*vfs->fill_names) (vfs, func);
|
||||
for (i = 0; i < vfs_list->len; i++)
|
||||
{
|
||||
struct vfs_class *vfs = (struct vfs_class *) g_ptr_array_index (vfs_list, i);
|
||||
|
||||
if (vfs->fill_names != NULL)
|
||||
vfs->fill_names (vfs, func);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1542,3 +1516,17 @@ vfs_file_is_local (const char *filename)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
vfs_print_message (const char *msg, ...)
|
||||
{
|
||||
ev_vfs_print_message_t event_data;
|
||||
|
||||
va_start (event_data.ap, msg);
|
||||
event_data.msg = msg;
|
||||
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "vfs_print_message", (gpointer) & event_data);
|
||||
va_end (event_data.ap);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
@ -8,11 +8,16 @@
|
||||
#define MC__VFS_VFS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <utime.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/fs.h" /* MC_MAXPATHLEN */
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
@ -87,6 +92,8 @@
|
||||
|
||||
typedef void (*fill_names_f) (const char *);
|
||||
|
||||
typedef void *vfsid;
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/* Flags of VFS classes */
|
||||
@ -118,7 +125,81 @@ enum
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
struct vfs_class;
|
||||
typedef struct vfs_class
|
||||
{
|
||||
const char *name; /* "FIles over SHell" */
|
||||
vfs_class_flags_t flags;
|
||||
const char *prefix; /* "fish:" */
|
||||
void *data; /* this is for filesystem's own use */
|
||||
int verrno; /* can't use errno because glibc2 might define errno as function */
|
||||
|
||||
int (*init) (struct vfs_class * me);
|
||||
void (*done) (struct vfs_class * me);
|
||||
|
||||
/**
|
||||
* The fill_names method shall call the callback function for every
|
||||
* filesystem name that this vfs module supports.
|
||||
*/
|
||||
void (*fill_names) (struct vfs_class * me, fill_names_f);
|
||||
|
||||
/**
|
||||
* The which() method shall return the index of the vfs subsystem
|
||||
* or -1 if this vfs cannot handle the given pathname.
|
||||
*/
|
||||
int (*which) (struct vfs_class * me, const char *path);
|
||||
|
||||
void *(*open) (struct vfs_class * me, const char *fname, int flags, mode_t mode);
|
||||
int (*close) (void *vfs_info);
|
||||
ssize_t (*read) (void *vfs_info, char *buffer, size_t count);
|
||||
ssize_t (*write) (void *vfs_info, const char *buf, size_t count);
|
||||
|
||||
void *(*opendir) (struct vfs_class * me, const char *dirname);
|
||||
void *(*readdir) (void *vfs_info);
|
||||
int (*closedir) (void *vfs_info);
|
||||
|
||||
int (*stat) (struct vfs_class * me, const char *path, struct stat * buf);
|
||||
int (*lstat) (struct vfs_class * me, const char *path, struct stat * buf);
|
||||
int (*fstat) (void *vfs_info, struct stat * buf);
|
||||
|
||||
int (*chmod) (struct vfs_class * me, const char *path, int mode);
|
||||
int (*chown) (struct vfs_class * me, const char *path, uid_t owner, gid_t group);
|
||||
int (*utime) (struct vfs_class * me, const char *path, struct utimbuf * times);
|
||||
|
||||
int (*readlink) (struct vfs_class * me, const char *path, char *buf, size_t size);
|
||||
int (*symlink) (struct vfs_class * me, const char *n1, const char *n2);
|
||||
int (*link) (struct vfs_class * me, const char *p1, const char *p2);
|
||||
int (*unlink) (struct vfs_class * me, const char *path);
|
||||
int (*rename) (struct vfs_class * me, const char *p1, const char *p2);
|
||||
int (*chdir) (struct vfs_class * me, const char *path);
|
||||
int (*ferrno) (struct vfs_class * me);
|
||||
off_t (*lseek) (void *vfs_info, off_t offset, int whence);
|
||||
int (*mknod) (struct vfs_class * me, const char *path, mode_t mode, dev_t dev);
|
||||
|
||||
vfsid (*getid) (struct vfs_class * me, const char *path);
|
||||
|
||||
int (*nothingisopen) (vfsid id);
|
||||
void (*free) (vfsid id);
|
||||
|
||||
char *(*getlocalcopy) (struct vfs_class * me, const char *filename);
|
||||
int (*ungetlocalcopy) (struct vfs_class * me, const char *filename,
|
||||
const char *local, int has_changed);
|
||||
|
||||
int (*mkdir) (struct vfs_class * me, const char *path, mode_t mode);
|
||||
int (*rmdir) (struct vfs_class * me, const char *path);
|
||||
|
||||
int (*ctl) (void *vfs_info, int ctlop, void *arg);
|
||||
int (*setctl) (struct vfs_class * me, const char *path, int ctlop, void *arg);
|
||||
} vfs_class;
|
||||
|
||||
/*
|
||||
* This union is used to ensure that there is enough space for the
|
||||
* filename (d_name) when the dirent structure is created.
|
||||
*/
|
||||
union vfs_dirent
|
||||
{
|
||||
struct dirent dent;
|
||||
char _extra_buffer[offsetof (struct dirent, d_name) + MC_MAXPATHLEN + 1];
|
||||
};
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
@ -130,16 +211,26 @@ extern int use_netrc;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/* lib/vfs/direntry.c: */
|
||||
void *vfs_s_open (struct vfs_class *me, const char *file, int flags, mode_t mode);
|
||||
|
||||
vfsid vfs_getid (struct vfs_class *vclass, const char *dir);
|
||||
|
||||
void vfs_init (void);
|
||||
void vfs_shut (void);
|
||||
/* Register a file system class */
|
||||
gboolean vfs_register_class (struct vfs_class *vfs);
|
||||
|
||||
void vfs_setup_work_dir (void);
|
||||
|
||||
void vfs_timeout_handler (void);
|
||||
int vfs_timeouts (void);
|
||||
void vfs_expire (int now);
|
||||
|
||||
char *vfs_get_current_dir (void);
|
||||
gboolean vfs_current_is_local (void);
|
||||
gboolean vfs_file_is_local (const char *filename);
|
||||
|
||||
ssize_t mc_read (int handle, void *buffer, size_t count);
|
||||
ssize_t mc_write (int handle, const void *buffer, size_t count);
|
||||
int mc_utime (const char *path, struct utimbuf *times);
|
||||
@ -172,6 +263,9 @@ char *mc_getlocalcopy (const char *pathname);
|
||||
char *vfs_strip_suffix_from_filename (const char *filename);
|
||||
char *vfs_translate_url (const char *url);
|
||||
|
||||
struct vfs_class *vfs_split (char *path, char **inpath, char **op);
|
||||
char *vfs_path (const char *path);
|
||||
|
||||
struct vfs_class *vfs_get_class (const char *path);
|
||||
vfs_class_flags_t vfs_file_class_flags (const char *filename);
|
||||
|
||||
@ -179,11 +273,14 @@ vfs_class_flags_t vfs_file_class_flags (const char *filename);
|
||||
* return static buffer */
|
||||
const char *vfs_get_encoding (const char *path);
|
||||
|
||||
/* return new string */
|
||||
char *vfs_translate_path_n (const char *path);
|
||||
|
||||
/* canonize and translate path, return new string */
|
||||
char *vfs_canon_and_translate (const char *path);
|
||||
/* translate path back to terminal encoding, remove all #enc:
|
||||
* every invalid character is replaced with question mark
|
||||
* return static buffer */
|
||||
char *vfs_translate_path (const char *path);
|
||||
/* return new string */
|
||||
char *vfs_translate_path_n (const char *path);
|
||||
|
||||
void vfs_stamp_path (const char *path);
|
||||
|
||||
@ -191,11 +288,7 @@ void vfs_release_path (const char *dir);
|
||||
|
||||
void vfs_fill_names (fill_names_f);
|
||||
|
||||
char *vfs_get_current_dir (void);
|
||||
/* translate path back to terminal encoding, remove all #enc:
|
||||
* every invalid character is replaced with question mark
|
||||
* return static buffer */
|
||||
char *vfs_translate_path (const char *path);
|
||||
void vfs_print_message (const char *msg, ...) __attribute__ ((format (__printf__, 1, 2)));
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
#endif /* MC_VFS_VFS_H */
|
@ -12,6 +12,7 @@ libmcwidget_la_SOURCES = \
|
||||
hline.c hline.h \
|
||||
history.c history.h \
|
||||
input.c input.h \
|
||||
input_complete.c input_complete.h \
|
||||
listbox-window.c listbox-window.h \
|
||||
listbox.c listbox.h \
|
||||
label.c label.h \
|
||||
|
@ -28,15 +28,15 @@
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/tty.h" /* LINES, COLS */
|
||||
#include "lib/tty/win.h" /* do_enter_ca_mode() */
|
||||
#include "lib/tty/color.h" /* tty_set_normal_attrs() */
|
||||
#include "lib/widget.h"
|
||||
|
||||
/* TODO: these includes should be removed! */
|
||||
#include "src/filemanager/layout.h" /* repaint_screen() */
|
||||
#include "src/filemanager/midnight.h" /* midnight_dlg */
|
||||
#include "src/main.h" /* midnight_shutdown */
|
||||
#include "lib/event.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
Dlg_head *midnight_dlg = NULL;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
@ -92,6 +92,17 @@ dialog_switch_goto (GList * dlg)
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
dlg_resize_cb (void *data, void *user_data)
|
||||
{
|
||||
Dlg_head *d = data;
|
||||
|
||||
(void) user_data;
|
||||
d->callback (d, NULL, DLG_RESIZE, 0, NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -148,7 +159,7 @@ dialog_switch_next (void)
|
||||
{
|
||||
GList *next;
|
||||
|
||||
if (midnight_shutdown || mc_current == NULL)
|
||||
if (mc_global.widget.midnight_shutdown || mc_current == NULL)
|
||||
return;
|
||||
|
||||
next = g_list_next (mc_current);
|
||||
@ -165,7 +176,7 @@ dialog_switch_prev (void)
|
||||
{
|
||||
GList *prev;
|
||||
|
||||
if (midnight_shutdown || mc_current == NULL)
|
||||
if (mc_global.widget.midnight_shutdown || mc_current == NULL)
|
||||
return;
|
||||
|
||||
prev = g_list_previous (mc_current);
|
||||
@ -187,7 +198,7 @@ dialog_switch_list (void)
|
||||
int i = 0;
|
||||
int rv;
|
||||
|
||||
if (midnight_shutdown || mc_current == NULL)
|
||||
if (mc_global.widget.midnight_shutdown || mc_current == NULL)
|
||||
return;
|
||||
|
||||
lines = min ((size_t) (LINES * 2 / 3), dlg_num);
|
||||
@ -240,10 +251,10 @@ dialog_switch_process_pending (void)
|
||||
{
|
||||
destroy_dlg (h);
|
||||
/* return to panels */
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
if (mc_global.mc_run_mode == MC_RUN_FULL)
|
||||
{
|
||||
mc_current = g_list_find (mc_dialogs, midnight_dlg);
|
||||
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
||||
mc_event_raise (MCEVENT_GROUP_FILEMANAGER, "update_panels", NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -280,3 +291,61 @@ dialog_switch_shutdown (void)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
clr_scr (void)
|
||||
{
|
||||
tty_set_normal_attrs ();
|
||||
tty_fill_region (0, 0, LINES, COLS, ' ');
|
||||
tty_refresh ();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
repaint_screen (void)
|
||||
{
|
||||
do_refresh ();
|
||||
tty_refresh ();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
dialog_change_screen_size (void)
|
||||
{
|
||||
mc_global.tty.winch_flag = FALSE;
|
||||
#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4
|
||||
#if defined TIOCGWINSZ
|
||||
|
||||
#ifndef NCURSES_VERSION
|
||||
tty_noraw_mode ();
|
||||
tty_reset_screen ();
|
||||
#endif
|
||||
tty_low_level_change_screen_size ();
|
||||
#ifdef HAVE_SLANG
|
||||
/* XSI Curses spec states that portable applications shall not invoke
|
||||
* initscr() more than once. This kludge could be done within the scope
|
||||
* of the specification by using endwin followed by a refresh (in fact,
|
||||
* more than one curses implementation does this); it is guaranteed to work
|
||||
* only with slang.
|
||||
*/
|
||||
SLsmg_init_smg ();
|
||||
do_enter_ca_mode ();
|
||||
tty_keypad (TRUE);
|
||||
tty_nodelay (FALSE);
|
||||
#endif
|
||||
|
||||
/* Inform all suspending dialogs */
|
||||
dialog_switch_got_winch ();
|
||||
/* Inform all running dialogs */
|
||||
g_list_foreach (top_dlg, (GFunc) dlg_resize_cb, NULL);
|
||||
|
||||
/* Now, force the redraw */
|
||||
repaint_screen ();
|
||||
|
||||
#endif /* TIOCGWINSZ */
|
||||
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
extern Dlg_head *midnight_dlg;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
void dialog_switch_add (struct Dlg_head *h);
|
||||
@ -26,5 +28,11 @@ int dialog_switch_process_pending (void);
|
||||
void dialog_switch_got_winch (void);
|
||||
void dialog_switch_shutdown (void);
|
||||
|
||||
/* Clear screen */
|
||||
void clr_scr (void);
|
||||
void repaint_screen (void);
|
||||
void dialog_change_screen_size (void);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__DIALOG_SWITCH_H */
|
||||
|
@ -37,12 +37,7 @@
|
||||
#include "lib/tty/key.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/widget.h"
|
||||
|
||||
/* TODO: these includes should be removed! */
|
||||
#include "src/help.h" /* interactive_display() */
|
||||
#include "src/filemanager/layout.h"
|
||||
#include "src/execute.h" /* suspend_cmd() */
|
||||
#include "src/keybind-defaults.h"
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -64,6 +59,8 @@ int fast_refresh = 0;
|
||||
/* left click outside of dialog closes it */
|
||||
int mouse_close_dialog = 0;
|
||||
|
||||
const global_keymap_t *dialog_map;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
@ -265,12 +262,15 @@ dlg_execute_cmd (Dlg_head * h, unsigned long command)
|
||||
break;
|
||||
|
||||
case CK_Help:
|
||||
interactive_display (NULL, h->help_ctx);
|
||||
do_refresh ();
|
||||
{
|
||||
ev_help_t event_data = { NULL, h->help_ctx };
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "help", &event_data);
|
||||
do_refresh ();
|
||||
}
|
||||
break;
|
||||
|
||||
case CK_Suspend:
|
||||
suspend_cmd ();
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "suspend", NULL);
|
||||
refresh_cmd ();
|
||||
break;
|
||||
case CK_Refresh:
|
||||
@ -498,7 +498,7 @@ frontend_run_dlg (Dlg_head * h)
|
||||
event.x = -1;
|
||||
|
||||
/* close opened editors, viewers, etc */
|
||||
if (!h->modal && midnight_shutdown)
|
||||
if (!h->modal && mc_global.widget.midnight_shutdown)
|
||||
{
|
||||
h->callback (h, NULL, DLG_VALIDATE, 0, NULL);
|
||||
return;
|
||||
@ -506,8 +506,8 @@ frontend_run_dlg (Dlg_head * h)
|
||||
|
||||
while (h->state == DLG_ACTIVE)
|
||||
{
|
||||
if (winch_flag)
|
||||
change_screen_size ();
|
||||
if (mc_global.tty.winch_flag)
|
||||
dialog_change_screen_size ();
|
||||
|
||||
if (is_idle ())
|
||||
{
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/hook.h" /* hook_t */
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
|
||||
/*** defined constants ***************************************************************************/
|
||||
|
||||
@ -162,6 +163,8 @@ extern hook_t *idle_hook;
|
||||
extern int fast_refresh;
|
||||
extern int mouse_close_dialog;
|
||||
|
||||
extern const global_keymap_t *dialog_map;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
/* draw box in window */
|
||||
|
@ -49,9 +49,6 @@
|
||||
#include "lib/util.h" /* list_append_unique */
|
||||
#include "lib/widget.h"
|
||||
|
||||
/* TODO: these includes should be removed! */
|
||||
#include "src/setup.h" /* num_history_items_recorded */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
int num_history_items_recorded = 60;
|
||||
@ -163,7 +160,7 @@ history_get (const char *input_name)
|
||||
|
||||
/* create charset conversion handler to convert strings
|
||||
from utf-8 to system codepage */
|
||||
if (!utf8_display)
|
||||
if (!mc_global.utf8_display)
|
||||
conv = str_crt_conv_from ("UTF-8");
|
||||
|
||||
buffer = g_string_sized_new (64);
|
||||
@ -254,7 +251,7 @@ history_put (const char *input_name, GList * h)
|
||||
|
||||
/* create charset conversion handler to convert strings
|
||||
from system codepage to UTF-8 */
|
||||
if (!utf8_display)
|
||||
if (!mc_global.utf8_display)
|
||||
conv = str_crt_conv_to ("UTF-8");
|
||||
|
||||
buffer = g_string_sized_new (64);
|
||||
|
@ -42,23 +42,22 @@
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/tty/mouse.h"
|
||||
#include "lib/tty/key.h" /* XCTRL and ALT macros */
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/fileloc.h"
|
||||
#include "lib/skin.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h"
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
#include "lib/widget.h"
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
|
||||
#include "src/main.h" /* home_dir */
|
||||
#include "src/filemanager/midnight.h" /* current_panel */
|
||||
#include "src/clipboard.h" /* copy_file_to_ext_clip, paste_to_file_from_ext_clip */
|
||||
#include "src/keybind-defaults.h" /* input_map */
|
||||
#include "input_complete.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
int quote = 0;
|
||||
|
||||
const global_keymap_t *input_map;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
#define LARGE_HISTORY_BUTTON 1
|
||||
@ -82,124 +81,6 @@ int quote = 0;
|
||||
static char *kill_buffer = NULL;
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
|
||||
static gboolean
|
||||
save_text_to_clip_file (const char *text)
|
||||
{
|
||||
int file;
|
||||
char *fname = NULL;
|
||||
ssize_t ret;
|
||||
size_t str_len;
|
||||
|
||||
fname = g_build_filename (mc_config_get_cache_path (), EDIT_CLIP_FILE, NULL);
|
||||
file = mc_open (fname, O_CREAT | O_WRONLY | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_BINARY);
|
||||
g_free (fname);
|
||||
|
||||
if (file == -1)
|
||||
return FALSE;
|
||||
|
||||
str_len = strlen (text);
|
||||
ret = mc_write (file, (char *) text, str_len);
|
||||
mc_close (file);
|
||||
return ret == (ssize_t) str_len;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gboolean
|
||||
load_text_from_clip_file (char **text)
|
||||
{
|
||||
char buf[BUF_LARGE];
|
||||
FILE *f;
|
||||
char *fname = NULL;
|
||||
gboolean first = TRUE;
|
||||
|
||||
fname = g_build_filename (mc_config_get_cache_path (), EDIT_CLIP_FILE, NULL);
|
||||
f = fopen (fname, "r");
|
||||
g_free (fname);
|
||||
|
||||
if (f == NULL)
|
||||
return FALSE;
|
||||
|
||||
*text = NULL;
|
||||
|
||||
while (fgets (buf, sizeof (buf), f))
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = strlen (buf);
|
||||
if (len > 0)
|
||||
{
|
||||
if (buf[len - 1] == '\n')
|
||||
buf[len - 1] = '\0';
|
||||
|
||||
if (first)
|
||||
{
|
||||
first = FALSE;
|
||||
*text = g_strdup (buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* remove \n on EOL */
|
||||
char *tmp;
|
||||
|
||||
tmp = g_strconcat (*text, " ", buf, (char *) NULL);
|
||||
g_free (*text);
|
||||
*text = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
|
||||
return (*text != NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static gboolean
|
||||
panel_save_curent_file_to_clip_file (void)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
if (current_panel->marked == 0)
|
||||
res = save_text_to_clip_file (selection (current_panel)->fname);
|
||||
else
|
||||
{
|
||||
int i;
|
||||
gboolean first = TRUE;
|
||||
char *flist = NULL;
|
||||
|
||||
for (i = 0; i < current_panel->count; i++)
|
||||
if (current_panel->dir.list[i].f.marked != 0)
|
||||
{ /* Skip the unmarked ones */
|
||||
if (first)
|
||||
{
|
||||
flist = g_strdup (current_panel->dir.list[i].fname);
|
||||
first = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Add empty lines after the file */
|
||||
char *tmp;
|
||||
|
||||
tmp =
|
||||
g_strconcat (flist, "\n", current_panel->dir.list[i].fname, (char *) NULL);
|
||||
g_free (flist);
|
||||
flist = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if (flist != NULL)
|
||||
{
|
||||
res = save_text_to_clip_file (flist);
|
||||
g_free (flist);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
@ -568,9 +449,9 @@ copy_region (WInput * in, int x_first, int x_last)
|
||||
if (last == first)
|
||||
{
|
||||
/* Copy selected files to clipboard */
|
||||
panel_save_curent_file_to_clip_file ();
|
||||
mc_event_raise (MCEVENT_GROUP_FILEMANAGER, "panel_save_curent_file_to_clip_file", NULL);
|
||||
/* try use external clipboard utility */
|
||||
copy_file_to_ext_clip ();
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -581,9 +462,9 @@ copy_region (WInput * in, int x_first, int x_last)
|
||||
|
||||
kill_buffer = g_strndup (in->buffer + first, last - first);
|
||||
|
||||
save_text_to_clip_file (kill_buffer);
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_text_to_file", kill_buffer);
|
||||
/* try use external clipboard utility */
|
||||
copy_file_to_ext_clip ();
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -666,11 +547,15 @@ static void
|
||||
ins_from_clip (WInput * in)
|
||||
{
|
||||
char *p = NULL;
|
||||
ev_clipboard_text_from_file_t event_data;
|
||||
|
||||
/* try use external clipboard utility */
|
||||
paste_to_file_from_ext_clip ();
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_from_ext_clip", NULL);
|
||||
|
||||
if (load_text_from_clip_file (&p))
|
||||
|
||||
event_data.text = &p;
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_text_from_file", &event_data);
|
||||
if (event_data.ret)
|
||||
{
|
||||
char *pp;
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef MC__WIDGET_INPUT_H
|
||||
#define MC__WIDGET_INPUT_H
|
||||
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/* For history load-save functions */
|
||||
@ -68,6 +70,8 @@ typedef struct
|
||||
|
||||
extern int quote;
|
||||
|
||||
extern const global_keymap_t *input_map;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
WInput *input_new (int y, int x, const int *input_colors,
|
||||
@ -88,9 +92,6 @@ void input_disable_update (WInput * in);
|
||||
void input_clean (WInput * in);
|
||||
void input_free_completions (WInput * in);
|
||||
|
||||
/* src/complete.c */
|
||||
void complete (WInput * in);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__WIDGET_INPUT_H */
|
||||
|
@ -40,13 +40,13 @@
|
||||
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/tty/key.h" /* XCTRL and ALT macros */
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/strescape.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h"
|
||||
|
||||
#include "src/setup.h" /* show_all_if_ambiguous */
|
||||
#include "input_complete.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -1343,7 +1343,7 @@ complete (WInput * in)
|
||||
{
|
||||
engine_flags = DO_INSERTION;
|
||||
|
||||
if (show_all_if_ambiguous)
|
||||
if (mc_global.widget.show_all_if_ambiguous)
|
||||
engine_flags |= DO_QUERY;
|
||||
}
|
||||
|
18
lib/widget/input_complete.h
Normal file
18
lib/widget/input_complete.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef MC__WIDGET_INPUT_COMPLETE_H
|
||||
#define MC__WIDGET_INPUT_COMPLETE_H
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
void complete (WInput * in);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__WIDGET_INPUT_COMPLETE_H */
|
@ -44,12 +44,10 @@
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
#include "lib/widget.h"
|
||||
|
||||
/* TODO: these includes should be removed! */
|
||||
#include "src/keybind-defaults.h" /* listbox_map */
|
||||
#include "src/setup.h" /* confirm_history_cleanup */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
const global_keymap_t *listbox_map;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
@ -123,8 +121,8 @@ listbox_draw (WListbox * l, gboolean focused)
|
||||
const gboolean disabled = (((Widget *) l)->options & W_DISABLED) != 0;
|
||||
const int normalc = disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL];
|
||||
int selc =
|
||||
disabled ? DISABLED_COLOR : focused ? h->color[DLG_COLOR_HOT_FOCUS] : h->
|
||||
color[DLG_COLOR_FOCUS];
|
||||
disabled ? DISABLED_COLOR : focused ? h->
|
||||
color[DLG_COLOR_HOT_FOCUS] : h->color[DLG_COLOR_FOCUS];
|
||||
|
||||
GList *le;
|
||||
int pos;
|
||||
@ -269,7 +267,7 @@ listbox_execute_cmd (WListbox * l, unsigned long command)
|
||||
}
|
||||
break;
|
||||
case CK_Clear:
|
||||
if (l->deletable && confirm_history_cleanup
|
||||
if (l->deletable && mc_global.widget.confirm_history_cleanup
|
||||
/* TRANSLATORS: no need to translate 'DialogTitle', it's just a context prefix */
|
||||
&& (query_dialog (Q_ ("DialogTitle|History cleanup"),
|
||||
_("Do you want clean this history?"),
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef MC__WIDGET_LISTBOX_H
|
||||
#define MC__WIDGET_LISTBOX_H
|
||||
|
||||
#include "lib/keybind.h" /* global_keymap_t */
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
@ -53,6 +55,8 @@ typedef struct WListbox
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
extern const global_keymap_t *listbox_map;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
WListbox *listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn callback);
|
||||
|
@ -34,11 +34,7 @@
|
||||
#include "lib/tty/key.h" /* key macros */
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/widget.h"
|
||||
|
||||
/* TODO: these includes should be removed! */
|
||||
#include "src/keybind-defaults.h" /* CK_IgnoreKey */
|
||||
#include "src/help.h"
|
||||
#include "src/filemanager/midnight.h" /* is_right */
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -296,7 +292,7 @@ menubar_execute (WMenuBar * menubar)
|
||||
|
||||
if ((entry != NULL) && (entry->command != CK_IgnoreKey))
|
||||
{
|
||||
is_right = (menubar->selected != 0);
|
||||
mc_global.is_right = (menubar->selected != 0);
|
||||
menubar_finish (menubar);
|
||||
menubar->widget.owner->callback (menubar->widget.owner, &menubar->widget,
|
||||
DLG_ACTION, entry->command, NULL);
|
||||
@ -422,15 +418,19 @@ menubar_handle_key (WMenuBar * menubar, int key)
|
||||
switch (key)
|
||||
{
|
||||
case KEY_F (1):
|
||||
if (menubar->is_dropped)
|
||||
interactive_display (NULL,
|
||||
((Menu *) g_list_nth_data (menubar->menu,
|
||||
menubar->selected))->help_node);
|
||||
else
|
||||
interactive_display (NULL, "[Menu Bar]");
|
||||
menubar_draw (menubar);
|
||||
return 1;
|
||||
{
|
||||
ev_help_t event_data = { NULL, NULL };
|
||||
|
||||
if (menubar->is_dropped)
|
||||
event_data.node =
|
||||
((Menu *) g_list_nth_data (menubar->menu, menubar->selected))->help_node;
|
||||
else
|
||||
event_data.node = "[Menu Bar]";
|
||||
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "help", &event_data);
|
||||
menubar_draw (menubar);
|
||||
return 1;
|
||||
}
|
||||
case KEY_LEFT:
|
||||
case XCTRL ('b'):
|
||||
menubar_left (menubar);
|
||||
|
@ -39,9 +39,7 @@
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/util.h" /* tilde_expand() */
|
||||
#include "lib/widget.h"
|
||||
|
||||
/* TODO: these includes should be removed! */
|
||||
#include "src/background.h" /* parent_call */
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -237,6 +235,37 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
|
||||
return (ret != B_CANCEL) ? my_str : NULL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
wtools_parent_call (void *routine, gpointer ctx, int argc, ...)
|
||||
{
|
||||
ev_background_parent_call_t event_data;
|
||||
|
||||
event_data.routine = routine;
|
||||
event_data.ctx = ctx;
|
||||
event_data.argc = argc;
|
||||
va_start (event_data.ap, argc);
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "background_parent_call", (gpointer) & event_data);
|
||||
va_end (event_data.ap);
|
||||
return event_data.ret.i;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static char *
|
||||
wtools_parent_call_string (void *routine, int argc, ...)
|
||||
{
|
||||
ev_background_parent_call_t event_data;
|
||||
|
||||
event_data.routine = routine;
|
||||
event_data.argc = argc;
|
||||
va_start (event_data.ap, argc);
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "background_parent_call_string", (gpointer) & event_data);
|
||||
va_end (event_data.ap);
|
||||
return event_data.ret.s;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -372,11 +401,6 @@ message (int flags, const char *title, const char *text, ...)
|
||||
{
|
||||
char *p;
|
||||
va_list ap;
|
||||
union
|
||||
{
|
||||
void *p;
|
||||
void (*f) (int, int *, char *, const char *);
|
||||
} func;
|
||||
|
||||
va_start (ap, text);
|
||||
p = g_strdup_vprintf (text, ap);
|
||||
@ -386,10 +410,17 @@ message (int flags, const char *title, const char *text, ...)
|
||||
title = _("Error");
|
||||
|
||||
#ifdef WITH_BACKGROUND
|
||||
if (we_are_background)
|
||||
if (mc_global.we_are_background)
|
||||
{
|
||||
union
|
||||
{
|
||||
void *p;
|
||||
void (*f) (int, int *, char *, const char *);
|
||||
} func;
|
||||
func.f = bg_message;
|
||||
parent_call (func.p, NULL, 3, sizeof (flags), &flags, strlen (title), title, strlen (p), p);
|
||||
|
||||
wtools_parent_call (func.p, NULL, 3, sizeof (flags), &flags, strlen (title), title,
|
||||
strlen (p), p);
|
||||
}
|
||||
else
|
||||
#endif /* WITH_BACKGROUND */
|
||||
@ -416,14 +447,14 @@ input_dialog_help (const char *header, const char *text, const char *help,
|
||||
char *(*f) (const char *, const char *, const char *, const char *, const char *);
|
||||
} func;
|
||||
#ifdef WITH_BACKGROUND
|
||||
if (we_are_background)
|
||||
if (mc_global.we_are_background)
|
||||
{
|
||||
func.f = fg_input_dialog_help;
|
||||
return parent_call_string (func.p, 5,
|
||||
strlen (header), header, strlen (text),
|
||||
text, strlen (help), help,
|
||||
strlen (history_name), history_name,
|
||||
strlen (def_text), def_text);
|
||||
return wtools_parent_call_string (func.p, 5,
|
||||
strlen (header), header, strlen (text),
|
||||
text, strlen (help), help,
|
||||
strlen (history_name), history_name,
|
||||
strlen (def_text), def_text);
|
||||
}
|
||||
else
|
||||
#endif /* WITH_BACKGROUND */
|
||||
@ -459,3 +490,22 @@ input_expand_dialog (const char *header, const char *text,
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_refresh (void)
|
||||
{
|
||||
#ifdef WITH_BACKGROUND
|
||||
if (mc_global.we_are_background)
|
||||
return;
|
||||
#endif /* WITH_BACKGROUND */
|
||||
if (mc_global.tty.winch_flag == FALSE)
|
||||
tty_refresh ();
|
||||
else
|
||||
{
|
||||
/* if winch was caugth, we should do not only redraw screen, but
|
||||
reposition/resize all */
|
||||
dialog_change_screen_size ();
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -47,6 +47,9 @@ struct Dlg_head *create_message (int flags, const char *title,
|
||||
void message (int flags, const char *title, const char *text, ...)
|
||||
__attribute__ ((format (__printf__, 3, 4)));
|
||||
|
||||
/* Clear screen */
|
||||
void mc_refresh (void);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__WTOOLS_H */
|
||||
|
@ -42,4 +42,57 @@ AC_DEFUN([AC_G_MODULE_SUPPORTED], [
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_GMODULE], [test x"$g_module_supported" != x])
|
||||
|
||||
dnl
|
||||
dnl Try to find static libraries for glib and gmodule.
|
||||
dnl
|
||||
if test x$with_glib_static = xyes; then
|
||||
new_GLIB_LIBS=
|
||||
for i in $GLIB_LIBS; do
|
||||
case x$i in
|
||||
x-lglib*)
|
||||
lib=glib ;;
|
||||
x-lgmodule*)
|
||||
lib=gmodule ;;
|
||||
*)
|
||||
lib=
|
||||
add="$i" ;;
|
||||
esac
|
||||
|
||||
if test -n "$lib"; then
|
||||
lib1=`echo $i | sed 's/^-l//'`
|
||||
if test -f "$GLIB_LIBDIR/lib${lib1}.a"; then
|
||||
add="$GLIB_LIBDIR/lib${lib1}.a"
|
||||
else
|
||||
if test -f "$GLIB_LIBDIR/lib${lib}.a"; then
|
||||
add="$GLIB_LIBDIR/lib${lib}.a"
|
||||
else
|
||||
AC_MSG_ERROR([Cannot find static $lib])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
new_GLIB_LIBS="$new_GLIB_LIBS $add"
|
||||
done
|
||||
GLIB_LIBS="$new_GLIB_LIBS"
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_CHECK_GLIB], [
|
||||
dnl
|
||||
dnl First try glib 2.x.
|
||||
dnl Keep this check close to the beginning, so that the users
|
||||
dnl without any glib won't have their time wasted by other checks.
|
||||
dnl
|
||||
|
||||
AC_ARG_WITH([glib_static],
|
||||
AC_HELP_STRING([--with-glib-static],[Link glib statically [[no]]]))
|
||||
|
||||
glib_found=no
|
||||
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.8], [glib_found=yes], [:])
|
||||
if test x"$glib_found" = xno; then
|
||||
AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.8)])
|
||||
fi
|
||||
|
||||
])
|
||||
|
25
m4.include/mc-tests.m4
Normal file
25
m4.include/mc-tests.m4
Normal file
@ -0,0 +1,25 @@
|
||||
dnl @synopsis MC_UNIT_TESTS
|
||||
dnl
|
||||
dnl Check if unit tests enabled
|
||||
dnl
|
||||
dnl @author Slava Zanko <slavazanko@gmail.com>
|
||||
dnl @version 2011-02-10
|
||||
dnl @license GPL
|
||||
dnl @copyright Free Software Foundation, Inc.
|
||||
|
||||
AC_DEFUN([MC_UNIT_TESTS],[
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[tests],
|
||||
AC_HELP_STRING([--enable-tests], [Enable unit tests (see http://check.sourceforge.net/)] )
|
||||
)
|
||||
|
||||
if test x$enable_tests != xno; then
|
||||
PKG_CHECK_MODULES(
|
||||
CHECK,
|
||||
[check >= 0.9.0],
|
||||
[have_check=yes],
|
||||
[AC_MSG_WARN(['Check' utility not found. Check your environment])])
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_TESTS, test x"$have_check" = "xyes")
|
||||
])
|
@ -19,7 +19,7 @@ AC_DEFUN([AC_MC_VFS_SMB],
|
||||
fi
|
||||
|
||||
if test "$enable_vfs_smb" = "yes"; then
|
||||
AC_CONFIG_SUBDIRS([lib/vfs/mc-vfs/samba])
|
||||
AC_CONFIG_SUBDIRS([src/vfs/smbfs/helpers])
|
||||
|
||||
AM_CONDITIONAL([ENABLE_VFS_SMB], [test "1" = "1"])
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
SUBDIRS = filemanager man2hlp viewer
|
||||
SUBDIRS = filemanager man2hlp vfs viewer
|
||||
|
||||
if USE_EDIT
|
||||
SUBDIRS += editor
|
||||
@ -8,10 +8,7 @@ if USE_DIFF
|
||||
SUBDIRS += diffviewer
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" \
|
||||
-DLOCALEDIR=\""$(localedir)"\" \
|
||||
-DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
|
||||
|
||||
AM_CPPFLAGS = -DLOCALEDIR=\""$(localedir)"\"
|
||||
|
||||
if CONS_SAVER
|
||||
SUBDIRS += consaver
|
||||
@ -34,26 +31,17 @@ DIFFLIB = diffviewer/libdiffviewer.la
|
||||
endif
|
||||
|
||||
mc_LDADD = \
|
||||
vfs/libmc-vfs.la \
|
||||
viewer/libmcviewer.la \
|
||||
filemanager/libmcfilemanager.la \
|
||||
$(DIFFLIB) $(EDITLIB) \
|
||||
../lib/libmc.la
|
||||
$(top_builddir)/lib/libmc.la
|
||||
|
||||
if ENABLE_VFS_SMB
|
||||
# this is a hack for linking with own samba library in simple way
|
||||
mc_LDADD += ../lib/vfs/mc-vfs/samba/libsamba.a
|
||||
mc_LDADD += vfs/smbfs/helpers/libsamba.a
|
||||
endif
|
||||
|
||||
mc_LDADD += $(MCLIBS) $(SLANGLIB)
|
||||
|
||||
if HAVE_GMODULE
|
||||
mc_LDADD += $(GMODULE_LIBS)
|
||||
else
|
||||
mc_LDADD += $(GLIB_LIBS)
|
||||
endif
|
||||
|
||||
mc_LDADD += $(PCRE_LIBS) $(LIBICONV) $(INTLLIBS)
|
||||
|
||||
SRC_mc_conssaver = \
|
||||
cons.handler.c consaver/cons.saver.h
|
||||
|
||||
@ -62,6 +50,7 @@ mc_SOURCES = \
|
||||
args.c args.h \
|
||||
background.c background.h \
|
||||
clipboard.c clipboard.h \
|
||||
events_init.c events_init.h \
|
||||
execute.c execute.h \
|
||||
help.c help.h \
|
||||
history.h \
|
||||
@ -70,7 +59,8 @@ mc_SOURCES = \
|
||||
main.c main.h \
|
||||
setup.c setup.h \
|
||||
subshell.c subshell.h \
|
||||
textconf.c textconf.h
|
||||
textconf.c textconf.h \
|
||||
util.c util.h
|
||||
|
||||
if CHARSET
|
||||
mc_SOURCES += selcodepage.c selcodepage.h
|
||||
|
59
src/args.c
59
src/args.c
@ -30,18 +30,17 @@
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/tty/color.h" /* command_line_colors */
|
||||
#include "lib/tty/mouse.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
#include "lib/vfs/mc-vfs/smbfs.h" /* smbfs_set_debugf() */
|
||||
#endif
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/util.h" /* x_basename() */
|
||||
|
||||
#ifdef ENABLE_VFS_SMB
|
||||
#include "src/vfs/smbfs/smbfs.h" /* smbfs_set_debugf() */
|
||||
#endif
|
||||
|
||||
#include "src/main.h"
|
||||
#include "src/textconf.h"
|
||||
#include "src/subshell.h" /* use_subshell */
|
||||
|
||||
#include "src/args.h"
|
||||
|
||||
@ -57,15 +56,6 @@ gboolean mc_args__force_xterm = FALSE;
|
||||
|
||||
gboolean mc_args__nomouse = FALSE;
|
||||
|
||||
/* For slow terminals */
|
||||
gboolean mc_args__slow_terminal = FALSE;
|
||||
|
||||
/* If true use +, -, | for line drawing */
|
||||
gboolean mc_args__ugly_line_drawing = FALSE;
|
||||
|
||||
/* Set to force black and white display at program startup */
|
||||
gboolean mc_args__disable_colors = FALSE;
|
||||
|
||||
/* Force colors, only used by Slang */
|
||||
gboolean mc_args__force_colors = FALSE;
|
||||
|
||||
@ -75,9 +65,6 @@ gboolean mc_args__nokeymap = FALSE;
|
||||
/* Line to start the editor on */
|
||||
int mc_args__edit_start_line = 0;
|
||||
|
||||
/* Use the specified skin */
|
||||
char *mc_args__skin = NULL;
|
||||
|
||||
char *mc_args__last_wd_file = NULL;
|
||||
|
||||
/* when enabled NETCODE, use folowing file as logfile */
|
||||
@ -136,7 +123,7 @@ static const GOptionEntry argument_main_table[] = {
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
{
|
||||
"subshell", 'U', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
|
||||
&use_subshell,
|
||||
&mc_global.tty.use_subshell,
|
||||
N_("Enables subshell support (default)"),
|
||||
NULL
|
||||
},
|
||||
@ -217,14 +204,14 @@ static const GOptionEntry argument_terminal_table[] = {
|
||||
|
||||
{
|
||||
"slow", 's', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
||||
&mc_args__slow_terminal,
|
||||
&mc_global.args.slow_terminal,
|
||||
N_("To run on slow terminals"),
|
||||
NULL
|
||||
},
|
||||
|
||||
{
|
||||
"stickchars", 'a', ARGS_TERM_OPTIONS, G_OPTION_ARG_NONE,
|
||||
&mc_args__ugly_line_drawing,
|
||||
&mc_global.args.ugly_line_drawing,
|
||||
N_("Use stickchars to draw"),
|
||||
NULL
|
||||
},
|
||||
@ -260,13 +247,13 @@ static const GOptionEntry argument_terminal_table[] = {
|
||||
|
||||
GOptionGroup *color_group;
|
||||
#define ARGS_COLOR_OPTIONS 0
|
||||
// #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN
|
||||
/* #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN */
|
||||
static const GOptionEntry argument_color_table[] = {
|
||||
/* *INDENT-OFF* */
|
||||
/* color options */
|
||||
{
|
||||
"nocolor", 'b', ARGS_COLOR_OPTIONS, G_OPTION_ARG_NONE,
|
||||
&mc_args__disable_colors,
|
||||
&mc_global.args.disable_colors,
|
||||
N_("Requests to run in black and white"),
|
||||
NULL
|
||||
},
|
||||
@ -280,14 +267,14 @@ static const GOptionEntry argument_color_table[] = {
|
||||
|
||||
{
|
||||
"colors", 'C', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
|
||||
&command_line_colors,
|
||||
&mc_global.tty.command_line_colors,
|
||||
N_("Specifies a color configuration"),
|
||||
"<string>"
|
||||
},
|
||||
|
||||
{
|
||||
"skin", 'S', ARGS_COLOR_OPTIONS, G_OPTION_ARG_STRING,
|
||||
&mc_args__skin,
|
||||
&mc_global.args.skin,
|
||||
N_("Show mc with specified skin"),
|
||||
"<string>"
|
||||
},
|
||||
@ -329,6 +316,7 @@ mc_args_clean_temp_help_strings (void)
|
||||
static GOptionGroup *
|
||||
mc_args_new_color_group (void)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
/* FIXME: to preserve translations, lines should be split. */
|
||||
mc_args__loc__colors_string = g_strdup_printf ("%s\n%s",
|
||||
/* TRANSLATORS: don't translate keywords */
|
||||
@ -357,6 +345,7 @@ mc_args_new_color_group (void)
|
||||
"Attributes:\n"
|
||||
" bold, underline, reverse, blink; append more with '+'\n")
|
||||
);
|
||||
/* *INDENT-ON* */
|
||||
|
||||
return g_option_group_new ("color", mc_args__loc__colors_string,
|
||||
_("Color options"), NULL, NULL);
|
||||
@ -498,7 +487,7 @@ mc_setup_by_args (int argc, char *argv[])
|
||||
mc_run_param0 = g_strdup (tmp);
|
||||
}
|
||||
}
|
||||
mc_run_mode = MC_RUN_EDITOR;
|
||||
mc_global.mc_run_mode = MC_RUN_EDITOR;
|
||||
}
|
||||
else if (strncmp (base, "mcv", 3) == 0 || strcmp (base, "view") == 0)
|
||||
{
|
||||
@ -511,7 +500,7 @@ mc_setup_by_args (int argc, char *argv[])
|
||||
fprintf (stderr, "%s\n", _("No arguments given to the viewer."));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
mc_run_mode = MC_RUN_VIEWER;
|
||||
mc_global.mc_run_mode = MC_RUN_VIEWER;
|
||||
}
|
||||
#ifdef USE_DIFF_VIEW
|
||||
else if (strncmp (base, "mcd", 3) == 0 || strcmp (base, "diff") == 0)
|
||||
@ -530,7 +519,7 @@ mc_setup_by_args (int argc, char *argv[])
|
||||
tmp = (argc > 1) ? argv[2] : NULL;
|
||||
if (tmp != NULL)
|
||||
mc_run_param1 = g_strdup (tmp);
|
||||
mc_run_mode = MC_RUN_DIFFVIEWER;
|
||||
mc_global.mc_run_mode = MC_RUN_DIFFVIEWER;
|
||||
}
|
||||
}
|
||||
#endif /* USE_DIFF_VIEW */
|
||||
@ -538,7 +527,7 @@ mc_setup_by_args (int argc, char *argv[])
|
||||
{
|
||||
/* MC is run as mc */
|
||||
|
||||
switch (mc_run_mode)
|
||||
switch (mc_global.mc_run_mode)
|
||||
{
|
||||
case MC_RUN_EDITOR:
|
||||
case MC_RUN_VIEWER:
|
||||
@ -559,7 +548,7 @@ mc_setup_by_args (int argc, char *argv[])
|
||||
if (tmp != NULL)
|
||||
mc_run_param1 = g_strdup (tmp);
|
||||
}
|
||||
mc_run_mode = MC_RUN_FULL;
|
||||
mc_global.mc_run_mode = MC_RUN_FULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -577,16 +566,16 @@ mc_args_process (int argc, char *argv[])
|
||||
}
|
||||
if (mc_args__show_datadirs)
|
||||
{
|
||||
printf ("%s (%s)\n", mc_sysconfig_dir, mc_share_data_dir);
|
||||
printf ("%s (%s)\n", mc_global.sysconfig_dir, mc_global.share_data_dir);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mc_args__force_colors)
|
||||
mc_args__disable_colors = FALSE;
|
||||
mc_global.args.disable_colors = FALSE;
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (mc_args__nouse_subshell)
|
||||
use_subshell = 0;
|
||||
mc_global.tty.use_subshell = FALSE;
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
|
||||
mc_setup_by_args (argc, argv);
|
||||
@ -621,7 +610,7 @@ parse_mc_e_argument (const gchar * option_name, const gchar * value, gpointer da
|
||||
(void) data;
|
||||
(void) error;
|
||||
|
||||
mc_run_mode = MC_RUN_EDITOR;
|
||||
mc_global.mc_run_mode = MC_RUN_EDITOR;
|
||||
mc_run_param0 = g_strdup (value);
|
||||
|
||||
return TRUE;
|
||||
@ -636,7 +625,7 @@ parse_mc_v_argument (const gchar * option_name, const gchar * value, gpointer da
|
||||
(void) data;
|
||||
(void) error;
|
||||
|
||||
mc_run_mode = MC_RUN_VIEWER;
|
||||
mc_global.mc_run_mode = MC_RUN_VIEWER;
|
||||
mc_run_param0 = g_strdup (value);
|
||||
|
||||
return TRUE;
|
||||
|
@ -13,12 +13,8 @@
|
||||
|
||||
extern gboolean mc_args__force_xterm;
|
||||
extern gboolean mc_args__nomouse;
|
||||
extern gboolean mc_args__slow_terminal;
|
||||
extern gboolean mc_args__ugly_line_drawing;
|
||||
extern gboolean mc_args__disable_colors;
|
||||
extern gboolean mc_args__force_colors;
|
||||
extern gboolean mc_args__nokeymap;
|
||||
extern char *mc_args__skin;
|
||||
extern gboolean mc_args__version;
|
||||
extern int mc_args__edit_start_line;
|
||||
extern char *mc_args__last_wd_file;
|
||||
|
157
src/background.c
157
src/background.c
@ -46,8 +46,8 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/tty/key.h" /* add_select_channel(), delete_select_channel() */
|
||||
#include "lib/widget.h" /* message() */
|
||||
#include "lib/event-types.h"
|
||||
|
||||
#include "filemanager/layout.h" /* repaint_screen() */
|
||||
#include "filemanager/fileopctx.h" /* FileOpContext */
|
||||
|
||||
#include "background.h"
|
||||
@ -56,9 +56,6 @@
|
||||
|
||||
#define MAXCALLARGS 4 /* Number of arguments supported */
|
||||
|
||||
/* If true, this is a background process */
|
||||
int we_are_background = 0;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
@ -411,6 +408,71 @@ parent_call_header (void *routine, int argc, enum ReturnType type, FileOpContext
|
||||
ret = write (parent_fd, ctx, sizeof (FileOpContext));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
parent_va_call (void *routine, gpointer data, int argc, va_list ap)
|
||||
{
|
||||
int i;
|
||||
ssize_t ret;
|
||||
struct FileOpContext *ctx = (struct FileOpContext *) data;
|
||||
|
||||
parent_call_header (routine, argc, Return_Integer, ctx);
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
int len;
|
||||
void *value;
|
||||
|
||||
len = va_arg (ap, int);
|
||||
value = va_arg (ap, void *);
|
||||
ret = write (parent_fd, &len, sizeof (int));
|
||||
ret = write (parent_fd, value, len);
|
||||
}
|
||||
|
||||
ret = read (from_parent_fd, &i, sizeof (int));
|
||||
if (ctx)
|
||||
ret = read (from_parent_fd, ctx, sizeof (FileOpContext));
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static char *
|
||||
parent_va_call_string (void *routine, int argc, va_list ap)
|
||||
{
|
||||
char *str;
|
||||
int i;
|
||||
|
||||
parent_call_header (routine, argc, Return_String, NULL);
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
int len;
|
||||
void *value;
|
||||
|
||||
len = va_arg (ap, int);
|
||||
value = va_arg (ap, void *);
|
||||
if ((write (parent_fd, &len, sizeof (int)) != sizeof (int)) ||
|
||||
(write (parent_fd, value, len) != len))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (read (from_parent_fd, &i, sizeof (int)) != sizeof (int))
|
||||
return NULL;
|
||||
if (!i)
|
||||
return NULL;
|
||||
str = g_malloc (i + 1);
|
||||
if (read (from_parent_fd, str, i) != i)
|
||||
{
|
||||
g_free (str);
|
||||
return NULL;
|
||||
}
|
||||
str[i] = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -475,7 +537,7 @@ do_background (struct FileOpContext *ctx, char *info)
|
||||
parent_fd = comm[1];
|
||||
from_parent_fd = back_comm[0];
|
||||
|
||||
we_are_background = 1;
|
||||
mc_global.we_are_background = 1;
|
||||
top_dlg = NULL;
|
||||
|
||||
/* Make stdin/stdout/stderr point somewhere */
|
||||
@ -509,28 +571,14 @@ do_background (struct FileOpContext *ctx, char *info)
|
||||
int
|
||||
parent_call (void *routine, struct FileOpContext *ctx, int argc, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
int i;
|
||||
ssize_t ret;
|
||||
|
||||
va_start (ap, argc);
|
||||
parent_call_header (routine, argc, Return_Integer, ctx);
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
int len;
|
||||
void *value;
|
||||
ret = parent_va_call (routine, (gpointer) ctx, argc, ap);
|
||||
va_end (ap);
|
||||
|
||||
len = va_arg (ap, int);
|
||||
value = va_arg (ap, void *);
|
||||
ret = write (parent_fd, &len, sizeof (int));
|
||||
ret = write (parent_fd, value, len);
|
||||
}
|
||||
|
||||
ret = read (from_parent_fd, &i, sizeof (int));
|
||||
if (ctx)
|
||||
ret = read (from_parent_fd, ctx, sizeof (FileOpContext));
|
||||
|
||||
return i;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -540,35 +588,52 @@ parent_call_string (void *routine, int argc, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *str;
|
||||
int i;
|
||||
|
||||
va_start (ap, argc);
|
||||
parent_call_header (routine, argc, Return_String, NULL);
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
int len;
|
||||
void *value;
|
||||
str = parent_va_call_string (routine, argc, ap);
|
||||
va_end (ap);
|
||||
|
||||
len = va_arg (ap, int);
|
||||
value = va_arg (ap, void *);
|
||||
if ((write (parent_fd, &len, sizeof (int)) != sizeof (int)) ||
|
||||
(write (parent_fd, value, len) != len))
|
||||
return NULL;
|
||||
}
|
||||
if (read (from_parent_fd, &i, sizeof (int)) != sizeof (int))
|
||||
return NULL;
|
||||
if (!i)
|
||||
return NULL;
|
||||
str = g_malloc (i + 1);
|
||||
if (read (from_parent_fd, str, i) != i)
|
||||
{
|
||||
g_free (str);
|
||||
return NULL;
|
||||
}
|
||||
str[i] = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* event callback */
|
||||
gboolean
|
||||
background_parent_call (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data)
|
||||
{
|
||||
ev_background_parent_call_t *event_data = (ev_background_parent_call_t *) data;
|
||||
|
||||
(void) event_group_name;
|
||||
(void) event_name;
|
||||
(void) init_data;
|
||||
|
||||
event_data->ret.i =
|
||||
parent_va_call (event_data->routine, event_data->ctx, event_data->argc, event_data->ap);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* event callback */
|
||||
gboolean
|
||||
background_parent_call_string (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data)
|
||||
{
|
||||
ev_background_parent_call_t *event_data = (ev_background_parent_call_t *) data;
|
||||
|
||||
(void) event_group_name;
|
||||
(void) event_name;
|
||||
(void) init_data;
|
||||
|
||||
event_data->ret.s =
|
||||
parent_va_call_string (event_data->routine, event_data->argc, event_data->ap);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif /* WITH_BACKGROUND */
|
||||
|
@ -37,8 +37,6 @@ struct FileOpContext;
|
||||
|
||||
extern struct TaskList *task_list;
|
||||
|
||||
extern int we_are_background;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
int do_background (struct FileOpContext *ctx, char *info);
|
||||
@ -48,6 +46,13 @@ char *parent_call_string (void *routine, int argc, ...);
|
||||
void unregister_task_running (pid_t pid, int fd);
|
||||
void unregister_task_with_pid (pid_t pid);
|
||||
|
||||
gboolean background_parent_call (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data);
|
||||
|
||||
gboolean
|
||||
background_parent_call_string (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* !WITH_BACKGROUND */
|
||||
|
120
src/clipboard.c
120
src/clipboard.c
@ -33,6 +33,9 @@
|
||||
#include "lib/fileloc.h"
|
||||
#include "lib/mcconfig.h"
|
||||
#include "lib/util.h"
|
||||
#include "lib/event.h"
|
||||
|
||||
#include "lib/vfs/vfs.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "src/execute.h"
|
||||
@ -58,15 +61,22 @@ char *clipboard_paste_path = NULL;
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* event callback */
|
||||
gboolean
|
||||
copy_file_to_ext_clip (void)
|
||||
clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data)
|
||||
{
|
||||
char *tmp, *cmd;
|
||||
int res = 0;
|
||||
const char *d = getenv ("DISPLAY");
|
||||
|
||||
(void) event_group_name;
|
||||
(void) event_name;
|
||||
(void) init_data;
|
||||
(void) data;
|
||||
|
||||
if (d == NULL || clipboard_store_path == NULL || clipboard_store_path[0] == '\0')
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
|
||||
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_CLIP_FILE);
|
||||
cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);
|
||||
@ -81,15 +91,22 @@ copy_file_to_ext_clip (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* event callback */
|
||||
gboolean
|
||||
paste_to_file_from_ext_clip (void)
|
||||
clipboard_file_from_ext_clip (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data)
|
||||
{
|
||||
char *tmp, *cmd;
|
||||
int res = 0;
|
||||
const char *d = getenv ("DISPLAY");
|
||||
|
||||
(void) event_group_name;
|
||||
(void) event_name;
|
||||
(void) init_data;
|
||||
(void) data;
|
||||
|
||||
if (d == NULL || clipboard_paste_path == NULL || clipboard_paste_path[0] == '\0')
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
|
||||
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_CLIP_FILE);
|
||||
cmd = g_strconcat (clipboard_paste_path, " > ", tmp, " 2>/dev/null", (char *) NULL);
|
||||
@ -103,3 +120,98 @@ paste_to_file_from_ext_clip (void)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* event callback */
|
||||
gboolean
|
||||
clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data)
|
||||
{
|
||||
int file;
|
||||
char *fname = NULL;
|
||||
ssize_t ret;
|
||||
size_t str_len;
|
||||
const char *text = (const char *) data;
|
||||
|
||||
(void) event_group_name;
|
||||
(void) event_name;
|
||||
(void) init_data;
|
||||
|
||||
if (text == NULL)
|
||||
return FALSE;
|
||||
|
||||
fname = g_build_filename (mc_config_get_cache_path (), EDIT_CLIP_FILE, NULL);
|
||||
file = mc_open (fname, O_CREAT | O_WRONLY | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | O_BINARY);
|
||||
g_free (fname);
|
||||
|
||||
if (file == -1)
|
||||
return TRUE;
|
||||
|
||||
str_len = strlen (text);
|
||||
ret = mc_write (file, (char *) text, str_len);
|
||||
mc_close (file);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* event callback */
|
||||
gboolean
|
||||
clipboard_text_from_file (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data)
|
||||
{
|
||||
char buf[BUF_LARGE];
|
||||
FILE *f;
|
||||
char *fname = NULL;
|
||||
gboolean first = TRUE;
|
||||
ev_clipboard_text_from_file_t *event_data = (ev_clipboard_text_from_file_t *) data;
|
||||
|
||||
(void) event_group_name;
|
||||
(void) event_name;
|
||||
(void) init_data;
|
||||
|
||||
fname = g_build_filename (mc_config_get_cache_path (), EDIT_CLIP_FILE, NULL);
|
||||
f = fopen (fname, "r");
|
||||
g_free (fname);
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
event_data->ret = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*(event_data->text) = NULL;
|
||||
|
||||
while (fgets (buf, sizeof (buf), f))
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = strlen (buf);
|
||||
if (len > 0)
|
||||
{
|
||||
if (buf[len - 1] == '\n')
|
||||
buf[len - 1] = '\0';
|
||||
|
||||
if (first)
|
||||
{
|
||||
first = FALSE;
|
||||
*(event_data->text) = g_strdup (buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* remove \n on EOL */
|
||||
char *tmp;
|
||||
|
||||
tmp = g_strconcat (*(event_data->text), " ", buf, (char *) NULL);
|
||||
g_free (*(event_data->text));
|
||||
*(event_data->text) = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
event_data->ret = (*(event_data->text) != NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -18,8 +18,15 @@ extern char *clipboard_paste_path;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
gboolean copy_file_to_ext_clip (void);
|
||||
gboolean paste_to_file_from_ext_clip (void);
|
||||
gboolean clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data);
|
||||
gboolean clipboard_file_from_ext_clip (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data);
|
||||
|
||||
gboolean clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data);
|
||||
gboolean clipboard_text_from_file (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
|
@ -45,8 +45,6 @@
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
signed char console_flag = 0;
|
||||
|
||||
#ifdef __linux__
|
||||
int cons_saver_pid = 1;
|
||||
#endif /* __linux__ */
|
||||
@ -90,13 +88,13 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
|
||||
ssize_t ret;
|
||||
|
||||
/* Is tty console? */
|
||||
if (!console_flag)
|
||||
if (!mc_global.tty.console_flag)
|
||||
return;
|
||||
/* Paranoid: Is the cons.saver still running? */
|
||||
if (cons_saver_pid < 1 || kill (cons_saver_pid, SIGCONT))
|
||||
{
|
||||
cons_saver_pid = 0;
|
||||
console_flag = 0;
|
||||
mc_global.tty.console_flag = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
@ -123,7 +121,7 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
|
||||
tty_print_char (message);
|
||||
}
|
||||
|
||||
/* Read the value of the console_flag */
|
||||
/* Read the value of the mc_global.tty.console_flag */
|
||||
ret = read (pipefd2[0], &message, 1);
|
||||
}
|
||||
|
||||
@ -145,7 +143,7 @@ handle_console_linux (unsigned char action)
|
||||
/* Create two pipes for communication */
|
||||
if (!((pipe (pipefd1) == 0) && ((pipe (pipefd2)) == 0)))
|
||||
{
|
||||
console_flag = 0;
|
||||
mc_global.tty.console_flag = '\0';
|
||||
break;
|
||||
}
|
||||
/* Get the console saver running */
|
||||
@ -158,7 +156,7 @@ handle_console_linux (unsigned char action)
|
||||
status = close (pipefd1[0]);
|
||||
status = close (pipefd2[1]);
|
||||
status = close (pipefd2[0]);
|
||||
console_flag = 0;
|
||||
mc_global.tty.console_flag = '\0';
|
||||
}
|
||||
else if (cons_saver_pid > 0)
|
||||
{
|
||||
@ -167,8 +165,8 @@ handle_console_linux (unsigned char action)
|
||||
status = close (pipefd1[0]);
|
||||
status = close (pipefd2[1]);
|
||||
/* Was the child successful? */
|
||||
status = read (pipefd2[0], &console_flag, 1);
|
||||
if (!console_flag)
|
||||
status = read (pipefd2[0], &mc_global.tty.console_flag, 1);
|
||||
if (!mc_global.tty.console_flag)
|
||||
{
|
||||
pid_t ret;
|
||||
status = close (pipefd1[1]);
|
||||
@ -208,8 +206,8 @@ handle_console_linux (unsigned char action)
|
||||
/* Console is not a tty or execl() failed */
|
||||
}
|
||||
while (0);
|
||||
console_flag = 0;
|
||||
status = write (1, &console_flag, 1);
|
||||
mc_global.tty.console_flag = '\0';
|
||||
status = write (1, &mc_global.tty.console_flag, 1);
|
||||
_exit (3);
|
||||
} /* if (cons_saver_pid ...) */
|
||||
break;
|
||||
@ -218,13 +216,13 @@ handle_console_linux (unsigned char action)
|
||||
case CONSOLE_SAVE:
|
||||
case CONSOLE_RESTORE:
|
||||
/* Is tty console? */
|
||||
if (!console_flag)
|
||||
if (!mc_global.tty.console_flag)
|
||||
return;
|
||||
/* Paranoid: Is the cons.saver still running? */
|
||||
if (cons_saver_pid < 1 || kill (cons_saver_pid, SIGCONT))
|
||||
{
|
||||
cons_saver_pid = 0;
|
||||
console_flag = 0;
|
||||
mc_global.tty.console_flag = '\0';
|
||||
return;
|
||||
}
|
||||
/* Send command to the console handler */
|
||||
@ -232,16 +230,16 @@ handle_console_linux (unsigned char action)
|
||||
if (action != CONSOLE_DONE)
|
||||
{
|
||||
/* Wait the console handler to do its job */
|
||||
status = read (pipefd2[0], &console_flag, 1);
|
||||
status = read (pipefd2[0], &mc_global.tty.console_flag, 1);
|
||||
}
|
||||
if (action == CONSOLE_DONE || !console_flag)
|
||||
if (action == CONSOLE_DONE || !mc_global.tty.console_flag)
|
||||
{
|
||||
/* We are done -> Let's clean up */
|
||||
pid_t ret;
|
||||
close (pipefd1[1]);
|
||||
close (pipefd2[0]);
|
||||
ret = waitpid (cons_saver_pid, &status, 0);
|
||||
console_flag = 0;
|
||||
mc_global.tty.console_flag = '\0';
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -258,7 +256,7 @@ handle_console_linux (unsigned char action)
|
||||
static void
|
||||
console_init (void)
|
||||
{
|
||||
if (console_flag)
|
||||
if (mc_global.tty.console_flag)
|
||||
return;
|
||||
|
||||
screen_info.size = sizeof (screen_info);
|
||||
@ -270,7 +268,7 @@ console_init (void)
|
||||
screen_shot.ysize = screen_info.mv_rsz;
|
||||
screen_shot.buf = g_try_malloc (screen_info.mv_csz * screen_info.mv_rsz * 2);
|
||||
if (screen_shot.buf != NULL)
|
||||
console_flag = 1;
|
||||
mc_global.tty.console_flag = '\001';
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -299,7 +297,7 @@ console_restore (void)
|
||||
{
|
||||
int i, last;
|
||||
|
||||
if (!console_flag)
|
||||
if (!mc_global.tty.console_flag)
|
||||
return;
|
||||
|
||||
cursor_to (0, 0);
|
||||
@ -323,12 +321,12 @@ console_restore (void)
|
||||
static void
|
||||
console_shutdown (void)
|
||||
{
|
||||
if (!console_flag)
|
||||
if (!mc_global.tty.console_flag)
|
||||
return;
|
||||
|
||||
g_free (screen_shot.buf);
|
||||
|
||||
console_flag = 0;
|
||||
mc_global.tty.console_flag = '\0';
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -340,7 +338,7 @@ console_save (void)
|
||||
scrmap_t map;
|
||||
scrmap_t revmap;
|
||||
|
||||
if (!console_flag)
|
||||
if (!mc_global.tty.console_flag)
|
||||
return;
|
||||
|
||||
/* screen_info.size is already set in console_init() */
|
||||
@ -391,7 +389,7 @@ show_console_contents_freebsd (int starty, unsigned char begin_line, unsigned ch
|
||||
int col, line;
|
||||
char c;
|
||||
|
||||
if (!console_flag)
|
||||
if (!mc_global.tty.console_flag)
|
||||
return;
|
||||
|
||||
for (line = begin_line; line <= end_line; line++)
|
||||
@ -450,7 +448,7 @@ show_console_contents (int starty, unsigned char begin_line, unsigned char end_l
|
||||
#elif defined (__FreeBSD__)
|
||||
show_console_contents_freebsd (starty, begin_line, end_line);
|
||||
#else
|
||||
console_flag = 0;
|
||||
mc_global.tty.console_flag = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ enum
|
||||
|
||||
#ifndef LINUX_CONS_SAVER_C
|
||||
/* Used only in mc, not in cons.saver */
|
||||
extern signed char console_flag;
|
||||
extern int cons_saver_pid;
|
||||
#endif /* !LINUX_CONS_SAVER_C */
|
||||
|
||||
|
@ -38,19 +38,18 @@
|
||||
#include "lib/tty/color.h"
|
||||
#include "lib/tty/key.h"
|
||||
#include "lib/skin.h" /* EDITOR_NORMAL_COLOR */
|
||||
#include "lib/vfs/mc-vfs/vfs.h" /* mc_opendir, mc_readdir, mc_closedir, */
|
||||
#include "lib/vfs/vfs.h" /* mc_opendir, mc_readdir, mc_closedir, */
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h"
|
||||
#include "lib/charsets.h"
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
|
||||
#include "src/filemanager/cmd.h"
|
||||
#include "src/filemanager/midnight.h" /* Needed for current_panel and other_panel */
|
||||
#include "src/filemanager/layout.h" /* Needed for get_current_index and get_other_panel */
|
||||
|
||||
#include "src/keybind-defaults.h"
|
||||
#include "src/help.h"
|
||||
#include "src/history.h"
|
||||
#include "src/main.h" /* mc_run_mode, midnight_shutdown */
|
||||
#include "src/selcodepage.h"
|
||||
|
||||
#include "ydiff.h"
|
||||
@ -119,7 +118,9 @@ dview_set_codeset (WDiff * dview)
|
||||
const char *encoding_id = NULL;
|
||||
|
||||
dview->utf8 = TRUE;
|
||||
encoding_id = get_codepage_id (source_codepage >= 0 ? source_codepage : display_codepage);
|
||||
encoding_id =
|
||||
get_codepage_id (mc_global.source_codepage >=
|
||||
0 ? mc_global.source_codepage : mc_global.display_codepage);
|
||||
if (encoding_id != NULL)
|
||||
{
|
||||
GIConv conv;
|
||||
@ -2582,7 +2583,7 @@ dview_display_file (const WDiff * dview, int ord, int r, int c, int height, int
|
||||
{
|
||||
tty_setcolor (att[cnt] ? DFF_CHH_COLOR : DFF_CHG_COLOR);
|
||||
#ifdef HAVE_CHARSET
|
||||
if (utf8_display)
|
||||
if (mc_global.utf8_display)
|
||||
{
|
||||
if (!dview->utf8)
|
||||
{
|
||||
@ -2660,7 +2661,7 @@ dview_display_file (const WDiff * dview, int ord, int r, int c, int height, int
|
||||
if (ch_res)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
if (utf8_display)
|
||||
if (mc_global.utf8_display)
|
||||
{
|
||||
if (!dview->utf8)
|
||||
{
|
||||
@ -2943,13 +2944,13 @@ dview_ok_to_exit (WDiff * dview)
|
||||
if (!dview->merged)
|
||||
return res;
|
||||
|
||||
act = query_dialog (_("Quit"), !midnight_shutdown ?
|
||||
act = query_dialog (_("Quit"), !mc_global.widget.midnight_shutdown ?
|
||||
_("File was modified. Save with exit?") :
|
||||
_("Midnight Commander is being shut down.\nSave modified file?"),
|
||||
D_NORMAL, 2, _("&Yes"), _("&No"));
|
||||
|
||||
/* Esc is No */
|
||||
if (midnight_shutdown || (act == -1))
|
||||
if (mc_global.widget.midnight_shutdown || (act == -1))
|
||||
act = 1;
|
||||
|
||||
switch (act)
|
||||
@ -2981,7 +2982,10 @@ dview_execute_cmd (WDiff * dview, unsigned long command)
|
||||
switch (command)
|
||||
{
|
||||
case CK_Help:
|
||||
interactive_display (NULL, "[Diff Viewer]");
|
||||
{
|
||||
ev_help_t event_data = { NULL, "[Diff Viewer]" };
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "help", &event_data);
|
||||
}
|
||||
break;
|
||||
case CK_ShowSymbols:
|
||||
dview->display_symbols ^= 1;
|
||||
@ -3235,7 +3239,7 @@ dview_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, v
|
||||
|
||||
case DLG_VALIDATE:
|
||||
dview = (WDiff *) find_widget_type (h, dview_callback);
|
||||
h->state = DLG_ACTIVE; /* don't stop the dialog before final decision */
|
||||
h->state = DLG_ACTIVE; /* don't stop the dialog before final decision */
|
||||
if (dview_ok_to_exit (dview))
|
||||
h->state = DLG_CLOSED;
|
||||
return MSG_HANDLED;
|
||||
@ -3357,7 +3361,7 @@ dview_diff_cmd (void)
|
||||
int is_dir0 = 0;
|
||||
int is_dir1 = 0;
|
||||
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
if (mc_global.mc_run_mode == MC_RUN_FULL)
|
||||
{
|
||||
const WPanel *panel0 = current_panel;
|
||||
const WPanel *panel1 = other_panel;
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "lib/tty/tty.h" /* attrset() */
|
||||
#include "lib/tty/key.h" /* is_idle() */
|
||||
#include "lib/skin.h" /* EDITOR_NORMAL_COLOR */
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/strutil.h" /* utf string functions */
|
||||
#include "lib/util.h" /* load_file_position(), save_file_position() */
|
||||
#include "lib/timefmt.h" /* time formatting */
|
||||
@ -60,7 +60,6 @@
|
||||
#include "src/filemanager/cmd.h" /* view_other_cmd() */
|
||||
#include "src/filemanager/usermenu.h" /* user_menu_cmd() */
|
||||
|
||||
#include "src/main.h" /* source_codepage */
|
||||
#include "src/setup.h" /* option_tab_spacing */
|
||||
#include "src/learn.h" /* learn_keys */
|
||||
#include "src/keybind-defaults.h"
|
||||
@ -2322,7 +2321,7 @@ edit_set_codeset (WEdit * edit)
|
||||
#ifdef HAVE_CHARSET
|
||||
const char *cp_id;
|
||||
|
||||
cp_id = get_codepage_id (source_codepage >= 0 ? source_codepage : display_codepage);
|
||||
cp_id = get_codepage_id (mc_global.source_codepage >= 0 ? mc_global.source_codepage : mc_global.display_codepage);
|
||||
|
||||
if (cp_id != NULL)
|
||||
{
|
||||
@ -2937,7 +2936,7 @@ edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
|
||||
int cw = 1;
|
||||
|
||||
utf_ch = edit_get_utf (edit, p, &cw);
|
||||
if (utf8_display)
|
||||
if (mc_global.utf8_display)
|
||||
{
|
||||
if (cw > 1)
|
||||
col -= cw - 1;
|
||||
@ -2960,7 +2959,7 @@ edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
|
||||
else
|
||||
return p;
|
||||
}
|
||||
else if ((c < 32 || c == 127) && (orig_c == c || (!utf8_display && !edit->utf8)))
|
||||
else if ((c < 32 || c == 127) && (orig_c == c || (!mc_global.utf8_display && !edit->utf8)))
|
||||
/* '\r' is shown as ^M, so we must advance 2 characters */
|
||||
/* Caret notation for control characters */
|
||||
col += 2;
|
||||
@ -3499,14 +3498,14 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
|
||||
if (edit->overwrite)
|
||||
{
|
||||
/* remove char only one time, after input first byte, multibyte chars */
|
||||
if ((!utf8_display || edit->charpoint == 0)
|
||||
if ((!mc_global.utf8_display || edit->charpoint == 0)
|
||||
&& edit_get_byte (edit, edit->curs1) != '\n')
|
||||
edit_delete (edit, 0);
|
||||
}
|
||||
if (option_cursor_beyond_eol && edit->over_col > 0)
|
||||
edit_insert_over (edit);
|
||||
#ifdef HAVE_CHARSET
|
||||
if (char_for_insertion > 255 && utf8_display == 0)
|
||||
if (char_for_insertion > 255 && mc_global.utf8_display == 0)
|
||||
{
|
||||
unsigned char str[6 + 1];
|
||||
size_t i = 0;
|
||||
|
@ -53,19 +53,18 @@
|
||||
#include "lib/strutil.h" /* utf string functions */
|
||||
#include "lib/lock.h"
|
||||
#include "lib/util.h" /* tilde_expand() */
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/widget.h"
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "src/filemanager/layout.h" /* clr_scr() */
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
|
||||
#include "src/history.h"
|
||||
#include "src/main.h" /* mc_sysconfig_dir, midnight_shutdown */
|
||||
#include "src/setup.h" /* option_tab_spacing */
|
||||
#include "src/help.h" /* interactive_display() */
|
||||
#include "src/selcodepage.h"
|
||||
#include "src/keybind-defaults.h"
|
||||
#include "src/clipboard.h" /* copy_file_to_ext_clip, paste_to_file_from_ext_clip */
|
||||
#include "src/util.h" /* check_for_default() */
|
||||
#include "src/filemanager/layout.h" /* mc_refresh() */
|
||||
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "edit-widget.h"
|
||||
@ -515,11 +514,11 @@ edit_load_syntax_file (WEdit * edit)
|
||||
_("&User"), _("&System Wide"));
|
||||
}
|
||||
|
||||
extdir = g_build_filename (mc_sysconfig_dir, "syntax", "Syntax", (char *) NULL);
|
||||
extdir = g_build_filename (mc_global.sysconfig_dir, "syntax", "Syntax", (char *) NULL);
|
||||
if (!exist_file (extdir))
|
||||
{
|
||||
g_free (extdir);
|
||||
extdir = g_build_filename (mc_share_data_dir, "syntax", "Syntax", (char *) NULL);
|
||||
extdir = g_build_filename (mc_global.share_data_dir, "syntax", "Syntax", (char *) NULL);
|
||||
}
|
||||
|
||||
if (dir == 0)
|
||||
@ -550,12 +549,12 @@ edit_load_menu_file (WEdit * edit)
|
||||
_("Which menu file do you want to edit?"), D_NORMAL,
|
||||
geteuid () != 0 ? 2 : 3, _("&Local"), _("&User"), _("&System Wide"));
|
||||
|
||||
menufile = concat_dir_and_file (mc_sysconfig_dir, EDIT_GLOBAL_MENU);
|
||||
menufile = concat_dir_and_file (mc_global.sysconfig_dir, EDIT_GLOBAL_MENU);
|
||||
|
||||
if (!exist_file (menufile))
|
||||
{
|
||||
g_free (menufile);
|
||||
menufile = concat_dir_and_file (mc_share_data_dir, EDIT_GLOBAL_MENU);
|
||||
menufile = concat_dir_and_file (mc_global.share_data_dir, EDIT_GLOBAL_MENU);
|
||||
}
|
||||
|
||||
switch (dir)
|
||||
@ -572,11 +571,11 @@ edit_load_menu_file (WEdit * edit)
|
||||
break;
|
||||
|
||||
case 2:
|
||||
buffer = concat_dir_and_file (mc_sysconfig_dir, EDIT_GLOBAL_MENU);
|
||||
buffer = concat_dir_and_file (mc_global.sysconfig_dir, EDIT_GLOBAL_MENU);
|
||||
if (!exist_file (buffer))
|
||||
{
|
||||
g_free (buffer);
|
||||
buffer = concat_dir_and_file (mc_share_data_dir, EDIT_GLOBAL_MENU);
|
||||
buffer = concat_dir_and_file (mc_global.share_data_dir, EDIT_GLOBAL_MENU);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1146,7 +1145,9 @@ edit_collect_completions (WEdit * edit, long start, gsize word_len,
|
||||
void
|
||||
edit_help_cmd (WEdit * edit)
|
||||
{
|
||||
interactive_display (NULL, "[Internal File Editor]");
|
||||
ev_help_t event_data = { NULL, "[Internal File Editor]" };
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "help", &event_data);
|
||||
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
}
|
||||
|
||||
@ -2486,7 +2487,7 @@ edit_ok_to_exit (WEdit * edit)
|
||||
if (!edit->modified)
|
||||
return TRUE;
|
||||
|
||||
if (!midnight_shutdown)
|
||||
if (!mc_global.widget.midnight_shutdown)
|
||||
{
|
||||
if (!edit_check_newline (edit))
|
||||
return FALSE;
|
||||
@ -2512,8 +2513,8 @@ edit_ok_to_exit (WEdit * edit)
|
||||
case 0: /* Yes */
|
||||
edit_push_markers (edit);
|
||||
edit_set_markers (edit, 0, 0, 0, 0);
|
||||
if (!edit_save_cmd (edit) || midnight_shutdown)
|
||||
return (gboolean) midnight_shutdown;
|
||||
if (!edit_save_cmd (edit) || mc_global.widget.midnight_shutdown)
|
||||
return mc_global.widget.midnight_shutdown;
|
||||
break;
|
||||
case 1: /* No */
|
||||
break;
|
||||
@ -2602,7 +2603,7 @@ edit_copy_to_X_buf_cmd (WEdit * edit)
|
||||
return 1;
|
||||
}
|
||||
/* try use external clipboard utility */
|
||||
copy_file_to_ext_clip ();
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2621,7 +2622,7 @@ edit_cut_to_X_buf_cmd (WEdit * edit)
|
||||
return 1;
|
||||
}
|
||||
/* try use external clipboard utility */
|
||||
copy_file_to_ext_clip ();
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", NULL);
|
||||
|
||||
edit_block_delete_cmd (edit);
|
||||
edit_mark_cmd (edit, 1);
|
||||
@ -2635,7 +2636,7 @@ edit_paste_from_X_buf_cmd (WEdit * edit)
|
||||
{
|
||||
gchar *tmp;
|
||||
/* try use external clipboard utility */
|
||||
paste_to_file_from_ext_clip ();
|
||||
mc_event_raise (MCEVENT_GROUP_CORE, "clipboard_file_from_ext_clip", NULL);
|
||||
tmp = concat_dir_and_file (mc_config_get_cache_path (), EDIT_CLIP_FILE);
|
||||
edit_insert_file (edit, tmp);
|
||||
g_free (tmp);
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "lib/widget.h" /* buttonbar_redraw() */
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "src/main.h" /* source_codepage */
|
||||
#include "src/setup.h" /* edit_tab_spacing */
|
||||
|
||||
#include "edit-impl.h"
|
||||
@ -151,7 +150,7 @@ status_string (WEdit * edit, char *s, int w)
|
||||
edit->curs_line + 1,
|
||||
edit->total_lines + 1, edit->curs1, edit->last_byte, byte_str,
|
||||
#ifdef HAVE_CHARSET
|
||||
source_codepage >= 0 ? get_codepage_id (source_codepage) : ""
|
||||
mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) : ""
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
@ -169,7 +168,7 @@ status_string (WEdit * edit, char *s, int w)
|
||||
edit->curs_line + 1,
|
||||
edit->total_lines + 1, edit->curs1, edit->last_byte, byte_str,
|
||||
#ifdef HAVE_CHARSET
|
||||
source_codepage >= 0 ? get_codepage_id (source_codepage) : ""
|
||||
mc_global.source_codepage >= 0 ? get_codepage_id (mc_global.source_codepage) : ""
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
@ -502,7 +501,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
||||
/* fallthrough */
|
||||
default:
|
||||
#ifdef HAVE_CHARSET
|
||||
if (utf8_display)
|
||||
if (mc_global.utf8_display)
|
||||
{
|
||||
if (!edit->utf8)
|
||||
{
|
||||
@ -540,8 +539,8 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
||||
}
|
||||
if (!edit->utf8)
|
||||
{
|
||||
if ((utf8_display && g_unichar_isprint (c)) ||
|
||||
(!utf8_display && is_printable (c)))
|
||||
if ((mc_global.utf8_display && g_unichar_isprint (c)) ||
|
||||
(!mc_global.utf8_display && is_printable (c)))
|
||||
{
|
||||
p->ch = c;
|
||||
p++;
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "editcmd_dialogs.h"
|
||||
|
||||
#include "src/keybind-defaults.h" /* keybind_lookup_keymap_command() */
|
||||
#include "src/main.h" /* display_codepage */
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
@ -95,7 +94,7 @@ edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch)
|
||||
}
|
||||
|
||||
/* input from 8-bit locale */
|
||||
if (!utf8_display)
|
||||
if (!mc_global.utf8_display)
|
||||
{
|
||||
/* source in 8-bit codeset */
|
||||
if (!edit->utf8)
|
||||
|
@ -57,8 +57,6 @@
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h" /* message() */
|
||||
|
||||
#include "src/main.h" /* mc_sysconfig_dir */
|
||||
|
||||
#include "edit-impl.h"
|
||||
#include "edit-widget.h"
|
||||
|
||||
@ -859,13 +857,13 @@ open_include_file (const char *filename)
|
||||
return f;
|
||||
|
||||
g_free (error_file_name);
|
||||
error_file_name = g_build_filename (mc_sysconfig_dir, "syntax", filename, (char *) NULL);
|
||||
error_file_name = g_build_filename (mc_global.sysconfig_dir, "syntax", filename, (char *) NULL);
|
||||
f = fopen (error_file_name, "r");
|
||||
if (f != NULL)
|
||||
return f;
|
||||
|
||||
g_free (error_file_name);
|
||||
error_file_name = g_build_filename (mc_share_data_dir, "syntax", filename, (char *) NULL);
|
||||
error_file_name = g_build_filename (mc_global.share_data_dir, "syntax", filename, (char *) NULL);
|
||||
|
||||
return fopen (error_file_name, "r");
|
||||
}
|
||||
@ -1267,7 +1265,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
|
||||
f = fopen (syntax_file, "r");
|
||||
if (f == NULL)
|
||||
{
|
||||
lib_file = g_build_filename (mc_share_data_dir, "syntax", "Syntax", (char *) NULL);
|
||||
lib_file = g_build_filename (mc_global.share_data_dir, "syntax", "Syntax", (char *) NULL);
|
||||
f = fopen (lib_file, "r");
|
||||
g_free (lib_file);
|
||||
if (f == NULL)
|
||||
|
84
src/events_init.c
Normal file
84
src/events_init.c
Normal file
@ -0,0 +1,84 @@
|
||||
/* Event callbacks initialization
|
||||
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011.
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
|
||||
#include "lib/event.h"
|
||||
|
||||
#ifdef WITH_BACKGROUND
|
||||
#include "background.h" /* (background_parent_call), background_parent_call_string() */
|
||||
#endif /* WITH_BACKGROUND */
|
||||
#include "clipboard.h" /* clipboard events */
|
||||
#include "execute.h" /* execute_suspend() */
|
||||
#include "help.h" /* help_interactive_display() */
|
||||
|
||||
#include "events_init.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
events_init (GError ** error)
|
||||
{
|
||||
/* *INDENT-OFF* */
|
||||
event_init_t standard_events[] =
|
||||
{
|
||||
{MCEVENT_GROUP_CORE, "clipboard_file_to_ext_clip", clipboard_file_to_ext_clip, NULL},
|
||||
{MCEVENT_GROUP_CORE, "clipboard_file_from_ext_clip", clipboard_file_from_ext_clip, NULL},
|
||||
{MCEVENT_GROUP_CORE, "clipboard_text_to_file", clipboard_text_to_file, NULL},
|
||||
{MCEVENT_GROUP_CORE, "clipboard_text_from_file", clipboard_text_from_file, NULL},
|
||||
|
||||
{MCEVENT_GROUP_CORE, "help", help_interactive_display, NULL},
|
||||
{MCEVENT_GROUP_CORE, "suspend", execute_suspend, NULL},
|
||||
|
||||
#ifdef WITH_BACKGROUND
|
||||
{MCEVENT_GROUP_CORE, "background_parent_call", background_parent_call, NULL},
|
||||
{MCEVENT_GROUP_CORE, "background_parent_call_string", background_parent_call_string, NULL},
|
||||
#endif /* WITH_BACKGROUND */
|
||||
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
if (!mc_event_init (error))
|
||||
return FALSE;
|
||||
|
||||
return mc_event_mass_add (standard_events, error);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
19
src/events_init.h
Normal file
19
src/events_init.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef MC__EVENTS_INIT_H
|
||||
#define MC__EVENTS_INIT_H
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
gboolean events_init (GError **);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__EVENTS_INIT_H */
|
@ -30,7 +30,7 @@
|
||||
#include "lib/tty/tty.h"
|
||||
#include "lib/tty/key.h"
|
||||
#include "lib/tty/win.h"
|
||||
#include "lib/vfs/mc-vfs/vfs.h"
|
||||
#include "lib/vfs/vfs.h"
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h"
|
||||
|
||||
@ -81,7 +81,7 @@ edition_pre_exec (void)
|
||||
clr_scr ();
|
||||
else
|
||||
{
|
||||
if (!(console_flag || xterm_flag))
|
||||
if (!(mc_global.tty.console_flag || xterm_flag))
|
||||
printf ("\n\n");
|
||||
}
|
||||
|
||||
@ -132,19 +132,19 @@ do_execute (const char *lc_shell, const char *command, int flags)
|
||||
if (!vfs_current_is_local ())
|
||||
old_vfs_dir = g_strdup (vfs_get_current_dir ());
|
||||
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
if (mc_global.mc_run_mode == MC_RUN_FULL)
|
||||
save_cwds_stat ();
|
||||
pre_exec ();
|
||||
if (console_flag)
|
||||
if (mc_global.tty.console_flag)
|
||||
handle_console (CONSOLE_RESTORE);
|
||||
|
||||
if (!use_subshell && command && !(flags & EXECUTE_INTERNAL))
|
||||
if (!mc_global.tty.use_subshell && command && !(flags & EXECUTE_INTERNAL))
|
||||
{
|
||||
printf ("%s%s\n", mc_prompt, command);
|
||||
fflush (stdout);
|
||||
}
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (use_subshell && !(flags & EXECUTE_INTERNAL))
|
||||
if (mc_global.tty.use_subshell && !(flags & EXECUTE_INTERNAL))
|
||||
{
|
||||
do_update_prompt ();
|
||||
|
||||
@ -159,7 +159,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
|
||||
{
|
||||
if ((pause_after_run == pause_always
|
||||
|| (pause_after_run == pause_on_dumb_terminals && !xterm_flag
|
||||
&& !console_flag)) && quit == 0
|
||||
&& !mc_global.tty.console_flag)) && quit == 0
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
&& subshell_state != RUNNING_COMMAND
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
@ -172,9 +172,9 @@ do_execute (const char *lc_shell, const char *command, int flags)
|
||||
printf ("\r\n");
|
||||
fflush (stdout);
|
||||
}
|
||||
if (console_flag)
|
||||
if (mc_global.tty.console_flag)
|
||||
{
|
||||
if (output_lines && keybar_visible)
|
||||
if (output_lines && mc_global.keybar_visible)
|
||||
{
|
||||
putchar ('\n');
|
||||
fflush (stdout);
|
||||
@ -182,7 +182,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
if (console_flag)
|
||||
if (mc_global.tty.console_flag)
|
||||
handle_console (CONSOLE_SAVE);
|
||||
edition_post_exec ();
|
||||
|
||||
@ -198,7 +198,7 @@ do_execute (const char *lc_shell, const char *command, int flags)
|
||||
g_free (old_vfs_dir);
|
||||
}
|
||||
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
if (mc_global.mc_run_mode == MC_RUN_FULL)
|
||||
{
|
||||
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
||||
update_xterm_title_path ();
|
||||
@ -215,7 +215,7 @@ do_suspend_cmd (void)
|
||||
{
|
||||
pre_exec ();
|
||||
|
||||
if (console_flag && !use_subshell)
|
||||
if (mc_global.tty.console_flag && !mc_global.tty.use_subshell)
|
||||
handle_console (CONSOLE_RESTORE);
|
||||
|
||||
#ifdef SIGTSTP
|
||||
@ -234,7 +234,7 @@ do_suspend_cmd (void)
|
||||
}
|
||||
#endif /* SIGTSTP */
|
||||
|
||||
if (console_flag && !use_subshell)
|
||||
if (mc_global.tty.console_flag && !mc_global.tty.use_subshell)
|
||||
handle_console (CONSOLE_SAVE);
|
||||
|
||||
edition_post_exec ();
|
||||
@ -277,7 +277,7 @@ shell_execute (const char *command, int flags)
|
||||
}
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (use_subshell)
|
||||
if (mc_global.tty.use_subshell)
|
||||
if (subshell_state == INACTIVE)
|
||||
do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
|
||||
else
|
||||
@ -324,11 +324,11 @@ toggle_panels (void)
|
||||
tty_reset_screen ();
|
||||
do_exit_ca_mode ();
|
||||
tty_raw_mode ();
|
||||
if (console_flag)
|
||||
if (mc_global.tty.console_flag)
|
||||
handle_console (CONSOLE_RESTORE);
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (use_subshell)
|
||||
if (mc_global.tty.use_subshell)
|
||||
{
|
||||
new_dir_p = vfs_current_is_local ()? &new_dir : NULL;
|
||||
invoke_subshell (NULL, VISIBLY, new_dir_p);
|
||||
@ -347,7 +347,7 @@ toggle_panels (void)
|
||||
get_key_code (0);
|
||||
}
|
||||
|
||||
if (console_flag)
|
||||
if (mc_global.tty.console_flag)
|
||||
handle_console (CONSOLE_SAVE);
|
||||
|
||||
do_enter_ca_mode ();
|
||||
@ -366,7 +366,7 @@ toggle_panels (void)
|
||||
quit = 0;
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
/* restart subshell */
|
||||
if (use_subshell)
|
||||
if (mc_global.tty.use_subshell)
|
||||
init_subshell ();
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
}
|
||||
@ -377,19 +377,19 @@ toggle_panels (void)
|
||||
application_keypad_mode ();
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (use_subshell)
|
||||
if (mc_global.tty.use_subshell)
|
||||
{
|
||||
load_prompt (0, NULL);
|
||||
if (new_dir)
|
||||
do_possible_cd (new_dir);
|
||||
if (console_flag && output_lines)
|
||||
if (mc_global.tty.console_flag && output_lines)
|
||||
show_console_contents (output_start_y,
|
||||
LINES - keybar_visible - output_lines -
|
||||
1, LINES - keybar_visible - 1);
|
||||
LINES - mc_global.keybar_visible - output_lines -
|
||||
1, LINES - mc_global.keybar_visible - 1);
|
||||
}
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
if (mc_global.mc_run_mode == MC_RUN_FULL)
|
||||
{
|
||||
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
||||
update_xterm_title_path ();
|
||||
@ -399,15 +399,24 @@ toggle_panels (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
suspend_cmd (void)
|
||||
/* event callback */
|
||||
gboolean
|
||||
execute_suspend (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data)
|
||||
{
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
(void) event_group_name;
|
||||
(void) event_name;
|
||||
(void) init_data;
|
||||
(void) data;
|
||||
|
||||
if (mc_global.mc_run_mode == MC_RUN_FULL)
|
||||
save_cwds_stat ();
|
||||
do_suspend_cmd ();
|
||||
if (mc_run_mode == MC_RUN_FULL)
|
||||
if (mc_global.mc_run_mode == MC_RUN_FULL)
|
||||
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
||||
do_refresh ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -5,12 +5,9 @@
|
||||
#ifndef MC__EXECUTE_H
|
||||
#define MC__EXECUTE_H
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
#include "lib/utilunix.h"
|
||||
|
||||
/* flags for shell_execute */
|
||||
#define EXECUTE_INTERNAL (1 << 0)
|
||||
#define EXECUTE_AS_SHELL (1 << 2)
|
||||
#define EXECUTE_HIDE (1 << 3)
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
@ -40,7 +37,8 @@ void exec_shell (void);
|
||||
void toggle_panels (void);
|
||||
|
||||
/* Handle toggling panels by Ctrl-Z */
|
||||
void suspend_cmd (void);
|
||||
gboolean execute_suspend (const gchar * event_group_name, const gchar * event_name,
|
||||
gpointer init_data, gpointer data);
|
||||
|
||||
/* Execute command on a filename that can be on VFS */
|
||||
void execute_with_vfs_arg (const char *command, const char *filename);
|
||||
@ -49,4 +47,5 @@ void post_exec (void);
|
||||
void pre_exec (void);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__EXECUTE_H */
|
||||
|
@ -8,7 +8,6 @@ libmcfilemanager_la_SOURCES = \
|
||||
chown.c chown.h \
|
||||
cmd.c cmd.h \
|
||||
command.c command.h \
|
||||
complete.c \
|
||||
dir.c dir.h \
|
||||
ext.c ext.h \
|
||||
file.c file.h \
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user