1 --- slang-1.4.4.orig/src/slinclud.h
2 +++ slang-1.4.4/src/slinclud.h
15 #endif /* _SLANG_INCLUDE_H_ */
16 --- slang-1.4.4.orig/src/slang.h
17 +++ slang-1.4.4/src/slang.h
18 @@ -1239,10 +1239,20 @@
19 extern int SLtt_Msdos_Cheap_Video;
25 +typedef int SLsmg_Char_Type;
26 +#define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFFFFFF)
27 +#define SLSMG_EXTRACT_COLOR(x) (((x)>>24)&0xFF)
28 +#define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(wchar_t)(ch))|((color)<<24))
29 +#define SLSMG_NOCHAR 1
31 typedef unsigned short SLsmg_Char_Type;
32 #define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFF)
33 #define SLSMG_EXTRACT_COLOR(x) (((x)>>8)&0xFF)
34 #define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(unsigned char)(ch))|((color)<<8))
37 extern int SLtt_flush_output (void);
38 extern void SLtt_set_scroll_region(int, int);
39 @@ -1334,7 +1342,11 @@
41 /*{{{ SLsmg Screen Management Functions */
44 +extern void SLsmg_fill_region (int, int, unsigned int, unsigned int, wchar_t);
46 extern void SLsmg_fill_region (int, int, unsigned int, unsigned int, unsigned char);
48 extern void SLsmg_set_char_set (int);
50 extern int SLsmg_Scroll_Hash_Border;
51 @@ -1351,7 +1363,12 @@
52 extern void SLsmg_vprintf (char *, va_list);
53 extern void SLsmg_write_string (char *);
54 extern void SLsmg_write_nstring (char *, unsigned int);
56 +extern void SLsmg_write_char (wchar_t);
57 +extern void SLsmg_write_nwchars (wchar_t *, unsigned int);
59 extern void SLsmg_write_char (char);
61 extern void SLsmg_write_nchars (char *, unsigned int);
62 extern void SLsmg_write_wrapped_string (char *, int, int, unsigned int, unsigned int, int);
63 extern void SLsmg_cls (void);
64 --- slang-1.4.4.orig/src/slcurses.c
65 +++ slang-1.4.4/src/slcurses.c
66 @@ -440,20 +440,130 @@
68 static int do_newline (SLcurses_Window_Type *w)
73 if (w->_cury >= w->scroll_max)
75 w->_cury = w->scroll_max - 1;
79 SLcurses_wscrl (w, 1);
89 +static int SLcurses_waddch1 (SLcurses_Window_Type *win,
90 + wchar_t ch, int color)
92 + SLsmg_Char_Type *b, *bmin, *bmax, *c;
95 + if (win == NULL) return -1;
97 + if (win->_cury >= win->nrows)
99 + /* Curses seems to move current postion to top of window. */
100 + win->_cury = win->_curx = 0;
110 + SLcurses_wclrtoeol (win);
111 + return do_newline (win);
122 + if (win->_curx > 0)
128 + /* HACK HACK!!!! */
129 + if (ch == '\t') ch = ' ';
135 + return 0; /* ignore combining characters for now */
137 + if (k > win->ncols)
138 + return 0; /* character wider than window */
140 + if (win->_curx + k > win->ncols) {
141 + if (win->_curx < win->ncols)
142 + SLcurses_wclrtoeol(win);
146 + bmin = win->lines[win->_cury];
147 + b = bmin + win->_curx;
148 + bmax = bmin + win->ncols;
150 + /* Remove overwritten chars to left */
151 + if (*b == SLSMG_NOCHAR) {
152 + for (c = b - 1; c >= bmin && *c == SLSMG_NOCHAR; c--)
153 + *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
155 + *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
158 + *b = SLSMG_BUILD_CHAR(ch,color);
161 + *++b = SLSMG_NOCHAR;
163 + /* Remove overwritten chars to right */
164 + for (c = b + 1; c < bmax && *c == SLSMG_NOCHAR; c++)
165 + *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
170 int SLcurses_waddch (SLcurses_Window_Type *win, SLtt_Char_Type attr)
172 + SLsmg_Char_Type ch, color;
174 + if (win == NULL) return -1;
176 + ch = SLSMG_EXTRACT_CHAR(attr);
179 + color = win->color;
182 + /* hack to pick up the default color for graphics chars */
183 + if (((attr & A_COLOR) == 0) && ((attr & A_ALTCHARSET) != 0))
185 + /* FIXME: priority=medium: Use SLSMG_?? instead of << */
186 + attr |= win->color << 8;
188 + color = map_attr_to_object (attr);
191 + return SLcurses_waddch1 (win, ch, color);
194 +int SLcurses_waddch (SLcurses_Window_Type *win, SLtt_Char_Type attr)
196 SLsmg_Char_Type *b, ch;
197 SLsmg_Char_Type color;
205 int SLcurses_wnoutrefresh (SLcurses_Window_Type *w)
209 int SLcurses_wclrtoeol (SLcurses_Window_Type *w)
212 + SLsmg_Char_Type *b, *bmin, *bmax, *c;
214 SLsmg_Char_Type *b, *bmax;
216 SLsmg_Char_Type blank;
218 if (w == NULL) return -1;
221 blank = SLSMG_BUILD_CHAR(' ',w->color);
224 + bmin = w->lines[w->_cury];
225 + b = bmin + w->_curx;
226 + bmax = bmin + w->ncols;
228 + /* Remove overwritten chars to left */
229 + if (b < bmax && *b == SLSMG_NOCHAR) {
230 + for (c = b - 1; c >= bmin && *c == SLSMG_NOCHAR; c--)
231 + *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
233 + *c = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*c));
236 b = w->lines[w->_cury];
241 while (b < bmax) *b++ = blank;
248 +/* Note: if len is < 0, entire string will be used.
250 +int SLcurses_waddnstr (SLcurses_Window_Type *w, char *str, int len)
261 + len = (char *)(-1) - str;
263 + memset (&mbstate, 0, sizeof (mbstate));
264 + while ((k = mbrtowc (&wc, str, len, &mbstate)) &&
265 + k != (size_t)(-1) &&
268 + SLcurses_waddch1 (w, wc, w->color);
275 /* Note: if len is < 0, entire string will be used.
277 int SLcurses_waddnstr (SLcurses_Window_Type *w, char *str, int len)
284 /* This routine IS NOT CORRECT. It needs to compute the proper overlap
285 * and copy accordingly. Here, I just assume windows are same size.
286 @@ -852,12 +1010,36 @@
288 int SLcurses_wdelch (SLcurses_Window_Type *w)
291 + SLsmg_Char_Type *p, *p1, *pmin, *pmax, *q;
293 SLsmg_Char_Type *p, *p1, *pmax;
297 + pmin = w->lines[w->_cury];
298 + p = pmin + w->_curx;
299 + pmax = pmin + w->ncols;
301 + /* Remove overwritten chars to left */
302 + if (p < pmax && *p == SLSMG_NOCHAR) {
303 + for (q = p - 1; q >= pmin && *q == SLSMG_NOCHAR; q--)
304 + *q = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*q));
306 + *q = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*q));
309 + /* Remove overwritten chars to right */
310 + for (q = p + 1; q < pmax && *q == SLSMG_NOCHAR; q++)
311 + *q = SLSMG_BUILD_CHAR(' ',SLSMG_EXTRACT_COLOR(*q));
315 p = w->lines[w->_cury];
323 @@ -884,12 +1066,12 @@
328 + *pmax = *p1; /* Doesn't this assign beyond the end of the line? */
334 + if (p < pmax) /* How could it be? */
335 *p = SLSMG_BUILD_CHAR(ch, w->color);
338 --- slang-1.4.4.orig/src/slsmg.c
339 +++ slang-1.4.4/src/slsmg.c
341 SLsmg_write_nchars (str, strlen (str));
345 +void SLsmg_write_nstring (char *str, unsigned int n)
350 + /* Avoid a problem if a user accidently passes a negative value */
360 + memset (&mbstate, 0, sizeof (mbstate));
361 + while ((k = mbrtowc (&wc, str, MB_LEN_MAX, &mbstate)) &&
362 + k != (size_t)(-1) &&
366 + if (w < 0 || w > n)
368 + SLsmg_write_nwchars (&wc, 1);
373 + while (n-- > 0) SLsmg_write_nchars (&blank, 1);
376 void SLsmg_write_nstring (char *str, unsigned int n)
381 while (width++ < n) SLsmg_write_nchars (&blank, 1);
386 +/* FIXME: This function not UTF8'd yet - Edmund */
388 void SLsmg_write_wrapped_string (char *s, int r, int c,
389 unsigned int dr, unsigned int dc,
391 @@ -302,6 +338,123 @@
392 int SLsmg_Display_Eight_Bit = 128;
396 +void SLsmg_write_nwchars (wchar_t *str, unsigned int n)
398 + SLsmg_Char_Type *p, *prev, *q;
399 + int len, max_len, w, i;
402 +#ifndef IBMPC_SYSTEM
403 + int alt_char_set_flag;
405 + alt_char_set_flag = ((This_Color & ALT_CHAR_FLAG)
406 + && ((tt_Use_Blink_For_ACS == NULL)
407 + || (*tt_Use_Blink_For_ACS == 0)));
410 + if (Smg_Inited == 0)
412 + if (This_Row < Start_Row || This_Row >= Start_Row + Screen_Rows)
415 + max_len = Start_Col + Screen_Cols;
417 + p = SL_Screen[This_Row - Start_Row].neew + len - Start_Col;
420 + for (i = 0; i < n; i++, str) {
422 +#ifndef IBMPC_SYSTEM
423 + if (alt_char_set_flag)
424 + ch = Alt_Char_Set[ch & 0x7F];
429 + if (len + w <= max_len) {
431 + for (q = p; *q == SLSMG_NOCHAR; q--)
432 + *q = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*q));
433 + *q = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*q));
436 + *p++ = SLSMG_BUILD_CHAR(ch, This_Color), ++len;
437 + for (; --w; len++, p++)
440 + else if (len < max_len) {
441 + for (; len < max_len; len++, p++)
442 + *p = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*p));
446 + else if (ch == '\n' &&
447 + SLsmg_Newline_Behavior != SLSMG_NEWLINE_PRINTABLE) {
448 + SL_Screen[This_Row - Start_Row].flags |= TOUCHED;
449 + for (; len < max_len && *p == SLSMG_NOCHAR; len++, p++)
450 + *p = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*p));
451 + if (!SLsmg_Newline_Behavior)
455 + if (This_Row == Start_Row + Screen_Rows) {
456 + if (SLsmg_Newline_Behavior == SLSMG_NEWLINE_SCROLLS)
461 + p = SL_Screen[This_Row - Start_Row].neew;
464 + else if (ch == '\t' && (SLsmg_Tab_Width > 0)) {
465 + while (len < max_len) {
466 + *p = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*p));
468 + if (len % SLsmg_Tab_Width == 0)
472 + else if ((ch == 0x8) && SLsmg_Backspace_Moves) {
473 + /* not implemented */
475 + else if (!w && ch) {
476 + /* we could handle combining characters here, using prev */
479 + /* we should convert control characters to printable form here */
484 + SL_Screen[This_Row - Start_Row].flags |= TOUCHED;
485 + for (; len < max_len && *p == SLSMG_NOCHAR; len++, p++)
486 + *p = SLSMG_BUILD_CHAR(' ', SLSMG_EXTRACT_COLOR(*p));
490 +void SLsmg_write_char (wchar_t wc)
492 + SLsmg_write_nwchars (&wc, 1);
495 +void SLsmg_write_nchars (char *str, unsigned int n)
501 + memset (&mbstate, 0, sizeof (mbstate));
502 + while ((k = mbrtowc (&wc, str, n, &mbstate)) &&
503 + k != (size_t)(-1) &&
506 + SLsmg_write_nwchars (&wc, 1);
512 void SLsmg_write_nchars (char *str, unsigned int n)
514 register SLsmg_Char_Type *p, old, neew, color;
517 SLsmg_write_nchars (&ch, 1);
523 @@ -891,6 +1045,10 @@
528 + /* FIXME: We should convert broken wide characters to spaces
529 + before calling smart_puts */
531 SL_Screen[i].old[Screen_Cols] = 0;
532 SL_Screen[i].neew[Screen_Cols] = 0;
534 @@ -1334,9 +1492,16 @@
535 This_Row = r; This_Col = c;
539 +void SLsmg_fill_region (int r, int c, unsigned int dr, unsigned int dc, wchar_t ch)
541 + static wchar_t hbuf[16];
544 void SLsmg_fill_region (int r, int c, unsigned int dr, unsigned int dc, unsigned char ch)
546 static unsigned char hbuf[16];
551 @@ -1357,16 +1522,30 @@
553 ch = Alt_Char_Set[ch];
557 + for (i = 0; i < 16; i++)
560 if (ch != hbuf[0]) SLMEMSET ((char *) hbuf, (char) ch, 16);
563 for (This_Row = r; This_Row < rmax; This_Row++)
568 + SLsmg_write_nwchars (hbuf, dc % 16);
570 SLsmg_write_nchars ((char *) hbuf, dc % 16);
575 + SLsmg_write_nwchars (hbuf, 16);
577 SLsmg_write_nchars ((char *) hbuf, 16);
582 @@ -1381,14 +1560,22 @@
583 void SLsmg_write_color_chars (SLsmg_Char_Type *s, unsigned int len)
585 SLsmg_Char_Type *smax, sh;
587 + wchar_t buf[32], *b, *bmax;
589 char buf[32], *b, *bmax;
591 int color, save_color;
593 if (Smg_Inited == 0) return;
598 + bmax = b + sizeof (buf) / sizeof (SLsmg_Char_Type);
600 bmax = b + sizeof (buf);
603 save_color = This_Color;
605 @@ -1412,16 +1599,28 @@
610 + SLsmg_write_nwchars (buf, (int) (b - buf));
612 SLsmg_write_nchars (buf, (int) (b - buf));
619 + *b++ = SLSMG_EXTRACT_CHAR(sh);
621 *b++ = (char) SLSMG_EXTRACT_CHAR(sh);
627 + SLsmg_write_nwchars (buf, (unsigned int) (b - buf));
629 SLsmg_write_nchars (buf, (unsigned int) (b - buf));
632 This_Color = save_color;
634 @@ -1473,7 +1672,11 @@
635 SLsmg_set_color_in_region (int color, int r, int c, unsigned int dr, unsigned int dc)
641 SLsmg_Char_Type char_mask;
644 if (Smg_Inited == 0) return;
646 @@ -1498,14 +1701,22 @@
647 color = ((color & 0x7F) + Bce_Color_Offset) & 0x7F;
659 if ((tt_Use_Blink_For_ACS == NULL)
660 || (0 == *tt_Use_Blink_For_ACS))
669 @@ -1519,7 +1730,13 @@
674 + *s = SLSMG_BUILD_CHAR(SLSMG_EXTRACT_CHAR(*s),
675 + (SLSMG_EXTRACT_COLOR(*s) & color_mask)
678 *s = (*s & char_mask) | color;
683 --- slang-1.4.5/src/Makefile.in.foo 2002-06-12 19:30:09.000000000 -0400
684 +++ slang-1.4.5/src/Makefile.in 2002-06-12 19:31:13.000000000 -0400
686 #---------------------------------------------------------------------------
687 # There should be no need to change anything below here.
688 #---------------------------------------------------------------------------
690 +THIS_LIB = slang-utf8#
692 THIS_LIB_DEFINES = -DSLANG
693 ELF_MAJOR_VERSION = @slang_major_version@#
694 --- slang-1.4.9/src/sldisply.c.orig 2003-10-27 17:24:15.000000000 -0500
695 +++ slang-1.4.9/src/sldisply.c 2003-10-27 17:56:25.000000000 -0500
702 #if !defined(VMS) || (__VMS_VER >= 70000000)
703 # include <sys/time.h>
704 @@ -1426,14 +1427,25 @@
706 /* Highest bit represents the character set. */
707 #define COLOR_MASK 0x7F00
709 +# define COLOR_OF(x) (SLSMG_EXTRACT_COLOR(x) & 0x7F)
711 #define COLOR_OF(x) (((x)&COLOR_MASK)>>8)
713 #define CHAR_OF(x) ((x)&0x80FF)
715 #if SLTT_HAS_NON_BCE_SUPPORT
717 +static int bce_color_eqs (SLsmg_Char_Type a, SLsmg_Char_Type b)
719 + a = SLSMG_EXTRACT_COLOR(a) & 0x7F;
720 + b = SLSMG_EXTRACT_COLOR(b) & 0x7F;
722 static int bce_color_eqs (unsigned int a, unsigned int b)
730 @@ -1459,8 +1471,14 @@
731 : (Ansi_Color_Map[COLOR_OF(a)].mono == Ansi_Color_Map[COLOR_OF(b)].mono))
735 +#define CHAR_EQS(a, b) ((a) == (b)\
736 + || (SLSMG_EXTRACT_CHAR(a) == SLSMG_EXTRACT_CHAR(b)\
737 + && COLOR_EQS((a), (b))))
739 #define CHAR_EQS(a, b) (((a) == (b))\
740 || ((CHAR_OF(a)==CHAR_OF(b)) && COLOR_EQS(a,b)))
743 /* The whole point of this routine is to prevent writing to the last column
744 * and last row on terminals with automatic margins.
745 @@ -1488,9 +1506,58 @@
750 +/* FIXME: This duplicates the function above
752 +static void write_wstring_with_care (SLsmg_Char_Type *str, unsigned int len)
756 + if (str == NULL) return;
758 + if (Automatic_Margins && (Cursor_r + 1 == SLtt_Screen_Rows))
760 + if (len + (unsigned int) Cursor_c >= (unsigned int) SLtt_Screen_Cols)
762 + /* For now, just do not write there. Later, something more
763 + * sophisticated will be implemented.
765 + if (SLtt_Screen_Cols > Cursor_c)
767 + len = SLtt_Screen_Cols - Cursor_c - 1;
768 + while (len > 0 && str[len] == SLSMG_NOCHAR)
775 + memset (&mbstate, 0, sizeof (mbstate));
778 + SLsmg_Char_Type c = *str++;
779 + char buf[MB_LEN_MAX];
782 + if (c == SLSMG_NOCHAR)
785 + n = wcrtomb (buf, c, &mbstate);
786 + if (n == (size_t)(-1))
794 static void send_attr_str (SLsmg_Char_Type *s)
797 + SLsmg_Char_Type out[SLTT_MAX_SCREEN_COLS], ch, *p;
799 unsigned char out[SLTT_MAX_SCREEN_COLS], ch, *p;
801 register SLtt_Char_Type attr;
802 register SLsmg_Char_Type sh;
803 int color, last_color = -1;
804 @@ -1498,8 +1565,13 @@
806 while (0 != (sh = *s++))
809 + ch = SLSMG_EXTRACT_CHAR(sh);
810 + color = SLSMG_EXTRACT_COLOR(sh);
813 color = ((int) sh & 0xFF00) >> 8;
816 #if SLTT_HAS_NON_BCE_SUPPORT
818 @@ -1511,8 +1583,12 @@
820 if (SLtt_Use_Ansi_Colors) attr = Ansi_Color_Map[color & 0x7F].fgbg;
821 else attr = Ansi_Color_Map[color & 0x7F].mono;
825 + if (SLSMG_EXTRACT_COLOR(sh) & 0x80) /* alternate char set */
827 if (sh & 0x8000) /* alternate char set */
830 if (SLtt_Use_Blink_For_ACS)
832 @@ -1534,8 +1610,12 @@
837 + write_wstring_with_care (out, p-out);
840 write_string_with_care ((char *) out);
842 Cursor_c += (int) (p - out);
845 @@ -1558,8 +1638,12 @@
850 + if (p != out) write_wstring_with_care (out, p-out);
853 if (p != out) write_string_with_care ((char *) out);
855 Cursor_c += (int) (p - out);
858 @@ -1686,7 +1770,11 @@
863 + if (SLSMG_EXTRACT_COLOR(*qq))
868 SLtt_normal_video ();
870 @@ -1701,7 +1789,11 @@
871 /* Find where the last non-blank character on old/new screen is */
875 + if (SLSMG_EXTRACT_CHAR(*(pmax-1)) == ' ')
877 if (CHAR_EQS(*(pmax-1), ' '))
880 /* If we get here, then we can erase to the end of the line to create
881 * the final space. However, this will only work _if_ erasing will
882 @@ -1752,7 +1844,11 @@
885 /* Try use use erase to bol if possible */
887 + if ((Del_Bol_Str != NULL) && (SLSMG_EXTRACT_CHAR(*neww) == ' '))
889 if ((Del_Bol_Str != NULL) && (CHAR_OF(*neww) == ' '))
893 SLsmg_Char_Type blank;
894 @@ -1781,7 +1877,11 @@
897 SLtt_goto_rc (row, ofs - 1);
899 + SLtt_reverse_video (SLSMG_EXTRACT_COLOR (blank));
901 SLtt_reverse_video (COLOR_OF(blank));
903 tt_write_string (Del_Bol_Str);
906 @@ -1978,7 +2078,11 @@
911 + SLtt_reverse_video (SLSMG_EXTRACT_COLOR (space_char));
913 SLtt_reverse_video (COLOR_OF(space_char));