Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 47675 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-8 / +434 lines)
Line  Link Here
0
-- slang-1.4.4.orig/src/slinclud.h
0
++ slang-1.4.4/src/slinclud.h
Lines 23-26 Link Here
23
# include <memory.h>
23
# include <memory.h>
24
#endif
24
#endif
25
#define UTF8 1
26
27
#ifdef UTF8
28
#include <wchar.h>
29
#include <limits.h>
30
#endif /* UTF8 */
31
32
25
#endif				       /* _SLANG_INCLUDE_H_ */
33
#endif				       /* _SLANG_INCLUDE_H_ */
26
-- slang-1.4.4.orig/src/slang.h
34
++ slang-1.4.4/src/slang.h
Lines 1239-1248 Link Here
1239
extern int SLtt_Msdos_Cheap_Video;
1239
extern int SLtt_Msdos_Cheap_Video;
1240
#endif
1240
#endif
1241
#define UTF8 1
1242
1243
#ifdef UTF8
1244
typedef int SLsmg_Char_Type;
1245
#define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFFFFFF)
1246
#define SLSMG_EXTRACT_COLOR(x) (((x)>>24)&0xFF)
1247
#define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(wchar_t)(ch))|((color)<<24))
1248
#define SLSMG_NOCHAR 1
1249
#else
1241
typedef unsigned short SLsmg_Char_Type;
1250
typedef unsigned short SLsmg_Char_Type;
1242
#define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFF)
1251
#define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFF)
1243
#define SLSMG_EXTRACT_COLOR(x) (((x)>>8)&0xFF)
1252
#define SLSMG_EXTRACT_COLOR(x) (((x)>>8)&0xFF)
1244
#define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(unsigned char)(ch))|((color)<<8))
1253
#define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(unsigned char)(ch))|((color)<<8))
1254
#endif /* UTF8 */
1245
1255
1246
extern int SLtt_flush_output (void);
1256
extern int SLtt_flush_output (void);
1247
extern void SLtt_set_scroll_region(int, int);
1257
extern void SLtt_set_scroll_region(int, int);
Lines 1334-1340 Link Here
1334
1342
1335
/*{{{ SLsmg Screen Management Functions */
1343
/*{{{ SLsmg Screen Management Functions */
1336
1344
1345
#ifdef UTF8
1346
extern void SLsmg_fill_region (int, int, unsigned int, unsigned int, wchar_t);
1347
#else
1337
extern void SLsmg_fill_region (int, int, unsigned int, unsigned int, unsigned char);
1348
extern void SLsmg_fill_region (int, int, unsigned int, unsigned int, unsigned char);
1349
#endif /* UTF8 */
1338
extern void SLsmg_set_char_set (int);
1350
extern void SLsmg_set_char_set (int);
1339
#ifndef IBMPC_SYSTEM
1351
#ifndef IBMPC_SYSTEM
1340
extern int SLsmg_Scroll_Hash_Border;
1352
extern int SLsmg_Scroll_Hash_Border;
Lines 1351-1357 Link Here
1351
extern void SLsmg_vprintf (char *, va_list);
1363
extern void SLsmg_vprintf (char *, va_list);
1352
extern void SLsmg_write_string (char *);
1364
extern void SLsmg_write_string (char *);
1353
extern void SLsmg_write_nstring (char *, unsigned int);
1365
extern void SLsmg_write_nstring (char *, unsigned int);
1366
#ifdef UTF8
1367
extern void SLsmg_write_char (wchar_t);
1368
extern void SLsmg_write_nwchars (wchar_t *, unsigned int);
1369
#else
1354
extern void SLsmg_write_char (char);
1370
extern void SLsmg_write_char (char);
1371
#endif /* UTF8 */
1355
extern void SLsmg_write_nchars (char *, unsigned int);
1372
extern void SLsmg_write_nchars (char *, unsigned int);
1356
extern void SLsmg_write_wrapped_string (char *, int, int, unsigned int, unsigned int, int);
1373
extern void SLsmg_write_wrapped_string (char *, int, int, unsigned int, unsigned int, int);
1357
extern void SLsmg_cls (void);
1374
extern void SLsmg_cls (void);
1358
-- slang-1.4.4.orig/src/slcurses.c
1375
++ slang-1.4.4/src/slcurses.c
Lines 440-459 Link Here
440
440
441
static int do_newline (SLcurses_Window_Type *w)
441
static int do_newline (SLcurses_Window_Type *w)
442
{
442
{
443
   w->_curx = 0;
443
   /* w->_curx = 0; */
444
   w->_cury += 1;
444
   w->_cury += 1;
445
   if (w->_cury >= w->scroll_max)
445
   if (w->_cury >= w->scroll_max)
446
     {
446
     {
447
	w->_cury = w->scroll_max - 1;
447
	w->_cury = w->scroll_max - 1;
448
	if (w->scroll_ok)
448
	if (w->scroll_ok) {
449
	  w->_curx = 0;
449
	  SLcurses_wscrl (w, 1);
450
	  SLcurses_wscrl (w, 1);
451
	}
450
     }
452
     }
453
   else
454
     w->_curx = 0;
455
   
456
   return 0;
457
}
458
459
#ifdef UTF8
460
static int SLcurses_waddch1 (SLcurses_Window_Type *win,
461
			     wchar_t ch, int color)
462
{
463
   SLsmg_Char_Type *b, *bmin, *bmax, *c;
464
   int k;
465
466
   if (win == NULL) return -1;
467
468
   if (win->_cury >= win->nrows)
469
     {
470
	/* Curses seems to move current postion to top of window. */
471
	win->_cury = win->_curx = 0;
472
	return -1;
473
     }
474
475
   win->modified = 1;
476
477
   if (ch < ' ')
478
     {
479
	if (ch == '\n')
480
	  {
481
	     SLcurses_wclrtoeol (win);
482
	     return do_newline (win);
483
	  }
484
485
	if (ch == '\r')
486
	  {
487
	     win->_curx = 0;
488
	     return 0;
489
	  }
490
491
	if (ch == '\b')
492
	  {
493
	     if (win->_curx > 0)
494
	       win->_curx--;
495
496
	     return 0;
497
	  }
498
499
	/* HACK HACK!!!! */
500
	if (ch == '\t') ch = ' ';
501
     }
502
503
   k = wcwidth(ch);
504
505
   if (!k)
506
     return 0; /* ignore combining characters for now */
507
508
   if (k > win->ncols)
509
     return 0; /* character wider than window */
510
511
   if (win->_curx + k > win->ncols) {
512
     if (win->_curx < win->ncols)
513
       SLcurses_wclrtoeol(win);
514
     do_newline (win);
515
   }
516
517
   bmin = win->lines[win->_cury];
518
   b = bmin + win->_curx;
519
   bmax = bmin + win->ncols;
520
521
   /* Remove overwritten chars to left */
522
   if (*b == SLSMG_NOCHAR) {
523
     for (c = b - 1; c >= bmin && *c == SLSMG_NOCHAR; c--)
524
       *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
525
     if (c >= bmin)
526
       *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
527
   }
528
529
   *b = SLSMG_BUILD_CHAR(ch,color);
530
   win->_curx += k;
531
   while (--k > 0)
532
     *++b = SLSMG_NOCHAR;
533
534
   /* Remove overwritten chars to right */
535
   for (c = b + 1; c < bmax && *c == SLSMG_NOCHAR; c++)
536
     *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
451
537
452
   return 0;
538
   return 0;
453
}
539
}
454
540
455
int SLcurses_waddch (SLcurses_Window_Type *win, SLtt_Char_Type attr)
541
int SLcurses_waddch (SLcurses_Window_Type *win, SLtt_Char_Type attr)
456
{
542
{
543
   SLsmg_Char_Type ch, color;
544
545
   if (win == NULL) return -1;
546
547
   ch = SLSMG_EXTRACT_CHAR(attr);
548
549
   if (attr == ch)
550
     color = win->color;
551
   else
552
     {
553
	/* hack to pick up the default color for graphics chars */
554
	if (((attr & A_COLOR) == 0) && ((attr & A_ALTCHARSET) != 0))
555
	  {
556
	     /* FIXME: priority=medium: Use SLSMG_?? instead of << */
557
	     attr |= win->color << 8;
558
	  }
559
	color = map_attr_to_object (attr);
560
     }
561
562
   return SLcurses_waddch1 (win, ch, color);
563
}
564
#else
565
int SLcurses_waddch (SLcurses_Window_Type *win, SLtt_Char_Type attr)
566
{
457
   SLsmg_Char_Type *b, ch;
567
   SLsmg_Char_Type *b, ch;
458
   SLsmg_Char_Type color;
568
   SLsmg_Char_Type color;
459
569
Lines 518-523 Link Here
518
628
519
   return 0;
629
   return 0;
520
}
630
}
631
#endif /* UTF8 */
521
632
522
int SLcurses_wnoutrefresh (SLcurses_Window_Type *w)
633
int SLcurses_wnoutrefresh (SLcurses_Window_Type *w)
523
{
634
{
Lines 577-583 Link Here
577
688
578
int SLcurses_wclrtoeol (SLcurses_Window_Type *w)
689
int SLcurses_wclrtoeol (SLcurses_Window_Type *w)
579
{
690
{
691
#ifdef UTF8
692
   SLsmg_Char_Type *b, *bmin, *bmax, *c;
693
#else
580
   SLsmg_Char_Type *b, *bmax;
694
   SLsmg_Char_Type *b, *bmax;
695
#endif /* UTF8 */
581
   SLsmg_Char_Type blank;
696
   SLsmg_Char_Type blank;
582
697
583
   if (w == NULL) return -1;
698
   if (w == NULL) return -1;
Lines 588-596 Link Here
588
703
589
   blank = SLSMG_BUILD_CHAR(' ',w->color);
704
   blank = SLSMG_BUILD_CHAR(' ',w->color);
590
705
706
#ifdef UTF8
707
   bmin = w->lines[w->_cury];
708
   b = bmin + w->_curx;
709
   bmax = bmin + w->ncols;
710
711
   /* Remove overwritten chars to left */
712
   if (b < bmax && *b == SLSMG_NOCHAR) {
713
     for (c = b - 1; c >= bmin && *c == SLSMG_NOCHAR; c--)
714
       *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
715
     if (c >= bmin) 
716
       *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
717
   }
718
#else
591
   b = w->lines[w->_cury];
719
   b = w->lines[w->_cury];
592
   bmax = b + w->ncols;
720
   bmax = b + w->ncols;
593
   b += w->_curx;
721
   b += w->_curx;
722
#endif /* UTF8 */
594
723
595
   while (b < bmax) *b++ = blank;
724
   while (b < bmax) *b++ = blank;
596
   return 0;
725
   return 0;
Lines 677-682 Link Here
677
   return 0;
806
   return 0;
678
}
807
}
679
808
809
#ifdef UTF8
810
/* Note: if len is < 0, entire string will be used.
811
 */
812
int SLcurses_waddnstr (SLcurses_Window_Type *w, char *str, int len)
813
{
814
   size_t k;
815
   wchar_t wc;
816
   mbstate_t mbstate;
817
818
   if ((w == NULL)
819
       || (str == NULL))
820
     return -1;
821
822
   if (len < 0)
823
     len = (char *)(-1) - str;
824
825
   memset (&mbstate, 0, sizeof (mbstate));
826
   while ((k = mbrtowc (&wc, str, len, &mbstate)) &&
827
	  k != (size_t)(-1) &&
828
	  k != (size_t)(-2))
829
     {
830
	SLcurses_waddch1 (w, wc, w->color);
831
	str += k;
832
	len -= k;
833
     }
834
   return k;
835
}
836
#else
680
/* Note: if len is < 0, entire string will be used.
837
/* Note: if len is < 0, entire string will be used.
681
 */
838
 */
682
int SLcurses_waddnstr (SLcurses_Window_Type *w, char *str, int len)
839
int SLcurses_waddnstr (SLcurses_Window_Type *w, char *str, int len)
Lines 758-763 Link Here
758
915
759
   return 0;
916
   return 0;
760
}
917
}
918
#endif /* UTF8 */
761
919
762
/* This routine IS NOT CORRECT.  It needs to compute the proper overlap
920
/* This routine IS NOT CORRECT.  It needs to compute the proper overlap
763
 * and copy accordingly.  Here, I just assume windows are same size.
921
 * and copy accordingly.  Here, I just assume windows are same size.
Lines 852-863 Link Here
852
1010
853
int SLcurses_wdelch (SLcurses_Window_Type *w)
1011
int SLcurses_wdelch (SLcurses_Window_Type *w)
854
{
1012
{
1013
#ifdef UTF8
1014
   SLsmg_Char_Type *p, *p1, *pmin, *pmax, *q;
1015
#else
855
   SLsmg_Char_Type *p, *p1, *pmax;
1016
   SLsmg_Char_Type *p, *p1, *pmax;
1017
#endif /* UTF8 */
856
1018
1019
#ifdef UTF8
1020
   pmin = w->lines[w->_cury];
