The R Project SVN R

Rev

Rev 37672 | Rev 38967 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37672 Rev 37676
Line 38... Line 38...
38
#include <windows.h>
38
#include <windows.h>
39
#include <string.h>
39
#include <string.h>
40
#include <ctype.h>
40
#include <ctype.h>
41
#include <wchar.h>
41
#include <wchar.h>
42
#include <limits.h>
42
#include <limits.h>
43
#ifdef SUPPORT_MBCS
-
 
44
#include <R_ext/rlocale.h>
43
#include <R_ext/rlocale.h>
45
#endif
-
 
46
#include "graphapp/ga.h"
44
#include "graphapp/ga.h"
47
#ifdef USE_MDI
45
#ifdef USE_MDI
48
#include "graphapp/stdimg.h"
46
#include "graphapp/stdimg.h"
49
#endif
47
#endif
50
#include "console.h"
48
#include "console.h"
Line 55... Line 53...
55
 
53
 
56
extern char *alloca(size_t);
54
extern char *alloca(size_t);
57
 
55
 
58
extern UImode  CharacterMode;
56
extern UImode  CharacterMode;
59
 
57
 
60
#ifdef SUPPORT_MBCS
-
 
61
#define mbs_init(x) memset(x, 0, sizeof(mbstate_t))
58
#define mbs_init(x) memset(x, 0, sizeof(mbstate_t))
62
 
59
 
63
static mbstate_t mb_st; /* use for char transpose as well */
60
static mbstate_t mb_st; /* use for char transpose as well */
64
 
61
 
65
/* This is input from the keyboard, so we do not do validity checks.
62
/* This is input from the keyboard, so we do not do validity checks.
Line 90... Line 87...
90
	p += used;
87
	p += used;
91
	res += Ri18n_wcwidth(wc);
88
	res += Ri18n_wcwidth(wc);
92
    }
89
    }
93
    return res;
90
    return res;
94
}
91
}
95
#else /* no SUPPORT_MBCS */
-
 
96
int inline mb_char_len(char *buf, int clength)
-
 
97
{
-
 
98
    return 1;
-
 
99
}
-
 
100
#endif
-
 
101
 
92
 
102
void setCURCOL(ConsoleData p)
93
void setCURCOL(ConsoleData p)
103
{
94
{
104
    char *P = LINE(NUMLINES - 1);
95
    char *P = LINE(NUMLINES - 1);
105
    int w0 = 0;
96
    int w0 = 0;
106
 
97
 
107
#ifdef SUPPORT_MBCS
-
 
108
    if(mbcslocale) {
98
    if(mbcslocale) {
109
	int used;
99
	int used;
110
	wchar_t wc;
100
	wchar_t wc;
111
	mbs_init(&mb_st);
101
	mbs_init(&mb_st);
112
	while (P < LINE(NUMLINES - 1) + prompt_len + cur_byte) {
102
	while (P < LINE(NUMLINES - 1) + prompt_len + cur_byte) {
Line 114... Line 104...
114
	    if(used <= 0) break;
104
	    if(used <= 0) break;
115
	    if(wc == L'\r') w0 = 0; else w0 += Ri18n_wcwidth(wc);
105
	    if(wc == L'\r') w0 = 0; else w0 += Ri18n_wcwidth(wc);
116
	    P += used;
106
	    P += used;
117
	}
107
	}
118
    } else
108
    } else
119
#endif
-
 
120
	for (; P < LINE(NUMLINES - 1) + prompt_len + cur_byte; P++)
109
	for (; P < LINE(NUMLINES - 1) + prompt_len + cur_byte; P++)
121
	    if(*P == '\r') w0 = 0; else w0++;
110
	    if(*P == '\r') w0 = 0; else w0++;
122
 
111
 
123
    CURCOL = w0;
112
    CURCOL = w0;
124
}
113
}
Line 249... Line 238...
249
	gabeep();
238
	gabeep();
250
	break;
239
	break;
251
    case '\b':
240
    case '\b':
