SOURCES: mc-utf8.patch - updated
arekm
arekm at pld-linux.org
Sat Oct 15 14:32:25 CEST 2005
Author: arekm Date: Sat Oct 15 12:32:25 2005 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- updated
---- Files affected:
SOURCES:
mc-utf8.patch (1.1 -> 1.2)
---- Diffs:
================================================================
Index: SOURCES/mc-utf8.patch
diff -u SOURCES/mc-utf8.patch:1.1 SOURCES/mc-utf8.patch:1.2
--- SOURCES/mc-utf8.patch:1.1 Mon Sep 19 23:55:29 2005
+++ SOURCES/mc-utf8.patch Sat Oct 15 14:32:20 2005
@@ -1,2439 +1,1972 @@
---- mc-4.6.1-pre5/edit/editdraw.c.utf8 2005-05-27 16:19:18.000000000 +0200
-+++ mc-4.6.1-pre5/edit/editdraw.c 2005-07-08 11:22:41.891088768 +0200
+--- mc-4.6.1/acinclude.m4.utf8 2005-05-11 20:53:22.000000000 +0200
++++ mc-4.6.1/acinclude.m4 2005-09-29 19:13:29.000000000 +0200
+@@ -769,14 +769,14 @@ AC_DEFUN([MC_WITH_SLANG], [
+ fi
- static void status_string (WEdit * edit, char *s, int w)
- {
-- char byte_str[16];
-+ char byte_str[32];
+ dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks
+- if test x$with_screen = xslang; then
+- :
+- m4_if([$1], strict, ,
+- [AC_CHECK_LIB([slang], [SLsmg_write_nwchars],
+- [AC_MSG_WARN([Rejecting S-Lang with UTF-8 support, \
+-it's not fully supported yet])
+- with_screen=mcslang])])
+- fi
++dnl if test x$with_screen = xslang; then
++dnl :
++dnl m4_if([$1], strict, ,
++dnl [AC_CHECK_LIB([slang], [SLsmg_write_nwchars],
++dnl [AC_MSG_WARN([Rejecting S-Lang with UTF-8 support, \
++dnl it's not fully supported yet])
++dnl with_screen=mcslang])])
++dnl fi
- /*
- * If we are at the end of file, print <EOF>,
-@@ -56,11 +56,16 @@ static void status_string (WEdit * edit,
- * as decimal and as hex.
- */
- if (edit->curs1 < edit->last_byte) {
-- unsigned char cur_byte = edit_get_byte (edit, edit->curs1);
-+ mc_wchar_t cur_byte = edit_get_byte (edit, edit->curs1);
-+#ifndef UTF8
- g_snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X",
- is_printable (cur_byte) ? cur_byte : '.',
-- (int) cur_byte,
-- (unsigned) cur_byte);
-+#else /* UTF8 */
-+ g_snprintf (byte_str, sizeof(byte_str), "%lc %3d 0x%02X",
-+ iswprint(cur_byte) ? cur_byte : '.',
-+#endif /* UTF8 */
-+ (int) cur_byte,
-+ (unsigned) cur_byte);
- } else {
- strcpy (byte_str, "<EOF>");
- }
-@@ -183,11 +188,16 @@ void edit_scroll_screen_over_cursor (WEd
- #define lowlevel_set_color(x) attrset(MY_COLOR_PAIR(color))
- #endif
+ if test x$with_screen = xslang; then
+ AC_DEFINE(HAVE_SYSTEM_SLANG, 1,
+--- mc-4.6.1/src/layout.c.utf8 2005-05-27 16:19:18.000000000 +0200
++++ mc-4.6.1/src/layout.c 2005-09-29 19:13:29.000000000 +0200
+@@ -362,36 +362,36 @@ init_layout (void)
-+struct line_s {
-+ mc_wchar_t ch;
-+ unsigned int style;
-+};
-+
- static void
- print_to_widget (WEdit *edit, long row, int start_col, int start_col_real,
-- long end_col, unsigned int line[])
-+ long end_col, struct line_s line[])
- {
-- unsigned int *p;
-+ struct line_s *p;
+ while (i--) {
+ s_split_direction[i] = _(s_split_direction[i]);
+- l1 = strlen (s_split_direction[i]) + 7;
++ l1 = mbstrlen (s_split_direction[i]) + 7;
+ if (l1 > first_width)
+ first_width = l1;
+ }
- int x = start_col_real + EDIT_TEXT_HORIZONTAL_OFFSET;
- int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET;
-@@ -201,9 +211,9 @@ print_to_widget (WEdit *edit, long row,
- edit_move (x1 + FONT_OFFSET_X, y + FONT_OFFSET_Y);
- p = line;
+ for (i = 0; i <= 8; i++) {
+ check_options[i].text = _(check_options[i].text);
+- l1 = strlen (check_options[i].text) + 7;
++ l1 = mbstrlen (check_options[i].text) + 7;
+ if (l1 > first_width)
+ first_width = l1;
+ }
-- while (*p) {
-+ while (p->ch) {
- int style;
-- int textchar;
-+ mc_wchar_t textchar;
- int color;
+- l1 = strlen (title1) + 1;
++ l1 = mbstrlen (title1) + 1;
+ if (l1 > first_width)
+ first_width = l1;
- if (cols_to_skip) {
-@@ -212,9 +222,9 @@ print_to_widget (WEdit *edit, long row,
- continue;
- }
+- l1 = strlen (title2) + 1;
++ l1 = mbstrlen (title2) + 1;
+ if (l1 > first_width)
+ first_width = l1;
-- style = *p & 0xFF00;
-- textchar = *p & 0xFF;
-- color = *p >> 16;
-+ style = p->style & 0xFF00;
-+ textchar = p->ch;
-+ color = p->style >> 16;
- if (style & MOD_ABNORMAL) {
- /* Non-printable - use black background */
-@@ -228,8 +238,11 @@ print_to_widget (WEdit *edit, long row,
- } else {
- lowlevel_set_color (color);
+- second_width = strlen (title3) + 1;
++ second_width = mbstrlen (title3) + 1;
+ for (i = 0; i < 6; i++) {
+ check_options[i].text = _(check_options[i].text);
+- l1 = strlen (check_options[i].text) + 7;
++ l1 = mbstrlen (check_options[i].text) + 7;
+ if (l1 > second_width)
+ second_width = l1;
}
--
-+#ifdef UTF8
-+ SLsmg_write_char(textchar);
-+#else
- addch (textchar);
-+#endif
- p++;
+ if (console_flag) {
+- l1 = strlen (output_lines_label) + 13;
++ l1 = mbstrlen (output_lines_label) + 13;
+ if (l1 > second_width)
+ second_width = l1;
+ }
+@@ -405,14 +405,14 @@ init_layout (void)
+ *
+ * Now the last thing to do - properly space buttons...
+ */
+- l1 = 11 + strlen (ok_button) /* 14 - all brackets and inner space */
+- +strlen (save_button) /* notice: it is 3 char less because */
+- +strlen (cancel_button); /* of '&' char in button text */
++ l1 = 11 + mbstrlen (ok_button) /* 14 - all brackets and inner space */
++ +mbstrlen (save_button) /* notice: it is 3 char less because */
++ +mbstrlen (cancel_button); /* of '&' char in button text */
+
+ i = (first_width + second_width - l1) / 4;
+ b1 = 5 + i;
+- b2 = b1 + strlen (ok_button) + i + 6;
+- b3 = b2 + strlen (save_button) + i + 4;
++ b2 = b1 + mbstrlen (ok_button) + i + 6;
++ b3 = b2 + mbstrlen (save_button) + i + 4;
+
+ i18n_layt_flag = 1;
}
- }
-@@ -239,11 +252,11 @@ static void
- edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
- long end_col)
- {
-- static unsigned int line[MAX_LINE_LEN];
-- unsigned int *p = line;
-+ struct line_s line[MAX_LINE_LEN];
-+ struct line_s *p = line;
- long m1 = 0, m2 = 0, q, c1, c2;
- int col, start_col_real;
-- unsigned int c;
-+ mc_wint_t c;
- int color;
- int i, book_mark = -1;
+@@ -684,7 +684,7 @@ setup_panels (void)
+ panel_do_cols (0);
+ panel_do_cols (1);
-@@ -265,66 +278,96 @@ edit_draw_this_line (WEdit *edit, long b
+- promptl = strlen (prompt);
++ promptl = mbstrlen (prompt);
- if (row <= edit->total_lines - edit->start_line) {
- while (col <= end_col - edit->start_col) {
-- *p = 0;
-+ p->ch = 0;
-+ p->style = 0;
- if (q == edit->curs1)
-- *p |= MOD_CURSOR;
-+ p->style |= MOD_CURSOR;
- if (q >= m1 && q < m2) {
- if (column_highlighting) {
- int x;
- x = edit_move_forward3 (edit, b, 0, q);
- if (x >= c1 && x < c2)
-- *p |= MOD_MARKED;
-+ p->style |= MOD_MARKED;
- } else
-- *p |= MOD_MARKED;
-+ p->style |= MOD_MARKED;
- }
- if (q == edit->bracket)
-- *p |= MOD_BOLD;
-+ p->style |= MOD_BOLD;
- if (q >= edit->found_start
- && q < edit->found_start + edit->found_len)
-- *p |= MOD_BOLD;
-+ p->style |= MOD_BOLD;
- c = edit_get_byte (edit, q);
- /* we don't use bg for mc - fg contains both */
- if (book_mark == -1) {
- edit_get_syntax_color (edit, q, &color);
-- *p |= color << 16;
-+ p->style |= color << 16;
- } else {
-- *p |= book_mark << 16;
-+ p->style |= book_mark << 16;
- }
- q++;
- switch (c) {
- case '\n':
- col = end_col - edit->start_col + 1; /* quit */
-- *(p++) |= ' ';
-+ p->ch = ' ';
-+ p++;
- break;
- case '\t':
- i = TAB_SIZE - ((int) col % TAB_SIZE);
-- *p |= ' ';
-- c = *(p++) & ~MOD_CURSOR;
-+ p->ch = ' ';
-+ c = p->style & ~MOD_CURSOR;
-+ p++;
- col += i;
-- while (--i)
-- *(p++) = c;
-+ while (--i) {
-+ p->ch = ' '; p->style = c;
-+ p++;
-+ }
- break;
- default:
- c = convert_to_display_c (c);
+ widget_set_size (&the_menubar->widget, 0, 0, 1, COLS);
- /* Caret notation for control characters */
- if (c < 32) {
-- *(p++) = '^' | MOD_ABNORMAL;
-- *(p++) = (c + 0x40) | MOD_ABNORMAL;
-+ p->ch = '^';
-+ p->style = MOD_ABNORMAL;
-+ p++;
-+ p->ch = c + 0x40;
-+ p->style = MOD_ABNORMAL;
- col += 2;
- break;
- }
- if (c == 127) {
-- *(p++) = '^' | MOD_ABNORMAL;
-- *(p++) = '?' | MOD_ABNORMAL;
-+ p->ch = '^';
-+ p->style = MOD_ABNORMAL;
-+ p++;
-+ p->ch = '?';
-+ p->style = MOD_ABNORMAL;
-+ p++;
- col += 2;
- break;
- }
+--- mc-4.6.1/src/option.c.utf8 2005-05-27 16:19:18.000000000 +0200
++++ mc-4.6.1/src/option.c 2005-09-29 19:13:29.000000000 +0200
+@@ -124,12 +124,12 @@ init_configure (void)
+ title2 = _(" Pause after run... ");
+ title3 = _(" Other options ");
-- if (is_printable (c)) {
-- *(p++) |= c;
-+#ifndef UTF8
-+ if (is_printable (c)
-+#else /* UTF8 */
-+ if (iswprint (c)
-+#ifdef __STDC_ISO_10646__
-+ && (c < BINARY_CHAR_OFFSET || c >= (BINARY_CHAR_OFFSET + 256))
-+#endif
-+#endif /* UTF8 */
-+ ) {
-+ p->ch = c;
-+ p++;
-+
-+#ifdef UTF8
-+ i = wcwidth(c);
-+ if (i > 1) {
-+ col += i - 1;
-+ }
-+#endif /* UTF8 */
- } else {
-- *(p++) = '.' | MOD_ABNORMAL;
-+ p->ch = '.';
-+ p->style = MOD_ABNORMAL;
-+ p++;
- }
- col++;
- break;
-@@ -334,7 +377,7 @@ edit_draw_this_line (WEdit *edit, long b
- } else {
- start_col_real = start_col = 0;
- }
-- *p = 0;
-+ p->ch = 0;
-
- print_to_widget (edit, row, start_col, start_col_real, end_col, line);
- }
---- mc-4.6.1-pre5/edit/editkeys.c.utf8 2005-05-27 16:19:18.000000000 +0200
-+++ mc-4.6.1-pre5/edit/editkeys.c 2005-07-08 11:22:41.892088616 +0200
-@@ -162,10 +162,10 @@ static long const common_key_map[] = {
- * 'command' is one of the editor commands from editcmddef.h.
- */
- int
--edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
-+edit_translate_key (WEdit *edit, long x_key, int *cmd, mc_wint_t *ch)
- {
- int command = CK_Insert_Char;
-- int char_for_insertion = -1;
-+ mc_wint_t char_for_insertion = -1;
- int i = 0;
- static const long *key_map;
+- first_width = strlen (title1) + 1;
+- second_width = strlen (title3) + 1;
++ first_width = mbstrlen (title1) + 1;
++ second_width = mbstrlen (title3) + 1;
-@@ -242,9 +242,30 @@ edit_translate_key (WEdit *edit, long x_
- /* an ordinary insertable character */
- if (x_key < 256) {
- int c = convert_from_input_c (x_key);
--
-+#ifdef UTF8
-+ mbstate_t mbs;
-+ int res;
-+ mc_wchar_t wc;
-+
-+ memset (&mbs, 0, sizeof (mbs));
-+
-+ if (edit->charpoint >= MB_CUR_MAX) edit->charpoint = 0;
-+
-+ edit->charbuf[edit->charpoint++] = c;
-+
-+ res = mbrtowc(&wc, (char *)edit->charbuf, edit->charpoint, &mbs);
-+ if (res < 0) {
-+ if (res != -2) edit->charpoint = 0; /* broken multibyte char, skip */
-+ return 0;
-+ }
-+ edit->charpoint = 0;
-+
-+ if (iswprint (wc)) {
-+ char_for_insertion = wc;
-+#else
- if (is_printable (c)) {
- char_for_insertion = c;
-+#endif /* UTF8 */
- goto fin;
+ for (i = 0; check_options[i].text; i++) {
+ check_options[i].text = _(check_options[i].text);
+- l1 = strlen (check_options[i].text) + 7;
++ l1 = mbstrlen (check_options[i].text) + 7;
+ if (i >= OTHER_OPTIONS) {
+ if (l1 > first_width)
+ first_width = l1;
+@@ -142,23 +142,23 @@ init_configure (void)
+ i = PAUSE_OPTIONS;
+ while (i--) {
+ pause_options[i] = _(pause_options[i]);
+- l1 = strlen (pause_options[i]) + 7;
++ l1 = mbstrlen (pause_options[i]) + 7;
+ if (l1 > first_width)
+ first_width = l1;
}
- }
-@@ -285,7 +306,7 @@ edit_translate_key (WEdit *edit, long x_
- *cmd = command;
- *ch = char_for_insertion;
-- if (command == CK_Insert_Char && char_for_insertion == -1) {
-+ if (command == CK_Insert_Char && char_for_insertion == (mc_wint_t)-1) {
- /* unchanged, key has no function here */
- return 0;
- }
---- mc-4.6.1-pre5/edit/editwidget.c.utf8 2005-05-27 16:19:18.000000000 +0200
-+++ mc-4.6.1-pre5/edit/editwidget.c 2005-07-08 11:22:41.893088464 +0200
-@@ -337,7 +337,8 @@ edit_callback (WEdit *e, widget_msg_t ms
+- l1 = strlen (title2) + 1;
++ l1 = mbstrlen (title2) + 1;
+ if (l1 > first_width)
+ first_width = l1;
- case WIDGET_KEY:
- {
-- int cmd, ch;
-+ int cmd;
-+ mc_wint_t ch;
+- l1 = 11 + strlen (ok_button)
+- + strlen (save_button)
+- + strlen (cancel_button);
++ l1 = 11 + mbstrlen (ok_button)
++ + mbstrlen (save_button)
++ + mbstrlen (cancel_button);
- /* first check alt-f, alt-e, alt-s, etc for drop menus */
- if (edit_drop_hotkey_menu (e, parm))
---- mc-4.6.1-pre5/edit/wordproc.c.utf8 2005-05-27 16:19:18.000000000 +0200
-+++ mc-4.6.1-pre5/edit/wordproc.c 2005-07-08 11:22:41.894088312 +0200
-@@ -24,7 +24,12 @@
+ i = (first_width + second_width - l1) / 4;
+ b1 = 5 + i;
+- b2 = b1 + strlen (ok_button) + i + 6;
+- b3 = b2 + strlen (save_button) + i + 4;
++ b2 = b1 + mbstrlen (ok_button) + i + 6;
++ b3 = b2 + mbstrlen (save_button) + i + 4;
- #define tab_width option_tab_spacing
+ i18n_config_flag = 1;
+ }
+--- mc-4.6.1/src/menu.h.utf8 2004-09-18 16:30:59.000000000 +0200
++++ mc-4.6.1/src/menu.h 2005-09-29 19:13:29.000000000 +0200
+@@ -21,6 +21,8 @@ typedef struct Menu {
+ menu_entry *entries;
+ int start_x; /* position relative to menubar start */
+ char *help_node;
++ wchar_t **wentries;
++ wchar_t *wname;
+ } Menu;
-+#ifndef UTF8
- #define NO_FORMAT_CHARS_START "-+*\\,.;:&>"
-+#else /* UTF8 */
-+#define NO_FORMAT_CHARS_START L"-+*\\,.;:&>"
-+#endif /* UTF8 */
+ extern int menubar_visible;
+--- mc-4.6.1/src/menu.c.utf8 2005-05-27 16:19:18.000000000 +0200
++++ mc-4.6.1/src/menu.c 2005-09-29 19:32:14.000000000 +0200
+@@ -20,6 +20,8 @@
+ #include <stdarg.h>
+ #include <sys/types.h>
+ #include <ctype.h>
++#include <wchar.h>
+
- #define FONT_MEAN_WIDTH 1
+ #include "global.h"
+ #include "tty.h"
+ #include "menu.h"
+@@ -50,34 +52,96 @@ create_menu (const char *name, menu_entr
+ {
+ Menu *menu;
+ const char *cp;
++ int wlen = 0;
++ mbstate_t s;
- static long
-@@ -41,14 +46,21 @@ line_start (WEdit *edit, long line)
- p = edit_move_forward (edit, p, line - l, 0);
+ menu = (Menu *) g_malloc (sizeof (*menu));
+ menu->count = count;
+ menu->max_entry_len = 20;
+ menu->entries = entries;
++ menu->name = g_strdup (name);
++ menu_scan_hotkey (menu);
++#ifdef UTF8
++ menu->wentries = NULL;
++ menu->wname = NULL;
++ if (SLsmg_Is_Unicode) {
++ const char *str = menu->name;
++ memset (&s, 0, sizeof (s));
++ wlen = mbsrtowcs (NULL, &str, -1, &s);
++ if (wlen > 0)
++ ++wlen;
++ else {
++ wlen = 0;
++ memset (&s, 0, sizeof (s));
++ }
++ }
++#endif
- p = edit_bol (edit, p);
-+
-+#ifndef UTF8
- while (strchr ("\t ", edit_get_byte (edit, p)))
-+#else /* UTF8 */
-+ while (wcschr (L"\t ", edit_get_byte (edit, p)))
-+#endif /* UTF8 */
-+
- p++;
- return p;
- }
+ if (entries != (menu_entry*) NULL) {
+ register menu_entry* mp;
+ for (mp = entries; count--; mp++) {
+ if (mp->text[0] != '\0') {
++ int len;
+ #ifdef ENABLE_NLS
+ mp->text = _(mp->text);
+ #endif /* ENABLE_NLS */
+ cp = strchr (mp->text,'&');
- static int bad_line_start (WEdit * edit, long p)
- {
-- int c;
-+ mc_wint_t c;
++#ifdef UTF8
++ if (SLsmg_Is_Unicode) {
++ len = mbstrlen(mp->text) + 1;
++ wlen += len;
++ menu->max_entry_len = max (len - 1, menu->max_entry_len);
++ } else
++#endif
++ len = strlen (mp->text);
+
- c = edit_get_byte (edit, p);
- if (c == '.') { /* `...' is acceptable */
- if (edit_get_byte (edit, p + 1) == '.')
-@@ -62,7 +74,13 @@ static int bad_line_start (WEdit * edit,
- return 0; /* `---' is acceptable */
- return 1;
+ if (cp != NULL && *(cp+1) != '\0') {
+ mp->hot_key = tolower (*(cp+1));
+- menu->max_entry_len = max ((int) (strlen (mp->text) - 1),
+- menu->max_entry_len);
++ menu->max_entry_len = max (len - 1, menu->max_entry_len);
+ } else {
+- menu->max_entry_len = max ((int) strlen (mp->text),
+- menu->max_entry_len);
++ menu->max_entry_len = max (len, menu->max_entry_len);
+ }
+ }
+ }
}
-+
-+#ifndef UTF8
- if (strchr (NO_FORMAT_CHARS_START, c))
-+#else /* UTF8 */
-+ if (wcschr (NO_FORMAT_CHARS_START, c))
-+#endif /* UTF8 */
-+
- return 1;
- return 0;
- }
-@@ -115,33 +133,37 @@ end_paragraph (WEdit *edit, int force)
- i - edit->curs_line, 0));
- }
--static unsigned char *
-+static mc_wchar_t *
- get_paragraph (WEdit *edit, long p, long q, int indent, int *size)
- {
-- unsigned char *s, *t;
-+ mc_wchar_t *s, *t;
- #if 0
-- t = g_malloc ((q - p) + 2 * (q - p) / option_word_wrap_line_length +
-- 10);
-+ t = g_malloc (((q - p) + 2 * (q - p) / option_word_wrap_line_length +
-+ 10) * sizeof(mc_wchar_t));
- #else
-- t = g_malloc (2 * (q - p) + 100);
-+ t = g_malloc ((2 * (q - p) + 100) * sizeof(mc_wchar_t));
- #endif
- if (!t)
- return 0;
- for (s = t; p < q; p++, s++) {
- if (indent)
- if (edit_get_byte (edit, p - 1) == '\n')
-+#ifndef UTF8
- while (strchr ("\t ", edit_get_byte (edit, p)))
-+#else /* UTF8 */
-+ while (wcschr (L"\t ", edit_get_byte (edit, p)))
-+#endif /* UTF8 */
- p++;
- *s = edit_get_byte (edit, p);
+- menu->name = g_strdup (name);
++#ifdef UTF8
++ if (wlen) {
++ wchar_t *wp;
++ const char *str;
++ int len;
++
<<Diff was trimmed, longer than 597 lines>>
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/mc-utf8.patch?r1=1.1&r2=1.2&f=u
More information about the pld-cvs-commit
mailing list