1021
   p = pmin + w->_curx;
1022
   pmax = pmin + w->ncols;
1023
1024
   /* Remove overwritten chars to left */
1025
   if (p < pmax && *p == SLSMG_NOCHAR) {
1026
     for (q = p - 1; q >= pmin && *q == SLSMG_NOCHAR; q--)
1027
       *q = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*q));
1028
     if (q >= pmin)
1029
       *q = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*q));
1030
   }
1031
1032
   /* Remove overwritten chars to right */
1033
   for (q = p + 1; q < pmax && *q == SLSMG_NOCHAR; q++)
1034
     *q = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*q));
1035
 
1036
   p1 = p + 1;
1037
#else
857
   p = w->lines[w->_cury];
1038
   p = w->lines[w->_cury];
858
   pmax = p + w->ncols;
1039
   pmax = p + w->ncols;
859
   p += w->_curx;
1040
   p += w->_curx;
860
   p1 = p + 1;
1041
   p1 = p + 1;
1042
#endif /* UTF8 */
861
1043
862
   while (p1 < pmax)
1044
   while (p1 < pmax)
863
     {
1045
     {
Lines 884-895 Link Here
884
1066
885
   while (pmax > p)
1067
   while (pmax > p)
886
     {
1068
     {
887
	*pmax = *p1;
1069
	*pmax = *p1; /* Doesn't this assign beyond the end of the line? */
888
	pmax = p1;
1070
	pmax = p1;
889
	p1--;
1071
	p1--;
890
     }
1072
     }
891
1073
892
   if (p < pmax)
1074
   if (p < pmax) /* How could it be? */
893
     *p = SLSMG_BUILD_CHAR(ch, w->color);
1075
     *p = SLSMG_BUILD_CHAR(ch, w->color);
894
1076
895
   w->modified = 1;
1077
   w->modified = 1;
896
-- slang-1.4.4.orig/src/slsmg.c
1078
++ slang-1.4.4/src/slsmg.c
Lines 225-230 Link Here
225
   SLsmg_write_nchars (str, strlen (str));
225
   SLsmg_write_nchars (str, strlen (str));
226
}
226
}
227
227
228
#ifdef UTF8
229
void SLsmg_write_nstring (char *str, unsigned int n)
230
{
231
   char blank = ' ';
232
   mbstate_t mbstate;
233
234
   /* Avoid a problem if a user accidently passes a negative value */
235
   if ((int) n < 0)
236
     return;
237
238
   if (str != NULL)
239
     {
240
	wchar_t wc;
241
	size_t k;
242
	int w;
243
244
	memset (&mbstate, 0, sizeof (mbstate));
245
        while ((k = mbrtowc (&wc, str, MB_LEN_MAX, &mbstate)) &&
246
	       k != (size_t)(-1) &&
247
	       k != (size_t)(-2))
248
	  {
249
	     w = wcwidth(wc);
250
	     if (w < 0 || w > n)
251
	       break;
252
	     SLsmg_write_nwchars (&wc, 1);
253
	     str += k;
254
	     n -= w;
255
	  }
256
     }
257
   while (n-- > 0) SLsmg_write_nchars (&blank, 1);
258
}
259
#else
228
void SLsmg_write_nstring (char *str, unsigned int n)
260
void SLsmg_write_nstring (char *str, unsigned int n)
229
{
261
{
230
   unsigned int width;
262
   unsigned int width;
Lines 243-249 Link Here
243
     }
275
     }
