2009-09-02 03:07:50 +04:00
|
|
|
/*
|
|
|
|
File highlight plugin.
|
|
|
|
Interface functions. get color pair index for highlighted file.
|
|
|
|
|
2024-01-01 09:46:17 +03:00
|
|
|
Copyright (C) 2009-2024
|
2014-02-12 10:33:10 +04:00
|
|
|
Free Software Foundation, Inc.
|
2009-09-02 03:07:50 +04:00
|
|
|
|
|
|
|
Written by:
|
|
|
|
Slava Zanko <slavazanko@gmail.com>, 2009.
|
|
|
|
|
|
|
|
This file is part of the Midnight Commander.
|
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
The Midnight Commander is free software: you can redistribute it
|
2009-09-02 03:07:50 +04:00
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
2011-10-15 14:56:47 +04:00
|
|
|
published by the Free Software Foundation, either version 3 of the License,
|
|
|
|
or (at your option) any later version.
|
2009-09-02 03:07:50 +04:00
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
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.
|
2009-09-02 03:07:50 +04:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2011-10-15 14:56:47 +04:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-09-02 03:07:50 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2010-01-20 18:11:52 +03:00
|
|
|
#include "lib/global.h"
|
2010-01-21 16:06:15 +03:00
|
|
|
#include "lib/skin.h"
|
2010-11-11 16:58:29 +03:00
|
|
|
#include "lib/util.h" /* is_exe() */
|
2010-01-21 16:06:15 +03:00
|
|
|
#include "lib/filehighlight.h"
|
2009-09-02 03:07:50 +04:00
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
/*** global variables ****************************************************************************/
|
|
|
|
|
|
|
|
/*** file scope macro definitions ****************************************************************/
|
|
|
|
|
|
|
|
/*** file scope type declarations ****************************************************************/
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/*** forward declarations (file scope functions) *************************************************/
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
/*** file scope variables ************************************************************************/
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2009-09-02 03:07:50 +04:00
|
|
|
/*** file scope functions ************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2010-11-08 21:50:15 +03:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*inline functions */
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_file (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2015-04-05 09:02:37 +03:00
|
|
|
#if HAVE_S_ISREG == 0
|
2009-10-27 14:56:49 +03:00
|
|
|
(void) fe;
|
|
|
|
#endif
|
2009-09-02 03:07:50 +04:00
|
|
|
return S_ISREG (fe->st.st_mode);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_file_exec (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
|
|
|
return is_exe (fe->st.st_mode);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_dir (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2015-04-05 09:02:37 +03:00
|
|
|
#if HAVE_S_ISDIR == 0
|
2009-10-27 14:56:49 +03:00
|
|
|
(void) fe;
|
|
|
|
#endif
|
2009-09-02 03:07:50 +04:00
|
|
|
return S_ISDIR (fe->st.st_mode);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_link (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2015-04-05 09:02:37 +03:00
|
|
|
#if HAVE_S_ISLNK == 0
|
2009-10-27 14:56:49 +03:00
|
|
|
(void) fe;
|
|
|
|
#endif
|
2009-09-02 03:07:50 +04:00
|
|
|
return S_ISLNK (fe->st.st_mode);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2011-02-04 14:40:50 +03:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_hlink (const file_entry_t *fe)
|
2011-02-04 14:40:50 +03:00
|
|
|
{
|
|
|
|
return (fe->st.st_nlink > 1);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_link_to_dir (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2023-04-16 12:06:20 +03:00
|
|
|
return mc_fhl_is_link (fe) && fe->f.link_to_dir != 0;
|
2009-09-02 03:07:50 +04:00
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_stale_link (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2023-04-16 12:06:20 +03:00
|
|
|
return mc_fhl_is_link (fe) ? (fe->f.stale_link != 0) : !mc_fhl_is_file (fe);
|
2009-09-02 03:07:50 +04:00
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_device_char (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2015-04-05 09:02:37 +03:00
|
|
|
#if HAVE_S_ISCHR == 0
|
2009-10-27 14:56:49 +03:00
|
|
|
(void) fe;
|
|
|
|
#endif
|
2009-09-02 03:07:50 +04:00
|
|
|
return S_ISCHR (fe->st.st_mode);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_device_block (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2015-04-05 09:02:37 +03:00
|
|
|
#if HAVE_S_ISBLK == 0
|
2009-10-27 14:56:49 +03:00
|
|
|
(void) fe;
|
|
|
|
#endif
|
2009-09-02 03:07:50 +04:00
|
|
|
return S_ISBLK (fe->st.st_mode);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_special_socket (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2015-04-05 09:02:37 +03:00
|
|
|
#if HAVE_S_ISSOCK == 0
|
2009-10-27 14:56:49 +03:00
|
|
|
(void) fe;
|
|
|
|
#endif
|
2009-09-02 03:07:50 +04:00
|
|
|
return S_ISSOCK (fe->st.st_mode);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_special_fifo (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2015-04-05 09:02:37 +03:00
|
|
|
#if HAVE_S_ISFIFO == 0
|
2009-10-27 14:56:49 +03:00
|
|
|
(void) fe;
|
|
|
|
#endif
|
2009-09-02 03:07:50 +04:00
|
|
|
return S_ISFIFO (fe->st.st_mode);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_special_door (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2015-04-05 09:02:37 +03:00
|
|
|
#if HAVE_S_ISDOOR == 0
|
2009-10-27 14:56:49 +03:00
|
|
|
(void) fe;
|
|
|
|
#endif
|
2009-09-02 03:07:50 +04:00
|
|
|
return S_ISDOOR (fe->st.st_mode);
|
|
|
|
}
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
inline static gboolean
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_is_special (const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
|
|
|
return
|
2010-11-08 13:21:45 +03:00
|
|
|
(mc_fhl_is_special_socket (fe) || mc_fhl_is_special_fifo (fe)
|
|
|
|
|| mc_fhl_is_special_door (fe));
|
2009-09-02 03:07:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_get_color_filetype (const mc_fhl_filter_t *mc_filter, const mc_fhl_t *fhl,
|
|
|
|
const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
|
|
|
gboolean my_color = FALSE;
|
2021-12-04 07:34:07 +03:00
|
|
|
|
2009-09-30 03:09:54 +04:00
|
|
|
(void) fhl;
|
2009-09-02 03:07:50 +04:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
switch (mc_filter->file_type)
|
|
|
|
{
|
2009-09-02 03:07:50 +04:00
|
|
|
case MC_FLHGH_FTYPE_T_FILE:
|
|
|
|
if (mc_fhl_is_file (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_FILE_EXE:
|
2021-12-04 07:47:20 +03:00
|
|
|
if (mc_fhl_is_file (fe) && mc_fhl_is_file_exec (fe))
|
2009-09-02 03:07:50 +04:00
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_DIR:
|
|
|
|
if (mc_fhl_is_dir (fe) || mc_fhl_is_link_to_dir (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_LINK_DIR:
|
|
|
|
if (mc_fhl_is_link_to_dir (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_LINK:
|
2021-12-04 07:47:20 +03:00
|
|
|
if (mc_fhl_is_link (fe) || mc_fhl_is_hlink (fe))
|
2009-09-02 03:07:50 +04:00
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_HARDLINK:
|
2011-02-04 14:40:50 +03:00
|
|
|
if (mc_fhl_is_hlink (fe))
|
2009-09-02 03:07:50 +04:00
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_SYMLINK:
|
|
|
|
if (mc_fhl_is_link (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_STALE_LINK:
|
|
|
|
if (mc_fhl_is_stale_link (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_DEVICE:
|
2021-12-04 07:47:20 +03:00
|
|
|
if (mc_fhl_is_device_char (fe) || mc_fhl_is_device_block (fe))
|
2009-09-02 03:07:50 +04:00
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_DEVICE_BLOCK:
|
|
|
|
if (mc_fhl_is_device_block (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_DEVICE_CHAR:
|
|
|
|
if (mc_fhl_is_device_char (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_SPECIAL:
|
|
|
|
if (mc_fhl_is_special (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_SPECIAL_SOCKET:
|
|
|
|
if (mc_fhl_is_special_socket (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_SPECIAL_FIFO:
|
|
|
|
if (mc_fhl_is_special_fifo (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_FTYPE_T_SPECIAL_DOOR:
|
|
|
|
if (mc_fhl_is_special_door (fe))
|
|
|
|
my_color = TRUE;
|
|
|
|
break;
|
2015-04-19 13:57:38 +03:00
|
|
|
default:
|
|
|
|
break;
|
2009-09-02 03:07:50 +04:00
|
|
|
}
|
|
|
|
|
2021-12-04 07:47:20 +03:00
|
|
|
return my_color ? mc_filter->color_pair_index : -1;
|
2009-09-02 03:07:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_get_color_regexp (const mc_fhl_filter_t *mc_filter, const mc_fhl_t *fhl,
|
|
|
|
const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
2009-09-30 03:09:54 +04:00
|
|
|
(void) fhl;
|
2021-12-04 07:34:07 +03:00
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
if (mc_filter->search_condition == NULL)
|
|
|
|
return -1;
|
|
|
|
|
2021-02-23 21:19:59 +03:00
|
|
|
if (mc_search_run (mc_filter->search_condition, fe->fname->str, 0, fe->fname->len, NULL))
|
2009-09-02 03:07:50 +04:00
|
|
|
return mc_filter->color_pair_index;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/*** public functions ****************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int
|
2024-06-01 21:12:14 +03:00
|
|
|
mc_fhl_get_color (const mc_fhl_t *fhl, const file_entry_t *fe)
|
2009-09-02 03:07:50 +04:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (fhl == NULL)
|
|
|
|
return NORMAL_COLOR;
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
for (i = 0; i < fhl->filters->len; i++)
|
|
|
|
{
|
2013-10-15 10:34:04 +04:00
|
|
|
mc_fhl_filter_t *mc_filter;
|
|
|
|
|
2009-09-02 03:07:50 +04:00
|
|
|
mc_filter = (mc_fhl_filter_t *) g_ptr_array_index (fhl->filters, i);
|
2010-11-08 13:21:45 +03:00
|
|
|
switch (mc_filter->type)
|
|
|
|
{
|
2009-09-02 03:07:50 +04:00
|
|
|
case MC_FLHGH_T_FTYPE:
|
|
|
|
ret = mc_fhl_get_color_filetype (mc_filter, fhl, fe);
|
|
|
|
if (ret > 0)
|
|
|
|
return -ret;
|
|
|
|
break;
|
|
|
|
case MC_FLHGH_T_EXT:
|
|
|
|
case MC_FLHGH_T_FREGEXP:
|
|
|
|
ret = mc_fhl_get_color_regexp (mc_filter, fhl, fe);
|
|
|
|
if (ret > 0)
|
|
|
|
return -ret;
|
|
|
|
break;
|
2015-04-19 13:57:38 +03:00
|
|
|
default:
|
|
|
|
break;
|
2009-09-02 03:07:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NORMAL_COLOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|