252
	if (strlen(p->s[p->ns - 1])) {
241
	if (strlen(p->s[p->ns - 1])) {
253
	    /* delete the last character, not the last byte */
242
	    /* delete the last character, not the last byte */
254
#ifdef SUPPORT_MBCS
-
 
255
	    if(mbcslocale) {
243
	    if(mbcslocale) {
256
		char *buf = p->s[p->ns - 1];
244
		char *buf = p->s[p->ns - 1];
257
		int l = mb_char_len(buf, strlen(buf)-1);
245
		int l = mb_char_len(buf, strlen(buf)-1);
258
		p->free -= l;
246
		p->free -= l;
259
		p->av += l;
247
		p->av += l;
260
		
248
		
261
	    } else
249
	    } else {
262
#endif
-
 
263
	    {
-
 
264
		p->free--;
250
		p->free--;
265
		p->av++;
251
		p->av++;
266
	    }
252
	    }
267
	}
253
	}
268
	break;
254
	break;
Line 384... Line 370...
384
			    rgb fgr, rgb bgr, int j, int len, char *s)
370
			    rgb fgr, rgb bgr, int j, int len, char *s)
385
{
371
{
386
    rect  r;
372
    rect  r;
387
    int last;
373
    int last;
388
    char ch, chf, chl;
374
    char ch, chf, chl;
389
#ifdef SUPPORT_MBCS
-
 
390
    int i, used, w0;
375
    int i, used, w0;
391
    char *buff, *P = s, *q;
376
    char *buff, *P = s, *q;
392
    wchar_t wc;
377
    wchar_t wc;
393
    Rboolean leftedge;
378
    Rboolean leftedge;
394
#endif
-
 
395
 
379
 
396
    /* This is right, since columns are of fixed size */
380
    /* This is right, since columns are of fixed size */
397
    r = rect(BORDERX + fch * FW, BORDERY + j * FH, (lch - fch + 1) * FW, FH);
381
    r = rect(BORDERX + fch * FW, BORDERY + j * FH, (lch - fch + 1) * FW, FH);
398
    gfillrect(p->bm, bgr, r);
382
    gfillrect(p->bm, bgr, r);
399
 
383
 
400
    if (len > FC+fch) {
384
    if (len > FC+fch) {
401
	/* Some of the string is visible: */
385
	/* Some of the string is visible: */
402
#ifdef SUPPORT_MBCS
-
 
403
	if(mbcslocale) {
386
	if(mbcslocale) {
404
	    q = buff = alloca(strlen(s) + 1); /* overkill */
387
	    q = buff = alloca(strlen(s) + 1); /* overkill */
405
 
388
 
406
	    leftedge = FC && (fch == 0);
389
	    leftedge = FC && (fch == 0);
407
	    if(leftedge) fch++;
390
	    if(leftedge) fch++;
Line 432... Line 415...
432
		used = mbrtowc(NULL, P, MB_CUR_MAX, &mb_st);
415
		used = mbrtowc(NULL, P, MB_CUR_MAX, &mb_st);
433
		for(j = 0; j < used; j++) *q++ = *P++;
416
		for(j = 0; j < used; j++) *q++ = *P++;
434
	    }
417
	    }
435
	    *q = '\0';
418
	    *q = '\0';
436
	    gdrawstr(p->bm, p->f, fgr, pt(r.x, r.y), buff);
419
	    gdrawstr(p->bm, p->f, fgr, pt(r.x, r.y), buff);
437
	} else
420
	} else {
438
#endif
-
 
439
	{
-
 
440
	    /* we don't know the string length, so modify it in place */
421
	    /* we don't know the string length, so modify it in place */
441
	    if (FC && (fch == 0)) {chf = s[FC]; s[FC] = '$';} else chf = '\0';
422
	    if (FC && (fch == 0)) {chf = s[FC]; s[FC] = '$';} else chf = '\0';
442
	    if ((len > FC+COLS) && (lch == COLS - 1)) {
423
	    if ((len > FC+COLS) && (lch == COLS - 1)) {
443
		chl = s[FC+lch]; s[FC+lch] = '$';
424
		chl = s[FC+lch]; s[FC+lch] = '$';
444
	    }
425
	    }
Line 460... Line 441...
460
static int writeline(ConsoleData p, int i, int j)
441
static int writeline(ConsoleData p, int i, int j)
461
{
442
{
462
    char *s, *stmp, *p0;
443
    char *s, *stmp, *p0;
463
    int   insel, len, col1, d;
444
    int   insel, len, col1, d;
464
    int   c1, c2, c3, x0, y0, x1, y1;
445
    int   c1, c2, c3, x0, y0, x1, y1;
465
#ifdef SUPPORT_MBCS
-
 
466
    rect r;
446
    rect r;
467
#endif
-
 
468
 
447
 
469
    if ((i < 0) || (i >= NUMLINES)) return 0;
448
    if ((i < 0) || (i >= NUMLINES)) return 0;
470
    stmp = s = LINE(i);
449
    stmp = s = LINE(i);
471
#ifdef SUPPORT_MBCS
-
 
472
    if(mbcslocale)
450
    if(mbcslocale)
473
	len = mbswidth(stmp);
451
	len = mbswidth(stmp);
474
    else
452
    else
475
#endif
-
 
476
	len = strlen(stmp);
453
	len = strlen(stmp);
477
    /* If there is a \r in the line, we need to preprocess it */
454
    /* If there is a \r in the line, we need to preprocess it */
478
    if((p0 = strchr(s, '\r'))) {
455
    if((p0 = strchr(s, '\r'))) {
479
	int l, l1;
456
	int l, l1;
480
	stmp = LINE(i);
457
	stmp = LINE(i);
Line 513... Line 490...
513
    } else
490
    } else
514
	WLHELPER(0, col1, p->fg, p->bg);
491
	WLHELPER(0, col1, p->fg, p->bg);
515
    /* This is the cursor, and it may need to be variable-width */
492
    /* This is the cursor, and it may need to be variable-width */
516
    if ((p->r >= 0) && (CURCOL >= FC) && (CURCOL < FC + COLS) &&
493
    if ((p->r >= 0) && (CURCOL >= FC) && (CURCOL < FC + COLS) &&
517
	(i == NUMLINES - 1)) {
494
	(i == NUMLINES - 1)) {
518
#ifdef SUPPORT_MBCS
-
 
519
	if(mbcslocale) { /* determine the width of the current char */
495
	if(mbcslocale) { /* determine the width of the current char */
520
	    int w0, used = 0, ii;
496
	    int w0, used = 0, ii;
521
	    wchar_t wc;
497
	    wchar_t wc;
522
	    char *P = s, nn[10];
498
	    char *P = s, nn[10];
523
	    mbs_init(&mb_st);
499
	    mbs_init(&mb_st);
Line 535... Line 511...
535
	    gfillrect(p->bm, p->ufg, r);
511
	    gfillrect(p->bm, p->ufg, r);
536
	    for(ii = 0; ii < used; ii++) nn[ii] = P[ii];
512
	    for(ii = 0; ii < used; ii++) nn[ii] = P[ii];
537
	    nn[used] = '\0';
513
	    nn[used] = '\0';
538
	    gdrawstr(p->bm, p->f, p->bg, pt(r.x, r.y), nn);
514
	    gdrawstr(p->bm, p->f, p->bg, pt(r.x, r.y), nn);
539
	} else
515
	} else
540
#endif
-
 
541
	    WLHELPER(CURCOL - FC, CURCOL - FC, p->bg, p->ufg);
516
	    WLHELPER(CURCOL - FC, CURCOL - FC, p->bg, p->ufg);
542
    }
517
    }
543
    if (insel != 0) return len;
518
    if (insel != 0) return len;
544
    c1 = (p->my0 < p->my1);
519
    c1 = (p->my0 < p->my1);
545
    c2 = (p->my0 == p->my1);
520
    c2 = (p->my0 == p->my1);
Line 551... Line 526...
551
	x0 = p->mx1; y0 = p->my1;
526
	x0 = p->mx1; y0 = p->my1;
552
	x1 = p->mx0; y1 = p->my0;
527
	x1 = p->mx0; y1 = p->my0;
553
    }
528
    }
554
    if (i == y0) {
529
    if (i == y0) {
555
	if (FC + COLS < x0) return len;
530
	if (FC + COLS < x0) return len;
556
#ifdef SUPPORT_MBCS
-
 
557
	if(mbcslocale) {
531
	if(mbcslocale) {
558
	    int w0, used = 0, w1=1;
532
	    int w0, used = 0, w1=1;
559
	    wchar_t wc;
533
	    wchar_t wc;
560
	    char *P = s;
534
	    char *P = s;
561
	    mbs_init(&mb_st);
535
	    mbs_init(&mb_st);
Line 566... Line 540...
566
		w0 += w1;
540
		w0 += w1;
567
		P += used;
541
		P += used;
568
	    }
542
	    }
569
	    if(w0 > x0) x0 = w0 - w1;
543
	    if(w0 > x0) x0 = w0 - w1;
570
	}
544
	}
571
#endif
-
 
572
	c1 = (x0 > FC) ? (x0 - FC) : 0;
545
	c1 = (x0 > FC) ? (x0 - FC) : 0;
573
    } else
546
    } else
574
	c1 = 0;
547
	c1 = 0;
575
    if (i == y1) {
548
    if (i == y1) {
576
	if (FC > x1) return len;
549
	if (FC > x1) return len;
577
#ifdef SUPPORT_MBCS
-
 
578
	if(mbcslocale) {
550
	if(mbcslocale) {
579
	    int w0, used = 0, wl = 1;
551
	    int w0, used = 0, wl = 1;
580
	    wchar_t wc;
552
	    wchar_t wc;
581
	    char *P = s;
553
	    char *P = s;
582
	    mbs_init(&mb_st);
554
	    mbs_init(&mb_st);
Line 587... Line 559...
587
		w0 += wl;
559
		w0 += wl;
588
		P += used;
560
		P += used;
589
	    }
561
	    }
590
	    x1 = w0-1;
562
	    x1 = w0-1;
591
	}
563
	}
592
#endif
-
 
593
	c2 = (x1 > FC + COLS) ? (COLS - 1) : (x1 - FC);
564
	c2 = (x1 > FC + COLS) ? (COLS - 1) : (x1 - FC);
594
    } else
565
    } else