244
   while (width++ < n) SLsmg_write_nchars (&blank, 1);
276
   while (width++ < n) SLsmg_write_nchars (&blank, 1);
245
}
277
}
278
#endif /* UTF8 */
246
279
280
#ifdef UTF8
281
/* FIXME: This function not UTF8'd yet - Edmund */
282
#endif /* UTF8 */
247
void SLsmg_write_wrapped_string (char *s, int r, int c,
283
void SLsmg_write_wrapped_string (char *s, int r, int c,
248
				 unsigned int dr, unsigned int dc,
284
				 unsigned int dr, unsigned int dc,
249
				 int fill)
285
				 int fill)
Lines 302-307 Link Here
302
int SLsmg_Display_Eight_Bit = 128;
338
int SLsmg_Display_Eight_Bit = 128;
303
#endif
339
#endif
304
340
341
#ifdef UTF8
342
void SLsmg_write_nwchars (wchar_t *str, unsigned int n)
343
{
344
  SLsmg_Char_Type *p, *prev, *q;
345
  int len, max_len, w, i;
346
  wchar_t ch;
347
348
#ifndef IBMPC_SYSTEM
349
   int alt_char_set_flag;
350
351
   alt_char_set_flag = ((This_Color & ALT_CHAR_FLAG)
352
			&& ((tt_Use_Blink_For_ACS == NULL)
353
			    || (*tt_Use_Blink_For_ACS == 0)));
354
#endif
355
356
  if (Smg_Inited == 0)
357
    return;
358
  if (This_Row < Start_Row || This_Row >= Start_Row + Screen_Rows)
359
    return;
360
361
  max_len = Start_Col + Screen_Cols;
362
  len = This_Col;
363
  p = SL_Screen[This_Row - Start_Row].neew + len - Start_Col;
364
  prev = 0;
365
366
  for (i = 0; i < n; i++, str) {
367
    ch = *str++;
368
#ifndef IBMPC_SYSTEM
369
    if (alt_char_set_flag)
370
      ch = Alt_Char_Set[ch & 0x7F];
371
#endif
372
    w = wcwidth(ch);
373
374
    if (w > 0) {
375
      if (len + w <= max_len) {
376
	if (!prev) {
377
	  for (q = p; *q == SLSMG_NOCHAR; q--)
378
	    *q = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*q));
379
	  *q = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*q));
380
	}
