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++; |