595
	c2 = COLS - 1;
566
	c2 = COLS - 1;
596
    WLHELPER(c1, c2, White, DarkBlue);
567
    WLHELPER(c1, c2, White, DarkBlue);
597
    return len;
568
    return len;
Line 674... Line 645...
674
 
645
 
675
    ll = (NUMLINES < ROWS) ? NUMLINES : ROWS;
646
    ll = (NUMLINES < ROWS) ? NUMLINES : ROWS;
676
    if (newcol > 0) {
647
    if (newcol > 0) {
677
	for (i = 0, ml = 0; i < ll; i++) {
648
	for (i = 0, ml = 0; i < ll; i++) {
678
	    /* <FIXME> this should really take \r into account */
649
	    /* <FIXME> this should really take \r into account */
679
#ifdef SUPPORT_MBCS
-
 
680
	    if(mbcslocale)
650
	    if(mbcslocale)
681
		li = mbswidth(LINE(NEWFV + i));
651
		li = mbswidth(LINE(NEWFV + i));
682
	    else
652
	    else
683
#endif
-
 
684
		li = strlen(LINE(NEWFV + i));
653
		li = strlen(LINE(NEWFV + i));
685
	    ml = (ml < li) ? li : ml;
654
	    ml = (ml < li) ? li : ml;
686
	}
655
	}
687
	ml = ml - COLS;
656
	ml = ml - COLS;
688
	ml = 5*(ml/5 + 1);
657
	ml = 5*(ml/5 + 1);
Line 960... Line 929...
960
 
929
 
961
    HGLOBAL hglb;
930
    HGLOBAL hglb;
962
    int ll, i, j;
931
    int ll, i, j;
963
    char *s;
932
    char *s;
964
 
933
 
965
#ifdef SUPPORT_MBCS
-
 
966
    int w0 = 0 /* -Wall */, used=0, x00, x11=100000;
934
    int w0 = 0 /* -Wall */, used=0, x00, x11=100000;
967
    wchar_t wc;
935
    wchar_t wc;
968
    char *P;
936
    char *P;
969
    if(mbcslocale) {
937
    if(mbcslocale) {
970
 
938
 
Line 985... Line 953...
985
		w0 += Ri18n_wcwidth(wc);
953
		w0 += Ri18n_wcwidth(wc);
986
	    }
954
	    }
987
	    if(w0 < x11) ll += 2;  /* \r\n */
955
	    if(w0 < x11) ll += 2;  /* \r\n */
988
	    i++;
956
	    i++;
989
	}
957
	}
