mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
* boxes.c [HAVE_CHARSET]: New charset selection dialog.
* main.c [HAVE_CHARSET]: Don't use eight_bit_clean and full_eight_bits. Use source_codepage and display_codepage to deduce the terminal 8-bitness. * main.h [HAVE_CHARSET]: Change to match main.c. * setup.c [HAVE_CHARSET]: Implement saving and loading charset settings. * util.c (is_printable) [HAVE_CHARSET]: Use charset settings. * view.c [HAVE_CHARSET]: Implement charset support. From Walery Studennikov <hqsoftware@mail.ru>.
This commit is contained in:
parent
d34b0fde60
commit
cd1fd56223
@ -1,5 +1,16 @@
|
||||
2001-06-05 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* boxes.c [HAVE_CHARSET]: New charset selection dialog.
|
||||
* main.c [HAVE_CHARSET]: Don't use eight_bit_clean and
|
||||
full_eight_bits. Use source_codepage and display_codepage to
|
||||
deduce the terminal 8-bitness.
|
||||
* main.h [HAVE_CHARSET]: Change to match main.c.
|
||||
* setup.c [HAVE_CHARSET]: Implement saving and loading charset
|
||||
settings.
|
||||
* util.c (is_printable) [HAVE_CHARSET]: Use charset settings.
|
||||
* view.c [HAVE_CHARSET]: Implement charset support.
|
||||
From Walery Studennikov <hqsoftware@mail.ru>.
|
||||
|
||||
* selcodepage.c (do_select_codepage): New function.
|
||||
* selcodepage.h: Declare it.
|
||||
From Walery Studennikov <hqsoftware@mail.ru>.
|
||||
|
130
src/boxes.c
130
src/boxes.c
@ -49,6 +49,11 @@
|
||||
#include "background.h"
|
||||
#include "x.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "charsets.h"
|
||||
#include "selcodepage.h"
|
||||
#endif
|
||||
|
||||
static int DISPLAY_X = 45, DISPLAY_Y = 14;
|
||||
|
||||
static Dlg_head *dd;
|
||||
@ -446,6 +451,9 @@ confirm_box ()
|
||||
#define DISPY 11
|
||||
#define DISPX 46
|
||||
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
|
||||
static int new_mode;
|
||||
static int new_meta;
|
||||
|
||||
@ -532,6 +540,128 @@ display_bits_box ()
|
||||
use_8th_bit_as_meta = !new_meta;
|
||||
}
|
||||
|
||||
|
||||
#else /* HAVE_CHARSET */
|
||||
|
||||
|
||||
Dlg_head *dbits_dlg;
|
||||
|
||||
static char* dbits_title = N_(" Display bits ");
|
||||
|
||||
#ifndef HAVE_X
|
||||
static void dbits_refresh()
|
||||
{
|
||||
attrset( COLOR_NORMAL );
|
||||
dlg_erase( dbits_dlg );
|
||||
|
||||
draw_box( dbits_dlg, 1, 2, dbits_dlg->lines - 2, dbits_dlg->cols - 4 );
|
||||
|
||||
attrset( COLOR_HOT_NORMAL );
|
||||
dlg_move( dbits_dlg, 1, (dbits_dlg->cols - strlen(dbits_title)) / 2 );
|
||||
addstr( dbits_title );
|
||||
}
|
||||
#endif /* HAVE_X */
|
||||
|
||||
static int dbits_callback( Dlg_head * h, int Par, int Msg )
|
||||
{
|
||||
switch (Msg) {
|
||||
#ifndef HAVE_X
|
||||
case DLG_DRAW:
|
||||
dbits_refresh();
|
||||
break;
|
||||
#endif /* HAVE_X */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int new_display_codepage;
|
||||
|
||||
WLabel *cplabel;
|
||||
WCheck *inpcheck;
|
||||
|
||||
static int sel_charset_button( int action, void *param )
|
||||
{
|
||||
char *cpname, buf[64];
|
||||
new_display_codepage = select_charset( new_display_codepage, 1 );
|
||||
cpname = (new_display_codepage < 0)
|
||||
? "Other 8 bit"
|
||||
: codepages[ new_display_codepage ].name;
|
||||
sprintf( buf, "%-27s", cpname ); // avoid strange bug with label repainting
|
||||
label_set_text( cplabel, buf );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void init_disp_bits_box()
|
||||
{
|
||||
char *cpname;
|
||||
|
||||
do_refresh();
|
||||
|
||||
dbits_dlg = create_dlg( 0, 0, DISPY, DISPX, dialog_colors,
|
||||
dbits_callback, "[Display bits]", "Display bits",
|
||||
DLG_CENTER );
|
||||
x_set_dialog_title( dbits_dlg, dbits_title );
|
||||
|
||||
add_widget( dbits_dlg,
|
||||
label_new( 3, 4, _("Input / display codepage:"), NULL));
|
||||
|
||||
cpname = (new_display_codepage < 0)
|
||||
? "Other 8 bit"
|
||||
: codepages[ new_display_codepage ].name;
|
||||
cplabel = label_new( 4, 4, cpname, NULL);
|
||||
add_widget( dbits_dlg, cplabel );
|
||||
|
||||
add_widget( dbits_dlg,
|
||||
button_new( DISPY - 3, DISPX / 2 + 3, B_CANCEL,
|
||||
NORMAL_BUTTON, _("&Cancel"), 0, 0, NULL ) );
|
||||
add_widget( dbits_dlg,
|
||||
button_new( DISPY - 3, 7, B_ENTER,
|
||||
NORMAL_BUTTON, _("&Ok"), 0, 0, NULL ) );
|
||||
|
||||
inpcheck = check_new( 6, 4, !use_8th_bit_as_meta,
|
||||
_("F&ull 8 bits input"), NULL );
|
||||
add_widget( dbits_dlg, inpcheck );
|
||||
|
||||
add_widget( dbits_dlg,
|
||||
button_new( 4, DISPX - 8 - strlen(_("&Select")) , B_USER,
|
||||
NORMAL_BUTTON, _("&Select"),
|
||||
sel_charset_button, 0, NULL ) );
|
||||
}
|
||||
|
||||
void display_bits_box()
|
||||
{
|
||||
new_display_codepage = display_codepage;
|
||||
|
||||
#ifndef HAVE_X
|
||||
application_keypad_mode ();
|
||||
#endif
|
||||
init_disp_bits_box();
|
||||
|
||||
run_dlg( dbits_dlg );
|
||||
|
||||
if (dbits_dlg->ret_value == B_ENTER) {
|
||||
char *errmsg;
|
||||
display_codepage = new_display_codepage;
|
||||
errmsg = init_translation_table( source_codepage, display_codepage );
|
||||
if (errmsg)
|
||||
message( 1, _(" Error "), errmsg );
|
||||
#ifndef HAVE_X
|
||||
#ifndef HAVE_SLANG
|
||||
meta( stdscr, display_codepage != 0 );
|
||||
#else
|
||||
SLsmg_Display_Eight_Bit
|
||||
= (display_codepage != 0 && display_codepage != 1) ? 128 : 160;
|
||||
#endif
|
||||
#endif
|
||||
use_8th_bit_as_meta = ! (inpcheck->state & C_BOOL);
|
||||
}
|
||||
destroy_dlg( dbits_dlg );
|
||||
repaint_screen();
|
||||
}
|
||||
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
|
||||
#define TREE_Y 20
|
||||
#define TREE_X 60
|
||||
|
||||
|
10
src/main.c
10
src/main.c
@ -213,12 +213,18 @@ int pause_after_run = pause_on_dumb_terminals;
|
||||
/* It true saves the setup when quitting */
|
||||
int auto_save_setup = 1;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
/* For charset translation */
|
||||
int source_codepage = -1;
|
||||
int display_codepage = -1;
|
||||
#else
|
||||
/* If true, be eight bit clean */
|
||||
int eight_bit_clean = 1;
|
||||
|
||||
/* If true, then display chars 0-255, else iso-8859-1,
|
||||
requires eight_bit_clean */
|
||||
int full_eight_bits = 1;
|
||||
#endif
|
||||
|
||||
/* If true use the internal viewer */
|
||||
int use_internal_view = 1;
|
||||
@ -1851,6 +1857,10 @@ static void
|
||||
setup_pre ()
|
||||
{
|
||||
/* Call all the inits */
|
||||
#ifdef HAVE_CHARSET
|
||||
int full_eight_bits = (display_codepage != 0 && display_codepage != 1);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SLANG
|
||||
meta (stdscr, eight_bit_clean);
|
||||
#else
|
||||
|
@ -67,8 +67,15 @@ extern int mou_auto_repeat;
|
||||
extern char *other_dir;
|
||||
extern int mouse_move_pages;
|
||||
extern int mouse_move_pages_viewer;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
extern int source_codepage;
|
||||
extern int display_codepage;
|
||||
#else
|
||||
extern int eight_bit_clean;
|
||||
extern int full_eight_bits;
|
||||
#endif
|
||||
|
||||
extern int confirm_view_dir;
|
||||
extern int fast_refresh;
|
||||
extern int navigate_with_arrows;
|
||||
|
34
src/setup.c
34
src/setup.c
@ -54,6 +54,11 @@
|
||||
# define PORT_LIST_MODE_DEFAULT "full"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "dialog.h"
|
||||
#include "charsets.h"
|
||||
#endif
|
||||
|
||||
#include "../vfs/vfs.h"
|
||||
#ifdef USE_NETCODE
|
||||
# include "../vfs/ftpfs.h"
|
||||
@ -194,8 +199,10 @@ static const struct {
|
||||
#ifndef HAVE_X
|
||||
{ "mouse_repeat_rate", &mou_auto_repeat },
|
||||
{ "double_click_speed", &double_click_speed },
|
||||
#ifndef HAVE_CHARSET
|
||||
{ "eight_bit_clean", &eight_bit_clean },
|
||||
{ "full_eight_bits", &full_eight_bits },
|
||||
#endif
|
||||
{ "use_8th_bit_as_meta", &use_8th_bit_as_meta },
|
||||
#endif
|
||||
{ "confirm_view_dir", &confirm_view_dir },
|
||||
@ -441,6 +448,12 @@ save_setup (void)
|
||||
ftpfs_proxy_host, profile);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
save_string( "Misc", "display_codepage",
|
||||
get_codepage_id( display_codepage ), profile_name );
|
||||
#endif
|
||||
|
||||
g_free (profile);
|
||||
saving_setup = 0;
|
||||
}
|
||||
@ -640,6 +653,27 @@ load_setup (void)
|
||||
ftpfs_init_passwd ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if ( load_codepages_list() <= 0 ) {
|
||||
char errmsg[256];
|
||||
sprintf( errmsg, "Can't load %s", CHARSETS_INDEX );
|
||||
message( 1, MSG_ERROR, errmsg );
|
||||
} else {
|
||||
char cpname[128];
|
||||
load_string( "Misc", "display_codepage", "",
|
||||
cpname, sizeof(cpname) );
|
||||
if ( cpname[0] != '\0' ) {
|
||||
char *errmsg;
|
||||
|
||||
display_codepage = get_codepage_index( cpname );
|
||||
init_printable_table( display_codepage );
|
||||
errmsg = init_translation_table( source_codepage, display_codepage );
|
||||
if (errmsg)
|
||||
message( 1, _(" Error "), errmsg );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_VFS
|
||||
|
18
src/util.c
18
src/util.c
@ -76,6 +76,10 @@
|
||||
#include "user.h" /* expand_format */
|
||||
#include "../vfs/vfs.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "charsets.h"
|
||||
#endif
|
||||
|
||||
/* "$Id$" */
|
||||
|
||||
char app_text [] = "Midnight-Commander";
|
||||
@ -101,14 +105,27 @@ int is_printable (int c)
|
||||
};
|
||||
|
||||
extern int xterm_flag;
|
||||
#ifdef HAVE_CHARSET
|
||||
extern int display_codepage;
|
||||
#else
|
||||
extern int eight_bit_clean;
|
||||
extern int full_eight_bits;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GNOME
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
c &= 0xff;
|
||||
#ifdef HAVE_CHARSET
|
||||
if (display_codepage < 0) {
|
||||
if (xterm_flag)
|
||||
return xterm_printable[c];
|
||||
else
|
||||
return (c > 31 && c != 127 && c != 155);
|
||||
} else
|
||||
return printable[ c ];
|
||||
#else
|
||||
if (eight_bit_clean){
|
||||
if (full_eight_bits){
|
||||
if (xterm_flag)
|
||||
@ -119,6 +136,7 @@ int is_printable (int c)
|
||||
return ((c >31 && c < 127) || c >= 160);
|
||||
} else
|
||||
return (c > 31 && c < 127);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Returns the message dimensions (lines and columns) */
|
||||
|
38
src/view.c
38
src/view.c
@ -73,6 +73,10 @@
|
||||
#define WANT_WIDGETS
|
||||
#include "view.h"
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "charsets.h"
|
||||
#endif
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
@ -938,6 +942,10 @@ display (WView *view)
|
||||
/* Print the corresponding ascii character */
|
||||
view_gotoyx (view, row, text_start + bytes);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
c = conv_displ[ c ];
|
||||
#endif
|
||||
|
||||
if (!is_printable (c))
|
||||
c = '.';
|
||||
switch (boldflag) {
|
||||
@ -1017,6 +1025,11 @@ display (WView *view)
|
||||
&& col < width-view->start_col)
|
||||
{
|
||||
view_gotoyx (view, row, col+view->start_col);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
c = conv_displ[ c ];
|
||||
#endif
|
||||
|
||||
if (!is_printable (c))
|
||||
c = '.';
|
||||
|
||||
@ -1983,6 +1996,12 @@ normal_search (WView *view, int direction)
|
||||
char *exp = "";
|
||||
|
||||
exp = old ? old : exp;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if ( strlen(exp) > 0 )
|
||||
convert_to_display( exp );
|
||||
#endif
|
||||
|
||||
exp = input_dialog (_(" Search "), _(" Enter search string:"), exp);
|
||||
if ((!exp)){
|
||||
return;
|
||||
@ -1995,6 +2014,10 @@ normal_search (WView *view, int direction)
|
||||
g_free (old);
|
||||
old = exp;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
convert_from_input( exp );
|
||||
#endif
|
||||
|
||||
view->direction = direction;
|
||||
do_normal_search (view, exp);
|
||||
view->last_search = do_normal_search;
|
||||
@ -2136,6 +2159,13 @@ view_handle_key (WView *view, int c)
|
||||
|
||||
set_monitor (view, off);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (c >= 128 && c <= 255) {
|
||||
int ch = conv_input[ c & 0xFF ];
|
||||
c = (c & 0xFF00) | ch;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (view->hex_mode) {
|
||||
switch (c) {
|
||||
case 0x09: /* Tab key */
|
||||
@ -2305,6 +2335,14 @@ view_handle_key (WView *view, int c)
|
||||
view->view_quit = 1;
|
||||
return 1;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
case XCTRL('t'):
|
||||
do_select_codepage();
|
||||
view->dirty++;
|
||||
view_update( view, TRUE );
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
}
|
||||
if (c >= '0' && c <= '9')
|
||||
view->marker = c - '0';
|
||||
|
Loading…
Reference in New Issue
Block a user