mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-20 18:29:19 +03:00
* util.c (load_mc_home_file): New function. Load file from
mc_home, but try localized version of that file first. * util.h: Declare load_mc_home_file(). * help.c (interactive_display): Use load_mc_home_file(). If the first argument is NULL assume mc.hlp. * dlg.c (dialog_handle_key): Use interactive_display() without specifying the help file. * tree.c (tree_copy): Likewise. * cmd.c (help_cmd): Likewise. (get_random_hint): Use load_mc_home_file().
This commit is contained in:
parent
9193c81bd9
commit
58d8979490
@ -1,3 +1,16 @@
|
|||||||
|
2001-06-09 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* util.c (load_mc_home_file): New function. Load file from
|
||||||
|
mc_home, but try localized version of that file first.
|
||||||
|
* util.h: Declare load_mc_home_file().
|
||||||
|
* help.c (interactive_display): Use load_mc_home_file(). If the
|
||||||
|
first argument is NULL assume mc.hlp.
|
||||||
|
* dlg.c (dialog_handle_key): Use interactive_display() without
|
||||||
|
specifying the help file.
|
||||||
|
* tree.c (tree_copy): Likewise.
|
||||||
|
* cmd.c (help_cmd): Likewise.
|
||||||
|
(get_random_hint): Use load_mc_home_file().
|
||||||
|
|
||||||
2001-06-07 Andrew V. Samoilov <sav@bcs.zp.ua>
|
2001-06-07 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||||
|
|
||||||
* charsets.h: Define CHARSETS_INDEX without leading LIBDIR.
|
* charsets.h: Define CHARSETS_INDEX without leading LIBDIR.
|
||||||
|
25
src/cmd.c
25
src/cmd.c
@ -1201,9 +1201,7 @@ void other_symlink_cmd (void)
|
|||||||
|
|
||||||
void help_cmd (void)
|
void help_cmd (void)
|
||||||
{
|
{
|
||||||
char *hlpfile = concat_dir_and_file (mc_home, _("mc.hlp"));
|
interactive_display (NULL, "[main]");
|
||||||
interactive_display (hlpfile, "[main]");
|
|
||||||
g_free (hlpfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_panel_cmd (void)
|
void view_panel_cmd (void)
|
||||||
@ -1269,8 +1267,6 @@ char *guess_message_value (unsigned want_info)
|
|||||||
char *get_random_hint (void)
|
char *get_random_hint (void)
|
||||||
{
|
{
|
||||||
char *data, *result, *eol;
|
char *data, *result, *eol;
|
||||||
char *hintfile_base, *hintfile;
|
|
||||||
char *lang;
|
|
||||||
int len;
|
int len;
|
||||||
int start;
|
int start;
|
||||||
|
|
||||||
@ -1294,24 +1290,7 @@ char *get_random_hint (void)
|
|||||||
last_sec = tv.tv_sec;
|
last_sec = tv.tv_sec;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hintfile_base = concat_dir_and_file (mc_home, MC_HINT);
|
data = load_mc_home_file (MC_HINT, NULL);
|
||||||
lang = guess_message_value (0);
|
|
||||||
|
|
||||||
hintfile = g_strdup_printf ("%s.%s", hintfile_base, lang);
|
|
||||||
data = load_file (hintfile);
|
|
||||||
g_free (hintfile);
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
hintfile = g_strdup_printf ("%s.%.2s", hintfile_base, lang);
|
|
||||||
data = load_file (hintfile);
|
|
||||||
g_free (hintfile);
|
|
||||||
|
|
||||||
if (!data)
|
|
||||||
data = load_file (hintfile_base);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (lang);
|
|
||||||
g_free (hintfile_base);
|
|
||||||
if (!data)
|
if (!data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -630,8 +630,6 @@ void dlg_stop (Dlg_head *h)
|
|||||||
|
|
||||||
static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
|
static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
|
||||||
{
|
{
|
||||||
char *hlpfile;
|
|
||||||
|
|
||||||
switch (d_key){
|
switch (d_key){
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
@ -644,9 +642,7 @@ static INLINE void dialog_handle_key (Dlg_head *h, int d_key)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_F(1):
|
case KEY_F(1):
|
||||||
hlpfile = concat_dir_and_file (mc_home, _("mc.hlp"));
|
interactive_display (NULL, h->help_ctx);
|
||||||
interactive_display (hlpfile, h->help_ctx);
|
|
||||||
g_free (hlpfile);
|
|
||||||
do_refresh ();
|
do_refresh ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
18
src/help.c
18
src/help.c
@ -757,12 +757,24 @@ interactive_display (char *filename, char *node)
|
|||||||
{
|
{
|
||||||
WButtonBar *help_bar;
|
WButtonBar *help_bar;
|
||||||
Widget *md;
|
Widget *md;
|
||||||
|
char *hlpfile = filename;
|
||||||
|
|
||||||
if ((data = load_file (filename)) == 0){
|
if (filename)
|
||||||
|
data = load_file (filename);
|
||||||
|
else
|
||||||
|
data = load_mc_home_file ("mc.hlp", &hlpfile);
|
||||||
|
|
||||||
|
if (data == NULL){
|
||||||
message (1, MSG_ERROR, _(" Can't open file %s \n %s "),
|
message (1, MSG_ERROR, _(" Can't open file %s \n %s "),
|
||||||
filename, unix_error_string (errno));
|
hlpfile, unix_error_string (errno));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!filename)
|
||||||
|
g_free (hlpfile);
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!(main_node = search_string (data, node))){
|
if (!(main_node = search_string (data, node))){
|
||||||
message (1, MSG_ERROR, _(" Can't find node %s in help file "), node);
|
message (1, MSG_ERROR, _(" Can't find node %s in help file "), node);
|
||||||
interactive_display_finish ();
|
interactive_display_finish ();
|
||||||
|
@ -651,9 +651,7 @@ void tree_copy (WTree *tree, char *default_dest)
|
|||||||
|
|
||||||
static void tree_help_cmd (void)
|
static void tree_help_cmd (void)
|
||||||
{
|
{
|
||||||
char *hlpfile = concat_dir_and_file (mc_home, _("mc.hlp"));
|
interactive_display (NULL, "[Directory Tree]");
|
||||||
interactive_display (hlpfile, "[Directory Tree]");
|
|
||||||
g_free (hlpfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tree_copy_cmd (WTree *tree)
|
static int tree_copy_cmd (WTree *tree)
|
||||||
|
39
src/util.c
39
src/util.c
@ -74,6 +74,8 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
#include "user.h" /* expand_format */
|
#include "user.h" /* expand_format */
|
||||||
|
#include "main.h" /* mc_home */
|
||||||
|
#include "cmd.h" /* guess_message_value */
|
||||||
#include "../vfs/vfs.h"
|
#include "../vfs/vfs.h"
|
||||||
|
|
||||||
#ifdef HAVE_CHARSET
|
#ifdef HAVE_CHARSET
|
||||||
@ -607,6 +609,43 @@ char *load_file (char *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *load_mc_home_file (const char *filename, char ** allocated_filename)
|
||||||
|
{
|
||||||
|
char *hintfile_base, *hintfile;
|
||||||
|
char *lang;
|
||||||
|
char *data;
|
||||||
|
|
||||||
|
hintfile_base = concat_dir_and_file (mc_home, filename);
|
||||||
|
lang = guess_message_value (0);
|
||||||
|
|
||||||
|
hintfile = g_strdup_printf ("%s.%s", hintfile_base, lang);
|
||||||
|
data = load_file (hintfile);
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
g_free (hintfile);
|
||||||
|
hintfile = g_strdup_printf ("%s.%.2s", hintfile_base, lang);
|
||||||
|
data = load_file (hintfile);
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
g_free (hintfile);
|
||||||
|
hintfile = hintfile_base;
|
||||||
|
data = load_file (hintfile_base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (lang);
|
||||||
|
|
||||||
|
if (hintfile != hintfile_base)
|
||||||
|
g_free (hintfile_base);
|
||||||
|
|
||||||
|
if (allocated_filename)
|
||||||
|
*allocated_filename = hintfile;
|
||||||
|
else
|
||||||
|
g_free (hintfile);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check strftime() results. Some systems (i.e. Solaris) have different
|
/* Check strftime() results. Some systems (i.e. Solaris) have different
|
||||||
short-month-name sizes for different locales */
|
short-month-name sizes for different locales */
|
||||||
size_t i18n_checktimelength (void)
|
size_t i18n_checktimelength (void)
|
||||||
|
@ -46,6 +46,7 @@ int set_int (char *, char *, int);
|
|||||||
int get_int (char *, char *, int);
|
int get_int (char *, char *, int);
|
||||||
|
|
||||||
char *load_file (char *filename);
|
char *load_file (char *filename);
|
||||||
|
char *load_mc_home_file (const char *filename, char ** allocated_filename);
|
||||||
|
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#ifndef S_ISLNK
|
#ifndef S_ISLNK
|
||||||
|
@ -1825,9 +1825,7 @@ static void do_normal_search (void *xview, char *text)
|
|||||||
/* Real view only */
|
/* Real view only */
|
||||||
static void help_cmd (void)
|
static void help_cmd (void)
|
||||||
{
|
{
|
||||||
char *hlpfile = concat_dir_and_file (mc_home, _("mc.hlp"));
|
interactive_display (NULL, "[Internal File Viewer]");
|
||||||
interactive_display (hlpfile, "[Internal File Viewer]");
|
|
||||||
g_free (hlpfile);
|
|
||||||
/*
|
/*
|
||||||
view_refresh (0);
|
view_refresh (0);
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user