381
	prev = p;
382
	*p++ = SLSMG_BUILD_CHAR(ch, This_Color), ++len;
383
	for (; --w; len++, p++)
384
	  *p = SLSMG_NOCHAR;
385
      }
386
      else if (len < max_len) {
387
	for (; len < max_len; len++, p++)
388
	  *p = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*p));
389
	prev = 0;
390
      }
391
    }
392
    else if (ch == '\n' &&
393
	     SLsmg_Newline_Behavior != SLSMG_NEWLINE_PRINTABLE) {
394
      SL_Screen[This_Row - Start_Row].flags |= TOUCHED;
395
      for (; len < max_len && *p == SLSMG_NOCHAR; len++, p++)
396
	*p = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*p));
397
      if (!SLsmg_Newline_Behavior)
398
	break;
399
      ++This_Row;
400
      len = 0;
401
      if (This_Row == Start_Row + Screen_Rows) {
402
	if (SLsmg_Newline_Behavior == SLSMG_NEWLINE_SCROLLS)
403
	  scroll_up();
404
	else
405
	  break;
406
      }
407
      p = SL_Screen[This_Row - Start_Row].neew;
408
      prev = 0;
409
    }
410
    else if (ch == '\t' && (SLsmg_Tab_Width > 0)) {
411
      while (len < max_len) {
412
	*p = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*p));
413
	++p, ++len;
414
	if (len % SLsmg_Tab_Width == 0)
415
	  break;
416
      }
417
    }
418
    else if ((ch == 0x8) && SLsmg_Backspace_Moves) {
419
      /* not implemented */
420
    }
421
    else if (!w && ch) {
422
      /* we could handle combining characters here, using prev */
423
    }
424
    else {
425
      /* we should convert control characters to printable form here */
426
    }
427
  }
428
  This_Col = len;
429
  if (i == n) {
430
    SL_Screen[This_Row - Start_Row].flags |= TOUCHED;
431
    for (; len < max_len && *p == SLSMG_NOCHAR; len++, p++)
432
      *p = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*p));
433
  }
434
}
435
436
void SLsmg_write_char (wchar_t wc)
437
{
438
   SLsmg_write_nwchars (&wc, 1);
439
}
440
441
void SLsmg_write_nchars (char *str, unsigned int n)
442
{
443
   wchar_t wc;
444
   size_t k;
445
   mbstate_t mbstate;
446
447
   memset (&mbstate, 0, sizeof (mbstate));
448
   while ((k = mbrtowc (&wc, str, n, &mbstate)) &&
449
	  k != (size_t)(-1) &&
450
	  k != (size_t)(-2))
451
     {
452
        SLsmg_write_nwchars (&wc, 1);
453
	str += k;
454
	n -= k;
455
     }
456
}
457
#else
305
void SLsmg_write_nchars (char *str, unsigned int n)
458
void SLsmg_write_nchars (char *str, unsigned int n)
306
{
459
{
307
   register SLsmg_Char_Type *p, old, neew, color;
460
   register SLsmg_Char_Type *p, old, neew, color;
Lines 475-480 Link Here
475
{
628
{
476
   SLsmg_write_nchars (&ch, 1);
629
   SLsmg_write_nchars (&ch, 1);
477
}
630
}
631
#endif /* UTF8 */
478
632
479
static int Cls_Flag;
633
static int Cls_Flag;
480
634
Lines 891-896 Link Here
891
	     This_Color = color;
1045
	     This_Color = color;
892
	  }
1046
	  }