990
    } else
958
    } else {
991
#endif
-
 
992
    {
-
 
993
	i = y0; j = x0; ll = 1; /* terminator */
959
	i = y0; j = x0; ll = 1; /* terminator */
994
	while ((i < y1) || ((i == y1) && (j <= x1))) {
960
	while ((i < y1) || ((i == y1) && (j <= x1))) {
995
	    if (LINE(i)[j]) {
961
	    if (LINE(i)[j]) {
996
		ll++;
962
		ll++;
997
		j++;
963
		j++;
Line 1010... Line 976...
1010
    }
976
    }
1011
    if (!(s = (char *)GlobalLock(hglb))){
977
    if (!(s = (char *)GlobalLock(hglb))){
1012
        R_ShowMessage(G_("Insufficient memory: text not copied to the clipboard"));
978
        R_ShowMessage(G_("Insufficient memory: text not copied to the clipboard"));
1013
        return;
979
        return;
1014
    }
980
    }
1015
#ifdef SUPPORT_MBCS
-
 
1016
    if(mbcslocale) {
981
    if(mbcslocale) {
1017
	i = y0; x00 = x0; x11=100000;
982
	i = y0; x00 = x0; x11=100000;
1018
	while (i <= y1) {
983
	while (i <= y1) {
1019
	    P = LINE(i);
984
	    P = LINE(i);
1020
	    mbs_init(&mb_st);
985
	    mbs_init(&mb_st);
Line 1030... Line 995...
1030
		for(j = 0; j < used; j++) *s++ = *P++;
995
		for(j = 0; j < used; j++) *s++ = *P++;
1031
	    }
996
	    }
1032
	    if(w0 < x11) *s++ = '\r'; *s++ = '\n';
997
	    if(w0 < x11) *s++ = '\r'; *s++ = '\n';
1033
	    i++;
998
	    i++;
1034
	}
999
	}
1035
    } else
1000
    } else {
1036
#endif
-
 
1037
    {
-
 
1038
	i = y0; j = x0;
1001
	i = y0; j = x0;
1039
	while ((i < y1) || ((i == y1) && (j <= x1))) {
1002
	while ((i < y1) || ((i == y1) && (j <= x1))) {
1040
	    char ch = LINE(i)[j];
1003
	    char ch = LINE(i)[j];
1041
	    if (ch) {
1004
	    if (ch) {
1042
		*s++ = ch;
1005
		*s++ = ch;
Line 1400... Line 1363...
1400
    /* print the prompt */
1363
    /* print the prompt */
1401
    xbufadds(p->lbuf, prompt, 1);
1364
    xbufadds(p->lbuf, prompt, 1);
1402
    if (!xbufmakeroom(p->lbuf, len + 1)) return 1;
1365
    if (!xbufmakeroom(p->lbuf, len + 1)) return 1;
1403
    P = aLine = LINE(NUMLINES - 1);
1366
    P = aLine = LINE(NUMLINES - 1);
1404
    prompt_len = strlen(aLine);
1367
    prompt_len = strlen(aLine);
1405
#ifdef SUPPORT_MBCS
-
 
1406
    if(mbcslocale) {
1368
    if(mbcslocale) {
1407
	int used;
1369
	int used;
1408
	wchar_t wc;
1370
	wchar_t wc;
1409
	mbs_init(&mb_st);
1371
	mbs_init(&mb_st);
1410
	while (P < aLine + pre_prompt_len) {
1372
	while (P < aLine + pre_prompt_len) {
Line 1413... Line 1375...
1413
	    if(wc == L'\r') w0 = 0; else w0 += Ri18n_wcwidth(wc);
1375
	    if(wc == L'\r') w0 = 0; else w0 += Ri18n_wcwidth(wc);
1414
	    P += used;
1376
	    P += used;
1415
	}
1377
	}
1416
	USER(NUMLINES - 1) = w0;
1378
	USER(NUMLINES - 1) = w0;
1417
	prompt_wid = w0 + mbswidth(prompt);
1379
	prompt_wid = w0 + mbswidth(prompt);
1418
    } else
1380
    } else {
1419
#endif
-
 
1420
    {
-
 
1421
	for (; P < aLine + pre_prompt_len; P++)
1381
	for (; P < aLine + pre_prompt_len; P++)
1422
	    if(*P == '\r') w0 = 0; else w0++;
1382
	    if(*P == '\r') w0 = 0; else w0++;
1423
	USER(NUMLINES - 1) = w0;
1383
	USER(NUMLINES - 1) = w0;
1424
	prompt_wid = w0 + strlen(prompt);
1384
	prompt_wid = w0 + strlen(prompt);
1425
    }
1385
    }
Line 1456... Line 1416...
1456
	    USER(NUMLINES - 1) = prompt_wid;
1416
	    USER(NUMLINES - 1) = prompt_wid;
1457
	    p->needredraw = 1;
1417
	    p->needredraw = 1;
1458
	}
1418
	}
1459
        if(chtype && (max_byte < len - 2)) { /* not a control char */
1419
        if(chtype && (max_byte < len - 2)) { /* not a control char */
1460
	    int i;
1420
	    int i;
1461
#ifdef SUPPORT_MBCS
-
 
1462
	    if(mbcslocale) {
1421
	    if(mbcslocale) {
1463
		char s[9];
1422
		char s[9];
1464
		int clen;
1423
		int clen;
1465
		int res;
1424
		int res;
1466
		wchar_t wc;
1425
		wchar_t wc;
Line 1484... Line 1443...
1484
		for(i = 0;  i< clen; i++) 
1443
		for(i = 0;  i< clen; i++) 
1485
		    cur_line[cur_byte + i] = s[i];
1444
		    cur_line[cur_byte + i] = s[i];
1486
		max_byte += clen;
1445
		max_byte += clen;
1487
		cur_byte += clen; 
1446
		cur_byte += clen; 
1488
	    } else {
1447
	    } else {
1489
#endif /* SUPPORT_MBCS */
-
 
1490
		if(!p->overwrite) {
1448
		if(!p->overwrite) {
1491
		    for(i = max_byte; i > cur_byte; i--) {
1449
		    for(i = max_byte; i > cur_byte; i--) {
1492
			cur_line[i] = cur_line[i - 1];
1450
			cur_line[i] = cur_line[i - 1];
1493
		    }
1451
		    }
1494
		}
1452
		}
Line 1496... Line 1454...
1496
		if(!p->overwrite || cur_byte == max_byte) {
1454
		if(!p->overwrite || cur_byte == max_byte) {
1497
		    max_byte += 1;
1455
		    max_byte += 1;
1498
		    cur_line[max_byte] = '\0';
1456
		    cur_line[max_byte] = '\0';
1499
		}
1457
		}
1500
		cur_byte++;
1458
		cur_byte++;
1501
#ifdef SUPPORT_MBCS /* SUPPORT_MBCS*/
-
 
1502
	    }
1459
	    }
1503
#endif /* */
-
 
1504
	} else { /* a control char */
1460
	} else { /* a control char */
1505
	    /* do normal editing commands */
1461
	    /* do normal editing commands */
1506
	    int i;
1462
	    int i;
1507
	    switch(cur_char) {
1463
	    switch(cur_char) {
1508
	    case BEGINLINE:
1464
	    case BEGINLINE:
Line 1559... Line 1515...
1559
		if(cur_byte < 1) break;
1515
		if(cur_byte < 1) break;
1560
		if(cur_byte >= max_byte) break;
1516
		if(cur_byte >= max_byte) break;
1561
		{
1517
		{
1562
		    int j, l_len = mb_char_len(cur_line, cur_byte-1), r_len;
1518
		    int j, l_len = mb_char_len(cur_line, cur_byte-1), r_len;
1563
		    /* we should not reset the state here */
1519
		    /* we should not reset the state here */
1564
#ifdef SUPPORT_MBCS
-
 
1565
		    if(mbcslocale)
1520
		    if(mbcslocale)
1566
			r_len = mbrtowc(NULL, cur_line+cur_byte, MB_CUR_MAX,
1521
			r_len = mbrtowc(NULL, cur_line+cur_byte, MB_CUR_MAX,
1567
					&mb_st);
1522
					&mb_st);
1568
		    else
1523
		    else
1569
#endif
-
 
1570
			r_len = 1;
1524
			r_len = 1;
1571
		    for (i = 0; i < r_len; i++)
1525
		    for (i = 0; i < r_len; i++)
1572
			for(j = 0; j < l_len; j++) {
1526
			for(j = 0; j < l_len; j++) {
1573
			    cur_char = cur_line[cur_byte+i-j];
1527
			    cur_char = cur_line[cur_byte+i-j];
1574
			    cur_line[cur_byte+i-j] = cur_line[cur_byte+i-j-1];
1528
			    cur_line[cur_byte+i-j] = cur_line[cur_byte+i-j-1];