13 #include "selcodepage.h"
18 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
19 int source_codepage
= -1;
20 int display_codepage
= -1;
22 static unsigned char get_hotkey( int n
)
24 return (n
<= 9) ? '0' + n
: 'a' + n
- 10;
27 int select_charset( int current_charset
, int seldisplay
)
29 int i
, menu_lines
= n_codepages
+ 1;
33 create_listbox_window ( ENTRY_LEN
+ 2, menu_lines
,
34 _(" Choose input codepage "),
35 "[Codepages Translation]");
38 LISTBOX_APPEND_TEXT( listbox
, '-', _("- < No translation >"), NULL
);
40 /* insert all the items found */
41 for (i
= 0; i
< n_codepages
; i
++) {
42 struct codepage_desc cpdesc
= codepages
[i
];
44 sprintf( buffer
, "%c %s", get_hotkey(i
), cpdesc
.name
);
45 LISTBOX_APPEND_TEXT( listbox
, get_hotkey(i
), buffer
, NULL
);
49 sprintf( buffer
, "%c %s", get_hotkey(n_codepages
), _("Other 8 bit"));
50 LISTBOX_APPEND_TEXT( listbox
, get_hotkey(n_codepages
), buffer
, NULL
);
53 /* Select the default entry */
56 ( (current_charset
< 0) ? n_codepages
: current_charset
)
58 ( current_charset
+ 1 );
60 listbox_select_by_number( listbox
->list
, i
);
62 i
= run_listbox( listbox
);
64 return (seldisplay
) ? ( (i
>= n_codepages
) ? -1 : i
)
68 /* Helper functions for codepages support */
71 int do_select_codepage(void)
75 message( 1, _(" Warning "),
76 _("Midnight Commander was compiled without iconv support,\n"
77 "so charsets recoding feature is not available!" ));
84 if (display_codepage
> 0) {
85 source_codepage
= select_charset( source_codepage
, 0 );
86 errmsg
= init_translation_table( source_codepage
, display_codepage
);
88 message( 1, MSG_ERROR
, "%s", errmsg
);
92 message( 1, _(" Warning "),
93 _("To use this feature select your codepage in\n"
94 "Setup / Display Bits dialog!\n"
95 "Do not forget to save options." ));
100 #endif /* HAVE_ICONV */
103 #endif /* HAVE_CHARSET */