893
1047
1048
#ifdef UTF8
1049
	/* FIXME: We should convert broken wide characters to spaces
1050
	   before calling smart_puts */
1051
#endif /* UTF8 */
894
	SL_Screen[i].old[Screen_Cols] = 0;
1052
	SL_Screen[i].old[Screen_Cols] = 0;
895
	SL_Screen[i].neew[Screen_Cols] = 0;
1053
	SL_Screen[i].neew[Screen_Cols] = 0;
896
1054
Lines 1334-1342 Link Here
1334
   This_Row = r; This_Col = c;
1492
   This_Row = r; This_Col = c;
1335
}
1493
}
1336
1494
1495
#ifdef UTF8
1496
void SLsmg_fill_region (int r, int c, unsigned int dr, unsigned int dc, wchar_t ch)
1497
{
1498
   static wchar_t hbuf[16];
1499
   int i;
1500
#else
1337
void SLsmg_fill_region (int r, int c, unsigned int dr, unsigned int dc, unsigned char ch)
1501
void SLsmg_fill_region (int r, int c, unsigned int dr, unsigned int dc, unsigned char ch)
1338
{
1502
{
1339
   static unsigned char hbuf[16];
1503
   static unsigned char hbuf[16];
1504
#endif /* UTF8 */
1340
   int count;
1505
   int count;
1341
   int dcmax, rmax;
1506
   int dcmax, rmax;
1342
1507
Lines 1357-1372 Link Here
1357
#if 0
1522
#if 0
1358
   ch = Alt_Char_Set[ch];
1523
   ch = Alt_Char_Set[ch];
1359
#endif
1524
#endif
1525
#ifdef UTF8
1526
   if (ch != hbuf[0])
1527
     for (i = 0; i < 16; i++)
1528
       hbuf[i] = ch;
1529
#else
1360
   if (ch != hbuf[0]) SLMEMSET ((char *) hbuf, (char) ch, 16);
1530
   if (ch != hbuf[0]) SLMEMSET ((char *) hbuf, (char) ch, 16);
1531
#endif /* UTF8 */
1361
1532
1362
   for (This_Row = r; This_Row < rmax; This_Row++)
1533
   for (This_Row = r; This_Row < rmax; This_Row++)
1363
     {
1534
     {
1364
	This_Col = c;
1535
	This_Col = c;
1365
	count = dc / 16;
1536
	count = dc / 16;
1537
#ifdef UTF8
1538
	SLsmg_write_nwchars (hbuf, dc % 16);
1539
#else
1366
	SLsmg_write_nchars ((char *) hbuf, dc % 16);
1540
	SLsmg_write_nchars ((char *) hbuf, dc % 16);
1541
#endif /* UTF8 */
1367
	while (count-- > 0)
1542
	while (count-- > 0)
1368
	  {
1543
	  {
1544
#ifdef UTF8
1545
	     SLsmg_write_nwchars (hbuf, 16);
1546
#else
1369
	     SLsmg_write_nchars ((char *) hbuf, 16);
1547
	     SLsmg_write_nchars ((char *) hbuf, 16);
1548
#endif /* UTF8 */
1370
	  }
1549
	  }
1371
     }
1550
     }
1372
1551
Lines 1381-1394 Link Here
1381
void SLsmg_write_color_chars (SLsmg_Char_Type *s, unsigned int len)
1560
void SLsmg_write_color_chars (SLsmg_Char_Type *s, unsigned int len)
1382
{
1561
{
1383
   SLsmg_Char_Type *smax, sh;
1562
   SLsmg_Char_Type *smax, sh;
1563
#ifdef UTF8
1564
   wchar_t buf[32], *b, *bmax;
1565
#else
1384
   char buf[32], *b, *bmax;
1566
   char buf[32], *b, *bmax;
1567
#endif /* UTF8 */
1385
   int color, save_color;
1568
   int color, save_color;
1386
1569
1387
   if (Smg_Inited == 0) return;
1570
   if (Smg_Inited == 0) return;
1388
1571
1389
   smax = s + len;
1572
   smax = s + len;
1390
   b = buf;
1573
   b = buf;
1574
#ifdef UTF8
1575
   bmax = b + sizeof (buf) / sizeof (SLsmg_Char_Type);
1576
#else
1391
   bmax = b + sizeof (buf);
1577
   bmax = b + sizeof (buf);
1578
#endif /* UTF8 */
1392
1579
1393
   save_color = This_Color;
1580
   save_color = This_Color;
1394
1581
Lines 1412-1427 Link Here
1412
	  {
1599
	  {
1413
	     if (b != buf)
1600
	     if (b != buf)
1414
	       {
1601
	       {
1602
#ifdef UTF8
1603
		  SLsmg_write_nwchars (buf, (int) (b - buf));
1604
#else
1415
		  SLsmg_write_nchars (buf, (int) (b - buf));
1605
		  SLsmg_write_nchars (buf, (int) (b - buf));
1606
#endif /* UTF8 */
1416
		  b = buf;
1607
		  b = buf;
1417
	       }
1608
	       }
1418
	     This_Color = color;
1609
	     This_Color = color;
1419
	  }
1610
	  }
1611
#ifdef UTF8
1612
	*b++ = SLSMG_EXTRACT_CHAR(sh);
1613
#else
1420
	*b++ = (char) SLSMG_EXTRACT_CHAR(sh);
1614
	*b++ = (char) SLSMG_EXTRACT_CHAR(sh);
1615
#endif /* UTF8 */
1421
     }
1616
     }
1422
1617
1423
   if (b != buf)
1618
   if (b != buf)
1619
#ifdef UTF8
1620
     SLsmg_write_nwchars (buf, (unsigned int) (b - buf));
1621
#else
1424
     SLsmg_write_nchars (buf, (unsigned int) (b - buf));
1622
     SLsmg_write_nchars (buf, (unsigned int) (b - buf));
1623
#endif /* UTF8 */
1425
1624
1426
   This_Color = save_color;
1625
   This_Color = save_color;
1427
}
1626
}
Lines 1473-1479 Link Here
1473
SLsmg_set_color_in_region (int color, int r, int c, unsigned int dr, unsigned int dc)
1672
SLsmg_set_color_in_region (int color, int r, int c, unsigned int dr, unsigned int dc)
1474
{
1673
{
1475
   int cmax, rmax;
1674
   int cmax, rmax;
1675
#ifdef UTF8
1676
   int color_mask;
1677
#else
1476
   SLsmg_Char_Type char_mask;
1678
   SLsmg_Char_Type char_mask;
1679
#endif /* UTF8 */
1477
1680
1478
   if (Smg_Inited == 0) return;
1681
   if (Smg_Inited == 0) return;
1479
1682
Lines 1498-1511 Link Here
1498
	  color = ((color & 0x7F) + Bce_Color_Offset) & 0x7F;
1701
	  color = ((color & 0x7F) + Bce_Color_Offset) & 0x7F;
1499
     }
1702
     }
1500
#endif
1703
#endif
1704
#ifdef UTF8
1705
   color_mask = 0;
1706
#else
1501
   color = color << 8;
1707
   color = color << 8;
1502
1708
1503
   char_mask = 0xFF;
1709
   char_mask = 0xFF;
1710
#endif /* UTF8 */
1504
1711
1505
#ifndef IBMPC_SYSTEM
1712
#ifndef IBMPC_SYSTEM
1506
   if ((tt_Use_Blink_For_ACS == NULL)
1713
   if ((tt_Use_Blink_For_ACS == NULL)
1507
       || (0 == *tt_Use_Blink_For_ACS))
1714
       || (0 == *tt_Use_Blink_For_ACS))
1715
#ifdef UTF8
1716
     color_mask = 0x80;
1717
#else
1508
     char_mask = 0x80FF;
1718
     char_mask = 0x80FF;
1719
#endif /* UTF8 */
1509
#endif
1720
#endif
1510
1721
1511
   while (r < rmax)
1722
   while (r < rmax)
Lines 1519-1525 Link Here
1519
1730
1520
	while (s < smax)
1731
	while (s < smax)
1521
	  {
1732
	  {
1733
#ifdef UTF8
1734
	     *s = SLSMG_BUILD_CHAR(SLSMG_EXTRACT_CHAR(*s),
1735
				   (SLSMG_EXTRACT_COLOR(*s) & color_mask)
1736
				   | color);
1737
#else
1522
	     *s = (*s & char_mask) | color;
1738
	     *s = (*s & char_mask) | color;
1739
#endif /* UTF8 */
1523
	     s++;
1740
	     s++;
1524
	  }
1741
	  }
1525
	r++;
1742
	r++;
(-)slang-1.4.9/src/sldisply.c.orig (-1 / +105 lines)
Lines 9-14 Link Here
9
9
10
#include <time.h>
10
#include <time.h>
11
#include <ctype.h>
11
#include <ctype.h>
12
#include <limits.h>
12
13
13
#if !defined(VMS) || (__VMS_VER >= 70000000)
14
#if !defined(VMS) || (__VMS_VER >= 70000000)
14
# include <sys/time.h>
15
# include <sys/time.h>
Lines 1426-1439 Link Here
1426
1427
1427
/* Highest bit represents the character set. */
1428
/* Highest bit represents the character set. */
1428
#define COLOR_MASK 0x7F00
1429
#define COLOR_MASK 0x7F00
1430
#ifdef UTF8
1431
# define COLOR_OF(x) (SLSMG_EXTRACT_COLOR(x) & 0x7F)
1432
#else
1429
#define COLOR_OF(x) (((x)&COLOR_MASK)>>8)
1433
#define COLOR_OF(x) (((x)&COLOR_MASK)>>8)
1434
#endif
1430
#define CHAR_OF(x) ((x)&0x80FF)
1435
#define CHAR_OF(x) ((x)&0x80FF)
1431
1436
1432
#if SLTT_HAS_NON_BCE_SUPPORT
1437
#if SLTT_HAS_NON_BCE_SUPPORT
1438
#ifdef UTF8
1439
static int bce_color_eqs (SLsmg_Char_Type a, SLsmg_Char_Type b)
1440
{
1441
   a = SLSMG_EXTRACT_COLOR(a) & 0x7F;
1442
   b = SLSMG_EXTRACT_COLOR(b) & 0x7F;
1443
#else
1433
static int bce_color_eqs (unsigned int a, unsigned int b)
1444
static int bce_color_eqs (unsigned int a, unsigned int b)
1434
{
1445
{
1435
   a = COLOR_OF(a);
1446
   a = COLOR_OF(a);
1436
   b = COLOR_OF(b);
1447
   b = COLOR_OF(b);
1448
#endif
1437
   
1449
   
1438
   if (a == b)
1450
   if (a == b)
1439
     return 1;
1451
     return 1;
Lines 1459-1466 Link Here
1459
    :  (Ansi_Color_Map[COLOR_OF(a)].mono == Ansi_Color_Map[COLOR_OF(b)].mono))
1471
    :  (Ansi_Color_Map[COLOR_OF(a)].mono == Ansi_Color_Map[COLOR_OF(b)].mono))
1460
#endif
1472
#endif
1461
1473
1474
#ifdef UTF8
1475
#define CHAR_EQS(a, b) ((a) == (b)\
1476
			|| (SLSMG_EXTRACT_CHAR(a) == SLSMG_EXTRACT_CHAR(b)\
1477
			    && COLOR_EQS((a), (b))))
1478
#else
1462
#define CHAR_EQS(a, b) (((a) == (b))\
1479
#define CHAR_EQS(a, b) (((a) == (b))\
1463
			|| ((CHAR_OF(a)==CHAR_OF(b)) && COLOR_EQS(a,b)))
