SOURCES: mc-utf8-look-and-feel.patch (NEW), mc-utf8.patch, mc-utf8...

arekm arekm at pld-linux.org
Wed Jan 18 22:56:54 CET 2006


Author: arekm                        Date: Wed Jan 18 21:56:53 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- update utf8 patches

---- Files affected:
SOURCES:
   mc-utf8-look-and-feel.patch (NONE -> 1.1)  (NEW), mc-utf8.patch (1.2 -> 1.3) , mc-utf8-view.patch (1.1 -> NONE)  (REMOVED)

---- Diffs:

================================================================
Index: SOURCES/mc-utf8-look-and-feel.patch
diff -u /dev/null SOURCES/mc-utf8-look-and-feel.patch:1.1
--- /dev/null	Wed Jan 18 22:56:53 2006
+++ SOURCES/mc-utf8-look-and-feel.patch	Wed Jan 18 22:56:48 2006
@@ -0,0 +1,204 @@
+--- mc-4.6.1a/src/main.c.laf	2005-11-24 16:55:06.000000000 +0100
++++ mc-4.6.1a/src/main.c	2005-11-24 16:56:27.000000000 +0100
+@@ -270,6 +270,9 @@ int midnight_shutdown = 0;
+ /* The user's shell */
+ const char *shell = NULL;
+ 
++/* Is the LANG UTF-8 ? */
++gboolean is_utf8 = FALSE;
++
+ /* The xterm title */
+ char *xterm_title_str = NULL;
+ 
+@@ -2167,6 +2170,16 @@ main (int argc, char *argv[])
+     /* if on, it displays the information that files have been moved to ~/.mc */
+     int show_change_notice = 0;
+ 
++    /* Check whether we have UTF-8 locale */
++    char *lang = getenv("LANG");
++    size_t len = 0;
++    
++    if ( lang )
++    	len = strlen(lang);
++    
++    if ( len >= 5 && !strcasecmp(&lang[len-5],"UTF-8") )
++	is_utf8 = TRUE;
++
+     /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */
+     setlocale (LC_ALL, "");
+     bindtextdomain ("mc", LOCALEDIR);
+--- mc-4.6.1a/src/main.h.laf	2005-11-24 16:55:06.000000000 +0100
++++ mc-4.6.1a/src/main.h	2005-11-24 16:55:06.000000000 +0100
+@@ -67,6 +67,7 @@ extern int alternate_plus_minus;
+ extern int only_leading_plus_minus;
+ extern int output_starts_shell;
+ extern int midnight_shutdown;
++extern gboolean is_utf8;
+ extern char *xterm_title_str;
+ extern char cmd_buf [512];
+ extern const char *shell;
+--- mc-4.6.1a/src/widget.c.laf	2005-11-24 16:55:06.000000000 +0100
++++ mc-4.6.1a/src/widget.c	2005-11-24 16:55:06.000000000 +0100
+@@ -1948,52 +1948,86 @@ input_new (int y, int x, int color, int 
+     return in;
+ }
+ 
+-
+-/* Listbox widget */
+-
+-/* Should draw the scrollbar, but currently draws only
+- * indications that there is more information
+- */
+-static int listbox_cdiff (WLEntry *s, WLEntry *e);
++/* Vertical scrollbar widget */
+ 
+-static void
+-listbox_drawscroll (WListbox *l)
++void
++vscrollbar (Widget widget, int height, int width, int tpad, int bpad,
++            int selected, int count, gboolean color)
+ {
+     int line;
+-    int i, top;
+-    int max_line = l->height-1;
+-    
++    int i;
++
+     /* Are we at the top? */
+-    widget_move (&l->widget, 0, l->width);
+-    if (l->list == l->top)
+-	one_vline ();
++    widget_move (&widget, tpad, width);
++#ifndef UTF8
++    if (!selected)
++        one_vline ();
+     else
+-	addch ('^');
++        addch ('^');
++#else
++    if (color) attrset (MARKED_COLOR);
++    if (is_utf8)
++	SLsmg_write_string("â–˛");
++    else
++        addch ('^');
++    if (color) attrset (NORMAL_COLOR);
++#endif
+ 
+     /* Are we at the bottom? */
+-    widget_move (&l->widget, max_line, l->width);
+-    top = listbox_cdiff (l->list, l->top);
+-    if ((top + l->height == l->count) || l->height >= l->count)
+-	one_vline ();
++    widget_move (&widget, height-1-bpad, width);
++#ifndef UTF8
++    if (selected == count-1)
++        one_vline ();
++    else
++        addch ('v');
++#else
++    if (color) attrset (MARKED_COLOR);
++    if (is_utf8)
++	SLsmg_write_string("â–ź");
+     else
+-	addch ('v');
++	addch('v');
++    if (color) attrset (NORMAL_COLOR);
++#endif
+ 
+     /* Now draw the nice relative pointer */
+-    if (l->count)
+-	line = 1+ ((l->pos * (l->height-2)) / l->count);
++    if (count > 1)
++        line = tpad + 1 + ((selected * (height-3-tpad-bpad)) / (count-1));
+     else
+-	line = 0;
+-    
+-    for (i = 1; i < max_line; i++){
+-	widget_move (&l->widget, i, l->width);
+-	if (i != line)
+-	    one_vline ();
+-	else
+-	    addch ('*');
++        line = 0;
++
++    for (i = tpad + 1; i < height-1-bpad; i++){
++        widget_move (&widget, i, width);
++        if (i != line)
++#ifndef UTF8
++            one_vline ();
++        else
++            addch ('*');
++#else
++            if (is_utf8)
++		SLsmg_write_string("â–’");
++	    else
++		one_vline();
++        else {
++            if (color) attrset (MARKED_COLOR);
++            if (is_utf8)
++		SLsmg_write_string("●");
++	    else
++		addch('*');
++            if (color) attrset (NORMAL_COLOR);
++        }
++#endif
+     }
+ }
+-    
+-static void
++
++
++/* Listbox widget */
++
++/* Should draw the scrollbar, but currently draws only
++ * indications that there is more information
++ */
++static int listbox_cdiff (WLEntry *s, WLEntry *e);
++
++void
+ listbox_draw (WListbox *l, int focused)
+ {
+     WLEntry *e;
+@@ -2034,7 +2068,7 @@ listbox_draw (WListbox *l, int focused)
+     if (!l->scrollbar)
+ 	return;
+     attrset (normalc);
+-    listbox_drawscroll (l);
++    vscrollbar (l->widget, l->height, l->width, 0, 0, l->pos, l->count, FALSE);
+ }
+ 
+ /* Returns the number of items between s and e,
+--- mc-4.6.1a/src/screen.c.laf	2005-11-24 16:55:06.000000000 +0100
++++ mc-4.6.1a/src/screen.c	2005-11-24 16:55:06.000000000 +0100
+@@ -888,6 +888,9 @@ show_dir (WPanel *panel)
+     }
+ #endif				/* HAVE_SLANG */
+ 
++    vscrollbar (panel->widget, panel->widget.lines, panel->widget.cols-1, 2, 2,
++		panel->selected, panel->count, TRUE);
++
+     if (panel->active)
+ 	attrset (REVERSE_COLOR);
+ 
+@@ -1504,7 +1507,7 @@ use_display_format (WPanel *panel, const
+     panel->dirty = 1;
+ 
+     /* Status needn't to be split */
+-    usable_columns = ((panel->widget.cols-2)/((isstatus)
++    usable_columns = ((panel->widget.cols-3)/((isstatus)
+ 					      ? 1
+ 					      : (panel->split+1))) - (!isstatus && panel->split);
+ 
+--- mc-4.6.1a/src/widget.h.laf	2005-11-24 16:55:06.000000000 +0100
++++ mc-4.6.1a/src/widget.h	2005-11-24 16:55:06.000000000 +0100
+@@ -170,6 +170,10 @@ void button_set_text (WButton *b, const 
+ /* Listbox manager */
+ WLEntry *listbox_get_data (WListbox *l, int pos);
+ 
++/* Vertical scrollbar */
++void vscrollbar (Widget widget, int height, int width, int tpad, int bpad,
++        	int selected, int count, gboolean color);
++
+ /* search text int listbox entries */
+ WLEntry *listbox_search_text (WListbox *l, const char *text);
+ void listbox_select_entry (WListbox *l, WLEntry *dest);

================================================================
Index: SOURCES/mc-utf8.patch
diff -u SOURCES/mc-utf8.patch:1.2 SOURCES/mc-utf8.patch:1.3
--- SOURCES/mc-utf8.patch:1.2	Sat Oct 15 14:32:20 2005
+++ SOURCES/mc-utf8.patch	Wed Jan 18 22:56:48 2006
@@ -1,2706 +1,2401 @@
---- 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
- 
-     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 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)
+--- 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
  
- 	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;
- 	}
+ static void status_string (WEdit * edit, char *s, int w)
+ {
+-    char byte_str[16];
++    char byte_str[32];
  
- 	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;
- 	}
+     /*
+      * 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
  
--	l1 = strlen (title1) + 1;
-+	l1 = mbstrlen (title1) + 1;
- 	if (l1 > first_width)
- 	    first_width = l1;
++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;
  
--	l1 = strlen (title2) + 1;
-+	l1 = mbstrlen (title2) + 1;
- 	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;
  
+-    while (*p) {
++    while (p->ch) {
+ 	int style;
+-	int textchar;
++	mc_wchar_t textchar;
+ 	int 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;
- 	}
- 	if (console_flag) {
--	    l1 = strlen (output_lines_label) + 13;
-+	    l1 = mbstrlen (output_lines_label) + 13;
- 	    if (l1 > second_width)
- 		second_width = l1;
+ 	if (cols_to_skip) {
+@@ -212,9 +222,9 @@ print_to_widget (WEdit *edit, long row, 
+ 	    continue;
  	}
-@@ -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;
+-	style = *p & 0xFF00;
+-	textchar = *p & 0xFF;
+-	color = *p >> 16;
++	style = p->style & 0xFF00;
++	textchar = p->ch;
++	color = p->style >> 16;
  
- 	i18n_layt_flag = 1;
+ 	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);
+ 	}
+-
++#ifdef UTF8
++	SLsmg_write_char(textchar);
++#else
+ 	addch (textchar);
++#endif
+ 	p++;
      }
-@@ -684,7 +684,7 @@ setup_panels (void)
-     panel_do_cols (0);
-     panel_do_cols (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;
  
--    promptl = strlen (prompt);
-+    promptl = mbstrlen (prompt);
+@@ -265,66 +278,96 @@ edit_draw_this_line (WEdit *edit, long b
  
-     widget_set_size (&the_menubar->widget, 0, 0, 1, COLS);
+ 	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);
  
---- 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 ");
+ 		    /* 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;
+ 		    }
  
--	first_width = strlen (title1) + 1;
--	second_width = strlen (title3) + 1;
-+	first_width = mbstrlen (title1) + 1;
-+	second_width = mbstrlen (title3) + 1;
+-		    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;
  
- 	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;
+     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;
+ 
+@@ -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)) {
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/mc-utf8.patch?r1=1.2&r2=1.3&f=u



More information about the pld-cvs-commit mailing list