1480
			|| ((CHAR_OF(a)==CHAR_OF(b)) && COLOR_EQS(a,b)))
1481
#endif
1464
1482
1465
/* The whole point of this routine is to prevent writing to the last column
1483
/* The whole point of this routine is to prevent writing to the last column
1466
 * and last row on terminals with automatic margins.
1484
 * and last row on terminals with automatic margins.
Lines 1488-1496 Link Here
1488
   tt_write (str, len);
1506
   tt_write (str, len);
1489
}
1507
}
1490
1508
1509
#ifdef UTF8
1510
/* FIXME: This duplicates the function above
1511
 */
1512
static void write_wstring_with_care (SLsmg_Char_Type *str, unsigned int len)
1513
{
1514
   mbstate_t mbstate;
1515
1516
   if (str == NULL) return;
1517
1518
   if (Automatic_Margins && (Cursor_r + 1 == SLtt_Screen_Rows))
1519
     {
1520
	if (len + (unsigned int) Cursor_c >= (unsigned int) SLtt_Screen_Cols)
1521
	  {
1522
	     /* For now, just do not write there.  Later, something more
1523
	      * sophisticated will be implemented.
1524
	      */
1525
	     if (SLtt_Screen_Cols > Cursor_c)
1526
	       {
1527
		  len = SLtt_Screen_Cols - Cursor_c - 1;
1528
		  while (len > 0 && str[len] == SLSMG_NOCHAR)
1529
		    --len;
1530
	       }
1531
	     else len = 0;
1532
	  }
1533
     }
1534
1535
   memset (&mbstate, 0, sizeof (mbstate));
1536
   while (len--)
1537
     {
1538
        SLsmg_Char_Type c = *str++;
1539
	char buf[MB_LEN_MAX];
1540
	size_t n;
1541
1542
	if (c == SLSMG_NOCHAR)
1543
	  continue;
1544
1545
	n = wcrtomb (buf, c, &mbstate);
1546
	if (n == (size_t)(-1))
1547
	  break;
1548
1549
	tt_write(buf, n);
1550
     }
1551
}
1552
#endif /* UTF8 */
1553
1491
static void send_attr_str (SLsmg_Char_Type *s)
1554
static void send_attr_str (SLsmg_Char_Type *s)
1492
{
1555
{
1556
#ifdef UTF8
1557
   SLsmg_Char_Type out[SLTT_MAX_SCREEN_COLS], ch, *p;
1558
#else
1493
   unsigned char out[SLTT_MAX_SCREEN_COLS], ch, *p;
1559
   unsigned char out[SLTT_MAX_SCREEN_COLS], ch, *p;
1560
#endif /* UTF8 */
1494
   register SLtt_Char_Type attr;
1561
   register SLtt_Char_Type attr;
1495
   register SLsmg_Char_Type sh;
1562
   register SLsmg_Char_Type sh;
1496
   int color, last_color = -1;
1563
   int color, last_color = -1;
Lines 1498-1505 Link Here
1498
   p = out;
1565
   p = out;
1499
   while (0 != (sh = *s++))
1566
   while (0 != (sh = *s++))
1500
     {
1567
     {
1568
#ifdef UTF8
1569
	ch = SLSMG_EXTRACT_CHAR(sh);
1570
	color = SLSMG_EXTRACT_COLOR(sh);
1571
#else
1501
	ch = sh & 0xFF;
1572
	ch = sh & 0xFF;
1502
	color = ((int) sh & 0xFF00) >> 8;
1573
	color = ((int) sh & 0xFF00) >> 8;
1574
#endif
1503
1575
1504
#if SLTT_HAS_NON_BCE_SUPPORT
1576
#if SLTT_HAS_NON_BCE_SUPPORT
1505
	if (Bce_Color_Offset
1577
	if (Bce_Color_Offset
Lines 1511-1518 Link Here
1511
	  {
1583
	  {
1512
	     if (SLtt_Use_Ansi_Colors) attr = Ansi_Color_Map[color & 0x7F].fgbg;
1584
	     if (SLtt_Use_Ansi_Colors) attr = Ansi_Color_Map[color & 0x7F].fgbg;
1513
	     else attr = Ansi_Color_Map[color & 0x7F].mono;
1585
	     else attr = Ansi_Color_Map[color & 0x7F].mono;
1514
1586
 
1587
#ifdef UTF8
1588
	     if (SLSMG_EXTRACT_COLOR(sh) & 0x80) /* alternate char set */
1589
#else
1515
	     if (sh & 0x8000) /* alternate char set */
1590
	     if (sh & 0x8000) /* alternate char set */
1591
#endif
1516
	       {
1592
	       {
1517
		  if (SLtt_Use_Blink_For_ACS)
1593
		  if (SLtt_Use_Blink_For_ACS)
1518
		    {
1594
		    {
Lines 1534-1541 Link Here
1534
		    {
1610
		    {
1535
		       if (p != out)
1611
		       if (p != out)
1536
			 {
1612
			 {
1613
#ifdef UTF8
1614
			    write_wstring_with_care (out, p-out);
1615
#else
1537
			    *p = 0;
1616
			    *p = 0;
1538
			    write_string_with_care ((char *) out);
1617
			    write_string_with_care ((char *) out);
1618
#endif
1539
			    Cursor_c += (int) (p - out);
1619
			    Cursor_c += (int) (p - out);
1540
			    p = out;
1620
			    p = out;
1541
			 }
1621
			 }
Lines 1558-1565 Link Here
1558
	  }
1638
	  }
1559
	*p++ = ch;
1639
	*p++ = ch;
1560
     }
1640
     }
1641
#ifdef UTF8
1642
   if (p != out) write_wstring_with_care (out, p-out);
1643
#else
1561
   *p = 0;
1644
   *p = 0;
1562
   if (p != out) write_string_with_care ((char *) out);
1645
   if (p != out) write_string_with_care ((char *) out);
1646
#endif
1563
   Cursor_c += (int) (p - out);
1647
   Cursor_c += (int) (p - out);
1564
}
1648
}
1565
1649
Lines 1686-1692 Link Here
1686
1770
1687
	while (qq < qmax)
1771
	while (qq < qmax)
1688
	  {
1772
	  {
1773
#ifdef UTF8
1774
	     if (SLSMG_EXTRACT_COLOR(*qq))
1775
#else
1689
	     if (*qq & 0xFF00)
1776
	     if (*qq & 0xFF00)
1777
#endif
1690
	       {
1778
	       {
1691
		  SLtt_normal_video ();
1779
		  SLtt_normal_video ();
1692
		  SLtt_del_eol ();
1780
		  SLtt_del_eol ();
Lines 1701-1707 Link Here
1701
   /* Find where the last non-blank character on old/new screen is */
1789
   /* Find where the last non-blank character on old/new screen is */
1702
1790
1703
   space_char = ' ';
1791
   space_char = ' ';
1792
#ifdef UTF8
1793
   if (SLSMG_EXTRACT_CHAR(*(pmax-1)) == ' ')
1794
#else
1704
   if (CHAR_EQS(*(pmax-1), ' '))
1795
   if (CHAR_EQS(*(pmax-1), ' '))
1796
#endif
1705
     {
1797
     {
1706
	/* If we get here, then we can erase to the end of the line to create
1798
	/* If we get here, then we can erase to the end of the line to create
1707
	 * the final space.  However, this will only work _if_ erasing will 
1799
	 * the final space.  However, this will only work _if_ erasing will 
Lines 1752-1758 Link Here
1752
     {
1844
     {
1753
#endif
1845
#endif
1754
	/* Try use use erase to bol if possible */
1846
	/* Try use use erase to bol if possible */
1847
#ifdef UTF8
1848
	if ((Del_Bol_Str != NULL) && (SLSMG_EXTRACT_CHAR(*neww) == ' '))
1849
#else
1755
	if ((Del_Bol_Str != NULL) && (CHAR_OF(*neww) == ' '))
1850
	if ((Del_Bol_Str != NULL) && (CHAR_OF(*neww) == ' '))
1851
#endif
1756
	  {
1852
	  {
1757
	     SLsmg_Char_Type *p1;
1853
	     SLsmg_Char_Type *p1;
1758
	     SLsmg_Char_Type blank;
1854
	     SLsmg_Char_Type blank;
Lines 1781-1787 Link Here
1781
		  q = oldd + ofs;
1877
		  q = oldd + ofs;
1782
		  p = p1;
1878
		  p = p1;
1783
		  SLtt_goto_rc (row, ofs - 1);
1879
		  SLtt_goto_rc (row, ofs - 1);
1880
#ifdef UTF8
1881
		  SLtt_reverse_video (SLSMG_EXTRACT_COLOR (blank));
1882
#else
1784
		  SLtt_reverse_video (COLOR_OF(blank));
1883
		  SLtt_reverse_video (COLOR_OF(blank));
1884
#endif
1785
		  tt_write_string (Del_Bol_Str);
1885
		  tt_write_string (Del_Bol_Str);
1786
		  tt_write (" ", 1);
1886
		  tt_write (" ", 1);
1787
		  Cursor_c += 1;
1887
		  Cursor_c += 1;
Lines 1978-1984 Link Here
1978
2078
1979
   if (q < qmax) 
2079
   if (q < qmax) 
1980
     {
2080
     {
2081
#ifdef UTF8
2082
	SLtt_reverse_video (SLSMG_EXTRACT_COLOR (space_char));
2083
#else
1981
	SLtt_reverse_video (COLOR_OF(space_char));
2084
	SLtt_reverse_video (COLOR_OF(space_char));
2085
#endif
1982
	del_eol ();
2086
	del_eol ();
1983
     }
2087
     }
1984
   
2088
   

Return to bug 47675